Merge "wcnss: Download NV during SSR"
diff --git a/Documentation/arm/msm/msm_sharedmem.txt b/Documentation/arm/msm/msm_sharedmem.txt
new file mode 100644
index 0000000..d9c939e
--- /dev/null
+++ b/Documentation/arm/msm/msm_sharedmem.txt
@@ -0,0 +1,115 @@
+Introduction
+============
+
+This is a new platform driver for newly introduced UIO devices
+to facilitate clients in Userspace.
+
+Hardware description
+====================
+This driver does not implement any specific hardware driver.
+
+Software description
+====================
+
+Design
+======
+
+The goal of this driver is to ensure there is no security lapse in the
+Userspace clients' functionality. This new driver uses the existing
+UIO framework to facilitate the clients to be able to memory map their
+respective allotted shared memory address in the client's address space.
+
+				  |
+    Userspace			  |		Kernel space
+ +--------------+	+---------------+	+---------------+
+ |   Client	|	|  Shared	|	|  shrdmem_uio	|
+ |		<------->    Memory	<------->  driver	|
+ +--------------+	+---------------+	+---------------+
+				  |
+				  |
+
+The shared memory (a transport buffer) address is unique for each
+individual client and is made available to the driver via device tree.
+
+For a given client the probe would be called once in the shrdmem_uio driver.
+This driver would parse the device tree and register a new UIO device with kernel
+available under /dev/uioX (where X would start from zero, being serially
+incremented for the next UIO device probed)
+
+The client in Userspace would be able to access the respective UIO device
+under the sysfs entry(/sys/class/uio/uioX) upon verifying the name and version
+of the device under this sysfs node. Once verified it could access the physical
+address under /sys/class/uio/uioX/maps/map0/addr
+
+The client would request for memory mapping which would be taken care of in the
+kernel space by the UIO framework. No explicit mmap() implementation required by
+the shrdmem_uio driver.
+
+Power Management
+================
+Does not implement any power management.
+
+SMP/multi-core
+==============
+
+The platform driver would be loaded/probed once per client.
+DTS files will be looked up for shared memory addresses and sizes for all the clients.
+The UIO char device will be created under /dev/uioX.
+
+This being one time activity for a given client it does not require SMP/multi-core safety.
+
+Security
+========
+
+The devices (/dev/uioX) would have permission checks for restricted access
+
+Performance
+===========
+
+None.
+
+Interface
+=========
+
+This driver does not export any APIs for kernel.
+Android user space can access the shared memory by mmaping it.
+
+Driver parameters
+=================
+
+None.
+
+Config options
+==============
+
+None.
+
+Dependencies
+============
+
+The only dependency is the kernel device tree files for the
+Userspace client details.
+
+User space utilities
+====================
+This driver communicates with the following user space clients/utilities:
+
+Remote File System:
+ - Based on Qualcomm Messaging Interface (QMI)
+ - This service enables the modules on the MSM modem processor to
+   read data from and write data to the embedded multimedia card (eMMC),
+   which is solely controlled by the applications processor.
+
+Remote File System Access (QMI_RFSA):
+ - Based on Qualcomm Messaging Interface (QMI)
+ - This service provides access from the Hexagon processor to a High-Level
+   Operating Sytem (HLOS) file system
+Other
+=====
+
+None.
+
+Known issues
+============
+
+None.
diff --git a/Documentation/devicetree/bindings/arm/msm/spm-v2.txt b/Documentation/devicetree/bindings/arm/msm/spm-v2.txt
index d9a0d59..f969e2f 100644
--- a/Documentation/devicetree/bindings/arm/msm/spm-v2.txt
+++ b/Documentation/devicetree/bindings/arm/msm/spm-v2.txt
@@ -40,6 +40,8 @@
 - qcom,saw2-spm-cmd-wfi: The WFI command sequence
 - qcom,saw2-spm-cmd-ret: The Retention command sequence
 - qcom,saw2-spm-cmd-spc: The Standalone PC command sequence
+- qcom,saw2-spm-cmd-pc-no-rpm: The Power Collapse command sequence where APPS
+	proc won't inform the RPM.
 - qcom,saw2-spm-cmd-pc: The Power Collapse command sequence
 - qcom,saw2-spm-cmd-gdhs: L2 GDHS command sequence
 - qcom,L2-spm-is-apcs-master: Boolean indicates if the target uses L2 SAW to
diff --git a/Documentation/devicetree/bindings/fb/mdss-edp.txt b/Documentation/devicetree/bindings/fb/mdss-edp.txt
index 3d7e5a2..e564cd5 100644
--- a/Documentation/devicetree/bindings/fb/mdss-edp.txt
+++ b/Documentation/devicetree/bindings/fb/mdss-edp.txt
@@ -3,6 +3,9 @@
 MDSS EDP is a edp driver which supports panels that are compatable with
 VESA EDP display interface specification.
 
+When configuring the optional properties for external backlight, one should also
+configure the gpio that drives the pwm to it.
+
 Required properties
 - compatible :				Must be "qcom,mdss-edp".
 - reg :						Offset and length of the register set for the
@@ -12,8 +15,6 @@
 - vdda-supply :				Phandle for vdd regulator device node.
 - gpio-panel-en	:			GPIO for supplying power to panel and backlight
 							driver.
-- qcom,panel-lpg-channel :		LPG channel for backlight.
-- qcom,panel-pwm-period :		PWM period in microseconds.
 - status :				A string that has to be set to "okay/ok" to enable
 						the driver. By default this property will be set to
 						"disable". Will be set to "ok/okay" status for
@@ -37,4 +38,8 @@
 		gpio-panel-hpd = <&msmgpio 102 0>;
 	};
 
+Optional properties
+- qcom,panel-lpg-channel :		LPG channel for backlight.
+- qcom,panel-pwm-period :		PWM period in microseconds.
+
 
diff --git a/Documentation/devicetree/bindings/fb/mdss-mdp.txt b/Documentation/devicetree/bindings/fb/mdss-mdp.txt
index 8f17a90..a4e61e8 100644
--- a/Documentation/devicetree/bindings/fb/mdss-mdp.txt
+++ b/Documentation/devicetree/bindings/fb/mdss-mdp.txt
@@ -141,6 +141,11 @@
 				restricted for a source surface pipe. If this
 				property is not specified, no such restriction
 				would be applied.
+- qcom,mdss-pipe-rgb-fixed-mmb: Array of indexes describing fixed Memory Macro
+				Blocks (MMBs) for rgb pipes. First value denotes
+				total numbers of MMBs per pipe while values, if
+				any, following first one denotes indexes of MMBs
+				to that RGB pipe.
 
 Optional subnodes:
 Child nodes representing the frame buffer virtual devices.
@@ -194,6 +199,10 @@
 		qcom,mdss-pipe-vig-fetch-id = <1 4 7>;
 		qcom,mdss-pipe-rgb-fetch-id = <16 17 18>;
 		qcom,mdss-pipe-dma-fetch-id = <10 13>;
+		qcom,mdss-pipe-rgb-fixed-mmb =	<2 0 1>,
+						<2 2 3>,
+						<2 4 5>,
+						<2 6 7>;
 		qcom,mdss-smp-data = <22 4096>;
 		qcom,mdss-rot-block-size = <64>;
 		qcom,mdss-smp-mb-per-pipe = <2>;
diff --git a/Documentation/devicetree/bindings/input/touchscreen/gt9xx/gt9xx.txt b/Documentation/devicetree/bindings/input/touchscreen/gt9xx/gt9xx.txt
index fdba7c2..f2ca95b 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/gt9xx/gt9xx.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/gt9xx/gt9xx.txt
@@ -30,6 +30,7 @@
 				min y, max x and max y values.
  - goodix,i2c-pull-up	: To specify pull up is required.
  - goodix,no-force-update	: To specify force update is allowed.
+ - goodix,enable-power-off	: Power off touchscreen during suspend.
  - goodix,button-map	: Button map of key codes. The number of key codes
 				depend on panel.
  - goodix,cfg-data0	: Touch screen controller config data group 0. Ask vendor
@@ -50,6 +51,7 @@
 				to provide that.
  - goodix,cfg-data5	: Touch screen controller config data group 5. Ask vendor
 				to provide that.
+ - goodix,fw-name	: Touch screen controller firmware file name.
 Example:
 i2c@f9927000 {
 		goodix@5d {
@@ -84,5 +86,6 @@
 				20 21 22 24 26 28 29 2A FF FF
 				FF FF FF FF FF FF FF 22 22 22
 				22 22 22 FF 07 01];
+			goodix,fw_name = "gtp_fw.bin";
 		};
 };
diff --git a/Documentation/devicetree/bindings/leds/leds-qpnp.txt b/Documentation/devicetree/bindings/leds/leds-qpnp.txt
index af6a0b5..749c594 100644
--- a/Documentation/devicetree/bindings/leds/leds-qpnp.txt
+++ b/Documentation/devicetree/bindings/leds/leds-qpnp.txt
@@ -10,13 +10,13 @@
 node will further contain the type of LED supported and its
 properties.  At least one child node is required for each LED
 module.  Each must have the required properties below, in addition
-to the properties for the LED type, WLED, Flash or RGB.
+to the properties for the LED type, WLED, Flash, RGB and MPP.
 
 Required properties for each child node, WLED, Flash and RGB:
 - compatible		: should be "qcom,leds-qpnp"
 - qcom,id		: must be one of values supported in enum qpnp_led
 - label			: type of led that will be used, ie "wled"
-- qcom,max-current	: maximum current that the LED can sustain
+- qcom,max-current	: maximum current that the LED can sustain in mA
 - linux,name		: name of the led that is used in led framework
 
 WLED is primarily used as display backlight. Display subsystem uses
@@ -85,6 +85,7 @@
 - qcom,vin-ctrl: select input source, supported values are 0 to 3
 - qcom,use-blink: Use blink sysfs entry for switching into lpg mode.  For optimal use, set default mode to pwm.  All required lpg parameters must be supplied.
 - qcom,min-brightness - Lowest possible brightness supported on this LED other than 0.
+- qcom,current-setting: default current value for wled used as button backlight in mA
 
 Required properties for PWM mode only:
 - qcom,pwm-channel: pwm channel the led will operate on
@@ -131,6 +132,22 @@
 
 Example:
 
+	qcom,leds@a100 {
+		status = "okay";
+		qcom,led_mpp_2 {
+			label = "mpp";
+			linux,name = "button-backlight";
+			linux,default-trigger = "hr-trigger";
+			qcom,default-state = "off";
+			qcom,current-setting = <20>;
+			qcom,max-current = <40>;
+			qcom,id = <6>;
+			qcom,source-sel = <1>;
+			qcom,mode-ctrl = <0x61>;
+			qcom,mode = "manual";
+		};
+	};
+
 	qcom,leds@a200 {
 		status = "okay";
 		qcom,led_mpp_3 {
diff --git a/Documentation/devicetree/bindings/media/video/msm-eeprom.txt b/Documentation/devicetree/bindings/media/video/msm-eeprom.txt
index 893c033..c7821f5 100644
--- a/Documentation/devicetree/bindings/media/video/msm-eeprom.txt
+++ b/Documentation/devicetree/bindings/media/video/msm-eeprom.txt
@@ -10,7 +10,7 @@
 - cell-index: eeprom hardware core index
 - compatible :
     - "qcom,eeprom"
-- reg : offset and length of eeprom device registers.
+- reg : offset of eeprom device registers.
 - qcom,eeprom-name : should specify relevant names of the eeprom module
     library.
 - qcom,slave-addr : should specify the slave address of the eeprom.
@@ -29,7 +29,6 @@
     data type, delay in ms. size 0 stand for not used.
     - address type : 1 byte, 2 word.
     - data type : 1 byte, 2 word.
-- cam_vdig-supply : should contain regulator to be used for the digital vdd.
 - cam_vio-supply : should contain regulator to be used for the IO vdd.
 - qcom,cam-vreg-name : should specify the regulator name to be used for
     this eeprom.
@@ -57,6 +56,7 @@
 Optional properties:
 - qcom,pageen%d : number %d page enable reg size, start address, address type,
     data, data type, delay in ms. size 0 stand for not used.
+- cam_vdig-supply : should contain regulator to be used for the digital vdd.
 
 Example:
 
diff --git a/Documentation/devicetree/bindings/nfc/nfc-nci.txt b/Documentation/devicetree/bindings/nfc/nfc-nci.txt
index cdd1e68..5c53470 100644
--- a/Documentation/devicetree/bindings/nfc/nfc-nci.txt
+++ b/Documentation/devicetree/bindings/nfc/nfc-nci.txt
@@ -10,23 +10,26 @@
 - qcom,irq-gpio: specific gpio for read interrupt.
 - qcom,clk-src: nfc clock source ("BBCLK2", "RFCLK3", "GPCLK", ...)
 - qcom,clk-en-gpio: msm gpio clock,used ony if clock source is msm gpio
+- vlogic-supply: LDO for power supply
 - interrupt-parent: Should be phandle for the interrupt controller
                     that services interrupts for this device.
 - interrupts: should contain the NFC interrupt. NFC has one read interrupt.
 - qcom,clk-gpio: pmic gpio on which bbclk2 signal is coming.
 
-Example:
+LDO example:
 
-	i2c@f9925000 { /* BLSP1 QUP3 */
-	    nfc-nci@0e {
-	        compatible = "qcom,nfc-nci";
-		reg = <0x0e>;
-		qcom,irq-gpio = <&msmgpio 21 0x00>;
-		qcom,dis-gpio = <&msmgpio 20 0x00>;
-		qcom,clk-src = "BBCLK2";
-		qcom,clk-en-gpio = <&msmgpio 0 0x00>;
-		interrupt-parent = <&msmgpio>;
-		interrupts = <21 0>;
-		qcom,clk-gpio = <&pm8226_gpios 3 0>;
-	    };
+	i2c@f9925000 { /* BLSP-1 QUP-3 */
+		nfc-nci@e {
+			compatible = "qcom,nfc-nci";
+			reg = <0x0e>;
+			qcom,irq-gpio = <&msmgpio 77 0x00>;
+			qcom,dis-gpio = <&msmgpio 93 0x00>;
+			qcom,clk-en-gpio = <&msmgpio 78 0x00>;
+			qcom,clk-src = "GPCLK";
+			interrupt-parent = <&msmgpio>;
+			interrupts = <77 0>;
+			qcom,clk-gpio = <&msmgpio 75 0x00>;
+			vlogic-supply = <&pm8110_l14>;
+		};
 	};
+
diff --git a/Documentation/devicetree/bindings/power/qpnp-bms.txt b/Documentation/devicetree/bindings/power/qpnp-bms.txt
index b076475..dc07d71 100644
--- a/Documentation/devicetree/bindings/power/qpnp-bms.txt
+++ b/Documentation/devicetree/bindings/power/qpnp-bms.txt
@@ -56,10 +56,14 @@
 - qcom,low-voltage-threshold : The battery voltage threshold in micro-volts for
 			when the BMS tries to wake up and hold a wakelock to
 			ensure a clean shutdown.
+- qcom,low-voltage-calculate-soc-ms : The time period between subsequent
+			SoC recalculations when the current voltage is below
+			qcom,low-voltage threshold. This takes precedence over
+			qcom,low-soc-calculate-soc-ms.
 - qcom,low-soc-calculate-soc-ms : The time period between subsequent
 			SoC recalculations when the current SoC is below
-			qcom,low-soc-calculate-soc-threshold or when battery
-			voltage is below qcom,low-voltage-threshold.
+			qcom,low-soc-calculate-soc-threshold. This takes
+			precedence over qcom,calculate-soc-ms.
 - qcom,calculate-soc-ms : The time period between subsequent SoC
 			recalculations when the current SoC is above or equal
 			qcom,low-soc-calculate-soc-threshold.
@@ -160,6 +164,7 @@
 	qcom,adjust-soc-low-threshold = <15>;
 	qcom,low-soc-calculate-soc-threshold = <15>;
 	qcom,low-voltage-threshold = <3420000>;
+	qcom,low-voltage-calculate-soc-ms = <1000>;
 	qcom,low-soc-calculate-soc-ms = <5000>;
 	qcom,calculate-soc-ms = <20000>;
 	qcom,chg-term-ua = <100000>;
diff --git a/Documentation/devicetree/bindings/power/qpnp-charger.txt b/Documentation/devicetree/bindings/power/qpnp-charger.txt
index 5425c92..7d8fe0a 100644
--- a/Documentation/devicetree/bindings/power/qpnp-charger.txt
+++ b/Documentation/devicetree/bindings/power/qpnp-charger.txt
@@ -93,6 +93,16 @@
 					set, the charger ovp status is monitored in software.
 - qcom,ext-ovp-present			Indicates if an external OVP exists which reduces the
 					overall input resistance of the charge path.
+- qcom,ibat-calibration-enabled		Indicates if ibat calibration is enabled. This is
+					required for devices which have a ibat trim error
+					causing ibatmax to go out of spec.
+- qcom,power-stage-reduced		Indicates if power stage workaround is enabled. This work
+					around reduces the power stage segments while charging
+					under high load during low battery voltages. It's for
+					improving IADC accuracy while board has a bad layout.
+- qcom,use-external-rsense		A boolean that controls whether BMS will use
+					an external sensor resistor instead of the default
+					RDS of the batfet.
 
 Sub node required structure:
 - A qcom,chg node must be a child of an SPMI node that has specified
diff --git a/Documentation/devicetree/bindings/sound/qcom-audio-dev.txt b/Documentation/devicetree/bindings/sound/qcom-audio-dev.txt
index 5e686a4f..56bdc59 100644
--- a/Documentation/devicetree/bindings/sound/qcom-audio-dev.txt
+++ b/Documentation/devicetree/bindings/sound/qcom-audio-dev.txt
@@ -407,6 +407,17 @@
 Required properties:
 - compatible : "qcom,msm8974-audio-taiko"
 - qcom,model : The user-visible name of this sound card.
+- reg : Offset and length of the register region(s) for MI2S/PCM MUX
+- reg-names : Register region name(s) referenced in reg above
+	 Required register resource entries are:
+	 "lpaif_pri_mode_muxsel": Physical address of MUX to select between
+				  Primary PCM and Primary MI2S
+	 "lpaif_sec_mode_muxsel": Physical address of MUX to select between
+				  Secondary PCM and Secondary MI2S
+	 "lpaif_tert_mode_muxsel": Physical address of MUX to select between
+				   Primary PCM and Tertiary MI2S
+	 "lpaif_quat_mode_muxsel": Physical address of MUX to select between
+				   Secondary PCM and Quarternary MI2S
 - qcom,audio-routing : A list of the connections between audio components.
   Each entry is a pair of strings, the first being the connection's sink,
   the second being the connection's source.
diff --git a/Documentation/devicetree/bindings/uio/msm_sharedmem.txt b/Documentation/devicetree/bindings/uio/msm_sharedmem.txt
new file mode 100644
index 0000000..5af50da
--- /dev/null
+++ b/Documentation/devicetree/bindings/uio/msm_sharedmem.txt
@@ -0,0 +1,13 @@
+msm_sharedmem provides the shared memory addresses for various clients in user-space
+
+Required properties:
+- compatible:		Must be "qcom,sharedmem-uio"
+- reg : The address and size of the shared memory. The address/sizes may vary.
+- reg-names : indicates various client-names.
+
+Example:
+	msm_sharedmem {
+		compatible = "qcom,sharedmem-uio";
+		reg = <0x0dc80000 0x00180000>,
+		reg-names = "rmtfs";
+	};
diff --git a/Documentation/devicetree/bindings/usb/msm-hsusb.txt b/Documentation/devicetree/bindings/usb/msm-hsusb.txt
index e7eae76..714311e 100644
--- a/Documentation/devicetree/bindings/usb/msm-hsusb.txt
+++ b/Documentation/devicetree/bindings/usb/msm-hsusb.txt
@@ -86,6 +86,11 @@
 	for detection of dp line transition during VDD minimization.
 - qcom,hsusb-otg-dmsehv-int: If present, indicates mpm interrupt to be configured
 	for detection of dm line transition during VDD minimization.
+- qcom,ahb-async-bridge-bypass: If present, indicates that enable AHB2AHB By Pass
+	mode with device controller for better throughput. With this mode, USB Core
+	runs using PNOC clock and synchronous to it. Hence it is must to have proper
+	"qcom,msm_bus,vectors" to have high bus frequency. User shouldn't try to
+	enable this feature without proper bus voting.
 
 Example HSUSB OTG controller device node :
 	usb@f9690000 {
@@ -176,12 +181,19 @@
 - qcom,android-usb-cdrom : if this property is present then device creates
   a new LUN as CD-ROM
 - qcom,android-usb-internal-ums : if this property is present then device
-  creates a new LUN as internal usb mass storage
+  creates a new LUN as internal usb mass storage.
+- qcom,streaming-func : add list of usb function name. If mention usb function
+  is being enable as part of USB composition, streaming mode is enable with
+  usb device controller to get better throughput. NOTE: Inverted CRC and
+  turnaround timeout is observed on enabling streaming. Hence it is required
+  to see these errors and number of erros on enabling this at USB level to make
+  final decision to enable this feature or not.
 Example Android USB device node :
 	android_usb@fc42b0c8 {
 		compatible = "qcom,android-usb";
 		reg = <0xfc42b0c8 0xc8>;
 		qcom,android-usb-swfi-latency = <1>;
+		qcom,streaming-func = "rndis","mtp";
 	};
 
 
diff --git a/Documentation/power/power_supply_class.txt b/Documentation/power/power_supply_class.txt
index 9f16c51..211831d 100644
--- a/Documentation/power/power_supply_class.txt
+++ b/Documentation/power/power_supply_class.txt
@@ -84,6 +84,8 @@
 HEALTH - represents health of the battery, values corresponds to
 POWER_SUPPLY_HEALTH_*, defined in battery.h.
 
+VOLTAGE_OCV - open circuit voltage of the battery.
+
 VOLTAGE_MAX_DESIGN, VOLTAGE_MIN_DESIGN - design values for maximal and
 minimal power supply voltages. Maximal/minimal means values of voltages
 when battery considered "full"/"empty" at normal conditions. Yes, there is
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index d43e69bf..4b544b7 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -69,6 +69,18 @@
 arch-$(CONFIG_CPU_32v4)		:=-D__LINUX_ARM_ARCH__=4 -march=armv4
 arch-$(CONFIG_CPU_32v3)		:=-D__LINUX_ARM_ARCH__=3 -march=armv3
 
+# Since 'cortex-a15' is a superset of the 'armv7-a' arch spec, we need to
+# explicitly redefine the arch options to not include '-march=armv7-a' when
+# generating code for Krait, which is compatible with the instruction set of the
+# Cortex-A15, because GCC will warn us about ambiguous ISA restrictions caused
+# by seemingly conflicting -march and -mcpu options.
+# If $(CC) does not support the -mcpu=cortex-a15 option, fall back on passing
+# -march=armv7-a to specify the ISA restriction, though this is suboptimal. To
+# keep things simpler, we don't bother with a fallback option if the compiler
+# doesn't even support -march=armv7-a, since in that situation we would have
+# bigger problems.
+arch-$(CONFIG_ARCH_MSM_KRAIT)	:=-D__LINUX_ARM_ARCH__=7 $(call cc-option,-mcpu=cortex-a15,-march=armv7-a)
+
 # This selects how we optimise for the processor.
 tune-$(CONFIG_CPU_ARM610)	:=-mtune=arm610
 tune-$(CONFIG_CPU_ARM710)	:=-mtune=arm710
diff --git a/arch/arm/boot/dts/apq8026-v1-cdp.dts b/arch/arm/boot/dts/apq8026-v1-cdp.dts
index d7e283b..b9ec6f9 100644
--- a/arch/arm/boot/dts/apq8026-v1-cdp.dts
+++ b/arch/arm/boot/dts/apq8026-v1-cdp.dts
@@ -13,7 +13,7 @@
 
 /dts-v1/;
 /include/ "apq8026-v1.dtsi"
-/include/ "msm8226-cdp.dtsi"
+/include/ "msm8226-720p-cdp.dtsi"
 
 / {
 	model = "Qualcomm APQ 8026 CDP";
diff --git a/arch/arm/boot/dts/apq8026-v1-mtp.dts b/arch/arm/boot/dts/apq8026-v1-mtp.dts
index d24875c..c2fc72c 100644
--- a/arch/arm/boot/dts/apq8026-v1-mtp.dts
+++ b/arch/arm/boot/dts/apq8026-v1-mtp.dts
@@ -13,7 +13,7 @@
 
 /dts-v1/;
 /include/ "apq8026-v1.dtsi"
-/include/ "msm8226-mtp.dtsi"
+/include/ "msm8226-720p-mtp.dtsi"
 
 / {
 	model = "Qualcomm APQ 8026 MTP";
diff --git a/arch/arm/boot/dts/apq8026-v1-xpm.dts b/arch/arm/boot/dts/apq8026-v1-xpm.dts
index f69511b..b435018 100644
--- a/arch/arm/boot/dts/apq8026-v1-xpm.dts
+++ b/arch/arm/boot/dts/apq8026-v1-xpm.dts
@@ -13,7 +13,7 @@
 
 /dts-v1/;
 /include/ "apq8026-v1.dtsi"
-/include/ "msm8226-cdp.dtsi"
+/include/ "msm8226-720p-cdp.dtsi"
 
 / {
 	model = "Qualcomm APQ 8026 XPM";
diff --git a/arch/arm/boot/dts/apq8026-v2-1080p-cdp.dts b/arch/arm/boot/dts/apq8026-v2-1080p-cdp.dts
new file mode 100644
index 0000000..5294628
--- /dev/null
+++ b/arch/arm/boot/dts/apq8026-v2-1080p-cdp.dts
@@ -0,0 +1,22 @@
+/* Copyright (c) 2013, The Linux Foundation. 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.
+ */
+
+
+/dts-v1/;
+/include/ "apq8026-v2.dtsi"
+/include/ "msm8226-1080p-cdp.dtsi"
+
+/ {
+	model = "Qualcomm APQ 8026v2 CDP";
+	compatible = "qcom,apq8026-cdp", "qcom,apq8026", "qcom,cdp";
+	qcom,board-id = <1 2>;
+};
diff --git a/arch/arm/boot/dts/apq8026-v2-1080p-mtp.dts b/arch/arm/boot/dts/apq8026-v2-1080p-mtp.dts
new file mode 100644
index 0000000..0ea98f5
--- /dev/null
+++ b/arch/arm/boot/dts/apq8026-v2-1080p-mtp.dts
@@ -0,0 +1,22 @@
+/* Copyright (c) 2013, The Linux Foundation. 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.
+ */
+
+
+/dts-v1/;
+/include/ "apq8026-v2.dtsi"
+/include/ "msm8226-1080p-mtp.dtsi"
+
+/ {
+	model = "Qualcomm APQ 8026v2 MTP";
+	compatible = "qcom,apq8026-mtp", "qcom,apq8026", "qcom,mtp";
+	qcom,board-id = <8 2>;
+};
diff --git a/arch/arm/boot/dts/apq8026-v2-720p-cdp.dts b/arch/arm/boot/dts/apq8026-v2-720p-cdp.dts
new file mode 100644
index 0000000..cb2226a
--- /dev/null
+++ b/arch/arm/boot/dts/apq8026-v2-720p-cdp.dts
@@ -0,0 +1,22 @@
+/* Copyright (c) 2013, The Linux Foundation. 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.
+ */
+
+
+/dts-v1/;
+/include/ "apq8026-v2.dtsi"
+/include/ "msm8226-720p-cdp.dtsi"
+
+/ {
+	model = "Qualcomm APQ 8026v2 CDP";
+	compatible = "qcom,apq8026-cdp", "qcom,apq8026", "qcom,cdp";
+	qcom,board-id = <1 0>;
+};
diff --git a/arch/arm/boot/dts/apq8026-v2-720p-mtp.dts b/arch/arm/boot/dts/apq8026-v2-720p-mtp.dts
new file mode 100644
index 0000000..439b3d7
--- /dev/null
+++ b/arch/arm/boot/dts/apq8026-v2-720p-mtp.dts
@@ -0,0 +1,22 @@
+/* Copyright (c) 2013, The Linux Foundation. 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.
+ */
+
+
+/dts-v1/;
+/include/ "apq8026-v2.dtsi"
+/include/ "msm8226-720p-mtp.dtsi"
+
+/ {
+	model = "Qualcomm APQ 8026v2 MTP";
+	compatible = "qcom,apq8026-mtp", "qcom,apq8026", "qcom,mtp";
+	qcom,board-id = <8 0>;
+};
diff --git a/arch/arm/boot/dts/apq8026-v2-cdp.dts b/arch/arm/boot/dts/apq8026-v2-cdp.dts
deleted file mode 100644
index cb68779..0000000
--- a/arch/arm/boot/dts/apq8026-v2-cdp.dts
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright (c) 2013, The Linux Foundation. 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.
- */
-
-
-/dts-v1/;
-/include/ "apq8026-v2.dtsi"
-/include/ "msm8226-cdp.dtsi"
-
-/ {
-	model = "Qualcomm APQ 8026v2 CDP";
-	compatible = "qcom,apq8026-cdp", "qcom,apq8026", "qcom,cdp";
-	qcom,board-id = <1 0>;
-};
diff --git a/arch/arm/boot/dts/apq8026-v2-mtp.dts b/arch/arm/boot/dts/apq8026-v2-mtp.dts
deleted file mode 100644
index 40856c8..0000000
--- a/arch/arm/boot/dts/apq8026-v2-mtp.dts
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright (c) 2013, The Linux Foundation. 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.
- */
-
-
-/dts-v1/;
-/include/ "apq8026-v2.dtsi"
-/include/ "msm8226-mtp.dtsi"
-
-/ {
-	model = "Qualcomm APQ 8026v2 MTP";
-	compatible = "qcom,apq8026-mtp", "qcom,apq8026", "qcom,mtp";
-	qcom,board-id = <8 0>;
-};
diff --git a/arch/arm/boot/dts/apq8026-v2-xpm.dts b/arch/arm/boot/dts/apq8026-v2-xpm.dts
index 324516d..3133424 100644
--- a/arch/arm/boot/dts/apq8026-v2-xpm.dts
+++ b/arch/arm/boot/dts/apq8026-v2-xpm.dts
@@ -13,7 +13,7 @@
 
 /dts-v1/;
 /include/ "apq8026-v2.dtsi"
-/include/ "msm8226-cdp.dtsi"
+/include/ "msm8226-720p-cdp.dtsi"
 
 / {
 	model = "Qualcomm APQ 8026v2 XPM";
diff --git a/arch/arm/boot/dts/apq8074-dragonboard.dtsi b/arch/arm/boot/dts/apq8074-dragonboard.dtsi
index 8afd986..824b0ab 100644
--- a/arch/arm/boot/dts/apq8074-dragonboard.dtsi
+++ b/arch/arm/boot/dts/apq8074-dragonboard.dtsi
@@ -504,13 +504,6 @@
 	};
 
 	gpio@e300 { /* GPIO 36 */
-		qcom,mode = <1>;  /* QPNP_PIN_MODE_DIG_OUT */
-		qcom,output-type = <0>; /* QPNP_PIN_OUT_BUF_CMOS */
-		qcom,pull = <5>; /* QPNP_PIN_PULL_NO */
-		qcom,vin-sel = <2>; /* QPNP_PIN_VIN2 */
-		qcom,out-strength = <3>; /* QPNP_PIN_OUT_STRENGTH_HIGH */
-		qcom,src-sel = <3>; /* QPNP_PIN_SEL_FUNC_2 */
-		qcom,master-en = <1>;
 	};
 };
 
diff --git a/arch/arm/boot/dts/batterydata-qrd-4v2-2200mah.dtsi b/arch/arm/boot/dts/batterydata-qrd-4v2-2200mah.dtsi
new file mode 100644
index 0000000..53aa781
--- /dev/null
+++ b/arch/arm/boot/dts/batterydata-qrd-4v2-2200mah.dtsi
@@ -0,0 +1,105 @@
+/* Copyright (c) 2013, The Linux Foundation. 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.
+ */
+
+qcom,qrd-4v2-2200mah-data {
+	qcom,default-rbatt-mohm = <163>;
+	qcom,max-voltage-uv = <4200>;
+	qcom,fcc-mah = <2200>;
+	qcom,rbatt-capacitive-mohm = <0>;
+	qcom,v-cutoff-uv = <3400000>;
+	qcom,chg-term-ua = <100000>;
+	qcom,batt-id-kohm = <10>;
+	qcom,flat-ocv-threshold-uv = <3800000>;
+
+	qcom,fcc-temp-lut {
+		qcom,lut-col-legend = <(-20) 0 25 40 60>;
+		qcom,lut-data = <2167 2179 2234 2178 2164>;
+	};
+
+	qcom,pc-temp-ocv-lut {
+		qcom,lut-col-legend = <(-20) 0 25 40 60>;
+		qcom,lut-row-legend = <100 95 90 85 80>,
+				<75 70 65 60 55>,
+				<50 45 40 35 30>,
+				<25 20 15 10 9>,
+				<8 7 6 5 4>,
+				<3 2 1 0>;
+		qcom,lut-data = <4188 4184 4199 4176 4170>,
+				<4109 4124 4145 4124 4118>,
+				<4051 4082 4097 4077 4072>,
+				<3963 4024 4055 4034 4029>,
+				<3920 3971 4002 3993 3989>,
+				<3880 3932 3963 3957 3952>,
+				<3846 3892 3920 3913 3910>,
+				<3822 3859 3881 3873 3871>,
+				<3805 3834 3851 3845 3844>,
+				<3790 3813 3828 3823 3822>,
+				<3777 3796 3808 3805 3803>,
+				<3764 3784 3792 3790 3788>,
+				<3750 3775 3778 3777 3774>,
+				<3736 3766 3766 3761 3751>,
+				<3721 3752 3755 3745 3732>,
+				<3704 3733 3737 3729 3716>,
+				<3684 3707 3713 3707 3694>,
+				<3655 3686 3688 3682 3672>,
+				<3598 3661 3677 3671 3659>,
+				<3585 3655 3673 3669 3656>,
+				<3571 3644 3664 3663 3650>,
+				<3551 3626 3643 3648 3631>,
+				<3523 3598 3609 3618 3600>,
+				<3489 3561 3565 3578 3561>,
+				<3445 3514 3510 3529 3512>,
+				<3389 3453 3440 3468 3450>,
+				<3313 3372 3345 3386 3366>,
+				<3207 3252 3209 3262 3239>,
+				<3000 3000 3000 3000 3000>;
+	};
+
+	qcom,rbatt-sf-lut {
+		qcom,lut-col-legend = <(-20) 0 25 40 60>;
+		qcom,lut-row-legend = <100 95 90 85 80>,
+				<75 70 65 60 55>,
+				<50 45 40 35 30>,
+				<25 20 15 10 9>,
+				<8 7 6 5 4>,
+				<3 2 1 0>;
+		qcom,lut-data = <1371 224 100 79 74>,
+				<1358 242 100 80 74>,
+				<1358 242 103 80 74>,
+				<1195 257 107 82 75>,
+				<1171 256 112 84 77>,
+				<1149 250 119 89 79>,
+				<1144 232 114 90 79>,
+				<1150 225 101 83 76>,
+				<1175 227 98 81 76>,
+				<1210 232 98 82 76>,
+				<1260 236 98 82 77>,
+				<1329 242 100 84 77>,
+				<1421 251 100 86 79>,
+				<1536 263 101 81 76>,
+				<1671 280 100 80 74>,
+				<1830 304 100 81 75>,
+				<2036 338 101 82 76>,
+				<2326 443 103 82 76>,
+				<2788 708 112 88 79>,
+				<2890 747 115 90 80>,
+				<2755 676 117 89 79>,
+				<2750 716 118 87 78>,
+				<2916 765 119 87 79>,
+				<3336 833 123 89 80>,
+				<4214 920 133 92 81>,
+				<5615 1031 151 96 83>,
+				<7923 1188 192 104 89>,
+				<13252 1886 585 137 122>,
+				<43764 20050 47711 3680 16847>;
+	};
+};
diff --git a/arch/arm/boot/dts/dsi-panel-hx8379a-wvga-video.dtsi b/arch/arm/boot/dts/dsi-panel-hx8379a-wvga-video.dtsi
index 23b65f3..92e6fc1 100644
--- a/arch/arm/boot/dts/dsi-panel-hx8379a-wvga-video.dtsi
+++ b/arch/arm/boot/dts/dsi-panel-hx8379a-wvga-video.dtsi
@@ -81,14 +81,47 @@
 				00 00 00 00
 			39 01 00 00 00 00 24
 				E0 79 05 0F
-				14 26 20 3F
-				2A 43 04 0C
-				11 15 17 15
-				15 10 13 05
-				0F 14 26 20
-				3F 2A 43 04
-				0C 11 15 17
-				15 15 10 13
+				14 23 24 3F
+				30 46 06 10
+				13 16 17 16
+				16 13 18 05
+				0F 14 23 24
+				3F 30 46 06
+				10 13 16 17
+				16 16 13 18
+			39 01 00 00 00 00 80
+				C1 01 00 07
+				10 17 1D 2A
+				33 3A 43 4A
+				52 5B 64 6D
+				78 7F 88 90
+				98 A0 A9 B2
+				B9 C1 C9 D1
+				D7 DF E6 ED
+				F4 FA FD 00
+				00 00 00 00
+				00 00 00 00
+				00 08 10 18
+				20 28 30 38
+				40 47 4F 58
+				60 68 70 78
+				80 88 90 98
+				A0 A9 B1 B9
+				C1 C9 D1 D8
+				E0 E8 F0 F9
+				FE 00 00 00
+				00 00 00 00
+				00 00 00 08
+				10 18 1E 26
+				2E 34 3A 41
+				49 4F 58 5E
+				67 6F 77 80
+				88 8F 97 9F
+				A7 AF B8 BF
+				C7 D1 D8 E3
+				EA F6 FF 00
+				00 00 00 00
+				00 00 00 00
 			23 01 00 00 00 00 02
 				cc 02
 			39 01 00 00 00 00 05
diff --git a/arch/arm/boot/dts/dsi-panel-hx8389b-qhd-video.dtsi b/arch/arm/boot/dts/dsi-panel-hx8389b-qhd-video.dtsi
new file mode 100755
index 0000000..8f94502
--- /dev/null
+++ b/arch/arm/boot/dts/dsi-panel-hx8389b-qhd-video.dtsi
@@ -0,0 +1,135 @@
+/* Copyright (c) 2013, The Linux Foundation. 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.
+ */
+
+/*---------------------------------------------------------------------------
+ * This file is autogenerated file using gcdb parser. Please do not edit it.
+ * Update input XML file to add a new entry or update variable in this file
+ * VERSION = "1.0"
+ *---------------------------------------------------------------------------*/
+&mdss_mdp {
+	dsi_hx8389b_qhd_vid: qcom,mdss_dsi_hx8389b_qhd_video {
+		qcom,mdss-dsi-panel-name = "HX8389b qhd video mode dsi panel";
+		qcom,mdss-dsi-panel-controller = <&mdss_dsi0>;
+		qcom,mdss-dsi-panel-type = "dsi_video_mode";
+		qcom,mdss-dsi-panel-destination = "display_1";
+		qcom,mdss-dsi-panel-framerate = <60>;
+		qcom,mdss-dsi-virtual-channel-id = <0>;
+		qcom,mdss-dsi-stream = <0>;
+		qcom,mdss-dsi-panel-width = <540>;
+		qcom,mdss-dsi-panel-height = <960>;
+		qcom,mdss-dsi-h-front-porch = <48>;
+		qcom,mdss-dsi-h-back-porch = <96>;
+		qcom,mdss-dsi-h-pulse-width = <96>;
+		qcom,mdss-dsi-h-sync-skew = <0>;
+		qcom,mdss-dsi-v-front-porch = <9>;
+		qcom,mdss-dsi-v-pulse-width = <3>;
+		qcom,mdss-dsi-v-back-porch = <13>;
+		qcom,mdss-dsi-h-left-border = <0>;
+		qcom,mdss-dsi-h-right-border = <0>;
+		qcom,mdss-dsi-v-top-border = <0>;
+		qcom,mdss-dsi-v-bottom-border = <0>;
+		qcom,mdss-dsi-bpp = <24>;
+		qcom,mdss-dsi-color-order = <0>;
+		qcom,mdss-dsi-underflow-color = <0xff>;
+		qcom,mdss-dsi-border-color = <0>;
+		qcom,mdss-dsi-on-command = [
+				39 01 00 00 00 00 04
+					B9 FF 83 89
+				39 01 00 00 00 00 08
+					BA 41 93 00
+					16 A4 10 18
+				23 01 00 00 00 00 02
+					C6 08
+				39 01 00 00 00 00 03
+					BC 02 00
+				23 01 00 00 00 00 02
+					CC 02
+				39 01 00 00 00 00 14
+					B1 00 00 07
+					E8 50 10 11
+					98 f8 21 29
+					27 27 43 01
+					58 F0 00 E6
+				39 01 00 00 00 00 08
+					B2 00 00 78
+					0C 07 3F 80
+				39 01 00 00 00 00 18
+					b4 82 08 00
+					32 10 04 32
+					10 00 32 10
+					00 37 0a 40
+					08 37 0a 40
+					14 46 50 0a
+				39 01 00 00 00 00 39
+					d5 00 00 00
+					00 01 00 00
+					00 60 00 99
+					88 AA BB 88
+					23 88 01 88
+					67 88 45 01
+					23 88 88 88
+					88 88 88 99
+					BB AA 88 54
+					88 76 88 10
+					88 32 32 10
+					88 88 88 88
+					88 00 04 00
+					00 00 00 00
+					00
+				39 01 00 00 00 00 03
+					CB 07 07
+				39 01 00 00 00 00 05
+					BB 00 00 FF
+					80
+				39 01 00 00 00 00 04
+					DE 05 58 10
+				39 01 00 00 00 00 05
+					B6 00 8A 00
+					8A
+				39 01 00 00 00 00 23
+					E0 01 08 0C
+					1F 25 36 12
+					35 05 09 0D
+					10 11 0F 0F
+					1C 1D 01 08
+					0C 1F 25 36
+					12 35 05 09
+					0D 10 11 0F
+					0F 1C 1D
+				05 01 00 00 96 00 02
+					11 00
+				05 01 00 00 96 00 02
+					29 00
+		];
+		qcom,mdss-dsi-off-command = [05 01 00 00 32 00 02 28 00
+					05 01 00 00 78 00 02 10 00];
+		qcom,mdss-dsi-on-command-state = "dsi_lp_mode";
+		qcom,mdss-dsi-off-command-state = "dsi_lp_mode";
+		qcom,mdss-dsi-h-sync-pulse = <1>;
+		qcom,mdss-dsi-traffic-mode = <2>;
+		qcom,mdss-dsi-lane-map = <1>;
+		qcom,mdss-dsi-bllp-eof-power-mode;
+		qcom,mdss-dsi-bllp-power-mode;
+		qcom,mdss-dsi-lane-0-state;
+		qcom,mdss-dsi-lane-1-state;
+		qcom,mdss-dsi-panel-timings = [97 23 17 00 4B 53 1C 27 27 03 04 00];
+		qcom,mdss-dsi-t-clk-post = <0x04>;
+		qcom,mdss-dsi-t-clk-pre = <0x1b>;
+		qcom,mdss-dsi-bl-min-level = <26>;
+		qcom,mdss-dsi-bl-max-level = <255>;
+		qcom,mdss-dsi-dma-trigger = <4>;
+		qcom,mdss-dsi-mdp-trigger = <0>;
+		qcom,mdss-dsi-bl-pmic-control-type = "bl_ctrl_wled";
+		qcom,mdss-dsi-reset-sequence = <1 20>, <0 2>, <1 20>;
+
+	};
+};
diff --git a/arch/arm/boot/dts/dsi-panel-otm8018b-fwvga-video.dtsi b/arch/arm/boot/dts/dsi-panel-otm8018b-fwvga-video.dtsi
index 9477c56..393419b 100644
--- a/arch/arm/boot/dts/dsi-panel-otm8018b-fwvga-video.dtsi
+++ b/arch/arm/boot/dts/dsi-panel-otm8018b-fwvga-video.dtsi
@@ -256,7 +256,7 @@
 		qcom,mdss-dsi-panel-timings = [8B 1F 14 00 45 4A 19 23 23 03 04 00];
 		qcom,mdss-dsi-t-clk-post = <0x04>;
 		qcom,mdss-dsi-t-clk-pre = <0x1b>;
-		qcom,mdss-dsi-bl-min-level = <1>;
+		qcom,mdss-dsi-bl-min-level = <26>;
 		qcom,mdss-dsi-bl-max-level = <255>;
 		qcom,mdss-dsi-dma-trigger = <4>;
 		qcom,mdss-dsi-mdp-trigger = <0>;
diff --git a/arch/arm/boot/dts/dsi-panel-ssd2080m-720p-video.dtsi b/arch/arm/boot/dts/dsi-panel-ssd2080m-720p-video.dtsi
index bb8389f..b510e6b 100644
--- a/arch/arm/boot/dts/dsi-panel-ssd2080m-720p-video.dtsi
+++ b/arch/arm/boot/dts/dsi-panel-ssd2080m-720p-video.dtsi
@@ -30,9 +30,9 @@
 		qcom,mdss-dsi-h-back-porch = <24>;
 		qcom,mdss-dsi-h-pulse-width = <14>;
 		qcom,mdss-dsi-h-sync-skew = <0>;
-		qcom,mdss-dsi-v-back-porch = <15>;
-		qcom,mdss-dsi-v-front-porch = <12>;
-		qcom,mdss-dsi-v-pulse-width = <10>;
+		qcom,mdss-dsi-v-back-porch = <14>;
+		qcom,mdss-dsi-v-front-porch = <11>;
+		qcom,mdss-dsi-v-pulse-width = <2>;
 		qcom,mdss-dsi-h-left-border = <0>;
 		qcom,mdss-dsi-h-right-border = <0>;
 		qcom,mdss-dsi-v-top-border = <0>;
diff --git a/arch/arm/boot/dts/msm-pm8110.dtsi b/arch/arm/boot/dts/msm-pm8110.dtsi
index 8523524..20e8a96 100644
--- a/arch/arm/boot/dts/msm-pm8110.dtsi
+++ b/arch/arm/boot/dts/msm-pm8110.dtsi
@@ -320,6 +320,7 @@
 			qcom,ocv-voltage-high-threshold-uv = <3750000>;
 			qcom,ocv-voltage-low-threshold-uv = <3650000>;
 			qcom,low-soc-calculate-soc-threshold = <15>;
+			qcom,low-voltage-calculate-soc-ms = <1000>;
 			qcom,low-soc-calculate-soc-ms = <5000>;
 			qcom,calculate-soc-ms = <20000>;
 			qcom,chg-term-ua = <100000>;
@@ -327,7 +328,7 @@
 			qcom,low-voltage-threshold = <3420000>;
 			qcom,tm-temp-margin = <5000>;
 			qcom,low-ocv-correction-limit-uv = <100>;
-			qcom,high-ocv-correction-limit-uv = <50>;
+			qcom,high-ocv-correction-limit-uv = <250>;
 			qcom,hold-soc-est = <3>;
 			qcom,bms-vadc = <&pm8110_vadc>;
 			qcom,bms-iadc = <&pm8110_iadc>;
diff --git a/arch/arm/boot/dts/msm-pm8226.dtsi b/arch/arm/boot/dts/msm-pm8226.dtsi
index f2ed8b5..6d506cc 100644
--- a/arch/arm/boot/dts/msm-pm8226.dtsi
+++ b/arch/arm/boot/dts/msm-pm8226.dtsi
@@ -199,13 +199,14 @@
 			qcom,ocv-voltage-high-threshold-uv = <3750000>;
 			qcom,ocv-voltage-low-threshold-uv = <3650000>;
 			qcom,low-soc-calculate-soc-threshold = <15>;
+			qcom,low-voltage-calculate-soc-ms = <1000>;
 			qcom,low-soc-calculate-soc-ms = <5000>;
 			qcom,calculate-soc-ms = <20000>;
 			qcom,chg-term-ua = <100000>;
 			qcom,batt-type = <0>;
 			qcom,tm-temp-margin = <5000>;
 			qcom,low-ocv-correction-limit-uv = <100>;
-			qcom,high-ocv-correction-limit-uv = <50>;
+			qcom,high-ocv-correction-limit-uv = <250>;
 			qcom,hold-soc-est = <3>;
 			qcom,low-voltage-threshold = <3420000>;
 			qcom,bms-vadc = <&pm8226_vadc>;
@@ -432,6 +433,16 @@
 				qcom,hw-settle-time = <0>;
 				qcom,fast-avg-setup = <0>;
 			};
+			chan@1 {
+				label = "external_rsense";
+				reg = <1>;
+				qcom,decimation = <0>;
+				qcom,pre-div-channel-scaling = <1>;
+				qcom,calibration-type = "absolute";
+				qcom,scale-function = <0>;
+				qcom,hw-settle-time = <0>;
+				qcom,fast-avg-setup = <0>;
+			};
 		};
 
 		pm8226_adc_tm: vadc@3400 {
diff --git a/arch/arm/boot/dts/msm-pm8941.dtsi b/arch/arm/boot/dts/msm-pm8941.dtsi
index c4de04c..520decd 100644
--- a/arch/arm/boot/dts/msm-pm8941.dtsi
+++ b/arch/arm/boot/dts/msm-pm8941.dtsi
@@ -127,6 +127,7 @@
 		qcom,ocv-voltage-high-threshold-uv = <3750000>;
 		qcom,ocv-voltage-low-threshold-uv = <3650000>;
 		qcom,low-soc-calculate-soc-threshold = <15>;
+		qcom,low-voltage-calculate-soc-ms = <1000>;
 		qcom,low-soc-calculate-soc-ms = <5000>;
 		qcom,calculate-soc-ms = <20000>;
 		qcom,chg-term-ua = <100000>;
@@ -134,7 +135,7 @@
 		qcom,low-voltage-threshold = <3420000>;
 		qcom,tm-temp-margin = <5000>;
 		qcom,low-ocv-correction-limit-uv = <100>;
-		qcom,high-ocv-correction-limit-uv = <50>;
+		qcom,high-ocv-correction-limit-uv = <250>;
 		qcom,hold-soc-est = <3>;
 		qcom,bms-vadc = <&pm8941_vadc>;
 		qcom,bms-iadc = <&pm8941_iadc>;
@@ -208,7 +209,9 @@
 		qcom,resume-soc = <99>;
 		qcom,tchg-mins = <150>;
 		qcom,chg-vadc = <&pm8941_vadc>;
+		qcom,chg-iadc = <&pm8941_iadc>;
 		qcom,chg-adc_tm = <&pm8941_adc_tm>;
+		qcom,ibat-calibration-enabled;
 
 		qcom,chgr@1000 {
 			status = "disabled";
diff --git a/arch/arm/boot/dts/msm8226-1080p-cdp.dtsi b/arch/arm/boot/dts/msm8226-1080p-cdp.dtsi
new file mode 100644
index 0000000..bb66538
--- /dev/null
+++ b/arch/arm/boot/dts/msm8226-1080p-cdp.dtsi
@@ -0,0 +1,502 @@
+/* Copyright (c) 2013, The Linux Foundation. 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.
+ */
+
+/include/ "msm8226-camera-sensor-cdp.dtsi"
+
+&soc {
+	serial@f991f000 {
+		status = "ok";
+	};
+
+	i2c@f9927000 { /* BLSP1 QUP5 */
+		synaptics@20 {
+			compatible = "synaptics,rmi4";
+			reg = <0x20>;
+			interrupt-parent = <&msmgpio>;
+			interrupts = <17 0x2008>;
+			vdd-supply = <&pm8226_l19>;
+			vcc_i2c-supply = <&pm8226_lvs1>;
+			synaptics,reset-gpio = <&msmgpio 16 0x00>;
+			synaptics,irq-gpio = <&msmgpio 17 0x2008>;
+			synaptics,display-coords = <0 0 1079 1919>;
+			synaptics,i2c-pull-up;
+			synaptics,power-down;
+			synaptics,disable-gpios;
+		};
+	};
+
+	gen-vkeys {
+		compatible = "qcom,gen-vkeys";
+		label = "synaptics_rmi4_i2c";
+		qcom,disp-maxx = <1079>;
+		qcom,disp-maxy = <1919>;
+		qcom,panel-maxx = <1079>;
+		qcom,panel-maxy = <2084>;
+		qcom,key-codes = <158 139 102 217>;
+	};
+
+	i2c@f9925000 { /* BLSP1 QUP3 */
+		nfc-nci@0e {
+			compatible = "qcom,nfc-nci";
+			reg = <0x0e>;
+			qcom,irq-gpio = <&msmgpio 21 0x00>;
+			qcom,dis-gpio = <&msmgpio 20 0x00>;
+			qcom,clk-src = "BBCLK2";
+			qcom,clk-en-gpio = <&msmgpio 0 0x00>;
+			interrupt-parent = <&msmgpio>;
+			interrupts = <21 0>;
+			qcom,clk-gpio = <&pm8226_gpios 3 0>;
+		};
+	};
+
+	gpio_keys {
+		compatible = "gpio-keys";
+		input-name = "gpio-keys";
+
+		camera_focus {
+			label = "camera_focus";
+			gpios = <&msmgpio 108 0x1>;
+			linux,input-type = <1>;
+			linux,code = <0x210>;
+			gpio-key,wakeup;
+			debounce-interval = <15>;
+		};
+
+		camera_snapshot {
+			label = "camera_snapshot";
+			gpios = <&msmgpio 107 0x1>;
+			linux,input-type = <1>;
+			linux,code = <0x2fe>;
+			gpio-key,wakeup;
+			debounce-interval = <15>;
+		};
+
+		vol_up {
+			label = "volume_up";
+			gpios = <&msmgpio 106 0x1>;
+			linux,input-type = <1>;
+			linux,code = <115>;
+			gpio-key,wakeup;
+			debounce-interval = <15>;
+		};
+	};
+
+	spi@f9923000 {
+		ethernet-switch@3 {
+			compatible = "micrel,ks8851";
+			reg = <3>;
+			interrupt-parent = <&msmgpio>;
+			interrupts = <115 0x8>;
+			spi-max-frequency = <4800000>;
+			rst-gpio = <&msmgpio 114 0>;
+			vdd-io-supply = <&pm8226_lvs1>;
+			vdd-phy-supply = <&pm8226_lvs1>;
+		};
+	};
+
+	sound {
+		qcom,audio-routing =
+			"RX_BIAS", "MCLK",
+			"LDO_H", "MCLK",
+			"SPK_OUT", "MCLK",
+			"SPK_OUT", "EXT_VDD_SPKR",
+			"AMIC1", "MIC BIAS1 Internal1",
+			"MIC BIAS1 Internal1", "Handset Mic",
+			"AMIC2", "MIC BIAS2 External",
+			"MIC BIAS2 External", "Headset Mic",
+			"AMIC4", "MIC BIAS2 External",
+			"MIC BIAS2 External", "ANCRight Headset Mic",
+			"AMIC5", "MIC BIAS2 External",
+			"MIC BIAS2 External", "ANCLeft Headset Mic",
+			"DMIC1", "MIC BIAS1 External",
+			"MIC BIAS1 External", "Digital Mic1",
+			"DMIC2", "MIC BIAS1 External",
+			"MIC BIAS1 External", "Digital Mic2",
+			"DMIC3", "MIC BIAS3 External",
+			"MIC BIAS3 External", "Digital Mic3",
+			"DMIC4", "MIC BIAS3 External",
+			"MIC BIAS3 External", "Digital Mic4";
+
+		qcom,cdc-mclk-gpios = <&pm8226_gpios 1 0>;
+		qcom,cdc-vdd-spkr-gpios = <&pm8226_gpios 2 0>;
+		qcom,headset-jack-type-NC;
+	};
+
+	sound-9302 {
+		qcom,audio-routing =
+			"RX_BIAS", "MCLK",
+			"LDO_H", "MCLK",
+			"SPK_OUT", "MCLK",
+			"SPK_OUT", "EXT_VDD_SPKR",
+			"AMIC1", "MIC BIAS1 External",
+			"MIC BIAS1 External", "Handset Mic",
+			"AMIC2", "MIC BIAS2 External",
+			"MIC BIAS2 External", "Headset Mic",
+			"AMIC3", "MIC BIAS1 External",
+			"MIC BIAS1 External", "Handset Mic";
+
+		qcom,cdc-mclk-gpios = <&pm8226_gpios 1 0>;
+		qcom,cdc-vdd-spkr-gpios = <&pm8226_gpios 2 0>;
+		qcom,headset-jack-type-NC;
+	};
+};
+
+&sdcc1 {
+	vdd-supply = <&pm8226_l17>;
+	qcom,vdd-voltage-level = <2950000 2950000>;
+	qcom,vdd-current-level = <800 500000>;
+
+	vdd-io-supply = <&pm8226_l6>;
+	qcom,vdd-io-always-on;
+	qcom,vdd-io-voltage-level = <1800000 1800000>;
+	qcom,vdd-io-current-level = <250 154000>;
+
+	qcom,pad-pull-on = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-pull-off = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
+	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
+
+	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
+	qcom,sup-voltages = <2950 2950>;
+
+	qcom,bus-speed-mode = "HS200_1p8v", "DDR_1p8v";
+	qcom,nonremovable;
+
+	status = "disabled";
+};
+
+&sdhc_1 {
+	vdd-supply = <&pm8226_l17>;
+	qcom,vdd-voltage-level = <2950000 2950000>;
+	qcom,vdd-current-level = <800 500000>;
+
+	vdd-io-supply = <&pm8226_l6>;
+	qcom,vdd-io-always-on;
+	qcom,vdd-io-voltage-level = <1800000 1800000>;
+	qcom,vdd-io-current-level = <250 154000>;
+
+	qcom,pad-pull-on = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-pull-off = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
+	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
+
+	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
+	qcom,bus-speed-mode = "HS200_1p8v", "DDR_1p8v";
+	qcom,nonremovable;
+
+	status = "ok";
+};
+
+&sdcc2 {
+	vdd-supply = <&pm8226_l18>;
+	qcom,vdd-voltage-level = <2950000 2950000>;
+	qcom,vdd-current-level = <9000 800000>;
+
+	vdd-io-supply = <&pm8226_l21>;
+	qcom,vdd-io-voltage-level = <1800000 2950000>;
+	qcom,vdd-io-current-level = <6 22000>;
+
+	qcom,pad-pull-on = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-pull-off = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
+	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
+
+	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
+	qcom,sup-voltages = <2950 2950>;
+
+	qcom,xpc;
+	qcom,bus-speed-mode = "SDR12", "SDR25", "SDR50", "DDR50", "SDR104";
+	qcom,current-limit = <600>;
+
+	#address-cells = <0>;
+	interrupt-parent = <&sdcc2>;
+	interrupts = <0 1 2>;
+	#interrupt-cells = <1>;
+	interrupt-map-mask = <0xffffffff>;
+	interrupt-map = <0 &intc 0 125 0
+			1 &intc 0 220 0
+			2 &msmgpio 38 0x3>;
+	interrupt-names = "core_irq", "bam_irq", "status_irq";
+	cd-gpios = <&msmgpio 38 0x1>;
+
+	status = "disabled";
+};
+
+&sdhc_2 {
+	vdd-supply = <&pm8226_l18>;
+	qcom,vdd-voltage-level = <2950000 2950000>;
+	qcom,vdd-current-level = <9000 800000>;
+
+	vdd-io-supply = <&pm8226_l21>;
+	qcom,vdd-io-voltage-level = <1800000 2950000>;
+	qcom,vdd-io-current-level = <6 22000>;
+
+	qcom,pad-pull-on = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-pull-off = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
+	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
+
+	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
+
+	#address-cells = <0>;
+	interrupt-parent = <&sdhc_2>;
+	interrupts = <0 1 2>;
+	#interrupt-cells = <1>;
+	interrupt-map-mask = <0xffffffff>;
+	interrupt-map = <0 &intc 0 125 0
+			1 &intc 0 221 0
+			2 &msmgpio 38 0x3>;
+	interrupt-names = "hc_irq", "pwr_irq", "status_irq";
+	cd-gpios = <&msmgpio 38 0x1>;
+
+	status = "ok";
+};
+
+&sdcc3 {
+	qcom,sup-voltages = <1800 1800>;
+	status = "disabled";
+};
+
+&sdhc_3 {
+	qcom,sup-voltages = <1800 1800>;
+	status = "disabled";
+};
+
+&spmi_bus {
+	qcom,pm8226@0 {
+		qcom,leds@a100 {
+			status = "okay";
+			qcom,led_mpp_2 {
+				label = "mpp";
+				linux,name = "button-backlight";
+				linux,default-trigger = "none";
+				qcom,default-state = "off";
+				qcom,max-current = <40>;
+				qcom,current-setting = <5>;
+				qcom,id = <6>;
+				qcom,mode = "manual";
+				qcom,source-sel = <1>;
+				qcom,mode-ctrl = <0x60>;
+			};
+		};
+
+		qcom,leds@a300 {
+			status = "okay";
+			qcom,led_mpp_4 {
+				label = "mpp";
+				linux,name = "green";
+				linux,default-trigger = "battery-full";
+				qcom,default-state = "off";
+				qcom,max-current = <40>;
+				qcom,current-setting = <5>;
+				qcom,id = <6>;
+				qcom,mode = "pwm";
+				qcom,pwm-us = <1000>;
+				qcom,source-sel = <8>;
+				qcom,mode-ctrl = <0x60>;
+				qcom,pwm-channel = <0>;
+				qcom,start-idx = <1>;
+				qcom,ramp-step-ms = <120>;
+				qcom,duty-pcts = [00 00 00 00 00
+						  00 00 00 00 00
+						  50 00 00 00 00
+						  00 00 00 00 00
+						  00];
+				qcom,use-blink;
+			};
+		};
+
+		qcom,leds@a500 {
+			status = "okay";
+			qcom,led_mpp_6 {
+				label = "mpp";
+				linux,name = "red";
+				linux,default-trigger = "battery-charging";
+				qcom,default-state = "off";
+				qcom,max-current = <40>;
+				qcom,current-setting = <5>;
+				qcom,id = <6>;
+				qcom,mode = "pwm";
+				qcom,pwm-us = <1000>;
+				qcom,mode-ctrl = <0x60>;
+				qcom,source-sel = <10>;
+				qcom,pwm-channel = <5>;
+				qcom,start-idx = <1>;
+				qcom,ramp-step-ms = <120>;
+				qcom,duty-pcts = [00 00 00 00 00
+						  00 00 00 00 00
+						  50 00 00 00 00
+						  00 00 00 00 00
+						  00];
+				qcom,use-blink;
+			};
+		};
+	};
+
+	qcom,pm8226@1 {
+		qcom,leds@d800 {
+			status = "okay";
+			qcom,wled_0 {
+				label = "wled";
+				linux,name = "wled:backlight";
+				linux,default-trigger = "bkl-trigger";
+				qcom,cs-out-en;
+				qcom,op-fdbck = <1>;
+				qcom,default-state = "on";
+				qcom,max-current = <20>;
+				qcom,ctrl-delay-us = <0>;
+				qcom,boost-curr-lim = <3>;
+				qcom,cp-sel = <0>;
+				qcom,switch-freq = <11>;
+				qcom,ovp-val = <0>;
+				qcom,num-strings = <1>;
+				qcom,id = <0>;
+			};
+		};
+
+		qcom,vibrator@c000 {
+			status = "okay";
+			qcom,vib-timeout-ms = <15000>;
+			qcom,vib-vtg-level-mV = <3100>;
+		};
+	};
+};
+
+&pm8226_gpios {
+	gpio@c000 { /* GPIO 1 */
+		/* XO_PMIC_CDC_MCLK enable for tapan codec */
+		qcom,mode = <1>;		/* Digital output */
+		qcom,output-type = <0>;	/* CMOS logic */
+		qcom,pull = <5>;		/* QPNP_PIN_PULL_NO*/
+		qcom,vin-sel = <3>;		/* QPNP_PIN_VIN3 */
+		qcom,out-strength = <3>;/* QPNP_PIN_OUT_STRENGTH_HIGH */
+		qcom,src-sel = <2>;		/* QPNP_PIN_SEL_FUNC_1 */
+		qcom,master-en = <1>;	/* Enable GPIO */
+	};
+
+	gpio@c100 { /* GPIO 2 */
+		qcom,mode = <1>;
+		qcom,output-type = <0>;
+		qcom,pull = <5>;
+		qcom,vin-sel = <3>;
+		qcom,out-strength = <3>;
+		qcom,src-sel = <2>;
+		qcom,master-en = <1>;
+	};
+
+	gpio@c200 { /* GPIO 3 */
+		qcom,mode = <0>;		/* QPNP_PIN_MODE_DIG_IN */
+		qcom,pull = <5>;		/* QPNP_PIN_PULL_NO */
+		qcom,vin-sel = <2>;		/* QPNP_PIN_VIN2 */
+		qcom,src-sel = <2>;		/* QPNP_PIN_SEL_FUNC_1 */
+		qcom,master-en = <1>;
+	};
+
+	gpio@c300 { /* GPIO 4 */
+	};
+
+	gpio@c400 { /* GPIO 5 */
+	};
+
+	gpio@c500 { /* GPIO 6 */
+	};
+
+	gpio@c600 { /* GPIO 7 */
+	};
+
+	gpio@c700 { /* GPIO 8 */
+	};
+};
+
+&pm8226_mpps {
+	mpp@a000 { /* MPP 1 */
+	};
+
+	mpp@a100 { /* MPP 2 */
+	};
+
+	mpp@a200 { /* MPP 3 */
+	};
+
+	mpp@a300 { /* MPP 4 */
+	};
+
+	mpp@a400 { /* MPP 5 */
+		/* PA_THERM0 config */
+		qcom,mode = <4>; /* AIN input */
+		qcom,invert = <1>; /* Enable MPP */
+		qcom,ain-route = <0>; /* AMUX 5 */
+		qcom,master-en = <1>;
+		qcom,src-sel = <0>; /* Function constant */
+	};
+
+	mpp@a500 { /* MPP 6 */
+	};
+
+	mpp@a600 { /* MPP 7 */
+	};
+
+	mpp@a700 { /* MPP 8 */
+		/* PA_THERM1 config */
+		qcom,mode = <4>; /* AIN input */
+		qcom,invert = <1>; /* Enable MPP */
+		qcom,ain-route = <3>; /* AMUX 8 */
+		qcom,master-en = <1>;
+		qcom,src-sel = <0>; /* Function constant */
+	};
+};
+
+&pm8226_chg {
+	qcom,charging-disabled;
+	qcom,use-default-batt-values;
+
+	qcom,bat-if@1200 {
+		status = "disabled";
+	};
+};
+
+&pm8226_vadc {
+	chan@14 {
+		label = "pa_therm0";
+		reg = <0x14>;
+		qcom,decimation = <0>;
+		qcom,pre-div-channel-scaling = <0>;
+		qcom,calibration-type = "ratiometric";
+		qcom,scale-function = <2>;
+		qcom,hw-settle-time = <2>;
+		qcom,fast-avg-setup = <0>;
+	};
+
+	chan@17 {
+		label = "pa_therm1";
+		reg = <0x17>;
+		qcom,decimation = <0>;
+		qcom,pre-div-channel-scaling = <0>;
+		qcom,calibration-type = "ratiometric";
+		qcom,scale-function = <2>;
+		qcom,hw-settle-time = <2>;
+		qcom,fast-avg-setup = <0>;
+	};
+};
+
+&mdss_mdp {
+	qcom,mdss-pref-prim-intf = "dsi";
+};
+
+&mdss_dsi0 {
+	qcom,dsi-pref-prim-pan = <&dsi_jdi_1080_vid>;
+	qcom,platform-enable-gpio = <&msmgpio 109 0>;
+};
+
+&dsi_jdi_1080_vid {
+	qcom,cont-splash-enabled;
+};
diff --git a/arch/arm/boot/dts/msm8226-1080p-mtp.dtsi b/arch/arm/boot/dts/msm8226-1080p-mtp.dtsi
new file mode 100644
index 0000000..31624de
--- /dev/null
+++ b/arch/arm/boot/dts/msm8226-1080p-mtp.dtsi
@@ -0,0 +1,519 @@
+/* Copyright (c) 2013, The Linux Foundation. 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.
+ */
+
+/include/ "msm8226-camera-sensor-mtp.dtsi"
+
+&soc {
+	serial@f991f000 {
+		status = "ok";
+	};
+
+	i2c@f9927000 { /* BLSP1 QUP5 */
+		synaptics@20 {
+			compatible = "synaptics,rmi4";
+			reg = <0x20>;
+			interrupt-parent = <&msmgpio>;
+			interrupts = <17 0x2008>;
+			vdd-supply = <&pm8226_l19>;
+			vcc_i2c-supply = <&pm8226_lvs1>;
+			synaptics,reset-gpio = <&msmgpio 16 0x00>;
+			synaptics,irq-gpio = <&msmgpio 17 0x2008>;
+			synaptics,display-coords = <0 0 1079 1919>;
+			synaptics,i2c-pull-up;
+			synaptics,power-down;
+			synaptics,disable-gpios;
+		};
+	};
+
+	gen-vkeys {
+		compatible = "qcom,gen-vkeys";
+		label = "synaptics_rmi4_i2c";
+		qcom,disp-maxx = <1079>;
+		qcom,disp-maxy = <1919>;
+		qcom,panel-maxx = <1079>;
+		qcom,panel-maxy = <2084>;
+		qcom,key-codes = <158 139 102 217>;
+	};
+
+	i2c@f9925000 { /* BLSP1 QUP3 */
+		nfc-nci@0e {
+			compatible = "qcom,nfc-nci";
+			reg = <0x0e>;
+			qcom,irq-gpio = <&msmgpio 21 0x00>;
+			qcom,dis-gpio = <&msmgpio 20 0x00>;
+			qcom,clk-src = "BBCLK2";
+			qcom,clk-en-gpio = <&msmgpio 0 0x00>;
+			interrupt-parent = <&msmgpio>;
+			interrupts = <21 0>;
+			qcom,clk-gpio = <&pm8226_gpios 3 0>;
+		};
+	};
+	gpio_keys {
+		compatible = "gpio-keys";
+		input-name = "gpio-keys";
+
+		camera_focus {
+			label = "camera_focus";
+			gpios = <&msmgpio 108 0x1>;
+			linux,input-type = <1>;
+			linux,code = <0x210>;
+			gpio-key,wakeup;
+			debounce-interval = <15>;
+		};
+
+		camera_snapshot {
+			label = "camera_snapshot";
+			gpios = <&msmgpio 107 0x1>;
+			linux,input-type = <1>;
+			linux,code = <0x2fe>;
+			gpio-key,wakeup;
+			debounce-interval = <15>;
+		};
+
+		vol_up {
+			label = "volume_up";
+			gpios = <&msmgpio 106 0x1>;
+			linux,input-type = <1>;
+			linux,code = <115>;
+			gpio-key,wakeup;
+			debounce-interval = <15>;
+		};
+	};
+
+	spi@f9923000 {
+		ethernet-switch@3 {
+			compatible = "micrel,ks8851";
+			reg = <3>;
+			interrupt-parent = <&msmgpio>;
+			interrupts = <115 0x8>;
+			spi-max-frequency = <4800000>;
+			rst-gpio = <&msmgpio 114 0>;
+			vdd-io-supply = <&pm8226_lvs1>;
+			vdd-phy-supply = <&pm8226_lvs1>;
+		};
+	};
+
+	sound {
+		qcom,audio-routing =
+			"RX_BIAS", "MCLK",
+			"LDO_H", "MCLK",
+			"SPK_OUT", "MCLK",
+			"SPK_OUT", "EXT_VDD_SPKR",
+			"AMIC1", "MIC BIAS1 External",
+			"MIC BIAS1 External", "Handset Mic",
+			"AMIC2", "MIC BIAS2 External",
+			"MIC BIAS2 External", "Headset Mic",
+			"AMIC4", "MIC BIAS2 External",
+			"MIC BIAS2 External", "ANCRight Headset Mic",
+			"AMIC5", "MIC BIAS2 External",
+			"MIC BIAS2 External", "ANCLeft Headset Mic";
+
+		qcom,cdc-mclk-gpios = <&pm8226_gpios 1 0>;
+		qcom,cdc-vdd-spkr-gpios = <&pm8226_gpios 2 0>;
+	};
+
+	sound-9302 {
+		qcom,audio-routing =
+			"RX_BIAS", "MCLK",
+			"LDO_H", "MCLK",
+			"SPK_OUT", "MCLK",
+			"SPK_OUT", "EXT_VDD_SPKR",
+			"AMIC1", "MIC BIAS1 Internal1",
+			"MIC BIAS1 Internal1", "Handset Mic",
+			"AMIC2", "MIC BIAS2 External",
+			"MIC BIAS2 External", "Headset Mic",
+			"AMIC3", "MIC BIAS1 External",
+			"MIC BIAS1 External", "Handset Mic";
+
+		qcom,cdc-mclk-gpios = <&pm8226_gpios 1 0>;
+		qcom,cdc-vdd-spkr-gpios = <&pm8226_gpios 2 0>;
+	};
+};
+
+&usb_otg {
+	#address-cells = <0>;
+	interrupt-parent = <&usb_otg>;
+	interrupts = <0 1 2>;
+	#interrupt-cells = <1>;
+	interrupt-map-mask = <0xffffffff>;
+	interrupt-map = <0 &intc 0 134 0
+			1 &intc 0 140 0
+			2 &spmi_bus 0x0 0x0 0x9 0x0>;
+	interrupt-names = "core_irq", "async_irq", "pmic_id_irq";
+
+	qcom,hsusb-otg-mode = <3>;
+	vbus_otg-supply = <&pm8226_chg_otg>;
+};
+
+&sdcc1 {
+	vdd-supply = <&pm8226_l17>;
+	qcom,vdd-voltage-level = <2950000 2950000>;
+	qcom,vdd-current-level = <800 500000>;
+
+	vdd-io-supply = <&pm8226_l6>;
+	qcom,vdd-io-always-on;
+	qcom,vdd-io-voltage-level = <1800000 1800000>;
+	qcom,vdd-io-current-level = <250 154000>;
+
+	qcom,pad-pull-on = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-pull-off = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
+	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
+
+	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
+	qcom,sup-voltages = <2950 2950>;
+
+	qcom,bus-speed-mode = "HS200_1p8v", "DDR_1p8v";
+	qcom,nonremovable;
+
+	status = "disabled";
+};
+
+&sdhc_1 {
+	vdd-supply = <&pm8226_l17>;
+	qcom,vdd-voltage-level = <2950000 2950000>;
+	qcom,vdd-current-level = <800 500000>;
+
+	vdd-io-supply = <&pm8226_l6>;
+	qcom,vdd-io-always-on;
+	qcom,vdd-io-voltage-level = <1800000 1800000>;
+	qcom,vdd-io-current-level = <250 154000>;
+
+	qcom,pad-pull-on = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-pull-off = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
+	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
+
+	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
+	qcom,bus-speed-mode = "HS200_1p8v", "DDR_1p8v";
+	qcom,nonremovable;
+
+	status = "ok";
+};
+
+&sdcc2 {
+	vdd-supply = <&pm8226_l18>;
+	qcom,vdd-voltage-level = <2950000 2950000>;
+	qcom,vdd-current-level = <9000 800000>;
+
+	vdd-io-supply = <&pm8226_l21>;
+	qcom,vdd-io-voltage-level = <1800000 2950000>;
+	qcom,vdd-io-current-level = <6 22000>;
+
+	qcom,pad-pull-on = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-pull-off = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
+	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
+
+	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
+	qcom,sup-voltages = <2950 2950>;
+
+	qcom,xpc;
+	qcom,bus-speed-mode = "SDR12", "SDR25", "SDR50", "DDR50", "SDR104";
+	qcom,current-limit = <600>; #address-cells = <0>; interrupt-parent = <&sdcc2>;
+	interrupts = <0 1 2>;
+	#interrupt-cells = <1>;
+	interrupt-map-mask = <0xffffffff>;
+	interrupt-map = <0 &intc 0 125 0
+			1 &intc 0 220 0
+			2 &msmgpio 38 0x3>;
+	interrupt-names = "core_irq", "bam_irq", "status_irq";
+	cd-gpios = <&msmgpio 38 0x1>;
+
+	status = "disabled";
+};
+
+&sdhc_2 {
+	vdd-supply = <&pm8226_l18>;
+	qcom,vdd-voltage-level = <2950000 2950000>;
+	qcom,vdd-current-level = <9000 800000>;
+
+	vdd-io-supply = <&pm8226_l21>;
+	qcom,vdd-io-voltage-level = <1800000 2950000>;
+	qcom,vdd-io-current-level = <6 22000>;
+
+	qcom,pad-pull-on = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-pull-off = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
+	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
+
+	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
+
+	#address-cells = <0>;
+	interrupt-parent = <&sdhc_2>;
+	interrupts = <0 1 2>;
+	#interrupt-cells = <1>;
+	interrupt-map-mask = <0xffffffff>;
+	interrupt-map = <0 &intc 0 125 0
+			1 &intc 0 221 0
+			2 &msmgpio 38 0x3>;
+	interrupt-names = "hc_irq", "pwr_irq", "status_irq";
+	cd-gpios = <&msmgpio 38 0x1>;
+
+	status = "ok";
+};
+
+&spmi_bus {
+	qcom,pm8226@0 {
+		qcom,leds@a100 {
+			status = "okay";
+			qcom,led_mpp_2 {
+				label = "mpp";
+				linux,name = "button-backlight";
+				linux,default-trigger = "none";
+				qcom,default-state = "off";
+				qcom,max-current = <40>;
+				qcom,current-setting = <5>;
+				qcom,id = <6>;
+				qcom,mode = "manual";
+				qcom,source-sel = <1>;
+				qcom,mode-ctrl = <0x60>;
+			};
+		};
+
+		qcom,leds@a300 {
+			status = "okay";
+			qcom,led_mpp_4 {
+				label = "mpp";
+				linux,name = "green";
+				linux,default-trigger = "battery-full";
+				qcom,default-state = "off";
+				qcom,max-current = <40>;
+				qcom,current-setting = <5>;
+				qcom,id = <6>;
+				qcom,mode = "pwm";
+				qcom,pwm-us = <1000>;
+				qcom,source-sel = <8>;
+				qcom,mode-ctrl = <0x60>;
+				qcom,pwm-channel = <0>;
+				qcom,start-idx = <1>;
+				qcom,ramp-step-ms = <120>;
+				qcom,duty-pcts = [00 00 00 00 00
+						  00 00 00 00 00
+						  50 00 00 00 00
+						  00 00 00 00 00
+						  00];
+				qcom,use-blink;
+			};
+		};
+
+		qcom,leds@a500 {
+			status = "okay";
+			qcom,led_mpp_6 {
+				label = "mpp";
+				linux,name = "red";
+				linux,default-trigger = "battery-charging";
+				qcom,default-state = "off";
+				qcom,max-current = <40>;
+				qcom,current-setting = <5>;
+				qcom,id = <6>;
+				qcom,mode = "pwm";
+				qcom,pwm-us = <1000>;
+				qcom,mode-ctrl = <0x60>;
+				qcom,source-sel = <10>;
+				qcom,pwm-channel = <5>;
+				qcom,start-idx = <1>;
+				qcom,ramp-step-ms = <120>;
+				qcom,duty-pcts = [00 00 00 00 00
+						  00 00 00 00 00
+						  50 00 00 00 00
+						  00 00 00 00 00
+						  00];
+				qcom,use-blink;
+			};
+		};
+	};
+
+	qcom,pm8226@1 {
+                qcom,leds@d300 {
+                        status = "okay";
+                };
+
+		qcom,leds@d800 {
+			status = "okay";
+			qcom,wled_0 {
+				label = "wled";
+				linux,name = "wled:backlight";
+				linux,default-trigger = "bkl-trigger";
+				qcom,cs-out-en;
+				qcom,op-fdbck = <1>;
+				qcom,default-state = "on";
+				qcom,max-current = <20>;
+				qcom,ctrl-delay-us = <0>;
+				qcom,boost-curr-lim = <3>;
+				qcom,cp-sel = <0>;
+				qcom,switch-freq = <11>;
+				qcom,ovp-val = <0>;
+				qcom,num-strings = <1>;
+				qcom,id = <0>;
+			};
+		};
+
+		qcom,vibrator@c000 {
+			status = "okay";
+			qcom,vib-timeout-ms = <15000>;
+			qcom,vib-vtg-level-mV = <3100>;
+		};
+	};
+};
+
+&pm8226_gpios {
+	gpio@c000 { /* GPIO 1 */
+		/* XO_PMIC_CDC_MCLK enable for tapan codec */
+		qcom,mode = <1>;		/* Digital output */
+		qcom,output-type = <0>;	/* CMOS logic */
+		qcom,pull = <5>;		/* QPNP_PIN_PULL_NO*/
+		qcom,vin-sel = <3>;		/* QPNP_PIN_VIN3 */
+		qcom,out-strength = <3>;/* QPNP_PIN_OUT_STRENGTH_HIGH */
+		qcom,src-sel = <2>;		/* QPNP_PIN_SEL_FUNC_1 */
+		qcom,master-en = <1>;	/* Enable GPIO */
+	};
+
+	gpio@c100 { /* GPIO 2 */
+		qcom,mode = <1>;
+		qcom,output-type = <0>;
+		qcom,pull = <5>;
+		qcom,vin-sel = <3>;
+		qcom,out-strength = <3>;
+		qcom,src-sel = <2>;
+		qcom,master-en = <1>;
+	};
+
+	gpio@c200 { /* GPIO 3 */
+		qcom,mode = <0>;		/* QPNP_PIN_MODE_DIG_IN */
+		qcom,pull = <5>;		/* QPNP_PIN_PULL_NO */
+		qcom,vin-sel = <2>;		/* QPNP_PIN_VIN2 */
+		qcom,src-sel = <2>;		/* QPNP_PIN_SEL_FUNC_1 */
+		qcom,master-en = <1>;
+	};
+
+	gpio@c300 { /* GPIO 4 */
+	};
+
+	gpio@c400 { /* GPIO 5 */
+	};
+
+	gpio@c500 { /* GPIO 6 */
+	};
+
+	gpio@c600 { /* GPIO 7 */
+	};
+
+	gpio@c700 { /* GPIO 8 */
+	};
+};
+
+&pm8226_mpps {
+	mpp@a000 { /* MPP 1 */
+	};
+
+	mpp@a100 { /* MPP 2 */
+	};
+
+	mpp@a200 { /* MPP 3 */
+	};
+
+	mpp@a300 { /* MPP 4 */
+	};
+
+	mpp@a400 { /* MPP 5 */
+		/* PA_THERM0 config */
+		qcom,mode = <4>; /* AIN input */
+		qcom,invert = <1>; /* Enable MPP */
+		qcom,ain-route = <0>; /* AMUX 5 */
+		qcom,master-en = <1>;
+		qcom,src-sel = <0>; /* Function constant */
+	};
+
+	mpp@a500 { /* MPP 6 */
+	};
+
+	mpp@a600 { /* MPP 7 */
+	};
+
+	mpp@a700 { /* MPP 8 */
+		/* PA_THERM1 config */
+		qcom,mode = <4>; /* AIN input */
+		qcom,invert = <1>; /* Enable MPP */
+		qcom,ain-route = <3>; /* AMUX 8 */
+		qcom,master-en = <1>;
+		qcom,src-sel = <0>; /* Function constant */
+	};
+};
+
+&pm8226_vadc {
+	chan@14 {
+		label = "pa_therm0";
+		reg = <0x14>;
+		qcom,decimation = <0>;
+		qcom,pre-div-channel-scaling = <0>;
+		qcom,calibration-type = "ratiometric";
+		qcom,scale-function = <2>;
+		qcom,hw-settle-time = <2>;
+		qcom,fast-avg-setup = <0>;
+	};
+
+	chan@17 {
+		label = "pa_therm1";
+		reg = <0x17>;
+		qcom,decimation = <0>;
+		qcom,pre-div-channel-scaling = <0>;
+		qcom,calibration-type = "ratiometric";
+		qcom,scale-function = <2>;
+		qcom,hw-settle-time = <2>;
+		qcom,fast-avg-setup = <0>;
+	};
+};
+
+/ {
+	mtp_batterydata: qcom,battery-data {
+		qcom,rpull-up-kohm = <100>;
+		qcom,vref-batt-therm = <1800000>;
+
+		/include/ "batterydata-palladium.dtsi"
+		/include/ "batterydata-mtp-3000mah.dtsi"
+	};
+};
+
+&pm8226_bms {
+	status = "ok";
+	qcom,battery-data = <&mtp_batterydata>;
+	qcom,enable-fcc-learning;
+	qcom,min-fcc-learning-soc = <20>;
+	qcom,min-fcc-ocv-pc = <30>;
+	qcom,min-fcc-learning-samples = <5>;
+	qcom,fcc-resolution = <10>;
+};
+
+&pm8226_chg {
+	qcom,charging-disabled;
+	qcom,battery-data = <&mtp_batterydata>;
+};
+
+&slim_msm {
+	tapan_codec {
+		qcom,cdc-micbias1-ext-cap;
+	};
+};
+
+&mdss_mdp {
+	qcom,mdss-pref-prim-intf = "dsi";
+};
+
+&mdss_dsi0 {
+	qcom,dsi-pref-prim-pan = <&dsi_jdi_1080_vid>;
+	qcom,platform-enable-gpio = <&msmgpio 109 0>;
+};
+
+&dsi_jdi_1080_vid {
+	qcom,cont-splash-enabled;
+};
diff --git a/arch/arm/boot/dts/msm8226-720p-cdp.dtsi b/arch/arm/boot/dts/msm8226-720p-cdp.dtsi
new file mode 100644
index 0000000..9a1eb36
--- /dev/null
+++ b/arch/arm/boot/dts/msm8226-720p-cdp.dtsi
@@ -0,0 +1,473 @@
+/* Copyright (c) 2013, The Linux Foundation. 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.
+ */
+
+/include/ "msm8226-camera-sensor-cdp.dtsi"
+
+&soc {
+	serial@f991f000 {
+		status = "ok";
+	};
+
+	i2c@f9927000 { /* BLSP1 QUP5 */
+		synaptics@20 {
+			compatible = "synaptics,rmi4";
+			reg = <0x20>;
+			interrupt-parent = <&msmgpio>;
+			interrupts = <17 0x2008>;
+			vdd-supply = <&pm8226_l19>;
+			vcc_i2c-supply = <&pm8226_lvs1>;
+			synaptics,reset-gpio = <&msmgpio 16 0x00>;
+			synaptics,irq-gpio = <&msmgpio 17 0x2008>;
+			synaptics,button-map = <139 102 158>;
+			synaptics,fw-image-name = "PR1468813.img";
+			synaptics,i2c-pull-up;
+			synaptics,power-down;
+			synaptics,disable-gpios;
+		};
+	};
+
+	gpio_keys {
+		compatible = "gpio-keys";
+		input-name = "gpio-keys";
+
+		camera_focus {
+			label = "camera_focus";
+			gpios = <&msmgpio 108 0x1>;
+			linux,input-type = <1>;
+			linux,code = <0x210>;
+			gpio-key,wakeup;
+			debounce-interval = <15>;
+		};
+
+		camera_snapshot {
+			label = "camera_snapshot";
+			gpios = <&msmgpio 107 0x1>;
+			linux,input-type = <1>;
+			linux,code = <0x2fe>;
+			gpio-key,wakeup;
+			debounce-interval = <15>;
+		};
+
+		vol_up {
+			label = "volume_up";
+			gpios = <&msmgpio 106 0x1>;
+			linux,input-type = <1>;
+			linux,code = <115>;
+			gpio-key,wakeup;
+			debounce-interval = <15>;
+		};
+	};
+
+	spi@f9923000 {
+		ethernet-switch@3 {
+			compatible = "micrel,ks8851";
+			reg = <3>;
+			interrupt-parent = <&msmgpio>;
+			interrupts = <115 0x8>;
+			spi-max-frequency = <4800000>;
+			rst-gpio = <&msmgpio 114 0>;
+			vdd-io-supply = <&pm8226_lvs1>;
+			vdd-phy-supply = <&pm8226_lvs1>;
+		};
+	};
+
+	sound {
+		qcom,audio-routing =
+			"RX_BIAS", "MCLK",
+			"LDO_H", "MCLK",
+			"SPK_OUT", "MCLK",
+			"SPK_OUT", "EXT_VDD_SPKR",
+			"AMIC1", "MIC BIAS1 Internal1",
+			"MIC BIAS1 Internal1", "Handset Mic",
+			"AMIC2", "MIC BIAS2 External",
+			"MIC BIAS2 External", "Headset Mic",
+			"AMIC4", "MIC BIAS2 External",
+			"MIC BIAS2 External", "ANCRight Headset Mic",
+			"AMIC5", "MIC BIAS2 External",
+			"MIC BIAS2 External", "ANCLeft Headset Mic",
+			"DMIC1", "MIC BIAS1 External",
+			"MIC BIAS1 External", "Digital Mic1",
+			"DMIC2", "MIC BIAS1 External",
+			"MIC BIAS1 External", "Digital Mic2",
+			"DMIC3", "MIC BIAS3 External",
+			"MIC BIAS3 External", "Digital Mic3",
+			"DMIC4", "MIC BIAS3 External",
+			"MIC BIAS3 External", "Digital Mic4";
+
+		qcom,cdc-mclk-gpios = <&pm8226_gpios 1 0>;
+		qcom,cdc-vdd-spkr-gpios = <&pm8226_gpios 2 0>;
+		qcom,headset-jack-type-NC;
+	};
+
+	sound-9302 {
+		qcom,audio-routing =
+			"RX_BIAS", "MCLK",
+			"LDO_H", "MCLK",
+			"SPK_OUT", "MCLK",
+			"SPK_OUT", "EXT_VDD_SPKR",
+			"AMIC1", "MIC BIAS1 External",
+			"MIC BIAS1 External", "Handset Mic",
+			"AMIC2", "MIC BIAS2 External",
+			"MIC BIAS2 External", "Headset Mic",
+			"AMIC3", "MIC BIAS1 External",
+			"MIC BIAS1 External", "Handset Mic";
+
+		qcom,cdc-mclk-gpios = <&pm8226_gpios 1 0>;
+		qcom,cdc-vdd-spkr-gpios = <&pm8226_gpios 2 0>;
+		qcom,headset-jack-type-NC;
+	};
+};
+
+&sdcc1 {
+	vdd-supply = <&pm8226_l17>;
+	qcom,vdd-voltage-level = <2950000 2950000>;
+	qcom,vdd-current-level = <800 500000>;
+
+	vdd-io-supply = <&pm8226_l6>;
+	qcom,vdd-io-always-on;
+	qcom,vdd-io-voltage-level = <1800000 1800000>;
+	qcom,vdd-io-current-level = <250 154000>;
+
+	qcom,pad-pull-on = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-pull-off = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
+	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
+
+	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
+	qcom,sup-voltages = <2950 2950>;
+
+	qcom,bus-speed-mode = "HS200_1p8v", "DDR_1p8v";
+	qcom,nonremovable;
+
+	status = "disabled";
+};
+
+&sdhc_1 {
+	vdd-supply = <&pm8226_l17>;
+	qcom,vdd-voltage-level = <2950000 2950000>;
+	qcom,vdd-current-level = <800 500000>;
+
+	vdd-io-supply = <&pm8226_l6>;
+	qcom,vdd-io-always-on;
+	qcom,vdd-io-voltage-level = <1800000 1800000>;
+	qcom,vdd-io-current-level = <250 154000>;
+
+	qcom,pad-pull-on = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-pull-off = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
+	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
+
+	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
+	qcom,bus-speed-mode = "HS200_1p8v", "DDR_1p8v";
+	qcom,nonremovable;
+
+	status = "ok";
+};
+
+&sdcc2 {
+	vdd-supply = <&pm8226_l18>;
+	qcom,vdd-voltage-level = <2950000 2950000>;
+	qcom,vdd-current-level = <9000 800000>;
+
+	vdd-io-supply = <&pm8226_l21>;
+	qcom,vdd-io-voltage-level = <1800000 2950000>;
+	qcom,vdd-io-current-level = <6 22000>;
+
+	qcom,pad-pull-on = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-pull-off = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
+	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
+
+	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
+	qcom,sup-voltages = <2950 2950>;
+
+	qcom,xpc;
+	qcom,bus-speed-mode = "SDR12", "SDR25", "SDR50", "DDR50", "SDR104";
+	qcom,current-limit = <600>;
+
+	#address-cells = <0>;
+	interrupt-parent = <&sdcc2>;
+	interrupts = <0 1 2>;
+	#interrupt-cells = <1>;
+	interrupt-map-mask = <0xffffffff>;
+	interrupt-map = <0 &intc 0 125 0
+			1 &intc 0 220 0
+			2 &msmgpio 38 0x3>;
+	interrupt-names = "core_irq", "bam_irq", "status_irq";
+	cd-gpios = <&msmgpio 38 0x1>;
+
+	status = "disabled";
+};
+
+&sdhc_2 {
+	vdd-supply = <&pm8226_l18>;
+	qcom,vdd-voltage-level = <2950000 2950000>;
+	qcom,vdd-current-level = <9000 800000>;
+
+	vdd-io-supply = <&pm8226_l21>;
+	qcom,vdd-io-voltage-level = <1800000 2950000>;
+	qcom,vdd-io-current-level = <6 22000>;
+
+	qcom,pad-pull-on = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-pull-off = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
+	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
+
+	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
+
+	#address-cells = <0>;
+	interrupt-parent = <&sdhc_2>;
+	interrupts = <0 1 2>;
+	#interrupt-cells = <1>;
+	interrupt-map-mask = <0xffffffff>;
+	interrupt-map = <0 &intc 0 125 0
+			1 &intc 0 221 0
+			2 &msmgpio 38 0x3>;
+	interrupt-names = "hc_irq", "pwr_irq", "status_irq";
+	cd-gpios = <&msmgpio 38 0x1>;
+
+	status = "ok";
+};
+
+&sdcc3 {
+	qcom,sup-voltages = <1800 1800>;
+	status = "disabled";
+};
+
+&sdhc_3 {
+	qcom,sup-voltages = <1800 1800>;
+	status = "disabled";
+};
+
+&spmi_bus {
+	qcom,pm8226@0 {
+		qcom,leds@a100 {
+			status = "okay";
+			qcom,led_mpp_2 {
+				label = "mpp";
+				linux,name = "button-backlight";
+				linux,default-trigger = "none";
+				qcom,default-state = "off";
+				qcom,max-current = <40>;
+				qcom,current-setting = <5>;
+				qcom,id = <6>;
+				qcom,mode = "manual";
+				qcom,source-sel = <1>;
+				qcom,mode-ctrl = <0x60>;
+			};
+		};
+
+		qcom,leds@a300 {
+			status = "okay";
+			qcom,led_mpp_4 {
+				label = "mpp";
+				linux,name = "green";
+				linux,default-trigger = "battery-full";
+				qcom,default-state = "off";
+				qcom,max-current = <40>;
+				qcom,current-setting = <5>;
+				qcom,id = <6>;
+				qcom,mode = "pwm";
+				qcom,pwm-us = <1000>;
+				qcom,source-sel = <8>;
+				qcom,mode-ctrl = <0x60>;
+				qcom,pwm-channel = <0>;
+				qcom,start-idx = <1>;
+				qcom,ramp-step-ms = <120>;
+				qcom,duty-pcts = [00 00 00 00 00
+						  00 00 00 00 00
+						  50 00 00 00 00
+						  00 00 00 00 00
+						  00];
+				qcom,use-blink;
+			};
+		};
+
+		qcom,leds@a500 {
+			status = "okay";
+			qcom,led_mpp_6 {
+				label = "mpp";
+				linux,name = "red";
+				linux,default-trigger = "battery-charging";
+				qcom,default-state = "off";
+				qcom,max-current = <40>;
+				qcom,current-setting = <5>;
+				qcom,id = <6>;
+				qcom,mode = "pwm";
+				qcom,pwm-us = <1000>;
+				qcom,mode-ctrl = <0x60>;
+				qcom,source-sel = <10>;
+				qcom,pwm-channel = <5>;
+				qcom,start-idx = <1>;
+				qcom,ramp-step-ms = <120>;
+				qcom,duty-pcts = [00 00 00 00 00
+						  00 00 00 00 00
+						  50 00 00 00 00
+						  00 00 00 00 00
+						  00];
+				qcom,use-blink;
+			};
+		};
+	};
+
+	qcom,pm8226@1 {
+		qcom,leds@d800 {
+			status = "okay";
+			qcom,wled_0 {
+				label = "wled";
+				linux,name = "wled:backlight";
+				linux,default-trigger = "bkl-trigger";
+				qcom,cs-out-en;
+				qcom,op-fdbck = <1>;
+				qcom,default-state = "on";
+				qcom,max-current = <20>;
+				qcom,ctrl-delay-us = <0>;
+				qcom,boost-curr-lim = <3>;
+				qcom,cp-sel = <0>;
+				qcom,switch-freq = <11>;
+				qcom,ovp-val = <0>;
+				qcom,num-strings = <1>;
+				qcom,id = <0>;
+			};
+		};
+
+		qcom,vibrator@c000 {
+			status = "okay";
+			qcom,vib-timeout-ms = <15000>;
+			qcom,vib-vtg-level-mV = <3100>;
+		};
+	};
+};
+
+&pm8226_gpios {
+	gpio@c000 { /* GPIO 1 */
+		/* XO_PMIC_CDC_MCLK enable for tapan codec */
+		qcom,mode = <1>;		/* Digital output */
+		qcom,output-type = <0>;	/* CMOS logic */
+		qcom,pull = <5>;		/* QPNP_PIN_PULL_NO*/
+		qcom,vin-sel = <3>;		/* QPNP_PIN_VIN3 */
+		qcom,out-strength = <3>;/* QPNP_PIN_OUT_STRENGTH_HIGH */
+		qcom,src-sel = <2>;		/* QPNP_PIN_SEL_FUNC_1 */
+		qcom,master-en = <1>;	/* Enable GPIO */
+	};
+
+	gpio@c100 { /* GPIO 2 */
+		qcom,mode = <1>;
+		qcom,output-type = <0>;
+		qcom,pull = <5>;
+		qcom,vin-sel = <3>;
+		qcom,out-strength = <3>;
+		qcom,src-sel = <2>;
+		qcom,master-en = <1>;
+	};
+
+	gpio@c200 { /* GPIO 3 */
+	};
+
+	gpio@c300 { /* GPIO 4 */
+	};
+
+	gpio@c400 { /* GPIO 5 */
+	};
+
+	gpio@c500 { /* GPIO 6 */
+	};
+
+	gpio@c600 { /* GPIO 7 */
+	};
+
+	gpio@c700 { /* GPIO 8 */
+	};
+};
+
+&pm8226_mpps {
+	mpp@a000 { /* MPP 1 */
+	};
+
+	mpp@a100 { /* MPP 2 */
+	};
+
+	mpp@a200 { /* MPP 3 */
+	};
+
+	mpp@a300 { /* MPP 4 */
+	};
+
+	mpp@a400 { /* MPP 5 */
+		/* PA_THERM0 config */
+		qcom,mode = <4>; /* AIN input */
+		qcom,invert = <1>; /* Enable MPP */
+		qcom,ain-route = <0>; /* AMUX 5 */
+		qcom,master-en = <1>;
+		qcom,src-sel = <0>; /* Function constant */
+	};
+
+	mpp@a500 { /* MPP 6 */
+	};
+
+	mpp@a600 { /* MPP 7 */
+	};
+
+	mpp@a700 { /* MPP 8 */
+		/* PA_THERM1 config */
+		qcom,mode = <4>; /* AIN input */
+		qcom,invert = <1>; /* Enable MPP */
+		qcom,ain-route = <3>; /* AMUX 8 */
+		qcom,master-en = <1>;
+		qcom,src-sel = <0>; /* Function constant */
+	};
+};
+
+&pm8226_chg {
+	qcom,charging-disabled;
+	qcom,use-default-batt-values;
+
+	qcom,bat-if@1200 {
+		status = "disabled";
+	};
+};
+
+&pm8226_vadc {
+	chan@14 {
+		label = "pa_therm0";
+		reg = <0x14>;
+		qcom,decimation = <0>;
+		qcom,pre-div-channel-scaling = <0>;
+		qcom,calibration-type = "ratiometric";
+		qcom,scale-function = <2>;
+		qcom,hw-settle-time = <2>;
+		qcom,fast-avg-setup = <0>;
+	};
+
+	chan@17 {
+		label = "pa_therm1";
+		reg = <0x17>;
+		qcom,decimation = <0>;
+		qcom,pre-div-channel-scaling = <0>;
+		qcom,calibration-type = "ratiometric";
+		qcom,scale-function = <2>;
+		qcom,hw-settle-time = <2>;
+		qcom,fast-avg-setup = <0>;
+	};
+};
+
+&mdss_mdp {
+	qcom,mdss-pref-prim-intf = "dsi";
+};
+
+&mdss_dsi0 {
+	qcom,dsi-pref-prim-pan = <&dsi_nt35590_720_vid>;
+};
+
+&dsi_nt35590_720_vid {
+	qcom,cont-splash-enabled;
+};
diff --git a/arch/arm/boot/dts/msm8226-720p-mtp.dtsi b/arch/arm/boot/dts/msm8226-720p-mtp.dtsi
new file mode 100644
index 0000000..7f4f8fc
--- /dev/null
+++ b/arch/arm/boot/dts/msm8226-720p-mtp.dtsi
@@ -0,0 +1,510 @@
+/* Copyright (c) 2013, The Linux Foundation. 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.
+ */
+
+/include/ "msm8226-camera-sensor-mtp.dtsi"
+
+&soc {
+	serial@f991f000 {
+		status = "ok";
+	};
+
+	i2c@f9927000 { /* BLSP1 QUP5 */
+		synaptics@20 {
+			compatible = "synaptics,rmi4";
+			reg = <0x20>;
+			interrupt-parent = <&msmgpio>;
+			interrupts = <17 0x2008>;
+			vdd-supply = <&pm8226_l19>;
+			vcc_i2c-supply = <&pm8226_lvs1>;
+			synaptics,reset-gpio = <&msmgpio 16 0x00>;
+			synaptics,irq-gpio = <&msmgpio 17 0x2008>;
+			synaptics,button-map = <139 102 158>;
+			synaptics,fw-image-name = "PR1468813.img";
+			synaptics,i2c-pull-up;
+			synaptics,power-down;
+			synaptics,disable-gpios;
+		};
+	};
+
+	i2c@f9925000 { /* BLSP1 QUP3 */
+		nfc-nci@0e {
+			compatible = "qcom,nfc-nci";
+			reg = <0x0e>;
+			qcom,irq-gpio = <&msmgpio 21 0x00>;
+			qcom,dis-gpio = <&msmgpio 20 0x00>;
+			qcom,clk-src = "BBCLK2";
+			qcom,clk-en-gpio = <&msmgpio 0 0x00>;
+			interrupt-parent = <&msmgpio>;
+			interrupts = <21 0>;
+			qcom,clk-gpio = <&pm8226_gpios 3 0>;
+		};
+	};
+	gpio_keys {
+		compatible = "gpio-keys";
+		input-name = "gpio-keys";
+
+		camera_focus {
+			label = "camera_focus";
+			gpios = <&msmgpio 108 0x1>;
+			linux,input-type = <1>;
+			linux,code = <0x210>;
+			gpio-key,wakeup;
+			debounce-interval = <15>;
+		};
+
+		camera_snapshot {
+			label = "camera_snapshot";
+			gpios = <&msmgpio 107 0x1>;
+			linux,input-type = <1>;
+			linux,code = <0x2fe>;
+			gpio-key,wakeup;
+			debounce-interval = <15>;
+		};
+
+		vol_up {
+			label = "volume_up";
+			gpios = <&msmgpio 106 0x1>;
+			linux,input-type = <1>;
+			linux,code = <115>;
+			gpio-key,wakeup;
+			debounce-interval = <15>;
+		};
+	};
+
+	spi@f9923000 {
+		ethernet-switch@3 {
+			compatible = "micrel,ks8851";
+			reg = <3>;
+			interrupt-parent = <&msmgpio>;
+			interrupts = <115 0x8>;
+			spi-max-frequency = <4800000>;
+			rst-gpio = <&msmgpio 114 0>;
+			vdd-io-supply = <&pm8226_lvs1>;
+			vdd-phy-supply = <&pm8226_lvs1>;
+		};
+	};
+
+	sound {
+		qcom,audio-routing =
+			"RX_BIAS", "MCLK",
+			"LDO_H", "MCLK",
+			"SPK_OUT", "MCLK",
+			"SPK_OUT", "EXT_VDD_SPKR",
+			"AMIC1", "MIC BIAS1 External",
+			"MIC BIAS1 External", "Handset Mic",
+			"AMIC2", "MIC BIAS2 External",
+			"MIC BIAS2 External", "Headset Mic",
+			"AMIC4", "MIC BIAS2 External",
+			"MIC BIAS2 External", "ANCRight Headset Mic",
+			"AMIC5", "MIC BIAS2 External",
+			"MIC BIAS2 External", "ANCLeft Headset Mic";
+
+		qcom,cdc-mclk-gpios = <&pm8226_gpios 1 0>;
+		qcom,cdc-vdd-spkr-gpios = <&pm8226_gpios 2 0>;
+	};
+
+	sound-9302 {
+		qcom,audio-routing =
+			"RX_BIAS", "MCLK",
+			"LDO_H", "MCLK",
+			"SPK_OUT", "MCLK",
+			"SPK_OUT", "EXT_VDD_SPKR",
+			"AMIC1", "MIC BIAS1 Internal1",
+			"MIC BIAS1 Internal1", "Handset Mic",
+			"AMIC2", "MIC BIAS2 External",
+			"MIC BIAS2 External", "Headset Mic",
+			"AMIC3", "MIC BIAS1 External",
+			"MIC BIAS1 External", "Handset Mic";
+
+		qcom,cdc-mclk-gpios = <&pm8226_gpios 1 0>;
+		qcom,cdc-vdd-spkr-gpios = <&pm8226_gpios 2 0>;
+	};
+};
+
+&usb_otg {
+	#address-cells = <0>;
+	interrupt-parent = <&usb_otg>;
+	interrupts = <0 1 2>;
+	#interrupt-cells = <1>;
+	interrupt-map-mask = <0xffffffff>;
+	interrupt-map = <0 &intc 0 134 0
+			1 &intc 0 140 0
+			2 &spmi_bus 0x0 0x0 0x9 0x0>;
+	interrupt-names = "core_irq", "async_irq", "pmic_id_irq";
+
+	qcom,hsusb-otg-mode = <3>;
+	vbus_otg-supply = <&pm8226_chg_otg>;
+};
+
+&sdcc1 {
+	vdd-supply = <&pm8226_l17>;
+	qcom,vdd-voltage-level = <2950000 2950000>;
+	qcom,vdd-current-level = <800 500000>;
+
+	vdd-io-supply = <&pm8226_l6>;
+	qcom,vdd-io-always-on;
+	qcom,vdd-io-voltage-level = <1800000 1800000>;
+	qcom,vdd-io-current-level = <250 154000>;
+
+	qcom,pad-pull-on = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-pull-off = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
+	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
+
+	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
+	qcom,sup-voltages = <2950 2950>;
+
+	qcom,bus-speed-mode = "HS200_1p8v", "DDR_1p8v";
+	qcom,nonremovable;
+
+	status = "disabled";
+};
+
+&sdhc_1 {
+	vdd-supply = <&pm8226_l17>;
+	qcom,vdd-voltage-level = <2950000 2950000>;
+	qcom,vdd-current-level = <800 500000>;
+
+	vdd-io-supply = <&pm8226_l6>;
+	qcom,vdd-io-always-on;
+	qcom,vdd-io-voltage-level = <1800000 1800000>;
+	qcom,vdd-io-current-level = <250 154000>;
+
+	qcom,pad-pull-on = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-pull-off = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
+	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
+
+	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
+	qcom,bus-speed-mode = "HS200_1p8v", "DDR_1p8v";
+	qcom,nonremovable;
+
+	status = "ok";
+};
+
+&sdcc2 {
+	vdd-supply = <&pm8226_l18>;
+	qcom,vdd-voltage-level = <2950000 2950000>;
+	qcom,vdd-current-level = <9000 800000>;
+
+	vdd-io-supply = <&pm8226_l21>;
+	qcom,vdd-io-voltage-level = <1800000 2950000>;
+	qcom,vdd-io-current-level = <6 22000>;
+
+	qcom,pad-pull-on = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-pull-off = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
+	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
+
+	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
+	qcom,sup-voltages = <2950 2950>;
+
+	qcom,xpc;
+	qcom,bus-speed-mode = "SDR12", "SDR25", "SDR50", "DDR50", "SDR104";
+	qcom,current-limit = <600>; #address-cells = <0>; interrupt-parent = <&sdcc2>;
+	interrupts = <0 1 2>;
+	#interrupt-cells = <1>;
+	interrupt-map-mask = <0xffffffff>;
+	interrupt-map = <0 &intc 0 125 0
+			1 &intc 0 220 0
+			2 &msmgpio 38 0x3>;
+	interrupt-names = "core_irq", "bam_irq", "status_irq";
+	cd-gpios = <&msmgpio 38 0x1>;
+
+	status = "disabled";
+};
+
+&sdhc_2 {
+	vdd-supply = <&pm8226_l18>;
+	qcom,vdd-voltage-level = <2950000 2950000>;
+	qcom,vdd-current-level = <9000 800000>;
+
+	vdd-io-supply = <&pm8226_l21>;
+	qcom,vdd-io-voltage-level = <1800000 2950000>;
+	qcom,vdd-io-current-level = <6 22000>;
+
+	qcom,pad-pull-on = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-pull-off = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
+	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
+	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
+
+	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
+
+	#address-cells = <0>;
+	interrupt-parent = <&sdhc_2>;
+	interrupts = <0 1 2>;
+	#interrupt-cells = <1>;
+	interrupt-map-mask = <0xffffffff>;
+	interrupt-map = <0 &intc 0 125 0
+			1 &intc 0 221 0
+			2 &msmgpio 38 0x3>;
+	interrupt-names = "hc_irq", "pwr_irq", "status_irq";
+	cd-gpios = <&msmgpio 38 0x1>;
+
+	status = "ok";
+};
+
+&spmi_bus {
+	qcom,pm8226@0 {
+		qcom,leds@a100 {
+			status = "okay";
+			qcom,led_mpp_2 {
+				label = "mpp";
+				linux,name = "button-backlight";
+				linux,default-trigger = "none";
+				qcom,default-state = "off";
+				qcom,max-current = <40>;
+				qcom,current-setting = <5>;
+				qcom,id = <6>;
+				qcom,mode = "manual";
+				qcom,source-sel = <1>;
+				qcom,mode-ctrl = <0x60>;
+			};
+		};
+
+		qcom,leds@a300 {
+			status = "okay";
+			qcom,led_mpp_4 {
+				label = "mpp";
+				linux,name = "green";
+				linux,default-trigger = "battery-full";
+				qcom,default-state = "off";
+				qcom,max-current = <40>;
+				qcom,current-setting = <5>;
+				qcom,id = <6>;
+				qcom,mode = "pwm";
+				qcom,pwm-us = <1000>;
+				qcom,source-sel = <8>;
+				qcom,mode-ctrl = <0x60>;
+				qcom,pwm-channel = <0>;
+				qcom,start-idx = <1>;
+				qcom,ramp-step-ms = <120>;
+				qcom,duty-pcts = [00 00 00 00 00
+						  00 00 00 00 00
+						  50 00 00 00 00
+						  00 00 00 00 00
+						  00];
+				qcom,use-blink;
+			};
+		};
+
+		qcom,leds@a500 {
+			status = "okay";
+			qcom,led_mpp_6 {
+				label = "mpp";
+				linux,name = "red";
+				linux,default-trigger = "battery-charging";
+				qcom,default-state = "off";
+				qcom,max-current = <40>;
+				qcom,current-setting = <5>;
+				qcom,id = <6>;
+				qcom,mode = "pwm";
+				qcom,pwm-us = <1000>;
+				qcom,mode-ctrl = <0x60>;
+				qcom,source-sel = <10>;
+				qcom,pwm-channel = <5>;
+				qcom,start-idx = <1>;
+				qcom,ramp-step-ms = <120>;
+				qcom,duty-pcts = [00 00 00 00 00
+						  00 00 00 00 00
+						  50 00 00 00 00
+						  00 00 00 00 00
+						  00];
+				qcom,use-blink;
+			};
+		};
+	};
+
+	qcom,pm8226@1 {
+                qcom,leds@d300 {
+                        status = "okay";
+                };
+
+		qcom,leds@d800 {
+			status = "okay";
+			qcom,wled_0 {
+				label = "wled";
+				linux,name = "wled:backlight";
+				linux,default-trigger = "bkl-trigger";
+				qcom,cs-out-en;
+				qcom,op-fdbck = <1>;
+				qcom,default-state = "on";
+				qcom,max-current = <20>;
+				qcom,ctrl-delay-us = <0>;
+				qcom,boost-curr-lim = <3>;
+				qcom,cp-sel = <0>;
+				qcom,switch-freq = <11>;
+				qcom,ovp-val = <0>;
+				qcom,num-strings = <1>;
+				qcom,id = <0>;
+			};
+		};
+
+		qcom,vibrator@c000 {
+			status = "okay";
+			qcom,vib-timeout-ms = <15000>;
+			qcom,vib-vtg-level-mV = <3100>;
+		};
+	};
+};
+
+&pm8226_gpios {
+	gpio@c000 { /* GPIO 1 */
+		/* XO_PMIC_CDC_MCLK enable for tapan codec */
+		qcom,mode = <1>;		/* Digital output */
+		qcom,output-type = <0>;	/* CMOS logic */
+		qcom,pull = <5>;		/* QPNP_PIN_PULL_NO*/
+		qcom,vin-sel = <3>;		/* QPNP_PIN_VIN3 */
+		qcom,out-strength = <3>;/* QPNP_PIN_OUT_STRENGTH_HIGH */
+		qcom,src-sel = <2>;		/* QPNP_PIN_SEL_FUNC_1 */
+		qcom,master-en = <1>;	/* Enable GPIO */
+	};
+
+	gpio@c100 { /* GPIO 2 */
+		qcom,mode = <1>;
+		qcom,output-type = <0>;
+		qcom,pull = <5>;
+		qcom,vin-sel = <3>;
+		qcom,out-strength = <3>;
+		qcom,src-sel = <2>;
+		qcom,master-en = <1>;
+	};
+
+	gpio@c200 { /* GPIO 3 */
+		qcom,mode = <0>;		/* QPNP_PIN_MODE_DIG_IN */
+		qcom,pull = <5>;		/* QPNP_PIN_PULL_NO */
+		qcom,vin-sel = <2>;		/* QPNP_PIN_VIN2 */
+		qcom,src-sel = <2>;		/* QPNP_PIN_SEL_FUNC_1 */
+		qcom,master-en = <1>;
+	};
+
+	gpio@c300 { /* GPIO 4 */
+	};
+
+	gpio@c400 { /* GPIO 5 */
+	};
+
+	gpio@c500 { /* GPIO 6 */
+	};
+
+	gpio@c600 { /* GPIO 7 */
+	};
+
+	gpio@c700 { /* GPIO 8 */
+	};
+};
+
+&pm8226_mpps {
+	mpp@a000 { /* MPP 1 */
+	};
+
+	mpp@a100 { /* MPP 2 */
+	};
+
+	mpp@a200 { /* MPP 3 */
+	};
+
+	mpp@a300 { /* MPP 4 */
+	};
+
+	mpp@a400 { /* MPP 5 */
+		/* PA_THERM0 config */
+		qcom,mode = <4>; /* AIN input */
+		qcom,invert = <1>; /* Enable MPP */
+		qcom,ain-route = <0>; /* AMUX 5 */
+		qcom,master-en = <1>;
+		qcom,src-sel = <0>; /* Function constant */
+	};
+
+	mpp@a500 { /* MPP 6 */
+	};
+
+	mpp@a600 { /* MPP 7 */
+	};
+
+	mpp@a700 { /* MPP 8 */
+		/* PA_THERM1 config */
+		qcom,mode = <4>; /* AIN input */
+		qcom,invert = <1>; /* Enable MPP */
+		qcom,ain-route = <3>; /* AMUX 8 */
+		qcom,master-en = <1>;
+		qcom,src-sel = <0>; /* Function constant */
+	};
+};
+
+&pm8226_vadc {
+	chan@14 {
+		label = "pa_therm0";
+		reg = <0x14>;
+		qcom,decimation = <0>;
+		qcom,pre-div-channel-scaling = <0>;
+		qcom,calibration-type = "ratiometric";
+		qcom,scale-function = <2>;
+		qcom,hw-settle-time = <2>;
+		qcom,fast-avg-setup = <0>;
+	};
+
+	chan@17 {
+		label = "pa_therm1";
+		reg = <0x17>;
+		qcom,decimation = <0>;
+		qcom,pre-div-channel-scaling = <0>;
+		qcom,calibration-type = "ratiometric";
+		qcom,scale-function = <2>;
+		qcom,hw-settle-time = <2>;
+		qcom,fast-avg-setup = <0>;
+	};
+};
+
+/ {
+	mtp_batterydata: qcom,battery-data {
+		qcom,rpull-up-kohm = <100>;
+		qcom,vref-batt-therm = <1800000>;
+
+		/include/ "batterydata-palladium.dtsi"
+		/include/ "batterydata-mtp-3000mah.dtsi"
+	};
+};
+
+&pm8226_bms {
+	status = "ok";
+	qcom,enable-fcc-learning;
+	qcom,min-fcc-learning-soc = <20>;
+	qcom,min-fcc-ocv-pc = <30>;
+	qcom,min-fcc-learning-samples = <5>;
+	qcom,fcc-resolution = <10>;
+	qcom,battery-data = <&mtp_batterydata>;
+};
+
+&pm8226_chg {
+	qcom,charging-disabled;
+	qcom,battery-data = <&mtp_batterydata>;
+};
+
+&slim_msm {
+	tapan_codec {
+		qcom,cdc-micbias1-ext-cap;
+	};
+};
+
+&mdss_mdp {
+	qcom,mdss-pref-prim-intf = "dsi";
+	batfet-supply = <&pm8226_chg_batif>;
+};
+
+&mdss_dsi0 {
+	qcom,dsi-pref-prim-pan = <&dsi_nt35590_720_vid>;
+};
+
+&dsi_nt35590_720_vid {
+	qcom,cont-splash-enabled;
+};
diff --git a/arch/arm/boot/dts/msm8226-bus.dtsi b/arch/arm/boot/dts/msm8226-bus.dtsi
index d87aa3e..74b4a30 100644
--- a/arch/arm/boot/dts/msm8226-bus.dtsi
+++ b/arch/arm/boot/dts/msm8226-bus.dtsi
@@ -78,7 +78,7 @@
 		mas-vfe {
 			cell-id = <29>;
 			label = "mas-vfe";
-			qcom,masterp = <16>;
+			qcom,masterp = <7>;
 			qcom,tier = <2>;
 			qcom,hw-sel = "NoC";
 			qcom,perm-mode = "Bypass";
diff --git a/arch/arm/boot/dts/msm8226-cdp.dtsi b/arch/arm/boot/dts/msm8226-cdp.dtsi
deleted file mode 100644
index 3ebe225..0000000
--- a/arch/arm/boot/dts/msm8226-cdp.dtsi
+++ /dev/null
@@ -1,472 +0,0 @@
-/* Copyright (c) 2013, The Linux Foundation. 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.
- */
-
-/include/ "msm8226-camera-sensor-cdp.dtsi"
-
-&soc {
-	serial@f991f000 {
-		status = "ok";
-	};
-
-	i2c@f9927000 { /* BLSP1 QUP5 */
-		synaptics@20 {
-			compatible = "synaptics,rmi4";
-			reg = <0x20>;
-			interrupt-parent = <&msmgpio>;
-			interrupts = <17 0x2008>;
-			vdd-supply = <&pm8226_l19>;
-			vcc_i2c-supply = <&pm8226_lvs1>;
-			synaptics,reset-gpio = <&msmgpio 16 0x00>;
-			synaptics,irq-gpio = <&msmgpio 17 0x2008>;
-			synaptics,button-map = <139 102 158>;
-			synaptics,i2c-pull-up;
-			synaptics,power-down;
-			synaptics,disable-gpios;
-		};
-	};
-
-	gpio_keys {
-		compatible = "gpio-keys";
-		input-name = "gpio-keys";
-
-		camera_focus {
-			label = "camera_focus";
-			gpios = <&msmgpio 108 0x1>;
-			linux,input-type = <1>;
-			linux,code = <0x210>;
-			gpio-key,wakeup;
-			debounce-interval = <15>;
-		};
-
-		camera_snapshot {
-			label = "camera_snapshot";
-			gpios = <&msmgpio 107 0x1>;
-			linux,input-type = <1>;
-			linux,code = <0x2fe>;
-			gpio-key,wakeup;
-			debounce-interval = <15>;
-		};
-
-		vol_up {
-			label = "volume_up";
-			gpios = <&msmgpio 106 0x1>;
-			linux,input-type = <1>;
-			linux,code = <115>;
-			gpio-key,wakeup;
-			debounce-interval = <15>;
-		};
-	};
-
-	spi@f9923000 {
-		ethernet-switch@3 {
-			compatible = "micrel,ks8851";
-			reg = <3>;
-			interrupt-parent = <&msmgpio>;
-			interrupts = <115 0x8>;
-			spi-max-frequency = <4800000>;
-			rst-gpio = <&msmgpio 114 0>;
-			vdd-io-supply = <&pm8226_lvs1>;
-			vdd-phy-supply = <&pm8226_lvs1>;
-		};
-	};
-
-	sound {
-		qcom,audio-routing =
-			"RX_BIAS", "MCLK",
-			"LDO_H", "MCLK",
-			"SPK_OUT", "MCLK",
-			"SPK_OUT", "EXT_VDD_SPKR",
-			"AMIC1", "MIC BIAS1 Internal1",
-			"MIC BIAS1 Internal1", "Handset Mic",
-			"AMIC2", "MIC BIAS2 External",
-			"MIC BIAS2 External", "Headset Mic",
-			"AMIC4", "MIC BIAS2 External",
-			"MIC BIAS2 External", "ANCRight Headset Mic",
-			"AMIC5", "MIC BIAS2 External",
-			"MIC BIAS2 External", "ANCLeft Headset Mic",
-			"DMIC1", "MIC BIAS1 External",
-			"MIC BIAS1 External", "Digital Mic1",
-			"DMIC2", "MIC BIAS1 External",
-			"MIC BIAS1 External", "Digital Mic2",
-			"DMIC3", "MIC BIAS3 External",
-			"MIC BIAS3 External", "Digital Mic3",
-			"DMIC4", "MIC BIAS3 External",
-			"MIC BIAS3 External", "Digital Mic4";
-
-		qcom,cdc-mclk-gpios = <&pm8226_gpios 1 0>;
-		qcom,cdc-vdd-spkr-gpios = <&pm8226_gpios 2 0>;
-		qcom,headset-jack-type-NC;
-	};
-
-	sound-9302 {
-		qcom,audio-routing =
-			"RX_BIAS", "MCLK",
-			"LDO_H", "MCLK",
-			"SPK_OUT", "MCLK",
-			"SPK_OUT", "EXT_VDD_SPKR",
-			"AMIC1", "MIC BIAS1 External",
-			"MIC BIAS1 External", "Handset Mic",
-			"AMIC2", "MIC BIAS2 External",
-			"MIC BIAS2 External", "Headset Mic",
-			"AMIC3", "MIC BIAS1 External",
-			"MIC BIAS1 External", "Handset Mic";
-
-		qcom,cdc-mclk-gpios = <&pm8226_gpios 1 0>;
-		qcom,cdc-vdd-spkr-gpios = <&pm8226_gpios 2 0>;
-		qcom,headset-jack-type-NC;
-	};
-};
-
-&sdcc1 {
-	vdd-supply = <&pm8226_l17>;
-	qcom,vdd-voltage-level = <2950000 2950000>;
-	qcom,vdd-current-level = <800 500000>;
-
-	vdd-io-supply = <&pm8226_l6>;
-	qcom,vdd-io-always-on;
-	qcom,vdd-io-voltage-level = <1800000 1800000>;
-	qcom,vdd-io-current-level = <250 154000>;
-
-	qcom,pad-pull-on = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
-	qcom,pad-pull-off = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
-	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
-	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
-
-	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
-	qcom,sup-voltages = <2950 2950>;
-
-	qcom,bus-speed-mode = "HS200_1p8v", "DDR_1p8v";
-	qcom,nonremovable;
-
-	status = "disabled";
-};
-
-&sdhc_1 {
-	vdd-supply = <&pm8226_l17>;
-	qcom,vdd-voltage-level = <2950000 2950000>;
-	qcom,vdd-current-level = <800 500000>;
-
-	vdd-io-supply = <&pm8226_l6>;
-	qcom,vdd-io-always-on;
-	qcom,vdd-io-voltage-level = <1800000 1800000>;
-	qcom,vdd-io-current-level = <250 154000>;
-
-	qcom,pad-pull-on = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
-	qcom,pad-pull-off = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
-	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
-	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
-
-	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
-	qcom,bus-speed-mode = "HS200_1p8v", "DDR_1p8v";
-	qcom,nonremovable;
-
-	status = "ok";
-};
-
-&sdcc2 {
-	vdd-supply = <&pm8226_l18>;
-	qcom,vdd-voltage-level = <2950000 2950000>;
-	qcom,vdd-current-level = <9000 800000>;
-
-	vdd-io-supply = <&pm8226_l21>;
-	qcom,vdd-io-voltage-level = <1800000 2950000>;
-	qcom,vdd-io-current-level = <6 22000>;
-
-	qcom,pad-pull-on = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
-	qcom,pad-pull-off = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
-	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
-	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
-
-	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
-	qcom,sup-voltages = <2950 2950>;
-
-	qcom,xpc;
-	qcom,bus-speed-mode = "SDR12", "SDR25", "SDR50", "DDR50", "SDR104";
-	qcom,current-limit = <600>;
-
-	#address-cells = <0>;
-	interrupt-parent = <&sdcc2>;
-	interrupts = <0 1 2>;
-	#interrupt-cells = <1>;
-	interrupt-map-mask = <0xffffffff>;
-	interrupt-map = <0 &intc 0 125 0
-			1 &intc 0 220 0
-			2 &msmgpio 38 0x3>;
-	interrupt-names = "core_irq", "bam_irq", "status_irq";
-	cd-gpios = <&msmgpio 38 0x1>;
-
-	status = "disabled";
-};
-
-&sdhc_2 {
-	vdd-supply = <&pm8226_l18>;
-	qcom,vdd-voltage-level = <2950000 2950000>;
-	qcom,vdd-current-level = <9000 800000>;
-
-	vdd-io-supply = <&pm8226_l21>;
-	qcom,vdd-io-voltage-level = <1800000 2950000>;
-	qcom,vdd-io-current-level = <6 22000>;
-
-	qcom,pad-pull-on = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
-	qcom,pad-pull-off = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
-	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
-	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
-
-	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
-
-	#address-cells = <0>;
-	interrupt-parent = <&sdhc_2>;
-	interrupts = <0 1 2>;
-	#interrupt-cells = <1>;
-	interrupt-map-mask = <0xffffffff>;
-	interrupt-map = <0 &intc 0 125 0
-			1 &intc 0 221 0
-			2 &msmgpio 38 0x3>;
-	interrupt-names = "hc_irq", "pwr_irq", "status_irq";
-	cd-gpios = <&msmgpio 38 0x1>;
-
-	status = "ok";
-};
-
-&sdcc3 {
-	qcom,sup-voltages = <1800 1800>;
-	status = "disabled";
-};
-
-&sdhc_3 {
-	qcom,sup-voltages = <1800 1800>;
-	status = "disabled";
-};
-
-&spmi_bus {
-	qcom,pm8226@0 {
-		qcom,leds@a100 {
-			status = "okay";
-			qcom,led_mpp_2 {
-				label = "mpp";
-				linux,name = "button-backlight";
-				linux,default-trigger = "none";
-				qcom,default-state = "off";
-				qcom,max-current = <40>;
-				qcom,current-setting = <5>;
-				qcom,id = <6>;
-				qcom,mode = "manual";
-				qcom,source-sel = <1>;
-				qcom,mode-ctrl = <0x60>;
-			};
-		};
-
-		qcom,leds@a300 {
-			status = "okay";
-			qcom,led_mpp_4 {
-				label = "mpp";
-				linux,name = "green";
-				linux,default-trigger = "battery-full";
-				qcom,default-state = "off";
-				qcom,max-current = <40>;
-				qcom,current-setting = <5>;
-				qcom,id = <6>;
-				qcom,mode = "pwm";
-				qcom,pwm-us = <1000>;
-				qcom,source-sel = <8>;
-				qcom,mode-ctrl = <0x60>;
-				qcom,pwm-channel = <0>;
-				qcom,start-idx = <1>;
-				qcom,ramp-step-ms = <120>;
-				qcom,duty-pcts = [00 00 00 00 00
-						  00 00 00 00 00
-						  50 00 00 00 00
-						  00 00 00 00 00
-						  00];
-				qcom,use-blink;
-			};
-		};
-
-		qcom,leds@a500 {
-			status = "okay";
-			qcom,led_mpp_6 {
-				label = "mpp";
-				linux,name = "red";
-				linux,default-trigger = "battery-charging";
-				qcom,default-state = "off";
-				qcom,max-current = <40>;
-				qcom,current-setting = <5>;
-				qcom,id = <6>;
-				qcom,mode = "pwm";
-				qcom,pwm-us = <1000>;
-				qcom,mode-ctrl = <0x60>;
-				qcom,source-sel = <10>;
-				qcom,pwm-channel = <5>;
-				qcom,start-idx = <1>;
-				qcom,ramp-step-ms = <120>;
-				qcom,duty-pcts = [00 00 00 00 00
-						  00 00 00 00 00
-						  50 00 00 00 00
-						  00 00 00 00 00
-						  00];
-				qcom,use-blink;
-			};
-		};
-	};
-
-	qcom,pm8226@1 {
-		qcom,leds@d800 {
-			status = "okay";
-			qcom,wled_0 {
-				label = "wled";
-				linux,name = "wled:backlight";
-				linux,default-trigger = "bkl-trigger";
-				qcom,cs-out-en;
-				qcom,op-fdbck = <1>;
-				qcom,default-state = "on";
-				qcom,max-current = <20>;
-				qcom,ctrl-delay-us = <0>;
-				qcom,boost-curr-lim = <3>;
-				qcom,cp-sel = <0>;
-				qcom,switch-freq = <11>;
-				qcom,ovp-val = <0>;
-				qcom,num-strings = <1>;
-				qcom,id = <0>;
-			};
-		};
-
-		qcom,vibrator@c000 {
-			status = "okay";
-			qcom,vib-timeout-ms = <15000>;
-			qcom,vib-vtg-level-mV = <3100>;
-		};
-	};
-};
-
-&pm8226_gpios {
-	gpio@c000 { /* GPIO 1 */
-		/* XO_PMIC_CDC_MCLK enable for tapan codec */
-		qcom,mode = <1>;		/* Digital output */
-		qcom,output-type = <0>;	/* CMOS logic */
-		qcom,pull = <5>;		/* QPNP_PIN_PULL_NO*/
-		qcom,vin-sel = <3>;		/* QPNP_PIN_VIN3 */
-		qcom,out-strength = <3>;/* QPNP_PIN_OUT_STRENGTH_HIGH */
-		qcom,src-sel = <2>;		/* QPNP_PIN_SEL_FUNC_1 */
-		qcom,master-en = <1>;	/* Enable GPIO */
-	};
-
-	gpio@c100 { /* GPIO 2 */
-		qcom,mode = <1>;
-		qcom,output-type = <0>;
-		qcom,pull = <5>;
-		qcom,vin-sel = <3>;
-		qcom,out-strength = <3>;
-		qcom,src-sel = <2>;
-		qcom,master-en = <1>;
-	};
-
-	gpio@c200 { /* GPIO 3 */
-	};
-
-	gpio@c300 { /* GPIO 4 */
-	};
-
-	gpio@c400 { /* GPIO 5 */
-	};
-
-	gpio@c500 { /* GPIO 6 */
-	};
-
-	gpio@c600 { /* GPIO 7 */
-	};
-
-	gpio@c700 { /* GPIO 8 */
-	};
-};
-
-&pm8226_mpps {
-	mpp@a000 { /* MPP 1 */
-	};
-
-	mpp@a100 { /* MPP 2 */
-	};
-
-	mpp@a200 { /* MPP 3 */
-	};
-
-	mpp@a300 { /* MPP 4 */
-	};
-
-	mpp@a400 { /* MPP 5 */
-		/* PA_THERM0 config */
-		qcom,mode = <4>; /* AIN input */
-		qcom,invert = <1>; /* Enable MPP */
-		qcom,ain-route = <0>; /* AMUX 5 */
-		qcom,master-en = <1>;
-		qcom,src-sel = <0>; /* Function constant */
-	};
-
-	mpp@a500 { /* MPP 6 */
-	};
-
-	mpp@a600 { /* MPP 7 */
-	};
-
-	mpp@a700 { /* MPP 8 */
-		/* PA_THERM1 config */
-		qcom,mode = <4>; /* AIN input */
-		qcom,invert = <1>; /* Enable MPP */
-		qcom,ain-route = <3>; /* AMUX 8 */
-		qcom,master-en = <1>;
-		qcom,src-sel = <0>; /* Function constant */
-	};
-};
-
-&pm8226_chg {
-	qcom,charging-disabled;
-	qcom,use-default-batt-values;
-
-	qcom,bat-if@1200 {
-		status = "disabled";
-	};
-};
-
-&pm8226_vadc {
-	chan@14 {
-		label = "pa_therm0";
-		reg = <0x14>;
-		qcom,decimation = <0>;
-		qcom,pre-div-channel-scaling = <0>;
-		qcom,calibration-type = "ratiometric";
-		qcom,scale-function = <2>;
-		qcom,hw-settle-time = <2>;
-		qcom,fast-avg-setup = <0>;
-	};
-
-	chan@17 {
-		label = "pa_therm1";
-		reg = <0x17>;
-		qcom,decimation = <0>;
-		qcom,pre-div-channel-scaling = <0>;
-		qcom,calibration-type = "ratiometric";
-		qcom,scale-function = <2>;
-		qcom,hw-settle-time = <2>;
-		qcom,fast-avg-setup = <0>;
-	};
-};
-
-&mdss_mdp {
-	qcom,mdss-pref-prim-intf = "dsi";
-};
-
-&mdss_dsi0 {
-	qcom,dsi-pref-prim-pan = <&dsi_nt35590_720_vid>;
-};
-
-&dsi_nt35590_720_vid {
-	qcom,cont-splash-enabled;
-};
diff --git a/arch/arm/boot/dts/msm8226-coresight.dtsi b/arch/arm/boot/dts/msm8226-coresight.dtsi
index ec3f248..feef9d5 100644
--- a/arch/arm/boot/dts/msm8226-coresight.dtsi
+++ b/arch/arm/boot/dts/msm8226-coresight.dtsi
@@ -215,12 +215,56 @@
 		qcom,round-robin;
 	};
 
+	audio_etm0 {
+		compatible = "qcom,coresight-audio-etm";
+
+		coresight-id = <14>;
+		coresight-name = "coresight-audio-etm0";
+		coresight-nr-inports = <0>;
+		coresight-outports = <0>;
+		coresight-child-list = <&funnel_in0>;
+		coresight-child-ports = <2>;
+	};
+
+	modem_etm0 {
+		compatible = "qcom,coresight-modem-etm";
+
+		coresight-id = <15>;
+		coresight-name = "coresight-modem-etm0";
+		coresight-nr-inports = <0>;
+		coresight-outports = <0>;
+		coresight-child-list = <&funnel_in0>;
+		coresight-child-ports = <1>;
+	};
+
+	wcn_etm0 {
+		compatible = "qcom,coresight-wcn-etm";
+
+		coresight-id = <16>;
+		coresight-name = "coresight-wcn-etm0";
+		coresight-nr-inports = <0>;
+		coresight-outports = <0>;
+		coresight-child-list = <&funnel_in1>;
+		coresight-child-ports = <2>;
+	};
+
+	rpm_etm0 {
+		compatible = "qcom,coresight-rpm-etm";
+
+		coresight-id = <17>;
+		coresight-name = "coresight-rpm-etm0";
+		coresight-nr-inports = <0>;
+		coresight-outports = <0>;
+		coresight-child-list = <&funnel_in0>;
+		coresight-child-ports = <0>;
+	};
+
 	csr: csr@fc302000 {
 		compatible = "qcom,coresight-csr";
 		reg = <0xfc302000 0x1000>;
 		reg-names = "csr-base";
 
-		coresight-id = <14>;
+		coresight-id = <18>;
 		coresight-name = "coresight-csr";
 		coresight-nr-inports = <0>;
 
@@ -232,7 +276,7 @@
 		reg = <0xfc308000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <15>;
+		coresight-id = <19>;
 		coresight-name = "coresight-cti0";
 		coresight-nr-inports = <0>;
 	};
@@ -242,7 +286,7 @@
 		reg = <0xfc309000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <16>;
+		coresight-id = <20>;
 		coresight-name = "coresight-cti1";
 		coresight-nr-inports = <0>;
 	};
@@ -252,7 +296,7 @@
 		reg = <0xfc30a000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <17>;
+		coresight-id = <21>;
 		coresight-name = "coresight-cti2";
 		coresight-nr-inports = <0>;
 	};
@@ -262,7 +306,7 @@
 		reg = <0xfc30b000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <18>;
+		coresight-id = <22>;
 		coresight-name = "coresight-cti3";
 		coresight-nr-inports = <0>;
 	};
@@ -272,7 +316,7 @@
 		reg = <0xfc30c000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <19>;
+		coresight-id = <23>;
 		coresight-name = "coresight-cti4";
 		coresight-nr-inports = <0>;
 	};
@@ -282,7 +326,7 @@
 		reg = <0xfc30d000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <20>;
+		coresight-id = <24>;
 		coresight-name = "coresight-cti5";
 		coresight-nr-inports = <0>;
 	};
@@ -292,7 +336,7 @@
 		reg = <0xfc30e000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <21>;
+		coresight-id = <25>;
 		coresight-name = "coresight-cti6";
 		coresight-nr-inports = <0>;
 	};
@@ -302,7 +346,7 @@
 		reg = <0xfc30f000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <22>;
+		coresight-id = <26>;
 		coresight-name = "coresight-cti7";
 		coresight-nr-inports = <0>;
 	};
@@ -312,7 +356,7 @@
 		reg = <0xfc310000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <23>;
+		coresight-id = <27>;
 		coresight-name = "coresight-cti8";
 		coresight-nr-inports = <0>;
 	};
@@ -322,7 +366,7 @@
 		reg = <0xfc340000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <24>;
+		coresight-id = <28>;
 		coresight-name = "coresight-cti-l2";
 		coresight-nr-inports = <0>;
 	};
@@ -332,7 +376,7 @@
 		reg = <0xfc341000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <25>;
+		coresight-id = <29>;
 		coresight-name = "coresight-cti-cpu0";
 		coresight-nr-inports = <0>;
 	};
@@ -342,7 +386,7 @@
 		reg = <0xfc342000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <26>;
+		coresight-id = <30>;
 		coresight-name = "coresight-cti-cpu1";
 		coresight-nr-inports = <0>;
 	};
@@ -352,7 +396,7 @@
 		reg = <0xfc343000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <27>;
+		coresight-id = <31>;
 		coresight-name = "coresight-cti-cpu2";
 		coresight-nr-inports = <0>;
 	};
@@ -362,11 +406,61 @@
 		reg = <0xfc344000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <28>;
+		coresight-id = <32>;
 		coresight-name = "coresight-cti-cpu3";
 		coresight-nr-inports = <0>;
 	};
 
+	cti_video_cpu0: cti@fc348000 {
+		compatible = "arm,coresight-cti";
+		reg = <0xfc348000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-id = <33>;
+		coresight-name = "coresight-cti-video-cpu0";
+		coresight-nr-inports = <0>;
+	};
+
+	cti_wcn_cpu0: cti@fc34d000 {
+		compatible = "arm,coresight-cti";
+		reg = <0xfc34d000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-id = <34>;
+		coresight-name = "coresight-cti-wcn-cpu0";
+		coresight-nr-inports = <0>;
+	};
+
+	cti_modem_cpu0: cti@fc350000 {
+		compatible = "arm,coresight-cti";
+		reg = <0xfc350000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-id = <35>;
+		coresight-name = "coresight-cti-modem-cpu0";
+		coresight-nr-inports = <0>;
+	};
+
+	cti_audio_cpu0: cti@fc354000 {
+		compatible = "arm,coresight-cti";
+		reg = <0xfc354000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-id = <36>;
+		coresight-name = "coresight-cti-audio-cpu0";
+		coresight-nr-inports = <0>;
+	};
+
+	cti_rpm_cpu0: cti@fc358000 {
+		compatible = "arm,coresight-cti";
+		reg = <0xfc358000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-id = <37>;
+		coresight-name = "coresight-cti-rpm-cpu0";
+		coresight-nr-inports = <0>;
+	};
+
 	hwevent: hwevent@fd828018 {
 		compatible = "qcom,coresight-hwevent";
 		reg = <0xfd828018 0x80>,
@@ -375,7 +469,7 @@
 		      <0xfc401600 0x80>;
 		reg-names = "mmss-mux", "apcs-mux", "ppss-mux", "gcc-mux";
 
-		coresight-id = <29>;
+		coresight-id = <38>;
 		coresight-name = "coresight-hwevent";
 		coresight-nr-inports = <0>;
 
@@ -387,7 +481,7 @@
 		reg = <0xfc4be024 0x8>;
 		reg-names = "fuse-base";
 
-		coresight-id = <30>;
+		coresight-id = <39>;
 		coresight-name = "coresight-fuse";
 		coresight-nr-inports = <0>;
 	};
diff --git a/arch/arm/boot/dts/msm8226-mdss-panels.dtsi b/arch/arm/boot/dts/msm8226-mdss-panels.dtsi
index eeec175..0731a9a 100644
--- a/arch/arm/boot/dts/msm8226-mdss-panels.dtsi
+++ b/arch/arm/boot/dts/msm8226-mdss-panels.dtsi
@@ -16,3 +16,4 @@
 /include/ "dsi-panel-nt35596-1080p-video.dtsi"
 /include/ "dsi-panel-nt35590-720p-cmd.dtsi"
 /include/ "dsi-panel-ssd2080m-720p-video.dtsi"
+/include/ "dsi-panel-jdi-1080p-video.dtsi"
diff --git a/arch/arm/boot/dts/msm8226-mdss.dtsi b/arch/arm/boot/dts/msm8226-mdss.dtsi
index 3e2507ff..e2891d1 100644
--- a/arch/arm/boot/dts/msm8226-mdss.dtsi
+++ b/arch/arm/boot/dts/msm8226-mdss.dtsi
@@ -36,7 +36,7 @@
 		qcom,mdss-wb-off = <0x00011100 0x00013100>;
 		qcom,mdss-intf-off = <0x00000000 0x00021300>;
 		qcom,mdss-rot-block-size = <64>;
-		qcom,mdss-smp-mb-per-pipe = <2>;
+		qcom,mdss-smp-mb-per-pipe = <4>;
 		vdd-cx-supply = <&pm8226_s1_corner>;
 
 		qcom,vbif-settings = <0x004 0x00000001>,
diff --git a/arch/arm/boot/dts/msm8226-mtp.dtsi b/arch/arm/boot/dts/msm8226-mtp.dtsi
deleted file mode 100644
index dbd2031..0000000
--- a/arch/arm/boot/dts/msm8226-mtp.dtsi
+++ /dev/null
@@ -1,508 +0,0 @@
-/* Copyright (c) 2013, The Linux Foundation. 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.
- */
-
-/include/ "msm8226-camera-sensor-mtp.dtsi"
-
-&soc {
-	serial@f991f000 {
-		status = "ok";
-	};
-
-	i2c@f9927000 { /* BLSP1 QUP5 */
-		synaptics@20 {
-			compatible = "synaptics,rmi4";
-			reg = <0x20>;
-			interrupt-parent = <&msmgpio>;
-			interrupts = <17 0x2008>;
-			vdd-supply = <&pm8226_l19>;
-			vcc_i2c-supply = <&pm8226_lvs1>;
-			synaptics,reset-gpio = <&msmgpio 16 0x00>;
-			synaptics,irq-gpio = <&msmgpio 17 0x2008>;
-			synaptics,button-map = <139 102 158>;
-			synaptics,i2c-pull-up;
-			synaptics,power-down;
-			synaptics,disable-gpios;
-		};
-	};
-
-	i2c@f9925000 { /* BLSP1 QUP3 */
-		nfc-nci@0e {
-			compatible = "qcom,nfc-nci";
-			reg = <0x0e>;
-			qcom,irq-gpio = <&msmgpio 21 0x00>;
-			qcom,dis-gpio = <&msmgpio 20 0x00>;
-			qcom,clk-src = "BBCLK2";
-			qcom,clk-en-gpio = <&msmgpio 0 0x00>;
-			interrupt-parent = <&msmgpio>;
-			interrupts = <21 0>;
-			qcom,clk-gpio = <&pm8226_gpios 3 0>;
-		};
-	};
-	gpio_keys {
-		compatible = "gpio-keys";
-		input-name = "gpio-keys";
-
-		camera_focus {
-			label = "camera_focus";
-			gpios = <&msmgpio 108 0x1>;
-			linux,input-type = <1>;
-			linux,code = <0x210>;
-			gpio-key,wakeup;
-			debounce-interval = <15>;
-		};
-
-		camera_snapshot {
-			label = "camera_snapshot";
-			gpios = <&msmgpio 107 0x1>;
-			linux,input-type = <1>;
-			linux,code = <0x2fe>;
-			gpio-key,wakeup;
-			debounce-interval = <15>;
-		};
-
-		vol_up {
-			label = "volume_up";
-			gpios = <&msmgpio 106 0x1>;
-			linux,input-type = <1>;
-			linux,code = <115>;
-			gpio-key,wakeup;
-			debounce-interval = <15>;
-		};
-	};
-
-	spi@f9923000 {
-		ethernet-switch@3 {
-			compatible = "micrel,ks8851";
-			reg = <3>;
-			interrupt-parent = <&msmgpio>;
-			interrupts = <115 0x8>;
-			spi-max-frequency = <4800000>;
-			rst-gpio = <&msmgpio 114 0>;
-			vdd-io-supply = <&pm8226_lvs1>;
-			vdd-phy-supply = <&pm8226_lvs1>;
-		};
-	};
-
-	sound {
-		qcom,audio-routing =
-			"RX_BIAS", "MCLK",
-			"LDO_H", "MCLK",
-			"SPK_OUT", "MCLK",
-			"SPK_OUT", "EXT_VDD_SPKR",
-			"AMIC1", "MIC BIAS1 External",
-			"MIC BIAS1 External", "Handset Mic",
-			"AMIC2", "MIC BIAS2 External",
-			"MIC BIAS2 External", "Headset Mic",
-			"AMIC4", "MIC BIAS2 External",
-			"MIC BIAS2 External", "ANCRight Headset Mic",
-			"AMIC5", "MIC BIAS2 External",
-			"MIC BIAS2 External", "ANCLeft Headset Mic";
-
-		qcom,cdc-mclk-gpios = <&pm8226_gpios 1 0>;
-		qcom,cdc-vdd-spkr-gpios = <&pm8226_gpios 2 0>;
-	};
-
-	sound-9302 {
-		qcom,audio-routing =
-			"RX_BIAS", "MCLK",
-			"LDO_H", "MCLK",
-			"SPK_OUT", "MCLK",
-			"SPK_OUT", "EXT_VDD_SPKR",
-			"AMIC1", "MIC BIAS1 Internal1",
-			"MIC BIAS1 Internal1", "Handset Mic",
-			"AMIC2", "MIC BIAS2 External",
-			"MIC BIAS2 External", "Headset Mic",
-			"AMIC3", "MIC BIAS1 External",
-			"MIC BIAS1 External", "Handset Mic";
-
-		qcom,cdc-mclk-gpios = <&pm8226_gpios 1 0>;
-		qcom,cdc-vdd-spkr-gpios = <&pm8226_gpios 2 0>;
-	};
-};
-
-&usb_otg {
-	#address-cells = <0>;
-	interrupt-parent = <&usb_otg>;
-	interrupts = <0 1 2>;
-	#interrupt-cells = <1>;
-	interrupt-map-mask = <0xffffffff>;
-	interrupt-map = <0 &intc 0 134 0
-			1 &intc 0 140 0
-			2 &spmi_bus 0x0 0x0 0x9 0x0>;
-	interrupt-names = "core_irq", "async_irq", "pmic_id_irq";
-
-	qcom,hsusb-otg-mode = <3>;
-	vbus_otg-supply = <&pm8226_chg_otg>;
-};
-
-&sdcc1 {
-	vdd-supply = <&pm8226_l17>;
-	qcom,vdd-voltage-level = <2950000 2950000>;
-	qcom,vdd-current-level = <800 500000>;
-
-	vdd-io-supply = <&pm8226_l6>;
-	qcom,vdd-io-always-on;
-	qcom,vdd-io-voltage-level = <1800000 1800000>;
-	qcom,vdd-io-current-level = <250 154000>;
-
-	qcom,pad-pull-on = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
-	qcom,pad-pull-off = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
-	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
-	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
-
-	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
-	qcom,sup-voltages = <2950 2950>;
-
-	qcom,bus-speed-mode = "HS200_1p8v", "DDR_1p8v";
-	qcom,nonremovable;
-
-	status = "disabled";
-};
-
-&sdhc_1 {
-	vdd-supply = <&pm8226_l17>;
-	qcom,vdd-voltage-level = <2950000 2950000>;
-	qcom,vdd-current-level = <800 500000>;
-
-	vdd-io-supply = <&pm8226_l6>;
-	qcom,vdd-io-always-on;
-	qcom,vdd-io-voltage-level = <1800000 1800000>;
-	qcom,vdd-io-current-level = <250 154000>;
-
-	qcom,pad-pull-on = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
-	qcom,pad-pull-off = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
-	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
-	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
-
-	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
-	qcom,bus-speed-mode = "HS200_1p8v", "DDR_1p8v";
-	qcom,nonremovable;
-
-	status = "ok";
-};
-
-&sdcc2 {
-	vdd-supply = <&pm8226_l18>;
-	qcom,vdd-voltage-level = <2950000 2950000>;
-	qcom,vdd-current-level = <9000 800000>;
-
-	vdd-io-supply = <&pm8226_l21>;
-	qcom,vdd-io-voltage-level = <1800000 2950000>;
-	qcom,vdd-io-current-level = <6 22000>;
-
-	qcom,pad-pull-on = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
-	qcom,pad-pull-off = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
-	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
-	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
-
-	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
-	qcom,sup-voltages = <2950 2950>;
-
-	qcom,xpc;
-	qcom,bus-speed-mode = "SDR12", "SDR25", "SDR50", "DDR50", "SDR104";
-	qcom,current-limit = <600>; #address-cells = <0>; interrupt-parent = <&sdcc2>;
-	interrupts = <0 1 2>;
-	#interrupt-cells = <1>;
-	interrupt-map-mask = <0xffffffff>;
-	interrupt-map = <0 &intc 0 125 0
-			1 &intc 0 220 0
-			2 &msmgpio 38 0x3>;
-	interrupt-names = "core_irq", "bam_irq", "status_irq";
-	cd-gpios = <&msmgpio 38 0x1>;
-
-	status = "disabled";
-};
-
-&sdhc_2 {
-	vdd-supply = <&pm8226_l18>;
-	qcom,vdd-voltage-level = <2950000 2950000>;
-	qcom,vdd-current-level = <9000 800000>;
-
-	vdd-io-supply = <&pm8226_l21>;
-	qcom,vdd-io-voltage-level = <1800000 2950000>;
-	qcom,vdd-io-current-level = <6 22000>;
-
-	qcom,pad-pull-on = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
-	qcom,pad-pull-off = <0x0 0x3 0x3>; /* no-pull, pull-up, pull-up */
-	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
-	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
-
-	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
-
-	#address-cells = <0>;
-	interrupt-parent = <&sdhc_2>;
-	interrupts = <0 1 2>;
-	#interrupt-cells = <1>;
-	interrupt-map-mask = <0xffffffff>;
-	interrupt-map = <0 &intc 0 125 0
-			1 &intc 0 221 0
-			2 &msmgpio 38 0x3>;
-	interrupt-names = "hc_irq", "pwr_irq", "status_irq";
-	cd-gpios = <&msmgpio 38 0x1>;
-
-	status = "ok";
-};
-
-&spmi_bus {
-	qcom,pm8226@0 {
-		qcom,leds@a100 {
-			status = "okay";
-			qcom,led_mpp_2 {
-				label = "mpp";
-				linux,name = "button-backlight";
-				linux,default-trigger = "none";
-				qcom,default-state = "off";
-				qcom,max-current = <40>;
-				qcom,current-setting = <5>;
-				qcom,id = <6>;
-				qcom,mode = "manual";
-				qcom,source-sel = <1>;
-				qcom,mode-ctrl = <0x60>;
-			};
-		};
-
-		qcom,leds@a300 {
-			status = "okay";
-			qcom,led_mpp_4 {
-				label = "mpp";
-				linux,name = "green";
-				linux,default-trigger = "battery-full";
-				qcom,default-state = "off";
-				qcom,max-current = <40>;
-				qcom,current-setting = <5>;
-				qcom,id = <6>;
-				qcom,mode = "pwm";
-				qcom,pwm-us = <1000>;
-				qcom,source-sel = <8>;
-				qcom,mode-ctrl = <0x60>;
-				qcom,pwm-channel = <0>;
-				qcom,start-idx = <1>;
-				qcom,ramp-step-ms = <120>;
-				qcom,duty-pcts = [00 00 00 00 00
-						  00 00 00 00 00
-						  50 00 00 00 00
-						  00 00 00 00 00
-						  00];
-				qcom,use-blink;
-			};
-		};
-
-		qcom,leds@a500 {
-			status = "okay";
-			qcom,led_mpp_6 {
-				label = "mpp";
-				linux,name = "red";
-				linux,default-trigger = "battery-charging";
-				qcom,default-state = "off";
-				qcom,max-current = <40>;
-				qcom,current-setting = <5>;
-				qcom,id = <6>;
-				qcom,mode = "pwm";
-				qcom,pwm-us = <1000>;
-				qcom,mode-ctrl = <0x60>;
-				qcom,source-sel = <10>;
-				qcom,pwm-channel = <5>;
-				qcom,start-idx = <1>;
-				qcom,ramp-step-ms = <120>;
-				qcom,duty-pcts = [00 00 00 00 00
-						  00 00 00 00 00
-						  50 00 00 00 00
-						  00 00 00 00 00
-						  00];
-				qcom,use-blink;
-			};
-		};
-	};
-
-	qcom,pm8226@1 {
-                qcom,leds@d300 {
-                        status = "okay";
-                };
-
-		qcom,leds@d800 {
-			status = "okay";
-			qcom,wled_0 {
-				label = "wled";
-				linux,name = "wled:backlight";
-				linux,default-trigger = "bkl-trigger";
-				qcom,cs-out-en;
-				qcom,op-fdbck = <1>;
-				qcom,default-state = "on";
-				qcom,max-current = <20>;
-				qcom,ctrl-delay-us = <0>;
-				qcom,boost-curr-lim = <3>;
-				qcom,cp-sel = <0>;
-				qcom,switch-freq = <11>;
-				qcom,ovp-val = <0>;
-				qcom,num-strings = <1>;
-				qcom,id = <0>;
-			};
-		};
-
-		qcom,vibrator@c000 {
-			status = "okay";
-			qcom,vib-timeout-ms = <15000>;
-			qcom,vib-vtg-level-mV = <3100>;
-		};
-	};
-};
-
-&pm8226_gpios {
-	gpio@c000 { /* GPIO 1 */
-		/* XO_PMIC_CDC_MCLK enable for tapan codec */
-		qcom,mode = <1>;		/* Digital output */
-		qcom,output-type = <0>;	/* CMOS logic */
-		qcom,pull = <5>;		/* QPNP_PIN_PULL_NO*/
-		qcom,vin-sel = <3>;		/* QPNP_PIN_VIN3 */
-		qcom,out-strength = <3>;/* QPNP_PIN_OUT_STRENGTH_HIGH */
-		qcom,src-sel = <2>;		/* QPNP_PIN_SEL_FUNC_1 */
-		qcom,master-en = <1>;	/* Enable GPIO */
-	};
-
-	gpio@c100 { /* GPIO 2 */
-		qcom,mode = <1>;
-		qcom,output-type = <0>;
-		qcom,pull = <5>;
-		qcom,vin-sel = <3>;
-		qcom,out-strength = <3>;
-		qcom,src-sel = <2>;
-		qcom,master-en = <1>;
-	};
-
-	gpio@c200 { /* GPIO 3 */
-		qcom,mode = <0>;		/* QPNP_PIN_MODE_DIG_IN */
-		qcom,pull = <5>;		/* QPNP_PIN_PULL_NO */
-		qcom,vin-sel = <2>;		/* QPNP_PIN_VIN2 */
-		qcom,src-sel = <2>;		/* QPNP_PIN_SEL_FUNC_1 */
-		qcom,master-en = <1>;
-	};
-
-	gpio@c300 { /* GPIO 4 */
-	};
-
-	gpio@c400 { /* GPIO 5 */
-	};
-
-	gpio@c500 { /* GPIO 6 */
-	};
-
-	gpio@c600 { /* GPIO 7 */
-	};
-
-	gpio@c700 { /* GPIO 8 */
-	};
-};
-
-&pm8226_mpps {
-	mpp@a000 { /* MPP 1 */
-	};
-
-	mpp@a100 { /* MPP 2 */
-	};
-
-	mpp@a200 { /* MPP 3 */
-	};
-
-	mpp@a300 { /* MPP 4 */
-	};
-
-	mpp@a400 { /* MPP 5 */
-		/* PA_THERM0 config */
-		qcom,mode = <4>; /* AIN input */
-		qcom,invert = <1>; /* Enable MPP */
-		qcom,ain-route = <0>; /* AMUX 5 */
-		qcom,master-en = <1>;
-		qcom,src-sel = <0>; /* Function constant */
-	};
-
-	mpp@a500 { /* MPP 6 */
-	};
-
-	mpp@a600 { /* MPP 7 */
-	};
-
-	mpp@a700 { /* MPP 8 */
-		/* PA_THERM1 config */
-		qcom,mode = <4>; /* AIN input */
-		qcom,invert = <1>; /* Enable MPP */
-		qcom,ain-route = <3>; /* AMUX 8 */
-		qcom,master-en = <1>;
-		qcom,src-sel = <0>; /* Function constant */
-	};
-};
-
-&pm8226_vadc {
-	chan@14 {
-		label = "pa_therm0";
-		reg = <0x14>;
-		qcom,decimation = <0>;
-		qcom,pre-div-channel-scaling = <0>;
-		qcom,calibration-type = "ratiometric";
-		qcom,scale-function = <2>;
-		qcom,hw-settle-time = <2>;
-		qcom,fast-avg-setup = <0>;
-	};
-
-	chan@17 {
-		label = "pa_therm1";
-		reg = <0x17>;
-		qcom,decimation = <0>;
-		qcom,pre-div-channel-scaling = <0>;
-		qcom,calibration-type = "ratiometric";
-		qcom,scale-function = <2>;
-		qcom,hw-settle-time = <2>;
-		qcom,fast-avg-setup = <0>;
-	};
-};
-
-/ {
-	mtp_batterydata: qcom,battery-data {
-		qcom,rpull-up-kohm = <100>;
-		qcom,vref-batt-therm = <1800000>;
-
-		/include/ "batterydata-palladium.dtsi"
-		/include/ "batterydata-mtp-3000mah.dtsi"
-	};
-};
-
-&pm8226_bms {
-	status = "ok";
-	qcom,enable-fcc-learning;
-	qcom,min-fcc-learning-soc = <20>;
-	qcom,min-fcc-ocv-pc = <30>;
-	qcom,min-fcc-learning-samples = <5>;
-	qcom,fcc-resolution = <10>;
-	qcom,battery-data = <&mtp_batterydata>;
-};
-
-&pm8226_chg {
-	qcom,charging-disabled;
-	qcom,battery-data = <&mtp_batterydata>;
-};
-
-&slim_msm {
-	tapan_codec {
-		qcom,cdc-micbias1-ext-cap;
-	};
-};
-
-&mdss_mdp {
-	qcom,mdss-pref-prim-intf = "dsi";
-};
-
-&mdss_dsi0 {
-	qcom,dsi-pref-prim-pan = <&dsi_nt35590_720_vid>;
-};
-
-&dsi_nt35590_720_vid {
-	qcom,cont-splash-enabled;
-};
diff --git a/arch/arm/boot/dts/msm8226-qrd-skuf.dtsi b/arch/arm/boot/dts/msm8226-qrd-skuf.dtsi
index 66f5095..2e32ac4 100755
--- a/arch/arm/boot/dts/msm8226-qrd-skuf.dtsi
+++ b/arch/arm/boot/dts/msm8226-qrd-skuf.dtsi
@@ -85,25 +85,25 @@
 			goodix,button-map= <158 102 139>;
 			goodix,product-id = "915";
 			goodix,cfg-data0 = [
-				41 D0 02 00 05 05 35 01 01 0F
-				2D 06 50 32 03 05 00 00 00 00
-				00 00 05 18 1A 1E 14 8C 0E 0E
-				3F 3D 2A 09 00 00 00 99 04 1D
-				00 00 00 00 00 00 00 00 00 00
-				00 32 6E 94 D5 01 05 00 00 04
-				CE 36 00 B5 3F 00 9E 4A 00 8B
-				57 00 7C 65 00 7C 10 38 68 00
-				56 50 35 66 66 27 00 00 00 00
+				41 D0 02 00 05 05 35 11 01 0F
+				2D 06 50 32 03 02 00 00 00 00
+				00 00 05 18 1A 1E 14 8C 2E 0E
+				59 5B B2 04 00 00 00 99 03 11
+				00 1C 00 00 00 00 00 00 00 00
+				00 53 A6 94 C5 01 05 00 00 08
+				7F 59 00 71 66 00 64 75 00 58
+				87 00 4E 9B 00 4E 10 38 68 00
+				56 45 30 66 66 27 00 00 00 00
 				00 00 00 00 00 00 00 00 00 00
 				00 00 00 00 00 00 00 00 00 00
 				00 00 02 04 06 08 0A 0C 0E 10
-				12 14 16 18 1A 1C 00 00 00 00
-				00 00 00 00 00 00 00 00 00 00
-				00 00 00 02 04 06 08 0A 0C 0F
+				12 14 16 18 1A 1C FF FF FF FF
+				FF FF FF FF FF FF FF FF FF FF
+				FF FF 00 02 04 06 08 0A 0C 0F
 				10 12 13 14 16 18 1C 1D 1E 1F
-				20 21 22 24 26 28 29 2A 00 00
-				00 FF FF FF FF FF FF FF FF FF
-				FF FF FF FF A3 01];
+				20 21 22 24 26 28 29 2A FF FF
+				FF FF FF FF FF FF FF FF FF FF
+				FF FF FF FF 03 01];
 			goodix,cfg-data1 = [
 				41 D0 02 00 05 05 35 01 01 C3
 				2D 06 55 32 03 03 00 00 00 00
@@ -124,6 +124,7 @@
 				20 21 22 24 26 28 29 2A FF FF
 				FF FF FF FF FF FF FF FF FF FF
 				FF FF FF FF 3E 01];
+			goodix,fw_name = "gtp_fw.bin";
 		};
 	};
 };
diff --git a/arch/arm/boot/dts/msm8226-qrd.dtsi b/arch/arm/boot/dts/msm8226-qrd.dtsi
index c31c612..7ff97f6 100644
--- a/arch/arm/boot/dts/msm8226-qrd.dtsi
+++ b/arch/arm/boot/dts/msm8226-qrd.dtsi
@@ -28,6 +28,7 @@
 			synaptics,reset-gpio = <&msmgpio 16 0x00>;
 			synaptics,irq-gpio = <&msmgpio 17 0x2008>;
 			synaptics,button-map = <139 102 158>;
+			synaptics,fw-image-name = "PR1468813.img";
 			synaptics,i2c-pull-up;
 			synaptics,power-down;
 			synaptics,disable-gpios;
@@ -494,6 +495,7 @@
 
 &mdss_mdp {
 	qcom,mdss-pref-prim-intf = "dsi";
+	batfet-supply = <&pm8226_chg_batif>;
 };
 
 &mdss_dsi0 {
diff --git a/arch/arm/boot/dts/msm8226-regulator.dtsi b/arch/arm/boot/dts/msm8226-regulator.dtsi
index 23a2158..9764982 100644
--- a/arch/arm/boot/dts/msm8226-regulator.dtsi
+++ b/arch/arm/boot/dts/msm8226-regulator.dtsi
@@ -336,7 +336,7 @@
 		pm8226_l16: regulator-l16 {
 			regulator-name = "8226_l16";
 			regulator-min-microvolt = <3000000>;
-			regulator-max-microvolt = <3300000>;
+			regulator-max-microvolt = <3350000>;
 			qcom,init-voltage = <3300000>;
 			status = "okay";
 		};
@@ -423,7 +423,7 @@
 		pm8226_l24: regulator-l24 {
 			regulator-name = "8226_l24";
 			regulator-min-microvolt = <1300000>;
-			regulator-max-microvolt = <1300000>;
+			regulator-max-microvolt = <1350000>;
 			qcom,init-voltage = <1300000>;
 			status = "okay";
 		};
diff --git a/arch/arm/boot/dts/msm8226-v1-cdp.dts b/arch/arm/boot/dts/msm8226-v1-cdp.dts
index e426a97..4b8cafd 100644
--- a/arch/arm/boot/dts/msm8226-v1-cdp.dts
+++ b/arch/arm/boot/dts/msm8226-v1-cdp.dts
@@ -12,7 +12,7 @@
 
 /dts-v1/;
 /include/ "msm8226-v1.dtsi"
-/include/ "msm8226-cdp.dtsi"
+/include/ "msm8226-720p-cdp.dtsi"
 
 / {
 	model = "Qualcomm MSM 8226 CDP";
diff --git a/arch/arm/boot/dts/msm8226-v1-mtp.dts b/arch/arm/boot/dts/msm8226-v1-mtp.dts
index 08d7cec..a1e78b7 100644
--- a/arch/arm/boot/dts/msm8226-v1-mtp.dts
+++ b/arch/arm/boot/dts/msm8226-v1-mtp.dts
@@ -12,7 +12,7 @@
 
 /dts-v1/;
 /include/ "msm8226-v1.dtsi"
-/include/ "msm8226-mtp.dtsi"
+/include/ "msm8226-720p-mtp.dtsi"
 
 / {
 	model = "Qualcomm MSM 8226 MTP";
diff --git a/arch/arm/boot/dts/msm8226-v2-1080p-cdp.dts b/arch/arm/boot/dts/msm8226-v2-1080p-cdp.dts
new file mode 100644
index 0000000..77cc08c
--- /dev/null
+++ b/arch/arm/boot/dts/msm8226-v2-1080p-cdp.dts
@@ -0,0 +1,26 @@
+/* Copyright (c) 2013, The Linux Foundation. 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.
+ */
+
+/dts-v1/;
+/include/ "msm8226-v2.dtsi"
+/include/ "msm8226-1080p-cdp.dtsi"
+/include/ "msm8226-camera-sensor-cdp.dtsi"
+
+/ {
+	model = "Qualcomm MSM 8226v2 CDP";
+	compatible = "qcom,msm8226-cdp", "qcom,msm8226", "qcom,cdp";
+	qcom,board-id = <1 2>;
+};
+
+&hsic_host {
+	status = "ok";
+};
diff --git a/arch/arm/boot/dts/msm8226-v2-1080p-mtp.dts b/arch/arm/boot/dts/msm8226-v2-1080p-mtp.dts
new file mode 100644
index 0000000..b12a77d
--- /dev/null
+++ b/arch/arm/boot/dts/msm8226-v2-1080p-mtp.dts
@@ -0,0 +1,22 @@
+/* Copyright (c) 2013, The Linux Foundation. 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.
+ */
+
+/dts-v1/;
+/include/ "msm8226-v2.dtsi"
+/include/ "msm8226-1080p-mtp.dtsi"
+/include/ "msm8226-camera-sensor-mtp.dtsi"
+
+/ {
+	model = "Qualcomm MSM 8226v2 MTP";
+	compatible = "qcom,msm8226-mtp", "qcom,msm8226", "qcom,mtp";
+	qcom,board-id = <8 2>;
+};
diff --git a/arch/arm/boot/dts/msm8226-v2-720p-cdp.dts b/arch/arm/boot/dts/msm8226-v2-720p-cdp.dts
new file mode 100644
index 0000000..966ae2b
--- /dev/null
+++ b/arch/arm/boot/dts/msm8226-v2-720p-cdp.dts
@@ -0,0 +1,26 @@
+/* Copyright (c) 2013, The Linux Foundation. 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.
+ */
+
+/dts-v1/;
+/include/ "msm8226-v2.dtsi"
+/include/ "msm8226-720p-cdp.dtsi"
+/include/ "msm8226-camera-sensor-cdp.dtsi"
+
+/ {
+	model = "Qualcomm MSM 8226v2 CDP";
+	compatible = "qcom,msm8226-cdp", "qcom,msm8226", "qcom,cdp";
+	qcom,board-id = <1 0>;
+};
+
+&hsic_host {
+	status = "ok";
+};
diff --git a/arch/arm/boot/dts/msm8226-v2-720p-mtp.dts b/arch/arm/boot/dts/msm8226-v2-720p-mtp.dts
new file mode 100644
index 0000000..0768b75
--- /dev/null
+++ b/arch/arm/boot/dts/msm8226-v2-720p-mtp.dts
@@ -0,0 +1,22 @@
+/* Copyright (c) 2013, The Linux Foundation. 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.
+ */
+
+/dts-v1/;
+/include/ "msm8226-v2.dtsi"
+/include/ "msm8226-720p-mtp.dtsi"
+/include/ "msm8226-camera-sensor-mtp.dtsi"
+
+/ {
+	model = "Qualcomm MSM 8226v2 MTP";
+	compatible = "qcom,msm8226-mtp", "qcom,msm8226", "qcom,mtp";
+	qcom,board-id = <8 0>;
+};
diff --git a/arch/arm/boot/dts/msm8226-v2-cdp.dts b/arch/arm/boot/dts/msm8226-v2-cdp.dts
deleted file mode 100644
index 3302d26..0000000
--- a/arch/arm/boot/dts/msm8226-v2-cdp.dts
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Copyright (c) 2013, The Linux Foundation. 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.
- */
-
-/dts-v1/;
-/include/ "msm8226-v2.dtsi"
-/include/ "msm8226-cdp.dtsi"
-/include/ "msm8226-camera-sensor-cdp.dtsi"
-
-/ {
-	model = "Qualcomm MSM 8226v2 CDP";
-	compatible = "qcom,msm8226-cdp", "qcom,msm8226", "qcom,cdp";
-	qcom,board-id = <1 0>;
-};
-
-&hsic_host {
-	status = "ok";
-};
diff --git a/arch/arm/boot/dts/msm8226-v2-mtp.dts b/arch/arm/boot/dts/msm8226-v2-mtp.dts
deleted file mode 100644
index 6034107..0000000
--- a/arch/arm/boot/dts/msm8226-v2-mtp.dts
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright (c) 2013, The Linux Foundation. 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.
- */
-
-/dts-v1/;
-/include/ "msm8226-v2.dtsi"
-/include/ "msm8226-mtp.dtsi"
-/include/ "msm8226-camera-sensor-mtp.dtsi"
-
-/ {
-	model = "Qualcomm MSM 8226v2 MTP";
-	compatible = "qcom,msm8226-mtp", "qcom,msm8226", "qcom,mtp";
-	qcom,board-id = <8 0>;
-};
diff --git a/arch/arm/boot/dts/msm8226-v2-qrd-pvt.dts b/arch/arm/boot/dts/msm8226-v2-qrd-pvt.dts
new file mode 100644
index 0000000..4b6a1da
--- /dev/null
+++ b/arch/arm/boot/dts/msm8226-v2-qrd-pvt.dts
@@ -0,0 +1,29 @@
+/* Copyright (c) 2013, The Linux Foundation. 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.
+ */
+
+/dts-v1/;
+/include/ "msm8226-v2.dtsi"
+/include/ "msm8226-qrd.dtsi"
+
+/ {
+	model = "Qualcomm MSM 8226v2 QRD PVT";
+	compatible = "qcom,msm8226-qrd", "qcom,msm8226", "qcom,qrd";
+	qcom,board-id = <0x3000b 0>;
+};
+
+&mdss_dsi0 {
+	qcom,dsi-pref-prim-pan = <&dsi_nt35590_720_vid>;
+};
+
+&dsi_nt35590_720_vid {
+	qcom,cont-splash-enabled;
+};
diff --git a/arch/arm/boot/dts/msm8226.dtsi b/arch/arm/boot/dts/msm8226.dtsi
index 151b508..906e4a8 100644
--- a/arch/arm/boot/dts/msm8226.dtsi
+++ b/arch/arm/boot/dts/msm8226.dtsi
@@ -39,7 +39,7 @@
 
 		qsecom_mem: qsecom_region {
 			linux,contiguous-region;
-			reg = <0 0x780000>;
+			reg = <0 0xd00000>;
 			label = "qsecom_mem";
 		};
 	};
@@ -183,8 +183,8 @@
 			<268000 348000>,
 			<505000 657000>;
 		qcom,buffer-type-tz-usage-table = <0x1 0x1>,
-			<0x2 0x2>,
-			<0x1f0 0x3>;
+			<0x6 0x2>,
+			<0x7C0 0x3>;
 		qcom,max-hw-load = <352800>; /* 720p @ 30 + 1080p @ 30 */
 		qcom,vidc-iommu-domains {
 			qcom,domain-ns {
@@ -216,6 +216,13 @@
 		reg = <0xf991f000 0x1000>;
 		interrupts = <0 109 0>;
 		status = "disabled";
+
+		qcom,msm-bus,name = "blsp1_uart2";
+		qcom,msm-bus,num-cases = <2>;
+		qcom,msm-bus,num-paths = <1>;
+		qcom,msm-bus,vectors-KBps =
+				<86 512 0 0>,
+				<86 512 500 800>;
 	};
 
 	serial@f995e000 {
@@ -283,6 +290,7 @@
 		qcom,hsusb-otg-otg-control = <2>;
 		qcom,hsusb-otg-disable-reset;
 		qcom,dp-manual-pullup;
+		qcom,ahb-async-bridge-bypass;
 
 		qcom,msm-bus,name = "usb";
 		qcom,msm-bus,num-cases = <3>;
@@ -297,6 +305,7 @@
 		compatible = "qcom,android-usb";
 		reg = <0xfe8050c8 0xc8>;
 		qcom,android-usb-swfi-latency = <1>;
+		qcom,streaming-func = "rndis";
 	};
 
 	hsic_host: hsic@f9a00000 {
@@ -720,6 +729,24 @@
 		compatible = "qcom,bcl";
 	};
 
+	rmtfs_sharedmem {
+		compatible = "qcom,sharedmem-uio";
+		reg = <0x0fd80000 0x00180000>;
+		reg-names = "rmtfs";
+	};
+
+	dsp_sharedmem {
+		compatible = "qcom,sharedmem-uio";
+		reg = <0x0fd60000 0x00020000>;
+		reg-names = "rfsa_dsp";
+	};
+
+	mdm_sharedmem {
+		compatible = "qcom,sharedmem-uio";
+		reg = <0x0fd60000 0x00020000>;
+		reg-names = "rfsa_mdm";
+	};
+
 	sdcc1: qcom,sdcc@f9824000 {
 		cell-index = <1>; /* SDC1 eMMC slot */
 		compatible = "qcom,msm-sdcc";
diff --git a/arch/arm/boot/dts/msm8610-cdp.dtsi b/arch/arm/boot/dts/msm8610-cdp.dtsi
index 452cc2f..d63c6e5 100644
--- a/arch/arm/boot/dts/msm8610-cdp.dtsi
+++ b/arch/arm/boot/dts/msm8610-cdp.dtsi
@@ -20,7 +20,7 @@
 		compatible = "atmel,mxt-ts";
 		reg = <0x4a>;
 		interrupt-parent = <&msmgpio>;
-		interrupts = <1 0x2>;
+		interrupts = <1 0x2002>;
 		vdd_ana-supply = <&pm8110_l19>;
 		vcc_i2c-supply = <&pm8110_l14>;
 		atmel,reset-gpio = <&msmgpio 0 0x00>;
@@ -76,6 +76,21 @@
 				];
 			};
 		};
+
+		synaptics@20 {
+			compatible = "synaptics,rmi4";
+			reg = <0x20>;
+			interrupt-parent = <&msmgpio>;
+			interrupts = <1 0x2002>;
+			vdd-supply = <&pm8110_l19>;
+			vcc_i2c-supply = <&pm8110_l14>;
+			synaptics,reset-gpio = <&msmgpio 0 0x00>;
+			synaptics,irq-gpio = <&msmgpio 1 0x2008>;
+			synaptics,button-map = <139 102 158>;
+			synaptics,i2c-pull-up;
+			synaptics,power-down;
+			synaptics,disable-gpios;
+		};
 	};
 
 	gen-vkeys {
@@ -162,8 +177,9 @@
 		qcom,cdc-vdd-mic-bias-voltage = <3075000 3075000>;
 		qcom,cdc-vdd-mic-bias-current = <25000>;
 
+		qcom,cdc-micbias-ldoh-v = <0x3>;
 		qcom,cdc-micbias-cfilt-sel = <0x0>;
-		qcom,cdc-micbias-cfilt-mv = <1800000>;
+		qcom,cdc-micbias-cfilt-mv = <2700>;
 		qcom,cdc-mclk-clk-rate = <12288000>;
 
 		qcom,cdc-static-supplies = "cdc-vdda-h",
@@ -245,7 +261,6 @@
 
 	vdd-io-supply = <&pm8110_l6>;
 	qcom,vdd-io-always-on;
-	qcom,vdd-io-lpm-sup;
 	qcom,vdd-io-voltage-level = <1800000 1800000>;
 	qcom,vdd-io-current-level = <200 60000>;
 
diff --git a/arch/arm/boot/dts/msm8610-coresight.dtsi b/arch/arm/boot/dts/msm8610-coresight.dtsi
index 78a4b5a..ca4f721 100644
--- a/arch/arm/boot/dts/msm8610-coresight.dtsi
+++ b/arch/arm/boot/dts/msm8610-coresight.dtsi
@@ -205,12 +205,56 @@
 		qcom,round-robin;
 	};
 
+	audio_etm0 {
+		compatible = "qcom,coresight-audio-etm";
+
+		coresight-id = <13>;
+		coresight-name = "coresight-audio-etm0";
+		coresight-nr-inports = <0>;
+		coresight-outports = <0>;
+		coresight-child-list = <&funnel_in0>;
+		coresight-child-ports = <2>;
+	};
+
+	modem_etm0 {
+		compatible = "qcom,coresight-modem-etm";
+
+		coresight-id = <14>;
+		coresight-name = "coresight-modem-etm0";
+		coresight-nr-inports = <0>;
+		coresight-outports = <0>;
+		coresight-child-list = <&funnel_in0>;
+		coresight-child-ports = <1>;
+	};
+
+	wcn_etm0 {
+		compatible = "qcom,coresight-wcn-etm";
+
+		coresight-id = <15>;
+		coresight-name = "coresight-wcn-etm0";
+		coresight-nr-inports = <0>;
+		coresight-outports = <0>;
+		coresight-child-list = <&funnel_in1>;
+		coresight-child-ports = <0>;
+	};
+
+	rpm_etm0 {
+		compatible = "qcom,coresight-rpm-etm";
+
+		coresight-id = <16>;
+		coresight-name = "coresight-rpm-etm0";
+		coresight-nr-inports = <0>;
+		coresight-outports = <0>;
+		coresight-child-list = <&funnel_in0>;
+		coresight-child-ports = <0>;
+	};
+
 	csr: csr@fc301000 {
 		compatible = "qcom,coresight-csr";
 		reg = <0xfc301000 0x1000>;
 		reg-names = "csr-base";
 
-		coresight-id = <13>;
+		coresight-id = <17>;
 		coresight-name = "coresight-csr";
 		coresight-nr-inports = <0>;
 
@@ -222,7 +266,7 @@
 		reg = <0xfc310000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <14>;
+		coresight-id = <18>;
 		coresight-name = "coresight-cti0";
 		coresight-nr-inports = <0>;
 	};
@@ -232,7 +276,7 @@
 		reg = <0xfc311000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <15>;
+		coresight-id = <19>;
 		coresight-name = "coresight-cti1";
 		coresight-nr-inports = <0>;
 	};
@@ -242,7 +286,7 @@
 		reg = <0xfc312000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <16>;
+		coresight-id = <20>;
 		coresight-name = "coresight-cti2";
 		coresight-nr-inports = <0>;
 	};
@@ -252,7 +296,7 @@
 		reg = <0xfc313000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <17>;
+		coresight-id = <21>;
 		coresight-name = "coresight-cti3";
 		coresight-nr-inports = <0>;
 	};
@@ -262,7 +306,7 @@
 		reg = <0xfc314000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <18>;
+		coresight-id = <22>;
 		coresight-name = "coresight-cti4";
 		coresight-nr-inports = <0>;
 	};
@@ -272,7 +316,7 @@
 		reg = <0xfc315000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <19>;
+		coresight-id = <23>;
 		coresight-name = "coresight-cti5";
 		coresight-nr-inports = <0>;
 	};
@@ -282,7 +326,7 @@
 		reg = <0xfc316000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <20>;
+		coresight-id = <24>;
 		coresight-name = "coresight-cti6";
 		coresight-nr-inports = <0>;
 	};
@@ -292,7 +336,7 @@
 		reg = <0xfc317000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <21>;
+		coresight-id = <25>;
 		coresight-name = "coresight-cti7";
 		coresight-nr-inports = <0>;
 	};
@@ -302,7 +346,7 @@
 		reg = <0xfc318000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <22>;
+		coresight-id = <26>;
 		coresight-name = "coresight-cti8";
 		coresight-nr-inports = <0>;
 	};
@@ -312,7 +356,7 @@
 		reg = <0xfc351000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <23>;
+		coresight-id = <27>;
 		coresight-name = "coresight-cti-cpu0";
 		coresight-nr-inports = <0>;
 	};
@@ -322,7 +366,7 @@
 		reg = <0xfc352000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <24>;
+		coresight-id = <28>;
 		coresight-name = "coresight-cti-cpu1";
 		coresight-nr-inports = <0>;
 	};
@@ -332,7 +376,7 @@
 		reg = <0xfc353000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <25>;
+		coresight-id = <29>;
 		coresight-name = "coresight-cti-cpu2";
 		coresight-nr-inports = <0>;
 	};
@@ -342,11 +386,51 @@
 		reg = <0xfc354000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <26>;
+		coresight-id = <30>;
 		coresight-name = "coresight-cti-cpu3";
 		coresight-nr-inports = <0>;
 	};
 
+	cti_wcn_cpu0: cti@fc335000 {
+		compatible = "arm,coresight-cti";
+		reg = <0xfc335000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-id = <31>;
+		coresight-name = "coresight-cti-wcn-cpu0";
+		coresight-nr-inports = <0>;
+	};
+
+	cti_modem_cpu0: cti@fc338000 {
+		compatible = "arm,coresight-cti";
+		reg = <0xfc338000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-id = <32>;
+		coresight-name = "coresight-cti-modem-cpu0";
+		coresight-nr-inports = <0>;
+	};
+
+	cti_audio_cpu0: cti@fc33c000 {
+		compatible = "arm,coresight-cti";
+		reg = <0xfc33c000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-id = <33>;
+		coresight-name = "coresight-cti-audio-cpu0";
+		coresight-nr-inports = <0>;
+	};
+
+	cti_rpm_cpu0: cti@fc360000 {
+		compatible = "arm,coresight-cti";
+		reg = <0xfc360000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-id = <34>;
+		coresight-name = "coresight-cti-rpm-cpu0";
+		coresight-nr-inports = <0>;
+	};
+
 	hwevent: hwevent@fd820018 {
 		compatible = "qcom,coresight-hwevent";
 		reg = <0xfd820018 0x80>,
@@ -355,7 +439,7 @@
 		      <0xfc401600 0x80>;
 		reg-names = "mmss-mux", "apcs-mux", "ppss-mux", "gcc-mux";
 
-		coresight-id = <27>;
+		coresight-id = <35>;
 		coresight-name = "coresight-hwevent";
 		coresight-nr-inports = <0>;
 
@@ -367,7 +451,7 @@
 		reg = <0xfc4be024 0x8>;
 		reg-names = "fuse-base";
 
-		coresight-id = <28>;
+		coresight-id = <36>;
 		coresight-name = "coresight-fuse";
 		coresight-nr-inports = <0>;
 	};
diff --git a/arch/arm/boot/dts/msm8610-mdss-panels.dtsi b/arch/arm/boot/dts/msm8610-mdss-panels.dtsi
index 243d7e8..afc5459 100644
--- a/arch/arm/boot/dts/msm8610-mdss-panels.dtsi
+++ b/arch/arm/boot/dts/msm8610-mdss-panels.dtsi
@@ -15,3 +15,4 @@
 /include/ "dsi-panel-nt35590-720p-video.dtsi"
 /include/ "dsi-panel-otm8018b-fwvga-video.dtsi"
 /include/ "dsi-panel-hx8379a-wvga-video.dtsi"
+/include/ "dsi-panel-hx8389b-qhd-video.dtsi"
diff --git a/arch/arm/boot/dts/msm8610-mtp.dtsi b/arch/arm/boot/dts/msm8610-mtp.dtsi
index 8d0e201..6ce0109 100644
--- a/arch/arm/boot/dts/msm8610-mtp.dtsi
+++ b/arch/arm/boot/dts/msm8610-mtp.dtsi
@@ -20,7 +20,7 @@
 		compatible = "atmel,mxt-ts";
 		reg = <0x4a>;
 		interrupt-parent = <&msmgpio>;
-		interrupts = <1 0x2>;
+		interrupts = <1 0x2002>;
 		vdd_ana-supply = <&pm8110_l19>;
 		vcc_i2c-supply = <&pm8110_l14>;
 		atmel,reset-gpio = <&msmgpio 0 0x00>;
@@ -76,6 +76,21 @@
 				];
 			};
 		};
+
+		synaptics@20 {
+			compatible = "synaptics,rmi4";
+			reg = <0x20>;
+			interrupt-parent = <&msmgpio>;
+			interrupts = <1 0x2002>;
+			vdd-supply = <&pm8110_l19>;
+			vcc_i2c-supply = <&pm8110_l14>;
+			synaptics,reset-gpio = <&msmgpio 0 0x00>;
+			synaptics,irq-gpio = <&msmgpio 1 0x2008>;
+			synaptics,button-map = <139 102 158>;
+			synaptics,i2c-pull-up;
+			synaptics,power-down;
+			synaptics,disable-gpios;
+		};
 	};
 
 	i2c@f9925000 {
@@ -229,8 +244,9 @@
 		qcom,cdc-vdd-mic-bias-voltage = <3075000 3075000>;
 		qcom,cdc-vdd-mic-bias-current = <25000>;
 
+		qcom,cdc-micbias-ldoh-v = <0x3>;
 		qcom,cdc-micbias-cfilt-sel = <0x0>;
-		qcom,cdc-micbias-cfilt-mv = <1800000>;
+		qcom,cdc-micbias-cfilt-mv = <2700>;
 		qcom,cdc-mclk-clk-rate = <12288000>;
 
 		qcom,cdc-static-supplies = "cdc-vdda-h",
@@ -312,7 +328,6 @@
 
 	vdd-io-supply = <&pm8110_l6>;
 	qcom,vdd-io-always-on;
-	qcom,vdd-io-lpm-sup;
 	qcom,vdd-io-voltage-level = <1800000 1800000>;
 	qcom,vdd-io-current-level = <200 60000>;
 
@@ -445,6 +460,7 @@
 
 &mdss_mdp {
 	qcom,mdss-pref-prim-intf = "dsi";
+	batfet-supply = <&pm8110_chg_batif>;
 };
 
 &mdss_dsi0 {
diff --git a/arch/arm/boot/dts/msm8610-qrd-skuaa.dtsi b/arch/arm/boot/dts/msm8610-qrd-skuaa.dtsi
index 86f1210..bb866b2 100644
--- a/arch/arm/boot/dts/msm8610-qrd-skuaa.dtsi
+++ b/arch/arm/boot/dts/msm8610-qrd-skuaa.dtsi
@@ -32,6 +32,21 @@
 		qcom,hsusb-otg-phy-init-seq =
 		<0x44 0x80 0x6a 0x81 0x34 0x82 0x13 0x83 0xffffffff>;
 	};
+
+	i2c@f9925000 { /* BLSP-1 QUP-3 */
+		nfc-nci@e {
+			compatible = "qcom,nfc-nci";
+			reg = <0x0e>;
+			qcom,irq-gpio = <&msmgpio 77 0x00>;
+			qcom,dis-gpio = <&msmgpio 93 0x00>;
+			qcom,clk-en-gpio = <&msmgpio 78 0x00>;
+			qcom,clk-src = "GPCLK";
+			interrupt-parent = <&msmgpio>;
+			interrupts = <77 0>;
+			qcom,clk-gpio = <&msmgpio 75 0x00>;
+			vlogic-supply = <&pm8110_l14>;
+		};
+	};
 };
 
 / {
@@ -41,6 +56,7 @@
 
 		/include/ "batterydata-qrd-4v2-1300mah.dtsi"
 	};
+
 };
 
 &pm8110_bms {
@@ -70,3 +86,13 @@
 &dsi_hx8379a_wvga_vid {
 	qcom,cont-splash-enabled;
 };
+
+&pm8110_gpios {
+	gpio@c000 { /* GPIO 1 */
+		qcom,mode = <0>;		/* QPNP_PIN_MODE_DIG_IN */
+		qcom,pull = <5>;		/* QPNP_PIN_PULL_NO */
+		qcom,vin-sel = <2>;		/* QPNP_PIN_VIN2 */
+		qcom,src-sel = <2>;		/* QPNP_PIN_SEL_FUNC_1 */
+		qcom,master-en = <1>;
+	};
+};
diff --git a/arch/arm/boot/dts/msm8610-qrd-skuab.dtsi b/arch/arm/boot/dts/msm8610-qrd-skuab.dtsi
index 08e9be5..a22958a 100644
--- a/arch/arm/boot/dts/msm8610-qrd-skuab.dtsi
+++ b/arch/arm/boot/dts/msm8610-qrd-skuab.dtsi
@@ -67,6 +67,7 @@
 			goodix,display-coords = <0 0 540 960>;
 			goodix,button-map= <139 102 158>;
 			goodix,product-id = "915";
+			goodix,enable-power-off;
 			goodix,cfg-data0 = [
 				46 1C 02 C0 03 0A 05 11 01 08
 				14 3B 46 32 03 05 00 00 00 00
diff --git a/arch/arm/boot/dts/msm8610-qrd.dtsi b/arch/arm/boot/dts/msm8610-qrd.dtsi
index 83d84c0..92d1a77 100644
--- a/arch/arm/boot/dts/msm8610-qrd.dtsi
+++ b/arch/arm/boot/dts/msm8610-qrd.dtsi
@@ -102,6 +102,10 @@
 		linux,default-trigger = "flashlight-trigger";
 	};
 
+	qcom,wdt@f9017000 {
+		qcom,bark-time = <13000>;
+	};
+
 	gpio_keys {
                 compatible = "gpio-keys";
                 input-name = "gpio-keys";
@@ -175,8 +179,9 @@
 		qcom,cdc-vdd-mic-bias-voltage = <3075000 3075000>;
 		qcom,cdc-vdd-mic-bias-current = <25000>;
 
+		qcom,cdc-micbias-ldoh-v = <0x3>;
 		qcom,cdc-micbias-cfilt-sel = <0x0>;
-		qcom,cdc-micbias-cfilt-mv = <1800000>;
+		qcom,cdc-micbias-cfilt-mv = <2700>;
 		qcom,cdc-mclk-clk-rate = <12288000>;
 
 		qcom,cdc-static-supplies = "cdc-vdda-h",
@@ -209,8 +214,9 @@
 			status = "okay";
 			qcom,led_mpp_2 {
 				label = "mpp";
-				linux,name = "wled-homerow";
-				linux-default-trigger = "hr-trigger";
+				linux,name = "button-backlight";
+				linux,default-trigger = "hr-trigger";
+				qcom,current-setting = <20>;
 				qcom,default-state = "off";
 				qcom,max-current = <40>;
 				qcom,id = <6>;
@@ -286,7 +292,7 @@
 	qcom,pad-drv-on = <0x4 0x4 0x4>; /* 10mA, 10mA, 10mA */
 	qcom,pad-drv-off = <0x0 0x0 0x0>; /* 2mA, 2mA, 2mA */
 
-	qcom,clk-rates = <400000 25000000 50000000 100000000 200000000>;
+	qcom,clk-rates = <400000 25000000 50000000>;
 
 	#address-cells = <0>;
 	interrupt-parent = <&sdhc_2>;
@@ -307,6 +313,7 @@
 
 	qcom,chgr@1000 {
 		status = "ok";
+		qcom,tchg-mins = <250>;
 	};
 
 	qcom,buck@1100 {
@@ -367,3 +374,7 @@
 	qcom,android-usb-cdrom;
 	qcom,android-usb-internal-ums;
 };
+
+&mdss_mdp {
+	batfet-supply = <&pm8110_chg_batif>;
+};
diff --git a/arch/arm/boot/dts/msm8610-regulator.dtsi b/arch/arm/boot/dts/msm8610-regulator.dtsi
index f97d991..7eb6a22 100644
--- a/arch/arm/boot/dts/msm8610-regulator.dtsi
+++ b/arch/arm/boot/dts/msm8610-regulator.dtsi
@@ -215,7 +215,7 @@
 		status = "okay";
 		pm8110_l5: regulator-l5 {
 			regulator-min-microvolt = <1300000>;
-			regulator-max-microvolt = <1300000>;
+			regulator-max-microvolt = <1350000>;
 			qcom,init-voltage = <1300000>;
 			status = "okay";
 		};
@@ -325,7 +325,7 @@
 		status = "okay";
 		pm8110_l16: regulator-l16 {
 			regulator-min-microvolt = <3000000>;
-			regulator-max-microvolt = <3000000>;
+			regulator-max-microvolt = <3350000>;
 			qcom,init-voltage = <3000000>;
 			status = "okay";
 		};
diff --git a/arch/arm/boot/dts/msm8610-rumi.dts b/arch/arm/boot/dts/msm8610-rumi.dts
index 7f06485..c22b4f28 100644
--- a/arch/arm/boot/dts/msm8610-rumi.dts
+++ b/arch/arm/boot/dts/msm8610-rumi.dts
@@ -17,7 +17,7 @@
 / {
 	model = "Qualcomm MSM 8610 Rumi";
 	compatible = "qcom,msm8610-rumi", "qcom,msm8610", "qcom,rumi";
-	qcom,msm-id = <147 15 0>;
+	qcom,board-id = <15 0>;
 };
 
 &soc {
diff --git a/arch/arm/boot/dts/msm8610-sim.dts b/arch/arm/boot/dts/msm8610-sim.dts
index 33176b9..531ee4b 100644
--- a/arch/arm/boot/dts/msm8610-sim.dts
+++ b/arch/arm/boot/dts/msm8610-sim.dts
@@ -17,7 +17,7 @@
 / {
 	model = "Qualcomm MSM 8610 Simulator";
 	compatible = "qcom,msm8610-sim", "qcom,msm8610", "qcom,sim";
-	qcom,msm-id = <147 16 0>;
+	qcom,board-id = <16 0>;
 };
 
 &soc {
diff --git a/arch/arm/boot/dts/msm8610-v1-cdp.dts b/arch/arm/boot/dts/msm8610-v1-cdp.dts
index beb3976..5a70379 100644
--- a/arch/arm/boot/dts/msm8610-v1-cdp.dts
+++ b/arch/arm/boot/dts/msm8610-v1-cdp.dts
@@ -19,8 +19,7 @@
 / {
 	model = "Qualcomm MSM 8610 CDP";
 	compatible = "qcom,msm8610-cdp", "qcom,msm8610", "qcom,cdp";
-	qcom,msm-id = <147 1 0>, <165 1 0>, <161 1 0>, <162 1 0>,
-		      <163 1 0>, <164 1 0>, <166 1 0>;
+	qcom,board-id = <1 0>;
 };
 
 
diff --git a/arch/arm/boot/dts/msm8610-v1-mtp.dts b/arch/arm/boot/dts/msm8610-v1-mtp.dts
index 82992a3..c8c8d09 100644
--- a/arch/arm/boot/dts/msm8610-v1-mtp.dts
+++ b/arch/arm/boot/dts/msm8610-v1-mtp.dts
@@ -19,8 +19,7 @@
 / {
 	model = "Qualcomm MSM 8610 MTP";
 	compatible = "qcom,msm8610-mtp", "qcom,msm8610", "qcom,mtp";
-	qcom,msm-id = <147 8 0>, <165 8 0>, <161 8 0>, <162 8 0>,
-		      <163 8 0>, <164 8 0>, <166 8 0>;
+	qcom,board-id = <8 0>;
 };
 
 
diff --git a/arch/arm/boot/dts/msm8610-v1-pm.dtsi b/arch/arm/boot/dts/msm8610-v1-pm.dtsi
index e560447..62aa0f4 100644
--- a/arch/arm/boot/dts/msm8610-v1-pm.dtsi
+++ b/arch/arm/boot/dts/msm8610-v1-pm.dtsi
@@ -56,10 +56,10 @@
 		qcom,saw2-spm-dly= <0x3c102800>;
 		qcom,saw2-spm-ctl = <0x8>;
 		qcom,saw2-spm-cmd-wfi = [60 03 60 0b 0f];
-		qcom,saw2-spm-cmd-spc = [00 20 10 80 30 90 5b 60 03 60 3b 76 76
-				0b 94 5b 80 10 06 26 30 0f];
-		qcom,saw2-spm-cmd-pc = [00 20 10 80 30 90 5b 60 03 60 3b 76 76
-				0b 94 5b 80 10 06 26 30 0f];
+		qcom,saw2-spm-cmd-spc = [20 10 80 30 90 5b 60 03 60 3b 76 76
+				0b 94 5b 80 10 26 30 0f];
+		qcom,saw2-spm-cmd-pc = [20 10 80 30 90 5b 60 03 60 3b 76 76
+				0b 94 5b 80 10 26 30 0f];
 	};
 
 	qcom,spm@f90b9000 {
@@ -99,6 +99,9 @@
 		qcom,saw2-spm-cmd-pc = [00 32 b0 10 e0 d0 6b c0 42 f0
 				11 07 01 b0 50 4e 02 02 c0 d0 12 e0 6b 02 32
 				50 f0 0f]; /*APCS_PMIC_OFF_L2RAM_OFF*/
+		qcom,saw2-spm-cmd-pc-no-rpm = [00 32 b0 10 e0 d0 6b c0 42 f0
+				11 03 01 b0 50 4e 02 02 c0 d0 12 e0 6b 02 32
+				50 f0 0f]; /*APCS_PMIC_OFF_L2RAM_OFF*/
 		qcom,L2-spm-is-apcs-master;
 	};
 
@@ -125,28 +128,29 @@
 			qcom,latency-us = <500>;
 			qcom,ss-power = <410>;
 			qcom,energy-overhead = <603400>;
-			qcom,time-overhead = <1200>;
+			qcom,time-overhead = <1410>;
 		};
 
 		qcom,lpm-level@2 {
 			reg = <0x2>;
 			qcom,mode = "pc";
-			qcom,l2 = "l2_cache_retention";
-			qcom,latency-us = <520>;
-			qcom,ss-power = <460>;
-			qcom,energy-overhead = <704900>;
-			qcom,time-overhead = <1300>;
+			qcom,l2 = "l2_cache_pc_no_rpm";
+			qcom,latency-us = <1000>;
+			qcom,ss-power = <315>;
+			qcom,energy-overhead = <1027150>;
+			qcom,time-overhead = <2400>;
 		};
 
 		qcom,lpm-level@3 {
 			reg = <0x3>;
 			qcom,mode = "pc";
 			qcom,l2 = "l2_cache_pc";
-			qcom,latency-us = <11700>;
+			qcom,latency-us = <12700>;
 			qcom,ss-power = <315>;
 			qcom,energy-overhead = <1027150>;
 			qcom,time-overhead = <2400>;
 		};
+
 	};
 
 	qcom,pm-boot {
@@ -180,7 +184,6 @@
 			<0xff 59>,  /* mss_to_apps_irq(2) */
 			<0xff 60>,  /* mss_to_apps_irq(3) */
 			<0xff 61>,  /* mss_a2_bam_irq */
-			<0xff 63>,  /* wcd9xxx_irq */
 			<0xff 65>,  /* o_gc_sys_irq[0] */
 			<0xff 74>,  /* venus0_mmu_cirpt[1] */
 			<0xff 75>,  /* venus0_mmu_cirpt[0] */
diff --git a/arch/arm/boot/dts/msm8610-v1-qrd-skuab-dvt2.dts b/arch/arm/boot/dts/msm8610-v1-qrd-skuab-dvt2.dts
index f250c4a..de48f1f 100644
--- a/arch/arm/boot/dts/msm8610-v1-qrd-skuab-dvt2.dts
+++ b/arch/arm/boot/dts/msm8610-v1-qrd-skuab-dvt2.dts
@@ -21,3 +21,22 @@
 	compatible = "qcom,msm8610-qrd", "qcom,msm8610", "qcom,qrd";
 	qcom,board-id = <0x2000b 3>;
 };
+
+&mdss_mdp {
+	qcom,mdss-pref-prim-intf = "dsi";
+};
+
+&mdss_dsi0 {
+	qcom,dsi-pref-prim-pan = <&dsi_hx8389b_qhd_vid>;
+};
+
+&dsi_hx8389b_qhd_vid {
+	qcom,cont-splash-enabled;
+};
+&soc {
+	i2c@f9925000 {
+		fsl@1c {
+			fsl,sensors-position = <7>;
+		};
+	};
+};
\ No newline at end of file
diff --git a/arch/arm/boot/dts/msm8610-v2-cdp.dts b/arch/arm/boot/dts/msm8610-v2-cdp.dts
index a6d1d9c..447161f 100644
--- a/arch/arm/boot/dts/msm8610-v2-cdp.dts
+++ b/arch/arm/boot/dts/msm8610-v2-cdp.dts
@@ -19,8 +19,7 @@
 / {
 	model = "Qualcomm MSM 8610v2 CDP";
 	compatible = "qcom,msm8610-cdp", "qcom,msm8610", "qcom,cdp";
-	qcom,msm-id = <147 1 0x10001>, <165 1 0x10001>, <161 1 0x10001>, <162 1 0x10001>,
-		      <163 1 0x10001>, <164 1 0x10001>, <166 1 0x10001>;
+	qcom,board-id = <1 0>;
 };
 
 
diff --git a/arch/arm/boot/dts/msm8610-v2-mtp.dts b/arch/arm/boot/dts/msm8610-v2-mtp.dts
index 405a775..77f5276 100644
--- a/arch/arm/boot/dts/msm8610-v2-mtp.dts
+++ b/arch/arm/boot/dts/msm8610-v2-mtp.dts
@@ -19,8 +19,7 @@
 / {
 	model = "Qualcomm MSM 8610v2 MTP";
 	compatible = "qcom,msm8610-mtp", "qcom,msm8610", "qcom,mtp";
-	qcom,msm-id = <147 8 0x10001>, <165 8 0x10001>, <161 8 0x10001>, <162 8 0x10001>,
-		      <163 8 0x10001>, <164 8 0x10001>, <166 8 0x10001>;
+	qcom,board-id = <8 0>;
 };
 
 
diff --git a/arch/arm/boot/dts/msm8610-v2-pm.dtsi b/arch/arm/boot/dts/msm8610-v2-pm.dtsi
index 72509c1..e401f7a 100644
--- a/arch/arm/boot/dts/msm8610-v2-pm.dtsi
+++ b/arch/arm/boot/dts/msm8610-v2-pm.dtsi
@@ -56,10 +56,10 @@
 		qcom,saw2-spm-dly= <0x3c102800>;
 		qcom,saw2-spm-ctl = <0x8>;
 		qcom,saw2-spm-cmd-wfi = [60 03 60 0b 0f];
-		qcom,saw2-spm-cmd-spc = [00 20 10 80 30 90 5b 60 03 60 3b 76 76
-				0b 94 5b 80 10 06 26 30 0f];
-		qcom,saw2-spm-cmd-pc = [00 20 10 80 30 90 5b 60 03 60 3b 76 76
-				0b 94 5b 80 10 06 26 30 0f];
+		qcom,saw2-spm-cmd-spc = [20 10 80 30 90 5b 60 03 60 3b 76 76
+				0b 94 5b 80 10 26 30 0f];
+		qcom,saw2-spm-cmd-pc = [20 10 80 30 90 5b 60 03 60 3b 76 76
+				0b 94 5b 80 10 26 30 0f];
 	};
 
 	qcom,spm@f90b9000 {
@@ -101,6 +101,9 @@
 		qcom,saw2-spm-cmd-pc = [00 32 b0 10 e0 d0 6b c0 42 f0
 				11 07 01 b0 50 4e 02 02 c0 d0 12 e0 6b 02 32
 				50 f0 0f]; /*APCS_PMIC_OFF_L2RAM_OFF*/
+		qcom,saw2-spm-cmd-pc-no-rpm = [00 32 b0 10 e0 d0 6b c0 42 f0
+				11 03 01 b0 50 4e 02 02 c0 d0 12 e0 6b 02 32
+				50 f0 0f]; /*APCS_PMIC_OFF_L2RAM_OFF*/
 		qcom,L2-spm-is-apcs-master;
 	};
 
@@ -134,17 +137,27 @@
 			reg = <0x2>;
 			qcom,mode = "pc";
 			qcom,l2 = "l2_cache_gdhs";
-			qcom,latency-us = <10700>;
-			qcom,ss-power = <325>;
-			qcom,energy-overhead = <441250>;
-			qcom,time-overhead = <1020>;
+			qcom,latency-us = <11700>;
+			qcom,ss-power = <372>;
+			qcom,energy-overhead = <738750>;
+			qcom,time-overhead = <1410>;
 		};
 
 		qcom,lpm-level@3 {
 			reg = <0x3>;
 			qcom,mode = "pc";
+			qcom,l2 = "l2_cache_pc_no_rpm";
+			qcom,latency-us = <1000>;
+			qcom,ss-power = <315>;
+			qcom,energy-overhead = <1027150>;
+			qcom,time-overhead = <2400>;
+		};
+
+		qcom,lpm-level@4 {
+			reg = <0x4>;
+			qcom,mode = "pc";
 			qcom,l2 = "l2_cache_pc";
-			qcom,latency-us = <11700>;
+			qcom,latency-us = <12700>;
 			qcom,ss-power = <315>;
 			qcom,energy-overhead = <1027150>;
 			qcom,time-overhead = <2400>;
@@ -177,7 +190,6 @@
 			<0xff 59>,  /* mss_to_apps_irq(2) */
 			<0xff 60>,  /* mss_to_apps_irq(3) */
 			<0xff 61>,  /* mss_a2_bam_irq */
-			<0xff 63>,  /* wcd9xxx_irq */
 			<0xff 173>, /* o_wcss_apss_smd_hi */
 			<0xff 174>, /* o_wcss_apss_smd_med */
 			<0xff 175>, /* o_wcss_apss_smd_low */
diff --git a/arch/arm/boot/dts/msm8610-v2-qrd-skuab-dvt2.dts b/arch/arm/boot/dts/msm8610-v2-qrd-skuab-dvt2.dts
index e32afba..2547148 100644
--- a/arch/arm/boot/dts/msm8610-v2-qrd-skuab-dvt2.dts
+++ b/arch/arm/boot/dts/msm8610-v2-qrd-skuab-dvt2.dts
@@ -44,3 +44,38 @@
 		qcom,led-flash-src = <&led_flash0>;
 	};
 };
+
+&mdss_mdp {
+	qcom,mdss-pref-prim-intf = "dsi";
+};
+
+&mdss_dsi0 {
+	qcom,dsi-pref-prim-pan = <&dsi_hx8389b_qhd_vid>;
+};
+
+&dsi_hx8389b_qhd_vid {
+	qcom,cont-splash-enabled;
+};
+
+&soc {
+	i2c@f9925000 {
+		fsl@1c {
+			fsl,sensors-position = <7>;
+		};
+	};
+};
+
+&qrd_batterydata {
+	qcom,rpull-up-kohm = <100>;
+	qcom,vref-batt-therm = <1800000>;
+
+	/include/ "batterydata-qrd-4v2-2200mah.dtsi"
+};
+
+&pm8110_bms {
+	qcom,battery-data = <&qrd_batterydata>;
+};
+
+&pm8110_chg {
+	qcom,battery-data = <&qrd_batterydata>;
+};
diff --git a/arch/arm/boot/dts/msm8610.dtsi b/arch/arm/boot/dts/msm8610.dtsi
index b0f9d62..1619d1f 100644
--- a/arch/arm/boot/dts/msm8610.dtsi
+++ b/arch/arm/boot/dts/msm8610.dtsi
@@ -182,7 +182,7 @@
 		compatible = "qcom,msm-vidc";
 		qcom,vidc-ns-map = <0x40000000 0x40000000>;
 		qcom,buffer-type-tz-usage-map = <0x1 0x1>,
-						<0x1fe 0x2>;
+						<0x7fe 0x2>;
 		qcom,hfi = "q6";
 		qcom,max-hw-load = <244800>; /* 1080p @ 30 * 1 */
 		qcom,vidc-iommu-domains {
@@ -239,6 +239,7 @@
 		qcom,hsusb-otg-otg-control = <2>;
 		qcom,hsusb-otg-disable-reset;
 		qcom,dp-manual-pullup;
+		qcom,ahb-async-bridge-bypass;
 
 		qcom,msm-bus,name = "usb2";
 		qcom,msm-bus,num-cases = <2>;
@@ -253,6 +254,25 @@
 		compatible = "qcom,android-usb";
 		reg = <0xfe8050c8 0xc8>;
 		qcom,android-usb-swfi-latency = <1>;
+		qcom,streaming-func = "rndis";
+	};
+
+	rmtfs_sharedmem {
+		compatible = "qcom,sharedmem-uio";
+		reg = <0x0dc80000 0x00180000>;
+		reg-names = "rmtfs";
+	};
+
+	dsp_sharedmem {
+		compatible = "qcom,sharedmem-uio";
+		reg = <0x0dc60000 0x00020000>;
+		reg-names = "rfsa_dsp";
+	};
+
+	mdm_sharedmem {
+		compatible = "qcom,sharedmem-uio";
+		reg = <0x0dc60000 0x00020000>;
+		reg-names = "rfsa_mdm";
 	};
 
 	sdcc1: qcom,sdcc@f9824000 {
@@ -271,7 +291,6 @@
 
 		vdd-io-supply = <&pm8110_l6>;
 		qcom,vdd-io-always-on;
-		qcom,vdd-io-lpm-sup;
 		qcom,vdd-io-voltage-level = <1800000 1800000>;
 		qcom,vdd-io-current-level = <9000 60000>;
 
@@ -423,7 +442,6 @@
 		compatible = "qcom,rpm-smd";
 		rpm-channel-name = "rpm_requests";
 		rpm-channel-type = <15>; /* SMD_APPS_RPM */
-		rpm-standalone;
 	};
 
 	qcom,bcl {
@@ -854,8 +872,8 @@
                 qcom,msm-bus,num-cases = <2>;
                 qcom,msm-bus,num-paths = <1>;
                 qcom,msm-bus,vectors-KBps =
-                                <1 618 0 0>,
-                                <1 618 0 800>;
+                                <54 618 0 0>,
+                                <54 618 0 800>;
         };
 
 	qcom,msm-rtb {
diff --git a/arch/arm/boot/dts/msm8612-qrd-camera-sensor.dtsi b/arch/arm/boot/dts/msm8612-qrd-camera-sensor.dtsi
index fc14455..205e749 100644
--- a/arch/arm/boot/dts/msm8612-qrd-camera-sensor.dtsi
+++ b/arch/arm/boot/dts/msm8612-qrd-camera-sensor.dtsi
@@ -78,6 +78,7 @@
 		gpios = <&msmgpio 14 0>,
 				<&msmgpio 15 0>,
 				<&msmgpio 85 0>;
+		qcom,gpio-reset = <1>;
 		qcom,gpio-standby = <2>;
 		qcom,gpio-req-tbl-num = <0 1 2>;
 		qcom,gpio-req-tbl-flags = <1 0 0>;
diff --git a/arch/arm/boot/dts/msm8926-1080p-cdp.dts b/arch/arm/boot/dts/msm8926-1080p-cdp.dts
new file mode 100644
index 0000000..33e484a
--- /dev/null
+++ b/arch/arm/boot/dts/msm8926-1080p-cdp.dts
@@ -0,0 +1,38 @@
+/* Copyright (c) 2013, The Linux Foundation. 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.
+ */
+
+
+/dts-v1/;
+/include/ "msm8926.dtsi"
+/include/ "msm8226-1080p-cdp.dtsi"
+/include/ "msm8226-camera-sensor-cdp.dtsi"
+
+/ {
+	model = "Qualcomm MSM 8926 CDP";
+	compatible = "qcom,msm8926-cdp", "qcom,msm8926", "qcom,cdp";
+	qcom,board-id = <1 2>;
+};
+
+&pm8226_chg {
+	status = "ok";
+	qcom,charging-disabled;
+	qcom,use-default-batt-values;
+
+	qcom,bat-if@1200 {
+		status = "disabled";
+	};
+
+};
+
+&hsic_host {
+	status = "ok";
+};
diff --git a/arch/arm/boot/dts/msm8926-1080p-mtp.dts b/arch/arm/boot/dts/msm8926-1080p-mtp.dts
new file mode 100644
index 0000000..c1217a2
--- /dev/null
+++ b/arch/arm/boot/dts/msm8926-1080p-mtp.dts
@@ -0,0 +1,23 @@
+/* Copyright (c) 2013, The Linux Foundation. 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.
+ */
+
+
+/dts-v1/;
+/include/ "msm8926.dtsi"
+/include/ "msm8226-1080p-mtp.dtsi"
+/include/ "msm8226-camera-sensor-mtp.dtsi"
+
+/ {
+	model = "Qualcomm MSM 8926 MTP";
+	compatible = "qcom,msm8926-mtp", "qcom,msm8926", "qcom,mtp";
+	qcom,board-id = <8 2>;
+};
diff --git a/arch/arm/boot/dts/msm8926-720p-cdp.dts b/arch/arm/boot/dts/msm8926-720p-cdp.dts
new file mode 100644
index 0000000..80bb5e6
--- /dev/null
+++ b/arch/arm/boot/dts/msm8926-720p-cdp.dts
@@ -0,0 +1,38 @@
+/* Copyright (c) 2013, The Linux Foundation. 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.
+ */
+
+
+/dts-v1/;
+/include/ "msm8926.dtsi"
+/include/ "msm8226-720p-cdp.dtsi"
+/include/ "msm8226-camera-sensor-cdp.dtsi"
+
+/ {
+	model = "Qualcomm MSM 8926 CDP";
+	compatible = "qcom,msm8926-cdp", "qcom,msm8926", "qcom,cdp";
+	qcom,board-id = <1 0>;
+};
+
+&pm8226_chg {
+	status = "ok";
+	qcom,charging-disabled;
+	qcom,use-default-batt-values;
+
+	qcom,bat-if@1200 {
+		status = "disabled";
+	};
+
+};
+
+&hsic_host {
+	status = "ok";
+};
diff --git a/arch/arm/boot/dts/msm8926-720p-mtp.dts b/arch/arm/boot/dts/msm8926-720p-mtp.dts
new file mode 100644
index 0000000..32301fd
--- /dev/null
+++ b/arch/arm/boot/dts/msm8926-720p-mtp.dts
@@ -0,0 +1,23 @@
+/* Copyright (c) 2013, The Linux Foundation. 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.
+ */
+
+
+/dts-v1/;
+/include/ "msm8926.dtsi"
+/include/ "msm8226-720p-mtp.dtsi"
+/include/ "msm8226-camera-sensor-mtp.dtsi"
+
+/ {
+	model = "Qualcomm MSM 8926 MTP";
+	compatible = "qcom,msm8926-mtp", "qcom,msm8926", "qcom,mtp";
+	qcom,board-id = <8 0>;
+};
diff --git a/arch/arm/boot/dts/msm8926-camera-sensor-qrd.dtsi b/arch/arm/boot/dts/msm8926-camera-sensor-qrd.dtsi
index a85e048..9b812da 100644
--- a/arch/arm/boot/dts/msm8926-camera-sensor-qrd.dtsi
+++ b/arch/arm/boot/dts/msm8926-camera-sensor-qrd.dtsi
@@ -31,6 +31,122 @@
 		qcom,cci-master = <0>;
 	};
 
+	eeprom2: qcom,eeprom@6b{
+		cell-index = <2>;
+		reg = <0x6b>;
+		qcom,eeprom-name = "ofilm_oty5f03";
+		compatible = "qcom,eeprom";
+		qcom,slave-addr = <0x6c>;
+		qcom,cci-master = <0>;
+		qcom,num-blocks = <7>;
+
+		qcom,page0 = <1 0x0100 2 0x01 1 1>;
+		qcom,poll0 = <0 0x0 2 0 1 1>;
+		qcom,mem0 = <0 0x0 2 0 1 0>;
+		qcom,page1 = <1 0x3d84 2 0xc0 1 1>;
+		qcom,poll1 = <0 0x0 2 0 1 1>;
+		qcom,mem1 = <0 0x0 2 0 1 0>;
+		qcom,page2 = <1 0x3d85 2 0x00 1 1>;
+		qcom,poll2 = <0 0x0 2 0 1 1>;
+		qcom,mem2 = <0 0x0 2 0 1 0>;
+		qcom,page3 = <1 0x3d86 2 0x0f 1 1>;
+		qcom,pageen3 = <1 0x3d81 2 0x01 1 10>;
+		qcom,poll3 = <0 0x0 2 0 1 1>;
+		qcom,mem3 = <16 0x3d00 2 0 1 0>;
+		qcom,page4 = <1 0x3d84 2 0xc0 1 1>;
+		qcom,poll4 = <0 0x0 2 0 1 1>;
+		qcom,mem4 = <0 0x0 2 0 1 0>;
+		qcom,page5 = <1 0x3d85 2 0x10 1 1>;
+		qcom,poll5 = <0 0x0 2 0 1 1>;
+		qcom,mem5 = <0 0x0 2 0 1 0>;
+		qcom,page6 = <1 0x3d86 2 0x1f 1 1>;
+		qcom,pageen6 = <1 0x3d81 2 0x01 1 10>;
+		qcom,poll6 = <0 0x0 2 0 1 1>;
+		qcom,mem6 = <16 0x3d00 2 0 1 0>;
+
+		cam_vio-supply = <&pm8226_lvs1>;
+		cam_vana-supply = <&pm8226_l19>;
+		qcom,cam-vreg-name = "cam_vio", "cam_vana";
+		qcom,cam-vreg-type = <1 0>;
+		qcom,cam-vreg-min-voltage = <0 2850000>;
+		qcom,cam-vreg-max-voltage = <0 2850000>;
+		qcom,cam-vreg-op-mode = <0 80000>;
+		qcom,gpio-no-mux = <0>;
+		gpios = <&msmgpio 26 0>,
+		        <&msmgpio 28 0>,
+		        <&msmgpio 35 0>,
+		        <&msmgpio 21 0>;
+		qcom,gpio-reset = <1>;
+		qcom,gpio-standby = <2>;
+		qcom,gpio-vdig = <3>;
+		qcom,gpio-req-tbl-num = <0 1 2 3>;
+		qcom,gpio-req-tbl-flags = <1 0 0 0>;
+		qcom,gpio-req-tbl-label = "CAMIF_MCLK",
+		        "CAM_RESET",
+		        "CAM_STANDBY",
+		        "CAM_VDIG";
+		qcom,cam-power-seq-type = "sensor_vreg",
+		        "sensor_vreg", "sensor_gpio",
+		        "sensor_gpio", "sensor_gpio" , "sensor_clk";
+		qcom,cam-power-seq-val = "cam_vio", "cam_vana","sensor_gpio_vdig",
+		         "sensor_gpio_reset",
+		        "sensor_gpio_standby","sensor_cam_mclk" ;
+		qcom,cam-power-seq-cfg-val = <1 1 1 1 1 24000000>;
+		qcom,cam-power-seq-delay = <1 1 10 10 10 5>;
+	};
+
+	eeprom3: qcom,eeprom@6c {
+		cell-index = <3>;
+		reg = <0x6c>;
+		qcom,eeprom-name = "sunny_q8v18a";
+		compatible = "qcom,eeprom";
+		qcom,slave-addr = <0x20>;
+		qcom,cci-master = <0>;
+		qcom,num-blocks = <4>;
+		qcom,page0 = <1 0x0100 2 0x01 1 1>;
+		qcom,poll0 = <0 0x0 2 0 1 1>;
+		qcom,mem0 = <0 0x0 2 0 1 0>;
+		qcom,page1 = <1 0x3d84 2 0xc0 1 1>;
+		qcom,poll1 = <0 0x0 2 0 1 1>;
+		qcom,mem1 = <0 0x3d00 2 0 1 0>;
+		qcom,page2 = <1 0x3d88 2 0x7010 2 1>;
+		qcom,poll2 = <0 0x0 2 0 1 1>;
+		qcom,mem2 = <0 0x3d00 2 0 1 0>;
+		qcom,page3 = <1 0x3d8A 2 0x70F4 2 1>;
+		qcom,pageen3 = <1 0x3d81 2 0x01 1 10>;
+		qcom,poll3 = <0 0x0 2 0 1 1>;
+		qcom,mem3 = <228 0x7010 2 0 1 1>;
+
+		cam_vdig-supply = <&pm8226_l5>;
+		cam_vana-supply = <&pm8226_l19>;
+		cam_vio-supply = <&pm8226_lvs1>;
+		qcom,cam-vreg-name = "cam_vdig","cam_vana", "cam_vio";
+		qcom,cam-vreg-type = <0 1 2>;
+		qcom,cam-vreg-min-voltage = <1200000 2850000 0>;
+		qcom,cam-vreg-max-voltage = <1200000 2850000 0>;
+		qcom,cam-vreg-op-mode = <200000 80000 0>;
+		qcom,gpio-no-mux = <0>;
+		gpios = <&msmgpio 26 0>,
+		        <&msmgpio 37 0>,
+		        <&msmgpio 36 0>;
+		qcom,gpio-reset = <1>;
+		qcom,gpio-standby = <2>;
+		qcom,gpio-req-tbl-num = <0 1 2>;
+		qcom,gpio-req-tbl-flags = <1 0 0>;
+		qcom,gpio-req-tbl-label = "CAMIF_MCLK",
+		        "CAM_RESET1",
+		        "CAM_STANDBY";
+		qcom,cam-power-seq-type = "sensor_vreg","sensor_vreg",
+		        "sensor_vreg", "sensor_clk",
+		        "sensor_gpio", "sensor_gpio";
+		qcom,cam-power-seq-val = "cam_vdig","cam_vana",
+		        "cam_vio", "sensor_cam_mclk",
+		        "sensor_gpio_reset",
+		        "sensor_gpio_standby";
+		qcom,cam-power-seq-cfg-val = <1 1 1 24000000 1 1>;
+		qcom,cam-power-seq-delay = <1 1 1 5 5 10>;
+	};
+
 	qcom,camera@20 {
 		compatible = "ovti,ov8865";
 		reg = <0x20>;
@@ -39,6 +155,7 @@
 		qcom,csid-sd-index = <0>;
 		qcom,actuator-src = <&actuator0>;
 		qcom,led-flash-src = <&led_flash0>;
+		qcom,eeprom-src = <&eeprom3>;
 		qcom,mount-angle = <90>;
 		qcom,sensor-name = "ov8865_q8v18a";
 		cam_vdig-supply = <&pm8226_l5>;
@@ -78,16 +195,16 @@
 		qcom,slave-id = <0x6c 0x300a 0x5648>;
 		qcom,csiphy-sd-index = <1>;
 		qcom,csid-sd-index = <1>;
+		qcom,eeprom-src = <&eeprom2>;
 		qcom,mount-angle = <270>;
 		qcom,sensor-name = "ov5648_oty5f03";
-		cam_vdig-supply = <&pm8226_l5>;
 		cam_vana-supply = <&pm8226_l19>;
 		cam_vio-supply = <&pm8226_lvs1>;
-		qcom,cam-vreg-name = "cam_vdig", "cam_vio", "cam_vana";
-		qcom,cam-vreg-type = <0 1 0>;
-		qcom,cam-vreg-min-voltage = <1200000 0 2850000>;
-		qcom,cam-vreg-max-voltage = <1200000 0 2850000>;
-		qcom,cam-vreg-op-mode = <200000 0 80000>;
+		qcom,cam-vreg-name = "cam_vio", "cam_vana";
+		qcom,cam-vreg-type = <1 0>;
+		qcom,cam-vreg-min-voltage = <0 2850000>;
+		qcom,cam-vreg-max-voltage = <0 2850000>;
+		qcom,cam-vreg-op-mode = <0 80000>;
 		qcom,gpio-no-mux = <0>;
 		gpios = <&msmgpio 26 0>,
 				<&msmgpio 28 0>,
diff --git a/arch/arm/boot/dts/msm8926-cdp.dts b/arch/arm/boot/dts/msm8926-cdp.dts
deleted file mode 100644
index d6e70e6..0000000
--- a/arch/arm/boot/dts/msm8926-cdp.dts
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright (c) 2013, The Linux Foundation. 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.
- */
-
-
-/dts-v1/;
-/include/ "msm8926.dtsi"
-/include/ "msm8226-cdp.dtsi"
-/include/ "msm8226-camera-sensor-cdp.dtsi"
-
-/ {
-	model = "Qualcomm MSM 8926 CDP";
-	compatible = "qcom,msm8926-cdp", "qcom,msm8926", "qcom,cdp";
-	qcom,board-id = <1 0>;
-};
-
-&pm8226_chg {
-	status = "ok";
-	qcom,charging-disabled;
-	qcom,use-default-batt-values;
-
-	qcom,bat-if@1200 {
-		status = "disabled";
-	};
-
-};
-
-&hsic_host {
-	status = "ok";
-};
diff --git a/arch/arm/boot/dts/msm8926-mtp.dts b/arch/arm/boot/dts/msm8926-mtp.dts
deleted file mode 100644
index 624781b..0000000
--- a/arch/arm/boot/dts/msm8926-mtp.dts
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright (c) 2013, The Linux Foundation. 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.
- */
-
-
-/dts-v1/;
-/include/ "msm8926.dtsi"
-/include/ "msm8226-mtp.dtsi"
-/include/ "msm8226-camera-sensor-mtp.dtsi"
-
-/ {
-	model = "Qualcomm MSM 8926 MTP";
-	compatible = "qcom,msm8926-mtp", "qcom,msm8926", "qcom,mtp";
-	qcom,board-id = <8 0>;
-};
diff --git a/arch/arm/boot/dts/msm8926-qrd-skug.dts b/arch/arm/boot/dts/msm8926-qrd-skug.dts
index 6d907ef..15a2d58 100644
--- a/arch/arm/boot/dts/msm8926-qrd-skug.dts
+++ b/arch/arm/boot/dts/msm8926-qrd-skug.dts
@@ -61,8 +61,8 @@
 			focaltech,fw-name = "ft_8926_qrd_fw.bin";
 			focaltech,fw-delay-aa-ms = <30>;
 			focaltech,fw-delay-55-ms = <30>;
-			focaltech,fw-upgrade-id1 = <0x79>;
-			focaltech,fw-upgrade-id2 = <0x08>;
+			focaltech,fw-upgrade-id1 = <0x11>;
+			focaltech,fw-upgrade-id2 = <0x11>;
 			focaltech,fw-delay-readid-ms = <10>;
 			focaltech,fw-delay-era-flsh-ms = <2000>;
 			focaltech,fw-auto-cal;
diff --git a/arch/arm/boot/dts/msm8974-camera-sensor-fluid.dtsi b/arch/arm/boot/dts/msm8974-camera-sensor-fluid.dtsi
index c84dfe5..07eb311 100644
--- a/arch/arm/boot/dts/msm8974-camera-sensor-fluid.dtsi
+++ b/arch/arm/boot/dts/msm8974-camera-sensor-fluid.dtsi
@@ -11,6 +11,16 @@
  * GNU General Public License for more details.
  */
 
+&soc {
+	led_flash0: qcom,camera-led-flash {
+		cell-index = <0>;
+		compatible = "qcom,camera-led-flash";
+		qcom,flash-type = <1>;
+		qcom,flash-source = <&pm8941_flash0 &pm8941_flash1>;
+		qcom,torch-source = <&pm8941_torch>;
+	};
+};
+
 &cci {
 
 	actuator0: qcom,actuator@18 {
diff --git a/arch/arm/boot/dts/msm8974-camera-sensor-mtp.dtsi b/arch/arm/boot/dts/msm8974-camera-sensor-mtp.dtsi
index 02d2288..9d44bda 100644
--- a/arch/arm/boot/dts/msm8974-camera-sensor-mtp.dtsi
+++ b/arch/arm/boot/dts/msm8974-camera-sensor-mtp.dtsi
@@ -11,6 +11,15 @@
  * GNU General Public License for more details.
  */
 
+&soc {
+	led_flash0: qcom,camera-led-flash {
+		cell-index = <0>;
+		compatible = "qcom,camera-led-flash";
+		qcom,flash-type = <1>;
+		qcom,flash-source = <&pm8941_flash0 &pm8941_flash1>;
+	};
+};
+
 &cci {
 
 	actuator0: qcom,actuator@18 {
diff --git a/arch/arm/boot/dts/msm8974-camera.dtsi b/arch/arm/boot/dts/msm8974-camera.dtsi
index 610f237..28799ab 100644
--- a/arch/arm/boot/dts/msm8974-camera.dtsi
+++ b/arch/arm/boot/dts/msm8974-camera.dtsi
@@ -176,14 +176,6 @@
 		vdd-supply = <&gdsc_vfe>;
 	};
 
-	led_flash0: qcom,camera-led-flash {
-		cell-index = <0>;
-		compatible = "qcom,camera-led-flash";
-		qcom,flash-type = <1>;
-		qcom,flash-source = <&pm8941_flash0 &pm8941_flash1>;
-		qcom,torch-source = <&pm8941_torch>;
-	};
-
 	cci: qcom,cci@fda0C000 {
 		cell-index = <0>;
 		compatible = "qcom,cci";
diff --git a/arch/arm/boot/dts/msm8974-coresight.dtsi b/arch/arm/boot/dts/msm8974-coresight.dtsi
index a809c2b..b7e64c3 100644
--- a/arch/arm/boot/dts/msm8974-coresight.dtsi
+++ b/arch/arm/boot/dts/msm8974-coresight.dtsi
@@ -219,12 +219,57 @@
 		qcom,round-robin;
 	};
 
+	audio_etm0 {
+		compatible = "qcom,coresight-audio-etm";
+
+		coresight-id = <14>;
+		coresight-name = "coresight-audio-etm0";
+		coresight-nr-inports = <0>;
+		coresight-outports = <0>;
+		coresight-child-list = <&funnel_in0>;
+		coresight-child-ports = <2>;
+	};
+
+	modem_etm0 {
+		compatible = "qcom,coresight-modem-etm";
+
+		coresight-id = <15>;
+		coresight-name = "coresight-modem-etm0";
+		coresight-nr-inports = <0>;
+		coresight-outports = <0>;
+		coresight-child-list = <&funnel_in0>;
+		coresight-child-ports = <1>;
+	};
+
+	wcn_etm0 {
+		compatible = "qcom,coresight-wcn-etm";
+
+		coresight-id = <16>;
+		coresight-name = "coresight-wcn-etm0";
+		coresight-nr-inports = <0>;
+		coresight-outports = <0>;
+		coresight-child-list = <&funnel_in1>;
+		coresight-child-ports = <2>;
+	};
+
+	rpm_etm0 {
+		compatible = "qcom,coresight-rpm-etm";
+
+		coresight-id = <17>;
+		coresight-name = "coresight-rpm-etm0";
+		coresight-nr-inports = <0>;
+		coresight-outports = <0>;
+		coresight-child-list = <&funnel_in0>;
+		coresight-child-ports = <0>;
+	};
+
+
 	csr: csr@fc302000 {
 		compatible = "qcom,coresight-csr";
 		reg = <0xfc302000 0x1000>;
 		reg-names = "csr-base";
 
-		coresight-id = <14>;
+		coresight-id = <18>;
 		coresight-name = "coresight-csr";
 		coresight-nr-inports = <0>;
 
@@ -236,7 +281,7 @@
 		reg = <0xfc308000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <15>;
+		coresight-id = <19>;
 		coresight-name = "coresight-cti0";
 		coresight-nr-inports = <0>;
 	};
@@ -246,7 +291,7 @@
 		reg = <0xfc309000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <16>;
+		coresight-id = <20>;
 		coresight-name = "coresight-cti1";
 		coresight-nr-inports = <0>;
 	};
@@ -256,7 +301,7 @@
 		reg = <0xfc30a000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <17>;
+		coresight-id = <21>;
 		coresight-name = "coresight-cti2";
 		coresight-nr-inports = <0>;
 	};
@@ -266,7 +311,7 @@
 		reg = <0xfc30b000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <18>;
+		coresight-id = <22>;
 		coresight-name = "coresight-cti3";
 		coresight-nr-inports = <0>;
 	};
@@ -276,7 +321,7 @@
 		reg = <0xfc30c000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <19>;
+		coresight-id = <23>;
 		coresight-name = "coresight-cti4";
 		coresight-nr-inports = <0>;
 	};
@@ -286,7 +331,7 @@
 		reg = <0xfc30d000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <20>;
+		coresight-id = <24>;
 		coresight-name = "coresight-cti5";
 		coresight-nr-inports = <0>;
 	};
@@ -296,7 +341,7 @@
 		reg = <0xfc30e000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <21>;
+		coresight-id = <25>;
 		coresight-name = "coresight-cti6";
 		coresight-nr-inports = <0>;
 	};
@@ -306,7 +351,7 @@
 		reg = <0xfc30f000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <22>;
+		coresight-id = <26>;
 		coresight-name = "coresight-cti7";
 		coresight-nr-inports = <0>;
 	};
@@ -316,7 +361,7 @@
 		reg = <0xfc310000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <23>;
+		coresight-id = <27>;
 		coresight-name = "coresight-cti8";
 		coresight-nr-inports = <0>;
 	};
@@ -326,7 +371,7 @@
 		reg = <0xfc340000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <24>;
+		coresight-id = <28>;
 		coresight-name = "coresight-cti-l2";
 		coresight-nr-inports = <0>;
 	};
@@ -336,7 +381,7 @@
 		reg = <0xfc341000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <25>;
+		coresight-id = <29>;
 		coresight-name = "coresight-cti-cpu0";
 		coresight-nr-inports = <0>;
 	};
@@ -346,7 +391,7 @@
 		reg = <0xfc342000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <26>;
+		coresight-id = <30>;
 		coresight-name = "coresight-cti-cpu1";
 		coresight-nr-inports = <0>;
 	};
@@ -356,7 +401,7 @@
 		reg = <0xfc343000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <27>;
+		coresight-id = <31>;
 		coresight-name = "coresight-cti-cpu2";
 		coresight-nr-inports = <0>;
 	};
@@ -366,11 +411,61 @@
 		reg = <0xfc344000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <28>;
+		coresight-id = <32>;
 		coresight-name = "coresight-cti-cpu3";
 		coresight-nr-inports = <0>;
 	};
 
+	cti_video_cpu0: cti@fc348000 {
+		compatible = "arm,coresight-cti";
+		reg = <0xfc348000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-id = <33>;
+		coresight-name = "coresight-cti-video-cpu0";
+		coresight-nr-inports = <0>;
+	};
+
+	cti_wcn_cpu0: cti@fc34d000 {
+		compatible = "arm,coresight-cti";
+		reg = <0xfc34d000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-id = <34>;
+		coresight-name = "coresight-cti-wcn-cpu0";
+		coresight-nr-inports = <0>;
+	};
+
+	cti_modem_cpu0: cti@fc350000 {
+		compatible = "arm,coresight-cti";
+		reg = <0xfc350000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-id = <35>;
+		coresight-name = "coresight-cti-modem-cpu0";
+		coresight-nr-inports = <0>;
+	};
+
+	cti_audio_cpu0: cti@fc354000 {
+		compatible = "arm,coresight-cti";
+		reg = <0xfc354000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-id = <36>;
+		coresight-name = "coresight-cti-audio-cpu0";
+		coresight-nr-inports = <0>;
+	};
+
+	cti_rpm_cpu0: cti@fc358000 {
+		compatible = "arm,coresight-cti";
+		reg = <0xfc358000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-id = <37>;
+		coresight-name = "coresight-cti-rpm-cpu0";
+		coresight-nr-inports = <0>;
+	};
+
 	hwevent: hwevent@fdf30018 {
 		compatible = "qcom,coresight-hwevent";
 		reg = <0xfdf30018 0x80>,
@@ -379,7 +474,7 @@
 		      <0xfc401600 0x80>;
 		reg-names = "mmss-mux", "apcs-mux", "ppss-mux", "gcc-mux";
 
-		coresight-id = <29>;
+		coresight-id = <38>;
 		coresight-name = "coresight-hwevent";
 		coresight-nr-inports = <0>;
 
@@ -391,7 +486,7 @@
 		reg = <0xfc4be024 0x8>;
 		reg-names = "fuse-base";
 
-		coresight-id = <30>;
+		coresight-id = <39>;
 		coresight-name = "coresight-fuse";
 		coresight-nr-inports = <0>;
 	};
diff --git a/arch/arm/boot/dts/msm8974-fluid.dtsi b/arch/arm/boot/dts/msm8974-fluid.dtsi
index c112bea..d0ca01d 100644
--- a/arch/arm/boot/dts/msm8974-fluid.dtsi
+++ b/arch/arm/boot/dts/msm8974-fluid.dtsi
@@ -30,6 +30,7 @@
 
 	qcom,mdss_mdp@fd900000 {
 		qcom,mdss-pref-prim-intf = "dsi";
+		batfet-supply = <&pm8941_chg_batif>;
 	};
 
 	qcom,hdmi_tx@fd922100 {
diff --git a/arch/arm/boot/dts/msm8974-liquid.dtsi b/arch/arm/boot/dts/msm8974-liquid.dtsi
index 67e1802..ba085a0 100644
--- a/arch/arm/boot/dts/msm8974-liquid.dtsi
+++ b/arch/arm/boot/dts/msm8974-liquid.dtsi
@@ -26,6 +26,8 @@
 
         qcom,mdss_mdp@fd900000 {
                 qcom,mdss-pref-prim-intf = "edp";
+		qcom,panel-lpg-channel = <7>; /* LPG Channel 8 */
+		qcom,panel-pwm-period = <53>;
         };
 
 	i2c@f9967000 {
@@ -214,7 +216,7 @@
 					/* Object 6, Instance = 0 */
 					00 00 00 00 00 00
 					/* Object 38, Instance = 0 */
-					19 03 00 1E 05 0D 00 00 00 00
+					19 04 00 07 08 0D 00 00 00 00
 					00 00 00 00 00 00 00 00 00 00
 					00 00 00 00 00 00 00 00 00 00
 					00 00 00 00 00 00 00 00 00 00
@@ -240,7 +242,7 @@
 					00 00 00 00 00 00 00 00 00
 					/* Object 25, Instance = 0 */
 					00 00 54 6F F0 55 00 00 00 00
-					00 00 00 00 00
+					00 00 00 00 0C
 					/* Object 27, Instance = 0 */
 					00 00 00 00 00 00 00
 					/* Object 40, Instance = 0 */
diff --git a/arch/arm/boot/dts/msm8974-mdss.dtsi b/arch/arm/boot/dts/msm8974-mdss.dtsi
index 6d5000f..c866de7 100644
--- a/arch/arm/boot/dts/msm8974-mdss.dtsi
+++ b/arch/arm/boot/dts/msm8974-mdss.dtsi
@@ -187,9 +187,6 @@
 		reg-names = "edp_base", "mmss_cc_base";
 		vdda-supply = <&pm8941_l12>;
 		gpio-panel-en = <&msmgpio 58 0>;
-		gpio-panel-pwm = <&pm8941_gpios 36 0>;
-		qcom,panel-lpg-channel = <7>; /* LPG Channel 8 */
-		qcom,panel-pwm-period = <53>;
 		qcom,mdss-fb-map = <&mdss_fb0>;
 		gpio-panel-hpd = <&msmgpio 102 0>;
 	};
diff --git a/arch/arm/boot/dts/msm8974-mtp.dtsi b/arch/arm/boot/dts/msm8974-mtp.dtsi
index b88fbdc..f73bcdc 100644
--- a/arch/arm/boot/dts/msm8974-mtp.dtsi
+++ b/arch/arm/boot/dts/msm8974-mtp.dtsi
@@ -30,6 +30,7 @@
 
 	qcom,mdss_mdp@fd900000 {
 		qcom,mdss-pref-prim-intf = "dsi";
+		batfet-supply = <&pm8941_chg_batif>;
 	};
 
 	qcom,hdmi_tx@fd922100 {
diff --git a/arch/arm/boot/dts/msm8974-regulator.dtsi b/arch/arm/boot/dts/msm8974-regulator.dtsi
index 344c26f..9b9202e 100644
--- a/arch/arm/boot/dts/msm8974-regulator.dtsi
+++ b/arch/arm/boot/dts/msm8974-regulator.dtsi
@@ -289,7 +289,7 @@
 		status = "okay";
 		pm8941_l11: regulator-l11 {
 			regulator-min-microvolt = <1300000>;
-			regulator-max-microvolt = <1300000>;
+			regulator-max-microvolt = <1350000>;
 			qcom,init-voltage = <1300000>;
 			status = "okay";
 		};
@@ -376,7 +376,7 @@
 		status = "okay";
 		pm8941_l19: regulator-l19 {
 			regulator-min-microvolt = <2900000>;
-			regulator-max-microvolt = <3300000>;
+			regulator-max-microvolt = <3350000>;
 			qcom,init-voltage = <2900000>;
 			status = "okay";
 		};
diff --git a/arch/arm/boot/dts/msm8974-v1-pm.dtsi b/arch/arm/boot/dts/msm8974-v1-pm.dtsi
index 0115d89..e850c55 100644
--- a/arch/arm/boot/dts/msm8974-v1-pm.dtsi
+++ b/arch/arm/boot/dts/msm8974-v1-pm.dtsi
@@ -208,10 +208,26 @@
 			<50 172>, /* usb1_hs_async_wakeup_irq */
 			<53 104>, /* mdss_irq */
 			<62 222>, /* ee0_krait_hlos_spmi_periph_irq */
+			<0xff 34>,  /* APCC_qgicL2ErrorIrptReq */
+			<0xff 35>,  /* WDT_barkInt */
+			<0xff 40>,  /* qtimer_phy_irq */
 			<0xff 57>,  /* mss_to_apps_irq(0) */
 			<0xff 58>,  /* mss_to_apps_irq(1) */
 			<0xff 59>,  /* mss_to_apps_irq(2) */
 			<0xff 60>,  /* mss_to_apps_irq(3) */
+			<0xff 74>,  /* osmmu_CIrpt[1] */
+			<0xff 75>,  /* osmmu_CIrpt[0] */
+			<0xff 77>,  /* osmmu_CIrpt[0] */
+			<0xff 78>,  /* osmmu_CIrpt[0] */
+			<0xff 79>,  /* osmmu_CIrpt[0] */
+			<0xff 94>,  /* osmmu_CIrpt[0] */
+			<0xff 99>,  /* msm_iommu_pmon_nonsecure_irq */
+			<0xff 102>,  /* osmmu_CIrpt[1] */
+			<0xff 109>,  /* ocmem_dm_nonsec_irq */
+			<0xff 126>,  /* bam_irq[0] */
+			<0xff 155>,  /* sdcc_irq[0] */
+			<0xff 163>,  /* usb30_ee1_irq */
+			<0xff 170>,  /* sdcc_pwr_cmd_irq */
 			<0xff 173>, /* o_wcss_apss_smd_hi */
 			<0xff 174>, /* o_wcss_apss_smd_med */
 			<0xff 175>, /* o_wcss_apss_smd_low */
@@ -230,6 +246,7 @@
 			<0xff 195>, /* lpass_irq_out_apcs(7) */
 			<0xff 196>, /* lpass_irq_out_apcs(8) */
 			<0xff 197>, /* lpass_irq_out_apcs(9) */
+			<0xff 198>, /* coresight-tmc-etr interrupt */
 			<0xff 200>, /* rpm_ipc(4) */
 			<0xff 201>, /* rpm_ipc(5) */
 			<0xff 202>, /* rpm_ipc(6) */
@@ -238,7 +255,10 @@
 			<0xff 205>, /* rpm_ipc(25) */
 			<0xff 206>, /* rpm_ipc(26) */
 			<0xff 207>, /* rpm_ipc(27) */
-			<0xff 240>; /* summary_irq_kpss */
+			<0xff 240>, /* summary_irq_kpss */
+			<0xff 268>, /* bam_irq[1] */
+			<0xff 270>, /* bam_irq[0] */
+			<0xff 271>; /* bam_irq[0] */
 
 		qcom,gpio-parent = <&msmgpio>;
 		qcom,gpio-map = <3  102>,
diff --git a/arch/arm/boot/dts/msm8974-v1.dtsi b/arch/arm/boot/dts/msm8974-v1.dtsi
index 249c963..556e912 100644
--- a/arch/arm/boot/dts/msm8974-v1.dtsi
+++ b/arch/arm/boot/dts/msm8974-v1.dtsi
@@ -134,7 +134,7 @@
 	qcom,iommu-groups = <&venus_domain_ns &venus_domain_cp>;
 	qcom,iommu-group-buffer-types = <0xfff 0x1ff>;
 	qcom,buffer-type-tz-usage-table = <0x1 0x1>,
-					<0x1fe 0x2>;
+					<0x7fe 0x2>;
 };
 
 &sfpb_spinlock {
diff --git a/arch/arm/boot/dts/msm8974-v2-pm.dtsi b/arch/arm/boot/dts/msm8974-v2-pm.dtsi
index 8836975..eb3a48f 100644
--- a/arch/arm/boot/dts/msm8974-v2-pm.dtsi
+++ b/arch/arm/boot/dts/msm8974-v2-pm.dtsi
@@ -215,6 +215,9 @@
 			<50 172>, /* usb1_hs_async_wakeup_irq */
 			<53 104>, /* mdss_irq */
 			<62 222>, /* ee0_krait_hlos_spmi_periph_irq */
+			<0xff 34>,  /* APCC_qgicL2ErrorIrptReq */
+			<0xff 35>,  /* WDT_barkInt */
+			<0xff 40>,  /* qtimer_phy_irq */
 			<0xff 56>,  /* modem_watchdog */
 			<0xff 57>,  /* mss_to_apps_irq(0) */
 			<0xff 58>,  /* mss_to_apps_irq(1) */
@@ -222,8 +225,21 @@
 			<0xff 60>,  /* mss_to_apps_irq(3) */
 			<0xff 61>,  /* mss_a2_bam_irq */
 			<0xff 70>,  /* iommu_pmon_nonsecure_irq */
+			<0xff 74>,  /* osmmu_CIrpt[1] */
+			<0xff 75>,  /* osmmu_CIrpt[0] */
+			<0xff 77>,  /* osmmu_CIrpt[0] */
+			<0xff 78>,  /* osmmu_CIrpt[0] */
+			<0xff 79>,  /* osmmu_CIrpt[0] */
+			<0xff 94>,  /* osmmu_CIrpt[0] */
 			<0xff 97>,  /* iommu_nonsecure_irq */
+			<0xff 99>,  /* msm_iommu_pmon_nonsecure_irq */
+			<0xff 102>,  /* osmmu_CIrpt[1] */
 			<0xff 105>, /* iommu_pmon_nonsecure_irq */
+			<0xff 109>,  /* ocmem_dm_nonsec_irq */
+			<0xff 126>,  /* bam_irq[0] */
+			<0xff 155>,  /* sdcc_irq[0] */
+			<0xff 163>,  /* usb30_ee1_irq */
+			<0xff 170>,  /* sdcc_pwr_cmd_irq */
 			<0xff 173>, /* o_wcss_apss_smd_hi */
 			<0xff 174>, /* o_wcss_apss_smd_med */
 			<0xff 175>, /* o_wcss_apss_smd_low */
@@ -231,7 +247,6 @@
 			<0xff 177>, /* o_wcss_apss_wlan_data_xfer_done */
 			<0xff 178>, /* o_wcss_apss_wlan_rx_data_avail */
 			<0xff 179>, /* o_wcss_apss_asic_intr */
-
 			<0xff 181>, /* wcnss watchdog */
 			<0xff 188>, /* lpass_irq_out_apcs(0) */
 			<0xff 189>, /* lpass_irq_out_apcs(1) */
@@ -243,6 +258,7 @@
 			<0xff 195>, /* lpass_irq_out_apcs(7) */
 			<0xff 196>, /* lpass_irq_out_apcs(8) */
 			<0xff 197>, /* lpass_irq_out_apcs(9) */
+			<0xff 198>, /* coresight-tmc-etr interrupt */
 			<0xff 200>, /* rpm_ipc(4) */
 			<0xff 201>, /* rpm_ipc(5) */
 			<0xff 202>, /* rpm_ipc(6) */
@@ -252,7 +268,10 @@
 			<0xff 206>, /* rpm_ipc(26) */
 			<0xff 207>, /* rpm_ipc(27) */
 			<0xff 211>, /* usb_dwc3_otg */
-			<0xff 240>; /* summary_irq_kpss */
+			<0xff 240>, /* summary_irq_kpss */
+			<0xff 268>, /* bam_irq[1] */
+			<0xff 270>, /* bam_irq[0] */
+			<0xff 271>; /* bam_irq[0] */
 
 		qcom,gpio-parent = <&msmgpio>;
 		qcom,gpio-map = <3  102>,
diff --git a/arch/arm/boot/dts/msm8974-v2.dtsi b/arch/arm/boot/dts/msm8974-v2.dtsi
index 55e18f0..238f02c 100644
--- a/arch/arm/boot/dts/msm8974-v2.dtsi
+++ b/arch/arm/boot/dts/msm8974-v2.dtsi
@@ -81,6 +81,7 @@
 	qcom,mdss-has-bwc;
 	qcom,mdss-has-decimation;
 	qcom,mdss-ad-off = <0x0013100 0x00013300>;
+	vdd-cx-supply = <&pm8841_s2_corner>;
 };
 
 &mdss_hdmi_tx {
@@ -136,9 +137,9 @@
 		<3240000 1600000>,
 		<4048000 1600000>,
 		<4264000 1600000>;
-	qcom,buffer-type-tz-usage-table = <0x91 0x1>,
-					<0x42 0x2>,
-					<0x120 0x3>;
+	qcom,buffer-type-tz-usage-table = <0x241 0x1>,
+					<0x106 0x2>,
+					<0x480 0x3>;
 	qcom,vidc-iommu-domains {
 		qcom,domain-ns {
 			qcom,vidc-domain-phandle = <&venus_domain_ns>;
diff --git a/arch/arm/boot/dts/msm8974.dtsi b/arch/arm/boot/dts/msm8974.dtsi
index 8079324..69e2529 100644
--- a/arch/arm/boot/dts/msm8974.dtsi
+++ b/arch/arm/boot/dts/msm8974.dtsi
@@ -283,6 +283,24 @@
 				<87 512 60000 960000>;
 	};
 
+	rmtfs_sharedmem {
+		compatible = "qcom,sharedmem-uio";
+		reg = <0x0fd80000 0x00180000>;
+		reg-names = "rmtfs";
+	};
+
+	dsp_sharedmem {
+		compatible = "qcom,sharedmem-uio";
+		reg = <0x0fd60000 0x00020000>;
+		reg-names = "rfsa_dsp";
+	};
+
+	mdm_sharedmem {
+		compatible = "qcom,sharedmem-uio";
+		reg = <0x0fd60000 0x00020000>;
+		reg-names = "rfsa_mdm";
+	};
+
 	sdcc1: qcom,sdcc@f9824000 {
 		cell-index = <1>; /* SDC1 eMMC slot */
 		compatible = "qcom,msm-sdcc";
@@ -600,7 +618,7 @@
 		#size-cells = <0>;
 		reg-names = "spi_physical", "spi_bam_physical";
 		reg = <0xf9966000 0x1000>,
-		      <0xf9944000 0x15000>;
+		      <0xf9944000 0x19000>;
 		interrupt-names = "spi_irq", "spi_bam_irq";
 		interrupts = <0 104 0>, <0 239 0>;
 		spi-max-frequency = <19200000>;
@@ -741,6 +759,14 @@
 	sound {
 		compatible = "qcom,msm8974-audio-taiko";
 		qcom,model = "msm8974-taiko-snd-card";
+		reg = <0xfe02b000 0x4>,
+		      <0xfe02c000 0x4>,
+		      <0xfe02d000 0x4>,
+		      <0xfe02e000 0x4>;
+		reg-names = "lpaif_pri_mode_muxsel",
+			    "lpaif_sec_mode_muxsel",
+			    "lpaif_tert_mode_muxsel",
+			    "lpaif_quat_mode_muxsel";
 
 		qcom,audio-routing =
 			"RX_BIAS", "MCLK",
@@ -804,7 +830,7 @@
 		interrupts = <0 105 0>;
 		interrupt-names = "qup_err_intr";
 		qcom,i2c-bus-freq = <100000>;
-		qcom,i2c-src-freq = <50000000>;
+		qcom,i2c-src-freq = <19200000>;
 		qcom,master-id = <84>;
 	};
 
@@ -847,7 +873,7 @@
 		#size-cells = <0>;
 		reg-names = "spi_physical", "spi_bam_physical";
 		reg = <0xf9923000 0x1000>,
-		      <0xf9904000 0xf000>;
+		      <0xf9904000 0x19000>;
 		interrupt-names = "spi_irq", "spi_bam_irq";
 		interrupts = <0 95 0>, <0 238 0>;
 		spi-max-frequency = <19200000>;
diff --git a/arch/arm/boot/dts/msm8974pro-ac-pma8084-pm8941.dtsi b/arch/arm/boot/dts/msm8974pro-ac-pma8084-pm8941.dtsi
index 746702b..dc438bb 100644
--- a/arch/arm/boot/dts/msm8974pro-ac-pma8084-pm8941.dtsi
+++ b/arch/arm/boot/dts/msm8974pro-ac-pma8084-pm8941.dtsi
@@ -106,6 +106,7 @@
 	interrupt-map = <0x0 0 &intc 0 133 0
 			0x0 1 &spmi_bus 0x0 0x2 0x9 0x0>;
 	interrupt-names = "hs_phy_irq", "pmic_id_irq";
+	qcom,dwc-ssphy-deemphasis-value = <26>;
 };
 
 /* Correct PM8941 local slave ID 0 to use global SID 4 for all interrupts. */
diff --git a/arch/arm/boot/dts/msm8974pro-pm.dtsi b/arch/arm/boot/dts/msm8974pro-pm.dtsi
index 9e1f83f..5769446 100644
--- a/arch/arm/boot/dts/msm8974pro-pm.dtsi
+++ b/arch/arm/boot/dts/msm8974pro-pm.dtsi
@@ -205,6 +205,9 @@
 			<50 172>, /* usb1_hs_async_wakeup_irq */
 			<53 104>, /* mdss_irq */
 			<62 222>, /* ee0_krait_hlos_spmi_periph_irq */
+			<0xff 34>,  /* APCC_qgicL2ErrorIrptReq */
+			<0xff 35>,  /* WDT_barkInt */
+			<0xff 40>,  /* qtimer_phy_irq */
 			<0xff 56>,  /* modem_watchdog */
 			<0xff 57>,  /* mss_to_apps_irq(0) */
 			<0xff 58>,  /* mss_to_apps_irq(1) */
@@ -212,8 +215,21 @@
 			<0xff 60>,  /* mss_to_apps_irq(3) */
 			<0xff 61>,  /* mss_a2_bam_irq */
 			<0xff 70>,  /* iommu_pmon_nonsecure_irq */
+			<0xff 74>,  /* osmmu_CIrpt[1] */
+			<0xff 75>,  /* osmmu_CIrpt[0] */
+			<0xff 77>,  /* osmmu_CIrpt[0] */
+			<0xff 78>,  /* osmmu_CIrpt[0] */
+			<0xff 79>,  /* osmmu_CIrpt[0] */
+			<0xff 94>,  /* osmmu_CIrpt[0] */
 			<0xff 97>,  /* iommu_nonsecure_irq */
+			<0xff 99>,  /* msm_iommu_pmon_nonsecure_irq */
+			<0xff 102>,  /* osmmu_CIrpt[1] */
 			<0xff 105>, /* iommu_pmon_nonsecure_irq */
+			<0xff 109>,  /* ocmem_dm_nonsec_irq */
+			<0xff 126>,  /* bam_irq[0] */
+			<0xff 155>,  /* sdcc_irq[0] */
+			<0xff 163>,  /* usb30_ee1_irq */
+			<0xff 170>,  /* sdcc_pwr_cmd_irq */
 			<0xff 173>, /* o_wcss_apss_smd_hi */
 			<0xff 174>, /* o_wcss_apss_smd_med */
 			<0xff 175>, /* o_wcss_apss_smd_low */
@@ -233,6 +249,7 @@
 			<0xff 195>, /* lpass_irq_out_apcs(7) */
 			<0xff 196>, /* lpass_irq_out_apcs(8) */
 			<0xff 197>, /* lpass_irq_out_apcs(9) */
+			<0xff 198>, /* coresight-tmc-etr interrupt */
 			<0xff 200>, /* rpm_ipc(4) */
 			<0xff 201>, /* rpm_ipc(5) */
 			<0xff 202>, /* rpm_ipc(6) */
@@ -242,7 +259,10 @@
 			<0xff 206>, /* rpm_ipc(26) */
 			<0xff 207>, /* rpm_ipc(27) */
 			<0xff 211>, /* usb_dwc3_otg */
-			<0xff 240>; /* summary_irq_kpss */
+			<0xff 240>, /* summary_irq_kpss */
+			<0xff 268>, /* bam_irq[1] */
+			<0xff 270>, /* bam_irq[0] */
+			<0xff 271>; /* bam_irq[0] */
 
 		qcom,gpio-parent = <&msmgpio>;
 		qcom,gpio-map = <3  102>,
diff --git a/arch/arm/boot/dts/msm8974pro-pm8941.dtsi b/arch/arm/boot/dts/msm8974pro-pm8941.dtsi
index 0f37584..2c06c3c 100644
--- a/arch/arm/boot/dts/msm8974pro-pm8941.dtsi
+++ b/arch/arm/boot/dts/msm8974pro-pm8941.dtsi
@@ -38,18 +38,22 @@
 
 &krait0_vreg {
 		regulator-max-microvolt = <1120000>;
+		qcom,ldo-delta-voltage = <25000>;
 };
 
 &krait1_vreg {
 		regulator-max-microvolt = <1120000>;
+		qcom,ldo-delta-voltage = <25000>;
 };
 
 &krait2_vreg {
 		regulator-max-microvolt = <1120000>;
+		qcom,ldo-delta-voltage = <25000>;
 };
 
 &krait3_vreg {
 		regulator-max-microvolt = <1120000>;
+		qcom,ldo-delta-voltage = <25000>;
 };
 
 &tspp {
diff --git a/arch/arm/boot/dts/msm8974pro-pma8084-regulator.dtsi b/arch/arm/boot/dts/msm8974pro-pma8084-regulator.dtsi
index df00f8a..00e3b8b 100644
--- a/arch/arm/boot/dts/msm8974pro-pma8084-regulator.dtsi
+++ b/arch/arm/boot/dts/msm8974pro-pma8084-regulator.dtsi
@@ -494,7 +494,7 @@
 			qcom,retention-voltage = <675000>;
 			qcom,ldo-default-voltage = <750000>;
 			qcom,ldo-threshold-voltage = <850000>;
-			qcom,ldo-delta-voltage = <50000>;
+			qcom,ldo-delta-voltage = <25000>;
 			qcom,cpu-num = <0>;
 		};
 
@@ -510,7 +510,7 @@
 			qcom,retention-voltage = <675000>;
 			qcom,ldo-default-voltage = <750000>;
 			qcom,ldo-threshold-voltage = <850000>;
-			qcom,ldo-delta-voltage = <50000>;
+			qcom,ldo-delta-voltage = <25000>;
 			qcom,cpu-num = <1>;
 		};
 
@@ -526,7 +526,7 @@
 			qcom,retention-voltage = <675000>;
 			qcom,ldo-default-voltage = <750000>;
 			qcom,ldo-threshold-voltage = <850000>;
-			qcom,ldo-delta-voltage = <50000>;
+			qcom,ldo-delta-voltage = <25000>;
 			qcom,cpu-num = <2>;
 		};
 
@@ -542,7 +542,7 @@
 			qcom,retention-voltage = <675000>;
 			qcom,ldo-default-voltage = <750000>;
 			qcom,ldo-threshold-voltage = <850000>;
-			qcom,ldo-delta-voltage = <50000>;
+			qcom,ldo-delta-voltage = <25000>;
 			qcom,cpu-num = <3>;
 		};
 	};
diff --git a/arch/arm/boot/dts/msm8974pro.dtsi b/arch/arm/boot/dts/msm8974pro.dtsi
index bd58653..174cee6 100644
--- a/arch/arm/boot/dts/msm8974pro.dtsi
+++ b/arch/arm/boot/dts/msm8974pro.dtsi
@@ -39,6 +39,17 @@
 		/delete-property/ qcom,pmic-sw-mode-temp-hysteresis;
 		/delete-property/ qcom,pmic-sw-mode-regs;
 	};
+
+	sound {
+		reg = <0xfe02c000 0x4>,
+		      <0xfe02d000 0x4>,
+		      <0xfe02e000 0x4>,
+		      <0xfe02f000 0x4>;
+		reg-names = "lpaif_pri_mode_muxsel",
+			    "lpaif_sec_mode_muxsel",
+			    "lpaif_tert_mode_muxsel",
+			    "lpaif_quat_mode_muxsel";
+	};
 };
 
 /* GPU overrides */
@@ -48,20 +59,29 @@
 
 	qcom,initial-pwrlevel = <6>;
 
+	qcom,msm-bus,num-cases = <10>;
 	/* Updated bus bandwidth requirements */
 	qcom,msm-bus,vectors-KBps =
 		/* Off */
 		<26 512 0 0>, <89 604 0 0>,
 		/* SVS */
-		<26 512 0 2400000>, <89 604 0 3000000>,
+		<26 512 0 2400000>, <89 604 0 3200000>,
 		/* Nominal / SVS */
-		<26 512 0 4656000>, <89 604 0 3000000>,
-		/* Nominal */
-		<26 512 0 4656000>, <89 604 0 5120000>,
-		/* Turbo / Nominal */
-		<26 512 0 7464000>, <89 604 0 5120000>,
+		<26 512 0 3680000>, <89 604 0 3200000>,
+		/* Nominal / Nominal */
+		<26 512 0 3680000>, <89 604 0 5280000>,
+		/* Nominal / Nominal */
+		<26 512 0 4912000>, <89 604 0 5280000>,
+		/* Nominal / Turbo */
+		<26 512 0 4912000>, <89 604 0 6224000>,
+		/* Turbo / Turbo */
+		<26 512 0 7464000>, <89 604 0 6224000>,
+		/* Nominal / Turbo */
+		<26 512 0 4912000>, <89 604 0 7400000>,
 		/* Turbo */
-		<26 512 0 7464000>, <89 604 0 6400000>;
+		<26 512 0 7464000>, <89 604 0 7400000>,
+		/* Turbo */
+		<26 512 0 7464000>, <89 604 0 9248000>;
 
        qcom,gpu-pwrlevels {
                #address-cells = <1>;
@@ -72,35 +92,35 @@
                qcom,gpu-pwrlevel@0 {
                        reg = <0>;
                        qcom,gpu-freq = <578000000>;
-                       qcom,bus-freq = <5>;
+                       qcom,bus-freq = <9>;
                        qcom,io-fraction = <33>;
                };
 
 		qcom,gpu-pwrlevel@1 {
 			reg = <1>;
 			qcom,gpu-freq = <462400000>;
-			qcom,bus-freq = <4>;
+			qcom,bus-freq = <8>;
 			qcom,io-fraction = <33>;
 		};
 
 		qcom,gpu-pwrlevel@2 {
 			reg = <2>;
 			qcom,gpu-freq = <462400000>;
-			qcom,bus-freq = <3>;
+			qcom,bus-freq = <7>;
 			qcom,io-fraction = <66>;
 		};
 
 		qcom,gpu-pwrlevel@3 {
 			reg = <3>;
 			qcom,gpu-freq = <389000000>;
-			qcom,bus-freq = <4>;
+			qcom,bus-freq = <6>;
 			qcom,io-fraction = <66>;
 		};
 
 		qcom,gpu-pwrlevel@4 {
 			reg = <4>;
 			qcom,gpu-freq = <389000000>;
-			qcom,bus-freq = <3>;
+			qcom,bus-freq = <5>;
 			qcom,io-fraction = <66>;
 		};
 
@@ -208,9 +228,9 @@
 		<4048000 1600000>,
 		<4264000 1600000>;
 	qcom,max-hw-load = <1281600>; /* max(4k X 2304 @ 24, 4k X 2160 @ 30) + 1080p @ 30 */
-	qcom,buffer-type-tz-usage-table = <0x91 0x1>,
-					<0x42 0x2>,
-					<0x120 0x3>;
+	qcom,buffer-type-tz-usage-table = <0x241 0x1>,
+					<0x106 0x2>,
+					<0x480 0x3>;
 	qcom,vidc-iommu-domains {
 		qcom,domain-ns {
 			qcom,vidc-domain-phandle = <&venus_domain_ns>;
diff --git a/arch/arm/boot/dts/msm9625-coresight.dtsi b/arch/arm/boot/dts/msm9625-coresight.dtsi
index 4880f96..05d5238 100644
--- a/arch/arm/boot/dts/msm9625-coresight.dtsi
+++ b/arch/arm/boot/dts/msm9625-coresight.dtsi
@@ -135,12 +135,45 @@
 		qcom,round-robin;
 	};
 
+	audio_etm0 {
+		compatible = "qcom,coresight-audio-etm";
+
+		coresight-id = <9>;
+		coresight-name = "coresight-audio-etm0";
+		coresight-nr-inports = <0>;
+		coresight-outports = <0>;
+		coresight-child-list = <&funnel_in0>;
+		coresight-child-ports = <2>;
+	};
+
+	modem_etm0 {
+		compatible = "qcom,coresight-modem-etm";
+
+		coresight-id = <10>;
+		coresight-name = "coresight-modem-etm0";
+		coresight-nr-inports = <0>;
+		coresight-outports = <0>;
+		coresight-child-list = <&funnel_in0>;
+		coresight-child-ports = <1>;
+	};
+
+	rpm_etm0 {
+		compatible = "qcom,coresight-rpm-etm";
+
+		coresight-id = <11>;
+		coresight-name = "coresight-rpm-etm0";
+		coresight-nr-inports = <0>;
+		coresight-outports = <0>;
+		coresight-child-list = <&funnel_in0>;
+		coresight-child-ports = <0>;
+	};
+
 	csr: csr@fc302000 {
 		compatible = "qcom,coresight-csr";
 		reg = <0xfc302000 0x1000>;
 		reg-names = "csr-base";
 
-		coresight-id = <9>;
+		coresight-id = <12>;
 		coresight-name = "coresight-csr";
 		coresight-nr-inports = <0>;
 
@@ -152,7 +185,7 @@
 		reg = <0xfc308000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <10>;
+		coresight-id = <13>;
 		coresight-name = "coresight-cti0";
 		coresight-nr-inports = <0>;
 	};
@@ -162,7 +195,7 @@
 		reg = <0xfc309000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <11>;
+		coresight-id = <14>;
 		coresight-name = "coresight-cti1";
 		coresight-nr-inports = <0>;
 	};
@@ -172,7 +205,7 @@
 		reg = <0xfc30a000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <12>;
+		coresight-id = <15>;
 		coresight-name = "coresight-cti2";
 		coresight-nr-inports = <0>;
 	};
@@ -182,7 +215,7 @@
 		reg = <0xfc30b000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <13>;
+		coresight-id = <16>;
 		coresight-name = "coresight-cti3";
 		coresight-nr-inports = <0>;
 	};
@@ -192,7 +225,7 @@
 		reg = <0xfc30c000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <14>;
+		coresight-id = <17>;
 		coresight-name = "coresight-cti4";
 		coresight-nr-inports = <0>;
 	};
@@ -202,7 +235,7 @@
 		reg = <0xfc30d000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <15>;
+		coresight-id = <18>;
 		coresight-name = "coresight-cti5";
 		coresight-nr-inports = <0>;
 	};
@@ -212,7 +245,7 @@
 		reg = <0xfc30e000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <16>;
+		coresight-id = <19>;
 		coresight-name = "coresight-cti6";
 		coresight-nr-inports = <0>;
 	};
@@ -222,7 +255,7 @@
 		reg = <0xfc30f000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <17>;
+		coresight-id = <20>;
 		coresight-name = "coresight-cti7";
 		coresight-nr-inports = <0>;
 	};
@@ -232,18 +265,48 @@
 		reg = <0xfc310000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <18>;
+		coresight-id = <21>;
 		coresight-name = "coresight-cti8";
 		coresight-nr-inports = <0>;
 	};
 
-	cti_cpu: cti@fc333000 {
+	cti_cpu0: cti@fc333000 {
 		compatible = "arm,coresight-cti";
 		reg = <0xfc333000 0x1000>;
 		reg-names = "cti-base";
 
-		coresight-id = <19>;
-		coresight-name = "coresight-cti-cpu";
+		coresight-id = <22>;
+		coresight-name = "coresight-cti-cpu0";
+		coresight-nr-inports = <0>;
+	};
+
+	cti_modem_cpu0: cti@fc350000 {
+		compatible = "arm,coresight-cti";
+		reg = <0xfc350000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-id = <23>;
+		coresight-name = "coresight-cti-modem-cpu0";
+		coresight-nr-inports = <0>;
+	};
+
+	cti_audio_cpu0: cti@fc354000 {
+		compatible = "arm,coresight-cti";
+		reg = <0xfc354000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-id = <24>;
+		coresight-name = "coresight-cti-audio-cpu0";
+		coresight-nr-inports = <0>;
+	};
+
+	cti_rpm_cpu0: cti@fc358000 {
+		compatible = "arm,coresight-cti";
+		reg = <0xfc358000 0x1000>;
+		reg-names = "cti-base";
+
+		coresight-id = <25>;
+		coresight-name = "coresight-cti-rpm-cpu0";
 		coresight-nr-inports = <0>;
 	};
 
@@ -254,7 +317,7 @@
 		      <0xfc401600 0x80>;
 		reg-names = "apcs-mux", "ppss-mux", "gcc-mux";
 
-		coresight-id = <20>;
+		coresight-id = <26>;
 		coresight-name = "coresight-hwevent";
 		coresight-nr-inports = <0>;
 	};
@@ -264,7 +327,7 @@
 		reg = <0xfc4be024 0x8>;
 		reg-names = "fuse-base";
 
-		coresight-id = <21>;
+		coresight-id = <27>;
 		coresight-name = "coresight-fuse";
 		coresight-nr-inports = <0>;
 	};
diff --git a/arch/arm/boot/dts/msmsamarium.dtsi b/arch/arm/boot/dts/msmsamarium.dtsi
index a492561..6c55566 100644
--- a/arch/arm/boot/dts/msmsamarium.dtsi
+++ b/arch/arm/boot/dts/msmsamarium.dtsi
@@ -65,6 +65,24 @@
 		reg = <0xfe805000 0x1000>; /* Address and size of IMEM */
 	};
 
+	rmtfs_sharedmem {
+		compatible = "qcom,sharedmem-uio";
+		reg = <0x0fd80000 0x00180000>;
+		reg-names = "rmtfs";
+	};
+
+	dsp_sharedmem {
+		compatible = "qcom,sharedmem-uio";
+		reg = <0x0fd60000 0x00020000>;
+		reg-names = "rfsa_dsp";
+	};
+
+	mdm_sharedmem {
+		compatible = "qcom,sharedmem-uio";
+		reg = <0x0fd60000 0x00020000>;
+		reg-names = "rfsa_mdm";
+	};
+
 	sdcc1: qcom,sdcc@f9824000 {
 		cell-index = <1>; /* SDC1 eMMC slot */
 		compatible = "qcom,msm-sdcc";
diff --git a/arch/arm/configs/apq8084_defconfig b/arch/arm/configs/apq8084_defconfig
index 7c1af1a..cda1e59 100644
--- a/arch/arm/configs/apq8084_defconfig
+++ b/arch/arm/configs/apq8084_defconfig
@@ -90,6 +90,7 @@
 CONFIG_AEABI=y
 CONFIG_HIGHMEM=y
 CONFIG_COMPACTION=y
+CONFIG_ENABLE_VMALLOC_SAVING=y
 CONFIG_CC_STACKPROTECTOR=y
 CONFIG_CP_ACCESS=y
 CONFIG_USE_OF=y
diff --git a/arch/arm/configs/msm8226-perf_defconfig b/arch/arm/configs/msm8226-perf_defconfig
index 03ed61f..c5aa51a 100644
--- a/arch/arm/configs/msm8226-perf_defconfig
+++ b/arch/arm/configs/msm8226-perf_defconfig
@@ -25,6 +25,7 @@
 CONFIG_PANIC_TIMEOUT=5
 CONFIG_KALLSYMS_ALL=y
 CONFIG_EMBEDDED=y
+# CONFIG_SLUB_DEBUG is not set
 CONFIG_PROFILING=y
 CONFIG_OPROFILE=m
 CONFIG_KPROBES=y
@@ -65,7 +66,6 @@
 CONFIG_MSM_OCMEM=y
 CONFIG_MSM_OCMEM_LOCAL_POWER_CTRL=y
 CONFIG_MSM_OCMEM_DEBUG=y
-CONFIG_MSM_OCMEM_NONSECURE=y
 CONFIG_MSM_OCMEM_POWER_DISABLE=y
 CONFIG_SENSORS_ADSP=y
 CONFIG_MSM_RTB=y
@@ -82,6 +82,7 @@
 CONFIG_AEABI=y
 CONFIG_HIGHMEM=y
 CONFIG_COMPACTION=y
+CONFIG_ENABLE_VMALLOC_SAVING=y
 CONFIG_CC_STACKPROTECTOR=y
 CONFIG_CP_ACCESS=y
 CONFIG_USE_OF=y
@@ -242,6 +243,9 @@
 CONFIG_PPPOE=y
 CONFIG_PPP_ASYNC=y
 CONFIG_PPP_SYNC_TTY=y
+CONFIG_PPPOLAC=y
+CONFIG_PPPOPNS=y
+CONFIG_PPP_MPPE=y
 CONFIG_USB_USBNET=y
 CONFIG_WCNSS_CORE=y
 CONFIG_WCNSS_CORE_PRONTO=y
@@ -266,6 +270,7 @@
 CONFIG_DIAG_CHAR=y
 CONFIG_HW_RANDOM=y
 CONFIG_HW_RANDOM_MSM=y
+CONFIG_MSM_ADSPRPC=y
 CONFIG_I2C=y
 CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_QUP=y
@@ -392,6 +397,8 @@
 CONFIG_RTC_CLASS=y
 # CONFIG_RTC_DRV_MSM is not set
 CONFIG_RTC_DRV_QPNP=y
+CONFIG_UIO=y
+CONFIG_UIO_MSM_SHAREDMEM=y
 CONFIG_STAGING=y
 CONFIG_ANDROID=y
 CONFIG_ANDROID_BINDER_IPC=y
diff --git a/arch/arm/configs/msm8226_defconfig b/arch/arm/configs/msm8226_defconfig
index f953a70..f4ee78d 100644
--- a/arch/arm/configs/msm8226_defconfig
+++ b/arch/arm/configs/msm8226_defconfig
@@ -65,7 +65,6 @@
 CONFIG_MSM_OCMEM=y
 CONFIG_MSM_OCMEM_LOCAL_POWER_CTRL=y
 CONFIG_MSM_OCMEM_DEBUG=y
-CONFIG_MSM_OCMEM_NONSECURE=y
 CONFIG_MSM_OCMEM_POWER_DISABLE=y
 CONFIG_SENSORS_ADSP=y
 CONFIG_MSM_RTB=y
@@ -83,6 +82,7 @@
 CONFIG_AEABI=y
 CONFIG_HIGHMEM=y
 CONFIG_COMPACTION=y
+CONFIG_ENABLE_VMALLOC_SAVING=y
 CONFIG_CC_STACKPROTECTOR=y
 CONFIG_CP_ACCESS=y
 CONFIG_USE_OF=y
@@ -244,6 +244,9 @@
 CONFIG_PPPOE=y
 CONFIG_PPP_ASYNC=y
 CONFIG_PPP_SYNC_TTY=y
+CONFIG_PPPOLAC=y
+CONFIG_PPPOPNS=y
+CONFIG_PPP_MPPE=y
 CONFIG_USB_USBNET=y
 CONFIG_WCNSS_CORE=y
 CONFIG_WCNSS_CORE_PRONTO=y
@@ -268,6 +271,7 @@
 CONFIG_DIAG_CHAR=y
 CONFIG_HW_RANDOM=y
 CONFIG_HW_RANDOM_MSM=y
+CONFIG_MSM_ADSPRPC=y
 CONFIG_I2C=y
 CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_QUP=y
@@ -418,6 +422,8 @@
 CONFIG_RTC_CLASS=y
 # CONFIG_RTC_DRV_MSM is not set
 CONFIG_RTC_DRV_QPNP=y
+CONFIG_UIO=y
+CONFIG_UIO_MSM_SHAREDMEM=y
 CONFIG_STAGING=y
 CONFIG_ANDROID=y
 CONFIG_ANDROID_BINDER_IPC=y
@@ -443,6 +449,10 @@
 CONFIG_CORESIGHT_STM=y
 CONFIG_CORESIGHT_HWEVENT=y
 CONFIG_CORESIGHT_ETM=y
+CONFIG_CORESIGHT_AUDIO_ETM=y
+CONFIG_CORESIGHT_MODEM_ETM=y
+CONFIG_CORESIGHT_WCN_ETM=y
+CONFIG_CORESIGHT_RPM_ETM=y
 CONFIG_CORESIGHT_EVENT=m
 CONFIG_EXT2_FS=y
 CONFIG_EXT2_FS_XATTR=y
diff --git a/arch/arm/configs/msm8610-perf_defconfig b/arch/arm/configs/msm8610-perf_defconfig
index 325aba1..8366a41 100644
--- a/arch/arm/configs/msm8610-perf_defconfig
+++ b/arch/arm/configs/msm8610-perf_defconfig
@@ -79,8 +79,9 @@
 CONFIG_ARM_ARCH_TIMER=y
 CONFIG_PREEMPT=y
 CONFIG_AEABI=y
-CONFIG_HIGHMEM=y
 CONFIG_COMPACTION=y
+CONFIG_CC_STACKPROTECTOR=y
+CONFIG_ENABLE_VMALLOC_SAVING=y
 CONFIG_CP_ACCESS=y
 CONFIG_USE_OF=y
 CONFIG_CPU_FREQ_GOV_POWERSAVE=y
@@ -245,6 +246,7 @@
 CONFIG_DIAG_CHAR=y
 CONFIG_HW_RANDOM=y
 CONFIG_HW_RANDOM_MSM=y
+CONFIG_MSM_ADSPRPC=y
 CONFIG_I2C=y
 CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_QUP=y
@@ -312,7 +314,6 @@
 CONFIG_MSM_KGSL=y
 CONFIG_KGSL_PER_PROCESS_PAGE_TABLE=y
 CONFIG_FB=y
-CONFIG_FB_VIRTUAL=y
 CONFIG_FB_MSM=y
 # CONFIG_FB_MSM_BACKLIGHT is not set
 CONFIG_FB_MSM_MDSS=y
@@ -349,11 +350,16 @@
 CONFIG_MMC_MSM_SPS_SUPPORT=y
 CONFIG_LEDS_QPNP=y
 CONFIG_LEDS_TRIGGERS=y
+CONFIG_LEDS_GPIO=y
 CONFIG_SWITCH=y
 CONFIG_RTC_CLASS=y
 # CONFIG_RTC_DRV_MSM is not set
 CONFIG_RTC_DRV_QPNP=y
+CONFIG_UIO=y
+CONFIG_UIO_MSM_SHAREDMEM=y
 CONFIG_STAGING=y
+CONFIG_ZRAM=y
+CONFIG_ZSMALLOC=y
 CONFIG_ANDROID=y
 CONFIG_ANDROID_BINDER_IPC=y
 CONFIG_ASHMEM=y
@@ -406,6 +412,9 @@
 CONFIG_PPP_DEFLATE=y
 CONFIG_PPP_BSDCOMP=y
 CONFIG_PPPOE=y
+CONFIG_PPPOLAC=y
+CONFIG_PPPOPNS=y
+CONFIG_PPP_MPPE=y
 CONFIG_N_HDLC=y
 CONFIG_UNIX98_PTYS=y
 CONFIG_INPUT_KXTJ9=y
diff --git a/arch/arm/configs/msm8610_defconfig b/arch/arm/configs/msm8610_defconfig
index 2c5363d..02db2f2 100644
--- a/arch/arm/configs/msm8610_defconfig
+++ b/arch/arm/configs/msm8610_defconfig
@@ -80,8 +80,9 @@
 CONFIG_ARM_ARCH_TIMER=y
 CONFIG_PREEMPT=y
 CONFIG_AEABI=y
-CONFIG_HIGHMEM=y
 CONFIG_COMPACTION=y
+CONFIG_CC_STACKPROTECTOR=y
+CONFIG_ENABLE_VMALLOC_SAVING=y
 CONFIG_CP_ACCESS=y
 CONFIG_USE_OF=y
 CONFIG_CPU_FREQ_GOV_POWERSAVE=y
@@ -247,6 +248,7 @@
 CONFIG_DIAG_CHAR=y
 CONFIG_HW_RANDOM=y
 CONFIG_HW_RANDOM_MSM=y
+CONFIG_MSM_ADSPRPC=y
 CONFIG_I2C=y
 CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_QUP=y
@@ -372,11 +374,16 @@
 CONFIG_LEDS_QPNP=y
 CONFIG_LEDS_MSM_GPIO_FLASH=y
 CONFIG_LEDS_TRIGGERS=y
+CONFIG_LEDS_GPIO=y
 CONFIG_SWITCH=y
 CONFIG_RTC_CLASS=y
 # CONFIG_RTC_DRV_MSM is not set
 CONFIG_RTC_DRV_QPNP=y
+CONFIG_UIO=y
+CONFIG_UIO_MSM_SHAREDMEM=y
 CONFIG_STAGING=y
+CONFIG_ZRAM=y
+CONFIG_ZSMALLOC=y
 CONFIG_ANDROID=y
 CONFIG_ANDROID_BINDER_IPC=y
 CONFIG_ASHMEM=y
@@ -401,6 +408,10 @@
 CONFIG_CORESIGHT_STM=y
 CONFIG_CORESIGHT_HWEVENT=y
 CONFIG_CORESIGHT_ETM=y
+CONFIG_CORESIGHT_AUDIO_ETM=y
+CONFIG_CORESIGHT_MODEM_ETM=y
+CONFIG_CORESIGHT_WCN_ETM=y
+CONFIG_CORESIGHT_RPM_ETM=y
 CONFIG_CORESIGHT_EVENT=m
 CONFIG_EXT2_FS=y
 CONFIG_EXT2_FS_XATTR=y
@@ -456,6 +467,9 @@
 CONFIG_PPP_DEFLATE=y
 CONFIG_PPP_BSDCOMP=y
 CONFIG_PPPOE=y
+CONFIG_PPPOLAC=y
+CONFIG_PPPOPNS=y
+CONFIG_PPP_MPPE=y
 CONFIG_N_HDLC=y
 CONFIG_UNIX98_PTYS=y
 CONFIG_INPUT_KXTJ9=y
diff --git a/arch/arm/configs/msm8974-perf_defconfig b/arch/arm/configs/msm8974-perf_defconfig
index fb05a08..07bb88c 100644
--- a/arch/arm/configs/msm8974-perf_defconfig
+++ b/arch/arm/configs/msm8974-perf_defconfig
@@ -298,6 +298,7 @@
 CONFIG_DIAG_CHAR=y
 CONFIG_HW_RANDOM=y
 CONFIG_HW_RANDOM_MSM=y
+CONFIG_MSM_ADSPRPC=y
 CONFIG_I2C=y
 CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_QUP=y
@@ -435,6 +436,8 @@
 CONFIG_RTC_CLASS=y
 # CONFIG_RTC_DRV_MSM is not set
 CONFIG_RTC_DRV_QPNP=y
+CONFIG_UIO=y
+CONFIG_UIO_MSM_SHAREDMEM=y
 CONFIG_STAGING=y
 CONFIG_ANDROID=y
 CONFIG_ANDROID_BINDER_IPC=y
diff --git a/arch/arm/configs/msm8974_defconfig b/arch/arm/configs/msm8974_defconfig
index b26a028..82bbdb7 100644
--- a/arch/arm/configs/msm8974_defconfig
+++ b/arch/arm/configs/msm8974_defconfig
@@ -306,6 +306,7 @@
 CONFIG_DIAG_CHAR=y
 CONFIG_HW_RANDOM=y
 CONFIG_HW_RANDOM_MSM=y
+CONFIG_MSM_ADSPRPC=y
 CONFIG_I2C=y
 CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_QUP=y
@@ -443,6 +444,8 @@
 CONFIG_RTC_CLASS=y
 # CONFIG_RTC_DRV_MSM is not set
 CONFIG_RTC_DRV_QPNP=y
+CONFIG_UIO=y
+CONFIG_UIO_MSM_SHAREDMEM=y
 CONFIG_STAGING=y
 CONFIG_ANDROID=y
 CONFIG_ANDROID_BINDER_IPC=y
@@ -475,6 +478,10 @@
 CONFIG_CORESIGHT_HWEVENT=y
 CONFIG_CORESIGHT_ETM=y
 CONFIG_CORESIGHT_ETM_PCSAVE_DEFAULT_ENABLE=y
+CONFIG_CORESIGHT_AUDIO_ETM=y
+CONFIG_CORESIGHT_MODEM_ETM=y
+CONFIG_CORESIGHT_WCN_ETM=y
+CONFIG_CORESIGHT_RPM_ETM=y
 CONFIG_CORESIGHT_EVENT=m
 CONFIG_BIF=y
 CONFIG_BIF_QPNP=y
diff --git a/arch/arm/configs/msm9625_defconfig b/arch/arm/configs/msm9625_defconfig
index 3f34690..d6811df 100644
--- a/arch/arm/configs/msm9625_defconfig
+++ b/arch/arm/configs/msm9625_defconfig
@@ -295,6 +295,9 @@
 CONFIG_CORESIGHT_STM=y
 CONFIG_CORESIGHT_HWEVENT=y
 CONFIG_CORESIGHT_ETM=y
+CONFIG_CORESIGHT_AUDIO_ETM=y
+CONFIG_CORESIGHT_MODEM_ETM=y
+CONFIG_CORESIGHT_RPM_ETM=y
 CONFIG_CORESIGHT_EVENT=m
 CONFIG_EXT3_FS=y
 CONFIG_VFAT_FS=y
diff --git a/arch/arm/kernel/arch_timer.c b/arch/arm/kernel/arch_timer.c
index 9e27592..92e4f18 100644
--- a/arch/arm/kernel/arch_timer.c
+++ b/arch/arm/kernel/arch_timer.c
@@ -357,7 +357,7 @@
 	.rating	= 400,
 	.read	= arch_counter_read,
 	.mask	= CLOCKSOURCE_MASK(56),
-	.flags	= CLOCK_SOURCE_IS_CONTINUOUS,
+	.flags	= CLOCK_SOURCE_IS_CONTINUOUS | CLOCK_SOURCE_SUSPEND_NONSTOP,
 };
 
 static u32 arch_counter_get_cntvct32(void)
diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
index e000e5e..edb73b4 100644
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
@@ -440,12 +440,18 @@
 		 */
 		thumb = handler & 1;
 
+#if __LINUX_ARM_ARCH__ >= 7
+		/*
+		 * Clear the If-Then Thumb-2 execution state
+		 * ARM spec requires this to be all 000s in ARM mode
+		 * Snapdragon S4/Krait misbehaves on a Thumb=>ARM
+		 * signal transition without this.
+		 */
+		cpsr &= ~PSR_IT_MASK;
+#endif
+
 		if (thumb) {
 			cpsr |= PSR_T_BIT;
-#if __LINUX_ARM_ARCH__ >= 7
-			/* clear the If-Then Thumb-2 execution state */
-			cpsr &= ~PSR_IT_MASK;
-#endif
 		} else
 			cpsr &= ~PSR_T_BIT;
 	}
diff --git a/arch/arm/lib/memset.S b/arch/arm/lib/memset.S
index 650d592..94b0650 100644
--- a/arch/arm/lib/memset.S
+++ b/arch/arm/lib/memset.S
@@ -14,27 +14,15 @@
 
 	.text
 	.align	5
-	.word	0
-
-1:	subs	r2, r2, #4		@ 1 do we have enough
-	blt	5f			@ 1 bytes to align with?
-	cmp	r3, #2			@ 1
-	strltb	r1, [r0], #1		@ 1
-	strleb	r1, [r0], #1		@ 1
-	strb	r1, [r0], #1		@ 1
-	add	r2, r2, r3		@ 1 (r2 = r2 - (4 - r3))
-/*
- * The pointer is now aligned and the length is adjusted.  Try doing the
- * memset again.
- */
 
 ENTRY(memset)
 	ands	r3, r0, #3		@ 1 unaligned?
-	bne	1b			@ 1
+	mov	ip, r0			@ preserve r0 as return value
+	bne	6f			@ 1
 /*
- * we know that the pointer in r0 is aligned to a word boundary.
+ * we know that the pointer in ip is aligned to a word boundary.
  */
-	orr	r1, r1, r1, lsl #8
+1:	orr	r1, r1, r1, lsl #8
 	orr	r1, r1, r1, lsl #16
 	mov	r3, r1
 	cmp	r2, #16
@@ -43,29 +31,28 @@
 #if ! CALGN(1)+0
 
 /*
- * We need an extra register for this loop - save the return address and
- * use the LR
+ * We need 2 extra registers for this loop - use r8 and the LR
  */
-	str	lr, [sp, #-4]!
-	mov	ip, r1
+	stmfd	sp!, {r8, lr}
+	mov	r8, r1
 	mov	lr, r1
 
 2:	subs	r2, r2, #64
-	stmgeia	r0!, {r1, r3, ip, lr}	@ 64 bytes at a time.
-	stmgeia	r0!, {r1, r3, ip, lr}
-	stmgeia	r0!, {r1, r3, ip, lr}
-	stmgeia	r0!, {r1, r3, ip, lr}
+	stmgeia	ip!, {r1, r3, r8, lr}	@ 64 bytes at a time.
+	stmgeia	ip!, {r1, r3, r8, lr}
+	stmgeia	ip!, {r1, r3, r8, lr}
+	stmgeia	ip!, {r1, r3, r8, lr}
 	bgt	2b
-	ldmeqfd	sp!, {pc}		@ Now <64 bytes to go.
+	ldmeqfd	sp!, {r8, pc}		@ Now <64 bytes to go.
 /*
  * No need to correct the count; we're only testing bits from now on
  */
 	tst	r2, #32
-	stmneia	r0!, {r1, r3, ip, lr}
-	stmneia	r0!, {r1, r3, ip, lr}
+	stmneia	ip!, {r1, r3, r8, lr}
+	stmneia	ip!, {r1, r3, r8, lr}
 	tst	r2, #16
-	stmneia	r0!, {r1, r3, ip, lr}
-	ldr	lr, [sp], #4
+	stmneia	ip!, {r1, r3, r8, lr}
+	ldmfd	sp!, {r8, lr}
 
 #else
 
@@ -74,54 +61,63 @@
  * whole cache lines at once.
  */
 
-	stmfd	sp!, {r4-r7, lr}
+	stmfd	sp!, {r4-r8, lr}
 	mov	r4, r1
 	mov	r5, r1
 	mov	r6, r1
 	mov	r7, r1
-	mov	ip, r1
+	mov	r8, r1
 	mov	lr, r1
 
 	cmp	r2, #96
-	tstgt	r0, #31
+	tstgt	ip, #31
 	ble	3f
 
-	and	ip, r0, #31
-	rsb	ip, ip, #32
-	sub	r2, r2, ip
-	movs	ip, ip, lsl #(32 - 4)
-	stmcsia	r0!, {r4, r5, r6, r7}
-	stmmiia	r0!, {r4, r5}
-	tst	ip, #(1 << 30)
-	mov	ip, r1
-	strne	r1, [r0], #4
+	and	r8, ip, #31
+	rsb	r8, r8, #32
+	sub	r2, r2, r8
+	movs	r8, r8, lsl #(32 - 4)
+	stmcsia	ip!, {r4, r5, r6, r7}
+	stmmiia	ip!, {r4, r5}
+	tst	r8, #(1 << 30)
+	mov	r8, r1
+	strne	r1, [ip], #4
 
 3:	subs	r2, r2, #64
-	stmgeia	r0!, {r1, r3-r7, ip, lr}
-	stmgeia	r0!, {r1, r3-r7, ip, lr}
+	stmgeia	ip!, {r1, r3-r8, lr}
+	stmgeia	ip!, {r1, r3-r8, lr}
 	bgt	3b
-	ldmeqfd	sp!, {r4-r7, pc}
+	ldmeqfd	sp!, {r4-r8, pc}
 
 	tst	r2, #32
-	stmneia	r0!, {r1, r3-r7, ip, lr}
+	stmneia	ip!, {r1, r3-r8, lr}
 	tst	r2, #16
-	stmneia	r0!, {r4-r7}
-	ldmfd	sp!, {r4-r7, lr}
+	stmneia	ip!, {r4-r7}
+	ldmfd	sp!, {r4-r8, lr}
 
 #endif
 
 4:	tst	r2, #8
-	stmneia	r0!, {r1, r3}
+	stmneia	ip!, {r1, r3}
 	tst	r2, #4
-	strne	r1, [r0], #4
+	strne	r1, [ip], #4
 /*
  * When we get here, we've got less than 4 bytes to zero.  We
  * may have an unaligned pointer as well.
  */
 5:	tst	r2, #2
-	strneb	r1, [r0], #1
-	strneb	r1, [r0], #1
+	strneb	r1, [ip], #1
+	strneb	r1, [ip], #1
 	tst	r2, #1
-	strneb	r1, [r0], #1
+	strneb	r1, [ip], #1
 	mov	pc, lr
+
+6:	subs	r2, r2, #4		@ 1 do we have enough
+	blt	5b			@ 1 bytes to align with?
+	cmp	r3, #2			@ 1
+	strltb	r1, [ip], #1		@ 1
+	strleb	r1, [ip], #1		@ 1
+	strb	r1, [ip], #1		@ 1
+	add	r2, r2, r3		@ 1 (r2 = r2 - (4 - r3))
+	b	1b
 ENDPROC(memset)
diff --git a/arch/arm/mach-msm/Kconfig b/arch/arm/mach-msm/Kconfig
index 87c2f8c..a341c23 100644
--- a/arch/arm/mach-msm/Kconfig
+++ b/arch/arm/mach-msm/Kconfig
@@ -280,11 +280,11 @@
 	select MEMORY_HOLE_CARVEOUT
 	select MSM_RPM_STATS_LOG
 	select QMI_ENCDEC
-	select DONT_MAP_HOLE_AFTER_MEMBANK0
 	select MSM_ULTRASOUND_B
 	select MSM_RPM_LOG
 	select ARCH_WANT_KMAP_ATOMIC_FLUSH
 	select KRAIT_REGULATOR
+	select ENABLE_VMALLOC_SAVINGS
 
 config ARCH_APQ8084
 	bool "APQ8084"
@@ -305,12 +305,12 @@
 	select ARCH_DMA_ADDR_T_64BIT if ARM_LPAE
 	select ARCH_WANT_KMAP_ATOMIC_FLUSH
 	select MEMORY_HOLE_CARVEOUT
-	select DONT_MAP_HOLE_AFTER_MEMBANK0
 	select QMI_ENCDEC
 	select MSM_SPM_V2
 	select MSM_L2_SPM
 	select MSM_PM8X60 if PM
 	select MSM_RPM_SMD
+	select ENABLE_VMALLOC_SAVINGS
 
 config ARCH_MPQ8092
 	bool "MPQ8092"
@@ -460,7 +460,6 @@
 	select MSM_L2_SPM
 	select MSM_PM8X60 if PM
 	select MEMORY_HOLE_CARVEOUT
-	select DONT_MAP_HOLE_AFTER_MEMBANK0
 	select MSM_BUS_SCALING
 	select CPU_FREQ_MSM
 	select CPU_FREQ
@@ -475,6 +474,7 @@
 	select MSM_RPM_LOG
 	select MSM_IOMMU_SYNC
 	select MSM_RPM_STATS_LOG
+	select ENABLE_VMALLOC_SAVINGS
 
 config ARCH_MSM8226
 	bool "MSM8226"
@@ -500,7 +500,6 @@
 	select MSM_L2_SPM
 	select MSM_PM8X60 if PM
 	select MEMORY_HOLE_CARVEOUT
-	select DONT_MAP_HOLE_AFTER_MEMBANK0
 	select MSM_BUS_SCALING
 	select CPU_FREQ_MSM
 	select CPU_FREQ
@@ -515,6 +514,7 @@
 	select MSM_RPM_LOG
 	select MSM_RPM_STATS_LOG
 	select ARCH_WANT_KMAP_ATOMIC_FLUSH
+	select ENABLE_VMALLOC_SAVINGS
 
 config ARCH_MSMSAMARIUM
 	bool "MSMSAMARIUM"
diff --git a/arch/arm/mach-msm/Makefile b/arch/arm/mach-msm/Makefile
index dd533f4..c44dbc7 100644
--- a/arch/arm/mach-msm/Makefile
+++ b/arch/arm/mach-msm/Makefile
@@ -155,10 +155,7 @@
 obj-$(CONFIG_MSM_DALRPC_TEST) += dal_remotetest.o
 obj-$(CONFIG_ARCH_MSM7X30) += dal_axi.o
 obj-$(CONFIG_ARCH_MSM7X27A) += dal_axi.o
-obj-$(CONFIG_MSM_ADSP) += qdsp5/
-obj-$(CONFIG_MSM7KV2_AUDIO) += qdsp5v2/
 obj-$(CONFIG_MSM_RPCSERVER_HANDSET) += rpc_server_handset.o
-obj-$(CONFIG_MSM_QDSP6) += qdsp6/
 obj-$(CONFIG_MSM8X60_AUDIO) += qdsp6v2/
 obj-$(CONFIG_MSM_AUDIO_QDSP6) += qdsp6v2/
 obj-$(CONFIG_MSM_AUDIO_QDSP6V2) += qdsp6v2/
diff --git a/arch/arm/mach-msm/Makefile.boot b/arch/arm/mach-msm/Makefile.boot
index 552ed16..83c1d4c 100644
--- a/arch/arm/mach-msm/Makefile.boot
+++ b/arch/arm/mach-msm/Makefile.boot
@@ -99,28 +99,34 @@
 
 # MSM8226
    zreladdr-$(CONFIG_ARCH_MSM8226)	:= 0x00008000
-        dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-sim.dtb
-        dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-fluid.dtb
-        dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-v1-cdp.dtb
-        dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-v1-mtp.dtb
-        dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-v1-qrd-evt.dtb
-        dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-v1-qrd-dvt.dtb
-        dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-v2-cdp.dtb
-        dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-v2-mtp.dtb
-        dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-v2-qrd-evt.dtb
-        dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-v2-qrd-dvt.dtb
-        dtb-$(CONFIG_ARCH_MSM8226)	+= msm8926-cdp.dtb
-        dtb-$(CONFIG_ARCH_MSM8226)	+= msm8926-mtp.dtb
-        dtb-$(CONFIG_ARCH_MSM8226)	+= msm8926-qrd.dtb
-        dtb-$(CONFIG_ARCH_MSM8226)	+= msm8926-qrd-skug.dtb
-        dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-v1-qrd-skuf.dtb
-        dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-v2-qrd-skuf.dtb
-        dtb-$(CONFIG_ARCH_MSM8226)	+= apq8026-v1-xpm.dtb
-        dtb-$(CONFIG_ARCH_MSM8226)	+= apq8026-v1-cdp.dtb
-        dtb-$(CONFIG_ARCH_MSM8226)	+= apq8026-v1-mtp.dtb
-        dtb-$(CONFIG_ARCH_MSM8226)	+= apq8026-v2-xpm.dtb
-        dtb-$(CONFIG_ARCH_MSM8226)	+= apq8026-v2-cdp.dtb
-        dtb-$(CONFIG_ARCH_MSM8226)	+= apq8026-v2-mtp.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-sim.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-fluid.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-v1-cdp.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-v1-mtp.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-v1-qrd-evt.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-v1-qrd-dvt.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-v2-720p-cdp.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-v2-1080p-cdp.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-v2-720p-mtp.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-v2-1080p-mtp.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-v2-qrd-evt.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-v2-qrd-dvt.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= msm8926-720p-cdp.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= msm8926-1080p-cdp.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= msm8926-720p-mtp.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= msm8926-1080p-mtp.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= msm8926-qrd.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= msm8926-qrd-skug.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-v1-qrd-skuf.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= msm8226-v2-qrd-skuf.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= apq8026-v1-xpm.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= apq8026-v1-cdp.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= apq8026-v1-mtp.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= apq8026-v2-xpm.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= apq8026-v2-720p-cdp.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= apq8026-v2-1080p-cdp.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= apq8026-v2-720p-mtp.dtb
+	dtb-$(CONFIG_ARCH_MSM8226)	+= apq8026-v2-1080p-mtp.dtb
 
 # FSM9XXX
    zreladdr-$(CONFIG_ARCH_FSM9XXX)	:= 0x10008000
diff --git a/arch/arm/mach-msm/acpuclock-8974.c b/arch/arm/mach-msm/acpuclock-8974.c
index 66534eb..5117949 100644
--- a/arch/arm/mach-msm/acpuclock-8974.c
+++ b/arch/arm/mach-msm/acpuclock-8974.c
@@ -55,7 +55,7 @@
 		.hfpll_phys_base = 0xF908A000,
 		.l2cpmr_iaddr = 0x4501,
 		.sec_clk_sel = 2,
-		.vreg[VREG_CORE] = { "krait0",     1100000 },
+		.vreg[VREG_CORE] = { "krait0",     1120000 },
 		.vreg[VREG_MEM]  = { "krait0_mem", 1050000 },
 		.vreg[VREG_DIG]  = { "krait0_dig", LVL_HIGH },
 		.vreg[VREG_HFPLL_A] = { "krait0_hfpll", 1800000 },
@@ -64,7 +64,7 @@
 		.hfpll_phys_base = 0xF909A000,
 		.l2cpmr_iaddr = 0x5501,
 		.sec_clk_sel = 2,
-		.vreg[VREG_CORE] = { "krait1",     1100000 },
+		.vreg[VREG_CORE] = { "krait1",     1120000 },
 		.vreg[VREG_MEM]  = { "krait1_mem", 1050000 },
 		.vreg[VREG_DIG]  = { "krait1_dig", LVL_HIGH },
 		.vreg[VREG_HFPLL_A] = { "krait1_hfpll", 1800000 },
@@ -73,7 +73,7 @@
 		.hfpll_phys_base = 0xF90AA000,
 		.l2cpmr_iaddr = 0x6501,
 		.sec_clk_sel = 2,
-		.vreg[VREG_CORE] = { "krait2",     1100000 },
+		.vreg[VREG_CORE] = { "krait2",     1120000 },
 		.vreg[VREG_MEM]  = { "krait2_mem", 1050000 },
 		.vreg[VREG_DIG]  = { "krait2_dig", LVL_HIGH },
 		.vreg[VREG_HFPLL_A] = { "krait2_hfpll", 1800000 },
@@ -82,7 +82,7 @@
 		.hfpll_phys_base = 0xF90BA000,
 		.l2cpmr_iaddr = 0x7501,
 		.sec_clk_sel = 2,
-		.vreg[VREG_CORE] = { "krait3",     1100000 },
+		.vreg[VREG_CORE] = { "krait3",     1120000 },
 		.vreg[VREG_MEM]  = { "krait3_mem", 1050000 },
 		.vreg[VREG_DIG]  = { "krait3_dig", LVL_HIGH },
 		.vreg[VREG_HFPLL_A] = { "krait3_hfpll", 1800000 },
@@ -95,159 +95,7 @@
 	},
 };
 
-static struct msm_bus_paths bw_level_tbl_v1[] __initdata = {
-	[0] =  BW_MBPS(600), /* At least  75 MHz on bus. */
-	[1] =  BW_MBPS(800), /* At least 100 MHz on bus. */
-	[2] = BW_MBPS(1200), /* At least 150 MHz on bus. */
-	[3] = BW_MBPS(1600), /* At least 200 MHz on bus. */
-	[4] = BW_MBPS(2224), /* At least 278 MHz on bus. */
-	[5] = BW_MBPS(3200), /* At least 400 MHz on bus. */
-	[6] = BW_MBPS(4448), /* At least 556 MHz on bus. */
-	[7] = BW_MBPS(6400), /* At least 800 MHz on bus. */
-};
-
-static struct l2_level l2_freq_tbl_v1[] __initdata = {
-	[0]  = { {  300000, PLL_0, 0,   0 }, LVL_LOW,   950000, 0 },
-	[1]  = { {  345600, HFPLL, 2,  36 }, LVL_NOM,   950000, 1 },
-	[2]  = { {  422400, HFPLL, 2,  44 }, LVL_NOM,   950000, 1 },
-	[3]  = { {  499200, HFPLL, 2,  52 }, LVL_NOM,   950000, 2 },
-	[4]  = { {  576000, HFPLL, 1,  30 }, LVL_NOM,   950000, 3 },
-	[5]  = { {  652800, HFPLL, 1,  34 }, LVL_NOM,   950000, 3 },
-	[6]  = { {  729600, HFPLL, 1,  38 }, LVL_NOM,   950000, 3 },
-	[7]  = { {  806400, HFPLL, 1,  42 }, LVL_HIGH, 1050000, 4 },
-	[8]  = { {  883200, HFPLL, 1,  46 }, LVL_HIGH, 1050000, 4 },
-	[9]  = { {  960000, HFPLL, 1,  50 }, LVL_HIGH, 1050000, 4 },
-	[10] = { { 1036800, HFPLL, 1,  54 }, LVL_HIGH, 1050000, 5 },
-	[11] = { { 1113600, HFPLL, 1,  58 }, LVL_HIGH, 1050000, 5 },
-	[12] = { { 1190400, HFPLL, 1,  62 }, LVL_HIGH, 1050000, 6 },
-	[13] = { { 1267200, HFPLL, 1,  66 }, LVL_HIGH, 1050000, 6 },
-	[14] = { { 1344000, HFPLL, 1,  70 }, LVL_HIGH, 1050000, 7 },
-	[15] = { { 1420800, HFPLL, 1,  74 }, LVL_HIGH, 1050000, 7 },
-	[16] = { { 1497600, HFPLL, 1,  78 }, LVL_HIGH, 1050000, 7 },
-	{ }
-};
-
-static struct acpu_level acpu_freq_tbl_v1_pvs0[] __initdata = {
-	{ 1, {  300000, PLL_0, 0,   0 }, L2(0),   825000,  73 },
-	{ 0, {  345600, HFPLL, 2,  36 }, L2(3),   825000,  85 },
-	{ 1, {  422400, HFPLL, 2,  44 }, L2(3),   825000, 104 },
-	{ 0, {  499200, HFPLL, 2,  52 }, L2(6),   825000, 124 },
-	{ 1, {  576000, HFPLL, 1,  30 }, L2(6),   825000, 144 },
-	{ 1, {  652800, HFPLL, 1,  34 }, L2(7),   825000, 165 },
-	{ 1, {  729600, HFPLL, 1,  38 }, L2(7),   825000, 186 },
-	{ 0, {  806400, HFPLL, 1,  42 }, L2(10),  835000, 208 },
-	{ 1, {  883200, HFPLL, 1,  46 }, L2(10),  845000, 229 },
-	{ 0, {  960000, HFPLL, 1,  50 }, L2(10),  860000, 252 },
-	{ 1, { 1036800, HFPLL, 1,  54 }, L2(10),  880000, 275 },
-	{ 0, { 1113600, HFPLL, 1,  58 }, L2(12),  905000, 298 },
-	{ 0, { 1190400, HFPLL, 1,  62 }, L2(12),  920000, 321 },
-	{ 0, { 1267200, HFPLL, 1,  66 }, L2(12),  940000, 346 },
-	{ 1, { 1344000, HFPLL, 1,  70 }, L2(12),  960000, 371 },
-	{ 0, { 1420800, HFPLL, 1,  74 }, L2(16),  980000, 397 },
-	{ 0, { 1497600, HFPLL, 1,  78 }, L2(16),  995000, 423 },
-	{ 0, { 1574400, HFPLL, 1,  82 }, L2(16), 1015000, 450 },
-	{ 0, { 1651200, HFPLL, 1,  86 }, L2(16), 1030000, 477 },
-	{ 1, { 1728000, HFPLL, 1,  90 }, L2(16), 1050000, 506 },
-	{ 0, { 0 } }
-};
-
-static struct acpu_level acpu_freq_tbl_v1_pvs1[] __initdata = {
-	{ 1, {  300000, PLL_0, 0,   0 }, L2(0),   825000,  73 },
-	{ 0, {  345600, HFPLL, 2,  36 }, L2(3),   825000,  85 },
-	{ 1, {  422400, HFPLL, 2,  44 }, L2(3),   825000, 104 },
-	{ 0, {  499200, HFPLL, 2,  52 }, L2(6),   825000, 124 },
-	{ 1, {  576000, HFPLL, 1,  30 }, L2(6),   825000, 144 },
-	{ 1, {  652800, HFPLL, 1,  34 }, L2(7),   825000, 165 },
-	{ 1, {  729600, HFPLL, 1,  38 }, L2(7),   825000, 186 },
-	{ 0, {  806400, HFPLL, 1,  42 }, L2(10),  835000, 208 },
-	{ 1, {  883200, HFPLL, 1,  46 }, L2(10),  845000, 229 },
-	{ 0, {  960000, HFPLL, 1,  50 }, L2(10),  860000, 252 },
-	{ 1, { 1036800, HFPLL, 1,  54 }, L2(10),  880000, 275 },
-	{ 0, { 1113600, HFPLL, 1,  58 }, L2(12),  905000, 298 },
-	{ 0, { 1190400, HFPLL, 1,  62 }, L2(12),  920000, 321 },
-	{ 0, { 1267200, HFPLL, 1,  66 }, L2(12),  940000, 346 },
-	{ 1, { 1344000, HFPLL, 1,  70 }, L2(12),  960000, 371 },
-	{ 0, { 1420800, HFPLL, 1,  74 }, L2(16),  980000, 397 },
-	{ 0, { 1497600, HFPLL, 1,  78 }, L2(16),  995000, 423 },
-	{ 0, { 1574400, HFPLL, 1,  82 }, L2(16), 1015000, 450 },
-	{ 0, { 1651200, HFPLL, 1,  86 }, L2(16), 1030000, 477 },
-	{ 1, { 1728000, HFPLL, 1,  90 }, L2(16), 1050000, 506 },
-	{ 0, { 0 } }
-};
-
-static struct acpu_level acpu_freq_tbl_v1_pvs2[] __initdata = {
-	{ 1, {  300000, PLL_0, 0,   0 }, L2(0),   825000,  73 },
-	{ 0, {  345600, HFPLL, 2,  36 }, L2(3),   825000,  85 },
-	{ 1, {  422400, HFPLL, 2,  44 }, L2(3),   825000, 104 },
-	{ 0, {  499200, HFPLL, 2,  52 }, L2(6),   825000, 124 },
-	{ 1, {  576000, HFPLL, 1,  30 }, L2(6),   825000, 144 },
-	{ 1, {  652800, HFPLL, 1,  34 }, L2(7),   825000, 165 },
-	{ 1, {  729600, HFPLL, 1,  38 }, L2(7),   825000, 186 },
-	{ 0, {  806400, HFPLL, 1,  42 }, L2(10),  825000, 208 },
-	{ 1, {  883200, HFPLL, 1,  46 }, L2(10),  825000, 229 },
-	{ 0, {  960000, HFPLL, 1,  50 }, L2(10),  835000, 252 },
-	{ 1, { 1036800, HFPLL, 1,  54 }, L2(10),  855000, 275 },
-	{ 0, { 1113600, HFPLL, 1,  58 }, L2(12),  875000, 298 },
-	{ 0, { 1190400, HFPLL, 1,  62 }, L2(12),  895000, 321 },
-	{ 0, { 1267200, HFPLL, 1,  66 }, L2(12),  915000, 346 },
-	{ 1, { 1344000, HFPLL, 1,  70 }, L2(12),  930000, 371 },
-	{ 0, { 1420800, HFPLL, 1,  74 }, L2(16),  945000, 397 },
-	{ 0, { 1497600, HFPLL, 1,  78 }, L2(16),  960000, 423 },
-	{ 0, { 1574400, HFPLL, 1,  82 }, L2(16),  975000, 450 },
-	{ 0, { 1651200, HFPLL, 1,  86 }, L2(16),  990000, 477 },
-	{ 1, { 1728000, HFPLL, 1,  90 }, L2(16), 1000000, 506 },
-	{ 0, { 0 } }
-};
-
-static struct acpu_level acpu_freq_tbl_v1_pvs3[] __initdata = {
-	{ 1, {  300000, PLL_0, 0,   0 }, L2(0),   825000,  73 },
-	{ 0, {  345600, HFPLL, 2,  36 }, L2(3),   825000,  85 },
-	{ 1, {  422400, HFPLL, 2,  44 }, L2(3),   825000, 104 },
-	{ 0, {  499200, HFPLL, 2,  52 }, L2(6),   825000, 124 },
-	{ 1, {  576000, HFPLL, 1,  30 }, L2(6),   825000, 144 },
-	{ 1, {  652800, HFPLL, 1,  34 }, L2(7),   825000, 165 },
-	{ 1, {  729600, HFPLL, 1,  38 }, L2(7),   825000, 186 },
-	{ 0, {  806400, HFPLL, 1,  42 }, L2(10),  825000, 208 },
-	{ 1, {  883200, HFPLL, 1,  46 }, L2(10),  825000, 229 },
-	{ 0, {  960000, HFPLL, 1,  50 }, L2(10),  835000, 252 },
-	{ 1, { 1036800, HFPLL, 1,  54 }, L2(10),  855000, 275 },
-	{ 0, { 1113600, HFPLL, 1,  58 }, L2(12),  875000, 298 },
-	{ 0, { 1190400, HFPLL, 1,  62 }, L2(12),  895000, 321 },
-	{ 0, { 1267200, HFPLL, 1,  66 }, L2(12),  915000, 346 },
-	{ 1, { 1344000, HFPLL, 1,  70 }, L2(12),  930000, 371 },
-	{ 0, { 1420800, HFPLL, 1,  74 }, L2(16),  945000, 397 },
-	{ 0, { 1497600, HFPLL, 1,  78 }, L2(16),  960000, 423 },
-	{ 0, { 1574400, HFPLL, 1,  82 }, L2(16),  975000, 450 },
-	{ 0, { 1651200, HFPLL, 1,  86 }, L2(16),  990000, 477 },
-	{ 1, { 1728000, HFPLL, 1,  90 }, L2(16), 1000000, 506 },
-	{ 0, { 0 } }
-};
-
-static struct acpu_level acpu_freq_tbl_v1_pvs4[] __initdata = {
-	{ 1, {  300000, PLL_0, 0,   0 }, L2(0),  825000,  73 },
-	{ 0, {  345600, HFPLL, 2,  36 }, L2(3),  825000,  85 },
-	{ 1, {  422400, HFPLL, 2,  44 }, L2(3),  825000, 104 },
-	{ 0, {  499200, HFPLL, 2,  52 }, L2(6),  825000, 124 },
-	{ 1, {  576000, HFPLL, 1,  30 }, L2(6),  825000, 144 },
-	{ 1, {  652800, HFPLL, 1,  34 }, L2(7),  825000, 165 },
-	{ 1, {  729600, HFPLL, 1,  38 }, L2(7),  825000, 186 },
-	{ 0, {  806400, HFPLL, 1,  42 }, L2(10), 825000, 208 },
-	{ 1, {  883200, HFPLL, 1,  46 }, L2(10), 825000, 229 },
-	{ 0, {  960000, HFPLL, 1,  50 }, L2(10), 825000, 252 },
-	{ 1, { 1036800, HFPLL, 1,  54 }, L2(10), 825000, 275 },
-	{ 0, { 1113600, HFPLL, 1,  58 }, L2(12), 835000, 298 },
-	{ 0, { 1190400, HFPLL, 1,  62 }, L2(12), 855000, 321 },
-	{ 0, { 1267200, HFPLL, 1,  66 }, L2(12), 870000, 346 },
-	{ 1, { 1344000, HFPLL, 1,  70 }, L2(12), 885000, 371 },
-	{ 0, { 1420800, HFPLL, 1,  74 }, L2(16), 900000, 397 },
-	{ 0, { 1497600, HFPLL, 1,  78 }, L2(16), 910000, 423 },
-	{ 0, { 1574400, HFPLL, 1,  82 }, L2(16), 925000, 450 },
-	{ 0, { 1651200, HFPLL, 1,  86 }, L2(16), 940000, 477 },
-	{ 1, { 1728000, HFPLL, 1,  90 }, L2(16), 950000, 506 },
-	{ 0, { 0 } }
-};
-
-static struct msm_bus_paths bw_level_tbl_v2[] __initdata = {
+static struct msm_bus_paths bw_level_tbl[] __initdata = {
 	[0] =  BW_MBPS(600), /* At least  75 MHz on bus. */
 	[1] =  BW_MBPS(800), /* At least 100 MHz on bus. */
 	[2] = BW_MBPS(1200), /* At least 150 MHz on bus. */
@@ -259,7 +107,7 @@
 	[8] = BW_MBPS(7448), /* At least 931 MHz on bus. */
 };
 
-static struct l2_level l2_freq_tbl_v2[] __initdata = {
+static struct l2_level l2_freq_tbl[] __initdata = {
 	[0]  = { {  300000, PLL_0, 0,   0 }, LVL_LOW,   950000, 0 },
 	[1]  = { {  345600, HFPLL, 2,  36 }, LVL_LOW,   950000, 1 },
 	[2]  = { {  422400, HFPLL, 2,  44 }, LVL_LOW,   950000, 2 },
@@ -2440,15 +2288,6 @@
 	{ 0, { 0 } }
 };
 
-static struct pvs_table pvs_v1[NUM_PVS_REVS][NUM_SPEED_BINS][NUM_PVS] __initdata = {
-	/* 8974v1 1.7GHz Parts */
-	[0][0][0] = { acpu_freq_tbl_v1_pvs0, sizeof(acpu_freq_tbl_v1_pvs0) },
-	[0][0][1] = { acpu_freq_tbl_v1_pvs1, sizeof(acpu_freq_tbl_v1_pvs1) },
-	[0][0][2] = { acpu_freq_tbl_v1_pvs2, sizeof(acpu_freq_tbl_v1_pvs2) },
-	[0][0][3] = { acpu_freq_tbl_v1_pvs3, sizeof(acpu_freq_tbl_v1_pvs3) },
-	[0][0][4] = { acpu_freq_tbl_v1_pvs4, sizeof(acpu_freq_tbl_v1_pvs4) },
-};
-
 static struct pvs_table pvs_v2[NUM_PVS_REVS][NUM_SPEED_BINS][NUM_PVS] __initdata = {
 	/* 8974v2 2.0GHz Parts */
 	[0][0][0] = { acpu_freq_tbl_2g_pvs0, sizeof(acpu_freq_tbl_2g_pvs0) },
@@ -2560,8 +2399,8 @@
 };
 
 static struct msm_bus_scale_pdata bus_scale_data __initdata = {
-	.usecase = bw_level_tbl_v2,
-	.num_usecases = ARRAY_SIZE(bw_level_tbl_v2),
+	.usecase = bw_level_tbl,
+	.num_usecases = ARRAY_SIZE(bw_level_tbl),
 	.active_only = 1,
 	.name = "acpuclk-8974",
 };
@@ -2570,68 +2409,23 @@
 	.scalable = scalable,
 	.scalable_size = sizeof(scalable),
 	.hfpll_data = &hfpll_data,
-	.pvs_tables = pvs_v2,
-	.l2_freq_tbl = l2_freq_tbl_v2,
-	.l2_freq_tbl_size = sizeof(l2_freq_tbl_v2),
+	.l2_freq_tbl = l2_freq_tbl,
+	.l2_freq_tbl_size = sizeof(l2_freq_tbl),
 	.bus_scale = &bus_scale_data,
 	.pte_efuse_phys = 0xFC4B80B0,
 	.get_bin_info = get_krait_bin_format_b,
 	.stby_khz = 300000,
 };
 
-static void __init apply_pro_bringup_workaround(void)
-{
-	acpuclk_8974_params.pvs_tables = pvs_pro;
-}
-
-static void __init apply_v1_l2_workaround(void)
-{
-	static struct l2_level resticted_l2_tbl[] __initdata = {
-		[0] = { {  300000, PLL_0, 0,   0 }, LVL_LOW,  1050000, 0 },
-		[1] = { { 1497600, HFPLL, 1,  78 }, LVL_HIGH, 1050000, 7 },
-		{ }
-	};
-	struct acpu_level *l;
-	int s, p, r;
-
-	for (r = 0; r < NUM_PVS_REVS; r++)
-		for (s = 0; s < NUM_SPEED_BINS; s++)
-			for (p = 0; p < NUM_PVS; p++) {
-				l = pvs_v1[r][s][p].table;
-				for (; l && l->speed.khz; l++)
-					l->l2_level = l->l2_level > 5 ? 1 : 0;
-			}
-
-	acpuclk_8974_params.l2_freq_tbl = resticted_l2_tbl;
-	acpuclk_8974_params.l2_freq_tbl_size = sizeof(resticted_l2_tbl);
-}
-
 #define cpu_is_msm8974pro() (cpu_is_msm8974pro_aa() || cpu_is_msm8974pro_ab() \
 			     || cpu_is_msm8974pro_ac())
 
 static int __init acpuclk_8974_probe(struct platform_device *pdev)
 {
-	if (SOCINFO_VERSION_MAJOR(socinfo_get_version()) == 1
-	    && cpu_is_msm8974()) {
-		acpuclk_8974_params.pvs_tables = pvs_v1;
-		acpuclk_8974_params.l2_freq_tbl = l2_freq_tbl_v1;
-		bus_scale_data.usecase = bw_level_tbl_v1;
-		bus_scale_data.num_usecases = ARRAY_SIZE(bw_level_tbl_v1);
-		acpuclk_8974_params.l2_freq_tbl_size = sizeof(l2_freq_tbl_v1);
-
-		/*
-		 * 8974 hardware revisions older than v1.2 may experience L2
-		 * parity errors when running at some performance points between
-		 * 300MHz and 1497.6MHz (non-inclusive), or when vdd_mx is less
-		 * than 1.05V. Restrict L2 operation to safe performance points
-		 * on these devices.
-		 */
-		if (SOCINFO_VERSION_MINOR(socinfo_get_version()) < 2)
-			apply_v1_l2_workaround();
-	}
-
 	if (cpu_is_msm8974pro())
-		apply_pro_bringup_workaround();
+		acpuclk_8974_params.pvs_tables = pvs_pro;
+	else
+		acpuclk_8974_params.pvs_tables = pvs_v2;
 
 	return acpuclk_krait_init(&pdev->dev, &acpuclk_8974_params);
 }
diff --git a/arch/arm/mach-msm/acpuclock-krait.c b/arch/arm/mach-msm/acpuclock-krait.c
index cf3fac0..c5b1deb 100644
--- a/arch/arm/mach-msm/acpuclock-krait.c
+++ b/arch/arm/mach-msm/acpuclock-krait.c
@@ -761,15 +761,22 @@
 	}
 
 	/*
-	 * Increment the L2 HFPLL regulator refcount if _this_ CPU's frequency
-	 * requires a corresponding target L2 frequency that needs the L2 to
-	 * run off of an HFPLL.
+	 * Vote for the L2 HFPLL regulators if _this_ CPU's frequency requires
+	 * a corresponding target L2 frequency that needs the L2 an HFPLL.
 	 */
-	if (drv.l2_freq_tbl[acpu_level->l2_level].speed.src == HFPLL)
-		l2_vreg_count++;
+	if (drv.l2_freq_tbl[acpu_level->l2_level].speed.src == HFPLL) {
+		ret = enable_l2_regulators();
+		if (ret) {
+			dev_err(drv.dev, "enable_l2_regulators() failed (%d)\n",
+				ret);
+			goto err_l2_regs;
+		}
+	}
 
 	return 0;
 
+err_l2_regs:
+	regulator_disable(sc->vreg[VREG_CORE].reg);
 err_core_conf:
 	regulator_put(sc->vreg[VREG_CORE].reg);
 err_core_get:
@@ -901,7 +908,7 @@
 			ret = -ENODEV;
 			goto err_table;
 		}
-		dev_dbg(drv.dev, "CPU%d is running at an unknown rate. Defaulting to %lu KHz.\n",
+		dev_warn(drv.dev, "CPU%d is running at an unknown rate. Defaulting to %lu KHz.\n",
 			cpu, acpu_level->speed.khz);
 	} else {
 		dev_dbg(drv.dev, "CPU%d is running at %lu KHz\n", cpu,
@@ -1208,7 +1215,7 @@
 	l2_level = find_cur_l2_level();
 	if (!l2_level) {
 		l2_level = drv.l2_freq_tbl;
-		dev_dbg(drv.dev, "L2 is running at an unknown rate. Defaulting to %lu KHz.\n",
+		dev_warn(drv.dev, "L2 is running at an unknown rate. Defaulting to %lu KHz.\n",
 			l2_level->speed.khz);
 	} else {
 		dev_dbg(drv.dev, "L2 is running at %lu KHz\n",
diff --git a/arch/arm/mach-msm/board-8226-gpiomux.c b/arch/arm/mach-msm/board-8226-gpiomux.c
index 4dcbc3a..9767746 100644
--- a/arch/arm/mach-msm/board-8226-gpiomux.c
+++ b/arch/arm/mach-msm/board-8226-gpiomux.c
@@ -185,7 +185,14 @@
 
 static struct msm_gpiomux_config msm_lcd_configs[] __initdata = {
 	{
-		.gpio = 25,
+		.gpio = 25,		/* LCD Reset */
+		.settings = {
+			[GPIOMUX_ACTIVE]    = &lcd_rst_act_cfg,
+			[GPIOMUX_SUSPENDED] = &lcd_rst_sus_cfg,
+		},
+	},
+	{
+		.gpio = 109,		/* LCD Enable */
 		.settings = {
 			[GPIOMUX_ACTIVE]    = &lcd_rst_act_cfg,
 			[GPIOMUX_SUSPENDED] = &lcd_rst_sus_cfg,
@@ -303,13 +310,13 @@
 
 static struct gpiomux_setting goodix_ldo_en_sus_cfg = {
 	.func = GPIOMUX_FUNC_GPIO,
-	.drv = GPIOMUX_DRV_6MA,
-	.pull = GPIOMUX_PULL_UP,
+	.drv = GPIOMUX_DRV_2MA,
+	.pull = GPIOMUX_PULL_DOWN,
 };
 
 static struct gpiomux_setting goodix_int_act_cfg = {
 	.func = GPIOMUX_FUNC_GPIO,
-	.drv = GPIOMUX_DRV_8MA,
+	.drv = GPIOMUX_DRV_6MA,
 	.pull = GPIOMUX_PULL_UP,
 };
 
@@ -321,14 +328,14 @@
 
 static struct gpiomux_setting goodix_reset_act_cfg = {
 	.func = GPIOMUX_FUNC_GPIO,
-	.drv = GPIOMUX_DRV_8MA,
+	.drv = GPIOMUX_DRV_6MA,
 	.pull = GPIOMUX_PULL_UP,
 };
 
 static struct gpiomux_setting goodix_reset_sus_cfg = {
 	.func = GPIOMUX_FUNC_GPIO,
-	.drv = GPIOMUX_DRV_8MA,
-	.pull = GPIOMUX_PULL_UP,
+	.drv = GPIOMUX_DRV_2MA,
+	.pull = GPIOMUX_PULL_DOWN,
 };
 
 static struct msm_gpiomux_config msm_skuf_blsp_configs[] __initdata = {
diff --git a/arch/arm/mach-msm/board-8226.c b/arch/arm/mach-msm/board-8226.c
index aff2d75..5244918 100644
--- a/arch/arm/mach-msm/board-8226.c
+++ b/arch/arm/mach-msm/board-8226.c
@@ -82,6 +82,8 @@
 			"msm_sdcc.2", NULL),
 	OF_DEV_AUXDATA("qcom,sdhci-msm", 0xF9864900, \
 			"msm_sdcc.3", NULL),
+	OF_DEV_AUXDATA("qcom,hsic-host", 0xF9A00000, "msm_hsic_host", NULL),
+
 	{}
 };
 
diff --git a/arch/arm/mach-msm/board-8974.c b/arch/arm/mach-msm/board-8974.c
index 80a957f..7b13bbc 100644
--- a/arch/arm/mach-msm/board-8974.c
+++ b/arch/arm/mach-msm/board-8974.c
@@ -108,6 +108,11 @@
 	msm_thermal_device_init();
 }
 
+static struct of_dev_auxdata msm_hsic_host_adata[] = {
+	OF_DEV_AUXDATA("qcom,hsic-host", 0xF9A00000, "msm_hsic_host", NULL),
+	{}
+};
+
 static struct of_dev_auxdata msm8974_auxdata_lookup[] __initdata = {
 	OF_DEV_AUXDATA("qcom,hsusb-otg", 0xF9A55000, \
 			"msm_otg", NULL),
@@ -148,6 +153,8 @@
 			"qcrypto.0", NULL),
 	OF_DEV_AUXDATA("qcom,hsic-host", 0xF9A00000, \
 			"msm_hsic_host", NULL),
+	OF_DEV_AUXDATA("qcom,hsic-smsc-hub", 0, "msm_smsc_hub",
+			msm_hsic_host_adata),
 	{}
 };
 
diff --git a/arch/arm/mach-msm/clock-8226.c b/arch/arm/mach-msm/clock-8226.c
index 993ce58..da0e500 100644
--- a/arch/arm/mach-msm/clock-8226.c
+++ b/arch/arm/mach-msm/clock-8226.c
@@ -694,6 +694,7 @@
 	F_GCC(  56000000,      gpll0,   1,    7,   75),
 	F_GCC(  58982400,      gpll0,   1, 1536, 15625),
 	F_GCC(  60000000,      gpll0,  10,    0,    0),
+	F_GCC(  63160000,      gpll0, 9.5,    0,    0),
 	F_END
 };
 
@@ -1278,6 +1279,7 @@
 	.en_mask = BIT(5),
 	.base = &virt_bases[GCC_BASE],
 	.c = {
+		.parent = &ce1_clk_src.c,
 		.dbg_name = "gcc_ce1_clk",
 		.ops = &clk_ops_vote,
 		CLK_INIT(gcc_ce1_clk.c),
@@ -3217,6 +3219,11 @@
 	CLK_LOOKUP("core_clk", qdss_clk.c, "fc342000.cti"),
 	CLK_LOOKUP("core_clk", qdss_clk.c, "fc343000.cti"),
 	CLK_LOOKUP("core_clk", qdss_clk.c, "fc344000.cti"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "fc348000.cti"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "fc34d000.cti"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "fc350000.cti"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "fc354000.cti"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "fc358000.cti"),
 	CLK_LOOKUP("core_clk", qdss_clk.c, "fd828018.hwevent"),
 
 	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc322000.tmc"),
@@ -3251,6 +3258,11 @@
 	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc342000.cti"),
 	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc343000.cti"),
 	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc344000.cti"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc348000.cti"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc34d000.cti"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc350000.cti"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc354000.cti"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc358000.cti"),
 	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fd828018.hwevent"),
 
 	CLK_LOOKUP("core_mmss_clk", mmss_misc_ahb_clk.c, "fd828018.hwevent"),
@@ -3371,6 +3383,7 @@
 	CLK_LOOKUP("pixel_clk", mdss_pclk0_clk.c, "fd922800.qcom,mdss_dsi"),
 	CLK_LOOKUP("iface_clk", mdss_ahb_clk.c, "fd922800.qcom,mdss_dsi"),
 	CLK_LOOKUP("bus_clk", mdss_axi_clk.c, "fd922800.qcom,mdss_dsi"),
+	CLK_LOOKUP("mdp_core_clk", mdss_mdp_clk.c, "fd922800.qcom,mdss_dsi"),
 
 	CLK_LOOKUP("core_clk", mdss_mdp_clk.c, "fd900000.qcom,mdss_mdp"),
 	CLK_LOOKUP("lut_clk", mdss_mdp_lut_clk.c, "fd900000.qcom,mdss_mdp"),
diff --git a/arch/arm/mach-msm/clock-8610.c b/arch/arm/mach-msm/clock-8610.c
index 85a9f45..5e312aa 100644
--- a/arch/arm/mach-msm/clock-8610.c
+++ b/arch/arm/mach-msm/clock-8610.c
@@ -676,6 +676,7 @@
 	F(  960000, gcc_xo, 10, 1, 2),
 	F( 4800000, gcc_xo,  4, 0, 0),
 	F( 9600000, gcc_xo,  2, 0, 0),
+	F(12000000,  gpll0, 10, 1, 5),
 	F(15000000,  gpll0, 10, 1, 4),
 	F(19200000, gcc_xo,  1, 0, 0),
 	F(25000000,  gpll0, 12, 1, 2),
@@ -782,6 +783,7 @@
 	F(56000000,  gpll0,    1,    7,    75),
 	F(58982400,  gpll0,    1, 1536, 15625),
 	F(60000000,  gpll0,   10,    0,     0),
+	F(63160000,  gpll0,  9.5,    0,     0),
 	F_END,
 };
 
@@ -1283,6 +1285,7 @@
 	.en_mask = BIT(5),
 	.base = &virt_bases[GCC_BASE],
 	.c = {
+		.parent = &ce1_clk_src.c,
 		.dbg_name = "gcc_ce1_clk",
 		.ops = &clk_ops_vote,
 		CLK_INIT(gcc_ce1_clk.c),
@@ -1351,8 +1354,6 @@
 	.cbcr_reg = LPASS_Q6_AXI_CBCR,
 	.has_sibling = 1,
 	.base = &virt_bases[GCC_BASE],
-	 /* FIXME: Remove this once simulation is fixed. */
-	.halt_check = DELAY,
 	.c = {
 		.dbg_name = "gcc_lpass_q6_axi_clk",
 		.ops = &clk_ops_branch,
@@ -1893,14 +1894,10 @@
 	.cbcr_reg = BIMC_GFX_CBCR,
 	.has_sibling = 1,
 	.base = &virt_bases[MMSS_BASE],
-	 /* FIXME: Remove this once simulation is fixed. */
-	.halt_check = DELAY,
 	.c = {
 		.dbg_name = "bimc_gfx_clk",
 		.ops = &clk_ops_branch,
 		CLK_INIT(bimc_gfx_clk.c),
-		/* FIXME: Remove once kgsl votes on the depends clock. */
-		.depends = &gcc_bimc_smmu_clk.c,
 	},
 };
 
@@ -2267,8 +2264,6 @@
 static struct branch_clk mdp_axi_clk = {
 	.cbcr_reg = MDP_AXI_CBCR,
 	.base = &virt_bases[MMSS_BASE],
-	 /* FIXME: Remove this once simulation is fixed. */
-	.halt_check = DELAY,
 	.c = {
 		.parent = &mdp_axi_clk_src.c,
 		.dbg_name = "mdp_axi_clk",
@@ -2416,8 +2411,6 @@
 	.bcr_reg = VFE_AXI_BCR,
 	.has_sibling = 1,
 	.base = &virt_bases[MMSS_BASE],
-	 /* FIXME: Remove this once simulation is fixed. */
-	.halt_check = DELAY,
 	.c = {
 		.parent = &axi_clk_src.c,
 		.dbg_name = "vfe_axi_clk",
@@ -2831,6 +2824,10 @@
 	CLK_LOOKUP("core_clk", qdss_clk.c, "fc352000.cti"),
 	CLK_LOOKUP("core_clk", qdss_clk.c, "fc353000.cti"),
 	CLK_LOOKUP("core_clk", qdss_clk.c, "fc354000.cti"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "fc335000.cti"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "fc338000.cti"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "fc33c000.cti"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "fc360000.cti"),
 	CLK_LOOKUP("core_clk", qdss_clk.c, "fc34c000.jtagmm"),
 	CLK_LOOKUP("core_clk", qdss_clk.c, "fc34d000.jtagmm"),
 	CLK_LOOKUP("core_clk", qdss_clk.c, "fc34e000.jtagmm"),
@@ -2865,6 +2862,10 @@
 	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc352000.cti"),
 	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc353000.cti"),
 	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc354000.cti"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc335000.cti"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc338000.cti"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc33c000.cti"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc360000.cti"),
 	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc34c000.jtagmm"),
 	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc34d000.jtagmm"),
 	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc34e000.jtagmm"),
@@ -3042,10 +3043,12 @@
 		"fda00c00.qcom,csiphy"),
 	CLK_LOOKUP("csiphy_timer_clk", csi0phytimer_clk.c,
 		"fda00c00.qcom,csiphy"),
+	CLK_LOOKUP("csi_ahb_clk", csi_ahb_clk.c, "fda00c00.qcom,csiphy"),
 	CLK_LOOKUP("csiphy_timer_src_clk", csi1phytimer_clk_src.c,
 		"fda01000.qcom,csiphy"),
 	CLK_LOOKUP("csiphy_timer_clk", csi1phytimer_clk.c,
 		"fda01000.qcom,csiphy"),
+	CLK_LOOKUP("csi_ahb_clk", csi_ahb_clk.c,  "fda01000.qcom,csiphy"),
 
 	/* CSID clocks */
 	CLK_LOOKUP("csi_clk", csi0_clk.c, "fda00000.qcom,csid"),
diff --git a/arch/arm/mach-msm/clock-8974.c b/arch/arm/mach-msm/clock-8974.c
index b0adfa0..d41b52b 100644
--- a/arch/arm/mach-msm/clock-8974.c
+++ b/arch/arm/mach-msm/clock-8974.c
@@ -578,17 +578,6 @@
 			| BVAL(10, 8, s##_mm_source_val), \
 	}
 
-#define F_HDMI(f, s, div, m, n) \
-	{ \
-		.freq_hz = (f), \
-		.src_clk = &s##_clk_src, \
-		.m_val = (m), \
-		.n_val = ~((n)-(m)) * !!(n), \
-		.d_val = ~(n),\
-		.div_src_val = BVAL(4, 0, (int)(2*(div) - 1)) \
-			| BVAL(10, 8, s##_mm_source_val), \
-	}
-
 #define F_MDSS(f, s, div, m, n) \
 	{ \
 		.freq_hz = (f), \
@@ -2200,6 +2189,7 @@
 	.en_mask = BIT(5),
 	.base = &virt_bases[GCC_BASE],
 	.c = {
+		.parent = &ce1_clk_src.c,
 		.dbg_name = "gcc_ce1_clk",
 		.ops = &clk_ops_vote,
 		CLK_INIT(gcc_ce1_clk.c),
@@ -2236,6 +2226,7 @@
 	.en_mask = BIT(2),
 	.base = &virt_bases[GCC_BASE],
 	.c = {
+		.parent = &ce2_clk_src.c,
 		.dbg_name = "gcc_ce2_clk",
 		.ops = &clk_ops_vote,
 		CLK_INIT(gcc_ce2_clk.c),
@@ -3253,60 +3244,19 @@
 	},
 };
 
-static int hdmi_pll_clk_enable(struct clk *c)
-{
-	return hdmi_pll_enable();
-}
-
-static void hdmi_pll_clk_disable(struct clk *c)
-{
-	hdmi_pll_disable();
-}
-
-static int hdmi_pll_clk_set_rate(struct clk *c, unsigned long rate)
-{
-	return hdmi_pll_set_rate(rate);
-}
-
-static struct clk_ops clk_ops_hdmi_pll = {
-	.enable = hdmi_pll_clk_enable,
-	.disable = hdmi_pll_clk_disable,
-	.set_rate = hdmi_pll_clk_set_rate,
-};
-
-static struct clk hdmipll_clk_src = {
-	.parent = &cxo_clk_src.c,
-	.dbg_name = "hdmipll_clk_src",
-	.ops = &clk_ops_hdmi_pll,
-	CLK_INIT(hdmipll_clk_src),
-};
-
 static struct clk_freq_tbl ftbl_mdss_extpclk_clk[] = {
-	/*
-	 * The zero rate is required since suspend/resume wipes out the HDMI PHY
-	 * registers. This entry allows the HDMI driver to switch the cached
-	 * rate to zero before suspend and back to the real rate after resume.
-	 */
-	F_HDMI(        0, hdmipll, 1, 0, 0),
-	F_HDMI( 25200000, hdmipll, 1, 0, 0),
-	F_HDMI( 27000000, hdmipll, 1, 0, 0),
-	F_HDMI( 27030000, hdmipll, 1, 0, 0),
-	F_HDMI( 65000000, hdmipll, 1, 0, 0),
-	F_HDMI( 74250000, hdmipll, 1, 0, 0),
-	F_HDMI(108000000, hdmipll, 1, 0, 0),
-	F_HDMI(148500000, hdmipll, 1, 0, 0),
-	F_HDMI(268500000, hdmipll, 1, 0, 0),
-	F_HDMI(297000000, hdmipll, 1, 0, 0),
+	F_MM(148500000, hdmipll, 1, 0, 0),
 	F_END
 };
 
 static struct rcg_clk extpclk_clk_src = {
 	.cmd_rcgr_reg = EXTPCLK_CMD_RCGR,
 	.freq_tbl = ftbl_mdss_extpclk_clk,
-	.current_freq = &rcg_dummy_freq,
+	.current_freq = ftbl_mdss_extpclk_clk,
 	.base = &virt_bases[MMSS_BASE],
 	.c = {
 		.dbg_name = "extpclk_clk_src",
+		.parent = &hdmipll_clk_src.c,
 		.ops = &clk_ops_rcg_hdmi,
 		VDD_DIG_FMAX_MAP2(LOW, 148500000, NOMINAL, 297000000),
 		CLK_INIT(extpclk_clk_src.c),
@@ -5102,6 +5052,8 @@
 	CLK_LOOKUP("bus_clk", mdss_axi_clk.c, "fd922e00.qcom,mdss_dsi"),
 	CLK_LOOKUP("pixel_clk", mdss_pclk0_clk.c, "fd922800.qcom,mdss_dsi"),
 	CLK_LOOKUP("pixel_clk", mdss_pclk1_clk.c, "fd922e00.qcom,mdss_dsi"),
+	CLK_LOOKUP("mdp_core_clk", mdss_mdp_clk.c, "fd922800.qcom,mdss_dsi"),
+	CLK_LOOKUP("mdp_core_clk", mdss_mdp_clk.c, "fd922e00.qcom,mdss_dsi"),
 	CLK_LOOKUP("iface_clk", mdss_ahb_clk.c, "fd922100.qcom,hdmi_tx"),
 	CLK_LOOKUP("alt_iface_clk", mdss_hdmi_ahb_clk.c,
 		"fd922100.qcom,hdmi_tx"),
@@ -5461,6 +5413,11 @@
 	CLK_LOOKUP("core_clk", qdss_clk.c, "fc342000.cti"),
 	CLK_LOOKUP("core_clk", qdss_clk.c, "fc343000.cti"),
 	CLK_LOOKUP("core_clk", qdss_clk.c, "fc344000.cti"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "fc348000.cti"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "fc34d000.cti"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "fc350000.cti"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "fc354000.cti"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "fc358000.cti"),
 	CLK_LOOKUP("core_clk", qdss_clk.c, "fdf30018.hwevent"),
 
 	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc322000.tmc"),
@@ -5491,6 +5448,11 @@
 	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc342000.cti"),
 	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc343000.cti"),
 	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc344000.cti"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc348000.cti"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc34d000.cti"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc350000.cti"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc354000.cti"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc358000.cti"),
 	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fdf30018.hwevent"),
 
 	CLK_LOOKUP("core_mmss_clk", mmss_misc_ahb_clk.c, "fdf30018.hwevent"),
diff --git a/arch/arm/mach-msm/clock-9625.c b/arch/arm/mach-msm/clock-9625.c
index 3b07069..0b73ac9 100644
--- a/arch/arm/mach-msm/clock-9625.c
+++ b/arch/arm/mach-msm/clock-9625.c
@@ -1887,6 +1887,9 @@
 	CLK_LOOKUP("core_clk", qdss_clk.c, "fc30f000.cti"),
 	CLK_LOOKUP("core_clk", qdss_clk.c, "fc310000.cti"),
 	CLK_LOOKUP("core_clk", qdss_clk.c, "fc333000.cti"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "fc350000.cti"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "fc354000.cti"),
+	CLK_LOOKUP("core_clk", qdss_clk.c, "fc358000.cti"),
 	CLK_LOOKUP("core_clk", qdss_clk.c, "f9011038.hwevent"),
 
 	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc322000.tmc"),
@@ -1909,6 +1912,9 @@
 	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc30f000.cti"),
 	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc310000.cti"),
 	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc333000.cti"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc350000.cti"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc354000.cti"),
+	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "fc358000.cti"),
 	CLK_LOOKUP("core_a_clk", qdss_a_clk.c, "f9011038.hwevent"),
 };
 
diff --git a/arch/arm/mach-msm/clock-krypton.c b/arch/arm/mach-msm/clock-krypton.c
index 176dc32..2b529b0 100644
--- a/arch/arm/mach-msm/clock-krypton.c
+++ b/arch/arm/mach-msm/clock-krypton.c
@@ -515,6 +515,7 @@
 	F(  56000000,      gpll0,    1,    7,    75),
 	F(  58982400,      gpll0,    1, 1536, 15625),
 	F(  60000000,      gpll0,   10,    0,     0),
+	F(  63160000,      gpll0,  9.5,    0,     0),
 	F_END
 };
 
diff --git a/arch/arm/mach-msm/clock-local2.c b/arch/arm/mach-msm/clock-local2.c
index 4488869..62ecfa8 100644
--- a/arch/arm/mach-msm/clock-local2.c
+++ b/arch/arm/mach-msm/clock-local2.c
@@ -774,27 +774,35 @@
  */
 static int rcg_clk_set_rate_hdmi(struct clk *c, unsigned long rate)
 {
-	struct clk_freq_tbl *nf;
 	struct rcg_clk *rcg = to_rcg_clk(c);
+	struct clk_freq_tbl *nf = rcg->freq_tbl;
 	int rc;
 
-	for (nf = rcg->freq_tbl; nf->freq_hz != rate; nf++)
-		if (nf->freq_hz == FREQ_END) {
-			rc = -EINVAL;
-			goto out;
-		}
-
 	rc = clk_set_rate(nf->src_clk, rate);
 	if (rc < 0)
 		goto out;
 	set_rate_hid(rcg, nf);
 
 	rcg->current_freq = nf;
-	c->parent = nf->src_clk;
 out:
 	return rc;
 }
 
+static struct clk *rcg_hdmi_clk_get_parent(struct clk *c)
+{
+	struct rcg_clk *rcg = to_rcg_clk(c);
+	struct clk_freq_tbl *freq = rcg->freq_tbl;
+	u32 cmd_rcgr_regval;
+
+	/* Is there a pending configuration? */
+	cmd_rcgr_regval = readl_relaxed(CMD_RCGR_REG(rcg));
+	if (cmd_rcgr_regval & CMD_RCGR_CONFIG_DIRTY_MASK)
+		return NULL;
+
+	rcg->current_freq->freq_hz = clk_get_rate(c->parent);
+
+	return freq->src_clk;
+}
 
 #define ENABLE_REG(x)	(*(x)->base + (x)->enable_reg)
 #define SELECT_REG(x)	(*(x)->base + (x)->select_reg)
@@ -987,7 +995,7 @@
 	.list_rate = rcg_clk_list_rate,
 	.round_rate = rcg_clk_round_rate,
 	.handoff = rcg_clk_handoff,
-	.get_parent = rcg_clk_get_parent,
+	.get_parent = rcg_hdmi_clk_get_parent,
 };
 
 struct clk_ops clk_ops_branch = {
diff --git a/arch/arm/mach-msm/clock-mdss-8974.c b/arch/arm/mach-msm/clock-mdss-8974.c
index cf2df18..343a6c6 100644
--- a/arch/arm/mach-msm/clock-mdss-8974.c
+++ b/arch/arm/mach-msm/clock-mdss-8974.c
@@ -167,23 +167,71 @@
 		(!(readl_relaxed(gdsc_base) & BIT(0)));
 }
 
-void hdmi_pll_disable(void)
+/* Auto PLL calibaration */
+static int mdss_ahb_clk_enable(int enable)
 {
-	clk_enable(mdss_ahb_clk);
+	int rc = 0;
+
+	/* todo: Ideally, we should enable/disable GDSC whenever we are
+	 * attempting to enable/disable MDSS AHB clock.
+	 * For now, just return error if  GDSC is not enabled.
+	 */
+	if (!mdss_gdsc_enabled()) {
+		pr_err("%s: mdss GDSC is not enabled\n", __func__);
+		return -EPERM;
+	}
+
+	if (enable)
+		rc = clk_prepare_enable(mdss_ahb_clk);
+	else
+		clk_disable_unprepare(mdss_ahb_clk);
+
+	return rc;
+}
+
+static void hdmi_vco_disable(struct clk *c)
+{
+	u32 rc;
+
+	if (!mdss_gdsc_enabled()) {
+		pr_err("%s: mdss GDSC is not enabled\n", __func__);
+		return;
+	}
+
+	rc = clk_enable(mdss_ahb_clk);
+	if (rc) {
+		pr_err("%s: failed to enable mdss ahb clock. rc=%d\n",
+			__func__, rc);
+		return;
+	}
+
 	REG_W(0x0, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
 	udelay(5);
 	REG_W(0x0, hdmi_phy_base + HDMI_PHY_GLB_CFG);
+
 	clk_disable(mdss_ahb_clk);
 
 	hdmi_pll_on = 0;
-} /* hdmi_pll_disable */
+} /* hdmi_vco_disable */
 
-int hdmi_pll_enable(void)
+static int hdmi_vco_enable(struct clk *c)
 {
 	u32 status;
+	u32 rc;
 	u32 max_reads, timeout_us;
 
-	clk_enable(mdss_ahb_clk);
+	if (!mdss_gdsc_enabled()) {
+		pr_err("%s: mdss GDSC is not enabled\n", __func__);
+		return -EPERM;
+	}
+
+	rc = clk_enable(mdss_ahb_clk);
+	if (rc) {
+		pr_err("%s: failed to enable mdss ahb clock. rc=%d\n",
+			__func__, rc);
+		return rc;
+	}
+
 	/* Global Enable */
 	REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
 	/* Power up power gen */
@@ -208,7 +256,7 @@
 		status, ((status & BIT(0)) == 1), max_reads, timeout_us)) {
 		pr_err("%s: hdmi phy pll status=%x failed to Lock\n",
 		       __func__, status);
-		hdmi_pll_disable();
+		hdmi_vco_disable(c);
 		clk_disable(mdss_ahb_clk);
 		return -EINVAL;
 	}
@@ -222,7 +270,7 @@
 		status, ((status & BIT(0)) == 1), max_reads, timeout_us)) {
 		pr_err("%s: hdmi phy status=%x failed to Lock\n",
 		       __func__, status);
-		hdmi_pll_disable();
+		hdmi_vco_disable(c);
 		clk_disable(mdss_ahb_clk);
 		return -EINVAL;
 	}
@@ -232,25 +280,173 @@
 	hdmi_pll_on = 1;
 
 	return 0;
-} /* hdmi_pll_enable */
+} /* hdmi_vco_enable */
 
-int hdmi_pll_set_rate(unsigned long rate)
+static inline struct hdmi_pll_vco_clk *to_hdmi_vco_clk(struct clk *clk)
+{
+	return container_of(clk, struct hdmi_pll_vco_clk, c);
+}
+
+static void hdmi_phy_pll_calculator(u32 vco_freq)
+{
+	u32 ref_clk             = 19200000;
+	u32 sdm_mode            = 1;
+	u32 ref_clk_multiplier  = sdm_mode == 1 ? 2 : 1;
+	u32 int_ref_clk_freq    = ref_clk * ref_clk_multiplier;
+	u32 fbclk_pre_div       = 1;
+	u32 ssc_mode            = 0;
+	u32 kvco                = 270;
+	u32 vdd                 = 95;
+	u32 ten_power_six       = 1000000;
+	u32 ssc_ds_ppm          = ssc_mode ? 5000 : 0;
+	u32 sdm_res             = 16;
+	u32 ssc_tri_step        = 32;
+	u32 ssc_freq            = 2;
+	u64 ssc_ds              = vco_freq * ssc_ds_ppm;
+	u32 div_in_freq         = vco_freq / fbclk_pre_div;
+	u64 dc_offset           = (div_in_freq / int_ref_clk_freq - 1) *
+					ten_power_six * 10;
+	u32 ssc_kdiv            = (int_ref_clk_freq / ssc_freq) -
+					ten_power_six;
+	u64 sdm_freq_seed;
+	u32 ssc_tri_inc;
+	u64 fb_div_n;
+
+	u32 val;
+
+	pr_debug("%s: vco_freq = %u\n", __func__, vco_freq);
+
+	do_div(ssc_ds, (u64)ten_power_six);
+
+	fb_div_n = (u64)div_in_freq * (u64)ten_power_six * 10;
+	do_div(fb_div_n, int_ref_clk_freq);
+
+	sdm_freq_seed = ((fb_div_n - dc_offset - ten_power_six * 10) *
+				(1 << sdm_res)  * 10) + 5;
+	do_div(sdm_freq_seed, ((u64)ten_power_six * 100));
+
+	ssc_tri_inc = (u32)ssc_ds;
+	ssc_tri_inc = (ssc_tri_inc / int_ref_clk_freq) * (1 << 16) /
+			ssc_tri_step;
+
+	val = (ref_clk_multiplier == 2 ? 1 : 0) +
+		((fbclk_pre_div == 2 ? 1 : 0) * 16);
+	pr_debug("%s: HDMI_UNI_PLL_REFCLK_CFG = 0x%x\n", __func__, val);
+	REG_W(val, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG);
+
+	REG_W(0x02, hdmi_phy_pll_base + HDMI_UNI_PLL_CHFPUMP_CFG);
+	REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG);
+	REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG);
+	REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_PWRGEN_CFG);
+	REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
+	REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
+	REG_W(0x0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG);
+	REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG);
+	REG_W(0x0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG);
+
+	do_div(dc_offset, (u64)ten_power_six * 10);
+	val = sdm_mode == 0 ? 64 + dc_offset : 0;
+	pr_debug("%s: HDMI_UNI_PLL_SDM_CFG0 = 0x%x\n", __func__, val);
+	REG_W(val, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0);
+
+	val = 64 + dc_offset;
+	pr_debug("%s: HDMI_UNI_PLL_SDM_CFG1 = 0x%x\n", __func__, val);
+	REG_W(val, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1);
+
+	val = sdm_freq_seed & 0xFF;
+	pr_debug("%s: HDMI_UNI_PLL_SDM_CFG2 = 0x%x\n", __func__, val);
+	REG_W(val, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2);
+
+	val = (sdm_freq_seed >> 8) & 0xFF;
+	pr_debug("%s: HDMI_UNI_PLL_SDM_CFG3 = 0x%x\n", __func__, val);
+	REG_W(val, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3);
+
+	val = (sdm_freq_seed >> 16) & 0xFF;
+	pr_debug("%s: HDMI_UNI_PLL_SDM_CFG4 = 0x%x\n", __func__, val);
+	REG_W(val, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4);
+
+	val = (ssc_mode == 0 ? 128 : 0) + (ssc_kdiv / ten_power_six);
+	pr_debug("%s: HDMI_UNI_PLL_SSC_CFG0 = 0x%x\n", __func__, val);
+	REG_W(val, hdmi_phy_pll_base + HDMI_UNI_PLL_SSC_CFG0);
+
+	val = ssc_tri_inc & 0xFF;
+	pr_debug("%s: HDMI_UNI_PLL_SSC_CFG1 = 0x%x\n", __func__, val);
+	REG_W(val, hdmi_phy_pll_base + HDMI_UNI_PLL_SSC_CFG1);
+
+	val = (ssc_tri_inc >> 8) & 0xFF;
+	pr_debug("%s: HDMI_UNI_PLL_SSC_CFG2 = 0x%x\n", __func__, val);
+	REG_W(val, hdmi_phy_pll_base + HDMI_UNI_PLL_SSC_CFG2);
+
+	pr_debug("%s: HDMI_UNI_PLL_SSC_CFG3 = 0x%x\n", __func__, ssc_tri_step);
+	REG_W(ssc_tri_step, hdmi_phy_pll_base + HDMI_UNI_PLL_SSC_CFG3);
+
+	REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
+	REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
+	REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
+	REG_W(0x0A, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG0);
+	REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG1);
+	REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
+	REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG3);
+	REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG4);
+	REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG5);
+
+	val = (kvco * vdd * 10000) / 6;
+	val += 500000;
+	val /= ten_power_six;
+	pr_debug("%s: HDMI_UNI_PLL_CAL_CFG6 = 0x%x\n", __func__, val);
+	REG_W(val & 0xFF, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG6);
+
+	val = (kvco * vdd * 10000) / 6;
+	val -= ten_power_six;
+	val /= ten_power_six;
+	val = (val >> 8) & 0xFF;
+	pr_debug("%s: HDMI_UNI_PLL_CAL_CFG7 = 0x%x\n", __func__, val);
+	REG_W(val, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG7);
+
+	val = (ref_clk * 5) / ten_power_six;
+	pr_debug("%s: HDMI_UNI_PLL_CAL_CFG8 = 0x%x\n", __func__, val);
+	REG_W(val, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8);
+
+	val = ((ref_clk * 5) / ten_power_six) >> 8;
+	pr_debug("%s: HDMI_UNI_PLL_CAL_CFG9 = 0x%x\n", __func__, val);
+	REG_W(val, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9);
+
+	vco_freq /= ten_power_six;
+	val = vco_freq & 0xFF;
+	pr_debug("%s: HDMI_UNI_PLL_CAL_CFG10 = 0x%x\n", __func__, val);
+	REG_W(val, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10);
+
+	val = vco_freq >> 8;
+	pr_debug("%s: HDMI_UNI_PLL_CAL_CFG11 = 0x%x\n", __func__, val);
+	REG_W(val, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11);
+} /* hdmi_phy_pll_calculator */
+
+static int hdmi_vco_set_rate(struct clk *c, unsigned long rate)
 {
 	unsigned int set_power_dwn = 0;
+	int rc = 0;
+
+	struct hdmi_pll_vco_clk *vco = to_hdmi_vco_clk(c);
 
 	if (hdmi_pll_on) {
-		hdmi_pll_disable();
+		hdmi_vco_disable(c);
 		set_power_dwn = 1;
 	}
 
-	clk_enable(mdss_ahb_clk);
+	rc = mdss_ahb_clk_enable(1);
+	if (rc) {
+		pr_err("%s: failed to enable mdss ahb clock. rc=%d\n",
+			__func__, rc);
+		return rc;
+	}
+
 	pr_debug("%s: rate=%ld\n", __func__, rate);
+
 	switch (rate) {
 	case 0:
-		/* This case is needed for suspend/resume. */
-	break;
+		break;
 
-	case 25200000:
+	case 756000000:
 		/* 640x480p60 */
 		REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
 		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
@@ -267,7 +463,6 @@
 		REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
 		REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
 		REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
-		REG_W(0x03, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
 		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
 		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
 		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
@@ -295,7 +490,7 @@
 		udelay(200);
 	break;
 
-	case 27000000:
+	case 810000000:
 		/* 576p50/576i50 case */
 		REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
 		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
@@ -312,7 +507,6 @@
 		REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
 		REG_W(0X1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
 		REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
-		REG_W(0x03, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
 		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
 		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
 		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
@@ -340,7 +534,7 @@
 		udelay(200);
 	break;
 
-	case 27030000:
+	case 810900000:
 		/* 480p60/480i60 case */
 		REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
 		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
@@ -357,7 +551,6 @@
 		REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
 		REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
 		REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
-		REG_W(0x03, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
 		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
 		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
 		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
@@ -384,7 +577,7 @@
 		REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3);
 		udelay(200);
 	break;
-	case 65000000:
+	case 650000000:
 		REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
 		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
 		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG);
@@ -400,7 +593,6 @@
 		REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
 		REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
 		REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
-		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
 		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
 		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
 		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
@@ -427,7 +619,7 @@
 		REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3);
 		udelay(200);
 	break;
-	case 74250000:
+	case 742500000:
 		/*
 		 * 720p60/720p50/1080i60/1080i50
 		 * 1080p24/1080p30/1080p25 case
@@ -447,7 +639,6 @@
 		REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
 		REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
 		REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
-		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
 		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
 		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
 		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
@@ -475,7 +666,7 @@
 		udelay(200);
 	break;
 
-	case 108000000:
+	case 1080000000:
 		REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
 		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
 		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG);
@@ -491,7 +682,6 @@
 		REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
 		REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
 		REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
-		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
 		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
 		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
 		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
@@ -519,51 +709,7 @@
 		udelay(200);
 	break;
 
-	case 148500000:
-		REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
-		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
-		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG);
-		REG_W(0x19, hdmi_phy_pll_base + HDMI_UNI_PLL_VCOLPF_CFG);
-		REG_W(0x0E, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFR_CFG);
-		REG_W(0x20, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC1_CFG);
-		REG_W(0x0D, hdmi_phy_pll_base + HDMI_UNI_PLL_LPFC2_CFG);
-		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG0);
-		REG_W(0x52, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG1);
-		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG2);
-		REG_W(0x56, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG3);
-		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_SDM_CFG4);
-		REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
-		REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
-		REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
-		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
-		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
-		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
-		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
-		REG_W(0x60, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG8);
-		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG9);
-		REG_W(0xE6, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG10);
-		REG_W(0x02, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG11);
-		REG_W(0x1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0);
-		udelay(50);
-
-		REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
-		REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1);
-		REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
-		REG_W(0xDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0);
-		REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1);
-		REG_W(0x02, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
-		REG_W(0x00, hdmi_phy_base + HDMI_PHY_ANA_CFG3);
-		REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG);
-		REG_W(0xD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0);
-		REG_W(0x1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1);
-		REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0);
-		REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1);
-		REG_W(0x02, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2);
-		REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3);
-		udelay(200);
-	break;
-
-	case 268500000:
+	case 1342500000:
 		REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
 		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
 		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG);
@@ -579,7 +725,6 @@
 		REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
 		REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
 		REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
-		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
 		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
 		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
 		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
@@ -607,7 +752,7 @@
 		udelay(200);
 	break;
 
-	case 297000000:
+	case 1485000000:
 		REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
 		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
 		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_REFCLK_CFG);
@@ -623,7 +768,6 @@
 		REG_W(0x10, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG0);
 		REG_W(0x1A, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG1);
 		REG_W(0x05, hdmi_phy_pll_base + HDMI_UNI_PLL_LKDET_CFG2);
-		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV1_CFG);
 		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV2_CFG);
 		REG_W(0x00, hdmi_phy_pll_base + HDMI_UNI_PLL_POSTDIV3_CFG);
 		REG_W(0x01, hdmi_phy_pll_base + HDMI_UNI_PLL_CAL_CFG2);
@@ -652,40 +796,68 @@
 	break;
 
 	default:
-		pr_err("%s: not supported rate=%ld\n", __func__, rate);
+		pr_debug("%s: Use pll settings calculator for rate=%ld\n",
+			__func__, rate);
+
+		REG_W(0x81, hdmi_phy_base + HDMI_PHY_GLB_CFG);
+		hdmi_phy_pll_calculator(rate);
+		REG_W(0x1F, hdmi_phy_base + HDMI_PHY_PD_CTRL0);
+		udelay(50);
+
+		REG_W(0x0F, hdmi_phy_pll_base + HDMI_UNI_PLL_GLB_CFG);
+		REG_W(0x00, hdmi_phy_base + HDMI_PHY_PD_CTRL1);
+		REG_W(0x10, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
+		REG_W(0xDB, hdmi_phy_base + HDMI_PHY_ANA_CFG0);
+		REG_W(0x43, hdmi_phy_base + HDMI_PHY_ANA_CFG1);
+
+		if (rate < 825000000) {
+			REG_W(0x01, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
+			REG_W(0x00, hdmi_phy_base + HDMI_PHY_ANA_CFG3);
+		} else if (rate >= 825000000 && rate < 1342500000) {
+			REG_W(0x05, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
+			REG_W(0x03, hdmi_phy_base + HDMI_PHY_ANA_CFG3);
+		} else {
+			REG_W(0x06, hdmi_phy_base + HDMI_PHY_ANA_CFG2);
+			REG_W(0x03, hdmi_phy_base + HDMI_PHY_ANA_CFG3);
+		}
+
+		REG_W(0x04, hdmi_phy_pll_base + HDMI_UNI_PLL_VREG_CFG);
+		REG_W(0xD0, hdmi_phy_base + HDMI_PHY_DCC_CFG0);
+		REG_W(0x1A, hdmi_phy_base + HDMI_PHY_DCC_CFG1);
+		REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG0);
+		REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG1);
+
+		if (rate < 825000000)
+			REG_W(0x01, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2);
+		else
+			REG_W(0x00, hdmi_phy_base + HDMI_PHY_TXCAL_CFG2);
+
+		REG_W(0x05, hdmi_phy_base + HDMI_PHY_TXCAL_CFG3);
+		REG_W(0x62, hdmi_phy_base + HDMI_PHY_BIST_PATN0);
+		REG_W(0x03, hdmi_phy_base + HDMI_PHY_BIST_PATN1);
+		REG_W(0x69, hdmi_phy_base + HDMI_PHY_BIST_PATN2);
+		REG_W(0x02, hdmi_phy_base + HDMI_PHY_BIST_PATN3);
+
+		udelay(200);
+
+		REG_W(0x00, hdmi_phy_base + HDMI_PHY_BIST_CFG1);
+		REG_W(0x00, hdmi_phy_base + HDMI_PHY_BIST_CFG0);
 	}
 
 	/* Make sure writes complete before disabling iface clock */
 	mb();
 
-	clk_disable(mdss_ahb_clk);
+	mdss_ahb_clk_enable(0);
 
 	if (set_power_dwn)
-		hdmi_pll_enable();
+		hdmi_vco_enable(c);
+
+	vco->rate = rate;
+	vco->rate_set = true;
 
 	return 0;
 } /* hdmi_pll_set_rate */
 
-/* Auto PLL calibaration */
-int mdss_ahb_clk_enable(int enable)
-{
-	int rc = 0;
-
-	/* todo: Ideally, we should enable/disable GDSC whenever we are
-	 * attempting to enable/disable MDSS AHB clock.
-	 * For now, just return error if  GDSC is not enabled.
-	 */
-	if (!mdss_gdsc_enabled())
-		return -EPERM;
-
-	if (enable)
-		rc = clk_prepare_enable(mdss_ahb_clk);
-	else
-		clk_disable_unprepare(mdss_ahb_clk);
-
-	return rc;
-}
-
 int set_byte_mux_sel(struct mux_clk *clk, int sel)
 {
 	pr_debug("%s: byte mux set to %s mode\n", __func__,
@@ -1649,6 +1821,271 @@
 	},
 };
 
+/* HDMI PLL DIV CLK */
+
+static unsigned long hdmi_vco_get_rate(struct clk *c)
+{
+	unsigned long freq = 0;
+
+	if (mdss_ahb_clk_enable(1)) {
+		pr_err("%s: Failed to enable mdss ahb clock\n", __func__);
+		return freq;
+	}
+
+	freq = DSS_REG_R(hdmi_phy_pll_base, HDMI_UNI_PLL_CAL_CFG11) << 8 |
+		DSS_REG_R(hdmi_phy_pll_base, HDMI_UNI_PLL_CAL_CFG10);
+
+	switch (freq) {
+	case 742:
+		freq = 742500000;
+		break;
+	case 810:
+		if (DSS_REG_R(hdmi_phy_pll_base, HDMI_UNI_PLL_SDM_CFG3) == 0x18)
+			freq = 810000000;
+		else
+			freq = 810900000;
+		break;
+	case 1342:
+		freq = 1342500000;
+		break;
+	default:
+		freq *= 1000000;
+	}
+
+	mdss_ahb_clk_enable(0);
+
+	return freq;
+}
+
+static long hdmi_vco_round_rate(struct clk *c, unsigned long rate)
+{
+	unsigned long rrate = rate;
+	struct hdmi_pll_vco_clk *vco = to_hdmi_vco_clk(c);
+
+	if (rate < vco->min_rate)
+		rrate = vco->min_rate;
+	if (rate > vco->max_rate)
+		rrate = vco->max_rate;
+
+	pr_debug("%s: rrate=%ld\n", __func__, rrate);
+
+	return rrate;
+}
+
+static int hdmi_vco_prepare(struct clk *c)
+{
+	struct hdmi_pll_vco_clk *vco = to_hdmi_vco_clk(c);
+	int ret = 0;
+
+	pr_debug("%s: rate=%ld\n", __func__, vco->rate);
+
+	if (!vco->rate_set && vco->rate)
+		ret = hdmi_vco_set_rate(c, vco->rate);
+
+	if (!ret)
+		ret = clk_prepare(mdss_ahb_clk);
+
+	return ret;
+}
+
+static void hdmi_vco_unprepare(struct clk *c)
+{
+	struct hdmi_pll_vco_clk *vco = to_hdmi_vco_clk(c);
+
+	vco->rate_set = false;
+
+	clk_unprepare(mdss_ahb_clk);
+}
+
+static int hdmi_pll_lock_status(void)
+{
+	u32 status;
+	int pll_locked = 0;
+	int rc;
+
+	rc = mdss_ahb_clk_enable(1);
+	if (rc) {
+		pr_err("%s: failed to enable mdss ahb clock. rc=%d\n",
+			__func__, rc);
+		return 0;
+	}
+	/* poll for PLL ready status */
+	if (readl_poll_timeout_noirq((hdmi_phy_base + HDMI_PHY_STATUS),
+			status, ((status & BIT(0)) == 1),
+			PLL_POLL_MAX_READS, PLL_POLL_TIMEOUT_US)) {
+		pr_debug("%s: HDMI PLL status=%x failed to Lock\n",
+				__func__, status);
+		pll_locked = 0;
+	} else {
+		pll_locked = 1;
+	}
+	mdss_ahb_clk_enable(0);
+
+	return pll_locked;
+}
+
+static enum handoff hdmi_vco_handoff(struct clk *c)
+{
+	enum handoff ret = HANDOFF_DISABLED_CLK;
+
+	if (hdmi_pll_lock_status()) {
+		c->rate = hdmi_vco_get_rate(c);
+		ret = HANDOFF_ENABLED_CLK;
+	}
+
+	pr_debug("%s: done, ret=%d\n", __func__, ret);
+	return ret;
+}
+
+static struct clk_ops hdmi_vco_clk_ops = {
+	.enable = hdmi_vco_enable,
+	.set_rate = hdmi_vco_set_rate,
+	.get_rate = hdmi_vco_get_rate,
+	.round_rate = hdmi_vco_round_rate,
+	.prepare = hdmi_vco_prepare,
+	.unprepare = hdmi_vco_unprepare,
+	.disable = hdmi_vco_disable,
+	.handoff = hdmi_vco_handoff,
+};
+
+static struct hdmi_pll_vco_clk hdmi_vco_clk = {
+	.min_rate = 600000000,
+	.max_rate = 1800000000,
+	.c = {
+		.dbg_name = "hdmi_vco_clk",
+		.ops = &hdmi_vco_clk_ops,
+		CLK_INIT(hdmi_vco_clk.c),
+	},
+};
+
+static struct div_clk hdmipll_div1_clk = {
+	.div = 1,
+	.c = {
+		.parent = &hdmi_vco_clk.c,
+		.dbg_name = "hdmipll_div1_clk",
+		.ops = &clk_ops_div,
+		.flags = CLKFLAG_NO_RATE_CACHE,
+		CLK_INIT(hdmipll_div1_clk.c),
+	},
+};
+
+static struct div_clk hdmipll_div2_clk = {
+	.div = 2,
+	.c = {
+		.parent = &hdmi_vco_clk.c,
+		.dbg_name = "hdmipll_div2_clk",
+		.ops = &clk_ops_div,
+		.flags = CLKFLAG_NO_RATE_CACHE,
+		CLK_INIT(hdmipll_div2_clk.c),
+	},
+};
+
+static struct div_clk hdmipll_div4_clk = {
+	.div = 4,
+	.c = {
+		.parent = &hdmi_vco_clk.c,
+		.dbg_name = "hdmipll_div4_clk",
+		.ops = &clk_ops_div,
+		.flags = CLKFLAG_NO_RATE_CACHE,
+		CLK_INIT(hdmipll_div4_clk.c),
+	},
+};
+
+static struct div_clk hdmipll_div6_clk = {
+	.div = 6,
+	.c = {
+		.parent = &hdmi_vco_clk.c,
+		.dbg_name = "hdmipll_div6_clk",
+		.ops = &clk_ops_div,
+		.flags = CLKFLAG_NO_RATE_CACHE,
+		CLK_INIT(hdmipll_div6_clk.c),
+	},
+};
+
+static int hdmipll_set_mux_sel(struct mux_clk *clk, int mux_sel)
+{
+	int rc;
+
+	if (!mdss_gdsc_enabled()) {
+		pr_err("%s: mdss GDSC is not enabled\n", __func__);
+		return -EPERM;
+	}
+
+	rc = clk_enable(mdss_ahb_clk);
+	if (rc) {
+		pr_err("%s: Failed to enable mdss ahb clock\n", __func__);
+		return rc;
+	}
+
+	pr_debug("%s: mux_sel=%d\n", __func__, mux_sel);
+	DSS_REG_W(hdmi_phy_pll_base, HDMI_UNI_PLL_POSTDIV1_CFG, mux_sel);
+
+	clk_disable(mdss_ahb_clk);
+
+	return 0;
+}
+
+static int hdmipll_get_mux_sel(struct mux_clk *clk)
+{
+	int mux_sel = 0;
+
+	if (mdss_ahb_clk_enable(1)) {
+		pr_err("%s: Failed to enable mdss ahb clock\n", __func__);
+		return mux_sel;
+	}
+
+	mux_sel = DSS_REG_R(hdmi_phy_pll_base, HDMI_UNI_PLL_POSTDIV1_CFG);
+	mux_sel &= 0x03;
+	pr_debug("%s: mux_sel=%d\n", __func__, mux_sel);
+
+	mdss_ahb_clk_enable(0);
+
+	return mux_sel;
+}
+
+static struct clk_mux_ops hdmipll_mux_ops = {
+	.set_mux_sel = hdmipll_set_mux_sel,
+	.get_mux_sel = hdmipll_get_mux_sel,
+};
+
+static struct clk_ops hdmi_mux_ops;
+
+static int hdmi_mux_prepare(struct clk *c)
+{
+	int ret = 0;
+
+	if (c && c->ops && c->ops->set_rate)
+		ret = c->ops->set_rate(c, c->rate);
+
+	return ret;
+}
+
+static struct mux_clk hdmipll_mux_clk = {
+	MUX_SRC_LIST(
+		{ &hdmipll_div1_clk.c, 0 },
+		{ &hdmipll_div2_clk.c, 1 },
+		{ &hdmipll_div4_clk.c, 2 },
+		{ &hdmipll_div6_clk.c, 3 },
+	),
+	.ops = &hdmipll_mux_ops,
+	.c = {
+		.parent = &hdmipll_div1_clk.c,
+		.dbg_name = "hdmipll_mux_clk",
+		.ops = &hdmi_mux_ops,
+		CLK_INIT(hdmipll_mux_clk.c),
+	},
+};
+
+struct div_clk hdmipll_clk_src = {
+	.div = 5,
+	.c = {
+		.parent = &hdmipll_mux_clk.c,
+		.dbg_name = "hdmipll_clk_src",
+		.ops = &clk_ops_div,
+		CLK_INIT(hdmipll_clk_src.c),
+	},
+};
+
 void __init mdss_clk_ctrl_pre_init(struct clk *ahb_clk)
 {
 	BUG_ON(ahb_clk == NULL);
@@ -1682,5 +2119,8 @@
 
 	byte_mux_clk_ops = clk_ops_gen_mux;
 	byte_mux_clk_ops.prepare = mux_prepare;
+
+	hdmi_mux_ops = clk_ops_gen_mux;
+	hdmi_mux_ops.prepare = hdmi_mux_prepare;
 }
 
diff --git a/arch/arm/mach-msm/clock-mdss-8974.h b/arch/arm/mach-msm/clock-mdss-8974.h
index 9fd3026..b1d5b45 100644
--- a/arch/arm/mach-msm/clock-mdss-8974.h
+++ b/arch/arm/mach-msm/clock-mdss-8974.h
@@ -22,9 +22,15 @@
 
 void mdss_clk_ctrl_pre_init(struct clk *ahb_clk);
 void mdss_clk_ctrl_post_init(void);
-int hdmi_pll_enable(void);
-void hdmi_pll_disable(void);
-int hdmi_pll_set_rate(unsigned long rate);
+
+struct hdmi_pll_vco_clk {
+	unsigned long rate;	/* current vco rate */
+	unsigned long min_rate;	/* min vco rate */
+	unsigned long max_rate;	/* max vco rate */
+	bool rate_set;
+
+	struct clk c;
+};
 
 struct lpfr_cfg {
 	unsigned long vco_rate;
@@ -57,4 +63,6 @@
 extern struct mux_clk byte_mux_8226;
 extern struct div_clk byte_clk_src_8226;
 
+extern struct div_clk hdmipll_clk_src;
+
 #endif
diff --git a/arch/arm/mach-msm/clock.c b/arch/arm/mach-msm/clock.c
index e3c11c5..6063302 100644
--- a/arch/arm/mach-msm/clock.c
+++ b/arch/arm/mach-msm/clock.c
@@ -557,7 +557,7 @@
 		return -ENOSYS;
 
 	mutex_lock(&clk->prepare_lock);
-	if (clk->parent == parent)
+	if (clk->parent == parent && !(clk->flags & CLKFLAG_NO_RATE_CACHE))
 		goto out;
 	rc = clk->ops->set_parent(clk, parent);
 	if (!rc)
diff --git a/arch/arm/mach-msm/cpuidle.c b/arch/arm/mach-msm/cpuidle.c
index 7c06268..c480e56 100644
--- a/arch/arm/mach-msm/cpuidle.c
+++ b/arch/arm/mach-msm/cpuidle.c
@@ -112,8 +112,8 @@
 			continue;
 
 		state = &msm_cpuidle_driver.states[state_count];
-		snprintf(state->name, CPUIDLE_NAME_LEN, cstate->name);
-		snprintf(state->desc, CPUIDLE_DESC_LEN, cstate->desc);
+		snprintf(state->name, CPUIDLE_NAME_LEN, "%s", cstate->name);
+		snprintf(state->desc, CPUIDLE_DESC_LEN, "%s", cstate->desc);
 		state->flags = 0;
 		state->exit_latency = 0;
 		state->power_usage = 0;
diff --git a/arch/arm/mach-msm/idle-v7.S b/arch/arm/mach-msm/idle-v7.S
index f8a32b4..2956bd6 100644
--- a/arch/arm/mach-msm/idle-v7.S
+++ b/arch/arm/mach-msm/idle-v7.S
@@ -180,6 +180,7 @@
 	mov	r2, #1
 	and	r1, r2, r1, ASR #30 /* Check if the cache is write back */
 	orr	r1, r0, r1
+	and	r1, r1, #1
 	cmp	r1, #1
 	bne	skip
 	bl	v7_flush_dcache_all
diff --git a/arch/arm/mach-msm/include/mach/msm_hdmi_audio_codec.h b/arch/arm/mach-msm/include/mach/msm_hdmi_audio_codec.h
index ff3da11..3973044 100644
--- a/arch/arm/mach-msm/include/mach/msm_hdmi_audio_codec.h
+++ b/arch/arm/mach-msm/include/mach/msm_hdmi_audio_codec.h
@@ -30,6 +30,7 @@
 		bool down_mix);
 	int (*get_audio_edid_blk) (struct platform_device *pdev,
 		struct msm_hdmi_audio_edid_blk *blk);
+	int (*hdmi_cable_status) (struct platform_device *pdev, u32 vote);
 };
 
 int msm_hdmi_register_audio_codec(struct platform_device *pdev,
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/acdb_commands.h b/arch/arm/mach-msm/include/mach/qdsp5/acdb_commands.h
deleted file mode 100644
index b24a3d9..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/acdb_commands.h
+++ /dev/null
@@ -1,303 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- *
- */
-#ifndef _MACH_QDSP5_V2_ACDB_COMMANDS_H
-#define _MACH_QDSP5_V2_ACDB_COMMANDS_H
-
-#define ACDB_VOICE_NETWORK_ID_DEFAULT		0x00010037
-#define ACDB_INITIALISING			0
-#define ACDB_READY				1
-
-
-/* 4KB */
-#define ACDB_PAGE_SIZE				0x1000
-
-#define ACDB_CDMA_NB		0x0108b153
-#define ACDB_CDMA_WB		0x0108b154
-#define ACDB_GSM_NB		0x0108b155
-#define ACDB_GSM_WB		0x0108b156
-#define ACDB_WCDMA_NB		0x0108b157
-#define ACDB_WCDMA_WB		0x0108b158
-
-
-/* ACDB commands */
-
-
-/* struct acdb_cmd_install_device */
-#define ACDB_INSTALL_DEVICE		0x0108d245
-
-/* struct acdb_cmd_install_device */
-#define ACDB_UNINSTALL_DEVICE		0x0108d246
-
-/* struct acdb_cmd_device */
-#define ACDB_GET_DEVICE			0x0108bb92
-
-/* struct acdb_cmd_device */
-#define ACDB_SET_DEVICE			0x0108bb93
-
-/* struct acdb_cmd_get_device_table */
-#define ACDB_GET_DEVICE_TABLE		0x0108bb97
-
-/* struct acdb_cmd_get_device_capabilities */
-#define ACDB_GET_DEVICE_CAPABILITIES	0x0108f5ca
-
-/* struct acdb_cmd_get_device_info */
-#define ACDB_GET_DEVICE_INFO		0x0108f5cb
-
-/*command to intitialize ACDB based on codec type*/
-#define ACDB_CMD_INITIALIZE_FOR_ADIE	0x00011283
-
-
-/* ACDB Error codes */
-
-#define ACDB_RES_SUCCESS		0
-#define ACDB_RES_FAILURE		-1
-#define ACDB_RES_BADPARM		-2
-#define ACDB_RES_BADSTATE		-3
-
-#define TGTVERS_MSM7x30_BRING_UP	0x00010064
-
-
-
-/* Algorithm Aspect IDs */
-
-#define IID_ENABLE_FLAG			0x0108b6b9
-
-
-#define IID_ENABLE_FLAG_SIZE					1
-#define IID_ECHO_CANCELLER_VERSION_SIZE				2
-#define IID_ECHO_CANCELLER_MODE_SIZE				2
-#define IID_ECHO_CANCELLER_NOISE_SUPPRESSOR_ENABLE_SIZE		1
-#define IID_ECHO_CANCELLER_PARAMETERS_SIZE			32
-#define IID_ECHO_CANCELLER_NEXTGEN_NB_PARAMETERS_SIZE		(38 * 2)
-#define IID_ECHO_CANCELLER_NEXTGEN_WB_PARAMETERS_SIZE		(38 * 2)
-#define IID_FLUENCE_PARAMETERS_SIZE				486
-#define IID_AFE_VOLUME_CONTROL_SIZE				6
-#define IID_GAIN_SIZE						2
-#define IID_VOICE_FIR_FILTER_SIZE				14
-#define IID_VOICE_IIR_FILTER_SIZE				114
-#define IID_RX_DBM_OFFSET_SIZE					2
-#define IID_AGC_SIZE						36
-#define IID_AVC_SIZE						80
-
-#define IID_AUDIO_IIR_COEFF_SIZE				100
-#define IID_MBADRC_PARAMETERS_SIZE				8
-#define IID_MBADRC_EXT_BUFF_SIZE				392
-#define IID_MBADRC_BAND_CONFIG_SIZE				100
-#define IID_QAFX_PARAMETERS_SIZE				2
-#define IID_QCONCERT_PARAMETERS_SIZE				2
-#define IID_AUDIO_AGC_PARAMETERS_SIZE				42
-#define IID_NS_PARAMETERS_SIZE					14
-
-#define IID_ECHO_CANCELLER_VERSION			0x00010042
-#define IID_ECHO_CANCELLER_MODE				0x00010043
-#define IID_ECHO_CANCELLER_NOISE_SUPPRESSOR_ENABLE	0x00010044
-#define IID_ECHO_CANCELLER_PARAMETERS			0x00010045
-#define IID_ECHO_CANCELLER_NEXTGEN_NB_PARAMETERS	0x00010046
-#define IID_ECHO_CANCELLER_NEXTGEN_WB_PARAMETERS	0x00010047
-#define IID_FLUENCE_PARAMETERS				0x00010048
-#define IID_AFE_VOLUME_CONTROL				0x00010049
-#define IID_GAIN					0x0001004A
-#define IID_VOICE_FIR_FILTER				0x0001004B
-#define IID_VOICE_IIR_FILTER				0x0001004C
-#define IID_AGC						0x0001004E
-#define IID_AVC						0x0001004F
-#define ABID_SIDETONE_GAIN				0x00010050
-#define ABID_TX_VOICE_GAIN				0x00010051
-#define ABID_TX_DTMF_GAIN				0x00010052
-#define ABID_CODEC_TX_GAIN				0x00010053
-#define ABID_HSSD					0x00010054
-#define ABID_TX_AGC					0x00010055
-#define ABID_TX_VOICE_FIR				0x00010056
-#define ABID_TX_VOICE_IIR				0x00010057
-#define ABID_ECHO_CANCELLER				0x00010058
-#define ABID_ECHO_CANCELLER_NB_LVHF			0x00010059
-#define ABID_ECHO_CANCELLER_WB_LVHF			0x0001005A
-#define ABID_FLUENCE					0x0001005B
-#define ABID_CODEC_RX_GAIN				0x0001005C
-#define ABID_RX_DBM_OFFSET				0x0001005D
-#define ABID_RX_AGC					0x0001005E
-#define ABID_AVC					0x0001005F
-#define ABID_RX_VOICE_FIR				0x00010060
-#define ABID_RX_VOICE_IIR				0x00010061
-#define ABID_AFE_VOL_CTRL				0x00010067
-
-
-/* AUDIO IDs */
-#define ABID_AUDIO_AGC_TX		0x00010068
-#define ABID_AUDIO_NS_TX		0x00010069
-#define ABID_VOICE_NS			0x0001006A
-#define ABID_AUDIO_IIR_TX		0x0001006B
-#define ABID_AUDIO_IIR_RX		0x0001006C
-#define ABID_AUDIO_MBADRC_RX		0x0001006E
-#define ABID_AUDIO_QAFX_RX		0x0001006F
-#define ABID_AUDIO_QCONCERT_RX		0x00010070
-#define ABID_AUDIO_STF_RX		0x00010071
-#define ABID_AUDIO_CALIBRATION_GAIN_RX  0x00011162
-#define ABID_AUDIO_CALIBRATION_GAIN_TX  0x00011149
-#define ABID_AUDIO_PBE_RX               0x00011197
-#define ABID_AUDIO_RMC_TX		0x00011226
-#define ABID_AUDIO_FLUENCE_TX		0x00011244
-
-
-#define IID_AUDIO_AGC_PARAMETERS	0x0001007E
-#define IID_NS_PARAMETERS		0x00010072
-#define IID_AUDIO_IIR_COEFF		0x00010073
-#define IID_MBADRC_EXT_BUFF		0x00010075
-#define IID_MBADRC_BAND_CONFIG		0x00010076
-#define IID_MBADRC_PARAMETERS		0x00010077
-#define IID_QAFX_PARAMETERS		0x00010079
-#define IID_QCONCERT_PARAMETERS		0x0001007A
-#define IID_STF_COEFF			0x0001007B
-#define IID_AUDIO_CALIBRATION_GAIN_RX   0x00011163
-#define IID_AUDIO_CALIBRATION_GAIN_TX   0x00011171
-#define IID_PBE_CONFIG_PARAMETERS       0x00011198
-#define IID_AUDIO_PBE_RX_ENABLE_FLAG    0x00011199
-#define IID_AUDIO_RMC_PARAM		0x00011227
-#define IID_AUDIO_FLUENCE_TX		0x00011245
-
-
-#define TOPID_RX_TOPOLOGY_1		0x00010062
-#define TOPID_TX_TOPOLOGY_1		0x00010063
-#define AFERID_INT_SINK			0x00010065
-#define AFERID_INT_SOURCE		0x00010066
-#define AFERID_NO_SINK			0x00000000
-#define AFERID_NULL_SINK		0x0108ea92
-
-
-struct acdb_cmd_install_device {
-	u32	command_id;
-	u32	device_id;
-	u32	topology_id;
-	u32	afe_routing_id;
-	u32	cad_routing_id;		/* see "Sample Rate Bit Mask" below */
-	u32	sample_rate_mask;
-
-	/* represents device direction: Tx, Rx (aux pga - loopback) */
-	u8	device_type;
-	u8	channel_config;		/* Mono or Stereo */
-	u32	adie_codec_path_id;
-};
-
-
-struct acdb_cmd_get_device_capabilities {
-	u32	command_id;
-	u32	total_bytes;	/* Length in bytes allocated for buffer */
-	u32	*phys_buf;	/* Physical Address of data */
-};
-
-
-struct acdb_cmd_get_device_info {
-	u32	command_id;
-	u32	device_id;
-	u32	total_bytes;	/* Length in bytes allocated for buffer */
-	u32	*phys_buf;	/* Physical Address of data */
-};
-
-struct acdb_cmd_device {
-	u32	command_id;
-	u32	device_id;
-	u32	network_id;
-	u32	sample_rate_id;		/* Actual sample rate value */
-	u32	interface_id;		/* See interface id's above */
-	u32	algorithm_block_id;	/* See enumerations above */
-	u32	total_bytes;		/* Length in bytes used by buffer */
-	u32	*phys_buf;		/* Physical Address of data */
-};
-
-struct acdb_cmd_get_device_table {
-	u32	command_id;
-	u32	device_id;
-	u32	network_id;
-	u32	sample_rate_id;		/* Actual sample rate value */
-	u32	total_bytes;		/* Length in bytes used by buffer */
-	u32	*phys_buf;		/* Physical Address of data */
-};
-
-struct acdb_result {
-	/* This field is populated in response to the */
-	/* ACDB_GET_DEVICE_CAPABILITIES command and indicates the total */
-	/* devices whose capabilities are copied to the physical memory. */
-	u32	total_devices;
-	u32	*buf;			/* Physical Address of data */
-	u32	used_bytes;		/* The size in bytes of the data */
-	u32	result;			/* See ACDB Error codes above */
-};
-
-struct acdb_device_capability {
-	u32	device_id;
-	u32	sample_rate_mask;	/* See "Sample Rate Bit Mask" below */
-};
-
-struct acdb_dev_info {
-	u32	cad_routing_id;
-	u32	sample_rate_mask;	/* See "Sample Rate Bit Mask" below */
-	u32	adsp_device_id;		/* QDSP6 device ID */
-	u32	device_type;		/* Tx, Rx  (aux pga - loopback) */
-	u32	channel_config;		/* Mono or Stereo */
-	s32	min_volume;		/* Min volume (mB) */
-	s32	max_volume;		/* Max volume (mB) */
-};
-
-/*structure is used to intialize ACDB software on modem
-based on adie type detected*/
-struct acdb_cmd_init_adie {
-	u32 command_id;
-	u32 adie_type;
-};
-
-#define ACDB_CURRENT_ADIE_MODE_UNKNOWN 0
-#define ACDB_CURRENT_ADIE_MODE_TIMPANI 1
-#define ACDB_CURRENT_ADIE_MODE_MARIMBA 2
-
-/* Sample Rate Bit Mask */
-
-/* AUX PGA devices will have a sample rate mask of 0xFFFFFFFF */
-/* 8kHz              0x00000001 */
-/* 11.025kHz         0x00000002 */
-/* 12kHz             0x00000004 */
-/* 16kHz             0x00000008 */
-/* 22.5kHz           0x00000010 */
-/* 24kHz             0x00000020 */
-/* 32kHz             0x00000040 */
-/* 44.1kHz           0x00000080 */
-/* 48kHz             0x00000100 */
-
-
-/* Device type enumeration */
-enum {
-	RX_DEVICE = 1,
-	TX_DEVICE,
-	AUXPGA_DEVICE,
-	DEVICE_TYPE_MAX
-};
-
-#ifdef CONFIG_DEBUG_FS
-/*These are ABID used for RTC*/
-#define ABID_AUDIO_RTC_MBADRC_RX 0x0001118A
-#define ABID_AUDIO_RTC_VOLUME_PAN_RX 0x0001118C
-#define ABID_AUDIO_RTC_SPA 0x0001118E
-#define ABID_AUDIO_RTC_EQUALIZER_PARAMETERS 0x0001119F
-
-/*These are IID used for RTC*/
-#define IID_AUDIO_RTC_MBADRC_PARAMETERS 0x0001118B
-#define IID_AUDIO_RTC_VOLUME_PAN_PARAMETERS 0x0001118D
-#define IID_AUDIO_RTC_SPA_PARAMETERS 0x0001118F
-#define IID_AUDIO_RTC_EQUALIZER_PARAMETERS 0x0001119E
-#define IID_AUDIO_RTC_AGC_PARAMETERS 0x000111A7
-#define IID_AUDIO_RTC_TX_IIR_COEFF 0x000111A8
-
-#endif
-
-
-#endif
-
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/audio_acdb_def.h b/arch/arm/mach-msm/include/mach/qdsp5/audio_acdb_def.h
deleted file mode 100644
index 5fc87e0..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/audio_acdb_def.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Copyright (c) 2012-2013, The Linux Foundation. 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.
- *
- */
-#ifndef _MACH_QDSP5_V2_AUDIO_ACDB_DEF_H
-#define _MACH_QDSP5_V2_AUDIO_ACDB_DEF_H
-
-/* Define ACDB device ID */
-#define ACDB_ID_HANDSET_SPKR				1
-#define ACDB_ID_HANDSET_MIC				2
-#define ACDB_ID_HEADSET_MIC				3
-#define ACDB_ID_HEADSET_SPKR_MONO			4
-#define ACDB_ID_HEADSET_SPKR_STEREO			5
-#define ACDB_ID_SPKR_PHONE_MIC				6
-#define ACDB_ID_SPKR_PHONE_MONO				7
-#define ACDB_ID_SPKR_PHONE_STEREO			8
-#define ACDB_ID_BT_SCO_MIC				9
-#define ACDB_ID_BT_SCO_SPKR				0x0A
-#define ACDB_ID_BT_A2DP_SPKR				0x0B
-#define ACDB_ID_BT_A2DP_TX				0x10
-#define ACDB_ID_TTY_HEADSET_MIC				0x0C
-#define ACDB_ID_TTY_HEADSET_SPKR			0x0D
-#define ACDB_ID_HEADSET_MONO_PLUS_SPKR_MONO_RX		0x11
-#define ACDB_ID_HEADSET_STEREO_PLUS_SPKR_STEREO_RX	0x14
-#define ACDB_ID_FM_TX_LOOPBACK				0x17
-#define ACDB_ID_FM_TX					0x18
-#define ACDB_ID_LP_FM_SPKR_PHONE_STEREO_RX		0x19
-#define ACDB_ID_LP_FM_HEADSET_SPKR_STEREO_RX		0x1A
-#define ACDB_ID_I2S_RX					0x20
-#define ACDB_ID_SPKR_PHONE_MIC_BROADSIDE		0x2B
-#define ACDB_ID_HANDSET_MIC_BROADSIDE			0x2C
-#define ACDB_ID_SPKR_PHONE_MIC_ENDFIRE			0x2D
-#define ACDB_ID_HANDSET_MIC_ENDFIRE			0x2E
-#define ACDB_ID_I2S_TX					0x30
-#define ACDB_ID_HDMI					0x40
-#define ACDB_ID_FM_RX					0x4F
-/*Replace the max device ID,if any new device is added Specific to RTC only*/
-#define ACDB_ID_MAX                                 ACDB_ID_FM_RX
-
-/* ID used for virtual devices */
-#define PSEUDO_ACDB_ID					0xFFFF
-
-int is_acdb_enabled(void);
-#endif /* _MACH_QDSP5_V2_AUDIO_ACDB_DEF_H */
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/audio_acdbi.h b/arch/arm/mach-msm/include/mach/qdsp5/audio_acdbi.h
deleted file mode 100644
index 682e4d9..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/audio_acdbi.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/* Copyright (c) 2012 The Linux Foundation. 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.
- *
- */
-#ifndef _MACH_QDSP5_V2_AUDIO_ACDBI_H
-#define _MACH_QDSP5_V2_AUDIO_ACDBI_H
-
-#define DBOR_SIGNATURE	0x524F4244
-
-void acdb_rtc_set_err(u32 err_code);
-
-
-struct header {
-	u32 dbor_signature;
-	u32 abid;
-	u32 iid;
-	u32 data_len;
-};
-
-enum {
-	ACDB_AGC_BLOCK			= 197,
-	ACDB_IIR_BLOCK			= 245,
-	ACDB_MBADRC_BLOCK		= 343
-};
-
-/* Structure to query for acdb parameter */
-struct acdb_get_block {
-	u32	acdb_id;
-	u32	sample_rate_id;		/* Actual sample rate value */
-	u32	interface_id;		/* Interface id's */
-	u32	algorithm_block_id;	/* Algorithm block id */
-	u32	total_bytes;		/* Length in bytes used by buffer for
-						configuration */
-	u32	*buf_ptr;		/* Address for storing configuration
-						data */
-};
-
-struct acdb_agc_block {
-	u16	enable_status;
-	u16	comp_rlink_static_gain;
-	u16	comp_rlink_aig_flag;
-	u16	exp_rlink_threshold;
-	u16	exp_rlink_slope;
-	u16	comp_rlink_threshold;
-	u16	comp_rlink_slope;
-	u16	comp_rlink_aig_attack_k;
-	u16	comp_rlink_aig_leak_down;
-	u16	comp_rlink_aig_leak_up;
-	u16	comp_rlink_aig_max;
-	u16	comp_rlink_aig_min;
-	u16	comp_rlink_aig_release_k;
-	u16	comp_rlink_aig_sm_leak_rate_fast;
-	u16	comp_rlink_aig_sm_leak_rate_slow;
-	u16	comp_rlink_attack_k_msw;
-	u16	comp_rlink_attack_k_lsw;
-	u16	comp_rlink_delay;
-	u16	comp_rlink_release_k_msw;
-	u16	comp_rlink_release_k_lsw;
-	u16	comp_rlink_rms_trav;
-};
-
-
-struct iir_coeff_type {
-	u16	b0_lo;
-	u16	b0_hi;
-	u16	b1_lo;
-	u16	b1_hi;
-	u16	b2_lo;
-	u16	b2_hi;
-};
-
-struct iir_coeff_stage_a {
-	u16	a1_lo;
-	u16	a1_hi;
-	u16	a2_lo;
-	u16	a2_hi;
-};
-
-struct acdb_iir_block {
-	u16			enable_flag;
-	u16			stage_count;
-	struct iir_coeff_type	stages[4];
-	struct iir_coeff_stage_a stages_a[4];
-	u16			shift_factor[4];
-	u16			pan[4];
-};
-
-struct mbadrc_band_config_type {
-	u16	mbadrc_sub_band_enable;
-	u16	mbadrc_sub_mute;
-	u16	mbadrc_comp_rms_tav;
-	u16	mbadrc_comp_threshold;
-	u16	mbadrc_comp_slop;
-	u16	mbadrc_comp_attack_msw;
-	u16	mbadrc_comp_attack_lsw;
-	u16	mbadrc_comp_release_msw;
-	u16	mbadrc_comp_release_lsw;
-	u16	mbadrc_make_up_gain;
-};
-
-struct mbadrc_parameter {
-	u16				mbadrc_enable;
-	u16				mbadrc_num_bands;
-	u16				mbadrc_down_sample_level;
-	u16				mbadrc_delay;
-};
-
-struct acdb_mbadrc_block {
-	u16				ext_buf[196];
-	struct mbadrc_band_config_type	band_config[5];
-	struct mbadrc_parameter		parameters;
-};
-
-struct acdb_ns_tx_block {
-	unsigned short	ec_mode_new;
-	unsigned short	dens_gamma_n;
-	unsigned short	dens_nfe_block_size;
-	unsigned short	dens_limit_ns;
-	unsigned short	dens_limit_ns_d;
-	unsigned short	wb_gamma_e;
-	unsigned short	wb_gamma_n;
-};
-
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audplaycmdi.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audplaycmdi.h
deleted file mode 100644
index 67ee549..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audplaycmdi.h
+++ /dev/null
@@ -1,129 +0,0 @@
-#ifndef QDSP5AUDPLAYCMDI_H
-#define QDSP5AUDPLAYCMDI_H
-
-/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
-
-       Q D S P 5  A U D I O   P L A Y  T A S K   C O M M A N D S
-
-GENERAL DESCRIPTION
-  Command Interface for AUDPLAYTASK on QDSP5
-
-REFERENCES
-  None
-
-EXTERNALIZED FUNCTIONS
-
-  audplay_cmd_dec_data_avail
-    Send buffer to AUDPLAY task
-	
-  
-Copyright (c) 1992-2009, The Linux Foundation. All rights reserved.
-
-This software is licensed under the terms of the GNU General Public
-License version 2, as published by the Free Software Foundation, and
-may be copied, distributed, and modified under those terms.
- 
-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.
-
-*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
-/*===========================================================================
-
-                      EDIT HISTORY FOR FILE
-
-This section contains comments describing changes made to this file.
-Notice that changes are listed in reverse chronological order.
-
-$Header: //source/qcom/qct/multimedia2/Audio/drivers/QDSP5Driver/QDSP5Interface/main/latest/qdsp5audplaycmdi.h#2 $
-  
-===========================================================================*/
-
-#define AUDPLAY_CMD_BITSTREAM_DATA_AVAIL		0x0000
-#define AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_LEN	\
-	sizeof(audplay_cmd_bitstream_data_avail)
-
-/* Type specification of dec_data_avail message sent to AUDPLAYTASK
-*/
-typedef struct {
-  /*command ID*/
-  unsigned int cmd_id;        
-
-  /* Decoder ID for which message is being sent */
-  unsigned int decoder_id;        
-
-  /* Start address of data in ARM global memory */
-  unsigned int buf_ptr;    
-
-  /* Number of 16-bit words of bit-stream data contiguously available at the
-   * above-mentioned address 
-   */
-  unsigned int buf_size;
-          
-  /* Partition number used by audPlayTask to communicate with DSP's RTOS
-   * kernel 
-  */
-  unsigned int partition_number;    
-
-} __attribute__((packed)) audplay_cmd_bitstream_data_avail;
-
-#define AUDPLAY_CMD_HPCM_BUF_CFG 0x0003
-#define AUDPLAY_CMD_HPCM_BUF_CFG_LEN \
-  sizeof(struct audplay_cmd_hpcm_buf_cfg)
-
-struct audplay_cmd_hpcm_buf_cfg {
-  unsigned int cmd_id;
-  unsigned int hostpcm_config;
-  unsigned int feedback_frequency;
-  unsigned int byte_swap;
-  unsigned int max_buffers;
-  unsigned int partition_number;
-} __attribute__((packed));
-
-#define AUDPLAY_CMD_BUFFER_REFRESH 0x0004
-#define AUDPLAY_CMD_BUFFER_REFRESH_LEN \
-  sizeof(struct audplay_cmd_buffer_update)
-
-struct audplay_cmd_buffer_refresh {
-  unsigned int cmd_id;
-  unsigned int num_buffers;
-  unsigned int buf_read_count;
-  unsigned int buf0_address;
-  unsigned int buf0_length;
-  unsigned int buf1_address;
-  unsigned int buf1_length;
-} __attribute__((packed));
-
-#define AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2            0x0005
-#define AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2_LEN    \
-	sizeof(audplay_cmd_bitstream_data_avail_nt2)
-
-/* Type specification of dec_data_avail message sent to AUDPLAYTASK
- * for NT2 */
-struct audplay_cmd_bitstream_data_avail_nt2 {
-  /*command ID*/
-  unsigned int cmd_id;
-
-  /* Decoder ID for which message is being sent */
-  unsigned int decoder_id;
-
-  /* Start address of data in ARM global memory */
-  unsigned int buf_ptr;
-
-  /* Number of 16-bit words of bit-stream data contiguously available at the
-   * above-mentioned address
-   */
-  unsigned int buf_size;
-
-  /* Partition number used by audPlayTask to communicate with DSP's RTOS
-   * kernel
-   */
-  unsigned int partition_number;
-
- /* bitstream write pointer */
-  unsigned int dspBitstreamWritePtr;
-
-} __attribute__((packed));
-
-#endif /* QDSP5AUDPLAYCMD_H */
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audplaymsg.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audplaymsg.h
deleted file mode 100644
index e79554a..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audplaymsg.h
+++ /dev/null
@@ -1,84 +0,0 @@
-#ifndef QDSP5AUDPLAYMSG_H
-#define QDSP5AUDPLAYMSG_H
-
-/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
-
-       Q D S P 5  A U D I O   P L A Y  T A S K   M S G
-
-GENERAL DESCRIPTION
-  Message sent by AUDPLAY task
-
-REFERENCES
-  None
-
-  
-Copyright (c) 1992-2009, The Linux Foundation. All rights reserved.
-
-This software is licensed under the terms of the GNU General Public
-License version 2, as published by the Free Software Foundation, and
-may be copied, distributed, and modified under those terms.
- 
-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.
-
-*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
-/*===========================================================================
-
-                      EDIT HISTORY FOR FILE
-
-This section contains comments describing changes made to this file.
-Notice that changes are listed in reverse chronological order.
-  
-$Header: //source/qcom/qct/multimedia2/Audio/drivers/QDSP5Driver/QDSP5Interface/main/latest/qdsp5audplaymsg.h#3 $
-
-===========================================================================*/
-#define AUDPLAY_MSG_DEC_NEEDS_DATA		0x0001
-#define AUDPLAY_MSG_DEC_NEEDS_DATA_MSG_LEN	\
-	sizeof(audplay_msg_dec_needs_data)
-
-typedef struct{
-   /* reserved*/
-  unsigned int dec_id;           
-
-  /*The read pointer offset of external memory till which bitstream 
-    has been dmeÂ’d in*/
-  unsigned int adecDataReadPtrOffset;  
-
-  /*	The buffer size of external memory. */
-  unsigned int adecDataBufSize;
-  
-  unsigned int 	bitstream_free_len;
-  unsigned int	bitstream_write_ptr;
-  unsigned int	bitstarem_buf_start;
-  unsigned int	bitstream_buf_len;
-} __attribute__((packed)) audplay_msg_dec_needs_data;
-
-#define AUDPLAY_UP_STREAM_INFO 0x0003
-#define AUDPLAY_UP_STREAM_INFO_LEN \
-  sizeof(struct audplay_msg_stream_info)
-
-struct audplay_msg_stream_info {
-  unsigned int decoder_id;
-  unsigned int channel_info;
-  unsigned int sample_freq;
-  unsigned int bitstream_info;
-  unsigned int bit_rate;
-} __attribute__((packed));
-
-#define AUDPLAY_MSG_BUFFER_UPDATE 0x0004
-#define AUDPLAY_MSG_BUFFER_UPDATE_LEN \
-  sizeof(struct audplay_msg_buffer_update)
-
-struct audplay_msg_buffer_update {
-  unsigned int buffer_write_count;
-  unsigned int num_of_buffer;
-  unsigned int buf0_address;
-  unsigned int buf0_length;
-  unsigned int buf1_address;
-  unsigned int buf1_length;
-} __attribute__((packed));
-
-#define ADSP_MESSAGE_ID 0xFFFF
-#endif /* QDSP5AUDPLAYMSG_H */
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audpp.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audpp.h
deleted file mode 100644
index 5fa36d6..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audpp.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*arch/arm/mach-msm/qdsp5audpp.h
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (c) 2012, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
-*/
-
-#ifndef _MACH_QDSP5_AUDPP_H
-#define _MACH_QDSP5_AUDPP_H
-
-#include <mach/qdsp5/qdsp5audppcmdi.h>
-
-typedef void (*audpp_event_func)(void *private, unsigned id, uint16_t *msg);
-
-/* worst case delay of 1sec for response */
-#define MSM_AUD_DECODER_WAIT_MS 1000
-#define MSM_AUD_MODE_TUNNEL  0x00000100
-#define MSM_AUD_MODE_NONTUNNEL  0x00000200
-#define MSM_AUD_DECODER_MASK  0x0000FFFF
-#define MSM_AUD_OP_MASK  0xFFFF0000
-
-/*Playback mode*/
-#define NON_TUNNEL_MODE_PLAYBACK 1
-#define TUNNEL_MODE_PLAYBACK 0
-
-enum msm_aud_decoder_state {
-	MSM_AUD_DECODER_STATE_NONE = 0,
-	MSM_AUD_DECODER_STATE_FAILURE = 1,
-	MSM_AUD_DECODER_STATE_SUCCESS = 2,
-	MSM_AUD_DECODER_STATE_CLOSE = 3,
-};
-
-int audpp_adec_alloc(unsigned dec_attrb, const char **module_name,
-			unsigned *queueid);
-void audpp_adec_free(int decid);
-
-struct audpp_event_callback {
-	audpp_event_func fn;
-	void *private;
-};
-
-int audpp_register_event_callback(struct audpp_event_callback *eh);
-int audpp_unregister_event_callback(struct audpp_event_callback *eh);
-int is_audpp_enable(void);
-
-int audpp_enable(int id, audpp_event_func func, void *private);
-void audpp_disable(int id, void *private);
-
-int audpp_send_queue1(void *cmd, unsigned len);
-int audpp_send_queue2(void *cmd, unsigned len);
-int audpp_send_queue3(void *cmd, unsigned len);
-
-int audpp_set_volume_and_pan(unsigned id, unsigned volume, int pan);
-int audpp_pause(unsigned id, int pause);
-int audpp_flush(unsigned id);
-void audpp_avsync(int id, unsigned rate);
-unsigned audpp_avsync_sample_count(int id);
-unsigned audpp_avsync_byte_count(int id);
-int audpp_dsp_set_mbadrc(unsigned id, unsigned enable,
-			audpp_cmd_cfg_object_params_mbadrc *mbadrc);
-int audpp_dsp_set_eq(unsigned id, unsigned enable,
-			audpp_cmd_cfg_object_params_eqalizer *eq);
-int audpp_dsp_set_rx_iir(unsigned id, unsigned enable,
-				audpp_cmd_cfg_object_params_pcm *iir);
-
-int audpp_dsp_set_rx_srs_trumedia_g
-	(struct audpp_cmd_cfg_object_params_srstm_g *srstm);
-int audpp_dsp_set_rx_srs_trumedia_w
-	(struct audpp_cmd_cfg_object_params_srstm_w *srstm);
-int audpp_dsp_set_rx_srs_trumedia_c
-	(struct audpp_cmd_cfg_object_params_srstm_c *srstm);
-int audpp_dsp_set_rx_srs_trumedia_h
-	(struct audpp_cmd_cfg_object_params_srstm_h *srstm);
-int audpp_dsp_set_rx_srs_trumedia_p
-	(struct audpp_cmd_cfg_object_params_srstm_p *srstm);
-int audpp_dsp_set_rx_srs_trumedia_l
-	(struct audpp_cmd_cfg_object_params_srstm_l *srstm);
-
-int audpp_dsp_set_vol_pan(unsigned id,
-				audpp_cmd_cfg_object_params_volume *vol_pan);
-int audpp_dsp_set_qconcert_plus(unsigned id, unsigned enable,
-			audpp_cmd_cfg_object_params_qconcert *qconcert_plus);
-
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audppcmdi.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audppcmdi.h
deleted file mode 100644
index 93b77f4..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audppcmdi.h
+++ /dev/null
@@ -1,1079 +0,0 @@
-#ifndef QDSP5AUDPPCMDI_H
-#define QDSP5AUDPPCMDI_H
-
-/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
-
-    A U D I O   P O S T   P R O C E S S I N G  I N T E R N A L  C O M M A N D S
-
-GENERAL DESCRIPTION
-  This file contains defintions of format blocks of commands 
-  that are accepted by AUDPP Task
-
-REFERENCES
-  None
-
-EXTERNALIZED FUNCTIONS
-  None
-
-Copyright(c) 1992-2009, 2012-2013 The Linux Foundation. All rights reserved.
-
-This software is licensed under the terms of the GNU General Public
-License version 2, as published by the Free Software Foundation, and
-may be copied, distributed, and modified under those terms.
- 
-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.
-
-*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
-/*===========================================================================
-
-                      EDIT HISTORY FOR FILE
-
-This section contains comments describing changes made to this file.
-Notice that changes are listed in reverse chronological order.
-   
-$Header: //source/qcom/qct/multimedia2/Audio/drivers/QDSP5Driver/QDSP5Interface/main/latest/qdsp5audppcmdi.h#2 $   
-  
-===========================================================================*/
-
-/*
- * ARM to AUDPPTASK Commands 
- *
- * ARM uses three command queues to communicate with AUDPPTASK
- * 1)uPAudPPCmd1Queue : Used for more frequent and shorter length commands
- * 	Location : MEMA
- * 	Buffer Size : 6 words
- * 	No of buffers in a queue : 20 for gaming audio and 5 for other images
- * 2)uPAudPPCmd2Queue : Used for commands which are not much lengthier
- * 	Location : MEMA
- * 	Buffer Size : 23
- * 	No of buffers in a queue : 2
- * 3)uPAudOOCmd3Queue : Used for lengthier and more frequent commands
- * 	Location : MEMA
- * 	Buffer Size : 145
- * 	No of buffers in a queue : 3
- */
-
-/*
- * Commands Related to uPAudPPCmd1Queue
- */
-
-/*
- * Command Structure to enable or disable the active decoders 
- */
-
-#define AUDPP_CMD_CFG_DEC_TYPE 		0x0001
-#define AUDPP_CMD_CFG_DEC_TYPE_LEN 	sizeof(audpp_cmd_cfg_dec_type)
-
-/* Enable the decoder */
-#define AUDPP_CMD_DEC_TYPE_M           	0x000F
-
-#define AUDPP_CMD_ENA_DEC_V         	0x4000
-#define AUDPP_CMD_DIS_DEC_V        	0x0000
-#define AUDPP_CMD_DEC_STATE_M          	0x4000
-#define AUDPP_CMD_LPA_MODE		0x2000
-
-#define AUDPP_CMD_UPDATDE_CFG_DEC	0x8000
-#define AUDPP_CMD_DONT_UPDATE_CFG_DEC	0x0000
-
-
-/* Type specification of cmd_cfg_dec */
- 
-typedef struct {
-  unsigned short cmd_id;
-  unsigned short dec0_cfg;
-  unsigned short dec1_cfg;
-  unsigned short dec2_cfg;
-  unsigned short dec3_cfg;
-  unsigned short dec4_cfg;
-} __attribute__((packed)) audpp_cmd_cfg_dec_type;
-
-/*
- * Command Structure to Pause , Resume and flushes the selected audio decoders
- */
-
-#define AUDPP_CMD_DEC_CTRL		0x0002
-#define AUDPP_CMD_DEC_CTRL_LEN		sizeof(audpp_cmd_dec_ctrl)
-
-/* Decoder control commands for pause, resume and flush */
-#define AUDPP_CMD_FLUSH_V         		0x2000
-
-#define AUDPP_CMD_PAUSE_V		        0x4000
-#define AUDPP_CMD_RESUME_V		        0x0000
-
-#define AUDPP_CMD_UPDATE_V		        0x8000
-#define AUDPP_CMD_IGNORE_V		        0x0000
-
-
-/* Type Spec for decoder control command*/
-
-typedef struct {
-  unsigned short cmd_id;
-  unsigned short dec0_ctrl;
-  unsigned short dec1_ctrl;
-  unsigned short dec2_ctrl;
-  unsigned short dec3_ctrl;
-  unsigned short dec4_ctrl;
-} __attribute__((packed)) audpp_cmd_dec_ctrl;
-
-/*
- * Command Structure to Configure the AVSync FeedBack Mechanism
- */
-
-#define AUDPP_CMD_AVSYNC	0x0003
-#define AUDPP_CMD_AVSYNC_LEN	sizeof(audpp_cmd_avsync)
-
-typedef struct {
-	unsigned short cmd_id;
-	unsigned short object_number;
-	unsigned short interrupt_interval_lsw;
-	unsigned short interrupt_interval_msw;
-} __attribute__((packed)) audpp_cmd_avsync;
-
-/*
- * Command Structure to enable or disable(sleep) the   AUDPPTASK 
- */
-
-#define AUDPP_CMD_CFG	0x0004
-#define AUDPP_CMD_CFG_LEN	sizeof(audpp_cmd_cfg)
-
-#define AUDPP_CMD_CFG_SLEEP   				0x0000
-#define AUDPP_CMD_CFG_ENABLE  				0xFFFF
-
-typedef struct {
-  unsigned short cmd_id;
-  unsigned short cfg;
-} __attribute__((packed)) audpp_cmd_cfg;
-
-/*
- * Command Structure to Inject or drop the specified no of samples
- */
-
-#define AUDPP_CMD_ADJUST_SAMP		0x0005
-#define AUDPP_CMD_ADJUST_SAMP_LEN	sizeof(audpp_cmd_adjust_samp)
-
-#define AUDPP_CMD_SAMP_DROP		-1
-#define AUDPP_CMD_SAMP_INSERT		0x0001
-
-#define AUDPP_CMD_NUM_SAMPLES		0x0001
-
-typedef struct {
-	unsigned short cmd_id;
-	unsigned short object_no;
-	signed short sample_insert_or_drop;
-	unsigned short num_samples;
-} __attribute__((packed)) audpp_cmd_adjust_samp;
-
-/*
- * Command Structure to Configure AVSync Feedback Mechanism
- */
-
-#define AUDPP_CMD_AVSYNC_CMD_2		0x0006
-#define AUDPP_CMD_AVSYNC_CMD_2_LEN	sizeof(audpp_cmd_avsync_cmd_2)
-
-typedef struct {
-	unsigned short cmd_id;
-	unsigned short object_number;
-	unsigned short interrupt_interval_lsw;
-	unsigned short interrupt_interval_msw;
-	unsigned short sample_counter_dlsw;
-	unsigned short sample_counter_dmsw;
-	unsigned short sample_counter_msw;
-	unsigned short byte_counter_dlsw;
-	unsigned short byte_counter_dmsw;
-	unsigned short byte_counter_msw;
-} __attribute__((packed)) audpp_cmd_avsync_cmd_2;
-
-/*
- * Command Structure to Configure AVSync Feedback Mechanism
- */
-
-#define AUDPP_CMD_AVSYNC_CMD_3		0x0007
-#define AUDPP_CMD_AVSYNC_CMD_3_LEN	sizeof(audpp_cmd_avsync_cmd_3)
-
-typedef struct {
-	unsigned short cmd_id;
-	unsigned short object_number;
-	unsigned short interrupt_interval_lsw;
-	unsigned short interrupt_interval_msw;
-	unsigned short sample_counter_dlsw;
-	unsigned short sample_counter_dmsw;
-	unsigned short sample_counter_msw;
-	unsigned short byte_counter_dlsw;
-	unsigned short byte_counter_dmsw;
-	unsigned short byte_counter_msw;
-} __attribute__((packed)) audpp_cmd_avsync_cmd_3;
-
-#define AUDPP_CMD_ROUTING_MODE      0x0008
-#define AUDPP_CMD_ROUTING_MODE_LEN  \
-sizeof(struct audpp_cmd_routing_mode)
-
-struct audpp_cmd_routing_mode {
-  unsigned short cmd_id;
-  unsigned short object_number;
-  unsigned short routing_mode;
-} __attribute__((packed));
-
-/*
- * Commands Related to uPAudPPCmd2Queue
- */
-
-/*
- * Command Structure to configure Per decoder Parameters (Common)
- */
-
-#define AUDPP_CMD_CFG_ADEC_PARAMS 		0x0000
-#define AUDPP_CMD_CFG_ADEC_PARAMS_COMMON_LEN	\
-	sizeof(audpp_cmd_cfg_adec_params_common)
-
-#define AUDPP_CMD_STATUS_MSG_FLAG_ENA_FCM	0x4000
-#define AUDPP_CMD_STATUS_MSG_FLAG_DIS_FCM	0x0000
-
-#define AUDPP_CMD_STATUS_MSG_FLAG_ENA_DCM	0x8000
-#define AUDPP_CMD_STATUS_MSG_FLAG_DIS_DCM	0x0000
-
-/* Sampling frequency*/
-#define  AUDPP_CMD_SAMP_RATE_96000 	0x0000
-#define  AUDPP_CMD_SAMP_RATE_88200 	0x0001
-#define  AUDPP_CMD_SAMP_RATE_64000 	0x0002
-#define  AUDPP_CMD_SAMP_RATE_48000 	0x0003
-#define  AUDPP_CMD_SAMP_RATE_44100 	0x0004
-#define  AUDPP_CMD_SAMP_RATE_32000 	0x0005
-#define  AUDPP_CMD_SAMP_RATE_24000 	0x0006
-#define  AUDPP_CMD_SAMP_RATE_22050 	0x0007
-#define  AUDPP_CMD_SAMP_RATE_16000 	0x0008
-#define  AUDPP_CMD_SAMP_RATE_12000 	0x0009
-#define  AUDPP_CMD_SAMP_RATE_11025 	0x000A
-#define  AUDPP_CMD_SAMP_RATE_8000  	0x000B
-
-
-/* 
- * Type specification of cmd_adec_cfg sent to all decoder
- */
-
-typedef struct {
-  unsigned short cmd_id;
-  unsigned short  length;
-  unsigned short  dec_id;
-  unsigned short  status_msg_flag;
-  unsigned short  decoder_frame_counter_msg_period;
-  unsigned short  input_sampling_frequency;
-} __attribute__((packed)) audpp_cmd_cfg_adec_params_common;
-
-/*
- * Command Structure to configure Per decoder Parameters (Wav)
- */
-
-#define AUDPP_CMD_CFG_ADEC_PARAMS_WAV_LEN	\
-	sizeof(audpp_cmd_cfg_adec_params_wav)
-
-
-#define	AUDPP_CMD_WAV_STEREO_CFG_MONO	0x0001
-#define AUDPP_CMD_WAV_STEREO_CFG_STEREO	0x0002
-
-#define AUDPP_CMD_WAV_PCM_WIDTH_8	0x0000
-#define AUDPP_CMD_WAV_PCM_WIDTH_16	0x0001
-#define AUDPP_CMD_WAV_PCM_WIDTH_24	0x0002
-
-typedef struct {
-	audpp_cmd_cfg_adec_params_common		common;
-	unsigned short					stereo_cfg;
-	unsigned short					pcm_width;
-	unsigned short 					sign;
-} __attribute__((packed)) audpp_cmd_cfg_adec_params_wav;
-
-/*
- * Command Structure to configure Per decoder Parameters (ADPCM)
- */
-
-#define AUDPP_CMD_CFG_ADEC_PARAMS_ADPCM_LEN	\
-	sizeof(audpp_cmd_cfg_adec_params_adpcm)
-
-
-#define	AUDPP_CMD_ADPCM_STEREO_CFG_MONO		0x0001
-#define AUDPP_CMD_ADPCM_STEREO_CFG_STEREO	0x0002
-
-typedef struct {
-	audpp_cmd_cfg_adec_params_common		common;
-	unsigned short					stereo_cfg;
-	unsigned short 					block_size;
-} __attribute__((packed)) audpp_cmd_cfg_adec_params_adpcm;
-
-/*
- * Command Structure to configure Per decoder Parameters (WMA)
- */
-
-#define AUDPP_CMD_CFG_ADEC_PARAMS_WMA_LEN	\
-	sizeof(struct audpp_cmd_cfg_adec_params_wma)
-
-struct audpp_cmd_cfg_adec_params_wma {
-	audpp_cmd_cfg_adec_params_common    common;
-	unsigned short 	armdatareqthr;
-	unsigned short 	channelsdecoded;
-	unsigned short 	wmabytespersec;
-	unsigned short	wmasamplingfreq;
-	unsigned short	wmaencoderopts;
-} __attribute__((packed));
-
-/*
- * Command Structure to configure Per decoder Parameters (WMAPRO)
- */
-
-#define AUDPP_CMD_CFG_ADEC_PARAMS_WMAPRO_LEN	\
-	sizeof(struct audpp_cmd_cfg_adec_params_wmapro)
-
-struct audpp_cmd_cfg_adec_params_wmapro {
-	audpp_cmd_cfg_adec_params_common    common;
-	unsigned short 	armdatareqthr;
-	uint8_t         validbitspersample;
-	uint8_t         numchannels;
-	unsigned short  formattag;
-	unsigned short  samplingrate;
-	unsigned short  avgbytespersecond;
-	unsigned short  asfpacketlength;
-	unsigned short 	channelmask;
-	unsigned short 	encodeopt;
-	unsigned short	advancedencodeopt;
-	uint32_t	advancedencodeopt2;
-} __attribute__((packed));
-
-/*
- * Command Structure to configure Per decoder Parameters (MP3)
- */
-
-#define AUDPP_CMD_CFG_ADEC_PARAMS_MP3_LEN	\
-	sizeof(audpp_cmd_cfg_adec_params_mp3)
-
-typedef struct {
-   audpp_cmd_cfg_adec_params_common    common;
-} __attribute__((packed)) audpp_cmd_cfg_adec_params_mp3;
-
-
-/*
- * Command Structure to configure Per decoder Parameters (AAC)
- */
-
-#define AUDPP_CMD_CFG_ADEC_PARAMS_AAC_LEN	\
-	sizeof(audpp_cmd_cfg_adec_params_aac)
-
-
-#define AUDPP_CMD_AAC_FORMAT_ADTS		-1
-#define	AUDPP_CMD_AAC_FORMAT_RAW		0x0000
-#define	AUDPP_CMD_AAC_FORMAT_PSUEDO_RAW		0x0001
-#define	AUDPP_CMD_AAC_FORMAT_LOAS		0x0002
-
-#define AUDPP_CMD_AAC_AUDIO_OBJECT_LC		0x0002
-#define AUDPP_CMD_AAC_AUDIO_OBJECT_LTP		0x0004
-#define AUDPP_CMD_AAC_AUDIO_OBJECT_ERLC	0x0011
-
-#define AUDPP_CMD_AAC_SBR_ON_FLAG_ON		0x0001
-#define AUDPP_CMD_AAC_SBR_ON_FLAG_OFF		0x0000
-
-#define AUDPP_CMD_AAC_SBR_PS_ON_FLAG_ON		0x0001
-#define AUDPP_CMD_AAC_SBR_PS_ON_FLAG_OFF	0x0000
-
-typedef struct {
-  audpp_cmd_cfg_adec_params_common	common;
-  signed short				format;
-  unsigned short			audio_object;
-  unsigned short			ep_config;
-  unsigned short                        aac_section_data_resilience_flag;
-  unsigned short                        aac_scalefactor_data_resilience_flag;
-  unsigned short                        aac_spectral_data_resilience_flag;
-  unsigned short                        sbr_on_flag;
-  unsigned short                        sbr_ps_on_flag;
-  unsigned short                        channel_configuration;
-} __attribute__((packed)) audpp_cmd_cfg_adec_params_aac;
-
-/*
- * Command Structure to configure Per decoder Parameters (V13K)
- */
-
-#define AUDPP_CMD_CFG_ADEC_PARAMS_V13K_LEN	\
-	sizeof(struct audpp_cmd_cfg_adec_params_v13k)
-
-
-#define AUDPP_CMD_STEREO_CFG_MONO		0x0001
-#define AUDPP_CMD_STEREO_CFG_STEREO		0x0002
-
-struct audpp_cmd_cfg_adec_params_v13k {
-   audpp_cmd_cfg_adec_params_common    	common;
-   unsigned short			stereo_cfg;
-} __attribute__((packed));
-
-#define AUDPP_CMD_CFG_ADEC_PARAMS_EVRC_LEN \
-	sizeof(struct audpp_cmd_cfg_adec_params_evrc)
-
-struct audpp_cmd_cfg_adec_params_evrc {
-	audpp_cmd_cfg_adec_params_common common;
-	unsigned short stereo_cfg;
-} __attribute__ ((packed));
-
-/*
- * Command Structure to configure Per decoder Parameters (AMRWB)
- */
-#define ADEC_PARAMS_AC3_INDEX 14
-
-struct audpp_cmd_cfg_adec_params_amrwb {
-	   audpp_cmd_cfg_adec_params_common     common;
-	      unsigned short                       stereo_cfg;
-} __attribute__((packed)) ;
-
-#define AUDPP_CMD_CFG_ADEC_PARAMS_AMRWB_LEN \
-	sizeof(struct audpp_cmd_cfg_adec_params_amrwb)
-
-/*
- * Command Structure to configure Per decoder Parameters (AC3)
- */
-
-struct audpp_cmd_cfg_adec_params_ac3 {
-	audpp_cmd_cfg_adec_params_common	common;
-	unsigned short				index[ADEC_PARAMS_AC3_INDEX];
-} __packed;
-
-#define AUDPP_CMD_CFG_ADEC_PARAMS_AC3_LEN \
-	sizeof(struct audpp_cmd_cfg_adec_params_ac3)
-
-/*
- * Command Structure to configure the  HOST PCM interface
- */
-
-#define AUDPP_CMD_PCM_INTF	0x0001
-#define AUDPP_CMD_PCM_INTF_2	0x0002
-#define AUDPP_CMD_PCM_INTF_LEN	sizeof(audpp_cmd_pcm_intf)
-
-#define AUDPP_CMD_PCM_INTF_MONO_V		        0x0001
-#define AUDPP_CMD_PCM_INTF_STEREO_V         	0x0002
-
-/* These two values differentiate the two types of commands that could be issued
- * Interface configuration command and Buffer update command */
-
-#define AUDPP_CMD_PCM_INTF_CONFIG_CMD_V	       	0x0000
-#define AUDPP_CMD_PCM_INTF_BUFFER_CMD_V	        -1
-
-#define AUDPP_CMD_PCM_INTF_RX_ENA_M              0x000F
-#define AUDPP_CMD_PCM_INTF_RX_ENA_ARMTODSP_V     0x0008
-#define AUDPP_CMD_PCM_INTF_RX_ENA_DSPTOARM_V     0x0004
-
-/* These flags control the enabling and disabling of the interface together
- *  with host interface bit mask. */
-
-#define AUDPP_CMD_PCM_INTF_ENA_V            -1
-#define AUDPP_CMD_PCM_INTF_DIS_V            0x0000
-
-
-#define  AUDPP_CMD_PCM_INTF_FULL_DUPLEX           0x0
-#define  AUDPP_CMD_PCM_INTF_HALF_DUPLEX_TODSP     0x1
-
-
-#define  AUDPP_CMD_PCM_INTF_OBJECT_NUM           0x5
-#define  AUDPP_CMD_PCM_INTF_COMMON_OBJECT_NUM    0x6
-  
-
-typedef struct {
-  unsigned short  cmd_id;
-  unsigned short  object_num;
-  signed short  config;
-  unsigned short  intf_type;
-  
-  /* DSP -> ARM Configuration */
-  unsigned short  read_buf1LSW;
-  unsigned short  read_buf1MSW;
-  unsigned short  read_buf1_len;
-
-  unsigned short  read_buf2LSW;
-  unsigned short  read_buf2MSW;
-  unsigned short  read_buf2_len;
-  /*   0:HOST_PCM_INTF disable
-   **  0xFFFF: HOST_PCM_INTF enable
-   */
-  signed short  dsp_to_arm_flag;
-  unsigned short  partition_number;
-
-  /* ARM -> DSP Configuration */
-  unsigned short  write_buf1LSW;
-  unsigned short  write_buf1MSW;
-  unsigned short  write_buf1_len;
- 
-  unsigned short  write_buf2LSW;
-  unsigned short  write_buf2MSW;
-  unsigned short  write_buf2_len;
-
-  /*   0:HOST_PCM_INTF disable
-   **  0xFFFF: HOST_PCM_INTF enable
-   */
-  signed short  arm_to_rx_flag;
-  unsigned short  weight_decoder_to_rx;
-  unsigned short  weight_arm_to_rx;
-
-  unsigned short  partition_number_arm_to_dsp;
-  unsigned short  sample_rate;
-  unsigned short  channel_mode;
-} __attribute__((packed)) audpp_cmd_pcm_intf;
-
-/*
- **  BUFFER UPDATE COMMAND
- */
-#define AUDPP_CMD_PCM_INTF_SEND_BUF_PARAMS_LEN	\
-	sizeof(audpp_cmd_pcm_intf_send_buffer)
-
-typedef struct {
-  unsigned short  cmd_id;
-  unsigned short  host_pcm_object;
-  /* set config = 0xFFFF for configuration*/
-  signed short  config;
-  unsigned short  intf_type;
-  unsigned short  dsp_to_arm_buf_id;
-  unsigned short  arm_to_dsp_buf_id;
-  unsigned short  arm_to_dsp_buf_len;
-} __attribute__((packed)) audpp_cmd_pcm_intf_send_buffer;
-
-#define AUDPP_CMD_PP_FEAT_QUERY_PARAMS  0x0003
-
-struct rtc_audpp_read_data {
-	unsigned short  cmd_id;
-	unsigned short  obj_id;
-	unsigned short  feature_id;
-	unsigned short  extbufsizemsw;
-	unsigned short  extbufsizelsw;
-	unsigned short	extpart;
-	unsigned short	extbufstartmsw;
-	unsigned short	extbufstartlsw;
-} __packed ;
-
-/*
- * Commands Related to uPAudPPCmd3Queue
- */
-
-/*
- * Command Structure to configure post processing params (Commmon)
- */
-
-#define AUDPP_CMD_CFG_OBJECT_PARAMS		0x0000
-#define AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN		\
-	sizeof(audpp_cmd_cfg_object_params_common)
-
-#define AUDPP_CMD_OBJ0_UPDATE		0x8000
-#define AUDPP_CMD_OBJ0_DONT_UPDATE	0x0000
-
-#define AUDPP_CMD_OBJ1_UPDATE		0x8000
-#define AUDPP_CMD_OBJ1_DONT_UPDATE	0x0000
-
-#define AUDPP_CMD_OBJ2_UPDATE		0x8000
-#define AUDPP_CMD_OBJ2_DONT_UPDATE	0x0000
-
-#define AUDPP_CMD_OBJ3_UPDATE		0x8000
-#define AUDPP_CMD_OBJ3_DONT_UPDATE	0x0000
-
-#define AUDPP_CMD_OBJ4_UPDATE		0x8000
-#define AUDPP_CMD_OBJ4_DONT_UPDATE	0x0000
-
-#define AUDPP_CMD_HPCM_UPDATE		0x8000
-#define AUDPP_CMD_HPCM_DONT_UPDATE	0x0000
-
-#define AUDPP_CMD_COMMON_CFG_UPDATE		0x8000
-#define AUDPP_CMD_COMMON_CFG_DONT_UPDATE	0x0000
-
-#define AUDPP_CMD_COPP_STREAM   0x0006
-
-typedef struct {
-	unsigned short  cmd_id;
-	unsigned short	obj0_cfg;
-	unsigned short	obj1_cfg;
-	unsigned short	obj2_cfg;
-	unsigned short	obj3_cfg;
-	unsigned short	obj4_cfg;
-	unsigned short	host_pcm_obj_cfg;
-	unsigned short	comman_cfg;
-	unsigned short  command_type;
-} __attribute__((packed)) audpp_cmd_cfg_object_params_common;
-
-/*
- * Command Structure to configure post processing params (Volume)
- */
-
-#define AUDPP_CMD_VOLUME_PAN		0
-#define AUDPP_CMD_CFG_OBJECT_PARAMS_VOLUME_LEN		\
-	sizeof(audpp_cmd_cfg_object_params_volume)
-
-typedef struct {
-	audpp_cmd_cfg_object_params_common 	common;
-	unsigned short					volume;
-	unsigned short					pan;
-} __attribute__((packed)) audpp_cmd_cfg_object_params_volume;
-
-/*
- * Command Structure to configure post processing params (PCM Filter) --DOUBT
- */
-
-typedef struct {
-	unsigned short			numerator_b0_filter_lsw;
-	unsigned short			numerator_b0_filter_msw;
-	unsigned short			numerator_b1_filter_lsw;
-	unsigned short			numerator_b1_filter_msw;
-	unsigned short			numerator_b2_filter_lsw;
-	unsigned short			numerator_b2_filter_msw;
-} __attribute__((packed)) numerator;
-
-typedef struct {
-	unsigned short			denominator_a0_filter_lsw;
-	unsigned short			denominator_a0_filter_msw;
-	unsigned short			denominator_a1_filter_lsw;
-	unsigned short			denominator_a1_filter_msw;
-} __attribute__((packed)) denominator;
-
-typedef struct {
-	unsigned short			shift_factor_0;
-} __attribute__((packed)) shift_factor;
-
-typedef struct {
-	unsigned short			pan_filter_0;
-} __attribute__((packed)) pan;
-
-typedef struct {
-		numerator		numerator_filter;
-		denominator		denominator_filter;
-		shift_factor		shift_factor_filter;
-		pan			pan_filter;
-} __attribute__((packed)) filter_1;
-
-typedef struct {
-		numerator		numerator_filter[2];
-		denominator		denominator_filter[2];
-		shift_factor		shift_factor_filter[2];
-		pan			pan_filter[2];
-} __attribute__((packed)) filter_2;
-
-typedef struct {
-		numerator		numerator_filter[3];
-		denominator		denominator_filter[3];
-		shift_factor		shift_factor_filter[3];
-		pan			pan_filter[3];
-} __attribute__((packed)) filter_3;
-
-typedef struct {
-		numerator		numerator_filter[4];
-		denominator		denominator_filter[4];
-		shift_factor		shift_factor_filter[4];
-		pan			pan_filter[4];
-} __attribute__((packed)) filter_4;
-
-#define AUDPP_CMD_IIR_TUNING_FILTER	1
-#define AUDPP_CMD_CFG_OBJECT_PARAMS_PCM_LEN		\
-	sizeof(audpp_cmd_cfg_object_params_pcm)
-
-
-typedef struct {
-	audpp_cmd_cfg_object_params_common 	common;
-	unsigned short				active_flag;
-	unsigned short 				num_bands;
-	union {
-		filter_1			filter_1_params;
-		filter_2			filter_2_params;
-		filter_3			filter_3_params;
-		filter_4			filter_4_params;
-	} __attribute__((packed)) params_filter;
-} __attribute__((packed)) audpp_cmd_cfg_object_params_pcm;
-
-
-/*
- * Command Structure to configure post processing parameters (equalizer) 
- */
-
-#define AUDPP_CMD_EQUALIZER		2
-#define AUDPP_CMD_CFG_OBJECT_PARAMS_EQALIZER_LEN		\
-	sizeof(audpp_cmd_cfg_object_params_eqalizer)
-
-typedef struct {
-	unsigned short			numerator_coeff_0_lsw;
-	unsigned short			numerator_coeff_0_msw;
-	unsigned short			numerator_coeff_1_lsw;
-	unsigned short			numerator_coeff_1_msw;
-	unsigned short			numerator_coeff_2_lsw;
-	unsigned short			numerator_coeff_2_msw;
-} __attribute__((packed)) eq_numerator;
-
-typedef struct {
-	unsigned short			denominator_coeff_0_lsw;
-	unsigned short			denominator_coeff_0_msw;
-	unsigned short			denominator_coeff_1_lsw;
-	unsigned short			denominator_coeff_1_msw;
-} __attribute__((packed)) eq_denominator;
-
-typedef struct {
-	unsigned short			shift_factor;
-} __attribute__((packed)) eq_shiftfactor;
-
-typedef struct {
-	eq_numerator	numerator;
-	eq_denominator	denominator;
-	eq_shiftfactor	shiftfactor;
-} __attribute__((packed)) eq_coeff_1;
-
-typedef struct {
-	eq_numerator	numerator[2];
-	eq_denominator	denominator[2];
-	eq_shiftfactor	shiftfactor[2];
-} __attribute__((packed)) eq_coeff_2;
-
-typedef struct {
-	eq_numerator	numerator[3];
-	eq_denominator	denominator[3];
-	eq_shiftfactor	shiftfactor[3];
-} __attribute__((packed)) eq_coeff_3;
-
-typedef struct {
-	eq_numerator	numerator[4];
-	eq_denominator	denominator[4];
-	eq_shiftfactor	shiftfactor[4];
-} __attribute__((packed)) eq_coeff_4;
-
-typedef struct {
-	eq_numerator	numerator[5];
-	eq_denominator	denominator[5];
-	eq_shiftfactor	shiftfactor[5];
-} __attribute__((packed)) eq_coeff_5;
-
-typedef struct {
-	eq_numerator	numerator[6];
-	eq_denominator	denominator[6];
-	eq_shiftfactor	shiftfactor[6];
-} __attribute__((packed)) eq_coeff_6;
-
-typedef struct {
-	eq_numerator	numerator[7];
-	eq_denominator	denominator[7];
-	eq_shiftfactor	shiftfactor[7];
-} __attribute__((packed)) eq_coeff_7;
-
-typedef struct {
-	eq_numerator	numerator[8];
-	eq_denominator	denominator[8];
-	eq_shiftfactor	shiftfactor[8];
-} __attribute__((packed)) eq_coeff_8;
-
-typedef struct {
-	eq_numerator	numerator[9];
-	eq_denominator	denominator[9];
-	eq_shiftfactor	shiftfactor[9];
-} __attribute__((packed)) eq_coeff_9;
-
-typedef struct {
-	eq_numerator	numerator[10];
-	eq_denominator	denominator[10];
-	eq_shiftfactor	shiftfactor[10];
-} __attribute__((packed)) eq_coeff_10;
-
-typedef struct {
-	eq_numerator	numerator[11];
-	eq_denominator	denominator[11];
-	eq_shiftfactor	shiftfactor[11];
-} __attribute__((packed)) eq_coeff_11;
-
-typedef struct {
-	eq_numerator	numerator[12];
-	eq_denominator	denominator[12];
-	eq_shiftfactor	shiftfactor[12];
-} __attribute__((packed)) eq_coeff_12;
-
-
-typedef struct {
-	audpp_cmd_cfg_object_params_common 	common;
-	unsigned short				eq_flag;
-	unsigned short				num_bands;
-	union {
-		eq_coeff_1	eq_coeffs_1;
-		eq_coeff_2	eq_coeffs_2;
-		eq_coeff_3	eq_coeffs_3;
-		eq_coeff_4	eq_coeffs_4;
-		eq_coeff_5	eq_coeffs_5;
-		eq_coeff_6	eq_coeffs_6;
-		eq_coeff_7	eq_coeffs_7;
-		eq_coeff_8	eq_coeffs_8;
-		eq_coeff_9	eq_coeffs_9;
-		eq_coeff_10	eq_coeffs_10;
-		eq_coeff_11	eq_coeffs_11;
-		eq_coeff_12	eq_coeffs_12;
-	} __attribute__((packed)) eq_coeff;
-} __attribute__((packed)) audpp_cmd_cfg_object_params_eqalizer;
-
-
-/*
- * Command Structure to configure post processing parameters (ADRC) 
- */
-
-#define AUDPP_CMD_ADRC			3
-#define AUDPP_CMD_CFG_OBJECT_PARAMS_ADRC_LEN		\
-	sizeof(audpp_cmd_cfg_object_params_adrc)
-
-
-#define AUDPP_CMD_ADRC_FLAG_DIS		0x0000
-#define AUDPP_CMD_ADRC_FLAG_ENA		-1
-
-#define AUDPP_CMD_MBADRC		10
-#define	AUDPP_MAX_MBADRC_BANDS		5
-#define	AUDPP_MBADRC_EXTERNAL_BUF_SIZE	196
-
-struct adrc_config {
-	uint16_t subband_enable;
-	uint16_t adrc_sub_mute;
-	uint16_t rms_time;
-	uint16_t compression_th;
-	uint16_t compression_slope;
-	uint16_t attack_const_lsw;
-	uint16_t attack_const_msw;
-	uint16_t release_const_lsw;
-	uint16_t release_const_msw;
-	uint16_t makeup_gain;
-};
-
-typedef struct {
-	audpp_cmd_cfg_object_params_common 	common;
-	uint16_t enable;
-	uint16_t num_bands;
-	uint16_t down_samp_level;
-	uint16_t adrc_delay;
-	uint16_t ext_buf_size;
-	uint16_t ext_partition;
-	uint16_t ext_buf_msw;
-	uint16_t ext_buf_lsw;
-	struct adrc_config adrc_band[AUDPP_MAX_MBADRC_BANDS];
-} __attribute__((packed)) audpp_cmd_cfg_object_params_mbadrc;
-
-struct audpp_cmd_cfg_object_params_adrc {
-	unsigned short	adrc_flag;
-	unsigned short	compression_th;
-	unsigned short	compression_slope;
-	unsigned short	rms_time;
-	unsigned short	attack_const_lsw;
-	unsigned short	attack_const_msw;
-	unsigned short	release_const_lsw;
-	unsigned short	release_const_msw;
-	unsigned short	adrc_delay;
-};
-
-/*
- * Command Structure to configure post processing parameters(Spectrum Analizer)
- */
-
-#define AUDPP_CMD_SPECTROGRAM		4
-#define AUDPP_CMD_CFG_OBJECT_PARAMS_SPECTRAM_LEN		\
-	sizeof(audpp_cmd_cfg_object_params_spectram)
-
-
-typedef struct {
-	audpp_cmd_cfg_object_params_common 	common;
-	unsigned short				sample_interval;
-	unsigned short				num_coeff;
-} __attribute__((packed)) audpp_cmd_cfg_object_params_spectram;
-
-/*
- * Command Structure to configure post processing parameters (QConcert) 
- */
-
-#define AUDPP_CMD_QCONCERT		5
-#define AUDPP_CMD_CFG_OBJECT_PARAMS_QCONCERT_LEN		\
-	sizeof(audpp_cmd_cfg_object_params_qconcert)
-
-
-#define AUDPP_CMD_QCON_ENA_FLAG_ENA		-1
-#define AUDPP_CMD_QCON_ENA_FLAG_DIS		0x0000
-
-#define AUDPP_CMD_QCON_OP_MODE_HEADPHONE	-1
-#define AUDPP_CMD_QCON_OP_MODE_SPEAKER_FRONT	0x0000
-#define AUDPP_CMD_QCON_OP_MODE_SPEAKER_SIDE	0x0001
-#define AUDPP_CMD_QCON_OP_MODE_SPEAKER_DESKTOP	0x0002
-
-#define AUDPP_CMD_QCON_GAIN_UNIT			0x7FFF
-#define AUDPP_CMD_QCON_GAIN_SIX_DB			0x4027
-
-
-#define AUDPP_CMD_QCON_EXPANSION_MAX		0x7FFF
-
-
-typedef struct {
-	audpp_cmd_cfg_object_params_common 	common;
-	signed short				enable_flag;
-	signed short				op_mode;
-	signed short				gain;
-	signed short				expansion;
-	signed short				delay;
-	unsigned short				stages_per_mode;
-	unsigned short				reverb_enable;
-	unsigned short				decay_msw;
-	unsigned short				decay_lsw;
-	unsigned short				decay_time_ratio_msw;
-	unsigned short				decay_time_ratio_lsw;
-	unsigned short				reflection_delay_time;
-	unsigned short				late_reverb_gain;
-	unsigned short				late_reverb_delay;
-	unsigned short                          delay_buff_size_msw;
-	unsigned short                          delay_buff_size_lsw;
-	unsigned short                          partition_num;
-	unsigned short                          delay_buff_start_msw;
-	unsigned short                          delay_buff_start_lsw;
-} __attribute__((packed)) audpp_cmd_cfg_object_params_qconcert;
-
-/*
- * Command Structure to configure post processing parameters (Side Chain) 
- */
-
-#define AUDPP_CMD_SIDECHAIN_TUNING_FILTER	6
-#define AUDPP_CMD_CFG_OBJECT_PARAMS_SIDECHAIN_LEN		\
-	sizeof(audpp_cmd_cfg_object_params_sidechain)
-
-
-#define AUDPP_CMD_SIDECHAIN_ACTIVE_FLAG_DIS	0x0000
-#define AUDPP_CMD_SIDECHAIN_ACTIVE_FLAG_ENA	-1
-
-typedef struct {
-	audpp_cmd_cfg_object_params_common 	common;
-	signed short				active_flag;
-	unsigned short				num_bands;
-	union {
-		filter_1			filter_1_params;
-		filter_2			filter_2_params;
-		filter_3			filter_3_params;
-		filter_4			filter_4_params;
-	} __attribute__((packed)) params_filter;
-} __attribute__((packed)) audpp_cmd_cfg_object_params_sidechain;
-
-
-/*
- * Command Structure to configure post processing parameters (QAFX)
- */
-
-#define AUDPP_CMD_QAFX			8
-#define AUDPP_CMD_CFG_OBJECT_PARAMS_QAFX_LEN		\
-	sizeof(audpp_cmd_cfg_object_params_qafx)
-
-#define AUDPP_CMD_QAFX_ENA_DISA		0x0000
-#define AUDPP_CMD_QAFX_ENA_ENA_CFG	-1
-#define AUDPP_CMD_QAFX_ENA_DIS_CFG	0x0001
-
-#define AUDPP_CMD_QAFX_CMD_TYPE_ENV	0x0100
-#define AUDPP_CMD_QAFX_CMD_TYPE_OBJ	0x0010
-#define AUDPP_CMD_QAFX_CMD_TYPE_QUERY	0x1000
-
-#define AUDPP_CMD_QAFX_CMDS_ENV_OP_MODE	0x0100
-#define AUDPP_CMD_QAFX_CMDS_ENV_LIS_POS	0x0101
-#define AUDPP_CMD_QAFX_CMDS_ENV_LIS_ORI	0x0102
-#define AUDPP_CMD_QAFX_CMDS_ENV_LIS_VEL	0X0103
-#define AUDPP_CMD_QAFX_CMDS_ENV_ENV_RES	0x0107
-
-#define AUDPP_CMD_QAFX_CMDS_OBJ_SAMP_FREQ	0x0010
-#define AUDPP_CMD_QAFX_CMDS_OBJ_VOL		0x0011
-#define AUDPP_CMD_QAFX_CMDS_OBJ_DIST		0x0012
-#define AUDPP_CMD_QAFX_CMDS_OBJ_POS		0x0013
-#define AUDPP_CMD_QAFX_CMDS_OBJ_VEL		0x0014
-
-
-typedef struct {
-	audpp_cmd_cfg_object_params_common 	common;
-	signed short				enable;
-	unsigned short				command_type;
-	unsigned short				num_commands;
-	unsigned short				commands;
-} __attribute__((packed)) audpp_cmd_cfg_object_params_qafx;
-
-/*
- * Command Structure to enable , disable or configure the reverberation effect
- * (Common)
- */
-
-#define AUDPP_CMD_REVERB_CONFIG		0x0001
-#define	AUDPP_CMD_REVERB_CONFIG_COMMON_LEN	\
-	sizeof(audpp_cmd_reverb_config_common)
-
-#define AUDPP_CMD_ENA_ENA	0xFFFF
-#define AUDPP_CMD_ENA_DIS	0x0000
-#define AUDPP_CMD_ENA_CFG	0x0001
-
-#define AUDPP_CMD_CMD_TYPE_ENV		0x0104
-#define AUDPP_CMD_CMD_TYPE_OBJ		0x0015
-#define AUDPP_CMD_CMD_TYPE_QUERY	0x1000
-
-#define SRS_PARAMS_MAX_G 8
-#define SRS_PARAMS_MAX_W 55
-#define SRS_PARAMS_MAX_C 51
-#define SRS_PARAMS_MAX_H 53
-#define SRS_PARAMS_MAX_P 116
-#define SRS_PARAMS_MAX_L 8
-
-typedef struct {
-	unsigned short			cmd_id;
-	unsigned short			enable;
-	unsigned short			cmd_type;
-} __attribute__((packed)) audpp_cmd_reverb_config_common;
-
-/*
- * Command Structure to enable , disable or configure the reverberation effect
- * (ENV-0x0104)
- */
-
-#define	AUDPP_CMD_REVERB_CONFIG_ENV_104_LEN	\
-	sizeof(audpp_cmd_reverb_config_env_104)
-
-typedef struct {
-	audpp_cmd_reverb_config_common	common;
-	unsigned short			env_gain;
-	unsigned short			decay_msw;
-	unsigned short			decay_lsw;
-	unsigned short			decay_timeratio_msw;
-	unsigned short			decay_timeratio_lsw;
-	unsigned short			delay_time;
-	unsigned short			reverb_gain;
-	unsigned short			reverb_delay;
-} __attribute__((packed)) audpp_cmd_reverb_config_env_104;
-
-/*
- * Command Structure to enable , disable or configure the reverberation effect
- * (ENV-0x0015)
- */
-
-#define	AUDPP_CMD_REVERB_CONFIG_ENV_15_LEN	\
-	sizeof(audpp_cmd_reverb_config_env_15)
-
-typedef struct {
-	audpp_cmd_reverb_config_common	common;
-	unsigned short			object_num;
-	unsigned short			absolute_gain;
-} __attribute__((packed)) audpp_cmd_reverb_config_env_15;
-
-/*
- * Command Structure to configure post processing params (SRS TruMedia)
- */
-struct audpp_cmd_cfg_object_params_srstm_g {
-	audpp_cmd_cfg_object_params_common	common;
-	unsigned short				v[SRS_PARAMS_MAX_G];
-} __packed;
-struct audpp_cmd_cfg_object_params_srstm_w {
-	audpp_cmd_cfg_object_params_common	common;
-	unsigned short				v[SRS_PARAMS_MAX_W];
-} __packed;
-struct audpp_cmd_cfg_object_params_srstm_c {
-	audpp_cmd_cfg_object_params_common	common;
-	unsigned short				v[SRS_PARAMS_MAX_C];
-} __packed;
-struct audpp_cmd_cfg_object_params_srstm_h {
-	audpp_cmd_cfg_object_params_common	common;
-	unsigned short				v[SRS_PARAMS_MAX_H];
-} __packed;
-struct audpp_cmd_cfg_object_params_srstm_p {
-	audpp_cmd_cfg_object_params_common	common;
-	unsigned short				v[SRS_PARAMS_MAX_P];
-} __packed;
-struct audpp_cmd_cfg_object_params_srstm_l {
-	audpp_cmd_cfg_object_params_common	common;
-	unsigned short				v[SRS_PARAMS_MAX_L];
-} __packed;
-#define AUDPP_CMD_SAMPLING_FREQUENCY	7
-#define AUDPP_CMD_QRUMBLE		9
-#define AUDPP_CMD_SRS			18
-#define AUDPP_DISABLE_FEATS_LSW		2
-#define AUDPP_DISABLE_FEATS_MSW		3
-
-#endif /* QDSP5AUDPPCMDI_H */
-
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audppmsg.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audppmsg.h
deleted file mode 100644
index 664e246..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audppmsg.h
+++ /dev/null
@@ -1,336 +0,0 @@
-#ifndef QDSP5AUDPPMSG_H
-#define QDSP5AUDPPMSG_H
-
-/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
-
-       Q D S P 5  A U D I O   P O S T   P R O C E S S I N G   M S G
-
- GENERAL DESCRIPTION
-   Messages sent by AUDPPTASK to ARM
-
- REFERENCES
-   None
-
- EXTERNALIZED FUNCTIONS
-   None
-
- Copyright (c) 1992-2009, 2012-2013 The Linux Foundation. All rights reserved.
-
- This software is licensed under the terms of the GNU General Public
- License version 2, as published by the Free Software Foundation, and
- may be copied, distributed, and modified under those terms.
-
- 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.
-
-*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
-/*===========================================================================
-
-                      EDIT HISTORY FOR FILE
-
-This section contains comments describing changes made to this file.
-Notice that changes are listed in reverse chronological order.
-  
- $Header: //source/qcom/qct/multimedia2/Audio/drivers/QDSP5Driver/QDSP5Interface/main/latest/qdsp5audppmsg.h#4 $
-
-===========================================================================*/
-
-/*
- * AUDPPTASK uses audPPuPRlist to send messages to the ARM
- * Location : MEMA
- * Buffer Size : 45
- * No of Buffers in a queue : 5 for gaming audio and 1 for other images 
- */
-
-/*
- * MSG to Informs the ARM os Success/Failure of bringing up the decoder
- */
-
-#define AUDPP_MSG_STATUS_MSG		0x0001
-#define AUDPP_MSG_STATUS_MSG_LEN	\
-	sizeof(audpp_msg_status_msg)
-
-#define AUDPP_MSG_STATUS_SLEEP		0x0000
-#define AUDPP_MSG_STATUS_INIT		0x0001
-#define AUDPP_MSG_STATUS_CFG		0x0002
-#define AUDPP_MSG_STATUS_PLAY		0x0003
-
-#define AUDPP_MSG_REASON_NONE	0x0000
-#define AUDPP_MSG_REASON_MEM	0x0001
-#define AUDPP_MSG_REASON_NODECODER 0x0002
-
-typedef struct{
-	unsigned short dec_id;
-	unsigned short status;
-	unsigned short reason;
-} __attribute__((packed)) audpp_msg_status_msg;
-
-/*
- * MSG to communicate the spectrum analyzer output bands to the ARM
- */
-#define AUDPP_MSG_SPA_BANDS		0x0002
-#define AUDPP_MSG_SPA_BANDS_LEN	\
-	sizeof(audpp_msg_spa_bands)
-
-typedef struct {
-	unsigned short			current_object;
-	unsigned short			spa_band_1;
-	unsigned short			spa_band_2;
-	unsigned short			spa_band_3;
-	unsigned short			spa_band_4;
-	unsigned short			spa_band_5;
-	unsigned short			spa_band_6;
-	unsigned short			spa_band_7;
-	unsigned short			spa_band_8;
-	unsigned short			spa_band_9;
-	unsigned short			spa_band_10;
-	unsigned short			spa_band_11;
-	unsigned short			spa_band_12;
-	unsigned short			spa_band_13;
-	unsigned short			spa_band_14;
-	unsigned short			spa_band_15;
-	unsigned short			spa_band_16;
-	unsigned short			spa_band_17;
-	unsigned short			spa_band_18;
-	unsigned short			spa_band_19;
-	unsigned short			spa_band_20;
-	unsigned short			spa_band_21;
-	unsigned short			spa_band_22;
-	unsigned short			spa_band_23;
-	unsigned short			spa_band_24;
-	unsigned short			spa_band_25;
-	unsigned short			spa_band_26;
-	unsigned short			spa_band_27;
-	unsigned short			spa_band_28;
-	unsigned short			spa_band_29;
-	unsigned short			spa_band_30;
-	unsigned short			spa_band_31;
-	unsigned short			spa_band_32;
-} __attribute__((packed)) audpp_msg_spa_bands;
-
-/*
- * MSG to communicate the PCM I/O buffer status to ARM
- */
-#define  AUDPP_MSG_HOST_PCM_INTF_MSG		0x0003
-#define  AUDPP_MSG_HOST_PCM_INTF_MSG_LEN	\
-	sizeof(audpp_msg_host_pcm_intf_msg)
-
-#define AUDPP_MSG_HOSTPCM_ID_TX_ARM	0x0000
-#define AUDPP_MSG_HOSTPCM_ID_ARM_TX	0x0001
-#define AUDPP_MSG_HOSTPCM_ID_RX_ARM	0x0002
-#define AUDPP_MSG_HOSTPCM_ID_ARM_RX	0x0003
-
-#define AUDPP_MSG_SAMP_FREQ_INDX_96000	0x0000
-#define AUDPP_MSG_SAMP_FREQ_INDX_88200	0x0001
-#define AUDPP_MSG_SAMP_FREQ_INDX_64000	0x0002
-#define AUDPP_MSG_SAMP_FREQ_INDX_48000	0x0003
-#define AUDPP_MSG_SAMP_FREQ_INDX_44100	0x0004
-#define AUDPP_MSG_SAMP_FREQ_INDX_32000	0x0005
-#define AUDPP_MSG_SAMP_FREQ_INDX_24000	0x0006
-#define AUDPP_MSG_SAMP_FREQ_INDX_22050	0x0007
-#define AUDPP_MSG_SAMP_FREQ_INDX_16000	0x0008
-#define AUDPP_MSG_SAMP_FREQ_INDX_12000	0x0009
-#define AUDPP_MSG_SAMP_FREQ_INDX_11025	0x000A
-#define AUDPP_MSG_SAMP_FREQ_INDX_8000	0x000B
-
-#define AUDPP_MSG_CHANNEL_MODE_MONO		0x0001
-#define AUDPP_MSG_CHANNEL_MODE_STEREO	0x0002
-
-typedef struct{
-	unsigned short obj_num;
-	unsigned short numbers_of_samples;
-	unsigned short host_pcm_id;
-	unsigned short buf_indx;
-	unsigned short samp_freq_indx;
-	unsigned short channel_mode;
-} __attribute__((packed)) audpp_msg_host_pcm_intf_msg;
-
-
-/*
- * MSG to communicate 3D position of the source and listener , source volume
- * source rolloff, source orientation
- */
-
-#define AUDPP_MSG_QAFX_POS		0x0004
-#define AUDPP_MSG_QAFX_POS_LEN		\
-	sizeof(audpp_msg_qafx_pos)
-
-typedef struct {
-	unsigned short	current_object;
-	unsigned short	x_pos_lis_msw;
-	unsigned short	x_pos_lis_lsw;
-	unsigned short	y_pos_lis_msw;
-	unsigned short	y_pos_lis_lsw;
-	unsigned short	z_pos_lis_msw;
-	unsigned short	z_pos_lis_lsw;
-	unsigned short	x_fwd_msw;
-	unsigned short	x_fwd_lsw;
-	unsigned short	y_fwd_msw;
-	unsigned short	y_fwd_lsw;
-	unsigned short	z_fwd_msw;
-	unsigned short	z_fwd_lsw;
-	unsigned short 	x_up_msw;
-	unsigned short	x_up_lsw;
-	unsigned short 	y_up_msw;
-	unsigned short	y_up_lsw;
-	unsigned short 	z_up_msw;
-	unsigned short	z_up_lsw;
-	unsigned short 	x_vel_lis_msw;
-	unsigned short 	x_vel_lis_lsw;
-	unsigned short 	y_vel_lis_msw;
-	unsigned short 	y_vel_lis_lsw;
-	unsigned short 	z_vel_lis_msw;
-	unsigned short 	z_vel_lis_lsw;
-	unsigned short	threed_enable_flag;
-	unsigned short 	volume;
-	unsigned short	x_pos_source_msw;
-	unsigned short	x_pos_source_lsw;
-	unsigned short	y_pos_source_msw;
-	unsigned short	y_pos_source_lsw;
-	unsigned short	z_pos_source_msw;
-	unsigned short	z_pos_source_lsw;
-	unsigned short	max_dist_0_msw;
-	unsigned short	max_dist_0_lsw;
-	unsigned short	min_dist_0_msw;
-	unsigned short	min_dist_0_lsw;
-	unsigned short	roll_off_factor;
-	unsigned short	mute_after_max_flag;
-	unsigned short	x_vel_source_msw;
-	unsigned short	x_vel_source_lsw;
-	unsigned short	y_vel_source_msw;
-	unsigned short	y_vel_source_lsw;
-	unsigned short	z_vel_source_msw;
-	unsigned short	z_vel_source_lsw;
-} __attribute__((packed)) audpp_msg_qafx_pos;
-
-/*
- * MSG to provide AVSYNC feedback from DSP to ARM
- */
-
-#define AUDPP_MSG_AVSYNC_MSG		0x0005
-#define AUDPP_MSG_AVSYNC_MSG_LEN	\
-	sizeof(audpp_msg_avsync_msg)
-
-typedef struct {
-	unsigned short	active_flag;
-	unsigned short	num_samples_counter0_HSW;
-	unsigned short	num_samples_counter0_MSW;
-	unsigned short	num_samples_counter0_LSW;
-	unsigned short	num_bytes_counter0_HSW;
-	unsigned short	num_bytes_counter0_MSW;
-	unsigned short	num_bytes_counter0_LSW;
-	unsigned short	samp_freq_obj_0;
-	unsigned short	samp_freq_obj_1;
-	unsigned short	samp_freq_obj_2;
-	unsigned short	samp_freq_obj_3;
-	unsigned short	samp_freq_obj_4;
-	unsigned short	samp_freq_obj_5;
-	unsigned short	samp_freq_obj_6;
-	unsigned short	samp_freq_obj_7;
-	unsigned short	samp_freq_obj_8;
-	unsigned short	samp_freq_obj_9;
-	unsigned short	samp_freq_obj_10;
-	unsigned short	samp_freq_obj_11;
-	unsigned short	samp_freq_obj_12;
-	unsigned short	samp_freq_obj_13;
-	unsigned short	samp_freq_obj_14;
-	unsigned short	samp_freq_obj_15;
-	unsigned short	num_samples_counter4_HSW;
-	unsigned short	num_samples_counter4_MSW;
-	unsigned short	num_samples_counter4_LSW;
-	unsigned short	num_bytes_counter4_HSW;
-	unsigned short	num_bytes_counter4_MSW;
-	unsigned short	num_bytes_counter4_LSW;
-} __attribute__((packed)) audpp_msg_avsync_msg;
-
-/*
- * MSG to provide PCM DMA Missed feedback from the DSP to ARM
- */
-
-#define  AUDPP_MSG_PCMDMAMISSED	0x0006
-#define  AUDPP_MSG_PCMDMAMISSED_LEN	\
-	sizeof(audpp_msg_pcmdmamissed);
-
-typedef struct{
-  /*
-  ** Bit 0	0 = PCM DMA not missed for object 0
-  **        1 = PCM DMA missed for object0
-  ** Bit 1	0 = PCM DMA not missed for object 1
-  **        1 = PCM DMA missed for object1
-  ** Bit 2	0 = PCM DMA not missed for object 2
-  **        1 = PCM DMA missed for object2
-  ** Bit 3	0 = PCM DMA not missed for object 3
-  **        1 = PCM DMA missed for object3
-  ** Bit 4	0 = PCM DMA not missed for object 4
-  **        1 = PCM DMA missed for object4
-  */
-  unsigned short pcmdmamissed;
-} __attribute__((packed)) audpp_msg_pcmdmamissed;
-
-/*
- * MSG to AUDPP enable or disable feedback form DSP to ARM
- */
-
-#define AUDPP_MSG_CFG_MSG	0x0007  
-#define AUDPP_MSG_CFG_MSG_LEN	\
-    sizeof(audpp_msg_cfg_msg)
-
-#define AUDPP_MSG_ENA_ENA	0xFFFF
-#define AUDPP_MSG_ENA_DIS	0x0000
-
-typedef struct{
-  /*   Enabled  - 0xffff 
-   **  Disabled - 0
-   */
-  unsigned short enabled;
-} __attribute__((packed)) audpp_msg_cfg_msg;
-
-/*
- * MSG to communicate the reverb  per object volume
- */
-
-#define AUDPP_MSG_QREVERB_VOLUME	0x0008
-#define AUDPP_MSG_QREVERB_VOLUME_LEN	\
-	sizeof(audpp_msg_qreverb_volume)
-
-
-typedef struct {
-	unsigned short	obj_0_gain;
-	unsigned short	obj_1_gain;
-	unsigned short	obj_2_gain;
-	unsigned short	obj_3_gain;
-	unsigned short	obj_4_gain;
-	unsigned short	hpcm_obj_volume;
-} __attribute__((packed)) audpp_msg_qreverb_volume;
-
-#define AUDPP_MSG_ROUTING_ACK 0x0009
-#define AUDPP_MSG_ROUTING_ACK_LEN \
-  sizeof(struct audpp_msg_routing_ack)
-
-struct audpp_msg_routing_ack {
-  unsigned short dec_id;
-  unsigned short routing_mode;
-} __attribute__((packed));
-
-#define AUDPP_MSG_FLUSH_ACK 0x000A
-
-#define ADSP_MESSAGE_ID 0xFFFF
-
-#define AUDPP_MSG_FEAT_QUERY_DM_DONE 0x000b
-
-/*
- * ADSP sends this message when a PP feature is disabled
- * due to ADSP resource limitation.
- */
-#define AUDPP_MSG_PP_DISABLE_FEEDBACK 0x000C
-
-/*
- * This message is sent by ADSP if any PP features is disabled
- * due to video and audio concurrency due to MIPS limitation and
- * the video session is ended in ADSP.
- */
-#define AUDPP_MSG_PP_FEATS_RE_ENABLE 0x000D
-
-#endif /* QDSP5AUDPPMSG_H */
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audpreproc.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audpreproc.h
deleted file mode 100644
index 7153c2d..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audpreproc.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-
-#ifndef QDSP5AUDPREPROC_H
-#define _QDSP5AUDPREPROC_H
-
-#include <mach/qdsp5/qdsp5audpreproccmdi.h>
-#include <mach/qdsp5/qdsp5audpreprocmsg.h>
-
-#define MSM_AUD_ENC_MODE_TUNNEL  0x00000100
-#define MSM_AUD_ENC_MODE_NONTUNNEL  0x00000200
-
-#define AUDPREPROC_CODEC_MASK 0x00FF
-#define AUDPREPROC_MODE_MASK 0xFF00
-
-#define MSM_ADSP_ENC_MODE_TUNNEL 24
-#define MSM_ADSP_ENC_MODE_NON_TUNNEL 25
-
-/* event callback routine prototype*/
-typedef void (*audpreproc_event_func)(void *private, unsigned id, void *msg);
-
-struct audpreproc_event_callback {
-	audpreproc_event_func fn;
-	void *private;
-};
-
-/*holds audrec information*/
-struct audrec_session_info {
-	int session_id;
-	int sampling_freq;
-};
-
-/* Exported common api's from audpreproc layer */
-int audpreproc_aenc_alloc(unsigned enc_type, const char **module_name,
-		unsigned *queue_id);
-void audpreproc_aenc_free(int enc_id);
-
-int audpreproc_enable(int enc_id, audpreproc_event_func func, void *private);
-void audpreproc_disable(int enc_id, void *private);
-
-int audpreproc_unregister_event_callback(struct audpreproc_event_callback *ecb);
-
-int audpreproc_register_event_callback(struct audpreproc_event_callback *ecb);
-
-int audpreproc_update_audrec_info(struct audrec_session_info
-						*audrec_session_info);
-int get_audrec_session_info(struct audrec_session_info *info);
-
-int audpreproc_dsp_set_agc(audpreproc_cmd_cfg_agc_params *agc,
-	unsigned len);
-int audpreproc_dsp_set_ns(audpreproc_cmd_cfg_ns_params *ns,
-	unsigned len);
-int audpreproc_dsp_set_iir(audpreproc_cmd_cfg_iir_tuning_filter_params *iir,
-	unsigned len);
-
-int audpreproc_send_preproccmdqueue(void *cmd, unsigned len);
-typedef void (*audrec_event_func)(void *private, unsigned id, uint16_t *msg);
-int audrectask_enable(unsigned enc_type, audrec_event_func func, void *private);
-void audrectask_disable(unsigned enc_type, void *private);
-
-int audrectask_send_cmdqueue(void *cmd, unsigned len);
-int audrectask_send_bitstreamqueue(void *cmd, unsigned len);
-
-#endif /* QDSP5AUDPREPROC_H */
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audpreproccmdi.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audpreproccmdi.h
deleted file mode 100644
index 0fc1e46..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audpreproccmdi.h
+++ /dev/null
@@ -1,268 +0,0 @@
-#ifndef QDSP5AUDPREPROCCMDI_H
-#define QDSP5AUDPREPROCCMDI_H
-
-/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
-*
-*    A U D I O   P R E   P R O C E S S I N G  I N T E R N A L  C O M M A N D S
-*
-* GENERAL DESCRIPTION
-*   This file contains defintions of format blocks of commands
-*   that are accepted by AUDPREPROC Task
-*
-* REFERENCES
-*   None
-*
-* EXTERNALIZED FUNCTIONS
-*   None
-*
-* Copyright (c) 1992-2009, 2012 The Linux Foundation. All rights reserved.
-*
-* This software is licensed under the terms of the GNU General Public
-* License version 2, as published by the Free Software Foundation, and
-* may be copied, distributed, and modified under those terms.
-*
-* 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.
-*
-*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
-/*===========================================================================
-
-                      EDIT HISTORY FOR FILE
-
-This section contains comments describing changes made to this file.
-Notice that changes are listed in reverse chronological order.
-   
-$Header: //source/qcom/qct/multimedia2/Audio/drivers/QDSP5Driver/QDSP5Interface/main/latest/qdsp5audpreproccmdi.h#2 $ 
-  
-===========================================================================*/
-
-/*
- * AUDIOPREPROC COMMANDS:
- * ARM uses uPAudPreProcCmdQueue to communicate with AUDPREPROCTASK
- * Location : MEMB
- * Buffer size : 51
- * Number of buffers in a queue : 3
- */
-
-/*
- * Command to configure the parameters of AGC
- */
-
-#define	AUDPREPROC_CMD_CFG_AGC_PARAMS	0x0000
-#define	AUDPREPROC_CMD_CFG_AGC_PARAMS_LEN	\
-	sizeof(audpreproc_cmd_cfg_agc_params)
-
-#define	AUDPREPROC_CMD_TX_AGC_PARAM_MASK_COMP_SLOPE	0x0009
-#define	AUDPREPROC_CMD_TX_AGC_PARAM_MASK_COMP_TH	0x000A
-#define	AUDPREPROC_CMD_TX_AGC_PARAM_MASK_EXP_SLOPE	0x000B
-#define	AUDPREPROC_CMD_TX_AGC_PARAM_MASK_EXP_TH		0x000C
-#define	AUDPREPROC_CMD_TX_AGC_PARAM_MASK_COMP_AIG_FLAG		0x000D
-#define	AUDPREPROC_CMD_TX_AGC_PARAM_MASK_COMP_STATIC_GAIN	0x000E
-#define	AUDPREPROC_CMD_TX_AGC_PARAM_MASK_TX_AGC_ENA_FLAG	0x000F
-
-#define	AUDPREPROC_CMD_TX_AGC_ENA_FLAG_ENA	-1
-#define	AUDPREPROC_CMD_TX_AGC_ENA_FLAG_DIS	0x0000
-
-#define	AUDPREPROC_CMD_ADP_GAIN_FLAG_ENA_ADP_GAIN	-1
-#define	AUDPREPROC_CMD_ADP_GAIN_FLAG_ENA_STATIC_GAIN	0x0000
-
-#define	AUDPREPROC_CMD_PARAM_MASK_RMS_TAY	0x0004
-#define	AUDPREPROC_CMD_PARAM_MASK_RELEASEK	0x0005
-#define	AUDPREPROC_CMD_PARAM_MASK_DELAY		0x0006
-#define	AUDPREPROC_CMD_PARAM_MASK_ATTACKK	0x0007
-#define	AUDPREPROC_CMD_PARAM_MASK_LEAKRATE_SLOW	0x0008
-#define	AUDPREPROC_CMD_PARAM_MASK_LEAKRATE_FAST	0x0009
-#define	AUDPREPROC_CMD_PARAM_MASK_AIG_RELEASEK 	0x000A
-#define	AUDPREPROC_CMD_PARAM_MASK_AIG_MIN	0x000B
-#define	AUDPREPROC_CMD_PARAM_MASK_AIG_MAX	0x000C
-#define	AUDPREPROC_CMD_PARAM_MASK_LEAK_UP	0x000D
-#define	AUDPREPROC_CMD_PARAM_MASK_LEAK_DOWN	0x000E
-#define	AUDPREPROC_CMD_PARAM_MASK_AIG_ATTACKK	0x000F
-
-typedef struct {
-	unsigned short	cmd_id;
-	unsigned short	tx_agc_param_mask;
-	signed short	tx_agc_enable_flag;
-	unsigned short	comp_rlink_static_gain;
-	signed short	comp_rlink_aig_flag;
-	unsigned short	expander_rlink_th;
-	unsigned short	expander_rlink_slope;
-	unsigned short	compressor_rlink_th;
-	unsigned short	compressor_rlink_slope;
-	unsigned short	tx_adc_agc_param_mask;
-	unsigned short	comp_rlink_aig_attackk;
-	unsigned short	comp_rlink_aig_leak_down;
-	unsigned short	comp_rlink_aig_leak_up;
-	unsigned short	comp_rlink_aig_max;
-	unsigned short	comp_rlink_aig_min;
-	unsigned short	comp_rlink_aig_releasek;
-	unsigned short	comp_rlink_aig_leakrate_fast;
-	unsigned short	comp_rlink_aig_leakrate_slow;
-	unsigned short	comp_rlink_attackk_msw;
-	unsigned short	comp_rlink_attackk_lsw;
-	unsigned short	comp_rlink_delay;
-	unsigned short	comp_rlink_releasek_msw;
-	unsigned short	comp_rlink_releasek_lsw;
-	unsigned short	comp_rlink_rms_tav;
-} __packed audpreproc_cmd_cfg_agc_params;
-
-
-/*
- * Command to configure the params of Advanved AGC
- */
-
-#define	AUDPREPROC_CMD_CFG_AGC_PARAMS_2		0x0001
-#define	AUDPREPROC_CMD_CFG_AGC_PARAMS_2_LEN		\
-	sizeof(audpreproc_cmd_cfg_agc_params_2)
-
-#define	AUDPREPROC_CMD_2_TX_AGC_ENA_FLAG_ENA	-1;
-#define	AUDPREPROC_CMD_2_TX_AGC_ENA_FLAG_DIS	0x0000;
-
-typedef struct {
-	unsigned short	cmd_id;
-	unsigned short	agc_param_mask;
-	signed short	tx_agc_enable_flag;
-	unsigned short	comp_static_gain;
-	unsigned short	exp_th;
-	unsigned short	exp_slope;
-	unsigned short	comp_th;
-	unsigned short	comp_slope;
-	unsigned short	comp_rms_tav;
-	unsigned short	comp_samp_mask;
-	unsigned short	comp_attackk_msw;
-	unsigned short	comp_attackk_lsw;
-	unsigned short	comp_releasek_msw;
-	unsigned short	comp_releasek_lsw;
-	unsigned short	comp_delay;
-	unsigned short	comp_makeup_gain;
-} __attribute__((packed)) audpreproc_cmd_cfg_agc_params_2;
-
-/*
- * Command to configure params for ns
- */
-
-#define	AUDPREPROC_CMD_CFG_NS_PARAMS		0x0002
-#define	AUDPREPROC_CMD_CFG_NS_PARAMS_LEN	\
-	sizeof(audpreproc_cmd_cfg_ns_params)
-
-#define	AUDPREPROC_CMD_EC_MODE_NEW_NLMS_ENA	0x0001
-#define	AUDPREPROC_CMD_EC_MODE_NEW_NLMS_DIS 	0x0000
-#define	AUDPREPROC_CMD_EC_MODE_NEW_DES_ENA	0x0002
-#define	AUDPREPROC_CMD_EC_MODE_NEW_DES_DIS	0x0000
-#define	AUDPREPROC_CMD_EC_MODE_NEW_NS_ENA	0x0004
-#define	AUDPREPROC_CMD_EC_MODE_NEW_NS_DIS	0x0000
-#define	AUDPREPROC_CMD_EC_MODE_NEW_CNI_ENA	0x0008
-#define	AUDPREPROC_CMD_EC_MODE_NEW_CNI_DIS	0x0000
-
-#define	AUDPREPROC_CMD_EC_MODE_NEW_NLES_ENA	0x0010
-#define	AUDPREPROC_CMD_EC_MODE_NEW_NLES_DIS	0x0000
-#define	AUDPREPROC_CMD_EC_MODE_NEW_HB_ENA	0x0020
-#define	AUDPREPROC_CMD_EC_MODE_NEW_HB_DIS	0x0000
-#define	AUDPREPROC_CMD_EC_MODE_NEW_VA_ENA	0x0040
-#define	AUDPREPROC_CMD_EC_MODE_NEW_VA_DIS	0x0000
-#define	AUDPREPROC_CMD_EC_MODE_NEW_PCD_ENA	0x0080
-#define	AUDPREPROC_CMD_EC_MODE_NEW_PCD_DIS	0x0000
-#define	AUDPREPROC_CMD_EC_MODE_NEW_FEHI_ENA	0x0100
-#define	AUDPREPROC_CMD_EC_MODE_NEW_FEHI_DIS 	0x0000
-#define	AUDPREPROC_CMD_EC_MODE_NEW_NEHI_ENA	0x0200
-#define	AUDPREPROC_CMD_EC_MODE_NEW_NEHI_DIS 	0x0000
-#define	AUDPREPROC_CMD_EC_MODE_NEW_NLPP_ENA	0x0400
-#define	AUDPREPROC_CMD_EC_MODE_NEW_NLPP_DIS	0x0000
-#define	AUDPREPROC_CMD_EC_MODE_NEW_FNE_ENA	0x0800
-#define	AUDPREPROC_CMD_EC_MODE_NEW_FNE_DIS	0x0000
-#define	AUDPREPROC_CMD_EC_MODE_NEW_PRENLMS_ENA 	0x1000
-#define	AUDPREPROC_CMD_EC_MODE_NEW_PRENLMS_DIS 	0x0000
-
-typedef struct {
-	unsigned short	cmd_id;
-	unsigned short	ec_mode_new;
-	unsigned short	dens_gamma_n;
-	unsigned short	dens_nfe_block_size;
-	unsigned short	dens_limit_ns;
-	unsigned short	dens_limit_ns_d;
-	unsigned short	wb_gamma_e;
-	unsigned short	wb_gamma_n;
-} __attribute__((packed)) audpreproc_cmd_cfg_ns_params;
-
-/*
- * Command to configure parameters for IIR tuning filter
- */
-
-#define	AUDPREPROC_CMD_CFG_IIR_TUNING_FILTER_PARAMS		0x0003
-#define	AUDPREPROC_CMD_CFG_IIR_TUNING_FILTER_PARAMS_LEN	\
-	sizeof(audpreproc_cmd_cfg_iir_tuning_filter_params)
-
-#define	AUDPREPROC_CMD_IIR_ACTIVE_FLAG_DIS	0x0000
-#define	AUDPREPROC_CMD_IIR_ACTIVE_FLAG_ENA	0x0001
-
-typedef struct {
-	unsigned short	cmd_id;
-	unsigned short	active_flag;
-	unsigned short	num_bands;
-	unsigned short	numerator_coeff_b0_filter0_lsw;
-	unsigned short	numerator_coeff_b0_filter0_msw;
-	unsigned short	numerator_coeff_b1_filter0_lsw;
-	unsigned short	numerator_coeff_b1_filter0_msw;
-	unsigned short	numerator_coeff_b2_filter0_lsw;
-	unsigned short	numerator_coeff_b2_filter0_msw;
-	unsigned short	numerator_coeff_b0_filter1_lsw;
-	unsigned short	numerator_coeff_b0_filter1_msw;
-	unsigned short	numerator_coeff_b1_filter1_lsw;
-	unsigned short	numerator_coeff_b1_filter1_msw;
-	unsigned short	numerator_coeff_b2_filter1_lsw;
-	unsigned short	numerator_coeff_b2_filter1_msw;
-	unsigned short	numerator_coeff_b0_filter2_lsw;
-	unsigned short	numerator_coeff_b0_filter2_msw;
-	unsigned short	numerator_coeff_b1_filter2_lsw;
-	unsigned short	numerator_coeff_b1_filter2_msw;
-	unsigned short	numerator_coeff_b2_filter2_lsw;
-	unsigned short	numerator_coeff_b2_filter2_msw;
-	unsigned short	numerator_coeff_b0_filter3_lsw;
-	unsigned short	numerator_coeff_b0_filter3_msw;
-	unsigned short	numerator_coeff_b1_filter3_lsw;
-	unsigned short	numerator_coeff_b1_filter3_msw;
-	unsigned short	numerator_coeff_b2_filter3_lsw;
-	unsigned short	numerator_coeff_b2_filter3_msw;
-	unsigned short 	denominator_coeff_a0_filter0_lsw;
-	unsigned short 	denominator_coeff_a0_filter0_msw;
-	unsigned short 	denominator_coeff_a1_filter0_lsw;
-	unsigned short 	denominator_coeff_a1_filter0_msw; 
-	unsigned short 	denominator_coeff_a0_filter1_lsw;
-	unsigned short 	denominator_coeff_a0_filter1_msw;
-	unsigned short 	denominator_coeff_a1_filter1_lsw;
-	unsigned short 	denominator_coeff_a1_filter1_msw;
-  unsigned short 	denominator_coeff_a0_filter2_lsw;
-	unsigned short 	denominator_coeff_a0_filter2_msw;
-	unsigned short 	denominator_coeff_a1_filter2_lsw;
-	unsigned short 	denominator_coeff_a1_filter2_msw;
-  unsigned short 	denominator_coeff_a0_filter3_lsw;
-	unsigned short 	denominator_coeff_a0_filter3_msw;
-	unsigned short 	denominator_coeff_a1_filter3_lsw;
-	unsigned short 	denominator_coeff_a1_filter3_msw;
-
-	unsigned short	shift_factor_filter0;
-	unsigned short	shift_factor_filter1;
-	unsigned short	shift_factor_filter2;
-	unsigned short	shift_factor_filter3;
-
-	unsigned short	channel_selected0;
-	unsigned short	channel_selected1;
-	unsigned short	channel_selected2;
-	unsigned short	channel_selected3;
-} __attribute__((packed))audpreproc_cmd_cfg_iir_tuning_filter_params;
-
-#define AUDPREPROC_CMD_FEAT_QUERY_PARAMS 0x0004
-
-struct rtc_audpreproc_read_data {
-	unsigned short	cmd_id;
-	unsigned short	stream_id;
-	unsigned short  feature_id;
-	unsigned short  extbufsizemsw;
-	unsigned short  extbufsizelsw;
-	unsigned short  extpart;
-	unsigned short  extbufstartmsw;
-	unsigned short	extbufstartlsw;
-} __packed ;
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audpreprocmsg.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audpreprocmsg.h
deleted file mode 100644
index 6a93279..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audpreprocmsg.h
+++ /dev/null
@@ -1,86 +0,0 @@
-#ifndef QDSP5AUDPREPROCMSG_H
-#define QDSP5AUDPREPROCMSG_H
-
-/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
-*
-*     A U D I O   P R E   P R O C E S S I N G  M E S S A G E S
-*
-* GENERAL DESCRIPTION
-*   This file contains defintions of format blocks of messages
-*   that are rcvd by AUDPREPROC Task
-*
-* REFERENCES
-*   None
-*
-* EXTERNALIZED FUNCTIONS
-*   None
-*
-* Copyright (c) 1992-2009, 2012 The Linux Foundation. All rights reserved.
-*
-* This software is licensed under the terms of the GNU General Public
-* License version 2, as published by the Free Software Foundation, and
-* may be copied, distributed, and modified under those terms.
-*
-* 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.
-*
-*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
-/*===========================================================================
-
-                      EDIT HISTORY FOR FILE
-
-This section contains comments describing changes made to this file.
-Notice that changes are listed in reverse chronological order.
-   
- $Header: //source/qcom/qct/multimedia2/Audio/drivers/QDSP5Driver/QDSP5Interface/main/latest/qdsp5audpreprocmsg.h#3 $
-  
-===========================================================================*/
-
-/*
- * ADSPREPROCTASK Messages
- * AUDPREPROCTASK uses audPreProcUpRlist to communicate with ARM
- * Location	: MEMA
- * Message Length  : 2
- */
-
-/*
- * Message to indicate particular feature has been enabled or disabled
- */
-
-
-#define	AUDPREPROC_MSG_CMD_CFG_DONE_MSG	0x0001
-#define	AUDPREPROC_MSG_CMD_CFG_DONE_MSG_LEN	\
-	sizeof(audpreproc_msg_cmd_cfg_done_msg)
-
-#define	AUDPREPROC_MSG_TYPE_AGC			0x0000
-#define	AUDPREPROC_MSG_TYPE_NOISE_REDUCTION	0x0001
-#define	AUDPREPROC_MSG_TYPE_IIR_FILTER		0x0002
-
-
-#define	AUDPREPROC_MSG_STATUS_FLAG_ENA		-1
-#define	AUDPREPROC_MSG_STATUS_FLAG_DIS		0x0000
-
-typedef struct {
-	unsigned short	type;
-	signed short	status_flag;
-} __attribute__((packed)) audpreproc_msg_cmd_cfg_done_msg;
-
-
-/*
- * Message to indicate particular feature has selected for wrong samp freq
- */
-
-#define	AUDPREPROC_MSG_ERROR_MSG_ID		0x0002
-#define	AUDPREPROC_MSG_ERROR_MSG_ID_LEN	\
-	sizeof(audpreproc_msg_error_msg_id)
-
-#define	AUDPREPROC_MSG_ERR_INDEX_NS		0x0000
-
-typedef struct {
-	 unsigned short	err_index;
-} __attribute__((packed)) audpreproc_msg_error_msg_id;
-
-#define AUDPREPROC_MSG_FEAT_QUERY_DM_DONE 0x0003
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audreccmdi.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audreccmdi.h
deleted file mode 100644
index 72f12c9..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audreccmdi.h
+++ /dev/null
@@ -1,401 +0,0 @@
-#ifndef QDSP5AUDRECCMDI_H
-#define QDSP5AUDRECCMDI_H
-
-/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
- *
- *    A U D I O   R E C O R D  I N T E R N A L  C O M M A N D S
- *
- * GENERAL DESCRIPTION
- *   This file contains defintions of format blocks of commands
- *   that are accepted by AUDREC Task
- *
- * REFERENCES
- *   None
- *
- * EXTERNALIZED FUNCTIONS
- *  None
- *
- * Copyright (c) 1992-2009, 2011 The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- *====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
-
-/*===========================================================================
-
-                      EDIT HISTORY FOR FILE
-
-This section contains comments describing changes made to this file.
-Notice that changes are listed in reverse chronological order.
-   
- $Header: //source/qcom/qct/multimedia2/Audio/drivers/QDSP5Driver/QDSP5Interface/main/latest/qdsp5audreccmdi.h#3 $
-  
-============================================================================*/
-
-/*
- * AUDRECTASK COMMANDS
- * ARM uses 2 queues to communicate with the AUDRECTASK
- * 1.uPAudRecCmdQueue
- * Location :MEMC
- * Buffer Size : 8
- * No of Buffers in a queue : 3
- * 2.audRecUpBitStreamQueue
- * Location : MEMC
- * Buffer Size : 4
- * No of buffers in a queue : 2
- */
-
-/*
- * Commands on uPAudRecCmdQueue 
- */
-
-/*
- * Command to initiate and terminate the audio recording section
- */
-
-#define AUDREC_CMD_CFG		0x0000
-#define	AUDREC_CMD_CFG_LEN	sizeof(audrec_cmd_cfg)
-
-#define	AUDREC_CMD_TYPE_0_INDEX_WAV	0x0000
-#define	AUDREC_CMD_TYPE_0_INDEX_AAC	0x0001
-#define	AUDREC_CMD_TYPE_0_INDEX_AMRNB	0x000A
-#define	AUDREC_CMD_TYPE_0_INDEX_EVRC	0x000B
-#define	AUDREC_CMD_TYPE_0_INDEX_QCELP	0x000C
-
-#define AUDREC_CMD_TYPE_0_ENA		0x4000
-#define AUDREC_CMD_TYPE_0_DIS		0x0000
-
-#define AUDREC_CMD_TYPE_0_NOUPDATE	0x0000
-#define AUDREC_CMD_TYPE_0_UPDATE	0x8000
-
-#define	AUDREC_CMD_TYPE_1_INDEX_SBC	0x0002
-
-#define AUDREC_CMD_TYPE_1_ENA		0x4000
-#define AUDREC_CMD_TYPE_1_DIS		0x0000
-
-#define AUDREC_CMD_TYPE_1_NOUPDATE	0x0000
-#define AUDREC_CMD_TYPE_1_UPDATE	0x8000
-
-typedef struct {
-	unsigned short 	cmd_id;
-	unsigned short	type_0;
-	unsigned short	type_1;
-} __attribute__((packed)) audrec_cmd_cfg;
-
-
-/*
- * Command to configure the recording parameters for RecType0(AAC/WAV) encoder
- */
-
-#define	AUDREC_CMD_AREC0PARAM_CFG	0x0001
-#define	AUDREC_CMD_AREC0PARAM_CFG_LEN	\
-	sizeof(audrec_cmd_arec0param_cfg)
-
-#define	AUDREC_CMD_SAMP_RATE_INDX_8000		0x000B
-#define	AUDREC_CMD_SAMP_RATE_INDX_11025		0x000A
-#define	AUDREC_CMD_SAMP_RATE_INDX_12000		0x0009
-#define	AUDREC_CMD_SAMP_RATE_INDX_16000		0x0008
-#define	AUDREC_CMD_SAMP_RATE_INDX_22050		0x0007
-#define	AUDREC_CMD_SAMP_RATE_INDX_24000		0x0006
-#define	AUDREC_CMD_SAMP_RATE_INDX_32000		0x0005
-#define	AUDREC_CMD_SAMP_RATE_INDX_44100		0x0004
-#define	AUDREC_CMD_SAMP_RATE_INDX_48000		0x0003
-
-#define AUDREC_CMD_STEREO_MODE_MONO		0x0000
-#define AUDREC_CMD_STEREO_MODE_STEREO		0x0001
-
-typedef struct {
-	unsigned short 	cmd_id;
-	unsigned short	ptr_to_extpkt_buffer_msw;
-	unsigned short	ptr_to_extpkt_buffer_lsw;
-	unsigned short	buf_len;
-	unsigned short	samp_rate_index;
-	unsigned short	stereo_mode;
-	unsigned short 	rec_quality;
-} __attribute__((packed)) audrec_cmd_arec0param_cfg;
-
-/*
- * Command to configure the recording parameters for RecType1(SBC) encoder
- */
-
-#define AUDREC_CMD_AREC1PARAM_CFG	0x0002
-#define AUDREC_CMD_AREC1PARAM_CFG_LEN	\
-	sizeof(audrec_cmd_arec1param_cfg)
-
-#define AUDREC_CMD_PARAM_BUF_BLOCKS_4	0x0000
-#define AUDREC_CMD_PARAM_BUF_BLOCKS_8	0x0001
-#define AUDREC_CMD_PARAM_BUF_BLOCKS_12	0x0002
-#define AUDREC_CMD_PARAM_BUF_BLOCKS_16	0x0003
-
-#define AUDREC_CMD_PARAM_BUF_SUB_BANDS_8	0x0010
-#define AUDREC_CMD_PARAM_BUF_MODE_MONO		0x0000
-#define AUDREC_CMD_PARAM_BUF_MODE_DUAL		0x0040
-#define AUDREC_CMD_PARAM_BUF_MODE_STEREO	0x0050
-#define AUDREC_CMD_PARAM_BUF_MODE_JSTEREO	0x0060
-#define AUDREC_CMD_PARAM_BUF_LOUDNESS		0x0000
-#define AUDREC_CMD_PARAM_BUF_SNR		0x0100
-#define AUDREC_CMD_PARAM_BUF_BASIC_VER		0x0000
-
-typedef struct {
-	unsigned short 	cmd_id;
-	unsigned short	ptr_to_extpkt_buffer_msw;
-	unsigned short	ptr_to_extpkt_buffer_lsw;
-	unsigned short	buf_len;
-	unsigned short	param_buf;
-	unsigned short	bit_rate_0;
-	unsigned short	bit_rate_1;
-} __attribute__((packed)) audrec_cmd_arec1param_cfg;
-
-/*
- * Command to enable encoder for the recording
- */
-
-#define AUDREC_CMD_ENC_CFG	0x0003
-#define AUDREC_CMD_ENC_CFG_LEN	\
-	sizeof(struct audrec_cmd_enc_cfg)
-
-
-#define AUDREC_CMD_ENC_ENA		0x8000
-#define AUDREC_CMD_ENC_DIS		0x0000
-
-#define AUDREC_CMD_ENC_TYPE_MASK	0x001F
-
-struct audrec_cmd_enc_cfg {
-	unsigned short 	cmd_id;
-	unsigned short	audrec_enc_type;
-	unsigned short	audrec_obj_idx;
-} __attribute__((packed));
-
-/*
- * Command to set external memory config for the selected encoder
- */
-
-#define AUDREC_CMD_ARECMEM_CFG	0x0004
-#define AUDREC_CMD_ARECMEM_CFG_LEN	\
-	sizeof(struct audrec_cmd_arecmem_cfg)
-
-
-struct audrec_cmd_arecmem_cfg {
-	unsigned short 	cmd_id;
-	unsigned short	audrec_obj_idx;
-	unsigned short	audrec_up_pkt_intm_cnt;
-	unsigned short	audrec_extpkt_buffer_msw;
-	unsigned short	audrec_extpkt_buffer_lsw;
-	unsigned short	audrec_extpkt_buffer_num;
-} __attribute__((packed));
-
-/*
- * Command to configure the recording parameters for selected encoder
- */
-
-#define AUDREC_CMD_ARECPARAM_CFG	0x0005
-#define AUDREC_CMD_ARECPARAM_COMMON_CFG_LEN	\
-	sizeof(struct audrec_cmd_arecparam_common_cfg)
-
-
-struct audrec_cmd_arecparam_common_cfg {
-	unsigned short 	cmd_id;
-	unsigned short	audrec_obj_idx;
-} __attribute__((packed));
-
-#define AUDREC_CMD_ARECPARAM_WAV_CFG_LEN	\
-	sizeof(struct audrec_cmd_arecparam_wav_cfg)
-
-
-struct audrec_cmd_arecparam_wav_cfg {
-	struct audrec_cmd_arecparam_common_cfg common;
-	unsigned short 	samp_rate_idx;
-	unsigned short  stereo_mode;
-} __attribute__((packed));
-
-#define AUDREC_CMD_ARECPARAM_AAC_CFG_LEN	\
-	sizeof(struct audrec_cmd_arecparam_aac_cfg)
-
-
-struct audrec_cmd_arecparam_aac_cfg {
-	struct audrec_cmd_arecparam_common_cfg common;
-	unsigned short 	samp_rate_idx;
-	unsigned short  stereo_mode;
-	unsigned short  rec_quality;
-} __attribute__((packed));
-
-#define AUDREC_CMD_ARECPARAM_SBC_CFG_LEN	\
-	sizeof(struct audrec_cmd_arecparam_sbc_cfg)
-
-
-struct audrec_cmd_arecparam_sbc_cfg {
-	struct audrec_cmd_arecparam_common_cfg common;
-	unsigned short 	param_buf;
-	unsigned short  bit_rate_0;
-	unsigned short  bit_rate_1;
-} __attribute__((packed));
-
-#define AUDREC_CMD_ARECPARAM_AMRNB_CFG_LEN	\
-	sizeof(struct audrec_cmd_arecparam_amrnb_cfg)
-
-
-struct audrec_cmd_arecparam_amrnb_cfg {
-	struct audrec_cmd_arecparam_common_cfg common;
-	unsigned short 	samp_rate_idx;
-	unsigned short 	voicememoencweight1;
-	unsigned short 	voicememoencweight2;
-	unsigned short 	voicememoencweight3;
-	unsigned short 	voicememoencweight4;
-	unsigned short 	update_mode;
-	unsigned short 	dtx_mode;
-	unsigned short 	test_mode;
-	unsigned short 	used_mode;
-} __attribute__((packed));
-
-#define AUDREC_CMD_ARECPARAM_EVRC_CFG_LEN	\
-	sizeof(struct audrec_cmd_arecparam_evrc_cfg)
-
-
-struct audrec_cmd_arecparam_evrc_cfg {
-	struct audrec_cmd_arecparam_common_cfg common;
-	unsigned short 	samp_rate_idx;
-	unsigned short 	voicememoencweight1;
-	unsigned short 	voicememoencweight2;
-	unsigned short 	voicememoencweight3;
-	unsigned short 	voicememoencweight4;
-	unsigned short 	update_mode;
-	unsigned short 	enc_min_rate;
-	unsigned short 	enc_max_rate;
-	unsigned short 	rate_modulation_cmd;
-} __attribute__((packed));
-
-#define AUDREC_CMD_ARECPARAM_QCELP_CFG_LEN	\
-	sizeof(struct audrec_cmd_arecparam_qcelp_cfg)
-
-
-struct audrec_cmd_arecparam_qcelp_cfg {
-	struct audrec_cmd_arecparam_common_cfg common;
-	unsigned short 	samp_rate_idx;
-	unsigned short 	voicememoencweight1;
-	unsigned short 	voicememoencweight2;
-	unsigned short 	voicememoencweight3;
-	unsigned short 	voicememoencweight4;
-	unsigned short 	update_mode;
-	unsigned short 	enc_min_rate;
-	unsigned short 	enc_max_rate;
-	unsigned short 	rate_modulation_cmd;
-	unsigned short 	reduced_rate_level;
-} __attribute__((packed));
-
-#define AUDREC_CMD_ARECPARAM_FGVNB_CFG_LEN	\
-	sizeof(struct audrec_cmd_arecparam_fgvnb_cfg)
-
-
-struct audrec_cmd_arecparam_fgvnb_cfg {
-	struct audrec_cmd_arecparam_common_cfg common;
-	unsigned short 	samp_rate_idx;
-	unsigned short 	voicememoencweight1;
-	unsigned short 	voicememoencweight2;
-	unsigned short 	voicememoencweight3;
-	unsigned short 	voicememoencweight4;
-	unsigned short 	update_mode;
-	unsigned short 	fgv_min_rate;
-	unsigned short 	fgv_max_rate;
-	unsigned short 	reduced_rate_level;
-} __attribute__((packed));
-
-/*
- * Command to configure Tunnel(RT) or Non-Tunnel(FTRT) mode
- */
-
-#define AUDREC_CMD_ROUTING_MODE		0x0006
-#define	AUDREC_CMD_ROUTING_MODE_LEN	\
-	sizeof(struct audpreproc_audrec_cmd_routing_mode)
-
-#define AUDIO_ROUTING_MODE_FTRT		0x0001
-#define AUDIO_ROUTING_MODE_RT		0x0002
-
-struct audrec_cmd_routing_mode {
-	unsigned short cmd_id;
-	unsigned short routing_mode;
-} __packed;
-
-/*
- * Command to configure pcm input memory
- */
-
-#define AUDREC_CMD_PCM_CFG_ARM_TO_ENC 0x0007
-#define AUDREC_CMD_PCM_CFG_ARM_TO_ENC_LEN	\
-	sizeof(struct audrec_cmd_pcm_cfg_arm_to_enc)
-
-struct audrec_cmd_pcm_cfg_arm_to_enc {
-	unsigned short cmd_id;
-	unsigned short config_update_flag;
-	unsigned short enable_flag;
-	unsigned short sampling_freq;
-	unsigned short channels;
-	unsigned short frequency_of_intimation;
-	unsigned short max_number_of_buffers;
-} __packed;
-
-#define AUDREC_PCM_CONFIG_UPDATE_FLAG_ENABLE -1
-#define AUDREC_PCM_CONFIG_UPDATE_FLAG_DISABLE 0
-
-#define AUDREC_ENABLE_FLAG_VALUE -1
-#define AUDREC_DISABLE_FLAG_VALUE 0
-
-/*
- * Command to intimate available pcm buffer
- */
-
-#define AUDREC_CMD_PCM_BUFFER_PTR_REFRESH_ARM_TO_ENC 0x0008
-#define AUDREC_CMD_PCM_BUFFER_PTR_REFRESH_ARM_TO_ENC_LEN \
-	sizeof(struct audrec_cmd_pcm_buffer_ptr_refresh_arm_enc)
-
-struct audrec_cmd_pcm_buffer_ptr_refresh_arm_enc {
-	unsigned short cmd_id;
-	unsigned short num_buffers;
-	unsigned short buffer_write_cnt_msw;
-	unsigned short buffer_write_cnt_lsw;
-	unsigned short buf_address_length[8];/*this array holds address
-						and length details of
-						two buffers*/
-} __packed;
-
-/*
- * Command to flush
- */
-
-#define AUDREC_CMD_FLUSH 0x009
-#define AUDREC_CMD_FLUSH_LEN	\
-	sizeof(struct audrec_cmd_flush)
-
-struct audrec_cmd_flush {
-	unsigned short cmd_id;
-} __packed;
-
-/*
- * Commands on audRecUpBitStreamQueue
- */
-
-/*
- * Command to indicate the current packet read count
- */
-
-#define AUDREC_CMD_PACKET_EXT_PTR		0x0000
-#define AUDREC_CMD_PACKET_EXT_PTR_LEN	\
-	sizeof(audrec_cmd_packet_ext_ptr)
-
-#define AUDREC_CMD_TYPE_0	0x0000
-#define AUDREC_CMD_TYPE_1	0x0001
-
-typedef struct {
-	unsigned short  cmd_id;
-	unsigned short	type; /* audrec_obj_idx */
-	unsigned short 	curr_rec_count_msw;
-	unsigned short 	curr_rec_count_lsw;
-} __attribute__((packed)) audrec_cmd_packet_ext_ptr;
-
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audrecmsg.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audrecmsg.h
deleted file mode 100644
index 22bdaa2..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5audrecmsg.h
+++ /dev/null
@@ -1,223 +0,0 @@
-#ifndef QDSP5AUDRECMSGI_H
-#define QDSP5AUDRECMSGI_H
-
-/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
- *
- *    A U D I O   R E C O R D  M E S S A G E S
- *
- * GENERAL DESCRIPTION
- *  This file contains defintions of format blocks of messages
- *  that are sent by AUDREC Task
- *
- * REFERENCES
- *   None
- *
- * EXTERNALIZED FUNCTIONS
- *  None
- *
- * Copyright (c) 1992-2009, 2011 The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- *====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
-
-/*===========================================================================
-
-                      EDIT HISTORY FOR FILE
-
-This section contains comments describing changes made to this file.
-Notice that changes are listed in reverse chronological order.
-   
- $Header: //source/qcom/qct/multimedia2/Audio/drivers/QDSP5Driver/QDSP5Interface/main/latest/qdsp5audrecmsg.h#3 $
-
-============================================================================*/
-
-/*
- * AUDRECTASK MESSAGES
- * AUDRECTASK uses audRecUpRlist to communicate with ARM
- * Location : MEMC
- * Buffer size : 4
- * No of buffers in a queue : 2
- */
-
-/*
- * Message to notify that config command is done
- */
-
-#define AUDREC_MSG_CMD_CFG_DONE_MSG	0x0002
-#define AUDREC_MSG_CMD_CFG_DONE_MSG_LEN	\
-	sizeof(struct audrec_msg_cmd_cfg_done_msg)
-
-
-#define AUDREC_MSG_CFG_DONE_TYPE_0_ENA		0x4000
-#define AUDREC_MSG_CFG_DONE_TYPE_0_DIS		0x0000
-
-#define AUDREC_MSG_CFG_DONE_TYPE_0_NO_UPDATE	0x0000
-#define AUDREC_MSG_CFG_DONE_TYPE_0_UPDATE	0x8000
-
-#define AUDREC_MSG_CFG_DONE_TYPE_1_ENA		0x4000
-#define AUDREC_MSG_CFG_DONE_TYPE_1_DIS		0x0000
-
-#define AUDREC_MSG_CFG_DONE_TYPE_1_NO_UPDATE	0x0000
-#define AUDREC_MSG_CFG_DONE_TYPE_1_UPDATE	0x8000
-
-#define AUDREC_MSG_CFG_DONE_ENC_ENA		0x8000
-#define AUDREC_MSG_CFG_DONE_ENC_DIS		0x0000
-
-struct audrec_msg_cmd_cfg_done_msg {
-	unsigned short	audrec_enc_type;
-	unsigned short	audrec_obj_idx;
-} __attribute__((packed));
-
-/*
- * Message to notify arec0/1 or concurrent encoder cfg done
- * and recording params recieved by task
- */
-
-#define	AUDREC_MSG_CMD_AREC_PARAM_CFG_DONE_MSG		0x0003
-#define	AUDREC_MSG_CMD_AREC_PARAM_CFG_DONE_MSG_LEN	\
-	sizeof(struct audrec_msg_cmd_arec_param_cfg_done_msg)
-
-
-#define	AUDREC_MSG_AREC_PARAM_TYPE_0	0x0000
-#define	AUDREC_MSG_AREC_PARAM_TYPE_1	0x0001
-
-struct audrec_msg_cmd_arec_param_cfg_done_msg {
-	unsigned short	audrec_obj_idx;
-} __attribute__((packed));
-
-/*
- * Message to notify no more buffers are available in ext mem to DME
- * Or no concurrent encoder supported
- */
-/* for 7x27 */
-#define AUDREC_MSG_FATAL_ERR_MSG		0x0004
-#define AUDREC_MSG_FATAL_ERR_MSG_LEN	\
-	sizeof(struct audrec_msg_fatal_err_msg)
-
-
-#define AUDREC_MSG_FATAL_ERR_TYPE_0	0x0000
-#define AUDREC_MSG_FATAL_ERR_TYPE_1	0x0001
-
-struct audrec_msg_fatal_err_msg {
-	unsigned short	audrec_obj_idx;
-	unsigned short	audrec_err_id;
-} __attribute__((packed));
-
-/* for 7x27A */
-#define AUDREC_MSG_NO_EXT_PKT_AVAILABLE_MSG		0x0004
-#define AUDREC_MSG_NO_EXT_PKT_AVAILABLE_MSG_LEN	\
-	sizeof(struct audrec_msg_no_ext_pkt_avail_msg)
-
-#define AUDREC_MSG_NO_EXT_PKT_AVAILABLE_TYPE_0	0x0000
-#define AUDREC_MSG_NO_EXT_PKT_AVAILABLE_TYPE_1	0x0001
-
-struct audrec_msg_no_ext_pkt_avail_msg {
-	unsigned short	audrec_obj_idx;
-	unsigned short	audrec_err_id;
-} __packed;
-
-/*
- * Message to notify DME deliverd the encoded pkt to ext pkt buffer
- */
-
-#define AUDREC_MSG_PACKET_READY_MSG		0x0005
-#define AUDREC_MSG_PACKET_READY_MSG_LEN	\
-	sizeof(struct audrec_msg_packet_ready_msg)
-
-
-#define AUDREC_MSG_PACKET_READY_TYPE_0	0x0000
-#define AUDREC_MSG_PACKET_READY_TYPE_1	0x0001
-
-struct audrec_msg_packet_ready_msg {
-	unsigned short	audrec_obj_idx;
-	unsigned short	pkt_counter_msw;
-	unsigned short	pkt_counter_lsw;
-	unsigned short	pkt_read_cnt_msw;
-	unsigned short	pkt_read_cnt_lsw;
-} __attribute__((packed));
-
-/*
- * Message to notify external memory cfg done and recieved by task
- */
-
-#define	AUDREC_MSG_CMD_AREC_MEM_CFG_DONE_MSG		0x0006
-#define	AUDREC_MSG_CMD_AREC_MEM_CFG_DONE_MSG_LEN	\
-	sizeof(struct audrec_msg_cmd_arec_mem_cfg_done_msg)
-
-
-struct audrec_msg_cmd_arec_mem_cfg_done_msg {
-	unsigned short	audrec_obj_idx;
-} __attribute__((packed));
-
-/*
- * Message to indicate Routing mode
- * configuration success or failure
- */
-
-#define AUDREC_MSG_CMD_ROUTING_MODE_DONE_MSG		 0x0007
-#define AUDREC_MSG_CMD_ROUTING_MODE_DONE_MSG_LEN	 \
-	sizeof(struct audrec_msg_cmd_routing_mode_done_msg)
-
-struct audrec_msg_cmd_routing_mode_done_msg {
-	unsigned short configuration;
-} __packed;
-
-/*
- * Message to indicate pcm buffer configured
- */
-
-#define AUDREC_CMD_PCM_CFG_ARM_TO_ENC_DONE_MSG		0x0008
-#define AUDREC_CMD_PCM_CFG_ARM_TO_ENC_DONE_MSG_LEN	\
-	sizeof(struct audrec_cmd_pcm_cfg_arm_to_enc_msg)
-
-struct  audrec_cmd_pcm_cfg_arm_to_enc_msg {
-	unsigned short configuration;
-} __packed;
-
-/*
- * Message to indicate encoded packet is delivered to external buffer in FTRT
- */
-
-#define AUDREC_UP_NT_PACKET_READY_MSG			0x0009
-#define AUDREC_UP_NT_PACKET_READY_MSG_LEN	\
-	sizeof(struct audrec_up_nt_packet_ready_msg)
-
-struct  audrec_up_nt_packet_ready_msg {
-	unsigned short audrec_packetwrite_cnt_lsw;
-	unsigned short audrec_packetwrite_cnt_msw;
-	unsigned short audrec_upprev_readcount_lsw;
-	unsigned short audrec_upprev_readcount_msw;
-} __packed;
-
-/*
- * Message to indicate pcm buffer is consumed
- */
-
-#define AUDREC_CMD_PCM_BUFFER_PTR_UPDATE_ARM_TO_ENC_MSG 0x000A
-#define AUDREC_CMD_PCM_BUFFER_PTR_UPDATE_ARM_TO_ENC_MSG_LEN	\
-	sizeof(struct audrec_cmd_pcm_buffer_ptr_update_arm_to_enc_msg)
-
-struct  audrec_cmd_pcm_buffer_ptr_update_arm_to_enc_msg {
-	unsigned short buffer_readcnt_msw;
-	unsigned short buffer_readcnt_lsw;
-	unsigned short number_of_buffers;
-	unsigned short buffer_address_length[];
-} __packed;
-
-/*
- * Message to indicate flush acknowledgement
- */
-
-#define AUDREC_CMD_FLUSH_DONE_MSG			0x000B
-
-#define ADSP_MESSAGE_ID 0xFFFF
-
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5jpegcmdi.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5jpegcmdi.h
deleted file mode 100644
index 40e96d7..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5jpegcmdi.h
+++ /dev/null
@@ -1,377 +0,0 @@
-#ifndef QDSP5VIDJPEGCMDI_H
-#define QDSP5VIDJPEGCMDI_H
-
-/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
-
-    J P E G  I N T E R N A L  C O M M A N D S
-
-GENERAL DESCRIPTION
-  This file contains defintions of format blocks of commands 
-  that are accepted by JPEG Task
-
-REFERENCES
-  None
-
-EXTERNALIZED FUNCTIONS
-  None
-
-Copyright (c) 1992-2009, The Linux Foundation. All rights reserved.
-
-This software is licensed under the terms of the GNU General Public
-License version 2, as published by the Free Software Foundation, and
-may be copied, distributed, and modified under those terms.
- 
-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.
-
-*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
-/*===========================================================================
-
-                      EDIT HISTORY FOR FILE
-
-This section contains comments describing changes made to this file.
-Notice that changes are listed in reverse chronological order.
-   
- 
-$Header: //source/qcom/qct/multimedia2/AdspSvc/7XXX/qdsp5cmd/video/qdsp5jpegcmdi.h#2 $ $DateTime: 2008/07/30 10:50:23 $ $Author: pavanr $                     
-Revision History:                                            
-when       who     what, where, why
---------   ---     ----------------------------------------------------------
-06/09/08   sv      initial version
-===========================================================================*/
-
-/*
- * ARM to JPEG configuration commands are passed through the
- * uPJpegCfgCmdQueue
- */
-
-/*
- * Command to configure JPEG Encoder
- */
-
-#define	JPEG_CMD_ENC_CFG		0x0000
-#define	JPEG_CMD_ENC_CFG_LEN	sizeof(jpeg_cmd_enc_cfg)
-
-#define	JPEG_CMD_ENC_PROCESS_CFG_OP_ROTATION_0		0x0000
-#define	JPEG_CMD_ENC_PROCESS_CFG_OP_ROTATION_90		0x0100
-#define	JPEG_CMD_ENC_PROCESS_CFG_OP_ROTATION_180	0x0200
-#define	JPEG_CMD_ENC_PROCESS_CFG_OP_ROTATION_270	0x0300
-#define	JPEG_CMD_ENC_PROCESS_CFG_IP_DATA_FORMAT_M	0x0003
-#define	JPEG_CMD_ENC_PROCESS_CFG_IP_DATA_FORMAT_H2V2	0x0000
-#define	JPEG_CMD_ENC_PROCESS_CFG_IP_DATA_FORMAT_H2V1	0x0001
-#define	JPEG_CMD_ENC_PROCESS_CFG_IP_DATA_FORMAT_H1V2	0x0002
-
-#define	JPEG_CMD_IP_SIZE_CFG_LUMA_HEIGHT_M		0x0000FFFF
-#define	JPEG_CMD_IP_SIZE_CFG_LUMA_WIDTH_M		0xFFFF0000
-#define	JPEG_CMD_ENC_UPSAMP_IP_SIZE_CFG_ENA		0x0001
-#define	JPEG_CMD_ENC_UPSAMP_IP_SIZE_CFG_DIS		0x0000
-
-#define	JPEG_CMD_FRAG_SIZE_LUMA_HEIGHT_M		0xFFFF
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	process_cfg;
-	unsigned int	ip_size_cfg;
-	unsigned int	op_size_cfg;
-	unsigned int	frag_cfg;
-	unsigned int	frag_cfg_part[16];
-
-	unsigned int    part_num;
-
-	unsigned int	op_buf_0_cfg_part1;
-	unsigned int	op_buf_0_cfg_part2;
-	unsigned int	op_buf_1_cfg_part1;
-	unsigned int	op_buf_1_cfg_part2;
-
-	unsigned int	luma_qunt_table[32];
-	unsigned int	chroma_qunt_table[32];
-
-	unsigned int	upsamp_ip_size_cfg;
-	unsigned int	upsamp_ip_frame_off;
-	unsigned int	upsamp_pp_filter_coeff[64];
-} __attribute__((packed)) jpeg_cmd_enc_cfg;
-
-/*
- * Command to configure JPEG Decoder
- */
-
-#define	JPEG_CMD_DEC_CFG		0x0001
-#define	JPEG_CMD_DEC_CFG_LEN		sizeof(jpeg_cmd_dec_cfg)
-
-#define	JPEG_CMD_DEC_OP_DATA_FORMAT_M		0x0001
-#define JPEG_CMD_DEC_OP_DATA_FORMAT_H2V2	0x0000
-#define JPEG_CMD_DEC_OP_DATA_FORMAT_H2V1	0x0001
-
-#define JPEG_CMD_DEC_OP_DATA_FORMAT_SCALE_FACTOR_8	0x000000
-#define JPEG_CMD_DEC_OP_DATA_FORMAT_SCALE_FACTOR_4	0x010000
-#define JPEG_CMD_DEC_OP_DATA_FORMAT_SCALE_FACTOR_2	0x020000
-#define JPEG_CMD_DEC_OP_DATA_FORMAT_SCALE_FACTOR_1	0x030000
-
-#define	JPEG_CMD_DEC_IP_STREAM_BUF_CFG_PART3_NOT_FINAL	0x0000
-#define	JPEG_CMD_DEC_IP_STREAM_BUF_CFG_PART3_FINAL	0x0001
-
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	img_dimension_cfg;
-	unsigned int	op_data_format;
-	unsigned int	restart_interval;
-	unsigned int	ip_buf_partition_num;
-	unsigned int	ip_stream_buf_cfg_part1;
-	unsigned int	ip_stream_buf_cfg_part2;
-	unsigned int	ip_stream_buf_cfg_part3;
-	unsigned int	op_stream_buf_0_cfg_part1;
-	unsigned int	op_stream_buf_0_cfg_part2;
-	unsigned int	op_stream_buf_0_cfg_part3;
-	unsigned int	op_stream_buf_1_cfg_part1;
-	unsigned int	op_stream_buf_1_cfg_part2;
-	unsigned int	op_stream_buf_1_cfg_part3;
-	unsigned int	luma_qunt_table_0_3;
-	unsigned int	luma_qunt_table_4_7;
-	unsigned int	luma_qunt_table_8_11;
-	unsigned int	luma_qunt_table_12_15;
-	unsigned int	luma_qunt_table_16_19;
-	unsigned int	luma_qunt_table_20_23;
-	unsigned int	luma_qunt_table_24_27;
-	unsigned int	luma_qunt_table_28_31;
-	unsigned int	luma_qunt_table_32_35;
-	unsigned int	luma_qunt_table_36_39;
-	unsigned int	luma_qunt_table_40_43;
-	unsigned int	luma_qunt_table_44_47;
-	unsigned int	luma_qunt_table_48_51;
-	unsigned int	luma_qunt_table_52_55;
-	unsigned int	luma_qunt_table_56_59;
-	unsigned int	luma_qunt_table_60_63;
-	unsigned int	chroma_qunt_table_0_3;
-	unsigned int	chroma_qunt_table_4_7;
-	unsigned int	chroma_qunt_table_8_11;
-	unsigned int	chroma_qunt_table_12_15;
-	unsigned int	chroma_qunt_table_16_19;
-	unsigned int	chroma_qunt_table_20_23;
-	unsigned int	chroma_qunt_table_24_27;
-	unsigned int	chroma_qunt_table_28_31;
-	unsigned int	chroma_qunt_table_32_35;
-	unsigned int	chroma_qunt_table_36_39;
-	unsigned int	chroma_qunt_table_40_43;
-	unsigned int	chroma_qunt_table_44_47;
-	unsigned int	chroma_qunt_table_48_51;
-	unsigned int	chroma_qunt_table_52_55;
-	unsigned int	chroma_qunt_table_56_59;
-	unsigned int	chroma_qunt_table_60_63;
-	unsigned int	luma_dc_hm_code_cnt_table_0_3;
-	unsigned int	luma_dc_hm_code_cnt_table_4_7;
-	unsigned int	luma_dc_hm_code_cnt_table_8_11;
-	unsigned int	luma_dc_hm_code_cnt_table_12_15;
-	unsigned int	luma_dc_hm_code_val_table_0_3;
-	unsigned int	luma_dc_hm_code_val_table_4_7;
-	unsigned int	luma_dc_hm_code_val_table_8_11;
-	unsigned int	chroma_dc_hm_code_cnt_table_0_3;
-	unsigned int	chroma_dc_hm_code_cnt_table_4_7;
-	unsigned int	chroma_dc_hm_code_cnt_table_8_11;
-	unsigned int	chroma_dc_hm_code_cnt_table_12_15;
-	unsigned int	chroma_dc_hm_code_val_table_0_3;
-	unsigned int	chroma_dc_hm_code_val_table_4_7;
-	unsigned int	chroma_dc_hm_code_val_table_8_11;
-	unsigned int	luma_ac_hm_code_cnt_table_0_3;
-	unsigned int	luma_ac_hm_code_cnt_table_4_7;
-	unsigned int	luma_ac_hm_code_cnt_table_8_11;
-	unsigned int	luma_ac_hm_code_cnt_table_12_15;
-	unsigned int	luma_ac_hm_code_val_table_0_3;
-	unsigned int	luma_ac_hm_code_val_table_4_7;
-	unsigned int	luma_ac_hm_code_val_table_8_11;
-	unsigned int	luma_ac_hm_code_val_table_12_15;
-	unsigned int	luma_ac_hm_code_val_table_16_19;
-	unsigned int	luma_ac_hm_code_val_table_20_23;
-	unsigned int	luma_ac_hm_code_val_table_24_27;
-	unsigned int	luma_ac_hm_code_val_table_28_31;
-	unsigned int	luma_ac_hm_code_val_table_32_35;
-	unsigned int	luma_ac_hm_code_val_table_36_39;
-	unsigned int	luma_ac_hm_code_val_table_40_43;
-	unsigned int	luma_ac_hm_code_val_table_44_47;
-	unsigned int	luma_ac_hm_code_val_table_48_51;
-	unsigned int	luma_ac_hm_code_val_table_52_55;
-	unsigned int	luma_ac_hm_code_val_table_56_59;
-	unsigned int	luma_ac_hm_code_val_table_60_63;
-	unsigned int	luma_ac_hm_code_val_table_64_67;
-	unsigned int	luma_ac_hm_code_val_table_68_71;
-	unsigned int	luma_ac_hm_code_val_table_72_75;
-	unsigned int	luma_ac_hm_code_val_table_76_79;
-	unsigned int	luma_ac_hm_code_val_table_80_83;
-	unsigned int	luma_ac_hm_code_val_table_84_87;
-	unsigned int	luma_ac_hm_code_val_table_88_91;
-	unsigned int	luma_ac_hm_code_val_table_92_95;
-	unsigned int	luma_ac_hm_code_val_table_96_99;
-	unsigned int	luma_ac_hm_code_val_table_100_103;
-	unsigned int	luma_ac_hm_code_val_table_104_107;
-	unsigned int	luma_ac_hm_code_val_table_108_111;
-	unsigned int	luma_ac_hm_code_val_table_112_115;
-	unsigned int	luma_ac_hm_code_val_table_116_119;
-	unsigned int	luma_ac_hm_code_val_table_120_123;
-	unsigned int	luma_ac_hm_code_val_table_124_127;
-	unsigned int	luma_ac_hm_code_val_table_128_131;
-	unsigned int	luma_ac_hm_code_val_table_132_135;
-	unsigned int	luma_ac_hm_code_val_table_136_139;
-	unsigned int	luma_ac_hm_code_val_table_140_143;
-	unsigned int	luma_ac_hm_code_val_table_144_147;
-	unsigned int	luma_ac_hm_code_val_table_148_151;
-	unsigned int	luma_ac_hm_code_val_table_152_155;
-	unsigned int	luma_ac_hm_code_val_table_156_159;
-	unsigned int	luma_ac_hm_code_val_table_160_161;
-	unsigned int	chroma_ac_hm_code_cnt_table_0_3;
-	unsigned int	chroma_ac_hm_code_cnt_table_4_7;
-	unsigned int	chroma_ac_hm_code_cnt_table_8_11;
-	unsigned int	chroma_ac_hm_code_cnt_table_12_15;
-	unsigned int	chroma_ac_hm_code_val_table_0_3;
-	unsigned int	chroma_ac_hm_code_val_table_4_7;
-	unsigned int	chroma_ac_hm_code_val_table_8_11;
-	unsigned int	chroma_ac_hm_code_val_table_12_15;
-	unsigned int	chroma_ac_hm_code_val_table_16_19;
-	unsigned int	chroma_ac_hm_code_val_table_20_23;
-	unsigned int	chroma_ac_hm_code_val_table_24_27;
-	unsigned int	chroma_ac_hm_code_val_table_28_31;
-	unsigned int	chroma_ac_hm_code_val_table_32_35;
-	unsigned int	chroma_ac_hm_code_val_table_36_39;
-	unsigned int	chroma_ac_hm_code_val_table_40_43;
-	unsigned int	chroma_ac_hm_code_val_table_44_47;
-	unsigned int	chroma_ac_hm_code_val_table_48_51;
-	unsigned int	chroma_ac_hm_code_val_table_52_55;
-	unsigned int	chroma_ac_hm_code_val_table_56_59;
-	unsigned int	chroma_ac_hm_code_val_table_60_63;
-	unsigned int	chroma_ac_hm_code_val_table_64_67;
-	unsigned int	chroma_ac_hm_code_val_table_68_71;
-	unsigned int	chroma_ac_hm_code_val_table_72_75;
-	unsigned int	chroma_ac_hm_code_val_table_76_79;
-	unsigned int	chroma_ac_hm_code_val_table_80_83;
-	unsigned int	chroma_ac_hm_code_val_table_84_87;
-	unsigned int	chroma_ac_hm_code_val_table_88_91;
-	unsigned int	chroma_ac_hm_code_val_table_92_95;
-	unsigned int	chroma_ac_hm_code_val_table_96_99;
-	unsigned int	chroma_ac_hm_code_val_table_100_103;
-	unsigned int	chroma_ac_hm_code_val_table_104_107;
-	unsigned int	chroma_ac_hm_code_val_table_108_111;
-	unsigned int	chroma_ac_hm_code_val_table_112_115;
-	unsigned int	chroma_ac_hm_code_val_table_116_119;
-	unsigned int	chroma_ac_hm_code_val_table_120_123;
-	unsigned int	chroma_ac_hm_code_val_table_124_127;
-	unsigned int	chroma_ac_hm_code_val_table_128_131;
-	unsigned int	chroma_ac_hm_code_val_table_132_135;
-	unsigned int	chroma_ac_hm_code_val_table_136_139;
-	unsigned int	chroma_ac_hm_code_val_table_140_143;
-	unsigned int	chroma_ac_hm_code_val_table_144_147;
-	unsigned int	chroma_ac_hm_code_val_table_148_151;
-	unsigned int	chroma_ac_hm_code_val_table_152_155;
-	unsigned int	chroma_ac_hm_code_val_table_156_159;
-	unsigned int	chroma_ac_hm_code_val_table_160_161;
-} __attribute__((packed)) jpeg_cmd_dec_cfg;
-
-
-/*
- * ARM to JPEG configuration commands are passed through the
- * uPJpegActionCmdQueue
- */
-
-/*
- * Command to start the encode process
- */
-
-#define	JPEG_CMD_ENC_ENCODE		0x0001
-#define	JPEG_CMD_ENC_ENCODE_LEN		sizeof(jpeg_cmd_enc_encode)
-
-
-typedef struct {
-	unsigned short	cmd_id;
-} __attribute__((packed)) jpeg_cmd_enc_encode;
-
-
-/*
- * Command to transition from current state of encoder to IDLE state
- */
-
-#define	JPEG_CMD_ENC_IDLE		0x0006
-#define	JPEG_CMD_ENC_IDLE_LEN		sizeof(jpeg_cmd_enc_idle)
-
-
-typedef struct {
-	unsigned short	cmd_id;
-} __attribute__((packed)) jpeg_cmd_enc_idle;
-
-
-/*
- * Command to inform the encoder that another buffer is ready
- */
-
-#define	JPEG_CMD_ENC_OP_CONSUMED	0x0002
-#define	JPEG_CMD_ENC_OP_CONSUMED_LEN	sizeof(jpeg_cmd_enc_op_consumed)
-
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	op_buf_addr;
-	unsigned int	op_buf_size;
-} __attribute__((packed)) jpeg_cmd_enc_op_consumed; 
-
-
-/*
- * Command to start the decoding process
- */
-
-#define	JPEG_CMD_DEC_DECODE		0x0003
-#define	JPEG_CMD_DEC_DECODE_LEN	sizeof(jpeg_cmd_dec_decode)
-
-
-typedef struct {
-	unsigned short	cmd_id;
-} __attribute__((packed)) jpeg_cmd_dec_decode;
-
-
-/*
- * Command to transition from the current state of decoder to IDLE
- */
-
-#define	JPEG_CMD_DEC_IDLE	0x0007
-#define	JPEG_CMD_DEC_IDLE_LEN	sizeof(jpeg_cmd_dec_idle)
-
-
-typedef struct {
-	unsigned short	cmd_id;
-} __attribute__((packed)) jpeg_cmd_dec_idle;
-
-
-/*
- * Command to inform that an op buffer is ready for use
- */
-
-#define	JPEG_CMD_DEC_OP_CONSUMED	0x0004
-#define	JPEG_CMD_DEC_OP_CONSUMED_LEN	sizeof(jpeg_cmd_dec_op_consumed)
-
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	luma_op_buf_addr;
-	unsigned int	luma_op_buf_size;
-	unsigned int	chroma_op_buf_addr;
-} __attribute__((packed)) jpeg_cmd_dec_op_consumed;
-
-
-/*
- * Command to pass a new ip buffer to the jpeg decoder
- */
-
-#define	JPEG_CMD_DEC_IP	0x0005
-#define	JPEG_CMD_DEC_IP_LEN	sizeof(jpeg_cmd_dec_ip_len)
-
-#define	JPEG_CMD_EOI_INDICATOR_NOT_END	0x0000
-#define	JPEG_CMD_EOI_INDICATOR_END	0x0001
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	ip_buf_addr;
-	unsigned int	ip_buf_size;
-	unsigned int	eoi_indicator;
-} __attribute__((packed)) jpeg_cmd_dec_ip;
-
-
-
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5jpegmsg.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5jpegmsg.h
deleted file mode 100644
index 9b5ce77..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5jpegmsg.h
+++ /dev/null
@@ -1,177 +0,0 @@
-#ifndef QDSP5VIDJPEGMSGI_H
-#define QDSP5VIDJPEGMSGI_H
-
-/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
-
-   J P E G  I N T E R N A L  M E S S A G E S
-
-GENERAL DESCRIPTION
-  This file contains defintions of format blocks of messages 
-  that are sent by JPEG Task
-
-REFERENCES
-  None
-
-EXTERNALIZED FUNCTIONS
-  None
-
-Copyright (c) 1992-2009, The Linux Foundation. All rights reserved.
-
-This software is licensed under the terms of the GNU General Public
-License version 2, as published by the Free Software Foundation, and
-may be copied, distributed, and modified under those terms.
- 
-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.
-
-*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
-/*===========================================================================
-
-                      EDIT HISTORY FOR FILE
-
-This section contains comments describing changes made to this file.
-Notice that changes are listed in reverse chronological order.
-   
-$Header: //source/qcom/qct/multimedia2/AdspSvc/7XXX/qdsp5cmd/video/qdsp5jpegmsg.h#2 $ $DateTime: 2008/07/30 10:50:23 $ $Author: pavanr $                     
-Revision History:                                            
-  
-when       who     what, where, why
---------   ---     ----------------------------------------------------------
-05/10/08   sv      initial version
-===========================================================================*/
-
-/*
- * Messages from JPEG task to ARM through jpeguPMsgQueue
- */
-
-/*
- * Message is ACK for CMD_JPEGE_ENCODE cmd
- */
-
-#define	JPEG_MSG_ENC_ENCODE_ACK	0x0000
-#define	JPEG_MSG_ENC_ENCODE_ACK_LEN	\
-	sizeof(jpeg_msg_enc_encode_ack)
-
-typedef struct {
-} __attribute__((packed)) jpeg_msg_enc_encode_ack;
-
-
-/*
- * Message informs the up when op buffer is ready for consumption and
- * when encoding is complete or errors
- */
-
-#define	JPEG_MSG_ENC_OP_PRODUCED	0x0001
-#define	JPEG_MSG_ENC_OP_PRODUCED_LEN	\
-	sizeof(jpeg_msg_enc_op_produced)
-
-#define	JPEG_MSGOP_OP_BUF_STATUS_ENC_DONE_PROGRESS	0x0000
-#define	JPEG_MSGOP_OP_BUF_STATUS_ENC_DONE_COMPLETE	0x0001
-#define	JPEG_MSGOP_OP_BUF_STATUS_ENC_ERR		0x10000
-
-typedef struct {
-	unsigned int	op_buf_addr;
-	unsigned int	op_buf_size;
-	unsigned int	op_buf_status;
-} __attribute__((packed)) jpeg_msg_enc_op_produced;
-
-
-/*
- * Message to ack CMD_JPEGE_IDLE
- */
-
-#define	JPEG_MSG_ENC_IDLE_ACK	0x0002
-#define	JPEG_MSG_ENC_IDLE_ACK_LEN	sizeof(jpeg_msg_enc_idle_ack)
-
-
-typedef struct {
-} __attribute__ ((packed)) jpeg_msg_enc_idle_ack;
-
-
-/*
- * Message to indicate the illegal command
- */
-
-#define	JPEG_MSG_ENC_ILLEGAL_COMMAND	0x0003
-#define	JPEG_MSG_ENC_ILLEGAL_COMMAND_LEN	\
-	sizeof(jpeg_msg_enc_illegal_command)
-
-typedef struct {
-	unsigned int	status;
-} __attribute__((packed)) jpeg_msg_enc_illegal_command;
-
-
-/*
- * Message to ACK CMD_JPEGD_DECODE
- */
-
-#define	JPEG_MSG_DEC_DECODE_ACK		0x0004
-#define	JPEG_MSG_DEC_DECODE_ACK_LEN	\
-	sizeof(jpeg_msg_dec_decode_ack)
-
-
-typedef struct {
-} __attribute__((packed)) jpeg_msg_dec_decode_ack;
-
-
-/*
- * Message to inform up that an op buffer is ready for consumption and when
- * decoding is complete or an error occurs
- */
-
-#define	JPEG_MSG_DEC_OP_PRODUCED		0x0005
-#define	JPEG_MSG_DEC_OP_PRODUCED_LEN	\
-	sizeof(jpeg_msg_dec_op_produced)
-
-#define	JPEG_MSG_DEC_OP_BUF_STATUS_PROGRESS	0x0000
-#define	JPEG_MSG_DEC_OP_BUF_STATUS_DONE		0x0001
-
-typedef struct {
-	unsigned int	luma_op_buf_addr;
-	unsigned int	chroma_op_buf_addr;
-	unsigned int	num_mcus;
-	unsigned int	op_buf_status;
-} __attribute__((packed)) jpeg_msg_dec_op_produced;
-
-/*
- * Message to ack CMD_JPEGD_IDLE cmd
- */
-
-#define	JPEG_MSG_DEC_IDLE_ACK	0x0006
-#define	JPEG_MSG_DEC_IDLE_ACK_LEN	sizeof(jpeg_msg_dec_idle_ack)
-
-
-typedef struct {
-} __attribute__((packed)) jpeg_msg_dec_idle_ack;
-
-
-/*
- * Message to indicate illegal cmd was received
- */
-
-#define	JPEG_MSG_DEC_ILLEGAL_COMMAND	0x0007
-#define	JPEG_MSG_DEC_ILLEGAL_COMMAND_LEN	\
-	sizeof(jpeg_msg_dec_illegal_command)
-
-
-typedef struct {
-	unsigned int	status;
-} __attribute__((packed)) jpeg_msg_dec_illegal_command;
-
-/*
- * Message to request up for the next segment of ip bit stream
- */
-
-#define	JPEG_MSG_DEC_IP_REQUEST		0x0008
-#define	JPEG_MSG_DEC_IP_REQUEST_LEN	\
-	sizeof(jpeg_msg_dec_ip_request)
-
-
-typedef struct {
-} __attribute__((packed)) jpeg_msg_dec_ip_request;
-
-
-
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5lpmcmdi.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5lpmcmdi.h
deleted file mode 100644
index 3d4fe56..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5lpmcmdi.h
+++ /dev/null
@@ -1,82 +0,0 @@
-#ifndef QDSP5LPMCMDI_H
-#define QDSP5LPMCMDI_H
-
-/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
-
-    L P M   I N T E R N A L   C O M M A N D S
-
-GENERAL DESCRIPTION
-  This file contains defintions of format blocks of commands 
-  that are accepted by LPM Task
-
-REFERENCES
-  None
-
-EXTERNALIZED FUNCTIONS
-  None
-
-Copyright (c) 1992-2009, The Linux Foundation. All rights reserved.
-
-This software is licensed under the terms of the GNU General Public
-License version 2, as published by the Free Software Foundation, and
-may be copied, distributed, and modified under those terms.
- 
-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.
-
-*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
-/*===========================================================================
-
-                      EDIT HISTORY FOR FILE
-
-This section contains comments describing changes made to this file.
-Notice that changes are listed in reverse chronological order.
-   
-  
-$Header: //source/qcom/qct/multimedia2/AdspSvc/7XXX/qdsp5cmd/video/qdsp5lpmcmdi.h#2 $ $DateTime: 2008/07/30 10:50:23 $ $Author: pavanr $                     
-Revision History:                                            
-  
-when       who     what, where, why
---------   ---     ----------------------------------------------------------
-06/12/08   sv      initial version
-===========================================================================*/
-
-
-/*
- * Command to start LPM processing based on the config params
- */
-
-#define	LPM_CMD_START		0x0000
-#define	LPM_CMD_START_LEN	sizeof(lpm_cmd_start)
-
-#define	LPM_CMD_SPATIAL_FILTER_PART_OPMODE_0	0x00000000
-#define	LPM_CMD_SPATIAL_FILTER_PART_OPMODE_1	0x00010000
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	ip_data_cfg_part1;
-	unsigned int	ip_data_cfg_part2;
-	unsigned int	ip_data_cfg_part3;
-	unsigned int	ip_data_cfg_part4;
-	unsigned int	op_data_cfg_part1;
-	unsigned int	op_data_cfg_part2;
-	unsigned int	op_data_cfg_part3;
-	unsigned int	spatial_filter_part[32];
-} __attribute__((packed)) lpm_cmd_start;
-
-
-
-/*
- * Command to stop LPM processing
- */
-
-#define	LPM_CMD_IDLE		0x0001
-#define	LPM_CMD_IDLE_LEN	sizeof(lpm_cmd_idle)
-
-typedef struct {
-	unsigned int	cmd_id;
-} __attribute__((packed)) lpm_cmd_idle;
-
-
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5lpmmsg.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5lpmmsg.h
deleted file mode 100644
index 81f766d..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5lpmmsg.h
+++ /dev/null
@@ -1,80 +0,0 @@
-#ifndef QDSP5LPMMSGI_H
-#define QDSP5LPMMSGI_H
-
-/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
-
-    L P M   I N T E R N A L   M E S S A G E S
-
-GENERAL DESCRIPTION
-  This file contains defintions of format blocks of commands 
-  that are accepted by LPM Task
-
-REFERENCES
-  None
-
-EXTERNALIZED FUNCTIONS
-  None
-
-Copyright (c) 1992-2009, The Linux Foundation. All rights reserved.
-
-This software is licensed under the terms of the GNU General Public
-License version 2, as published by the Free Software Foundation, and
-may be copied, distributed, and modified under those terms.
- 
-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.
-
-*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
-/*===========================================================================
-
-                      EDIT HISTORY FOR FILE
-
-This section contains comments describing changes made to this file.
-Notice that changes are listed in reverse chronological order.
-   
-$Header: //source/qcom/qct/multimedia2/AdspSvc/7XXX/qdsp5cmd/video/qdsp5lpmmsg.h#2 $ $DateTime: 2008/07/30 10:50:23 $ $Author: pavanr $                     
-Revision History:                                              
-  
-when       who     what, where, why
---------   ---     ----------------------------------------------------------
-06/12/08   sv      initial version
-===========================================================================*/
-
-/*
- * Message to acknowledge CMD_LPM_IDLE command
- */
-
-#define	LPM_MSG_IDLE_ACK	0x0000
-#define	LPM_MSG_IDLE_ACK_LEN	sizeof(lpm_msg_idle_ack)
-
-typedef struct {
-} __attribute__((packed)) lpm_msg_idle_ack;
-
-
-/*
- * Message to acknowledge CMD_LPM_START command
- */
-
-
-#define	LPM_MSG_START_ACK	0x0001
-#define	LPM_MSG_START_ACK_LEN	sizeof(lpm_msg_start_ack)
-
-
-typedef struct {
-} __attribute__((packed)) lpm_msg_start_ack;
-
-
-/*
- * Message to notify the ARM that LPM processing is complete
- */
-
-#define	LPM_MSG_DONE		0x0002
-#define	LPM_MSG_DONE_LEN	sizeof(lpm_msg_done)
-
-typedef struct {
-} __attribute__((packed)) lpm_msg_done;
-
-
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5rmtcmdi.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5rmtcmdi.h
deleted file mode 100644
index 9b9521f..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5rmtcmdi.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Copyright (c) 2010, The Linux Foundation. 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.
- */
-
-#ifndef QDSP5RMTCMDI_H
-#define QDSP5RMTCMDI_H
-
-/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
-
-    R M T A S K I N T E R N A L  C O M M A N D S
-
-GENERAL DESCRIPTION
-  This file contains defintions of format blocks of commands
-  that are accepted by RM Task
-
-REFERENCES
-  None
-
-EXTERNALIZED FUNCTIONS
-  None
-
-*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
-
-/*
- * ARM to RMTASK Commands
- *
- * ARM uses one command queue to communicate with AUDPPTASK
- * 1) apuRmtQueue: Used to send commands to RMTASK from APPS processor
- * Location : MEMA
- * Buffer Size : 3 words
- */
-
-#define RM_CMD_AUD_CODEC_CFG	0x0
-
-#define RM_AUD_CLIENT_ID	0x0
-#define RMT_ENABLE		0x1
-#define RMT_DISABLE		0x0
-
-struct aud_codec_config_cmd {
-	unsigned short			cmd_id;
-	unsigned char			task_id;
-	unsigned char			client_id;
-	unsigned short			enable;
-	unsigned short			dec_type;
-} __attribute__((packed));
-
-#endif /* QDSP5RMTCMDI_H */
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5rmtmsg.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5rmtmsg.h
deleted file mode 100644
index 4e7ed33..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5rmtmsg.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Copyright (c) 2010, The Linux Foundation. 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.
- */
-
-#ifndef QDSP5RMTMSG_H
-#define QDSP5RMTMSG_H
-
-/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
-
-       R M T A S K   M S G
-
-GENERAL DESCRIPTION
-  Messages sent by RMTASK to APPS PROCESSOR
-
-REFERENCES
-  None
-
-EXTERNALIZED FUNCTIONS
-  None
-*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
-
-/*
- * RMTASK uses RmtApuRlist to send messages to the APPS PROCESSOR
- * Location : MEMA
- * Buffer Size : 3
- */
-
-#define RMT_CODEC_CONFIG_ACK	0x1
-
-struct aud_codec_config_ack {
-	unsigned char			task_id;
-	unsigned char			client_id;
-	unsigned char			reason;
-	unsigned char			enable;
-	unsigned short			dec_type;
-} __attribute__((packed));
-
-#define RMT_DSP_OUT_OF_MIPS	0x2
-
-struct rmt_dsp_out_of_mips {
-	unsigned short			dec_info;
-	unsigned short			rvd_0;
-	unsigned short			rvd_1;
-} __attribute__((packed));
-
-#endif /* QDSP5RMTMSG_H */
-
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5vdeccmdi.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5vdeccmdi.h
deleted file mode 100644
index 89af4aa..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5vdeccmdi.h
+++ /dev/null
@@ -1,189 +0,0 @@
-#ifndef QDSP5VIDDECCMDI_H
-#define QDSP5VIDDECCMDI_H
-
-/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
-
-    V I D E O  D E C O D E R  I N T E R N A L  C O M M A N D S
-
-GENERAL DESCRIPTION
-  This file contains defintions of format blocks of commands 
-  that are accepted by VIDDEC Task
-
-REFERENCES
-  None
-
-EXTERNALIZED FUNCTIONS
-  None
-
-Copyright (c) 1992-2009, The Linux Foundation. All rights reserved.
-
-This software is licensed under the terms of the GNU General Public
-License version 2, as published by the Free Software Foundation, and
-may be copied, distributed, and modified under those terms.
- 
-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.
-
-*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
-/*===========================================================================
-
-                      EDIT HISTORY FOR FILE
-
-This section contains comments describing changes made to this file.
-Notice that changes are listed in reverse chronological order.
-   
-$Header: //source/qcom/qct/multimedia2/AdspSvc/7XXX/qdsp5cmd/video/qdsp5vdeccmdi.h#2 $ $DateTime: 2008/07/30 10:50:23 $ $Author: pavanr $                     
-Revision History:                                              
-  
-when       who     what, where, why
---------   ---     ----------------------------------------------------------
-05/10/08   ac      initial version
-===========================================================================*/
-
-
-/*
- * Command to inform VIDDEC that new subframe packet is ready
- */
-
-#define	VIDDEC_CMD_SUBFRAME_PKT		0x0000
-#define	VIDDEC_CMD_SUBFRAME_PKT_LEN \
-	sizeof(viddec_cmd_subframe_pkt)
-
-#define	VIDDEC_CMD_SF_INFO_1_DM_DMA_STATS_EXCHANGE_FLAG_DM		0x0000
-#define	VIDDEC_CMD_SF_INFO_1_DM_DMA_STATS_EXCHANGE_FLAG_DMA 	0x0001
-
-#define	VIDDEC_CMD_SF_INFO_0_SUBFRAME_CONTI		0x0000
-#define	VIDDEC_CMD_SF_INFO_0_SUBFRAME_FIRST		0x0001
-#define	VIDDEC_CMD_SF_INFO_0_SUBFRAME_LAST		0x0002
-#define	VIDDEC_CMD_SF_INFO_0_SUBFRAME_FIRST_AND_LAST 	0x0003
-
-#define	VIDDEC_CMD_CODEC_SELECTION_WORD_MPEG_4		0x0000
-#define	VIDDEC_CMD_CODEC_SELECTION_WORD_H_263_P0	0x0001
-#define	VIDDEC_CMD_CODEC_SELECTION_WORD_H_264		0x0002
-#define	VIDDEC_CMD_CODEC_SELECTION_WORD_H_263_p3	0x0003
-#define	VIDDEC_CMD_CODEC_SELECTION_WORD_RV9		0x0004
-#define	VIDDEC_CMD_CODEC_SELECTION_WORD_WMV9		0x0005
-#define	VIDDEC_CMD_CODEC_SELECTION_WORD_SMCDB		0x0006
-#define	VIDDEC_CMD_CODEC_SELECTION_WORD_QFRE		0x0007
-#define	VIDDEC_CMD_CODEC_SELECTION_WORD_VLD		0x0008
-
-typedef struct {
-	unsigned short	cmd_id;
-	unsigned short	packet_seq_number;
-	unsigned short	codec_instance_id;
-	unsigned short	subframe_packet_size_high;
-	unsigned short	subframe_packet_size_low;
-	unsigned short	subframe_packet_high;
-	unsigned short	subframe_packet_low;
-	unsigned short	subframe_packet_partition;
-	unsigned short	statistics_packet_size_high;
-	unsigned short	statistics_packet_size_low;
-	unsigned short	statistics_packet_high;
-	unsigned short	statistics_packet_low;
-	unsigned short	statistics_partition;
-	unsigned short	subframe_info_1;
-	unsigned short	subframe_info_0;
-	unsigned short	codec_selection_word;
-	unsigned short	num_mbs;
-} __attribute__((packed)) viddec_cmd_subframe_pkt;
-
-
-/*
- * Command to inform VIDDEC task that post processing is required for the frame
- */
-
-#define	VIDDEC_CMD_PP_ENABLE		0x0001
-#define	VIDDEC_CMD_PP_ENABLE_LEN \
-	sizeof(viddec_cmd_pp_enable)
-
-#define	VIDDEC_CMD_PP_INFO_0_DM_DMA_LS_EXCHANGE_FLAG_DM		0x0000
-#define	VIDDEC_CMD_PP_INFO_0_DM_DMA_LS_EXCHANGE_FLAG_DMA	0x0001
-
-typedef struct {
-	unsigned short	cmd_id;
-	unsigned short	packet_seq_num;
-	unsigned short	codec_instance_id;
-	unsigned short	postproc_info_0;
-	unsigned short	codec_selection_word;
-	unsigned short	pp_output_addr_high;
-	unsigned short	pp_output_addr_low;
-	unsigned short	postproc_info_1;
-	unsigned short	load_sharing_packet_size_high;
-	unsigned short	load_sharing_packet_size_low;
-	unsigned short	load_sharing_packet_high;
-	unsigned short	load_sharing_packet_low;
-	unsigned short	load_sharing_partition;
-	unsigned short	pp_param_0;
-	unsigned short	pp_param_1;
-	unsigned short	pp_param_2;
-	unsigned short	pp_param_3;
-} __attribute__((packed)) viddec_cmd_pp_enable;
-
-
-/*
- * FRAME Header Packet : It is at the start of new frame
- */
-
-#define	VIDDEC_CMD_FRAME_HEADER_PACKET	0x0002
-
-#define	VIDDEC_CMD_FRAME_INFO_0_ERROR_SKIP	0x0000
-#define	VIDDEC_CMD_FRAME_INFO_0_ERROR_BLACK	0x0800
-
-/*
- * SLICE HEADER PACKET 
- * I-Slice and P-Slice
- */
-
-#define	VIDDEC_CMD_SLICE_HEADER_PKT_ISLICE		0x0003
-#define	VIDDEC_CMD_SLICE_HEADER_PKT_ISLICE_LEN	\
-	sizeof(viddec_cmd_slice_header_pkt_islice)
-
-#define	VIDDEC_CMD_ISLICE_INFO_1_MOD_SLICE_TYPE_PSLICE	0x0000
-#define	VIDDEC_CMD_ISLICE_INFO_1_MOD_SLICE_TYPE_BSLICE	0x0100
-#define	VIDDEC_CMD_ISLICE_INFO_1_MOD_SLICE_TYPE_ISLICE	0x0200
-#define	VIDDEC_CMD_ISLICE_INFO_1_MOD_SLICE_TYPE_SPSLICE	0x0300
-#define	VIDDEC_CMD_ISLICE_INFO_1_MOD_SLICE_TYPE_SISLICE	0x0400
-#define	VIDDEC_CMD_ISLICE_INFO_1_NOPADDING	0x0000
-#define	VIDDEC_CMD_ISLICE_INFO_1_PADDING	0x0800
-
-#define	VIDDEC_CMD_ISLICE_EOP_MARKER		0x7FFF
-
-typedef struct {
-	unsigned short	cmd_id;
-	unsigned short	packet_id;
-	unsigned short	slice_info_0;
-	unsigned short	slice_info_1;
-	unsigned short	slice_info_2;
-	unsigned short	num_bytes_in_rbsp_high;
-	unsigned short	num_bytes_in_rbsp_low;
-	unsigned short	num_bytes_in_rbsp_consumed;
-	unsigned short	end_of_packet_marker;
-} __attribute__((packed)) viddec_cmd_slice_header_pkt_islice;
-
-
-#define	VIDDEC_CMD_SLICE_HEADER_PKT_PSLICE		0x0003
-#define	VIDDEC_CMD_SLICE_HEADER_PKT_PSLICE_LEN	\
-	sizeof(viddec_cmd_slice_header_pkt_pslice)
-
-
-typedef struct {
-	unsigned short	cmd_id;
-	unsigned short	packet_id;
-	unsigned short	slice_info_0;
-	unsigned short	slice_info_1;
-	unsigned short	slice_info_2;
-	unsigned short	slice_info_3;
-	unsigned short	refidx_l0_map_tab_info_0;
-	unsigned short	refidx_l0_map_tab_info_1;
-	unsigned short	refidx_l0_map_tab_info_2;
-	unsigned short	refidx_l0_map_tab_info_3;
-	unsigned short	num_bytes_in_rbsp_high;
-	unsigned short	num_bytes_in_rbsp_low;
-	unsigned short	num_bytes_in_rbsp_consumed;
-	unsigned short	end_of_packet_marker;
-} __attribute__((packed)) viddec_cmd_slice_header_pkt_pslice;
-
-
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5vdecmsg.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5vdecmsg.h
deleted file mode 100644
index ccd129d..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5vdecmsg.h
+++ /dev/null
@@ -1,107 +0,0 @@
-#ifndef QDSP5VIDDECMSGI_H
-#define QDSP5VIDDECMSGI_H
-
-/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
-
-    V I D E O  D E C O D E R   I N T E R N A L  M E S S A G E S
-
-GENERAL DESCRIPTION
-  This file contains defintions of format blocks of messages 
-  that are sent by VIDDEC Task
-
-REFERENCES
-  None
-
-EXTERNALIZED FUNCTIONS
-  None
-
-Copyright (c) 1992-2009, The Linux Foundation. All rights reserved.
-
-This software is licensed under the terms of the GNU General Public
-License version 2, as published by the Free Software Foundation, and
-may be copied, distributed, and modified under those terms.
- 
-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.
-
-*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
-/*===========================================================================
-
-                      EDIT HISTORY FOR FILE
-
-This section contains comments describing changes made to this file.
-Notice that changes are listed in reverse chronological order.
-   
-$Header: //source/qcom/qct/multimedia2/AdspSvc/7XXX/qdsp5cmd/video/qdsp5vdecmsg.h#2 $ $DateTime: 2008/07/30 10:50:23 $ $Author: pavanr $                     
-Revision History:                                              
-  
-when       who     what, where, why
---------   ---     ----------------------------------------------------------
-05/10/08   ac      initial version
-===========================================================================*/
-
-/*
- * Message to inform ARM which VDEC_SUBFRAME_PKT_CMD processed by VIDDEC TASK
- */
-
-#define	VIDDEC_MSG_SUBF_DONE	0x0000
-#define	VIDDEC_MSG_SUBF_DONE_LEN	\
-	sizeof(viddec_msg_subf_done)
-
-typedef struct {
-	unsigned short	packet_seq_number;
-	unsigned short	codec_instance_id;
-} __attribute__((packed)) viddec_msg_subf_done;
-
-
-/*
- * Message to inform ARM one frame has been decoded
- */
-
-#define	VIDDEC_MSG_FRAME_DONE	0x0001
-#define	VIDDEC_MSG_FRAME_DONE_LEN	\
-	sizeof(viddec_msg_frame_done)
-
-typedef struct {
-	unsigned short	packet_seq_number;
-	unsigned short	codec_instance_id;
-} __attribute__((packed)) viddec_msg_frame_done;
-
-
-/*
- * Message to inform ARM that post processing frame has been decoded
- */
-
-#define	VIDDEC_MSG_PP_ENABLE_CMD_DONE	0x0002
-#define	VIDDEC_MSG_PP_ENABLE_CMD_DONE_LEN	\
-	sizeof(viddec_msg_pp_enable_cmd_done)
-
-typedef struct {
-	unsigned short	packet_seq_number;
-	unsigned short	codec_instance_id;
-} __attribute__((packed)) viddec_msg_pp_enable_cmd_done;
-
-
-/*
- * Message to inform ARM that one post processing frame has been decoded
- */
-
-
-#define	VIDDEC_MSG_PP_FRAME_DONE		0x0003
-#define	VIDDEC_MSG_PP_FRAME_DONE_LEN	\
-	sizeof(viddec_msg_pp_frame_done)
-
-#define	VIDDEC_MSG_DISP_WORTHY_DISP		0x0000
-#define	VIDDEC_MSG_DISP_WORTHY_DISP_NONE	0xFFFF
-
-
-typedef struct {
-	unsigned short	packet_seq_number;
-	unsigned short	codec_instance_id;
-	unsigned short	display_worthy;
-} __attribute__((packed)) viddec_msg_pp_frame_done;
-
-
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5venccmdi.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5venccmdi.h
deleted file mode 100644
index 34e00a6..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5venccmdi.h
+++ /dev/null
@@ -1,231 +0,0 @@
-#ifndef QDSP5VIDENCCMDI_H
-#define QDSP5VIDENCCMDI_H
-
-/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
-
-    V I D E O  E N C O D E R  I N T E R N A L  C O M M A N D S
-
-GENERAL DESCRIPTION
-  This file contains defintions of format blocks of commands
-  that are accepted by VIDENC Task
-
-REFERENCES
-  None
-
-EXTERNALIZED FUNCTIONS
-  None
-
-Copyright (c) 2008-2009, The Linux Foundation. All rights reserved.
-*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
-/*===========================================================================
-
-			EDIT HISTORY FOR FILE
-
-This section contains comments describing changes made to this file.
-Notice that changes are listed in reverse chronological order.
-
-Revision History:
-
-when       who     what, where, why
---------   ---     ----------------------------------------------------------
-09/25/08   umeshp      initial version
-===========================================================================*/
-
-  #define VIDENC_CMD_CFG           0x0000
-  #define VIDENC_CMD_ACTIVE        0x0001
-  #define VIDENC_CMD_IDLE          0x0002
-  #define VIDENC_CMD_FRAME_START   0x0003
-  #define VIDENC_CMD_STATUS_QUERY  0x0004
-  #define VIDENC_CMD_RC_CFG        0x0005
-  #define VIDENC_CMD_INTRA_REFRESH 0x0006
-  #define VIDENC_CMD_CODEC_CONFIG  0x0007
-  #define VIDENC_CMD_VIDEO_CONFIG  0x0008
-  #define VIDENC_CMD_PARAMETER_UPDATE       0x0009
-  #define VIDENC_CMD_VENC_CLOCK    0x000A
-  #define VIDENC_CMD_DIS_CFG       0x000B
-  #define VIDENC_CMD_DIS           0x000C
-  #define VIDENC_CMD_DIGITAL_ZOOM  0x000D
-
-
-
-
-/*
- * Command to pass the frame message information to VIDENC
- */
-
-
-#define VIDENC_CMD_FRAME_START_LEN \
-	sizeof(videnc_cmd_frame_start)
-
-typedef struct {
-    unsigned short  cmd_id;
-    unsigned short  frame_info;
-    unsigned short  frame_rho_budget_word_high;
-    unsigned short  frame_rho_budget_word_low;
-    unsigned short  input_luma_addr_high;
-    unsigned short  input_luma_addr_low;
-    unsigned short  input_chroma_addr_high;
-    unsigned short  input_chroma_addr_low;
-    unsigned short  ref_vop_buf_ptr_high;
-    unsigned short  ref_vop_buf_ptr_low;
-    unsigned short  enc_pkt_buf_ptr_high;
-    unsigned short  enc_pkt_buf_ptr_low;
-    unsigned short  enc_pkt_buf_size_high;
-    unsigned short  enc_pkt_buf_size_low;
-    unsigned short  unfilt_recon_vop_buf_ptr_high;
-    unsigned short  unfilt_recon_vop_buf_ptr_low;
-    unsigned short  filt_recon_vop_buf_ptr_high;
-    unsigned short  filt_recon_vop_buf_ptr_low;
-} __attribute__((packed)) videnc_cmd_frame_start;
-
-/*
- * Command to pass the frame-level digital stabilization parameters to VIDENC
- */
-
-
-#define VIDENC_CMD_DIS_LEN \
-    sizeof(videnc_cmd_dis)
-
-typedef struct {
-    unsigned short  cmd_id;
-    unsigned short  vfe_out_prev_luma_addr_high;
-    unsigned short  vfe_out_prev_luma_addr_low;
-    unsigned short  stabilization_info;
-} __attribute__((packed)) videnc_cmd_dis;
-
-/*
- * Command to pass the codec related parameters to VIDENC
- */
-
-
-#define VIDENC_CMD_CFG_LEN \
-    sizeof(videnc_cmd_cfg)
-
-typedef struct {
-    unsigned short  cmd_id;
-    unsigned short  cfg_info_0;
-    unsigned short  cfg_info_1;
-    unsigned short  four_mv_threshold;
-    unsigned short  ise_fse_mv_cost_fac;
-	unsigned short  venc_frame_dim;
-	unsigned short  venc_DM_partition;
-} __attribute__((packed)) videnc_cmd_cfg;
-
-/*
- * Command to start the video encoding
- */
-
-
-#define VIDENC_CMD_ACTIVE_LEN \
-    sizeof(videnc_cmd_active)
-
-typedef struct {
-    unsigned short  cmd_id;
-} __attribute__((packed)) videnc_cmd_active;
-
-/*
- * Command to stop the video encoding
- */
-
-
-#define VIDENC_CMD_IDLE_LEN \
-    sizeof(videnc_cmd_idle)
-
-typedef struct {
-    unsigned short  cmd_id;
-} __attribute__((packed)) videnc_cmd_idle;
-
-/*
- * Command to query staus of VIDENC
- */
-
-
-#define VIDENC_CMD_STATUS_QUERY_LEN \
-    sizeof(videnc_cmd_status_query)
-
-typedef struct {
-    unsigned short  cmd_id;
-} __attribute__((packed)) videnc_cmd_status_query;
-
-/*
- * Command to set rate control for a frame
- */
-
-
-#define VIDENC_CMD_RC_CFG_LEN \
-    sizeof(videnc_cmd_rc_cfg)
-
-typedef struct {
-    unsigned short  cmd_id;
-	unsigned short  max_frame_qp_delta;
-	unsigned short  max_min_frame_qp;
-} __attribute__((packed)) videnc_cmd_rc_cfg;
-
-/*
- * Command to set intra-refreshing
- */
-
-
-#define VIDENC_CMD_INTRA_REFRESH_LEN \
-    sizeof(videnc_cmd_intra_refresh)
-
-typedef struct {
-    unsigned short  cmd_id;
-	unsigned short  num_mb_refresh;
-	unsigned short  mb_index[15];
-} __attribute__((packed)) videnc_cmd_intra_refresh;
-
-/*
- * Command to pass digital zoom information to the VIDENC
- */
-#define VIDENC_CMD_DIGITAL_ZOOM_LEN \
-    sizeof(videnc_cmd_digital_zoom)
-
-typedef struct {
-    unsigned short  cmd_id;
-    unsigned short  digital_zoom_en;
-    unsigned short  luma_frame_shift_X;
-    unsigned short  luma_frame_shift_Y;
-    unsigned short  up_ip_luma_rows;
-    unsigned short  up_ip_luma_cols;
-    unsigned short  up_ip_chroma_rows;
-    unsigned short  up_ip_chroma_cols;
-    unsigned short  luma_ph_incr_V_low;
-    unsigned short  luma_ph_incr_V_high;
-    unsigned short  luma_ph_incr_H_low;
-    unsigned short  luma_ph_incr_H_high;
-    unsigned short  chroma_ph_incr_V_low;
-    unsigned short  chroma_ph_incr_V_high;
-    unsigned short  chroma_ph_incr_H_low;
-    unsigned short  chroma_ph_incr_H_high;
-} __attribute__((packed)) videnc_cmd_digital_zoom;
-
-/*
- * Command to configure digital stabilization parameters
- */
-
-#define VIDENC_CMD_DIS_CFG_LEN \
-    sizeof(videnc_cmd_dis_cfg)
-
-typedef struct {
-    unsigned short  cmd_id;
-    unsigned short  image_stab_subf_start_row_col;
-    unsigned short  image_stab_subf_dim;
-    unsigned short  image_stab_info_0;
-} __attribute__((packed)) videnc_cmd_dis_cfg;
-
-
-/*
- * Command to set VIDENC_CMD_VENC_CLOCK
- */
-
-
-#define VIDENC_CMD_VENC_CLOCK_LEN \
-    sizeof(struct videnc_cmd_venc_clock)
-
-struct videnc_cmd_venc_clock {
-    unsigned short  cmd_id;
-    unsigned short  payload;
-} __attribute__((packed)) ;
-
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5vfecmdi.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5vfecmdi.h
deleted file mode 100644
index 18ea21c..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5vfecmdi.h
+++ /dev/null
@@ -1,910 +0,0 @@
-#ifndef QDSP5VFECMDI_H
-#define QDSP5VFECMDI_H
-
-/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
-
-    V F E   I N T E R N A L   C O M M A N D S
-
-GENERAL DESCRIPTION
-  This file contains defintions of format blocks of commands 
-  that are accepted by VFE Task
-
-REFERENCES
-  None
-
-EXTERNALIZED FUNCTIONS
-  None
-
-Copyright (c) 1992-2009, The Linux Foundation. All rights reserved.
-
-This software is licensed under the terms of the GNU General Public
-License version 2, as published by the Free Software Foundation, and
-may be copied, distributed, and modified under those terms.
- 
-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.
-
-*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
-/*===========================================================================
-
-                      EDIT HISTORY FOR FILE
-
-This section contains comments describing changes made to this file.
-Notice that changes are listed in reverse chronological order.
-   
-$Header: //source/qcom/qct/multimedia2/AdspSvc/7XXX/qdsp5cmd/video/qdsp5vfecmdi.h#2 $ $DateTime: 2008/07/30 10:50:23 $ $Author: pavanr $                     
-Revision History:                                              
-  
-when       who     what, where, why
---------   ---     ----------------------------------------------------------
-06/12/08   sv      initial version
-===========================================================================*/
-
-/******************************************************************************
- * Commands through vfeCommandScaleQueue
- *****************************************************************************/
-
-/*
- * Command to program scaler for op1 . max op of scaler is VGA
- */
-
-
-#define	VFE_CMD_SCALE_OP1_CFG		0x0000
-#define	VFE_CMD_SCALE_OP1_CFG_LEN	\
-	sizeof(vfe_cmd_scale_op1_cfg)
-
-#define	VFE_CMD_SCALE_OP1_SEL_IP_SEL_Y_STANDARD	0x0000
-#define	VFE_CMD_SCALE_OP1_SEL_IP_SEL_Y_CASCADED	0x0001
-#define	VFE_CMD_SCALE_OP1_SEL_H_Y_SCALER_DIS	0x0000
-#define	VFE_CMD_SCALE_OP1_SEL_H_Y_SCALER_ENA	0x0002
-#define	VFE_CMD_SCALE_OP1_SEL_H_PP_Y_SCALER_DIS	0x0000
-#define	VFE_CMD_SCALE_OP1_SEL_H_PP_Y_SCALER_ENA	0x0004
-#define	VFE_CMD_SCALE_OP1_SEL_V_Y_SCALER_DIS	0x0000
-#define	VFE_CMD_SCALE_OP1_SEL_V_Y_SCALER_ENA	0x0008
-#define	VFE_CMD_SCALE_OP1_SEL_V_PP_Y_SCALER_DIS	0x0000
-#define	VFE_CMD_SCALE_OP1_SEL_V_PP_Y_SCALER_ENA	0x0010
-#define	VFE_CMD_SCALE_OP1_SEL_IP_SEL_CBCR_STANDARD	0x0000
-#define	VFE_CMD_SCALE_OP1_SEL_IP_SEL_CBCR_CASCADED	0x0020
-#define	VFE_CMD_SCALE_OP1_SEL_H_CBCR_SCALER_DIS		0x0000
-#define	VFE_CMD_SCALE_OP1_SEL_H_CBCR_SCALER_ENA		0x0040
-#define	VFE_CMD_SCALE_OP1_SEL_V_CBCR_SCALER_DIS		0x0000
-#define	VFE_CMD_SCALE_OP1_SEL_V_CBCR_SCALER_ENA		0x0080
-
-#define	VFE_CMD_OP1_PP_Y_SCALER_CFG_PART1_DONT_LOAD_COEFFS	0x80000000
-#define	VFE_CMD_OP1_PP_Y_SCALER_CFG_PART1_LOAD_COEFFS	0x80000000
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	scale_op1_sel;
-	unsigned int	y_scaler_cfg_part1;
-	unsigned int	y_scaler_cfg_part2;
-	unsigned int	cbcr_scaler_cfg_part1;
-	unsigned int	cbcr_scaler_cfg_part2;
-	unsigned int	cbcr_scaler_cfg_part3;
-	unsigned int	pp_y_scaler_cfg_part1;
-	unsigned int	pp_y_scaler_cfg_part2;
-	unsigned int	y_scaler_v_coeff_bank_part1[16];
-	unsigned int	y_scaler_v_coeff_bank_part2[16];
-	unsigned int	y_scaler_h_coeff_bank_part1[16];
-	unsigned int	y_scaler_h_coeff_bank_part2[16];
-} __attribute__((packed)) vfe_cmd_scale_op1_cfg;
-
-
-/*
- * Command to program scaler for op2
- */
-
-#define	VFE_CMD_SCALE_OP2_CFG		0x0001
-#define	VFE_CMD_SCALE_OP2_CFG_LEN	\
-	sizeof(vfe_cmd_scale_op2_cfg)
-
-#define	VFE_CMD_SCALE_OP2_SEL_IP_SEL_Y_STANDARD	0x0000
-#define	VFE_CMD_SCALE_OP2_SEL_IP_SEL_Y_CASCADED	0x0001
-#define	VFE_CMD_SCALE_OP2_SEL_H_Y_SCALER_DIS	0x0000
-#define	VFE_CMD_SCALE_OP2_SEL_H_Y_SCALER_ENA	0x0002
-#define	VFE_CMD_SCALE_OP2_SEL_H_PP_Y_SCALER_DIS	0x0000
-#define	VFE_CMD_SCALE_OP2_SEL_H_PP_Y_SCALER_ENA	0x0004
-#define	VFE_CMD_SCALE_OP2_SEL_V_Y_SCALER_DIS	0x0000
-#define	VFE_CMD_SCALE_OP2_SEL_V_Y_SCALER_ENA	0x0008
-#define	VFE_CMD_SCALE_OP2_SEL_V_PP_Y_SCALER_DIS	0x0000
-#define	VFE_CMD_SCALE_OP2_SEL_V_PP_Y_SCALER_ENA	0x0010
-#define	VFE_CMD_SCALE_OP2_SEL_IP_SEL_CBCR_STANDARD	0x0000
-#define	VFE_CMD_SCALE_OP2_SEL_IP_SEL_CBCR_CASCADED	0x0020
-#define	VFE_CMD_SCALE_OP2_SEL_H_CBCR_SCALER_DIS		0x0000
-#define	VFE_CMD_SCALE_OP2_SEL_H_CBCR_SCALER_ENA		0x0040
-#define	VFE_CMD_SCALE_OP2_SEL_V_CBCR_SCALER_DIS		0x0000
-#define	VFE_CMD_SCALE_OP2_SEL_V_CBCR_SCALER_ENA		0x0080
-
-#define	VFE_CMD_OP2_PP_Y_SCALER_CFG_PART1_DONT_LOAD_COEFFS	0x80000000
-#define	VFE_CMD_OP2_PP_Y_SCALER_CFG_PART1_LOAD_COEFFS		0x80000000
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	scale_op2_sel;
-	unsigned int	y_scaler_cfg_part1;
-	unsigned int	y_scaler_cfg_part2;
-	unsigned int	cbcr_scaler_cfg_part1;
-	unsigned int	cbcr_scaler_cfg_part2;
-	unsigned int	cbcr_scaler_cfg_part3;
-	unsigned int	pp_y_scaler_cfg_part1;
-	unsigned int	pp_y_scaler_cfg_part2;
-	unsigned int	y_scaler_v_coeff_bank_part1[16];
-	unsigned int	y_scaler_v_coeff_bank_part2[16];
-	unsigned int	y_scaler_h_coeff_bank_part1[16];
-	unsigned int	y_scaler_h_coeff_bank_part2[16];
-} __attribute__((packed)) vfe_cmd_scale_op2_cfg;
-
-
-/******************************************************************************
- * Commands through vfeCommandTableQueue
- *****************************************************************************/
-
-/*
- * Command to program the AXI ip paths
- */
-
-#define	VFE_CMD_AXI_IP_CFG		0x0000
-#define	VFE_CMD_AXI_IP_CFG_LEN		sizeof(vfe_cmd_axi_ip_cfg)
-
-#define	VFE_CMD_IP_SEL_IP_FORMAT_8	0x0000
-#define	VFE_CMD_IP_SEL_IP_FORMAT_10	0x0001
-#define	VFE_CMD_IP_SEL_IP_FORMAT_12	0x0002
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	ip_sel;
-	unsigned int	ip_cfg_part1;
-	unsigned int	ip_cfg_part2;
-	unsigned int	ip_unpack_cfg_part[6];
-	unsigned int	ip_buf_addr[8];
-} __attribute__ ((packed)) vfe_cmd_axi_ip_cfg;
-
-
-/*
- * Command to program axi op paths
- */
-
-#define	VFE_CMD_AXI_OP_CFG	0x0001
-#define	VFE_CMD_AXI_OP_CFG_LEN	sizeof(vfe_cmd_axi_op_cfg)
-
-#define	VFE_CMD_OP_SEL_OP1		0x0000
-#define	VFE_CMD_OP_SEL_OP2		0x0001
-#define	VFE_CMD_OP_SEL_OP1_OP2		0x0002
-#define	VFE_CMD_OP_SEL_CTOA		0x0003
-#define	VFE_CMD_OP_SEL_CTOA_OP1		0x0004
-#define	VFE_CMD_OP_SEL_CTOA_OP2		0x0005
-#define	VFE_CMD_OP_SEL_OP_FORMAT_8	0x0000
-#define	VFE_CMD_OP_SEL_OP_FORMAT_10	0x0008
-#define	VFE_CMD_OP_SEL_OP_FORMAT_12	0x0010
-
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	op_sel;
-	unsigned int	op1_y_cfg_part1;
-	unsigned int	op1_y_cfg_part2;
-	unsigned int	op1_cbcr_cfg_part1;
-	unsigned int	op1_cbcr_cfg_part2;
-	unsigned int	op2_y_cfg_part1;
-	unsigned int	op2_y_cfg_part2;
-	unsigned int	op2_cbcr_cfg_part1;
-	unsigned int	op2_cbcr_cfg_part2;
-	unsigned int	op1_buf1_addr[16];
-	unsigned int	op2_buf1_addr[16];
-} __attribute__((packed)) vfe_cmd_axi_op_cfg;
-
-
-
-
-/*
- * Command to program the roll off correction module
- */
-
-#define	VFE_CMD_ROLLOFF_CFG	0x0002
-#define	VFE_CMD_ROLLOFF_CFG_LEN	\
-	sizeof(vfe_cmd_rolloff_cfg)
-
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	correction_opt_center_pos;
-	unsigned int	radius_square_entry[32];
-	unsigned int	red_table_entry[32];
-	unsigned int	green_table_entry[32];
-	unsigned int	blue_table_entry[32];
-} __attribute__((packed)) vfe_cmd_rolloff_cfg;
-
-/*
- * Command to program RGB gamma table
- */
-
-#define	VFE_CMD_RGB_GAMMA_CFG		0x0003
-#define	VFE_CMD_RGB_GAMMA_CFG_LEN	\
-	sizeof(vfe_cmd_rgb_gamma_cfg)
-
-#define	VFE_CMD_RGB_GAMMA_SEL_LINEAR		0x0000
-#define	VFE_CMD_RGB_GAMMA_SEL_PW_LINEAR		0x0001
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	rgb_gamma_sel;
-	unsigned int	rgb_gamma_entry[256];
-} __attribute__((packed)) vfe_cmd_rgb_gamma_cfg;
-
-
-/*
- * Command to program luma gamma table for the noise reduction path
- */
-
-#define	VFE_CMD_Y_GAMMA_CFG		0x0004
-#define	VFE_CMD_Y_GAMMA_CFG_LEN		\
-	sizeof(vfe_cmd_y_gamma_cfg)
-
-#define	VFE_CMD_Y_GAMMA_SEL_LINEAR	0x0000
-#define	VFE_CMD_Y_GAMMA_SEL_PW_LINEAR	0x0001
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	y_gamma_sel;
-	unsigned int	y_gamma_entry[256];	
-} __attribute__((packed)) vfe_cmd_y_gamma_cfg;
-
-
-
-/******************************************************************************
- * Commands through vfeCommandQueue
- *****************************************************************************/
-
-/*
- * Command to reset the VFE to a known good state.All previously programmed 
- * Params will be lost
- */
-
-
-#define	VFE_CMD_RESET		0x0000
-#define	VFE_CMD_RESET_LEN	sizeof(vfe_cmd_reset)
-
-
-typedef struct {
-	unsigned short	cmd_id;
-} __attribute__((packed)) vfe_cmd_reset;
-
-
-/*
- * Command to start VFE processing based on the config params
- */
-
-
-#define	VFE_CMD_START		0x0001
-#define	VFE_CMD_START_LEN	sizeof(vfe_cmd_start)
-
-#define	VFE_CMD_STARTUP_PARAMS_SRC_CAMIF	0x0000
-#define	VFE_CMD_STARTUP_PARAMS_SRC_AXI		0x0001
-#define	VFE_CMD_STARTUP_PARAMS_MODE_CONTINUOUS	0x0000
-#define	VFE_CMD_STARTUP_PARAMS_MODE_SNAPSHOT	0x0002
-
-#define	VFE_CMD_IMAGE_PL_BLACK_LVL_CORR_DIS	0x0000
-#define	VFE_CMD_IMAGE_PL_BLACK_LVL_CORR_ENA	0x0001
-#define	VFE_CMD_IMAGE_PL_ROLLOFF_CORR_DIS	0x0000
-#define	VFE_CMD_IMAGE_PL_ROLLOFF_CORR_ENA	0x0002
-#define	VFE_CMD_IMAGE_PL_WHITE_BAL_DIS		0x0000
-#define	VFE_CMD_IMAGE_PL_WHITE_BAL_ENA		0x0004
-#define	VFE_CMD_IMAGE_PL_RGB_GAMMA_DIS		0x0000
-#define	VFE_CMD_IMAGE_PL_RGB_GAMMA_ENA		0x0008
-#define	VFE_CMD_IMAGE_PL_LUMA_NOISE_RED_PATH_DIS	0x0000
-#define	VFE_CMD_IMAGE_PL_LUMA_NOISE_RED_PATH_ENA	0x0010
-#define	VFE_CMD_IMAGE_PL_ADP_FILTER_DIS		0x0000
-#define	VFE_CMD_IMAGE_PL_ADP_FILTER_ENA		0x0020
-#define	VFE_CMD_IMAGE_PL_CHROMA_SAMP_DIS	0x0000
-#define	VFE_CMD_IMAGE_PL_CHROMA_SAMP_ENA	0x0040
-
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	startup_params;
-	unsigned int	image_pipeline;
-	unsigned int	frame_dimension;
-} __attribute__((packed)) vfe_cmd_start;
-
-
-/*
- * Command to halt all processing
- */
-
-#define	VFE_CMD_STOP		0x0002
-#define	VFE_CMD_STOP_LEN	sizeof(vfe_cmd_stop)
-
-typedef struct {
-	unsigned short	cmd_id;
-} __attribute__((packed)) vfe_cmd_stop;
-
-
-/*
- * Command to commit the params that have been programmed to take
- * effect on the next frame
- */
-
-#define	VFE_CMD_UPDATE		0x0003
-#define	VFE_CMD_UPDATE_LEN	sizeof(vfe_cmd_update)
-
-
-typedef struct {
-	unsigned short	cmd_id;
-} __attribute__((packed)) vfe_cmd_update;
-
-
-/*
- * Command to program CAMIF module
- */
-
-#define	VFE_CMD_CAMIF_CFG	0x0004
-#define	VFE_CMD_CAMIF_CFG_LEN	sizeof(vfe_cmd_camif_cfg)
-
-#define	VFE_CMD_CFG_VSYNC_SYNC_EDGE_HIGH	0x0000
-#define	VFE_CMD_CFG_VSYNC_SYNC_EDGE_LOW		0x0002
-#define	VFE_CMD_CFG_HSYNC_SYNC_EDGE_HIGH	0x0000
-#define	VFE_CMD_CFG_HSYNC_SYNC_EDGE_LOW		0x0004
-#define	VFE_CMD_CFG_SYNC_MODE_APS		0x0000
-#define	VFE_CMD_CFG_SYNC_MODE_EFS		0X0008
-#define	VFE_CMD_CFG_SYNC_MODE_ELS		0x0010
-#define	VFE_CMD_CFG_SYNC_MODE_RVD		0x0018
-#define	VFE_CMD_CFG_VFE_SUBSAMP_EN_DIS		0x0000
-#define	VFE_CMD_CFG_VFE_SUBSAMP_EN_ENA		0x0020
-#define	VFE_CMD_CFG_BUS_SUBSAMP_EN_DIS		0x0000
-#define	VFE_CMD_CFG_BUS_SUBSAMP_EN_ENA		0x0080
-#define	VFE_CMD_CFG_IRQ_SUBSAMP_EN_DIS		0x0000
-#define	VFE_CMD_CFG_IRQ_SUBSAMP_EN_ENA		0x0800
-
-#define	VFE_CMD_SUBSAMP2_CFG_PIXEL_SKIP_16	0x0000
-#define	VFE_CMD_SUBSAMP2_CFG_PIXEL_SKIP_12	0x0010
-
-#define	VFE_CMD_EPOCH_IRQ_1_DIS			0x0000
-#define	VFE_CMD_EPOCH_IRQ_1_ENA			0x4000
-#define	VFE_CMD_EPOCH_IRQ_2_DIS			0x0000
-#define	VFE_CMD_EPOCH_IRQ_2_ENA			0x8000
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	cfg;
-	unsigned int	efs_cfg;
-	unsigned int	frame_cfg;
-	unsigned int	window_width_cfg;
-	unsigned int	window_height_cfg;
-	unsigned int	subsamp1_cfg;
-	unsigned int	subsamp2_cfg;
-	unsigned int	epoch_irq;
-} __attribute__((packed)) vfe_cmd_camif_cfg;
-
-
-
-/*
- * Command to program the black level module
- */
-
-#define	VFE_CMD_BLACK_LVL_CFG		0x0005
-#define	VFE_CMD_BLACK_LVL_CFG_LEN	sizeof(vfe_cmd_black_lvl_cfg)
-
-#define	VFE_CMD_BL_SEL_MANUAL		0x0000
-#define	VFE_CMD_BL_SEL_AUTO		0x0001
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	black_lvl_sel;
-	unsigned int	cfg_part[3];
-} __attribute__((packed)) vfe_cmd_black_lvl_cfg;
-
-
-/*
- * Command to program the active region by cropping the region of interest
- */
-
-#define	VFE_CMD_ACTIVE_REGION_CFG	0x0006
-#define	VFE_CMD_ACTIVE_REGION_CFG_LEN	\
-	sizeof(vfe_cmd_active_region_cfg)
-
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	cfg_part1;
-	unsigned int	cfg_part2;
-} __attribute__((packed)) vfe_cmd_active_region_cfg;
-
-
-
-/*
- * Command to program the defective pixel correction(DPC) ,
- * adaptive bayer filter (ABF) and demosaic modules
- */
-
-#define	VFE_CMD_DEMOSAIC_CFG		0x0007
-#define	VFE_CMD_DEMOSAIC_CFG_LEN	sizeof(vfe_cmd_demosaic_cfg)
-
-#define	VFE_CMD_DEMOSAIC_PART1_ABF_EN_DIS	0x0000
-#define	VFE_CMD_DEMOSAIC_PART1_ABF_EN_ENA	0x0001
-#define	VFE_CMD_DEMOSAIC_PART1_DPC_EN_DIS	0x0000
-#define	VFE_CMD_DEMOSAIC_PART1_DPC_EN_ENA	0x0002
-#define	VFE_CMD_DEMOSAIC_PART1_FORCE_ABF_OFF	0x0000
-#define	VFE_CMD_DEMOSAIC_PART1_FORCE_ABF_ON	0x0004
-#define	VFE_CMD_DEMOSAIC_PART1_SLOPE_SHIFT_1	0x00000000
-#define	VFE_CMD_DEMOSAIC_PART1_SLOPE_SHIFT_2	0x10000000
-#define	VFE_CMD_DEMOSAIC_PART1_SLOPE_SHIFT_4	0x20000000
-#define	VFE_CMD_DEMOSAIC_PART1_SLOPE_SHIFT_8	0x30000000
-#define	VFE_CMD_DEMOSAIC_PART1_SLOPE_SHIFT_1_2	0x50000000
-#define	VFE_CMD_DEMOSAIC_PART1_SLOPE_SHIFT_1_4	0x60000000
-#define	VFE_CMD_DEMOSAIC_PART1_SLOPE_SHIFT_1_8	0x70000000
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	demosaic_part1;
-	unsigned int	demosaic_part2;
-	unsigned int	demosaic_part3;
-	unsigned int	demosaic_part4;
-	unsigned int	demosaic_part5;
-} __attribute__((packed)) vfe_cmd_demosaic_cfg;
-
-
-/*
- * Command to program the ip format
- */
-
-#define	VFE_CMD_IP_FORMAT_CFG		0x0008
-#define	VFE_CMD_IP_FORMAT_CFG_LEN	\
-	sizeof(vfe_cmd_ip_format_cfg)
-
-#define	VFE_CMD_IP_FORMAT_SEL_RGRG	0x0000
-#define	VFE_CMD_IP_FORMAT_SEL_GRGR	0x0001
-#define	VFE_CMD_IP_FORMAT_SEL_BGBG	0x0002
-#define	VFE_CMD_IP_FORMAT_SEL_GBGB	0x0003
-#define	VFE_CMD_IP_FORMAT_SEL_YCBYCR	0x0004
-#define	VFE_CMD_IP_FORMAT_SEL_YCRYCB	0x0005
-#define	VFE_CMD_IP_FORMAT_SEL_CBYCRY	0x0006
-#define	VFE_CMD_IP_FORMAT_SEL_CRYCBY	0x0007
-#define	VFE_CMD_IP_FORMAT_SEL_NO_CHROMA	0x0000
-#define	VFE_CMD_IP_FORMAT_SEL_CHROMA	0x0008
-
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	ip_format_sel;
-	unsigned int	balance_gains_part1;
-	unsigned int	balance_gains_part2;
-} __attribute__((packed)) vfe_cmd_ip_format_cfg;
-
-
-
-/*
- * Command to program max and min allowed op values
- */
-
-#define	VFE_CMD_OP_CLAMP_CFG		0x0009
-#define	VFE_CMD_OP_CLAMP_CFG_LEN	\
-	sizeof(vfe_cmd_op_clamp_cfg)
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	op_clamp_max;
-	unsigned int	op_clamp_min;
-} __attribute__((packed)) vfe_cmd_op_clamp_cfg;
-
-
-/*
- * Command to program chroma sub sample module
- */
-
-#define	VFE_CMD_CHROMA_SUBSAMPLE_CFG		0x000A
-#define	VFE_CMD_CHROMA_SUBSAMPLE_CFG_LEN	\
-	sizeof(vfe_cmd_chroma_subsample_cfg)
-
-#define	VFE_CMD_CHROMA_SUBSAMP_SEL_H_INTERESTIAL_SAMPS	0x0000
-#define	VFE_CMD_CHROMA_SUBSAMP_SEL_H_COSITED_SAMPS	0x0001
-#define	VFE_CMD_CHROMA_SUBSAMP_SEL_V_INTERESTIAL_SAMPS	0x0000
-#define	VFE_CMD_CHROMA_SUBSAMP_SEL_V_COSITED_SAMPS	0x0002
-#define	VFE_CMD_CHROMA_SUBSAMP_SEL_H_SUBSAMP_DIS	0x0000
-#define	VFE_CMD_CHROMA_SUBSAMP_SEL_H_SUBSAMP_ENA	0x0004
-#define	VFE_CMD_CHROMA_SUBSAMP_SEL_V_SUBSAMP_DIS	0x0000
-#define	VFE_CMD_CHROMA_SUBSAMP_SEL_V_SUBSAMP_ENA	0x0008
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	chroma_subsamp_sel;
-} __attribute__((packed)) vfe_cmd_chroma_subsample_cfg;
-
-
-/*
- * Command to program the white balance module
- */
-
-#define	VFE_CMD_WHITE_BALANCE_CFG	0x000B
-#define	VFE_CMD_WHITE_BALANCE_CFG_LEN	\
-	sizeof(vfe_cmd_white_balance_cfg)
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	white_balance_gains;
-} __attribute__((packed)) vfe_cmd_white_balance_cfg;
-
-
-/*
- * Command to program the color processing module
- */
-
-#define	VFE_CMD_COLOR_PROCESS_CFG	0x000C
-#define	VFE_CMD_COLOR_PROCESS_CFG_LEN	\
-	sizeof(vfe_cmd_color_process_cfg)
-
-#define	VFE_CMD_COLOR_CORRE_PART7_Q7_FACTORS	0x0000
-#define	VFE_CMD_COLOR_CORRE_PART7_Q8_FACTORS	0x0001
-#define	VFE_CMD_COLOR_CORRE_PART7_Q9_FACTORS	0x0002
-#define	VFE_CMD_COLOR_CORRE_PART7_Q10_FACTORS	0x0003
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	color_correction_part1;
-	unsigned int	color_correction_part2;
-	unsigned int	color_correction_part3;
-	unsigned int	color_correction_part4;
-	unsigned int	color_correction_part5;
-	unsigned int	color_correction_part6;
-	unsigned int	color_correction_part7;
-	unsigned int	chroma_enhance_part1;
-	unsigned int	chroma_enhance_part2;
-	unsigned int	chroma_enhance_part3;
-	unsigned int	chroma_enhance_part4;
-	unsigned int	chroma_enhance_part5;
-	unsigned int	luma_calc_part1;
-	unsigned int	luma_calc_part2;
-} __attribute__((packed)) vfe_cmd_color_process_cfg;
-
-
-/*
- * Command to program adaptive filter module
- */
-
-#define	VFE_CMD_ADP_FILTER_CFG		0x000D
-#define	VFE_CMD_ADP_FILTER_CFG_LEN	\
-	sizeof(vfe_cmd_adp_filter_cfg)
-
-#define	VFE_CMD_ASF_CFG_PART_SMOOTH_FILTER_DIS		0x0000
-#define	VFE_CMD_ASF_CFG_PART_SMOOTH_FILTER_ENA		0x0001
-#define	VFE_CMD_ASF_CFG_PART_NO_SHARP_MODE		0x0000
-#define	VFE_CMD_ASF_CFG_PART_SINGLE_FILTER		0x0002
-#define	VFE_CMD_ASF_CFG_PART_DUAL_FILTER		0x0004
-#define	VFE_CMD_ASF_CFG_PART_SHARP_MODE			0x0007
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	asf_cfg_part[7];
-} __attribute__((packed)) vfe_cmd_adp_filter_cfg;
-
-
-/*
- * Command to program for frame skip pattern for op1 and op2
- */
-
-#define	VFE_CMD_FRAME_SKIP_CFG		0x000E
-#define	VFE_CMD_FRAME_SKIP_CFG_LEN	\
-	sizeof(vfe_cmd_frame_skip_cfg)
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	frame_skip_pattern_op1;
-	unsigned int	frame_skip_pattern_op2;
-} __attribute__((packed)) vfe_cmd_frame_skip_cfg;
-
-
-/*
- * Command to program field-of-view crop for digital zoom
- */
-
-#define	VFE_CMD_FOV_CROP	0x000F
-#define	VFE_CMD_FOV_CROP_LEN	sizeof(vfe_cmd_fov_crop)
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	fov_crop_part1;
-	unsigned int	fov_crop_part2;
-} __attribute__((packed)) vfe_cmd_fov_crop; 
-
-
-
-/*
- * Command to program auto focus(AF) statistics module
- */
-
-#define	VFE_CMD_STATS_AUTOFOCUS_CFG	0x0010
-#define	VFE_CMD_STATS_AUTOFOCUS_CFG_LEN	\
-	sizeof(vfe_cmd_stats_autofocus_cfg)
-
-#define	VFE_CMD_AF_STATS_SEL_STATS_DIS	0x0000
-#define	VFE_CMD_AF_STATS_SEL_STATS_ENA	0x0001
-#define	VFE_CMD_AF_STATS_SEL_PRI_FIXED	0x0000
-#define	VFE_CMD_AF_STATS_SEL_PRI_VAR	0x0002
-#define	VFE_CMD_AF_STATS_CFG_PART_METRIC_SUM	0x00000000
-#define	VFE_CMD_AF_STATS_CFG_PART_METRIC_MAX	0x00200000
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	af_stats_sel;
-	unsigned int	af_stats_cfg_part[8];
-	unsigned int	af_stats_op_buf_hdr;
-	unsigned int	af_stats_op_buf[3];
-} __attribute__((packed)) vfe_cmd_stats_autofocus_cfg;
-
-
-/*
- * Command to program White balance(wb) and exposure (exp)
- * statistics module
- */
-
-#define	VFE_CMD_STATS_WB_EXP_CFG	0x0011
-#define	VFE_CMD_STATS_WB_EXP_CFG_LEN	\
-	sizeof(vfe_cmd_stats_wb_exp_cfg)
-
-#define	VFE_CMD_WB_EXP_STATS_SEL_STATS_DIS	0x0000
-#define	VFE_CMD_WB_EXP_STATS_SEL_STATS_ENA	0x0001
-#define	VFE_CMD_WB_EXP_STATS_SEL_PRI_FIXED	0x0000
-#define	VFE_CMD_WB_EXP_STATS_SEL_PRI_VAR	0x0002
-
-#define	VFE_CMD_WB_EXP_STATS_CFG_PART1_EXP_REG_8_8	0x0000
-#define	VFE_CMD_WB_EXP_STATS_CFG_PART1_EXP_REG_16_16	0x0001
-#define	VFE_CMD_WB_EXP_STATS_CFG_PART1_EXP_SREG_8_8	0x0000
-#define	VFE_CMD_WB_EXP_STATS_CFG_PART1_EXP_SREG_4_4	0x0002
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	wb_exp_stats_sel;
-	unsigned int	wb_exp_stats_cfg_part1;
-	unsigned int	wb_exp_stats_cfg_part2;
-	unsigned int	wb_exp_stats_cfg_part3;
-	unsigned int	wb_exp_stats_cfg_part4;
-	unsigned int	wb_exp_stats_op_buf_hdr;
-	unsigned int	wb_exp_stats_op_buf[3];
-} __attribute__((packed)) vfe_cmd_stats_wb_exp_cfg;
-
-
-/*
- * Command to program histogram(hg) stats module
- */
-
-#define	VFE_CMD_STATS_HG_CFG		0x0012
-#define	VFE_CMD_STATS_HG_CFG_LEN	\
-	sizeof(vfe_cmd_stats_hg_cfg)
-
-#define	VFE_CMD_HG_STATS_SEL_PRI_FIXED	0x0000
-#define	VFE_CMD_HG_STATS_SEL_PRI_VAR	0x0002
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	hg_stats_sel;
-	unsigned int	hg_stats_cfg_part1;
-	unsigned int	hg_stats_cfg_part2;
-	unsigned int	hg_stats_op_buf_hdr;
-	unsigned int	hg_stats_op_buf;
-} __attribute__((packed)) vfe_cmd_stats_hg_cfg;
-
-
-/*
- * Command to acknowledge last MSG_VFE_OP1 message
- */
-
-#define	VFE_CMD_OP1_ACK		0x0013
-#define	VFE_CMD_OP1_ACK_LEN	sizeof(vfe_cmd_op1_ack)
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	op1_buf_y_addr;
-	unsigned int	op1_buf_cbcr_addr;
-} __attribute__((packed)) vfe_cmd_op1_ack;
-
-
-
-/*
- * Command to acknowledge last MSG_VFE_OP2 message
- */
-
-#define	VFE_CMD_OP2_ACK		0x0014
-#define	VFE_CMD_OP2_ACK_LEN	sizeof(vfe_cmd_op2_ack)
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	op2_buf_y_addr;
-	unsigned int	op2_buf_cbcr_addr;
-} __attribute__((packed)) vfe_cmd_op2_ack;
-
-
-
-/*
- * Command to acknowledge MSG_VFE_STATS_AUTOFOCUS msg
- */
-
-#define	VFE_CMD_STATS_AF_ACK		0x0015
-#define	VFE_CMD_STATS_AF_ACK_LEN	sizeof(vfe_cmd_stats_af_ack)
-
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	af_stats_op_buf;
-} __attribute__((packed)) vfe_cmd_stats_af_ack;
-
-
-/*
- * Command to acknowledge MSG_VFE_STATS_WB_EXP msg
- */
-
-#define	VFE_CMD_STATS_WB_EXP_ACK	0x0016
-#define	VFE_CMD_STATS_WB_EXP_ACK_LEN	sizeof(vfe_cmd_stats_wb_exp_ack)
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	wb_exp_stats_op_buf;
-} __attribute__((packed)) vfe_cmd_stats_wb_exp_ack;
-
-
-/*
- * Command to acknowledge MSG_VFE_EPOCH1 message
- */
-
-#define	VFE_CMD_EPOCH1_ACK	0x0017
-#define	VFE_CMD_EPOCH1_ACK_LEN	sizeof(vfe_cmd_epoch1_ack)
-
-typedef struct {
-	unsigned short cmd_id;
-} __attribute__((packed)) vfe_cmd_epoch1_ack;
-
-
-/*
- * Command to acknowledge MSG_VFE_EPOCH2 message
- */
-
-#define	VFE_CMD_EPOCH2_ACK	0x0018
-#define	VFE_CMD_EPOCH2_ACK_LEN	sizeof(vfe_cmd_epoch2_ack)
-
-typedef struct {
-	unsigned short cmd_id;
-} __attribute__((packed)) vfe_cmd_epoch2_ack;
-
-
-
-/*
- * Command to configure, enable or disable synchronous timer1
- */
-
-#define	VFE_CMD_SYNC_TIMER1_CFG		0x0019
-#define	VFE_CMD_SYNC_TIMER1_CFG_LEN	\
-	sizeof(vfe_cmd_sync_timer1_cfg)
-
-#define	VFE_CMD_SYNC_T1_CFG_PART1_TIMER_DIS	0x0000
-#define	VFE_CMD_SYNC_T1_CFG_PART1_TIMER_ENA	0x0001
-#define	VFE_CMD_SYNC_T1_CFG_PART1_POL_HIGH	0x0000
-#define	VFE_CMD_SYNC_T1_CFG_PART1_POL_LOW	0x0002
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	sync_t1_cfg_part1;
-	unsigned int	sync_t1_h_sync_countdown;
-	unsigned int	sync_t1_pclk_countdown;
-	unsigned int	sync_t1_duration;
-} __attribute__((packed)) vfe_cmd_sync_timer1_cfg;
-
-
-/*
- * Command to configure, enable or disable synchronous timer1
- */
-
-#define	VFE_CMD_SYNC_TIMER2_CFG		0x001A
-#define	VFE_CMD_SYNC_TIMER2_CFG_LEN	\
-	sizeof(vfe_cmd_sync_timer2_cfg)
-
-#define	VFE_CMD_SYNC_T2_CFG_PART1_TIMER_DIS	0x0000
-#define	VFE_CMD_SYNC_T2_CFG_PART1_TIMER_ENA	0x0001
-#define	VFE_CMD_SYNC_T2_CFG_PART1_POL_HIGH	0x0000
-#define	VFE_CMD_SYNC_T2_CFG_PART1_POL_LOW	0x0002
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	sync_t2_cfg_part1;
-	unsigned int	sync_t2_h_sync_countdown;
-	unsigned int	sync_t2_pclk_countdown;
-	unsigned int	sync_t2_duration;
-} __attribute__((packed)) vfe_cmd_sync_timer2_cfg;
-
-
-/*
- * Command to configure and start asynchronous timer1
- */
-
-#define	VFE_CMD_ASYNC_TIMER1_START	0x001B
-#define	VFE_CMD_ASYNC_TIMER1_START_LEN	\
-	sizeof(vfe_cmd_async_timer1_start)
-
-#define	VFE_CMD_ASYNC_T1_POLARITY_A_HIGH	0x0000
-#define	VFE_CMD_ASYNC_T1_POLARITY_A_LOW		0x0001
-#define	VFE_CMD_ASYNC_T1_POLARITY_B_HIGH	0x0000
-#define	VFE_CMD_ASYNC_T1_POLARITY_B_LOW		0x0002
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	async_t1a_cfg;
-	unsigned int	async_t1b_cfg;
-	unsigned int	async_t1_polarity;
-} __attribute__((packed)) vfe_cmd_async_timer1_start;
-
-
-/*
- * Command to configure and start asynchronous timer2
- */
-
-#define	VFE_CMD_ASYNC_TIMER2_START	0x001C
-#define	VFE_CMD_ASYNC_TIMER2_START_LEN	\
-	sizeof(vfe_cmd_async_timer2_start)
-
-#define	VFE_CMD_ASYNC_T2_POLARITY_A_HIGH	0x0000
-#define	VFE_CMD_ASYNC_T2_POLARITY_A_LOW		0x0001
-#define	VFE_CMD_ASYNC_T2_POLARITY_B_HIGH	0x0000
-#define	VFE_CMD_ASYNC_T2_POLARITY_B_LOW		0x0002
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	async_t2a_cfg;
-	unsigned int	async_t2b_cfg;
-	unsigned int	async_t2_polarity;
-} __attribute__((packed)) vfe_cmd_async_timer2_start;
-
-
-/*
- * Command to program partial configurations of auto focus(af)
- */
-
-#define	VFE_CMD_STATS_AF_UPDATE		0x001D
-#define	VFE_CMD_STATS_AF_UPDATE_LEN	\
-	sizeof(vfe_cmd_stats_af_update)
-
-#define	VFE_CMD_AF_UPDATE_PART1_WINDOW_ONE	0x00000000
-#define	VFE_CMD_AF_UPDATE_PART1_WINDOW_MULTI	0x80000000
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	af_update_part1;
-	unsigned int	af_update_part2;
-} __attribute__((packed)) vfe_cmd_stats_af_update;
-
-
-/*
- * Command to program partial cfg of wb and exp
- */
-
-#define	VFE_CMD_STATS_WB_EXP_UPDATE	0x001E
-#define	VFE_CMD_STATS_WB_EXP_UPDATE_LEN	\
-	sizeof(vfe_cmd_stats_wb_exp_update)
-
-#define	VFE_CMD_WB_EXP_UPDATE_PART1_REGIONS_8_8		0x0000
-#define	VFE_CMD_WB_EXP_UPDATE_PART1_REGIONS_16_16	0x0001
-#define	VFE_CMD_WB_EXP_UPDATE_PART1_SREGIONS_8_8	0x0000
-#define	VFE_CMD_WB_EXP_UPDATE_PART1_SREGIONS_4_4	0x0002
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	wb_exp_update_part1;
-	unsigned int	wb_exp_update_part2;
-	unsigned int	wb_exp_update_part3;
-	unsigned int	wb_exp_update_part4;
-} __attribute__((packed)) vfe_cmd_stats_wb_exp_update;
-
-
-
-/*
- * Command to re program the CAMIF FRAME CONFIG settings
- */
-
-#define	VFE_CMD_UPDATE_CAMIF_FRAME_CFG		0x001F
-#define	VFE_CMD_UPDATE_CAMIF_FRAME_CFG_LEN	\
-	sizeof(vfe_cmd_update_camif_frame_cfg)
-
-typedef struct {
-	unsigned int	cmd_id;
-	unsigned int	camif_frame_cfg;
-} __attribute__((packed)) vfe_cmd_update_camif_frame_cfg;
-
-
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5vfemsg.h b/arch/arm/mach-msm/include/mach/qdsp5/qdsp5vfemsg.h
deleted file mode 100644
index 7d7f731..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/qdsp5vfemsg.h
+++ /dev/null
@@ -1,290 +0,0 @@
-#ifndef QDSP5VFEMSGI_H
-#define QDSP5VFEMSGI_H
-
-/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
-
-    V F E   I N T E R N A L   M E S S A G E S
-
-GENERAL DESCRIPTION
-  This file contains defintions of format blocks of commands 
-  that are sent by VFE Task
-
-REFERENCES
-  None
-
-EXTERNALIZED FUNCTIONS
-  None
-
-Copyright (c) 1992-2009, The Linux Foundation. All rights reserved.
-
-This software is licensed under the terms of the GNU General Public
-License version 2, as published by the Free Software Foundation, and
-may be copied, distributed, and modified under those terms.
- 
-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.
-
-*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
-/*===========================================================================
-
-                      EDIT HISTORY FOR FILE
-
-This section contains comments describing changes made to this file.
-Notice that changes are listed in reverse chronological order.
-   
-$Header: //source/qcom/qct/multimedia2/AdspSvc/7XXX/qdsp5cmd/video/qdsp5vfemsg.h#2 $ $DateTime: 2008/07/30 10:50:23 $ $Author: pavanr $                     
-Revision History:                                              
-  
-when       who     what, where, why
---------   ---     ----------------------------------------------------------
-06/12/08   sv      initial version
-===========================================================================*/
-
-
-/*
- * Message to acknowledge CMD_VFE_REST command
- */
-
-#define	VFE_MSG_RESET_ACK	0x0000
-#define	VFE_MSG_RESET_ACK_LEN	sizeof(vfe_msg_reset_ack)
-
-typedef struct {
-} __attribute__((packed)) vfe_msg_reset_ack;
-
-
-/*
- * Message to acknowledge CMD_VFE_START command
- */
-
-#define	VFE_MSG_START_ACK	0x0001
-#define	VFE_MSG_START_ACK_LEN	sizeof(vfe_msg_start_ack)
-
-typedef struct {
-} __attribute__((packed)) vfe_msg_start_ack;
-
-/*
- * Message to acknowledge CMD_VFE_STOP	command
- */
-
-#define	VFE_MSG_STOP_ACK	0x0002
-#define	VFE_MSG_STOP_ACK_LEN	sizeof(vfe_msg_stop_ack)
-
-typedef struct {
-} __attribute__((packed)) vfe_msg_stop_ack;
-
-
-/*
- * Message to acknowledge CMD_VFE_UPDATE command
- */
-
-#define	VFE_MSG_UPDATE_ACK	0x0003
-#define	VFE_MSG_UPDATE_ACK_LEN	sizeof(vfe_msg_update_ack)
-
-typedef struct {
-} __attribute__((packed)) vfe_msg_update_ack;
-
-
-/*
- * Message to notify the ARM that snapshot processing is complete
- * and that the VFE is now STATE_VFE_IDLE
- */
-
-#define	VFE_MSG_SNAPSHOT_DONE		0x0004
-#define	VFE_MSG_SNAPSHOT_DONE_LEN	\
-	sizeof(vfe_msg_snapshot_done)
-
-typedef struct {
-} __attribute__((packed)) vfe_msg_snapshot_done;
-
-
-
-/*
- * Message to notify ARM that illegal cmd was received and 
- * system is in the IDLE state
- */
-
-#define	VFE_MSG_ILLEGAL_CMD	0x0005
-#define	VFE_MSG_ILLEGAL_CMD_LEN	\
-	sizeof(vfe_msg_illegal_cmd)
-
-typedef struct {
-	unsigned int	status;
-} __attribute__((packed)) vfe_msg_illegal_cmd;
-
-
-/*
- * Message to notify ARM that op1 buf is full and ready
- */
-
-#define	VFE_MSG_OP1		0x0006
-#define	VFE_MSG_OP1_LEN		sizeof(vfe_msg_op1)
-
-typedef struct {
-	unsigned int	op1_buf_y_addr;
-	unsigned int	op1_buf_cbcr_addr;
-	unsigned int	black_level_even_col;
-	unsigned int	black_level_odd_col;
-	unsigned int	defect_pixels_detected;
-	unsigned int	asf_max_edge;
-} __attribute__((packed)) vfe_msg_op1; 
-
-
-/*
- * Message to notify ARM that op2 buf is full and ready
- */
-
-#define	VFE_MSG_OP2		0x0007
-#define	VFE_MSG_OP2_LEN		sizeof(vfe_msg_op2)
-
-typedef struct {
-	unsigned int	op2_buf_y_addr;
-	unsigned int	op2_buf_cbcr_addr;
-	unsigned int	black_level_even_col;
-	unsigned int	black_level_odd_col;
-	unsigned int	defect_pixels_detected;
-	unsigned int	asf_max_edge;
-} __attribute__((packed)) vfe_msg_op2; 
-
-
-/*
- * Message to notify ARM that autofocus(af) stats are ready
- */
-
-#define	VFE_MSG_STATS_AF	0x0008
-#define	VFE_MSG_STATS_AF_LEN	sizeof(vfe_msg_stats_af)
-
-typedef struct {
-	unsigned int	af_stats_op_buffer;
-} __attribute__((packed)) vfe_msg_stats_af;
-
-
-/*
- * Message to notify ARM that white balance(wb) and exposure (exp)
- * stats are ready
- */
-
-#define	VFE_MSG_STATS_WB_EXP		0x0009
-#define	VFE_MSG_STATS_WB_EXP_LEN	\
-	sizeof(vfe_msg_stats_wb_exp)
-
-typedef struct {
-	unsigned int	wb_exp_stats_op_buf;
-} __attribute__((packed)) vfe_msg_stats_wb_exp;
-
-
-/*
- * Message to notify the ARM that histogram(hg) stats are ready
- */
-
-#define	VFE_MSG_STATS_HG	0x000A
-#define	VFE_MSG_STATS_HG_LEN	sizeof(vfe_msg_stats_hg)
-
-typedef struct {
-	unsigned int	hg_stats_op_buf;
-} __attribute__((packed)) vfe_msg_stats_hg;
-
-
-/*
- * Message to notify the ARM that epoch1 event occurred in the CAMIF
- */
-
-#define	VFE_MSG_EPOCH1		0x000B
-#define	VFE_MSG_EPOCH1_LEN	sizeof(vfe_msg_epoch1)
-
-typedef struct {
-} __attribute__((packed)) vfe_msg_epoch1;
-
-
-/*
- * Message to notify the ARM that epoch2 event occurred in the CAMIF
- */
-
-#define	VFE_MSG_EPOCH2		0x000C
-#define	VFE_MSG_EPOCH2_LEN	sizeof(vfe_msg_epoch2)
-
-typedef struct {
-} __attribute__((packed)) vfe_msg_epoch2;
-
-
-/*
- * Message to notify the ARM that sync timer1 op is completed
- */
-
-#define	VFE_MSG_SYNC_T1_DONE		0x000D
-#define	VFE_MSG_SYNC_T1_DONE_LEN	sizeof(vfe_msg_sync_t1_done)
-
-typedef struct {
-} __attribute__((packed)) vfe_msg_sync_t1_done;
-
-
-/*
- * Message to notify the ARM that sync timer2 op is completed
- */
-
-#define	VFE_MSG_SYNC_T2_DONE		0x000E
-#define	VFE_MSG_SYNC_T2_DONE_LEN	sizeof(vfe_msg_sync_t2_done)
-
-typedef struct {
-} __attribute__((packed)) vfe_msg_sync_t2_done;
-
-
-/*
- * Message to notify the ARM that async t1 operation completed
- */
-
-#define	VFE_MSG_ASYNC_T1_DONE		0x000F
-#define	VFE_MSG_ASYNC_T1_DONE_LEN	sizeof(vfe_msg_async_t1_done)
-
-typedef struct {
-} __attribute__((packed)) vfe_msg_async_t1_done;
-
-
-
-/*
- * Message to notify the ARM that async t2 operation completed
- */
-
-#define	VFE_MSG_ASYNC_T2_DONE		0x0010
-#define	VFE_MSG_ASYNC_T2_DONE_LEN	sizeof(vfe_msg_async_t2_done)
-
-typedef struct {
-} __attribute__((packed)) vfe_msg_async_t2_done;
-
-
-
-/*
- * Message to notify the ARM that an error has occurred
- */
-
-#define	VFE_MSG_ERROR		0x0011
-#define	VFE_MSG_ERROR_LEN	sizeof(vfe_msg_error)
-
-#define	VFE_MSG_ERR_COND_NO_CAMIF_ERR		0x0000
-#define	VFE_MSG_ERR_COND_CAMIF_ERR		0x0001
-#define	VFE_MSG_ERR_COND_OP1_Y_NO_BUS_OF	0x0000
-#define	VFE_MSG_ERR_COND_OP1_Y_BUS_OF		0x0002
-#define	VFE_MSG_ERR_COND_OP1_CBCR_NO_BUS_OF	0x0000
-#define	VFE_MSG_ERR_COND_OP1_CBCR_BUS_OF	0x0004
-#define	VFE_MSG_ERR_COND_OP2_Y_NO_BUS_OF	0x0000
-#define	VFE_MSG_ERR_COND_OP2_Y_BUS_OF		0x0008
-#define	VFE_MSG_ERR_COND_OP2_CBCR_NO_BUS_OF	0x0000
-#define	VFE_MSG_ERR_COND_OP2_CBCR_BUS_OF	0x0010
-#define	VFE_MSG_ERR_COND_AF_NO_BUS_OF		0x0000
-#define	VFE_MSG_ERR_COND_AF_BUS_OF		0x0020
-#define	VFE_MSG_ERR_COND_WB_EXP_NO_BUS_OF	0x0000
-#define	VFE_MSG_ERR_COND_WB_EXP_BUS_OF		0x0040
-#define	VFE_MSG_ERR_COND_NO_AXI_ERR		0x0000
-#define	VFE_MSG_ERR_COND_AXI_ERR		0x0080
-
-#define	VFE_MSG_CAMIF_STS_IDLE			0x0000
-#define	VFE_MSG_CAMIF_STS_CAPTURE_DATA		0x0001
-
-typedef struct {
-	unsigned int	err_cond;
-	unsigned int	camif_sts;
-} __attribute__((packed)) vfe_msg_error;
-
-
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5/snd_adie.h b/arch/arm/mach-msm/include/mach/qdsp5/snd_adie.h
deleted file mode 100644
index 2bad3b0..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5/snd_adie.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- */
-
-#ifndef __SND_ADIE_SVC_H_
-#define __SND_ADIE_SVC_H_
-
-#define ADIE_SVC_PROG	0x30000002
-#define ADIE_SVC_VERS	0x00020003
-
-#define ADIE_SVC_CLIENT_STATUS_FUNC_PTR_TYPE_PROC 0xFFFFFF01
-#define SND_ADIE_SVC_CLIENT_REGISTER_PROC 	34
-#define SND_ADIE_SVC_CONFIG_ADIE_BLOCK_PROC 	35
-#define SND_ADIE_SVC_CLIENT_DEREGISTER_PROC 	36
-
-#define ADIE_SVC_MAX_CLIENTS 5
-
-enum adie_svc_client_operation{
-	ADIE_SVC_REGISTER_CLIENT,
-	ADIE_SVC_DEREGISTER_CLIENT,
-	ADIE_SVC_CONFIG_ADIE_BLOCK,
-};
-
-enum adie_svc_status_type{
-	ADIE_SVC_STATUS_SUCCESS,
-	ADIE_SVC_STATUS_FAILURE,
-	ADIE_SVC_STATUS_INUSE
-};
-
-enum adie_block_enum_type{
-	MIC_BIAS,
-	HSSD,
-	HPH_PA
-};
-
-enum adie_config_enum_type{
-	DISABLE,
-	ENABLE
-};
-
-struct adie_svc_client{
-	int client_id;
-	int cb_id;
-	enum adie_svc_status_type status;
-	bool adie_svc_cb_done;
-	struct mutex lock;
-	wait_queue_head_t wq;
-	struct msm_rpc_client *rpc_client;
-};
-
-struct adie_svc_client_register_cb_cb_args {
-	int cb_id;
-	uint32_t size;
-	int client_id;
-	enum adie_block_enum_type adie_block;
-	enum adie_svc_status_type status;
-	enum adie_svc_client_operation client_operation;
-};
-
-struct adie_svc_client_register_cb_args {
-	int cb_id;
-};
-
-struct adie_svc_client_deregister_cb_args {
-	int client_id;
-};
-
-struct adie_svc_config_adie_block_cb_args {
-	int client_id;
-	enum adie_block_enum_type adie_block;
-	enum adie_config_enum_type config;
-};
-
-int adie_svc_get(void);
-int adie_svc_put(int id);
-int adie_svc_config_adie_block(int id,
-	enum adie_block_enum_type adie_block_type, bool enable);
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/acdb_commands.h b/arch/arm/mach-msm/include/mach/qdsp5v2/acdb_commands.h
deleted file mode 100644
index 9386307..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/acdb_commands.h
+++ /dev/null
@@ -1,303 +0,0 @@
-/* Copyright (c) 2009-2011, The Linux Foundation. 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.
- *
- */
-#ifndef _MACH_QDSP5_V2_ACDB_COMMANDS_H
-#define _MACH_QDSP5_V2_ACDB_COMMANDS_H
-
-#define ACDB_VOICE_NETWORK_ID_DEFAULT		0x00010037
-#define ACDB_INITIALISING			0
-#define ACDB_READY				1
-
-
-/* 4KB */
-#define ACDB_PAGE_SIZE				0x1000
-
-#define ACDB_CDMA_NB		0x0108b153
-#define ACDB_CDMA_WB		0x0108b154
-#define ACDB_GSM_NB		0x0108b155
-#define ACDB_GSM_WB		0x0108b156
-#define ACDB_WCDMA_NB		0x0108b157
-#define ACDB_WCDMA_WB		0x0108b158
-
-
-/* ACDB commands */
-
-
-/* struct acdb_cmd_install_device */
-#define ACDB_INSTALL_DEVICE		0x0108d245
-
-/* struct acdb_cmd_install_device */
-#define ACDB_UNINSTALL_DEVICE		0x0108d246
-
-/* struct acdb_cmd_device */
-#define ACDB_GET_DEVICE			0x0108bb92
-
-/* struct acdb_cmd_device */
-#define ACDB_SET_DEVICE			0x0108bb93
-
-/* struct acdb_cmd_get_device_table */
-#define ACDB_GET_DEVICE_TABLE		0x0108bb97
-
-/* struct acdb_cmd_get_device_capabilities */
-#define ACDB_GET_DEVICE_CAPABILITIES	0x0108f5ca
-
-/* struct acdb_cmd_get_device_info */
-#define ACDB_GET_DEVICE_INFO		0x0108f5cb
-
-/*command to intitialize ACDB based on codec type*/
-#define ACDB_CMD_INITIALIZE_FOR_ADIE	0x00011283
-
-
-/* ACDB Error codes */
-
-#define ACDB_RES_SUCCESS		0
-#define ACDB_RES_FAILURE		-1
-#define ACDB_RES_BADPARM		-2
-#define ACDB_RES_BADSTATE		-3
-
-#define TGTVERS_MSM7x30_BRING_UP	0x00010064
-
-
-
-/* Algorithm Aspect IDs */
-
-#define IID_ENABLE_FLAG			0x0108b6b9
-
-
-#define IID_ENABLE_FLAG_SIZE					1
-#define IID_ECHO_CANCELLER_VERSION_SIZE				2
-#define IID_ECHO_CANCELLER_MODE_SIZE				2
-#define IID_ECHO_CANCELLER_NOISE_SUPPRESSOR_ENABLE_SIZE		1
-#define IID_ECHO_CANCELLER_PARAMETERS_SIZE			32
-#define IID_ECHO_CANCELLER_NEXTGEN_NB_PARAMETERS_SIZE		(38 * 2)
-#define IID_ECHO_CANCELLER_NEXTGEN_WB_PARAMETERS_SIZE		(38 * 2)
-#define IID_FLUENCE_PARAMETERS_SIZE				486
-#define IID_AFE_VOLUME_CONTROL_SIZE				6
-#define IID_GAIN_SIZE						2
-#define IID_VOICE_FIR_FILTER_SIZE				14
-#define IID_VOICE_IIR_FILTER_SIZE				114
-#define IID_RX_DBM_OFFSET_SIZE					2
-#define IID_AGC_SIZE						36
-#define IID_AVC_SIZE						80
-
-#define IID_AUDIO_IIR_COEFF_SIZE				100
-#define IID_MBADRC_PARAMETERS_SIZE				8
-#define IID_MBADRC_EXT_BUFF_SIZE				392
-#define IID_MBADRC_BAND_CONFIG_SIZE				100
-#define IID_QAFX_PARAMETERS_SIZE				2
-#define IID_QCONCERT_PARAMETERS_SIZE				2
-#define IID_AUDIO_AGC_PARAMETERS_SIZE				42
-#define IID_NS_PARAMETERS_SIZE					14
-
-#define IID_ECHO_CANCELLER_VERSION			0x00010042
-#define IID_ECHO_CANCELLER_MODE				0x00010043
-#define IID_ECHO_CANCELLER_NOISE_SUPPRESSOR_ENABLE	0x00010044
-#define IID_ECHO_CANCELLER_PARAMETERS			0x00010045
-#define IID_ECHO_CANCELLER_NEXTGEN_NB_PARAMETERS	0x00010046
-#define IID_ECHO_CANCELLER_NEXTGEN_WB_PARAMETERS	0x00010047
-#define IID_FLUENCE_PARAMETERS				0x00010048
-#define IID_AFE_VOLUME_CONTROL				0x00010049
-#define IID_GAIN					0x0001004A
-#define IID_VOICE_FIR_FILTER				0x0001004B
-#define IID_VOICE_IIR_FILTER				0x0001004C
-#define IID_AGC						0x0001004E
-#define IID_AVC						0x0001004F
-#define ABID_SIDETONE_GAIN				0x00010050
-#define ABID_TX_VOICE_GAIN				0x00010051
-#define ABID_TX_DTMF_GAIN				0x00010052
-#define ABID_CODEC_TX_GAIN				0x00010053
-#define ABID_HSSD					0x00010054
-#define ABID_TX_AGC					0x00010055
-#define ABID_TX_VOICE_FIR				0x00010056
-#define ABID_TX_VOICE_IIR				0x00010057
-#define ABID_ECHO_CANCELLER				0x00010058
-#define ABID_ECHO_CANCELLER_NB_LVHF			0x00010059
-#define ABID_ECHO_CANCELLER_WB_LVHF			0x0001005A
-#define ABID_FLUENCE					0x0001005B
-#define ABID_CODEC_RX_GAIN				0x0001005C
-#define ABID_RX_DBM_OFFSET				0x0001005D
-#define ABID_RX_AGC					0x0001005E
-#define ABID_AVC					0x0001005F
-#define ABID_RX_VOICE_FIR				0x00010060
-#define ABID_RX_VOICE_IIR				0x00010061
-#define ABID_AFE_VOL_CTRL				0x00010067
-
-
-/* AUDIO IDs */
-#define ABID_AUDIO_AGC_TX		0x00010068
-#define ABID_AUDIO_NS_TX		0x00010069
-#define ABID_VOICE_NS			0x0001006A
-#define ABID_AUDIO_IIR_TX		0x0001006B
-#define ABID_AUDIO_IIR_RX		0x0001006C
-#define ABID_AUDIO_MBADRC_RX		0x0001006E
-#define ABID_AUDIO_QAFX_RX		0x0001006F
-#define ABID_AUDIO_QCONCERT_RX		0x00010070
-#define ABID_AUDIO_STF_RX		0x00010071
-#define ABID_AUDIO_CALIBRATION_GAIN_RX  0x00011162
-#define ABID_AUDIO_CALIBRATION_GAIN_TX  0x00011149
-#define ABID_AUDIO_PBE_RX               0x00011197
-#define ABID_AUDIO_RMC_TX		0x00011226
-#define ABID_AUDIO_FLUENCE_TX		0x00011244
-
-
-#define IID_AUDIO_AGC_PARAMETERS	0x0001007E
-#define IID_NS_PARAMETERS		0x00010072
-#define IID_AUDIO_IIR_COEFF		0x00010073
-#define IID_MBADRC_EXT_BUFF		0x00010075
-#define IID_MBADRC_BAND_CONFIG		0x00010076
-#define IID_MBADRC_PARAMETERS		0x00010077
-#define IID_QAFX_PARAMETERS		0x00010079
-#define IID_QCONCERT_PARAMETERS		0x0001007A
-#define IID_STF_COEFF			0x0001007B
-#define IID_AUDIO_CALIBRATION_GAIN_RX   0x00011163
-#define IID_AUDIO_CALIBRATION_GAIN_TX   0x00011171
-#define IID_PBE_CONFIG_PARAMETERS       0x00011198
-#define IID_AUDIO_PBE_RX_ENABLE_FLAG    0x00011199
-#define IID_AUDIO_RMC_PARAM		0x00011227
-#define IID_AUDIO_FLUENCE_TX		0x00011245
-
-
-#define TOPID_RX_TOPOLOGY_1		0x00010062
-#define TOPID_TX_TOPOLOGY_1		0x00010063
-#define AFERID_INT_SINK			0x00010065
-#define AFERID_INT_SOURCE		0x00010066
-#define AFERID_NO_SINK			0x00000000
-#define AFERID_NULL_SINK		0x0108ea92
-
-
-struct acdb_cmd_install_device {
-	u32	command_id;
-	u32	device_id;
-	u32	topology_id;
-	u32	afe_routing_id;
-	u32	cad_routing_id;		/* see "Sample Rate Bit Mask" below */
-	u32	sample_rate_mask;
-
-	/* represents device direction: Tx, Rx (aux pga - loopback) */
-	u8	device_type;
-	u8	channel_config;		/* Mono or Stereo */
-	u32	adie_codec_path_id;
-};
-
-
-struct acdb_cmd_get_device_capabilities {
-	u32	command_id;
-	u32	total_bytes;	/* Length in bytes allocated for buffer */
-	u32	*phys_buf;	/* Physical Address of data */
-};
-
-
-struct acdb_cmd_get_device_info {
-	u32	command_id;
-	u32	device_id;
-	u32	total_bytes;	/* Length in bytes allocated for buffer */
-	u32	*phys_buf;	/* Physical Address of data */
-};
-
-struct acdb_cmd_device {
-	u32	command_id;
-	u32	device_id;
-	u32	network_id;
-	u32	sample_rate_id;		/* Actual sample rate value */
-	u32	interface_id;		/* See interface id's above */
-	u32	algorithm_block_id;	/* See enumerations above */
-	u32	total_bytes;		/* Length in bytes used by buffer */
-	u32	*phys_buf;		/* Physical Address of data */
-};
-
-struct acdb_cmd_get_device_table {
-	u32	command_id;
-	u32	device_id;
-	u32	network_id;
-	u32	sample_rate_id;		/* Actual sample rate value */
-	u32	total_bytes;		/* Length in bytes used by buffer */
-	u32	*phys_buf;		/* Physical Address of data */
-};
-
-struct acdb_result {
-	/* This field is populated in response to the */
-	/* ACDB_GET_DEVICE_CAPABILITIES command and indicates the total */
-	/* devices whose capabilities are copied to the physical memory. */
-	u32	total_devices;
-	u32	*buf;			/* Physical Address of data */
-	u32	used_bytes;		/* The size in bytes of the data */
-	u32	result;			/* See ACDB Error codes above */
-};
-
-struct acdb_device_capability {
-	u32	device_id;
-	u32	sample_rate_mask;	/* See "Sample Rate Bit Mask" below */
-};
-
-struct acdb_dev_info {
-	u32	cad_routing_id;
-	u32	sample_rate_mask;	/* See "Sample Rate Bit Mask" below */
-	u32	adsp_device_id;		/* QDSP6 device ID */
-	u32	device_type;		/* Tx, Rx  (aux pga - loopback) */
-	u32	channel_config;		/* Mono or Stereo */
-	s32	min_volume;		/* Min volume (mB) */
-	s32	max_volume;		/* Max volume (mB) */
-};
-
-/*structure is used to intialize ACDB software on modem
-based on adie type detected*/
-struct acdb_cmd_init_adie {
-    u32 command_id;
-    u32 adie_type;
-};
-
-#define ACDB_CURRENT_ADIE_MODE_UNKNOWN 0
-#define ACDB_CURRENT_ADIE_MODE_TIMPANI 1
-#define ACDB_CURRENT_ADIE_MODE_MARIMBA 2
-
-/* Sample Rate Bit Mask */
-
-/* AUX PGA devices will have a sample rate mask of 0xFFFFFFFF */
-/* 8kHz              0x00000001 */
-/* 11.025kHz         0x00000002 */
-/* 12kHz             0x00000004 */
-/* 16kHz             0x00000008 */
-/* 22.5kHz           0x00000010 */
-/* 24kHz             0x00000020 */
-/* 32kHz             0x00000040 */
-/* 44.1kHz           0x00000080 */
-/* 48kHz             0x00000100 */
-
-
-/* Device type enumeration */
-enum {
-	RX_DEVICE = 1,
-	TX_DEVICE,
-	AUXPGA_DEVICE,
-	DEVICE_TYPE_MAX
-};
-
-#ifdef CONFIG_DEBUG_FS
-/*These are ABID used for RTC*/
-#define ABID_AUDIO_RTC_MBADRC_RX 0x0001118A
-#define ABID_AUDIO_RTC_VOLUME_PAN_RX 0x0001118C
-#define ABID_AUDIO_RTC_SPA 0x0001118E
-#define ABID_AUDIO_RTC_EQUALIZER_PARAMETERS 0x0001119F
-
-/*These are IID used for RTC*/
-#define IID_AUDIO_RTC_MBADRC_PARAMETERS 0x0001118B
-#define IID_AUDIO_RTC_VOLUME_PAN_PARAMETERS 0x0001118D
-#define IID_AUDIO_RTC_SPA_PARAMETERS 0x0001118F
-#define IID_AUDIO_RTC_EQUALIZER_PARAMETERS 0x0001119E
-#define IID_AUDIO_RTC_AGC_PARAMETERS 0x000111A7
-#define IID_AUDIO_RTC_TX_IIR_COEFF 0x000111A8
-
-#endif
-
-
-#endif
-
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/adie_marimba.h b/arch/arm/mach-msm/include/mach/qdsp5v2/adie_marimba.h
deleted file mode 100644
index 1851322..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/adie_marimba.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* Copyright (c) 2009-2010, The Linux Foundation. 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.
- *
- */
-#ifndef __MACH_QDSP5_V2_ADIE_MARIMBA_H
-#define __MACH_QDSP5_V2_ADIE_MARIMBA_H
-
-#include <linux/types.h>
-
-/* Value Represents a entry */
-#define ADIE_CODEC_ACTION_ENTRY       0x1
-/* Value representing a delay wait */
-#define ADIE_CODEC_ACTION_DELAY_WAIT      0x2
-/* Value representing a stage reached */
-#define ADIE_CODEC_ACTION_STAGE_REACHED   0x3
-
-/* This value is the state after the client sets the path */
-#define ADIE_CODEC_PATH_OFF                                        0x0050
-
-/* State to which client asks the drv to proceed to where it can
- * set up the clocks and 0-fill PCM buffers
- */
-#define ADIE_CODEC_DIGITAL_READY                                   0x0100
-
-/* State to which client asks the drv to proceed to where it can
- * start sending data after internal steady state delay
- */
-#define ADIE_CODEC_DIGITAL_ANALOG_READY                            0x1000
-
-
-/*  Client Asks adie to switch off the Analog portion of the
- *  the internal codec. After the use of this path
- */
-#define ADIE_CODEC_ANALOG_OFF                                      0x0750
-
-
-/* Client Asks adie to switch off the digital portion of the
- *  the internal codec. After switching off the analog portion.
- *
- *  0-fill PCM may or maynot be sent at this point
- *
- */
-#define ADIE_CODEC_DIGITAL_OFF                                     0x0600
-
-/* State to which client asks the drv to write the default values
- * to the registers */
-#define ADIE_CODEC_FLASH_IMAGE 					   0x0001
-
-/* Path type */
-#define ADIE_CODEC_RX 0
-#define ADIE_CODEC_TX 1
-#define ADIE_CODEC_LB 3
-#define ADIE_CODEC_MAX 4
-
-#define ADIE_CODEC_PACK_ENTRY(reg, mask, val) ((val)|(mask << 8)|(reg << 16))
-
-#define ADIE_CODEC_UNPACK_ENTRY(packed, reg, mask, val) \
-	do { \
-		((reg) = ((packed >> 16) & (0xff))); \
-		((mask) = ((packed >> 8) & (0xff))); \
-		((val) = ((packed) & (0xff))); \
-	} while (0);
-
-struct adie_codec_action_unit {
-	u32 type;
-	u32 action;
-};
-
-struct adie_codec_hwsetting_entry{
-	struct adie_codec_action_unit *actions;
-	u32 action_sz;
-	u32 freq_plan;
-	u32 osr;
-	/* u32  VolMask;
-	 * u32  SidetoneMask;
-	 */
-};
-
-struct adie_codec_dev_profile {
-	u32 path_type; /* RX or TX */
-	u32 setting_sz;
-	struct adie_codec_hwsetting_entry *settings;
-};
-
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/afe.h b/arch/arm/mach-msm/include/mach/qdsp5v2/afe.h
deleted file mode 100644
index e4e2933..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/afe.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Copyright (c) 2009-2011, The Linux Foundation. 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.
- *
- */
-#ifndef _MACH_QDSP5_V2_AFE_H
-#define _MACH_QDSP5_V2_AFE_H
-
-#include <asm/types.h>
-#include <mach/qdsp5v2/audio_acdbi.h>
-
-#define AFE_HW_PATH_CODEC_RX    1
-#define AFE_HW_PATH_CODEC_TX    2
-#define AFE_HW_PATH_AUXPCM_RX   3
-#define AFE_HW_PATH_AUXPCM_TX   4
-#define AFE_HW_PATH_MI2S_RX     5
-#define AFE_HW_PATH_MI2S_TX     6
-
-#define AFE_VOLUME_UNITY 0x4000 /* Based on Q14 */
-
-struct msm_afe_config {
-	u16 sample_rate;
-	u16 channel_mode;
-	u16 volume;
-	/* To be expaned for AUX CODEC */
-};
-
-int afe_enable(u8 path_id, struct msm_afe_config *config);
-
-int afe_disable(u8 path_id);
-
-int afe_config_aux_codec(int pcm_ctl_value, int aux_codec_intf_value,
-			int data_format_pad);
-int afe_config_fm_codec(int fm_enable, uint16_t source);
-
-int afe_config_fm_volume(uint16_t volume);
-int afe_config_fm_calibration_gain(uint16_t device_id,
-			uint16_t calibration_gain);
-void afe_loopback(int enable);
-void afe_ext_loopback(int enable, int rx_copp_id, int tx_copp_id);
-
-void afe_device_volume_ctrl(u16 device_id, u16 device_volume);
-
-int afe_config_rmc_block(struct acdb_rmc_block *acdb_rmc);
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/audio_acdb_def.h b/arch/arm/mach-msm/include/mach/qdsp5v2/audio_acdb_def.h
deleted file mode 100644
index 0a0c308..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/audio_acdb_def.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Copyright (c) 2010 - 2011, The Linux Foundation. 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.
- *
- */
-#ifndef _MACH_QDSP5_V2_AUDIO_ACDB_DEF_H
-#define _MACH_QDSP5_V2_AUDIO_ACDB_DEF_H
-
-/* Define ACDB device ID */
-#define ACDB_ID_HANDSET_SPKR				1
-#define ACDB_ID_HANDSET_MIC				2
-#define ACDB_ID_HEADSET_MIC				3
-#define ACDB_ID_HEADSET_SPKR_MONO			4
-#define ACDB_ID_HEADSET_SPKR_STEREO			5
-#define ACDB_ID_SPKR_PHONE_MIC				6
-#define ACDB_ID_SPKR_PHONE_MONO				7
-#define ACDB_ID_SPKR_PHONE_STEREO			8
-#define ACDB_ID_BT_SCO_MIC				9
-#define ACDB_ID_BT_SCO_SPKR				0x0A
-#define ACDB_ID_BT_A2DP_SPKR				0x0B
-#define ACDB_ID_BT_A2DP_TX				0x10
-#define ACDB_ID_TTY_HEADSET_MIC				0x0C
-#define ACDB_ID_TTY_HEADSET_SPKR			0x0D
-#define ACDB_ID_HEADSET_MONO_PLUS_SPKR_MONO_RX		0x11
-#define ACDB_ID_HEADSET_STEREO_PLUS_SPKR_STEREO_RX	0x14
-#define ACDB_ID_FM_TX_LOOPBACK				0x17
-#define ACDB_ID_FM_TX					0x18
-#define ACDB_ID_LP_FM_SPKR_PHONE_STEREO_RX		0x19
-#define ACDB_ID_LP_FM_HEADSET_SPKR_STEREO_RX		0x1A
-#define ACDB_ID_I2S_RX					0x20
-#define ACDB_ID_SPKR_PHONE_MIC_BROADSIDE		0x2B
-#define ACDB_ID_HANDSET_MIC_BROADSIDE			0x2C
-#define ACDB_ID_SPKR_PHONE_MIC_ENDFIRE			0x2D
-#define ACDB_ID_HANDSET_MIC_ENDFIRE			0x2E
-#define ACDB_ID_I2S_TX					0x30
-#define ACDB_ID_HDMI					0x40
-#define ACDB_ID_FM_RX					0x4F
-/*Replace the max device ID,if any new device is added Specific to RTC only*/
-#define ACDB_ID_MAX                                 ACDB_ID_FM_RX
-
-/* ID used for virtual devices */
-#define PSEUDO_ACDB_ID 					0xFFFF
-
-#endif /* _MACH_QDSP5_V2_AUDIO_ACDB_DEF_H */
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/audio_acdbi.h b/arch/arm/mach-msm/include/mach/qdsp5v2/audio_acdbi.h
deleted file mode 100644
index f05ebaa..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/audio_acdbi.h
+++ /dev/null
@@ -1,303 +0,0 @@
-/* Copyright (c) 2009-2011, The Linux Foundation. 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.
- *
- */
-#ifndef _MACH_QDSP5_V2_AUDIO_ACDBI_H
-#define _MACH_QDSP5_V2_AUDIO_ACDBI_H
-
-#define DBOR_SIGNATURE	0x524F4244
-
-#ifdef CONFIG_DEBUG_FS
-void acdb_rtc_set_err(u32 ErrCode);
-#endif
-
-
-struct header {
-	u32 dbor_signature;
-	u32 abid;
-	u32 iid;
-	u32 data_len;
-};
-
-enum {
-	ACDB_AGC_BLOCK			= 197,
-	ACDB_IIR_BLOCK			= 245,
-	ACDB_MBADRC_BLOCK		= 343
-};
-
-/* Structure to query for acdb parameter */
-struct acdb_get_block {
-	u32	acdb_id;
-	u32	sample_rate_id;		/* Actual sample rate value */
-	u32	interface_id;		/* Interface id's */
-	u32	algorithm_block_id;	/* Algorithm block id */
-	u32	total_bytes;		/* Length in bytes used by buffer for
-						configuration */
-	u32	*buf_ptr;		/* Address for storing configuration
-						data */
-};
-
-struct acdb_agc_block {
-	u16	enable_status;
-	u16	comp_rlink_static_gain;
-	u16	comp_rlink_aig_flag;
-	u16	exp_rlink_threshold;
-	u16	exp_rlink_slope;
-	u16	comp_rlink_threshold;
-	u16	comp_rlink_slope;
-	u16	comp_rlink_aig_attack_k;
-	u16	comp_rlink_aig_leak_down;
-	u16	comp_rlink_aig_leak_up;
-	u16	comp_rlink_aig_max;
-	u16	comp_rlink_aig_min;
-	u16	comp_rlink_aig_release_k;
-	u16	comp_rlink_aig_sm_leak_rate_fast;
-	u16	comp_rlink_aig_sm_leak_rate_slow;
-	u16	comp_rlink_attack_k_msw;
-	u16	comp_rlink_attack_k_lsw;
-	u16	comp_rlink_delay;
-	u16	comp_rlink_release_k_msw;
-	u16	comp_rlink_release_k_lsw;
-	u16	comp_rlink_rms_trav;
-};
-
-
-struct iir_coeff_type {
-	u16	b0_lo;
-	u16	b0_hi;
-	u16	b1_lo;
-	u16	b1_hi;
-	u16	b2_lo;
-	u16	b2_hi;
-};
-
-struct iir_coeff_stage_a {
-	u16	a1_lo;
-	u16	a1_hi;
-	u16	a2_lo;
-	u16	a2_hi;
-};
-
-struct acdb_iir_block {
-	u16			enable_flag;
-	u16			stage_count;
-	struct iir_coeff_type	stages[4];
-	struct iir_coeff_stage_a stages_a[4];
-	u16			shift_factor[4];
-	u16			pan[4];
-};
-
-
-
-struct mbadrc_band_config_type {
-	u16	mbadrc_sub_band_enable;
-	u16	mbadrc_sub_mute;
-	u16	mbadrc_comp_rms_tav;
-	u16	mbadrc_comp_threshold;
-	u16	mbadrc_comp_slop;
-	u16	mbadrc_comp_attack_msw;
-	u16	mbadrc_comp_attack_lsw;
-	u16	mbadrc_comp_release_msw;
-	u16	mbadrc_comp_release_lsw;
-	u16	mbadrc_make_up_gain;
-};
-
-struct mbadrc_parameter {
-	u16				mbadrc_enable;
-	u16				mbadrc_num_bands;
-	u16				mbadrc_down_sample_level;
-	u16				mbadrc_delay;
-};
-
-struct acdb_mbadrc_block {
-	u16				ext_buf[196];
-	struct mbadrc_band_config_type	band_config[5];
-	struct mbadrc_parameter		parameters;
-};
-
-struct  acdb_calib_gain_rx {
-	u16 audppcalgain;
-	u16 reserved;
-};
-
-struct acdb_calib_gain_tx {
-	u16 audprecalgain;
-	u16 reserved;
-};
-
-struct acdb_pbe_block {
-	s16 realbassmix;
-	s16 basscolorcontrol;
-	u16 mainchaindelay;
-	u16 xoverfltorder;
-	u16 bandpassfltorder;
-	s16 adrcdelay;
-	u16 downsamplelevel;
-	u16 comprmstav;
-	s16 expthreshold;
-	u16 expslope;
-	u16 compthreshold;
-	u16 compslope;
-	u16 cpmpattack_lsw;
-	u16 compattack_msw;
-	u16 comprelease_lsw;
-	u16 comprelease_msw;
-	u16 compmakeupgain;
-	s16 baselimthreshold;
-	s16 highlimthreshold;
-	s16 basslimmakeupgain;
-	s16 highlimmakeupgain;
-	s16 limbassgrc;
-	s16 limhighgrc;
-	s16 limdelay;
-	u16 filter_coeffs[90];
-};
-
-struct acdb_rmc_block  {
-	s16 rmc_enable;
-	u16 rmc_ipw_length_ms;
-	u16 rmc_detect_start_threshdb;
-	u16 rmc_peak_length_ms;
-	s16 rmc_init_pulse_threshdb;
-	u16 rmc_init_pulse_length_ms;
-	u16 rmc_total_int_length_ms;
-	u16 rmc_rampupdn_length_ms;
-	u16 rmc_delay_length_ms;
-	u16 reserved00;
-	u16 reserved01;
-	s16 reserved02;
-	s16 reserved03;
-	s16 reserved04;
-};
-
-struct acdb_fluence_block {
-	u16 csmode;
-	u16 cs_tuningMode;
-	u16 cs_echo_path_delay_by_80;
-	u16 cs_echo_path_delay;
-	u16 af1_twoalpha;
-	u16 af1_erl;
-	u16 af1_taps;
-	u16 af1_preset_coefs;
-	u16 af1_offset;
-	u16 af2_twoalpha;
-	u16 af2_erl;
-	u16 af2_taps;
-	u16 af2_preset_coefs;
-	u16 af2_offset;
-	u16 pcd_twoalpha;
-	u16 pcd_offset;
-	u16 cspcd_threshold;
-	u16 wgthreshold;
-	u16 mpthreshold;
-	u16 sf_init_table_0[8];
-	u16 sf_init_table_1[8];
-	u16 sf_taps;
-	u16 sf_twoalpha;
-	u16 dnns_echoalpharev;
-	u16 dnns_echoycomp;
-	u16 dnns_wbthreshold;
-	u16 dnns_echogammahi;
-	u16 dnns_echogammalo;
-	u16 dnns_noisegammas;
-	u16 dnns_noisegamman;
-	u16 dnns_noisegainmins;
-	u16 dnns_noisegainminn;
-	u16 dnns_noisebiascomp;
-	u16 dnns_acthreshold;
-	u16 wb_echo_ratio_2mic;
-	u16 wb_gamma_e;
-	u16 wb_gamma_nn;
-	u16 wb_gamma_sn;
-	u16 vcodec_delay0;
-	u16 vcodec_delay1;
-	u16 vcodec_len0;
-	u16 vcodec_len1;
-	u16 vcodec_thr0;
-	u16 vcodec_thr1;
-	u16 fixcalfactorleft;
-	u16 fixcalfactorright;
-	u16 csoutputgain;
-	u16 enh_meu_1;
-	u16 enh_meu_2;
-	u16 fixed_over_est;
-	u16 rx_nlpp_limit;
-	u16 rx_nlpp_gain;
-	u16 wnd_threshold;
-	u16 wnd_ns_hover;
-	u16 wnd_pwr_smalpha;
-	u16 wnd_det_esmalpha;
-	u16 wnd_ns_egoffset;
-	u16 wnd_sm_ratio;
-	u16 wnd_det_coefs[5];
-	u16 wnd_th1;
-	u16 wnd_th2;
-	u16 wnd_fq;
-	u16 wnd_dfc;
-	u16 wnd_sm_alphainc;
-	u16 wnd_sm_alphsdec;
-	u16 lvnv_spdet_far;
-	u16 lvnv_spdet_mic;
-	u16 lvnv_spdet_xclip;
-	u16 dnns_nl_atten;
-	u16 dnns_cni_level;
-	u16 dnns_echogammaalpha;
-	u16 dnns_echogammarescue;
-	u16 dnns_echogammadt;
-	u16 mf_noisegammafac;
-	u16 e_noisegammafac;
-	u16 dnns_noisegammainit;
-	u16 sm_noisegammas;
-	u16 wnd_noisegamman;
-	u16 af_taps_bg_spkr;
-	u16 af_erl_bg_spkr;
-	u16 minimum_erl_bg;
-	u16 erl_step_bg;
-	u16 upprisecalpha;
-	u16 upprisecthresh;
-	u16 uppriwindbias;
-	u16 e_pcd_threshold;
-	u16 nv_maxvadcount;
-	u16 crystalspeechreserved[38];
-	u16 cs_speaker[7];
-	u16 ns_fac;
-	u16 ns_blocksize;
-	u16 is_bias;
-	u16 is_bias_inp;
-	u16 sc_initb;
-	u16 ac_resetb;
-	u16 sc_avar;
-	u16 is_hover[5];
-	u16 is_cf_level;
-	u16 is_cf_ina;
-	u16 is_cf_inb;
-	u16 is_cf_a;
-	u16 is_cf_b;
-	u16 sc_th;
-	u16 sc_pscale;
-	u16 sc_nc;
-	u16 sc_hover;
-	u16 sc_alphas;
-	u16 sc_cfac;
-	u16 sc_sdmax;
-	u16 sc_sdmin;
-	u16 sc_initl;
-	u16 sc_maxval;
-	u16 sc_spmin;
-	u16 is_ec_th;
-	u16 is_fx_dl;
-	u16 coeffs_iva_filt_0[32];
-	u16 coeffs_iva_filt_1[32];
-};
-
-s32 acdb_get_calibration_data(struct acdb_get_block *get_block);
-void fluence_feature_update(int enable, int stream_id);
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/audio_def.h b/arch/arm/mach-msm/include/mach/qdsp5v2/audio_def.h
deleted file mode 100644
index 35a4d5c..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/audio_def.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright (c) 2009,2011, The Linux Foundation. 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.
- *
- */
-#ifndef _MACH_QDSP5_V2_AUDIO_DEF_H
-#define _MACH_QDSP5_V2_AUDIO_DEF_H
-
-/* Define sound device capability */
-#define SNDDEV_CAP_RX 0x1 /* RX direction */
-#define SNDDEV_CAP_TX 0x2 /* TX direction */
-#define SNDDEV_CAP_VOICE 0x4 /* Support voice call */
-#define SNDDEV_CAP_PLAYBACK 0x8 /* Support playback */
-#define SNDDEV_CAP_FM 0x10 /* Support FM radio */
-#define SNDDEV_CAP_TTY 0x20 /* Support TTY */
-#define SNDDEV_CAP_ANC 0x40 /* Support ANC */
-#define SNDDEV_CAP_LB 0x80 /* Loopback */
-#define VOC_NB_INDEX	0
-#define VOC_WB_INDEX	1
-#define VOC_RX_VOL_ARRAY_NUM	2
-
-/* Device volume types . In Current deisgn only one of these are supported. */
-#define SNDDEV_DEV_VOL_DIGITAL  0x1  /* Codec Digital volume control */
-#define SNDDEV_DEV_VOL_ANALOG   0x2  /* Codec Analog volume control */
-
-#define SIDE_TONE_MASK	0x01
-
-#endif /* _MACH_QDSP5_V2_AUDIO_DEF_H */
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/audio_dev_ctl.h b/arch/arm/mach-msm/include/mach/qdsp5v2/audio_dev_ctl.h
deleted file mode 100644
index 976d9ae..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/audio_dev_ctl.h
+++ /dev/null
@@ -1,206 +0,0 @@
-/* Copyright (c) 2009-2011, The Linux Foundation. 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.
- *
- */
-#ifndef __MACH_QDSP5_V2_SNDDEV_H
-#define __MACH_QDSP5_V2_SNDDEV_H
-#include <mach/qdsp5v2/audio_def.h>
-
-#define AUDIO_DEV_CTL_MAX_DEV 64
-#define DIR_TX	2
-#define DIR_RX	1
-
-#define DEVICE_IGNORE	0xff
-#define SESSION_IGNORE 0x00000000
-
-#define VOICE_STATE_INVALID 0x0
-#define VOICE_STATE_INCALL 0x1
-#define VOICE_STATE_OFFCALL 0x2
-#define MAX_COPP_NODE_SUPPORTED 6
-#define MAX_AUDREC_SESSIONS 3
-
-#define REAL_STEREO_CHANNEL_MODE	9
-
-struct msm_snddev_info {
-	const char *name;
-	u32 capability;
-	u32 copp_id;
-	u32 acdb_id;
-	u32 dev_volume;
-	struct msm_snddev_ops {
-		int (*open)(struct msm_snddev_info *);
-		int (*close)(struct msm_snddev_info *);
-		int (*set_freq)(struct msm_snddev_info *, u32);
-		int (*enable_sidetone)(struct msm_snddev_info *, u32);
-		int (*set_device_volume)(struct msm_snddev_info *, u32);
-	} dev_ops;
-	u8 opened;
-	void *private_data;
-	bool state;
-	u32 sample_rate;
-	u32 set_sample_rate;
-	u32 sessions;
-	int usage_count;
-	s32 max_voc_rx_vol[VOC_RX_VOL_ARRAY_NUM]; /* [0] is for NB,[1] for WB */
-	s32 min_voc_rx_vol[VOC_RX_VOL_ARRAY_NUM];
-};
-
-struct msm_volume {
-	int volume; /* Volume parameter, in % Scale */
-	int pan;
-};
-
-extern struct msm_volume msm_vol_ctl;
-
-int msm_get_dual_mic_config(int enc_session_id);
-int msm_set_dual_mic_config(int enc_session_id, int config);
-int msm_reset_all_device(void);
-void msm_snddev_register(struct msm_snddev_info *);
-void msm_snddev_unregister(struct msm_snddev_info *);
-int msm_snddev_devcount(void);
-int msm_snddev_query(int dev_id);
-unsigned short msm_snddev_route_dec(int popp_id);
-unsigned short msm_snddev_route_enc(int enc_id);
-int msm_snddev_set_dec(int popp_id, int copp_id, int set);
-int msm_snddev_set_enc(int popp_id, int copp_id, int set);
-int msm_snddev_is_set(int popp_id, int copp_id);
-int msm_get_voc_route(u32 *rx_id, u32 *tx_id);
-int msm_set_voc_route(struct msm_snddev_info *dev_info, int stream_type,
-			int dev_id);
-int msm_snddev_enable_sidetone(u32 dev_id, u32 enable);
-
-struct msm_snddev_info *audio_dev_ctrl_find_dev(u32 dev_id);
-
-void msm_release_voc_thread(void);
-
-int snddev_voice_set_volume(int vol, int path);
-
-struct auddev_evt_voc_devinfo {
-	u32 dev_type;           /* Rx or Tx */
-	u32 acdb_dev_id;        /* acdb id of device */
-	u32 dev_sample;         /* Sample rate of device */
-	s32 max_rx_vol[VOC_RX_VOL_ARRAY_NUM]; 	/* unit is mb (milibel),
-						[0] is for NB, other for WB */
-	s32 min_rx_vol[VOC_RX_VOL_ARRAY_NUM];	/* unit is mb */
-	u32 dev_id;             /* registered device id */
-};
-
-struct auddev_evt_audcal_info {
-	u32 dev_id;
-	u32 acdb_id;
-	u32 sample_rate;
-	u32 dev_type;
-	u32 sessions;
-};
-
-struct auddev_evt_devinfo {
-	u32 dev_id;
-	u32 acdb_id;
-	u32 sample_rate;
-	u32 dev_type;
-	u32 sessions;
-};
-
-union msm_vol_mute {
-	int vol;
-	bool mute;
-};
-
-struct auddev_evt_voc_mute_info {
-	u32 dev_type;
-	u32 acdb_dev_id;
-	union msm_vol_mute dev_vm_val;
-};
-
-struct auddev_evt_freq_info {
-	u32 dev_type;
-	u32 acdb_dev_id;
-	u32 sample_rate;
-};
-
-union auddev_evt_data {
-	struct auddev_evt_voc_devinfo voc_devinfo;
-	struct auddev_evt_voc_mute_info voc_vm_info;
-	struct auddev_evt_freq_info freq_info;
-	u32 routing_id;
-	s32 session_vol;
-	s32 voice_state;
-	struct auddev_evt_audcal_info audcal_info;
-	struct auddev_evt_devinfo devinfo;
-};
-
-struct message_header {
-	uint32_t id;
-	uint32_t data_len;
-};
-
-#define AUDDEV_EVT_DEV_CHG_VOICE	0x01 	/* device change event */
-#define AUDDEV_EVT_DEV_RDY 		0x02 	/* device ready event */
-#define AUDDEV_EVT_DEV_RLS 		0x04 	/* device released event */
-#define AUDDEV_EVT_REL_PENDING		0x08 	/* device release pending */
-#define AUDDEV_EVT_DEVICE_VOL_MUTE_CHG	0x10 	/* device volume changed */
-#define AUDDEV_EVT_START_VOICE		0x20	/* voice call start */
-#define AUDDEV_EVT_END_VOICE		0x40	/* voice call end */
-#define AUDDEV_EVT_STREAM_VOL_CHG	0x80 	/* device volume changed */
-#define AUDDEV_EVT_FREQ_CHG		0x100	/* Change in freq */
-#define AUDDEV_EVT_VOICE_STATE_CHG	0x200   /* Change in voice state */
-#define AUDDEV_EVT_DEVICE_INFO		0x400	/* routed device information
-							event */
-
-#define AUDDEV_CLNT_VOC 		0x1	/* Vocoder clients */
-#define AUDDEV_CLNT_DEC 		0x2	/* Decoder clients */
-#define AUDDEV_CLNT_ENC 		0x3	/* Encoder clients */
-#define AUDDEV_CLNT_AUDIOCAL 		0x4	/* AudioCalibration client */
-
-#define AUDIO_DEV_CTL_MAX_LISTNER	20	/* Max Listeners Supported */
-
-struct msm_snd_evt_listner {
-	uint32_t evt_id;
-	uint32_t clnt_type;
-	uint32_t clnt_id;
-	void *private_data;
-	void (*auddev_evt_listener)(u32 evt_id,
-		union auddev_evt_data *evt_payload,
-		void *private_data);
-	struct msm_snd_evt_listner *cb_next;
-	struct msm_snd_evt_listner *cb_prev;
-};
-
-struct event_listner {
-	struct msm_snd_evt_listner *cb;
-	u32 num_listner;
-	int state; /* Call state */ /* TODO remove this if not req*/
-};
-
-extern struct event_listner event;
-int auddev_register_evt_listner(u32 evt_id, u32 clnt_type, u32 clnt_id,
-		void (*listner)(u32 evt_id,
-			union auddev_evt_data *evt_payload,
-			void *private_data),
-		void *private_data);
-int auddev_unregister_evt_listner(u32 clnt_type, u32 clnt_id);
-void mixer_post_event(u32 evt_id, u32 dev_id);
-void broadcast_event(u32 evt_id, u32 dev_id, u32 session_id);
-int msm_snddev_request_freq(int *freq, u32 session_id,
-			u32 capability, u32 clnt_type);
-int msm_snddev_withdraw_freq(u32 session_id,
-			u32 capability, u32 clnt_type);
-int msm_device_is_voice(int dev_id);
-int msm_get_voc_freq(int *tx_freq, int *rx_freq);
-int msm_snddev_get_enc_freq(int session_id);
-int msm_set_voice_vol(int dir, s32 volume);
-int msm_set_voice_mute(int dir, int mute);
-int msm_get_voice_state(void);
-#ifdef CONFIG_DEBUG_FS
-bool is_dev_opened(u32 acdb_id);
-#endif
-
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/audio_interct.h b/arch/arm/mach-msm/include/mach/qdsp5v2/audio_interct.h
deleted file mode 100644
index 2690bf5..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/audio_interct.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-#ifndef __MACH_QDSP5_V2_AUDIO_INTERCT_H
-#define __MACH_QDSP5_V2_AUDIO_INTERCT_H
-
-#define AUDIO_INTERCT_ADSP 0
-#define AUDIO_INTERCT_LPA 1
-#define AUDIO_ADSP_A 1
-#define AUDIO_ADSP_V 0
-
-void audio_interct_lpa(u32 source);
-void audio_interct_aux_regsel(u32 source);
-void audio_interct_rpcm_source(u32 source);
-void audio_interct_tpcm_source(u32 source);
-void audio_interct_pcmmi2s(u32 source);
-void audio_interct_codec(u32 source);
-void audio_interct_multichannel(u32 source);
-
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/audpp.h b/arch/arm/mach-msm/include/mach/qdsp5v2/audpp.h
deleted file mode 100644
index 763a651..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/audpp.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/*arch/arm/mach-msm/qdsp5iv2/audpp.h
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (c) 2008-2011, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
-*/
-
-#ifndef _MACH_QDSP5_V2_AUDPP_H
-#define _MACH_QDSP5_V2_AUDPP_H
-
-#include <mach/qdsp5v2/qdsp5audppcmdi.h>
-
-typedef void (*audpp_event_func)(void *private, unsigned id, uint16_t *msg);
-
-/* worst case delay of 1sec for response */
-#define MSM_AUD_DECODER_WAIT_MS 1000
-#define MSM_AUD_MODE_TUNNEL  0x00000100
-#define MSM_AUD_MODE_NONTUNNEL  0x00000200
-#define MSM_AUD_MODE_LP  0x00000400
-#define MSM_AUD_DECODER_MASK  0x0000FFFF
-#define MSM_AUD_OP_MASK  0xFFFF0000
-
-/* read call timeout for error cases */
-#define MSM_AUD_BUFFER_UPDATE_WAIT_MS 2000
-
-/* stream info error message mask */
-#define AUDPLAY_STREAM_INFO_MSG_MASK 0xFFFF0000
-#define AUDPLAY_ERROR_THRESHOLD_ENABLE 0xFFFFFFFF
-
-#define NON_TUNNEL_MODE_PLAYBACK 1
-#define TUNNEL_MODE_PLAYBACK 0
-
-#define AUDPP_MIXER_ICODEC AUDPP_CMD_CFG_DEV_MIXER_DEV_0
-#define AUDPP_MIXER_1 AUDPP_CMD_CFG_DEV_MIXER_DEV_1
-#define AUDPP_MIXER_2 AUDPP_CMD_CFG_DEV_MIXER_DEV_2
-#define AUDPP_MIXER_3 AUDPP_CMD_CFG_DEV_MIXER_DEV_3
-#define AUDPP_MIXER_HLB AUDPP_CMD_CFG_DEV_MIXER_DEV_4
-#define AUDPP_MIXER_NONHLB (AUDPP_CMD_CFG_DEV_MIXER_DEV_0 | \
-			AUDPP_CMD_CFG_DEV_MIXER_DEV_1 | \
-			AUDPP_CMD_CFG_DEV_MIXER_DEV_2 | \
-			AUDPP_CMD_CFG_DEV_MIXER_DEV_3)
-#define AUDPP_MIXER_UPLINK_RX		AUDPP_CMD_CFG_DEV_MIXER_DEV_5
-#define AUDPP_MAX_COPP_DEVICES		6
-
-enum obj_type {
-	COPP,
-	POPP
-};
-
-enum msm_aud_decoder_state {
-	MSM_AUD_DECODER_STATE_NONE = 0,
-	MSM_AUD_DECODER_STATE_FAILURE = 1,
-	MSM_AUD_DECODER_STATE_SUCCESS = 2,
-	MSM_AUD_DECODER_STATE_CLOSE = 3,
-};
-
-int audpp_adec_alloc(unsigned dec_attrb, const char **module_name,
-			unsigned *queueid);
-void audpp_adec_free(int decid);
-
-struct audpp_event_callback {
-	audpp_event_func fn;
-	void *private;
-};
-
-int audpp_register_event_callback(struct audpp_event_callback *eh);
-int audpp_unregister_event_callback(struct audpp_event_callback *eh);
-int is_audpp_enable(void);
-
-int audpp_enable(int id, audpp_event_func func, void *private);
-void audpp_disable(int id, void *private);
-
-int audpp_send_queue1(void *cmd, unsigned len);
-int audpp_send_queue2(void *cmd, unsigned len);
-int audpp_send_queue3(void *cmd, unsigned len);
-
-void audpp_route_stream(unsigned short dec_id, unsigned short mixer_mask);
-
-int audpp_set_volume_and_pan(unsigned id, unsigned volume, int pan,
-					enum obj_type objtype);
-int audpp_pause(unsigned id, int pause);
-int audpp_flush(unsigned id);
-int audpp_query_avsync(int id);
-int audpp_restore_avsync(int id, uint16_t *avsync);
-
-int audpp_dsp_set_eq(unsigned id, unsigned enable,
-	struct audpp_cmd_cfg_object_params_eqalizer *eq,
-			enum obj_type objtype);
-
-int audpp_dsp_set_spa(unsigned id,
-	struct audpp_cmd_cfg_object_params_spectram *spa,
-			enum obj_type objtype);
-
-int audpp_dsp_set_stf(unsigned id, unsigned enable,
-     struct audpp_cmd_cfg_object_params_sidechain *stf,
-			enum obj_type objtype);
-
-int audpp_dsp_set_vol_pan(unsigned id,
-	struct audpp_cmd_cfg_object_params_volume *vol_pan,
-			enum obj_type objtype);
-
-int audpp_dsp_set_mbadrc(unsigned id, unsigned enable,
-	struct audpp_cmd_cfg_object_params_mbadrc *mbadrc,
-	enum obj_type objtype);
-
-int audpp_dsp_set_qconcert_plus(unsigned id, unsigned enable,
-	struct audpp_cmd_cfg_object_params_qconcert *qconcert_plus,
-	enum obj_type objtype);
-
-int audpp_dsp_set_rx_iir(unsigned id, unsigned enable,
-	struct audpp_cmd_cfg_object_params_pcm *iir,
-	enum obj_type objtype);
-
-int audpp_dsp_set_gain_rx(unsigned id,
-	struct audpp_cmd_cfg_cal_gain *calib_gain_rx,
-	enum obj_type objtype);
-int audpp_dsp_set_pbe(unsigned id, unsigned enable,
-	struct audpp_cmd_cfg_pbe *pbe_block,
-	enum obj_type objtype);
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/audpreproc.h b/arch/arm/mach-msm/include/mach/qdsp5v2/audpreproc.h
deleted file mode 100644
index 16a0a8f..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/audpreproc.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* Copyright (c) 2009-2011, The Linux Foundation. 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.
- *
- */
-
-#ifndef _MACH_QDSP5_V2_AUDPREPROC_H
-#define _MACH_QDSP5_V2_AUDPREPROC_H
-
-#include <mach/qdsp5v2/qdsp5audpreproccmdi.h>
-#include <mach/qdsp5v2/qdsp5audpreprocmsg.h>
-
-#define MAX_ENC_COUNT 3
-
-#define MSM_ADSP_ENC_CODEC_WAV 0
-#define MSM_ADSP_ENC_CODEC_AAC 1
-#define MSM_ADSP_ENC_CODEC_SBC 2
-#define MSM_ADSP_ENC_CODEC_AMRNB 3
-#define MSM_ADSP_ENC_CODEC_EVRC 4
-#define MSM_ADSP_ENC_CODEC_QCELP 5
-#define MSM_ADSP_ENC_CODEC_EXT_WAV (15)
-
-#define MSM_ADSP_ENC_MODE_TUNNEL 24
-#define MSM_ADSP_ENC_MODE_NON_TUNNEL 25
-
-#define AUDPREPROC_CODEC_MASK 0x00FF
-#define AUDPREPROC_MODE_MASK 0xFF00
-
-#define MSM_AUD_ENC_MODE_TUNNEL  0x00000100
-#define MSM_AUD_ENC_MODE_NONTUNNEL  0x00000200
-
-#define SOURCE_PIPE_1	0x0001
-#define SOURCE_PIPE_0	0x0000
-
-/* event callback routine prototype*/
-typedef void (*audpreproc_event_func)(void *private, unsigned id, void *msg);
-
-struct audpreproc_event_callback {
-	audpreproc_event_func fn;
-	void *private;
-};
-
-/*holds audrec information*/
-struct audrec_session_info {
-	int session_id;
-	int sampling_freq;
-};
-
-/* Exported common api's from audpreproc layer */
-int audpreproc_aenc_alloc(unsigned enc_type, const char **module_name,
-		unsigned *queue_id);
-void audpreproc_aenc_free(int enc_id);
-
-int audpreproc_enable(int enc_id, audpreproc_event_func func, void *private);
-void audpreproc_disable(int enc_id, void *private);
-
-int audpreproc_send_audreccmdqueue(void *cmd, unsigned len);
-
-int audpreproc_send_preproccmdqueue(void *cmd, unsigned len);
-
-int audpreproc_dsp_set_agc(struct audpreproc_cmd_cfg_agc_params *agc,
-	unsigned len);
-int audpreproc_dsp_set_agc2(struct audpreproc_cmd_cfg_agc_params_2 *agc2,
-	unsigned len);
-int audpreproc_dsp_set_ns(struct audpreproc_cmd_cfg_ns_params *ns,
-	unsigned len);
-int audpreproc_dsp_set_iir(
-struct audpreproc_cmd_cfg_iir_tuning_filter_params *iir, unsigned len);
-
-int audpreproc_dsp_set_agc(struct audpreproc_cmd_cfg_agc_params *agc,
- unsigned int len);
-
-int audpreproc_dsp_set_iir(
-struct audpreproc_cmd_cfg_iir_tuning_filter_params *iir, unsigned int len);
-
-int audpreproc_update_audrec_info(struct audrec_session_info
-						*audrec_session_info);
-int audpreproc_unregister_event_callback(struct audpreproc_event_callback *ecb);
-
-int audpreproc_register_event_callback(struct audpreproc_event_callback *ecb);
-
-int audpreproc_dsp_set_gain_tx(
-	struct audpreproc_cmd_cfg_cal_gain *calib_gain_tx, unsigned len);
-
-void get_audrec_session_info(int id, struct audrec_session_info *info);
-
-int audpreproc_dsp_set_lvnv(
-	struct audpreproc_cmd_cfg_lvnv_param *preproc_lvnv, unsigned len);
-#endif /* _MACH_QDSP5_V2_AUDPREPROC_H */
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/aux_pcm.h b/arch/arm/mach-msm/include/mach/qdsp5v2/aux_pcm.h
deleted file mode 100644
index d9b9427..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/aux_pcm.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-#ifndef __MACH_QDSP5_V2_AUX_PCM_H
-#define __MACH_QDSP5_V2_AUX_PCM_H
-#include <mach/qdsp5v2/audio_def.h>
-
-/* define some values in AUX_CODEC_CTL register */
-#define AUX_CODEC_CTL__ADSP_CODEC_CTL_EN__MSM_V 0 /* default */
-#define AUX_CODEC_CTL__ADSP_CODEC_CTL_EN__ADSP_V 0x800
-#define AUX_CODEC_CTL__PCM_SYNC_LONG_OFFSET_V  0x400
-#define AUX_CODEC_CTL__PCM_SYNC_SHORT_OFFSET_V 0x200
-#define AUX_CODEC_CTL__I2S_SAMPLE_CLK_SRC__SDAC_V 0
-#define AUX_CODEC_CTL__I2S_SAMPLE_CLK_SRC__ICODEC_V 0x80
-#define AUX_CODEC_CTL__I2S_SAMPLE_CLK_MODE__MASTER_V 0
-#define AUX_CODEC_CTL__I2S_SAMPLE_CLK_MODE__SLAVE_V 0x40
-#define AUX_CODEC_CTL__I2S_RX_MODE__REV_V 0
-#define AUX_CODEC_CTL__I2S_RX_MODE__TRAN_V 0x20
-#define AUX_CODEC_CTL__I2S_CLK_MODE__MASTER_V 0
-#define AUX_CODEC_CTL__I2S_CLK_MODE__SLAVE_V 0x10
-#define AUX_CODEC_CTL__AUX_PCM_MODE__PRIM_MASTER_V 0
-#define AUX_CODEC_CTL__AUX_PCM_MODE__AUX_MASTER_V 0x4
-#define AUX_CODEC_CTL__AUX_PCM_MODE__PRIM_SLAVE_V 0x8
-#define AUX_CODEC_CTL__AUX_CODEC_MDOE__PCM_V 0
-#define AUX_CODEC_CTL__AUX_CODEC_MODE__I2S_V 0x2
-
-/* define some values in PCM_PATH_CTL register */
-#define PCM_PATH_CTL__ADSP_CTL_EN__MSM_V 0
-#define PCM_PATH_CTL__ADSP_CTL_EN__ADSP_V 0x8
-
-/* define some values for aux codec config of AFE*/
-/* PCM CTL */
-#define PCM_CTL__RPCM_WIDTH__LINEAR_V 0x1
-#define PCM_CTL__TPCM_WIDTH__LINEAR_V 0x2
-/* AUX_CODEC_INTF_CTL */
-#define AUX_CODEC_INTF_CTL__PCMINTF_DATA_EN_V 0x800
-/* DATA_FORMAT_PADDING_INFO */
-#define DATA_FORMAT_PADDING_INFO__RPCM_FORMAT_V 0x400
-#define DATA_FORMAT_PADDING_INFO__TPCM_FORMAT_V 0x2000
-
-void aux_codec_adsp_codec_ctl_en(bool msm_adsp_en);
-void aux_codec_pcm_path_ctl_en(bool msm_adsp_en);
-int aux_pcm_gpios_request(void);
-void aux_pcm_gpios_free(void);
-
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/codec_utils.h b/arch/arm/mach-msm/include/mach/qdsp5v2/codec_utils.h
deleted file mode 100644
index 2cfdabf..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/codec_utils.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/* Copyright (c) 2010, 2012, The Linux Foundation. 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.
- *
- */
-#ifndef CODEC_UTILS_H
-#define CODEC_UTILS_H
-
-#include <linux/earlysuspend.h>
-
-#define ADRV_STATUS_AIO_INTF 0x00000001
-#define ADRV_STATUS_OBUF_GIVEN 0x00000002
-#define ADRV_STATUS_IBUF_GIVEN 0x00000004
-#define ADRV_STATUS_FSYNC 0x00000008
-
-#define PCM_BUFSZ_MIN 4800	/* Hold one stereo MP3 frame */
-#define PCM_BUF_MAX_COUNT 5	/* DSP only accepts 5 buffers at most
-				   but support 2 buffers currently */
-#define ROUTING_MODE_FTRT 1
-#define ROUTING_MODE_RT 2
-/* Decoder status received from AUDPPTASK */
-#define  AUDPP_DEC_STATUS_SLEEP	0
-#define	 AUDPP_DEC_STATUS_INIT  1
-#define  AUDPP_DEC_STATUS_CFG   2
-#define  AUDPP_DEC_STATUS_PLAY  3
-#define  AUDPP_DEC_STATUS_EOS   5
-
-/* worst case delay of 3secs(3000ms) for AV Sync Query response */
-#define AVSYNC_EVENT_TIMEOUT 3000
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;		/* Input usage actual DSP produced PCM size  */
-	unsigned addr;
-};
-struct audio;
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-struct audio_suspend_ctl {
-	struct early_suspend node;
-	struct audio *audio;
-};
-#endif
-
-struct codec_operations {
-	long (*ioctl)(struct file *, unsigned int, unsigned long);
-	void (*adec_params)(struct audio *);
-};
-
-struct audio {
-	spinlock_t dsp_lock;
-
-	uint8_t out_needed; /* number of buffers the dsp is waiting for */
-	struct list_head out_queue; /* queue to retain output buffers */
-	atomic_t out_bytes;
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-
-	struct msm_adsp_module *audplay;
-
-	/* configuration to use on next enable */
-	uint32_t out_sample_rate;
-	uint32_t out_channel_mode;
-	uint32_t out_bits; /* bits per sample (used by PCM decoder) */
-
-	/* data allocated for various buffers */
-	char *data;
-	int32_t phys; /* physical address of write buffer */
-
-	uint32_t drv_status;
-	int wflush; /* Write flush */
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped, cleared on flush */
-	int buf_refresh;
-	int teos; /* valid only if tunnel mode & no data left for decoder */
-	enum msm_aud_decoder_state dec_state;	/* Represents decoder state */
-	int reserved; /* A byte is being reserved */
-	char rsv_byte; /* Handle odd length user data */
-
-	const char *module_name;
-	unsigned queue_id;
-	uint16_t dec_id;
-	uint32_t read_ptr_offset;
-	int16_t source;
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	struct audio_suspend_ctl suspend_ctl;
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *dentry;
-#endif
-
-	wait_queue_head_t wait;
-	struct list_head free_event_queue;
-	struct list_head event_queue;
-	wait_queue_head_t event_wait;
-	spinlock_t event_queue_lock;
-	struct mutex get_event_lock;
-	int event_abort;
-	/* AV sync Info */
-	int avsync_flag;              /* Flag to indicate feedback from DSP */
-	wait_queue_head_t avsync_wait;/* Wait queue for AV Sync Message     */
-	/* flags, 48 bits sample/bytes counter per channel */
-	uint16_t avsync[AUDPP_AVSYNC_CH_COUNT * AUDPP_AVSYNC_NUM_WORDS + 1];
-
-	uint32_t device_events;
-	uint32_t device_switch;       /* Flag to indicate device switch */
-	uint64_t bytecount_consumed;
-	uint64_t bytecount_head;
-	uint64_t bytecount_given;
-	uint64_t bytecount_query;
-
-	struct list_head ion_region_queue; /* protected by lock */
-	struct ion_client *client;
-
-	int eq_enable;
-	int eq_needs_commit;
-	struct audpp_cmd_cfg_object_params_eqalizer eq;
-	struct audpp_cmd_cfg_object_params_volume vol_pan;
-
-	unsigned int minor_no;
-	struct codec_operations codec_ops;
-	uint32_t buffer_size;
-	uint32_t buffer_count;
-};
-
-#endif /* !CODEC_UTILS_H */
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/lpa.h b/arch/arm/mach-msm/include/mach/qdsp5v2/lpa.h
deleted file mode 100644
index d9d9ab1..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/lpa.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-#ifndef __MACH_QDSP5_V2_LPA_H__
-#define __MACH_QDSP5_V2_LPA_H__
-
-#define LPA_OUTPUT_INTF_WB_CODEC 3
-#define LPA_OUTPUT_INTF_SDAC     1
-#define LPA_OUTPUT_INTF_MI2S     2
-
-struct lpa_codec_config {
-	uint32_t sample_rate;
-	uint32_t sample_width;
-	uint32_t output_interface;
-	uint32_t num_channels;
-};
-
-struct lpa_drv;
-
-struct lpa_drv *lpa_get(void);
-void lpa_put(struct lpa_drv *lpa);
-int lpa_cmd_codec_config(struct lpa_drv *lpa,
-	struct lpa_codec_config *config_ptr);
-int lpa_cmd_enable_codec(struct lpa_drv *lpa, bool enable);
-
-#endif
-
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/lpa_hw.h b/arch/arm/mach-msm/include/mach/qdsp5v2/lpa_hw.h
deleted file mode 100644
index beb4aee..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/lpa_hw.h
+++ /dev/null
@@ -1,236 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-#ifndef __MACH_QDSP5_V2_LPA_HW_H__
-#define __MACH_QDSP5_V2_LPA_HW_H__
-
-#define LPA_MAX_BUF_SIZE 0x30000
-
-/* LPA Output config registers */
-enum {
-	LPA_OBUF_CONTROL	= 0x00000000,
-	LPA_OBUF_CODEC		= 0x00000004,
-	LPA_OBUF_HLB_MIN_ADDR	= 0x00000008,
-	LPA_OBUF_HLB_MAX_ADDR	= 0x0000000C,
-	LPA_OBUF_HLB_WPTR	= 0x00000010,
-	LPA_OBUF_HLB_VOLUME_CONTROL = 0x00000014,
-	LPA_OBUF_LLB_MIN_ADDR	= 0x00000018,
-	LPA_OBUF_LLB_MAX_ADDR	= 0x0000001C,
-	LPA_OBUF_SB_MIN_ADDR	= 0x00000020,
-	LPA_OBUF_SB_MAX_ADDR	= 0x00000024,
-	LPA_OBUF_INTR_ENABLE	= 0x00000028,
-	LPA_OBUF_INTR_STATUS	= 0x0000002C,
-	LPA_OBUF_WMARK_ASSIGN	= 0x00000030,
-	LPA_OBUF_WMARK_0_LLB	= 0x00000034,
-	LPA_OBUF_WMARK_1_LLB	= 0x00000038,
-	LPA_OBUF_WMARK_2_LLB	= 0x0000003C,
-	LPA_OBUF_WMARK_3_LLB	= 0x00000040,
-	LPA_OBUF_WMARK_HLB	= 0x00000044,
-	LPA_OBUF_WMARK_SB	= 0x00000048,
-	LPA_OBUF_RDPTR_LLB	= 0x0000004C,
-	LPA_OBUF_RDPTR_HLB	= 0x00000050,
-	LPA_OBUF_WRPTR_SB	= 0x00000054,
-	LPA_OBUF_UTC_CONFIG	= 0x00000058,
-	LPA_OBUF_UTC_INTR_LOW	= 0x0000005C,
-	LPA_OBUF_UTC_INTR_HIGH	= 0x00000060,
-	LPA_OBUF_UTC_LOW	= 0x00000064,
-	LPA_OBUF_UTC_HIGH	= 0x00000068,
-	LPA_OBUF_MISR		= 0x0000006C,
-	LPA_OBUF_STATUS		= 0x00000070,
-	LPA_OBUF_ACK		= 0x00000074,
-	LPA_OBUF_MEMORY_CONTROL	= 0x00000078,
-	LPA_OBUF_MEMORY_STATUS	= 0x0000007C,
-	LPA_OBUF_MEMORY_TIME_CONTROL	= 0x00000080,
-	LPA_OBUF_ACC_LV			= 0x00000084,
-	LPA_OBUF_ACC_HV			= 0x0000008c,
-	LPA_OBUF_RESETS			= 0x00000090,
-	LPA_OBUF_TESTBUS		= 0x00000094,
-};
-
-/* OBUF_CODEC definition */
-#define LPA_OBUF_CODEC_RESERVED31_22_BMSK        0xffc00000
-#define LPA_OBUF_CODEC_RESERVED31_22_SHFT        0x16
-#define LPA_OBUF_CODEC_LOAD_BMSK                 0x200000
-#define LPA_OBUF_CODEC_LOAD_SHFT                 0x15
-#define LPA_OBUF_CODEC_CODEC_INTF_EN_BMSK        0x100000
-#define LPA_OBUF_CODEC_CODEC_INTF_EN_SHFT        0x14
-#define LPA_OBUF_CODEC_SAMP_BMSK                 0xf0000
-#define LPA_OBUF_CODEC_SAMP_SHFT                 0x10
-#define LPA_OBUF_CODEC_BITS_PER_CHAN_BMSK        0xc000
-#define LPA_OBUF_CODEC_BITS_PER_CHAN_SHFT        0xe
-#define LPA_OBUF_CODEC_RESERVED_13_7_BMSK        0x3f80
-#define LPA_OBUF_CODEC_RESERVED_13_7_SHFT        0x7
-#define LPA_OBUF_CODEC_INTF_BMSK                 0x70
-#define LPA_OBUF_CODEC_INTF_SHFT                 0x4
-#define LPA_OBUF_CODEC_NUM_CHAN_BMSK             0xf
-#define LPA_OBUF_CODEC_NUM_CHAN_SHFT             0
-
-/* OBUF_CONTROL definition */
-#define LPA_OBUF_CONTROL_RESERVED31_9_BMSK       0xfffffe00
-#define LPA_OBUF_CONTROL_RESERVED31_9_SHFT       0x9
-#define LPA_OBUF_CONTROL_TEST_EN_BMSK            0x100
-#define LPA_OBUF_CONTROL_TEST_EN_SHFT            0x8
-#define LPA_OBUF_CONTROL_LLB_CLR_CMD_BMSK        0x80
-#define LPA_OBUF_CONTROL_LLB_CLR_CMD_SHFT        0x7
-#define LPA_OBUF_CONTROL_SB_SAT_EN_BMSK          0x40
-#define LPA_OBUF_CONTROL_SB_SAT_EN_SHFT          0x6
-#define LPA_OBUF_CONTROL_LLB_SAT_EN_BMSK         0x20
-#define LPA_OBUF_CONTROL_LLB_SAT_EN_SHFT         0x5
-#define LPA_OBUF_CONTROL_RESERVED4_BMSK          0x10
-#define LPA_OBUF_CONTROL_RESERVED4_SHFT          0x4
-#define LPA_OBUF_CONTROL_LLB_ACC_EN_BMSK         0x8
-#define LPA_OBUF_CONTROL_LLB_ACC_EN_SHFT         0x3
-#define LPA_OBUF_CONTROL_HLB_EN_BMSK             0x4
-#define LPA_OBUF_CONTROL_HLB_EN_SHFT             0x2
-#define LPA_OBUF_CONTROL_LLB_EN_BMSK             0x2
-#define LPA_OBUF_CONTROL_LLB_EN_SHFT             0x1
-#define LPA_OBUF_CONTROL_SB_EN_BMSK              0x1
-#define LPA_OBUF_CONTROL_SB_EN_SHFT              0
-
-/* OBUF_RESET definition */
-#define LPA_OBUF_RESETS_MISR_RESET 0x1
-#define LPA_OBUF_RESETS_OVERALL_RESET 0x2
-
-/* OBUF_STATUS definition */
-#define LPA_OBUF_STATUS_RESET_DONE 0x80000
-#define LPA_OBUF_STATUS_LLB_CLR_BMSK 0x40000
-#define LPA_OBUF_STATUS_LLB_CLR_SHFT 0x12
-
-/* OBUF_HLB_MIN_ADDR definition */
-#define LPA_OBUF_HLB_MIN_ADDR_LOAD_BMSK 0x40000
-#define LPA_OBUF_HLB_MIN_ADDR_SEG_BMSK 0x3e000
-
-/* OBUF_HLB_MAX_ADDR definition */
-#define LPA_OBUF_HLB_MAX_ADDR_SEG_BMSK 0x3fff8
-
-/* OBUF_LLB_MIN_ADDR definition */
-#define LPA_OBUF_LLB_MIN_ADDR_LOAD_BMSK 0x40000
-#define LPA_OBUF_LLB_MIN_ADDR_SEG_BMSK 0x3e000
-
-/* OBUF_LLB_MAX_ADDR definition */
-#define LPA_OBUF_LLB_MAX_ADDR_SEG_BMSK 0x3ff8
-#define LPA_OBUF_LLB_MAX_ADDR_SEG_SHFT 0x3
-
-/* OBUF_SB_MIN_ADDR definition */
-#define LPA_OBUF_SB_MIN_ADDR_LOAD_BMSK 0x4000
-#define LPA_OBUF_SB_MIN_ADDR_SEG_BMSK 0x3e00
-
-/* OBUF_SB_MAX_ADDR definition */
-#define LPA_OBUF_SB_MAX_ADDR_SEG_BMSK 0x3ff8
-
-/* OBUF_MEMORY_CONTROL definition */
-#define LPA_OBUF_MEM_CTL_PWRUP_BMSK 0xfff
-#define LPA_OBUF_MEM_CTL_PWRUP_SHFT 0x0
-
-/* OBUF_INTR_ENABLE definition */
-#define LPA_OBUF_INTR_EN_BMSK 0x3
-
-/* OBUF_WMARK_ASSIGN definition */
-#define LPA_OBUF_WMARK_ASSIGN_BMSK 0xF
-#define LPA_OBUF_WMARK_ASSIGN_DONE 0xF
-
-/* OBUF_WMARK_n_LLB definition */
-#define LPA_OBUF_WMARK_n_LLB_ADDR(n)  (0x00000034 + 0x4 * (n))
-#define LPA_OBUF_LLB_WMARK_CTRL_BMSK 0xc0000
-#define LPA_OBUF_LLB_WMARK_CTRL_SHFT 0x12
-#define LPA_OBUF_LLB_WMARK_MAP_BMSK  0xf00000
-#define LPA_OBUF_LLB_WMARK_MAP_SHFT  0x14
-
-/* OBUF_WMARK_SB definition */
-#define LPA_OBUF_SB_WMARK_CTRL_BMSK 0xc0000
-#define LPA_OBUF_SB_WMARK_CTRL_SHFT 0x12
-#define LPA_OBUF_SB_WMARK_MAP_BMSK  0xf00000
-#define LPA_OBUF_SB_WMARK_MAP_SHFT  0x14
-
-/* OBUF_WMARK_HLB definition */
-#define LPA_OBUF_HLB_WMARK_CTRL_BMSK 0xc0000
-#define LPA_OBUF_HLB_WMARK_CTRL_SHFT 0x12
-#define LPA_OBUF_HLB_WMARK_MAP_BMSK  0xf00000
-#define LPA_OBUF_HLB_WMARK_MAP_SHFT  0x14
-
-/* OBUF_UTC_CONFIG definition */
-#define LPA_OBUF_UTC_CONFIG_MAP_BMSK 0xf0
-#define LPA_OBUF_UTC_CONFIG_MAP_SHFT 0x4
-#define LPA_OBUF_UTC_CONFIG_EN_BMSK  0x1
-#define LPA_OBUF_UTC_CONFIG_EN_SHFT  0
-#define LPA_OBUF_UTC_CONFIG_NO_INTR 0xF
-
-/* OBUF_ACK definition */
-#define LPA_OBUF_ACK_RESET_DONE_BMSK   0x80000
-#define LPA_OBUF_ACK_RESET_DONE_SHFT   0x13
-enum {
-	LPA_SAMPLE_RATE_8KHZ		= 0x0000,
-	LPA_SAMPLE_RATE_11P025KHZ	= 0x0001,
-	LPA_SAMPLE_RATE_16KHZ		= 0x0002,
-	LPA_SAMPLE_RATE_22P05KHZ	= 0x0003,
-	LPA_SAMPLE_RATE_32KHZ		= 0x0004,
-	LPA_SAMPLE_RATE_44P1KHZ		= 0x0005,
-	LPA_SAMPLE_RATE_48KHZ		= 0x0006,
-	LPA_SAMPLE_RATE_64KHZ		= 0x0007,
-	LPA_SAMPLE_RATE_96KHZ		= 0x0008,
-};
-
-enum {
-	LPA_BITS_PER_CHAN_16BITS	= 0x0000,
-	LPA_BITS_PER_CHAN_24BITS	= 0x0001,
-	LPA_BITS_PER_CHAN_32BITS	= 0x0002,
-	LPA_BITS_PER_CHAN_RESERVED	= 0x0003,
-};
-
-enum {
-	LPA_INTF_WB_CODEC		= 0x0000,
-	LPA_INTF_SDAC			= 0x0001,
-	LPA_INTF_MI2S			= 0x0002,
-	LPA_INTF_RESERVED		= 0x0003,
-};
-
-enum {
-	LPA_BUF_ID_HLB,   /* HLB buffer */
-	LPA_BUF_ID_LLB,   /* LLB buffer */
-	LPA_BUF_ID_SB,    /* SB buffer */
-	LPA_BUF_ID_UTC,
-};
-
-/* WB_CODEC & SDAC can only support 16bit mono/stereo.
- * MI2S can bit format and number of channel
- */
-enum {
-	LPA_NUM_CHAN_MONO		= 0x0000,
-	LPA_NUM_CHAN_STEREO		= 0x0001,
-	LPA_NUM_CHAN_5P1		= 0x0002,
-	LPA_NUM_CHAN_7P1		= 0x0003,
-	LPA_NUM_CHAN_4_CHANNEL		= 0x0004,
-};
-
-enum {
-	LPA_WMARK_CTL_DISABLED = 0x0,
-	LPA_WMARK_CTL_NON_BLOCK = 0x1,
-	LPA_WMARK_CTL_ZERO_INSERT = 0x2,
-	LPA_WMARK_CTL_RESERVED = 0x3
-};
-
-struct lpa_mem_bank_select {
-  u32    b0:1;       /*RAM bank 0 16KB=2Kx64(0) */
-  u32    b1:1;       /*RAM bank 1 16KB=2Kx64(0) */
-  u32    b2:1;       /*RAM bank 2 16KB=2Kx64(0) */
-  u32    b3:1;       /*RAM bank 3 16KB=2Kx64(0) */
-  u32    b4:1;       /*RAM bank 4 16KB=2Kx64(1) */
-  u32    b5:1;       /*RAM bank 5 16KB=2Kx64(1) */
-  u32    b6:1;       /*RAM bank 6 16KB=2Kx64(1) */
-  u32    b7:1;       /*RAM bank 7 16KB=2Kx64(1) */
-  u32    b8:1;       /*RAM bank 8 16KB=4Kx32(0) */
-  u32    b9:1;       /*RAM bank 9 16KB=4Kx32(1) */
-  u32    b10:1;      /*RAM bank 10 16KB=4Kx32(2) */
-  u32    llb:1;      /*RAM bank 11 16KB=4Kx32(3) */
-};
-
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/marimba_profile.h b/arch/arm/mach-msm/include/mach/qdsp5v2/marimba_profile.h
deleted file mode 100644
index 7e455a1..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/marimba_profile.h
+++ /dev/null
@@ -1,3201 +0,0 @@
-/* Copyright (c) 2009-2011,  The Linux Foundation. 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.
- *
- */
-#ifndef __MACH_QDSP5_V2_MARIMBA_PROFILE_H__
-#define __MACH_QDSP5_V2_MARIMBA_PROFILE_H__
-
-/***************************************************************************\
-				Handset
-\***************************************************************************/
-
-
-#define HANDSET_RX_8000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE},  \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80,  0x02,  0x02)},  \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x44)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x04, 0xff, 0x8C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x4E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x36, 0xc0, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0x2B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3d, 0xFF, 0xD5)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x21, 0x21)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x2710}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x40, 0x40)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x05, 0x04)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x36, 0xc0, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x40, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HANDSET_RX_16000_OSR_256 HANDSET_RX_8000_OSR_256
-
-#define HANDSET_RX_48000_OSR_64\
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x47)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x04, 0xfF, 0x8C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x42)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x36, 0xc0, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0x2B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3d, 0xFF, 0xD5)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x21, 0x21)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x2710}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x40, 0x40)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x05, 0x04)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x36, 0xc0, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x40, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HANDSET_RX_48000_OSR_256\
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x44)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x04, 0xfF, 0x8C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x4e)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x36, 0xc0, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0x2B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3d, 0xFF, 0x55)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x21, 0x21)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x2710}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x40, 0x40)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x05, 0x04)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x36, 0xc0, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x40, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HANDSET_TX_8000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x13, 0xfc, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xff, 0x65)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x15, 0xff, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xff, 0x5E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x10, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xF0, 0xd0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x14, 0x14)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8b, 0xff, 0xE6)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8c, 0x03, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x50, 0x40)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x10, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x14, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HANDSET_TX_16000_OSR_256 HANDSET_TX_8000_OSR_256
-
-#define HANDSET_TX_48000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x13, 0xfc, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xff, 0x65)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x15, 0xff, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xff, 0x5A)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x10, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xF0, 0xd0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x14, 0x14)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8b, 0xff, 0xE6)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8c, 0x03, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x50, 0x40)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x10, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x14, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-/***************************************************************************\
-				Headset
-\***************************************************************************/
-
-
-
-#define HEADSET_STEREO_TX_8000_OSR_256\
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x13, 0xfc, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xfd, 0x65)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x15, 0xff, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x5E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x10, 0xFF, 0x64)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xE8, 0xE8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xF0, 0xD0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x1c, 0x1c)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8b, 0xff, 0xE7)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8c, 0x03, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0e, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0d, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x1c, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HEADSET_STEREO_TX_16000_OSR_256 HEADSET_STEREO_TX_8000_OSR_256
-
-#define HEADSET_STEREO_TX_48000_OSR_64\
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x13, 0xfc, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xfd, 0x65)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x15, 0xfc, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x46)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x10, 0xFF, 0x64)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xE8, 0xE8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xF0, 0xD0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x1c, 0x1c)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8b, 0xff, 0xE7)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8c, 0x03, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0e, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0d, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x1c, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HEADSET_STEREO_TX_48000_OSR_256\
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FALSH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x13, 0xfc, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xfd, 0x65)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x15, 0xfc, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xff, 0x5A)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x10, 0xFF, 0x64)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xE8, 0xE8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xF0, 0xD0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x1c, 0x1c)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8b, 0xff, 0xE7)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8c, 0x03, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0e, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0d, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x1c, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HEADSET_MONO_TX_16000_OSR_256\
-	{{ADIE_CODEC_ACTION_STAGE_REACHED,  ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY,  ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY,  ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY,  ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY,  ADIE_CODEC_PACK_ENTRY(0x11, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY,  ADIE_CODEC_PACK_ENTRY(0x13, 0xfc, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY,  ADIE_CODEC_PACK_ENTRY(0x14, 0xff, 0x65)}, \
-	{ADIE_CODEC_ACTION_ENTRY,  ADIE_CODEC_PACK_ENTRY(0x15, 0xfc, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY,  ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x5E)}, \
-	{ADIE_CODEC_ACTION_ENTRY,  ADIE_CODEC_PACK_ENTRY(0x10, 0xFF, 0x64)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED,  ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY,  ADIE_CODEC_PACK_ENTRY(0x0D, 0xFf, 0xc8)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT,  0xbb8}, \
-	{ADIE_CODEC_ACTION_ENTRY,  ADIE_CODEC_PACK_ENTRY(0x83, 0x14, 0x14)}, \
-	{ADIE_CODEC_ACTION_ENTRY,  ADIE_CODEC_PACK_ENTRY(0x8b, 0xff, 0xE7)}, \
-	{ADIE_CODEC_ACTION_ENTRY,  ADIE_CODEC_PACK_ENTRY(0x8c, 0x03, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY,  ADIE_CODEC_PACK_ENTRY(0x86, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY,  ADIE_CODEC_PACK_ENTRY(0x8A, 0x50, 0x40)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED,  ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY,  ADIE_CODEC_PACK_ENTRY(0x8A, 0x10, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY,  ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY,  ADIE_CODEC_PACK_ENTRY(0x83, 0x14, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED,  ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY,  ADIE_CODEC_PACK_ENTRY(0x11, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED,  ADIE_CODEC_DIGITAL_OFF} }
-
-#define HEADSET_MONO_TX_8000_OSR_256 HEADSET_MONO_TX_16000_OSR_256
-
-#define HEADSET_MONO_TX_48000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x13, 0xfc, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xff, 0x65)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x15, 0xff, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xff, 0x5A)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x10, 0xFF, 0x64)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0xC8)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x14, 0x14)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8b, 0xff, 0xE7)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8c, 0x03, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x50, 0x40)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x10, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x14, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HEADSET_RX_CAPLESS_8000_OSR_256\
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x4E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x04, 0xff, 0xBC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xff, 0xa2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0xeb)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xf0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HEADSET_RX_CAPLESS_48000_OSR_64 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x42)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x04, 0xff, 0xBC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x67)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xff, 0xa2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0xab)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xf0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HEADSET_RX_CAPLESS_48000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x4e)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x04, 0xff, 0xBC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xff, 0xa2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0xab)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xf0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-
-#define HEADSET_RX_LEGACY_8000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x4E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x04, 0xff, 0xBC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xff, 0xa0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0x2b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xa0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xf0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HEADSET_RX_LEGACY_16000_OSR_256 HEADSET_RX_LEGACY_8000_OSR_256
-
-#define HEADSET_RX_LEGACY_48000_OSR_64 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x42)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x04, 0xff, 0xBC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x67)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xff, 0xa0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0x2b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xa0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xf0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-
-#define HEADSET_RX_LEGACY_48000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x4e)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x04, 0xff, 0xBC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xff, 0xa0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0x2b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xa0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xf0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HEADSET_RX_CLASS_D_LEGACY_8000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0e)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xf8, 0xA8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x29, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x50, 0x50)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x40, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x41, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x42, 0xFF, 0xFF)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x43, 0xFF, 0xc4)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x44, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0xFF, 0xDD)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3F, 0xFF, 0x0f)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x45, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x46, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x47, 0xFF, 0xc4)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x48, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x49, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4a, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0a, 0x0a)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0f, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-
-#define HEADSET_RX_CLASS_D_LEGACY_11025_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0e)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xf8, 0xA8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x29, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x50, 0x50)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x40, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x41, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x42, 0xFF, 0xbb)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x43, 0xFF, 0xc2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x44, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0xFF, 0xDD)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3F, 0xFF, 0x0f)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x45, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x46, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x47, 0xFF, 0xc2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x48, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x49, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4a, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0a, 0x0a)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0f, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-
-#define HEADSET_RX_CLASS_D_LEGACY_16000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0e)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xf8, 0xA8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x29, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x50, 0x50)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x40, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x41, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x42, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x43, 0xFF, 0xd4)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x44, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0xFF, 0xDD)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3F, 0xFF, 0x0f)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x45, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x46, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x47, 0xFF, 0xd4)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x48, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x49, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4a, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0a, 0x0a)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0f, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-
-#define HEADSET_RX_CLASS_D_LEGACY_22050_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0e)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xf8, 0xA8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x29, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x50, 0x50)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x40, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x41, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x42, 0xFF, 0xbb)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x43, 0xFF, 0xd2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x44, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0xFF, 0xDD)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3F, 0xFF, 0x0f)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x45, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x46, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x47, 0xFF, 0xd2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x48, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x49, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4a, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0a, 0x0a)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0f, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-
-#define HEADSET_CLASS_D_LEGACY_32000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0e)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xf8, 0xA8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x29, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x50, 0x50)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x40, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x41, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x42, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x43, 0xFF, 0xf4)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x44, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0xFF, 0xDD)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3F, 0xFF, 0x0f)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x45, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x46, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x47, 0xFF, 0xf4)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x48, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x49, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4a, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0a, 0x0a)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0f, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HEADSET_RX_CLASS_D_LEGACY_48000_OSR_64 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xf8, 0xA8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x29, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x50, 0x50)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x40, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x41, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x42, 0xFF, 0x55)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x43, 0xFF, 0xc5)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x44, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0xFF, 0xDD)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3F, 0xFF, 0x0f)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x45, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x46, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x47, 0xFF, 0xc2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x48, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x49, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4a, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0a, 0x0a)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0f, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HEADSET_RX_CLASS_D_LEGACY_48000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0e)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xf8, 0xA8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x29, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x50, 0x50)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x40, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x41, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x42, 0xFF, 0xBB)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x43, 0xFF, 0xF2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x44, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0xFF, 0xDD)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3F, 0xFF, 0x0f)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x45, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x46, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x47, 0xFF, 0xF2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x48, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x49, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4a, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0a, 0x0a)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0f, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HEADSET_STEREO_RX_CAPLESS_8000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x4E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x04, 0xff, 0xBC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xff, 0x82)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0xeb)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xf0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HEADSET_STEREO_RX_CAPLESS_48000_OSR_64 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x42)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x04, 0xff, 0xBC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x67)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xff, 0x82)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0xab)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xf0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-
-
-#define HEADSET_STEREO_RX_CAPLESS_48000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x4e)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x04, 0xff, 0xBC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xff, 0x82)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0xab)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x82)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xf0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HEADSET_STEREO_RX_LEGACY_8000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x4E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x04, 0xff, 0xBC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xff, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0x2b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xa0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xf0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFF, 0xaC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xaC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HEADSET_STEREO_RX_LEGACY_48000_OSR_64 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x42)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x04, 0xff, 0xBC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x67)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xff, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0x2b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xa0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xf0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HEADSET_STEREO_RX_LEGACY_48000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x4e)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x04, 0xff, 0xBC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xff, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0x2b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xa0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xf0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HEADSET_STEREO_RX_CLASS_D_LEGACY_8000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0e)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xf8, 0xA8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x29, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x40, 0x40)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x40, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x41, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x42, 0xFF, 0xFF)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x43, 0xFF, 0xc4)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x44, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0xFF, 0xDD)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3F, 0xFF, 0x0f)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x45, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x46, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x47, 0xFF, 0xc4)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x48, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x49, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4a, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0a, 0x0a)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0f, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-
-#define HEADSET_STEREO_RX_CLASS_D_LEGACY_11025_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0e)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xf8, 0xA8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x29, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x40, 0x40)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x40, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x41, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x42, 0xFF, 0xbb)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x43, 0xFF, 0xc2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x44, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0xFF, 0xDD)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3F, 0xFF, 0x0f)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x45, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x46, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x47, 0xFF, 0xc2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x48, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x49, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4a, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0a, 0x0a)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0f, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HEADSET_STEREO_RX_CLASS_D_LEGACY_16000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0e)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xf8, 0xA8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x29, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x40, 0x40)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x40, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x41, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x42, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x43, 0xFF, 0xd4)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x44, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0xFF, 0xDD)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3F, 0xFF, 0x0f)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x45, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x46, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x47, 0xFF, 0xd4)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x48, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x49, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4a, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0a, 0x0a)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0f, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-
-#define HEADSET_STEREO_RX_CLASS_D_LEGACY_22050_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0e)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xf8, 0xA8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x29, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x40, 0x40)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x40, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x41, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x42, 0xFF, 0xbb)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x43, 0xFF, 0xd2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x44, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0xFF, 0xDD)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3F, 0xFF, 0x0f)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x45, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x46, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x47, 0xFF, 0xd2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x48, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x49, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4a, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0a, 0x0a)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0f, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-
-#define HEADSET_STEREO_RX_CLASS_D_LEGACY_32000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0e)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xf8, 0xA8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x29, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x40, 0x40)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x40, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x41, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x42, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x43, 0xFF, 0xf4)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x44, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0xFF, 0xDD)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3F, 0xFF, 0x0f)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x45, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x46, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x47, 0xFF, 0xf4)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x48, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x49, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4a, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0a, 0x0a)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0f, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HEADSET_STEREO_RX_CLASS_D_LEGACY_48000_OSR_64 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xf8, 0xA8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x29, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x40, 0x40)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x40, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x41, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x42, 0xFF, 0x55)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x43, 0xFF, 0xc5)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x44, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0xFF, 0xDD)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3F, 0xFF, 0x0f)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x45, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x46, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x47, 0xFF, 0xc2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x48, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x49, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4a, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0a, 0x0a)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0f, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HEADSET_STEREO_RX_CLASS_D_LEGACY_48000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0e)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xf8, 0xA8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x29, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x40, 0x40)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x40, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x41, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x42, 0xFF, 0xBB)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x43, 0xFF, 0xF2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x44, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0xFF, 0xDD)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3F, 0xFF, 0x0f)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x45, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x46, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x47, 0xFF, 0xF2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x48, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x49, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4a, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0a, 0x0a)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0f, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define SPEAKER_RX_8000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x4E)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x37, 0xe2, 0xa2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0x2B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3d, 0xFF, 0x55)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x8a, 0x8a)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x7530}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x05, 0x04)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x40, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x7530}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-
-#define SPEAKER_RX_48000_OSR_64 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x42)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x67)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x37, 0xe2, 0xa2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0x2B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3d, 0xFF, 0x55)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x8a, 0x8a)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x7530}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x05, 0x04)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x40, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x7530}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define SPEAKER_RX_48000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x37, 0xe2, 0xa2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0x2B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3d, 0xFF, 0x55)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x8a, 0x8a)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x7530}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x05, 0x04)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x40, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x7530}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define SPEAKER_STEREO_RX_8000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x4E)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x37, 0xe6, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0x2B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3d, 0xFF, 0x55)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x8a, 0x8a)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x7530}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x0f, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x40, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x7530}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-
-#define SPEAKER_STEREO_RX_48000_OSR_64 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x42)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x67)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x37, 0xe6, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0x2B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3d, 0xFF, 0x55)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x8a, 0x8a)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x7530}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x0f, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x40, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x7530}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define SPEAKER_STEREO_RX_48000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x37, 0xe6, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0x2B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3d, 0xFF, 0x55)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x8a, 0x8a)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x7530}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x0f, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x40, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x7530}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-
-#define SPEAKER_TX_8000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x13, 0xfc, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xff, 0x65)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x15, 0xff, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xff, 0x5E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x10, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xF0, 0xD0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x14, 0x14)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8c, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x50, 0x40)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x10, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x14, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define SPEAKER_TX_48000_OSR_64 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x13, 0xfc, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xff, 0x65)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x15, 0xff, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xff, 0x46)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x10, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xF0, 0xD0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x14, 0x14)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8c, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x50, 0x40)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x10, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x14, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-
-#define SPEAKER_TX_48000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x13, 0xfc, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xff, 0x65)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x15, 0xff, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xff, 0x5A)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x10, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xF0, 0xD0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x14, 0x14)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8c, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x50, 0x40)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x10, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x14, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define FM_HANDSET_OSR_64 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x47)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x04, 0xff, 0x8C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x92)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x36, 0xc0, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0x2B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3d, 0xFF, 0xD5)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x2710}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x40, 0x40)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x05, 0x04)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x36, 0xc0, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x40, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define FM_HEADSET_STEREO_CLASS_D_LEGACY_OSR_64 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x92)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xf8, 0xA8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x29, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x40, 0x40)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x40, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x41, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x42, 0xFF, 0x55)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x43, 0xFF, 0xD5)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x44, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0xFF, 0xDD)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3F, 0xFF, 0x0f)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x45, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x46, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x47, 0xFF, 0xD5)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x48, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x49, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4a, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0a, 0x0a)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0f, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define FM_HEADSET_CLASS_AB_STEREO_LEGACY_OSR_64 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x92)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x04, 0xff, 0xBC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x67)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xff, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0x2b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xa0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xf0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define FM_HEADSET_CLASS_AB_STEREO_CAPLESS_OSR_64 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x92)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x04, 0xff, 0xBC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x67)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xff, 0x82)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0xeb)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xf0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define FM_SPEAKER_OSR_64 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x92)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x67)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x37, 0xe2, 0xa2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0x2B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3d, 0xFF, 0x55)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x8a, 0x8a)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x2710}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x05, 0x04)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x40, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-
-#define AUXPGA_HEADSET_STEREO_RX_LEGACY \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2B, 0xff, 0x09)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2C, 0xff, 0x09)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0x2b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2B, 0xff, 0x89)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2C, 0xff, 0x89)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xff, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xa0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xf0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0x10)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0x18, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x40, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define AUXPGA_HEADSET_MONO_RX_LEGACY \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2B, 0xff, 0x09)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2C, 0xff, 0x09)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0x2b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2B, 0xff, 0x89)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2C, 0xff, 0x89)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xff, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xa0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xf0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0x10)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0x18, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x40, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define AUXPGA_HEADSET_STEREO_RX_CAPLESS \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0xeb)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2B, 0xff, 0x89)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2C, 0xff, 0x89)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xff, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xa0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xf0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0x18, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x40, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define AUXPGA_HEADSET_MONO_RX_CAPLESS \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2B, 0xff, 0x09)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2C, 0xff, 0x09)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0xeb)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2B, 0xff, 0x89)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2C, 0xff, 0x89)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xff, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xa0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xf0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0x18, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x40, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define AUXPGA_HEADSET_STEREO_RX_CLASS_D \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2B, 0xff, 0x09)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2C, 0xff, 0x09)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2B, 0xff, 0x89)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2C, 0xff, 0x89)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x20, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x40, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x41, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x42, 0xFF, 0x55)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x43, 0xFF, 0xD5)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x44, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0xFF, 0xDD)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3F, 0xFF, 0x0f)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x45, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x46, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x47, 0xFF, 0xD5)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x48, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x49, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4a, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0a, 0x0a)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFC, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFC, 0x04)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x20, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x05, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-
-#define AUXPGA_HEADSET_MONO_RX_CLASS_D \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2B, 0xff, 0x09)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2C, 0xff, 0x09)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2B, 0xff, 0x89)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2C, 0xff, 0x89)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x40, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x41, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x42, 0xFF, 0x55)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x43, 0xFF, 0xD5)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x44, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0xFF, 0xDD)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3F, 0xFF, 0x0f)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x45, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x46, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x47, 0xFF, 0xD5)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x48, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x49, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4a, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0a, 0x0a)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFC, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFC, 0x04)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x20, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x05, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define AUXPGA_EAR \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2B, 0xff, 0x09)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2C, 0xff, 0x09)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2B, 0xff, 0x89)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2C, 0xff, 0x89)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x36, 0x20, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x2710}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x40, 0x40)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x36, 0x20, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x40, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-
-/***************************************************************************\
-				DigitalMicprofile
-\***************************************************************************/
-#define DIGITAL_MIC \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xfd, 0x65)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x1A, 0xff, 0xc0)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x66)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x1c, 0x1c)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x1c, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-/***************************************************************************\
-				DualMicprofile
-\***************************************************************************/
-#define SPEAKER_MIC1_LEFT_LINE_IN_RIGHT_8000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x13, 0xfc, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xfd, 0x65)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x15, 0xff, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x5E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x10, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xE2, 0xE2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xF0, 0xD0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x1c, 0x1c)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8c, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xc0)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0e, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0d, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x1c, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define SPEAKER_MIC1_LEFT_AUX_IN_RIGHT_8000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x13, 0xfc, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xfd, 0x65)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x15, 0xff, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x5E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x10, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xE2, 0xE1)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xF0, 0xD0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x1c, 0x1c)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8c, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xc0)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0e, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0d, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x1c, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define MIC1_LEFT_LINE_IN_RIGHT_8000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x13, 0xfc, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xfd, 0x65)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x15, 0xff, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x5E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x10, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xE2, 0xE2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xF0, 0xD0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x1c, 0x1c)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8b, 0xff, 0xCE)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8c, 0x03, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xc0)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0e, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0d, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x1c, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define MIC1_LEFT_AUX_IN_RIGHT_8000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x13, 0xfc, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xfd, 0x65)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x15, 0xff, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x5E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x10, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xE1, 0xE1)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xF0, 0xD0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x1c, 0x1c)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8b, 0xff, 0xCE)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8c, 0x03, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xc0)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0e, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0d, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x1c, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-
-/***************************************************************************\
-				AnalogDualMicProfile
-\***************************************************************************/
-#define ANALOG_DUAL_MIC \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x13, 0xfc, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xfd, 0x65)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x15, 0xff, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x5E)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xE2, 0xE2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xF0, 0xD0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x1c, 0x1c)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0e, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0d, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x1c, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-/***************************************************************************\
-				TTY
-\***************************************************************************/
-#define TTY_HEADSET_MONO_TX_8000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x13, 0xfc, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xff, 0x65)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x15, 0xfc, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x5E)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFf, 0xA8)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x14, 0x14)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8c, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xff, 0x0A)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x50, 0x40)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x10, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x14, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define TTY_HEADSET_MONO_TX_16000_OSR_256 TTY_HEADSET_MONO_TX_8000_OSR_256
-
-#define TTY_HEADSET_MONO_RX_CLASS_D_8000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0e)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xf8, 0xA8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x29, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x40, 0x40)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x40, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x41, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x42, 0xFF, 0xFF)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x43, 0xFF, 0xc4)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x44, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0xFF, 0xD5)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3F, 0xFF, 0x0f)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x45, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x46, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x47, 0xFF, 0xc4)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x48, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x49, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4a, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0a, 0x0a)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x05, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0xF4)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0f, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define TTY_HEADSET_MONO_RX_CLASS_D_16000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0e)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xf8, 0xA8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x29, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x40, 0x40)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x40, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x41, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x42, 0xFF, 0xFF)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x43, 0xFF, 0xd4)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x44, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0xFF, 0xD5)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3F, 0xFF, 0x0f)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x45, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x46, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x47, 0xFF, 0xd4)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x48, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x49, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4a, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0a, 0x0a)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x05, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0xF4)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0f, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define TTY_HEADSET_MONO_RX_CLASS_D_48000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0e)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xf8, 0xA8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x28, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x29, 0xfF, 0xCA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x40, 0x40)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x40, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x41, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x42, 0xFF, 0xBB)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x43, 0xFF, 0xF2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x44, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0xFF, 0xD5)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3F, 0xFF, 0x0f)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x45, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x46, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x47, 0xFF, 0xF2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x48, 0xFF, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x49, 0xFF, 0xff)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4a, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0a, 0x0a)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x05, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x3E8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0xF4)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0x0f, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-/***************************************************************************\
-				FFA
-\***************************************************************************/
-#define HANDSET_RX_8000_OSR_256_FFA \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE},  \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80,  0x02,  0x02)},  \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x44)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x04, 0xff, 0x8C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x4E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x36, 0xc0, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0x2B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3d, 0xFF, 0xD5)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x21, 0x21)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x2710}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x40, 0x40)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x05, 0x04)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x36, 0xc0, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x40, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HANDSET_RX_16000_OSR_256_FFA HANDSET_RX_8000_OSR_256_FFA
-
-#define HANDSET_RX_48000_OSR_64_FFA \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x47)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x04, 0xfF, 0x8C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x42)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x36, 0xc0, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0x2B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3d, 0xFF, 0xD5)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x21, 0x21)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x2710}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x40, 0x40)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x05, 0x04)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x36, 0xc0, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x40, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HANDSET_RX_48000_OSR_256_FFA \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x44)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x04, 0xfF, 0x8C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x4e)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x36, 0xc0, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0x2B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3d, 0xFF, 0x55)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x21, 0x21)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x2710}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x40, 0x40)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x05, 0x04)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x36, 0xc0, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x40, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HANDSET_TX_8000_OSR_256_FFA \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x13, 0xfc, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xff, 0x65)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x15, 0xff, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xff, 0x5E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x10, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xF0, 0xd0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x14, 0x14)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8b, 0xff, 0xCE)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8c, 0x03, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x50, 0x40)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x10, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x14, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HANDSET_TX_16000_OSR_256_FFA HANDSET_TX_8000_OSR_256_FFA
-
-#define HANDSET_TX_48000_OSR_256_FFA \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x13, 0xfc, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xff, 0x65)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x15, 0xff, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xff, 0x5A)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x10, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xF0, 0xd0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x14, 0x14)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8b, 0xff, 0xCE)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8c, 0x03, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x50, 0x40)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x10, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x14, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HEADSET_STEREO_SPEAKER_STEREO_RX_CAPLESS_48000_OSR_256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_FLASH_IMAGE}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xac)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x4E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x04, 0xff, 0xBC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xff, 0x82)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x37, 0xe6, 0xa0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0x2b)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x23, 0x23)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x8A, 0x8A)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xa0)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x7530}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xf0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x98)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x88)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x78)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x68)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x58)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x48)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x38)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x28)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x18)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFF, 0xaC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0xaC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x7530}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-#endif /* __MARIMBA_PROFILE_H__ */
-
-
-
-
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/mi2s.h b/arch/arm/mach-msm/include/mach/qdsp5v2/mi2s.h
deleted file mode 100644
index 2106bfc..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/mi2s.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-#ifndef _MACH_QDSP5_V2_MI2S_H
-#define _MACH_QDSP5_V2_MI2S_H
-
-#define WT_16_BIT 0
-#define WT_24_BIT 1
-#define WT_32_BIT 2
-#define WT_MAX 4
-
-enum mi2s_ret_enum_type {
-	MI2S_FALSE = 0,
-	MI2S_TRUE
-};
-
-#define MI2S_CHAN_MONO_RAW 0
-#define MI2S_CHAN_MONO_PACKED 1
-#define MI2S_CHAN_STEREO 2
-#define MI2S_CHAN_4CHANNELS 3
-#define MI2S_CHAN_6CHANNELS 4
-#define MI2S_CHAN_8CHANNELS 5
-#define MI2S_CHAN_MAX_OUTBOUND_CHANNELS MI2S__CHAN_8CHANNELS
-
-#define MI2S_SD_0    0x01
-#define MI2S_SD_1    0x02
-#define MI2S_SD_2    0x04
-#define MI2S_SD_3    0x08
-
-#define MI2S_SD_LINE_MASK    (MI2S_SD_0 | MI2S_SD_1 | MI2S_SD_2 |  MI2S_SD_3)
-
-bool mi2s_set_hdmi_output_path(uint8_t channels, uint8_t size,
-				uint8_t sd_line);
-
-bool mi2s_set_hdmi_input_path(uint8_t channels, uint8_t size, uint8_t sd_line);
-
-bool mi2s_set_codec_output_path(uint8_t channels, uint8_t size);
-
-bool mi2s_set_codec_input_path(uint8_t channels, uint8_t size);
-
-#endif /* #ifndef MI2S_H */
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/mp3_funcs.h b/arch/arm/mach-msm/include/mach/qdsp5v2/mp3_funcs.h
deleted file mode 100644
index b3f7c54..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/mp3_funcs.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (c) 2010, The Linux Foundation. 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.
- *
- */
-#ifndef MP3_FUNCS_H
-#define MP3_FUNCS_H
-
-/* Function Prototypes */
-long mp3_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
-void audpp_cmd_cfg_mp3_params(struct audio *audio);
-
-#endif /* !MP3_FUNCS_H */
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/msm_lpa.h b/arch/arm/mach-msm/include/mach/qdsp5v2/msm_lpa.h
deleted file mode 100644
index cdfa19b..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/msm_lpa.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-#ifndef _MACH_QDSP5_V2_MSM_LPA_H
-#define _MACH_QDSP5_V2_MSM_LPA_H
-
-struct lpa_mem_config {
-	u32 llb_min_addr;
-	u32 llb_max_addr;
-	u32 sb_min_addr;
-	u32 sb_max_addr;
-};
-
-struct msm_lpa_platform_data {
-	u32 obuf_hlb_size;
-	u32 dsp_proc_id;
-	u32 app_proc_id;
-	struct lpa_mem_config nosb_config; /* no summing  */
-	struct lpa_mem_config sb_config; /* summing required */
-};
-
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/pcm_funcs.h b/arch/arm/mach-msm/include/mach/qdsp5v2/pcm_funcs.h
deleted file mode 100644
index b8fe2ba..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/pcm_funcs.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Copyright (c) 2010, The Linux Foundation. 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.
- *
- */
-#ifndef PCM_FUNCS_H
-#define PCM_FUNCS_H
-
-long pcm_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
-void audpp_cmd_cfg_pcm_params(struct audio *audio);
-
-#endif /* !PCM_FUNCS_H */
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5afecmdi.h b/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5afecmdi.h
deleted file mode 100644
index b4ff5b8..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5afecmdi.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/* Copyright (c) 2009-2011, The Linux Foundation. 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.
- *
- */
-#ifndef __MACH_QDSP5_V2_QDSP5AFECMDI_H
-#define __MACH_QDSP5_V2_QDSP5AFECMDI_H
-
-#define QDSP5_DEVICE_mI2S_CODEC_RX 1     /* internal codec rx path  */
-#define QDSP5_DEVICE_mI2S_CODEC_TX 2     /* internal codec tx path  */
-#define QDSP5_DEVICE_AUX_CODEC_RX  3     /* external codec rx path  */
-#define QDSP5_DEVICE_AUX_CODEC_TX  4     /* external codec tx path  */
-#define QDSP5_DEVICE_mI2S_HDMI_RX  5     /* HDMI/FM block rx path   */
-#define QDSP5_DEVICE_mI2S_HDMI_TX  6     /* HDMI/FM block tx path   */
-#define QDSP5_DEVICE_ID_MAX        7
-
-#define AFE_CMD_CODEC_CONFIG_CMD     0x1
-#define AFE_CMD_CODEC_CONFIG_LEN sizeof(struct afe_cmd_codec_config)
-
-struct afe_cmd_codec_config{
-	uint16_t cmd_id;
-	uint16_t device_id;
-	uint16_t activity;
-	uint16_t sample_rate;
-	uint16_t channel_mode;
-	uint16_t volume;
-	uint16_t reserved;
-} __attribute__ ((packed));
-
-#define AFE_CMD_DEVICE_VOLUME_CTRL	0x2
-#define AFE_CMD_DEVICE_VOLUME_CTRL_LEN \
-		sizeof(struct afe_cmd_device_volume_ctrl)
-
-struct afe_cmd_device_volume_ctrl {
-	uint16_t cmd_id;
-	uint16_t device_id;
-	uint16_t device_volume;
-	uint16_t reserved;
-} __attribute__ ((packed));
-
-#define AFE_CMD_AUX_CODEC_CONFIG_CMD 	0x3
-#define AFE_CMD_AUX_CODEC_CONFIG_LEN sizeof(struct afe_cmd_aux_codec_config)
-
-struct afe_cmd_aux_codec_config{
-	uint16_t cmd_id;
-	uint16_t dma_path_ctl;
-	uint16_t pcm_ctl;
-	uint16_t eight_khz_int_mode;
-	uint16_t aux_codec_intf_ctl;
-	uint16_t data_format_padding_info;
-} __attribute__ ((packed));
-
-#define AFE_CMD_FM_RX_ROUTING_CMD	0x6
-#define AFE_CMD_FM_RX_ROUTING_LEN sizeof(struct afe_cmd_fm_codec_config)
-
-struct afe_cmd_fm_codec_config{
-	uint16_t cmd_id;
-	uint16_t enable;
-	uint16_t device_id;
-} __attribute__ ((packed));
-
-#define AFE_CMD_FM_PLAYBACK_VOLUME_CMD	0x8
-#define AFE_CMD_FM_PLAYBACK_VOLUME_LEN sizeof(struct afe_cmd_fm_volume_config)
-
-struct afe_cmd_fm_volume_config{
-	uint16_t cmd_id;
-	uint16_t volume;
-	uint16_t reserved;
-} __attribute__ ((packed));
-
-#define AFE_CMD_FM_CALIBRATION_GAIN_CMD	0x11
-#define AFE_CMD_FM_CALIBRATION_GAIN_LEN \
-	sizeof(struct afe_cmd_fm_calibgain_config)
-
-struct afe_cmd_fm_calibgain_config{
-	uint16_t cmd_id;
-	uint16_t device_id;
-	uint16_t calibration_gain;
-} __attribute__ ((packed));
-
-#define AFE_CMD_LOOPBACK	0xD
-#define AFE_CMD_EXT_LOOPBACK	0xE
-#define AFE_CMD_LOOPBACK_LEN sizeof(struct afe_cmd_loopback)
-#define AFE_LOOPBACK_ENABLE_COMMAND 0xFFFF
-#define AFE_LOOPBACK_DISABLE_COMMAND 0x0000
-
-struct afe_cmd_loopback {
-	uint16_t cmd_id;
-	uint16_t enable_flag;
-	uint16_t reserved[2];
-} __attribute__ ((packed));
-
-struct afe_cmd_ext_loopback {
-	uint16_t cmd_id;
-	uint16_t enable_flag;
-	uint16_t source_id;
-	uint16_t dst_id;
-	uint16_t reserved[2];
-} __packed;
-
-#define AFE_CMD_CFG_RMC_PARAMS 0x12
-#define AFE_CMD_CFG_RMC_LEN \
-	sizeof(struct afe_cmd_cfg_rmc)
-
-struct afe_cmd_cfg_rmc {
-	unsigned short cmd_id;
-	signed short   rmc_mode;
-	unsigned short rmc_ipw_length_ms;
-	unsigned short rmc_peak_length_ms;
-	unsigned short rmc_init_pulse_length_ms;
-	unsigned short rmc_total_int_length_ms;
-	unsigned short rmc_rampupdn_length_ms;
-	unsigned short rmc_delay_length_ms;
-	unsigned short rmc_detect_start_threshdb;
-	signed short   rmc_init_pulse_threshdb;
-}  __attribute__((packed));
-
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5afemsg.h b/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5afemsg.h
deleted file mode 100644
index 292683a..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5afemsg.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-#ifndef __MACH_QDSP5_V2_QDSP5AFEMSG_H
-#define __MACH_QDSP5_V2_QDSP5AFEMSG_H
-
-#define AFE_APU_MSG_CODEC_CONFIG_ACK		0x0001
-#define AFE_APU_MSG_CODEC_CONFIG_ACK_LEN	\
-	sizeof(struct afe_msg_codec_config_ack)
-
-#define AFE_APU_MSG_VOC_TIMING_SUCCESS		0x0002
-
-#define AFE_MSG_CODEC_CONFIG_ENABLED 0x1
-#define AFE_MSG_CODEC_CONFIG_DISABLED 0xFFFF
-
-struct afe_msg_codec_config_ack {
-	uint16_t device_id;
-	uint16_t device_activity;
-	uint16_t reserved;
-} __attribute__((packed));
-
-#endif /* QDSP5AFEMSG_H */
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audplaycmdi.h b/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audplaycmdi.h
deleted file mode 100644
index dad7fab..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audplaycmdi.h
+++ /dev/null
@@ -1,145 +0,0 @@
-#ifndef QDSP5AUDPLAYCMDI_H
-#define QDSP5AUDPLAYCMDI_H
-
-/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
-	Q D S P 5  A U D I O   P L A Y  T A S K   C O M M A N D S
-
-GENERAL DESCRIPTION
-   Command Interface for AUDPLAYTASK on QDSP5
-
-REFERENCES
-   None
-
-EXTERNALIZED FUNCTIONS
-
-  audplay_cmd_dec_data_avail
-  Send buffer to AUDPLAY task
-
-
-Copyright (c) 1992-2009, The Linux Foundation. All rights reserved.
-
-This software is licensed under the terms of the GNU General Public
-License version 2, as published by the Free Software Foundation, and
-may be copied, distributed, and modified under those terms.
-
-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 AUDPLAY_CMD_BITSTREAM_DATA_AVAIL		0x0000
-#define AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_LEN	\
-	sizeof(struct audplay_cmd_bitstream_data_avail)
-
-/* Type specification of dec_data_avail message sent to AUDPLAYTASK
-*/
-struct audplay_cmd_bitstream_data_avail{
-	/*command ID*/
-	unsigned int cmd_id;
-
-	/* Decoder ID for which message is being sent */
-	unsigned int decoder_id;
-
-	/* Start address of data in ARM global memory */
-	unsigned int buf_ptr;
-
-	/* Number of 16-bit words of bit-stream data contiguously
-	* available at the above-mentioned address
-	*/
-	unsigned int buf_size;
-
-	/* Partition number used by audPlayTask to communicate with DSP's RTOS
-	* kernel
-	*/
-	unsigned int partition_number;
-
-} __attribute__((packed));
-
-#define AUDPLAY_CMD_CHANNEL_INFO 0x0001
-#define AUDPLAY_CMD_CHANNEL_INFO_LEN \
-  sizeof(struct audplay_cmd_channel_info)
-
-struct audplay_cmd_channel_select {
-  unsigned int cmd_id;
-  unsigned int stream_id;
-  unsigned int channel_select;
-} __attribute__((packed));
-
-struct audplay_cmd_threshold_update {
-  unsigned int cmd_id;
-  unsigned int threshold_update;
-  unsigned int threshold_value;
-} __attribute__((packed));
-
-union audplay_cmd_channel_info {
-  struct audplay_cmd_channel_select ch_select;
-  struct audplay_cmd_threshold_update thr_update;
-};
-
-#define AUDPLAY_CMD_HPCM_BUF_CFG 0x0003
-#define AUDPLAY_CMD_HPCM_BUF_CFG_LEN \
-  sizeof(struct audplay_cmd_hpcm_buf_cfg)
-
-struct audplay_cmd_hpcm_buf_cfg {
-	unsigned int cmd_id;
-	unsigned int hostpcm_config;
-	unsigned int feedback_frequency;
-	unsigned int byte_swap;
-	unsigned int max_buffers;
-	unsigned int partition_number;
-} __attribute__((packed));
-
-#define AUDPLAY_CMD_BUFFER_REFRESH 0x0004
-#define AUDPLAY_CMD_BUFFER_REFRESH_LEN \
-  sizeof(struct audplay_cmd_buffer_update)
-
-struct audplay_cmd_buffer_refresh {
-	unsigned int cmd_id;
-	unsigned int num_buffers;
-	unsigned int buf_read_count;
-	unsigned int buf0_address;
-	unsigned int buf0_length;
-	unsigned int buf1_address;
-	unsigned int buf1_length;
-} __attribute__((packed));
-
-#define AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2            0x0005
-#define AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2_LEN    \
-	sizeof(struct audplay_cmd_bitstream_data_avail_nt2)
-
-/* Type specification of dec_data_avail message sent to AUDPLAYTASK
- * for NT2 */
-struct audplay_cmd_bitstream_data_avail_nt2 {
-	/*command ID*/
-	unsigned int cmd_id;
-
-	/* Decoder ID for which message is being sent */
-	unsigned int decoder_id;
-
-	/* Start address of data in ARM global memory */
-	unsigned int buf_ptr;
-
-	/* Number of 16-bit words of bit-stream data contiguously
-	*  available at the above-mentioned address
-	*/
-	unsigned int buf_size;
-
-	/* Partition number used by audPlayTask to communicate with DSP's RTOS
-	* kernel
-	*/
-	unsigned int partition_number;
-
-	/* bitstream write pointer */
-	unsigned int dspBitstreamWritePtr;
-
-} __attribute__((packed));
-
-#define AUDPLAY_CMD_OUTPORT_FLUSH 0x0006
-
-struct audplay_cmd_outport_flush {
-	unsigned int cmd_id;
-} __attribute__((packed));
-
-#endif /* QDSP5AUDPLAYCMD_H */
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audplaymsg.h b/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audplaymsg.h
deleted file mode 100644
index 653f0e7..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audplaymsg.h
+++ /dev/null
@@ -1,74 +0,0 @@
-#ifndef QDSP5AUDPLAYMSG_H
-#define QDSP5AUDPLAYMSG_H
-
-/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
-       Q D S P 5  A U D I O   P L A Y  T A S K   M S G
-
-GENERAL DESCRIPTION
-  Message sent by AUDPLAY task
-
-REFERENCES
-  None
-
-
-Copyright (c) 1992-2009, The Linux Foundation. All rights reserved.
-
-This software is licensed under the terms of the GNU General Public
-License version 2, as published by the Free Software Foundation, and
-may be copied, distributed, and modified under those terms.
-
-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 AUDPLAY_MSG_DEC_NEEDS_DATA		0x0001
-#define AUDPLAY_MSG_DEC_NEEDS_DATA_MSG_LEN	\
-	sizeof(audplay_msg_dec_needs_data)
-
-struct audplay_msg_dec_needs_data {
-	/* reserved*/
-	unsigned int dec_id;
-
-	/*The read pointer offset of external memory till which bitstream
-	has been dmed in*/
-	unsigned int adecDataReadPtrOffset;
-
-	/*The buffer size of external memory. */
-	unsigned int adecDataBufSize;
-
-	unsigned int 	bitstream_free_len;
-	unsigned int	bitstream_write_ptr;
-	unsigned int	bitstarem_buf_start;
-	unsigned int	bitstream_buf_len;
-} __attribute__((packed));
-
-#define AUDPLAY_UP_STREAM_INFO 0x0003
-#define AUDPLAY_UP_STREAM_INFO_LEN \
-	sizeof(struct audplay_msg_stream_info)
-
-struct audplay_msg_stream_info {
-	unsigned int decoder_id;
-	unsigned int channel_info;
-	unsigned int sample_freq;
-	unsigned int bitstream_info;
-	unsigned int bit_rate;
-} __attribute__((packed));
-
-#define AUDPLAY_MSG_BUFFER_UPDATE 0x0004
-#define AUDPLAY_MSG_BUFFER_UPDATE_LEN \
-	sizeof(struct audplay_msg_buffer_update)
-
-struct audplay_msg_buffer_update {
-	unsigned int buffer_write_count;
-	unsigned int num_of_buffer;
-	unsigned int buf0_address;
-	unsigned int buf0_length;
-	unsigned int buf1_address;
-	unsigned int buf1_length;
-} __attribute__((packed));
-
-#define AUDPLAY_UP_OUTPORT_FLUSH_ACK 0x0005
-
-#endif /* QDSP5AUDPLAYMSG_H */
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audppcmdi.h b/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audppcmdi.h
deleted file mode 100644
index bdcf5d8..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audppcmdi.h
+++ /dev/null
@@ -1,1088 +0,0 @@
-#ifndef __MACH_QDSP5_V2_QDSP5AUDPPCMDI_H
-#define __MACH_QDSP5_V2_QDSP5AUDPPCMDI_H
-
-/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
-
-    A U D I O   P O S T   P R O C E S S I N G  I N T E R N A L  C O M M A N D S
-
-GENERAL DESCRIPTION
-  This file contains defintions of format blocks of commands
-  that are accepted by AUDPP Task
-
-REFERENCES
-  None
-
-EXTERNALIZED FUNCTIONS
-  None
-
-Copyright(c) 1992-2011, The Linux Foundation. All rights reserved.
-
-This software is licensed under the terms of the GNU General Public
-License version 2, as published by the Free Software Foundation, and
-may be copied, distributed, and modified under those terms.
-
-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.
-
-*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
-
-/*
- * ARM to AUDPPTASK Commands
- *
- * ARM uses three command queues to communicate with AUDPPTASK
- * 1)uPAudPPCmd1Queue : Used for more frequent and shorter length commands
- * 	Location : MEMA
- * 	Buffer Size : 6 words
- * 	No of buffers in a queue : 20 for gaming audio and 5 for other images
- * 2)uPAudPPCmd2Queue : Used for commands which are not much lengthier
- * 	Location : MEMA
- * 	Buffer Size : 23
- * 	No of buffers in a queue : 2
- * 3)uPAudOOCmd3Queue : Used for lengthier and more frequent commands
- * 	Location : MEMA
- * 	Buffer Size : 145
- * 	No of buffers in a queue : 3
- */
-
-/*
- * Commands Related to uPAudPPCmd1Queue
- */
-
-/*
- * Command Structure to enable or disable the active decoders
- */
-
-#define AUDPP_CMD_CFG_DEC_TYPE 		0x0001
-#define AUDPP_CMD_CFG_DEC_TYPE_LEN 	sizeof(struct audpp_cmd_cfg_dec_type)
-
-/* Enable the decoder */
-#define AUDPP_CMD_DEC_TYPE_M           	0x000F
-
-#define AUDPP_CMD_ENA_DEC_V         	0x4000
-#define AUDPP_CMD_DIS_DEC_V        	0x0000
-#define AUDPP_CMD_DEC_STATE_M          	0x4000
-
-#define AUDPP_CMD_UPDATDE_CFG_DEC	0x8000
-#define AUDPP_CMD_DONT_UPDATE_CFG_DEC	0x0000
-
-
-/* Type specification of cmd_cfg_dec */
-
-struct audpp_cmd_cfg_dec_type {
-	unsigned short cmd_id;
-	unsigned short stream_id;
-	unsigned short dec_cfg;
-	unsigned short dm_mode;
-} __attribute__((packed));
-
-/*
- * Command Structure to Pause , Resume and flushes the selected audio decoders
- */
-
-#define AUDPP_CMD_DEC_CTRL		0x0002
-#define AUDPP_CMD_DEC_CTRL_LEN		sizeof(struct audpp_cmd_dec_ctrl)
-
-/* Decoder control commands for pause, resume and flush */
-#define AUDPP_CMD_FLUSH_V         		0x2000
-
-#define AUDPP_CMD_PAUSE_V		        0x4000
-#define AUDPP_CMD_RESUME_V		        0x0000
-
-#define AUDPP_CMD_UPDATE_V		        0x8000
-#define AUDPP_CMD_IGNORE_V		        0x0000
-
-
-/* Type Spec for decoder control command*/
-
-struct audpp_cmd_dec_ctrl{
-	unsigned short cmd_id;
-	unsigned short stream_id;
-	unsigned short dec_ctrl;
-} __attribute__((packed));
-
-/*
- * Command Structure to Configure the AVSync FeedBack Mechanism
- */
-
-#define AUDPP_CMD_AVSYNC	0x0003
-#define AUDPP_CMD_AVSYNC_LEN	sizeof(struct audpp_cmd_avsync)
-
-struct audpp_cmd_avsync{
-	unsigned short cmd_id;
-	unsigned short stream_id;
-	unsigned short interrupt_interval;
-	unsigned short sample_counter_dlsw;
-	unsigned short sample_counter_dmsw;
-	unsigned short sample_counter_msw;
-	unsigned short byte_counter_dlsw;
-	unsigned short byte_counter_dmsw;
-	unsigned short byte_counter_msw;
-} __attribute__((packed));
-
-/*
- * Macros used to store the AV Sync Info from DSP
- */
-
-#define AUDPP_AVSYNC_CH_COUNT 1
-#define AUDPP_AVSYNC_NUM_WORDS 6
-/* Timeout of 3000ms for AV Sync Query response */
-#define AUDPP_AVSYNC_EVENT_TIMEOUT 3000
-
-/*
- * Command Structure to Query AVSync Info from DSP
- */
-
-#define AUDPP_CMD_QUERY_AVSYNC	0x0006
-
-struct audpp_cmd_query_avsync{
-	unsigned short cmd_id;
-	unsigned short stream_id;
-} __attribute__((packed));
-
-/*
- * Command Structure to enable or disable(sleep) the AUDPPTASK
- */
-
-#define AUDPP_CMD_CFG	0x0004
-#define AUDPP_CMD_CFG_LEN	sizeof(struct audpp_cmd_cfg)
-
-#define AUDPP_CMD_CFG_SLEEP   				0x0000
-#define AUDPP_CMD_CFG_ENABLE  				0xFFFF
-
-struct audpp_cmd_cfg {
-	unsigned short cmd_id;
-	unsigned short cfg;
-} __attribute__((packed));
-
-/*
- * Command Structure to Inject or drop the specified no of samples
- */
-
-#define AUDPP_CMD_ADJUST_SAMP		0x0005
-#define AUDPP_CMD_ADJUST_SAMP_LEN	sizeof(struct audpp_cmd_adjust_samp)
-
-#define AUDPP_CMD_SAMP_DROP		-1
-#define AUDPP_CMD_SAMP_INSERT		0x0001
-
-#define AUDPP_CMD_NUM_SAMPLES		0x0001
-
-struct audpp_cmd_adjust_samp {
-	unsigned short cmd_id;
-	unsigned short object_no;
-	signed short sample_insert_or_drop;
-	unsigned short num_samples;
-} __attribute__((packed));
-
-/*
- * Command Structure to Configure AVSync Feedback Mechanism
- */
-
-#define AUDPP_CMD_ROUTING_MODE      0x0007
-#define AUDPP_CMD_ROUTING_MODE_LEN  \
-sizeof(struct audpp_cmd_routing_mode)
-
-struct audpp_cmd_routing_mode {
-	unsigned short cmd_id;
-	unsigned short object_number;
-	unsigned short routing_mode;
-} __attribute__((packed));
-
-/*
- * Commands Related to uPAudPPCmd2Queue
- */
-
-/*
- * Command Structure to configure Per decoder Parameters (Common)
- */
-
-#define AUDPP_CMD_CFG_ADEC_PARAMS 		0x0000
-#define AUDPP_CMD_CFG_ADEC_PARAMS_COMMON_LEN	\
-	sizeof(struct audpp_cmd_cfg_adec_params_common)
-
-#define AUDPP_CMD_STATUS_MSG_FLAG_ENA_FCM	0x4000
-#define AUDPP_CMD_STATUS_MSG_FLAG_DIS_FCM	0x0000
-
-#define AUDPP_CMD_STATUS_MSG_FLAG_ENA_DCM	0x8000
-#define AUDPP_CMD_STATUS_MSG_FLAG_DIS_DCM	0x0000
-
-/* Sampling frequency*/
-#define  AUDPP_CMD_SAMP_RATE_96000 	0x0000
-#define  AUDPP_CMD_SAMP_RATE_88200 	0x0001
-#define  AUDPP_CMD_SAMP_RATE_64000 	0x0002
-#define  AUDPP_CMD_SAMP_RATE_48000 	0x0003
-#define  AUDPP_CMD_SAMP_RATE_44100 	0x0004
-#define  AUDPP_CMD_SAMP_RATE_32000 	0x0005
-#define  AUDPP_CMD_SAMP_RATE_24000 	0x0006
-#define  AUDPP_CMD_SAMP_RATE_22050 	0x0007
-#define  AUDPP_CMD_SAMP_RATE_16000 	0x0008
-#define  AUDPP_CMD_SAMP_RATE_12000 	0x0009
-#define  AUDPP_CMD_SAMP_RATE_11025 	0x000A
-#define  AUDPP_CMD_SAMP_RATE_8000  	0x000B
-
-
-/*
- * Type specification of cmd_adec_cfg sent to all decoder
- */
-
-struct audpp_cmd_cfg_adec_params_common {
-	unsigned short  cmd_id;
-	unsigned short  dec_id;
-	unsigned short  length;
-	unsigned short  reserved;
-	unsigned short  input_sampling_frequency;
-} __attribute__((packed));
-
-/*
- * Command Structure to configure Per decoder Parameters (Wav)
- */
-
-#define AUDPP_CMD_CFG_ADEC_PARAMS_WAV_LEN \
-	sizeof(struct audpp_cmd_cfg_adec_params_wav)
-
-
-#define	AUDPP_CMD_WAV_STEREO_CFG_MONO	0x0001
-#define AUDPP_CMD_WAV_STEREO_CFG_STEREO	0x0002
-
-#define AUDPP_CMD_WAV_PCM_WIDTH_8	0x0000
-#define AUDPP_CMD_WAV_PCM_WIDTH_16	0x0001
-#define AUDPP_CMD_WAV_PCM_WIDTH_24	0x0002
-
-struct audpp_cmd_cfg_adec_params_wav {
-	struct audpp_cmd_cfg_adec_params_common		common;
-	unsigned short					stereo_cfg;
-	unsigned short					pcm_width;
-	unsigned short 					sign;
-} __attribute__((packed));
-
-/*
- *  Command Structure for CMD_CFG_DEV_MIXER
- */
-
-#define AUDPP_CMD_CFG_DEV_MIXER_PARAMS_LEN \
-	sizeof(struct audpp_cmd_cfg_dev_mixer_params)
-
-#define AUDPP_CMD_CFG_DEV_MIXER            0x0008
-
-#define AUDPP_CMD_CFG_DEV_MIXER_ID_0       0
-#define AUDPP_CMD_CFG_DEV_MIXER_ID_1       1
-#define AUDPP_CMD_CFG_DEV_MIXER_ID_2       2
-#define AUDPP_CMD_CFG_DEV_MIXER_ID_3       3
-#define AUDPP_CMD_CFG_DEV_MIXER_ID_4       4
-#define AUDPP_CMD_CFG_DEV_MIXER_ID_5       5
-
-#define AUDPP_CMD_CFG_DEV_MIXER_DEV_NONE   0x0000
-#define AUDPP_CMD_CFG_DEV_MIXER_DEV_0      \
-				(0x1 << AUDPP_CMD_CFG_DEV_MIXER_ID_0)
-#define AUDPP_CMD_CFG_DEV_MIXER_DEV_1      \
-				(0x1 << AUDPP_CMD_CFG_DEV_MIXER_ID_1)
-#define AUDPP_CMD_CFG_DEV_MIXER_DEV_2      \
-				(0x1 << AUDPP_CMD_CFG_DEV_MIXER_ID_2)
-#define AUDPP_CMD_CFG_DEV_MIXER_DEV_3      \
-				(0x1 << AUDPP_CMD_CFG_DEV_MIXER_ID_3)
-#define AUDPP_CMD_CFG_DEV_MIXER_DEV_4      \
-				(0x1 << AUDPP_CMD_CFG_DEV_MIXER_ID_4)
-#define AUDPP_CMD_CFG_DEV_MIXER_DEV_5      \
-				(0x1 << AUDPP_CMD_CFG_DEV_MIXER_ID_5)
-
-struct audpp_cmd_cfg_dev_mixer_params {
-	unsigned short cmd_id;
-	unsigned short stream_id;
-	unsigned short mixer_cmd;
-} __attribute__((packed));
-
-
-/*
- * Command Structure to configure Per decoder Parameters (ADPCM)
- */
-
-#define AUDPP_CMD_CFG_ADEC_PARAMS_ADPCM_LEN \
-	sizeof(struct audpp_cmd_cfg_adec_params_adpcm)
-
-
-#define	AUDPP_CMD_ADPCM_STEREO_CFG_MONO		0x0001
-#define AUDPP_CMD_ADPCM_STEREO_CFG_STEREO	0x0002
-
-struct audpp_cmd_cfg_adec_params_adpcm {
-	struct audpp_cmd_cfg_adec_params_common		common;
-	unsigned short					stereo_cfg;
-	unsigned short 					block_size;
-} __attribute__((packed));
-
-/*
- * Command Structure to configure Per decoder Parameters (WMA)
- */
-
-#define AUDPP_CMD_CFG_ADEC_PARAMS_WMA_LEN	\
-	sizeof(struct audpp_cmd_cfg_adec_params_wma)
-
-struct audpp_cmd_cfg_adec_params_wma {
-	struct audpp_cmd_cfg_adec_params_common    common;
-	unsigned short 	armdatareqthr;
-	unsigned short 	channelsdecoded;
-	unsigned short 	wmabytespersec;
-	unsigned short	wmasamplingfreq;
-	unsigned short	wmaencoderopts;
-} __attribute__((packed));
-
-
-/*
- * Command Structure to configure Per decoder Parameters (MP3)
- */
-
-#define AUDPP_CMD_CFG_ADEC_PARAMS_MP3_LEN	\
-	sizeof(struct audpp_cmd_cfg_adec_params_mp3)
-
-struct audpp_cmd_cfg_adec_params_mp3 {
-	struct audpp_cmd_cfg_adec_params_common    common;
-} __attribute__((packed));
-
-
-/*
- * Command Structure to configure Per decoder Parameters (AAC)
- */
-
-#define AUDPP_CMD_CFG_ADEC_PARAMS_AAC_LEN	\
-	sizeof(struct audpp_cmd_cfg_adec_params_aac)
-
-
-#define AUDPP_CMD_AAC_FORMAT_ADTS		-1
-#define	AUDPP_CMD_AAC_FORMAT_RAW		0x0000
-#define	AUDPP_CMD_AAC_FORMAT_PSUEDO_RAW		0x0001
-#define	AUDPP_CMD_AAC_FORMAT_LOAS		0x0002
-
-#define AUDPP_CMD_AAC_AUDIO_OBJECT_LC		0x0002
-#define AUDPP_CMD_AAC_AUDIO_OBJECT_LTP		0x0004
-#define AUDPP_CMD_AAC_AUDIO_OBJECT_ERLC	0x0011
-
-#define AUDPP_CMD_AAC_SBR_ON_FLAG_ON		0x0001
-#define AUDPP_CMD_AAC_SBR_ON_FLAG_OFF		0x0000
-
-#define AUDPP_CMD_AAC_SBR_PS_ON_FLAG_ON		0x0001
-#define AUDPP_CMD_AAC_SBR_PS_ON_FLAG_OFF	0x0000
-
-struct audpp_cmd_cfg_adec_params_aac {
-	struct audpp_cmd_cfg_adec_params_common	common;
-	signed short			format;
-	unsigned short			audio_object;
-	unsigned short			ep_config;
-	unsigned short                  aac_section_data_resilience_flag;
-	unsigned short                  aac_scalefactor_data_resilience_flag;
-	unsigned short                  aac_spectral_data_resilience_flag;
-	unsigned short                  sbr_on_flag;
-	unsigned short                  sbr_ps_on_flag;
-	unsigned short                  channel_configuration;
-} __attribute__((packed));
-
-/*
- * Command Structure to configure Per decoder Parameters (V13K)
- */
-
-#define AUDPP_CMD_CFG_ADEC_PARAMS_V13K_LEN	\
-	sizeof(struct audpp_cmd_cfg_adec_params_v13k)
-
-
-#define AUDPP_CMD_STEREO_CFG_MONO		0x0001
-#define AUDPP_CMD_STEREO_CFG_STEREO		0x0002
-
-struct audpp_cmd_cfg_adec_params_v13k {
-	struct audpp_cmd_cfg_adec_params_common    	common;
-	unsigned short			stereo_cfg;
-} __attribute__((packed));
-
-#define AUDPP_CMD_CFG_ADEC_PARAMS_EVRC_LEN \
-	sizeof(struct audpp_cmd_cfg_adec_params_evrc)
-
-struct audpp_cmd_cfg_adec_params_evrc {
-	struct audpp_cmd_cfg_adec_params_common common;
-	unsigned short stereo_cfg;
-} __attribute__ ((packed));
-
-/*
- * Command Structure to configure Per decoder Parameters (AMRWB)
- */
-
-#define AUDPP_CMD_CFG_ADEC_PARAMS_AMRWB_LEN \
-	sizeof(struct audpp_cmd_cfg_adec_params_amrwb)
-
-struct audpp_cmd_cfg_adec_params_amrwb {
-	struct audpp_cmd_cfg_adec_params_common    	common;
-	unsigned short			stereo_cfg;
-} __attribute__((packed));
-
-/*
- * Command Structure to configure Per decoder Parameters (WMAPRO)
- */
-
-#define AUDPP_CMD_CFG_ADEC_PARAMS_WMAPRO_LEN	\
-	sizeof(struct audpp_cmd_cfg_adec_params_wmapro)
-
-struct audpp_cmd_cfg_adec_params_wmapro {
-	struct audpp_cmd_cfg_adec_params_common    common;
-	unsigned short 	armdatareqthr;
-	uint8_t         validbitspersample;
-	uint8_t         numchannels;
-	unsigned short  formattag;
-	unsigned short  samplingrate;
-	unsigned short  avgbytespersecond;
-	unsigned short  asfpacketlength;
-	unsigned short 	channelmask;
-	unsigned short 	encodeopt;
-	unsigned short	advancedencodeopt;
-	uint32_t	advancedencodeopt2;
-} __attribute__((packed));
-
-/*
- * Command Structure to configure the  HOST PCM interface
- */
-
-#define AUDPP_CMD_PCM_INTF	0x0001
-#define AUDPP_CMD_PCM_INTF_2	0x0002
-#define AUDPP_CMD_PCM_INTF_LEN	sizeof(struct audpp_cmd_pcm_intf)
-
-#define AUDPP_CMD_PCM_INTF_MONO_V		        0x0001
-#define AUDPP_CMD_PCM_INTF_STEREO_V         	0x0002
-
-/* These two values differentiate the two types of commands that could be issued
- * Interface configuration command and Buffer update command */
-
-#define AUDPP_CMD_PCM_INTF_CONFIG_CMD_V	       	0x0000
-#define AUDPP_CMD_PCM_INTF_BUFFER_CMD_V	        -1
-
-#define AUDPP_CMD_PCM_INTF_RX_ENA_M              0x000F
-#define AUDPP_CMD_PCM_INTF_RX_ENA_ARMTODSP_V     0x0008
-#define AUDPP_CMD_PCM_INTF_RX_ENA_DSPTOARM_V     0x0004
-
-/* These flags control the enabling and disabling of the interface together
- *  with host interface bit mask. */
-
-#define AUDPP_CMD_PCM_INTF_ENA_V            -1
-#define AUDPP_CMD_PCM_INTF_DIS_V            0x0000
-
-
-#define  AUDPP_CMD_PCM_INTF_FULL_DUPLEX           0x0
-#define  AUDPP_CMD_PCM_INTF_HALF_DUPLEX_TODSP     0x1
-
-
-#define  AUDPP_CMD_PCM_INTF_OBJECT_NUM           0x5
-#define  AUDPP_CMD_PCM_INTF_COMMON_OBJECT_NUM    0x6
-
-struct audpp_cmd_pcm_intf {
-	unsigned short  cmd_id;
-	unsigned short  stream;
-	unsigned short  stream_id;
-	signed short  config;
-	unsigned short  intf_type;
-
-	/* DSP -> ARM Configuration */
-	unsigned short  read_buf1LSW;
-	unsigned short  read_buf1MSW;
-	unsigned short  read_buf1_len;
-
-	unsigned short  read_buf2LSW;
-	unsigned short  read_buf2MSW;
-	unsigned short  read_buf2_len;
-	/*   0:HOST_PCM_INTF disable
-	**  0xFFFF: HOST_PCM_INTF enable
-	*/
-	signed short  dsp_to_arm_flag;
-	unsigned short  partition_number;
-
-	/* ARM -> DSP Configuration */
-	unsigned short  write_buf1LSW;
-	unsigned short  write_buf1MSW;
-	unsigned short  write_buf1_len;
-
-	unsigned short  write_buf2LSW;
-	unsigned short  write_buf2MSW;
-	unsigned short  write_buf2_len;
-
-	/*   0:HOST_PCM_INTF disable
-	**  0xFFFF: HOST_PCM_INTF enable
-	*/
-	signed short  arm_to_rx_flag;
-	unsigned short  weight_decoder_to_rx;
-	unsigned short  weight_arm_to_rx;
-
-	unsigned short  partition_number_arm_to_dsp;
-	unsigned short  sample_rate;
-	unsigned short  channel_mode;
-} __attribute__((packed));
-
-/*
- **  BUFFER UPDATE COMMAND
- */
-#define AUDPP_CMD_PCM_INTF_SEND_BUF_PARAMS_LEN	\
-	sizeof(struct audpp_cmd_pcm_intf_send_buffer)
-
-struct audpp_cmd_pcm_intf_send_buffer {
-	unsigned short  cmd_id;
-	unsigned short  stream;
-	unsigned short  stream_id;
-	/* set config = 0xFFFF for configuration*/
-	signed short  config;
-	unsigned short  intf_type;
-	unsigned short  dsp_to_arm_buf_id;
-	unsigned short  arm_to_dsp_buf_id;
-	unsigned short  arm_to_dsp_buf_len;
-} __attribute__((packed));
-
-
-/*
- * Commands Related to uPAudPPCmd3Queue
- */
-
-/*
- * Command Structure to configure post processing params (Commmon)
- */
-
-#define AUDPP_CMD_CFG_OBJECT_PARAMS		0x0000
-#define AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN		\
-	sizeof(struct audpp_cmd_cfg_object_params_common)
-
-#define AUDPP_CMD_OBJ0_UPDATE		0x8000
-#define AUDPP_CMD_OBJ0_DONT_UPDATE	0x0000
-
-
-#define AUDPP_CMD_OBJ2_UPDATE		0x8000
-#define AUDPP_CMD_OBJ2_DONT_UPDATE	0x0000
-
-#define AUDPP_CMD_OBJ3_UPDATE		0x8000
-#define AUDPP_CMD_OBJ3_DONT_UPDATE	0x0000
-
-#define AUDPP_CMD_OBJ4_UPDATE		0x8000
-#define AUDPP_CMD_OBJ4_DONT_UPDATE	0x0000
-
-#define AUDPP_CMD_HPCM_UPDATE		0x8000
-#define AUDPP_CMD_HPCM_DONT_UPDATE	0x0000
-
-#define AUDPP_CMD_COMMON_CFG_UPDATE		0x8000
-#define AUDPP_CMD_COMMON_CFG_DONT_UPDATE	0x0000
-
-#define AUDPP_CMD_POPP_STREAM   0xFFFF
-#define AUDPP_CMD_COPP_STREAM   0x0000
-
-struct audpp_cmd_cfg_object_params_common{
-	unsigned short  cmd_id;
-	unsigned short	stream;
-	unsigned short	stream_id;
-	unsigned short	obj_cfg;
-	unsigned short	command_type;
-} __attribute__((packed));
-
-/*
- * Command Structure to configure post processing params (Volume)
- */
-#define AUDPP_CMD_VOLUME_PAN		0
-#define AUDPP_CMD_CFG_OBJECT_PARAMS_VOLUME_LEN		\
-	sizeof(struct audpp_cmd_cfg_object_params_volume)
-
-struct audpp_cmd_cfg_object_params_volume {
-	struct audpp_cmd_cfg_object_params_common 	common;
-	unsigned short					volume;
-	unsigned short					pan;
-} __attribute__((packed));
-
-/*
- * Command Structure to configure post processing params (PCM Filter)
- */
-
-struct numerator {
-	unsigned short			numerator_b0_filter_lsw;
-	unsigned short			numerator_b0_filter_msw;
-	unsigned short			numerator_b1_filter_lsw;
-	unsigned short			numerator_b1_filter_msw;
-	unsigned short			numerator_b2_filter_lsw;
-	unsigned short			numerator_b2_filter_msw;
-} __attribute__((packed));
-
-struct denominator {
-	unsigned short			denominator_a0_filter_lsw;
-	unsigned short			denominator_a0_filter_msw;
-	unsigned short			denominator_a1_filter_lsw;
-	unsigned short			denominator_a1_filter_msw;
-} __attribute__((packed));
-
-struct shift_factor {
-	unsigned short			shift_factor_0;
-} __attribute__((packed));
-
-struct pan {
-	unsigned short			pan_filter_0;
-} __attribute__((packed));
-
-struct filter_1 {
-	struct numerator		numerator_filter;
-	struct denominator		denominator_filter;
-	struct shift_factor		shift_factor_filter;
-	struct pan			pan_filter;
-} __attribute__((packed));
-
-struct filter_2 {
-	struct numerator		numerator_filter[2];
-	struct denominator		denominator_filter[2];
-	struct shift_factor		shift_factor_filter[2];
-	struct pan			pan_filter[2];
-} __attribute__((packed));
-
-struct filter_3 {
-	struct numerator		numerator_filter[3];
-	struct denominator		denominator_filter[3];
-	struct shift_factor		shift_factor_filter[3];
-	struct pan			pan_filter[3];
-} __attribute__((packed));
-
-struct filter_4 {
-	struct numerator		numerator_filter[4];
-	struct denominator		denominator_filter[4];
-	struct shift_factor		shift_factor_filter[4];
-	struct pan			pan_filter[4];
-} __attribute__((packed));
-
-#define AUDPP_CMD_IIR_TUNING_FILTER	1
-#define AUDPP_CMD_CFG_OBJECT_PARAMS_PCM_LEN		\
-	sizeof(struct audpp_cmd_cfg_object_params_pcm)
-
-
-struct audpp_cmd_cfg_object_params_pcm {
-	struct audpp_cmd_cfg_object_params_common 	common;
-	signed short				active_flag;
-	unsigned short 				num_bands;
-	union {
-		struct filter_1			filter_1_params;
-		struct filter_2			filter_2_params;
-		struct filter_3			filter_3_params;
-		struct filter_4			filter_4_params;
-	} __attribute__((packed)) params_filter;
-} __attribute__((packed));
-
-#define AUDPP_CMD_CALIB_GAIN_RX         15
-#define AUDPP_CMD_CFG_CAL_GAIN_LEN sizeof(struct audpp_cmd_cfg_cal_gain)
-
-
-struct audpp_cmd_cfg_cal_gain {
-	struct audpp_cmd_cfg_object_params_common common;
-	unsigned short audppcalgain;
-	unsigned short reserved;
-} __attribute__((packed));
-
-
-/*
- * Command Structure to configure post processing parameters (equalizer)
- */
-#define AUDPP_CMD_EQUALIZER		2
-#define AUDPP_CMD_CFG_OBJECT_PARAMS_EQALIZER_LEN		\
-	sizeof(struct audpp_cmd_cfg_object_params_eqalizer)
-
-struct eq_numerator {
-	unsigned short			numerator_coeff_0_lsw;
-	unsigned short			numerator_coeff_0_msw;
-	unsigned short			numerator_coeff_1_lsw;
-	unsigned short			numerator_coeff_1_msw;
-	unsigned short			numerator_coeff_2_lsw;
-	unsigned short			numerator_coeff_2_msw;
-} __attribute__((packed));
-
-struct eq_denominator {
-	unsigned short			denominator_coeff_0_lsw;
-	unsigned short			denominator_coeff_0_msw;
-	unsigned short			denominator_coeff_1_lsw;
-	unsigned short			denominator_coeff_1_msw;
-} __attribute__((packed));
-
-struct eq_shiftfactor {
-	unsigned short			shift_factor;
-} __attribute__((packed));
-
-struct eq_coeff_1 {
-	struct eq_numerator	numerator;
-	struct eq_denominator	denominator;
-	struct eq_shiftfactor	shiftfactor;
-} __attribute__((packed));
-
-struct eq_coeff_2 {
-	struct eq_numerator	numerator[2];
-	struct eq_denominator	denominator[2];
-	struct eq_shiftfactor	shiftfactor[2];
-} __attribute__((packed));
-
-struct eq_coeff_3 {
-	struct eq_numerator	numerator[3];
-	struct eq_denominator	denominator[3];
-	struct eq_shiftfactor	shiftfactor[3];
-} __attribute__((packed));
-
-struct eq_coeff_4 {
-	struct eq_numerator	numerator[4];
-	struct eq_denominator	denominator[4];
-	struct eq_shiftfactor	shiftfactor[4];
-} __attribute__((packed));
-
-struct eq_coeff_5 {
-	struct eq_numerator	numerator[5];
-	struct eq_denominator	denominator[5];
-	struct eq_shiftfactor	shiftfactor[5];
-} __attribute__((packed));
-
-struct eq_coeff_6 {
-	struct eq_numerator	numerator[6];
-	struct eq_denominator	denominator[6];
-	struct eq_shiftfactor	shiftfactor[6];
-} __attribute__((packed));
-
-struct eq_coeff_7 {
-	struct eq_numerator	numerator[7];
-	struct eq_denominator	denominator[7];
-	struct eq_shiftfactor	shiftfactor[7];
-} __attribute__((packed));
-
-struct eq_coeff_8 {
-	struct eq_numerator	numerator[8];
-	struct eq_denominator	denominator[8];
-	struct eq_shiftfactor	shiftfactor[8];
-} __attribute__((packed));
-
-struct eq_coeff_9 {
-	struct eq_numerator	numerator[9];
-	struct eq_denominator	denominator[9];
-	struct eq_shiftfactor	shiftfactor[9];
-} __attribute__((packed));
-
-struct eq_coeff_10 {
-	struct eq_numerator	numerator[10];
-	struct eq_denominator	denominator[10];
-	struct eq_shiftfactor	shiftfactor[10];
-} __attribute__((packed));
-
-struct eq_coeff_11 {
-	struct eq_numerator	numerator[11];
-	struct eq_denominator	denominator[11];
-	struct eq_shiftfactor	shiftfactor[11];
-} __attribute__((packed));
-
-struct eq_coeff_12 {
-	struct eq_numerator	numerator[12];
-	struct eq_denominator	denominator[12];
-	struct eq_shiftfactor	shiftfactor[12];
-} __attribute__((packed));
-
-
-struct audpp_cmd_cfg_object_params_eqalizer {
-	struct audpp_cmd_cfg_object_params_common 	common;
-	signed short				eq_flag;
-	unsigned short				num_bands;
-	union {
-		struct eq_coeff_1	eq_coeffs_1;
-		struct eq_coeff_2	eq_coeffs_2;
-		struct eq_coeff_3	eq_coeffs_3;
-		struct eq_coeff_4	eq_coeffs_4;
-		struct eq_coeff_5	eq_coeffs_5;
-		struct eq_coeff_6	eq_coeffs_6;
-		struct eq_coeff_7	eq_coeffs_7;
-		struct eq_coeff_8	eq_coeffs_8;
-		struct eq_coeff_9	eq_coeffs_9;
-		struct eq_coeff_10	eq_coeffs_10;
-		struct eq_coeff_11	eq_coeffs_11;
-		struct eq_coeff_12	eq_coeffs_12;
-	} __attribute__((packed)) eq_coeff;
-} __attribute__((packed));
-
-/*
- * Command Structure to configure post processing parameters (ADRC)
- */
-#define AUDPP_CMD_ADRC			3
-#define AUDPP_CMD_CFG_OBJECT_PARAMS_ADRC_LEN		\
-	sizeof(struct audpp_cmd_cfg_object_params_adrc)
-
-
-#define AUDPP_CMD_ADRC_FLAG_DIS		0x0000
-#define AUDPP_CMD_ADRC_FLAG_ENA		-1
-#define AUDPP_CMD_PBE_FLAG_DIS		0x0000
-#define AUDPP_CMD_PBE_FLAG_ENA		-1
-
-struct audpp_cmd_cfg_object_params_adrc {
-	struct audpp_cmd_cfg_object_params_common 	common;
-	signed short		adrc_flag;
-	unsigned short	compression_th;
-	unsigned short	compression_slope;
-	unsigned short	rms_time;
-	unsigned short	attack_const_lsw;
-	unsigned short	attack_const_msw;
-	unsigned short	release_const_lsw;
-	unsigned short	release_const_msw;
-	unsigned short	adrc_delay;
-};
-
-/*
- * Command Structure to configure post processing parameters (MB - ADRC)
- */
-#define AUDPP_CMD_MBADRC		10
-#define	AUDPP_MAX_MBADRC_BANDS		5
-
-struct adrc_config {
-	uint16_t subband_enable;
-	uint16_t adrc_sub_mute;
-	uint16_t rms_time;
-	uint16_t compression_th;
-	uint16_t compression_slope;
-	uint16_t attack_const_lsw;
-	uint16_t attack_const_msw;
-	uint16_t release_const_lsw;
-	uint16_t release_const_msw;
-	uint16_t makeup_gain;
-};
-
-struct audpp_cmd_cfg_object_params_mbadrc {
-	struct audpp_cmd_cfg_object_params_common 	common;
-	uint16_t enable;
-	uint16_t num_bands;
-	uint16_t down_samp_level;
-	uint16_t adrc_delay;
-	uint16_t ext_buf_size;
-	uint16_t ext_partition;
-	uint16_t ext_buf_msw;
-	uint16_t ext_buf_lsw;
-	struct adrc_config adrc_band[AUDPP_MAX_MBADRC_BANDS];
-} __attribute__((packed));
-
-/*
- * Command Structure to configure post processing parameters(Spectrum Analizer)
- */
-#define AUDPP_CMD_SPECTROGRAM		4
-#define AUDPP_CMD_CFG_OBJECT_PARAMS_SPECTRAM_LEN		\
-	sizeof(struct audpp_cmd_cfg_object_params_spectram)
-
-
-struct audpp_cmd_cfg_object_params_spectram {
-	struct audpp_cmd_cfg_object_params_common 	common;
-	unsigned short				sample_interval;
-	unsigned short				num_coeff;
-} __attribute__((packed));
-
-/*
- * Command Structure to configure post processing parameters (QConcert)
- */
-#define AUDPP_CMD_QCONCERT		5
-#define AUDPP_CMD_CFG_OBJECT_PARAMS_QCONCERT_LEN		\
-	sizeof(struct audpp_cmd_cfg_object_params_qconcert)
-
-
-#define AUDPP_CMD_QCON_ENA_FLAG_ENA		-1
-#define AUDPP_CMD_QCON_ENA_FLAG_DIS		0x0000
-
-#define AUDPP_CMD_QCON_OP_MODE_HEADPHONE	-1
-#define AUDPP_CMD_QCON_OP_MODE_SPEAKER_FRONT	0x0000
-#define AUDPP_CMD_QCON_OP_MODE_SPEAKER_SIDE	0x0001
-#define AUDPP_CMD_QCON_OP_MODE_SPEAKER_DESKTOP	0x0002
-
-#define AUDPP_CMD_QCON_GAIN_UNIT			0x7FFF
-#define AUDPP_CMD_QCON_GAIN_SIX_DB			0x4027
-
-
-#define AUDPP_CMD_QCON_EXPANSION_MAX		0x7FFF
-
-
-struct audpp_cmd_cfg_object_params_qconcert {
-	struct audpp_cmd_cfg_object_params_common 	common;
-	signed short				enable_flag;
-	signed short				op_mode;
-	signed short				gain;
-	signed short				expansion;
-	signed short				delay;
-	unsigned short				stages_per_mode;
-	unsigned short				reverb_enable;
-	unsigned short				decay_msw;
-	unsigned short				decay_lsw;
-	unsigned short				decay_time_ratio_msw;
-	unsigned short				decay_time_ratio_lsw;
-	unsigned short				reflection_delay_time;
-	unsigned short				late_reverb_gain;
-	unsigned short				late_reverb_delay;
-	unsigned short                          delay_buff_size_msw;
-	unsigned short                          delay_buff_size_lsw;
-	unsigned short                          partition_num;
-	unsigned short                          delay_buff_start_msw;
-	unsigned short                          delay_buff_start_lsw;
-} __attribute__((packed));
-
-/*
- * Command Structure to configure post processing parameters (Side Chain)
- */
-#define AUDPP_CMD_SIDECHAIN_TUNING_FILTER	6
-#define AUDPP_CMD_CFG_OBJECT_PARAMS_SIDECHAIN_LEN		\
-	sizeof(struct audpp_cmd_cfg_object_params_sidechain)
-
-
-#define AUDPP_CMD_SIDECHAIN_ACTIVE_FLAG_DIS	0x0000
-#define AUDPP_CMD_SIDECHAIN_ACTIVE_FLAG_ENA	-1
-
-struct audpp_cmd_cfg_object_params_sidechain {
-	struct audpp_cmd_cfg_object_params_common 	common;
-	signed short				active_flag;
-	unsigned short				num_bands;
-	union {
-		struct filter_1			filter_1_params;
-		struct filter_2			filter_2_params;
-		struct filter_3			filter_3_params;
-		struct filter_4			filter_4_params;
-	} __attribute__((packed)) params_filter;
-} __attribute__((packed));
-
-
-/*
- * Command Structure to configure post processing parameters (QAFX)
- */
-#define AUDPP_CMD_QAFX			8
-#define AUDPP_CMD_CFG_OBJECT_PARAMS_QAFX_LEN		\
-	sizeof(struct audpp_cmd_cfg_object_params_qafx)
-
-#define AUDPP_CMD_QAFX_ENA_DISA		0x0000
-#define AUDPP_CMD_QAFX_ENA_ENA_CFG	-1
-#define AUDPP_CMD_QAFX_ENA_DIS_CFG	0x0001
-
-#define AUDPP_CMD_QAFX_CMD_TYPE_ENV	0x0100
-#define AUDPP_CMD_QAFX_CMD_TYPE_OBJ	0x0010
-#define AUDPP_CMD_QAFX_CMD_TYPE_QUERY	0x1000
-
-#define AUDPP_CMD_QAFX_CMDS_ENV_OP_MODE	0x0100
-#define AUDPP_CMD_QAFX_CMDS_ENV_LIS_POS	0x0101
-#define AUDPP_CMD_QAFX_CMDS_ENV_LIS_ORI	0x0102
-#define AUDPP_CMD_QAFX_CMDS_ENV_LIS_VEL	0X0103
-#define AUDPP_CMD_QAFX_CMDS_ENV_ENV_RES	0x0107
-
-#define AUDPP_CMD_QAFX_CMDS_OBJ_SAMP_FREQ	0x0010
-#define AUDPP_CMD_QAFX_CMDS_OBJ_VOL		0x0011
-#define AUDPP_CMD_QAFX_CMDS_OBJ_DIST		0x0012
-#define AUDPP_CMD_QAFX_CMDS_OBJ_POS		0x0013
-#define AUDPP_CMD_QAFX_CMDS_OBJ_VEL		0x0014
-
-
-struct audpp_cmd_cfg_object_params_qafx {
-	struct audpp_cmd_cfg_object_params_common 	common;
-	signed short				enable;
-	unsigned short				command_type;
-	unsigned short				num_commands;
-	unsigned short				commands;
-} __attribute__((packed));
-
-/*
- * Command Structure to enable , disable or configure the reverberation effect
- * (REVERB) (Common)
- */
-
-#define AUDPP_CMD_REVERB_CONFIG		0x0001
-#define	AUDPP_CMD_REVERB_CONFIG_COMMON_LEN	\
-	sizeof(struct audpp_cmd_reverb_config_common)
-
-#define AUDPP_CMD_ENA_ENA	0xFFFF
-#define AUDPP_CMD_ENA_DIS	0x0000
-#define AUDPP_CMD_ENA_CFG	0x0001
-
-#define AUDPP_CMD_CMD_TYPE_ENV		0x0104
-#define AUDPP_CMD_CMD_TYPE_OBJ		0x0015
-#define AUDPP_CMD_CMD_TYPE_QUERY	0x1000
-
-
-struct audpp_cmd_reverb_config_common {
-	unsigned short			cmd_id;
-	unsigned short			enable;
-	unsigned short			cmd_type;
-} __attribute__((packed));
-
-/*
- * Command Structure to enable , disable or configure the reverberation effect
- * (ENV-0x0104)
- */
-
-#define	AUDPP_CMD_REVERB_CONFIG_ENV_104_LEN	\
-	sizeof(struct audpp_cmd_reverb_config_env_104)
-
-struct audpp_cmd_reverb_config_env_104 {
-	struct audpp_cmd_reverb_config_common	common;
-	unsigned short			env_gain;
-	unsigned short			decay_msw;
-	unsigned short			decay_lsw;
-	unsigned short			decay_timeratio_msw;
-	unsigned short			decay_timeratio_lsw;
-	unsigned short			delay_time;
-	unsigned short			reverb_gain;
-	unsigned short			reverb_delay;
-} __attribute__((packed));
-
-/*
- * Command Structure to enable , disable or configure the reverberation effect
- * (ENV-0x0015)
- */
-
-#define	AUDPP_CMD_REVERB_CONFIG_ENV_15_LEN	\
-	sizeof(struct audpp_cmd_reverb_config_env_15)
-
-struct audpp_cmd_reverb_config_env_15 {
-	struct audpp_cmd_reverb_config_common	common;
-	unsigned short			object_num;
-	unsigned short			absolute_gain;
-} __attribute__((packed));
-
-#define AUDPP_CMD_PBE                   16
-#define AUDPP_CMD_CFG_PBE_LEN sizeof(struct audpp_cmd_cfg_pbe)
-
-struct audpp_cmd_cfg_pbe {
-	struct audpp_cmd_cfg_object_params_common       common;
-	unsigned short pbe_enable;
-	signed short   realbassmix;
-	signed short   basscolorcontrol;
-	unsigned short mainchaindelay;
-	unsigned short xoverfltorder;
-	unsigned short bandpassfltorder;
-	signed short   adrcdelay;
-	unsigned short downsamplelevel;
-	unsigned short comprmstav;
-	signed short   expthreshold;
-	unsigned short expslope;
-	unsigned short compthreshold;
-	unsigned short compslope;
-	unsigned short cpmpattack_lsw;
-	unsigned short compattack_msw;
-	unsigned short comprelease_lsw;
-	unsigned short comprelease_msw;
-	unsigned short compmakeupgain;
-	signed short   baselimthreshold;
-	signed short   highlimthreshold;
-	signed short   basslimmakeupgain;
-	signed short   highlimmakeupgain;
-	signed short   limbassgrc;
-	signed short   limhighgrc;
-	signed short   limdelay;
-	unsigned short filter_coeffs[90];
-	unsigned short extbuffsize_lsw;
-	unsigned short extbuffsize_msw;
-	unsigned short extpartition;
-	unsigned short extbuffstart_lsw;
-	unsigned short extbuffstart_msw;
-} __attribute__((packed));
-
-#define AUDPP_CMD_PP_FEAT_QUERY_PARAMS  0x0002
-
-struct audpp_cmd_cfg_object_params_volpan {
-	struct audpp_cmd_cfg_object_params_common       common;
-	u16 volume ;
-	u16 pan;
-};
-
-struct rtc_audpp_read_data {
-	unsigned short  cmd_id;
-	unsigned short  obj_id;
-	unsigned short  route_id;
-	unsigned short  feature_id;
-	unsigned short  extbufsizemsw;
-	unsigned short  extbufsizelsw;
-	unsigned short	extpart;
-	unsigned short	extbufstartmsw;
-	unsigned short	extbufstartlsw;
-} __attribute__((packed)) ;
-
-#define AUDPP_CMD_SAMPLING_FREQUENCY	7
-#define AUDPP_CMD_QRUMBLE		9
-
-#endif /* __MACH_QDSP5_V2_QDSP5AUDPPCMDI_H */
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audppmsg.h b/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audppmsg.h
deleted file mode 100644
index 300232d..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audppmsg.h
+++ /dev/null
@@ -1,311 +0,0 @@
-#ifndef QDSP5AUDPPMSG_H
-#define QDSP5AUDPPMSG_H
-
-/*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*
-
-       Q D S P 5  A U D I O   P O S T   P R O C E S S I N G   M S G
-
-GENERAL DESCRIPTION
-  Messages sent by AUDPPTASK to ARM
-
-REFERENCES
-  None
-
-EXTERNALIZED FUNCTIONS
-  None
-
-Copyright (c) 1992-2009, The Linux Foundation. All rights reserved.
-
-This software is licensed under the terms of the GNU General Public
-License version 2, as published by the Free Software Foundation, and
-may be copied, distributed, and modified under those terms.
-
-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.
-
-*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*/
-
-/*
- * AUDPPTASK uses audPPuPRlist to send messages to the ARM
- * Location : MEMA
- * Buffer Size : 45
- * No of Buffers in a queue : 5 for gaming audio and 1 for other images
- */
-
-/*
- * MSG to Informs the ARM os Success/Failure of bringing up the decoder
- */
-
-#define AUDPP_MSG_FEAT_QUERY_DM_DONE 0x000b
-
-#define AUDPP_MSG_STATUS_MSG		0x0001
-#define AUDPP_MSG_STATUS_MSG_LEN	\
-	sizeof(struct audpp_msg_status_msg)
-
-#define AUDPP_MSG_STATUS_SLEEP		0x0000
-#define AUDPP_MSG_STATUS_INIT		0x0001
-#define AUDPP_MSG_STATUS_CFG		0x0002
-#define AUDPP_MSG_STATUS_PLAY		0x0003
-
-#define AUDPP_MSG_REASON_NONE	0x0000
-#define AUDPP_MSG_REASON_MEM	0x0001
-#define AUDPP_MSG_REASON_NODECODER 0x0002
-
-struct audpp_msg_status_msg {
-	unsigned short dec_id;
-	unsigned short status;
-	unsigned short reason;
-} __attribute__((packed));
-
-/*
- * MSG to communicate the spectrum analyzer output bands to the ARM
- */
-#define AUDPP_MSG_SPA_BANDS		0x0002
-#define AUDPP_MSG_SPA_BANDS_LEN	\
-	sizeof(struct audpp_msg_spa_bands)
-
-struct audpp_msg_spa_bands {
-	unsigned short			current_object;
-	unsigned short			spa_band_1;
-	unsigned short			spa_band_2;
-	unsigned short			spa_band_3;
-	unsigned short			spa_band_4;
-	unsigned short			spa_band_5;
-	unsigned short			spa_band_6;
-	unsigned short			spa_band_7;
-	unsigned short			spa_band_8;
-	unsigned short			spa_band_9;
-	unsigned short			spa_band_10;
-	unsigned short			spa_band_11;
-	unsigned short			spa_band_12;
-	unsigned short			spa_band_13;
-	unsigned short			spa_band_14;
-	unsigned short			spa_band_15;
-	unsigned short			spa_band_16;
-	unsigned short			spa_band_17;
-	unsigned short			spa_band_18;
-	unsigned short			spa_band_19;
-	unsigned short			spa_band_20;
-	unsigned short			spa_band_21;
-	unsigned short			spa_band_22;
-	unsigned short			spa_band_23;
-	unsigned short			spa_band_24;
-	unsigned short			spa_band_25;
-	unsigned short			spa_band_26;
-	unsigned short			spa_band_27;
-	unsigned short			spa_band_28;
-	unsigned short			spa_band_29;
-	unsigned short			spa_band_30;
-	unsigned short			spa_band_31;
-	unsigned short			spa_band_32;
-} __attribute__((packed));
-
-/*
- * MSG to communicate the PCM I/O buffer status to ARM
- */
-#define  AUDPP_MSG_HOST_PCM_INTF_MSG		0x0003
-#define  AUDPP_MSG_HOST_PCM_INTF_MSG_LEN	\
-	sizeof(struct audpp_msg_host_pcm_intf_msg)
-
-#define AUDPP_MSG_HOSTPCM_ID_TX_ARM	0x0000
-#define AUDPP_MSG_HOSTPCM_ID_ARM_TX	0x0001
-#define AUDPP_MSG_HOSTPCM_ID_RX_ARM	0x0002
-#define AUDPP_MSG_HOSTPCM_ID_ARM_RX	0x0003
-
-#define AUDPP_MSG_SAMP_FREQ_INDX_96000	0x0000
-#define AUDPP_MSG_SAMP_FREQ_INDX_88200	0x0001
-#define AUDPP_MSG_SAMP_FREQ_INDX_64000	0x0002
-#define AUDPP_MSG_SAMP_FREQ_INDX_48000	0x0003
-#define AUDPP_MSG_SAMP_FREQ_INDX_44100	0x0004
-#define AUDPP_MSG_SAMP_FREQ_INDX_32000	0x0005
-#define AUDPP_MSG_SAMP_FREQ_INDX_24000	0x0006
-#define AUDPP_MSG_SAMP_FREQ_INDX_22050	0x0007
-#define AUDPP_MSG_SAMP_FREQ_INDX_16000	0x0008
-#define AUDPP_MSG_SAMP_FREQ_INDX_12000	0x0009
-#define AUDPP_MSG_SAMP_FREQ_INDX_11025	0x000A
-#define AUDPP_MSG_SAMP_FREQ_INDX_8000	0x000B
-
-#define AUDPP_MSG_CHANNEL_MODE_MONO		0x0001
-#define AUDPP_MSG_CHANNEL_MODE_STEREO	0x0002
-
-struct audpp_msg_host_pcm_intf_msg {
-	unsigned short obj_num;
-	unsigned short numbers_of_samples;
-	unsigned short host_pcm_id;
-	unsigned short buf_indx;
-	unsigned short samp_freq_indx;
-	unsigned short channel_mode;
-} __attribute__((packed));
-
-
-/*
- * MSG to communicate 3D position of the source and listener , source volume
- * source rolloff, source orientation
- */
-
-#define AUDPP_MSG_QAFX_POS		0x0004
-#define AUDPP_MSG_QAFX_POS_LEN		\
-	sizeof(struct audpp_msg_qafx_pos)
-
-struct audpp_msg_qafx_pos {
-	unsigned short	current_object;
-	unsigned short	x_pos_lis_msw;
-	unsigned short	x_pos_lis_lsw;
-	unsigned short	y_pos_lis_msw;
-	unsigned short	y_pos_lis_lsw;
-	unsigned short	z_pos_lis_msw;
-	unsigned short	z_pos_lis_lsw;
-	unsigned short	x_fwd_msw;
-	unsigned short	x_fwd_lsw;
-	unsigned short	y_fwd_msw;
-	unsigned short	y_fwd_lsw;
-	unsigned short	z_fwd_msw;
-	unsigned short	z_fwd_lsw;
-	unsigned short 	x_up_msw;
-	unsigned short	x_up_lsw;
-	unsigned short 	y_up_msw;
-	unsigned short	y_up_lsw;
-	unsigned short 	z_up_msw;
-	unsigned short	z_up_lsw;
-	unsigned short 	x_vel_lis_msw;
-	unsigned short 	x_vel_lis_lsw;
-	unsigned short 	y_vel_lis_msw;
-	unsigned short 	y_vel_lis_lsw;
-	unsigned short 	z_vel_lis_msw;
-	unsigned short 	z_vel_lis_lsw;
-	unsigned short	threed_enable_flag;
-	unsigned short 	volume;
-	unsigned short	x_pos_source_msw;
-	unsigned short	x_pos_source_lsw;
-	unsigned short	y_pos_source_msw;
-	unsigned short	y_pos_source_lsw;
-	unsigned short	z_pos_source_msw;
-	unsigned short	z_pos_source_lsw;
-	unsigned short	max_dist_0_msw;
-	unsigned short	max_dist_0_lsw;
-	unsigned short	min_dist_0_msw;
-	unsigned short	min_dist_0_lsw;
-	unsigned short	roll_off_factor;
-	unsigned short	mute_after_max_flag;
-	unsigned short	x_vel_source_msw;
-	unsigned short	x_vel_source_lsw;
-	unsigned short	y_vel_source_msw;
-	unsigned short	y_vel_source_lsw;
-	unsigned short	z_vel_source_msw;
-	unsigned short	z_vel_source_lsw;
-} __attribute__((packed));
-
-/*
- * MSG to provide AVSYNC feedback from DSP to ARM
- */
-
-#define AUDPP_MSG_AVSYNC_MSG		0x0005
-#define AUDPP_MSG_AVSYNC_MSG_LEN	\
-	sizeof(struct audpp_msg_avsync_msg)
-
-struct audpp_msg_avsync_msg {
-	unsigned short	active_flag;
-	unsigned short	num_samples_counter0_HSW;
-	unsigned short	num_samples_counter0_MSW;
-	unsigned short	num_samples_counter0_LSW;
-	unsigned short	num_bytes_counter0_HSW;
-	unsigned short	num_bytes_counter0_MSW;
-	unsigned short	num_bytes_counter0_LSW;
-	unsigned short	samp_freq_obj_0;
-	unsigned short	samp_freq_obj_1;
-	unsigned short	samp_freq_obj_2;
-	unsigned short	samp_freq_obj_3;
-	unsigned short	samp_freq_obj_4;
-	unsigned short	samp_freq_obj_5;
-	unsigned short	samp_freq_obj_6;
-	unsigned short	samp_freq_obj_7;
-	unsigned short	samp_freq_obj_8;
-	unsigned short	samp_freq_obj_9;
-	unsigned short	samp_freq_obj_10;
-	unsigned short	samp_freq_obj_11;
-	unsigned short	samp_freq_obj_12;
-	unsigned short	samp_freq_obj_13;
-	unsigned short	samp_freq_obj_14;
-	unsigned short	samp_freq_obj_15;
-	unsigned short	num_samples_counter4_HSW;
-	unsigned short	num_samples_counter4_MSW;
-	unsigned short	num_samples_counter4_LSW;
-	unsigned short	num_bytes_counter4_HSW;
-	unsigned short	num_bytes_counter4_MSW;
-	unsigned short	num_bytes_counter4_LSW;
-} __attribute__((packed));
-
-/*
- * MSG to provide PCM DMA Missed feedback from the DSP to ARM
- */
-
-#define  AUDPP_MSG_PCMDMAMISSED	0x0006
-#define  AUDPP_MSG_PCMDMAMISSED_LEN	\
-	sizeof(struct audpp_msg_pcmdmamissed);
-
-struct audpp_msg_pcmdmamissed {
-	/*
-	** Bit 0	0 = PCM DMA not missed for object 0
-	**        1 = PCM DMA missed for object0
-	** Bit 1	0 = PCM DMA not missed for object 1
-	**        1 = PCM DMA missed for object1
-	** Bit 2	0 = PCM DMA not missed for object 2
-	**        1 = PCM DMA missed for object2
-	** Bit 3	0 = PCM DMA not missed for object 3
-	**        1 = PCM DMA missed for object3
-	** Bit 4	0 = PCM DMA not missed for object 4
-	**        1 = PCM DMA missed for object4
-	*/
-	unsigned short pcmdmamissed;
-} __attribute__((packed));
-
-/*
- * MSG to AUDPP enable or disable feedback form DSP to ARM
- */
-
-#define AUDPP_MSG_CFG_MSG	0x0007
-#define AUDPP_MSG_CFG_MSG_LEN	\
-    sizeof(struct audpp_msg_cfg_msg)
-
-#define AUDPP_MSG_ENA_ENA	0xFFFF
-#define AUDPP_MSG_ENA_DIS	0x0000
-
-struct audpp_msg_cfg_msg {
-	/*   Enabled  - 0xffff
-	**  Disabled - 0
-	*/
-	unsigned short enabled;
-} __attribute__((packed));
-
-/*
- * MSG to communicate the reverb  per object volume
- */
-
-#define AUDPP_MSG_QREVERB_VOLUME	0x0008
-#define AUDPP_MSG_QREVERB_VOLUME_LEN	\
-	sizeof(struct audpp_msg_qreverb_volume)
-
-
-struct audpp_msg_qreverb_volume {
-	unsigned short	obj_0_gain;
-	unsigned short	obj_1_gain;
-	unsigned short	obj_2_gain;
-	unsigned short	obj_3_gain;
-	unsigned short	obj_4_gain;
-	unsigned short	hpcm_obj_volume;
-} __attribute__((packed));
-
-#define AUDPP_MSG_ROUTING_ACK 0x0009
-#define AUDPP_MSG_ROUTING_ACK_LEN \
-	sizeof(struct audpp_msg_routing_ack)
-
-struct audpp_msg_routing_ack {
-	unsigned short dec_id;
-	unsigned short routing_mode;
-} __attribute__((packed));
-
-#define AUDPP_MSG_FLUSH_ACK 0x000A
-
-#endif /* QDSP5AUDPPMSG_H */
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audpreproccmdi.h b/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audpreproccmdi.h
deleted file mode 100644
index 3d5cf84..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audpreproccmdi.h
+++ /dev/null
@@ -1,519 +0,0 @@
-/* Copyright (c) 2009-2011, The Linux Foundation. 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.
- *
- */
-
-#ifndef QDSP5AUDPREPROCCMDI_H
-#define QDSP5AUDPREPROCCMDI_H
-
-/*
- * AUDIOPREPROC COMMANDS:
- * ARM uses uPAudPreProcAudRecCmdQueue to communicate with AUDPREPROCTASK
- * Location : MEMB
- * Buffer size : 7
- * Number of buffers in a queue : 4
- */
-
-/*
- * Command to enable or disable particular encoder for new interface
- */
-
-#define AUDPREPROC_AUDREC_CMD_ENC_CFG		0x0000
-#define	AUDPREPROC_AUDREC_CMD_ENC_CFG_LEN	\
-	sizeof(struct audpreproc_audrec_cmd_enc_cfg)
-#define AUDREC_TASK_0	0x00 /* SBC / PCM */
-#define AUDREC_TASK_1	0x01 /* AAC / PCM / VOICE ENC */
-
-#define ENCODE_ENABLE	0x8000
-
-/* encoder type supported */
-#define ENC_TYPE_WAV	0x00
-#define ENC_TYPE_AAC	0x01
-#define ENC_TYPE_SBC	0x02
-#define ENC_TYPE_AMRNB	0x03
-#define ENC_TYPE_EVRC	0x04
-#define ENC_TYPE_V13K	0x05
-#define ENC_TYPE_EXT_WAV   0x0F /* to dynamically configure frame size */
-
-/* structure definitions according to
- * command description of ARM-DSP interface specifications
- */
-struct audpreproc_audrec_cmd_enc_cfg {
-	unsigned short	cmd_id;
-	unsigned short  stream_id;
-	unsigned short  audrec_enc_type;
-} __attribute__((packed));
-
-/*
- * Command to configure parameters of selected Encoder
- */
-
-#define AUDPREPROC_AUDREC_CMD_PARAM_CFG	0x0001
-
-#define AUDPREPROC_AUDREC_CMD_PARAM_CFG_COMMON_LEN		\
-	sizeof(struct audpreproc_audrec_cmd_param_cfg_common)
-
-#define DUAL_MIC_STEREO_RECORDING      2
-
-struct audpreproc_audrec_cmd_param_cfg_common {
-	unsigned short cmd_id;
-	unsigned short stream_id;
-} __attribute__((packed));
-
-/*
- * Command Structure to configure WAV Encoder
- */
-
-#define AUDPREPROC_AUDREC_CMD_PARAM_CFG_WAV_LEN		\
-	sizeof(struct audpreproc_audrec_cmd_parm_cfg_wav)
-
-#define AUDREC_CMD_MODE_MONO 0
-#define AUDREC_CMD_MODE_STEREO 1
-
-struct audpreproc_audrec_cmd_parm_cfg_wav {
-	struct audpreproc_audrec_cmd_param_cfg_common common;
-	unsigned short aud_rec_samplerate_idx;
-	unsigned short aud_rec_stereo_mode;
-	unsigned short aud_rec_frame_size;
-} __attribute__((packed));
-
-/*
- * Command Structure to configure AAC Encoder
- */
-
-#define AUDPREPROC_AUDREC_CMD_PARAM_CFG_AAC_LEN		\
-	sizeof(struct audpreproc_audrec_cmd_parm_cfg_aac)
-
-struct audpreproc_audrec_cmd_parm_cfg_aac {
-	struct audpreproc_audrec_cmd_param_cfg_common common;
-	unsigned short aud_rec_samplerate_idx;
-	unsigned short aud_rec_stereo_mode;
-	signed short   recording_quality;
-} __attribute__((packed));
-
-/*
- * Command Structure to configure SBC Encoder
- */
-
-#define AUDPREPROC_AUDREC_CMD_PARAM_CFG_SBC_LEN		\
-	sizeof(struct audpreproc_audrec_cmd_parm_cfg_sbc)
-
-/* encoder parameters mask definitions*/
-
-#define AUDREC_SBC_ENC_PARAM_VER_MASK				0x000A
-#define AUDREC_SBC_ENC_PARAM_ENAHANCED_SBC_BASELINE_VERSION	0x0000
-#define AUDREC_SBC_ENC_PARAM_ENAHANCED_SBC_NA_MASK		0x0400
-#define AUDREC_SBC_ENC_PARAM_BIT_ALLOC_MASK			0x0008
-#define AUDREC_SBC_ENC_PARAM_SNR_MASK				0x0100
-#define AUDREC_SBC_ENC_PARAM_MODE_MASK				0x0006
-#define AUDREC_SBC_ENC_PARAM_MODE_DUAL_MASK			0x0040
-#define AUDREC_SBC_ENC_PARAM_MODE_STEREO_MASK			0x0080
-#define AUDREC_SBC_ENC_PARAM_MODE_JOINT_STEREO_MASK		0x00C0
-#define AUDREC_SBC_ENC_PARAM_NUM_SUB_BANDS_MASK 		0x0004
-#define AUDREC_SBC_ENC_PARAM_NUM_SUB_BANDS_8_MASK		0x0001
-#define AUDREC_SBC_ENC_PARAM_NUM_SUB_BLOCKS_MASK		0x0000
-#define AUDREC_SBC_ENC_PARAM_NUM_SUB_BLOCKS_4_MASK		0x0000
-#define AUDREC_SBC_ENC_PARAM_NUM_SUB_BLOCKS_8_MASK		0x0001
-#define AUDREC_SBC_ENC_PARAM_NUM_SUB_BLOCKS_12_MASK		0x0002
-#define AUDREC_SBC_ENC_PARAM_NUM_SUB_BLOCKS_16_MASK		0x0003
-
-struct audpreproc_audrec_cmd_parm_cfg_sbc {
-	struct audpreproc_audrec_cmd_param_cfg_common common;
-	unsigned short aud_rec_sbc_enc_param;
-	unsigned short aud_rec_sbc_bit_rate_msw;
-	unsigned short aud_rec_sbc_bit_rate_lsw;
-} __attribute__((packed));
-
-/*
- * Command Structure to configure AMRNB Encoder
- */
-
-#define AUDPREPROC_AUDREC_CMD_PARAM_CFG_AMRNB_LEN		\
-	sizeof(struct audpreproc_audrec_cmd_parm_cfg_amrnb)
-
-#define AMRNB_DTX_MODE_ENABLE		-1
-#define AMRNB_DTX_MODE_DISABLE		 0
-
-#define AMRNB_TEST_MODE_ENABLE		-1
-#define AMRNB_TEST_MODE_DISABLE		 0
-
-#define AMRNB_USED_MODE_MR475		0x0
-#define AMRNB_USED_MODE_MR515		0x1
-#define AMRNB_USED_MODE_MR59		0x2
-#define AMRNB_USED_MODE_MR67		0x3
-#define AMRNB_USED_MODE_MR74		0x4
-#define AMRNB_USED_MODE_MR795		0x5
-#define AMRNB_USED_MODE_MR102		0x6
-#define AMRNB_USED_MODE_MR122		0x7
-
-struct audpreproc_audrec_cmd_parm_cfg_amrnb {
-	struct audpreproc_audrec_cmd_param_cfg_common common;
-	signed short dtx_mode;
-	signed short test_mode;
-	unsigned short used_mode;
-} __attribute__((packed)) ;
-
-/*
- * Command Structure to configure EVRC Encoder
- */
-
-#define AUDPREPROC_AUDREC_CMD_PARAM_CFG_EVRC_LEN		\
-	sizeof(struct audpreproc_audrec_cmd_parm_cfg_evrc)
-
-struct audpreproc_audrec_cmd_parm_cfg_evrc {
-	struct audpreproc_audrec_cmd_param_cfg_common common;
-	unsigned short enc_min_rate;
-	unsigned short enc_max_rate;
-	unsigned short rate_modulation_cmd;
-} __attribute__((packed));
-
-/*
- * Command Structure to configure QCELP_13K Encoder
- */
-
-#define AUDPREPROC_AUDREC_CMD_PARAM_CFG_QCELP13K_LEN		\
-	sizeof(struct audpreproc_audrec_cmd_parm_cfg_qcelp13k)
-
-struct audpreproc_audrec_cmd_parm_cfg_qcelp13k {
-	struct audpreproc_audrec_cmd_param_cfg_common common;
-	unsigned short enc_min_rate;
-	unsigned short enc_max_rate;
-	unsigned short rate_modulation_cmd;
-	unsigned short reduced_rate_level;
-} __attribute__((packed));
-
-/*
- * Command to configure AFE for recording paths
- */
-#define AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG 0x0002
-
-#define AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG_LEN		\
-	sizeof(struct audpreproc_afe_cmd_audio_record_cfg)
-
-#define AUDIO_RECORDING_TURN_ON		0xFFFF
-#define AUDIO_RECORDING_TURN_OFF	0x0000
-
-#define AUDPP_A2DP_PIPE_SOURCE_MIX_MASK		0x0020
-#define VOICE_DL_SOURCE_MIX_MASK		0x0010
-#define VOICE_UL_SOURCE_MIX_MASK		0x0008
-#define FM_SOURCE_MIX_MASK			0x0004
-#define AUX_CODEC_TX_SOURCE_MIX_MASK		0x0002
-#define INTERNAL_CODEC_TX_SOURCE_MIX_MASK	0x0001
-
-struct audpreproc_afe_cmd_audio_record_cfg {
-	unsigned short cmd_id;
-	unsigned short stream_id;
-	unsigned short destination_activity;
-	unsigned short source_mix_mask;
-	unsigned short pipe_id;
-	unsigned short reserved;
-} __attribute__((packed));
-
-/*
- * Command to configure Tunnel(RT) or Non-Tunnel(FTRT) mode
- */
-#define AUDPREPROC_AUDREC_CMD_ROUTING_MODE 0x0003
-#define	AUDPREPROC_AUDREC_CMD_ROUTING_MODE_LEN	\
-	sizeof(struct audpreproc_audrec_cmd_routing_mode)
-
-#define AUDIO_ROUTING_MODE_FTRT		0x0001
-#define AUDIO_ROUTING_MODE_RT		0x0002
-
-struct audpreproc_audrec_cmd_routing_mode {
-	unsigned short cmd_id;
-	unsigned short stream_id;
-	unsigned short routing_mode;
-} __attribute__((packed));
-
-/*
- * Command to configure DSP for topology where resampler moved
- * in front of pre processing chain
- */
-#define AUDPREPROC_AUDREC_CMD_ENC_CFG_2		0x0004
-#define	AUDPREPROC_AUDREC_CMD_ENC_CFG_2_LEN	\
-	sizeof(struct audpreproc_audrec_cmd_enc_cfg_2)
-
-
-struct audpreproc_audrec_cmd_enc_cfg_2 {
-	unsigned short	cmd_id;
-	unsigned short  stream_id;
-	unsigned short  audrec_enc_type;
-} __attribute__((packed));
-
-/*
- * AUDIOPREPROC COMMANDS:
- * ARM uses uPAudPreProcCmdQueue to communicate with AUDPREPROCTASK
- * Location : MEMB
- * Buffer size : 52
- * Number of buffers in a queue : 3
- */
-
-/*
- * Command to configure the parameters of AGC
- */
-
-#define	AUDPREPROC_CMD_CFG_AGC_PARAMS	0x0000
-#define	AUDPREPROC_CMD_CFG_AGC_PARAMS_LEN	\
-	sizeof(struct audpreproc_cmd_cfg_agc_params)
-
-#define	AUDPREPROC_CMD_TX_AGC_PARAM_MASK_COMP_SLOPE	0x0200
-#define	AUDPREPROC_CMD_TX_AGC_PARAM_MASK_COMP_TH	0x0400
-#define	AUDPREPROC_CMD_TX_AGC_PARAM_MASK_EXP_SLOPE	0x0800
-#define	AUDPREPROC_CMD_TX_AGC_PARAM_MASK_EXP_TH		0x1000
-#define	AUDPREPROC_CMD_TX_AGC_PARAM_MASK_COMP_AIG_FLAG		0x2000
-#define	AUDPREPROC_CMD_TX_AGC_PARAM_MASK_COMP_STATIC_GAIN	0x4000
-#define	AUDPREPROC_CMD_TX_AGC_PARAM_MASK_TX_AGC_ENA_FLAG	0x8000
-
-#define	AUDPREPROC_CMD_TX_AGC_ENA_FLAG_ENA	-1
-#define	AUDPREPROC_CMD_TX_AGC_ENA_FLAG_DIS	0x0000
-
-#define	AUDPREPROC_CMD_ADP_GAIN_FLAG_ENA_ADP_GAIN	-1
-#define	AUDPREPROC_CMD_ADP_GAIN_FLAG_ENA_STATIC_GAIN	0x0000
-
-#define	AUDPREPROC_CMD_PARAM_MASK_RMS_TAY	0x0010
-#define	AUDPREPROC_CMD_PARAM_MASK_RELEASEK	0x0020
-#define	AUDPREPROC_CMD_PARAM_MASK_DELAY		0x0040
-#define	AUDPREPROC_CMD_PARAM_MASK_ATTACKK	0x0080
-#define	AUDPREPROC_CMD_PARAM_MASK_LEAKRATE_SLOW	0x0100
-#define	AUDPREPROC_CMD_PARAM_MASK_LEAKRATE_FAST	0x0200
-#define	AUDPREPROC_CMD_PARAM_MASK_AIG_RELEASEK 	0x0400
-#define	AUDPREPROC_CMD_PARAM_MASK_AIG_MIN	0x0800
-#define	AUDPREPROC_CMD_PARAM_MASK_AIG_MAX	0x1000
-#define	AUDPREPROC_CMD_PARAM_MASK_LEAK_UP	0x2000
-#define	AUDPREPROC_CMD_PARAM_MASK_LEAK_DOWN	0x4000
-#define	AUDPREPROC_CMD_PARAM_MASK_AIG_ATTACKK	0x8000
-
-struct audpreproc_cmd_cfg_agc_params {
-	unsigned short	cmd_id;
-	unsigned short 	stream_id;
-	unsigned short	tx_agc_param_mask;
-	signed short	tx_agc_enable_flag;
-	unsigned short	comp_rlink_static_gain;
-	signed short	comp_rlink_aig_flag;
-	unsigned short	expander_rlink_th;
-	unsigned short	expander_rlink_slope;
-	unsigned short	compressor_rlink_th;
-	unsigned short	compressor_rlink_slope;
-	unsigned short	tx_adc_agc_param_mask;
-	unsigned short	comp_rlink_aig_attackk;
-	unsigned short	comp_rlink_aig_leak_down;
-	unsigned short	comp_rlink_aig_leak_up;
-	unsigned short	comp_rlink_aig_max;
-	unsigned short	comp_rlink_aig_min;
-	unsigned short	comp_rlink_aig_releasek;
-	unsigned short	comp_rlink_aig_leakrate_fast;
-	unsigned short	comp_rlink_aig_leakrate_slow;
-	unsigned short	comp_rlink_attackk_msw;
-	unsigned short	comp_rlink_attackk_lsw;
-	unsigned short	comp_rlink_delay;
-	unsigned short	comp_rlink_releasek_msw;
-	unsigned short	comp_rlink_releasek_lsw;
-	unsigned short	comp_rlink_rms_tav;
-} __attribute__((packed));
-
-/*
- * Command to configure the params of Advanved AGC
- */
-
-#define	AUDPREPROC_CMD_CFG_AGC_PARAMS_2		0x0001
-#define	AUDPREPROC_CMD_CFG_AGC_PARAMS_2_LEN		\
-	sizeof(struct audpreproc_cmd_cfg_agc_params_2)
-
-#define	AUDPREPROC_CMD_2_TX_AGC_ENA_FLAG_ENA	-1;
-#define	AUDPREPROC_CMD_2_TX_AGC_ENA_FLAG_DIS	0x0000;
-
-struct audpreproc_cmd_cfg_agc_params_2 {
-	unsigned short	cmd_id;
-	unsigned short 	stream_id;
-	unsigned short	agc_param_mask;
-	signed short	tx_agc_enable_flag;
-	unsigned short	comp_rlink_static_gain;
-	unsigned short	exp_rlink_th;
-	unsigned short	exp_rlink_slope;
-	unsigned short	comp_rlink_th;
-	unsigned short	comp_rlink_slope;
-	unsigned short	comp_rlink_rms_tav;
-	unsigned short	comp_rlink_down_samp_mask;
-	unsigned short	comp_rlink_attackk_msw;
-	unsigned short	comp_rlink_attackk_lsw;
-	unsigned short	comp_rlink_releasek_msw;
-	unsigned short	comp_rlink_releasek_lsw;
-	unsigned short	comp_rlink_delay;
-	unsigned short	comp_rlink_makeup_gain;
-} __attribute__((packed));
-
-/*
- * Command to configure params for ns
- */
-
-#define	AUDPREPROC_CMD_CFG_NS_PARAMS		0x0002
-#define	AUDPREPROC_CMD_CFG_NS_PARAMS_LEN	\
-	sizeof(struct audpreproc_cmd_cfg_ns_params)
-
-#define	AUDPREPROC_CMD_EC_MODE_NLMS_ENA	0x0001
-#define	AUDPREPROC_CMD_EC_MODE_NLMS_DIS 	0x0000
-#define	AUDPREPROC_CMD_EC_MODE_DES_ENA	0x0002
-#define	AUDPREPROC_CMD_EC_MODE_DES_DIS	0x0000
-#define	AUDPREPROC_CMD_EC_MODE_NS_ENA	0x0004
-#define	AUDPREPROC_CMD_EC_MODE_NS_DIS	0x0000
-#define	AUDPREPROC_CMD_EC_MODE_CNI_ENA	0x0008
-#define	AUDPREPROC_CMD_EC_MODE_CNI_DIS	0x0000
-
-#define	AUDPREPROC_CMD_EC_MODE_NLES_ENA	0x0010
-#define	AUDPREPROC_CMD_EC_MODE_NLES_DIS	0x0000
-#define	AUDPREPROC_CMD_EC_MODE_HB_ENA	0x0020
-#define	AUDPREPROC_CMD_EC_MODE_HB_DIS	0x0000
-#define	AUDPREPROC_CMD_EC_MODE_VA_ENA	0x0040
-#define	AUDPREPROC_CMD_EC_MODE_VA_DIS	0x0000
-#define	AUDPREPROC_CMD_EC_MODE_PCD_ENA	0x0080
-#define	AUDPREPROC_CMD_EC_MODE_PCD_DIS	0x0000
-#define	AUDPREPROC_CMD_EC_MODE_FEHI_ENA	0x0100
-#define	AUDPREPROC_CMD_EC_MODE_FEHI_DIS 	0x0000
-#define	AUDPREPROC_CMD_EC_MODE_NEHI_ENA	0x0200
-#define	AUDPREPROC_CMD_EC_MODE_NEHI_DIS 	0x0000
-#define	AUDPREPROC_CMD_EC_MODE_NLPP_ENA	0x0400
-#define	AUDPREPROC_CMD_EC_MODE_NLPP_DIS	0x0000
-#define	AUDPREPROC_CMD_EC_MODE_FNE_ENA	0x0800
-#define	AUDPREPROC_CMD_EC_MODE_FNE_DIS	0x0000
-#define	AUDPREPROC_CMD_EC_MODE_PRENLMS_ENA 	0x1000
-#define	AUDPREPROC_CMD_EC_MODE_PRENLMS_DIS 	0x0000
-
-struct audpreproc_cmd_cfg_ns_params {
-	unsigned short	cmd_id;
-	unsigned short  stream_id;
-	unsigned short	ec_mode_new;
-	unsigned short	dens_gamma_n;
-	unsigned short	dens_nfe_block_size;
-	unsigned short	dens_limit_ns;
-	unsigned short	dens_limit_ns_d;
-	unsigned short	wb_gamma_e;
-	unsigned short	wb_gamma_n;
-} __attribute__((packed));
-
-/*
- * Command to configure parameters for IIR tuning filter
- */
-
-#define	AUDPREPROC_CMD_CFG_IIR_TUNING_FILTER_PARAMS		0x0003
-#define	AUDPREPROC_CMD_CFG_IIR_TUNING_FILTER_PARAMS_LEN	\
-	sizeof(struct audpreproc_cmd_cfg_iir_tuning_filter_params)
-
-#define	AUDPREPROC_CMD_IIR_ACTIVE_FLAG_DIS	0x0000
-#define	AUDPREPROC_CMD_IIR_ACTIVE_FLAG_ENA	0x0001
-
-struct audpreproc_cmd_cfg_iir_tuning_filter_params {
-	unsigned short	cmd_id;
-	unsigned short  stream_id;
-	unsigned short	active_flag;
-	unsigned short	num_bands;
-
-	unsigned short	numerator_coeff_b0_filter0_lsw;
-	unsigned short	numerator_coeff_b0_filter0_msw;
-	unsigned short	numerator_coeff_b1_filter0_lsw;
-	unsigned short	numerator_coeff_b1_filter0_msw;
-	unsigned short	numerator_coeff_b2_filter0_lsw;
-	unsigned short	numerator_coeff_b2_filter0_msw;
-
-	unsigned short	numerator_coeff_b0_filter1_lsw;
-	unsigned short	numerator_coeff_b0_filter1_msw;
-	unsigned short	numerator_coeff_b1_filter1_lsw;
-	unsigned short	numerator_coeff_b1_filter1_msw;
-	unsigned short	numerator_coeff_b2_filter1_lsw;
-	unsigned short	numerator_coeff_b2_filter1_msw;
-
-	unsigned short	numerator_coeff_b0_filter2_lsw;
-	unsigned short	numerator_coeff_b0_filter2_msw;
-	unsigned short	numerator_coeff_b1_filter2_lsw;
-	unsigned short	numerator_coeff_b1_filter2_msw;
-	unsigned short	numerator_coeff_b2_filter2_lsw;
-	unsigned short	numerator_coeff_b2_filter2_msw;
-
-	unsigned short	numerator_coeff_b0_filter3_lsw;
-	unsigned short	numerator_coeff_b0_filter3_msw;
-	unsigned short	numerator_coeff_b1_filter3_lsw;
-	unsigned short	numerator_coeff_b1_filter3_msw;
-	unsigned short	numerator_coeff_b2_filter3_lsw;
-	unsigned short	numerator_coeff_b2_filter3_msw;
-
-	unsigned short 	denominator_coeff_a0_filter0_lsw;
-	unsigned short 	denominator_coeff_a0_filter0_msw;
-	unsigned short 	denominator_coeff_a1_filter0_lsw;
-	unsigned short 	denominator_coeff_a1_filter0_msw;
-
-	unsigned short 	denominator_coeff_a0_filter1_lsw;
-	unsigned short 	denominator_coeff_a0_filter1_msw;
-	unsigned short 	denominator_coeff_a1_filter1_lsw;
-	unsigned short 	denominator_coeff_a1_filter1_msw;
-
-	unsigned short	denominator_coeff_a0_filter2_lsw;
-	unsigned short	denominator_coeff_a0_filter2_msw;
-	unsigned short	denominator_coeff_a1_filter2_lsw;
-	unsigned short	denominator_coeff_a1_filter2_msw;
-
-	unsigned short	denominator_coeff_a0_filter3_lsw;
-	unsigned short	denominator_coeff_a0_filter3_msw;
-	unsigned short 	denominator_coeff_a1_filter3_lsw;
-	unsigned short 	denominator_coeff_a1_filter3_msw;
-
-	unsigned short	shift_factor_filter0;
-	unsigned short	shift_factor_filter1;
-	unsigned short	shift_factor_filter2;
-	unsigned short	shift_factor_filter3;
-
-	unsigned short	pan_of_filter0;
-	unsigned short	pan_of_filter1;
-	unsigned short	pan_of_filter2;
-	unsigned short	pan_of_filter3;
-} __attribute__((packed));
-
-/*
- * Command to configure parameters for calibration gain rx
- */
-
-#define AUDPREPROC_CMD_CFG_CAL_GAIN_PARAMS 0x0004
-#define AUDPREPROC_CMD_CFG_CAL_GAIN_LEN    \
-	sizeof(struct audpreproc_cmd_cfg_cal_gain)
-
-struct audpreproc_cmd_cfg_cal_gain {
-	unsigned short  cmd_id;
-	unsigned short  stream_id;
-	unsigned short  audprecalgain;
-	unsigned short  reserved;
-}  __attribute__((packed));
-
-#define AUDPREPROC_CMD_CFG_LVNV_PARMS	0x0006
-#define AUDPREPROC_CMD_CFG_LVNV_PARMS_LEN	\
-		sizeof(struct audpreproc_cmd_cfg_lvnv_param)
-
-struct audpreproc_cmd_cfg_lvnv_param {
-	unsigned short cmd_id;
-	unsigned short stream_id;
-	unsigned short cs_mode;
-	unsigned short lvnv_ext_buf_size;
-	unsigned short lvnv_ext_partition;
-	unsigned short lvnv_ext_buf_start_lsw;
-	unsigned short lvnv_ext_buf_start_msw;
-};
-
-#define AUDPREPROC_CMD_FEAT_QUERY_PARAMS 0x0005
-
-struct rtc_audpreproc_read_data {
-	unsigned short	cmd_id;
-	unsigned short	stream_id;
-	unsigned short  feature_id;
-	unsigned short  extbufsizemsw;
-	unsigned short  extbufsizelsw;
-	unsigned short  extpart;
-	unsigned short  extbufstartmsw;
-	unsigned short	extbufstartlsw;
-} __attribute__((packed)) ;
-
-#endif /* QDSP5AUDPREPROCCMDI_H */
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audpreprocmsg.h b/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audpreprocmsg.h
deleted file mode 100644
index d3efbcd..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audpreprocmsg.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/* Copyright (c) 2009-2010, The Linux Foundation. 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.
- *
- */
-
-#ifndef QDSP5AUDPREPROCMSG_H
-#define QDSP5AUDPREPROCMSG_H
-
-#define AUDPREPROC_MSG_FEAT_QUERY_DM_DONE 0x0006
-
-/*
- * ADSPREPROCTASK Messages
- * AUDPREPROCTASK uses audPreProcUpRlist to communicate with ARM
- * Location	: MEMB
- * Buffer size :  6
- * No of buffers in queue : 4
- */
-
-/*
- * Message to indicate Pre processing config command is done
- */
-
-#define AUDPREPROC_CMD_CFG_DONE_MSG 0x0001
-#define	AUDPREPROC_CMD_CFG_DONE_MSG_LEN	\
-	sizeof(struct audpreproc_cmd_cfg_done_msg)
-
-#define AUD_PREPROC_TYPE_AGC		0x0
-#define AUD_PREPROC_NOISE_REDUCTION	0x1
-#define AUD_PREPROC_IIR_TUNNING_FILTER	0x2
-
-#define AUD_PREPROC_CONFIG_ENABLED 	-1
-#define AUD_PREPROC_CONFIG_DISABLED	 0
-
-struct audpreproc_cmd_cfg_done_msg {
-	unsigned short stream_id;
-	unsigned short aud_preproc_type;
-	signed short aud_preproc_status_flag;
-} __attribute__((packed));
-
-/*
- * Message to indicate Pre processing error messages
- */
-
-#define AUDPREPROC_ERROR_MSG 0x0002
-#define AUDPREPROC_ERROR_MSG_LEN \
-	sizeof(struct audpreproc_err_msg)
-
-#define AUD_PREPROC_ERR_IDX_WRONG_SAMPLING_FREQUENCY	0x00
-#define AUD_PREPROC_ERR_IDX_ENC_NOT_SUPPORTED		0x01
-
-struct audpreproc_err_msg {
-	unsigned short stream_id;
-	signed short aud_preproc_err_idx;
-} __attribute__((packed));
-
-/*
- * Message to indicate encoder config command
- */
-
-#define AUDPREPROC_CMD_ENC_CFG_DONE_MSG	0x0003
-#define AUDPREPROC_CMD_ENC_CFG_DONE_MSG_LEN \
-	sizeof(struct audpreproc_cmd_enc_cfg_done_msg)
-
-struct audpreproc_cmd_enc_cfg_done_msg {
-	unsigned short stream_id;
-	unsigned short rec_enc_type;
-} __attribute__((packed));
-
-/*
- * Message to indicate encoder param config command
- */
-
-#define AUDPREPROC_CMD_ENC_PARAM_CFG_DONE_MSG	0x0004
-#define AUDPREPROC_CMD_ENC_PARAM_CFG_DONE_MSG_LEN \
-	sizeof(struct audpreproc_cmd_enc_param_cfg_done_msg)
-
-struct audpreproc_cmd_enc_param_cfg_done_msg {
-	unsigned short stream_id;
-} __attribute__((packed));
-
-
-/*
- * Message to indicate AFE config cmd for
- * audio recording is successfully recieved
- */
-
-#define AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG_DONE_MSG  0x0005
-#define AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG_DONE_MSG_LEN \
-	sizeof(struct audpreproc_afe_cmd_audio_record_cfg_done)
-
-struct audpreproc_afe_cmd_audio_record_cfg_done {
-	unsigned short stream_id;
-} __attribute__((packed));
-
-/*
- * Message to indicate Routing mode
- * configuration success or failure
- */
-
-#define AUDPREPROC_CMD_ROUTING_MODE_DONE_MSG  0x0007
-#define AUDPREPROC_CMD_ROUTING_MODE_DONE_MSG_LEN \
-	sizeof(struct audpreproc_cmd_routing_mode_done)
-
-struct audpreproc_cmd_routing_mode_done {
-	unsigned short stream_id;
-	unsigned short configuration;
-} __attribute__((packed));
-
-
-#define AUDPREPROC_CMD_PCM_CFG_ARM_TO_PREPROC_DONE_MSG	0x0008
-#define AUDPREPROC_CMD_PCM_CFG_ARM_TO_PREPROC_DONE_MSG_LEN \
-	sizeof(struct audreproc_cmd_pcm_cfg_arm_to_preproc_done)
-
-struct audreproc_cmd_pcm_cfg_arm_to_preproc_done {
-	unsigned short stream_id;
-	unsigned short configuration;
-} __attribute__((packed));
-
-#endif /* QDSP5AUDPREPROCMSG_H */
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audreccmdi.h b/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audreccmdi.h
deleted file mode 100644
index 49642df..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audreccmdi.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/* Copyright (c) 2009-2011, The Linux Foundation. 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.
- *
- */
-
-#ifndef QDSP5AUDRECCMDI_H
-#define QDSP5AUDRECCMDI_H
-
-/*
- * AUDRECTASK COMMANDS
- * ARM uses 2 queues to communicate with the AUDRECTASK
- * 1.uPAudRec[i]CmdQueue, where i=0,1,2
- * Location :MEMC
- * Buffer Size : 5
- * No of Buffers in a queue : 2
- * 2.uPAudRec[i]BitstreamQueue, where i=0,1,2
- * Location : MEMC
- * Buffer Size : 5
- * No of buffers in a queue : 3
- */
-
-/*
- * Commands on uPAudRec[i]CmdQueue, where i=0,1,2
- */
-
-/*
- * Command to configure memory for enabled encoder
- */
-
-#define AUDREC_CMD_MEM_CFG_CMD 0x0000
-#define AUDREC_CMD_ARECMEM_CFG_LEN	\
-	sizeof(struct audrec_cmd_arecmem_cfg)
-
-struct audrec_cmd_arecmem_cfg {
-	unsigned short cmd_id;
-	unsigned short audrec_up_pkt_intm_count;
-	unsigned short audrec_ext_pkt_start_addr_msw;
-	unsigned short audrec_ext_pkt_start_addr_lsw;
-	unsigned short audrec_ext_pkt_buf_number;
-} __attribute__((packed));
-
-/*
- * Command to configure pcm input memory
- */
-
-#define AUDREC_CMD_PCM_CFG_ARM_TO_ENC 0x0001
-#define AUDREC_CMD_PCM_CFG_ARM_TO_ENC_LEN	\
-	sizeof(struct audrec_cmd_pcm_cfg_arm_to_enc)
-
-struct audrec_cmd_pcm_cfg_arm_to_enc {
-	unsigned short cmd_id;
-	unsigned short config_update_flag;
-	unsigned short enable_flag;
-	unsigned short sampling_freq;
-	unsigned short channels;
-	unsigned short frequency_of_intimation;
-	unsigned short max_number_of_buffers;
-} __attribute__((packed));
-
-#define AUDREC_PCM_CONFIG_UPDATE_FLAG_ENABLE -1
-#define AUDREC_PCM_CONFIG_UPDATE_FLAG_DISABLE 0
-
-#define AUDREC_ENABLE_FLAG_VALUE -1
-#define AUDREC_DISABLE_FLAG_VALUE 0
-
-/*
- * Command to intimate available pcm buffer
- */
-
-#define AUDREC_CMD_PCM_BUFFER_PTR_REFRESH_ARM_TO_ENC 0x0002
-#define AUDREC_CMD_PCM_BUFFER_PTR_REFRESH_ARM_TO_ENC_LEN \
-  sizeof(struct audrec_cmd_pcm_buffer_ptr_refresh_arm_enc)
-
-struct audrec_cmd_pcm_buffer_ptr_refresh_arm_enc {
-	unsigned short cmd_id;
-	unsigned short num_buffers;
-	unsigned short buffer_write_cnt_msw;
-	unsigned short buffer_write_cnt_lsw;
-	unsigned short buf_address_length[8];/*this array holds address
-						and length details of
-						two buffers*/
-} __attribute__((packed));
-
-/*
- * Command to flush
- */
-
-#define AUDREC_CMD_FLUSH 0x0003
-#define AUDREC_CMD_FLUSH_LEN	\
-	sizeof(struct audrec_cmd_flush)
-
-struct audrec_cmd_flush {
-	unsigned short cmd_id;
-} __attribute__((packed));
-
-/*
- * Commands on uPAudRec[i]BitstreamQueue, where i=0,1,2
- */
-
-/*
- * Command to indicate current packet read count
- */
-
-#define UP_AUDREC_PACKET_EXT_PTR 0x0000
-#define UP_AUDREC_PACKET_EXT_PTR_LEN	\
-	sizeof(up_audrec_packet_ext_ptr)
-
-struct up_audrec_packet_ext_ptr {
-	unsigned short cmd_id;
-	unsigned short audrec_up_curr_read_count_lsw;
-	unsigned short audrec_up_curr_read_count_msw;
-} __attribute__((packed));
-
-#endif /* QDSP5AUDRECCMDI_H */
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audrecmsg.h b/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audrecmsg.h
deleted file mode 100644
index eb46235..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/qdsp5audrecmsg.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* Copyright (c) 2009-2010, The Linux Foundation. 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.
- *
- */
-
-#ifndef QDSP5AUDRECMSG_H
-#define QDSP5AUDRECMSG_H
-
-/*
- * AUDRECTASK MESSAGES
- * AUDRECTASK uses audRec[i]UpRlist, where i=0,1,2 to communicate with ARM
- * Location : MEMC
- * Buffer size : 5
- * No of buffers in a queue : 10
- */
-
-/*
- * Message to notify 2 error conditions
- */
-
-#define AUDREC_FATAL_ERR_MSG 0x0001
-#define AUDREC_FATAL_ERR_MSG_LEN	\
-	sizeof(struct audrec_fatal_err_msg)
-
-#define AUDREC_FATAL_ERR_MSG_NO_PKT	0x00
-
-struct audrec_fatal_err_msg {
-	unsigned short audrec_err_id;
-} __attribute__((packed));
-
-/*
- * Message to indicate encoded packet is delivered to external buffer
- */
-
-#define AUDREC_UP_PACKET_READY_MSG 0x0002
-#define AUDREC_UP_PACKET_READY_MSG_LEN	\
-	sizeof(struct audrec_up_pkt_ready_msg)
-
-struct  audrec_up_pkt_ready_msg {
-	unsigned short audrec_packet_write_cnt_lsw;
-	unsigned short audrec_packet_write_cnt_msw;
-	unsigned short audrec_up_prev_read_cnt_lsw;
-	unsigned short audrec_up_prev_read_cnt_msw;
-} __attribute__((packed));
-
-/*
- * Message indicates arecmem cfg done
- */
-#define AUDREC_CMD_MEM_CFG_DONE_MSG 0x0003
-
-/* buffer conntents are nill only message id is required */
-
-/*
- * Message to indicate pcm buffer configured
- */
-
-#define AUDREC_CMD_PCM_CFG_ARM_TO_ENC_DONE_MSG 0x0004
-#define AUDREC_CMD_PCM_CFG_ARM_TO_ENC_DONE_MSG_LEN	\
-	sizeof(struct audrec_cmd_pcm_cfg_arm_to_enc_msg)
-
-struct  audrec_cmd_pcm_cfg_arm_to_enc_msg {
-	unsigned short configuration;
-} __attribute__((packed));
-
-/*
- * Message to indicate encoded packet is delivered to external buffer in FTRT
- */
-
-#define AUDREC_UP_NT_PACKET_READY_MSG 0x0005
-#define AUDREC_UP_NT_PACKET_READY_MSG_LEN	\
-	sizeof(struct audrec_up_nt_packet_ready_msg)
-
-struct  audrec_up_nt_packet_ready_msg {
-	unsigned short audrec_packetwrite_cnt_lsw;
-	unsigned short audrec_packetwrite_cnt_msw;
-	unsigned short audrec_upprev_readcount_lsw;
-	unsigned short audrec_upprev_readcount_msw;
-} __attribute__((packed));
-
-/*
- * Message to indicate pcm buffer is consumed
- */
-
-#define AUDREC_CMD_PCM_BUFFER_PTR_UPDATE_ARM_TO_ENC_MSG 0x0006
-#define AUDREC_CMD_PCM_BUFFER_PTR_UPDATE_ARM_TO_ENC_MSG_LEN	\
-	sizeof(struct audrec_cmd_pcm_buffer_ptr_update_arm_to_enc_msg)
-
-struct  audrec_cmd_pcm_buffer_ptr_update_arm_to_enc_msg {
-	unsigned short buffer_readcnt_msw;
-	unsigned short buffer_readcnt_lsw;
-	unsigned short number_of_buffers;
-	unsigned short buffer_address_length[];
-} __attribute__((packed));
-
-/*
- * Message to indicate flush acknowledgement
- */
-
-#define AUDREC_CMD_FLUSH_DONE_MSG 0x0007
-
-/*
- * Message to indicate End of Stream acknowledgement
- */
-
-#define AUDREC_CMD_EOS_ACK_MSG 0x0008
-
-#endif /* QDSP5AUDRECMSG_H */
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/snddev_ecodec.h b/arch/arm/mach-msm/include/mach/qdsp5v2/snddev_ecodec.h
deleted file mode 100644
index 8e7d96c..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/snddev_ecodec.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-#ifndef __MACH_QDSP5_V2_SNDDEV_ECODEC_H
-#define __MACH_QDSP5_V2_SNDDEV_ECODEC_H
-#include <mach/qdsp5v2/audio_def.h>
-
-struct snddev_ecodec_data {
-	u32 capability; /* RX or TX */
-	const char *name;
-	u32 copp_id; /* audpp routing */
-	u32 acdb_id; /* Audio Cal purpose */
-	u8 channel_mode;
-	u32 conf_pcm_ctl_val;
-	u32 conf_aux_codec_intf;
-	u32 conf_data_format_padding_val;
-	s32 max_voice_rx_vol[VOC_RX_VOL_ARRAY_NUM]; /* [0]:NB, [1]:WB */
-	s32 min_voice_rx_vol[VOC_RX_VOL_ARRAY_NUM];
-};
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/snddev_icodec.h b/arch/arm/mach-msm/include/mach/qdsp5v2/snddev_icodec.h
deleted file mode 100644
index 7a811a0..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/snddev_icodec.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Copyright (c) 2009-2011, The Linux Foundation. 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.
- *
- */
-#ifndef __MACH_QDSP5_V2_SNDDEV_ICODEC_H
-#define __MACH_QDSP5_V2_SNDDEV_ICODEC_H
-#include <linux/mfd/msm-adie-codec.h>
-#include <mach/qdsp5v2/audio_def.h>
-#include <mach/pmic.h>
-
-struct snddev_icodec_data {
-	u32 capability; /* RX or TX */
-	const char *name;
-	u32 copp_id; /* audpp routing */
-	u32 acdb_id; /* Audio Cal purpose */
-	/* Adie profile */
-	struct adie_codec_dev_profile *profile;
-	/* Afe setting */
-	u8 channel_mode;
-	enum hsed_controller *pmctl_id; /* tx only enable mic bias */
-	u32 pmctl_id_sz;
-	u32 default_sample_rate;
-	void (*pamp_on) (void);
-	void (*pamp_off) (void);
-	void (*voltage_on) (void);
-	void (*voltage_off) (void);
-	s32 max_voice_rx_vol[VOC_RX_VOL_ARRAY_NUM]; /* [0]: NB,[1]: WB */
-	s32 min_voice_rx_vol[VOC_RX_VOL_ARRAY_NUM];
-	u32 dev_vol_type;
-	u32 property; /*variable used to hold the properties
-				internal to the device*/
-};
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/snddev_mi2s.h b/arch/arm/mach-msm/include/mach/qdsp5v2/snddev_mi2s.h
deleted file mode 100644
index a8f5234..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/snddev_mi2s.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Copyright (c) 2010, The Linux Foundation. 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.
- *
- */
-#ifndef __MACH_QDSP5_V2_SNDDEV_MI2S_H
-#define __MACH_QDSP5_V2_SNDDEV_MI2S_H
-
-struct snddev_mi2s_data {
-	u32 capability; /* RX or TX */
-	const char *name;
-	u32 copp_id; /* audpp routing */
-	u32 acdb_id; /* Audio Cal purpose */
-	u8 channel_mode;
-	u8 sd_lines;
-	void (*route) (void);
-	void (*deroute) (void);
-	u32 default_sample_rate;
-};
-
-int mi2s_config_clk_gpio(void);
-
-int mi2s_config_data_gpio(u32 direction, u8 sd_line_mask);
-
-int mi2s_unconfig_clk_gpio(void);
-
-int mi2s_unconfig_data_gpio(u32 direction, u8 sd_line_mask);
-
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/snddev_virtual.h b/arch/arm/mach-msm/include/mach/qdsp5v2/snddev_virtual.h
deleted file mode 100644
index 639e981..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/snddev_virtual.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright (c) 2010, The Linux Foundation. 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.
- *
- */
-#ifndef __MACH_QDSP5_V2_SNDDEV_VIRTUAL_H
-#define __MACH_QDSP5_V2_SNDDEV_VIRTUAL_H
-#include <mach/qdsp5v2/audio_def.h>
-
-struct snddev_virtual_data {
-	u32 capability; /* RX or TX */
-	const char *name;
-	u32 copp_id; /* audpp routing */
-	u32 acdb_id; /* Audio Cal purpose */
-};
-#endif
diff --git a/arch/arm/mach-msm/include/mach/qdsp5v2/voice.h b/arch/arm/mach-msm/include/mach/qdsp5v2/voice.h
deleted file mode 100644
index 93f9bad..0000000
--- a/arch/arm/mach-msm/include/mach/qdsp5v2/voice.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/* Copyright (c) 2009-2010, The Linux Foundation. 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.
- *
- */
-#ifndef _MACH_QDSP5_V2_VOICE_H
-#define _MACH_QDSP5_V2_VOICE_H
-
-#define VOICE_DALRPC_DEVICEID 0x02000075
-#define VOICE_DALRPC_PORT_NAME "DAL00"
-#define VOICE_DALRPC_CPU 0
-
-
-/* Commands sent to Modem */
-#define CMD_VOICE_INIT                  0x1
-#define CMD_ACQUIRE_DONE                0x2
-#define CMD_RELEASE_DONE                0x3
-#define CMD_DEVICE_INFO                 0x4
-#define CMD_DEVICE_CHANGE               0x6
-
-/* EVENTS received from MODEM */
-#define EVENT_ACQUIRE_START             0x51
-#define EVENT_RELEASE_START             0x52
-#define EVENT_CHANGE_START              0x54
-#define EVENT_NETWORK_RECONFIG          0x53
-
-/* voice state */
-enum {
-	VOICE_INIT = 0,
-	VOICE_ACQUIRE,
-	VOICE_CHANGE,
-	VOICE_RELEASE,
-};
-
-enum {
-	NETWORK_CDMA = 0,
-	NETWORK_GSM,
-	NETWORK_WCDMA,
-	NETWORK_WCDMA_WB,
-};
-
-enum {
-	VOICE_DALRPC_CMD = DALDEVICE_FIRST_DEVICE_API_IDX
-};
-
-/* device state */
-enum {
-	DEV_INIT = 0,
-	DEV_READY,
-	DEV_CHANGE,
-	DEV_CONCUR,
-	DEV_REL_DONE,
-};
-
-/* Voice Event */
-enum{
-	VOICE_RELEASE_START = 1,
-	VOICE_CHANGE_START,
-	VOICE_ACQUIRE_START,
-	VOICE_NETWORK_RECONFIG,
-};
-
-/* Device Event */
-#define DEV_CHANGE_READY                0x1
-
-#define VOICE_CALL_START	0x1
-#define VOICE_CALL_END		0
-
-#define VOICE_DEV_ENABLED	0x1
-#define VOICE_DEV_DISABLED	0
-
-struct voice_header {
-	uint32_t id;
-	uint32_t data_len;
-};
-
-struct voice_init {
-	struct voice_header hdr;
-	void *cb_handle;
-};
-
-
-/* Device information payload structure */
-struct voice_device {
-	struct voice_header hdr;
-	uint32_t rx_device;
-	uint32_t tx_device;
-	uint32_t rx_volume;
-	uint32_t rx_mute;
-	uint32_t tx_mute;
-	uint32_t rx_sample;
-	uint32_t tx_sample;
-};
-
-/*Voice command structure*/
-struct voice_network {
-	struct voice_header hdr;
-	uint32_t network_info;
-};
-
-struct device_data {
-	uint32_t dev_acdb_id;
-	uint32_t volume; /* in percentage */
-	uint32_t mute;
-	uint32_t sample;
-	uint32_t enabled;
-	uint32_t dev_id;
-};
-
-#endif
diff --git a/arch/arm/mach-msm/iommu_domains.c b/arch/arm/mach-msm/iommu_domains.c
index 20a5249..1d5e0d9 100644
--- a/arch/arm/mach-msm/iommu_domains.c
+++ b/arch/arm/mach-msm/iommu_domains.c
@@ -553,7 +553,8 @@
 	ida_simple_remove(&domain_nums, data->domain_num);
 
 	for (i = 0; i < data->npools; ++i)
-		gen_pool_destroy(data->pools[i].gpool);
+		if (data->pools[i].gpool)
+			gen_pool_destroy(data->pools[i].gpool);
 
 	kfree(data->pools);
 	kfree(data);
diff --git a/arch/arm/mach-msm/ipc_socket.c b/arch/arm/mach-msm/ipc_socket.c
index bdda546..5aa6c93 100644
--- a/arch/arm/mach-msm/ipc_socket.c
+++ b/arch/arm/mach-msm/ipc_socket.c
@@ -589,17 +589,24 @@
 };
 
 static const struct proto_ops msm_ipc_proto_ops = {
-	.owner		= THIS_MODULE,
 	.family         = AF_MSM_IPC,
+	.owner		= THIS_MODULE,
+	.release        = msm_ipc_router_close,
 	.bind		= msm_ipc_router_bind,
 	.connect	= sock_no_connect,
+	.socketpair	= sock_no_socketpair,
+	.accept		= sock_no_accept,
+	.getname	= sock_no_getname,
+	.poll           = msm_ipc_router_poll,
+	.ioctl          = msm_ipc_router_ioctl,
+	.listen		= sock_no_listen,
+	.shutdown	= sock_no_shutdown,
+	.setsockopt     = sock_no_setsockopt,
+	.getsockopt     = sock_no_getsockopt,
 	.sendmsg	= msm_ipc_router_sendmsg,
 	.recvmsg	= msm_ipc_router_recvmsg,
-	.ioctl		= msm_ipc_router_ioctl,
-	.poll		= msm_ipc_router_poll,
-	.setsockopt	= sock_no_setsockopt,
-	.getsockopt	= sock_no_getsockopt,
-	.release	= msm_ipc_router_close,
+	.mmap		= sock_no_mmap,
+	.sendpage	= sock_no_sendpage,
 };
 
 static struct proto msm_ipc_proto = {
diff --git a/arch/arm/mach-msm/msm_watchdog_v2.c b/arch/arm/mach-msm/msm_watchdog_v2.c
index 52e94e6..ead2e95 100644
--- a/arch/arm/mach-msm/msm_watchdog_v2.c
+++ b/arch/arm/mach-msm/msm_watchdog_v2.c
@@ -68,7 +68,7 @@
 
 /*
  * On the kernel command line specify
- * msm_watchdog.enable=1 to enable the watchdog
+ * msm_watchdog_v2.enable=1 to enable the watchdog
  * By default watchdog is turned on
  */
 static int enable = 1;
@@ -76,7 +76,7 @@
 
 /*
  * On the kernel command line specify
- * msm_watchdog.WDT_HZ=<clock val in HZ> to set Watchdog
+ * msm_watchdog_v2.WDT_HZ=<clock val in HZ> to set Watchdog
  * ticks. By default it is set to 32765.
  */
 static long WDT_HZ = 32765;
diff --git a/arch/arm/mach-msm/ocmem.c b/arch/arm/mach-msm/ocmem.c
index d31f3c4..99e54b7 100644
--- a/arch/arm/mach-msm/ocmem.c
+++ b/arch/arm/mach-msm/ocmem.c
@@ -836,7 +836,7 @@
 		return -EBUSY;
 
 	if (ocmem_debugfs_init(pdev))
-		return -EBUSY;
+		dev_err(dev, "ocmem: No debugfs node available\n");
 
 	if (ocmem_core_init(pdev))
 		return -EBUSY;
diff --git a/arch/arm/mach-msm/pil-msa.c b/arch/arm/mach-msm/pil-msa.c
index 3a26af9..76afe6c 100644
--- a/arch/arm/mach-msm/pil-msa.c
+++ b/arch/arm/mach-msm/pil-msa.c
@@ -233,18 +233,17 @@
 	if (drv->self_auth) {
 		ret = pil_msa_wait_for_mba_ready(drv);
 		if (ret)
-			goto err_auth;
+			goto err_q6v5_reset;
 	}
 
 	drv->is_booted = true;
 
 	return 0;
 
-err_auth:
-	pil_q6v5_shutdown(pil);
 err_q6v5_reset:
 	pil_msa_pbl_disable_clks(drv);
 err_clks:
+	writel_relaxed(1, drv->restart_reg);
 	pil_msa_pbl_power_down(drv);
 err_power:
 	return ret;
diff --git a/arch/arm/mach-msm/pm-8x60.c b/arch/arm/mach-msm/pm-8x60.c
index 00b0b3b..af21584 100644
--- a/arch/arm/mach-msm/pm-8x60.c
+++ b/arch/arm/mach-msm/pm-8x60.c
@@ -651,8 +651,11 @@
 {
 	int64_t time = 0;
 
-	if (msm_pm_use_sync_timer)
-		return sched_clock();
+	if (msm_pm_use_sync_timer) {
+		struct timespec ts;
+		getnstimeofday(&ts);
+		return timespec_to_ns(&ts);
+	}
 
 	time = msm_timer_get_sclk_time(period);
 	if (!time)
@@ -663,8 +666,12 @@
 
 static int64_t msm_pm_timer_exit_suspend(int64_t time, int64_t period)
 {
-	if (msm_pm_use_sync_timer)
-		return sched_clock() - time;
+	if (msm_pm_use_sync_timer) {
+		struct timespec ts;
+		getnstimeofday(&ts);
+
+		return timespec_to_ns(&ts) - time;
+	}
 
 	if (time != 0) {
 		int64_t end_time = msm_timer_get_sclk_time(NULL);
@@ -1048,12 +1055,14 @@
 }
 EXPORT_SYMBOL(msm_pm_enable_retention);
 
+static int64_t suspend_time, suspend_period;
+static int collapsed;
+static int suspend_power_collapsed;
+
 static int msm_pm_enter(suspend_state_t state)
 {
 	bool allow[MSM_PM_SLEEP_MODE_NR];
 	int i;
-	int64_t period = 0;
-	int64_t time = msm_pm_timer_enter_suspend(&period);
 	struct msm_pm_time_params time_param;
 
 	time_param.latency_us = -1;
@@ -1081,7 +1090,6 @@
 		int ret = -ENODEV;
 		uint32_t power;
 		uint32_t msm_pm_max_sleep_time = 0;
-		int collapsed = 0;
 
 		if (MSM_PM_DEBUG_SUSPEND & msm_pm_debug_mask)
 			pr_info("%s: power collapse\n", __func__);
@@ -1115,11 +1123,7 @@
 			pr_err("%s: cannot find the lowest power limit\n",
 				__func__);
 		}
-		time = msm_pm_timer_exit_suspend(time, period);
-		if (collapsed)
-			msm_pm_add_stat(MSM_PM_STAT_SUSPEND, time);
-		else
-			msm_pm_add_stat(MSM_PM_STAT_FAILED_SUSPEND, time);
+		suspend_power_collapsed = true;
 	} else if (allow[MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE]) {
 		if (MSM_PM_DEBUG_SUSPEND & msm_pm_debug_mask)
 			pr_info("%s: standalone power collapse\n", __func__);
@@ -1149,6 +1153,7 @@
 
 static int msm_suspend_prepare(void)
 {
+	suspend_time = msm_pm_timer_enter_suspend(&suspend_period);
 	msm_mpm_suspend_prepare();
 	return 0;
 }
@@ -1156,6 +1161,16 @@
 static void msm_suspend_wake(void)
 {
 	msm_mpm_suspend_wake();
+	if (suspend_power_collapsed) {
+		suspend_time = msm_pm_timer_exit_suspend(suspend_time,
+				suspend_period);
+		if (collapsed)
+			msm_pm_add_stat(MSM_PM_STAT_SUSPEND, suspend_time);
+		else
+			msm_pm_add_stat(MSM_PM_STAT_FAILED_SUSPEND,
+					suspend_time);
+		suspend_power_collapsed = false;
+	}
 }
 
 static const struct platform_suspend_ops msm_pm_ops = {
diff --git a/arch/arm/mach-msm/qdsp5/Makefile b/arch/arm/mach-msm/qdsp5/Makefile
deleted file mode 100644
index f4fe052..0000000
--- a/arch/arm/mach-msm/qdsp5/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-obj-y += adsp.o adsp_driver.o adsp_info.o adsp_rm.o dsp_debug.o adsp_debug.o
-obj-y += adsp_video_verify_cmd.o
-obj-y += adsp_videoenc_verify_cmd.o
-obj-y += adsp_jpeg_verify_cmd.o adsp_jpeg_patch_event.o
-obj-y += adsp_vfe_verify_cmd.o adsp_vfe_patch_event.o
-obj-y += adsp_lpm_verify_cmd.o
-ifdef CONFIG_MSM7X27A_AUDIO
-obj-y += audio_pcm_in.o
-obj-$(CONFIG_DEBUG_FS) += audio_voice_lb.o
-else
-obj-y += audio_in.o snd_pcm_client.o
-endif
-obj-$(CONFIG_MSM7X27A_AUDIO) += audio_aac_in.o audio_evrc_in.o audio_qcelp_in.o
-obj-y += audio_out.o audio_mp3.o audmgr.o audpp.o audrec.o audpreproc.o
-obj-y += audio_evrc.o audio_qcelp.o audio_amrnb.o audio_aac.o audio_amrnb_in.o
-obj-y += audio_wma.o audio_voicememo.o audio_pcm.o audio_amrwb.o audio_wmapro.o
-obj-y += snd.o snd_cad.o snd_adie.o audio_acdb.o
-obj-$(CONFIG_ARCH_MSM7X27A) += audio_fm.o
-obj-$(CONFIG_ARCH_MSM7X27A) += audio_mvs.o
-obj-$(CONFIG_ARCH_MSM7X27A) += audio_lpa.o audio_ac3.o
diff --git a/arch/arm/mach-msm/qdsp5/adsp.c b/arch/arm/mach-msm/qdsp5/adsp.c
deleted file mode 100644
index 353de3d..0000000
--- a/arch/arm/mach-msm/qdsp5/adsp.c
+++ /dev/null
@@ -1,1509 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/adsp.c
- *
- * Register/Interrupt access for userspace aDSP library.
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (c) 2008-2012, The Linux Foundation. All rights reserved.
- * Author: Iliyan Malchev <ibm@android.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-/* TODO:
- * - move shareable rpc code outside of adsp.c
- * - general solution for virt->phys patchup
- * - queue IDs should be relative to modules
- * - disallow access to non-associated queues
- */
-
-#include <linux/clk.h>
-#include <linux/delay.h>
-#include <linux/interrupt.h>
-#include <linux/kernel.h>
-#include <linux/kthread.h>
-#include <linux/module.h>
-#include <linux/uaccess.h>
-#include <linux/wait.h>
-#include <linux/wakelock.h>
-#include <linux/slab.h>
-#include <linux/workqueue.h>
-#include <mach/debug_mm.h>
-#include <linux/debugfs.h>
-
-#ifdef CONFIG_DEBUG_FS
-static struct dentry *dentry_adsp;
-static struct dentry *dentry_wdata;
-static struct dentry *dentry_rdata;
-static int wdump, rdump;
-#endif /* CONFIG_DEBUG_FS */
-static struct wake_lock adsp_wake_lock;
-static inline void prevent_suspend(void)
-{
-	wake_lock(&adsp_wake_lock);
-}
-static inline void allow_suspend(void)
-{
-	wake_unlock(&adsp_wake_lock);
-}
-
-#include <linux/io.h>
-#include <mach/msm_iomap.h>
-#include <mach/msm_adsp.h>
-#include "adsp.h"
-
-static struct adsp_info adsp_info;
-static struct msm_rpc_endpoint *rpc_cb_server_client;
-static struct msm_adsp_module *adsp_modules;
-static int adsp_open_count;
-
-static uint32_t rpc_adsp_rtos_atom_prog;
-static uint32_t rpc_adsp_rtos_atom_vers;
-static uint32_t rpc_adsp_rtos_atom_vers_comp;
-static uint32_t rpc_adsp_rtos_mtoa_prog;
-static uint32_t rpc_adsp_rtos_mtoa_vers;
-static uint32_t rpc_adsp_rtos_mtoa_vers_comp;
-static DEFINE_MUTEX(adsp_open_lock);
-
-static struct workqueue_struct *msm_adsp_probe_work_queue;
-static void adsp_probe_work(struct work_struct *work);
-static DECLARE_WORK(msm_adsp_probe_work, adsp_probe_work);
-
-/* protect interactions with the ADSP command/message queue */
-static spinlock_t adsp_cmd_lock;
-static spinlock_t adsp_write_lock;
-
-static uint32_t current_image = -1;
-
-void adsp_set_image(struct adsp_info *info, uint32_t image)
-{
-	current_image = image;
-}
-
-/*
- * Checks whether the module_id is available in the
- * module_entries table.If module_id is available returns `0`.
- * If module_id is not available returns `-ENXIO`.
- */
-static int32_t adsp_validate_module(uint32_t module_id)
-{
-	uint32_t	*ptr;
-	uint32_t	module_index;
-	uint32_t	num_mod_entries;
-
-	ptr = adsp_info.init_info_ptr->module_entries;
-	num_mod_entries = adsp_info.init_info_ptr->module_table_size;
-
-	for (module_index = 0; module_index < num_mod_entries; module_index++)
-		if (module_id == ptr[module_index])
-			return 0;
-
-	return -ENXIO;
-}
-
-static int32_t adsp_validate_queue(uint32_t mod_id, unsigned q_idx,
-							uint32_t size)
-{
-	int32_t i;
-	struct adsp_rtos_mp_mtoa_init_info_type	*sptr;
-
-	sptr = adsp_info.init_info_ptr;
-	for (i = 0; i < sptr->mod_to_q_entries; i++)
-		if (mod_id == sptr->mod_to_q_tbl[i].module)
-			if (q_idx == sptr->mod_to_q_tbl[i].q_type) {
-				if (size <= sptr->mod_to_q_tbl[i].q_max_len)
-					return 0;
-				MM_ERR("q_idx: %d is not a valid queue \
-					for module %x\n", q_idx, mod_id);
-				return -EINVAL;
-			}
-	MM_ERR("cmd_buf size is more than allowed size\n");
-	return -EINVAL;
-}
-
-uint32_t adsp_get_module(struct adsp_info *info, uint32_t task)
-{
-	return info->task_to_module[current_image][task];
-}
-
-uint32_t adsp_get_queue_offset(struct adsp_info *info, uint32_t queue_id)
-{
-	return info->queue_offset[current_image][queue_id];
-}
-
-static int rpc_adsp_rtos_app_to_modem(uint32_t cmd, uint32_t module,
-				      struct msm_adsp_module *adsp_module)
-{
-	int rc;
-	struct rpc_adsp_rtos_app_to_modem_args_t rpc_req;
-	struct rpc_reply_hdr rpc_rsp;
-
-	rpc_req.gotit = cpu_to_be32(1);
-	rpc_req.cmd = cpu_to_be32(cmd);
-	rpc_req.proc_id = cpu_to_be32(RPC_ADSP_RTOS_PROC_APPS);
-	rpc_req.module = cpu_to_be32(module);
-	rc = msm_rpc_call_reply(adsp_module->rpc_client,
-					RPC_ADSP_RTOS_APP_TO_MODEM_PROC,
-					&rpc_req, sizeof(rpc_req),
-					&rpc_rsp, sizeof(rpc_rsp),
-					5 * HZ);
-
-	if (rc < 0) {
-		MM_ERR("error receiving RPC reply: %d (%d)\n",
-				rc, -ERESTARTSYS);
-		return rc;
-	}
-
-	if (be32_to_cpu(rpc_rsp.reply_stat) != RPCMSG_REPLYSTAT_ACCEPTED) {
-		MM_ERR("RPC call was denied!\n");
-		return -EPERM;
-	}
-
-	if (be32_to_cpu(rpc_rsp.data.acc_hdr.accept_stat) !=
-	    RPC_ACCEPTSTAT_SUCCESS) {
-		MM_ERR("RPC call was not successful (%d)\n",
-				be32_to_cpu(rpc_rsp.data.acc_hdr.accept_stat));
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-static int get_module_index(uint32_t id)
-{
-	int mod_idx;
-	for (mod_idx = 0; mod_idx < adsp_info.module_count; mod_idx++)
-		if (adsp_info.module[mod_idx].id == id)
-			return mod_idx;
-
-	return -ENXIO;
-}
-
-static struct msm_adsp_module *find_adsp_module_by_id(
-	struct adsp_info *info, uint32_t id)
-{
-	int mod_idx;
-
-	if (id > info->max_module_id) {
-		return NULL;
-	} else {
-		mod_idx = get_module_index(id);
-		if (mod_idx < 0)
-			return NULL;
-		return info->id_to_module[mod_idx];
-	}
-}
-
-static struct msm_adsp_module *find_adsp_module_by_name(
-	struct adsp_info *info, const char *name)
-{
-	unsigned n;
-	for (n = 0; n < info->module_count; n++)
-		if (!strcmp(name, adsp_modules[n].name))
-			return adsp_modules + n;
-	return NULL;
-}
-
-static int adsp_rpc_init(struct msm_adsp_module *adsp_module)
-{
-	/* remove the original connect once compatible support is complete */
-	adsp_module->rpc_client = msm_rpc_connect(
-		rpc_adsp_rtos_atom_prog,
-		rpc_adsp_rtos_atom_vers,
-		MSM_RPC_UNINTERRUPTIBLE);
-	if (IS_ERR(adsp_module->rpc_client))
-		adsp_module->rpc_client = msm_rpc_connect_compatible(
-		rpc_adsp_rtos_atom_prog,
-		rpc_adsp_rtos_atom_vers_comp,
-		MSM_RPC_UNINTERRUPTIBLE);
-
-	if (IS_ERR(adsp_module->rpc_client)) {
-		int rc = PTR_ERR(adsp_module->rpc_client);
-		adsp_module->rpc_client = 0;
-		MM_ERR("could not open rpc client: %d\n", rc);
-		return rc;
-	}
-
-	return 0;
-}
-
-/*
- * Send RPC_ADSP_RTOS_CMD_GET_INIT_INFO cmd to ARM9 and get
- * queue offsets and module entries (init info) as part of the event.
- */
-static void  msm_get_init_info(void)
-{
-	int rc;
-	struct rpc_adsp_rtos_app_to_modem_args_t rpc_req;
-	struct rpc_reply_hdr rpc_rsp;
-
-	adsp_info.init_info_rpc_client = msm_rpc_connect(
-		rpc_adsp_rtos_atom_prog,
-		rpc_adsp_rtos_atom_vers,
-		MSM_RPC_UNINTERRUPTIBLE);
-	if (IS_ERR(adsp_info.init_info_rpc_client)) {
-		adsp_info.init_info_rpc_client = msm_rpc_connect_compatible(
-		rpc_adsp_rtos_atom_prog,
-		rpc_adsp_rtos_atom_vers_comp,
-		MSM_RPC_UNINTERRUPTIBLE);
-		if (IS_ERR(adsp_info.init_info_rpc_client)) {
-			rc = PTR_ERR(adsp_info.init_info_rpc_client);
-			adsp_info.init_info_rpc_client = 0;
-			MM_ERR("could not open rpc client: %d\n", rc);
-			return;
-		}
-	}
-
-	rpc_req.gotit = cpu_to_be32(1);
-	rpc_req.cmd = cpu_to_be32(RPC_ADSP_RTOS_CMD_GET_INIT_INFO);
-	rpc_req.proc_id = cpu_to_be32(RPC_ADSP_RTOS_PROC_APPS);
-	rpc_req.module = 0;
-
-	rc = msm_rpc_call_reply(adsp_info.init_info_rpc_client,
-					RPC_ADSP_RTOS_APP_TO_MODEM_PROC,
-					&rpc_req, sizeof(rpc_req),
-					&rpc_rsp, sizeof(rpc_rsp),
-					5 * HZ);
-
-	if (rc < 0)
-		MM_ERR("could not send RPC request: %d\n", rc);
-}
-
-int msm_adsp_get(const char *name, struct msm_adsp_module **out,
-		 struct msm_adsp_ops *ops, void *driver_data)
-{
-	struct msm_adsp_module *module;
-	int rc = 0;
-	static uint32_t init_info_cmd_sent;
-
-	mutex_lock(&adsp_info.lock);
-	if (!init_info_cmd_sent) {
-		init_waitqueue_head(&adsp_info.init_info_wait);
-		msm_get_init_info();
-		rc = wait_event_timeout(adsp_info.init_info_wait,
-			adsp_info.init_info_state == ADSP_STATE_INIT_INFO,
-			5 * HZ);
-		if (!rc) {
-			MM_ERR("INIT_INFO failed\n");
-			mutex_unlock(&adsp_info.lock);
-			return -ETIMEDOUT;
-
-		}
-		init_info_cmd_sent++;
-	}
-	mutex_unlock(&adsp_info.lock);
-
-	module = find_adsp_module_by_name(&adsp_info, name);
-	if (!module)
-		return -ENODEV;
-
-	mutex_lock(&module->lock);
-	MM_INFO("opening module %s\n", module->name);
-
-	if (module->ops) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	rc = adsp_rpc_init(module);
-	if (rc)
-		goto done;
-
-	module->ops = ops;
-	module->driver_data = driver_data;
-	*out = module;
-	rc = rpc_adsp_rtos_app_to_modem(RPC_ADSP_RTOS_CMD_REGISTER_APP,
-					module->id, module);
-	if (rc) {
-		module->ops = NULL;
-		module->driver_data = NULL;
-		*out = NULL;
-		MM_ERR("REGISTER_APP failed\n");
-		goto done;
-	}
-
-	MM_DBG("module %s has been registered\n", module->name);
-
-done:
-	mutex_unlock(&module->lock);
-	return rc;
-}
-EXPORT_SYMBOL(msm_adsp_get);
-
-static int msm_adsp_disable_locked(struct msm_adsp_module *module);
-
-void msm_adsp_put(struct msm_adsp_module *module)
-{
-	unsigned long flags;
-
-	mutex_lock(&module->lock);
-	if (module->ops) {
-		MM_INFO("closing module %s\n", module->name);
-
-		/* lock to ensure a dsp event cannot be delivered
-		 * during or after removal of the ops and driver_data
-		 */
-		spin_lock_irqsave(&adsp_cmd_lock, flags);
-		module->ops = NULL;
-		module->driver_data = NULL;
-		spin_unlock_irqrestore(&adsp_cmd_lock, flags);
-
-		if (module->state != ADSP_STATE_DISABLED) {
-			MM_INFO("disabling module %s\n", module->name);
-			msm_adsp_disable_locked(module);
-		}
-
-		msm_rpc_close(module->rpc_client);
-		module->rpc_client = 0;
-	} else {
-		MM_INFO("module %s is already closed\n", module->name);
-	}
-	mutex_unlock(&module->lock);
-}
-EXPORT_SYMBOL(msm_adsp_put);
-
-/* this should be common code with rpc_servers.c */
-static int rpc_send_accepted_void_reply(struct msm_rpc_endpoint *client,
-					uint32_t xid, uint32_t accept_status)
-{
-	int rc = 0;
-	uint8_t reply_buf[sizeof(struct rpc_reply_hdr)];
-	struct rpc_reply_hdr *reply = (struct rpc_reply_hdr *)reply_buf;
-
-	reply->xid = cpu_to_be32(xid);
-	reply->type = cpu_to_be32(1); /* reply */
-	reply->reply_stat = cpu_to_be32(RPCMSG_REPLYSTAT_ACCEPTED);
-
-	reply->data.acc_hdr.accept_stat = cpu_to_be32(accept_status);
-	reply->data.acc_hdr.verf_flavor = 0;
-	reply->data.acc_hdr.verf_length = 0;
-
-	rc = msm_rpc_write(rpc_cb_server_client, reply_buf, sizeof(reply_buf));
-	if (rc < 0)
-		MM_ERR("could not write RPC response: %d\n", rc);
-	return rc;
-}
-
-int __msm_adsp_write(struct msm_adsp_module *module, unsigned dsp_queue_addr,
-		   void *cmd_buf, size_t cmd_size)
-{
-	uint32_t ctrl_word;
-	uint32_t dsp_q_addr;
-	uint32_t dsp_addr;
-	uint32_t cmd_id = 0;
-	int cnt = 0;
-	int ret_status = 0;
-	unsigned long flags;
-	struct adsp_info *info;
-
-	if (!module || !cmd_buf) {
-		MM_ERR("Called with NULL parameters\n");
-		return -EINVAL;
-	}
-	info = module->info;
-	spin_lock_irqsave(&adsp_write_lock, flags);
-
-	if (module->state != ADSP_STATE_ENABLED) {
-		spin_unlock_irqrestore(&adsp_write_lock, flags);
-		MM_ERR("module %s not enabled before write\n", module->name);
-		return -ENODEV;
-	}
-	if (adsp_validate_module(module->id)) {
-		spin_unlock_irqrestore(&adsp_write_lock, flags);
-		MM_ERR("module id validation failed %s  %d\n",
-				module->name, module->id);
-		return -ENXIO;
-	}
-	if (dsp_queue_addr >= QDSP_MAX_NUM_QUEUES) {
-		spin_unlock_irqrestore(&adsp_write_lock, flags);
-		MM_ERR("Invalid Queue Index: %d\n", dsp_queue_addr);
-		return -ENXIO;
-	}
-	if (adsp_validate_queue(module->id, dsp_queue_addr, cmd_size)) {
-		spin_unlock_irqrestore(&adsp_write_lock, flags);
-		return -EINVAL;
-	}
-	dsp_q_addr = adsp_get_queue_offset(info, dsp_queue_addr);
-	dsp_q_addr &= ADSP_RTOS_WRITE_CTRL_WORD_DSP_ADDR_M;
-
-	/* Poll until the ADSP is ready to accept a command.
-	 * Wait for 100us, return error if it's not responding.
-	 * If this returns an error, we need to disable ALL modules and
-	 * then retry.
-	 */
-	while (((ctrl_word = readl(info->write_ctrl)) &
-		ADSP_RTOS_WRITE_CTRL_WORD_READY_M) !=
-		ADSP_RTOS_WRITE_CTRL_WORD_READY_V) {
-		if (cnt > 50) {
-			MM_ERR("timeout waiting for DSP write ready\n");
-			ret_status = -EIO;
-			goto fail;
-		}
-		MM_DBG("waiting for DSP write ready\n");
-		udelay(2);
-		cnt++;
-	}
-
-	/* Set the mutex bits */
-	ctrl_word &= ~(ADSP_RTOS_WRITE_CTRL_WORD_MUTEX_M);
-	ctrl_word |=  ADSP_RTOS_WRITE_CTRL_WORD_MUTEX_NAVAIL_V;
-
-	/* Clear the command bits */
-	ctrl_word &= ~(ADSP_RTOS_WRITE_CTRL_WORD_CMD_M);
-
-	/* Set the queue address bits */
-	ctrl_word &= ~(ADSP_RTOS_WRITE_CTRL_WORD_DSP_ADDR_M);
-	ctrl_word |= dsp_q_addr;
-
-	writel(ctrl_word, info->write_ctrl);
-
-	/* Generate an interrupt to the DSP.  This notifies the DSP that
-	 * we are about to send a command on this particular queue.  The
-	 * DSP will in response change its state.
-	 */
-	writel(1, info->send_irq);
-
-	/* Poll until the adsp responds to the interrupt; this does not
-	 * generate an interrupt from the adsp.  This should happen within
-	 * 5ms.
-	 */
-	cnt = 0;
-	while ((readl(info->write_ctrl) &
-		ADSP_RTOS_WRITE_CTRL_WORD_MUTEX_M) ==
-		ADSP_RTOS_WRITE_CTRL_WORD_MUTEX_NAVAIL_V) {
-		if (cnt > 2500) {
-			MM_ERR("timeout waiting for adsp ack\n");
-			ret_status = -EIO;
-			goto fail;
-		}
-		udelay(2);
-		cnt++;
-	}
-
-	/* Read the ctrl word */
-	ctrl_word = readl(info->write_ctrl);
-
-	if ((ctrl_word & ADSP_RTOS_WRITE_CTRL_WORD_STATUS_M) !=
-	    ADSP_RTOS_WRITE_CTRL_WORD_NO_ERR_V) {
-		ret_status = -EAGAIN;
-		goto fail;
-	} else {
-		/* No error */
-		/* Get the DSP buffer address */
-		dsp_addr = (ctrl_word & ADSP_RTOS_WRITE_CTRL_WORD_DSP_ADDR_M) +
-			   (uint32_t)MSM_AD5_BASE;
-
-		if (dsp_addr < (uint32_t)(MSM_AD5_BASE + QDSP_RAMC_OFFSET)) {
-			uint16_t *buf_ptr = (uint16_t *) cmd_buf;
-			uint16_t *dsp_addr16 = (uint16_t *)dsp_addr;
-			cmd_size /= sizeof(uint16_t);
-
-			/* Save the command ID */
-			cmd_id = (uint32_t) buf_ptr[0];
-
-			/* Copy the command to DSP memory */
-			cmd_size++;
-			while (--cmd_size)
-				*dsp_addr16++ = *buf_ptr++;
-		} else {
-			uint32_t *buf_ptr = (uint32_t *) cmd_buf;
-			uint32_t *dsp_addr32 = (uint32_t *)dsp_addr;
-			cmd_size /= sizeof(uint32_t);
-
-			/* Save the command ID */
-			cmd_id = buf_ptr[0];
-
-			cmd_size++;
-			while (--cmd_size)
-				*dsp_addr32++ = *buf_ptr++;
-		}
-
-		/* Set the mutex bits */
-		ctrl_word &= ~(ADSP_RTOS_WRITE_CTRL_WORD_MUTEX_M);
-		ctrl_word |=  ADSP_RTOS_WRITE_CTRL_WORD_MUTEX_NAVAIL_V;
-
-		/* Set the command bits to write done */
-		ctrl_word &= ~(ADSP_RTOS_WRITE_CTRL_WORD_CMD_M);
-		ctrl_word |= ADSP_RTOS_WRITE_CTRL_WORD_CMD_WRITE_DONE_V;
-
-		/* Set the queue address bits */
-		ctrl_word &= ~(ADSP_RTOS_WRITE_CTRL_WORD_DSP_ADDR_M);
-		ctrl_word |= dsp_q_addr;
-
-		writel(ctrl_word, info->write_ctrl);
-
-		/* Generate an interrupt to the DSP.  It does not respond with
-		 * an interrupt, and we do not need to wait for it to
-		 * acknowledge, because it will hold the mutex lock until it's
-		 * ready to receive more commands again.
-		 */
-		writel(1, info->send_irq);
-
-		module->num_commands++;
-	} /* Ctrl word status bits were 00, no error in the ctrl word */
-
-fail:
-	spin_unlock_irqrestore(&adsp_write_lock, flags);
-	return ret_status;
-}
-EXPORT_SYMBOL(msm_adsp_write);
-
-int msm_adsp_write(struct msm_adsp_module *module, unsigned dsp_queue_addr,
-			void *cmd_buf, size_t cmd_size)
-{
-	int rc, retries = 0;
-#ifdef CONFIG_DEBUG_FS
-	uint16_t *ptr;
-	int ii;
-
-	if (wdump > 0) {
-		ptr = cmd_buf;
-		pr_info("A->D:%x\n", module->id);
-		pr_info("adsp: %x %d\n", dsp_queue_addr, cmd_size);
-		for (ii = 0; ii < cmd_size/2; ii++)
-			pr_info("%x ", ptr[ii]);
-		pr_info("\n");
-	}
-#endif /* CONFIG_DEBUG_FS */
-	do {
-		rc = __msm_adsp_write(module, dsp_queue_addr, cmd_buf,
-								cmd_size);
-		if (rc == -EAGAIN)
-			udelay(10);
-	} while (rc == -EAGAIN && retries++ < 300);
-	if (retries > 50)
-		MM_ERR("adsp: %s command took %d attempts: rc %d\n",
-			module->name, retries, rc);
-	return rc;
-}
-
-static void *event_addr;
-static void read_event(void *buf, size_t len)
-{
-	uint32_t dptr[3];
-	struct rpc_adsp_rtos_modem_to_app_args_t *sptr;
-	struct adsp_rtos_mp_mtoa_type	*pkt_ptr;
-
-	sptr = event_addr;
-	pkt_ptr = &sptr->mtoa_pkt.adsp_rtos_mp_mtoa_data.mp_mtoa_packet;
-
-	dptr[0] = be32_to_cpu(sptr->mtoa_pkt.mp_mtoa_header.event);
-	dptr[1] = be32_to_cpu(pkt_ptr->module);
-	dptr[2] = be32_to_cpu(pkt_ptr->image);
-
-	if (len > EVENT_LEN)
-		len = EVENT_LEN;
-
-	memcpy(buf, dptr, len);
-}
-
-static void handle_adsp_rtos_mtoa_app(struct rpc_request_hdr *req)
-{
-	struct rpc_adsp_rtos_modem_to_app_args_t *args =
-		(struct rpc_adsp_rtos_modem_to_app_args_t *)req;
-	uint32_t event;
-	uint32_t proc_id;
-	uint32_t module_id;
-	uint32_t image;
-	struct msm_adsp_module *module;
-	struct adsp_rtos_mp_mtoa_type	*pkt_ptr;
-	struct queue_to_offset_type	*qptr;
-	struct queue_to_offset_type	*qtbl;
-	struct mod_to_queue_offsets	*mqptr;
-	struct mod_to_queue_offsets	*mqtbl;
-	uint32_t	*mptr;
-	uint32_t	*mtbl;
-	uint32_t	q_idx;
-	uint32_t	num_entries;
-	uint32_t	entries_per_image;
-	struct adsp_rtos_mp_mtoa_init_info_type *iptr;
-	struct adsp_rtos_mp_mtoa_init_info_type	*sptr;
-	int32_t		i_no, e_idx;
-
-	event = be32_to_cpu(args->mtoa_pkt.mp_mtoa_header.event);
-	proc_id = be32_to_cpu(args->mtoa_pkt.mp_mtoa_header.proc_id);
-
-	if (event == RPC_ADSP_RTOS_INIT_INFO) {
-		MM_INFO("INIT_INFO Event\n");
-		sptr = &args->mtoa_pkt.adsp_rtos_mp_mtoa_data.mp_mtoa_init_packet;
-
-		iptr = adsp_info.init_info_ptr;
-		iptr->image_count = be32_to_cpu(sptr->image_count);
-		if (iptr->image_count > IMG_MAX)
-			iptr->image_count = IMG_MAX;
-		iptr->num_queue_offsets = be32_to_cpu(sptr->num_queue_offsets);
-		num_entries = iptr->num_queue_offsets;
-		if (num_entries > ENTRIES_MAX) {
-			num_entries = ENTRIES_MAX;
-			iptr->num_queue_offsets = ENTRIES_MAX;
-		}
-		qptr = &sptr->queue_offsets_tbl[0][0];
-		for (i_no = 0; i_no < iptr->image_count; i_no++) {
-			qtbl = &iptr->queue_offsets_tbl[i_no][0];
-			for (e_idx = 0; e_idx < num_entries; e_idx++) {
-				qtbl[e_idx].offset = be32_to_cpu(qptr->offset);
-				qtbl[e_idx].queue = be32_to_cpu(qptr->queue);
-				q_idx = be32_to_cpu(qptr->queue);
-				iptr->queue_offsets[i_no][q_idx] = qtbl[e_idx].offset;
-				qptr++;
-			}
-		}
-
-		num_entries = be32_to_cpu(sptr->num_task_module_entries);
-		if (num_entries > ENTRIES_MAX)
-			num_entries = ENTRIES_MAX;
-		iptr->num_task_module_entries = num_entries;
-		entries_per_image = num_entries / iptr->image_count;
-		mptr = &sptr->task_to_module_tbl[0][0];
-		for (i_no = 0; i_no < iptr->image_count; i_no++) {
-			mtbl = &iptr->task_to_module_tbl[i_no][0];
-			for (e_idx = 0; e_idx < entries_per_image; e_idx++) {
-				mtbl[e_idx] = be32_to_cpu(*mptr);
-				mptr++;
-			}
-		}
-
-		iptr->module_table_size = be32_to_cpu(sptr->module_table_size);
-#if CONFIG_ADSP_RPC_VER > 0x30001
-		if (iptr->module_table_size > MODULES_MAX)
-			iptr->module_table_size = MODULES_MAX;
-#else
-		if (iptr->module_table_size > ENTRIES_MAX)
-			iptr->module_table_size = ENTRIES_MAX;
-#endif
-		mptr = &sptr->module_entries[0];
-		for (i_no = 0; i_no < iptr->module_table_size; i_no++)
-			iptr->module_entries[i_no] = be32_to_cpu(mptr[i_no]);
-
-		mqptr = &sptr->mod_to_q_tbl[0];
-		mqtbl = &iptr->mod_to_q_tbl[0];
-		iptr->mod_to_q_entries = be32_to_cpu(sptr->mod_to_q_entries);
-		if (iptr->mod_to_q_entries > ENTRIES_MAX)
-			iptr->mod_to_q_entries = ENTRIES_MAX;
-		for (e_idx = 0; e_idx < iptr->mod_to_q_entries; e_idx++) {
-			mqtbl[e_idx].module = be32_to_cpu(mqptr->module);
-			mqtbl[e_idx].q_type = be32_to_cpu(mqptr->q_type);
-			mqtbl[e_idx].q_max_len = be32_to_cpu(mqptr->q_max_len);
-			mqptr++;
-		}
-
-		adsp_info.init_info_state = ADSP_STATE_INIT_INFO;
-		rpc_send_accepted_void_reply(rpc_cb_server_client, req->xid,
-						RPC_ACCEPTSTAT_SUCCESS);
-		wake_up(&adsp_info.init_info_wait);
-
-		return;
-	}
-
-	pkt_ptr = &args->mtoa_pkt.adsp_rtos_mp_mtoa_data.mp_mtoa_packet;
-	module_id = be32_to_cpu(pkt_ptr->module);
-	image     = be32_to_cpu(pkt_ptr->image);
-
-	MM_DBG("rpc event=%d, proc_id=%d, module=%d, image=%d\n",
-		event, proc_id, module_id, image);
-
-	module = find_adsp_module_by_id(&adsp_info, module_id);
-	if (!module) {
-		MM_ERR("module %d is not supported!\n", module_id);
-		rpc_send_accepted_void_reply(rpc_cb_server_client, req->xid,
-				RPC_ACCEPTSTAT_GARBAGE_ARGS);
-		return;
-	}
-
-	mutex_lock(&module->lock);
-	switch (event) {
-	case RPC_ADSP_RTOS_MOD_READY:
-		if (module->state == ADSP_STATE_ENABLING) {
-			MM_INFO("module %s: READY\n", module->name);
-			module->state = ADSP_STATE_ENABLED;
-			wake_up(&module->state_wait);
-			adsp_set_image(module->info, image);
-			break;
-		} else {
-			MM_ERR("module %s got READY event in state[%d]\n",
-								module->name,
-								module->state);
-			rpc_send_accepted_void_reply(rpc_cb_server_client,
-						req->xid,
-						RPC_ACCEPTSTAT_GARBAGE_ARGS);
-			mutex_unlock(&module->lock);
-			return;
-		}
-	case RPC_ADSP_RTOS_MOD_DISABLE:
-		MM_INFO("module %s: DISABLED\n", module->name);
-		module->state = ADSP_STATE_DISABLED;
-		wake_up(&module->state_wait);
-		break;
-	case RPC_ADSP_RTOS_SERVICE_RESET:
-		MM_INFO("module %s: SERVICE_RESET\n", module->name);
-		module->state = ADSP_STATE_DISABLED;
-		wake_up(&module->state_wait);
-		break;
-	case RPC_ADSP_RTOS_CMD_SUCCESS:
-		MM_INFO("module %s: CMD_SUCCESS\n", module->name);
-		break;
-	case RPC_ADSP_RTOS_CMD_FAIL:
-		MM_INFO("module %s: CMD_FAIL\n", module->name);
-		break;
-	case RPC_ADSP_RTOS_DISABLE_FAIL:
-		MM_INFO("module %s: DISABLE_FAIL\n", module->name);
-		break;
-	default:
-		MM_ERR("unknown event %d\n", event);
-		rpc_send_accepted_void_reply(rpc_cb_server_client, req->xid,
-					     RPC_ACCEPTSTAT_GARBAGE_ARGS);
-		mutex_unlock(&module->lock);
-		return;
-	}
-	rpc_send_accepted_void_reply(rpc_cb_server_client, req->xid,
-				     RPC_ACCEPTSTAT_SUCCESS);
-#ifdef CONFIG_MSM_ADSP_REPORT_EVENTS
-	event_addr = (uint32_t *)req;
-	module->ops->event(module->driver_data,
-				EVENT_MSG_ID,
-				EVENT_LEN,
-				read_event);
-#endif
-	mutex_unlock(&module->lock);
-}
-
-static int handle_adsp_rtos_mtoa(struct rpc_request_hdr *req)
-{
-	switch (req->procedure) {
-	case RPC_ADSP_RTOS_MTOA_NULL_PROC:
-		rpc_send_accepted_void_reply(rpc_cb_server_client,
-					     req->xid,
-					     RPC_ACCEPTSTAT_SUCCESS);
-		break;
-#if CONFIG_ADSP_RPC_VER > 0x30001
-	case RPC_ADSP_RTOS_MTOA_INIT_INFO_PROC:
-	case RPC_ADSP_RTOS_MTOA_EVENT_INFO_PROC:
-#else
-	case RPC_ADSP_RTOS_MODEM_TO_APP_PROC:
-#endif
-		handle_adsp_rtos_mtoa_app(req);
-		break;
-	default:
-		MM_ERR("unknowned proc %d\n", req->procedure);
-		rpc_send_accepted_void_reply(
-			rpc_cb_server_client, req->xid,
-			RPC_ACCEPTSTAT_PROC_UNAVAIL);
-		break;
-	}
-	return 0;
-}
-
-/* this should be common code with rpc_servers.c */
-static int adsp_rpc_thread(void *data)
-{
-	void *buffer;
-	struct rpc_request_hdr *req;
-	int rc, exit = 0;
-
-	do {
-		rc = msm_rpc_read(rpc_cb_server_client, &buffer, -1, -1);
-		if (rc < 0) {
-			MM_ERR("could not read rpc: %d\n", rc);
-			break;
-		}
-		req = (struct rpc_request_hdr *)buffer;
-
-		req->type = be32_to_cpu(req->type);
-		req->xid = be32_to_cpu(req->xid);
-		req->rpc_vers = be32_to_cpu(req->rpc_vers);
-		req->prog = be32_to_cpu(req->prog);
-		req->vers = be32_to_cpu(req->vers);
-		req->procedure = be32_to_cpu(req->procedure);
-
-		if (req->type != 0)
-			goto bad_rpc;
-		if (req->rpc_vers != 2)
-			goto bad_rpc;
-		if (req->prog != rpc_adsp_rtos_mtoa_prog)
-			goto bad_rpc;
-		if (!msm_rpc_is_compatible_version(rpc_adsp_rtos_mtoa_vers,
-							req->vers))
-			goto bad_rpc;
-
-		handle_adsp_rtos_mtoa(req);
-		kfree(buffer);
-		continue;
-
-bad_rpc:
-		MM_ERR("bogus rpc from modem\n");
-		kfree(buffer);
-	} while (!exit);
-	do_exit(0);
-}
-
-static size_t read_event_size;
-static void *read_event_addr;
-
-static void read_event_16(void *buf, size_t len)
-{
-	uint16_t *dst = buf;
-	uint16_t *src = read_event_addr;
-	len /= 2;
-	if (len > read_event_size)
-		len = read_event_size;
-	while (len--)
-		*dst++ = *src++;
-}
-
-static void read_event_32(void *buf, size_t len)
-{
-	uint32_t *dst = buf;
-	uint32_t *src = read_event_addr;
-	len /= 2;
-	if (len > read_event_size)
-		len = read_event_size;
-	while (len--)
-		*dst++ = *src++;
-}
-
-static int adsp_rtos_read_ctrl_word_cmd_tast_to_h_v(
-	struct adsp_info *info, void *dsp_addr)
-{
-	struct msm_adsp_module *module;
-	unsigned rtos_task_id;
-	unsigned msg_id;
-	unsigned msg_length;
-#ifdef CONFIG_DEBUG_FS
-	uint16_t *ptr16;
-	uint32_t *ptr32;
-	int ii;
-#endif /* CONFIG_DEBUG_FS */
-	void (*func)(void *, size_t);
-
-	if (dsp_addr >= (void *)(MSM_AD5_BASE + QDSP_RAMC_OFFSET)) {
-		uint32_t *dsp_addr32 = dsp_addr;
-		uint32_t tmp = *dsp_addr32++;
-		rtos_task_id = (tmp & ADSP_RTOS_READ_CTRL_WORD_TASK_ID_M) >> 8;
-		msg_id = (tmp & ADSP_RTOS_READ_CTRL_WORD_MSG_ID_M);
-		read_event_size = tmp >> 16;
-		read_event_addr = dsp_addr32;
-		msg_length = read_event_size * sizeof(uint32_t);
-		func = read_event_32;
-	} else {
-		uint16_t *dsp_addr16 = dsp_addr;
-		uint16_t tmp = *dsp_addr16++;
-		rtos_task_id = (tmp & ADSP_RTOS_READ_CTRL_WORD_TASK_ID_M) >> 8;
-		msg_id = tmp & ADSP_RTOS_READ_CTRL_WORD_MSG_ID_M;
-		read_event_size = *dsp_addr16++;
-		read_event_addr = dsp_addr16;
-		msg_length = read_event_size * sizeof(uint16_t);
-		func = read_event_16;
-	}
-
-	if (rtos_task_id > info->max_task_id) {
-		MM_ERR("bogus task id %d\n", rtos_task_id);
-		return 0;
-	}
-	module = find_adsp_module_by_id(info,
-					adsp_get_module(info, rtos_task_id));
-
-	if (!module) {
-		MM_ERR("no module for task id %d\n", rtos_task_id);
-		return 0;
-	}
-
-	module->num_events++;
-
-	if (!module->ops) {
-		MM_ERR("module %s is not open\n", module->name);
-		return 0;
-	}
-#ifdef CONFIG_DEBUG_FS
-	if (rdump > 0 &&
-		(dsp_addr >= (void *)(MSM_AD5_BASE + QDSP_RAMC_OFFSET))) {
-		ptr32 = read_event_addr;
-		pr_info("D->A\n");
-		pr_info("m_id = %x id = %x\n", module->id, msg_id);
-		for (ii = 0; ii < msg_length/4; ii++)
-			pr_info("%x ", ptr32[ii]);
-		pr_info("\n");
-	} else if (rdump > 0) {
-		ptr16 = read_event_addr;
-		pr_info("D->A\n");
-		pr_info("m_id = %x id = %x\n", module->id, msg_id);
-		for (ii = 0; ii < msg_length/2; ii++)
-			pr_info("%x ", ptr16[ii]);
-		pr_info("\n");
-	}
-#endif /* CONFIG_DEBUG_FS */
-
-	module->ops->event(module->driver_data, msg_id, msg_length, func);
-	return 0;
-}
-
-static int adsp_get_event(struct adsp_info *info)
-{
-	uint32_t ctrl_word;
-	uint32_t ready;
-	void *dsp_addr;
-	uint32_t cmd_type;
-	int cnt;
-	unsigned long flags;
-	int rc = 0;
-
-	spin_lock_irqsave(&adsp_cmd_lock, flags);
-
-	/* Whenever the DSP has a message, it updates this control word
-	 * and generates an interrupt.  When we receive the interrupt, we
-	 * read this register to find out what ADSP task the command is
-	 * comming from.
-	 *
-	 * The ADSP should *always* be ready on the first call, but the
-	 * irq handler calls us in a loop (to handle back-to-back command
-	 * processing), so we give the DSP some time to return to the
-	 * ready state.  The DSP will not issue another IRQ for events
-	 * pending between the first IRQ and the event queue being drained,
-	 * unfortunately.
-	 */
-
-	for (cnt = 0; cnt < 50; cnt++) {
-		ctrl_word = readl(info->read_ctrl);
-
-		if ((ctrl_word & ADSP_RTOS_READ_CTRL_WORD_FLAG_M) ==
-		    ADSP_RTOS_READ_CTRL_WORD_FLAG_UP_CONT_V)
-			goto ready;
-
-		udelay(2);
-	}
-	MM_ERR("not ready after 100uS\n");
-	rc = -EBUSY;
-	goto done;
-
-ready:
-	/* Here we check to see if there are pending messages. If there are
-	 * none, we siply return -EAGAIN to indicate that there are no more
-	 * messages pending.
-	 */
-	ready = ctrl_word & ADSP_RTOS_READ_CTRL_WORD_READY_M;
-	if ((ready != ADSP_RTOS_READ_CTRL_WORD_READY_V) &&
-	    (ready != ADSP_RTOS_READ_CTRL_WORD_CONT_V)) {
-		rc = -EAGAIN;
-		goto done;
-	}
-
-	/* DSP says that there are messages waiting for the host to read */
-
-	/* Get the Command Type */
-	cmd_type = ctrl_word & ADSP_RTOS_READ_CTRL_WORD_CMD_TYPE_M;
-
-	/* Get the DSP buffer address */
-	dsp_addr = (void *)((ctrl_word &
-			     ADSP_RTOS_READ_CTRL_WORD_DSP_ADDR_M) +
-			    (uint32_t)MSM_AD5_BASE);
-
-	/* We can only handle Task-to-Host messages */
-	if (cmd_type != ADSP_RTOS_READ_CTRL_WORD_CMD_TASK_TO_H_V) {
-		MM_ERR("unknown dsp cmd_type %d\n", cmd_type);
-		rc = -EIO;
-		goto done;
-	}
-
-	adsp_rtos_read_ctrl_word_cmd_tast_to_h_v(info, dsp_addr);
-
-	ctrl_word = readl(info->read_ctrl);
-	ctrl_word &= ~ADSP_RTOS_READ_CTRL_WORD_READY_M;
-
-	/* Write ctrl word to the DSP */
-	writel(ctrl_word, info->read_ctrl);
-
-	/* Generate an interrupt to the DSP */
-	writel(1, info->send_irq);
-
-done:
-	spin_unlock_irqrestore(&adsp_cmd_lock, flags);
-	return rc;
-}
-
-static irqreturn_t adsp_irq_handler(int irq, void *data)
-{
-	struct adsp_info *info = &adsp_info;
-	int cnt = 0;
-	for (cnt = 0; cnt < 15; cnt++)
-		if (adsp_get_event(info) < 0)
-			break;
-	if (cnt > info->event_backlog_max)
-		info->event_backlog_max = cnt;
-	info->events_received += cnt;
-	if (cnt == 15)
-		MM_ERR("too many (%d) events for single irq!\n", cnt);
-	return IRQ_HANDLED;
-}
-
-int adsp_set_clkrate(struct msm_adsp_module *module, unsigned long clk_rate)
-{
-	if (!module)
-		return -EINVAL;
-
-	if (module->clk && clk_rate)
-		return clk_set_rate(module->clk, clk_rate);
-
-	return -EINVAL;
-}
-
-int msm_adsp_generate_event(void *data,
-			struct msm_adsp_module *mod,
-			unsigned event_id,
-			unsigned event_length,
-			unsigned event_size,
-			void *msg)
-{
-	unsigned long flags;
-	void (*func)(void *, size_t);
-
-	if (!mod)
-		return -EINVAL;
-
-	if (event_size == sizeof(uint32_t))
-		func = read_event_32;
-	else if (event_size == sizeof(uint16_t))
-		func = read_event_16;
-	else
-		return -EINVAL;
-
-	spin_lock_irqsave(&adsp_cmd_lock, flags);
-	read_event_addr = msg;
-	read_event_size = event_length;
-	mod->ops->event(data, event_id, event_length, func);
-	spin_unlock_irqrestore(&adsp_cmd_lock, flags);
-	return 0;
-}
-
-int msm_adsp_dump(struct msm_adsp_module *module)
-{
-	int rc = 0;
-	if (!module) {
-		MM_INFO("Invalid module. Dumps are not collected\n");
-		return -EINVAL;
-	}
-	MM_INFO("starting DSP DUMP\n");
-	rc = rpc_adsp_rtos_app_to_modem(RPC_ADSP_RTOS_CMD_CORE_DUMP,
-			module->id, module);
-	MM_INFO("DSP DUMP done rc =%d\n", rc);
-	return rc;
-}
-EXPORT_SYMBOL(msm_adsp_dump);
-
-int msm_adsp_enable(struct msm_adsp_module *module)
-{
-	int rc = 0;
-	struct msm_adsp_module *module_en = NULL;
-
-	if (!module)
-		return -EINVAL;
-
-	MM_INFO("enable '%s'state[%d] id[%d]\n",
-				module->name, module->state, module->id);
-	if (!strncmp(module->name, "JPEGTASK", sizeof(module->name)))
-		module_en = find_adsp_module_by_name(&adsp_info, "VIDEOTASK");
-	else if (!strncmp(module->name, "VIDEOTASK", sizeof(module->name)))
-		module_en = find_adsp_module_by_name(&adsp_info, "JPEGTASK");
-	if (module_en) {
-		mutex_lock(&module_en->lock);
-		if (module_en->state == ADSP_STATE_ENABLED ||
-			module_en->state == ADSP_STATE_ENABLING) {
-			MM_ERR("both jpeg and video module can't"\
-				" exist at a time\n");
-			mutex_unlock(&module_en->lock);
-			return -EINVAL;
-		}
-		mutex_unlock(&module_en->lock);
-	}
-
-	mutex_lock(&module->lock);
-	switch (module->state) {
-	case ADSP_STATE_DISABLED:
-		rc = rpc_adsp_rtos_app_to_modem(RPC_ADSP_RTOS_CMD_ENABLE,
-						module->id, module);
-		if (rc)
-			break;
-		module->state = ADSP_STATE_ENABLING;
-		mutex_unlock(&module->lock);
-		rc = wait_event_timeout(module->state_wait,
-					module->state != ADSP_STATE_ENABLING,
-					1 * HZ);
-		mutex_lock(&module->lock);
-		if (module->state == ADSP_STATE_ENABLED) {
-			rc = 0;
-		} else {
-			MM_ERR("module '%s' enable timed out\n", module->name);
-			msm_adsp_dump(module);
-			rc = -ETIMEDOUT;
-		}
-		if (module->open_count++ == 0 && module->clk)
-			clk_prepare_enable(module->clk);
-
-		mutex_lock(&adsp_open_lock);
-		if (adsp_open_count++ == 0) {
-			enable_irq(adsp_info.int_adsp);
-			prevent_suspend();
-		}
-		mutex_unlock(&adsp_open_lock);
-		break;
-	case ADSP_STATE_ENABLING:
-		MM_DBG("module '%s' enable in progress\n", module->name);
-		break;
-	case ADSP_STATE_ENABLED:
-		MM_DBG("module '%s' already enabled\n", module->name);
-		break;
-	case ADSP_STATE_DISABLING:
-		MM_ERR("module '%s' disable in progress\n", module->name);
-		rc = -EBUSY;
-		break;
-	}
-	mutex_unlock(&module->lock);
-	return rc;
-}
-EXPORT_SYMBOL(msm_adsp_enable);
-
-int msm_adsp_disable_event_rsp(struct msm_adsp_module *module)
-{
-	int rc = 0;
-
-	if (!module)
-		return -EINVAL;
-
-	mutex_lock(&module->lock);
-
-	rc = rpc_adsp_rtos_app_to_modem(RPC_ADSP_RTOS_CMD_DISABLE_EVENT_RSP,
-							module->id, module);
-	mutex_unlock(&module->lock);
-
-	return rc;
-}
-EXPORT_SYMBOL(msm_adsp_disable_event_rsp);
-
-static int msm_adsp_disable_locked(struct msm_adsp_module *module)
-{
-	int rc = 0;
-
-	if (!module)
-		return -EINVAL;
-
-	switch (module->state) {
-	case ADSP_STATE_DISABLED:
-		MM_DBG("module '%s' already disabled\n", module->name);
-		break;
-	case ADSP_STATE_ENABLING:
-	case ADSP_STATE_ENABLED:
-		rc = rpc_adsp_rtos_app_to_modem(RPC_ADSP_RTOS_CMD_DISABLE,
-						module->id, module);
-		module->state = ADSP_STATE_DISABLED;
-		if (--module->open_count == 0 && module->clk)
-			clk_disable_unprepare(module->clk);
-		mutex_lock(&adsp_open_lock);
-		if (--adsp_open_count == 0) {
-			disable_irq(adsp_info.int_adsp);
-			allow_suspend();
-			MM_DBG("disable interrupt\n");
-		}
-		mutex_unlock(&adsp_open_lock);
-	}
-	return rc;
-}
-
-int msm_adsp_disable(struct msm_adsp_module *module)
-{
-	int rc;
-
-	if (!module)
-		return -EINVAL;
-
-	MM_INFO("disable '%s'\n", module->name);
-	mutex_lock(&module->lock);
-	rc = msm_adsp_disable_locked(module);
-	mutex_unlock(&module->lock);
-	return rc;
-}
-EXPORT_SYMBOL(msm_adsp_disable);
-
-static int msm_adsp_probe(struct platform_device *pdev)
-{
-	unsigned count;
-	int rc, i;
-
-	adsp_info.int_adsp = platform_get_irq(pdev, 0);
-	if (adsp_info.int_adsp < 0) {
-		MM_ERR("no irq resource?\n");
-		return -ENODEV;
-	}
-
-	wake_lock_init(&adsp_wake_lock, WAKE_LOCK_SUSPEND, "adsp");
-	adsp_info.init_info_ptr = kzalloc(
-		(sizeof(struct adsp_rtos_mp_mtoa_init_info_type)), GFP_KERNEL);
-	if (!adsp_info.init_info_ptr)
-		return -ENOMEM;
-
-	rc = adsp_init_info(&adsp_info);
-	if (rc)
-		return rc;
-	adsp_info.send_irq += (uint32_t) MSM_AD5_BASE;
-	adsp_info.read_ctrl += (uint32_t) MSM_AD5_BASE;
-	adsp_info.write_ctrl += (uint32_t) MSM_AD5_BASE;
-	count = adsp_info.module_count;
-
-	adsp_modules = kzalloc(
-		(sizeof(struct msm_adsp_module) + sizeof(void *)) *
-		count, GFP_KERNEL);
-	if (!adsp_modules)
-		return -ENOMEM;
-
-	adsp_info.id_to_module = (void *) (adsp_modules + count);
-
-	spin_lock_init(&adsp_cmd_lock);
-	spin_lock_init(&adsp_write_lock);
-	mutex_init(&adsp_info.lock);
-
-	rc = request_irq(adsp_info.int_adsp, adsp_irq_handler,
-			IRQF_TRIGGER_RISING, "adsp", 0);
-	if (rc < 0)
-		goto fail_request_irq;
-	disable_irq(adsp_info.int_adsp);
-
-	rpc_cb_server_client = msm_rpc_open();
-	if (IS_ERR(rpc_cb_server_client)) {
-		rpc_cb_server_client = NULL;
-		rc = PTR_ERR(rpc_cb_server_client);
-		MM_ERR("could not create rpc server (%d)\n", rc);
-		goto fail_rpc_open;
-	}
-
-	rc = msm_rpc_register_server(rpc_cb_server_client,
-				     rpc_adsp_rtos_mtoa_prog,
-				     rpc_adsp_rtos_mtoa_vers);
-	if (rc) {
-		MM_ERR("could not register callback server (%d)\n", rc);
-		goto fail_rpc_register;
-	}
-
-	/* schedule start of kernel thread later using work queue */
-	queue_work(msm_adsp_probe_work_queue, &msm_adsp_probe_work);
-
-	for (i = 0; i < count; i++) {
-		struct msm_adsp_module *mod = adsp_modules + i;
-		mutex_init(&mod->lock);
-		init_waitqueue_head(&mod->state_wait);
-		mod->info = &adsp_info;
-		mod->name = adsp_info.module[i].name;
-		mod->id = adsp_info.module[i].id;
-		if (adsp_info.module[i].clk_name)
-			mod->clk = clk_get(NULL, adsp_info.module[i].clk_name);
-		else
-			mod->clk = NULL;
-		if (mod->clk && adsp_info.module[i].clk_rate)
-			clk_set_rate(mod->clk, adsp_info.module[i].clk_rate);
-		mod->verify_cmd = adsp_info.module[i].verify_cmd;
-		mod->patch_event = adsp_info.module[i].patch_event;
-		INIT_HLIST_HEAD(&mod->ion_regions);
-		mod->pdev.name = adsp_info.module[i].pdev_name;
-		mod->pdev.id = -1;
-		adsp_info.id_to_module[i] = mod;
-		platform_device_register(&mod->pdev);
-	}
-
-	msm_adsp_publish_cdevs(adsp_modules, count);
-	rmtask_init();
-
-	return 0;
-
-fail_rpc_register:
-	msm_rpc_close(rpc_cb_server_client);
-	rpc_cb_server_client = NULL;
-fail_rpc_open:
-	enable_irq(adsp_info.int_adsp);
-	free_irq(adsp_info.int_adsp, 0);
-fail_request_irq:
-	kfree(adsp_modules);
-	kfree(adsp_info.init_info_ptr);
-	return rc;
-}
-
-static void adsp_probe_work(struct work_struct *work)
-{
-	/* start the kernel thread to process the callbacks */
-	kthread_run(adsp_rpc_thread, NULL, "kadspd");
-}
-
-#ifdef CONFIG_DEBUG_FS
-static int get_parameters(char *buf, long int *param1, int num_of_par)
-{
-	char *token;
-	int base, cnt;
-
-	token = strsep(&buf, " ");
-
-	for (cnt = 0; cnt < num_of_par; cnt++) {
-		if (token != NULL) {
-			if ((token[1] == 'x') || (token[1] == 'X'))
-				base = 16;
-			else
-				base = 10;
-
-			if (strict_strtoul(token, base, &param1[cnt]) != 0)
-				return -EINVAL;
-
-			token = strsep(&buf, " ");
-			}
-		else
-			return -EINVAL;
-	}
-	return 0;
-}
-
-
-static ssize_t adsp_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	pr_debug("adsp debugfs opened\n");
-	return 0;
-}
-static ssize_t adsp_debug_write(struct file *file, const char __user *buf,
-				size_t cnt, loff_t *ppos)
-{
-	char *access_str = file->private_data;
-	char lbuf[32];
-	int rc;
-	long int param[5];
-
-	if (cnt > sizeof(lbuf) - 1)
-		return -EINVAL;
-	rc = copy_from_user(lbuf, buf, cnt);
-	if (rc) {
-		pr_info("Unable to copy data from user space\n");
-		return -EFAULT;
-	}
-	lbuf[cnt] = '\0';
-
-	if (!strcmp(access_str, "write_log")) {
-		if (get_parameters(lbuf, param, 1) == 0) {
-			switch (param[0]) {
-			case 1:
-				if (wdump <= 0)
-					wdump = 1;
-				pr_debug("write cmd to DSP(A->D) dump \
-					 started:%d\n", wdump);
-				break;
-			case 0:
-				if (wdump > 0)
-					wdump = 0;
-				pr_debug("Stop write cmd to \
-					 DSP(A->D):%d\n", wdump);
-				break;
-			default:
-				rc = -EINVAL;
-				break;
-			}
-		} else
-			rc = -EINVAL;
-	} else if (!strcmp(access_str, "read_log")) {
-		if (get_parameters(lbuf, param, 1) == 0) {
-			switch (param[0]) {
-			case 1:
-				if (rdump <= 0)
-					rdump = 1;
-				pr_debug("write cmd from DSP(D->A) dump \
-					started:%d\n", wdump);
-				break;
-			case 0:
-				if (rdump > 0)
-					rdump = 0;
-				pr_debug("Stop write cmd from \
-					DSP(D->A):%d\n", wdump);
-				break;
-			default:
-				rc = -EINVAL;
-				break;
-			}
-		} else
-			rc = -EINVAL;
-	} else {
-		rc = -EINVAL;
-	}
-	if (rc == 0)
-		rc = cnt;
-	else {
-		pr_err("%s: rc = %d\n", __func__, rc);
-		pr_info("\nWrong command: Use =>\n");
-		pr_info("-------------------------\n");
-		pr_info("To Start A->D:: echo \"1\">/sys/kernel/debug/ \
-			adsp_cmd/write_log\n");
-		pr_info("To Start D->A:: echo \"1\">/sys/kernel/debug/ \
-			adsp_cmd/read_log\n");
-		pr_info("To Stop  A->D:: echo \"0\">/sys/kernel/debug/ \
-			adsp_cmd/write_log\n");
-		pr_info("To Stop  D->A:: echo \"0\">/sys/kernel/debug/ \
-			adsp_cmd/read_log\n");
-		pr_info("------------------------\n");
-	}
-
-	return rc;
-}
-#endif
-
-static struct platform_driver msm_adsp_driver = {
-	.probe = msm_adsp_probe,
-	.driver = {
-		.owner = THIS_MODULE,
-	},
-};
-
-static const char msm_adsp_driver_name[] = "msm_adsp";
-
-#ifdef CONFIG_DEBUG_FS
-static const struct file_operations adsp_debug_fops = {
-	.write = adsp_debug_write,
-	.open = adsp_debug_open,
-};
-#endif
-
-static int __init adsp_init(void)
-{
-	int rc;
-
-#ifdef CONFIG_DEBUG_FS
-	dentry_adsp    = debugfs_create_dir("adsp_cmd", 0);
-	if (!IS_ERR(dentry_adsp)) {
-		dentry_wdata   = debugfs_create_file("write_log", \
-		 S_IFREG | S_IRUGO, dentry_adsp,
-		 (void *) "write_log" , &adsp_debug_fops);
-		dentry_rdata   = debugfs_create_file("read_log", \
-		 S_IFREG | S_IRUGO, dentry_adsp,
-		 (void *) "read_log", &adsp_debug_fops);
-	}
-	rdump = 0;
-	wdump = 0;
-#endif /* CONFIG_DEBUG_FS */
-
-	rpc_adsp_rtos_atom_prog = 0x3000000a;
-	rpc_adsp_rtos_atom_vers = 0x10001;
-	rpc_adsp_rtos_atom_vers_comp = 0x00010001;
-	rpc_adsp_rtos_mtoa_prog = 0x3000000b;
-#if CONFIG_ADSP_RPC_VER > 0x30001
-	rpc_adsp_rtos_mtoa_vers = 0x30002;
-	rpc_adsp_rtos_mtoa_vers_comp = 0x00030002;
-#else
-	rpc_adsp_rtos_mtoa_vers = 0x30001;
-	rpc_adsp_rtos_mtoa_vers_comp = 0x00030001;
-#endif
-
-	msm_adsp_probe_work_queue = create_workqueue("msm_adsp_probe");
-	if (msm_adsp_probe_work_queue == NULL)
-		return -ENOMEM;
-	msm_adsp_driver.driver.name = msm_adsp_driver_name;
-	rc = platform_driver_register(&msm_adsp_driver);
-	MM_INFO("%s -- %d\n", msm_adsp_driver_name, rc);
-	return rc;
-}
-
-device_initcall(adsp_init);
diff --git a/arch/arm/mach-msm/qdsp5/adsp.h b/arch/arm/mach-msm/qdsp5/adsp.h
deleted file mode 100644
index 0922d88..0000000
--- a/arch/arm/mach-msm/qdsp5/adsp.h
+++ /dev/null
@@ -1,361 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/adsp.h
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (c) 2008-2010, 2012 The Linux Foundation. All rights reserved.
- * Author: Iliyan Malchev <ibm@android.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#ifndef _ARCH_ARM_MACH_MSM_ADSP_H
-#define _ARCH_ARM_MACH_MSM_ADSP_H
-
-#include <linux/types.h>
-#include <linux/msm_adsp.h>
-#include <linux/msm_ion.h>
-#include <mach/msm_rpcrouter.h>
-#include <mach/msm_adsp.h>
-
-int adsp_pmem_fixup(struct msm_adsp_module *module, void **addr,
-		    unsigned long len);
-int adsp_ion_do_cache_op(struct msm_adsp_module *module, void *addr,
-			void *paddr, unsigned long len,
-			unsigned long offset, int cmd);
-int adsp_ion_fixup_kvaddr(struct msm_adsp_module *module, void **addr,
-			   unsigned long *kvaddr, unsigned long len,
-			   struct file **filp, unsigned long *offset);
-int adsp_pmem_paddr_fixup(struct msm_adsp_module *module, void **addr);
-
-int adsp_vfe_verify_cmd(struct msm_adsp_module *module,
-			unsigned int queue_id, void *cmd_data,
-			size_t cmd_size);
-int adsp_jpeg_verify_cmd(struct msm_adsp_module *module,
-			 unsigned int queue_id, void *cmd_data,
-			 size_t cmd_size);
-int adsp_lpm_verify_cmd(struct msm_adsp_module *module,
-			unsigned int queue_id, void *cmd_data,
-			size_t cmd_size);
-int adsp_video_verify_cmd(struct msm_adsp_module *module,
-			  unsigned int queue_id, void *cmd_data,
-			  size_t cmd_size);
-int adsp_videoenc_verify_cmd(struct msm_adsp_module *module,
-			  unsigned int queue_id, void *cmd_data,
-			  size_t cmd_size);
-void q5audio_dsp_not_responding(void);
-
-struct adsp_event;
-
-int adsp_vfe_patch_event(struct msm_adsp_module *module,
-			struct adsp_event *event);
-
-int adsp_jpeg_patch_event(struct msm_adsp_module *module,
-			struct adsp_event *event);
-
-
-struct adsp_module_info {
-	const char *name;
-	const char *pdev_name;
-	uint32_t id;
-	const char *clk_name;
-	unsigned long clk_rate;
-	int (*verify_cmd) (struct msm_adsp_module*, unsigned int, void *,
-			   size_t);
-	int (*patch_event) (struct msm_adsp_module*, struct adsp_event *);
-};
-
-#define ADSP_EVENT_MAX_SIZE 496
-#define EVENT_LEN       12
-#define EVENT_MSG_ID ((uint16_t)~0)
-
-struct adsp_event {
-	struct list_head list;
-	uint32_t size; /* always in bytes */
-	uint16_t msg_id;
-	uint16_t type; /* 0 for msgs (from aDSP), -1 for events (from ARM9) */
-	int is16; /* always 0 (msg is 32-bit) when the event type is 1(ARM9) */
-	union {
-		uint16_t msg16[ADSP_EVENT_MAX_SIZE / 2];
-		uint32_t msg32[ADSP_EVENT_MAX_SIZE / 4];
-	} data;
-};
-
-struct adsp_info {
-	uint32_t send_irq;
-	uint32_t read_ctrl;
-	uint32_t write_ctrl;
-
-	uint32_t max_msg16_size;
-	uint32_t max_msg32_size;
-
-	uint32_t max_task_id;
-	uint32_t max_module_id;
-	uint32_t max_queue_id;
-	uint32_t max_image_id;
-
-	/* for each image id, a map of queue id to offset */
-	uint32_t **queue_offset;
-
-	/* for each image id, a map of task id to module id */
-	uint32_t **task_to_module;
-
-	/* for each module id, map of module id to module */
-	struct msm_adsp_module **id_to_module;
-
-	uint32_t module_count;
-	struct adsp_module_info *module;
-
-	/* stats */
-	uint32_t events_received;
-	uint32_t event_backlog_max;
-
-	/* rpc_client for init_info */
-	struct msm_rpc_endpoint	*init_info_rpc_client;
-	struct adsp_rtos_mp_mtoa_init_info_type	*init_info_ptr;
-	wait_queue_head_t	init_info_wait;
-	unsigned 		init_info_state;
-	struct mutex lock;
-
-	/* Interrupt value */
-	int int_adsp;
-};
-
-#define RPC_ADSP_RTOS_ATOM_NULL_PROC 0
-#define RPC_ADSP_RTOS_MTOA_NULL_PROC 0
-#define RPC_ADSP_RTOS_APP_TO_MODEM_PROC 2
-#define RPC_ADSP_RTOS_MODEM_TO_APP_PROC 2
-#define RPC_ADSP_RTOS_MTOA_EVENT_INFO_PROC 3
-#define RPC_ADSP_RTOS_MTOA_INIT_INFO_PROC 4
-
-enum rpc_adsp_rtos_proc_type {
-	RPC_ADSP_RTOS_PROC_NONE = 0,
-	RPC_ADSP_RTOS_PROC_MODEM = 1,
-	RPC_ADSP_RTOS_PROC_APPS = 2,
-};
-
-enum {
-	RPC_ADSP_RTOS_CMD_REGISTER_APP,
-	RPC_ADSP_RTOS_CMD_ENABLE,
-	RPC_ADSP_RTOS_CMD_DISABLE,
-	RPC_ADSP_RTOS_CMD_KERNEL_COMMAND,
-	RPC_ADSP_RTOS_CMD_16_COMMAND,
-	RPC_ADSP_RTOS_CMD_32_COMMAND,
-	RPC_ADSP_RTOS_CMD_DISABLE_EVENT_RSP,
-	RPC_ADSP_RTOS_CMD_REMOTE_EVENT,
-	RPC_ADSP_RTOS_CMD_SET_STATE,
-	RPC_ADSP_RTOS_CMD_REMOTE_INIT_INFO_EVENT,
-	RPC_ADSP_RTOS_CMD_GET_INIT_INFO,
-	RPC_ADSP_RTOS_CMD_CORE_DUMP,
-};
-
-enum rpc_adsp_rtos_mod_status_type {
-	RPC_ADSP_RTOS_MOD_READY,
-	RPC_ADSP_RTOS_MOD_DISABLE,
-	RPC_ADSP_RTOS_SERVICE_RESET,
-	RPC_ADSP_RTOS_CMD_FAIL,
-	RPC_ADSP_RTOS_CMD_SUCCESS,
-	RPC_ADSP_RTOS_INIT_INFO,
-	RPC_ADSP_RTOS_DISABLE_FAIL,
-};
-
-struct rpc_adsp_rtos_app_to_modem_args_t {
-	struct rpc_request_hdr hdr;
-	uint32_t gotit; /* if 1, the next elements are present */
-	uint32_t cmd; /* e.g., RPC_ADSP_RTOS_CMD_REGISTER_APP */
-	uint32_t proc_id; /* e.g., RPC_ADSP_RTOS_PROC_APPS */
-	uint32_t module; /* e.g., QDSP_MODULE_AUDPPTASK */
-};
-
-enum qdsp_image_type {
-	QDSP_IMAGE_COMBO,
-	QDSP_IMAGE_GAUDIO,
-	QDSP_IMAGE_QTV_LP,
-	QDSP_IMAGE_MAX,
-	/* DO NOT USE: Force this enum to be a 32bit type to improve speed */
-	QDSP_IMAGE_32BIT_DUMMY = 0x10000
-};
-
-struct adsp_rtos_mp_mtoa_header_type {
-	enum rpc_adsp_rtos_mod_status_type  event;
-	enum rpc_adsp_rtos_proc_type        proc_id;
-};
-
-/* ADSP RTOS MP Communications - Modem to APP's  Event Info*/
-struct adsp_rtos_mp_mtoa_type {
-	uint32_t	module;
-	uint32_t	image;
-	uint32_t	apps_okts;
-};
-
-/* ADSP RTOS MP Communications - Modem to APP's Init Info  */
-#if CONFIG_ADSP_RPC_VER > 0x30001
-#define IMG_MAX         2
-#define ENTRIES_MAX     36
-#define MODULES_MAX     64
-#else
-#define IMG_MAX         6
-#define ENTRIES_MAX     48
-#endif
-#define QUEUES_MAX      64
-
-struct queue_to_offset_type {
-	uint32_t	queue;
-	uint32_t	offset;
-};
-
-struct mod_to_queue_offsets {
-	uint32_t        module;
-	uint32_t        q_type;
-	uint32_t        q_max_len;
-};
-
-struct adsp_rtos_mp_mtoa_init_info_type {
-	uint32_t	image_count;
-	uint32_t	num_queue_offsets;
-	struct queue_to_offset_type	queue_offsets_tbl[IMG_MAX][ENTRIES_MAX];
-	uint32_t	num_task_module_entries;
-	uint32_t	task_to_module_tbl[IMG_MAX][ENTRIES_MAX];
-
-	uint32_t	module_table_size;
-#if CONFIG_ADSP_RPC_VER > 0x30001
-	uint32_t	module_entries[MODULES_MAX];
-#else
-	uint32_t	module_entries[ENTRIES_MAX];
-#endif
-	uint32_t	mod_to_q_entries;
-	struct mod_to_queue_offsets	mod_to_q_tbl[ENTRIES_MAX];
-	/*
-	 * queue_offsets[] is to store only queue_offsets
-	 */
-	uint32_t	queue_offsets[IMG_MAX][QUEUES_MAX];
-};
-
-struct adsp_rtos_mp_mtoa_s_type {
-	struct adsp_rtos_mp_mtoa_header_type mp_mtoa_header;
-#if CONFIG_ADSP_RPC_VER == 0x30001
-	uint32_t desc_field;
-#endif
-	union {
-		struct adsp_rtos_mp_mtoa_init_info_type mp_mtoa_init_packet;
-		struct adsp_rtos_mp_mtoa_type mp_mtoa_packet;
-	} adsp_rtos_mp_mtoa_data;
-};
-
-struct rpc_adsp_rtos_modem_to_app_args_t {
-	struct rpc_request_hdr hdr;
-	uint32_t gotit; /* if 1, the next elements are present */
-	struct adsp_rtos_mp_mtoa_s_type mtoa_pkt;
-};
-
-#define ADSP_STATE_DISABLED   0
-#define ADSP_STATE_ENABLING   1
-#define ADSP_STATE_ENABLED    2
-#define ADSP_STATE_DISABLING  3
-#define ADSP_STATE_INIT_INFO  4
-
-struct msm_adsp_module {
-	struct mutex lock;
-	const char *name;
-	unsigned id;
-	struct adsp_info *info;
-
-	struct msm_rpc_endpoint *rpc_client;
-	struct msm_adsp_ops *ops;
-	void *driver_data;
-
-	/* statistics */
-	unsigned num_commands;
-	unsigned num_events;
-
-	wait_queue_head_t state_wait;
-	unsigned state;
-
-	struct platform_device pdev;
-	struct clk *clk;
-	int open_count;
-
-	struct mutex ion_regions_lock;
-	struct hlist_head ion_regions;
-	int (*verify_cmd) (struct msm_adsp_module*, unsigned int, void *,
-			   size_t);
-	int (*patch_event) (struct msm_adsp_module*, struct adsp_event *);
-};
-
-extern void msm_adsp_publish_cdevs(struct msm_adsp_module *, unsigned);
-extern int adsp_init_info(struct adsp_info *info);
-extern void rmtask_init(void);
-
-/* Value to indicate that a queue is not defined for a particular image */
-#define QDSP_RTOS_NO_QUEUE  0xfffffffe
-
-/*
- * Constants used to communicate with the ADSP RTOS
- */
-#define ADSP_RTOS_WRITE_CTRL_WORD_MUTEX_M            0x80000000U
-#define ADSP_RTOS_WRITE_CTRL_WORD_MUTEX_NAVAIL_V     0x80000000U
-#define ADSP_RTOS_WRITE_CTRL_WORD_MUTEX_AVAIL_V      0x00000000U
-
-#define ADSP_RTOS_WRITE_CTRL_WORD_CMD_M              0x70000000U
-#define ADSP_RTOS_WRITE_CTRL_WORD_CMD_WRITE_REQ_V    0x00000000U
-#define ADSP_RTOS_WRITE_CTRL_WORD_CMD_WRITE_DONE_V   0x10000000U
-#define ADSP_RTOS_WRITE_CTRL_WORD_CMD_NO_CMD_V       0x70000000U
-
-#define ADSP_RTOS_WRITE_CTRL_WORD_STATUS_M           0x0E000000U
-#define ADSP_RTOS_WRITE_CTRL_WORD_NO_ERR_V           0x00000000U
-#define ADSP_RTOS_WRITE_CTRL_WORD_NO_FREE_BUF_V      0x02000000U
-
-#define ADSP_RTOS_WRITE_CTRL_WORD_KERNEL_FLG_M       0x01000000U
-#define ADSP_RTOS_WRITE_CTRL_WORD_HTOD_MSG_WRITE_V   0x00000000U
-#define ADSP_RTOS_WRITE_CTRL_WORD_HTOD_CMD_V         0x01000000U
-
-#define ADSP_RTOS_WRITE_CTRL_WORD_DSP_ADDR_M         0x00FFFFFFU
-#define ADSP_RTOS_WRITE_CTRL_WORD_HTOD_CMD_ID_M      0x00FFFFFFU
-
-/* Combination of MUTEX and CMD bits to check if the DSP is busy */
-#define ADSP_RTOS_WRITE_CTRL_WORD_READY_M            0xF0000000U
-#define ADSP_RTOS_WRITE_CTRL_WORD_READY_V            0x70000000U
-
-/* RTOS to Host processor command mask values */
-#define ADSP_RTOS_READ_CTRL_WORD_FLAG_M              0x80000000U
-#define ADSP_RTOS_READ_CTRL_WORD_FLAG_UP_WAIT_V      0x00000000U
-#define ADSP_RTOS_READ_CTRL_WORD_FLAG_UP_CONT_V      0x80000000U
-
-#define ADSP_RTOS_READ_CTRL_WORD_CMD_M               0x60000000U
-#define ADSP_RTOS_READ_CTRL_WORD_READ_DONE_V         0x00000000U
-#define ADSP_RTOS_READ_CTRL_WORD_READ_REQ_V          0x20000000U
-#define ADSP_RTOS_READ_CTRL_WORD_NO_CMD_V            0x60000000U
-
-/* Combination of FLAG and COMMAND bits to check if MSG ready */
-#define ADSP_RTOS_READ_CTRL_WORD_READY_M             0xE0000000U
-#define ADSP_RTOS_READ_CTRL_WORD_READY_V             0xA0000000U
-#define ADSP_RTOS_READ_CTRL_WORD_CONT_V              0xC0000000U
-#define ADSP_RTOS_READ_CTRL_WORD_DONE_V              0xE0000000U
-
-#define ADSP_RTOS_READ_CTRL_WORD_STATUS_M            0x18000000U
-#define ADSP_RTOS_READ_CTRL_WORD_NO_ERR_V            0x00000000U
-
-#define ADSP_RTOS_READ_CTRL_WORD_IN_PROG_M           0x04000000U
-#define ADSP_RTOS_READ_CTRL_WORD_NO_READ_IN_PROG_V   0x00000000U
-#define ADSP_RTOS_READ_CTRL_WORD_READ_IN_PROG_V      0x04000000U
-
-#define ADSP_RTOS_READ_CTRL_WORD_CMD_TYPE_M          0x03000000U
-#define ADSP_RTOS_READ_CTRL_WORD_CMD_TASK_TO_H_V     0x00000000U
-#define ADSP_RTOS_READ_CTRL_WORD_CMD_KRNL_TO_H_V     0x01000000U
-#define ADSP_RTOS_READ_CTRL_WORD_CMD_H_TO_KRNL_CFM_V 0x02000000U
-
-#define ADSP_RTOS_READ_CTRL_WORD_DSP_ADDR_M          0x00FFFFFFU
-
-#define ADSP_RTOS_READ_CTRL_WORD_MSG_ID_M            0x000000FFU
-#define ADSP_RTOS_READ_CTRL_WORD_TASK_ID_M           0x0000FF00U
-
-/* Base address of DSP and DSP hardware registers */
-#define QDSP_RAMC_OFFSET  0x400000
-
-#endif
diff --git a/arch/arm/mach-msm/qdsp5/adsp_6210.c b/arch/arm/mach-msm/qdsp5/adsp_6210.c
deleted file mode 100644
index bf69ce2..0000000
--- a/arch/arm/mach-msm/qdsp5/adsp_6210.c
+++ /dev/null
@@ -1,283 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/adsp_6210.h
- *
- * Copyright (c) 2008-2009, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include "adsp.h"
-
-/* Firmware modules */
-typedef enum { 
-	QDSP_MODULE_KERNEL,
-	QDSP_MODULE_AFETASK,
-	QDSP_MODULE_AUDPLAY0TASK,
-	QDSP_MODULE_AUDPLAY1TASK,
-	QDSP_MODULE_AUDPPTASK,
-	QDSP_MODULE_VIDEOTASK,
-	QDSP_MODULE_VIDEO_AAC_VOC,
-	QDSP_MODULE_PCM_DEC,
-	QDSP_MODULE_AUDIO_DEC_MP3,
-	QDSP_MODULE_AUDIO_DEC_AAC,
-	QDSP_MODULE_AUDIO_DEC_WMA,
-	QDSP_MODULE_HOSTPCM,
-	QDSP_MODULE_DTMF,
-	QDSP_MODULE_AUDRECTASK,
-	QDSP_MODULE_AUDPREPROCTASK,
-	QDSP_MODULE_SBC_ENC,
-	QDSP_MODULE_VOC,
-	QDSP_MODULE_VOC_PCM,
-	QDSP_MODULE_VOCENCTASK,
-	QDSP_MODULE_VOCDECTASK,
-	QDSP_MODULE_VOICEPROCTASK,
-	QDSP_MODULE_VIDEOENCTASK,
-	QDSP_MODULE_VFETASK,
-	QDSP_MODULE_WAV_ENC,
-	QDSP_MODULE_AACLC_ENC,
-	QDSP_MODULE_VIDEO_AMR,
-	QDSP_MODULE_VOC_AMR,
-	QDSP_MODULE_VOC_EVRC,
-	QDSP_MODULE_VOC_13K,
-	QDSP_MODULE_VOC_FGV,
-	QDSP_MODULE_DIAGTASK,
-	QDSP_MODULE_JPEGTASK,
-	QDSP_MODULE_LPMTASK,
-	QDSP_MODULE_QCAMTASK,
-	QDSP_MODULE_MODMATHTASK,
-	QDSP_MODULE_AUDPLAY2TASK,
-	QDSP_MODULE_AUDPLAY3TASK,
-	QDSP_MODULE_AUDPLAY4TASK,
-	QDSP_MODULE_GRAPHICSTASK,
-	QDSP_MODULE_MIDI,
-	QDSP_MODULE_GAUDIO,
-	QDSP_MODULE_VDEC_LP_MODE,
-	QDSP_MODULE_MAX,
-} qdsp_module_type;
-
-#define QDSP_RTOS_MAX_TASK_ID  19U
-
-/* Table of modules indexed by task ID for the GAUDIO image */
-static qdsp_module_type qdsp_gaudio_task_to_module_table[] = {
-	QDSP_MODULE_KERNEL,
-	QDSP_MODULE_AFETASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_AUDPPTASK,
-	QDSP_MODULE_AUDPLAY0TASK,
-	QDSP_MODULE_AUDPLAY1TASK,
-	QDSP_MODULE_AUDPLAY2TASK,
-	QDSP_MODULE_AUDPLAY3TASK,
-	QDSP_MODULE_AUDPLAY4TASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_AUDRECTASK,
-	QDSP_MODULE_AUDPREPROCTASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_GRAPHICSTASK,
-	QDSP_MODULE_MAX
-};
-
-/* Queue offset table indexed by queue ID for the GAUDIO image */
-static uint32_t qdsp_gaudio_queue_offset_table[] = {
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_lpmCommandQueue              */
-	0x3be,               /* QDSP_mpuAfeQueue                  */
-	0x3ee,               /* QDSP_mpuGraphicsCmdQueue          */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_mpuModmathCmdQueue           */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_mpuVDecCmdQueue              */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_mpuVDecPktQueue              */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_mpuVEncCmdQueue              */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_rxMpuDecCmdQueue             */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_rxMpuDecPktQueue             */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_txMpuEncQueue                */
-	0x3c2,               /* QDSP_uPAudPPCmd1Queue             */
-	0x3c6,               /* QDSP_uPAudPPCmd2Queue             */
-	0x3ca,               /* QDSP_uPAudPPCmd3Queue             */
-	0x3da,               /* QDSP_uPAudPlay0BitStreamCtrlQueue */
-	0x3de,               /* QDSP_uPAudPlay1BitStreamCtrlQueue */
-	0x3e2,               /* QDSP_uPAudPlay2BitStreamCtrlQueue */
-	0x3e6,               /* QDSP_uPAudPlay3BitStreamCtrlQueue */
-	0x3ea,               /* QDSP_uPAudPlay4BitStreamCtrlQueue */
-	0x3ce,               /* QDSP_uPAudPreProcCmdQueue         */
-	0x3d6,               /* QDSP_uPAudRecBitStreamQueue       */
-	0x3d2,               /* QDSP_uPAudRecCmdQueue             */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPJpegActionCmdQueue         */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPJpegCfgCmdQueue            */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPVocProcQueue               */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_vfeCommandQueue              */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_vfeCommandScaleQueue         */
-	QDSP_RTOS_NO_QUEUE   /* QDSP_vfeCommandTableQueue         */
-};
-
-/* Table of modules indexed by task ID for the COMBO image */
-static qdsp_module_type qdsp_combo_task_to_module_table[] = {
-	QDSP_MODULE_KERNEL,
-	QDSP_MODULE_AFETASK,
-	QDSP_MODULE_VOCDECTASK,
-	QDSP_MODULE_VOCENCTASK,
-	QDSP_MODULE_VIDEOTASK,
-	QDSP_MODULE_VIDEOENCTASK,
-	QDSP_MODULE_VOICEPROCTASK,
-	QDSP_MODULE_VFETASK,
-	QDSP_MODULE_JPEGTASK,
-	QDSP_MODULE_AUDPPTASK,
-	QDSP_MODULE_AUDPLAY0TASK,
-	QDSP_MODULE_AUDPLAY1TASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_LPMTASK,
-	QDSP_MODULE_AUDRECTASK,
-	QDSP_MODULE_AUDPREPROCTASK,
-	QDSP_MODULE_MODMATHTASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX
-};
-
-/* Queue offset table indexed by queue ID for the COMBO image */
-static uint32_t qdsp_combo_queue_offset_table[] = {
-	0x585,               /* QDSP_lpmCommandQueue              */
-	0x52d,               /* QDSP_mpuAfeQueue                  */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_mpuGraphicsCmdQueue          */
-	0x541,               /* QDSP_mpuModmathCmdQueue           */
-	0x555,               /* QDSP_mpuVDecCmdQueue              */
-	0x559,               /* QDSP_mpuVDecPktQueue              */
-	0x551,               /* QDSP_mpuVEncCmdQueue              */
-	0x535,               /* QDSP_rxMpuDecCmdQueue             */
-	0x539,               /* QDSP_rxMpuDecPktQueue             */
-	0x53d,               /* QDSP_txMpuEncQueue                */
-	0x55d,               /* QDSP_uPAudPPCmd1Queue             */
-	0x561,               /* QDSP_uPAudPPCmd2Queue             */
-	0x565,               /* QDSP_uPAudPPCmd3Queue             */
-	0x575,               /* QDSP_uPAudPlay0BitStreamCtrlQueue */
-	0x579,               /* QDSP_uPAudPlay1BitStreamCtrlQueue */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPAudPlay2BitStreamCtrlQueue */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPAudPlay3BitStreamCtrlQueue */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPAudPlay4BitStreamCtrlQueue */
-	0x569,               /* QDSP_uPAudPreProcCmdQueue         */
-	0x571,               /* QDSP_uPAudRecBitStreamQueue       */
-	0x56d,               /* QDSP_uPAudRecCmdQueue             */
-	0x581,               /* QDSP_uPJpegActionCmdQueue         */
-	0x57d,               /* QDSP_uPJpegCfgCmdQueue            */
-	0x531,               /* QDSP_uPVocProcQueue               */
-	0x545,               /* QDSP_vfeCommandQueue              */
-	0x54d,               /* QDSP_vfeCommandScaleQueue         */
-	0x549                /* QDSP_vfeCommandTableQueue         */
-};
-
-/* Table of modules indexed by task ID for the QTV_LP image */
-static qdsp_module_type qdsp_qtv_lp_task_to_module_table[] = {
-	QDSP_MODULE_KERNEL,
-	QDSP_MODULE_AFETASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_VIDEOTASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_AUDPPTASK,
-	QDSP_MODULE_AUDPLAY0TASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_AUDRECTASK,
-	QDSP_MODULE_AUDPREPROCTASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX
-};
-
-/* Queue offset table indexed by queue ID for the QTV_LP image */
-static uint32_t qdsp_qtv_lp_queue_offset_table[] = {
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_lpmCommandQueue              */
-	0x40c,               /* QDSP_mpuAfeQueue                  */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_mpuGraphicsCmdQueue          */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_mpuModmathCmdQueue           */
-	0x410,               /* QDSP_mpuVDecCmdQueue              */
-	0x414,               /* QDSP_mpuVDecPktQueue              */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_mpuVEncCmdQueue              */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_rxMpuDecCmdQueue             */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_rxMpuDecPktQueue             */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_txMpuEncQueue                */
-	0x41c,               /* QDSP_uPAudPPCmd1Queue             */
-	0x420,               /* QDSP_uPAudPPCmd2Queue             */
-	0x424,               /* QDSP_uPAudPPCmd3Queue             */
-	0x430,               /* QDSP_uPAudPlay0BitStreamCtrlQueue */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPAudPlay1BitStreamCtrlQueue */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPAudPlay2BitStreamCtrlQueue */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPAudPlay3BitStreamCtrlQueue */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPAudPlay4BitStreamCtrlQueue */
-	0x418,               /* QDSP_uPAudPreProcCmdQueue         */
-	0x42c,               /* QDSP_uPAudRecBitStreamQueue       */
-	0x428,               /* QDSP_uPAudRecCmdQueue             */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPJpegActionCmdQueue         */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPJpegCfgCmdQueue            */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPVocProcQueue               */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_vfeCommandQueue              */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_vfeCommandScaleQueue         */
-	QDSP_RTOS_NO_QUEUE   /* QDSP_vfeCommandTableQueue         */
-};
-
-/* Tables to convert tasks to modules */
-static uint32_t *qdsp_task_to_module[] = {
-	qdsp_combo_task_to_module_table,
-	qdsp_gaudio_task_to_module_table,
-	qdsp_qtv_lp_task_to_module_table,
-};
-
-/* Tables to retrieve queue offsets */
-static uint32_t *qdsp_queue_offset_table[] = {
-	qdsp_combo_queue_offset_table,
-	qdsp_gaudio_queue_offset_table,
-	qdsp_qtv_lp_queue_offset_table,
-};
-
-#define QDSP_MODULE(n) \
-	{ .name = #n, .pdev_name = "adsp_" #n, .id = QDSP_MODULE_##n }
-
-static struct adsp_module_info module_info[] = {
-	QDSP_MODULE(AUDPPTASK),
-	QDSP_MODULE(AUDRECTASK),
-	QDSP_MODULE(AUDPREPROCTASK),
-	QDSP_MODULE(VFETASK),
-	QDSP_MODULE(QCAMTASK),
-	QDSP_MODULE(LPMTASK),
-	QDSP_MODULE(JPEGTASK),
-	QDSP_MODULE(VIDEOTASK),
-	QDSP_MODULE(VDEC_LP_MODE),
-};
-
-int adsp_init_info(struct adsp_info *info)
-{
-	info->send_irq =   0x00c00200;
-	info->read_ctrl =  0x00400038;
-	info->write_ctrl = 0x00400034;
-
-	info->max_msg16_size = 193;
-	info->max_msg32_size = 8;
-
-	info->max_task_id = 16;
-	info->max_module_id = QDSP_MODULE_MAX - 1;
-	info->max_queue_id = QDSP_QUEUE_MAX;
-	info->max_image_id = 2;
-	info->queue_offset = qdsp_queue_offset_table;
-	info->task_to_module = qdsp_task_to_module;
-
-	info->module_count = ARRAY_SIZE(module_info);
-	info->module = module_info;
-	return 0;
-}
diff --git a/arch/arm/mach-msm/qdsp5/adsp_6220.c b/arch/arm/mach-msm/qdsp5/adsp_6220.c
deleted file mode 100644
index 0073790..0000000
--- a/arch/arm/mach-msm/qdsp5/adsp_6220.c
+++ /dev/null
@@ -1,284 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/adsp_6220.h
- *
- * Copyright (c) 2008-2009, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include "adsp.h"
-
-/* Firmware modules */
-typedef enum { 
-	QDSP_MODULE_KERNEL,
-	QDSP_MODULE_AFETASK,
-	QDSP_MODULE_AUDPLAY0TASK,
-	QDSP_MODULE_AUDPLAY1TASK,
-	QDSP_MODULE_AUDPPTASK,
-	QDSP_MODULE_VIDEOTASK,
-	QDSP_MODULE_VIDEO_AAC_VOC,
-	QDSP_MODULE_PCM_DEC,
-	QDSP_MODULE_AUDIO_DEC_MP3,
-	QDSP_MODULE_AUDIO_DEC_AAC,
-	QDSP_MODULE_AUDIO_DEC_WMA,
-	QDSP_MODULE_HOSTPCM,
-	QDSP_MODULE_DTMF,
-	QDSP_MODULE_AUDRECTASK,
-	QDSP_MODULE_AUDPREPROCTASK,
-	QDSP_MODULE_SBC_ENC,
-	QDSP_MODULE_VOC,
-	QDSP_MODULE_VOC_PCM,
-	QDSP_MODULE_VOCENCTASK,
-	QDSP_MODULE_VOCDECTASK,
-	QDSP_MODULE_VOICEPROCTASK,
-	QDSP_MODULE_VIDEOENCTASK,
-	QDSP_MODULE_VFETASK,
-	QDSP_MODULE_WAV_ENC,
-	QDSP_MODULE_AACLC_ENC,
-	QDSP_MODULE_VIDEO_AMR,
-	QDSP_MODULE_VOC_AMR,
-	QDSP_MODULE_VOC_EVRC,
-	QDSP_MODULE_VOC_13K,
-	QDSP_MODULE_VOC_FGV,
-	QDSP_MODULE_DIAGTASK,
-	QDSP_MODULE_JPEGTASK,
-	QDSP_MODULE_LPMTASK,
-	QDSP_MODULE_QCAMTASK,
-	QDSP_MODULE_MODMATHTASK,
-	QDSP_MODULE_AUDPLAY2TASK,
-	QDSP_MODULE_AUDPLAY3TASK,
-	QDSP_MODULE_AUDPLAY4TASK,
-	QDSP_MODULE_GRAPHICSTASK,
-	QDSP_MODULE_MIDI,
-	QDSP_MODULE_GAUDIO,
-	QDSP_MODULE_VDEC_LP_MODE,
-	QDSP_MODULE_MAX,
-} qdsp_module_type;
-
-#define QDSP_RTOS_MAX_TASK_ID  19U
-
-/* Table of modules indexed by task ID for the GAUDIO image */
-static qdsp_module_type qdsp_gaudio_task_to_module_table[] = {
-	QDSP_MODULE_KERNEL,
-	QDSP_MODULE_AFETASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_AUDPPTASK,
-	QDSP_MODULE_AUDPLAY0TASK,
-	QDSP_MODULE_AUDPLAY1TASK,
-	QDSP_MODULE_AUDPLAY2TASK,
-	QDSP_MODULE_AUDPLAY3TASK,
-	QDSP_MODULE_AUDPLAY4TASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_AUDRECTASK,
-	QDSP_MODULE_AUDPREPROCTASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_GRAPHICSTASK,
-	QDSP_MODULE_MAX
-};
-
-/* Queue offset table indexed by queue ID for the GAUDIO image */
-static uint32_t qdsp_gaudio_queue_offset_table[] = {
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_lpmCommandQueue              */
-	0x3f0,               /* QDSP_mpuAfeQueue                  */
-	0x420,               /* QDSP_mpuGraphicsCmdQueue          */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_mpuModmathCmdQueue           */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_mpuVDecCmdQueue              */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_mpuVDecPktQueue              */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_mpuVEncCmdQueue              */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_rxMpuDecCmdQueue             */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_rxMpuDecPktQueue             */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_txMpuEncQueue                */
-	0x3f4,               /* QDSP_uPAudPPCmd1Queue             */
-	0x3f8,               /* QDSP_uPAudPPCmd2Queue             */
-	0x3fc,               /* QDSP_uPAudPPCmd3Queue             */
-	0x40c,               /* QDSP_uPAudPlay0BitStreamCtrlQueue */
-	0x410,               /* QDSP_uPAudPlay1BitStreamCtrlQueue */
-	0x414,               /* QDSP_uPAudPlay2BitStreamCtrlQueue */
-	0x418,               /* QDSP_uPAudPlay3BitStreamCtrlQueue */
-	0x41c,               /* QDSP_uPAudPlay4BitStreamCtrlQueue */
-	0x400,               /* QDSP_uPAudPreProcCmdQueue         */
-	0x408,               /* QDSP_uPAudRecBitStreamQueue       */
-	0x404,               /* QDSP_uPAudRecCmdQueue             */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPJpegActionCmdQueue         */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPJpegCfgCmdQueue            */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPVocProcQueue               */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_vfeCommandQueue              */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_vfeCommandScaleQueue         */
-	QDSP_RTOS_NO_QUEUE   /* QDSP_vfeCommandTableQueue         */
-};
-
-/* Table of modules indexed by task ID for the COMBO image */
-static qdsp_module_type qdsp_combo_task_to_module_table[] = {
-	QDSP_MODULE_KERNEL,
-	QDSP_MODULE_AFETASK,
-	QDSP_MODULE_VOCDECTASK,
-	QDSP_MODULE_VOCENCTASK,
-	QDSP_MODULE_VIDEOTASK,
-	QDSP_MODULE_VIDEOENCTASK,
-	QDSP_MODULE_VOICEPROCTASK,
-	QDSP_MODULE_VFETASK,
-	QDSP_MODULE_JPEGTASK,
-	QDSP_MODULE_AUDPPTASK,
-	QDSP_MODULE_AUDPLAY0TASK,
-	QDSP_MODULE_AUDPLAY1TASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_LPMTASK,
-	QDSP_MODULE_AUDRECTASK,
-	QDSP_MODULE_AUDPREPROCTASK,
-	QDSP_MODULE_MODMATHTASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX
-};
-
-/* Queue offset table indexed by queue ID for the COMBO image */
-static uint32_t qdsp_combo_queue_offset_table[] = {
-	0x6f2,               /* QDSP_lpmCommandQueue              */
-	0x69e,               /* QDSP_mpuAfeQueue                  */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_mpuGraphicsCmdQueue          */
-	0x6b2,               /* QDSP_mpuModmathCmdQueue           */
-	0x6c6,               /* QDSP_mpuVDecCmdQueue              */
-	0x6ca,               /* QDSP_mpuVDecPktQueue              */
-	0x6c2,               /* QDSP_mpuVEncCmdQueue              */
-	0x6a6,               /* QDSP_rxMpuDecCmdQueue             */
-	0x6aa,               /* QDSP_rxMpuDecPktQueue             */
-	0x6ae,               /* QDSP_txMpuEncQueue                */
-	0x6ce,               /* QDSP_uPAudPPCmd1Queue             */
-	0x6d2,               /* QDSP_uPAudPPCmd2Queue             */
-	0x6d6,               /* QDSP_uPAudPPCmd3Queue             */
-	0x6e6,               /* QDSP_uPAudPlay0BitStreamCtrlQueue */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPAudPlay1BitStreamCtrlQueue */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPAudPlay2BitStreamCtrlQueue */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPAudPlay3BitStreamCtrlQueue */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPAudPlay4BitStreamCtrlQueue */
-	0x6da,               /* QDSP_uPAudPreProcCmdQueue         */
-	0x6e2,               /* QDSP_uPAudRecBitStreamQueue       */
-	0x6de,               /* QDSP_uPAudRecCmdQueue             */
-	0x6ee,               /* QDSP_uPJpegActionCmdQueue         */
-	0x6ea,               /* QDSP_uPJpegCfgCmdQueue            */
-	0x6a2,               /* QDSP_uPVocProcQueue               */
-	0x6b6,               /* QDSP_vfeCommandQueue              */
-	0x6be,               /* QDSP_vfeCommandScaleQueue         */
-	0x6ba                /* QDSP_vfeCommandTableQueue         */
-};
-
-/* Table of modules indexed by task ID for the QTV_LP image */
-static qdsp_module_type qdsp_qtv_lp_task_to_module_table[] = {
-	QDSP_MODULE_KERNEL,
-	QDSP_MODULE_AFETASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_VIDEOTASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_AUDPPTASK,
-	QDSP_MODULE_AUDPLAY0TASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_AUDRECTASK,
-	QDSP_MODULE_AUDPREPROCTASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX
-};
-
-/* Queue offset table indexed by queue ID for the QTV_LP image */
-static uint32_t qdsp_qtv_lp_queue_offset_table[] = {
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_lpmCommandQueue              */
-	0x430,               /* QDSP_mpuAfeQueue                  */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_mpuGraphicsCmdQueue          */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_mpuModmathCmdQueue           */
-	0x434,               /* QDSP_mpuVDecCmdQueue              */
-	0x438,               /* QDSP_mpuVDecPktQueue              */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_mpuVEncCmdQueue              */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_rxMpuDecCmdQueue             */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_rxMpuDecPktQueue             */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_txMpuEncQueue                */
-	0x440,               /* QDSP_uPAudPPCmd1Queue             */
-	0x444,               /* QDSP_uPAudPPCmd2Queue             */
-	0x448,               /* QDSP_uPAudPPCmd3Queue             */
-	0x454,               /* QDSP_uPAudPlay0BitStreamCtrlQueue */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPAudPlay1BitStreamCtrlQueue */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPAudPlay2BitStreamCtrlQueue */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPAudPlay3BitStreamCtrlQueue */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPAudPlay4BitStreamCtrlQueue */
-	0x43c,               /* QDSP_uPAudPreProcCmdQueue         */
-	0x450,               /* QDSP_uPAudRecBitStreamQueue       */
-	0x44c,               /* QDSP_uPAudRecCmdQueue             */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPJpegActionCmdQueue         */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPJpegCfgCmdQueue            */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPVocProcQueue               */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_vfeCommandQueue              */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_vfeCommandScaleQueue         */
-	QDSP_RTOS_NO_QUEUE   /* QDSP_vfeCommandTableQueue         */
-};
-
-/* Tables to convert tasks to modules */
-static qdsp_module_type *qdsp_task_to_module[] = {
-	qdsp_combo_task_to_module_table,
-	qdsp_gaudio_task_to_module_table,
-	qdsp_qtv_lp_task_to_module_table,
-};
-
-/* Tables to retrieve queue offsets */
-static uint32_t *qdsp_queue_offset_table[] = {
-	qdsp_combo_queue_offset_table,
-	qdsp_gaudio_queue_offset_table,
-	qdsp_qtv_lp_queue_offset_table,
-};
-
-#define QDSP_MODULE(n) \
-	{ .name = #n, .pdev_name = "adsp_" #n, .id = QDSP_MODULE_##n }
-
-static struct adsp_module_info module_info[] = {
-	QDSP_MODULE(AUDPLAY0TASK),
-	QDSP_MODULE(AUDPPTASK),
-	QDSP_MODULE(AUDPREPROCTASK),
-	QDSP_MODULE(AUDRECTASK),
-	QDSP_MODULE(VFETASK),
-	QDSP_MODULE(QCAMTASK),
-	QDSP_MODULE(LPMTASK),
-	QDSP_MODULE(JPEGTASK),
-	QDSP_MODULE(VIDEOTASK),
-	QDSP_MODULE(VDEC_LP_MODE),
-};
-
-int adsp_init_info(struct adsp_info *info)
-{
-	info->send_irq =   0x00c00200;
-	info->read_ctrl =  0x00400038;
-	info->write_ctrl = 0x00400034;
-
-	info->max_msg16_size = 193;
-	info->max_msg32_size = 8;
-
-	info->max_task_id = 16;
-	info->max_module_id = QDSP_MODULE_MAX - 1;
-	info->max_queue_id = QDSP_QUEUE_MAX;
-	info->max_image_id = 2;
-	info->queue_offset = qdsp_queue_offset_table;
-	info->task_to_module = qdsp_task_to_module;
-
-	info->module_count = ARRAY_SIZE(module_info);
-	info->module = module_info;
-	return 0;
-}
diff --git a/arch/arm/mach-msm/qdsp5/adsp_6225.c b/arch/arm/mach-msm/qdsp5/adsp_6225.c
deleted file mode 100644
index 6a402b7..0000000
--- a/arch/arm/mach-msm/qdsp5/adsp_6225.c
+++ /dev/null
@@ -1,328 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/adsp_6225.h
- *
- * Copyright (c) 2008-2009, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include "adsp.h"
-
-/* Firmware modules */
-typedef enum {
-	QDSP_MODULE_KERNEL,
-	QDSP_MODULE_AFETASK,
-	QDSP_MODULE_AUDPLAY0TASK,
-	QDSP_MODULE_AUDPLAY1TASK,
-	QDSP_MODULE_AUDPPTASK,
-	QDSP_MODULE_VIDEOTASK,
-	QDSP_MODULE_VIDEO_AAC_VOC,
-	QDSP_MODULE_PCM_DEC,
-	QDSP_MODULE_AUDIO_DEC_MP3,
-	QDSP_MODULE_AUDIO_DEC_AAC,
-	QDSP_MODULE_AUDIO_DEC_WMA,
-	QDSP_MODULE_HOSTPCM,
-	QDSP_MODULE_DTMF,
-	QDSP_MODULE_AUDRECTASK,
-	QDSP_MODULE_AUDPREPROCTASK,
-	QDSP_MODULE_SBC_ENC,
-	QDSP_MODULE_VOC_UMTS,
-	QDSP_MODULE_VOC_CDMA,
-	QDSP_MODULE_VOC_PCM,
-	QDSP_MODULE_VOCENCTASK,
-	QDSP_MODULE_VOCDECTASK,
-	QDSP_MODULE_VOICEPROCTASK,
-	QDSP_MODULE_VIDEOENCTASK,
-	QDSP_MODULE_VFETASK,
-	QDSP_MODULE_WAV_ENC,
-	QDSP_MODULE_AACLC_ENC,
-	QDSP_MODULE_VIDEO_AMR,
-	QDSP_MODULE_VOC_AMR,
-	QDSP_MODULE_VOC_EVRC,
-	QDSP_MODULE_VOC_13K,
-	QDSP_MODULE_VOC_FGV,
-	QDSP_MODULE_DIAGTASK,
-	QDSP_MODULE_JPEGTASK,
-	QDSP_MODULE_LPMTASK,
-	QDSP_MODULE_QCAMTASK,
-	QDSP_MODULE_MODMATHTASK,
-	QDSP_MODULE_AUDPLAY2TASK,
-	QDSP_MODULE_AUDPLAY3TASK,
-	QDSP_MODULE_AUDPLAY4TASK,
-	QDSP_MODULE_GRAPHICSTASK,
-	QDSP_MODULE_MIDI,
-	QDSP_MODULE_GAUDIO,
-	QDSP_MODULE_VDEC_LP_MODE,
-	QDSP_MODULE_MAX,
-} qdsp_module_type;
-
-#define QDSP_RTOS_MAX_TASK_ID  30U
-
-/* Table of modules indexed by task ID for the GAUDIO image */
-static qdsp_module_type qdsp_gaudio_task_to_module_table[] = {
-	QDSP_MODULE_KERNEL,
-	QDSP_MODULE_AFETASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_AUDPPTASK,
-	QDSP_MODULE_AUDPLAY0TASK,
-	QDSP_MODULE_AUDPLAY1TASK,
-	QDSP_MODULE_AUDPLAY2TASK,
-	QDSP_MODULE_AUDPLAY3TASK,
-	QDSP_MODULE_AUDPLAY4TASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_AUDRECTASK,
-	QDSP_MODULE_AUDPREPROCTASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_GRAPHICSTASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-};
-
-/* Queue offset table indexed by queue ID for the GAUDIO image */
-static uint32_t qdsp_gaudio_queue_offset_table[] = {
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_lpmCommandQueue              */
-	0x3f0,               /* QDSP_mpuAfeQueue                  */
-	0x420,               /* QDSP_mpuGraphicsCmdQueue          */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_mpuModmathCmdQueue           */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_mpuVDecCmdQueue              */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_mpuVDecPktQueue              */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_mpuVEncCmdQueue              */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_rxMpuDecCmdQueue             */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_rxMpuDecPktQueue             */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_txMpuEncQueue                */
-	0x3f4,               /* QDSP_uPAudPPCmd1Queue             */
-	0x3f8,               /* QDSP_uPAudPPCmd2Queue             */
-	0x3fc,               /* QDSP_uPAudPPCmd3Queue             */
-	0x40c,               /* QDSP_uPAudPlay0BitStreamCtrlQueue */
-	0x410,               /* QDSP_uPAudPlay1BitStreamCtrlQueue */
-	0x414,               /* QDSP_uPAudPlay2BitStreamCtrlQueue */
-	0x418,               /* QDSP_uPAudPlay3BitStreamCtrlQueue */
-	0x41c,               /* QDSP_uPAudPlay4BitStreamCtrlQueue */
-	0x400,               /* QDSP_uPAudPreProcCmdQueue         */
-	0x408,               /* QDSP_uPAudRecBitStreamQueue       */
-	0x404,               /* QDSP_uPAudRecCmdQueue             */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPJpegActionCmdQueue         */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPJpegCfgCmdQueue            */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPVocProcQueue               */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_vfeCommandQueue              */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_vfeCommandScaleQueue         */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_vfeCommandTableQueue         */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPDiagQueue                  */
-};
-
-/* Table of modules indexed by task ID for the COMBO image */
-static qdsp_module_type qdsp_combo_task_to_module_table[] = {
-	QDSP_MODULE_KERNEL,
-	QDSP_MODULE_AFETASK,
-	QDSP_MODULE_VOCDECTASK,
-	QDSP_MODULE_VOCENCTASK,
-	QDSP_MODULE_VIDEOTASK,
-	QDSP_MODULE_VIDEOENCTASK,
-	QDSP_MODULE_VOICEPROCTASK,
-	QDSP_MODULE_VFETASK,
-	QDSP_MODULE_JPEGTASK,
-	QDSP_MODULE_AUDPPTASK,
-	QDSP_MODULE_AUDPLAY0TASK,
-	QDSP_MODULE_AUDPLAY1TASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_LPMTASK,
-	QDSP_MODULE_AUDRECTASK,
-	QDSP_MODULE_AUDPREPROCTASK,
-	QDSP_MODULE_MODMATHTASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_DIAGTASK,
-	QDSP_MODULE_MAX,
-};
-
-/* Queue offset table indexed by queue ID for the COMBO image */
-static uint32_t qdsp_combo_queue_offset_table[] = {
-	0x714,               /* QDSP_lpmCommandQueue              */
-	0x6bc,               /* QDSP_mpuAfeQueue                  */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_mpuGraphicsCmdQueue          */
-	0x6d0,               /* QDSP_mpuModmathCmdQueue           */
-	0x6e8,               /* QDSP_mpuVDecCmdQueue              */
-	0x6ec,               /* QDSP_mpuVDecPktQueue              */
-	0x6e4,               /* QDSP_mpuVEncCmdQueue              */
-	0x6c4,               /* QDSP_rxMpuDecCmdQueue             */
-	0x6c8,               /* QDSP_rxMpuDecPktQueue             */
-	0x6cc,               /* QDSP_txMpuEncQueue                */
-	0x6f0,               /* QDSP_uPAudPPCmd1Queue             */
-	0x6f4,               /* QDSP_uPAudPPCmd2Queue             */
-	0x6f8,               /* QDSP_uPAudPPCmd3Queue             */
-	0x708,               /* QDSP_uPAudPlay0BitStreamCtrlQueue */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPAudPlay1BitStreamCtrlQueue */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPAudPlay2BitStreamCtrlQueue */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPAudPlay3BitStreamCtrlQueue */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPAudPlay4BitStreamCtrlQueue */
-	0x6fc,               /* QDSP_uPAudPreProcCmdQueue         */
-	0x704,               /* QDSP_uPAudRecBitStreamQueue       */
-	0x700,               /* QDSP_uPAudRecCmdQueue             */
-	0x710,               /* QDSP_uPJpegActionCmdQueue         */
-	0x70c,               /* QDSP_uPJpegCfgCmdQueue            */
-	0x6c0,               /* QDSP_uPVocProcQueue               */
-	0x6d8,               /* QDSP_vfeCommandQueue              */
-	0x6e0,               /* QDSP_vfeCommandScaleQueue         */
-	0x6dc,               /* QDSP_vfeCommandTableQueue         */
-	0x6d4,               /* QDSP_uPDiagQueue                  */
-};
-
-/* Table of modules indexed by task ID for the QTV_LP image */
-static qdsp_module_type qdsp_qtv_lp_task_to_module_table[] = {
-	QDSP_MODULE_KERNEL,
-	QDSP_MODULE_AFETASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_VIDEOTASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_AUDPPTASK,
-	QDSP_MODULE_AUDPLAY0TASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_AUDRECTASK,
-	QDSP_MODULE_AUDPREPROCTASK,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-	QDSP_MODULE_MAX,
-};
-
-/* Queue offset table indexed by queue ID for the QTV_LP image */
-static uint32_t qdsp_qtv_lp_queue_offset_table[] = {
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_lpmCommandQueue              */
-	0x3fe,               /* QDSP_mpuAfeQueue                  */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_mpuGraphicsCmdQueue          */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_mpuModmathCmdQueue           */
-	0x402,               /* QDSP_mpuVDecCmdQueue              */
-	0x406,               /* QDSP_mpuVDecPktQueue              */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_mpuVEncCmdQueue              */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_rxMpuDecCmdQueue             */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_rxMpuDecPktQueue             */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_txMpuEncQueue                */
-	0x40e,               /* QDSP_uPAudPPCmd1Queue             */
-	0x412,               /* QDSP_uPAudPPCmd2Queue             */
-	0x416,               /* QDSP_uPAudPPCmd3Queue             */
-	0x422,               /* QDSP_uPAudPlay0BitStreamCtrlQueue */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPAudPlay1BitStreamCtrlQueue */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPAudPlay2BitStreamCtrlQueue */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPAudPlay3BitStreamCtrlQueue */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPAudPlay4BitStreamCtrlQueue */
-	0x40a,               /* QDSP_uPAudPreProcCmdQueue         */
-	0x41e,               /* QDSP_uPAudRecBitStreamQueue       */
-	0x41a,               /* QDSP_uPAudRecCmdQueue             */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPJpegActionCmdQueue         */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPJpegCfgCmdQueue            */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPVocProcQueue               */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_vfeCommandQueue              */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_vfeCommandScaleQueue         */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_vfeCommandTableQueue         */
-	QDSP_RTOS_NO_QUEUE,  /* QDSP_uPDiagQueue                  */
-};
-
-/* Tables to convert tasks to modules */
-static qdsp_module_type *qdsp_task_to_module[] = {
-	qdsp_combo_task_to_module_table,
-	qdsp_gaudio_task_to_module_table,
-	qdsp_qtv_lp_task_to_module_table,
-};
-
-/* Tables to retrieve queue offsets */
-static uint32_t *qdsp_queue_offset_table[] = {
-	qdsp_combo_queue_offset_table,
-	qdsp_gaudio_queue_offset_table,
-	qdsp_qtv_lp_queue_offset_table,
-};
-
-#define QDSP_MODULE(n, clkname, clkrate, verify_cmd_func, patch_event_func) \
-	{ .name = #n, .pdev_name = "adsp_" #n, .id = QDSP_MODULE_##n, \
-	  .clk_name = clkname, .clk_rate = clkrate, \
-	  .verify_cmd = verify_cmd_func, .patch_event = patch_event_func }
-
-static struct adsp_module_info module_info[] = {
-	QDSP_MODULE(AUDPLAY0TASK, NULL, 0, NULL, NULL),
-	QDSP_MODULE(AUDPPTASK, NULL, 0, NULL, NULL),
-	QDSP_MODULE(AUDRECTASK, NULL, 0, NULL, NULL),
-	QDSP_MODULE(AUDPREPROCTASK, NULL, 0, NULL, NULL),
-	QDSP_MODULE(VFETASK, "vfe_clk", 0, adsp_vfe_verify_cmd,
-		adsp_vfe_patch_event),
-	QDSP_MODULE(QCAMTASK, NULL, 0, NULL, NULL),
-	QDSP_MODULE(LPMTASK, NULL, 0, adsp_lpm_verify_cmd, NULL),
-	QDSP_MODULE(JPEGTASK, "vdc_clk", 0, adsp_jpeg_verify_cmd,
-		adsp_jpeg_patch_event),
-	QDSP_MODULE(VIDEOTASK, "vdc_clk", 96000000,
-		adsp_video_verify_cmd, NULL),
-	QDSP_MODULE(VDEC_LP_MODE, NULL, 0, NULL, NULL),
-	QDSP_MODULE(VIDEOENCTASK, "vdc_clk", 96000000,
-		adsp_videoenc_verify_cmd, NULL),
-};
-
-int adsp_init_info(struct adsp_info *info)
-{
-	info->send_irq =   0x00c00200;
-	info->read_ctrl =  0x00400038;
-	info->write_ctrl = 0x00400034;
-
-	info->max_msg16_size = 193;
-	info->max_msg32_size = 8;
-
-	info->max_task_id = 16;
-	info->max_module_id = QDSP_MODULE_MAX - 1;
-	info->max_queue_id = QDSP_QUEUE_MAX;
-	info->max_image_id = 2;
-	info->queue_offset = qdsp_queue_offset_table;
-	info->task_to_module = qdsp_task_to_module;
-
-	info->module_count = ARRAY_SIZE(module_info);
-	info->module = module_info;
-	return 0;
-}
diff --git a/arch/arm/mach-msm/qdsp5/adsp_debug.c b/arch/arm/mach-msm/qdsp5/adsp_debug.c
deleted file mode 100644
index ccddd43..0000000
--- a/arch/arm/mach-msm/qdsp5/adsp_debug.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301, USA.
- */
-
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/errno.h>
-#include <linux/fs.h>
-#include <linux/kernel.h>
-#include <linux/list.h>
-#include <linux/module.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/spinlock.h>
-#include <linux/string.h>
-#include <linux/types.h>
-#include <linux/uaccess.h>
-#include <linux/wait.h>
-
-#include <mach/debug_mm.h>
-#include <mach/msm_smd.h>
-
-#include "adsp.h"
-
-#define MAX_LEN 64
-#ifdef CONFIG_DEBUG_FS
-static struct dentry *adsp_dentry;
-#endif
-static char l_buf[MAX_LEN];
-static unsigned int crash_enable;
-
-static ssize_t q5_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	MM_DBG("q5 debugfs opened\n");
-	return 0;
-}
-
-static ssize_t q5_debug_write(struct file *file, const char __user *buf,
-				size_t count, loff_t *ppos)
-{
-	int len;
-
-	if (count < 0)
-		return 0;
-	len = count > (MAX_LEN - 1) ? (MAX_LEN - 1) : count;
-	if (copy_from_user(l_buf, buf, len)) {
-		MM_INFO("Unable to copy data from user space\n");
-		return -EFAULT;
-	}
-	l_buf[len] = 0;
-	if (l_buf[len - 1] == '\n') {
-		l_buf[len - 1] = 0;
-		len--;
-	}
-	if (!strncmp(l_buf, "boom", MAX_LEN)) {
-		q5audio_dsp_not_responding();
-	} else if (!strncmp(l_buf, "enable", MAX_LEN)) {
-		crash_enable = 1;
-		MM_INFO("Crash enabled : %d\n", crash_enable);
-	} else if (!strncmp(l_buf, "disable", MAX_LEN)) {
-		crash_enable = 0;
-		MM_INFO("Crash disabled : %d\n", crash_enable);
-	} else
-		MM_INFO("Unknown Command\n");
-
-	return count;
-}
-
-static const struct file_operations q5_debug_fops = {
-	.write = q5_debug_write,
-	.open = q5_debug_open,
-};
-
-static int __init q5_debug_init(void)
-{
-#ifdef CONFIG_DEBUG_FS
-	adsp_dentry = debugfs_create_file("q5_debug", S_IFREG | S_IRUGO,
-				NULL, (void *) NULL, &q5_debug_fops);
-#endif /* CONFIG_DEBUG_FS */
-	return 0;
-}
-device_initcall(q5_debug_init);
-
diff --git a/arch/arm/mach-msm/qdsp5/adsp_driver.c b/arch/arm/mach-msm/qdsp5/adsp_driver.c
deleted file mode 100644
index eb9c388..0000000
--- a/arch/arm/mach-msm/qdsp5/adsp_driver.c
+++ /dev/null
@@ -1,744 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/adsp_driver.c
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (c) 2009, 2012 The Linux Foundation. All rights reserved.
- * Author: Iliyan Malchev <ibm@android.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/cdev.h>
-#include <linux/fs.h>
-#include <linux/list.h>
-#include <linux/platform_device.h>
-#include <linux/sched.h>
-#include <linux/uaccess.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include "adsp.h"
-#include <linux/msm_adsp.h>
-#include <mach/debug_mm.h>
-
-struct adsp_ion_info {
-	int fd;
-	void *vaddr;
-};
-
-struct adsp_ion_region {
-	struct hlist_node list;
-	void *vaddr;
-	unsigned long paddr;
-	unsigned long kvaddr;
-	unsigned long len;
-	unsigned long ion_flag;
-	struct file *file;
-	struct ion_handle *handle;
-	struct ion_client *client;
-	int fd;
-};
-
-struct adsp_device {
-	struct msm_adsp_module *module;
-
-	spinlock_t event_queue_lock;
-	wait_queue_head_t event_wait;
-	struct list_head event_queue;
-	int abort;
-
-	const char *name;
-	struct device *device;
-	struct cdev cdev;
-};
-
-static struct adsp_device *inode_to_device(struct inode *inode);
-
-#define __CONTAINS(r, v, l) ({					\
-	typeof(r) __r = r;					\
-	typeof(v) __v = v;					\
-	typeof(v) __e = __v + l;				\
-	int res = __v >= __r->vaddr && 				\
-		__e <= __r->vaddr + __r->len;			\
-	res;							\
-})
-
-#define CONTAINS(r1, r2) ({					\
-	typeof(r2) __r2 = r2;					\
-	__CONTAINS(r1, __r2->vaddr, __r2->len);			\
-})
-
-#define IN_RANGE(r, v) ({					\
-	typeof(r) __r = r;					\
-	typeof(v) __vv = v;					\
-	int res = ((__vv >= __r->vaddr) &&			\
-		(__vv < (__r->vaddr + __r->len)));		\
-	res;							\
-})
-
-#define OVERLAPS(r1, r2) ({					\
-	typeof(r1) __r1 = r1;					\
-	typeof(r2) __r2 = r2;					\
-	typeof(__r2->vaddr) __v = __r2->vaddr;			\
-	typeof(__v) __e = __v + __r2->len - 1;			\
-	int res = (IN_RANGE(__r1, __v) || IN_RANGE(__r1, __e));	\
-	res;							\
-})
-
-static int adsp_ion_check(struct msm_adsp_module *module,
-		void *vaddr, unsigned long len)
-{
-	struct adsp_ion_region *region_elt;
-	struct hlist_node *node;
-	struct adsp_ion_region t = { .vaddr = vaddr, .len = len };
-
-	hlist_for_each_entry(region_elt, node, &module->ion_regions, list) {
-		if (CONTAINS(region_elt, &t) || CONTAINS(&t, region_elt) ||
-		    OVERLAPS(region_elt, &t)) {
-			MM_ERR("module %s:"
-				" region (vaddr %p len %ld)"
-				" clashes with registered region"
-				" (vaddr %p paddr %p len %ld)\n",
-				module->name,
-				vaddr, len,
-				region_elt->vaddr,
-				(void *)region_elt->paddr,
-				region_elt->len);
-			return -EINVAL;
-		}
-	}
-
-	return 0;
-}
-
-static int get_ion_region_info(int fd, struct adsp_ion_region *region)
-{
-	unsigned long ionflag;
-	void *temp_ptr;
-	int rc = -EINVAL;
-
-	region->client = msm_ion_client_create(UINT_MAX, "Video_Client");
-	if (IS_ERR_OR_NULL(region->client)) {
-		pr_err("Unable to create ION client\n");
-		goto client_error;
-	}
-	region->handle = ion_import_dma_buf(region->client, fd);
-	if (IS_ERR_OR_NULL(region->handle)) {
-		pr_err("%s: could not get handle of the given fd\n", __func__);
-		goto import_error;
-	}
-	rc = ion_handle_get_flags(region->client, region->handle, &ionflag);
-	if (rc) {
-		pr_err("%s: could not get flags for the handle\n", __func__);
-		goto flag_error;
-	}
-	temp_ptr = ion_map_kernel(region->client, region->handle);
-	if (IS_ERR_OR_NULL(temp_ptr)) {
-		pr_err("%s: could not get virtual address\n", __func__);
-		goto map_error;
-	}
-	region->kvaddr = (unsigned long) temp_ptr;
-	region->ion_flag = (unsigned long) ionflag;
-
-	rc = ion_phys(region->client, region->handle, &region->paddr,
-					(size_t *)(&region->len));
-	if (rc) {
-		pr_err("%s: could not get physical address\n", __func__);
-		goto ion_error;
-	}
-	return rc;
-ion_error:
-	ion_unmap_kernel(region->client, region->handle);
-map_error:
-	ion_free(region->client, region->handle);
-flag_error:
-import_error:
-	ion_client_destroy(region->client);
-client_error:
-	return -EINVAL;
-}
-
-static void free_ion_region(struct ion_client *client,
-			struct ion_handle *handle)
-{
-	ion_unmap_kernel(client, handle);
-	ion_free(client, handle);
-	ion_client_destroy(client);
-}
-
-static int adsp_ion_add(struct msm_adsp_module *module,
-			 struct adsp_ion_info *info)
-{
-	struct adsp_ion_region *region;
-	int rc = -EINVAL;
-	mutex_lock(&module->ion_regions_lock);
-	region = kmalloc(sizeof(struct adsp_ion_region), GFP_KERNEL);
-	if (!region) {
-		rc = -ENOMEM;
-		goto end;
-	}
-	INIT_HLIST_NODE(&region->list);
-	if (get_ion_region_info(info->fd, region)) {
-		kfree(region);
-		goto end;
-	}
-
-	rc = adsp_ion_check(module, info->vaddr, region->len);
-	if (rc < 0) {
-		free_ion_region(region->client, region->handle);
-		kfree(region);
-		goto end;
-	}
-	region->vaddr = info->vaddr;
-	region->fd = info->fd;
-	region->file = NULL;
-	MM_INFO("adsp_ion_add: module %s: fd %d, vaddr Ox%x, len %d\n",
-			module->name, region->fd, (unsigned int)region->vaddr,
-			(int)region->len);
-	hlist_add_head(&region->list, &module->ion_regions);
-end:
-	mutex_unlock(&module->ion_regions_lock);
-	return rc;
-}
-
-static int adsp_ion_lookup_vaddr(struct msm_adsp_module *module, void **addr,
-		     unsigned long len, struct adsp_ion_region **region)
-{
-	struct hlist_node *node;
-	void *vaddr = *addr;
-	struct adsp_ion_region *region_elt;
-
-	int match_count = 0;
-
-	*region = NULL;
-
-	/* returns physical address or zero */
-	hlist_for_each_entry(region_elt, node, &module->ion_regions, list) {
-		if (vaddr >= region_elt->vaddr &&
-		    vaddr < region_elt->vaddr + region_elt->len &&
-		    vaddr + len <= region_elt->vaddr + region_elt->len) {
-			/* offset since we could pass vaddr inside a registerd
-			 * pmem buffer
-			 */
-
-			match_count++;
-			if (!*region)
-				*region = region_elt;
-		}
-	}
-
-	if (match_count > 1) {
-		MM_ERR("module %s: "
-			"multiple hits for vaddr %p, len %ld\n",
-			module->name, vaddr, len);
-		hlist_for_each_entry(region_elt, node,
-				&module->ion_regions, list) {
-			if (vaddr >= region_elt->vaddr &&
-			    vaddr < region_elt->vaddr + region_elt->len &&
-			    vaddr + len <= region_elt->vaddr + region_elt->len)
-				MM_ERR("%p, %ld --> %p\n",
-					region_elt->vaddr,
-					region_elt->len,
-					(void *)region_elt->paddr);
-		}
-	}
-
-	return *region ? 0 : -1;
-}
-
-int adsp_ion_do_cache_op(struct msm_adsp_module *module,
-				void *addr, void *paddr, unsigned long len,
-				unsigned long offset, int cmd)
-{
-	struct adsp_ion_region   *region;
-	void *vaddr = addr;
-	int ret;
-	ret = adsp_ion_lookup_vaddr(module, &vaddr, len, &region);
-	if (ret) {
-		MM_ERR("not patching %s (paddr & kvaddr)," \
-			" lookup (%p, %ld) failed\n",
-			module->name, vaddr, len);
-		return ret;
-	}
-	if ((region->ion_flag == ION_FLAG_CACHED) && region->handle) {
-		len = ((((len) + 31) & (~31)) + 32);
-		ret = msm_ion_do_cache_op(region->client, region->handle,
-				(void *)paddr, len, cmd);
-	}
-	return ret;
-}
-int adsp_ion_fixup_kvaddr(struct msm_adsp_module *module, void **addr,
-			   unsigned long *kvaddr, unsigned long len,
-			   struct file **filp, unsigned long *offset)
-{
-	struct adsp_ion_region *region;
-	void *vaddr = *addr;
-	unsigned long *paddr = (unsigned long *)addr;
-	int ret;
-
-	ret = adsp_ion_lookup_vaddr(module, addr, len, &region);
-	if (ret) {
-		MM_ERR("not patching %s (paddr & kvaddr),"
-			" lookup (%p, %ld) failed\n",
-			module->name, vaddr, len);
-		return ret;
-	}
-	*paddr = region->paddr + (vaddr - region->vaddr);
-	*kvaddr = region->kvaddr + (vaddr - region->vaddr);
-	if (filp)
-		*filp = region->file;
-	if (offset)
-		*offset = vaddr - region->vaddr;
-	return 0;
-}
-
-int adsp_pmem_fixup(struct msm_adsp_module *module, void **addr,
-		    unsigned long len)
-{
-	struct adsp_ion_region *region;
-	void *vaddr = *addr;
-	unsigned long *paddr = (unsigned long *)addr;
-	int ret;
-
-	ret = adsp_ion_lookup_vaddr(module, addr, len, &region);
-	if (ret) {
-		MM_ERR("not patching %s, lookup (%p, %ld) failed\n",
-			module->name, vaddr, len);
-		return ret;
-	}
-
-	*paddr = region->paddr + (vaddr - region->vaddr);
-	return 0;
-}
-
-static int adsp_verify_cmd(struct msm_adsp_module *module,
-			   unsigned int queue_id, void *cmd_data,
-			   size_t cmd_size)
-{
-	/* call the per module verifier */
-	if (module->verify_cmd)
-		return module->verify_cmd(module, queue_id, cmd_data,
-					     cmd_size);
-	else
-		MM_INFO("no packet verifying function "
-				 "for task %s\n", module->name);
-	return 0;
-}
-
-static long adsp_write_cmd(struct adsp_device *adev, void __user *arg)
-{
-	struct adsp_command_t cmd;
-	unsigned char buf[256];
-	void *cmd_data;
-	long rc;
-
-	if (copy_from_user(&cmd, (void __user *)arg, sizeof(cmd)))
-		return -EFAULT;
-
-	if (cmd.len > 256) {
-		cmd_data = kmalloc(cmd.len, GFP_USER);
-		if (!cmd_data)
-			return -ENOMEM;
-	} else {
-		cmd_data = buf;
-	}
-
-	if (copy_from_user(cmd_data, (void __user *)(cmd.data), cmd.len)) {
-		rc = -EFAULT;
-		goto end;
-	}
-
-	mutex_lock(&adev->module->ion_regions_lock);
-	if (adsp_verify_cmd(adev->module, cmd.queue, cmd_data, cmd.len)) {
-		MM_ERR("module %s: verify failed.\n", adev->module->name);
-		rc = -EINVAL;
-		goto end;
-	}
-	/* complete the writes to the buffer */
-	wmb();
-	rc = msm_adsp_write(adev->module, cmd.queue, cmd_data, cmd.len);
-end:
-	mutex_unlock(&adev->module->ion_regions_lock);
-
-	if (cmd.len > 256)
-		kfree(cmd_data);
-
-	return rc;
-}
-
-static int adsp_events_pending(struct adsp_device *adev)
-{
-	unsigned long flags;
-	int yes;
-	spin_lock_irqsave(&adev->event_queue_lock, flags);
-	yes = !list_empty(&adev->event_queue);
-	spin_unlock_irqrestore(&adev->event_queue_lock, flags);
-	return yes || adev->abort;
-}
-
-static int adsp_ion_lookup_paddr(struct msm_adsp_module *module, void **addr,
-		     struct adsp_ion_region **region)
-{
-	struct hlist_node *node;
-	unsigned long paddr = (unsigned long)(*addr);
-	struct adsp_ion_region *region_elt;
-
-	hlist_for_each_entry(region_elt, node, &module->ion_regions, list) {
-		if (paddr >= region_elt->paddr &&
-		    paddr < region_elt->paddr + region_elt->len) {
-			*region = region_elt;
-			return 0;
-		}
-	}
-	return -1;
-}
-
-int adsp_pmem_paddr_fixup(struct msm_adsp_module *module, void **addr)
-{
-	struct adsp_ion_region *region;
-	unsigned long paddr = (unsigned long)(*addr);
-	unsigned long *vaddr = (unsigned long *)addr;
-	int ret;
-
-	ret = adsp_ion_lookup_paddr(module, addr, &region);
-	if (ret) {
-		MM_ERR("not patching %s, paddr %p lookup failed\n",
-			module->name, vaddr);
-		return ret;
-	}
-
-	*vaddr = (unsigned long)region->vaddr + (paddr - region->paddr);
-	return 0;
-}
-
-static int adsp_patch_event(struct msm_adsp_module *module,
-				struct adsp_event *event)
-{
-	/* call the per-module msg verifier */
-	if (module->patch_event)
-		return module->patch_event(module, event);
-	return 0;
-}
-
-static long adsp_get_event(struct adsp_device *adev, void __user *arg)
-{
-	unsigned long flags;
-	struct adsp_event *data = NULL;
-	struct adsp_event_t evt;
-	int timeout;
-	long rc = 0;
-
-	if (copy_from_user(&evt, arg, sizeof(struct adsp_event_t)))
-		return -EFAULT;
-
-	timeout = (int)evt.timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(
-			adev->event_wait, adsp_events_pending(adev),
-			msecs_to_jiffies(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(
-			adev->event_wait, adsp_events_pending(adev));
-	}
-	if (rc < 0)
-		return rc;
-
-	if (adev->abort)
-		return -ENODEV;
-
-	spin_lock_irqsave(&adev->event_queue_lock, flags);
-	if (!list_empty(&adev->event_queue)) {
-		data = list_first_entry(&adev->event_queue,
-					struct adsp_event, list);
-		list_del(&data->list);
-	}
-	spin_unlock_irqrestore(&adev->event_queue_lock, flags);
-
-	if (!data)
-		return -EAGAIN;
-
-	/* DSP messages are type 0; they may contain physical addresses */
-	if (data->type == 0)
-		adsp_patch_event(adev->module, data);
-
-	/* map adsp_event --> adsp_event_t */
-	if (evt.len < data->size) {
-		rc = -ETOOSMALL;
-		goto end;
-	}
-	/* order the reads to the buffer */
-	rmb();
-	if (data->msg_id != EVENT_MSG_ID) {
-		if (copy_to_user((void *)(evt.data), data->data.msg16,
-					data->size)) {
-			rc = -EFAULT;
-			goto end;
-	}
-	} else {
-		if (copy_to_user((void *)(evt.data), data->data.msg32,
-					data->size)) {
-			rc = -EFAULT;
-			goto end;
-		}
-	}
-
-	evt.type = data->type; /* 0 --> from aDSP, 1 --> from ARM9 */
-	evt.msg_id = data->msg_id;
-	evt.flags = data->is16;
-	evt.len = data->size;
-	if (copy_to_user(arg, &evt, sizeof(evt)))
-		rc = -EFAULT;
-end:
-	kfree(data);
-	return rc;
-}
-
-static int adsp_ion_del(struct msm_adsp_module *module)
-{
-	struct hlist_node *node, *tmp;
-	struct adsp_ion_region *region;
-
-	mutex_lock(&module->ion_regions_lock);
-	hlist_for_each_safe(node, tmp, &module->ion_regions) {
-		region = hlist_entry(node, struct adsp_ion_region, list);
-		hlist_del(node);
-		MM_INFO("adsp_ion_del: module %s: fd %d, vaddr Ox%x, len %d\n",
-			module->name, region->fd, (unsigned int)region->vaddr,
-			(int)region->len);
-		free_ion_region(region->client, region->handle);
-		kfree(region);
-	}
-	mutex_unlock(&module->ion_regions_lock);
-	BUG_ON(!hlist_empty(&module->ion_regions));
-
-	return 0;
-}
-
-static long adsp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
-{
-	struct adsp_device *adev = filp->private_data;
-
-	switch (cmd) {
-	case ADSP_IOCTL_ENABLE:
-		return msm_adsp_enable(adev->module);
-
-	case ADSP_IOCTL_DISABLE:
-		return msm_adsp_disable(adev->module);
-
-	case ADSP_IOCTL_DISABLE_EVENT_RSP:
-		return msm_adsp_disable_event_rsp(adev->module);
-
-	case ADSP_IOCTL_DISABLE_ACK:
-		MM_ERR("ADSP_IOCTL_DISABLE_ACK is not implemented\n");
-		break;
-
-	case ADSP_IOCTL_WRITE_COMMAND:
-		return adsp_write_cmd(adev, (void __user *) arg);
-
-	case ADSP_IOCTL_GET_EVENT:
-		return adsp_get_event(adev, (void __user *) arg);
-
-	case ADSP_IOCTL_SET_CLKRATE: {
-		unsigned long clk_rate;
-		if (copy_from_user(&clk_rate, (void *) arg, sizeof(clk_rate)))
-			return -EFAULT;
-		return adsp_set_clkrate(adev->module, clk_rate);
-	}
-
-	case ADSP_IOCTL_REGISTER_PMEM: {
-		struct adsp_ion_info info;
-		if (copy_from_user(&info, (void *) arg, sizeof(info)))
-			return -EFAULT;
-		return adsp_ion_add(adev->module, &info);
-	}
-
-	case ADSP_IOCTL_ABORT_EVENT_READ:
-		adev->abort = 1;
-		wake_up(&adev->event_wait);
-		break;
-
-	case ADSP_IOCTL_UNREGISTER_PMEM:
-		return adsp_ion_del(adev->module);
-
-	default:
-		break;
-	}
-	return -EINVAL;
-}
-
-static int adsp_release(struct inode *inode, struct file *filp)
-{
-	struct adsp_device *adev = filp->private_data;
-	struct msm_adsp_module *module = adev->module;
-	int rc = 0;
-
-	MM_INFO("release '%s'\n", adev->name);
-
-	/* clear module before putting it to avoid race with open() */
-	adev->module = NULL;
-
-	rc = adsp_ion_del(module);
-
-	msm_adsp_put(module);
-	return rc;
-}
-
-static void adsp_event(void *driver_data, unsigned id, size_t len,
-		       void (*getevent)(void *ptr, size_t len))
-{
-	struct adsp_device *adev = driver_data;
-	struct adsp_event *event;
-	unsigned long flags;
-
-	if (len > ADSP_EVENT_MAX_SIZE) {
-		MM_ERR("event too large (%d bytes)\n", len);
-		return;
-	}
-
-	event = kmalloc(sizeof(*event), GFP_ATOMIC);
-	if (!event) {
-		MM_ERR("cannot allocate buffer\n");
-		return;
-	}
-
-	if (id != EVENT_MSG_ID) {
-		event->type = 0;
-		event->is16 = 0;
-		event->msg_id = id;
-		event->size = len;
-
-		getevent(event->data.msg16, len);
-	} else {
-		event->type = 1;
-		event->is16 = 1;
-		event->msg_id = id;
-		event->size = len;
-		getevent(event->data.msg32, len);
-	}
-
-	spin_lock_irqsave(&adev->event_queue_lock, flags);
-	list_add_tail(&event->list, &adev->event_queue);
-	spin_unlock_irqrestore(&adev->event_queue_lock, flags);
-	wake_up(&adev->event_wait);
-}
-
-static struct msm_adsp_ops adsp_ops = {
-	.event = adsp_event,
-};
-
-static int adsp_open(struct inode *inode, struct file *filp)
-{
-	struct adsp_device *adev;
-	int rc;
-
-	rc = nonseekable_open(inode, filp);
-	if (rc < 0)
-		return rc;
-
-	adev = inode_to_device(inode);
-	if (!adev)
-		return -ENODEV;
-
-	MM_INFO("open '%s'\n", adev->name);
-
-	rc = msm_adsp_get(adev->name, &adev->module, &adsp_ops, adev);
-	if (rc)
-		return rc;
-
-	MM_INFO("opened module '%s' adev %p\n", adev->name, adev);
-	filp->private_data = adev;
-	adev->abort = 0;
-	INIT_HLIST_HEAD(&adev->module->ion_regions);
-	mutex_init(&adev->module->ion_regions_lock);
-
-	return 0;
-}
-
-static unsigned adsp_device_count;
-static struct adsp_device *adsp_devices;
-
-static struct adsp_device *inode_to_device(struct inode *inode)
-{
-	unsigned n = MINOR(inode->i_rdev);
-	if (n < adsp_device_count) {
-		if (adsp_devices[n].device)
-			return adsp_devices + n;
-	}
-	return NULL;
-}
-
-static dev_t adsp_devno;
-static struct class *adsp_class;
-
-static struct file_operations adsp_fops = {
-	.owner = THIS_MODULE,
-	.open = adsp_open,
-	.unlocked_ioctl = adsp_ioctl,
-	.release = adsp_release,
-};
-
-static void adsp_create(struct adsp_device *adev, const char *name,
-			struct device *parent, dev_t devt)
-{
-	struct device *dev;
-	int rc;
-
-	dev = device_create(adsp_class, parent, devt, "%s", name);
-	if (IS_ERR(dev))
-		return;
-
-	init_waitqueue_head(&adev->event_wait);
-	INIT_LIST_HEAD(&adev->event_queue);
-	spin_lock_init(&adev->event_queue_lock);
-
-	cdev_init(&adev->cdev, &adsp_fops);
-	adev->cdev.owner = THIS_MODULE;
-
-	rc = cdev_add(&adev->cdev, devt, 1);
-	if (rc < 0) {
-		device_destroy(adsp_class, devt);
-	} else {
-		adev->device = dev;
-		adev->name = name;
-	}
-}
-
-void msm_adsp_publish_cdevs(struct msm_adsp_module *modules, unsigned n)
-{
-	int rc;
-
-	adsp_devices = kzalloc(sizeof(struct adsp_device) * n, GFP_KERNEL);
-	if (!adsp_devices)
-		return;
-
-	adsp_class = class_create(THIS_MODULE, "adsp");
-	if (IS_ERR(adsp_class))
-		goto fail_create_class;
-
-	rc = alloc_chrdev_region(&adsp_devno, 0, n, "adsp");
-	if (rc < 0)
-		goto fail_alloc_region;
-
-	adsp_device_count = n;
-	for (n = 0; n < adsp_device_count; n++) {
-		adsp_create(adsp_devices + n,
-			    modules[n].name, &modules[n].pdev.dev,
-			    MKDEV(MAJOR(adsp_devno), n));
-	}
-
-	return;
-
-fail_alloc_region:
-	class_unregister(adsp_class);
-fail_create_class:
-	kfree(adsp_devices);
-}
diff --git a/arch/arm/mach-msm/qdsp5/adsp_info.c b/arch/arm/mach-msm/qdsp5/adsp_info.c
deleted file mode 100644
index 69a2d18..0000000
--- a/arch/arm/mach-msm/qdsp5/adsp_info.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/* arch/arm/mach-msm/adsp_info.c
- *
- * Copyright (c) 2008-2009, 2011-2012 The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include "adsp.h"
-
-/* Firmware modules */
-#define QDSP_MODULE_KERNEL                  0x0106dd4e
-#define QDSP_MODULE_AFETASK                 0x0106dd6f
-#define QDSP_MODULE_AUDPLAY0TASK            0x0106dd70
-#define QDSP_MODULE_AUDPLAY1TASK            0x0106dd71
-#define QDSP_MODULE_AUDPPTASK               0x0106dd72
-#define QDSP_MODULE_VIDEOTASK               0x0106dd73
-#define QDSP_MODULE_VIDEO_AAC_VOC           0x0106dd74
-#define QDSP_MODULE_PCM_DEC                 0x0106dd75
-#define QDSP_MODULE_AUDIO_DEC_MP3           0x0106dd76
-#define QDSP_MODULE_AUDIO_DEC_AAC           0x0106dd77
-#define QDSP_MODULE_AUDIO_DEC_WMA           0x0106dd78
-#define QDSP_MODULE_HOSTPCM                 0x0106dd79
-#define QDSP_MODULE_DTMF                    0x0106dd7a
-#define QDSP_MODULE_AUDRECTASK              0x0106dd7b
-#define QDSP_MODULE_AUDPREPROCTASK          0x0106dd7c
-#define QDSP_MODULE_SBC_ENC                 0x0106dd7d
-#define QDSP_MODULE_VOC_UMTS                0x0106dd9a
-#define QDSP_MODULE_VOC_CDMA                0x0106dd98
-#define QDSP_MODULE_VOC_PCM                 0x0106dd7f
-#define QDSP_MODULE_VOCENCTASK              0x0106dd80
-#define QDSP_MODULE_VOCDECTASK              0x0106dd81
-#define QDSP_MODULE_VOICEPROCTASK           0x0106dd82
-#define QDSP_MODULE_VIDEOENCTASK            0x0106dd83
-#define QDSP_MODULE_VFETASK                 0x0106dd84
-#define QDSP_MODULE_WAV_ENC                 0x0106dd85
-#define QDSP_MODULE_AACLC_ENC               0x0106dd86
-#define QDSP_MODULE_VIDEO_AMR               0x0106dd87
-#define QDSP_MODULE_VOC_AMR                 0x0106dd88
-#define QDSP_MODULE_VOC_EVRC                0x0106dd89
-#define QDSP_MODULE_VOC_13K                 0x0106dd8a
-#define QDSP_MODULE_VOC_FGV                 0x0106dd8b
-#define QDSP_MODULE_DIAGTASK                0x0106dd8c
-#define QDSP_MODULE_JPEGTASK                0x0106dd8d
-#define QDSP_MODULE_LPMTASK                 0x0106dd8e
-#define QDSP_MODULE_QCAMTASK                0x0106dd8f
-#define QDSP_MODULE_MODMATHTASK             0x0106dd90
-#define QDSP_MODULE_AUDPLAY2TASK            0x0106dd91
-#define QDSP_MODULE_AUDPLAY3TASK            0x0106dd92
-#define QDSP_MODULE_AUDPLAY4TASK            0x0106dd93
-#define QDSP_MODULE_GRAPHICSTASK            0x0106dd94
-#define QDSP_MODULE_MIDI                    0x0106dd95
-#define QDSP_MODULE_GAUDIO                  0x0106dd96
-#define QDSP_MODULE_VDEC_LP_MODE            0x0106dd97
-#define QDSP_MODULE_VIDEO_AAC_VOC_TURBO     0x01089f77
-#define QDSP_MODULE_VIDEO_AMR_TURBO         0x01089f78
-#define QDSP_MODULE_WM_TURBO_MODE           0x01089f79
-#define QDSP_MODULE_VDEC_LP_MODE_TURBO      0x01089f7a
-#define QDSP_MODULE_AUDREC0TASK             0x0109696f
-#define QDSP_MODULE_AUDREC1TASK             0x01096970
-#define QDSP_MODULE_RMTASK                  0x01090f8e
-#define QDSP_MODULE_MAX                     0x7fffffff
-
-   /* DO NOT USE: Force this enum to be a 32bit type to improve speed */
-#define QDSP_MODULE_32BIT_DUMMY 0x10000
-
-static uint32_t *qdsp_task_to_module[IMG_MAX];
-static uint32_t	*qdsp_queue_offset_table[IMG_MAX];
-
-#define QDSP_MODULE(n, clkname, clkrate, verify_cmd_func, patch_event_func) \
-	{ .name = #n, .pdev_name = "adsp_" #n, .id = QDSP_MODULE_##n, \
-	  .clk_name = clkname, .clk_rate = clkrate, \
-	  .verify_cmd = verify_cmd_func, .patch_event = patch_event_func }
-
-static struct adsp_module_info module_info[] = {
-	QDSP_MODULE(AUDPLAY0TASK, NULL, 0, NULL, NULL),
-	QDSP_MODULE(AUDPLAY1TASK, NULL, 0, NULL, NULL),
-	QDSP_MODULE(AUDPLAY2TASK, NULL, 0, NULL, NULL),
-	QDSP_MODULE(AUDPLAY3TASK, NULL, 0, NULL, NULL),
-	QDSP_MODULE(AUDPPTASK, NULL, 0, NULL, NULL),
-	QDSP_MODULE(AUDPREPROCTASK, NULL, 0, NULL, NULL),
-	QDSP_MODULE(RMTASK, NULL, 0, NULL, NULL),
-#if !defined(CONFIG_ARCH_MSM7X30)
-	QDSP_MODULE(AUDRECTASK, NULL, 0, NULL, NULL),
-	QDSP_MODULE(VFETASK, NULL, 0, adsp_vfe_verify_cmd,
-		adsp_vfe_patch_event),
-	QDSP_MODULE(QCAMTASK, NULL, 0, NULL, NULL),
-	QDSP_MODULE(LPMTASK, NULL, 0, adsp_lpm_verify_cmd, NULL),
-	QDSP_MODULE(JPEGTASK, "vdc_clk", 96000000, adsp_jpeg_verify_cmd,
-		adsp_jpeg_patch_event),
-	QDSP_MODULE(VIDEOTASK, "vdc_clk", 96000000,
-		adsp_video_verify_cmd, NULL),
-	QDSP_MODULE(VDEC_LP_MODE, NULL, 0, NULL, NULL),
-	QDSP_MODULE(VIDEOENCTASK, "vdc_clk", 96000000,
-		adsp_videoenc_verify_cmd, NULL),
-	QDSP_MODULE(VIDEO_AAC_VOC_TURBO, NULL, 0, NULL, NULL),
-	QDSP_MODULE(VIDEO_AMR_TURBO, NULL, 0, NULL, NULL),
-	QDSP_MODULE(WM_TURBO_MODE, NULL, 0, NULL, NULL),
-	QDSP_MODULE(VDEC_LP_MODE_TURBO, NULL, 0, NULL, NULL),
-#if defined(CONFIG_MSM7X27A_AUDIO)
-	QDSP_MODULE(AUDREC1TASK, NULL, 0, NULL, NULL),
-#endif
-#else
-	QDSP_MODULE(AFETASK , NULL, 0, NULL, NULL),
-	QDSP_MODULE(AUDREC0TASK, NULL, 0, NULL, NULL),
-	QDSP_MODULE(AUDREC1TASK, NULL, 0, NULL, NULL),
-#endif
-};
-
-int adsp_init_info(struct adsp_info *info)
-{
-	uint32_t img_num;
-
-	info->send_irq =   0x00c00200;
-	info->read_ctrl =  0x00400038;
-	info->write_ctrl = 0x00400034;
-
-	info->max_msg16_size = 193;
-	info->max_msg32_size = 8;
-	for (img_num = 0; img_num < IMG_MAX; img_num++)
-		qdsp_queue_offset_table[img_num] =
-		&info->init_info_ptr->queue_offsets[img_num][0];
-
-	for (img_num = 0; img_num < IMG_MAX; img_num++)
-		qdsp_task_to_module[img_num] =
-		&info->init_info_ptr->task_to_module_tbl[img_num][0];
-	info->max_task_id = 30;
-	info->max_module_id = QDSP_MODULE_MAX - 1;
-	info->max_queue_id = QDSP_MAX_NUM_QUEUES;
-	info->max_image_id = 2;
-	info->queue_offset = qdsp_queue_offset_table;
-	info->task_to_module = qdsp_task_to_module;
-
-	info->module_count = ARRAY_SIZE(module_info);
-	info->module = module_info;
-	return 0;
-}
diff --git a/arch/arm/mach-msm/qdsp5/adsp_jpeg_patch_event.c b/arch/arm/mach-msm/qdsp5/adsp_jpeg_patch_event.c
deleted file mode 100644
index 768ac31..0000000
--- a/arch/arm/mach-msm/qdsp5/adsp_jpeg_patch_event.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/adsp_jpeg_patch_event.c
- *
- * Verification code for aDSP JPEG events.
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (c) 2008-2009, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <mach/qdsp5/qdsp5jpegmsg.h>
-#include "adsp.h"
-
-int adsp_jpeg_patch_event(struct msm_adsp_module *module,
-			struct adsp_event *event)
-{
-	if (event->msg_id == JPEG_MSG_ENC_OP_PRODUCED) {
-		jpeg_msg_enc_op_produced *op = (jpeg_msg_enc_op_produced *)event->data.msg16;
-		return adsp_pmem_paddr_fixup(module, (void **)&op->op_buf_addr);
-	}
-	if (event->msg_id == JPEG_MSG_DEC_OP_PRODUCED) {
-		jpeg_msg_dec_op_produced *op = (jpeg_msg_dec_op_produced *)
-			event->data.msg16;
-		return adsp_pmem_paddr_fixup(module,
-				(void **)&op->luma_op_buf_addr) ||
-			adsp_pmem_paddr_fixup(module,
-				(void **)&op->chroma_op_buf_addr);
-	}
-
-	return 0;
-}
diff --git a/arch/arm/mach-msm/qdsp5/adsp_jpeg_verify_cmd.c b/arch/arm/mach-msm/qdsp5/adsp_jpeg_verify_cmd.c
deleted file mode 100644
index a5dd4ad..0000000
--- a/arch/arm/mach-msm/qdsp5/adsp_jpeg_verify_cmd.c
+++ /dev/null
@@ -1,201 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/adsp_jpeg_verify_cmd.c
- *
- * Verification code for aDSP JPEG packets from userspace.
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (c) 2008-2009, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <mach/qdsp5/qdsp5jpegcmdi.h>
-#include "adsp.h"
-#include <mach/debug_mm.h>
-
-static uint32_t dec_fmt;
-
-static inline void get_sizes(jpeg_cmd_enc_cfg *cmd, uint32_t *luma_size,
-			     uint32_t *chroma_size)
-{
-	uint32_t fmt, luma_width, luma_height;
-
-	fmt = cmd->process_cfg & JPEG_CMD_ENC_PROCESS_CFG_IP_DATA_FORMAT_M;
-	luma_width = (cmd->ip_size_cfg & JPEG_CMD_IP_SIZE_CFG_LUMA_WIDTH_M)
-		      >> 16;
-	luma_height = cmd->frag_cfg & JPEG_CMD_FRAG_SIZE_LUMA_HEIGHT_M;
-	*luma_size = luma_width * luma_height;
-	if (fmt == JPEG_CMD_ENC_PROCESS_CFG_IP_DATA_FORMAT_H2V2)
-		*chroma_size = *luma_size/2;
-	else
-		*chroma_size = *luma_size;
-}
-
-static inline int verify_jpeg_cmd_enc_cfg(struct msm_adsp_module *module,
-                             		  void *cmd_data, size_t cmd_size)
-{
-	jpeg_cmd_enc_cfg *cmd = (jpeg_cmd_enc_cfg *)cmd_data;
-	uint32_t luma_size, chroma_size;
-	int i, num_frags;
-
-	if (cmd_size != sizeof(jpeg_cmd_enc_cfg)) {
-		MM_ERR("module %s: JPEG ENC CFG invalid \
-			cmd_size %d\n", module->name, cmd_size);
-		return -1;
-	}
-
-	get_sizes(cmd, &luma_size, &chroma_size);
-	num_frags = (cmd->process_cfg >> 10) & 0xf;
-	num_frags = ((num_frags == 1) ? num_frags : num_frags * 2);
-	for (i = 0; i < num_frags; i += 2) {
-		if (adsp_pmem_fixup(module, (void **)(&cmd->frag_cfg_part[i]), luma_size) ||
-		    adsp_pmem_fixup(module, (void **)(&cmd->frag_cfg_part[i+1]), chroma_size))
-			return -1;
-	}
-
-	if (adsp_pmem_fixup(module, (void **)&cmd->op_buf_0_cfg_part1,
-			    cmd->op_buf_0_cfg_part2) ||
-	    adsp_pmem_fixup(module, (void **)&cmd->op_buf_1_cfg_part1,
-			    cmd->op_buf_1_cfg_part2))
-		return -1;
-	return 0;
-}
-
-static inline int verify_jpeg_cmd_dec_cfg(struct msm_adsp_module *module,
-					  void *cmd_data, size_t cmd_size)
-{
-	jpeg_cmd_dec_cfg *cmd = (jpeg_cmd_dec_cfg *)cmd_data;
-	uint32_t div;
-
-	if (cmd_size != sizeof(jpeg_cmd_dec_cfg)) {
-		MM_ERR("module %s: JPEG DEC CFG invalid \
-			cmd_size %d\n", module->name, cmd_size);
-		return -1;
-	}
-
-	if (adsp_pmem_fixup(module, (void **)&cmd->ip_stream_buf_cfg_part1,
-			    cmd->ip_stream_buf_cfg_part2) ||
-	    adsp_pmem_fixup(module, (void **)&cmd->op_stream_buf_0_cfg_part1,
-			    cmd->op_stream_buf_0_cfg_part2) ||
-	    adsp_pmem_fixup(module, (void **)&cmd->op_stream_buf_1_cfg_part1,
-			    cmd->op_stream_buf_1_cfg_part2))
-		return -1;
-	dec_fmt = cmd->op_data_format &
-		JPEG_CMD_DEC_OP_DATA_FORMAT_M;
-	div = (dec_fmt == JPEG_CMD_DEC_OP_DATA_FORMAT_H2V2) ? 2 : 1;
-	if (adsp_pmem_fixup(module, (void **)&cmd->op_stream_buf_0_cfg_part3,
-			    cmd->op_stream_buf_0_cfg_part2 / div) ||
-	    adsp_pmem_fixup(module, (void **)&cmd->op_stream_buf_1_cfg_part3,
-			    cmd->op_stream_buf_1_cfg_part2 / div))
-		return -1;
-	return 0;
-}
-
-static int verify_jpeg_cfg_cmd(struct msm_adsp_module *module,
-			       void *cmd_data, size_t cmd_size)
-{
-	uint32_t cmd_id = ((uint32_t *)cmd_data)[0];
-	switch(cmd_id) {
-	case JPEG_CMD_ENC_CFG:
-		return verify_jpeg_cmd_enc_cfg(module, cmd_data, cmd_size);
-	case JPEG_CMD_DEC_CFG:
-		return verify_jpeg_cmd_dec_cfg(module, cmd_data, cmd_size);
-	default:
-		if (cmd_id > 1) {
-			MM_ERR("module %s: invalid JPEG CFG cmd_id %d\n",
-					module->name, cmd_id);
-			return -1;
-		}
-	}
-	return 0;
-}
-
-static int verify_jpeg_action_cmd(struct msm_adsp_module *module,
-				  void *cmd_data, size_t cmd_size)
-{
-	uint32_t cmd_id = ((uint32_t *)cmd_data)[0];
-	switch (cmd_id) {
-	case JPEG_CMD_ENC_OP_CONSUMED:
-	{
-		jpeg_cmd_enc_op_consumed *cmd =
-			(jpeg_cmd_enc_op_consumed *)cmd_data;
-
-		if (cmd_size != sizeof(jpeg_cmd_enc_op_consumed)) {
-			MM_ERR("module %s: JPEG_CMD_ENC_OP_CONSUMED \
-				invalid size %d\n", module->name, cmd_size);
-			return -1;
-		}
-
-		if (adsp_pmem_fixup(module, (void **)&cmd->op_buf_addr,
-				    cmd->op_buf_size))
-			return -1;
-	}
-	break;
-	case JPEG_CMD_DEC_OP_CONSUMED:
-	{
-		uint32_t div;
-		jpeg_cmd_dec_op_consumed *cmd =
-			(jpeg_cmd_dec_op_consumed *)cmd_data;
-
-		if (cmd_size != sizeof(jpeg_cmd_dec_op_consumed)) {
-			MM_ERR("module %s: JPEG_CMD_DEC_OP_CONSUMED \
-				invalid size %d\n", module->name, cmd_size);
-			return -1;
-		}
-
-		div = (dec_fmt == JPEG_CMD_DEC_OP_DATA_FORMAT_H2V2) ?  2 : 1;
-		if (adsp_pmem_fixup(module, (void **)&cmd->luma_op_buf_addr,
-				    cmd->luma_op_buf_size) ||
-		    adsp_pmem_fixup(module, (void **)&cmd->chroma_op_buf_addr,
-				    cmd->luma_op_buf_size / div))
-			return -1;
-	}
-	break;
-
-	case JPEG_CMD_DEC_IP:
-	{
-		jpeg_cmd_dec_ip *cmd =
-			(jpeg_cmd_dec_ip *)cmd_data;
-
-		if (cmd_size != sizeof(jpeg_cmd_dec_ip)) {
-			MM_ERR("module %s: JPEG_CMD_DEC_IP invalid \
-				size %d\n", module->name, cmd_size);
-			return -1;
-		}
-		if (adsp_pmem_fixup(module, (void **)&cmd->ip_buf_addr,
-			cmd->ip_buf_size))
-			return -1;
-	}
-	break;
-
-	default:
-		if (cmd_id > 7) {
-			MM_ERR("module %s: invalid cmd_id %d\n",
-				module->name, cmd_id);
-			return -1;
-		}
-	}
-	return 0;
-}
-
-int adsp_jpeg_verify_cmd(struct msm_adsp_module *module,
-			 unsigned int queue_id, void *cmd_data,
-			 size_t cmd_size)
-{
-	switch(queue_id) {
-	case QDSP_uPJpegCfgCmdQueue:
-		return verify_jpeg_cfg_cmd(module, cmd_data, cmd_size);
-	case QDSP_uPJpegActionCmdQueue:
-		return verify_jpeg_action_cmd(module, cmd_data, cmd_size);
-	default:
-		return -1;
-	}
-}
-
diff --git a/arch/arm/mach-msm/qdsp5/adsp_lpm_verify_cmd.c b/arch/arm/mach-msm/qdsp5/adsp_lpm_verify_cmd.c
deleted file mode 100644
index 6424975..0000000
--- a/arch/arm/mach-msm/qdsp5/adsp_lpm_verify_cmd.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/adsp_lpm_verify_cmd.c
- *
- * Verificion code for aDSP LPM packets from userspace.
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (c) 2008-2009, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <mach/qdsp5/qdsp5lpmcmdi.h>
-#include "adsp.h"
-#include <mach/debug_mm.h>
-
-int adsp_lpm_verify_cmd(struct msm_adsp_module *module,
-			 unsigned int queue_id, void *cmd_data,
-			 size_t cmd_size)
-{
-	uint32_t cmd_id, col_height, input_row_incr, output_row_incr,
-		input_size, output_size;
-	uint32_t size_mask = 0x0fff;
-	lpm_cmd_start *cmd;
-
-	if (queue_id != QDSP_lpmCommandQueue) {
-		MM_ERR("module %s: wrong queue id %d\n",
-				module->name, queue_id);
-		return -1;
-	}
-
-	cmd = (lpm_cmd_start *)cmd_data;
-	cmd_id = cmd->cmd_id;
-
-	if (cmd_id == LPM_CMD_START) {
-		if (cmd_size != sizeof(lpm_cmd_start)) {
-			MM_ERR("module %s: wrong size %d, \
-				expect %d\n", module->name,
-				cmd_size, sizeof(lpm_cmd_start));
-			return -1;
-		}
-		col_height = cmd->ip_data_cfg_part1 & size_mask;
-		input_row_incr = cmd->ip_data_cfg_part2 & size_mask;
-		output_row_incr = cmd->op_data_cfg_part1 & size_mask;
-		input_size = col_height * input_row_incr;
-		output_size = col_height * output_row_incr;
-		if ((cmd->ip_data_cfg_part4 && adsp_pmem_fixup(module,
-				    (void **)(&cmd->ip_data_cfg_part4),
-				    input_size)) ||
-		   (cmd->op_data_cfg_part3 && adsp_pmem_fixup(module,
-				    (void **)(&cmd->op_data_cfg_part3),
-				    output_size)))
-			return -1;
-	} else if (cmd_id > 1) {
-		MM_ERR("module %s: invalid cmd_id %d\n", module->name, cmd_id);
-		return -1;
-	}
-	return 0;
-}
-
diff --git a/arch/arm/mach-msm/qdsp5/adsp_rm.c b/arch/arm/mach-msm/qdsp5/adsp_rm.c
deleted file mode 100644
index 95489f8..0000000
--- a/arch/arm/mach-msm/qdsp5/adsp_rm.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/* Copyright (c) 2010, The Linux Foundation. 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.
- */
-
-#include <linux/cdev.h>
-#include <linux/fs.h>
-#include <linux/list.h>
-#include <linux/platform_device.h>
-#include <linux/sched.h>
-#include <linux/uaccess.h>
-#include <linux/msm_adsp.h>
-#include <linux/module.h>
-
-#include <mach/qdsp5/qdsp5rmtcmdi.h>
-#include <mach/qdsp5/qdsp5rmtmsg.h>
-#include <mach/debug_mm.h>
-#include "adsp.h"
-
-#define MAX_CLIENTS		5
-#define MAX_AUDIO_CLIENTS	5
-#define MAX_RM_CLIENTS		MAX_AUDIO_CLIENTS
-
-static char *rm_errs[] = {
-			"",
-			"PCM Blocks not Sufficient",
-			"TASK is already occupied",
-			"Concurrency not supported",
-			"MIPS not sufficient",
-			"DDP invalid/no licence"
-			};
-static struct client {
-	wait_queue_head_t		wait;
-	unsigned int			wait_state;
-	struct aud_codec_config_ack	cfg_msg;
-} rmclient[MAX_RM_CLIENTS];
-
-static struct rm {
-	struct msm_adsp_module		*mod;
-	int				cnt;
-	int				state;
-
-	struct aud_codec_config_ack	cfg_msg;
-	struct mutex			lock;
-} rmtask;
-
-static void rm_dsp_event(void *data, unsigned id, size_t len,
-			void (*getevent) (void *ptr, size_t len));
-static struct msm_adsp_ops rm_ops = {
-	.event = rm_dsp_event,
-};
-
-int32_t get_adsp_resource(unsigned short client_id,
-				void *cmd_buf, size_t cmd_size)
-{
-	int rc = 0;
-	int client_idx;
-
-	client_idx = ((client_id >> 8) * MAX_CLIENTS) + (client_id & 0xFF);
-	if (client_idx >= MAX_RM_CLIENTS)
-		return -EINVAL;
-
-	mutex_lock(&rmtask.lock);
-	if (rmtask.state != ADSP_STATE_ENABLED) {
-		rc = msm_adsp_get("RMTASK", &rmtask.mod, &rm_ops, NULL);
-		if (rc) {
-			MM_ERR("Failed to get module RMTASK\n");
-			mutex_unlock(&rmtask.lock);
-			return rc;
-		}
-		rc = msm_adsp_enable(rmtask.mod);
-		if (rc) {
-			MM_ERR("RMTASK enable Failed\n");
-			msm_adsp_put(rmtask.mod);
-			mutex_unlock(&rmtask.lock);
-			return rc;
-		}
-		rmtask.state = ADSP_STATE_ENABLED;
-	}
-	rmclient[client_idx].wait_state = -1;
-	mutex_unlock(&rmtask.lock);
-	msm_adsp_write(rmtask.mod, QDSP_apuRmtQueue, cmd_buf, cmd_size);
-	rc = wait_event_interruptible_timeout(rmclient[client_idx].wait,
-			rmclient[client_idx].wait_state != -1, 5 * HZ);
-	mutex_lock(&rmtask.lock);
-	if (unlikely(rc < 0)) {
-		if (rc == -ERESTARTSYS)
-			MM_ERR("wait_event_interruptible "
-					"returned -ERESTARTSYS\n");
-		else
-			MM_ERR("wait_event_interruptible "
-					"returned error\n");
-		if (!rmtask.cnt)
-			goto disable_rm;
-		goto unlock;
-	} else if (rc == 0) {
-		MM_ERR("RMTASK Msg not received\n");
-		rc = -ETIMEDOUT;
-		if (!rmtask.cnt)
-			goto disable_rm;
-		goto unlock;
-	}
-	if (!(rmclient[client_idx].cfg_msg.enable)) {
-		MM_ERR("Reason for failure: %s\n",
-			rm_errs[rmclient[client_idx].cfg_msg.reason]);
-		rc = -EBUSY;
-		if (!rmtask.cnt)
-			goto disable_rm;
-		goto unlock;
-	}
-	rmtask.cnt++;
-	mutex_unlock(&rmtask.lock);
-	return 0;
-
-disable_rm:
-	msm_adsp_disable(rmtask.mod);
-	msm_adsp_put(rmtask.mod);
-	rmtask.state = ADSP_STATE_DISABLED;
-unlock:
-	mutex_unlock(&rmtask.lock);
-	return rc;
-}
-EXPORT_SYMBOL(get_adsp_resource);
-
-int32_t put_adsp_resource(unsigned short client_id, void *cmd_buf,
-							size_t cmd_size)
-{
-	mutex_lock(&rmtask.lock);
-	if (rmtask.state != ADSP_STATE_ENABLED) {
-		mutex_unlock(&rmtask.lock);
-		return 0;
-	}
-
-	msm_adsp_write(rmtask.mod, QDSP_apuRmtQueue, cmd_buf, cmd_size);
-	rmtask.cnt--;
-	if (!rmtask.cnt) {
-		msm_adsp_disable(rmtask.mod);
-		msm_adsp_put(rmtask.mod);
-		rmtask.state = ADSP_STATE_DISABLED;
-	}
-	mutex_unlock(&rmtask.lock);
-	return 0;
-}
-EXPORT_SYMBOL(put_adsp_resource);
-
-static void rm_dsp_event(void *data, unsigned id, size_t len,
-				void (*getevent) (void *ptr, size_t len))
-{
-	unsigned short client_id;
-	int client_idx;
-
-	MM_DBG("Msg ID = %d\n", id);
-
-	switch (id) {
-	case RMT_CODEC_CONFIG_ACK: {
-		getevent(&rmtask.cfg_msg, sizeof(rmtask.cfg_msg));
-		client_id = ((rmtask.cfg_msg.client_id << 8) |
-						rmtask.cfg_msg.task_id);
-		client_idx = ((client_id >> 8) * MAX_CLIENTS) +
-						(client_id & 0xFF);
-		memcpy(&rmclient[client_idx].cfg_msg, &rmtask.cfg_msg,
-							sizeof(rmtask.cfg_msg));
-		rmclient[client_idx].wait_state = 1;
-		wake_up(&rmclient[client_idx].wait);
-		break;
-	}
-	case RMT_DSP_OUT_OF_MIPS: {
-		struct rmt_dsp_out_of_mips msg;
-		getevent(&msg, sizeof(msg));
-		MM_ERR("RMT_DSP_OUT_OF_MIPS: Not enough resorces in ADSP \
-				to handle all sessions :%hx\n", msg.dec_info);
-		break;
-	}
-	default:
-		MM_DBG("Unknown Msg Id\n");
-		break;
-	}
-}
-
-void rmtask_init(void)
-{
-	int i;
-
-	for (i = 0; i < MAX_RM_CLIENTS; i++)
-		init_waitqueue_head(&rmclient[i].wait);
-	mutex_init(&rmtask.lock);
-}
diff --git a/arch/arm/mach-msm/qdsp5/adsp_vfe_patch_event.c b/arch/arm/mach-msm/qdsp5/adsp_vfe_patch_event.c
deleted file mode 100644
index c89a37d..0000000
--- a/arch/arm/mach-msm/qdsp5/adsp_vfe_patch_event.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/adsp_vfe_patch_event.c
- *
- * Verification code for aDSP VFE packets from userspace.
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (c) 2008-2009, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <mach/qdsp5/qdsp5vfemsg.h>
-#include "adsp.h"
-
-static int patch_op_event(struct msm_adsp_module *module,
-				struct adsp_event *event)
-{
-	vfe_msg_op1 *op = (vfe_msg_op1 *)event->data.msg16;
-	if (adsp_pmem_paddr_fixup(module, (void **)&op->op1_buf_y_addr) ||
-	    adsp_pmem_paddr_fixup(module, (void **)&op->op1_buf_cbcr_addr))
-		return -1;
-	return 0;
-}
-
-static int patch_af_wb_event(struct msm_adsp_module *module,
-				struct adsp_event *event)
-{
-	vfe_msg_stats_wb_exp *af = (vfe_msg_stats_wb_exp *)event->data.msg16;
-	return adsp_pmem_paddr_fixup(module, (void **)&af->wb_exp_stats_op_buf);
-}
-
-int adsp_vfe_patch_event(struct msm_adsp_module *module,
-			struct adsp_event *event)
-{
-	switch(event->msg_id) {
-	case VFE_MSG_OP1:
-	case VFE_MSG_OP2:
-		return patch_op_event(module, event);
-	case VFE_MSG_STATS_AF:
-	case VFE_MSG_STATS_WB_EXP:	
-		return patch_af_wb_event(module, event);
-	default:
-		break;
-	}
-
-	return 0;
-}
diff --git a/arch/arm/mach-msm/qdsp5/adsp_vfe_verify_cmd.c b/arch/arm/mach-msm/qdsp5/adsp_vfe_verify_cmd.c
deleted file mode 100644
index dba012e..0000000
--- a/arch/arm/mach-msm/qdsp5/adsp_vfe_verify_cmd.c
+++ /dev/null
@@ -1,244 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/adsp_vfe_verify_cmd.c
- *
- * Verification code for aDSP VFE packets from userspace.
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (c) 2008-2009, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <mach/qdsp5/qdsp5vfecmdi.h>
-#include "adsp.h"
-#include <mach/debug_mm.h>
-
-static uint32_t size1_y, size2_y, size1_cbcr, size2_cbcr;
-static uint32_t af_size = 4228;
-static uint32_t awb_size = 8196;
-
-static inline int verify_cmd_op_ack(struct msm_adsp_module *module,
-				    void *cmd_data, size_t cmd_size)
-{
-	vfe_cmd_op1_ack *cmd = (vfe_cmd_op1_ack *)cmd_data;
-	void **addr_y = (void **)&cmd->op1_buf_y_addr;
-	void **addr_cbcr = (void **)(&cmd->op1_buf_cbcr_addr);
-
-	if (cmd_size != sizeof(vfe_cmd_op1_ack))
-		return -1;
-	if ((*addr_y && adsp_pmem_fixup(module, addr_y, size1_y)) ||
-	    (*addr_cbcr && adsp_pmem_fixup(module, addr_cbcr, size1_cbcr)))
-		return -1;
-	return 0;
-}
-
-static inline int verify_cmd_stats_autofocus_cfg(struct msm_adsp_module *module,
-						 void *cmd_data, size_t cmd_size)
-{
-	int i;
-	vfe_cmd_stats_autofocus_cfg *cmd =
-		(vfe_cmd_stats_autofocus_cfg *)cmd_data;
-
-	if (cmd_size != sizeof(vfe_cmd_stats_autofocus_cfg))
-		return -1;
-
-	for (i = 0; i < 3; i++) {
-		void **addr = (void **)(&cmd->af_stats_op_buf[i]);
-		if (*addr && adsp_pmem_fixup(module, addr, af_size))
-			return -1;
-	}
-	return 0;
-}
-
-static inline int verify_cmd_stats_wb_exp_cfg(struct msm_adsp_module *module,
-					      void *cmd_data, size_t cmd_size)
-{
-	vfe_cmd_stats_wb_exp_cfg *cmd =
-		(vfe_cmd_stats_wb_exp_cfg *)cmd_data;
-	int i;
-
-	if (cmd_size != sizeof(vfe_cmd_stats_wb_exp_cfg))
-		return -1;
-
-	for (i = 0; i < 3; i++) {
-		void **addr = (void **)(&cmd->wb_exp_stats_op_buf[i]);
-		if (*addr && adsp_pmem_fixup(module, addr, awb_size))
-			return -1;
-	}
-	return 0;
-}
-
-static inline int verify_cmd_stats_af_ack(struct msm_adsp_module *module,
-					  void *cmd_data, size_t cmd_size)
-{
-	vfe_cmd_stats_af_ack *cmd = (vfe_cmd_stats_af_ack *)cmd_data;
-	void **addr = (void **)&cmd->af_stats_op_buf;
-
-	if (cmd_size != sizeof(vfe_cmd_stats_af_ack))
-		return -1;
-
-	if (*addr && adsp_pmem_fixup(module, addr, af_size))
-		return -1;
-	return 0;
-}
-
-static inline int verify_cmd_stats_wb_exp_ack(struct msm_adsp_module *module,
-					      void *cmd_data, size_t cmd_size)
-{
-	vfe_cmd_stats_wb_exp_ack *cmd =
-		(vfe_cmd_stats_wb_exp_ack *)cmd_data;
-	void **addr = (void **)&cmd->wb_exp_stats_op_buf;
-
-	if (cmd_size != sizeof(vfe_cmd_stats_wb_exp_ack))
-		return -1;
-
-	if (*addr && adsp_pmem_fixup(module, addr, awb_size))
-		return -1;
-	return 0;
-}
-
-static int verify_vfe_command(struct msm_adsp_module *module,
-			      void *cmd_data, size_t cmd_size)
-{
-	uint32_t cmd_id = ((uint32_t *)cmd_data)[0];
-	switch (cmd_id) {
-	case VFE_CMD_OP1_ACK:
-		return verify_cmd_op_ack(module, cmd_data, cmd_size);
-	case VFE_CMD_OP2_ACK:
-		return verify_cmd_op_ack(module, cmd_data, cmd_size);
-	case VFE_CMD_STATS_AUTOFOCUS_CFG:
-		return verify_cmd_stats_autofocus_cfg(module, cmd_data,
-						      cmd_size);
-	case VFE_CMD_STATS_WB_EXP_CFG:
-		return verify_cmd_stats_wb_exp_cfg(module, cmd_data, cmd_size);
-	case VFE_CMD_STATS_AF_ACK:
-		return verify_cmd_stats_af_ack(module, cmd_data, cmd_size);
-	case VFE_CMD_STATS_WB_EXP_ACK:
-		return verify_cmd_stats_wb_exp_ack(module, cmd_data, cmd_size);
-	default:
-		if (cmd_id > 29) {
-			MM_ERR("module %s: invalid VFE command id %d\n",
-					module->name, cmd_id);
-			return -1;
-		}
-	}
-	return 0;
-}
-
-static int verify_vfe_command_scale(struct msm_adsp_module *module,
-				    void *cmd_data, size_t cmd_size)
-{
-	uint32_t cmd_id = ((uint32_t *)cmd_data)[0];
-	// FIXME: check the size
-	if (cmd_id > 1) {
-		MM_ERR("module %s: invalid VFE SCALE command id %d\n",
-				module->name, cmd_id);
-		return -1;
-	}
-	return 0;
-}
-
-
-static uint32_t get_size(uint32_t hw)
-{
-	uint32_t height, width;
-	uint32_t height_mask = 0x3ffc;
-	uint32_t width_mask = 0x3ffc000;
-
-	height = (hw & height_mask) >> 2;
-	width = (hw & width_mask) >> 14 ;
-	return height * width;
-}
-
-static int verify_vfe_command_table(struct msm_adsp_module *module,
-				    void *cmd_data, size_t cmd_size)
-{
-	uint32_t cmd_id = ((uint32_t *)cmd_data)[0];
-	int i;
-
-	switch (cmd_id) {
-	case VFE_CMD_AXI_IP_CFG:
-	{
-		vfe_cmd_axi_ip_cfg *cmd = (vfe_cmd_axi_ip_cfg *)cmd_data;
-		uint32_t size;
-		if (cmd_size != sizeof(vfe_cmd_axi_ip_cfg)) {
-			MM_ERR("module %s: invalid VFE TABLE \
-				(VFE_CMD_AXI_IP_CFG) command size %d\n",
-				module->name, cmd_size);
-			return -1;
-		}
-		size = get_size(cmd->ip_cfg_part2);
-
-		for (i = 0; i < 8; i++) {
-			void **addr = (void **)
-				&cmd->ip_buf_addr[i];
-			if (*addr && adsp_pmem_fixup(module, addr, size))
-				return -1;
-		}
-	}
-	case VFE_CMD_AXI_OP_CFG:
-	{
-		vfe_cmd_axi_op_cfg *cmd = (vfe_cmd_axi_op_cfg *)cmd_data;
-		void **addr1_y, **addr2_y, **addr1_cbcr, **addr2_cbcr;
-
-		if (cmd_size != sizeof(vfe_cmd_axi_op_cfg)) { 
-			MM_ERR("module %s: invalid VFE TABLE \
-				(VFE_CMD_AXI_OP_CFG) command size %d\n",
-				module->name, cmd_size);
-			return -1;
-		}
-		size1_y = get_size(cmd->op1_y_cfg_part2);
-		size1_cbcr = get_size(cmd->op1_cbcr_cfg_part2);
-		size2_y = get_size(cmd->op2_y_cfg_part2);
-		size2_cbcr = get_size(cmd->op2_cbcr_cfg_part2);
-		for (i = 0; i < 8; i++) {
-			addr1_y = (void **)(&cmd->op1_buf1_addr[2*i]);
-			addr1_cbcr = (void **)(&cmd->op1_buf1_addr[2*i+1]);
-			addr2_y = (void **)(&cmd->op2_buf1_addr[2*i]);
-			addr2_cbcr = (void **)(&cmd->op2_buf1_addr[2*i+1]);
-/*
-			printk("module %s: [%d] %p %p %p %p\n",
-				module->name, i,
-				*addr1_y, *addr1_cbcr, *addr2_y, *addr2_cbcr);
-*/
-			if ((*addr1_y && adsp_pmem_fixup(module, addr1_y, size1_y)) ||
-			    (*addr1_cbcr && adsp_pmem_fixup(module, addr1_cbcr, size1_cbcr)) ||
-			    (*addr2_y && adsp_pmem_fixup(module, addr2_y, size2_y)) ||
-			    (*addr2_cbcr && adsp_pmem_fixup(module, addr2_cbcr, size2_cbcr)))
-				return -1;
-		}
-	}
-	default:
-		if (cmd_id > 4) {
-			MM_ERR("module %s: invalid VFE TABLE command \
-				id %d\n", module->name, cmd_id);
-			return -1;
-		}
-	}
-	return 0;
-}
-
-int adsp_vfe_verify_cmd(struct msm_adsp_module *module,
-			unsigned int queue_id, void *cmd_data,
-			size_t cmd_size)
-{
-	switch (queue_id) {
-	case QDSP_vfeCommandQueue:
-		return verify_vfe_command(module, cmd_data, cmd_size);
-	case QDSP_vfeCommandScaleQueue:
-		return verify_vfe_command_scale(module, cmd_data, cmd_size);
-	case QDSP_vfeCommandTableQueue:
-		return verify_vfe_command_table(module, cmd_data, cmd_size);
-	default:
-		MM_ERR("module %s: unknown queue id %d\n",
-			 module->name, queue_id);
-		return -1;
-	}
-}
diff --git a/arch/arm/mach-msm/qdsp5/adsp_video_verify_cmd.c b/arch/arm/mach-msm/qdsp5/adsp_video_verify_cmd.c
deleted file mode 100644
index 62d6d58..0000000
--- a/arch/arm/mach-msm/qdsp5/adsp_video_verify_cmd.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/adsp_video_verify_cmd.c
- *
- * Verificion code for aDSP VDEC packets from userspace.
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (c) 2008-2010, 2012 The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/io.h>
-
-#include <mach/qdsp5/qdsp5vdeccmdi.h>
-#include "adsp.h"
-#include <mach/debug_mm.h>
-
-#define MAX_FLUSH_SIZE 160
-
-static inline void *high_low_short_to_ptr(unsigned short high,
-					  unsigned short low)
-{
-	return (void *)((((unsigned long)high) << 16) | ((unsigned long)low));
-}
-
-static inline void ptr_to_high_low_short(void *ptr, unsigned short *high,
-					 unsigned short *low)
-{
-	*high = (unsigned short)((((unsigned long)ptr) >> 16) & 0xffff);
-	*low = (unsigned short)((unsigned long)ptr & 0xffff);
-}
-
-static int pmem_fixup_high_low(unsigned short *high,
-				unsigned short *low,
-				unsigned short size_high,
-				unsigned short size_low,
-				struct msm_adsp_module *module,
-				unsigned long *addr, unsigned long *size,
-				struct file **filp, unsigned long *offset)
-{
-	void *phys_addr;
-	unsigned long phys_size;
-	unsigned long kvaddr;
-
-	phys_addr = high_low_short_to_ptr(*high, *low);
-	phys_size = (unsigned long)high_low_short_to_ptr(size_high, size_low);
-	MM_DBG("virt %x %x\n", (unsigned int)phys_addr,
-			(unsigned int)phys_size);
-	if (phys_addr) {
-		if (adsp_ion_fixup_kvaddr(module, &phys_addr,
-			 &kvaddr, phys_size, filp, offset)) {
-			MM_ERR("ah%x al%x sh%x sl%x addr %x size %x\n",
-					*high, *low, size_high,
-					size_low, (unsigned int)phys_addr,
-					(unsigned int)phys_size);
-			return -EINVAL;
-		}
-	}
-	ptr_to_high_low_short(phys_addr, high, low);
-	MM_DBG("phys %x %x\n", (unsigned int)phys_addr,
-			(unsigned int)phys_size);
-	if (addr)
-		*addr = kvaddr;
-	if (size)
-		*size = phys_size;
-	return 0;
-}
-
-static int verify_vdec_pkt_cmd(struct msm_adsp_module *module,
-			       void *cmd_data, size_t cmd_size)
-{
-	void *phys_addr;
-	unsigned short cmd_id = ((unsigned short *)cmd_data)[0];
-	viddec_cmd_subframe_pkt *pkt;
-	unsigned long subframe_pkt_addr;
-	unsigned long subframe_pkt_size;
-	unsigned short *frame_header_pkt;
-	int i, num_addr, col_addr = 0, skip;
-	int start_pos = 0, xdim_pos = 1, ydim_pos = 2;
-	unsigned short *frame_buffer_high, *frame_buffer_low;
-	unsigned long frame_buffer_size;
-	unsigned short frame_buffer_size_high, frame_buffer_size_low;
-	struct file *filp = NULL;
-	unsigned long offset = 0;
-	unsigned long Codec_Id = 0;
-
-	MM_DBG("cmd_size %d cmd_id %d cmd_data %x\n", cmd_size, cmd_id,
-					(unsigned int)cmd_data);
-	if (cmd_id != VIDDEC_CMD_SUBFRAME_PKT) {
-		MM_INFO("adsp_video: unknown video packet %u\n", cmd_id);
-		return 0;
-	}
-	if (cmd_size < sizeof(viddec_cmd_subframe_pkt))
-		return -1;
-
-	pkt = (viddec_cmd_subframe_pkt *)cmd_data;
-	phys_addr = high_low_short_to_ptr(pkt->subframe_packet_high,
-				pkt->subframe_packet_low);
-
-	if (pmem_fixup_high_low(&(pkt->subframe_packet_high),
-				&(pkt->subframe_packet_low),
-				pkt->subframe_packet_size_high,
-				pkt->subframe_packet_size_low,
-				module,
-				&subframe_pkt_addr,
-				&subframe_pkt_size,
-				&filp, &offset))
-		return -1;
-	Codec_Id = pkt->codec_selection_word;
-	/*Invalidate cache before accessing the cached pmem buffer*/
-	if (adsp_ion_do_cache_op(module, phys_addr, (void *)subframe_pkt_addr,
-		subframe_pkt_size*2, offset, ION_IOC_INV_CACHES)){
-		MM_ERR("Cache operation failed for" \
-			" phys addr high %x addr low %x\n",
-			pkt->subframe_packet_high, pkt->subframe_packet_low);
-		return -EINVAL;
-	}
-	/* deref those ptrs and check if they are a frame header packet */
-	frame_header_pkt = (unsigned short *)subframe_pkt_addr;
-	switch (frame_header_pkt[0]) {
-	case 0xB201: /* h.264 vld in dsp */
-	   if (Codec_Id == 0x8) {
-		num_addr = 16;
-		skip = 0;
-		start_pos = 5;
-	   } else {
-	       num_addr = 16;
-	       skip = 0;
-	       start_pos = 6;
-	       col_addr = 17;
-	   }
-		break;
-	case 0x8201: /* h.264 vld in arm */
-		num_addr = 16;
-		skip = 0;
-		start_pos = 6;
-		break;
-	case 0x4D01: /* mpeg-4 and h.263 vld in arm */
-		num_addr = 3;
-		skip = 0;
-		start_pos = 5;
-		break;
-	case 0x9201: /*For Real Decoder*/
-		num_addr = 2;
-		skip = 0;
-		start_pos = 5;
-		break;
-	case 0xBD01: /* mpeg-4 and h.263 vld in dsp */
-		num_addr = 3;
-		skip = 0;
-		start_pos = 6;
-		if (((frame_header_pkt[5] & 0x000c) >> 2) == 0x2) /* B-frame */
-			start_pos = 8;
-		break;
-	case 0x0001: /* wmv */
-		num_addr = 2;
-		skip = 0;
-		start_pos = 5;
-		break;
-	case 0xC201: /*WMV main profile*/
-		 num_addr = 3;
-		 skip = 0;
-		 start_pos = 6;
-		 break;
-	case 0xDD01: /* VP6 */
-		num_addr = 3;
-		skip = 0;
-		start_pos = 10;
-		break;
-	case 0xFD01: /* VP8 */
-		num_addr = 3;
-		skip = 0;
-		start_pos = 24;
-		break;
-	default:
-		return 0;
-	}
-
-	frame_buffer_high = &frame_header_pkt[start_pos];
-	frame_buffer_low = &frame_header_pkt[start_pos + 1];
-	frame_buffer_size = (frame_header_pkt[xdim_pos] *
-			     frame_header_pkt[ydim_pos] * 3) / 2;
-	ptr_to_high_low_short((void *)frame_buffer_size,
-			      &frame_buffer_size_high,
-			      &frame_buffer_size_low);
-	for (i = 0; i < num_addr; i++) {
-		if (frame_buffer_high && frame_buffer_low) {
-			if (pmem_fixup_high_low(frame_buffer_high,
-						frame_buffer_low,
-						frame_buffer_size_high,
-						frame_buffer_size_low,
-						module,
-						NULL, NULL, NULL, NULL))
-				return -EINVAL;
-	   }
-		frame_buffer_high += 2;
-		frame_buffer_low += 2;
-	}
-	/* Patch the output buffer. */
-	frame_buffer_high += 2*skip;
-	frame_buffer_low += 2*skip;
-	if (frame_buffer_high && frame_buffer_low) {
-		if (pmem_fixup_high_low(frame_buffer_high,
-					frame_buffer_low,
-					frame_buffer_size_high,
-					frame_buffer_size_low,
-					module,
-					NULL, NULL, NULL, NULL))
-			return -EINVAL;
-	}
-	if (col_addr) {
-		frame_buffer_high += 2;
-		frame_buffer_low += 2;
-		/* Patch the Co-located buffers.*/
-		frame_buffer_size =  (72 * frame_header_pkt[xdim_pos] *
-					frame_header_pkt[ydim_pos]) >> 16;
-		ptr_to_high_low_short((void *)frame_buffer_size,
-					&frame_buffer_size_high,
-					&frame_buffer_size_low);
-		for (i = 0; i < col_addr; i++) {
-			if (frame_buffer_high && frame_buffer_low) {
-				if (pmem_fixup_high_low(frame_buffer_high,
-						frame_buffer_low,
-						frame_buffer_size_high,
-						frame_buffer_size_low,
-						module,
-						NULL, NULL, NULL, NULL))
-					return -EINVAL;
-			}
-			frame_buffer_high += 2;
-			frame_buffer_low += 2;
-		}
-	}
-	/*Flush the cached mem subframe packet before sending to DSP*/
-	if (adsp_ion_do_cache_op(module,  phys_addr, (void *)subframe_pkt_addr,
-		MAX_FLUSH_SIZE, offset, ION_IOC_CLEAN_CACHES)){
-		MM_ERR("Cache operation failed for" \
-			" phys addr high %x addr low %x\n",
-			pkt->subframe_packet_high, pkt->subframe_packet_low);
-		return -EINVAL;
-	}
-	return 0;
-}
-
-int adsp_video_verify_cmd(struct msm_adsp_module *module,
-			 unsigned int queue_id, void *cmd_data,
-			 size_t cmd_size)
-{
-	switch (queue_id) {
-	case QDSP_mpuVDecPktQueue:
-		return verify_vdec_pkt_cmd(module, cmd_data, cmd_size);
-	default:
-		MM_INFO("unknown video queue %u\n", queue_id);
-		return 0;
-	}
-}
-
diff --git a/arch/arm/mach-msm/qdsp5/adsp_videoenc_verify_cmd.c b/arch/arm/mach-msm/qdsp5/adsp_videoenc_verify_cmd.c
deleted file mode 100644
index 1b16628..0000000
--- a/arch/arm/mach-msm/qdsp5/adsp_videoenc_verify_cmd.c
+++ /dev/null
@@ -1,235 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/adsp_video_verify_cmd.c
- *
- * Verificion code for aDSP VENC packets from userspace.
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (c) 2008-2009, 2012 The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/io.h>
-
-#include <mach/qdsp5/qdsp5venccmdi.h>
-#include "adsp.h"
-#include <mach/debug_mm.h>
-
-
-static unsigned short x_dimension, y_dimension;
-
-static inline void *high_low_short_to_ptr(unsigned short high,
-					  unsigned short low)
-{
-	return (void *)((((unsigned long)high) << 16) | ((unsigned long)low));
-}
-
-static inline void ptr_to_high_low_short(void *ptr, unsigned short *high,
-					 unsigned short *low)
-{
-	*high = (unsigned short)((((unsigned long)ptr) >> 16) & 0xffff);
-	*low = (unsigned short)((unsigned long)ptr & 0xffff);
-}
-
-static int pmem_fixup_high_low(unsigned short *high,
-				unsigned short *low,
-				unsigned short size_high,
-				unsigned short size_low,
-				struct msm_adsp_module *module,
-				unsigned long *addr, unsigned long *size)
-{
-	void *phys_addr;
-	unsigned long phys_size;
-	unsigned long kvaddr;
-
-	phys_addr = high_low_short_to_ptr(*high, *low);
-	phys_size = (unsigned long)high_low_short_to_ptr(size_high, size_low);
-	MM_DBG("virt %x %x\n", (unsigned int)phys_addr,
-			(unsigned int)phys_size);
-	if (adsp_ion_fixup_kvaddr(module, &phys_addr, &kvaddr, phys_size,
-				NULL, NULL)) {
-		MM_ERR("ah%x al%x sh%x sl%x addr %x size %x\n",
-			*high, *low, size_high,
-			size_low, (unsigned int)phys_addr,
-			(unsigned int) phys_size);
-		return -1;
-	}
-	ptr_to_high_low_short(phys_addr, high, low);
-	MM_DBG("phys %x %x\n", (unsigned int)phys_addr,
-			(unsigned int)phys_size);
-	if (addr)
-		*addr = kvaddr;
-	if (size)
-		*size = phys_size;
-	return 0;
-}
-
-static int verify_venc_cmd(struct msm_adsp_module *module,
-			       void *cmd_data, size_t cmd_size)
-{
-	unsigned short cmd_id = ((unsigned short *)cmd_data)[0];
-	unsigned long frame_buf_size, luma_buf_size, chroma_buf_size;
-	unsigned short frame_buf_size_high, frame_buf_size_low;
-	unsigned short luma_buf_size_high, luma_buf_size_low;
-	unsigned short chroma_buf_size_high, chroma_buf_size_low;
-	videnc_cmd_cfg *config_cmd;
-	videnc_cmd_frame_start *frame_cmd;
-	videnc_cmd_dis *dis_cmd;
-
-	MM_DBG("cmd_size %d cmd_id %d cmd_data %x\n",
-		cmd_size, cmd_id, (unsigned int)cmd_data);
-	switch (cmd_id) {
-	case VIDENC_CMD_ACTIVE:
-		if (cmd_size < sizeof(videnc_cmd_active))
-			return -1;
-		break;
-	case VIDENC_CMD_IDLE:
-		if (cmd_size < sizeof(videnc_cmd_idle))
-			return -1;
-		x_dimension = y_dimension = 0;
-		break;
-	case VIDENC_CMD_STATUS_QUERY:
-		if (cmd_size < sizeof(videnc_cmd_status_query))
-			return -1;
-		break;
-	case VIDENC_CMD_RC_CFG:
-		if (cmd_size < sizeof(videnc_cmd_rc_cfg))
-			return -1;
-		break;
-	case VIDENC_CMD_INTRA_REFRESH:
-		if (cmd_size < sizeof(videnc_cmd_intra_refresh))
-			return -1;
-		break;
-	case VIDENC_CMD_DIGITAL_ZOOM:
-		if (cmd_size < sizeof(videnc_cmd_digital_zoom))
-			return -1;
-		break;
-	case VIDENC_CMD_DIS_CFG:
-		if (cmd_size < sizeof(videnc_cmd_dis_cfg))
-			return -1;
-		break;
-	case VIDENC_CMD_VENC_CLOCK:
-		if (cmd_size < sizeof(struct videnc_cmd_venc_clock))
-			return -1;
-		break;
-	case VIDENC_CMD_CFG:
-		if (cmd_size < sizeof(videnc_cmd_cfg))
-			return -1;
-		config_cmd = (videnc_cmd_cfg *)cmd_data;
-		x_dimension = ((config_cmd->venc_frame_dim) & 0xFF00)>>8;
-		x_dimension = x_dimension*16;
-		y_dimension = (config_cmd->venc_frame_dim) & 0xFF;
-		y_dimension = y_dimension * 16;
-		break;
-	case VIDENC_CMD_FRAME_START:
-		if (cmd_size < sizeof(videnc_cmd_frame_start))
-			return -1;
-		frame_cmd = (videnc_cmd_frame_start *)cmd_data;
-		luma_buf_size = x_dimension * y_dimension;
-		chroma_buf_size = luma_buf_size>>1;
-		frame_buf_size = luma_buf_size + chroma_buf_size;
-		ptr_to_high_low_short((void *)luma_buf_size,
-			      &luma_buf_size_high,
-			      &luma_buf_size_low);
-		ptr_to_high_low_short((void *)chroma_buf_size,
-			      &chroma_buf_size_high,
-			      &chroma_buf_size_low);
-		ptr_to_high_low_short((void *)frame_buf_size,
-			      &frame_buf_size_high,
-			      &frame_buf_size_low);
-		/* Address of raw Y data. */
-		if (pmem_fixup_high_low(&frame_cmd->input_luma_addr_high,
-					&frame_cmd->input_luma_addr_low,
-					luma_buf_size_high,
-					luma_buf_size_low,
-					module,
-					NULL, NULL))
-			return -1;
-		/* Address of raw CbCr data */
-		if (pmem_fixup_high_low(&frame_cmd->input_chroma_addr_high,
-					&frame_cmd->input_chroma_addr_low,
-					chroma_buf_size_high,
-					chroma_buf_size_low,
-					module,
-					NULL, NULL))
-			return -1;
-		/* Reference VOP */
-		if (pmem_fixup_high_low(&frame_cmd->ref_vop_buf_ptr_high,
-					&frame_cmd->ref_vop_buf_ptr_low,
-					frame_buf_size_high,
-					frame_buf_size_low,
-					module,
-					NULL, NULL))
-			return -1;
-		/* Encoded Packet Address */
-		if (pmem_fixup_high_low(&frame_cmd->enc_pkt_buf_ptr_high,
-					&frame_cmd->enc_pkt_buf_ptr_low,
-					frame_cmd->enc_pkt_buf_size_high,
-					frame_cmd->enc_pkt_buf_size_low,
-					module,
-					NULL, NULL))
-			return -1;
-		/* Unfiltered VOP Buffer Address */
-		if (pmem_fixup_high_low(
-				&frame_cmd->unfilt_recon_vop_buf_ptr_high,
-				&frame_cmd->unfilt_recon_vop_buf_ptr_low,
-				frame_buf_size_high,
-				frame_buf_size_low,
-				module,
-				NULL, NULL))
-			return -1;
-		/* Filtered VOP Buffer Address */
-		if (pmem_fixup_high_low(&frame_cmd->filt_recon_vop_buf_ptr_high,
-					&frame_cmd->filt_recon_vop_buf_ptr_low,
-					frame_buf_size_high,
-					frame_buf_size_low,
-					module,
-					NULL, NULL))
-			return -1;
-		break;
-	case VIDENC_CMD_DIS:
-		if (cmd_size < sizeof(videnc_cmd_dis))
-			return -1;
-		dis_cmd = (videnc_cmd_dis *)cmd_data;
-		luma_buf_size = x_dimension * y_dimension;
-		ptr_to_high_low_short((void *)luma_buf_size,
-			      &luma_buf_size_high,
-			      &luma_buf_size_low);
-		/* Prev VFE Luma Output Address */
-		if (pmem_fixup_high_low(&dis_cmd->vfe_out_prev_luma_addr_high,
-					&dis_cmd->vfe_out_prev_luma_addr_low,
-					luma_buf_size_high,
-					luma_buf_size_low,
-					module,
-					NULL, NULL))
-			return -1;
-		break;
-	default:
-		MM_INFO("adsp_video:unknown encoder video cmd %u\n", cmd_id);
-		return 0;
-	}
-
-	return 0;
-}
-
-
-int adsp_videoenc_verify_cmd(struct msm_adsp_module *module,
-			 unsigned int queue_id, void *cmd_data,
-			 size_t cmd_size)
-{
-	switch (queue_id) {
-	case QDSP_mpuVEncCmdQueue:
-		return verify_venc_cmd(module, cmd_data, cmd_size);
-	default:
-		MM_INFO("unknown video queue %u\n", queue_id);
-		return 0;
-	}
-}
-
diff --git a/arch/arm/mach-msm/qdsp5/audio_aac.c b/arch/arm/mach-msm/qdsp5/audio_aac.c
deleted file mode 100644
index b82df8d..0000000
--- a/arch/arm/mach-msm/qdsp5/audio_aac.c
+++ /dev/null
@@ -1,1971 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/audio_aac.c
- *
- * aac audio decoder device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2008-2009, 2011-2012 The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/list.h>
-#include <linux/earlysuspend.h>
-#include <linux/slab.h>
-#include <linux/msm_audio_aac.h>
-#include <linux/memory_alloc.h>
-#include <linux/msm_ion.h>
-
-#include <mach/msm_adsp.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/qdsp5/qdsp5audppcmdi.h>
-#include <mach/qdsp5/qdsp5audppmsg.h>
-#include <mach/qdsp5/qdsp5audpp.h>
-#include <mach/qdsp5/qdsp5audplaycmdi.h>
-#include <mach/qdsp5/qdsp5audplaymsg.h>
-#include <mach/qdsp5/qdsp5rmtcmdi.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_memtypes.h>
-
-#include "audmgr.h"
-
-#define BUFSZ 32768
-#define DMASZ (BUFSZ * 2)
-#define BUFSZ_MIN 4096
-#define DMASZ_MIN (BUFSZ_MIN * 2)
-
-#define AUDPLAY_INVALID_READ_PTR_OFFSET	0xFFFF
-#define AUDDEC_DEC_AAC 5
-
-#define PCM_BUFSZ_MIN 9600	/* Hold one stereo AAC frame */
-#define PCM_BUF_MAX_COUNT 5	/* DSP only accepts 5 buffers at most
-				   but support 2 buffers currently */
-#define ROUTING_MODE_FTRT 1
-#define ROUTING_MODE_RT 2
-/* Decoder status received from AUDPPTASK */
-#define  AUDPP_DEC_STATUS_SLEEP	0
-#define	 AUDPP_DEC_STATUS_INIT  1
-#define  AUDPP_DEC_STATUS_CFG   2
-#define  AUDPP_DEC_STATUS_PLAY  3
-
-#define AUDAAC_METAFIELD_MASK 0xFFFF0000
-#define AUDAAC_EOS_FLG_OFFSET 0x0A /* Offset from beginning of buffer */
-#define AUDAAC_EOS_FLG_MASK 0x01
-#define AUDAAC_EOS_NONE 0x0 /* No EOS detected */
-#define AUDAAC_EOS_SET 0x1 /* EOS set in meta field */
-
-#define AUDAAC_EVENT_NUM 10 /* Default number of pre-allocated event packets */
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;		/* Input usage actual DSP produced PCM size  */
-	unsigned addr;
-	unsigned short mfield_sz; /*only useful for data has meta field */
-};
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-struct audaac_suspend_ctl {
-	struct early_suspend node;
-	struct audio *audio;
-};
-#endif
-
-struct audaac_event{
-	struct list_head list;
-	int event_type;
-	union msm_audio_event_payload payload;
-};
-
-struct audio {
-	struct buffer out[2];
-
-	spinlock_t dsp_lock;
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed;	/* number of buffers the dsp is waiting for */
-	unsigned out_dma_sz;
-
-	atomic_t out_bytes;
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-
-	/* Host PCM section */
-	struct buffer in[PCM_BUF_MAX_COUNT];
-	struct mutex read_lock;
-	wait_queue_head_t read_wait;	/* Wait queue for read */
-	char *read_data;	/* pointer to reader buffer */
-	int32_t read_phys;	/* physical address of reader buffer */
-	uint8_t read_next;	/* index to input buffers to be read next */
-	uint8_t fill_next;	/* index to buffer that DSP should be filling */
-	uint8_t pcm_buf_count;	/* number of pcm buffer allocated */
-	/* ---- End of Host PCM section */
-
-	struct msm_adsp_module *audplay;
-	void *map_v_read;
-	void *map_v_write;
-
-	/* configuration to use on next enable */
-	uint32_t out_sample_rate;
-	uint32_t out_channel_mode;
-	struct msm_audio_aac_config aac_config;
-	struct audmgr audmgr;
-
-	/* data allocated for various buffers */
-	char *data;
-	int32_t phys; /* physical address of write buffer */
-
-	int mfield; /* meta field embedded in data */
-	int rflush; /* Read  flush */
-	int eos_in_progress;
-	int wflush; /* Write flush */
-	int opened;
-	int enabled;
-	int running;
-	int stopped;	/* set when stopped, cleared on flush */
-	int pcm_feedback;
-	int buf_refresh;
-	int rmt_resource_released;
-	int teos; /* valid only if tunnel mode & no data left for decoder */
-	enum msm_aud_decoder_state dec_state;	/* Represents decoder state */
-	int reserved; /* A byte is being reserved */
-	char rsv_byte; /* Handle odd length user data */
-
-	const char *module_name;
-	unsigned queue_id;
-	uint16_t dec_id;
-	uint32_t read_ptr_offset;
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	struct audaac_suspend_ctl suspend_ctl;
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *dentry;
-#endif
-
-	wait_queue_head_t wait;
-	struct list_head free_event_queue;
-	struct list_head event_queue;
-	wait_queue_head_t event_wait;
-	spinlock_t event_queue_lock;
-	struct mutex get_event_lock;
-	int event_abort;
-
-	struct msm_audio_bitstream_info stream_info;
-
-	int eq_enable;
-	int eq_needs_commit;
-	audpp_cmd_cfg_object_params_eqalizer eq;
-	audpp_cmd_cfg_object_params_volume vol_pan;
-	struct ion_client *client;
-	struct ion_handle *input_buff_handle;
-	struct ion_handle *output_buff_handle;
-};
-
-static int auddec_dsp_config(struct audio *audio, int enable);
-static void audpp_cmd_cfg_adec_params(struct audio *audio);
-static void audpp_cmd_cfg_routing_mode(struct audio *audio);
-static void audplay_send_data(struct audio *audio, unsigned needed);
-static void audplay_config_hostpcm(struct audio *audio);
-static void audplay_buffer_refresh(struct audio *audio);
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg);
-static void audaac_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload);
-
-static int rmt_put_resource(struct audio *audio)
-{
-	struct aud_codec_config_cmd cmd;
-	unsigned short client_idx;
-
-	cmd.cmd_id = RM_CMD_AUD_CODEC_CFG;
-	cmd.client_id = RM_AUD_CLIENT_ID;
-	cmd.task_id = audio->dec_id;
-	cmd.enable = RMT_DISABLE;
-	cmd.dec_type = AUDDEC_DEC_AAC;
-	client_idx = ((cmd.client_id << 8) | cmd.task_id);
-
-	return put_adsp_resource(client_idx, &cmd, sizeof(cmd));
-}
-
-static int rmt_get_resource(struct audio *audio)
-{
-	struct aud_codec_config_cmd cmd;
-	unsigned short client_idx;
-
-	cmd.cmd_id = RM_CMD_AUD_CODEC_CFG;
-	cmd.client_id = RM_AUD_CLIENT_ID;
-	cmd.task_id = audio->dec_id;
-	cmd.enable = RMT_ENABLE;
-	cmd.dec_type = AUDDEC_DEC_AAC;
-	client_idx = ((cmd.client_id << 8) | cmd.task_id);
-
-	return get_adsp_resource(client_idx, &cmd, sizeof(cmd));
-}
-
-/* must be called with audio->lock held */
-static int audio_enable(struct audio *audio)
-{
-	struct audmgr_config cfg;
-	int rc;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	if (audio->enabled)
-		return 0;
-
-	if (audio->rmt_resource_released == 1) {
-		audio->rmt_resource_released = 0;
-		rc = rmt_get_resource(audio);
-		if (rc) {
-			MM_ERR("ADSP resources are not available for AAC \
-				session 0x%08x on decoder: %d\n Ignoring \
-				error and going ahead with the playback\n",
-				(int)audio, audio->dec_id);
-		}
-	}
-
-	audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-
-	if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK) {
-		cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE;
-		cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000;
-		cfg.def_method = RPC_AUD_DEF_METHOD_PLAYBACK;
-		cfg.codec = RPC_AUD_DEF_CODEC_AAC;
-		cfg.snd_method = RPC_SND_METHOD_MIDI;
-
-		rc = audmgr_enable(&audio->audmgr, &cfg);
-		if (rc < 0) {
-			msm_adsp_dump(audio->audplay);
-			return rc;
-		}
-	}
-
-	if (msm_adsp_enable(audio->audplay)) {
-		MM_ERR("msm_adsp_enable(audplay) failed\n");
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_disable(&audio->audmgr);
-		return -ENODEV;
-	}
-
-	if (audpp_enable(audio->dec_id, audio_dsp_event, audio)) {
-		MM_ERR("audpp_enable() failed\n");
-		msm_adsp_disable(audio->audplay);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_disable(&audio->audmgr);
-		return -ENODEV;
-	}
-	audio->enabled = 1;
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audio_disable(struct audio *audio)
-{
-	int rc = 0;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-		auddec_dsp_config(audio, 0);
-		rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-		if (rc == 0)
-			rc = -ETIMEDOUT;
-		else if (audio->dec_state != MSM_AUD_DECODER_STATE_CLOSE)
-			rc = -EFAULT;
-		else
-			rc = 0;
-		audio->stopped = 1;
-		wake_up(&audio->write_wait);
-		wake_up(&audio->read_wait);
-		msm_adsp_disable(audio->audplay);
-		audpp_disable(audio->dec_id, audio);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK) {
-			rc = audmgr_disable(&audio->audmgr);
-			if (rc < 0)
-				msm_adsp_dump(audio->audplay);
-		}
-
-		audio->out_needed = 0;
-		rmt_put_resource(audio);
-		audio->rmt_resource_released = 1;
-	}
-	return rc;
-}
-
-/* ------------------- dsp --------------------- */
-static void audio_update_pcm_buf_entry(struct audio *audio, uint32_t *payload)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	if (audio->rflush)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < payload[1]; index++) {
-		if (audio->in[audio->fill_next].addr ==
-		    payload[2 + index * 2]) {
-			MM_DBG("in[%d] ready\n", audio->fill_next);
-			audio->in[audio->fill_next].used =
-				payload[3 + index * 2];
-			if ((++audio->fill_next) == audio->pcm_buf_count)
-				audio->fill_next = 0;
-
-		} else {
-			MM_ERR("expected=%x ret=%x\n",
-				audio->in[audio->fill_next].addr,
-				payload[1 + index * 2]);
-			break;
-		}
-	}
-	if (audio->in[audio->fill_next].used == 0) {
-		audplay_buffer_refresh(audio);
-	} else {
-		MM_DBG("read cannot keep up\n");
-		audio->buf_refresh = 1;
-	}
-	wake_up(&audio->read_wait);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-
-}
-static void audaac_update_stream_info(struct audio *audio, uint32_t *payload)
-{
-	unsigned long flags;
-	union msm_audio_event_payload e_payload;
-
-	/* get stream info from DSP msg */
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-
-	audio->stream_info.codec_type = AUDIO_CODEC_TYPE_AAC;
-	audio->stream_info.chan_info = (0x0000FFFF & payload[1]);
-	audio->stream_info.sample_rate = (0x0000FFFF & payload[2]);
-	audio->stream_info.bit_stream_info = (0x0000FFFF & payload[3]);
-	audio->stream_info.bit_rate = payload[4];
-
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	MM_DBG("chan_info=%d, sample_rate=%d, bit_stream_info=%d\n",
-			audio->stream_info.chan_info,
-			audio->stream_info.sample_rate,
-			audio->stream_info.bit_stream_info);
-
-	/* send event to ARM to notify steam info coming */
-	e_payload.stream_info = audio->stream_info;
-	audaac_post_event(audio, AUDIO_EVENT_STREAM_INFO, e_payload);
-}
-static void audplay_dsp_event(void *data, unsigned id, size_t len,
-			      void (*getevent) (void *ptr, size_t len))
-{
-	struct audio *audio = data;
-	uint32_t msg[28];
-	getevent(msg, sizeof(msg));
-
-	MM_DBG("msg_id=%x\n", id);
-
-	switch (id) {
-	case AUDPLAY_MSG_DEC_NEEDS_DATA:
-		audplay_send_data(audio, 1);
-		break;
-
-	case AUDPLAY_MSG_BUFFER_UPDATE:
-		audio_update_pcm_buf_entry(audio, msg);
-		break;
-
-	case AUDPLAY_UP_STREAM_INFO:
-		audaac_update_stream_info(audio, msg);
-		break;
-
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audplaytask)\n");
-		break;
-
-	default:
-		MM_ERR("unexpected message from decoder \n");
-	}
-}
-
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg)
-{
-	struct audio *audio = private;
-
-	switch (id) {
-	case AUDPP_MSG_STATUS_MSG:{
-			unsigned status = msg[1];
-
-			switch (status) {
-			case AUDPP_DEC_STATUS_SLEEP: {
-				uint16_t reason = msg[2];
-				MM_DBG("decoder status: sleep reason = \
-						0x%04x\n", reason);
-				if ((reason == AUDPP_MSG_REASON_MEM)
-					|| (reason ==
-					AUDPP_MSG_REASON_NODECODER)) {
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_FAILURE;
-					wake_up(&audio->wait);
-				} else if (reason == AUDPP_MSG_REASON_NONE) {
-					/* decoder is in disable state */
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_CLOSE;
-					wake_up(&audio->wait);
-				}
-				break;
-			}
-			case AUDPP_DEC_STATUS_INIT:
-				MM_DBG("decoder status: init \n");
-				if (audio->pcm_feedback)
-					audpp_cmd_cfg_routing_mode(audio);
-				else
-					audpp_cmd_cfg_adec_params(audio);
-				break;
-
-			case AUDPP_DEC_STATUS_CFG:
-				MM_DBG("decoder status: cfg \n");
-				break;
-			case AUDPP_DEC_STATUS_PLAY:
-				MM_DBG("decoder status: play \n");
-				if (audio->pcm_feedback) {
-					audplay_config_hostpcm(audio);
-					audplay_buffer_refresh(audio);
-				}
-				audio->dec_state =
-					MSM_AUD_DECODER_STATE_SUCCESS;
-				wake_up(&audio->wait);
-				break;
-			default:
-				MM_ERR("unknown decoder status \n");
-			}
-			break;
-		}
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_DBG("CFG_MSG ENABLE\n");
-			auddec_dsp_config(audio, 1);
-			audio->out_needed = 0;
-			audio->running = 1;
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-			audpp_dsp_set_eq(audio->dec_id, audio->eq_enable,
-								&audio->eq);
-			audpp_avsync(audio->dec_id, 22050);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			MM_DBG("CFG_MSG DISABLE\n");
-			audpp_avsync(audio->dec_id, 0);
-			audio->running = 0;
-		} else {
-			MM_DBG("CFG_MSG %d?\n",	msg[0]);
-		}
-		break;
-	case AUDPP_MSG_ROUTING_ACK:
-		MM_DBG("ROUTING_ACK mode=%d\n",	msg[1]);
-		audpp_cmd_cfg_adec_params(audio);
-		break;
-
-	case AUDPP_MSG_FLUSH_ACK:
-		MM_DBG("FLUSH_ACK\n");
-		audio->wflush = 0;
-		audio->rflush = 0;
-		wake_up(&audio->write_wait);
-		if (audio->pcm_feedback)
-			audplay_buffer_refresh(audio);
-		break;
-
-	case AUDPP_MSG_PCMDMAMISSED:
-		MM_DBG("PCMDMAMISSED\n");
-		audio->teos = 1;
-		wake_up(&audio->write_wait);
-		break;
-
-	default:
-		MM_ERR("UNKNOWN (%d)\n", id);
-	}
-
-}
-
-struct msm_adsp_ops audplay_adsp_ops_aac = {
-	.event = audplay_dsp_event,
-};
-
-#define audplay_send_queue0(audio, cmd, len) \
-	msm_adsp_write(audio->audplay, audio->queue_id,\
-			cmd, len)
-
-static int auddec_dsp_config(struct audio *audio, int enable)
-{
-	u16 cfg_dec_cmd[AUDPP_CMD_CFG_DEC_TYPE_LEN / sizeof(unsigned short)];
-
-	memset(cfg_dec_cmd, 0, sizeof(cfg_dec_cmd));
-	cfg_dec_cmd[0] = AUDPP_CMD_CFG_DEC_TYPE;
-
-	if (enable)
-		cfg_dec_cmd[1 + audio->dec_id] = AUDPP_CMD_UPDATDE_CFG_DEC |
-			AUDPP_CMD_ENA_DEC_V | AUDDEC_DEC_AAC;
-	else
-		cfg_dec_cmd[1 + audio->dec_id] = AUDPP_CMD_UPDATDE_CFG_DEC |
-		AUDPP_CMD_DIS_DEC_V;
-
-	return audpp_send_queue1(&cfg_dec_cmd, sizeof(cfg_dec_cmd));
-}
-
-static void audpp_cmd_cfg_adec_params(struct audio *audio)
-{
-	audpp_cmd_cfg_adec_params_aac cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_CMD_CFG_ADEC_PARAMS;
-	cmd.common.length = AUDPP_CMD_CFG_ADEC_PARAMS_AAC_LEN;
-	cmd.common.dec_id = audio->dec_id;
-	cmd.common.input_sampling_frequency = audio->out_sample_rate;
-	cmd.format = audio->aac_config.format;
-	cmd.audio_object = audio->aac_config.audio_object;
-	cmd.ep_config = audio->aac_config.ep_config;
-	cmd.aac_section_data_resilience_flag =
-		audio->aac_config.aac_section_data_resilience_flag;
-	cmd.aac_scalefactor_data_resilience_flag =
-		audio->aac_config.aac_scalefactor_data_resilience_flag;
-	cmd.aac_spectral_data_resilience_flag =
-		audio->aac_config.aac_spectral_data_resilience_flag;
-	cmd.sbr_on_flag = audio->aac_config.sbr_on_flag;
-	cmd.sbr_ps_on_flag = audio->aac_config.sbr_ps_on_flag;
-	cmd.channel_configuration = audio->aac_config.channel_configuration;
-
-	audpp_send_queue2(&cmd, sizeof(cmd));
-}
-
-static void audpp_cmd_cfg_routing_mode(struct audio *audio)
-{
-	struct audpp_cmd_routing_mode cmd;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPP_CMD_ROUTING_MODE;
-	cmd.object_number = audio->dec_id;
-	if (audio->pcm_feedback)
-		cmd.routing_mode = ROUTING_MODE_FTRT;
-	else
-		cmd.routing_mode = ROUTING_MODE_RT;
-
-	audpp_send_queue1(&cmd, sizeof(cmd));
-}
-
-static int audplay_dsp_send_data_avail(struct audio *audio,
-				       unsigned idx, unsigned len)
-{
-	struct audplay_cmd_bitstream_data_avail_nt2 cmd;
-
-	cmd.cmd_id = AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2;
-	if (audio->mfield)
-		cmd.decoder_id = AUDAAC_METAFIELD_MASK |
-			(audio->out[idx].mfield_sz >> 1);
-	else
-	    cmd.decoder_id = audio->dec_id;
-	cmd.buf_ptr = audio->out[idx].addr;
-	cmd.buf_size = len / 2;
-	cmd.partition_number = 0;
-	/* complete all the writes to the input buffer */
-	wmb();
-	return audplay_send_queue0(audio, &cmd, sizeof(cmd));
-}
-
-static void audplay_buffer_refresh(struct audio *audio)
-{
-	struct audplay_cmd_buffer_refresh refresh_cmd;
-
-	refresh_cmd.cmd_id = AUDPLAY_CMD_BUFFER_REFRESH;
-	refresh_cmd.num_buffers = 1;
-	refresh_cmd.buf0_address = audio->in[audio->fill_next].addr;
-	/* AAC frame size */
-	refresh_cmd.buf0_length = audio->in[audio->fill_next].size -
-		(audio->in[audio->fill_next].size % 1024)
-		+ (audio->mfield ? 24 : 0);
-	refresh_cmd.buf_read_count = 0;
-	MM_DBG("buf0_addr=%x buf0_len=%d\n", refresh_cmd.buf0_address,
-			refresh_cmd.buf0_length);
-	(void)audplay_send_queue0(audio, &refresh_cmd, sizeof(refresh_cmd));
-}
-
-static void audplay_config_hostpcm(struct audio *audio)
-{
-	struct audplay_cmd_hpcm_buf_cfg cfg_cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	cfg_cmd.cmd_id = AUDPLAY_CMD_HPCM_BUF_CFG;
-	cfg_cmd.max_buffers = audio->pcm_buf_count;
-	cfg_cmd.byte_swap = 0;
-	cfg_cmd.hostpcm_config = (0x8000) | (0x4000);
-	cfg_cmd.feedback_frequency = 1;
-	cfg_cmd.partition_number = 0;
-	(void)audplay_send_queue0(audio, &cfg_cmd, sizeof(cfg_cmd));
-
-}
-
-static void audplay_send_data(struct audio *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			MM_DBG("frame %d free\n", audio->out_tail);
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		} else if ((audio->out[0].used == 0) &&
-			 (audio->out[1].used == 0) &&
-			 (audio->eos_in_progress)) {
-			wake_up(&audio->write_wait);
-		}
-
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			MM_DBG("frame %d busy\n", audio->out_tail);
-			audplay_dsp_send_data_avail(audio, audio->out_tail,
-						    frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
- done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-
-static void audio_flush(struct audio *audio)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->out[0].used = 0;
-	audio->out[1].used = 0;
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->reserved = 0;
-	audio->out_needed = 0;
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	atomic_set(&audio->out_bytes, 0);
-}
-
-static void audio_flush_pcm_buf(struct audio *audio)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < PCM_BUF_MAX_COUNT; index++)
-		audio->in[index].used = 0;
-	audio->buf_refresh = 0;
-	audio->read_next = 0;
-	audio->fill_next = 0;
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static int audaac_validate_usr_config(struct msm_audio_aac_config *config)
-{
-	int ret_val = -1;
-
-	if (config->format != AUDIO_AAC_FORMAT_ADTS &&
-		config->format != AUDIO_AAC_FORMAT_RAW &&
-		config->format != AUDIO_AAC_FORMAT_PSUEDO_RAW &&
-		config->format != AUDIO_AAC_FORMAT_LOAS)
-		goto done;
-
-	if (config->audio_object != AUDIO_AAC_OBJECT_LC &&
-		config->audio_object != AUDIO_AAC_OBJECT_LTP &&
-		config->audio_object != AUDIO_AAC_OBJECT_BSAC &&
-		config->audio_object != AUDIO_AAC_OBJECT_ERLC)
-		goto done;
-
-	if (config->audio_object == AUDIO_AAC_OBJECT_ERLC) {
-		if (config->ep_config > 3)
-			goto done;
-		if (config->aac_scalefactor_data_resilience_flag !=
-			AUDIO_AAC_SCA_DATA_RES_OFF &&
-			config->aac_scalefactor_data_resilience_flag !=
-			AUDIO_AAC_SCA_DATA_RES_ON)
-			goto done;
-		if (config->aac_section_data_resilience_flag !=
-			AUDIO_AAC_SEC_DATA_RES_OFF &&
-			config->aac_section_data_resilience_flag !=
-			AUDIO_AAC_SEC_DATA_RES_ON)
-			goto done;
-		if (config->aac_spectral_data_resilience_flag !=
-			AUDIO_AAC_SPEC_DATA_RES_OFF &&
-			config->aac_spectral_data_resilience_flag !=
-			AUDIO_AAC_SPEC_DATA_RES_ON)
-			goto done;
-	} else {
-		config->aac_section_data_resilience_flag =
-			AUDIO_AAC_SEC_DATA_RES_OFF;
-		config->aac_scalefactor_data_resilience_flag =
-			AUDIO_AAC_SCA_DATA_RES_OFF;
-		config->aac_spectral_data_resilience_flag =
-			AUDIO_AAC_SPEC_DATA_RES_OFF;
-	}
-
-#ifndef CONFIG_AUDIO_AAC_PLUS
-	if (AUDIO_AAC_SBR_ON_FLAG_OFF != config->sbr_on_flag)
-		goto done;
-#else
-	if (config->sbr_on_flag != AUDIO_AAC_SBR_ON_FLAG_OFF &&
-		config->sbr_on_flag != AUDIO_AAC_SBR_ON_FLAG_ON)
-		goto done;
-#endif
-
-#ifndef CONFIG_AUDIO_ENHANCED_AAC_PLUS
-	if (AUDIO_AAC_SBR_PS_ON_FLAG_OFF != config->sbr_ps_on_flag)
-		goto done;
-#else
-	if (config->sbr_ps_on_flag != AUDIO_AAC_SBR_PS_ON_FLAG_OFF &&
-		config->sbr_ps_on_flag != AUDIO_AAC_SBR_PS_ON_FLAG_ON)
-		goto done;
-#endif
-
-	if (config->dual_mono_mode > AUDIO_AAC_DUAL_MONO_PL_SR)
-		goto done;
-
-	if (config->channel_configuration > 2)
-		goto done;
-
-	ret_val = 0;
- done:
-	return ret_val;
-}
-
-static void audio_ioport_reset(struct audio *audio)
-{
-	/* Make sure read/write thread are free from
-	 * sleep and knowing that system is not able
-	 * to process io request at the moment
-	 */
-	wake_up(&audio->write_wait);
-	mutex_lock(&audio->write_lock);
-	audio_flush(audio);
-	mutex_unlock(&audio->write_lock);
-	wake_up(&audio->read_wait);
-	mutex_lock(&audio->read_lock);
-	audio_flush_pcm_buf(audio);
-	mutex_unlock(&audio->read_lock);
-}
-
-static int audaac_events_pending(struct audio *audio)
-{
-	unsigned long flags;
-	int empty;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	empty = !list_empty(&audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	return empty || audio->event_abort;
-}
-
-static void audaac_reset_event_queue(struct audio *audio)
-{
-	unsigned long flags;
-	struct audaac_event *drv_evt;
-	struct list_head *ptr, *next;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	list_for_each_safe(ptr, next, &audio->event_queue) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audaac_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	list_for_each_safe(ptr, next, &audio->free_event_queue) {
-		drv_evt = list_first_entry(&audio->free_event_queue,
-				struct audaac_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	return;
-}
-
-static long audaac_process_event_req(struct audio *audio, void __user *arg)
-{
-	long rc;
-	struct msm_audio_event usr_evt;
-	struct audaac_event *drv_evt = NULL;
-	int timeout;
-	unsigned long flags;
-
-	if (copy_from_user(&usr_evt, arg, sizeof(struct msm_audio_event)))
-		return -EFAULT;
-
-	timeout = (int) usr_evt.timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(
-			audio->event_wait, audaac_events_pending(audio),
-			msecs_to_jiffies(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(
-			audio->event_wait, audaac_events_pending(audio));
-	}
-
-	if (rc < 0)
-		return rc;
-
-	if (audio->event_abort) {
-		audio->event_abort = 0;
-		return -ENODEV;
-	}
-
-	rc = 0;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	if (!list_empty(&audio->event_queue)) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audaac_event, list);
-		list_del(&drv_evt->list);
-	}
-	if (drv_evt) {
-		usr_evt.event_type = drv_evt->event_type;
-		usr_evt.event_payload = drv_evt->payload;
-		list_add_tail(&drv_evt->list, &audio->free_event_queue);
-	} else
-		rc = -1;
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	if (!rc && copy_to_user(arg, &usr_evt, sizeof(usr_evt)))
-		rc = -EFAULT;
-
-	return rc;
-}
-
-static int audio_enable_eq(struct audio *audio, int enable)
-{
-	if (audio->eq_enable == enable && !audio->eq_needs_commit)
-		return 0;
-
-	audio->eq_enable = enable;
-
-	if (audio->running) {
-		audpp_dsp_set_eq(audio->dec_id, enable, &audio->eq);
-		audio->eq_needs_commit = 0;
-	}
-	return 0;
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = -EINVAL;
-	unsigned long flags = 0;
-	uint16_t enable_mask;
-	int enable;
-	int prev_state;
-
-	MM_DBG("cmd = %d\n", cmd);
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		stats.byte_count = audpp_avsync_byte_count(audio->dec_id);
-		stats.sample_count = audpp_avsync_sample_count(audio->dec_id);
-		if (copy_to_user((void *)arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-
-	switch (cmd) {
-	case AUDIO_ENABLE_AUDPP:
-		if (copy_from_user(&enable_mask, (void *) arg,
-						sizeof(enable_mask))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		enable = (enable_mask & EQ_ENABLE) ? 1 : 0;
-		audio_enable_eq(audio, enable);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-	case AUDIO_SET_VOLUME:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.volume = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_PAN:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.pan = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_EQ:
-		prev_state = audio->eq_enable;
-		audio->eq_enable = 0;
-		if (copy_from_user(&audio->eq.num_bands, (void *) arg,
-				sizeof(audio->eq) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2))) {
-			rc = -EFAULT;
-			break;
-		}
-		audio->eq_enable = prev_state;
-		audio->eq_needs_commit = 1;
-		rc = 0;
-		break;
-	}
-
-	if (-EINVAL != rc)
-		return rc;
-
-	if (cmd == AUDIO_GET_EVENT) {
-		MM_DBG("AUDIO_GET_EVENT\n");
-		if (mutex_trylock(&audio->get_event_lock)) {
-			rc = audaac_process_event_req(audio,
-					(void __user *) arg);
-			mutex_unlock(&audio->get_event_lock);
-		} else
-			rc = -EBUSY;
-		return rc;
-	}
-
-	if (cmd == AUDIO_ABORT_GET_EVENT) {
-		audio->event_abort = 1;
-		wake_up(&audio->event_wait);
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		MM_DBG("AUDIO_START\n");
-		rc = audio_enable(audio);
-		if (!rc) {
-			rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-			MM_INFO("dec_state %d rc = %d\n", audio->dec_state, rc);
-
-			if (audio->dec_state != MSM_AUD_DECODER_STATE_SUCCESS)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		break;
-	case AUDIO_STOP:
-		MM_DBG("AUDIO_STOP\n");
-		rc = audio_disable(audio);
-		audio_ioport_reset(audio);
-		audio->stopped = 0;
-		break;
-	case AUDIO_FLUSH:
-		MM_DBG("AUDIO_FLUSH running=%d\n", audio->running);
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audio_ioport_reset(audio);
-		if (audio->running) {
-			audpp_flush(audio->dec_id);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-
-	case AUDIO_SET_CONFIG:{
-			struct msm_audio_config config;
-
-			if (copy_from_user
-			    (&config, (void *)arg, sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-
-			if (config.channel_count == 1) {
-				config.channel_count =
-				    AUDPP_CMD_PCM_INTF_MONO_V;
-			} else if (config.channel_count == 2) {
-				config.channel_count =
-				    AUDPP_CMD_PCM_INTF_STEREO_V;
-			} else {
-				rc = -EINVAL;
-				break;
-			}
-
-			audio->out_sample_rate = config.sample_rate;
-			audio->out_channel_mode = config.channel_count;
-			audio->mfield = config.meta_field;
-			rc = 0;
-			break;
-		}
-	case AUDIO_GET_CONFIG:{
-			struct msm_audio_config config;
-			config.buffer_size = (audio->out_dma_sz >> 1);
-			config.buffer_count = 2;
-			config.sample_rate = audio->out_sample_rate;
-			if (audio->out_channel_mode ==
-			    AUDPP_CMD_PCM_INTF_MONO_V) {
-				config.channel_count = 1;
-			} else {
-				config.channel_count = 2;
-			}
-			config.meta_field = 0;
-			config.unused[0] = 0;
-			config.unused[1] = 0;
-			config.unused[2] = 0;
-			if (copy_to_user((void *)arg, &config,
-					 sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-
-			break;
-		}
-	case AUDIO_GET_AAC_CONFIG:{
-			if (copy_to_user((void *)arg, &audio->aac_config,
-				sizeof(audio->aac_config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_SET_AAC_CONFIG:{
-			struct msm_audio_aac_config usr_config;
-
-			if (copy_from_user
-				(&usr_config, (void *)arg,
-					sizeof(usr_config))) {
-				rc = -EFAULT;
-				break;
-			}
-
-			if (audaac_validate_usr_config(&usr_config) == 0) {
-				audio->aac_config = usr_config;
-				rc = 0;
-			} else
-				rc = -EINVAL;
-
-			break;
-		}
-	case AUDIO_GET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			config.pcm_feedback = audio->pcm_feedback;
-			config.buffer_count = PCM_BUF_MAX_COUNT;
-			config.buffer_size = PCM_BUFSZ_MIN;
-			if (copy_to_user((void *)arg, &config,
-					 sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_SET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			if (copy_from_user
-			    (&config, (void *)arg, sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-			if (config.pcm_feedback != audio->pcm_feedback) {
-				MM_ERR("Not sufficient permission to"
-					 "change the playback mode\n");
-				rc = -EACCES;
-				break;
-			}
-			if ((config.buffer_count > PCM_BUF_MAX_COUNT) ||
-			    (config.buffer_count == 1))
-				config.buffer_count = PCM_BUF_MAX_COUNT;
-
-			if (config.buffer_size < PCM_BUFSZ_MIN)
-				config.buffer_size = PCM_BUFSZ_MIN;
-
-			/* Check if pcm feedback is required */
-			if (config.pcm_feedback) {
-					audio->buf_refresh = 0;
-					audio->read_next = 0;
-					audio->fill_next = 0;
-			}
-			rc = 0;
-			break;
-		}
-	case AUDIO_PAUSE:
-		MM_DBG("AUDIO_PAUSE %ld\n", arg);
-		rc = audpp_pause(audio->dec_id, (int) arg);
-		break;
-	case AUDIO_GET_STREAM_INFO:{
-		if (audio->stream_info.sample_rate == 0) {
-			/* haven't received DSP stream event,
-			the stream info is not updated */
-			rc = -EPERM;
-			break;
-		}
-		if (copy_to_user((void *)arg, &audio->stream_info,
-			sizeof(struct msm_audio_bitstream_info)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-/* Only useful in tunnel-mode */
-static int audaac_fsync(struct file *file, loff_t a, loff_t b, int datasync)
-{
-	struct audio *audio = file->private_data;
-	struct buffer *frame;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	if (!audio->running || audio->pcm_feedback) {
-		rc = -EINVAL;
-		goto done_nolock;
-	}
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(!audio->out[0].used &&
-		!audio->out[1].used &&
-		audio->out_needed) || audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (audio->reserved) {
-		MM_DBG("send reserved byte\n");
-		frame = audio->out + audio->out_tail;
-		((char *) frame->data)[0] = audio->rsv_byte;
-		((char *) frame->data)[1] = 0;
-		frame->used = 2;
-		audplay_send_data(audio, 0);
-
-		rc = wait_event_interruptible(audio->write_wait,
-			(!audio->out[0].used &&
-			!audio->out[1].used &&
-			audio->out_needed) || audio->wflush);
-
-		if (rc < 0)
-			goto done;
-		else if (audio->wflush) {
-			rc = -EBUSY;
-			goto done;
-		}
-	}
-
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		audio->teos || audio->wflush);
-
-	if (audio->wflush)
-		rc = -EBUSY;
-
-done:
-	mutex_unlock(&audio->write_lock);
-done_nolock:
-	return rc;
-}
-
-static ssize_t audio_read(struct file *file, char __user *buf, size_t count,
-			  loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	int rc = 0;
-
-	if (!audio->pcm_feedback)
-		return 0; /* PCM feedback is not enabled. Nothing to read */
-
-	mutex_lock(&audio->read_lock);
-	MM_DBG("to read %d \n", count);
-	while (count > 0) {
-		rc = wait_event_interruptible(audio->read_wait,
-					      (audio->in[audio->read_next].
-						used > 0) || (audio->stopped)
-						|| (audio->rflush));
-
-		if (rc < 0)
-			break;
-
-		if (audio->stopped || audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (count < audio->in[audio->read_next].used) {
-			/* Read must happen in frame boundary. Since driver
-			   does not know frame size, read count must be greater
-			   or equal to size of PCM samples */
-			MM_DBG("no partial frame done reading\n");
-			break;
-		} else {
-			MM_DBG("read from in[%d]\n", audio->read_next);
-			/* order reads to the output buffer */
-			rmb();
-			if (copy_to_user
-			    (buf, audio->in[audio->read_next].data,
-			     audio->in[audio->read_next].used)) {
-				MM_ERR("invalid addr %x\n", (unsigned int)buf);
-				rc = -EFAULT;
-				break;
-			}
-			count -= audio->in[audio->read_next].used;
-			buf += audio->in[audio->read_next].used;
-			audio->in[audio->read_next].used = 0;
-			if ((++audio->read_next) == audio->pcm_buf_count)
-				audio->read_next = 0;
-			break;
-				/*
-				* Force to exit while loop
-				* to prevent output thread
-				* sleep too long if data is not
-				* ready at this moment.
-				*/
-		}
-	}
-
-	/* don't feed output buffer to HW decoder during flushing
-	 * buffer refresh command will be sent once flush completes
-	 * send buf refresh command here can confuse HW decoder
-	 */
-	if (audio->buf_refresh && !audio->rflush) {
-		audio->buf_refresh = 0;
-		MM_DBG("kick start pcm feedback again\n");
-		audplay_buffer_refresh(audio);
-	}
-
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		rc = buf - start;
-
-	MM_DBG("read %d bytes\n", rc);
-	return rc;
-}
-
-static int audaac_process_eos(struct audio *audio,
-	const char __user *buf_start, unsigned short mfield_size)
-{
-	struct buffer *frame;
-	char *buf_ptr;
-	int rc = 0;
-	unsigned long flags = 0;
-
-	MM_DBG("signal input EOS reserved=%d\n", audio->reserved);
-	if (audio->reserved) {
-		MM_DBG("Pass reserve byte\n");
-		frame = audio->out + audio->out_head;
-		buf_ptr = frame->data;
-		rc = wait_event_interruptible(audio->write_wait,
-					(frame->used == 0)
-					|| (audio->stopped)
-					|| (audio->wflush));
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-	buf_ptr[0] = audio->rsv_byte;
-	buf_ptr[1] = 0;
-	audio->out_head ^= 1;
-	frame->mfield_sz = 0;
-	audio->reserved = 0;
-	frame->used = 2;
-	audplay_send_data(audio, 0);
-	}
-	MM_DBG("Now signal input EOS after reserved bytes %d %d %d\n",
-		audio->out[0].used, audio->out[1].used, audio->out_needed);
-	frame = audio->out + audio->out_head;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->eos_in_progress = 1;
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->eos_in_progress = 0;
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	audplay_send_data(audio, 0);
-done:
-	return rc;
-}
-static ssize_t audio_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	size_t xfer;
-	char *cpy_ptr;
-	int rc = 0, eos_condition = AUDAAC_EOS_NONE;
-	unsigned dsize;
-
-	unsigned short mfield_size = 0;
-	MM_DBG("cnt=%d\n", count);
-	mutex_lock(&audio->write_lock);
-	while (count > 0) {
-		frame = audio->out + audio->out_head;
-		cpy_ptr = frame->data;
-		dsize = 0;
-		rc = wait_event_interruptible(audio->write_wait,
-					      (frame->used == 0)
-						|| (audio->stopped)
-						|| (audio->wflush));
-		if (rc < 0)
-			break;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			break;
-		}
-		if (audio->mfield) {
-			if (buf == start) {
-				/* Processing beginning of user buffer */
-				if (__get_user(mfield_size,
-					(unsigned short __user *) buf)) {
-					rc = -EFAULT;
-					break;
-				} else 	if (mfield_size > count) {
-					rc = -EINVAL;
-					break;
-				}
-				MM_DBG("mf offset_val %x\n", mfield_size);
-				if (copy_from_user(cpy_ptr, buf, mfield_size)) {
-					rc = -EFAULT;
-					break;
-				}
-				/* Check if EOS flag is set and buffer has
-				* contains just meta field
-				*/
-				if (cpy_ptr[AUDAAC_EOS_FLG_OFFSET] &
-						AUDAAC_EOS_FLG_MASK) {
-					MM_DBG("eos set\n");
-					eos_condition = AUDAAC_EOS_SET;
-					if (mfield_size == count) {
-						buf += mfield_size;
-						break;
-					} else
-					cpy_ptr[AUDAAC_EOS_FLG_OFFSET] &=
-							~AUDAAC_EOS_FLG_MASK;
-				}
-				/* Check EOS to see if */
-				cpy_ptr += mfield_size;
-				count -= mfield_size;
-				dsize += mfield_size;
-				buf += mfield_size;
-			} else {
-				mfield_size = 0;
-				MM_DBG("continuous buffer\n");
-			}
-			frame->mfield_sz = mfield_size;
-		}
-
-		if (audio->reserved) {
-			MM_DBG("append reserved byte %x\n",
-				audio->rsv_byte);
-			*cpy_ptr = audio->rsv_byte;
-			xfer = (count > ((frame->size - mfield_size) - 1)) ?
-				(frame->size - mfield_size) - 1 : count;
-			cpy_ptr++;
-			dsize += 1;
-			audio->reserved = 0;
-		} else
-			xfer = (count > (frame->size - mfield_size)) ?
-				(frame->size - mfield_size) : count;
-
-		if (copy_from_user(cpy_ptr, buf, xfer)) {
-			rc = -EFAULT;
-			break;
-		}
-
-		dsize += xfer;
-		if (dsize & 1) {
-			audio->rsv_byte = ((char *) frame->data)[dsize - 1];
-			MM_DBG("odd length buf reserve last byte %x\n",
-					audio->rsv_byte);
-			audio->reserved = 1;
-			dsize--;
-		}
-		count -= xfer;
-		buf += xfer;
-
-		if (dsize > 0) {
-			audio->out_head ^= 1;
-			frame->used = dsize;
-			audplay_send_data(audio, 0);
-		}
-	}
-	MM_DBG("eos_condition %x buf[0x%x] start[0x%x]\n", eos_condition,
-			(int) buf, (int) start);
-	if (eos_condition == AUDAAC_EOS_SET)
-		rc = audaac_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	if (!rc) {
-		if (buf > start)
-			return buf - start;
-	}
-	return rc;
-}
-
-static int audio_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	MM_INFO("audio instance 0x%08x freeing\n", (int)audio);
-	mutex_lock(&audio->lock);
-	audio_disable(audio);
-	if (audio->rmt_resource_released == 0)
-		rmt_put_resource(audio);
-	audio_flush(audio);
-	audio_flush_pcm_buf(audio);
-	msm_adsp_put(audio->audplay);
-	audpp_adec_free(audio->dec_id);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	unregister_early_suspend(&audio->suspend_ctl.node);
-#endif
-	audio->event_abort = 1;
-	wake_up(&audio->event_wait);
-	audaac_reset_event_queue(audio);
-	ion_unmap_kernel(audio->client, audio->output_buff_handle);
-	ion_free(audio->client, audio->output_buff_handle);
-	ion_unmap_kernel(audio->client, audio->input_buff_handle);
-	ion_free(audio->client, audio->input_buff_handle);
-	ion_client_destroy(audio->client);
-	mutex_unlock(&audio->lock);
-#ifdef CONFIG_DEBUG_FS
-	if (audio->dentry)
-		debugfs_remove(audio->dentry);
-#endif
-	kfree(audio);
-	return 0;
-}
-
-static void audaac_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload)
-{
-	struct audaac_event *e_node = NULL;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-
-	if (!list_empty(&audio->free_event_queue)) {
-		e_node = list_first_entry(&audio->free_event_queue,
-				struct audaac_event, list);
-		list_del(&e_node->list);
-	} else {
-		e_node = kmalloc(sizeof(struct audaac_event), GFP_ATOMIC);
-		if (!e_node) {
-			MM_ERR("No mem to post event %d\n", type);
-			spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-			return;
-		}
-	}
-
-	e_node->event_type = type;
-	e_node->payload = payload;
-
-	list_add_tail(&e_node->list, &audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	wake_up(&audio->event_wait);
-}
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audaac_suspend(struct early_suspend *h)
-{
-	struct audaac_suspend_ctl *ctl =
-		container_of(h, struct audaac_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audaac_post_event(ctl->audio, AUDIO_EVENT_SUSPEND, payload);
-}
-
-static void audaac_resume(struct early_suspend *h)
-{
-	struct audaac_suspend_ctl *ctl =
-		container_of(h, struct audaac_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audaac_post_event(ctl->audio, AUDIO_EVENT_RESUME, payload);
-}
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-static ssize_t audaac_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static ssize_t audaac_debug_read(struct file *file, char __user *buf,
-					size_t count, loff_t *ppos)
-{
-	const int debug_bufmax = 1024;
-	static char buffer[1024];
-	int n = 0, i;
-	struct audio *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	n = scnprintf(buffer, debug_bufmax, "opened %d\n", audio->opened);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"enabled %d\n", audio->enabled);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"stopped %d\n", audio->stopped);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_feedback %d\n", audio->pcm_feedback);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_buf_sz %d\n", audio->out[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_buf_count %d \n", audio->pcm_buf_count);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_buf_sz %d \n", audio->in[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"volume %x \n", audio->vol_pan.volume);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"sample rate %d \n", audio->out_sample_rate);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"channel mode %d \n", audio->out_channel_mode);
-	mutex_unlock(&audio->lock);
-	/* Following variables are only useful for debugging when
-	 * when playback halts unexpectedly. Thus, no mutual exclusion
-	 * enforced
-	 */
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"wflush %d\n", audio->wflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"rflush %d\n", audio->rflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"running %d \n", audio->running);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"dec state %d \n", audio->dec_state);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_needed %d \n", audio->out_needed);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_head %d \n", audio->out_head);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_tail %d \n", audio->out_tail);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out[0].used %d \n", audio->out[0].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out[1].used %d \n", audio->out[1].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"buffer_refresh %d \n", audio->buf_refresh);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"read_next %d \n", audio->read_next);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"fill_next %d \n", audio->fill_next);
-	for (i = 0; i < audio->pcm_buf_count; i++)
-		n += scnprintf(buffer + n, debug_bufmax - n,
-				"in[%d].used %d \n", i, audio->in[i].used);
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations audaac_debug_fops = {
-	.read = audaac_debug_read,
-	.open = audaac_debug_open,
-};
-#endif
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = NULL;
-	int rc, dec_attrb, decid, index, offset = 0;
-	unsigned mem_sz = DMASZ;
-	struct audaac_event *e_node = NULL;
-	int len = 0;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	struct ion_client *client = NULL;
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_aac_" + 5];
-#endif
-
-	/* Allocate audio instance, set to zero */
-	audio = kzalloc(sizeof(struct audio), GFP_KERNEL);
-	if (!audio) {
-		MM_ERR("no memory to allocate audio instance \n");
-		rc = -ENOMEM;
-		goto done;
-	}
-	MM_INFO("audio instance 0x%08x created\n", (int)audio);
-
-	/* Allocate the decoder */
-	dec_attrb = AUDDEC_DEC_AAC;
-	if ((file->f_mode & FMODE_WRITE) &&
-			(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_NONTUNNEL;
-		audio->pcm_feedback = NON_TUNNEL_MODE_PLAYBACK;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_TUNNEL;
-		audio->pcm_feedback = TUNNEL_MODE_PLAYBACK;
-	} else {
-		kfree(audio);
-		rc = -EACCES;
-		goto done;
-	}
-	decid = audpp_adec_alloc(dec_attrb, &audio->module_name,
-			&audio->queue_id);
-
-	if (decid < 0) {
-		MM_ERR("No free decoder available, freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENODEV;
-		kfree(audio);
-		goto done;
-	}
-	audio->dec_id = decid & MSM_AUD_DECODER_MASK;
-
-	client = msm_ion_client_create(UINT_MAX, "Audio_AAC_client");
-	if (IS_ERR_OR_NULL(client)) {
-		MM_ERR("Unable to create ION client\n");
-		rc = -ENOMEM;
-		goto client_create_error;
-	}
-	audio->client = client;
-
-	MM_DBG("allocating mem sz = %d\n", mem_sz);
-	handle = ion_alloc(client, mem_sz, SZ_4K,
-		ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-	if (IS_ERR_OR_NULL(handle)) {
-		MM_ERR("Unable to create allocate O/P buffers\n");
-		rc = -ENOMEM;
-		goto output_buff_alloc_error;
-	}
-
-	audio->output_buff_handle = handle;
-
-	rc = ion_phys(client, handle, &addr, &len);
-	if (rc) {
-		MM_ERR("O/P buffers:Invalid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-		goto output_buff_get_phys_error;
-	} else {
-		MM_INFO("O/P buffers:valid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-	}
-	audio->phys = (int32_t)addr;
-
-	rc = ion_handle_get_flags(client, handle, &ionflag);
-	if (rc) {
-		MM_ERR("could not get flags for the handle\n");
-		goto output_buff_get_flags_error;
-	}
-
-	audio->map_v_write = ion_map_kernel(client, handle);
-	if (IS_ERR(audio->map_v_write)) {
-		MM_ERR("could not map write buffers,freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENOMEM;
-		goto output_buff_map_error;
-	}
-	audio->data = audio->map_v_write;
-	MM_DBG("write buf: phy addr 0x%08x kernel addr 0x%08x\n",
-		audio->phys, (int)audio->data);
-
-	audio->out_dma_sz = mem_sz;
-
-	mem_sz = (PCM_BUFSZ_MIN * PCM_BUF_MAX_COUNT);
-	MM_DBG("allocating mem sz = %d\n", mem_sz);
-	handle = ion_alloc(client, mem_sz,
-			SZ_4K, ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-	if (IS_ERR_OR_NULL(handle)) {
-		MM_ERR("Unable to create allocate I/P buffers\n");
-		rc = -ENOMEM;
-		goto input_buff_alloc_error;
-	}
-
-	audio->input_buff_handle = handle;
-
-	rc = ion_phys(client , handle, &addr, &len);
-	if (rc) {
-		MM_ERR("I/P buffers:Invalid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-		goto input_buff_get_phys_error;
-	} else {
-		MM_INFO("out Got valid phy: %x sz: %x\n",
-			(unsigned int) audio->read_phys, (unsigned int) len);
-	}
-	audio->read_phys = (int32_t)addr;
-
-	rc = ion_handle_get_flags(client,
-		handle, &ionflag);
-	if (rc) {
-		MM_ERR("could not get flags for the handle\n");
-		goto input_buff_get_flags_error;
-	}
-
-	audio->map_v_read = ion_map_kernel(client, handle);
-	if (IS_ERR(audio->map_v_read)) {
-		MM_ERR("could not map read buffers, freeing instance \
-				0x%08x\n", (int)audio);
-		rc = -ENOMEM;
-		goto input_buff_map_error;
-	}
-	audio->read_data = audio->map_v_read;
-	MM_DBG("read buf: phy addr 0x%08x kernel addr 0x%08x\n",
-				audio->read_phys, (int)audio->read_data);
-
-	if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK) {
-		rc = audmgr_open(&audio->audmgr);
-		if (rc) {
-			MM_ERR("audmgr open failed, freeing instance \
-					0x%08x\n", (int)audio);
-			goto err;
-		}
-	}
-
-	rc = msm_adsp_get(audio->module_name, &audio->audplay,
-			  &audplay_adsp_ops_aac, audio);
-	if (rc) {
-		MM_ERR("failed to get %s module, freeing instance 0x%08x\n",
-				audio->module_name, (int)audio);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_close(&audio->audmgr);
-		goto err;
-	}
-
-	rc = rmt_get_resource(audio);
-	if (rc) {
-		MM_ERR("ADSP resources are not available for AAC session \
-			 0x%08x on decoder: %d\n", (int)audio, audio->dec_id);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_close(&audio->audmgr);
-		msm_adsp_put(audio->audplay);
-		goto err;
-	}
-
-	mutex_init(&audio->lock);
-	mutex_init(&audio->write_lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->get_event_lock);
-	spin_lock_init(&audio->dsp_lock);
-	spin_lock_init(&audio->event_queue_lock);
-	INIT_LIST_HEAD(&audio->free_event_queue);
-	INIT_LIST_HEAD(&audio->event_queue);
-	init_waitqueue_head(&audio->write_wait);
-	init_waitqueue_head(&audio->read_wait);
-	init_waitqueue_head(&audio->wait);
-	init_waitqueue_head(&audio->event_wait);
-
-	audio->out[0].data = audio->data + 0;
-	audio->out[0].addr = audio->phys + 0;
-	audio->out[0].size = audio->out_dma_sz >> 1;
-
-	audio->out[1].data = audio->data + audio->out[0].size;
-	audio->out[1].addr = audio->phys + audio->out[0].size;
-	audio->out[1].size = audio->out[0].size;
-
-	audio->pcm_buf_count = PCM_BUF_MAX_COUNT;
-	for (index = 0; index < PCM_BUF_MAX_COUNT; index++) {
-		audio->in[index].data = audio->read_data + offset;
-		audio->in[index].addr = audio->read_phys + offset;
-		audio->in[index].size = PCM_BUFSZ_MIN;
-		audio->in[index].used = 0;
-		offset += PCM_BUFSZ_MIN;
-	}
-
-	audio->out_sample_rate = 44100;
-	audio->out_channel_mode = AUDPP_CMD_PCM_INTF_STEREO_V;
-	audio->aac_config.format = AUDIO_AAC_FORMAT_ADTS;
-	audio->aac_config.audio_object = AUDIO_AAC_OBJECT_LC;
-	audio->aac_config.ep_config = 0;
-	audio->aac_config.aac_section_data_resilience_flag =
-		AUDIO_AAC_SEC_DATA_RES_OFF;
-	audio->aac_config.aac_scalefactor_data_resilience_flag =
-		AUDIO_AAC_SCA_DATA_RES_OFF;
-	audio->aac_config.aac_spectral_data_resilience_flag =
-		AUDIO_AAC_SPEC_DATA_RES_OFF;
-#ifdef CONFIG_AUDIO_AAC_PLUS
-	audio->aac_config.sbr_on_flag = AUDIO_AAC_SBR_ON_FLAG_ON;
-#else
-	audio->aac_config.sbr_on_flag = AUDIO_AAC_SBR_ON_FLAG_OFF;
-#endif
-#ifdef CONFIG_AUDIO_ENHANCED_AAC_PLUS
-	audio->aac_config.sbr_ps_on_flag = AUDIO_AAC_SBR_PS_ON_FLAG_ON;
-#else
-	audio->aac_config.sbr_ps_on_flag = AUDIO_AAC_SBR_PS_ON_FLAG_OFF;
-#endif
-	audio->aac_config.dual_mono_mode = AUDIO_AAC_DUAL_MONO_PL_SR;
-	audio->aac_config.channel_configuration = 2;
-	audio->vol_pan.volume = 0x2000;
-
-	audio_flush(audio);
-
-	file->private_data = audio;
-	audio->opened = 1;
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof name, "msm_aac_%04x", audio->dec_id);
-	audio->dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
-				NULL, (void *) audio,
-				&audaac_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		MM_DBG("debugfs_create_file failed\n");
-#endif
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	audio->suspend_ctl.node.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
-	audio->suspend_ctl.node.resume = audaac_resume;
-	audio->suspend_ctl.node.suspend = audaac_suspend;
-	audio->suspend_ctl.audio = audio;
-	register_early_suspend(&audio->suspend_ctl.node);
-#endif
-	for (index = 0; index < AUDAAC_EVENT_NUM; index++) {
-		e_node = kmalloc(sizeof(struct audaac_event), GFP_KERNEL);
-		if (e_node)
-			list_add_tail(&e_node->list, &audio->free_event_queue);
-		else {
-			MM_ERR("event pkt alloc failed\n");
-			break;
-		}
-	}
-	memset(&audio->stream_info, 0, sizeof(struct msm_audio_bitstream_info));
-done:
-	return rc;
-err:
-	ion_unmap_kernel(client, audio->input_buff_handle);
-input_buff_map_error:
-input_buff_get_flags_error:
-input_buff_get_phys_error:
-	ion_free(client, audio->input_buff_handle);
-input_buff_alloc_error:
-	ion_unmap_kernel(client, audio->output_buff_handle);
-output_buff_map_error:
-output_buff_get_phys_error:
-output_buff_get_flags_error:
-	ion_free(client, audio->output_buff_handle);
-output_buff_alloc_error:
-	ion_client_destroy(client);
-client_create_error:
-	audpp_adec_free(audio->dec_id);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_aac_fops = {
-	.owner = THIS_MODULE,
-	.open = audio_open,
-	.release = audio_release,
-	.read = audio_read,
-	.write = audio_write,
-	.unlocked_ioctl = audio_ioctl,
-	.fsync = audaac_fsync
-};
-
-struct miscdevice audio_aac_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_aac",
-	.fops = &audio_aac_fops,
-};
-
-static int __init audio_init(void)
-{
-	return misc_register(&audio_aac_misc);
-}
-
-static void __exit audio_exit(void)
-{
-	misc_deregister(&audio_aac_misc);
-}
-
-module_init(audio_init);
-module_exit(audio_exit);
-
-MODULE_DESCRIPTION("MSM AAC driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5/audio_aac_in.c b/arch/arm/mach-msm/qdsp5/audio_aac_in.c
deleted file mode 100644
index 8cfa4e3..0000000
--- a/arch/arm/mach-msm/qdsp5/audio_aac_in.c
+++ /dev/null
@@ -1,1526 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/audio_aac_in.c
- *
- * aac audio input device
- *
- * Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
- *
- * This code is based in part on arch/arm/mach-msm/qdsp5v2/audio_aac_in.c,
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/delay.h>
-#include <linux/msm_audio_aac.h>
-#include <linux/memory_alloc.h>
-#include <linux/msm_ion.h>
-
-#include "audmgr.h"
-
-#include <mach/msm_rpcrouter.h>
-#include <mach/msm_memtypes.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-
-#include <mach/msm_adsp.h>
-#include <mach/qdsp5/qdsp5audpreproc.h>
-#include <mach/qdsp5/qdsp5audpreproccmdi.h>
-#include <mach/qdsp5/qdsp5audpreprocmsg.h>
-#include <mach/qdsp5/qdsp5audreccmdi.h>
-#include <mach/qdsp5/qdsp5audrecmsg.h>
-#include <mach/debug_mm.h>
-
-#define FRAME_HEADER_SIZE	8 /* 8 bytes frame header */
-#define NT_FRAME_HEADER_SIZE	24 /* 24 bytes frame header */
-/* FRAME_NUM must be a power of two */
-#define FRAME_NUM	8
-#define AAC_FRAME_SIZE	1536 /* 36 bytes data */
-/*Tunnel mode : 1536 bytes data + 8 byte header*/
-#define FRAME_SIZE	(AAC_FRAME_SIZE + FRAME_HEADER_SIZE)
-/* 1536 bytes data  + 24 meta field*/
-#define NT_FRAME_SIZE	(AAC_FRAME_SIZE + NT_FRAME_HEADER_SIZE)
-#define DMASZ		(FRAME_SIZE * FRAME_NUM)
-#define NT_DMASZ	(NT_FRAME_SIZE * FRAME_NUM)
-#define OUT_FRAME_NUM	2
-#define OUT_BUFFER_SIZE (32 * 1024 + NT_FRAME_HEADER_SIZE)
-#define BUFFER_SIZE	(OUT_BUFFER_SIZE * OUT_FRAME_NUM)
-
-#define AUDPREPROC_AAC_EOS_FLG_OFFSET 0x0A /* Offset from beginning of buffer*/
-#define AUDPREPROC_AAC_EOS_FLG_MASK 0x01
-#define AUDPREPROC_AAC_EOS_NONE 0x0 /* No EOS detected */
-#define AUDPREPROC_AAC_EOS_SET 0x1 /* EOS set in meta field */
-
-struct buffer {
-	void *data;
-	uint32_t size;
-	uint32_t read;
-	uint32_t addr;
-	uint32_t used;
-	uint32_t mfield_sz;
-};
-
-struct audio_aac_in {
-	struct buffer in[FRAME_NUM];
-
-	spinlock_t dsp_lock;
-
-	atomic_t in_bytes;
-	atomic_t in_samples;
-
-	struct mutex lock;
-	struct mutex read_lock;
-	wait_queue_head_t wait;
-	wait_queue_head_t wait_enable;
-	/*write section*/
-	struct buffer out[OUT_FRAME_NUM];
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed;	/* number of buffers the dsp is waiting for */
-	uint32_t out_count;
-
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-	int32_t out_phys; /* physical address of write buffer */
-	char *out_data;
-	int mfield; /* meta field embedded in data */
-	int wflush; /*write flush */
-	int rflush; /*read flush*/
-	int out_frame_cnt;
-
-	struct msm_adsp_module *audrec;
-
-
-	/* configuration to use on next enable */
-	uint32_t samp_rate;
-	uint32_t channel_mode;
-	uint32_t buffer_size; /* Frame size (1536 bytes) */
-	uint32_t bit_rate; /* bit rate for AAC */
-	uint32_t record_quality; /* record quality (bits/sample/channel) */
-	uint32_t enc_type; /* 1 for AAC */
-	uint32_t mode; /* T or NT Mode*/
-	uint32_t dsp_cnt;
-	uint32_t in_head; /* next buffer dsp will write */
-	uint32_t in_tail; /* next buffer read() will read */
-	uint32_t in_count; /* number of buffers available to read() */
-
-	uint32_t eos_ack;
-	uint32_t flush_ack;
-
-	const char *module_name;
-	unsigned queue_ids;
-	uint16_t enc_id; /* Session Id */
-
-	unsigned short samp_rate_index;
-	uint32_t audrec_obj_idx ;
-
-	struct audmgr audmgr;
-
-	/* data allocated for various buffers */
-	char *data;
-	dma_addr_t phys;
-	void *map_v_read;
-	void *map_v_write;
-
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped, cleared on flush */
-	struct ion_client *client;
-	struct ion_handle *input_buff_handle;
-	struct ion_handle *output_buff_handle;
-
-	struct audrec_session_info session_info; /*audrec session info*/
-};
-
-struct audio_frame {
-	uint16_t frame_count_lsw;
-	uint16_t frame_count_msw;
-	uint16_t frame_length;
-	uint16_t erased_pcm;
-	unsigned char raw_bitstream[];
-} __packed;
-
-struct audio_frame_nt {
-	uint16_t metadata_len;
-	uint16_t frame_count_lsw;
-	uint16_t frame_count_msw;
-	uint16_t frame_length;
-	uint16_t erased_pcm;
-	uint16_t reserved;
-	uint16_t time_stamp_dword_lsw;
-	uint16_t time_stamp_dword_msw;
-	uint16_t time_stamp_lsw;
-	uint16_t time_stamp_msw;
-	uint16_t nflag_lsw;
-	uint16_t nflag_msw;
-	unsigned char raw_bitstream[]; /* samples */
-} __packed;
-
-struct aac_encoded_meta_out {
-	uint16_t metadata_len;
-	uint16_t time_stamp_dword_lsw;
-	uint16_t time_stamp_dword_msw;
-	uint16_t time_stamp_lsw;
-	uint16_t time_stamp_msw;
-	uint16_t nflag_lsw;
-	uint16_t nflag_msw;
-};
-
-/* Audrec Queue command sent macro's */
-#define audio_send_queue_pre(audio, cmd, len) \
-	msm_adsp_write(audio->audpre, QDSP_uPAudPreProcCmdQueue, cmd, len)
-
-#define audio_send_queue_recbs(audio, cmd, len) \
-	msm_adsp_write(audio->audrec, ((audio->queue_ids & 0xFFFF0000) >> 16),\
-			cmd, len)
-#define audio_send_queue_rec(audio, cmd, len) \
-	msm_adsp_write(audio->audrec, (audio->queue_ids & 0x0000FFFF),\
-			cmd, len)
-
-static int audaac_in_dsp_enable(struct audio_aac_in *audio, int enable);
-static int audaac_in_encparam_config(struct audio_aac_in *audio);
-static int audaac_in_encmem_config(struct audio_aac_in *audio);
-static int audaac_in_dsp_read_buffer(struct audio_aac_in *audio,
-				uint32_t read_cnt);
-static void audaac_in_flush(struct audio_aac_in *audio);
-
-static void audaac_in_get_dsp_frames(struct audio_aac_in *audio);
-static int audpcm_config(struct audio_aac_in *audio);
-static void audaac_out_flush(struct audio_aac_in *audio);
-static int audaac_in_routing_mode_config(struct audio_aac_in *audio);
-static void audrec_pcm_send_data(struct audio_aac_in *audio, unsigned needed);
-static void audaac_nt_in_get_dsp_frames(struct audio_aac_in *audio);
-static void audaac_in_flush(struct audio_aac_in *audio);
-
-static unsigned convert_dsp_samp_index(unsigned index)
-{
-	switch (index) {
-	case 48000:	return AUDREC_CMD_SAMP_RATE_INDX_48000;
-	case 44100:	return AUDREC_CMD_SAMP_RATE_INDX_44100;
-	case 32000:	return AUDREC_CMD_SAMP_RATE_INDX_32000;
-	case 24000:	return AUDREC_CMD_SAMP_RATE_INDX_24000;
-	case 22050:	return AUDREC_CMD_SAMP_RATE_INDX_22050;
-	case 16000:	return AUDREC_CMD_SAMP_RATE_INDX_16000;
-	case 12000:	return AUDREC_CMD_SAMP_RATE_INDX_12000;
-	case 11025:	return AUDREC_CMD_SAMP_RATE_INDX_11025;
-	case 8000:	return AUDREC_CMD_SAMP_RATE_INDX_8000;
-	default:	return AUDREC_CMD_SAMP_RATE_INDX_11025;
-	}
-}
-
-static unsigned convert_samp_rate(unsigned hz)
-{
-	switch (hz) {
-	case 48000: return RPC_AUD_DEF_SAMPLE_RATE_48000;
-	case 44100: return RPC_AUD_DEF_SAMPLE_RATE_44100;
-	case 32000: return RPC_AUD_DEF_SAMPLE_RATE_32000;
-	case 24000: return RPC_AUD_DEF_SAMPLE_RATE_24000;
-	case 22050: return RPC_AUD_DEF_SAMPLE_RATE_22050;
-	case 16000: return RPC_AUD_DEF_SAMPLE_RATE_16000;
-	case 12000: return RPC_AUD_DEF_SAMPLE_RATE_12000;
-	case 11025: return RPC_AUD_DEF_SAMPLE_RATE_11025;
-	case 8000:  return RPC_AUD_DEF_SAMPLE_RATE_8000;
-	default:    return RPC_AUD_DEF_SAMPLE_RATE_11025;
-	}
-}
-
-static unsigned convert_samp_index(unsigned index)
-{
-	switch (index) {
-	case RPC_AUD_DEF_SAMPLE_RATE_48000:	return 48000;
-	case RPC_AUD_DEF_SAMPLE_RATE_44100:	return 44100;
-	case RPC_AUD_DEF_SAMPLE_RATE_32000:	return 32000;
-	case RPC_AUD_DEF_SAMPLE_RATE_24000:	return 24000;
-	case RPC_AUD_DEF_SAMPLE_RATE_22050:	return 22050;
-	case RPC_AUD_DEF_SAMPLE_RATE_16000:	return 16000;
-	case RPC_AUD_DEF_SAMPLE_RATE_12000:	return 12000;
-	case RPC_AUD_DEF_SAMPLE_RATE_11025:	return 11025;
-	case RPC_AUD_DEF_SAMPLE_RATE_8000:	return 8000;
-	default:				return 11025;
-	}
-}
-
-/* Convert Bit Rate to Record Quality field of DSP */
-static unsigned int bitrate_to_record_quality(unsigned int sample_rate,
-		unsigned int channel, unsigned int bit_rate) {
-	unsigned int temp;
-
-	temp = sample_rate * channel;
-	MM_DBG(" sample rate *  channel = %d\n", temp);
-	/* To represent in Q12 fixed format */
-	temp = (bit_rate * 4096) / temp;
-	MM_DBG(" Record Quality = 0x%8x\n", temp);
-	return temp;
-}
-
-/* ------------------- dsp --------------------- */
-static void audpre_dsp_event(void *data, unsigned id,  void *event_data)
-{
-
-	uint16_t *msg = event_data;
-
-	if (!msg)
-		return;
-
-	switch (id) {
-	case AUDPREPROC_MSG_CMD_CFG_DONE_MSG:
-		MM_DBG("type %d, status_flag %d\n",\
-			msg[0], msg[1]);
-		break;
-	case AUDPREPROC_MSG_ERROR_MSG_ID:
-		MM_INFO("err_index %d\n", msg[0]);
-		break;
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audpreproctask)\n");
-		break;
-	default:
-		MM_ERR("unknown event %d\n", id);
-	}
-}
-
-/* must be called with audio->lock held */
-static int audaac_in_enable(struct audio_aac_in *audio)
-{
-	struct audmgr_config cfg;
-	int rc;
-
-	if (audio->enabled)
-		return 0;
-
-	cfg.tx_rate = audio->samp_rate;
-	cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE;
-	cfg.def_method = RPC_AUD_DEF_METHOD_RECORD;
-	cfg.codec = RPC_AUD_DEF_CODEC_AAC;
-	cfg.snd_method = RPC_SND_METHOD_MIDI;
-
-	if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-		rc = audmgr_enable(&audio->audmgr, &cfg);
-		if (rc < 0)
-			return rc;
-
-		if (audpreproc_enable(audio->enc_id,
-				&audpre_dsp_event, audio)) {
-			MM_ERR("msm_adsp_enable(audpreproc) failed\n");
-			audmgr_disable(&audio->audmgr);
-			return -ENODEV;
-		}
-
-		/*update aurec session info in audpreproc layer*/
-		audio->session_info.session_id = audio->enc_id;
-		audio->session_info.sampling_freq =
-			convert_samp_index(audio->samp_rate);
-		audpreproc_update_audrec_info(&audio->session_info);
-	}
-
-	if (msm_adsp_enable(audio->audrec)) {
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			audpreproc_disable(audio->enc_id, audio);
-			audmgr_disable(&audio->audmgr);
-		}
-		MM_ERR("msm_adsp_enable(audrec) failed\n");
-		return -ENODEV;
-	}
-
-	audio->enabled = 1;
-	audaac_in_dsp_enable(audio, 1);
-
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audaac_in_disable(struct audio_aac_in *audio)
-{
-	if (audio->enabled) {
-		audio->enabled = 0;
-
-		audaac_in_dsp_enable(audio, 0);
-
-		wait_event_interruptible_timeout(audio->wait_enable,
-				audio->running == 0, 1*HZ);
-		audio->stopped = 1;
-		wake_up(&audio->wait);
-		msm_adsp_disable(audio->audrec);
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			audpreproc_disable(audio->enc_id, audio);
-			/*reset the sampling frequency information at
-			audpreproc layer*/
-			audio->session_info.sampling_freq = 0;
-			audpreproc_update_audrec_info(&audio->session_info);
-			audmgr_disable(&audio->audmgr);
-		}
-	}
-	return 0;
-}
-
-static void audaac_in_get_dsp_frames(struct audio_aac_in *audio)
-{
-	struct audio_frame *frame;
-	uint32_t index;
-	unsigned long flags;
-
-	index = audio->in_head;
-
-	frame = (void *) (((char *)audio->in[index].data) -
-			sizeof(*frame));
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->in[index].size = frame->frame_length;
-
-	/* statistics of read */
-	atomic_add(audio->in[index].size, &audio->in_bytes);
-	atomic_add(1, &audio->in_samples);
-
-	audio->in_head = (audio->in_head + 1) & (FRAME_NUM - 1);
-
-	/* If overflow, move the tail index foward. */
-	if (audio->in_head == audio->in_tail) {
-		MM_ERR("Error! not able to keep up the read\n");
-		audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
-		MM_ERR("in_count = %d\n", audio->in_count);
-	} else
-		audio->in_count++;
-
-	audaac_in_dsp_read_buffer(audio, audio->dsp_cnt++);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-
-	wake_up(&audio->wait);
-}
-
-static void audaac_nt_in_get_dsp_frames(struct audio_aac_in *audio)
-{
-	struct audio_frame_nt *nt_frame;
-	uint32_t index;
-	unsigned long flags;
-
-	index = audio->in_head;
-	nt_frame = (void *) (((char *)audio->in[index].data) - \
-				sizeof(struct audio_frame_nt));
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->in[index].size = nt_frame->frame_length;
-	/* statistics of read */
-	atomic_add(audio->in[index].size, &audio->in_bytes);
-	atomic_add(1, &audio->in_samples);
-
-	audio->in_head = (audio->in_head + 1) & (FRAME_NUM - 1);
-
-	/* If overflow, move the tail index foward. */
-	if (audio->in_head == audio->in_tail)
-		MM_DBG("Error! not able to keep up the read\n");
-	else
-		audio->in_count++;
-
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	wake_up(&audio->wait);
-}
-
-static int audrec_pcm_buffer_ptr_refresh(struct audio_aac_in *audio,
-				       unsigned idx, unsigned len)
-{
-	struct audrec_cmd_pcm_buffer_ptr_refresh_arm_enc cmd;
-
-	if (len ==  NT_FRAME_HEADER_SIZE)
-		len = len / 2;
-	else
-		len = (len + NT_FRAME_HEADER_SIZE) / 2;
-	MM_DBG("len = %d\n", len);
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_PCM_BUFFER_PTR_REFRESH_ARM_TO_ENC;
-	cmd.num_buffers = 1;
-	if (cmd.num_buffers == 1) {
-		cmd.buf_address_length[0] = (audio->out[idx].addr &
-							0xffff0000) >> 16;
-		cmd.buf_address_length[1] = (audio->out[idx].addr &
-							0x0000ffff);
-		cmd.buf_address_length[2] = (len & 0xffff0000) >> 16;
-		cmd.buf_address_length[3] = (len & 0x0000ffff);
-	}
-	audio->out_frame_cnt++;
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audpcm_config(struct audio_aac_in *audio)
-{
-	struct audrec_cmd_pcm_cfg_arm_to_enc cmd;
-	MM_DBG("\n");
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_PCM_CFG_ARM_TO_ENC;
-	cmd.config_update_flag = AUDREC_PCM_CONFIG_UPDATE_FLAG_ENABLE;
-	cmd.enable_flag = AUDREC_ENABLE_FLAG_VALUE;
-	cmd.sampling_freq = convert_samp_index(audio->samp_rate);
-	if (!audio->channel_mode)
-		cmd.channels = 1;
-	else
-		cmd.channels = 2;
-	cmd.frequency_of_intimation = 1;
-	cmd.max_number_of_buffers = OUT_FRAME_NUM;
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audaac_in_routing_mode_config(struct audio_aac_in *audio)
-{
-	struct audrec_cmd_routing_mode cmd;
-
-	MM_DBG("\n");
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_ROUTING_MODE;
-	if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL)
-		cmd.routing_mode = 1;
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static void audrec_dsp_event(void *data, unsigned id, size_t len,
-			    void (*getevent)(void *ptr, size_t len))
-{
-	struct audio_aac_in *audio = NULL;
-	if (data)
-		audio = data;
-	else {
-		MM_ERR("invalid data for event %x\n", id);
-		return;
-	}
-
-	switch (id) {
-	case AUDREC_MSG_CMD_CFG_DONE_MSG: {
-		struct audrec_msg_cmd_cfg_done_msg cmd_cfg_done_msg;
-		getevent(&cmd_cfg_done_msg, AUDREC_MSG_CMD_CFG_DONE_MSG_LEN);
-		if (cmd_cfg_done_msg.audrec_enc_type & \
-				AUDREC_MSG_CFG_DONE_ENC_ENA) {
-			audio->audrec_obj_idx = cmd_cfg_done_msg.audrec_obj_idx;
-			MM_DBG("CFG ENABLED\n");
-			if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) {
-				MM_DBG("routing command\n");
-				audaac_in_routing_mode_config(audio);
-			} else {
-				audaac_in_encmem_config(audio);
-			}
-		} else {
-			MM_DBG("CFG SLEEP\n");
-			audio->running = 0;
-			wake_up(&audio->wait_enable);
-		}
-		break;
-	}
-	case AUDREC_MSG_CMD_ROUTING_MODE_DONE_MSG: {
-		struct audrec_msg_cmd_routing_mode_done_msg \
-			routing_msg;
-		getevent(&routing_msg, AUDREC_MSG_CMD_ROUTING_MODE_DONE_MSG);
-		MM_DBG("AUDREC_MSG_CMD_ROUTING_MODE_DONE_MSG");
-		if (routing_msg.configuration == 0) {
-			MM_ERR("routing configuration failed\n");
-			audio->running = 0;
-			wake_up(&audio->wait_enable);
-		} else
-			audaac_in_encmem_config(audio);
-		break;
-	}
-	case AUDREC_MSG_CMD_AREC_MEM_CFG_DONE_MSG: {
-		MM_DBG("AREC_MEM_CFG_DONE_MSG\n");
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)
-			audaac_in_encparam_config(audio);
-		else
-			audpcm_config(audio);
-		break;
-	}
-	case AUDREC_CMD_PCM_CFG_ARM_TO_ENC_DONE_MSG: {
-		MM_DBG("AUDREC_CMD_PCM_CFG_ARM_TO_ENC_DONE_MSG");
-		audaac_in_encparam_config(audio);
-	    break;
-	}
-	case AUDREC_MSG_CMD_AREC_PARAM_CFG_DONE_MSG: {
-		MM_DBG("AUDREC_MSG_CMD_AREC_PARAM_CFG_DONE_MSG\n");
-		audio->running = 1;
-		wake_up(&audio->wait_enable);
-		if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL)
-			audrec_pcm_send_data(audio, 1);
-		break;
-	}
-	case AUDREC_CMD_PCM_BUFFER_PTR_UPDATE_ARM_TO_ENC_MSG: {
-		MM_DBG("ptr_update recieved from DSP\n");
-		audrec_pcm_send_data(audio, 1);
-		break;
-	}
-	case AUDREC_MSG_NO_EXT_PKT_AVAILABLE_MSG: {
-		struct audrec_msg_no_ext_pkt_avail_msg err_msg;
-		getevent(&err_msg, AUDREC_MSG_NO_EXT_PKT_AVAILABLE_MSG_LEN);
-		MM_DBG("NO_EXT_PKT_AVAILABLE_MSG %x\n",\
-			err_msg.audrec_err_id);
-		break;
-	}
-	case AUDREC_MSG_PACKET_READY_MSG: {
-		struct audrec_msg_packet_ready_msg pkt_ready_msg;
-
-		getevent(&pkt_ready_msg, AUDREC_MSG_PACKET_READY_MSG_LEN);
-		MM_DBG("UP_PACKET_READY_MSG: write cnt msw  %d \
-		write cnt lsw %d read cnt msw %d  read cnt lsw %d \n",\
-		pkt_ready_msg.pkt_counter_msw, \
-		pkt_ready_msg.pkt_counter_lsw, \
-		pkt_ready_msg.pkt_read_cnt_msw, \
-		pkt_ready_msg.pkt_read_cnt_lsw);
-
-		audaac_in_get_dsp_frames(audio);
-		break;
-	}
-	case AUDREC_UP_NT_PACKET_READY_MSG: {
-		struct audrec_up_nt_packet_ready_msg pkt_ready_msg;
-
-		getevent(&pkt_ready_msg, AUDREC_UP_NT_PACKET_READY_MSG_LEN);
-		MM_DBG("UP_NT_PACKET_READY_MSG: write cnt lsw  %d \
-		write cnt msw %d read cnt lsw %d  read cnt msw %d \n",\
-		pkt_ready_msg.audrec_packetwrite_cnt_lsw, \
-		pkt_ready_msg.audrec_packetwrite_cnt_msw, \
-		pkt_ready_msg.audrec_upprev_readcount_lsw, \
-		pkt_ready_msg.audrec_upprev_readcount_msw);
-
-		audaac_nt_in_get_dsp_frames(audio);
-		break;
-	}
-	case AUDREC_CMD_FLUSH_DONE_MSG: {
-		audio->wflush = 0;
-		audio->rflush = 0;
-		audio->flush_ack = 1;
-		wake_up(&audio->write_wait);
-		MM_DBG("flush ack recieved\n");
-		break;
-	}
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module \
-				enable/disable(audrectask)\n");
-		break;
-	default:
-		MM_ERR("unknown event %d\n", id);
-	}
-}
-
-static struct msm_adsp_ops audrec_aac_adsp_ops = {
-	.event = audrec_dsp_event,
-};
-
-static int audaac_in_dsp_enable(struct audio_aac_in *audio, int enable)
-{
-	struct audrec_cmd_enc_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_ENC_CFG;
-	cmd.audrec_enc_type = (audio->enc_type & 0xFF) |
-			(enable ? AUDREC_CMD_ENC_ENA : AUDREC_CMD_ENC_DIS);
-	/* Don't care */
-	cmd.audrec_obj_idx = audio->audrec_obj_idx;
-
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audaac_in_encmem_config(struct audio_aac_in *audio)
-{
-	struct audrec_cmd_arecmem_cfg cmd;
-	uint16_t *data = (void *) audio->data;
-	int n;
-	int header_len = 0;
-
-	memset(&cmd, 0, sizeof(cmd));
-
-	cmd.cmd_id = AUDREC_CMD_ARECMEM_CFG;
-	cmd.audrec_obj_idx = audio->audrec_obj_idx;
-	/* Rate at which packet complete message comes */
-	cmd.audrec_up_pkt_intm_cnt = 1;
-	cmd.audrec_extpkt_buffer_msw = audio->phys >> 16;
-	cmd.audrec_extpkt_buffer_lsw = audio->phys;
-	/* Max Buffer no available for frames */
-	cmd.audrec_extpkt_buffer_num = FRAME_NUM;
-
-	/* prepare buffer pointers:
-	 * T:1536 bytes aac packet + 4 halfword header
-	 * NT:1536 bytes aac packet + 12 halfword header
-	 */
-	if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)
-		header_len = FRAME_HEADER_SIZE/2;
-	else
-		header_len = NT_FRAME_HEADER_SIZE/2;
-
-	for (n = 0; n < FRAME_NUM; n++) {
-		audio->in[n].data = data + header_len;
-		data += (AAC_FRAME_SIZE/2) + header_len;
-		MM_DBG("0x%8x\n", (int)(audio->in[n].data - header_len*2));
-	}
-
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audaac_in_encparam_config(struct audio_aac_in *audio)
-{
-	struct audrec_cmd_arecparam_aac_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDREC_CMD_ARECPARAM_CFG;
-	cmd.common.audrec_obj_idx = audio->audrec_obj_idx;
-	cmd.samp_rate_idx = audio->samp_rate_index;
-	cmd.stereo_mode = audio->channel_mode;
-	cmd.rec_quality = audio->record_quality;
-
-
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audaac_flush_command(struct audio_aac_in *audio)
-{
-	struct audrec_cmd_flush cmd;
-	MM_DBG("\n");
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_FLUSH;
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audaac_in_dsp_read_buffer(struct audio_aac_in *audio,
-		uint32_t read_cnt)
-{
-	audrec_cmd_packet_ext_ptr cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_PACKET_EXT_PTR;
-	cmd.type = audio->audrec_obj_idx;
-	cmd.curr_rec_count_msw = read_cnt >> 16;
-	cmd.curr_rec_count_lsw = read_cnt;
-
-	return audio_send_queue_recbs(audio, &cmd, sizeof(cmd));
-}
-
-/* ------------------- device --------------------- */
-
-static void audaac_ioport_reset(struct audio_aac_in *audio)
-{
-	/* Make sure read/write thread are free from
-	 * sleep and knowing that system is not able
-	 * to process io request at the moment
-	 */
-	wake_up(&audio->wait);
-	mutex_lock(&audio->read_lock);
-	audaac_in_flush(audio);
-	mutex_unlock(&audio->read_lock);
-	wake_up(&audio->write_wait);
-	mutex_lock(&audio->write_lock);
-	audaac_out_flush(audio);
-	mutex_unlock(&audio->write_lock);
-}
-
-static void audaac_in_flush(struct audio_aac_in *audio)
-{
-	int i;
-	unsigned long flags;
-
-	audio->dsp_cnt = 0;
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->in_head = 0;
-	audio->in_tail = 0;
-	audio->in_count = 0;
-	audio->eos_ack = 0;
-	for (i = FRAME_NUM-1; i >= 0; i--) {
-		audio->in[i].size = 0;
-		audio->in[i].read = 0;
-	}
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	MM_DBG("in_bytes %d\n", atomic_read(&audio->in_bytes));
-	MM_DBG("in_samples %d\n", atomic_read(&audio->in_samples));
-	atomic_set(&audio->in_bytes, 0);
-	atomic_set(&audio->in_samples, 0);
-}
-
-static void audaac_out_flush(struct audio_aac_in *audio)
-{
-	int i;
-	unsigned long flags;
-
-	audio->out_head = 0;
-	audio->out_count = 0;
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->out_tail = 0;
-	for (i = OUT_FRAME_NUM-1; i >= 0; i--) {
-		audio->out[i].size = 0;
-		audio->out[i].read = 0;
-		audio->out[i].used = 0;
-	}
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-static long audaac_in_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct audio_aac_in *audio = file->private_data;
-	int rc = 0;
-
-	MM_DBG("\n");
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		stats.byte_count = atomic_read(&audio->in_bytes);
-		stats.sample_count = atomic_read(&audio->in_samples);
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return rc;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START: {
-		rc = audaac_in_enable(audio);
-		if (!rc) {
-			rc =
-			wait_event_interruptible_timeout(audio->wait_enable,
-				audio->running != 0, 1*HZ);
-			MM_DBG("state %d rc = %d\n", audio->running, rc);
-
-			if (audio->running == 0)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		audio->stopped = 0;
-		break;
-	}
-	case AUDIO_STOP: {
-		rc = audaac_in_disable(audio);
-		break;
-	}
-	case AUDIO_FLUSH: {
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audaac_ioport_reset(audio);
-		if (audio->running) {
-			audaac_flush_command(audio);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config cfg;
-		memset(&cfg, 0, sizeof(cfg));
-		cfg.buffer_size = OUT_BUFFER_SIZE;
-		cfg.buffer_count = OUT_FRAME_NUM;
-		cfg.sample_rate = convert_samp_index(audio->samp_rate);
-		cfg.channel_count = 1;
-		cfg.type = 0;
-		cfg.unused[0] = 0;
-		cfg.unused[1] = 0;
-		cfg.unused[2] = 0;
-		if (copy_to_user((void *) arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-	case AUDIO_GET_STREAM_CONFIG: {
-		struct msm_audio_stream_config cfg;
-		memset(&cfg, 0, sizeof(cfg));
-		cfg.buffer_size = audio->buffer_size;
-		cfg.buffer_count = FRAME_NUM;
-		if (copy_to_user((void *)arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-	case AUDIO_SET_STREAM_CONFIG: {
-		struct msm_audio_stream_config cfg;
-		if (copy_from_user(&cfg, (void *) arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		/* Allow only single frame */
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			if (cfg.buffer_size != (FRAME_SIZE - 8))
-				rc = -EINVAL;
-				break;
-		} else {
-			if (cfg.buffer_size != (AAC_FRAME_SIZE + 14))
-				rc = -EINVAL;
-				break;
-		}
-		audio->buffer_size = cfg.buffer_size;
-		break;
-	}
-	case AUDIO_GET_AAC_ENC_CONFIG: {
-		struct msm_audio_aac_enc_config cfg;
-		if (audio->channel_mode == AUDREC_CMD_STEREO_MODE_MONO)
-			cfg.channels = 1;
-		else
-			cfg.channels = 2;
-		cfg.sample_rate = convert_samp_index(audio->samp_rate);
-		cfg.bit_rate = audio->bit_rate;
-		cfg.stream_format = AUDIO_AAC_FORMAT_RAW;
-		if (copy_to_user((void *)arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		break;
-	}
-	case AUDIO_SET_AAC_ENC_CONFIG: {
-		struct msm_audio_aac_enc_config cfg;
-		unsigned int record_quality;
-		if (copy_from_user(&cfg, (void *)arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (cfg.stream_format != AUDIO_AAC_FORMAT_RAW) {
-			MM_ERR("unsupported AAC format\n");
-			rc = -EINVAL;
-			break;
-		}
-		record_quality = bitrate_to_record_quality(cfg.sample_rate,
-					cfg.channels, cfg.bit_rate);
-		/* Range of Record Quality Supported by DSP, Q12 format */
-		if ((record_quality < 0x800) || (record_quality > 0x4000)) {
-			MM_ERR("Unsupported bit rate\n");
-			rc = -EINVAL;
-			break;
-		}
-		MM_DBG("channels = %d\n", cfg.channels);
-		if (cfg.channels == 1) {
-			cfg.channels = AUDREC_CMD_STEREO_MODE_MONO;
-		} else if (cfg.channels == 2) {
-			cfg.channels = AUDREC_CMD_STEREO_MODE_STEREO;
-		} else {
-			rc = -EINVAL;
-			break;
-		}
-
-		audio->samp_rate = convert_samp_rate(cfg.sample_rate);
-		audio->samp_rate_index =
-		  convert_dsp_samp_index(cfg.sample_rate);
-		audio->channel_mode = cfg.channels;
-		audio->bit_rate = cfg.bit_rate;
-		audio->record_quality = record_quality;
-		MM_DBG(" Record Quality = 0x%8x\n", audio->record_quality);
-		break;
-	}
-
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static ssize_t audaac_in_read(struct file *file,
-				char __user *buf,
-				size_t count, loff_t *pos)
-{
-	struct audio_aac_in *audio = file->private_data;
-	unsigned long flags;
-	const char __user *start = buf;
-	void *data;
-	uint32_t index;
-	uint32_t size;
-	int rc = 0;
-	struct aac_encoded_meta_out meta_field;
-	struct audio_frame_nt *nt_frame;
-	MM_DBG("count = %d\n", count);
-	mutex_lock(&audio->read_lock);
-	while (count > 0) {
-		rc = wait_event_interruptible(
-			audio->wait, (audio->in_count > 0) || audio->stopped ||
-			audio->rflush);
-		if (rc < 0)
-			break;
-
-		if (audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-		if (audio->stopped && !audio->in_count) {
-			MM_DBG("Driver in stop state, No more buffer to read");
-			rc = 0;/* End of File */
-			break;
-		}
-
-		index = audio->in_tail;
-		data = (uint8_t *) audio->in[index].data;
-		size = audio->in[index].size;
-
-		if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) {
-			nt_frame = (struct audio_frame_nt *)(data -
-					sizeof(struct audio_frame_nt));
-			memcpy((char *)&meta_field.time_stamp_dword_lsw,
-				(char *)&nt_frame->time_stamp_dword_lsw,
-				(sizeof(struct aac_encoded_meta_out) - \
-				sizeof(uint16_t)));
-			meta_field.metadata_len =
-					sizeof(struct aac_encoded_meta_out);
-			if (copy_to_user((char *)start, (char *)&meta_field,
-					sizeof(struct aac_encoded_meta_out))) {
-				rc = -EFAULT;
-				break;
-			}
-			if (nt_frame->nflag_lsw & 0x0001) {
-				MM_DBG("recieved EOS in read call\n");
-				audio->eos_ack = 1;
-			}
-			buf += sizeof(struct aac_encoded_meta_out);
-			count -= sizeof(struct aac_encoded_meta_out);
-		}
-		if (count >= size) {
-			/* order the reads on the buffer */
-			dma_coherent_post_ops();
-			if (copy_to_user(buf, data, size)) {
-				rc = -EFAULT;
-				break;
-			}
-			spin_lock_irqsave(&audio->dsp_lock, flags);
-			if (index != audio->in_tail) {
-				/* overrun -- data is
-				 * invalid and we need to retry */
-				spin_unlock_irqrestore(&audio->dsp_lock, flags);
-				continue;
-			}
-			audio->in[index].size = 0;
-			audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
-			audio->in_count--;
-			spin_unlock_irqrestore(&audio->dsp_lock, flags);
-			count -= size;
-			buf += size;
-			if ((audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL)) {
-				if (!audio->eos_ack) {
-					MM_DBG("sending read ptr command \
-							%d %d\n",
-							audio->dsp_cnt,
-							audio->in_tail);
-					audaac_in_dsp_read_buffer(audio,
-							audio->dsp_cnt++);
-				}
-			}
-		} else {
-			MM_ERR("short read\n");
-			break;
-		}
-		break;
-	}
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		return buf - start;
-
-	return rc;
-}
-
-static void audrec_pcm_send_data(struct audio_aac_in *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-	MM_DBG("\n");
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			MM_DBG("frame %d free\n", audio->out_tail);
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			audrec_pcm_buffer_ptr_refresh(audio,
-						 audio->out_tail,
-						    frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
- done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-
-static int audaac_in_fsync(struct file *file, loff_t a, loff_t b, int datasync)
-
-{
-	struct audio_aac_in *audio = file->private_data;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (!audio->running || (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)) {
-		rc = -EINVAL;
-		goto done_nolock;
-	}
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-			audio->wflush);
-	MM_DBG("waked on by some event audio->wflush = %d\n", audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-done:
-	mutex_unlock(&audio->write_lock);
-done_nolock:
-	return rc;
-
-}
-
-int audrec_aac_process_eos(struct audio_aac_in *audio,
-		const char __user *buf_start, unsigned short mfield_size)
-{
-	struct buffer *frame;
-	int rc = 0;
-
-	frame = audio->out + audio->out_head;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	MM_DBG("copying meta_out frame->used = %d\n", frame->used);
-	audrec_pcm_send_data(audio, 0);
-done:
-	return rc;
-}
-static ssize_t audaac_in_write(struct file *file,
-				const char __user *buf,
-				size_t count, loff_t *pos)
-{
-	struct audio_aac_in *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	char *cpy_ptr;
-	int rc = 0, eos_condition = AUDPREPROC_AAC_EOS_NONE;
-	unsigned short mfield_size = 0;
-	int write_count = 0;
-	MM_DBG("cnt=%d\n", count);
-
-	if (count & 1)
-		return -EINVAL;
-
-	if (audio->mode != MSM_AUD_ENC_MODE_NONTUNNEL)
-		return -EINVAL;
-
-	mutex_lock(&audio->write_lock);
-	frame = audio->out + audio->out_head;
-	/* if supplied count is more than driver buffer size
-	 * then only copy driver buffer size
-	 */
-	if (count > frame->size)
-		count = frame->size;
-
-	write_count = count;
-	cpy_ptr = frame->data;
-	rc = wait_event_interruptible(audio->write_wait,
-				      (frame->used == 0)
-					|| (audio->stopped)
-					|| (audio->wflush));
-	if (rc < 0)
-		goto error;
-
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto error;
-	}
-	if (audio->mfield) {
-		if (buf == start) {
-			/* Processing beginning of user buffer */
-			if (__get_user(mfield_size,
-				(unsigned short __user *) buf)) {
-				rc = -EFAULT;
-				goto error;
-			} else if (mfield_size > count) {
-				rc = -EINVAL;
-				goto error;
-			}
-			MM_DBG("mf offset_val %x\n", mfield_size);
-			if (copy_from_user(cpy_ptr, buf, mfield_size)) {
-				rc = -EFAULT;
-				goto error;
-			}
-			/* Check if EOS flag is set and buffer has
-			 * contains just meta field
-			 */
-			if (cpy_ptr[AUDPREPROC_AAC_EOS_FLG_OFFSET] &
-					AUDPREPROC_AAC_EOS_FLG_MASK) {
-				eos_condition = AUDPREPROC_AAC_EOS_SET;
-				MM_DBG("EOS SET\n");
-				if (mfield_size == count) {
-					buf += mfield_size;
-					eos_condition = 0;
-					goto exit;
-				} else
-				cpy_ptr[AUDPREPROC_AAC_EOS_FLG_OFFSET] &=
-					~AUDPREPROC_AAC_EOS_FLG_MASK;
-			}
-			cpy_ptr += mfield_size;
-			count -= mfield_size;
-			buf += mfield_size;
-		} else {
-			mfield_size = 0;
-			MM_DBG("continuous buffer\n");
-		}
-		frame->mfield_sz = mfield_size;
-	}
-	MM_DBG("copying the stream count = %d\n", count);
-	if (copy_from_user(cpy_ptr, buf, count)) {
-		rc = -EFAULT;
-		goto error;
-	}
-exit:
-	frame->used = count;
-	audio->out_head ^= 1;
-	if (!audio->flush_ack)
-		audrec_pcm_send_data(audio, 0);
-	else {
-		audrec_pcm_send_data(audio, 1);
-		audio->flush_ack = 0;
-	}
-	if (eos_condition == AUDPREPROC_AAC_EOS_SET)
-		rc = audrec_aac_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	return write_count;
-error:
-	mutex_unlock(&audio->write_lock);
-	return rc;
-}
-
-static int audaac_in_release(struct inode *inode, struct file *file)
-{
-	struct audio_aac_in *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	audaac_in_disable(audio);
-	audaac_in_flush(audio);
-	msm_adsp_put(audio->audrec);
-
-
-	audpreproc_aenc_free(audio->enc_id);
-	audio->audrec = NULL;
-	audio->opened = 0;
-
-	if ((audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) && \
-	   (audio->out_data)) {
-		ion_unmap_kernel(audio->client, audio->input_buff_handle);
-		ion_free(audio->client, audio->input_buff_handle);
-		audio->out_data = NULL;
-	}
-
-	if (audio->data) {
-		ion_unmap_kernel(audio->client, audio->output_buff_handle);
-		ion_free(audio->client, audio->output_buff_handle);
-		audio->data = NULL;
-	}
-	ion_client_destroy(audio->client);
-	mutex_unlock(&audio->lock);
-	return 0;
-}
-
-struct audio_aac_in the_audio_aac_in;
-
-static int audaac_in_open(struct inode *inode, struct file *file)
-{
-	struct audio_aac_in *audio = &the_audio_aac_in;
-	int rc;
-	int encid;
-	int dma_size = 0;
-	int len = 0;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	struct ion_client *client = NULL;
-
-	mutex_lock(&audio->lock);
-	if (audio->opened) {
-		rc = -EBUSY;
-		goto done;
-	}
-	if ((file->f_mode & FMODE_WRITE) &&
-		(file->f_mode & FMODE_READ)) {
-		audio->mode = MSM_AUD_ENC_MODE_NONTUNNEL;
-		dma_size = NT_DMASZ;
-		MM_DBG("Opened for non tunnel mode encoding\n");
-	} else if (!(file->f_mode & FMODE_WRITE) &&
-				(file->f_mode & FMODE_READ)) {
-		audio->mode = MSM_AUD_ENC_MODE_TUNNEL;
-		dma_size = DMASZ;
-		MM_DBG("Opened for tunnel mode encoding\n");
-	} else {
-		MM_ERR("Invalid mode\n");
-		rc = -EACCES;
-		goto done;
-	}
-
-	/* Settings will be re-config at AUDIO_SET_CONFIG,
-	 * but at least we need to have initial config
-	 */
-	audio->samp_rate = RPC_AUD_DEF_SAMPLE_RATE_11025;
-	audio->samp_rate_index = AUDREC_CMD_SAMP_RATE_INDX_11025;
-
-	/* For AAC, bit rate hard coded, default settings is
-	 * sample rate (11025) x channel count (1) x recording quality (1.75)
-	 * = 19293 bps  */
-	audio->bit_rate = 19293;
-	audio->record_quality = 0x1c00;
-
-	audio->channel_mode = AUDREC_CMD_STEREO_MODE_MONO;
-	if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL)
-			audio->buffer_size = (AAC_FRAME_SIZE + 14);
-	else
-			audio->buffer_size = (FRAME_SIZE - 8);
-	audio->enc_type = AUDREC_CMD_TYPE_0_INDEX_AAC | audio->mode;
-
-	if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-		rc = audmgr_open(&audio->audmgr);
-		if (rc)
-			goto done;
-	}
-
-	encid = audpreproc_aenc_alloc(audio->enc_type, &audio->module_name,
-			&audio->queue_ids);
-	if (encid < 0) {
-		MM_ERR("No free encoder available\n");
-		rc = -ENODEV;
-		goto done;
-	}
-	audio->enc_id = encid;
-
-	rc = msm_adsp_get(audio->module_name, &audio->audrec,
-			   &audrec_aac_adsp_ops, audio);
-	if (rc) {
-		audpreproc_aenc_free(audio->enc_id);
-		goto done;
-	}
-
-	audio->dsp_cnt = 0;
-	audio->stopped = 0;
-	audio->wflush = 0;
-	audio->rflush = 0;
-	audio->flush_ack = 0;
-
-	audaac_in_flush(audio);
-	audaac_out_flush(audio);
-
-
-	client = msm_ion_client_create(UINT_MAX, "Audio_AAC_in_client");
-	if (IS_ERR_OR_NULL(client)) {
-		MM_ERR("Unable to create ION client\n");
-		rc = -ENOMEM;
-		goto client_create_error;
-	}
-	audio->client = client;
-
-	MM_DBG("allocating mem sz = %d\n", dma_size);
-	handle = ion_alloc(client, dma_size, SZ_4K,
-		ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-	if (IS_ERR_OR_NULL(handle)) {
-		MM_ERR("Unable to create allocate O/P buffers\n");
-		rc = -ENOMEM;
-		goto output_buff_alloc_error;
-	}
-
-	audio->output_buff_handle = handle;
-
-	rc = ion_phys(client , handle, &addr, &len);
-	if (rc) {
-		MM_ERR("O/P buffers:Invalid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-		rc = -ENOMEM;
-		goto output_buff_get_phys_error;
-	} else {
-		MM_INFO("O/P buffers:valid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-	}
-	audio->phys = (int32_t)addr;
-
-	rc = ion_handle_get_flags(client, handle, &ionflag);
-	if (rc) {
-		MM_ERR("could not get flags for the handle\n");
-		rc = -ENOMEM;
-		goto output_buff_get_flags_error;
-	}
-
-	audio->map_v_read = ion_map_kernel(client, handle);
-	if (IS_ERR(audio->map_v_read)) {
-		MM_ERR("could not map read buffers,freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENOMEM;
-		goto output_buff_map_error;
-	}
-	audio->data = audio->map_v_read;
-	MM_DBG("read buf: phy addr 0x%08x kernel addr 0x%08x\n",
-		audio->phys, (int)audio->data);
-
-	audio->out_data = NULL;
-	if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) {
-
-		MM_DBG("allocating BUFFER_SIZE  %d\n", BUFFER_SIZE);
-		handle = ion_alloc(client, BUFFER_SIZE,
-				SZ_4K, ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-		if (IS_ERR_OR_NULL(handle)) {
-			MM_ERR("Unable to create allocate I/P buffers\n");
-			rc = -ENOMEM;
-			goto input_buff_alloc_error;
-		}
-
-		audio->input_buff_handle = handle;
-
-		rc = ion_phys(client , handle, &addr, &len);
-		if (rc) {
-			MM_ERR("I/P buffers:Invalid phy: %x sz: %x\n",
-				(unsigned int) addr, (unsigned int) len);
-			rc = -ENOMEM;
-			goto input_buff_get_phys_error;
-		} else {
-			MM_INFO("Got valid phy: %x sz: %x\n",
-				(unsigned int) addr,
-				(unsigned int) len);
-		}
-		audio->out_phys = (int32_t)addr;
-
-		rc = ion_handle_get_flags(client,
-			handle, &ionflag);
-		if (rc) {
-			MM_ERR("could not get flags for the handle\n");
-			rc = -ENOMEM;
-			goto input_buff_get_flags_error;
-		}
-
-		audio->map_v_write = ion_map_kernel(client, handle);
-		if (IS_ERR(audio->map_v_write)) {
-			MM_ERR("could not map write buffers\n");
-			rc = -ENOMEM;
-			goto input_buff_map_error;
-		}
-		audio->out_data = audio->map_v_write;
-		MM_DBG("write buf: phy addr 0x%08x kernel addr 0x%08x\n",
-					(unsigned int)addr,
-					(unsigned int)audio->out_data);
-
-		/* Initialize buffer */
-		audio->out[0].data = audio->out_data + 0;
-		audio->out[0].addr = audio->out_phys + 0;
-		audio->out[0].size = OUT_BUFFER_SIZE;
-
-		audio->out[1].data = audio->out_data + OUT_BUFFER_SIZE;
-		audio->out[1].addr = audio->out_phys + OUT_BUFFER_SIZE;
-		audio->out[1].size = OUT_BUFFER_SIZE;
-
-		MM_DBG("audio->out[0].data = %d  audio->out[1].data = %d",
-				(unsigned int)audio->out[0].data,
-				(unsigned int)audio->out[1].data);
-		audio->mfield = NT_FRAME_HEADER_SIZE;
-		audio->out_frame_cnt++;
-	}
-	file->private_data = audio;
-	audio->opened = 1;
-
-done:
-	mutex_unlock(&audio->lock);
-	return rc;
-input_buff_map_error:
-input_buff_get_flags_error:
-input_buff_get_phys_error:
-	ion_free(client, audio->input_buff_handle);
-input_buff_alloc_error:
-	ion_unmap_kernel(client, audio->output_buff_handle);
-output_buff_map_error:
-output_buff_get_phys_error:
-output_buff_get_flags_error:
-	ion_free(client, audio->output_buff_handle);
-output_buff_alloc_error:
-	ion_client_destroy(client);
-client_create_error:
-	msm_adsp_put(audio->audrec);
-
-	audpreproc_aenc_free(audio->enc_id);
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static const struct file_operations audio_aac_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audaac_in_open,
-	.release	= audaac_in_release,
-	.read		= audaac_in_read,
-	.write		= audaac_in_write,
-	.fsync		= audaac_in_fsync,
-	.unlocked_ioctl	= audaac_in_ioctl,
-};
-
-static struct miscdevice audaac_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_aac_in",
-	.fops	= &audio_aac_in_fops,
-};
-
-static int __init audaac_in_init(void)
-{
-	mutex_init(&the_audio_aac_in.lock);
-	mutex_init(&the_audio_aac_in.read_lock);
-	spin_lock_init(&the_audio_aac_in.dsp_lock);
-	init_waitqueue_head(&the_audio_aac_in.wait);
-	init_waitqueue_head(&the_audio_aac_in.wait_enable);
-	mutex_init(&the_audio_aac_in.write_lock);
-	init_waitqueue_head(&the_audio_aac_in.write_wait);
-	return misc_register(&audaac_in_misc);
-}
-device_initcall(audaac_in_init);
diff --git a/arch/arm/mach-msm/qdsp5/audio_ac3.c b/arch/arm/mach-msm/qdsp5/audio_ac3.c
deleted file mode 100644
index 199b322..0000000
--- a/arch/arm/mach-msm/qdsp5/audio_ac3.c
+++ /dev/null
@@ -1,1760 +0,0 @@
-/* arch/arm/mach-msm/audio_ac3.c
- *
- * Copyright (c) 2008-2009, 2011-2013 The Linux Foundation. All rights reserved.
- *
- * This code also borrows from audio_aac.c, which is
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you can find it at http://www.fsf.org.
- */
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/list.h>
-#include <linux/earlysuspend.h>
-#include <linux/slab.h>
-#include <linux/msm_audio.h>
-#include <linux/memory_alloc.h>
-#include <linux/msm_audio_ac3.h>
-#include <linux/msm_ion.h>
-
-#include <mach/msm_adsp.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/qdsp5/qdsp5audppcmdi.h>
-#include <mach/qdsp5/qdsp5audppmsg.h>
-#include <mach/qdsp5/qdsp5audpp.h>
-#include <mach/qdsp5/qdsp5audplaycmdi.h>
-#include <mach/qdsp5/qdsp5audplaymsg.h>
-#include <mach/qdsp5/qdsp5rmtcmdi.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_memtypes.h>
-
-#include "audmgr.h"
-
-#define BUFSZ			4096
-#define DMASZ			(BUFSZ * 2)
-
-#define AUDDEC_DEC_AC3		23
-
-#define PCM_BUFSZ		6168 /* maximum frame size is 512 * 6 samples */
-#define PCM_BUF_MAX_COUNT	5  /* DSP only accepts 5 buffers at most
-				    * but support 2 buffers currently
-				   */
-#define ROUTING_MODE_FTRT	1
-#define ROUTING_MODE_RT		2
-
-/* Decoder status received from AUDPPTASK */
-#define AUDPP_DEC_STATUS_SLEEP	0
-#define	AUDPP_DEC_STATUS_INIT  1
-#define AUDPP_DEC_STATUS_CFG   2
-#define AUDPP_DEC_STATUS_PLAY  3
-
-#define AUDAC3_METAFIELD_MASK 0xFFFF0000
-#define AUDAC3_EOS_FLG_OFFSET 0x0A /* Offset from beginning of buffer */
-#define AUDAC3_EOS_FLG_MASK 0x01
-#define AUDAC3_EOS_NONE 0x0 /* No EOS detected */
-#define AUDAC3_EOS_SET 0x1 /* EOS set in meta field */
-
-#define AUDAC3_EVENT_NUM 10 /* Default number of pre-allocated event packets */
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;		/* Input usage actual DSP produced PCM size  */
-	unsigned addr;
-	unsigned short mfield_sz; /* only useful for data has meta field */
-};
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-struct audac3_suspend_ctl {
-	struct early_suspend node;
-	struct audio *audio;
-};
-#endif
-
-struct audac3_event {
-	struct list_head list;
-	int event_type;
-	union msm_audio_event_payload payload;
-};
-
-struct audio {
-	struct buffer out[2];
-
-	spinlock_t dsp_lock;
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed;	/* number of buffers the dsp is waiting for */
-
-	atomic_t out_bytes;
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-
-	/* Host PCM section */
-	struct buffer in[PCM_BUF_MAX_COUNT];
-	struct mutex read_lock;
-	wait_queue_head_t read_wait;	/* Wait queue for read */
-	char *read_data;	/* pointer to reader buffer */
-	int32_t read_phys;	/* physical address of reader buffer */
-	uint8_t read_next;	/* index to input buffers to be read next */
-	uint8_t fill_next;	/* index to buffer that DSP should be filling */
-	uint8_t pcm_buf_count;	/* number of pcm buffer allocated */
-	/* ---- End of Host PCM section */
-
-	struct msm_adsp_module *audplay;
-	struct audmgr audmgr;
-	struct msm_audio_ac3_config ac3_config;
-
-	/* data allocated for various buffers */
-	char *data;
-	int32_t phys;  /* physical address of write buffer */
-	void *map_v_read;
-	void *map_v_write;
-
-	int mfield; /* meta field embedded in data */
-	int rflush; /* Read  flush */
-	int wflush; /* Write flush */
-	uint8_t opened;
-	uint8_t enabled;
-	uint8_t running;
-	uint8_t stopped;	/* set when stopped, cleared on flush */
-	uint8_t pcm_feedback;
-	uint8_t buf_refresh;
-	int teos; /* valid only if tunnel mode & no data left for decoder */
-	enum msm_aud_decoder_state dec_state;	/* Represents decoder state */
-	int rmt_resource_released;
-
-	const char *module_name;
-	unsigned queue_id;
-	uint16_t dec_id;
-	uint32_t read_ptr_offset;
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	struct audac3_suspend_ctl suspend_ctl;
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *dentry;
-#endif
-
-	wait_queue_head_t wait;
-	struct list_head free_event_queue;
-	struct list_head event_queue;
-	wait_queue_head_t event_wait;
-	spinlock_t event_queue_lock;
-	struct mutex get_event_lock;
-	int event_abort;
-
-	int eq_enable;
-	int eq_needs_commit;
-	audpp_cmd_cfg_object_params_eqalizer eq;
-	audpp_cmd_cfg_object_params_volume vol_pan;
-	struct ion_client *client;
-	struct ion_handle *input_buff_handle;
-	struct ion_handle *output_buff_handle;
-};
-
-static int auddec_dsp_config(struct audio *audio, int enable);
-static void audpp_cmd_cfg_adec_params(struct audio *audio);
-static void audpp_cmd_cfg_routing_mode(struct audio *audio);
-static void audac3_send_data(struct audio *audio, unsigned needed);
-static void audac3_dsp_event(void *private, unsigned id, uint16_t *msg);
-static void audac3_config_hostpcm(struct audio *audio);
-static void audac3_buffer_refresh(struct audio *audio);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audac3_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload);
-#endif
-
-static int rmt_put_resource(struct audio *audio)
-{
-	struct aud_codec_config_cmd cmd;
-	unsigned short client_idx;
-
-	cmd.cmd_id = RM_CMD_AUD_CODEC_CFG;
-	cmd.client_id = RM_AUD_CLIENT_ID;
-	cmd.task_id = audio->dec_id;
-	cmd.enable = RMT_DISABLE;
-	cmd.dec_type = AUDDEC_DEC_AC3;
-	client_idx = ((cmd.client_id << 8) | cmd.task_id);
-
-	return put_adsp_resource(client_idx, &cmd, sizeof(cmd));
-}
-
-static int rmt_get_resource(struct audio *audio)
-{
-	struct aud_codec_config_cmd cmd;
-	unsigned short client_idx;
-
-	cmd.cmd_id = RM_CMD_AUD_CODEC_CFG;
-	cmd.client_id = RM_AUD_CLIENT_ID;
-	cmd.task_id = audio->dec_id;
-	cmd.enable = RMT_ENABLE;
-	cmd.dec_type = AUDDEC_DEC_AC3;
-	client_idx = ((cmd.client_id << 8) | cmd.task_id);
-	return get_adsp_resource(client_idx, &cmd, sizeof(cmd));
-}
-
-/* must be called with audio->lock held */
-static int audac3_enable(struct audio *audio)
-{
-	struct audmgr_config cfg;
-	int rc;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	if (audio->enabled)
-		return 0;
-
-	if (audio->rmt_resource_released == 1) {
-		audio->rmt_resource_released = 0;
-		rc = rmt_get_resource(audio);
-		if (rc) {
-			MM_ERR("ADSP resources are not available for AC3"\
-				" session 0x%08x on decoder: %d\n Ignoring"\
-				" error and going ahead with the playback\n",
-				(int)audio, audio->dec_id);
-		}
-	}
-
-	audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-
-	if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK) {
-		cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE;
-		cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000;
-		cfg.def_method = RPC_AUD_DEF_METHOD_PLAYBACK;
-		cfg.codec = RPC_AUD_DEF_CODEC_AC3;
-		cfg.snd_method = RPC_SND_METHOD_MIDI;
-
-		rc = audmgr_enable(&audio->audmgr, &cfg);
-		if (rc < 0) {
-			msm_adsp_dump(audio->audplay);
-			return rc;
-		}
-	}
-
-	if (msm_adsp_enable(audio->audplay)) {
-		MM_ERR("msm_adsp_enable(audplay) failed\n");
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_disable(&audio->audmgr);
-		return -ENODEV;
-	}
-
-	if (audpp_enable(audio->dec_id, audac3_dsp_event, audio)) {
-		MM_ERR("audpp_enable() failed\n");
-		msm_adsp_disable(audio->audplay);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_disable(&audio->audmgr);
-		return -ENODEV;
-	}
-	audio->enabled = 1;
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audac3_disable(struct audio *audio)
-{
-	int rc = 0;
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-		auddec_dsp_config(audio, 0);
-		rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-		if (rc == 0)
-			rc = -ETIMEDOUT;
-		else if (audio->dec_state != MSM_AUD_DECODER_STATE_CLOSE)
-			rc = -EFAULT;
-		else
-			rc = 0;
-		audio->stopped = 1;
-		wake_up(&audio->write_wait);
-		wake_up(&audio->read_wait);
-		msm_adsp_disable(audio->audplay);
-		audpp_disable(audio->dec_id, audio);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK) {
-			rc = audmgr_disable(&audio->audmgr);
-			if (rc < 0)
-				msm_adsp_dump(audio->audplay);
-		}
-		audio->out_needed = 0;
-		rmt_put_resource(audio);
-		audio->rmt_resource_released = 1;
-	}
-	return rc;
-}
-
-/* ------------------- dsp --------------------- */
-
-static void audac3_update_pcm_buf_entry(struct audio *audio,
-					 uint32_t *payload)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	if (audio->rflush)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < payload[1]; index++) {
-		if (audio->in[audio->fill_next].addr
-				== payload[2 + index * 2]) {
-			MM_DBG("in[%d] ready\n", audio->fill_next);
-			audio->in[audio->fill_next].used =
-				payload[3 + index * 2];
-			if ((++audio->fill_next) == audio->pcm_buf_count)
-				audio->fill_next = 0;
-
-		} else {
-			MM_ERR("expected=%x ret=%x\n",
-				audio->in[audio->fill_next].addr,
-				payload[1 + index * 2]);
-			break;
-		}
-	}
-	if (audio->in[audio->fill_next].used == 0) {
-		audac3_buffer_refresh(audio);
-	} else {
-		MM_DBG("read cannot keep up\n");
-		audio->buf_refresh = 1;
-	}
-	wake_up(&audio->read_wait);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audplay_dsp_event(void *data, unsigned id, size_t len,
-			      void (*getevent) (void *ptr, size_t len))
-{
-	struct audio *audio = data;
-	uint32_t msg[28];
-	getevent(msg, sizeof(msg));
-
-	MM_DBG("msg_id=%x\n", id);
-	switch (id) {
-	case AUDPLAY_MSG_DEC_NEEDS_DATA:
-		audac3_send_data(audio, 1);
-		break;
-	case AUDPLAY_MSG_BUFFER_UPDATE:
-		MM_DBG("\n"); /* Macro prints the file name and function */
-		audac3_update_pcm_buf_entry(audio, msg);
-		break;
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audplaytask)\n");
-		break;
-	default:
-		MM_ERR("unexpected message from decoder\n");
-	}
-}
-
-static void audac3_dsp_event(void *private, unsigned id, uint16_t *msg)
-{
-	struct audio *audio = private;
-
-	switch (id) {
-	case AUDPP_MSG_STATUS_MSG:{
-			unsigned status = msg[1];
-
-			switch (status) {
-			case AUDPP_DEC_STATUS_SLEEP: {
-				uint16_t reason = msg[2];
-				MM_DBG("decoder status:sleep reason =0x%04x\n",
-					reason);
-				if ((reason == AUDPP_MSG_REASON_MEM)
-					|| (reason ==
-					AUDPP_MSG_REASON_NODECODER)) {
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_FAILURE;
-					wake_up(&audio->wait);
-				} else if (reason == AUDPP_MSG_REASON_NONE) {
-					/* decoder is in disable state */
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_CLOSE;
-					wake_up(&audio->wait);
-				}
-				break;
-			}
-			case AUDPP_DEC_STATUS_INIT:
-				MM_DBG("decoder status: init\n");
-				if (audio->pcm_feedback)
-					audpp_cmd_cfg_routing_mode(audio);
-				else
-					audpp_cmd_cfg_adec_params(audio);
-				break;
-
-			case AUDPP_DEC_STATUS_CFG:
-				MM_DBG("decoder status: cfg\n");
-				break;
-			case AUDPP_DEC_STATUS_PLAY:
-				MM_DBG("decoder status: play\n");
-				if (audio->pcm_feedback) {
-					audac3_config_hostpcm(audio);
-					audac3_buffer_refresh(audio);
-				}
-				audio->dec_state =
-					MSM_AUD_DECODER_STATE_SUCCESS;
-				wake_up(&audio->wait);
-				break;
-			default:
-				MM_ERR("unknown decoder status\n");
-			}
-			break;
-		}
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_DBG("CFG_MSG ENABLE\n");
-			auddec_dsp_config(audio, 1);
-			audio->out_needed = 0;
-			audio->running = 1;
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-			audpp_dsp_set_eq(audio->dec_id,	audio->eq_enable,
-								&audio->eq);
-			audpp_avsync(audio->dec_id, 22050);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			MM_DBG("CFG_MSG DISABLE\n");
-			audpp_avsync(audio->dec_id, 0);
-			audio->running = 0;
-		} else {
-			MM_DBG("CFG_MSG %d?\n", msg[0]);
-		}
-		break;
-	case AUDPP_MSG_ROUTING_ACK:
-		MM_DBG("ROUTING_ACK\n");
-		audpp_cmd_cfg_adec_params(audio);
-		break;
-	case AUDPP_MSG_FLUSH_ACK:
-		MM_DBG("FLUSH_ACK\n");
-		audio->wflush = 0;
-		audio->rflush = 0;
-		wake_up(&audio->write_wait);
-		if (audio->pcm_feedback)
-			audac3_buffer_refresh(audio);
-		break;
-	case AUDPP_MSG_PCMDMAMISSED:
-		MM_DBG("PCMDMAMISSED\n");
-		audio->teos = 1;
-		wake_up(&audio->write_wait);
-		break;
-	default:
-		MM_ERR("UNKNOWN (%d)\n", id);
-	}
-
-}
-
-struct msm_adsp_ops audplay_adsp_ops_ac3 = {
-	.event = audplay_dsp_event,
-};
-
-#define audplay_send_queue0(audio, cmd, len) \
-	msm_adsp_write(audio->audplay, audio->queue_id, \
-			cmd, len)
-
-static int auddec_dsp_config(struct audio *audio, int enable)
-{
-	u16 cfg_dec_cmd[AUDPP_CMD_CFG_DEC_TYPE_LEN / sizeof(unsigned short)];
-
-	memset(cfg_dec_cmd, 0, sizeof(cfg_dec_cmd));
-
-	cfg_dec_cmd[0] = AUDPP_CMD_CFG_DEC_TYPE;
-	if (enable)
-		cfg_dec_cmd[1 + audio->dec_id] = AUDPP_CMD_UPDATDE_CFG_DEC |
-			AUDPP_CMD_ENA_DEC_V | AUDDEC_DEC_AC3;
-	else
-		cfg_dec_cmd[1 + audio->dec_id] = AUDPP_CMD_UPDATDE_CFG_DEC |
-			AUDPP_CMD_DIS_DEC_V;
-
-	return audpp_send_queue1(&cfg_dec_cmd, sizeof(cfg_dec_cmd));
-}
-static int get_frequency_index(unsigned short frequency)
-{
-	switch (frequency) {
-	case 48000: return 0;
-	case 44100: return 1;
-	case 32000: return 2;
-	default: return -EINVAL;
-	}
-}
-static void audpp_cmd_cfg_adec_params(struct audio *audio)
-{
-	struct audpp_cmd_cfg_adec_params_ac3 cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_CMD_CFG_ADEC_PARAMS;
-	/* dsp needs word size */
-	cmd.common.length = AUDPP_CMD_CFG_ADEC_PARAMS_AC3_LEN >> 1;
-	cmd.common.dec_id = audio->dec_id;
-	cmd.common.input_sampling_frequency = (audio->ac3_config).fsCod;
-
-	cmd.index[0] = (((audio->ac3_config).numChans << 8) & 0xFF00) |
-				((audio->ac3_config).wordSize & 0x00FF);
-
-	cmd.index[1] = (((audio->ac3_config).kCapableMode << 12) & 0xF000) |
-				(((audio->ac3_config).compMode << 8) & 0x0F00) |
-				(((audio->ac3_config).outLfeOn << 4) & 0x00F0) |
-				((audio->ac3_config).outputMode & 0x000F);
-
-	cmd.index[2] = ((((audio->ac3_config).stereoMode << 12) & 0xF000) |
-			(((audio->ac3_config).dualMonoMode << 8) & 0x0F00) |
-			((get_frequency_index((audio->ac3_config).fsCod) << 4)
-			& 0x00F0)) & 0xFFF0; /* last 4 bytes are reserved */
-
-	cmd.index[3] = (audio->ac3_config).pcmScaleFac;
-	cmd.index[4] = (audio->ac3_config).dynRngScaleHi;
-	cmd.index[5] = (audio->ac3_config).dynRngScaleLow;
-
-	cmd.index[6] = (((audio->ac3_config).user_downmix_flag << 8) & 0xFF00)|
-			((audio->ac3_config).user_karaoke_flag & 0x00FF);
-
-	cmd.index[7] = (audio->ac3_config).dm_address_high;
-	cmd.index[8] = (audio->ac3_config).dm_address_low;
-	cmd.index[9] = (audio->ac3_config).ko_address_high;
-	cmd.index[10] = (audio->ac3_config).ko_address_high;
-
-	cmd.index[11] = (((audio->ac3_config).max_rep_count << 1) & 0xFFFE) |
-			((audio->ac3_config).error_concealment & 0x0001);
-
-	cmd.index[12] = (((audio->ac3_config).channel_routing_mode[3] << 12)
-			& 0xF000) |
-			(((audio->ac3_config).channel_routing_mode[2] << 8)
-			& 0x0F00) |
-			(((audio->ac3_config).channel_routing_mode[1] << 4)
-			& 0x00F0) |
-			((audio->ac3_config).channel_routing_mode[0] & 0x000F);
-
-	cmd.index[13] = ((((audio->ac3_config).channel_routing_mode[5] << 12)
-			& 0xF000) |
-			(((audio->ac3_config).channel_routing_mode[4] << 8)
-			& 0x0F00)) & 0xFF00; /* last 8 bytes are reserved */
-
-	audpp_send_queue2(&cmd, sizeof(cmd));
-}
-
-static void audpp_cmd_cfg_routing_mode(struct audio *audio)
-{
-	struct audpp_cmd_routing_mode cmd;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPP_CMD_ROUTING_MODE;
-	cmd.object_number = audio->dec_id;
-	if (audio->pcm_feedback)
-		cmd.routing_mode = ROUTING_MODE_FTRT;
-	else
-		cmd.routing_mode = ROUTING_MODE_RT;
-
-	audpp_send_queue1(&cmd, sizeof(cmd));
-}
-
-static int audplay_dsp_send_data_avail(struct audio *audio,
-				       unsigned idx, unsigned len)
-{
-	struct audplay_cmd_bitstream_data_avail_nt2 cmd;
-
-	cmd.cmd_id = AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2;
-	if (audio->mfield)
-		cmd.decoder_id = AUDAC3_METAFIELD_MASK |
-			(audio->out[idx].mfield_sz >> 1);
-	else
-		cmd.decoder_id = audio->dec_id;
-	cmd.buf_ptr = audio->out[idx].addr;
-	cmd.buf_size = len / 2;
-	cmd.partition_number = 0;
-	/* complete writes to the input buffer */
-	wmb();
-	return audplay_send_queue0(audio, &cmd, sizeof(cmd));
-}
-
-static void audac3_buffer_refresh(struct audio *audio)
-{
-	struct audplay_cmd_buffer_refresh refresh_cmd;
-
-	refresh_cmd.cmd_id = AUDPLAY_CMD_BUFFER_REFRESH;
-	refresh_cmd.num_buffers = 1;
-	refresh_cmd.buf0_address = audio->in[audio->fill_next].addr;
-	refresh_cmd.buf0_length = audio->in[audio->fill_next].size;
-
-	refresh_cmd.buf_read_count = 0;
-	MM_DBG("buf0_addr=%x buf0_len=%d\n", refresh_cmd.buf0_address,
-			refresh_cmd.buf0_length);
-	(void)audplay_send_queue0(audio, &refresh_cmd, sizeof(refresh_cmd));
-}
-
-static void audac3_config_hostpcm(struct audio *audio)
-{
-	struct audplay_cmd_hpcm_buf_cfg cfg_cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	cfg_cmd.cmd_id = AUDPLAY_CMD_HPCM_BUF_CFG;
-	cfg_cmd.max_buffers = 1;
-	cfg_cmd.byte_swap = 0;
-	cfg_cmd.hostpcm_config = (0x8000) | (0x4000);
-	cfg_cmd.feedback_frequency = 1;
-	cfg_cmd.partition_number = 0;
-	(void)audplay_send_queue0(audio, &cfg_cmd, sizeof(cfg_cmd));
-
-}
-
-static void audac3_send_data(struct audio *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			MM_DBG("frame %d free\n", audio->out_tail);
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			MM_DBG("frame %d busy\n", audio->out_tail);
-			audplay_dsp_send_data_avail(audio, audio->out_tail,
-						    frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
-done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-
-static void audac3_flush(struct audio *audio)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->out[0].used = 0;
-	audio->out[1].used = 0;
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	atomic_set(&audio->out_bytes, 0);
-}
-
-static void audac3_flush_pcm_buf(struct audio *audio)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < PCM_BUF_MAX_COUNT; index++)
-		audio->in[index].used = 0;
-	audio->buf_refresh = 0;
-	audio->read_next = 0;
-	audio->fill_next = 0;
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-/*check if func to be added to validate user data*/
-
-static void audac3_ioport_reset(struct audio *audio)
-{
-	/* Make sure read/write thread are free from
-	 * sleep and knowing that system is not able
-	 * to process io request at the moment
-	 */
-	wake_up(&audio->write_wait);
-	mutex_lock(&audio->write_lock);
-	audac3_flush(audio);
-	mutex_unlock(&audio->write_lock);
-	wake_up(&audio->read_wait);
-	mutex_lock(&audio->read_lock);
-	audac3_flush_pcm_buf(audio);
-	mutex_unlock(&audio->read_lock);
-}
-
-static int audac3_events_pending(struct audio *audio)
-{
-	unsigned long flags;
-	int empty;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	empty = !list_empty(&audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	return empty || audio->event_abort;
-}
-
-static void audac3_reset_event_queue(struct audio *audio)
-{
-	unsigned long flags;
-	struct audac3_event *drv_evt;
-	struct list_head *ptr, *next;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	list_for_each_safe(ptr, next, &audio->event_queue) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audac3_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	list_for_each_safe(ptr, next, &audio->free_event_queue) {
-		drv_evt = list_first_entry(&audio->free_event_queue,
-			struct audac3_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	return;
-}
-
-
-static long audac3_process_event_req(struct audio *audio, void __user *arg)
-{
-	long rc;
-	struct msm_audio_event usr_evt;
-	struct audac3_event *drv_evt = NULL;
-	int timeout;
-	unsigned long flags;
-
-	if (copy_from_user(&usr_evt, arg, sizeof(struct msm_audio_event)))
-		return -EFAULT;
-
-	timeout = (int) usr_evt.timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(
-			audio->event_wait, audac3_events_pending(audio),
-			msecs_to_jiffies(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(
-			audio->event_wait, audac3_events_pending(audio));
-	}
-
-	if (rc < 0)
-		return rc;
-
-	if (audio->event_abort) {
-		audio->event_abort = 0;
-		return -ENODEV;
-	}
-
-	rc = 0;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	if (!list_empty(&audio->event_queue)) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audac3_event, list);
-		list_del(&drv_evt->list);
-	}
-	if (drv_evt) {
-		usr_evt.event_type = drv_evt->event_type;
-		usr_evt.event_payload = drv_evt->payload;
-		list_add_tail(&drv_evt->list, &audio->free_event_queue);
-	} else
-		rc = -1;
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	if (!rc && copy_to_user(arg, &usr_evt, sizeof(usr_evt)))
-		rc = -EFAULT;
-
-	return rc;
-}
-
-static int audio_enable_eq(struct audio *audio, int enable)
-{
-	if (audio->eq_enable == enable && !audio->eq_needs_commit)
-		return 0;
-
-	audio->eq_enable = enable;
-
-	if (audio->running) {
-		audpp_dsp_set_eq(audio->dec_id, enable, &audio->eq);
-		audio->eq_needs_commit = 0;
-	}
-	return 0;
-}
-
-static long audac3_ioctl(struct file *file, unsigned int cmd,
-			  unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = -EINVAL;
-	unsigned long flags = 0;
-	uint16_t enable_mask;
-	int enable;
-	int prev_state;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	int len = 0;
-
-	MM_DBG("cmd = %d\n", cmd);
-
-	switch (cmd) {
-	case AUDIO_ENABLE_AUDPP:
-		if (copy_from_user(&enable_mask, (void *) arg,
-						sizeof(enable_mask))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		enable = (enable_mask & EQ_ENABLE) ? 1 : 0;
-		audio_enable_eq(audio, enable);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-	case AUDIO_SET_VOLUME:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.volume = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_PAN:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.pan = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_EQ:
-		prev_state = audio->eq_enable;
-		audio->eq_enable = 0;
-		if (copy_from_user(&audio->eq.num_bands, (void *) arg,
-				sizeof(audio->eq) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2))) {
-			rc = -EFAULT;
-			break;
-		}
-		audio->eq_enable = prev_state;
-		audio->eq_needs_commit = 1;
-		rc = 0;
-		break;
-	}
-
-	if (-EINVAL != rc)
-		return rc;
-
-	if (cmd == AUDIO_GET_EVENT) {
-		MM_DBG("AUDIO_GET_EVENT\n");
-		if (mutex_trylock(&audio->get_event_lock)) {
-			rc = audac3_process_event_req(audio,
-					(void __user *) arg);
-			mutex_unlock(&audio->get_event_lock);
-		} else
-			rc = -EBUSY;
-		return rc;
-	}
-
-	if (cmd == AUDIO_ABORT_GET_EVENT) {
-		audio->event_abort = 1;
-		wake_up(&audio->event_wait);
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		MM_DBG("AUDIO_START\n");
-		rc = audac3_enable(audio);
-		if (!rc) {
-			rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-			MM_INFO("dec_state %d rc = %d\n", audio->dec_state, rc);
-
-			if (audio->dec_state != MSM_AUD_DECODER_STATE_SUCCESS) {
-				MM_ERR("In audio->dec_state !=\n");
-				rc = -ENODEV;
-			} else
-				rc = 0;
-		}
-		break;
-	case AUDIO_STOP:
-		MM_DBG("AUDIO_STOP\n");
-		rc = audac3_disable(audio);
-		audac3_ioport_reset(audio);
-		audio->stopped = 0;
-		break;
-	case AUDIO_FLUSH:
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audac3_ioport_reset(audio);
-		if (audio->running) {
-			audpp_flush(audio->dec_id);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-	case AUDIO_SET_CONFIG:{
-			struct msm_audio_config config;
-			if (copy_from_user
-				(&config, (void *)arg, sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-			audio->mfield = config.meta_field;
-			rc = 0;
-			MM_DBG("AUDIO_SET_CONFIG applicable only"\
-				" for meta field configuration\n");
-			break;
-		}
-	case AUDIO_GET_CONFIG:{
-			struct msm_audio_config config;
-			config.buffer_size = BUFSZ;
-			config.buffer_count = 2;
-			config.sample_rate = (audio->ac3_config).fsCod;
-			config.channel_count = 2;
-			config.meta_field = 0;
-			config.unused[0] = 0;
-			config.unused[1] = 0;
-			config.unused[2] = 0;
-			if (copy_to_user((void *)arg, &config, sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_GET_AC3_CONFIG:{
-			if (copy_to_user((void *)arg, &audio->ac3_config,
-				sizeof(audio->ac3_config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_SET_AC3_CONFIG:{
-			struct msm_audio_ac3_config usr_config;
-
-			if (copy_from_user
-				(&usr_config, (void *)arg,
-					sizeof(usr_config))) {
-				rc = -EFAULT;
-				break;
-			}
-
-			audio->ac3_config = usr_config;
-			rc = 0;
-			break;
-		}
-	case AUDIO_GET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			config.pcm_feedback = audio->pcm_feedback;
-			config.buffer_count = PCM_BUF_MAX_COUNT;
-			config.buffer_size = PCM_BUFSZ;
-			if (copy_to_user((void *)arg, &config, sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_SET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			if (copy_from_user
-			    (&config, (void *)arg, sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-			if (config.pcm_feedback != audio->pcm_feedback) {
-
-				MM_ERR("Not sufficient permission to"\
-					" change the playback mode\n");
-				rc = -EACCES;
-				break;
-
-			}
-			if ((config.buffer_count > PCM_BUF_MAX_COUNT) ||
-			    (config.buffer_count == 1))
-				config.buffer_count = PCM_BUF_MAX_COUNT;
-
-			if (config.buffer_size < PCM_BUFSZ)
-				config.buffer_size = PCM_BUFSZ;
-
-			/* Check if pcm feedback is required */
-			if ((config.pcm_feedback) && (!audio->read_data)) {
-				MM_DBG("allocate PCM buf %d\n",
-					config.buffer_count *
-					config.buffer_size);
-				handle = ion_alloc(audio->client,
-					(config.buffer_size *
-					config.buffer_count),
-					SZ_4K, ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-				if (IS_ERR_OR_NULL(handle)) {
-					MM_ERR("Unable to alloc I/P buffs\n");
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-					break;
-				}
-
-				audio->input_buff_handle = handle;
-
-				rc = ion_phys(audio->client ,
-					handle, &addr, &len);
-				if (rc) {
-					MM_ERR("Invalid phy: %x sz: %x\n",
-						(unsigned int) addr,
-						(unsigned int) len);
-					ion_free(audio->client, handle);
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-					break;
-				} else {
-					MM_INFO("Got valid phy: %x sz: %x\n",
-						(unsigned int) audio->read_phys,
-						(unsigned int) len);
-				}
-				audio->read_phys = (int32_t)addr;
-
-				rc = ion_handle_get_flags(audio->client,
-					handle, &ionflag);
-				if (rc) {
-					MM_ERR("could not get flags\n");
-					ion_free(audio->client, handle);
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-					break;
-				}
-
-				audio->map_v_read = ion_map_kernel(
-					audio->client, handle);
-				if (IS_ERR(audio->map_v_read)) {
-					MM_ERR("map of read buf failed\n");
-					ion_free(audio->client, handle);
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-				} else {
-					uint8_t index;
-					uint32_t offset = 0;
-					audio->read_data =
-						audio->map_v_read;
-					audio->buf_refresh = 0;
-					audio->pcm_buf_count =
-					    config.buffer_count;
-					audio->read_next = 0;
-					audio->fill_next = 0;
-
-					for (index = 0;
-					     index < config.buffer_count;
-					     index++) {
-						audio->in[index].data =
-						    audio->read_data + offset;
-						audio->in[index].addr =
-						    audio->read_phys + offset;
-						audio->in[index].size =
-						    config.buffer_size;
-						audio->in[index].used = 0;
-						offset += config.buffer_size;
-					}
-					MM_DBG("read buf: phy addr"\
-						" 0x%08x kernel addr 0x%08x\n",
-						audio->read_phys,
-						(int)audio->read_data);
-					rc = 0;
-				}
-			} else {
-				rc = 0;
-			}
-			break;
-		}
-	case AUDIO_PAUSE:
-		MM_DBG("AUDIO_PAUSE %ld\n", arg);
-		rc = audpp_pause(audio->dec_id, (int) arg);
-		break;
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-/* Only useful in tunnel-mode */
-static int audac3_fsync(struct file *file, loff_t a, loff_t b, int datasync)
-{
-	struct audio *audio = file->private_data;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (!audio->running || audio->pcm_feedback) {
-		rc = -EINVAL;
-		goto done_nolock;
-	}
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(!audio->out[0].used &&
-		!audio->out[1].used &&
-		audio->out_needed) || audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		audio->teos || audio->wflush);
-
-	if (audio->wflush)
-		rc = -EBUSY;
-
-done:
-	mutex_unlock(&audio->write_lock);
-done_nolock:
-	return rc;
-}
-
-static ssize_t audac3_read(struct file *file, char __user *buf, size_t count,
-			    loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	int rc = 0;
-	if (!audio->pcm_feedback) {
-		MM_ERR("returning from read as tunnel mode\n");
-		return 0;
-		/* PCM feedback is not enabled. Nothing to read */
-	}
-	mutex_lock(&audio->read_lock);
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	while (count > 0) {
-		rc = wait_event_interruptible(audio->read_wait,
-				(audio->in[audio->read_next].used > 0) ||
-				(audio->stopped) || (audio->rflush));
-
-		MM_DBG("wait terminated count%d\n", count);
-		if (rc < 0)
-			break;
-		if (audio->stopped || audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-		if (count < audio->in[audio->read_next].used) {
-			/* Read must happen in frame boundary. Since driver does
-			 * not know frame size, read count must be greater or
-			 * equal to size of PCM samples
-			 */
-			MM_DBG("read stop - partial frame\n");
-			break;
-		} else {
-			MM_DBG("read from in[%d]\n", audio->read_next);
-			/* order reads from the output buffer */
-			rmb();
-			if (copy_to_user
-			    (buf, audio->in[audio->read_next].data,
-			     audio->in[audio->read_next].used)) {
-				MM_ERR("invalid addr %x\n",
-				       (unsigned int)buf);
-				rc = -EFAULT;
-				break;
-			}
-			count -= audio->in[audio->read_next].used;
-			buf += audio->in[audio->read_next].used;
-			audio->in[audio->read_next].used = 0;
-			if ((++audio->read_next) == audio->pcm_buf_count)
-				audio->read_next = 0;
-			break;
-				/* Force to exit while loop
-				 * to prevent output thread
-				 * sleep too long if data is
-				 * not ready at this moment
-				 */
-
-		}
-	}
-	/* don't feed output buffer to HW decoder during flushing
-	 * buffer refresh command will be sent once flush completes
-	 * send buf refresh command here can confuse HW decoder
-	 */
-	if (audio->buf_refresh && !audio->rflush) {
-		audio->buf_refresh = 0;
-		MM_DBG("kick start pcm feedback again\n");
-		audac3_buffer_refresh(audio);
-	}
-	mutex_unlock(&audio->read_lock);
-	if (buf > start)
-		rc = buf - start;
-	MM_DBG("read %d bytes\n", rc);
-	return rc;
-}
-
-static int audac3_process_eos(struct audio *audio,
-		const char __user *buf_start, unsigned short mfield_size)
-{
-	int rc = 0;
-	struct buffer *frame;
-
-	frame = audio->out + audio->out_head;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	audac3_send_data(audio, 0);
-
-done:
-	return rc;
-}
-
-static ssize_t audac3_write(struct file *file, const char __user *buf,
-			     size_t count, loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	size_t xfer;
-	char *cpy_ptr;
-	unsigned short mfield_size = 0;
-	int rc = 0, eos_condition = AUDAC3_EOS_NONE;
-
-	MM_DBG("cnt=%d\n", count);
-
-	if (count & 1)
-		return -EINVAL;
-
-	mutex_lock(&audio->write_lock);
-	while (count > 0) {
-		frame = audio->out + audio->out_head;
-		cpy_ptr = frame->data;
-		rc = wait_event_interruptible(audio->write_wait,
-					      (frame->used == 0)
-						|| (audio->stopped)
-						|| (audio->wflush));
-		if (rc < 0)
-			break;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (audio->mfield) {
-			if (buf == start) {
-				/* Processing beginning of user buffer */
-				if (__get_user(mfield_size,
-					(unsigned short __user *) buf)) {
-					rc = -EFAULT;
-					break;
-				} else if (mfield_size > count) {
-					rc = -EINVAL;
-					break;
-				}
-				MM_DBG("mf offset_val %x\n", mfield_size);
-				if (copy_from_user(cpy_ptr, buf,
-							mfield_size)) {
-					rc = -EFAULT;
-					break;
-				}
-				/* Check if EOS flag is set and buffer has
-				 * contains just meta field
-				 */
-				if (cpy_ptr[AUDAC3_EOS_FLG_OFFSET] &
-						AUDAC3_EOS_FLG_MASK) {
-					MM_DBG("eos set\n");
-					eos_condition = AUDAC3_EOS_SET;
-					if (mfield_size == count) {
-						buf += mfield_size;
-						break;
-					} else
-					cpy_ptr[AUDAC3_EOS_FLG_OFFSET] &=
-						~AUDAC3_EOS_FLG_MASK;
-				}
-				 /* Check EOS to see if */
-				cpy_ptr += mfield_size;
-				count -= mfield_size;
-				buf += mfield_size;
-			 } else {
-				 mfield_size = 0;
-				 MM_DBG("continuous buffer\n");
-			 }
-			 frame->mfield_sz = mfield_size;
-		}
-
-		xfer = (count > (frame->size - mfield_size)) ?
-			(frame->size - mfield_size) : count;
-		if (copy_from_user(cpy_ptr, buf, xfer)) {
-			rc = -EFAULT;
-			break;
-		}
-		frame->used = xfer + mfield_size;
-		audio->out_head ^= 1;
-		count -= xfer;
-		buf += xfer;
-		audac3_send_data(audio, 0);
-	}
-	if (eos_condition == AUDAC3_EOS_SET)
-		rc = audac3_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	if (!rc) {
-		if (buf > start)
-			return buf - start;
-	}
-	return rc;
-}
-
-static int audac3_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	MM_INFO("audio instance 0x%08x freeing\n", (int)audio);
-	mutex_lock(&audio->lock);
-	audac3_disable(audio);
-	if (audio->rmt_resource_released == 0)
-		rmt_put_resource(audio);
-	audac3_flush(audio);
-	audac3_flush_pcm_buf(audio);
-	msm_adsp_put(audio->audplay);
-	audpp_adec_free(audio->dec_id);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	unregister_early_suspend(&audio->suspend_ctl.node);
-#endif
-	audio->event_abort = 1;
-	wake_up(&audio->event_wait);
-	audac3_reset_event_queue(audio);
-	ion_unmap_kernel(audio->client, audio->output_buff_handle);
-	ion_free(audio->client, audio->output_buff_handle);
-	if (audio->input_buff_handle != NULL) {
-		ion_unmap_kernel(audio->client, audio->input_buff_handle);
-		ion_free(audio->client, audio->input_buff_handle);
-	}
-	ion_client_destroy(audio->client);
-	mutex_unlock(&audio->lock);
-#ifdef CONFIG_DEBUG_FS
-	if (audio->dentry)
-		debugfs_remove(audio->dentry);
-#endif
-	kfree(audio);
-	return 0;
-}
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audac3_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload)
-{
-	struct audac3_event *e_node = NULL;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-
-	if (!list_empty(&audio->free_event_queue)) {
-		e_node = list_first_entry(&audio->free_event_queue,
-				struct audac3_event, list);
-		list_del(&e_node->list);
-	} else {
-		e_node = kmalloc(sizeof(struct audac3_event), GFP_ATOMIC);
-		if (!e_node) {
-			MM_ERR("No mem to post event %d\n", type);
-			spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-			return;
-		}
-	}
-
-	e_node->event_type = type;
-	e_node->payload = payload;
-
-	list_add_tail(&e_node->list, &audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	wake_up(&audio->event_wait);
-}
-
-static void audac3_suspend(struct early_suspend *h)
-{
-	struct audac3_suspend_ctl *ctl =
-		container_of(h, struct audac3_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audac3_post_event(ctl->audio, AUDIO_EVENT_SUSPEND, payload);
-}
-
-static void audac3_resume(struct early_suspend *h)
-{
-	struct audac3_suspend_ctl *ctl =
-		container_of(h, struct audac3_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audac3_post_event(ctl->audio, AUDIO_EVENT_RESUME, payload);
-}
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-static ssize_t audac3_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static ssize_t audac3_debug_read(struct file *file, char __user *buf,
-					size_t count, loff_t *ppos)
-{
-	const int debug_bufmax = 1024;
-	static char buffer[1024];
-	int n = 0, i;
-	struct audio *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	n = scnprintf(buffer, debug_bufmax, "opened %d\n", audio->opened);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"enabled %d\n", audio->enabled);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"stopped %d\n", audio->stopped);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_feedback %d\n", audio->pcm_feedback);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_buf_sz %d\n", audio->out[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_buf_count %d\n", audio->pcm_buf_count);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_buf_sz %d\n", audio->in[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"volume %x\n", audio->vol_pan.volume);
-	mutex_unlock(&audio->lock);
-	/* Following variables are only useful for debugging when
-	 * when playback halts unexpectedly. Thus, no mutual exclusion
-	 * enforced
-	 */
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"wflush %d\n", audio->wflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"rflush %d\n", audio->rflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"running %d\n", audio->running);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"dec state %d\n", audio->dec_state);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_needed %d\n", audio->out_needed);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_head %d\n", audio->out_head);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_tail %d\n", audio->out_tail);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out[0].used %d\n", audio->out[0].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out[1].used %d\n", audio->out[1].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"buffer_refresh %d\n", audio->buf_refresh);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"read_next %d\n", audio->read_next);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"fill_next %d\n", audio->fill_next);
-	for (i = 0; i < audio->pcm_buf_count; i++)
-		n += scnprintf(buffer + n, debug_bufmax - n,
-				"in[%d].size %d\n", i, audio->in[i].used);
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations audac3_debug_fops = {
-	.read = audac3_debug_read,
-	.open = audac3_debug_open,
-};
-#endif
-
-static int audac3_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = NULL;
-	int rc, dec_attrb, decid, i;
-	struct audac3_event *e_node = NULL;
-	int len = 0;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	struct ion_client *client = NULL;
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_ac3_" + 5];
-#endif
-
-	/* Allocate audio instance, set to zero */
-	audio = kzalloc(sizeof(struct audio), GFP_KERNEL);
-	if (!audio) {
-		MM_ERR("no memory to allocate audio instance\n");
-		rc = -ENOMEM;
-		goto done;
-	}
-	MM_INFO("audio instance 0x%08x created\n", (int)audio);
-
-	/* Allocate the decoder */
-	dec_attrb = AUDDEC_DEC_AC3;
-	if ((file->f_mode & FMODE_WRITE) &&
-			(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_NONTUNNEL;
-		audio->pcm_feedback = NON_TUNNEL_MODE_PLAYBACK;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_TUNNEL;
-		audio->pcm_feedback = TUNNEL_MODE_PLAYBACK;
-	} else {
-		kfree(audio);
-		rc = -EACCES;
-		goto done;
-	}
-	decid = audpp_adec_alloc(dec_attrb, &audio->module_name,
-			&audio->queue_id);
-
-	if (decid < 0) {
-		MM_ERR("No free decoder available, freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENODEV;
-		kfree(audio);
-		goto done;
-	}
-
-	audio->dec_id = decid & MSM_AUD_DECODER_MASK;
-
-	client = msm_ion_client_create(UINT_MAX, "Audio_AC3_client");
-	if (IS_ERR_OR_NULL(client)) {
-		MM_ERR("Unable to create ION client\n");
-		rc = -ENOMEM;
-		goto client_create_error;
-	}
-	audio->client = client;
-
-	handle = ion_alloc(client, DMASZ, SZ_4K,
-			ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-	if (IS_ERR_OR_NULL(handle)) {
-		MM_ERR("Unable to create allocate O/P buffers\n");
-		rc = -ENOMEM;
-		goto output_buff_alloc_error;
-	}
-
-	audio->output_buff_handle = handle;
-
-	rc = ion_phys(client, handle, &addr, &len);
-	if (rc) {
-		MM_ERR("O/P buffers:Invalid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-		goto output_buff_get_phys_error;
-	} else {
-		MM_INFO("O/P buffers:valid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-	}
-	audio->phys = (int32_t)addr;
-
-	rc = ion_handle_get_flags(client, handle, &ionflag);
-	if (rc) {
-		MM_ERR("could not get flags for the handle\n");
-		goto output_buff_get_flags_error;
-	}
-
-	audio->map_v_write = ion_map_kernel(client, handle);
-	if (IS_ERR(audio->map_v_write)) {
-		MM_ERR("could not map write buffers,freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENOMEM;
-		goto output_buff_map_error;
-	}
-	audio->data = audio->map_v_write;
-	MM_DBG("write buf: phy addr 0x%08x kernel addr 0x%08x\n",
-		audio->phys, (int)audio->data);
-
-	rc = msm_adsp_get(audio->module_name, &audio->audplay,
-			&audplay_adsp_ops_ac3, audio);
-	if (rc) {
-		MM_ERR("failed to get %s module, freeing instance 0x%08x\n",
-				audio->module_name, (int)audio);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_close(&audio->audmgr);
-		goto err;
-	}
-
-	rc = rmt_get_resource(audio);
-	if (rc) {
-		MM_ERR("ADSP resources are not available for AC3 session"\
-			" 0x%08x on decoder: %d\n", (int)audio, audio->dec_id);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_close(&audio->audmgr);
-		msm_adsp_put(audio->audplay);
-		goto err;
-	}
-
-	/* Initialize all locks of audio instance */
-	audio->input_buff_handle = NULL;
-	mutex_init(&audio->lock);
-	mutex_init(&audio->write_lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->get_event_lock);
-	spin_lock_init(&audio->dsp_lock);
-	init_waitqueue_head(&audio->write_wait);
-	init_waitqueue_head(&audio->read_wait);
-	INIT_LIST_HEAD(&audio->free_event_queue);
-	INIT_LIST_HEAD(&audio->event_queue);
-	init_waitqueue_head(&audio->wait);
-	init_waitqueue_head(&audio->event_wait);
-	spin_lock_init(&audio->event_queue_lock);
-
-	audio->out[0].data = audio->data + 0;
-	audio->out[0].addr = audio->phys + 0;
-	audio->out[0].size = BUFSZ;
-
-	audio->out[1].data = audio->data + BUFSZ;
-	audio->out[1].addr = audio->phys + BUFSZ;
-	audio->out[1].size = BUFSZ;
-
-	audio->vol_pan.volume = 0x3FFF;
-
-	(audio->ac3_config).wordSize = AUDAC3_DEF_WORDSIZE;
-	(audio->ac3_config).user_downmix_flag = AUDAC3_DEF_USER_DOWNMIX_FLAG;
-	(audio->ac3_config).user_karaoke_flag = AUDAC3_DEF_USER_KARAOKE_FLAG;
-	(audio->ac3_config).error_concealment = AUDAC3_DEF_ERROR_CONCEALMENT;
-	(audio->ac3_config).max_rep_count = AUDAC3_DEF_MAX_REPEAT_COUNT;
-
-	audac3_flush(audio);
-
-	file->private_data = audio;
-	audio->opened = 1;
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof name, "msm_ac3_%04x", audio->dec_id);
-	audio->dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
-			NULL, (void *) audio, &audac3_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		MM_DBG("debugfs_create_file failed\n");
-#endif
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	audio->suspend_ctl.node.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
-	audio->suspend_ctl.node.resume = audac3_resume;
-	audio->suspend_ctl.node.suspend = audac3_suspend;
-	audio->suspend_ctl.audio = audio;
-	register_early_suspend(&audio->suspend_ctl.node);
-#endif
-	for (i = 0; i < AUDAC3_EVENT_NUM; i++) {
-		e_node = kmalloc(sizeof(struct audac3_event), GFP_KERNEL);
-		if (e_node)
-			list_add_tail(&e_node->list, &audio->free_event_queue);
-		else {
-			MM_ERR("event pkt alloc failed\n");
-			break;
-		}
-	}
-done:
-	return rc;
-err:
-	ion_unmap_kernel(client, audio->output_buff_handle);
-output_buff_map_error:
-output_buff_get_flags_error:
-output_buff_get_phys_error:
-	ion_free(client, audio->output_buff_handle);
-output_buff_alloc_error:
-	ion_client_destroy(client);
-client_create_error:
-	audpp_adec_free(audio->dec_id);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_ac3_fops = {
-	.owner = THIS_MODULE,
-	.open = audac3_open,
-	.release = audac3_release,
-	.read = audac3_read,
-	.write = audac3_write,
-	.unlocked_ioctl = audac3_ioctl,
-	.fsync = audac3_fsync,
-};
-
-struct miscdevice audio_ac3_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_ac3",
-	.fops = &audio_ac3_fops,
-};
-
-static int __init audac3_init(void)
-{
-	return misc_register(&audio_ac3_misc);
-
-}
-
-static void __exit audac3_exit(void)
-{
-	misc_deregister(&audio_ac3_misc);
-}
-
-module_init(audac3_init);
-module_exit(audac3_exit);
-
-MODULE_DESCRIPTION("MSM AC3 driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5/audio_acdb.c b/arch/arm/mach-msm/qdsp5/audio_acdb.c
deleted file mode 100644
index 608f544..0000000
--- a/arch/arm/mach-msm/qdsp5/audio_acdb.c
+++ /dev/null
@@ -1,2704 +0,0 @@
-/* Copyright (c) 2012-2013, The Linux Foundation. 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.
- *
- */
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/mutex.h>
-#include <linux/io.h>
-#include <linux/delay.h>
-#include <linux/dma-mapping.h>
-#include <linux/uaccess.h>
-#include <linux/msm_audio.h>
-#include <linux/slab.h>
-#include <linux/debugfs.h>
-#include <linux/memory_alloc.h>
-#include <linux/mfd/marimba.h>
-#include <mach/dal.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/socinfo.h>
-#include <mach/qdsp5/qdsp5audpp.h>
-#include <mach/qdsp5/qdsp5audpreproc.h>
-#include <mach/qdsp5/qdsp5audppcmdi.h>
-#include <mach/qdsp5/qdsp5audpreproccmdi.h>
-#include <mach/qdsp5/qdsp5audpreprocmsg.h>
-#include <mach/qdsp5/qdsp5audppmsg.h>
-#include <mach/qdsp5/audio_acdbi.h>
-#include <mach/qdsp5/acdb_commands.h>
-#include <mach/qdsp5/audio_acdb_def.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_memtypes.h>
-
-#include "audmgr.h"
-
-/* this is the ACDB device ID */
-#define DALDEVICEID_ACDB		0x02000069
-#define ACDB_PORT_NAME			"DAL00"
-#define ACDB_CPU			SMD_APPS_MODEM
-#define ACDB_BUF_SIZE			4096
-#define FLUENCE_BUF_SIZE	498
-
-#define ACDB_VALUES_NOT_FILLED		0
-#define ACDB_VALUES_FILLED		1
-#define MAX_RETRY			10
-
-#define COMMON_OBJ_ID                   6
-
-/*below macro is used to align the session info received from
-Devctl driver with the state mentioned as not to alter the
-Existing code*/
-#define AUDREC_OFFSET	2
-/* rpc table index */
-enum {
-	ACDB_DAL_IOCTL = DALDEVICE_FIRST_DEVICE_API_IDX
-};
-
-enum {
-	CAL_DATA_READY	= 0x1,
-	AUDPP_READY	= 0x2,
-	AUDREC_READY	= 0x4,
-};
-
-struct acdb_data {
-	void *handle;
-
-	u32 phys_addr;
-	u8 *virt_addr;
-
-	struct task_struct *cb_thread_task;
-	struct device_info_callback dev_cb;
-
-	u32 acdb_state;
-	struct audpp_event_callback audpp_cb;
-	struct audpreproc_event_callback audpreproc_cb;
-	struct dev_evt_msg *device_info;
-
-	audpp_cmd_cfg_object_params_pcm *pp_iir;
-	audpp_cmd_cfg_object_params_mbadrc *pp_mbadrc;
-	audpreproc_cmd_cfg_agc_params *preproc_agc;
-	audpreproc_cmd_cfg_iir_tuning_filter_params *preproc_iir;
-	audpreproc_cmd_cfg_ns_params *preproc_ns;
-	struct acdb_mbadrc_block mbadrc_block;
-
-	wait_queue_head_t wait;
-	struct mutex acdb_mutex;
-	u32 device_cb_compl;
-	u32 audpp_cb_compl;
-	u32 preproc_cb_compl;
-	u32 audpp_cb_reenable_compl;
-	u8 preproc_stream_id;
-	u8 audrec_applied;
-	u32 multiple_sessions;
-	u32 cur_tx_session;
-	struct acdb_result acdb_result;
-	uint32_t audpp_disabled_features;
-
-	spinlock_t dsp_lock;
-	int dec_id;
-	audpp_cmd_cfg_object_params_eqalizer eq;
-	struct audrec_session_info session_info;
-	/*pmem info*/
-	unsigned long paddr;
-	unsigned long kvaddr;
-	unsigned long pmem_len;
-	struct file *file;
-	/* pmem for get acdb blk */
-	unsigned long	get_blk_paddr;
-	u8		*get_blk_kvaddr;
-	void *map_v_get_blk;
-};
-
-static struct acdb_data		acdb_data;
-
-struct acdb_cache_node {
-	u32 node_status;
-	s32 stream_id;
-	u32 phys_addr_acdb_values;
-	void *map_v_addr;
-	u8 *virt_addr_acdb_values;
-	struct dev_evt_msg device_info;
-};
-
-struct acdb_cache_node acdb_cache_rx;
-
-/*for TX devices acdb values are applied based on AUDREC session and
-the depth of the tx cache is define by number of AUDREC sessions supported*/
-struct acdb_cache_node acdb_cache_tx;
-
-/*Audrec session info includes Attributes Sampling frequency and enc_id */
-struct audrec_session_info session_info;
-#ifdef CONFIG_DEBUG_FS
-
-#define RTC_MAX_TIMEOUT 500 /* 500 ms */
-#define PMEM_RTC_ACDB_QUERY_MEM 4096
-#define EXTRACT_HIGH_WORD(x) ((x & 0xFFFF0000)>>16)
-#define EXTRACT_LOW_WORD(x) (0x0000FFFF & x)
-#define	ACDB_RTC_TX 0xF1
-#define	ACDB_RTC_RX 0x1F
-
-
-static u32 acdb_audpp_entry[][4] = {
-
-	{
-	ABID_AUDIO_RTC_VOLUME_PAN_RX,\
-	IID_AUDIO_RTC_VOLUME_PAN_PARAMETERS,\
-	AUDPP_CMD_VOLUME_PAN,\
-	ACDB_RTC_RX
-	},
-	{
-	ABID_AUDIO_IIR_RX,\
-	IID_AUDIO_IIR_COEFF,\
-	AUDPP_CMD_IIR_TUNING_FILTER,
-	ACDB_RTC_RX
-	},
-	{
-	ABID_AUDIO_RTC_EQUALIZER_PARAMETERS,\
-	IID_AUDIO_RTC_EQUALIZER_PARAMETERS,\
-	AUDPP_CMD_EQUALIZER,\
-	ACDB_RTC_RX
-	},
-	{
-	ABID_AUDIO_RTC_SPA,\
-	IID_AUDIO_RTC_SPA_PARAMETERS,\
-	AUDPP_CMD_SPECTROGRAM,
-	ACDB_RTC_RX
-	},
-	{
-	ABID_AUDIO_STF_RX,\
-	IID_AUDIO_IIR_COEFF,\
-	AUDPP_CMD_SIDECHAIN_TUNING_FILTER,\
-	ACDB_RTC_RX
-	},
-	{
-	ABID_AUDIO_MBADRC_RX,\
-	IID_AUDIO_RTC_MBADRC_PARAMETERS,\
-	AUDPP_CMD_MBADRC,\
-	ACDB_RTC_RX
-	},
-	{
-	ABID_AUDIO_AGC_TX,\
-	IID_AUDIO_AGC_PARAMETERS,\
-	AUDPREPROC_CMD_CFG_AGC_PARAMS,\
-	ACDB_RTC_TX
-	},
-	{
-	ABID_AUDIO_AGC_TX,\
-	IID_AUDIO_RTC_AGC_PARAMETERS,\
-	AUDPREPROC_CMD_CFG_AGC_PARAMS,\
-	ACDB_RTC_TX
-	},
-	{
-	ABID_AUDIO_NS_TX,\
-	IID_NS_PARAMETERS,\
-	AUDPREPROC_CMD_CFG_NS_PARAMS,\
-	ACDB_RTC_TX
-	},
-	{
-	ABID_AUDIO_IIR_TX,\
-	IID_AUDIO_RTC_TX_IIR_COEFF,\
-	AUDPREPROC_CMD_CFG_IIR_TUNING_FILTER_PARAMS,\
-	ACDB_RTC_TX
-	},
-	{
-	ABID_AUDIO_IIR_TX,\
-	IID_AUDIO_IIR_COEFF,\
-	AUDPREPROC_CMD_CFG_IIR_TUNING_FILTER_PARAMS,\
-	ACDB_RTC_TX
-	}
- /*Any new entries should be added here*/
-};
-
-static struct dentry *get_set_abid_dentry;
-static struct dentry *get_set_abid_data_dentry;
-
-struct rtc_acdb_pmem {
-	u8 *viraddr;
-	int32_t phys;
-	void *map_v_rtc;
-};
-
-struct rtc_acdb_data {
-	u32 acdb_id;
-	u32 cmd_id;
-	u32 set_abid;
-	u32 set_iid;
-	u32 abid;
-	u32 err;
-	bool valid_abid;
-	u32 tx_rx_ctl;
-	struct rtc_acdb_pmem rtc_read;
-	struct rtc_acdb_pmem rtc_write;
-	wait_queue_head_t  wait;
-};
-
-struct get_abid {
-	u32	cmd_id;
-	u32	acdb_id;
-	u32	set_abid;
-	u32	set_iid;
-};
-
-struct acdb_block_mbadrc_rtc {
-	u16 enable;
-	u16 num_bands;
-	u16 down_samp_level;
-	u16 adrc_delay;
-	u16 ext_buf_size;
-	u16 ext_partition;
-	u16 ext_buf_msw;
-	u16 ext_buf_lsw;
-	struct adrc_config adrc_band[AUDPP_MAX_MBADRC_BANDS];
-	signed int ext_buff[196];
-} __packed;
-
-enum {
-	ACDB_RTC_SUCCESS,
-	ACDB_RTC_ERR_INVALID_DEVICE,
-	ACDB_RTC_ERR_DEVICE_INACTIVE,
-	ACDB_RTC_ERR_INVALID_ABID,
-	ACDB_RTC_DSP_FAILURE,
-	ACDB_RTC_DSP_FEATURE_NOT_AVAILABLE,
-	ACDB_RTC_ERR_INVALID_LEN,
-	ACDB_RTC_ERR_UNKNOWN_FAILURE,
-	ACDB_RTC_PENDING_RESPONSE,
-	ACDB_RTC_INIT_FAILURE,
-};
-
-static  struct rtc_acdb_data rtc_acdb;
-
-static int rtc_getsetabid_dbg_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	MM_DBG("GET-SET ABID Open debug intf %s\n",\
-			(char *) file->private_data);
-	return 0;
-}
-
-static bool get_feature_id(u32 set_abid, u32 iid, unsigned short *feature_id)
-{
-	bool ret_value = false;
-	int i = 0;
-
-	for (; i < (sizeof(acdb_audpp_entry) / sizeof(acdb_audpp_entry[0]));\
-		i++) {
-		if (acdb_audpp_entry[i][0] == set_abid &&
-			acdb_audpp_entry[i][1] == iid) {
-			*feature_id =  acdb_audpp_entry[i][2];
-			rtc_acdb.tx_rx_ctl = acdb_audpp_entry[i][3];
-			ret_value = true;
-			break;
-		}
-	}
-	return ret_value;
-}
-static ssize_t rtc_getsetabid_dbg_write(struct file *filp,
-					const char __user *ubuf,
-					size_t cnt, loff_t *ppos)
-{
-	struct  get_abid write_abid;
-	unsigned short feat_id = 0;
-	rtc_acdb.valid_abid = false;
-
-	if (copy_from_user(&write_abid, \
-		(void *)ubuf, sizeof(struct get_abid))) {
-		MM_ERR("ACDB DATA WRITE - INVALID READ LEN\n");
-		rtc_acdb.err = ACDB_RTC_ERR_INVALID_LEN;
-		return cnt;
-	}
-	MM_DBG("SET ABID : Cmd ID: %d Device:%d ABID:%d IID : %d cnt: %d\n",\
-		write_abid.cmd_id, write_abid.acdb_id,\
-		write_abid.set_abid, write_abid.set_iid, cnt);
-	if (write_abid.acdb_id > ACDB_ID_MAX ||
-		write_abid.acdb_id < ACDB_ID_HANDSET_SPKR){
-		rtc_acdb.err = ACDB_RTC_ERR_INVALID_DEVICE;
-		return cnt;
-	}
-
-	rtc_acdb.err = ACDB_RTC_ERR_INVALID_ABID;
-	rtc_acdb.abid = write_abid.set_abid;
-	if (get_feature_id(write_abid.set_abid, \
-		write_abid.set_iid, &feat_id)) {
-		rtc_acdb.err = ACDB_RTC_SUCCESS;
-		rtc_acdb.cmd_id = write_abid.cmd_id;
-		rtc_acdb.acdb_id = write_abid.acdb_id;
-		rtc_acdb.set_abid = feat_id;
-		rtc_acdb.valid_abid = true;
-		rtc_acdb.set_iid = write_abid.set_iid;
-	}
-	return cnt;
-}
-static ssize_t	rtc_getsetabid_dbg_read(struct file *file, char __user *buf,
-					size_t count, loff_t *ppos)
-{
-	static char buffer[1024];
-	int n = 0;
-	u32 msg = rtc_acdb.err;
-	memcpy(buffer, &rtc_acdb.cmd_id, sizeof(struct get_abid));
-	memcpy(buffer+16, &msg, 4);
-	n = 20;
-	MM_INFO("SET ABID : Cmd ID: %x Device:%x ABID:%x IID : %x Err: %d\n",\
-		rtc_acdb.cmd_id, rtc_acdb.acdb_id, rtc_acdb.set_abid,\
-		rtc_acdb.set_iid, rtc_acdb.err);
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static int rtc_getsetabid_data_dbg_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	MM_INFO("GET-SET ABID DATA Open debug intf %s\n",
-		(char *) file->private_data);
-	return 0;
-}
-
-void acdb_rtc_set_err(u32 err_code)
-{
-	if (rtc_acdb.err == ACDB_RTC_PENDING_RESPONSE) {
-		if (err_code == 0xFFFF) {
-			rtc_acdb.err = ACDB_RTC_SUCCESS;
-			MM_INFO("RTC READ SUCCESS---\n");
-		} else if (err_code == 0) {
-			rtc_acdb.err = ACDB_RTC_DSP_FAILURE;
-			MM_INFO("RTC READ FAIL---\n");
-		} else if (err_code == 1) {
-			rtc_acdb.err = ACDB_RTC_DSP_FEATURE_NOT_AVAILABLE;
-			MM_INFO("RTC READ FEAT UNAVAILABLE---\n");
-		} else {
-			rtc_acdb.err = ACDB_RTC_DSP_FAILURE;
-			MM_INFO("RTC Err CODE---\n");
-		}
-	} else {
-		rtc_acdb.err = ACDB_RTC_DSP_FAILURE;
-		MM_ERR("RTC Err code Invalid State\n");
-	}
-	wake_up(&rtc_acdb.wait);
-}
-
-static ssize_t	rtc_getsetabid_data_dbg_read(struct file *file,
-					char __user *buf, size_t count,
-					loff_t *ppos)
-{
-	static char buffer[PMEM_RTC_ACDB_QUERY_MEM];
-	int rc, n = 0;
-	int counter = 0;
-	struct rtc_acdb_pmem *rtc_read = &rtc_acdb.rtc_read;
-	memset(&buffer, 0, PMEM_RTC_ACDB_QUERY_MEM);
-
-	if (rtc_acdb.valid_abid != true) {
-		MM_ERR("ACDB DATA READ ---INVALID ABID\n");
-		n = 0;
-		rtc_acdb.err = ACDB_RTC_ERR_INVALID_ABID;
-	} else {
-		if (PMEM_RTC_ACDB_QUERY_MEM < count) {
-			MM_ERR("ACDB DATA READ ---"\
-				"INVALID READ LEN %x\n", count);
-			n = 0;
-			rtc_acdb.err = ACDB_RTC_ERR_INVALID_LEN;
-		} else {
-			rtc_acdb.err = ACDB_RTC_PENDING_RESPONSE;
-			if (rtc_read->viraddr != NULL) {
-				memset(rtc_read->viraddr,
-					0, PMEM_RTC_ACDB_QUERY_MEM);
-			}
-			if (rtc_acdb.tx_rx_ctl == ACDB_RTC_RX) {
-				struct rtc_audpp_read_data rtc_read_cmd;
-				rtc_read_cmd.cmd_id =
-					AUDPP_CMD_PP_FEAT_QUERY_PARAMS;
-				rtc_read_cmd.obj_id =
-					AUDPP_CMD_COPP_STREAM;
-				rtc_read_cmd.feature_id = rtc_acdb.set_abid;
-				rtc_read_cmd.extbufsizemsw =
-					EXTRACT_HIGH_WORD(\
-						PMEM_RTC_ACDB_QUERY_MEM);
-				rtc_read_cmd.extbufsizelsw =
-					EXTRACT_LOW_WORD(\
-						PMEM_RTC_ACDB_QUERY_MEM);
-				rtc_read_cmd.extpart = 0x0000;
-				rtc_read_cmd.extbufstartmsw =
-					EXTRACT_HIGH_WORD(rtc_read->phys);
-				rtc_read_cmd.extbufstartlsw =
-					EXTRACT_LOW_WORD(rtc_read->phys);
-				rc = audpp_send_queue2(&rtc_read_cmd,
-						sizeof(rtc_read_cmd));
-			} else if (rtc_acdb.tx_rx_ctl == ACDB_RTC_TX) {
-				struct rtc_audpreproc_read_data rtc_audpreproc;
-				rtc_audpreproc.cmd_id =
-					AUDPREPROC_CMD_FEAT_QUERY_PARAMS;
-				rtc_audpreproc.feature_id = rtc_acdb.set_abid;
-				 /*AUDREC1 is used for pcm recording */
-				rtc_audpreproc.stream_id = 1;
-				rtc_audpreproc.extbufsizemsw =
-					EXTRACT_HIGH_WORD(\
-						PMEM_RTC_ACDB_QUERY_MEM);
-				rtc_audpreproc.extbufsizelsw =
-					EXTRACT_LOW_WORD(\
-						PMEM_RTC_ACDB_QUERY_MEM);
-				rtc_audpreproc.extpart = 0x0000;
-				rtc_audpreproc.extbufstartmsw =
-					EXTRACT_HIGH_WORD(rtc_read->phys);
-				rtc_audpreproc.extbufstartlsw =
-					EXTRACT_LOW_WORD(rtc_read->phys);
-				rc =  audpreproc_send_preproccmdqueue(
-						&rtc_audpreproc,\
-						sizeof(rtc_audpreproc));
-				MM_INFO("ACDB READ Command RC --->%x,"\
-					"stream_id %x\n", rc,
-					acdb_data.preproc_stream_id);
-			}
-		rc = wait_event_timeout(rtc_acdb.wait,
-					(rtc_acdb.err !=
-					ACDB_RTC_PENDING_RESPONSE),
-					msecs_to_jiffies(RTC_MAX_TIMEOUT));
-		MM_INFO("ACDB READ ACK Count = %x Err = %x\n",
-			count, rtc_acdb.err);
-		{
-			if (rtc_acdb.err == ACDB_RTC_SUCCESS
-				&& rtc_read->viraddr != NULL) {
-				memcpy(buffer, rtc_read->viraddr, count);
-				n = count;
-				while (counter < count) {
-					MM_DBG("%x", \
-						rtc_read->viraddr[counter]);
-					counter++;
-					}
-				}
-		}
-	}
-	}
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static bool acdb_set_tx_rtc(const char *ubuf, size_t writecount)
-{
-	audpreproc_cmd_cfg_iir_tuning_filter_params *preproc_iir;
-	audpreproc_cmd_cfg_agc_params *preproc_agc;
-	audpreproc_cmd_cfg_ns_params *preproc_ns;
-	s32	result = 0;
-	bool retval = false;
-	unsigned short iircmdsize =
-		sizeof(audpreproc_cmd_cfg_iir_tuning_filter_params);
-	unsigned short iircmdid = AUDPREPROC_CMD_CFG_IIR_TUNING_FILTER_PARAMS;
-
-	rtc_acdb.err = ACDB_RTC_ERR_UNKNOWN_FAILURE;
-
-	switch (rtc_acdb.set_abid) {
-
-	case AUDPREPROC_CMD_CFG_AGC_PARAMS:
-	{
-		preproc_agc = kmalloc(sizeof(\
-					audpreproc_cmd_cfg_agc_params),\
-					GFP_KERNEL);
-		if ((sizeof(audpreproc_cmd_cfg_agc_params) -\
-			(sizeof(unsigned short)))
-			< writecount) {
-				MM_ERR("ACDB DATA WRITE --"\
-					"AGC TX writecount > DSP struct\n");
-		} else {
-			if (preproc_agc != NULL) {
-				char *base; unsigned short offset;
-				unsigned short *offset_addr;
-				base = (char *)preproc_agc;
-				offset = offsetof(\
-					audpreproc_cmd_cfg_agc_params,\
-						tx_agc_param_mask);
-				offset_addr = (unsigned short *)(base + offset);
-				if ((copy_from_user(offset_addr,\
-					(void *)ubuf, writecount)) == 0x00) {
-					preproc_agc->cmd_id =
-						AUDPREPROC_CMD_CFG_AGC_PARAMS;
-
-					result = audpreproc_dsp_set_agc(
-						preproc_agc,
-						sizeof(\
-						audpreproc_cmd_cfg_agc_params));
-					if (result) {
-						MM_ERR("ACDB=> Failed to "\
-							"send AGC data to "\
-							"preproc)\n");
-					} else {
-						retval = true;
-					       }
-				} else {
-					MM_ERR("ACDB DATA WRITE ---"\
-						"GC Tx copy_from_user Fail\n");
-				}
-			} else {
-				MM_ERR("ACDB DATA WRITE --"\
-					"AGC TX kalloc Failed LEN\n");
-			}
-		}
-		if (preproc_agc != NULL)
-			kfree(preproc_agc);
-		break;
-	}
-	case AUDPREPROC_CMD_CFG_NS_PARAMS:
-	{
-
-		preproc_ns = kmalloc(sizeof(\
-					audpreproc_cmd_cfg_ns_params),\
-					GFP_KERNEL);
-		if ((sizeof(audpreproc_cmd_cfg_ns_params) -\
-				(sizeof(unsigned short)))
-				< writecount) {
-				MM_ERR("ACDB DATA WRITE --"\
-					"NS TX writecount > DSP struct\n");
-		} else {
-			if (preproc_ns != NULL) {
-				char *base; unsigned short offset;
-				unsigned short *offset_addr;
-				base = (char *)preproc_ns;
-				offset = offsetof(\
-						audpreproc_cmd_cfg_ns_params,\
-						ec_mode_new);
-				offset_addr = (unsigned short *)(base + offset);
-				if ((copy_from_user(offset_addr,\
-					(void *)ubuf, writecount)) == 0x00) {
-					preproc_ns->cmd_id =
-						AUDPREPROC_CMD_CFG_NS_PARAMS;
-					result = audpreproc_dsp_set_ns(
-						preproc_ns,
-						sizeof(\
-						audpreproc_cmd_cfg_ns_params));
-					if (result) {
-						MM_ERR("ACDB=> Failed to send "\
-							"NS data to preproc\n");
-					} else {
-						retval = true;
-					}
-				} else {
-					MM_ERR("ACDB DATA WRITE ---NS Tx "\
-						"copy_from_user Fail\n");
-					}
-			} else {
-				MM_ERR("ACDB DATA WRITE --NS TX "\
-					"kalloc Failed LEN\n");
-			}
-		}
-		if (preproc_ns != NULL)
-			kfree(preproc_ns);
-		break;
-	}
-	case AUDPREPROC_CMD_CFG_IIR_TUNING_FILTER_PARAMS:
-	{
-
-		preproc_iir = kmalloc(sizeof(\
-				audpreproc_cmd_cfg_iir_tuning_filter_params),\
-				GFP_KERNEL);
-		if ((sizeof(\
-			audpreproc_cmd_cfg_iir_tuning_filter_params)-\
-			(sizeof(unsigned short)))
-			< writecount) {
-			MM_ERR("ACDB DATA WRITE --IIR TX writecount "\
-						"> DSP struct\n");
-		} else {
-			if (preproc_iir != NULL) {
-				char *base; unsigned short offset;
-				unsigned short *offset_addr;
-				base = (char *)preproc_iir;
-				offset = offsetof(\
-				audpreproc_cmd_cfg_iir_tuning_filter_params,\
-				active_flag);
-				offset_addr = (unsigned short *)(base + \
-						offset);
-				if ((copy_from_user(offset_addr,\
-					(void *)ubuf, writecount)) == 0x00) {
-					preproc_iir->cmd_id = iircmdid;
-					result = audpreproc_dsp_set_iir(\
-							preproc_iir,
-							iircmdsize);
-					if (result) {
-						MM_ERR("ACDB=> Failed to send "\
-						"IIR data to preproc\n");
-					} else {
-						retval = true;
-					}
-				} else {
-					MM_ERR("ACDB DATA WRITE ---IIR Tx "\
-						"copy_from_user Fail\n");
-				}
-			} else {
-				MM_ERR("ACDB DATA WRITE --IIR TX kalloc "\
-					"Failed LEN\n");
-		     }
-		}
-		if (preproc_iir != NULL)
-			kfree(preproc_iir);
-		break;
-	}
-	}
-	return retval;
-}
-
-static bool acdb_set_rx_rtc(const char *ubuf, size_t writecount)
-{
-
-	audpp_cmd_cfg_object_params_volume *volpan_config;
-	audpp_cmd_cfg_object_params_mbadrc *mbadrc_config;
-	struct acdb_block_mbadrc_rtc *acdb_mbadrc_rtc;
-	audpp_cmd_cfg_object_params_eqalizer *eq_config;
-	audpp_cmd_cfg_object_params_pcm *iir_config;
-	struct rtc_acdb_pmem *rtc_write = &rtc_acdb.rtc_write;
-	s32	result = 0;
-	bool retval = false;
-
-	switch (rtc_acdb.set_abid) {
-	case AUDPP_CMD_VOLUME_PAN:
-	{
-		volpan_config =  kmalloc(sizeof(\
-					 audpp_cmd_cfg_object_params_volume),\
-					 GFP_KERNEL);
-		if ((sizeof(audpp_cmd_cfg_object_params_volume) -\
-			sizeof(audpp_cmd_cfg_object_params_common))
-			< writecount) {
-			MM_ERR("ACDB DATA WRITE -- "\
-				"VolPan writecount > DSP struct\n");
-		} else {
-			if (volpan_config != NULL) {
-				char *base; unsigned short offset;
-				unsigned short *offset_addr;
-				base = (char *)volpan_config;
-				offset = offsetof(\
-					audpp_cmd_cfg_object_params_volume,\
-					volume);
-				offset_addr = (unsigned short *)(base+offset);
-				if ((copy_from_user(offset_addr,\
-					(void *)ubuf, writecount)) == 0x00) {
-					MM_ERR("ACDB RX WRITE DATA: "\
-						"AUDPP_CMD_VOLUME_PAN\n");
-					result = audpp_set_volume_and_pan(
-						COMMON_OBJ_ID,
-						volpan_config->volume,
-						volpan_config->pan);
-					if (result) {
-						MM_ERR("ACDB=> Failed to "\
-							"send VOLPAN data to"
-							" postproc\n");
-					} else {
-						retval = true;
-					}
-				} else {
-					MM_ERR("ACDB DATA WRITE ---"\
-						"copy_from_user Fail\n");
-				}
-			} else {
-				MM_ERR("ACDB DATA WRITE --"\
-					"Vol Pan kalloc Failed LEN\n");
-			}
-		}
-	if (volpan_config != NULL)
-		kfree(volpan_config);
-	break;
-	}
-
-	case AUDPP_CMD_IIR_TUNING_FILTER:
-	{
-		iir_config =  kmalloc(sizeof(\
-				audpp_cmd_cfg_object_params_pcm),\
-				GFP_KERNEL);
-		if ((sizeof(audpp_cmd_cfg_object_params_pcm) -\
-			sizeof(audpp_cmd_cfg_object_params_common))
-			< writecount) {
-			MM_ERR("ACDB DATA WRITE --"\
-					"IIR RX writecount > DSP struct\n");
-		} else {
-			if (iir_config != NULL) {
-				char *base; unsigned short offset;
-				unsigned short *offset_addr;
-				base = (char *)iir_config;
-				offset = offsetof(\
-					audpp_cmd_cfg_object_params_pcm,\
-					active_flag);
-				offset_addr = (unsigned short *)(base+offset);
-				if ((copy_from_user(offset_addr,\
-					(void *)ubuf, writecount)) == 0x00) {
-					MM_ERR("ACDB RX WRITE DATA:"\
-					"AUDPP_CMD_IIR_TUNING_FILTER\n");
-					result = audpp_dsp_set_rx_iir(
-						COMMON_OBJ_ID,
-						iir_config->active_flag,\
-						iir_config);
-					if (result) {
-						MM_ERR("ACDB=> Failed to send"\
-							"IIR data to"\
-							"postproc\n");
-					} else {
-						retval = true;
-					}
-				} else {
-					MM_ERR("ACDB DATA WRITE ---"\
-						"IIR Rx copy_from_user Fail\n");
-				      }
-			 } else {
-				MM_ERR("ACDB DATA WRITE --"\
-					"acdb_iir_block kalloc Failed LEN\n");
-			}
-		}
-		if (iir_config != NULL)
-			kfree(iir_config);
-		break;
-	}
-	case AUDPP_CMD_EQUALIZER:
-	{
-		eq_config =  kmalloc(sizeof(\
-				audpp_cmd_cfg_object_params_eqalizer),\
-				GFP_KERNEL);
-	if ((sizeof(audpp_cmd_cfg_object_params_eqalizer) -\
-			sizeof(audpp_cmd_cfg_object_params_common))
-			< writecount) {
-			MM_ERR("ACDB DATA WRITE --"\
-			"EQ RX writecount > DSP struct\n");
-		} else {
-			if (eq_config != NULL) {
-				char *base; unsigned short offset;
-				unsigned short *offset_addr;
-				base = (char *)eq_config;
-				offset = offsetof(\
-					audpp_cmd_cfg_object_params_eqalizer,\
-					eq_flag);
-				offset_addr = (unsigned short *)(base+offset);
-				if ((copy_from_user(offset_addr,\
-					(void *)ubuf, writecount)) == 0x00) {
-					MM_ERR("ACDB RX WRITE"\
-					"DATA:AUDPP_CMD_EQUALIZER\n");
-					result = audpp_dsp_set_eq(
-						COMMON_OBJ_ID,
-						eq_config->eq_flag,\
-						eq_config);
-					if (result) {
-						MM_ERR("ACDB=> Failed to "\
-						"send EQ data to postproc\n");
-					} else {
-						retval = true;
-					}
-				} else {
-					MM_ERR("ACDB DATA WRITE ---"\
-					"EQ Rx copy_from_user Fail\n");
-				}
-			} else {
-				MM_ERR("ACDB DATA WRITE --"\
-					"EQ kalloc Failed LEN\n");
-			}
-		}
-		if (eq_config != NULL)
-			kfree(eq_config);
-		break;
-	}
-
-	case AUDPP_CMD_MBADRC:
-	{
-		acdb_mbadrc_rtc =  kmalloc(sizeof(struct \
-					acdb_block_mbadrc_rtc),\
-					GFP_KERNEL);
-		mbadrc_config =  kmalloc(sizeof(\
-					audpp_cmd_cfg_object_params_mbadrc),\
-					GFP_KERNEL);
-		if (mbadrc_config != NULL && acdb_mbadrc_rtc != NULL) {
-			if ((copy_from_user(acdb_mbadrc_rtc,\
-				(void *)ubuf,
-				sizeof(struct acdb_block_mbadrc_rtc)))
-				== 0x00) {
-
-				memset(mbadrc_config, 0,
-					sizeof(\
-					audpp_cmd_cfg_object_params_mbadrc));
-
-				mbadrc_config->enable =
-						acdb_mbadrc_rtc->enable;
-				mbadrc_config->num_bands =
-						acdb_mbadrc_rtc->num_bands;
-				mbadrc_config->down_samp_level =
-				acdb_mbadrc_rtc->down_samp_level;
-				mbadrc_config->adrc_delay =
-					acdb_mbadrc_rtc->adrc_delay;
-				memcpy(mbadrc_config->adrc_band,\
-					acdb_mbadrc_rtc->adrc_band,\
-					AUDPP_MAX_MBADRC_BANDS *\
-					sizeof(struct adrc_config));
-				if (mbadrc_config->num_bands > 1) {
-					mbadrc_config->ext_buf_size =
-						(97 * 2) + (33 * 2 * \
-					(mbadrc_config->num_bands - 2));
-				}
-				mbadrc_config->ext_partition = 0;
-				mbadrc_config->ext_buf_lsw =
-					(u16) EXTRACT_LOW_WORD(\
-						rtc_write->phys);
-				mbadrc_config->ext_buf_msw =
-					(u16) EXTRACT_HIGH_WORD(\
-						rtc_write->phys);
-				memcpy(rtc_write->viraddr,
-					acdb_mbadrc_rtc->ext_buff,
-					(196*sizeof(signed int)));
-				result = audpp_dsp_set_mbadrc(
-						COMMON_OBJ_ID,
-						mbadrc_config->enable,
-						mbadrc_config);
-				if (result) {
-					MM_ERR("ACDB=> Failed to "\
-						"Send MBADRC data "\
-						"to postproc\n");
-				} else {
-					retval = true;
-				}
-			} else {
-				MM_ERR("ACDB DATA WRITE ---"\
-					"MBADRC Rx copy_from_user Fail\n");
-			}
-		} else {
-			MM_ERR("ACDB DATA WRITE --MBADRC kalloc Failed LEN\n");
-		}
-		if (mbadrc_config != NULL)
-			kfree(mbadrc_config);
-		if (acdb_mbadrc_rtc != NULL)
-			kfree(acdb_mbadrc_rtc);
-	break;
-	}
-	}
-	return retval;
-}
-static ssize_t rtc_getsetabid_data_dbg_write(struct file *filp,
-						const char __user *ubuf,
-						size_t cnt, loff_t *ppos)
-{
-	if (rtc_acdb.valid_abid != true) {
-		MM_INFO("ACDB DATA READ ---INVALID ABID\n");
-		rtc_acdb.err = ACDB_RTC_ERR_INVALID_ABID;
-	} else {
-		if (rtc_acdb.tx_rx_ctl == ACDB_RTC_RX) {
-			if (acdb_set_rx_rtc(ubuf, cnt)) {
-				rtc_acdb.err = ACDB_RTC_SUCCESS;
-			} else {
-				rtc_acdb.err = ACDB_RTC_ERR_UNKNOWN_FAILURE;
-				cnt = 0;
-			}
-		} else if (rtc_acdb.tx_rx_ctl == ACDB_RTC_TX) {
-			if (acdb_set_tx_rtc(ubuf, cnt)) {
-				rtc_acdb.err = ACDB_RTC_SUCCESS;
-			} else {
-				rtc_acdb.err = ACDB_RTC_ERR_UNKNOWN_FAILURE;
-				cnt = 0;
-			}
-		}
-	}
-	return cnt;
-}
-
-
-static const	struct file_operations rtc_acdb_data_debug_fops = {
-	.open = rtc_getsetabid_data_dbg_open,
-	.write = rtc_getsetabid_data_dbg_write,
-	.read = rtc_getsetabid_data_dbg_read
-};
-
-static const	struct file_operations rtc_acdb_debug_fops = {
-	.open = rtc_getsetabid_dbg_open,
-	.write = rtc_getsetabid_dbg_write,
-	.read = rtc_getsetabid_dbg_read
-};
-
-static void rtc_acdb_deinit(void)
-{
-	struct rtc_acdb_pmem *rtc_read = &rtc_acdb.rtc_read;
-	struct rtc_acdb_pmem *rtc_write = &rtc_acdb.rtc_write;
-	if (get_set_abid_dentry) {
-		MM_DBG("GetSet ABID remove debugfs\n");
-		debugfs_remove(get_set_abid_dentry);
-	}
-
-	if (get_set_abid_data_dentry) {
-		MM_DBG("GetSet ABID remove debugfs\n");
-		debugfs_remove(get_set_abid_data_dentry);
-	}
-	rtc_acdb.abid = 0;
-	rtc_acdb.acdb_id = 0;
-	rtc_acdb.cmd_id = 0;
-	rtc_acdb.err = 1;
-	rtc_acdb.set_abid = 0;
-	rtc_acdb.set_iid = 0;
-	rtc_acdb.tx_rx_ctl = 0;
-	rtc_acdb.valid_abid = false;
-
-	if (rtc_read->viraddr != NULL || ((void *)rtc_read->phys) != NULL) {
-		iounmap(rtc_read->map_v_rtc);
-		free_contiguous_memory_by_paddr(rtc_read->phys);
-	}
-	if (rtc_write->viraddr != NULL || ((void *)rtc_write->phys) != NULL) {
-		iounmap(rtc_write->map_v_rtc);
-		free_contiguous_memory_by_paddr(rtc_write->phys);
-	}
-}
-
-static bool rtc_acdb_init(void)
-{
-	struct rtc_acdb_pmem *rtc_read = &rtc_acdb.rtc_read;
-	struct rtc_acdb_pmem *rtc_write = &rtc_acdb.rtc_write;
-	s32 result = 0;
-	char name[sizeof "get_set_abid"+1];
-	char name1[sizeof "get_set_abid_data"+1];
-	rtc_acdb.abid = 0;
-	rtc_acdb.acdb_id = 0;
-	rtc_acdb.cmd_id = 0;
-	rtc_acdb.err = 1;
-	rtc_acdb.set_abid = 0;
-	rtc_acdb.set_iid = 0;
-	rtc_acdb.valid_abid = false;
-	rtc_acdb.tx_rx_ctl = 0;
-
-	snprintf(name, sizeof name, "get_set_abid");
-	get_set_abid_dentry = debugfs_create_file(name,
-			S_IFREG | S_IRUGO | S_IWUGO,
-			NULL, NULL, &rtc_acdb_debug_fops);
-	if (IS_ERR(get_set_abid_dentry)) {
-		MM_ERR("SET GET ABID debugfs_create_file failed\n");
-		return false;
-	}
-
-	snprintf(name1, sizeof name1, "get_set_abid_data");
-	get_set_abid_data_dentry = debugfs_create_file(name1,
-			S_IFREG | S_IRUGO | S_IWUGO,
-			NULL, NULL,
-			&rtc_acdb_data_debug_fops);
-	if (IS_ERR(get_set_abid_data_dentry)) {
-		MM_ERR("SET GET ABID DATA"\
-				" debugfs_create_file failed\n");
-		return false;
-	}
-
-	rtc_read->phys = allocate_contiguous_ebi_nomap(PMEM_RTC_ACDB_QUERY_MEM,
-								 SZ_4K);
-
-	if (!rtc_read->phys) {
-		MM_ERR("ACDB Cannot allocate physical memory\n");
-		result = -ENOMEM;
-		goto error;
-	}
-	rtc_read->map_v_rtc = ioremap(rtc_read->phys,
-				PMEM_RTC_ACDB_QUERY_MEM);
-
-	if (IS_ERR(rtc_read->map_v_rtc)) {
-		MM_ERR("ACDB Could not map physical address\n");
-		result = -ENOMEM;
-		goto error;
-	}
-	rtc_read->viraddr = rtc_read->map_v_rtc;
-	memset(rtc_read->viraddr, 0, PMEM_RTC_ACDB_QUERY_MEM);
-
-	rtc_write->phys = allocate_contiguous_ebi_nomap(PMEM_RTC_ACDB_QUERY_MEM,
-								SZ_4K);
-
-	if (!rtc_write->phys) {
-		MM_ERR("ACDB Cannot allocate physical memory\n");
-		result = -ENOMEM;
-		goto error;
-	}
-	rtc_write->map_v_rtc = ioremap(rtc_write->phys,
-				PMEM_RTC_ACDB_QUERY_MEM);
-
-	if (IS_ERR(rtc_write->map_v_rtc)) {
-		MM_ERR("ACDB Could not map physical address\n");
-		result = -ENOMEM;
-		goto error;
-	}
-	rtc_write->viraddr = rtc_write->map_v_rtc;
-	memset(rtc_write->viraddr, 0, PMEM_RTC_ACDB_QUERY_MEM);
-	init_waitqueue_head(&rtc_acdb.wait);
-	return true;
-error:
-	MM_DBG("INIT RTC FAILED REMOVING RTC DEBUG FS\n");
-	if (get_set_abid_dentry) {
-		MM_DBG("GetSet ABID remove debugfs\n");
-		debugfs_remove(get_set_abid_dentry);
-	}
-
-	if (get_set_abid_data_dentry) {
-		MM_DBG("GetSet ABID remove debugfs\n");
-		debugfs_remove(get_set_abid_data_dentry);
-	}
-	if (rtc_read->viraddr != NULL || ((void *)rtc_read->phys) != NULL) {
-		iounmap(rtc_read->map_v_rtc);
-		free_contiguous_memory_by_paddr(rtc_read->phys);
-	}
-	if (rtc_write->viraddr != NULL || ((void *)rtc_write->phys) != NULL) {
-		iounmap(rtc_write->map_v_rtc);
-		free_contiguous_memory_by_paddr(rtc_write->phys);
-	}
-	return false;
-}
-#else
-void acdb_rtc_set_err(u32 err_code)
-{
-	return 0
-}
-#endif /*CONFIG_DEBUG_FS*/
-static s32 acdb_set_calibration_blk(unsigned long arg)
-{
-	struct acdb_cmd_device acdb_cmd;
-	s32 result = 0;
-
-	MM_DBG("acdb_set_calibration_blk\n");
-	if (copy_from_user(&acdb_cmd, (struct acdb_cmd_device *)arg,
-			sizeof(acdb_cmd))) {
-		MM_ERR("Failed copy command struct from user in"\
-			"acdb_set_calibration_blk\n");
-		return -EFAULT;
-	}
-	acdb_cmd.phys_buf = (u32 *)acdb_data.paddr;
-
-	MM_DBG("acdb_cmd.phys_buf %x\n", (u32)acdb_cmd.phys_buf);
-
-	result = dalrpc_fcn_8(ACDB_DAL_IOCTL, acdb_data.handle,
-			(const void *)&acdb_cmd, sizeof(acdb_cmd),
-			&acdb_data.acdb_result,
-			sizeof(acdb_data.acdb_result));
-
-	if (result < 0) {
-		MM_ERR("ACDB=> Device Set RPC failure"\
-			" result = %d\n", result);
-		return -EINVAL;
-	} else {
-		MM_ERR("ACDB=> Device Set RPC success\n");
-		if (acdb_data.acdb_result.result == ACDB_RES_SUCCESS)
-			MM_DBG("ACDB_SET_DEVICE Success\n");
-		else if (acdb_data.acdb_result.result == ACDB_RES_FAILURE)
-			MM_ERR("ACDB_SET_DEVICE Failure\n");
-		else if (acdb_data.acdb_result.result == ACDB_RES_BADPARM)
-			MM_ERR("ACDB_SET_DEVICE BadParams\n");
-		else
-			MM_ERR("Unknown error\n");
-	}
-	return result;
-}
-
-static s32 acdb_get_calibration_blk(unsigned long arg)
-{
-	s32 result = 0;
-	struct acdb_cmd_device acdb_cmd;
-
-	MM_DBG("acdb_get_calibration_blk\n");
-
-	if (copy_from_user(&acdb_cmd, (struct acdb_cmd_device *)arg,
-			sizeof(acdb_cmd))) {
-		MM_ERR("Failed copy command struct from user in"\
-			"acdb_get_calibration_blk\n");
-		return -EFAULT;
-	}
-	acdb_cmd.phys_buf = (u32 *)acdb_data.paddr;
-	MM_ERR("acdb_cmd.phys_buf %x\n", (u32)acdb_cmd.phys_buf);
-
-	result = dalrpc_fcn_8(ACDB_DAL_IOCTL, acdb_data.handle,
-			(const void *)&acdb_cmd, sizeof(acdb_cmd),
-			&acdb_data.acdb_result,
-			sizeof(acdb_data.acdb_result));
-
-	if (result < 0) {
-		MM_ERR("ACDB=> Device Get RPC failure"\
-			" result = %d\n", result);
-		return -EINVAL;
-	} else {
-		MM_ERR("ACDB=> Device Get RPC Success\n");
-		if (acdb_data.acdb_result.result == ACDB_RES_SUCCESS)
-			MM_DBG("ACDB_GET_DEVICE Success\n");
-		else if (acdb_data.acdb_result.result == ACDB_RES_FAILURE)
-			MM_ERR("ACDB_GET_DEVICE Failure\n");
-		else if (acdb_data.acdb_result.result == ACDB_RES_BADPARM)
-			MM_ERR("ACDB_GET_DEVICE BadParams\n");
-		else
-			MM_ERR("Unknown error\n");
-	}
-	return result;
-}
-
-static int audio_acdb_open(struct inode *inode, struct file *file)
-{
-	MM_DBG("%s\n", __func__);
-	return 0;
-}
-static int audio_acdb_release(struct inode *inode, struct file *file)
-{
-	MM_DBG("%s\n", __func__);
-	return 0;
-}
-
-static long audio_acdb_ioctl(struct file *file, unsigned int cmd,
-					unsigned long arg)
-{
-	int rc = 0;
-	unsigned long flags = 0;
-
-	MM_DBG("%s\n", __func__);
-
-	switch (cmd) {
-	case AUDIO_SET_EQ:
-		MM_DBG("IOCTL SET_EQ_CONFIG\n");
-		if (copy_from_user(&acdb_data.eq.num_bands, (void *) arg,
-				sizeof(acdb_data.eq) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2))) {
-			rc = -EFAULT;
-			break;
-		}
-		spin_lock_irqsave(&acdb_data.dsp_lock, flags);
-		rc = audpp_dsp_set_eq(COMMON_OBJ_ID, 1,
-			&acdb_data.eq);
-		if (rc < 0)
-			MM_ERR("AUDPP returned err =%d\n", rc);
-		spin_unlock_irqrestore(&acdb_data.dsp_lock, flags);
-		break;
-	case AUDIO_SET_ACDB_BLK:
-		MM_DBG("IOCTL AUDIO_SET_ACDB_BLK\n");
-		rc = acdb_set_calibration_blk(arg);
-		break;
-	case AUDIO_GET_ACDB_BLK:
-		MM_DBG("IOiCTL AUDIO_GET_ACDB_BLK\n");
-		rc = acdb_get_calibration_blk(arg);
-		break;
-	default:
-		MM_DBG("Unknown IOCTL%d\n", cmd);
-		rc = -EINVAL;
-	}
-	return rc;
-}
-
-static const struct file_operations acdb_fops = {
-	.owner = THIS_MODULE,
-	.open = audio_acdb_open,
-	.release = audio_acdb_release,
-	.llseek = no_llseek,
-	.unlocked_ioctl = audio_acdb_ioctl
-};
-
-struct miscdevice acdb_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_acdb",
-	.fops	= &acdb_fops,
-};
-
-static s32 acdb_get_calibration(void)
-{
-	struct acdb_cmd_get_device_table	acdb_cmd;
-	s32					result = 0;
-	u32 iterations = 0;
-
-	MM_DBG("acdb state = %d\n", acdb_data.acdb_state);
-
-	acdb_cmd.command_id = ACDB_GET_DEVICE_TABLE;
-	acdb_cmd.device_id = acdb_data.device_info->acdb_id;
-	acdb_cmd.network_id = 0x0108B153;
-	acdb_cmd.sample_rate_id = acdb_data.device_info->sample_rate;
-	acdb_cmd.total_bytes = ACDB_BUF_SIZE;
-	acdb_cmd.phys_buf = (u32 *)acdb_data.phys_addr;
-	MM_DBG("device_id = %d, sampling_freq = %d\n",
-				acdb_cmd.device_id, acdb_cmd.sample_rate_id);
-
-	do {
-		result = dalrpc_fcn_8(ACDB_DAL_IOCTL, acdb_data.handle,
-				(const void *)&acdb_cmd, sizeof(acdb_cmd),
-				&acdb_data.acdb_result,
-				sizeof(acdb_data.acdb_result));
-
-		if (result < 0) {
-			MM_ERR("ACDB=> Device table RPC failure"\
-				" result = %d\n", result);
-			goto error;
-		}
-		/*following check is introduced to handle boot up race
-		condition between AUDCAL SW peers running on apps
-		and modem (ACDB_RES_BADSTATE indicates modem AUDCAL SW is
-		not in initialized sate) we need to retry to get ACDB
-		values*/
-		if (acdb_data.acdb_result.result == ACDB_RES_BADSTATE) {
-			msleep(500);
-			iterations++;
-		} else if (acdb_data.acdb_result.result == ACDB_RES_SUCCESS) {
-			MM_DBG("Modem query for acdb values is successful"\
-					" (iterations = %d)\n", iterations);
-			acdb_data.acdb_state |= CAL_DATA_READY;
-			return result;
-		} else {
-			MM_ERR("ACDB=> modem failed to fill acdb values,"\
-					" reuslt = %d, (iterations = %d)\n",
-					acdb_data.acdb_result.result,
-					iterations);
-			goto error;
-		}
-	} while (iterations < MAX_RETRY);
-	MM_ERR("ACDB=> AUDCAL SW on modem is not in intiailized state (%d)\n",
-			acdb_data.acdb_result.result);
-error:
-	result = -EINVAL;
-	return result;
-}
-
-s32 acdb_get_calibration_data(struct acdb_get_block *get_block)
-{
-	s32 result = -EINVAL;
-	struct acdb_cmd_device acdb_cmd;
-	struct acdb_result acdb_result;
-
-	MM_DBG("acdb_get_calibration_data\n");
-
-	acdb_cmd.command_id = ACDB_GET_DEVICE;
-	acdb_cmd.network_id = 0x0108B153;
-	acdb_cmd.device_id = get_block->acdb_id;
-	acdb_cmd.sample_rate_id = get_block->sample_rate_id;
-	acdb_cmd.interface_id = get_block->interface_id;
-	acdb_cmd.algorithm_block_id = get_block->algorithm_block_id;
-	acdb_cmd.total_bytes = get_block->total_bytes;
-	acdb_cmd.phys_buf = (u32 *)acdb_data.get_blk_paddr;
-
-	result = dalrpc_fcn_8(ACDB_DAL_IOCTL, acdb_data.handle,
-			(const void *)&acdb_cmd, sizeof(acdb_cmd),
-			&acdb_result,
-			sizeof(acdb_result));
-
-	if (result < 0) {
-		MM_ERR("ACDB=> Device Get RPC failure"\
-			" result = %d\n", result);
-		goto err_state;
-	} else {
-		MM_DBG("ACDB=> Device Get RPC Success\n");
-		if (acdb_result.result == ACDB_RES_SUCCESS) {
-			MM_DBG("ACDB_GET_DEVICE Success\n");
-			result = 0;
-			memcpy(get_block->buf_ptr, acdb_data.get_blk_kvaddr,
-					get_block->total_bytes);
-		} else if (acdb_result.result == ACDB_RES_FAILURE)
-			MM_ERR("ACDB_GET_DEVICE Failure\n");
-		else if (acdb_result.result == ACDB_RES_BADPARM)
-			MM_ERR("ACDB_GET_DEVICE BadParams\n");
-		else
-			MM_ERR("Unknown error\n");
-	}
-err_state:
-	return result;
-}
-EXPORT_SYMBOL(acdb_get_calibration_data);
-
-int is_acdb_enabled()
-{
-	if (acdb_data.handle != NULL)
-		return 1;
-	else
-		return 0;
-}
-EXPORT_SYMBOL(is_acdb_enabled);
-
-static u8 check_device_info_already_present(
-		struct dev_evt_msg device_info,
-			struct acdb_cache_node *acdb_cache_free_node)
-{
-	if ((device_info.sample_rate ==
-				acdb_cache_free_node->device_info.\
-				sample_rate) &&
-			(device_info.acdb_id ==
-				acdb_cache_free_node->device_info.acdb_id)) {
-		MM_DBG("acdb values are already present\n");
-		/*if acdb state is not set for CAL_DATA_READY and node status
-		is filled, acdb state should be updated with CAL_DATA_READY
-		state*/
-		acdb_data.acdb_state |= CAL_DATA_READY;
-		return 1; /*node is present but status as filled*/
-	}
-	MM_DBG("copying device info into node\n");
-	/*as device information is not present in cache copy
-	the current device information into the node*/
-	memcpy(&acdb_cache_free_node->device_info,
-				 &device_info, sizeof(device_info));
-	return 0; /*cant find the node*/
-}
-
-static struct acdb_iir_block *get_audpp_irr_block(void)
-{
-	struct header *prs_hdr;
-	u32 index = 0;
-
-	while (index < acdb_data.acdb_result.used_bytes) {
-		prs_hdr = (struct header *)(acdb_data.virt_addr + index);
-		if (prs_hdr->dbor_signature == DBOR_SIGNATURE) {
-			if (prs_hdr->abid == ABID_AUDIO_IIR_RX) {
-				if (prs_hdr->iid == IID_AUDIO_IIR_COEFF)
-					return (struct acdb_iir_block *)
-						(acdb_data.virt_addr + index
-						 + sizeof(struct header));
-			} else {
-				index += prs_hdr->data_len +
-						sizeof(struct header);
-			}
-		} else {
-			break;
-		}
-	}
-	return NULL;
-}
-
-
-static s32 acdb_fill_audpp_iir(void)
-{
-	struct acdb_iir_block *acdb_iir;
-	s32 i = 0;
-
-	acdb_iir = get_audpp_irr_block();
-	if (acdb_iir == NULL) {
-		MM_ERR("unable to find  audpp iir block returning\n");
-		return -EINVAL;
-	}
-	memset(acdb_data.pp_iir, 0, sizeof(*acdb_data.pp_iir));
-
-	acdb_data.pp_iir->active_flag = acdb_iir->enable_flag;
-	acdb_data.pp_iir->num_bands = acdb_iir->stage_count;
-	for (; i < acdb_iir->stage_count; i++) {
-		acdb_data.pp_iir->params_filter.filter_4_params.
-			numerator_filter[i].numerator_b0_filter_lsw =
-			acdb_iir->stages[i].b0_lo;
-		acdb_data.pp_iir->params_filter.filter_4_params.
-			numerator_filter[i].numerator_b0_filter_msw =
-			acdb_iir->stages[i].b0_hi;
-		acdb_data.pp_iir->params_filter.filter_4_params.
-			numerator_filter[i].numerator_b1_filter_lsw =
-			acdb_iir->stages[i].b1_lo;
-		acdb_data.pp_iir->params_filter.filter_4_params.
-			numerator_filter[i].numerator_b1_filter_msw =
-			acdb_iir->stages[i].b1_hi;
-		acdb_data.pp_iir->params_filter.filter_4_params.
-			numerator_filter[i].numerator_b2_filter_lsw =
-			acdb_iir->stages[i].b2_lo;
-		acdb_data.pp_iir->params_filter.filter_4_params.
-			numerator_filter[i].numerator_b2_filter_msw =
-			acdb_iir->stages[i].b2_hi;
-		acdb_data.pp_iir->params_filter.filter_4_params.
-			denominator_filter[i].denominator_a0_filter_lsw =
-			acdb_iir->stages_a[i].a1_lo;
-		acdb_data.pp_iir->params_filter.filter_4_params.
-			denominator_filter[i].denominator_a0_filter_msw =
-			acdb_iir->stages_a[i].a1_hi;
-		acdb_data.pp_iir->params_filter.filter_4_params.
-			denominator_filter[i].denominator_a1_filter_lsw =
-			acdb_iir->stages_a[i].a2_lo;
-		acdb_data.pp_iir->params_filter.filter_4_params.
-			denominator_filter[i].denominator_a1_filter_msw =
-			acdb_iir->stages_a[i].a2_hi;
-		acdb_data.pp_iir->params_filter.filter_4_params.
-			shift_factor_filter[i].shift_factor_0 =
-			acdb_iir->shift_factor[i];
-		acdb_data.pp_iir->params_filter.filter_4_params.pan_filter[i].
-			pan_filter_0 = acdb_iir->pan[i];
-	}
-	return 0;
-}
-
-static void extract_mbadrc(u32 *phy_addr, struct header *prs_hdr, u32 *index)
-{
-	if (prs_hdr->iid == IID_MBADRC_EXT_BUFF) {
-		MM_DBG("Got IID = IID_MBADRC_EXT_BUFF\n");
-		*phy_addr = acdb_data.phys_addr	+ *index +
-					sizeof(struct header);
-		memcpy(acdb_data.mbadrc_block.ext_buf,
-				(acdb_data.virt_addr + *index +
-					sizeof(struct header)), 196*2);
-		MM_DBG("phy_addr = %x\n", *phy_addr);
-		*index += prs_hdr->data_len + sizeof(struct header);
-	} else if (prs_hdr->iid == IID_MBADRC_BAND_CONFIG) {
-		MM_DBG("Got IID == IID_MBADRC_BAND_CONFIG\n");
-		memcpy(acdb_data.mbadrc_block.band_config, (acdb_data.virt_addr
-					+ *index + sizeof(struct header)),
-				sizeof(struct mbadrc_band_config_type) *
-					 acdb_data.mbadrc_block.parameters.\
-						mbadrc_num_bands);
-		*index += prs_hdr->data_len + sizeof(struct header);
-	} else if (prs_hdr->iid == IID_MBADRC_PARAMETERS) {
-		struct mbadrc_parameter *tmp;
-		tmp = (struct mbadrc_parameter *)(acdb_data.virt_addr + *index
-						+ sizeof(struct header));
-		MM_DBG("Got IID == IID_MBADRC_PARAMETERS");
-		acdb_data.mbadrc_block.parameters.mbadrc_enable =
-							tmp->mbadrc_enable;
-		acdb_data.mbadrc_block.parameters.mbadrc_num_bands =
-							tmp->mbadrc_num_bands;
-		acdb_data.mbadrc_block.parameters.mbadrc_down_sample_level =
-						tmp->mbadrc_down_sample_level;
-		acdb_data.mbadrc_block.parameters.mbadrc_delay =
-							tmp->mbadrc_delay;
-		*index += prs_hdr->data_len + sizeof(struct header);
-	}
-}
-
-static void get_audpp_mbadrc_block(u32 *phy_addr)
-{
-	struct header *prs_hdr;
-	u32 index = 0;
-
-	while (index < acdb_data.acdb_result.used_bytes) {
-		prs_hdr = (struct header *)(acdb_data.virt_addr + index);
-
-		if (prs_hdr->dbor_signature == DBOR_SIGNATURE) {
-			if (prs_hdr->abid == ABID_AUDIO_MBADRC_RX) {
-				if ((prs_hdr->iid == IID_MBADRC_EXT_BUFF)
-					|| (prs_hdr->iid ==
-						IID_MBADRC_BAND_CONFIG)
-					|| (prs_hdr->iid ==
-						IID_MBADRC_PARAMETERS)) {
-					extract_mbadrc(phy_addr, prs_hdr,
-								&index);
-				}
-			} else {
-				index += prs_hdr->data_len +
-						sizeof(struct header);
-			}
-		} else {
-			break;
-		}
-	}
-}
-
-static s32 acdb_fill_audpp_mbadrc(void)
-{
-	u32 mbadrc_phys_addr = -1;
-	get_audpp_mbadrc_block(&mbadrc_phys_addr);
-	if (IS_ERR_VALUE(mbadrc_phys_addr)) {
-		MM_ERR("failed to get mbadrc block\n");
-		return -EINVAL;
-	}
-
-	memset(acdb_data.pp_mbadrc, 0, sizeof(*acdb_data.pp_mbadrc));
-
-	acdb_data.pp_mbadrc->enable = acdb_data.mbadrc_block.\
-					parameters.mbadrc_enable;
-	acdb_data.pp_mbadrc->num_bands =
-				acdb_data.mbadrc_block.\
-					parameters.mbadrc_num_bands;
-	acdb_data.pp_mbadrc->down_samp_level =
-				acdb_data.mbadrc_block.parameters.\
-					mbadrc_down_sample_level;
-	acdb_data.pp_mbadrc->adrc_delay =
-				acdb_data.mbadrc_block.parameters.\
-					mbadrc_delay;
-
-	if (acdb_data.mbadrc_block.parameters.mbadrc_num_bands > 1)
-		acdb_data.pp_mbadrc->ext_buf_size = (97 * 2) +
-			(33 * 2 * (acdb_data.mbadrc_block.parameters.\
-					mbadrc_num_bands - 2));
-
-	acdb_data.pp_mbadrc->ext_partition = 0;
-	acdb_data.pp_mbadrc->ext_buf_lsw = (u16)(mbadrc_phys_addr\
-						 & 0xFFFF);
-	acdb_data.pp_mbadrc->ext_buf_msw = (u16)((mbadrc_phys_addr\
-						 & 0xFFFF0000) >> 16);
-	memcpy(acdb_data.pp_mbadrc->adrc_band, acdb_data.mbadrc_block.\
-					band_config,
-		sizeof(struct mbadrc_band_config_type) *
-		acdb_data.mbadrc_block.parameters.mbadrc_num_bands);
-	return 0;
-}
-
-static s32 acdb_calibrate_audpp(void)
-{
-	s32	result = 0;
-
-	result = acdb_fill_audpp_iir();
-	if (!IS_ERR_VALUE(result)) {
-		result = audpp_dsp_set_rx_iir(COMMON_OBJ_ID,
-				acdb_data.pp_iir->active_flag,
-					acdb_data.pp_iir);
-		if (result) {
-			MM_ERR("ACDB=> Failed to send IIR data to postproc\n");
-			result = -EINVAL;
-			goto done;
-		} else
-			MM_DBG("AUDPP is calibrated with IIR parameters\n");
-	}
-	result = acdb_fill_audpp_mbadrc();
-	if (!IS_ERR_VALUE(result)) {
-		result = audpp_dsp_set_mbadrc(COMMON_OBJ_ID,
-					acdb_data.pp_mbadrc->enable,
-					acdb_data.pp_mbadrc);
-		if (result) {
-			MM_ERR("ACDB=> Failed to send MBADRC data to"\
-					" postproc\n");
-			result = -EINVAL;
-			goto done;
-		} else
-			MM_DBG("AUDPP is calibrated with MBADRC parameters");
-	}
-done:
-	return result;
-}
-
-static s32 acdb_re_enable_audpp(void)
-{
-	s32	result = 0;
-
-	if ((acdb_data.audpp_disabled_features &
-			(1 << AUDPP_CMD_IIR_TUNING_FILTER))
-			== (1 << AUDPP_CMD_IIR_TUNING_FILTER)) {
-		result = audpp_dsp_set_rx_iir(COMMON_OBJ_ID,
-				acdb_data.pp_iir->active_flag,
-				acdb_data.pp_iir);
-		if (result) {
-			MM_ERR("ACDB=> Failed to send IIR data to postproc\n");
-			result = -EINVAL;
-		} else {
-			MM_DBG("Re-enable IIR parameters");
-		}
-	}
-	if ((acdb_data.audpp_disabled_features & (1 << AUDPP_CMD_MBADRC))
-			== (1 << AUDPP_CMD_MBADRC)) {
-		result = audpp_dsp_set_mbadrc(COMMON_OBJ_ID,
-				acdb_data.pp_mbadrc->enable,
-				acdb_data.pp_mbadrc);
-		if (result) {
-			MM_ERR("ACDB=> Failed to send MBADRC data to"\
-					" postproc\n");
-			result = -EINVAL;
-		} else {
-			MM_DBG("Re-enable MBADRC parameters");
-		}
-	}
-	acdb_data.audpp_disabled_features = 0;
-	return result;
-}
-
-static struct acdb_agc_block *get_audpreproc_agc_block(void)
-{
-	struct header *prs_hdr;
-	u32 index = 0;
-
-	while (index < acdb_data.acdb_result.used_bytes) {
-		prs_hdr = (struct header *)(acdb_data.virt_addr + index);
-		if (prs_hdr->dbor_signature == DBOR_SIGNATURE) {
-			if (prs_hdr->abid == ABID_AUDIO_AGC_TX) {
-				if (prs_hdr->iid == IID_AUDIO_AGC_PARAMETERS) {
-					MM_DBG("GOT ABID_AUDIO_AGC_TX\n");
-					return (struct acdb_agc_block *)
-						(acdb_data.virt_addr + index
-						 + sizeof(struct header));
-				}
-			} else {
-				index += prs_hdr->data_len +
-						sizeof(struct header);
-			}
-		} else {
-			break;
-		}
-	}
-	return NULL;
-}
-
-static s32 acdb_fill_audpreproc_agc(void)
-{
-	struct acdb_agc_block	*acdb_agc;
-
-	acdb_agc = get_audpreproc_agc_block();
-	if (!acdb_agc) {
-		MM_DBG("unable to find preproc agc parameters winding up\n");
-		return -EINVAL;
-	}
-	memset(acdb_data.preproc_agc, 0, sizeof(*acdb_data.preproc_agc));
-	acdb_data.preproc_agc->cmd_id = AUDPREPROC_CMD_CFG_AGC_PARAMS;
-	/* 0xFE00 to configure all parameters */
-	acdb_data.preproc_agc->tx_agc_param_mask = 0xFFFF;
-	if (acdb_agc->enable_status)
-		acdb_data.preproc_agc->tx_agc_enable_flag =
-			AUDPREPROC_CMD_TX_AGC_ENA_FLAG_ENA;
-	else
-		acdb_data.preproc_agc->tx_agc_enable_flag =
-			AUDPREPROC_CMD_TX_AGC_ENA_FLAG_DIS;
-
-	acdb_data.preproc_agc->comp_rlink_static_gain =
-		acdb_agc->comp_rlink_static_gain;
-	acdb_data.preproc_agc->comp_rlink_aig_flag =
-		acdb_agc->comp_rlink_aig_flag;
-	acdb_data.preproc_agc->expander_rlink_th =
-		acdb_agc->exp_rlink_threshold;
-	acdb_data.preproc_agc->expander_rlink_slope =
-		acdb_agc->exp_rlink_slope;
-	acdb_data.preproc_agc->compressor_rlink_th =
-		acdb_agc->comp_rlink_threshold;
-	acdb_data.preproc_agc->compressor_rlink_slope =
-		acdb_agc->comp_rlink_slope;
-
-	/* 0xFFF0 to configure all parameters */
-	acdb_data.preproc_agc->tx_adc_agc_param_mask = 0xFFFF;
-
-	acdb_data.preproc_agc->comp_rlink_aig_attackk =
-		acdb_agc->comp_rlink_aig_attack_k;
-	acdb_data.preproc_agc->comp_rlink_aig_leak_down =
-		acdb_agc->comp_rlink_aig_leak_down;
-	acdb_data.preproc_agc->comp_rlink_aig_leak_up =
-		acdb_agc->comp_rlink_aig_leak_up;
-	acdb_data.preproc_agc->comp_rlink_aig_max =
-		acdb_agc->comp_rlink_aig_max;
-	acdb_data.preproc_agc->comp_rlink_aig_min =
-		acdb_agc->comp_rlink_aig_min;
-	acdb_data.preproc_agc->comp_rlink_aig_releasek =
-		acdb_agc->comp_rlink_aig_release_k;
-	acdb_data.preproc_agc->comp_rlink_aig_leakrate_fast =
-		acdb_agc->comp_rlink_aig_sm_leak_rate_fast;
-	acdb_data.preproc_agc->comp_rlink_aig_leakrate_slow =
-		acdb_agc->comp_rlink_aig_sm_leak_rate_slow;
-	acdb_data.preproc_agc->comp_rlink_attackk_msw =
-		acdb_agc->comp_rlink_attack_k_msw;
-	acdb_data.preproc_agc->comp_rlink_attackk_lsw =
-		acdb_agc->comp_rlink_attack_k_lsw;
-	acdb_data.preproc_agc->comp_rlink_delay =
-		acdb_agc->comp_rlink_delay;
-	acdb_data.preproc_agc->comp_rlink_releasek_msw =
-		acdb_agc->comp_rlink_release_k_msw;
-	acdb_data.preproc_agc->comp_rlink_releasek_lsw =
-		acdb_agc->comp_rlink_release_k_lsw;
-	acdb_data.preproc_agc->comp_rlink_rms_tav =
-		acdb_agc->comp_rlink_rms_trav;
-	return 0;
-}
-
-static struct acdb_iir_block *get_audpreproc_irr_block(void)
-{
-
-	struct header *prs_hdr;
-	u32 index = 0;
-
-	while (index < acdb_data.acdb_result.used_bytes) {
-		prs_hdr = (struct header *)(acdb_data.virt_addr + index);
-
-		if (prs_hdr->dbor_signature == DBOR_SIGNATURE) {
-			if (prs_hdr->abid == ABID_AUDIO_IIR_TX) {
-				if (prs_hdr->iid == IID_AUDIO_IIR_COEFF)
-					return (struct acdb_iir_block *)
-						(acdb_data.virt_addr + index
-						 + sizeof(struct header));
-			} else {
-				index += prs_hdr->data_len +
-						sizeof(struct header);
-			}
-		} else {
-			break;
-		}
-	}
-	return NULL;
-}
-
-
-static s32 acdb_fill_audpreproc_iir(void)
-{
-	struct acdb_iir_block	*acdb_iir;
-
-
-	acdb_iir =  get_audpreproc_irr_block();
-	if (!acdb_iir) {
-		MM_DBG("unable to find preproc iir parameters winding up\n");
-		return -EINVAL;
-	}
-	memset(acdb_data.preproc_iir, 0, sizeof(*acdb_data.preproc_iir));
-
-	acdb_data.preproc_iir->cmd_id =
-		AUDPREPROC_CMD_CFG_IIR_TUNING_FILTER_PARAMS;
-	acdb_data.preproc_iir->active_flag = acdb_iir->enable_flag;
-	acdb_data.preproc_iir->num_bands = acdb_iir->stage_count;
-
-	acdb_data.preproc_iir->numerator_coeff_b0_filter0_lsw =
-		acdb_iir->stages[0].b0_lo;
-	acdb_data.preproc_iir->numerator_coeff_b0_filter0_msw =
-		acdb_iir->stages[0].b0_hi;
-	acdb_data.preproc_iir->numerator_coeff_b1_filter0_lsw =
-		acdb_iir->stages[0].b1_lo;
-	acdb_data.preproc_iir->numerator_coeff_b1_filter0_msw =
-		acdb_iir->stages[0].b1_hi;
-	acdb_data.preproc_iir->numerator_coeff_b2_filter0_lsw =
-		acdb_iir->stages[0].b2_lo;
-	acdb_data.preproc_iir->numerator_coeff_b2_filter0_msw =
-		acdb_iir->stages[0].b2_hi;
-
-	acdb_data.preproc_iir->numerator_coeff_b0_filter1_lsw =
-		acdb_iir->stages[1].b0_lo;
-	acdb_data.preproc_iir->numerator_coeff_b0_filter1_msw =
-		acdb_iir->stages[1].b0_hi;
-	acdb_data.preproc_iir->numerator_coeff_b1_filter1_lsw =
-		acdb_iir->stages[1].b1_lo;
-	acdb_data.preproc_iir->numerator_coeff_b1_filter1_msw =
-		acdb_iir->stages[1].b1_hi;
-	acdb_data.preproc_iir->numerator_coeff_b2_filter1_lsw =
-		acdb_iir->stages[1].b2_lo;
-	acdb_data.preproc_iir->numerator_coeff_b2_filter1_msw =
-		acdb_iir->stages[1].b2_hi;
-
-	acdb_data.preproc_iir->numerator_coeff_b0_filter2_lsw =
-		acdb_iir->stages[2].b0_lo;
-	acdb_data.preproc_iir->numerator_coeff_b0_filter2_msw =
-		acdb_iir->stages[2].b0_hi;
-	acdb_data.preproc_iir->numerator_coeff_b1_filter2_lsw =
-		acdb_iir->stages[2].b1_lo;
-	acdb_data.preproc_iir->numerator_coeff_b1_filter2_msw =
-		acdb_iir->stages[2].b1_hi;
-	acdb_data.preproc_iir->numerator_coeff_b2_filter2_lsw =
-		acdb_iir->stages[2].b2_lo;
-	acdb_data.preproc_iir->numerator_coeff_b2_filter2_msw =
-		acdb_iir->stages[2].b2_hi;
-
-	acdb_data.preproc_iir->numerator_coeff_b0_filter3_lsw =
-		acdb_iir->stages[3].b0_lo;
-	acdb_data.preproc_iir->numerator_coeff_b0_filter3_msw =
-		acdb_iir->stages[3].b0_hi;
-	acdb_data.preproc_iir->numerator_coeff_b1_filter3_lsw =
-		acdb_iir->stages[3].b1_lo;
-	acdb_data.preproc_iir->numerator_coeff_b1_filter3_msw =
-		acdb_iir->stages[3].b1_hi;
-	acdb_data.preproc_iir->numerator_coeff_b2_filter3_lsw =
-		acdb_iir->stages[3].b2_lo;
-	acdb_data.preproc_iir->numerator_coeff_b2_filter3_msw =
-		acdb_iir->stages[3].b2_hi;
-
-	acdb_data.preproc_iir->denominator_coeff_a0_filter0_lsw =
-		acdb_iir->stages_a[0].a1_lo;
-	acdb_data.preproc_iir->denominator_coeff_a0_filter0_msw =
-		acdb_iir->stages_a[0].a1_hi;
-	acdb_data.preproc_iir->denominator_coeff_a1_filter0_lsw =
-		acdb_iir->stages_a[0].a2_lo;
-	acdb_data.preproc_iir->denominator_coeff_a1_filter0_msw =
-		acdb_iir->stages_a[0].a2_hi;
-
-	acdb_data.preproc_iir->denominator_coeff_a0_filter1_lsw =
-		acdb_iir->stages_a[1].a1_lo;
-	acdb_data.preproc_iir->denominator_coeff_a0_filter1_msw =
-		acdb_iir->stages_a[1].a1_hi;
-	acdb_data.preproc_iir->denominator_coeff_a1_filter1_lsw =
-		acdb_iir->stages_a[1].a2_lo;
-	acdb_data.preproc_iir->denominator_coeff_a1_filter1_msw =
-		acdb_iir->stages_a[1].a2_hi;
-
-	acdb_data.preproc_iir->denominator_coeff_a0_filter2_lsw =
-		acdb_iir->stages_a[2].a1_lo;
-	acdb_data.preproc_iir->denominator_coeff_a0_filter2_msw =
-		acdb_iir->stages_a[2].a1_hi;
-	acdb_data.preproc_iir->denominator_coeff_a1_filter2_lsw =
-		acdb_iir->stages_a[2].a2_lo;
-	acdb_data.preproc_iir->denominator_coeff_a1_filter2_msw =
-		acdb_iir->stages_a[2].a2_hi;
-
-	acdb_data.preproc_iir->denominator_coeff_a0_filter3_lsw =
-		acdb_iir->stages_a[3].a1_lo;
-	acdb_data.preproc_iir->denominator_coeff_a0_filter3_msw =
-		acdb_iir->stages_a[3].a1_hi;
-	acdb_data.preproc_iir->denominator_coeff_a1_filter3_lsw =
-		acdb_iir->stages_a[3].a2_lo;
-	acdb_data.preproc_iir->denominator_coeff_a1_filter3_msw =
-		acdb_iir->stages_a[3].a2_hi;
-
-	acdb_data.preproc_iir->shift_factor_filter0 =
-		acdb_iir->shift_factor[0];
-	acdb_data.preproc_iir->shift_factor_filter1 =
-		acdb_iir->shift_factor[1];
-	acdb_data.preproc_iir->shift_factor_filter2 =
-		acdb_iir->shift_factor[2];
-	acdb_data.preproc_iir->shift_factor_filter3 =
-		acdb_iir->shift_factor[3];
-
-	acdb_data.preproc_iir->channel_selected0 =
-		acdb_iir->pan[0];
-	acdb_data.preproc_iir->channel_selected1 =
-		acdb_iir->pan[1];
-	acdb_data.preproc_iir->channel_selected2 =
-		acdb_iir->pan[2];
-	acdb_data.preproc_iir->channel_selected3 =
-		acdb_iir->pan[3];
-	return 0;
-}
-
-static struct acdb_ns_tx_block *get_audpreproc_ns_block(void)
-{
-
-	struct header *prs_hdr;
-	u32 index = 0;
-
-	while (index < acdb_data.acdb_result.used_bytes) {
-		prs_hdr = (struct header *)(acdb_data.virt_addr + index);
-
-		if (prs_hdr->dbor_signature == DBOR_SIGNATURE) {
-			if (prs_hdr->abid == ABID_AUDIO_NS_TX) {
-				if (prs_hdr->iid == IID_NS_PARAMETERS)
-					return (struct acdb_ns_tx_block *)
-						(acdb_data.virt_addr + index
-						 + sizeof(struct header));
-			} else {
-				index += prs_hdr->data_len +
-						sizeof(struct header);
-			}
-		} else {
-			break;
-		}
-	}
-	return NULL;
-}
-
-static s32 acdb_fill_audpreproc_ns(void)
-{
-	struct acdb_ns_tx_block	*acdb_ns;
-	/* TO DO: do we enable_status_filled */
-	acdb_ns = get_audpreproc_ns_block();
-	if (!acdb_ns) {
-		MM_DBG("unable to find preproc ns parameters winding up\n");
-		return -EINVAL;
-	}
-	memset(acdb_data.preproc_ns, 0, sizeof(*acdb_data.preproc_ns));
-	acdb_data.preproc_ns->cmd_id = AUDPREPROC_CMD_CFG_NS_PARAMS;
-
-	acdb_data.preproc_ns->ec_mode_new  = acdb_ns->ec_mode_new;
-	acdb_data.preproc_ns->dens_gamma_n = acdb_ns->dens_gamma_n;
-	acdb_data.preproc_ns->dens_nfe_block_size  =
-					acdb_ns->dens_nfe_block_size;
-	acdb_data.preproc_ns->dens_limit_ns = acdb_ns->dens_limit_ns;
-	acdb_data.preproc_ns->dens_limit_ns_d  = acdb_ns->dens_limit_ns_d;
-	acdb_data.preproc_ns->wb_gamma_e  = acdb_ns->wb_gamma_e;
-	acdb_data.preproc_ns->wb_gamma_n  = acdb_ns->wb_gamma_n;
-
-	return 0;
-}
-
-s32 acdb_calibrate_audpreproc(void)
-{
-	s32	result = 0;
-
-	result = acdb_fill_audpreproc_agc();
-	if (!IS_ERR_VALUE(result)) {
-		result = audpreproc_dsp_set_agc(acdb_data.preproc_agc, sizeof(
-					audpreproc_cmd_cfg_agc_params));
-		if (result) {
-			MM_ERR("ACDB=> Failed to send AGC data to preproc)\n");
-			result = -EINVAL;
-			goto done;
-		} else
-			MM_DBG("AUDPREC is calibrated with AGC parameters");
-	}
-	result = acdb_fill_audpreproc_iir();
-	if (!IS_ERR_VALUE(result)) {
-		result = audpreproc_dsp_set_iir(acdb_data.preproc_iir,
-				sizeof(\
-				audpreproc_cmd_cfg_iir_tuning_filter_params));
-		if (result) {
-			MM_ERR("ACDB=> Failed to send IIR data to preproc\n");
-			result = -EINVAL;
-			goto done;
-		} else
-			MM_DBG("audpreproc is calibrated with iir parameters");
-	}
-
-	result = acdb_fill_audpreproc_ns();
-	if (!IS_ERR_VALUE(result)) {
-		result = audpreproc_dsp_set_ns(acdb_data.preproc_ns,
-						sizeof(\
-						audpreproc_cmd_cfg_ns_params));
-		if (result) {
-			MM_ERR("ACDB=> Failed to send NS data to preproc\n");
-			result = -EINVAL;
-			goto done;
-		} else
-			MM_DBG("audpreproc is calibrated with NS parameters");
-	}
-done:
-	return result;
-}
-
-static s32 acdb_send_calibration(void)
-{
-	s32 result = 0;
-
-	if (acdb_data.device_info->dev_type.rx_device) {
-		result = acdb_calibrate_audpp();
-		if (result)
-			goto done;
-	} else if (acdb_data.device_info->dev_type.tx_device) {
-		result = acdb_calibrate_audpreproc();
-		if (result)
-			goto done;
-		acdb_data.audrec_applied |= AUDREC_READY;
-		MM_DBG("acdb_data.audrec_applied = %x\n",
-					acdb_data.audrec_applied);
-	}
-done:
-	return result;
-}
-
-static u8 check_tx_acdb_values_cached(void)
-{
-	if ((acdb_data.device_info->sample_rate ==
-		acdb_cache_tx.device_info.sample_rate) &&
-		(acdb_data.device_info->acdb_id ==
-		acdb_cache_tx.device_info.acdb_id) &&
-		(acdb_cache_tx.node_status ==
-						ACDB_VALUES_FILLED))
-		return 0;
-	else
-		return 1;
-}
-
-static void handle_tx_device_ready_callback(void)
-{
-	u8 acdb_value_apply = 0;
-	u8 result = 0;
-
-	/*check wheather AUDREC enabled before device call backs*/
-	if ((acdb_data.acdb_state & AUDREC_READY) &&
-			!(acdb_data.audrec_applied & AUDREC_READY)) {
-		MM_DBG("AUDREC already enabled apply acdb values\n");
-		acdb_value_apply |= AUDREC_READY;
-	}
-	if (acdb_value_apply) {
-		if (session_info.sampling_freq)
-			acdb_data.device_info->sample_rate =
-					session_info.sampling_freq;
-		result = check_tx_acdb_values_cached();
-		if (result) {
-			result = acdb_get_calibration();
-			if (result < 0) {
-				MM_ERR("Not able to get calibration"\
-						" data continue\n");
-				return;
-			}
-		}
-		acdb_cache_tx.node_status = ACDB_VALUES_FILLED;
-		acdb_send_calibration();
-	}
-}
-
-static struct acdb_cache_node *get_acdb_values_from_cache_tx(u32 stream_id)
-{
-	MM_DBG("searching node with stream_id");
-	if ((acdb_cache_tx.stream_id == stream_id) &&
-			(acdb_cache_tx.node_status ==
-					ACDB_VALUES_NOT_FILLED)) {
-			return &acdb_cache_tx;
-	}
-	MM_DBG("Error! in finding node\n");
-	return NULL;
-}
-
-static void update_acdb_data_struct(struct acdb_cache_node *cur_node)
-{
-	if (cur_node) {
-		acdb_data.device_info = &cur_node->device_info;
-		acdb_data.virt_addr = cur_node->virt_addr_acdb_values;
-		acdb_data.phys_addr = cur_node->phys_addr_acdb_values;
-	} else
-		MM_ERR("error in curent node\n");
-}
-
-static void send_acdb_values_for_active_devices(void)
-{
-	if (acdb_cache_rx.node_status ==
-			ACDB_VALUES_FILLED) {
-		update_acdb_data_struct(&acdb_cache_rx);
-		if (acdb_data.acdb_state & CAL_DATA_READY)
-			acdb_send_calibration();
-	}
-}
-
-static s32 initialize_rpc(void)
-{
-	s32 result = 0;
-
-	result = daldevice_attach(DALDEVICEID_ACDB, ACDB_PORT_NAME,
-			ACDB_CPU, &acdb_data.handle);
-
-	if (result) {
-		MM_ERR("ACDB=> Device Attach failed\n");
-		result = -ENODEV;
-		goto done;
-	}
-done:
-	return result;
-}
-
-static u32 allocate_memory_acdb_cache_tx(void)
-{
-	u32 result = 0;
-	/*initialize local cache */
-	acdb_cache_tx.phys_addr_acdb_values =
-		allocate_contiguous_ebi_nomap(ACDB_BUF_SIZE,
-				SZ_4K);
-
-	if (!acdb_cache_tx.phys_addr_acdb_values) {
-		MM_ERR("ACDB=> Cannot allocate physical memory\n");
-		result = -ENOMEM;
-		goto error;
-	}
-	acdb_cache_tx.map_v_addr = ioremap(
-			acdb_cache_tx.phys_addr_acdb_values,
-			ACDB_BUF_SIZE);
-	if (IS_ERR(acdb_cache_tx.map_v_addr)) {
-		MM_ERR("ACDB=> Could not map physical address\n");
-		result = -ENOMEM;
-		free_contiguous_memory_by_paddr(
-				acdb_cache_tx.phys_addr_acdb_values);
-		goto error;
-	}
-	acdb_cache_tx.virt_addr_acdb_values =
-		acdb_cache_tx.map_v_addr;
-	memset(acdb_cache_tx.virt_addr_acdb_values, 0,
-			ACDB_BUF_SIZE);
-	return result;
-error:
-	iounmap(acdb_cache_tx.map_v_addr);
-	free_contiguous_memory_by_paddr(
-			acdb_cache_tx.phys_addr_acdb_values);
-	return result;
-}
-
-static u32 allocate_memory_acdb_cache_rx(void)
-{
-	u32 result = 0;
-
-	/*initialize local cache */
-	acdb_cache_rx.phys_addr_acdb_values =
-		allocate_contiguous_ebi_nomap(
-				ACDB_BUF_SIZE, SZ_4K);
-
-	if (!acdb_cache_rx.phys_addr_acdb_values) {
-		MM_ERR("ACDB=> Can not allocate physical memory\n");
-		result = -ENOMEM;
-		goto error;
-	}
-	acdb_cache_rx.map_v_addr =
-		ioremap(acdb_cache_rx.phys_addr_acdb_values,
-				ACDB_BUF_SIZE);
-	if (IS_ERR(acdb_cache_rx.map_v_addr)) {
-		MM_ERR("ACDB=> Could not map physical address\n");
-		result = -ENOMEM;
-		free_contiguous_memory_by_paddr(
-				acdb_cache_rx.phys_addr_acdb_values);
-		goto error;
-	}
-	acdb_cache_rx.virt_addr_acdb_values =
-		acdb_cache_rx.map_v_addr;
-	memset(acdb_cache_rx.virt_addr_acdb_values, 0,
-			ACDB_BUF_SIZE);
-	return result;
-error:
-	iounmap(acdb_cache_rx.map_v_addr);
-	free_contiguous_memory_by_paddr(
-			acdb_cache_rx.phys_addr_acdb_values);
-	return result;
-}
-
-static u32 allocate_memory_acdb_get_blk(void)
-{
-	u32 result = 0;
-	acdb_data.get_blk_paddr = allocate_contiguous_ebi_nomap(
-						ACDB_BUF_SIZE, SZ_4K);
-	if (!acdb_data.get_blk_paddr) {
-		MM_ERR("ACDB=> Cannot allocate physical memory\n");
-		result = -ENOMEM;
-		goto error;
-	}
-	acdb_data.map_v_get_blk = ioremap(acdb_data.get_blk_paddr,
-					ACDB_BUF_SIZE);
-	if (IS_ERR(acdb_data.map_v_get_blk)) {
-		MM_ERR("ACDB=> Could not map physical address\n");
-		result = -ENOMEM;
-		free_contiguous_memory_by_paddr(
-					acdb_data.get_blk_paddr);
-		goto error;
-	}
-	acdb_data.get_blk_kvaddr = acdb_data.map_v_get_blk;
-	memset(acdb_data.get_blk_kvaddr, 0, ACDB_BUF_SIZE);
-error:
-	return result;
-}
-
-static void free_memory_acdb_cache_rx(void)
-{
-	iounmap(acdb_cache_rx.map_v_addr);
-	free_contiguous_memory_by_paddr(
-			acdb_cache_rx.phys_addr_acdb_values);
-}
-
-static void free_memory_acdb_cache_tx(void)
-{
-
-	iounmap(acdb_cache_tx.map_v_addr);
-	free_contiguous_memory_by_paddr(
-			acdb_cache_tx.phys_addr_acdb_values);
-}
-
-static void free_memory_acdb_get_blk(void)
-{
-	iounmap(acdb_data.map_v_get_blk);
-	free_contiguous_memory_by_paddr(acdb_data.get_blk_paddr);
-}
-
-static s32 initialize_memory(void)
-{
-	s32 result = 0;
-
-	result = allocate_memory_acdb_get_blk();
-	if (result < 0) {
-		MM_ERR("memory allocation for get blk failed\n");
-		goto done;
-	}
-
-	result = allocate_memory_acdb_cache_rx();
-	if (result < 0) {
-		MM_ERR("memory allocation for rx cache is failed\n");
-		free_memory_acdb_get_blk();
-		goto done;
-	}
-	result = allocate_memory_acdb_cache_tx();
-	if (result < 0) {
-		MM_ERR("memory allocation for tx cache is failed\n");
-		free_memory_acdb_get_blk();
-		free_memory_acdb_cache_rx();
-		goto done;
-	}
-	acdb_data.pp_iir = kmalloc(sizeof(*acdb_data.pp_iir),
-		GFP_KERNEL);
-	if (acdb_data.pp_iir == NULL) {
-		MM_ERR("ACDB=> Could not allocate postproc iir memory\n");
-		free_memory_acdb_get_blk();
-		free_memory_acdb_cache_rx();
-		free_memory_acdb_cache_tx();
-		result = -ENOMEM;
-		goto done;
-	}
-
-	acdb_data.pp_mbadrc = kmalloc(sizeof(*acdb_data.pp_mbadrc), GFP_KERNEL);
-	if (acdb_data.pp_mbadrc == NULL) {
-		MM_ERR("ACDB=> Could not allocate postproc mbadrc memory\n");
-		free_memory_acdb_get_blk();
-		free_memory_acdb_cache_rx();
-		free_memory_acdb_cache_tx();
-		kfree(acdb_data.pp_iir);
-		result = -ENOMEM;
-		goto done;
-	}
-
-	acdb_data.preproc_agc = kmalloc(sizeof(*acdb_data.preproc_agc),
-							GFP_KERNEL);
-	if (acdb_data.preproc_agc == NULL) {
-		MM_ERR("ACDB=> Could not allocate preproc agc memory\n");
-		free_memory_acdb_get_blk();
-		free_memory_acdb_cache_rx();
-		free_memory_acdb_cache_tx();
-		kfree(acdb_data.pp_iir);
-		kfree(acdb_data.pp_mbadrc);
-		result = -ENOMEM;
-		goto done;
-	}
-
-	acdb_data.preproc_iir = kmalloc(sizeof(*acdb_data.preproc_iir),
-							GFP_KERNEL);
-	if (acdb_data.preproc_iir == NULL) {
-		MM_ERR("ACDB=> Could not allocate preproc iir memory\n");
-		free_memory_acdb_get_blk();
-		free_memory_acdb_cache_rx();
-		free_memory_acdb_cache_tx();
-		kfree(acdb_data.pp_iir);
-		kfree(acdb_data.pp_mbadrc);
-		kfree(acdb_data.preproc_agc);
-		result = -ENOMEM;
-		goto done;
-	}
-
-	acdb_data.preproc_ns = kmalloc(sizeof(*acdb_data.preproc_ns),
-							GFP_KERNEL);
-	if (acdb_data.preproc_ns == NULL) {
-		MM_ERR("ACDB=> Could not allocate preproc ns memory\n");
-		free_memory_acdb_get_blk();
-		free_memory_acdb_cache_rx();
-		free_memory_acdb_cache_tx();
-		kfree(acdb_data.pp_iir);
-		kfree(acdb_data.pp_mbadrc);
-		kfree(acdb_data.preproc_agc);
-		kfree(acdb_data.preproc_iir);
-		result = -ENOMEM;
-		goto done;
-	}
-done:
-	return result;
-}
-
-static u8 check_device_change(struct dev_evt_msg device_info)
-{
-	if (!acdb_data.device_info) {
-		MM_ERR("not pointing to previous valid device detail\n");
-		return 1; /*device info will not be pointing to*/
-			/* valid device when acdb driver comes up*/
-	}
-	if ((device_info.sample_rate ==
-				acdb_data.device_info->sample_rate) &&
-		(device_info.acdb_id == acdb_data.device_info->acdb_id)) {
-		return 0;
-	}
-	return 1;
-}
-
-static void device_cb(struct dev_evt_msg *evt, void *private)
-{
-	struct cad_device_info_type dev_type;
-	struct acdb_cache_node *acdb_cache_free_node =  NULL;
-	u32 session_id = 0;
-	u8 ret = 0;
-	u8 device_change = 0;
-
-	/*if session value is zero it indicates that device call back is for
-	voice call we will drop the request as acdb values for voice call is
-	not applied from acdb driver*/
-	if (!evt->session_info) {
-		MM_DBG("no active sessions and call back is for"\
-				" voice call\n");
-		goto done;
-	}
-
-	if ((evt->dev_type.rx_device) &&
-			(evt->acdb_id == PSEUDO_ACDB_ID)) {
-		MM_INFO("device cb is for rx device with pseudo acdb id\n");
-		goto done;
-	}
-	dev_type = evt->dev_type;
-	MM_DBG("sample_rate = %d\n", evt->sample_rate);
-	MM_DBG("acdb_id = %d\n", evt->acdb_id);
-	MM_DBG("sessions = %d\n", evt->session_info);
-	MM_DBG("acdb_state = %x\n", acdb_data.acdb_state);
-	mutex_lock(&acdb_data.acdb_mutex);
-	device_change = check_device_change(*evt);
-	if (!device_change) {
-		if (dev_type.tx_device) {
-			if (!(acdb_data.acdb_state & AUDREC_READY))
-				acdb_data.audrec_applied &= ~AUDREC_READY;
-
-			acdb_data.acdb_state &= ~CAL_DATA_READY;
-			goto update_cache;
-		}
-	} else
-		/* state is updated to query the modem for values */
-		acdb_data.acdb_state &= ~CAL_DATA_READY;
-
-update_cache:
-	if (dev_type.tx_device) {
-		/*Only one recording session possible*/
-		session_id = 0;
-		acdb_cache_free_node =	&acdb_cache_tx;
-		ret  = check_device_info_already_present(
-				*evt,
-				acdb_cache_free_node);
-		acdb_cache_free_node->stream_id = session_id;
-		acdb_data.cur_tx_session = session_id;
-	} else {
-		acdb_cache_free_node = &acdb_cache_rx;
-		ret = check_device_info_already_present(*evt,
-						acdb_cache_free_node);
-		if (ret == 1) {
-			MM_DBG("got device ready call back for another "\
-					"audplay task sessions on same COPP\n");
-			mutex_unlock(&acdb_data.acdb_mutex);
-			goto done;
-		}
-	}
-	update_acdb_data_struct(acdb_cache_free_node);
-	acdb_data.device_cb_compl = 1;
-	mutex_unlock(&acdb_data.acdb_mutex);
-	wake_up(&acdb_data.wait);
-done:
-	return;
-}
-
-static s32 register_device_cb(void)
-{
-	s32 result = 0;
-	acdb_data.dev_cb.func = device_cb;
-	acdb_data.dev_cb.private = (void *)&acdb_data;
-
-	result = audmgr_register_device_info_callback(&acdb_data.dev_cb);
-
-	if (result) {
-		MM_ERR("ACDB=> Could not register device callback\n");
-		result = -ENODEV;
-		goto done;
-	}
-done:
-	return result;
-}
-
-static void audpp_cb(void *private, u32 id, u16 *msg)
-{
-	MM_DBG("\n");
-
-	if (id == AUDPP_MSG_PP_DISABLE_FEEDBACK) {
-		acdb_data.audpp_disabled_features |=
-			((uint32_t)(msg[AUDPP_DISABLE_FEATS_MSW] << 16) |
-			 msg[AUDPP_DISABLE_FEATS_LSW]);
-		MM_INFO("AUDPP disable feedback: %x",
-				acdb_data.audpp_disabled_features);
-		goto done;
-	} else if (id == AUDPP_MSG_PP_FEATS_RE_ENABLE) {
-		MM_INFO("AUDPP re-enable messaage: %x",
-				acdb_data.audpp_disabled_features);
-		acdb_data.audpp_cb_reenable_compl = 1;
-		wake_up(&acdb_data.wait);
-		return;
-	}
-
-	if (id != AUDPP_MSG_CFG_MSG)
-		goto done;
-
-	if (msg[0] == AUDPP_MSG_ENA_DIS) {
-		if (--acdb_cache_rx.stream_id <= 0) {
-			acdb_data.acdb_state &= ~AUDPP_READY;
-			acdb_cache_rx.stream_id = 0;
-			MM_DBG("AUDPP_MSG_ENA_DIS\n");
-		}
-		goto done;
-	}
-	/*stream_id is used to keep track of number of active*/
-	/*sessions active on this device*/
-	acdb_cache_rx.stream_id++;
-
-	acdb_data.acdb_state |= AUDPP_READY;
-	acdb_data.audpp_cb_compl = 1;
-	wake_up(&acdb_data.wait);
-done:
-	return;
-}
-
-static s8 handle_audpreproc_cb(void)
-{
-	struct acdb_cache_node *acdb_cached_values;
-	s8 result = 0;
-	u8 stream_id = acdb_data.preproc_stream_id;
-	acdb_data.preproc_cb_compl = 0;
-	acdb_cached_values = get_acdb_values_from_cache_tx(stream_id);
-	if (acdb_cached_values == NULL) {
-		MM_DBG("ERROR: to get chached acdb values\n");
-		return -EPERM;
-	}
-	update_acdb_data_struct(acdb_cached_values);
-
-	if (session_info.sampling_freq)
-		acdb_data.device_info->sample_rate =
-			session_info.sampling_freq;
-
-	if (!(acdb_data.acdb_state & CAL_DATA_READY)) {
-		result = check_tx_acdb_values_cached();
-		if (result) {
-			result = acdb_get_calibration();
-			if (result < 0) {
-				MM_ERR("failed to get calibration data\n");
-				return result;
-			}
-		}
-		acdb_cached_values->node_status = ACDB_VALUES_FILLED;
-	}
-	return result;
-}
-
-static void audpreproc_cb(void *private, u32 id, void *event_data)
-{
-	u8 result = 0;
-	uint16_t *msg = event_data;
-	int stream_id = 0; /* Only single tunnel mode recording supported */
-	if (id != AUDPREPROC_MSG_CMD_CFG_DONE_MSG)
-		goto done;
-
-	acdb_data.preproc_stream_id = stream_id;
-	get_audrec_session_info(&session_info);
-	MM_DBG("status_flag = %x\n", msg[0]);
-	if (msg[0]  == AUDPREPROC_MSG_STATUS_FLAG_DIS) {
-		acdb_data.acdb_state &= ~AUDREC_READY;
-		acdb_cache_tx.node_status =\
-						ACDB_VALUES_NOT_FILLED;
-		acdb_data.acdb_state &= ~CAL_DATA_READY;
-		goto done;
-	}
-	/*Following check is added to make sure that device info
-	  is updated. audpre proc layer enabled without device
-	  callback at this scenario we should not access
-	  device information
-	 */
-	if (acdb_data.device_info &&
-			session_info.sampling_freq) {
-		acdb_data.device_info->sample_rate =
-			session_info.sampling_freq;
-		result = check_tx_acdb_values_cached();
-		if (!result) {
-			MM_INFO("acdb values for the stream is" \
-					" querried from modem");
-			acdb_data.acdb_state |= CAL_DATA_READY;
-		} else {
-			acdb_data.acdb_state &= ~CAL_DATA_READY;
-		}
-	}
-	acdb_data.acdb_state |= AUDREC_READY;
-
-	acdb_data.preproc_cb_compl = 1;
-	MM_DBG("acdb_data.acdb_state = %x\n", acdb_data.acdb_state);
-	wake_up(&acdb_data.wait);
-done:
-	return;
-}
-
-static s32 register_audpp_cb(void)
-{
-	s32 result = 0;
-
-	acdb_data.audpp_cb.fn = audpp_cb;
-	acdb_data.audpp_cb.private = NULL;
-	result = audpp_register_event_callback(&acdb_data.audpp_cb);
-	if (result) {
-		MM_ERR("ACDB=> Could not register audpp callback\n");
-		result = -ENODEV;
-		goto done;
-	}
-done:
-	return result;
-}
-
-static s32 register_audpreproc_cb(void)
-{
-	s32 result = 0;
-
-	acdb_data.audpreproc_cb.fn = audpreproc_cb;
-	acdb_data.audpreproc_cb.private = NULL;
-	result = audpreproc_register_event_callback(&acdb_data.audpreproc_cb);
-	if (result) {
-		MM_ERR("ACDB=> Could not register audpreproc callback\n");
-		result = -ENODEV;
-		goto done;
-	}
-
-done:
-	return result;
-}
-
-static s32 acdb_initialize_data(void)
-{
-	s32	result = 0;
-
-	mutex_init(&acdb_data.acdb_mutex);
-
-	result = initialize_rpc();
-	if (result)
-		goto err;
-
-	result = initialize_memory();
-	if (result)
-		goto err1;
-
-	result = register_device_cb();
-	if (result)
-		goto err2;
-
-	result = register_audpp_cb();
-	if (result)
-		goto err3;
-
-	result = register_audpreproc_cb();
-	if (result)
-		goto err4;
-
-
-	return result;
-
-err4:
-	result = audpreproc_unregister_event_callback(&acdb_data.audpreproc_cb);
-	if (result)
-		MM_ERR("ACDB=> Could not unregister audpreproc callback\n");
-err3:
-	result = audpp_unregister_event_callback(&acdb_data.audpp_cb);
-	if (result)
-		MM_ERR("ACDB=> Could not unregister audpp callback\n");
-err2:
-	result = audmgr_deregister_device_info_callback(&acdb_data.dev_cb);
-	if (result)
-		MM_ERR("ACDB=> Could not unregister device callback\n");
-err1:
-	daldevice_detach(acdb_data.handle);
-	acdb_data.handle = NULL;
-err:
-	return result;
-}
-
-static s32 acdb_calibrate_device(void *data)
-{
-	s32 result = 0;
-
-	/* initialize driver */
-	result = acdb_initialize_data();
-	if (result)
-		goto done;
-
-	while (!kthread_should_stop()) {
-		MM_DBG("Waiting for call back events\n");
-		wait_event_interruptible(acdb_data.wait,
-					(acdb_data.device_cb_compl
-					| acdb_data.audpp_cb_compl
-					| acdb_data.audpp_cb_reenable_compl
-					| acdb_data.preproc_cb_compl));
-		mutex_lock(&acdb_data.acdb_mutex);
-		if (acdb_data.device_cb_compl) {
-			acdb_data.device_cb_compl = 0;
-			if (!(acdb_data.acdb_state & CAL_DATA_READY)) {
-				if (acdb_data.device_info->dev_type.rx_device) {
-					/*we need to get calibration values
-					only for RX device as resampler
-					moved to start of the pre - proc chain
-					tx calibration value will be based on
-					sampling frequency what audrec is
-					configured, calibration values for tx
-					device are fetch in audpreproc
-					callback*/
-					result = acdb_get_calibration();
-					if (result < 0) {
-						mutex_unlock(
-							&acdb_data.acdb_mutex);
-						MM_ERR("Not able to get "\
-							"calibration "\
-							"data continue\n");
-						continue;
-					}
-				}
-			}
-			MM_DBG("acdb state = %d\n",
-					 acdb_data.acdb_state);
-			if (acdb_data.device_info->dev_type.tx_device)
-				handle_tx_device_ready_callback();
-			else {
-				if (acdb_data.audpp_cb_reenable_compl) {
-					MM_INFO("Reset disabled feature flag");
-					acdb_data.audpp_disabled_features = 0;
-					acdb_data.audpp_cb_reenable_compl = 0;
-				}
-				acdb_cache_rx.node_status =\
-						ACDB_VALUES_FILLED;
-				if (acdb_data.acdb_state &
-						AUDPP_READY) {
-					MM_DBG("AUDPP already enabled "\
-							"apply acdb values\n");
-					goto apply;
-				}
-			}
-		}
-
-		if (!(acdb_data.audpp_cb_compl ||
-				acdb_data.audpp_cb_reenable_compl ||
-				acdb_data.preproc_cb_compl)) {
-			MM_DBG("need to wait for either AUDPP / AUDPREPROC "\
-					"Event\n");
-			mutex_unlock(&acdb_data.acdb_mutex);
-			continue;
-		} else {
-			MM_DBG("got audpp / preproc call back\n");
-			if (acdb_data.audpp_cb_compl) {
-				if (acdb_data.audpp_cb_reenable_compl) {
-					MM_INFO("Reset disabled feature flag");
-					acdb_data.audpp_disabled_features = 0;
-					acdb_data.audpp_cb_reenable_compl = 0;
-				}
-				send_acdb_values_for_active_devices();
-				acdb_data.audpp_cb_compl = 0;
-				mutex_unlock(&acdb_data.acdb_mutex);
-				continue;
-			} else if (acdb_data.audpp_cb_reenable_compl) {
-				acdb_re_enable_audpp();
-				acdb_data.audpp_disabled_features = 0;
-				acdb_data.audpp_cb_reenable_compl = 0;
-				mutex_unlock(&acdb_data.acdb_mutex);
-				continue;
-			} else {
-				result = handle_audpreproc_cb();
-				if (result < 0) {
-					mutex_unlock(&acdb_data.acdb_mutex);
-					continue;
-				}
-			}
-		}
-apply:
-		if (acdb_data.acdb_state & CAL_DATA_READY)
-			result = acdb_send_calibration();
-
-		mutex_unlock(&acdb_data.acdb_mutex);
-	}
-done:
-	return 0;
-}
-
-static int __init acdb_init(void)
-{
-
-	s32 result = 0;
-
-	memset(&acdb_data, 0, sizeof(acdb_data));
-	spin_lock_init(&acdb_data.dsp_lock);
-	init_waitqueue_head(&acdb_data.wait);
-	acdb_data.cb_thread_task = kthread_run(acdb_calibrate_device,
-		NULL, "acdb_cb_thread");
-
-	if (IS_ERR(acdb_data.cb_thread_task)) {
-		MM_ERR("ACDB=> Could not register cb thread\n");
-		result = -ENODEV;
-		goto err;
-	}
-
-#ifdef CONFIG_DEBUG_FS
-	/*This is RTC specific INIT used only with debugfs*/
-	if (!rtc_acdb_init())
-		MM_ERR("RTC ACDB=>INIT Failure\n");
-
-#endif
-
-	return misc_register(&acdb_misc);
-err:
-	return result;
-}
-
-static void __exit acdb_exit(void)
-{
-	s32	result = 0;
-
-	result = audmgr_deregister_device_info_callback(&acdb_data.dev_cb);
-	if (result)
-		MM_ERR("ACDB=> Could not unregister device callback\n");
-
-	result = audpp_unregister_event_callback(&acdb_data.audpp_cb);
-	if (result)
-		MM_ERR("ACDB=> Could not unregister audpp callback\n");
-
-	result = audpreproc_unregister_event_callback(&acdb_data.\
-				audpreproc_cb);
-	if (result)
-		MM_ERR("ACDB=> Could not unregister audpreproc callback\n");
-
-	result = kthread_stop(acdb_data.cb_thread_task);
-	if (result)
-		MM_ERR("ACDB=> Could not stop kthread\n");
-
-	free_memory_acdb_get_blk();
-
-	iounmap(acdb_cache_tx.map_v_addr);
-	free_contiguous_memory_by_paddr(
-			acdb_cache_tx.phys_addr_acdb_values);
-	iounmap(acdb_cache_rx.map_v_addr);
-	free_contiguous_memory_by_paddr(
-			acdb_cache_rx.phys_addr_acdb_values);
-	kfree(acdb_data.device_info);
-	kfree(acdb_data.pp_iir);
-	kfree(acdb_data.pp_mbadrc);
-	kfree(acdb_data.preproc_agc);
-	kfree(acdb_data.preproc_iir);
-	kfree(acdb_data.preproc_ns);
-	mutex_destroy(&acdb_data.acdb_mutex);
-	memset(&acdb_data, 0, sizeof(acdb_data));
-	#ifdef CONFIG_DEBUG_FS
-	rtc_acdb_deinit();
-	#endif
-}
-
-late_initcall(acdb_init);
-module_exit(acdb_exit);
-
-MODULE_DESCRIPTION("MSM 8x25 Audio ACDB driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5/audio_amrnb.c b/arch/arm/mach-msm/qdsp5/audio_amrnb.c
deleted file mode 100644
index d32dc4f..0000000
--- a/arch/arm/mach-msm/qdsp5/audio_amrnb.c
+++ /dev/null
@@ -1,1707 +0,0 @@
-/* linux/arch/arm/mach-msm/qdsp5/audio_amrnb.c
- *
- * amrnb audio decoder device
- *
- * Copyright (c) 2008-2009, 2011-2013 The Linux Foundation. All rights reserved.
- *
- * Based on the mp3 native driver in arch/arm/mach-msm/qdsp5/audio_mp3.c
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- *
- * All source code in this file is licensed under the following license except
- * where indicated.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you can find it at http://www.fsf.org
- */
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/list.h>
-#include <linux/earlysuspend.h>
-#include <linux/slab.h>
-#include <linux/msm_audio.h>
-#include <linux/memory_alloc.h>
-#include <linux/msm_ion.h>
-
-#include <mach/msm_adsp.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/qdsp5/qdsp5audppcmdi.h>
-#include <mach/qdsp5/qdsp5audppmsg.h>
-#include <mach/qdsp5/qdsp5audplaycmdi.h>
-#include <mach/qdsp5/qdsp5audplaymsg.h>
-#include <mach/qdsp5/qdsp5audpp.h>
-#include <mach/qdsp5/qdsp5rmtcmdi.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_memtypes.h>
-
-#include "audmgr.h"
-
-#define BUFSZ 1024 /* Hold minimum 700ms voice data and 14 bytes of meta in*/
-#define DMASZ (BUFSZ * 2)
-
-#define AUDPLAY_INVALID_READ_PTR_OFFSET	0xFFFF
-#define AUDDEC_DEC_AMRNB 10
-
-#define PCM_BUFSZ_MIN 1624 /* 100ms worth of data and 24 bytes of meta out*/
-#define AMRNB_DECODED_FRSZ 320 /* AMR-NB 20ms 8KHz mono PCM size */
-#define PCM_BUF_MAX_COUNT 5	/* DSP only accepts 5 buffers at most
-				   but support 2 buffers currently */
-#define ROUTING_MODE_FTRT 1
-#define ROUTING_MODE_RT 2
-/* Decoder status received from AUDPPTASK */
-#define  AUDPP_DEC_STATUS_SLEEP	0
-#define	 AUDPP_DEC_STATUS_INIT  1
-#define  AUDPP_DEC_STATUS_CFG   2
-#define  AUDPP_DEC_STATUS_PLAY  3
-
-#define AUDAMRNB_METAFIELD_MASK 0xFFFF0000
-#define AUDAMRNB_EOS_FLG_OFFSET 0x0A /* Offset from beginning of buffer */
-#define AUDAMRNB_EOS_FLG_MASK 0x01
-#define AUDAMRNB_EOS_NONE 0x0 /* No EOS detected */
-#define AUDAMRNB_EOS_SET 0x1 /* EOS set in meta field */
-
-#define AUDAMRNB_EVENT_NUM 10 /* Default number of pre-allocated event pkts */
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;		/* Input usage actual DSP produced PCM size  */
-	unsigned addr;
-	unsigned short mfield_sz; /*only useful for data has meta field */
-};
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-struct audamrnb_suspend_ctl {
-	struct early_suspend node;
-	struct audio *audio;
-};
-#endif
-
-struct audamrnb_event{
-	struct list_head list;
-	int event_type;
-	union msm_audio_event_payload payload;
-};
-
-struct audio {
-	struct buffer out[2];
-
-	spinlock_t dsp_lock;
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed;	/* number of buffers the dsp is waiting for */
-
-	atomic_t out_bytes;
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-
-	/* Host PCM section */
-	struct buffer in[PCM_BUF_MAX_COUNT];
-	struct mutex read_lock;
-	wait_queue_head_t read_wait;	/* Wait queue for read */
-	char *read_data;	/* pointer to reader buffer */
-	int32_t read_phys;	/* physical address of reader buffer */
-	uint8_t read_next;	/* index to input buffers to be read next */
-	uint8_t fill_next;	/* index to buffer that DSP should be filling */
-	uint8_t pcm_buf_count;	/* number of pcm buffer allocated */
-	/* ---- End of Host PCM section */
-
-	struct msm_adsp_module *audplay;
-
-	struct audmgr audmgr;
-
-	/* data allocated for various buffers */
-	char *data;
-	int32_t phys; /* physical address of write buffer */
-	void *map_v_read;
-	void *map_v_write;
-
-
-	int mfield; /* meta field embedded in data */
-	int rflush; /* Read  flush */
-	int wflush; /* Write flush */
-	uint8_t opened:1;
-	uint8_t enabled:1;
-	uint8_t running:1;
-	uint8_t stopped:1;	/* set when stopped, cleared on flush */
-	uint8_t pcm_feedback:1;
-	uint8_t buf_refresh:1;
-	int teos; /* valid only if tunnel mode & no data left for decoder */
-	enum msm_aud_decoder_state dec_state;	/* Represents decoder state */
-	int rmt_resource_released;
-
-	const char *module_name;
-	unsigned queue_id;
-	uint16_t dec_id;
-	uint32_t read_ptr_offset;
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	struct audamrnb_suspend_ctl suspend_ctl;
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *dentry;
-#endif
-
-	wait_queue_head_t wait;
-	struct list_head free_event_queue;
-	struct list_head event_queue;
-	wait_queue_head_t event_wait;
-	spinlock_t event_queue_lock;
-	struct mutex get_event_lock;
-	int event_abort;
-
-	int eq_enable;
-	int eq_needs_commit;
-	audpp_cmd_cfg_object_params_eqalizer eq;
-	audpp_cmd_cfg_object_params_volume vol_pan;
-	struct ion_client *client;
-	struct ion_handle *input_buff_handle;
-	struct ion_handle *output_buff_handle;
-};
-
-struct audpp_cmd_cfg_adec_params_amrnb {
-   audpp_cmd_cfg_adec_params_common     common;
-   unsigned short                       stereo_cfg;
-} __attribute__((packed)) ;
-
-static int auddec_dsp_config(struct audio *audio, int enable);
-static void audpp_cmd_cfg_adec_params(struct audio *audio);
-static void audpp_cmd_cfg_routing_mode(struct audio *audio);
-static void audamrnb_send_data(struct audio *audio, unsigned needed);
-static void audamrnb_config_hostpcm(struct audio *audio);
-static void audamrnb_buffer_refresh(struct audio *audio);
-static void audamrnb_dsp_event(void *private, unsigned id, uint16_t *msg);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audamrnb_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload);
-#endif
-
-static int rmt_put_resource(struct audio *audio)
-{
-	struct aud_codec_config_cmd cmd;
-	unsigned short client_idx;
-
-	cmd.cmd_id = RM_CMD_AUD_CODEC_CFG;
-	cmd.client_id = RM_AUD_CLIENT_ID;
-	cmd.task_id = audio->dec_id;
-	cmd.enable = RMT_DISABLE;
-	cmd.dec_type = AUDDEC_DEC_AMRNB;
-	client_idx = ((cmd.client_id << 8) | cmd.task_id);
-
-	return put_adsp_resource(client_idx, &cmd, sizeof(cmd));
-}
-
-static int rmt_get_resource(struct audio *audio)
-{
-	struct aud_codec_config_cmd cmd;
-	unsigned short client_idx;
-
-	cmd.cmd_id = RM_CMD_AUD_CODEC_CFG;
-	cmd.client_id = RM_AUD_CLIENT_ID;
-	cmd.task_id = audio->dec_id;
-	cmd.enable = RMT_ENABLE;
-	cmd.dec_type = AUDDEC_DEC_AMRNB;
-	client_idx = ((cmd.client_id << 8) | cmd.task_id);
-
-	return get_adsp_resource(client_idx, &cmd, sizeof(cmd));
-}
-
-/* must be called with audio->lock held */
-static int audamrnb_enable(struct audio *audio)
-{
-	struct audmgr_config cfg;
-	int rc;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled)
-		return 0;
-
-	if (audio->rmt_resource_released == 1) {
-		audio->rmt_resource_released = 0;
-		rc = rmt_get_resource(audio);
-		if (rc) {
-			MM_ERR("ADSP resources are not available for AMRNB \
-				session 0x%08x on decoder: %d\n Ignoring \
-				error and going ahead with the playback\n",
-				(int)audio, audio->dec_id);
-		}
-	}
-
-	audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-
-	if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK) {
-		cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE;
-		cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000;
-		cfg.def_method = RPC_AUD_DEF_METHOD_PLAYBACK;
-		cfg.codec = RPC_AUD_DEF_CODEC_AMR_NB;
-		cfg.snd_method = RPC_SND_METHOD_MIDI;
-
-		rc = audmgr_enable(&audio->audmgr, &cfg);
-		if (rc < 0) {
-			msm_adsp_dump(audio->audplay);
-			return rc;
-		}
-	}
-
-	if (msm_adsp_enable(audio->audplay)) {
-		MM_ERR("msm_adsp_enable(audplay) failed\n");
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_disable(&audio->audmgr);
-		return -ENODEV;
-	}
-
-	if (audpp_enable(audio->dec_id, audamrnb_dsp_event, audio)) {
-		MM_ERR("audpp_enable() failed\n");
-		msm_adsp_disable(audio->audplay);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_disable(&audio->audmgr);
-		return -ENODEV;
-	}
-	audio->enabled = 1;
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audamrnb_disable(struct audio *audio)
-{
-	int rc = 0;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-		auddec_dsp_config(audio, 0);
-		rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-		if (rc == 0)
-			rc = -ETIMEDOUT;
-		else if (audio->dec_state != MSM_AUD_DECODER_STATE_CLOSE)
-			rc = -EFAULT;
-		else
-			rc = 0;
-		audio->stopped = 1;
-		wake_up(&audio->write_wait);
-		wake_up(&audio->read_wait);
-		msm_adsp_disable(audio->audplay);
-		audpp_disable(audio->dec_id, audio);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK) {
-			rc = audmgr_disable(&audio->audmgr);
-			if (rc < 0)
-				msm_adsp_dump(audio->audplay);
-		}
-		audio->out_needed = 0;
-		rmt_put_resource(audio);
-		audio->rmt_resource_released = 1;
-	}
-	return rc;
-}
-
-/* ------------------- dsp --------------------- */
-static void audamrnb_update_pcm_buf_entry(struct audio *audio,
-		uint32_t *payload)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	if (audio->rflush)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < payload[1]; index++) {
-		if (audio->in[audio->fill_next].addr ==
-		    payload[2 + index * 2]) {
-			MM_DBG("in[%d] ready\n", audio->fill_next);
-			audio->in[audio->fill_next].used =
-			    payload[3 + index * 2];
-			if ((++audio->fill_next) == audio->pcm_buf_count)
-				audio->fill_next = 0;
-
-		} else {
-			MM_ERR("expected=%x ret=%x\n",
-				audio->in[audio->fill_next].addr,
-				payload[1 + index * 2]);
-			break;
-		}
-	}
-	if (audio->in[audio->fill_next].used == 0) {
-		audamrnb_buffer_refresh(audio);
-	} else {
-		MM_DBG("read cannot keep up\n");
-		audio->buf_refresh = 1;
-	}
-	wake_up(&audio->read_wait);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audplay_dsp_event(void *data, unsigned id, size_t len,
-			      void (*getevent) (void *ptr, size_t len))
-{
-	struct audio *audio = data;
-	uint32_t msg[28];
-	getevent(msg, sizeof(msg));
-
-	MM_DBG("msg_id=%x\n", id);
-
-	switch (id) {
-	case AUDPLAY_MSG_DEC_NEEDS_DATA:
-		audamrnb_send_data(audio, 1);
-		break;
-
-	case AUDPLAY_MSG_BUFFER_UPDATE:
-		audamrnb_update_pcm_buf_entry(audio, msg);
-		break;
-
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audplaytask)\n");
-		break;
-
-	default:
-		MM_ERR("unexpected message from decoder\n");
-	}
-}
-
-static void audamrnb_dsp_event(void *private, unsigned id, uint16_t *msg)
-{
-	struct audio *audio = private;
-
-	switch (id) {
-	case AUDPP_MSG_STATUS_MSG:{
-			unsigned status = msg[1];
-
-			switch (status) {
-			case AUDPP_DEC_STATUS_SLEEP: {
-				uint16_t reason = msg[2];
-				MM_DBG("decoder status:sleep reason = \
-						0x%04x\n", reason);
-				if ((reason == AUDPP_MSG_REASON_MEM)
-					|| (reason ==
-					AUDPP_MSG_REASON_NODECODER)) {
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_FAILURE;
-					wake_up(&audio->wait);
-				} else if (reason == AUDPP_MSG_REASON_NONE) {
-					/* decoder is in disable state */
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_CLOSE;
-					wake_up(&audio->wait);
-				}
-				break;
-			}
-			case AUDPP_DEC_STATUS_INIT:
-				MM_DBG("decoder status: init \n");
-				if (audio->pcm_feedback)
-					audpp_cmd_cfg_routing_mode(audio);
-				else
-					audpp_cmd_cfg_adec_params(audio);
-				break;
-
-			case AUDPP_DEC_STATUS_CFG:
-				MM_DBG("decoder status: cfg \n");
-				break;
-			case AUDPP_DEC_STATUS_PLAY:
-				MM_DBG("decoder status: play \n");
-				if (audio->pcm_feedback) {
-					audamrnb_config_hostpcm(audio);
-					audamrnb_buffer_refresh(audio);
-				}
-				audio->dec_state =
-					MSM_AUD_DECODER_STATE_SUCCESS;
-				wake_up(&audio->wait);
-				break;
-			default:
-				MM_ERR("unknown decoder status \n");
-				break;
-			}
-			break;
-		}
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_DBG("CFG_MSG ENABLE\n");
-			auddec_dsp_config(audio, 1);
-			audio->out_needed = 0;
-			audio->running = 1;
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-			audpp_dsp_set_eq(audio->dec_id,	audio->eq_enable,
-								&audio->eq);
-			audpp_avsync(audio->dec_id, 22050);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			MM_DBG("CFG_MSG DISABLE\n");
-			audpp_avsync(audio->dec_id, 0);
-			audio->running = 0;
-		} else {
-			MM_DBG("CFG_MSG %d?\n", msg[0]);
-		}
-		break;
-	case AUDPP_MSG_ROUTING_ACK:
-		MM_DBG("ROUTING_ACK mode=%d\n", msg[1]);
-		audpp_cmd_cfg_adec_params(audio);
-		break;
-	case AUDPP_MSG_FLUSH_ACK:
-		MM_DBG("FLUSH_ACK\n");
-		audio->wflush = 0;
-		audio->rflush = 0;
-		wake_up(&audio->write_wait);
-		if (audio->pcm_feedback)
-			audamrnb_buffer_refresh(audio);
-		break;
-	case AUDPP_MSG_PCMDMAMISSED:
-		MM_DBG("PCMDMAMISSED\n");
-		audio->teos = 1;
-		wake_up(&audio->write_wait);
-		break;
-	default:
-		MM_ERR("UNKNOWN (%d)\n", id);
-	}
-
-}
-
-struct msm_adsp_ops audplay_adsp_ops_amrnb = {
-	.event = audplay_dsp_event,
-};
-
-#define audplay_send_queue0(audio, cmd, len) \
-	msm_adsp_write(audio->audplay, audio->queue_id, \
-			cmd, len)
-
-static int auddec_dsp_config(struct audio *audio, int enable)
-{
-	u16 cfg_dec_cmd[AUDPP_CMD_CFG_DEC_TYPE_LEN / sizeof(unsigned short)];
-
-	memset(cfg_dec_cmd, 0, sizeof(cfg_dec_cmd));
-	cfg_dec_cmd[0] = AUDPP_CMD_CFG_DEC_TYPE;
-	if (enable)
-		cfg_dec_cmd[1 + audio->dec_id] = AUDPP_CMD_UPDATDE_CFG_DEC |
-			AUDPP_CMD_ENA_DEC_V | AUDDEC_DEC_AMRNB;
-	else
-		cfg_dec_cmd[1 + audio->dec_id] = AUDPP_CMD_UPDATDE_CFG_DEC |
-			AUDPP_CMD_DIS_DEC_V;
-
-	return audpp_send_queue1(&cfg_dec_cmd, sizeof(cfg_dec_cmd));
-}
-
-static void audpp_cmd_cfg_adec_params(struct audio *audio)
-{
-	struct audpp_cmd_cfg_adec_params_amrnb cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_CMD_CFG_ADEC_PARAMS;
-	cmd.common.length = AUDPP_CMD_CFG_ADEC_PARAMS_V13K_LEN;
-	cmd.common.dec_id = audio->dec_id;
-	cmd.common.input_sampling_frequency = 8000;
-	cmd.stereo_cfg = AUDPP_CMD_PCM_INTF_MONO_V;
-
-	audpp_send_queue2(&cmd, sizeof(cmd));
-}
-
-static void audpp_cmd_cfg_routing_mode(struct audio *audio)
-{
-	struct audpp_cmd_routing_mode cmd;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPP_CMD_ROUTING_MODE;
-	cmd.object_number = audio->dec_id;
-	if (audio->pcm_feedback)
-		cmd.routing_mode = ROUTING_MODE_FTRT;
-	else
-		cmd.routing_mode = ROUTING_MODE_RT;
-
-	audpp_send_queue1(&cmd, sizeof(cmd));
-}
-
-static int audplay_dsp_send_data_avail(struct audio *audio,
-				       unsigned idx, unsigned len)
-{
-	struct audplay_cmd_bitstream_data_avail_nt2 cmd;
-
-	cmd.cmd_id = AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2;
-	if (audio->mfield)
-		cmd.decoder_id = AUDAMRNB_METAFIELD_MASK |
-			(audio->out[idx].mfield_sz >> 1);
-	else
-		cmd.decoder_id = audio->dec_id;
-	cmd.buf_ptr = audio->out[idx].addr;
-	cmd.buf_size = len / 2;
-	cmd.partition_number = 0;
-	/* complete writes to the input buffer */
-	wmb();
-	return audplay_send_queue0(audio, &cmd, sizeof(cmd));
-}
-
-static void audamrnb_buffer_refresh(struct audio *audio)
-{
-	struct audplay_cmd_buffer_refresh refresh_cmd;
-
-	refresh_cmd.cmd_id = AUDPLAY_CMD_BUFFER_REFRESH;
-	refresh_cmd.num_buffers = 1;
-	refresh_cmd.buf0_address = audio->in[audio->fill_next].addr;
-	refresh_cmd.buf0_length = audio->in[audio->fill_next].size -
-	  (audio->in[audio->fill_next].size % AMRNB_DECODED_FRSZ) +
-	  (audio->mfield ? 24 : 0);
-	refresh_cmd.buf_read_count = 0;
-	MM_DBG("buf0_addr=%x buf0_len=%d\n", refresh_cmd.buf0_address,
-			refresh_cmd.buf0_length);
-	(void)audplay_send_queue0(audio, &refresh_cmd, sizeof(refresh_cmd));
-}
-
-static void audamrnb_config_hostpcm(struct audio *audio)
-{
-	struct audplay_cmd_hpcm_buf_cfg cfg_cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	cfg_cmd.cmd_id = AUDPLAY_CMD_HPCM_BUF_CFG;
-	cfg_cmd.max_buffers = audio->pcm_buf_count;
-	cfg_cmd.byte_swap = 0;
-	cfg_cmd.hostpcm_config = (0x8000) | (0x4000);
-	cfg_cmd.feedback_frequency = 1;
-	cfg_cmd.partition_number = 0;
-	(void)audplay_send_queue0(audio, &cfg_cmd, sizeof(cfg_cmd));
-
-}
-
-static void audamrnb_send_data(struct audio *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			MM_DBG("frame %d busy\n", audio->out_tail);
-			audplay_dsp_send_data_avail(audio, audio->out_tail,
-						    frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
- done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-
-static void audamrnb_flush(struct audio *audio)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->out[0].used = 0;
-	audio->out[1].used = 0;
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	atomic_set(&audio->out_bytes, 0);
-}
-
-static void audamrnb_flush_pcm_buf(struct audio *audio)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < PCM_BUF_MAX_COUNT; index++)
-		audio->in[index].used = 0;
-
-	audio->buf_refresh = 0;
-	audio->read_next = 0;
-	audio->fill_next = 0;
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audamrnb_ioport_reset(struct audio *audio)
-{
-	/* Make sure read/write thread are free from
-	 * sleep and knowing that system is not able
-	 * to process io request at the moment
-	 */
-	wake_up(&audio->write_wait);
-	mutex_lock(&audio->write_lock);
-	audamrnb_flush(audio);
-	mutex_unlock(&audio->write_lock);
-	wake_up(&audio->read_wait);
-	mutex_lock(&audio->read_lock);
-	audamrnb_flush_pcm_buf(audio);
-	mutex_unlock(&audio->read_lock);
-}
-
-static int audamrnb_events_pending(struct audio *audio)
-{
-	unsigned long flags;
-	int empty;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	empty = !list_empty(&audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	return empty || audio->event_abort;
-}
-
-static void audamrnb_reset_event_queue(struct audio *audio)
-{
-	unsigned long flags;
-	struct audamrnb_event *drv_evt;
-	struct list_head *ptr, *next;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	list_for_each_safe(ptr, next, &audio->event_queue) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audamrnb_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	list_for_each_safe(ptr, next, &audio->free_event_queue) {
-		drv_evt = list_first_entry(&audio->free_event_queue,
-				struct audamrnb_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	return;
-}
-
-static long audamrnb_process_event_req(struct audio *audio, void __user *arg)
-{
-	long rc;
-	struct msm_audio_event usr_evt;
-	struct audamrnb_event *drv_evt = NULL;
-	int timeout;
-	unsigned long flags;
-
-	if (copy_from_user(&usr_evt, arg, sizeof(struct msm_audio_event)))
-		return -EFAULT;
-
-	timeout = (int) usr_evt.timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(
-			audio->event_wait, audamrnb_events_pending(audio),
-			msecs_to_jiffies(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(
-			audio->event_wait, audamrnb_events_pending(audio));
-	}
-
-	if (rc < 0)
-		return rc;
-
-	if (audio->event_abort) {
-		audio->event_abort = 0;
-		return -ENODEV;
-	}
-
-	rc = 0;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	if (!list_empty(&audio->event_queue)) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audamrnb_event, list);
-		list_del(&drv_evt->list);
-	}
-
-	if (drv_evt) {
-		usr_evt.event_type = drv_evt->event_type;
-		usr_evt.event_payload = drv_evt->payload;
-		list_add_tail(&drv_evt->list, &audio->free_event_queue);
-	} else
-		rc = -1;
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	if (!rc && copy_to_user(arg, &usr_evt, sizeof(usr_evt)))
-		rc = -EFAULT;
-
-	return rc;
-}
-
-static int audio_enable_eq(struct audio *audio, int enable)
-{
-	if (audio->eq_enable == enable && !audio->eq_needs_commit)
-		return 0;
-
-	audio->eq_enable = enable;
-
-	if (audio->running) {
-		audpp_dsp_set_eq(audio->dec_id, enable, &audio->eq);
-		audio->eq_needs_commit = 0;
-	}
-	return 0;
-}
-
-static long audamrnb_ioctl(struct file *file, unsigned int cmd,
-		unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = -EINVAL;
-	unsigned long flags = 0;
-	uint16_t enable_mask;
-	int enable;
-	int prev_state;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	int len = 0;
-
-	MM_DBG("cmd = %d\n", cmd);
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		stats.byte_count = audpp_avsync_byte_count(audio->dec_id);
-		stats.sample_count = audpp_avsync_sample_count(audio->dec_id);
-		if (copy_to_user((void *)arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-
-	switch (cmd) {
-	case AUDIO_ENABLE_AUDPP:
-		if (copy_from_user(&enable_mask, (void *) arg,
-						sizeof(enable_mask))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		enable = (enable_mask & EQ_ENABLE) ? 1 : 0;
-		audio_enable_eq(audio, enable);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-	case AUDIO_SET_VOLUME:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.volume = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_PAN:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.pan = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_EQ:
-		prev_state = audio->eq_enable;
-		audio->eq_enable = 0;
-		if (copy_from_user(&audio->eq.num_bands, (void *) arg,
-				sizeof(audio->eq) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2))) {
-			rc = -EFAULT;
-			break;
-		}
-		audio->eq_enable = prev_state;
-		audio->eq_needs_commit = 1;
-		rc = 0;
-		break;
-	}
-
-	if (-EINVAL != rc)
-		return rc;
-
-	if (cmd == AUDIO_GET_EVENT) {
-		MM_DBG("AUDIO_GET_EVENT\n");
-		if (mutex_trylock(&audio->get_event_lock)) {
-			rc = audamrnb_process_event_req(audio,
-					(void __user *) arg);
-			mutex_unlock(&audio->get_event_lock);
-		} else
-			rc = -EBUSY;
-		return rc;
-	}
-
-	if (cmd == AUDIO_ABORT_GET_EVENT) {
-		audio->event_abort = 1;
-		wake_up(&audio->event_wait);
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		MM_DBG("AUDIO_START\n");
-		rc = audamrnb_enable(audio);
-		if (!rc) {
-			rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-			MM_INFO("dec_state %d rc = %d\n", audio->dec_state, rc);
-
-			if (audio->dec_state != MSM_AUD_DECODER_STATE_SUCCESS)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		break;
-	case AUDIO_STOP:
-		MM_DBG("AUDIO_STOP\n");
-		rc = audamrnb_disable(audio);
-		audamrnb_ioport_reset(audio);
-		audio->stopped = 0;
-		break;
-	case AUDIO_FLUSH:
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audamrnb_ioport_reset(audio);
-		if (audio->running) {
-			audpp_flush(audio->dec_id);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-	case AUDIO_SET_CONFIG:{
-			struct msm_audio_config config;
-			if (copy_from_user
-			    (&config, (void *)arg, sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-			audio->mfield = config.meta_field;
-			rc = 0;
-			break;
-		}
-	case AUDIO_GET_CONFIG:{
-			struct msm_audio_config config;
-			config.buffer_size = BUFSZ;
-			config.buffer_count = 2;
-			config.sample_rate = 8000;
-			config.channel_count = 1;
-			config.meta_field = 0;
-			config.unused[0] = 0;
-			config.unused[1] = 0;
-			config.unused[2] = 0;
-			if (copy_to_user((void *)arg, &config,
-					 sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-
-			break;
-		}
-	case AUDIO_GET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			config.pcm_feedback = audio->pcm_feedback;
-			config.buffer_count = PCM_BUF_MAX_COUNT;
-			config.buffer_size = PCM_BUFSZ_MIN;
-			if (copy_to_user((void *)arg, &config,
-					 sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_SET_PCM_CONFIG:{
-		struct msm_audio_pcm_config config;
-		if (copy_from_user
-		    (&config, (void *)arg, sizeof(config))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (config.pcm_feedback != audio->pcm_feedback) {
-			MM_ERR("Not sufficient permission to"
-				 "change the playback mode\n");
-			rc = -EACCES;
-			break;
-		}
-		if ((config.buffer_count > PCM_BUF_MAX_COUNT) ||
-		    (config.buffer_count == 1))
-			config.buffer_count = PCM_BUF_MAX_COUNT;
-
-		if (config.buffer_size < PCM_BUFSZ_MIN)
-			config.buffer_size = PCM_BUFSZ_MIN;
-
-			/* Check if pcm feedback is required */
-		if ((config.pcm_feedback) && (!audio->read_data)) {
-			MM_DBG("allocate PCM buf %d\n",
-					config.buffer_count *
-					config.buffer_size);
-				handle = ion_alloc(audio->client,
-					(config.buffer_size *
-					config.buffer_count),
-					SZ_4K, ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-				if (IS_ERR_OR_NULL(handle)) {
-					MM_ERR("Unable to alloc I/P buffs\n");
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-					break;
-				}
-
-				audio->input_buff_handle = handle;
-
-				rc = ion_phys(audio->client ,
-					handle, &addr, &len);
-				if (rc) {
-					MM_ERR("Invalid phy: %x sz: %x\n",
-						(unsigned int) addr,
-						(unsigned int) len);
-					ion_free(audio->client, handle);
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-					break;
-				} else {
-					MM_INFO("Got valid phy: %x sz: %x\n",
-						(unsigned int) audio->read_phys,
-						(unsigned int) len);
-				}
-				audio->read_phys = (int32_t)addr;
-
-				rc = ion_handle_get_flags(audio->client,
-					handle, &ionflag);
-				if (rc) {
-					MM_ERR("could not get flags\n");
-					ion_free(audio->client, handle);
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-					break;
-				}
-				audio->map_v_read = ion_map_kernel(
-					audio->client, handle);
-			if (IS_ERR(audio->map_v_read)) {
-				MM_ERR("failed to map read buf\n");
-				ion_free(audio->client, handle);
-				audio->input_buff_handle = NULL;
-				rc = -ENOMEM;
-			} else {
-				uint8_t index;
-				uint32_t offset = 0;
-				audio->read_data =
-						audio->map_v_read;
-				audio->buf_refresh = 0;
-				audio->pcm_buf_count =
-					config.buffer_count;
-				audio->read_next = 0;
-				audio->fill_next = 0;
-
-				for (index = 0;
-				index < config.buffer_count; index++) {
-					audio->in[index].data =
-						audio->read_data + offset;
-					audio->in[index].addr =
-					    audio->read_phys + offset;
-					audio->in[index].size =
-					    config.buffer_size;
-					audio->in[index].used = 0;
-					offset += config.buffer_size;
-				}
-				MM_DBG("read buf: phy addr 0x%08x kernel \
-					addr 0x%08x\n", audio->read_phys,
-					(int)audio->read_data);
-				rc = 0;
-			}
-		} else {
-			rc = 0;
-		}
-		break;
-	}
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-/* Only useful in tunnel-mode */
-static int audamrnb_fsync(struct file *file, loff_t a, loff_t b, int datasync)
-{
-	struct audio *audio = file->private_data;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	if (!audio->running || audio->pcm_feedback) {
-		rc = -EINVAL;
-		goto done_nolock;
-	}
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(!audio->out[0].used &&
-		!audio->out[1].used &&
-		audio->out_needed) || audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		audio->teos || audio->wflush);
-
-	if (audio->wflush)
-		rc = -EBUSY;
-
-done:
-	mutex_unlock(&audio->write_lock);
-done_nolock:
-	return rc;
-}
-
-static ssize_t audamrnb_read(struct file *file, char __user *buf, size_t count,
-			  loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	int rc = 0;
-
-	if (!audio->pcm_feedback)
-		return 0; /* PCM feedback is not enabled. Nothing to read */
-
-	mutex_lock(&audio->read_lock);
-	MM_DBG("%d \n",	count);
-	while (count > 0) {
-		rc = wait_event_interruptible(audio->read_wait,
-			(audio->in[audio->read_next].used > 0) ||
-			(audio->stopped) || (audio->rflush));
-
-		if (rc < 0)
-			break;
-
-		if (audio->stopped || audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (count < audio->in[audio->read_next].used) {
-			/* Read must happen in frame boundary. Since driver does
-			 * not know frame size, read count must be greater or
-			 * equal to size of PCM samples
-			 */
-			MM_DBG("read stop - partial frame\n");
-			break;
-		} else {
-			MM_DBG("read from in[%d]\n", audio->read_next);
-			/* order reads from the output buffer */
-			rmb();
-			if (copy_to_user
-			    (buf, audio->in[audio->read_next].data,
-			     audio->in[audio->read_next].used)) {
-				MM_ERR("invalid addr %x \n", (unsigned int)buf);
-				rc = -EFAULT;
-				break;
-			}
-			count -= audio->in[audio->read_next].used;
-			buf += audio->in[audio->read_next].used;
-			audio->in[audio->read_next].used = 0;
-			if ((++audio->read_next) == audio->pcm_buf_count)
-				audio->read_next = 0;
-			break;
-		}
-	}
-
-	/* don't feed output buffer to HW decoder during flushing
-	 * buffer refresh command will be sent once flush completes
-	 * send buf refresh command here can confuse HW decoder
-	 */
-	if (audio->buf_refresh && !audio->rflush) {
-		audio->buf_refresh = 0;
-		MM_DBG("kick start pcm feedback again\n");
-		audamrnb_buffer_refresh(audio);
-	}
-
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		rc = buf - start;
-
-	MM_DBG("read %d bytes\n", rc);
-	return rc;
-}
-
-static int audamrnb_process_eos(struct audio *audio,
-		const char __user *buf_start, unsigned short mfield_size)
-{
-	int rc = 0;
-	struct buffer *frame;
-
-	frame = audio->out + audio->out_head;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	audamrnb_send_data(audio, 0);
-
-done:
-	return rc;
-}
-
-static ssize_t audamrnb_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	size_t xfer;
-	char *cpy_ptr;
-	int rc = 0, eos_condition = AUDAMRNB_EOS_NONE;
-	unsigned short mfield_size = 0;
-
-	MM_DBG("cnt=%d\n", count);
-
-	if (count & 1)
-		return -EINVAL;
-
-	mutex_lock(&audio->write_lock);
-	while (count > 0) {
-		frame = audio->out + audio->out_head;
-		cpy_ptr = frame->data;
-		rc = wait_event_interruptible(audio->write_wait,
-					      (frame->used == 0)
-						|| (audio->stopped)
-						|| (audio->wflush));
-
-		MM_DBG("buffer available\n");
-		if (rc < 0)
-			break;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (audio->mfield) {
-			if (buf == start) {
-				/* Processing beginning of user buffer */
-				if (__get_user(mfield_size,
-					(unsigned short __user *) buf)) {
-					rc = -EFAULT;
-					break;
-				} else 	if (mfield_size > count) {
-					rc = -EINVAL;
-					break;
-				}
-				MM_DBG("mf offset_val %x\n", mfield_size);
-				if (copy_from_user(cpy_ptr, buf, mfield_size)) {
-					rc = -EFAULT;
-					break;
-				}
-				/* Check if EOS flag is set and buffer
-				 * contains just meta field
-				 */
-				if (cpy_ptr[AUDAMRNB_EOS_FLG_OFFSET] &
-						AUDAMRNB_EOS_FLG_MASK) {
-					MM_DBG("eos set\n");
-					eos_condition = AUDAMRNB_EOS_SET;
-					if (mfield_size == count) {
-						buf += mfield_size;
-						break;
-					} else
-					cpy_ptr[AUDAMRNB_EOS_FLG_OFFSET] &=
-							~AUDAMRNB_EOS_FLG_MASK;
-				}
-				cpy_ptr += mfield_size;
-				count -= mfield_size;
-				buf += mfield_size;
-			} else {
-				mfield_size = 0;
-				MM_DBG("continuous buffer\n");
-			}
-			frame->mfield_sz = mfield_size;
-		}
-
-		xfer = (count > (frame->size - mfield_size)) ?
-			(frame->size - mfield_size) : count;
-		if (copy_from_user(cpy_ptr, buf, xfer)) {
-			rc = -EFAULT;
-			break;
-		}
-
-		frame->used = (xfer + mfield_size);
-		audio->out_head ^= 1;
-		count -= xfer;
-		buf += xfer;
-
-		audamrnb_send_data(audio, 0);
-
-	}
-	if (eos_condition == AUDAMRNB_EOS_SET)
-		rc = audamrnb_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	if (!rc) {
-		if (buf > start)
-			return buf - start;
-	}
-	return rc;
-}
-
-static int audamrnb_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	MM_INFO("audio instance 0x%08x freeing\n", (int)audio);
-	mutex_lock(&audio->lock);
-	audamrnb_disable(audio);
-	if (audio->rmt_resource_released == 0)
-		rmt_put_resource(audio);
-	audamrnb_flush(audio);
-	audamrnb_flush_pcm_buf(audio);
-	msm_adsp_put(audio->audplay);
-	audpp_adec_free(audio->dec_id);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	unregister_early_suspend(&audio->suspend_ctl.node);
-#endif
-	audio->event_abort = 1;
-	wake_up(&audio->event_wait);
-	audamrnb_reset_event_queue(audio);
-	ion_unmap_kernel(audio->client, audio->output_buff_handle);
-	ion_free(audio->client, audio->output_buff_handle);
-	if (audio->input_buff_handle != NULL) {
-		ion_unmap_kernel(audio->client, audio->input_buff_handle);
-		ion_free(audio->client, audio->input_buff_handle);
-	}
-	ion_client_destroy(audio->client);
-	mutex_unlock(&audio->lock);
-#ifdef CONFIG_DEBUG_FS
-	if (audio->dentry)
-		debugfs_remove(audio->dentry);
-#endif
-	kfree(audio);
-	return 0;
-}
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audamrnb_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload)
-{
-	struct audamrnb_event *e_node = NULL;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-
-	if (!list_empty(&audio->free_event_queue)) {
-		e_node = list_first_entry(&audio->free_event_queue,
-				struct audamrnb_event, list);
-		list_del(&e_node->list);
-	} else {
-		e_node = kmalloc(sizeof(struct audamrnb_event), GFP_ATOMIC);
-		if (!e_node) {
-			MM_ERR("No mem to post event %d\n", type);
-			spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-			return;
-		}
-	}
-
-	e_node->event_type = type;
-	e_node->payload = payload;
-
-	list_add_tail(&e_node->list, &audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	wake_up(&audio->event_wait);
-}
-
-static void audamrnb_suspend(struct early_suspend *h)
-{
-	struct audamrnb_suspend_ctl *ctl =
-		container_of(h, struct audamrnb_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audamrnb_post_event(ctl->audio, AUDIO_EVENT_SUSPEND, payload);
-}
-
-static void audamrnb_resume(struct early_suspend *h)
-{
-	struct audamrnb_suspend_ctl *ctl =
-		container_of(h, struct audamrnb_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audamrnb_post_event(ctl->audio, AUDIO_EVENT_RESUME, payload);
-}
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-static ssize_t audamrnb_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static ssize_t audamrnb_debug_read(struct file *file, char __user *buf,
-					size_t count, loff_t *ppos)
-{
-	const int debug_bufmax = 1024;
-	static char buffer[1024];
-	int n = 0, i;
-	struct audio *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	n = scnprintf(buffer, debug_bufmax, "opened %d\n", audio->opened);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"enabled %d\n", audio->enabled);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"stopped %d\n", audio->stopped);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_feedback %d\n", audio->pcm_feedback);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_buf_sz %d\n", audio->out[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_buf_count %d \n", audio->pcm_buf_count);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_buf_sz %d \n", audio->in[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"volume %x \n", audio->vol_pan.volume);
-	mutex_unlock(&audio->lock);
-	/* Following variables are only useful for debugging when
-	 * when playback halts unexpectedly. Thus, no mutual exclusion
-	 * enforced
-	 */
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"wflush %d\n", audio->wflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"rflush %d\n", audio->rflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"running %d \n", audio->running);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"dec state %d \n", audio->dec_state);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_needed %d \n", audio->out_needed);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_head %d \n", audio->out_head);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_tail %d \n", audio->out_tail);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out[0].used %d \n", audio->out[0].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out[1].used %d \n", audio->out[1].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"buffer_refresh %d \n", audio->buf_refresh);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"read_next %d \n", audio->read_next);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"fill_next %d \n", audio->fill_next);
-	for (i = 0; i < audio->pcm_buf_count; i++)
-		n += scnprintf(buffer + n, debug_bufmax - n,
-				"in[%d].used %d \n", i, audio->in[i].used);
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations audamrnb_debug_fops = {
-	.read = audamrnb_debug_read,
-	.open = audamrnb_debug_open,
-};
-#endif
-
-static int audamrnb_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = NULL;
-	int rc, dec_attrb, decid, i;
-	struct audamrnb_event *e_node = NULL;
-	unsigned mem_sz = DMASZ;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	struct ion_client *client = NULL;
-	int len = 0;
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_amrnb_" + 5];
-#endif
-
-	/* Allocate Mem for audio instance */
-	audio = kzalloc(sizeof(struct audio), GFP_KERNEL);
-	if (!audio) {
-		MM_ERR("no memory to allocate audio instance \n");
-		rc = -ENOMEM;
-		goto done;
-	}
-	MM_INFO("audio instance 0x%08x created\n", (int)audio);
-
-	/* Allocate the decoder */
-	dec_attrb = AUDDEC_DEC_AMRNB;
-	if ((file->f_mode & FMODE_WRITE) &&
-			(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_NONTUNNEL;
-		audio->pcm_feedback = NON_TUNNEL_MODE_PLAYBACK;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_TUNNEL;
-		audio->pcm_feedback = TUNNEL_MODE_PLAYBACK;
-	} else {
-		kfree(audio);
-		rc = -EACCES;
-		goto done;
-	}
-
-	decid = audpp_adec_alloc(dec_attrb, &audio->module_name,
-			&audio->queue_id);
-
-	if (decid < 0) {
-		MM_ERR("No free decoder available, freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENODEV;
-		kfree(audio);
-		goto done;
-	}
-
-	audio->dec_id = decid & MSM_AUD_DECODER_MASK;
-
-	client = msm_ion_client_create(UINT_MAX, "Audio_AMR_NB_Client");
-	if (IS_ERR_OR_NULL(client)) {
-		pr_err("Unable to create ION client\n");
-		rc = -ENOMEM;
-		goto client_create_error;
-	}
-	audio->client = client;
-
-	handle = ion_alloc(client, mem_sz, SZ_4K,
-		ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-	if (IS_ERR_OR_NULL(handle)) {
-		MM_ERR("Unable to create allocate O/P buffers\n");
-		rc = -ENOMEM;
-		goto output_buff_alloc_error;
-	}
-	audio->output_buff_handle = handle;
-
-	rc = ion_phys(client, handle, &addr, &len);
-	if (rc) {
-		MM_ERR("O/P buffers:Invalid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-		goto output_buff_get_phys_error;
-	} else {
-		MM_INFO("O/P buffers:valid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-	}
-	audio->phys = (int32_t)addr;
-
-
-	rc = ion_handle_get_flags(client, handle, &ionflag);
-	if (rc) {
-		MM_ERR("could not get flags for the handle\n");
-		goto output_buff_get_flags_error;
-	}
-
-	audio->map_v_write = ion_map_kernel(client, handle);
-	if (IS_ERR(audio->map_v_write)) {
-		MM_ERR("could not map write buffers\n");
-		rc = -ENOMEM;
-		goto output_buff_map_error;
-	}
-	audio->data = audio->map_v_write;
-	MM_DBG("write buf: phy addr 0x%08x kernel addr 0x%08x\n",
-		audio->phys, (int)audio->data);
-
-	if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK) {
-		rc = audmgr_open(&audio->audmgr);
-		if (rc) {
-			MM_ERR("audmgr open failed, freeing instance \
-					0x%08x\n", (int)audio);
-			goto err;
-		}
-	}
-
-	rc = msm_adsp_get(audio->module_name, &audio->audplay,
-		&audplay_adsp_ops_amrnb, audio);
-	if (rc) {
-		MM_ERR("failed to get %s module, freeing instance 0x%08x\n",
-				audio->module_name, (int)audio);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_close(&audio->audmgr);
-		goto err;
-	}
-
-	rc = rmt_get_resource(audio);
-	if (rc) {
-		MM_ERR("ADSP resources are not available for AMRNB session \
-			 0x%08x on decoder: %d\n", (int)audio, audio->dec_id);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_close(&audio->audmgr);
-		msm_adsp_put(audio->audplay);
-		goto err;
-	}
-
-	audio->input_buff_handle = NULL;
-
-	mutex_init(&audio->lock);
-	mutex_init(&audio->write_lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->get_event_lock);
-	spin_lock_init(&audio->dsp_lock);
-	spin_lock_init(&audio->event_queue_lock);
-	INIT_LIST_HEAD(&audio->free_event_queue);
-	INIT_LIST_HEAD(&audio->event_queue);
-	init_waitqueue_head(&audio->write_wait);
-	init_waitqueue_head(&audio->read_wait);
-	init_waitqueue_head(&audio->wait);
-	init_waitqueue_head(&audio->event_wait);
-
-	audio->out[0].data = audio->data + 0;
-	audio->out[0].addr = audio->phys + 0;
-	audio->out[0].size = BUFSZ;
-
-	audio->out[1].data = audio->data + BUFSZ;
-	audio->out[1].addr = audio->phys + BUFSZ;
-	audio->out[1].size = BUFSZ;
-
-	audio->vol_pan.volume = 0x2000;
-
-	audamrnb_flush(audio);
-
-	file->private_data = audio;
-	audio->opened = 1;
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof name, "msm_amrnb_%04x", audio->dec_id);
-	audio->dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
-			NULL, (void *) audio, &audamrnb_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		MM_DBG("debugfs_create_file failed\n");
-#endif
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	audio->suspend_ctl.node.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
-	audio->suspend_ctl.node.resume = audamrnb_resume;
-	audio->suspend_ctl.node.suspend = audamrnb_suspend;
-	audio->suspend_ctl.audio = audio;
-	register_early_suspend(&audio->suspend_ctl.node);
-#endif
-	for (i = 0; i < AUDAMRNB_EVENT_NUM; i++) {
-		e_node = kmalloc(sizeof(struct audamrnb_event), GFP_KERNEL);
-		if (e_node)
-			list_add_tail(&e_node->list, &audio->free_event_queue);
-		else {
-			MM_ERR("event pkt alloc failed\n");
-			break;
-		}
-	}
-done:
-	return rc;
-err:
-	ion_unmap_kernel(client, audio->output_buff_handle);
-output_buff_map_error:
-output_buff_get_phys_error:
-output_buff_get_flags_error:
-	ion_free(client, audio->output_buff_handle);
-output_buff_alloc_error:
-	ion_client_destroy(client);
-client_create_error:
-	audpp_adec_free(audio->dec_id);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_amrnb_fops = {
-	.owner = THIS_MODULE,
-	.open = audamrnb_open,
-	.release = audamrnb_release,
-	.read = audamrnb_read,
-	.write = audamrnb_write,
-	.unlocked_ioctl = audamrnb_ioctl,
-	.fsync = audamrnb_fsync,
-};
-
-struct miscdevice audio_amrnb_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_amrnb",
-	.fops = &audio_amrnb_fops,
-};
-
-static int __init audamrnb_init(void)
-{
-	return misc_register(&audio_amrnb_misc);
-}
-
-static void __exit audamrnb_exit(void)
-{
-	misc_deregister(&audio_amrnb_misc);
-}
-
-module_init(audamrnb_init);
-module_exit(audamrnb_exit);
-
-MODULE_DESCRIPTION("MSM AMR-NB driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5/audio_amrnb_in.c b/arch/arm/mach-msm/qdsp5/audio_amrnb_in.c
deleted file mode 100644
index 0eca74d..0000000
--- a/arch/arm/mach-msm/qdsp5/audio_amrnb_in.c
+++ /dev/null
@@ -1,1520 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/audio_amrnb_in.c
- *
- * amrnb encoder device
- *
- * Copyright (c) 2009, 2011-2013 The Linux Foundation. All rights reserved.
- *
- * This code is based in part on arch/arm/mach-msm/qdsp5/audio_in.c, which is
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you can find it at http://www.fsf.org.
- *
- */
-
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/msm_audio_amrnb.h>
-#include <linux/memory_alloc.h>
-#include <linux/msm_ion.h>
-
-#include "audmgr.h"
-
-#include <mach/msm_rpcrouter.h>
-#include <mach/msm_memtypes.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-
-#include <mach/msm_adsp.h>
-#include <mach/qdsp5/qdsp5audpreproc.h>
-#include <mach/qdsp5/qdsp5audpreproccmdi.h>
-#include <mach/qdsp5/qdsp5audpreprocmsg.h>
-#include <mach/qdsp5/qdsp5audreccmdi.h>
-#include <mach/qdsp5/qdsp5audrecmsg.h>
-#include <mach/debug_mm.h>
-
-#define FRAME_HEADER_SIZE	8 /* 8 bytes frame header */
-#define NT_FRAME_HEADER_SIZE	24 /* 24 bytes frame header */
-/* FRAME_NUM must be a power of two */
-#define FRAME_NUM	8
-#define AMRNB_FRAME_SIZE	36 /* 36 bytes data */
-/*Tunnel mode : 1536 bytes data + 8 byte header*/
-#define FRAME_SIZE	(AMRNB_FRAME_SIZE + FRAME_HEADER_SIZE)
-/* 1536 bytes data  + 24 meta field*/
-#define NT_FRAME_SIZE	(AMRNB_FRAME_SIZE + NT_FRAME_HEADER_SIZE)
-#define DMASZ		(FRAME_SIZE * FRAME_NUM)
-#define NT_DMASZ	(NT_FRAME_SIZE * FRAME_NUM)
-#define OUT_FRAME_NUM	2
-#define OUT_BUFFER_SIZE (4 * 1024 + NT_FRAME_HEADER_SIZE)
-#define BUFFER_SIZE	(OUT_BUFFER_SIZE * OUT_FRAME_NUM)
-
-/* Offset from beginning of buffer*/
-#define AUDPREPROC_AMRNB_EOS_FLG_OFFSET 0x0A
-#define AUDPREPROC_AMRNB_EOS_FLG_MASK 0x01
-#define AUDPREPROC_AMRNB_EOS_NONE 0x0 /* No EOS detected */
-#define AUDPREPROC_AMRNB_EOS_SET 0x1 /* EOS set in meta field */
-
-struct buffer {
-	void *data;
-	uint32_t size;
-	uint32_t read;
-	uint32_t addr;
-	uint32_t used;
-	uint32_t mfield_sz;
-};
-
-struct audio_amrnb_in {
-	struct buffer in[FRAME_NUM];
-
-	spinlock_t dsp_lock;
-
-	atomic_t in_bytes;
-	atomic_t in_samples;
-
-	struct mutex lock;
-	struct mutex read_lock;
-	wait_queue_head_t wait;
-	wait_queue_head_t wait_enable;
-	/*write section*/
-	struct buffer out[OUT_FRAME_NUM];
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed;	/* number of buffers the dsp is waiting for */
-	uint32_t out_count;
-
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-	int32_t out_phys; /* physical address of write buffer */
-	char *out_data;
-	uint8_t mfield; /* meta field embedded in data */
-	uint8_t wflush; /*write flush */
-	uint8_t rflush; /*read flush*/
-	uint32_t out_frame_cnt;
-
-	struct msm_adsp_module *audrec;
-
-	/* configuration to use on next enable */
-	uint32_t samp_rate;
-	uint32_t channel_mode;
-	uint32_t buffer_size;
-	uint32_t enc_type; /* 0 for WAV ,1 for AAC,10 for AMRNB */
-	uint32_t mode; /* T or NT Mode*/
-	struct msm_audio_amrnb_enc_config amrnb_enc_cfg;
-
-	uint32_t dsp_cnt;
-	uint32_t in_head; /* next buffer dsp will write */
-	uint32_t in_tail; /* next buffer read() will read */
-	uint32_t in_count; /* number of buffers available to read() */
-
-	uint32_t eos_ack;
-	uint32_t flush_ack;
-
-	const char *module_name;
-	unsigned queue_ids;
-	uint16_t enc_id; /* Session Id */
-
-	unsigned short samp_rate_index;
-	uint32_t audrec_obj_idx ;
-
-	struct audmgr audmgr;
-
-	/* data allocated for various buffers */
-	char *data;
-	dma_addr_t phys;
-	void *map_v_write;
-
-	uint8_t opened;
-	uint8_t enabled;
-	uint8_t running;
-	uint8_t stopped; /* set when stopped, cleared on flush */
-	struct ion_client *client;
-	struct ion_handle *input_buff_handle;
-
-	struct audrec_session_info session_info; /*audrec session info*/
-};
-
-struct audio_frame {
-	uint16_t frame_count_lsw;
-	uint16_t frame_count_msw;
-	uint16_t frame_length;
-	uint16_t erased_pcm;
-	unsigned char raw_bitstream[];
-} __packed;
-
-struct audio_frame_nt {
-	uint16_t metadata_len;
-	uint16_t frame_count_lsw;
-	uint16_t frame_count_msw;
-	uint16_t frame_length;
-	uint16_t erased_pcm;
-	uint16_t reserved;
-	uint16_t time_stamp_dword_lsw;
-	uint16_t time_stamp_dword_msw;
-	uint16_t time_stamp_lsw;
-	uint16_t time_stamp_msw;
-	uint16_t nflag_lsw;
-	uint16_t nflag_msw;
-	unsigned char raw_bitstream[]; /* samples */
-} __packed;
-
-struct amrnb_encoded_meta_out {
-	uint16_t metadata_len;
-	uint16_t time_stamp_dword_lsw;
-	uint16_t time_stamp_dword_msw;
-	uint16_t time_stamp_lsw;
-	uint16_t time_stamp_msw;
-	uint16_t nflag_lsw;
-	uint16_t nflag_msw;
-};
-
-/* Audrec Queue command sent macro's */
-#define audio_send_queue_pre(audio, cmd, len) \
-	msm_adsp_write(audio->audpre, QDSP_uPAudPreProcCmdQueue, cmd, len)
-
-#define audio_send_queue_recbs(audio, cmd, len) \
-	msm_adsp_write(audio->audrec, ((audio->queue_ids & 0xFFFF0000) >> 16),\
-			cmd, len)
-#define audio_send_queue_rec(audio, cmd, len) \
-	msm_adsp_write(audio->audrec, (audio->queue_ids & 0x0000FFFF),\
-			cmd, len)
-
-static int audamrnb_in_dsp_enable(struct audio_amrnb_in *audio, int enable);
-static int audamrnb_in_encparam_config(struct audio_amrnb_in *audio);
-static int audamrnb_in_encmem_config(struct audio_amrnb_in *audio);
-static int audamrnb_in_dsp_read_buffer(struct audio_amrnb_in *audio,
-				uint32_t read_cnt);
-static void audamrnb_in_flush(struct audio_amrnb_in *audio);
-
-static void audamrnb_in_get_dsp_frames(struct audio_amrnb_in *audio);
-static int audpcm_config(struct audio_amrnb_in *audio);
-static void audamrnb_out_flush(struct audio_amrnb_in *audio);
-static int audamrnb_in_routing_mode_config(struct audio_amrnb_in *audio);
-static void audrec_pcm_send_data(struct audio_amrnb_in *audio, unsigned needed);
-static void audamrnb_nt_in_get_dsp_frames(struct audio_amrnb_in *audio);
-static void audamrnb_in_flush(struct audio_amrnb_in *audio);
-
-static unsigned convert_samp_index(unsigned index)
-{
-	switch (index) {
-	case RPC_AUD_DEF_SAMPLE_RATE_48000:	return 48000;
-	case RPC_AUD_DEF_SAMPLE_RATE_44100:	return 44100;
-	case RPC_AUD_DEF_SAMPLE_RATE_32000:	return 32000;
-	case RPC_AUD_DEF_SAMPLE_RATE_24000:	return 24000;
-	case RPC_AUD_DEF_SAMPLE_RATE_22050:	return 22050;
-	case RPC_AUD_DEF_SAMPLE_RATE_16000:	return 16000;
-	case RPC_AUD_DEF_SAMPLE_RATE_12000:	return 12000;
-	case RPC_AUD_DEF_SAMPLE_RATE_11025:	return 11025;
-	case RPC_AUD_DEF_SAMPLE_RATE_8000:	return 8000;
-	default:				return 11025;
-	}
-}
-
-/* ------------------- dsp --------------------- */
-static void audpre_dsp_event(void *data, unsigned id,  void *event_data)
-{
-
-	uint16_t *msg = event_data;
-
-	if (!msg)
-		return;
-
-	switch (id) {
-	case AUDPREPROC_MSG_CMD_CFG_DONE_MSG:
-		MM_DBG("type %d, status_flag %d\n",\
-			msg[0], msg[1]);
-		break;
-	case AUDPREPROC_MSG_ERROR_MSG_ID:
-		MM_INFO("err_index %d\n", msg[0]);
-		break;
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audpreproctask)\n");
-		break;
-	default:
-		MM_ERR("unknown event %d\n", id);
-	}
-}
-/* must be called with audio->lock held */
-static int audamrnb_in_enable(struct audio_amrnb_in *audio)
-{
-	struct audmgr_config cfg;
-	int32_t rc;
-
-	if (audio->enabled)
-		return 0;
-
-	cfg.tx_rate = audio->samp_rate;
-	cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE;
-	cfg.def_method = RPC_AUD_DEF_METHOD_RECORD;
-	cfg.codec = RPC_AUD_DEF_CODEC_AMR_NB;
-	cfg.snd_method = RPC_SND_METHOD_MIDI;
-
-	if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-		rc = audmgr_enable(&audio->audmgr, &cfg);
-		if (rc < 0)
-			return rc;
-
-		if (audpreproc_enable(audio->enc_id,
-				&audpre_dsp_event, audio)) {
-			MM_ERR("msm_adsp_enable(audpreproc) failed\n");
-			audmgr_disable(&audio->audmgr);
-			return -ENODEV;
-		}
-		/*update aurec session info in audpreproc layer*/
-		audio->session_info.session_id = audio->enc_id;
-		audio->session_info.sampling_freq =
-			convert_samp_index(audio->samp_rate);
-		audpreproc_update_audrec_info(&audio->session_info);
-	}
-
-	if (msm_adsp_enable(audio->audrec)) {
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			audpreproc_disable(audio->enc_id, audio);
-			audmgr_disable(&audio->audmgr);
-		}
-		MM_ERR("msm_adsp_enable(audrec) failed\n");
-		return -ENODEV;
-	}
-
-	audio->enabled = 1;
-	audamrnb_in_dsp_enable(audio, 1);
-
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audamrnb_in_disable(struct audio_amrnb_in *audio)
-{
-	if (audio->enabled) {
-		audio->enabled = 0;
-
-		audamrnb_in_dsp_enable(audio, 0);
-
-		wake_up(&audio->wait);
-		wait_event_interruptible_timeout(audio->wait_enable,
-				audio->running == 0, 1*HZ);
-		msm_adsp_disable(audio->audrec);
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			/*reset the sampling frequency information at
-			audpreproc layer*/
-			audio->session_info.sampling_freq = 0;
-			audpreproc_update_audrec_info(&audio->session_info);
-			audpreproc_disable(audio->enc_id, audio);
-			audmgr_disable(&audio->audmgr);
-		}
-	}
-	return 0;
-}
-
-static void audamrnb_in_get_dsp_frames(struct audio_amrnb_in *audio)
-{
-	struct audio_frame *frame;
-	uint32_t index;
-	unsigned long flags;
-	index = audio->in_head;
-
-	frame = (void *) (((char *)audio->in[index].data) -
-		sizeof(*frame));
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-
-	/* Send	Complete Transcoded Data, not actual frame part  */
-	audio->in[index].size = FRAME_SIZE - (sizeof(*frame));
-	/* statistics of read */
-	atomic_add(audio->in[index].size, &audio->in_bytes);
-	atomic_add(1, &audio->in_samples);
-
-	audio->in_head = (audio->in_head + 1) & (FRAME_NUM - 1);
-
-	/* If overflow, move the tail index foward. */
-	if (audio->in_head == audio->in_tail) {
-		MM_ERR("Error! not able to keep up the read\n");
-		audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
-		MM_ERR("in_count = %d\n", audio->in_count);
-	} else
-		audio->in_count++;
-
-	audamrnb_in_dsp_read_buffer(audio, audio->dsp_cnt++);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-
-	wake_up(&audio->wait);
-}
-
-static void audamrnb_nt_in_get_dsp_frames(struct audio_amrnb_in *audio)
-{
-	struct audio_frame_nt *nt_frame;
-	uint32_t index;
-	unsigned long flags;
-
-	index = audio->in_head;
-	nt_frame = (void *) (((char *)audio->in[index].data) - \
-				sizeof(struct audio_frame_nt));
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->in[index].size = nt_frame->frame_length;
-	/* statistics of read */
-	atomic_add(audio->in[index].size, &audio->in_bytes);
-	atomic_add(1, &audio->in_samples);
-
-	audio->in_head = (audio->in_head + 1) & (FRAME_NUM - 1);
-
-	/* If overflow, move the tail index foward. */
-	if (audio->in_head == audio->in_tail)
-		MM_DBG("Error! not able to keep up the read\n");
-	else
-		audio->in_count++;
-
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	wake_up(&audio->wait);
-}
-
-static int audrec_pcm_buffer_ptr_refresh(struct audio_amrnb_in *audio,
-				       unsigned idx, unsigned len)
-{
-	struct audrec_cmd_pcm_buffer_ptr_refresh_arm_enc cmd;
-
-	if (len ==  NT_FRAME_HEADER_SIZE)
-		len = len / 2;
-	else
-		len = (len + NT_FRAME_HEADER_SIZE) / 2;
-	MM_DBG("len = %d\n", len);
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_PCM_BUFFER_PTR_REFRESH_ARM_TO_ENC;
-	cmd.num_buffers = 1;
-	if (cmd.num_buffers == 1) {
-		cmd.buf_address_length[0] = (audio->out[idx].addr &
-							0xffff0000) >> 16;
-		cmd.buf_address_length[1] = (audio->out[idx].addr &
-							0x0000ffff);
-		cmd.buf_address_length[2] = (len & 0xffff0000) >> 16;
-		cmd.buf_address_length[3] = (len & 0x0000ffff);
-	}
-	audio->out_frame_cnt++;
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audpcm_config(struct audio_amrnb_in *audio)
-{
-	struct audrec_cmd_pcm_cfg_arm_to_enc cmd;
-	MM_DBG("\n");
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_PCM_CFG_ARM_TO_ENC;
-	cmd.config_update_flag = AUDREC_PCM_CONFIG_UPDATE_FLAG_ENABLE;
-	cmd.enable_flag = AUDREC_ENABLE_FLAG_VALUE;
-	cmd.sampling_freq = convert_samp_index(audio->samp_rate);
-	if (!audio->channel_mode)
-		cmd.channels = 1;
-	else
-		cmd.channels = 2;
-	cmd.frequency_of_intimation = 1;
-	cmd.max_number_of_buffers = OUT_FRAME_NUM;
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-
-static int audamrnb_in_routing_mode_config(struct audio_amrnb_in *audio)
-{
-	struct audrec_cmd_routing_mode cmd;
-
-	MM_DBG("\n");
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_ROUTING_MODE;
-	if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL)
-		cmd.routing_mode = 1;
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static void audrec_dsp_event(void *data, unsigned id, size_t len,
-			    void (*getevent)(void *ptr, size_t len))
-{
-	struct audio_amrnb_in *audio = data;
-	if (data)
-		audio = data;
-	else {
-		MM_ERR("invalid data for event %x\n", id);
-		return;
-	}
-
-	switch (id) {
-	case AUDREC_MSG_CMD_CFG_DONE_MSG: {
-		struct audrec_msg_cmd_cfg_done_msg cmd_cfg_done_msg;
-		getevent(&cmd_cfg_done_msg, AUDREC_MSG_CMD_CFG_DONE_MSG_LEN);
-		if (cmd_cfg_done_msg.audrec_enc_type & \
-				AUDREC_MSG_CFG_DONE_ENC_ENA) {
-			audio->audrec_obj_idx = cmd_cfg_done_msg.audrec_obj_idx;
-			MM_DBG("CFG ENABLED\n");
-			if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) {
-				MM_DBG("routing command\n");
-				audamrnb_in_routing_mode_config(audio);
-			} else {
-				audamrnb_in_encmem_config(audio);
-			}
-		} else {
-			MM_DBG("CFG SLEEP\n");
-			audio->running = 0;
-			wake_up(&audio->wait_enable);
-		}
-		break;
-	}
-	case AUDREC_MSG_CMD_ROUTING_MODE_DONE_MSG: {
-		struct audrec_msg_cmd_routing_mode_done_msg \
-			routing_msg;
-		getevent(&routing_msg, AUDREC_MSG_CMD_ROUTING_MODE_DONE_MSG);
-		MM_DBG("AUDREC_MSG_CMD_ROUTING_MODE_DONE_MSG");
-		if (routing_msg.configuration == 0) {
-			MM_ERR("routing configuration failed\n");
-			audio->running = 0;
-			wake_up(&audio->wait_enable);
-		} else
-			audamrnb_in_encmem_config(audio);
-		break;
-	}
-	case AUDREC_MSG_CMD_AREC_MEM_CFG_DONE_MSG: {
-		MM_DBG("AREC_MEM_CFG_DONE_MSG\n");
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)
-			audamrnb_in_encparam_config(audio);
-		else
-			audpcm_config(audio);
-		break;
-	}
-
-	case AUDREC_CMD_PCM_CFG_ARM_TO_ENC_DONE_MSG: {
-		MM_DBG("AUDREC_CMD_PCM_CFG_ARM_TO_ENC_DONE_MSG");
-		audamrnb_in_encparam_config(audio);
-	    break;
-	}
-	case AUDREC_MSG_CMD_AREC_PARAM_CFG_DONE_MSG: {
-		MM_DBG("AUDREC_MSG_CMD_AREC_PARAM_CFG_DONE_MSG\n");
-		audio->running = 1;
-		wake_up(&audio->wait_enable);
-		if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL)
-			audrec_pcm_send_data(audio, 1);
-		break;
-	}
-	case AUDREC_CMD_PCM_BUFFER_PTR_UPDATE_ARM_TO_ENC_MSG: {
-		MM_DBG("ptr_update recieved from DSP\n");
-		audrec_pcm_send_data(audio, 1);
-		break;
-	}
-	case AUDREC_MSG_NO_EXT_PKT_AVAILABLE_MSG: {
-		struct audrec_msg_no_ext_pkt_avail_msg err_msg;
-		getevent(&err_msg, AUDREC_MSG_NO_EXT_PKT_AVAILABLE_MSG_LEN);
-		MM_DBG("NO_EXT_PKT_AVAILABLE_MSG %x\n",\
-			err_msg.audrec_err_id);
-		break;
-	}
-	case AUDREC_MSG_PACKET_READY_MSG: {
-		struct audrec_msg_packet_ready_msg pkt_ready_msg;
-
-		getevent(&pkt_ready_msg, AUDREC_MSG_PACKET_READY_MSG_LEN);
-		MM_DBG("UP_PACKET_READY_MSG: write cnt msw  %d \
-		write cnt lsw %d read cnt msw %d  read cnt lsw %d \n",\
-		pkt_ready_msg.pkt_counter_msw, \
-		pkt_ready_msg.pkt_counter_lsw, \
-		pkt_ready_msg.pkt_read_cnt_msw, \
-		pkt_ready_msg.pkt_read_cnt_lsw);
-
-		audamrnb_in_get_dsp_frames(audio);
-		break;
-	}
-	case AUDREC_UP_NT_PACKET_READY_MSG: {
-		struct audrec_up_nt_packet_ready_msg pkt_ready_msg;
-
-		getevent(&pkt_ready_msg, AUDREC_UP_NT_PACKET_READY_MSG_LEN);
-		MM_DBG("UP_NT_PACKET_READY_MSG: write cnt lsw  %d \
-		write cnt msw %d read cnt lsw %d  read cnt msw %d \n",\
-		pkt_ready_msg.audrec_packetwrite_cnt_lsw, \
-		pkt_ready_msg.audrec_packetwrite_cnt_msw, \
-		pkt_ready_msg.audrec_upprev_readcount_lsw, \
-		pkt_ready_msg.audrec_upprev_readcount_msw);
-
-		audamrnb_nt_in_get_dsp_frames(audio);
-		break;
-	}
-	case AUDREC_CMD_FLUSH_DONE_MSG: {
-		audio->wflush = 0;
-		audio->rflush = 0;
-		audio->flush_ack = 1;
-		wake_up(&audio->write_wait);
-		MM_DBG("flush ack recieved\n");
-		break;
-	}
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module \
-				enable/disable(audrectask)\n");
-		break;
-	default:
-		MM_ERR("unknown event %d\n", id);
-	}
-}
-
-struct msm_adsp_ops audrec_amrnb_adsp_ops = {
-	.event = audrec_dsp_event,
-};
-
-static int audamrnb_in_dsp_enable(struct audio_amrnb_in *audio, int enable)
-{
-	struct audrec_cmd_enc_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_ENC_CFG;
-	cmd.audrec_enc_type = (audio->enc_type & 0xFF) |
-	(enable ? AUDREC_CMD_ENC_ENA : AUDREC_CMD_ENC_DIS);
-	/* Don't care on enable, required on disable */
-	cmd.audrec_obj_idx = audio->audrec_obj_idx;
-
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audamrnb_in_encmem_config(struct audio_amrnb_in *audio)
-{
-	struct audrec_cmd_arecmem_cfg cmd;
-	uint16_t *data = (void *) audio->data;
-	uint8_t n;
-	uint16_t header_len = 0;
-
-	memset(&cmd, 0, sizeof(cmd));
-
-	cmd.cmd_id = AUDREC_CMD_ARECMEM_CFG;
-	cmd.audrec_obj_idx = audio->audrec_obj_idx;
-	/* Rate at which packet complete message comes */
-	cmd.audrec_up_pkt_intm_cnt = 1;
-	cmd.audrec_extpkt_buffer_msw = audio->phys >> 16;
-	cmd.audrec_extpkt_buffer_lsw = audio->phys;
-	/* Max Buffer no available for frames */
-	cmd.audrec_extpkt_buffer_num = FRAME_NUM;
-
-	/* prepare buffer pointers:
-	 * T:36 bytes amrnb packet + 4 halfword header
-	 * NT:36 bytes amrnb packet + 12 halfword header
-	 */
-	if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)
-		header_len = FRAME_HEADER_SIZE/2;
-	else
-		header_len = NT_FRAME_HEADER_SIZE/2;
-
-	for (n = 0; n < FRAME_NUM; n++) {
-		audio->in[n].data = data + header_len;
-		data += (AMRNB_FRAME_SIZE/2) + header_len;
-		MM_DBG("0x%8x\n", (uint32_t)(audio->in[n].data - header_len*2));
-	}
-
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audamrnb_in_encparam_config(struct audio_amrnb_in *audio)
-{
-	struct audrec_cmd_arecparam_amrnb_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-
-	cmd.common.cmd_id = AUDREC_CMD_ARECPARAM_CFG;
-	cmd.common.audrec_obj_idx = audio->audrec_obj_idx;
-	cmd.samp_rate_idx = audio->samp_rate_index; /* 8k Sampling rate */
-	cmd.voicememoencweight1 = audio->amrnb_enc_cfg.voicememoencweight1;
-	cmd.voicememoencweight2 = audio->amrnb_enc_cfg.voicememoencweight2;
-	cmd.voicememoencweight3 = audio->amrnb_enc_cfg.voicememoencweight3;
-	cmd.voicememoencweight4 = audio->amrnb_enc_cfg.voicememoencweight4;
-	cmd.update_mode = 0x8000 | 0x0000;
-	cmd.dtx_mode = audio->amrnb_enc_cfg.dtx_mode_enable;
-	cmd.test_mode = audio->amrnb_enc_cfg.test_mode_enable;
-	cmd.used_mode = audio->amrnb_enc_cfg.enc_mode;
-
-	MM_DBG("cmd.common.cmd_id = 0x%4x\n", cmd.common.cmd_id);
-	MM_DBG("cmd.common.audrec_obj_idx = 0x%4x\n",
-			cmd.common.audrec_obj_idx);
-	MM_DBG("cmd.samp_rate_idx = 0x%4x\n", cmd.samp_rate_idx);
-	MM_DBG("cmd.voicememoencweight1 = 0x%4x\n",
-			cmd.voicememoencweight1);
-	MM_DBG("cmd.voicememoencweight2 = 0x%4x\n",
-			cmd.voicememoencweight2);
-	MM_DBG("cmd.voicememoencweight3 = 0x%4x\n",
-			cmd.voicememoencweight3);
-	MM_DBG("cmd.voicememoencweight4 = 0x%4x\n",
-			cmd.voicememoencweight4);
-	MM_DBG("cmd.update_mode = 0x%4x\n", cmd.update_mode);
-	MM_DBG("cmd.dtx_mode = 0x%4x\n", cmd.dtx_mode);
-	MM_DBG("cmd.test_mode = 0x%4x\n", cmd.test_mode);
-	MM_DBG("cmd.used_mode = 0x%4x\n", cmd.used_mode);
-
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audamrnb_flush_command(struct audio_amrnb_in *audio)
-{
-	struct audrec_cmd_flush cmd;
-	MM_DBG("\n");
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_FLUSH;
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-static int audamrnb_in_dsp_read_buffer(struct audio_amrnb_in *audio,
-		uint32_t read_cnt)
-{
-	audrec_cmd_packet_ext_ptr cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_PACKET_EXT_PTR;
-	cmd.type = audio->audrec_obj_idx;
-	cmd.curr_rec_count_msw = read_cnt >> 16;
-	cmd.curr_rec_count_lsw = read_cnt;
-
-	return audio_send_queue_recbs(audio, &cmd, sizeof(cmd));
-}
-
-/* ------------------- device --------------------- */
-
-static void audamrnb_ioport_reset(struct audio_amrnb_in *audio)
-{
-	/* Make sure read/write thread are free from
-	 * sleep and knowing that system is not able
-	 * to process io request at the moment
-	 */
-	wake_up(&audio->write_wait);
-	mutex_lock(&audio->write_lock);
-	audamrnb_in_flush(audio);
-	mutex_unlock(&audio->write_lock);
-	wake_up(&audio->wait);
-	mutex_lock(&audio->read_lock);
-	audamrnb_out_flush(audio);
-	mutex_unlock(&audio->read_lock);
-}
-
-static void audamrnb_in_flush(struct audio_amrnb_in *audio)
-{
-	uint8_t i;
-
-	audio->dsp_cnt = 0;
-	audio->in_head = 0;
-	audio->in_tail = 0;
-	audio->in_count = 0;
-	audio->eos_ack = 0;
-	for (i = FRAME_NUM-1; i >= 0; i--) {
-		audio->in[i].size = 0;
-		audio->in[i].read = 0;
-	}
-	MM_DBG("in_bytes %d\n", atomic_read(&audio->in_bytes));
-	MM_DBG("in_samples %d\n", atomic_read(&audio->in_samples));
-	atomic_set(&audio->in_bytes, 0);
-	atomic_set(&audio->in_samples, 0);
-}
-
-static void audamrnb_out_flush(struct audio_amrnb_in *audio)
-{
-	uint8_t i;
-
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->out_count = 0;
-	for (i = OUT_FRAME_NUM-1; i >= 0; i--) {
-		audio->out[i].size = 0;
-		audio->out[i].read = 0;
-		audio->out[i].used = 0;
-	}
-}
-
-/* ------------------- device --------------------- */
-static long audamrnb_in_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct audio_amrnb_in *audio = file->private_data;
-	int32_t rc = 0;
-
-	MM_DBG("\n");
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		memset(&stats, 0, sizeof(stats));
-		stats.byte_count = atomic_read(&audio->in_bytes);
-		stats.sample_count = atomic_read(&audio->in_samples);
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return rc;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START: {
-		rc = audamrnb_in_enable(audio);
-		if (!rc) {
-			rc =
-			wait_event_interruptible_timeout(audio->wait_enable,
-				audio->running != 0, 1*HZ);
-			MM_INFO("state %d rc = %d\n", audio->running, rc);
-
-			if (audio->running == 0)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		audio->stopped = 0;
-		break;
-	}
-	case AUDIO_STOP: {
-		rc = audamrnb_in_disable(audio);
-		audio->stopped = 1;
-		break;
-	}
-	case AUDIO_FLUSH: {
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audamrnb_ioport_reset(audio);
-		if (audio->running) {
-			audamrnb_flush_command(audio);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-	struct msm_audio_config cfg;
-		memset(&cfg, 0, sizeof(cfg));
-		if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) {
-			cfg.buffer_size = OUT_BUFFER_SIZE;
-			cfg.buffer_count = OUT_FRAME_NUM;
-		} else {
-			cfg.buffer_size = audio->buffer_size;
-			cfg.buffer_count = FRAME_NUM;
-		}
-		cfg.sample_rate = convert_samp_index(audio->samp_rate);
-		cfg.channel_count = 1;
-		cfg.type = 0;
-		cfg.unused[0] = 0;
-		cfg.unused[1] = 0;
-		cfg.unused[2] = 0;
-		if (copy_to_user((void *) arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-	case AUDIO_GET_STREAM_CONFIG: {
-		struct msm_audio_stream_config cfg;
-		memset(&cfg, 0, sizeof(cfg));
-		cfg.buffer_size = audio->buffer_size;
-		cfg.buffer_count = FRAME_NUM;
-		if (copy_to_user((void *)arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-	case AUDIO_SET_STREAM_CONFIG: {
-		struct msm_audio_stream_config cfg;
-		if (copy_from_user(&cfg, (void *) arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		/* Allow only single frame */
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			if (cfg.buffer_size != (FRAME_SIZE - 8)) {
-				rc = -EINVAL;
-				break;
-			}
-		} else {
-			if (cfg.buffer_size != (AMRNB_FRAME_SIZE + 14)) {
-				rc = -EINVAL;
-				break;
-			}
-		}
-		audio->buffer_size = cfg.buffer_size;
-		break;
-	}
-
-	case AUDIO_GET_AMRNB_ENC_CONFIG: {
-		if (copy_to_user((void *)arg, &audio->amrnb_enc_cfg,
-			sizeof(audio->amrnb_enc_cfg)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-	case AUDIO_SET_AMRNB_ENC_CONFIG: {
-		struct msm_audio_amrnb_enc_config cfg;
-		if (copy_from_user
-			(&cfg, (void *)arg, sizeof(cfg))) {
-			rc = -EFAULT;
-		} else
-			rc = 0;
-		audio->amrnb_enc_cfg.voicememoencweight1 =
-					cfg.voicememoencweight1;
-		audio->amrnb_enc_cfg.voicememoencweight2 =
-					cfg.voicememoencweight2;
-		audio->amrnb_enc_cfg.voicememoencweight3 =
-					cfg.voicememoencweight3;
-		audio->amrnb_enc_cfg.voicememoencweight4 =
-					cfg.voicememoencweight4;
-		audio->amrnb_enc_cfg.dtx_mode_enable = cfg.dtx_mode_enable;
-		audio->amrnb_enc_cfg.test_mode_enable = cfg.test_mode_enable;
-		audio->amrnb_enc_cfg.enc_mode = cfg.enc_mode;
-		/* Run time change of Param */
-		break;
-	}
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static ssize_t audamrnb_in_read(struct file *file,
-				char __user *buf,
-				size_t count, loff_t *pos)
-{
-	struct audio_amrnb_in *audio = file->private_data;
-	unsigned long flags;
-	const char __user *start = buf;
-	void *data;
-	uint32_t index;
-	uint32_t size;
-	int32_t rc = 0;
-	struct amrnb_encoded_meta_out meta_field;
-	struct audio_frame_nt *nt_frame;
-	MM_DBG("count = %d\n", count);
-	mutex_lock(&audio->read_lock);
-	while (count > 0) {
-		rc = wait_event_interruptible(
-			audio->wait, (audio->in_count > 0) || audio->stopped ||
-			audio->rflush);
-		if (rc < 0)
-			break;
-
-		if (audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-		if (audio->stopped && !audio->in_count) {
-			MM_DBG("Driver in stop state, No more buffer to read");
-			rc = 0;/* End of File */
-			break;
-		}
-
-		index = audio->in_tail;
-		data = (uint8_t *) audio->in[index].data;
-		size = audio->in[index].size;
-
-		if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) {
-			nt_frame = (struct audio_frame_nt *)(data -
-					sizeof(struct audio_frame_nt));
-			memcpy((char *)&meta_field.time_stamp_dword_lsw,
-				(char *)&nt_frame->time_stamp_dword_lsw,
-				(sizeof(struct amrnb_encoded_meta_out) - \
-				sizeof(uint16_t)));
-			meta_field.metadata_len =
-					sizeof(struct amrnb_encoded_meta_out);
-			if (copy_to_user((char *)start, (char *)&meta_field,
-				sizeof(struct amrnb_encoded_meta_out))) {
-				rc = -EFAULT;
-				break;
-			}
-			if (nt_frame->nflag_lsw & 0x0001) {
-				MM_ERR("recieved EOS in read call\n");
-				audio->eos_ack = 1;
-			}
-			buf += sizeof(struct amrnb_encoded_meta_out);
-			count -= sizeof(struct amrnb_encoded_meta_out);
-		}
-		if (count >= size) {
-			/* order the reads on the buffer */
-			dma_coherent_post_ops();
-			if (copy_to_user(buf, data, size)) {
-				rc = -EFAULT;
-				break;
-			}
-			spin_lock_irqsave(&audio->dsp_lock, flags);
-			if (index != audio->in_tail) {
-				/* overrun -- data is
-				 * invalid and we need to retry */
-				spin_unlock_irqrestore(&audio->dsp_lock, flags);
-				continue;
-			}
-			audio->in[index].size = 0;
-			audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
-			audio->in_count--;
-			spin_unlock_irqrestore(&audio->dsp_lock, flags);
-			count -= size;
-			buf += size;
-			if ((audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL)) {
-				if (!audio->eos_ack) {
-					MM_DBG("sending read ptr command \
-							%d %d\n",
-							audio->dsp_cnt,
-							audio->in_tail);
-					audamrnb_in_dsp_read_buffer(audio,
-							audio->dsp_cnt++);
-				}
-			}
-		} else {
-			MM_ERR("short read\n");
-			break;
-		}
-
-	}
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		return buf - start;
-
-	return rc;
-}
-
-static void audrec_pcm_send_data(struct audio_amrnb_in *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-	MM_DBG("\n");
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			MM_DBG("frame %d free\n", audio->out_tail);
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			audrec_pcm_buffer_ptr_refresh(audio,
-						 audio->out_tail,
-						    frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
- done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static int audamrnb_in_fsync(struct file *file, loff_t a, loff_t b, int datasync)
-
-{
-	struct audio_amrnb_in *audio = file->private_data;
-	int32_t rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (!audio->running || (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)) {
-		rc = -EINVAL;
-		goto done_nolock;
-	}
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-			audio->wflush);
-	MM_DBG("waked on by some event audio->wflush = %d\n", audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-done:
-	mutex_unlock(&audio->write_lock);
-done_nolock:
-	return rc;
-
-}
-
-int audrec_amrnb_process_eos(struct audio_amrnb_in *audio,
-		const char __user *buf_start, unsigned short mfield_size)
-{
-	struct buffer *frame;
-	int32_t rc = 0;
-
-	frame = audio->out + audio->out_head;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	MM_DBG("copying meta_out frame->used = %d\n", frame->used);
-	audrec_pcm_send_data(audio, 0);
-done:
-	return rc;
-}
-
-static ssize_t audamrnb_in_write(struct file *file,
-				const char __user *buf,
-				size_t count, loff_t *pos)
-{
-	struct audio_amrnb_in *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	char *cpy_ptr;
-	int32_t rc = 0, eos_condition = AUDPREPROC_AMRNB_EOS_NONE;
-	unsigned short mfield_size = 0;
-	int32_t write_count = 0;
-	MM_DBG("cnt=%d\n", count);
-
-	if (count & 1)
-		return -EINVAL;
-
-	if (audio->mode != MSM_AUD_ENC_MODE_NONTUNNEL)
-		return -EINVAL;
-
-	mutex_lock(&audio->write_lock);
-	frame = audio->out + audio->out_head;
-	/* if supplied count is more than driver buffer size
-	 * then only copy driver buffer size
-	 */
-	if (count > frame->size)
-		count = frame->size;
-
-	write_count = count;
-	cpy_ptr = frame->data;
-	rc = wait_event_interruptible(audio->write_wait,
-				      (frame->used == 0)
-					|| (audio->stopped)
-					|| (audio->wflush));
-	if (rc < 0)
-		goto error;
-
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto error;
-	}
-	if (audio->mfield) {
-		if (buf == start) {
-			/* Processing beginning of user buffer */
-			if (__get_user(mfield_size,
-				(unsigned short __user *) buf)) {
-				rc = -EFAULT;
-				goto error;
-			} else if (mfield_size > count) {
-				rc = -EINVAL;
-				goto error;
-			}
-			MM_DBG("mf offset_val %x\n", mfield_size);
-			if (copy_from_user(cpy_ptr, buf, mfield_size)) {
-				rc = -EFAULT;
-				goto error;
-			}
-			/* Check if EOS flag is set and buffer has
-			 * contains just meta field
-			 */
-			if (cpy_ptr[AUDPREPROC_AMRNB_EOS_FLG_OFFSET] &
-					AUDPREPROC_AMRNB_EOS_FLG_MASK) {
-				eos_condition = AUDPREPROC_AMRNB_EOS_SET;
-				MM_DBG("EOS SET\n");
-				if (mfield_size == count) {
-					buf += mfield_size;
-					eos_condition = 0;
-					goto exit;
-				} else
-				cpy_ptr[AUDPREPROC_AMRNB_EOS_FLG_OFFSET] &=
-					~AUDPREPROC_AMRNB_EOS_FLG_MASK;
-			}
-			cpy_ptr += mfield_size;
-			count -= mfield_size;
-			buf += mfield_size;
-		} else {
-			mfield_size = 0;
-			MM_DBG("continuous buffer\n");
-		}
-		frame->mfield_sz = mfield_size;
-	}
-	MM_DBG("copying the stream count = %d\n", count);
-	if (copy_from_user(cpy_ptr, buf, count)) {
-		rc = -EFAULT;
-		goto error;
-	}
-exit:
-	frame->used = count;
-	audio->out_head ^= 1;
-	if (!audio->flush_ack)
-		audrec_pcm_send_data(audio, 0);
-	else {
-		audrec_pcm_send_data(audio, 1);
-		audio->flush_ack = 0;
-	}
-	if (eos_condition == AUDPREPROC_AMRNB_EOS_SET)
-		rc = audrec_amrnb_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	return write_count;
-error:
-	mutex_unlock(&audio->write_lock);
-	return rc;
-}
-
-static int audamrnb_in_release(struct inode *inode, struct file *file)
-{
-	struct audio_amrnb_in *audio = file->private_data;
-	int32_t dma_size = 0;
-	mutex_lock(&audio->lock);
-	audamrnb_in_disable(audio);
-	audamrnb_in_flush(audio);
-	msm_adsp_put(audio->audrec);
-
-	audpreproc_aenc_free(audio->enc_id);
-	audio->audrec = NULL;
-	audio->opened = 0;
-	if ((audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) && \
-	   (audio->out_data)) {
-		ion_unmap_kernel(audio->client, audio->input_buff_handle);
-		ion_free(audio->client, audio->input_buff_handle);
-		audio->out_data = NULL;
-	}
-	if (audio->data) {
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)
-			dma_size = DMASZ;
-		else
-			dma_size = NT_DMASZ;
-
-		dma_free_coherent(NULL,
-			dma_size, audio->data, audio->phys);
-		audio->data = NULL;
-	}
-	ion_client_destroy(audio->client);
-	mutex_unlock(&audio->lock);
-	return 0;
-}
-
-struct audio_amrnb_in the_audio_amrnb_in;
-
-static int audamrnb_in_open(struct inode *inode, struct file *file)
-{
-	struct audio_amrnb_in *audio = &the_audio_amrnb_in;
-	int32_t rc;
-	int encid;
-	int32_t dma_size = 0;
-	int len = 0;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	struct ion_client *client = NULL;
-
-	mutex_lock(&audio->lock);
-	if (audio->opened) {
-		rc = -EBUSY;
-		goto done;
-	}
-	if ((file->f_mode & FMODE_WRITE) &&
-		(file->f_mode & FMODE_READ)) {
-		audio->mode = MSM_AUD_ENC_MODE_NONTUNNEL;
-		dma_size = NT_DMASZ;
-		MM_DBG("Opened for non tunnel mode encoding\n");
-	} else if (!(file->f_mode & FMODE_WRITE) &&
-				(file->f_mode & FMODE_READ)) {
-		audio->mode = MSM_AUD_ENC_MODE_TUNNEL;
-		dma_size = DMASZ;
-		MM_DBG("Opened for tunnel mode encoding\n");
-	} else {
-		MM_ERR("Invalid mode\n");
-		rc = -EACCES;
-		goto done;
-	}
-
-	/* Settings will be re-config at AUDIO_SET_CONFIG,
-	 * but at least we need to have initial config
-	 */
-	audio->samp_rate = RPC_AUD_DEF_SAMPLE_RATE_8000,
-	audio->samp_rate_index = AUDREC_CMD_SAMP_RATE_INDX_8000;
-	audio->channel_mode = AUDREC_CMD_STEREO_MODE_MONO;
-	if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL)
-			audio->buffer_size = (AMRNB_FRAME_SIZE + 14);
-	else
-			audio->buffer_size = (FRAME_SIZE - 8);
-	audio->enc_type = AUDREC_CMD_TYPE_0_INDEX_AMRNB | audio->mode;
-
-	if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-		rc = audmgr_open(&audio->audmgr);
-		if (rc)
-			goto done;
-	}
-	audio->amrnb_enc_cfg.voicememoencweight1 = 0x0000;
-	audio->amrnb_enc_cfg.voicememoencweight2 = 0x0000;
-	audio->amrnb_enc_cfg.voicememoencweight3 = 0x4000;
-	audio->amrnb_enc_cfg.voicememoencweight4 = 0x0000;
-	audio->amrnb_enc_cfg.dtx_mode_enable = 0;
-	audio->amrnb_enc_cfg.test_mode_enable = 0;
-	audio->amrnb_enc_cfg.enc_mode = 7;
-
-	encid = audpreproc_aenc_alloc(audio->enc_type, &audio->module_name,
-			&audio->queue_ids);
-	if (encid < 0) {
-		MM_ERR("No free encoder available\n");
-		rc = -ENODEV;
-		goto done;
-	}
-	audio->enc_id = encid;
-	rc = msm_adsp_get(audio->module_name, &audio->audrec,
-			   &audrec_amrnb_adsp_ops, audio);
-	if (rc) {
-		audpreproc_aenc_free(audio->enc_id);
-		goto done;
-	}
-
-	audio->dsp_cnt = 0;
-	audio->stopped = 0;
-	audio->wflush = 0;
-	audio->rflush = 0;
-	audio->flush_ack = 0;
-
-	audamrnb_in_flush(audio);
-	audamrnb_out_flush(audio);
-	/* used dma_allco_coherent for backward compatibility with 7x27 */
-	audio->data = dma_alloc_coherent(NULL, dma_size,
-				       &audio->phys, GFP_KERNEL);
-	if (!audio->data) {
-		MM_ERR("Unable to allocate DMA buffer\n");
-		goto evt_error;
-	}
-
-	client = msm_ion_client_create(UINT_MAX, "Audio_AMRNB_in_client");
-	if (IS_ERR_OR_NULL(client)) {
-		MM_ERR("Unable to create ION client\n");
-		rc = -ENOMEM;
-		goto client_create_error;
-	}
-	audio->client = client;
-
-	audio->out_data = NULL;
-	if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) {
-		MM_DBG("allocating BUFFER_SIZE  %d\n", BUFFER_SIZE);
-		handle = ion_alloc(client, BUFFER_SIZE,
-				SZ_4K, ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-		if (IS_ERR_OR_NULL(handle)) {
-			MM_ERR("Unable to create allocate write buffers\n");
-			rc = -ENOMEM;
-			goto input_buff_alloc_error;
-		}
-
-		audio->input_buff_handle = handle;
-
-		rc = ion_phys(client , handle, &addr, &len);
-		if (rc) {
-			MM_ERR("I/P buffers:Invalid phy: %x sz: %x\n",
-				(unsigned int) addr, (unsigned int) len);
-			rc = -ENOMEM;
-			goto input_buff_get_phys_error;
-		} else {
-			MM_INFO("Got valid phy: %x sz: %x\n",
-				(unsigned int) addr,
-				(unsigned int) len);
-		}
-		audio->out_phys = (int32_t)addr;
-
-		rc = ion_handle_get_flags(client,
-			handle, &ionflag);
-		if (rc) {
-			MM_ERR("could not get flags for the handle\n");
-			rc = -ENOMEM;
-			goto input_buff_get_flags_error;
-		}
-
-		audio->map_v_write = ion_map_kernel(client, handle);
-		if (IS_ERR(audio->map_v_write)) {
-			MM_ERR("could not map write buffers\n");
-			rc = -ENOMEM;
-			goto input_buff_map_error;
-		}
-		audio->out_data = audio->map_v_write;
-		MM_DBG("write buf: phy addr 0x%08x kernel addr 0x%08x\n",
-					(unsigned int)addr,
-					(unsigned int)audio->out_data);
-
-		/* Initialize buffer */
-		audio->out[0].data = audio->out_data + 0;
-		audio->out[0].addr = audio->out_phys + 0;
-		audio->out[0].size = OUT_BUFFER_SIZE;
-
-		audio->out[1].data = audio->out_data + OUT_BUFFER_SIZE;
-		audio->out[1].addr = audio->out_phys + OUT_BUFFER_SIZE;
-		audio->out[1].size = OUT_BUFFER_SIZE;
-
-		MM_DBG("audio->out[0].data = %d  audio->out[1].data = %d",
-				(uint32_t)audio->out[0].data,
-				(uint32_t)audio->out[1].data);
-		audio->mfield = NT_FRAME_HEADER_SIZE;
-		audio->out_frame_cnt++;
-	}
-	file->private_data = audio;
-	audio->opened = 1;
-
-done:
-	mutex_unlock(&audio->lock);
-	return rc;
-input_buff_map_error:
-input_buff_get_phys_error:
-input_buff_get_flags_error:
-	ion_free(client, audio->input_buff_handle);
-input_buff_alloc_error:
-	ion_client_destroy(client);
-client_create_error:
-	dma_free_coherent(NULL, dma_size, audio->data, audio->phys);
-evt_error:
-	msm_adsp_put(audio->audrec);
-
-	audpreproc_aenc_free(audio->enc_id);
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static const struct file_operations audio_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audamrnb_in_open,
-	.release	= audamrnb_in_release,
-	.read		= audamrnb_in_read,
-	.write		= audamrnb_in_write,
-	.fsync		= audamrnb_in_fsync,
-	.unlocked_ioctl	= audamrnb_in_ioctl,
-};
-
-struct miscdevice audamrnb_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_amrnb_in",
-	.fops	= &audio_fops,
-};
-
-#ifdef CONFIG_DEBUG_FS
-static ssize_t audamrnb_in_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static ssize_t audamrnb_in_debug_read(struct file *file, char __user *buf,
-		size_t count, loff_t *ppos)
-{
-	const int32_t debug_bufmax = 1024;
-	static char buffer[1024];
-	int32_t n = 0, i;
-	struct audio_amrnb_in *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	n = scnprintf(buffer, debug_bufmax, "opened %d\n", audio->opened);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"enabled %d\n", audio->enabled);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"stopped %d\n", audio->stopped);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"audrec_obj_idx %d\n", audio->audrec_obj_idx);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"dsp_cnt %d \n", audio->dsp_cnt);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"in_count %d \n", audio->in_count);
-	for (i = 0; i < FRAME_NUM; i++)
-		n += scnprintf(buffer + n, debug_bufmax - n,
-			"audio->in[%d].size %d \n", i, audio->in[i].size);
-	mutex_unlock(&audio->lock);
-	/* Following variables are only useful for debugging when
-	 * when record halts unexpectedly. Thus, no mutual exclusion
-	 * enforced
-	 */
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"running %d \n", audio->running);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"buffer_size %d \n", audio->buffer_size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"in_head %d \n", audio->in_head);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"in_tail %d \n", audio->in_tail);
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations audamrnb_in_debug_fops = {
-	.read = audamrnb_in_debug_read,
-	.open = audamrnb_in_debug_open,
-};
-#endif
-
-static int __init audamrnb_in_init(void)
-{
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *dentry;
-#endif
-
-	mutex_init(&the_audio_amrnb_in.lock);
-	mutex_init(&the_audio_amrnb_in.read_lock);
-	spin_lock_init(&the_audio_amrnb_in.dsp_lock);
-	init_waitqueue_head(&the_audio_amrnb_in.wait);
-	init_waitqueue_head(&the_audio_amrnb_in.wait_enable);
-	mutex_init(&the_audio_amrnb_in.write_lock);
-	init_waitqueue_head(&the_audio_amrnb_in.write_wait);
-
-#ifdef CONFIG_DEBUG_FS
-	dentry = debugfs_create_file("msm_amrnb_in", S_IFREG | S_IRUGO, NULL,
-		(void *) &the_audio_amrnb_in, &audamrnb_in_debug_fops);
-
-	if (IS_ERR(dentry))
-		MM_ERR("debugfs_create_file failed\n");
-#endif
-	return misc_register(&audamrnb_in_misc);
-}
-
-static void __exit audamrnb_in_exit(void)
-{
-	misc_deregister(&audamrnb_in_misc);
-}
-
-module_init(audamrnb_in_init);
-module_exit(audamrnb_in_exit);
-
-MODULE_DESCRIPTION("MSM AMRNB Encoder driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5/audio_amrwb.c b/arch/arm/mach-msm/qdsp5/audio_amrwb.c
deleted file mode 100644
index db3a1ab..0000000
--- a/arch/arm/mach-msm/qdsp5/audio_amrwb.c
+++ /dev/null
@@ -1,1774 +0,0 @@
-/* linux/arch/arm/mach-msm/qdsp5/audio_amrwb.c
- *
- * amrwb audio decoder device
- *
- * Based on the mp3 native driver in arch/arm/mach-msm/qdsp5/audio_mp3.c
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2009, 2011-2012 The Linux Foundation. All rights reserved.
- *
- * All source code in this file is licensed under the following license except
- * where indicated.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you can find it at http://www.fsf.org
- */
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/list.h>
-#include <linux/earlysuspend.h>
-#include <linux/slab.h>
-#include <linux/msm_audio.h>
-#include <linux/memory_alloc.h>
-#include <linux/msm_ion.h>
-
-#include <mach/msm_adsp.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/qdsp5/qdsp5audppcmdi.h>
-#include <mach/qdsp5/qdsp5audppmsg.h>
-#include <mach/qdsp5/qdsp5audpp.h>
-#include <mach/qdsp5/qdsp5audplaycmdi.h>
-#include <mach/qdsp5/qdsp5audplaymsg.h>
-#include <mach/qdsp5/qdsp5rmtcmdi.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_memtypes.h>
-
-#include "audmgr.h"
-
-#define BUFSZ 4110 /* Hold minimum 700ms voice data and 14 bytes of meta in*/
-#define DMASZ (BUFSZ * 2)
-
-#define AUDPLAY_INVALID_READ_PTR_OFFSET	0xFFFF
-#define AUDDEC_DEC_AMRWB 11
-
-#define PCM_BUFSZ_MIN 8216 /* 100ms worth of data and 24 bytes of meta out*/
-#define PCM_BUF_MAX_COUNT 5	/* DSP only accepts 5 buffers at most
-				   but support 2 buffers currently */
-#define ROUTING_MODE_FTRT 1
-#define ROUTING_MODE_RT 2
-/* Decoder status received from AUDPPTASK */
-#define  AUDPP_DEC_STATUS_SLEEP	0
-#define	 AUDPP_DEC_STATUS_INIT  1
-#define  AUDPP_DEC_STATUS_CFG   2
-#define  AUDPP_DEC_STATUS_PLAY  3
-
-#define AUDAMRWB_METAFIELD_MASK 0xFFFF0000
-#define AUDAMRWB_EOS_FLG_OFFSET 0x0A /* Offset from beginning of buffer */
-#define AUDAMRWB_EOS_FLG_MASK 0x01
-#define AUDAMRWB_EOS_NONE 0x0 /* No EOS detected */
-#define AUDAMRWB_EOS_SET 0x1 /* EOS set in meta field */
-
-#define AUDAMRWB_EVENT_NUM 10 /* Default number of pre-allocated event pkts */
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;		/* Input usage actual DSP produced PCM size  */
-	unsigned addr;
-	unsigned short mfield_sz; /*only useful for data has meta field */
-};
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-struct audamrwb_suspend_ctl {
-	struct early_suspend node;
-	struct audio *audio;
-};
-#endif
-
-struct audamrwb_event{
-	struct list_head list;
-	int event_type;
-	union msm_audio_event_payload payload;
-};
-
-struct audio {
-	struct buffer out[2];
-
-	spinlock_t dsp_lock;
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed;	/* number of buffers the dsp is waiting for */
-
-	atomic_t out_bytes;
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-
-	/* Host PCM section */
-	struct buffer in[PCM_BUF_MAX_COUNT];
-	struct mutex read_lock;
-	wait_queue_head_t read_wait;	/* Wait queue for read */
-	char *read_data;	/* pointer to reader buffer */
-	int32_t read_phys;	/* physical address of reader buffer */
-	uint8_t read_next;	/* index to input buffers to be read next */
-	uint8_t fill_next;	/* index to buffer that DSP should be filling */
-	uint8_t pcm_buf_count;	/* number of pcm buffer allocated */
-	/* ---- End of Host PCM section */
-
-	struct msm_adsp_module *audplay;
-	struct audmgr audmgr;
-
-	/* configuration to use on next enable */
-	uint32_t out_sample_rate;
-	uint32_t out_channel_mode;
-
-	/* data allocated for various buffers */
-	char *data;
-	int32_t phys; /* physical address of write buffer */
-	void *map_v_read;
-	void *map_v_write;
-	int mfield; /* meta field embedded in data */
-	int rflush; /* Read  flush */
-	int wflush; /* Write flush */
-	int opened;
-	int enabled;
-	int running;
-	int stopped;	/* set when stopped, cleared on flush */
-	int pcm_feedback;
-	int buf_refresh;
-	int rmt_resource_released;
-	int teos; /* valid only if tunnel mode & no data left for decoder */
-	enum msm_aud_decoder_state dec_state;	/* Represents decoder state */
-	int reserved; /* A byte is being reserved */
-	char rsv_byte; /* Handle odd length user data */
-
-	const char *module_name;
-	unsigned queue_id;
-	uint16_t dec_id;
-	uint32_t read_ptr_offset;
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	struct audamrwb_suspend_ctl suspend_ctl;
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *dentry;
-#endif
-
-	wait_queue_head_t wait;
-	struct list_head free_event_queue;
-	struct list_head event_queue;
-	wait_queue_head_t event_wait;
-	spinlock_t event_queue_lock;
-	struct mutex get_event_lock;
-	int event_abort;
-
-	int eq_enable;
-	int eq_needs_commit;
-	audpp_cmd_cfg_object_params_eqalizer eq;
-	audpp_cmd_cfg_object_params_volume vol_pan;
-	struct ion_client *client;
-	struct ion_handle *input_buff_handle;
-	struct ion_handle *output_buff_handle;
-};
-
-static int auddec_dsp_config(struct audio *audio, int enable);
-static void audpp_cmd_cfg_adec_params(struct audio *audio);
-static void audpp_cmd_cfg_routing_mode(struct audio *audio);
-static void audamrwb_send_data(struct audio *audio, unsigned needed);
-static void audamrwb_config_hostpcm(struct audio *audio);
-static void audamrwb_buffer_refresh(struct audio *audio);
-static void audamrwb_dsp_event(void *private, unsigned id, uint16_t *msg);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audamrwb_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload);
-#endif
-
-static int rmt_put_resource(struct audio *audio)
-{
-	struct aud_codec_config_cmd cmd;
-	unsigned short client_idx;
-
-	cmd.cmd_id = RM_CMD_AUD_CODEC_CFG;
-	cmd.client_id = RM_AUD_CLIENT_ID;
-	cmd.task_id = audio->dec_id;
-	cmd.enable = RMT_DISABLE;
-	cmd.dec_type = AUDDEC_DEC_AMRWB;
-	client_idx = ((cmd.client_id << 8) | cmd.task_id);
-
-	return put_adsp_resource(client_idx, &cmd, sizeof(cmd));
-}
-
-static int rmt_get_resource(struct audio *audio)
-{
-	struct aud_codec_config_cmd cmd;
-	unsigned short client_idx;
-
-	cmd.cmd_id = RM_CMD_AUD_CODEC_CFG;
-	cmd.client_id = RM_AUD_CLIENT_ID;
-	cmd.task_id = audio->dec_id;
-	cmd.enable = RMT_ENABLE;
-	cmd.dec_type = AUDDEC_DEC_AMRWB;
-	client_idx = ((cmd.client_id << 8) | cmd.task_id);
-
-	return get_adsp_resource(client_idx, &cmd, sizeof(cmd));
-}
-
-/* must be called with audio->lock held */
-static int audamrwb_enable(struct audio *audio)
-{
-	struct audmgr_config cfg;
-	int rc;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	if (audio->enabled)
-		return 0;
-
-	if (audio->rmt_resource_released == 1) {
-		audio->rmt_resource_released = 0;
-		rc = rmt_get_resource(audio);
-		if (rc) {
-			MM_ERR("ADSP resources are not available for AMRWB \
-				session 0x%08x on decoder: %d\n Ignoring \
-				error and going ahead with the playback\n",
-				(int)audio, audio->dec_id);
-		}
-	}
-
-	audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-
-	if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK) {
-		cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE;
-		cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000;
-		cfg.def_method = RPC_AUD_DEF_METHOD_PLAYBACK;
-		cfg.codec = RPC_AUD_DEF_CODEC_AMR_WB;
-		cfg.snd_method = RPC_SND_METHOD_MIDI;
-
-		rc = audmgr_enable(&audio->audmgr, &cfg);
-		if (rc < 0) {
-			msm_adsp_dump(audio->audplay);
-			return rc;
-		}
-	}
-
-	if (msm_adsp_enable(audio->audplay)) {
-		MM_ERR("msm_adsp_enable(audplay) failed\n");
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_disable(&audio->audmgr);
-		return -ENODEV;
-	}
-
-	if (audpp_enable(audio->dec_id, audamrwb_dsp_event, audio)) {
-		MM_ERR("audpp_enable() failed\n");
-		msm_adsp_disable(audio->audplay);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_disable(&audio->audmgr);
-		return -ENODEV;
-	}
-	audio->enabled = 1;
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audamrwb_disable(struct audio *audio)
-{
-	int rc = 0;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-		auddec_dsp_config(audio, 0);
-		rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-		if (rc == 0)
-			rc = -ETIMEDOUT;
-		else if (audio->dec_state != MSM_AUD_DECODER_STATE_CLOSE)
-			rc = -EFAULT;
-		else
-			rc = 0;
-		audio->stopped = 1;
-		wake_up(&audio->write_wait);
-		wake_up(&audio->read_wait);
-		msm_adsp_disable(audio->audplay);
-		audpp_disable(audio->dec_id, audio);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK) {
-			rc = audmgr_disable(&audio->audmgr);
-			if (rc < 0)
-				msm_adsp_dump(audio->audplay);
-		}
-		audio->out_needed = 0;
-		rmt_put_resource(audio);
-		audio->rmt_resource_released = 1;
-	}
-	return rc;
-}
-
-/* ------------------- dsp --------------------- */
-static void audamrwb_update_pcm_buf_entry(struct audio *audio,
-		uint32_t *payload)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	if (audio->rflush)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < payload[1]; index++) {
-		if (audio->in[audio->fill_next].addr ==
-		    payload[2 + index * 2]) {
-			MM_DBG("in[%d] ready\n", audio->fill_next);
-			audio->in[audio->fill_next].used =
-			    payload[3 + index * 2];
-			if ((++audio->fill_next) == audio->pcm_buf_count)
-				audio->fill_next = 0;
-
-		} else {
-			MM_ERR("expected=%x ret=%x\n",
-					audio->in[audio->fill_next].addr,
-					payload[1 + index * 2]);
-			break;
-		}
-	}
-	if (audio->in[audio->fill_next].used == 0) {
-		audamrwb_buffer_refresh(audio);
-	} else {
-		MM_DBG("read cannot keep up\n");
-		audio->buf_refresh = 1;
-	}
-	wake_up(&audio->read_wait);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audplay_dsp_event(void *data, unsigned id, size_t len,
-			      void (*getevent) (void *ptr, size_t len))
-{
-	struct audio *audio = data;
-	uint32_t msg[28];
-	getevent(msg, sizeof(msg));
-
-	MM_DBG("msg_id=%x\n", id);
-
-	switch (id) {
-	case AUDPLAY_MSG_DEC_NEEDS_DATA:
-		audamrwb_send_data(audio, 1);
-		break;
-
-	case AUDPLAY_MSG_BUFFER_UPDATE:
-		audamrwb_update_pcm_buf_entry(audio, msg);
-		break;
-
-	default:
-		MM_ERR("unexpected message from decoder\n");
-	}
-}
-
-static void audamrwb_dsp_event(void *private, unsigned id, uint16_t *msg)
-{
-	struct audio *audio = private;
-
-	switch (id) {
-	case AUDPP_MSG_STATUS_MSG:{
-			unsigned status = msg[1];
-
-			switch (status) {
-			case AUDPP_DEC_STATUS_SLEEP: {
-				uint16_t reason = msg[2];
-				MM_DBG("decoder status:sleep reason=0x%04x\n",
-					reason);
-				if ((reason == AUDPP_MSG_REASON_MEM)
-					|| (reason ==
-					AUDPP_MSG_REASON_NODECODER)) {
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_FAILURE;
-					wake_up(&audio->wait);
-				} else if (reason == AUDPP_MSG_REASON_NONE) {
-					/* decoder is in disable state */
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_CLOSE;
-					wake_up(&audio->wait);
-				}
-				break;
-			}
-			case AUDPP_DEC_STATUS_INIT:
-				MM_DBG("decoder status: init\n");
-				if (audio->pcm_feedback)
-					audpp_cmd_cfg_routing_mode(audio);
-				else
-					audpp_cmd_cfg_adec_params(audio);
-				break;
-
-			case AUDPP_DEC_STATUS_CFG:
-				MM_DBG("decoder status: cfg\n");
-				break;
-			case AUDPP_DEC_STATUS_PLAY:
-				MM_DBG("decoder status: play\n");
-				if (audio->pcm_feedback) {
-					audamrwb_config_hostpcm(audio);
-					audamrwb_buffer_refresh(audio);
-				}
-				audio->dec_state =
-					MSM_AUD_DECODER_STATE_SUCCESS;
-				wake_up(&audio->wait);
-				break;
-			default:
-				MM_DBG("unknown decoder status\n");
-				break;
-			}
-			break;
-		}
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_DBG("CFG_MSG ENABLE\n");
-			auddec_dsp_config(audio, 1);
-			audio->out_needed = 0;
-			audio->running = 1;
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-			audpp_dsp_set_eq(audio->dec_id,	audio->eq_enable,
-								&audio->eq);
-			audpp_avsync(audio->dec_id, 22050);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			MM_DBG("CFG_MSG DISABLE\n");
-			audpp_avsync(audio->dec_id, 0);
-			audio->running = 0;
-		} else {
-			MM_DBG("CFG_MSG %d?\n", msg[0]);
-		}
-		break;
-	case AUDPP_MSG_ROUTING_ACK:
-		MM_DBG("ROUTING_ACK mode=%d\n", msg[1]);
-		audpp_cmd_cfg_adec_params(audio);
-		break;
-	case AUDPP_MSG_FLUSH_ACK:
-		MM_DBG("FLUSH_ACK\n");
-		audio->wflush = 0;
-		audio->rflush = 0;
-		wake_up(&audio->write_wait);
-		if (audio->pcm_feedback)
-			audamrwb_buffer_refresh(audio);
-		break;
-	case AUDPP_MSG_PCMDMAMISSED:
-		MM_DBG("PCMDMAMISSED\n");
-		audio->teos = 1;
-		wake_up(&audio->write_wait);
-		break;
-	default:
-		MM_DBG("UNKNOWN (%d)\n", id);
-	}
-
-}
-
-struct msm_adsp_ops audplay_adsp_ops_amrwb = {
-	.event = audplay_dsp_event,
-};
-
-#define audplay_send_queue0(audio, cmd, len) \
-	msm_adsp_write(audio->audplay, audio->queue_id, \
-			cmd, len)
-
-static int auddec_dsp_config(struct audio *audio, int enable)
-{
-	u16 cfg_dec_cmd[AUDPP_CMD_CFG_DEC_TYPE_LEN / sizeof(unsigned short)];
-
-	memset(cfg_dec_cmd, 0, sizeof(cfg_dec_cmd));
-	cfg_dec_cmd[0] = AUDPP_CMD_CFG_DEC_TYPE;
-	if (enable)
-		cfg_dec_cmd[1 + audio->dec_id] = AUDPP_CMD_UPDATDE_CFG_DEC |
-			AUDPP_CMD_ENA_DEC_V | AUDDEC_DEC_AMRWB;
-	else
-		cfg_dec_cmd[1 + audio->dec_id] = AUDPP_CMD_UPDATDE_CFG_DEC |
-			AUDPP_CMD_DIS_DEC_V;
-
-	return audpp_send_queue1(&cfg_dec_cmd, sizeof(cfg_dec_cmd));
-}
-
-static void audpp_cmd_cfg_adec_params(struct audio *audio)
-{
-	struct audpp_cmd_cfg_adec_params_amrwb cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_CMD_CFG_ADEC_PARAMS;
-	cmd.common.length = AUDPP_CMD_CFG_ADEC_PARAMS_AMRWB_LEN;
-	cmd.common.dec_id = audio->dec_id;
-	cmd.common.input_sampling_frequency = audio->out_sample_rate;
-	cmd.stereo_cfg = audio->out_channel_mode;
-	audpp_send_queue2(&cmd, sizeof(cmd));
-}
-
-static void audpp_cmd_cfg_routing_mode(struct audio *audio)
-{
-	struct audpp_cmd_routing_mode cmd;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPP_CMD_ROUTING_MODE;
-	cmd.object_number = audio->dec_id;
-	if (audio->pcm_feedback)
-		cmd.routing_mode = ROUTING_MODE_FTRT;
-	else
-		cmd.routing_mode = ROUTING_MODE_RT;
-
-	audpp_send_queue1(&cmd, sizeof(cmd));
-}
-
-static int audplay_dsp_send_data_avail(struct audio *audio,
-				       unsigned idx, unsigned len)
-{
-	struct audplay_cmd_bitstream_data_avail_nt2 cmd;
-
-	cmd.cmd_id = AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2;
-	if (audio->mfield)
-		cmd.decoder_id = AUDAMRWB_METAFIELD_MASK |
-			(audio->out[idx].mfield_sz >> 1);
-	else
-		cmd.decoder_id = audio->dec_id;
-	cmd.buf_ptr = audio->out[idx].addr;
-	cmd.buf_size = len / 2;
-	cmd.partition_number = 0;
-	return audplay_send_queue0(audio, &cmd, sizeof(cmd));
-}
-
-static void audamrwb_buffer_refresh(struct audio *audio)
-{
-	struct audplay_cmd_buffer_refresh refresh_cmd;
-
-	refresh_cmd.cmd_id = AUDPLAY_CMD_BUFFER_REFRESH;
-	refresh_cmd.num_buffers = 1;
-	refresh_cmd.buf0_address = audio->in[audio->fill_next].addr;
-	refresh_cmd.buf0_length = audio->in[audio->fill_next].size;
-	refresh_cmd.buf_read_count = 0;
-	MM_DBG("buf0_addr=%x buf0_len=%d\n", refresh_cmd.buf0_address,
-			refresh_cmd.buf0_length);
-	(void)audplay_send_queue0(audio, &refresh_cmd, sizeof(refresh_cmd));
-}
-
-static void audamrwb_config_hostpcm(struct audio *audio)
-{
-	struct audplay_cmd_hpcm_buf_cfg cfg_cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	cfg_cmd.cmd_id = AUDPLAY_CMD_HPCM_BUF_CFG;
-	cfg_cmd.max_buffers = audio->pcm_buf_count;
-	cfg_cmd.byte_swap = 0;
-	cfg_cmd.hostpcm_config = (0x8000) | (0x4000);
-	cfg_cmd.feedback_frequency = 1;
-	cfg_cmd.partition_number = 0;
-	(void)audplay_send_queue0(audio, &cfg_cmd, sizeof(cfg_cmd));
-
-}
-
-static void audamrwb_send_data(struct audio *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			MM_DBG("frame %d busy\n", audio->out_tail);
-			audplay_dsp_send_data_avail(audio, audio->out_tail,
-						    frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
- done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-
-static void audamrwb_flush(struct audio *audio)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->out[0].used = 0;
-	audio->out[1].used = 0;
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->reserved = 0;
-	audio->out_needed = 0;
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	atomic_set(&audio->out_bytes, 0);
-}
-
-static void audamrwb_flush_pcm_buf(struct audio *audio)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < PCM_BUF_MAX_COUNT; index++)
-		audio->in[index].used = 0;
-
-	audio->buf_refresh = 0;
-	audio->read_next = 0;
-	audio->fill_next = 0;
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audamrwb_ioport_reset(struct audio *audio)
-{
-	/* Make sure read/write thread are free from
-	 * sleep and knowing that system is not able
-	 * to process io request at the moment
-	 */
-	wake_up(&audio->write_wait);
-	mutex_lock(&audio->write_lock);
-	audamrwb_flush(audio);
-	mutex_unlock(&audio->write_lock);
-	wake_up(&audio->read_wait);
-	mutex_lock(&audio->read_lock);
-	audamrwb_flush_pcm_buf(audio);
-	mutex_unlock(&audio->read_lock);
-}
-
-static int audamrwb_events_pending(struct audio *audio)
-{
-	unsigned long flags;
-	int empty;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	empty = !list_empty(&audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	return empty || audio->event_abort;
-}
-
-static void audamrwb_reset_event_queue(struct audio *audio)
-{
-	unsigned long flags;
-	struct audamrwb_event *drv_evt;
-	struct list_head *ptr, *next;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	list_for_each_safe(ptr, next, &audio->event_queue) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audamrwb_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	list_for_each_safe(ptr, next, &audio->free_event_queue) {
-		drv_evt = list_first_entry(&audio->free_event_queue,
-				struct audamrwb_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	return;
-}
-
-static long audamrwb_process_event_req(struct audio *audio, void __user *arg)
-{
-	long rc;
-	struct msm_audio_event usr_evt;
-	struct audamrwb_event *drv_evt = NULL;
-	int timeout;
-	unsigned long flags;
-
-	if (copy_from_user(&usr_evt, arg, sizeof(struct msm_audio_event)))
-		return -EFAULT;
-
-	timeout = (int) usr_evt.timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(
-			audio->event_wait, audamrwb_events_pending(audio),
-			msecs_to_jiffies(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(
-			audio->event_wait, audamrwb_events_pending(audio));
-	}
-
-	if (rc < 0)
-		return rc;
-
-	if (audio->event_abort) {
-		audio->event_abort = 0;
-		return -ENODEV;
-	}
-
-	rc = 0;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	if (!list_empty(&audio->event_queue)) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audamrwb_event, list);
-		list_del(&drv_evt->list);
-	}
-
-	if (drv_evt) {
-		usr_evt.event_type = drv_evt->event_type;
-		usr_evt.event_payload = drv_evt->payload;
-		list_add_tail(&drv_evt->list, &audio->free_event_queue);
-	} else
-		rc = -1;
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	if (!rc && copy_to_user(arg, &usr_evt, sizeof(usr_evt)))
-		rc = -EFAULT;
-
-	return rc;
-}
-
-static int audio_enable_eq(struct audio *audio, int enable)
-{
-	if (audio->eq_enable == enable && !audio->eq_needs_commit)
-		return 0;
-
-	audio->eq_enable = enable;
-
-	if (audio->running) {
-		audpp_dsp_set_eq(audio->dec_id, enable, &audio->eq);
-		audio->eq_needs_commit = 0;
-	}
-	return 0;
-}
-
-static long audamrwb_ioctl(struct file *file, unsigned int cmd,
-		unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = -EINVAL;
-	unsigned long flags = 0;
-	uint16_t enable_mask;
-	int enable;
-	int prev_state;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	int len = 0;
-
-	MM_DBG("cmd = %d\n", cmd);
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		stats.byte_count = audpp_avsync_byte_count(audio->dec_id);
-		stats.sample_count = audpp_avsync_sample_count(audio->dec_id);
-		if (copy_to_user((void *)arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-
-	switch (cmd) {
-	case AUDIO_ENABLE_AUDPP:
-		if (copy_from_user(&enable_mask, (void *) arg,
-						sizeof(enable_mask))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		enable = (enable_mask & EQ_ENABLE) ? 1 : 0;
-		audio_enable_eq(audio, enable);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-	case AUDIO_SET_VOLUME:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.volume = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_PAN:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.pan = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_EQ:
-		prev_state = audio->eq_enable;
-		audio->eq_enable = 0;
-		if (copy_from_user(&audio->eq.num_bands, (void *) arg,
-				sizeof(audio->eq) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2))) {
-			rc = -EFAULT;
-			break;
-		}
-		audio->eq_enable = prev_state;
-		audio->eq_needs_commit = 1;
-		rc = 0;
-		break;
-	}
-
-	if (-EINVAL != rc)
-		return rc;
-
-	if (cmd == AUDIO_GET_EVENT) {
-		MM_DBG("AUDIO_GET_EVENT\n");
-		if (mutex_trylock(&audio->get_event_lock)) {
-			rc = audamrwb_process_event_req(audio,
-					(void __user *) arg);
-			mutex_unlock(&audio->get_event_lock);
-		} else
-			rc = -EBUSY;
-		return rc;
-	}
-
-	if (cmd == AUDIO_ABORT_GET_EVENT) {
-		audio->event_abort = 1;
-		wake_up(&audio->event_wait);
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		MM_DBG("AUDIO_START\n");
-		rc = audamrwb_enable(audio);
-		if (!rc) {
-			rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-			MM_INFO("dec_state %d rc = %d\n", audio->dec_state, rc);
-
-			if (audio->dec_state != MSM_AUD_DECODER_STATE_SUCCESS)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		break;
-	case AUDIO_STOP:
-		MM_DBG("AUDIO_STOP\n");
-		rc = audamrwb_disable(audio);
-		audamrwb_ioport_reset(audio);
-		audio->stopped = 0;
-		break;
-	case AUDIO_FLUSH:
-		MM_DBG(" AUDIO_FLUSH\n");
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audamrwb_ioport_reset(audio);
-		if (audio->running) {
-			audpp_flush(audio->dec_id);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-	case AUDIO_SET_CONFIG:{
-			struct msm_audio_config config;
-			if (copy_from_user
-			    (&config, (void *)arg, sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-			if (config.channel_count == 1)
-				config.channel_count =
-					AUDPP_CMD_PCM_INTF_MONO_V;
-			else if (config.channel_count == 2)
-				config.channel_count =
-					AUDPP_CMD_PCM_INTF_STEREO_V;
-			else
-				rc = -EINVAL;
-			audio->out_channel_mode = config.channel_count;
-			audio->out_sample_rate = config.sample_rate;
-			audio->mfield = config.meta_field;
-			rc = 0;
-			break;
-		}
-	case AUDIO_GET_CONFIG:{
-			struct msm_audio_config config;
-			config.buffer_size = BUFSZ;
-			config.buffer_count = 2;
-			config.sample_rate = audio->out_sample_rate;
-			if (audio->out_channel_mode ==
-					AUDPP_CMD_PCM_INTF_MONO_V)
-				config.channel_count = 1;
-			else
-				config.channel_count = 2;
-			config.meta_field = 0;
-			config.unused[0] = 0;
-			config.unused[1] = 0;
-			config.unused[2] = 0;
-			if (copy_to_user((void *)arg, &config,
-					 sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-
-			break;
-		}
-	case AUDIO_GET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			config.pcm_feedback = 0;
-			config.buffer_count = PCM_BUF_MAX_COUNT;
-			config.buffer_size = PCM_BUFSZ_MIN;
-			if (copy_to_user((void *)arg, &config,
-					 sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_SET_PCM_CONFIG:{
-		struct msm_audio_pcm_config config;
-		if (copy_from_user
-		    (&config, (void *)arg, sizeof(config))) {
-			rc = -EFAULT;
-			break;
-		}
-		if ((config.buffer_count > PCM_BUF_MAX_COUNT) ||
-		    (config.buffer_count == 1))
-			config.buffer_count = PCM_BUF_MAX_COUNT;
-
-		if (config.buffer_size < PCM_BUFSZ_MIN)
-			config.buffer_size = PCM_BUFSZ_MIN;
-
-			/* Check if pcm feedback is required */
-		if ((config.pcm_feedback) && (!audio->read_data)) {
-			MM_DBG("allocate PCM buf %d\n", config.buffer_count *
-					config.buffer_size);
-				handle = ion_alloc(audio->client,
-					(config.buffer_size *
-					config.buffer_count),
-					SZ_4K, ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-				if (IS_ERR_OR_NULL(handle)) {
-					MM_ERR("Unable to alloc I/P buffs\n");
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-					break;
-				}
-
-				audio->input_buff_handle = handle;
-
-				rc = ion_phys(audio->client ,
-					handle, &addr, &len);
-				if (rc) {
-					MM_ERR("Invalid phy: %x sz: %x\n",
-						(unsigned int) addr,
-						(unsigned int) len);
-					ion_free(audio->client, handle);
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-					break;
-				} else {
-					MM_INFO("Got valid phy: %x sz: %x\n",
-						(unsigned int) audio->read_phys,
-						(unsigned int) len);
-				}
-				audio->read_phys = (int32_t)addr;
-
-				rc = ion_handle_get_flags(audio->client,
-					handle, &ionflag);
-				if (rc) {
-					MM_ERR("could not get flags\n");
-					ion_free(audio->client, handle);
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-					break;
-				}
-				audio->map_v_read = ion_map_kernel(
-					audio->client, handle);
-			if (IS_ERR(audio->map_v_read)) {
-				MM_ERR("failed to map mem for read buf\n");
-				ion_free(audio->client, handle);
-				audio->input_buff_handle = NULL;
-				rc = -ENOMEM;
-			} else {
-				uint8_t index;
-				uint32_t offset = 0;
-				audio->read_data = audio->map_v_read;
-				audio->pcm_feedback = 1;
-				audio->buf_refresh = 0;
-				audio->pcm_buf_count =
-					config.buffer_count;
-				audio->read_next = 0;
-				audio->fill_next = 0;
-
-				for (index = 0;
-				index < config.buffer_count; index++) {
-					audio->in[index].data =
-						audio->read_data + offset;
-					audio->in[index].addr =
-					    audio->read_phys + offset;
-					audio->in[index].size =
-					    config.buffer_size;
-					audio->in[index].used = 0;
-					offset += config.buffer_size;
-				}
-				MM_DBG("read buf: phy addr 0x%08x \
-						kernel addr 0x%08x\n",
-						audio->read_phys,
-						(int)audio->read_data);
-				rc = 0;
-			}
-		} else {
-			rc = 0;
-		}
-		break;
-	}
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-/* Only useful in tunnel-mode */
-static int audamrwb_fsync(struct file *file, loff_t a, loff_t b,
-	int datasync)
-{
-	struct audio *audio = file->private_data;
-	struct buffer *frame;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	if (!audio->running || audio->pcm_feedback) {
-		rc = -EINVAL;
-		goto done_nolock;
-	}
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(!audio->out[0].used &&
-		!audio->out[1].used &&
-		audio->out_needed) || audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (audio->reserved) {
-		MM_DBG("send reserved byte\n");
-		frame = audio->out + audio->out_tail;
-		((char *) frame->data)[0] = audio->rsv_byte;
-		((char *) frame->data)[1] = 0;
-		frame->used = 2;
-		audamrwb_send_data(audio, 0);
-
-		rc = wait_event_interruptible(audio->write_wait,
-			(!audio->out[0].used &&
-			!audio->out[1].used &&
-			audio->out_needed) || audio->wflush);
-
-		if (rc < 0)
-			goto done;
-		else if (audio->wflush) {
-			rc = -EBUSY;
-			goto done;
-		}
-	}
-
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		audio->teos || audio->wflush);
-
-	if (audio->wflush)
-		rc = -EBUSY;
-
-done:
-	mutex_unlock(&audio->write_lock);
-done_nolock:
-	return rc;
-}
-
-static ssize_t audamrwb_read(struct file *file, char __user *buf, size_t count,
-			  loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	int rc = 0;
-
-	if (!audio->pcm_feedback)
-		return 0; /* PCM feedback is not enabled. Nothing to read */
-
-	mutex_lock(&audio->read_lock);
-	MM_DBG("count %d\n", count);
-	while (count > 0) {
-		rc = wait_event_interruptible(audio->read_wait,
-			(audio->in[audio->read_next].used > 0) ||
-			(audio->stopped) || (audio->rflush));
-
-		if (rc < 0)
-			break;
-
-		if (audio->stopped || audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (count < audio->in[audio->read_next].used) {
-			/* Read must happen in frame boundary. Since driver does
-			 * not know frame size, read count must be greater or
-			 * equal to size of PCM samples
-			 */
-			MM_DBG("read stop - partial frame\n");
-			break;
-		} else {
-			MM_DBG("read from in[%d]\n",
-				audio->read_next);
-
-			if (copy_to_user
-			    (buf, audio->in[audio->read_next].data,
-			     audio->in[audio->read_next].used)) {
-				MM_ERR("invalid addr %x \n", (unsigned int)buf);
-				rc = -EFAULT;
-				break;
-			}
-			count -= audio->in[audio->read_next].used;
-			buf += audio->in[audio->read_next].used;
-			audio->in[audio->read_next].used = 0;
-			if ((++audio->read_next) == audio->pcm_buf_count)
-				audio->read_next = 0;
-			break;
-		}
-	}
-
-	/* don't feed output buffer to HW decoder during flushing
-	 * buffer refresh command will be sent once flush completes
-	 * send buf refresh command here can confuse HW decoder
-	 */
-	if (audio->buf_refresh && !audio->rflush) {
-		audio->buf_refresh = 0;
-		MM_ERR("kick start pcm feedback again\n");
-		audamrwb_buffer_refresh(audio);
-	}
-
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		rc = buf - start;
-
-	MM_DBG("read %d bytes\n", rc);
-	return rc;
-}
-
-static int audamrwb_process_eos(struct audio *audio,
-		const char __user *buf_start, unsigned short mfield_size)
-{
-	struct buffer *frame;
-	char *buf_ptr;
-	int rc = 0;
-
-	MM_DBG("signal input EOS reserved=%d\n", audio->reserved);
-	if (audio->reserved) {
-		MM_DBG("Pass reserve byte\n");
-		frame = audio->out + audio->out_head;
-		buf_ptr = frame->data;
-		rc = wait_event_interruptible(audio->write_wait,
-					(frame->used == 0)
-					|| (audio->stopped)
-					|| (audio->wflush));
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-	buf_ptr[0] = audio->rsv_byte;
-	buf_ptr[1] = 0;
-	audio->out_head ^= 1;
-	frame->mfield_sz = 0;
-	audio->reserved = 0;
-	frame->used = 2;
-	audamrwb_send_data(audio, 0);
-	}
-
-	MM_DBG("Now signal input EOS after reserved bytes %d %d %d\n",
-		audio->out[0].used, audio->out[1].used, audio->out_needed);
-
-	frame = audio->out + audio->out_head;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	audamrwb_send_data(audio, 0);
-
-done:
-	return rc;
-}
-
-static ssize_t audamrwb_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	size_t xfer;
-	char *cpy_ptr;
-	int rc = 0, eos_condition = AUDAMRWB_EOS_NONE;
-	unsigned short mfield_size = 0;
-	unsigned dsize;
-
-	MM_DBG("cnt=%d\n", count);
-
-	mutex_lock(&audio->write_lock);
-	while (count > 0) {
-		frame = audio->out + audio->out_head;
-		cpy_ptr = frame->data;
-		dsize = 0;
-		rc = wait_event_interruptible(audio->write_wait,
-					      (frame->used == 0)
-						|| (audio->stopped)
-						|| (audio->wflush));
-
-		MM_DBG("buffer available\n");
-		if (rc < 0)
-			break;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (audio->mfield) {
-			if (buf == start) {
-				/* Processing beginning of user buffer */
-				if (__get_user(mfield_size,
-					(unsigned short __user *) buf)) {
-					rc = -EFAULT;
-					break;
-				} else 	if (mfield_size > count) {
-					rc = -EINVAL;
-					break;
-				}
-				MM_DBG("mf offset_val %x\n", mfield_size);
-				if (copy_from_user(cpy_ptr, buf, mfield_size)) {
-					rc = -EFAULT;
-					break;
-				}
-				/* Check if EOS flag is set and buffer
-				 * contains just meta field
-				 */
-				if (cpy_ptr[AUDAMRWB_EOS_FLG_OFFSET] &
-						AUDAMRWB_EOS_FLG_MASK) {
-					MM_DBG("eos set\n");
-					eos_condition = AUDAMRWB_EOS_SET;
-					if (mfield_size == count) {
-						buf += mfield_size;
-						break;
-					} else
-					cpy_ptr[AUDAMRWB_EOS_FLG_OFFSET] &=
-							~AUDAMRWB_EOS_FLG_MASK;
-				}
-				cpy_ptr += mfield_size;
-				count -= mfield_size;
-				dsize += mfield_size;
-				buf += mfield_size;
-			} else {
-				mfield_size = 0;
-				MM_DBG("continuous buffer\n");
-			}
-			frame->mfield_sz = mfield_size;
-		}
-
-		if (audio->reserved) {
-			MM_DBG("append reserved byte %x\n", audio->rsv_byte);
-			*cpy_ptr = audio->rsv_byte;
-			xfer = (count > ((frame->size - mfield_size) - 1)) ?
-				((frame->size - mfield_size) - 1) : count;
-			cpy_ptr++;
-			dsize += 1;
-			audio->reserved = 0;
-		} else
-			xfer = (count > (frame->size - mfield_size)) ?
-				(frame->size - mfield_size) : count;
-
-		if (copy_from_user(cpy_ptr, buf, xfer)) {
-			rc = -EFAULT;
-			break;
-		}
-
-		dsize += xfer;
-		if (dsize & 1) {
-			audio->rsv_byte = ((char *) frame->data)[dsize - 1];
-			MM_DBG("odd length buf reserve last byte %x\n",
-					audio->rsv_byte);
-			audio->reserved = 1;
-			dsize--;
-		}
-		count -= xfer;
-		buf += xfer;
-
-		if (dsize > 0) {
-			audio->out_head ^= 1;
-			frame->used = dsize;
-			audamrwb_send_data(audio, 0);
-		}
-	}
-	MM_DBG("eos_condition %x buf[0x%x] start[0x%x]\n", eos_condition,
-			(int) buf, (int) start);
-	if (eos_condition == AUDAMRWB_EOS_SET)
-		rc = audamrwb_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	if (!rc) {
-		if (buf > start)
-			return buf - start;
-	}
-	return rc;
-}
-
-static int audamrwb_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	MM_INFO("audio instance 0x%08x freeing\n", (int)audio);
-	mutex_lock(&audio->lock);
-	audamrwb_disable(audio);
-	if (audio->rmt_resource_released == 0)
-		rmt_put_resource(audio);
-	audamrwb_flush(audio);
-	audamrwb_flush_pcm_buf(audio);
-	msm_adsp_put(audio->audplay);
-	audpp_adec_free(audio->dec_id);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	unregister_early_suspend(&audio->suspend_ctl.node);
-#endif
-	audio->event_abort = 1;
-	wake_up(&audio->event_wait);
-	audamrwb_reset_event_queue(audio);
-	ion_unmap_kernel(audio->client, audio->output_buff_handle);
-	ion_free(audio->client, audio->output_buff_handle);
-	if (audio->input_buff_handle != NULL) {
-		ion_unmap_kernel(audio->client, audio->input_buff_handle);
-		ion_free(audio->client, audio->input_buff_handle);
-	}
-	ion_client_destroy(audio->client);
-	mutex_unlock(&audio->lock);
-#ifdef CONFIG_DEBUG_FS
-	if (audio->dentry)
-		debugfs_remove(audio->dentry);
-#endif
-	kfree(audio);
-	return 0;
-}
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audamrwb_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload)
-{
-	struct audamrwb_event *e_node = NULL;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-
-	if (!list_empty(&audio->free_event_queue)) {
-		e_node = list_first_entry(&audio->free_event_queue,
-				struct audamrwb_event, list);
-		list_del(&e_node->list);
-	} else {
-		e_node = kmalloc(sizeof(struct audamrwb_event), GFP_ATOMIC);
-		if (!e_node) {
-			MM_ERR("No mem to post event %d\n", type);
-			spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-			return;
-		}
-	}
-
-	e_node->event_type = type;
-	e_node->payload = payload;
-
-	list_add_tail(&e_node->list, &audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	wake_up(&audio->event_wait);
-}
-
-static void audamrwb_suspend(struct early_suspend *h)
-{
-	struct audamrwb_suspend_ctl *ctl =
-		container_of(h, struct audamrwb_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audamrwb_post_event(ctl->audio, AUDIO_EVENT_SUSPEND, payload);
-}
-
-static void audamrwb_resume(struct early_suspend *h)
-{
-	struct audamrwb_suspend_ctl *ctl =
-		container_of(h, struct audamrwb_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audamrwb_post_event(ctl->audio, AUDIO_EVENT_RESUME, payload);
-}
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-static ssize_t audamrwb_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static ssize_t audamrwb_debug_read(struct file *file, char __user *buf,
-					size_t count, loff_t *ppos)
-{
-	const int debug_bufmax = 1024;
-	static char buffer[1024];
-	int n = 0, i;
-	struct audio *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	n = scnprintf(buffer, debug_bufmax, "opened %d\n", audio->opened);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"enabled %d\n", audio->enabled);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"stopped %d\n", audio->stopped);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_feedback %d\n", audio->pcm_feedback);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_buf_sz %d\n", audio->out[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_buf_count %d \n", audio->pcm_buf_count);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_buf_sz %d \n", audio->in[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"volume %x \n", audio->vol_pan.volume);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"sample rate %d \n", audio->out_sample_rate);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"channel mode %d \n", audio->out_channel_mode);
-	mutex_unlock(&audio->lock);
-	/* Following variables are only useful for debugging when
-	 * when playback halts unexpectedly. Thus, no mutual exclusion
-	 * enforced
-	 */
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"wflush %d\n", audio->wflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"rflush %d\n", audio->rflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"running %d \n", audio->running);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"dec state %d \n", audio->dec_state);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_needed %d \n", audio->out_needed);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_head %d \n", audio->out_head);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_tail %d \n", audio->out_tail);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out[0].used %d \n", audio->out[0].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out[1].used %d \n", audio->out[1].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"buffer_refresh %d \n", audio->buf_refresh);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"read_next %d \n", audio->read_next);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"fill_next %d \n", audio->fill_next);
-	for (i = 0; i < audio->pcm_buf_count; i++)
-		n += scnprintf(buffer + n, debug_bufmax - n,
-				"in[%d].used %d \n", i, audio->in[i].used);
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations audamrwb_debug_fops = {
-	.read = audamrwb_debug_read,
-	.open = audamrwb_debug_open,
-};
-#endif
-
-static int audamrwb_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = NULL;
-	int rc = 0, dec_attrb, decid, i;
-	struct audamrwb_event *e_node = NULL;
-	unsigned mem_sz = DMASZ;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	struct ion_client *client = NULL;
-	int len = 0;
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_amrwb_" + 5];
-#endif
-
-	/* Allocate Mem for audio instance */
-	audio = kzalloc(sizeof(struct audio), GFP_KERNEL);
-	if (!audio) {
-		MM_ERR("No memory to allocate audio instance\n");
-		rc = -ENOMEM;
-		goto done;
-	}
-	MM_INFO("audio instance 0x%08x created\n", (int)audio);
-
-	/* Allocate the decoder */
-	dec_attrb = AUDDEC_DEC_AMRWB;
-	if (file->f_mode & FMODE_READ)
-		dec_attrb |= MSM_AUD_MODE_NONTUNNEL;
-	else
-		dec_attrb |= MSM_AUD_MODE_TUNNEL;
-
-	decid = audpp_adec_alloc(dec_attrb, &audio->module_name,
-			&audio->queue_id);
-
-	if (decid < 0) {
-		MM_ERR("No free decoder available, freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENODEV;
-		kfree(audio);
-		goto done;
-	}
-
-	audio->dec_id = decid & MSM_AUD_DECODER_MASK;
-
-	client = msm_ion_client_create(UINT_MAX, "Audio_AMR_WB_Client");
-	if (IS_ERR_OR_NULL(client)) {
-		pr_err("Unable to create ION client\n");
-		rc = -ENOMEM;
-		goto client_create_error;
-	}
-	audio->client = client;
-
-	handle = ion_alloc(client, mem_sz, SZ_4K,
-		ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-	if (IS_ERR_OR_NULL(handle)) {
-		MM_ERR("Unable to create allocate O/P buffers\n");
-		goto output_buff_alloc_error;
-	}
-	audio->output_buff_handle = handle;
-
-	rc = ion_phys(client, handle, &addr, &len);
-	if (rc) {
-		MM_ERR("O/P buffers:Invalid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-		goto output_buff_get_phys_error;
-	} else {
-		MM_INFO("O/P buffers:valid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-	}
-	audio->phys = (int32_t)addr;
-
-
-	rc = ion_handle_get_flags(client, handle, &ionflag);
-	if (rc) {
-		MM_ERR("could not get flags for the handle\n");
-		goto output_buff_get_flags_error;
-	}
-
-	audio->map_v_write = ion_map_kernel(client, handle);
-	if (IS_ERR(audio->map_v_write)) {
-		MM_ERR("could not map write buffers\n");
-		rc = -ENOMEM;
-		goto output_buff_map_error;
-	}
-	audio->data = audio->map_v_write;
-	MM_DBG("write buf: phy addr 0x%08x kernel addr 0x%08x\n",
-		audio->phys, (int)audio->data);
-
-	if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK) {
-		rc = audmgr_open(&audio->audmgr);
-		if (rc) {
-			MM_ERR("audmgr open failed, freeing instance \
-					0x%08x\n", (int)audio);
-			goto err;
-		}
-	}
-
-	rc = msm_adsp_get(audio->module_name, &audio->audplay,
-		&audplay_adsp_ops_amrwb, audio);
-	if (rc) {
-		MM_ERR("failed to get %s module, freeing instance 0x%08x\n",
-				audio->module_name, (int)audio);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_close(&audio->audmgr);
-		goto err;
-	}
-
-	rc = rmt_get_resource(audio);
-	if (rc) {
-		MM_ERR("ADSP resources are not available for AMRWB session \
-			 0x%08x on decoder: %d\n", (int)audio, audio->dec_id);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_close(&audio->audmgr);
-		msm_adsp_put(audio->audplay);
-		goto err;
-	}
-
-	audio->input_buff_handle = NULL;
-	mutex_init(&audio->lock);
-	mutex_init(&audio->write_lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->get_event_lock);
-	spin_lock_init(&audio->dsp_lock);
-	spin_lock_init(&audio->event_queue_lock);
-	INIT_LIST_HEAD(&audio->free_event_queue);
-	INIT_LIST_HEAD(&audio->event_queue);
-	init_waitqueue_head(&audio->write_wait);
-	init_waitqueue_head(&audio->read_wait);
-	init_waitqueue_head(&audio->wait);
-	init_waitqueue_head(&audio->event_wait);
-
-	audio->out[0].data = audio->data + 0;
-	audio->out[0].addr = audio->phys + 0;
-	audio->out[0].size = BUFSZ;
-
-	audio->out[1].data = audio->data + BUFSZ;
-	audio->out[1].addr = audio->phys + BUFSZ;
-	audio->out[1].size = BUFSZ;
-
-	audio->vol_pan.volume = 0x2000;
-	audio->vol_pan.pan = 0x0;
-	audio->eq_enable = 0;
-	audio->out_sample_rate = 44100;
-	audio->out_channel_mode = AUDPP_CMD_PCM_INTF_STEREO_V;
-
-	audamrwb_flush(audio);
-
-	file->private_data = audio;
-	audio->opened = 1;
-	audio->event_abort = 0;
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof name, "msm_amrwb_%04x", audio->dec_id);
-	audio->dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
-			NULL, (void *) audio, &audamrwb_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		MM_DBG("debugfs_create_file failed\n");
-#endif
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	audio->suspend_ctl.node.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
-	audio->suspend_ctl.node.resume = audamrwb_resume;
-	audio->suspend_ctl.node.suspend = audamrwb_suspend;
-	audio->suspend_ctl.audio = audio;
-	register_early_suspend(&audio->suspend_ctl.node);
-#endif
-	for (i = 0; i < AUDAMRWB_EVENT_NUM; i++) {
-		e_node = kmalloc(sizeof(struct audamrwb_event), GFP_KERNEL);
-		if (e_node)
-			list_add_tail(&e_node->list, &audio->free_event_queue);
-		else {
-			MM_ERR("event pkt alloc failed\n");
-			break;
-		}
-	}
-done:
-	return rc;
-err:
-	ion_unmap_kernel(client, audio->output_buff_handle);
-output_buff_map_error:
-output_buff_get_phys_error:
-output_buff_get_flags_error:
-	ion_free(client, audio->output_buff_handle);
-output_buff_alloc_error:
-	ion_client_destroy(client);
-client_create_error:
-	audpp_adec_free(audio->dec_id);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_amrwb_fops = {
-	.owner = THIS_MODULE,
-	.open = audamrwb_open,
-	.release = audamrwb_release,
-	.read = audamrwb_read,
-	.write = audamrwb_write,
-	.unlocked_ioctl = audamrwb_ioctl,
-	.fsync = audamrwb_fsync,
-};
-
-struct miscdevice audio_amrwb_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_amrwb",
-	.fops = &audio_amrwb_fops,
-};
-
-static int __init audamrwb_init(void)
-{
-	return misc_register(&audio_amrwb_misc);
-}
-
-static void __exit audamrwb_exit(void)
-{
-	misc_deregister(&audio_amrwb_misc);
-}
-
-module_init(audamrwb_init);
-module_exit(audamrwb_exit);
-
-MODULE_DESCRIPTION("MSM AMR-WB driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5/audio_evrc.c b/arch/arm/mach-msm/qdsp5/audio_evrc.c
deleted file mode 100644
index 15612a3..0000000
--- a/arch/arm/mach-msm/qdsp5/audio_evrc.c
+++ /dev/null
@@ -1,1701 +0,0 @@
-/* arch/arm/mach-msm/audio_evrc.c
- *
- * Copyright (c) 2008-2009, 2011-2012 The Linux Foundation. All rights reserved.
- *
- * This code also borrows from audio_aac.c, which is
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you can find it at http://www.fsf.org.
- */
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/list.h>
-#include <linux/earlysuspend.h>
-#include <linux/slab.h>
-#include <linux/msm_audio.h>
-#include <linux/memory_alloc.h>
-#include <linux/msm_ion.h>
-
-#include <mach/msm_adsp.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/qdsp5/qdsp5audppcmdi.h>
-#include <mach/qdsp5/qdsp5audppmsg.h>
-#include <mach/qdsp5/qdsp5audpp.h>
-#include <mach/qdsp5/qdsp5audplaycmdi.h>
-#include <mach/qdsp5/qdsp5audplaymsg.h>
-#include <mach/qdsp5/qdsp5rmtcmdi.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_memtypes.h>
-
-#include "audmgr.h"
-
-/* Hold 30 packets of 24 bytes each and 14 bytes of meta in */
-#define BUFSZ 			734
-#define DMASZ 			(BUFSZ * 2)
-
-#define AUDDEC_DEC_EVRC 	12
-
-#define PCM_BUFSZ_MIN 		1624	/* 100ms worth of data and
-					   and 24 bytes of meta out */
-#define PCM_BUF_MAX_COUNT 	5
-/* DSP only accepts 5 buffers at most
- * but support 2 buffers currently
- */
-#define EVRC_DECODED_FRSZ 	320	/* EVRC 20ms 8KHz mono PCM size */
-
-#define ROUTING_MODE_FTRT 	1
-#define ROUTING_MODE_RT 	2
-/* Decoder status received from AUDPPTASK */
-#define  AUDPP_DEC_STATUS_SLEEP	0
-#define	 AUDPP_DEC_STATUS_INIT  1
-#define  AUDPP_DEC_STATUS_CFG   2
-#define  AUDPP_DEC_STATUS_PLAY  3
-
-#define AUDEVRC_METAFIELD_MASK 0xFFFF0000
-#define AUDEVRC_EOS_FLG_OFFSET 0x0A /* Offset from beginning of buffer */
-#define AUDEVRC_EOS_FLG_MASK 0x01
-#define AUDEVRC_EOS_NONE 0x0 /* No EOS detected */
-#define AUDEVRC_EOS_SET 0x1 /* EOS set in meta field */
-
-#define AUDEVRC_EVENT_NUM 10 /* Default number of pre-allocated event packets */
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;		/* Input usage actual DSP produced PCM size  */
-	unsigned addr;
-	unsigned short mfield_sz; /*only useful for data has meta field */
-};
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-struct audevrc_suspend_ctl {
-	struct early_suspend node;
-	struct audio *audio;
-};
-#endif
-
-struct audevrc_event{
-	struct list_head list;
-	int event_type;
-	union msm_audio_event_payload payload;
-};
-
-struct audio {
-	struct buffer out[2];
-
-	spinlock_t dsp_lock;
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed;	/* number of buffers the dsp is waiting for */
-
-	atomic_t out_bytes;
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-
-	/* Host PCM section */
-	struct buffer in[PCM_BUF_MAX_COUNT];
-	struct mutex read_lock;
-	wait_queue_head_t read_wait;	/* Wait queue for read */
-	char *read_data;	/* pointer to reader buffer */
-	int32_t read_phys;	/* physical address of reader buffer */
-	uint8_t read_next;	/* index to input buffers to be read next */
-	uint8_t fill_next;	/* index to buffer that DSP should be filling */
-	uint8_t pcm_buf_count;	/* number of pcm buffer allocated */
-	/* ---- End of Host PCM section */
-
-	struct msm_adsp_module *audplay;
-	struct audmgr audmgr;
-
-	/* data allocated for various buffers */
-	char *data;
-	int32_t phys;  /* physical address of write buffer */
-	void *map_v_read;
-	void *map_v_write;
-
-	int mfield; /* meta field embedded in data */
-	int rflush; /* Read  flush */
-	int wflush; /* Write flush */
-	uint8_t opened:1;
-	uint8_t enabled:1;
-	uint8_t running:1;
-	uint8_t stopped:1;	/* set when stopped, cleared on flush */
-	uint8_t pcm_feedback:1;
-	uint8_t buf_refresh:1;
-	int teos; /* valid only if tunnel mode & no data left for decoder */
-	enum msm_aud_decoder_state dec_state;	/* Represents decoder state */
-	int rmt_resource_released;
-
-	const char *module_name;
-	unsigned queue_id;
-	uint16_t dec_id;
-	uint32_t read_ptr_offset;
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	struct audevrc_suspend_ctl suspend_ctl;
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *dentry;
-#endif
-
-	wait_queue_head_t wait;
-	struct list_head free_event_queue;
-	struct list_head event_queue;
-	wait_queue_head_t event_wait;
-	spinlock_t event_queue_lock;
-	struct mutex get_event_lock;
-	int event_abort;
-
-	int eq_enable;
-	int eq_needs_commit;
-	audpp_cmd_cfg_object_params_eqalizer eq;
-	audpp_cmd_cfg_object_params_volume vol_pan;
-	struct ion_client *client;
-	struct ion_handle *input_buff_handle;
-	struct ion_handle *output_buff_handle;
-};
-
-static int auddec_dsp_config(struct audio *audio, int enable);
-static void audpp_cmd_cfg_adec_params(struct audio *audio);
-static void audpp_cmd_cfg_routing_mode(struct audio *audio);
-static void audevrc_send_data(struct audio *audio, unsigned needed);
-static void audevrc_dsp_event(void *private, unsigned id, uint16_t *msg);
-static void audevrc_config_hostpcm(struct audio *audio);
-static void audevrc_buffer_refresh(struct audio *audio);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audevrc_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload);
-#endif
-
-static int rmt_put_resource(struct audio *audio)
-{
-	struct aud_codec_config_cmd cmd;
-	unsigned short client_idx;
-
-	cmd.cmd_id = RM_CMD_AUD_CODEC_CFG;
-	cmd.client_id = RM_AUD_CLIENT_ID;
-	cmd.task_id = audio->dec_id;
-	cmd.enable = RMT_DISABLE;
-	cmd.dec_type = AUDDEC_DEC_EVRC;
-	client_idx = ((cmd.client_id << 8) | cmd.task_id);
-
-	return put_adsp_resource(client_idx, &cmd, sizeof(cmd));
-}
-
-static int rmt_get_resource(struct audio *audio)
-{
-	struct aud_codec_config_cmd cmd;
-	unsigned short client_idx;
-
-	cmd.cmd_id = RM_CMD_AUD_CODEC_CFG;
-	cmd.client_id = RM_AUD_CLIENT_ID;
-	cmd.task_id = audio->dec_id;
-	cmd.enable = RMT_ENABLE;
-	cmd.dec_type = AUDDEC_DEC_EVRC;
-	client_idx = ((cmd.client_id << 8) | cmd.task_id);
-
-	return get_adsp_resource(client_idx, &cmd, sizeof(cmd));
-}
-
-/* must be called with audio->lock held */
-static int audevrc_enable(struct audio *audio)
-{
-	struct audmgr_config cfg;
-	int rc;
-
-	if (audio->enabled)
-		return 0;
-
-	if (audio->rmt_resource_released == 1) {
-		audio->rmt_resource_released = 0;
-		rc = rmt_get_resource(audio);
-		if (rc) {
-			MM_ERR("ADSP resources are not available for EVRC \
-				session 0x%08x on decoder: %d\n Ignoring \
-				error and going ahead with the playback\n",
-				(int)audio, audio->dec_id);
-		}
-	}
-
-	audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-
-	if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK) {
-		cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE;
-		cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000;
-		cfg.def_method = RPC_AUD_DEF_METHOD_PLAYBACK;
-		cfg.codec = RPC_AUD_DEF_CODEC_EVRC;
-		cfg.snd_method = RPC_SND_METHOD_MIDI;
-
-		rc = audmgr_enable(&audio->audmgr, &cfg);
-		if (rc < 0) {
-			msm_adsp_dump(audio->audplay);
-			return rc;
-		}
-	}
-
-	if (msm_adsp_enable(audio->audplay)) {
-		MM_ERR("msm_adsp_enable(audplay) failed\n");
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_disable(&audio->audmgr);
-		return -ENODEV;
-	}
-
-	if (audpp_enable(audio->dec_id, audevrc_dsp_event, audio)) {
-		MM_ERR("audpp_enable() failed\n");
-		msm_adsp_disable(audio->audplay);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_disable(&audio->audmgr);
-		return -ENODEV;
-	}
-	audio->enabled = 1;
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audevrc_disable(struct audio *audio)
-{
-	int rc = 0;
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-		auddec_dsp_config(audio, 0);
-		rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-		if (rc == 0)
-			rc = -ETIMEDOUT;
-		else if (audio->dec_state != MSM_AUD_DECODER_STATE_CLOSE)
-			rc = -EFAULT;
-		else
-			rc = 0;
-		audio->stopped = 1;
-		wake_up(&audio->write_wait);
-		wake_up(&audio->read_wait);
-		msm_adsp_disable(audio->audplay);
-		audpp_disable(audio->dec_id, audio);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK) {
-			rc = audmgr_disable(&audio->audmgr);
-			if (rc < 0)
-				msm_adsp_dump(audio->audplay);
-		}
-		audio->out_needed = 0;
-		rmt_put_resource(audio);
-		audio->rmt_resource_released = 1;
-	}
-	return rc;
-}
-
-/* ------------------- dsp --------------------- */
-
-static void audevrc_update_pcm_buf_entry(struct audio *audio,
-					 uint32_t *payload)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	if (audio->rflush)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < payload[1]; index++) {
-		if (audio->in[audio->fill_next].addr
-				== payload[2 + index * 2]) {
-			MM_DBG("in[%d] ready\n", audio->fill_next);
-			audio->in[audio->fill_next].used =
-				payload[3 + index * 2];
-			if ((++audio->fill_next) == audio->pcm_buf_count)
-				audio->fill_next = 0;
-
-		} else {
-			MM_ERR("expected=%x ret=%x\n",
-				audio->in[audio->fill_next].addr,
-				payload[1 + index * 2]);
-			break;
-		}
-	}
-	if (audio->in[audio->fill_next].used == 0) {
-		audevrc_buffer_refresh(audio);
-	} else {
-		MM_DBG("read cannot keep up\n");
-		audio->buf_refresh = 1;
-	}
-	wake_up(&audio->read_wait);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audplay_dsp_event(void *data, unsigned id, size_t len,
-			      void (*getevent) (void *ptr, size_t len))
-{
-	struct audio *audio = data;
-	uint32_t msg[28];
-	getevent(msg, sizeof(msg));
-
-	MM_DBG("msg_id=%x\n", id);
-	switch (id) {
-	case AUDPLAY_MSG_DEC_NEEDS_DATA:
-		audevrc_send_data(audio, 1);
-		break;
-	case AUDPLAY_MSG_BUFFER_UPDATE:
-		MM_DBG("\n"); /* Macro prints the file name and function */
-		audevrc_update_pcm_buf_entry(audio, msg);
-		break;
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audplaytask)\n");
-		break;
-	default:
-		MM_ERR("unexpected message from decoder \n");
-	}
-}
-
-static void audevrc_dsp_event(void *private, unsigned id, uint16_t *msg)
-{
-	struct audio *audio = private;
-
-	switch (id) {
-	case AUDPP_MSG_STATUS_MSG:{
-			unsigned status = msg[1];
-
-			switch (status) {
-			case AUDPP_DEC_STATUS_SLEEP: {
-				uint16_t reason = msg[2];
-				MM_DBG("decoder status:sleep reason = \
-						0x%04x\n", reason);
-				if ((reason == AUDPP_MSG_REASON_MEM)
-					|| (reason ==
-					AUDPP_MSG_REASON_NODECODER)) {
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_FAILURE;
-					wake_up(&audio->wait);
-				} else if (reason == AUDPP_MSG_REASON_NONE) {
-					/* decoder is in disable state */
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_CLOSE;
-					wake_up(&audio->wait);
-				}
-				break;
-			}
-			case AUDPP_DEC_STATUS_INIT:
-				MM_DBG("decoder status: init \n");
-				if (audio->pcm_feedback)
-					audpp_cmd_cfg_routing_mode(audio);
-				else
-					audpp_cmd_cfg_adec_params(audio);
-				break;
-
-			case AUDPP_DEC_STATUS_CFG:
-				MM_DBG("decoder status: cfg \n");
-				break;
-			case AUDPP_DEC_STATUS_PLAY:
-				MM_DBG("decoder status: play \n");
-				if (audio->pcm_feedback) {
-					audevrc_config_hostpcm(audio);
-					audevrc_buffer_refresh(audio);
-				}
-				audio->dec_state =
-					MSM_AUD_DECODER_STATE_SUCCESS;
-				wake_up(&audio->wait);
-				break;
-			default:
-				MM_ERR("unknown decoder status \n");
-			}
-			break;
-		}
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_DBG("CFG_MSG ENABLE\n");
-			auddec_dsp_config(audio, 1);
-			audio->out_needed = 0;
-			audio->running = 1;
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-			audpp_dsp_set_eq(audio->dec_id,	audio->eq_enable,
-								&audio->eq);
-			audpp_avsync(audio->dec_id, 22050);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			MM_DBG("CFG_MSG DISABLE\n");
-			audpp_avsync(audio->dec_id, 0);
-			audio->running = 0;
-		} else {
-			MM_DBG("CFG_MSG %d?\n", msg[0]);
-		}
-		break;
-	case AUDPP_MSG_ROUTING_ACK:
-		MM_DBG("ROUTING_ACK\n");
-		audpp_cmd_cfg_adec_params(audio);
-		break;
-	case AUDPP_MSG_FLUSH_ACK:
-		MM_DBG("FLUSH_ACK\n");
-		audio->wflush = 0;
-		audio->rflush = 0;
-		wake_up(&audio->write_wait);
-		if (audio->pcm_feedback)
-			audevrc_buffer_refresh(audio);
-		break;
-	case AUDPP_MSG_PCMDMAMISSED:
-		MM_DBG("PCMDMAMISSED\n");
-		audio->teos = 1;
-		wake_up(&audio->write_wait);
-		break;
-	default:
-		MM_ERR("UNKNOWN (%d)\n", id);
-	}
-
-}
-
-struct msm_adsp_ops audplay_adsp_ops_evrc = {
-	.event = audplay_dsp_event,
-};
-
-#define audplay_send_queue0(audio, cmd, len) \
-	msm_adsp_write(audio->audplay, audio->queue_id, \
-			cmd, len)
-
-static int auddec_dsp_config(struct audio *audio, int enable)
-{
-	u16 cfg_dec_cmd[AUDPP_CMD_CFG_DEC_TYPE_LEN / sizeof(unsigned short)];
-
-	memset(cfg_dec_cmd, 0, sizeof(cfg_dec_cmd));
-
-	cfg_dec_cmd[0] = AUDPP_CMD_CFG_DEC_TYPE;
-	if (enable)
-		cfg_dec_cmd[1 + audio->dec_id] = AUDPP_CMD_UPDATDE_CFG_DEC |
-			AUDPP_CMD_ENA_DEC_V | AUDDEC_DEC_EVRC;
-	else
-		cfg_dec_cmd[1 + audio->dec_id] = AUDPP_CMD_UPDATDE_CFG_DEC |
-			AUDPP_CMD_DIS_DEC_V;
-
-	return audpp_send_queue1(&cfg_dec_cmd, sizeof(cfg_dec_cmd));
-}
-
-static void audpp_cmd_cfg_adec_params(struct audio *audio)
-{
-	struct audpp_cmd_cfg_adec_params_evrc cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_CMD_CFG_ADEC_PARAMS;
-	cmd.common.length = sizeof(cmd);
-	cmd.common.dec_id = audio->dec_id;
-	cmd.common.input_sampling_frequency = 8000;
-	cmd.stereo_cfg = AUDPP_CMD_PCM_INTF_MONO_V;
-
-	audpp_send_queue2(&cmd, sizeof(cmd));
-}
-
-static void audpp_cmd_cfg_routing_mode(struct audio *audio)
-{
-	struct audpp_cmd_routing_mode cmd;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPP_CMD_ROUTING_MODE;
-	cmd.object_number = audio->dec_id;
-	if (audio->pcm_feedback)
-		cmd.routing_mode = ROUTING_MODE_FTRT;
-	else
-		cmd.routing_mode = ROUTING_MODE_RT;
-
-	audpp_send_queue1(&cmd, sizeof(cmd));
-}
-
-static int audplay_dsp_send_data_avail(struct audio *audio,
-				       unsigned idx, unsigned len)
-{
-	struct audplay_cmd_bitstream_data_avail_nt2 cmd;
-
-	cmd.cmd_id = AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2;
-	if (audio->mfield)
-		cmd.decoder_id = AUDEVRC_METAFIELD_MASK |
-			(audio->out[idx].mfield_sz >> 1);
-	else
-		cmd.decoder_id = audio->dec_id;
-	cmd.buf_ptr = audio->out[idx].addr;
-	cmd.buf_size = len / 2;
-	cmd.partition_number = 0;
-	/* complete writes to the input buffer */
-	wmb();
-	return audplay_send_queue0(audio, &cmd, sizeof(cmd));
-}
-
-static void audevrc_buffer_refresh(struct audio *audio)
-{
-	struct audplay_cmd_buffer_refresh refresh_cmd;
-
-	refresh_cmd.cmd_id = AUDPLAY_CMD_BUFFER_REFRESH;
-	refresh_cmd.num_buffers = 1;
-	refresh_cmd.buf0_address = audio->in[audio->fill_next].addr;
-	refresh_cmd.buf0_length = audio->in[audio->fill_next].size;
-
-	refresh_cmd.buf_read_count = 0;
-	MM_DBG("buf0_addr=%x buf0_len=%d\n", refresh_cmd.buf0_address,
-			refresh_cmd.buf0_length);
-	audplay_send_queue0(audio, &refresh_cmd, sizeof(refresh_cmd));
-}
-
-static void audevrc_config_hostpcm(struct audio *audio)
-{
-	struct audplay_cmd_hpcm_buf_cfg cfg_cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	cfg_cmd.cmd_id = AUDPLAY_CMD_HPCM_BUF_CFG;
-	cfg_cmd.max_buffers = 1;
-	cfg_cmd.byte_swap = 0;
-	cfg_cmd.hostpcm_config = (0x8000) | (0x4000);
-	cfg_cmd.feedback_frequency = 1;
-	cfg_cmd.partition_number = 0;
-	audplay_send_queue0(audio, &cfg_cmd, sizeof(cfg_cmd));
-
-}
-
-static void audevrc_send_data(struct audio *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			MM_DBG("frame %d free\n", audio->out_tail);
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			MM_DBG("frame %d busy\n", audio->out_tail);
-			audplay_dsp_send_data_avail(audio, audio->out_tail,
-						    frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
-done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-
-static void audevrc_flush(struct audio *audio)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->out[0].used = 0;
-	audio->out[1].used = 0;
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	atomic_set(&audio->out_bytes, 0);
-}
-
-static void audevrc_flush_pcm_buf(struct audio *audio)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < PCM_BUF_MAX_COUNT; index++)
-		audio->in[index].used = 0;
-	audio->buf_refresh = 0;
-	audio->read_next = 0;
-	audio->fill_next = 0;
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audevrc_ioport_reset(struct audio *audio)
-{
-	/* Make sure read/write thread are free from
-	 * sleep and knowing that system is not able
-	 * to process io request at the moment
-	 */
-	wake_up(&audio->write_wait);
-	mutex_lock(&audio->write_lock);
-	audevrc_flush(audio);
-	mutex_unlock(&audio->write_lock);
-	wake_up(&audio->read_wait);
-	mutex_lock(&audio->read_lock);
-	audevrc_flush_pcm_buf(audio);
-	mutex_unlock(&audio->read_lock);
-}
-
-static int audevrc_events_pending(struct audio *audio)
-{
-	unsigned long flags;
-	int empty;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	empty = !list_empty(&audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	return empty || audio->event_abort;
-}
-
-static void audevrc_reset_event_queue(struct audio *audio)
-{
-	unsigned long flags;
-	struct audevrc_event *drv_evt;
-	struct list_head *ptr, *next;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	list_for_each_safe(ptr, next, &audio->event_queue) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audevrc_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	list_for_each_safe(ptr, next, &audio->free_event_queue) {
-		drv_evt = list_first_entry(&audio->free_event_queue,
-			struct audevrc_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	return;
-}
-
-
-static long audevrc_process_event_req(struct audio *audio, void __user *arg)
-{
-	long rc;
-	struct msm_audio_event usr_evt;
-	struct audevrc_event *drv_evt = NULL;
-	int timeout;
-	unsigned long flags;
-
-	if (copy_from_user(&usr_evt, arg, sizeof(struct msm_audio_event)))
-		return -EFAULT;
-
-	timeout = (int) usr_evt.timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(
-			audio->event_wait, audevrc_events_pending(audio),
-			msecs_to_jiffies(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(
-			audio->event_wait, audevrc_events_pending(audio));
-	}
-
-	if (rc < 0)
-		return rc;
-
-	if (audio->event_abort) {
-		audio->event_abort = 0;
-		return -ENODEV;
-	}
-
-	rc = 0;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	if (!list_empty(&audio->event_queue)) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audevrc_event, list);
-		list_del(&drv_evt->list);
-	}
-	if (drv_evt) {
-		usr_evt.event_type = drv_evt->event_type;
-		usr_evt.event_payload = drv_evt->payload;
-		list_add_tail(&drv_evt->list, &audio->free_event_queue);
-	} else
-		rc = -1;
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	if (!rc && copy_to_user(arg, &usr_evt, sizeof(usr_evt)))
-		rc = -EFAULT;
-
-	return rc;
-}
-
-static int audio_enable_eq(struct audio *audio, int enable)
-{
-	if (audio->eq_enable == enable && !audio->eq_needs_commit)
-		return 0;
-
-	audio->eq_enable = enable;
-
-	if (audio->running) {
-		audpp_dsp_set_eq(audio->dec_id, enable, &audio->eq);
-		audio->eq_needs_commit = 0;
-	}
-	return 0;
-}
-
-static long audevrc_ioctl(struct file *file, unsigned int cmd,
-			  unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = -EINVAL;
-	unsigned long flags = 0;
-	uint16_t enable_mask;
-	int enable;
-	int prev_state;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	int len = 0;
-
-	MM_DBG("cmd = %d\n", cmd);
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		stats.byte_count = audpp_avsync_byte_count(audio->dec_id);
-		stats.sample_count = audpp_avsync_sample_count(audio->dec_id);
-		if (copy_to_user((void *)arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-
-	switch (cmd) {
-	case AUDIO_ENABLE_AUDPP:
-		if (copy_from_user(&enable_mask, (void *) arg,
-						sizeof(enable_mask))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		enable = (enable_mask & EQ_ENABLE) ? 1 : 0;
-		audio_enable_eq(audio, enable);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-	case AUDIO_SET_VOLUME:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.volume = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_PAN:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.pan = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_EQ:
-		prev_state = audio->eq_enable;
-		audio->eq_enable = 0;
-		if (copy_from_user(&audio->eq.num_bands, (void *) arg,
-				sizeof(audio->eq) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2))) {
-			rc = -EFAULT;
-			break;
-		}
-		audio->eq_enable = prev_state;
-		audio->eq_needs_commit = 1;
-		rc = 0;
-		break;
-	}
-
-	if (-EINVAL != rc)
-		return rc;
-
-	if (cmd == AUDIO_GET_EVENT) {
-		MM_DBG("AUDIO_GET_EVENT\n");
-		if (mutex_trylock(&audio->get_event_lock)) {
-			rc = audevrc_process_event_req(audio,
-					(void __user *) arg);
-			mutex_unlock(&audio->get_event_lock);
-		} else
-			rc = -EBUSY;
-		return rc;
-	}
-
-	if (cmd == AUDIO_ABORT_GET_EVENT) {
-		audio->event_abort = 1;
-		wake_up(&audio->event_wait);
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		MM_DBG("AUDIO_START\n");
-		rc = audevrc_enable(audio);
-		if (!rc) {
-			rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-			MM_INFO("dec_state %d rc = %d\n", audio->dec_state, rc);
-
-			if (audio->dec_state != MSM_AUD_DECODER_STATE_SUCCESS)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		break;
-	case AUDIO_STOP:
-		MM_DBG("AUDIO_STOP\n");
-		rc = audevrc_disable(audio);
-		audevrc_ioport_reset(audio);
-		audio->stopped = 0;
-		break;
-	case AUDIO_FLUSH:
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audevrc_ioport_reset(audio);
-		if (audio->running) {
-			audpp_flush(audio->dec_id);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-	case AUDIO_SET_CONFIG:{
-			struct msm_audio_config config;
-			if (copy_from_user
-				(&config, (void *)arg, sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-			audio->mfield = config.meta_field;
-			rc = 0;
-			MM_DBG("AUDIO_SET_CONFIG applicable only \
-				for meta field configuration\n");
-			break;
-		}
-	case AUDIO_GET_CONFIG:{
-			struct msm_audio_config config;
-			config.buffer_size = BUFSZ;
-			config.buffer_count = 2;
-			config.sample_rate = 8000;
-			config.channel_count = 1;
-			config.meta_field = 0;
-			config.unused[0] = 0;
-			config.unused[1] = 0;
-			config.unused[2] = 0;
-			if (copy_to_user((void *)arg, &config, sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_GET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			config.pcm_feedback = audio->pcm_feedback;
-			config.buffer_count = PCM_BUF_MAX_COUNT;
-			config.buffer_size = PCM_BUFSZ_MIN;
-			if (copy_to_user((void *)arg, &config, sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_SET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			if (copy_from_user
-			    (&config, (void *)arg, sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-			if (config.pcm_feedback != audio->pcm_feedback) {
-				MM_ERR("Not sufficient permission to"
-					 "change the playback mode\n");
-				rc = -EACCES;
-				break;
-			}
-			if ((config.buffer_count > PCM_BUF_MAX_COUNT) ||
-			    (config.buffer_count == 1))
-				config.buffer_count = PCM_BUF_MAX_COUNT;
-
-			if (config.buffer_size < PCM_BUFSZ_MIN)
-				config.buffer_size = PCM_BUFSZ_MIN;
-
-			/* Check if pcm feedback is required */
-			if ((config.pcm_feedback) && (!audio->read_data)) {
-				MM_DBG("allocate PCM buf %d\n",
-					config.buffer_count *
-					config.buffer_size);
-				handle = ion_alloc(audio->client,
-					(config.buffer_size *
-					config.buffer_count),
-					SZ_4K, ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-				if (IS_ERR_OR_NULL(handle)) {
-					MM_ERR("Unable to alloc I/P buffs\n");
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-					break;
-				}
-
-				audio->input_buff_handle = handle;
-
-				rc = ion_phys(audio->client ,
-					handle, &addr, &len);
-				if (rc) {
-					MM_ERR("Invalid phy: %x sz: %x\n",
-						(unsigned int) addr,
-						(unsigned int) len);
-					ion_free(audio->client, handle);
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-					break;
-				} else {
-					MM_INFO("Got valid phy: %x sz: %x\n",
-						(unsigned int) audio->read_phys,
-						(unsigned int) len);
-				}
-				audio->read_phys = (int32_t)addr;
-
-				rc = ion_handle_get_flags(audio->client,
-					handle, &ionflag);
-				if (rc) {
-					MM_ERR("could not get flags\n");
-					ion_free(audio->client, handle);
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-					break;
-				}
-				audio->map_v_read = ion_map_kernel(
-					audio->client, handle);
-				if (IS_ERR(audio->map_v_read)) {
-					MM_ERR("failed to map mem"
-							" for read buf\n");
-					ion_free(audio->client, handle);
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-				} else {
-					uint8_t index;
-					uint32_t offset = 0;
-					audio->read_data =
-						audio->map_v_read;
-					audio->buf_refresh = 0;
-					audio->pcm_buf_count =
-					    config.buffer_count;
-					audio->read_next = 0;
-					audio->fill_next = 0;
-
-					for (index = 0;
-					     index < config.buffer_count;
-					     index++) {
-						audio->in[index].data =
-						    audio->read_data + offset;
-						audio->in[index].addr =
-						    audio->read_phys + offset;
-						audio->in[index].size =
-						    config.buffer_size;
-						audio->in[index].used = 0;
-						offset += config.buffer_size;
-					}
-					MM_DBG("read buf: phy addr \
-						0x%08x kernel addr 0x%08x\n",
-						audio->read_phys,
-						(int)audio->read_data);
-					rc = 0;
-				}
-			} else {
-				rc = 0;
-			}
-			break;
-		}
-	case AUDIO_PAUSE:
-		MM_DBG("AUDIO_PAUSE %ld\n", arg);
-		rc = audpp_pause(audio->dec_id, (int) arg);
-		break;
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-/* Only useful in tunnel-mode */
-static int audevrc_fsync(struct file *file, loff_t a, loff_t b, int datasync)
-{
-	struct audio *audio = file->private_data;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (!audio->running || audio->pcm_feedback) {
-		rc = -EINVAL;
-		goto done_nolock;
-	}
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(!audio->out[0].used &&
-		!audio->out[1].used &&
-		audio->out_needed) || audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		audio->teos || audio->wflush);
-
-	if (audio->wflush)
-		rc = -EBUSY;
-
-done:
-	mutex_unlock(&audio->write_lock);
-done_nolock:
-	return rc;
-}
-
-static ssize_t audevrc_read(struct file *file, char __user *buf, size_t count,
-			    loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	int rc = 0;
-	if (!audio->pcm_feedback) {
-		return 0;
-		/* PCM feedback is not enabled. Nothing to read */
-	}
-	mutex_lock(&audio->read_lock);
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	while (count > 0) {
-		rc = wait_event_interruptible(audio->read_wait,
-				(audio->in[audio->read_next].used > 0) ||
-				(audio->stopped) || (audio->rflush));
-
-		MM_DBG("wait terminated \n");
-		if (rc < 0)
-			break;
-		if (audio->stopped || audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-		if (count < audio->in[audio->read_next].used) {
-			/* Read must happen in frame boundary. Since driver does
-			 * not know frame size, read count must be greater or
-			 * equal to size of PCM samples
-			 */
-			MM_DBG("read stop - partial frame\n");
-			break;
-		} else {
-			MM_DBG("read from in[%d]\n", audio->read_next);
-			/* order reads from the output buffer */
-			rmb();
-			if (copy_to_user
-			    (buf, audio->in[audio->read_next].data,
-			     audio->in[audio->read_next].used)) {
-				MM_ERR("invalid addr %x \n",
-				       (unsigned int)buf);
-				rc = -EFAULT;
-				break;
-			}
-			count -= audio->in[audio->read_next].used;
-			buf += audio->in[audio->read_next].used;
-			audio->in[audio->read_next].used = 0;
-			if ((++audio->read_next) == audio->pcm_buf_count)
-				audio->read_next = 0;
-			break;
-				/* Force to exit while loop
-				 * to prevent output thread
-				 * sleep too long if data is
-				 * not ready at this moment
-				 */
-
-		}
-	}
-	/* don't feed output buffer to HW decoder during flushing
-	 * buffer refresh command will be sent once flush completes
-	 * send buf refresh command here can confuse HW decoder
-	 */
-	if (audio->buf_refresh && !audio->rflush) {
-		audio->buf_refresh = 0;
-		MM_DBG("kick start pcm feedback again\n");
-		audevrc_buffer_refresh(audio);
-	}
-	mutex_unlock(&audio->read_lock);
-	if (buf > start)
-		rc = buf - start;
-	MM_DBG("read %d bytes\n", rc);
-	return rc;
-}
-
-static int audevrc_process_eos(struct audio *audio,
-		const char __user *buf_start, unsigned short mfield_size)
-{
-	int rc = 0;
-	struct buffer *frame;
-
-	frame = audio->out + audio->out_head;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	audevrc_send_data(audio, 0);
-
-done:
-	return rc;
-}
-
-static ssize_t audevrc_write(struct file *file, const char __user *buf,
-			     size_t count, loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	size_t xfer;
-	char *cpy_ptr;
-	unsigned short mfield_size = 0;
-	int rc = 0, eos_condition = AUDEVRC_EOS_NONE;
-
-	MM_DBG("cnt=%d\n", count);
-
-	if (count & 1)
-		return -EINVAL;
-
-	mutex_lock(&audio->write_lock);
-	while (count > 0) {
-		frame = audio->out + audio->out_head;
-		cpy_ptr = frame->data;
-		rc = wait_event_interruptible(audio->write_wait,
-					      (frame->used == 0)
-						|| (audio->stopped)
-						|| (audio->wflush));
-		if (rc < 0)
-			break;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (audio->mfield) {
-			if (buf == start) {
-				/* Processing beginning of user buffer */
-				if (__get_user(mfield_size,
-					(unsigned short __user *) buf)) {
-					rc = -EFAULT;
-					break;
-				} else if (mfield_size > count) {
-					rc = -EINVAL;
-					break;
-				}
-				MM_DBG("mf offset_val %x\n", mfield_size);
-				if (copy_from_user(cpy_ptr, buf,
-							mfield_size)) {
-					rc = -EFAULT;
-					break;
-				}
-				/* Check if EOS flag is set and buffer has
-				 * contains just meta field
-				 */
-				if (cpy_ptr[AUDEVRC_EOS_FLG_OFFSET] &
-						AUDEVRC_EOS_FLG_MASK) {
-					MM_DBG("eos set\n");
-					eos_condition = AUDEVRC_EOS_SET;
-					if (mfield_size == count) {
-						buf += mfield_size;
-						break;
-					} else
-					cpy_ptr[AUDEVRC_EOS_FLG_OFFSET] &=
-						~AUDEVRC_EOS_FLG_MASK;
-				}
-				 /* Check EOS to see if */
-				cpy_ptr += mfield_size;
-				count -= mfield_size;
-				buf += mfield_size;
-			 } else {
-				 mfield_size = 0;
-				 MM_DBG("continuous buffer\n");
-			 }
-			 frame->mfield_sz = mfield_size;
-		}
-
-		xfer = (count > (frame->size - mfield_size)) ?
-			(frame->size - mfield_size) : count;
-		if (copy_from_user(cpy_ptr, buf, xfer)) {
-			rc = -EFAULT;
-			break;
-		}
-
-		frame->used = xfer + mfield_size;
-		audio->out_head ^= 1;
-		count -= xfer;
-		buf += xfer;
-		audevrc_send_data(audio, 0);
-	}
-	if (eos_condition == AUDEVRC_EOS_SET)
-		rc = audevrc_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	if (!rc) {
-		if (buf > start)
-			return buf - start;
-	}
-	return rc;
-}
-
-static int audevrc_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	MM_INFO("audio instance 0x%08x freeing\n", (int)audio);
-	mutex_lock(&audio->lock);
-	audevrc_disable(audio);
-	if (audio->rmt_resource_released == 0)
-		rmt_put_resource(audio);
-	audevrc_flush(audio);
-	audevrc_flush_pcm_buf(audio);
-	msm_adsp_put(audio->audplay);
-	audpp_adec_free(audio->dec_id);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	unregister_early_suspend(&audio->suspend_ctl.node);
-#endif
-	audio->event_abort = 1;
-	wake_up(&audio->event_wait);
-	audevrc_reset_event_queue(audio);
-	ion_unmap_kernel(audio->client, audio->output_buff_handle);
-	ion_free(audio->client, audio->output_buff_handle);
-	if (audio->input_buff_handle != NULL) {
-		ion_unmap_kernel(audio->client, audio->input_buff_handle);
-		ion_free(audio->client, audio->input_buff_handle);
-	}
-	ion_client_destroy(audio->client);
-	mutex_unlock(&audio->lock);
-#ifdef CONFIG_DEBUG_FS
-	if (audio->dentry)
-		debugfs_remove(audio->dentry);
-#endif
-	kfree(audio);
-	return 0;
-}
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audevrc_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload)
-{
-	struct audevrc_event *e_node = NULL;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-
-	if (!list_empty(&audio->free_event_queue)) {
-		e_node = list_first_entry(&audio->free_event_queue,
-				struct audevrc_event, list);
-		list_del(&e_node->list);
-	} else {
-		e_node = kmalloc(sizeof(struct audevrc_event), GFP_ATOMIC);
-		if (!e_node) {
-			MM_ERR("No mem to post event %d\n", type);
-			spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-			return;
-		}
-	}
-
-	e_node->event_type = type;
-	e_node->payload = payload;
-
-	list_add_tail(&e_node->list, &audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	wake_up(&audio->event_wait);
-}
-
-static void audevrc_suspend(struct early_suspend *h)
-{
-	struct audevrc_suspend_ctl *ctl =
-		container_of(h, struct audevrc_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audevrc_post_event(ctl->audio, AUDIO_EVENT_SUSPEND, payload);
-}
-
-static void audevrc_resume(struct early_suspend *h)
-{
-	struct audevrc_suspend_ctl *ctl =
-		container_of(h, struct audevrc_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audevrc_post_event(ctl->audio, AUDIO_EVENT_RESUME, payload);
-}
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-static ssize_t audevrc_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static ssize_t audevrc_debug_read(struct file *file, char __user *buf,
-					size_t count, loff_t *ppos)
-{
-	const int debug_bufmax = 1024;
-	static char buffer[1024];
-	int n = 0, i;
-	struct audio *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	n = scnprintf(buffer, debug_bufmax, "opened %d\n", audio->opened);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"enabled %d\n", audio->enabled);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"stopped %d\n", audio->stopped);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_feedback %d\n", audio->pcm_feedback);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_buf_sz %d\n", audio->out[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_buf_count %d \n", audio->pcm_buf_count);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_buf_sz %d \n", audio->in[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"volume %x \n", audio->vol_pan.volume);
-	mutex_unlock(&audio->lock);
-	/* Following variables are only useful for debugging when
-	 * when playback halts unexpectedly. Thus, no mutual exclusion
-	 * enforced
-	 */
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"wflush %d\n", audio->wflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"rflush %d\n", audio->rflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"running %d \n", audio->running);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"dec state %d \n", audio->dec_state);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_needed %d \n", audio->out_needed);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_head %d \n", audio->out_head);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_tail %d \n", audio->out_tail);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out[0].used %d \n", audio->out[0].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out[1].used %d \n", audio->out[1].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"buffer_refresh %d \n", audio->buf_refresh);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"read_next %d \n", audio->read_next);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"fill_next %d \n", audio->fill_next);
-	for (i = 0; i < audio->pcm_buf_count; i++)
-		n += scnprintf(buffer + n, debug_bufmax - n,
-				"in[%d].size %d \n", i, audio->in[i].used);
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations audevrc_debug_fops = {
-	.read = audevrc_debug_read,
-	.open = audevrc_debug_open,
-};
-#endif
-
-static int audevrc_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = NULL;
-	int rc, dec_attrb, decid, i;
-	struct audevrc_event *e_node = NULL;
-	unsigned mem_sz = DMASZ;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	struct ion_client *client = NULL;
-	int len = 0;
-
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_evrc_" + 5];
-#endif
-
-	/* Allocate audio instance, set to zero */
-	audio = kzalloc(sizeof(struct audio), GFP_KERNEL);
-	if (!audio) {
-		MM_ERR("no memory to allocate audio instance\n");
-		rc = -ENOMEM;
-		goto done;
-	}
-	MM_INFO("audio instance 0x%08x created\n", (int)audio);
-
-	/* Allocate the decoder */
-	dec_attrb = AUDDEC_DEC_EVRC;
-	if ((file->f_mode & FMODE_WRITE) &&
-			(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_NONTUNNEL;
-		audio->pcm_feedback = NON_TUNNEL_MODE_PLAYBACK;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_TUNNEL;
-		audio->pcm_feedback = TUNNEL_MODE_PLAYBACK;
-	} else {
-		kfree(audio);
-		rc = -EACCES;
-		goto done;
-	}
-	decid = audpp_adec_alloc(dec_attrb, &audio->module_name,
-			&audio->queue_id);
-
-	if (decid < 0) {
-		MM_ERR("No free decoder available, freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENODEV;
-		kfree(audio);
-		goto done;
-	}
-
-	audio->dec_id = decid & MSM_AUD_DECODER_MASK;
-
-	client = msm_ion_client_create(UINT_MAX, "Audio_EVRC_Client");
-	if (IS_ERR_OR_NULL(client)) {
-		pr_err("Unable to create ION client\n");
-		rc = -ENOMEM;
-		goto client_create_error;
-	}
-	audio->client = client;
-
-	handle = ion_alloc(client, mem_sz, SZ_4K,
-		ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-	if (IS_ERR_OR_NULL(handle)) {
-		MM_ERR("Unable to create allocate O/P buffers\n");
-		rc = -ENOMEM;
-		goto output_buff_alloc_error;
-	}
-	audio->output_buff_handle = handle;
-
-	rc = ion_phys(client, handle, &addr, &len);
-	if (rc) {
-		MM_ERR("O/P buffers:Invalid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-		goto output_buff_get_phys_error;
-	} else {
-		MM_INFO("O/P buffers:valid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-	}
-	audio->phys = (int32_t)addr;
-
-
-	rc = ion_handle_get_flags(client, handle, &ionflag);
-	if (rc) {
-		MM_ERR("could not get flags for the handle\n");
-		goto output_buff_get_flags_error;
-	}
-
-	audio->map_v_write = ion_map_kernel(client, handle);
-	if (IS_ERR(audio->map_v_write)) {
-		MM_ERR("could not map write buffers\n");
-		rc = -ENOMEM;
-		goto output_buff_map_error;
-	}
-	audio->data = audio->map_v_write;
-	MM_DBG("write buf: phy addr 0x%08x kernel addr 0x%08x\n",
-		audio->phys, (int)audio->data);
-
-	if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK) {
-		rc = audmgr_open(&audio->audmgr);
-		if (rc) {
-			MM_ERR("audmgr open failed, freeing instance \
-					0x%08x\n", (int)audio);
-			goto err;
-		}
-	}
-
-	rc = msm_adsp_get(audio->module_name, &audio->audplay,
-			&audplay_adsp_ops_evrc, audio);
-
-	if (rc) {
-		MM_ERR("failed to get %s module, freeing instance 0x%08x\n",
-				audio->module_name, (int)audio);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_close(&audio->audmgr);
-		goto err;
-	}
-
-	rc = rmt_get_resource(audio);
-	if (rc) {
-		MM_ERR("ADSP resources are not available for EVRC session \
-			 0x%08x on decoder: %d\n", (int)audio, audio->dec_id);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_close(&audio->audmgr);
-		msm_adsp_put(audio->audplay);
-		goto err;
-	}
-
-	audio->input_buff_handle = NULL;
-
-	/* Initialize all locks of audio instance */
-	mutex_init(&audio->lock);
-	mutex_init(&audio->write_lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->get_event_lock);
-	spin_lock_init(&audio->dsp_lock);
-	init_waitqueue_head(&audio->write_wait);
-	init_waitqueue_head(&audio->read_wait);
-	INIT_LIST_HEAD(&audio->free_event_queue);
-	INIT_LIST_HEAD(&audio->event_queue);
-	init_waitqueue_head(&audio->wait);
-	init_waitqueue_head(&audio->event_wait);
-	spin_lock_init(&audio->event_queue_lock);
-
-	audio->out[0].data = audio->data + 0;
-	audio->out[0].addr = audio->phys + 0;
-	audio->out[0].size = BUFSZ;
-
-	audio->out[1].data = audio->data + BUFSZ;
-	audio->out[1].addr = audio->phys + BUFSZ;
-	audio->out[1].size = BUFSZ;
-
-	audio->vol_pan.volume = 0x3FFF;
-
-	audevrc_flush(audio);
-
-	file->private_data = audio;
-	audio->opened = 1;
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof name, "msm_evrc_%04x", audio->dec_id);
-	audio->dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
-			NULL, (void *) audio, &audevrc_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		MM_DBG("debugfs_create_file failed\n");
-#endif
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	audio->suspend_ctl.node.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
-	audio->suspend_ctl.node.resume = audevrc_resume;
-	audio->suspend_ctl.node.suspend = audevrc_suspend;
-	audio->suspend_ctl.audio = audio;
-	register_early_suspend(&audio->suspend_ctl.node);
-#endif
-	for (i = 0; i < AUDEVRC_EVENT_NUM; i++) {
-		e_node = kmalloc(sizeof(struct audevrc_event), GFP_KERNEL);
-		if (e_node)
-			list_add_tail(&e_node->list, &audio->free_event_queue);
-		else {
-			MM_ERR("event pkt alloc failed\n");
-			break;
-		}
-	}
-done:
-	return rc;
-err:
-	ion_unmap_kernel(client, audio->output_buff_handle);
-output_buff_map_error:
-output_buff_get_phys_error:
-output_buff_get_flags_error:
-	ion_free(client, audio->output_buff_handle);
-output_buff_alloc_error:
-	ion_client_destroy(client);
-client_create_error:
-	audpp_adec_free(audio->dec_id);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_evrc_fops = {
-	.owner = THIS_MODULE,
-	.open = audevrc_open,
-	.release = audevrc_release,
-	.read = audevrc_read,
-	.write = audevrc_write,
-	.unlocked_ioctl = audevrc_ioctl,
-	.fsync = audevrc_fsync,
-};
-
-struct miscdevice audio_evrc_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_evrc",
-	.fops = &audio_evrc_fops,
-};
-
-static int __init audevrc_init(void)
-{
-	return misc_register(&audio_evrc_misc);
-
-}
-
-static void __exit audevrc_exit(void)
-{
-	misc_deregister(&audio_evrc_misc);
-}
-
-module_init(audevrc_init);
-module_exit(audevrc_exit);
-
-MODULE_DESCRIPTION("MSM EVRC driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5/audio_evrc_in.c b/arch/arm/mach-msm/qdsp5/audio_evrc_in.c
deleted file mode 100644
index 7a8c3e4..0000000
--- a/arch/arm/mach-msm/qdsp5/audio_evrc_in.c
+++ /dev/null
@@ -1,1463 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/audio_evrc_in.c
- *
- * evrc audio input device
- *
- * Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
- *
- * This code is based in part on arch/arm/mach-msm/qdsp5v2/audio_evrc_in.c,
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-
-#include <linux/delay.h>
-
-#include <linux/msm_audio_qcp.h>
-
-
-#include <linux/memory_alloc.h>
-#include <linux/msm_ion.h>
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-#include <mach/msm_memtypes.h>
-#include <mach/msm_adsp.h>
-#include <mach/msm_rpcrouter.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-
-#include "audmgr.h"
-
-#include <mach/qdsp5/qdsp5audpreproc.h>
-#include <mach/qdsp5/qdsp5audpreproccmdi.h>
-#include <mach/qdsp5/qdsp5audpreprocmsg.h>
-#include <mach/qdsp5/qdsp5audreccmdi.h>
-#include <mach/qdsp5/qdsp5audrecmsg.h>
-#include <mach/debug_mm.h>
-
-#define FRAME_HEADER_SIZE	8 /* 8 bytes frame header */
-#define NT_FRAME_HEADER_SIZE	24 /* 24 bytes frame header */
-/* FRAME_NUM must be a power of two */
-#define FRAME_NUM	8
-#define EVRC_FRAME_SIZE	36 /* 36 bytes data */
-/*Tunnel mode : 36 bytes data + 8 byte header*/
-#define FRAME_SIZE	(EVRC_FRAME_SIZE + FRAME_HEADER_SIZE)
- /* 36 bytes data  + 24 meta field*/
-#define NT_FRAME_SIZE	(EVRC_FRAME_SIZE + NT_FRAME_HEADER_SIZE)
-#define DMASZ		(FRAME_SIZE * FRAME_NUM)
-#define NT_DMASZ	(NT_FRAME_SIZE * FRAME_NUM)
-#define OUT_FRAME_NUM	2
-#define OUT_BUFFER_SIZE (4 * 1024 + NT_FRAME_HEADER_SIZE)
-#define BUFFER_SIZE	(OUT_BUFFER_SIZE * OUT_FRAME_NUM)
-
-#define AUDPREPROC_EVRC_EOS_FLG_OFFSET 0x0A /* Offset from beginning of buffer*/
-#define AUDPREPROC_EVRC_EOS_FLG_MASK 0x01
-#define AUDPREPROC_EVRC_EOS_NONE 0x0 /* No EOS detected */
-#define AUDPREPROC_EVRC_EOS_SET 0x1 /* EOS set in meta field */
-
-struct buffer {
-	void *data;
-	uint32_t size;
-	uint32_t read;
-	uint32_t addr;
-	uint32_t used;
-	uint32_t mfield_sz;
-};
-
-struct audio_evrc_in {
-	struct buffer in[FRAME_NUM];
-
-	spinlock_t dsp_lock;
-
-	atomic_t in_bytes;
-	atomic_t in_samples;
-
-	struct mutex lock;
-	struct mutex read_lock;
-	wait_queue_head_t wait;
-	wait_queue_head_t wait_enable;
-	/*write section*/
-	struct buffer out[OUT_FRAME_NUM];
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed;	/* number of buffers the dsp is waiting for */
-	uint32_t out_count;
-
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-	int32_t out_phys; /* physical address of write buffer */
-	char *out_data;
-	int mfield; /* meta field embedded in data */
-	int wflush; /*write flush */
-	int rflush; /*read flush*/
-	int out_frame_cnt;
-
-	struct msm_adsp_module *audrec;
-
-
-	/* configuration to use on next enable */
-	uint32_t samp_rate;
-	uint32_t channel_mode;
-	uint32_t buffer_size; /* Frame size (36 bytes) */
-	uint32_t enc_type; /* 11 for EVRC */
-	uint32_t mode; /* T or NT Mode*/
-
-	struct msm_audio_evrc_enc_config cfg;
-
-	uint32_t dsp_cnt;
-	uint32_t in_head; /* next buffer dsp will write */
-	uint32_t in_tail; /* next buffer read() will read */
-	uint32_t in_count; /* number of buffers available to read() */
-
-	uint32_t eos_ack;
-	uint32_t flush_ack;
-
-	const char *module_name;
-	unsigned queue_ids;
-	uint16_t enc_id; /* Session Id */
-
-	unsigned short samp_rate_index;
-	uint32_t audrec_obj_idx ;
-
-	struct audmgr audmgr;
-
-	/* data allocated for various buffers */
-	char *data;
-	dma_addr_t phys;
-
-	void *map_v_read;
-	void *map_v_write;
-
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped, cleared on flush */
-	struct ion_client *client;
-	struct ion_handle *input_buff_handle;
-	struct ion_handle *output_buff_handle;
-
-	struct audrec_session_info session_info; /*audrec session info*/
-};
-
-struct audio_frame {
-	uint16_t frame_count_lsw;
-	uint16_t frame_count_msw;
-	uint16_t frame_length;
-	uint16_t erased_pcm;
-	unsigned char raw_bitstream[];
-} __packed;
-
-struct audio_frame_nt {
-	uint16_t metadata_len;
-	uint16_t frame_count_lsw;
-	uint16_t frame_count_msw;
-	uint16_t frame_length;
-	uint16_t erased_pcm;
-	uint16_t reserved;
-	uint16_t time_stamp_dword_lsw;
-	uint16_t time_stamp_dword_msw;
-	uint16_t time_stamp_lsw;
-	uint16_t time_stamp_msw;
-	uint16_t nflag_lsw;
-	uint16_t nflag_msw;
-	unsigned char raw_bitstream[]; /* samples */
-} __packed;
-
-struct evrc_encoded_meta_out {
-	uint16_t metadata_len;
-	uint16_t time_stamp_dword_lsw;
-	uint16_t time_stamp_dword_msw;
-	uint16_t time_stamp_lsw;
-	uint16_t time_stamp_msw;
-	uint16_t nflag_lsw;
-	uint16_t nflag_msw;
-};
-
-/* Audrec Queue command sent macro's */
-#define audio_send_queue_pre(audio, cmd, len) \
-	msm_adsp_write(audio->audpre, QDSP_uPAudPreProcCmdQueue, cmd, len)
-
-#define audio_send_queue_recbs(audio, cmd, len) \
-	msm_adsp_write(audio->audrec, ((audio->queue_ids & 0xFFFF0000) >> 16),\
-			cmd, len)
-#define audio_send_queue_rec(audio, cmd, len) \
-	msm_adsp_write(audio->audrec, (audio->queue_ids & 0x0000FFFF),\
-			cmd, len)
-
-static int audevrc_in_dsp_enable(struct audio_evrc_in *audio, int enable);
-static int audevrc_in_encparam_config(struct audio_evrc_in *audio);
-static int audevrc_in_encmem_config(struct audio_evrc_in *audio);
-static int audevrc_in_dsp_read_buffer(struct audio_evrc_in *audio,
-				uint32_t read_cnt);
-static void audevrc_in_flush(struct audio_evrc_in *audio);
-
-static void audevrc_in_get_dsp_frames(struct audio_evrc_in *audio);
-static int audpcm_config(struct audio_evrc_in *audio);
-static void audevrc_out_flush(struct audio_evrc_in *audio);
-static int audevrc_in_routing_mode_config(struct audio_evrc_in *audio);
-static void audrec_pcm_send_data(struct audio_evrc_in *audio, unsigned needed);
-static void audevrc_nt_in_get_dsp_frames(struct audio_evrc_in *audio);
-static void audevrc_in_flush(struct audio_evrc_in *audio);
-
-static unsigned convert_samp_index(unsigned index)
-{
-	switch (index) {
-	case RPC_AUD_DEF_SAMPLE_RATE_48000:	return 48000;
-	case RPC_AUD_DEF_SAMPLE_RATE_44100:	return 44100;
-	case RPC_AUD_DEF_SAMPLE_RATE_32000:	return 32000;
-	case RPC_AUD_DEF_SAMPLE_RATE_24000:	return 24000;
-	case RPC_AUD_DEF_SAMPLE_RATE_22050:	return 22050;
-	case RPC_AUD_DEF_SAMPLE_RATE_16000:	return 16000;
-	case RPC_AUD_DEF_SAMPLE_RATE_12000:	return 12000;
-	case RPC_AUD_DEF_SAMPLE_RATE_11025:	return 11025;
-	case RPC_AUD_DEF_SAMPLE_RATE_8000:	return 8000;
-	default:				return 11025;
-	}
-}
-
-/* ------------------- dsp --------------------- */
-static void audpre_dsp_event(void *data, unsigned id,  void *event_data)
-{
-
-	uint16_t *msg = event_data;
-
-	if (!msg)
-		return;
-
-	switch (id) {
-	case AUDPREPROC_MSG_CMD_CFG_DONE_MSG:
-		MM_DBG("type %d, status_flag %d\n",\
-			msg[0], msg[1]);
-		break;
-	case AUDPREPROC_MSG_ERROR_MSG_ID:
-		MM_INFO("err_index %d\n", msg[0]);
-		break;
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audpreproctask)\n");
-		break;
-	default:
-		MM_ERR("unknown event %d\n", id);
-	}
-}
-
-
-/* must be called with audio->lock held */
-static int audevrc_in_enable(struct audio_evrc_in *audio)
-{
-	struct audmgr_config cfg;
-	int rc;
-
-	if (audio->enabled)
-		return 0;
-
-	cfg.tx_rate = audio->samp_rate;
-	cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE;
-	cfg.def_method = RPC_AUD_DEF_METHOD_RECORD;
-	cfg.codec = RPC_AUD_DEF_CODEC_EVRC;
-	cfg.snd_method = RPC_SND_METHOD_MIDI;
-
-	if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-		rc = audmgr_enable(&audio->audmgr, &cfg);
-		if (rc < 0)
-			return rc;
-
-		if (audpreproc_enable(audio->enc_id,
-				&audpre_dsp_event, audio)) {
-			MM_ERR("msm_adsp_enable(audpreproc) failed\n");
-			audmgr_disable(&audio->audmgr);
-			return -ENODEV;
-		}
-
-		/*update aurec session info in audpreproc layer*/
-		audio->session_info.session_id = audio->enc_id;
-		audio->session_info.sampling_freq =
-			convert_samp_index(audio->samp_rate);
-		audpreproc_update_audrec_info(&audio->session_info);
-	}
-
-	if (msm_adsp_enable(audio->audrec)) {
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			audpreproc_disable(audio->enc_id, audio);
-			audmgr_disable(&audio->audmgr);
-		}
-		MM_ERR("msm_adsp_enable(audrec) failed\n");
-		return -ENODEV;
-	}
-
-	audio->enabled = 1;
-	audevrc_in_dsp_enable(audio, 1);
-
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audevrc_in_disable(struct audio_evrc_in *audio)
-{
-	if (audio->enabled) {
-		audio->enabled = 0;
-
-		audevrc_in_dsp_enable(audio, 0);
-
-		wake_up(&audio->wait);
-		wait_event_interruptible_timeout(audio->wait_enable,
-				audio->running == 0, 1*HZ);
-		audio->stopped = 1;
-		wake_up(&audio->wait);
-		msm_adsp_disable(audio->audrec);
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			audpreproc_disable(audio->enc_id, audio);
-			/*reset the sampling frequency information at
-			audpreproc layer*/
-			audio->session_info.sampling_freq = 0;
-			audpreproc_update_audrec_info(&audio->session_info);
-			audmgr_disable(&audio->audmgr);
-		}
-	}
-	return 0;
-}
-
-static void audevrc_in_get_dsp_frames(struct audio_evrc_in *audio)
-{
-	struct audio_frame *frame;
-	uint32_t index;
-	unsigned long flags;
-
-	index = audio->in_head;
-
-	frame = (void *) (((char *)audio->in[index].data) -
-			sizeof(*frame));
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->in[index].size = frame->frame_length;
-
-	/* statistics of read */
-	atomic_add(audio->in[index].size, &audio->in_bytes);
-	atomic_add(1, &audio->in_samples);
-
-	audio->in_head = (audio->in_head + 1) & (FRAME_NUM - 1);
-
-	/* If overflow, move the tail index foward. */
-	if (audio->in_head == audio->in_tail) {
-		MM_ERR("Error! not able to keep up the read\n");
-		audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
-		MM_ERR("in_count = %d\n", audio->in_count);
-	} else
-		audio->in_count++;
-
-	audevrc_in_dsp_read_buffer(audio, audio->dsp_cnt++);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-
-	wake_up(&audio->wait);
-}
-
-static void audevrc_nt_in_get_dsp_frames(struct audio_evrc_in *audio)
-{
-	struct audio_frame_nt *nt_frame;
-	uint32_t index;
-	unsigned long flags;
-
-	index = audio->in_head;
-	nt_frame = (void *) (((char *)audio->in[index].data) - \
-				sizeof(struct audio_frame_nt));
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->in[index].size = nt_frame->frame_length;
-	/* statistics of read */
-	atomic_add(audio->in[index].size, &audio->in_bytes);
-	atomic_add(1, &audio->in_samples);
-
-	audio->in_head = (audio->in_head + 1) & (FRAME_NUM - 1);
-
-	/* If overflow, move the tail index foward. */
-	if (audio->in_head == audio->in_tail)
-		MM_DBG("Error! not able to keep up the read\n");
-	else
-		audio->in_count++;
-
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	wake_up(&audio->wait);
-}
-
-static int audrec_pcm_buffer_ptr_refresh(struct audio_evrc_in *audio,
-				       unsigned idx, unsigned len)
-{
-	struct audrec_cmd_pcm_buffer_ptr_refresh_arm_enc cmd;
-
-	if (len ==  NT_FRAME_HEADER_SIZE)
-		len = len / 2;
-	else
-		len = (len + NT_FRAME_HEADER_SIZE) / 2;
-	MM_DBG("len = %d\n", len);
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_PCM_BUFFER_PTR_REFRESH_ARM_TO_ENC;
-	cmd.num_buffers = 1;
-	if (cmd.num_buffers == 1) {
-		cmd.buf_address_length[0] = (audio->out[idx].addr &
-							0xffff0000) >> 16;
-		cmd.buf_address_length[1] = (audio->out[idx].addr &
-							0x0000ffff);
-		cmd.buf_address_length[2] = (len & 0xffff0000) >> 16;
-		cmd.buf_address_length[3] = (len & 0x0000ffff);
-	}
-	audio->out_frame_cnt++;
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audpcm_config(struct audio_evrc_in *audio)
-{
-	struct audrec_cmd_pcm_cfg_arm_to_enc cmd;
-	MM_DBG("\n");
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_PCM_CFG_ARM_TO_ENC;
-	cmd.config_update_flag = AUDREC_PCM_CONFIG_UPDATE_FLAG_ENABLE;
-	cmd.enable_flag = AUDREC_ENABLE_FLAG_VALUE;
-	cmd.sampling_freq = convert_samp_index(audio->samp_rate);
-	if (!audio->channel_mode)
-		cmd.channels = 1;
-	else
-		cmd.channels = 2;
-	cmd.frequency_of_intimation = 1;
-	cmd.max_number_of_buffers = OUT_FRAME_NUM;
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-
-static int audevrc_in_routing_mode_config(struct audio_evrc_in *audio)
-{
-	struct audrec_cmd_routing_mode cmd;
-
-	MM_DBG("\n");
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_ROUTING_MODE;
-	if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL)
-		cmd.routing_mode = 1;
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static void audrec_dsp_event(void *data, unsigned id, size_t len,
-			    void (*getevent)(void *ptr, size_t len))
-{
-	struct audio_evrc_in *audio = NULL;
-
-	if (data)
-		audio = data;
-	else {
-		MM_ERR("invalid data for event %x\n", id);
-		return;
-	}
-
-	switch (id) {
-	case AUDREC_MSG_CMD_CFG_DONE_MSG: {
-		struct audrec_msg_cmd_cfg_done_msg cmd_cfg_done_msg;
-		getevent(&cmd_cfg_done_msg, AUDREC_MSG_CMD_CFG_DONE_MSG_LEN);
-		if (cmd_cfg_done_msg.audrec_enc_type & \
-				AUDREC_MSG_CFG_DONE_ENC_ENA) {
-			audio->audrec_obj_idx = cmd_cfg_done_msg.audrec_obj_idx;
-			MM_DBG("CFG ENABLED\n");
-			if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) {
-				MM_DBG("routing command\n");
-				audevrc_in_routing_mode_config(audio);
-			} else {
-				audevrc_in_encmem_config(audio);
-			}
-		} else {
-			MM_DBG("CFG SLEEP\n");
-			audio->running = 0;
-			wake_up(&audio->wait_enable);
-		}
-		break;
-	}
-	case AUDREC_MSG_CMD_ROUTING_MODE_DONE_MSG: {
-		struct audrec_msg_cmd_routing_mode_done_msg \
-			routing_msg;
-		getevent(&routing_msg, AUDREC_MSG_CMD_ROUTING_MODE_DONE_MSG);
-		MM_DBG("AUDREC_MSG_CMD_ROUTING_MODE_DONE_MSG");
-		if (routing_msg.configuration == 0) {
-			MM_ERR("routing configuration failed\n");
-			audio->running = 0;
-			wake_up(&audio->wait_enable);
-		} else
-			audevrc_in_encmem_config(audio);
-		break;
-	}
-	case AUDREC_MSG_CMD_AREC_MEM_CFG_DONE_MSG: {
-		MM_DBG("AREC_MEM_CFG_DONE_MSG\n");
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)
-			audevrc_in_encparam_config(audio);
-		else
-			audpcm_config(audio);
-		break;
-	}
-	case AUDREC_CMD_PCM_CFG_ARM_TO_ENC_DONE_MSG: {
-		MM_DBG("AUDREC_CMD_PCM_CFG_ARM_TO_ENC_DONE_MSG");
-		audevrc_in_encparam_config(audio);
-	    break;
-	}
-	case AUDREC_MSG_CMD_AREC_PARAM_CFG_DONE_MSG: {
-		MM_DBG("AUDREC_MSG_CMD_AREC_PARAM_CFG_DONE_MSG\n");
-		audio->running = 1;
-		wake_up(&audio->wait_enable);
-		if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL)
-			audrec_pcm_send_data(audio, 1);
-		break;
-	}
-	case AUDREC_CMD_PCM_BUFFER_PTR_UPDATE_ARM_TO_ENC_MSG: {
-		MM_DBG("ptr_update recieved from DSP\n");
-		audrec_pcm_send_data(audio, 1);
-		break;
-	}
-	case AUDREC_MSG_NO_EXT_PKT_AVAILABLE_MSG: {
-		struct audrec_msg_no_ext_pkt_avail_msg err_msg;
-		getevent(&err_msg, AUDREC_MSG_NO_EXT_PKT_AVAILABLE_MSG_LEN);
-		MM_DBG("NO_EXT_PKT_AVAILABLE_MSG %x\n",\
-			err_msg.audrec_err_id);
-		break;
-	}
-	case AUDREC_MSG_PACKET_READY_MSG: {
-		struct audrec_msg_packet_ready_msg pkt_ready_msg;
-
-		getevent(&pkt_ready_msg, AUDREC_MSG_PACKET_READY_MSG_LEN);
-		MM_DBG("UP_PACKET_READY_MSG: write cnt msw  %d \
-		write cnt lsw %d read cnt msw %d  read cnt lsw %d \n",\
-		pkt_ready_msg.pkt_counter_msw, \
-		pkt_ready_msg.pkt_counter_lsw, \
-		pkt_ready_msg.pkt_read_cnt_msw, \
-		pkt_ready_msg.pkt_read_cnt_lsw);
-
-		audevrc_in_get_dsp_frames(audio);
-		break;
-	}
-	case AUDREC_UP_NT_PACKET_READY_MSG: {
-		struct audrec_up_nt_packet_ready_msg pkt_ready_msg;
-
-		getevent(&pkt_ready_msg, AUDREC_UP_NT_PACKET_READY_MSG_LEN);
-		MM_DBG("UP_NT_PACKET_READY_MSG: write cnt lsw  %d \
-		write cnt msw %d read cnt lsw %d  read cnt msw %d \n",\
-		pkt_ready_msg.audrec_packetwrite_cnt_lsw, \
-		pkt_ready_msg.audrec_packetwrite_cnt_msw, \
-		pkt_ready_msg.audrec_upprev_readcount_lsw, \
-		pkt_ready_msg.audrec_upprev_readcount_msw);
-
-		audevrc_nt_in_get_dsp_frames(audio);
-		break;
-	}
-	case AUDREC_CMD_FLUSH_DONE_MSG: {
-		audio->wflush = 0;
-		audio->rflush = 0;
-		audio->flush_ack = 1;
-		wake_up(&audio->write_wait);
-		MM_DBG("flush ack recieved\n");
-		break;
-	}
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module \
-				enable/disable(audrectask)\n");
-		break;
-	default:
-		MM_ERR("unknown event %d\n", id);
-	}
-}
-
-static struct msm_adsp_ops audrec_evrc_adsp_ops = {
-	.event = audrec_dsp_event,
-};
-
-static int audevrc_in_dsp_enable(struct audio_evrc_in *audio, int enable)
-{
-	struct audrec_cmd_enc_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_ENC_CFG;
-	cmd.audrec_enc_type = (audio->enc_type & 0xFF) |
-			(enable ? AUDREC_CMD_ENC_ENA : AUDREC_CMD_ENC_DIS);
-	/* Don't care */
-	cmd.audrec_obj_idx = audio->audrec_obj_idx;
-
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audevrc_in_encmem_config(struct audio_evrc_in *audio)
-{
-	struct audrec_cmd_arecmem_cfg cmd;
-	uint16_t *data = (void *) audio->data;
-	int n;
-	int header_len = 0;
-
-	memset(&cmd, 0, sizeof(cmd));
-
-	cmd.cmd_id = AUDREC_CMD_ARECMEM_CFG;
-	cmd.audrec_obj_idx = audio->audrec_obj_idx;
-	/* Rate at which packet complete message comes */
-	cmd.audrec_up_pkt_intm_cnt = 1;
-	cmd.audrec_extpkt_buffer_msw = audio->phys >> 16;
-	cmd.audrec_extpkt_buffer_lsw = audio->phys;
-	/* Max Buffer no available for frames */
-	cmd.audrec_extpkt_buffer_num = FRAME_NUM;
-
-	/* prepare buffer pointers:
-	 * T:36 bytes evrc packet + 4 halfword header
-	 * NT:36 bytes evrc packet + 12 halfword header
-	 */
-	if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)
-		header_len = FRAME_HEADER_SIZE/2;
-	else
-		header_len = NT_FRAME_HEADER_SIZE/2;
-
-	for (n = 0; n < FRAME_NUM; n++) {
-		audio->in[n].data = data + header_len;
-		data += (EVRC_FRAME_SIZE/2) + header_len;
-		MM_DBG("0x%8x\n", (int)(audio->in[n].data - header_len*2));
-	}
-
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audevrc_in_encparam_config(struct audio_evrc_in *audio)
-{
-	struct audrec_cmd_arecparam_evrc_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDREC_CMD_ARECPARAM_CFG;
-	cmd.common.audrec_obj_idx = audio->audrec_obj_idx;
-	cmd.enc_min_rate = audio->cfg.min_bit_rate;
-	cmd.enc_max_rate = audio->cfg.max_bit_rate;
-	cmd.rate_modulation_cmd = 0;  /* Default set to 0 */
-
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audevrc_flush_command(struct audio_evrc_in *audio)
-{
-	struct audrec_cmd_flush cmd;
-	MM_DBG("\n");
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_FLUSH;
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audevrc_in_dsp_read_buffer(struct audio_evrc_in *audio,
-		uint32_t read_cnt)
-{
-	audrec_cmd_packet_ext_ptr cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_PACKET_EXT_PTR;
-	cmd.type = audio->audrec_obj_idx;
-	cmd.curr_rec_count_msw = read_cnt >> 16;
-	cmd.curr_rec_count_lsw = read_cnt;
-
-	return audio_send_queue_recbs(audio, &cmd, sizeof(cmd));
-}
-
-/* ------------------- device --------------------- */
-
-static void audevrc_ioport_reset(struct audio_evrc_in *audio)
-{
-	/* Make sure read/write thread are free from
-	 * sleep and knowing that system is not able
-	 * to process io request at the moment
-	 */
-	wake_up(&audio->wait);
-	mutex_lock(&audio->read_lock);
-	audevrc_in_flush(audio);
-	mutex_unlock(&audio->read_lock);
-	wake_up(&audio->write_wait);
-	mutex_lock(&audio->write_lock);
-	audevrc_out_flush(audio);
-	mutex_unlock(&audio->write_lock);
-}
-
-static void audevrc_in_flush(struct audio_evrc_in *audio)
-{
-	int i;
-	unsigned long flags;
-
-	audio->dsp_cnt = 0;
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->in_head = 0;
-	audio->in_tail = 0;
-	audio->in_count = 0;
-	audio->eos_ack = 0;
-	for (i = FRAME_NUM-1; i >= 0; i--) {
-		audio->in[i].size = 0;
-		audio->in[i].read = 0;
-	}
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	MM_DBG("in_bytes %d\n", atomic_read(&audio->in_bytes));
-	MM_DBG("in_samples %d\n", atomic_read(&audio->in_samples));
-	atomic_set(&audio->in_bytes, 0);
-	atomic_set(&audio->in_samples, 0);
-}
-
-static void audevrc_out_flush(struct audio_evrc_in *audio)
-{
-	int i;
-	unsigned long flags;
-
-	audio->out_head = 0;
-	audio->out_count = 0;
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->out_tail = 0;
-	for (i = OUT_FRAME_NUM-1; i >= 0; i--) {
-		audio->out[i].size = 0;
-		audio->out[i].read = 0;
-		audio->out[i].used = 0;
-	}
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-static long audevrc_in_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct audio_evrc_in *audio = file->private_data;
-	int rc = 0;
-
-	MM_DBG("\n");
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		stats.byte_count = atomic_read(&audio->in_bytes);
-		stats.sample_count = atomic_read(&audio->in_samples);
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return rc;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START: {
-		rc = audevrc_in_enable(audio);
-		if (!rc) {
-			rc =
-			wait_event_interruptible_timeout(audio->wait_enable,
-				audio->running != 0, 1*HZ);
-			MM_DBG("state %d rc = %d\n", audio->running, rc);
-
-			if (audio->running == 0)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		audio->stopped = 0;
-		break;
-	}
-	case AUDIO_STOP: {
-		rc = audevrc_in_disable(audio);
-		break;
-	}
-	case AUDIO_FLUSH: {
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audevrc_ioport_reset(audio);
-		if (audio->running) {
-			audevrc_flush_command(audio);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config cfg;
-		memset(&cfg, 0, sizeof(cfg));
-		cfg.buffer_size = OUT_BUFFER_SIZE;
-		cfg.buffer_count = OUT_FRAME_NUM;
-		cfg.sample_rate = convert_samp_index(audio->samp_rate);
-		cfg.channel_count = 1;
-		cfg.type = 0;
-		cfg.unused[0] = 0;
-		cfg.unused[1] = 0;
-		cfg.unused[2] = 0;
-		if (copy_to_user((void *) arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-	case AUDIO_GET_STREAM_CONFIG: {
-		struct msm_audio_stream_config cfg;
-		memset(&cfg, 0, sizeof(cfg));
-		cfg.buffer_size = audio->buffer_size;
-		cfg.buffer_count = FRAME_NUM;
-		if (copy_to_user((void *)arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-	case AUDIO_SET_STREAM_CONFIG: {
-		struct msm_audio_stream_config cfg;
-		if (copy_from_user(&cfg, (void *) arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		/* Allow only single frame */
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			if (cfg.buffer_size != (FRAME_SIZE - 8)) {
-				rc = -EINVAL;
-				break;
-			}
-		} else {
-			if (cfg.buffer_size != (EVRC_FRAME_SIZE + 14)) {
-				rc = -EINVAL;
-				break;
-			}
-		}
-		audio->buffer_size = cfg.buffer_size;
-		break;
-	}
-	case AUDIO_GET_EVRC_ENC_CONFIG: {
-		if (copy_to_user((void *) arg, &audio->cfg, sizeof(audio->cfg)))
-			rc = -EFAULT;
-		break;
-	}
-	case AUDIO_SET_EVRC_ENC_CONFIG: {
-		struct msm_audio_evrc_enc_config cfg;
-		if (copy_from_user(&cfg, (void *) arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		MM_DBG("0X%8x, 0x%8x, 0x%8x\n", cfg.min_bit_rate,
-				cfg.max_bit_rate, cfg.cdma_rate);
-		if (cfg.min_bit_rate > CDMA_RATE_FULL || \
-				 cfg.min_bit_rate < CDMA_RATE_EIGHTH) {
-			MM_ERR("invalid min bitrate\n");
-			rc = -EFAULT;
-			break;
-		}
-		if (cfg.max_bit_rate > CDMA_RATE_FULL || \
-				cfg.max_bit_rate < CDMA_RATE_EIGHTH) {
-			MM_ERR("invalid max bitrate\n");
-			rc = -EFAULT;
-			break;
-		}
-		/* Recording Does not support Erase and Blank */
-		if (cfg.cdma_rate > CDMA_RATE_FULL ||
-			cfg.cdma_rate < CDMA_RATE_EIGHTH) {
-			MM_ERR("invalid qcelp cdma rate\n");
-			rc = -EFAULT;
-			break;
-		}
-		memcpy(&audio->cfg, &cfg, sizeof(cfg));
-		break;
-	}
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static ssize_t audevrc_in_read(struct file *file,
-				char __user *buf,
-				size_t count, loff_t *pos)
-{
-	struct audio_evrc_in *audio = file->private_data;
-	unsigned long flags;
-	const char __user *start = buf;
-	void *data;
-	uint32_t index;
-	uint32_t size;
-	int rc = 0;
-	struct evrc_encoded_meta_out meta_field;
-	struct audio_frame_nt *nt_frame;
-	MM_DBG("count = %d\n", count);
-	mutex_lock(&audio->read_lock);
-	while (count > 0) {
-		rc = wait_event_interruptible(
-			audio->wait, (audio->in_count > 0) || audio->stopped ||
-			audio->rflush);
-		if (rc < 0)
-			break;
-
-		if (audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-		if (audio->stopped && !audio->in_count) {
-			MM_DBG("Driver in stop state, No more buffer to read");
-			rc = 0;/* End of File */
-			break;
-		}
-
-		index = audio->in_tail;
-		data = (uint8_t *) audio->in[index].data;
-		size = audio->in[index].size;
-
-		if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) {
-			nt_frame = (struct audio_frame_nt *)(data -
-					sizeof(struct audio_frame_nt));
-			memcpy((char *)&meta_field.time_stamp_dword_lsw,
-				(char *)&nt_frame->time_stamp_dword_lsw,
-				(sizeof(struct evrc_encoded_meta_out) - \
-				sizeof(uint16_t)));
-			meta_field.metadata_len =
-					sizeof(struct evrc_encoded_meta_out);
-			if (copy_to_user((char *)start, (char *)&meta_field,
-					sizeof(struct evrc_encoded_meta_out))) {
-				rc = -EFAULT;
-				break;
-			}
-			if (nt_frame->nflag_lsw & 0x0001) {
-				MM_ERR("recieved EOS in read call\n");
-				audio->eos_ack = 1;
-			}
-			buf += sizeof(struct evrc_encoded_meta_out);
-			count -= sizeof(struct evrc_encoded_meta_out);
-		}
-		if (count >= size) {
-			/* order the reads on the buffer */
-			dma_coherent_post_ops();
-			if (copy_to_user(buf, data, size)) {
-				rc = -EFAULT;
-				break;
-			}
-			spin_lock_irqsave(&audio->dsp_lock, flags);
-			if (index != audio->in_tail) {
-				/* overrun -- data is
-				 * invalid and we need to retry */
-				spin_unlock_irqrestore(&audio->dsp_lock, flags);
-				continue;
-			}
-			audio->in[index].size = 0;
-			audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
-			audio->in_count--;
-			spin_unlock_irqrestore(&audio->dsp_lock, flags);
-			count -= size;
-			buf += size;
-			if ((audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL)) {
-				if (!audio->eos_ack) {
-					MM_DBG("sending read ptr command \
-							%d %d\n",
-							audio->dsp_cnt,
-							audio->in_tail);
-					audevrc_in_dsp_read_buffer(audio,
-							audio->dsp_cnt++);
-				}
-			}
-		} else {
-			MM_ERR("short read\n");
-			break;
-		}
-		break;
-	}
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		return buf - start;
-
-	return rc;
-}
-
-static void audrec_pcm_send_data(struct audio_evrc_in *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-	MM_DBG("\n");
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			MM_DBG("frame %d free\n", audio->out_tail);
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			audrec_pcm_buffer_ptr_refresh(audio,
-						 audio->out_tail,
-						    frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
- done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static int audevrc_in_fsync(struct file *file, loff_t a, loff_t b,
-	int datasync)
-
-{
-	struct audio_evrc_in *audio = file->private_data;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (!audio->running || (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)) {
-		rc = -EINVAL;
-		goto done_nolock;
-	}
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-			audio->wflush);
-	MM_DBG("waked on by some event audio->wflush = %d\n", audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-done:
-	mutex_unlock(&audio->write_lock);
-done_nolock:
-	return rc;
-
-}
-
-int audrec_evrc_process_eos(struct audio_evrc_in *audio,
-		const char __user *buf_start, unsigned short mfield_size)
-{
-	struct buffer *frame;
-	int rc = 0;
-
-	frame = audio->out + audio->out_head;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	MM_DBG("copying meta_out frame->used = %d\n", frame->used);
-	audrec_pcm_send_data(audio, 0);
-done:
-	return rc;
-}
-
-static ssize_t audevrc_in_write(struct file *file,
-				const char __user *buf,
-				size_t count, loff_t *pos)
-{
-	struct audio_evrc_in *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	char *cpy_ptr;
-	int rc = 0, eos_condition = AUDPREPROC_EVRC_EOS_NONE;
-	unsigned short mfield_size = 0;
-	int write_count = 0;
-	MM_DBG("cnt=%d\n", count);
-
-	if (count & 1)
-		return -EINVAL;
-
-	if (audio->mode != MSM_AUD_ENC_MODE_NONTUNNEL)
-		return -EINVAL;
-
-	mutex_lock(&audio->write_lock);
-	frame = audio->out + audio->out_head;
-	/* if supplied count is more than driver buffer size
-	 * then only copy driver buffer size
-	 */
-	if (count > frame->size)
-		count = frame->size;
-
-	write_count = count;
-	cpy_ptr = frame->data;
-	rc = wait_event_interruptible(audio->write_wait,
-				      (frame->used == 0)
-					|| (audio->stopped)
-					|| (audio->wflush));
-	if (rc < 0)
-		goto error;
-
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto error;
-	}
-	if (audio->mfield) {
-		if (buf == start) {
-			/* Processing beginning of user buffer */
-			if (__get_user(mfield_size,
-				(unsigned short __user *) buf)) {
-				rc = -EFAULT;
-				goto error;
-			} else if (mfield_size > count) {
-				rc = -EINVAL;
-				goto error;
-			}
-			MM_DBG("mf offset_val %x\n", mfield_size);
-			if (copy_from_user(cpy_ptr, buf, mfield_size)) {
-				rc = -EFAULT;
-				goto error;
-			}
-			/* Check if EOS flag is set and buffer has
-			 * contains just meta field
-			 */
-			if (cpy_ptr[AUDPREPROC_EVRC_EOS_FLG_OFFSET] &
-					AUDPREPROC_EVRC_EOS_FLG_MASK) {
-				eos_condition = AUDPREPROC_EVRC_EOS_SET;
-				MM_DBG("EOS SET\n");
-				if (mfield_size == count) {
-					buf += mfield_size;
-					eos_condition = 0;
-					goto exit;
-				} else
-				cpy_ptr[AUDPREPROC_EVRC_EOS_FLG_OFFSET] &=
-					~AUDPREPROC_EVRC_EOS_FLG_MASK;
-			}
-			cpy_ptr += mfield_size;
-			count -= mfield_size;
-			buf += mfield_size;
-		} else {
-			mfield_size = 0;
-			MM_DBG("continuous buffer\n");
-		}
-		frame->mfield_sz = mfield_size;
-	}
-	MM_DBG("copying the stream count = %d\n", count);
-	if (copy_from_user(cpy_ptr, buf, count)) {
-		rc = -EFAULT;
-		goto error;
-	}
-exit:
-	frame->used = count;
-	audio->out_head ^= 1;
-	if (!audio->flush_ack)
-		audrec_pcm_send_data(audio, 0);
-	else {
-		audrec_pcm_send_data(audio, 1);
-		audio->flush_ack = 0;
-	}
-	if (eos_condition == AUDPREPROC_EVRC_EOS_SET)
-		rc = audrec_evrc_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	return write_count;
-error:
-	mutex_unlock(&audio->write_lock);
-	return rc;
-}
-
-static int audevrc_in_release(struct inode *inode, struct file *file)
-{
-	struct audio_evrc_in *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	audevrc_in_disable(audio);
-	audevrc_in_flush(audio);
-	msm_adsp_put(audio->audrec);
-
-	audpreproc_aenc_free(audio->enc_id);
-	audio->audrec = NULL;
-	audio->opened = 0;
-	if ((audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) && \
-	   (audio->out_data)) {
-		ion_unmap_kernel(audio->client, audio->input_buff_handle);
-		ion_free(audio->client, audio->input_buff_handle);
-		audio->out_data = NULL;
-	}
-	if (audio->data) {
-		ion_unmap_kernel(audio->client, audio->output_buff_handle);
-		ion_free(audio->client, audio->output_buff_handle);
-		audio->data = NULL;
-	}
-	ion_client_destroy(audio->client);
-	mutex_unlock(&audio->lock);
-	return 0;
-}
-
-static struct audio_evrc_in the_audio_evrc_in;
-
-static int audevrc_in_open(struct inode *inode, struct file *file)
-{
-	struct audio_evrc_in *audio = &the_audio_evrc_in;
-	int rc;
-	int encid;
-	int dma_size = 0;
-	int len = 0;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	struct ion_client *client = NULL;
-
-	mutex_lock(&audio->lock);
-	if (audio->opened) {
-		rc = -EBUSY;
-		goto done;
-	}
-	if ((file->f_mode & FMODE_WRITE) &&
-		(file->f_mode & FMODE_READ)) {
-		audio->mode = MSM_AUD_ENC_MODE_NONTUNNEL;
-		dma_size = NT_DMASZ;
-		MM_DBG("Opened for non tunnel mode encoding\n");
-	} else if (!(file->f_mode & FMODE_WRITE) &&
-				(file->f_mode & FMODE_READ)) {
-		audio->mode = MSM_AUD_ENC_MODE_TUNNEL;
-		dma_size = DMASZ;
-		MM_DBG("Opened for tunnel mode encoding\n");
-	} else {
-		MM_ERR("Invalid mode\n");
-		rc = -EACCES;
-		goto done;
-	}
-
-	/* Settings will be re-config at AUDIO_SET_CONFIG,
-	 * but at least we need to have initial config
-	 */
-	audio->samp_rate = RPC_AUD_DEF_SAMPLE_RATE_8000,
-	audio->samp_rate_index = AUDREC_CMD_SAMP_RATE_INDX_8000;
-	audio->channel_mode = AUDREC_CMD_STEREO_MODE_MONO;
-	if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL)
-		audio->buffer_size = (EVRC_FRAME_SIZE + 14);
-	else
-		audio->buffer_size = EVRC_FRAME_SIZE;
-	audio->enc_type = AUDREC_CMD_TYPE_0_INDEX_EVRC | audio->mode;
-
-	audio->cfg.cdma_rate = CDMA_RATE_FULL;
-	audio->cfg.min_bit_rate = CDMA_RATE_FULL;
-	audio->cfg.max_bit_rate = CDMA_RATE_FULL;
-
-	if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-		rc = audmgr_open(&audio->audmgr);
-		if (rc)
-			goto done;
-	}
-
-	encid = audpreproc_aenc_alloc(audio->enc_type, &audio->module_name,
-			&audio->queue_ids);
-	if (encid < 0) {
-		MM_ERR("No free encoder available\n");
-		rc = -ENODEV;
-		goto done;
-	}
-	audio->enc_id = encid;
-
-	rc = msm_adsp_get(audio->module_name, &audio->audrec,
-			   &audrec_evrc_adsp_ops, audio);
-	if (rc) {
-		audpreproc_aenc_free(audio->enc_id);
-		goto done;
-	}
-
-	audio->dsp_cnt = 0;
-	audio->stopped = 0;
-	audio->wflush = 0;
-	audio->rflush = 0;
-	audio->flush_ack = 0;
-
-	audevrc_in_flush(audio);
-	audevrc_out_flush(audio);
-
-	client = msm_ion_client_create(UINT_MAX, "Audio_EVRC_in_client");
-	if (IS_ERR_OR_NULL(client)) {
-		MM_ERR("Unable to create ION client\n");
-		rc = -ENOMEM;
-		goto client_create_error;
-	}
-	audio->client = client;
-
-	MM_DBG("allocating mem sz = %d\n", dma_size);
-	handle = ion_alloc(client, dma_size, SZ_4K,
-		ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-	if (IS_ERR_OR_NULL(handle)) {
-		MM_ERR("Unable to create allocate O/P buffers\n");
-		rc = -ENOMEM;
-		goto output_buff_alloc_error;
-	}
-
-	audio->output_buff_handle = handle;
-
-	rc = ion_phys(client , handle, &addr, &len);
-	if (rc) {
-		MM_ERR("O/P buffers:Invalid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-		rc = -ENOMEM;
-		goto output_buff_get_phys_error;
-	} else {
-		MM_INFO("O/P buffers:valid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-	}
-	audio->phys = (int32_t)addr;
-
-	rc = ion_handle_get_flags(client, handle, &ionflag);
-	if (rc) {
-		MM_ERR("could not get flags for the handle\n");
-		rc = -ENOMEM;
-		goto output_buff_get_flags_error;
-	}
-
-	audio->map_v_read = ion_map_kernel(client, handle);
-	if (IS_ERR(audio->map_v_read)) {
-		MM_ERR("could not map read buffers,freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENOMEM;
-		goto output_buff_map_error;
-	}
-	audio->data = audio->map_v_read;
-	MM_DBG("read buf: phy addr 0x%08x kernel addr 0x%08x\n",
-		audio->phys, (int)audio->data);
-
-	audio->out_data = NULL;
-	if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) {
-		MM_DBG("allocating BUFFER_SIZE  %d\n", BUFFER_SIZE);
-		handle = ion_alloc(client, BUFFER_SIZE,
-				SZ_4K, ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-		if (IS_ERR_OR_NULL(handle)) {
-			MM_ERR("Unable to create allocate I/P buffers\n");
-			rc = -ENOMEM;
-			goto input_buff_alloc_error;
-		}
-
-		audio->input_buff_handle = handle;
-
-		rc = ion_phys(client , handle, &addr, &len);
-		if (rc) {
-			MM_ERR("I/P buffers:Invalid phy: %x sz: %x\n",
-				(unsigned int) addr, (unsigned int) len);
-			rc = -ENOMEM;
-			goto input_buff_alloc_error;
-		} else {
-			MM_INFO("Got valid phy: %x sz: %x\n",
-				(unsigned int) addr,
-				(unsigned int) len);
-		}
-		audio->out_phys = (int32_t)addr;
-
-		rc = ion_handle_get_flags(client,
-			handle, &ionflag);
-		if (rc) {
-			MM_ERR("could not get flags for the handle\n");
-			rc = -ENOMEM;
-			goto input_buff_alloc_error;
-		}
-
-		audio->map_v_write = ion_map_kernel(client, handle);
-		if (IS_ERR(audio->map_v_write)) {
-			MM_ERR("could not map write buffers\n");
-			rc = -ENOMEM;
-			goto input_buff_map_error;
-		}
-		audio->out_data = audio->map_v_write;
-		MM_DBG("write buf: phy addr 0x%08x kernel addr 0x%08x\n",
-					(unsigned int)addr,
-					(unsigned int)audio->out_data);
-
-		/* Initialize buffer */
-		audio->out[0].data = audio->out_data + 0;
-		audio->out[0].addr = audio->out_phys + 0;
-		audio->out[0].size = OUT_BUFFER_SIZE;
-
-		audio->out[1].data = audio->out_data + OUT_BUFFER_SIZE;
-		audio->out[1].addr = audio->out_phys + OUT_BUFFER_SIZE;
-		audio->out[1].size = OUT_BUFFER_SIZE;
-
-		MM_DBG("audio->out[0].data = %d  audio->out[1].data = %d",
-				(unsigned int)audio->out[0].data,
-				(unsigned int)audio->out[1].data);
-		audio->mfield = NT_FRAME_HEADER_SIZE;
-		audio->out_frame_cnt++;
-	}
-	file->private_data = audio;
-	audio->opened = 1;
-
-done:
-	mutex_unlock(&audio->lock);
-	return rc;
-input_buff_map_error:
-	ion_free(client, audio->input_buff_handle);
-input_buff_alloc_error:
-	ion_unmap_kernel(client, audio->output_buff_handle);
-output_buff_map_error:
-output_buff_get_phys_error:
-output_buff_get_flags_error:
-	ion_free(client, audio->output_buff_handle);
-output_buff_alloc_error:
-	ion_client_destroy(client);
-client_create_error:
-	msm_adsp_put(audio->audrec);
-
-	audpreproc_aenc_free(audio->enc_id);
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static const struct file_operations audio_evrc_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audevrc_in_open,
-	.release	= audevrc_in_release,
-	.read		= audevrc_in_read,
-	.write		= audevrc_in_write,
-	.fsync		= audevrc_in_fsync,
-	.unlocked_ioctl	= audevrc_in_ioctl,
-};
-
-static struct miscdevice audevrc_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_evrc_in",
-	.fops	= &audio_evrc_in_fops,
-};
-
-static int __init audevrc_in_init(void)
-{
-	mutex_init(&the_audio_evrc_in.lock);
-	mutex_init(&the_audio_evrc_in.read_lock);
-	spin_lock_init(&the_audio_evrc_in.dsp_lock);
-	init_waitqueue_head(&the_audio_evrc_in.wait);
-	init_waitqueue_head(&the_audio_evrc_in.wait_enable);
-	mutex_init(&the_audio_evrc_in.write_lock);
-	init_waitqueue_head(&the_audio_evrc_in.write_wait);
-	return misc_register(&audevrc_in_misc);
-}
-device_initcall(audevrc_in_init);
diff --git a/arch/arm/mach-msm/qdsp5/audio_fm.c b/arch/arm/mach-msm/qdsp5/audio_fm.c
deleted file mode 100644
index 957a407..0000000
--- a/arch/arm/mach-msm/qdsp5/audio_fm.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/audio_fm.c
- *
- * pcm audio output device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2011, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/msm_audio.h>
-#include <mach/debug_mm.h>
-
-#include "audmgr.h"
-
-struct audio {
-	struct mutex lock;
-	int opened;
-	int enabled;
-	int running;
-	struct audmgr audmgr;
-	uint16_t volume;
-};
-
-static struct audio fm_audio;
-
-/* must be called with audio->lock held */
-static int audio_enable(struct audio *audio)
-{
-	struct audmgr_config cfg;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	if (audio->enabled)
-		return 0;
-
-	cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000;
-	cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000;
-	cfg.def_method = RPC_AUD_DEF_METHOD_HOST_PCM;
-	cfg.codec = RPC_AUD_DEF_CODEC_PCM;
-	cfg.snd_method = RPC_SND_METHOD_VOICE;
-
-	rc = audmgr_enable(&audio->audmgr, &cfg);
-	if (rc < 0)
-		return rc;
-
-	audio->enabled = 1;
-	return rc;
-}
-
-/* must be called with audio->lock held */
-static int audio_disable(struct audio *audio)
-{
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audmgr_disable(&audio->audmgr);
-	}
-	return 0;
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = -EINVAL;
-
-	MM_DBG("cmd %d", cmd);
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		MM_DBG("AUDIO_START\n");
-		rc = audio_enable(audio);
-		break;
-	case AUDIO_STOP:
-		MM_DBG("AUDIO_STOP\n");
-		rc = audio_disable(audio);
-		audio->running = 0;
-		audio->enabled = 0;
-		break;
-
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static int audio_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	MM_DBG("audio instance 0x%08x freeing\n", (int)audio);
-	mutex_lock(&audio->lock);
-	audio_disable(audio);
-	audio->running = 0;
-	audio->enabled = 0;
-	audio->opened = 0;
-	mutex_unlock(&audio->lock);
-	return 0;
-}
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = &fm_audio;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	mutex_lock(&audio->lock);
-
-	if (audio->opened) {
-		MM_ERR("busy\n");
-		rc = -EBUSY;
-		goto done;
-	}
-
-	rc = audmgr_open(&audio->audmgr);
-
-	if (rc) {
-		MM_ERR("%s: failed to register listnet\n", __func__);
-		goto done;
-	}
-
-	file->private_data = audio;
-	audio->opened = 1;
-
-done:
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static const struct file_operations audio_fm_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audio_open,
-	.release	= audio_release,
-	.unlocked_ioctl	= audio_ioctl,
-};
-
-struct miscdevice audio_fm_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_fm",
-	.fops	= &audio_fm_fops,
-};
-
-static int __init audio_init(void)
-{
-	struct audio *audio = &fm_audio;
-
-	mutex_init(&audio->lock);
-	return misc_register(&audio_fm_misc);
-}
-
-device_initcall(audio_init);
-
-MODULE_DESCRIPTION("MSM FM driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5/audio_in.c b/arch/arm/mach-msm/qdsp5/audio_in.c
deleted file mode 100644
index 6fc2ac0..0000000
--- a/arch/arm/mach-msm/qdsp5/audio_in.c
+++ /dev/null
@@ -1,996 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/audio_in.c
- *
- * pcm audio input device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2009, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-
-#include <linux/delay.h>
-
-#include <linux/msm_audio_aac.h>
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-#include <mach/msm_adsp.h>
-#include <mach/msm_rpcrouter.h>
-
-#include "audmgr.h"
-
-#include <mach/qdsp5/qdsp5audpreproccmdi.h>
-#include <mach/qdsp5/qdsp5audpreprocmsg.h>
-#include <mach/qdsp5/qdsp5audreccmdi.h>
-#include <mach/qdsp5/qdsp5audrecmsg.h>
-#include <mach/debug_mm.h>
-
-/* FRAME_NUM must be a power of two */
-#define FRAME_NUM		(8)
-#define FRAME_SIZE		(2052 * 2)
-#define MONO_DATA_SIZE		(2048)
-#define STEREO_DATA_SIZE	(MONO_DATA_SIZE * 2)
-#define DMASZ 			(FRAME_SIZE * FRAME_NUM)
-
-struct buffer {
-	void *data;
-	uint32_t size;
-	uint32_t read;
-	uint32_t addr;
-};
-
-struct audio_in {
-	struct buffer in[FRAME_NUM];
-
-	spinlock_t dsp_lock;
-
-	atomic_t in_bytes;
-
-	struct mutex lock;
-	struct mutex read_lock;
-	wait_queue_head_t wait;
-
-	struct msm_adsp_module *audpre;
-	struct msm_adsp_module *audrec;
-
-	/* configuration to use on next enable */
-	uint32_t samp_rate;
-	uint32_t channel_mode;
-	uint32_t buffer_size; /* 2048 for mono, 4096 for stereo */
-	uint32_t type; /* 0 for PCM ,1 for AAC */
-	uint32_t bit_rate; /* bit rate for AAC */
-	uint32_t record_quality; /* record quality (bits/sample/channel)
-				    for AAC*/
-	uint32_t buffer_cfg_ioctl; /* to allow any one of buffer set ioctl */
-	uint32_t dsp_cnt;
-	uint32_t in_head; /* next buffer dsp will write */
-	uint32_t in_tail; /* next buffer read() will read */
-	uint32_t in_count; /* number of buffers available to read() */
-
-	unsigned short samp_rate_index;
-
-	struct audmgr audmgr;
-
-	/* data allocated for various buffers */
-	char *data;
-	dma_addr_t phys;
-
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped, cleared on flush */
-
-	/* audpre settings */
-	int tx_agc_enable;
-	audpreproc_cmd_cfg_agc_params tx_agc_cfg;
-	int ns_enable;
-	audpreproc_cmd_cfg_ns_params ns_cfg;
-	/* For different sample rate, the coeff might be different. *
-	 * All the coeff should be passed from user space	    */
-	int iir_enable;
-	audpreproc_cmd_cfg_iir_tuning_filter_params iir_cfg;
-};
-
-static int audio_in_dsp_enable(struct audio_in *audio, int enable);
-static int audio_in_encoder_config(struct audio_in *audio);
-static int audio_dsp_read_buffer(struct audio_in *audio, uint32_t read_cnt);
-static void audio_flush(struct audio_in *audio);
-static int audio_dsp_set_tx_agc(struct audio_in *audio);
-static int audio_dsp_set_ns(struct audio_in *audio);
-static int audio_dsp_set_iir(struct audio_in *audio);
-
-static unsigned convert_dsp_samp_index(unsigned index)
-{
-	switch (index) {
-	case 48000:	return AUDREC_CMD_SAMP_RATE_INDX_48000;
-	case 44100:	return AUDREC_CMD_SAMP_RATE_INDX_44100;
-	case 32000:	return AUDREC_CMD_SAMP_RATE_INDX_32000;
-	case 24000:	return AUDREC_CMD_SAMP_RATE_INDX_24000;
-	case 22050:	return AUDREC_CMD_SAMP_RATE_INDX_22050;
-	case 16000:	return AUDREC_CMD_SAMP_RATE_INDX_16000;
-	case 12000:	return AUDREC_CMD_SAMP_RATE_INDX_12000;
-	case 11025:	return AUDREC_CMD_SAMP_RATE_INDX_11025;
-	case 8000:	return AUDREC_CMD_SAMP_RATE_INDX_8000;
-	default: 	return AUDREC_CMD_SAMP_RATE_INDX_11025;
-	}
-}
-
-static unsigned convert_samp_rate(unsigned hz)
-{
-	switch (hz) {
-	case 48000: return RPC_AUD_DEF_SAMPLE_RATE_48000;
-	case 44100: return RPC_AUD_DEF_SAMPLE_RATE_44100;
-	case 32000: return RPC_AUD_DEF_SAMPLE_RATE_32000;
-	case 24000: return RPC_AUD_DEF_SAMPLE_RATE_24000;
-	case 22050: return RPC_AUD_DEF_SAMPLE_RATE_22050;
-	case 16000: return RPC_AUD_DEF_SAMPLE_RATE_16000;
-	case 12000: return RPC_AUD_DEF_SAMPLE_RATE_12000;
-	case 11025: return RPC_AUD_DEF_SAMPLE_RATE_11025;
-	case 8000:  return RPC_AUD_DEF_SAMPLE_RATE_8000;
-	default:    return RPC_AUD_DEF_SAMPLE_RATE_11025;
-	}
-}
-
-static unsigned convert_samp_index(unsigned index)
-{
-	switch (index) {
-	case RPC_AUD_DEF_SAMPLE_RATE_48000:	return 48000;
-	case RPC_AUD_DEF_SAMPLE_RATE_44100:	return 44100;
-	case RPC_AUD_DEF_SAMPLE_RATE_32000:	return 32000;
-	case RPC_AUD_DEF_SAMPLE_RATE_24000:	return 24000;
-	case RPC_AUD_DEF_SAMPLE_RATE_22050:	return 22050;
-	case RPC_AUD_DEF_SAMPLE_RATE_16000:	return 16000;
-	case RPC_AUD_DEF_SAMPLE_RATE_12000:	return 12000;
-	case RPC_AUD_DEF_SAMPLE_RATE_11025:	return 11025;
-	case RPC_AUD_DEF_SAMPLE_RATE_8000:	return 8000;
-	default: 				return 11025;
-	}
-}
-
-/* must be called with audio->lock held */
-static int audio_in_enable(struct audio_in *audio)
-{
-	struct audmgr_config cfg;
-	int rc;
-
-	if (audio->enabled)
-		return 0;
-
-	cfg.tx_rate = audio->samp_rate;
-	cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE;
-	cfg.def_method = RPC_AUD_DEF_METHOD_RECORD;
-	if (audio->type == AUDREC_CMD_TYPE_0_INDEX_WAV)
-		cfg.codec = RPC_AUD_DEF_CODEC_PCM;
-	else
-		cfg.codec = RPC_AUD_DEF_CODEC_AAC;
-	cfg.snd_method = RPC_SND_METHOD_MIDI;
-
-	rc = audmgr_enable(&audio->audmgr, &cfg);
-	if (rc < 0)
-		return rc;
-
-	if (msm_adsp_enable(audio->audpre)) {
-		MM_ERR("msm_adsp_enable(audpre) failed\n");
-		return -ENODEV;
-	}
-	if (msm_adsp_enable(audio->audrec)) {
-		MM_ERR("msm_adsp_enable(audrec) failed\n");
-		return -ENODEV;
-	}
-
-	audio->enabled = 1;
-	audio_in_dsp_enable(audio, 1);
-
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audio_in_disable(struct audio_in *audio)
-{
-	if (audio->enabled) {
-		audio->enabled = 0;
-
-		audio_in_dsp_enable(audio, 0);
-
-		wake_up(&audio->wait);
-
-		msm_adsp_disable(audio->audrec);
-		msm_adsp_disable(audio->audpre);
-		audmgr_disable(&audio->audmgr);
-	}
-	return 0;
-}
-
-/* ------------------- dsp --------------------- */
-static void audpre_dsp_event(void *data, unsigned id, size_t len,
-			    void (*getevent)(void *ptr, size_t len))
-{
-	uint16_t msg[2];
-	getevent(msg, sizeof(msg));
-
-	switch (id) {
-	case AUDPREPROC_MSG_CMD_CFG_DONE_MSG:
-		MM_INFO("type %d, status_flag %d\n", msg[0], msg[1]);
-		break;
-	case AUDPREPROC_MSG_ERROR_MSG_ID:
-		MM_INFO("err_index %d\n", msg[0]);
-		break;
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audpreproctask)\n");
-		break;
-	default:
-		MM_ERR("unknown event %d\n", id);
-	}
-}
-
-struct audio_frame {
-	uint16_t count_low;
-	uint16_t count_high;
-	uint16_t bytes;
-	uint16_t unknown;
-	unsigned char samples[];
-} __attribute__((packed));
-
-static void audio_in_get_dsp_frames(struct audio_in *audio)
-{
-	struct audio_frame *frame;
-	uint32_t index;
-	unsigned long flags;
-
-		index = audio->in_head;
-
-		/* XXX check for bogus frame size? */
-
-		frame = (void *) (((char *)audio->in[index].data) -
-				 sizeof(*frame));
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->in[index].size = frame->bytes;
-
-		audio->in_head = (audio->in_head + 1) & (FRAME_NUM - 1);
-
-		/* If overflow, move the tail index foward. */
-		if (audio->in_head == audio->in_tail)
-			audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
-		else
-			audio->in_count++;
-
-		audio_dsp_read_buffer(audio, audio->dsp_cnt++);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-
-		wake_up(&audio->wait);
-}
-
-static void audrec_dsp_event(void *data, unsigned id, size_t len,
-			    void (*getevent)(void *ptr, size_t len))
-{
-	struct audio_in *audio = data;
-	uint16_t msg[3];
-	getevent(msg, sizeof(msg));
-
-	switch (id) {
-	case AUDREC_MSG_CMD_CFG_DONE_MSG:
-		if (msg[0] & AUDREC_MSG_CFG_DONE_TYPE_0_UPDATE) {
-			if (msg[0] & AUDREC_MSG_CFG_DONE_TYPE_0_ENA) {
-				MM_INFO("CFG ENABLED\n");
-				audio_in_encoder_config(audio);
-			} else {
-				MM_INFO("CFG SLEEP\n");
-				audio->running = 0;
-				audio->tx_agc_enable = 0;
-				audio->ns_enable = 0;
-				audio->iir_enable = 0;
-			}
-		} else {
-			MM_INFO("CMD_CFG_DONE %x\n", msg[0]);
-		}
-		break;
-	case AUDREC_MSG_CMD_AREC_PARAM_CFG_DONE_MSG: {
-		MM_INFO("PARAM CFG DONE\n");
-		audio->running = 1;
-		audio_dsp_set_tx_agc(audio);
-		audio_dsp_set_ns(audio);
-		audio_dsp_set_iir(audio);
-		break;
-	}
-	case AUDREC_MSG_FATAL_ERR_MSG:
-		MM_ERR("ERROR %x\n", msg[0]);
-		break;
-	case AUDREC_MSG_PACKET_READY_MSG:
-/* REC_DBG("type %x, count %d", msg[0], (msg[1] | (msg[2] << 16))); */
-		audio_in_get_dsp_frames(audio);
-		break;
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module \
-				enable/disable(audrectask)\n");
-		break;
-	default:
-		MM_ERR("unknown event %d\n", id);
-	}
-}
-
-struct msm_adsp_ops audpre_adsp_ops = {
-	.event = audpre_dsp_event,
-};
-
-struct msm_adsp_ops audrec_adsp_ops = {
-	.event = audrec_dsp_event,
-};
-
-
-#define audio_send_queue_pre(audio, cmd, len) \
-	msm_adsp_write(audio->audpre, QDSP_uPAudPreProcCmdQueue, cmd, len)
-#define audio_send_queue_recbs(audio, cmd, len) \
-	msm_adsp_write(audio->audrec, QDSP_uPAudRecBitStreamQueue, cmd, len)
-#define audio_send_queue_rec(audio, cmd, len) \
-	msm_adsp_write(audio->audrec, \
-	QDSP_uPAudRecCmdQueue, cmd, len)
-
-/* Convert Bit Rate to Record Quality field of DSP */
-static unsigned int bitrate_to_record_quality(unsigned int sample_rate,
-    unsigned int channel, unsigned int bit_rate) {
-	unsigned int temp;
-
-	temp = sample_rate * channel;
-	MM_DBG(" sample rate *  channel = %d \n", temp);
-	/* To represent in Q12 fixed format */
-	temp = (bit_rate * 4096) / temp;
-	MM_DBG(" Record Quality = 0x%8x \n", temp);
-	return temp;
-}
-
-static int audio_dsp_set_tx_agc(struct audio_in *audio)
-{
-	audpreproc_cmd_cfg_agc_params cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-
-	audio->tx_agc_cfg.cmd_id = AUDPREPROC_CMD_CFG_AGC_PARAMS;
-	if (audio->tx_agc_enable) {
-		/* cmd.tx_agc_param_mask = 0xFE00 from sample code */
-		audio->tx_agc_cfg.tx_agc_param_mask =
-		(1 << AUDPREPROC_CMD_TX_AGC_PARAM_MASK_COMP_SLOPE) |
-		(1 << AUDPREPROC_CMD_TX_AGC_PARAM_MASK_COMP_TH) |
-		(1 << AUDPREPROC_CMD_TX_AGC_PARAM_MASK_EXP_SLOPE) |
-		(1 << AUDPREPROC_CMD_TX_AGC_PARAM_MASK_EXP_TH) |
-		(1 << AUDPREPROC_CMD_TX_AGC_PARAM_MASK_COMP_AIG_FLAG) |
-		(1 << AUDPREPROC_CMD_TX_AGC_PARAM_MASK_COMP_STATIC_GAIN) |
-		(1 << AUDPREPROC_CMD_TX_AGC_PARAM_MASK_TX_AGC_ENA_FLAG);
-		audio->tx_agc_cfg.tx_agc_enable_flag =
-			AUDPREPROC_CMD_TX_AGC_ENA_FLAG_ENA;
-		/* cmd.param_mask = 0xFFF0 from sample code */
-		audio->tx_agc_cfg.param_mask =
-			(1 << AUDPREPROC_CMD_PARAM_MASK_RMS_TAY) |
-			(1 << AUDPREPROC_CMD_PARAM_MASK_RELEASEK) |
-			(1 << AUDPREPROC_CMD_PARAM_MASK_DELAY) |
-			(1 << AUDPREPROC_CMD_PARAM_MASK_ATTACKK) |
-			(1 << AUDPREPROC_CMD_PARAM_MASK_LEAKRATE_SLOW) |
-			(1 << AUDPREPROC_CMD_PARAM_MASK_LEAKRATE_FAST) |
-			(1 << AUDPREPROC_CMD_PARAM_MASK_AIG_RELEASEK) |
-			(1 << AUDPREPROC_CMD_PARAM_MASK_AIG_MIN) |
-			(1 << AUDPREPROC_CMD_PARAM_MASK_AIG_MAX) |
-			(1 << AUDPREPROC_CMD_PARAM_MASK_LEAK_UP) |
-			(1 << AUDPREPROC_CMD_PARAM_MASK_LEAK_DOWN) |
-			(1 << AUDPREPROC_CMD_PARAM_MASK_AIG_ATTACKK);
-	} else {
-		audio->tx_agc_cfg.tx_agc_param_mask =
-			(1 << AUDPREPROC_CMD_TX_AGC_PARAM_MASK_TX_AGC_ENA_FLAG);
-		audio->tx_agc_cfg.tx_agc_enable_flag =
-			AUDPREPROC_CMD_TX_AGC_ENA_FLAG_DIS;
-	}
-	cmd = audio->tx_agc_cfg;
-
-	return audio_send_queue_pre(audio, &cmd, sizeof(cmd));
-}
-
-static int audio_enable_tx_agc(struct audio_in *audio, int enable)
-{
-	if (audio->tx_agc_enable != enable) {
-		audio->tx_agc_enable = enable;
-		if (audio->running)
-			audio_dsp_set_tx_agc(audio);
-	}
-	return 0;
-}
-
-static int audio_dsp_set_ns(struct audio_in *audio)
-{
-	audpreproc_cmd_cfg_ns_params cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-
-	audio->ns_cfg.cmd_id = AUDPREPROC_CMD_CFG_NS_PARAMS;
-
-	if (audio->ns_enable) {
-		/* cmd.ec_mode_new is fixed as 0x0064 when enable
-		 * from sample code */
-		audio->ns_cfg.ec_mode_new =
-			AUDPREPROC_CMD_EC_MODE_NEW_NS_ENA |
-			AUDPREPROC_CMD_EC_MODE_NEW_HB_ENA |
-			AUDPREPROC_CMD_EC_MODE_NEW_VA_ENA;
-	} else {
-		audio->ns_cfg.ec_mode_new =
-			AUDPREPROC_CMD_EC_MODE_NEW_NLMS_DIS |
-			AUDPREPROC_CMD_EC_MODE_NEW_DES_DIS |
-			AUDPREPROC_CMD_EC_MODE_NEW_NS_DIS |
-			AUDPREPROC_CMD_EC_MODE_NEW_CNI_DIS |
-			AUDPREPROC_CMD_EC_MODE_NEW_NLES_DIS |
-			AUDPREPROC_CMD_EC_MODE_NEW_HB_DIS |
-			AUDPREPROC_CMD_EC_MODE_NEW_VA_DIS |
-			AUDPREPROC_CMD_EC_MODE_NEW_PCD_DIS |
-			AUDPREPROC_CMD_EC_MODE_NEW_FEHI_DIS |
-			AUDPREPROC_CMD_EC_MODE_NEW_NEHI_DIS |
-			AUDPREPROC_CMD_EC_MODE_NEW_NLPP_DIS |
-			AUDPREPROC_CMD_EC_MODE_NEW_FNE_DIS |
-			AUDPREPROC_CMD_EC_MODE_NEW_PRENLMS_DIS;
-	}
-	cmd = audio->ns_cfg;
-
-	return audio_send_queue_pre(audio, &cmd, sizeof(cmd));
-}
-
-static int audio_enable_ns(struct audio_in *audio, int enable)
-{
-	if (audio->ns_enable != enable) {
-		audio->ns_enable = enable;
-		if (audio->running)
-			audio_dsp_set_ns(audio);
-	}
-	return 0;
-}
-
-static int audio_dsp_set_iir(struct audio_in *audio)
-{
-	audpreproc_cmd_cfg_iir_tuning_filter_params cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-
-	audio->iir_cfg.cmd_id = AUDPREPROC_CMD_CFG_IIR_TUNING_FILTER_PARAMS;
-
-	if (audio->iir_enable)
-		/* cmd.active_flag is 0xFFFF from sample code but 0x0001 here */
-		audio->iir_cfg.active_flag = AUDPREPROC_CMD_IIR_ACTIVE_FLAG_ENA;
-	else
-		audio->iir_cfg.active_flag = AUDPREPROC_CMD_IIR_ACTIVE_FLAG_DIS;
-
-	cmd = audio->iir_cfg;
-
-	return audio_send_queue_pre(audio, &cmd, sizeof(cmd));
-}
-
-static int audio_enable_iir(struct audio_in *audio, int enable)
-{
-	if (audio->iir_enable != enable) {
-		audio->iir_enable = enable;
-		if (audio->running)
-			audio_dsp_set_iir(audio);
-	}
-	return 0;
-}
-
-static int audio_in_dsp_enable(struct audio_in *audio, int enable)
-{
-	audrec_cmd_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_CFG;
-	cmd.type_0 = enable ? AUDREC_CMD_TYPE_0_ENA : AUDREC_CMD_TYPE_0_DIS;
-	cmd.type_0 |= (AUDREC_CMD_TYPE_0_UPDATE | audio->type);
-	cmd.type_1 = 0;
-
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audio_in_encoder_config(struct audio_in *audio)
-{
-	audrec_cmd_arec0param_cfg cmd;
-	uint16_t *data = (void *) audio->data;
-	unsigned n;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_AREC0PARAM_CFG;
-	cmd.ptr_to_extpkt_buffer_msw = audio->phys >> 16;
-	cmd.ptr_to_extpkt_buffer_lsw = audio->phys;
-	cmd.buf_len = FRAME_NUM; /* Both WAV and AAC use 8 frames */
-	cmd.samp_rate_index = audio->samp_rate_index;
-	cmd.stereo_mode = audio->channel_mode; /* 0 for mono, 1 for stereo */
-
-	/* cmd.rec_quality is based on user set bit rate / sample rate /
-	 * channel
-	 */
-	cmd.rec_quality = audio->record_quality;
-
-	/* prepare buffer pointers:
-	 * Mono: 1024 samples + 4 halfword header
-	 * Stereo: 2048 samples + 4 halfword header
-	 * AAC
-	 * Mono/Stere: 768 + 4 halfword header
-	 */
-	for (n = 0; n < FRAME_NUM; n++) {
-		audio->in[n].data = data + 4;
-		if (audio->type == AUDREC_CMD_TYPE_0_INDEX_WAV)
-			data += (4 + (audio->channel_mode ? 2048 : 1024));
-		else if (audio->type == AUDREC_CMD_TYPE_0_INDEX_AAC)
-			data += (4 + 768);
-	}
-
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audio_dsp_read_buffer(struct audio_in *audio, uint32_t read_cnt)
-{
-	audrec_cmd_packet_ext_ptr cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_PACKET_EXT_PTR;
-	/* Both WAV and AAC use AUDREC_CMD_TYPE_0 */
-	cmd.type = AUDREC_CMD_TYPE_0;
-	cmd.curr_rec_count_msw = read_cnt >> 16;
-	cmd.curr_rec_count_lsw = read_cnt;
-
-	return audio_send_queue_recbs(audio, &cmd, sizeof(cmd));
-}
-
-/* ------------------- device --------------------- */
-
-static void audio_flush(struct audio_in *audio)
-{
-	int i;
-
-	audio->dsp_cnt = 0;
-	audio->in_head = 0;
-	audio->in_tail = 0;
-	audio->in_count = 0;
-	for (i = 0; i < FRAME_NUM; i++) {
-		audio->in[i].size = 0;
-		audio->in[i].read = 0;
-	}
-}
-
-static long audio_in_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct audio_in *audio = file->private_data;
-	int rc;
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		stats.byte_count = atomic_read(&audio->in_bytes);
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		rc = audio_in_enable(audio);
-		break;
-	case AUDIO_STOP:
-		rc = audio_in_disable(audio);
-		audio->stopped = 1;
-		break;
-	case AUDIO_FLUSH:
-		if (audio->stopped) {
-			/* Make sure we're stopped and we wake any threads
-			 * that might be blocked holding the read_lock.
-			 * While audio->stopped read threads will always
-			 * exit immediately.
-			 */
-			wake_up(&audio->wait);
-			mutex_lock(&audio->read_lock);
-			audio_flush(audio);
-			mutex_unlock(&audio->read_lock);
-		}
-	case AUDIO_SET_CONFIG: {
-		struct msm_audio_config cfg;
-		/* The below code is to make mutual exclusive between
-		 * AUDIO_SET_CONFIG and AUDIO_SET_STREAM_CONFIG.
-		 * Allow any one IOCTL.
-		 */
-		if (audio->buffer_cfg_ioctl == AUDIO_SET_STREAM_CONFIG) {
-			rc = -EINVAL;
-			break;
-		}
-		if (copy_from_user(&cfg, (void *) arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (cfg.channel_count == 1) {
-			cfg.channel_count = AUDREC_CMD_STEREO_MODE_MONO;
-		} else if (cfg.channel_count == 2) {
-			cfg.channel_count = AUDREC_CMD_STEREO_MODE_STEREO;
-		} else {
-			rc = -EINVAL;
-			break;
-		}
-
-		if (cfg.type == 0) {
-			cfg.type = AUDREC_CMD_TYPE_0_INDEX_WAV;
-		} else if (cfg.type == 1) {
-			cfg.type = AUDREC_CMD_TYPE_0_INDEX_AAC;
-		} else {
-			rc = -EINVAL;
-			break;
-		}
-		audio->samp_rate = convert_samp_rate(cfg.sample_rate);
-		audio->samp_rate_index =
-		  convert_dsp_samp_index(cfg.sample_rate);
-		audio->channel_mode = cfg.channel_count;
-		audio->buffer_size =
-				audio->channel_mode ? STEREO_DATA_SIZE
-							: MONO_DATA_SIZE;
-		audio->type = cfg.type;
-		audio->buffer_cfg_ioctl = AUDIO_SET_CONFIG;
-		rc = 0;
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config cfg;
-		cfg.buffer_size = audio->buffer_size;
-		cfg.buffer_count = FRAME_NUM;
-		cfg.sample_rate = convert_samp_index(audio->samp_rate);
-		if (audio->channel_mode == AUDREC_CMD_STEREO_MODE_MONO)
-			cfg.channel_count = 1;
-		else
-			cfg.channel_count = 2;
-		if (audio->type == AUDREC_CMD_TYPE_0_INDEX_WAV)
-			cfg.type = 0;
-		else
-			cfg.type = 1;
-		cfg.unused[0] = 0;
-		cfg.unused[1] = 0;
-		cfg.unused[2] = 0;
-		if (copy_to_user((void *) arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-	case AUDIO_GET_STREAM_CONFIG: {
-		struct msm_audio_stream_config cfg;
-		cfg.buffer_size = audio->buffer_size;
-		cfg.buffer_count = FRAME_NUM;
-		if (copy_to_user((void *)arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-	case AUDIO_SET_STREAM_CONFIG: {
-		struct msm_audio_stream_config cfg;
-		/* The below code is to make mutual exclusive between
-		 * AUDIO_SET_CONFIG and AUDIO_SET_STREAM_CONFIG.
-		 * Allow any one IOCTL.
-		 */
-		if (audio->buffer_cfg_ioctl == AUDIO_SET_CONFIG) {
-			rc = -EINVAL;
-			break;
-		}
-		if (copy_from_user(&cfg, (void *)arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		} else
-			rc = 0;
-		audio->buffer_size = cfg.buffer_size;
-		/* The IOCTL is only of AAC, set the encoder as AAC */
-		audio->type = 1;
-		audio->buffer_cfg_ioctl = AUDIO_SET_STREAM_CONFIG;
-		break;
-	}
-	case AUDIO_GET_AAC_ENC_CONFIG: {
-		struct msm_audio_aac_enc_config cfg;
-		if (audio->channel_mode == AUDREC_CMD_STEREO_MODE_MONO)
-			cfg.channels = 1;
-		else
-			cfg.channels = 2;
-		cfg.sample_rate = convert_samp_index(audio->samp_rate);
-		cfg.bit_rate = audio->bit_rate;
-		cfg.stream_format = AUDIO_AAC_FORMAT_RAW;
-		if (copy_to_user((void *)arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-	case AUDIO_SET_AAC_ENC_CONFIG: {
-		struct msm_audio_aac_enc_config cfg;
-		unsigned int record_quality;
-		if (copy_from_user(&cfg, (void *)arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (cfg.stream_format != AUDIO_AAC_FORMAT_RAW) {
-			MM_ERR("unsupported AAC format\n");
-			rc = -EINVAL;
-			break;
-		}
-		record_quality = bitrate_to_record_quality(cfg.sample_rate,
-					cfg.channels, cfg.bit_rate);
-		/* Range of Record Quality Supported by DSP, Q12 format */
-		if ((record_quality < 0x800) || (record_quality > 0x4000)) {
-			MM_ERR("Unsupported bit rate \n");
-			rc = -EINVAL;
-			break;
-		}
-		if (cfg.channels == 1) {
-			cfg.channels = AUDREC_CMD_STEREO_MODE_MONO;
-		} else if (cfg.channels == 2) {
-			cfg.channels = AUDREC_CMD_STEREO_MODE_STEREO;
-		} else {
-			rc = -EINVAL;
-			break;
-		}
-		audio->samp_rate = convert_samp_rate(cfg.sample_rate);
-		audio->samp_rate_index =
-		  convert_dsp_samp_index(cfg.sample_rate);
-		audio->channel_mode = cfg.channels;
-		audio->bit_rate = cfg.bit_rate;
-		audio->record_quality = record_quality;
-		MM_DBG(" Record Quality = 0x%8x \n", audio->record_quality);
-		rc = 0;
-		break;
-	}
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static ssize_t audio_in_read(struct file *file,
-				char __user *buf,
-				size_t count, loff_t *pos)
-{
-	struct audio_in *audio = file->private_data;
-	unsigned long flags;
-	const char __user *start = buf;
-	void *data;
-	uint32_t index;
-	uint32_t size;
-	int rc = 0;
-
-	mutex_lock(&audio->read_lock);
-	while (count > 0) {
-		rc = wait_event_interruptible(
-			audio->wait, (audio->in_count > 0) || audio->stopped);
-		if (rc < 0)
-			break;
-
-		if (audio->stopped && !audio->in_count) {
-			rc = 0;/* End of File */
-			break;
-		}
-
-		index = audio->in_tail;
-		data = (uint8_t *) audio->in[index].data;
-		size = audio->in[index].size;
-		if (count >= size) {
-			/* order the reads on the buffer */
-			dma_coherent_post_ops();
-			if (copy_to_user(buf, data, size)) {
-				rc = -EFAULT;
-				break;
-			}
-			spin_lock_irqsave(&audio->dsp_lock, flags);
-			if (index != audio->in_tail) {
-			/* overrun -- data is invalid and we need to retry */
-				spin_unlock_irqrestore(&audio->dsp_lock, flags);
-				continue;
-			}
-			audio->in[index].size = 0;
-			audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
-			audio->in_count--;
-			spin_unlock_irqrestore(&audio->dsp_lock, flags);
-			count -= size;
-			buf += size;
-		} else {
-			MM_ERR("short read\n");
-			break;
-		}
-		if (audio->type == AUDREC_CMD_TYPE_0_INDEX_AAC)
-			break; /* AAC only read one frame */
-	}
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		return buf - start;
-
-	return rc;
-}
-
-static ssize_t audio_in_write(struct file *file,
-				const char __user *buf,
-				size_t count, loff_t *pos)
-{
-	return -EINVAL;
-}
-
-static int audio_in_release(struct inode *inode, struct file *file)
-{
-	struct audio_in *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	audio_in_disable(audio);
-	audio_flush(audio);
-	msm_adsp_put(audio->audrec);
-	msm_adsp_put(audio->audpre);
-	audio->audrec = NULL;
-	audio->audpre = NULL;
-	audio->opened = 0;
-	mutex_unlock(&audio->lock);
-	return 0;
-}
-
-struct audio_in the_audio_in;
-
-static int audio_in_open(struct inode *inode, struct file *file)
-{
-	struct audio_in *audio = &the_audio_in;
-	int rc;
-
-	mutex_lock(&audio->lock);
-	if (audio->opened) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	/* Settings will be re-config at AUDIO_SET_CONFIG,
-	 * but at least we need to have initial config
-	 */
-	audio->samp_rate = RPC_AUD_DEF_SAMPLE_RATE_11025;
-	audio->samp_rate_index = AUDREC_CMD_SAMP_RATE_INDX_11025;
-	audio->channel_mode = AUDREC_CMD_STEREO_MODE_MONO;
-	audio->buffer_size = MONO_DATA_SIZE;
-	audio->type = AUDREC_CMD_TYPE_0_INDEX_WAV;
-
-	/* For AAC, bit rate hard coded, default settings is
-	 * sample rate (11025) x channel count (1) x recording quality (1.75)
-	 * = 19293 bps  */
-	audio->bit_rate = 19293;
-	audio->record_quality = 0x1c00;
-
-	rc = audmgr_open(&audio->audmgr);
-	if (rc)
-		goto done;
-	rc = msm_adsp_get("AUDPREPROCTASK", &audio->audpre,
-				&audpre_adsp_ops, audio);
-	if (rc)
-		goto done;
-	rc = msm_adsp_get("AUDRECTASK", &audio->audrec,
-			   &audrec_adsp_ops, audio);
-	if (rc)
-		goto done;
-
-	audio->dsp_cnt = 0;
-	audio->stopped = 0;
-	audio->buffer_cfg_ioctl = 0; /* No valid ioctl set */
-
-	audio_flush(audio);
-
-	file->private_data = audio;
-	audio->opened = 1;
-	rc = 0;
-done:
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static long audpre_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct audio_in *audio = file->private_data;
-	int rc = 0, enable;
-	uint16_t enable_mask;
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_ENABLE_AUDPRE:
-		if (copy_from_user(&enable_mask, (void *) arg,
-						sizeof(enable_mask))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		enable = (enable_mask & AGC_ENABLE) ? 1 : 0;
-		audio_enable_tx_agc(audio, enable);
-		enable = (enable_mask & NS_ENABLE) ? 1 : 0;
-		audio_enable_ns(audio, enable);
-		enable = (enable_mask & TX_IIR_ENABLE) ? 1 : 0;
-		audio_enable_iir(audio, enable);
-		break;
-
-	case AUDIO_SET_AGC:
-		if (copy_from_user(&audio->tx_agc_cfg, (void *) arg,
-						sizeof(audio->tx_agc_cfg)))
-			rc = -EFAULT;
-		break;
-
-	case AUDIO_SET_NS:
-		if (copy_from_user(&audio->ns_cfg, (void *) arg,
-						sizeof(audio->ns_cfg)))
-			rc = -EFAULT;
-		break;
-
-	case AUDIO_SET_TX_IIR:
-		if (copy_from_user(&audio->iir_cfg, (void *) arg,
-						sizeof(audio->iir_cfg)))
-			rc = -EFAULT;
-		break;
-
-	default:
-		rc = -EINVAL;
-	}
-
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static int audpre_open(struct inode *inode, struct file *file)
-{
-	struct audio_in *audio = &the_audio_in;
-
-	file->private_data = audio;
-
-	return 0;
-}
-
-static struct file_operations audio_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audio_in_open,
-	.release	= audio_in_release,
-	.read		= audio_in_read,
-	.write		= audio_in_write,
-	.unlocked_ioctl	= audio_in_ioctl,
-};
-
-struct miscdevice audio_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_pcm_in",
-	.fops	= &audio_fops,
-};
-
-static const struct file_operations audpre_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audpre_open,
-	.unlocked_ioctl	= audpre_ioctl,
-};
-
-struct miscdevice audpre_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_preproc_ctl",
-	.fops	= &audpre_fops,
-};
-
-static int __init audio_in_init(void)
-{
-	the_audio_in.data = dma_alloc_coherent(NULL, DMASZ,
-					       &the_audio_in.phys, GFP_KERNEL);
-	if (!the_audio_in.data) {
-		MM_ERR("Unable to allocate DMA buffer\n");
-		return -ENOMEM;
-	}
-
-	mutex_init(&the_audio_in.lock);
-	mutex_init(&the_audio_in.read_lock);
-	spin_lock_init(&the_audio_in.dsp_lock);
-	init_waitqueue_head(&the_audio_in.wait);
-	return misc_register(&audio_in_misc) || misc_register(&audpre_misc);
-}
-
-device_initcall(audio_in_init);
diff --git a/arch/arm/mach-msm/qdsp5/audio_lpa.c b/arch/arm/mach-msm/qdsp5/audio_lpa.c
deleted file mode 100644
index 7f0d68a..0000000
--- a/arch/arm/mach-msm/qdsp5/audio_lpa.c
+++ /dev/null
@@ -1,1520 +0,0 @@
-
-/* audio_lpa.c - low power audio driver
- *
- * Copyright (c) 2012, The Linux Foundation. All rights reserved.
- *
- * Based on the PCM decoder driver in arch/arm/mach-msm/qdsp5/audio_pcm.c
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- *
- * All source code in this file is licensed under the following license except
- * where indicated.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you can find it at http://www.fsf.org
- */
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/earlysuspend.h>
-#include <linux/msm_ion.h>
-#include <linux/list.h>
-#include <linux/slab.h>
-#include <linux/msm_audio.h>
-
-
-#include <mach/msm_adsp.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/qdsp5/qdsp5audppcmdi.h>
-#include <mach/qdsp5/qdsp5audppmsg.h>
-#include <mach/qdsp5/qdsp5audpp.h>
-#include <mach/qdsp5/qdsp5audplaycmdi.h>
-#include <mach/qdsp5/qdsp5audplaymsg.h>
-#include <mach/qdsp5/qdsp5rmtcmdi.h>
-#include <mach/debug_mm.h>
-#include <linux/memory_alloc.h>
-#include <mach/msm_memtypes.h>
-
-#include "audmgr.h"
-
-/* for queue ids - should be relative to module number*/
-#include "adsp.h"
-
-#define ADRV_STATUS_AIO_INTF 0x00000001
-#define ADRV_STATUS_OBUF_GIVEN 0x00000002
-#define ADRV_STATUS_IBUF_GIVEN 0x00000004
-#define ADRV_STATUS_FSYNC 0x00000008
-
-#define MSM_MAX_VOLUME 0x2000
-/* 17 added to avoid more deviation */
-#define MSM_VOLUME_STEP (MSM_MAX_VOLUME+17)
-#define MSM_VOLUME_FACTOR (10000)
-
-/* Size must be power of 2 */
-#define MAX_BUF 2
-#define BUFSZ (524288)
-
-#define AUDDEC_DEC_PCM 0
-
-/* Decoder status received from AUDPPTASK */
-#define  AUDPP_DEC_STATUS_SLEEP	0
-#define  AUDPP_DEC_STATUS_INIT  1
-#define  AUDPP_DEC_STATUS_CFG   2
-#define  AUDPP_DEC_STATUS_PLAY  3
-
-#define AUDPCM_EVENT_NUM 10 /* Default number of pre-allocated event packets */
-
-#define __CONTAINS(r, v, l) ({					\
-	typeof(r) __r = r;					\
-	typeof(v) __v = v;					\
-	typeof(v) __e = __v + l;				\
-	int res = ((__v >= __r->vaddr) &&			\
-		(__e <= __r->vaddr + __r->len));		\
-	res;							\
-})
-
-#define CONTAINS(r1, r2) ({					\
-	typeof(r2) __r2 = r2;					\
-	__CONTAINS(r1, __r2->vaddr, __r2->len);			\
-})
-
-#define IN_RANGE(r, v) ({					\
-	typeof(r) __r = r;					\
-	typeof(v) __vv = v;					\
-	int res = ((__vv >= __r->vaddr) &&			\
-		(__vv < (__r->vaddr + __r->len)));		\
-	res;							\
-})
-
-#define OVERLAPS(r1, r2) ({					\
-	typeof(r1) __r1 = r1;					\
-	typeof(r2) __r2 = r2;					\
-	typeof(__r2->vaddr) __v = __r2->vaddr;			\
-	typeof(__v) __e = __v + __r2->len - 1;			\
-	int res = (IN_RANGE(__r1, __v) || IN_RANGE(__r1, __e));	\
-	res;							\
-})
-
-struct audio;
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;		/* Input usage actual DSP produced PCM size  */
-	unsigned addr;
-};
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-struct audpcm_suspend_ctl {
-struct early_suspend node;
-struct audio *audio;
-};
-#endif
-
-struct audpcm_event {
-	struct list_head list;
-	int event_type;
-	union msm_audio_event_payload payload;
-};
-
-struct audlpa_ion_region {
-	struct list_head list;
-	struct ion_handle *handle;
-	int fd;
-	void *vaddr;
-	unsigned long paddr;
-	unsigned long kvaddr;
-	unsigned long len;
-	unsigned ref_cnt;
-};
-
-struct audpcm_buffer_node {
-	struct list_head list;
-	struct msm_audio_aio_buf buf;
-	unsigned long paddr;
-};
-
-struct audio {
-	struct buffer out[2];
-
-	spinlock_t dsp_lock;
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed; /* number of buffers the dsp is waiting for */
-	struct list_head out_queue; /* queue to retain output buffers */
-	atomic_t out_bytes;
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-
-	struct msm_adsp_module *audplay;
-
-	/* configuration to use on next enable */
-	uint32_t out_sample_rate;
-	uint32_t out_channel_mode;
-	uint32_t out_bits; /* bits per sample */
-
-	struct audmgr audmgr;
-
-	/* data allocated for various buffers */
-	char *data;
-	int32_t phys;
-	struct msm_mapped_buffer *map_v_write;
-
-	uint32_t drv_status;
-	int wflush; /* Write flush */
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped, cleared on flush */
-	int teos; /* valid only if tunnel mode & no data left for decoder */
-	int rmt_resource_released;
-	enum msm_aud_decoder_state dec_state; /* Represents decoder state */
-	int reserved; /* A byte is being reserved */
-	char rsv_byte; /* Handle odd length user data */
-
-	const char *module_name;
-	unsigned queue_id;
-
-	unsigned long volume;
-
-	uint16_t dec_id;
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	struct audpcm_suspend_ctl suspend_ctl;
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *dentry;
-#endif
-	wait_queue_head_t wait;
-	struct list_head free_event_queue;
-	struct list_head event_queue;
-	wait_queue_head_t event_wait;
-	spinlock_t event_queue_lock;
-	struct mutex get_event_lock;
-	int event_abort;
-
-	struct list_head ion_region_queue;
-	int buffer_count;
-	int buffer_size;
-	struct ion_client *client;
-};
-
-static int auddec_dsp_config(struct audio *audio, int enable);
-static void audpp_cmd_cfg_adec_params(struct audio *audio);
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg);
-static void audpcm_post_event(struct audio *audio, int type,
-	union msm_audio_event_payload payload);
-static unsigned long audlpa_ion_fixup(struct audio *audio, void *addr,
-	unsigned long len, int ref_up);
-static void audpcm_async_send_data(struct audio *audio,
-	unsigned needed);
-
-
-static int rmt_put_resource(struct audio *audio)
-{
-	struct aud_codec_config_cmd cmd;
-	unsigned short client_idx;
-
-	cmd.cmd_id = RM_CMD_AUD_CODEC_CFG;
-	cmd.client_id = RM_AUD_CLIENT_ID;
-	cmd.task_id = audio->dec_id;
-	cmd.enable = RMT_DISABLE;
-	cmd.dec_type = AUDDEC_DEC_PCM;
-	client_idx = ((cmd.client_id << 8) | cmd.task_id);
-
-	return put_adsp_resource(client_idx, &cmd, sizeof(cmd));
-}
-
-static int rmt_get_resource(struct audio *audio)
-{
-	struct aud_codec_config_cmd cmd;
-	unsigned short client_idx;
-
-	cmd.cmd_id = RM_CMD_AUD_CODEC_CFG;
-	cmd.client_id = RM_AUD_CLIENT_ID;
-	cmd.task_id = audio->dec_id;
-	cmd.enable = RMT_ENABLE;
-	cmd.dec_type = AUDDEC_DEC_PCM;
-	client_idx = ((cmd.client_id << 8) | cmd.task_id);
-
-	return get_adsp_resource(client_idx, &cmd, sizeof(cmd));
-}
-
-/* must be called with audio->lock held */
-static int audio_enable(struct audio *audio)
-{
-	struct audmgr_config cfg;
-	int rc;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled)
-		return 0;
-
-	if (audio->rmt_resource_released == 1) {
-		audio->rmt_resource_released = 0;
-		rc = rmt_get_resource(audio);
-		if (rc)
-			MM_ERR("ADSP resources are not available");
-	}
-
-	audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-
-	cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE;
-	cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000;
-	cfg.def_method = RPC_AUD_DEF_METHOD_PLAYBACK;
-	cfg.codec = RPC_AUD_DEF_CODEC_PCM;
-	cfg.snd_method = RPC_SND_METHOD_MIDI;
-
-	rc = audmgr_enable(&audio->audmgr, &cfg);
-	if (rc < 0) {
-		msm_adsp_dump(audio->audplay);
-		return rc;
-	}
-	if (msm_adsp_enable(audio->audplay)) {
-		MM_ERR("msm_adsp_enable(audplay) failed\n");
-		audmgr_disable(&audio->audmgr);
-		return -ENODEV;
-	}
-
-	if (audpp_enable(audio->dec_id, audio_dsp_event, audio)) {
-		MM_ERR("audpp_enable() failed\n");
-		msm_adsp_disable(audio->audplay);
-		audmgr_disable(&audio->audmgr);
-		return -ENODEV;
-	}
-
-	audio->enabled = 1;
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audio_disable(struct audio *audio)
-{
-	int rc = 0;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-		auddec_dsp_config(audio, 0);
-		rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-		if (rc == 0)
-			rc = -ETIMEDOUT;
-		else if (audio->dec_state != MSM_AUD_DECODER_STATE_CLOSE)
-			rc = -EFAULT;
-		else
-			rc = 0;
-		audio->stopped = 1;
-		wake_up(&audio->write_wait);
-		msm_adsp_disable(audio->audplay);
-		audpp_disable(audio->dec_id, audio);
-		rc = audmgr_disable(&audio->audmgr);
-		if (rc < 0)
-			msm_adsp_dump(audio->audplay);
-		audio->out_needed = 0;
-		rmt_put_resource(audio);
-		audio->rmt_resource_released = 1;
-	}
-	return rc;
-}
-
-/* ------------------- dsp --------------------- */
-static void audplay_dsp_event(void *data, unsigned id, size_t len,
-			      void (*getevent) (void *ptr, size_t len))
-{
-	struct audio *audio = data;
-	uint32_t msg[28];
-	getevent(msg, sizeof(msg));
-
-	MM_DBG("msg_id=%x\n", id);
-
-	switch (id) {
-	case AUDPLAY_MSG_DEC_NEEDS_DATA:
-		audpcm_async_send_data(audio, 1);
-		break;
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audplaytask)\n");
-		break;
-	default:
-		MM_ERR("unexpected message from decoder\n");
-		break;
-	}
-}
-
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg)
-{
-	struct audio *audio = private;
-
-	switch (id) {
-	case AUDPP_MSG_STATUS_MSG:{
-			unsigned status = msg[1];
-
-			switch (status) {
-			case AUDPP_DEC_STATUS_SLEEP: {
-				uint16_t reason = msg[2];
-				MM_DBG("decoder status: sleep reason =0x%04x\n",
-						reason);
-				if ((reason == AUDPP_MSG_REASON_MEM)
-						|| (reason ==
-						AUDPP_MSG_REASON_NODECODER)) {
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_FAILURE;
-					wake_up(&audio->wait);
-				} else if (reason == AUDPP_MSG_REASON_NONE) {
-					/* decoder is in disable state */
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_CLOSE;
-					wake_up(&audio->wait);
-				}
-				break;
-			}
-			case AUDPP_DEC_STATUS_INIT:
-				MM_DBG("decoder status: init\n");
-				audpp_cmd_cfg_adec_params(audio);
-				break;
-
-			case AUDPP_DEC_STATUS_CFG:
-				MM_DBG("decoder status: cfg\n");
-				break;
-			case AUDPP_DEC_STATUS_PLAY:
-				MM_DBG("decoder status: play\n");
-				audio->dec_state =
-					MSM_AUD_DECODER_STATE_SUCCESS;
-				wake_up(&audio->wait);
-				break;
-			default:
-				MM_ERR("unknown decoder status\n");
-				break;
-			}
-			break;
-		}
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_DBG("CFG_MSG ENABLE\n");
-			auddec_dsp_config(audio, 1);
-			audio->out_needed = 0;
-			audio->running = 1;
-			audpp_set_volume_and_pan(audio->dec_id, audio->volume,
-					0);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			MM_DBG("CFG_MSG DISABLE\n");
-			audio->running = 0;
-		} else {
-			MM_ERR("CFG_MSG %d?\n",	msg[0]);
-		}
-		break;
-	case AUDPP_MSG_FLUSH_ACK:
-		MM_DBG("FLUSH_ACK\n");
-		audio->wflush = 0;
-		wake_up(&audio->write_wait);
-		break;
-
-	case AUDPP_MSG_PCMDMAMISSED:
-		MM_DBG("PCMDMAMISSED\n");
-		audio->teos = 1;
-		wake_up(&audio->write_wait);
-		break;
-
-	default:
-		MM_ERR("UNKNOWN (%d)\n", id);
-	}
-
-}
-
-
-struct msm_adsp_ops audlpadec_adsp_ops = {
-	.event = audplay_dsp_event,
-};
-
-
-#define audplay_send_queue0(audio, cmd, len) \
-	msm_adsp_write(audio->audplay, audio->queue_id, \
-			cmd, len)
-
-static int auddec_dsp_config(struct audio *audio, int enable)
-{
-	u16 cfg_dec_cmd[AUDPP_CMD_CFG_DEC_TYPE_LEN / sizeof(unsigned short)];
-
-	memset(cfg_dec_cmd, 0, sizeof(cfg_dec_cmd));
-
-	cfg_dec_cmd[0] = AUDPP_CMD_CFG_DEC_TYPE;
-	if (enable)
-		cfg_dec_cmd[1 + audio->dec_id] = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_ENA_DEC_V | AUDDEC_DEC_PCM |
-				AUDPP_CMD_LPA_MODE;
-	else
-		cfg_dec_cmd[1 + audio->dec_id] = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_DIS_DEC_V;
-
-	return audpp_send_queue1(&cfg_dec_cmd, sizeof(cfg_dec_cmd));
-}
-
-static void audpp_cmd_cfg_adec_params(struct audio *audio)
-{
-	audpp_cmd_cfg_adec_params_wav cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_CMD_CFG_ADEC_PARAMS;
-	cmd.common.length = AUDPP_CMD_CFG_ADEC_PARAMS_WAV_LEN;
-	cmd.common.dec_id = audio->dec_id;
-	cmd.common.input_sampling_frequency = audio->out_sample_rate;
-	cmd.stereo_cfg = audio->out_channel_mode;
-	cmd.pcm_width = audio->out_bits;
-	cmd.sign = 0;
-	audpp_send_queue2(&cmd, sizeof(cmd));
-}
-static void audpcm_async_send_data(struct audio *audio, unsigned needed)
-{
-	unsigned long flags;
-
-	if (!audio->running)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-
-	if (needed && !audio->wflush) {
-		audio->out_needed = 1;
-		if (audio->drv_status & ADRV_STATUS_OBUF_GIVEN) {
-			/* pop one node out of queue */
-			union msm_audio_event_payload payload;
-			struct audpcm_buffer_node *used_buf;
-
-			MM_DBG("consumed\n");
-
-			BUG_ON(list_empty(&audio->out_queue));
-			used_buf = list_first_entry(&audio->out_queue,
-				struct audpcm_buffer_node, list);
-			list_del(&used_buf->list);
-			payload.aio_buf = used_buf->buf;
-			audpcm_post_event(audio, AUDIO_EVENT_WRITE_DONE,
-				payload);
-			kfree(used_buf);
-			audio->drv_status &= ~ADRV_STATUS_OBUF_GIVEN;
-		}
-	}
-	if (audio->out_needed) {
-		struct audpcm_buffer_node *next_buf;
-		audplay_cmd_bitstream_data_avail cmd;
-		if (!list_empty(&audio->out_queue)) {
-			next_buf = list_first_entry(&audio->out_queue,
-					struct audpcm_buffer_node, list);
-			MM_DBG("next_buf %p\n", next_buf);
-			if (next_buf) {
-				MM_DBG("next buf phy %lx len %d\n",
-				next_buf->paddr, next_buf->buf.data_len);
-
-				cmd.cmd_id = AUDPLAY_CMD_BITSTREAM_DATA_AVAIL;
-				if (next_buf->buf.data_len)
-					cmd.decoder_id = audio->dec_id;
-				else {
-					cmd.decoder_id = -1;
-					MM_DBG("input EOS signaled\n");
-				}
-				cmd.buf_ptr	= (unsigned) next_buf->paddr;
-				cmd.buf_size = next_buf->buf.data_len >> 1;
-				cmd.partition_number	= 0;
-				/* complete writes to the input buffer */
-				wmb();
-				audplay_send_queue0(audio, &cmd, sizeof(cmd));
-				audio->out_needed = 0;
-				audio->drv_status |= ADRV_STATUS_OBUF_GIVEN;
-			}
-		}
-	}
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-static void audpcm_async_flush(struct audio *audio)
-{
-	struct audpcm_buffer_node *buf_node;
-	struct list_head *ptr, *next;
-	union msm_audio_event_payload payload;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	list_for_each_safe(ptr, next, &audio->out_queue) {
-		buf_node = list_entry(ptr, struct audpcm_buffer_node, list);
-		list_del(&buf_node->list);
-		payload.aio_buf = buf_node->buf;
-		audpcm_post_event(audio, AUDIO_EVENT_WRITE_DONE,
-				payload);
-		kfree(buf_node);
-	}
-	audio->drv_status &= ~ADRV_STATUS_OBUF_GIVEN;
-	audio->out_needed = 0;
-	atomic_set(&audio->out_bytes, 0);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-static void audio_ioport_reset(struct audio *audio)
-{
-	if (audio->drv_status & ADRV_STATUS_AIO_INTF) {
-		/* If fsync is in progress, make sure
-		 * return value of fsync indicates
-		 * abort due to flush
-		 */
-		if (audio->drv_status & ADRV_STATUS_FSYNC) {
-			MM_DBG("fsync in progress\n");
-			wake_up(&audio->write_wait);
-			mutex_lock(&audio->write_lock);
-			audpcm_async_flush(audio);
-			mutex_unlock(&audio->write_lock);
-		} else
-			audpcm_async_flush(audio);
-	} else {
-		/* Make sure read/write thread are free from
-		 * sleep and knowing that system is not able
-		 * to process io request at the moment
-		 */
-		wake_up(&audio->write_wait);
-		mutex_lock(&audio->write_lock);
-		audpcm_async_flush(audio);
-		mutex_unlock(&audio->write_lock);
-	}
-}
-
-static int audpcm_events_pending(struct audio *audio)
-{
-	unsigned long flags;
-	int empty;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	empty = !list_empty(&audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	return empty || audio->event_abort;
-}
-
-static void audpcm_reset_event_queue(struct audio *audio)
-{
-	unsigned long flags;
-	struct audpcm_event *drv_evt;
-	struct list_head *ptr, *next;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	list_for_each_safe(ptr, next, &audio->event_queue) {
-		drv_evt = list_first_entry(&audio->event_queue,
-			struct audpcm_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	list_for_each_safe(ptr, next, &audio->free_event_queue) {
-		drv_evt = list_first_entry(&audio->free_event_queue,
-			struct audpcm_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	return;
-}
-
-static long audpcm_process_event_req(struct audio *audio, void __user *arg)
-{
-	long rc;
-	struct msm_audio_event usr_evt;
-	struct audpcm_event *drv_evt = NULL;
-	int timeout;
-	unsigned long flags;
-
-	if (copy_from_user(&usr_evt, arg, sizeof(struct msm_audio_event)))
-		return -EFAULT;
-
-	timeout = (int) usr_evt.timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(
-			audio->event_wait, audpcm_events_pending(audio),
-			msecs_to_jiffies(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(
-			audio->event_wait, audpcm_events_pending(audio));
-	}
-
-	if (rc < 0)
-		return rc;
-
-	if (audio->event_abort) {
-		audio->event_abort = 0;
-		return -ENODEV;
-	}
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	if (!list_empty(&audio->event_queue)) {
-		drv_evt = list_first_entry(&audio->event_queue,
-			struct audpcm_event, list);
-		list_del(&drv_evt->list);
-	}
-	if (drv_evt) {
-		usr_evt.event_type = drv_evt->event_type;
-		usr_evt.event_payload = drv_evt->payload;
-		list_add_tail(&drv_evt->list, &audio->free_event_queue);
-	} else
-		rc = -1;
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	if (drv_evt && drv_evt->event_type == AUDIO_EVENT_WRITE_DONE) {
-		mutex_lock(&audio->lock);
-		audlpa_ion_fixup(audio, drv_evt->payload.aio_buf.buf_addr,
-				  drv_evt->payload.aio_buf.buf_len, 0);
-		mutex_unlock(&audio->lock);
-	}
-	if (!rc && copy_to_user(arg, &usr_evt, sizeof(usr_evt)))
-		rc = -EFAULT;
-
-	return rc;
-}
-
-static int audlpa_ion_check(struct audio *audio,
-		void *vaddr, unsigned long len)
-{
-	struct audlpa_ion_region *region_elt;
-	struct audlpa_ion_region t = {.vaddr = vaddr, .len = len };
-
-	list_for_each_entry(region_elt, &audio->ion_region_queue, list) {
-		if (CONTAINS(region_elt, &t) || CONTAINS(&t, region_elt) ||
-		    OVERLAPS(region_elt, &t)) {
-			MM_ERR("[%p]:region (vaddr %p len %ld)"
-				" clashes with registered region"
-				" (vaddr %p paddr %p len %ld)\n",
-				audio, vaddr, len,
-				region_elt->vaddr,
-				(void *)region_elt->paddr, region_elt->len);
-			return -EINVAL;
-		}
-	}
-
-	return 0;
-}
-static int audlpa_ion_add(struct audio *audio,
-			struct msm_audio_ion_info *info)
-{
-	ion_phys_addr_t paddr;
-	size_t len;
-	unsigned long kvaddr;
-	struct audlpa_ion_region *region;
-	int rc = -EINVAL;
-	struct ion_handle *handle;
-	unsigned long ionflag;
-
-	MM_ERR("\n"); /* Macro prints the file name and function */
-	region = kmalloc(sizeof(*region), GFP_KERNEL);
-
-	if (!region) {
-		rc = -ENOMEM;
-		goto end;
-	}
-	handle = ion_import_dma_buf(audio->client, info->fd);
-	if (IS_ERR_OR_NULL(handle)) {
-		pr_err("%s: could not get handle of the given fd\n", __func__);
-		goto import_error;
-	}
-	rc = ion_handle_get_flags(audio->client, handle, &ionflag);
-	if (rc) {
-		pr_err("%s: could not get flags for the handle\n", __func__);
-		goto flag_error;
-	}
-	kvaddr = (unsigned long)ion_map_kernel(audio->client, handle);
-	if (IS_ERR_OR_NULL((void *)kvaddr)) {
-		pr_err("%s: could not get virtual address\n", __func__);
-		goto map_error;
-	}
-	rc = ion_phys(audio->client, handle, &paddr, &len);
-	if (rc) {
-		pr_err("%s: could not get physical address\n", __func__);
-		goto ion_error;
-	}
-	rc = audlpa_ion_check(audio, info->vaddr, len);
-	if (rc < 0) {
-		MM_ERR("audpcm_ion_check failed\n");
-		goto ion_error;
-	}
-	region->handle = handle;
-	region->vaddr = info->vaddr;
-	region->fd = info->fd;
-	region->paddr = paddr;
-	region->kvaddr = kvaddr;
-	region->len = len;
-	region->ref_cnt = 0;
-	MM_DBG("[%p]:add region paddr %lx vaddr %p, len %lu kvaddr %lx\n",
-		audio, region->paddr, region->vaddr,
-		region->len, region->kvaddr);
-	list_add_tail(&region->list, &audio->ion_region_queue);
-
-	return rc;
-
-ion_error:
-	ion_unmap_kernel(audio->client, handle);
-map_error:
-flag_error:
-	ion_free(audio->client, handle);
-import_error:
-	kfree(region);
-end:
-	return rc;
-}
-
-static int audlpa_ion_remove(struct audio *audio,
-			struct msm_audio_ion_info *info)
-{
-	struct audlpa_ion_region *region;
-	struct list_head *ptr, *next;
-	int rc = -EINVAL;
-
-	list_for_each_safe(ptr, next, &audio->ion_region_queue) {
-		region = list_entry(ptr, struct audlpa_ion_region, list);
-
-		if (region != NULL && (region->fd == info->fd) &&
-		    (region->vaddr == info->vaddr)) {
-			if (region->ref_cnt) {
-				MM_DBG("%s[%p]:region %p in use ref_cnt %d\n",
-					__func__, audio, region,
-					region->ref_cnt);
-				break;
-			}
-			MM_DBG("remove region fd %d vaddr %p\n",
-				info->fd, info->vaddr);
-			list_del(&region->list);
-			ion_unmap_kernel(audio->client, region->handle);
-			ion_free(audio->client, region->handle);
-			kfree(region);
-			rc = 0;
-			break;
-		}
-	}
-
-	return rc;
-}
-
-static int audlpa_ion_lookup_vaddr(struct audio *audio, void *addr,
-			unsigned long len, struct audlpa_ion_region **region)
-{
-	struct audlpa_ion_region *region_elt;
-	int match_count = 0;
-	*region = NULL;
-
-	/* returns physical address or zero */
-	list_for_each_entry(region_elt, &audio->ion_region_queue, list) {
-		if (addr >= region_elt->vaddr &&
-		    addr < region_elt->vaddr + region_elt->len &&
-		    addr + len <= region_elt->vaddr + region_elt->len) {
-			/* offset since we could pass vaddr inside a registerd
-			 * ion buffer
-			 */
-
-			match_count++;
-			if (!*region)
-				*region = region_elt;
-		}
-	}
-
-	if (match_count > 1) {
-		MM_ERR("%s[%p]:multiple hits for vaddr %p, len %ld\n",
-			 __func__, audio, addr, len);
-		list_for_each_entry(region_elt, &audio->ion_region_queue,
-					list) {
-			if (addr >= region_elt->vaddr &&
-			addr < region_elt->vaddr + region_elt->len &&
-			addr + len <= region_elt->vaddr + region_elt->len)
-					MM_ERR("\t%s[%p]:%p, %ld --> %p\n",
-						__func__, audio,
-						region_elt->vaddr,
-						region_elt->len,
-						(void *)region_elt->paddr);
-		}
-	}
-	return *region ? 0 : -1;
-}
-static unsigned long audlpa_ion_fixup(struct audio *audio, void *addr,
-		    unsigned long len, int ref_up)
-{
-	struct audlpa_ion_region *region;
-	unsigned long paddr;
-	int ret;
-
-	ret = audlpa_ion_lookup_vaddr(audio, addr, len, &region);
-	if (ret) {
-		MM_ERR("%s[%p]:lookup (%p, %ld) failed\n",
-			__func__, audio, addr, len);
-		return 0;
-	}
-	if (ref_up)
-		region->ref_cnt++;
-	else
-		region->ref_cnt--;
-	MM_DBG("found region %p ref_cnt %d\n", region, region->ref_cnt);
-	paddr = region->paddr + (addr - region->vaddr);
-	return paddr;
-}
-
-/* audio -> lock must be held at this point */
-static int audlpa_aio_buf_add(struct audio *audio, unsigned dir,
-	void __user *arg)
-{
-	unsigned long flags;
-	struct audpcm_buffer_node *buf_node;
-
-	buf_node = kmalloc(sizeof(*buf_node), GFP_KERNEL);
-
-	if (!buf_node)
-		return -ENOMEM;
-
-	if (copy_from_user(&buf_node->buf, arg, sizeof(buf_node->buf))) {
-		kfree(buf_node);
-		return -EFAULT;
-	}
-
-	MM_DBG("node %p dir %x buf_addr %p buf_len %d data_len"
-			"%d\n", buf_node, dir,
-			buf_node->buf.buf_addr, buf_node->buf.buf_len,
-			buf_node->buf.data_len);
-
-	buf_node->paddr = audlpa_ion_fixup(
-		audio, buf_node->buf.buf_addr,
-		buf_node->buf.buf_len, 1);
-	if (dir) {
-		/* write */
-		if (!buf_node->paddr ||
-		    (buf_node->paddr & 0x1) ||
-		    (buf_node->buf.data_len & 0x1)) {
-			kfree(buf_node);
-			return -EINVAL;
-		}
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		list_add_tail(&buf_node->list, &audio->out_queue);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		audpcm_async_send_data(audio, 0);
-	}
-	MM_DBG("Add buf_node %p paddr %lx\n", buf_node, buf_node->paddr);
-
-	return 0;
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = 0;
-
-	MM_DBG("cmd = %d\n", cmd);
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		stats.byte_count = audpp_avsync_byte_count(audio->dec_id);
-		stats.sample_count = audpp_avsync_sample_count(audio->dec_id);
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-	if (cmd == AUDIO_SET_VOLUME) {
-		unsigned long flags;
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-
-		audio->volume = MSM_VOLUME_STEP * arg;
-		audio->volume /= MSM_VOLUME_FACTOR;
-
-		if (audio->volume > MSM_MAX_VOLUME)
-			audio->volume = MSM_MAX_VOLUME;
-
-		if (audio->running)
-			audpp_set_volume_and_pan(audio->dec_id,
-			audio->volume, 0);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		return 0;
-	}
-	if (cmd == AUDIO_GET_EVENT) {
-		MM_DBG("AUDIO_GET_EVENT\n");
-		if (mutex_trylock(&audio->get_event_lock)) {
-			rc = audpcm_process_event_req(audio,
-				(void __user *) arg);
-			mutex_unlock(&audio->get_event_lock);
-		} else
-			rc = -EBUSY;
-		return rc;
-	}
-
-	if (cmd == AUDIO_ABORT_GET_EVENT) {
-		audio->event_abort = 1;
-		wake_up(&audio->event_wait);
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		MM_DBG("AUDIO_START\n");
-		rc = audio_enable(audio);
-		if (!rc) {
-			rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-			MM_INFO("dec_state %d rc = %d\n", audio->dec_state, rc);
-
-			if (audio->dec_state != MSM_AUD_DECODER_STATE_SUCCESS)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		break;
-	case AUDIO_STOP:
-		MM_DBG("AUDIO_STOP\n");
-		rc = audio_disable(audio);
-		audio_ioport_reset(audio);
-		audio->stopped = 0;
-		break;
-	case AUDIO_FLUSH:
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->wflush = 1;
-		audio_ioport_reset(audio);
-		if (audio->running) {
-			audpp_flush(audio->dec_id);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->wflush = 0;
-		}
-		break;
-
-	case AUDIO_SET_CONFIG: {
-		struct msm_audio_config config;
-		if (copy_from_user(&config, (void *) arg, sizeof(config))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (config.channel_count == 1) {
-			config.channel_count = AUDPP_CMD_PCM_INTF_MONO_V;
-		} else if (config.channel_count == 2) {
-			config.channel_count = AUDPP_CMD_PCM_INTF_STEREO_V;
-		} else {
-			rc = -EINVAL;
-			break;
-		}
-		if (config.bits == 8)
-			config.bits = AUDPP_CMD_WAV_PCM_WIDTH_8;
-		else if (config.bits == 16)
-			config.bits = AUDPP_CMD_WAV_PCM_WIDTH_16;
-		else {
-			rc = -EINVAL;
-			break;
-		}
-		audio->out_sample_rate = config.sample_rate;
-		audio->out_channel_mode = config.channel_count;
-		audio->out_bits = config.bits;
-		audio->buffer_count = config.buffer_count;
-		audio->buffer_size = config.buffer_size;
-		MM_DBG("AUDIO_SET_CONFIG\n");
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config config;
-		config.buffer_count = audio->buffer_count;
-		config.buffer_size = audio->buffer_size;
-		config.sample_rate = audio->out_sample_rate;
-		if (audio->out_channel_mode == AUDPP_CMD_PCM_INTF_MONO_V)
-			config.channel_count = 1;
-		else
-			config.channel_count = 2;
-		if (audio->out_bits == AUDPP_CMD_WAV_PCM_WIDTH_8)
-			config.bits = 8;
-		else if (audio->out_bits == AUDPP_CMD_WAV_PCM_WIDTH_16)
-			config.bits = 16;
-		else
-			config.bits = 16;
-		config.unused[0] = 0;
-		config.unused[1] = 0;
-
-		if (copy_to_user((void *) arg, &config, sizeof(config)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		MM_DBG("AUDIO_GET_CONFIG\n");
-		break;
-	}
-
-
-	case AUDIO_PAUSE:
-		MM_DBG("AUDIO_PAUSE %ld\n", arg);
-		rc = audpp_pause(audio->dec_id, (int) arg);
-		break;
-
-	case AUDIO_REGISTER_ION: {
-		struct msm_audio_ion_info info;
-		MM_ERR("AUDIO_REGISTER_ION\n");
-			if (copy_from_user(&info, (void *) arg, sizeof(info)))
-				rc = -EFAULT;
-			else
-				rc = audlpa_ion_add(audio, &info);
-			break;
-		}
-
-	case AUDIO_DEREGISTER_ION: {
-		struct msm_audio_ion_info info;
-		MM_ERR("AUDIO_DEREGISTER_ION\n");
-			if (copy_from_user(&info, (void *) arg, sizeof(info)))
-				rc = -EFAULT;
-			else
-				rc = audlpa_ion_remove(audio, &info);
-			break;
-		}
-
-	case AUDIO_ASYNC_WRITE:
-		if (audio->drv_status & ADRV_STATUS_FSYNC)
-			rc = -EBUSY;
-		else
-			rc = audlpa_aio_buf_add(audio, 1, (void __user *) arg);
-		break;
-
-	case AUDIO_ASYNC_READ:
-		MM_ERR("AUDIO_ASYNC_READ not supported\n");
-		rc = -EPERM;
-		break;
-
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-/* Only useful in tunnel-mode */
-int audlpa_async_fsync(struct audio *audio)
-{
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	/* Blocking client sends more data */
-	mutex_lock(&audio->lock);
-	audio->drv_status |= ADRV_STATUS_FSYNC;
-	mutex_unlock(&audio->lock);
-
-	mutex_lock(&audio->write_lock);
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->teos && audio->out_needed &&
-		list_empty(&audio->out_queue))
-		|| audio->wflush || audio->stopped);
-
-	if (audio->stopped || audio->wflush)
-		rc = -EBUSY;
-
-	mutex_unlock(&audio->write_lock);
-	mutex_lock(&audio->lock);
-	audio->drv_status &= ~ADRV_STATUS_FSYNC;
-	mutex_unlock(&audio->lock);
-
-	return rc;
-}
-
-int audlpa_sync_fsync(struct audio *audio)
-{
-	struct buffer *frame;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(!audio->out[0].used &&
-		!audio->out[1].used &&
-		audio->out_needed) || audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (audio->reserved) {
-		MM_DBG("send reserved byte\n");
-		frame = audio->out + audio->out_tail;
-		((char *) frame->data)[0] = audio->rsv_byte;
-		((char *) frame->data)[1] = 0;
-		frame->used = 2;
-		audpcm_async_send_data(audio, 0);
-
-		rc = wait_event_interruptible(audio->write_wait,
-			(!audio->out[0].used &&
-			!audio->out[1].used &&
-			audio->out_needed) || audio->wflush);
-
-		if (rc < 0)
-			goto done;
-		else if (audio->wflush) {
-			rc = -EBUSY;
-			goto done;
-		}
-	}
-
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		audio->teos || audio->wflush);
-
-	if (audio->wflush)
-		rc = -EBUSY;
-
-done:
-	mutex_unlock(&audio->write_lock);
-	return rc;
-}
-
-int audlpa_fsync(struct file *file, loff_t a, loff_t b,
-	int datasync)
-{
-	struct audio *audio = file->private_data;
-
-	if (!audio->running)
-		return -EINVAL;
-
-	return audlpa_async_fsync(audio);
-}
-
-static void audpcm_reset_ion_region(struct audio *audio)
-{
-	struct audlpa_ion_region *region;
-	struct list_head *ptr, *next;
-
-	list_for_each_safe(ptr, next, &audio->ion_region_queue) {
-		region = list_entry(ptr, struct audlpa_ion_region, list);
-		list_del(&region->list);
-		ion_unmap_kernel(audio->client, region->handle);
-		ion_free(audio->client, region->handle);
-		kfree(region);
-	}
-
-	return;
-}
-static int audio_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	MM_DBG("audio instance 0x%08x freeing\n", (int)audio);
-	mutex_lock(&audio->lock);
-	audio_disable(audio);
-	if (audio->rmt_resource_released == 0)
-		rmt_put_resource(audio);
-	audpcm_async_flush(audio);
-	audpcm_reset_ion_region(audio);
-
-	msm_adsp_put(audio->audplay);
-	audpp_adec_free(audio->dec_id);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	unregister_early_suspend(&audio->suspend_ctl.node);
-#endif
-	audio->opened = 0;
-	audio->event_abort = 1;
-	wake_up(&audio->event_wait);
-	audpcm_reset_event_queue(audio);
-	mutex_unlock(&audio->lock);
-#ifdef CONFIG_DEBUG_FS
-	if (audio->dentry)
-		debugfs_remove(audio->dentry);
-#endif
-	ion_client_destroy(audio->client);
-	kfree(audio);
-	return 0;
-}
-
-static void audpcm_post_event(struct audio *audio, int type,
-	union msm_audio_event_payload payload)
-{
-	struct audpcm_event *e_node = NULL;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-
-	if (!list_empty(&audio->free_event_queue)) {
-		e_node = list_first_entry(&audio->free_event_queue,
-			struct audpcm_event, list);
-		list_del(&e_node->list);
-	} else {
-		e_node = kmalloc(sizeof(struct audpcm_event), GFP_ATOMIC);
-		if (!e_node) {
-			MM_ERR("No mem to post event %d\n", type);
-			spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-			return;
-		}
-	}
-
-	e_node->event_type = type;
-	e_node->payload = payload;
-
-	list_add_tail(&e_node->list, &audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	wake_up(&audio->event_wait);
-}
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audpcm_suspend(struct early_suspend *h)
-{
-	struct audpcm_suspend_ctl *ctl =
-		container_of(h, struct audpcm_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audpcm_post_event(ctl->audio, AUDIO_EVENT_SUSPEND, payload);
-}
-
-static void audpcm_resume(struct early_suspend *h)
-{
-	struct audpcm_suspend_ctl *ctl =
-		container_of(h, struct audpcm_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audpcm_post_event(ctl->audio, AUDIO_EVENT_RESUME, payload);
-}
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-static ssize_t audpcm_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static ssize_t audpcm_debug_read(struct file *file, char __user *buf,
-			  size_t count, loff_t *ppos)
-{
-	const int debug_bufmax = 4096;
-	static char buffer[4096];
-	int n = 0;
-	struct audio *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	n = scnprintf(buffer, debug_bufmax, "opened %d\n", audio->opened);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "enabled %d\n", audio->enabled);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "stopped %d\n", audio->stopped);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_buf_sz %d\n", audio->out[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "volume %lx\n", audio->volume);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "sample rate %d\n", audio->out_sample_rate);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-		"channel mode %d\n", audio->out_channel_mode);
-	mutex_unlock(&audio->lock);
-	/* Following variables are only useful for debugging when
-	 * when playback halts unexpectedly. Thus, no mutual exclusion
-	 * enforced
-	 */
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "wflush %d\n", audio->wflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "running %d\n", audio->running);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				"dec state %d\n", audio->dec_state);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_needed %d\n", audio->out_needed);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_head %d\n", audio->out_head);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_tail %d\n", audio->out_tail);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out[0].used %d\n", audio->out[0].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out[1].used %d\n", audio->out[1].used);
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations audpcm_debug_fops = {
-	.read = audpcm_debug_read,
-	.open = audpcm_debug_open,
-};
-#endif
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = NULL;
-	int rc, i, dec_attrb, decid;
-	struct audpcm_event *e_node = NULL;
-
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_lpa_" + 5];
-#endif
-
-	/* Allocate audio instance, set to zero */
-	audio = kzalloc(sizeof(struct audio), GFP_KERNEL);
-	if (!audio) {
-		MM_ERR("no memory to allocate audio instance\n");
-		rc = -ENOMEM;
-		goto done;
-	}
-	MM_DBG("audio instance 0x%08x created\n", (int)audio);
-
-	/* Allocate the decoder */
-	dec_attrb = AUDDEC_DEC_PCM;
-	if (file->f_mode & FMODE_READ) {
-		MM_ERR("Non-Tunneled mode not supported\n");
-		rc = -EPERM;
-		kfree(audio);
-		goto done;
-	} else
-		dec_attrb |= MSM_AUD_MODE_TUNNEL;
-
-	decid = audpp_adec_alloc(dec_attrb, &audio->module_name,
-			&audio->queue_id);
-	if (decid < 0) {
-		MM_ERR("No free decoder available\n");
-		rc = -ENODEV;
-		MM_DBG("audio instance 0x%08x freeing\n", (int)audio);
-		kfree(audio);
-		goto done;
-	}
-	audio->dec_id = decid & MSM_AUD_DECODER_MASK;
-
-	audio->buffer_size = BUFSZ;
-	audio->buffer_count = MAX_BUF;
-	rc = audmgr_open(&audio->audmgr);
-	if (rc)
-		goto err;
-
-	rc = msm_adsp_get(audio->module_name, &audio->audplay,
-			&audlpadec_adsp_ops, audio);
-	if (rc) {
-		MM_ERR("failed to get %s module\n", audio->module_name);
-		audmgr_close(&audio->audmgr);
-		goto err;
-	}
-
-	rc = rmt_get_resource(audio);
-	if (rc) {
-		MM_ERR("ADSP resources are not available for PCM session");
-		audmgr_close(&audio->audmgr);
-		msm_adsp_put(audio->audplay);
-		goto err;
-	}
-
-	/* Initialize all locks of audio instance */
-	mutex_init(&audio->lock);
-	mutex_init(&audio->write_lock);
-	mutex_init(&audio->get_event_lock);
-	spin_lock_init(&audio->dsp_lock);
-	init_waitqueue_head(&audio->write_wait);
-	INIT_LIST_HEAD(&audio->out_queue);
-	INIT_LIST_HEAD(&audio->ion_region_queue);
-	INIT_LIST_HEAD(&audio->free_event_queue);
-	INIT_LIST_HEAD(&audio->event_queue);
-	init_waitqueue_head(&audio->wait);
-	init_waitqueue_head(&audio->event_wait);
-	spin_lock_init(&audio->event_queue_lock);
-
-	audio->out_sample_rate = 44100;
-	audio->out_channel_mode = AUDPP_CMD_PCM_INTF_STEREO_V;
-	audio->out_bits = AUDPP_CMD_WAV_PCM_WIDTH_16;
-	audio->volume = 0x2000;
-	audpcm_async_flush(audio);
-
-	file->private_data = audio;
-	audio->opened = 1;
-
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof name, "msm_pcm_lp_dec_%04x", audio->dec_id);
-	audio->dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
-		NULL, (void *) audio, &audpcm_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		MM_DBG("debugfs_create_file failed\n");
-#endif
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	audio->suspend_ctl.node.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
-	audio->suspend_ctl.node.resume = audpcm_resume;
-	audio->suspend_ctl.node.suspend = audpcm_suspend;
-	audio->suspend_ctl.audio = audio;
-	register_early_suspend(&audio->suspend_ctl.node);
-#endif
-	for (i = 0; i < AUDPCM_EVENT_NUM; i++) {
-		e_node = kmalloc(sizeof(struct audpcm_event), GFP_KERNEL);
-		if (e_node)
-			list_add_tail(&e_node->list, &audio->free_event_queue);
-		else {
-			MM_ERR("event pkt alloc failed\n");
-			break;
-		}
-	}
-
-	audio->client = msm_ion_client_create(UINT_MAX, "Audio_LPA_Client");
-	if (IS_ERR_OR_NULL(audio->client)) {
-		pr_err("Unable to create ION client\n");
-		goto err;
-	}
-	MM_DBG("Ion client created\n");
-
-done:
-	return rc;
-err:
-	audpp_adec_free(audio->dec_id);
-	MM_DBG("audio instance 0x%08x freeing\n", (int)audio);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_pcm_lp_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audio_open,
-	.release	= audio_release,
-	.unlocked_ioctl	= audio_ioctl,
-	.fsync = audlpa_fsync,
-};
-
-struct miscdevice audio_lpa_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_pcm_lp_dec",
-	.fops	= &audio_pcm_lp_fops,
-};
-
-static int __init audio_init(void)
-{
-	return misc_register(&audio_lpa_misc);
-}
-
-device_initcall(audio_init);
diff --git a/arch/arm/mach-msm/qdsp5/audio_mp3.c b/arch/arm/mach-msm/qdsp5/audio_mp3.c
deleted file mode 100644
index c310e1e..0000000
--- a/arch/arm/mach-msm/qdsp5/audio_mp3.c
+++ /dev/null
@@ -1,2462 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/audio_mp3.c
- *
- * mp3 audio output device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2009-2012, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/earlysuspend.h>
-#include <linux/list.h>
-#include <linux/slab.h>
-#include <linux/msm_audio.h>
-#include <linux/memory_alloc.h>
-#include <linux/msm_ion.h>
-
-#include <mach/msm_adsp.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/msm_memtypes.h>
-#include <mach/qdsp5/qdsp5audppcmdi.h>
-#include <mach/qdsp5/qdsp5audppmsg.h>
-#include <mach/qdsp5/qdsp5audpp.h>
-#include <mach/qdsp5/qdsp5audplaycmdi.h>
-#include <mach/qdsp5/qdsp5audplaymsg.h>
-#include <mach/qdsp5/qdsp5rmtcmdi.h>
-#include <mach/debug_mm.h>
-
-#include "audmgr.h"
-
-#define ADRV_STATUS_AIO_INTF 0x00000001
-#define ADRV_STATUS_OBUF_GIVEN 0x00000002
-#define ADRV_STATUS_IBUF_GIVEN 0x00000004
-#define ADRV_STATUS_FSYNC 0x00000008
-
-/* Size must be power of 2 */
-#define BUFSZ_MAX 32768
-#define BUFSZ_MIN 4096
-#define DMASZ_MAX (BUFSZ_MAX * 2)
-#define DMASZ_MIN (BUFSZ_MIN * 2)
-
-#define AUDPLAY_INVALID_READ_PTR_OFFSET	0xFFFF
-#define AUDDEC_DEC_MP3 2
-
-#define PCM_BUFSZ_MIN 4800	/* Hold one stereo MP3 frame */
-#define PCM_BUF_MAX_COUNT 5	/* DSP only accepts 5 buffers at most
-				   but support 2 buffers currently */
-#define ROUTING_MODE_FTRT 1
-#define ROUTING_MODE_RT 2
-/* Decoder status received from AUDPPTASK */
-#define  AUDPP_DEC_STATUS_SLEEP	0
-#define	 AUDPP_DEC_STATUS_INIT  1
-#define  AUDPP_DEC_STATUS_CFG   2
-#define  AUDPP_DEC_STATUS_PLAY  3
-
-#define AUDMP3_METAFIELD_MASK 0xFFFF0000
-#define AUDMP3_EOS_FLG_OFFSET 0x0A /* Offset from beginning of buffer */
-#define AUDMP3_EOS_FLG_MASK 0x01
-#define AUDMP3_EOS_NONE 0x0 /* No EOS detected */
-#define AUDMP3_EOS_SET 0x1 /* EOS set in meta field */
-
-#define AUDMP3_EVENT_NUM 10 /* Default number of pre-allocated event packets */
-
-#define __CONTAINS(r, v, l) ({					\
-	typeof(r) __r = r;					\
-	typeof(v) __v = v;					\
-	typeof(v) __e = __v + l;				\
-	int res = ((__v >= __r->vaddr) && 			\
-		(__e <= __r->vaddr + __r->len));		\
-	res;							\
-})
-
-#define CONTAINS(r1, r2) ({					\
-	typeof(r2) __r2 = r2;					\
-	__CONTAINS(r1, __r2->vaddr, __r2->len);			\
-})
-
-#define IN_RANGE(r, v) ({					\
-	typeof(r) __r = r;					\
-	typeof(v) __vv = v;					\
-	int res = ((__vv >= __r->vaddr) &&			\
-		(__vv < (__r->vaddr + __r->len)));		\
-	res;							\
-})
-
-#define OVERLAPS(r1, r2) ({					\
-	typeof(r1) __r1 = r1;					\
-	typeof(r2) __r2 = r2;					\
-	typeof(__r2->vaddr) __v = __r2->vaddr;			\
-	typeof(__v) __e = __v + __r2->len - 1;			\
-	int res = (IN_RANGE(__r1, __v) || IN_RANGE(__r1, __e));	\
-	res;							\
-})
-
-struct audio;
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;		/* Input usage actual DSP produced PCM size  */
-	unsigned addr;
-	unsigned short mfield_sz; /*only useful for data has meta field */
-};
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-struct audmp3_suspend_ctl {
-  struct early_suspend node;
-  struct audio *audio;
-};
-#endif
-
-struct audmp3_event {
-	struct list_head list;
-	int event_type;
-	union msm_audio_event_payload payload;
-};
-
-struct audmp3_ion_region {
-	struct list_head list;
-	struct ion_handle *handle;
-	int fd;
-	void *vaddr;
-	unsigned long paddr;
-	unsigned long kvaddr;
-	unsigned long len;
-	unsigned ref_cnt;
-};
-
-struct audmp3_buffer_node {
-	struct list_head list;
-	struct msm_audio_aio_buf buf;
-	unsigned long paddr;
-};
-
-struct audmp3_drv_operations {
-	void (*pcm_buf_update)(struct audio *, uint32_t *);
-	void (*buffer_refresh)(struct audio *);
-	void (*send_data)(struct audio *, unsigned);
-	void (*out_flush)(struct audio *);
-	void (*in_flush)(struct audio *);
-	int (*fsync)(struct audio *);
-};
-
-struct audio {
-	struct buffer out[2];
-
-	spinlock_t dsp_lock;
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed; /* number of buffers the dsp is waiting for */
-	unsigned out_dma_sz;
-	struct list_head out_queue; /* queue to retain output buffers */
-	atomic_t out_bytes;
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-
-	/* Host PCM section */
-	struct buffer in[PCM_BUF_MAX_COUNT];
-	struct mutex read_lock;
-	wait_queue_head_t read_wait;	/* Wait queue for read */
-	char *read_data;	/* pointer to reader buffer */
-	int32_t read_phys;	/* physical address of reader buffer */
-	uint8_t read_next;	/* index to input buffers to be read next */
-	uint8_t fill_next;	/* index to buffer that DSP should be filling */
-	uint8_t pcm_buf_count;	/* number of pcm buffer allocated */
-	struct list_head in_queue; /* queue to retain input buffers */
-	/* ---- End of Host PCM section */
-
-	struct msm_adsp_module *audplay;
-
-	/* configuration to use on next enable */
-	uint32_t out_sample_rate;
-	uint32_t out_channel_mode;
-
-	struct audmgr audmgr;
-
-	/* data allocated for various buffers */
-	char *data;
-	int32_t phys; /* physical address of write buffer */
-	void *map_v_read;
-	void *map_v_write;
-
-	uint32_t drv_status;
-	int mfield; /* meta field embedded in data */
-	int rflush; /* Read  flush */
-	int wflush; /* Write flush */
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped, cleared on flush */
-	int pcm_feedback;
-	int buf_refresh;
-	int rmt_resource_released;
-	int teos; /* valid only if tunnel mode & no data left for decoder */
-	enum msm_aud_decoder_state dec_state;	/* Represents decoder state */
-	int reserved; /* A byte is being reserved */
-	char rsv_byte; /* Handle odd length user data */
-
-	const char *module_name;
-	unsigned queue_id;
-	uint16_t dec_id;
-	uint32_t read_ptr_offset;
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	struct audmp3_suspend_ctl suspend_ctl;
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *dentry;
-#endif
-
-	wait_queue_head_t wait;
-	struct list_head free_event_queue;
-	struct list_head event_queue;
-	wait_queue_head_t event_wait;
-	spinlock_t event_queue_lock;
-	struct mutex get_event_lock;
-	int event_abort;
-
-	struct list_head ion_region_queue; /* protected by lock */
-	struct audmp3_drv_operations drv_ops;
-
-	int eq_enable;
-	int eq_needs_commit;
-	audpp_cmd_cfg_object_params_eqalizer eq;
-	audpp_cmd_cfg_object_params_volume vol_pan;
-	struct ion_client *client;
-	struct ion_handle *input_buff_handle;
-	struct ion_handle *output_buff_handle;
-};
-
-static int auddec_dsp_config(struct audio *audio, int enable);
-static void audpp_cmd_cfg_adec_params(struct audio *audio);
-static void audpp_cmd_cfg_routing_mode(struct audio *audio);
-static void audplay_send_data(struct audio *audio, unsigned needed);
-static void audplay_config_hostpcm(struct audio *audio);
-static void audplay_buffer_refresh(struct audio *audio);
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg);
-static void audmp3_post_event(struct audio *audio, int type,
-	union msm_audio_event_payload payload);
-static unsigned long audmp3_ion_fixup(struct audio *audio, void *addr,
-				unsigned long len, int ref_up);
-
-static int rmt_put_resource(struct audio *audio)
-{
-	struct aud_codec_config_cmd cmd;
-	unsigned short client_idx;
-
-	cmd.cmd_id = RM_CMD_AUD_CODEC_CFG;
-	cmd.client_id = RM_AUD_CLIENT_ID;
-	cmd.task_id = audio->dec_id;
-	cmd.enable = RMT_DISABLE;
-	cmd.dec_type = AUDDEC_DEC_MP3;
-	client_idx = ((cmd.client_id << 8) | cmd.task_id);
-
-	return put_adsp_resource(client_idx, &cmd, sizeof(cmd));
-}
-
-static int rmt_get_resource(struct audio *audio)
-{
-	struct aud_codec_config_cmd cmd;
-	unsigned short client_idx;
-
-	cmd.cmd_id = RM_CMD_AUD_CODEC_CFG;
-	cmd.client_id = RM_AUD_CLIENT_ID;
-	cmd.task_id = audio->dec_id;
-	cmd.enable = RMT_ENABLE;
-	cmd.dec_type = AUDDEC_DEC_MP3;
-	client_idx = ((cmd.client_id << 8) | cmd.task_id);
-
-	return get_adsp_resource(client_idx, &cmd, sizeof(cmd));
-}
-
-/* must be called with audio->lock held */
-static int audio_enable(struct audio *audio)
-{
-	struct audmgr_config cfg;
-	int rc;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	if (audio->enabled)
-		return 0;
-
-	if (audio->rmt_resource_released == 1) {
-		audio->rmt_resource_released = 0;
-		rc = rmt_get_resource(audio);
-		if (rc) {
-			MM_ERR("ADSP resources are not available for MP3 \
-				session 0x%08x on decoder: %d\n Ignoring \
-				error and going ahead with the playback\n",
-				(int)audio, audio->dec_id);
-		}
-	}
-
-	audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-
-	if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK) {
-		cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE;
-		cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000;
-		cfg.def_method = RPC_AUD_DEF_METHOD_PLAYBACK;
-		cfg.codec = RPC_AUD_DEF_CODEC_MP3;
-		cfg.snd_method = RPC_SND_METHOD_MIDI;
-
-		rc = audmgr_enable(&audio->audmgr, &cfg);
-		if (rc < 0) {
-			msm_adsp_dump(audio->audplay);
-			return rc;
-		}
-	}
-
-	if (msm_adsp_enable(audio->audplay)) {
-		MM_ERR("msm_adsp_enable(audplay) failed\n");
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_disable(&audio->audmgr);
-		return -ENODEV;
-	}
-
-	if (audpp_enable(audio->dec_id, audio_dsp_event, audio)) {
-		MM_ERR("audpp_enable() failed\n");
-		msm_adsp_disable(audio->audplay);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_disable(&audio->audmgr);
-		return -ENODEV;
-	}
-
-	audio->enabled = 1;
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audio_disable(struct audio *audio)
-{
-	int rc = 0;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-		auddec_dsp_config(audio, 0);
-		rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-		if (rc == 0)
-			rc = -ETIMEDOUT;
-		else if (audio->dec_state != MSM_AUD_DECODER_STATE_CLOSE)
-			rc = -EFAULT;
-		else
-			rc = 0;
-		audio->stopped = 1;
-		wake_up(&audio->write_wait);
-		wake_up(&audio->read_wait);
-		msm_adsp_disable(audio->audplay);
-		audpp_disable(audio->dec_id, audio);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK) {
-			rc = audmgr_disable(&audio->audmgr);
-			if (rc < 0)
-				msm_adsp_dump(audio->audplay);
-		}
-		audio->out_needed = 0;
-		rmt_put_resource(audio);
-		audio->rmt_resource_released = 1;
-	}
-	return rc;
-}
-
-/* ------------------- dsp --------------------- */
-static void audmp3_async_pcm_buf_update(struct audio *audio, uint32_t *payload)
-{
-	unsigned long flags;
-	union msm_audio_event_payload event_payload;
-	struct audmp3_buffer_node *filled_buf;
-	uint8_t index;
-
-	if (audio->rflush)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < payload[1]; index++) {
-		BUG_ON(list_empty(&audio->in_queue));
-		filled_buf = list_first_entry(&audio->in_queue,
-					struct audmp3_buffer_node, list);
-		if (filled_buf->paddr == payload[2 + index * 2]) {
-			list_del(&filled_buf->list);
-			event_payload.aio_buf = filled_buf->buf;
-			event_payload.aio_buf.data_len =
-				payload[3 + index * 2];
-			MM_DBG("pcm buf %p data_len %d\n", filled_buf,
-					event_payload.aio_buf.data_len);
-			audmp3_post_event(audio, AUDIO_EVENT_READ_DONE,
-						event_payload);
-			kfree(filled_buf);
-		} else {
-			MM_ERR("expected=%lx ret=%x\n", filled_buf->paddr,
-					payload[2 + index * 2]);
-			break;
-		}
-	}
-
-	audio->drv_status &= ~ADRV_STATUS_IBUF_GIVEN;
-	audio->drv_ops.buffer_refresh(audio);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-
-}
-
-static void audio_update_pcm_buf_entry(struct audio *audio, uint32_t *payload)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	if (audio->rflush)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < payload[1]; index++) {
-		if (audio->in[audio->fill_next].addr ==
-		    payload[2 + index * 2]) {
-			MM_DBG("in[%d] ready\n", audio->fill_next);
-			audio->in[audio->fill_next].used =
-			  payload[3 + index * 2];
-			if ((++audio->fill_next) == audio->pcm_buf_count)
-				audio->fill_next = 0;
-
-		} else {
-			MM_ERR("expected=%x ret=%x\n",
-					audio->in[audio->fill_next].addr,
-					payload[2 + index * 2]);
-			break;
-		}
-	}
-	if (audio->in[audio->fill_next].used == 0) {
-		audio->drv_ops.buffer_refresh(audio);
-	} else {
-		MM_DBG("read cannot keep up\n");
-		audio->buf_refresh = 1;
-	}
-	wake_up(&audio->read_wait);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-
-}
-
-static void audplay_dsp_event(void *data, unsigned id, size_t len,
-			      void (*getevent) (void *ptr, size_t len))
-{
-	struct audio *audio = data;
-	uint32_t msg[28];
-	getevent(msg, sizeof(msg));
-
-	MM_DBG("msg_id=%x\n", id);
-
-	switch (id) {
-	case AUDPLAY_MSG_DEC_NEEDS_DATA:
-		audio->drv_ops.send_data(audio, 1);
-		break;
-
-	case AUDPLAY_MSG_BUFFER_UPDATE:
-		audio->drv_ops.pcm_buf_update(audio, msg);
-		break;
-
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audplaytask)\n");
-		break;
-
-	default:
-		MM_ERR("unexpected message from decoder \n");
-		break;
-	}
-}
-
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg)
-{
-	struct audio *audio = private;
-
-	switch (id) {
-	case AUDPP_MSG_STATUS_MSG:{
-			unsigned status = msg[1];
-
-			switch (status) {
-			case AUDPP_DEC_STATUS_SLEEP: {
-				uint16_t reason = msg[2];
-				MM_DBG("decoder status: sleep reason=0x%04x\n",
-						reason);
-				if ((reason == AUDPP_MSG_REASON_MEM)
-					|| (reason ==
-					AUDPP_MSG_REASON_NODECODER)) {
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_FAILURE;
-					wake_up(&audio->wait);
-				} else if (reason == AUDPP_MSG_REASON_NONE) {
-					/* decoder is in disable state */
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_CLOSE;
-					wake_up(&audio->wait);
-				}
-				break;
-			}
-			case AUDPP_DEC_STATUS_INIT:
-				MM_DBG("decoder status: init \n");
-				if (audio->pcm_feedback)
-					audpp_cmd_cfg_routing_mode(audio);
-				else
-					audpp_cmd_cfg_adec_params(audio);
-				break;
-
-			case AUDPP_DEC_STATUS_CFG:
-				MM_DBG("decoder status: cfg \n");
-				break;
-			case AUDPP_DEC_STATUS_PLAY:
-				MM_DBG("decoder status: play \n");
-				if (audio->pcm_feedback) {
-					audplay_config_hostpcm(audio);
-					audio->drv_ops.buffer_refresh(audio);
-				}
-				audio->dec_state =
-					MSM_AUD_DECODER_STATE_SUCCESS;
-				wake_up(&audio->wait);
-				break;
-			default:
-				MM_ERR("unknown decoder status \n");
-				break;
-			}
-			break;
-		}
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_DBG("CFG_MSG ENABLE\n");
-			auddec_dsp_config(audio, 1);
-			audio->out_needed = 0;
-			audio->running = 1;
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-			audpp_dsp_set_eq(audio->dec_id, audio->eq_enable,
-								&audio->eq);
-			audpp_avsync(audio->dec_id, 22050);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			MM_DBG("CFG_MSG DISABLE\n");
-			audpp_avsync(audio->dec_id, 0);
-			audio->running = 0;
-		} else {
-			MM_DBG("CFG_MSG %d?\n", msg[0]);
-		}
-		break;
-	case AUDPP_MSG_ROUTING_ACK:
-		MM_DBG("ROUTING_ACK mode=%d\n",	msg[1]);
-		audpp_cmd_cfg_adec_params(audio);
-		break;
-
-	case AUDPP_MSG_FLUSH_ACK:
-		MM_DBG("FLUSH_ACK\n");
-		audio->wflush = 0;
-		audio->rflush = 0;
-		wake_up(&audio->write_wait);
-		if (audio->pcm_feedback)
-			audio->drv_ops.buffer_refresh(audio);
-		break;
-
-	case AUDPP_MSG_PCMDMAMISSED:
-		MM_DBG("PCMDMAMISSED\n");
-		audio->teos = 1;
-		wake_up(&audio->write_wait);
-		break;
-
-	default:
-		MM_ERR("UNKNOWN (%d)\n", id);
-	}
-
-}
-
-
-struct msm_adsp_ops audplay_adsp_ops = {
-	.event = audplay_dsp_event,
-};
-
-
-#define audplay_send_queue0(audio, cmd, len) \
-	msm_adsp_write(audio->audplay, audio->queue_id, \
-			cmd, len)
-
-static int auddec_dsp_config(struct audio *audio, int enable)
-{
-	u16 cfg_dec_cmd[AUDPP_CMD_CFG_DEC_TYPE_LEN / sizeof(unsigned short)];
-
-	memset(cfg_dec_cmd, 0, sizeof(cfg_dec_cmd));
-
-	cfg_dec_cmd[0] = AUDPP_CMD_CFG_DEC_TYPE;
-	if (enable)
-		cfg_dec_cmd[1 + audio->dec_id] = AUDPP_CMD_UPDATDE_CFG_DEC |
-			AUDPP_CMD_ENA_DEC_V | AUDDEC_DEC_MP3;
-	else
-		cfg_dec_cmd[1 + audio->dec_id] = AUDPP_CMD_UPDATDE_CFG_DEC |
-			AUDPP_CMD_DIS_DEC_V;
-
-	return audpp_send_queue1(&cfg_dec_cmd, sizeof(cfg_dec_cmd));
-}
-
-static void audpp_cmd_cfg_adec_params(struct audio *audio)
-{
-	audpp_cmd_cfg_adec_params_mp3 cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_CMD_CFG_ADEC_PARAMS;
-	cmd.common.length = AUDPP_CMD_CFG_ADEC_PARAMS_MP3_LEN;
-	cmd.common.dec_id = audio->dec_id;
-	cmd.common.input_sampling_frequency = audio->out_sample_rate;
-
-	audpp_send_queue2(&cmd, sizeof(cmd));
-}
-
-static void audpp_cmd_cfg_routing_mode(struct audio *audio)
-{
-	struct audpp_cmd_routing_mode cmd;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPP_CMD_ROUTING_MODE;
-	cmd.object_number = audio->dec_id;
-	if (audio->pcm_feedback)
-		cmd.routing_mode = ROUTING_MODE_FTRT;
-	else
-		cmd.routing_mode = ROUTING_MODE_RT;
-
-	audpp_send_queue1(&cmd, sizeof(cmd));
-}
-
-static int audplay_dsp_send_data_avail(struct audio *audio,
-					unsigned idx, unsigned len)
-{
-	struct audplay_cmd_bitstream_data_avail_nt2 cmd;
-
-	cmd.cmd_id		= AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2;
-	if (audio->mfield)
-		cmd.decoder_id = AUDMP3_METAFIELD_MASK |
-			(audio->out[idx].mfield_sz >> 1);
-	else
-		cmd.decoder_id		= audio->dec_id;
-	cmd.buf_ptr		= audio->out[idx].addr;
-	cmd.buf_size		= len/2;
-	cmd.partition_number	= 0;
-	/* complete all the writes to the input buffer */
-	wmb();
-	return audplay_send_queue0(audio, &cmd, sizeof(cmd));
-}
-
-/* Caller holds irq_lock */
-static void audmp3_async_buffer_refresh(struct audio *audio)
-{
-	struct audplay_cmd_buffer_refresh refresh_cmd;
-	struct audmp3_buffer_node *next_buf;
-
-	if (!audio->running ||
-	    audio->drv_status & ADRV_STATUS_IBUF_GIVEN)
-		return;
-
-	if (!list_empty(&audio->in_queue)) {
-		next_buf = list_first_entry(&audio->in_queue,
-		    struct audmp3_buffer_node, list);
-		if (!next_buf)
-			return;
-		MM_DBG("next buf %p phy %lx len %d\n", next_buf,
-				next_buf->paddr, next_buf->buf.buf_len);
-		refresh_cmd.cmd_id = AUDPLAY_CMD_BUFFER_REFRESH;
-		refresh_cmd.num_buffers = 1;
-		refresh_cmd.buf0_address = next_buf->paddr;
-		refresh_cmd.buf0_length = next_buf->buf.buf_len -
-			(next_buf->buf.buf_len % 576) +
-			(audio->mfield ? 24 : 0); /* Mp3 frame size */
-		refresh_cmd.buf_read_count = 0;
-		audio->drv_status |= ADRV_STATUS_IBUF_GIVEN;
-		(void) audplay_send_queue0(audio, &refresh_cmd,
-			sizeof(refresh_cmd));
-	}
-
-}
-
-static void audplay_buffer_refresh(struct audio *audio)
-{
-	struct audplay_cmd_buffer_refresh refresh_cmd;
-
-	refresh_cmd.cmd_id = AUDPLAY_CMD_BUFFER_REFRESH;
-	refresh_cmd.num_buffers = 1;
-	refresh_cmd.buf0_address = audio->in[audio->fill_next].addr;
-	refresh_cmd.buf0_length = audio->in[audio->fill_next].size -
-		(audio->in[audio->fill_next].size % 576) +
-		(audio->mfield ? 24 : 0); /* Mp3 frame size */
-	refresh_cmd.buf_read_count = 0;
-	MM_DBG("buf0_addr=%x buf0_len=%d\n", refresh_cmd.buf0_address,
-			refresh_cmd.buf0_length);
-	(void)audplay_send_queue0(audio, &refresh_cmd, sizeof(refresh_cmd));
-}
-
-static void audplay_config_hostpcm(struct audio *audio)
-{
-	struct audplay_cmd_hpcm_buf_cfg cfg_cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	cfg_cmd.cmd_id = AUDPLAY_CMD_HPCM_BUF_CFG;
-	cfg_cmd.max_buffers = 1;
-	cfg_cmd.byte_swap = 0;
-	cfg_cmd.hostpcm_config = (0x8000) | (0x4000);
-	cfg_cmd.feedback_frequency = 1;
-	cfg_cmd.partition_number = 0;
-	(void)audplay_send_queue0(audio, &cfg_cmd, sizeof(cfg_cmd));
-
-}
-
-static void audmp3_async_send_data(struct audio *audio, unsigned needed)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (needed && !audio->wflush) {
-		audio->out_needed = 1;
-		if (audio->drv_status & ADRV_STATUS_OBUF_GIVEN) {
-			/* pop one node out of queue */
-			union msm_audio_event_payload payload;
-			struct audmp3_buffer_node *used_buf;
-
-			MM_DBG("consumed\n");
-			BUG_ON(list_empty(&audio->out_queue));
-			used_buf = list_first_entry(&audio->out_queue,
-				struct audmp3_buffer_node, list);
-			list_del(&used_buf->list);
-			payload.aio_buf = used_buf->buf;
-			audmp3_post_event(audio, AUDIO_EVENT_WRITE_DONE,
-				payload);
-			kfree(used_buf);
-			audio->drv_status &= ~ADRV_STATUS_OBUF_GIVEN;
-		}
-
-	}
-
-	if (audio->out_needed) {
-		struct audmp3_buffer_node *next_buf;
-		struct audplay_cmd_bitstream_data_avail_nt2 cmd;
-		if (!list_empty(&audio->out_queue)) {
-			next_buf = list_first_entry(&audio->out_queue,
-					struct audmp3_buffer_node, list);
-			MM_DBG("next_buf %p\n", next_buf);
-			if (next_buf) {
-				MM_DBG("next buf phy %lx len %d\n",
-						next_buf->paddr,
-						next_buf->buf.data_len);
-
-				cmd.cmd_id =
-					AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2;
-				if (audio->mfield)
-					cmd.decoder_id = AUDMP3_METAFIELD_MASK |
-						(next_buf->buf.mfield_sz >> 1);
-				else
-					cmd.decoder_id = audio->dec_id;
-				cmd.buf_ptr	= (unsigned) next_buf->paddr;
-				cmd.buf_size = next_buf->buf.data_len >> 1;
-				cmd.partition_number	= 0;
-				/* complete the writes to the input buffer */
-				wmb();
-				audplay_send_queue0(audio, &cmd, sizeof(cmd));
-				audio->out_needed = 0;
-				audio->drv_status |= ADRV_STATUS_OBUF_GIVEN;
-			}
-		}
-	}
-
-done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audplay_send_data(struct audio *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			MM_DBG("frame %d free\n", audio->out_tail);
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-		  BUG_ON(frame->used == 0xffffffff);
-		  MM_DBG("frame %d busy\n", audio->out_tail);
-		  audplay_dsp_send_data_avail(audio, audio->out_tail,
-					      frame->used);
-		  frame->used = 0xffffffff;
-		  audio->out_needed = 0;
-		}
-	}
-done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-static void audmp3_async_flush(struct audio *audio)
-{
-	struct audmp3_buffer_node *buf_node;
-	struct list_head *ptr, *next;
-	union msm_audio_event_payload payload;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	list_for_each_safe(ptr, next, &audio->out_queue) {
-		buf_node = list_entry(ptr, struct audmp3_buffer_node, list);
-		list_del(&buf_node->list);
-		payload.aio_buf = buf_node->buf;
-		audmp3_post_event(audio, AUDIO_EVENT_WRITE_DONE,
-				payload);
-		kfree(buf_node);
-	}
-	audio->drv_status &= ~ADRV_STATUS_OBUF_GIVEN;
-	audio->out_needed = 0;
-	atomic_set(&audio->out_bytes, 0);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audio_flush(struct audio *audio)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->out[0].used = 0;
-	audio->out[1].used = 0;
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->reserved = 0;
-	audio->out_needed = 0;
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	atomic_set(&audio->out_bytes, 0);
-}
-
-static void audmp3_async_flush_pcm_buf(struct audio *audio)
-{
-	struct audmp3_buffer_node *buf_node;
-	struct list_head *ptr, *next;
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	list_for_each_safe(ptr, next, &audio->in_queue) {
-		buf_node = list_entry(ptr, struct audmp3_buffer_node, list);
-		list_del(&buf_node->list);
-		payload.aio_buf = buf_node->buf;
-		payload.aio_buf.data_len = 0;
-		audmp3_post_event(audio, AUDIO_EVENT_READ_DONE,
-				payload);
-		kfree(buf_node);
-	}
-	audio->drv_status &= ~ADRV_STATUS_IBUF_GIVEN;
-
-}
-
-static void audio_flush_pcm_buf(struct audio *audio)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < PCM_BUF_MAX_COUNT; index++)
-		audio->in[index].used = 0;
-	audio->buf_refresh = 0;
-	audio->read_next = 0;
-	audio->fill_next = 0;
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audio_ioport_reset(struct audio *audio)
-{
-	if (audio->drv_status & ADRV_STATUS_AIO_INTF) {
-		/* If fsync is in progress, make sure
-		 * return value of fsync indicates
-		 * abort due to flush
-		 */
-		if (audio->drv_status & ADRV_STATUS_FSYNC) {
-			MM_DBG("fsync in progress\n");
-			wake_up(&audio->write_wait);
-			mutex_lock(&audio->write_lock);
-			audio->drv_ops.out_flush(audio);
-			mutex_unlock(&audio->write_lock);
-		} else
-			audio->drv_ops.out_flush(audio);
-		audio->drv_ops.in_flush(audio);
-	} else {
-		/* Make sure read/write thread are free from
-		 * sleep and knowing that system is not able
-		 * to process io request at the moment
-		 */
-		wake_up(&audio->write_wait);
-		mutex_lock(&audio->write_lock);
-		audio->drv_ops.out_flush(audio);
-		mutex_unlock(&audio->write_lock);
-		wake_up(&audio->read_wait);
-		mutex_lock(&audio->read_lock);
-		audio->drv_ops.in_flush(audio);
-		mutex_unlock(&audio->read_lock);
-	}
-}
-
-static int audmp3_events_pending(struct audio *audio)
-{
-	unsigned long flags;
-	int empty;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	empty = !list_empty(&audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	return empty || audio->event_abort;
-}
-
-static void audmp3_reset_event_queue(struct audio *audio)
-{
-	unsigned long flags;
-	struct audmp3_event *drv_evt;
-	struct list_head *ptr, *next;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	list_for_each_safe(ptr, next, &audio->event_queue) {
-		drv_evt = list_first_entry(&audio->event_queue,
-			struct audmp3_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	list_for_each_safe(ptr, next, &audio->free_event_queue) {
-		drv_evt = list_first_entry(&audio->free_event_queue,
-			struct audmp3_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	return;
-}
-
-static long audmp3_process_event_req(struct audio *audio, void __user *arg)
-{
-	long rc;
-	struct msm_audio_event usr_evt;
-	struct audmp3_event *drv_evt = NULL;
-	int timeout;
-	unsigned long flags;
-
-	if (copy_from_user(&usr_evt, arg, sizeof(struct msm_audio_event)))
-		return -EFAULT;
-
-	timeout = (int) usr_evt.timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(
-			audio->event_wait, audmp3_events_pending(audio),
-			msecs_to_jiffies(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(
-			audio->event_wait, audmp3_events_pending(audio));
-	}
-
-	if (rc < 0)
-		return rc;
-
-	if (audio->event_abort) {
-		audio->event_abort = 0;
-		return -ENODEV;
-	}
-
-	rc = 0;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	if (!list_empty(&audio->event_queue)) {
-		drv_evt = list_first_entry(&audio->event_queue,
-			struct audmp3_event, list);
-		list_del(&drv_evt->list);
-	}
-	if (drv_evt) {
-		usr_evt.event_type = drv_evt->event_type;
-		usr_evt.event_payload = drv_evt->payload;
-		list_add_tail(&drv_evt->list, &audio->free_event_queue);
-	} else
-		rc = -1;
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	if (drv_evt->event_type == AUDIO_EVENT_WRITE_DONE ||
-	    drv_evt->event_type == AUDIO_EVENT_READ_DONE) {
-		mutex_lock(&audio->lock);
-		audmp3_ion_fixup(audio, drv_evt->payload.aio_buf.buf_addr,
-				  drv_evt->payload.aio_buf.buf_len, 0);
-		mutex_unlock(&audio->lock);
-	}
-
-	/* order reads from the output buffer */
-	if (drv_evt->event_type == AUDIO_EVENT_READ_DONE)
-		rmb();
-
-	if (!rc && copy_to_user(arg, &usr_evt, sizeof(usr_evt)))
-		rc = -EFAULT;
-
-	return rc;
-}
-
-static int audmp3_ion_check(struct audio *audio,
-		void *vaddr, unsigned long len)
-{
-	struct audmp3_ion_region *region_elt;
-	struct audmp3_ion_region t = { .vaddr = vaddr, .len = len };
-
-	list_for_each_entry(region_elt, &audio->ion_region_queue, list) {
-		if (CONTAINS(region_elt, &t) || CONTAINS(&t, region_elt) ||
-		    OVERLAPS(region_elt, &t)) {
-			MM_ERR("region (vaddr %p len %ld)"
-				" clashes with registered region"
-				" (vaddr %p paddr %p len %ld)\n",
-				vaddr, len,
-				region_elt->vaddr,
-				(void *)region_elt->paddr,
-				region_elt->len);
-			return -EINVAL;
-		}
-	}
-
-	return 0;
-}
-
-static int audmp3_ion_add(struct audio *audio,
-			struct msm_audio_ion_info *info)
-{
-	ion_phys_addr_t paddr;
-	size_t len;
-	unsigned long kvaddr;
-	struct audmp3_ion_region *region;
-	int rc = -EINVAL;
-	struct ion_handle *handle;
-	unsigned long ionflag;
-	void *temp_ptr;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	region = kmalloc(sizeof(*region), GFP_KERNEL);
-
-	if (!region) {
-		rc = -ENOMEM;
-		goto end;
-	}
-
-	handle = ion_import_dma_buf(audio->client, info->fd);
-	if (IS_ERR_OR_NULL(handle)) {
-		pr_err("%s: could not get handle of the given fd\n", __func__);
-		goto import_error;
-	}
-
-	rc = ion_handle_get_flags(audio->client, handle, &ionflag);
-	if (rc) {
-		pr_err("%s: could not get flags for the handle\n", __func__);
-		goto flag_error;
-	}
-
-	temp_ptr = ion_map_kernel(audio->client, handle);
-	if (IS_ERR_OR_NULL(temp_ptr)) {
-		pr_err("%s: could not get virtual address\n", __func__);
-		goto map_error;
-	}
-	kvaddr = (unsigned long) temp_ptr;
-
-	rc = ion_phys(audio->client, handle, &paddr, &len);
-	if (rc) {
-		pr_err("%s: could not get physical address\n", __func__);
-		goto ion_error;
-	}
-
-	rc = audmp3_ion_check(audio, info->vaddr, len);
-	if (rc < 0) {
-		MM_ERR("audpcm_ion_check failed\n");
-		goto ion_error;
-	}
-
-	region->handle = handle;
-	region->vaddr = info->vaddr;
-	region->fd = info->fd;
-	region->paddr = paddr;
-	region->kvaddr = kvaddr;
-	region->len = len;
-	region->ref_cnt = 0;
-	MM_DBG("[%p]:add region paddr %lx vaddr %p, len %lu kvaddr %lx\n",
-		audio, region->paddr, region->vaddr,
-		region->len, region->kvaddr);
-	list_add_tail(&region->list, &audio->ion_region_queue);
-	return rc;
-
-ion_error:
-	ion_unmap_kernel(audio->client, handle);
-map_error:
-flag_error:
-	ion_free(audio->client, handle);
-import_error:
-	kfree(region);
-end:
-	return rc;
-}
-
-static int audmp3_ion_remove(struct audio *audio,
-			struct msm_audio_ion_info *info)
-{
-	struct audmp3_ion_region *region;
-	struct list_head *ptr, *next;
-	int rc = -EINVAL;
-
-	list_for_each_safe(ptr, next, &audio->ion_region_queue) {
-		region = list_entry(ptr, struct audmp3_ion_region, list);
-
-		if (region != NULL && (region->fd == info->fd) &&
-		    (region->vaddr == info->vaddr)) {
-			if (region->ref_cnt) {
-				MM_DBG("%s[%p]:region %p in use ref_cnt %d\n",
-					__func__, audio, region,
-					region->ref_cnt);
-				break;
-			}
-			MM_DBG("remove region fd %d vaddr %p\n",
-				info->fd, info->vaddr);
-			list_del(&region->list);
-			ion_unmap_kernel(audio->client, region->handle);
-			ion_free(audio->client, region->handle);
-			kfree(region);
-			rc = 0;
-			break;
-		}
-	}
-
-	return rc;
-}
-
-static int audmp3_ion_lookup_vaddr(struct audio *audio, void *addr,
-			unsigned long len, struct audmp3_ion_region **region)
-{
-	struct audmp3_ion_region *region_elt;
-	int match_count = 0;
-	*region = NULL;
-
-	/* returns physical address or zero */
-	list_for_each_entry(region_elt, &audio->ion_region_queue, list) {
-		if (addr >= region_elt->vaddr &&
-		    addr < region_elt->vaddr + region_elt->len &&
-		    addr + len <= region_elt->vaddr + region_elt->len) {
-			/* offset since we could pass vaddr inside a registerd
-			 * ion buffer
-			 */
-
-			match_count++;
-			if (!*region)
-				*region = region_elt;
-		}
-	}
-
-	if (match_count > 1) {
-		MM_ERR("%s[%p]:multiple hits for vaddr %p, len %ld\n",
-			 __func__, audio, addr, len);
-		list_for_each_entry(region_elt, &audio->ion_region_queue,
-					list) {
-			if (addr >= region_elt->vaddr &&
-			addr < region_elt->vaddr + region_elt->len &&
-			addr + len <= region_elt->vaddr + region_elt->len)
-					MM_ERR("\t%s[%p]:%p, %ld --> %p\n",
-						__func__, audio,
-						region_elt->vaddr,
-						region_elt->len,
-						(void *)region_elt->paddr);
-		}
-	}
-	return *region ? 0 : -1;
-}
-
-unsigned long audmp3_ion_fixup(struct audio *audio, void *addr,
-		    unsigned long len, int ref_up)
-{
-	struct audmp3_ion_region *region;
-	unsigned long paddr;
-	int ret;
-
-	ret = audmp3_ion_lookup_vaddr(audio, addr, len, &region);
-	if (ret) {
-		MM_ERR("lookup (%p, %ld) failed\n", addr, len);
-		return 0;
-	}
-	if (ref_up)
-		region->ref_cnt++;
-	else
-		region->ref_cnt--;
-	MM_DBG("found region %p ref_cnt %d\n", region, region->ref_cnt);
-	paddr = region->paddr + (addr - region->vaddr);
-	return paddr;
-}
-
-/* audio -> lock must be held at this point */
-static int audmp3_aio_buf_add(struct audio *audio, unsigned dir,
-	void __user *arg)
-{
-	unsigned long flags;
-	struct audmp3_buffer_node *buf_node;
-
-	buf_node = kmalloc(sizeof(*buf_node), GFP_KERNEL);
-
-	if (!buf_node)
-		return -ENOMEM;
-
-	if (copy_from_user(&buf_node->buf, arg, sizeof(buf_node->buf))) {
-		kfree(buf_node);
-		return -EFAULT;
-	}
-
-	MM_DBG("node %p dir %x buf_addr %p buf_len %d data_len \
-			%d\n", buf_node, dir,
-			buf_node->buf.buf_addr, buf_node->buf.buf_len,
-			buf_node->buf.data_len);
-
-	buf_node->paddr = audmp3_ion_fixup(
-		audio, buf_node->buf.buf_addr,
-		buf_node->buf.buf_len, 1);
-
-	if (dir) {
-		/* write */
-		if (!buf_node->paddr ||
-		    (buf_node->paddr & 0x1) ||
-		    (buf_node->buf.data_len & 0x1) ||
-		    (!audio->pcm_feedback &&
-		    !buf_node->buf.data_len)) {
-			kfree(buf_node);
-			return -EINVAL;
-		}
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		list_add_tail(&buf_node->list, &audio->out_queue);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		audio->drv_ops.send_data(audio, 0);
-	} else {
-		/* read */
-		if (!buf_node->paddr ||
-		    (buf_node->paddr & 0x1) ||
-		    (buf_node->buf.buf_len < PCM_BUFSZ_MIN)) {
-			kfree(buf_node);
-			return -EINVAL;
-		}
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		list_add_tail(&buf_node->list, &audio->in_queue);
-		audio->drv_ops.buffer_refresh(audio);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	}
-
-	MM_DBG("Add buf_node %p paddr %lx\n", buf_node, buf_node->paddr);
-
-	return 0;
-}
-
-static int audio_enable_eq(struct audio *audio, int enable)
-{
-	if (audio->eq_enable == enable && !audio->eq_needs_commit)
-		return 0;
-
-	audio->eq_enable = enable;
-
-	if (audio->running) {
-		audpp_dsp_set_eq(audio->dec_id, enable, &audio->eq);
-		audio->eq_needs_commit = 0;
-	}
-	return 0;
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = -EINVAL;
-	unsigned long flags = 0;
-	uint16_t enable_mask;
-	int enable;
-	int prev_state;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	int len = 0;
-
-	MM_DBG("cmd = %d\n", cmd);
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		stats.byte_count = audpp_avsync_byte_count(audio->dec_id);
-		stats.sample_count = audpp_avsync_sample_count(audio->dec_id);
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-
-	switch (cmd) {
-	case AUDIO_ENABLE_AUDPP:
-		if (copy_from_user(&enable_mask, (void *) arg,
-						sizeof(enable_mask))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		enable = (enable_mask & EQ_ENABLE) ? 1 : 0;
-		audio_enable_eq(audio, enable);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-	case AUDIO_SET_VOLUME:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.volume = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_PAN:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.pan = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_EQ:
-		prev_state = audio->eq_enable;
-		audio->eq_enable = 0;
-		if (copy_from_user(&audio->eq.num_bands, (void *) arg,
-				sizeof(audio->eq) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2))) {
-			rc = -EFAULT;
-			break;
-		}
-		audio->eq_enable = prev_state;
-		audio->eq_needs_commit = 1;
-		rc = 0;
-		break;
-	}
-
-	if (-EINVAL != rc)
-		return rc;
-
-	if (cmd == AUDIO_GET_EVENT) {
-		MM_DBG(" AUDIO_GET_EVENT\n");
-		if (mutex_trylock(&audio->get_event_lock)) {
-			rc = audmp3_process_event_req(audio,
-				(void __user *) arg);
-			mutex_unlock(&audio->get_event_lock);
-		} else
-			rc = -EBUSY;
-		return rc;
-	}
-
-	if (cmd == AUDIO_ABORT_GET_EVENT) {
-		audio->event_abort = 1;
-		wake_up(&audio->event_wait);
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		MM_DBG("AUDIO_START\n");
-		rc = audio_enable(audio);
-		if (!rc) {
-			rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-			MM_INFO("dec_state %d rc = %d\n", audio->dec_state, rc);
-
-			if (audio->dec_state != MSM_AUD_DECODER_STATE_SUCCESS)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		break;
-	case AUDIO_STOP:
-		MM_DBG("AUDIO_STOP\n");
-		rc = audio_disable(audio);
-		audio_ioport_reset(audio);
-		audio->stopped = 0;
-		break;
-	case AUDIO_FLUSH:
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audio_ioport_reset(audio);
-		if (audio->running) {
-			audpp_flush(audio->dec_id);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-
-	case AUDIO_SET_CONFIG: {
-		struct msm_audio_config config;
-		if (copy_from_user(&config, (void *) arg, sizeof(config))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (config.channel_count == 1) {
-			config.channel_count = AUDPP_CMD_PCM_INTF_MONO_V;
-		} else if (config.channel_count == 2) {
-			config.channel_count = AUDPP_CMD_PCM_INTF_STEREO_V;
-		} else {
-			rc = -EINVAL;
-			break;
-		}
-		audio->mfield = config.meta_field;
-		audio->out_sample_rate = config.sample_rate;
-		audio->out_channel_mode = config.channel_count;
-		rc = 0;
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config config;
-		config.buffer_size = (audio->out_dma_sz >> 1);
-		config.buffer_count = 2;
-		config.sample_rate = audio->out_sample_rate;
-		if (audio->out_channel_mode == AUDPP_CMD_PCM_INTF_MONO_V) {
-			config.channel_count = 1;
-		} else {
-			config.channel_count = 2;
-		}
-		config.meta_field = 0;
-		config.unused[0] = 0;
-		config.unused[1] = 0;
-		config.unused[2] = 0;
-		if (copy_to_user((void *) arg, &config, sizeof(config))) {
-			rc = -EFAULT;
-		} else {
-			rc = 0;
-		}
-		break;
-	}
-	case AUDIO_GET_PCM_CONFIG:{
-		struct msm_audio_pcm_config config;
-		config.pcm_feedback = audio->pcm_feedback;
-		config.buffer_count = PCM_BUF_MAX_COUNT;
-		config.buffer_size = PCM_BUFSZ_MIN;
-		if (copy_to_user((void *)arg, &config,
-			 sizeof(config)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-	case AUDIO_SET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			if (copy_from_user
-			    (&config, (void *)arg, sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-
-			if (config.pcm_feedback != audio->pcm_feedback) {
-				MM_ERR("Not sufficient permission to"
-					 "change the playback mode\n");
-				rc = -EACCES;
-				break;
-			}
-			if (audio->drv_status & ADRV_STATUS_AIO_INTF) {
-				rc = 0;
-				break;
-			}
-
-			if ((config.buffer_count > PCM_BUF_MAX_COUNT) ||
-			    (config.buffer_count == 1))
-				config.buffer_count = PCM_BUF_MAX_COUNT;
-
-			if (config.buffer_size < PCM_BUFSZ_MIN)
-				config.buffer_size = PCM_BUFSZ_MIN;
-
-			/* Check if pcm feedback is required */
-			if ((config.pcm_feedback) && (!audio->read_data)) {
-				MM_DBG("allocate PCM buffer %d\n",
-					config.buffer_count *
-					config.buffer_size);
-
-				handle = ion_alloc(audio->client,
-					(config.buffer_size *
-					config.buffer_count),
-					SZ_4K, ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-				if (IS_ERR_OR_NULL(handle)) {
-					MM_ERR("Unable to alloc I/P buffs\n");
-					rc = -ENOMEM;
-					break;
-				}
-
-				audio->input_buff_handle = handle;
-
-				rc = ion_phys(audio->client ,
-					handle, &addr, &len);
-				if (rc) {
-					MM_ERR("Invalid phy: %x sz: %x\n",
-						(unsigned int) addr,
-						(unsigned int) len);
-					rc = -ENOMEM;
-					break;
-				} else {
-					MM_INFO("Got valid phy: %x sz: %x\n",
-						(unsigned int) audio->read_phys,
-						(unsigned int) len);
-				}
-				audio->read_phys = (int32_t)addr;
-
-				rc = ion_handle_get_flags(audio->client,
-					handle, &ionflag);
-				if (rc) {
-					MM_ERR("could not get flags\n");
-					rc = -ENOMEM;
-					break;
-				}
-
-				audio->map_v_read = ion_map_kernel(
-					audio->client, handle);
-
-				if (IS_ERR(audio->map_v_read)) {
-					MM_ERR("map of read buf failed\n");
-					rc = -ENOMEM;
-					ion_free(audio->client, handle);
-				} else {
-					uint8_t index;
-					uint32_t offset = 0;
-					audio->read_data =
-						audio->map_v_read;
-					audio->buf_refresh = 0;
-					audio->pcm_buf_count =
-					    config.buffer_count;
-					audio->read_next = 0;
-					audio->fill_next = 0;
-
-					for (index = 0;
-					     index < config.buffer_count;
-					     index++) {
-						audio->in[index].data =
-						    audio->read_data + offset;
-						audio->in[index].addr =
-						    audio->read_phys + offset;
-						audio->in[index].size =
-						    config.buffer_size;
-						audio->in[index].used = 0;
-						offset += config.buffer_size;
-					}
-					rc = 0;
-					MM_DBG("read buf: phy addr \
-						0x%08x kernel addr 0x%08x\n",
-						audio->read_phys,
-						(int)audio->read_data);
-				}
-			} else {
-				rc = 0;
-			}
-			break;
-		}
-	case AUDIO_PAUSE:
-		MM_DBG("AUDIO_PAUSE %ld\n", arg);
-		rc = audpp_pause(audio->dec_id, (int) arg);
-		break;
-
-	case AUDIO_REGISTER_ION: {
-			struct msm_audio_ion_info info;
-			MM_DBG("AUDIO_REGISTER_ION\n");
-			if (copy_from_user(&info, (void *) arg, sizeof(info)))
-				rc = -EFAULT;
-			else
-				rc = audmp3_ion_add(audio, &info);
-			break;
-		}
-
-	case AUDIO_DEREGISTER_ION: {
-			struct msm_audio_ion_info info;
-			MM_DBG("AUDIO_DEREGISTER_ION\n");
-			if (copy_from_user(&info, (void *) arg, sizeof(info)))
-				rc = -EFAULT;
-			else
-				rc = audmp3_ion_remove(audio, &info);
-			break;
-		}
-	case AUDIO_ASYNC_WRITE:
-		if (audio->drv_status & ADRV_STATUS_FSYNC)
-			rc = -EBUSY;
-		else
-			rc = audmp3_aio_buf_add(audio, 1, (void __user *) arg);
-		break;
-
-	case AUDIO_ASYNC_READ:
-		if (audio->pcm_feedback)
-			rc = audmp3_aio_buf_add(audio, 0, (void __user *) arg);
-		else
-			rc = -EPERM;
-		break;
-
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-/* Only useful in tunnel-mode */
-int audmp3_async_fsync(struct audio *audio)
-{
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	/* Blocking client sends more data */
-	mutex_lock(&audio->lock);
-	audio->drv_status |= ADRV_STATUS_FSYNC;
-	mutex_unlock(&audio->lock);
-
-	mutex_lock(&audio->write_lock);
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->teos && audio->out_needed &&
-		list_empty(&audio->out_queue))
-		|| audio->wflush || audio->stopped);
-
-	if (audio->stopped || audio->wflush)
-		rc = -EBUSY;
-
-	mutex_unlock(&audio->write_lock);
-	mutex_lock(&audio->lock);
-	audio->drv_status &= ~ADRV_STATUS_FSYNC;
-	mutex_unlock(&audio->lock);
-
-	return rc;
-}
-
-int audmp3_sync_fsync(struct audio *audio)
-{
-	struct buffer *frame;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(!audio->out[0].used &&
-		!audio->out[1].used &&
-		audio->out_needed) || audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (audio->reserved) {
-		MM_DBG("send reserved byte\n");
-		frame = audio->out + audio->out_tail;
-		((char *) frame->data)[0] = audio->rsv_byte;
-		((char *) frame->data)[1] = 0;
-		frame->used = 2;
-		audio->drv_ops.send_data(audio, 0);
-
-		rc = wait_event_interruptible(audio->write_wait,
-			(!audio->out[0].used &&
-			!audio->out[1].used &&
-			audio->out_needed) || audio->wflush);
-
-		if (rc < 0)
-			goto done;
-		else if (audio->wflush) {
-			rc = -EBUSY;
-			goto done;
-		}
-	}
-
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		audio->teos || audio->wflush);
-
-	if (audio->wflush)
-		rc = -EBUSY;
-
-done:
-	mutex_unlock(&audio->write_lock);
-	return rc;
-}
-
-int audmp3_fsync(struct file *file, loff_t a, loff_t b, int datasync)
-{
-	struct audio *audio = file->private_data;
-
-	if (!audio->running || audio->pcm_feedback)
-		return -EINVAL;
-
-	return audio->drv_ops.fsync(audio);
-}
-
-static ssize_t audio_read(struct file *file, char __user *buf, size_t count,
-			  loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	int rc = 0;
-
-	if (audio->drv_status & ADRV_STATUS_AIO_INTF)
-		return -EPERM;
-	else if (!audio->pcm_feedback)
-		return 0; /* PCM feedback disabled. Nothing to read */
-
-	mutex_lock(&audio->read_lock);
-	MM_DBG("%d \n",	count);
-	while (count > 0) {
-		rc = wait_event_interruptible(
-			audio->read_wait,
-			(audio->in[audio->read_next].
-			used > 0) || (audio->stopped)
-			|| (audio->rflush));
-
-		if (rc < 0)
-			break;
-
-		if (audio->stopped || audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (count < audio->in[audio->read_next].used) {
-			/* Read must happen in frame boundary. Since
-			 * driver does not know frame size, read count
-			 * must be greater or equal
-			 * to size of PCM samples
-			 */
-			MM_DBG("no partial frame done reading\n");
-			break;
-		} else {
-			MM_DBG("read from in[%d]\n", audio->read_next);
-			/* order reads from the output buffer */
-			rmb();
-			if (copy_to_user
-			    (buf, audio->in[audio->read_next].data,
-			     audio->in[audio->read_next].used)) {
-				MM_ERR("invalid addr %x \n", (unsigned int)buf);
-				rc = -EFAULT;
-				break;
-			}
-			count -= audio->in[audio->read_next].used;
-			buf += audio->in[audio->read_next].used;
-			audio->in[audio->read_next].used = 0;
-			if ((++audio->read_next) == audio->pcm_buf_count)
-				audio->read_next = 0;
-			break;	/* Force to exit while loop
-				 * to prevent output thread
-				 * sleep too long if data is
-				 * not ready at this moment.
-				 */
-		}
-	}
-
-	/* don't feed output buffer to HW decoder during flushing
-	 * buffer refresh command will be sent once flush completes
-	 * send buf refresh command here can confuse HW decoder
-	 */
-	if (audio->buf_refresh && !audio->rflush) {
-		audio->buf_refresh = 0;
-		MM_DBG("kick start pcm feedback again\n");
-		audio->drv_ops.buffer_refresh(audio);
-	}
-
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		rc = buf - start;
-
-	MM_DBG("read %d bytes\n", rc);
-	return rc;
-}
-
-static int audmp3_process_eos(struct audio *audio,
-		const char __user *buf_start, unsigned short mfield_size)
-{
-	int rc = 0;
-	struct buffer *frame;
-	char *buf_ptr;
-
-	if (audio->reserved) {
-		MM_DBG("flush reserve byte\n");
-		frame = audio->out + audio->out_head;
-		buf_ptr = frame->data;
-		rc = wait_event_interruptible(audio->write_wait,
-			(frame->used == 0)
-			|| (audio->stopped)
-			|| (audio->wflush));
-		if (rc < 0)
-			goto done;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			goto done;
-		}
-
-		buf_ptr[0] = audio->rsv_byte;
-		buf_ptr[1] = 0;
-		audio->out_head ^= 1;
-		frame->mfield_sz = 0;
-		frame->used = 2;
-		audio->reserved = 0;
-		audio->drv_ops.send_data(audio, 0);
-	}
-
-	frame = audio->out + audio->out_head;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	audio->drv_ops.send_data(audio, 0);
-done:
-	return rc;
-}
-
-static ssize_t audio_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	size_t xfer;
-	char *cpy_ptr;
-	int rc = 0, eos_condition = AUDMP3_EOS_NONE;
-	unsigned dsize;
-	unsigned short mfield_size = 0;
-
-	if (audio->drv_status & ADRV_STATUS_AIO_INTF)
-		return -EPERM;
-
-	MM_DBG("cnt=%d\n", count);
-
-	mutex_lock(&audio->write_lock);
-	while (count > 0) {
-		frame = audio->out + audio->out_head;
-		cpy_ptr = frame->data;
-		dsize = 0;
-		rc = wait_event_interruptible(audio->write_wait,
-					      (frame->used == 0)
-					      || (audio->stopped)
-						  || (audio->wflush));
-		if (rc < 0)
-			break;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			break;
-		}
-		if (audio->mfield) {
-			if (buf == start) {
-				/* Processing beginning of user buffer */
-				if (__get_user(mfield_size,
-					(unsigned short __user *) buf)) {
-					rc = -EFAULT;
-					break;
-				} else  if (mfield_size > count) {
-					rc = -EINVAL;
-					break;
-				}
-				MM_DBG("mf offset_val %x\n", mfield_size);
-				if (copy_from_user(cpy_ptr, buf, mfield_size)) {
-					rc = -EFAULT;
-					break;
-				}
-				/* Check if EOS flag is set and buffer has
-				 * contains just meta field
-				 */
-				if (cpy_ptr[AUDMP3_EOS_FLG_OFFSET] &
-						 AUDMP3_EOS_FLG_MASK) {
-					MM_DBG("EOS SET\n");
-					eos_condition = AUDMP3_EOS_SET;
-					if (mfield_size == count) {
-						buf += mfield_size;
-						break;
-					} else
-						cpy_ptr[AUDMP3_EOS_FLG_OFFSET]
-							&= ~AUDMP3_EOS_FLG_MASK;
-				}
-				cpy_ptr += mfield_size;
-				count -= mfield_size;
-				dsize += mfield_size;
-				buf += mfield_size;
-			} else {
-				mfield_size = 0;
-				MM_DBG("continuous buffer\n");
-			}
-			frame->mfield_sz = mfield_size;
-		}
-
-		if (audio->reserved) {
-			MM_DBG("append reserved byte %x\n", audio->rsv_byte);
-			*cpy_ptr = audio->rsv_byte;
-			xfer = (count > ((frame->size - mfield_size) - 1)) ?
-				(frame->size - mfield_size) - 1 : count;
-			cpy_ptr++;
-			dsize += 1;
-			audio->reserved = 0;
-		} else
-			xfer = (count > (frame->size - mfield_size)) ?
-				(frame->size - mfield_size) : count;
-
-		if (copy_from_user(cpy_ptr, buf, xfer)) {
-			rc = -EFAULT;
-			break;
-		}
-
-		dsize += xfer;
-		if (dsize & 1) {
-			audio->rsv_byte = ((char *) frame->data)[dsize - 1];
-			MM_DBG("odd length buf reserve last byte %x\n",
-					audio->rsv_byte);
-			audio->reserved = 1;
-			dsize--;
-		}
-		count -= xfer;
-		buf += xfer;
-
-		if (dsize > 0) {
-			audio->out_head ^= 1;
-			frame->used = dsize;
-			audio->drv_ops.send_data(audio, 0);
-		}
-	}
-	if (eos_condition == AUDMP3_EOS_SET)
-		rc = audmp3_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	if (!rc) {
-		if (buf > start)
-			return buf - start;
-	}
-	return rc;
-}
-static void audmp3_reset_ion_region(struct audio *audio)
-{
-	struct audmp3_ion_region *region;
-	struct list_head *ptr, *next;
-
-	list_for_each_safe(ptr, next, &audio->ion_region_queue) {
-		region = list_entry(ptr, struct audmp3_ion_region, list);
-		list_del(&region->list);
-		ion_unmap_kernel(audio->client, region->handle);
-		ion_free(audio->client, region->handle);
-		kfree(region);
-	}
-
-	return;
-}
-
-static int audio_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	MM_INFO("audio instance 0x%08x freeing\n", (int)audio);
-	mutex_lock(&audio->lock);
-	audio_disable(audio);
-	if (audio->rmt_resource_released == 0)
-		rmt_put_resource(audio);
-	audio->drv_ops.out_flush(audio);
-	audio->drv_ops.in_flush(audio);
-	audmp3_reset_ion_region(audio);
-
-	msm_adsp_put(audio->audplay);
-	audpp_adec_free(audio->dec_id);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	unregister_early_suspend(&audio->suspend_ctl.node);
-#endif
-	audio->opened = 0;
-	audio->event_abort = 1;
-	wake_up(&audio->event_wait);
-	audmp3_reset_event_queue(audio);
-	mutex_unlock(&audio->lock);
-#ifdef CONFIG_DEBUG_FS
-	if (audio->dentry)
-		debugfs_remove(audio->dentry);
-#endif
-	if (!(audio->drv_status & ADRV_STATUS_AIO_INTF)) {
-		ion_unmap_kernel(audio->client, audio->output_buff_handle);
-		ion_free(audio->client, audio->output_buff_handle);
-		ion_unmap_kernel(audio->client, audio->input_buff_handle);
-		ion_free(audio->client, audio->input_buff_handle);
-	}
-	ion_client_destroy(audio->client);
-	kfree(audio);
-	return 0;
-}
-
-static void audmp3_post_event(struct audio *audio, int type,
-	union msm_audio_event_payload payload)
-{
-	struct audmp3_event *e_node = NULL;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-
-	if (!list_empty(&audio->free_event_queue)) {
-		e_node = list_first_entry(&audio->free_event_queue,
-			struct audmp3_event, list);
-		list_del(&e_node->list);
-	} else {
-		e_node = kmalloc(sizeof(struct audmp3_event), GFP_ATOMIC);
-		if (!e_node) {
-			MM_ERR("No mem to post event %d\n", type);
-			spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-			return;
-		}
-	}
-
-	e_node->event_type = type;
-	e_node->payload = payload;
-
-	list_add_tail(&e_node->list, &audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	wake_up(&audio->event_wait);
-}
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audmp3_suspend(struct early_suspend *h)
-{
-	struct audmp3_suspend_ctl *ctl =
-		container_of(h, struct audmp3_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audmp3_post_event(ctl->audio, AUDIO_EVENT_SUSPEND, payload);
-}
-
-static void audmp3_resume(struct early_suspend *h)
-{
-	struct audmp3_suspend_ctl *ctl =
-		container_of(h, struct audmp3_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audmp3_post_event(ctl->audio, AUDIO_EVENT_RESUME, payload);
-}
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-static ssize_t audmp3_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static ssize_t audmp3_debug_read(struct file *file, char __user *buf,
-			  size_t count, loff_t *ppos)
-{
-	const int debug_bufmax = 4096;
-	static char buffer[4096];
-	int n = 0, i;
-	struct audio *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	n = scnprintf(buffer, debug_bufmax, "opened %d\n", audio->opened);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "enabled %d\n", audio->enabled);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "stopped %d\n", audio->stopped);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "pcm_feedback %d\n", audio->pcm_feedback);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_buf_sz %d\n", audio->out[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "pcm_buf_count %d \n", audio->pcm_buf_count);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "pcm_buf_sz %d \n", audio->in[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "volume %x \n", audio->vol_pan.volume);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "sample rate %d \n", audio->out_sample_rate);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-		"channel mode %d \n", audio->out_channel_mode);
-	mutex_unlock(&audio->lock);
-	/* Following variables are only useful for debugging when
-	 * when playback halts unexpectedly. Thus, no mutual exclusion
-	 * enforced
-	 */
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "wflush %d\n", audio->wflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "rflush %d\n", audio->rflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "running %d \n", audio->running);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				"dec state %d \n", audio->dec_state);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_needed %d \n", audio->out_needed);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_head %d \n", audio->out_head);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_tail %d \n", audio->out_tail);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out[0].used %d \n", audio->out[0].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out[1].used %d \n", audio->out[1].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "buffer_refresh %d \n", audio->buf_refresh);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "read_next %d \n", audio->read_next);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "fill_next %d \n", audio->fill_next);
-	for (i = 0; i < audio->pcm_buf_count; i++)
-		n += scnprintf(buffer + n, debug_bufmax - n,
-			"in[%d].size %d \n", i, audio->in[i].used);
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations audmp3_debug_fops = {
-	.read = audmp3_debug_read,
-	.open = audmp3_debug_open,
-};
-#endif
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-
-	struct audio *audio = NULL;
-	int rc, i, dec_attrb, decid;
-	struct audmp3_event *e_node = NULL;
-	unsigned mem_sz = DMASZ_MAX;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	struct ion_client *client = NULL;
-	int len = 0;
-
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_mp3_" + 5];
-#endif
-
-	/* Allocate audio instance, set to zero */
-	audio = kzalloc(sizeof(struct audio), GFP_KERNEL);
-	if (!audio) {
-		MM_ERR("no memory to allocate audio instance \n");
-		rc = -ENOMEM;
-		goto done;
-	}
-	MM_INFO("audio instance 0x%08x created\n", (int)audio);
-
-	/* Allocate the decoder */
-	dec_attrb = AUDDEC_DEC_MP3;
-	if ((file->f_mode & FMODE_WRITE) &&
-			(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_NONTUNNEL;
-		audio->pcm_feedback = NON_TUNNEL_MODE_PLAYBACK;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_TUNNEL;
-		audio->pcm_feedback = TUNNEL_MODE_PLAYBACK;
-	} else {
-		kfree(audio);
-		rc = -EACCES;
-		goto done;
-	}
-
-	decid = audpp_adec_alloc(dec_attrb, &audio->module_name,
-			&audio->queue_id);
-	if (decid < 0) {
-		MM_ERR("No free decoder available, freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENODEV;
-		kfree(audio);
-		goto done;
-	}
-	audio->dec_id = decid & MSM_AUD_DECODER_MASK;
-
-	client = msm_ion_client_create(UINT_MAX, "Audio_MP3_Client");
-	if (IS_ERR_OR_NULL(client)) {
-		pr_err("Unable to create ION client\n");
-		rc = -ENOMEM;
-		goto client_create_error;
-	}
-	audio->client = client;
-
-	/* Non AIO interface */
-	if (!(file->f_flags & O_NONBLOCK)) {
-
-		MM_DBG("memsz = %d\n", mem_sz);
-
-		handle = ion_alloc(client, mem_sz, SZ_4K,
-			ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-		if (IS_ERR_OR_NULL(handle)) {
-			MM_ERR("Unable to create allocate O/P buffers\n");
-			rc = -ENOMEM;
-			goto output_buff_alloc_error;
-		}
-		audio->output_buff_handle = handle;
-
-		rc = ion_phys(client , handle, &addr, &len);
-		if (rc) {
-			MM_ERR("O/P buffers:Invalid phy: %x sz: %x\n",
-				(unsigned int) addr, (unsigned int) len);
-			goto output_buff_get_phys_error;
-		} else {
-			MM_INFO("O/P buffers:valid phy: %x sz: %x\n",
-				(unsigned int) addr, (unsigned int) len);
-		}
-		audio->phys = (int32_t)addr;
-
-
-		rc = ion_handle_get_flags(client, handle, &ionflag);
-		if (rc) {
-			MM_ERR("could not get flags for the handle\n");
-			goto output_buff_get_flags_error;
-		}
-
-		audio->map_v_write = ion_map_kernel(client, handle);
-		if (IS_ERR(audio->map_v_write)) {
-			MM_ERR("could not map write buffers\n");
-			rc = -ENOMEM;
-			goto output_buff_map_error;
-		}
-		audio->data = audio->map_v_write;
-		MM_DBG("write buf: phy addr 0x%08x kernel addr 0x%08x\n",
-			audio->phys, (int)audio->data);
-
-		audio->out_dma_sz = mem_sz;
-	}
-
-	if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK) {
-		rc = audmgr_open(&audio->audmgr);
-		if (rc) {
-			MM_ERR("audmgr open failed, freeing instance \
-					0x%08x\n", (int)audio);
-			if (!(file->f_flags & O_NONBLOCK))
-				goto err;
-			else
-				goto resource_err;
-		}
-	}
-
-	rc = msm_adsp_get(audio->module_name, &audio->audplay,
-		&audplay_adsp_ops, audio);
-
-	if (rc) {
-		MM_ERR("failed to get %s module, freeing instance 0x%08x\n",
-				audio->module_name, (int)audio);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_close(&audio->audmgr);
-		if (!(file->f_flags & O_NONBLOCK))
-			goto err;
-		else
-			goto resource_err;
-	}
-
-	rc = rmt_get_resource(audio);
-	if (rc) {
-		MM_ERR("ADSP resources are not available for MP3 session \
-			 0x%08x on decoder: %d\n", (int)audio, audio->dec_id);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_close(&audio->audmgr);
-		msm_adsp_put(audio->audplay);
-		if (!(file->f_flags & O_NONBLOCK))
-			goto err;
-		else
-			goto resource_err;
-	}
-
-	if (file->f_flags & O_NONBLOCK) {
-		MM_DBG("set to aio interface\n");
-		audio->drv_status |= ADRV_STATUS_AIO_INTF;
-		audio->drv_ops.pcm_buf_update = audmp3_async_pcm_buf_update;
-		audio->drv_ops.buffer_refresh = audmp3_async_buffer_refresh;
-		audio->drv_ops.send_data = audmp3_async_send_data;
-		audio->drv_ops.out_flush = audmp3_async_flush;
-		audio->drv_ops.in_flush = audmp3_async_flush_pcm_buf;
-		audio->drv_ops.fsync = audmp3_async_fsync;
-	} else {
-		MM_DBG("set to std io interface\n");
-		audio->drv_ops.pcm_buf_update = audio_update_pcm_buf_entry;
-		audio->drv_ops.buffer_refresh = audplay_buffer_refresh;
-		audio->drv_ops.send_data = audplay_send_data;
-		audio->drv_ops.out_flush = audio_flush;
-		audio->drv_ops.in_flush = audio_flush_pcm_buf;
-		audio->drv_ops.fsync = audmp3_sync_fsync;
-		audio->out[0].data = audio->data + 0;
-		audio->out[0].addr = audio->phys + 0;
-		audio->out[0].size = (audio->out_dma_sz >> 1);
-
-		audio->out[1].data = audio->data + audio->out[0].size;
-		audio->out[1].addr = audio->phys + audio->out[0].size;
-		audio->out[1].size = audio->out[0].size;
-	}
-
-	/* Initialize all locks of audio instance */
-	mutex_init(&audio->lock);
-	mutex_init(&audio->write_lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->get_event_lock);
-	spin_lock_init(&audio->dsp_lock);
-	init_waitqueue_head(&audio->write_wait);
-	init_waitqueue_head(&audio->read_wait);
-	INIT_LIST_HEAD(&audio->out_queue);
-	INIT_LIST_HEAD(&audio->in_queue);
-	INIT_LIST_HEAD(&audio->ion_region_queue);
-	INIT_LIST_HEAD(&audio->free_event_queue);
-	INIT_LIST_HEAD(&audio->event_queue);
-	init_waitqueue_head(&audio->wait);
-	init_waitqueue_head(&audio->event_wait);
-	spin_lock_init(&audio->event_queue_lock);
-
-	audio->out_sample_rate = 44100;
-	audio->out_channel_mode = AUDPP_CMD_PCM_INTF_STEREO_V;
-	audio->vol_pan.volume = 0x2000;
-
-	audio->drv_ops.out_flush(audio);
-
-	file->private_data = audio;
-	audio->opened = 1;
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof name, "msm_mp3_%04x", audio->dec_id);
-	audio->dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
-			NULL, (void *) audio, &audmp3_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		MM_DBG("debugfs_create_file failed\n");
-#endif
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	audio->suspend_ctl.node.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
-	audio->suspend_ctl.node.resume = audmp3_resume;
-	audio->suspend_ctl.node.suspend = audmp3_suspend;
-	audio->suspend_ctl.audio = audio;
-	register_early_suspend(&audio->suspend_ctl.node);
-#endif
-	for (i = 0; i < AUDMP3_EVENT_NUM; i++) {
-		e_node = kmalloc(sizeof(struct audmp3_event), GFP_KERNEL);
-		if (e_node)
-			list_add_tail(&e_node->list, &audio->free_event_queue);
-		else {
-			MM_ERR("event pkt alloc failed\n");
-			break;
-		}
-	}
-
-done:
-	return rc;
-err:
-	ion_unmap_kernel(client, audio->output_buff_handle);
-output_buff_map_error:
-output_buff_get_flags_error:
-output_buff_get_phys_error:
-	ion_free(client, audio->output_buff_handle);
-output_buff_alloc_error:
-	ion_client_destroy(client);
-client_create_error:
-resource_err:
-	audpp_adec_free(audio->dec_id);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_mp3_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audio_open,
-	.release	= audio_release,
-	.read		= audio_read,
-	.write		= audio_write,
-	.unlocked_ioctl	= audio_ioctl,
-	.fsync = audmp3_fsync,
-};
-
-struct miscdevice audio_mp3_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_mp3",
-	.fops	= &audio_mp3_fops,
-};
-
-static int __init audio_init(void)
-{
-	return misc_register(&audio_mp3_misc);
-}
-
-static void __exit audio_exit(void)
-{
-	misc_deregister(&audio_mp3_misc);
-}
-
-module_init(audio_init);
-module_exit(audio_exit);
-
-MODULE_DESCRIPTION("MSM MP3 driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5/audio_mvs.c b/arch/arm/mach-msm/qdsp5/audio_mvs.c
deleted file mode 100644
index d1aba82..0000000
--- a/arch/arm/mach-msm/qdsp5/audio_mvs.c
+++ /dev/null
@@ -1,1746 +0,0 @@
-/* Copyright (c) 2011-2013, The Linux Foundation. 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.
- *
- */
-#include <linux/fs.h>
-#include <linux/kthread.h>
-#include <linux/list.h>
-#include <linux/miscdevice.h>
-#include <linux/module.h>
-#include <linux/msm_audio_mvs.h>
-#include <linux/mutex.h>
-#include <linux/slab.h>
-#include <linux/uaccess.h>
-#include <linux/wakelock.h>
-#include <linux/pm_qos.h>
-
-#include <mach/debug_mm.h>
-#include <mach/msm_rpcrouter.h>
-#include <mach/cpuidle.h>
-
-#define MVS_PROG 0x30000014
-#define MVS_VERS 0x00030001
-#define MVS_VERS_COMP_VER2 0x00060001
-#define MVS_VERS_COMP_VER3 0x00030001
-
-
-#define MVS_CLIENT_ID_VOIP 0x00000003
-
-#define MVS_ACQUIRE_PROC 4
-#define MVS_ENABLE_PROC 5
-#define MVS_RELEASE_PROC 6
-#define MVS_AMR_SET_AMR_MODE_PROC 7
-#define MVS_AMR_SET_AWB_MODE_PROC 8
-#define MVS_VOC_SET_FRAME_RATE_PROC 10
-#define MVS_GSM_SET_DTX_MODE_PROC 11
-#define MVS_G729A_SET_MODE_PROC 12
-#define MVS_G711_GET_MODE_PROC 14
-#define MVS_G711_SET_MODE_PROC 15
-#define MVS_G711A_GET_MODE_PROC 16
-#define MVS_G711A_SET_MODE_PROC 17
-#define MVS_G722_SET_MODE_PROC 20
-#define MVS_G722_GET_MODE_PROC 21
-#define MVS_SET_DTX_MODE_PROC 22
-
-#define MVS_EVENT_CB_TYPE_PROC 1
-#define MVS_PACKET_UL_FN_TYPE_PROC 2
-#define MVS_PACKET_DL_FN_TYPE_PROC 3
-
-#define MVS_CB_FUNC_ID 0xAAAABBBB
-#define MVS_UL_CB_FUNC_ID 0xBBBBCCCC
-#define MVS_DL_CB_FUNC_ID 0xCCCCDDDD
-
-#define MVS_FRAME_MODE_VOC_TX 1
-#define MVS_FRAME_MODE_VOC_RX 2
-#define MVS_FRAME_MODE_AMR_UL 3
-#define MVS_FRAME_MODE_AMR_DL 4
-#define MVS_FRAME_MODE_GSM_UL 5
-#define MVS_FRAME_MODE_GSM_DL 6
-#define MVS_FRAME_MODE_HR_UL 7
-#define MVS_FRAME_MODE_HR_DL 8
-#define MVS_FRAME_MODE_G711_UL 9
-#define MVS_FRAME_MODE_G711_DL 10
-#define MVS_FRAME_MODE_PCM_UL 13
-#define MVS_FRAME_MODE_PCM_DL 14
-#define MVS_FRAME_MODE_PCM_WB_UL 23
-#define MVS_FRAME_MODE_PCM_WB_DL 24
-#define MVS_FRAME_MODE_G729A_UL 17
-#define MVS_FRAME_MODE_G729A_DL 18
-#define MVS_FRAME_MODE_G711A_UL 19
-#define MVS_FRAME_MODE_G711A_DL 20
-#define MVS_FRAME_MODE_G722_UL 21
-#define MVS_FRAME_MODE_G722_DL 22
-
-
-
-#define MVS_PKT_CONTEXT_ISR 0x00000001
-
-#define RPC_TYPE_REQUEST 0
-#define RPC_TYPE_REPLY 1
-
-#define RPC_STATUS_FAILURE 0
-#define RPC_STATUS_SUCCESS 1
-#define RPC_STATUS_REJECT 1
-
-#define RPC_COMMON_HDR_SZ  (sizeof(uint32_t) * 2)
-#define RPC_REQUEST_HDR_SZ (sizeof(struct rpc_request_hdr))
-#define RPC_REPLY_HDR_SZ   (sizeof(uint32_t) * 3)
-
-enum audio_mvs_state_type {
-	AUDIO_MVS_CLOSED,
-	AUDIO_MVS_OPENED,
-	AUDIO_MVS_STARTED,
-	AUDIO_MVS_STOPPED
-};
-
-enum audio_mvs_event_type {
-	AUDIO_MVS_COMMAND,
-	AUDIO_MVS_MODE,
-	AUDIO_MVS_NOTIFY
-};
-
-enum audio_mvs_cmd_status_type {
-	AUDIO_MVS_CMD_FAILURE,
-	AUDIO_MVS_CMD_BUSY,
-	AUDIO_MVS_CMD_SUCCESS
-};
-
-enum audio_mvs_mode_status_type {
-	AUDIO_MVS_MODE_NOT_AVAIL,
-	AUDIO_MVS_MODE_INIT,
-	AUDIO_MVS_MODE_READY
-};
-
-enum audio_mvs_pkt_status_type {
-	AUDIO_MVS_PKT_NORMAL,
-	AUDIO_MVS_PKT_FAST,
-	AUDIO_MVS_PKT_SLOW
-};
-
-/* Parameters required for MVS acquire. */
-struct rpc_audio_mvs_acquire_args {
-	uint32_t client_id;
-	uint32_t cb_func_id;
-};
-
-struct audio_mvs_acquire_msg {
-	struct rpc_request_hdr rpc_hdr;
-	struct rpc_audio_mvs_acquire_args acquire_args;
-};
-
-/* Parameters required for MVS enable. */
-struct rpc_audio_mvs_enable_args {
-	uint32_t client_id;
-	uint32_t mode;
-	uint32_t ul_cb_func_id;
-	uint32_t dl_cb_func_id;
-	uint32_t context;
-};
-
-struct audio_mvs_enable_msg {
-	struct rpc_request_hdr rpc_hdr;
-	struct rpc_audio_mvs_enable_args enable_args;
-};
-
-/* Parameters required for MVS release. */
-struct audio_mvs_release_msg {
-	struct rpc_request_hdr rpc_hdr;
-	uint32_t client_id;
-};
-
-/* Parameters required for setting AMR mode. */
-struct audio_mvs_set_amr_mode_msg {
-	struct rpc_request_hdr rpc_hdr;
-	uint32_t amr_mode;
-};
-
-/* Parameters required for setting DTX. */
-struct audio_mvs_set_dtx_mode_msg {
-	struct rpc_request_hdr rpc_hdr;
-	uint32_t dtx_mode;
-};
-
-/* Parameters required for setting EVRC mode. */
-struct audio_mvs_set_voc_mode_msg {
-	struct rpc_request_hdr rpc_hdr;
-	uint32_t max_rate;
-	uint32_t min_rate;
-};
-
-/* Parameters for G711 mode */
-struct audio_mvs_set_g711_mode_msg {
-	struct rpc_request_hdr rpc_hdr;
-	uint32_t g711_mode;
-};
-
-/* Parameters for G729 mode */
-struct audio_mvs_set_g729_mode_msg {
-	struct rpc_request_hdr rpc_hdr;
-	uint32_t g729_mode;
-};
-
-/* Parameters for G722 mode */
-struct audio_mvs_set_g722_mode_msg {
-	struct rpc_request_hdr rpc_hdr;
-	uint32_t g722_mode;
-};
-
-
-/* Parameters for G711A mode */
-struct audio_mvs_set_g711A_mode_msg {
-	struct rpc_request_hdr rpc_hdr;
-	uint32_t g711A_mode;
-};
-
-/* Parameters for EFR FR and HR mode */
-struct audio_mvs_set_efr_mode_msg {
-	struct rpc_request_hdr rpc_hdr;
-	uint32_t efr_mode;
-};
-
-union audio_mvs_event_data {
-	struct mvs_ev_command_type {
-		uint32_t event;
-		uint32_t client_id;
-		uint32_t cmd_status;
-	} mvs_ev_command_type;
-
-	struct mvs_ev_mode_type {
-		uint32_t event;
-		uint32_t client_id;
-		uint32_t mode_status;
-		uint32_t mode;
-	} mvs_ev_mode_type;
-
-	struct mvs_ev_notify_type {
-		uint32_t event;
-		uint32_t client_id;
-		uint32_t buf_dir;
-		uint32_t max_frames;
-	} mvs_ev_notify_type;
-};
-
-struct audio_mvs_cb_func_args {
-	uint32_t cb_func_id;
-	uint32_t valid_ptr;
-	uint32_t event;
-	union audio_mvs_event_data event_data;
-};
-
-struct audio_mvs_frame_info_hdr {
-	uint32_t frame_mode;
-	uint32_t mvs_mode;
-	uint16_t buf_free_cnt;
-};
-
-struct audio_mvs_ul_reply {
-	struct rpc_reply_hdr reply_hdr;
-	uint32_t valid_pkt_status_ptr;
-	uint32_t pkt_status;
-};
-
-struct audio_mvs_dl_cb_func_args {
-	uint32_t cb_func_id;
-
-	uint32_t valid_ptr;
-	uint32_t frame_mode;
-	uint32_t frame_mode_ignore;
-
-	struct audio_mvs_frame_info_hdr frame_info_hdr;
-
-	uint32_t amr_frame;
-	uint32_t amr_mode;
-};
-/*general codec parameters includes AMR, G711A, PCM
-G729, VOC and HR vocoders
-*/
-struct gnr_cdc_param {
-	uint32_t param1;
-	uint32_t param2;
-	uint32_t valid_pkt_status_ptr;
-	uint32_t pkt_status;
-};
-/*G711 codec parameter*/
-struct g711_param {
-	uint32_t param1;
-	uint32_t valid_pkt_status_ptr;
-	uint32_t pkt_status;
-};
-
-union codec_param {
-	struct gnr_cdc_param gnr_arg;
-	struct g711_param g711_arg;
-};
-
-struct audio_mvs_dl_reply {
-	struct rpc_reply_hdr reply_hdr;
-
-	uint32_t voc_pkt[MVS_MAX_VOC_PKT_SIZE/4];
-
-	uint32_t valid_frame_info_ptr;
-	uint32_t frame_mode;
-	uint32_t frame_mode_again;
-
-	struct audio_mvs_frame_info_hdr frame_info_hdr;
-	union codec_param cdc_param;
-};
-
-struct audio_mvs_buf_node {
-	struct list_head list;
-	struct msm_audio_mvs_frame frame;
-};
-
-/* Each buffer is 20 ms, queue holds 200 ms of data. */
-#define MVS_MAX_Q_LEN 10
-
-struct audio_mvs_info_type {
-	enum audio_mvs_state_type state;
-	uint32_t frame_mode;
-	uint32_t mvs_mode;
-	uint32_t buf_free_cnt;
-	uint32_t rate_type;
-	uint32_t dtx_mode;
-
-	struct msm_rpc_endpoint *rpc_endpt;
-	uint32_t rpc_prog;
-	uint32_t rpc_ver;
-	uint32_t rpc_status;
-
-	uint8_t *mem_chunk;
-
-	struct list_head in_queue;
-	struct list_head free_in_queue;
-
-	struct list_head out_queue;
-	struct list_head free_out_queue;
-
-	struct task_struct *task;
-
-	wait_queue_head_t wait;
-	wait_queue_head_t mode_wait;
-	wait_queue_head_t in_wait;
-	wait_queue_head_t out_wait;
-
-	struct mutex lock;
-	struct mutex in_lock;
-	struct mutex out_lock;
-
-	struct wake_lock suspend_lock;
-	struct pm_qos_request pm_qos_req;
-
-	struct completion complete;
-};
-
-static struct audio_mvs_info_type audio_mvs_info;
-
-static int audio_mvs_setup_mode(struct audio_mvs_info_type *audio)
-{
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	switch (audio->mvs_mode) {
-	case MVS_MODE_AMR:
-	case MVS_MODE_AMR_WB: {
-		struct audio_mvs_set_amr_mode_msg set_amr_mode_msg;
-		struct audio_mvs_set_dtx_mode_msg set_dtx_mode_msg;
-
-		/* Set AMR mode. */
-		memset(&set_amr_mode_msg, 0, sizeof(set_amr_mode_msg));
-		set_amr_mode_msg.amr_mode = cpu_to_be32(audio->rate_type);
-
-		if (audio->mvs_mode == MVS_MODE_AMR) {
-			msm_rpc_setup_req(&set_amr_mode_msg.rpc_hdr,
-					  audio->rpc_prog,
-					  audio->rpc_ver,
-					  MVS_AMR_SET_AMR_MODE_PROC);
-		} else {
-			msm_rpc_setup_req(&set_amr_mode_msg.rpc_hdr,
-					  audio->rpc_prog,
-					  audio->rpc_ver,
-					  MVS_AMR_SET_AWB_MODE_PROC);
-		}
-
-		audio->rpc_status = RPC_STATUS_FAILURE;
-		rc = msm_rpc_write(audio->rpc_endpt,
-				   &set_amr_mode_msg,
-				   sizeof(set_amr_mode_msg));
-
-		if (rc >= 0) {
-			MM_DBG("RPC write for set amr mode done\n");
-
-			/* Save the MVS configuration information. */
-			audio->frame_mode = MVS_FRAME_MODE_AMR_DL;
-
-			/* Disable DTX. */
-			memset(&set_dtx_mode_msg, 0, sizeof(set_dtx_mode_msg));
-			set_dtx_mode_msg.dtx_mode = cpu_to_be32(0);
-
-			msm_rpc_setup_req(&set_dtx_mode_msg.rpc_hdr,
-					  audio->rpc_prog,
-					  audio->rpc_ver,
-					  MVS_SET_DTX_MODE_PROC);
-
-			audio->rpc_status = RPC_STATUS_FAILURE;
-			rc = msm_rpc_write(audio->rpc_endpt,
-					   &set_dtx_mode_msg,
-					   sizeof(set_dtx_mode_msg));
-
-			if (rc >= 0) {
-				MM_DBG("RPC write for set dtx done\n");
-
-				rc = 0;
-			}
-		} else {
-			MM_ERR("RPC write for set amr mode failed %d\n", rc);
-		}
-		break;
-	}
-	case MVS_MODE_PCM:
-	case MVS_MODE_LINEAR_PCM: {
-		/* PCM does not have any params to be set.
-		Save the MVS configuration information. */
-		audio->rate_type = MVS_AMR_MODE_UNDEF;
-		audio->frame_mode = MVS_FRAME_MODE_PCM_DL;
-		break;
-	}
-	case MVS_MODE_PCM_WB: {
-		audio->rate_type = MVS_AMR_MODE_UNDEF;
-		audio->frame_mode = MVS_FRAME_MODE_PCM_WB_DL;
-		break;
-	}
-	case MVS_MODE_IS127:
-	case MVS_MODE_IS733:
-	case MVS_MODE_4GV_NB:
-	case MVS_MODE_4GV_WB: {
-		struct audio_mvs_set_voc_mode_msg set_voc_mode_msg;
-
-		/* Set EVRC mode. */
-		memset(&set_voc_mode_msg, 0, sizeof(set_voc_mode_msg));
-		set_voc_mode_msg.min_rate = cpu_to_be32(audio->rate_type);
-		set_voc_mode_msg.max_rate = cpu_to_be32(audio->rate_type);
-
-		MM_DBG("audio->mvs_mode %d audio->rate_type %d\n",
-			audio->mvs_mode, audio->rate_type);
-		msm_rpc_setup_req(&set_voc_mode_msg.rpc_hdr,
-				  audio->rpc_prog,
-				  audio->rpc_ver,
-				  MVS_VOC_SET_FRAME_RATE_PROC);
-
-		audio->rpc_status = RPC_STATUS_FAILURE;
-		rc = msm_rpc_write(audio->rpc_endpt,
-				   &set_voc_mode_msg,
-				   sizeof(set_voc_mode_msg));
-
-		if (rc >= 0) {
-			MM_DBG("RPC write for set voc mode done\n");
-
-			/* Save the MVS configuration information. */
-			audio->frame_mode = MVS_FRAME_MODE_VOC_RX;
-
-			rc = 0;
-		} else {
-			MM_ERR("RPC write for set voc mode failed %d\n", rc);
-		}
-		break;
-	}
-	case MVS_MODE_G711: {
-		struct audio_mvs_set_g711_mode_msg set_g711_mode_msg;
-
-		/* Set G711 mode. */
-		memset(&set_g711_mode_msg, 0, sizeof(set_g711_mode_msg));
-		set_g711_mode_msg.g711_mode = cpu_to_be32(audio->rate_type);
-
-		MM_DBG("mode of g711:%d\n", set_g711_mode_msg.g711_mode);
-
-		msm_rpc_setup_req(&set_g711_mode_msg.rpc_hdr,
-				 audio->rpc_prog,
-				 audio->rpc_ver,
-				 MVS_G711_SET_MODE_PROC);
-
-		audio->rpc_status = RPC_STATUS_FAILURE;
-		rc = msm_rpc_write(audio->rpc_endpt,
-				  &set_g711_mode_msg,
-				  sizeof(set_g711_mode_msg));
-
-		if (rc >= 0) {
-			MM_DBG("RPC write for set g711 mode done\n");
-			/* Save the MVS configuration information. */
-			audio->frame_mode = MVS_FRAME_MODE_G711_DL;
-
-			rc = 0;
-		} else {
-		       MM_ERR("RPC write for set g711 mode failed %d\n", rc);
-		}
-		break;
-	}
-	case MVS_MODE_G729A: {
-		struct audio_mvs_set_g729_mode_msg set_g729_mode_msg;
-
-		/* Set G729 mode. */
-		memset(&set_g729_mode_msg, 0, sizeof(set_g729_mode_msg));
-		set_g729_mode_msg.g729_mode = cpu_to_be32(audio->dtx_mode);
-
-		MM_DBG("mode of g729:%d\n",
-			       set_g729_mode_msg.g729_mode);
-
-		msm_rpc_setup_req(&set_g729_mode_msg.rpc_hdr,
-				 audio->rpc_prog,
-				 audio->rpc_ver,
-				 MVS_G729A_SET_MODE_PROC);
-
-		audio->rpc_status = RPC_STATUS_FAILURE;
-		rc = msm_rpc_write(audio->rpc_endpt,
-				  &set_g729_mode_msg,
-				  sizeof(set_g729_mode_msg));
-
-		if (rc >= 0) {
-			MM_DBG("RPC write for set g729 mode done\n");
-
-			/* Save the MVS configuration information. */
-			audio->frame_mode = MVS_FRAME_MODE_G729A_DL;
-
-			rc = 0;
-		} else {
-		       MM_ERR("RPC write for set g729 mode failed %d\n", rc);
-		}
-		break;
-	}
-	case MVS_MODE_G722: {
-		struct audio_mvs_set_g722_mode_msg set_g722_mode_msg;
-
-		/* Set G722 mode. */
-		memset(&set_g722_mode_msg, 0, sizeof(set_g722_mode_msg));
-		set_g722_mode_msg.g722_mode = cpu_to_be32(audio->rate_type);
-
-		MM_DBG("mode of g722:%d\n",
-		      set_g722_mode_msg.g722_mode);
-
-		msm_rpc_setup_req(&set_g722_mode_msg.rpc_hdr,
-			audio->rpc_prog,
-			audio->rpc_ver,
-			MVS_G722_SET_MODE_PROC);
-
-		audio->rpc_status = RPC_STATUS_FAILURE;
-		rc = msm_rpc_write(audio->rpc_endpt,
-			 &set_g722_mode_msg,
-			 sizeof(set_g722_mode_msg));
-
-		if (rc >= 0) {
-			MM_DBG("RPC write for set g722 mode done\n");
-
-			/* Save the MVS configuration information. */
-			audio->frame_mode = MVS_FRAME_MODE_G722_DL;
-
-			rc = 0;
-		}
-		break;
-	}
-	case MVS_MODE_G711A: {
-		struct audio_mvs_set_g711A_mode_msg set_g711A_mode_msg;
-		struct audio_mvs_set_dtx_mode_msg set_dtx_mode_msg;
-
-		/* Set G711A mode. */
-		memset(&set_g711A_mode_msg, 0, sizeof(set_g711A_mode_msg));
-		set_g711A_mode_msg.g711A_mode = cpu_to_be32(audio->rate_type);
-
-		MM_DBG("mode of g711A:%d\n",
-		       set_g711A_mode_msg.g711A_mode);
-
-		msm_rpc_setup_req(&set_g711A_mode_msg.rpc_hdr,
-			 audio->rpc_prog,
-			 audio->rpc_ver,
-			 MVS_G711A_SET_MODE_PROC);
-
-		audio->rpc_status = RPC_STATUS_FAILURE;
-		rc = msm_rpc_write(audio->rpc_endpt,
-			  &set_g711A_mode_msg,
-			  sizeof(set_g711A_mode_msg));
-
-		if (rc >= 0) {
-			MM_DBG("RPC write for set g711A mode done\n");
-
-			/* Save the MVS configuration information. */
-			audio->frame_mode = MVS_FRAME_MODE_G711A_DL;
-			/* Set DTX MODE. */
-			memset(&set_dtx_mode_msg, 0, sizeof(set_dtx_mode_msg));
-			set_dtx_mode_msg.dtx_mode =
-				cpu_to_be32((audio->dtx_mode));
-
-			msm_rpc_setup_req(&set_dtx_mode_msg.rpc_hdr,
-					  audio->rpc_prog,
-					  audio->rpc_ver,
-					  MVS_SET_DTX_MODE_PROC);
-
-			audio->rpc_status = RPC_STATUS_FAILURE;
-			rc = msm_rpc_write(audio->rpc_endpt,
-					   &set_dtx_mode_msg,
-					   sizeof(set_dtx_mode_msg));
-
-			if (rc >= 0) {
-				MM_DBG("RPC write for set dtx done\n");
-
-				rc = 0;
-			}
-			rc = 0;
-		} else {
-		MM_ERR("RPC write for set g711A mode failed %d\n", rc);
-		}
-		break;
-	}
-	case MVS_MODE_EFR:
-	case MVS_MODE_FR:
-	case MVS_MODE_HR: {
-		struct audio_mvs_set_efr_mode_msg set_efr_mode_msg;
-
-		/* Set G729 mode. */
-		memset(&set_efr_mode_msg, 0, sizeof(set_efr_mode_msg));
-		set_efr_mode_msg.efr_mode = cpu_to_be32(audio->dtx_mode);
-
-		MM_DBG("mode of EFR, FR and HR:%d\n",
-			       set_efr_mode_msg.efr_mode);
-
-		msm_rpc_setup_req(&set_efr_mode_msg.rpc_hdr,
-				 audio->rpc_prog,
-				 audio->rpc_ver,
-				 MVS_GSM_SET_DTX_MODE_PROC);
-
-		audio->rpc_status = RPC_STATUS_FAILURE;
-		rc = msm_rpc_write(audio->rpc_endpt,
-				  &set_efr_mode_msg,
-				  sizeof(set_efr_mode_msg));
-
-		if (rc >= 0) {
-			MM_DBG("RPC write for set EFR, FR and HR mode done\n");
-
-			/* Save the MVS configuration information. */
-			if ((audio->mvs_mode == MVS_MODE_EFR) ||
-				(audio->mvs_mode == MVS_MODE_FR))
-				audio->frame_mode = MVS_FRAME_MODE_GSM_DL;
-			if (audio->mvs_mode == MVS_MODE_HR)
-				audio->frame_mode = MVS_FRAME_MODE_HR_DL;
-
-			rc = 0;
-		} else {
-			MM_ERR("RPC write for set EFR, FR"
-				"and HR mode failed %d\n", rc);
-		}
-		break;
-	}
-	default:
-		rc = -EINVAL;
-		MM_ERR("Default case\n");
-	}
-	return rc;
-}
-
-static int audio_mvs_setup(struct audio_mvs_info_type *audio)
-{
-	int rc = 0;
-	struct audio_mvs_enable_msg enable_msg;
-
-	MM_DBG("\n");
-
-	/* Enable MVS. */
-	memset(&enable_msg, 0, sizeof(enable_msg));
-	enable_msg.enable_args.client_id = cpu_to_be32(MVS_CLIENT_ID_VOIP);
-	enable_msg.enable_args.mode = cpu_to_be32(audio->mvs_mode);
-	enable_msg.enable_args.ul_cb_func_id = cpu_to_be32(MVS_UL_CB_FUNC_ID);
-	enable_msg.enable_args.dl_cb_func_id = cpu_to_be32(MVS_DL_CB_FUNC_ID);
-	enable_msg.enable_args.context = cpu_to_be32(MVS_PKT_CONTEXT_ISR);
-
-	msm_rpc_setup_req(&enable_msg.rpc_hdr,
-			  audio->rpc_prog,
-			  audio->rpc_ver,
-			  MVS_ENABLE_PROC);
-
-	audio->rpc_status = RPC_STATUS_FAILURE;
-	rc = msm_rpc_write(audio->rpc_endpt, &enable_msg, sizeof(enable_msg));
-
-	if (rc >= 0) {
-		MM_DBG("RPC write for enable done\n");
-
-		rc = wait_event_timeout(audio->mode_wait,
-				(audio->rpc_status != RPC_STATUS_FAILURE),
-				10 * HZ);
-
-		if (rc > 0) {
-			MM_DBG("Wait event for enable succeeded\n");
-			rc = audio_mvs_setup_mode(audio);
-			if (rc < 0) {
-				MM_ERR("Unknown MVS mode %d\n",
-				       audio->mvs_mode);
-			}
-			MM_ERR("rc value after mode setup: %d\n", rc);
-		} else {
-			MM_ERR("Wait event for enable failed %d\n", rc);
-		}
-	} else {
-		MM_ERR("RPC write for enable failed %d\n", rc);
-	}
-
-	return rc;
-}
-
-static int audio_mvs_start(struct audio_mvs_info_type *audio)
-{
-	int rc = 0;
-	struct audio_mvs_acquire_msg acquire_msg;
-
-	MM_DBG("\n");
-
-	/* Prevent sleep. */
-	wake_lock(&audio->suspend_lock);
-	pm_qos_update_request(&audio->pm_qos_req,
-			      msm_cpuidle_get_deep_idle_latency());
-
-	/* Acquire MVS. */
-	memset(&acquire_msg, 0, sizeof(acquire_msg));
-	acquire_msg.acquire_args.client_id = cpu_to_be32(MVS_CLIENT_ID_VOIP);
-	acquire_msg.acquire_args.cb_func_id = cpu_to_be32(MVS_CB_FUNC_ID);
-
-	msm_rpc_setup_req(&acquire_msg.rpc_hdr,
-			  audio->rpc_prog,
-			  audio->rpc_ver,
-			  MVS_ACQUIRE_PROC);
-
-	audio->rpc_status = RPC_STATUS_FAILURE;
-	rc = msm_rpc_write(audio->rpc_endpt,
-			   &acquire_msg,
-			   sizeof(acquire_msg));
-
-	if (rc >= 0) {
-		MM_DBG("RPC write for acquire done\n");
-
-		rc = wait_event_timeout(audio->wait,
-			(audio->rpc_status != RPC_STATUS_FAILURE),
-			1 * HZ);
-
-		if (rc > 0) {
-
-			rc = audio_mvs_setup(audio);
-
-			if (rc == 0)
-				audio->state = AUDIO_MVS_STARTED;
-
-		} else {
-			MM_ERR("Wait event for acquire failed %d\n", rc);
-
-			rc = -EBUSY;
-		}
-	} else {
-		MM_ERR("RPC write for acquire failed %d\n", rc);
-
-		rc = -EBUSY;
-	}
-
-	return rc;
-}
-
-static int audio_mvs_stop(struct audio_mvs_info_type *audio)
-{
-	int rc = 0;
-	struct audio_mvs_release_msg release_msg;
-
-	MM_DBG("\n");
-
-	/* Release MVS. */
-	memset(&release_msg, 0, sizeof(release_msg));
-	release_msg.client_id = cpu_to_be32(MVS_CLIENT_ID_VOIP);
-
-	msm_rpc_setup_req(&release_msg.rpc_hdr,
-			  audio->rpc_prog,
-			  audio->rpc_ver,
-			  MVS_RELEASE_PROC);
-
-	audio->rpc_status = RPC_STATUS_FAILURE;
-	rc = msm_rpc_write(audio->rpc_endpt, &release_msg, sizeof(release_msg));
-
-	if (rc >= 0) {
-		MM_DBG("RPC write for release done\n");
-
-		rc = wait_event_timeout(audio->mode_wait,
-				(audio->rpc_status != RPC_STATUS_FAILURE),
-				1 * HZ);
-
-		if (rc > 0) {
-			MM_DBG("Wait event for release succeeded\n");
-
-			audio->state = AUDIO_MVS_STOPPED;
-
-			/* Un-block read in case it is waiting for data. */
-			wake_up(&audio->out_wait);
-			rc = 0;
-		} else {
-			MM_ERR("Wait event for release failed %d\n", rc);
-		}
-	} else {
-		MM_ERR("RPC write for release failed %d\n", rc);
-	}
-
-	/* Allow sleep. */
-	pm_qos_update_request(&audio->pm_qos_req, PM_QOS_DEFAULT_VALUE);
-	wake_unlock(&audio->suspend_lock);
-
-	return rc;
-}
-
-static void audio_mvs_process_rpc_request(uint32_t procedure,
-					  uint32_t xid,
-					  void *data,
-					  uint32_t length,
-					  struct audio_mvs_info_type *audio)
-{
-	int rc = 0;
-
-	MM_DBG("\n");
-
-	switch (procedure) {
-	case MVS_EVENT_CB_TYPE_PROC: {
-		struct audio_mvs_cb_func_args *args = data;
-		struct rpc_reply_hdr reply_hdr;
-
-		MM_DBG("MVS CB CB_FUNC_ID 0x%x\n",
-			 be32_to_cpu(args->cb_func_id));
-
-		if (be32_to_cpu(args->valid_ptr)) {
-			uint32_t event_type = be32_to_cpu(args->event);
-
-			MM_DBG("MVS CB event type %d\n",
-				 be32_to_cpu(args->event));
-
-			if (event_type == AUDIO_MVS_COMMAND) {
-				uint32_t cmd_status = be32_to_cpu(
-			args->event_data.mvs_ev_command_type.cmd_status);
-
-				MM_DBG("MVS CB command status %d\n",
-					cmd_status);
-
-				if (cmd_status == AUDIO_MVS_CMD_SUCCESS) {
-					audio->rpc_status = RPC_STATUS_SUCCESS;
-					wake_up(&audio->wait);
-				}
-
-			} else if (event_type == AUDIO_MVS_MODE) {
-				uint32_t mode_status = be32_to_cpu(
-				args->event_data.mvs_ev_mode_type.mode_status);
-
-				MM_DBG("MVS CB mode status %d\n", mode_status);
-
-				if (mode_status == AUDIO_MVS_MODE_READY) {
-					audio->rpc_status = RPC_STATUS_SUCCESS;
-					wake_up(&audio->mode_wait);
-				}
-			} else {
-				MM_ERR("MVS CB unknown event type %d\n",
-					event_type);
-			}
-		} else {
-			MM_ERR("MVS CB event pointer not valid\n");
-		}
-
-		/* Send ack to modem. */
-		memset(&reply_hdr, 0, sizeof(reply_hdr));
-		reply_hdr.xid = cpu_to_be32(xid);
-		reply_hdr.type = cpu_to_be32(RPC_TYPE_REPLY);
-		reply_hdr.reply_stat = cpu_to_be32(RPCMSG_REPLYSTAT_ACCEPTED);
-
-		reply_hdr.data.acc_hdr.accept_stat = cpu_to_be32(
-			RPC_ACCEPTSTAT_SUCCESS);
-		reply_hdr.data.acc_hdr.verf_flavor = 0;
-		reply_hdr.data.acc_hdr.verf_length = 0;
-
-		rc = msm_rpc_write(audio->rpc_endpt,
-				   &reply_hdr,
-				   sizeof(reply_hdr));
-
-		if (rc < 0)
-			MM_ERR("RPC write for response failed %d\n", rc);
-
-		break;
-	}
-
-	case MVS_PACKET_UL_FN_TYPE_PROC: {
-		uint32_t *args = data;
-		uint32_t pkt_len;
-		uint32_t frame_mode;
-		struct audio_mvs_ul_reply ul_reply;
-		struct audio_mvs_buf_node *buf_node = NULL;
-
-		MM_DBG("MVS UL CB_FUNC_ID 0x%x\n",
-			 be32_to_cpu(*args));
-		args++;
-
-		pkt_len = be32_to_cpu(*args);
-		MM_DBG("UL pkt_len %d\n", pkt_len);
-		args++;
-
-		/* Copy the vocoder packets. */
-		mutex_lock(&audio->out_lock);
-
-		if (!list_empty(&audio->free_out_queue)) {
-			buf_node = list_first_entry(&audio->free_out_queue,
-						    struct audio_mvs_buf_node,
-						    list);
-			list_del(&buf_node->list);
-
-			memcpy(&buf_node->frame.voc_pkt[0], args, pkt_len);
-			buf_node->frame.len = pkt_len;
-			pkt_len = ALIGN(pkt_len, 4);
-			args = args + pkt_len/4;
-
-			MM_DBG("UL valid_ptr 0x%x\n",
-				 be32_to_cpu(*args));
-			args++;
-
-			frame_mode = be32_to_cpu(*args);
-			MM_DBG("UL frame_mode %d\n",
-				 frame_mode);
-			args++;
-
-			MM_DBG("UL frame_mode %d\n",
-				 be32_to_cpu(*args));
-			args++;
-
-			MM_DBG("UL frame_mode %d\n",
-				 be32_to_cpu(*args));
-			args++;
-
-			MM_DBG("UL mvs_mode %d\n",
-				 be32_to_cpu(*args));
-			args++;
-
-			MM_DBG("UL buf_free_cnt %d\n",
-				 be32_to_cpu(*args));
-			args++;
-
-			if (frame_mode == MVS_FRAME_MODE_AMR_UL) {
-				/* Extract AMR frame type. */
-				buf_node->frame.frame_type = be32_to_cpu(*args);
-
-				MM_DBG("UL AMR frame_type %d\n",
-					 be32_to_cpu(*args));
-			} else if (frame_mode == MVS_FRAME_MODE_PCM_UL) {
-				/* PCM doesn't have frame_type */
-				buf_node->frame.frame_type = 0;
-			} else if (frame_mode == MVS_FRAME_MODE_VOC_TX) {
-				/* Extracting EVRC current buffer frame rate*/
-				buf_node->frame.frame_type = be32_to_cpu(*args);
-				pr_debug("%s: UL EVRC frame_type %d\n",
-					__func__, be32_to_cpu(*args));
-			} else if (frame_mode == MVS_FRAME_MODE_G711_UL) {
-				/* Extract G711 frame type. */
-				buf_node->frame.frame_type = be32_to_cpu(*args);
-
-				MM_DBG("UL G711 frame_type %d\n",
-					be32_to_cpu(*args));
-			} else if (frame_mode == MVS_FRAME_MODE_G729A_UL) {
-				/* Extract G729 frame type. */
-				buf_node->frame.frame_type = be32_to_cpu(*args);
-
-				MM_DBG("UL G729 frame_type %d\n",
-					be32_to_cpu(*args));
-			} else if (frame_mode == MVS_FRAME_MODE_G722_UL) {
-				/* Extract G722 frame type. */
-				buf_node->frame.frame_type = be32_to_cpu(*args);
-
-				MM_DBG("UL G722 frame_type %d\n",
-				       be32_to_cpu(*args));
-			} else if (frame_mode == MVS_FRAME_MODE_G711A_UL) {
-				/* Extract G711A frame type. */
-				buf_node->frame.frame_type = be32_to_cpu(*args);
-
-				MM_DBG("UL G711A frame_type %d\n",
-				       be32_to_cpu(*args));
-			} else if ((frame_mode == MVS_FRAME_MODE_GSM_UL) ||
-				   (frame_mode == MVS_FRAME_MODE_HR_UL)) {
-				/* Extract EFR, FR and HR frame type. */
-				buf_node->frame.frame_type = be32_to_cpu(*args);
-
-				MM_DBG("UL EFR,FR,HR frame_type %d\n",
-					be32_to_cpu(*args));
-			} else {
-				MM_DBG("UL Unknown frame mode %d\n",
-				       frame_mode);
-			}
-
-			list_add_tail(&buf_node->list, &audio->out_queue);
-		} else {
-			MM_ERR("UL data dropped, read is slow\n");
-		}
-
-		mutex_unlock(&audio->out_lock);
-
-		wake_up(&audio->out_wait);
-
-		/* Send UL message accept to modem. */
-		memset(&ul_reply, 0, sizeof(ul_reply));
-		ul_reply.reply_hdr.xid = cpu_to_be32(xid);
-		ul_reply.reply_hdr.type = cpu_to_be32(RPC_TYPE_REPLY);
-		ul_reply.reply_hdr.reply_stat = cpu_to_be32(
-			RPCMSG_REPLYSTAT_ACCEPTED);
-
-		ul_reply.reply_hdr.data.acc_hdr.accept_stat = cpu_to_be32(
-			RPC_ACCEPTSTAT_SUCCESS);
-		ul_reply.reply_hdr.data.acc_hdr.verf_flavor = 0;
-		ul_reply.reply_hdr.data.acc_hdr.verf_length = 0;
-
-		ul_reply.valid_pkt_status_ptr = cpu_to_be32(0x00000001);
-		ul_reply.pkt_status = cpu_to_be32(0x00000000);
-
-		rc = msm_rpc_write(audio->rpc_endpt,
-				   &ul_reply,
-				   sizeof(ul_reply));
-
-		if (rc < 0)
-			MM_ERR("RPC write for UL response failed %d\n",
-			       rc);
-
-		break;
-	}
-
-	case MVS_PACKET_DL_FN_TYPE_PROC: {
-		struct audio_mvs_dl_cb_func_args *args = data;
-		struct audio_mvs_dl_reply dl_reply;
-		uint32_t frame_mode;
-		struct audio_mvs_buf_node *buf_node = NULL;
-
-		MM_DBG("MVS DL CB CB_FUNC_ID 0x%x\n",
-			 be32_to_cpu(args->cb_func_id));
-
-		frame_mode = be32_to_cpu(args->frame_mode);
-		MM_DBG("DL frame_mode %d\n", frame_mode);
-
-		/* Prepare and send the DL packets to modem. */
-		memset(&dl_reply, 0, sizeof(dl_reply));
-		dl_reply.reply_hdr.xid = cpu_to_be32(xid);
-		dl_reply.reply_hdr.type = cpu_to_be32(RPC_TYPE_REPLY);
-		dl_reply.reply_hdr.reply_stat = cpu_to_be32(
-			RPCMSG_REPLYSTAT_ACCEPTED);
-
-		dl_reply.reply_hdr.data.acc_hdr.accept_stat = cpu_to_be32(
-			RPC_ACCEPTSTAT_SUCCESS);
-		dl_reply.reply_hdr.data.acc_hdr.verf_flavor = 0;
-		dl_reply.reply_hdr.data.acc_hdr.verf_length = 0;
-
-		mutex_lock(&audio->in_lock);
-
-		if (!list_empty(&audio->in_queue)) {
-			buf_node = list_first_entry(&audio->in_queue,
-						    struct audio_mvs_buf_node,
-						    list);
-			list_del(&buf_node->list);
-
-			memcpy(&dl_reply.voc_pkt,
-			       &buf_node->frame.voc_pkt[0],
-			       buf_node->frame.len);
-
-			MM_DBG("frame mode %d buf_node->frame.len %d\n",
-				 frame_mode, buf_node->frame.len);
-			if (frame_mode == MVS_FRAME_MODE_AMR_DL) {
-				dl_reply.cdc_param.gnr_arg.param1 = cpu_to_be32(
-					buf_node->frame.frame_type);
-				dl_reply.cdc_param.gnr_arg.param2 =
-						cpu_to_be32(audio->rate_type);
-				dl_reply.cdc_param.\
-						gnr_arg.valid_pkt_status_ptr =
-							cpu_to_be32(0x00000001);
-				dl_reply.cdc_param.gnr_arg.pkt_status =
-					cpu_to_be32(AUDIO_MVS_PKT_NORMAL);
-			} else if (frame_mode == MVS_FRAME_MODE_PCM_DL) {
-				dl_reply.cdc_param.gnr_arg.param1 = 0;
-				dl_reply.cdc_param.gnr_arg.param2 = 0;
-				dl_reply.cdc_param.\
-						gnr_arg.valid_pkt_status_ptr =
-							cpu_to_be32(0x00000001);
-				dl_reply.cdc_param.gnr_arg.pkt_status =
-					cpu_to_be32(AUDIO_MVS_PKT_NORMAL);
-			} else if (frame_mode == MVS_FRAME_MODE_VOC_RX) {
-				dl_reply.cdc_param.gnr_arg.param1 =
-					cpu_to_be32(buf_node->frame.frame_type);
-				dl_reply.cdc_param.gnr_arg.param2 = 0;
-				dl_reply.cdc_param.\
-						gnr_arg.valid_pkt_status_ptr =
-							cpu_to_be32(0x00000001);
-				dl_reply.cdc_param.gnr_arg.pkt_status =
-					cpu_to_be32(AUDIO_MVS_PKT_NORMAL);
-			} else if (frame_mode == MVS_FRAME_MODE_G711_DL) {
-				dl_reply.cdc_param.g711_arg.param1 =
-				cpu_to_be32(buf_node->frame.frame_type);
-				dl_reply.cdc_param.\
-						g711_arg.valid_pkt_status_ptr =
-							cpu_to_be32(0x00000001);
-				dl_reply.cdc_param.g711_arg.pkt_status =
-					cpu_to_be32(AUDIO_MVS_PKT_NORMAL);
-			} else if (frame_mode == MVS_FRAME_MODE_G729A_DL) {
-				dl_reply.cdc_param.gnr_arg.param1 = cpu_to_be32(
-				       buf_node->frame.frame_type);
-				dl_reply.cdc_param.gnr_arg.param2 =
-						cpu_to_be32(audio->rate_type);
-				dl_reply.cdc_param.\
-						gnr_arg.valid_pkt_status_ptr =
-							cpu_to_be32(0x00000001);
-				dl_reply.cdc_param.gnr_arg.pkt_status =
-					cpu_to_be32(AUDIO_MVS_PKT_NORMAL);
-			} else if (frame_mode == MVS_FRAME_MODE_G722_DL) {
-				dl_reply.cdc_param.gnr_arg.param1 = cpu_to_be32(
-				      buf_node->frame.frame_type);
-				dl_reply.cdc_param.gnr_arg.param2 =
-						cpu_to_be32(audio->rate_type);
-				dl_reply.cdc_param.\
-						gnr_arg.valid_pkt_status_ptr =
-							cpu_to_be32(0x00000001);
-				dl_reply.cdc_param.gnr_arg.pkt_status =
-					cpu_to_be32(AUDIO_MVS_PKT_NORMAL);
-			} else if (frame_mode == MVS_FRAME_MODE_G711A_DL) {
-				dl_reply.cdc_param.gnr_arg.param1 = cpu_to_be32(
-				       buf_node->frame.frame_type);
-				dl_reply.cdc_param.gnr_arg.param2 =
-						cpu_to_be32(audio->rate_type);
-				dl_reply.cdc_param.\
-						gnr_arg.valid_pkt_status_ptr =
-							cpu_to_be32(0x00000001);
-				dl_reply.cdc_param.gnr_arg.pkt_status =
-					cpu_to_be32(AUDIO_MVS_PKT_NORMAL);
-			} else if ((frame_mode == MVS_FRAME_MODE_GSM_DL) ||
-				   (frame_mode == MVS_FRAME_MODE_HR_DL)) {
-				dl_reply.cdc_param.gnr_arg.param1 = cpu_to_be32(
-				       buf_node->frame.frame_type);
-				dl_reply.cdc_param.gnr_arg.param2 =
-						cpu_to_be32(audio->rate_type);
-				dl_reply.cdc_param.\
-						gnr_arg.valid_pkt_status_ptr =
-							cpu_to_be32(0x00000001);
-				dl_reply.cdc_param.gnr_arg.pkt_status =
-					cpu_to_be32(AUDIO_MVS_PKT_NORMAL);
-			} else {
-				MM_ERR("DL Unknown frame mode %d\n",
-				       frame_mode);
-			}
-			list_add_tail(&buf_node->list, &audio->free_in_queue);
-		} else {
-			MM_DBG("No DL data available to send to MVS\n");
-			if (frame_mode == MVS_FRAME_MODE_G711_DL) {
-				dl_reply.cdc_param.\
-						g711_arg.valid_pkt_status_ptr =
-							cpu_to_be32(0x00000001);
-				dl_reply.cdc_param.g711_arg.pkt_status =
-						cpu_to_be32(AUDIO_MVS_PKT_SLOW);
-			} else {
-				dl_reply.cdc_param.\
-						gnr_arg.valid_pkt_status_ptr =
-							cpu_to_be32(0x00000001);
-				dl_reply.cdc_param.gnr_arg.pkt_status =
-						cpu_to_be32(AUDIO_MVS_PKT_SLOW);
-			}
-		}
-
-		mutex_unlock(&audio->in_lock);
-
-		wake_up(&audio->in_wait);
-		dl_reply.valid_frame_info_ptr = cpu_to_be32(0x00000001);
-
-		dl_reply.frame_mode = cpu_to_be32(audio->frame_mode);
-		dl_reply.frame_mode_again = cpu_to_be32(audio->frame_mode);
-
-		dl_reply.frame_info_hdr.frame_mode =
-			cpu_to_be32(audio->frame_mode);
-		dl_reply.frame_info_hdr.mvs_mode = cpu_to_be32(audio->mvs_mode);
-		dl_reply.frame_info_hdr.buf_free_cnt = 0;
-
-		rc = msm_rpc_write(audio->rpc_endpt,
-				   &dl_reply,
-				   sizeof(dl_reply));
-
-		if (rc < 0)
-			MM_ERR("RPC write for DL response failed %d\n",
-			       rc);
-
-		break;
-	}
-
-	default:
-		MM_ERR("Unknown CB type %d\n", procedure);
-	}
-}
-
-static int audio_mvs_thread(void *data)
-{
-	struct audio_mvs_info_type *audio = data;
-	struct rpc_request_hdr *rpc_hdr = NULL;
-
-	MM_DBG("\n");
-
-	while (!kthread_should_stop()) {
-
-		int rpc_hdr_len = msm_rpc_read(audio->rpc_endpt,
-					       (void **) &rpc_hdr,
-					       -1,
-					       -1);
-
-		if (rpc_hdr_len < 0) {
-			MM_ERR("RPC read failed %d\n",
-			       rpc_hdr_len);
-
-			break;
-		} else if ((rpc_hdr_len == 0) &&
-				(audio->state == AUDIO_MVS_CLOSED)) {
-			break;
-		} else if (rpc_hdr_len < RPC_COMMON_HDR_SZ) {
-			continue;
-		} else {
-			uint32_t rpc_type = be32_to_cpu(rpc_hdr->type);
-			if (rpc_type == RPC_TYPE_REPLY) {
-				struct rpc_reply_hdr *rpc_reply =
-					(void *) rpc_hdr;
-				uint32_t reply_status;
-
-				if (rpc_hdr_len < RPC_REPLY_HDR_SZ)
-					continue;
-
-				reply_status =
-					be32_to_cpu(rpc_reply->reply_stat);
-
-				if (reply_status != RPCMSG_REPLYSTAT_ACCEPTED) {
-					/* If the command is not accepted, there
-					 * will be no response callback. Wake
-					 * the caller and report error. */
-					audio->rpc_status = RPC_STATUS_REJECT;
-
-					wake_up(&audio->wait);
-
-					MM_ERR("RPC reply status denied\n");
-				}
-			} else if (rpc_type == RPC_TYPE_REQUEST) {
-				if (rpc_hdr_len < RPC_REQUEST_HDR_SZ)
-					continue;
-
-				audio_mvs_process_rpc_request(
-					be32_to_cpu(rpc_hdr->procedure),
-					be32_to_cpu(rpc_hdr->xid),
-					(void *) (rpc_hdr + 1),
-					(rpc_hdr_len - sizeof(*rpc_hdr)),
-					audio);
-			} else {
-				MM_ERR("Unexpected RPC type %d\n", rpc_type);
-			}
-		}
-
-		kfree(rpc_hdr);
-		rpc_hdr = NULL;
-	}
-	complete_and_exit(&audio->complete, 0);
-	MM_DBG("MVS thread stopped\n");
-
-	return 0;
-}
-
-static int audio_mvs_alloc_buf(struct audio_mvs_info_type *audio)
-{
-	int i = 0;
-	struct audio_mvs_buf_node *buf_node = NULL;
-	struct list_head *ptr = NULL;
-	struct list_head *next = NULL;
-
-	MM_DBG("\n");
-
-	/* Allocate input buffers. */
-	for (i = 0; i < MVS_MAX_Q_LEN; i++) {
-		buf_node = kmalloc(sizeof(struct audio_mvs_buf_node),
-				   GFP_KERNEL);
-
-		if (buf_node != NULL) {
-			list_add_tail(&buf_node->list,
-				      &audio->free_in_queue);
-		} else {
-			MM_ERR("No memory for IO buffers\n");
-			goto err;
-		}
-		buf_node = NULL;
-	}
-
-	/* Allocate output buffers. */
-	for (i = 0; i < MVS_MAX_Q_LEN; i++) {
-		buf_node = kmalloc(sizeof(struct audio_mvs_buf_node),
-				   GFP_KERNEL);
-
-		if (buf_node != NULL) {
-			list_add_tail(&buf_node->list,
-				      &audio->free_out_queue);
-		} else {
-			MM_ERR("No memory for IO buffers\n");
-			goto err;
-		}
-		buf_node = NULL;
-	}
-
-	return 0;
-
-err:
-	list_for_each_safe(ptr, next, &audio->free_in_queue) {
-		buf_node = list_entry(ptr, struct audio_mvs_buf_node, list);
-		list_del(&buf_node->list);
-		kfree(buf_node);
-		buf_node = NULL;
-	}
-
-	ptr = next = NULL;
-	list_for_each_safe(ptr, next, &audio->free_out_queue) {
-		buf_node = list_entry(ptr, struct audio_mvs_buf_node, list);
-		list_del(&buf_node->list);
-		kfree(buf_node);
-		buf_node = NULL;
-	}
-
-	return -ENOMEM;
-}
-
-static void audio_mvs_free_buf(struct audio_mvs_info_type *audio)
-{
-	struct list_head *ptr = NULL;
-	struct list_head *next = NULL;
-	struct audio_mvs_buf_node *buf_node = NULL;
-
-	MM_DBG("\n");
-
-	mutex_lock(&audio->in_lock);
-	/* Free input buffers. */
-	list_for_each_safe(ptr, next, &audio->in_queue) {
-		buf_node = list_entry(ptr, struct audio_mvs_buf_node, list);
-		list_del(&buf_node->list);
-		kfree(buf_node);
-		buf_node = NULL;
-	}
-
-	ptr = next = NULL;
-	/* Free free_input buffers. */
-	list_for_each_safe(ptr, next, &audio->free_in_queue) {
-		buf_node = list_entry(ptr, struct audio_mvs_buf_node, list);
-		list_del(&buf_node->list);
-		kfree(buf_node);
-		buf_node = NULL;
-	}
-	mutex_unlock(&audio->in_lock);
-
-	mutex_lock(&audio->out_lock);
-	ptr = next = NULL;
-	/* Free output buffers. */
-	list_for_each_safe(ptr, next, &audio->out_queue) {
-		buf_node = list_entry(ptr, struct audio_mvs_buf_node, list);
-		list_del(&buf_node->list);
-		kfree(buf_node);
-		buf_node = NULL;
-	}
-
-	/* Free free_ioutput buffers. */
-	ptr = next = NULL;
-	list_for_each_safe(ptr, next, &audio->free_out_queue) {
-		buf_node = list_entry(ptr, struct audio_mvs_buf_node, list);
-		list_del(&buf_node->list);
-		kfree(buf_node);
-		buf_node = NULL;
-	}
-	mutex_unlock(&audio->out_lock);
-}
-static int audio_mvs_release(struct inode *inode, struct file *file)
-{
-
-	struct audio_mvs_info_type *audio = file->private_data;
-
-	MM_DBG("\n");
-
-	mutex_lock(&audio->lock);
-	if (audio->state == AUDIO_MVS_STARTED)
-		audio_mvs_stop(audio);
-	audio->state = AUDIO_MVS_CLOSED;
-	msm_rpc_read_wakeup(audio->rpc_endpt);
-	wait_for_completion(&audio->complete);
-	msm_rpc_close(audio->rpc_endpt);
-	audio->task = NULL;
-	audio_mvs_free_buf(audio);
-	mutex_unlock(&audio->lock);
-
-	MM_DBG("Release done\n");
-	return 0;
-}
-
-static ssize_t audio_mvs_read(struct file *file,
-			      char __user *buf,
-			      size_t count,
-			      loff_t *pos)
-{
-	int rc = 0;
-	struct audio_mvs_buf_node *buf_node = NULL;
-	struct audio_mvs_info_type *audio = file->private_data;
-
-	MM_DBG("\n");
-
-	rc = wait_event_interruptible_timeout(audio->out_wait,
-			(!list_empty(&audio->out_queue) ||
-			 audio->state == AUDIO_MVS_STOPPED),
-			1 * HZ);
-
-	if (rc > 0) {
-		mutex_lock(&audio->out_lock);
-		if ((audio->state == AUDIO_MVS_STARTED) &&
-		    (!list_empty(&audio->out_queue))) {
-
-			if (count >= sizeof(struct msm_audio_mvs_frame)) {
-				buf_node = list_first_entry(&audio->out_queue,
-						struct audio_mvs_buf_node,
-						list);
-				list_del(&buf_node->list);
-
-				rc = copy_to_user(buf,
-					&buf_node->frame,
-					sizeof(struct msm_audio_mvs_frame));
-
-				if (rc == 0) {
-					rc = buf_node->frame.len +
-					    sizeof(buf_node->frame.frame_type) +
-					    sizeof(buf_node->frame.len);
-				} else {
-					MM_ERR("Copy to user retuned %d", rc);
-
-					rc = -EFAULT;
-				}
-
-				list_add_tail(&buf_node->list,
-					      &audio->free_out_queue);
-			} else {
-				MM_ERR("Read count %d < sizeof(frame) %d",
-				       count,
-				       sizeof(struct msm_audio_mvs_frame));
-
-				rc = -ENOMEM;
-			}
-		} else {
-			MM_ERR("Read performed in state %d\n",
-			       audio->state);
-
-			rc = -EPERM;
-		}
-		mutex_unlock(&audio->out_lock);
-
-	} else if (rc == 0) {
-		MM_ERR("No UL data available\n");
-
-		rc = -ETIMEDOUT;
-	} else {
-		MM_ERR("Read was interrupted\n");
-
-		rc = -ERESTARTSYS;
-	}
-
-	return rc;
-}
-
-static ssize_t audio_mvs_write(struct file *file,
-			       const char __user *buf,
-			       size_t count,
-			       loff_t *pos)
-{
-	int rc = 0;
-	struct audio_mvs_buf_node *buf_node = NULL;
-	struct audio_mvs_info_type *audio = file->private_data;
-
-	MM_DBG("\n");
-
-	rc = wait_event_interruptible_timeout(audio->in_wait,
-		(!list_empty(&audio->free_in_queue) ||
-		audio->state == AUDIO_MVS_STOPPED), 1 * HZ);
-	if (rc > 0) {
-		mutex_lock(&audio->in_lock);
-		if (audio->state == AUDIO_MVS_STARTED) {
-			if (count <= sizeof(struct msm_audio_mvs_frame)) {
-				if (!list_empty(&audio->free_in_queue)) {
-					buf_node = list_first_entry(
-						&audio->free_in_queue,
-						struct audio_mvs_buf_node,
-						list);
-					list_del(&buf_node->list);
-
-					rc = copy_from_user(&buf_node->frame,
-							    buf,
-							    count);
-
-					list_add_tail(&buf_node->list,
-						      &audio->in_queue);
-				} else {
-					MM_ERR("No free DL buffs\n");
-				}
-			} else {
-				MM_ERR("Write count %d > sizeof(frame) %d",
-					count,
-					sizeof(struct msm_audio_mvs_frame));
-
-				rc = -ENOMEM;
-			}
-		} else {
-			MM_ERR("Write performed in invalid state %d\n",
-				audio->state);
-
-			rc = -EPERM;
-		}
-		mutex_unlock(&audio->in_lock);
-	} else if (rc == 0) {
-		MM_ERR("%s: No free DL buffs\n", __func__);
-
-		rc = -ETIMEDOUT;
-	} else {
-		MM_ERR("%s: write was interrupted\n", __func__);
-
-		rc = -ERESTARTSYS;
-	}
-	return rc;
-}
-
-static long audio_mvs_ioctl(struct file *file,
-			    unsigned int cmd,
-			    unsigned long arg)
-{
-	int rc = 0;
-
-	struct audio_mvs_info_type *audio = file->private_data;
-
-	MM_DBG("\n");
-
-	switch (cmd) {
-	case AUDIO_GET_MVS_CONFIG: {
-		struct msm_audio_mvs_config config;
-
-		MM_DBG("GET_MVS_CONFIG mvs_mode %d rate_type %d\n",
-			config.mvs_mode, config.rate_type);
-
-		mutex_lock(&audio->lock);
-		config.mvs_mode = audio->mvs_mode;
-		config.rate_type = audio->rate_type;
-		mutex_unlock(&audio->lock);
-
-		rc = copy_to_user((void *)arg, &config, sizeof(config));
-		if (rc == 0)
-			rc = sizeof(config);
-		else
-			MM_ERR("Config copy failed %d\n", rc);
-
-		break;
-	}
-
-	case AUDIO_SET_MVS_CONFIG: {
-		struct msm_audio_mvs_config config;
-
-		MM_DBG("IOCTL SET_MVS_CONFIG\n");
-
-		rc = copy_from_user(&config, (void *)arg, sizeof(config));
-		if (rc == 0) {
-			mutex_lock(&audio->lock);
-
-			if (audio->state == AUDIO_MVS_OPENED) {
-				audio->mvs_mode = config.mvs_mode;
-				audio->rate_type = config.rate_type;
-				audio->dtx_mode = config.dtx_mode;
-			} else {
-				MM_ERR("Set confg called in state %d\n",
-				       audio->state);
-
-				rc = -EPERM;
-			}
-
-			mutex_unlock(&audio->lock);
-		} else {
-			MM_ERR("Config copy failed %d\n", rc);
-		}
-
-		break;
-	}
-
-	case AUDIO_START: {
-		MM_DBG("IOCTL START\n");
-
-		mutex_lock(&audio->lock);
-
-		if (audio->state == AUDIO_MVS_OPENED ||
-		    audio->state == AUDIO_MVS_STOPPED) {
-			rc = audio_mvs_start(audio);
-			if (rc != 0)
-				audio_mvs_stop(audio);
-		} else {
-			MM_ERR("Start called in invalid state %d\n",
-			       audio->state);
-
-			rc = -EPERM;
-		}
-
-		mutex_unlock(&audio->lock);
-
-		break;
-	}
-
-	case AUDIO_STOP: {
-		MM_DBG("IOCTL STOP\n");
-
-		mutex_lock(&audio->lock);
-
-		if (audio->state == AUDIO_MVS_STARTED) {
-			rc = audio_mvs_stop(audio);
-		} else {
-			MM_ERR("Stop called in invalid state %d\n",
-			       audio->state);
-
-			rc = -EPERM;
-		}
-
-		mutex_unlock(&audio->lock);
-		break;
-	}
-
-	default: {
-		MM_ERR("Unknown IOCTL %d\n", cmd);
-	}
-	}
-
-	return rc;
-}
-
-static int audio_mvs_open(struct inode *inode, struct file *file)
-{
-	int rc = 0;
-
-	MM_DBG("\n");
-
-	mutex_lock(&audio_mvs_info.lock);
-
-	if (audio_mvs_info.state != AUDIO_MVS_CLOSED) {
-		MM_ERR("MVS driver exists, state %d\n",
-				audio_mvs_info.state);
-
-		rc = -EBUSY;
-		mutex_unlock(&audio_mvs_info.lock);
-		goto done;
-	}
-
-	mutex_unlock(&audio_mvs_info.lock);
-
-	audio_mvs_info.rpc_endpt = msm_rpc_connect_compatible(MVS_PROG,
-					MVS_VERS_COMP_VER2,
-					MSM_RPC_UNINTERRUPTIBLE);
-
-	if (IS_ERR(audio_mvs_info.rpc_endpt)) {
-		MM_ERR("MVS RPC connect failed ver 0x%x\n",
-				MVS_VERS_COMP_VER2);
-		audio_mvs_info.rpc_endpt = msm_rpc_connect_compatible(MVS_PROG,
-					MVS_VERS_COMP_VER3,
-					MSM_RPC_UNINTERRUPTIBLE);
-		if (IS_ERR(audio_mvs_info.rpc_endpt)) {
-			MM_ERR("MVS RPC connect failed ver 0x%x\n",
-				MVS_VERS_COMP_VER3);
-		} else {
-			MM_DBG("MVS RPC connect succeeded ver 0x%x\n",
-				MVS_VERS_COMP_VER3);
-			audio_mvs_info.rpc_prog = MVS_PROG;
-			audio_mvs_info.rpc_ver = MVS_VERS_COMP_VER3;
-		}
-	} else {
-		MM_DBG("MVS RPC connect succeeded ver 0x%x\n",
-			MVS_VERS_COMP_VER2);
-		audio_mvs_info.rpc_prog = MVS_PROG;
-		audio_mvs_info.rpc_ver = MVS_VERS_COMP_VER2;
-	}
-	audio_mvs_info.task = kthread_run(audio_mvs_thread,
-					  &audio_mvs_info,
-					  "audio_mvs");
-	if (IS_ERR(audio_mvs_info.task)) {
-		MM_ERR("MVS thread create failed\n");
-		rc = PTR_ERR(audio_mvs_info.task);
-		audio_mvs_info.task = NULL;
-		msm_rpc_close(audio_mvs_info.rpc_endpt);
-		audio_mvs_info.rpc_endpt = NULL;
-		goto done;
-	}
-
-	mutex_lock(&audio_mvs_info.lock);
-
-	if (audio_mvs_info.task != NULL ||
-			audio_mvs_info.rpc_endpt != NULL) {
-		rc = audio_mvs_alloc_buf(&audio_mvs_info);
-
-		if (rc == 0) {
-			audio_mvs_info.state = AUDIO_MVS_OPENED;
-			file->private_data = &audio_mvs_info;
-		}
-	}  else {
-		MM_ERR("MVS thread and RPC end point do not exist\n");
-
-		rc = -ENODEV;
-	}
-
-	mutex_unlock(&audio_mvs_info.lock);
-
-done:
-	return rc;
-}
-
-static const struct file_operations audio_mvs_fops = {
-	.owner = THIS_MODULE,
-	.open = audio_mvs_open,
-	.release = audio_mvs_release,
-	.read = audio_mvs_read,
-	.write = audio_mvs_write,
-	.unlocked_ioctl = audio_mvs_ioctl
-};
-
-struct miscdevice audio_mvs_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_mvs",
-	.fops = &audio_mvs_fops
-};
-static int __init audio_mvs_init(void)
-{
-	memset(&audio_mvs_info, 0, sizeof(audio_mvs_info));
-	mutex_init(&audio_mvs_info.lock);
-	mutex_init(&audio_mvs_info.in_lock);
-	mutex_init(&audio_mvs_info.out_lock);
-
-	init_waitqueue_head(&audio_mvs_info.wait);
-	init_waitqueue_head(&audio_mvs_info.mode_wait);
-	init_waitqueue_head(&audio_mvs_info.in_wait);
-	init_waitqueue_head(&audio_mvs_info.out_wait);
-
-	INIT_LIST_HEAD(&audio_mvs_info.in_queue);
-	INIT_LIST_HEAD(&audio_mvs_info.free_in_queue);
-	INIT_LIST_HEAD(&audio_mvs_info.out_queue);
-	INIT_LIST_HEAD(&audio_mvs_info.free_out_queue);
-
-	init_completion(&audio_mvs_info.complete);
-
-	wake_lock_init(&audio_mvs_info.suspend_lock,
-		       WAKE_LOCK_SUSPEND,
-		       "audio_mvs_suspend");
-	pm_qos_add_request(&audio_mvs_info.pm_qos_req, PM_QOS_CPU_DMA_LATENCY,
-				PM_QOS_DEFAULT_VALUE);
-
-	return misc_register(&audio_mvs_misc);
-}
-
-static void __exit audio_mvs_exit(void)
-{
-	MM_DBG("\n");
-
-	wake_lock_destroy(&audio_mvs_info.suspend_lock);
-	misc_deregister(&audio_mvs_misc);
-}
-
-module_init(audio_mvs_init);
-module_exit(audio_mvs_exit);
-
-MODULE_DESCRIPTION("MSM MVS driver");
-MODULE_LICENSE("GPL v2");
-
diff --git a/arch/arm/mach-msm/qdsp5/audio_out.c b/arch/arm/mach-msm/qdsp5/audio_out.c
deleted file mode 100644
index 07f9f4c..0000000
--- a/arch/arm/mach-msm/qdsp5/audio_out.c
+++ /dev/null
@@ -1,1233 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/audio_out.c
- *
- * pcm audio output device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/slab.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/wakelock.h>
-#include <linux/pm_qos.h>
-
-#include <linux/msm_audio.h>
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-#include <mach/msm_adsp.h>
-#include <mach/cpuidle.h>
-
-#include "audmgr.h"
-
-#include <mach/qdsp5/audio_acdb_def.h>
-#include <mach/qdsp5/qdsp5audppcmdi.h>
-#include <mach/qdsp5/qdsp5audppmsg.h>
-#include <mach/qdsp5/qdsp5audpp.h>
-
-#include <mach/htc_pwrsink.h>
-#include <mach/debug_mm.h>
-
-#include "evlog.h"
-
-#define LOG_AUDIO_EVENTS 1
-#define LOG_AUDIO_FAULTS 0
-
-#define SRS_ID_GLOBAL			0x00000001
-#define SRS_ID_WOWHD			0x00000002
-#define SRS_ID_CSHP			0x00000003
-#define SRS_ID_HPF			0x00000004
-#define SRS_ID_PEQ			0x00000005
-#define SRS_ID_HL			0x00000006
-
-#define SRS_MASK_G 1
-#define SRS_MASK_W 2
-#define SRS_MASK_C 4
-#define SRS_MASK_HP 8
-#define SRS_MASK_P 16
-#define SRS_MASK_HL 32
-
-
-enum {
-	EV_NULL,
-	EV_OPEN,
-	EV_WRITE,
-	EV_RETURN,
-	EV_IOCTL,
-	EV_WRITE_WAIT,
-	EV_WAIT_EVENT,
-	EV_FILL_BUFFER,
-	EV_SEND_BUFFER,
-	EV_DSP_EVENT,
-	EV_ENABLE,
-};
-
-#if (LOG_AUDIO_EVENTS != 1)
-static inline void LOG(unsigned id, unsigned arg) {}
-#else
-static const char *pcm_log_strings[] = {
-	"NULL",
-	"OPEN",
-	"WRITE",
-	"RETURN",
-	"IOCTL",
-	"WRITE_WAIT",
-	"WAIT_EVENT",
-	"FILL_BUFFER",
-	"SEND_BUFFER",
-	"DSP_EVENT",
-	"ENABLE",
-};
-
-DECLARE_LOG(pcm_log, 64, pcm_log_strings);
-
-static int __init _pcm_log_init(void)
-{
-	return ev_log_init(&pcm_log);
-}
-module_init(_pcm_log_init);
-
-#define LOG(id,arg) ev_log_write(&pcm_log, id, arg)
-#endif
-
-
-
-
-
-#define BUFSZ (5248)
-#define DMASZ (BUFSZ * 2)
-
-#define COMMON_OBJ_ID 6
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;
-	unsigned addr;
-};
-
-struct audio {
-	struct buffer out[2];
-
-	spinlock_t dsp_lock;
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed; /* number of buffers the dsp is waiting for */
-
-	atomic_t out_bytes;
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t wait;
-
-	/* configuration to use on next enable */
-	uint32_t out_sample_rate;
-	uint32_t out_channel_mode;
-	uint32_t out_weight;
-	uint32_t out_buffer_size;
-
-	struct audmgr audmgr;
-
-	/* data allocated for various buffers */
-	char *data;
-	dma_addr_t phys;
-
-	int teos; /* valid only if tunnel mode & no data left for decoder */
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped, cleared on flush */
-
-	struct wake_lock wakelock;
-	struct pm_qos_request pm_qos_req;
-
-	audpp_cmd_cfg_object_params_volume vol_pan;
-};
-
-struct audio_copp {
-	int mbadrc_enable;
-	int mbadrc_needs_commit;
-	char *mbadrc_data;
-	dma_addr_t mbadrc_phys;
-
-	audpp_cmd_cfg_object_params_mbadrc mbadrc;
-
-	int eq_enable;
-	int eq_needs_commit;
-	audpp_cmd_cfg_object_params_eqalizer eq;
-
-	int rx_iir_enable;
-	int rx_iir_needs_commit;
-	audpp_cmd_cfg_object_params_pcm iir;
-
-	audpp_cmd_cfg_object_params_volume vol_pan;
-
-	int qconcert_plus_enable;
-	int qconcert_plus_needs_commit;
-
-	int srs_enable;
-	int srs_needs_commit;
-	int srs_feature_mask;
-	audpp_cmd_cfg_object_params_qconcert qconcert_plus;
-	int srs_current_feature_mask;
-	uint32_t audpp_disabled_features;
-
-	int status;
-	int opened;
-	struct mutex lock;
-
-	struct audpp_event_callback ecb;
-
-	struct audpp_cmd_cfg_object_params_srstm_g g;
-	struct audpp_cmd_cfg_object_params_srstm_w w;
-	struct audpp_cmd_cfg_object_params_srstm_c c;
-	struct audpp_cmd_cfg_object_params_srstm_h h;
-	struct audpp_cmd_cfg_object_params_srstm_p p;
-	struct audpp_cmd_cfg_object_params_srstm_l l;
-} the_audio_copp;
-
-static void audio_prevent_sleep(struct audio *audio)
-{
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	wake_lock(&audio->wakelock);
-	pm_qos_update_request(&audio->pm_qos_req,
-			      msm_cpuidle_get_deep_idle_latency());
-}
-
-static void audio_allow_sleep(struct audio *audio)
-{
-	pm_qos_update_request(&audio->pm_qos_req, PM_QOS_DEFAULT_VALUE);
-	wake_unlock(&audio->wakelock);
-	MM_DBG("\n"); /* Macro prints the file name and function */
-}
-
-static int audio_dsp_out_enable(struct audio *audio, int yes);
-static int audio_dsp_send_buffer(struct audio *audio, unsigned id, unsigned len);
-
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg);
-static int audio_enable_srs_trumedia(struct audio_copp *audio_copp, int enable);
-/* must be called with audio->lock held */
-static int audio_enable(struct audio *audio)
-{
-	struct audmgr_config cfg;
-	int rc;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	if (audio->enabled)
-		return 0;	
-
-	/* refuse to start if we're not ready */
-	if (!audio->out[0].used || !audio->out[1].used)
-		return -EIO;
-
-	/* we start buffers 0 and 1, so buffer 0 will be the
-	 * next one the dsp will want
-	 */
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-
-	cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE;
-	cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000;
-	cfg.def_method = RPC_AUD_DEF_METHOD_HOST_PCM;
-	cfg.codec = RPC_AUD_DEF_CODEC_PCM;
-	cfg.snd_method = RPC_SND_METHOD_MIDI;
-
-	audio_prevent_sleep(audio);	
-	rc = audmgr_enable(&audio->audmgr, &cfg);
-	if (rc < 0) {
-		audio_allow_sleep(audio);
-		return rc;
-	}
-
-	if (audpp_enable(-1, audio_dsp_event, audio)) {
-		MM_ERR("audpp_enable() failed\n");
-		audmgr_disable(&audio->audmgr);
-		audio_allow_sleep(audio);
-		return -ENODEV;
-	}
-
-	audio->enabled = 1;
-	htc_pwrsink_set(PWRSINK_AUDIO, 100);
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audio_disable(struct audio *audio)
-{
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audio_dsp_out_enable(audio, 0);
-
-		audpp_disable(-1, audio);
-
-		audio->stopped = 1;
-		wake_up(&audio->wait);
-		audmgr_disable(&audio->audmgr);
-		audio->out_needed = 0;
-		audio_allow_sleep(audio);
-	}
-	return 0;
-}
-
-void audio_commit_pending_pp_params(void *priv, unsigned id, uint16_t *msg)
-{
-	struct audio_copp *audio_copp = priv;
-
-	if (audio_copp == NULL) {
-		MM_ERR("NULL audio copp pointer\n");
-		return;
-	}
-
-	if (AUDPP_MSG_CFG_MSG == id && msg[0] == AUDPP_MSG_ENA_DIS) {
-		audio_copp->audpp_disabled_features = 0;
-		return;
-	}
-	if (AUDPP_MSG_CFG_MSG == id && msg[0] == AUDPP_MSG_ENA_ENA)
-		audio_copp->audpp_disabled_features = 0;
-
-	if (!audio_copp->status)
-		return;
-
-	if (id == AUDPP_MSG_PP_DISABLE_FEEDBACK) {
-		audio_copp->audpp_disabled_features |=
-			((uint32_t)(msg[AUDPP_DISABLE_FEATS_MSW] << 16) |
-			 msg[AUDPP_DISABLE_FEATS_LSW]);
-		MM_DBG("AUDPP disable feedback: %x",
-				audio_copp->audpp_disabled_features);
-		return;
-	} else if (id == AUDPP_MSG_PP_FEATS_RE_ENABLE) {
-		MM_DBG("AUDPP re-enable messaage: %x, acdb_enabled %d",
-			audio_copp->audpp_disabled_features, is_acdb_enabled());
-		if (!is_acdb_enabled()) {
-			if ((audio_copp->audpp_disabled_features &
-				(1 << AUDPP_CMD_MBADRC)) ==
-				(1 << AUDPP_CMD_MBADRC)) {
-				audpp_dsp_set_mbadrc(COMMON_OBJ_ID,
-						audio_copp->mbadrc_enable,
-						&audio_copp->mbadrc);
-			}
-			if ((audio_copp->audpp_disabled_features &
-				(1 << AUDPP_CMD_EQUALIZER)) ==
-				(1 << AUDPP_CMD_EQUALIZER)) {
-				audpp_dsp_set_eq(COMMON_OBJ_ID,
-						audio_copp->eq_enable,
-						&audio_copp->eq);
-			}
-			if ((audio_copp->audpp_disabled_features &
-				(1 << AUDPP_CMD_IIR_TUNING_FILTER)) ==
-				(1 << AUDPP_CMD_IIR_TUNING_FILTER)) {
-				audpp_dsp_set_rx_iir(COMMON_OBJ_ID,
-						audio_copp->rx_iir_enable,
-						&audio_copp->iir);
-			}
-			if ((audio_copp->audpp_disabled_features &
-				(1 << AUDPP_CMD_QCONCERT)) ==
-					(1 << AUDPP_CMD_QCONCERT)) {
-				audpp_dsp_set_qconcert_plus(COMMON_OBJ_ID,
-					audio_copp->qconcert_plus_enable,
-					&audio_copp->qconcert_plus);
-			}
-		}
-		if ((audio_copp->audpp_disabled_features & (1 << AUDPP_CMD_SRS))
-			== (1 << AUDPP_CMD_SRS)) {
-			if (audio_copp->srs_current_feature_mask & SRS_MASK_W)
-				audpp_dsp_set_rx_srs_trumedia_w(&audio_copp->w);
-			if (audio_copp->srs_current_feature_mask & SRS_MASK_C)
-				audpp_dsp_set_rx_srs_trumedia_c(&audio_copp->c);
-			if (audio_copp->srs_current_feature_mask & SRS_MASK_HP)
-				audpp_dsp_set_rx_srs_trumedia_h(&audio_copp->h);
-			if (audio_copp->srs_current_feature_mask & SRS_MASK_P)
-				audpp_dsp_set_rx_srs_trumedia_p(&audio_copp->p);
-			if (audio_copp->srs_current_feature_mask & SRS_MASK_HL)
-				audpp_dsp_set_rx_srs_trumedia_l(&audio_copp->l);
-			if (audio_copp->srs_current_feature_mask & SRS_MASK_G)
-				audpp_dsp_set_rx_srs_trumedia_g(&audio_copp->g);
-		}
-		audio_copp->audpp_disabled_features = 0;
-		return;
-	}
-
-	if (!is_acdb_enabled()) {
-		audpp_dsp_set_mbadrc(COMMON_OBJ_ID, audio_copp->mbadrc_enable,
-						&audio_copp->mbadrc);
-
-		audpp_dsp_set_eq(COMMON_OBJ_ID, audio_copp->eq_enable,
-						&audio_copp->eq);
-		audpp_dsp_set_rx_iir(COMMON_OBJ_ID, audio_copp->rx_iir_enable,
-							&audio_copp->iir);
-		audpp_dsp_set_vol_pan(COMMON_OBJ_ID, &audio_copp->vol_pan);
-
-		audpp_dsp_set_qconcert_plus(COMMON_OBJ_ID,
-				audio_copp->qconcert_plus_enable,
-				&audio_copp->qconcert_plus);
-	}
-	audio_enable_srs_trumedia(audio_copp, true);
-}
-EXPORT_SYMBOL(audio_commit_pending_pp_params);
-
-/* ------------------- dsp --------------------- */
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg)
-{
-	struct audio *audio = private;
-	struct buffer *frame;
-	unsigned long flags;
-
-	LOG(EV_DSP_EVENT, id);
-	switch (id) {
-	case AUDPP_MSG_HOST_PCM_INTF_MSG: {
-		unsigned id = msg[2];
-		unsigned idx = msg[3] - 1;
-
-		/* MM_INFO("HOST_PCM id %d idx %d\n", id, idx); */
-		if (id != AUDPP_MSG_HOSTPCM_ID_ARM_RX) {
-			MM_ERR("bogus id\n");
-			break;
-		}
-		if (idx > 1) {
-			MM_ERR("bogus buffer idx\n");
-			break;
-		}
-
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		if (audio->running) {
-			atomic_add(audio->out[idx].used, &audio->out_bytes);
-			audio->out[idx].used = 0;
-
-			frame = audio->out + audio->out_tail;
-			if (frame->used) {
-				audio_dsp_send_buffer(
-					audio, audio->out_tail, frame->used);
-				audio->out_tail ^= 1;
-			} else {
-				audio->out_needed++;
-			}
-			wake_up(&audio->wait);
-		}
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		break;
-	}
-	case AUDPP_MSG_PCMDMAMISSED:
-		MM_INFO("PCMDMAMISSED %d\n", msg[0]);
-		audio->teos = 1;
-		wake_up(&audio->wait);
-		break;
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			LOG(EV_ENABLE, 1);
-			MM_DBG("CFG_MSG ENABLE\n");
-			audio->out_needed = 0;
-			audio->running = 1;
-			audpp_dsp_set_vol_pan(5, &audio->vol_pan);
-			audio_dsp_out_enable(audio, 1);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			LOG(EV_ENABLE, 0);
-			MM_DBG("CFG_MSG DISABLE\n");
-			audio->running = 0;
-		} else {
-			MM_ERR("CFG_MSG %d?\n", msg[0]);
-		}
-		break;
-	default:
-		MM_ERR("UNKNOWN (%d)\n", id);
-	}
-}
-
-static int audio_dsp_out_enable(struct audio *audio, int yes)
-{
-	audpp_cmd_pcm_intf cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id	= AUDPP_CMD_PCM_INTF_2; 
-	cmd.object_num	= AUDPP_CMD_PCM_INTF_OBJECT_NUM;
-	cmd.config	= AUDPP_CMD_PCM_INTF_CONFIG_CMD_V;
-	cmd.intf_type	= AUDPP_CMD_PCM_INTF_RX_ENA_ARMTODSP_V;
-
-	if (yes) {
-		cmd.write_buf1LSW	= audio->out[0].addr;
-		cmd.write_buf1MSW	= audio->out[0].addr >> 16;
-		if (audio->out[0].used)
-			cmd.write_buf1_len	= audio->out[0].used;
-		else
-			cmd.write_buf1_len	= audio->out[0].size;
-		cmd.write_buf2LSW	= audio->out[1].addr;
-		cmd.write_buf2MSW	= audio->out[1].addr >> 16;
-		if (audio->out[1].used)
-			cmd.write_buf2_len	= audio->out[1].used;
-		else
-			cmd.write_buf2_len	= audio->out[1].size;
-		cmd.arm_to_rx_flag	= AUDPP_CMD_PCM_INTF_ENA_V;
-		cmd.weight_decoder_to_rx = audio->out_weight;
-		cmd.weight_arm_to_rx	= 1;
-		cmd.partition_number_arm_to_dsp = 0;
-		cmd.sample_rate		= audio->out_sample_rate;
-		cmd.channel_mode	= audio->out_channel_mode;
-	}
-	
-	return audpp_send_queue2(&cmd, sizeof(cmd));
-}
-
-static int audio_dsp_send_buffer(struct audio *audio, unsigned idx, unsigned len)
-{
-	audpp_cmd_pcm_intf_send_buffer cmd;
-	
-	cmd.cmd_id		= AUDPP_CMD_PCM_INTF_2;
-	cmd.host_pcm_object	= AUDPP_CMD_PCM_INTF_OBJECT_NUM;
-	cmd.config		= AUDPP_CMD_PCM_INTF_BUFFER_CMD_V;
-	cmd.intf_type		= AUDPP_CMD_PCM_INTF_RX_ENA_ARMTODSP_V;
-	cmd.dsp_to_arm_buf_id	= 0;
-	cmd.arm_to_dsp_buf_id	= idx + 1;
-	cmd.arm_to_dsp_buf_len	= len;
-
-	LOG(EV_SEND_BUFFER, idx);
-	dma_coherent_pre_ops();
-	return audpp_send_queue2(&cmd, sizeof(cmd));
-}
-
-/* ------------------- device --------------------- */
-
-static int audio_enable_mbadrc(struct audio_copp *audio_copp, int enable)
-{
-	if (audio_copp->mbadrc_enable == enable &&
-				!audio_copp->mbadrc_needs_commit)
-		return 0;
-
-	audio_copp->mbadrc_enable = enable;
-	if (is_audpp_enable()) {
-		audpp_dsp_set_mbadrc(COMMON_OBJ_ID, enable,
-						&audio_copp->mbadrc);
-		audio_copp->mbadrc_needs_commit = 0;
-	}
-
-	return 0;
-}
-
-static int audio_enable_eq(struct audio_copp *audio_copp, int enable)
-{
-	if (audio_copp->eq_enable == enable &&
-				!audio_copp->eq_needs_commit)
-		return 0;
-
-	audio_copp->eq_enable = enable;
-
-	if (is_audpp_enable()) {
-		audpp_dsp_set_eq(COMMON_OBJ_ID, enable, &audio_copp->eq);
-		audio_copp->eq_needs_commit = 0;
-	}
-	return 0;
-}
-
-static int audio_enable_rx_iir(struct audio_copp *audio_copp, int enable)
-{
-	if (audio_copp->rx_iir_enable == enable &&
-				!audio_copp->rx_iir_needs_commit)
-		return 0;
-
-	audio_copp->rx_iir_enable = enable;
-
-	if (is_audpp_enable()) {
-		audpp_dsp_set_rx_iir(COMMON_OBJ_ID, enable, &audio_copp->iir);
-		audio_copp->rx_iir_needs_commit = 0;
-	}
-	return 0;
-}
-
-static int audio_enable_srs_trumedia(struct audio_copp *audio_copp, int enable)
-{
-
-	if (!audio_copp->srs_needs_commit)
-		return 0;
-
-	audio_copp->srs_enable = enable;
-
-	MM_DBG("Enable SRS flags 0x%x enable %d\n",
-		audio_copp->srs_feature_mask, enable);
-	if (is_audpp_enable()) {
-		MM_DBG("Updating audpp for srs\n");
-		if (audio_copp->srs_feature_mask & SRS_MASK_W)
-			audpp_dsp_set_rx_srs_trumedia_w(&audio_copp->w);
-		if (audio_copp->srs_feature_mask & SRS_MASK_C)
-			audpp_dsp_set_rx_srs_trumedia_c(&audio_copp->c);
-		if (audio_copp->srs_feature_mask & SRS_MASK_HP)
-			audpp_dsp_set_rx_srs_trumedia_h(&audio_copp->h);
-		if (audio_copp->srs_feature_mask & SRS_MASK_P)
-			audpp_dsp_set_rx_srs_trumedia_p(&audio_copp->p);
-		if (audio_copp->srs_feature_mask & SRS_MASK_HL)
-			audpp_dsp_set_rx_srs_trumedia_l(&audio_copp->l);
-		if (audio_copp->srs_feature_mask & SRS_MASK_G)
-			audpp_dsp_set_rx_srs_trumedia_g(&audio_copp->g);
-
-		audio_copp->srs_current_feature_mask =
-			audio_copp->srs_feature_mask;
-		audio_copp->srs_needs_commit = 0;
-		audio_copp->srs_feature_mask = 0;
-	}
-	return 0;
-}
-
-static int audio_enable_vol_pan(struct audio_copp *audio_copp)
-{
-	if (is_audpp_enable())
-		audpp_dsp_set_vol_pan(COMMON_OBJ_ID, &audio_copp->vol_pan);
-	return 0;
-}
-
-static int audio_enable_qconcert_plus(struct audio_copp *audio_copp, int enable)
-{
-	if (audio_copp->qconcert_plus_enable == enable &&
-				!audio_copp->qconcert_plus_needs_commit)
-		return 0;
-
-	audio_copp->qconcert_plus_enable = enable;
-
-	if (is_audpp_enable()) {
-		audpp_dsp_set_qconcert_plus(COMMON_OBJ_ID, enable,
-					&audio_copp->qconcert_plus);
-		audio_copp->qconcert_plus_needs_commit = 0;
-	}
-	return 0;
-}
-
-static void audio_flush(struct audio *audio)
-{
-	audio->out[0].used = 0;
-	audio->out[1].used = 0;
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->stopped = 0;
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = -EINVAL;
-	unsigned long flags = 0;
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		stats.byte_count = atomic_read(&audio->out_bytes);
-		if (copy_to_user((void*) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-
-	switch (cmd) {
-	case AUDIO_SET_VOLUME:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.volume = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(5, &audio->vol_pan);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		return 0;
-
-	case AUDIO_SET_PAN:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.pan = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(5, &audio->vol_pan);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		return 0;
-	}
-
-	LOG(EV_IOCTL, cmd);
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		rc = audio_enable(audio);
-		break;
-	case AUDIO_STOP:
-		rc = audio_disable(audio);
-		break;
-	case AUDIO_FLUSH:
-		if (audio->stopped) {
-			/* Make sure we're stopped and we wake any threads
-			 * that might be blocked holding the write_lock.
-			 * While audio->stopped write threads will always
-			 * exit immediately.
-			 */
-			wake_up(&audio->wait);
-			mutex_lock(&audio->write_lock);
-			audio_flush(audio);
-			mutex_unlock(&audio->write_lock);
-		}
-		break;
-	case AUDIO_SET_CONFIG: {
-		struct msm_audio_config config;
-		if (copy_from_user(&config, (void*) arg, sizeof(config))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (config.channel_count == 1) {
-			config.channel_count = AUDPP_CMD_PCM_INTF_MONO_V;
-		} else if (config.channel_count == 2) {
-			config.channel_count= AUDPP_CMD_PCM_INTF_STEREO_V;
-		} else {
-			rc = -EINVAL;
-			break;
-		}
-		audio->out_sample_rate = config.sample_rate;
-		audio->out_channel_mode = config.channel_count;
-		rc = 0;
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config config;
-		config.buffer_size = BUFSZ;
-		config.buffer_count = 2;
-		config.sample_rate = audio->out_sample_rate;
-		if (audio->out_channel_mode == AUDPP_CMD_PCM_INTF_MONO_V) {
-			config.channel_count = 1;
-		} else {
-			config.channel_count = 2;
-		}
-		config.unused[0] = 0;
-		config.unused[1] = 0;
-		config.unused[2] = 0;
-		if (copy_to_user((void*) arg, &config, sizeof(config))) {
-			rc = -EFAULT;
-		} else {
-			rc = 0;
-		}
-		break;
-	}
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-/* Only useful in tunnel-mode */
-static int audio_fsync(struct file *file, loff_t a, loff_t b, int datasync)
-{
-	struct audio *audio = file->private_data;
-	int rc = 0;
-
-	if (!audio->running)
-		return -EINVAL;
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->wait,
-		(!audio->out[0].used &&
-		!audio->out[1].used));
-
-	if (rc < 0)
-		goto done;
-
-	/* pcm dmamiss message is sent continously when
-	 * decoder is starved so no race condition concern
-	 */
-
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->wait,
-		audio->teos);
-
-done:
-	mutex_unlock(&audio->write_lock);
-	return rc;
-}
-
-static ssize_t audio_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
-{
-	return -EINVAL;
-}
-
-static inline int rt_policy(int policy)
-{
-	if (unlikely(policy == SCHED_FIFO) || unlikely(policy == SCHED_RR))
-		return 1;
-	return 0;
-}
-
-static inline int task_has_rt_policy(struct task_struct *p)
-{
-	return rt_policy(p->policy);
-}
-
-static ssize_t audio_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct sched_param s = { .sched_priority = 1 };
-	struct audio *audio = file->private_data;
-	unsigned long flags;
-	const char __user *start = buf;
-	struct buffer *frame;
-	size_t xfer;
-	int old_prio = current->rt_priority;
-	int old_policy = current->policy;
-	int cap_nice = cap_raised(current_cap(), CAP_SYS_NICE);
-	int rc = 0;
-
-	LOG(EV_WRITE, count | (audio->running << 28) | (audio->stopped << 24));
-
-	/* just for this write, set us real-time */
-	if (!task_has_rt_policy(current)) {
-		struct cred *new = prepare_creds();
-		cap_raise(new->cap_effective, CAP_SYS_NICE);
-		commit_creds(new);
-		if ((sched_setscheduler(current, SCHED_RR, &s)) < 0)
-			MM_ERR("sched_setscheduler failed\n");
-	}
-
-	mutex_lock(&audio->write_lock);
-	while (count > 0) {
-		frame = audio->out + audio->out_head;
-
-		LOG(EV_WAIT_EVENT, 0);
-		rc = wait_event_interruptible(audio->wait,
-					      (frame->used == 0) || (audio->stopped));
-		LOG(EV_WAIT_EVENT, 1);
-
-		if (rc < 0)
-			break;
-		if (audio->stopped) {
-			rc = -EBUSY;
-			break;
-		}
-		xfer = count > frame->size ? frame->size : count;
-		if (copy_from_user(frame->data, buf, xfer)) {
-			rc = -EFAULT;
-			break;
-		}
-		frame->used = xfer;
-		audio->out_head ^= 1;
-		count -= xfer;
-		buf += xfer;
-
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		LOG(EV_FILL_BUFFER, audio->out_head ^ 1);
-		frame = audio->out + audio->out_tail;
-		if (frame->used && audio->out_needed) {
-			audio_dsp_send_buffer(audio, audio->out_tail, frame->used);
-			audio->out_tail ^= 1;
-			audio->out_needed--;
-		}
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	}
-
-	mutex_unlock(&audio->write_lock);
-
-	/* restore scheduling policy and priority */
-	if (!rt_policy(old_policy)) {
-		struct sched_param v = { .sched_priority = old_prio };
-		if ((sched_setscheduler(current, old_policy, &v)) < 0)
-			MM_ERR("sched_setscheduler failed\n");
-		if (likely(!cap_nice)) {
-			struct cred *new = prepare_creds();
-			cap_lower(new->cap_effective, CAP_SYS_NICE);
-			commit_creds(new);
-		}
-	}
-
-	LOG(EV_RETURN,(buf > start) ? (buf - start) : rc);
-	if (buf > start)
-		return buf - start;
-	return rc;	
-}
-
-static int audio_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	LOG(EV_OPEN, 0);
-	mutex_lock(&audio->lock);
-	audio_disable(audio);
-	audio_flush(audio);
-	audio->opened = 0;
-	mutex_unlock(&audio->lock);
-	htc_pwrsink_set(PWRSINK_AUDIO, 0);
-	return 0;
-}
-
-struct audio the_audio;
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = &the_audio;
-	int rc;
-
-	mutex_lock(&audio->lock);
-
-	if (audio->opened) {
-		MM_ERR("busy\n");
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (!audio->data) {
-		audio->data = dma_alloc_coherent(NULL, DMASZ, 
-						 &audio->phys, GFP_KERNEL);
-		if (!audio->data) {
-			MM_ERR("could not allocate DMA buffers\n");
-			rc = -ENOMEM;
-			goto done;
-		}
-	}
-
-	rc = audmgr_open(&audio->audmgr);
-	if (rc)
-		goto done;
-
-	audio->out_buffer_size = BUFSZ;
-	audio->out_sample_rate = 48000;
-	audio->out_channel_mode = AUDPP_CMD_PCM_INTF_STEREO_V;
-	audio->out_weight = 100;
-
-	audio->out[0].data = audio->data + 0;
-	audio->out[0].addr = audio->phys + 0;
-	audio->out[0].size = BUFSZ;
-	
-	audio->out[1].data = audio->data + BUFSZ;
-	audio->out[1].addr = audio->phys + BUFSZ;
-	audio->out[1].size = BUFSZ;
-
-	audio->vol_pan.volume = 0x2000;
-	audio->vol_pan.pan = 0x0;
-
-	audio_flush(audio);
-
-	file->private_data = audio;
-	audio->opened = 1;
-	rc = 0;
-	LOG(EV_OPEN, 1);
-done:
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static long audpp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct audio_copp *audio_copp = file->private_data;
-	int rc = 0, enable;
-	uint16_t enable_mask;
-	int prev_state;
-	uint32_t to_set, size = 0;
-	void *tmpbuf, *srs_params = NULL;
-
-	mutex_lock(&audio_copp->lock);
-	switch (cmd) {
-	case AUDIO_ENABLE_AUDPP:
-		if (copy_from_user(&enable_mask, (void *) arg,
-						sizeof(enable_mask))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		enable = ((enable_mask & ADRC_ENABLE) ||
-				(enable_mask & MBADRC_ENABLE)) ? 1 : 0;
-		audio_enable_mbadrc(audio_copp, enable);
-		enable = (enable_mask & EQ_ENABLE) ? 1 : 0;
-		audio_enable_eq(audio_copp, enable);
-		enable = (enable_mask & IIR_ENABLE) ? 1 : 0;
-		audio_enable_rx_iir(audio_copp, enable);
-		enable = (enable_mask & QCONCERT_PLUS_ENABLE) ? 1 : 0;
-		audio_enable_qconcert_plus(audio_copp, enable);
-		enable = (enable_mask & SRS_ENABLE) ? 1 : 0;
-		audio_enable_srs_trumedia(audio_copp, enable);
-		break;
-
-	case AUDIO_SET_MBADRC: {
-		uint32_t mbadrc_coeff_buf;
-		prev_state = audio_copp->mbadrc_enable;
-		audio_copp->mbadrc_enable = 0;
-		if (copy_from_user(&audio_copp->mbadrc.num_bands, (void *) arg,
-				sizeof(audio_copp->mbadrc) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2)))
-			rc = -EFAULT;
-		else if (audio_copp->mbadrc.ext_buf_size) {
-			mbadrc_coeff_buf = (uint32_t) ((char *) arg +
-					sizeof(audio_copp->mbadrc) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2));
-			if ((copy_from_user(audio_copp->mbadrc_data,
-					(void *) mbadrc_coeff_buf,
-					AUDPP_MBADRC_EXTERNAL_BUF_SIZE * 2))) {
-				rc = -EFAULT;
-				break;
-			}
-			audio_copp->mbadrc.ext_buf_lsw =
-					audio_copp->mbadrc_phys & 0xFFFF;
-			audio_copp->mbadrc.ext_buf_msw =
-				((audio_copp->mbadrc_phys & 0xFFFF0000) >> 16);
-		}
-		audio_copp->mbadrc_enable = prev_state;
-		if (!rc)
-			audio_copp->mbadrc_needs_commit = 1;
-		break;
-	}
-
-	case AUDIO_SET_ADRC: {
-			struct audpp_cmd_cfg_object_params_adrc adrc;
-			prev_state = audio_copp->mbadrc_enable;
-			audio_copp->mbadrc_enable = 0;
-			if (copy_from_user(&adrc.compression_th, (void *) arg,
-							sizeof(adrc) - 2)) {
-				rc = -EFAULT;
-				audio_copp->mbadrc_enable = prev_state;
-				break;
-			}
-			audio_copp->mbadrc.num_bands = 1;
-			audio_copp->mbadrc.down_samp_level = 8;
-			audio_copp->mbadrc.adrc_delay = adrc.adrc_delay;
-			audio_copp->mbadrc.ext_buf_size = 0;
-			audio_copp->mbadrc.ext_partition = 0;
-			audio_copp->mbadrc.adrc_band[0].subband_enable = 1;
-			audio_copp->mbadrc.adrc_band[0].adrc_sub_mute = 0;
-			audio_copp->mbadrc.adrc_band[0].rms_time =
-								adrc.rms_time;
-			audio_copp->mbadrc.adrc_band[0].compression_th =
-							adrc.compression_th;
-			audio_copp->mbadrc.adrc_band[0].compression_slope =
-							adrc.compression_slope;
-			audio_copp->mbadrc.adrc_band[0].attack_const_lsw =
-							adrc.attack_const_lsw;
-			audio_copp->mbadrc.adrc_band[0].attack_const_msw =
-							adrc.attack_const_msw;
-			audio_copp->mbadrc.adrc_band[0].release_const_lsw =
-							adrc.release_const_lsw;
-			audio_copp->mbadrc.adrc_band[0].release_const_msw =
-							adrc.release_const_msw;
-			audio_copp->mbadrc.adrc_band[0].makeup_gain = 0x2000;
-			audio_copp->mbadrc_enable = prev_state;
-			audio_copp->mbadrc_needs_commit = 1;
-			break;
-		}
-
-	case AUDIO_SET_EQ:
-		prev_state = audio_copp->eq_enable;
-		audio_copp->eq_enable = 0;
-		if (copy_from_user(&audio_copp->eq.num_bands, (void *) arg,
-				sizeof(audio_copp->eq) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2)))
-			rc = -EFAULT;
-		audio_copp->eq_enable = prev_state;
-		audio_copp->eq_needs_commit = 1;
-		break;
-
-	case AUDIO_SET_RX_IIR:
-		prev_state = audio_copp->rx_iir_enable;
-		audio_copp->rx_iir_enable = 0;
-		if (copy_from_user(&audio_copp->iir.num_bands, (void *) arg,
-				sizeof(audio_copp->iir) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2)))
-			rc = -EFAULT;
-		audio_copp->rx_iir_enable = prev_state;
-		audio_copp->rx_iir_needs_commit = 1;
-		break;
-
-	case AUDIO_SET_VOLUME:
-		audio_copp->vol_pan.volume = arg;
-		audio_enable_vol_pan(audio_copp);
-		break;
-
-	case AUDIO_SET_PAN:
-		audio_copp->vol_pan.pan = arg;
-		audio_enable_vol_pan(audio_copp);
-		break;
-
-	case AUDIO_SET_QCONCERT_PLUS:
-		prev_state = audio_copp->qconcert_plus_enable;
-		audio_copp->qconcert_plus_enable = 0;
-		if (copy_from_user(&audio_copp->qconcert_plus.op_mode,
-				(void *) arg,
-				sizeof(audio_copp->qconcert_plus) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2)))
-			rc = -EFAULT;
-		audio_copp->qconcert_plus_enable = prev_state;
-		audio_copp->qconcert_plus_needs_commit = 1;
-		break;
-
-	case AUDIO_SET_SRS_TRUMEDIA_PARAM: {
-		prev_state = audio_copp->srs_enable;
-		audio_copp->srs_enable = 0;
-
-		if (copy_from_user(&to_set, (void *)arg, sizeof(uint32_t))) {
-			rc = -EFAULT;
-			break;
-		}
-		switch (to_set) {
-		case SRS_ID_GLOBAL:
-			srs_params = (void *)audio_copp->g.v;
-			size = sizeof(audio_copp->g.v);
-			audio_copp->srs_feature_mask |= SRS_MASK_G;
-			break;
-		case SRS_ID_WOWHD:
-			srs_params = (void *)audio_copp->w.v;
-			size = sizeof(audio_copp->w.v);
-			audio_copp->srs_feature_mask |= SRS_MASK_W;
-			break;
-		case SRS_ID_CSHP:
-			srs_params = (void *)audio_copp->c.v;
-			size = sizeof(audio_copp->c.v);
-			audio_copp->srs_feature_mask |= SRS_MASK_C;
-			break;
-		case SRS_ID_HPF:
-			srs_params = (void *)audio_copp->h.v;
-			size = sizeof(audio_copp->h.v);
-			audio_copp->srs_feature_mask |= SRS_MASK_HP;
-			break;
-		case SRS_ID_PEQ:
-			srs_params = (void *)audio_copp->p.v;
-			size = sizeof(audio_copp->p.v);
-			audio_copp->srs_feature_mask |= SRS_MASK_P;
-			break;
-		case SRS_ID_HL:
-			srs_params = (void *)audio_copp->l.v;
-			size = sizeof(audio_copp->l.v);
-			audio_copp->srs_feature_mask |= SRS_MASK_HL;
-			break;
-		default:
-			MM_ERR("SRS TruMedia error: invalid ioctl\n");
-			rc = -EINVAL;
-		}
-
-		if (rc >= 0) {
-			tmpbuf = kzalloc(sizeof(uint32_t) + size , GFP_KERNEL);
-			if (!tmpbuf) {
-				MM_ERR("SRS TruMedia error: no kernel mem\n");
-				rc = -ENOMEM;
-			} else {
-				if (copy_from_user(tmpbuf, (void *)arg,
-						sizeof(uint32_t) + size))
-					rc = -EFAULT;
-				memcpy(srs_params,
-					&(((uint32_t *)tmpbuf)[1]), size);
-				kfree(tmpbuf);
-			}
-		}
-
-		MM_DBG("Ioctl SRS flags=0x%x\n", audio_copp->srs_feature_mask);
-		if (rc < 0)
-			MM_ERR("SRS TruMedia error setting params failed.\n");
-		else{
-			audio_copp->srs_needs_commit = 1;
-			audio_copp->srs_enable = prev_state;
-		}
-		break;
-	}
-
-	default:
-		rc = -EINVAL;
-	}
-
-	mutex_unlock(&audio_copp->lock);
-	return rc;
-}
-
-static int audpp_open(struct inode *inode, struct file *file)
-{
-	struct audio_copp *audio_copp = &the_audio_copp;
-	int rc;
-
-	mutex_lock(&audio_copp->lock);
-	if (audio_copp->opened) {
-		mutex_unlock(&audio_copp->lock);
-		return -EBUSY;
-	}
-
-	audio_copp->opened = 1;
-
-	if (!audio_copp->status) {
-		audio_copp->ecb.fn = audio_commit_pending_pp_params;
-		audio_copp->ecb.private = audio_copp;
-		rc = audpp_register_event_callback(&audio_copp->ecb);
-		if (rc) {
-			audio_copp->opened = 0;
-			mutex_unlock(&audio_copp->lock);
-			return rc;
-		}
-		audio_copp->mbadrc_data = dma_alloc_coherent(NULL,
-				AUDPP_MBADRC_EXTERNAL_BUF_SIZE * 2,
-				 &audio_copp->mbadrc_phys, GFP_KERNEL);
-		if (!audio_copp->mbadrc_data) {
-			MM_ERR("could not allocate DMA buffers\n");
-			audio_copp->opened = 0;
-			audpp_unregister_event_callback(&audio_copp->ecb);
-			mutex_unlock(&audio_copp->lock);
-			return -ENOMEM;
-		}
-		audio_copp->vol_pan.volume = 0x2000;
-		audio_copp->vol_pan.pan = 0x0;
-		audio_copp->status = 1;
-	}
-
-	file->private_data = audio_copp;
-	mutex_unlock(&audio_copp->lock);
-
-	return 0;
-}
-
-static int audpp_release(struct inode *inode, struct file *file)
-{
-	struct audio_copp *audio_copp = &the_audio_copp;
-
-	audio_copp->opened = 0;
-
-	return 0;
-}
-
-static struct file_operations audio_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audio_open,
-	.release	= audio_release,
-	.read		= audio_read,
-	.write		= audio_write,
-	.unlocked_ioctl	= audio_ioctl,
-	.fsync		= audio_fsync,
-};
-
-static struct file_operations audpp_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audpp_open,
-	.release	= audpp_release,
-	.unlocked_ioctl	= audpp_ioctl,
-};
-
-struct miscdevice audio_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_pcm_out",
-	.fops	= &audio_fops,
-};
-
-struct miscdevice audpp_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_pcm_ctl",
-	.fops	= &audpp_fops,
-};
-
-static int __init audio_init(void)
-{
-	mutex_init(&the_audio.lock);
-	mutex_init(&the_audio.write_lock);
-	mutex_init(&the_audio_copp.lock);
-	spin_lock_init(&the_audio.dsp_lock);
-	init_waitqueue_head(&the_audio.wait);
-	wake_lock_init(&the_audio.wakelock, WAKE_LOCK_SUSPEND, "audio_pcm");
-	pm_qos_add_request(&the_audio.pm_qos_req, PM_QOS_CPU_DMA_LATENCY,
-				PM_QOS_DEFAULT_VALUE);
-	return (misc_register(&audio_misc) || misc_register(&audpp_misc));
-}
-
-device_initcall(audio_init);
diff --git a/arch/arm/mach-msm/qdsp5/audio_pcm.c b/arch/arm/mach-msm/qdsp5/audio_pcm.c
deleted file mode 100644
index 4ffc2be..0000000
--- a/arch/arm/mach-msm/qdsp5/audio_pcm.c
+++ /dev/null
@@ -1,1746 +0,0 @@
-
-/* audio_pcm.c - pcm audio decoder driver
- *
- * Copyright (c) 2009-2012, The Linux Foundation. All rights reserved.
- *
- * Based on the mp3 decoder driver in arch/arm/mach-msm/qdsp5/audio_mp3.c
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- *
- * All source code in this file is licensed under the following license except
- * where indicated.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you can find it at http://www.fsf.org
- */
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/earlysuspend.h>
-#include <linux/list.h>
-#include <linux/msm_ion.h>
-#include <linux/slab.h>
-#include <linux/msm_audio.h>
-
-
-#include <mach/msm_adsp.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/qdsp5/qdsp5audppcmdi.h>
-#include <mach/qdsp5/qdsp5audppmsg.h>
-#include <mach/qdsp5/qdsp5audpp.h>
-#include <mach/qdsp5/qdsp5audplaycmdi.h>
-#include <mach/qdsp5/qdsp5audplaymsg.h>
-#include <mach/qdsp5/qdsp5rmtcmdi.h>
-#include <mach/debug_mm.h>
-#include <linux/memory_alloc.h>
-#include <mach/msm_memtypes.h>
-
-#include "audmgr.h"
-
-/* for queue ids - should be relative to module number*/
-#include "adsp.h"
-
-#define ADRV_STATUS_AIO_INTF 0x00000001
-#define ADRV_STATUS_OBUF_GIVEN 0x00000002
-#define ADRV_STATUS_IBUF_GIVEN 0x00000004
-#define ADRV_STATUS_FSYNC 0x00000008
-
-/* Size must be power of 2 */
-#define BUFSZ_MAX 32768
-#define BUFSZ_MIN 4096
-#define DMASZ_MAX (BUFSZ_MAX * 2)
-#define DMASZ_MIN (BUFSZ_MIN * 2)
-
-#define AUDDEC_DEC_PCM 0
-
-/* Decoder status received from AUDPPTASK */
-#define  AUDPP_DEC_STATUS_SLEEP	0
-#define  AUDPP_DEC_STATUS_INIT  1
-#define  AUDPP_DEC_STATUS_CFG   2
-#define  AUDPP_DEC_STATUS_PLAY  3
-
-#define AUDPCM_EVENT_NUM 10 /* Default number of pre-allocated event packets */
-
-#define __CONTAINS(r, v, l) ({					\
-	typeof(r) __r = r;					\
-	typeof(v) __v = v;					\
-	typeof(v) __e = __v + l;				\
-	int res = ((__v >= __r->vaddr) && 			\
-		(__e <= __r->vaddr + __r->len));		\
-	res;							\
-})
-
-#define CONTAINS(r1, r2) ({					\
-	typeof(r2) __r2 = r2;					\
-	__CONTAINS(r1, __r2->vaddr, __r2->len);			\
-})
-
-#define IN_RANGE(r, v) ({					\
-	typeof(r) __r = r;					\
-	typeof(v) __vv = v;					\
-	int res = ((__vv >= __r->vaddr) &&			\
-		(__vv < (__r->vaddr + __r->len)));		\
-	res;							\
-})
-
-#define OVERLAPS(r1, r2) ({					\
-	typeof(r1) __r1 = r1;					\
-	typeof(r2) __r2 = r2;					\
-	typeof(__r2->vaddr) __v = __r2->vaddr;			\
-	typeof(__v) __e = __v + __r2->len - 1;			\
-	int res = (IN_RANGE(__r1, __v) || IN_RANGE(__r1, __e));	\
-	res;							\
-})
-
-struct audio;
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;		/* Input usage actual DSP produced PCM size  */
-	unsigned addr;
-};
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-struct audpcm_suspend_ctl {
-  struct early_suspend node;
-  struct audio *audio;
-};
-#endif
-
-struct audpcm_event {
-	struct list_head list;
-	int event_type;
-	union msm_audio_event_payload payload;
-};
-
-struct audpcm_ion_region {
-	struct list_head list;
-	struct ion_handle *handle;
-	int fd;
-	void *vaddr;
-	unsigned long paddr;
-	unsigned long kvaddr;
-	unsigned long len;
-	unsigned ref_cnt;
-};
-
-struct audpcm_buffer_node {
-	struct list_head list;
-	struct msm_audio_aio_buf buf;
-	unsigned long paddr;
-};
-
-struct audpcm_drv_operations {
-	void (*send_data)(struct audio *, unsigned);
-	void (*out_flush)(struct audio *);
-	int (*fsync)(struct audio *);
-};
-
-struct audio {
-	struct buffer out[2];
-
-	spinlock_t dsp_lock;
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed; /* number of buffers the dsp is waiting for */
-	unsigned out_dma_sz;
-	struct list_head out_queue; /* queue to retain output buffers */
-	atomic_t out_bytes;
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-
-	struct msm_adsp_module *audplay;
-
-	/* configuration to use on next enable */
-	uint32_t out_sample_rate;
-	uint32_t out_channel_mode;
-	uint32_t out_bits; /* bits per sample */
-
-	struct audmgr audmgr;
-
-	/* data allocated for various buffers */
-	char *data;
-	int32_t phys;
-	void *map_v_write;
-
-	uint32_t drv_status;
-	int wflush; /* Write flush */
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped, cleared on flush */
-	int teos; /* valid only if tunnel mode & no data left for decoder */
-	int rmt_resource_released;
-	enum msm_aud_decoder_state dec_state; /* Represents decoder state */
-	int reserved; /* A byte is being reserved */
-	char rsv_byte; /* Handle odd length user data */
-
-	const char *module_name;
-	unsigned queue_id;
-
-	unsigned volume;
-
-	uint16_t dec_id;
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	struct audpcm_suspend_ctl suspend_ctl;
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *dentry;
-#endif
-	wait_queue_head_t wait;
-	struct list_head free_event_queue;
-	struct list_head event_queue;
-	wait_queue_head_t event_wait;
-	spinlock_t event_queue_lock;
-	struct mutex get_event_lock;
-	int event_abort;
-
-	struct list_head ion_region_queue;
-	struct audpcm_drv_operations drv_ops;
-	struct ion_client *client;
-	struct ion_handle *output_buff_handle;
-};
-
-static int auddec_dsp_config(struct audio *audio, int enable);
-static void audpp_cmd_cfg_adec_params(struct audio *audio);
-static void audplay_send_data(struct audio *audio, unsigned needed);
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg);
-static void audpcm_post_event(struct audio *audio, int type,
-	union msm_audio_event_payload payload);
-static unsigned long audpcm_ion_fixup(struct audio *audio, void *addr,
-	unsigned long len, int ref_up);
-
-static int rmt_put_resource(struct audio *audio)
-{
-	struct aud_codec_config_cmd cmd;
-	unsigned short client_idx;
-
-	cmd.cmd_id = RM_CMD_AUD_CODEC_CFG;
-	cmd.client_id = RM_AUD_CLIENT_ID;
-	cmd.task_id = audio->dec_id;
-	cmd.enable = RMT_DISABLE;
-	cmd.dec_type = AUDDEC_DEC_PCM;
-	client_idx = ((cmd.client_id << 8) | cmd.task_id);
-
-	return put_adsp_resource(client_idx, &cmd, sizeof(cmd));
-}
-
-static int rmt_get_resource(struct audio *audio)
-{
-	struct aud_codec_config_cmd cmd;
-	unsigned short client_idx;
-
-	cmd.cmd_id = RM_CMD_AUD_CODEC_CFG;
-	cmd.client_id = RM_AUD_CLIENT_ID;
-	cmd.task_id = audio->dec_id;
-	cmd.enable = RMT_ENABLE;
-	cmd.dec_type = AUDDEC_DEC_PCM;
-	client_idx = ((cmd.client_id << 8) | cmd.task_id);
-
-	return get_adsp_resource(client_idx, &cmd, sizeof(cmd));
-}
-
-/* must be called with audio->lock held */
-static int audio_enable(struct audio *audio)
-{
-	struct audmgr_config cfg;
-	int rc;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled)
-		return 0;
-
-	if (audio->rmt_resource_released == 1) {
-		audio->rmt_resource_released = 0;
-		rc = rmt_get_resource(audio);
-		if (rc) {
-			MM_ERR("ADSP resources are not available for PCM \
-				session 0x%08x on decoder: %d\n Ignoring \
-				error and going ahead with the playback\n",
-				(int)audio, audio->dec_id);
-		}
-	}
-
-	audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-
-	cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE;
-	cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000;
-	cfg.def_method = RPC_AUD_DEF_METHOD_PLAYBACK;
-	cfg.codec = RPC_AUD_DEF_CODEC_PCM;
-	cfg.snd_method = RPC_SND_METHOD_MIDI;
-
-	rc = audmgr_enable(&audio->audmgr, &cfg);
-	if (rc < 0) {
-		msm_adsp_dump(audio->audplay);
-		return rc;
-	}
-	if (msm_adsp_enable(audio->audplay)) {
-		MM_ERR("msm_adsp_enable(audplay) failed\n");
-		audmgr_disable(&audio->audmgr);
-		return -ENODEV;
-	}
-
-	if (audpp_enable(audio->dec_id, audio_dsp_event, audio)) {
-		MM_ERR("audpp_enable() failed\n");
-		msm_adsp_disable(audio->audplay);
-		audmgr_disable(&audio->audmgr);
-		return -ENODEV;
-	}
-
-	audio->enabled = 1;
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audio_disable(struct audio *audio)
-{
-	int rc = 0;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-		auddec_dsp_config(audio, 0);
-		rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-		if (rc == 0)
-			rc = -ETIMEDOUT;
-		else if (audio->dec_state != MSM_AUD_DECODER_STATE_CLOSE)
-			rc = -EFAULT;
-		else
-			rc = 0;
-		audio->stopped = 1;
-		wake_up(&audio->write_wait);
-		msm_adsp_disable(audio->audplay);
-		audpp_disable(audio->dec_id, audio);
-		rc = audmgr_disable(&audio->audmgr);
-		if (rc < 0)
-			msm_adsp_dump(audio->audplay);
-		audio->out_needed = 0;
-		rmt_put_resource(audio);
-		audio->rmt_resource_released = 1;
-	}
-	return rc;
-}
-
-/* ------------------- dsp --------------------- */
-static void audplay_dsp_event(void *data, unsigned id, size_t len,
-			      void (*getevent) (void *ptr, size_t len))
-{
-	struct audio *audio = data;
-	uint32_t msg[28];
-	getevent(msg, sizeof(msg));
-
-	MM_DBG("msg_id=%x\n", id);
-
-	switch (id) {
-	case AUDPLAY_MSG_DEC_NEEDS_DATA:
-		audio->drv_ops.send_data(audio, 1);
-		break;
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audplaytask)\n");
-		break;
-	default:
-		MM_ERR("unexpected message from decoder \n");
-		break;
-	}
-}
-
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg)
-{
-	struct audio *audio = private;
-
-	switch (id) {
-	case AUDPP_MSG_STATUS_MSG:{
-			unsigned status = msg[1];
-
-			switch (status) {
-			case AUDPP_DEC_STATUS_SLEEP: {
-				uint16_t reason = msg[2];
-				MM_DBG("decoder status: sleep reason = \
-						0x%04x\n", reason);
-				if ((reason == AUDPP_MSG_REASON_MEM)
-						|| (reason ==
-						AUDPP_MSG_REASON_NODECODER)) {
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_FAILURE;
-					wake_up(&audio->wait);
-				} else if (reason == AUDPP_MSG_REASON_NONE) {
-					/* decoder is in disable state */
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_CLOSE;
-					wake_up(&audio->wait);
-				}
-				break;
-			}
-			case AUDPP_DEC_STATUS_INIT:
-				MM_DBG("decoder status: init\n");
-				audpp_cmd_cfg_adec_params(audio);
-				break;
-
-			case AUDPP_DEC_STATUS_CFG:
-				MM_DBG("decoder status: cfg \n");
-				break;
-			case AUDPP_DEC_STATUS_PLAY:
-				MM_DBG("decoder status: play \n");
-				audio->dec_state =
-					MSM_AUD_DECODER_STATE_SUCCESS;
-				wake_up(&audio->wait);
-				break;
-			default:
-				MM_ERR("unknown decoder status \n");
-				break;
-			}
-			break;
-		}
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_DBG("CFG_MSG ENABLE\n");
-			auddec_dsp_config(audio, 1);
-			audio->out_needed = 0;
-			audio->running = 1;
-			audpp_set_volume_and_pan(audio->dec_id, audio->volume,
-					0);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			MM_DBG("CFG_MSG DISABLE\n");
-			audio->running = 0;
-		} else {
-			MM_ERR("CFG_MSG %d?\n",	msg[0]);
-		}
-		break;
-	case AUDPP_MSG_FLUSH_ACK:
-		MM_DBG("FLUSH_ACK\n");
-		audio->wflush = 0;
-		wake_up(&audio->write_wait);
-		break;
-
-	case AUDPP_MSG_PCMDMAMISSED:
-		MM_DBG("PCMDMAMISSED\n");
-		audio->teos = 1;
-		wake_up(&audio->write_wait);
-		break;
-
-	default:
-		MM_ERR("UNKNOWN (%d)\n", id);
-	}
-
-}
-
-
-struct msm_adsp_ops audpcmdec_adsp_ops = {
-	.event = audplay_dsp_event,
-};
-
-
-#define audplay_send_queue0(audio, cmd, len) \
-	msm_adsp_write(audio->audplay, audio->queue_id, \
-			cmd, len)
-
-static int auddec_dsp_config(struct audio *audio, int enable)
-{
-	u16 cfg_dec_cmd[AUDPP_CMD_CFG_DEC_TYPE_LEN / sizeof(unsigned short)];
-
-	memset(cfg_dec_cmd, 0, sizeof(cfg_dec_cmd));
-
-	cfg_dec_cmd[0] = AUDPP_CMD_CFG_DEC_TYPE;
-	if (enable)
-		cfg_dec_cmd[1 + audio->dec_id] = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_ENA_DEC_V | AUDDEC_DEC_PCM;
-	else
-		cfg_dec_cmd[1 + audio->dec_id] = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_DIS_DEC_V;
-
-	return audpp_send_queue1(&cfg_dec_cmd, sizeof(cfg_dec_cmd));
-}
-
-static void audpp_cmd_cfg_adec_params(struct audio *audio)
-{
-	audpp_cmd_cfg_adec_params_wav cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_CMD_CFG_ADEC_PARAMS;
-	cmd.common.length = AUDPP_CMD_CFG_ADEC_PARAMS_WAV_LEN;
-	cmd.common.dec_id = audio->dec_id;
-	cmd.common.input_sampling_frequency = audio->out_sample_rate;
-	cmd.stereo_cfg = audio->out_channel_mode;
-	cmd.pcm_width = audio->out_bits;
-	cmd.sign = 0;
-	audpp_send_queue2(&cmd, sizeof(cmd));
-}
-
-static int audplay_dsp_send_data_avail(struct audio *audio,
-					unsigned idx, unsigned len)
-{
-	audplay_cmd_bitstream_data_avail cmd;
-
-	cmd.cmd_id		= AUDPLAY_CMD_BITSTREAM_DATA_AVAIL;
-	cmd.decoder_id		= audio->dec_id;
-	cmd.buf_ptr		= audio->out[idx].addr;
-	cmd.buf_size		= len/2;
-	cmd.partition_number	= 0;
-	/* complete writes to the input buffer */
-	wmb();
-	return audplay_send_queue0(audio, &cmd, sizeof(cmd));
-}
-
-static void audpcm_async_send_data(struct audio *audio, unsigned needed)
-{
-	unsigned long flags;
-
-	if (!audio->running)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-
-	if (needed && !audio->wflush) {
-		audio->out_needed = 1;
-		if (audio->drv_status & ADRV_STATUS_OBUF_GIVEN) {
-			/* pop one node out of queue */
-			union msm_audio_event_payload payload;
-			struct audpcm_buffer_node *used_buf;
-
-			MM_DBG("consumed\n");
-
-			BUG_ON(list_empty(&audio->out_queue));
-			used_buf = list_first_entry(&audio->out_queue,
-				struct audpcm_buffer_node, list);
-			list_del(&used_buf->list);
-			payload.aio_buf = used_buf->buf;
-			audpcm_post_event(audio, AUDIO_EVENT_WRITE_DONE,
-				payload);
-			kfree(used_buf);
-			audio->drv_status &= ~ADRV_STATUS_OBUF_GIVEN;
-		}
-	}
-	if (audio->out_needed) {
-		struct audpcm_buffer_node *next_buf;
-		audplay_cmd_bitstream_data_avail cmd;
-		if (!list_empty(&audio->out_queue)) {
-			next_buf = list_first_entry(&audio->out_queue,
-					struct audpcm_buffer_node, list);
-			MM_DBG("next_buf %p\n", next_buf);
-			if (next_buf) {
-				MM_DBG("next buf phy %lx len %d\n",
-				next_buf->paddr, next_buf->buf.data_len);
-
-				cmd.cmd_id = AUDPLAY_CMD_BITSTREAM_DATA_AVAIL;
-				if (next_buf->buf.data_len)
-					cmd.decoder_id = audio->dec_id;
-				else {
-					cmd.decoder_id = -1;
-					MM_DBG("input EOS signaled\n");
-				}
-				cmd.buf_ptr	= (unsigned) next_buf->paddr;
-				cmd.buf_size = next_buf->buf.data_len >> 1;
-				cmd.partition_number	= 0;
-				/* complete writes to the input buffer */
-				wmb();
-				audplay_send_queue0(audio, &cmd, sizeof(cmd));
-				audio->out_needed = 0;
-				audio->drv_status |= ADRV_STATUS_OBUF_GIVEN;
-			}
-		}
-	}
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audplay_send_data(struct audio *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-
-	if (!audio->running)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			MM_DBG("frame %d free\n", audio->out_tail);
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			MM_DBG("frame %d busy\n", audio->out_tail);
-			audplay_dsp_send_data_avail(audio, audio->out_tail,
-					frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-static void audpcm_async_flush(struct audio *audio)
-{
-	struct audpcm_buffer_node *buf_node;
-	struct list_head *ptr, *next;
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	list_for_each_safe(ptr, next, &audio->out_queue) {
-		buf_node = list_entry(ptr, struct audpcm_buffer_node, list);
-		list_del(&buf_node->list);
-		payload.aio_buf = buf_node->buf;
-		audpcm_post_event(audio, AUDIO_EVENT_WRITE_DONE,
-				payload);
-		kfree(buf_node);
-	}
-	audio->drv_status &= ~ADRV_STATUS_OBUF_GIVEN;
-	audio->out_needed = 0;
-	atomic_set(&audio->out_bytes, 0);
-}
-
-static void audio_flush(struct audio *audio)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->out[0].used = 0;
-	audio->out[1].used = 0;
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->reserved = 0;
-	audio->out_needed = 0;
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	atomic_set(&audio->out_bytes, 0);
-}
-
-static void audio_ioport_reset(struct audio *audio)
-{
-	if (audio->drv_status & ADRV_STATUS_AIO_INTF) {
-		/* If fsync is in progress, make sure
-		 * return value of fsync indicates
-		 * abort due to flush
-		 */
-		if (audio->drv_status & ADRV_STATUS_FSYNC) {
-			MM_DBG("fsync in progress\n");
-			wake_up(&audio->write_wait);
-			mutex_lock(&audio->write_lock);
-			audio->drv_ops.out_flush(audio);
-			mutex_unlock(&audio->write_lock);
-		} else
-			audio->drv_ops.out_flush(audio);
-	} else {
-		/* Make sure read/write thread are free from
-		 * sleep and knowing that system is not able
-		 * to process io request at the moment
-		 */
-		wake_up(&audio->write_wait);
-		mutex_lock(&audio->write_lock);
-		audio->drv_ops.out_flush(audio);
-		mutex_unlock(&audio->write_lock);
-	}
-}
-
-static int audpcm_events_pending(struct audio *audio)
-{
-	unsigned long flags;
-	int empty;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	empty = !list_empty(&audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	return empty || audio->event_abort;
-}
-
-static void audpcm_reset_event_queue(struct audio *audio)
-{
-	unsigned long flags;
-	struct audpcm_event *drv_evt;
-	struct list_head *ptr, *next;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	list_for_each_safe(ptr, next, &audio->event_queue) {
-		drv_evt = list_first_entry(&audio->event_queue,
-			struct audpcm_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	list_for_each_safe(ptr, next, &audio->free_event_queue) {
-		drv_evt = list_first_entry(&audio->free_event_queue,
-			struct audpcm_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	return;
-}
-
-static long audpcm_process_event_req(struct audio *audio, void __user *arg)
-{
-	long rc;
-	struct msm_audio_event usr_evt;
-	struct audpcm_event *drv_evt = NULL;
-	int timeout;
-	unsigned long flags;
-
-	if (copy_from_user(&usr_evt, arg, sizeof(struct msm_audio_event)))
-		return -EFAULT;
-
-	timeout = (int) usr_evt.timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(
-			audio->event_wait, audpcm_events_pending(audio),
-			msecs_to_jiffies(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(
-			audio->event_wait, audpcm_events_pending(audio));
-	}
-
-	if (rc < 0)
-		return rc;
-
-	if (audio->event_abort) {
-		audio->event_abort = 0;
-		return -ENODEV;
-	}
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	if (!list_empty(&audio->event_queue)) {
-		drv_evt = list_first_entry(&audio->event_queue,
-			struct audpcm_event, list);
-		list_del(&drv_evt->list);
-	}
-	if (drv_evt) {
-		usr_evt.event_type = drv_evt->event_type;
-		usr_evt.event_payload = drv_evt->payload;
-		list_add_tail(&drv_evt->list, &audio->free_event_queue);
-	} else
-		rc = -1;
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	if (drv_evt && drv_evt->event_type == AUDIO_EVENT_WRITE_DONE) {
-		mutex_lock(&audio->lock);
-		audpcm_ion_fixup(audio, drv_evt->payload.aio_buf.buf_addr,
-				  drv_evt->payload.aio_buf.buf_len, 0);
-		mutex_unlock(&audio->lock);
-	}
-	if (!rc && copy_to_user(arg, &usr_evt, sizeof(usr_evt)))
-		rc = -EFAULT;
-
-	return rc;
-}
-
-static int audpcm_ion_check(struct audio *audio,
-		void *vaddr, unsigned long len)
-{
-	struct audpcm_ion_region *region_elt;
-	struct audpcm_ion_region t = {.vaddr = vaddr, .len = len };
-
-	list_for_each_entry(region_elt, &audio->ion_region_queue, list) {
-		if (CONTAINS(region_elt, &t) || CONTAINS(&t, region_elt) ||
-		    OVERLAPS(region_elt, &t)) {
-			MM_ERR("[%p]:region (vaddr %p len %ld)"
-				" clashes with registered region"
-				" (vaddr %p paddr %p len %ld)\n",
-				audio, vaddr, len,
-				region_elt->vaddr,
-				(void *)region_elt->paddr, region_elt->len);
-			return -EINVAL;
-		}
-	}
-
-	return 0;
-}
-static int audpcm_ion_add(struct audio *audio,
-			struct msm_audio_ion_info *info)
-{
-	ion_phys_addr_t paddr;
-	size_t len;
-	unsigned long kvaddr;
-	struct audpcm_ion_region *region;
-	int rc = -EINVAL;
-	struct ion_handle *handle;
-	unsigned long ionflag;
-
-	MM_ERR("\n"); /* Macro prints the file name and function */
-	region = kmalloc(sizeof(*region), GFP_KERNEL);
-
-	if (!region) {
-		rc = -ENOMEM;
-		goto end;
-	}
-	handle = ion_import_dma_buf(audio->client, info->fd);
-	if (IS_ERR_OR_NULL(handle)) {
-		pr_err("%s: could not get handle of the given fd\n", __func__);
-		goto import_error;
-	}
-	rc = ion_handle_get_flags(audio->client, handle, &ionflag);
-	if (rc) {
-		pr_err("%s: could not get flags for the handle\n", __func__);
-		goto flag_error;
-	}
-	kvaddr = (unsigned long)ion_map_kernel(audio->client, handle);
-	if (IS_ERR_OR_NULL((void *)kvaddr)) {
-		pr_err("%s: could not get virtual address\n", __func__);
-		goto map_error;
-	}
-	rc = ion_phys(audio->client, handle, &paddr, &len);
-	if (rc) {
-		pr_err("%s: could not get physical address\n", __func__);
-		goto ion_error;
-	}
-	rc = audpcm_ion_check(audio, info->vaddr, len);
-	if (rc < 0) {
-		MM_ERR("audpcm_ion_check failed\n");
-		goto ion_error;
-	}
-	region->handle = handle;
-	region->vaddr = info->vaddr;
-	region->fd = info->fd;
-	region->paddr = paddr;
-	region->kvaddr = kvaddr;
-	region->len = len;
-	region->ref_cnt = 0;
-	MM_DBG("[%p]:add region paddr %lx vaddr %p, len %lu kvaddr %lx\n",
-		audio, region->paddr, region->vaddr,
-		region->len, region->kvaddr);
-	list_add_tail(&region->list, &audio->ion_region_queue);
-
-	return rc;
-
-ion_error:
-	ion_unmap_kernel(audio->client, handle);
-map_error:
-flag_error:
-	ion_free(audio->client, handle);
-import_error:
-	kfree(region);
-end:
-	return rc;
-}
-
-static int audpcm_ion_remove(struct audio *audio,
-			struct msm_audio_ion_info *info)
-{
-	struct audpcm_ion_region *region;
-	struct list_head *ptr, *next;
-	int rc = -EINVAL;
-
-	list_for_each_safe(ptr, next, &audio->ion_region_queue) {
-		region = list_entry(ptr, struct audpcm_ion_region, list);
-
-		if (region != NULL && (region->fd == info->fd) &&
-		    (region->vaddr == info->vaddr)) {
-			if (region->ref_cnt) {
-				MM_DBG("%s[%p]:region %p in use ref_cnt %d\n",
-					__func__, audio, region,
-					region->ref_cnt);
-				break;
-			}
-			MM_DBG("remove region fd %d vaddr %p\n",
-				info->fd, info->vaddr);
-			list_del(&region->list);
-			ion_unmap_kernel(audio->client, region->handle);
-			ion_free(audio->client, region->handle);
-			kfree(region);
-			rc = 0;
-			break;
-		}
-	}
-
-	return rc;
-}
-
-static int audpcm_ion_lookup_vaddr(struct audio *audio, void *addr,
-			unsigned long len, struct audpcm_ion_region **region)
-{
-	struct audpcm_ion_region *region_elt;
-	int match_count = 0;
-	*region = NULL;
-
-	/* returns physical address or zero */
-	list_for_each_entry(region_elt, &audio->ion_region_queue, list) {
-		if (addr >= region_elt->vaddr &&
-		    addr < region_elt->vaddr + region_elt->len &&
-		    addr + len <= region_elt->vaddr + region_elt->len) {
-			/* offset since we could pass vaddr inside a registerd
-			 * ion buffer
-			 */
-
-			match_count++;
-			if (!*region)
-				*region = region_elt;
-		}
-	}
-
-	if (match_count > 1) {
-		MM_ERR("%s[%p]:multiple hits for vaddr %p, len %ld\n",
-			 __func__, audio, addr, len);
-		list_for_each_entry(region_elt, &audio->ion_region_queue,
-					list) {
-			if (addr >= region_elt->vaddr &&
-			    addr < region_elt->vaddr + region_elt->len &&
-			    addr + len <= region_elt->vaddr + region_elt->len)
-					MM_ERR("\t%s[%p]:%p, %ld --> %p\n",
-						__func__, audio,
-						region_elt->vaddr,
-						region_elt->len,
-						(void *)region_elt->paddr);
-		}
-	}
-	return *region ? 0 : -1;
-}
-static unsigned long audpcm_ion_fixup(struct audio *audio, void *addr,
-		    unsigned long len, int ref_up)
-{
-	struct audpcm_ion_region *region;
-	unsigned long paddr;
-	int ret;
-
-	ret = audpcm_ion_lookup_vaddr(audio, addr, len, &region);
-	if (ret) {
-		MM_ERR("%s[%p]:lookup (%p, %ld) failed\n",
-			__func__, audio, addr, len);
-		return 0;
-	}
-	if (ref_up)
-		region->ref_cnt++;
-	else
-		region->ref_cnt--;
-	MM_DBG("found region %p ref_cnt %d\n", region, region->ref_cnt);
-	paddr = region->paddr + (addr - region->vaddr);
-	return paddr;
-}
-
-/* audio -> lock must be held at this point */
-static int audpcm_aio_buf_add(struct audio *audio, unsigned dir,
-	void __user *arg)
-{
-	unsigned long flags;
-	struct audpcm_buffer_node *buf_node;
-
-	buf_node = kmalloc(sizeof(*buf_node), GFP_KERNEL);
-
-	if (!buf_node)
-		return -ENOMEM;
-
-	if (copy_from_user(&buf_node->buf, arg, sizeof(buf_node->buf))) {
-		kfree(buf_node);
-		return -EFAULT;
-	}
-
-	MM_DBG("node %p dir %x buf_addr %p buf_len %d data_len %d\n",
-			buf_node, dir, buf_node->buf.buf_addr,
-			buf_node->buf.buf_len, buf_node->buf.data_len);
-
-	buf_node->paddr = audpcm_ion_fixup(
-		audio, buf_node->buf.buf_addr,
-		buf_node->buf.buf_len, 1);
-	if (dir) {
-		/* write */
-		if (!buf_node->paddr ||
-		    (buf_node->paddr & 0x1) ||
-		    (buf_node->buf.data_len & 0x1) ||
-		    (!buf_node->buf.data_len)) {
-			kfree(buf_node);
-			return -EINVAL;
-		}
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		list_add_tail(&buf_node->list, &audio->out_queue);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		audio->drv_ops.send_data(audio, 0);
-	}
-
-	MM_DBG("Add buf_node %p paddr %lx\n", buf_node, buf_node->paddr);
-
-	return 0;
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = 0;
-
-	MM_DBG("cmd = %d\n", cmd);
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		stats.byte_count = audpp_avsync_byte_count(audio->dec_id);
-		stats.sample_count = audpp_avsync_sample_count(audio->dec_id);
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-	if (cmd == AUDIO_SET_VOLUME) {
-		unsigned long flags;
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->volume = arg;
-		if (audio->running)
-			audpp_set_volume_and_pan(audio->dec_id, arg, 0);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		return 0;
-	}
-	if (cmd == AUDIO_GET_EVENT) {
-		MM_DBG("AUDIO_GET_EVENT\n");
-		if (mutex_trylock(&audio->get_event_lock)) {
-			rc = audpcm_process_event_req(audio,
-				(void __user *) arg);
-			mutex_unlock(&audio->get_event_lock);
-		} else
-			rc = -EBUSY;
-		return rc;
-	}
-
-	if (cmd == AUDIO_ABORT_GET_EVENT) {
-		audio->event_abort = 1;
-		wake_up(&audio->event_wait);
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		MM_DBG("AUDIO_START\n");
-		rc = audio_enable(audio);
-		if (!rc) {
-			rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-			MM_INFO("dec_state %d rc = %d\n", audio->dec_state, rc);
-
-			if (audio->dec_state != MSM_AUD_DECODER_STATE_SUCCESS)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		break;
-	case AUDIO_STOP:
-		MM_DBG("AUDIO_STOP\n");
-		rc = audio_disable(audio);
-		audio_ioport_reset(audio);
-		audio->stopped = 0;
-		break;
-	case AUDIO_FLUSH:
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->wflush = 1;
-		audio_ioport_reset(audio);
-		if (audio->running) {
-			audpp_flush(audio->dec_id);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->wflush = 0;
-		}
-		break;
-
-	case AUDIO_SET_CONFIG: {
-		struct msm_audio_config config;
-		if (copy_from_user(&config, (void *) arg, sizeof(config))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (config.channel_count == 1) {
-			config.channel_count = AUDPP_CMD_PCM_INTF_MONO_V;
-		} else if (config.channel_count == 2) {
-			config.channel_count = AUDPP_CMD_PCM_INTF_STEREO_V;
-		} else {
-			rc = -EINVAL;
-			break;
-		}
-		if (config.bits == 8)
-			config.bits = AUDPP_CMD_WAV_PCM_WIDTH_8;
-		else if (config.bits == 16)
-			config.bits = AUDPP_CMD_WAV_PCM_WIDTH_16;
-		else if (config.bits == 24)
-			config.bits = AUDPP_CMD_WAV_PCM_WIDTH_24;
-		else {
-			rc = -EINVAL;
-			break;
-		}
-		audio->out_sample_rate = config.sample_rate;
-		audio->out_channel_mode = config.channel_count;
-		audio->out_bits = config.bits;
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config config;
-		config.buffer_size = (audio->out_dma_sz >> 1);
-		config.buffer_count = 2;
-		config.sample_rate = audio->out_sample_rate;
-		if (audio->out_channel_mode == AUDPP_CMD_PCM_INTF_MONO_V)
-			config.channel_count = 1;
-		else
-			config.channel_count = 2;
-		if (audio->out_bits == AUDPP_CMD_WAV_PCM_WIDTH_8)
-			config.bits = 8;
-		else if (audio->out_bits == AUDPP_CMD_WAV_PCM_WIDTH_24)
-			config.bits = 24;
-		else
-			config.bits = 16;
-		config.unused[0] = 0;
-		config.unused[1] = 0;
-
-		if (copy_to_user((void *) arg, &config, sizeof(config)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-
-
-	case AUDIO_PAUSE:
-		MM_DBG("AUDIO_PAUSE %ld\n", arg);
-		rc = audpp_pause(audio->dec_id, (int) arg);
-		break;
-
-	case AUDIO_REGISTER_ION: {
-		struct msm_audio_ion_info info;
-		MM_ERR("AUDIO_REGISTER_ION\n");
-			if (copy_from_user(&info, (void *) arg, sizeof(info)))
-				rc = -EFAULT;
-			else
-				rc = audpcm_ion_add(audio, &info);
-			break;
-		}
-
-	case AUDIO_DEREGISTER_ION: {
-		struct msm_audio_ion_info info;
-		MM_ERR("AUDIO_DEREGISTER_ION\n");
-			if (copy_from_user(&info, (void *) arg, sizeof(info)))
-				rc = -EFAULT;
-			else
-				rc = audpcm_ion_remove(audio, &info);
-			break;
-		}
-
-	case AUDIO_ASYNC_WRITE:
-		if (audio->drv_status & ADRV_STATUS_FSYNC)
-			rc = -EBUSY;
-		else
-			rc = audpcm_aio_buf_add(audio, 1, (void __user *) arg);
-		break;
-
-	case AUDIO_ASYNC_READ:
-		MM_ERR("AUDIO_ASYNC_READ not supported\n");
-		rc = -EPERM;
-		break;
-
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-/* Only useful in tunnel-mode */
-int audpcm_async_fsync(struct audio *audio)
-{
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	/* Blocking client sends more data */
-	mutex_lock(&audio->lock);
-	audio->drv_status |= ADRV_STATUS_FSYNC;
-	mutex_unlock(&audio->lock);
-
-	mutex_lock(&audio->write_lock);
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->teos && audio->out_needed &&
-		list_empty(&audio->out_queue))
-		|| audio->wflush || audio->stopped);
-
-	if (audio->stopped || audio->wflush)
-		rc = -EBUSY;
-
-	mutex_unlock(&audio->write_lock);
-	mutex_lock(&audio->lock);
-	audio->drv_status &= ~ADRV_STATUS_FSYNC;
-	mutex_unlock(&audio->lock);
-
-	return rc;
-}
-
-int audpcm_sync_fsync(struct audio *audio)
-{
-	struct buffer *frame;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(!audio->out[0].used &&
-		!audio->out[1].used &&
-		audio->out_needed) || audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (audio->reserved) {
-		MM_DBG("send reserved byte\n");
-		frame = audio->out + audio->out_tail;
-		((char *) frame->data)[0] = audio->rsv_byte;
-		((char *) frame->data)[1] = 0;
-		frame->used = 2;
-		audio->drv_ops.send_data(audio, 0);
-
-		rc = wait_event_interruptible(audio->write_wait,
-			(!audio->out[0].used &&
-			!audio->out[1].used &&
-			audio->out_needed) || audio->wflush);
-
-		if (rc < 0)
-			goto done;
-		else if (audio->wflush) {
-			rc = -EBUSY;
-			goto done;
-		}
-	}
-
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		audio->teos || audio->wflush);
-
-	if (audio->wflush)
-		rc = -EBUSY;
-
-done:
-	mutex_unlock(&audio->write_lock);
-	return rc;
-}
-
-int audpcm_fsync(struct file *file, loff_t a, loff_t b, int datasync)
-{
-	struct audio *audio = file->private_data;
-
-	if (!audio->running)
-		return -EINVAL;
-
-	return audio->drv_ops.fsync(audio);
-}
-
-static ssize_t audio_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	size_t xfer;
-	char *cpy_ptr;
-	int rc = 0;
-	unsigned dsize;
-
-	if (audio->drv_status & ADRV_STATUS_AIO_INTF)
-		return -EPERM;
-
-	MM_DBG("cnt=%d\n", count);
-
-	mutex_lock(&audio->write_lock);
-	while (count > 0) {
-		frame = audio->out + audio->out_head;
-		cpy_ptr = frame->data;
-		dsize = 0;
-		rc = wait_event_interruptible(audio->write_wait,
-					      (frame->used == 0)
-					      || (audio->stopped)
-						  || (audio->wflush));
-		if (rc < 0)
-			break;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (audio->reserved) {
-			MM_DBG("append reserved byte %x\n", audio->rsv_byte);
-			*cpy_ptr = audio->rsv_byte;
-			xfer = (count > (frame->size - 1)) ?
-				frame->size - 1 : count;
-			cpy_ptr++;
-			dsize = 1;
-			audio->reserved = 0;
-		} else
-			xfer = (count > frame->size) ? frame->size : count;
-
-		if (copy_from_user(cpy_ptr, buf, xfer)) {
-			rc = -EFAULT;
-			break;
-		}
-
-		dsize += xfer;
-		if (dsize & 1) {
-			audio->rsv_byte = ((char *) frame->data)[dsize - 1];
-			MM_DBG("odd length buf reserve last byte %x\n",
-					audio->rsv_byte);
-			audio->reserved = 1;
-			dsize--;
-		}
-		count -= xfer;
-		buf += xfer;
-
-		if (dsize > 0) {
-			audio->out_head ^= 1;
-			frame->used = dsize;
-			audio->drv_ops.send_data(audio, 0);
-		}
-	}
-	mutex_unlock(&audio->write_lock);
-	if (buf > start)
-		return buf - start;
-
-	return rc;
-}
-
-static void audpcm_reset_ion_region(struct audio *audio)
-{
-	struct audpcm_ion_region *region;
-	struct list_head *ptr, *next;
-
-	list_for_each_safe(ptr, next, &audio->ion_region_queue) {
-		region = list_entry(ptr, struct audpcm_ion_region, list);
-		list_del(&region->list);
-		ion_unmap_kernel(audio->client, region->handle);
-		ion_free(audio->client, region->handle);
-		kfree(region);
-	}
-
-	return;
-}
-
-static int audio_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	MM_DBG("audio instance 0x%08x freeing\n", (int)audio);
-	mutex_lock(&audio->lock);
-	audio_disable(audio);
-	if (audio->rmt_resource_released == 0)
-		rmt_put_resource(audio);
-	audio->drv_ops.out_flush(audio);
-	audpcm_reset_ion_region(audio);
-
-	msm_adsp_put(audio->audplay);
-	audpp_adec_free(audio->dec_id);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	unregister_early_suspend(&audio->suspend_ctl.node);
-#endif
-	audio->opened = 0;
-	audio->event_abort = 1;
-	wake_up(&audio->event_wait);
-	audpcm_reset_event_queue(audio);
-	mutex_unlock(&audio->lock);
-#ifdef CONFIG_DEBUG_FS
-	if (audio->dentry)
-		debugfs_remove(audio->dentry);
-#endif
-	ion_client_destroy(audio->client);
-	kfree(audio);
-	return 0;
-}
-
-static void audpcm_post_event(struct audio *audio, int type,
-	union msm_audio_event_payload payload)
-{
-	struct audpcm_event *e_node = NULL;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-
-	if (!list_empty(&audio->free_event_queue)) {
-		e_node = list_first_entry(&audio->free_event_queue,
-			struct audpcm_event, list);
-		list_del(&e_node->list);
-	} else {
-		e_node = kmalloc(sizeof(struct audpcm_event), GFP_ATOMIC);
-		if (!e_node) {
-			MM_ERR("No mem to post event %d\n", type);
-			spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-			return;
-		}
-	}
-
-	e_node->event_type = type;
-	e_node->payload = payload;
-
-	list_add_tail(&e_node->list, &audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	wake_up(&audio->event_wait);
-}
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audpcm_suspend(struct early_suspend *h)
-{
-	struct audpcm_suspend_ctl *ctl =
-		container_of(h, struct audpcm_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audpcm_post_event(ctl->audio, AUDIO_EVENT_SUSPEND, payload);
-}
-
-static void audpcm_resume(struct early_suspend *h)
-{
-	struct audpcm_suspend_ctl *ctl =
-		container_of(h, struct audpcm_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audpcm_post_event(ctl->audio, AUDIO_EVENT_RESUME, payload);
-}
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-static ssize_t audpcm_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static ssize_t audpcm_debug_read(struct file *file, char __user *buf,
-			  size_t count, loff_t *ppos)
-{
-	const int debug_bufmax = 4096;
-	static char buffer[4096];
-	int n = 0;
-	struct audio *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	n = scnprintf(buffer, debug_bufmax, "opened %d\n", audio->opened);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "enabled %d\n", audio->enabled);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "stopped %d\n", audio->stopped);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_buf_sz %d\n", audio->out[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "volume %x \n", audio->volume);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "sample rate %d \n", audio->out_sample_rate);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-		"channel mode %d \n", audio->out_channel_mode);
-	mutex_unlock(&audio->lock);
-	/* Following variables are only useful for debugging when
-	 * when playback halts unexpectedly. Thus, no mutual exclusion
-	 * enforced
-	 */
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "wflush %d\n", audio->wflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "running %d \n", audio->running);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				"dec state %d \n", audio->dec_state);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_needed %d \n", audio->out_needed);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_head %d \n", audio->out_head);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_tail %d \n", audio->out_tail);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out[0].used %d \n", audio->out[0].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out[1].used %d \n", audio->out[1].used);
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations audpcm_debug_fops = {
-	.read = audpcm_debug_read,
-	.open = audpcm_debug_open,
-};
-#endif
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = NULL;
-	int rc, i, dec_attrb, decid;
-	struct audpcm_event *e_node = NULL;
-	unsigned mem_sz = DMASZ_MAX;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	struct ion_client *client = NULL;
-	int len = 0;
-
-
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_pcm_dec_" + 5];
-#endif
-
-	/* Allocate audio instance, set to zero */
-	audio = kzalloc(sizeof(struct audio), GFP_KERNEL);
-	if (!audio) {
-		MM_ERR("no memory to allocate audio instance \n");
-		rc = -ENOMEM;
-		goto done;
-	}
-	MM_DBG("audio instance 0x%08x created\n", (int)audio);
-
-	/* Allocate the decoder */
-	dec_attrb = AUDDEC_DEC_PCM;
-	if (file->f_mode & FMODE_READ) {
-		MM_ERR("Non-Tunneled mode not supported\n");
-		rc = -EPERM;
-		kfree(audio);
-		goto done;
-	} else
-		dec_attrb |= MSM_AUD_MODE_TUNNEL;
-
-	decid = audpp_adec_alloc(dec_attrb, &audio->module_name,
-			&audio->queue_id);
-	if (decid < 0) {
-		MM_ERR("No free decoder available\n");
-		rc = -ENODEV;
-		MM_DBG("audio instance 0x%08x freeing\n", (int)audio);
-		kfree(audio);
-		goto done;
-	}
-	audio->dec_id = decid & MSM_AUD_DECODER_MASK;
-
-	client = msm_ion_client_create(UINT_MAX, "Audio_PCM_Client");
-	if (IS_ERR_OR_NULL(client)) {
-		pr_err("Unable to create ION client\n");
-		rc = -ENOMEM;
-		goto client_create_error;
-	}
-	audio->client = client;
-
-	/* Non AIO interface */
-	if (!(file->f_flags & O_NONBLOCK)) {
-
-		MM_DBG("memsz = %d\n", mem_sz);
-
-		handle = ion_alloc(client, mem_sz, SZ_4K,
-			ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-		if (IS_ERR_OR_NULL(handle)) {
-			MM_ERR("Unable to create allocate O/P buffers\n");
-			rc = -ENOMEM;
-			goto output_buff_alloc_error;
-		}
-		audio->output_buff_handle = handle;
-
-		rc = ion_phys(client , handle, &addr, &len);
-		if (rc) {
-			MM_ERR("O/P buffers:Invalid phy: %x sz: %x\n",
-				(unsigned int) addr, (unsigned int) len);
-			goto output_buff_get_phys_error;
-		} else {
-			MM_INFO("O/P buffers:valid phy: %x sz: %x\n",
-				(unsigned int) addr, (unsigned int) len);
-		}
-		audio->phys = (int32_t)addr;
-
-
-		rc = ion_handle_get_flags(client, handle, &ionflag);
-		if (rc) {
-			MM_ERR("could not get flags for the handle\n");
-			goto output_buff_get_flags_error;
-		}
-
-		audio->map_v_write = ion_map_kernel(client, handle);
-		if (IS_ERR(audio->map_v_write)) {
-			MM_ERR("could not map write buffers\n");
-			rc = -ENOMEM;
-			goto output_buff_map_error;
-		}
-		audio->data = audio->map_v_write;
-		MM_DBG("write buf: phy addr 0x%08x kernel addr 0x%08x\n",
-			audio->phys, (int)audio->data);
-
-		audio->out_dma_sz = mem_sz;
-	}
-
-	rc = audmgr_open(&audio->audmgr);
-	if (rc)
-		goto err;
-
-	rc = msm_adsp_get(audio->module_name, &audio->audplay,
-			&audpcmdec_adsp_ops, audio);
-	if (rc) {
-		MM_ERR("failed to get %s module\n", audio->module_name);
-		audmgr_close(&audio->audmgr);
-		goto err;
-	}
-
-	rc = rmt_get_resource(audio);
-	if (rc) {
-		MM_ERR("ADSP resources are not available for PCM session \
-			 0x%08x on decoder: %d\n", (int)audio, audio->dec_id);
-		audmgr_close(&audio->audmgr);
-		msm_adsp_put(audio->audplay);
-		goto err;
-	}
-
-	if (file->f_flags & O_NONBLOCK) {
-		MM_DBG("set to aio interface\n");
-		audio->drv_status |= ADRV_STATUS_AIO_INTF;
-		audio->drv_ops.send_data = audpcm_async_send_data;
-		audio->drv_ops.out_flush = audpcm_async_flush;
-		audio->drv_ops.fsync = audpcm_async_fsync;
-	} else {
-		MM_DBG("set to std io interface\n");
-		audio->drv_ops.send_data = audplay_send_data;
-		audio->drv_ops.out_flush = audio_flush;
-		audio->drv_ops.fsync = audpcm_sync_fsync;
-		audio->out[0].data = audio->data + 0;
-		audio->out[0].addr = audio->phys + 0;
-		audio->out[0].size = (audio->out_dma_sz >> 1);
-
-		audio->out[1].data = audio->data + audio->out[0].size;
-		audio->out[1].addr = audio->phys + audio->out[0].size;
-		audio->out[1].size = audio->out[0].size;
-	}
-
-	/* Initialize all locks of audio instance */
-	mutex_init(&audio->lock);
-	mutex_init(&audio->write_lock);
-	mutex_init(&audio->get_event_lock);
-	spin_lock_init(&audio->dsp_lock);
-	init_waitqueue_head(&audio->write_wait);
-	INIT_LIST_HEAD(&audio->out_queue);
-	INIT_LIST_HEAD(&audio->ion_region_queue);
-	INIT_LIST_HEAD(&audio->free_event_queue);
-	INIT_LIST_HEAD(&audio->event_queue);
-	init_waitqueue_head(&audio->wait);
-	init_waitqueue_head(&audio->event_wait);
-	spin_lock_init(&audio->event_queue_lock);
-
-	audio->out_sample_rate = 44100;
-	audio->out_channel_mode = AUDPP_CMD_PCM_INTF_STEREO_V;
-	audio->out_bits = AUDPP_CMD_WAV_PCM_WIDTH_16;
-	audio->volume = 0x2000;
-	audio->drv_ops.out_flush(audio);
-
-	file->private_data = audio;
-	audio->opened = 1;
-
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof name, "msm_pcm_dec_%04x", audio->dec_id);
-	audio->dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
-		NULL, (void *) audio, &audpcm_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		MM_DBG("debugfs_create_file failed\n");
-#endif
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	audio->suspend_ctl.node.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
-	audio->suspend_ctl.node.resume = audpcm_resume;
-	audio->suspend_ctl.node.suspend = audpcm_suspend;
-	audio->suspend_ctl.audio = audio;
-	register_early_suspend(&audio->suspend_ctl.node);
-#endif
-	for (i = 0; i < AUDPCM_EVENT_NUM; i++) {
-		e_node = kmalloc(sizeof(struct audpcm_event), GFP_KERNEL);
-		if (e_node)
-			list_add_tail(&e_node->list, &audio->free_event_queue);
-		else {
-			MM_ERR("event pkt alloc failed\n");
-			break;
-		}
-	}
-done:
-	return rc;
-err:
-	ion_unmap_kernel(client, audio->output_buff_handle);
-output_buff_map_error:
-output_buff_get_flags_error:
-output_buff_get_phys_error:
-	ion_free(client, audio->output_buff_handle);
-output_buff_alloc_error:
-	ion_client_destroy(client);
-client_create_error:
-	audpp_adec_free(audio->dec_id);
-	MM_DBG("audio instance 0x%08x freeing\n", (int)audio);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_pcm_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audio_open,
-	.release	= audio_release,
-	.write		= audio_write,
-	.unlocked_ioctl	= audio_ioctl,
-	.fsync = audpcm_fsync,
-};
-
-struct miscdevice audio_pcm_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_pcm_dec",
-	.fops	= &audio_pcm_fops,
-};
-
-static int __init audio_init(void)
-{
-	return misc_register(&audio_pcm_misc);
-}
-
-device_initcall(audio_init);
diff --git a/arch/arm/mach-msm/qdsp5/audio_pcm_in.c b/arch/arm/mach-msm/qdsp5/audio_pcm_in.c
deleted file mode 100644
index c5787fd..0000000
--- a/arch/arm/mach-msm/qdsp5/audio_pcm_in.c
+++ /dev/null
@@ -1,1011 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/audio_pcm_in.c
- *
- * pcm audio input device
- *
- * Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
- *
- * This code is based in part on arch/arm/mach-msm/qdsp5v2/audio_pcm_in.c,
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/msm_ion.h>
-
-#include <linux/delay.h>
-
-#include <linux/msm_audio.h>
-
-#include <mach/msm_memtypes.h>
-#include <linux/memory_alloc.h>
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-#include <mach/msm_adsp.h>
-#include <mach/msm_rpcrouter.h>
-
-#include "audmgr.h"
-
-#include <mach/qdsp5/audio_acdb_def.h>
-#include <mach/qdsp5/qdsp5audpreproc.h>
-#include <mach/qdsp5/qdsp5audpreproccmdi.h>
-#include <mach/qdsp5/qdsp5audpreprocmsg.h>
-#include <mach/qdsp5/qdsp5audreccmdi.h>
-#include <mach/qdsp5/qdsp5audrecmsg.h>
-#include <mach/debug_mm.h>
-
-/* FRAME_NUM must be a power of two */
-#define FRAME_NUM		(8)
-#define FRAME_SIZE		(2052 * 2)
-#define MONO_DATA_SIZE		(2048)
-#define STEREO_DATA_SIZE	(MONO_DATA_SIZE * 2)
-#define DMASZ			(FRAME_SIZE * FRAME_NUM)
-#define MSM_AUD_BUFFER_UPDATE_WAIT_MS 2000
-
-struct buffer {
-	void *data;
-	uint32_t size;
-	uint32_t read;
-	uint32_t addr;
-};
-
-struct audio_in {
-	struct buffer in[FRAME_NUM];
-
-	spinlock_t dsp_lock;
-
-	atomic_t in_bytes;
-
-	struct mutex lock;
-	struct mutex read_lock;
-	wait_queue_head_t wait;
-
-	struct msm_adsp_module *audrec;
-	const char *module_name;
-	unsigned queue_ids;
-	uint16_t enc_id; /* Session Id */
-
-	/* configuration to use on next enable */
-	uint32_t samp_rate;
-	uint32_t channel_mode;
-	uint32_t buffer_size; /* 2048 for mono, 4096 for stereo */
-	uint32_t enc_type; /* 0 for PCM */
-	uint32_t mode; /* Tunnel for PCM */
-	uint32_t dsp_cnt;
-	uint32_t in_head; /* next buffer dsp will write */
-	uint32_t in_tail; /* next buffer read() will read */
-	uint32_t in_count; /* number of buffers available to read() */
-
-	unsigned short samp_rate_index;
-	uint32_t audrec_obj_idx ;
-
-	struct audmgr audmgr;
-
-	/* data allocated for various buffers */
-	char *data;
-	dma_addr_t phys;
-
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped, cleared on flush */
-	struct audrec_session_info session_info; /*audrec session info*/
-
-	/* audpre settings */
-	int tx_agc_enable;
-	audpreproc_cmd_cfg_agc_params tx_agc_cfg;
-	int ns_enable;
-	audpreproc_cmd_cfg_ns_params ns_cfg;
-	/* For different sample rate, the coeff might be different. *
-	 * All the coeff should be passed from user space	    */
-	int iir_enable;
-	audpreproc_cmd_cfg_iir_tuning_filter_params iir_cfg;
-	struct ion_client *client;
-	struct ion_handle *output_buff_handle;
-};
-
-static int audpcm_in_dsp_enable(struct audio_in *audio, int enable);
-static int audpcm_in_encmem_config(struct audio_in *audio);
-static int audpcm_in_encparam_config(struct audio_in *audio);
-static int audpcm_in_dsp_read_buffer(struct audio_in *audio, uint32_t read_cnt);
-static void audpcm_in_flush(struct audio_in *audio);
-static int audio_dsp_set_tx_agc(struct audio_in *audio);
-static int audio_dsp_set_ns(struct audio_in *audio);
-static int audio_dsp_set_iir(struct audio_in *audio);
-
-static unsigned convert_dsp_samp_index(unsigned index)
-{
-	switch (index) {
-	case 48000:	return AUDREC_CMD_SAMP_RATE_INDX_48000;
-	case 44100:	return AUDREC_CMD_SAMP_RATE_INDX_44100;
-	case 32000:	return AUDREC_CMD_SAMP_RATE_INDX_32000;
-	case 24000:	return AUDREC_CMD_SAMP_RATE_INDX_24000;
-	case 22050:	return AUDREC_CMD_SAMP_RATE_INDX_22050;
-	case 16000:	return AUDREC_CMD_SAMP_RATE_INDX_16000;
-	case 12000:	return AUDREC_CMD_SAMP_RATE_INDX_12000;
-	case 11025:	return AUDREC_CMD_SAMP_RATE_INDX_11025;
-	case 8000:	return AUDREC_CMD_SAMP_RATE_INDX_8000;
-	default:	return AUDREC_CMD_SAMP_RATE_INDX_11025;
-	}
-}
-
-static unsigned convert_samp_rate(unsigned hz)
-{
-	switch (hz) {
-	case 48000: return RPC_AUD_DEF_SAMPLE_RATE_48000;
-	case 44100: return RPC_AUD_DEF_SAMPLE_RATE_44100;
-	case 32000: return RPC_AUD_DEF_SAMPLE_RATE_32000;
-	case 24000: return RPC_AUD_DEF_SAMPLE_RATE_24000;
-	case 22050: return RPC_AUD_DEF_SAMPLE_RATE_22050;
-	case 16000: return RPC_AUD_DEF_SAMPLE_RATE_16000;
-	case 12000: return RPC_AUD_DEF_SAMPLE_RATE_12000;
-	case 11025: return RPC_AUD_DEF_SAMPLE_RATE_11025;
-	case 8000:  return RPC_AUD_DEF_SAMPLE_RATE_8000;
-	default:    return RPC_AUD_DEF_SAMPLE_RATE_11025;
-	}
-}
-
-static unsigned convert_samp_index(unsigned index)
-{
-	switch (index) {
-	case RPC_AUD_DEF_SAMPLE_RATE_48000:	return 48000;
-	case RPC_AUD_DEF_SAMPLE_RATE_44100:	return 44100;
-	case RPC_AUD_DEF_SAMPLE_RATE_32000:	return 32000;
-	case RPC_AUD_DEF_SAMPLE_RATE_24000:	return 24000;
-	case RPC_AUD_DEF_SAMPLE_RATE_22050:	return 22050;
-	case RPC_AUD_DEF_SAMPLE_RATE_16000:	return 16000;
-	case RPC_AUD_DEF_SAMPLE_RATE_12000:	return 12000;
-	case RPC_AUD_DEF_SAMPLE_RATE_11025:	return 11025;
-	case RPC_AUD_DEF_SAMPLE_RATE_8000:	return 8000;
-	default:				return 11025;
-	}
-}
-
-/* ------------------- dsp --------------------- */
-static void audpre_dsp_event(void *data, unsigned id,  void *event_data)
-{
-
-	uint16_t *msg = event_data;
-
-	if (!msg)
-		return;
-
-	switch (id) {
-	case AUDPREPROC_MSG_CMD_CFG_DONE_MSG:
-		MM_DBG("type %d, status_flag %d\n",\
-			msg[0], msg[1]);
-		break;
-	case AUDPREPROC_MSG_ERROR_MSG_ID:
-		MM_INFO("err_index %d\n", msg[0]);
-		break;
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audpreproctask)\n");
-		break;
-	default:
-		MM_ERR("unknown event %d\n", id);
-	}
-}
-
-
-/* must be called with audio->lock held */
-static int audpcm_in_enable(struct audio_in *audio)
-{
-	struct audmgr_config cfg;
-	int rc;
-
-	if (audio->enabled)
-		return 0;
-
-	cfg.tx_rate = audio->samp_rate;
-	cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE;
-	cfg.def_method = RPC_AUD_DEF_METHOD_RECORD;
-	cfg.codec = RPC_AUD_DEF_CODEC_PCM;
-	cfg.snd_method = RPC_SND_METHOD_MIDI;
-
-	rc = audmgr_enable(&audio->audmgr, &cfg);
-	if (rc < 0) {
-		msm_adsp_dump(audio->audrec);
-		return rc;
-	}
-	if (audpreproc_enable(audio->enc_id, &audpre_dsp_event, audio)) {
-		MM_ERR("msm_adsp_enable(audpreproc) failed\n");
-		audmgr_disable(&audio->audmgr);
-		return -ENODEV;
-	}
-
-	if (msm_adsp_enable(audio->audrec)) {
-		audpreproc_disable(audio->enc_id, audio);
-		audmgr_disable(&audio->audmgr);
-		MM_ERR("msm_adsp_enable(audrec) failed\n");
-		return -ENODEV;
-	}
-
-	audio->enabled = 1;
-	audpcm_in_dsp_enable(audio, 1);
-
-	/*update aurec session info in audpreproc layer*/
-	audio->session_info.session_id = audio->enc_id;
-	audio->session_info.sampling_freq =
-			convert_samp_index(audio->samp_rate);
-	audpreproc_update_audrec_info(&audio->session_info);
-
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audpcm_in_disable(struct audio_in *audio)
-{
-	int rc;
-
-	if (audio->enabled) {
-		audio->enabled = 0;
-
-		audpcm_in_dsp_enable(audio, 0);
-
-		audio->stopped = 1;
-		wake_up(&audio->wait);
-
-		msm_adsp_disable(audio->audrec);
-		audpreproc_disable(audio->enc_id, audio);
-		/*reset the sampling frequency information at audpreproc layer*/
-		audio->session_info.sampling_freq = 0;
-		audpreproc_update_audrec_info(&audio->session_info);
-		rc = audmgr_disable(&audio->audmgr);
-		if (rc < 0)
-			msm_adsp_dump(audio->audrec);
-	}
-	return 0;
-}
-
-struct audio_frame {
-	uint16_t count_low;
-	uint16_t count_high;
-	uint16_t bytes;
-	uint16_t unknown;
-	unsigned char samples[];
-} __packed;
-
-static void audpcm_in_get_dsp_frames(struct audio_in *audio)
-{
-	struct audio_frame *frame;
-	uint32_t index;
-	unsigned long flags;
-
-	index = audio->in_head;
-
-	frame = (void *) (((char *)audio->in[index].data) -
-			sizeof(*frame));
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->in[index].size = frame->bytes;
-
-	audio->in_head = (audio->in_head + 1) & (FRAME_NUM - 1);
-
-	/* If overflow, move the tail index foward. */
-	if (audio->in_head == audio->in_tail) {
-		audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
-		MM_ERR("Error! not able to keep up the read\n");
-	} else
-		audio->in_count++;
-
-	audpcm_in_dsp_read_buffer(audio, audio->dsp_cnt++);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-
-	wake_up(&audio->wait);
-}
-
-static void audrec_dsp_event(void *data, unsigned id, size_t len,
-			    void (*getevent)(void *ptr, size_t len))
-{
-	struct audio_in *audio = NULL;
-	uint16_t msg[3];
-
-	if (data)
-		audio = data;
-	else {
-		MM_ERR("invalid data for event %x\n", id);
-		return;
-	}
-
-	getevent(msg, sizeof(msg));
-
-	switch (id) {
-	case AUDREC_MSG_CMD_CFG_DONE_MSG: {
-		if (msg[0] & AUDREC_MSG_CFG_DONE_ENC_ENA) {
-			audio->audrec_obj_idx = msg[1];
-			MM_INFO("CFG ENABLED\n");
-			audpcm_in_encmem_config(audio);
-		} else {
-			MM_INFO("CFG SLEEP\n");
-			audio->running = 0;
-			audio->tx_agc_enable = 0;
-			audio->ns_enable = 0;
-			audio->iir_enable = 0;
-		}
-		break;
-	}
-	case AUDREC_MSG_CMD_AREC_MEM_CFG_DONE_MSG: {
-		MM_DBG("AREC_MEM_CFG_DONE_MSG\n");
-		audpcm_in_encparam_config(audio);
-		break;
-	}
-	case AUDREC_MSG_CMD_AREC_PARAM_CFG_DONE_MSG: {
-		MM_INFO("PARAM CFG DONE\n");
-		audio->running = 1;
-		if (is_acdb_enabled())
-			break;
-		audio_dsp_set_tx_agc(audio);
-		audio_dsp_set_ns(audio);
-		audio_dsp_set_iir(audio);
-		break;
-	}
-	case AUDREC_MSG_NO_EXT_PKT_AVAILABLE_MSG: {
-		MM_DBG("ERROR %x\n", msg[0]);
-		break;
-	}
-	case AUDREC_MSG_PACKET_READY_MSG: {
-		struct audrec_msg_packet_ready_msg pkt_ready_msg;
-
-		getevent(&pkt_ready_msg, AUDREC_MSG_PACKET_READY_MSG_LEN);
-		MM_DBG("UP_PACKET_READY_MSG: write cnt msw  %d \
-		write cnt lsw %d read cnt msw %d  read cnt lsw %d \n",\
-		pkt_ready_msg.pkt_counter_msw, \
-		pkt_ready_msg.pkt_counter_lsw, \
-		pkt_ready_msg.pkt_read_cnt_msw, \
-		pkt_ready_msg.pkt_read_cnt_lsw);
-
-		audpcm_in_get_dsp_frames(audio);
-		break;
-	}
-	case ADSP_MESSAGE_ID: {
-		MM_DBG("Received ADSP event: module \
-				enable/disable(audrectask)\n");
-		break;
-	}
-	default:
-		MM_ERR("unknown event %d\n", id);
-	}
-}
-
-static struct msm_adsp_ops audrec_adsp_ops = {
-	.event = audrec_dsp_event,
-};
-
-#define audio_send_queue_recbs(audio, cmd, len) \
-	msm_adsp_write(audio->audrec, ((audio->queue_ids & 0xFFFF0000) >> 16),\
-			cmd, len)
-#define audio_send_queue_rec(audio, cmd, len) \
-	msm_adsp_write(audio->audrec, (audio->queue_ids & 0x0000FFFF),\
-			cmd, len)
-
-static int audio_dsp_set_tx_agc(struct audio_in *audio)
-{
-	audpreproc_cmd_cfg_agc_params cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-
-	audio->tx_agc_cfg.cmd_id = AUDPREPROC_CMD_CFG_AGC_PARAMS;
-	if (audio->tx_agc_enable) {
-		/* cmd.tx_agc_param_mask = 0xFE00 from sample code */
-		audio->tx_agc_cfg.tx_agc_param_mask =
-		(1 << AUDPREPROC_CMD_TX_AGC_PARAM_MASK_COMP_SLOPE) |
-		(1 << AUDPREPROC_CMD_TX_AGC_PARAM_MASK_COMP_TH) |
-		(1 << AUDPREPROC_CMD_TX_AGC_PARAM_MASK_EXP_SLOPE) |
-		(1 << AUDPREPROC_CMD_TX_AGC_PARAM_MASK_EXP_TH) |
-		(1 << AUDPREPROC_CMD_TX_AGC_PARAM_MASK_COMP_AIG_FLAG) |
-		(1 << AUDPREPROC_CMD_TX_AGC_PARAM_MASK_COMP_STATIC_GAIN) |
-		(1 << AUDPREPROC_CMD_TX_AGC_PARAM_MASK_TX_AGC_ENA_FLAG);
-		audio->tx_agc_cfg.tx_agc_enable_flag =
-			AUDPREPROC_CMD_TX_AGC_ENA_FLAG_ENA;
-		/* cmd.param_mask = 0xFFF0 from sample code */
-		audio->tx_agc_cfg.tx_agc_param_mask =
-			(1 << AUDPREPROC_CMD_PARAM_MASK_RMS_TAY) |
-			(1 << AUDPREPROC_CMD_PARAM_MASK_RELEASEK) |
-			(1 << AUDPREPROC_CMD_PARAM_MASK_DELAY) |
-			(1 << AUDPREPROC_CMD_PARAM_MASK_ATTACKK) |
-			(1 << AUDPREPROC_CMD_PARAM_MASK_LEAKRATE_SLOW) |
-			(1 << AUDPREPROC_CMD_PARAM_MASK_LEAKRATE_FAST) |
-			(1 << AUDPREPROC_CMD_PARAM_MASK_AIG_RELEASEK) |
-			(1 << AUDPREPROC_CMD_PARAM_MASK_AIG_MIN) |
-			(1 << AUDPREPROC_CMD_PARAM_MASK_AIG_MAX) |
-			(1 << AUDPREPROC_CMD_PARAM_MASK_LEAK_UP) |
-			(1 << AUDPREPROC_CMD_PARAM_MASK_LEAK_DOWN) |
-			(1 << AUDPREPROC_CMD_PARAM_MASK_AIG_ATTACKK);
-	} else {
-		audio->tx_agc_cfg.tx_agc_param_mask =
-			(1 << AUDPREPROC_CMD_TX_AGC_PARAM_MASK_TX_AGC_ENA_FLAG);
-		audio->tx_agc_cfg.tx_agc_enable_flag =
-			AUDPREPROC_CMD_TX_AGC_ENA_FLAG_DIS;
-	}
-	cmd = audio->tx_agc_cfg;
-
-	return audpreproc_dsp_set_agc(&cmd, sizeof(cmd));
-}
-
-static int audio_enable_tx_agc(struct audio_in *audio, int enable)
-{
-	if (audio->tx_agc_enable != enable) {
-		audio->tx_agc_enable = enable;
-		if (audio->running)
-			audio_dsp_set_tx_agc(audio);
-	}
-	return 0;
-}
-
-static int audio_dsp_set_ns(struct audio_in *audio)
-{
-	audpreproc_cmd_cfg_ns_params cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-
-	audio->ns_cfg.cmd_id = AUDPREPROC_CMD_CFG_NS_PARAMS;
-
-	if (audio->ns_enable) {
-		/* cmd.ec_mode_new is fixed as 0x0064 when enable
-		 * from sample code */
-		audio->ns_cfg.ec_mode_new =
-			AUDPREPROC_CMD_EC_MODE_NEW_NS_ENA |
-			AUDPREPROC_CMD_EC_MODE_NEW_HB_ENA |
-			AUDPREPROC_CMD_EC_MODE_NEW_VA_ENA;
-	} else {
-		audio->ns_cfg.ec_mode_new =
-			AUDPREPROC_CMD_EC_MODE_NEW_NLMS_DIS |
-			AUDPREPROC_CMD_EC_MODE_NEW_DES_DIS |
-			AUDPREPROC_CMD_EC_MODE_NEW_NS_DIS |
-			AUDPREPROC_CMD_EC_MODE_NEW_CNI_DIS |
-			AUDPREPROC_CMD_EC_MODE_NEW_NLES_DIS |
-			AUDPREPROC_CMD_EC_MODE_NEW_HB_DIS |
-			AUDPREPROC_CMD_EC_MODE_NEW_VA_DIS |
-			AUDPREPROC_CMD_EC_MODE_NEW_PCD_DIS |
-			AUDPREPROC_CMD_EC_MODE_NEW_FEHI_DIS |
-			AUDPREPROC_CMD_EC_MODE_NEW_NEHI_DIS |
-			AUDPREPROC_CMD_EC_MODE_NEW_NLPP_DIS |
-			AUDPREPROC_CMD_EC_MODE_NEW_FNE_DIS |
-			AUDPREPROC_CMD_EC_MODE_NEW_PRENLMS_DIS;
-	}
-	cmd = audio->ns_cfg;
-
-	return audpreproc_dsp_set_ns(&cmd, sizeof(cmd));
-}
-
-static int audio_enable_ns(struct audio_in *audio, int enable)
-{
-	if (audio->ns_enable != enable) {
-		audio->ns_enable = enable;
-		if (audio->running)
-			audio_dsp_set_ns(audio);
-	}
-	return 0;
-}
-
-static int audio_dsp_set_iir(struct audio_in *audio)
-{
-	audpreproc_cmd_cfg_iir_tuning_filter_params cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-
-	audio->iir_cfg.cmd_id = AUDPREPROC_CMD_CFG_IIR_TUNING_FILTER_PARAMS;
-
-	if (audio->iir_enable)
-		/* cmd.active_flag is 0xFFFF from sample code but 0x0001 here */
-		audio->iir_cfg.active_flag = AUDPREPROC_CMD_IIR_ACTIVE_FLAG_ENA;
-	else
-		audio->iir_cfg.active_flag = AUDPREPROC_CMD_IIR_ACTIVE_FLAG_DIS;
-
-	cmd = audio->iir_cfg;
-
-	return audpreproc_dsp_set_iir(&cmd, sizeof(cmd));
-}
-
-static int audio_enable_iir(struct audio_in *audio, int enable)
-{
-	if (audio->iir_enable != enable) {
-		audio->iir_enable = enable;
-		if (audio->running)
-			audio_dsp_set_iir(audio);
-	}
-	return 0;
-}
-
-static int audpcm_in_dsp_enable(struct audio_in *audio, int enable)
-{
-	struct audrec_cmd_enc_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_ENC_CFG;
-
-	cmd.audrec_enc_type = (audio->enc_type & 0xFF) |
-	(enable ? AUDREC_CMD_ENC_ENA : AUDREC_CMD_ENC_DIS);
-	/* Don't care */
-	cmd.audrec_obj_idx = audio->audrec_obj_idx;
-
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audpcm_in_encmem_config(struct audio_in *audio)
-{
-	struct audrec_cmd_arecmem_cfg cmd;
-	uint16_t cnt = 0;
-	uint16_t *data = (void *) audio->data;
-
-	memset(&cmd, 0, sizeof(cmd));
-
-	cmd.cmd_id = AUDREC_CMD_ARECMEM_CFG;
-	cmd.audrec_obj_idx = audio->audrec_obj_idx;
-	/* Rate at which packet complete message comes */
-	cmd.audrec_up_pkt_intm_cnt = 1;
-	cmd.audrec_extpkt_buffer_msw = audio->phys >> 16;
-	cmd.audrec_extpkt_buffer_lsw = audio->phys;
-	/* Max Buffer no available for frames */
-	cmd.audrec_extpkt_buffer_num = FRAME_NUM;
-
-	/* prepare buffer pointers:
-	 * Mono: 1024 samples + 4 halfword header
-	 * Stereo: 2048 samples + 4 halfword header
-	 */
-	for (cnt = 0; cnt < FRAME_NUM; cnt++) {
-		audio->in[cnt].data = data + 4;
-			data += (4 + (audio->channel_mode ? 2048 : 1024));
-	}
-
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audpcm_in_encparam_config(struct audio_in *audio)
-{
-	struct audrec_cmd_arecparam_wav_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDREC_CMD_ARECPARAM_CFG;
-	cmd.common.audrec_obj_idx = audio->audrec_obj_idx;
-	cmd.samp_rate_idx = audio->samp_rate_index;
-	cmd.stereo_mode = audio->channel_mode; /* 0 for mono, 1 for stereo */
-
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audpcm_in_dsp_read_buffer(struct audio_in *audio, uint32_t read_cnt)
-{
-	audrec_cmd_packet_ext_ptr cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_PACKET_EXT_PTR;
-	cmd.type = audio->audrec_obj_idx;
-	cmd.curr_rec_count_msw = read_cnt >> 16;
-	cmd.curr_rec_count_lsw = read_cnt;
-
-	return audio_send_queue_recbs(audio, &cmd, sizeof(cmd));
-}
-
-/* ------------------- device --------------------- */
-
-static void audpcm_in_flush(struct audio_in *audio)
-{
-	int i;
-
-	audio->dsp_cnt = 0;
-	audio->in_head = 0;
-	audio->in_tail = 0;
-	audio->in_count = 0;
-	for (i = FRAME_NUM-1; i >= 0; i--) {
-		audio->in[i].size = 0;
-		audio->in[i].read = 0;
-	}
-}
-
-static long audpcm_in_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct audio_in *audio = file->private_data;
-	int rc = 0;
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		stats.byte_count = atomic_read(&audio->in_bytes);
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START: {
-		rc = audpcm_in_enable(audio);
-		audio->stopped = 0;
-		break;
-	}
-	case AUDIO_STOP:
-		rc = audpcm_in_disable(audio);
-		break;
-	case AUDIO_FLUSH:
-		if (audio->stopped) {
-			/* Make sure we're stopped and we wake any threads
-			 * that might be blocked holding the read_lock.
-			 * While audio->stopped read threads will always
-			 * exit immediately.
-			 */
-			wake_up(&audio->wait);
-			mutex_lock(&audio->read_lock);
-			audpcm_in_flush(audio);
-			mutex_unlock(&audio->read_lock);
-		}
-		break;
-	case AUDIO_SET_CONFIG: {
-		struct msm_audio_config cfg;
-
-		if (copy_from_user(&cfg, (void *) arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (cfg.channel_count == 1) {
-			cfg.channel_count = AUDREC_CMD_STEREO_MODE_MONO;
-		} else if (cfg.channel_count == 2) {
-			cfg.channel_count = AUDREC_CMD_STEREO_MODE_STEREO;
-		} else {
-			rc = -EINVAL;
-			break;
-		}
-
-		audio->samp_rate = convert_samp_rate(cfg.sample_rate);
-		audio->samp_rate_index =
-		  convert_dsp_samp_index(cfg.sample_rate);
-		audio->channel_mode = cfg.channel_count;
-		audio->buffer_size =
-				audio->channel_mode ? STEREO_DATA_SIZE
-							: MONO_DATA_SIZE;
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config cfg;
-		cfg.buffer_size = audio->buffer_size;
-		cfg.buffer_count = FRAME_NUM;
-		cfg.sample_rate = convert_samp_index(audio->samp_rate);
-		if (audio->channel_mode == AUDREC_CMD_STEREO_MODE_MONO)
-			cfg.channel_count = 1;
-		else
-			cfg.channel_count = 2;
-		cfg.type = 0;
-		cfg.unused[0] = 0;
-		cfg.unused[1] = 0;
-		cfg.unused[2] = 0;
-		if (copy_to_user((void *) arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		break;
-	}
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static ssize_t audpcm_in_read(struct file *file,
-				char __user *buf,
-				size_t count, loff_t *pos)
-{
-	struct audio_in *audio = file->private_data;
-	unsigned long flags;
-	const char __user *start = buf;
-	void *data;
-	uint32_t index;
-	uint32_t size;
-	int rc = 0;
-
-	mutex_lock(&audio->read_lock);
-	while (count > 0) {
-		rc = wait_event_interruptible_timeout(
-			audio->wait, (audio->in_count > 0) || audio->stopped,
-			msecs_to_jiffies(MSM_AUD_BUFFER_UPDATE_WAIT_MS));
-		if (rc == 0) {
-			rc = -ETIMEDOUT;
-			break;
-		} else if (rc < 0) {
-			break;
-		}
-
-		if (audio->stopped && !audio->in_count) {
-			rc = 0;/* End of File */
-			break;
-		}
-
-		index = audio->in_tail;
-		data = (uint8_t *) audio->in[index].data;
-		size = audio->in[index].size;
-		if (count >= size) {
-			/* order the reads on the buffer */
-			dma_coherent_post_ops();
-			if (copy_to_user(buf, data, size)) {
-				rc = -EFAULT;
-				break;
-			}
-			spin_lock_irqsave(&audio->dsp_lock, flags);
-			if (index != audio->in_tail) {
-				/* overrun -- data is invalid and we need to
-				 * retry
-				 */
-				spin_unlock_irqrestore(&audio->dsp_lock, flags);
-				continue;
-			}
-			audio->in[index].size = 0;
-			audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
-			audio->in_count--;
-			spin_unlock_irqrestore(&audio->dsp_lock, flags);
-			count -= size;
-			buf += size;
-		} else {
-			MM_ERR("short read\n");
-			break;
-		}
-	}
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		return buf - start;
-
-	return rc;
-}
-
-static ssize_t audpcm_in_write(struct file *file,
-				const char __user *buf,
-				size_t count, loff_t *pos)
-{
-	return -EINVAL;
-}
-
-static int audpcm_in_release(struct inode *inode, struct file *file)
-{
-	struct audio_in *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	audpcm_in_disable(audio);
-	audpcm_in_flush(audio);
-	audpreproc_aenc_free(audio->enc_id);
-	msm_adsp_put(audio->audrec);
-	audio->audrec = NULL;
-	audio->opened = 0;
-	if (audio->data) {
-		ion_unmap_kernel(audio->client, audio->output_buff_handle);
-		ion_free(audio->client, audio->output_buff_handle);
-		audio->data = NULL;
-	}
-	ion_client_destroy(audio->client);
-	mutex_unlock(&audio->lock);
-	return 0;
-}
-
-static struct audio_in the_audio_in;
-
-static int audpcm_in_open(struct inode *inode, struct file *file)
-{
-	struct audio_in *audio = &the_audio_in;
-	int rc;
-	int len = 0;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	struct ion_client *client = NULL;
-
-	int encid;
-	mutex_lock(&audio->lock);
-	if (audio->opened) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	/* Settings will be re-config at AUDIO_SET_CONFIG,
-	 * but at least we need to have initial config
-	 */
-	audio->mode = MSM_AUD_ENC_MODE_TUNNEL;
-	audio->samp_rate = RPC_AUD_DEF_SAMPLE_RATE_11025;
-	audio->samp_rate_index = AUDREC_CMD_SAMP_RATE_INDX_11025;
-	audio->channel_mode = AUDREC_CMD_STEREO_MODE_MONO;
-	audio->buffer_size = MONO_DATA_SIZE;
-	audio->enc_type = AUDREC_CMD_TYPE_0_INDEX_WAV | audio->mode;
-
-	rc = audmgr_open(&audio->audmgr);
-	if (rc)
-		goto done;
-	encid = audpreproc_aenc_alloc(audio->enc_type, &audio->module_name,
-			&audio->queue_ids);
-	if (encid < 0) {
-		MM_ERR("No free encoder available\n");
-		rc = -ENODEV;
-		goto done;
-	}
-	audio->enc_id = encid;
-
-	rc = msm_adsp_get(audio->module_name, &audio->audrec,
-			   &audrec_adsp_ops, audio);
-	if (rc) {
-		audpreproc_aenc_free(audio->enc_id);
-		goto done;
-	}
-
-	audio->dsp_cnt = 0;
-	audio->stopped = 0;
-
-	audpcm_in_flush(audio);
-
-	client = msm_ion_client_create(UINT_MAX, "Audio_PCM_in_client");
-	if (IS_ERR_OR_NULL(client)) {
-		MM_ERR("Unable to create ION client\n");
-		rc = -ENOMEM;
-		goto client_create_error;
-	}
-	audio->client = client;
-
-	MM_DBG("allocating mem sz = %d\n", DMASZ);
-	handle = ion_alloc(client, DMASZ, SZ_4K,
-		ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-	if (IS_ERR_OR_NULL(handle)) {
-		MM_ERR("Unable to create allocate O/P buffers\n");
-		rc = -ENOMEM;
-		goto output_buff_alloc_error;
-	}
-
-	audio->output_buff_handle = handle;
-
-	rc = ion_phys(client , handle, &addr, &len);
-	if (rc) {
-		MM_ERR("O/P buffers:Invalid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-		rc = -ENOMEM;
-		goto output_buff_get_phys_error;
-	} else {
-		MM_INFO("O/P buffers:valid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-	}
-	audio->phys = (int32_t)addr;
-
-	rc = ion_handle_get_flags(client, handle, &ionflag);
-	if (rc) {
-		MM_ERR("could not get flags for the handle\n");
-		rc = -ENOMEM;
-		goto output_buff_get_flags_error;
-	}
-
-	audio->data = ion_map_kernel(client, handle);
-	if (IS_ERR(audio->data)) {
-		MM_ERR("could not map read buffers,freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENOMEM;
-		goto output_buff_map_error;
-	}
-	MM_DBG("read buf: phy addr 0x%08x kernel addr 0x%08x\n",
-		audio->phys, (int)audio->data);
-
-	file->private_data = audio;
-	audio->opened = 1;
-	rc = 0;
-done:
-	mutex_unlock(&audio->lock);
-	return rc;
-output_buff_map_error:
-output_buff_get_phys_error:
-output_buff_get_flags_error:
-	ion_free(client, audio->output_buff_handle);
-output_buff_alloc_error:
-	ion_client_destroy(client);
-client_create_error:
-	msm_adsp_put(audio->audrec);
-	audpreproc_aenc_free(audio->enc_id);
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static long audpre_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct audio_in *audio = file->private_data;
-	int rc = 0, enable;
-	uint16_t enable_mask;
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_ENABLE_AUDPRE:
-
-		if (is_acdb_enabled()) {
-			MM_INFO("Audpp is supported via acdb\n");
-			rc = -EFAULT;
-			break;
-		}
-		if (copy_from_user(&enable_mask, (void *) arg,
-						sizeof(enable_mask))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		enable = (enable_mask & AGC_ENABLE) ? 1 : 0;
-		audio_enable_tx_agc(audio, enable);
-		enable = (enable_mask & NS_ENABLE) ? 1 : 0;
-		audio_enable_ns(audio, enable);
-		enable = (enable_mask & TX_IIR_ENABLE) ? 1 : 0;
-		audio_enable_iir(audio, enable);
-		break;
-
-	case AUDIO_SET_AGC:
-		if (copy_from_user(&audio->tx_agc_cfg, (void *) arg,
-						sizeof(audio->tx_agc_cfg)))
-			rc = -EFAULT;
-		break;
-
-	case AUDIO_SET_NS:
-		if (copy_from_user(&audio->ns_cfg, (void *) arg,
-						sizeof(audio->ns_cfg)))
-			rc = -EFAULT;
-		break;
-
-	case AUDIO_SET_TX_IIR:
-		if (copy_from_user(&audio->iir_cfg, (void *) arg,
-						sizeof(audio->iir_cfg)))
-			rc = -EFAULT;
-		break;
-
-	default:
-		rc = -EINVAL;
-	}
-
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static int audpre_open(struct inode *inode, struct file *file)
-{
-	struct audio_in *audio = &the_audio_in;
-
-	file->private_data = audio;
-
-	return 0;
-}
-
-static const struct file_operations audio_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audpcm_in_open,
-	.release	= audpcm_in_release,
-	.read		= audpcm_in_read,
-	.write		= audpcm_in_write,
-	.unlocked_ioctl	= audpcm_in_ioctl,
-};
-
-static struct miscdevice audpcm_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_pcm_in",
-	.fops	= &audio_fops,
-};
-
-static const struct file_operations audpre_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audpre_open,
-	.unlocked_ioctl	= audpre_ioctl,
-};
-
-static struct miscdevice audpre_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_preproc_ctl",
-	.fops	= &audpre_fops,
-};
-
-static int __init audpcm_in_init(void)
-{
-
-	mutex_init(&the_audio_in.lock);
-	mutex_init(&the_audio_in.read_lock);
-	spin_lock_init(&the_audio_in.dsp_lock);
-	init_waitqueue_head(&the_audio_in.wait);
-	return misc_register(&audpcm_in_misc) || misc_register(&audpre_misc);
-}
-device_initcall(audpcm_in_init);
diff --git a/arch/arm/mach-msm/qdsp5/audio_qcelp.c b/arch/arm/mach-msm/qdsp5/audio_qcelp.c
deleted file mode 100644
index 50bde91..0000000
--- a/arch/arm/mach-msm/qdsp5/audio_qcelp.c
+++ /dev/null
@@ -1,1698 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/audio_qcelp.c
- *
- * qcelp 13k audio decoder device
- *
- * Copyright (c) 2008-2009, 2011-2012 The Linux Foundation. All rights reserved.
- *
- * This code is based in part on audio_mp3.c, which is
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you can find it at http://www.fsf.org.
- *
- */
-
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/earlysuspend.h>
-#include <linux/list.h>
-#include <linux/slab.h>
-#include <linux/msm_audio.h>
-#include <linux/memory_alloc.h>
-#include <linux/msm_ion.h>
-
-#include <mach/msm_adsp.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/qdsp5/qdsp5audppcmdi.h>
-#include <mach/qdsp5/qdsp5audppmsg.h>
-#include <mach/qdsp5/qdsp5audpp.h>
-#include <mach/qdsp5/qdsp5audplaycmdi.h>
-#include <mach/qdsp5/qdsp5audplaymsg.h>
-#include <mach/qdsp5/qdsp5rmtcmdi.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_memtypes.h>
-
-#include "audmgr.h"
-
-#define BUFSZ 1094 /* QCELP 13K Hold 600ms packet data = 36 * 30 and
-		      14 bytes of meta in */
-#define BUF_COUNT 2
-#define DMASZ (BUFSZ * BUF_COUNT)
-
-#define PCM_BUFSZ_MIN 1624 /* 100ms worth of data and
-			      24 bytes of meta out  */
-#define PCM_BUF_MAX_COUNT 5
-
-#define AUDDEC_DEC_QCELP 9
-
-#define	ROUTING_MODE_FTRT	1
-#define	ROUTING_MODE_RT		2
-/* Decoder status received from AUDPPTASK */
-#define	AUDPP_DEC_STATUS_SLEEP	0
-#define	AUDPP_DEC_STATUS_INIT	1
-#define	AUDPP_DEC_STATUS_CFG	2
-#define	AUDPP_DEC_STATUS_PLAY	3
-
-#define AUDQCELP_METAFIELD_MASK 0xFFFF0000
-#define AUDQCELP_EOS_FLG_OFFSET 0x0A /* Offset from beginning of buffer */
-#define AUDQCELP_EOS_FLG_MASK 0x01
-#define AUDQCELP_EOS_NONE 0x0 /* No EOS detected */
-#define AUDQCELP_EOS_SET 0x1 /* EOS set in meta field */
-
-#define AUDQCELP_EVENT_NUM 10 /* Default number of pre-allocated event pkts */
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;		/* Input usage actual DSP produced PCM size  */
-	unsigned addr;
-	unsigned short mfield_sz; /*only useful for data has meta field */
-};
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-struct audqcelp_suspend_ctl {
-	struct early_suspend node;
-	struct audio *audio;
-};
-#endif
-
-struct audqcelp_event{
-	struct list_head list;
-	int event_type;
-	union msm_audio_event_payload payload;
-};
-
-struct audio {
-	struct buffer out[BUF_COUNT];
-
-	spinlock_t dsp_lock;
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed;	/* number of buffers the dsp is waiting for */
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-
-	/* Host PCM section - START */
-	struct buffer in[PCM_BUF_MAX_COUNT];
-	struct mutex read_lock;
-	wait_queue_head_t read_wait;    /* Wait queue for read */
-	char *read_data;        /* pointer to reader buffer */
-	int32_t read_phys;   /* physical address of reader buffer */
-	uint8_t read_next;      /* index to input buffers to be read next */
-	uint8_t fill_next;      /* index to buffer that DSP should be filling */
-	uint8_t pcm_buf_count;  /* number of pcm buffer allocated */
-	/* Host PCM section - END */
-
-	struct msm_adsp_module *audplay;
-
-	struct audmgr audmgr;
-
-	/* data allocated for various buffers */
-	char *data;
-	int32_t phys; /* physical address of write buffer */
-	void *map_v_read;
-	void *map_v_write;
-	int mfield; /* meta field embedded in data */
-	int rflush; /* Read  flush */
-	int wflush; /* Write flush */
-	uint8_t opened:1;
-	uint8_t enabled:1;
-	uint8_t running:1;
-	uint8_t stopped:1;	/* set when stopped, cleared on flush */
-	uint8_t pcm_feedback:1; /* set when non-tunnel mode */
-	uint8_t buf_refresh:1;
-	int teos; /* valid only if tunnel mode & no data left for decoder */
-	enum msm_aud_decoder_state dec_state;	/* Represents decoder state */
-	int rmt_resource_released;
-
-	const char *module_name;
-	unsigned queue_id;
-	uint16_t dec_id;
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	struct audqcelp_suspend_ctl suspend_ctl;
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *dentry;
-#endif
-
-	wait_queue_head_t wait;
-	struct list_head free_event_queue;
-	struct list_head event_queue;
-	wait_queue_head_t event_wait;
-	spinlock_t event_queue_lock;
-	struct mutex get_event_lock;
-	int event_abort;
-
-	int eq_enable;
-	int eq_needs_commit;
-	audpp_cmd_cfg_object_params_eqalizer eq;
-	audpp_cmd_cfg_object_params_volume vol_pan;
-	struct ion_client *client;
-	struct ion_handle *input_buff_handle;
-	struct ion_handle *output_buff_handle;
-};
-
-static int auddec_dsp_config(struct audio *audio, int enable);
-static void audpp_cmd_cfg_adec_params(struct audio *audio);
-static void audpp_cmd_cfg_routing_mode(struct audio *audio);
-static void audqcelp_send_data(struct audio *audio, unsigned needed);
-static void audqcelp_config_hostpcm(struct audio *audio);
-static void audqcelp_buffer_refresh(struct audio *audio);
-static void audqcelp_dsp_event(void *private, unsigned id, uint16_t *msg);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audqcelp_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload);
-#endif
-
-static int rmt_put_resource(struct audio *audio)
-{
-	struct aud_codec_config_cmd cmd;
-	unsigned short client_idx;
-
-	cmd.cmd_id = RM_CMD_AUD_CODEC_CFG;
-	cmd.client_id = RM_AUD_CLIENT_ID;
-	cmd.task_id = audio->dec_id;
-	cmd.enable = RMT_DISABLE;
-	cmd.dec_type = AUDDEC_DEC_QCELP;
-	client_idx = ((cmd.client_id << 8) | cmd.task_id);
-
-	return put_adsp_resource(client_idx, &cmd, sizeof(cmd));
-}
-
-static int rmt_get_resource(struct audio *audio)
-{
-	struct aud_codec_config_cmd cmd;
-	unsigned short client_idx;
-
-	cmd.cmd_id = RM_CMD_AUD_CODEC_CFG;
-	cmd.client_id = RM_AUD_CLIENT_ID;
-	cmd.task_id = audio->dec_id;
-	cmd.enable = RMT_ENABLE;
-	cmd.dec_type = AUDDEC_DEC_QCELP;
-	client_idx = ((cmd.client_id << 8) | cmd.task_id);
-
-	return get_adsp_resource(client_idx, &cmd, sizeof(cmd));
-}
-
-/* must be called with audio->lock held */
-static int audqcelp_enable(struct audio *audio)
-{
-	struct audmgr_config cfg;
-	int rc;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled)
-		return 0;
-
-	if (audio->rmt_resource_released == 1) {
-		audio->rmt_resource_released = 0;
-		rc = rmt_get_resource(audio);
-		if (rc) {
-			MM_ERR("ADSP resources are not available for QCELP \
-				session 0x%08x on decoder: %d\n Ignoring \
-				error and going ahead with the playback\n",
-				(int)audio, audio->dec_id);
-		}
-	}
-
-	audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-
-	if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK) {
-		cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE;
-		cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000;
-		cfg.def_method = RPC_AUD_DEF_METHOD_PLAYBACK;
-		cfg.codec = RPC_AUD_DEF_CODEC_13K;
-		cfg.snd_method = RPC_SND_METHOD_MIDI;
-
-		rc = audmgr_enable(&audio->audmgr, &cfg);
-		if (rc < 0) {
-			msm_adsp_dump(audio->audplay);
-			return rc;
-		}
-	}
-
-	if (msm_adsp_enable(audio->audplay)) {
-		MM_ERR("msm_adsp_enable(audplay) failed\n");
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_disable(&audio->audmgr);
-		return -ENODEV;
-	}
-
-	if (audpp_enable(audio->dec_id, audqcelp_dsp_event, audio)) {
-		MM_ERR("audpp_enable() failed\n");
-		msm_adsp_disable(audio->audplay);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_disable(&audio->audmgr);
-		return -ENODEV;
-	}
-	audio->enabled = 1;
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audqcelp_disable(struct audio *audio)
-{
-	int rc = 0;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-		auddec_dsp_config(audio, 0);
-		rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-		if (rc == 0)
-			rc = -ETIMEDOUT;
-		else if (audio->dec_state != MSM_AUD_DECODER_STATE_CLOSE)
-			rc = -EFAULT;
-		else
-			rc = 0;
-		audio->stopped = 1;
-		wake_up(&audio->write_wait);
-		wake_up(&audio->read_wait);
-		msm_adsp_disable(audio->audplay);
-		audpp_disable(audio->dec_id, audio);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK) {
-			rc = audmgr_disable(&audio->audmgr);
-			if (rc < 0)
-				msm_adsp_dump(audio->audplay);
-		}
-		audio->out_needed = 0;
-		rmt_put_resource(audio);
-		audio->rmt_resource_released = 1;
-	}
-	return rc;
-}
-
-/* ------------------- dsp --------------------- */
-static void audqcelp_update_pcm_buf_entry(struct audio *audio,
-	uint32_t *payload)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	if (audio->rflush)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < payload[1]; index++) {
-		if (audio->in[audio->fill_next].addr ==
-			payload[2 + index * 2]) {
-			MM_DBG("in[%d] ready\n", audio->fill_next);
-			audio->in[audio->fill_next].used =
-			payload[3 + index * 2];
-			if ((++audio->fill_next) == audio->pcm_buf_count)
-				audio->fill_next = 0;
-		} else {
-			MM_ERR("expected=%x ret=%x\n",
-				audio->in[audio->fill_next].addr,
-				payload[1 + index * 2]);
-			break;
-		}
-	}
-	if (audio->in[audio->fill_next].used == 0) {
-		audqcelp_buffer_refresh(audio);
-	} else {
-		MM_DBG("read cannot keep up\n");
-		audio->buf_refresh = 1;
-	}
-	wake_up(&audio->read_wait);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audplay_dsp_event(void *data, unsigned id, size_t len,
-			      void (*getevent) (void *ptr, size_t len))
-{
-	struct audio *audio = data;
-	uint32_t msg[28];
-	getevent(msg, sizeof(msg));
-
-	MM_DBG("msg_id=%x\n", id);
-
-	switch (id) {
-	case AUDPLAY_MSG_DEC_NEEDS_DATA:
-		audqcelp_send_data(audio, 1);
-		break;
-
-	case AUDPLAY_MSG_BUFFER_UPDATE:
-		audqcelp_update_pcm_buf_entry(audio, msg);
-		break;
-
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audplaytask)\n");
-		break;
-
-	default:
-		MM_ERR("unexpected message from decoder \n");
-	}
-}
-
-static void audqcelp_dsp_event(void *private, unsigned id, uint16_t *msg)
-{
-	struct audio *audio = private;
-
-	switch (id) {
-	case AUDPP_MSG_STATUS_MSG:{
-			unsigned status = msg[1];
-
-			switch (status) {
-			case AUDPP_DEC_STATUS_SLEEP: {
-				uint16_t reason = msg[2];
-				MM_DBG("decoder status:sleep reason = \
-						0x%04x\n", reason);
-				if ((reason == AUDPP_MSG_REASON_MEM)
-					|| (reason ==
-					AUDPP_MSG_REASON_NODECODER)) {
-					audio->dec_state =
-					MSM_AUD_DECODER_STATE_FAILURE;
-					wake_up(&audio->wait);
-				} else if (reason == AUDPP_MSG_REASON_NONE) {
-					/* decoder is in disable state */
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_CLOSE;
-					wake_up(&audio->wait);
-				}
-				break;
-			}
-			case AUDPP_DEC_STATUS_INIT:
-				MM_DBG("decoder status: init \n");
-				if (audio->pcm_feedback)
-					audpp_cmd_cfg_routing_mode(audio);
-				else
-					audpp_cmd_cfg_adec_params(audio);
-				break;
-
-			case AUDPP_DEC_STATUS_CFG:
-				MM_DBG("decoder status: cfg \n");
-				break;
-			case AUDPP_DEC_STATUS_PLAY:
-				MM_DBG("decoder status: play \n");
-				if (audio->pcm_feedback) {
-					audqcelp_config_hostpcm(audio);
-					audqcelp_buffer_refresh(audio);
-				}
-				audio->dec_state =
-					MSM_AUD_DECODER_STATE_SUCCESS;
-				wake_up(&audio->wait);
-				break;
-			default:
-				MM_ERR("unknown decoder status\n");
-			}
-			break;
-		}
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_DBG("CFG_MSG ENABLE\n");
-			auddec_dsp_config(audio, 1);
-			audio->out_needed = 0;
-			audio->running = 1;
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-			audpp_dsp_set_eq(audio->dec_id,	audio->eq_enable,
-								&audio->eq);
-			audpp_avsync(audio->dec_id, 22050);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			MM_DBG("CFG_MSG DISABLE\n");
-			audpp_avsync(audio->dec_id, 0);
-			audio->running = 0;
-		} else {
-			MM_DBG("CFG_MSG %d?\n", msg[0]);
-		}
-		break;
-	case AUDPP_MSG_ROUTING_ACK:
-		MM_DBG("ROUTING_ACK mode=%d\n", msg[1]);
-		audpp_cmd_cfg_adec_params(audio);
-		break;
-	case AUDPP_MSG_FLUSH_ACK:
-		MM_DBG("FLUSH_ACK\n");
-		audio->wflush = 0;
-		audio->rflush = 0;
-		wake_up(&audio->write_wait);
-		if (audio->pcm_feedback)
-			audqcelp_buffer_refresh(audio);
-		break;
-	case AUDPP_MSG_PCMDMAMISSED:
-		MM_DBG("PCMDMAMISSED\n");
-		audio->teos = 1;
-		wake_up(&audio->write_wait);
-		break;
-	default:
-		MM_ERR("UNKNOWN (%d)\n", id);
-	}
-
-}
-
-struct msm_adsp_ops audplay_adsp_ops_qcelp = {
-	.event = audplay_dsp_event,
-};
-
-#define audplay_send_queue0(audio, cmd, len) \
-	msm_adsp_write(audio->audplay, audio->queue_id, \
-		cmd, len)
-
-static int auddec_dsp_config(struct audio *audio, int enable)
-{
-	u16 cfg_dec_cmd[AUDPP_CMD_CFG_DEC_TYPE_LEN / sizeof(unsigned short)];
-
-	memset(cfg_dec_cmd, 0, sizeof(cfg_dec_cmd));
-
-	cfg_dec_cmd[0] = AUDPP_CMD_CFG_DEC_TYPE;
-	if (enable)
-		cfg_dec_cmd[1 + audio->dec_id] = AUDPP_CMD_UPDATDE_CFG_DEC |
-			AUDPP_CMD_ENA_DEC_V | AUDDEC_DEC_QCELP;
-	else
-		cfg_dec_cmd[1 + audio->dec_id] = AUDPP_CMD_UPDATDE_CFG_DEC |
-			AUDPP_CMD_DIS_DEC_V;
-
-	return audpp_send_queue1(&cfg_dec_cmd, sizeof(cfg_dec_cmd));
-}
-
-static void audpp_cmd_cfg_adec_params(struct audio *audio)
-{
-	struct audpp_cmd_cfg_adec_params_v13k cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_CMD_CFG_ADEC_PARAMS;
-	cmd.common.length = AUDPP_CMD_CFG_ADEC_PARAMS_V13K_LEN;
-	cmd.common.dec_id = audio->dec_id;
-	cmd.common.input_sampling_frequency = 8000;
-	cmd.stereo_cfg = AUDPP_CMD_PCM_INTF_MONO_V;
-
-	audpp_send_queue2(&cmd, sizeof(cmd));
-}
-
-static void audpp_cmd_cfg_routing_mode(struct audio *audio)
-{
-	struct audpp_cmd_routing_mode cmd;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPP_CMD_ROUTING_MODE;
-	cmd.object_number = audio->dec_id;
-	if (audio->pcm_feedback)
-		cmd.routing_mode = ROUTING_MODE_FTRT;
-	else
-		cmd.routing_mode = ROUTING_MODE_RT;
-	audpp_send_queue1(&cmd, sizeof(cmd));
-}
-
-static int audplay_dsp_send_data_avail(struct audio *audio,
-				       unsigned idx, unsigned len)
-{
-	struct audplay_cmd_bitstream_data_avail_nt2 cmd;
-
-	cmd.cmd_id = AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2;
-	if (audio->mfield)
-		cmd.decoder_id = AUDQCELP_METAFIELD_MASK |
-			(audio->out[idx].mfield_sz >> 1);
-	else
-		cmd.decoder_id = audio->dec_id;
-	cmd.buf_ptr = audio->out[idx].addr;
-	cmd.buf_size = len / 2;
-	cmd.partition_number = 0;
-	/* complete writes to the input buffer */
-	wmb();
-	return audplay_send_queue0(audio, &cmd, sizeof(cmd));
-}
-
-static void audqcelp_buffer_refresh(struct audio *audio)
-{
-	struct audplay_cmd_buffer_refresh refresh_cmd;
-
-	refresh_cmd.cmd_id = AUDPLAY_CMD_BUFFER_REFRESH;
-	refresh_cmd.num_buffers = 1;
-	refresh_cmd.buf0_address = audio->in[audio->fill_next].addr;
-	refresh_cmd.buf0_length = audio->in[audio->fill_next].size;
-	refresh_cmd.buf_read_count = 0;
-	MM_DBG("buf0_addr=%x buf0_len=%d\n", refresh_cmd.buf0_address,
-			refresh_cmd.buf0_length);
-
-	(void)audplay_send_queue0(audio, &refresh_cmd, sizeof(refresh_cmd));
-}
-
-static void audqcelp_config_hostpcm(struct audio *audio)
-{
-	struct audplay_cmd_hpcm_buf_cfg cfg_cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	cfg_cmd.cmd_id = AUDPLAY_CMD_HPCM_BUF_CFG;
-	cfg_cmd.max_buffers = 1;
-	cfg_cmd.byte_swap = 0;
-	cfg_cmd.hostpcm_config = (0x8000) | (0x4000);
-	cfg_cmd.feedback_frequency = 1;
-	cfg_cmd.partition_number = 0;
-
-	(void)audplay_send_queue0(audio, &cfg_cmd, sizeof(cfg_cmd));
-}
-
-static void audqcelp_send_data(struct audio *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			MM_DBG("frame %d free\n", audio->out_tail);
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			MM_DBG("frame %d busy\n", audio->out_tail);
-			audplay_dsp_send_data_avail(audio, audio->out_tail,
-						    frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
- done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-
-static void audqcelp_flush(struct audio *audio)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->out[0].used = 0;
-	audio->out[1].used = 0;
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audqcelp_flush_pcm_buf(struct audio *audio)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < PCM_BUF_MAX_COUNT; index++)
-		audio->in[index].used = 0;
-
-	audio->buf_refresh = 0;
-	audio->read_next = 0;
-	audio->fill_next = 0;
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audqcelp_ioport_reset(struct audio *audio)
-{
-	/* Make sure read/write thread are free from
-	 * sleep and knowing that system is not able
-	 * to process io request at the moment
-	 */
-	wake_up(&audio->write_wait);
-	mutex_lock(&audio->write_lock);
-	audqcelp_flush(audio);
-	mutex_unlock(&audio->write_lock);
-	wake_up(&audio->read_wait);
-	mutex_lock(&audio->read_lock);
-	audqcelp_flush_pcm_buf(audio);
-	mutex_unlock(&audio->read_lock);
-}
-
-static int audqcelp_events_pending(struct audio *audio)
-{
-	unsigned long flags;
-	int empty;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	empty = !list_empty(&audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	return empty || audio->event_abort;
-}
-
-static void audqcelp_reset_event_queue(struct audio *audio)
-{
-	unsigned long flags;
-	struct audqcelp_event *drv_evt;
-	struct list_head *ptr, *next;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	list_for_each_safe(ptr, next, &audio->event_queue) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audqcelp_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	list_for_each_safe(ptr, next, &audio->free_event_queue) {
-		drv_evt = list_first_entry(&audio->free_event_queue,
-				struct audqcelp_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	return;
-}
-
-
-static long audqcelp_process_event_req(struct audio *audio, void __user *arg)
-{
-	long rc;
-	struct msm_audio_event usr_evt;
-	struct audqcelp_event *drv_evt = NULL;
-	int timeout;
-	unsigned long flags;
-
-	if (copy_from_user(&usr_evt, arg, sizeof(struct msm_audio_event)))
-		return -EFAULT;
-
-	timeout = (int) usr_evt.timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(
-			audio->event_wait, audqcelp_events_pending(audio),
-			msecs_to_jiffies(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(
-			audio->event_wait, audqcelp_events_pending(audio));
-	}
-
-	if (rc < 0)
-		return rc;
-
-	if (audio->event_abort) {
-		audio->event_abort = 0;
-		return -ENODEV;
-	}
-
-	rc = 0;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	if (!list_empty(&audio->event_queue)) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audqcelp_event, list);
-		list_del(&drv_evt->list);
-	}
-
-	if (drv_evt) {
-		usr_evt.event_type = drv_evt->event_type;
-		usr_evt.event_payload = drv_evt->payload;
-		list_add_tail(&drv_evt->list, &audio->free_event_queue);
-	} else
-		rc = -1;
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	if (!rc && copy_to_user(arg, &usr_evt, sizeof(usr_evt)))
-		rc = -EFAULT;
-
-	return rc;
-}
-
-static int audio_enable_eq(struct audio *audio, int enable)
-{
-	if (audio->eq_enable == enable && !audio->eq_needs_commit)
-		return 0;
-
-	audio->eq_enable = enable;
-
-	if (audio->running) {
-		audpp_dsp_set_eq(audio->dec_id, enable, &audio->eq);
-		audio->eq_needs_commit = 0;
-	}
-	return 0;
-}
-
-static long audqcelp_ioctl(struct file *file, unsigned int cmd,
-		unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = -EINVAL;
-	unsigned long flags = 0;
-	uint16_t enable_mask;
-	int enable;
-	int prev_state;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	int len = 0;
-
-	MM_DBG("cmd = %d\n", cmd);
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		stats.byte_count = audpp_avsync_byte_count(audio->dec_id);
-		stats.sample_count = audpp_avsync_sample_count(audio->dec_id);
-		if (copy_to_user((void *)arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-
-	switch (cmd) {
-	case AUDIO_ENABLE_AUDPP:
-		if (copy_from_user(&enable_mask, (void *) arg,
-						sizeof(enable_mask))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		enable = (enable_mask & EQ_ENABLE) ? 1 : 0;
-		audio_enable_eq(audio, enable);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-	case AUDIO_SET_VOLUME:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.volume = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_PAN:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.pan = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_EQ:
-		prev_state = audio->eq_enable;
-		audio->eq_enable = 0;
-		if (copy_from_user(&audio->eq.num_bands, (void *) arg,
-				sizeof(audio->eq) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2))) {
-			rc = -EFAULT;
-			break;
-		}
-		audio->eq_enable = prev_state;
-		audio->eq_needs_commit = 1;
-		rc = 0;
-		break;
-	}
-
-	if (-EINVAL != rc)
-		return rc;
-
-	if (cmd == AUDIO_GET_EVENT) {
-		MM_DBG("AUDIO_GET_EVENT\n");
-		if (mutex_trylock(&audio->get_event_lock)) {
-			rc = audqcelp_process_event_req(audio,
-					(void __user *) arg);
-			mutex_unlock(&audio->get_event_lock);
-		} else
-			rc = -EBUSY;
-		return rc;
-	}
-
-	if (cmd == AUDIO_ABORT_GET_EVENT) {
-		audio->event_abort = 1;
-		wake_up(&audio->event_wait);
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		MM_DBG("AUDIO_START\n");
-		rc = audqcelp_enable(audio);
-		if (!rc) {
-			rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-			MM_INFO("dec_state %d rc = %d\n", audio->dec_state, rc);
-
-			if (audio->dec_state != MSM_AUD_DECODER_STATE_SUCCESS)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		break;
-	case AUDIO_STOP:
-		MM_DBG("AUDIO_STOP\n");
-		rc = audqcelp_disable(audio);
-		audqcelp_ioport_reset(audio);
-		audio->stopped = 0;
-		break;
-	case AUDIO_FLUSH:
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audqcelp_ioport_reset(audio);
-		if (audio->running) {
-			audpp_flush(audio->dec_id);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-	case AUDIO_SET_CONFIG:{
-			struct msm_audio_config config;
-			if (copy_from_user(&config, (void *)arg,
-				sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-			audio->mfield = config.meta_field;
-			MM_DBG("AUDIO_SET_CONFIG applicable \
-				for metafield configuration\n");
-			rc = 0;
-			break;
-		}
-	case AUDIO_GET_CONFIG:{
-			struct msm_audio_config config;
-			config.buffer_size = BUFSZ;
-			config.buffer_count = BUF_COUNT;
-			config.sample_rate = 8000;
-			config.channel_count = 1;
-			config.meta_field = 0;
-			config.unused[0] = 0;
-			config.unused[1] = 0;
-			config.unused[2] = 0;
-			if (copy_to_user((void *)arg, &config,
-					 sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-
-			break;
-		}
-	case AUDIO_GET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-
-			config.pcm_feedback = audio->pcm_feedback;
-			config.buffer_count = PCM_BUF_MAX_COUNT;
-			config.buffer_size = PCM_BUFSZ_MIN;
-			if (copy_to_user((void *)arg, &config,
-				sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_SET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-
-			if (copy_from_user(&config, (void *)arg,
-				sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-			if (config.pcm_feedback != audio->pcm_feedback) {
-				MM_ERR("Not sufficient permission to"
-					 "change the playback mode\n");
-				rc = -EACCES;
-				break;
-			}
-			if ((config.buffer_count > PCM_BUF_MAX_COUNT) ||
-				(config.buffer_count == 1))
-				config.buffer_count = PCM_BUF_MAX_COUNT;
-
-			if (config.buffer_size < PCM_BUFSZ_MIN)
-				config.buffer_size = PCM_BUFSZ_MIN;
-
-			/* Check if pcm feedback is required */
-			if ((config.pcm_feedback) && (!audio->read_data)) {
-				MM_DBG("allocate PCM buf %d\n",
-				config.buffer_count * config.buffer_size);
-				handle = ion_alloc(audio->client,
-					(config.buffer_size *
-					config.buffer_count),
-					SZ_4K, ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-				if (IS_ERR_OR_NULL(handle)) {
-					MM_ERR("Unable to alloc I/P buffs\n");
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-					break;
-				}
-
-				audio->input_buff_handle = handle;
-
-				rc = ion_phys(audio->client ,
-					handle, &addr, &len);
-				if (rc) {
-					MM_ERR("Invalid phy: %x sz: %x\n",
-						(unsigned int) addr,
-						(unsigned int) len);
-					ion_free(audio->client, handle);
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-					break;
-				} else {
-					MM_INFO("Got valid phy: %x sz: %x\n",
-						(unsigned int) audio->read_phys,
-						(unsigned int) len);
-				}
-				audio->read_phys = (int32_t)addr;
-
-				rc = ion_handle_get_flags(audio->client,
-					handle, &ionflag);
-				if (rc) {
-					MM_ERR("could not get flags\n");
-					ion_free(audio->client, handle);
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-					break;
-				}
-				audio->map_v_read = ion_map_kernel(
-					audio->client, handle);
-				if (IS_ERR(audio->map_v_read)) {
-					MM_ERR("failed to map read buf\n");
-					ion_free(audio->client, handle);
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-				} else {
-					uint8_t index;
-					uint32_t offset = 0;
-					audio->read_data =
-						audio->map_v_read;
-					audio->buf_refresh = 0;
-					audio->pcm_buf_count =
-						config.buffer_count;
-					audio->read_next = 0;
-					audio->fill_next = 0;
-
-					for (index = 0;
-					index < config.buffer_count; index++) {
-						audio->in[index].data =
-						audio->read_data + offset;
-						audio->in[index].addr =
-						audio->read_phys + offset;
-						audio->in[index].size =
-						config.buffer_size;
-						audio->in[index].used = 0;
-						offset += config.buffer_size;
-					}
-					MM_DBG("read buf: phy addr 0x%08x \
-						kernel addr 0x%08x\n",
-						audio->read_phys,
-						(int)audio->read_data);
-					rc = 0;
-				}
-			} else {
-				rc = 0;
-			}
-			break;
-		}
-	case AUDIO_PAUSE:
-		MM_DBG("AUDIO_PAUSE %ld\n", arg);
-		rc = audpp_pause(audio->dec_id, (int) arg);
-		break;
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-/* Only useful in tunnel-mode */
-static int audqcelp_fsync(struct file *file, loff_t a, loff_t b,
-	int datasync)
-{
-	struct audio *audio = file->private_data;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (!audio->running || audio->pcm_feedback) {
-		rc = -EINVAL;
-		goto done_nolock;
-	}
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(!audio->out[0].used &&
-		!audio->out[1].used &&
-		audio->out_needed) || audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		audio->teos || audio->wflush);
-
-	if (audio->wflush)
-		rc = -EBUSY;
-
-done:
-	mutex_unlock(&audio->write_lock);
-done_nolock:
-	return rc;
-}
-
-static ssize_t audqcelp_read(struct file *file, char __user *buf, size_t count,
-			loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	int rc = 0;
-
-	if (!audio->pcm_feedback)
-		return 0; /* PCM feedback is not enabled. Nothing to read */
-
-	mutex_lock(&audio->read_lock);
-	MM_DBG("%d\n", count);
-	while (count > 0) {
-		rc = wait_event_interruptible(audio->read_wait,
-				(audio->in[audio->read_next].used > 0) ||
-				(audio->stopped) || (audio->rflush));
-		if (rc < 0)
-			break;
-
-		if (audio->stopped || audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (count < audio->in[audio->read_next].used) {
-			/* Read must happen in frame boundary. Since driver does
-			not know frame size, read count must be greater or equal
-			to size of PCM samples */
-			MM_DBG("read stop - partial frame\n");
-			break;
-		} else {
-			MM_DBG("read from in[%d]\n", audio->read_next);
-			/* order reads from the output buffer */
-			rmb();
-			if (copy_to_user(buf,
-				audio->in[audio->read_next].data,
-				audio->in[audio->read_next].used)) {
-				MM_ERR("invalid addr %x\n", (unsigned int)buf);
-				rc = -EFAULT;
-				break;
-			}
-			count -= audio->in[audio->read_next].used;
-			buf += audio->in[audio->read_next].used;
-			audio->in[audio->read_next].used = 0;
-			if ((++audio->read_next) == audio->pcm_buf_count)
-				audio->read_next = 0;
-			break;
-				/* Force to exit while loop
-				 * to prevent output thread
-				 * sleep too long if data is
-				 * not ready at this moment.
-				 */
-		}
-	}
-
-	/* don't feed output buffer to HW decoder during flushing
-	 * buffer refresh command will be sent once flush completes
-	 * send buf refresh command here can confuse HW decoder
-	 */
-	if (audio->buf_refresh && !audio->rflush) {
-		audio->buf_refresh = 0;
-		MM_DBG("kick start pcm feedback again\n");
-		audqcelp_buffer_refresh(audio);
-	}
-
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		rc = buf - start;
-
-	MM_DBG("read %d bytes\n", rc);
-	return rc;
-}
-
-static int audqcelp_process_eos(struct audio *audio,
-		const char __user *buf_start, unsigned short mfield_size)
-{
-	struct buffer *frame;
-	int rc = 0;
-
-	frame = audio->out + audio->out_head;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	audqcelp_send_data(audio, 0);
-
-done:
-	return rc;
-}
-
-static ssize_t audqcelp_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	size_t xfer;
-	char *cpy_ptr;
-	int rc = 0, eos_condition = AUDQCELP_EOS_NONE;
-	unsigned short mfield_size = 0;
-
-	MM_DBG("cnt=%d\n", count);
-
-	if (count & 1)
-		return -EINVAL;
-
-	mutex_lock(&audio->write_lock);
-	while (count > 0) {
-		frame = audio->out + audio->out_head;
-		cpy_ptr = frame->data;
-		rc = wait_event_interruptible(audio->write_wait,
-					      (frame->used == 0)
-						|| (audio->stopped)
-						|| (audio->wflush));
-		MM_DBG("buffer available\n");
-		if (rc < 0)
-			break;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (audio->mfield) {
-			if (buf == start) {
-				/* Processing beginning of user buffer */
-				if (__get_user(mfield_size,
-					(unsigned short __user *) buf)) {
-					rc = -EFAULT;
-					break;
-				} else 	if (mfield_size > count) {
-					rc = -EINVAL;
-					break;
-				}
-				MM_DBG("mf offset_val %x\n", mfield_size);
-				if (copy_from_user(cpy_ptr, buf, mfield_size)) {
-					rc = -EFAULT;
-					break;
-				}
-				/* Check if EOS flag is set and buffer has
-				 * contains just meta field
-				 */
-				if (cpy_ptr[AUDQCELP_EOS_FLG_OFFSET] &
-						AUDQCELP_EOS_FLG_MASK) {
-					MM_DBG("EOS SET\n");
-					eos_condition = AUDQCELP_EOS_SET;
-					if (mfield_size == count) {
-						buf += mfield_size;
-						break;
-					} else
-					cpy_ptr[AUDQCELP_EOS_FLG_OFFSET] &=
-						~AUDQCELP_EOS_FLG_MASK;
-				}
-				cpy_ptr += mfield_size;
-				count -= mfield_size;
-				buf += mfield_size;
-			} else {
-				mfield_size = 0;
-				MM_DBG("continuous buffer\n");
-			}
-			frame->mfield_sz = mfield_size;
-		}
-
-		xfer = (count > (frame->size - mfield_size)) ?
-			(frame->size - mfield_size) : count;
-		if (copy_from_user(cpy_ptr, buf, xfer)) {
-			rc = -EFAULT;
-			break;
-		}
-
-		frame->used = xfer + mfield_size;
-		audio->out_head ^= 1;
-		count -= xfer;
-		buf += xfer;
-		audqcelp_send_data(audio, 0);
-	}
-	if (eos_condition == AUDQCELP_EOS_SET)
-		rc = audqcelp_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	if (!rc) {
-		if (buf > start)
-			return buf - start;
-	}
-	return rc;
-}
-
-static int audqcelp_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	MM_INFO("audio instance 0x%08x freeing\n", (int) audio);
-	mutex_lock(&audio->lock);
-	audqcelp_disable(audio);
-	if (audio->rmt_resource_released == 0)
-		rmt_put_resource(audio);
-	audqcelp_flush(audio);
-	audqcelp_flush_pcm_buf(audio);
-	msm_adsp_put(audio->audplay);
-	audpp_adec_free(audio->dec_id);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	unregister_early_suspend(&audio->suspend_ctl.node);
-#endif
-	audio->opened = 0;
-	audio->event_abort = 1;
-	wake_up(&audio->event_wait);
-	audqcelp_reset_event_queue(audio);
-	ion_unmap_kernel(audio->client, audio->output_buff_handle);
-	ion_free(audio->client, audio->output_buff_handle);
-	if (audio->input_buff_handle != NULL) {
-		ion_unmap_kernel(audio->client, audio->input_buff_handle);
-		ion_free(audio->client, audio->input_buff_handle);
-	}
-	ion_client_destroy(audio->client);
-	mutex_unlock(&audio->lock);
-#ifdef CONFIG_DEBUG_FS
-	if (audio->dentry)
-		debugfs_remove(audio->dentry);
-#endif
-	kfree(audio);
-	return 0;
-}
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audqcelp_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload)
-{
-	struct audqcelp_event *e_node = NULL;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-
-	if (!list_empty(&audio->free_event_queue)) {
-		e_node = list_first_entry(&audio->free_event_queue,
-				struct audqcelp_event, list);
-		list_del(&e_node->list);
-	} else {
-		e_node = kmalloc(sizeof(struct audqcelp_event), GFP_ATOMIC);
-		if (!e_node) {
-			MM_ERR("No mem to post event %d\n", type);
-			spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-			return;
-		}
-	}
-
-	e_node->event_type = type;
-	e_node->payload = payload;
-
-	list_add_tail(&e_node->list, &audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	wake_up(&audio->event_wait);
-}
-
-static void audqcelp_suspend(struct early_suspend *h)
-{
-	struct audqcelp_suspend_ctl *ctl =
-		container_of(h, struct audqcelp_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audqcelp_post_event(ctl->audio, AUDIO_EVENT_SUSPEND, payload);
-}
-
-static void audqcelp_resume(struct early_suspend *h)
-{
-	struct audqcelp_suspend_ctl *ctl =
-		container_of(h, struct audqcelp_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audqcelp_post_event(ctl->audio, AUDIO_EVENT_RESUME, payload);
-}
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-static ssize_t audqcelp_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static ssize_t audqcelp_debug_read(struct file *file, char __user *buf,
-					size_t count, loff_t *ppos)
-{
-	const int debug_bufmax = 1024;
-	static char buffer[1024];
-	int n = 0, i;
-	struct audio *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	n = scnprintf(buffer, debug_bufmax, "opened %d\n", audio->opened);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"enabled %d\n", audio->enabled);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"stopped %d\n", audio->stopped);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_feedback %d\n", audio->pcm_feedback);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_buf_sz %d\n", audio->out[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_buf_count %d \n", audio->pcm_buf_count);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_buf_sz %d \n", audio->in[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"volume %x \n", audio->vol_pan.volume);
-	mutex_unlock(&audio->lock);
-	/* Following variables are only useful for debugging when
-	 * when playback halts unexpectedly. Thus, no mutual exclusion
-	 * enforced
-	 */
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"wflush %d\n", audio->wflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"rflush %d\n", audio->rflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"running %d \n", audio->running);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"dec state %d \n", audio->dec_state);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_needed %d \n", audio->out_needed);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_head %d \n", audio->out_head);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_tail %d \n", audio->out_tail);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out[0].used %d \n", audio->out[0].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out[1].used %d \n", audio->out[1].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"buffer_refresh %d \n", audio->buf_refresh);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"read_next %d \n", audio->read_next);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"fill_next %d \n", audio->fill_next);
-	for (i = 0; i < audio->pcm_buf_count; i++)
-		n += scnprintf(buffer + n, debug_bufmax - n,
-				"in[%d].size %d \n", i, audio->in[i].used);
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations audqcelp_debug_fops = {
-	.read = audqcelp_debug_read,
-	.open = audqcelp_debug_open,
-};
-#endif
-
-static int audqcelp_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = NULL;
-	int rc, dec_attrb, decid, i;
-	struct audqcelp_event *e_node = NULL;
-	unsigned mem_sz = DMASZ;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	struct ion_client *client = NULL;
-	int len = 0;
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_qcelp_" + 5];
-#endif
-
-	/* Create audio instance, set to zero */
-	audio = kzalloc(sizeof(struct audio), GFP_KERNEL);
-	if (!audio) {
-		MM_ERR("no memory to allocate audio instance\n");
-		rc = -ENOMEM;
-		goto done;
-	}
-	MM_INFO("audio instance 0x%08x created\n", (int)audio);
-
-	/* Allocate the decoder */
-	dec_attrb = AUDDEC_DEC_QCELP;
-	if ((file->f_mode & FMODE_WRITE) &&
-			(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_NONTUNNEL;
-		audio->pcm_feedback = NON_TUNNEL_MODE_PLAYBACK;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_TUNNEL;
-		audio->pcm_feedback = TUNNEL_MODE_PLAYBACK;
-	} else {
-		kfree(audio);
-		rc = -EACCES;
-		goto done;
-	}
-	decid = audpp_adec_alloc(dec_attrb, &audio->module_name,
-			&audio->queue_id);
-	if (decid < 0) {
-		MM_ERR("No free decoder available, freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENODEV;
-		kfree(audio);
-		goto done;
-	}
-	audio->dec_id = decid & MSM_AUD_DECODER_MASK;
-
-	client = msm_ion_client_create(UINT_MAX, "Audio_QCELP_Client");
-	if (IS_ERR_OR_NULL(client)) {
-		pr_err("Unable to create ION client\n");
-		rc = -ENOMEM;
-		goto client_create_error;
-	}
-	audio->client = client;
-
-	handle = ion_alloc(client, mem_sz, SZ_4K,
-		ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-	if (IS_ERR_OR_NULL(handle)) {
-		MM_ERR("Unable to create allocate O/P buffers\n");
-		rc = -ENOMEM;
-		goto output_buff_alloc_error;
-	}
-	audio->output_buff_handle = handle;
-
-	rc = ion_phys(client, handle, &addr, &len);
-	if (rc) {
-		MM_ERR("O/P buffers:Invalid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-		goto output_buff_get_phys_error;
-	} else {
-		MM_INFO("O/P buffers:valid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-	}
-	audio->phys = (int32_t)addr;
-
-
-	rc = ion_handle_get_flags(client, handle, &ionflag);
-	if (rc) {
-		MM_ERR("could not get flags for the handle\n");
-		goto output_buff_get_flags_error;
-	}
-
-	audio->map_v_write = ion_map_kernel(client, handle);
-	if (IS_ERR(audio->map_v_write)) {
-		MM_ERR("could not map write buffers\n");
-		rc = -ENOMEM;
-		goto output_buff_map_error;
-	}
-	audio->data = audio->map_v_write;
-	MM_DBG("write buf: phy addr 0x%08x kernel addr 0x%08x\n",
-		audio->phys, (int)audio->data);
-
-	if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK) {
-		rc = audmgr_open(&audio->audmgr);
-		if (rc) {
-			MM_ERR("audmgr open failed, freeing instance \
-					0x%08x\n", (int)audio);
-			goto err;
-		}
-	}
-
-	rc = msm_adsp_get(audio->module_name, &audio->audplay,
-		&audplay_adsp_ops_qcelp, audio);
-	if (rc) {
-		MM_ERR("failed to get %s module, freeing instance 0x%08x\n",
-				audio->module_name, (int)audio);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_close(&audio->audmgr);
-		goto err;
-	}
-
-	rc = rmt_get_resource(audio);
-	if (rc) {
-		MM_ERR("ADSP resources are not available for QCELP session \
-			 0x%08x on decoder: %d\n", (int)audio, audio->dec_id);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_close(&audio->audmgr);
-		msm_adsp_put(audio->audplay);
-		goto err;
-	}
-
-	audio->input_buff_handle = NULL;
-
-	/* Initialize all locks of audio instance */
-	mutex_init(&audio->lock);
-	mutex_init(&audio->write_lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->get_event_lock);
-	spin_lock_init(&audio->dsp_lock);
-	init_waitqueue_head(&audio->write_wait);
-	init_waitqueue_head(&audio->read_wait);
-	INIT_LIST_HEAD(&audio->free_event_queue);
-	INIT_LIST_HEAD(&audio->event_queue);
-	init_waitqueue_head(&audio->wait);
-	init_waitqueue_head(&audio->event_wait);
-	spin_lock_init(&audio->event_queue_lock);
-
-	/* Initialize buffer */
-	audio->out[0].data = audio->data + 0;
-	audio->out[0].addr = audio->phys + 0;
-	audio->out[0].size = BUFSZ;
-
-	audio->out[1].data = audio->data + BUFSZ;
-	audio->out[1].addr = audio->phys + BUFSZ;
-	audio->out[1].size = BUFSZ;
-
-	audio->vol_pan.volume = 0x2000;
-
-	audqcelp_flush(audio);
-
-	file->private_data = audio;
-	audio->opened = 1;
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof name, "msm_qcelp_%04x", audio->dec_id);
-	audio->dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
-			NULL, (void *) audio, &audqcelp_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		MM_DBG("debugfs_create_file failed\n");
-#endif
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	audio->suspend_ctl.node.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
-	audio->suspend_ctl.node.resume = audqcelp_resume;
-	audio->suspend_ctl.node.suspend = audqcelp_suspend;
-	audio->suspend_ctl.audio = audio;
-	register_early_suspend(&audio->suspend_ctl.node);
-#endif
-	for (i = 0; i < AUDQCELP_EVENT_NUM; i++) {
-		e_node = kmalloc(sizeof(struct audqcelp_event), GFP_KERNEL);
-		if (e_node)
-			list_add_tail(&e_node->list, &audio->free_event_queue);
-		else {
-			MM_ERR("event pkt alloc failed\n");
-			break;
-		}
-	}
-done:
-	return rc;
-err:
-	ion_unmap_kernel(client, audio->output_buff_handle);
-output_buff_map_error:
-output_buff_get_phys_error:
-output_buff_get_flags_error:
-	ion_free(client, audio->output_buff_handle);
-output_buff_alloc_error:
-	ion_client_destroy(client);
-client_create_error:
-	audpp_adec_free(audio->dec_id);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_qcelp_fops = {
-	.owner = THIS_MODULE,
-	.open = audqcelp_open,
-	.release = audqcelp_release,
-	.read = audqcelp_read,
-	.write = audqcelp_write,
-	.unlocked_ioctl = audqcelp_ioctl,
-	.fsync = audqcelp_fsync,
-};
-
-struct miscdevice audio_qcelp_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_qcelp",
-	.fops = &audio_qcelp_fops,
-};
-
-static int __init audqcelp_init(void)
-{
-	return misc_register(&audio_qcelp_misc);
-}
-
-static void __exit audqcelp_exit(void)
-{
-	misc_deregister(&audio_qcelp_misc);
-}
-
-module_init(audqcelp_init);
-module_exit(audqcelp_exit);
-
-MODULE_DESCRIPTION("MSM QCELP 13K driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5/audio_qcelp_in.c b/arch/arm/mach-msm/qdsp5/audio_qcelp_in.c
deleted file mode 100644
index cfda4b9..0000000
--- a/arch/arm/mach-msm/qdsp5/audio_qcelp_in.c
+++ /dev/null
@@ -1,1468 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/audio_qcelp_in.c
- *
- * qcelp audio input device
- *
- * Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
- *
- * This code is based in part on arch/arm/mach-msm/qdsp5v2/audio_qcelp_in.c,
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-
-#include <linux/delay.h>
-
-#include <linux/msm_audio_qcp.h>
-
-
-#include <linux/memory_alloc.h>
-#include <linux/msm_ion.h>
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-
-#include <mach/msm_memtypes.h>
-#include <mach/msm_adsp.h>
-#include <mach/msm_rpcrouter.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include "audmgr.h"
-
-#include <mach/qdsp5/qdsp5audpreproc.h>
-#include <mach/qdsp5/qdsp5audpreproccmdi.h>
-#include <mach/qdsp5/qdsp5audpreprocmsg.h>
-#include <mach/qdsp5/qdsp5audreccmdi.h>
-#include <mach/qdsp5/qdsp5audrecmsg.h>
-#include <mach/debug_mm.h>
-
-#define FRAME_HEADER_SIZE	8 /* 8 bytes frame header */
-#define NT_FRAME_HEADER_SIZE	24 /* 24 bytes frame header */
-/* FRAME_NUM must be a power of two */
-#define FRAME_NUM	8
-#define QCELP_FRAME_SIZE	36 /* 36 bytes data */
-/*Tunnel mode : 36 bytes data + 8 byte header*/
-#define FRAME_SIZE	(QCELP_FRAME_SIZE + FRAME_HEADER_SIZE)
- /* 36 bytes data  + 24 meta field*/
-#define NT_FRAME_SIZE	(QCELP_FRAME_SIZE + NT_FRAME_HEADER_SIZE)
-#define DMASZ		(FRAME_SIZE * FRAME_NUM)
-#define NT_DMASZ	(NT_FRAME_SIZE * FRAME_NUM)
-#define OUT_FRAME_NUM	2
-#define OUT_BUFFER_SIZE (4 * 1024 + NT_FRAME_HEADER_SIZE)
-#define BUFFER_SIZE	(OUT_BUFFER_SIZE * OUT_FRAME_NUM)
-
-/* Offset from beginning of buffer*/
-#define AUDPREPROC_QCELP_EOS_FLG_OFFSET 0x0A
-#define AUDPREPROC_QCELP_EOS_FLG_MASK 0x01
-#define AUDPREPROC_QCELP_EOS_NONE 0x0 /* No EOS detected */
-#define AUDPREPROC_QCELP_EOS_SET 0x1 /* EOS set in meta field */
-
-struct buffer {
-	void *data;
-	uint32_t size;
-	uint32_t read;
-	uint32_t addr;
-	uint32_t used;
-	uint32_t mfield_sz;
-};
-
-struct audio_qcelp_in {
-	struct buffer in[FRAME_NUM];
-
-	spinlock_t dsp_lock;
-
-	atomic_t in_bytes;
-	atomic_t in_samples;
-
-	struct mutex lock;
-	struct mutex read_lock;
-	wait_queue_head_t wait;
-	wait_queue_head_t wait_enable;
-	/*write section*/
-	struct buffer out[OUT_FRAME_NUM];
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed;	/* number of buffers the dsp is waiting for */
-	uint32_t out_count;
-
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-	int32_t out_phys; /* physical address of write buffer */
-	char *out_data;
-	int mfield; /* meta field embedded in data */
-	int wflush; /*write flush */
-	int rflush; /*read flush*/
-	int out_frame_cnt;
-
-	struct msm_adsp_module *audrec;
-
-
-	/* configuration to use on next enable */
-	uint32_t samp_rate;
-	uint32_t channel_mode;
-	uint32_t buffer_size; /* Frame size (36 bytes) */
-	uint32_t enc_type; /* 11 for QCELP */
-	uint32_t mode; /* T or NT Mode*/
-
-	struct msm_audio_qcelp_enc_config cfg;
-
-	uint32_t dsp_cnt;
-	uint32_t in_head; /* next buffer dsp will write */
-	uint32_t in_tail; /* next buffer read() will read */
-	uint32_t in_count; /* number of buffers available to read() */
-
-	uint32_t eos_ack;
-	uint32_t flush_ack;
-
-	const char *module_name;
-	unsigned queue_ids;
-	uint16_t enc_id; /* Session Id */
-
-	unsigned short samp_rate_index;
-	uint32_t audrec_obj_idx ;
-
-	struct audmgr audmgr;
-
-	/* data allocated for various buffers */
-	char *data;
-	dma_addr_t phys;
-
-	void *map_v_read;
-	void *map_v_write;
-
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped, cleared on flush */
-	struct ion_client *client;
-	struct ion_handle *input_buff_handle;
-	struct ion_handle *output_buff_handle;
-
-	struct audrec_session_info session_info; /*audrec session info*/
-};
-
-struct audio_frame {
-	uint16_t frame_count_lsw;
-	uint16_t frame_count_msw;
-	uint16_t frame_length;
-	uint16_t erased_pcm;
-	unsigned char raw_bitstream[];
-} __packed;
-
-struct audio_frame_nt {
-	uint16_t metadata_len;
-	uint16_t frame_count_lsw;
-	uint16_t frame_count_msw;
-	uint16_t frame_length;
-	uint16_t erased_pcm;
-	uint16_t reserved;
-	uint16_t time_stamp_dword_lsw;
-	uint16_t time_stamp_dword_msw;
-	uint16_t time_stamp_lsw;
-	uint16_t time_stamp_msw;
-	uint16_t nflag_lsw;
-	uint16_t nflag_msw;
-	unsigned char raw_bitstream[]; /* samples */
-} __packed;
-
-struct qcelp_encoded_meta_out {
-	uint16_t metadata_len;
-	uint16_t time_stamp_dword_lsw;
-	uint16_t time_stamp_dword_msw;
-	uint16_t time_stamp_lsw;
-	uint16_t time_stamp_msw;
-	uint16_t nflag_lsw;
-	uint16_t nflag_msw;
-};
-
-/* Audrec Queue command sent macro's */
-#define audio_send_queue_pre(audio, cmd, len) \
-	msm_adsp_write(audio->audpre, QDSP_uPAudPreProcCmdQueue, cmd, len)
-
-#define audio_send_queue_recbs(audio, cmd, len) \
-	msm_adsp_write(audio->audrec, ((audio->queue_ids & 0xFFFF0000) >> 16),\
-			cmd, len)
-#define audio_send_queue_rec(audio, cmd, len) \
-	msm_adsp_write(audio->audrec, (audio->queue_ids & 0x0000FFFF),\
-			cmd, len)
-
-static int audqcelp_in_dsp_enable(struct audio_qcelp_in *audio, int enable);
-static int audqcelp_in_encparam_config(struct audio_qcelp_in *audio);
-static int audqcelp_in_encmem_config(struct audio_qcelp_in *audio);
-static int audqcelp_in_dsp_read_buffer(struct audio_qcelp_in *audio,
-				uint32_t read_cnt);
-static void audqcelp_in_flush(struct audio_qcelp_in *audio);
-
-static void audqcelp_in_get_dsp_frames(struct audio_qcelp_in *audio);
-static int audpcm_config(struct audio_qcelp_in *audio);
-static void audqcelp_out_flush(struct audio_qcelp_in *audio);
-static int audqcelp_in_routing_mode_config(struct audio_qcelp_in *audio);
-static void audrec_pcm_send_data(struct audio_qcelp_in *audio, unsigned needed);
-static void audqcelp_nt_in_get_dsp_frames(struct audio_qcelp_in *audio);
-static void audqcelp_in_flush(struct audio_qcelp_in *audio);
-
-static unsigned convert_samp_index(unsigned index)
-{
-	switch (index) {
-	case RPC_AUD_DEF_SAMPLE_RATE_48000:	return 48000;
-	case RPC_AUD_DEF_SAMPLE_RATE_44100:	return 44100;
-	case RPC_AUD_DEF_SAMPLE_RATE_32000:	return 32000;
-	case RPC_AUD_DEF_SAMPLE_RATE_24000:	return 24000;
-	case RPC_AUD_DEF_SAMPLE_RATE_22050:	return 22050;
-	case RPC_AUD_DEF_SAMPLE_RATE_16000:	return 16000;
-	case RPC_AUD_DEF_SAMPLE_RATE_12000:	return 12000;
-	case RPC_AUD_DEF_SAMPLE_RATE_11025:	return 11025;
-	case RPC_AUD_DEF_SAMPLE_RATE_8000:	return 8000;
-	default:				return 11025;
-	}
-}
-
-/* ------------------- dsp --------------------- */
-static void audpre_dsp_event(void *data, unsigned id,  void *event_data)
-{
-
-	uint16_t *msg = event_data;
-
-	if (!msg)
-		return;
-
-	switch (id) {
-	case AUDPREPROC_MSG_CMD_CFG_DONE_MSG:
-		MM_DBG("type %d, status_flag %d\n",\
-			msg[0], msg[1]);
-		break;
-	case AUDPREPROC_MSG_ERROR_MSG_ID:
-		MM_INFO("err_index %d\n", msg[0]);
-		break;
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audpreproctask)\n");
-		break;
-	default:
-		MM_ERR("unknown event %d\n", id);
-	}
-}
-
-
-/* must be called with audio->lock held */
-static int audqcelp_in_enable(struct audio_qcelp_in *audio)
-{
-	struct audmgr_config cfg;
-	int rc;
-
-	if (audio->enabled)
-		return 0;
-
-	cfg.tx_rate = audio->samp_rate;
-	cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE;
-	cfg.def_method = RPC_AUD_DEF_METHOD_RECORD;
-	cfg.codec = RPC_AUD_DEF_CODEC_13K;
-	cfg.snd_method = RPC_SND_METHOD_MIDI;
-
-	if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-		rc = audmgr_enable(&audio->audmgr, &cfg);
-		if (rc < 0)
-			return rc;
-
-		if (audpreproc_enable(audio->enc_id,
-				&audpre_dsp_event, audio)) {
-			MM_ERR("msm_adsp_enable(audpreproc) failed\n");
-			audmgr_disable(&audio->audmgr);
-			return -ENODEV;
-		}
-
-		/*update aurec session info in audpreproc layer*/
-		audio->session_info.session_id = audio->enc_id;
-		audio->session_info.sampling_freq =
-			convert_samp_index(audio->samp_rate);
-		audpreproc_update_audrec_info(&audio->session_info);
-	}
-	if (msm_adsp_enable(audio->audrec)) {
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			audpreproc_disable(audio->enc_id, audio);
-			audmgr_disable(&audio->audmgr);
-		}
-		MM_ERR("msm_adsp_enable(audrec) failed\n");
-		return -ENODEV;
-	}
-
-	audio->enabled = 1;
-	audqcelp_in_dsp_enable(audio, 1);
-
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audqcelp_in_disable(struct audio_qcelp_in *audio)
-{
-	if (audio->enabled) {
-		audio->enabled = 0;
-
-		audqcelp_in_dsp_enable(audio, 0);
-
-		wait_event_interruptible_timeout(audio->wait_enable,
-				audio->running == 0, 1*HZ);
-		audio->stopped = 1;
-		wake_up(&audio->wait);
-		msm_adsp_disable(audio->audrec);
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			audpreproc_disable(audio->enc_id, audio);
-			audmgr_disable(&audio->audmgr);
-			/*reset the sampling frequency information at
-			  audpreproc layer*/
-			audio->session_info.sampling_freq = 0;
-			audpreproc_update_audrec_info(&audio->session_info);
-		}
-	}
-	return 0;
-}
-
-static void audqcelp_in_get_dsp_frames(struct audio_qcelp_in *audio)
-{
-	struct audio_frame *frame;
-	uint32_t index;
-	unsigned long flags;
-
-	index = audio->in_head;
-
-	frame = (void *) (((char *)audio->in[index].data) -
-			sizeof(*frame));
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->in[index].size = frame->frame_length;
-
-	/* statistics of read */
-	atomic_add(audio->in[index].size, &audio->in_bytes);
-	atomic_add(1, &audio->in_samples);
-
-	audio->in_head = (audio->in_head + 1) & (FRAME_NUM - 1);
-
-	/* If overflow, move the tail index foward. */
-	if (audio->in_head == audio->in_tail) {
-		MM_ERR("Error! not able to keep up the read\n");
-		audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
-		MM_ERR("in_count = %d\n", audio->in_count);
-	} else
-		audio->in_count++;
-
-	audqcelp_in_dsp_read_buffer(audio, audio->dsp_cnt++);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-
-	wake_up(&audio->wait);
-}
-
-static void audqcelp_nt_in_get_dsp_frames(struct audio_qcelp_in *audio)
-{
-	struct audio_frame_nt *nt_frame;
-	uint32_t index;
-	unsigned long flags;
-
-	index = audio->in_head;
-	nt_frame = (void *) (((char *)audio->in[index].data) - \
-				sizeof(struct audio_frame_nt));
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->in[index].size = nt_frame->frame_length;
-	/* statistics of read */
-	atomic_add(audio->in[index].size, &audio->in_bytes);
-	atomic_add(1, &audio->in_samples);
-
-	audio->in_head = (audio->in_head + 1) & (FRAME_NUM - 1);
-
-	/* If overflow, move the tail index foward. */
-	if (audio->in_head == audio->in_tail)
-		MM_DBG("Error! not able to keep up the read\n");
-	else
-		audio->in_count++;
-
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	wake_up(&audio->wait);
-}
-
-static int audrec_pcm_buffer_ptr_refresh(struct audio_qcelp_in *audio,
-				       unsigned idx, unsigned len)
-{
-	struct audrec_cmd_pcm_buffer_ptr_refresh_arm_enc cmd;
-
-	if (len ==  NT_FRAME_HEADER_SIZE)
-		len = len / 2;
-	else
-		len = (len + NT_FRAME_HEADER_SIZE) / 2;
-	MM_DBG("len = %d\n", len);
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_PCM_BUFFER_PTR_REFRESH_ARM_TO_ENC;
-	cmd.num_buffers = 1;
-	if (cmd.num_buffers == 1) {
-		cmd.buf_address_length[0] = (audio->out[idx].addr &
-							0xffff0000) >> 16;
-		cmd.buf_address_length[1] = (audio->out[idx].addr &
-							0x0000ffff);
-		cmd.buf_address_length[2] = (len & 0xffff0000) >> 16;
-		cmd.buf_address_length[3] = (len & 0x0000ffff);
-	}
-	audio->out_frame_cnt++;
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audpcm_config(struct audio_qcelp_in *audio)
-{
-	struct audrec_cmd_pcm_cfg_arm_to_enc cmd;
-	MM_DBG("\n");
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_PCM_CFG_ARM_TO_ENC;
-	cmd.config_update_flag = AUDREC_PCM_CONFIG_UPDATE_FLAG_ENABLE;
-	cmd.enable_flag = AUDREC_ENABLE_FLAG_VALUE;
-	cmd.sampling_freq = convert_samp_index(audio->samp_rate);
-	if (!audio->channel_mode)
-		cmd.channels = 1;
-	else
-		cmd.channels = 2;
-	cmd.frequency_of_intimation = 1;
-	cmd.max_number_of_buffers = OUT_FRAME_NUM;
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-
-static int audqcelp_in_routing_mode_config(struct audio_qcelp_in *audio)
-{
-	struct audrec_cmd_routing_mode cmd;
-
-	MM_DBG("\n");
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_ROUTING_MODE;
-	if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL)
-		cmd.routing_mode = 1;
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static void audrec_dsp_event(void *data, unsigned id, size_t len,
-			    void (*getevent)(void *ptr, size_t len))
-{
-	struct audio_qcelp_in *audio = NULL;
-
-	if (data)
-		audio = data;
-	else {
-		MM_ERR("invalid data for event %x\n", id);
-		return;
-	}
-
-	switch (id) {
-	case AUDREC_MSG_CMD_CFG_DONE_MSG: {
-		struct audrec_msg_cmd_cfg_done_msg cmd_cfg_done_msg;
-		getevent(&cmd_cfg_done_msg, AUDREC_MSG_CMD_CFG_DONE_MSG_LEN);
-		if (cmd_cfg_done_msg.audrec_enc_type & \
-				AUDREC_MSG_CFG_DONE_ENC_ENA) {
-			audio->audrec_obj_idx = cmd_cfg_done_msg.audrec_obj_idx;
-			MM_DBG("CFG ENABLED\n");
-			if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) {
-				MM_DBG("routing command\n");
-				audqcelp_in_routing_mode_config(audio);
-			} else {
-				audqcelp_in_encmem_config(audio);
-			}
-		} else {
-			MM_DBG("CFG SLEEP\n");
-			audio->running = 0;
-			wake_up(&audio->wait_enable);
-		}
-		break;
-	}
-	case AUDREC_MSG_CMD_ROUTING_MODE_DONE_MSG: {
-		struct audrec_msg_cmd_routing_mode_done_msg \
-			routing_msg;
-		getevent(&routing_msg, AUDREC_MSG_CMD_ROUTING_MODE_DONE_MSG);
-		MM_DBG("AUDREC_MSG_CMD_ROUTING_MODE_DONE_MSG");
-		if (routing_msg.configuration == 0) {
-			MM_ERR("routing configuration failed\n");
-			audio->running = 0;
-			wake_up(&audio->wait_enable);
-		} else
-			audqcelp_in_encmem_config(audio);
-		break;
-	}
-	case AUDREC_MSG_CMD_AREC_MEM_CFG_DONE_MSG: {
-		MM_DBG("AREC_MEM_CFG_DONE_MSG\n");
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)
-			audqcelp_in_encparam_config(audio);
-		else
-			audpcm_config(audio);
-		break;
-	}
-	case AUDREC_CMD_PCM_CFG_ARM_TO_ENC_DONE_MSG: {
-		MM_DBG("AUDREC_CMD_PCM_CFG_ARM_TO_ENC_DONE_MSG");
-		audqcelp_in_encparam_config(audio);
-	    break;
-	}
-	case AUDREC_MSG_CMD_AREC_PARAM_CFG_DONE_MSG: {
-		MM_DBG("AUDREC_MSG_CMD_AREC_PARAM_CFG_DONE_MSG\n");
-		audio->running = 1;
-		wake_up(&audio->wait_enable);
-		if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL)
-			audrec_pcm_send_data(audio, 1);
-		break;
-	}
-	case AUDREC_CMD_PCM_BUFFER_PTR_UPDATE_ARM_TO_ENC_MSG: {
-		MM_DBG("ptr_update recieved from DSP\n");
-		audrec_pcm_send_data(audio, 1);
-		break;
-	}
-	case AUDREC_MSG_NO_EXT_PKT_AVAILABLE_MSG: {
-		struct audrec_msg_no_ext_pkt_avail_msg err_msg;
-		getevent(&err_msg, AUDREC_MSG_NO_EXT_PKT_AVAILABLE_MSG_LEN);
-		MM_DBG("NO_EXT_PKT_AVAILABLE_MSG %x\n",\
-			err_msg.audrec_err_id);
-		break;
-	}
-	case AUDREC_MSG_PACKET_READY_MSG: {
-		struct audrec_msg_packet_ready_msg pkt_ready_msg;
-
-		getevent(&pkt_ready_msg, AUDREC_MSG_PACKET_READY_MSG_LEN);
-		MM_DBG("UP_PACKET_READY_MSG: write cnt msw  %d \
-		write cnt lsw %d read cnt msw %d  read cnt lsw %d \n",\
-		pkt_ready_msg.pkt_counter_msw, \
-		pkt_ready_msg.pkt_counter_lsw, \
-		pkt_ready_msg.pkt_read_cnt_msw, \
-		pkt_ready_msg.pkt_read_cnt_lsw);
-
-		audqcelp_in_get_dsp_frames(audio);
-		break;
-	}
-	case AUDREC_UP_NT_PACKET_READY_MSG: {
-		struct audrec_up_nt_packet_ready_msg pkt_ready_msg;
-
-		getevent(&pkt_ready_msg, AUDREC_UP_NT_PACKET_READY_MSG_LEN);
-		MM_DBG("UP_NT_PACKET_READY_MSG: write cnt lsw  %d \
-		write cnt msw %d read cnt lsw %d  read cnt msw %d \n",\
-		pkt_ready_msg.audrec_packetwrite_cnt_lsw, \
-		pkt_ready_msg.audrec_packetwrite_cnt_msw, \
-		pkt_ready_msg.audrec_upprev_readcount_lsw, \
-		pkt_ready_msg.audrec_upprev_readcount_msw);
-
-		audqcelp_nt_in_get_dsp_frames(audio);
-		break;
-	}
-	case AUDREC_CMD_FLUSH_DONE_MSG: {
-		audio->wflush = 0;
-		audio->rflush = 0;
-		audio->flush_ack = 1;
-		wake_up(&audio->write_wait);
-		MM_DBG("flush ack recieved\n");
-		break;
-	}
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module \
-				enable/disable(audrectask)\n");
-		break;
-	default:
-		MM_ERR("unknown event %d\n", id);
-	}
-}
-
-static struct msm_adsp_ops audrec_qcelp_adsp_ops = {
-	.event = audrec_dsp_event,
-};
-
-static int audqcelp_in_dsp_enable(struct audio_qcelp_in *audio, int enable)
-{
-	struct audrec_cmd_enc_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_ENC_CFG;
-	cmd.audrec_enc_type = (audio->enc_type & 0xFF) |
-			(enable ? AUDREC_CMD_ENC_ENA : AUDREC_CMD_ENC_DIS);
-	/* Don't care */
-	cmd.audrec_obj_idx = audio->audrec_obj_idx;
-
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audqcelp_in_encmem_config(struct audio_qcelp_in *audio)
-{
-	struct audrec_cmd_arecmem_cfg cmd;
-	uint16_t *data = (void *) audio->data;
-	int n;
-	int header_len = 0;
-
-	memset(&cmd, 0, sizeof(cmd));
-
-	cmd.cmd_id = AUDREC_CMD_ARECMEM_CFG;
-	cmd.audrec_obj_idx = audio->audrec_obj_idx;
-	/* Rate at which packet complete message comes */
-	cmd.audrec_up_pkt_intm_cnt = 1;
-	cmd.audrec_extpkt_buffer_msw = audio->phys >> 16;
-	cmd.audrec_extpkt_buffer_lsw = audio->phys;
-	/* Max Buffer no available for frames */
-	cmd.audrec_extpkt_buffer_num = FRAME_NUM;
-
-	/* prepare buffer pointers:
-	 * T:36 bytes qcelp packet + 4 halfword header
-	 * NT:36 bytes qcelp packet + 12 halfword header
-	 */
-	if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)
-		header_len = FRAME_HEADER_SIZE/2;
-	else
-		header_len = NT_FRAME_HEADER_SIZE/2;
-
-	for (n = 0; n < FRAME_NUM; n++) {
-		audio->in[n].data = data + header_len;
-		data += (QCELP_FRAME_SIZE/2) + header_len;
-		MM_DBG("0x%8x\n", (int)(audio->in[n].data - header_len*2));
-	}
-
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audqcelp_in_encparam_config(struct audio_qcelp_in *audio)
-{
-	struct audrec_cmd_arecparam_qcelp_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDREC_CMD_ARECPARAM_CFG;
-	cmd.common.audrec_obj_idx = audio->audrec_obj_idx;
-	cmd.enc_min_rate = audio->cfg.min_bit_rate;
-	cmd.enc_max_rate = audio->cfg.max_bit_rate;
-	cmd.rate_modulation_cmd = 0;  /* Default set to 0 */
-	cmd.reduced_rate_level = 0;  /* Default set to 0 */
-
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audqcelp_flush_command(struct audio_qcelp_in *audio)
-{
-	struct audrec_cmd_flush cmd;
-	MM_DBG("\n");
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_FLUSH;
-	return audio_send_queue_rec(audio, &cmd, sizeof(cmd));
-}
-
-static int audqcelp_in_dsp_read_buffer(struct audio_qcelp_in *audio,
-		uint32_t read_cnt)
-{
-	audrec_cmd_packet_ext_ptr cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_PACKET_EXT_PTR;
-	cmd.type = audio->audrec_obj_idx;
-	cmd.curr_rec_count_msw = read_cnt >> 16;
-	cmd.curr_rec_count_lsw = read_cnt;
-
-	return audio_send_queue_recbs(audio, &cmd, sizeof(cmd));
-}
-
-/* ------------------- device --------------------- */
-
-static void audqcelp_ioport_reset(struct audio_qcelp_in *audio)
-{
-	/* Make sure read/write thread are free from
-	 * sleep and knowing that system is not able
-	 * to process io request at the moment
-	 */
-	wake_up(&audio->wait);
-	mutex_lock(&audio->read_lock);
-	audqcelp_in_flush(audio);
-	mutex_unlock(&audio->read_lock);
-	wake_up(&audio->write_wait);
-	mutex_lock(&audio->write_lock);
-	audqcelp_out_flush(audio);
-	mutex_unlock(&audio->write_lock);
-}
-
-static void audqcelp_in_flush(struct audio_qcelp_in *audio)
-{
-	int i;
-	unsigned long flags;
-
-	audio->eos_ack = 0;
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->dsp_cnt = 0;
-	audio->in_head = 0;
-	audio->in_tail = 0;
-	audio->in_count = 0;
-	for (i = FRAME_NUM-1; i >= 0; i--) {
-		audio->in[i].size = 0;
-		audio->in[i].read = 0;
-	}
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	MM_DBG("in_bytes %d\n", atomic_read(&audio->in_bytes));
-	MM_DBG("in_samples %d\n", atomic_read(&audio->in_samples));
-	atomic_set(&audio->in_bytes, 0);
-	atomic_set(&audio->in_samples, 0);
-}
-
-static void audqcelp_out_flush(struct audio_qcelp_in *audio)
-{
-	int i;
-	unsigned long flags;
-
-	audio->out_head = 0;
-	audio->out_count = 0;
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->out_tail = 0;
-	for (i = OUT_FRAME_NUM-1; i >= 0; i--) {
-		audio->out[i].size = 0;
-		audio->out[i].read = 0;
-		audio->out[i].used = 0;
-	}
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-static long audqcelp_in_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct audio_qcelp_in *audio = file->private_data;
-	int rc = 0;
-
-	MM_DBG("\n");
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		memset(&stats, 0, sizeof(stats));
-		stats.byte_count = atomic_read(&audio->in_bytes);
-		stats.sample_count = atomic_read(&audio->in_samples);
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return rc;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START: {
-		rc = audqcelp_in_enable(audio);
-		if (!rc) {
-			rc =
-			wait_event_interruptible_timeout(audio->wait_enable,
-				audio->running != 0, 1*HZ);
-			MM_DBG("state %d rc = %d\n", audio->running, rc);
-
-			if (audio->running == 0)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		audio->stopped = 0;
-		break;
-	}
-	case AUDIO_STOP: {
-		rc = audqcelp_in_disable(audio);
-		break;
-	}
-	case AUDIO_FLUSH: {
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audqcelp_ioport_reset(audio);
-		if (audio->running) {
-			audqcelp_flush_command(audio);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config cfg;
-		memset(&cfg, 0, sizeof(cfg));
-		cfg.buffer_size = OUT_BUFFER_SIZE;
-		cfg.buffer_count = OUT_FRAME_NUM;
-		cfg.sample_rate = convert_samp_index(audio->samp_rate);
-		cfg.channel_count = 1;
-		cfg.type = 0;
-		cfg.unused[0] = 0;
-		cfg.unused[1] = 0;
-		cfg.unused[2] = 0;
-		if (copy_to_user((void *) arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-	case AUDIO_GET_STREAM_CONFIG: {
-		struct msm_audio_stream_config cfg;
-		memset(&cfg, 0, sizeof(cfg));
-		cfg.buffer_size = audio->buffer_size;
-		cfg.buffer_count = FRAME_NUM;
-		if (copy_to_user((void *)arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-	case AUDIO_SET_STREAM_CONFIG: {
-		struct msm_audio_stream_config cfg;
-		if (copy_from_user(&cfg, (void *) arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		/* Allow only single frame */
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			if (cfg.buffer_size != (FRAME_SIZE - 8)) {
-				rc = -EINVAL;
-				break;
-			}
-		} else {
-			if (cfg.buffer_size != (QCELP_FRAME_SIZE + 14)) {
-				rc = -EINVAL;
-				break;
-			}
-		}
-		audio->buffer_size = cfg.buffer_size;
-		break;
-	}
-	case AUDIO_GET_QCELP_ENC_CONFIG: {
-		if (copy_to_user((void *) arg, &audio->cfg, sizeof(audio->cfg)))
-			rc = -EFAULT;
-		break;
-	}
-	case AUDIO_SET_QCELP_ENC_CONFIG: {
-		struct msm_audio_qcelp_enc_config cfg;
-		if (copy_from_user(&cfg, (void *) arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		MM_DBG("0X%8x, 0x%8x, 0x%8x\n", cfg.min_bit_rate,
-				cfg.max_bit_rate, cfg.cdma_rate);
-		if (cfg.min_bit_rate > CDMA_RATE_FULL || \
-				 cfg.min_bit_rate < CDMA_RATE_EIGHTH) {
-			MM_ERR("invalid min bitrate\n");
-			rc = -EFAULT;
-			break;
-		}
-		if (cfg.max_bit_rate > CDMA_RATE_FULL || \
-				cfg.max_bit_rate < CDMA_RATE_EIGHTH) {
-			MM_ERR("invalid max bitrate\n");
-			rc = -EFAULT;
-			break;
-		}
-		/* Recording Does not support Erase and Blank */
-		if (cfg.cdma_rate > CDMA_RATE_FULL ||
-			cfg.cdma_rate < CDMA_RATE_EIGHTH) {
-			MM_ERR("invalid qcelp cdma rate\n");
-			rc = -EFAULT;
-			break;
-		}
-		memcpy(&audio->cfg, &cfg, sizeof(cfg));
-		break;
-	}
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static ssize_t audqcelp_in_read(struct file *file,
-				char __user *buf,
-				size_t count, loff_t *pos)
-{
-	struct audio_qcelp_in *audio = file->private_data;
-	unsigned long flags;
-	const char __user *start = buf;
-	void *data;
-	uint32_t index;
-	uint32_t size;
-	int rc = 0;
-	struct qcelp_encoded_meta_out meta_field;
-	struct audio_frame_nt *nt_frame;
-	MM_DBG("count = %d\n", count);
-	mutex_lock(&audio->read_lock);
-	while (count > 0) {
-		rc = wait_event_interruptible(
-			audio->wait, (audio->in_count > 0) || audio->stopped ||
-			audio->rflush);
-		if (rc < 0)
-			break;
-
-		if (audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-		if (audio->stopped && !audio->in_count) {
-			MM_DBG("Driver in stop state, No more buffer to read");
-			rc = 0;/* End of File */
-			break;
-		}
-
-		index = audio->in_tail;
-		data = (uint8_t *) audio->in[index].data;
-		size = audio->in[index].size;
-
-		if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) {
-			nt_frame = (struct audio_frame_nt *)(data -
-					sizeof(struct audio_frame_nt));
-			memcpy((char *)&meta_field.time_stamp_dword_lsw,
-				(char *)&nt_frame->time_stamp_dword_lsw,
-				(sizeof(struct qcelp_encoded_meta_out) - \
-				sizeof(uint16_t)));
-			meta_field.metadata_len =
-					sizeof(struct qcelp_encoded_meta_out);
-			if (copy_to_user((char *)start, (char *)&meta_field,
-				sizeof(struct qcelp_encoded_meta_out))) {
-				rc = -EFAULT;
-				break;
-			}
-			if (nt_frame->nflag_lsw & 0x0001) {
-				MM_ERR("recieved EOS in read call\n");
-				audio->eos_ack = 1;
-			}
-			buf += sizeof(struct qcelp_encoded_meta_out);
-			count -= sizeof(struct qcelp_encoded_meta_out);
-		}
-		if (count >= size) {
-			/* order the reads on the buffer */
-			dma_coherent_post_ops();
-			if (copy_to_user(buf, data, size)) {
-				rc = -EFAULT;
-				break;
-			}
-			spin_lock_irqsave(&audio->dsp_lock, flags);
-			if (index != audio->in_tail) {
-				/* overrun -- data is
-				 * invalid and we need to retry */
-				spin_unlock_irqrestore(&audio->dsp_lock, flags);
-				continue;
-			}
-			audio->in[index].size = 0;
-			audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
-			audio->in_count--;
-			spin_unlock_irqrestore(&audio->dsp_lock, flags);
-			count -= size;
-			buf += size;
-			if ((audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL)) {
-				if (!audio->eos_ack) {
-					MM_DBG("sending read ptr command \
-							%d %d\n",
-							audio->dsp_cnt,
-							audio->in_tail);
-					audqcelp_in_dsp_read_buffer(audio,
-							audio->dsp_cnt++);
-				}
-			}
-		} else {
-			MM_ERR("short read\n");
-			break;
-		}
-		break;
-	}
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		return buf - start;
-
-	return rc;
-}
-
-static void audrec_pcm_send_data(struct audio_qcelp_in *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-	MM_DBG("\n");
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			MM_DBG("frame %d free\n", audio->out_tail);
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			audrec_pcm_buffer_ptr_refresh(audio,
-						 audio->out_tail,
-						    frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
- done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static int audqcelp_in_fsync(struct file *file, loff_t a, loff_t b,
-	int datasync)
-
-{
-	struct audio_qcelp_in *audio = file->private_data;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (!audio->running || (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)) {
-		rc = -EINVAL;
-		goto done_nolock;
-	}
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-			audio->wflush);
-	MM_DBG("waked on by some event audio->wflush = %d\n", audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-done:
-	mutex_unlock(&audio->write_lock);
-done_nolock:
-	return rc;
-
-}
-
-int audrec_qcelp_process_eos(struct audio_qcelp_in *audio,
-		const char __user *buf_start, unsigned short mfield_size)
-{
-	struct buffer *frame;
-	int rc = 0;
-
-	frame = audio->out + audio->out_head;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	MM_DBG("copying meta_out frame->used = %d\n", frame->used);
-	audrec_pcm_send_data(audio, 0);
-done:
-	return rc;
-}
-
-static ssize_t audqcelp_in_write(struct file *file,
-				const char __user *buf,
-				size_t count, loff_t *pos)
-{
-	struct audio_qcelp_in *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	char *cpy_ptr;
-	int rc = 0, eos_condition = AUDPREPROC_QCELP_EOS_NONE;
-	unsigned short mfield_size = 0;
-	int write_count = 0;
-	MM_DBG("cnt=%d\n", count);
-
-	if (count & 1)
-		return -EINVAL;
-
-	if (audio->mode != MSM_AUD_ENC_MODE_NONTUNNEL)
-		return -EINVAL;
-
-	mutex_lock(&audio->write_lock);
-	frame = audio->out + audio->out_head;
-	/* if supplied count is more than driver buffer size
-	 * then only copy driver buffer size
-	 */
-	if (count > frame->size)
-		count = frame->size;
-
-	write_count = count;
-	cpy_ptr = frame->data;
-	rc = wait_event_interruptible(audio->write_wait,
-				      (frame->used == 0)
-					|| (audio->stopped)
-					|| (audio->wflush));
-	if (rc < 0)
-		goto error;
-
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto error;
-	}
-	if (audio->mfield) {
-		if (buf == start) {
-			/* Processing beginning of user buffer */
-			if (__get_user(mfield_size,
-				(unsigned short __user *) buf)) {
-				rc = -EFAULT;
-				goto error;
-			} else if (mfield_size > count) {
-				rc = -EINVAL;
-				goto error;
-			}
-			MM_DBG("mf offset_val %x\n", mfield_size);
-			if (copy_from_user(cpy_ptr, buf, mfield_size)) {
-				rc = -EFAULT;
-				goto error;
-			}
-			/* Check if EOS flag is set and buffer has
-			 * contains just meta field
-			 */
-			if (cpy_ptr[AUDPREPROC_QCELP_EOS_FLG_OFFSET] &
-					AUDPREPROC_QCELP_EOS_FLG_MASK) {
-				eos_condition = AUDPREPROC_QCELP_EOS_SET;
-				MM_DBG("EOS SET\n");
-				if (mfield_size == count) {
-					buf += mfield_size;
-					eos_condition = 0;
-					goto exit;
-				} else
-				cpy_ptr[AUDPREPROC_QCELP_EOS_FLG_OFFSET] &=
-					~AUDPREPROC_QCELP_EOS_FLG_MASK;
-			}
-			cpy_ptr += mfield_size;
-			count -= mfield_size;
-			buf += mfield_size;
-		} else {
-			mfield_size = 0;
-			MM_DBG("continuous buffer\n");
-		}
-		frame->mfield_sz = mfield_size;
-	}
-	MM_DBG("copying the stream count = %d\n", count);
-	if (copy_from_user(cpy_ptr, buf, count)) {
-		rc = -EFAULT;
-		goto error;
-	}
-exit:
-	frame->used = count;
-	audio->out_head ^= 1;
-	if (!audio->flush_ack)
-		audrec_pcm_send_data(audio, 0);
-	else {
-		audrec_pcm_send_data(audio, 1);
-		audio->flush_ack = 0;
-	}
-	if (eos_condition == AUDPREPROC_QCELP_EOS_SET)
-		rc = audrec_qcelp_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	return write_count;
-error:
-	mutex_unlock(&audio->write_lock);
-	return rc;
-}
-
-static int audqcelp_in_release(struct inode *inode, struct file *file)
-{
-	struct audio_qcelp_in *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	audqcelp_in_disable(audio);
-	audqcelp_in_flush(audio);
-	msm_adsp_put(audio->audrec);
-
-	audpreproc_aenc_free(audio->enc_id);
-	audio->audrec = NULL;
-	audio->opened = 0;
-
-	if ((audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) && \
-	   (audio->out_data)) {
-		ion_unmap_kernel(audio->client, audio->input_buff_handle);
-		ion_free(audio->client, audio->input_buff_handle);
-		audio->out_data = NULL;
-	}
-
-	if (audio->data) {
-		ion_unmap_kernel(audio->client, audio->output_buff_handle);
-		ion_free(audio->client, audio->output_buff_handle);
-		audio->data = NULL;
-	}
-	ion_client_destroy(audio->client);
-	mutex_unlock(&audio->lock);
-	return 0;
-}
-
-static struct audio_qcelp_in the_audio_qcelp_in;
-
-static int audqcelp_in_open(struct inode *inode, struct file *file)
-{
-	struct audio_qcelp_in *audio = &the_audio_qcelp_in;
-	int rc;
-	int encid;
-	int dma_size = 0;
-	int len = 0;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	struct ion_client *client = NULL;
-
-	mutex_lock(&audio->lock);
-	if (audio->opened) {
-		rc = -EBUSY;
-		goto done;
-	}
-	if ((file->f_mode & FMODE_WRITE) &&
-		(file->f_mode & FMODE_READ)) {
-		audio->mode = MSM_AUD_ENC_MODE_NONTUNNEL;
-		dma_size = NT_DMASZ;
-		MM_DBG("Opened for non tunnel mode encoding\n");
-	} else if (!(file->f_mode & FMODE_WRITE) &&
-				(file->f_mode & FMODE_READ)) {
-		audio->mode = MSM_AUD_ENC_MODE_TUNNEL;
-		dma_size = DMASZ;
-		MM_DBG("Opened for tunnel mode encoding\n");
-	} else {
-		MM_ERR("Invalid mode\n");
-		rc = -EACCES;
-		goto done;
-	}
-
-	/* Settings will be re-config at AUDIO_SET_CONFIG,
-	 * but at least we need to have initial config
-	 */
-	audio->samp_rate = RPC_AUD_DEF_SAMPLE_RATE_8000,
-	audio->samp_rate_index = AUDREC_CMD_SAMP_RATE_INDX_8000;
-	audio->channel_mode = AUDREC_CMD_STEREO_MODE_MONO;
-	if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL)
-		audio->buffer_size = (QCELP_FRAME_SIZE + 14);
-	else
-		audio->buffer_size = QCELP_FRAME_SIZE;
-	audio->enc_type = AUDREC_CMD_TYPE_0_INDEX_QCELP | audio->mode;
-
-	audio->cfg.cdma_rate = CDMA_RATE_FULL;
-	audio->cfg.min_bit_rate = CDMA_RATE_FULL;
-	audio->cfg.max_bit_rate = CDMA_RATE_FULL;
-
-	if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-		rc = audmgr_open(&audio->audmgr);
-		if (rc)
-			goto done;
-	}
-
-	encid = audpreproc_aenc_alloc(audio->enc_type, &audio->module_name,
-			&audio->queue_ids);
-	if (encid < 0) {
-		MM_ERR("No free encoder available\n");
-		rc = -ENODEV;
-		goto done;
-	}
-	audio->enc_id = encid;
-
-	rc = msm_adsp_get(audio->module_name, &audio->audrec,
-			   &audrec_qcelp_adsp_ops, audio);
-	if (rc) {
-		audpreproc_aenc_free(audio->enc_id);
-		goto done;
-	}
-
-	audio->dsp_cnt = 0;
-	audio->stopped = 0;
-	audio->wflush = 0;
-	audio->rflush = 0;
-	audio->flush_ack = 0;
-
-	audqcelp_in_flush(audio);
-	audqcelp_out_flush(audio);
-
-	client = msm_ion_client_create(UINT_MAX, "Audio_QCELP_in_client");
-	if (IS_ERR_OR_NULL(client)) {
-		MM_ERR("Unable to create ION client\n");
-		rc = -ENOMEM;
-		goto client_create_error;
-	}
-	audio->client = client;
-
-	MM_DBG("allocating mem sz = %d\n", dma_size);
-	handle = ion_alloc(client, dma_size, SZ_4K,
-		ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-	if (IS_ERR_OR_NULL(handle)) {
-		MM_ERR("Unable to create allocate O/P buffers\n");
-		rc = -ENOMEM;
-		goto output_buff_alloc_error;
-	}
-
-	audio->output_buff_handle = handle;
-
-	rc = ion_phys(client , handle, &addr, &len);
-	if (rc) {
-		MM_ERR("O/P buffers:Invalid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-		rc = -ENOMEM;
-		goto output_buff_get_phys_error;
-	} else {
-		MM_INFO("O/P buffers:valid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-	}
-	audio->phys = (int32_t)addr;
-
-	rc = ion_handle_get_flags(client, handle, &ionflag);
-	if (rc) {
-		MM_ERR("could not get flags for the handle\n");
-		rc = -ENOMEM;
-		goto output_buff_get_flags_error;
-	}
-
-	audio->map_v_read = ion_map_kernel(client, handle);
-	if (IS_ERR(audio->map_v_read)) {
-		MM_ERR("could not map read buffers,freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENOMEM;
-		goto output_buff_map_error;
-	}
-	audio->data = audio->map_v_read;
-	MM_DBG("read buf: phy addr 0x%08x kernel addr 0x%08x\n",
-		audio->phys, (int)audio->data);
-
-	audio->out_data = NULL;
-	if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) {
-		MM_DBG("allocating BUFFER_SIZE  %d\n", BUFFER_SIZE);
-		handle = ion_alloc(client, BUFFER_SIZE,
-				SZ_4K, ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-		if (IS_ERR_OR_NULL(handle)) {
-			MM_ERR("Unable to create allocate I/P buffers\n");
-			rc = -ENOMEM;
-			goto input_buff_alloc_error;
-		}
-
-		audio->input_buff_handle = handle;
-
-		rc = ion_phys(client , handle, &addr, &len);
-		if (rc) {
-			MM_ERR("I/P buffers:Invalid phy: %x sz: %x\n",
-				(unsigned int) addr, (unsigned int) len);
-			rc = -ENOMEM;
-			goto input_buff_get_phys_error;
-		} else {
-			MM_INFO("Got valid phy: %x sz: %x\n",
-				(unsigned int) addr,
-				(unsigned int) len);
-		}
-		audio->out_phys = (int32_t)addr;
-
-		rc = ion_handle_get_flags(client,
-			handle, &ionflag);
-		if (rc) {
-			MM_ERR("could not get flags for the handle\n");
-			rc = -ENOMEM;
-			goto input_buff_get_flags_error;
-		}
-
-		audio->map_v_write = ion_map_kernel(client, handle);
-		if (IS_ERR(audio->map_v_write)) {
-			MM_ERR("could not map write buffers\n");
-			rc = -ENOMEM;
-			goto input_buff_map_error;
-		}
-		audio->out_data = audio->map_v_write;
-		MM_DBG("write buf: phy addr 0x%08x kernel addr 0x%08x\n",
-					(unsigned int)addr,
-					(unsigned int)audio->out_data);
-
-		/* Initialize buffer */
-		audio->out[0].data = audio->out_data + 0;
-		audio->out[0].addr = audio->out_phys + 0;
-		audio->out[0].size = OUT_BUFFER_SIZE;
-
-		audio->out[1].data = audio->out_data + OUT_BUFFER_SIZE;
-		audio->out[1].addr = audio->out_phys + OUT_BUFFER_SIZE;
-		audio->out[1].size = OUT_BUFFER_SIZE;
-
-		MM_DBG("audio->out[0].data = %d  audio->out[1].data = %d",
-				(unsigned int)audio->out[0].data,
-				(unsigned int)audio->out[1].data);
-		audio->mfield = NT_FRAME_HEADER_SIZE;
-		audio->out_frame_cnt++;
-	}
-	file->private_data = audio;
-	audio->opened = 1;
-
-done:
-	mutex_unlock(&audio->lock);
-	return rc;
-input_buff_map_error:
-input_buff_get_flags_error:
-input_buff_get_phys_error:
-	ion_free(client, audio->input_buff_handle);
-input_buff_alloc_error:
-	ion_unmap_kernel(client, audio->output_buff_handle);
-output_buff_map_error:
-output_buff_get_phys_error:
-output_buff_get_flags_error:
-	ion_free(client, audio->output_buff_handle);
-output_buff_alloc_error:
-	ion_client_destroy(client);
-client_create_error:
-	msm_adsp_put(audio->audrec);
-
-	audpreproc_aenc_free(audio->enc_id);
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static const struct file_operations audio_qcelp_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audqcelp_in_open,
-	.release	= audqcelp_in_release,
-	.read		= audqcelp_in_read,
-	.write		= audqcelp_in_write,
-	.fsync		= audqcelp_in_fsync,
-	.unlocked_ioctl	= audqcelp_in_ioctl,
-};
-
-static struct miscdevice audqcelp_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_qcelp_in",
-	.fops	= &audio_qcelp_in_fops,
-};
-
-static int __init audqcelp_in_init(void)
-{
-	mutex_init(&the_audio_qcelp_in.lock);
-	mutex_init(&the_audio_qcelp_in.read_lock);
-	spin_lock_init(&the_audio_qcelp_in.dsp_lock);
-	init_waitqueue_head(&the_audio_qcelp_in.wait);
-	init_waitqueue_head(&the_audio_qcelp_in.wait_enable);
-	mutex_init(&the_audio_qcelp_in.write_lock);
-	init_waitqueue_head(&the_audio_qcelp_in.write_wait);
-	return misc_register(&audqcelp_in_misc);
-}
-device_initcall(audqcelp_in_init);
diff --git a/arch/arm/mach-msm/qdsp5/audio_voice_lb.c b/arch/arm/mach-msm/qdsp5/audio_voice_lb.c
deleted file mode 100644
index a73defd..0000000
--- a/arch/arm/mach-msm/qdsp5/audio_voice_lb.c
+++ /dev/null
@@ -1,369 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- *
- */
-
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/fs.h>
-#include <linux/kthread.h>
-#include <linux/miscdevice.h>
-#include <linux/module.h>
-#include <linux/wakelock.h>
-#include <linux/slab.h>
-#include <linux/uaccess.h>
-
-#include <mach/debug_mm.h>
-#include <mach/msm_rpcrouter.h>
-
-#include "audmgr_new.h"
-
-#define VOICELOOPBACK_PROG	0x300000B8
-#define VOICELOOP_VERS	0x00010001
-
-#define VOICELOOPBACK_START_PROC 2
-#define VOICELOOPBACK_STOP_PROC 3
-
-#define RPC_TYPE_REQUEST 0
-#define RPC_TYPE_REPLY 1
-
-#define RPC_STATUS_FAILURE 0
-#define RPC_STATUS_SUCCESS 1
-#define RPC_STATUS_REJECT 1
-
-#define RPC_COMMON_HDR_SZ  (sizeof(uint32_t) * 2)
-#define RPC_REQUEST_HDR_SZ (sizeof(struct rpc_request_hdr))
-#define RPC_REPLY_HDR_SZ   (sizeof(uint32_t) * 3)
-
-#define MAX_LEN 32
-
-struct audio {
-	struct msm_rpc_endpoint *rpc_endpt;
-	uint32_t rpc_prog;
-	uint32_t rpc_ver;
-	uint32_t rpc_status;
-	struct audmgr audmgr;
-
-	struct dentry *dentry;
-
-	struct mutex lock;
-
-	struct task_struct *task;
-
-	wait_queue_head_t wait;
-	int enabled;
-	int thread_exit;
-};
-
-static struct audio the_audio;
-
-static int audio_voice_loopback_thread(void *data)
-{
-	struct audio *audio = data;
-	struct rpc_request_hdr *rpc_hdr = NULL;
-	int rpc_hdr_len;
-
-	MM_DBG("\n");
-
-	while (!kthread_should_stop()) {
-		if (rpc_hdr != NULL) {
-			kfree(rpc_hdr);
-			rpc_hdr = NULL;
-		}
-
-		if (audio->thread_exit)
-			break;
-
-		rpc_hdr_len = msm_rpc_read(audio->rpc_endpt,
-					       (void **) &rpc_hdr,
-					       -1,
-					       -1);
-		if (rpc_hdr_len < 0) {
-			MM_ERR("RPC read failed %d\n", rpc_hdr_len);
-			break;
-		} else if (rpc_hdr_len < RPC_COMMON_HDR_SZ) {
-			continue;
-		} else {
-			uint32_t rpc_type = be32_to_cpu(rpc_hdr->type);
-			if (rpc_type == RPC_TYPE_REPLY) {
-				struct rpc_reply_hdr *rpc_reply =
-					 (void *) rpc_hdr;
-				uint32_t reply_status;
-
-				reply_status =
-					be32_to_cpu(rpc_reply->reply_stat);
-
-				if (reply_status == RPC_ACCEPTSTAT_SUCCESS)
-					audio->rpc_status = \
-							RPC_STATUS_SUCCESS;
-				else {
-					audio->rpc_status = \
-							RPC_STATUS_REJECT;
-					MM_ERR("RPC reply status denied\n");
-				}
-				wake_up(&audio->wait);
-			} else {
-				MM_ERR("Unexpected RPC type %d\n", rpc_type);
-			}
-		}
-	}
-	kfree(rpc_hdr);
-	rpc_hdr = NULL;
-
-	MM_DBG("Audio Voice Looopback thread stopped\n");
-
-	return 0;
-}
-
-static int audio_voice_loopback_start(struct audio *audio)
-{
-	int rc = 0;
-	struct audmgr_config cfg;
-	struct rpc_request_hdr rpc_hdr;
-
-	MM_DBG("\n");
-
-	cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_8000;
-	cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_8000;
-	cfg.def_method = RPC_AUD_DEF_METHOD_VOICE;
-	cfg.codec = RPC_AUD_DEF_CODEC_VOC_CDMA;
-	cfg.snd_method = RPC_SND_METHOD_VOICE;
-	rc = audmgr_enable(&audio->audmgr, &cfg);
-	if (rc < 0) {
-		MM_ERR("audmgr open failed, freeing instance\n");
-		rc = -EINVAL;
-		goto done;
-	}
-
-	memset(&rpc_hdr, 0, sizeof(rpc_hdr));
-
-	msm_rpc_setup_req(&rpc_hdr,
-			audio->rpc_prog,
-			audio->rpc_ver,
-			VOICELOOPBACK_START_PROC);
-
-	audio->rpc_status = RPC_STATUS_FAILURE;
-	rc = msm_rpc_write(audio->rpc_endpt,
-			   &rpc_hdr,
-			   sizeof(rpc_hdr));
-	if (rc >= 0) {
-		rc = wait_event_timeout(audio->wait,
-			(audio->rpc_status != RPC_STATUS_FAILURE),
-			1 * HZ);
-		if (rc > 0) {
-			if (audio->rpc_status != RPC_STATUS_SUCCESS) {
-				MM_ERR("Start loopback failed %d\n", rc);
-				rc = -EBUSY;
-			} else {
-				rc = 0;
-			}
-		} else {
-			MM_ERR("Wait event for acquire failed %d\n", rc);
-			rc = -EBUSY;
-		}
-	} else {
-		audmgr_disable(&audio->audmgr);
-		MM_ERR("RPC write for start loopback failed %d\n", rc);
-		rc = -EBUSY;
-	}
-done:
-	return rc;
-}
-
-static int audio_voice_loopback_stop(struct audio *audio)
-{
-	int rc = 0;
-	struct rpc_request_hdr rpc_hdr;
-
-	MM_DBG("\n");
-
-	memset(&rpc_hdr, 0, sizeof(rpc_hdr));
-
-	msm_rpc_setup_req(&rpc_hdr,
-			  audio->rpc_prog,
-			  audio->rpc_ver,
-			  VOICELOOPBACK_STOP_PROC);
-
-	audio->rpc_status = RPC_STATUS_FAILURE;
-	audio->thread_exit = 1;
-	rc = msm_rpc_write(audio->rpc_endpt,
-			   &rpc_hdr,
-			   sizeof(rpc_hdr));
-	if (rc >= 0) {
-
-		rc = wait_event_timeout(audio->wait,
-				(audio->rpc_status != RPC_STATUS_FAILURE),
-				1 * HZ);
-		if (rc > 0) {
-			MM_DBG("Wait event for release succeeded\n");
-			rc = 0;
-		} else {
-			MM_ERR("Wait event for release failed %d\n", rc);
-		}
-	} else {
-		MM_ERR("RPC write for release failed %d\n", rc);
-	}
-
-	audmgr_disable(&audio->audmgr);
-
-	return rc;
-}
-
-static int audio_voice_loopback_open(struct audio *audio_info)
-{
-	int rc = 0;
-
-	MM_DBG("\n");
-
-	rc = audmgr_open(&audio_info->audmgr);
-	if (rc) {
-		MM_ERR("audmgr open failed, freeing instance\n");
-		rc = -EINVAL;
-		goto done;
-	}
-
-	audio_info->rpc_endpt = msm_rpc_connect_compatible(VOICELOOPBACK_PROG,
-			VOICELOOP_VERS,
-			MSM_RPC_UNINTERRUPTIBLE);
-	if (IS_ERR(audio_info->rpc_endpt)) {
-		MM_ERR("VOICE LOOPBACK RPC connect\
-				failed ver 0x%x\n",
-				VOICELOOP_VERS);
-		rc = PTR_ERR(audio_info->rpc_endpt);
-		audio_info->rpc_endpt = NULL;
-		rc = -EINVAL;
-	} else {
-		MM_DBG("VOICE LOOPBACK connect succeeded ver 0x%x\n",
-				VOICELOOP_VERS);
-		audio_info->thread_exit = 0;
-		audio_info->task = kthread_run(audio_voice_loopback_thread,
-				audio_info,
-				"audio_voice_loopback");
-		if (IS_ERR(audio_info->task)) {
-			MM_ERR("voice loopback thread create failed\n");
-			rc = PTR_ERR(audio_info->task);
-			audio_info->task = NULL;
-			msm_rpc_close(audio_info->rpc_endpt);
-			audio_info->rpc_endpt = NULL;
-			rc = -EINVAL;
-		}
-		audio_info->rpc_prog = VOICELOOPBACK_PROG;
-		audio_info->rpc_ver = VOICELOOP_VERS;
-	}
-done:
-	return rc;
-}
-
-static int audio_voice_loopback_close(struct audio *audio_info)
-{
-	MM_DBG("\n");
-	msm_rpc_close(audio_info->rpc_endpt);
-	audio_info->rpc_endpt = NULL;
-	audmgr_close(&audio_info->audmgr);
-	audio_info->task = NULL;
-	return 0;
-}
-
-static ssize_t audio_voice_loopback_debug_write(struct file *file,
-				const char __user *buf,
-				size_t cnt, loff_t *ppos)
-{
-	char lbuf[MAX_LEN];
-	int rc = 0;
-
-	if (cnt > (MAX_LEN - 1))
-		return -EINVAL;
-
-	memset(&lbuf[0], 0, sizeof(lbuf));
-
-	rc = copy_from_user(lbuf, buf, cnt);
-	if (rc) {
-		MM_ERR("Unable to copy data from user space\n");
-		return -EFAULT;
-	}
-
-	lbuf[cnt] = '\0';
-
-	if (!strncmp(&lbuf[0], "1", cnt-1)) {
-		mutex_lock(&the_audio.lock);
-		if (!the_audio.enabled) {
-			rc = audio_voice_loopback_open(&the_audio);
-			if (!rc) {
-				rc = audio_voice_loopback_start(&the_audio);
-				if (rc < 0) {
-					the_audio.enabled = 0;
-					audio_voice_loopback_close(&the_audio);
-				} else {
-					the_audio.enabled = 1;
-				}
-			}
-		}
-		mutex_unlock(&the_audio.lock);
-	} else if (!strncmp(lbuf, "0", cnt-1)) {
-		mutex_lock(&the_audio.lock);
-		if (the_audio.enabled) {
-			audio_voice_loopback_stop(&the_audio);
-			audio_voice_loopback_close(&the_audio);
-			the_audio.enabled = 0;
-		}
-		mutex_unlock(&the_audio.lock);
-	} else {
-		rc = -EINVAL;
-	}
-
-	if (rc == 0) {
-		rc = cnt;
-	} else {
-		MM_INFO("rc = %d\n", rc);
-		MM_INFO("\nWrong command: Use =>\n");
-		MM_INFO("-------------------------\n");
-		MM_INFO("To Start Loopback:: echo \"1\">/sys/kernel/debug/\
-			voice_loopback\n");
-		MM_INFO("To Stop Loopback:: echo \"0\">/sys/kernel/debug/\
-			voice_loopback\n");
-		MM_INFO("------------------------\n");
-	}
-
-	return rc;
-}
-
-static ssize_t audio_voice_loopback_debug_open(struct inode *inode,
-		struct file *file)
-{
-	file->private_data = inode->i_private;
-	MM_DBG("Audio Voiceloop debugfs opened\n");
-	return 0;
-}
-
-static const struct file_operations voice_loopback_debug_fops = {
-	.write = audio_voice_loopback_debug_write,
-	.open = audio_voice_loopback_debug_open,
-};
-
-static int __init audio_init(void)
-{
-	int rc = 0;
-	memset(&the_audio, 0, sizeof(the_audio));
-
-	mutex_init(&the_audio.lock);
-
-	init_waitqueue_head(&the_audio.wait);
-
-	the_audio.dentry = debugfs_create_file("voice_loopback",
-			S_IFREG | S_IRUGO,
-			NULL,
-			NULL, &voice_loopback_debug_fops);
-	if (IS_ERR(the_audio.dentry))
-		MM_ERR("debugfs_create_file failed\n");
-
-	return rc;
-}
-late_initcall(audio_init);
diff --git a/arch/arm/mach-msm/qdsp5/audio_voicememo.c b/arch/arm/mach-msm/qdsp5/audio_voicememo.c
deleted file mode 100644
index f7295b7..0000000
--- a/arch/arm/mach-msm/qdsp5/audio_voicememo.c
+++ /dev/null
@@ -1,982 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/audio_voicememo.c
- *
- * Voice Memo device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
- *
- * This code is based in part on arch/arm/mach-msm/qdsp5/audio_mp3.c
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you can find it at http://www.fsf.org.
- *
- */
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/delay.h>
-#include <linux/msm_audio_voicememo.h>
-#include <linux/slab.h>
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-#include <mach/msm_rpcrouter.h>
-#include <mach/debug_mm.h>
-
-#include "audmgr.h"
-
-#define SND_PROG_VERS "rs30000002:0x00020001"
-#define SND_PROG 0x30000002
-#define SND_VERS_COMP 0x00020001
-#define SND_VERS2_COMP 0x00030001
-
-#define SND_VOC_REC_START_PROC                  19
-#define SND_VOC_REC_STOP_PROC                   20
-#define SND_VOC_REC_PAUSE_PROC			21
-#define SND_VOC_REC_RESUME_PROC                 22
-#define SND_VOC_REC_PUT_BUF_PROC                23
-
-#define SND_VOC_REC_AV_SYNC_CB_PTR_PROC 	9
-#define SND_VOC_REC_CB_FUNC_TYPE_PROC 		10
-
-#define REC_CLIENT_DATA		0x11223344
-#define DATA_CB_FUNC_ID		0x12345678
-#define AV_SYNC_CB_FUNC_ID	0x87654321
-#define CLIENT_DATA		0xaabbccdd
-
-#define RPC_TYPE_REQUEST 0
-#define RPC_TYPE_REPLY 1
-
-#define RPC_STATUS_FAILURE 0
-#define RPC_STATUS_SUCCESS 1
-
-#define RPC_VERSION 2
-
-#define RPC_COMMON_HDR_SZ  (sizeof(uint32_t) * 2)
-#define RPC_REQUEST_HDR_SZ (sizeof(struct rpc_request_hdr))
-#define RPC_REPLY_HDR_SZ   (sizeof(uint32_t) * 3)
-#define RPC_REPLY_SZ       (sizeof(uint32_t) * 6)
-
-#define MAX_FRAME_SIZE 36 /* QCELP - 36, AMRNB - 32, EVRC - 24 */
-#define MAX_REC_BUF_COUNT 5 /* Maximum supported voc rec buffers */
-#define MAX_REC_BUF_SIZE (MAX_FRAME_SIZE * 10)
-#define MAX_VOICEMEMO_BUF_SIZE  \
-	((MAX_REC_BUF_SIZE)*MAX_REC_BUF_COUNT) /* 5 buffers for 200ms frame */
-#define MSM_AUD_BUFFER_UPDATE_WAIT_MS 2000
-
-enum rpc_voc_rec_status_type {
-	RPC_VOC_REC_STAT_SUCCESS = 1,
-	RPC_VOC_REC_STAT_DONE = 2,
-	RPC_VOC_REC_STAT_AUTO_STOP = 4,
-	RPC_VOC_REC_STAT_PAUSED = 8,
-	RPC_VOC_REC_STAT_RESUMED = 16,
-	RPC_VOC_REC_STAT_ERROR = 32,
-	RPC_VOC_REC_STAT_BUFFER_ERROR = 64,
-	RPC_VOC_REC_STAT_INVALID_PARAM = 128,
-	RPC_VOC_REC_STAT_INT_TIME = 256,
-	RPC_VOC_REC_STAT_DATA = 512,
-	RPC_VOC_REC_STAT_NOT_READY = 1024,
-	RPC_VOC_REC_STAT_INFORM_EVRC = 2048,
-	RPC_VOC_REC_STAT_INFORM_13K = 4096,
-	RPC_VOC_REC_STAT_INFORM_AMR = 8192,
-	RPC_VOC_REC_STAT_INFORM_MAX = 65535
-};
-
-struct rpc_snd_voc_rec_start_args {
-	uint32_t param_status; /* 1 = valid, 0 = not valid */
-	uint32_t rec_type;
-	uint32_t rec_interval_ms;
-	uint32_t auto_stop_ms;
-	uint32_t capability;
-	uint32_t max_rate;
-	uint32_t min_rate;
-	uint32_t frame_format;
-	uint32_t dtx_enable;
-	uint32_t data_req_ms;
-	uint32_t rec_client_data;
-
-	uint32_t cb_func_id;
-	uint32_t sync_cb_func_id;
-	uint32_t client_data;
-};
-
-struct rpc_snd_voc_rec_put_buf_args {
-	uint32_t buf;
-	uint32_t num_bytes;
-};
-
-struct snd_voc_rec_start_msg {
-	struct rpc_request_hdr hdr;
-	struct rpc_snd_voc_rec_start_args args;
-};
-
-struct snd_voc_rec_put_buf_msg {
-	struct rpc_request_hdr hdr;
-	struct rpc_snd_voc_rec_put_buf_args args;
-};
-
-struct snd_voc_rec_av_sync_cb_func_data {
-	uint32_t sync_cb_func_id;
-	uint32_t status;  /* Pointer status (1 = valid, 0  = invalid) */
-	uint32_t num_samples;
-	uint32_t time_stamp[2];
-	uint32_t lost_samples;
-	uint32_t frame_index;
-	uint32_t client_data;
-};
-
-struct snd_voc_rec_cb_func_fw_data {
-	uint32_t fw_ptr_status; /* FW Pointer status (1=valid,0=invalid) */
-	uint32_t rec_buffer_size;
-	uint32_t data[MAX_REC_BUF_SIZE/4];
-	uint32_t rec_buffer_size_copy;
-	uint32_t rec_num_frames; /* Number of voice frames */
-	uint32_t rec_length; /* Valid data in record buffer =
-			      * data_req_ms amount of data */
-	uint32_t client_data; /* A11 rec buffer pointer */
-	uint32_t rw_ptr_status; /* RW Pointer status (1=valid,0=invalid) */
-};
-
-struct snd_voc_rec_cb_func_rw_data {
-	uint32_t fw_ptr_status; /* FW Pointer status (1=valid,0=invalid) */
-	uint32_t rw_ptr_status; /* RW Pointer status (1=valid,0=invalid) */
-	uint32_t rec_buffer_size;
-	uint32_t data[MAX_REC_BUF_SIZE/4];
-	uint32_t rec_buffer_size_copy;
-	uint32_t rec_num_frames; /* Number of voice frames */
-	uint32_t rec_length; /* Valid data in record buffer =
-			      * data_req_ms amount of data */
-	uint32_t client_data; /* A11 rec buffer pointer */
-};
-
-struct snd_voc_rec_data_cb_func_data {
-	uint32_t cb_func_id;
-	uint32_t status; /* Pointer status (1 = valid, 0  = invalid) */
-	uint32_t rec_status;
-
-	union {
-		struct snd_voc_rec_cb_func_fw_data fw_data;
-		struct snd_voc_rec_cb_func_rw_data rw_data;
-	} pkt;
-};
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used; /* Usage actual recorded data */
-	unsigned addr;
-	unsigned numframes;
-};
-
-struct audio_voicememo {
-	uint32_t byte_count; /* Pass statistics to user space for
-			      * time stamping */
-	uint32_t frame_count;
-
-	int opened;
-	int enabled;
-	int running;
-	int stopped;
-	int pause_resume;
-
-	uint32_t rpc_prog;
-	uint32_t rpc_ver;
-	uint32_t rpc_xid;
-	uint32_t rpc_status;
-
-	struct mutex lock;
-	struct mutex read_lock;
-	struct mutex dsp_lock;
-	wait_queue_head_t read_wait;
-	wait_queue_head_t wait;
-
-	struct buffer in[MAX_REC_BUF_COUNT];
-	char *rec_buf_ptr;
-	dma_addr_t phys;
-	uint32_t rec_buf_size;
-	uint8_t read_next;	/* index to input buffers to be read next */
-	uint8_t fill_next;	/* index to buffer that should be filled as
-				 * data comes from A9 */
-
-	struct audmgr audmgr;
-
-	struct msm_audio_voicememo_config voicememo_cfg;
-
-	struct msm_rpc_endpoint *sndept;
-	struct task_struct *task;
-};
-
-static struct audio_voicememo the_audio_voicememo;
-
-static int audvoicememo_validate_usr_config(
-		struct msm_audio_voicememo_config *config)
-{
-	int rc = -1; /* error */
-
-	if (config->rec_type != RPC_VOC_REC_FORWARD &&
-		config->rec_type != RPC_VOC_REC_REVERSE &&
-		config->rec_type != RPC_VOC_REC_BOTH)
-		goto done;
-
-	/* QCELP, EVRC, AMR-NB only */
-	if (config->capability != RPC_VOC_CAP_IS733 &&
-		config->capability != RPC_VOC_CAP_IS127 &&
-		config->capability != RPC_VOC_CAP_AMR)
-		goto done;
-
-	/* QCP, AMR format supported */
-	if ((config->frame_format != RPC_VOC_PB_NATIVE_QCP) &&
-		(config->frame_format != RPC_VOC_PB_AMR))
-		goto done;
-
-	if ((config->frame_format == RPC_VOC_PB_AMR) &&
-		(config->capability != RPC_VOC_CAP_AMR))
-		goto done;
-
-	/* To make sure, max kernel buf size matches
-	 * with max data request time */
-	if (config->data_req_ms > ((MAX_REC_BUF_SIZE/MAX_FRAME_SIZE)*20))
-		goto done;
-
-	rc = 0;
-done:
-	return rc;
-}
-
-static void audvoicememo_flush_buf(struct audio_voicememo *audio)
-{
-	uint8_t index;
-
-	for (index = 0; index < MAX_REC_BUF_COUNT; index++)
-		audio->in[index].used = 0;
-
-	audio->read_next = 0;
-	mutex_lock(&audio->dsp_lock);
-	audio->fill_next = 0;
-	mutex_unlock(&audio->dsp_lock);
-}
-
-static void audvoicememo_ioport_reset(struct audio_voicememo *audio)
-{
-	/* Make sure read/write thread are free from
-	 * sleep and knowing that system is not able
-	 * to process io request at the moment
-	 */
-	wake_up(&audio->read_wait);
-	mutex_lock(&audio->read_lock);
-	audvoicememo_flush_buf(audio);
-	mutex_unlock(&audio->read_lock);
-}
-
-/* must be called with audio->lock held */
-static int audvoicememo_enable(struct audio_voicememo *audio)
-{
-	struct audmgr_config cfg;
-	struct snd_voc_rec_put_buf_msg bmsg;
-	struct snd_voc_rec_start_msg msg;
-	uint8_t index;
-	uint32_t offset = 0;
-	int rc;
-
-	if (audio->enabled)
-		return 0;
-
-	/* Codec / method configure to audmgr client */
-	cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_8000;
-	cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE;
-	cfg.def_method = RPC_AUD_DEF_METHOD_RECORD;
-
-	if (audio->voicememo_cfg.capability == RPC_VOC_CAP_IS733)
-		cfg.codec = RPC_AUD_DEF_CODEC_VOC_13K;
-	else if (audio->voicememo_cfg.capability == RPC_VOC_CAP_IS127)
-		cfg.codec = RPC_AUD_DEF_CODEC_VOC_EVRC;
-	else
-		cfg.codec = RPC_AUD_DEF_CODEC_VOC_AMR; /* RPC_VOC_CAP_AMR */
-
-	cfg.snd_method = RPC_SND_METHOD_VOICE;
-	rc = audmgr_enable(&audio->audmgr, &cfg);
-
-	if (rc < 0)
-		return rc;
-
-	/* Configure VOC Rec buffer */
-	for (index = 0; index < MAX_REC_BUF_COUNT; index++) {
-		audio->in[index].data = audio->rec_buf_ptr + offset;
-		audio->in[index].addr = audio->phys + offset;
-		audio->in[index].size = audio->rec_buf_size;
-		audio->in[index].used = 0;
-		audio->in[index].numframes = 0;
-		offset += audio->rec_buf_size;
-		bmsg.args.buf = (uint32_t) audio->in[index].data;
-		bmsg.args.num_bytes = cpu_to_be32(audio->in[index].size);
-		MM_DBG("rec_buf_ptr=0x%8x, rec_buf_size = 0x%8x\n",
-				bmsg.args.buf, bmsg.args.num_bytes);
-
-		msm_rpc_setup_req(&bmsg.hdr, audio->rpc_prog, audio->rpc_ver,
-				SND_VOC_REC_PUT_BUF_PROC);
-		audio->rpc_xid = bmsg.hdr.xid;
-		audio->rpc_status = RPC_STATUS_FAILURE;
-		msm_rpc_write(audio->sndept, &bmsg, sizeof(bmsg));
-		rc = wait_event_timeout(audio->wait,
-			audio->rpc_status != RPC_STATUS_FAILURE, 1 * HZ);
-		if (rc == 0)
-			goto err;
-	}
-
-
-	/* Start Recording */
-	msg.args.param_status = cpu_to_be32(0x00000001);
-	msg.args.rec_type = cpu_to_be32(audio->voicememo_cfg.rec_type);
-	msg.args.rec_interval_ms =
-		cpu_to_be32(audio->voicememo_cfg.rec_interval_ms);
-	msg.args.auto_stop_ms = cpu_to_be32(audio->voicememo_cfg.auto_stop_ms);
-	msg.args.capability = cpu_to_be32(audio->voicememo_cfg.capability);
-	msg.args.max_rate = cpu_to_be32(audio->voicememo_cfg.max_rate);
-	msg.args.min_rate = cpu_to_be32(audio->voicememo_cfg.min_rate);
-	msg.args.frame_format = cpu_to_be32(audio->voicememo_cfg.frame_format);
-	msg.args.dtx_enable = cpu_to_be32(audio->voicememo_cfg.dtx_enable);
-	msg.args.data_req_ms = cpu_to_be32(audio->voicememo_cfg.data_req_ms);
-	msg.args.rec_client_data = cpu_to_be32(REC_CLIENT_DATA);
-	msg.args.cb_func_id = cpu_to_be32(DATA_CB_FUNC_ID);
-	msg.args.sync_cb_func_id = cpu_to_be32(AV_SYNC_CB_FUNC_ID);
-	msg.args.client_data = cpu_to_be32(CLIENT_DATA);
-
-	msm_rpc_setup_req(&msg.hdr, audio->rpc_prog, audio->rpc_ver,
-			SND_VOC_REC_START_PROC);
-
-	audio->rpc_xid = msg.hdr.xid;
-	audio->rpc_status = RPC_STATUS_FAILURE;
-	msm_rpc_write(audio->sndept, &msg, sizeof(msg));
-	rc = wait_event_timeout(audio->wait,
-		audio->rpc_status != RPC_STATUS_FAILURE, 1 * HZ);
-	if (rc == 0)
-		goto err;
-
-	audio->rpc_xid = 0;
-	audio->enabled = 1;
-	return 0;
-
-err:
-	audio->rpc_xid = 0;
-	audmgr_disable(&audio->audmgr);
-	MM_ERR("Fail\n");
-	return -1;
-}
-
-/* must be called with audio->lock held */
-static int audvoicememo_disable(struct audio_voicememo *audio)
-{
-	struct rpc_request_hdr rhdr;
-	int rc = 0;
-	if (audio->enabled) {
-		msm_rpc_setup_req(&rhdr, audio->rpc_prog, audio->rpc_ver,
-				SND_VOC_REC_STOP_PROC);
-		rc = msm_rpc_write(audio->sndept, &rhdr, sizeof(rhdr));
-		rc = wait_event_timeout(audio->wait, audio->stopped == 1,
-				1 * HZ);
-		if (rc == 0)
-			audio->stopped = 1;
-		wake_up(&audio->read_wait);
-		audmgr_disable(&audio->audmgr);
-		audio->enabled = 0;
-	}
-	return 0;
-}
-
-/* RPC Reply Generator */
-static void rpc_reply(struct msm_rpc_endpoint *ept, uint32_t xid)
-{
-	int rc = 0;
-	uint8_t reply_buf[sizeof(struct rpc_reply_hdr)];
-	struct rpc_reply_hdr *reply = (struct rpc_reply_hdr *)reply_buf;
-
-	MM_DBG("inside\n");
-	reply->xid = cpu_to_be32(xid);
-	reply->type = cpu_to_be32(RPC_TYPE_REPLY); /* reply */
-	reply->reply_stat = cpu_to_be32(RPCMSG_REPLYSTAT_ACCEPTED);
-
-	reply->data.acc_hdr.accept_stat = cpu_to_be32(RPC_ACCEPTSTAT_SUCCESS);
-	reply->data.acc_hdr.verf_flavor = 0;
-	reply->data.acc_hdr.verf_length = 0;
-
-	rc = msm_rpc_write(ept, reply_buf, sizeof(reply_buf));
-	if (rc < 0)
-		MM_ERR("could not write RPC response: %d\n", rc);
-}
-
-static void process_rpc_request(uint32_t proc, uint32_t xid,
-		void *data, int len, void *private)
-{
-	struct audio_voicememo *audio = private;
-
-	MM_DBG("inside\n");
-	/* Sending Ack before processing the request
-	 * to make sure A9 get response immediate
-	 * However, if there is validation of request planned
-	 * may be move this reply Ack at the end */
-	rpc_reply(audio->sndept, xid);
-	switch (proc) {
-	case SND_VOC_REC_AV_SYNC_CB_PTR_PROC: {
-		MM_DBG("AV Sync CB:func_id=0x%8x,status=0x%x\n",
-			be32_to_cpu(( \
-			(struct snd_voc_rec_av_sync_cb_func_data *)\
-			data)->sync_cb_func_id),\
-			be32_to_cpu(( \
-			(struct snd_voc_rec_av_sync_cb_func_data *)\
-			data)->status));
-		break;
-		}
-	case SND_VOC_REC_CB_FUNC_TYPE_PROC: {
-		struct snd_voc_rec_data_cb_func_data *datacb_data
-			= (void *)(data);
-		struct snd_voc_rec_put_buf_msg bmsg;
-		uint32_t rec_status = be32_to_cpu(datacb_data->rec_status);
-
-		MM_DBG("Data CB:func_id=0x%8x,status=0x%x,\
-			rec_status=0x%x\n",
-			be32_to_cpu(datacb_data->cb_func_id),\
-			be32_to_cpu(datacb_data->status),\
-			be32_to_cpu(datacb_data->rec_status));
-
-		/* Data recorded */
-		if ((rec_status == RPC_VOC_REC_STAT_DATA) ||
-		(rec_status == RPC_VOC_REC_STAT_DONE)) {
-			if (datacb_data->pkt.fw_data.fw_ptr_status &&
-			be32_to_cpu(datacb_data->pkt.fw_data.rec_length) &&
-			be32_to_cpu(datacb_data->pkt.fw_data.rec_length)
-			<= MAX_REC_BUF_SIZE) {
-
-				MM_DBG("Copy FW link:rec_buf_size \
-				= 0x%08x, rec_length=0x%08x\n",
-				be32_to_cpu( \
-				datacb_data->pkt.fw_data. \
-				rec_buffer_size_copy),\
-				be32_to_cpu(datacb_data->pkt.fw_data. \
-				rec_length));
-
-				mutex_lock(&audio->dsp_lock);
-				memcpy(audio->in[audio->fill_next].data, \
-					&(datacb_data->pkt.fw_data.data[0]), \
-				be32_to_cpu(
-				datacb_data->pkt.fw_data.rec_length));
-				audio->in[audio->fill_next].used =
-				be32_to_cpu(
-					datacb_data->pkt.fw_data.rec_length);
-				audio->in[audio->fill_next].numframes =
-				be32_to_cpu(
-				datacb_data->pkt.fw_data.rec_num_frames);
-				mutex_unlock(&audio->dsp_lock);
-			} else if (datacb_data->pkt.rw_data.rw_ptr_status &&
-			be32_to_cpu(datacb_data->pkt.rw_data.rec_length) &&
-			be32_to_cpu(datacb_data->pkt.rw_data.rec_length)
-			<= MAX_REC_BUF_SIZE) {
-
-				MM_DBG("Copy RW link:rec_buf_size \
-				=0x%08x, rec_length=0x%08x\n",
-				be32_to_cpu( \
-				datacb_data->pkt.rw_data. \
-				rec_buffer_size_copy),\
-				be32_to_cpu(datacb_data->pkt.rw_data. \
-				rec_length));
-
-				mutex_lock(&audio->dsp_lock);
-				memcpy(audio->in[audio->fill_next].data, \
-				&(datacb_data->pkt.rw_data.data[0]), \
-				be32_to_cpu(
-					datacb_data->pkt.rw_data.rec_length));
-				audio->in[audio->fill_next].used =
-				be32_to_cpu(
-					datacb_data->pkt.rw_data.rec_length);
-				audio->in[audio->fill_next].numframes =
-				be32_to_cpu(
-				datacb_data->pkt.rw_data.rec_num_frames);
-				mutex_unlock(&audio->dsp_lock);
-			} else {
-				MM_ERR("FW: ptr_status %d, rec_length=0x%08x,"
-				"RW: ptr_status %d, rec_length=0x%08x\n",
-				datacb_data->pkt.fw_data.fw_ptr_status, \
-				be32_to_cpu( \
-				datacb_data->pkt.fw_data.rec_length), \
-				datacb_data->pkt.rw_data.rw_ptr_status, \
-				be32_to_cpu( \
-				datacb_data->pkt.rw_data.rec_length));
-			}
-			if (rec_status != RPC_VOC_REC_STAT_DONE) {
-				/* Not end of record */
-				bmsg.args.buf = \
-				(uint32_t) audio->in[audio->fill_next].data;
-				bmsg.args.num_bytes = \
-				be32_to_cpu(audio->in[audio->fill_next].size);
-
-				if (++audio->fill_next ==  MAX_REC_BUF_COUNT)
-					audio->fill_next = 0;
-
-				msm_rpc_setup_req(&bmsg.hdr, audio->rpc_prog,
-				audio->rpc_ver, SND_VOC_REC_PUT_BUF_PROC);
-
-				msm_rpc_write(audio->sndept, &bmsg,
-				sizeof(bmsg));
-
-				wake_up(&audio->read_wait);
-			} else {
-				/* Indication record stopped gracefully */
-				MM_DBG("End Of Voice Record\n");
-				audio->stopped = 1;
-				wake_up(&audio->wait);
-			}
-		} else if (rec_status == RPC_VOC_REC_STAT_PAUSED) {
-			MM_DBG(" Voice Record PAUSED\n");
-			audio->pause_resume = 1;
-		} else if (rec_status == RPC_VOC_REC_STAT_RESUMED) {
-			MM_DBG(" Voice Record RESUMED\n");
-			audio->pause_resume = 0;
-		} else if ((rec_status == RPC_VOC_REC_STAT_ERROR) ||
-		(rec_status == RPC_VOC_REC_STAT_INVALID_PARAM) ||
-		(rec_status == RPC_VOC_REC_STAT_BUFFER_ERROR))
-			MM_ERR("error recording =0x%8x\n",
-				rec_status);
-		else if (rec_status == RPC_VOC_REC_STAT_INT_TIME)
-			MM_DBG("Frames recorded matches interval \
-					callback time\n");
-		else if (rec_status == RPC_VOC_REC_STAT_AUTO_STOP) {
-			MM_DBG(" Voice Record AUTO STOP\n");
-			mutex_lock(&audio->lock);
-			audio->stopped = 1;
-			wake_up(&audio->read_wait);
-			audmgr_disable(&audio->audmgr);
-			audvoicememo_ioport_reset(audio);
-			audio->stopped = 0;
-			audio->enabled = 0;
-			mutex_unlock(&audio->lock);
-		}
-			break;
-		}
-	default:
-		MM_ERR("UNKNOWN PROC , proc = 0x%8x \n", proc);
-	}
-}
-
-static int voicememo_rpc_thread(void *data)
-{
-	struct audio_voicememo *audio = data;
-	struct rpc_request_hdr *hdr = NULL;
-	uint32_t type;
-	int len;
-
-	MM_DBG("start\n");
-
-	while (!kthread_should_stop()) {
-		kfree(hdr);
-		hdr = NULL;
-
-		len = msm_rpc_read(audio->sndept, (void **) &hdr, -1, -1);
-		MM_DBG("rpc_read len = 0x%x\n", len);
-		if (len < 0) {
-			MM_ERR("rpc read failed (%d)\n", len);
-			break;
-		}
-		if (len < RPC_COMMON_HDR_SZ)
-			continue;
-		type = be32_to_cpu(hdr->type);
-		if (type == RPC_TYPE_REPLY) {
-			struct rpc_reply_hdr *rep = (void *) hdr;
-			uint32_t status;
-			if (len < RPC_REPLY_HDR_SZ)
-				continue;
-			status = be32_to_cpu(rep->reply_stat);
-			if (status == RPCMSG_REPLYSTAT_ACCEPTED) {
-				status =
-				be32_to_cpu(rep->data.acc_hdr.accept_stat);
-
-				/* Confirm major RPC success during open*/
-				if ((audio->enabled == 0) &&
-					(status == RPC_ACCEPTSTAT_SUCCESS) &&
-					(audio->rpc_xid == rep->xid)) {
-						audio->rpc_status = \
-							RPC_STATUS_SUCCESS;
-						wake_up(&audio->wait);
-				}
-				MM_DBG("rpc_reply status 0x%8x\n", status);
-			} else {
-				MM_ERR("rpc_reply denied!\n");
-			}
-			/* process reply */
-			continue;
-		} else if (type == RPC_TYPE_REQUEST) {
-			if (len < RPC_REQUEST_HDR_SZ)
-				continue;
-			process_rpc_request(be32_to_cpu(hdr->procedure),
-						be32_to_cpu(hdr->xid),
-						(void *) (hdr + 1),
-						len - sizeof(*hdr),
-						audio);
-		} else
-			MM_ERR("Unexpected type (%d)\n", type);
-	}
-	MM_DBG("stop\n");
-	kfree(hdr);
-	hdr = NULL;
-
-	return 0;
-}
-
-/* ------------------- device --------------------- */
-static long audio_voicememo_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct audio_voicememo *audio = file->private_data;
-	int rc = 0;
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		memset(&stats, 0, sizeof(stats));
-		mutex_lock(&audio->dsp_lock);
-		stats.byte_count = audio->byte_count;
-		stats.sample_count = audio->frame_count;
-		mutex_unlock(&audio->dsp_lock);
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START: {
-			MM_DBG("AUDIO_START\n");
-			audio->byte_count = 0;
-			audio->frame_count = 0;
-			if (audio->voicememo_cfg.rec_type != RPC_VOC_REC_NONE)
-				rc = audvoicememo_enable(audio);
-			else
-				rc = -EINVAL;
-			MM_DBG("AUDIO_START rc %d\n", rc);
-			break;
-		}
-	case AUDIO_STOP: {
-			MM_DBG("AUDIO_STOP\n");
-			rc = audvoicememo_disable(audio);
-			audvoicememo_ioport_reset(audio);
-			audio->stopped = 0;
-			MM_DBG("AUDIO_STOP rc %d\n", rc);
-			break;
-		}
-	case AUDIO_GET_CONFIG: {
-			struct msm_audio_config cfg;
-			MM_DBG("AUDIO_GET_CONFIG\n");
-			cfg.buffer_size = audio->rec_buf_size;
-			cfg.buffer_count = MAX_REC_BUF_COUNT;
-			cfg.sample_rate = 8000; /* Voice Encoder works on 8k,
-						 * Mono */
-			cfg.channel_count = 1;
-			cfg.type = 0;
-			cfg.unused[0] = 0;
-			cfg.unused[1] = 0;
-			cfg.unused[2] = 0;
-			if (copy_to_user((void *) arg, &cfg, sizeof(cfg)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			MM_DBG("AUDIO_GET_CONFIG rc %d\n", rc);
-			break;
-		}
-	case AUDIO_GET_VOICEMEMO_CONFIG: {
-			MM_DBG("AUDIO_GET_VOICEMEMO_CONFIG\n");
-			if (copy_to_user((void *)arg, &audio->voicememo_cfg,
-				sizeof(audio->voicememo_cfg)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			MM_DBG("AUDIO_GET_VOICEMEMO_CONFIG rc %d\n", rc);
-			break;
-		}
-	case AUDIO_SET_VOICEMEMO_CONFIG: {
-			struct msm_audio_voicememo_config usr_config;
-			MM_DBG("AUDIO_SET_VOICEMEMO_CONFIG\n");
-			if (copy_from_user
-				(&usr_config, (void *)arg,
-				sizeof(usr_config))) {
-				rc = -EFAULT;
-				break;
-			}
-			if (audvoicememo_validate_usr_config(&usr_config)
-					== 0) {
-				audio->voicememo_cfg = usr_config;
-				rc = 0;
-			} else
-				rc = -EINVAL;
-			MM_DBG("AUDIO_SET_VOICEMEMO_CONFIG rc %d\n", rc);
-			break;
-		}
-	case AUDIO_PAUSE: {
-			struct rpc_request_hdr rhdr;
-			MM_DBG("AUDIO_PAUSE\n");
-			if (arg == 1)
-				msm_rpc_setup_req(&rhdr, audio->rpc_prog,
-				audio->rpc_ver, SND_VOC_REC_PAUSE_PROC);
-			else
-				msm_rpc_setup_req(&rhdr, audio->rpc_prog,
-				audio->rpc_ver, SND_VOC_REC_RESUME_PROC);
-
-			rc = msm_rpc_write(audio->sndept, &rhdr, sizeof(rhdr));
-			MM_DBG("AUDIO_PAUSE exit %d\n",	rc);
-			break;
-		}
-	default:
-		MM_ERR("IOCTL %d not supported\n", cmd);
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static ssize_t audio_voicememo_read(struct file *file,
-				char __user *buf,
-				size_t count, loff_t *pos)
-{
-	struct audio_voicememo *audio = file->private_data;
-	const char __user *start = buf;
-	int rc = 0;
-
-	mutex_lock(&audio->read_lock);
-
-	MM_DBG("buff read =0x%8x \n", count);
-
-	while (count > 0) {
-		rc = wait_event_interruptible_timeout(audio->read_wait,
-			(audio->in[audio->read_next].used > 0) ||
-			(audio->stopped),
-			msecs_to_jiffies(MSM_AUD_BUFFER_UPDATE_WAIT_MS));
-
-		if (rc == 0) {
-			rc = -ETIMEDOUT;
-			break;
-		} else if (rc < 0)
-			break;
-
-		if (audio->stopped) {
-			rc = -EBUSY;
-			break;
-		}
-		if (count < audio->in[audio->read_next].used) {
-			/* Read must happen in frame boundary. Since driver does
-			 * not split frames, read count must be greater or
-			 * equal to size of existing frames to copy
-			 */
-			MM_DBG("read not in frame boundary\n");
-			break;
-		} else {
-			mutex_lock(&audio->dsp_lock);
-			dma_coherent_post_ops();
-			if (copy_to_user
-				(buf, audio->in[audio->read_next].data,
-				audio->in[audio->read_next].used)) {
-				MM_ERR("invalid addr %x \n", (unsigned int)buf);
-				rc = -EFAULT;
-				mutex_unlock(&audio->dsp_lock);
-				break;
-			}
-			count -= audio->in[audio->read_next].used;
-			audio->byte_count += audio->in[audio->read_next].used;
-			audio->frame_count +=
-			audio->in[audio->read_next].numframes;
-			buf += audio->in[audio->read_next].used;
-			audio->in[audio->read_next].used = 0;
-			mutex_unlock(&audio->dsp_lock);
-			if ((++audio->read_next) == MAX_REC_BUF_COUNT)
-				audio->read_next = 0;
-			if (audio->in[audio->read_next].used == 0)
-				break;  /* No data ready at this moment
-					 * Exit while loop to prevent
-					 * output thread sleep too long
-					 */
-		}
-	}
-	mutex_unlock(&audio->read_lock);
-	if (buf > start)
-		rc = buf - start;
-	MM_DBG("exit return =0x%8x\n", rc);
-	return rc;
-}
-
-static ssize_t audio_voicememo_write(struct file *file,
-				const char __user *buf,
-				size_t count, loff_t *pos)
-{
-	return -EINVAL;
-}
-
-static int audio_voicememo_release(struct inode *inode, struct file *file)
-{
-	struct audio_voicememo *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	audvoicememo_disable(audio);
-	audvoicememo_flush_buf(audio);
-	audio->opened = 0;
-	mutex_unlock(&audio->lock);
-	return 0;
-}
-
-static int audio_voicememo_open(struct inode *inode, struct file *file)
-{
-	struct audio_voicememo *audio = &the_audio_voicememo;
-	int rc;
-
-	mutex_lock(&audio->lock);
-	if (audio->opened) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	rc = audmgr_open(&audio->audmgr);
-
-	if (rc)
-		goto done;
-
-	/*Set default param to None*/
-	memset(&audio->voicememo_cfg, 0, sizeof(audio->voicememo_cfg));
-
-	file->private_data = audio;
-	audio->opened = 1;
-	audio->stopped = 0;
-	rc = 0;
-done:
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static const struct file_operations audio_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audio_voicememo_open,
-	.release	= audio_voicememo_release,
-	.read		= audio_voicememo_read,
-	.write		= audio_voicememo_write,
-	.unlocked_ioctl	= audio_voicememo_ioctl,
-};
-
-struct miscdevice audio_voicememo_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_voicememo",
-	.fops	= &audio_fops,
-};
-
-static int audio_voicememo_probe(struct platform_device *pdev)
-{
-	int rc;
-
-	if ((pdev->id != (SND_VERS_COMP & RPC_VERSION_MAJOR_MASK)) &&
-	    (pdev->id != (SND_VERS2_COMP & RPC_VERSION_MAJOR_MASK)))
-		return -EINVAL;
-
-	mutex_init(&the_audio_voicememo.lock);
-	mutex_init(&the_audio_voicememo.read_lock);
-	mutex_init(&the_audio_voicememo.dsp_lock);
-	init_waitqueue_head(&the_audio_voicememo.read_wait);
-	init_waitqueue_head(&the_audio_voicememo.wait);
-
-	the_audio_voicememo.rec_buf_ptr = dma_alloc_coherent(NULL,
-					MAX_VOICEMEMO_BUF_SIZE,
-					&the_audio_voicememo.phys, GFP_KERNEL);
-	if (the_audio_voicememo.rec_buf_ptr == NULL) {
-		MM_ERR("error allocating memory\n");
-		rc = -ENOMEM;
-		return rc;
-	}
-	the_audio_voicememo.rec_buf_size = MAX_REC_BUF_SIZE;
-	MM_DBG("rec_buf_ptr = 0x%8x, phys = 0x%8x \n",
-		(uint32_t) the_audio_voicememo.rec_buf_ptr, \
-		the_audio_voicememo.phys);
-
-	the_audio_voicememo.sndept = msm_rpc_connect_compatible(SND_PROG,
-					SND_VERS_COMP, MSM_RPC_UNINTERRUPTIBLE);
-	if (IS_ERR(the_audio_voicememo.sndept)) {
-		MM_DBG("connect failed with VERS \
-				= %x, trying again with another API\n",
-				SND_VERS_COMP);
-		the_audio_voicememo.sndept = msm_rpc_connect_compatible(
-					SND_PROG, SND_VERS2_COMP,
-					MSM_RPC_UNINTERRUPTIBLE);
-		if (IS_ERR(the_audio_voicememo.sndept)) {
-			rc = PTR_ERR(the_audio_voicememo.sndept);
-			the_audio_voicememo.sndept = NULL;
-			MM_ERR("Failed to connect to snd svc\n");
-			goto err;
-		}
-		the_audio_voicememo.rpc_ver = SND_VERS2_COMP;
-	} else
-		the_audio_voicememo.rpc_ver = SND_VERS_COMP;
-
-	the_audio_voicememo.task = kthread_run(voicememo_rpc_thread,
-					&the_audio_voicememo, "voicememo_rpc");
-	if (IS_ERR(the_audio_voicememo.task)) {
-		rc = PTR_ERR(the_audio_voicememo.task);
-		the_audio_voicememo.task = NULL;
-		msm_rpc_close(the_audio_voicememo.sndept);
-		the_audio_voicememo.sndept = NULL;
-		MM_ERR("Failed to create voicememo_rpc task\n");
-		goto err;
-	}
-	the_audio_voicememo.rpc_prog = SND_PROG;
-
-	return misc_register(&audio_voicememo_misc);
-err:
-	dma_free_coherent(NULL, MAX_VOICEMEMO_BUF_SIZE,
-		the_audio_voicememo.rec_buf_ptr,
-		the_audio_voicememo.phys);
-	the_audio_voicememo.rec_buf_ptr = NULL;
-	return rc;
-}
-
-static void __exit audio_voicememo_exit(void)
-{
-	/* Close the RPC connection to make thread to comeout */
-	msm_rpc_close(the_audio_voicememo.sndept);
-	the_audio_voicememo.sndept = NULL;
-	kthread_stop(the_audio_voicememo.task);
-	the_audio_voicememo.task = NULL;
-	if (the_audio_voicememo.rec_buf_ptr)
-		dma_free_coherent(NULL, MAX_VOICEMEMO_BUF_SIZE,
-			the_audio_voicememo.rec_buf_ptr,
-			the_audio_voicememo.phys);
-	the_audio_voicememo.rec_buf_ptr = NULL;
-	misc_deregister(&audio_voicememo_misc);
-}
-
-static char audio_voicememo_rpc_name[] = "rs00000000";
-
-static struct platform_driver audio_voicememo_driver = {
-	.probe = audio_voicememo_probe,
-	.driver = {
-		.owner = THIS_MODULE,
-	},
- };
-
-static int __init audio_voicememo_init(void)
-{
-	snprintf(audio_voicememo_rpc_name, sizeof(audio_voicememo_rpc_name),
-			"rs%08x", SND_PROG);
-	audio_voicememo_driver.driver.name = audio_voicememo_rpc_name;
-	return platform_driver_register(&audio_voicememo_driver);
-}
-
-module_init(audio_voicememo_init);
-module_exit(audio_voicememo_exit);
-
-MODULE_DESCRIPTION("MSM Voice Memo driver");
-MODULE_LICENSE("GPL v2");
-MODULE_AUTHOR("QUALCOMM");
diff --git a/arch/arm/mach-msm/qdsp5/audio_wma.c b/arch/arm/mach-msm/qdsp5/audio_wma.c
deleted file mode 100644
index 839739f..0000000
--- a/arch/arm/mach-msm/qdsp5/audio_wma.c
+++ /dev/null
@@ -1,1851 +0,0 @@
-/* audio_wma.c - wma audio decoder driver
- *
- * Copyright (c) 2009, 2011-2012, The Linux Foundation. All rights reserved.
- *
- * Based on the mp3 native driver in arch/arm/mach-msm/qdsp5/audio_mp3.c
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- *
- * All source code in this file is licensed under the following license except
- * where indicated.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you can find it at http://www.fsf.org
- */
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/list.h>
-#include <linux/earlysuspend.h>
-#include <linux/slab.h>
-#include <linux/msm_audio.h>
-#include <linux/msm_audio_wma.h>
-#include <linux/memory_alloc.h>
-#include <linux/msm_ion.h>
-
-#include <mach/msm_adsp.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/qdsp5/qdsp5audppcmdi.h>
-#include <mach/qdsp5/qdsp5audppmsg.h>
-#include <mach/qdsp5/qdsp5audpp.h>
-#include <mach/qdsp5/qdsp5audplaycmdi.h>
-#include <mach/qdsp5/qdsp5audplaymsg.h>
-#include <mach/qdsp5/qdsp5rmtcmdi.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_memtypes.h>
-
-#include "audmgr.h"
-
-/* Size must be power of 2 */
-#define BUFSZ_MAX 	2062	/* Includes meta in size */
-#define BUFSZ_MIN 	1038	/* Includes meta in size */
-#define DMASZ_MAX 	(BUFSZ_MAX * 2)
-#define DMASZ_MIN 	(BUFSZ_MIN * 2)
-
-#define AUDPLAY_INVALID_READ_PTR_OFFSET	0xFFFF
-#define AUDDEC_DEC_WMA 4
-
-#define PCM_BUFSZ_MIN 	8216 	/* Hold one stereo WMA frame and meta out*/
-#define PCM_BUF_MAX_COUNT 5	/* DSP only accepts 5 buffers at most
-				   but support 2 buffers currently */
-#define ROUTING_MODE_FTRT 1
-#define ROUTING_MODE_RT 2
-/* Decoder status received from AUDPPTASK */
-#define  AUDPP_DEC_STATUS_SLEEP	0
-#define	 AUDPP_DEC_STATUS_INIT  1
-#define  AUDPP_DEC_STATUS_CFG   2
-#define  AUDPP_DEC_STATUS_PLAY  3
-
-#define AUDWMA_METAFIELD_MASK 0xFFFF0000
-#define AUDWMA_EOS_FLG_OFFSET 0x0A /* Offset from beginning of buffer */
-#define AUDWMA_EOS_FLG_MASK 0x01
-#define AUDWMA_EOS_NONE 0x0 /* No EOS detected */
-#define AUDWMA_EOS_SET 0x1 /* EOS set in meta field */
-
-#define AUDWMA_EVENT_NUM 10 /* Default number of pre-allocated event packets */
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;		/* Input usage actual DSP produced PCM size  */
-	unsigned addr;
-	unsigned short mfield_sz; /*only useful for data has meta field */
-};
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-struct audwma_suspend_ctl {
-	struct early_suspend node;
-	struct audio *audio;
-};
-#endif
-
-struct audwma_event{
-	struct list_head list;
-	int event_type;
-	union msm_audio_event_payload payload;
-};
-
-struct audio {
-	struct buffer out[2];
-
-	spinlock_t dsp_lock;
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed; /* number of buffers the dsp is waiting for */
-	unsigned out_dma_sz;
-
-	atomic_t out_bytes;
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-
-	/* Host PCM section */
-	struct buffer in[PCM_BUF_MAX_COUNT];
-	struct mutex read_lock;
-	wait_queue_head_t read_wait;	/* Wait queue for read */
-	char *read_data;	/* pointer to reader buffer */
-	int32_t read_phys;	/* physical address of reader buffer */
-	uint8_t read_next;	/* index to input buffers to be read next */
-	uint8_t fill_next;	/* index to buffer that DSP should be filling */
-	uint8_t pcm_buf_count;	/* number of pcm buffer allocated */
-	/* ---- End of Host PCM section */
-
-	struct msm_adsp_module *audplay;
-
-	/* configuration to use on next enable */
-	uint32_t out_sample_rate;
-	uint32_t out_channel_mode;
-
-	struct msm_audio_wma_config wma_config;
-	struct audmgr audmgr;
-
-	/* data allocated for various buffers */
-	char *data;
-	int32_t phys; /* physical address of write buffer */
-	void *map_v_read;
-	void *map_v_write;
-
-	int mfield; /* meta field embedded in data */
-	int rflush; /* Read  flush */
-	int wflush; /* Write flush */
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped, cleared on flush */
-	int pcm_feedback;
-	int buf_refresh;
-	int rmt_resource_released;
-	int teos; /* valid only if tunnel mode & no data left for decoder */
-	enum msm_aud_decoder_state dec_state;	/* Represents decoder state */
-	int reserved; /* A byte is being reserved */
-	char rsv_byte; /* Handle odd length user data */
-
-	const char *module_name;
-	unsigned queue_id;
-	uint16_t dec_id;
-	uint32_t read_ptr_offset;
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	struct audwma_suspend_ctl suspend_ctl;
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *dentry;
-#endif
-
-	wait_queue_head_t wait;
-	struct list_head free_event_queue;
-	struct list_head event_queue;
-	wait_queue_head_t event_wait;
-	spinlock_t event_queue_lock;
-	struct mutex get_event_lock;
-	int event_abort;
-
-	int eq_enable;
-	int eq_needs_commit;
-	audpp_cmd_cfg_object_params_eqalizer eq;
-	audpp_cmd_cfg_object_params_volume vol_pan;
-	struct ion_client *client;
-	struct ion_handle *input_buff_handle;
-	struct ion_handle *output_buff_handle;
-};
-
-static int auddec_dsp_config(struct audio *audio, int enable);
-static void audpp_cmd_cfg_adec_params(struct audio *audio);
-static void audpp_cmd_cfg_routing_mode(struct audio *audio);
-static void audplay_send_data(struct audio *audio, unsigned needed);
-static void audplay_config_hostpcm(struct audio *audio);
-static void audplay_buffer_refresh(struct audio *audio);
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audwma_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload);
-#endif
-
-static int rmt_put_resource(struct audio *audio)
-{
-	struct aud_codec_config_cmd cmd;
-	unsigned short client_idx;
-
-	cmd.cmd_id = RM_CMD_AUD_CODEC_CFG;
-	cmd.client_id = RM_AUD_CLIENT_ID;
-	cmd.task_id = audio->dec_id;
-	cmd.enable = RMT_DISABLE;
-	cmd.dec_type = AUDDEC_DEC_WMA;
-	client_idx = ((cmd.client_id << 8) | cmd.task_id);
-
-	return put_adsp_resource(client_idx, &cmd, sizeof(cmd));
-}
-
-static int rmt_get_resource(struct audio *audio)
-{
-	struct aud_codec_config_cmd cmd;
-	unsigned short client_idx;
-
-	cmd.cmd_id = RM_CMD_AUD_CODEC_CFG;
-	cmd.client_id = RM_AUD_CLIENT_ID;
-	cmd.task_id = audio->dec_id;
-	cmd.enable = RMT_ENABLE;
-	cmd.dec_type = AUDDEC_DEC_WMA;
-	client_idx = ((cmd.client_id << 8) | cmd.task_id);
-
-	return get_adsp_resource(client_idx, &cmd, sizeof(cmd));
-}
-
-/* must be called with audio->lock held */
-static int audio_enable(struct audio *audio)
-{
-	struct audmgr_config cfg;
-	int rc;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled)
-		return 0;
-
-	if (audio->rmt_resource_released == 1) {
-		audio->rmt_resource_released = 0;
-		rc = rmt_get_resource(audio);
-		if (rc) {
-			MM_ERR("ADSP resources are not available for WMA \
-				session 0x%08x on decoder: %d\n Ignoring \
-				error and going ahead with the playback\n",
-				(int)audio, audio->dec_id);
-		}
-	}
-
-	audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-
-	if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK) {
-		cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE;
-		cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000;
-		cfg.def_method = RPC_AUD_DEF_METHOD_PLAYBACK;
-		cfg.codec = RPC_AUD_DEF_CODEC_WMA;
-		cfg.snd_method = RPC_SND_METHOD_MIDI;
-
-		rc = audmgr_enable(&audio->audmgr, &cfg);
-		if (rc < 0) {
-			msm_adsp_dump(audio->audplay);
-			return rc;
-		}
-	}
-
-	if (msm_adsp_enable(audio->audplay)) {
-		MM_ERR("msm_adsp_enable(audplay) failed\n");
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_disable(&audio->audmgr);
-		return -ENODEV;
-	}
-
-	if (audpp_enable(audio->dec_id, audio_dsp_event, audio)) {
-		MM_ERR("audpp_enable() failed\n");
-		msm_adsp_disable(audio->audplay);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_disable(&audio->audmgr);
-		return -ENODEV;
-	}
-
-	audio->enabled = 1;
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audio_disable(struct audio *audio)
-{
-	int rc = 0;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-		auddec_dsp_config(audio, 0);
-		rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-		if (rc == 0)
-			rc = -ETIMEDOUT;
-		else if (audio->dec_state != MSM_AUD_DECODER_STATE_CLOSE)
-			rc = -EFAULT;
-		else
-			rc = 0;
-		audio->stopped = 1;
-		wake_up(&audio->write_wait);
-		wake_up(&audio->read_wait);
-		msm_adsp_disable(audio->audplay);
-		audpp_disable(audio->dec_id, audio);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK) {
-			rc = audmgr_disable(&audio->audmgr);
-			if (rc < 0)
-				msm_adsp_dump(audio->audplay);
-		}
-		audio->out_needed = 0;
-		rmt_put_resource(audio);
-		audio->rmt_resource_released = 1;
-	}
-	return rc;
-}
-
-/* ------------------- dsp --------------------- */
-static void audio_update_pcm_buf_entry(struct audio *audio,
-	uint32_t *payload)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	if (audio->rflush)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < payload[1]; index++) {
-		if (audio->in[audio->fill_next].addr ==
-			payload[2 + index * 2]) {
-			MM_DBG("audio_update_pcm_buf_entry: \
-				in[%d] ready\n", audio->fill_next);
-			audio->in[audio->fill_next].used =
-			payload[3 + index * 2];
-			if ((++audio->fill_next) == audio->pcm_buf_count)
-				audio->fill_next = 0;
-		} else {
-			MM_ERR("audio_update_pcm_buf_entry: \
-				expected=%x ret=%x\n",
-				audio->in[audio->fill_next].addr,
-				payload[1 + index * 2]);
-			break;
-		}
-	}
-	if (audio->in[audio->fill_next].used == 0) {
-		audplay_buffer_refresh(audio);
-	} else {
-		MM_DBG("read cannot keep up\n");
-		audio->buf_refresh = 1;
-	}
-	wake_up(&audio->read_wait);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audplay_dsp_event(void *data, unsigned id, size_t len,
-			      void (*getevent) (void *ptr, size_t len))
-{
-	struct audio *audio = data;
-	uint32_t msg[28];
-
-	getevent(msg, sizeof(msg));
-
-	MM_DBG("msg_id=%x\n", id);
-
-	switch (id) {
-	case AUDPLAY_MSG_DEC_NEEDS_DATA:
-		audplay_send_data(audio, 1);
-		break;
-
-	case AUDPLAY_MSG_BUFFER_UPDATE:
-		audio_update_pcm_buf_entry(audio, msg);
-		break;
-
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audplaytask)\n");
-		break;
-
-	default:
-		MM_ERR("unexpected message from decoder \n");
-		break;
-	}
-}
-
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg)
-{
-	struct audio *audio = private;
-
-	switch (id) {
-	case AUDPP_MSG_STATUS_MSG:{
-			unsigned status = msg[1];
-
-			switch (status) {
-			case AUDPP_DEC_STATUS_SLEEP: {
-				uint16_t reason = msg[2];
-				MM_DBG("decoder status:sleep reason = \
-						0x%04x\n", reason);
-				if ((reason == AUDPP_MSG_REASON_MEM)
-					|| (reason ==
-					AUDPP_MSG_REASON_NODECODER)) {
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_FAILURE;
-					wake_up(&audio->wait);
-				} else if (reason == AUDPP_MSG_REASON_NONE) {
-					/* decoder is in disable state */
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_CLOSE;
-					wake_up(&audio->wait);
-				}
-				break;
-			}
-			case AUDPP_DEC_STATUS_INIT:
-				MM_DBG("decoder status: init\n");
-				if (audio->pcm_feedback)
-					audpp_cmd_cfg_routing_mode(audio);
-				else
-					audpp_cmd_cfg_adec_params(audio);
-				break;
-
-			case AUDPP_DEC_STATUS_CFG:
-				MM_DBG("decoder status: cfg\n");
-				break;
-			case AUDPP_DEC_STATUS_PLAY:
-				MM_DBG("decoder status: play\n");
-				if (audio->pcm_feedback) {
-					audplay_config_hostpcm(audio);
-					audplay_buffer_refresh(audio);
-				}
-				audio->dec_state =
-					MSM_AUD_DECODER_STATE_SUCCESS;
-				wake_up(&audio->wait);
-				break;
-			default:
-				MM_ERR("unknown decoder status\n");
-			}
-			break;
-		}
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_DBG("CFG_MSG ENABLE\n");
-			auddec_dsp_config(audio, 1);
-			audio->out_needed = 0;
-			audio->running = 1;
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-			audpp_dsp_set_eq(audio->dec_id,	audio->eq_enable,
-								&audio->eq);
-			audpp_avsync(audio->dec_id, 22050);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			MM_DBG("CFG_MSG DISABLE\n");
-			audpp_avsync(audio->dec_id, 0);
-			audio->running = 0;
-		} else {
-			MM_DBG("CFG_MSG %d?\n", msg[0]);
-		}
-		break;
-	case AUDPP_MSG_ROUTING_ACK:
-		MM_DBG("ROUTING_ACK mode=%d\n", msg[1]);
-		audpp_cmd_cfg_adec_params(audio);
-		break;
-
-	case AUDPP_MSG_FLUSH_ACK:
-		MM_DBG("FLUSH_ACK\n");
-		audio->wflush = 0;
-		audio->rflush = 0;
-		wake_up(&audio->write_wait);
-		if (audio->pcm_feedback)
-			audplay_buffer_refresh(audio);
-		break;
-	case AUDPP_MSG_PCMDMAMISSED:
-		MM_DBG("PCMDMAMISSED\n");
-		audio->teos = 1;
-		wake_up(&audio->write_wait);
-		break;
-
-	default:
-		MM_ERR("UNKNOWN (%d)\n", id);
-	}
-
-}
-
-static struct msm_adsp_ops audplay_adsp_ops_wma = {
-	.event = audplay_dsp_event,
-};
-
-#define audplay_send_queue0(audio, cmd, len) \
-	msm_adsp_write(audio->audplay, audio->queue_id, \
-			cmd, len)
-
-static int auddec_dsp_config(struct audio *audio, int enable)
-{
-	u16 cfg_dec_cmd[AUDPP_CMD_CFG_DEC_TYPE_LEN / sizeof(unsigned short)];
-
-	memset(cfg_dec_cmd, 0, sizeof(cfg_dec_cmd));
-	cfg_dec_cmd[0] = AUDPP_CMD_CFG_DEC_TYPE;
-	if (enable)
-		cfg_dec_cmd[1 + audio->dec_id] = AUDPP_CMD_UPDATDE_CFG_DEC |
-			AUDPP_CMD_ENA_DEC_V | AUDDEC_DEC_WMA;
-	else
-		cfg_dec_cmd[1 + audio->dec_id] = AUDPP_CMD_UPDATDE_CFG_DEC |
-			AUDPP_CMD_DIS_DEC_V;
-
-	return audpp_send_queue1(&cfg_dec_cmd, sizeof(cfg_dec_cmd));
-}
-
-static void audpp_cmd_cfg_adec_params(struct audio *audio)
-{
-	struct audpp_cmd_cfg_adec_params_wma cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_CMD_CFG_ADEC_PARAMS;
-	cmd.common.length = AUDPP_CMD_CFG_ADEC_PARAMS_WMA_LEN;
-	cmd.common.dec_id = audio->dec_id;
-	cmd.common.input_sampling_frequency = audio->out_sample_rate;
-
-	/*
-	 * Test done for sample with the following configuration
-	 * armdatareqthr 	= 1262
-	 * channelsdecoded 	= 1(MONO)/2(STEREO)
-	 * wmabytespersec 	= Tested with 6003 Bytes per sec
-	 * wmasamplingfreq	= 44100
-	 * wmaencoderopts	= 31
-	 */
-
-	cmd.armdatareqthr = audio->wma_config.armdatareqthr;
-	cmd.channelsdecoded = audio->wma_config.channelsdecoded;
-	cmd.wmabytespersec = audio->wma_config.wmabytespersec;
-	cmd.wmasamplingfreq = audio->wma_config.wmasamplingfreq;
-	cmd.wmaencoderopts = audio->wma_config.wmaencoderopts;
-
-	audpp_send_queue2(&cmd, sizeof(cmd));
-}
-
-static void audpp_cmd_cfg_routing_mode(struct audio *audio)
-{
-	struct audpp_cmd_routing_mode cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPP_CMD_ROUTING_MODE;
-	cmd.object_number = audio->dec_id;
-	if (audio->pcm_feedback)
-		cmd.routing_mode = ROUTING_MODE_FTRT;
-	else
-		cmd.routing_mode = ROUTING_MODE_RT;
-
-	audpp_send_queue1(&cmd, sizeof(cmd));
-}
-
-static void audplay_buffer_refresh(struct audio *audio)
-{
-	struct audplay_cmd_buffer_refresh refresh_cmd;
-
-	refresh_cmd.cmd_id = AUDPLAY_CMD_BUFFER_REFRESH;
-	refresh_cmd.num_buffers = 1;
-	refresh_cmd.buf0_address = audio->in[audio->fill_next].addr;
-	refresh_cmd.buf0_length = audio->in[audio->fill_next].size;
-	refresh_cmd.buf_read_count = 0;
-
-	MM_DBG("buf0_addr=%x buf0_len=%d\n",
-			refresh_cmd.buf0_address,
-			refresh_cmd.buf0_length);
-
-	(void)audplay_send_queue0(audio, &refresh_cmd, sizeof(refresh_cmd));
-}
-
-static void audplay_config_hostpcm(struct audio *audio)
-{
-	struct audplay_cmd_hpcm_buf_cfg cfg_cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	cfg_cmd.cmd_id = AUDPLAY_CMD_HPCM_BUF_CFG;
-	cfg_cmd.max_buffers = audio->pcm_buf_count;
-	cfg_cmd.byte_swap = 0;
-	cfg_cmd.hostpcm_config = (0x8000) | (0x4000);
-	cfg_cmd.feedback_frequency = 1;
-	cfg_cmd.partition_number = 0;
-
-	(void)audplay_send_queue0(audio, &cfg_cmd, sizeof(cfg_cmd));
-}
-
-
-static int audplay_dsp_send_data_avail(struct audio *audio,
-					unsigned idx, unsigned len)
-{
-	struct audplay_cmd_bitstream_data_avail_nt2 cmd;
-
-	cmd.cmd_id		= AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2;
-	if (audio->mfield)
-		cmd.decoder_id = AUDWMA_METAFIELD_MASK |
-			(audio->out[idx].mfield_sz >> 1);
-	else
-		cmd.decoder_id		= audio->dec_id;
-	cmd.buf_ptr		= audio->out[idx].addr;
-	cmd.buf_size		= len/2;
-	cmd.partition_number	= 0;
-	/* complete writes to the input buffer */
-	wmb();
-	return audplay_send_queue0(audio, &cmd, sizeof(cmd));
-}
-
-static void audplay_send_data(struct audio *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (audio->wflush) {
-		audio->out_needed = 1;
-		goto done;
-	}
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			MM_DBG("frame %d free\n", audio->out_tail);
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		MM_DBG("\n"); /* Macro prints the file name and function */
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			MM_DBG("frame %d busy\n", audio->out_tail);
-			audplay_dsp_send_data_avail(audio, audio->out_tail,
-								frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
-done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-
-static void audio_flush(struct audio *audio)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->out[0].used = 0;
-	audio->out[1].used = 0;
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->reserved = 0;
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	atomic_set(&audio->out_bytes, 0);
-}
-
-static void audio_flush_pcm_buf(struct audio *audio)
-{
-	uint8_t index;
-
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < PCM_BUF_MAX_COUNT; index++)
-		audio->in[index].used = 0;
-	audio->buf_refresh = 0;
-	audio->read_next = 0;
-	audio->fill_next = 0;
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audio_ioport_reset(struct audio *audio)
-{
-	/* Make sure read/write thread are free from
-	 * sleep and knowing that system is not able
-	 * to process io request at the moment
-	 */
-	wake_up(&audio->write_wait);
-	mutex_lock(&audio->write_lock);
-	audio_flush(audio);
-	mutex_unlock(&audio->write_lock);
-	wake_up(&audio->read_wait);
-	mutex_lock(&audio->read_lock);
-	audio_flush_pcm_buf(audio);
-	mutex_unlock(&audio->read_lock);
-}
-
-static int audwma_events_pending(struct audio *audio)
-{
-	unsigned long flags;
-	int empty;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	empty = !list_empty(&audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	return empty || audio->event_abort;
-}
-
-static void audwma_reset_event_queue(struct audio *audio)
-{
-	unsigned long flags;
-	struct audwma_event *drv_evt;
-	struct list_head *ptr, *next;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	list_for_each_safe(ptr, next, &audio->event_queue) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audwma_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	list_for_each_safe(ptr, next, &audio->free_event_queue) {
-		drv_evt = list_first_entry(&audio->free_event_queue,
-				struct audwma_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	return;
-}
-
-static long audwma_process_event_req(struct audio *audio, void __user *arg)
-{
-	long rc;
-	struct msm_audio_event usr_evt;
-	struct audwma_event *drv_evt = NULL;
-	int timeout;
-	unsigned long flags;
-
-	if (copy_from_user(&usr_evt, arg, sizeof(struct msm_audio_event)))
-		return -EFAULT;
-
-	timeout = (int) usr_evt.timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(
-				audio->event_wait, audwma_events_pending(audio),
-				msecs_to_jiffies(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(
-			audio->event_wait, audwma_events_pending(audio));
-	}
-
-	if (rc < 0)
-		return rc;
-
-	if (audio->event_abort) {
-		audio->event_abort = 0;
-		return -ENODEV;
-	}
-
-	rc = 0;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	if (!list_empty(&audio->event_queue)) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audwma_event, list);
-		list_del(&drv_evt->list);
-	}
-
-	if (drv_evt) {
-		usr_evt.event_type = drv_evt->event_type;
-		usr_evt.event_payload = drv_evt->payload;
-		list_add_tail(&drv_evt->list, &audio->free_event_queue);
-	} else
-		rc = -1;
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	if (!rc && copy_to_user(arg, &usr_evt, sizeof(usr_evt)))
-		rc = -EFAULT;
-
-	return rc;
-}
-
-static int audio_enable_eq(struct audio *audio, int enable)
-{
-	if (audio->eq_enable == enable && !audio->eq_needs_commit)
-		return 0;
-
-	audio->eq_enable = enable;
-
-	if (audio->running) {
-		audpp_dsp_set_eq(audio->dec_id, enable, &audio->eq);
-		audio->eq_needs_commit = 0;
-	}
-	return 0;
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = -EINVAL;
-	unsigned long flags = 0;
-	uint16_t enable_mask;
-	int enable;
-	int prev_state;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	int len = 0;
-
-	MM_DBG("cmd = %d\n", cmd);
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		stats.byte_count = audpp_avsync_byte_count(audio->dec_id);
-		stats.sample_count = audpp_avsync_sample_count(audio->dec_id);
-		if (copy_to_user((void *)arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-
-	switch (cmd) {
-	case AUDIO_ENABLE_AUDPP:
-		if (copy_from_user(&enable_mask, (void *) arg,
-						sizeof(enable_mask))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		enable = (enable_mask & EQ_ENABLE) ? 1 : 0;
-		audio_enable_eq(audio, enable);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-	case AUDIO_SET_VOLUME:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.volume = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_PAN:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.pan = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_EQ:
-		prev_state = audio->eq_enable;
-		audio->eq_enable = 0;
-		if (copy_from_user(&audio->eq.num_bands, (void *) arg,
-				sizeof(audio->eq) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2))) {
-			rc = -EFAULT;
-			break;
-		}
-		audio->eq_enable = prev_state;
-		audio->eq_needs_commit = 1;
-		rc = 0;
-		break;
-	}
-
-	if (-EINVAL != rc)
-		return rc;
-
-	if (cmd == AUDIO_GET_EVENT) {
-		MM_DBG("AUDIO_GET_EVENT\n");
-		if (mutex_trylock(&audio->get_event_lock)) {
-			rc = audwma_process_event_req(audio,
-					(void __user *) arg);
-			mutex_unlock(&audio->get_event_lock);
-		} else
-			rc = -EBUSY;
-		return rc;
-	}
-
-	if (cmd == AUDIO_ABORT_GET_EVENT) {
-		audio->event_abort = 1;
-		wake_up(&audio->event_wait);
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		MM_DBG("AUDIO_START\n");
-		rc = audio_enable(audio);
-		if (!rc) {
-			rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-			MM_INFO("dec_state %d rc = %d\n", audio->dec_state, rc);
-
-			if (audio->dec_state != MSM_AUD_DECODER_STATE_SUCCESS)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		break;
-	case AUDIO_STOP:
-		MM_DBG("AUDIO_STOP\n");
-		rc = audio_disable(audio);
-		audio_ioport_reset(audio);
-		audio->stopped = 0;
-		break;
-	case AUDIO_FLUSH:
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audio_ioport_reset(audio);
-		if (audio->running) {
-			audpp_flush(audio->dec_id);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-	case AUDIO_SET_CONFIG: {
-		struct msm_audio_config config;
-		if (copy_from_user(&config, (void *) arg, sizeof(config))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (config.channel_count == 1) {
-			config.channel_count = AUDPP_CMD_PCM_INTF_MONO_V;
-		} else if (config.channel_count == 2) {
-			config.channel_count = AUDPP_CMD_PCM_INTF_STEREO_V;
-		} else {
-			rc = -EINVAL;
-			break;
-		}
-		audio->mfield = config.meta_field;
-		audio->out_sample_rate = config.sample_rate;
-		audio->out_channel_mode = config.channel_count;
-		rc = 0;
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config config;
-		config.buffer_size = (audio->out_dma_sz >> 1);
-		config.buffer_count = 2;
-		config.sample_rate = audio->out_sample_rate;
-		if (audio->out_channel_mode == AUDPP_CMD_PCM_INTF_MONO_V)
-			config.channel_count = 1;
-		else
-			config.channel_count = 2;
-		config.meta_field = 0;
-		config.unused[0] = 0;
-		config.unused[1] = 0;
-		config.unused[2] = 0;
-		if (copy_to_user((void *) arg, &config, sizeof(config)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-
-		break;
-	}
-	case AUDIO_GET_WMA_CONFIG:{
-			if (copy_to_user((void *)arg, &audio->wma_config,
-				sizeof(audio->wma_config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_SET_WMA_CONFIG:{
-		struct msm_audio_wma_config usr_config;
-
-		if (copy_from_user
-			(&usr_config, (void *)arg,
-			sizeof(usr_config))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		audio->wma_config = usr_config;
-		rc = 0;
-		break;
-	}
-	case AUDIO_GET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			config.pcm_feedback = audio->pcm_feedback;
-			config.buffer_count = PCM_BUF_MAX_COUNT;
-			config.buffer_size = PCM_BUFSZ_MIN;
-			if (copy_to_user((void *)arg, &config,
-					 sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_SET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			if (copy_from_user
-			    (&config, (void *)arg, sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-			if (config.pcm_feedback != audio->pcm_feedback) {
-				MM_ERR("Not sufficient permission to"
-					 "change the playback mode\n");
-				rc = -EACCES;
-				break;
-			}
-			if ((config.buffer_count > PCM_BUF_MAX_COUNT) ||
-			    (config.buffer_count == 1))
-				config.buffer_count = PCM_BUF_MAX_COUNT;
-
-			if (config.buffer_size < PCM_BUFSZ_MIN)
-				config.buffer_size = PCM_BUFSZ_MIN;
-
-			/* Check if pcm feedback is required */
-			if ((config.pcm_feedback) && (!audio->read_data)) {
-				MM_DBG("allocate PCM buffer %d\n",
-						config.buffer_count *
-						config.buffer_size);
-				handle = ion_alloc(audio->client,
-					(config.buffer_size *
-					config.buffer_count),
-					SZ_4K, ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-				if (IS_ERR_OR_NULL(handle)) {
-					MM_ERR("Unable to alloc I/P buffs\n");
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-					break;
-				}
-
-				audio->input_buff_handle = handle;
-
-				rc = ion_phys(audio->client ,
-					handle, &addr, &len);
-				if (rc) {
-					MM_ERR("Invalid phy: %x sz: %x\n",
-						(unsigned int) addr,
-						(unsigned int) len);
-					ion_free(audio->client, handle);
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-					break;
-				} else {
-					MM_INFO("Got valid phy: %x sz: %x\n",
-						(unsigned int) audio->read_phys,
-						(unsigned int) len);
-				}
-				audio->read_phys = (int32_t)addr;
-
-				rc = ion_handle_get_flags(audio->client,
-					handle, &ionflag);
-				if (rc) {
-					MM_ERR("could not get flags\n");
-					ion_free(audio->client, handle);
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-					break;
-				}
-
-				audio->map_v_read = ion_map_kernel(
-					audio->client, handle);
-				if (IS_ERR(audio->map_v_read)) {
-					MM_ERR("map of read buf failed\n");
-					ion_free(audio->client, handle);
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-				} else {
-					uint8_t index;
-					uint32_t offset = 0;
-					audio->read_data =
-						audio->map_v_read;
-					audio->buf_refresh = 0;
-					audio->pcm_buf_count =
-					    config.buffer_count;
-					audio->read_next = 0;
-					audio->fill_next = 0;
-
-					for (index = 0;
-					     index < config.buffer_count;
-					     index++) {
-						audio->in[index].data =
-						    audio->read_data + offset;
-						audio->in[index].addr =
-						    audio->read_phys + offset;
-						audio->in[index].size =
-						    config.buffer_size;
-						audio->in[index].used = 0;
-						offset += config.buffer_size;
-					}
-					MM_DBG("read buf: phy addr \
-						0x%08x kernel addr 0x%08x\n",
-						audio->read_phys,
-						(int)audio->read_data);
-					rc = 0;
-				}
-			} else {
-				rc = 0;
-			}
-			break;
-		}
-	case AUDIO_PAUSE:
-		MM_DBG("AUDIO_PAUSE %ld\n", arg);
-		rc = audpp_pause(audio->dec_id, (int) arg);
-		break;
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-/* Only useful in tunnel-mode */
-static int audio_fsync(struct file *file, loff_t a, loff_t b,
-	int datasync)
-{
-	struct audio *audio = file->private_data;
-	struct buffer *frame;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	if (!audio->running || audio->pcm_feedback) {
-		rc = -EINVAL;
-		goto done_nolock;
-	}
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(!audio->out[0].used &&
-		!audio->out[1].used &&
-		audio->out_needed) || audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (audio->reserved) {
-		MM_DBG("send reserved byte\n");
-		frame = audio->out + audio->out_tail;
-		((char *) frame->data)[0] = audio->rsv_byte;
-		((char *) frame->data)[1] = 0;
-		frame->used = 2;
-		audplay_send_data(audio, 0);
-
-		rc = wait_event_interruptible(audio->write_wait,
-			(!audio->out[0].used &&
-			!audio->out[1].used &&
-			audio->out_needed) || audio->wflush);
-
-		if (rc < 0)
-			goto done;
-		else if (audio->wflush) {
-			rc = -EBUSY;
-			goto done;
-		}
-	}
-
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		audio->teos || audio->wflush);
-
-	if (audio->wflush)
-		rc = -EBUSY;
-
-done:
-	mutex_unlock(&audio->write_lock);
-done_nolock:
-	return rc;
-}
-
-static ssize_t audio_read(struct file *file, char __user *buf, size_t count,
-			  loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	int rc = 0;
-
-	if (!audio->pcm_feedback)
-		return 0; /* PCM feedback is not enabled. Nothing to read */
-
-	mutex_lock(&audio->read_lock);
-	MM_DBG("%d \n", count);
-	while (count > 0) {
-		rc = wait_event_interruptible(audio->read_wait,
-			(audio->in[audio->read_next].used > 0) ||
-			(audio->stopped) || (audio->rflush));
-
-		if (rc < 0)
-			break;
-
-		if (audio->stopped || audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (count < audio->in[audio->read_next].used) {
-			/* Read must happen in frame boundary. Since driver
-			   does not know frame size, read count must be greater
-			   or equal to size of PCM samples */
-			MM_DBG("audio_read: no partial frame done reading\n");
-			break;
-		} else {
-			MM_DBG("audio_read: read from in[%d]\n",
-					audio->read_next);
-			/* order reads from the output buffer */
-			rmb();
-			if (copy_to_user
-			    (buf, audio->in[audio->read_next].data,
-			     audio->in[audio->read_next].used)) {
-				MM_ERR("invalid addr %x \n", (unsigned int)buf);
-				rc = -EFAULT;
-				break;
-			}
-			count -= audio->in[audio->read_next].used;
-			buf += audio->in[audio->read_next].used;
-			audio->in[audio->read_next].used = 0;
-			if ((++audio->read_next) == audio->pcm_buf_count)
-				audio->read_next = 0;
-			break;	/* Force to exit while loop
-				 * to prevent output thread
-				 * sleep too long if data is
-				 * not ready at this moment.
-				 */
-		}
-	}
-
-	/* don't feed output buffer to HW decoder during flushing
-	 * buffer refresh command will be sent once flush completes
-	 * send buf refresh command here can confuse HW decoder
-	 */
-	if (audio->buf_refresh && !audio->rflush) {
-		audio->buf_refresh = 0;
-		MM_DBG("kick start pcm feedback again\n");
-		audplay_buffer_refresh(audio);
-	}
-
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		rc = buf - start;
-
-	MM_DBG("read %d bytes\n", rc);
-	return rc;
-}
-
-static int audwma_process_eos(struct audio *audio,
-		const char __user *buf_start, unsigned short mfield_size)
-{
-	int rc = 0;
-	struct buffer *frame;
-	char *buf_ptr;
-
-	if (audio->reserved) {
-		MM_DBG("flush reserve byte\n");
-		frame = audio->out + audio->out_head;
-		buf_ptr = frame->data;
-		rc = wait_event_interruptible(audio->write_wait,
-				(frame->used == 0)
-				|| (audio->stopped)
-				|| (audio->wflush));
-		if (rc < 0)
-			goto done;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			goto done;
-		}
-
-		buf_ptr[0] = audio->rsv_byte;
-		buf_ptr[1] = 0;
-		audio->out_head ^= 1;
-		frame->mfield_sz = 0;
-		frame->used = 2;
-		audio->reserved = 0;
-		audplay_send_data(audio, 0);
-	}
-
-	frame = audio->out + audio->out_head;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	audplay_send_data(audio, 0);
-done:
-	return rc;
-}
-
-static ssize_t audio_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	size_t xfer;
-	char *cpy_ptr;
-	int rc = 0, eos_condition = AUDWMA_EOS_NONE;
-	unsigned dsize;
-	unsigned short mfield_size = 0;
-
-	MM_DBG("cnt=%d\n", count);
-
-	mutex_lock(&audio->write_lock);
-	while (count > 0) {
-		frame = audio->out + audio->out_head;
-		cpy_ptr = frame->data;
-		dsize = 0;
-		rc = wait_event_interruptible(audio->write_wait,
-					      (frame->used == 0)
-					      || (audio->stopped)
-						  || (audio->wflush));
-		if (rc < 0)
-			break;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			break;
-		}
-		if (audio->mfield) {
-			if (buf == start) {
-				/* Processing beginning of user buffer */
-				if (__get_user(mfield_size,
-					(unsigned short __user *) buf)) {
-					rc = -EFAULT;
-					break;
-				} else  if (mfield_size > count) {
-					rc = -EINVAL;
-					break;
-				}
-				MM_DBG("audio_write: mf offset_val %x\n",
-						mfield_size);
-				if (copy_from_user(cpy_ptr, buf, mfield_size)) {
-					rc = -EFAULT;
-					break;
-				}
-				/* Check if EOS flag is set and buffer has
-				 * contains just meta field
-				 */
-				if (cpy_ptr[AUDWMA_EOS_FLG_OFFSET] &
-						 AUDWMA_EOS_FLG_MASK) {
-					MM_DBG("audio_write: EOS SET\n");
-					eos_condition = AUDWMA_EOS_SET;
-					if (mfield_size == count) {
-						buf += mfield_size;
-						break;
-					} else
-						cpy_ptr[AUDWMA_EOS_FLG_OFFSET]
-							&= ~AUDWMA_EOS_FLG_MASK;
-				}
-				cpy_ptr += mfield_size;
-				count -= mfield_size;
-				dsize += mfield_size;
-				buf += mfield_size;
-			} else {
-				mfield_size = 0;
-				MM_DBG("audio_write: continuous buffer\n");
-			}
-			frame->mfield_sz = mfield_size;
-		}
-
-		if (audio->reserved) {
-			MM_DBG("append reserved byte %x\n", audio->rsv_byte);
-			*cpy_ptr = audio->rsv_byte;
-			xfer = (count > ((frame->size - mfield_size) - 1)) ?
-				(frame->size - mfield_size) - 1 : count;
-			cpy_ptr++;
-			dsize += 1;
-			audio->reserved = 0;
-		} else
-			xfer = (count > (frame->size - mfield_size)) ?
-				(frame->size - mfield_size) : count;
-
-		if (copy_from_user(cpy_ptr, buf, xfer)) {
-			rc = -EFAULT;
-			break;
-		}
-
-		dsize += xfer;
-		if (dsize & 1) {
-			audio->rsv_byte = ((char *) frame->data)[dsize - 1];
-			MM_DBG("odd length buf reserve last byte %x\n",
-					audio->rsv_byte);
-			audio->reserved = 1;
-			dsize--;
-		}
-		count -= xfer;
-		buf += xfer;
-
-		if (dsize > 0) {
-			audio->out_head ^= 1;
-			frame->used = dsize;
-			audplay_send_data(audio, 0);
-		}
-	}
-	if (eos_condition == AUDWMA_EOS_SET)
-		rc = audwma_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	if (!rc) {
-		if (buf > start)
-			return buf - start;
-	}
-	return rc;
-}
-
-static int audio_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	MM_INFO("audio instance 0x%08x freeing\n", (int)audio);
-	mutex_lock(&audio->lock);
-	audio_disable(audio);
-	if (audio->rmt_resource_released == 0)
-		rmt_put_resource(audio);
-	audio_flush(audio);
-	audio_flush_pcm_buf(audio);
-	msm_adsp_put(audio->audplay);
-	audpp_adec_free(audio->dec_id);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	unregister_early_suspend(&audio->suspend_ctl.node);
-#endif
-	audio->event_abort = 1;
-	wake_up(&audio->event_wait);
-	audwma_reset_event_queue(audio);
-	ion_unmap_kernel(audio->client, audio->output_buff_handle);
-	ion_free(audio->client, audio->output_buff_handle);
-	if (audio->input_buff_handle != NULL) {
-		ion_unmap_kernel(audio->client, audio->input_buff_handle);
-		ion_free(audio->client, audio->input_buff_handle);
-	}
-	ion_client_destroy(audio->client);
-	mutex_unlock(&audio->lock);
-#ifdef CONFIG_DEBUG_FS
-	if (audio->dentry)
-		debugfs_remove(audio->dentry);
-#endif
-	kfree(audio);
-	return 0;
-}
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audwma_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload)
-{
-	struct audwma_event *e_node = NULL;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-
-	if (!list_empty(&audio->free_event_queue)) {
-		e_node = list_first_entry(&audio->free_event_queue,
-				struct audwma_event, list);
-		list_del(&e_node->list);
-	} else {
-		e_node = kmalloc(sizeof(struct audwma_event), GFP_ATOMIC);
-		if (!e_node) {
-			MM_ERR("No mem to post event %d\n", type);
-			spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-			return;
-		}
-	}
-
-	e_node->event_type = type;
-	e_node->payload = payload;
-
-	list_add_tail(&e_node->list, &audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	wake_up(&audio->event_wait);
-}
-
-static void audwma_suspend(struct early_suspend *h)
-{
-	struct audwma_suspend_ctl *ctl =
-		container_of(h, struct audwma_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audwma_post_event(ctl->audio, AUDIO_EVENT_SUSPEND, payload);
-}
-
-static void audwma_resume(struct early_suspend *h)
-{
-	struct audwma_suspend_ctl *ctl =
-		container_of(h, struct audwma_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audwma_post_event(ctl->audio, AUDIO_EVENT_RESUME, payload);
-}
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-static ssize_t audwma_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static ssize_t audwma_debug_read(struct file *file, char __user *buf,
-			  size_t count, loff_t *ppos)
-{
-	const int debug_bufmax = 4096;
-	static char buffer[4096];
-	int n = 0, i;
-	struct audio *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	n = scnprintf(buffer, debug_bufmax, "opened %d\n", audio->opened);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "enabled %d\n", audio->enabled);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "stopped %d\n", audio->stopped);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "pcm_feedback %d\n", audio->pcm_feedback);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_buf_sz %d\n", audio->out[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "pcm_buf_count %d \n", audio->pcm_buf_count);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "pcm_buf_sz %d \n", audio->in[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "volume %x \n", audio->vol_pan.volume);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "sample rate %d \n", audio->out_sample_rate);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-		"channel mode %d \n", audio->out_channel_mode);
-	mutex_unlock(&audio->lock);
-	/* Following variables are only useful for debugging when
-	 * when playback halts unexpectedly. Thus, no mutual exclusion
-	 * enforced
-	 */
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "wflush %d\n", audio->wflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "rflush %d\n", audio->rflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "running %d \n", audio->running);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"dec state %d \n", audio->dec_state);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_needed %d \n", audio->out_needed);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_head %d \n", audio->out_head);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_tail %d \n", audio->out_tail);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out[0].used %d \n", audio->out[0].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out[1].used %d \n", audio->out[1].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "buffer_refresh %d \n", audio->buf_refresh);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "read_next %d \n", audio->read_next);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "fill_next %d \n", audio->fill_next);
-	for (i = 0; i < audio->pcm_buf_count; i++)
-		n += scnprintf(buffer + n, debug_bufmax - n,
-			"in[%d].size %d \n", i, audio->in[i].used);
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations audwma_debug_fops = {
-	.read = audwma_debug_read,
-	.open = audwma_debug_open,
-};
-#endif
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = NULL;
-	int rc, dec_attrb, decid, i;
-	unsigned mem_sz = DMASZ_MAX;
-	struct audwma_event *e_node = NULL;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	struct ion_client *client = NULL;
-	int len = 0;
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_wma_" + 5];
-#endif
-
-	/* Allocate Mem for audio instance */
-	audio = kzalloc(sizeof(struct audio), GFP_KERNEL);
-	if (!audio) {
-		MM_ERR("no memory to allocate audio instance \n");
-		rc = -ENOMEM;
-		goto done;
-	}
-	MM_INFO("audio instance 0x%08x created\n", (int)audio);
-
-	/* Allocate the decoder */
-	dec_attrb = AUDDEC_DEC_WMA;
-	if ((file->f_mode & FMODE_WRITE) &&
-			(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_NONTUNNEL;
-		audio->pcm_feedback = NON_TUNNEL_MODE_PLAYBACK;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_TUNNEL;
-		audio->pcm_feedback = TUNNEL_MODE_PLAYBACK;
-	} else {
-		kfree(audio);
-		rc = -EACCES;
-		goto done;
-	}
-
-	decid = audpp_adec_alloc(dec_attrb, &audio->module_name,
-			&audio->queue_id);
-
-	if (decid < 0) {
-		MM_ERR("No free decoder available, freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENODEV;
-		kfree(audio);
-		goto done;
-	}
-	audio->dec_id = decid & MSM_AUD_DECODER_MASK;
-
-	client = msm_ion_client_create(UINT_MAX, "Audio_WMA_Client");
-	if (IS_ERR_OR_NULL(client)) {
-		pr_err("Unable to create ION client\n");
-		rc = -ENOMEM;
-		goto client_create_error;
-	}
-	audio->client = client;
-
-	handle = ion_alloc(client, mem_sz, SZ_4K,
-		ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-	if (IS_ERR_OR_NULL(handle)) {
-		MM_ERR("Unable to create allocate O/P buffers\n");
-		rc = -ENOMEM;
-		goto output_buff_alloc_error;
-	}
-	audio->output_buff_handle = handle;
-
-	rc = ion_phys(client, handle, &addr, &len);
-	if (rc) {
-		MM_ERR("O/P buffers:Invalid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-		goto output_buff_get_phys_error;
-	} else {
-		MM_INFO("O/P buffers:valid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-	}
-	audio->phys = (int32_t)addr;
-
-
-	rc = ion_handle_get_flags(client, handle, &ionflag);
-	if (rc) {
-		MM_ERR("could not get flags for the handle\n");
-		goto output_buff_get_flags_error;
-	}
-
-	audio->map_v_write = ion_map_kernel(client, handle);
-	if (IS_ERR(audio->map_v_write)) {
-		MM_ERR("could not map write buffers\n");
-		rc = -ENOMEM;
-		goto output_buff_map_error;
-	}
-	audio->data = audio->map_v_write;
-	MM_DBG("write buf: phy addr 0x%08x kernel addr 0x%08x\n",
-		audio->phys, (int)audio->data);
-
-	audio->out_dma_sz = mem_sz;
-
-	if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK) {
-		rc = audmgr_open(&audio->audmgr);
-		if (rc) {
-			MM_ERR("audmgr open failed, freeing instance \
-					0x%08x\n", (int)audio);
-			goto err;
-		}
-	}
-
-	rc = msm_adsp_get(audio->module_name, &audio->audplay,
-			&audplay_adsp_ops_wma, audio);
-	if (rc) {
-		MM_ERR("failed to get %s module, freeing instance 0x%08x\n",
-				audio->module_name, (int)audio);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_close(&audio->audmgr);
-		goto err;
-	}
-
-	rc = rmt_get_resource(audio);
-	if (rc) {
-		MM_ERR("ADSP resources are not available for WMA session \
-			 0x%08x on decoder: %d\n", (int)audio, audio->dec_id);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_close(&audio->audmgr);
-		msm_adsp_put(audio->audplay);
-		goto err;
-	}
-
-	audio->input_buff_handle = NULL;
-	mutex_init(&audio->lock);
-	mutex_init(&audio->write_lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->get_event_lock);
-	spin_lock_init(&audio->dsp_lock);
-	init_waitqueue_head(&audio->write_wait);
-	init_waitqueue_head(&audio->read_wait);
-	INIT_LIST_HEAD(&audio->free_event_queue);
-	INIT_LIST_HEAD(&audio->event_queue);
-	init_waitqueue_head(&audio->wait);
-	init_waitqueue_head(&audio->event_wait);
-	spin_lock_init(&audio->event_queue_lock);
-
-	audio->out[0].data = audio->data + 0;
-	audio->out[0].addr = audio->phys + 0;
-	audio->out[0].size = audio->out_dma_sz >> 1;
-
-	audio->out[1].data = audio->data + audio->out[0].size;
-	audio->out[1].addr = audio->phys + audio->out[0].size;
-	audio->out[1].size = audio->out[0].size;
-
-	audio->wma_config.armdatareqthr =  1262;
-	audio->wma_config.channelsdecoded = 2;
-	audio->wma_config.wmabytespersec = 6003;
-	audio->wma_config.wmasamplingfreq = 44100;
-	audio->wma_config.wmaencoderopts = 31;
-
-	audio->out_sample_rate = 44100;
-	audio->out_channel_mode = AUDPP_CMD_PCM_INTF_STEREO_V;
-
-	audio->vol_pan.volume = 0x2000;
-
-	audio_flush(audio);
-
-	file->private_data = audio;
-	audio->opened = 1;
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof name, "msm_wma_%04x", audio->dec_id);
-	audio->dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
-				NULL, (void *) audio,
-				&audwma_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		MM_DBG("debugfs_create_file failed\n");
-#endif
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	audio->suspend_ctl.node.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
-	audio->suspend_ctl.node.resume = audwma_resume;
-	audio->suspend_ctl.node.suspend = audwma_suspend;
-	audio->suspend_ctl.audio = audio;
-	register_early_suspend(&audio->suspend_ctl.node);
-#endif
-	for (i = 0; i < AUDWMA_EVENT_NUM; i++) {
-		e_node = kmalloc(sizeof(struct audwma_event), GFP_KERNEL);
-		if (e_node)
-			list_add_tail(&e_node->list, &audio->free_event_queue);
-		else {
-			MM_ERR("event pkt alloc failed\n");
-			break;
-		}
-	}
-done:
-	return rc;
-err:
-	ion_unmap_kernel(client, audio->output_buff_handle);
-output_buff_map_error:
-output_buff_get_phys_error:
-output_buff_get_flags_error:
-	ion_free(client, audio->output_buff_handle);
-output_buff_alloc_error:
-	ion_client_destroy(client);
-client_create_error:
-	audpp_adec_free(audio->dec_id);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_wma_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audio_open,
-	.release	= audio_release,
-	.read 		= audio_read,
-	.write		= audio_write,
-	.unlocked_ioctl	= audio_ioctl,
-	.fsync 		= audio_fsync,
-};
-
-struct miscdevice audio_wma_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_wma",
-	.fops	= &audio_wma_fops,
-};
-
-static int __init audio_init(void)
-{
-	return misc_register(&audio_wma_misc);
-}
-
-device_initcall(audio_init);
diff --git a/arch/arm/mach-msm/qdsp5/audio_wmapro.c b/arch/arm/mach-msm/qdsp5/audio_wmapro.c
deleted file mode 100644
index 6a1d1d6..0000000
--- a/arch/arm/mach-msm/qdsp5/audio_wmapro.c
+++ /dev/null
@@ -1,1837 +0,0 @@
-/* audio_wmapro.c - wmapro audio decoder driver
- *
- * Based on the mp3 native driver in arch/arm/mach-msm/qdsp5/audio_mp3.c
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2009-2012, The Linux Foundation. All rights reserved.
- *
- * All source code in this file is licensed under the following license except
- * where indicated.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you can find it at http://www.fsf.org
- */
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/list.h>
-#include <linux/earlysuspend.h>
-#include <linux/slab.h>
-#include <linux/msm_audio.h>
-#include <linux/memory_alloc.h>
-#include <linux/msm_audio_wmapro.h>
-#include <linux/msm_ion.h>
-
-#include <mach/msm_adsp.h>
-#include <mach/qdsp5/qdsp5audppcmdi.h>
-#include <mach/qdsp5/qdsp5audppmsg.h>
-#include <mach/qdsp5/qdsp5audpp.h>
-#include <mach/qdsp5/qdsp5audplaycmdi.h>
-#include <mach/qdsp5/qdsp5audplaymsg.h>
-#include <mach/qdsp5/qdsp5rmtcmdi.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_memtypes.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-
-#include "audmgr.h"
-
-/* Size must be power of 2 */
-#define BUFSZ_MAX	8206	/* Includes meta in size */
-#define BUFSZ_MIN 	2062	/* Includes meta in size */
-#define DMASZ_MAX 	(BUFSZ_MAX * 2)
-#define DMASZ_MIN 	(BUFSZ_MIN * 2)
-
-#define AUDPLAY_INVALID_READ_PTR_OFFSET	0xFFFF
-#define AUDDEC_DEC_WMAPRO 13
-
-#define PCM_BUFSZ_MIN 	8216 	/* Hold one stereo WMAPRO frame and meta out*/
-#define PCM_BUF_MAX_COUNT 5	/* DSP only accepts 5 buffers at most
-				   but support 2 buffers currently */
-#define ROUTING_MODE_FTRT 1
-#define ROUTING_MODE_RT 2
-/* Decoder status received from AUDPPTASK */
-#define  AUDPP_DEC_STATUS_SLEEP	0
-#define	 AUDPP_DEC_STATUS_INIT  1
-#define  AUDPP_DEC_STATUS_CFG   2
-#define  AUDPP_DEC_STATUS_PLAY  3
-
-#define AUDWMAPRO_METAFIELD_MASK 0xFFFF0000
-#define AUDWMAPRO_EOS_FLG_OFFSET 0x0A /* Offset from beginning of buffer */
-#define AUDWMAPRO_EOS_FLG_MASK 0x01
-#define AUDWMAPRO_EOS_NONE 0x0 /* No EOS detected */
-#define AUDWMAPRO_EOS_SET 0x1 /* EOS set in meta field */
-
-#define AUDWMAPRO_EVENT_NUM 10 /* Default no. of pre-allocated event packets */
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;		/* Input usage actual DSP produced PCM size  */
-	unsigned addr;
-	unsigned short mfield_sz; /*only useful for data has meta field */
-};
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-struct audwmapro_suspend_ctl {
-	struct early_suspend node;
-	struct audio *audio;
-};
-#endif
-
-struct audwmapro_event{
-	struct list_head list;
-	int event_type;
-	union msm_audio_event_payload payload;
-};
-
-struct audio {
-	struct buffer out[2];
-
-	spinlock_t dsp_lock;
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed; /* number of buffers the dsp is waiting for */
-	unsigned out_dma_sz;
-
-	atomic_t out_bytes;
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-
-	/* Host PCM section */
-	struct buffer in[PCM_BUF_MAX_COUNT];
-	struct mutex read_lock;
-	wait_queue_head_t read_wait;	/* Wait queue for read */
-	char *read_data;	/* pointer to reader buffer */
-	int32_t read_phys;	/* physical address of reader buffer */
-	uint8_t read_next;	/* index to input buffers to be read next */
-	uint8_t fill_next;	/* index to buffer that DSP should be filling */
-	uint8_t pcm_buf_count;	/* number of pcm buffer allocated */
-	/* ---- End of Host PCM section */
-
-	struct msm_adsp_module *audplay;
-
-	/* configuration to use on next enable */
-	uint32_t out_sample_rate;
-	uint32_t out_channel_mode;
-
-	struct msm_audio_wmapro_config wmapro_config;
-	struct audmgr audmgr;
-
-	/* data allocated for various buffers */
-	char *data;
-	int32_t phys; /* physical address of write buffer */
-	void *map_v_read;
-	void *map_v_write;
-
-	int mfield; /* meta field embedded in data */
-	int rflush; /* Read  flush */
-	int wflush; /* Write flush */
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped, cleared on flush */
-	int pcm_feedback;
-	int buf_refresh;
-	int rmt_resource_released;
-	int teos; /* valid only if tunnel mode & no data left for decoder */
-	enum msm_aud_decoder_state dec_state;	/* Represents decoder state */
-	int reserved; /* A byte is being reserved */
-	char rsv_byte; /* Handle odd length user data */
-
-	const char *module_name;
-	unsigned queue_id;
-	uint16_t dec_id;
-	uint32_t read_ptr_offset;
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	struct audwmapro_suspend_ctl suspend_ctl;
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *dentry;
-#endif
-
-	wait_queue_head_t wait;
-	struct list_head free_event_queue;
-	struct list_head event_queue;
-	wait_queue_head_t event_wait;
-	spinlock_t event_queue_lock;
-	struct mutex get_event_lock;
-	int event_abort;
-
-	int eq_enable;
-	int eq_needs_commit;
-	audpp_cmd_cfg_object_params_eqalizer eq;
-	audpp_cmd_cfg_object_params_volume vol_pan;
-	struct ion_client *client;
-	struct ion_handle *input_buff_handle;
-	struct ion_handle *output_buff_handle;
-};
-
-static int auddec_dsp_config(struct audio *audio, int enable);
-static void audpp_cmd_cfg_adec_params(struct audio *audio);
-static void audpp_cmd_cfg_routing_mode(struct audio *audio);
-static void audplay_send_data(struct audio *audio, unsigned needed);
-static void audplay_config_hostpcm(struct audio *audio);
-static void audplay_buffer_refresh(struct audio *audio);
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audwmapro_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload);
-#endif
-
-static int rmt_put_resource(struct audio *audio)
-{
-	struct aud_codec_config_cmd cmd;
-	unsigned short client_idx;
-
-	cmd.cmd_id = RM_CMD_AUD_CODEC_CFG;
-	cmd.client_id = RM_AUD_CLIENT_ID;
-	cmd.task_id = audio->dec_id;
-	cmd.enable = RMT_DISABLE;
-	cmd.dec_type = AUDDEC_DEC_WMAPRO;
-	client_idx = ((cmd.client_id << 8) | cmd.task_id);
-
-	return put_adsp_resource(client_idx, &cmd, sizeof(cmd));
-}
-
-static int rmt_get_resource(struct audio *audio)
-{
-	struct aud_codec_config_cmd cmd;
-	unsigned short client_idx;
-
-	cmd.cmd_id = RM_CMD_AUD_CODEC_CFG;
-	cmd.client_id = RM_AUD_CLIENT_ID;
-	cmd.task_id = audio->dec_id;
-	cmd.enable = RMT_ENABLE;
-	cmd.dec_type = AUDDEC_DEC_WMAPRO;
-	client_idx = ((cmd.client_id << 8) | cmd.task_id);
-
-	return get_adsp_resource(client_idx, &cmd, sizeof(cmd));
-}
-
-/* must be called with audio->lock held */
-static int audio_enable(struct audio *audio)
-{
-	struct audmgr_config cfg;
-	int rc;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled)
-		return 0;
-
-	if (audio->rmt_resource_released == 1) {
-		audio->rmt_resource_released = 0;
-		rc = rmt_get_resource(audio);
-		if (rc) {
-			MM_ERR("ADSP resources are not available for WMAPRO \
-				session 0x%08x on decoder: %d\n Ignoring \
-				error and going ahead with the playback\n",
-				(int)audio, audio->dec_id);
-		}
-	}
-
-	audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-
-	cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE;
-	cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000;
-	cfg.def_method = RPC_AUD_DEF_METHOD_PLAYBACK;
-	cfg.codec = RPC_AUD_DEF_CODEC_WMA;
-	cfg.snd_method = RPC_SND_METHOD_MIDI;
-
-	rc = audmgr_enable(&audio->audmgr, &cfg);
-	if (rc < 0) {
-		msm_adsp_dump(audio->audplay);
-		return rc;
-	}
-
-	if (msm_adsp_enable(audio->audplay)) {
-		MM_ERR("msm_adsp_enable(audplay) failed\n");
-		audmgr_disable(&audio->audmgr);
-		return -ENODEV;
-	}
-
-	if (audpp_enable(audio->dec_id, audio_dsp_event, audio)) {
-		MM_ERR("audpp_enable() failed\n");
-		msm_adsp_disable(audio->audplay);
-		audmgr_disable(&audio->audmgr);
-		return -ENODEV;
-	}
-
-	audio->enabled = 1;
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audio_disable(struct audio *audio)
-{
-	int rc = 0;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-		auddec_dsp_config(audio, 0);
-		rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-		if (rc == 0)
-			rc = -ETIMEDOUT;
-		else if (audio->dec_state != MSM_AUD_DECODER_STATE_CLOSE)
-			rc = -EFAULT;
-		else
-			rc = 0;
-		audio->stopped = 1;
-		wake_up(&audio->write_wait);
-		wake_up(&audio->read_wait);
-		msm_adsp_disable(audio->audplay);
-		audpp_disable(audio->dec_id, audio);
-		rc = audmgr_disable(&audio->audmgr);
-		if (rc < 0)
-			msm_adsp_dump(audio->audplay);
-
-		audio->out_needed = 0;
-		rmt_put_resource(audio);
-		audio->rmt_resource_released = 1;
-	}
-	return rc;
-}
-
-/* ------------------- dsp --------------------- */
-static void audio_update_pcm_buf_entry(struct audio *audio,
-	uint32_t *payload)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	if (audio->rflush)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < payload[1]; index++) {
-		if (audio->in[audio->fill_next].addr ==
-			payload[2 + index * 2]) {
-			MM_DBG("audio_update_pcm_buf_entry: \
-				in[%d] ready\n", audio->fill_next);
-			audio->in[audio->fill_next].used =
-			payload[3 + index * 2];
-			if ((++audio->fill_next) == audio->pcm_buf_count)
-				audio->fill_next = 0;
-		} else {
-			MM_ERR("audio_update_pcm_buf_entry: \
-				expected=%x ret=%x\n",
-				audio->in[audio->fill_next].addr,
-				payload[1 + index * 2]);
-			break;
-		}
-	}
-	if (audio->in[audio->fill_next].used == 0) {
-		audplay_buffer_refresh(audio);
-	} else {
-		MM_DBG("read cannot keep up\n");
-		audio->buf_refresh = 1;
-	}
-	wake_up(&audio->read_wait);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audplay_dsp_event(void *data, unsigned id, size_t len,
-			      void (*getevent) (void *ptr, size_t len))
-{
-	struct audio *audio = data;
-	uint32_t msg[28];
-
-	getevent(msg, sizeof(msg));
-
-	MM_DBG("msg_id=%x\n", id);
-
-	switch (id) {
-	case AUDPLAY_MSG_DEC_NEEDS_DATA:
-		audplay_send_data(audio, 1);
-		break;
-
-	case AUDPLAY_MSG_BUFFER_UPDATE:
-		audio_update_pcm_buf_entry(audio, msg);
-		break;
-
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audplaytask)\n");
-		break;
-
-	default:
-		MM_ERR("unexpected message from decoder \n");
-		break;
-	}
-}
-
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg)
-{
-	struct audio *audio = private;
-
-	switch (id) {
-	case AUDPP_MSG_STATUS_MSG:{
-			unsigned status = msg[1];
-
-			switch (status) {
-			case AUDPP_DEC_STATUS_SLEEP: {
-				uint16_t reason = msg[2];
-				MM_DBG("decoder status:sleep reason = \
-						0x%04x\n", reason);
-				if ((reason == AUDPP_MSG_REASON_MEM)
-					|| (reason ==
-					AUDPP_MSG_REASON_NODECODER)) {
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_FAILURE;
-					wake_up(&audio->wait);
-				} else if (reason == AUDPP_MSG_REASON_NONE) {
-					/* decoder is in disable state */
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_CLOSE;
-					wake_up(&audio->wait);
-				}
-				break;
-			}
-			case AUDPP_DEC_STATUS_INIT:
-				MM_DBG("decoder status: init\n");
-				if (audio->pcm_feedback)
-					audpp_cmd_cfg_routing_mode(audio);
-				else
-					audpp_cmd_cfg_adec_params(audio);
-				break;
-
-			case AUDPP_DEC_STATUS_CFG:
-				MM_DBG("decoder status: cfg\n");
-				break;
-			case AUDPP_DEC_STATUS_PLAY:
-				MM_DBG("decoder status: play\n");
-				if (audio->pcm_feedback) {
-					audplay_config_hostpcm(audio);
-					audplay_buffer_refresh(audio);
-				}
-				audio->dec_state =
-					MSM_AUD_DECODER_STATE_SUCCESS;
-				wake_up(&audio->wait);
-				break;
-			default:
-				MM_ERR("unknown decoder status\n");
-			}
-			break;
-		}
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_DBG("CFG_MSG ENABLE\n");
-			auddec_dsp_config(audio, 1);
-			audio->out_needed = 0;
-			audio->running = 1;
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-			audpp_dsp_set_eq(audio->dec_id,	audio->eq_enable,
-								&audio->eq);
-			audpp_avsync(audio->dec_id, 22050);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			MM_DBG("CFG_MSG DISABLE\n");
-			audpp_avsync(audio->dec_id, 0);
-			audio->running = 0;
-		} else {
-			MM_DBG("CFG_MSG %d?\n", msg[0]);
-		}
-		break;
-	case AUDPP_MSG_ROUTING_ACK:
-		MM_DBG("ROUTING_ACK mode=%d\n", msg[1]);
-		audpp_cmd_cfg_adec_params(audio);
-		break;
-
-	case AUDPP_MSG_FLUSH_ACK:
-		MM_DBG("FLUSH_ACK\n");
-		audio->wflush = 0;
-		audio->rflush = 0;
-		wake_up(&audio->write_wait);
-		if (audio->pcm_feedback)
-			audplay_buffer_refresh(audio);
-		break;
-	case AUDPP_MSG_PCMDMAMISSED:
-		MM_DBG("PCMDMAMISSED\n");
-		audio->teos = 1;
-		wake_up(&audio->write_wait);
-		break;
-
-	default:
-		MM_ERR("UNKNOWN (%d)\n", id);
-	}
-
-}
-
-static struct msm_adsp_ops audplay_adsp_ops_wmapro = {
-	.event = audplay_dsp_event,
-};
-
-#define audplay_send_queue0(audio, cmd, len) \
-	msm_adsp_write(audio->audplay, audio->queue_id, \
-			cmd, len)
-
-static int auddec_dsp_config(struct audio *audio, int enable)
-{
-	u16 cfg_dec_cmd[AUDPP_CMD_CFG_DEC_TYPE_LEN / sizeof(unsigned short)];
-
-	memset(cfg_dec_cmd, 0, sizeof(cfg_dec_cmd));
-	cfg_dec_cmd[0] = AUDPP_CMD_CFG_DEC_TYPE;
-	if (enable)
-		cfg_dec_cmd[1 + audio->dec_id] = AUDPP_CMD_UPDATDE_CFG_DEC |
-			AUDPP_CMD_ENA_DEC_V | AUDDEC_DEC_WMAPRO;
-	else
-		cfg_dec_cmd[1 + audio->dec_id] = AUDPP_CMD_UPDATDE_CFG_DEC |
-			AUDPP_CMD_DIS_DEC_V;
-
-	return audpp_send_queue1(&cfg_dec_cmd, sizeof(cfg_dec_cmd));
-}
-
-static void audpp_cmd_cfg_adec_params(struct audio *audio)
-{
-	struct audpp_cmd_cfg_adec_params_wmapro cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_CMD_CFG_ADEC_PARAMS;
-	cmd.common.length = AUDPP_CMD_CFG_ADEC_PARAMS_WMAPRO_LEN;
-	cmd.common.dec_id = audio->dec_id;
-	cmd.common.input_sampling_frequency = audio->out_sample_rate;
-
-	cmd.armdatareqthr = audio->wmapro_config.armdatareqthr;
-	cmd.numchannels = audio->wmapro_config.numchannels;
-	cmd.validbitspersample = audio->wmapro_config.validbitspersample;
-	cmd.formattag = audio->wmapro_config.formattag;
-	cmd.samplingrate = audio->wmapro_config.samplingrate;
-	cmd.avgbytespersecond = audio->wmapro_config.avgbytespersecond;
-	cmd.asfpacketlength = audio->wmapro_config.asfpacketlength;
-	cmd.channelmask = audio->wmapro_config.channelmask;
-	cmd.encodeopt = audio->wmapro_config.encodeopt;
-	cmd.advancedencodeopt = audio->wmapro_config.advancedencodeopt;
-	cmd.advancedencodeopt2 = audio->wmapro_config.advancedencodeopt2;
-
-	audpp_send_queue2(&cmd, sizeof(cmd));
-}
-
-static void audpp_cmd_cfg_routing_mode(struct audio *audio)
-{
-	struct audpp_cmd_routing_mode cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPP_CMD_ROUTING_MODE;
-	cmd.object_number = audio->dec_id;
-	if (audio->pcm_feedback)
-		cmd.routing_mode = ROUTING_MODE_FTRT;
-	else
-		cmd.routing_mode = ROUTING_MODE_RT;
-
-	audpp_send_queue1(&cmd, sizeof(cmd));
-}
-
-static void audplay_buffer_refresh(struct audio *audio)
-{
-	struct audplay_cmd_buffer_refresh refresh_cmd;
-
-	refresh_cmd.cmd_id = AUDPLAY_CMD_BUFFER_REFRESH;
-	refresh_cmd.num_buffers = 1;
-	refresh_cmd.buf0_address = audio->in[audio->fill_next].addr;
-	refresh_cmd.buf0_length = audio->in[audio->fill_next].size;
-	refresh_cmd.buf_read_count = 0;
-
-	MM_DBG("buf0_addr=%x buf0_len=%d\n",
-			refresh_cmd.buf0_address,
-			refresh_cmd.buf0_length);
-
-	(void)audplay_send_queue0(audio, &refresh_cmd, sizeof(refresh_cmd));
-}
-
-static void audplay_config_hostpcm(struct audio *audio)
-{
-	struct audplay_cmd_hpcm_buf_cfg cfg_cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	cfg_cmd.cmd_id = AUDPLAY_CMD_HPCM_BUF_CFG;
-	cfg_cmd.max_buffers = audio->pcm_buf_count;
-	cfg_cmd.byte_swap = 0;
-	cfg_cmd.hostpcm_config = (0x8000) | (0x4000);
-	cfg_cmd.feedback_frequency = 1;
-	cfg_cmd.partition_number = 0;
-
-	(void)audplay_send_queue0(audio, &cfg_cmd, sizeof(cfg_cmd));
-}
-
-
-static int audplay_dsp_send_data_avail(struct audio *audio,
-					unsigned idx, unsigned len)
-{
-	struct audplay_cmd_bitstream_data_avail_nt2 cmd;
-
-	cmd.cmd_id		= AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2;
-	if (audio->mfield)
-		cmd.decoder_id = AUDWMAPRO_METAFIELD_MASK |
-			(audio->out[idx].mfield_sz >> 1);
-	else
-		cmd.decoder_id		= audio->dec_id;
-	cmd.buf_ptr		= audio->out[idx].addr;
-	cmd.buf_size		= len/2;
-	cmd.partition_number	= 0;
-	return audplay_send_queue0(audio, &cmd, sizeof(cmd));
-}
-
-static void audplay_send_data(struct audio *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (audio->wflush) {
-		audio->out_needed = 1;
-		goto done;
-	}
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			MM_DBG("frame %d free\n", audio->out_tail);
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		MM_DBG("\n"); /* Macro prints the file name and function */
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			MM_DBG("frame %d busy\n", audio->out_tail);
-			audplay_dsp_send_data_avail(audio, audio->out_tail,
-								frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
-done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-
-static void audio_flush(struct audio *audio)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->out[0].used = 0;
-	audio->out[1].used = 0;
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->reserved = 0;
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	atomic_set(&audio->out_bytes, 0);
-}
-
-static void audio_flush_pcm_buf(struct audio *audio)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < PCM_BUF_MAX_COUNT; index++)
-		audio->in[index].used = 0;
-	audio->buf_refresh = 0;
-	audio->read_next = 0;
-	audio->fill_next = 0;
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audio_ioport_reset(struct audio *audio)
-{
-	/* Make sure read/write thread are free from
-	 * sleep and knowing that system is not able
-	 * to process io request at the moment
-	 */
-	wake_up(&audio->write_wait);
-	mutex_lock(&audio->write_lock);
-	audio_flush(audio);
-	mutex_unlock(&audio->write_lock);
-	wake_up(&audio->read_wait);
-	mutex_lock(&audio->read_lock);
-	audio_flush_pcm_buf(audio);
-	mutex_unlock(&audio->read_lock);
-}
-
-static int audwmapro_events_pending(struct audio *audio)
-{
-	unsigned long flags;
-	int empty;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	empty = !list_empty(&audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	return empty || audio->event_abort;
-}
-
-static void audwmapro_reset_event_queue(struct audio *audio)
-{
-	unsigned long flags;
-	struct audwmapro_event *drv_evt;
-	struct list_head *ptr, *next;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	list_for_each_safe(ptr, next, &audio->event_queue) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audwmapro_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	list_for_each_safe(ptr, next, &audio->free_event_queue) {
-		drv_evt = list_first_entry(&audio->free_event_queue,
-				struct audwmapro_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	return;
-}
-
-static long audwmapro_process_event_req(struct audio *audio, void __user *arg)
-{
-	long rc;
-	struct msm_audio_event usr_evt;
-	struct audwmapro_event *drv_evt = NULL;
-	int timeout;
-	unsigned long flags;
-
-	if (copy_from_user(&usr_evt, arg, sizeof(struct msm_audio_event)))
-		return -EFAULT;
-
-	timeout = (int) usr_evt.timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(audio->event_wait,
-				audwmapro_events_pending(audio),
-				msecs_to_jiffies(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(
-			audio->event_wait, audwmapro_events_pending(audio));
-	}
-
-	if (rc < 0)
-		return rc;
-
-	if (audio->event_abort) {
-		audio->event_abort = 0;
-		return -ENODEV;
-	}
-
-	rc = 0;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	if (!list_empty(&audio->event_queue)) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audwmapro_event, list);
-		list_del(&drv_evt->list);
-	}
-
-	if (drv_evt) {
-		usr_evt.event_type = drv_evt->event_type;
-		usr_evt.event_payload = drv_evt->payload;
-		list_add_tail(&drv_evt->list, &audio->free_event_queue);
-	} else
-		rc = -1;
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	if (!rc && copy_to_user(arg, &usr_evt, sizeof(usr_evt)))
-		rc = -EFAULT;
-
-	return rc;
-}
-
-static int audio_enable_eq(struct audio *audio, int enable)
-{
-	if (audio->eq_enable == enable && !audio->eq_needs_commit)
-		return 0;
-
-	audio->eq_enable = enable;
-
-	if (audio->running) {
-		audpp_dsp_set_eq(audio->dec_id, enable, &audio->eq);
-		audio->eq_needs_commit = 0;
-	}
-	return 0;
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = -EINVAL;
-	unsigned long flags = 0;
-	uint16_t enable_mask;
-	int enable;
-	int prev_state;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	int len = 0;
-
-	MM_DBG("cmd = %d\n", cmd);
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		stats.byte_count = audpp_avsync_byte_count(audio->dec_id);
-		stats.sample_count = audpp_avsync_sample_count(audio->dec_id);
-		if (copy_to_user((void *)arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-
-	switch (cmd) {
-	case AUDIO_ENABLE_AUDPP:
-		if (copy_from_user(&enable_mask, (void *) arg,
-						sizeof(enable_mask))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		enable = (enable_mask & EQ_ENABLE) ? 1 : 0;
-		audio_enable_eq(audio, enable);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-	case AUDIO_SET_VOLUME:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.volume = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_PAN:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.pan = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_EQ:
-		prev_state = audio->eq_enable;
-		audio->eq_enable = 0;
-		if (copy_from_user(&audio->eq.num_bands, (void *) arg,
-				sizeof(audio->eq) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2))) {
-			rc = -EFAULT;
-			break;
-		}
-		audio->eq_enable = prev_state;
-		audio->eq_needs_commit = 1;
-		rc = 0;
-		break;
-	}
-
-	if (-EINVAL != rc)
-		return rc;
-
-	if (cmd == AUDIO_GET_EVENT) {
-		MM_DBG("AUDIO_GET_EVENT\n");
-		if (mutex_trylock(&audio->get_event_lock)) {
-			rc = audwmapro_process_event_req(audio,
-					(void __user *) arg);
-			mutex_unlock(&audio->get_event_lock);
-		} else
-			rc = -EBUSY;
-		return rc;
-	}
-
-	if (cmd == AUDIO_ABORT_GET_EVENT) {
-		audio->event_abort = 1;
-		wake_up(&audio->event_wait);
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		MM_DBG("AUDIO_START\n");
-		rc = audio_enable(audio);
-		if (!rc) {
-			rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-			MM_INFO("dec_state %d rc = %d\n", audio->dec_state, rc);
-
-			if (audio->dec_state != MSM_AUD_DECODER_STATE_SUCCESS)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		break;
-	case AUDIO_STOP:
-		MM_DBG("AUDIO_STOP\n");
-		rc = audio_disable(audio);
-		audio_ioport_reset(audio);
-		audio->stopped = 0;
-		break;
-	case AUDIO_FLUSH:
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audio_ioport_reset(audio);
-		if (audio->running) {
-			audpp_flush(audio->dec_id);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-	case AUDIO_SET_CONFIG: {
-		struct msm_audio_config config;
-		if (copy_from_user(&config, (void *) arg, sizeof(config))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (config.channel_count == 1) {
-			config.channel_count = AUDPP_CMD_PCM_INTF_MONO_V;
-		} else if (config.channel_count == 2) {
-			config.channel_count = AUDPP_CMD_PCM_INTF_STEREO_V;
-		} else {
-			rc = -EINVAL;
-			break;
-		}
-		audio->mfield = config.meta_field;
-		audio->out_sample_rate = config.sample_rate;
-		audio->out_channel_mode = config.channel_count;
-		rc = 0;
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config config;
-		config.buffer_size = (audio->out_dma_sz >> 1);
-		config.buffer_count = 2;
-		config.sample_rate = audio->out_sample_rate;
-		if (audio->out_channel_mode == AUDPP_CMD_PCM_INTF_MONO_V)
-			config.channel_count = 1;
-		else
-			config.channel_count = 2;
-		config.meta_field = 0;
-		config.unused[0] = 0;
-		config.unused[1] = 0;
-		config.unused[2] = 0;
-		if (copy_to_user((void *) arg, &config, sizeof(config)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-
-		break;
-	}
-	case AUDIO_GET_WMAPRO_CONFIG:{
-			if (copy_to_user((void *)arg, &audio->wmapro_config,
-				sizeof(audio->wmapro_config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_SET_WMAPRO_CONFIG:{
-		struct msm_audio_wmapro_config usr_config;
-
-		if (copy_from_user
-			(&usr_config, (void *)arg,
-			sizeof(usr_config))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		audio->wmapro_config = usr_config;
-
-		/* Need to swap the first and last words of advancedencodeopt2
-		 * as DSP cannot read 32-bit variable at a time. Need to be
-		 * split into two 16-bit and swap them as required by DSP */
-
-		audio->wmapro_config.advancedencodeopt2 =
-			((audio->wmapro_config.advancedencodeopt2 & 0xFFFF0000)
-			 >> 16) | ((audio->wmapro_config.advancedencodeopt2
-			 << 16) & 0xFFFF0000);
-		rc = 0;
-		break;
-	}
-	case AUDIO_GET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			config.pcm_feedback = audio->pcm_feedback;
-			config.buffer_count = PCM_BUF_MAX_COUNT;
-			config.buffer_size = PCM_BUFSZ_MIN;
-			if (copy_to_user((void *)arg, &config,
-					 sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_SET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			if (copy_from_user
-			    (&config, (void *)arg, sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-			if (config.pcm_feedback != audio->pcm_feedback) {
-				MM_ERR("Not sufficient permission to"
-						"change the playback mode\n");
-				rc = -EACCES;
-				break;
-			}
-			if ((config.buffer_count > PCM_BUF_MAX_COUNT) ||
-			    (config.buffer_count == 1))
-				config.buffer_count = PCM_BUF_MAX_COUNT;
-
-			if (config.buffer_size < PCM_BUFSZ_MIN)
-				config.buffer_size = PCM_BUFSZ_MIN;
-
-			/* Check if pcm feedback is required */
-			if ((config.pcm_feedback) && (!audio->read_data)) {
-				MM_DBG("allocate PCM buffer %d\n",
-						config.buffer_count *
-						config.buffer_size);
-				handle = ion_alloc(audio->client,
-					(config.buffer_size *
-					config.buffer_count),
-					SZ_4K, ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-				if (IS_ERR_OR_NULL(handle)) {
-					MM_ERR("Unable to alloc I/P buffs\n");
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-					break;
-				}
-
-				audio->input_buff_handle = handle;
-
-				rc = ion_phys(audio->client ,
-					handle, &addr, &len);
-				if (rc) {
-					MM_ERR("Invalid phy: %x sz: %x\n",
-						(unsigned int) addr,
-						(unsigned int) len);
-					ion_free(audio->client, handle);
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-					break;
-				} else {
-					MM_INFO("Got valid phy: %x sz: %x\n",
-						(unsigned int) audio->read_phys,
-						(unsigned int) len);
-				}
-				audio->read_phys = (int32_t)addr;
-
-				rc = ion_handle_get_flags(audio->client,
-					handle, &ionflag);
-				if (rc) {
-					MM_ERR("could not get flags\n");
-					ion_free(audio->client, handle);
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-					break;
-				}
-
-				audio->map_v_read = ion_map_kernel(
-					audio->client, handle);
-				if (IS_ERR(audio->map_v_read)) {
-					MM_ERR("map of read buf failed\n");
-					ion_free(audio->client, handle);
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-				} else {
-					uint8_t index;
-					uint32_t offset = 0;
-					audio->read_data = audio->map_v_read;
-					audio->pcm_feedback = 1;
-					audio->buf_refresh = 0;
-					audio->pcm_buf_count =
-					    config.buffer_count;
-					audio->read_next = 0;
-					audio->fill_next = 0;
-
-					for (index = 0;
-					     index < config.buffer_count;
-					     index++) {
-						audio->in[index].data =
-						    audio->read_data + offset;
-						audio->in[index].addr =
-						    audio->read_phys + offset;
-						audio->in[index].size =
-						    config.buffer_size;
-						audio->in[index].used = 0;
-						offset += config.buffer_size;
-					}
-					MM_DBG("read buf: phy addr \
-						0x%08x kernel addr 0x%08x\n",
-						audio->read_phys,
-						(int)audio->read_data);
-					rc = 0;
-				}
-			} else {
-				rc = 0;
-			}
-			break;
-		}
-	case AUDIO_PAUSE:
-		MM_DBG("AUDIO_PAUSE %ld\n", arg);
-		rc = audpp_pause(audio->dec_id, (int) arg);
-		break;
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-/* Only useful in tunnel-mode */
-static int audio_fsync(struct file *file, loff_t a, loff_t b,
-	int datasync)
-{
-	struct audio *audio = file->private_data;
-	struct buffer *frame;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	if (!audio->running || audio->pcm_feedback) {
-		rc = -EINVAL;
-		goto done_nolock;
-	}
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(!audio->out[0].used &&
-		!audio->out[1].used &&
-		audio->out_needed) || audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (audio->reserved) {
-		MM_DBG("send reserved byte\n");
-		frame = audio->out + audio->out_tail;
-		((char *) frame->data)[0] = audio->rsv_byte;
-		((char *) frame->data)[1] = 0;
-		frame->used = 2;
-		audplay_send_data(audio, 0);
-
-		rc = wait_event_interruptible(audio->write_wait,
-			(!audio->out[0].used &&
-			!audio->out[1].used &&
-			audio->out_needed) || audio->wflush);
-
-		if (rc < 0)
-			goto done;
-		else if (audio->wflush) {
-			rc = -EBUSY;
-			goto done;
-		}
-	}
-
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		audio->teos || audio->wflush);
-
-	if (audio->wflush)
-		rc = -EBUSY;
-
-done:
-	mutex_unlock(&audio->write_lock);
-done_nolock:
-	return rc;
-}
-
-static ssize_t audio_read(struct file *file, char __user *buf, size_t count,
-			  loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	int rc = 0;
-
-	if (!audio->pcm_feedback)
-		return 0; /* PCM feedback is not enabled. Nothing to read */
-
-	mutex_lock(&audio->read_lock);
-	MM_DBG("%d \n", count);
-	while (count > 0) {
-		rc = wait_event_interruptible(audio->read_wait,
-			(audio->in[audio->read_next].used > 0) ||
-			(audio->stopped) || (audio->rflush));
-
-		if (rc < 0)
-			break;
-
-		if (audio->stopped || audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (count < audio->in[audio->read_next].used) {
-			/* Read must happen in frame boundary. Since driver
-			   does not know frame size, read count must be greater
-			   or equal to size of PCM samples */
-			MM_DBG("audio_read: no partial frame done reading\n");
-			break;
-		} else {
-			MM_DBG("audio_read: read from in[%d]\n",
-					audio->read_next);
-			if (copy_to_user
-			    (buf, audio->in[audio->read_next].data,
-			     audio->in[audio->read_next].used)) {
-				MM_ERR("invalid addr %x \n", (unsigned int)buf);
-				rc = -EFAULT;
-				break;
-			}
-			count -= audio->in[audio->read_next].used;
-			buf += audio->in[audio->read_next].used;
-			audio->in[audio->read_next].used = 0;
-			if ((++audio->read_next) == audio->pcm_buf_count)
-				audio->read_next = 0;
-			break;	/* Force to exit while loop
-				 * to prevent output thread
-				 * sleep too long if data is
-				 * not ready at this moment.
-				 */
-		}
-	}
-
-	/* don't feed output buffer to HW decoder during flushing
-	 * buffer refresh command will be sent once flush completes
-	 * send buf refresh command here can confuse HW decoder
-	 */
-	if (audio->buf_refresh && !audio->rflush) {
-		audio->buf_refresh = 0;
-		MM_DBG("kick start pcm feedback again\n");
-		audplay_buffer_refresh(audio);
-	}
-
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		rc = buf - start;
-
-	MM_DBG("read %d bytes\n", rc);
-	return rc;
-}
-
-static int audwmapro_process_eos(struct audio *audio,
-		const char __user *buf_start, unsigned short mfield_size)
-{
-	int rc = 0;
-	struct buffer *frame;
-	char *buf_ptr;
-
-	if (audio->reserved) {
-		MM_DBG("flush reserve byte\n");
-		frame = audio->out + audio->out_head;
-		buf_ptr = frame->data;
-		rc = wait_event_interruptible(audio->write_wait,
-				(frame->used == 0)
-				|| (audio->stopped)
-				|| (audio->wflush));
-		if (rc < 0)
-			goto done;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			goto done;
-		}
-
-		buf_ptr[0] = audio->rsv_byte;
-		buf_ptr[1] = 0;
-		audio->out_head ^= 1;
-		frame->mfield_sz = 0;
-		frame->used = 2;
-		audio->reserved = 0;
-		audplay_send_data(audio, 0);
-	}
-
-	frame = audio->out + audio->out_head;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	audplay_send_data(audio, 0);
-done:
-	return rc;
-}
-
-static ssize_t audio_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	size_t xfer;
-	char *cpy_ptr;
-	int rc = 0, eos_condition = AUDWMAPRO_EOS_NONE;
-	unsigned dsize;
-	unsigned short mfield_size = 0;
-
-	MM_DBG("cnt=%d\n", count);
-
-	mutex_lock(&audio->write_lock);
-	while (count > 0) {
-		frame = audio->out + audio->out_head;
-		cpy_ptr = frame->data;
-		dsize = 0;
-		rc = wait_event_interruptible(audio->write_wait,
-					      (frame->used == 0)
-					      || (audio->stopped)
-						  || (audio->wflush));
-		if (rc < 0)
-			break;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			break;
-		}
-		if (audio->mfield) {
-			if (buf == start) {
-				/* Processing beginning of user buffer */
-				if (__get_user(mfield_size,
-					(unsigned short __user *) buf)) {
-					rc = -EFAULT;
-					break;
-				} else  if (mfield_size > count) {
-					rc = -EINVAL;
-					break;
-				}
-				MM_DBG("audio_write: mf offset_val %x\n",
-						mfield_size);
-				if (copy_from_user(cpy_ptr, buf, mfield_size)) {
-					rc = -EFAULT;
-					break;
-				}
-				/* Check if EOS flag is set and buffer has
-				 * contains just meta field
-				 */
-				if (cpy_ptr[AUDWMAPRO_EOS_FLG_OFFSET] &
-						 AUDWMAPRO_EOS_FLG_MASK) {
-					MM_DBG("audio_write: EOS SET\n");
-					eos_condition = AUDWMAPRO_EOS_SET;
-					if (mfield_size == count) {
-						buf += mfield_size;
-						break;
-					} else
-					cpy_ptr[AUDWMAPRO_EOS_FLG_OFFSET]
-						&= ~AUDWMAPRO_EOS_FLG_MASK;
-				}
-				cpy_ptr += mfield_size;
-				count -= mfield_size;
-				dsize += mfield_size;
-				buf += mfield_size;
-			} else {
-				mfield_size = 0;
-				MM_DBG("audio_write: continuous buffer\n");
-			}
-			frame->mfield_sz = mfield_size;
-		}
-
-		if (audio->reserved) {
-			MM_DBG("append reserved byte %x\n", audio->rsv_byte);
-			*cpy_ptr = audio->rsv_byte;
-			xfer = (count > ((frame->size - mfield_size) - 1)) ?
-				(frame->size - mfield_size) - 1 : count;
-			cpy_ptr++;
-			dsize += 1;
-			audio->reserved = 0;
-		} else
-			xfer = (count > (frame->size - mfield_size)) ?
-				(frame->size - mfield_size) : count;
-
-		if (copy_from_user(cpy_ptr, buf, xfer)) {
-			rc = -EFAULT;
-			break;
-		}
-
-		dsize += xfer;
-		if (dsize & 1) {
-			audio->rsv_byte = ((char *) frame->data)[dsize - 1];
-			MM_DBG("odd length buf reserve last byte %x\n",
-					audio->rsv_byte);
-			audio->reserved = 1;
-			dsize--;
-		}
-		count -= xfer;
-		buf += xfer;
-
-		if (dsize > 0) {
-			audio->out_head ^= 1;
-			frame->used = dsize;
-			audplay_send_data(audio, 0);
-		}
-	}
-	if (eos_condition == AUDWMAPRO_EOS_SET)
-		rc = audwmapro_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	if (!rc) {
-		if (buf > start)
-			return buf - start;
-	}
-	return rc;
-}
-
-static int audio_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	MM_INFO("audio instance 0x%08x freeing\n", (int)audio);
-	mutex_lock(&audio->lock);
-	audio_disable(audio);
-	if (audio->rmt_resource_released == 0)
-		rmt_put_resource(audio);
-	audio_flush(audio);
-	audio_flush_pcm_buf(audio);
-	msm_adsp_put(audio->audplay);
-	audpp_adec_free(audio->dec_id);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	unregister_early_suspend(&audio->suspend_ctl.node);
-#endif
-	audio->event_abort = 1;
-	wake_up(&audio->event_wait);
-	audwmapro_reset_event_queue(audio);
-	ion_unmap_kernel(audio->client, audio->output_buff_handle);
-	ion_free(audio->client, audio->output_buff_handle);
-	if (audio->input_buff_handle != NULL) {
-		ion_unmap_kernel(audio->client, audio->input_buff_handle);
-		ion_free(audio->client, audio->input_buff_handle);
-	}
-	ion_client_destroy(audio->client);
-	mutex_unlock(&audio->lock);
-#ifdef CONFIG_DEBUG_FS
-	if (audio->dentry)
-		debugfs_remove(audio->dentry);
-#endif
-	kfree(audio);
-	return 0;
-}
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audwmapro_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload)
-{
-	struct audwmapro_event *e_node = NULL;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-
-	if (!list_empty(&audio->free_event_queue)) {
-		e_node = list_first_entry(&audio->free_event_queue,
-				struct audwmapro_event, list);
-		list_del(&e_node->list);
-	} else {
-		e_node = kmalloc(sizeof(struct audwmapro_event), GFP_ATOMIC);
-		if (!e_node) {
-			MM_ERR("No mem to post event %d\n", type);
-			spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-			return;
-		}
-	}
-
-	e_node->event_type = type;
-	e_node->payload = payload;
-
-	list_add_tail(&e_node->list, &audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	wake_up(&audio->event_wait);
-}
-
-static void audwmapro_suspend(struct early_suspend *h)
-{
-	struct audwmapro_suspend_ctl *ctl =
-		container_of(h, struct audwmapro_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audwmapro_post_event(ctl->audio, AUDIO_EVENT_SUSPEND, payload);
-}
-
-static void audwmapro_resume(struct early_suspend *h)
-{
-	struct audwmapro_suspend_ctl *ctl =
-		container_of(h, struct audwmapro_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audwmapro_post_event(ctl->audio, AUDIO_EVENT_RESUME, payload);
-}
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-static ssize_t audwmapro_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static ssize_t audwmapro_debug_read(struct file *file, char __user *buf,
-			  size_t count, loff_t *ppos)
-{
-	const int debug_bufmax = 4096;
-	static char buffer[4096];
-	int n = 0, i;
-	struct audio *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	n = scnprintf(buffer, debug_bufmax, "opened %d\n", audio->opened);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "enabled %d\n", audio->enabled);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "stopped %d\n", audio->stopped);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "pcm_feedback %d\n", audio->pcm_feedback);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_buf_sz %d\n", audio->out[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "pcm_buf_count %d \n", audio->pcm_buf_count);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "pcm_buf_sz %d \n", audio->in[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "volume %x \n", audio->vol_pan.volume);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "sample rate %d \n", audio->out_sample_rate);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-		"channel mode %d \n", audio->out_channel_mode);
-	mutex_unlock(&audio->lock);
-	/* Following variables are only useful for debugging when
-	 * when playback halts unexpectedly. Thus, no mutual exclusion
-	 * enforced
-	 */
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "wflush %d\n", audio->wflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "rflush %d\n", audio->rflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "running %d \n", audio->running);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"dec state %d \n", audio->dec_state);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_needed %d \n", audio->out_needed);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_head %d \n", audio->out_head);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_tail %d \n", audio->out_tail);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out[0].used %d \n", audio->out[0].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out[1].used %d \n", audio->out[1].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "buffer_refresh %d \n", audio->buf_refresh);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "read_next %d \n", audio->read_next);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "fill_next %d \n", audio->fill_next);
-	for (i = 0; i < audio->pcm_buf_count; i++)
-		n += scnprintf(buffer + n, debug_bufmax - n,
-			"in[%d].size %d \n", i, audio->in[i].used);
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations audwmapro_debug_fops = {
-	.read = audwmapro_debug_read,
-	.open = audwmapro_debug_open,
-};
-#endif
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = NULL;
-	int rc, dec_attrb, decid, i;
-	unsigned mem_sz = DMASZ_MAX;
-	struct audwmapro_event *e_node = NULL;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	struct ion_client *client = NULL;
-	int len = 0;
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_wmapro_" + 5];
-#endif
-
-	/* Allocate Mem for audio instance */
-	audio = kzalloc(sizeof(struct audio), GFP_KERNEL);
-	if (!audio) {
-		MM_ERR("no memory to allocate audio instance \n");
-		rc = -ENOMEM;
-		goto done;
-	}
-	MM_INFO("audio instance 0x%08x created\n", (int)audio);
-
-	/* Allocate the decoder */
-	dec_attrb = AUDDEC_DEC_WMAPRO;
-	if ((file->f_mode & FMODE_WRITE) &&
-			(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_NONTUNNEL;
-		audio->pcm_feedback = NON_TUNNEL_MODE_PLAYBACK;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_TUNNEL;
-		audio->pcm_feedback = TUNNEL_MODE_PLAYBACK;
-	} else {
-		kfree(audio);
-		rc = -EACCES;
-		goto done;
-	}
-
-	decid = audpp_adec_alloc(dec_attrb, &audio->module_name,
-			&audio->queue_id);
-
-	if (decid < 0) {
-		MM_ERR("No free decoder available, freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENODEV;
-		kfree(audio);
-		goto done;
-	}
-	audio->dec_id = decid & MSM_AUD_DECODER_MASK;
-
-	client = msm_ion_client_create(UINT_MAX, "Audio_WMA_PRO_Client");
-	if (IS_ERR_OR_NULL(client)) {
-		pr_err("Unable to create ION client\n");
-		rc = -ENOMEM;
-		goto client_create_error;
-	}
-	audio->client = client;
-
-	handle = ion_alloc(client, mem_sz, SZ_4K,
-		ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-	if (IS_ERR_OR_NULL(handle)) {
-		MM_ERR("Unable to create allocate O/P buffers\n");
-		rc = -ENOMEM;
-		goto output_buff_alloc_error;
-	}
-	audio->output_buff_handle = handle;
-
-	rc = ion_phys(client, handle, &addr, &len);
-	if (rc) {
-		MM_ERR("O/P buffers:Invalid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-		goto output_buff_get_phys_error;
-	} else {
-		MM_INFO("O/P buffers:valid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-	}
-	audio->phys = (int32_t)addr;
-
-
-	rc = ion_handle_get_flags(client, handle, &ionflag);
-	if (rc) {
-		MM_ERR("could not get flags for the handle\n");
-		goto output_buff_get_flags_error;
-	}
-
-	audio->map_v_write = ion_map_kernel(client, handle);
-	if (IS_ERR(audio->map_v_write)) {
-		MM_ERR("could not map write buffers\n");
-		rc = -ENOMEM;
-		goto output_buff_map_error;
-	}
-	audio->data = audio->map_v_write;
-	MM_DBG("write buf: phy addr 0x%08x kernel addr 0x%08x\n",
-		audio->phys, (int)audio->data);
-
-	audio->out_dma_sz = mem_sz;
-
-	rc = audmgr_open(&audio->audmgr);
-	if (rc) {
-		MM_ERR("audmgr open failed, freeing instance 0x%08x\n",
-				(int)audio);
-		goto err;
-	}
-
-	rc = msm_adsp_get(audio->module_name, &audio->audplay,
-			&audplay_adsp_ops_wmapro, audio);
-	if (rc) {
-		MM_ERR("failed to get %s module, freeing instance 0x%08x\n",
-				audio->module_name, (int)audio);
-		audmgr_close(&audio->audmgr);
-		goto err;
-	}
-
-	rc = rmt_get_resource(audio);
-	if (rc) {
-		MM_ERR("ADSP resources are not available for WMAPRO session \
-			 0x%08x on decoder: %d\n", (int)audio, audio->dec_id);
-		if (audio->pcm_feedback == TUNNEL_MODE_PLAYBACK)
-			audmgr_close(&audio->audmgr);
-		msm_adsp_put(audio->audplay);
-		goto err;
-	}
-
-	audio->input_buff_handle = NULL;
-	mutex_init(&audio->lock);
-	mutex_init(&audio->write_lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->get_event_lock);
-	spin_lock_init(&audio->dsp_lock);
-	init_waitqueue_head(&audio->write_wait);
-	init_waitqueue_head(&audio->read_wait);
-	INIT_LIST_HEAD(&audio->free_event_queue);
-	INIT_LIST_HEAD(&audio->event_queue);
-	init_waitqueue_head(&audio->wait);
-	init_waitqueue_head(&audio->event_wait);
-	spin_lock_init(&audio->event_queue_lock);
-
-	audio->out[0].data = audio->data + 0;
-	audio->out[0].addr = audio->phys + 0;
-	audio->out[0].size = audio->out_dma_sz >> 1;
-
-	audio->out[1].data = audio->data + audio->out[0].size;
-	audio->out[1].addr = audio->phys + audio->out[0].size;
-	audio->out[1].size = audio->out[0].size;
-
-	audio->out_sample_rate = 44100;
-	audio->out_channel_mode = AUDPP_CMD_PCM_INTF_STEREO_V;
-
-	audio->vol_pan.volume = 0x2000;
-
-	audio_flush(audio);
-
-	file->private_data = audio;
-	audio->opened = 1;
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof name, "msm_wmapro_%04x", audio->dec_id);
-	audio->dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
-				NULL, (void *) audio,
-				&audwmapro_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		MM_DBG("debugfs_create_file failed\n");
-#endif
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	audio->suspend_ctl.node.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
-	audio->suspend_ctl.node.resume = audwmapro_resume;
-	audio->suspend_ctl.node.suspend = audwmapro_suspend;
-	audio->suspend_ctl.audio = audio;
-	register_early_suspend(&audio->suspend_ctl.node);
-#endif
-	for (i = 0; i < AUDWMAPRO_EVENT_NUM; i++) {
-		e_node = kmalloc(sizeof(struct audwmapro_event), GFP_KERNEL);
-		if (e_node)
-			list_add_tail(&e_node->list, &audio->free_event_queue);
-		else {
-			MM_ERR("event pkt alloc failed\n");
-			break;
-		}
-	}
-done:
-	return rc;
-err:
-	ion_unmap_kernel(client, audio->output_buff_handle);
-output_buff_map_error:
-output_buff_get_phys_error:
-output_buff_get_flags_error:
-	ion_free(client, audio->output_buff_handle);
-output_buff_alloc_error:
-	ion_client_destroy(client);
-client_create_error:
-	audpp_adec_free(audio->dec_id);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_wmapro_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audio_open,
-	.release	= audio_release,
-	.read 		= audio_read,
-	.write		= audio_write,
-	.unlocked_ioctl	= audio_ioctl,
-	.fsync 		= audio_fsync,
-};
-
-struct miscdevice audio_wmapro_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_wmapro",
-	.fops	= &audio_wmapro_fops,
-};
-
-static int __init audio_init(void)
-{
-	return misc_register(&audio_wmapro_misc);
-}
-
-device_initcall(audio_init);
diff --git a/arch/arm/mach-msm/qdsp5/audmgr.c b/arch/arm/mach-msm/qdsp5/audmgr.c
deleted file mode 100644
index cc40585..0000000
--- a/arch/arm/mach-msm/qdsp5/audmgr.c
+++ /dev/null
@@ -1,526 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/audmgr.c
- *
- * interface to "audmgr" service on the baseband cpu
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (c) 2009, 2012, 2013 The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/slab.h>
-
-#include <asm/atomic.h>
-#include <mach/msm_rpcrouter.h>
-
-#include "audmgr.h"
-#include <mach/debug_mm.h>
-
-#define STATE_CLOSED    0
-#define STATE_DISABLED  1
-#define STATE_ENABLING  2
-#define STATE_ENABLED   3
-#define STATE_DISABLING 4
-#define STATE_ERROR	5
-#define MAX_DEVICE_INFO_CALLBACK 1
-#define SESSION_VOICE 0
-#define SESSION_PLAYBACK 1
-#define SESSION_RECORDING 2
-
-/* store information used across complete audmgr sessions */
-struct audmgr_global {
-	struct mutex *lock;
-	struct msm_rpc_endpoint *ept;
-	struct task_struct *task;
-	uint32_t rpc_version;
-	uint32_t rx_device;
-	uint32_t tx_device;
-	int cad;
-	struct device_info_callback *device_cb[MAX_DEVICE_INFO_CALLBACK];
-
-};
-static DEFINE_MUTEX(audmgr_lock);
-
-static struct audmgr_global the_audmgr_state = {
-	.lock = &audmgr_lock,
-};
-
-static void audmgr_rpc_connect(struct audmgr_global *amg)
-{
-	amg->cad = 0;
-	amg->ept = msm_rpc_connect_compatible(AUDMGR_PROG,
-			AUDMGR_VERS_COMP_VER3,
-			MSM_RPC_UNINTERRUPTIBLE);
-	if (IS_ERR(amg->ept)) {
-		MM_DBG("connect failed with current VERS"\
-				"= %x, trying again with  Cad API\n",
-				AUDMGR_VERS_COMP_VER3);
-		amg->ept = msm_rpc_connect_compatible(AUDMGR_PROG,
-				AUDMGR_VERS_COMP_VER4,
-				MSM_RPC_UNINTERRUPTIBLE);
-		if (IS_ERR(amg->ept)) {
-			amg->ept = msm_rpc_connect_compatible(AUDMGR_PROG,
-					AUDMGR_VERS_COMP_VER2,
-					MSM_RPC_UNINTERRUPTIBLE);
-			if (IS_ERR(amg->ept)) {
-				MM_ERR("connect failed with current VERS" \
-					"= %x, trying again with another API\n",
-					AUDMGR_VERS_COMP_VER2);
-				amg->ept = msm_rpc_connect_compatible(
-						AUDMGR_PROG,
-						AUDMGR_VERS_COMP,
-						MSM_RPC_UNINTERRUPTIBLE);
-				if (IS_ERR(amg->ept)) {
-					MM_ERR("connect failed with current" \
-						"VERS=%x, trying again with" \
-						"another API\n",
-						AUDMGR_VERS_COMP);
-					amg->ept = msm_rpc_connect(AUDMGR_PROG,
-						AUDMGR_VERS,
-						MSM_RPC_UNINTERRUPTIBLE);
-					amg->rpc_version = AUDMGR_VERS;
-				} else
-					amg->rpc_version = AUDMGR_VERS_COMP;
-			} else
-				amg->rpc_version = AUDMGR_VERS_COMP_VER2;
-		} else {
-			amg->rpc_version = AUDMGR_VERS_COMP_VER4;
-			amg->cad = 1;
-		}
-	} else
-		amg->rpc_version = AUDMGR_VERS_COMP_VER3;
-
-	if (IS_ERR(amg->ept)) {
-		amg->ept = NULL;
-		MM_ERR("failed to connect to audmgr svc\n");
-	}
-
-	return;
-}
-
-static void rpc_ack(struct msm_rpc_endpoint *ept, uint32_t xid)
-{
-	uint32_t rep[6];
-
-	rep[0] = cpu_to_be32(xid);
-	rep[1] = cpu_to_be32(1);
-	rep[2] = cpu_to_be32(RPCMSG_REPLYSTAT_ACCEPTED);
-	rep[3] = cpu_to_be32(RPC_ACCEPTSTAT_SUCCESS);
-	rep[4] = 0;
-	rep[5] = 0;
-
-	msm_rpc_write(ept, rep, sizeof(rep));
-}
-
-static void process_audmgr_callback(struct audmgr_global *amg,
-				   void *args, int len)
-{
-	struct audmgr *am;
-	int i = 0;
-	struct rpc_audmgr_cb_device_info *temp;
-
-	/* Allow only if complete arguments recevied*/
-	if (len < MIN_RPC_DATA_LENGTH)
-		return;
-
-	/* Allow only if valid argument */
-	if (be32_to_cpu(((struct rpc_audmgr_cb_common *)args)->set_to_one) != 1)
-		return;
-
-	switch (be32_to_cpu(((struct rpc_audmgr_cb_common *)args)->status)) {
-	case RPC_AUDMGR_STATUS_READY:
-		am = (struct audmgr *) be32_to_cpu(
-			((struct rpc_audmgr_cb_ready *)args)->client_data);
-		if (!am)
-			return;
-		am->handle = be32_to_cpu(
-				((struct rpc_audmgr_cb_ready *)args)->u.handle);
-		MM_INFO("rpc READY handle=0x%08x\n", am->handle);
-		break;
-	case RPC_AUDMGR_STATUS_CODEC_CONFIG: {
-		MM_INFO("rpc CODEC_CONFIG\n");
-		am = (struct audmgr *) be32_to_cpu(
-			((struct rpc_audmgr_cb_ready *)args)->client_data);
-		if (!am)
-			return;
-		if (am->state != STATE_ENABLED)
-			am->state = STATE_ENABLED;
-		if (!amg->cad) {
-			wake_up(&am->wait);
-			break;
-		}
-
-		if (am->evt.session_info == SESSION_PLAYBACK &&
-			am->evt.dev_type.rx_device != amg->rx_device) {
-			am->evt.dev_type.rx_device = amg->rx_device;
-			am->evt.dev_type.tx_device = 0;
-			am->evt.acdb_id = am->evt.dev_type.rx_device;
-		}
-		if (am->evt.session_info == SESSION_RECORDING &&
-			am->evt.dev_type.tx_device != amg->tx_device) {
-			am->evt.dev_type.rx_device = 0;
-			am->evt.dev_type.tx_device = amg->tx_device;
-			am->evt.acdb_id = am->evt.dev_type.tx_device;
-		}
-
-		while ((amg->device_cb[i] != NULL) &&
-				(i < MAX_DEVICE_INFO_CALLBACK) &&
-				(amg->cad)) {
-			amg->device_cb[i]->func(&(am->evt),
-					amg->device_cb[i]->private);
-			i++;
-		}
-		wake_up(&am->wait);
-		break;
-	}
-	case RPC_AUDMGR_STATUS_PENDING:
-		MM_ERR("PENDING?\n");
-		break;
-	case RPC_AUDMGR_STATUS_SUSPEND:
-		MM_ERR("SUSPEND?\n");
-		break;
-	case RPC_AUDMGR_STATUS_FAILURE:
-		MM_ERR("FAILURE\n");
-		break;
-	case RPC_AUDMGR_STATUS_VOLUME_CHANGE:
-		MM_ERR("VOLUME_CHANGE?\n");
-		break;
-	case RPC_AUDMGR_STATUS_DISABLED:
-		MM_ERR("DISABLED\n");
-		am = (struct audmgr *) be32_to_cpu(
-			((struct rpc_audmgr_cb_ready *)args)->client_data);
-		if (!am)
-			return;
-		am->state = STATE_DISABLED;
-		wake_up(&am->wait);
-		break;
-	case RPC_AUDMGR_STATUS_ERROR:
-		MM_ERR("ERROR?\n");
-		am = (struct audmgr *) be32_to_cpu(
-			((struct rpc_audmgr_cb_ready *)args)->client_data);
-		if (!am)
-			return;
-		am->state = STATE_ERROR;
-		wake_up(&am->wait);
-		break;
-	case RPC_AUDMGR_STATUS_DEVICE_INFO:
-		MM_INFO("rpc DEVICE_INFO\n");
-		if (!amg->cad)
-			break;
-		temp = (struct rpc_audmgr_cb_device_info *)args;
-		am = (struct audmgr *) be32_to_cpu(temp->client_data);
-		if (!am)
-			return;
-		if (am->evt.session_info == SESSION_PLAYBACK) {
-			am->evt.dev_type.rx_device =
-					be32_to_cpu(temp->d.rx_device);
-			am->evt.dev_type.tx_device = 0;
-			am->evt.acdb_id = am->evt.dev_type.rx_device;
-			amg->rx_device = am->evt.dev_type.rx_device;
-		} else if (am->evt.session_info == SESSION_RECORDING) {
-			am->evt.dev_type.rx_device = 0;
-			am->evt.dev_type.tx_device =
-					be32_to_cpu(temp->d.tx_device);
-			am->evt.acdb_id = am->evt.dev_type.tx_device;
-			amg->tx_device = am->evt.dev_type.tx_device;
-		}
-		am->evt.dev_type.ear_mute =
-					be32_to_cpu(temp->d.ear_mute);
-		am->evt.dev_type.mic_mute =
-					be32_to_cpu(temp->d.mic_mute);
-		am->evt.dev_type.volume =
-					be32_to_cpu(temp->d.volume);
-		break;
-	case RPC_AUDMGR_STATUS_DEVICE_CONFIG:
-		MM_ERR("rpc DEVICE_CONFIG\n");
-		break;
-	default:
-		break;
-	}
-}
-
-static void process_rpc_request(uint32_t proc, uint32_t xid,
-				void *data, int len, void *private)
-{
-	struct audmgr_global *amg = private;
-
-	if (proc == AUDMGR_CB_FUNC_PTR)
-		process_audmgr_callback(amg, data, len);
-	else
-		MM_ERR("unknown rpc proc %d\n", proc);
-	rpc_ack(amg->ept, xid);
-}
-
-#define RPC_TYPE_REQUEST 0
-#define RPC_TYPE_REPLY 1
-
-#define RPC_VERSION 2
-
-#define RPC_COMMON_HDR_SZ  (sizeof(uint32_t) * 2)
-#define RPC_REQUEST_HDR_SZ (sizeof(struct rpc_request_hdr))
-#define RPC_REPLY_HDR_SZ   (sizeof(uint32_t) * 3)
-#define RPC_REPLY_SZ       (sizeof(uint32_t) * 6)
-
-static int audmgr_rpc_thread(void *data)
-{
-	struct audmgr_global *amg = data;
-	struct rpc_request_hdr *hdr = NULL;
-	uint32_t type;
-	int len;
-
-	MM_INFO("start\n");
-
-	while (!kthread_should_stop()) {
-		if (hdr) {
-			kfree(hdr);
-			hdr = NULL;
-		}
-		len = msm_rpc_read(amg->ept, (void **) &hdr, -1, -1);
-		if (len < 0) {
-			MM_ERR("rpc read failed (%d)\n", len);
-			break;
-		}
-		if (len < RPC_COMMON_HDR_SZ)
-			continue;
-
-		type = be32_to_cpu(hdr->type);
-		if (type == RPC_TYPE_REPLY) {
-			struct rpc_reply_hdr *rep = (void *) hdr;
-			uint32_t status;
-			if (len < RPC_REPLY_HDR_SZ)
-				continue;
-			status = be32_to_cpu(rep->reply_stat);
-			if (status == RPCMSG_REPLYSTAT_ACCEPTED) {
-				status = be32_to_cpu(rep->data.acc_hdr.accept_stat);
-				MM_INFO("rpc_reply status %d\n", status);
-			} else {
-				MM_INFO("rpc_reply denied!\n");
-			}
-			/* process reply */
-			continue;
-		}
-
-		if (len < RPC_REQUEST_HDR_SZ)
-			continue;
-
-		process_rpc_request(be32_to_cpu(hdr->procedure),
-				    be32_to_cpu(hdr->xid),
-				    (void *) (hdr + 1),
-				    len - sizeof(*hdr),
-				    data);
-	}
-	MM_INFO("exit\n");
-	if (hdr) {
-		kfree(hdr);
-		hdr = NULL;
-	}
-	amg->task = NULL;
-	return 0;
-}
-
-static unsigned convert_samp_index(unsigned index)
-{
-	switch (index) {
-	case RPC_AUD_DEF_SAMPLE_RATE_48000:	return 48000;
-	case RPC_AUD_DEF_SAMPLE_RATE_44100:	return 44100;
-	case RPC_AUD_DEF_SAMPLE_RATE_32000:	return 32000;
-	case RPC_AUD_DEF_SAMPLE_RATE_24000:	return 24000;
-	case RPC_AUD_DEF_SAMPLE_RATE_22050:	return 22050;
-	case RPC_AUD_DEF_SAMPLE_RATE_16000:	return 16000;
-	case RPC_AUD_DEF_SAMPLE_RATE_12000:	return 12000;
-	case RPC_AUD_DEF_SAMPLE_RATE_11025:	return 11025;
-	case RPC_AUD_DEF_SAMPLE_RATE_8000:	return 8000;
-	default:				return 11025;
-	}
-}
-
-static void get_current_session_info(struct audmgr *am,
-				struct audmgr_config *cfg)
-{
-	if (cfg->def_method == RPC_AUD_DEF_METHOD_PLAYBACK ||
-	   (cfg->def_method == RPC_AUD_DEF_METHOD_HOST_PCM && cfg->rx_rate)) {
-		am->evt.session_info = SESSION_PLAYBACK; /* playback */
-		am->evt.sample_rate = convert_samp_index(cfg->rx_rate);
-	} else if (cfg->def_method == RPC_AUD_DEF_METHOD_RECORD) {
-		am->evt.session_info = SESSION_RECORDING; /* recording */
-		am->evt.sample_rate = convert_samp_index(cfg->tx_rate);
-	} else
-		am->evt.session_info = SESSION_VOICE;
-}
-
-struct audmgr_enable_msg {
-	struct rpc_request_hdr hdr;
-	struct rpc_audmgr_enable_client_args args;
-};
-
-struct audmgr_disable_msg {
-	struct rpc_request_hdr hdr;
-	uint32_t handle;
-};
-
-int audmgr_open(struct audmgr *am)
-{
-	struct audmgr_global *amg = &the_audmgr_state;
-	int rc;
-
-	if (am->state != STATE_CLOSED)
-		return 0;
-
-	mutex_lock(amg->lock);
-
-	/* connect to audmgr end point and polling thread only once */
-	if (amg->ept == NULL) {
-		audmgr_rpc_connect(amg);
-		if (IS_ERR(amg->ept)) {
-			rc = PTR_ERR(amg->ept);
-			amg->ept = NULL;
-			MM_ERR("failed to connect to audmgr svc\n");
-			goto done;
-		}
-
-		amg->task = kthread_run(audmgr_rpc_thread, amg, "audmgr_rpc");
-		if (IS_ERR(amg->task)) {
-			rc = PTR_ERR(amg->task);
-			amg->task = NULL;
-			msm_rpc_close(amg->ept);
-			amg->ept = NULL;
-			goto done;
-		}
-	}
-
-	/* Initialize session parameters */
-	init_waitqueue_head(&am->wait);
-	am->state = STATE_DISABLED;
-	rc = 0;
-done:
-	mutex_unlock(amg->lock);
-	return rc;
-}
-EXPORT_SYMBOL(audmgr_open);
-
-int audmgr_close(struct audmgr *am)
-{
-	return -EBUSY;
-}
-EXPORT_SYMBOL(audmgr_close);
-
-int audmgr_enable(struct audmgr *am, struct audmgr_config *cfg)
-{
-	struct audmgr_global *amg = &the_audmgr_state;
-	struct audmgr_enable_msg msg;
-	int rc;
-
-	if (am->state == STATE_ENABLED)
-		return 0;
-
-	if (am->state == STATE_DISABLING)
-		MM_ERR("state is DISABLING in enable?\n");
-	am->state = STATE_ENABLING;
-
-	MM_INFO("session 0x%08x\n", (int) am);
-	msg.args.set_to_one = cpu_to_be32(1);
-	msg.args.tx_sample_rate = cpu_to_be32(cfg->tx_rate);
-	msg.args.rx_sample_rate = cpu_to_be32(cfg->rx_rate);
-	msg.args.def_method = cpu_to_be32(cfg->def_method);
-	msg.args.codec_type = cpu_to_be32(cfg->codec);
-	msg.args.snd_method = cpu_to_be32(cfg->snd_method);
-	msg.args.cb_func = cpu_to_be32(0x11111111);
-	msg.args.client_data = cpu_to_be32((int)am);
-
-	get_current_session_info(am, cfg);
-	msm_rpc_setup_req(&msg.hdr, AUDMGR_PROG, amg->rpc_version,
-			  AUDMGR_ENABLE_CLIENT);
-
-	rc = msm_rpc_write(amg->ept, &msg, sizeof(msg));
-	if (rc < 0)
-		return rc;
-
-	rc = wait_event_timeout(am->wait, am->state != STATE_ENABLING, 15 * HZ);
-	if (rc == 0) {
-		MM_ERR("ARM9 did not reply to RPC am->state = %d\n", am->state);
-	}
-	if (am->state == STATE_ENABLED)
-		return 0;
-
-	am->evt.session_info = -1;
-	MM_ERR("unexpected state %d while enabling?!\n", am->state);
-	return -ENODEV;
-}
-EXPORT_SYMBOL(audmgr_enable);
-
-int audmgr_disable(struct audmgr *am)
-{
-	struct audmgr_global *amg = &the_audmgr_state;
-	struct audmgr_disable_msg msg;
-	int rc;
-
-	if (am->state == STATE_DISABLED)
-		return 0;
-
-	MM_INFO("session 0x%08x\n", (int) am);
-	am->evt.session_info = -1;
-	msg.handle = cpu_to_be32(am->handle);
-	msm_rpc_setup_req(&msg.hdr, AUDMGR_PROG, amg->rpc_version,
-			  AUDMGR_DISABLE_CLIENT);
-
-	am->state = STATE_DISABLING;
-
-	rc = msm_rpc_write(amg->ept, &msg, sizeof(msg));
-	if (rc < 0)
-		return rc;
-
-	rc = wait_event_timeout(am->wait, am->state != STATE_DISABLING, 15 * HZ);
-	if (rc == 0) {
-		MM_ERR("ARM9 did not reply to RPC am->state = %d\n", am->state);
-	}
-
-	if (am->state == STATE_DISABLED)
-		return 0;
-
-	MM_ERR("unexpected state %d while disabling?!\n", am->state);
-	return -ENODEV;
-}
-EXPORT_SYMBOL(audmgr_disable);
-
-int audmgr_register_device_info_callback(struct device_info_callback *dcb)
-{
-	struct audmgr_global *amg = &the_audmgr_state;
-	int i;
-
-	for (i = 0; i < MAX_DEVICE_INFO_CALLBACK; i++) {
-		if (NULL == amg->device_cb[i]) {
-			amg->device_cb[i] = dcb;
-			return 0;
-		}
-	}
-	return -EINVAL;
-}
-EXPORT_SYMBOL(audmgr_register_device_info_callback);
-
-int audmgr_deregister_device_info_callback(struct device_info_callback *dcb)
-{
-	struct audmgr_global *amg = &the_audmgr_state;
-	int i;
-
-	for (i = 0; i < MAX_DEVICE_INFO_CALLBACK; i++) {
-		if (dcb == amg->device_cb[i]) {
-			amg->device_cb[i] = NULL;
-			return 0;
-		}
-	}
-	return -EINVAL;
-}
-EXPORT_SYMBOL(audmgr_deregister_device_info_callback);
diff --git a/arch/arm/mach-msm/qdsp5/audmgr.h b/arch/arm/mach-msm/qdsp5/audmgr.h
deleted file mode 100644
index 01a0890..0000000
--- a/arch/arm/mach-msm/qdsp5/audmgr.h
+++ /dev/null
@@ -1,240 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/audmgr.h
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (c) 2008-2009, 2012 The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#ifndef _AUDIO_RPC_H_
-#define _AUDIO_RPC_H_
-
-#include <mach/qdsp5/qdsp5audppcmdi.h>
-
-enum rpc_aud_def_sample_rate_type {
-	RPC_AUD_DEF_SAMPLE_RATE_NONE,
-	RPC_AUD_DEF_SAMPLE_RATE_8000,
-	RPC_AUD_DEF_SAMPLE_RATE_11025,
-	RPC_AUD_DEF_SAMPLE_RATE_12000,
-	RPC_AUD_DEF_SAMPLE_RATE_16000,
-	RPC_AUD_DEF_SAMPLE_RATE_22050,
-	RPC_AUD_DEF_SAMPLE_RATE_24000,
-	RPC_AUD_DEF_SAMPLE_RATE_32000,
-	RPC_AUD_DEF_SAMPLE_RATE_44100,
-	RPC_AUD_DEF_SAMPLE_RATE_48000,
-	RPC_AUD_DEF_SAMPLE_RATE_MAX,
-};
-
-enum rpc_aud_def_method_type {
-	RPC_AUD_DEF_METHOD_NONE,
-	RPC_AUD_DEF_METHOD_KEY_BEEP,
-	RPC_AUD_DEF_METHOD_PLAYBACK,
-	RPC_AUD_DEF_METHOD_VOICE,
-	RPC_AUD_DEF_METHOD_RECORD,
-	RPC_AUD_DEF_METHOD_HOST_PCM,
-	RPC_AUD_DEF_METHOD_MIDI_OUT,
-	RPC_AUD_DEF_METHOD_RECORD_SBC,
-	RPC_AUD_DEF_METHOD_DTMF_RINGER,
-	RPC_AUD_DEF_METHOD_MAX,
-};
-
-enum rpc_aud_def_codec_type {
-	RPC_AUD_DEF_CODEC_NONE,
-	RPC_AUD_DEF_CODEC_DTMF,
-	RPC_AUD_DEF_CODEC_MIDI,
-	RPC_AUD_DEF_CODEC_MP3,
-	RPC_AUD_DEF_CODEC_PCM,
-	RPC_AUD_DEF_CODEC_AAC,
-	RPC_AUD_DEF_CODEC_WMA,
-	RPC_AUD_DEF_CODEC_RA,
-	RPC_AUD_DEF_CODEC_ADPCM,
-	RPC_AUD_DEF_CODEC_GAUDIO,
-	RPC_AUD_DEF_CODEC_VOC_EVRC,
-	RPC_AUD_DEF_CODEC_VOC_13K,
-	RPC_AUD_DEF_CODEC_VOC_4GV_NB,
-	RPC_AUD_DEF_CODEC_VOC_AMR,
-	RPC_AUD_DEF_CODEC_VOC_EFR,
-	RPC_AUD_DEF_CODEC_VOC_FR,
-	RPC_AUD_DEF_CODEC_VOC_HR,
-	RPC_AUD_DEF_CODEC_VOC_CDMA,
-	RPC_AUD_DEF_CODEC_VOC_CDMA_WB,
-	RPC_AUD_DEF_CODEC_VOC_UMTS,
-	RPC_AUD_DEF_CODEC_VOC_UMTS_WB,
-	RPC_AUD_DEF_CODEC_SBC,
-	RPC_AUD_DEF_CODEC_VOC_PCM,
-	RPC_AUD_DEF_CODEC_AMR_WB,
-	RPC_AUD_DEF_CODEC_AMR_WB_PLUS,
-	RPC_AUD_DEF_CODEC_AAC_BSAC,
-	RPC_AUD_DEF_CODEC_MAX,
-	RPC_AUD_DEF_CODEC_AMR_NB,
-	RPC_AUD_DEF_CODEC_13K,
-	RPC_AUD_DEF_CODEC_EVRC,
-	RPC_AUD_DEF_CODEC_AC3,
-	RPC_AUD_DEF_CODEC_MAX_002,
-};
-
-enum rpc_snd_method_type {
-	RPC_SND_METHOD_VOICE = 0,
-	RPC_SND_METHOD_KEY_BEEP,
-	RPC_SND_METHOD_MESSAGE,
-	RPC_SND_METHOD_RING,
-	RPC_SND_METHOD_MIDI,
-	RPC_SND_METHOD_AUX,
-	RPC_SND_METHOD_MAX,
-};
-
-enum rpc_voc_codec_type {
-	RPC_VOC_CODEC_DEFAULT,
-	RPC_VOC_CODEC_ON_CHIP_0 = RPC_VOC_CODEC_DEFAULT,
-	RPC_VOC_CODEC_ON_CHIP_1,
-	RPC_VOC_CODEC_STEREO_HEADSET,
-	RPC_VOC_CODEC_ON_CHIP_AUX,
-	RPC_VOC_CODEC_BT_OFF_BOARD,
-	RPC_VOC_CODEC_BT_A2DP,
-	RPC_VOC_CODEC_OFF_BOARD,
-	RPC_VOC_CODEC_SDAC,
-	RPC_VOC_CODEC_RX_EXT_SDAC_TX_INTERNAL,
-	RPC_VOC_CODEC_IN_STEREO_SADC_OUT_MONO_HANDSET,
-	RPC_VOC_CODEC_IN_STEREO_SADC_OUT_STEREO_HEADSET,
-	RPC_VOC_CODEC_TX_INT_SADC_RX_EXT_AUXPCM,
-	RPC_VOC_CODEC_EXT_STEREO_SADC_OUT_MONO_HANDSET,
-	RPC_VOC_CODEC_EXT_STEREO_SADC_OUT_STEREO_HEADSET,
-	RPC_VOC_CODEC_TTY_ON_CHIP_1,
-	RPC_VOC_CODEC_TTY_OFF_BOARD,
-	RPC_VOC_CODEC_TTY_VCO,
-	RPC_VOC_CODEC_TTY_HCO,
-	RPC_VOC_CODEC_ON_CHIP_0_DUAL_MIC,
-	RPC_VOC_CODEC_MAX,
-	RPC_VOC_CODEC_NONE,
-};
-
-enum rpc_audmgr_status_type {
-	RPC_AUDMGR_STATUS_READY,
-	RPC_AUDMGR_STATUS_CODEC_CONFIG,
-	RPC_AUDMGR_STATUS_PENDING,
-	RPC_AUDMGR_STATUS_SUSPEND,
-	RPC_AUDMGR_STATUS_FAILURE,
-	RPC_AUDMGR_STATUS_VOLUME_CHANGE,
-	RPC_AUDMGR_STATUS_DISABLED,
-	RPC_AUDMGR_STATUS_ERROR,
-	RPC_AUDMGR_STATUS_DEVICE_CONFIG,
-	RPC_AUDMGR_STATUS_DEVICE_INFO
-
-};
-
-struct rpc_audmgr_enable_client_args {
-	uint32_t set_to_one;
-	uint32_t tx_sample_rate;
-	uint32_t rx_sample_rate;
-	uint32_t def_method;
-	uint32_t codec_type;
-	uint32_t snd_method;
-
-	uint32_t cb_func;
-	uint32_t client_data;
-};
-	
-#define AUDMGR_ENABLE_CLIENT			2
-#define AUDMGR_DISABLE_CLIENT			3
-#define AUDMGR_SUSPEND_EVENT_RSP		4
-#define AUDMGR_REGISTER_OPERATION_LISTENER	5
-#define AUDMGR_UNREGISTER_OPERATION_LISTENER	6
-#define AUDMGR_REGISTER_CODEC_LISTENER		7
-#define AUDMGR_GET_RX_SAMPLE_RATE		8
-#define AUDMGR_GET_TX_SAMPLE_RATE		9
-#define AUDMGR_SET_DEVICE_MODE			10
-#define MIN_RPC_DATA_LENGTH 16
-
-#define AUDMGR_PROG_VERS "rs30000013:0x7feccbff"
-#define AUDMGR_PROG 0x30000013
-#define AUDMGR_VERS 0x7feccbff
-#define AUDMGR_VERS_COMP 0x00010001
-#define AUDMGR_VERS_COMP_VER2 0x00020001
-#define AUDMGR_VERS_COMP_VER3 0x00030001
-#define AUDMGR_VERS_COMP_VER4 0x00040001
-
-struct cad_device_info_type {
-	uint32_t rx_device;
-	uint32_t tx_device;
-	uint32_t ear_mute;
-	uint32_t mic_mute;
-	uint32_t volume;
-};
-
-struct rpc_audmgr_cb_common {
-	uint32_t cb_id; /* cb_func */
-	uint32_t status; /* Audmgr status */
-	uint32_t set_to_one;  /* Pointer status (1 = valid, 0  = invalid) */
-	uint32_t disc;
-	/* disc = AUDMGR_STATUS_READY => data=handle
-	   disc = AUDMGR_STATUS_CODEC_CONFIG => data = volume
-	   disc = AUDMGR_STATUS_DISABLED => data =status_disabled
-	   disc = AUDMGR_STATUS_VOLUME_CHANGE => data = volume_change */
-};
-
-struct rpc_audmgr_cb_ready {
-	struct rpc_audmgr_cb_common c_data;
-	union {
-		uint32_t handle;
-		uint32_t volume;
-		uint32_t status_disabled;
-		uint32_t volume_change;
-	} u;
-	uint32_t client_data;
-};
-
-struct rpc_audmgr_cb_device_info {
-	struct rpc_audmgr_cb_common c_data;
-	struct cad_device_info_type d;
-	uint32_t client_data;
-};
-
-#define AUDMGR_CB_FUNC_PTR			1
-#define AUDMGR_OPR_LSTNR_CB_FUNC_PTR		2
-#define AUDMGR_CODEC_LSTR_FUNC_PTR		3
-
-struct dev_evt_msg {
-	struct cad_device_info_type dev_type;
-	uint32_t acdb_id;
-	int session_info;
-	uint32_t sample_rate;
-};
-
-typedef void (*device_info_func)(struct dev_evt_msg *evt_msg, void *private);
-
-struct device_info_callback {
-	device_info_func func;
-	void *private;
-};
-
-struct audmgr {
-	wait_queue_head_t wait;
-	uint32_t handle;
-	int state;
-	struct dev_evt_msg evt;
-};
-
-struct audmgr_config {
-	uint32_t tx_rate;
-	uint32_t rx_rate;
-	uint32_t def_method;
-	uint32_t codec;
-	uint32_t snd_method;
-};
-
-int audmgr_register_device_info_callback(struct device_info_callback *dcb);
-int audmgr_deregister_device_info_callback(struct device_info_callback *dcb);
-
-int audmgr_open(struct audmgr *am);
-int audmgr_close(struct audmgr *am);
-int audmgr_enable(struct audmgr *am, struct audmgr_config *cfg);
-int audmgr_disable(struct audmgr *am);
-#endif
diff --git a/arch/arm/mach-msm/qdsp5/audmgr_new.h b/arch/arm/mach-msm/qdsp5/audmgr_new.h
deleted file mode 100644
index d775a93..0000000
--- a/arch/arm/mach-msm/qdsp5/audmgr_new.h
+++ /dev/null
@@ -1,197 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/audmgr.h
- *
- * Copyright 2008,2012 (c) The Linux Foundation. All rights reserved.
- * Copyright (C) 2008 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#ifndef _ARCH_ARM_MACH_MSM_AUDMGR_NEW_H
-#define _ARCH_ARM_MACH_MSM_AUDMGR_NEW_H
-
-enum rpc_aud_def_sample_rate_type {
-	RPC_AUD_DEF_SAMPLE_RATE_NONE,
-	RPC_AUD_DEF_SAMPLE_RATE_8000,
-	RPC_AUD_DEF_SAMPLE_RATE_11025,
-	RPC_AUD_DEF_SAMPLE_RATE_12000,
-	RPC_AUD_DEF_SAMPLE_RATE_16000,
-	RPC_AUD_DEF_SAMPLE_RATE_22050,
-	RPC_AUD_DEF_SAMPLE_RATE_24000,
-	RPC_AUD_DEF_SAMPLE_RATE_32000,
-	RPC_AUD_DEF_SAMPLE_RATE_44100,
-	RPC_AUD_DEF_SAMPLE_RATE_48000,
-	RPC_AUD_DEF_SAMPLE_RATE_MAX,
-};
-
-enum rpc_aud_def_method_type {
-	RPC_AUD_DEF_METHOD_NONE,
-	RPC_AUD_DEF_METHOD_KEY_BEEP,
-	RPC_AUD_DEF_METHOD_PLAYBACK,
-	RPC_AUD_DEF_METHOD_VOICE,
-	RPC_AUD_DEF_METHOD_RECORD,
-	RPC_AUD_DEF_METHOD_HOST_PCM,
-	RPC_AUD_DEF_METHOD_MIDI_OUT,
-	RPC_AUD_DEF_METHOD_RECORD_SBC,
-	RPC_AUD_DEF_METHOD_DTMF_RINGER,
-	RPC_AUD_DEF_METHOD_MAX,
-};
-
-enum rpc_aud_def_codec_type {
-	RPC_AUD_DEF_CODEC_NONE,
-	RPC_AUD_DEF_CODEC_DTMF,
-	RPC_AUD_DEF_CODEC_MIDI,
-	RPC_AUD_DEF_CODEC_MP3,
-	RPC_AUD_DEF_CODEC_PCM,
-	RPC_AUD_DEF_CODEC_AAC,
-	RPC_AUD_DEF_CODEC_WMA,
-	RPC_AUD_DEF_CODEC_RA,
-	RPC_AUD_DEF_CODEC_ADPCM,
-	RPC_AUD_DEF_CODEC_GAUDIO,
-	RPC_AUD_DEF_CODEC_VOC_EVRC,
-	RPC_AUD_DEF_CODEC_VOC_13K,
-	RPC_AUD_DEF_CODEC_VOC_4GV_NB,
-	RPC_AUD_DEF_CODEC_VOC_AMR,
-	RPC_AUD_DEF_CODEC_VOC_EFR,
-	RPC_AUD_DEF_CODEC_VOC_FR,
-	RPC_AUD_DEF_CODEC_VOC_HR,
-	RPC_AUD_DEF_CODEC_VOC_CDMA,
-	RPC_AUD_DEF_CODEC_VOC_CDMA_WB,
-	RPC_AUD_DEF_CODEC_VOC_UMTS,
-	RPC_AUD_DEF_CODEC_VOC_UMTS_WB,
-	RPC_AUD_DEF_CODEC_SBC,
-	RPC_AUD_DEF_CODEC_VOC_PCM,
-	RPC_AUD_DEF_CODEC_AMR_WB,
-	RPC_AUD_DEF_CODEC_AMR_WB_PLUS,
-	RPC_AUD_DEF_CODEC_AAC_BSAC,
-	RPC_AUD_DEF_CODEC_MAX,
-	RPC_AUD_DEF_CODEC_AMR_NB,
-	RPC_AUD_DEF_CODEC_13K,
-	RPC_AUD_DEF_CODEC_EVRC,
-	RPC_AUD_DEF_CODEC_AC3,
-	RPC_AUD_DEF_CODEC_MAX_002,
-};
-
-enum rpc_snd_method_type {
-	RPC_SND_METHOD_VOICE = 0,
-	RPC_SND_METHOD_KEY_BEEP,
-	RPC_SND_METHOD_MESSAGE,
-	RPC_SND_METHOD_RING,
-	RPC_SND_METHOD_MIDI,
-	RPC_SND_METHOD_AUX,
-	RPC_SND_METHOD_MAX,
-};
-
-enum rpc_voc_codec_type {
-	RPC_VOC_CODEC_DEFAULT,
-	RPC_VOC_CODEC_ON_CHIP_0 = RPC_VOC_CODEC_DEFAULT,
-	RPC_VOC_CODEC_ON_CHIP_1,
-	RPC_VOC_CODEC_STEREO_HEADSET,
-	RPC_VOC_CODEC_ON_CHIP_AUX,
-	RPC_VOC_CODEC_BT_OFF_BOARD,
-	RPC_VOC_CODEC_BT_A2DP,
-	RPC_VOC_CODEC_OFF_BOARD,
-	RPC_VOC_CODEC_SDAC,
-	RPC_VOC_CODEC_RX_EXT_SDAC_TX_INTERNAL,
-	RPC_VOC_CODEC_IN_STEREO_SADC_OUT_MONO_HANDSET,
-	RPC_VOC_CODEC_IN_STEREO_SADC_OUT_STEREO_HEADSET,
-	RPC_VOC_CODEC_TX_INT_SADC_RX_EXT_AUXPCM,
-	RPC_VOC_CODEC_EXT_STEREO_SADC_OUT_MONO_HANDSET,
-	RPC_VOC_CODEC_EXT_STEREO_SADC_OUT_STEREO_HEADSET,
-	RPC_VOC_CODEC_TTY_ON_CHIP_1,
-	RPC_VOC_CODEC_TTY_OFF_BOARD,
-	RPC_VOC_CODEC_TTY_VCO,
-	RPC_VOC_CODEC_TTY_HCO,
-	RPC_VOC_CODEC_ON_CHIP_0_DUAL_MIC,
-	RPC_VOC_CODEC_MAX,
-	RPC_VOC_CODEC_NONE,
-};
-
-enum rpc_audmgr_status_type {
-	RPC_AUDMGR_STATUS_READY,
-	RPC_AUDMGR_STATUS_CODEC_CONFIG,
-	RPC_AUDMGR_STATUS_PENDING,
-	RPC_AUDMGR_STATUS_SUSPEND,
-	RPC_AUDMGR_STATUS_FAILURE,
-	RPC_AUDMGR_STATUS_VOLUME_CHANGE,
-	RPC_AUDMGR_STATUS_DISABLED,
-	RPC_AUDMGR_STATUS_ERROR,
-};
-
-struct rpc_audmgr_enable_client_args {
-	uint32_t set_to_one;
-	uint32_t tx_sample_rate;
-	uint32_t rx_sample_rate;
-	uint32_t def_method;
-	uint32_t codec_type;
-	uint32_t snd_method;
-
-	uint32_t cb_func;
-	uint32_t client_data;
-};
-	
-#define AUDMGR_ENABLE_CLIENT			2
-#define AUDMGR_DISABLE_CLIENT			3
-#define AUDMGR_SUSPEND_EVENT_RSP		4
-#define AUDMGR_REGISTER_OPERATION_LISTENER	5
-#define AUDMGR_UNREGISTER_OPERATION_LISTENER	6
-#define AUDMGR_REGISTER_CODEC_LISTENER		7
-#define AUDMGR_GET_RX_SAMPLE_RATE		8
-#define AUDMGR_GET_TX_SAMPLE_RATE		9
-#define AUDMGR_SET_DEVICE_MODE			10
-
-#define AUDMGR_PROG 0x30000013
-#define AUDMGR_VERS MSM_RPC_VERS(1,0)
-
-struct rpc_audmgr_cb_func_ptr {
-	uint32_t cb_id;
-	uint32_t status; /* Audmgr status */
-	uint32_t set_to_one;  /* Pointer status (1 = valid, 0  = invalid) */
-	uint32_t disc;
-	/* disc = AUDMGR_STATUS_READY => data=handle
-	   disc = AUDMGR_STATUS_CODEC_CONFIG => data = handle
-	   disc = AUDMGR_STATUS_DISABLED => data =status_disabled
-	   disc = AUDMGR_STATUS_VOLUME_CHANGE => data = volume-change */
-	union {
-		uint32_t handle;
-		uint32_t volume;
-		uint32_t status_disabled;
-		uint32_t volume_change;
-	} u;
-};
-
-#define AUDMGR_CB_FUNC_PTR			1
-#define AUDMGR_OPR_LSTNR_CB_FUNC_PTR		2
-#define AUDMGR_CODEC_LSTR_FUNC_PTR		3
-
-#define AUDMGR_CB_PROG 0x31000013
-#define AUDMGR_CB_VERS 0xf8e3e2d9
-
-struct audmgr {
-	wait_queue_head_t wait;
-	uint32_t handle;
-	struct msm_rpc_endpoint *ept;
-	struct task_struct *task;
-	int state;
-};
-
-struct audmgr_config {
-	uint32_t tx_rate;
-	uint32_t rx_rate;
-	uint32_t def_method;
-	uint32_t codec;
-	uint32_t snd_method;
-};
-
-int audmgr_open(struct audmgr *am);
-int audmgr_close(struct audmgr *am);
-int audmgr_enable(struct audmgr *am, struct audmgr_config *cfg);
-int audmgr_disable(struct audmgr *am);
-#endif
diff --git a/arch/arm/mach-msm/qdsp5/audpp.c b/arch/arm/mach-msm/qdsp5/audpp.c
deleted file mode 100644
index bcc00a4..0000000
--- a/arch/arm/mach-msm/qdsp5/audpp.c
+++ /dev/null
@@ -1,1038 +0,0 @@
-
-/* arch/arm/mach-msm/qdsp5/audpp.c
- *
- * common code to deal with the AUDPP dsp task (audio postproc)
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (c) 2009-2010, 2012-2013 The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/wait.h>
-#include <linux/delay.h>
-#include <linux/sched.h>
-#include <linux/platform_device.h>
-#include <linux/dma-mapping.h>
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-#include <mach/board.h>
-#include <mach/msm_adsp.h>
-
-#include "audmgr.h"
-
-#include <mach/qdsp5/qdsp5audppcmdi.h>
-#include <mach/qdsp5/qdsp5audppmsg.h>
-#include <mach/qdsp5/qdsp5audpp.h>
-#include <mach/qdsp5v2/audio_acdbi.h>
-#include <mach/debug_mm.h>
-
-#include "evlog.h"
-
-enum {
-	EV_NULL,
-	EV_ENABLE,
-	EV_DISABLE,
-	EV_EVENT,
-	EV_DATA,
-};
-
-static const char *dsp_log_strings[] = {
-	"NULL",
-	"ENABLE",
-	"DISABLE",
-	"EVENT",
-	"DATA",
-};
-
-DECLARE_LOG(dsp_log, 64, dsp_log_strings);
-
-static int __init _dsp_log_init(void)
-{
-	return ev_log_init(&dsp_log);
-}
-
-module_init(_dsp_log_init);
-#define LOG(id,arg) ev_log_write(&dsp_log, id, arg)
-
-static DEFINE_MUTEX(audpp_lock);
-static DEFINE_MUTEX(audpp_dec_lock);
-
-#define CH_COUNT 5
-#define AUDPP_CLNT_MAX_COUNT 6
-#define AUDPP_AVSYNC_INFO_SIZE 7
-
-#define AUDPP_SRS_PARAMS 2
-#define AUDPP_SRS_PARAMS_G 0
-#define AUDPP_SRS_PARAMS_W 1
-#define AUDPP_SRS_PARAMS_C 2
-#define AUDPP_SRS_PARAMS_H 3
-#define AUDPP_SRS_PARAMS_P 4
-#define AUDPP_SRS_PARAMS_L 5
-
-#define AUDPP_CMD_CFG_OBJ_UPDATE 0x8000
-#define AUDPP_CMD_EQ_FLAG_DIS	0x0000
-#define AUDPP_CMD_EQ_FLAG_ENA	-1
-#define AUDPP_CMD_IIR_FLAG_DIS	  0x0000
-#define AUDPP_CMD_IIR_FLAG_ENA	  -1
-
-#define MAX_EVENT_CALLBACK_CLIENTS	2
-
-#define AUDPP_CONCURRENCY_DEFAULT 6	/* All non tunnel mode */
-#define AUDPP_MAX_DECODER_CNT 5
-#define AUDPP_CODEC_MASK 0x000000FF
-#define AUDPP_MODE_MASK 0x00000F00
-#define AUDPP_OP_MASK 0xF0000000
-
-struct audpp_decoder_info {
-	unsigned int codec;
-	pid_t pid;
-};
-
-struct audpp_state {
-	struct msm_adsp_module *mod;
-	audpp_event_func func[AUDPP_CLNT_MAX_COUNT];
-	void *private[AUDPP_CLNT_MAX_COUNT];
-	struct mutex *lock;
-	unsigned open_count;
-	unsigned enabled;
-
-	/* Related to decoder allocation */
-	struct mutex *lock_dec;
-	struct msm_adspdec_database *dec_database;
-	struct audpp_decoder_info dec_info_table[AUDPP_MAX_DECODER_CNT];
-	unsigned dec_inuse;
-	unsigned long concurrency;
-
-	/* which channels are actually enabled */
-	unsigned avsync_mask;
-
-	/* flags, 48 bits sample/bytes counter per channel */
-	uint16_t avsync[CH_COUNT * AUDPP_CLNT_MAX_COUNT + 1];
-	struct audpp_event_callback *cb_tbl[MAX_EVENT_CALLBACK_CLIENTS];
-
-	spinlock_t avsync_lock;
-
-	wait_queue_head_t event_wait;
-};
-
-struct audpp_state the_audpp_state = {
-	.lock = &audpp_lock,
-	.lock_dec = &audpp_dec_lock,
-};
-
-int audpp_send_queue1(void *cmd, unsigned len)
-{
-	return msm_adsp_write(the_audpp_state.mod,
-			      QDSP_uPAudPPCmd1Queue, cmd, len);
-}
-EXPORT_SYMBOL(audpp_send_queue1);
-
-int audpp_send_queue2(void *cmd, unsigned len)
-{
-	return msm_adsp_write(the_audpp_state.mod,
-			      QDSP_uPAudPPCmd2Queue, cmd, len);
-}
-EXPORT_SYMBOL(audpp_send_queue2);
-
-int audpp_send_queue3(void *cmd, unsigned len)
-{
-	return msm_adsp_write(the_audpp_state.mod,
-			      QDSP_uPAudPPCmd3Queue, cmd, len);
-}
-EXPORT_SYMBOL(audpp_send_queue3);
-
-static int audpp_dsp_config(int enable)
-{
-	audpp_cmd_cfg cmd;
-
-	cmd.cmd_id = AUDPP_CMD_CFG;
-	cmd.cfg = enable ? AUDPP_CMD_CFG_ENABLE : AUDPP_CMD_CFG_SLEEP;
-
-	return audpp_send_queue1(&cmd, sizeof(cmd));
-}
-
-int is_audpp_enable(void)
-{
-	struct audpp_state *audpp = &the_audpp_state;
-
-	return audpp->enabled;
-}
-EXPORT_SYMBOL(is_audpp_enable);
-
-int audpp_register_event_callback(struct audpp_event_callback *ecb)
-{
-	struct audpp_state *audpp = &the_audpp_state;
-	int i;
-
-	mutex_lock(audpp->lock);
-	for (i = 0; i < MAX_EVENT_CALLBACK_CLIENTS; ++i) {
-		if (NULL == audpp->cb_tbl[i]) {
-			audpp->cb_tbl[i] = ecb;
-			mutex_unlock(audpp->lock);
-			return 0;
-		}
-	}
-	mutex_unlock(audpp->lock);
-	return -1;
-}
-EXPORT_SYMBOL(audpp_register_event_callback);
-
-int audpp_unregister_event_callback(struct audpp_event_callback *ecb)
-{
-	struct audpp_state *audpp = &the_audpp_state;
-	int i;
-
-	mutex_lock(audpp->lock);
-	for (i = 0; i < MAX_EVENT_CALLBACK_CLIENTS; ++i) {
-		if (ecb == audpp->cb_tbl[i]) {
-			audpp->cb_tbl[i] = NULL;
-			mutex_unlock(audpp->lock);
-			return 0;
-		}
-	}
-	mutex_unlock(audpp->lock);
-	return -1;
-}
-EXPORT_SYMBOL(audpp_unregister_event_callback);
-
-static void audpp_broadcast(struct audpp_state *audpp, unsigned id,
-			    uint16_t *msg)
-{
-	unsigned n;
-
-	if ((id != AUDPP_MSG_PP_DISABLE_FEEDBACK) &&
-		(id != AUDPP_MSG_PP_FEATS_RE_ENABLE)) {
-		for (n = 0; n < AUDPP_CLNT_MAX_COUNT; n++) {
-			if (audpp->func[n])
-				audpp->func[n] (audpp->private[n], id, msg);
-		}
-	}
-
-	for (n = 0; n < MAX_EVENT_CALLBACK_CLIENTS; ++n)
-		if (audpp->cb_tbl[n] && audpp->cb_tbl[n]->fn)
-			audpp->cb_tbl[n]->fn(audpp->cb_tbl[n]->private, id,
-					     msg);
-}
-
-static void audpp_notify_clnt(struct audpp_state *audpp, unsigned clnt_id,
-			      unsigned id, uint16_t *msg)
-{
-	if (clnt_id < AUDPP_CLNT_MAX_COUNT && audpp->func[clnt_id])
-		audpp->func[clnt_id] (audpp->private[clnt_id], id, msg);
-}
-
-static void audpp_handle_pcmdmamiss(struct audpp_state *audpp,
-				    uint16_t bit_mask)
-{
-	uint8_t b_index;
-
-	for (b_index = 0; b_index < AUDPP_CLNT_MAX_COUNT; b_index++) {
-		if (bit_mask & (0x1 << b_index))
-			if (audpp->func[b_index])
-				audpp->func[b_index] (audpp->private[b_index],
-						      AUDPP_MSG_PCMDMAMISSED,
-						      &bit_mask);
-	}
-}
-
-static void audpp_fake_event(struct audpp_state *audpp, int id,
-			     unsigned event, unsigned arg)
-{
-	uint16_t msg[1];
-	msg[0] = arg;
-	audpp->func[id] (audpp->private[id], event, msg);
-}
-
-static void audpp_dsp_event(void *data, unsigned id, size_t len,
-			    void (*getevent) (void *ptr, size_t len))
-{
-	struct audpp_state *audpp = data;
-	unsigned long flags;
-	uint16_t msg[8];
-	int cid = 0;
-
-	if (id == AUDPP_MSG_AVSYNC_MSG) {
-		spin_lock_irqsave(&audpp->avsync_lock, flags);
-		getevent(audpp->avsync, sizeof(audpp->avsync));
-
-		/* mask off any channels we're not watching to avoid
-		 * cases where we might get one last update after
-		 * disabling avsync and end up in an odd state when
-		 * we next read...
-		 */
-		audpp->avsync[0] &= audpp->avsync_mask;
-		spin_unlock_irqrestore(&audpp->avsync_lock, flags);
-		return;
-	}
-
-	getevent(msg, sizeof(msg));
-
-	LOG(EV_EVENT, (id << 16) | msg[0]);
-	LOG(EV_DATA, (msg[1] << 16) | msg[2]);
-
-	switch (id) {
-	case AUDPP_MSG_STATUS_MSG:{
-			unsigned cid = msg[0];
-			MM_DBG("status %d %d %d\n", cid, msg[1], msg[2]);
-			if ((cid < 5) && audpp->func[cid])
-				audpp->func[cid] (audpp->private[cid], id, msg);
-			break;
-		}
-	case AUDPP_MSG_HOST_PCM_INTF_MSG:
-		if (audpp->func[5])
-			audpp->func[5] (audpp->private[5], id, msg);
-		break;
-	case AUDPP_MSG_PCMDMAMISSED:
-		audpp_handle_pcmdmamiss(audpp, msg[0]);
-		break;
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_INFO("ENABLE\n");
-			if (!audpp->enabled) {
-				audpp->enabled = 1;
-				wake_up(&audpp->event_wait);
-				audpp_broadcast(audpp, id, msg);
-			} else {
-				cid = msg[1];
-				audpp_fake_event(audpp, cid,
-					id, AUDPP_MSG_ENA_ENA);
-			}
-
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			if (audpp->open_count == 0) {
-				MM_INFO("DISABLE\n");
-				audpp->enabled = 0;
-				wake_up(&audpp->event_wait);
-				audpp_broadcast(audpp, id, msg);
-			} else {
-				cid = msg[1];
-				audpp_fake_event(audpp, cid,
-					id, AUDPP_MSG_ENA_DIS);
-				audpp->func[cid] = NULL;
-				audpp->private[cid] = NULL;
-			}
-		} else {
-			MM_ERR("invalid config msg %d\n", msg[0]);
-		}
-		break;
-	case AUDPP_MSG_ROUTING_ACK:
-		audpp_notify_clnt(audpp, msg[0], id, msg);
-		break;
-	case AUDPP_MSG_FLUSH_ACK:
-		audpp_notify_clnt(audpp, msg[0], id, msg);
-		break;
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable/disable(audpptask)");
-		break;
-	case AUDPP_MSG_FEAT_QUERY_DM_DONE:
-		MM_INFO(" RTC ACK --> %x %x %x\n", msg[0],\
-			msg[1], msg[2]);
-		acdb_rtc_set_err(msg[2]);
-		break;
-	case AUDPP_MSG_PP_DISABLE_FEEDBACK:
-		MM_DBG("PP Disable feedback due to mips limitation");
-		audpp_broadcast(audpp, id, msg);
-		break;
-	case AUDPP_MSG_PP_FEATS_RE_ENABLE:
-		MM_DBG("Re-enable the disabled PP features");
-		audpp_broadcast(audpp, id, msg);
-		break;
-	default:
-		MM_ERR("unhandled msg id %x\n", id);
-	}
-}
-
-static struct msm_adsp_ops adsp_ops = {
-	.event = audpp_dsp_event,
-};
-
-int audpp_enable(int id, audpp_event_func func, void *private)
-{
-	struct audpp_state *audpp = &the_audpp_state;
-	uint16_t msg[8];
-	int res = 0;
-	int rc;
-
-	if (id < -1 || id > 4)
-		return -EINVAL;
-
-	if (id == -1)
-		id = 5;
-
-	mutex_lock(audpp->lock);
-	if (audpp->func[id]) {
-		res = -EBUSY;
-		goto out;
-	}
-
-	audpp->func[id] = func;
-	audpp->private[id] = private;
-
-	LOG(EV_ENABLE, 1);
-	if (audpp->open_count++ == 0) {
-		MM_DBG("enable\n");
-		res = msm_adsp_get("AUDPPTASK", &audpp->mod, &adsp_ops, audpp);
-		if (res < 0) {
-			MM_ERR("cannot open AUDPPTASK\n");
-			audpp->open_count = 0;
-			audpp->func[id] = NULL;
-			audpp->private[id] = NULL;
-			goto out;
-		}
-		LOG(EV_ENABLE, 2);
-		msm_adsp_enable(audpp->mod);
-		audpp_dsp_config(1);
-		rc = wait_event_timeout(audpp->event_wait,
-					(audpp->enabled == 1),
-					3 * HZ);
-		if (rc == 0)
-			msm_adsp_dump(audpp->mod);
-	} else {
-		if (audpp->enabled) {
-			msg[0] = AUDPP_MSG_ENA_ENA;
-			msg[1] = id;
-			res = msm_adsp_generate_event(audpp, audpp->mod,
-					 AUDPP_MSG_CFG_MSG, sizeof(msg),
-					 sizeof(uint16_t), (void *)msg);
-			if (res < 0)
-				goto out;
-		}
-	}
-
-	res = 0;
-out:
-	mutex_unlock(audpp->lock);
-	return res;
-}
-EXPORT_SYMBOL(audpp_enable);
-
-void audpp_disable(int id, void *private)
-{
-	struct audpp_state *audpp = &the_audpp_state;
-	uint16_t msg[8];
-	int rc;
-
-	if (id < -1 || id > 4)
-		return;
-
-	if (id == -1)
-		id = 5;
-
-	mutex_lock(audpp->lock);
-	LOG(EV_DISABLE, 1);
-	if (!audpp->func[id])
-		goto out;
-	if (audpp->private[id] != private)
-		goto out;
-
-	msg[0] = AUDPP_MSG_ENA_DIS;
-	msg[1] = id;
-	rc = msm_adsp_generate_event(audpp, audpp->mod,
-				 AUDPP_MSG_CFG_MSG, sizeof(msg),
-				 sizeof(uint16_t), (void *)msg);
-	if (rc < 0)
-		goto out;
-
-	if (--audpp->open_count == 0) {
-		MM_DBG("disable\n");
-		LOG(EV_DISABLE, 2);
-		audpp_dsp_config(0);
-		rc = wait_event_timeout(audpp->event_wait,
-					(audpp->enabled == 0),
-					3 * HZ);
-		if (audpp->enabled == 0)
-			MM_INFO("Received CFG_MSG_DISABLE from ADSP\n");
-		else {
-			MM_ERR("Didn't receive CFG_MSG DISABLE \
-					message from ADSP\n");
-			if (rc == 0)
-				msm_adsp_dump(audpp->mod);
-		}
-		msm_adsp_disable(audpp->mod);
-		msm_adsp_put(audpp->mod);
-		audpp->mod = NULL;
-	}
-out:
-	mutex_unlock(audpp->lock);
-}
-EXPORT_SYMBOL(audpp_disable);
-
-#define BAD_ID(id) ((id < 0) || (id >= CH_COUNT))
-
-void audpp_avsync(int id, unsigned rate)
-{
-	unsigned long flags;
-	audpp_cmd_avsync cmd;
-
-	if (BAD_ID(id))
-		return;
-
-	spin_lock_irqsave(&the_audpp_state.avsync_lock, flags);
-	if (rate)
-		the_audpp_state.avsync_mask |= (1 << id);
-	else
-		the_audpp_state.avsync_mask &= (~(1 << id));
-	the_audpp_state.avsync[0] &= the_audpp_state.avsync_mask;
-	spin_unlock_irqrestore(&the_audpp_state.avsync_lock, flags);
-
-	cmd.cmd_id = AUDPP_CMD_AVSYNC;
-	cmd.object_number = id;
-	cmd.interrupt_interval_lsw = rate;
-	cmd.interrupt_interval_msw = rate >> 16;
-	audpp_send_queue1(&cmd, sizeof(cmd));
-}
-EXPORT_SYMBOL(audpp_avsync);
-
-unsigned audpp_avsync_sample_count(int id)
-{
-	struct audpp_state *audpp = &the_audpp_state;
-	uint16_t *avsync = audpp->avsync;
-	unsigned val;
-	unsigned long flags;
-	unsigned mask;
-
-	if (BAD_ID(id))
-		return 0;
-
-	mask = 1 << id;
-	id = id * AUDPP_AVSYNC_INFO_SIZE + 2;
-	spin_lock_irqsave(&audpp->avsync_lock, flags);
-	if (avsync[0] & mask)
-		val = (avsync[id] << 16) | avsync[id + 1];
-	else
-		val = 0;
-	spin_unlock_irqrestore(&audpp->avsync_lock, flags);
-
-	return val;
-}
-EXPORT_SYMBOL(audpp_avsync_sample_count);
-
-unsigned audpp_avsync_byte_count(int id)
-{
-	struct audpp_state *audpp = &the_audpp_state;
-	uint16_t *avsync = audpp->avsync;
-	unsigned val;
-	unsigned long flags;
-	unsigned mask;
-
-	if (BAD_ID(id))
-		return 0;
-
-	mask = 1 << id;
-	id = id * AUDPP_AVSYNC_INFO_SIZE + 5;
-	spin_lock_irqsave(&audpp->avsync_lock, flags);
-	if (avsync[0] & mask)
-		val = (avsync[id] << 16) | avsync[id + 1];
-	else
-		val = 0;
-	spin_unlock_irqrestore(&audpp->avsync_lock, flags);
-
-	return val;
-}
-EXPORT_SYMBOL(audpp_avsync_byte_count);
-
-int audpp_set_volume_and_pan(unsigned id, unsigned volume, int pan)
-{
-	/* cmd, obj_cfg[7], cmd_type, volume, pan */
-	uint16_t cmd[11];
-
-	if (id > 6)
-		return -EINVAL;
-
-	memset(cmd, 0, sizeof(cmd));
-	cmd[0] = AUDPP_CMD_CFG_OBJECT_PARAMS;
-	cmd[1 + id] = AUDPP_CMD_CFG_OBJ_UPDATE;
-	cmd[8] = AUDPP_CMD_VOLUME_PAN;
-	cmd[9] = volume;
-	cmd[10] = pan;
-
-	return audpp_send_queue3(cmd, sizeof(cmd));
-}
-EXPORT_SYMBOL(audpp_set_volume_and_pan);
-
-/* Implementation of COPP features */
-int audpp_dsp_set_mbadrc(unsigned id, unsigned enable,
-			 audpp_cmd_cfg_object_params_mbadrc *mbadrc)
-{
-	audpp_cmd_cfg_object_params_mbadrc cmd;
-
-	if (id != 6)
-		return -EINVAL;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.comman_cfg = AUDPP_CMD_CFG_OBJ_UPDATE;
-	cmd.common.command_type = AUDPP_CMD_MBADRC;
-
-	if (enable) {
-		memcpy(&cmd.num_bands, &mbadrc->num_bands,
-		       sizeof(*mbadrc) -
-		       (AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2));
-		cmd.enable = AUDPP_CMD_ADRC_FLAG_ENA;
-	} else
-		cmd.enable = AUDPP_CMD_ADRC_FLAG_DIS;
-
-	/*order the writes to mbadrc */
-	dma_coherent_pre_ops();
-	return audpp_send_queue3(&cmd, sizeof(cmd));
-}
-EXPORT_SYMBOL(audpp_dsp_set_mbadrc);
-
-int audpp_dsp_set_qconcert_plus(unsigned id, unsigned enable,
-				audpp_cmd_cfg_object_params_qconcert *
-				qconcert_plus)
-{
-	audpp_cmd_cfg_object_params_qconcert cmd;
-	if (id != 6)
-		return -EINVAL;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.comman_cfg = AUDPP_CMD_CFG_OBJ_UPDATE;
-	cmd.common.command_type = AUDPP_CMD_QCONCERT;
-
-	if (enable) {
-		memcpy(&cmd.op_mode, &qconcert_plus->op_mode,
-		       sizeof(audpp_cmd_cfg_object_params_qconcert) -
-		       (AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2));
-		cmd.enable_flag = AUDPP_CMD_ADRC_FLAG_ENA;
-	} else
-		cmd.enable_flag = AUDPP_CMD_ADRC_FLAG_DIS;
-
-	return audpp_send_queue3(&cmd, sizeof(cmd));
-}
-
-int audpp_dsp_set_rx_iir(unsigned id, unsigned enable,
-			 audpp_cmd_cfg_object_params_pcm *iir)
-{
-	audpp_cmd_cfg_object_params_pcm cmd;
-
-	if (id != 6)
-		return -EINVAL;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.comman_cfg = AUDPP_CMD_CFG_OBJ_UPDATE;
-	cmd.common.command_type = AUDPP_CMD_IIR_TUNING_FILTER;
-
-	if (enable) {
-		cmd.active_flag = AUDPP_CMD_IIR_FLAG_ENA;
-		cmd.num_bands = iir->num_bands;
-		memcpy(&cmd.params_filter, &iir->params_filter,
-		       sizeof(iir->params_filter));
-	} else
-		cmd.active_flag = AUDPP_CMD_IIR_FLAG_DIS;
-
-	return audpp_send_queue3(&cmd, sizeof(cmd));
-}
-EXPORT_SYMBOL(audpp_dsp_set_rx_iir);
-
-int audpp_dsp_set_rx_srs_trumedia_g(
-	struct audpp_cmd_cfg_object_params_srstm_g *srstm)
-{
-	struct audpp_cmd_cfg_object_params_srstm_g cmd;
-
-	MM_DBG("%s\n", __func__);
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_SRS_PARAMS;
-	cmd.common.comman_cfg = AUDPP_CMD_CFG_OBJ_UPDATE;
-	cmd.common.command_type = AUDPP_SRS_PARAMS_G;
-
-	memcpy(cmd.v, srstm->v, sizeof(srstm->v));
-
-	return audpp_send_queue3(&cmd, sizeof(cmd));
-}
-EXPORT_SYMBOL(audpp_dsp_set_rx_srs_trumedia_g);
-
-int audpp_dsp_set_rx_srs_trumedia_w(
-	struct audpp_cmd_cfg_object_params_srstm_w *srstm)
-{
-	struct audpp_cmd_cfg_object_params_srstm_w cmd;
-
-	MM_DBG("%s\n", __func__);
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_SRS_PARAMS;
-	cmd.common.comman_cfg = AUDPP_CMD_CFG_OBJ_UPDATE;
-	cmd.common.command_type = AUDPP_SRS_PARAMS_W;
-
-	memcpy(cmd.v, srstm->v, sizeof(srstm->v));
-
-	return audpp_send_queue3(&cmd, sizeof(cmd));
-}
-EXPORT_SYMBOL(audpp_dsp_set_rx_srs_trumedia_w);
-
-int audpp_dsp_set_rx_srs_trumedia_c(
-	struct audpp_cmd_cfg_object_params_srstm_c *srstm)
-{
-	struct audpp_cmd_cfg_object_params_srstm_c cmd;
-
-	MM_DBG("%s\n", __func__);
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_SRS_PARAMS;
-	cmd.common.comman_cfg = AUDPP_CMD_CFG_OBJ_UPDATE;
-	cmd.common.command_type = AUDPP_SRS_PARAMS_C;
-
-	memcpy(cmd.v, srstm->v, sizeof(srstm->v));
-
-	return audpp_send_queue3(&cmd, sizeof(cmd));
-}
-EXPORT_SYMBOL(audpp_dsp_set_rx_srs_trumedia_c);
-
-int audpp_dsp_set_rx_srs_trumedia_h(
-	struct audpp_cmd_cfg_object_params_srstm_h *srstm)
-{
-	struct audpp_cmd_cfg_object_params_srstm_h cmd;
-
-	MM_DBG("%s\n", __func__);
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_SRS_PARAMS;
-	cmd.common.comman_cfg = AUDPP_CMD_CFG_OBJ_UPDATE;
-	cmd.common.command_type = AUDPP_SRS_PARAMS_H;
-
-	memcpy(cmd.v, srstm->v, sizeof(srstm->v));
-
-	return audpp_send_queue3(&cmd, sizeof(cmd));
-}
-EXPORT_SYMBOL(audpp_dsp_set_rx_srs_trumedia_h);
-
-int audpp_dsp_set_rx_srs_trumedia_p(
-	struct audpp_cmd_cfg_object_params_srstm_p *srstm)
-{
-	struct audpp_cmd_cfg_object_params_srstm_p cmd;
-
-	MM_DBG("%s\n", __func__);
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_SRS_PARAMS;
-	cmd.common.comman_cfg = AUDPP_CMD_CFG_OBJ_UPDATE;
-	cmd.common.command_type = AUDPP_SRS_PARAMS_P;
-
-	memcpy(cmd.v, srstm->v, sizeof(srstm->v));
-
-	return audpp_send_queue3(&cmd, sizeof(cmd));
-}
-EXPORT_SYMBOL(audpp_dsp_set_rx_srs_trumedia_p);
-
-int audpp_dsp_set_rx_srs_trumedia_l(
-	struct audpp_cmd_cfg_object_params_srstm_l *srstm)
-{
-	struct audpp_cmd_cfg_object_params_srstm_l cmd;
-
-	MM_DBG("%s\n", __func__);
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_SRS_PARAMS;
-	cmd.common.comman_cfg = AUDPP_CMD_CFG_OBJ_UPDATE;
-	cmd.common.command_type = AUDPP_SRS_PARAMS_L;
-
-	memcpy(cmd.v, srstm->v, sizeof(srstm->v));
-
-	return audpp_send_queue3(&cmd, sizeof(cmd));
-}
-EXPORT_SYMBOL(audpp_dsp_set_rx_srs_trumedia_l);
-
-/* Implementation Of COPP + POPP */
-int audpp_dsp_set_eq(unsigned id, unsigned enable,
-		     audpp_cmd_cfg_object_params_eqalizer *eq)
-{
-	audpp_cmd_cfg_object_params_eqalizer cmd;
-	unsigned short *id_ptr = (unsigned short *)&cmd;
-
-	if (id > 6 || id == 5)
-		return -EINVAL;
-
-	memset(&cmd, 0, sizeof(cmd));
-	id_ptr[1 + id] = AUDPP_CMD_CFG_OBJ_UPDATE;
-	cmd.common.command_type = AUDPP_CMD_EQUALIZER;
-
-	if (enable) {
-		cmd.eq_flag = AUDPP_CMD_EQ_FLAG_ENA;
-		cmd.num_bands = eq->num_bands;
-		memcpy(&cmd.eq_coeff, &eq->eq_coeff, sizeof(eq->eq_coeff));
-	} else
-		cmd.eq_flag = AUDPP_CMD_EQ_FLAG_DIS;
-
-	return audpp_send_queue3(&cmd, sizeof(cmd));
-}
-EXPORT_SYMBOL(audpp_dsp_set_eq);
-
-int audpp_dsp_set_vol_pan(unsigned id,
-			  audpp_cmd_cfg_object_params_volume *vol_pan)
-{
-	audpp_cmd_cfg_object_params_volume cmd;
-	unsigned short *id_ptr = (unsigned short *)&cmd;
-
-	if (id > 6)
-		return -EINVAL;
-
-	memset(&cmd, 0, sizeof(cmd));
-	id_ptr[1 + id] = AUDPP_CMD_CFG_OBJ_UPDATE;
-	cmd.common.command_type = AUDPP_CMD_VOLUME_PAN;
-
-	cmd.volume = vol_pan->volume;
-	cmd.pan = vol_pan->pan;
-
-	return audpp_send_queue3(&cmd, sizeof(cmd));
-}
-EXPORT_SYMBOL(audpp_dsp_set_vol_pan);
-
-int audpp_pause(unsigned id, int pause)
-{
-	/* pause 1 = pause 0 = resume */
-	u16 pause_cmd[AUDPP_CMD_DEC_CTRL_LEN / sizeof(unsigned short)];
-
-	if (id >= CH_COUNT)
-		return -EINVAL;
-
-	memset(pause_cmd, 0, sizeof(pause_cmd));
-
-	pause_cmd[0] = AUDPP_CMD_DEC_CTRL;
-	if (pause == 1)
-		pause_cmd[1 + id] = AUDPP_CMD_UPDATE_V | AUDPP_CMD_PAUSE_V;
-	else if (pause == 0)
-		pause_cmd[1 + id] = AUDPP_CMD_UPDATE_V | AUDPP_CMD_RESUME_V;
-	else
-		return -EINVAL;
-
-	return audpp_send_queue1(pause_cmd, sizeof(pause_cmd));
-}
-EXPORT_SYMBOL(audpp_pause);
-
-int audpp_flush(unsigned id)
-{
-	u16 flush_cmd[AUDPP_CMD_DEC_CTRL_LEN / sizeof(unsigned short)];
-
-	if (id >= CH_COUNT)
-		return -EINVAL;
-
-	memset(flush_cmd, 0, sizeof(flush_cmd));
-
-	flush_cmd[0] = AUDPP_CMD_DEC_CTRL;
-	flush_cmd[1 + id] = AUDPP_CMD_UPDATE_V | AUDPP_CMD_FLUSH_V;
-
-	return audpp_send_queue1(flush_cmd, sizeof(flush_cmd));
-}
-EXPORT_SYMBOL(audpp_flush);
-
-/* dec_attrb = 7:0, 0 - No Decoder, else supported decoder *
- * like mp3, aac, wma etc ... *
- *           =  15:8, bit[8] = 1 - Tunnel, bit[9] = 1 - NonTunnel *
- *           =  31:16, reserved */
-int audpp_adec_alloc(unsigned dec_attrb, const char **module_name,
-		     unsigned *queueid)
-{
-	struct audpp_state *audpp = &the_audpp_state;
-	int decid = -1, idx, lidx, mode, codec;
-	int codecs_supported, min_codecs_supported;
-	unsigned int *concurrency_entry;
-	mutex_lock(audpp->lock_dec);
-	/* Represents in bit mask */
-	mode = ((dec_attrb & AUDPP_MODE_MASK) << 16);
-	codec = (1 << (dec_attrb & AUDPP_CODEC_MASK));
-	/* Point to Last entry of the row */
-	concurrency_entry = ((audpp->dec_database->dec_concurrency_table +
-			      ((audpp->concurrency + 1) *
-			       (audpp->dec_database->num_dec))) - 1);
-
-	lidx = audpp->dec_database->num_dec;
-	min_codecs_supported = sizeof(unsigned int) * 8;
-
-	MM_DBG("mode = 0x%08x codec = 0x%08x\n", mode, codec);
-
-	for (idx = lidx; idx > 0; idx--, concurrency_entry--) {
-		if (!(audpp->dec_inuse & (1 << (idx - 1)))) {
-			if ((mode & *concurrency_entry) &&
-			    (codec & *concurrency_entry)) {
-				/* Check supports minimum number codecs */
-				codecs_supported =
-				    audpp->dec_database->dec_info_list[idx -
-								       1].
-				    nr_codec_support;
-				if (codecs_supported < min_codecs_supported) {
-					lidx = idx - 1;
-					min_codecs_supported = codecs_supported;
-				}
-			}
-		}
-	}
-
-	if (lidx < audpp->dec_database->num_dec) {
-		audpp->dec_inuse |= (1 << lidx);
-		*module_name =
-		    audpp->dec_database->dec_info_list[lidx].module_name;
-		*queueid =
-		    audpp->dec_database->dec_info_list[lidx].module_queueid;
-		decid = audpp->dec_database->dec_info_list[lidx].module_decid;
-		audpp->dec_info_table[lidx].codec =
-		    (dec_attrb & AUDPP_CODEC_MASK);
-		audpp->dec_info_table[lidx].pid = current->pid;
-		/* point to row to get supported operation */
-		concurrency_entry =
-		    ((audpp->dec_database->dec_concurrency_table +
-		      ((audpp->concurrency) * (audpp->dec_database->num_dec))) +
-		     lidx);
-		decid |= ((*concurrency_entry & AUDPP_OP_MASK) >> 12);
-		MM_INFO("decid =0x%08x module_name=%s, queueid=%d \n",
-			decid, *module_name, *queueid);
-	}
-	mutex_unlock(audpp->lock_dec);
-	return decid;
-
-}
-EXPORT_SYMBOL(audpp_adec_alloc);
-
-void audpp_adec_free(int decid)
-{
-	struct audpp_state *audpp = &the_audpp_state;
-	int idx;
-	mutex_lock(audpp->lock_dec);
-	for (idx = audpp->dec_database->num_dec; idx > 0; idx--) {
-		if (audpp->dec_database->dec_info_list[idx - 1].module_decid ==
-		    decid) {
-			audpp->dec_inuse &= ~(1 << (idx - 1));
-			audpp->dec_info_table[idx - 1].codec = -1;
-			audpp->dec_info_table[idx - 1].pid = 0;
-			MM_INFO("free decid =%d \n", decid);
-			break;
-		}
-	}
-	mutex_unlock(audpp->lock_dec);
-	return;
-
-}
-EXPORT_SYMBOL(audpp_adec_free);
-
-static ssize_t concurrency_show(struct device *dev,
-				struct device_attribute *attr, char *buf)
-{
-	struct audpp_state *audpp = &the_audpp_state;
-	int rc;
-	mutex_lock(audpp->lock_dec);
-	rc = sprintf(buf, "%ld\n", audpp->concurrency);
-	mutex_unlock(audpp->lock_dec);
-	return rc;
-}
-
-static ssize_t concurrency_store(struct device *dev,
-				 struct device_attribute *attr,
-				 const char *buf, size_t count)
-{
-	struct audpp_state *audpp = &the_audpp_state;
-	unsigned long concurrency;
-	int rc = -1;
-	mutex_lock(audpp->lock_dec);
-	if (audpp->dec_inuse) {
-		MM_ERR("Can not change profile, while playback in progress\n");
-		goto done;
-	}
-	rc = strict_strtoul(buf, 10, &concurrency);
-	if (!rc &&
-		(concurrency < audpp->dec_database->num_concurrency_support)) {
-		audpp->concurrency = concurrency;
-		MM_DBG("Concurrency case %ld\n", audpp->concurrency);
-		rc = count;
-	} else {
-		MM_ERR("Not a valid Concurrency case\n");
-		rc = -EINVAL;
-	}
-done:
-	mutex_unlock(audpp->lock_dec);
-	return rc;
-}
-
-static ssize_t decoder_info_show(struct device *dev,
-				 struct device_attribute *attr, char *buf);
-static struct device_attribute dev_attr_decoder[AUDPP_MAX_DECODER_CNT] = {
-	__ATTR(decoder0, S_IRUGO, decoder_info_show, NULL),
-	__ATTR(decoder1, S_IRUGO, decoder_info_show, NULL),
-	__ATTR(decoder2, S_IRUGO, decoder_info_show, NULL),
-	__ATTR(decoder3, S_IRUGO, decoder_info_show, NULL),
-	__ATTR(decoder4, S_IRUGO, decoder_info_show, NULL),
-};
-
-static ssize_t decoder_info_show(struct device *dev,
-				 struct device_attribute *attr, char *buf)
-{
-	int cpy_sz = 0;
-	struct audpp_state *audpp = &the_audpp_state;
-	const ptrdiff_t off = attr - dev_attr_decoder;	/* decoder number */
-	mutex_lock(audpp->lock_dec);
-	cpy_sz += scnprintf(buf + cpy_sz, PAGE_SIZE - cpy_sz, "%d:",
-			    audpp->dec_info_table[off].codec);
-	cpy_sz += scnprintf(buf + cpy_sz, PAGE_SIZE - cpy_sz, "%d\n",
-			    audpp->dec_info_table[off].pid);
-	mutex_unlock(audpp->lock_dec);
-	return cpy_sz;
-}
-
-static DEVICE_ATTR(concurrency, S_IWUSR | S_IRUGO, concurrency_show,
-	    concurrency_store);
-static int audpp_probe(struct platform_device *pdev)
-{
-	int rc, idx;
-	struct audpp_state *audpp = &the_audpp_state;
-	audpp->concurrency = AUDPP_CONCURRENCY_DEFAULT;
-	audpp->dec_database =
-	    (struct msm_adspdec_database *)pdev->dev.platform_data;
-
-	MM_INFO("Number of decoder supported %d\n",
-			audpp->dec_database->num_dec);
-	MM_INFO("Number of concurrency supported %d\n",
-			audpp->dec_database->num_concurrency_support);
-
-	init_waitqueue_head(&audpp->event_wait);
-
-	spin_lock_init(&audpp->avsync_lock);
-
-	for (idx = 0; idx < audpp->dec_database->num_dec; idx++) {
-		audpp->dec_info_table[idx].codec = -1;
-		audpp->dec_info_table[idx].pid = 0;
-		MM_INFO("module_name:%s\n",
-			audpp->dec_database->dec_info_list[idx].module_name);
-		MM_INFO("queueid:%d\n",
-			audpp->dec_database->dec_info_list[idx].module_queueid);
-		MM_INFO("decid:%d\n",
-			audpp->dec_database->dec_info_list[idx].module_decid);
-		MM_INFO("nr_codec_support:%d\n",
-			audpp->dec_database->dec_info_list[idx].
-			nr_codec_support);
-	}
-
-	for (idx = 0; idx < audpp->dec_database->num_dec; idx++) {
-		rc = device_create_file(&pdev->dev, &dev_attr_decoder[idx]);
-		if (rc)
-			goto err;
-	}
-	rc = device_create_file(&pdev->dev, &dev_attr_concurrency);
-	if (rc)
-		goto err;
-	else
-		goto done;
-err:
-	while (idx--)
-		device_remove_file(&pdev->dev, &dev_attr_decoder[idx]);
-done:
-	return rc;
-}
-
-static struct platform_driver audpp_plat_driver = {
-	.probe = audpp_probe,
-	.driver = {
-		   .name = "msm_adspdec",
-		   .owner = THIS_MODULE,
-		   },
-};
-
-static int __init audpp_init(void)
-{
-	return platform_driver_register(&audpp_plat_driver);
-}
-
-device_initcall(audpp_init);
diff --git a/arch/arm/mach-msm/qdsp5/audpreproc.c b/arch/arm/mach-msm/qdsp5/audpreproc.c
deleted file mode 100644
index 45d9153..0000000
--- a/arch/arm/mach-msm/qdsp5/audpreproc.c
+++ /dev/null
@@ -1,430 +0,0 @@
-/*
- * Common code to deal with the AUDPREPROC dsp task (audio preprocessing)
- *
- * Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
- *
- * Based on the audpp layer in arch/arm/mach-msm/qdsp5/audpp.c
- *
- * Copyright (C) 2008 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <mach/msm_adsp.h>
-#include <mach/debug_mm.h>
-#include <mach/qdsp5/qdsp5audpreproc.h>
-#include <mach/qdsp5/qdsp5audreccmdi.h>
-#include <mach/qdsp5v2/audio_acdbi.h>
-
-
-static DEFINE_MUTEX(audpreproc_lock);
-
-struct msm_adspenc_info {
-	const char *module_name;
-	unsigned module_queueids;
-	int module_encid; /* streamid */
-	int enc_formats; /* supported formats */
-	int nr_codec_support; /* number of codec suported */
-};
-
-#define ENC_MODULE_INFO(name, queueids, encid, formats, nr_codec) \
-	{.module_name = name, .module_queueids = queueids, \
-	 .module_encid = encid, .enc_formats = formats, \
-	 .nr_codec_support = nr_codec }
-
-#ifdef CONFIG_MSM7X27A_AUDIO
-#define ENC0_FORMAT ((1<<AUDREC_CMD_TYPE_1_INDEX_SBC)| \
-		(1<<AUDREC_CMD_TYPE_0_INDEX_AAC)| \
-		(1<<AUDREC_CMD_TYPE_0_INDEX_AMRNB)| \
-		(1<<AUDREC_CMD_TYPE_0_INDEX_EVRC)| \
-		(1<<AUDREC_CMD_TYPE_0_INDEX_QCELP))
-
-#define ENC1_FORMAT (1<<AUDREC_CMD_TYPE_0_INDEX_WAV)
-#else
-#define ENC0_FORMAT ((1<<AUDREC_CMD_TYPE_0_INDEX_WAV)| \
-		(1<<AUDREC_CMD_TYPE_1_INDEX_SBC)| \
-		(1<<AUDREC_CMD_TYPE_0_INDEX_AAC)| \
-		(1<<AUDREC_CMD_TYPE_0_INDEX_AMRNB)| \
-		(1<<AUDREC_CMD_TYPE_0_INDEX_EVRC)| \
-		(1<<AUDREC_CMD_TYPE_0_INDEX_QCELP))
-#endif
-
-#define MAX_ENC_COUNT 2
-#define MAX_EVENT_CALLBACK_CLIENTS 2
-
-struct msm_adspenc_database {
-	unsigned num_enc;
-	struct msm_adspenc_info *enc_info_list;
-};
-
-#ifdef CONFIG_MSM7X27A_AUDIO
-static struct msm_adspenc_info enc_info_list[] = {
-	ENC_MODULE_INFO("AUDRECTASK", \
-			((QDSP_uPAudRecBitStreamQueue << 16)| \
-			  QDSP_uPAudRecCmdQueue), 0, \
-			(ENC0_FORMAT | (1 << MSM_ADSP_ENC_MODE_TUNNEL) | \
-			(1 << MSM_ADSP_ENC_MODE_NON_TUNNEL)), 5),
-
-	ENC_MODULE_INFO("AUDREC1TASK", \
-			((QDSP_uPAudRec1BitStreamQueue << 16)| \
-			  QDSP_uPAudRec1CmdQueue), 1, \
-			(ENC1_FORMAT | (1 << MSM_ADSP_ENC_MODE_TUNNEL)), 1),
-};
-#else
-static struct msm_adspenc_info enc_info_list[] = {
-	ENC_MODULE_INFO("AUDRECTASK",
-			((QDSP_uPAudRecBitStreamQueue << 16)| \
-			  QDSP_uPAudRecCmdQueue), 0, \
-			(ENC0_FORMAT | (1 << MSM_ADSP_ENC_MODE_TUNNEL)), 6),
-};
-#endif
-
-static struct msm_adspenc_database msm_enc_database = {
-	.num_enc = ARRAY_SIZE(enc_info_list),
-	.enc_info_list = enc_info_list,
-};
-
-struct audpreproc_state {
-	struct msm_adsp_module *mod;
-	audpreproc_event_func func[MAX_ENC_COUNT];
-	void *private[MAX_ENC_COUNT];
-	struct mutex *lock;
-	unsigned open_count;
-	unsigned enc_inuse;
-	struct audpreproc_event_callback *cb_tbl[MAX_EVENT_CALLBACK_CLIENTS];
-};
-
-static struct audrec_session_info session_info;
-
-static struct audpreproc_state the_audpreproc_state = {
-	.lock = &audpreproc_lock,
-};
-
-/* DSP preproc event handler */
-static void audpreproc_dsp_event(void *data, unsigned id, size_t len,
-			    void (*getevent)(void *ptr, size_t len))
-{
-	struct audpreproc_state *audpreproc = data;
-	uint16_t msg[2];
-	MM_ERR("audpreproc_dsp_event %id", id);
-
-	getevent(msg, sizeof(msg));
-
-	switch (id) {
-	case AUDPREPROC_MSG_CMD_CFG_DONE_MSG:
-		MM_DBG("type %d, status_flag %d\n", msg[0], msg[1]);
-		if (audpreproc->func[0])
-			audpreproc->func[0](
-			audpreproc->private[0], id,
-			&msg);
-		break;
-	case AUDPREPROC_MSG_ERROR_MSG_ID:
-		MM_INFO("err_index %d\n", msg[0]);
-		if (audpreproc->func[0])
-			audpreproc->func[0](
-			audpreproc->private[0], id,
-			&msg);
-		break;
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audpreproctask)\n");
-		if (audpreproc->func[0])
-			audpreproc->func[0](
-			audpreproc->private[0], id,
-			&msg);
-		break;
-	case AUDPREPROC_MSG_FEAT_QUERY_DM_DONE:
-	   {
-	    uint16_t msg[3];
-	    getevent(msg, sizeof(msg));
-	    MM_INFO("RTC ACK --> %x %x %x\n", msg[0], msg[1], msg[2]);
-	    acdb_rtc_set_err(msg[2]);
-	   }
-	break;
-	default:
-		MM_ERR("unknown event %d\n", id);
-	}
-	return;
-}
-
-static struct msm_adsp_ops adsp_ops = {
-	.event = audpreproc_dsp_event,
-};
-
-/* EXPORTED API's */
-int audpreproc_enable(int enc_id, audpreproc_event_func func, void *private)
-{
-	struct audpreproc_state *audpreproc = &the_audpreproc_state;
-	int res = 0;
-	uint16_t msg[2];
-	int n = 0;
-	MM_DBG("audpreproc_enable %d\n", enc_id);
-
-	if (enc_id < 0 || enc_id > (MAX_ENC_COUNT - 1))
-		return -EINVAL;
-
-	mutex_lock(audpreproc->lock);
-	if (audpreproc->func[enc_id]) {
-		res = -EBUSY;
-		goto out;
-	}
-
-	audpreproc->func[enc_id] = func;
-	audpreproc->private[enc_id] = private;
-
-	/* First client to enable preproc task */
-	if (audpreproc->open_count++ == 0) {
-		MM_DBG("Get AUDPREPROCTASK\n");
-		res = msm_adsp_get("AUDPREPROCTASK", &audpreproc->mod,
-				&adsp_ops, audpreproc);
-		if (res < 0) {
-			MM_ERR("Can not get AUDPREPROCTASK\n");
-			audpreproc->open_count = 0;
-			audpreproc->func[enc_id] = NULL;
-			audpreproc->private[enc_id] = NULL;
-			goto out;
-		}
-		if (msm_adsp_enable(audpreproc->mod)) {
-			audpreproc->open_count = 0;
-			audpreproc->func[enc_id] = NULL;
-			audpreproc->private[enc_id] = NULL;
-			msm_adsp_put(audpreproc->mod);
-			audpreproc->mod = NULL;
-			res = -ENODEV;
-			goto out;
-		}
-	}
-	msg[0] = AUDPREPROC_MSG_STATUS_FLAG_ENA;
-	/* Generate audpre enabled message for registered clients */
-	for (n = 0; n < MAX_EVENT_CALLBACK_CLIENTS; ++n) {
-			if (audpreproc->cb_tbl[n] &&
-					audpreproc->cb_tbl[n]->fn) {
-				audpreproc->cb_tbl[n]->fn( \
-						audpreproc->cb_tbl[n]->private,\
-						AUDPREPROC_MSG_CMD_CFG_DONE_MSG,
-						(void *) &msg);
-			}
-	}
-	res = 0;
-out:
-	mutex_unlock(audpreproc->lock);
-	return res;
-}
-EXPORT_SYMBOL(audpreproc_enable);
-
-
-void audpreproc_disable(int enc_id, void *private)
-{
-	struct audpreproc_state *audpreproc = &the_audpreproc_state;
-	uint16_t msg[2];
-	int n = 0;
-
-	if (enc_id < 0 || enc_id > (MAX_ENC_COUNT - 1))
-		return;
-
-	mutex_lock(audpreproc->lock);
-	if (!audpreproc->func[enc_id])
-		goto out;
-	if (audpreproc->private[enc_id] != private)
-		goto out;
-
-	audpreproc->func[enc_id] = NULL;
-	audpreproc->private[enc_id] = NULL;
-
-	/* Last client then disable preproc task */
-	if (--audpreproc->open_count == 0) {
-		msm_adsp_disable(audpreproc->mod);
-		MM_DBG("Put AUDPREPROCTASK\n");
-		msm_adsp_put(audpreproc->mod);
-		audpreproc->mod = NULL;
-	}
-	msg[0] = AUDPREPROC_MSG_STATUS_FLAG_DIS;
-	/* Generate audpre enabled message for registered clients */
-	for (n = 0; n < MAX_EVENT_CALLBACK_CLIENTS; ++n) {
-			if (audpreproc->cb_tbl[n] &&
-					audpreproc->cb_tbl[n]->fn) {
-				audpreproc->cb_tbl[n]->fn( \
-						audpreproc->cb_tbl[n]->private,\
-						AUDPREPROC_MSG_CMD_CFG_DONE_MSG,
-						(void *) &msg);
-			}
-	}
-out:
-	mutex_unlock(audpreproc->lock);
-	return;
-}
-EXPORT_SYMBOL(audpreproc_disable);
-
-int audpreproc_update_audrec_info(
-			struct audrec_session_info *audrec_session_info)
-{
-	if (!audrec_session_info) {
-		MM_ERR("error in audrec session info address\n");
-		return -EINVAL;
-	}
-	if (audrec_session_info->session_id < MAX_ENC_COUNT) {
-		memcpy(&session_info,
-				audrec_session_info,
-				sizeof(struct audrec_session_info));
-		return 0;
-	}
-	return -EINVAL;
-}
-EXPORT_SYMBOL(audpreproc_update_audrec_info);
-
-int get_audrec_session_info(struct audrec_session_info *info)
-{
-	if (!info) {
-		MM_ERR("error in audrec session info address\n");
-		return -EINVAL;
-	}
-
-	if (the_audpreproc_state.open_count == 0) {
-		MM_ERR("No aud pre session active\n");
-		return -EINVAL;
-	}
-
-	memcpy(info, &session_info, sizeof(struct audrec_session_info));
-
-	return 0;
-}
-EXPORT_SYMBOL(get_audrec_session_info);
-
-int audpreproc_register_event_callback(struct audpreproc_event_callback *ecb)
-{
-	struct audpreproc_state *audpreproc = &the_audpreproc_state;
-	int i;
-
-	for (i = 0; i < MAX_EVENT_CALLBACK_CLIENTS; ++i) {
-		if (NULL == audpreproc->cb_tbl[i]) {
-			audpreproc->cb_tbl[i] = ecb;
-			return 0;
-		}
-	}
-	return -EINVAL;
-}
-EXPORT_SYMBOL(audpreproc_register_event_callback);
-
-int audpreproc_unregister_event_callback(struct audpreproc_event_callback *ecb)
-{
-	struct audpreproc_state *audpreproc = &the_audpreproc_state;
-	int i;
-
-	for (i = 0; i < MAX_EVENT_CALLBACK_CLIENTS; ++i) {
-		if (ecb == audpreproc->cb_tbl[i]) {
-			audpreproc->cb_tbl[i] = NULL;
-			return 0;
-		}
-	}
-	return -EINVAL;
-}
-/* enc_type = supported encode format *
- * like pcm, aac, sbc, evrc, qcelp, amrnb etc ... *
- */
-int audpreproc_aenc_alloc(unsigned enc_type, const char **module_name,
-		     unsigned *queue_ids)
-{
-	struct audpreproc_state *audpreproc = &the_audpreproc_state;
-	int encid = -1, idx, lidx, mode, codec;
-	int codecs_supported, min_codecs_supported;
-
-	mutex_lock(audpreproc->lock);
-	/* Represents in bit mask */
-	mode = ((enc_type & AUDPREPROC_MODE_MASK) << 16);
-	codec = (1 << (enc_type & AUDPREPROC_CODEC_MASK));
-
-	lidx = msm_enc_database.num_enc;
-	min_codecs_supported = sizeof(unsigned int) * 8;
-	MM_DBG("mode = 0x%08x codec = 0x%08x\n", mode, codec);
-
-	for (idx = lidx-1; idx >= 0; idx--) {
-		/* encoder free and supports the format */
-		if (!(audpreproc->enc_inuse & (1 << (idx))) &&
-		((mode & msm_enc_database.enc_info_list[idx].enc_formats)
-		== mode) && ((codec &
-		msm_enc_database.enc_info_list[idx].enc_formats)
-		== codec)){
-			/* Check supports minimum number codecs */
-			codecs_supported =
-			msm_enc_database.enc_info_list[idx].nr_codec_support;
-			if (codecs_supported < min_codecs_supported) {
-				lidx = idx;
-				min_codecs_supported = codecs_supported;
-			}
-		}
-	}
-
-	if (lidx < msm_enc_database.num_enc) {
-		audpreproc->enc_inuse |= (1 << lidx);
-		*module_name =
-		    msm_enc_database.enc_info_list[lidx].module_name;
-		*queue_ids =
-		    msm_enc_database.enc_info_list[lidx].module_queueids;
-		encid = msm_enc_database.enc_info_list[lidx].module_encid;
-	}
-
-	mutex_unlock(audpreproc->lock);
-	return encid;
-}
-EXPORT_SYMBOL(audpreproc_aenc_alloc);
-
-void audpreproc_aenc_free(int enc_id)
-{
-	struct audpreproc_state *audpreproc = &the_audpreproc_state;
-	int idx;
-
-	mutex_lock(audpreproc->lock);
-	for (idx = 0; idx < msm_enc_database.num_enc; idx++) {
-		if (msm_enc_database.enc_info_list[idx].module_encid ==
-		    enc_id) {
-			audpreproc->enc_inuse &= ~(1 << idx);
-			break;
-		}
-	}
-	mutex_unlock(audpreproc->lock);
-	return;
-
-}
-EXPORT_SYMBOL(audpreproc_aenc_free);
-
-int audpreproc_dsp_set_agc(
-		audpreproc_cmd_cfg_agc_params *agc_cfg,
-		unsigned len)
-{
-	return msm_adsp_write(the_audpreproc_state.mod,
-			QDSP_uPAudPreProcCmdQueue, agc_cfg, len);
-}
-EXPORT_SYMBOL(audpreproc_dsp_set_agc);
-
-int audpreproc_dsp_set_ns(
-	audpreproc_cmd_cfg_ns_params *ns_cfg,
-	unsigned len)
-{
-	return msm_adsp_write(the_audpreproc_state.mod,
-			QDSP_uPAudPreProcCmdQueue, ns_cfg, len);
-}
-EXPORT_SYMBOL(audpreproc_dsp_set_ns);
-
-int audpreproc_dsp_set_iir(
-		audpreproc_cmd_cfg_iir_tuning_filter_params *iir_cfg,
-		unsigned len)
-{
-	return msm_adsp_write(the_audpreproc_state.mod,
-			QDSP_uPAudPreProcCmdQueue, iir_cfg, len);
-}
-EXPORT_SYMBOL(audpreproc_dsp_set_iir);
-
-int audpreproc_send_preproccmdqueue(void *cmd, unsigned len)
-{
-	return msm_adsp_write(the_audpreproc_state.mod,
-			QDSP_uPAudPreProcCmdQueue, cmd, len);
-}
-EXPORT_SYMBOL(audpreproc_send_preproccmdqueue);
diff --git a/arch/arm/mach-msm/qdsp5/audrec.c b/arch/arm/mach-msm/qdsp5/audrec.c
deleted file mode 100644
index 0f34518..0000000
--- a/arch/arm/mach-msm/qdsp5/audrec.c
+++ /dev/null
@@ -1,273 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/audrec.c
- *
- * common code to deal with the AUDREC dsp task (audio recording)
- *
- * Copyright (c) 2009,2012 The Linux Foundation. All rights reserved.
- *
- * Based on the audpp layer in arch/arm/mach-msm/qdsp5/audpp.c
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you can find it at http://www.fsf.org.
- *
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/wait.h>
-#include <linux/delay.h>
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-#include <mach/msm_adsp.h>
-
-#include <mach/qdsp5/qdsp5audreccmdi.h>
-#include <mach/qdsp5/qdsp5audrecmsg.h>
-#include <mach/qdsp5/qdsp5audpreproc.h>
-
-#include "audmgr.h"
-#include <mach/debug_mm.h>
-
-static DEFINE_MUTEX(audrec_lock);
-
-#define MAX_ENC_COUNT 8 /* Max encoder supported */
-
-#define ENC_SESSION_FREE 0
-#define ENC_SESSION_ACTIVE 1
-
-struct enc_session {
-	unsigned enc_type;  /* Param to identify type of encoder */
-	unsigned audrec_obj_idx;  /* Param to identify REC_OBJ or Session ID */
-	audrec_event_func event_func; /* Event Call back
-					routine for the encoder */
-	void *private;	/* private data element passed as
-				part of Event Call back  routine */
-	unsigned state; /* Current state of the encoder session ,
-				free, active*/
-};
-
-struct audrec_state {
-	struct msm_adsp_module *audrec_mod;
-	struct enc_session enc_session[MAX_ENC_COUNT];
-	struct mutex *lock;
-	unsigned enc_count;
-};
-
-struct audrec_state the_audrec_state = {
-	.lock = &audrec_lock,
-};
-
-int audrectask_send_cmdqueue(void *cmd, unsigned len)
-{
-	return msm_adsp_write(the_audrec_state.audrec_mod,
-				QDSP_uPAudRecCmdQueue, cmd, len);
-}
-EXPORT_SYMBOL(audrectask_send_cmdqueue);
-
-int audrectask_send_bitstreamqueue(void *cmd, unsigned len)
-{
-	return msm_adsp_write(the_audrec_state.audrec_mod,
-				QDSP_uPAudRecBitStreamQueue, cmd, len);
-}
-EXPORT_SYMBOL(audrectask_send_bitstreamqueue);
-
-static void audrectask_dsp_event(void *data, unsigned id, size_t len,
-			    void (*getevent)(void *ptr, size_t len))
-{
-	struct audrec_state *audrec = data;
-	int cnt;
-	uint16_t msg[5]; /* Max size of message */
-	getevent(msg, len);
-
-	switch (id) {
-	case AUDREC_MSG_CMD_CFG_DONE_MSG: {
-		MM_DBG("CMD CFG DONE %x\n", msg[1]);
-		if (msg[0] & AUDREC_MSG_CFG_DONE_ENC_ENA) {
-			for (cnt = 0; cnt < MAX_ENC_COUNT ; cnt++) {
-				if (audrec->enc_session[cnt].enc_type ==
-					(msg[0] & AUDREC_CMD_ENC_TYPE_MASK)) {
-					audrec->enc_session[cnt].audrec_obj_idx
-					 = msg[1];
-					audrec->enc_session[cnt].event_func(
-					audrec->enc_session[cnt].private, id,
-					msg);
-					break;
-				}
-			}
-		} else {
-			for (cnt = 0; cnt < MAX_ENC_COUNT ; cnt++) {
-				if (audrec->enc_session[cnt].enc_type ==
-					(msg[0] & AUDREC_CMD_ENC_TYPE_MASK)) {
-					audrec->enc_session[cnt].event_func(
-					audrec->enc_session[cnt].private, id,
-					msg);
-					audrec->enc_session[cnt].audrec_obj_idx
-					= 0xFFFFFFFF;
-					audrec->enc_session[cnt].state
-					= ENC_SESSION_FREE;
-					audrec->enc_session[cnt].enc_type
-					= 0xFFFFFFFF;
-					audrec->enc_session[cnt].event_func
-					= NULL;
-					audrec->enc_session[cnt].private
-					= NULL;
-					break;
-				}
-			}
-		}
-		break;
-	}
-	case AUDREC_MSG_CMD_AREC_MEM_CFG_DONE_MSG: {
-		MM_DBG("CMD AREC MEM CFG DONE %x\n", msg[0]);
-		for (cnt = 0; cnt < MAX_ENC_COUNT ; cnt++) {
-			if (audrec->enc_session[cnt].audrec_obj_idx ==
-				msg[0]) {
-				audrec->enc_session[cnt].event_func(
-				audrec->enc_session[cnt].private, id, msg);
-				break;
-			}
-		}
-		break;
-	}
-	case AUDREC_MSG_CMD_AREC_PARAM_CFG_DONE_MSG: {
-		MM_DBG("CMD AREC PARAM CFG DONE %x\n", msg[0]);
-		for (cnt = 0; cnt < MAX_ENC_COUNT ; cnt++) {
-			if (audrec->enc_session[cnt].audrec_obj_idx ==
-				msg[0]) {
-				audrec->enc_session[cnt].event_func(
-				audrec->enc_session[cnt].private, id, msg);
-				break;
-			}
-		}
-		break;
-	}
-	case AUDREC_MSG_PACKET_READY_MSG: {
-		MM_DBG("PCK READY %x\n", msg[0]);
-		for (cnt = 0; cnt < MAX_ENC_COUNT ; cnt++) {
-			if (audrec->enc_session[cnt].audrec_obj_idx ==
-				msg[0]) {
-				audrec->enc_session[cnt].event_func(
-				audrec->enc_session[cnt].private, id, msg);
-				break;
-			}
-		}
-		break;
-	}
-	case AUDREC_MSG_FATAL_ERR_MSG: {
-		MM_ERR("ERROR %x\n", msg[0]);
-		if (msg[1] & AUDREC_MSG_FATAL_ERR_TYPE_0) {
-			for (cnt = 0; cnt < MAX_ENC_COUNT ; cnt++) {
-				if (audrec->enc_session[cnt].audrec_obj_idx ==
-					msg[0]) {
-					audrec->enc_session[cnt].event_func(
-					audrec->enc_session[cnt].private, id,
-					msg);
-				break;
-				}
-			}
-		} else if (msg[1] & AUDREC_MSG_FATAL_ERR_TYPE_1) {
-			cnt = audrec->enc_count-1;
-			if (audrec->enc_session[cnt].event_func)
-				audrec->enc_session[cnt].event_func(
-				audrec->enc_session[cnt].private, id,
-				msg);
-		}
-		break;
-	}
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module \
-				enable/disable(audrectask)\n");
-		break;
-	default:
-		MM_ERR("unknown event %d\n", id);
-	}
-}
-
-static struct msm_adsp_ops adsp_ops = {
-	.event = audrectask_dsp_event,
-};
-
-int audrectask_enable(unsigned enc_type, audrec_event_func func, void *private)
-{
-	struct audrec_state *audrec = &the_audrec_state;
-	int cnt, rc = 0;
-
-	mutex_lock(audrec->lock);
-
-	if (audrec->enc_count++ == 0) {
-		MM_DBG("enable\n");
-		for (cnt = 0; cnt < MAX_ENC_COUNT ; cnt++) {
-			if (audrec->enc_session[cnt].state ==
-				ENC_SESSION_FREE) {
-				audrec->enc_session[cnt].state =
-				ENC_SESSION_ACTIVE;
-				audrec->enc_session[cnt].enc_type = enc_type;
-				audrec->enc_session[cnt].event_func = func;
-				audrec->enc_session[cnt].private = private;
-				break;
-			}
-		}
-		rc = msm_adsp_get("AUDRECTASK", &audrec->audrec_mod, &adsp_ops,
-					audrec);
-		if (rc < 0) {
-			MM_ERR("cannot open AUDRECTASK\n");
-			audrec->enc_count = 0;
-			audrec->enc_session[cnt].state = ENC_SESSION_FREE;
-			audrec->enc_session[cnt].enc_type = 0xFFFFFFFF;
-			audrec->enc_session[cnt].event_func = NULL;
-			audrec->enc_session[cnt].private = NULL;
-			goto out;
-		}
-		msm_adsp_enable(audrec->audrec_mod);
-	} else {
-		for (cnt = 0; cnt < MAX_ENC_COUNT ; cnt++) {
-			if (audrec->enc_session[cnt].state ==
-				ENC_SESSION_FREE) {
-				audrec->enc_session[cnt].state =
-				ENC_SESSION_ACTIVE;
-				audrec->enc_session[cnt].enc_type = enc_type;
-				audrec->enc_session[cnt].event_func = func;
-				audrec->enc_session[cnt].private = private;
-				break;
-			}
-		}
-	}
-	if (cnt == MAX_ENC_COUNT)
-		rc = -EBUSY;
-	else
-		rc = 0;
-
-out:
-	mutex_unlock(audrec->lock);
-	return rc;
-}
-EXPORT_SYMBOL(audrectask_enable);
-
-void audrectask_disable(unsigned enc_type, void *private)
-{
-	struct audrec_state *audrec = &the_audrec_state;
-
-	mutex_lock(audrec->lock);
-
-	if (--audrec->enc_count == 0) {
-		MM_DBG("\n"); /* Macro prints the file name and function */
-		msm_adsp_disable(audrec->audrec_mod);
-		msm_adsp_put(audrec->audrec_mod);
-		audrec->audrec_mod = NULL;
-	}
-
-	mutex_unlock(audrec->lock);
-}
-EXPORT_SYMBOL(audrectask_disable);
-
diff --git a/arch/arm/mach-msm/qdsp5/dsp_debug.c b/arch/arm/mach-msm/qdsp5/dsp_debug.c
deleted file mode 100644
index 6e73a60..0000000
--- a/arch/arm/mach-msm/qdsp5/dsp_debug.c
+++ /dev/null
@@ -1,235 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <asm/atomic.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/fs.h>
-#include <linux/io.h>
-#include <linux/miscdevice.h>
-#include <linux/module.h>
-#include <linux/sched.h>
-#include <linux/uaccess.h>
-#include <linux/wait.h>
-
-#include <mach/debug_mm.h>
-#include <mach/msm_iomap.h>
-
-#include "dsp_debug.h"
-
-static wait_queue_head_t dsp_wait;
-static int dsp_has_crashed;
-static int dsp_wait_count;
-
-static atomic_t dsp_crash_count = ATOMIC_INIT(0);
-static dsp_state_cb cb_ptr;
-
-#define MAX_LEN 64
-#define HDR_LEN 20
-#define NUM_DSP_RAM_BANKS 3
-
-static char l_buf[MAX_LEN];
-#ifdef CONFIG_DEBUG_FS
-static struct dentry *dsp_dentry;
-#endif
-
-void q5audio_dsp_not_responding(void)
-{
-	if (cb_ptr)
-		cb_ptr(DSP_STATE_CRASHED);
-
-	MM_DBG("entered q5audio_dsp_not_responding\n");
-	if (atomic_add_return(1, &dsp_crash_count) != 1) {
-		MM_ERR("q5audio_dsp_not_responding() \
-			- parking additional crasher...\n");
-		for (;;)
-			msleep(1000);
-	}
-	if (dsp_wait_count) {
-		dsp_has_crashed = 1;
-		wake_up(&dsp_wait);
-
-		while (dsp_has_crashed != 2)
-			wait_event(dsp_wait, dsp_has_crashed == 2);
-	} else {
-		MM_ERR("q5audio_dsp_not_responding() - no waiter?\n");
-	}
-
-	if (cb_ptr)
-		cb_ptr(DSP_STATE_CRASH_DUMP_DONE);
-}
-
-static int dsp_open(struct inode *inode, struct file *file)
-{
-	return 0;
-}
-
-static ssize_t dsp_write(struct file *file, const char __user *buf,
-			 size_t count, loff_t *pos)
-{
-	char cmd[32];
-
-	if (count >= sizeof(cmd))
-		return -EINVAL;
-	if (copy_from_user(cmd, buf, count))
-		return -EFAULT;
-	cmd[count] = 0;
-
-	if ((count > 1) && (cmd[count-1] == '\n'))
-		cmd[count-1] = 0;
-
-	if (!strncmp(cmd, "wait-for-crash", sizeof("wait-for-crash"))) {
-		while (!dsp_has_crashed) {
-			int res;
-			dsp_wait_count++;
-			res = wait_event_interruptible(dsp_wait,
-							dsp_has_crashed);
-			if (res < 0) {
-				dsp_wait_count--;
-				return res;
-			}
-		}
-	} else if (!strncmp(cmd, "boom", sizeof("boom"))) {
-		q5audio_dsp_not_responding();
-	} else if (!strncmp(cmd, "continue-crash", sizeof("continue-crash"))) {
-		dsp_has_crashed = 2;
-		wake_up(&dsp_wait);
-	} else {
-		MM_ERR("[%s:%s] unknown dsp_debug command: %s\n", __MM_FILE__,
-				__func__, cmd);
-	}
-
-	return count;
-}
-
-static ssize_t dsp_read(struct file *file, char __user *buf,
-			size_t count, loff_t *pos)
-{
-	size_t actual = 0;
-	static void *dsp_addr;
-	static unsigned copy_ok_count;
-
-	MM_INFO("pos = %lld\n", *pos);
-	if (*pos >= DSP_RAM_SIZE * NUM_DSP_RAM_BANKS)
-		return 0;
-
-	if (*pos == 0)
-		dsp_addr = (*pos + RAMA_BASE);
-	else if (*pos == DSP_RAM_SIZE)
-		dsp_addr = RAMB_BASE;
-	else if (*pos >= DSP_RAM_SIZE * 2)
-		dsp_addr = RAMC_BASE;
-
-	MM_INFO("dsp_addr = %p\n", dsp_addr);
-	while (count >= PAGE_SIZE) {
-		if (copy_to_user(buf, dsp_addr, PAGE_SIZE)) {
-			MM_ERR("[%s:%s] copy error @ %p\n", __MM_FILE__,
-					__func__, buf);
-			return -EFAULT;
-		}
-		copy_ok_count += PAGE_SIZE;
-		dsp_addr = (char *)dsp_addr + PAGE_SIZE;
-		buf += PAGE_SIZE;
-		actual += PAGE_SIZE;
-		count -= PAGE_SIZE;
-	}
-
-	*pos += actual;
-	return actual;
-}
-
-static int dsp_release(struct inode *inode, struct file *file)
-{
-	return 0;
-}
-
-int dsp_debug_register(dsp_state_cb ptr)
-{
-	if (ptr == NULL)
-		return -EINVAL;
-
-	cb_ptr = ptr;
-
-	return 0;
-}
-
-static const struct file_operations dsp_fops = {
-	.owner		= THIS_MODULE,
-	.open		= dsp_open,
-	.read		= dsp_read,
-	.write		= dsp_write,
-	.release	= dsp_release,
-};
-
-#ifdef CONFIG_DEBUG_FS
-static struct miscdevice dsp_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "dsp_debug",
-	.fops	= &dsp_fops,
-};
-#endif
-
-static ssize_t dsp_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	MM_DBG("adsp debugfs opened\n");
-	return 0;
-}
-
-static ssize_t dsp_debug_write(struct file *file, const char __user *buf,
-					size_t count, loff_t *ppos)
-{
-	int len;
-
-	if (count < 0)
-		return 0;
-	len = count > (MAX_LEN - 1) ? (MAX_LEN - 1) : count;
-	if (copy_from_user(l_buf + HDR_LEN, buf, len)) {
-		MM_ERR("Unable to copy data from user space\n");
-		return -EFAULT;
-	}
-	l_buf[len + HDR_LEN] = 0;
-	if (l_buf[len + HDR_LEN - 1] == '\n') {
-		l_buf[len + HDR_LEN - 1] = 0;
-		len--;
-	}
-	if (!strncmp(l_buf + HDR_LEN, "boom", 64)) {
-		q5audio_dsp_not_responding();
-	} else if (!strncmp(l_buf + HDR_LEN, "continue-crash",
-				sizeof("continue-crash"))) {
-		dsp_has_crashed = 2;
-		wake_up(&dsp_wait);
-	} else
-		MM_ERR("Unknown command\n");
-
-	return count;
-}
-static const struct file_operations dsp_debug_fops = {
-	.write = dsp_debug_write,
-	.open = dsp_debug_open,
-};
-
-static int __init dsp_init(void)
-{
-	init_waitqueue_head(&dsp_wait);
-#ifdef CONFIG_DEBUG_FS
-	dsp_dentry = debugfs_create_file("dsp_debug", S_IFREG | S_IRUGO,
-			NULL, (void *) NULL, &dsp_debug_fops);
-
-	return misc_register(&dsp_misc);
-#else
-	return 0;
-#endif /* CONFIG_DEBUG_FS */
-}
-
-device_initcall(dsp_init);
diff --git a/arch/arm/mach-msm/qdsp5/dsp_debug.h b/arch/arm/mach-msm/qdsp5/dsp_debug.h
deleted file mode 100644
index 15c14ca..0000000
--- a/arch/arm/mach-msm/qdsp5/dsp_debug.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#ifndef __DSP_DEBUG_H_
-#define __DSP_DEBUG_H_
-
-typedef int (*dsp_state_cb)(int state);
-int dsp_debug_register(dsp_state_cb ptr);
-
-#define DSP_STATE_CRASHED         0x0
-#define DSP_STATE_CRASH_DUMP_DONE 0x1
-
-#define RAMA_BASE MSM_AD5_BASE
-#define RAMB_BASE ((RAMA_BASE) + (0x200000))
-#define RAMC_BASE ((RAMB_BASE) + (0x200000))
-#define DSP_RAM_SIZE 0x40000
-
-#endif
diff --git a/arch/arm/mach-msm/qdsp5/evlog.h b/arch/arm/mach-msm/qdsp5/evlog.h
deleted file mode 100644
index 1f0f16b..0000000
--- a/arch/arm/mach-msm/qdsp5/evlog.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/evlog.h
- *
- * simple event log debugging facility
- *
- * Copyright (C) 2008 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/fs.h>
-#include <linux/hrtimer.h>
-#include <linux/debugfs.h>
-
-#define EV_LOG_ENTRY_NAME(n) n##_entry
-
-#define DECLARE_LOG(_name, _size, _str) \
-static struct ev_entry EV_LOG_ENTRY_NAME(_name)[_size]; \
-static struct ev_log _name = { \
-	.name = #_name, \
-	.strings = _str, \
-	.num_strings = ARRAY_SIZE(_str), \
-	.entry = EV_LOG_ENTRY_NAME(_name), \
-	.max = ARRAY_SIZE(EV_LOG_ENTRY_NAME(_name)), \
-}
-
-struct ev_entry {
-	struct timespec when;
-	uint32_t id;
-	uint32_t arg;
-};
-	
-struct ev_log {
-	struct ev_entry *entry;
-	unsigned max;
-	unsigned next;
-	unsigned fault;
-	const char **strings;
-	unsigned num_strings;
-	const char *name;
-};
-
-static char ev_buf[4096];
-
-static ssize_t ev_log_read(struct file *file, char __user *buf,
-			   size_t count, loff_t *ppos)
-{
-	struct ev_log *log = file->private_data;
-	struct ev_entry *entry;
-	unsigned long flags;
-	int size = 0;
-	unsigned n, id, max;
-	struct timespec now, t;
-	
-	max = log->max;
-	getnstimeofday(&now);
-	local_irq_save(flags);
-	n = (log->next - 1) & (max - 1);
-	entry = log->entry;
-	while (n != log->next) {
-		t = timespec_sub(now, entry[n].when);
-		id = entry[n].id;
-		if (id) {
-			const char *str;
-			if (id < log->num_strings)
-				str = log->strings[id];
-			else
-				str = "UNKNOWN";
-			size += scnprintf(ev_buf + size, 4096 - size,
-					  "%lu.%03lu %08x %s\n",
-					  t.tv_sec, t.tv_nsec / 1000000,
-					  entry[n].arg, str);
-		}
-		n = (n - 1) & (max - 1);
-	}
-	log->fault = 0;
-	local_irq_restore(flags);
-	return simple_read_from_buffer(buf, count, ppos, ev_buf, size);
-}
-
-static void ev_log_write(struct ev_log *log, unsigned id, unsigned arg)
-{
-	struct ev_entry *entry;
-	unsigned long flags;
-	local_irq_save(flags);
-
-	if (log->fault) {
-		if (log->fault == 1)
-			goto done;
-		log->fault--;
-	}
-
-	entry = log->entry + log->next;
-	getnstimeofday(&entry->when);
-	entry->id = id;
-	entry->arg = arg;
-	log->next = (log->next + 1) & (log->max - 1);
-done:
-	local_irq_restore(flags);
-}
-
-static int ev_log_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static const struct file_operations ev_log_ops = {
-	.read = ev_log_read,
-	.open = ev_log_open,
-};
-
-static int ev_log_init(struct ev_log *log)
-{
-	debugfs_create_file(log->name, 0444, 0, log, &ev_log_ops);
-	return 0;
-}
-
diff --git a/arch/arm/mach-msm/qdsp5/snd.c b/arch/arm/mach-msm/qdsp5/snd.c
deleted file mode 100644
index 3f379dc..0000000
--- a/arch/arm/mach-msm/qdsp5/snd.c
+++ /dev/null
@@ -1,675 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/snd.c
- *
- * interface to "snd" service on the baseband cpu
- *
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2009, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/delay.h>
-#include <linux/msm_audio.h>
-#include <linux/seq_file.h>
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-#include <mach/board.h>
-#include <mach/msm_rpcrouter.h>
-#include <mach/debug_mm.h>
-
-struct snd_ctxt {
-	struct mutex lock;
-	int opened;
-	struct msm_rpc_endpoint *ept;
-	struct msm_snd_endpoints *snd_epts;
-};
-
-struct snd_sys_ctxt {
-	struct mutex lock;
-	struct msm_rpc_endpoint *ept;
-};
-
-static struct snd_sys_ctxt the_snd_sys;
-
-static struct snd_ctxt the_snd;
-
-#define RPC_SND_PROG	0x30000002
-#define RPC_SND_CB_PROG	0x31000002
-
-#define RPC_SND_VERS                    0x00020001
-#define RPC_SND_VERS2                    0x00030001
-
-#define SND_SET_DEVICE_PROC 2
-#define SND_SET_VOLUME_PROC 3
-#define SND_AVC_CTL_PROC 29
-#define SND_AGC_CTL_PROC 30
-
-struct rpc_snd_set_device_args {
-	uint32_t device;
-	uint32_t ear_mute;
-	uint32_t mic_mute;
-
-	uint32_t cb_func;
-	uint32_t client_data;
-};
-
-struct rpc_snd_set_volume_args {
-	uint32_t device;
-	uint32_t method;
-	uint32_t volume;
-
-	uint32_t cb_func;
-	uint32_t client_data;
-};
-
-struct rpc_snd_avc_ctl_args {
-	uint32_t avc_ctl;
-	uint32_t cb_func;
-	uint32_t client_data;
-};
-
-struct rpc_snd_agc_ctl_args {
-	uint32_t agc_ctl;
-	uint32_t cb_func;
-	uint32_t client_data;
-};
-
-struct snd_set_device_msg {
-	struct rpc_request_hdr hdr;
-	struct rpc_snd_set_device_args args;
-};
-
-struct snd_set_volume_msg {
-	struct rpc_request_hdr hdr;
-	struct rpc_snd_set_volume_args args;
-};
-
-struct snd_avc_ctl_msg {
-	struct rpc_request_hdr hdr;
-	struct rpc_snd_avc_ctl_args args;
-};
-
-struct snd_agc_ctl_msg {
-	struct rpc_request_hdr hdr;
-	struct rpc_snd_agc_ctl_args args;
-};
-
-struct snd_endpoint *get_snd_endpoints(int *size);
-
-static inline int check_mute(int mute)
-{
-	return (mute == SND_MUTE_MUTED ||
-		mute == SND_MUTE_UNMUTED) ? 0 : -EINVAL;
-}
-
-static int get_endpoint(struct snd_ctxt *snd, unsigned long arg)
-{
-	int rc = 0, index;
-	struct msm_snd_endpoint ept;
-
-	if (copy_from_user(&ept, (void __user *)arg, sizeof(ept))) {
-		MM_ERR("snd_ioctl get endpoint: invalid read pointer\n");
-		return -EFAULT;
-	}
-
-	index = ept.id;
-	if (index < 0 || index >= snd->snd_epts->num) {
-		MM_ERR("snd_ioctl get endpoint: invalid index!\n");
-		return -EINVAL;
-	}
-
-	ept.id = snd->snd_epts->endpoints[index].id;
-	strncpy(ept.name,
-		snd->snd_epts->endpoints[index].name,
-		sizeof(ept.name));
-
-	if (copy_to_user((void __user *)arg, &ept, sizeof(ept))) {
-		MM_ERR("snd_ioctl get endpoint: invalid write pointer\n");
-		rc = -EFAULT;
-	}
-
-	return rc;
-}
-
-static long snd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct snd_set_device_msg dmsg;
-	struct snd_set_volume_msg vmsg;
-	struct snd_avc_ctl_msg avc_msg;
-	struct snd_agc_ctl_msg agc_msg;
-
-	struct msm_snd_device_config dev;
-	struct msm_snd_volume_config vol;
-	struct snd_ctxt *snd = file->private_data;
-	int rc = 0;
-
-	uint32_t avc, agc;
-
-	mutex_lock(&snd->lock);
-	switch (cmd) {
-	case SND_SET_DEVICE:
-		if (copy_from_user(&dev, (void __user *) arg, sizeof(dev))) {
-			MM_ERR("set device: invalid pointer\n");
-			rc = -EFAULT;
-			break;
-		}
-
-		dmsg.args.device = cpu_to_be32(dev.device);
-		dmsg.args.ear_mute = cpu_to_be32(dev.ear_mute);
-		dmsg.args.mic_mute = cpu_to_be32(dev.mic_mute);
-		if (check_mute(dev.ear_mute) < 0 ||
-				check_mute(dev.mic_mute) < 0) {
-			MM_ERR("set device: invalid mute status\n");
-			rc = -EINVAL;
-			break;
-		}
-		dmsg.args.cb_func = -1;
-		dmsg.args.client_data = 0;
-
-		MM_INFO("snd_set_device %d %d %d\n", dev.device,
-				dev.ear_mute, dev.mic_mute);
-
-		rc = msm_rpc_call(snd->ept,
-			SND_SET_DEVICE_PROC,
-			&dmsg, sizeof(dmsg), 5 * HZ);
-		break;
-
-	case SND_SET_VOLUME:
-		if (copy_from_user(&vol, (void __user *) arg, sizeof(vol))) {
-			MM_ERR("set volume: invalid pointer\n");
-			rc = -EFAULT;
-			break;
-		}
-
-		vmsg.args.device = cpu_to_be32(vol.device);
-		vmsg.args.method = cpu_to_be32(vol.method);
-		if (vol.method != SND_METHOD_VOICE) {
-			MM_ERR("set volume: invalid method\n");
-			rc = -EINVAL;
-			break;
-		}
-
-		vmsg.args.volume = cpu_to_be32(vol.volume);
-		vmsg.args.cb_func = -1;
-		vmsg.args.client_data = 0;
-
-		MM_INFO("snd_set_volume %d %d %d\n", vol.device,
-				vol.method, vol.volume);
-
-		rc = msm_rpc_call(snd->ept,
-			SND_SET_VOLUME_PROC,
-			&vmsg, sizeof(vmsg), 5 * HZ);
-		break;
-
-	case SND_AVC_CTL:
-		if (get_user(avc, (uint32_t __user *) arg)) {
-			rc = -EFAULT;
-			break;
-		} else if ((avc != 1) && (avc != 0)) {
-			rc = -EINVAL;
-			break;
-		}
-
-		avc_msg.args.avc_ctl = cpu_to_be32(avc);
-		avc_msg.args.cb_func = -1;
-		avc_msg.args.client_data = 0;
-
-		MM_INFO("snd_avc_ctl %d\n", avc);
-
-		rc = msm_rpc_call(snd->ept,
-			SND_AVC_CTL_PROC,
-			&avc_msg, sizeof(avc_msg), 5 * HZ);
-		break;
-
-	case SND_AGC_CTL:
-		if (get_user(agc, (uint32_t __user *) arg)) {
-			rc = -EFAULT;
-			break;
-		} else if ((agc != 1) && (agc != 0)) {
-			rc = -EINVAL;
-			break;
-		}
-		agc_msg.args.agc_ctl = cpu_to_be32(agc);
-		agc_msg.args.cb_func = -1;
-		agc_msg.args.client_data = 0;
-
-		MM_INFO("snd_agc_ctl %d\n", agc);
-
-		rc = msm_rpc_call(snd->ept,
-			SND_AGC_CTL_PROC,
-			&agc_msg, sizeof(agc_msg), 5 * HZ);
-		break;
-
-	case SND_GET_NUM_ENDPOINTS:
-		if (copy_to_user((void __user *)arg,
-				&snd->snd_epts->num, sizeof(unsigned))) {
-			MM_ERR("get endpoint: invalid pointer\n");
-			rc = -EFAULT;
-		}
-		break;
-
-	case SND_GET_ENDPOINT:
-		rc = get_endpoint(snd, arg);
-		break;
-
-	default:
-		MM_ERR("unknown command\n");
-		rc = -EINVAL;
-		break;
-	}
-	mutex_unlock(&snd->lock);
-
-	return rc;
-}
-
-static int snd_release(struct inode *inode, struct file *file)
-{
-	struct snd_ctxt *snd = file->private_data;
-	int rc;
-
-	mutex_lock(&snd->lock);
-	rc = msm_rpc_close(snd->ept);
-	if (rc < 0)
-		MM_ERR("msm_rpc_close failed\n");
-	snd->ept = NULL;
-	snd->opened = 0;
-	mutex_unlock(&snd->lock);
-	return 0;
-}
-static int snd_sys_release(void)
-{
-	struct snd_sys_ctxt *snd_sys = &the_snd_sys;
-	int rc = 0;
-
-	mutex_lock(&snd_sys->lock);
-	rc = msm_rpc_close(snd_sys->ept);
-	if (rc < 0)
-		MM_ERR("msm_rpc_close failed\n");
-	snd_sys->ept = NULL;
-	mutex_unlock(&snd_sys->lock);
-	return rc;
-}
-static int snd_open(struct inode *inode, struct file *file)
-{
-	struct snd_ctxt *snd = &the_snd;
-	int rc = 0;
-
-	mutex_lock(&snd->lock);
-	if (snd->opened == 0) {
-		if (snd->ept == NULL) {
-			snd->ept = msm_rpc_connect_compatible(RPC_SND_PROG,
-					RPC_SND_VERS, 0);
-			if (IS_ERR(snd->ept)) {
-				MM_DBG("connect failed with current VERS \
-					= %x, trying again with another API\n",
-					RPC_SND_VERS2);
-				snd->ept =
-					msm_rpc_connect_compatible(RPC_SND_PROG,
-							RPC_SND_VERS2, 0);
-			}
-			if (IS_ERR(snd->ept)) {
-				rc = PTR_ERR(snd->ept);
-				snd->ept = NULL;
-				MM_ERR("failed to connect snd svc\n");
-				goto err;
-			}
-		}
-		file->private_data = snd;
-		snd->opened = 1;
-	} else {
-		MM_ERR("snd already opened\n");
-		rc = -EBUSY;
-	}
-
-err:
-	mutex_unlock(&snd->lock);
-	return rc;
-}
-static int snd_sys_open(void)
-{
-	struct snd_sys_ctxt *snd_sys = &the_snd_sys;
-	int rc = 0;
-
-	mutex_lock(&snd_sys->lock);
-	if (snd_sys->ept == NULL) {
-		snd_sys->ept = msm_rpc_connect_compatible(RPC_SND_PROG,
-			RPC_SND_VERS, 0);
-		if (IS_ERR(snd_sys->ept)) {
-			MM_DBG("connect failed with current VERS \
-				= %x, trying again with another API\n",
-				RPC_SND_VERS2);
-			snd_sys->ept = msm_rpc_connect_compatible(RPC_SND_PROG,
-					RPC_SND_VERS2, 0);
-		}
-		if (IS_ERR(snd_sys->ept)) {
-			rc = PTR_ERR(snd_sys->ept);
-			snd_sys->ept = NULL;
-			MM_ERR("failed to connect snd svc\n");
-			goto err;
-		}
-	} else
-		MM_DBG("snd already opened\n");
-
-err:
-	mutex_unlock(&snd_sys->lock);
-	return rc;
-}
-
-static struct file_operations snd_fops = {
-	.owner		= THIS_MODULE,
-	.open		= snd_open,
-	.release	= snd_release,
-	.unlocked_ioctl	= snd_ioctl,
-};
-
-struct miscdevice snd_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_snd",
-	.fops	= &snd_fops,
-};
-
-static long snd_agc_enable(unsigned long arg)
-{
-	struct snd_sys_ctxt *snd_sys = &the_snd_sys;
-	struct snd_agc_ctl_msg agc_msg;
-	int rc = 0;
-
-	if ((arg != 1) && (arg != 0))
-		return -EINVAL;
-
-	agc_msg.args.agc_ctl = cpu_to_be32(arg);
-	agc_msg.args.cb_func = -1;
-	agc_msg.args.client_data = 0;
-
-	MM_DBG("snd_agc_ctl %ld,%d\n", arg, agc_msg.args.agc_ctl);
-
-	rc = msm_rpc_call(snd_sys->ept,
-		SND_AGC_CTL_PROC,
-		&agc_msg, sizeof(agc_msg), 5 * HZ);
-	return rc;
-}
-
-static long snd_avc_enable(unsigned long arg)
-{
-	struct snd_sys_ctxt *snd_sys = &the_snd_sys;
-	struct snd_avc_ctl_msg avc_msg;
-	int rc = 0;
-
-	if ((arg != 1) && (arg != 0))
-		return -EINVAL;
-
-	avc_msg.args.avc_ctl = cpu_to_be32(arg);
-
-	avc_msg.args.cb_func = -1;
-	avc_msg.args.client_data = 0;
-
-	MM_DBG("snd_avc_ctl %ld,%d\n", arg, avc_msg.args.avc_ctl);
-
-	rc = msm_rpc_call(snd_sys->ept,
-		SND_AVC_CTL_PROC,
-		&avc_msg, sizeof(avc_msg), 5 * HZ);
-	return rc;
-}
-
-static ssize_t snd_agc_store(struct device *dev,
-		struct device_attribute *attr, const char *buf, size_t size)
-{
-	ssize_t status;
-	struct snd_sys_ctxt *snd_sys = &the_snd_sys;
-	int rc = 0;
-
-	rc = snd_sys_open();
-	if (rc)
-		return rc;
-
-	mutex_lock(&snd_sys->lock);
-
-	if (sysfs_streq(buf, "enable"))
-		status = snd_agc_enable(1);
-	else if (sysfs_streq(buf, "disable"))
-		status = snd_agc_enable(0);
-	else
-		status = -EINVAL;
-
-	mutex_unlock(&snd_sys->lock);
-	rc = snd_sys_release();
-	if (rc)
-		return rc;
-
-	return status ? : size;
-}
-
-static ssize_t snd_avc_store(struct device *dev,
-		struct device_attribute *attr, const char *buf, size_t size)
-{
-	ssize_t status;
-	struct snd_sys_ctxt *snd_sys = &the_snd_sys;
-	int rc = 0;
-
-	rc = snd_sys_open();
-	if (rc)
-		return rc;
-
-	mutex_lock(&snd_sys->lock);
-
-	if (sysfs_streq(buf, "enable"))
-		status = snd_avc_enable(1);
-	else if (sysfs_streq(buf, "disable"))
-		status = snd_avc_enable(0);
-	else
-		status = -EINVAL;
-
-	mutex_unlock(&snd_sys->lock);
-	rc = snd_sys_release();
-	if (rc)
-		return rc;
-
-	return status ? : size;
-}
-
-static long snd_vol_enable(const char *arg)
-{
-	struct snd_sys_ctxt *snd_sys = &the_snd_sys;
-	struct snd_set_volume_msg vmsg;
-	struct msm_snd_volume_config vol;
-	int rc = 0;
-
-	rc = sscanf(arg, "%d %d %d", &vol.device, &vol.method, &vol.volume);
-	if (rc != 3) {
-		MM_ERR("Invalid arguments. Usage: <device> <method> \
-				<volume>\n");
-		rc = -EINVAL;
-		return rc;
-	}
-
-	vmsg.args.device = cpu_to_be32(vol.device);
-	vmsg.args.method = cpu_to_be32(vol.method);
-	if (vol.method != SND_METHOD_VOICE) {
-		MM_ERR("snd_ioctl set volume: invalid method\n");
-		rc = -EINVAL;
-		return rc;
-	}
-
-	vmsg.args.volume = cpu_to_be32(vol.volume);
-	vmsg.args.cb_func = -1;
-	vmsg.args.client_data = 0;
-
-	MM_DBG("snd_set_volume %d %d %d\n", vol.device, vol.method,
-			vol.volume);
-
-	rc = msm_rpc_call(snd_sys->ept,
-		SND_SET_VOLUME_PROC,
-		&vmsg, sizeof(vmsg), 5 * HZ);
-	return rc;
-}
-
-static long snd_dev_enable(const char *arg)
-{
-	struct snd_sys_ctxt *snd_sys = &the_snd_sys;
-	struct snd_set_device_msg dmsg;
-	struct msm_snd_device_config dev;
-	int rc = 0;
-
-	rc = sscanf(arg, "%d %d %d", &dev.device, &dev.ear_mute, &dev.mic_mute);
-	if (rc != 3) {
-		MM_ERR("Invalid arguments. Usage: <device> <ear_mute> \
-				<mic_mute>\n");
-		rc = -EINVAL;
-		return rc;
-	}
-	dmsg.args.device = cpu_to_be32(dev.device);
-	dmsg.args.ear_mute = cpu_to_be32(dev.ear_mute);
-	dmsg.args.mic_mute = cpu_to_be32(dev.mic_mute);
-	if (check_mute(dev.ear_mute) < 0 ||
-			check_mute(dev.mic_mute) < 0) {
-		MM_ERR("snd_ioctl set device: invalid mute status\n");
-		rc = -EINVAL;
-		return rc;
-	}
-	dmsg.args.cb_func = -1;
-	dmsg.args.client_data = 0;
-
-	MM_INFO("snd_set_device %d %d %d\n", dev.device, dev.ear_mute,
-			dev.mic_mute);
-
-	rc = msm_rpc_call(snd_sys->ept,
-		SND_SET_DEVICE_PROC,
-		&dmsg, sizeof(dmsg), 5 * HZ);
-	return rc;
-}
-
-static ssize_t snd_dev_store(struct device *dev,
-		struct device_attribute *attr, const char *buf, size_t size)
-{
-	ssize_t status;
-	struct snd_sys_ctxt *snd_sys = &the_snd_sys;
-	int rc = 0;
-
-	rc = snd_sys_open();
-	if (rc)
-		return rc;
-
-	mutex_lock(&snd_sys->lock);
-	status = snd_dev_enable(buf);
-	mutex_unlock(&snd_sys->lock);
-
-	rc = snd_sys_release();
-	if (rc)
-		return rc;
-
-	return status ? : size;
-}
-
-static ssize_t snd_vol_store(struct device *dev,
-		struct device_attribute *attr, const char *buf, size_t size)
-{
-	ssize_t status;
-	struct snd_sys_ctxt *snd_sys = &the_snd_sys;
-	int rc = 0;
-
-	rc = snd_sys_open();
-	if (rc)
-		return rc;
-
-	mutex_lock(&snd_sys->lock);
-	status = snd_vol_enable(buf);
-	mutex_unlock(&snd_sys->lock);
-
-	rc = snd_sys_release();
-	if (rc)
-		return rc;
-
-	return status ? : size;
-}
-
-static DEVICE_ATTR(agc, S_IWUSR | S_IRUGO,
-		NULL, snd_agc_store);
-
-static DEVICE_ATTR(avc, S_IWUSR | S_IRUGO,
-		NULL, snd_avc_store);
-
-static DEVICE_ATTR(device, S_IWUSR | S_IRUGO,
-		NULL, snd_dev_store);
-
-static DEVICE_ATTR(volume, S_IWUSR | S_IRUGO,
-		NULL, snd_vol_store);
-
-static int snd_probe(struct platform_device *pdev)
-{
-	struct snd_ctxt *snd = &the_snd;
-	struct snd_sys_ctxt *snd_sys = &the_snd_sys;
-	int rc = 0;
-
-	mutex_init(&snd->lock);
-	mutex_init(&snd_sys->lock);
-	snd_sys->ept = NULL;
-	snd->snd_epts = (struct msm_snd_endpoints *)pdev->dev.platform_data;
-	rc = misc_register(&snd_misc);
-	if (rc)
-		return rc;
-
-	rc = device_create_file(snd_misc.this_device, &dev_attr_agc);
-	if (rc) {
-		misc_deregister(&snd_misc);
-		return rc;
-	}
-
-	rc = device_create_file(snd_misc.this_device, &dev_attr_avc);
-	if (rc) {
-		device_remove_file(snd_misc.this_device,
-						&dev_attr_agc);
-		misc_deregister(&snd_misc);
-		return rc;
-	}
-
-	rc = device_create_file(snd_misc.this_device, &dev_attr_device);
-	if (rc) {
-		device_remove_file(snd_misc.this_device,
-						&dev_attr_agc);
-		device_remove_file(snd_misc.this_device,
-						&dev_attr_avc);
-		misc_deregister(&snd_misc);
-		return rc;
-	}
-
-	rc = device_create_file(snd_misc.this_device, &dev_attr_volume);
-	if (rc) {
-		device_remove_file(snd_misc.this_device,
-						&dev_attr_agc);
-		device_remove_file(snd_misc.this_device,
-						&dev_attr_avc);
-		device_remove_file(snd_misc.this_device,
-						&dev_attr_device);
-		misc_deregister(&snd_misc);
-	}
-
-	return rc;
-}
-
-static struct platform_driver snd_plat_driver = {
-	.probe = snd_probe,
-	.driver = {
-		.name = "msm_snd",
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init snd_init(void)
-{
-	return platform_driver_register(&snd_plat_driver);
-}
-
-module_init(snd_init);
diff --git a/arch/arm/mach-msm/qdsp5/snd_adie.c b/arch/arm/mach-msm/qdsp5/snd_adie.c
deleted file mode 100644
index 160ed93..0000000
--- a/arch/arm/mach-msm/qdsp5/snd_adie.c
+++ /dev/null
@@ -1,480 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/delay.h>
-#include <mach/msm_rpcrouter.h>
-#include <linux/debugfs.h>
-#include <mach/qdsp5/snd_adie.h>
-#include <mach/debug_mm.h>
-
-static struct adie_svc_client adie_client[ADIE_SVC_MAX_CLIENTS];
-static DEFINE_MUTEX(adie_client_lock);
-
-static int adie_svc_process_cb(struct msm_rpc_client *client,
-				 void *buffer, int in_size)
-{
-	int rc, id;
-	uint32_t accept_status;
-	struct rpc_request_hdr *req;
-	struct adie_svc_client_register_cb_cb_args arg, *buf_ptr;
-
-	req = (struct rpc_request_hdr *)buffer;
-	for (id = 0; id < ADIE_SVC_MAX_CLIENTS; id++) {
-		if (adie_client[id].rpc_client == client)
-			break;
-	}
-	if (id == ADIE_SVC_MAX_CLIENTS) {
-		MM_ERR("RPC reply with invalid rpc client\n");
-		accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR;
-		goto err;
-	}
-
-	buf_ptr = (struct adie_svc_client_register_cb_cb_args *)(req + 1);
-	arg.cb_id		= be32_to_cpu(buf_ptr->cb_id);
-	arg.size		= be32_to_cpu(buf_ptr->size);
-	arg.client_id		= be32_to_cpu(buf_ptr->client_id);
-	arg.adie_block		= be32_to_cpu(buf_ptr->adie_block);
-	arg.status		= be32_to_cpu(buf_ptr->status);
-	arg.client_operation	= be32_to_cpu(buf_ptr->client_operation);
-
-	if (arg.cb_id != adie_client[id].cb_id) {
-		MM_ERR("RPC reply with invalid invalid cb_id\n");
-		accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR;
-		goto err;
-	}
-
-	mutex_lock(&adie_client[id].lock);
-	switch (arg.client_operation) {
-	case ADIE_SVC_REGISTER_CLIENT:
-		MM_DBG("ADIE_SVC_REGISTER_CLIENT callback\n");
-		adie_client[id].client_id = arg.client_id;
-		break;
-	case ADIE_SVC_DEREGISTER_CLIENT:
-		MM_DBG("ADIE_SVC_DEREGISTER_CLIENT callback\n");
-		break;
-	case ADIE_SVC_CONFIG_ADIE_BLOCK:
-		MM_DBG("ADIE_SVC_CONFIG_ADIE_BLOCK callback\n");
-		if (adie_client[id].client_id != arg.client_id) {
-			mutex_unlock(&adie_client[id].lock);
-			accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR;
-			goto err;
-		}
-		break;
-	default:
-		accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR;
-		goto err;
-	}
-
-	adie_client[id].status = arg.status;
-	adie_client[id].adie_svc_cb_done = 1;
-	mutex_unlock(&adie_client[id].lock);
-	wake_up(&adie_client[id].wq);
-	accept_status = RPC_ACCEPTSTAT_SUCCESS;
-
-err:
-	msm_rpc_start_accepted_reply(client, be32_to_cpu(req->xid),
-				     accept_status);
-	rc = msm_rpc_send_accepted_reply(client, 0);
-	if (rc)
-		MM_ERR("%s: send accepted reply failed: %d\n", __func__, rc);
-
-	return rc;
-}
-
-static int adie_svc_rpc_cb_func(struct msm_rpc_client *client,
-			    void *buffer, int in_size)
-{
-	int rc = 0;
-	struct rpc_request_hdr *req;
-
-	req = (struct rpc_request_hdr *)buffer;
-
-	MM_DBG("procedure received to rpc cb %d\n",
-			be32_to_cpu(req->procedure));
-	switch (be32_to_cpu(req->procedure)) {
-	case ADIE_SVC_CLIENT_STATUS_FUNC_PTR_TYPE_PROC:
-		rc = adie_svc_process_cb(client, buffer, in_size);
-		break;
-	default:
-		MM_ERR("%s: procedure not supported %d\n", __func__,
-		       be32_to_cpu(req->procedure));
-		msm_rpc_start_accepted_reply(client, be32_to_cpu(req->xid),
-					     RPC_ACCEPTSTAT_PROC_UNAVAIL);
-		rc = msm_rpc_send_accepted_reply(client, 0);
-		if (rc)
-			MM_ERR("%s: sending reply failed: %d\n", __func__, rc);
-		break;
-	}
-	return rc;
-}
-
-static int adie_svc_client_register_arg(struct msm_rpc_client *client,
-		void *buf, void *data)
-{
-	struct adie_svc_client_register_cb_args *arg;
-
-	arg = (struct adie_svc_client_register_cb_args *)data;
-
-	*((int *)buf) = cpu_to_be32((int)arg->cb_id);
-	return sizeof(int);
-}
-
-static int adie_svc_client_deregister_arg(struct msm_rpc_client *client,
-		void *buf, void *data)
-{
-	struct adie_svc_client_deregister_cb_args *arg;
-
-	arg = (struct adie_svc_client_deregister_cb_args *)data;
-
-	*((int *)buf) = cpu_to_be32(arg->client_id);
-	return sizeof(int);
-}
-
-static int adie_svc_config_adie_block_arg(struct msm_rpc_client *client,
-		void *buf, void *data)
-{
-	struct adie_svc_config_adie_block_cb_args *arg;
-	int size = 0;
-
-	arg = (struct adie_svc_config_adie_block_cb_args *)data;
-
-	*((int *)buf) = cpu_to_be32(arg->client_id);
-	size += sizeof(int);
-	buf += sizeof(int);
-
-	*((int *)buf) = cpu_to_be32(arg->adie_block);
-	size += sizeof(int);
-	buf += sizeof(int);
-
-	*((int *)buf) = cpu_to_be32(arg->config);
-	size += sizeof(int);
-
-	return size;
-}
-
-/* Returns : client id on success
- *           and -1 on failure
- */
-int adie_svc_get(void)
-{
-	int id, rc = 0;
-	struct adie_svc_client_register_cb_args arg;
-
-	mutex_lock(&adie_client_lock);
-	for (id = 0; id < ADIE_SVC_MAX_CLIENTS; id++) {
-		if (adie_client[id].client_id == -1 &&
-				adie_client[id].rpc_client == NULL)
-			break;
-	}
-	if (id == ADIE_SVC_MAX_CLIENTS) {
-		mutex_unlock(&adie_client_lock);
-		return -1;
-	}
-
-	mutex_lock(&adie_client[id].lock);
-	adie_client[id].rpc_client = msm_rpc_register_client("adie_client",
-							ADIE_SVC_PROG,
-							ADIE_SVC_VERS, 1,
-							adie_svc_rpc_cb_func);
-	if (IS_ERR(adie_client[id].rpc_client)) {
-		MM_ERR("Failed to register RPC client\n");
-		adie_client[id].rpc_client = NULL;
-		mutex_unlock(&adie_client[id].lock);
-		mutex_unlock(&adie_client_lock);
-		return -1;
-	}
-	mutex_unlock(&adie_client_lock);
-
-	adie_client[id].adie_svc_cb_done = 0;
-	arg.cb_id = id;
-	adie_client[id].cb_id = arg.cb_id;
-	mutex_unlock(&adie_client[id].lock);
-	rc = msm_rpc_client_req(adie_client[id].rpc_client,
-				SND_ADIE_SVC_CLIENT_REGISTER_PROC,
-				adie_svc_client_register_arg, &arg,
-					NULL, NULL, -1);
-	if (!rc) {
-		rc = wait_event_interruptible(adie_client[id].wq,
-				adie_client[id].adie_svc_cb_done);
-		mutex_lock(&adie_client[id].lock);
-		if (unlikely(rc < 0)) {
-			if (rc == -ERESTARTSYS)
-				MM_ERR("wait_event_interruptible "
-						"returned -ERESTARTSYS\n");
-			else
-				MM_ERR("wait_event_interruptible "
-						"returned error\n");
-			rc = -1;
-			goto err;
-		}
-		MM_DBG("Status %d received from CB function, id %d rc %d\n",
-		       adie_client[id].status, adie_client[id].client_id, rc);
-		rc = id;
-		if (adie_client[id].status == ADIE_SVC_STATUS_FAILURE) {
-			MM_ERR("Received failed status for register request\n");
-			rc = -1;
-		} else
-			goto done;
-	} else {
-		MM_ERR("Failed to send register client request\n");
-		rc = -1;
-		mutex_lock(&adie_client[id].lock);
-	}
-err:
-	msm_rpc_unregister_client(adie_client[id].rpc_client);
-	adie_client[id].rpc_client = NULL;
-	adie_client[id].client_id = -1;
-	adie_client[id].cb_id = MSM_RPC_CLIENT_NULL_CB_ID;
-	adie_client[id].adie_svc_cb_done = 0;
-done:
-	mutex_unlock(&adie_client[id].lock);
-	return rc;
-}
-EXPORT_SYMBOL(adie_svc_get);
-
-/* Returns: 0 on succes and
- *         -1 on failure
- */
-int adie_svc_put(int id)
-{
-	int rc = 0;
-	struct adie_svc_client_deregister_cb_args arg;
-
-	if (id < 0 || id >= ADIE_SVC_MAX_CLIENTS)
-		return -1;
-
-	mutex_lock(&adie_client[id].lock);
-	if (adie_client[id].client_id == -1 ||
-			adie_client[id].rpc_client == NULL) {
-		mutex_unlock(&adie_client[id].lock);
-		return -1;
-	}
-	arg.client_id = adie_client[id].client_id;
-	adie_client[id].adie_svc_cb_done = 0;
-	mutex_unlock(&adie_client[id].lock);
-	rc = msm_rpc_client_req(adie_client[id].rpc_client,
-					SND_ADIE_SVC_CLIENT_DEREGISTER_PROC,
-					adie_svc_client_deregister_arg, &arg,
-					NULL, NULL, -1);
-	if (!rc) {
-		rc = wait_event_interruptible(adie_client[id].wq,
-				adie_client[id].adie_svc_cb_done);
-		if (unlikely(rc < 0)) {
-			if (rc == -ERESTARTSYS)
-				MM_ERR("wait_event_interruptible "
-						"returned -ERESTARTSYS\n");
-			else
-				MM_ERR("wait_event_interruptible "
-						"returned error\n");
-			rc = -1;
-			goto err;
-		}
-		MM_DBG("Status received from CB function\n");
-		mutex_lock(&adie_client[id].lock);
-		if (adie_client[id].status == ADIE_SVC_STATUS_FAILURE) {
-			rc = -1;
-		} else {
-			msm_rpc_unregister_client(adie_client[id].rpc_client);
-			adie_client[id].rpc_client = NULL;
-			adie_client[id].client_id = -1;
-			adie_client[id].cb_id = MSM_RPC_CLIENT_NULL_CB_ID;
-			adie_client[id].adie_svc_cb_done = 0;
-		}
-		mutex_unlock(&adie_client[id].lock);
-	} else {
-		MM_ERR("Failed to send deregister client request\n");
-		rc = -1;
-	}
-err:
-	return rc;
-}
-EXPORT_SYMBOL(adie_svc_put);
-
-/* Returns: 0 on success
- *          2 already in use
- *         -1 on failure
- */
-int adie_svc_config_adie_block(int id,
-		enum adie_block_enum_type adie_block_type, bool enable)
-{
-	int rc = 0;
-	struct adie_svc_config_adie_block_cb_args arg;
-
-	if (id < 0 || id >= ADIE_SVC_MAX_CLIENTS)
-		return -1;
-
-	mutex_lock(&adie_client[id].lock);
-	if (adie_client[id].client_id == -1 ||
-			adie_client[id].rpc_client == NULL) {
-		mutex_unlock(&adie_client[id].lock);
-		return -1;
-	}
-	arg.client_id 	= adie_client[id].client_id;
-	arg.adie_block	= adie_block_type;
-	arg.config	= (enum adie_config_enum_type)enable;
-	adie_client[id].adie_svc_cb_done = 0;
-	mutex_unlock(&adie_client[id].lock);
-	rc = msm_rpc_client_req(adie_client[id].rpc_client,
-					SND_ADIE_SVC_CONFIG_ADIE_BLOCK_PROC,
-					adie_svc_config_adie_block_arg, &arg,
-					NULL, NULL, -1);
-	if (!rc) {
-		rc = wait_event_interruptible(adie_client[id].wq,
-				adie_client[id].adie_svc_cb_done);
-		if (unlikely(rc < 0)) {
-			if (rc == -ERESTARTSYS)
-				MM_ERR("wait_event_interruptible "
-						"returned -ERESTARTSYS\n");
-			else
-				MM_ERR("wait_event_interruptible "
-						"returned error\n");
-			rc = -1;
-			goto err;
-		}
-		MM_DBG("Status received from CB function\n");
-		mutex_lock(&adie_client[id].lock);
-		if (adie_client[id].status == ADIE_SVC_STATUS_FAILURE)
-			rc = -1;
-		else
-			rc = adie_client[id].status;
-		mutex_unlock(&adie_client[id].lock);
-	} else {
-		MM_ERR("Failed to send adie block config request\n");
-		rc = -1;
-	}
-err:
-	return rc;
-}
-EXPORT_SYMBOL(adie_svc_config_adie_block);
-
-#ifdef CONFIG_DEBUG_FS
-
-struct dentry *dentry;
-
-static ssize_t snd_adie_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static ssize_t snd_adie_debug_write(struct file *file, const char __user *buf,
-	       size_t count, loff_t *ppos)
-{
-	int rc = 0, op = 0;
-	int id = 0, adie_block = 0, config = 1;
-
-	sscanf(buf, "%d %d %d %d", &op, &id, &adie_block, &config);
-	MM_INFO("\nUser input: op %d id %d block %d config %d\n", op, id,
-			adie_block, config);
-	switch (op) {
-	case ADIE_SVC_REGISTER_CLIENT:
-		MM_INFO("ADIE_SVC_REGISTER_CLIENT\n");
-		rc = adie_svc_get();
-		if (rc >= 0)
-			MM_INFO("Client registered: %d\n", rc);
-		else
-			MM_ERR("Failed registering client\n");
-		break;
-	case ADIE_SVC_DEREGISTER_CLIENT:
-		MM_INFO("ADIE_SVC_DEREGISTER_CLIENT: %d\n", id);
-		rc = adie_svc_put(id);
-		if (!rc)
-			MM_INFO("Client %d deregistered\n", id);
-		else
-			MM_ERR("Failed unregistering the client: %d\n",	id);
-		break;
-	case ADIE_SVC_CONFIG_ADIE_BLOCK:
-		MM_INFO("ADIE_SVC_CONFIG_ADIE_BLOCK: id %d adie_block %d \
-				config %d\n", id, adie_block, config);
-		rc =  adie_svc_config_adie_block(id,
-			(enum adie_block_enum_type)adie_block, (bool)config);
-		if (!rc)
-			MM_INFO("ADIE block %d %s", adie_block,
-					config ? "enabled\n" : "disabled\n");
-		else if (rc == 2)
-			MM_INFO("ADIE block %d already in use\n", adie_block);
-		else
-			MM_ERR("ERROR configuring the ADIE block\n");
-		break;
-	default:
-		MM_INFO("Invalid operation\n");
-	}
-	return count;
-}
-
-static ssize_t snd_adie_debug_read(struct file *file, char __user *buf,
-			  size_t count, loff_t *ppos)
-{
-	static char buffer[1024];
-	const int debug_bufmax = sizeof(buffer);
-	int id, n = 0;
-
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"LIST OF CLIENTS\n");
-	for (id = 0; id < ADIE_SVC_MAX_CLIENTS ; id++) {
-		if (adie_client[id].client_id != -1 &&
-				adie_client[id].rpc_client != NULL) {
-			n += scnprintf(buffer + n, debug_bufmax - n,
-				"id %d rpc client 0x%08x\n", id,
-				(uint32_t)adie_client[id].rpc_client);
-		}
-	}
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations snd_adie_debug_fops = {
-	.read = snd_adie_debug_read,
-	.open = snd_adie_debug_open,
-	.write = snd_adie_debug_write,
-};
-#endif
-
-static void __exit snd_adie_exit(void)
-{
-#ifdef CONFIG_DEBUG_FS
-	if (dentry)
-		debugfs_remove(dentry);
-#endif
-}
-
-static int __init snd_adie_init(void)
-{
-	int id;
-#ifdef CONFIG_DEBUG_FS
-	char name[sizeof "msm_snd_adie"];
-
-	snprintf(name, sizeof name, "msm_snd_adie");
-	dentry = debugfs_create_file(name, S_IFREG | S_IRUGO | S_IWUGO,
-			NULL, NULL, &snd_adie_debug_fops);
-	if (IS_ERR(dentry))
-		MM_DBG("debugfs_create_file failed\n");
-#endif
-	for (id = 0; id < ADIE_SVC_MAX_CLIENTS; id++) {
-		adie_client[id].client_id = -1;
-		adie_client[id].cb_id = MSM_RPC_CLIENT_NULL_CB_ID;
-		adie_client[id].status = 0;
-		adie_client[id].adie_svc_cb_done = 0;
-		mutex_init(&adie_client[id].lock);
-		init_waitqueue_head(&adie_client[id].wq);
-		adie_client[id].rpc_client = NULL;
-	}
-	return 0;
-}
-
-module_init(snd_adie_init);
-module_exit(snd_adie_exit);
diff --git a/arch/arm/mach-msm/qdsp5/snd_cad.c b/arch/arm/mach-msm/qdsp5/snd_cad.c
deleted file mode 100644
index 0b92cef2..0000000
--- a/arch/arm/mach-msm/qdsp5/snd_cad.c
+++ /dev/null
@@ -1,608 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/snd_cad.c
- *
- * interface to "snd" service on the baseband cpu
- * This code also borrows from snd.c, which is
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2009, 2012 The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/delay.h>
-#include <linux/msm_audio.h>
-#include <linux/seq_file.h>
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-#include <mach/board.h>
-#include <mach/msm_rpcrouter.h>
-#include <mach/debug_mm.h>
-#include <linux/debugfs.h>
-
-struct snd_cad_ctxt {
-	struct mutex lock;
-	int opened;
-	struct msm_rpc_endpoint *ept;
-	struct msm_cad_endpoints *cad_epts;
-};
-
-struct snd_cad_sys_ctxt {
-	struct mutex lock;
-	struct msm_rpc_endpoint *ept;
-};
-
-struct snd_curr_dev_info {
-	int rx_dev;
-	int tx_dev;
-};
-
-static struct snd_cad_sys_ctxt the_snd_cad_sys;
-
-static struct snd_cad_ctxt the_snd;
-static struct snd_curr_dev_info curr_dev;
-
-#define RPC_SND_PROG	0x30000002
-#define RPC_SND_CB_PROG	0x31000002
-
-#define RPC_SND_VERS	0x00030003
-
-#define SND_CAD_SET_DEVICE_PROC 40
-#define SND_CAD_SET_VOLUME_PROC 39
-#define MAX_SND_ACTIVE_DEVICE 2
-
-struct rpc_cad_set_device_args {
-	struct cad_devices_type device;
-	uint32_t ear_mute;
-	uint32_t mic_mute;
-
-	uint32_t cb_func;
-	uint32_t client_data;
-};
-
-struct rpc_cad_set_volume_args {
-	struct cad_devices_type device;
-	uint32_t method;
-	uint32_t volume;
-
-	uint32_t cb_func;
-	uint32_t client_data;
-};
-
-struct snd_cad_set_device_msg {
-	struct rpc_request_hdr hdr;
-	struct rpc_cad_set_device_args args;
-};
-
-struct snd_cad_set_volume_msg {
-	struct rpc_request_hdr hdr;
-	struct rpc_cad_set_volume_args args;
-};
-
-struct cad_endpoint *get_cad_endpoints(int *size);
-
-#ifdef CONFIG_DEBUG_FS
-static struct dentry *dentry;
-
-static int rtc_getdevice_dbg_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	MM_INFO("debug intf %s\n", (char *) file->private_data);
-	return 0;
-}
-
-static ssize_t rtc_getdevice_dbg_read(struct file *file, char __user *buf,
-			  size_t count, loff_t *ppos)
-{
-	int n = 0;
-	static char *buffer;
-	static char *swap_buf;
-	const int debug_bufmax = 1024;
-	int swap_count = 0;
-	int rc = 0;
-	int dev_count = 0;
-	int dev_id = 0;
-	struct msm_cad_endpoints *msm_cad_epts = the_snd.cad_epts;
-	struct cad_endpoint *cad_epts;
-
-	buffer = kmalloc(sizeof(char) * 1024, GFP_KERNEL);
-	if (buffer == NULL) {
-		MM_ERR("Memory allocation failed for buffer failed\n");
-		return -EFAULT;
-	}
-
-	swap_buf = kmalloc(sizeof(char) * 1024, GFP_KERNEL);
-	if (swap_buf == NULL) {
-		MM_ERR("Memory allocation failed for swap buffer failed\n");
-		kfree(buffer);
-		return -EFAULT;
-	}
-
-	if (msm_cad_epts->num <= 0) {
-		dev_count = 0;
-		n = scnprintf(buffer, debug_bufmax, "DEV_NO:0x%x\n",
-				msm_cad_epts->num);
-	} else {
-		for (dev_id = 0; dev_id < msm_cad_epts->num; dev_id++) {
-			cad_epts = &msm_cad_epts->endpoints[dev_id];
-			if (IS_ERR(cad_epts)) {
-				MM_ERR("invalid snd endpoint for dev_id %d\n",
-					dev_id);
-				rc = PTR_ERR(cad_epts);
-				continue;
-			}
-
-			if ((cad_epts->id != curr_dev.tx_dev) &&
-				(cad_epts->id != curr_dev.rx_dev))
-				continue;
-
-			n += scnprintf(swap_buf + n, debug_bufmax - n,
-					"ACDB_ID:0x%x;CAPB:0x%x\n",
-					cad_epts->id,
-					cad_epts->capability);
-			dev_count++;
-			MM_DBG("RTC Get Device %x Capb %x Dev Count %x\n",
-					dev_id, cad_epts->capability,
-					dev_count);
-
-		}
-	}
-	swap_count = scnprintf(buffer, debug_bufmax, \
-			"DEV_NO:0x%x\n", dev_count);
-
-	memcpy(buffer+swap_count, swap_buf, n*sizeof(char));
-	n = n+swap_count;
-
-	buffer[n] = 0;
-	rc =  simple_read_from_buffer(buf, count, ppos, buffer, n);
-	kfree(buffer);
-	kfree(swap_buf);
-	return rc;
-}
-
-static const struct file_operations rtc_acdb_debug_fops = {
-	.open = rtc_getdevice_dbg_open,
-	.read = rtc_getdevice_dbg_read
-};
-
-static int rtc_debugfs_create_entry(void)
-{
-	int rc = 0;
-	char name[sizeof "rtc_get_device"+1];
-
-	snprintf(name, sizeof name, "rtc_get_device");
-	dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
-			NULL, NULL, &rtc_acdb_debug_fops);
-	if (IS_ERR(dentry)) {
-		MM_ERR("debugfs_create_file failed\n");
-		rc = PTR_ERR(dentry);
-	}
-	return rc;
-}
-#else
-static int rtc_debugfs_create_entry()
-{
-	return 0;
-}
-#endif
-
-static inline int check_mute(int mute)
-{
-	return (mute == SND_MUTE_MUTED ||
-		mute == SND_MUTE_UNMUTED) ? 0 : -EINVAL;
-}
-
-static int get_endpoint(struct snd_cad_ctxt *snd, unsigned long arg)
-{
-	int rc = 0, index;
-	struct msm_cad_endpoint ept;
-
-	if (copy_from_user(&ept, (void __user *)arg, sizeof(ept))) {
-		MM_ERR("cad_ioctl get endpoint: invalid read pointer\n");
-		return -EFAULT;
-	}
-
-	index = ept.id;
-	if (index < 0 || index >= snd->cad_epts->num) {
-		MM_ERR("snd_ioctl get endpoint: invalid index!\n");
-		return -EINVAL;
-	}
-
-	ept.id = snd->cad_epts->endpoints[index].id;
-	strlcpy(ept.name,
-		snd->cad_epts->endpoints[index].name,
-		sizeof(ept.name));
-
-	if (copy_to_user((void __user *)arg, &ept, sizeof(ept))) {
-		MM_ERR("snd_ioctl get endpoint: invalid write pointer\n");
-		rc = -EFAULT;
-	}
-
-	return rc;
-}
-
-static long snd_cad_ioctl(struct file *file, unsigned int cmd,
-		unsigned long arg)
-{
-	struct snd_cad_set_device_msg dmsg;
-	struct snd_cad_set_volume_msg vmsg;
-
-	struct msm_cad_device_config dev;
-	struct msm_cad_volume_config vol;
-	struct snd_cad_ctxt *snd = file->private_data;
-	int rc = 0;
-
-	mutex_lock(&snd->lock);
-	switch (cmd) {
-	case SND_SET_DEVICE:
-		if (copy_from_user(&dev, (void __user *) arg, sizeof(dev))) {
-			MM_ERR("set device: invalid pointer\n");
-			rc = -EFAULT;
-			break;
-		}
-
-		dmsg.args.device.rx_device = cpu_to_be32(dev.device.rx_device);
-		dmsg.args.device.tx_device = cpu_to_be32(dev.device.tx_device);
-		dmsg.args.device.pathtype = cpu_to_be32(dev.device.pathtype);
-		dmsg.args.ear_mute = cpu_to_be32(dev.ear_mute);
-		dmsg.args.mic_mute = cpu_to_be32(dev.mic_mute);
-		if (check_mute(dev.ear_mute) < 0 ||
-				check_mute(dev.mic_mute) < 0) {
-			MM_ERR("set device: invalid mute status\n");
-			rc = -EINVAL;
-			break;
-		}
-		dmsg.args.cb_func = -1;
-		dmsg.args.client_data = 0;
-		curr_dev.tx_dev = dev.device.tx_device;
-		curr_dev.rx_dev = dev.device.rx_device;
-		MM_ERR("snd_cad_set_device %d %d %d %d\n", dev.device.rx_device,
-			dev.device.tx_device, dev.ear_mute, dev.mic_mute);
-
-		rc = msm_rpc_call(snd->ept,
-			SND_CAD_SET_DEVICE_PROC,
-			&dmsg, sizeof(dmsg), 5 * HZ);
-		break;
-
-	case SND_SET_VOLUME:
-		if (copy_from_user(&vol, (void __user *) arg, sizeof(vol))) {
-			MM_ERR("set volume: invalid pointer\n");
-			rc = -EFAULT;
-			break;
-		}
-
-		vmsg.args.device.rx_device = cpu_to_be32(dev.device.rx_device);
-		vmsg.args.device.tx_device = cpu_to_be32(dev.device.tx_device);
-		vmsg.args.method = cpu_to_be32(vol.method);
-		if (vol.method != SND_METHOD_VOICE &&
-				vol.method != SND_METHOD_MIDI) {
-			MM_ERR("set volume: invalid method %d\n", vol.method);
-			rc = -EINVAL;
-			break;
-		}
-
-		vmsg.args.volume = cpu_to_be32(vol.volume);
-		vmsg.args.cb_func = -1;
-		vmsg.args.client_data = 0;
-
-		MM_ERR("snd_cad_set_volume %d %d %d %d\n", vol.device.rx_device,
-				vol.device.tx_device, vol.method, vol.volume);
-
-		rc = msm_rpc_call(snd->ept,
-			SND_CAD_SET_VOLUME_PROC,
-			&vmsg, sizeof(vmsg), 5 * HZ);
-
-		break;
-
-	case SND_GET_NUM_ENDPOINTS:
-		if (copy_to_user((void __user *)arg,
-				&snd->cad_epts->num, sizeof(unsigned))) {
-			MM_ERR("get endpoint: invalid pointer\n");
-			rc = -EFAULT;
-		}
-		break;
-
-	case SND_GET_ENDPOINT:
-		rc = get_endpoint(snd, arg);
-		break;
-
-	default:
-		MM_ERR("unknown command\n");
-		rc = -EINVAL;
-		break;
-	}
-	mutex_unlock(&snd->lock);
-
-	return rc;
-}
-
-static int snd_cad_release(struct inode *inode, struct file *file)
-{
-	struct snd_cad_ctxt *snd = file->private_data;
-	int rc;
-
-	mutex_lock(&snd->lock);
-	rc = msm_rpc_close(snd->ept);
-	if (rc < 0)
-		MM_ERR("msm_rpc_close failed\n");
-	snd->ept = NULL;
-	snd->opened = 0;
-	mutex_unlock(&snd->lock);
-	return 0;
-}
-static int snd_cad_sys_release(void)
-{
-	struct snd_cad_sys_ctxt *snd_cad_sys = &the_snd_cad_sys;
-	int rc = 0;
-
-	mutex_lock(&snd_cad_sys->lock);
-	rc = msm_rpc_close(snd_cad_sys->ept);
-	if (rc < 0)
-		MM_ERR("msm_rpc_close failed\n");
-	snd_cad_sys->ept = NULL;
-	mutex_unlock(&snd_cad_sys->lock);
-	return rc;
-}
-static int snd_cad_open(struct inode *inode, struct file *file)
-{
-	struct snd_cad_ctxt *snd = &the_snd;
-	int rc = 0;
-
-	mutex_lock(&snd->lock);
-	if (snd->opened == 0) {
-		if (snd->ept == NULL) {
-			snd->ept = msm_rpc_connect_compatible(RPC_SND_PROG,
-					RPC_SND_VERS, 0);
-			if (IS_ERR(snd->ept)) {
-				rc = PTR_ERR(snd->ept);
-				snd->ept = NULL;
-				MM_ERR("cad connect failed with VERS %x\n",
-					RPC_SND_VERS);
-				goto err;
-			}
-		}
-		file->private_data = snd;
-		snd->opened = 1;
-	} else {
-		MM_ERR("snd already opened\n");
-		rc = -EBUSY;
-	}
-
-err:
-	mutex_unlock(&snd->lock);
-	return rc;
-}
-static int snd_cad_sys_open(void)
-{
-	struct snd_cad_sys_ctxt *snd_cad_sys = &the_snd_cad_sys;
-	int rc = 0;
-
-	mutex_lock(&snd_cad_sys->lock);
-	if (snd_cad_sys->ept == NULL) {
-		snd_cad_sys->ept = msm_rpc_connect_compatible(RPC_SND_PROG,
-			RPC_SND_VERS, 0);
-		if (IS_ERR(snd_cad_sys->ept)) {
-			rc = PTR_ERR(snd_cad_sys->ept);
-			snd_cad_sys->ept = NULL;
-			MM_ERR("func %s : cad connect failed with VERS %x\n",
-				__func__, RPC_SND_VERS);
-			goto err;
-		}
-	} else
-		MM_DBG("snd already opened\n");
-err:
-	mutex_unlock(&snd_cad_sys->lock);
-	return rc;
-}
-
-static const struct file_operations snd_cad_fops = {
-	.owner		= THIS_MODULE,
-	.open		= snd_cad_open,
-	.release	= snd_cad_release,
-	.unlocked_ioctl	= snd_cad_ioctl,
-};
-
-struct miscdevice snd_cad_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_cad",
-	.fops	= &snd_cad_fops,
-};
-
-static long snd_cad_vol_enable(const char *arg)
-{
-	struct snd_cad_sys_ctxt *snd_cad_sys = &the_snd_cad_sys;
-	struct snd_cad_set_volume_msg vmsg;
-	struct msm_cad_volume_config vol;
-	int rc = 0;
-
-	rc = sscanf(arg, "%d %d %d %d", &vol.device.rx_device,
-			&vol.device.tx_device, &vol.method, &vol.volume);
-	if (rc != 4) {
-		MM_ERR("Invalid arguments. Usage: <rx_device> <tx_device>" \
-			"method> <volume>\n");
-		rc = -EINVAL;
-		return rc;
-	}
-
-	vmsg.args.device.rx_device = cpu_to_be32(vol.device.rx_device);
-	vmsg.args.device.tx_device = cpu_to_be32(vol.device.tx_device);
-	vmsg.args.method = cpu_to_be32(vol.method);
-	if (vol.method != SND_METHOD_VOICE && vol.method != SND_METHOD_MIDI) {
-		MM_ERR("snd_cad_ioctl set volume: invalid method\n");
-		rc = -EINVAL;
-		return rc;
-	}
-
-	vmsg.args.volume = cpu_to_be32(vol.volume);
-	vmsg.args.cb_func = -1;
-	vmsg.args.client_data = 0;
-
-	MM_DBG("snd_cad_set_volume %d %d %d %d\n", vol.device.rx_device,
-			vol.device.tx_device, vol.method, vol.volume);
-
-	rc = msm_rpc_call(snd_cad_sys->ept,
-		SND_CAD_SET_VOLUME_PROC,
-		&vmsg, sizeof(vmsg), 5 * HZ);
-	return rc;
-}
-
-static long snd_cad_dev_enable(const char *arg)
-{
-	struct snd_cad_sys_ctxt *snd_cad_sys = &the_snd_cad_sys;
-	struct snd_cad_set_device_msg dmsg;
-	struct msm_cad_device_config dev;
-	int rc = 0;
-
-
-	rc = sscanf(arg, "%d %d %d %d", &dev.device.rx_device,
-			&dev.device.tx_device, &dev.ear_mute, &dev.mic_mute);
-	if (rc != 4) {
-		MM_ERR("Invalid arguments. Usage: <rx_device> <tx_device> "\
-			"<ear_mute> <mic_mute>\n");
-		rc = -EINVAL;
-		return rc;
-	}
-	dmsg.args.device.rx_device = cpu_to_be32(dev.device.rx_device);
-	dmsg.args.device.tx_device = cpu_to_be32(dev.device.tx_device);
-	dmsg.args.device.pathtype = cpu_to_be32(CAD_DEVICE_PATH_RX_TX);
-	dmsg.args.ear_mute = cpu_to_be32(dev.ear_mute);
-	dmsg.args.mic_mute = cpu_to_be32(dev.mic_mute);
-	if (check_mute(dev.ear_mute) < 0 ||
-			check_mute(dev.mic_mute) < 0) {
-		MM_ERR("snd_cad_ioctl set device: invalid mute status\n");
-		rc = -EINVAL;
-		return rc;
-	}
-	dmsg.args.cb_func = -1;
-	dmsg.args.client_data = 0;
-	curr_dev.tx_dev = dev.device.tx_device;
-	curr_dev.rx_dev = dev.device.rx_device;
-
-	MM_INFO("snd_cad_set_device %d %d %d %d\n", dev.device.rx_device,
-			dev.device.tx_device, dev.ear_mute, dev.mic_mute);
-
-	rc = msm_rpc_call(snd_cad_sys->ept,
-		SND_CAD_SET_DEVICE_PROC,
-		&dmsg, sizeof(dmsg), 5 * HZ);
-	return rc;
-}
-
-static ssize_t snd_cad_dev_store(struct device *dev,
-		struct device_attribute *attr, const char *buf, size_t size)
-{
-	ssize_t status;
-	struct snd_cad_sys_ctxt *snd_cad_sys = &the_snd_cad_sys;
-	int rc = 0;
-
-	rc = snd_cad_sys_open();
-	if (rc)
-		return rc;
-
-	mutex_lock(&snd_cad_sys->lock);
-	status = snd_cad_dev_enable(buf);
-	mutex_unlock(&snd_cad_sys->lock);
-
-	rc = snd_cad_sys_release();
-	if (rc)
-		return rc;
-
-	return status ? : size;
-}
-
-static ssize_t snd_cad_vol_store(struct device *dev,
-		struct device_attribute *attr, const char *buf, size_t size)
-{
-	ssize_t status;
-	struct snd_cad_sys_ctxt *snd_cad_sys = &the_snd_cad_sys;
-	int rc = 0;
-
-	rc = snd_cad_sys_open();
-	if (rc)
-		return rc;
-
-	mutex_lock(&snd_cad_sys->lock);
-	status = snd_cad_vol_enable(buf);
-	mutex_unlock(&snd_cad_sys->lock);
-
-	rc = snd_cad_sys_release();
-	if (rc)
-		return rc;
-
-	return status ? : size;
-}
-
-static DEVICE_ATTR(device, S_IWUSR | S_IRUGO,
-		NULL, snd_cad_dev_store);
-
-static DEVICE_ATTR(volume, S_IWUSR | S_IRUGO,
-		NULL, snd_cad_vol_store);
-
-static int snd_cad_probe(struct platform_device *pdev)
-{
-	struct snd_cad_ctxt *snd = &the_snd;
-	struct snd_cad_sys_ctxt *snd_cad_sys = &the_snd_cad_sys;
-	int rc = 0;
-
-	mutex_init(&snd->lock);
-	mutex_init(&snd_cad_sys->lock);
-	snd_cad_sys->ept = NULL;
-	snd->cad_epts =
-			(struct msm_cad_endpoints *)pdev->dev.platform_data;
-	rc = misc_register(&snd_cad_misc);
-	if (rc)
-		return rc;
-
-	rc = device_create_file(snd_cad_misc.this_device, &dev_attr_device);
-	if (rc) {
-		misc_deregister(&snd_cad_misc);
-		return rc;
-	}
-
-	rc = device_create_file(snd_cad_misc.this_device, &dev_attr_volume);
-	if (rc) {
-		device_remove_file(snd_cad_misc.this_device,
-						&dev_attr_device);
-		misc_deregister(&snd_cad_misc);
-	}
-
-#ifdef CONFIG_DEBUG_FS
-	rc = rtc_debugfs_create_entry();
-	if (rc) {
-		device_remove_file(snd_cad_misc.this_device,
-						&dev_attr_volume);
-		device_remove_file(snd_cad_misc.this_device,
-						&dev_attr_device);
-		misc_deregister(&snd_cad_misc);
-	}
-#endif
-	return rc;
-}
-
-static struct platform_driver snd_cad_plat_driver = {
-	.probe = snd_cad_probe,
-	.driver = {
-		.name = "msm_cad",
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init snd_cad_init(void)
-{
-	return platform_driver_register(&snd_cad_plat_driver);
-}
-
-module_init(snd_cad_init);
-
-MODULE_DESCRIPTION("MSM CAD SND driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5/snd_pcm_client.c b/arch/arm/mach-msm/qdsp5/snd_pcm_client.c
deleted file mode 100644
index 5c59601..0000000
--- a/arch/arm/mach-msm/qdsp5/snd_pcm_client.c
+++ /dev/null
@@ -1,522 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- *
- */
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/fs.h>
-#include <linux/kthread.h>
-#include <linux/miscdevice.h>
-#include <linux/module.h>
-#include <linux/msm_audio.h>
-#include <linux/slab.h>
-#include <linux/uaccess.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_rpcrouter.h>
-
-#define SND_VOC_PCM_INTERFACE_PROG	0x30000002
-#define SND_VOC_PCM_INTERFACE_VERS	0x00020004
-
-/* Supply always 160 words of PCM samples (20ms data) */
-#define MAX_VOC_FRAME_SIZE 160
-#define VOC_FRAME_DURATION 20
-/* Buffering for Maximum 8 frames between userspace and driver */
-#define MAX_VOC_FRAMES 8
-#define BUFSZ ((MAX_VOC_FRAME_SIZE*2)*MAX_VOC_FRAMES)
-#define SND_VOC_PCM_CLIENT_INPUT_FN_TYPE_PROC 3
-#define SND_VOC_REGISTER_PCM_INPUT_CLIENT_PROC 24
-
-#define START_CALLBACK_ID 0x12345678
-#define STOP_CALLBACK_ID 0xffffffff
-
-#define MAX_WAIT_CONSUME (MAX_VOC_FRAMES * VOC_FRAME_DURATION)
-/* PCM Interfaces */
-enum voice_pcm_interface_type {
-	VOICE_PCM_INTERFACE_TX_INPUT = 3, /* PCM Inject input to PreProc */
-};
-
-enum voice_pcm_interface_reg_status_type {
-	SUCCESS = 0, /* Success 0, else failure */
-};
-
-/* status used by PCM input callbacks to indicate availability of PCM Data */
-enum voice_pcm_data_status_type {
-	VOICE_PCM_DATA_STATUS_AVAILABLE,    /* Data available for PCM input */
-	VOICE_PCM_DATA_STATUS_UNAVAILABLE,  /* Data not available           */
-	VOICE_PCM_DATA_STATUS_MAX
-};
-
-/* Argument needed to register PCM input  client */
-struct snd_voice_pcm_interface_ipclnt_reg_args {
-	/* Interface number specifies the PCM inject point */
-	enum voice_pcm_interface_type interface;
-	/* Non-NULL indicates start,NULL indicates stop */
-	uint32_t callback_id;
-};
-
-struct snd_voice_pcm_interface_ipclnt_reg_status {
-	enum voice_pcm_interface_reg_status_type status;
-};
-
-struct snd_voice_pcm_interface_ipclnt_fn_type_args {
-	uint32_t callback_id;
-	uint32_t pcm_data_ptr_not_null;
-	uint32_t pcm_data_max_length;
-};
-
-struct snd_voice_pcm_interface_ipclnt_fn_type_reply {
-	enum voice_pcm_data_status_type status;
-	struct {
-		uint32_t pcm_data_len;
-		struct {
-			uint16_t pcm_data_ignore;
-			uint16_t pcm_data_valid;
-		} pcm_data_val[MAX_VOC_FRAME_SIZE];
-	} pcm_data;
-};
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;
-};
-
-struct audio {
-	struct buffer out[MAX_VOC_FRAMES];
-
-	uint8_t out_head;
-	uint8_t out_tail;
-
-	atomic_t out_bytes;
-	/* data allocated for various buffers */
-	char *data;
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t wait;
-	wait_queue_head_t stop_wait;
-
-	int buffer_finished;
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped */
-
-	struct msm_rpc_client *client;
-};
-
-static struct audio the_audio;
-
-static int snd_voice_pcm_interface_ipclnt_reg_args(
-	struct msm_rpc_client *client, void *buf, void *data)
-{
-	struct snd_voice_pcm_interface_ipclnt_reg_args *arg;
-	int size = 0;
-
-	arg = (struct snd_voice_pcm_interface_ipclnt_reg_args *)data;
-	*((int *)buf) = cpu_to_be32(arg->interface);
-	size += sizeof(int);
-	buf += sizeof(int);
-	*((int *)buf) = cpu_to_be32(arg->callback_id);
-	size += sizeof(int);
-
-	return size;
-}
-
-static int snd_voice_pcm_interface_ipclnt_reg_status(
-	struct msm_rpc_client *client, void *buf, void *data)
-{
-	struct snd_voice_pcm_interface_ipclnt_reg_status *result =
-	(struct snd_voice_pcm_interface_ipclnt_reg_status *)buf;
-
-	*((int *)data) =  be32_to_cpu(result->status);
-	return 0;
-}
-
-static void process_callback(struct audio *audio,
-	void *buffer, int in_size)
-{
-	uint32_t accept_status = RPC_ACCEPTSTAT_SUCCESS;
-	struct rpc_request_hdr *req;
-	struct snd_voice_pcm_interface_ipclnt_fn_type_args arg, *buf_ptr;
-	struct snd_voice_pcm_interface_ipclnt_fn_type_reply *reply;
-	struct buffer *frame;
-	uint32_t status;
-	uint32_t pcm_data_len;
-
-	req = (struct rpc_request_hdr *)buffer;
-	buf_ptr = (struct snd_voice_pcm_interface_ipclnt_fn_type_args *)\
-				(req + 1);
-	arg.callback_id = be32_to_cpu(buf_ptr->callback_id);
-	arg.pcm_data_ptr_not_null = be32_to_cpu(buf_ptr->pcm_data_ptr_not_null);
-	arg.pcm_data_max_length = be32_to_cpu(buf_ptr->pcm_data_max_length);
-
-	MM_DBG("callback_id = 0x%8x pcm_data_ptr_not_null = 0x%8x"\
-		"pcm_data_max_length = 0x%8x\n", arg.callback_id,\
-		arg.pcm_data_ptr_not_null, arg.pcm_data_max_length);
-	/* Flag interface as running */
-	if (!audio->running)
-		audio->running = 1;
-	if (!arg.pcm_data_ptr_not_null) {
-		accept_status = RPC_ACCEPTSTAT_SYSTEM_ERR;
-		msm_rpc_start_accepted_reply(audio->client,
-			be32_to_cpu(req->xid), accept_status);
-		msm_rpc_send_accepted_reply(audio->client, 0);
-		return;
-	}
-	reply = (struct snd_voice_pcm_interface_ipclnt_fn_type_reply *)
-		msm_rpc_start_accepted_reply(audio->client,
-			be32_to_cpu(req->xid), accept_status);
-	frame = audio->out + audio->out_tail;
-	/* If Data available, send data */
-	if (frame->used) {
-		int i;
-		unsigned short *src = frame->data;
-		atomic_add(frame->used, &audio->out_bytes);
-		status = VOICE_PCM_DATA_STATUS_AVAILABLE;
-		pcm_data_len = MAX_VOC_FRAME_SIZE;
-		xdr_send_int32(&audio->client->cb_xdr, &status);
-		xdr_send_int32(&audio->client->cb_xdr, &pcm_data_len);
-		/* Expected cb_xdr buffer size is more than PCM buffer size */
-		for (i = 0; i < MAX_VOC_FRAME_SIZE; i++, ++src)
-			xdr_send_int16(&audio->client->cb_xdr, src);
-		frame->used = 0;
-		audio->out_tail = ((++audio->out_tail) % MAX_VOC_FRAMES);
-		wake_up(&audio->wait);
-	} else {
-		status = VOICE_PCM_DATA_STATUS_UNAVAILABLE;
-		pcm_data_len = 0;
-		xdr_send_int32(&audio->client->cb_xdr, &status);
-		xdr_send_int32(&audio->client->cb_xdr, &pcm_data_len);
-		wake_up(&audio->wait);
-		/* Flag all buffer completed */
-		if (audio->stopped) {
-			audio->buffer_finished = 1;
-			wake_up(&audio->stop_wait);
-		}
-	}
-	MM_DBG("Provided PCM data = 0x%8x\n", reply->status);
-	msm_rpc_send_accepted_reply(audio->client, 0);
-	return;
-}
-
-static int pcm_interface_process_callback_routine(struct msm_rpc_client *client,
-	void *buffer, int in_size)
-{
-	struct rpc_request_hdr *req;
-	struct audio *audio = &the_audio;
-	int rc = 0;
-
-	req = (struct rpc_request_hdr *)buffer;
-
-	MM_DBG("proc id = 0x%8x xid = 0x%8x size = 0x%8x\n",
-		be32_to_cpu(req->procedure), be32_to_cpu(req->xid), in_size);
-	switch (be32_to_cpu(req->procedure)) {
-	/* Procedure which called every 20ms for PCM samples request*/
-	case SND_VOC_PCM_CLIENT_INPUT_FN_TYPE_PROC:
-		process_callback(audio, buffer, in_size);
-		break;
-	default:
-		MM_ERR("Not supported proceudure 0x%8x\n",
-			be32_to_cpu(req->procedure));
-		/* Not supported RPC Procedure, send nagative code */
-		msm_rpc_start_accepted_reply(client, be32_to_cpu(req->xid),
-				RPC_ACCEPTSTAT_PROC_UNAVAIL);
-		msm_rpc_send_accepted_reply(client, 0);
-	}
-	return rc;
-}
-
-static void audio_flush(struct audio *audio)
-{
-	int cnt;
-	for (cnt = 0; cnt < MAX_VOC_FRAMES; cnt++)
-		audio->out[cnt].used = 0;
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->stopped = 0;
-	audio->running = 0;
-	audio->buffer_finished = 0;
-}
-
-/* must be called with audio->lock held */
-static int audio_enable(struct audio *audio)
-{
-	int rc;
-	struct snd_voice_pcm_interface_ipclnt_reg_args arg;
-	struct snd_voice_pcm_interface_ipclnt_reg_status result;
-
-	/* voice_pcm_interface_type */
-	arg.interface = VOICE_PCM_INTERFACE_TX_INPUT;
-	/* Should be non-zero, unique */
-	arg.callback_id = START_CALLBACK_ID;
-	/* Start Voice PCM interface */
-	rc = msm_rpc_client_req(audio->client,
-				SND_VOC_REGISTER_PCM_INPUT_CLIENT_PROC,
-				snd_voice_pcm_interface_ipclnt_reg_args, &arg,
-				snd_voice_pcm_interface_ipclnt_reg_status,
-				&result, -1);
-	MM_DBG("input client registration status rc 0x%8x result 0x%8x\n",
-		rc, result.status);
-	/* If error in server side */
-	if (rc == 0)
-		if (result.status != SUCCESS)
-			rc = -ENODEV;
-	return rc;
-}
-static int audio_disable(struct audio *audio)
-{
-	int rc;
-	struct snd_voice_pcm_interface_ipclnt_reg_args arg;
-	struct snd_voice_pcm_interface_ipclnt_reg_status result;
-
-	/* Wait till all buffers consumed to prevent data loss
-	   Also ensure if client stops due to vocoder disable
-	   do not loop forever */
-	rc = wait_event_interruptible_timeout(audio->stop_wait,
-		!(audio->running) || (audio->buffer_finished == 1),
-		msecs_to_jiffies(MAX_WAIT_CONSUME));
-	if (rc < 0)
-		return 0;
-	/* voice_pcm_interface_type */
-	arg.interface = VOICE_PCM_INTERFACE_TX_INPUT;
-	arg.callback_id = STOP_CALLBACK_ID; /* Should be zero */
-	/* Stop Voice PCM interface */
-	rc = msm_rpc_client_req(audio->client,
-				SND_VOC_REGISTER_PCM_INPUT_CLIENT_PROC,
-				snd_voice_pcm_interface_ipclnt_reg_args, &arg,
-				snd_voice_pcm_interface_ipclnt_reg_status,
-				&result, -1);
-	MM_DBG("input client de-registration status rc 0x%8x result 0x%8x\n",
-		rc, result.status);
-	/* If error in server side */
-	if (rc == 0)
-		if (result.status != SUCCESS)
-			rc = -ENODEV;
-	return rc;
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = -EINVAL;
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		stats.byte_count = atomic_read(&audio->out_bytes);
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		rc = audio_enable(audio);
-		if (rc == 0)
-			audio->enabled = 1;
-		break;
-	case AUDIO_STOP:
-		if (audio->enabled) {
-			audio->stopped = 1;
-			rc = audio_disable(audio);
-			if (rc == 0) {
-				audio->enabled = 0;
-				audio->running = 0;
-				wake_up(&audio->wait);
-			} else
-				audio->stopped = 0;
-		}
-		break;
-	case AUDIO_SET_CONFIG: {
-		struct msm_audio_config config;
-		if (copy_from_user(&config, (void *) arg, sizeof(config))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (config.type == 0) {
-			/* Selection for different PCM intect point */
-		} else {
-			rc = -EINVAL;
-			break;
-		}
-		rc = 0;
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config config;
-		config.buffer_size = MAX_VOC_FRAME_SIZE * 2;
-		config.buffer_count = MAX_VOC_FRAMES;
-		config.sample_rate = 8000;
-		config.channel_count = 1;
-		config.type = 0;
-		config.unused[0] = 0;
-		config.unused[1] = 0;
-		config.unused[2] = 0;
-		if (copy_to_user((void *) arg, &config, sizeof(config)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-	default: {
-		rc = -EINVAL;
-		MM_ERR(" Unsupported ioctl 0x%8x\n", cmd);
-	}
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-static ssize_t audio_read(struct file *file, char __user *buf,
-		size_t count, loff_t *pos)
-{
-	return -EINVAL;
-}
-
-static ssize_t audio_write(struct file *file, const char __user *buf,
-		size_t count, loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	size_t xfer;
-	int rc = 0;
-
-	mutex_lock(&audio->write_lock);
-	/* Ensure to copy only till frame boundary */
-	while (count >= (MAX_VOC_FRAME_SIZE*2)) {
-		frame = audio->out + audio->out_head;
-		rc = wait_event_interruptible_timeout(audio->wait,\
-				(frame->used == 0) || (audio->stopped),
-				msecs_to_jiffies(MAX_WAIT_CONSUME));
-
-		if (rc < 0)
-			break;
-		if (audio->stopped) {
-			rc = -EBUSY;
-			break;
-		}
-		if (rc == 0) {
-			rc = -ETIMEDOUT;
-			break;
-		}
-
-		xfer = count > frame->size ? frame->size : count;
-		if (copy_from_user(frame->data, buf, xfer)) {
-			rc = -EFAULT;
-			break;
-		}
-		frame->used = xfer;
-		audio->out_head = ((++audio->out_head) % MAX_VOC_FRAMES);
-		count -= xfer;
-		buf += xfer;
-	}
-	mutex_unlock(&audio->write_lock);
-	MM_DBG("write done 0x%8x\n", (unsigned int)(buf - start));
-	if (rc < 0)
-		return rc;
-	return buf - start;
-}
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = &the_audio;
-	int rc, cnt;
-
-	mutex_lock(&audio->lock);
-
-	if (audio->opened) {
-		MM_ERR("busy as driver already in open state\n");
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (!audio->data) {
-		audio->data = kmalloc(BUFSZ, GFP_KERNEL);
-		if (!audio->data) {
-			MM_ERR("could not allocate buffers\n");
-			rc = -ENOMEM;
-			goto done;
-		}
-	}
-
-	audio->client = msm_rpc_register_client("voice_pcm_interface_client",
-				SND_VOC_PCM_INTERFACE_PROG,
-				SND_VOC_PCM_INTERFACE_VERS, 1,
-				pcm_interface_process_callback_routine);
-	if (IS_ERR(audio->client)) {
-		MM_ERR("Failed to register voice pcm interface client"\
-			"to 0x%8x\n", SND_VOC_PCM_INTERFACE_PROG);
-		kfree(audio->data);
-		audio->data = NULL;
-		rc = -ENODEV;
-		goto done;
-	}
-	MM_INFO("voice pcm client registred %p\n", audio->client);
-	for (cnt = 0; cnt < MAX_VOC_FRAMES; cnt++) {
-		audio->out[cnt].data = (audio->data +\
-					((MAX_VOC_FRAME_SIZE * 2) * cnt));
-		audio->out[cnt].size = MAX_VOC_FRAME_SIZE * 2;
-		MM_DBG("data ptr = %p\n", audio->out[cnt].data);
-	}
-	file->private_data = audio;
-	audio_flush(audio);
-	audio->opened = 1;
-	rc = 0;
-done:
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static int audio_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	if (audio->enabled) {
-		audio->stopped = 1;
-		audio_disable(audio);
-		audio->running = 0;
-		audio->enabled = 0;
-		wake_up(&audio->wait);
-	}
-	msm_rpc_unregister_client(audio->client);
-	kfree(audio->data);
-	audio->data = NULL;
-	audio->opened = 0;
-	mutex_unlock(&audio->lock);
-	return 0;
-}
-
-static const struct file_operations audio_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audio_open,
-	.release	= audio_release,
-	.read		= audio_read,
-	.write		= audio_write,
-	.unlocked_ioctl	= audio_ioctl,
-};
-
-static struct miscdevice audio_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "snd_pcm_client",
-	.fops	= &audio_fops,
-};
-
-static int __init audio_init(void)
-{
-	mutex_init(&the_audio.lock);
-	mutex_init(&the_audio.write_lock);
-	init_waitqueue_head(&the_audio.wait);
-	init_waitqueue_head(&the_audio.stop_wait);
-	return misc_register(&audio_misc);
-}
-device_initcall(audio_init);
diff --git a/arch/arm/mach-msm/qdsp5v2/Makefile b/arch/arm/mach-msm/qdsp5v2/Makefile
deleted file mode 100644
index 3ae3c1b..0000000
--- a/arch/arm/mach-msm/qdsp5v2/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
-obj-y += afe.o audio_interct.o mi2s.o audio_dev_ctl.o voice.o
-
-ifeq ($(CONFIG_TIMPANI_CODEC), y)
-obj-y += snddev_icodec.o
-else ifeq ($(CONFIG_MARIMBA_CODEC), y)
-obj-y += snddev_icodec.o
-endif
-
-obj-$(CONFIG_MARIMBA_CODEC) += snddev_data_marimba.o
-obj-$(CONFIG_TIMPANI_CODEC) += snddev_data_timpani.o
-
-obj-y += audio_pcm.o audpp.o audio_mp3.o audio_wma.o audio_aac.o audio_amrnb.o
-obj-y += audio_amrwb.o audio_wmapro.o audio_adpcm.o audio_evrc.o audio_qcelp.o
-obj-y += aux_pcm.o snddev_ecodec.o audio_out.o
-obj-y += audio_lpa.o mp3_funcs.o pcm_funcs.o
-obj-y += audpreproc.o audio_pcm_in.o audio_aac_in.o audio_amrnb_in.o audio_a2dp_in.o
-obj-y += audio_evrc_in.o audio_qcelp_in.o
-obj-y += adsp.o adsp_driver.o adsp_info.o
-obj-y += audio_acdb.o snddev_virtual.o
-obj-y += audio_fm.o
-obj-y += lpa.o snddev_mi2s.o
-obj-y += audio_mvs.o
\ No newline at end of file
diff --git a/arch/arm/mach-msm/qdsp5v2/adsp.c b/arch/arm/mach-msm/qdsp5v2/adsp.c
deleted file mode 100644
index 371ef00..0000000
--- a/arch/arm/mach-msm/qdsp5v2/adsp.c
+++ /dev/null
@@ -1,1225 +0,0 @@
-/*
- * Register/Interrupt access for userspace aDSP library.
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (c) 2008-2009,2011-2012 The Linux Foundation. All rights reserved.
- * Author: Iliyan Malchev <ibm@android.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-/* TODO:
- * - move shareable rpc code outside of adsp.c
- * - general solution for virt->phys patchup
- * - queue IDs should be relative to modules
- * - disallow access to non-associated queues
- */
-
-#include <linux/clk.h>
-#include <linux/delay.h>
-#include <linux/interrupt.h>
-#include <linux/kernel.h>
-#include <linux/kthread.h>
-#include <linux/module.h>
-#include <linux/uaccess.h>
-#include <linux/wait.h>
-#include <linux/slab.h>
-#include <linux/io.h>
-#include <mach/msm_iomap.h>
-#include <mach/msm_adsp.h>
-#include "adsp.h"
-#include <mach/debug_mm.h>
-#include <linux/debugfs.h>
-
-#ifdef CONFIG_DEBUG_FS
-static struct dentry *dentry_adsp;
-static struct dentry *dentry_wdata;
-static struct dentry *dentry_rdata;
-static int wdump, rdump;
-#endif /* CONFIG_DEBUG_FS */
-
-static struct adsp_info adsp_info;
-static struct msm_adsp_module *adsp_modules;
-static int adsp_open_count;
-
-static DEFINE_MUTEX(adsp_open_lock);
-
-/* protect interactions with the ADSP command/message queue */
-static spinlock_t adsp_cmd_lock;
-static spinlock_t adsp_write_lock;
-
-static uint32_t current_image = -1;
-
-void adsp_set_image(struct adsp_info *info, uint32_t image)
-{
-	current_image = image;
-}
-
-/*
- * Checks whether the module_id is available in the
- * module_entries table.If module_id is available returns `0`.
- * If module_id is not available returns `-ENXIO`.
- */
-static int32_t adsp_validate_module(uint32_t module_id)
-{
-	uint32_t	*ptr;
-	uint32_t	module_index;
-	uint32_t	num_mod_entries;
-
-	ptr = adsp_info.init_info_ptr->module_entries;
-	num_mod_entries = adsp_info.init_info_ptr->module_table_size;
-
-	for (module_index = 0; module_index < num_mod_entries; module_index++)
-		if (module_id == ptr[module_index])
-			return 0;
-
-	return -ENXIO;
-}
-
-static int32_t adsp_validate_queue(uint32_t mod_id, unsigned q_idx,
-							uint32_t size)
-{
-	int32_t i;
-	struct adsp_rtos_mp_mtoa_init_info_type	*sptr;
-
-	sptr = adsp_info.init_info_ptr;
-	for (i = 0; i < sptr->mod_to_q_entries; i++)
-		if (mod_id == sptr->mod_to_q_tbl[i].module)
-			if (q_idx == sptr->mod_to_q_tbl[i].q_type) {
-				if (size <= sptr->mod_to_q_tbl[i].q_max_len)
-					return 0;
-				MM_ERR("q_idx: %d is not a valid queue \
-					for module %x\n", q_idx, mod_id);
-				return -EINVAL;
-			}
-	MM_ERR("cmd_buf size is more than allowed size\n");
-	return -EINVAL;
-}
-
-uint32_t adsp_get_module(struct adsp_info *info, uint32_t task)
-{
-	return info->task_to_module[current_image][task];
-}
-
-uint32_t adsp_get_queue_offset(struct adsp_info *info, uint32_t queue_id)
-{
-	return info->queue_offset[current_image][queue_id];
-}
-
-static int rpc_adsp_rtos_app_to_modem(uint32_t cmd, uint32_t module,
-				      struct msm_adsp_module *adsp_module)
-{
-	struct adsp_rtos_atom_cmd adspsvc_cmd;
-	int err;
-
-	adspsvc_cmd.cmd = cmd;
-	adspsvc_cmd.proc_id = RPC_ADSP_RTOS_PROC_APPS;
-	adspsvc_cmd.module = module;
-	adspsvc_cmd.cb_handle = adsp_info.cb_handle;
-
-	err = dalrpc_fcn_5(DALDEVICE_ADSP_CMD_IDX | 0x80000000,
-					adsp_info.handle,
-					&adspsvc_cmd, sizeof(adspsvc_cmd));
-	if (err < 0)
-		MM_ERR("ADSP command send Failed\n");
-
-	return 0;
-}
-
-static int get_module_index(uint32_t id)
-{
-	int mod_idx;
-	for (mod_idx = 0; mod_idx < adsp_info.module_count; mod_idx++)
-		if (adsp_info.module[mod_idx].id == id)
-			return mod_idx;
-
-	return -ENXIO;
-}
-
-static struct msm_adsp_module *find_adsp_module_by_id(
-	struct adsp_info *info, uint32_t id)
-{
-	int mod_idx;
-
-	if (id > info->max_module_id) {
-		return NULL;
-	} else {
-		mod_idx = get_module_index(id);
-		if (mod_idx < 0)
-			return NULL;
-		return info->id_to_module[mod_idx];
-	}
-}
-
-static struct msm_adsp_module *find_adsp_module_by_name(
-	struct adsp_info *info, const char *name)
-{
-	unsigned n;
-	for (n = 0; n < info->module_count; n++)
-		if (!strcmp(name, adsp_modules[n].name))
-			return adsp_modules + n;
-	return NULL;
-}
-
-/*
- * Send RPC_ADSP_RTOS_CMD_GET_INIT_INFO cmd to ARM9 and get
- * queue offsets and module entries (init info) as part of the event.
- */
-static void  msm_get_init_info(void)
-{
-	struct adsp_rtos_atom_cmd cmd;
-	int err;
-
-	cmd.cmd = RPC_ADSP_RTOS_CMD_GET_INIT_INFO;
-	cmd.proc_id = RPC_ADSP_RTOS_PROC_APPS;
-	cmd.module = 0;
-	cmd.cb_handle = adsp_info.cb_handle;
-
-	err = dalrpc_fcn_5(DALDEVICE_ADSP_CMD_IDX | 0x80000000,
-							adsp_info.handle,
-							&cmd, sizeof(cmd));
-	if (err < 0)
-		MM_ERR("INIT_INFO command send Failed\n");
-}
-
-int msm_adsp_get(const char *name, struct msm_adsp_module **out,
-		 struct msm_adsp_ops *ops, void *driver_data)
-{
-	struct msm_adsp_module *module;
-	int rc = 0;
-
-	module = find_adsp_module_by_name(&adsp_info, name);
-	if (!module)
-		return -ENODEV;
-
-	mutex_lock(&module->lock);
-	MM_DBG("opening module %s\n", module->name);
-
-	if (module->ops) {
-		rc = -EBUSY;
-		mutex_unlock(&module->lock);
-		goto done;
-	}
-
-	module->ops = ops;
-	module->driver_data = driver_data;
-	*out = module;
-	mutex_unlock(&module->lock);
-	rc = rpc_adsp_rtos_app_to_modem(RPC_ADSP_RTOS_CMD_REGISTER_APP,
-					module->id, module);
-	if (rc) {
-		mutex_lock(&module->lock);
-		module->ops = NULL;
-		module->driver_data = NULL;
-		*out = NULL;
-		MM_ERR("REGISTER_APP failed\n");
-		mutex_unlock(&module->lock);
-		goto done;
-	}
-
-	MM_INFO("module %s has been registered\n", module->name);
-
-done:
-	return rc;
-}
-EXPORT_SYMBOL(msm_adsp_get);
-
-void msm_adsp_put(struct msm_adsp_module *module)
-{
-	unsigned long flags;
-
-	mutex_lock(&module->lock);
-	if (module->ops) {
-		MM_INFO("closing module %s\n", module->name);
-
-		/* lock to ensure a dsp event cannot be delivered
-		 * during or after removal of the ops and driver_data
-		 */
-		spin_lock_irqsave(&adsp_cmd_lock, flags);
-		module->ops = NULL;
-		module->driver_data = NULL;
-		spin_unlock_irqrestore(&adsp_cmd_lock, flags);
-
-		if (module->state != ADSP_STATE_DISABLED) {
-			MM_INFO("disabling module %s\n", module->name);
-			mutex_unlock(&module->lock);
-			msm_adsp_disable(module);
-			return;
-		}
-	} else {
-		MM_INFO("module %s is already closed\n", module->name);
-	}
-	mutex_unlock(&module->lock);
-}
-EXPORT_SYMBOL(msm_adsp_put);
-
-int __msm_adsp_write(struct msm_adsp_module *module, unsigned dsp_queue_addr,
-		   void *cmd_buf, size_t cmd_size)
-{
-	uint32_t ctrl_word;
-	uint32_t dsp_q_addr;
-	uint32_t dsp_addr;
-	uint32_t cmd_id = 0;
-	int cnt = 0;
-	int ret_status = 0;
-	unsigned long flags;
-	struct adsp_info *info;
-
-	if (!module || !cmd_buf) {
-		MM_ERR("Called with NULL parameters\n");
-		return -EINVAL;
-	}
-	info = module->info;
-	spin_lock_irqsave(&adsp_write_lock, flags);
-
-	if (module->state != ADSP_STATE_ENABLED) {
-		spin_unlock_irqrestore(&adsp_write_lock, flags);
-		MM_ERR("module %s not enabled before write\n", module->name);
-		return -ENODEV;
-	}
-	if (adsp_validate_module(module->id)) {
-		spin_unlock_irqrestore(&adsp_write_lock, flags);
-		MM_ERR("module id validation failed %s  %d\n",
-				module->name, module->id);
-		return -ENXIO;
-	}
-	if (dsp_queue_addr >= QDSP_MAX_NUM_QUEUES) {
-		spin_unlock_irqrestore(&adsp_write_lock, flags);
-		MM_ERR("Invalid Queue Index: %d\n", dsp_queue_addr);
-		return -ENXIO;
-	}
-	if (adsp_validate_queue(module->id, dsp_queue_addr, cmd_size)) {
-		spin_unlock_irqrestore(&adsp_write_lock, flags);
-		return -EINVAL;
-	}
-	dsp_q_addr = adsp_get_queue_offset(info, dsp_queue_addr);
-	dsp_q_addr &= ADSP_RTOS_WRITE_CTRL_WORD_DSP_ADDR_M;
-
-	/* Poll until the ADSP is ready to accept a command.
-	 * Wait for 100us, return error if it's not responding.
-	 * If this returns an error, we need to disable ALL modules and
-	 * then retry.
-	 */
-	while (((ctrl_word = readl(info->write_ctrl)) &
-		ADSP_RTOS_WRITE_CTRL_WORD_READY_M) !=
-		ADSP_RTOS_WRITE_CTRL_WORD_READY_V) {
-		if (cnt > 50) {
-			MM_ERR("timeout waiting for DSP write ready\n");
-			ret_status = -EIO;
-			goto fail;
-		}
-		MM_DBG("waiting for DSP write ready\n");
-		udelay(2);
-		cnt++;
-	}
-
-	/* Set the mutex bits */
-	ctrl_word &= ~(ADSP_RTOS_WRITE_CTRL_WORD_MUTEX_M);
-	ctrl_word |=  ADSP_RTOS_WRITE_CTRL_WORD_MUTEX_NAVAIL_V;
-
-	/* Clear the command bits */
-	ctrl_word &= ~(ADSP_RTOS_WRITE_CTRL_WORD_CMD_M);
-
-	/* Set the queue address bits */
-	ctrl_word &= ~(ADSP_RTOS_WRITE_CTRL_WORD_DSP_ADDR_M);
-	ctrl_word |= dsp_q_addr;
-
-	writel(ctrl_word, info->write_ctrl);
-
-	/* Generate an interrupt to the DSP.  This notifies the DSP that
-	 * we are about to send a command on this particular queue.  The
-	 * DSP will in response change its state.
-	 */
-	writel(1, info->send_irq);
-
-	/* Poll until the adsp responds to the interrupt; this does not
-	 * generate an interrupt from the adsp.  This should happen within
-	 * 5ms.
-	 */
-	cnt = 0;
-	while ((readl(info->write_ctrl) &
-		ADSP_RTOS_WRITE_CTRL_WORD_MUTEX_M) ==
-		ADSP_RTOS_WRITE_CTRL_WORD_MUTEX_NAVAIL_V) {
-		if (cnt > 2500) {
-			MM_ERR("timeout waiting for adsp ack\n");
-			ret_status = -EIO;
-			goto fail;
-		}
-		udelay(2);
-		cnt++;
-	}
-
-	/* Read the ctrl word */
-	ctrl_word = readl(info->write_ctrl);
-
-	if ((ctrl_word & ADSP_RTOS_WRITE_CTRL_WORD_STATUS_M) !=
-	    ADSP_RTOS_WRITE_CTRL_WORD_NO_ERR_V) {
-		ret_status = -EAGAIN;
-		goto fail;
-	} else {
-		/* No error */
-		/* Get the DSP buffer address */
-		dsp_addr = (ctrl_word & ADSP_RTOS_WRITE_CTRL_WORD_DSP_ADDR_M) +
-			   (uint32_t)MSM_AD5_BASE;
-
-		if (dsp_addr < (uint32_t)(MSM_AD5_BASE + QDSP_RAMC_OFFSET)) {
-			uint16_t *buf_ptr = (uint16_t *) cmd_buf;
-			uint16_t *dsp_addr16 = (uint16_t *)dsp_addr;
-			cmd_size /= sizeof(uint16_t);
-
-			/* Save the command ID */
-			cmd_id = (uint32_t) buf_ptr[0];
-
-			/* Copy the command to DSP memory */
-			cmd_size++;
-			while (--cmd_size)
-				*dsp_addr16++ = *buf_ptr++;
-		} else {
-			uint32_t *buf_ptr = (uint32_t *) cmd_buf;
-			uint32_t *dsp_addr32 = (uint32_t *)dsp_addr;
-			cmd_size /= sizeof(uint32_t);
-
-			/* Save the command ID */
-			cmd_id = buf_ptr[0];
-
-			cmd_size++;
-			while (--cmd_size)
-				*dsp_addr32++ = *buf_ptr++;
-		}
-
-		/* Set the mutex bits */
-		ctrl_word &= ~(ADSP_RTOS_WRITE_CTRL_WORD_MUTEX_M);
-		ctrl_word |=  ADSP_RTOS_WRITE_CTRL_WORD_MUTEX_NAVAIL_V;
-
-		/* Set the command bits to write done */
-		ctrl_word &= ~(ADSP_RTOS_WRITE_CTRL_WORD_CMD_M);
-		ctrl_word |= ADSP_RTOS_WRITE_CTRL_WORD_CMD_WRITE_DONE_V;
-
-		/* Set the queue address bits */
-		ctrl_word &= ~(ADSP_RTOS_WRITE_CTRL_WORD_DSP_ADDR_M);
-		ctrl_word |= dsp_q_addr;
-
-		writel(ctrl_word, info->write_ctrl);
-
-		/* Generate an interrupt to the DSP.  It does not respond with
-		 * an interrupt, and we do not need to wait for it to
-		 * acknowledge, because it will hold the mutex lock until it's
-		 * ready to receive more commands again.
-		 */
-		writel(1, info->send_irq);
-
-		module->num_commands++;
-	} /* Ctrl word status bits were 00, no error in the ctrl word */
-
-fail:
-	spin_unlock_irqrestore(&adsp_write_lock, flags);
-	return ret_status;
-}
-EXPORT_SYMBOL(msm_adsp_write);
-
-int msm_adsp_write(struct msm_adsp_module *module, unsigned dsp_queue_addr,
-			void *cmd_buf, size_t cmd_size)
-{
-	int rc, retries = 0;
-#ifdef CONFIG_DEBUG_FS
-	uint16_t *ptr;
-	int ii;
-
-	if (wdump > 0) {
-		ptr = cmd_buf;
-		pr_info("A->D:%x\n", module->id);
-		pr_info("adsp: %x %d\n", dsp_queue_addr, cmd_size);
-		for (ii = 0; ii < cmd_size/2; ii++)
-			pr_info("%x ", ptr[ii]);
-		pr_info("\n");
-	}
-#endif /* CONFIG_DEBUG_FS */
-	do {
-		rc = __msm_adsp_write(module, dsp_queue_addr, cmd_buf,
-								cmd_size);
-		if (rc == -EAGAIN)
-			udelay(50);
-	} while (rc == -EAGAIN && retries++ < 300);
-	if (retries > 20)
-		MM_INFO("%s command took %d attempts: rc %d\n",
-			module->name, retries, rc);
-	return rc;
-}
-
-#ifdef CONFIG_MSM_ADSP_REPORT_EVENTS
-static void *event_addr;
-static void read_event(void *buf, size_t len)
-{
-	uint32_t dptr[3];
-	struct adsp_rtos_mp_mtoa_s_type *sptr;
-	struct adsp_rtos_mp_mtoa_type	*pkt_ptr;
-
-	sptr = event_addr;
-	pkt_ptr = &sptr->adsp_rtos_mp_mtoa_data.mp_mtoa_packet;
-
-	dptr[0] = sptr->mp_mtoa_header.event;
-	dptr[1] = pkt_ptr->module;
-	dptr[2] = pkt_ptr->image;
-
-	if (len > EVENT_LEN)
-		len = EVENT_LEN;
-
-	memcpy(buf, dptr, len);
-}
-#endif
-
-static void adsp_rtos_mtoa_cb(void *context, uint32_t param,
-					void *evt_buf, uint32_t len)
-{
-	struct adsp_rtos_mp_mtoa_s_type *args = NULL;
-	uint32_t event = 0;
-	uint32_t proc_id = 0;
-	uint32_t module_id;
-	uint32_t image;
-	struct msm_adsp_module *module;
-	struct adsp_rtos_mp_mtoa_type	*pkt_ptr;
-	struct queue_to_offset_type	*qptr;
-	struct queue_to_offset_type	*qtbl;
-	struct mod_to_queue_offsets	*mqptr;
-	struct mod_to_queue_offsets	*mqtbl;
-	uint32_t	*mptr;
-	uint32_t	*mtbl;
-	uint32_t	q_idx;
-	uint32_t	num_entries;
-	uint32_t	entries_per_image;
-	struct adsp_rtos_mp_mtoa_init_info_type *iptr;
-	struct adsp_rtos_mp_mtoa_init_info_type	*sptr;
-	int32_t		i_no, e_idx;
-	static uint32_t	init_info_completed;
-	static uint32_t init_info_len =
-				sizeof(struct adsp_rtos_mp_mtoa_header_type);
-	static uint32_t	next_init_info_byte;
-	static uint32_t expected_byte = 1;
-	uint32_t hdr_len = sizeof(struct adsp_rtos_mp_mtoa_header_type);
-
-	if (len) {
-		args = (struct adsp_rtos_mp_mtoa_s_type *) evt_buf;
-		event = args->mp_mtoa_header.event;
-		proc_id = args->mp_mtoa_header.proc_id;
-	}
-
-	if (!init_info_completed && event == RPC_ADSP_RTOS_INIT_INFO) {
-		memcpy(((char *)adsp_info.raw_event) + init_info_len,
-						(char *)evt_buf + hdr_len + 4,
-							len - ((hdr_len + 4)));
-		init_info_len += (len - (hdr_len + 4));
-		evt_buf += hdr_len;
-		next_init_info_byte = *(uint32_t *) evt_buf;
-		expected_byte += len;
-		if (next_init_info_byte &&
-				(expected_byte != next_init_info_byte)) {
-			MM_ERR("INIT_INFO - expecting next byte to be %d\n"
-				"\tbut ADSPSVC indicated next byte to be %d\n",
-				expected_byte, next_init_info_byte);
-			return;
-		}
-		if (!next_init_info_byte) {
-			args = adsp_info.raw_event;
-			args->mp_mtoa_header.event = event;
-			args->mp_mtoa_header.proc_id = proc_id;
-			init_info_completed = 1;
-		} else
-			return;
-	}
-
-	if (event == RPC_ADSP_RTOS_INIT_INFO) {
-		MM_INFO("INIT_INFO Event\n");
-		sptr = &args->adsp_rtos_mp_mtoa_data.mp_mtoa_init_packet;
-
-		iptr = adsp_info.init_info_ptr;
-		iptr->image_count = sptr->image_count;
-		if (iptr->image_count > IMG_MAX)
-			iptr->image_count = IMG_MAX;
-		iptr->num_queue_offsets = sptr->num_queue_offsets;
-		num_entries = iptr->num_queue_offsets;
-		if (num_entries > ENTRIES_MAX) {
-			num_entries = ENTRIES_MAX;
-			iptr->num_queue_offsets = ENTRIES_MAX;
-		}
-		qptr = &sptr->queue_offsets_tbl[0][0];
-		for (i_no = 0; i_no < iptr->image_count; i_no++) {
-			qtbl = &iptr->queue_offsets_tbl[i_no][0];
-			for (e_idx = 0; e_idx < num_entries; e_idx++) {
-				qtbl[e_idx].offset = qptr->offset;
-				qtbl[e_idx].queue = qptr->queue;
-				q_idx = qptr->queue;
-				iptr->queue_offsets[i_no][q_idx] =
-							qtbl[e_idx].offset;
-				qptr++;
-			}
-		}
-
-		num_entries = sptr->num_task_module_entries;
-		if (num_entries > ENTRIES_MAX)
-			num_entries = ENTRIES_MAX;
-		iptr->num_task_module_entries = num_entries;
-		entries_per_image = num_entries / iptr->image_count;
-		mptr = &sptr->task_to_module_tbl[0][0];
-		for (i_no = 0; i_no < iptr->image_count; i_no++) {
-			mtbl = &iptr->task_to_module_tbl[i_no][0];
-			for (e_idx = 0; e_idx < entries_per_image; e_idx++) {
-				mtbl[e_idx] = *mptr;
-				mptr++;
-			}
-		}
-
-		iptr->module_table_size = sptr->module_table_size;
-		if (iptr->module_table_size > MODULES_MAX)
-			iptr->module_table_size = MODULES_MAX;
-		mptr = &sptr->module_entries[0];
-		for (i_no = 0; i_no < iptr->module_table_size; i_no++)
-			iptr->module_entries[i_no] = mptr[i_no];
-
-		mqptr = &sptr->mod_to_q_tbl[0];
-		mqtbl = &iptr->mod_to_q_tbl[0];
-		iptr->mod_to_q_entries = sptr->mod_to_q_entries;
-		if (iptr->mod_to_q_entries > ENTRIES_MAX)
-			iptr->mod_to_q_entries = ENTRIES_MAX;
-		for (e_idx = 0; e_idx < iptr->mod_to_q_entries; e_idx++) {
-			mqtbl[e_idx].module = mqptr->module;
-			mqtbl[e_idx].q_type = mqptr->q_type;
-			mqtbl[e_idx].q_max_len = mqptr->q_max_len;
-			mqptr++;
-		}
-
-		adsp_info.init_info_state = ADSP_STATE_INIT_INFO;
-		kfree(adsp_info.raw_event);
-		wake_up(&adsp_info.init_info_wait);
-		return;
-	}
-	pkt_ptr = &args->adsp_rtos_mp_mtoa_data.mp_mtoa_packet;
-	module_id = pkt_ptr->module;
-	image     = pkt_ptr->image;
-
-	MM_INFO("rpc event=%d, proc_id=%d, module=%d, image=%d\n",
-		event, proc_id, module_id, image);
-
-	module = find_adsp_module_by_id(&adsp_info, module_id);
-	if (!module) {
-		MM_ERR("module %d is not supported!\n", module_id);
-		return;
-	}
-
-	mutex_lock(&module->lock);
-	switch (event) {
-	case RPC_ADSP_RTOS_MOD_READY:
-		MM_INFO("module %s: READY\n", module->name);
-		module->state = ADSP_STATE_ENABLED;
-		wake_up(&module->state_wait);
-		adsp_set_image(module->info, image);
-		break;
-	case RPC_ADSP_RTOS_MOD_DISABLE:
-		MM_INFO("module %s: DISABLED\n", module->name);
-		module->state = ADSP_STATE_DISABLED;
-		wake_up(&module->state_wait);
-		break;
-	case RPC_ADSP_RTOS_SERVICE_RESET:
-		MM_INFO("module %s: SERVICE_RESET\n", module->name);
-		module->state = ADSP_STATE_DISABLED;
-		wake_up(&module->state_wait);
-		break;
-	case RPC_ADSP_RTOS_CMD_SUCCESS:
-		MM_INFO("module %s: CMD_SUCCESS\n", module->name);
-		break;
-	case RPC_ADSP_RTOS_CMD_FAIL:
-		MM_INFO("module %s: CMD_FAIL\n", module->name);
-		break;
-	case RPC_ADSP_RTOS_DISABLE_FAIL:
-		MM_INFO("module %s: DISABLE_FAIL\n", module->name);
-		break;
-	default:
-		MM_ERR("unknown event %d\n", event);
-		mutex_unlock(&module->lock);
-		return;
-	}
-#ifdef CONFIG_MSM_ADSP_REPORT_EVENTS
-	event_addr = (uint32_t *)evt_buf;
-	if (module->ops)
-		module->ops->event(module->driver_data,
-					EVENT_MSG_ID,
-					EVENT_LEN,
-					read_event);
-#endif
-	mutex_unlock(&module->lock);
-}
-
-static size_t read_event_size;
-static void *read_event_addr;
-
-static void read_event_16(void *buf, size_t len)
-{
-	uint16_t *dst = buf;
-	uint16_t *src = read_event_addr;
-	len /= 2;
-	if (len > read_event_size)
-		len = read_event_size;
-	while (len--)
-		*dst++ = *src++;
-}
-
-static void read_event_32(void *buf, size_t len)
-{
-	uint32_t *dst = buf;
-	uint32_t *src = read_event_addr;
-	len /= 2;
-	if (len > read_event_size)
-		len = read_event_size;
-	while (len--)
-		*dst++ = *src++;
-}
-
-static int adsp_rtos_read_ctrl_word_cmd_tast_to_h_v(
-	struct adsp_info *info, void *dsp_addr)
-{
-	struct msm_adsp_module *module;
-	unsigned rtos_task_id;
-	unsigned msg_id;
-	unsigned msg_length;
-#ifdef CONFIG_DEBUG_FS
-	uint16_t *ptr;
-	int ii;
-#endif /* CONFIG_DEBUG_FS */
-	void (*func)(void *, size_t);
-
-	if (dsp_addr >= (void *)(MSM_AD5_BASE + QDSP_RAMC_OFFSET)) {
-		uint32_t *dsp_addr32 = dsp_addr;
-		uint32_t tmp = *dsp_addr32++;
-		rtos_task_id = (tmp & ADSP_RTOS_READ_CTRL_WORD_TASK_ID_M) >> 8;
-		msg_id = (tmp & ADSP_RTOS_READ_CTRL_WORD_MSG_ID_M);
-		read_event_size = tmp >> 16;
-		read_event_addr = dsp_addr32;
-		msg_length = read_event_size * sizeof(uint32_t);
-		func = read_event_32;
-	} else {
-		uint16_t *dsp_addr16 = dsp_addr;
-		uint16_t tmp = *dsp_addr16++;
-		rtos_task_id = (tmp & ADSP_RTOS_READ_CTRL_WORD_TASK_ID_M) >> 8;
-		msg_id = tmp & ADSP_RTOS_READ_CTRL_WORD_MSG_ID_M;
-		read_event_size = *dsp_addr16++;
-		read_event_addr = dsp_addr16;
-		msg_length = read_event_size * sizeof(uint16_t);
-		func = read_event_16;
-	}
-
-	if (rtos_task_id > info->max_task_id) {
-		MM_ERR("bogus task id %d\n", rtos_task_id);
-		return 0;
-	}
-	module = find_adsp_module_by_id(info,
-					adsp_get_module(info, rtos_task_id));
-
-	if (!module) {
-		MM_ERR("no module for task id %d\n", rtos_task_id);
-		return 0;
-	}
-
-	module->num_events++;
-
-	if (!module->ops) {
-		MM_ERR("module %s is not open\n", module->name);
-		return 0;
-	}
-#ifdef CONFIG_DEBUG_FS
-	if (rdump > 0) {
-		ptr = read_event_addr;
-		pr_info("D->A\n");
-		pr_info("m_id = %x id = %x\n", module->id, msg_id);
-		for (ii = 0; ii < msg_length/2; ii++)
-			pr_info("%x ", ptr[ii]);
-		pr_info("\n");
-	}
-#endif /* CONFIG_DEBUG_FS */
-
-	module->ops->event(module->driver_data, msg_id, msg_length, func);
-	return 0;
-}
-
-static int adsp_get_event(struct adsp_info *info)
-{
-	uint32_t ctrl_word;
-	uint32_t ready;
-	void *dsp_addr;
-	uint32_t cmd_type;
-	int cnt;
-	unsigned long flags;
-	int rc = 0;
-
-	spin_lock_irqsave(&adsp_cmd_lock, flags);
-
-	/* Whenever the DSP has a message, it updates this control word
-	 * and generates an interrupt.  When we receive the interrupt, we
-	 * read this register to find out what ADSP task the command is
-	 * comming from.
-	 *
-	 * The ADSP should *always* be ready on the first call, but the
-	 * irq handler calls us in a loop (to handle back-to-back command
-	 * processing), so we give the DSP some time to return to the
-	 * ready state.  The DSP will not issue another IRQ for events
-	 * pending between the first IRQ and the event queue being drained,
-	 * unfortunately.
-	 */
-
-	for (cnt = 0; cnt < 50; cnt++) {
-		ctrl_word = readl(info->read_ctrl);
-
-		if ((ctrl_word & ADSP_RTOS_READ_CTRL_WORD_FLAG_M) ==
-		    ADSP_RTOS_READ_CTRL_WORD_FLAG_UP_CONT_V)
-			goto ready;
-
-		udelay(2);
-	}
-	MM_ERR("not ready after 100uS\n");
-	rc = -EBUSY;
-	goto done;
-
-ready:
-	/* Here we check to see if there are pending messages. If there are
-	 * none, we siply return -EAGAIN to indicate that there are no more
-	 * messages pending.
-	 */
-	ready = ctrl_word & ADSP_RTOS_READ_CTRL_WORD_READY_M;
-	if ((ready != ADSP_RTOS_READ_CTRL_WORD_READY_V) &&
-	    (ready != ADSP_RTOS_READ_CTRL_WORD_CONT_V)) {
-		rc = -EAGAIN;
-		goto done;
-	}
-
-	/* DSP says that there are messages waiting for the host to read */
-
-	/* Get the Command Type */
-	cmd_type = ctrl_word & ADSP_RTOS_READ_CTRL_WORD_CMD_TYPE_M;
-
-	/* Get the DSP buffer address */
-	dsp_addr = (void *)((ctrl_word &
-			     ADSP_RTOS_READ_CTRL_WORD_DSP_ADDR_M) +
-			    (uint32_t)MSM_AD5_BASE);
-
-	/* We can only handle Task-to-Host messages */
-	if (cmd_type != ADSP_RTOS_READ_CTRL_WORD_CMD_TASK_TO_H_V) {
-		MM_ERR("unknown dsp cmd_type %d\n", cmd_type);
-		rc = -EIO;
-		goto done;
-	}
-
-	adsp_rtos_read_ctrl_word_cmd_tast_to_h_v(info, dsp_addr);
-
-	ctrl_word = readl(info->read_ctrl);
-	ctrl_word &= ~ADSP_RTOS_READ_CTRL_WORD_READY_M;
-
-	/* Write ctrl word to the DSP */
-	writel(ctrl_word, info->read_ctrl);
-
-	/* Generate an interrupt to the DSP */
-	writel(1, info->send_irq);
-
-done:
-	spin_unlock_irqrestore(&adsp_cmd_lock, flags);
-	return rc;
-}
-
-static irqreturn_t adsp_irq_handler(int irq, void *data)
-{
-	struct adsp_info *info = &adsp_info;
-	int cnt = 0;
-	for (cnt = 0; cnt < 15; cnt++)
-		if (adsp_get_event(info) < 0)
-			break;
-	if (cnt > info->event_backlog_max)
-		info->event_backlog_max = cnt;
-	info->events_received += cnt;
-	if (cnt == 15)
-		MM_ERR("too many (%d) events for single irq!\n", cnt);
-	return IRQ_HANDLED;
-}
-
-int adsp_set_clkrate(struct msm_adsp_module *module, unsigned long clk_rate)
-{
-	if (module->clk && clk_rate)
-		return clk_set_rate(module->clk, clk_rate);
-
-	return -EINVAL;
-}
-
-int msm_adsp_enable(struct msm_adsp_module *module)
-{
-	int rc = 0;
-
-	MM_INFO("enable '%s'state[%d] id[%d]\n",
-				module->name, module->state, module->id);
-
-	mutex_lock(&module->lock);
-	switch (module->state) {
-	case ADSP_STATE_DISABLED:
-		module->state = ADSP_STATE_ENABLING;
-		mutex_unlock(&module->lock);
-		rc = rpc_adsp_rtos_app_to_modem(RPC_ADSP_RTOS_CMD_ENABLE,
-						module->id, module);
-		if (rc) {
-			mutex_lock(&module->lock);
-			module->state = ADSP_STATE_DISABLED;
-			break;
-		}
-		rc = wait_event_timeout(module->state_wait,
-					module->state != ADSP_STATE_ENABLING,
-					1 * HZ);
-		mutex_lock(&module->lock);
-		if (module->state == ADSP_STATE_ENABLED) {
-			rc = 0;
-		} else {
-			MM_ERR("module '%s' enable timed out\n", module->name);
-			rc = -ETIMEDOUT;
-		}
-		if (module->open_count++ == 0 && module->clk)
-			clk_prepare_enable(module->clk);
-
-		mutex_lock(&adsp_open_lock);
-		if (adsp_open_count++ == 0)
-			enable_irq(adsp_info.int_adsp);
-		mutex_unlock(&adsp_open_lock);
-		break;
-	case ADSP_STATE_ENABLING:
-		MM_DBG("module '%s' enable in progress\n", module->name);
-		break;
-	case ADSP_STATE_ENABLED:
-		MM_DBG("module '%s' already enabled\n", module->name);
-		break;
-	case ADSP_STATE_DISABLING:
-		MM_ERR("module '%s' disable in progress\n", module->name);
-		rc = -EBUSY;
-		break;
-	}
-	mutex_unlock(&module->lock);
-	return rc;
-}
-EXPORT_SYMBOL(msm_adsp_enable);
-
-int msm_adsp_disable_event_rsp(struct msm_adsp_module *module)
-{
-	int rc = 0;
-
-	mutex_lock(&module->lock);
-
-	rc = rpc_adsp_rtos_app_to_modem(RPC_ADSP_RTOS_CMD_DISABLE_EVENT_RSP,
-							module->id, module);
-	mutex_unlock(&module->lock);
-
-	return rc;
-}
-EXPORT_SYMBOL(msm_adsp_disable_event_rsp);
-
-int msm_adsp_disable(struct msm_adsp_module *module)
-{
-	int rc = 0;
-
-	mutex_lock(&module->lock);
-	switch (module->state) {
-	case ADSP_STATE_DISABLED:
-		MM_DBG("module '%s' already disabled\n", module->name);
-		mutex_unlock(&module->lock);
-		break;
-	case ADSP_STATE_ENABLING:
-	case ADSP_STATE_ENABLED:
-		mutex_unlock(&module->lock);
-		rc = rpc_adsp_rtos_app_to_modem(RPC_ADSP_RTOS_CMD_DISABLE,
-						module->id, module);
-		mutex_lock(&module->lock);
-		module->state = ADSP_STATE_DISABLED;
-		if (--module->open_count == 0 && module->clk)
-			clk_disable_unprepare(module->clk);
-		mutex_unlock(&module->lock);
-		mutex_lock(&adsp_open_lock);
-		if (--adsp_open_count == 0) {
-			disable_irq(adsp_info.int_adsp);
-			MM_INFO("disable interrupt\n");
-		}
-		mutex_unlock(&adsp_open_lock);
-		break;
-	}
-	return rc;
-}
-EXPORT_SYMBOL(msm_adsp_disable);
-
-static int msm_adsp_probe(struct platform_device *pdev)
-{
-	unsigned count;
-	int rc, i;
-
-	adsp_info.int_adsp = platform_get_irq(pdev, 0);
-	if (adsp_info.int_adsp < 0) {
-		MM_ERR("no irq resource?\n");
-		return -ENODEV;
-	}
-
-	adsp_info.init_info_ptr = kzalloc(
-		(sizeof(struct adsp_rtos_mp_mtoa_init_info_type)), GFP_KERNEL);
-	if (!adsp_info.init_info_ptr)
-		return -ENOMEM;
-
-	adsp_info.raw_event = kzalloc(
-		(sizeof(struct adsp_rtos_mp_mtoa_s_type)), GFP_KERNEL);
-	if (!adsp_info.raw_event) {
-		kfree(adsp_info.init_info_ptr);
-		return -ENOMEM;
-	}
-
-	rc = adsp_init_info(&adsp_info);
-	if (rc) {
-		kfree(adsp_info.init_info_ptr);
-		kfree(adsp_info.raw_event);
-		return rc;
-	}
-	adsp_info.send_irq += (uint32_t) MSM_AD5_BASE;
-	adsp_info.read_ctrl += (uint32_t) MSM_AD5_BASE;
-	adsp_info.write_ctrl += (uint32_t) MSM_AD5_BASE;
-	count = adsp_info.module_count;
-
-	adsp_modules = kzalloc(
-		(sizeof(struct msm_adsp_module) + sizeof(void *)) *
-		count, GFP_KERNEL);
-	if (!adsp_modules) {
-		kfree(adsp_info.init_info_ptr);
-		kfree(adsp_info.raw_event);
-		return -ENOMEM;
-	}
-
-	adsp_info.id_to_module = (void *) (adsp_modules + count);
-
-	spin_lock_init(&adsp_cmd_lock);
-	spin_lock_init(&adsp_write_lock);
-
-	rc = request_irq(adsp_info.int_adsp, adsp_irq_handler,
-			IRQF_TRIGGER_RISING, "adsp", 0);
-	if (rc < 0)
-		goto fail_request_irq;
-	disable_irq(adsp_info.int_adsp);
-
-	for (i = 0; i < count; i++) {
-		struct msm_adsp_module *mod = adsp_modules + i;
-		mutex_init(&mod->lock);
-		init_waitqueue_head(&mod->state_wait);
-		mod->info = &adsp_info;
-		mod->name = adsp_info.module[i].name;
-		mod->id = adsp_info.module[i].id;
-		if (adsp_info.module[i].clk_name)
-			mod->clk = clk_get(NULL, adsp_info.module[i].clk_name);
-		else
-			mod->clk = NULL;
-		if (mod->clk && adsp_info.module[i].clk_rate)
-			clk_set_rate(mod->clk, adsp_info.module[i].clk_rate);
-		mod->verify_cmd = adsp_info.module[i].verify_cmd;
-		mod->patch_event = adsp_info.module[i].patch_event;
-		INIT_HLIST_HEAD(&mod->pmem_regions);
-		mod->pdev.name = adsp_info.module[i].pdev_name;
-		mod->pdev.id = -1;
-		adsp_info.id_to_module[i] = mod;
-		platform_device_register(&mod->pdev);
-	}
-
-	msm_adsp_publish_cdevs(adsp_modules, count);
-
-	rc = daldevice_attach(DALRPC_ADSPSVC_DEVICEID, DALRPC_ADSPSVC_PORT,
-					DALRPC_ADSPSVC_DEST, &adsp_info.handle);
-	if (rc) {
-		MM_ERR("adsp attach failed : %d\n", rc);
-		goto fail_dal_attach;
-	}
-
-	adsp_info.cb_handle = dalrpc_alloc_cb(adsp_info.handle,
-						adsp_rtos_mtoa_cb, NULL);
-	if (adsp_info.cb_handle == NULL) {
-		MM_ERR("Callback registration failed\n");
-		goto fail_allocate_cb;
-	}
-
-	/* Get INIT_INFO */
-	init_waitqueue_head(&adsp_info.init_info_wait);
-	msm_get_init_info();
-	rc = wait_event_timeout(adsp_info.init_info_wait,
-		adsp_info.init_info_state == ADSP_STATE_INIT_INFO,
-		10 * HZ);
-	if (!rc) {
-		MM_ERR("INIT_INFO failed\n");
-		rc = -ETIMEDOUT;
-	} else
-		return 0;
-
-fail_allocate_cb:
-	daldevice_detach(adsp_info.handle);
-	adsp_info.handle = NULL;
-fail_dal_attach:
-	enable_irq(adsp_info.int_adsp);
-	free_irq(adsp_info.int_adsp, 0);
-fail_request_irq:
-	kfree(adsp_modules);
-	kfree(adsp_info.init_info_ptr);
-	kfree(adsp_info.raw_event);
-	return rc;
-}
-
-#ifdef CONFIG_DEBUG_FS
-static int get_parameters(char *buf, long int *param1, int num_of_par)
-{
-	char *token;
-	int base, cnt;
-
-	token = strsep(&buf, " ");
-
-	for (cnt = 0; cnt < num_of_par; cnt++) {
-		if (token != NULL) {
-			if ((token[1] == 'x') || (token[1] == 'X'))
-				base = 16;
-			else
-				base = 10;
-
-			if (strict_strtoul(token, base, &param1[cnt]) != 0)
-				return -EINVAL;
-
-			token = strsep(&buf, " ");
-			}
-		else
-			return -EINVAL;
-	}
-	return 0;
-}
-
-static ssize_t adsp_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	pr_debug("adsp debugfs opened\n");
-	return 0;
-}
-static ssize_t adsp_debug_write(struct file *file, const char __user *buf,
-				size_t cnt, loff_t *ppos)
-{
-	char *access_str = file->private_data;
-	char lbuf[32];
-	int rc;
-	long int param[5];
-
-	if (cnt > sizeof(lbuf) - 1)
-		return -EINVAL;
-	rc = copy_from_user(lbuf, buf, cnt);
-	if (rc) {
-		pr_info("Unable to copy data from user space\n");
-		return -EFAULT;
-	}
-	lbuf[cnt] = '\0';
-
-	if (!strncmp(access_str, "write_log", 9)) {
-		if (get_parameters(lbuf, param, 1) == 0) {
-			switch (param[0]) {
-			case 1:
-				if (wdump <= 0)
-					wdump = 1;
-				pr_debug("write cmd to DSP(A->D) dump \
-					 started:%d\n", wdump);
-				break;
-			case 0:
-				if (wdump > 0)
-					wdump = 0;
-				pr_debug("Stop write cmd to \
-					 DSP(A->D):%d\n", wdump);
-				break;
-			default:
-				rc = -EINVAL;
-				break;
-			}
-		} else
-			rc = -EINVAL;
-	} else if (!strncmp(access_str, "read_log", 8)) {
-		if (get_parameters(lbuf, param, 1) == 0) {
-			switch (param[0]) {
-			case 1:
-				if (rdump <= 0)
-					rdump = 1;
-				pr_debug("write cmd from DSP(D->A) dump \
-					started:%d\n", wdump);
-				break;
-			case 0:
-				if (rdump > 0)
-					rdump = 0;
-				pr_debug("Stop write cmd from \
-					DSP(D->A):%d\n", wdump);
-				break;
-			default:
-				rc = -EINVAL;
-				break;
-			}
-		} else
-			rc = -EINVAL;
-	} else {
-		rc = -EINVAL;
-	}
-	if (rc == 0)
-		rc = cnt;
-	else {
-		pr_err("%s: rc = %d\n", __func__, rc);
-		pr_info("\nWrong command: Use =>\n");
-		pr_info("-------------------------\n");
-		pr_info("To Start A->D:: echo \"1\">/sys/kernel/debug/ \
-			adsp_cmd/write_log\n");
-		pr_info("To Start D->A:: echo \"1\">/sys/kernel/debug/ \
-			adsp_cmd/read_log\n");
-		pr_info("To Stop  A->D:: echo \"0\">/sys/kernel/debug/ \
-			adsp_cmd/write_log\n");
-		pr_info("To Stop  D->A:: echo \"0\">/sys/kernel/debug/ \
-			adsp_cmd/read_log\n");
-		pr_info("------------------------\n");
-	}
-
-	return rc;
-}
-#endif
-
-static struct platform_driver msm_adsp_driver = {
-	.probe = msm_adsp_probe,
-	.driver = {
-		.owner = THIS_MODULE,
-	},
-};
-
-static char msm_adsp_driver_name[] = "msm_adsp";
-
-#ifdef CONFIG_DEBUG_FS
-static const struct file_operations adsp_debug_fops = {
-	.write = adsp_debug_write,
-	.open = adsp_debug_open,
-};
-#endif
-
-static int __init adsp_init(void)
-{
-	int rc;
-
-#ifdef CONFIG_DEBUG_FS
-	dentry_adsp    = debugfs_create_dir("adsp_cmd", 0);
-	if (!IS_ERR(dentry_adsp)) {
-		dentry_wdata   = debugfs_create_file("write_log", \
-		 S_IFREG | S_IRUGO, dentry_adsp,
-		 (void *) "write_log" , &adsp_debug_fops);
-		dentry_rdata   = debugfs_create_file("read_log", \
-		 S_IFREG | S_IRUGO, dentry_adsp,
-		 (void *) "read_log", &adsp_debug_fops);
-	}
-#endif /* CONFIG_DEBUG_FS */
-
-	msm_adsp_driver.driver.name = msm_adsp_driver_name;
-	rc = platform_driver_register(&msm_adsp_driver);
-	MM_INFO("%s -- %d\n", msm_adsp_driver_name, rc);
-	return rc;
-}
-
-device_initcall(adsp_init);
diff --git a/arch/arm/mach-msm/qdsp5v2/adsp.h b/arch/arm/mach-msm/qdsp5v2/adsp.h
deleted file mode 100644
index b5a574b..0000000
--- a/arch/arm/mach-msm/qdsp5v2/adsp.h
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * Copyright (C) 2008 Google, Inc.
- * Copyright (c) 2008-2009, The Linux Foundation. All rights reserved.
- * Author: Iliyan Malchev <ibm@android.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#ifndef _ARCH_ARM_MACH_MSM_ADSP_H
-#define _ARCH_ARM_MACH_MSM_ADSP_H
-
-#include <linux/types.h>
-#include <linux/msm_adsp.h>
-#include <linux/platform_device.h>
-#include <mach/msm_adsp.h>
-#include <mach/dal.h>
-
-int adsp_pmem_fixup(struct msm_adsp_module *module, void **addr,
-		    unsigned long len);
-int adsp_pmem_fixup_kvaddr(struct msm_adsp_module *module, void **addr,
-			   unsigned long *kvaddr, unsigned long len);
-int adsp_pmem_paddr_fixup(struct msm_adsp_module *module, void **addr);
-
-int adsp_vfe_verify_cmd(struct msm_adsp_module *module,
-			unsigned int queue_id, void *cmd_data,
-			size_t cmd_size);
-int adsp_jpeg_verify_cmd(struct msm_adsp_module *module,
-			 unsigned int queue_id, void *cmd_data,
-			 size_t cmd_size);
-int adsp_lpm_verify_cmd(struct msm_adsp_module *module,
-			unsigned int queue_id, void *cmd_data,
-			size_t cmd_size);
-int adsp_video_verify_cmd(struct msm_adsp_module *module,
-			  unsigned int queue_id, void *cmd_data,
-			  size_t cmd_size);
-int adsp_videoenc_verify_cmd(struct msm_adsp_module *module,
-			  unsigned int queue_id, void *cmd_data,
-			  size_t cmd_size);
-
-
-struct adsp_event;
-
-int adsp_vfe_patch_event(struct msm_adsp_module *module,
-			struct adsp_event *event);
-
-int adsp_jpeg_patch_event(struct msm_adsp_module *module,
-			struct adsp_event *event);
-
-
-struct adsp_module_info {
-	const char *name;
-	const char *pdev_name;
-	uint32_t id;
-	const char *clk_name;
-	unsigned long clk_rate;
-	int (*verify_cmd) (struct msm_adsp_module*, unsigned int, void *,
-			   size_t);
-	int (*patch_event) (struct msm_adsp_module*, struct adsp_event *);
-};
-
-#define ADSP_EVENT_MAX_SIZE 496
-#define EVENT_LEN       12
-#define EVENT_MSG_ID ((uint16_t)~0)
-
-struct adsp_event {
-	struct list_head list;
-	uint32_t size; /* always in bytes */
-	uint16_t msg_id;
-	uint16_t type; /* 0 for msgs (from aDSP), -1 for events (from ARM9) */
-	int is16; /* always 0 (msg is 32-bit) when the event type is 1(ARM9) */
-	union {
-		uint16_t msg16[ADSP_EVENT_MAX_SIZE / 2];
-		uint32_t msg32[ADSP_EVENT_MAX_SIZE / 4];
-	} data;
-};
-
-#define DALRPC_ADSPSVC_DEVICEID 0x0200009A
-#define DALRPC_ADSPSVC_DEST SMD_APPS_MODEM
-#define DALRPC_ADSPSVC_PORT "DAL00"
-
-enum {
-	DALDEVICE_ADSP_CMD_IDX = DALDEVICE_FIRST_DEVICE_API_IDX,
-};
-
-struct adsp_rtos_atom_cmd {
-	uint32_t cmd;
-	uint32_t proc_id;
-	uint32_t module;
-	void *cb_handle;
-};
-
-enum rpc_adsp_rtos_proc_type {
-	RPC_ADSP_RTOS_PROC_NONE = 0,
-	RPC_ADSP_RTOS_PROC_MODEM = 1,
-	RPC_ADSP_RTOS_PROC_APPS = 2,
-};
-
-enum {
-	RPC_ADSP_RTOS_CMD_REGISTER_APP,
-	RPC_ADSP_RTOS_CMD_ENABLE,
-	RPC_ADSP_RTOS_CMD_DISABLE,
-	RPC_ADSP_RTOS_CMD_KERNEL_COMMAND,
-	RPC_ADSP_RTOS_CMD_16_COMMAND,
-	RPC_ADSP_RTOS_CMD_32_COMMAND,
-	RPC_ADSP_RTOS_CMD_DISABLE_EVENT_RSP,
-	RPC_ADSP_RTOS_CMD_REMOTE_EVENT,
-	RPC_ADSP_RTOS_CMD_SET_STATE,
-	RPC_ADSP_RTOS_CMD_REMOTE_INIT_INFO_EVENT,
-	RPC_ADSP_RTOS_CMD_GET_INIT_INFO,
-};
-
-enum rpc_adsp_rtos_mod_status_type {
-	RPC_ADSP_RTOS_MOD_READY,
-	RPC_ADSP_RTOS_MOD_DISABLE,
-	RPC_ADSP_RTOS_SERVICE_RESET,
-	RPC_ADSP_RTOS_CMD_FAIL,
-	RPC_ADSP_RTOS_CMD_SUCCESS,
-	RPC_ADSP_RTOS_INIT_INFO,
-	RPC_ADSP_RTOS_DISABLE_FAIL,
-};
-
-enum qdsp_image_type {
-	QDSP_IMAGE_COMBO,
-	QDSP_IMAGE_GAUDIO,
-	QDSP_IMAGE_QTV_LP,
-	QDSP_IMAGE_MAX,
-	/* DO NOT USE: Force this enum to be a 32bit type to improve speed */
-	QDSP_IMAGE_32BIT_DUMMY = 0x10000
-};
-
-struct adsp_rtos_mp_mtoa_header_type {
-	enum rpc_adsp_rtos_mod_status_type  event;
-	uint32_t		            version;
-	enum rpc_adsp_rtos_proc_type        proc_id;
-};
-
-/* ADSP RTOS MP Communications - Modem to APP's  Event Info*/
-struct adsp_rtos_mp_mtoa_type {
-	uint32_t	module;
-	uint32_t	image;
-	uint32_t	apps_okts;
-};
-
-/* ADSP RTOS MP Communications - Modem to APP's Init Info  */
-#define IMG_MAX         2
-#define ENTRIES_MAX     36
-#define MODULES_MAX     64
-#define QUEUES_MAX	64
-
-struct queue_to_offset_type {
-	uint32_t	queue;
-	uint32_t	offset;
-};
-
-struct mod_to_queue_offsets {
-	uint32_t        module;
-	uint32_t        q_type;
-	uint32_t        q_max_len;
-};
-
-struct adsp_rtos_mp_mtoa_init_info_type {
-	uint32_t	image_count;
-	uint32_t	num_queue_offsets;
-	struct queue_to_offset_type	queue_offsets_tbl[IMG_MAX][ENTRIES_MAX];
-	uint32_t	num_task_module_entries;
-	uint32_t	task_to_module_tbl[IMG_MAX][ENTRIES_MAX];
-
-	uint32_t	module_table_size;
-	uint32_t	module_entries[MODULES_MAX];
-	uint32_t	mod_to_q_entries;
-	struct mod_to_queue_offsets	mod_to_q_tbl[ENTRIES_MAX];
-	/*
-	 * queue_offsets[] is to store only queue_offsets
-	 */
-	uint32_t	queue_offsets[IMG_MAX][QUEUES_MAX];
-};
-
-struct adsp_rtos_mp_mtoa_s_type {
-	struct adsp_rtos_mp_mtoa_header_type mp_mtoa_header;
-
-	union {
-		struct adsp_rtos_mp_mtoa_init_info_type mp_mtoa_init_packet;
-		struct adsp_rtos_mp_mtoa_type mp_mtoa_packet;
-	} adsp_rtos_mp_mtoa_data;
-};
-
-struct adsp_info {
-	uint32_t send_irq;
-	uint32_t read_ctrl;
-	uint32_t write_ctrl;
-
-	uint32_t max_msg16_size;
-	uint32_t max_msg32_size;
-
-	uint32_t max_task_id;
-	uint32_t max_module_id;
-	uint32_t max_queue_id;
-	uint32_t max_image_id;
-
-	/* for each image id, a map of queue id to offset */
-	uint32_t **queue_offset;
-
-	/* for each image id, a map of task id to module id */
-	uint32_t **task_to_module;
-
-	/* for each module id, map of module id to module */
-	struct msm_adsp_module **id_to_module;
-
-	uint32_t module_count;
-	struct adsp_module_info *module;
-
-	/* stats */
-	uint32_t events_received;
-	uint32_t event_backlog_max;
-
-	/* rpc_client for init_info */
-	struct adsp_rtos_mp_mtoa_init_info_type	*init_info_ptr;
-	struct adsp_rtos_mp_mtoa_s_type *raw_event;
-	wait_queue_head_t	init_info_wait;
-	unsigned 		init_info_state;
-
-	void *handle;
-	void *cb_handle;
-
-	/* Interrupt value */
-	int int_adsp;
-};
-
-#define ADSP_STATE_DISABLED   0
-#define ADSP_STATE_ENABLING   1
-#define ADSP_STATE_ENABLED    2
-#define ADSP_STATE_DISABLING  3
-#define ADSP_STATE_INIT_INFO  4
-
-struct msm_adsp_module {
-	struct mutex lock;
-	const char *name;
-	unsigned id;
-	struct adsp_info *info;
-
-	struct msm_adsp_ops *ops;
-	void *driver_data;
-
-	/* statistics */
-	unsigned num_commands;
-	unsigned num_events;
-
-	wait_queue_head_t state_wait;
-	unsigned state;
-
-	struct platform_device pdev;
-	struct clk *clk;
-	int open_count;
-
-	struct mutex pmem_regions_lock;
-	struct hlist_head pmem_regions;
-	int (*verify_cmd) (struct msm_adsp_module*, unsigned int, void *,
-			   size_t);
-	int (*patch_event) (struct msm_adsp_module*, struct adsp_event *);
-};
-
-extern void msm_adsp_publish_cdevs(struct msm_adsp_module *, unsigned);
-extern int adsp_init_info(struct adsp_info *info);
-
-/* Value to indicate that a queue is not defined for a particular image */
-#define QDSP_RTOS_NO_QUEUE  0xfffffffe
-
-/*
- * Constants used to communicate with the ADSP RTOS
- */
-#define ADSP_RTOS_WRITE_CTRL_WORD_MUTEX_M            0x80000000U
-#define ADSP_RTOS_WRITE_CTRL_WORD_MUTEX_NAVAIL_V     0x80000000U
-#define ADSP_RTOS_WRITE_CTRL_WORD_MUTEX_AVAIL_V      0x00000000U
-
-#define ADSP_RTOS_WRITE_CTRL_WORD_CMD_M              0x70000000U
-#define ADSP_RTOS_WRITE_CTRL_WORD_CMD_WRITE_REQ_V    0x00000000U
-#define ADSP_RTOS_WRITE_CTRL_WORD_CMD_WRITE_DONE_V   0x10000000U
-#define ADSP_RTOS_WRITE_CTRL_WORD_CMD_NO_CMD_V       0x70000000U
-
-#define ADSP_RTOS_WRITE_CTRL_WORD_STATUS_M           0x0E000000U
-#define ADSP_RTOS_WRITE_CTRL_WORD_NO_ERR_V           0x00000000U
-#define ADSP_RTOS_WRITE_CTRL_WORD_NO_FREE_BUF_V      0x02000000U
-
-#define ADSP_RTOS_WRITE_CTRL_WORD_KERNEL_FLG_M       0x01000000U
-#define ADSP_RTOS_WRITE_CTRL_WORD_HTOD_MSG_WRITE_V   0x00000000U
-#define ADSP_RTOS_WRITE_CTRL_WORD_HTOD_CMD_V         0x01000000U
-
-#define ADSP_RTOS_WRITE_CTRL_WORD_DSP_ADDR_M         0x00FFFFFFU
-#define ADSP_RTOS_WRITE_CTRL_WORD_HTOD_CMD_ID_M      0x00FFFFFFU
-
-/* Combination of MUTEX and CMD bits to check if the DSP is busy */
-#define ADSP_RTOS_WRITE_CTRL_WORD_READY_M            0xF0000000U
-#define ADSP_RTOS_WRITE_CTRL_WORD_READY_V            0x70000000U
-
-/* RTOS to Host processor command mask values */
-#define ADSP_RTOS_READ_CTRL_WORD_FLAG_M              0x80000000U
-#define ADSP_RTOS_READ_CTRL_WORD_FLAG_UP_WAIT_V      0x00000000U
-#define ADSP_RTOS_READ_CTRL_WORD_FLAG_UP_CONT_V      0x80000000U
-
-#define ADSP_RTOS_READ_CTRL_WORD_CMD_M               0x60000000U
-#define ADSP_RTOS_READ_CTRL_WORD_READ_DONE_V         0x00000000U
-#define ADSP_RTOS_READ_CTRL_WORD_READ_REQ_V          0x20000000U
-#define ADSP_RTOS_READ_CTRL_WORD_NO_CMD_V            0x60000000U
-
-/* Combination of FLAG and COMMAND bits to check if MSG ready */
-#define ADSP_RTOS_READ_CTRL_WORD_READY_M             0xE0000000U
-#define ADSP_RTOS_READ_CTRL_WORD_READY_V             0xA0000000U
-#define ADSP_RTOS_READ_CTRL_WORD_CONT_V              0xC0000000U
-#define ADSP_RTOS_READ_CTRL_WORD_DONE_V              0xE0000000U
-
-#define ADSP_RTOS_READ_CTRL_WORD_STATUS_M            0x18000000U
-#define ADSP_RTOS_READ_CTRL_WORD_NO_ERR_V            0x00000000U
-
-#define ADSP_RTOS_READ_CTRL_WORD_IN_PROG_M           0x04000000U
-#define ADSP_RTOS_READ_CTRL_WORD_NO_READ_IN_PROG_V   0x00000000U
-#define ADSP_RTOS_READ_CTRL_WORD_READ_IN_PROG_V      0x04000000U
-
-#define ADSP_RTOS_READ_CTRL_WORD_CMD_TYPE_M          0x03000000U
-#define ADSP_RTOS_READ_CTRL_WORD_CMD_TASK_TO_H_V     0x00000000U
-#define ADSP_RTOS_READ_CTRL_WORD_CMD_KRNL_TO_H_V     0x01000000U
-#define ADSP_RTOS_READ_CTRL_WORD_CMD_H_TO_KRNL_CFM_V 0x02000000U
-
-#define ADSP_RTOS_READ_CTRL_WORD_DSP_ADDR_M          0x00FFFFFFU
-
-#define ADSP_RTOS_READ_CTRL_WORD_MSG_ID_M            0x000000FFU
-#define ADSP_RTOS_READ_CTRL_WORD_TASK_ID_M           0x0000FF00U
-
-/* Base address of DSP and DSP hardware registers */
-#define QDSP_RAMC_OFFSET  0x400000
-
-#endif
diff --git a/arch/arm/mach-msm/qdsp5v2/adsp_driver.c b/arch/arm/mach-msm/qdsp5v2/adsp_driver.c
deleted file mode 100644
index ad74ca3..0000000
--- a/arch/arm/mach-msm/qdsp5v2/adsp_driver.c
+++ /dev/null
@@ -1,560 +0,0 @@
-/*
- * Copyright (C) 2008 Google, Inc.
- * Copyright (c) 2009, The Linux Foundation. All rights reserved.
- * Author: Iliyan Malchev <ibm@android.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/cdev.h>
-#include <linux/fs.h>
-#include <linux/list.h>
-#include <linux/platform_device.h>
-#include <linux/sched.h>
-#include <linux/uaccess.h>
-#include <linux/msm_adsp.h>
-#include <linux/export.h>
-#include "adsp.h"
-#include <mach/debug_mm.h>
-#include <linux/slab.h>
-
-struct adsp_pmem_info {
-	int fd;
-	void *vaddr;
-};
-
-struct adsp_pmem_region {
-	struct hlist_node list;
-	void *vaddr;
-	unsigned long paddr;
-	unsigned long kvaddr;
-	unsigned long len;
-	struct file *file;
-};
-
-struct adsp_device {
-	struct msm_adsp_module *module;
-
-	spinlock_t event_queue_lock;
-	wait_queue_head_t event_wait;
-	struct list_head event_queue;
-	int abort;
-
-	const char *name;
-	struct device *device;
-	struct cdev cdev;
-};
-
-static struct adsp_device *inode_to_device(struct inode *inode);
-
-#define __CONTAINS(r, v, l) ({					\
-	typeof(r) __r = r;					\
-	typeof(v) __v = v;					\
-	typeof(v) __e = __v + l;				\
-	int res = __v >= __r->vaddr && 				\
-		__e <= __r->vaddr + __r->len;			\
-	res;							\
-})
-
-#define CONTAINS(r1, r2) ({					\
-	typeof(r2) __r2 = r2;					\
-	__CONTAINS(r1, __r2->vaddr, __r2->len);			\
-})
-
-#define IN_RANGE(r, v) ({					\
-	typeof(r) __r = r;					\
-	typeof(v) __vv = v;					\
-	int res = ((__vv >= __r->vaddr) &&			\
-		(__vv < (__r->vaddr + __r->len)));		\
-	res;							\
-})
-
-#define OVERLAPS(r1, r2) ({					\
-	typeof(r1) __r1 = r1;					\
-	typeof(r2) __r2 = r2;					\
-	typeof(__r2->vaddr) __v = __r2->vaddr;			\
-	typeof(__v) __e = __v + __r2->len - 1;			\
-	int res = (IN_RANGE(__r1, __v) || IN_RANGE(__r1, __e));	\
-	res;							\
-})
-
-static int adsp_pmem_lookup_vaddr(struct msm_adsp_module *module, void **addr,
-		     unsigned long len, struct adsp_pmem_region **region)
-{
-	struct hlist_node *node;
-	void *vaddr = *addr;
-	struct adsp_pmem_region *region_elt;
-
-	int match_count = 0;
-
-	*region = NULL;
-
-	/* returns physical address or zero */
-	hlist_for_each_entry(region_elt, node, &module->pmem_regions, list) {
-		if (vaddr >= region_elt->vaddr &&
-		    vaddr < region_elt->vaddr + region_elt->len &&
-		    vaddr + len <= region_elt->vaddr + region_elt->len) {
-			/* offset since we could pass vaddr inside a registerd
-			 * pmem buffer
-			 */
-
-			match_count++;
-			if (!*region)
-				*region = region_elt;
-		}
-	}
-
-	if (match_count > 1) {
-		MM_ERR("module %s: "
-			"multiple hits for vaddr %p, len %ld\n",
-			module->name, vaddr, len);
-		hlist_for_each_entry(region_elt, node,
-				&module->pmem_regions, list) {
-			if (vaddr >= region_elt->vaddr &&
-			    vaddr < region_elt->vaddr + region_elt->len &&
-			    vaddr + len <= region_elt->vaddr + region_elt->len)
-				MM_ERR("%p, %ld --> %p\n",
-					region_elt->vaddr,
-					region_elt->len,
-					(void *)region_elt->paddr);
-		}
-	}
-
-	return *region ? 0 : -1;
-}
-
-int adsp_pmem_fixup_kvaddr(struct msm_adsp_module *module, void **addr,
-			   unsigned long *kvaddr, unsigned long len)
-{
-	struct adsp_pmem_region *region;
-	void *vaddr = *addr;
-	unsigned long *paddr = (unsigned long *)addr;
-	int ret;
-
-	ret = adsp_pmem_lookup_vaddr(module, addr, len, &region);
-	if (ret) {
-		MM_ERR("not patching %s (paddr & kvaddr),"
-			" lookup (%p, %ld) failed\n",
-			module->name, vaddr, len);
-		return ret;
-	}
-	*paddr = region->paddr + (vaddr - region->vaddr);
-	*kvaddr = region->kvaddr + (vaddr - region->vaddr);
-	return 0;
-}
-
-int adsp_pmem_fixup(struct msm_adsp_module *module, void **addr,
-		    unsigned long len)
-{
-	struct adsp_pmem_region *region;
-	void *vaddr = *addr;
-	unsigned long *paddr = (unsigned long *)addr;
-	int ret;
-
-	ret = adsp_pmem_lookup_vaddr(module, addr, len, &region);
-	if (ret) {
-		MM_ERR("not patching %s, lookup (%p, %ld) failed\n",
-			module->name, vaddr, len);
-		return ret;
-	}
-
-	*paddr = region->paddr + (vaddr - region->vaddr);
-	return 0;
-}
-
-static int adsp_verify_cmd(struct msm_adsp_module *module,
-			   unsigned int queue_id, void *cmd_data,
-			   size_t cmd_size)
-{
-	/* call the per module verifier */
-	if (module->verify_cmd)
-		return module->verify_cmd(module, queue_id, cmd_data,
-					     cmd_size);
-	else
-		MM_INFO("no packet verifying function "
-				 "for task %s\n", module->name);
-	return 0;
-}
-
-static long adsp_write_cmd(struct adsp_device *adev, void __user *arg)
-{
-	struct adsp_command_t cmd;
-	unsigned char buf[256];
-	void *cmd_data;
-	long rc;
-
-	if (copy_from_user(&cmd, (void __user *)arg, sizeof(cmd)))
-		return -EFAULT;
-
-	if (cmd.len > 256) {
-		cmd_data = kmalloc(cmd.len, GFP_USER);
-		if (!cmd_data)
-			return -ENOMEM;
-	} else {
-		cmd_data = buf;
-	}
-
-	if (copy_from_user(cmd_data, (void __user *)(cmd.data), cmd.len)) {
-		rc = -EFAULT;
-		goto end;
-	}
-
-	mutex_lock(&adev->module->pmem_regions_lock);
-	if (adsp_verify_cmd(adev->module, cmd.queue, cmd_data, cmd.len)) {
-		MM_ERR("module %s: verify failed.\n", adev->module->name);
-		rc = -EINVAL;
-		goto end;
-	}
-	rc = msm_adsp_write(adev->module, cmd.queue, cmd_data, cmd.len);
-end:
-	mutex_unlock(&adev->module->pmem_regions_lock);
-
-	if (cmd.len > 256)
-		kfree(cmd_data);
-
-	return rc;
-}
-
-static int adsp_events_pending(struct adsp_device *adev)
-{
-	unsigned long flags;
-	int yes;
-	spin_lock_irqsave(&adev->event_queue_lock, flags);
-	yes = !list_empty(&adev->event_queue);
-	spin_unlock_irqrestore(&adev->event_queue_lock, flags);
-	return yes || adev->abort;
-}
-
-static int adsp_pmem_lookup_paddr(struct msm_adsp_module *module, void **addr,
-		     struct adsp_pmem_region **region)
-{
-	struct hlist_node *node;
-	unsigned long paddr = (unsigned long)(*addr);
-	struct adsp_pmem_region *region_elt;
-
-	hlist_for_each_entry(region_elt, node, &module->pmem_regions, list) {
-		if (paddr >= region_elt->paddr &&
-		    paddr < region_elt->paddr + region_elt->len) {
-			*region = region_elt;
-			return 0;
-		}
-	}
-	return -1;
-}
-
-int adsp_pmem_paddr_fixup(struct msm_adsp_module *module, void **addr)
-{
-	struct adsp_pmem_region *region;
-	unsigned long paddr = (unsigned long)(*addr);
-	unsigned long *vaddr = (unsigned long *)addr;
-	int ret;
-
-	ret = adsp_pmem_lookup_paddr(module, addr, &region);
-	if (ret) {
-		MM_ERR("not patching %s, paddr %p lookup failed\n",
-			module->name, vaddr);
-		return ret;
-	}
-
-	*vaddr = (unsigned long)region->vaddr + (paddr - region->paddr);
-	return 0;
-}
-
-static int adsp_patch_event(struct msm_adsp_module *module,
-				struct adsp_event *event)
-{
-	/* call the per-module msg verifier */
-	if (module->patch_event)
-		return module->patch_event(module, event);
-	return 0;
-}
-
-static long adsp_get_event(struct adsp_device *adev, void __user *arg)
-{
-	unsigned long flags;
-	struct adsp_event *data = NULL;
-	struct adsp_event_t evt;
-	int timeout;
-	long rc = 0;
-
-	if (copy_from_user(&evt, arg, sizeof(struct adsp_event_t)))
-		return -EFAULT;
-
-	timeout = (int)evt.timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(
-			adev->event_wait, adsp_events_pending(adev),
-			msecs_to_jiffies(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(
-			adev->event_wait, adsp_events_pending(adev));
-	}
-	if (rc < 0)
-		return rc;
-
-	if (adev->abort)
-		return -ENODEV;
-
-	spin_lock_irqsave(&adev->event_queue_lock, flags);
-	if (!list_empty(&adev->event_queue)) {
-		data = list_first_entry(&adev->event_queue,
-					struct adsp_event, list);
-		list_del(&data->list);
-	}
-	spin_unlock_irqrestore(&adev->event_queue_lock, flags);
-
-	if (!data)
-		return -EAGAIN;
-
-	/* DSP messages are type 0; they may contain physical addresses */
-	if (data->type == 0)
-		adsp_patch_event(adev->module, data);
-
-	/* map adsp_event --> adsp_event_t */
-	if (evt.len < data->size) {
-		rc = -ETOOSMALL;
-		goto end;
-	}
-	if (data->msg_id != EVENT_MSG_ID) {
-		if (copy_to_user((void *)(evt.data), data->data.msg16,
-					data->size)) {
-			rc = -EFAULT;
-			goto end;
-	}
-	} else {
-		if (copy_to_user((void *)(evt.data), data->data.msg32,
-					data->size)) {
-			rc = -EFAULT;
-			goto end;
-		}
-	}
-
-	evt.type = data->type; /* 0 --> from aDSP, 1 --> from ARM9 */
-	evt.msg_id = data->msg_id;
-	evt.flags = data->is16;
-	evt.len = data->size;
-	if (copy_to_user(arg, &evt, sizeof(evt)))
-		rc = -EFAULT;
-end:
-	kfree(data);
-	return rc;
-}
-
-static long adsp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
-{
-	struct adsp_device *adev = filp->private_data;
-
-	switch (cmd) {
-	case ADSP_IOCTL_ENABLE:
-		return msm_adsp_enable(adev->module);
-
-	case ADSP_IOCTL_DISABLE:
-		return msm_adsp_disable(adev->module);
-
-	case ADSP_IOCTL_DISABLE_EVENT_RSP:
-		return msm_adsp_disable_event_rsp(adev->module);
-
-	case ADSP_IOCTL_DISABLE_ACK:
-		MM_ERR("ADSP_IOCTL_DISABLE_ACK is not implemented\n");
-		break;
-
-	case ADSP_IOCTL_WRITE_COMMAND:
-		return adsp_write_cmd(adev, (void __user *) arg);
-
-	case ADSP_IOCTL_GET_EVENT:
-		return adsp_get_event(adev, (void __user *) arg);
-
-	case ADSP_IOCTL_SET_CLKRATE: {
-		unsigned long clk_rate;
-		if (copy_from_user(&clk_rate, (void *) arg, sizeof(clk_rate)))
-			return -EFAULT;
-		return adsp_set_clkrate(adev->module, clk_rate);
-	}
-
-	case ADSP_IOCTL_ABORT_EVENT_READ:
-		adev->abort = 1;
-		wake_up(&adev->event_wait);
-		break;
-
-	default:
-		break;
-	}
-	return -EINVAL;
-}
-
-static int adsp_release(struct inode *inode, struct file *filp)
-{
-	struct adsp_device *adev = filp->private_data;
-	struct msm_adsp_module *module = adev->module;
-	int rc = 0;
-
-	MM_INFO("release '%s'\n", adev->name);
-
-	/* clear module before putting it to avoid race with open() */
-	adev->module = NULL;
-
-	msm_adsp_put(module);
-	return rc;
-}
-
-static void adsp_event(void *driver_data, unsigned id, size_t len,
-		       void (*getevent)(void *ptr, size_t len))
-{
-	struct adsp_device *adev = driver_data;
-	struct adsp_event *event;
-	unsigned long flags;
-
-	if (len > ADSP_EVENT_MAX_SIZE) {
-		MM_ERR("event too large (%d bytes)\n", len);
-		return;
-	}
-
-	event = kmalloc(sizeof(*event), GFP_ATOMIC);
-	if (!event) {
-		MM_ERR("cannot allocate buffer\n");
-		return;
-	}
-
-	if (id != EVENT_MSG_ID) {
-		event->type = 0;
-		event->is16 = 0;
-		event->msg_id = id;
-		event->size = len;
-
-		getevent(event->data.msg16, len);
-	} else {
-		event->type = 1;
-		event->is16 = 1;
-		event->msg_id = id;
-		event->size = len;
-		getevent(event->data.msg32, len);
-	}
-
-	spin_lock_irqsave(&adev->event_queue_lock, flags);
-	list_add_tail(&event->list, &adev->event_queue);
-	spin_unlock_irqrestore(&adev->event_queue_lock, flags);
-	wake_up(&adev->event_wait);
-}
-
-static struct msm_adsp_ops adsp_ops = {
-	.event = adsp_event,
-};
-
-static int adsp_open(struct inode *inode, struct file *filp)
-{
-	struct adsp_device *adev;
-	int rc;
-
-	rc = nonseekable_open(inode, filp);
-	if (rc < 0)
-		return rc;
-
-	adev = inode_to_device(inode);
-	if (!adev)
-		return -ENODEV;
-
-	MM_INFO("open '%s'\n", adev->name);
-
-	rc = msm_adsp_get(adev->name, &adev->module, &adsp_ops, adev);
-	if (rc)
-		return rc;
-
-	MM_INFO("opened module '%s' adev %p\n", adev->name, adev);
-	filp->private_data = adev;
-	adev->abort = 0;
-	INIT_HLIST_HEAD(&adev->module->pmem_regions);
-	mutex_init(&adev->module->pmem_regions_lock);
-
-	return 0;
-}
-
-static unsigned adsp_device_count;
-static struct adsp_device *adsp_devices;
-
-static struct adsp_device *inode_to_device(struct inode *inode)
-{
-	unsigned n = MINOR(inode->i_rdev);
-	if (n < adsp_device_count) {
-		if (adsp_devices[n].device)
-			return adsp_devices + n;
-	}
-	return NULL;
-}
-
-static dev_t adsp_devno;
-static struct class *adsp_class;
-
-static const struct file_operations adsp_fops = {
-	.owner = THIS_MODULE,
-	.open = adsp_open,
-	.unlocked_ioctl = adsp_ioctl,
-	.release = adsp_release,
-};
-
-static void adsp_create(struct adsp_device *adev, const char *name,
-			struct device *parent, dev_t devt)
-{
-	struct device *dev;
-	int rc;
-
-	dev = device_create(adsp_class, parent, devt, "%s", name);
-	if (IS_ERR(dev))
-		return;
-
-	init_waitqueue_head(&adev->event_wait);
-	INIT_LIST_HEAD(&adev->event_queue);
-	spin_lock_init(&adev->event_queue_lock);
-
-	cdev_init(&adev->cdev, &adsp_fops);
-	adev->cdev.owner = THIS_MODULE;
-
-	rc = cdev_add(&adev->cdev, devt, 1);
-	if (rc < 0) {
-		device_destroy(adsp_class, devt);
-	} else {
-		adev->device = dev;
-		adev->name = name;
-	}
-}
-
-void msm_adsp_publish_cdevs(struct msm_adsp_module *modules, unsigned n)
-{
-	int rc;
-
-	adsp_devices = kzalloc(sizeof(struct adsp_device) * n, GFP_KERNEL);
-	if (!adsp_devices)
-		return;
-
-	adsp_class = class_create(THIS_MODULE, "adsp");
-	if (IS_ERR(adsp_class))
-		goto fail_create_class;
-
-	rc = alloc_chrdev_region(&adsp_devno, 0, n, "adsp");
-	if (rc < 0)
-		goto fail_alloc_region;
-
-	adsp_device_count = n;
-	for (n = 0; n < adsp_device_count; n++) {
-		adsp_create(adsp_devices + n,
-			    modules[n].name, &modules[n].pdev.dev,
-			    MKDEV(MAJOR(adsp_devno), n));
-	}
-
-	return;
-
-fail_alloc_region:
-	class_unregister(adsp_class);
-fail_create_class:
-	kfree(adsp_devices);
-}
diff --git a/arch/arm/mach-msm/qdsp5v2/adsp_info.c b/arch/arm/mach-msm/qdsp5v2/adsp_info.c
deleted file mode 100644
index 03b810d..0000000
--- a/arch/arm/mach-msm/qdsp5v2/adsp_info.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2008-2010, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include "adsp.h"
-
-/* Firmware modules */
-#define QDSP_MODULE_KERNEL                  0x0106dd4e
-#define QDSP_MODULE_AFETASK                 0x0106dd6f
-#define QDSP_MODULE_AUDPLAY0TASK            0x0106dd70
-#define QDSP_MODULE_AUDPLAY1TASK            0x0106dd71
-#define QDSP_MODULE_AUDPPTASK               0x0106dd72
-#define QDSP_MODULE_VIDEOTASK               0x0106dd73
-#define QDSP_MODULE_VIDEO_AAC_VOC           0x0106dd74
-#define QDSP_MODULE_PCM_DEC                 0x0106dd75
-#define QDSP_MODULE_AUDIO_DEC_MP3           0x0106dd76
-#define QDSP_MODULE_AUDIO_DEC_AAC           0x0106dd77
-#define QDSP_MODULE_AUDIO_DEC_WMA           0x0106dd78
-#define QDSP_MODULE_HOSTPCM                 0x0106dd79
-#define QDSP_MODULE_DTMF                    0x0106dd7a
-#define QDSP_MODULE_AUDRECTASK              0x0106dd7b
-#define QDSP_MODULE_AUDPREPROCTASK          0x0106dd7c
-#define QDSP_MODULE_SBC_ENC                 0x0106dd7d
-#define QDSP_MODULE_VOC_UMTS                0x0106dd9a
-#define QDSP_MODULE_VOC_CDMA                0x0106dd98
-#define QDSP_MODULE_VOC_PCM                 0x0106dd7f
-#define QDSP_MODULE_VOCENCTASK              0x0106dd80
-#define QDSP_MODULE_VOCDECTASK              0x0106dd81
-#define QDSP_MODULE_VOICEPROCTASK           0x0106dd82
-#define QDSP_MODULE_VIDEOENCTASK            0x0106dd83
-#define QDSP_MODULE_VFETASK                 0x0106dd84
-#define QDSP_MODULE_WAV_ENC                 0x0106dd85
-#define QDSP_MODULE_AACLC_ENC               0x0106dd86
-#define QDSP_MODULE_VIDEO_AMR               0x0106dd87
-#define QDSP_MODULE_VOC_AMR                 0x0106dd88
-#define QDSP_MODULE_VOC_EVRC                0x0106dd89
-#define QDSP_MODULE_VOC_13K                 0x0106dd8a
-#define QDSP_MODULE_VOC_FGV                 0x0106dd8b
-#define QDSP_MODULE_DIAGTASK                0x0106dd8c
-#define QDSP_MODULE_JPEGTASK                0x0106dd8d
-#define QDSP_MODULE_LPMTASK                 0x0106dd8e
-#define QDSP_MODULE_QCAMTASK                0x0106dd8f
-#define QDSP_MODULE_MODMATHTASK             0x0106dd90
-#define QDSP_MODULE_AUDPLAY2TASK            0x0106dd91
-#define QDSP_MODULE_AUDPLAY3TASK            0x0106dd92
-#define QDSP_MODULE_AUDPLAY4TASK            0x0106dd93
-#define QDSP_MODULE_GRAPHICSTASK            0x0106dd94
-#define QDSP_MODULE_MIDI                    0x0106dd95
-#define QDSP_MODULE_GAUDIO                  0x0106dd96
-#define QDSP_MODULE_VDEC_LP_MODE            0x0106dd97
-#define QDSP_MODULE_VIDEO_AAC_VOC_TURBO     0x01089f77
-#define QDSP_MODULE_VIDEO_AMR_TURBO         0x01089f78
-#define QDSP_MODULE_WM_TURBO_MODE           0x01089f79
-#define QDSP_MODULE_VDEC_LP_MODE_TURBO      0x01089f7a
-#define QDSP_MODULE_AUDREC0TASK             0x0109696f
-#define QDSP_MODULE_AUDREC1TASK             0x01096970
-#define QDSP_MODULE_AUDREC2TASK             0x010a2f59
-#define QDSP_MODULE_MAX                     0x7fffffff
-
-   /* DO NOT USE: Force this enum to be a 32bit type to improve speed */
-#define QDSP_MODULE_32BIT_DUMMY 0x10000
-
-static uint32_t *qdsp_task_to_module[IMG_MAX];
-static uint32_t	*qdsp_queue_offset_table[IMG_MAX];
-
-#define QDSP_MODULE(n, clkname, clkrate, verify_cmd_func, patch_event_func) \
-	{ .name = #n, .pdev_name = "adsp_" #n, .id = QDSP_MODULE_##n, \
-	  .clk_name = clkname, .clk_rate = clkrate, \
-	  .verify_cmd = verify_cmd_func, .patch_event = patch_event_func }
-
-static struct adsp_module_info module_info[] = {
-	QDSP_MODULE(AUDPLAY0TASK, NULL, 0, NULL, NULL),
-	QDSP_MODULE(AUDPLAY1TASK, NULL, 0, NULL, NULL),
-	QDSP_MODULE(AUDPLAY2TASK, NULL, 0, NULL, NULL),
-	QDSP_MODULE(AUDPLAY3TASK, NULL, 0, NULL, NULL),
-	QDSP_MODULE(AUDPPTASK, NULL, 0, NULL, NULL),
-	QDSP_MODULE(AUDPREPROCTASK, NULL, 0, NULL, NULL),
-	QDSP_MODULE(AFETASK , NULL, 0, NULL, NULL),
-	QDSP_MODULE(AUDREC0TASK, NULL, 0, NULL, NULL),
-	QDSP_MODULE(AUDREC1TASK, NULL, 0, NULL, NULL),
-	QDSP_MODULE(AUDREC2TASK, NULL, 0, NULL, NULL),
-};
-
-int adsp_init_info(struct adsp_info *info)
-{
-	uint32_t img_num;
-
-	info->send_irq =   0x00c00200;
-	info->read_ctrl =  0x00400038;
-	info->write_ctrl = 0x00400034;
-
-	info->max_msg16_size = 193;
-	info->max_msg32_size = 8;
-	for (img_num = 0; img_num < IMG_MAX; img_num++)
-		qdsp_queue_offset_table[img_num] =
-		&info->init_info_ptr->queue_offsets[img_num][0];
-
-	for (img_num = 0; img_num < IMG_MAX; img_num++)
-		qdsp_task_to_module[img_num] =
-		&info->init_info_ptr->task_to_module_tbl[img_num][0];
-	info->max_task_id = ENTRIES_MAX;
-	info->max_module_id = QDSP_MODULE_MAX - 1;
-	info->max_queue_id = QDSP_MAX_NUM_QUEUES;
-	info->max_image_id = 0;
-	info->queue_offset = qdsp_queue_offset_table;
-	info->task_to_module = qdsp_task_to_module;
-
-	info->module_count = ARRAY_SIZE(module_info);
-	info->module = module_info;
-	return 0;
-}
diff --git a/arch/arm/mach-msm/qdsp5v2/afe.c b/arch/arm/mach-msm/qdsp5v2/afe.c
deleted file mode 100644
index 1e856e5..0000000
--- a/arch/arm/mach-msm/qdsp5v2/afe.c
+++ /dev/null
@@ -1,534 +0,0 @@
-/* Copyright (c) 2009-2011, The Linux Foundation. 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.
- *
- */
-#include <linux/module.h>
-#include <linux/wait.h>
-#include <linux/sched.h>
-#include <linux/jiffies.h>
-#include <linux/debugfs.h>
-#include <asm/uaccess.h>
-#include <mach/qdsp5v2/qdsp5afecmdi.h>
-#include <mach/qdsp5v2/qdsp5afemsg.h>
-#include <mach/qdsp5v2/afe.h>
-#include <mach/msm_adsp.h>
-#include <mach/debug_mm.h>
-
-#define AFE_MAX_TIMEOUT 500 /* 500 ms */
-#define AFE_MAX_CLNT 6 /* 6 HW path defined so far */
-#define GETDEVICEID(x) ((x) - 1)
-
-struct msm_afe_state {
-	struct msm_adsp_module *mod;
-	struct msm_adsp_ops    adsp_ops;
-	struct mutex           lock;
-	u8                     in_use;
-	u8                     codec_config[AFE_MAX_CLNT];
-	wait_queue_head_t      wait;
-	u8			aux_conf_flag;
-};
-
-#ifdef CONFIG_DEBUG_FS
-static struct dentry *debugfs_afelb;
-#endif
-
-
-static struct msm_afe_state the_afe_state;
-
-#define afe_send_queue(afe, cmd, len) \
-  msm_adsp_write(afe->mod, QDSP_apuAfeQueue, \
-	cmd, len)
-
-static void afe_dsp_event(void *data, unsigned id, size_t len,
-			    void (*getevent)(void *ptr, size_t len))
-{
-	struct msm_afe_state *afe = data;
-
-	MM_DBG("msg_id %d \n", id);
-
-	switch (id) {
-	case AFE_APU_MSG_CODEC_CONFIG_ACK: {
-		struct afe_msg_codec_config_ack afe_ack;
-		getevent(&afe_ack, AFE_APU_MSG_CODEC_CONFIG_ACK_LEN);
-		MM_DBG("%s: device_id: %d device activity: %d\n", __func__,
-		afe_ack.device_id, afe_ack.device_activity);
-		if (afe_ack.device_activity == AFE_MSG_CODEC_CONFIG_DISABLED)
-			afe->codec_config[GETDEVICEID(afe_ack.device_id)] = 0;
-		else
-			afe->codec_config[GETDEVICEID(afe_ack.device_id)] =
-			afe_ack.device_activity;
-
-		wake_up(&afe->wait);
-		break;
-	}
-	case AFE_APU_MSG_VOC_TIMING_SUCCESS:
-		MM_INFO("Received VOC_TIMING_SUCCESS message from AFETASK\n");
-		break;
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable/disable(audpptask)");
-		break;
-	default:
-		MM_ERR("unexpected message from afe \n");
-	}
-
-	return;
-}
-
-static void afe_dsp_codec_config(struct msm_afe_state *afe,
-	u8 path_id, u8 enable, struct msm_afe_config *config)
-{
-	struct afe_cmd_codec_config cmd;
-
-	MM_DBG("%s() %p\n", __func__, config);
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AFE_CMD_CODEC_CONFIG_CMD;
-	cmd.device_id = path_id;
-	cmd.activity = enable;
-	if (config) {
-		MM_DBG("%s: sample_rate %x ch mode %x vol %x\n",
-			__func__, config->sample_rate,
-			config->channel_mode, config->volume);
-		cmd.sample_rate = config->sample_rate;
-		cmd.channel_mode = config->channel_mode;
-		cmd.volume = config->volume;
-	}
-	afe_send_queue(afe, &cmd, sizeof(cmd));
-}
-/* Function is called after afe module been enabled */
-void afe_loopback(int enable)
-{
-	struct afe_cmd_loopback cmd;
-	struct msm_afe_state *afe;
-
-	afe = &the_afe_state;
-	MM_DBG("enable %d\n", enable);
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AFE_CMD_LOOPBACK;
-	if (enable)
-		cmd.enable_flag = AFE_LOOPBACK_ENABLE_COMMAND;
-
-	afe_send_queue(afe, &cmd, sizeof(cmd));
-}
-EXPORT_SYMBOL(afe_loopback);
-
-void afe_ext_loopback(int enable, int rx_copp_id, int tx_copp_id)
-{
-	struct afe_cmd_ext_loopback cmd;
-	struct msm_afe_state *afe;
-
-	afe = &the_afe_state;
-	MM_DBG("enable %d\n", enable);
-	if ((rx_copp_id == 0) && (tx_copp_id == 0)) {
-		afe_loopback(enable);
-	} else {
-		memset(&cmd, 0, sizeof(cmd));
-		cmd.cmd_id = AFE_CMD_EXT_LOOPBACK;
-		cmd.source_id = tx_copp_id;
-		cmd.dst_id = rx_copp_id;
-		if (enable)
-			cmd.enable_flag = AFE_LOOPBACK_ENABLE_COMMAND;
-
-		afe_send_queue(afe, &cmd, sizeof(cmd));
-	}
-}
-EXPORT_SYMBOL(afe_ext_loopback);
-
-void afe_device_volume_ctrl(u16 device_id, u16 device_volume)
-{
-	struct afe_cmd_device_volume_ctrl cmd;
-	struct msm_afe_state *afe;
-
-	afe = &the_afe_state;
-	MM_DBG("device 0x%4x volume 0x%4x\n", device_id, device_volume);
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AFE_CMD_DEVICE_VOLUME_CTRL;
-	cmd.device_id = device_id;
-	cmd.device_volume = device_volume;
-	afe_send_queue(afe, &cmd, sizeof(cmd));
-}
-EXPORT_SYMBOL(afe_device_volume_ctrl);
-
-int afe_enable(u8 path_id, struct msm_afe_config *config)
-{
-	struct msm_afe_state *afe = &the_afe_state;
-	int rc;
-
-	MM_DBG("%s: path %d\n", __func__, path_id);
-	if ((GETDEVICEID(path_id) < 0) || (GETDEVICEID(path_id) > 5)) {
-		MM_ERR("Invalid path_id: %d\n", path_id);
-		return -EINVAL;
-	}
-	mutex_lock(&afe->lock);
-	if (!afe->in_use && !afe->aux_conf_flag) {
-		/* enable afe */
-		rc = msm_adsp_get("AFETASK", &afe->mod, &afe->adsp_ops, afe);
-		if (rc < 0) {
-			MM_ERR("%s: failed to get AFETASK module\n", __func__);
-			goto error_adsp_get;
-		}
-		rc = msm_adsp_enable(afe->mod);
-		if (rc < 0)
-			goto error_adsp_enable;
-	}
-	/* Issue codec config command */
-	afe_dsp_codec_config(afe, path_id, 1, config);
-	rc = wait_event_timeout(afe->wait,
-		afe->codec_config[GETDEVICEID(path_id)],
-		msecs_to_jiffies(AFE_MAX_TIMEOUT));
-	if (!rc) {
-		MM_ERR("AFE failed to respond within %d ms\n", AFE_MAX_TIMEOUT);
-		rc = -ENODEV;
-		if (!afe->in_use) {
-			if (!afe->aux_conf_flag ||
-			(afe->aux_conf_flag &&
-			(path_id == AFE_HW_PATH_AUXPCM_RX ||
-			path_id == AFE_HW_PATH_AUXPCM_TX))) {
-				/* clean up if there is no client */
-				msm_adsp_disable(afe->mod);
-				msm_adsp_put(afe->mod);
-				afe->aux_conf_flag = 0;
-				afe->mod = NULL;
-			}
-		}
-
-	} else {
-		rc = 0;
-		afe->in_use++;
-	}
-
-	mutex_unlock(&afe->lock);
-	return rc;
-
-error_adsp_enable:
-	msm_adsp_put(afe->mod);
-	afe->mod = NULL;
-error_adsp_get:
-	mutex_unlock(&afe->lock);
-	return rc;
-}
-EXPORT_SYMBOL(afe_enable);
-
-int afe_config_fm_codec(int fm_enable, uint16_t source)
-{
-	struct afe_cmd_fm_codec_config cmd;
-	struct msm_afe_state *afe = &the_afe_state;
-	int rc = 0;
-	int i = 0;
-	unsigned short *ptrmem = (unsigned short *)&cmd;
-
-	MM_INFO(" configure fm codec\n");
-	mutex_lock(&afe->lock);
-	if (!afe->in_use) {
-		/* enable afe */
-		rc = msm_adsp_get("AFETASK", &afe->mod, &afe->adsp_ops, afe);
-		if (rc < 0) {
-			MM_ERR("%s: failed to get AFETASK module\n", __func__);
-			goto error_adsp_get;
-		}
-		rc = msm_adsp_enable(afe->mod);
-		if (rc < 0)
-			goto error_adsp_enable;
-	}
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AFE_CMD_FM_RX_ROUTING_CMD;
-	cmd.enable = fm_enable;
-	cmd.device_id = source;
-
-	for (i = 0; i < sizeof(cmd)/2; i++, ++ptrmem)
-		MM_DBG("cmd[%d]=0x%04x\n", i, *ptrmem);
-	afe_send_queue(afe, &cmd, sizeof(cmd));
-
-	mutex_unlock(&afe->lock);
-	return rc;
-error_adsp_enable:
-	msm_adsp_put(afe->mod);
-	afe->mod = NULL;
-error_adsp_get:
-	mutex_unlock(&afe->lock);
-	return rc;
-}
-EXPORT_SYMBOL(afe_config_fm_codec);
-
-int afe_config_fm_volume(uint16_t volume)
-{
-	struct afe_cmd_fm_volume_config cmd;
-	struct msm_afe_state *afe = &the_afe_state;
-	int rc = 0;
-
-	MM_INFO(" configure fm volume\n");
-	mutex_lock(&afe->lock);
-	if (!afe->in_use) {
-		/* enable afe */
-		rc = msm_adsp_get("AFETASK", &afe->mod, &afe->adsp_ops, afe);
-		if (rc < 0) {
-			MM_ERR("%s: failed to get AFETASK module\n", __func__);
-			goto error_adsp_get;
-		}
-		rc = msm_adsp_enable(afe->mod);
-		if (rc < 0)
-			goto error_adsp_enable;
-	}
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AFE_CMD_FM_PLAYBACK_VOLUME_CMD;
-	cmd.volume = volume;
-
-	afe_send_queue(afe, &cmd, sizeof(cmd));
-
-	mutex_unlock(&afe->lock);
-	return rc;
-error_adsp_enable:
-	msm_adsp_put(afe->mod);
-	afe->mod = NULL;
-error_adsp_get:
-	mutex_unlock(&afe->lock);
-	return rc;
-}
-EXPORT_SYMBOL(afe_config_fm_volume);
-
-int afe_config_fm_calibration_gain(uint16_t device_id,
-			uint16_t calibration_gain)
-{
-	struct afe_cmd_fm_calibgain_config cmd;
-	struct msm_afe_state *afe = &the_afe_state;
-	int rc = 0;
-
-	MM_INFO("Configure for rx device = 0x%4x, gain = 0x%4x\n", device_id,
-			calibration_gain);
-	mutex_lock(&afe->lock);
-	if (!afe->in_use) {
-		/* enable afe */
-		rc = msm_adsp_get("AFETASK", &afe->mod, &afe->adsp_ops, afe);
-		if (rc < 0) {
-			MM_ERR("%s: failed to get AFETASK module\n", __func__);
-			goto error_adsp_get;
-		}
-		rc = msm_adsp_enable(afe->mod);
-		if (rc < 0)
-			goto error_adsp_enable;
-	}
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AFE_CMD_FM_CALIBRATION_GAIN_CMD;
-	cmd.device_id = device_id;
-	cmd.calibration_gain = calibration_gain;
-
-	afe_send_queue(afe, &cmd, sizeof(cmd));
-
-	mutex_unlock(&afe->lock);
-	return rc;
-error_adsp_enable:
-	msm_adsp_put(afe->mod);
-	afe->mod = NULL;
-error_adsp_get:
-	mutex_unlock(&afe->lock);
-	return rc;
-}
-EXPORT_SYMBOL(afe_config_fm_calibration_gain);
-
-int afe_config_aux_codec(int pcm_ctl_value, int aux_codec_intf_value,
-				int data_format_pad)
-{
-	struct afe_cmd_aux_codec_config cmd;
-	struct msm_afe_state *afe = &the_afe_state;
-	int rc = 0;
-
-	MM_DBG(" configure aux codec \n");
-	mutex_lock(&afe->lock);
-	if (!afe->in_use && !afe->aux_conf_flag) {
-		/* enable afe */
-		rc = msm_adsp_get("AFETASK", &afe->mod, &afe->adsp_ops, afe);
-		if (rc < 0) {
-			MM_ERR("%s: failed to get AFETASK module\n", __func__);
-			goto error_adsp_get;
-		}
-		rc = msm_adsp_enable(afe->mod);
-		if (rc < 0)
-			goto error_adsp_enable;
-	}
-	afe->aux_conf_flag = 1;
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AFE_CMD_AUX_CODEC_CONFIG_CMD;
-	cmd.dma_path_ctl = 0;
-	cmd.pcm_ctl = pcm_ctl_value;
-	cmd.eight_khz_int_mode = 0;
-	cmd.aux_codec_intf_ctl = aux_codec_intf_value;
-	cmd.data_format_padding_info = data_format_pad;
-
-	afe_send_queue(afe, &cmd, sizeof(cmd));
-
-	mutex_unlock(&afe->lock);
-	return rc;
-error_adsp_enable:
-	msm_adsp_put(afe->mod);
-	afe->mod = NULL;
-error_adsp_get:
-	mutex_unlock(&afe->lock);
-	return rc;
-}
-EXPORT_SYMBOL(afe_config_aux_codec);
-
-int afe_config_rmc_block(struct acdb_rmc_block *acdb_rmc)
-{
-	struct afe_cmd_cfg_rmc cmd;
-	struct msm_afe_state *afe = &the_afe_state;
-	int rc = 0;
-	int i = 0;
-	unsigned short *ptrmem = (unsigned short *)&cmd;
-
-	MM_DBG(" configure rmc block\n");
-	mutex_lock(&afe->lock);
-	if (!afe->in_use && !afe->mod) {
-		/* enable afe */
-		rc = msm_adsp_get("AFETASK", &afe->mod, &afe->adsp_ops, afe);
-		if (rc < 0) {
-			MM_DBG("%s: failed to get AFETASK module\n", __func__);
-			goto error_adsp_get;
-		}
-		rc = msm_adsp_enable(afe->mod);
-		if (rc < 0)
-			goto error_adsp_enable;
-	}
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AFE_CMD_CFG_RMC_PARAMS;
-
-	cmd.rmc_mode = acdb_rmc->rmc_enable;
-	cmd.rmc_ipw_length_ms =	acdb_rmc->rmc_ipw_length_ms;
-	cmd.rmc_peak_length_ms = acdb_rmc->rmc_peak_length_ms;
-	cmd.rmc_init_pulse_length_ms = acdb_rmc->rmc_init_pulse_length_ms;
-	cmd.rmc_total_int_length_ms = acdb_rmc->rmc_total_int_length_ms;
-	cmd.rmc_rampupdn_length_ms = acdb_rmc->rmc_rampupdn_length_ms;
-	cmd.rmc_delay_length_ms = acdb_rmc->rmc_delay_length_ms;
-	cmd.rmc_detect_start_threshdb = acdb_rmc->rmc_detect_start_threshdb;
-	cmd.rmc_init_pulse_threshdb = acdb_rmc->rmc_init_pulse_threshdb;
-
-	for (i = 0; i < sizeof(cmd)/2; i++, ++ptrmem)
-		MM_DBG("cmd[%d]=0x%04x\n", i, *ptrmem);
-	afe_send_queue(afe, &cmd, sizeof(cmd));
-
-	mutex_unlock(&afe->lock);
-	return rc;
-error_adsp_enable:
-	msm_adsp_put(afe->mod);
-	afe->mod = NULL;
-error_adsp_get:
-	mutex_unlock(&afe->lock);
-	return rc;
-}
-EXPORT_SYMBOL(afe_config_rmc_block);
-
-int afe_disable(u8 path_id)
-{
-	struct msm_afe_state *afe = &the_afe_state;
-	int rc;
-
-	mutex_lock(&afe->lock);
-
-	BUG_ON(!afe->in_use);
-	MM_DBG("%s() path_id:%d codec state:%d\n", __func__, path_id,
-	afe->codec_config[GETDEVICEID(path_id)]);
-	afe_dsp_codec_config(afe, path_id, 0, NULL);
-	rc = wait_event_timeout(afe->wait,
-		!afe->codec_config[GETDEVICEID(path_id)],
-		msecs_to_jiffies(AFE_MAX_TIMEOUT));
-	if (!rc) {
-		MM_ERR("AFE failed to respond within %d ms\n", AFE_MAX_TIMEOUT);
-		rc = -1;
-	} else
-		rc = 0;
-	afe->in_use--;
-	MM_DBG("%s() in_use:%d \n", __func__, afe->in_use);
-	if (!afe->in_use) {
-		msm_adsp_disable(afe->mod);
-		msm_adsp_put(afe->mod);
-		afe->aux_conf_flag = 0;
-		afe->mod = NULL;
-	}
-	mutex_unlock(&afe->lock);
-	return rc;
-}
-EXPORT_SYMBOL(afe_disable);
-
-
-#ifdef CONFIG_DEBUG_FS
-static int afe_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	MM_INFO("debug intf %s\n", (char *) file->private_data);
-	return 0;
-}
-
-static ssize_t afe_debug_write(struct file *filp,
-	const char __user *ubuf, size_t cnt, loff_t *ppos)
-{
-	char *lb_str = filp->private_data;
-	char cmd;
-
-	if (get_user(cmd, ubuf))
-		return -EFAULT;
-
-	MM_INFO("%s %c\n", lb_str, cmd);
-
-	if (!strcmp(lb_str, "afe_loopback")) {
-		switch (cmd) {
-		case '1':
-			afe_loopback(1);
-			break;
-		case '0':
-			afe_loopback(0);
-			break;
-		}
-	}
-
-	return cnt;
-}
-
-static const struct file_operations afe_debug_fops = {
-	.open = afe_debug_open,
-	.write = afe_debug_write
-};
-#endif
-
-static int __init afe_init(void)
-{
-	struct msm_afe_state *afe = &the_afe_state;
-
-	MM_INFO("AFE driver init\n");
-
-	memset(afe, 0, sizeof(struct msm_afe_state));
-	afe->adsp_ops.event = afe_dsp_event;
-	mutex_init(&afe->lock);
-	init_waitqueue_head(&afe->wait);
-
-#ifdef CONFIG_DEBUG_FS
-	debugfs_afelb = debugfs_create_file("afe_loopback",
-	S_IFREG | S_IWUGO, NULL, (void *) "afe_loopback",
-	&afe_debug_fops);
-#endif
-
-	return 0;
-}
-
-static void __exit afe_exit(void)
-{
-	MM_INFO("AFE driver exit\n");
-#ifdef CONFIG_DEBUG_FS
-	if (debugfs_afelb)
-		debugfs_remove(debugfs_afelb);
-#endif
-	if (the_afe_state.mod)
-		msm_adsp_put(the_afe_state.mod);
-	return;
-}
-
-module_init(afe_init);
-module_exit(afe_exit);
-
-MODULE_DESCRIPTION("MSM AFE driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5v2/audio_a2dp_in.c b/arch/arm/mach-msm/qdsp5v2/audio_a2dp_in.c
deleted file mode 100644
index 8d644f0..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audio_a2dp_in.c
+++ /dev/null
@@ -1,1041 +0,0 @@
-/* Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.
- *
- * sbc/pcm audio input driver
- * Based on the pcm input driver in arch/arm/mach-msm/qdsp5v2/audio_pcm_in.c
- *
- * Copyright (C) 2008 HTC Corporation
- * Copyright (C) 2008 Google, Inc.
- * Copyright (c) 2012 The Linux Foundation. All rights reserved.
- *
- * All source code in this file is licensed under the following license except
- * where indicated.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/msm_audio.h>
-#include <linux/msm_audio_sbc.h>
-#include <linux/msm_ion.h>
-#include <linux/memory_alloc.h>
-
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/msm_adsp.h>
-#include <mach/msm_memtypes.h>
-#include <mach/socinfo.h>
-#include <mach/qdsp5v2/qdsp5audreccmdi.h>
-#include <mach/qdsp5v2/qdsp5audrecmsg.h>
-#include <mach/qdsp5v2/audpreproc.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/debug_mm.h>
-
-/* FRAME_NUM must be a power of two */
-#define FRAME_NUM		(8)
-#define FRAME_SIZE		(2052 * 2)
-#define FRAME_SIZE_SBC		(768 * 2)
-#define MONO_DATA_SIZE		(2048)
-#define STEREO_DATA_SIZE	(MONO_DATA_SIZE * 2)
-#define DMASZ 			(FRAME_SIZE * FRAME_NUM)
-
-struct buffer {
-	void *data;
-	uint32_t size;
-	uint32_t read;
-	uint32_t addr;
-	uint32_t frame_num;
-	uint32_t frame_len;
-};
-
-struct audio_a2dp_in {
-	struct buffer in[FRAME_NUM];
-
-	spinlock_t dsp_lock;
-
-	atomic_t in_bytes;
-	atomic_t in_samples;
-
-	struct mutex lock;
-	struct mutex read_lock;
-	wait_queue_head_t wait;
-	wait_queue_head_t wait_enable;
-
-	struct msm_adsp_module *audrec;
-
-	struct audrec_session_info session_info; /*audrec session info*/
-
-	/* configuration to use on next enable */
-	uint32_t samp_rate;
-	uint32_t channel_mode;
-	uint32_t buffer_size; /* 2048 for mono, 4096 for stereo */
-	uint32_t enc_type;
-	struct msm_audio_sbc_enc_config cfg;
-
-	uint32_t dsp_cnt;
-	uint32_t in_head; /* next buffer dsp will write */
-	uint32_t in_tail; /* next buffer read() will read */
-	uint32_t in_count; /* number of buffers available to read() */
-	uint32_t mode;
-
-	const char *module_name;
-	unsigned queue_ids;
-	uint16_t enc_id; /* Session Id */
-
-	uint16_t source; /* Encoding source bit mask */
-	uint32_t device_events; /* device events interested in */
-	uint32_t dev_cnt;
-	spinlock_t dev_lock;
-
-	/* data allocated for various buffers */
-	char *data;
-	dma_addr_t phys;
-	void *msm_map;
-
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped, cleared on flush */
-	int abort; /* set when error, like sample rate mismatch */
-	char *build_id;
-	struct ion_client *client;
-	struct ion_handle *output_buff_handle;
-};
-
-static struct audio_a2dp_in the_audio_a2dp_in;
-
-struct wav_frame {
-	uint16_t frame_count_lsw;
-	uint16_t frame_count_msw;
-	uint16_t frame_length;
-	uint16_t erased_a2dp;
-	unsigned char raw_bitstream[]; /* samples */
-};
-
-struct sbc_frame {
-	uint16_t bit_rate_msw;
-	uint16_t bit_rate_lsw;
-	uint16_t frame_length;
-	uint16_t frame_num;
-	unsigned char raw_bitstream[]; /* samples */
-};
-
-struct audio_frame {
-	union {
-		struct wav_frame wav;
-		struct sbc_frame sbc;
-	} a2dp;
-} __attribute__((packed));
-
-/* Audrec Queue command sent macro's */
-#define audrec_send_bitstreamqueue(audio, cmd, len) \
-	msm_adsp_write(audio->audrec, ((audio->queue_ids & 0xFFFF0000) >> 16),\
-			cmd, len)
-
-#define audrec_send_audrecqueue(audio, cmd, len) \
-	msm_adsp_write(audio->audrec, (audio->queue_ids & 0x0000FFFF),\
-			cmd, len)
-
-/* DSP command send functions */
-static int auda2dp_in_enc_config(struct audio_a2dp_in *audio, int enable);
-static int auda2dp_in_param_config(struct audio_a2dp_in *audio);
-static int auda2dp_in_mem_config(struct audio_a2dp_in *audio);
-static int auda2dp_in_record_config(struct audio_a2dp_in *audio, int enable);
-static int auda2dp_dsp_read_buffer(struct audio_a2dp_in *audio,
-							uint32_t read_cnt);
-
-static void auda2dp_in_get_dsp_frames(struct audio_a2dp_in *audio);
-
-static void auda2dp_in_flush(struct audio_a2dp_in *audio);
-
-static void a2dp_in_listener(u32 evt_id, union auddev_evt_data *evt_payload,
-				void *private_data)
-{
-	struct audio_a2dp_in *audio = (struct audio_a2dp_in *) private_data;
-	unsigned long flags;
-
-	MM_DBG("evt_id = 0x%8x\n", evt_id);
-	switch (evt_id) {
-	case AUDDEV_EVT_DEV_RDY: {
-		MM_DBG("AUDDEV_EVT_DEV_RDY\n");
-		spin_lock_irqsave(&audio->dev_lock, flags);
-		audio->dev_cnt++;
-		audio->source |= (0x1 << evt_payload->routing_id);
-		spin_unlock_irqrestore(&audio->dev_lock, flags);
-
-		if ((audio->running == 1) && (audio->enabled == 1))
-			auda2dp_in_record_config(audio, 1);
-
-		break;
-	}
-	case AUDDEV_EVT_DEV_RLS: {
-		MM_DBG("AUDDEV_EVT_DEV_RLS\n");
-		spin_lock_irqsave(&audio->dev_lock, flags);
-		audio->dev_cnt--;
-		audio->source &= ~(0x1 << evt_payload->routing_id);
-		spin_unlock_irqrestore(&audio->dev_lock, flags);
-
-		if (!audio->running || !audio->enabled)
-			break;
-
-		/* Turn of as per source */
-		if (audio->source)
-			auda2dp_in_record_config(audio, 1);
-		else
-			/* Turn off all */
-			auda2dp_in_record_config(audio, 0);
-
-		break;
-	}
-	case AUDDEV_EVT_FREQ_CHG: {
-		MM_DBG("Encoder Driver got sample rate change event\n");
-		MM_DBG("sample rate %d\n", evt_payload->freq_info.sample_rate);
-		MM_DBG("dev_type %d\n", evt_payload->freq_info.dev_type);
-		MM_DBG("acdb_dev_id %d\n", evt_payload->freq_info.acdb_dev_id);
-		if (audio->running == 1) {
-			/* Stop Recording sample rate does not match
-			   with device sample rate */
-			if (evt_payload->freq_info.sample_rate !=
-				audio->samp_rate) {
-				auda2dp_in_record_config(audio, 0);
-				audio->abort = 1;
-				wake_up(&audio->wait);
-			}
-		}
-		break;
-	}
-	default:
-		MM_ERR("wrong event %d\n", evt_id);
-		break;
-	}
-}
-
-/* ------------------- dsp preproc event handler--------------------- */
-static void audpreproc_dsp_event(void *data, unsigned id,  void *msg)
-{
-	struct audio_a2dp_in *audio = data;
-
-	switch (id) {
-	case AUDPREPROC_ERROR_MSG: {
-		struct audpreproc_err_msg *err_msg = msg;
-
-		MM_ERR("ERROR_MSG: stream id %d err idx %d\n",
-		err_msg->stream_id, err_msg->aud_preproc_err_idx);
-		/* Error case */
-		wake_up(&audio->wait_enable);
-		break;
-	}
-	case AUDPREPROC_CMD_CFG_DONE_MSG: {
-		MM_DBG("CMD_CFG_DONE_MSG \n");
-		break;
-	}
-	case AUDPREPROC_CMD_ENC_CFG_DONE_MSG: {
-		struct audpreproc_cmd_enc_cfg_done_msg *enc_cfg_msg = msg;
-
-		MM_DBG("CMD_ENC_CFG_DONE_MSG: stream id %d enc type \
-			0x%8x\n", enc_cfg_msg->stream_id,
-			enc_cfg_msg->rec_enc_type);
-		/* Encoder enable success */
-		if (enc_cfg_msg->rec_enc_type & ENCODE_ENABLE)
-			auda2dp_in_param_config(audio);
-		else { /* Encoder disable success */
-			audio->running = 0;
-			auda2dp_in_record_config(audio, 0);
-		}
-		break;
-	}
-	case AUDPREPROC_CMD_ENC_PARAM_CFG_DONE_MSG: {
-		MM_DBG("CMD_ENC_PARAM_CFG_DONE_MSG \n");
-		auda2dp_in_mem_config(audio);
-		break;
-	}
-	case AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG_DONE_MSG: {
-		MM_DBG("AFE_CMD_AUDIO_RECORD_CFG_DONE_MSG \n");
-		wake_up(&audio->wait_enable);
-		break;
-	}
-	default:
-		MM_ERR("Unknown Event id %d\n", id);
-	}
-}
-
-/* ------------------- dsp audrec event handler--------------------- */
-static void audrec_dsp_event(void *data, unsigned id, size_t len,
-			    void (*getevent)(void *ptr, size_t len))
-{
-	struct audio_a2dp_in *audio = data;
-
-	switch (id) {
-	case AUDREC_CMD_MEM_CFG_DONE_MSG: {
-		MM_DBG("CMD_MEM_CFG_DONE MSG DONE\n");
-		audio->running = 1;
-		if (audio->dev_cnt > 0)
-			auda2dp_in_record_config(audio, 1);
-		break;
-	}
-	case AUDREC_FATAL_ERR_MSG: {
-		struct audrec_fatal_err_msg fatal_err_msg;
-
-		getevent(&fatal_err_msg, AUDREC_FATAL_ERR_MSG_LEN);
-		MM_ERR("FATAL_ERR_MSG: err id %d\n",
-				fatal_err_msg.audrec_err_id);
-		/* Error stop the encoder */
-		audio->stopped = 1;
-		wake_up(&audio->wait);
-		break;
-	}
-	case AUDREC_UP_PACKET_READY_MSG: {
-		struct audrec_up_pkt_ready_msg pkt_ready_msg;
-
-		getevent(&pkt_ready_msg, AUDREC_UP_PACKET_READY_MSG_LEN);
-		MM_DBG("UP_PACKET_READY_MSG: write cnt lsw  %d \
-		write cnt msw %d read cnt lsw %d  read cnt msw %d \n",\
-		pkt_ready_msg.audrec_packet_write_cnt_lsw, \
-		pkt_ready_msg.audrec_packet_write_cnt_msw, \
-		pkt_ready_msg.audrec_up_prev_read_cnt_lsw, \
-		pkt_ready_msg.audrec_up_prev_read_cnt_msw);
-
-		auda2dp_in_get_dsp_frames(audio);
-		break;
-	}
-	case ADSP_MESSAGE_ID: {
-		MM_DBG("Received ADSP event: module audrectask\n");
-		break;
-	}
-	default:
-		MM_ERR("Unknown Event id %d\n", id);
-	}
-}
-
-static void auda2dp_in_get_dsp_frames(struct audio_a2dp_in *audio)
-{
-	struct audio_frame *frame;
-	uint32_t index;
-	unsigned long flags;
-
-	index = audio->in_head;
-
-	frame = (void *) (((char *)audio->in[index].data) - \
-			 sizeof(*frame));
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (audio->enc_type == ENC_TYPE_WAV)
-		audio->in[index].size = frame->a2dp.wav.frame_length;
-	else if (audio->enc_type == ENC_TYPE_SBC) {
-		audio->in[index].size = frame->a2dp.sbc.frame_length *
-						frame->a2dp.sbc.frame_num;
-		audio->in[index].frame_num = frame->a2dp.sbc.frame_num;
-		audio->in[index].frame_len = frame->a2dp.sbc.frame_length;
-	}
-
-	/* statistics of read */
-	atomic_add(audio->in[index].size, &audio->in_bytes);
-	atomic_add(1, &audio->in_samples);
-
-	audio->in_head = (audio->in_head + 1) & (FRAME_NUM - 1);
-
-	/* If overflow, move the tail index foward. */
-	if (audio->in_head == audio->in_tail)
-		audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
-	else
-		audio->in_count++;
-
-	auda2dp_dsp_read_buffer(audio, audio->dsp_cnt++);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	wake_up(&audio->wait);
-}
-
-static struct msm_adsp_ops audrec_adsp_ops = {
-	.event = audrec_dsp_event,
-};
-
-static int auda2dp_in_enc_config(struct audio_a2dp_in *audio, int enable)
-{
-	struct audpreproc_audrec_cmd_enc_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	if (audio->build_id[17] == '1') {
-		cmd.cmd_id = AUDPREPROC_AUDREC_CMD_ENC_CFG_2;
-	} else {
-		cmd.cmd_id = AUDPREPROC_AUDREC_CMD_ENC_CFG;
-	}
-	cmd.stream_id = audio->enc_id;
-
-	if (enable)
-		cmd.audrec_enc_type = audio->enc_type | ENCODE_ENABLE;
-	else
-		cmd.audrec_enc_type &= ~(ENCODE_ENABLE);
-
-	return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd));
-}
-
-static int auda2dp_in_param_config(struct audio_a2dp_in *audio)
-{
-	if (audio->enc_type == ENC_TYPE_WAV) {
-		struct audpreproc_audrec_cmd_parm_cfg_wav cmd;
-
-		memset(&cmd, 0, sizeof(cmd));
-		cmd.common.cmd_id = AUDPREPROC_AUDREC_CMD_PARAM_CFG;
-		cmd.common.stream_id = audio->enc_id;
-
-		cmd.aud_rec_samplerate_idx = audio->samp_rate;
-		cmd.aud_rec_stereo_mode = audio->channel_mode;
-		return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd));
-	} else if (audio->enc_type == ENC_TYPE_SBC) {
-		struct audpreproc_audrec_cmd_parm_cfg_sbc cmd;
-
-		memset(&cmd, 0, sizeof(cmd));
-		cmd.common.cmd_id = AUDPREPROC_AUDREC_CMD_PARAM_CFG;
-		cmd.common.stream_id = audio->enc_id;
-		cmd.aud_rec_sbc_enc_param =
-			(audio->cfg.number_of_blocks <<
-			AUDREC_SBC_ENC_PARAM_NUM_SUB_BLOCKS_MASK) |
-			(audio->cfg.number_of_subbands <<
-			AUDREC_SBC_ENC_PARAM_NUM_SUB_BANDS_MASK) |
-			(audio->cfg.mode <<
-			AUDREC_SBC_ENC_PARAM_MODE_MASK) |
-			(audio->cfg.bit_allocation <<
-			AUDREC_SBC_ENC_PARAM_BIT_ALLOC_MASK);
-		cmd.aud_rec_sbc_bit_rate_msw =
-			(audio->cfg.bit_rate & 0xFFFF0000) >> 16;
-		cmd.aud_rec_sbc_bit_rate_lsw =
-			(audio->cfg.bit_rate & 0xFFFF);
-		return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd));
-	}
-	return 0;
-}
-
-/* To Do: msm_snddev_route_enc(audio->enc_id); */
-static int auda2dp_in_record_config(struct audio_a2dp_in *audio, int enable)
-{
-	struct audpreproc_afe_cmd_audio_record_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG;
-	cmd.stream_id = audio->enc_id;
-	if (enable)
-		cmd.destination_activity = AUDIO_RECORDING_TURN_ON;
-	else
-		cmd.destination_activity = AUDIO_RECORDING_TURN_OFF;
-
-	cmd.source_mix_mask = audio->source;
-	if (audio->enc_id == 2) {
-		if ((cmd.source_mix_mask &
-				INTERNAL_CODEC_TX_SOURCE_MIX_MASK) ||
-			(cmd.source_mix_mask & AUX_CODEC_TX_SOURCE_MIX_MASK) ||
-			(cmd.source_mix_mask & VOICE_UL_SOURCE_MIX_MASK) ||
-			(cmd.source_mix_mask & VOICE_DL_SOURCE_MIX_MASK)) {
-			cmd.pipe_id = SOURCE_PIPE_1;
-		}
-		if (cmd.source_mix_mask &
-				AUDPP_A2DP_PIPE_SOURCE_MIX_MASK)
-			cmd.pipe_id |= SOURCE_PIPE_0;
-	}
-	return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd));
-}
-
-static int auda2dp_in_mem_config(struct audio_a2dp_in *audio)
-{
-	struct audrec_cmd_arecmem_cfg cmd;
-	uint16_t *data = (void *) audio->data;
-	int n;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_MEM_CFG_CMD;
-	cmd.audrec_up_pkt_intm_count = 1;
-	cmd.audrec_ext_pkt_start_addr_msw = audio->phys >> 16;
-	cmd.audrec_ext_pkt_start_addr_lsw = audio->phys;
-	cmd.audrec_ext_pkt_buf_number = FRAME_NUM;
-
-	/* prepare buffer pointers:
-	 * Wav:
-	 * Mono: 1024 samples + 4 halfword header
-	 * Stereo: 2048 samples + 4 halfword header
-	 * SBC:
-	 * 768 + 4 halfword header
-	 */
-	if (audio->enc_type == ENC_TYPE_SBC) {
-		for (n = 0; n < FRAME_NUM; n++) {
-			audio->in[n].data = data + 4;
-			data += (4 + (FRAME_SIZE_SBC/2));
-			MM_DBG("0x%8x\n", (int)(audio->in[n].data - 8));
-		}
-	} else if (audio->enc_type == ENC_TYPE_WAV) {
-		for (n = 0; n < FRAME_NUM; n++) {
-			audio->in[n].data = data + 4;
-			data += (4 + (audio->channel_mode ? 2048 : 1024));
-			MM_DBG("0x%8x\n", (int)(audio->in[n].data - 8));
-		}
-	}
-
-	return audrec_send_audrecqueue(audio, &cmd, sizeof(cmd));
-}
-
-static int auda2dp_dsp_read_buffer(struct audio_a2dp_in *audio,
-							uint32_t read_cnt)
-{
-	struct up_audrec_packet_ext_ptr cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = UP_AUDREC_PACKET_EXT_PTR;
-	cmd.audrec_up_curr_read_count_msw = read_cnt >> 16;
-	cmd.audrec_up_curr_read_count_lsw = read_cnt;
-
-	return audrec_send_bitstreamqueue(audio, &cmd, sizeof(cmd));
-}
-
-/* must be called with audio->lock held */
-static int auda2dp_in_enable(struct audio_a2dp_in *audio)
-{
-	if (audio->enabled)
-		return 0;
-
-	if (audpreproc_enable(audio->enc_id, &audpreproc_dsp_event, audio)) {
-		MM_ERR("msm_adsp_enable(audpreproc) failed\n");
-		return -ENODEV;
-	}
-
-	if (msm_adsp_enable(audio->audrec)) {
-		MM_ERR("msm_adsp_enable(audrec) failed\n");
-		audpreproc_disable(audio->enc_id, audio);
-		return -ENODEV;
-	}
-	audio->enabled = 1;
-	auda2dp_in_enc_config(audio, 1);
-
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int auda2dp_in_disable(struct audio_a2dp_in *audio)
-{
-	if (audio->enabled) {
-		audio->enabled = 0;
-		auda2dp_in_enc_config(audio, 0);
-		wake_up(&audio->wait);
-		wait_event_interruptible_timeout(audio->wait_enable,
-				audio->running == 0, 1*HZ);
-		msm_adsp_disable(audio->audrec);
-		audpreproc_disable(audio->enc_id, audio);
-	}
-	return 0;
-}
-
-static void auda2dp_in_flush(struct audio_a2dp_in *audio)
-{
-	int i;
-
-	audio->dsp_cnt = 0;
-	audio->in_head = 0;
-	audio->in_tail = 0;
-	audio->in_count = 0;
-	for (i = 0; i < FRAME_NUM; i++) {
-		audio->in[i].size = 0;
-		audio->in[i].read = 0;
-	}
-	MM_DBG("in_bytes %d\n", atomic_read(&audio->in_bytes));
-	MM_DBG("in_samples %d\n", atomic_read(&audio->in_samples));
-	atomic_set(&audio->in_bytes, 0);
-	atomic_set(&audio->in_samples, 0);
-}
-
-/* ------------------- device --------------------- */
-static long auda2dp_in_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct audio_a2dp_in *audio = file->private_data;
-	int rc = 0;
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		stats.byte_count = atomic_read(&audio->in_bytes);
-		stats.sample_count = atomic_read(&audio->in_samples);
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return rc;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START: {
-		uint32_t freq;
-		/* Poll at 48KHz always */
-		freq = 48000;
-		MM_DBG("AUDIO_START\n");
-		rc = msm_snddev_request_freq(&freq, audio->enc_id,
-					SNDDEV_CAP_TX, AUDDEV_CLNT_ENC);
-		MM_DBG("sample rate configured %d sample rate requested %d\n",
-				freq, audio->samp_rate);
-		if (rc < 0) {
-			MM_DBG("sample rate can not be set, return code %d\n",\
-							rc);
-			msm_snddev_withdraw_freq(audio->enc_id,
-						SNDDEV_CAP_TX, AUDDEV_CLNT_ENC);
-			MM_DBG("msm_snddev_withdraw_freq\n");
-			break;
-		}
-		/*update aurec session info in audpreproc layer*/
-		audio->session_info.session_id = audio->enc_id;
-		audio->session_info.sampling_freq = audio->samp_rate;
-		audpreproc_update_audrec_info(&audio->session_info);
-		rc = auda2dp_in_enable(audio);
-		if (!rc) {
-			rc =
-			wait_event_interruptible_timeout(audio->wait_enable,
-				audio->running != 0, 1*HZ);
-			MM_DBG("state %d rc = %d\n", audio->running, rc);
-
-			if (audio->running == 0) {
-				rc = -ENODEV;
-				msm_snddev_withdraw_freq(audio->enc_id,
-					SNDDEV_CAP_TX, AUDDEV_CLNT_ENC);
-				MM_DBG("msm_snddev_withdraw_freq\n");
-			} else
-				rc = 0;
-		}
-		audio->stopped = 0;
-		break;
-	}
-	case AUDIO_STOP: {
-		/*reset the sampling frequency information at audpreproc layer*/
-		audio->session_info.sampling_freq = 0;
-		audpreproc_update_audrec_info(&audio->session_info);
-		rc = auda2dp_in_disable(audio);
-		rc = msm_snddev_withdraw_freq(audio->enc_id,
-					SNDDEV_CAP_TX, AUDDEV_CLNT_ENC);
-		MM_DBG("msm_snddev_withdraw_freq\n");
-		audio->stopped = 1;
-		audio->abort = 0;
-		break;
-	}
-	case AUDIO_FLUSH: {
-		if (audio->stopped) {
-			/* Make sure we're stopped and we wake any threads
-			 * that might be blocked holding the read_lock.
-			 * While audio->stopped read threads will always
-			 * exit immediately.
-			 */
-			wake_up(&audio->wait);
-			mutex_lock(&audio->read_lock);
-			auda2dp_in_flush(audio);
-			mutex_unlock(&audio->read_lock);
-		}
-		break;
-	}
-	case AUDIO_SET_STREAM_CONFIG: {
-		struct msm_audio_stream_config cfg;
-		if (copy_from_user(&cfg, (void *) arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		/* Allow only single frame */
-		if ((audio->enc_type == ENC_TYPE_SBC) &&
-				(cfg.buffer_size != FRAME_SIZE_SBC))
-			rc = -EINVAL;
-		else
-			audio->buffer_size = cfg.buffer_size;
-		break;
-	}
-	case AUDIO_GET_STREAM_CONFIG: {
-		struct msm_audio_stream_config cfg;
-		memset(&cfg, 0, sizeof(cfg));
-		if (audio->enc_type == ENC_TYPE_SBC)
-			cfg.buffer_size = FRAME_SIZE_SBC;
-		else
-			cfg.buffer_size = MONO_DATA_SIZE;
-		cfg.buffer_count = FRAME_NUM;
-		if (copy_to_user((void *) arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		break;
-	}
-	case AUDIO_SET_SBC_ENC_CONFIG: {
-		if (copy_from_user(&audio->cfg, (void *) arg,
-						sizeof(audio->cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		audio->samp_rate = audio->cfg.sample_rate;
-		audio->channel_mode = audio->cfg.channels;
-		audio->enc_type = ENC_TYPE_SBC;
-		break;
-	}
-	case AUDIO_SET_CONFIG: {
-		struct msm_audio_config cfg;
-		if (copy_from_user(&cfg, (void *) arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (cfg.channel_count == 1) {
-			cfg.channel_count = AUDREC_CMD_MODE_MONO;
-			audio->buffer_size = MONO_DATA_SIZE;
-		} else if (cfg.channel_count == 2) {
-			cfg.channel_count = AUDREC_CMD_MODE_STEREO;
-			audio->buffer_size = STEREO_DATA_SIZE;
-		} else {
-			rc = -EINVAL;
-			break;
-		}
-		audio->samp_rate = cfg.sample_rate;
-		audio->channel_mode = cfg.channel_count;
-		audio->enc_type = ENC_TYPE_WAV;
-		break;
-	}
-	case AUDIO_GET_SBC_ENC_CONFIG: {
-		struct msm_audio_sbc_enc_config cfg;
-		memset(&cfg, 0, sizeof(cfg));
-		cfg.bit_allocation = audio->cfg.bit_allocation;
-		cfg.mode =  audio->cfg.mode;
-		cfg.number_of_subbands = audio->cfg.number_of_subbands;
-		cfg.number_of_blocks = audio->cfg.number_of_blocks;
-		cfg.sample_rate = audio->samp_rate;
-		cfg.channels = audio->channel_mode;
-		cfg.bit_rate = audio->cfg.bit_rate;
-		if (copy_to_user((void *) arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config cfg;
-		memset(&cfg, 0, sizeof(cfg));
-		cfg.buffer_count = FRAME_NUM;
-		cfg.sample_rate = audio->samp_rate;
-		if (audio->channel_mode == AUDREC_CMD_MODE_MONO) {
-			cfg.channel_count = 1;
-			cfg.buffer_size = MONO_DATA_SIZE;
-		} else {
-			cfg.channel_count = 2;
-			cfg.buffer_size = STEREO_DATA_SIZE;
-		}
-		cfg.type = ENC_TYPE_WAV;
-		if (copy_to_user((void *) arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		break;
-	}
-	case AUDIO_GET_SESSION_ID: {
-		if (copy_to_user((void *) arg, &audio->enc_id,
-			sizeof(unsigned short))) {
-			rc = -EFAULT;
-		}
-		break;
-	}
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static ssize_t auda2dp_in_read(struct file *file,
-				char __user *buf,
-				size_t count, loff_t *pos)
-{
-	struct audio_a2dp_in *audio = file->private_data;
-	unsigned long flags;
-	const char __user *start = buf;
-	void *data;
-	uint32_t index;
-	uint32_t size;
-	int rc = 0;
-	uint32_t f_len = 0, f_num = 0;
-	int i = 0;
-
-	mutex_lock(&audio->read_lock);
-	while (count > 0) {
-		rc = wait_event_interruptible(
-			audio->wait, (audio->in_count > 0) || audio->stopped ||
-			audio->abort);
-
-		if (rc < 0)
-			break;
-
-		if (audio->stopped && !audio->in_count) {
-			MM_DBG("Driver in stop state, No more buffer to read");
-			rc = 0;/* End of File */
-			break;
-		}
-
-		if (audio->abort) {
-			rc = -EPERM; /* Not permitted due to abort */
-			break;
-		}
-
-		index = audio->in_tail;
-		data = (uint8_t *) audio->in[index].data;
-		size = audio->in[index].size;
-		if (count >= size) {
-			if (audio->enc_type == ENC_TYPE_SBC &&
-				(audio->in[index].frame_len % 2)) {
-				f_len = audio->in[index].frame_len;
-				f_num = audio->in[index].frame_num;
-				for (i = 0; i < f_num; i++) {
-					if (copy_to_user(&buf[i * f_len],
-					(uint8_t *) (data + (i * (f_len + 1))),
-					f_len)) {
-						rc = -EFAULT;
-						break;
-					}
-				}
-			} else {
-				if (copy_to_user(buf, data, size)) {
-					rc = -EFAULT;
-					break;
-				}
-			}
-			spin_lock_irqsave(&audio->dsp_lock, flags);
-			if (index != audio->in_tail) {
-				/* overrun -- data is
-				 * invalid and we need to retry */
-				spin_unlock_irqrestore(&audio->dsp_lock, flags);
-				continue;
-			}
-			audio->in[index].size = 0;
-			audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
-			audio->in_count--;
-			spin_unlock_irqrestore(&audio->dsp_lock, flags);
-			count -= size;
-			buf += size;
-		} else {
-			MM_ERR("short read\n");
-			break;
-		}
-	}
-	mutex_unlock(&audio->read_lock);
-	if (buf > start)
-		return buf - start;
-
-	return rc;
-}
-
-static ssize_t auda2dp_in_write(struct file *file,
-				const char __user *buf,
-				size_t count, loff_t *pos)
-{
-	return -EINVAL;
-}
-
-static int auda2dp_in_release(struct inode *inode, struct file *file)
-{
-	struct audio_a2dp_in *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	/* with draw frequency for session
-	   incase not stopped the driver */
-	msm_snddev_withdraw_freq(audio->enc_id, SNDDEV_CAP_TX,
-					AUDDEV_CLNT_ENC);
-	auddev_unregister_evt_listner(AUDDEV_CLNT_ENC, audio->enc_id);
-	/*reset the sampling frequency information at audpreproc layer*/
-	audio->session_info.sampling_freq = 0;
-	audpreproc_update_audrec_info(&audio->session_info);
-	auda2dp_in_disable(audio);
-	auda2dp_in_flush(audio);
-	msm_adsp_put(audio->audrec);
-	audpreproc_aenc_free(audio->enc_id);
-	audio->audrec = NULL;
-	audio->opened = 0;
-	if (audio->data) {
-		ion_unmap_kernel(audio->client, audio->output_buff_handle);
-		ion_free(audio->client, audio->output_buff_handle);
-		audio->data = NULL;
-	}
-	ion_client_destroy(audio->client);
-	mutex_unlock(&audio->lock);
-	return 0;
-}
-
-static int auda2dp_in_open(struct inode *inode, struct file *file)
-{
-	struct audio_a2dp_in *audio = &the_audio_a2dp_in;
-	int rc;
-	int encid;
-	int len = 0;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	struct ion_client *client = NULL;
-
-	mutex_lock(&audio->lock);
-	if (audio->opened) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	client = msm_ion_client_create(UINT_MAX, "Audio_a2dp_in_client");
-	if (IS_ERR_OR_NULL(client)) {
-		MM_ERR("Unable to create ION client\n");
-			rc = -ENOMEM;
-		goto client_create_error;
-	}
-	audio->client = client;
-
-	MM_DBG("allocating mem sz = %d\n", DMASZ);
-	handle = ion_alloc(client, DMASZ, SZ_4K,
-		ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-	if (IS_ERR_OR_NULL(handle)) {
-		MM_ERR("Unable to create allocate O/P buffers\n");
-		rc = -ENOMEM;
-		goto output_buff_alloc_error;
-		}
-
-	audio->output_buff_handle = handle;
-
-	rc = ion_phys(client , handle, &addr, &len);
-	if (rc) {
-		MM_ERR("O/P buffers:Invalid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-		rc = -ENOMEM;
-		goto output_buff_get_phys_error;
-	} else {
-		MM_INFO("O/P buffers:valid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-	}
-	audio->phys = (int32_t)addr;
-
-	rc = ion_handle_get_flags(client, handle, &ionflag);
-	if (rc) {
-		MM_ERR("could not get flags for the handle\n");
-		rc = -ENOMEM;
-		goto output_buff_get_flags_error;
-	}
-
-	audio->msm_map = ion_map_kernel(client, handle);
-	if (IS_ERR(audio->data)) {
-		MM_ERR("could not map read buffers,freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENOMEM;
-		goto output_buff_map_error;
-	}
-	MM_DBG("read buf: phy addr 0x%08x kernel addr 0x%08x\n",
-		audio->phys, (int)audio->data);
-
-	audio->data = (char *)audio->msm_map;
-
-	MM_DBG("Memory addr = 0x%8x  phy addr = 0x%8x\n",\
-		(int) audio->data, (int) audio->phys);
-
-	if ((file->f_mode & FMODE_WRITE) &&
-				(file->f_mode & FMODE_READ)) {
-		rc = -EACCES;
-		MM_ERR("Non tunnel encoding is not supported\n");
-		goto done;
-	} else if (!(file->f_mode & FMODE_WRITE) &&
-					(file->f_mode & FMODE_READ)) {
-		audio->mode = MSM_AUD_ENC_MODE_TUNNEL;
-		MM_DBG("Opened for Tunnel mode encoding\n");
-	} else {
-		rc = -EACCES;
-		goto done;
-	}
-	/* Settings will be re-config at AUDIO_SET_CONFIG/SBC_ENC_CONFIG,
-	 * but at least we need to have initial config
-	 */
-	audio->channel_mode = AUDREC_CMD_MODE_MONO;
-	audio->buffer_size = FRAME_SIZE_SBC;
-	audio->samp_rate = 48000;
-	audio->enc_type = ENC_TYPE_SBC | audio->mode;
-	audio->cfg.bit_allocation = AUDIO_SBC_BA_SNR;
-	audio->cfg.mode = AUDIO_SBC_MODE_JSTEREO;
-	audio->cfg.number_of_subbands = AUDIO_SBC_BANDS_8;
-	audio->cfg.number_of_blocks = AUDIO_SBC_BLOCKS_16;
-	audio->cfg.bit_rate = 320000; /* max 512kbps(mono), 320kbs(others) */
-
-	encid = audpreproc_aenc_alloc(audio->enc_type, &audio->module_name,
-			&audio->queue_ids);
-	if (encid < 0) {
-		MM_ERR("No free encoder available\n");
-		rc = -ENODEV;
-		goto done;
-	}
-	audio->enc_id = encid;
-
-	rc = msm_adsp_get(audio->module_name, &audio->audrec,
-			   &audrec_adsp_ops, audio);
-
-	if (rc) {
-		audpreproc_aenc_free(audio->enc_id);
-		goto done;
-	}
-
-	audio->stopped = 0;
-	audio->source = 0;
-	audio->abort = 0;
-	auda2dp_in_flush(audio);
-	audio->device_events = AUDDEV_EVT_DEV_RDY | AUDDEV_EVT_DEV_RLS |
-				AUDDEV_EVT_FREQ_CHG;
-
-	rc = auddev_register_evt_listner(audio->device_events,
-					AUDDEV_CLNT_ENC, audio->enc_id,
-					a2dp_in_listener, (void *) audio);
-	if (rc) {
-		MM_ERR("failed to register device event listener\n");
-		goto evt_error;
-	}
-	audio->build_id = socinfo_get_build_id();
-	MM_DBG("Modem build id = %s\n", audio->build_id);
-	file->private_data = audio;
-	audio->opened = 1;
-	rc = 0;
-done:
-	mutex_unlock(&audio->lock);
-	return rc;
-evt_error:
-output_buff_map_error:
-output_buff_get_phys_error:
-output_buff_get_flags_error:
-	 ion_free(client, audio->output_buff_handle);
-output_buff_alloc_error:
-	    ion_client_destroy(client);
-client_create_error:
-	msm_adsp_put(audio->audrec);
-	audpreproc_aenc_free(audio->enc_id);
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static const struct file_operations audio_a2dp_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= auda2dp_in_open,
-	.release	= auda2dp_in_release,
-	.read		= auda2dp_in_read,
-	.write		= auda2dp_in_write,
-	.unlocked_ioctl	= auda2dp_in_ioctl,
-};
-
-struct miscdevice audio_a2dp_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_a2dp_in",
-	.fops	= &audio_a2dp_in_fops,
-};
-
-static int __init auda2dp_in_init(void)
-{
-	mutex_init(&the_audio_a2dp_in.lock);
-	mutex_init(&the_audio_a2dp_in.read_lock);
-	spin_lock_init(&the_audio_a2dp_in.dsp_lock);
-	spin_lock_init(&the_audio_a2dp_in.dev_lock);
-	init_waitqueue_head(&the_audio_a2dp_in.wait);
-	init_waitqueue_head(&the_audio_a2dp_in.wait_enable);
-	return misc_register(&audio_a2dp_in_misc);
-}
-
-device_initcall(auda2dp_in_init);
-
-MODULE_DESCRIPTION("MSM SBC encode driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5v2/audio_aac.c b/arch/arm/mach-msm/qdsp5v2/audio_aac.c
deleted file mode 100644
index fbce5d6..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audio_aac.c
+++ /dev/null
@@ -1,2036 +0,0 @@
-/*
- * aac audio decoder device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2008-2012, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/list.h>
-#include <linux/earlysuspend.h>
-#include <linux/slab.h>
-#include <linux/msm_audio_aac.h>
-#include <linux/memory_alloc.h>
-
-#include <mach/msm_adsp.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/qdsp5v2/qdsp5audppmsg.h>
-#include <mach/qdsp5v2/qdsp5audplaycmdi.h>
-#include <mach/qdsp5v2/qdsp5audplaymsg.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/qdsp5v2/audpp.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_memtypes.h>
-
-
-#define BUFSZ 32768
-#define DMASZ (BUFSZ * 2)
-#define BUFSZ_MIN 4096
-#define DMASZ_MIN (BUFSZ_MIN * 2)
-
-#define AUDPLAY_INVALID_READ_PTR_OFFSET	0xFFFF
-#define AUDDEC_DEC_AAC 5
-
-#define PCM_BUFSZ_MIN 9600	/* Hold one stereo AAC frame */
-#define PCM_BUF_MAX_COUNT 5	/* DSP only accepts 5 buffers at most
-				   but support 2 buffers currently */
-#define ROUTING_MODE_FTRT 1
-#define ROUTING_MODE_RT 2
-/* Decoder status received from AUDPPTASK */
-#define  AUDPP_DEC_STATUS_SLEEP	0
-#define	 AUDPP_DEC_STATUS_INIT  1
-#define  AUDPP_DEC_STATUS_CFG   2
-#define  AUDPP_DEC_STATUS_PLAY  3
-
-#define AUDAAC_METAFIELD_MASK 0xFFFF0000
-#define AUDAAC_EOS_FLG_OFFSET 0x0A /* Offset from beginning of buffer */
-#define AUDAAC_EOS_FLG_MASK 0x01
-#define AUDAAC_EOS_NONE 0x0 /* No EOS detected */
-#define AUDAAC_EOS_SET 0x1 /* EOS set in meta field */
-
-#define AUDAAC_EVENT_NUM 10 /* Default number of pre-allocated event packets */
-
-#define BITSTREAM_ERROR_THRESHOLD_VALUE 0x1 /* DEFAULT THRESHOLD VALUE */
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;		/* Input usage actual DSP produced PCM size  */
-	unsigned addr;
-	unsigned short mfield_sz; /*only useful for data has meta field */
-};
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-struct audaac_suspend_ctl {
-	struct early_suspend node;
-	struct audio *audio;
-};
-#endif
-
-struct audaac_event{
-	struct list_head list;
-	int event_type;
-	union msm_audio_event_payload payload;
-};
-
-struct audio {
-	struct buffer out[2];
-
-	spinlock_t dsp_lock;
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed;	/* number of buffers the dsp is waiting for */
-	unsigned out_dma_sz;
-
-	atomic_t out_bytes;
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-
-	/* Host PCM section */
-	struct buffer in[PCM_BUF_MAX_COUNT];
-	struct mutex read_lock;
-	wait_queue_head_t read_wait;	/* Wait queue for read */
-	char *read_data;	/* pointer to reader buffer */
-	int32_t read_phys;	/* physical address of reader buffer */
-	uint8_t read_next;	/* index to input buffers to be read next */
-	uint8_t fill_next;	/* index to buffer that DSP should be filling */
-	uint8_t pcm_buf_count;	/* number of pcm buffer allocated */
-	/* ---- End of Host PCM section */
-
-	struct msm_adsp_module *audplay;
-
-	/* configuration to use on next enable */
-	uint32_t out_sample_rate;
-	uint32_t out_channel_mode;
-	struct msm_audio_aac_config aac_config;
-
-	/* AV sync Info */
-	int avsync_flag;              /* Flag to indicate feedback from DSP */
-	wait_queue_head_t avsync_wait;/* Wait queue for AV Sync Message     */
-	/* 48 bits sample/bytes counter per channel */
-	uint16_t avsync[AUDPP_AVSYNC_CH_COUNT * AUDPP_AVSYNC_NUM_WORDS + 1];
-
-	/* data allocated for various buffers */
-	char *data;
-	int32_t phys; /* physical address of write buffer */
-	void *map_v_read;
-	void *map_v_write;
-
-	int mfield; /* meta field embedded in data */
-	int rflush; /* Read  flush */
-	int wflush; /* Write flush */
-	int opened;
-	int enabled;
-	int running;
-	int stopped;	/* set when stopped, cleared on flush */
-	int pcm_feedback;
-	int buf_refresh;
-	int teos; /* valid only if tunnel mode & no data left for decoder */
-	enum msm_aud_decoder_state dec_state;	/* Represents decoder state */
-	int reserved; /* A byte is being reserved */
-	char rsv_byte; /* Handle odd length user data */
-
-	const char *module_name;
-	unsigned queue_id;
-	uint16_t dec_id;
-	uint32_t read_ptr_offset;
-	int16_t source;
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	struct audaac_suspend_ctl suspend_ctl;
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *dentry;
-#endif
-
-	wait_queue_head_t wait;
-	struct list_head free_event_queue;
-	struct list_head event_queue;
-	wait_queue_head_t event_wait;
-	spinlock_t event_queue_lock;
-	struct mutex get_event_lock;
-	int event_abort;
-	uint32_t device_events;
-
-	struct msm_audio_bitstream_info stream_info;
-	struct msm_audio_bitstream_error_info bitstream_error_info;
-	uint32_t bitstream_error_threshold_value;
-
-	int eq_enable;
-	int eq_needs_commit;
-	struct audpp_cmd_cfg_object_params_eqalizer eq;
-	struct audpp_cmd_cfg_object_params_volume vol_pan;
-};
-
-static int auddec_dsp_config(struct audio *audio, int enable);
-static void audpp_cmd_cfg_adec_params(struct audio *audio);
-static void audpp_cmd_cfg_routing_mode(struct audio *audio);
-static void audplay_send_data(struct audio *audio, unsigned needed);
-static void audplay_error_threshold_config(struct audio *audio);
-static void audplay_config_hostpcm(struct audio *audio);
-static void audplay_buffer_refresh(struct audio *audio);
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg);
-static void audaac_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload);
-
-/* must be called with audio->lock held */
-static int audio_enable(struct audio *audio)
-{
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	if (audio->enabled)
-		return 0;
-
-	audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-
-	if (msm_adsp_enable(audio->audplay)) {
-		MM_ERR("msm_adsp_enable(audplay) failed\n");
-		return -ENODEV;
-	}
-
-	if (audpp_enable(audio->dec_id, audio_dsp_event, audio)) {
-		MM_ERR("audpp_enable() failed\n");
-		msm_adsp_disable(audio->audplay);
-		return -ENODEV;
-	}
-	audio->enabled = 1;
-	return 0;
-}
-
-static void aac_listner(u32 evt_id, union auddev_evt_data *evt_payload,
-			void *private_data)
-{
-	struct audio *audio = (struct audio *) private_data;
-	switch (evt_id) {
-	case AUDDEV_EVT_DEV_RDY:
-		MM_DBG(":AUDDEV_EVT_DEV_RDY\n");
-		audio->source |= (0x1 << evt_payload->routing_id);
-		if (audio->running == 1 && audio->enabled == 1)
-			audpp_route_stream(audio->dec_id, audio->source);
-		break;
-	case AUDDEV_EVT_DEV_RLS:
-		MM_DBG(":AUDDEV_EVT_DEV_RLS\n");
-		audio->source &= ~(0x1 << evt_payload->routing_id);
-		if (audio->running == 1 && audio->enabled == 1)
-			audpp_route_stream(audio->dec_id, audio->source);
-		break;
-	case AUDDEV_EVT_STREAM_VOL_CHG:
-		audio->vol_pan.volume = evt_payload->session_vol;
-		MM_DBG(":AUDDEV_EVT_STREAM_VOL_CHG, stream vol %d\n",
-				audio->vol_pan.volume);
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		break;
-	default:
-		MM_ERR(":ERROR:wrong event\n");
-		break;
-	}
-}
-/* must be called with audio->lock held */
-static int audio_disable(struct audio *audio)
-{
-	int rc = 0;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-		auddec_dsp_config(audio, 0);
-		rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-		if (rc == 0)
-			rc = -ETIMEDOUT;
-		else if (audio->dec_state != MSM_AUD_DECODER_STATE_CLOSE)
-			rc = -EFAULT;
-		else
-			rc = 0;
-		wake_up(&audio->write_wait);
-		wake_up(&audio->read_wait);
-		msm_adsp_disable(audio->audplay);
-		audpp_disable(audio->dec_id, audio);
-		audio->out_needed = 0;
-	}
-	return rc;
-}
-
-/* ------------------- dsp --------------------- */
-static void audio_update_pcm_buf_entry(struct audio *audio, uint32_t *payload)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	if (audio->rflush)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < payload[1]; index++) {
-		if (audio->in[audio->fill_next].addr ==
-		    payload[2 + index * 2]) {
-			MM_DBG("in[%d] ready\n", audio->fill_next);
-			audio->in[audio->fill_next].used =
-				payload[3 + index * 2];
-			if ((++audio->fill_next) == audio->pcm_buf_count)
-				audio->fill_next = 0;
-
-		} else {
-			MM_ERR("expected=%x ret=%x\n",
-				audio->in[audio->fill_next].addr,
-				payload[1 + index * 2]);
-			break;
-		}
-	}
-	if (audio->in[audio->fill_next].used == 0) {
-		audplay_buffer_refresh(audio);
-	} else {
-		MM_DBG("read cannot keep up\n");
-		audio->buf_refresh = 1;
-	}
-	wake_up(&audio->read_wait);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-
-}
-
-static void audaac_bitstream_error_info(struct audio *audio, uint32_t *payload)
-{
-	unsigned long flags;
-	union msm_audio_event_payload e_payload;
-
-	if (payload[0] != AUDDEC_DEC_AAC) {
-		MM_ERR("Unexpected bitstream error info from DSP:\
-				Invalid decoder\n");
-		return;
-	}
-
-	/* get stream info from DSP msg */
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-
-	audio->bitstream_error_info.dec_id = payload[0];
-	audio->bitstream_error_info.err_msg_indicator = payload[1];
-	audio->bitstream_error_info.err_type = payload[2];
-
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	MM_ERR("bit_stream_error_type=%d error_count=%d\n",
-			audio->bitstream_error_info.err_type, (0x0000FFFF &
-			audio->bitstream_error_info.err_msg_indicator));
-
-	/* send event to ARM to notify error info coming */
-	e_payload.error_info = audio->bitstream_error_info;
-	audaac_post_event(audio, AUDIO_EVENT_BITSTREAM_ERROR_INFO, e_payload);
-}
-
-static void audaac_update_stream_info(struct audio *audio, uint32_t *payload)
-{
-	unsigned long flags;
-	union msm_audio_event_payload e_payload;
-
-	/* get stream info from DSP msg */
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-
-	audio->stream_info.codec_type = AUDIO_CODEC_TYPE_AAC;
-	audio->stream_info.chan_info = (0x0000FFFF & payload[1]);
-	audio->stream_info.sample_rate = (0x0000FFFF & payload[2]);
-	audio->stream_info.bit_stream_info = (0x0000FFFF & payload[3]);
-	audio->stream_info.bit_rate = payload[4];
-
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	MM_DBG("chan_info=%d, sample_rate=%d, bit_stream_info=%d\n",
-			audio->stream_info.chan_info,
-			audio->stream_info.sample_rate,
-			audio->stream_info.bit_stream_info);
-
-	/* send event to ARM to notify steam info coming */
-	e_payload.stream_info = audio->stream_info;
-	audaac_post_event(audio, AUDIO_EVENT_STREAM_INFO, e_payload);
-}
-static void audplay_dsp_event(void *data, unsigned id, size_t len,
-			      void (*getevent) (void *ptr, size_t len))
-{
-	struct audio *audio = data;
-	uint32_t msg[28];
-	getevent(msg, sizeof(msg));
-
-	MM_DBG("msg_id=%x\n", id);
-
-	switch (id) {
-	case AUDPLAY_MSG_DEC_NEEDS_DATA:
-		audplay_send_data(audio, 1);
-		break;
-
-	case AUDPLAY_MSG_BUFFER_UPDATE:
-		audio_update_pcm_buf_entry(audio, msg);
-		break;
-
-	case AUDPLAY_UP_STREAM_INFO:
-		if ((msg[1] & AUDPLAY_STREAM_INFO_MSG_MASK) ==
-				AUDPLAY_STREAM_INFO_MSG_MASK) {
-			audaac_bitstream_error_info(audio, msg);
-		} else {
-			audaac_update_stream_info(audio, msg);
-		}
-		break;
-
-	case AUDPLAY_UP_OUTPORT_FLUSH_ACK:
-		MM_DBG("OUTPORT_FLUSH_ACK\n");
-		audio->rflush = 0;
-		wake_up(&audio->read_wait);
-		if (audio->pcm_feedback)
-			audplay_buffer_refresh(audio);
-		break;
-
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audplaytask)\n");
-		break;
-
-	default:
-		MM_ERR("unexpected message from decoder \n");
-	}
-}
-
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg)
-{
-	struct audio *audio = private;
-
-	switch (id) {
-	case AUDPP_MSG_STATUS_MSG:{
-			unsigned status = msg[1];
-
-			switch (status) {
-			case AUDPP_DEC_STATUS_SLEEP: {
-				uint16_t reason = msg[2];
-				MM_DBG("decoder status: sleep reason = \
-						0x%04x\n", reason);
-				if ((reason == AUDPP_MSG_REASON_MEM)
-					|| (reason ==
-					AUDPP_MSG_REASON_NODECODER)) {
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_FAILURE;
-					wake_up(&audio->wait);
-				} else if (reason == AUDPP_MSG_REASON_NONE) {
-					/* decoder is in disable state */
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_CLOSE;
-					wake_up(&audio->wait);
-				}
-				break;
-			}
-			case AUDPP_DEC_STATUS_INIT:
-				MM_DBG("decoder status: init \n");
-				if (audio->pcm_feedback)
-					audpp_cmd_cfg_routing_mode(audio);
-				else
-					audpp_cmd_cfg_adec_params(audio);
-				break;
-
-			case AUDPP_DEC_STATUS_CFG:
-				MM_DBG("decoder status: cfg \n");
-				break;
-			case AUDPP_DEC_STATUS_PLAY:
-				MM_DBG("decoder status: play \n");
-				/* send  mixer command */
-				audpp_route_stream(audio->dec_id,
-						audio->source);
-				if (audio->pcm_feedback) {
-					audplay_error_threshold_config(audio);
-					audplay_config_hostpcm(audio);
-					audplay_buffer_refresh(audio);
-				}
-				audio->dec_state =
-					MSM_AUD_DECODER_STATE_SUCCESS;
-				wake_up(&audio->wait);
-				break;
-			default:
-				MM_ERR("unknown decoder status \n");
-			}
-			break;
-		}
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_DBG("CFG_MSG ENABLE\n");
-			auddec_dsp_config(audio, 1);
-			audio->out_needed = 0;
-			audio->running = 1;
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-			audpp_dsp_set_eq(audio->dec_id, audio->eq_enable,
-					&audio->eq, POPP);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			MM_DBG("CFG_MSG DISABLE\n");
-			audio->running = 0;
-		} else {
-			MM_DBG("CFG_MSG %d?\n",	msg[0]);
-		}
-		break;
-	case AUDPP_MSG_ROUTING_ACK:
-		MM_DBG("ROUTING_ACK mode=%d\n",	msg[1]);
-		audpp_cmd_cfg_adec_params(audio);
-		break;
-
-	case AUDPP_MSG_FLUSH_ACK:
-		MM_DBG("FLUSH_ACK\n");
-		audio->wflush = 0;
-		audio->rflush = 0;
-		wake_up(&audio->write_wait);
-		if (audio->pcm_feedback)
-			audplay_buffer_refresh(audio);
-		break;
-
-	case AUDPP_MSG_PCMDMAMISSED:
-		MM_DBG("PCMDMAMISSED\n");
-		audio->teos = 1;
-		wake_up(&audio->write_wait);
-		break;
-
-	case AUDPP_MSG_AVSYNC_MSG:
-		MM_DBG("AUDPP_MSG_AVSYNC_MSG\n");
-		memcpy(&audio->avsync[0], msg, sizeof(audio->avsync));
-		audio->avsync_flag = 1;
-		wake_up(&audio->avsync_wait);
-		break;
-
-	default:
-		MM_ERR("UNKNOWN (%d)\n", id);
-	}
-
-}
-
-struct msm_adsp_ops audplay_adsp_ops_aac = {
-	.event = audplay_dsp_event,
-};
-
-#define audplay_send_queue0(audio, cmd, len) \
-	msm_adsp_write(audio->audplay, audio->queue_id,\
-			cmd, len)
-
-static int auddec_dsp_config(struct audio *audio, int enable)
-{
-	struct audpp_cmd_cfg_dec_type cfg_dec_cmd;
-
-	memset(&cfg_dec_cmd, 0, sizeof(cfg_dec_cmd));
-
-	cfg_dec_cmd.cmd_id = AUDPP_CMD_CFG_DEC_TYPE;
-	if (enable)
-		cfg_dec_cmd.dec_cfg = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_ENA_DEC_V | AUDDEC_DEC_AAC;
-	else
-		cfg_dec_cmd.dec_cfg = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_DIS_DEC_V;
-	cfg_dec_cmd.dm_mode = 0x0;
-	cfg_dec_cmd.stream_id = audio->dec_id;
-
-	return audpp_send_queue1(&cfg_dec_cmd, sizeof(cfg_dec_cmd));
-}
-
-static void audpp_cmd_cfg_adec_params(struct audio *audio)
-{
-	struct audpp_cmd_cfg_adec_params_aac cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_CMD_CFG_ADEC_PARAMS;
-	cmd.common.length = AUDPP_CMD_CFG_ADEC_PARAMS_AAC_LEN;
-	cmd.common.dec_id = audio->dec_id;
-	cmd.common.input_sampling_frequency = audio->out_sample_rate;
-	cmd.format = audio->aac_config.format;
-	cmd.audio_object = audio->aac_config.audio_object;
-	cmd.ep_config = audio->aac_config.ep_config;
-	cmd.aac_section_data_resilience_flag =
-		audio->aac_config.aac_section_data_resilience_flag;
-	cmd.aac_scalefactor_data_resilience_flag =
-		audio->aac_config.aac_scalefactor_data_resilience_flag;
-	cmd.aac_spectral_data_resilience_flag =
-		audio->aac_config.aac_spectral_data_resilience_flag;
-	cmd.sbr_on_flag = audio->aac_config.sbr_on_flag;
-	cmd.sbr_ps_on_flag = audio->aac_config.sbr_ps_on_flag;
-	cmd.channel_configuration = audio->aac_config.channel_configuration;
-
-	audpp_send_queue2(&cmd, sizeof(cmd));
-}
-
-static void audpp_cmd_cfg_routing_mode(struct audio *audio)
-{
-	struct audpp_cmd_routing_mode cmd;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPP_CMD_ROUTING_MODE;
-	cmd.object_number = audio->dec_id;
-	if (audio->pcm_feedback)
-		cmd.routing_mode = ROUTING_MODE_FTRT;
-	else
-		cmd.routing_mode = ROUTING_MODE_RT;
-
-	audpp_send_queue1(&cmd, sizeof(cmd));
-}
-
-static int audplay_dsp_send_data_avail(struct audio *audio,
-				       unsigned idx, unsigned len)
-{
-	struct audplay_cmd_bitstream_data_avail_nt2 cmd;
-
-	cmd.cmd_id = AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2;
-	if (audio->mfield)
-		cmd.decoder_id = AUDAAC_METAFIELD_MASK |
-			(audio->out[idx].mfield_sz >> 1);
-	else
-	    cmd.decoder_id = audio->dec_id;
-	cmd.buf_ptr = audio->out[idx].addr;
-	cmd.buf_size = len / 2;
-	cmd.partition_number = 0;
-	return audplay_send_queue0(audio, &cmd, sizeof(cmd));
-}
-
-static void audplay_buffer_refresh(struct audio *audio)
-{
-	struct audplay_cmd_buffer_refresh refresh_cmd;
-
-	refresh_cmd.cmd_id = AUDPLAY_CMD_BUFFER_REFRESH;
-	refresh_cmd.num_buffers = 1;
-	refresh_cmd.buf0_address = audio->in[audio->fill_next].addr;
-	/* AAC frame size */
-	refresh_cmd.buf0_length = audio->in[audio->fill_next].size -
-		(audio->in[audio->fill_next].size % 1024)
-		+ (audio->mfield ? 24 : 0);
-	refresh_cmd.buf_read_count = 0;
-	MM_DBG("buf0_addr=%x buf0_len=%d\n", refresh_cmd.buf0_address,
-			refresh_cmd.buf0_length);
-	(void)audplay_send_queue0(audio, &refresh_cmd, sizeof(refresh_cmd));
-}
-
-static void audplay_outport_flush(struct audio *audio)
-{
-	struct audplay_cmd_outport_flush op_flush_cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	op_flush_cmd.cmd_id = AUDPLAY_CMD_OUTPORT_FLUSH;
-	(void)audplay_send_queue0(audio, &op_flush_cmd, sizeof(op_flush_cmd));
-}
-
-static void audplay_error_threshold_config(struct audio *audio)
-{
-	union audplay_cmd_channel_info ch_cfg_cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	ch_cfg_cmd.thr_update.cmd_id = AUDPLAY_CMD_CHANNEL_INFO;
-	ch_cfg_cmd.thr_update.threshold_update = AUDPLAY_ERROR_THRESHOLD_ENABLE;
-	ch_cfg_cmd.thr_update.threshold_value =
-		audio->bitstream_error_threshold_value;
-	(void)audplay_send_queue0(audio, &ch_cfg_cmd, sizeof(ch_cfg_cmd));
-}
-
-static void audplay_config_hostpcm(struct audio *audio)
-{
-	struct audplay_cmd_hpcm_buf_cfg cfg_cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	cfg_cmd.cmd_id = AUDPLAY_CMD_HPCM_BUF_CFG;
-	cfg_cmd.max_buffers = audio->pcm_buf_count;
-	cfg_cmd.byte_swap = 0;
-	cfg_cmd.hostpcm_config = (0x8000) | (0x4000);
-	cfg_cmd.feedback_frequency = 1;
-	cfg_cmd.partition_number = 0;
-	(void)audplay_send_queue0(audio, &cfg_cmd, sizeof(cfg_cmd));
-
-}
-
-static void audplay_send_data(struct audio *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			MM_DBG("frame %d free\n", audio->out_tail);
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			MM_DBG("frame %d busy\n", audio->out_tail);
-			audplay_dsp_send_data_avail(audio, audio->out_tail,
-						    frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
- done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-
-static void audio_flush(struct audio *audio)
-{
-	audio->out[0].used = 0;
-	audio->out[1].used = 0;
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->reserved = 0;
-	audio->out_needed = 0;
-	atomic_set(&audio->out_bytes, 0);
-}
-
-static void audio_flush_pcm_buf(struct audio *audio)
-{
-	uint8_t index;
-
-	for (index = 0; index < PCM_BUF_MAX_COUNT; index++)
-		audio->in[index].used = 0;
-	audio->buf_refresh = 0;
-	audio->read_next = 0;
-	audio->fill_next = 0;
-}
-
-static int audaac_validate_usr_config(struct msm_audio_aac_config *config)
-{
-	int ret_val = -1;
-
-	if (config->format != AUDIO_AAC_FORMAT_ADTS &&
-		config->format != AUDIO_AAC_FORMAT_RAW &&
-		config->format != AUDIO_AAC_FORMAT_PSUEDO_RAW &&
-		config->format != AUDIO_AAC_FORMAT_LOAS)
-		goto done;
-
-	if (config->audio_object != AUDIO_AAC_OBJECT_LC &&
-		config->audio_object != AUDIO_AAC_OBJECT_LTP &&
-		config->audio_object != AUDIO_AAC_OBJECT_BSAC &&
-		config->audio_object != AUDIO_AAC_OBJECT_ERLC)
-		goto done;
-
-	if (config->audio_object == AUDIO_AAC_OBJECT_ERLC) {
-		if (config->ep_config > 3)
-			goto done;
-		if (config->aac_scalefactor_data_resilience_flag !=
-			AUDIO_AAC_SCA_DATA_RES_OFF &&
-			config->aac_scalefactor_data_resilience_flag !=
-			AUDIO_AAC_SCA_DATA_RES_ON)
-			goto done;
-		if (config->aac_section_data_resilience_flag !=
-			AUDIO_AAC_SEC_DATA_RES_OFF &&
-			config->aac_section_data_resilience_flag !=
-			AUDIO_AAC_SEC_DATA_RES_ON)
-			goto done;
-		if (config->aac_spectral_data_resilience_flag !=
-			AUDIO_AAC_SPEC_DATA_RES_OFF &&
-			config->aac_spectral_data_resilience_flag !=
-			AUDIO_AAC_SPEC_DATA_RES_ON)
-			goto done;
-	} else {
-		config->aac_section_data_resilience_flag =
-			AUDIO_AAC_SEC_DATA_RES_OFF;
-		config->aac_scalefactor_data_resilience_flag =
-			AUDIO_AAC_SCA_DATA_RES_OFF;
-		config->aac_spectral_data_resilience_flag =
-			AUDIO_AAC_SPEC_DATA_RES_OFF;
-	}
-
-#ifndef CONFIG_AUDIO_AAC_PLUS
-	if (AUDIO_AAC_SBR_ON_FLAG_OFF != config->sbr_on_flag)
-		goto done;
-#else
-	if (config->sbr_on_flag != AUDIO_AAC_SBR_ON_FLAG_OFF &&
-		config->sbr_on_flag != AUDIO_AAC_SBR_ON_FLAG_ON)
-		goto done;
-#endif
-
-#ifndef CONFIG_AUDIO_ENHANCED_AAC_PLUS
-	if (AUDIO_AAC_SBR_PS_ON_FLAG_OFF != config->sbr_ps_on_flag)
-		goto done;
-#else
-	if (config->sbr_ps_on_flag != AUDIO_AAC_SBR_PS_ON_FLAG_OFF &&
-		config->sbr_ps_on_flag != AUDIO_AAC_SBR_PS_ON_FLAG_ON)
-		goto done;
-#endif
-
-	if (config->dual_mono_mode > AUDIO_AAC_DUAL_MONO_PL_SR)
-		goto done;
-
-	if (config->channel_configuration > 2)
-		goto done;
-
-	ret_val = 0;
- done:
-	return ret_val;
-}
-
-static void audio_ioport_reset(struct audio *audio)
-{
-	/* Make sure read/write thread are free from
-	 * sleep and knowing that system is not able
-	 * to process io request at the moment
-	 */
-	wake_up(&audio->write_wait);
-	mutex_lock(&audio->write_lock);
-	audio_flush(audio);
-	mutex_unlock(&audio->write_lock);
-	wake_up(&audio->read_wait);
-	mutex_lock(&audio->read_lock);
-	audio_flush_pcm_buf(audio);
-	mutex_unlock(&audio->read_lock);
-	audio->avsync_flag = 1;
-	wake_up(&audio->avsync_wait);
-
-}
-
-static int audaac_events_pending(struct audio *audio)
-{
-	unsigned long flags;
-	int empty;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	empty = !list_empty(&audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	return empty || audio->event_abort;
-}
-
-static void audaac_reset_event_queue(struct audio *audio)
-{
-	unsigned long flags;
-	struct audaac_event *drv_evt;
-	struct list_head *ptr, *next;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	list_for_each_safe(ptr, next, &audio->event_queue) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audaac_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	list_for_each_safe(ptr, next, &audio->free_event_queue) {
-		drv_evt = list_first_entry(&audio->free_event_queue,
-				struct audaac_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	return;
-}
-
-static long audaac_process_event_req(struct audio *audio, void __user *arg)
-{
-	long rc;
-	struct msm_audio_event usr_evt;
-	struct audaac_event *drv_evt = NULL;
-	int timeout;
-	unsigned long flags;
-
-	if (copy_from_user(&usr_evt, arg, sizeof(struct msm_audio_event)))
-		return -EFAULT;
-
-	timeout = (int) usr_evt.timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(
-			audio->event_wait, audaac_events_pending(audio),
-			msecs_to_jiffies(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(
-			audio->event_wait, audaac_events_pending(audio));
-	}
-
-	if (rc < 0)
-		return rc;
-
-	if (audio->event_abort) {
-		audio->event_abort = 0;
-		return -ENODEV;
-	}
-
-	rc = 0;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	if (!list_empty(&audio->event_queue)) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audaac_event, list);
-		list_del(&drv_evt->list);
-	}
-	if (drv_evt) {
-		usr_evt.event_type = drv_evt->event_type;
-		usr_evt.event_payload = drv_evt->payload;
-		list_add_tail(&drv_evt->list, &audio->free_event_queue);
-	} else
-		rc = -1;
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	if (!rc && copy_to_user(arg, &usr_evt, sizeof(usr_evt)))
-		rc = -EFAULT;
-
-	return rc;
-}
-
-static int audio_enable_eq(struct audio *audio, int enable)
-{
-	if (audio->eq_enable == enable && !audio->eq_needs_commit)
-		return 0;
-
-	audio->eq_enable = enable;
-
-	if (audio->running) {
-		audpp_dsp_set_eq(audio->dec_id, enable, &audio->eq, POPP);
-		audio->eq_needs_commit = 0;
-	}
-	return 0;
-}
-
-static int audio_get_avsync_data(struct audio *audio,
-						struct msm_audio_stats *stats)
-{
-	int rc = -EINVAL;
-	unsigned long flags;
-
-	local_irq_save(flags);
-	if (audio->dec_id == audio->avsync[0] && audio->avsync_flag) {
-		/* av_sync sample count */
-		stats->sample_count = (audio->avsync[2] << 16) |
-							(audio->avsync[3]);
-
-		/* av_sync byte_count */
-		stats->byte_count = (audio->avsync[5] << 16) |
-							(audio->avsync[6]);
-
-		audio->avsync_flag = 0;
-		rc = 0;
-	}
-	local_irq_restore(flags);
-	return rc;
-
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = -EINVAL;
-	unsigned long flags = 0;
-	uint16_t enable_mask;
-	int enable;
-	int prev_state;
-
-	MM_DBG("cmd = %d\n", cmd);
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-
-		audio->avsync_flag = 0;
-		memset(&stats, 0, sizeof(stats));
-		if (audpp_query_avsync(audio->dec_id) < 0)
-			return rc;
-
-		rc = wait_event_interruptible_timeout(audio->avsync_wait,
-				(audio->avsync_flag == 1),
-				msecs_to_jiffies(AUDPP_AVSYNC_EVENT_TIMEOUT));
-
-		if (rc < 0)
-			return rc;
-		else if ((rc > 0) || ((rc == 0) && (audio->avsync_flag == 1))) {
-			if (audio_get_avsync_data(audio, &stats) < 0)
-				return rc;
-
-			if (copy_to_user((void *)arg, &stats, sizeof(stats)))
-				return -EFAULT;
-			return 0;
-		} else
-			return -EAGAIN;
-	}
-
-	switch (cmd) {
-	case AUDIO_ENABLE_AUDPP:
-		if (copy_from_user(&enable_mask, (void *) arg,
-						sizeof(enable_mask))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		enable = (enable_mask & EQ_ENABLE) ? 1 : 0;
-		audio_enable_eq(audio, enable);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-	case AUDIO_SET_VOLUME:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.volume = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_PAN:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.pan = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_EQ:
-		prev_state = audio->eq_enable;
-		audio->eq_enable = 0;
-		if (copy_from_user(&audio->eq.num_bands, (void *) arg,
-				sizeof(audio->eq) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2))) {
-			rc = -EFAULT;
-			break;
-		}
-		audio->eq_enable = prev_state;
-		audio->eq_needs_commit = 1;
-		rc = 0;
-		break;
-	}
-
-	if (-EINVAL != rc)
-		return rc;
-
-	if (cmd == AUDIO_GET_EVENT) {
-		MM_DBG("AUDIO_GET_EVENT\n");
-		if (mutex_trylock(&audio->get_event_lock)) {
-			rc = audaac_process_event_req(audio,
-					(void __user *) arg);
-			mutex_unlock(&audio->get_event_lock);
-		} else
-			rc = -EBUSY;
-		return rc;
-	}
-
-	if (cmd == AUDIO_ABORT_GET_EVENT) {
-		audio->event_abort = 1;
-		wake_up(&audio->event_wait);
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		MM_DBG("AUDIO_START\n");
-		rc = audio_enable(audio);
-		if (!rc) {
-			rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-			MM_INFO("dec_state %d rc = %d\n", audio->dec_state, rc);
-
-			if (audio->dec_state != MSM_AUD_DECODER_STATE_SUCCESS)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		break;
-	case AUDIO_STOP:
-		MM_DBG("AUDIO_STOP\n");
-		rc = audio_disable(audio);
-		audio->stopped = 1;
-		audio_ioport_reset(audio);
-		audio->stopped = 0;
-		break;
-	case AUDIO_FLUSH:
-		MM_DBG("AUDIO_FLUSH running=%d\n", audio->running);
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audio_ioport_reset(audio);
-		if (audio->running) {
-			audpp_flush(audio->dec_id);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-
-	case AUDIO_OUTPORT_FLUSH:
-		MM_DBG("AUDIO_OUTPORT_FLUSH\n");
-		audio->rflush = 1;
-		wake_up(&audio->read_wait);
-		mutex_lock(&audio->read_lock);
-		audio_flush_pcm_buf(audio);
-		mutex_unlock(&audio->read_lock);
-		audplay_outport_flush(audio);
-		rc = wait_event_interruptible(audio->read_wait,
-				!audio->rflush);
-		if (rc < 0) {
-			MM_ERR("AUDPLAY_OUTPORT_FLUSH interrupted\n");
-			rc = -EINTR;
-		}
-		break;
-
-	case AUDIO_SET_CONFIG:{
-			struct msm_audio_config config;
-
-			if (copy_from_user
-			    (&config, (void *)arg, sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-
-			if (config.channel_count == 1) {
-				config.channel_count =
-				    AUDPP_CMD_PCM_INTF_MONO_V;
-			} else if (config.channel_count == 2) {
-				config.channel_count =
-				    AUDPP_CMD_PCM_INTF_STEREO_V;
-			} else {
-				rc = -EINVAL;
-				break;
-			}
-
-			audio->out_sample_rate = config.sample_rate;
-			audio->out_channel_mode = config.channel_count;
-			audio->mfield = config.meta_field;
-			rc = 0;
-			break;
-		}
-	case AUDIO_GET_CONFIG:{
-			struct msm_audio_config config;
-			config.buffer_size = (audio->out_dma_sz >> 1);
-			config.buffer_count = 2;
-			config.sample_rate = audio->out_sample_rate;
-			if (audio->out_channel_mode ==
-			    AUDPP_CMD_PCM_INTF_MONO_V) {
-				config.channel_count = 1;
-			} else {
-				config.channel_count = 2;
-			}
-			config.meta_field = 0;
-			config.unused[0] = 0;
-			config.unused[1] = 0;
-			config.unused[2] = 0;
-			if (copy_to_user((void *)arg, &config,
-					 sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-
-			break;
-		}
-	case AUDIO_GET_AAC_CONFIG:{
-			if (copy_to_user((void *)arg, &audio->aac_config,
-				sizeof(audio->aac_config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_SET_AAC_CONFIG:{
-			struct msm_audio_aac_config usr_config;
-
-			if (copy_from_user
-				(&usr_config, (void *)arg,
-					sizeof(usr_config))) {
-				rc = -EFAULT;
-				break;
-			}
-
-			if (audaac_validate_usr_config(&usr_config) == 0) {
-				audio->aac_config = usr_config;
-				rc = 0;
-			} else
-				rc = -EINVAL;
-
-			break;
-		}
-	case AUDIO_GET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			config.pcm_feedback = audio->pcm_feedback;
-			config.buffer_count = PCM_BUF_MAX_COUNT;
-			config.buffer_size = PCM_BUFSZ_MIN;
-			if (copy_to_user((void *)arg, &config,
-					 sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_SET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			if (copy_from_user
-			    (&config, (void *)arg, sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-			if (config.pcm_feedback != audio->pcm_feedback) {
-				MM_ERR("Not sufficient permission to"
-					 "change the playback mode\n");
-				rc = -EACCES;
-				break;
-			}
-			if ((config.buffer_count > PCM_BUF_MAX_COUNT) ||
-			    (config.buffer_count == 1))
-				config.buffer_count = PCM_BUF_MAX_COUNT;
-
-			if (config.buffer_size < PCM_BUFSZ_MIN)
-				config.buffer_size = PCM_BUFSZ_MIN;
-
-			/* Check if pcm feedback is required */
-			if (config.pcm_feedback) {
-					audio->buf_refresh = 0;
-					audio->read_next = 0;
-					audio->fill_next = 0;
-			}
-			rc = 0;
-			break;
-		}
-	case AUDIO_PAUSE:
-		MM_DBG("AUDIO_PAUSE %ld\n", arg);
-		rc = audpp_pause(audio->dec_id, (int) arg);
-		break;
-	case AUDIO_GET_STREAM_INFO:{
-		if (audio->stream_info.sample_rate == 0) {
-			/* haven't received DSP stream event,
-			the stream info is not updated */
-			rc = -EPERM;
-			break;
-		}
-		if (copy_to_user((void *)arg, &audio->stream_info,
-			sizeof(struct msm_audio_bitstream_info)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-	case AUDIO_GET_BITSTREAM_ERROR_INFO:{
-		if ((audio->bitstream_error_info.err_msg_indicator &
-				AUDPLAY_STREAM_INFO_MSG_MASK) ==
-				AUDPLAY_STREAM_INFO_MSG_MASK) {
-			/* haven't received bitstream error info event,
-			the bitstream error info is not updated */
-			rc = -EPERM;
-			break;
-		}
-		if (copy_to_user((void *)arg, &audio->bitstream_error_info,
-			sizeof(struct msm_audio_bitstream_error_info)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-	case AUDIO_GET_SESSION_ID:
-		if (copy_to_user((void *) arg, &audio->dec_id,
-				sizeof(unsigned short)))
-			rc =  -EFAULT;
-		else
-			rc = 0;
-		break;
-	case AUDIO_SET_ERR_THRESHOLD_VALUE:
-		if (copy_from_user(&audio->bitstream_error_threshold_value,
-					(void *)arg, sizeof(uint32_t)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-/* Only useful in tunnel-mode */
-static int audaac_fsync(struct file *file, loff_t ppos1, loff_t ppos2, int datasync)
-{
-	struct audio *audio = file->private_data;
-	struct buffer *frame;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	if (!audio->running || audio->pcm_feedback) {
-		rc = -EINVAL;
-		goto done_nolock;
-	}
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(!audio->out[0].used &&
-		!audio->out[1].used &&
-		audio->out_needed) || audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (audio->reserved) {
-		MM_DBG("send reserved byte\n");
-		frame = audio->out + audio->out_tail;
-		((char *) frame->data)[0] = audio->rsv_byte;
-		((char *) frame->data)[1] = 0;
-		frame->used = 2;
-		audplay_send_data(audio, 0);
-
-		rc = wait_event_interruptible(audio->write_wait,
-			(!audio->out[0].used &&
-			!audio->out[1].used &&
-			audio->out_needed) || audio->wflush);
-
-		if (rc < 0)
-			goto done;
-		else if (audio->wflush) {
-			rc = -EBUSY;
-			goto done;
-		}
-	}
-
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		audio->teos || audio->wflush);
-
-	if (audio->wflush)
-		rc = -EBUSY;
-
-done:
-	mutex_unlock(&audio->write_lock);
-done_nolock:
-	return rc;
-}
-
-static ssize_t audio_read(struct file *file, char __user *buf, size_t count,
-			  loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	int rc = 0;
-
-	if (!audio->pcm_feedback)
-		return 0; /* PCM feedback is not enabled. Nothing to read */
-
-	mutex_lock(&audio->read_lock);
-	MM_DBG("to read %d \n", count);
-	while (count > 0) {
-		rc = wait_event_interruptible_timeout(audio->read_wait,
-					      (audio->in[audio->read_next].
-						used > 0) || (audio->stopped)
-						|| (audio->rflush),
-			msecs_to_jiffies(MSM_AUD_BUFFER_UPDATE_WAIT_MS));
-
-		if (rc == 0) {
-			rc = -ETIMEDOUT;
-			break;
-		} else if (rc < 0)
-			break;
-
-		if (audio->stopped || audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (count < audio->in[audio->read_next].used) {
-			/* Read must happen in frame boundary. Since driver
-			   does not know frame size, read count must be greater
-			   or equal to size of PCM samples */
-			MM_DBG("no partial frame done reading\n");
-			break;
-		} else {
-			MM_DBG("read from in[%d]\n", audio->read_next);
-			if (copy_to_user
-			    (buf, audio->in[audio->read_next].data,
-			     audio->in[audio->read_next].used)) {
-				MM_ERR("invalid addr %x\n", (unsigned int)buf);
-				rc = -EFAULT;
-				break;
-			}
-			count -= audio->in[audio->read_next].used;
-			buf += audio->in[audio->read_next].used;
-			audio->in[audio->read_next].used = 0;
-			if ((++audio->read_next) == audio->pcm_buf_count)
-				audio->read_next = 0;
-			break;
-				/*
-				* Force to exit while loop
-				* to prevent output thread
-				* sleep too long if data is not
-				* ready at this moment.
-				*/
-		}
-	}
-
-	/* don't feed output buffer to HW decoder during flushing
-	 * buffer refresh command will be sent once flush completes
-	 * send buf refresh command here can confuse HW decoder
-	 */
-	if (audio->buf_refresh && !audio->rflush) {
-		audio->buf_refresh = 0;
-		MM_DBG("kick start pcm feedback again\n");
-		audplay_buffer_refresh(audio);
-	}
-
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		rc = buf - start;
-
-	MM_DBG("read %d bytes\n", rc);
-	return rc;
-}
-
-static int audaac_process_eos(struct audio *audio,
-	const char __user *buf_start, unsigned short mfield_size)
-{
-	struct buffer *frame;
-	char *buf_ptr;
-	int rc = 0;
-
-	MM_DBG("signal input EOS reserved=%d\n", audio->reserved);
-	if (audio->reserved) {
-		MM_DBG("Pass reserve byte\n");
-		frame = audio->out + audio->out_head;
-		buf_ptr = frame->data;
-		rc = wait_event_interruptible(audio->write_wait,
-					(frame->used == 0)
-					|| (audio->stopped)
-					|| (audio->wflush));
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-	buf_ptr[0] = audio->rsv_byte;
-	buf_ptr[1] = 0;
-	audio->out_head ^= 1;
-	frame->mfield_sz = 0;
-	audio->reserved = 0;
-	frame->used = 2;
-	audplay_send_data(audio, 0);
-	}
-	MM_DBG("Now signal input EOS after reserved bytes %d %d %d\n",
-		audio->out[0].used, audio->out[1].used, audio->out_needed);
-	frame = audio->out + audio->out_head;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	audplay_send_data(audio, 0);
-done:
-	return rc;
-}
-static ssize_t audio_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	size_t xfer;
-	char *cpy_ptr;
-	int rc = 0, eos_condition = AUDAAC_EOS_NONE;
-	unsigned dsize;
-
-	unsigned short mfield_size = 0;
-	MM_DBG("cnt=%d\n", count);
-	mutex_lock(&audio->write_lock);
-	while (count > 0) {
-		frame = audio->out + audio->out_head;
-		cpy_ptr = frame->data;
-		dsize = 0;
-		rc = wait_event_interruptible(audio->write_wait,
-					      (frame->used == 0)
-						|| (audio->stopped)
-						|| (audio->wflush));
-		if (rc < 0)
-			break;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			break;
-		}
-		if (audio->mfield) {
-			if (buf == start) {
-				/* Processing beginning of user buffer */
-				if (__get_user(mfield_size,
-					(unsigned short __user *) buf)) {
-					rc = -EFAULT;
-					break;
-				} else 	if (mfield_size > count) {
-					rc = -EINVAL;
-					break;
-				}
-				MM_DBG("mf offset_val %x\n", mfield_size);
-				if (copy_from_user(cpy_ptr, buf, mfield_size)) {
-					rc = -EFAULT;
-					break;
-				}
-				/* Check if EOS flag is set and buffer has
-				* contains just meta field
-				*/
-				if (cpy_ptr[AUDAAC_EOS_FLG_OFFSET] &
-						AUDAAC_EOS_FLG_MASK) {
-					MM_DBG("eos set\n");
-					eos_condition = AUDAAC_EOS_SET;
-					if (mfield_size == count) {
-						buf += mfield_size;
-						break;
-					} else
-					cpy_ptr[AUDAAC_EOS_FLG_OFFSET] &=
-							~AUDAAC_EOS_FLG_MASK;
-				}
-				/* Check EOS to see if */
-				cpy_ptr += mfield_size;
-				count -= mfield_size;
-				dsize += mfield_size;
-				buf += mfield_size;
-			} else {
-				mfield_size = 0;
-				MM_DBG("continuous buffer\n");
-			}
-			frame->mfield_sz = mfield_size;
-		}
-
-		if (audio->reserved) {
-			MM_DBG("append reserved byte %x\n",
-				audio->rsv_byte);
-			*cpy_ptr = audio->rsv_byte;
-			xfer = (count > ((frame->size - mfield_size) - 1)) ?
-				(frame->size - mfield_size) - 1 : count;
-			cpy_ptr++;
-			dsize += 1;
-			audio->reserved = 0;
-		} else
-			xfer = (count > (frame->size - mfield_size)) ?
-				(frame->size - mfield_size) : count;
-
-		if (copy_from_user(cpy_ptr, buf, xfer)) {
-			rc = -EFAULT;
-			break;
-		}
-
-		dsize += xfer;
-		if (dsize & 1) {
-			audio->rsv_byte = ((char *) frame->data)[dsize - 1];
-			MM_DBG("odd length buf reserve last byte %x\n",
-					audio->rsv_byte);
-			audio->reserved = 1;
-			dsize--;
-		}
-		count -= xfer;
-		buf += xfer;
-
-		if (dsize > 0) {
-			audio->out_head ^= 1;
-			frame->used = dsize;
-			audplay_send_data(audio, 0);
-		}
-	}
-	MM_DBG("eos_condition %x buf[0x%x] start[0x%x]\n", eos_condition,
-			(int) buf, (int) start);
-	if (eos_condition == AUDAAC_EOS_SET)
-		rc = audaac_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	if (!rc) {
-		if (buf > start)
-			return buf - start;
-	}
-	return rc;
-}
-
-static int audio_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	MM_INFO("audio instance 0x%08x freeing\n", (int)audio);
-
-	mutex_lock(&audio->lock);
-	auddev_unregister_evt_listner(AUDDEV_CLNT_DEC, audio->dec_id);
-	audio_disable(audio);
-	audio_flush(audio);
-	audio_flush_pcm_buf(audio);
-	msm_adsp_put(audio->audplay);
-	audpp_adec_free(audio->dec_id);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	unregister_early_suspend(&audio->suspend_ctl.node);
-#endif
-	audio->event_abort = 1;
-	wake_up(&audio->event_wait);
-	audaac_reset_event_queue(audio);
-	iounmap(audio->map_v_write);
-	free_contiguous_memory_by_paddr(audio->phys);
-	iounmap(audio->map_v_read);
-	free_contiguous_memory_by_paddr(audio->read_phys);
-	mutex_unlock(&audio->lock);
-#ifdef CONFIG_DEBUG_FS
-	if (audio->dentry)
-		debugfs_remove(audio->dentry);
-#endif
-	kfree(audio);
-	return 0;
-}
-
-static void audaac_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload)
-{
-	struct audaac_event *e_node = NULL;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-
-	if (!list_empty(&audio->free_event_queue)) {
-		e_node = list_first_entry(&audio->free_event_queue,
-				struct audaac_event, list);
-		list_del(&e_node->list);
-	} else {
-		e_node = kmalloc(sizeof(struct audaac_event), GFP_ATOMIC);
-		if (!e_node) {
-			MM_ERR("No mem to post event %d\n", type);
-			return;
-		}
-	}
-
-	e_node->event_type = type;
-	e_node->payload = payload;
-
-	list_add_tail(&e_node->list, &audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	wake_up(&audio->event_wait);
-}
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audaac_suspend(struct early_suspend *h)
-{
-	struct audaac_suspend_ctl *ctl =
-		container_of(h, struct audaac_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audaac_post_event(ctl->audio, AUDIO_EVENT_SUSPEND, payload);
-}
-
-static void audaac_resume(struct early_suspend *h)
-{
-	struct audaac_suspend_ctl *ctl =
-		container_of(h, struct audaac_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audaac_post_event(ctl->audio, AUDIO_EVENT_RESUME, payload);
-}
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-static ssize_t audaac_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static ssize_t audaac_debug_read(struct file *file, char __user *buf,
-					size_t count, loff_t *ppos)
-{
-	const int debug_bufmax = 1024;
-	static char buffer[1024];
-	int n = 0, i;
-	struct audio *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	n = scnprintf(buffer, debug_bufmax, "opened %d\n", audio->opened);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"enabled %d\n", audio->enabled);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"stopped %d\n", audio->stopped);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_feedback %d\n", audio->pcm_feedback);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_buf_sz %d\n", audio->out[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_buf_count %d \n", audio->pcm_buf_count);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_buf_sz %d \n", audio->in[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"volume %x \n", audio->vol_pan.volume);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"sample rate %d \n", audio->out_sample_rate);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"channel mode %d \n", audio->out_channel_mode);
-	mutex_unlock(&audio->lock);
-	/* Following variables are only useful for debugging when
-	 * when playback halts unexpectedly. Thus, no mutual exclusion
-	 * enforced
-	 */
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"wflush %d\n", audio->wflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"rflush %d\n", audio->rflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"running %d \n", audio->running);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"dec state %d \n", audio->dec_state);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_needed %d \n", audio->out_needed);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_head %d \n", audio->out_head);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_tail %d \n", audio->out_tail);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out[0].used %d \n", audio->out[0].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out[1].used %d \n", audio->out[1].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"buffer_refresh %d \n", audio->buf_refresh);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"read_next %d \n", audio->read_next);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"fill_next %d \n", audio->fill_next);
-	for (i = 0; i < audio->pcm_buf_count; i++)
-		n += scnprintf(buffer + n, debug_bufmax - n,
-				"in[%d].used %d \n", i, audio->in[i].used);
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations audaac_debug_fops = {
-	.read = audaac_debug_read,
-	.open = audaac_debug_open,
-};
-#endif
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = NULL;
-	int rc, dec_attrb, decid, index, offset = 0;
-	unsigned pmem_sz = DMASZ;
-	struct audaac_event *e_node = NULL;
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_aac_" + 5];
-#endif
-
-	/* Allocate audio instance, set to zero */
-	audio = kzalloc(sizeof(struct audio), GFP_KERNEL);
-	if (!audio) {
-		MM_ERR("no memory to allocate audio instance \n");
-		rc = -ENOMEM;
-		goto done;
-	}
-	MM_INFO("audio instance 0x%08x created\n", (int)audio);
-
-	/* Allocate the decoder */
-	dec_attrb = AUDDEC_DEC_AAC;
-	if ((file->f_mode & FMODE_WRITE) &&
-			(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_NONTUNNEL;
-		audio->pcm_feedback = NON_TUNNEL_MODE_PLAYBACK;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_TUNNEL;
-		audio->pcm_feedback = TUNNEL_MODE_PLAYBACK;
-	} else {
-		kfree(audio);
-		rc = -EACCES;
-		goto done;
-	}
-	decid = audpp_adec_alloc(dec_attrb, &audio->module_name,
-			&audio->queue_id);
-
-	if (decid < 0) {
-		MM_ERR("No free decoder available, freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENODEV;
-		kfree(audio);
-		goto done;
-	}
-	audio->dec_id = decid & MSM_AUD_DECODER_MASK;
-
-	while (pmem_sz >= DMASZ_MIN) {
-		MM_DBG("pmemsz = %d\n", pmem_sz);
-		audio->phys = allocate_contiguous_ebi_nomap(pmem_sz, SZ_4K);
-		if (audio->phys) {
-			audio->map_v_write =
-					ioremap(audio->phys,
-						pmem_sz);
-			if (IS_ERR(audio->map_v_write)) {
-				MM_ERR("could not map write phys address, \
-						freeing instance 0x%08x\n",
-						(int)audio);
-				rc = -ENOMEM;
-				free_contiguous_memory_by_paddr(audio->phys);
-				audpp_adec_free(audio->dec_id);
-				kfree(audio);
-				goto done;
-			}
-			audio->data = (u8 *)audio->map_v_write;
-			MM_DBG("write buf: phy addr 0x%08x kernel addr \
-				0x%08x\n", audio->phys, (int)audio->data);
-			break;
-		} else if (pmem_sz == DMASZ_MIN) {
-			MM_ERR("could not allocate write buffers, freeing \
-					instance 0x%08x\n", (int)audio);
-			rc = -ENOMEM;
-			audpp_adec_free(audio->dec_id);
-			kfree(audio);
-			goto done;
-		} else
-			pmem_sz >>= 1;
-	}
-	audio->out_dma_sz = pmem_sz;
-
-	audio->read_phys = allocate_contiguous_ebi_nomap(PCM_BUFSZ_MIN
-					* PCM_BUF_MAX_COUNT, SZ_4K);
-	if (!audio->read_phys) {
-		MM_ERR("could not allocate read buffers, freeing instance \
-				0x%08x\n", (int)audio);
-		rc = -ENOMEM;
-		iounmap(audio->map_v_write);
-		free_contiguous_memory_by_paddr(audio->phys);
-		audpp_adec_free(audio->dec_id);
-		kfree(audio);
-		goto done;
-	}
-	audio->map_v_read = ioremap(audio->read_phys,
-				PCM_BUFSZ_MIN * PCM_BUF_MAX_COUNT);
-	if (IS_ERR(audio->map_v_read)) {
-		MM_ERR("could not map read phys address, freeing instance \
-				0x%08x\n", (int)audio);
-		rc = -ENOMEM;
-		iounmap(audio->map_v_write);
-		free_contiguous_memory_by_paddr(audio->phys);
-		free_contiguous_memory_by_paddr(audio->read_phys);
-		audpp_adec_free(audio->dec_id);
-		kfree(audio);
-		goto done;
-	}
-	audio->read_data = audio->map_v_read;
-	MM_DBG("read buf: phy addr 0x%08x kernel addr 0x%08x\n",
-				audio->read_phys, (int)audio->read_data);
-
-	rc = msm_adsp_get(audio->module_name, &audio->audplay,
-			  &audplay_adsp_ops_aac, audio);
-	if (rc) {
-		MM_ERR("failed to get %s module, freeing instance 0x%08x\n",
-				audio->module_name, (int)audio);
-		goto err;
-	}
-
-	mutex_init(&audio->lock);
-	mutex_init(&audio->write_lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->get_event_lock);
-	spin_lock_init(&audio->dsp_lock);
-	spin_lock_init(&audio->event_queue_lock);
-	INIT_LIST_HEAD(&audio->free_event_queue);
-	INIT_LIST_HEAD(&audio->event_queue);
-	init_waitqueue_head(&audio->write_wait);
-	init_waitqueue_head(&audio->read_wait);
-	init_waitqueue_head(&audio->wait);
-	init_waitqueue_head(&audio->event_wait);
-	init_waitqueue_head(&audio->avsync_wait);
-
-	audio->out[0].data = audio->data + 0;
-	audio->out[0].addr = audio->phys + 0;
-	audio->out[0].size = audio->out_dma_sz >> 1;
-
-	audio->out[1].data = audio->data + audio->out[0].size;
-	audio->out[1].addr = audio->phys + audio->out[0].size;
-	audio->out[1].size = audio->out[0].size;
-
-	audio->pcm_buf_count = PCM_BUF_MAX_COUNT;
-	for (index = 0; index < PCM_BUF_MAX_COUNT; index++) {
-		audio->in[index].data = audio->read_data + offset;
-		audio->in[index].addr = audio->read_phys + offset;
-		audio->in[index].size = PCM_BUFSZ_MIN;
-		audio->in[index].used = 0;
-		offset += PCM_BUFSZ_MIN;
-	}
-
-	audio->out_sample_rate = 44100;
-	audio->out_channel_mode = AUDPP_CMD_PCM_INTF_STEREO_V;
-	audio->aac_config.format = AUDIO_AAC_FORMAT_ADTS;
-	audio->aac_config.audio_object = AUDIO_AAC_OBJECT_LC;
-	audio->aac_config.ep_config = 0;
-	audio->aac_config.aac_section_data_resilience_flag =
-		AUDIO_AAC_SEC_DATA_RES_OFF;
-	audio->aac_config.aac_scalefactor_data_resilience_flag =
-		AUDIO_AAC_SCA_DATA_RES_OFF;
-	audio->aac_config.aac_spectral_data_resilience_flag =
-		AUDIO_AAC_SPEC_DATA_RES_OFF;
-#ifdef CONFIG_AUDIO_AAC_PLUS
-	audio->aac_config.sbr_on_flag = AUDIO_AAC_SBR_ON_FLAG_ON;
-#else
-	audio->aac_config.sbr_on_flag = AUDIO_AAC_SBR_ON_FLAG_OFF;
-#endif
-#ifdef CONFIG_AUDIO_ENHANCED_AAC_PLUS
-	audio->aac_config.sbr_ps_on_flag = AUDIO_AAC_SBR_PS_ON_FLAG_ON;
-#else
-	audio->aac_config.sbr_ps_on_flag = AUDIO_AAC_SBR_PS_ON_FLAG_OFF;
-#endif
-	audio->aac_config.dual_mono_mode = AUDIO_AAC_DUAL_MONO_PL_SR;
-	audio->aac_config.channel_configuration = 2;
-	audio->vol_pan.volume = 0x2000;
-	audio->bitstream_error_threshold_value =
-		BITSTREAM_ERROR_THRESHOLD_VALUE;
-
-	audio_flush(audio);
-
-	file->private_data = audio;
-	audio->opened = 1;
-
-	audio->device_events = AUDDEV_EVT_DEV_RDY
-				|AUDDEV_EVT_DEV_RLS|
-				AUDDEV_EVT_STREAM_VOL_CHG;
-
-	rc = auddev_register_evt_listner(audio->device_events,
-					AUDDEV_CLNT_DEC,
-					audio->dec_id,
-					aac_listner,
-					(void *)audio);
-	if (rc) {
-		MM_ERR("%s: failed to register listner\n", __func__);
-		goto event_err;
-	}
-
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof name, "msm_aac_%04x", audio->dec_id);
-	audio->dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
-				NULL, (void *) audio,
-				&audaac_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		MM_DBG("debugfs_create_file failed\n");
-#endif
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	audio->suspend_ctl.node.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
-	audio->suspend_ctl.node.resume = audaac_resume;
-	audio->suspend_ctl.node.suspend = audaac_suspend;
-	audio->suspend_ctl.audio = audio;
-	register_early_suspend(&audio->suspend_ctl.node);
-#endif
-	for (index = 0; index < AUDAAC_EVENT_NUM; index++) {
-		e_node = kmalloc(sizeof(struct audaac_event), GFP_KERNEL);
-		if (e_node)
-			list_add_tail(&e_node->list, &audio->free_event_queue);
-		else {
-			MM_ERR("event pkt alloc failed\n");
-			break;
-		}
-	}
-	memset(&audio->stream_info, 0, sizeof(struct msm_audio_bitstream_info));
-	memset(&audio->bitstream_error_info, 0,
-			sizeof(struct msm_audio_bitstream_info));
-done:
-	return rc;
-event_err:
-	msm_adsp_put(audio->audplay);
-err:
-	iounmap(audio->map_v_write);
-	free_contiguous_memory_by_paddr(audio->phys);
-	iounmap(audio->map_v_read);
-	free_contiguous_memory_by_paddr(audio->read_phys);
-	audpp_adec_free(audio->dec_id);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_aac_fops = {
-	.owner = THIS_MODULE,
-	.open = audio_open,
-	.release = audio_release,
-	.read = audio_read,
-	.write = audio_write,
-	.unlocked_ioctl = audio_ioctl,
-	.fsync = audaac_fsync
-};
-
-struct miscdevice audio_aac_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_aac",
-	.fops = &audio_aac_fops,
-};
-
-static int __init audio_init(void)
-{
-	return misc_register(&audio_aac_misc);
-}
-
-static void __exit audio_exit(void)
-{
-	misc_deregister(&audio_aac_misc);
-}
-
-module_init(audio_init);
-module_exit(audio_exit);
-
-MODULE_DESCRIPTION("MSM AAC driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5v2/audio_aac_in.c b/arch/arm/mach-msm/qdsp5v2/audio_aac_in.c
deleted file mode 100644
index cf1f58d..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audio_aac_in.c
+++ /dev/null
@@ -1,1481 +0,0 @@
-/*
- * aac audio input device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2009-2012, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/msm_audio_aac.h>
-#include <linux/memory_alloc.h>
-#include <mach/msm_memtypes.h>
-
-#include <mach/msm_adsp.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/qdsp5v2/qdsp5audreccmdi.h>
-#include <mach/qdsp5v2/qdsp5audrecmsg.h>
-#include <mach/qdsp5v2/audpreproc.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/debug_mm.h>
-#include <mach/socinfo.h>
-
-/* FRAME_NUM must be a power of two */
-#define FRAME_NUM		(8)
-#define FRAME_SIZE		(772 * 2) /* 1536 bytes data */
-#define NT_FRAME_SIZE	(780 * 2) /* 1536 bytes data  + 24 meta field*/
-#define AAC_FRAME_SIZE	1536
-#define DMASZ 			(FRAME_SIZE * FRAME_NUM)
-#define OUT_FRAME_NUM	(2)
-#define META_OUT_SIZE	(24)
-#define META_IN_SIZE	(14)
-#define OUT_BUFFER_SIZE (32 * 1024 + META_OUT_SIZE)
-#define BUFFER_SIZE		(OUT_BUFFER_SIZE * OUT_FRAME_NUM)
-
-#define AUDPREPROC_AAC_EOS_FLG_OFFSET 0x0A /* Offset from beginning of buffer */
-#define AUDPREPROC_AAC_EOS_FLG_MASK 0x01
-#define AUDPREPROC_AAC_EOS_NONE 0x0 /* No EOS detected */
-#define AUDPREPROC_AAC_EOS_SET 0x1 /* EOS set in meta field */
-
-#define PCM_CONFIG_UPDATE_FLAG_ENABLE -1
-#define PCM_CONFIG_UPDATE_FLAG_DISABLE	0
-
-#define ENABLE_FLAG_VALUE	-1
-#define DISABLE_FLAG_VALUE	0
-
-struct buffer {
-	void *data;
-	uint32_t size;
-	uint32_t read;
-	uint32_t addr;
-	uint32_t used;
-	uint32_t mfield_sz;
-};
-
-struct audio_in {
-	struct buffer in[FRAME_NUM];
-
-	spinlock_t dsp_lock;
-
-	atomic_t in_bytes;
-	atomic_t in_samples;
-
-	struct mutex lock;
-	struct mutex read_lock;
-	wait_queue_head_t wait;
-	wait_queue_head_t wait_enable;
-	/*write section*/
-	struct buffer out[OUT_FRAME_NUM];
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed;	/* number of buffers the dsp is waiting for */
-	uint32_t out_count;
-
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-	int32_t out_phys; /* physical address of write buffer */
-	char *out_data;
-	void *map_v_read;
-	void *map_v_write;
-
-	int mfield; /* meta field embedded in data */
-	int wflush; /*write flush */
-	int rflush; /*read flush*/
-	int out_frame_cnt;
-
-	struct msm_adsp_module *audrec;
-
-	/* configuration to use on next enable */
-	uint32_t buffer_size; /* Frame size (36 bytes) */
-	uint32_t samp_rate;
-	uint32_t channel_mode;
-	uint32_t bit_rate; /* bit rate for AAC */
-	uint32_t record_quality; /* record quality (bits/sample/channel) */
-	uint32_t enc_type;
-
-	uint32_t dsp_cnt;
-	uint32_t in_head; /* next buffer dsp will write */
-	uint32_t in_tail; /* next buffer read() will read */
-	uint32_t in_count; /* number of buffers available to read() */
-	uint32_t mode;
-	uint32_t eos_ack;
-	uint32_t flush_ack;
-
-	const char *module_name;
-	unsigned queue_ids;
-	uint16_t enc_id;
-
-	struct audrec_session_info session_info; /*audrec session info*/
-	uint16_t source; /* Encoding source bit mask */
-	uint32_t device_events; /* device events interested in */
-	uint32_t dev_cnt;
-	spinlock_t dev_lock;
-
-	/* data allocated for various buffers */
-	char *data;
-	dma_addr_t phys;
-
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped, cleared on flush */
-	int abort; /* set when error, like sample rate mismatch */
-	char *build_id;
-};
-
-struct audio_frame {
-	uint16_t frame_count_lsw;
-	uint16_t frame_count_msw;
-	uint16_t frame_length;
-	uint16_t erased_pcm;
-	unsigned char raw_bitstream[]; /* samples */
-} __attribute__((packed));
-
-struct audio_frame_nt {
-	uint16_t metadata_len;
-	uint16_t frame_count_lsw;
-	uint16_t frame_count_msw;
-	uint16_t frame_length;
-	uint16_t erased_pcm;
-	uint16_t reserved;
-	uint16_t time_stamp_dword_lsw;
-	uint16_t time_stamp_dword_msw;
-	uint16_t time_stamp_lsw;
-	uint16_t time_stamp_msw;
-	uint16_t nflag_lsw;
-	uint16_t nflag_msw;
-	unsigned char raw_bitstream[]; /* samples */
-} __attribute__((packed));
-
-struct aac_encoded_meta_in {
-	uint16_t metadata_len;
-	uint16_t time_stamp_dword_lsw;
-	uint16_t time_stamp_dword_msw;
-	uint16_t time_stamp_lsw;
-	uint16_t time_stamp_msw;
-	uint16_t nflag_lsw;
-	uint16_t nflag_msw;
-};
-
-/* Audrec Queue command sent macro's */
-#define audrec_send_bitstreamqueue(audio, cmd, len) \
-	msm_adsp_write(audio->audrec, ((audio->queue_ids & 0xFFFF0000) >> 16),\
-			cmd, len)
-
-#define audrec_send_audrecqueue(audio, cmd, len) \
-	msm_adsp_write(audio->audrec, (audio->queue_ids & 0x0000FFFF),\
-			cmd, len)
-
-/* DSP command send functions */
-static int audaac_in_enc_config(struct audio_in *audio, int enable);
-static int audaac_in_param_config(struct audio_in *audio);
-static int audaac_in_mem_config(struct audio_in *audio);
-static int audaac_in_record_config(struct audio_in *audio, int enable);
-static int audaac_dsp_read_buffer(struct audio_in *audio, uint32_t read_cnt);
-
-static void audaac_in_get_dsp_frames(struct audio_in *audio);
-static int audpcm_config(struct audio_in *audio);
-static void audaac_out_flush(struct audio_in *audio);
-static int audpreproc_cmd_cfg_routing_mode(struct audio_in *audio);
-static void audpreproc_pcm_send_data(struct audio_in *audio, unsigned needed);
-static void audaac_nt_in_get_dsp_frames(struct audio_in *audio);
-
-static void audaac_in_flush(struct audio_in *audio);
-
-static void aac_in_listener(u32 evt_id, union auddev_evt_data *evt_payload,
-				void *private_data)
-{
-	struct audio_in *audio = (struct audio_in *) private_data;
-	unsigned long flags;
-
-	MM_DBG("evt_id = 0x%8x\n", evt_id);
-	switch (evt_id) {
-	case AUDDEV_EVT_DEV_RDY: {
-		MM_DBG("AUDDEV_EVT_DEV_RDY\n");
-		spin_lock_irqsave(&audio->dev_lock, flags);
-		audio->dev_cnt++;
-		audio->source |= (0x1 << evt_payload->routing_id);
-		spin_unlock_irqrestore(&audio->dev_lock, flags);
-
-		if ((audio->running == 1) && (audio->enabled == 1) &&
-			(audio->mode == MSM_AUD_ENC_MODE_TUNNEL))
-			audaac_in_record_config(audio, 1);
-
-		break;
-	}
-	case AUDDEV_EVT_DEV_RLS: {
-		MM_DBG("AUDDEV_EVT_DEV_RLS\n");
-		spin_lock_irqsave(&audio->dev_lock, flags);
-		audio->dev_cnt--;
-		audio->source &= ~(0x1 << evt_payload->routing_id);
-		spin_unlock_irqrestore(&audio->dev_lock, flags);
-
-		if ((!audio->running) || (!audio->enabled))
-			break;
-
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			/* Turn of as per source */
-			if (audio->source)
-				audaac_in_record_config(audio, 1);
-			else
-			/* Turn off all */
-				audaac_in_record_config(audio, 0);
-		}
-		break;
-	}
-	case AUDDEV_EVT_FREQ_CHG: {
-		MM_DBG("Encoder Driver got sample rate change event\n");
-		MM_DBG("sample rate %d\n", evt_payload->freq_info.sample_rate);
-		MM_DBG("dev_type %d\n", evt_payload->freq_info.dev_type);
-		MM_DBG("acdb_dev_id %d\n", evt_payload->freq_info.acdb_dev_id);
-		if ((audio->running == 1) && (audio->enabled == 1)) {
-			/* Stop Recording sample rate does not match
-			   with device sample rate */
-			if (evt_payload->freq_info.sample_rate !=
-				audio->samp_rate) {
-				if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)
-					audaac_in_record_config(audio, 0);
-				audio->abort = 1;
-				wake_up(&audio->wait);
-			}
-		}
-		break;
-	}
-	default:
-		MM_ERR("wrong event %d\n", evt_id);
-		break;
-	}
-}
-
-/* Convert Bit Rate to Record Quality field of DSP */
-static unsigned int bitrate_to_record_quality(unsigned int sample_rate,
-		unsigned int channel, unsigned int bit_rate) {
-	unsigned int temp;
-
-	temp = sample_rate * channel;
-	MM_DBG(" sample rate *  channel = %d \n", temp);
-	/* To represent in Q12 fixed format */
-	temp = (bit_rate * 4096) / temp;
-	MM_DBG(" Record Quality = 0x%8x \n", temp);
-	return temp;
-}
-
-/* ------------------- dsp preproc event handler--------------------- */
-static void audpreproc_dsp_event(void *data, unsigned id,  void *msg)
-{
-	struct audio_in *audio = data;
-
-	switch (id) {
-	case AUDPREPROC_ERROR_MSG: {
-		struct audpreproc_err_msg *err_msg = msg;
-
-		MM_ERR("ERROR_MSG: stream id %d err idx %d\n",
-		err_msg->stream_id, err_msg->aud_preproc_err_idx);
-		/* Error case */
-		wake_up(&audio->wait_enable);
-		break;
-	}
-	case AUDPREPROC_CMD_CFG_DONE_MSG: {
-		MM_DBG("CMD_CFG_DONE_MSG \n");
-		break;
-	}
-	case AUDPREPROC_CMD_ENC_CFG_DONE_MSG: {
-		struct audpreproc_cmd_enc_cfg_done_msg *enc_cfg_msg = msg;
-
-		MM_DBG("CMD_ENC_CFG_DONE_MSG: stream id %d enc type \
-			0x%8x\n", enc_cfg_msg->stream_id,
-			enc_cfg_msg->rec_enc_type);
-		/* Encoder enable success */
-		if (enc_cfg_msg->rec_enc_type & ENCODE_ENABLE) {
-			if(audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) {
-				MM_DBG("routing command\n");
-				audpreproc_cmd_cfg_routing_mode(audio);
-			} else {
-				audaac_in_param_config(audio);
-			}
-		} else { /* Encoder disable success */
-			audio->running = 0;
-			if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)
-				audaac_in_record_config(audio, 0);
-			else
-				wake_up(&audio->wait_enable);
-		}
-		break;
-	}
-	case AUDPREPROC_CMD_ENC_PARAM_CFG_DONE_MSG: {
-		MM_DBG("CMD_ENC_PARAM_CFG_DONE_MSG\n");
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)
-			audaac_in_mem_config(audio);
-		else
-			audpcm_config(audio);
-		break;
-	}
-	case AUDPREPROC_CMD_ROUTING_MODE_DONE_MSG: {
-		struct audpreproc_cmd_routing_mode_done\
-				*routing_cfg_done_msg = msg;
-		if (routing_cfg_done_msg->configuration == 0) {
-			MM_INFO("routing configuration failed\n");
-			audio->running = 0;
-		} else
-			audaac_in_param_config(audio);
-		break;
-	}
-	case AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG_DONE_MSG: {
-		MM_DBG("AFE_CMD_AUDIO_RECORD_CFG_DONE_MSG\n");
-		wake_up(&audio->wait_enable);
-		break;
-	}
-	default:
-		MM_ERR("Unknown Event id %d\n", id);
-	}
-}
-
-/* ------------------- dsp audrec event handler--------------------- */
-static void audrec_dsp_event(void *data, unsigned id, size_t len,
-			    void (*getevent)(void *ptr, size_t len))
-{
-	struct audio_in *audio = data;
-
-	switch (id) {
-	case AUDREC_CMD_MEM_CFG_DONE_MSG: {
-		MM_DBG("CMD_MEM_CFG_DONE MSG DONE\n");
-		audio->running = 1;
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			if (audio->dev_cnt > 0)
-				audaac_in_record_config(audio, 1);
-		} else {
-			audpreproc_pcm_send_data(audio, 1);
-			wake_up(&audio->wait_enable);
-		}
-		break;
-	}
-	case AUDREC_FATAL_ERR_MSG: {
-		struct audrec_fatal_err_msg fatal_err_msg;
-
-		getevent(&fatal_err_msg, AUDREC_FATAL_ERR_MSG_LEN);
-		MM_ERR("FATAL_ERR_MSG: err id %d\n",
-				fatal_err_msg.audrec_err_id);
-		/* Error stop the encoder */
-		audio->stopped = 1;
-		wake_up(&audio->wait);
-		if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL)
-			wake_up(&audio->write_wait);
-		break;
-	}
-	case AUDREC_UP_PACKET_READY_MSG: {
-		struct audrec_up_pkt_ready_msg pkt_ready_msg;
-
-		getevent(&pkt_ready_msg, AUDREC_UP_PACKET_READY_MSG_LEN);
-		MM_DBG("UP_PACKET_READY_MSG: write cnt lsw  %d \
-		write cnt msw %d read cnt lsw %d  read cnt msw %d \n",\
-		pkt_ready_msg.audrec_packet_write_cnt_lsw, \
-		pkt_ready_msg.audrec_packet_write_cnt_msw, \
-		pkt_ready_msg.audrec_up_prev_read_cnt_lsw, \
-		pkt_ready_msg.audrec_up_prev_read_cnt_msw);
-
-		audaac_in_get_dsp_frames(audio);
-		break;
-	}
-	case AUDREC_CMD_PCM_BUFFER_PTR_UPDATE_ARM_TO_ENC_MSG: {
-		MM_DBG("ptr_update recieved from DSP\n");
-		audpreproc_pcm_send_data(audio, 1);
-		break;
-	}
-	case AUDREC_CMD_PCM_CFG_ARM_TO_ENC_DONE_MSG: {
-		MM_ERR("AUDREC_CMD_PCM_CFG_ARM_TO_ENC_DONE_MSG");
-		audaac_in_mem_config(audio);
-		break;
-	}
-	case AUDREC_UP_NT_PACKET_READY_MSG: {
-		struct audrec_up_nt_packet_ready_msg pkt_ready_msg;
-
-		getevent(&pkt_ready_msg, AUDREC_UP_NT_PACKET_READY_MSG_LEN);
-		MM_DBG("UP_NT_PACKET_READY_MSG: write cnt lsw  %d \
-		write cnt msw %d read cnt lsw %d  read cnt msw %d \n",\
-		pkt_ready_msg.audrec_packetwrite_cnt_lsw, \
-		pkt_ready_msg.audrec_packetwrite_cnt_msw, \
-		pkt_ready_msg.audrec_upprev_readcount_lsw, \
-		pkt_ready_msg.audrec_upprev_readcount_msw);
-
-		audaac_nt_in_get_dsp_frames(audio);
-		break;
-	}
-	case AUDREC_CMD_EOS_ACK_MSG: {
-		MM_DBG("eos ack recieved\n");
-		break;
-	}
-	case AUDREC_CMD_FLUSH_DONE_MSG: {
-		audio->wflush = 0;
-		audio->rflush = 0;
-		audio->flush_ack = 1;
-		wake_up(&audio->write_wait);
-		MM_DBG("flush ack recieved\n");
-		break;
-	}
-	case ADSP_MESSAGE_ID: {
-		MM_DBG("Received ADSP event:module audrectask\n");
-		break;
-	}
-	default:
-		MM_ERR("Unknown Event id %d\n", id);
-	}
-}
-
-static void audaac_in_get_dsp_frames(struct audio_in *audio)
-{
-	struct audio_frame *frame;
-	uint32_t index;
-	unsigned long flags;
-
-	MM_DBG("head = %d\n", audio->in_head);
-	index = audio->in_head;
-
-	frame = (void *) (((char *)audio->in[index].data) - \
-			 sizeof(*frame));
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->in[index].size = frame->frame_length;
-
-	/* statistics of read */
-	atomic_add(audio->in[index].size, &audio->in_bytes);
-	atomic_add(1, &audio->in_samples);
-
-	audio->in_head = (audio->in_head + 1) & (FRAME_NUM - 1);
-
-	/* If overflow, move the tail index foward. */
-	if (audio->in_head == audio->in_tail) {
-		MM_ERR("Error! not able to keep up the read\n");
-		audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
-	} else
-		audio->in_count++;
-
-	audaac_dsp_read_buffer(audio, audio->dsp_cnt++);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-
-	wake_up(&audio->wait);
-}
-
-static void audaac_nt_in_get_dsp_frames(struct audio_in *audio)
-{
-	struct audio_frame_nt *nt_frame;
-	uint32_t index;
-	unsigned long flags;
-	MM_DBG("head = %d\n", audio->in_head);
-	index = audio->in_head;
-	nt_frame = (void *) (((char *)audio->in[index].data) - \
-				sizeof(struct audio_frame_nt));
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->in[index].size = nt_frame->frame_length;
-	/* statistics of read */
-	atomic_add(audio->in[index].size, &audio->in_bytes);
-	atomic_add(1, &audio->in_samples);
-
-	audio->in_head = (audio->in_head + 1) & (FRAME_NUM - 1);
-
-	/* If overflow, move the tail index foward. */
-	if (audio->in_head == audio->in_tail)
-		MM_DBG("Error! not able to keep up the read\n");
-	else
-		audio->in_count++;
-
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	wake_up(&audio->wait);
-}
-
-
-struct msm_adsp_ops audrec_aac_adsp_ops = {
-	.event = audrec_dsp_event,
-};
-
-static int audpreproc_pcm_buffer_ptr_refresh(struct audio_in *audio,
-				       unsigned idx, unsigned len)
-{
-	struct audrec_cmd_pcm_buffer_ptr_refresh_arm_enc cmd;
-
-	if (len ==  META_OUT_SIZE)
-		len = len / 2;
-	else
-		len = (len + META_OUT_SIZE) / 2;
-	MM_DBG("len = %d\n", len);
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_PCM_BUFFER_PTR_REFRESH_ARM_TO_ENC;
-	cmd.num_buffers = 1;
-	if (cmd.num_buffers == 1) {
-		cmd.buf_address_length[0] = (audio->out[idx].addr &
-							0xffff0000) >> 16;
-		cmd.buf_address_length[1] = (audio->out[idx].addr &
-							0x0000ffff);
-		cmd.buf_address_length[2] = (len & 0xffff0000) >> 16;
-		cmd.buf_address_length[3] = (len & 0x0000ffff);
-	}
-	audio->out_frame_cnt++;
-	return audrec_send_audrecqueue(audio, (void *)&cmd,
-					(unsigned int)sizeof(cmd));
-}
-
-
-static int audpcm_config(struct audio_in *audio)
-{
-	struct audrec_cmd_pcm_cfg_arm_to_enc cmd;
-	MM_DBG("\n");
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_PCM_CFG_ARM_TO_ENC;
-	cmd.config_update_flag = PCM_CONFIG_UPDATE_FLAG_ENABLE;
-	cmd.enable_flag = ENABLE_FLAG_VALUE;
-	cmd.sampling_freq = audio->samp_rate;
-	if (!audio->channel_mode)
-		cmd.channels = 1;
-	else
-		cmd.channels = 2;
-	cmd.frequency_of_intimation = 1;
-	cmd.max_number_of_buffers = OUT_FRAME_NUM;
-	return audrec_send_audrecqueue(audio, (void *)&cmd,
-					(unsigned int)sizeof(cmd));
-}
-
-
-static int audpreproc_cmd_cfg_routing_mode(struct audio_in *audio)
-{
-	struct audpreproc_audrec_cmd_routing_mode cmd;
-
-	MM_DBG("\n");
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPREPROC_AUDREC_CMD_ROUTING_MODE;
-	cmd.stream_id = audio->enc_id;
-	if (audio->mode == MSM_ADSP_ENC_MODE_NON_TUNNEL)
-		cmd.routing_mode = 1;
-	return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd));
-}
-
-
-
-static int audaac_in_enc_config(struct audio_in *audio, int enable)
-{
-	struct audpreproc_audrec_cmd_enc_cfg cmd;
-	memset(&cmd, 0, sizeof(cmd));
-	if (audio->build_id[17] == '1') {
-		cmd.cmd_id = AUDPREPROC_AUDREC_CMD_ENC_CFG_2;
-		MM_ERR("sending AUDPREPROC_AUDREC_CMD_ENC_CFG_2 command");
-	} else {
-		cmd.cmd_id = AUDPREPROC_AUDREC_CMD_ENC_CFG;
-		MM_ERR("sending AUDPREPROC_AUDREC_CMD_ENC_CFG command");
-	}
-	cmd.stream_id = audio->enc_id;
-
-	if (enable)
-		cmd.audrec_enc_type = audio->enc_type | ENCODE_ENABLE;
-	else
-		cmd.audrec_enc_type &= ~(ENCODE_ENABLE);
-
-	return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd));
-}
-
-static int audaac_in_param_config(struct audio_in *audio)
-{
-	struct audpreproc_audrec_cmd_parm_cfg_aac cmd;
-
-	MM_DBG("\n");
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPREPROC_AUDREC_CMD_PARAM_CFG;
-	cmd.common.stream_id = audio->enc_id;
-
-	cmd.aud_rec_samplerate_idx = audio->samp_rate;
-	cmd.aud_rec_stereo_mode = audio->channel_mode;
-	cmd.recording_quality = audio->record_quality;
-
-	return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd));
-}
-
-/* To Do: msm_snddev_route_enc(audio->enc_id); */
-static int audaac_in_record_config(struct audio_in *audio, int enable)
-{
-	struct audpreproc_afe_cmd_audio_record_cfg cmd;
-	MM_DBG("\n");
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG;
-	cmd.stream_id = audio->enc_id;
-	if (enable)
-		cmd.destination_activity = AUDIO_RECORDING_TURN_ON;
-	else
-		cmd.destination_activity = AUDIO_RECORDING_TURN_OFF;
-
-	cmd.source_mix_mask = audio->source;
-	if (audio->enc_id == 2) {
-		if ((cmd.source_mix_mask & INTERNAL_CODEC_TX_SOURCE_MIX_MASK) ||
-			(cmd.source_mix_mask & AUX_CODEC_TX_SOURCE_MIX_MASK) ||
-			(cmd.source_mix_mask & VOICE_UL_SOURCE_MIX_MASK) ||
-			(cmd.source_mix_mask & VOICE_DL_SOURCE_MIX_MASK)) {
-			cmd.pipe_id = SOURCE_PIPE_1;
-		}
-		if (cmd.source_mix_mask &
-				AUDPP_A2DP_PIPE_SOURCE_MIX_MASK)
-			cmd.pipe_id |= SOURCE_PIPE_0;
-	}
-	return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd));
-}
-
-static int audaac_in_mem_config(struct audio_in *audio)
-{
-	struct audrec_cmd_arecmem_cfg cmd;
-	uint16_t *data = (void *) audio->data;
-	int n;
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_MEM_CFG_CMD;
-	cmd.audrec_up_pkt_intm_count = 1;
-	cmd.audrec_ext_pkt_start_addr_msw = audio->phys >> 16;
-	cmd.audrec_ext_pkt_start_addr_lsw = audio->phys;
-	cmd.audrec_ext_pkt_buf_number = FRAME_NUM;
-	MM_DBG("audio->phys = %x\n", audio->phys);
-	/* prepare buffer pointers:
-	 * 1536 bytes aac packet + 4 halfword header
-	 */
-	for (n = 0; n < FRAME_NUM; n++) {
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			audio->in[n].data = data + 4;
-			data += (FRAME_SIZE/2);
-			MM_DBG("0x%8x\n", (int)(audio->in[n].data - 8));
-		} else  {
-			audio->in[n].data = data + 12;
-			data += ((AAC_FRAME_SIZE) / 2) + 12;
-			MM_DBG("0x%8x\n", (int)(audio->in[n].data - 24));
-		}
-	}
-	return audrec_send_audrecqueue(audio, &cmd, sizeof(cmd));
-}
-
-static int audaac_dsp_read_buffer(struct audio_in *audio, uint32_t read_cnt)
-{
-	struct up_audrec_packet_ext_ptr cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = UP_AUDREC_PACKET_EXT_PTR;
-	cmd.audrec_up_curr_read_count_msw = read_cnt >> 16;
-	cmd.audrec_up_curr_read_count_lsw = read_cnt;
-
-	return audrec_send_bitstreamqueue(audio, &cmd, sizeof(cmd));
-}
-static int audaac_flush_command(struct audio_in *audio)
-{
-	struct audrec_cmd_flush cmd;
-	MM_DBG("\n");
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_FLUSH;
-	return audrec_send_audrecqueue(audio, &cmd, sizeof(cmd));
-}
-
-/* must be called with audio->lock held */
-static int audaac_in_enable(struct audio_in *audio)
-{
-	if (audio->enabled)
-		return 0;
-
-	if (audpreproc_enable(audio->enc_id, &audpreproc_dsp_event, audio)) {
-		MM_ERR("msm_adsp_enable(audpreproc) failed\n");
-		return -ENODEV;
-	}
-
-	if (msm_adsp_enable(audio->audrec)) {
-		MM_ERR("msm_adsp_enable(audrec) failed\n");
-		audpreproc_disable(audio->enc_id, audio);
-		return -ENODEV;
-	}
-	audio->enabled = 1;
-	audaac_in_enc_config(audio, 1);
-
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audaac_in_disable(struct audio_in *audio)
-{
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audaac_in_enc_config(audio, 0);
-		wake_up(&audio->wait);
-		wait_event_interruptible_timeout(audio->wait_enable,
-				audio->running == 0, 1*HZ);
-		msm_adsp_disable(audio->audrec);
-		audpreproc_disable(audio->enc_id, audio);
-	}
-	return 0;
-}
-
-static void audaac_ioport_reset(struct audio_in *audio)
-{
-	/* Make sure read/write thread are free from
-	 * sleep and knowing that system is not able
-	 * to process io request at the moment
-	 */
-	wake_up(&audio->write_wait);
-	mutex_lock(&audio->write_lock);
-	audaac_in_flush(audio);
-	mutex_unlock(&audio->write_lock);
-	wake_up(&audio->wait);
-	mutex_lock(&audio->read_lock);
-	audaac_out_flush(audio);
-	mutex_unlock(&audio->read_lock);
-}
-
-static void audaac_in_flush(struct audio_in *audio)
-{
-	int i;
-
-	audio->dsp_cnt = 0;
-	audio->in_head = 0;
-	audio->in_tail = 0;
-	audio->in_count = 0;
-	audio->eos_ack = 0;
-	for (i = 0; i < FRAME_NUM; i++) {
-		audio->in[i].size = 0;
-		audio->in[i].read = 0;
-	}
-	MM_DBG("in_bytes %d\n", atomic_read(&audio->in_bytes));
-	MM_DBG("in_samples %d\n", atomic_read(&audio->in_samples));
-	atomic_set(&audio->in_bytes, 0);
-	atomic_set(&audio->in_samples, 0);
-}
-
-static void audaac_out_flush(struct audio_in *audio)
-{
-	int i;
-
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->out_count = 0;
-	for (i = 0; i < OUT_FRAME_NUM; i++) {
-		audio->out[i].size = 0;
-		audio->out[i].read = 0;
-		audio->out[i].used = 0;
-	}
-}
-
-/* ------------------- device --------------------- */
-static long audaac_in_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct audio_in *audio = file->private_data;
-	int rc = 0;
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		stats.byte_count = atomic_read(&audio->in_bytes);
-		stats.sample_count = atomic_read(&audio->in_samples);
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return rc;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START: {
-		uint32_t freq;
-		/* Poll at 48KHz always */
-		freq = 48000;
-		MM_DBG("AUDIO_START\n");
-		rc = msm_snddev_request_freq(&freq, audio->enc_id,
-					SNDDEV_CAP_TX, AUDDEV_CLNT_ENC);
-		MM_DBG("sample rate configured %d sample rate requested %d\n",
-				freq, audio->samp_rate);
-		if (rc < 0) {
-			MM_DBG(" Sample rate can not be set, return code %d\n",
-								 rc);
-			msm_snddev_withdraw_freq(audio->enc_id,
-					SNDDEV_CAP_TX, AUDDEV_CLNT_ENC);
-			MM_DBG("msm_snddev_withdraw_freq\n");
-			break;
-		}
-		/*update aurec session info in audpreproc layer*/
-		audio->session_info.session_id = audio->enc_id;
-		audio->session_info.sampling_freq = audio->samp_rate;
-		audpreproc_update_audrec_info(&audio->session_info);
-		rc = audaac_in_enable(audio);
-		if (!rc) {
-			rc =
-			wait_event_interruptible_timeout(audio->wait_enable,
-				audio->running != 0, 1*HZ);
-			MM_DBG("state %d rc = %d\n", audio->running, rc);
-
-			if (audio->running == 0)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		audio->stopped = 0;
-		break;
-	}
-	case AUDIO_STOP: {
-		audio->session_info.sampling_freq = 0;
-		audpreproc_update_audrec_info(&audio->session_info);
-		rc = audaac_in_disable(audio);
-		rc = msm_snddev_withdraw_freq(audio->enc_id,
-					SNDDEV_CAP_TX, AUDDEV_CLNT_ENC);
-		MM_DBG("msm_snddev_withdraw_freq\n");
-		audio->stopped = 1;
-		audio->abort = 0;
-		break;
-	}
-	case AUDIO_FLUSH:
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audaac_ioport_reset(audio);
-		if (audio->running) {
-			audaac_flush_command(audio);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-	case AUDIO_GET_STREAM_CONFIG: {
-		struct msm_audio_stream_config cfg;
-		memset(&cfg, 0, sizeof(cfg));
-		cfg.buffer_size = audio->buffer_size;
-		cfg.buffer_count = FRAME_NUM;
-		if (copy_to_user((void *)arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		break;
-	}
-	case AUDIO_SET_STREAM_CONFIG: {
-		struct msm_audio_stream_config cfg;
-		if (copy_from_user(&cfg, (void *)arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		/* Allow only single frame */
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			if (cfg.buffer_size != (FRAME_SIZE - 8)) {
-				rc = -EINVAL;
-				break;
-			}
-		} else {
-			if (cfg.buffer_size != (NT_FRAME_SIZE - 24)) {
-				rc = -EINVAL;
-				break;
-			}
-		}
-		audio->buffer_size = cfg.buffer_size;
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_pcm_config cfg;
-		memset(&cfg, 0, sizeof(cfg));
-		cfg.buffer_size = OUT_BUFFER_SIZE;
-		cfg.buffer_count = OUT_FRAME_NUM;
-		if (copy_to_user((void *)arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		break;
-	}
-	case AUDIO_GET_AAC_ENC_CONFIG: {
-		struct msm_audio_aac_enc_config cfg;
-		if (audio->channel_mode == AUDREC_CMD_MODE_MONO)
-			cfg.channels = 1;
-		else
-			cfg.channels = 2;
-		cfg.sample_rate = audio->samp_rate;
-		cfg.bit_rate = audio->bit_rate;
-		cfg.stream_format = AUDIO_AAC_FORMAT_RAW;
-		if (copy_to_user((void *)arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		break;
-	}
-	case AUDIO_SET_AAC_ENC_CONFIG: {
-		struct msm_audio_aac_enc_config cfg;
-		unsigned int record_quality;
-		if (copy_from_user(&cfg, (void *)arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (cfg.stream_format != AUDIO_AAC_FORMAT_RAW) {
-			MM_ERR("unsupported AAC format\n");
-			rc = -EINVAL;
-			break;
-		}
-		record_quality = bitrate_to_record_quality(cfg.sample_rate,
-					cfg.channels, cfg.bit_rate);
-		/* Range of Record Quality Supported by DSP, Q12 format */
-		if ((record_quality < 0x800) || (record_quality > 0x4000)) {
-			MM_ERR("Unsupported bit rate \n");
-			rc = -EINVAL;
-			break;
-		}
-		MM_DBG("channels = %d\n", cfg.channels);
-		if (cfg.channels == 1) {
-			cfg.channels = AUDREC_CMD_MODE_MONO;
-		} else if (cfg.channels == 2) {
-			cfg.channels = AUDREC_CMD_MODE_STEREO;
-		} else {
-			rc = -EINVAL;
-			break;
-		}
-		MM_DBG("channels = %d\n", cfg.channels);
-		audio->samp_rate = cfg.sample_rate;
-		audio->channel_mode = cfg.channels;
-		audio->bit_rate = cfg.bit_rate;
-		audio->record_quality = record_quality;
-		MM_DBG(" Record Quality = 0x%8x \n", audio->record_quality);
-		break;
-	}
-	case AUDIO_GET_SESSION_ID: {
-		if (copy_to_user((void *) arg, &audio->enc_id,
-			sizeof(unsigned short))) {
-			rc = -EFAULT;
-		}
-		break;
-	}
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static ssize_t audaac_in_read(struct file *file,
-				char __user *buf,
-				size_t count, loff_t *pos)
-{
-	struct audio_in *audio = file->private_data;
-	unsigned long flags;
-	const char __user *start = buf;
-	void *data;
-	uint32_t index;
-	uint32_t size;
-	int rc = 0;
-	struct aac_encoded_meta_in meta_field;
-	struct audio_frame_nt *nt_frame;
-	MM_DBG(" count = %d\n", count);
-	mutex_lock(&audio->read_lock);
-	while (count > 0) {
-		rc = wait_event_interruptible(
-			audio->wait, (audio->in_count > 0) || audio->stopped ||
-				audio->abort || audio->rflush);
-
-		if (rc < 0)
-			break;
-
-		if (audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (audio->stopped && !audio->in_count) {
-			MM_DBG("Driver in stop state, No more buffer to read");
-			rc = 0;/* End of File */
-			break;
-		}
-
-		if (audio->abort) {
-			rc = -EPERM; /* Not permitted due to abort */
-			break;
-		}
-
-		index = audio->in_tail;
-		data = (uint8_t *) audio->in[index].data;
-		size = audio->in[index].size;
-
-		if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) {
-			nt_frame = (struct audio_frame_nt *)(data -
-					sizeof(struct audio_frame_nt));
-			memcpy((char *)&meta_field.time_stamp_dword_lsw,
-				(char *)&nt_frame->time_stamp_dword_lsw, 12);
-			meta_field.metadata_len =
-					sizeof(struct aac_encoded_meta_in);
-			if (copy_to_user((char *)start, (char *)&meta_field,
-					sizeof(struct aac_encoded_meta_in))) {
-				rc = -EFAULT;
-				break;
-			}
-			if (nt_frame->nflag_lsw & 0x0001) {
-				MM_ERR("recieved EOS in read call\n");
-				audio->eos_ack = 1;
-			}
-			buf += sizeof(struct aac_encoded_meta_in);
-			count -= sizeof(struct aac_encoded_meta_in);
-		}
-		if (count >= size) {
-			if (copy_to_user(buf, data, size)) {
-				rc = -EFAULT;
-				break;
-			}
-			spin_lock_irqsave(&audio->dsp_lock, flags);
-			if (index != audio->in_tail) {
-				/* overrun -- data is
-				 * invalid and we need to retry */
-				spin_unlock_irqrestore(&audio->dsp_lock, flags);
-				continue;
-			}
-			audio->in[index].size = 0;
-			audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
-			audio->in_count--;
-			spin_unlock_irqrestore(&audio->dsp_lock, flags);
-			count -= size;
-			buf += size;
-			if ((audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) &&
-						(!audio->eos_ack)) {
-				MM_DBG("sending read ptr command %d %d\n",
-							audio->dsp_cnt,
-							audio->in_tail);
-				audaac_dsp_read_buffer(audio,
-							audio->dsp_cnt++);
-				break;
-			}
-		} else {
-			MM_ERR("short read\n");
-			break;
-		}
-		break;
-	}
-	mutex_unlock(&audio->read_lock);
-	if (buf > start)
-		return buf - start;
-
-	return rc;
-}
-
-static void audpreproc_pcm_send_data(struct audio_in *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-	MM_DBG("\n");
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			MM_DBG("frame %d free\n", audio->out_tail);
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			MM_DBG("frame %d busy\n", audio->out_tail);
-			audpreproc_pcm_buffer_ptr_refresh(audio,
-						 audio->out_tail,
-						    frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
- done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-
-static int audaac_in_fsync(struct file *file, loff_t ppos1, loff_t ppos2, int datasync)
-
-{
-	struct audio_in *audio = file->private_data;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (!audio->running || (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)) {
-		rc = -EINVAL;
-		goto done_nolock;
-	}
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-			audio->wflush);
-	MM_DBG("waked on by some event audio->wflush = %d\n", audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-done:
-	mutex_unlock(&audio->write_lock);
-done_nolock:
-	return rc;
-
-}
-
- int audpreproc_aac_process_eos(struct audio_in *audio,
-		const char __user *buf_start, unsigned short mfield_size)
-{
-	struct buffer *frame;
-	int rc = 0;
-
-	frame = audio->out + audio->out_head;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	MM_DBG("copying meta_out frame->used = %d\n", frame->used);
-	audpreproc_pcm_send_data(audio, 0);
-done:
-	return rc;
-}
-
-static ssize_t audaac_in_write(struct file *file,
-				const char __user *buf,
-				size_t count, loff_t *pos)
-{
-	struct audio_in *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	char *cpy_ptr;
-	int rc = 0, eos_condition = AUDPREPROC_AAC_EOS_NONE;
-	unsigned short mfield_size = 0;
-	int write_count = count;
-	MM_DBG("cnt=%d\n", count);
-
-	if (count & 1)
-		return -EINVAL;
-
-	mutex_lock(&audio->write_lock);
-	frame = audio->out + audio->out_head;
-	cpy_ptr = frame->data;
-	rc = wait_event_interruptible(audio->write_wait,
-				      (frame->used == 0)
-					|| (audio->stopped)
-					|| (audio->wflush));
-	if (rc < 0)
-		goto error;
-
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto error;
-	}
-	if (audio->mfield) {
-		if (buf == start) {
-			/* Processing beginning of user buffer */
-			if (__get_user(mfield_size,
-				(unsigned short __user *) buf)) {
-				rc = -EFAULT;
-				goto error;
-			} else if (mfield_size > count) {
-				rc = -EINVAL;
-				goto error;
-			}
-			MM_DBG("mf offset_val %x\n", mfield_size);
-			if (copy_from_user(cpy_ptr, buf, mfield_size)) {
-				rc = -EFAULT;
-				goto error;
-			}
-			/* Check if EOS flag is set and buffer has
-			 * contains just meta field
-			 */
-			if (cpy_ptr[AUDPREPROC_AAC_EOS_FLG_OFFSET] &
-					AUDPREPROC_AAC_EOS_FLG_MASK) {
-				MM_DBG("EOS SET\n");
-				eos_condition = AUDPREPROC_AAC_EOS_SET;
-				if (mfield_size == count) {
-					buf += mfield_size;
-					if (audio->mode ==
-						MSM_AUD_ENC_MODE_NONTUNNEL) {
-						eos_condition = 0;
-						goto exit;
-					}
-					goto error;
-				} else
-				cpy_ptr[AUDPREPROC_AAC_EOS_FLG_OFFSET] &=
-					~AUDPREPROC_AAC_EOS_FLG_MASK;
-			}
-			cpy_ptr += mfield_size;
-			count -= mfield_size;
-			buf += mfield_size;
-		} else {
-			mfield_size = 0;
-			MM_DBG("continuous buffer\n");
-		}
-		frame->mfield_sz = mfield_size;
-	}
-	MM_DBG("copying the stream count = %d\n", count);
-	if (copy_from_user(cpy_ptr, buf, count)) {
-		rc = -EFAULT;
-		goto error;
-	}
-exit:
-	frame->used = count;
-	audio->out_head ^= 1;
-	if (!audio->flush_ack)
-		audpreproc_pcm_send_data(audio, 0);
-	else {
-		audpreproc_pcm_send_data(audio, 1);
-		audio->flush_ack = 0;
-	}
-	if (eos_condition == AUDPREPROC_AAC_EOS_SET)
-		rc = audpreproc_aac_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	return write_count;
-error:
-	mutex_unlock(&audio->write_lock);
-	return rc;
-}
-
-static int audaac_in_release(struct inode *inode, struct file *file)
-{
-	struct audio_in *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	/* with draw frequency for session
-	   incase not stopped the driver */
-	msm_snddev_withdraw_freq(audio->enc_id, SNDDEV_CAP_TX,
-					AUDDEV_CLNT_ENC);
-	auddev_unregister_evt_listner(AUDDEV_CLNT_ENC, audio->enc_id);
-	/*reset the sampling frequency information at audpreproc layer*/
-	audio->session_info.sampling_freq = 0;
-	audpreproc_update_audrec_info(&audio->session_info);
-	audaac_in_disable(audio);
-	audaac_in_flush(audio);
-	msm_adsp_put(audio->audrec);
-	audpreproc_aenc_free(audio->enc_id);
-	audio->audrec = NULL;
-	audio->opened = 0;
-	if (audio->data) {
-		iounmap(audio->map_v_read);
-		free_contiguous_memory_by_paddr(audio->phys);
-		audio->data = NULL;
-	}
-	if (audio->out_data) {
-		iounmap(audio->map_v_write);
-		free_contiguous_memory_by_paddr(audio->out_phys);
-		audio->out_data = NULL;
-	}
-	mutex_unlock(&audio->lock);
-	return 0;
-}
-
-struct audio_in the_audio_aac_in;
-
-static int audaac_in_open(struct inode *inode, struct file *file)
-{
-	struct audio_in *audio = &the_audio_aac_in;
-	int rc;
-	int encid;
-
-	mutex_lock(&audio->lock);
-	if (audio->opened) {
-		rc = -EBUSY;
-		goto done;
-	}
-	audio->phys = allocate_contiguous_ebi_nomap(DMASZ, SZ_4K);
-	if (audio->phys) {
-		audio->map_v_read = ioremap(audio->phys, DMASZ);
-		if (IS_ERR(audio->map_v_read)) {
-			MM_ERR("could not map DMA buffers\n");
-			rc = -ENOMEM;
-			free_contiguous_memory_by_paddr(audio->phys);
-			goto done;
-		}
-		audio->data = audio->map_v_read;
-	} else {
-		MM_ERR("could not allocate DMA buffers\n");
-		rc = -ENOMEM;
-		goto done;
-	}
-	MM_DBG("Memory addr = 0x%8x  phy addr = 0x%8x\n",\
-		(int) audio->data, (int) audio->phys);
-	if ((file->f_mode & FMODE_WRITE) &&
-				(file->f_mode & FMODE_READ)) {
-		audio->mode = MSM_AUD_ENC_MODE_NONTUNNEL;
-	} else if (!(file->f_mode & FMODE_WRITE) &&
-					(file->f_mode & FMODE_READ)) {
-		audio->mode = MSM_AUD_ENC_MODE_TUNNEL;
-		MM_DBG("Opened for tunnel mode encoding\n");
-	} else {
-		rc = -EACCES;
-		goto done;
-	}
-
-	/* Settings will be re-config at AUDIO_SET_CONFIG,
-	 * but at least we need to have initial config
-	 */
-	 if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL)
-			audio->buffer_size = (NT_FRAME_SIZE - 24);
-	else
-			audio->buffer_size = (FRAME_SIZE - 8);
-	audio->enc_type = ENC_TYPE_AAC | audio->mode;
-	audio->samp_rate = 8000;
-	audio->channel_mode = AUDREC_CMD_MODE_MONO;
-	/* For AAC, bit rate hard coded, default settings is
-	 * sample rate (8000) x channel count (1) x recording quality (1.75)
-	 * = 14000 bps  */
-	audio->bit_rate = 14000;
-	audio->record_quality = 0x1c00;
-	MM_DBG("enc_type = %x\n", audio->enc_type);
-	encid = audpreproc_aenc_alloc(audio->enc_type, &audio->module_name,
-			&audio->queue_ids);
-	if (encid < 0) {
-		MM_ERR("No free encoder available\n");
-		rc = -ENODEV;
-		goto done;
-	}
-	audio->enc_id = encid;
-
-	rc = msm_adsp_get(audio->module_name, &audio->audrec,
-			   &audrec_aac_adsp_ops, audio);
-
-	if (rc) {
-		audpreproc_aenc_free(audio->enc_id);
-		goto done;
-	}
-
-	audio->stopped = 0;
-	audio->source = 0;
-	audio->abort = 0;
-	audio->wflush = 0;
-	audio->rflush = 0;
-	audio->flush_ack = 0;
-
-	audaac_in_flush(audio);
-	audaac_out_flush(audio);
-
-	audio->out_phys = allocate_contiguous_ebi_nomap(BUFFER_SIZE, SZ_4K);
-	if (!audio->out_phys) {
-		MM_ERR("could not allocate write buffers\n");
-		rc = -ENOMEM;
-		goto evt_error;
-	} else {
-		audio->map_v_write = ioremap(
-					audio->out_phys, BUFFER_SIZE);
-		if (IS_ERR(audio->map_v_write)) {
-			MM_ERR("could not map write phys address\n");
-			rc = -ENOMEM;
-			free_contiguous_memory_by_paddr(audio->out_phys);
-			goto evt_error;
-		}
-		audio->out_data = audio->map_v_write;
-		MM_DBG("write buf: phy addr 0x%08x kernel addr 0x%08x\n",
-				audio->out_phys, (int)audio->out_data);
-	}
-	audio->build_id = socinfo_get_build_id();
-	MM_DBG("Modem build id = %s\n", audio->build_id);
-
-		/* Initialize buffer */
-	audio->out[0].data = audio->out_data + 0;
-	audio->out[0].addr = audio->out_phys + 0;
-	audio->out[0].size = OUT_BUFFER_SIZE;
-
-	audio->out[1].data = audio->out_data + OUT_BUFFER_SIZE;
-	audio->out[1].addr = audio->out_phys + OUT_BUFFER_SIZE;
-	audio->out[1].size = OUT_BUFFER_SIZE;
-
-	MM_DBG("audio->out[0].data = %d  audio->out[1].data = %d",
-					(unsigned int)audio->out[0].data,
-					(unsigned int)audio->out[1].data);
-	audio->device_events = AUDDEV_EVT_DEV_RDY | AUDDEV_EVT_DEV_RLS |
-				AUDDEV_EVT_FREQ_CHG;
-
-	rc = auddev_register_evt_listner(audio->device_events,
-					AUDDEV_CLNT_ENC, audio->enc_id,
-					aac_in_listener, (void *) audio);
-	if (rc) {
-		MM_ERR("failed to register device event listener\n");
-		iounmap(audio->map_v_write);
-		free_contiguous_memory_by_paddr(audio->out_phys);
-		goto evt_error;
-	}
-	audio->mfield = META_OUT_SIZE;
-	file->private_data = audio;
-	audio->opened = 1;
-	audio->out_frame_cnt++;
-	rc = 0;
-done:
-	mutex_unlock(&audio->lock);
-	return rc;
-evt_error:
-	msm_adsp_put(audio->audrec);
-	audpreproc_aenc_free(audio->enc_id);
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static const struct file_operations audio_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audaac_in_open,
-	.release	= audaac_in_release,
-	.read		= audaac_in_read,
-	.write		= audaac_in_write,
-	.fsync		= audaac_in_fsync,
-	.unlocked_ioctl	= audaac_in_ioctl,
-};
-
-struct miscdevice audio_aac_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_aac_in",
-	.fops	= &audio_in_fops,
-};
-
-static int __init audaac_in_init(void)
-{
-	mutex_init(&the_audio_aac_in.lock);
-	mutex_init(&the_audio_aac_in.read_lock);
-	spin_lock_init(&the_audio_aac_in.dsp_lock);
-	spin_lock_init(&the_audio_aac_in.dev_lock);
-	init_waitqueue_head(&the_audio_aac_in.wait);
-	init_waitqueue_head(&the_audio_aac_in.wait_enable);
-	mutex_init(&the_audio_aac_in.write_lock);
-	init_waitqueue_head(&the_audio_aac_in.write_wait);
-
-	return misc_register(&audio_aac_in_misc);
-}
-
-device_initcall(audaac_in_init);
diff --git a/arch/arm/mach-msm/qdsp5v2/audio_acdb.c b/arch/arm/mach-msm/qdsp5v2/audio_acdb.c
deleted file mode 100644
index 85378be..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audio_acdb.c
+++ /dev/null
@@ -1,3429 +0,0 @@
-/* Copyright (c) 2009-2012, The Linux Foundation. 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.
- *
- */
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/mutex.h>
-#include <linux/io.h>
-#include <linux/delay.h>
-#include <linux/dma-mapping.h>
-#include <linux/uaccess.h>
-#include <linux/msm_audio.h>
-#include <linux/slab.h>
-#include <linux/debugfs.h>
-#include <linux/memory_alloc.h>
-#include <linux/mfd/marimba.h>
-#include <mach/dal.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/qdsp5v2/audpp.h>
-#include <mach/socinfo.h>
-#include <mach/qdsp5v2/audpreproc.h>
-#include <mach/qdsp5v2/qdsp5audppcmdi.h>
-#include <mach/qdsp5v2/qdsp5audpreproccmdi.h>
-#include <mach/qdsp5v2/qdsp5audpreprocmsg.h>
-#include <mach/qdsp5v2/qdsp5audppmsg.h>
-#include <mach/qdsp5v2/afe.h>
-#include <mach/qdsp5v2/audio_acdbi.h>
-#include <mach/qdsp5v2/acdb_commands.h>
-#include <mach/qdsp5v2/audio_acdb_def.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_memtypes.h>
-
-/* this is the ACDB device ID */
-#define DALDEVICEID_ACDB		0x02000069
-#define ACDB_PORT_NAME			"DAL00"
-#define ACDB_CPU			SMD_APPS_MODEM
-#define ACDB_BUF_SIZE			4096
-#define PBE_BUF_SIZE                    (33*1024)
-#define FLUENCE_BUF_SIZE	498
-
-#define ACDB_VALUES_NOT_FILLED		0
-#define ACDB_VALUES_FILLED		1
-#define MAX_RETRY			10
-
-/*below macro is used to align the session info received from
-Devctl driver with the state mentioned as not to alter the
-Existing code*/
-#define AUDREC_OFFSET	2
-/* rpc table index */
-enum {
-	ACDB_DalACDB_ioctl = DALDEVICE_FIRST_DEVICE_API_IDX
-};
-
-enum {
-	CAL_DATA_READY	= 0x1,
-	AUDPP_READY	= 0x2,
-	AUDREC0_READY	= 0x4,
-	AUDREC1_READY	= 0x8,
-	AUDREC2_READY	= 0x10,
-};
-
-
-struct acdb_data {
-	void *handle;
-
-	u32 phys_addr;
-	u8 *virt_addr;
-
-	struct task_struct *cb_thread_task;
-	struct auddev_evt_audcal_info *device_info;
-
-	u32 acdb_state;
-	struct audpp_event_callback audpp_cb;
-	struct audpreproc_event_callback audpreproc_cb;
-
-	struct audpp_cmd_cfg_object_params_pcm *pp_iir;
-	struct audpp_cmd_cfg_cal_gain *calib_gain_rx;
-	struct audpp_cmd_cfg_pbe *pbe_block;
-	struct audpp_cmd_cfg_object_params_mbadrc *pp_mbadrc;
-	struct audpreproc_cmd_cfg_agc_params *preproc_agc;
-	struct audpreproc_cmd_cfg_iir_tuning_filter_params *preproc_iir;
-	struct audpreproc_cmd_cfg_cal_gain *calib_gain_tx;
-	struct acdb_mbadrc_block mbadrc_block;
-	struct audpreproc_cmd_cfg_lvnv_param preproc_lvnv;
-
-	wait_queue_head_t wait;
-	struct mutex acdb_mutex;
-	u32 device_cb_compl;
-	u32 audpp_cb_compl;
-	u32 preproc_cb_compl;
-	u8 preproc_stream_id;
-	u8 audrec_applied;
-	u32 multiple_sessions;
-	u32 cur_tx_session;
-	struct acdb_result acdb_result;
-	u16 *pbe_extbuff;
-	u16 *pbe_enable_flag;
-	u32 fluence_extbuff;
-	u8 *fluence_extbuff_virt;
-	void *map_v_fluence;
-
-	struct acdb_pbe_block *pbe_blk;
-
-	spinlock_t dsp_lock;
-	int dec_id;
-	struct audpp_cmd_cfg_object_params_eqalizer eq;
-	 /*status to enable or disable the fluence*/
-	int fleuce_feature_status[MAX_AUDREC_SESSIONS];
-	struct audrec_session_info session_info;
-	/*pmem info*/
-	int pmem_fd;
-	unsigned long paddr;
-	unsigned long kvaddr;
-	unsigned long pmem_len;
-	struct file *file;
-	/* pmem for get acdb blk */
-	unsigned long	get_blk_paddr;
-	u8		*get_blk_kvaddr;
-	void *map_v_get_blk;
-	char *build_id;
-};
-
-static struct acdb_data		acdb_data;
-
-struct acdb_cache_node {
-	u32 node_status;
-	s32 stream_id;
-	u32 phys_addr_acdb_values;
-	void *map_v_addr;
-	u8 *virt_addr_acdb_values;
-	struct auddev_evt_audcal_info device_info;
-};
-
-/*for RX devices  acdb values are applied based on copp ID so
-the depth of tx cache is MAX number of COPP supported in the system*/
-struct acdb_cache_node acdb_cache_rx[MAX_COPP_NODE_SUPPORTED];
-
-/*for TX devices acdb values are applied based on AUDREC session and
-the depth of the tx cache is define by number of AUDREC sessions supported*/
-struct acdb_cache_node acdb_cache_tx[MAX_AUDREC_SESSIONS];
-
-/*Audrec session info includes Attributes Sampling frequency and enc_id */
-struct audrec_session_info session_info[MAX_AUDREC_SESSIONS];
-#ifdef CONFIG_DEBUG_FS
-
-#define RTC_MAX_TIMEOUT 500 /* 500 ms */
-#define PMEM_RTC_ACDB_QUERY_MEM 4096
-#define EXTRACT_HIGH_WORD(x) ((x & 0xFFFF0000)>>16)
-#define EXTRACT_LOW_WORD(x) (0x0000FFFF & x)
-#define	ACDB_RTC_TX 0xF1
-#define	ACDB_RTC_RX 0x1F
-
-
-static u32 acdb_audpp_entry[][4] = {
-
-  { ABID_AUDIO_RTC_VOLUME_PAN_RX,\
-    IID_AUDIO_RTC_VOLUME_PAN_PARAMETERS,\
-    AUDPP_CMD_VOLUME_PAN,\
-    ACDB_RTC_RX
-   },
-  { ABID_AUDIO_IIR_RX,\
-     IID_AUDIO_IIR_COEFF,\
-     AUDPP_CMD_IIR_TUNING_FILTER,
-     ACDB_RTC_RX
-   },
-  { ABID_AUDIO_RTC_EQUALIZER_PARAMETERS,\
-     IID_AUDIO_RTC_EQUALIZER_PARAMETERS,\
-     AUDPP_CMD_EQUALIZER,\
-     ACDB_RTC_RX
-   },
-  { ABID_AUDIO_RTC_SPA,\
-     IID_AUDIO_RTC_SPA_PARAMETERS,\
-     AUDPP_CMD_SPECTROGRAM,
-     ACDB_RTC_RX
-   },
-  { ABID_AUDIO_STF_RX,\
-     IID_AUDIO_IIR_COEFF,\
-     AUDPP_CMD_SIDECHAIN_TUNING_FILTER,\
-     ACDB_RTC_RX
-  },
-  {
-     ABID_AUDIO_MBADRC_RX,\
-     IID_AUDIO_RTC_MBADRC_PARAMETERS,\
-     AUDPP_CMD_MBADRC,\
-     ACDB_RTC_RX
-  },
-  {
-    ABID_AUDIO_AGC_TX,\
-    IID_AUDIO_AGC_PARAMETERS,\
-    AUDPREPROC_CMD_CFG_AGC_PARAMS,\
-    ACDB_RTC_TX
-  },
-  {
-    ABID_AUDIO_AGC_TX,\
-    IID_AUDIO_RTC_AGC_PARAMETERS,\
-    AUDPREPROC_CMD_CFG_AGC_PARAMS,\
-    ACDB_RTC_TX
-  },
-  {
-    ABID_AUDIO_NS_TX,\
-    IID_NS_PARAMETERS,\
-    AUDPREPROC_CMD_CFG_NS_PARAMS,\
-    ACDB_RTC_TX
-  },
-  {
-     ABID_AUDIO_IIR_TX,\
-     IID_AUDIO_RTC_TX_IIR_COEFF,\
-     AUDPREPROC_CMD_CFG_IIR_TUNING_FILTER_PARAMS,\
-     ACDB_RTC_TX
-  },
-  {
-     ABID_AUDIO_IIR_TX,\
-     IID_AUDIO_IIR_COEFF,\
-     AUDPREPROC_CMD_CFG_IIR_TUNING_FILTER_PARAMS,\
-     ACDB_RTC_TX
-  }
- /*Any new entries should be added here*/
-};
-
-static struct dentry *get_set_abid_dentry;
-static struct dentry *get_set_abid_data_dentry;
-
-struct rtc_acdb_pmem {
-	u8 *viraddr;
-	int32_t phys;
-	void *map_v_rtc;
-};
-
-struct rtc_acdb_data {
-	u32 acdb_id;
-	u32 cmd_id;
-	u32 set_abid;
-	u32 set_iid;
-	u32 abid;
-	u32 err;
-	bool valid_abid;
-	u32 tx_rx_ctl;
-	struct rtc_acdb_pmem rtc_read;
-	struct rtc_acdb_pmem rtc_write;
-	wait_queue_head_t  wait;
-};
-
-struct get_abid {
-	u32	cmd_id;
-	u32	acdb_id;
-	u32	set_abid;
-	u32	set_iid;
-};
-
-struct acdb_block_mbadrc_rtc {
-	u16 enable;
-	u16 num_bands;
-	u16 down_samp_level;
-	u16 adrc_delay;
-	u16 ext_buf_size;
-	u16 ext_partition;
-	u16 ext_buf_msw;
-	u16 ext_buf_lsw;
-	struct adrc_config adrc_band[AUDPP_MAX_MBADRC_BANDS];
-	signed int ExtBuff[196];
-} __attribute__((packed));
-
-enum {
-	ACDB_RTC_SUCCESS,
-	ACDB_RTC_ERR_INVALID_DEVICE,
-	ACDB_RTC_ERR_DEVICE_INACTIVE,
-	ACDB_RTC_ERR_INVALID_ABID,
-	ACDB_RTC_DSP_FAILURE,
-	ACDB_RTC_DSP_FEATURE_NOT_AVAILABLE,
-	ACDB_RTC_ERR_INVALID_LEN,
-	ACDB_RTC_ERR_UNKNOWN_FAILURE,
-	ACDB_RTC_PENDING_RESPONSE,
-	ACDB_RTC_INIT_FAILURE,
-};
-
-static  struct rtc_acdb_data rtc_acdb;
-
-static int rtc_getsetabid_dbg_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	MM_INFO("GET-SET ABID Open debug intf %s\n",
-			(char *) file->private_data);
-	return 0;
-}
-
-static bool get_feature_id(u32 set_abid, u32 iid, unsigned short *feature_id)
-{
-	bool ret_value = false;
-	int i = 0;
-
-	for (; i < (sizeof(acdb_audpp_entry) / sizeof(acdb_audpp_entry[0]));\
-		i++) {
-		if (acdb_audpp_entry[i][0] == set_abid &&
-			acdb_audpp_entry[i][1] == iid) {
-			*feature_id =  acdb_audpp_entry[i][2];
-			rtc_acdb.tx_rx_ctl = acdb_audpp_entry[i][3];
-			ret_value = true;
-			break;
-		}
-	}
-	return ret_value;
-}
-static ssize_t rtc_getsetabid_dbg_write(struct file *filp,
-					const char __user *ubuf,
-					size_t cnt, loff_t *ppos)
-{
-	struct  get_abid write_abid;
-	unsigned short feat_id = 0;
-	rtc_acdb.valid_abid = false;
-
-	if (copy_from_user(&write_abid, \
-		(void *)ubuf, sizeof(struct get_abid))) {
-		MM_ERR("ACDB DATA WRITE - INVALID READ LEN\n");
-		rtc_acdb.err = ACDB_RTC_ERR_INVALID_LEN;
-		return cnt;
-	}
-	MM_INFO("SET ABID : Cmd ID: %d Device:%d ABID:%d IID : %d cnt: %d\n",\
-		write_abid.cmd_id, write_abid.acdb_id,
-		write_abid.set_abid, write_abid.set_iid, cnt);
-	if (write_abid.acdb_id > ACDB_ID_MAX ||
-		write_abid.acdb_id < ACDB_ID_HANDSET_SPKR){
-		rtc_acdb.err = ACDB_RTC_ERR_INVALID_DEVICE;
-		return cnt;
-	}
-	if (!is_dev_opened(write_abid.acdb_id))	{
-		rtc_acdb.err = ACDB_RTC_ERR_DEVICE_INACTIVE;
-		return cnt;
-	}
-	rtc_acdb.err = ACDB_RTC_ERR_INVALID_ABID;
-	rtc_acdb.abid = write_abid.set_abid;
-	if (get_feature_id(write_abid.set_abid, \
-		write_abid.set_iid, &feat_id)) {
-		rtc_acdb.err = ACDB_RTC_SUCCESS;
-		rtc_acdb.cmd_id = write_abid.cmd_id;
-		rtc_acdb.acdb_id = write_abid.acdb_id;
-		rtc_acdb.set_abid = feat_id;
-		rtc_acdb.valid_abid = true;
-		rtc_acdb.set_iid = write_abid.set_iid;
-	}
-	return cnt;
-}
-static ssize_t	rtc_getsetabid_dbg_read(struct file *file, char __user *buf,
-					size_t count, loff_t *ppos)
-{
-	static char buffer[1024];
-	int n = 0;
-	u32 msg = rtc_acdb.err;
-	memcpy(buffer, &rtc_acdb.cmd_id, sizeof(struct get_abid));
-	memcpy(buffer+16, &msg, 4);
-	n = 20;
-	MM_INFO("SET ABID : Cmd ID: %x Device:%x ABID:%x IID : %x Err: %d\n",\
-		rtc_acdb.cmd_id, rtc_acdb.acdb_id, rtc_acdb.set_abid,\
-		rtc_acdb.set_iid, rtc_acdb.err);
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static int rtc_getsetabid_data_dbg_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	MM_INFO("GET-SET ABID DATA Open debug intf %s\n",
-		(char *) file->private_data);
-	return 0;
-}
-
-void acdb_rtc_set_err(u32 ErrCode)
-{
-	if (rtc_acdb.err == ACDB_RTC_PENDING_RESPONSE) {
-		if (ErrCode == 0xFFFF) {
-			rtc_acdb.err = ACDB_RTC_SUCCESS;
-			MM_INFO("RTC READ SUCCESS---\n");
-		} else if (ErrCode == 0) {
-			rtc_acdb.err = ACDB_RTC_DSP_FAILURE;
-			MM_INFO("RTC READ FAIL---\n");
-		} else if (ErrCode == 1) {
-			rtc_acdb.err = ACDB_RTC_DSP_FEATURE_NOT_AVAILABLE;
-			MM_INFO("RTC READ FEAT UNAVAILABLE---\n");
-		} else {
-			rtc_acdb.err = ACDB_RTC_DSP_FAILURE;
-			MM_ERR("RTC Err CODE---\n");
-		}
-	} else {
-		rtc_acdb.err = ACDB_RTC_DSP_FAILURE;
-		MM_ERR("RTC Err code Invalid State\n");
-	}
-	wake_up(&rtc_acdb.wait);
-}
-static ssize_t	rtc_getsetabid_data_dbg_read(struct file *file,
-					char __user *buf, size_t count,
-					loff_t *ppos)
-{
-	static char buffer[PMEM_RTC_ACDB_QUERY_MEM];
-	int rc, n = 0;
-	int counter = 0;
-	struct rtc_acdb_pmem *rtc_read = &rtc_acdb.rtc_read;
-	memset(&buffer, 0, PMEM_RTC_ACDB_QUERY_MEM);
-
-	if (rtc_acdb.valid_abid != true) {
-		MM_ERR("ACDB DATA READ ---INVALID ABID\n");
-		n = 0;
-		rtc_acdb.err = ACDB_RTC_ERR_INVALID_ABID;
-	} else {
-		if (PMEM_RTC_ACDB_QUERY_MEM < count) {
-			MM_ERR("ACDB DATA READ ---\
-				INVALID READ LEN %x\n", count);
-			n = 0;
-			rtc_acdb.err = ACDB_RTC_ERR_INVALID_LEN;
-		} else {
-			rtc_acdb.err = ACDB_RTC_PENDING_RESPONSE;
-			if (rtc_read->viraddr != NULL) {
-				memset(rtc_read->viraddr,
-					0, PMEM_RTC_ACDB_QUERY_MEM);
-			}
-			if (rtc_acdb.tx_rx_ctl == ACDB_RTC_RX) {
-				struct rtc_audpp_read_data rtc_read_cmd;
-				rtc_read_cmd.cmd_id =
-					AUDPP_CMD_PP_FEAT_QUERY_PARAMS;
-				rtc_read_cmd.obj_id =
-					AUDPP_CMD_COPP_STREAM;
-				rtc_read_cmd.route_id =
-					acdb_data.device_info->dev_id;
-				rtc_read_cmd.feature_id = rtc_acdb.set_abid;
-				rtc_read_cmd.extbufsizemsw =
-					EXTRACT_HIGH_WORD(\
-						PMEM_RTC_ACDB_QUERY_MEM);
-				rtc_read_cmd.extbufsizelsw =
-					EXTRACT_LOW_WORD(\
-						PMEM_RTC_ACDB_QUERY_MEM);
-				rtc_read_cmd.extpart = 0x0000;
-				rtc_read_cmd.extbufstartmsw =
-					EXTRACT_HIGH_WORD(rtc_read->phys);
-				rtc_read_cmd.extbufstartlsw =
-					EXTRACT_LOW_WORD(rtc_read->phys);
-				rc = audpp_send_queue2(&rtc_read_cmd,
-						sizeof(rtc_read_cmd));
-				MM_INFO("ACDB READ Command RC --->%x\
-					Route ID=%x\n", rc,\
-					acdb_data.device_info->dev_id);
-			} else if (rtc_acdb.tx_rx_ctl == ACDB_RTC_TX) {
-				struct rtc_audpreproc_read_data rtc_audpreproc;
-				rtc_audpreproc.cmd_id =
-					AUDPREPROC_CMD_FEAT_QUERY_PARAMS;
-				rtc_audpreproc.stream_id =
-					acdb_data.preproc_stream_id;
-				rtc_audpreproc.feature_id = rtc_acdb.set_abid;
-				rtc_audpreproc.extbufsizemsw =
-					EXTRACT_HIGH_WORD(\
-						PMEM_RTC_ACDB_QUERY_MEM);
-				rtc_audpreproc.extbufsizelsw =
-					EXTRACT_LOW_WORD(\
-						PMEM_RTC_ACDB_QUERY_MEM);
-				rtc_audpreproc.extpart = 0x0000;
-				rtc_audpreproc.extbufstartmsw =
-					EXTRACT_HIGH_WORD(rtc_read->phys);
-				rtc_audpreproc.extbufstartlsw =
-					EXTRACT_LOW_WORD(rtc_read->phys);
-				rc =  audpreproc_send_preproccmdqueue(
-						&rtc_audpreproc,\
-						sizeof(rtc_audpreproc));
-				MM_INFO("ACDB READ Command RC --->%x,\
-					stream_id %x\n", rc,\
-					acdb_data.preproc_stream_id);
-			}
-		rc = wait_event_timeout(rtc_acdb.wait,
-					(rtc_acdb.err !=
-					ACDB_RTC_PENDING_RESPONSE),
-					msecs_to_jiffies(RTC_MAX_TIMEOUT));
-		MM_INFO("ACDB READ ACK Count = %x Err = %x\n",
-			count, rtc_acdb.err);
-		{
-			if (rtc_acdb.err == ACDB_RTC_SUCCESS
-				&& rtc_read->viraddr != NULL) {
-				memcpy(buffer, rtc_read->viraddr, count);
-				n = count;
-				while (counter < count) {
-					MM_DBG("%x", \
-						rtc_read->viraddr[counter]);
-					counter++;
-					}
-				}
-		}
-	}
-	}
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static bool acdb_set_tx_rtc(const char *ubuf, size_t writecount)
-{
-	struct audpreproc_cmd_cfg_iir_tuning_filter_params *preproc_iir;
-	struct audpreproc_cmd_cfg_agc_params *preproc_agc;
-	struct audpreproc_cmd_cfg_ns_params *preproc_ns;
-	s32	result = 0;
-	bool retval = false;
-	unsigned short iircmdsize =
-		sizeof(struct audpreproc_cmd_cfg_iir_tuning_filter_params);
-	unsigned short iircmdid = AUDPREPROC_CMD_CFG_IIR_TUNING_FILTER_PARAMS;
-
-	rtc_acdb.err = ACDB_RTC_ERR_UNKNOWN_FAILURE;
-
-	switch (rtc_acdb.set_abid) {
-
-	case AUDPREPROC_CMD_CFG_AGC_PARAMS:
-	case AUDPREPROC_CMD_CFG_AGC_PARAMS_2:
-	{
-		preproc_agc = kmalloc(sizeof(\
-					struct audpreproc_cmd_cfg_agc_params),\
-					GFP_KERNEL);
-		if ((sizeof(struct audpreproc_cmd_cfg_agc_params) -\
-			(2*sizeof(unsigned short)))
-			< writecount) {
-				MM_ERR("ACDB DATA WRITE --\
-					AGC TX writecount > DSP struct\n");
-		} else {
-			if (preproc_agc != NULL) {
-				char *base; unsigned short offset;
-				unsigned short *offset_addr;
-				base = (char *)preproc_agc;
-				offset = offsetof(struct \
-						audpreproc_cmd_cfg_agc_params,\
-						tx_agc_param_mask);
-				offset_addr = (unsigned short *)(base + offset);
-				if ((copy_from_user(offset_addr,\
-					(void *)ubuf, writecount)) == 0x00) {
-					preproc_agc->cmd_id =
-						AUDPREPROC_CMD_CFG_AGC_PARAMS;
-					preproc_agc->stream_id =
-						acdb_data.preproc_stream_id;
-					result = audpreproc_dsp_set_agc(
-						preproc_agc,
-						sizeof(struct \
-						audpreproc_cmd_cfg_agc_params));
-					if (result) {
-						MM_ERR("ACDB=> Failed to \
-							send AGC data to \
-							preproc)\n");
-					} else {
-						retval = true;
-					       }
-				} else {
-					MM_ERR("ACDB DATA WRITE ---\
-						GC Tx copy_from_user Fail\n");
-				}
-			} else {
-				MM_ERR("ACDB DATA WRITE --\
-					AGC TX kalloc Failed LEN\n");
-			}
-		}
-		if (preproc_agc != NULL)
-			kfree(preproc_agc);
-		break;
-	}
-	case AUDPREPROC_CMD_CFG_NS_PARAMS:
-	{
-
-		preproc_ns = kmalloc(sizeof(struct \
-					audpreproc_cmd_cfg_ns_params),\
-					GFP_KERNEL);
-		if ((sizeof(struct audpreproc_cmd_cfg_ns_params) -\
-				(2 * sizeof(unsigned short)))
-				< writecount) {
-				MM_ERR("ACDB DATA WRITE --\
-					NS TX writecount > DSP struct\n");
-		} else {
-			if (preproc_ns != NULL) {
-				char *base; unsigned short offset;
-				unsigned short *offset_addr;
-				base = (char *)preproc_ns;
-				offset = offsetof(struct \
-						audpreproc_cmd_cfg_ns_params,\
-						ec_mode_new);
-				offset_addr = (unsigned short *)(base + offset);
-				if ((copy_from_user(offset_addr,\
-					(void *)ubuf, writecount)) == 0x00) {
-					preproc_ns->cmd_id =
-						AUDPREPROC_CMD_CFG_NS_PARAMS;
-					preproc_ns->stream_id =
-						acdb_data.preproc_stream_id;
-					result = audpreproc_dsp_set_ns(
-						preproc_ns,
-						sizeof(struct \
-						audpreproc_cmd_cfg_ns_params));
-					if (result) {
-						MM_ERR("ACDB=> Failed to send \
-							NS data to preproc\n");
-					} else {
-						retval = true;
-					}
-				} else {
-					MM_ERR("ACDB DATA WRITE ---NS Tx \
-						copy_from_user Fail\n");
-					}
-			} else {
-				MM_ERR("ACDB DATA WRITE --NS TX\
-					kalloc Failed LEN\n");
-			}
-		}
-		if (preproc_ns != NULL)
-			kfree(preproc_ns);
-		break;
-	}
-	case AUDPREPROC_CMD_CFG_IIR_TUNING_FILTER_PARAMS:
-	{
-
-		preproc_iir = kmalloc(sizeof(struct \
-				audpreproc_cmd_cfg_iir_tuning_filter_params),\
-				GFP_KERNEL);
-		if ((sizeof(struct \
-			audpreproc_cmd_cfg_iir_tuning_filter_params)-\
-			(2 * sizeof(unsigned short)))
-			< writecount) {
-			MM_ERR("ACDB DATA WRITE --IIR TX writecount\
-						> DSP struct\n");
-		} else {
-			if (preproc_iir != NULL) {
-				char *base; unsigned short offset;
-				unsigned short *offset_addr;
-				base = (char *)preproc_iir;
-				offset = offsetof(struct \
-				audpreproc_cmd_cfg_iir_tuning_filter_params,\
-				active_flag);
-				offset_addr = (unsigned short *)(base + \
-						offset);
-				if ((copy_from_user(offset_addr,\
-					(void *)ubuf, writecount)) == 0x00) {
-					preproc_iir->cmd_id = iircmdid;
-					preproc_iir->stream_id =
-						acdb_data.preproc_stream_id;
-					result = audpreproc_dsp_set_iir(\
-							preproc_iir,
-							iircmdsize);
-					if (result) {
-						MM_ERR("ACDB=> Failed to send\
-						IIR data to preproc\n");
-					} else {
-						retval = true;
-					}
-				} else {
-					MM_ERR("ACDB DATA WRITE ---IIR Tx \
-						copy_from_user Fail\n");
-				}
-			} else {
-				MM_ERR("ACDB DATA WRITE --IIR TX kalloc \
-					Failed LEN\n");
-		     }
-		}
-		if (preproc_iir != NULL)
-			kfree(preproc_iir);
-		break;
-	}
-	}
-	return retval;
-}
-
-static bool acdb_set_rx_rtc(const char *ubuf, size_t writecount)
-{
-
-	struct audpp_cmd_cfg_object_params_volpan *volpan_config;
-	struct audpp_cmd_cfg_object_params_mbadrc *mbadrc_config;
-	struct acdb_block_mbadrc_rtc *acdb_mbadrc_rtc;
-	struct audpp_cmd_cfg_object_params_sidechain *stf_config;
-	struct audpp_cmd_cfg_object_params_spectram *spa_config;
-	struct audpp_cmd_cfg_object_params_eqalizer *eq_config;
-	struct audpp_cmd_cfg_object_params_pcm *iir_config;
-	unsigned short temp_spa[34];
-	struct rtc_acdb_pmem *rtc_write = &rtc_acdb.rtc_write;
-	s32	result = 0;
-	bool retval = false;
-
-	switch (rtc_acdb.set_abid) {
-	case AUDPP_CMD_VOLUME_PAN:
-	{
-		volpan_config =  kmalloc(sizeof(struct \
-					 audpp_cmd_cfg_object_params_volpan),\
-					 GFP_KERNEL);
-		if ((sizeof(struct audpp_cmd_cfg_object_params_volpan) -\
-			sizeof(struct audpp_cmd_cfg_object_params_common))
-			< writecount) {
-			MM_ERR("ACDB DATA WRITE --\
-				VolPan writecount > DSP struct\n");
-		} else {
-			if (volpan_config != NULL) {
-				char *base; unsigned short offset;
-				unsigned short *offset_addr;
-				base = (char *)volpan_config;
-				offset = offsetof(struct \
-					audpp_cmd_cfg_object_params_volpan,\
-					volume);
-				offset_addr = (unsigned short *)(base+offset);
-				if ((copy_from_user(offset_addr,\
-					(void *)ubuf, writecount)) == 0x00) {
-					MM_ERR("ACDB RX WRITE DATA:\
-						AUDPP_CMD_VOLUME_PAN\n");
-					result = audpp_set_volume_and_pan(
-						acdb_data.device_info->dev_id,\
-						volpan_config->volume,
-						volpan_config->pan,
-						COPP);
-					if (result) {
-						MM_ERR("ACDB=> Failed to \
-							send VOLPAN data to"
-							" postproc\n");
-					} else {
-						retval = true;
-					}
-				} else {
-					MM_ERR("ACDB DATA WRITE ---\
-						copy_from_user Fail\n");
-				}
-			} else {
-				MM_ERR("ACDB DATA WRITE --\
-					Vol Pan kalloc Failed LEN\n");
-			}
-		}
-	if (volpan_config != NULL)
-		kfree(volpan_config);
-	break;
-	}
-
-	case AUDPP_CMD_IIR_TUNING_FILTER:
-	{
-		iir_config =  kmalloc(sizeof(struct \
-				audpp_cmd_cfg_object_params_pcm),\
-				GFP_KERNEL);
-		if ((sizeof(struct audpp_cmd_cfg_object_params_pcm) -\
-			sizeof(struct audpp_cmd_cfg_object_params_common))
-			< writecount) {
-			MM_ERR("ACDB DATA WRITE --\
-					IIR RX writecount > DSP struct\n");
-		} else {
-			if (iir_config != NULL) {
-				char *base; unsigned short offset;
-				unsigned short *offset_addr;
-				base = (char *)iir_config;
-				offset = offsetof(struct \
-					audpp_cmd_cfg_object_params_pcm,\
-					active_flag);
-				offset_addr = (unsigned short *)(base+offset);
-				if ((copy_from_user(offset_addr,\
-					(void *)ubuf, writecount)) == 0x00) {
-
-					iir_config->common.cmd_id =
-						AUDPP_CMD_CFG_OBJECT_PARAMS;
-					iir_config->common.stream =
-						AUDPP_CMD_COPP_STREAM;
-					iir_config->common.stream_id = 0;
-					iir_config->common.obj_cfg =
-						AUDPP_CMD_OBJ0_UPDATE;
-					iir_config->common.command_type = 0;
-					MM_ERR("ACDB RX WRITE DATA:\
-					AUDPP_CMD_IIR_TUNING_FILTER\n");
-					result = audpp_dsp_set_rx_iir(
-						acdb_data.device_info->dev_id,
-						iir_config->active_flag,\
-						iir_config, COPP);
-					if (result) {
-						MM_ERR("ACDB=> Failed to send\
-							IIR data to\
-							postproc\n");
-					} else {
-						retval = true;
-					}
-				} else {
-					MM_ERR("ACDB DATA WRITE ---\
-						IIR Rx copy_from_user Fail\n");
-				      }
-			 } else {
-				MM_ERR("ACDB DATA WRITE --\
-					acdb_iir_block kalloc Failed LEN\n");
-			}
-		}
-		if (iir_config != NULL)
-			kfree(iir_config);
-		break;
-	}
-	case AUDPP_CMD_EQUALIZER:
-	{
-		eq_config =  kmalloc(sizeof(struct \
-				audpp_cmd_cfg_object_params_eqalizer),\
-				GFP_KERNEL);
-	if ((sizeof(struct audpp_cmd_cfg_object_params_eqalizer) -\
-			sizeof(struct audpp_cmd_cfg_object_params_common))
-			< writecount) {
-			MM_ERR("ACDB DATA WRITE --\
-			EQ RX writecount > DSP struct\n");
-		} else {
-			if (eq_config != NULL) {
-				char *base; unsigned short offset;
-				unsigned short *offset_addr;
-				base = (char *)eq_config;
-				offset = offsetof(struct \
-					audpp_cmd_cfg_object_params_eqalizer,\
-					eq_flag);
-				offset_addr = (unsigned short *)(base+offset);
-				if ((copy_from_user(offset_addr,\
-					(void *)ubuf, writecount)) == 0x00) {
-					eq_config->common.cmd_id =
-						AUDPP_CMD_CFG_OBJECT_PARAMS;
-					eq_config->common.stream =
-						AUDPP_CMD_COPP_STREAM;
-					eq_config->common.stream_id = 0;
-					eq_config->common.obj_cfg =
-						AUDPP_CMD_OBJ0_UPDATE;
-					eq_config->common.command_type = 0;
-					MM_ERR("ACDB RX WRITE\
-					DATA:AUDPP_CMD_EQUALIZER\n");
-					result = audpp_dsp_set_eq(
-						acdb_data.device_info->dev_id,
-						eq_config->eq_flag,\
-						eq_config,
-						COPP);
-					if (result) {
-						MM_ERR("ACDB=> Failed to \
-						send EQ data to postproc\n");
-					} else {
-						retval = true;
-					}
-				} else {
-					MM_ERR("ACDB DATA WRITE ---\
-					EQ Rx copy_from_user Fail\n");
-				}
-			} else {
-				MM_ERR("ACDB DATA WRITE --\
-					EQ kalloc Failed LEN\n");
-			}
-		}
-		if (eq_config != NULL)
-			kfree(eq_config);
-		break;
-	}
-
-	case AUDPP_CMD_SPECTROGRAM:
-	{
-		spa_config =  kmalloc(sizeof(struct \
-				audpp_cmd_cfg_object_params_spectram),\
-				GFP_KERNEL);
-		if ((sizeof(struct audpp_cmd_cfg_object_params_spectram)-\
-				sizeof(struct \
-				audpp_cmd_cfg_object_params_common))
-				< (2 * sizeof(unsigned short))) {
-					MM_ERR("ACDB DATA WRITE --SPA \
-					RX writecount > DSP struct\n");
-		} else {
-			if (spa_config != NULL) {
-				if ((copy_from_user(&temp_spa[0],\
-					(void *)ubuf,
-					(34 * sizeof(unsigned short))))
-					== 0x00) {
-					spa_config->common.cmd_id =
-						AUDPP_CMD_CFG_OBJECT_PARAMS;
-					spa_config->common.stream =
-						AUDPP_CMD_COPP_STREAM;
-					spa_config->common.stream_id = 0;
-					spa_config->common.obj_cfg =
-						AUDPP_CMD_OBJ0_UPDATE;
-					spa_config->common.command_type = 0;
-					spa_config->sample_interval =
-						temp_spa[0];
-					spa_config->num_coeff = temp_spa[1];
-					MM_ERR("ACDB RX WRITE DATA:\
-						AUDPP_CMD_SPECTROGRAM\n");
-					result = audpp_dsp_set_spa(
-						acdb_data.device_info->dev_id,\
-						spa_config, COPP);
-					if (result) {
-						MM_ERR("ACDB=> Failed to \
-							send SPA data \
-							to postproc\n");
-					} else {
-						retval = true;
-					      }
-				} else {
-					MM_ERR("ACDB DATA WRITE \
-					---SPA Rx copy_from_user\
-					Fail\n");
-				}
-			} else {
-				MM_ERR("ACDB DATA WRITE --\
-				SPA kalloc Failed LEN\n");
-			       }
-			}
-		if (spa_config != NULL)
-			kfree(spa_config);
-	break;
-	}
-	case AUDPP_CMD_MBADRC:
-	{
-		acdb_mbadrc_rtc =  kmalloc(sizeof(struct \
-					acdb_block_mbadrc_rtc),\
-					GFP_KERNEL);
-		mbadrc_config =  kmalloc(sizeof(struct \
-					audpp_cmd_cfg_object_params_mbadrc),\
-					GFP_KERNEL);
-		if (mbadrc_config != NULL && acdb_mbadrc_rtc != NULL) {
-			if ((copy_from_user(acdb_mbadrc_rtc,\
-				(void *)ubuf,
-				sizeof(struct acdb_block_mbadrc_rtc)))
-				== 0x00) {
-				mbadrc_config->common.cmd_id =
-					AUDPP_CMD_CFG_OBJECT_PARAMS;
-				mbadrc_config->common.stream =
-					AUDPP_CMD_COPP_STREAM;
-				mbadrc_config->common.stream_id = 0;
-				mbadrc_config->common.obj_cfg =
-					AUDPP_CMD_OBJ0_UPDATE;
-				mbadrc_config->common.command_type = 0;
-				mbadrc_config->enable =
-						acdb_mbadrc_rtc->enable;
-				mbadrc_config->num_bands =
-						acdb_mbadrc_rtc->num_bands;
-				mbadrc_config->down_samp_level =
-				acdb_mbadrc_rtc->down_samp_level;
-				mbadrc_config->adrc_delay =
-					acdb_mbadrc_rtc->adrc_delay;
-				memcpy(mbadrc_config->adrc_band,\
-					acdb_mbadrc_rtc->adrc_band,\
-					AUDPP_MAX_MBADRC_BANDS *\
-					sizeof(struct adrc_config));
-				if (mbadrc_config->num_bands > 1) {
-					mbadrc_config->ext_buf_size =
-						(97 * 2) + (33 * 2 * \
-					(mbadrc_config->num_bands - 2));
-				}
-				mbadrc_config->ext_partition = 0;
-				mbadrc_config->ext_buf_lsw =
-					(u16) EXTRACT_LOW_WORD(\
-						rtc_write->phys);
-				mbadrc_config->ext_buf_msw =
-					(u16) EXTRACT_HIGH_WORD(\
-						rtc_write->phys);
-				memcpy(rtc_write->viraddr,
-					acdb_mbadrc_rtc->ExtBuff,
-					(196*sizeof(signed int)));
-				result = audpp_dsp_set_mbadrc(
-						acdb_data.device_info->dev_id,
-						mbadrc_config->enable,
-						mbadrc_config, COPP);
-				if (result) {
-					MM_ERR("ACDB=> Failed to \
-						Send MBADRC data \
-						to postproc\n");
-				} else {
-					retval = true;
-				}
-			} else {
-				MM_ERR("ACDB DATA WRITE ---\
-					MBADRC Rx copy_from_user Fail\n");
-			}
-		} else {
-			MM_ERR("ACDB DATA WRITE --MBADRC kalloc Failed LEN\n");
-		}
-		if (mbadrc_config != NULL)
-			kfree(mbadrc_config);
-		if (acdb_mbadrc_rtc != NULL)
-			kfree(acdb_mbadrc_rtc);
-	break;
-	}
-	case AUDPP_CMD_SIDECHAIN_TUNING_FILTER:
-	{
-		stf_config =  kmalloc(sizeof(struct \
-				audpp_cmd_cfg_object_params_sidechain),\
-				GFP_KERNEL);
-		if ((sizeof(struct audpp_cmd_cfg_object_params_sidechain) -\
-			sizeof(struct audpp_cmd_cfg_object_params_common))
-			< writecount) {
-				MM_ERR("ACDB DATA WRITE --\
-					STF RX writecount > DSP struct\n");
-		} else {
-			if (stf_config != NULL) {
-				char *base; unsigned short offset;
-				unsigned short *offset_addr;
-				base = (char *)stf_config;
-				offset = offsetof(struct \
-					audpp_cmd_cfg_object_params_sidechain,\
-					active_flag);
-				offset_addr = (unsigned short *)(base+offset);
-				if ((copy_from_user(offset_addr,\
-					(void *)ubuf, writecount)) == 0x00) {
-					stf_config->common.cmd_id =
-						AUDPP_CMD_CFG_OBJECT_PARAMS;
-					stf_config->common.stream =
-						AUDPP_CMD_COPP_STREAM;
-					stf_config->common.stream_id = 0;
-					stf_config->common.obj_cfg =
-						AUDPP_CMD_OBJ0_UPDATE;
-					stf_config->common.command_type = 0;
-					MM_ERR("ACDB RX WRITE DATA:\
-					AUDPP_CMD_SIDECHAIN_TUNING_FILTER\n");
-				result = audpp_dsp_set_stf(
-						acdb_data.device_info->dev_id,\
-						stf_config->active_flag,\
-						stf_config, COPP);
-					if (result) {
-						MM_ERR("ACDB=> Failed to send \
-						STF data to postproc\n");
-					} else {
-						retval = true;
-					}
-				} else {
-					MM_ERR("ACDB DATA WRITE ---\
-					STF Rx copy_from_user Fail\n");
-				}
-			} else {
-				MM_ERR("ACDB DATA WRITE \
-					STF kalloc Failed LEN\n");
-		}
-	}
-	if (stf_config != NULL)
-		kfree(stf_config);
-	break;
-	}
-	}
-	return retval;
-}
-static ssize_t rtc_getsetabid_data_dbg_write(struct file *filp,
-						const char __user *ubuf,
-						size_t cnt, loff_t *ppos)
-{
-	if (rtc_acdb.valid_abid != true) {
-		MM_INFO("ACDB DATA READ ---INVALID ABID\n");
-		rtc_acdb.err = ACDB_RTC_ERR_INVALID_ABID;
-	} else {
-		if (rtc_acdb.tx_rx_ctl == ACDB_RTC_RX) {
-			if (acdb_set_rx_rtc(ubuf, cnt)) {
-				rtc_acdb.err = ACDB_RTC_SUCCESS;
-			} else {
-			rtc_acdb.err = ACDB_RTC_ERR_UNKNOWN_FAILURE;
-			cnt = 0;
-		}
-	} else if (rtc_acdb.tx_rx_ctl == ACDB_RTC_TX) {
-		if (acdb_set_tx_rtc(ubuf, cnt)) {
-			rtc_acdb.err = ACDB_RTC_SUCCESS;
-		} else {
-			rtc_acdb.err = ACDB_RTC_ERR_UNKNOWN_FAILURE;
-			cnt = 0;
-		}
-	}
-  }
-	return cnt;
-}
-
-
-static const	struct file_operations rtc_acdb_data_debug_fops = {
-	.open = rtc_getsetabid_data_dbg_open,
-	.write = rtc_getsetabid_data_dbg_write,
-	.read = rtc_getsetabid_data_dbg_read
-};
-
-static const	struct file_operations rtc_acdb_debug_fops = {
-	.open = rtc_getsetabid_dbg_open,
-	.write = rtc_getsetabid_dbg_write,
-	.read = rtc_getsetabid_dbg_read
-};
-
-static void rtc_acdb_deinit(void)
-{
-	struct rtc_acdb_pmem *rtc_read = &rtc_acdb.rtc_read;
-	struct rtc_acdb_pmem *rtc_write = &rtc_acdb.rtc_write;
-	if (get_set_abid_dentry) {
-		MM_DBG("GetSet ABID remove debugfs\n");
-		debugfs_remove(get_set_abid_dentry);
-	}
-
-	if (get_set_abid_data_dentry) {
-		MM_DBG("GetSet ABID remove debugfs\n");
-		debugfs_remove(get_set_abid_data_dentry);
-	}
-	rtc_acdb.abid = 0;
-	rtc_acdb.acdb_id = 0;
-	rtc_acdb.cmd_id = 0;
-	rtc_acdb.err = 1;
-	rtc_acdb.set_abid = 0;
-	rtc_acdb.set_iid = 0;
-	rtc_acdb.tx_rx_ctl = 0;
-	rtc_acdb.valid_abid = false;
-
-	if (rtc_read->viraddr != NULL || ((void *)rtc_read->phys) != NULL) {
-		iounmap(rtc_read->map_v_rtc);
-		free_contiguous_memory_by_paddr(rtc_read->phys);
-	}
-	if (rtc_write->viraddr != NULL || ((void *)rtc_write->phys) != NULL) {
-		iounmap(rtc_write->map_v_rtc);
-		free_contiguous_memory_by_paddr(rtc_write->phys);
-	}
-}
-
-static bool rtc_acdb_init(void)
-{
-	struct rtc_acdb_pmem *rtc_read = &rtc_acdb.rtc_read;
-	struct rtc_acdb_pmem *rtc_write = &rtc_acdb.rtc_write;
-	s32 result = 0;
-	char name[sizeof "get_set_abid"+1];
-	char name1[sizeof "get_set_abid_data"+1];
-	rtc_acdb.abid = 0;
-	rtc_acdb.acdb_id = 0;
-	rtc_acdb.cmd_id = 0;
-	rtc_acdb.err = 1;
-	rtc_acdb.set_abid = 0;
-	rtc_acdb.set_iid = 0;
-	rtc_acdb.valid_abid = false;
-	rtc_acdb.tx_rx_ctl = 0;
-	if (acdb_data.build_id[17] == '1') {
-		snprintf(name, sizeof name, "get_set_abid");
-		get_set_abid_dentry = debugfs_create_file(name,
-					S_IFREG | S_IRUGO | S_IWUGO,
-					NULL, NULL, &rtc_acdb_debug_fops);
-		if (IS_ERR(get_set_abid_dentry)) {
-			MM_ERR("SET GET ABID debugfs_create_file failed\n");
-			return false;
-		}
-
-		snprintf(name1, sizeof name1, "get_set_abid_data");
-		get_set_abid_data_dentry = debugfs_create_file(name1,
-						S_IFREG | S_IRUGO | S_IWUGO,
-						NULL, NULL,
-						&rtc_acdb_data_debug_fops);
-		if (IS_ERR(get_set_abid_data_dentry)) {
-			MM_ERR("SET GET ABID DATA"
-					" debugfs_create_file failed\n");
-			return false;
-		}
-	}
-
-	rtc_read->phys = allocate_contiguous_ebi_nomap(PMEM_RTC_ACDB_QUERY_MEM,
-								 SZ_4K);
-
-	if (!rtc_read->phys) {
-		MM_ERR("ACDB Cannot allocate physical memory\n");
-		result = -ENOMEM;
-		goto error;
-	}
-	rtc_read->map_v_rtc = ioremap(rtc_read->phys,
-				PMEM_RTC_ACDB_QUERY_MEM);
-
-	if (IS_ERR(rtc_read->map_v_rtc)) {
-		MM_ERR("ACDB Could not map physical address\n");
-		result = -ENOMEM;
-		goto error;
-	}
-	rtc_read->viraddr = rtc_read->map_v_rtc;
-	memset(rtc_read->viraddr, 0, PMEM_RTC_ACDB_QUERY_MEM);
-
-	rtc_write->phys = allocate_contiguous_ebi_nomap(PMEM_RTC_ACDB_QUERY_MEM,
-								SZ_4K);
-
-	if (!rtc_write->phys) {
-		MM_ERR("ACDB Cannot allocate physical memory\n");
-		result = -ENOMEM;
-		goto error;
-	}
-	rtc_write->map_v_rtc = ioremap(rtc_write->phys,
-				PMEM_RTC_ACDB_QUERY_MEM);
-
-	if (IS_ERR(rtc_write->map_v_rtc)) {
-		MM_ERR("ACDB Could not map physical address\n");
-		result = -ENOMEM;
-		goto error;
-	}
-	rtc_write->viraddr = rtc_write->map_v_rtc;
-	memset(rtc_write->viraddr, 0, PMEM_RTC_ACDB_QUERY_MEM);
-	init_waitqueue_head(&rtc_acdb.wait);
-	return true;
-error:
-	MM_DBG("INIT RTC FAILED REMOVING RTC DEBUG FS\n");
-	if (get_set_abid_dentry) {
-		MM_DBG("GetSet ABID remove debugfs\n");
-		debugfs_remove(get_set_abid_dentry);
-	}
-
-	if (get_set_abid_data_dentry) {
-		MM_DBG("GetSet ABID remove debugfs\n");
-		debugfs_remove(get_set_abid_data_dentry);
-	}
-	if (rtc_read->viraddr != NULL || ((void *)rtc_read->phys) != NULL) {
-		iounmap(rtc_read->map_v_rtc);
-		free_contiguous_memory_by_paddr(rtc_read->phys);
-	}
-	if (rtc_write->viraddr != NULL || ((void *)rtc_write->phys) != NULL) {
-		iounmap(rtc_write->map_v_rtc);
-		free_contiguous_memory_by_paddr(rtc_write->phys);
-	}
-	return false;
-}
-#endif /*CONFIG_DEBUG_FS*/
-static s32 acdb_set_calibration_blk(unsigned long arg)
-{
-	struct acdb_cmd_device acdb_cmd;
-	s32 result = 0;
-
-	MM_DBG("acdb_set_calibration_blk\n");
-	if (copy_from_user(&acdb_cmd, (struct acdb_cmd_device *)arg,
-			sizeof(acdb_cmd))) {
-		MM_ERR("Failed copy command struct from user in"
-			"acdb_set_calibration_blk\n");
-		return -EFAULT;
-	}
-	acdb_cmd.phys_buf = (u32 *)acdb_data.paddr;
-
-	MM_DBG("acdb_cmd.phys_buf %x\n", (u32)acdb_cmd.phys_buf);
-
-	result = dalrpc_fcn_8(ACDB_DalACDB_ioctl, acdb_data.handle,
-			(const void *)&acdb_cmd, sizeof(acdb_cmd),
-			&acdb_data.acdb_result,
-			sizeof(acdb_data.acdb_result));
-
-	if (result < 0) {
-		MM_ERR("ACDB=> Device Set RPC failure"
-			" result = %d\n", result);
-		return -EINVAL;
-	} else {
-		MM_ERR("ACDB=> Device Set RPC success\n");
-		if (acdb_data.acdb_result.result == ACDB_RES_SUCCESS)
-			MM_DBG("ACDB_SET_DEVICE Success\n");
-		else if (acdb_data.acdb_result.result == ACDB_RES_FAILURE)
-			MM_ERR("ACDB_SET_DEVICE Failure\n");
-		else if (acdb_data.acdb_result.result == ACDB_RES_BADPARM)
-			MM_ERR("ACDB_SET_DEVICE BadParams\n");
-		else
-			MM_ERR("Unknown error\n");
-	}
-	return result;
-}
-
-static s32 acdb_get_calibration_blk(unsigned long arg)
-{
-	s32 result = 0;
-	struct acdb_cmd_device acdb_cmd;
-
-	MM_DBG("acdb_get_calibration_blk\n");
-
-	if (copy_from_user(&acdb_cmd, (struct acdb_cmd_device *)arg,
-			sizeof(acdb_cmd))) {
-		MM_ERR("Failed copy command struct from user in"
-			"acdb_get_calibration_blk\n");
-		return -EFAULT;
-	}
-	acdb_cmd.phys_buf = (u32 *)acdb_data.paddr;
-	MM_ERR("acdb_cmd.phys_buf %x\n", (u32)acdb_cmd.phys_buf);
-
-	result = dalrpc_fcn_8(ACDB_DalACDB_ioctl, acdb_data.handle,
-			(const void *)&acdb_cmd, sizeof(acdb_cmd),
-			&acdb_data.acdb_result,
-			sizeof(acdb_data.acdb_result));
-
-	if (result < 0) {
-		MM_ERR("ACDB=> Device Get RPC failure"
-			" result = %d\n", result);
-		return -EINVAL;
-	} else {
-		MM_ERR("ACDB=> Device Get RPC Success\n");
-		if (acdb_data.acdb_result.result == ACDB_RES_SUCCESS)
-			MM_DBG("ACDB_GET_DEVICE Success\n");
-		else if (acdb_data.acdb_result.result == ACDB_RES_FAILURE)
-			MM_ERR("ACDB_GET_DEVICE Failure\n");
-		else if (acdb_data.acdb_result.result == ACDB_RES_BADPARM)
-			MM_ERR("ACDB_GET_DEVICE BadParams\n");
-		else
-			MM_ERR("Unknown error\n");
-	}
-	return result;
-}
-
-static int audio_acdb_open(struct inode *inode, struct file *file)
-{
-	MM_DBG("%s\n", __func__);
-	return 0;
-}
-static int audio_acdb_release(struct inode *inode, struct file *file)
-{
-	MM_DBG("%s\n", __func__);
-	return 0;
-}
-
-static long audio_acdb_ioctl(struct file *file, unsigned int cmd,
-					unsigned long arg)
-{
-	int rc = 0;
-	unsigned long flags = 0;
-
-	MM_DBG("%s\n", __func__);
-
-	switch (cmd) {
-	case AUDIO_SET_EQ:
-		MM_DBG("IOCTL SET_EQ_CONFIG\n");
-		if (copy_from_user(&acdb_data.eq.num_bands, (void *) arg,
-				sizeof(acdb_data.eq) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2))) {
-			rc = -EFAULT;
-			break;
-		}
-		spin_lock_irqsave(&acdb_data.dsp_lock, flags);
-		acdb_data.dec_id    = 0;
-		rc = audpp_dsp_set_eq(acdb_data.dec_id, 1,
-			&acdb_data.eq, COPP);
-		if (rc < 0)
-			MM_ERR("AUDPP returned err =%d\n", rc);
-		spin_unlock_irqrestore(&acdb_data.dsp_lock, flags);
-		break;
-	case AUDIO_SET_ACDB_BLK:
-		MM_DBG("IOCTL AUDIO_SET_ACDB_BLK\n");
-		rc = acdb_set_calibration_blk(arg);
-		break;
-	case AUDIO_GET_ACDB_BLK:
-		MM_DBG("IOiCTL AUDIO_GET_ACDB_BLK\n");
-		rc = acdb_get_calibration_blk(arg);
-		break;
-	default:
-		MM_DBG("Unknown IOCTL%d\n", cmd);
-		rc = -EINVAL;
-	}
-	return rc;
-}
-
-static const struct file_operations acdb_fops = {
-	.owner = THIS_MODULE,
-	.open = audio_acdb_open,
-	.release = audio_acdb_release,
-	.llseek = no_llseek,
-	.unlocked_ioctl = audio_acdb_ioctl
-};
-
-struct miscdevice acdb_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_acdb",
-	.fops	= &acdb_fops,
-};
-
-static s32 acdb_get_calibration(void)
-{
-	struct acdb_cmd_get_device_table	acdb_cmd;
-	s32					result = 0;
-	u32 iterations = 0;
-
-	MM_DBG("acdb state = %d\n", acdb_data.acdb_state);
-
-	acdb_cmd.command_id = ACDB_GET_DEVICE_TABLE;
-	acdb_cmd.device_id = acdb_data.device_info->acdb_id;
-	acdb_cmd.network_id = 0x0108B153;
-	acdb_cmd.sample_rate_id = acdb_data.device_info->sample_rate;
-	acdb_cmd.total_bytes = ACDB_BUF_SIZE;
-	acdb_cmd.phys_buf = (u32 *)acdb_data.phys_addr;
-	MM_DBG("device_id = %d, sampling_freq = %d\n",
-				acdb_cmd.device_id, acdb_cmd.sample_rate_id);
-
-	do {
-		result = dalrpc_fcn_8(ACDB_DalACDB_ioctl, acdb_data.handle,
-				(const void *)&acdb_cmd, sizeof(acdb_cmd),
-				&acdb_data.acdb_result,
-				sizeof(acdb_data.acdb_result));
-
-		if (result < 0) {
-			MM_ERR("ACDB=> Device table RPC failure"
-				" result = %d\n", result);
-			goto error;
-		}
-		/*following check is introduced to handle boot up race
-		condition between AUDCAL SW peers running on apps
-		and modem (ACDB_RES_BADSTATE indicates modem AUDCAL SW is
-		not in initialized sate) we need to retry to get ACDB
-		values*/
-		if (acdb_data.acdb_result.result == ACDB_RES_BADSTATE) {
-			msleep(500);
-			iterations++;
-		} else if (acdb_data.acdb_result.result == ACDB_RES_SUCCESS) {
-			MM_DBG("Modem query for acdb values is successful"
-					" (iterations = %d)\n", iterations);
-			acdb_data.acdb_state |= CAL_DATA_READY;
-			return result;
-		} else {
-			MM_ERR("ACDB=> modem failed to fill acdb values,"
-					" reuslt = %d, (iterations = %d)\n",
-					acdb_data.acdb_result.result,
-					iterations);
-			goto error;
-		}
-	} while (iterations < MAX_RETRY);
-	MM_ERR("ACDB=> AUDCAL SW on modem is not in intiailized state (%d)\n",
-			acdb_data.acdb_result.result);
-error:
-	result = -EINVAL;
-	return result;
-}
-
-s32 acdb_get_calibration_data(struct acdb_get_block *get_block)
-{
-	s32 result = -EINVAL;
-	struct acdb_cmd_device acdb_cmd;
-	struct acdb_result acdb_result;
-
-	MM_DBG("acdb_get_calibration_data\n");
-
-	acdb_cmd.command_id = ACDB_GET_DEVICE;
-	acdb_cmd.network_id = 0x0108B153;
-	acdb_cmd.device_id = get_block->acdb_id;
-	acdb_cmd.sample_rate_id = get_block->sample_rate_id;
-	acdb_cmd.interface_id = get_block->interface_id;
-	acdb_cmd.algorithm_block_id = get_block->algorithm_block_id;
-	acdb_cmd.total_bytes = get_block->total_bytes;
-	acdb_cmd.phys_buf = (u32 *)acdb_data.get_blk_paddr;
-
-	result = dalrpc_fcn_8(ACDB_DalACDB_ioctl, acdb_data.handle,
-			(const void *)&acdb_cmd, sizeof(acdb_cmd),
-			&acdb_result,
-			sizeof(acdb_result));
-
-	if (result < 0) {
-		MM_ERR("ACDB=> Device Get RPC failure"
-			" result = %d\n", result);
-		goto err_state;
-	} else {
-		MM_DBG("ACDB=> Device Get RPC Success\n");
-		if (acdb_result.result == ACDB_RES_SUCCESS) {
-			MM_DBG("ACDB_GET_DEVICE Success\n");
-			result = 0;
-			memcpy(get_block->buf_ptr, acdb_data.get_blk_kvaddr,
-					get_block->total_bytes);
-		} else if (acdb_result.result == ACDB_RES_FAILURE)
-			MM_ERR("ACDB_GET_DEVICE Failure\n");
-		else if (acdb_result.result == ACDB_RES_BADPARM)
-			MM_ERR("ACDB_GET_DEVICE BadParams\n");
-		else
-			MM_ERR("Unknown error\n");
-	}
-err_state:
-	return result;
-}
-EXPORT_SYMBOL(acdb_get_calibration_data);
-
-static u8 check_device_info_already_present(
-		struct auddev_evt_audcal_info   audcal_info,
-			struct acdb_cache_node *acdb_cache_free_node)
-{
-	if ((audcal_info.dev_id ==
-				acdb_cache_free_node->device_info.dev_id) &&
-		(audcal_info.sample_rate ==
-				acdb_cache_free_node->device_info.\
-				sample_rate) &&
-			(audcal_info.acdb_id ==
-				acdb_cache_free_node->device_info.acdb_id)) {
-		MM_DBG("acdb values are already present\n");
-		/*if acdb state is not set for CAL_DATA_READY and node status
-		is filled, acdb state should be updated with CAL_DATA_READY
-		state*/
-		acdb_data.acdb_state |= CAL_DATA_READY;
-		/*checking for cache node status if it is not filled then the
-		acdb values are not cleaned from node so update node status
-		with acdb value filled*/
-		if ((acdb_cache_free_node->node_status != ACDB_VALUES_FILLED) &&
-			((audcal_info.dev_type & RX_DEVICE) == 1)) {
-			MM_DBG("device was released earlier\n");
-			acdb_cache_free_node->node_status = ACDB_VALUES_FILLED;
-			return 2; /*node is presnet but status as not filled*/
-		}
-		return 1; /*node is present but status as filled*/
-	}
-	MM_DBG("copying device info into node\n");
-	/*as device information is not present in cache copy
-	the current device information into the node*/
-	memcpy(&acdb_cache_free_node->device_info,
-				 &audcal_info, sizeof(audcal_info));
-	return 0; /*cant find the node*/
-}
-
-static struct acdb_iir_block *get_audpp_irr_block(void)
-{
-	struct header *prs_hdr;
-	u32 index = 0;
-
-	while (index < acdb_data.acdb_result.used_bytes) {
-		prs_hdr = (struct header *)(acdb_data.virt_addr + index);
-		if (prs_hdr->dbor_signature == DBOR_SIGNATURE) {
-			if (prs_hdr->abid == ABID_AUDIO_IIR_RX) {
-				if (prs_hdr->iid == IID_AUDIO_IIR_COEFF)
-					return (struct acdb_iir_block *)
-						(acdb_data.virt_addr + index
-						 + sizeof(struct header));
-			} else {
-				index += prs_hdr->data_len +
-						sizeof(struct header);
-			}
-		} else {
-			break;
-		}
-	}
-	return NULL;
-}
-
-
-static s32 acdb_fill_audpp_iir(void)
-{
-	struct acdb_iir_block *acdb_iir;
-	s32 i = 0;
-
-	acdb_iir = get_audpp_irr_block();
-	if (acdb_iir == NULL) {
-		MM_ERR("unable to find  audpp iir block returning\n");
-		return -1;
-	}
-	memset(acdb_data.pp_iir, 0, sizeof(*acdb_data.pp_iir));
-
-	acdb_data.pp_iir->common.cmd_id = AUDPP_CMD_CFG_OBJECT_PARAMS;
-	acdb_data.pp_iir->common.stream = AUDPP_CMD_COPP_STREAM;
-	acdb_data.pp_iir->common.stream_id = 0;
-	acdb_data.pp_iir->common.obj_cfg = AUDPP_CMD_OBJ0_UPDATE;
-	acdb_data.pp_iir->common.command_type = 0;
-
-	acdb_data.pp_iir->active_flag = acdb_iir->enable_flag;
-	acdb_data.pp_iir->num_bands = acdb_iir->stage_count;
-	for (; i < acdb_iir->stage_count; i++) {
-		acdb_data.pp_iir->params_filter.filter_4_params.
-			numerator_filter[i].numerator_b0_filter_lsw =
-			acdb_iir->stages[i].b0_lo;
-		acdb_data.pp_iir->params_filter.filter_4_params.
-			numerator_filter[i].numerator_b0_filter_msw =
-			acdb_iir->stages[i].b0_hi;
-		acdb_data.pp_iir->params_filter.filter_4_params.
-			numerator_filter[i].numerator_b1_filter_lsw =
-			acdb_iir->stages[i].b1_lo;
-		acdb_data.pp_iir->params_filter.filter_4_params.
-			numerator_filter[i].numerator_b1_filter_msw =
-			acdb_iir->stages[i].b1_hi;
-		acdb_data.pp_iir->params_filter.filter_4_params.
-			numerator_filter[i].numerator_b2_filter_lsw =
-			acdb_iir->stages[i].b2_lo;
-		acdb_data.pp_iir->params_filter.filter_4_params.
-			numerator_filter[i].numerator_b2_filter_msw =
-			acdb_iir->stages[i].b2_hi;
-		acdb_data.pp_iir->params_filter.filter_4_params.
-			denominator_filter[i].denominator_a0_filter_lsw =
-			acdb_iir->stages_a[i].a1_lo;
-		acdb_data.pp_iir->params_filter.filter_4_params.
-			denominator_filter[i].denominator_a0_filter_msw =
-			acdb_iir->stages_a[i].a1_hi;
-		acdb_data.pp_iir->params_filter.filter_4_params.
-			denominator_filter[i].denominator_a1_filter_lsw =
-			acdb_iir->stages_a[i].a2_lo;
-		acdb_data.pp_iir->params_filter.filter_4_params.
-			denominator_filter[i].denominator_a1_filter_msw =
-			acdb_iir->stages_a[i].a2_hi;
-		acdb_data.pp_iir->params_filter.filter_4_params.
-			shift_factor_filter[i].shift_factor_0 =
-			acdb_iir->shift_factor[i];
-		acdb_data.pp_iir->params_filter.filter_4_params.pan_filter[i].
-			pan_filter_0 = acdb_iir->pan[i];
-	}
-	return 0;
-}
-
-static void extract_mbadrc(u32 *phy_addr, struct header *prs_hdr, u32 *index)
-{
-	if (prs_hdr->iid == IID_MBADRC_EXT_BUFF) {
-		MM_DBG("Got IID = IID_MBADRC_EXT_BUFF\n");
-		*phy_addr = acdb_data.phys_addr	+ *index +
-					sizeof(struct header);
-		memcpy(acdb_data.mbadrc_block.ext_buf,
-				(acdb_data.virt_addr + *index +
-					sizeof(struct header)), 196*2);
-		MM_DBG("phy_addr = %x\n", *phy_addr);
-		*index += prs_hdr->data_len + sizeof(struct header);
-	} else if (prs_hdr->iid == IID_MBADRC_BAND_CONFIG) {
-		MM_DBG("Got IID == IID_MBADRC_BAND_CONFIG\n");
-		memcpy(acdb_data.mbadrc_block.band_config, (acdb_data.virt_addr
-					+ *index + sizeof(struct header)),
-				sizeof(struct mbadrc_band_config_type) *
-					 acdb_data.mbadrc_block.parameters.\
-						mbadrc_num_bands);
-		*index += prs_hdr->data_len + sizeof(struct header);
-	} else if (prs_hdr->iid == IID_MBADRC_PARAMETERS) {
-		struct mbadrc_parameter *tmp;
-		tmp = (struct mbadrc_parameter *)(acdb_data.virt_addr + *index
-						+ sizeof(struct header));
-		MM_DBG("Got IID == IID_MBADRC_PARAMETERS\n");
-		acdb_data.mbadrc_block.parameters.mbadrc_enable =
-							tmp->mbadrc_enable;
-		acdb_data.mbadrc_block.parameters.mbadrc_num_bands =
-							tmp->mbadrc_num_bands;
-		acdb_data.mbadrc_block.parameters.mbadrc_down_sample_level =
-						tmp->mbadrc_down_sample_level;
-		acdb_data.mbadrc_block.parameters.mbadrc_delay =
-							tmp->mbadrc_delay;
-		*index += prs_hdr->data_len + sizeof(struct header);
-	}
-}
-
-static void get_audpp_mbadrc_block(u32 *phy_addr)
-{
-	struct header *prs_hdr;
-	u32 index = 0;
-
-	while (index < acdb_data.acdb_result.used_bytes) {
-		prs_hdr = (struct header *)(acdb_data.virt_addr + index);
-
-		if (prs_hdr->dbor_signature == DBOR_SIGNATURE) {
-			if (prs_hdr->abid == ABID_AUDIO_MBADRC_RX) {
-				if ((prs_hdr->iid == IID_MBADRC_EXT_BUFF)
-					|| (prs_hdr->iid ==
-						IID_MBADRC_BAND_CONFIG)
-					|| (prs_hdr->iid ==
-						IID_MBADRC_PARAMETERS)) {
-					extract_mbadrc(phy_addr, prs_hdr,
-								&index);
-				}
-			} else {
-				index += prs_hdr->data_len +
-						sizeof(struct header);
-			}
-		} else {
-			break;
-		}
-	}
-}
-
-static s32 acdb_fill_audpp_mbadrc(void)
-{
-	u32 mbadrc_phys_addr = -1;
-	get_audpp_mbadrc_block(&mbadrc_phys_addr);
-	if (IS_ERR_VALUE(mbadrc_phys_addr)) {
-		MM_ERR("failed to get mbadrc block\n");
-		return -1;
-	}
-
-	memset(acdb_data.pp_mbadrc, 0, sizeof(*acdb_data.pp_mbadrc));
-
-	acdb_data.pp_mbadrc->common.cmd_id = AUDPP_CMD_CFG_OBJECT_PARAMS;
-	acdb_data.pp_mbadrc->common.stream = AUDPP_CMD_COPP_STREAM;
-	acdb_data.pp_mbadrc->common.stream_id = 0;
-	acdb_data.pp_mbadrc->common.obj_cfg = AUDPP_CMD_OBJ0_UPDATE;
-	acdb_data.pp_mbadrc->common.command_type = 0;
-
-	acdb_data.pp_mbadrc->enable = acdb_data.mbadrc_block.\
-					parameters.mbadrc_enable;
-	acdb_data.pp_mbadrc->num_bands =
-				acdb_data.mbadrc_block.\
-					parameters.mbadrc_num_bands;
-	acdb_data.pp_mbadrc->down_samp_level =
-				acdb_data.mbadrc_block.parameters.\
-					mbadrc_down_sample_level;
-	acdb_data.pp_mbadrc->adrc_delay =
-				acdb_data.mbadrc_block.parameters.\
-					mbadrc_delay;
-
-	if (acdb_data.mbadrc_block.parameters.mbadrc_num_bands > 1)
-		acdb_data.pp_mbadrc->ext_buf_size = (97 * 2) +
-			(33 * 2 * (acdb_data.mbadrc_block.parameters.\
-					mbadrc_num_bands - 2));
-
-	acdb_data.pp_mbadrc->ext_partition = 0;
-	acdb_data.pp_mbadrc->ext_buf_lsw = (u16)(mbadrc_phys_addr\
-						 & 0xFFFF);
-	acdb_data.pp_mbadrc->ext_buf_msw = (u16)((mbadrc_phys_addr\
-						 & 0xFFFF0000) >> 16);
-	memcpy(acdb_data.pp_mbadrc->adrc_band, acdb_data.mbadrc_block.\
-					band_config,
-		sizeof(struct mbadrc_band_config_type) *
-		acdb_data.mbadrc_block.parameters.mbadrc_num_bands);
-	return 0;
-}
-
-static struct acdb_calib_gain_rx *get_audpp_cal_gain(void)
-{
-	struct header *prs_hdr;
-	u32 index = 0;
-
-	while (index < acdb_data.acdb_result.used_bytes) {
-		prs_hdr = (struct header *)(acdb_data.virt_addr + index);
-		if (prs_hdr->dbor_signature == DBOR_SIGNATURE) {
-			if (prs_hdr->abid == ABID_AUDIO_CALIBRATION_GAIN_RX) {
-				if (prs_hdr->iid ==
-					IID_AUDIO_CALIBRATION_GAIN_RX) {
-					MM_DBG("Got audpp_calib_gain_rx"
-					" block\n");
-					return (struct acdb_calib_gain_rx *)
-						(acdb_data.virt_addr + index
-						+ sizeof(struct header));
-				}
-			} else {
-				index += prs_hdr->data_len +
-					sizeof(struct header);
-			}
-		} else {
-			break;
-		}
-	}
-	return NULL;
-}
-
-static s32 acdb_fill_audpp_cal_gain(void)
-{
-	struct acdb_calib_gain_rx *acdb_calib_gain_rx = NULL;
-
-	acdb_calib_gain_rx = get_audpp_cal_gain();
-	if (acdb_calib_gain_rx == NULL) {
-		MM_ERR("unable to find  audpp"
-			" calibration gain block returning\n");
-		return -1;
-	}
-	MM_DBG("Calibration value"
-		" for calib_gain_rx %d\n", acdb_calib_gain_rx->audppcalgain);
-	memset(acdb_data.calib_gain_rx, 0, sizeof(*acdb_data.calib_gain_rx));
-
-	acdb_data.calib_gain_rx->common.cmd_id = AUDPP_CMD_CFG_OBJECT_PARAMS;
-	acdb_data.calib_gain_rx->common.stream = AUDPP_CMD_COPP_STREAM;
-	acdb_data.calib_gain_rx->common.stream_id = 0;
-	acdb_data.calib_gain_rx->common.obj_cfg = AUDPP_CMD_OBJ0_UPDATE;
-	acdb_data.calib_gain_rx->common.command_type = 0;
-
-	acdb_data.calib_gain_rx->audppcalgain =
-				acdb_calib_gain_rx->audppcalgain;
-	return 0;
-}
-
-static void extract_pbe_block(struct header *prs_hdr, u32 *index)
-{
-	if (prs_hdr->iid == IID_AUDIO_PBE_RX_ENABLE_FLAG) {
-		MM_DBG("Got IID = IID_AUDIO_PBE_RX_ENABLE\n");
-		acdb_data.pbe_enable_flag = (u16 *)(acdb_data.virt_addr +
-							*index +
-							sizeof(struct header));
-		*index += prs_hdr->data_len + sizeof(struct header);
-	} else if (prs_hdr->iid == IID_PBE_CONFIG_PARAMETERS) {
-		MM_DBG("Got IID == IID_PBE_CONFIG_PARAMETERS\n");
-		acdb_data.pbe_blk = (struct acdb_pbe_block *)
-					(acdb_data.virt_addr + *index
-					+ sizeof(struct header));
-		*index += prs_hdr->data_len + sizeof(struct header);
-	}
-}
-
-static s32 get_audpp_pbe_block(void)
-{
-	struct header *prs_hdr;
-	u32 index = 0;
-	s32 result = -1;
-
-	while (index < acdb_data.acdb_result.used_bytes) {
-		prs_hdr = (struct header *)(acdb_data.virt_addr + index);
-
-		if (prs_hdr->dbor_signature == DBOR_SIGNATURE) {
-			if (prs_hdr->abid == ABID_AUDIO_PBE_RX) {
-				if ((prs_hdr->iid == IID_PBE_CONFIG_PARAMETERS)
-					|| (prs_hdr->iid ==
-						IID_AUDIO_PBE_RX_ENABLE_FLAG)) {
-					extract_pbe_block(prs_hdr, &index);
-					result = 0;
-				}
-			} else {
-				index += prs_hdr->data_len +
-					sizeof(struct header);
-			}
-		} else {
-			break;
-		}
-	}
-	return result;
-}
-
-static s32 acdb_fill_audpp_pbe(void)
-{
-	s32 result = -1;
-
-	result = get_audpp_pbe_block();
-	if (IS_ERR_VALUE(result))
-		return result;
-	memset(acdb_data.pbe_block, 0, sizeof(*acdb_data.pbe_block));
-
-	acdb_data.pbe_block->common.cmd_id = AUDPP_CMD_CFG_OBJECT_PARAMS;
-	acdb_data.pbe_block->common.stream = AUDPP_CMD_COPP_STREAM;
-	acdb_data.pbe_block->common.stream_id = 0;
-	acdb_data.pbe_block->common.obj_cfg = AUDPP_CMD_OBJ0_UPDATE;
-	acdb_data.pbe_block->common.command_type = 0;
-	acdb_data.pbe_block->pbe_enable = *acdb_data.pbe_enable_flag;
-
-	acdb_data.pbe_block->realbassmix = acdb_data.pbe_blk->realbassmix;
-	acdb_data.pbe_block->basscolorcontrol =
-					acdb_data.pbe_blk->basscolorcontrol;
-	acdb_data.pbe_block->mainchaindelay = acdb_data.pbe_blk->mainchaindelay;
-	acdb_data.pbe_block->xoverfltorder = acdb_data.pbe_blk->xoverfltorder;
-	acdb_data.pbe_block->bandpassfltorder =
-					acdb_data.pbe_blk->bandpassfltorder;
-	acdb_data.pbe_block->adrcdelay = acdb_data.pbe_blk->adrcdelay;
-	acdb_data.pbe_block->downsamplelevel =
-					acdb_data.pbe_blk->downsamplelevel;
-	acdb_data.pbe_block->comprmstav = acdb_data.pbe_blk->comprmstav;
-	acdb_data.pbe_block->expthreshold = acdb_data.pbe_blk->expthreshold;
-	acdb_data.pbe_block->expslope = acdb_data.pbe_blk->expslope;
-	acdb_data.pbe_block->compthreshold = acdb_data.pbe_blk->compthreshold;
-	acdb_data.pbe_block->compslope = acdb_data.pbe_blk->compslope;
-	acdb_data.pbe_block->cpmpattack_lsw = acdb_data.pbe_blk->cpmpattack_lsw;
-	acdb_data.pbe_block->compattack_msw = acdb_data.pbe_blk->compattack_msw;
-	acdb_data.pbe_block->comprelease_lsw =
-					acdb_data.pbe_blk->comprelease_lsw;
-	acdb_data.pbe_block->comprelease_msw =
-					acdb_data.pbe_blk->comprelease_msw;
-	acdb_data.pbe_block->compmakeupgain = acdb_data.pbe_blk->compmakeupgain;
-	acdb_data.pbe_block->baselimthreshold =
-					acdb_data.pbe_blk->baselimthreshold;
-	acdb_data.pbe_block->highlimthreshold =
-					acdb_data.pbe_blk->highlimthreshold;
-	acdb_data.pbe_block->basslimmakeupgain =
-					acdb_data.pbe_blk->basslimmakeupgain;
-	acdb_data.pbe_block->highlimmakeupgain =
-					acdb_data.pbe_blk->highlimmakeupgain;
-	acdb_data.pbe_block->limbassgrc = acdb_data.pbe_blk->limbassgrc;
-	acdb_data.pbe_block->limhighgrc = acdb_data.pbe_blk->limhighgrc;
-	acdb_data.pbe_block->limdelay = acdb_data.pbe_blk->limdelay;
-	memcpy(acdb_data.pbe_block->filter_coeffs,
-		acdb_data.pbe_blk->filter_coeffs, sizeof(u16)*90);
-	acdb_data.pbe_block->extpartition = 0;
-	acdb_data.pbe_block->extbuffsize_lsw = PBE_BUF_SIZE;
-	acdb_data.pbe_block->extbuffsize_msw = 0;
-	acdb_data.pbe_block->extbuffstart_lsw = ((u32)acdb_data.pbe_extbuff
-							& 0xFFFF);
-	acdb_data.pbe_block->extbuffstart_msw = (((u32)acdb_data.pbe_extbuff
-							& 0xFFFF0000) >> 16);
-	return 0;
-}
-
-
-static s32 acdb_calibrate_audpp(void)
-{
-	s32	result = 0;
-
-	result = acdb_fill_audpp_iir();
-	if (!IS_ERR_VALUE(result)) {
-		result = audpp_dsp_set_rx_iir(acdb_data.device_info->dev_id,
-				acdb_data.pp_iir->active_flag,
-					acdb_data.pp_iir, COPP);
-		if (result) {
-			MM_ERR("ACDB=> Failed to send IIR data to postproc\n");
-			result = -EINVAL;
-			goto done;
-		} else
-			MM_DBG("AUDPP is calibrated with IIR parameters"
-					" for COPP ID %d\n",
-						acdb_data.device_info->dev_id);
-	}
-	result = acdb_fill_audpp_mbadrc();
-	if (!IS_ERR_VALUE(result)) {
-		result = audpp_dsp_set_mbadrc(acdb_data.device_info->dev_id,
-					acdb_data.pp_mbadrc->enable,
-					acdb_data.pp_mbadrc, COPP);
-		if (result) {
-			MM_ERR("ACDB=> Failed to send MBADRC data to"
-					" postproc\n");
-			result = -EINVAL;
-			goto done;
-		} else
-			MM_DBG("AUDPP is calibrated with MBADRC parameters"
-					" for COPP ID %d\n",
-					acdb_data.device_info->dev_id);
-	}
-	result = acdb_fill_audpp_cal_gain();
-	if (!(IS_ERR_VALUE(result))) {
-		result = audpp_dsp_set_gain_rx(acdb_data.device_info->dev_id,
-					acdb_data.calib_gain_rx, COPP);
-		if (result) {
-			MM_ERR("ACDB=> Failed to send gain_rx"
-				" data to postproc\n");
-			result = -EINVAL;
-			goto done;
-		} else
-			MM_DBG("AUDPP is calibrated with calib_gain_rx\n");
-	}
-	result = acdb_fill_audpp_pbe();
-	if (!(IS_ERR_VALUE(result))) {
-		result = audpp_dsp_set_pbe(acdb_data.device_info->dev_id,
-					acdb_data.pbe_block->pbe_enable,
-					acdb_data.pbe_block, COPP);
-		if (result) {
-			MM_ERR("ACDB=> Failed to send pbe block"
-				"data to postproc\n");
-			result = -EINVAL;
-			goto done;
-		}
-		MM_DBG("AUDPP is calibarted with PBE\n");
-	}
-done:
-	return result;
-}
-
-static struct acdb_agc_block *get_audpreproc_agc_block(void)
-{
-	struct header *prs_hdr;
-	u32 index = 0;
-
-	while (index < acdb_data.acdb_result.used_bytes) {
-		prs_hdr = (struct header *)(acdb_data.virt_addr + index);
-		if (prs_hdr->dbor_signature == DBOR_SIGNATURE) {
-			if (prs_hdr->abid == ABID_AUDIO_AGC_TX) {
-				if (prs_hdr->iid == IID_AUDIO_AGC_PARAMETERS) {
-					MM_DBG("GOT ABID_AUDIO_AGC_TX\n");
-					return (struct acdb_agc_block *)
-						(acdb_data.virt_addr + index
-						 + sizeof(struct header));
-				}
-			} else {
-				index += prs_hdr->data_len +
-						sizeof(struct header);
-			}
-		} else {
-			break;
-		}
-	}
-	return NULL;
-}
-
-static s32 acdb_fill_audpreproc_agc(void)
-{
-	struct acdb_agc_block	*acdb_agc;
-
-	acdb_agc = get_audpreproc_agc_block();
-	if (!acdb_agc) {
-		MM_DBG("unable to find preproc agc parameters winding up\n");
-		return -1;
-	}
-	memset(acdb_data.preproc_agc, 0, sizeof(*acdb_data.preproc_agc));
-	acdb_data.preproc_agc->cmd_id = AUDPREPROC_CMD_CFG_AGC_PARAMS;
-	acdb_data.preproc_agc->stream_id = acdb_data.preproc_stream_id;
-	/* 0xFE00 to configure all parameters */
-	acdb_data.preproc_agc->tx_agc_param_mask = 0xFFFF;
-
-	if (acdb_agc->enable_status)
-		acdb_data.preproc_agc->tx_agc_enable_flag =
-			AUDPREPROC_CMD_TX_AGC_ENA_FLAG_ENA;
-	else
-		acdb_data.preproc_agc->tx_agc_enable_flag =
-			AUDPREPROC_CMD_TX_AGC_ENA_FLAG_DIS;
-
-	acdb_data.preproc_agc->comp_rlink_static_gain =
-		acdb_agc->comp_rlink_static_gain;
-	acdb_data.preproc_agc->comp_rlink_aig_flag =
-		acdb_agc->comp_rlink_aig_flag;
-	acdb_data.preproc_agc->expander_rlink_th =
-		acdb_agc->exp_rlink_threshold;
-	acdb_data.preproc_agc->expander_rlink_slope =
-		acdb_agc->exp_rlink_slope;
-	acdb_data.preproc_agc->compressor_rlink_th =
-		acdb_agc->comp_rlink_threshold;
-	acdb_data.preproc_agc->compressor_rlink_slope =
-		acdb_agc->comp_rlink_slope;
-
-	/* 0xFFF0 to configure all parameters */
-	acdb_data.preproc_agc->tx_adc_agc_param_mask = 0xFFFF;
-
-	acdb_data.preproc_agc->comp_rlink_aig_attackk =
-		acdb_agc->comp_rlink_aig_attack_k;
-	acdb_data.preproc_agc->comp_rlink_aig_leak_down =
-		acdb_agc->comp_rlink_aig_leak_down;
-	acdb_data.preproc_agc->comp_rlink_aig_leak_up =
-		acdb_agc->comp_rlink_aig_leak_up;
-	acdb_data.preproc_agc->comp_rlink_aig_max =
-		acdb_agc->comp_rlink_aig_max;
-	acdb_data.preproc_agc->comp_rlink_aig_min =
-		acdb_agc->comp_rlink_aig_min;
-	acdb_data.preproc_agc->comp_rlink_aig_releasek =
-		acdb_agc->comp_rlink_aig_release_k;
-	acdb_data.preproc_agc->comp_rlink_aig_leakrate_fast =
-		acdb_agc->comp_rlink_aig_sm_leak_rate_fast;
-	acdb_data.preproc_agc->comp_rlink_aig_leakrate_slow =
-		acdb_agc->comp_rlink_aig_sm_leak_rate_slow;
-	acdb_data.preproc_agc->comp_rlink_attackk_msw =
-		acdb_agc->comp_rlink_attack_k_msw;
-	acdb_data.preproc_agc->comp_rlink_attackk_lsw =
-		acdb_agc->comp_rlink_attack_k_lsw;
-	acdb_data.preproc_agc->comp_rlink_delay =
-		acdb_agc->comp_rlink_delay;
-	acdb_data.preproc_agc->comp_rlink_releasek_msw =
-		acdb_agc->comp_rlink_release_k_msw;
-	acdb_data.preproc_agc->comp_rlink_releasek_lsw =
-		acdb_agc->comp_rlink_release_k_lsw;
-	acdb_data.preproc_agc->comp_rlink_rms_tav =
-		acdb_agc->comp_rlink_rms_trav;
-	return 0;
-}
-
-static struct acdb_iir_block *get_audpreproc_irr_block(void)
-{
-
-	struct header *prs_hdr;
-	u32 index = 0;
-
-	while (index < acdb_data.acdb_result.used_bytes) {
-		prs_hdr = (struct header *)(acdb_data.virt_addr + index);
-
-		if (prs_hdr->dbor_signature == DBOR_SIGNATURE) {
-			if (prs_hdr->abid == ABID_AUDIO_IIR_TX) {
-				if (prs_hdr->iid == IID_AUDIO_IIR_COEFF)
-					return (struct acdb_iir_block *)
-						(acdb_data.virt_addr + index
-						 + sizeof(struct header));
-			} else {
-				index += prs_hdr->data_len +
-						sizeof(struct header);
-			}
-		} else {
-			break;
-		}
-	}
-	return NULL;
-}
-
-
-static s32 acdb_fill_audpreproc_iir(void)
-{
-	struct acdb_iir_block	*acdb_iir;
-
-
-	acdb_iir =  get_audpreproc_irr_block();
-	if (!acdb_iir) {
-		MM_DBG("unable to find preproc iir parameters winding up\n");
-		return -1;
-	}
-	memset(acdb_data.preproc_iir, 0, sizeof(*acdb_data.preproc_iir));
-
-	acdb_data.preproc_iir->cmd_id =
-		AUDPREPROC_CMD_CFG_IIR_TUNING_FILTER_PARAMS;
-	acdb_data.preproc_iir->stream_id = acdb_data.preproc_stream_id;
-	acdb_data.preproc_iir->active_flag = acdb_iir->enable_flag;
-	acdb_data.preproc_iir->num_bands = acdb_iir->stage_count;
-
-	acdb_data.preproc_iir->numerator_coeff_b0_filter0_lsw =
-		acdb_iir->stages[0].b0_lo;
-	acdb_data.preproc_iir->numerator_coeff_b0_filter0_msw =
-		acdb_iir->stages[0].b0_hi;
-	acdb_data.preproc_iir->numerator_coeff_b1_filter0_lsw =
-		acdb_iir->stages[0].b1_lo;
-	acdb_data.preproc_iir->numerator_coeff_b1_filter0_msw =
-		acdb_iir->stages[0].b1_hi;
-	acdb_data.preproc_iir->numerator_coeff_b2_filter0_lsw =
-		acdb_iir->stages[0].b2_lo;
-	acdb_data.preproc_iir->numerator_coeff_b2_filter0_msw =
-		acdb_iir->stages[0].b2_hi;
-
-	acdb_data.preproc_iir->numerator_coeff_b0_filter1_lsw =
-		acdb_iir->stages[1].b0_lo;
-	acdb_data.preproc_iir->numerator_coeff_b0_filter1_msw =
-		acdb_iir->stages[1].b0_hi;
-	acdb_data.preproc_iir->numerator_coeff_b1_filter1_lsw =
-		acdb_iir->stages[1].b1_lo;
-	acdb_data.preproc_iir->numerator_coeff_b1_filter1_msw =
-		acdb_iir->stages[1].b1_hi;
-	acdb_data.preproc_iir->numerator_coeff_b2_filter1_lsw =
-		acdb_iir->stages[1].b2_lo;
-	acdb_data.preproc_iir->numerator_coeff_b2_filter1_msw =
-		acdb_iir->stages[1].b2_hi;
-
-	acdb_data.preproc_iir->numerator_coeff_b0_filter2_lsw =
-		acdb_iir->stages[2].b0_lo;
-	acdb_data.preproc_iir->numerator_coeff_b0_filter2_msw =
-		acdb_iir->stages[2].b0_hi;
-	acdb_data.preproc_iir->numerator_coeff_b1_filter2_lsw =
-		acdb_iir->stages[2].b1_lo;
-	acdb_data.preproc_iir->numerator_coeff_b1_filter2_msw =
-		acdb_iir->stages[2].b1_hi;
-	acdb_data.preproc_iir->numerator_coeff_b2_filter2_lsw =
-		acdb_iir->stages[2].b2_lo;
-	acdb_data.preproc_iir->numerator_coeff_b2_filter2_msw =
-		acdb_iir->stages[2].b2_hi;
-
-	acdb_data.preproc_iir->numerator_coeff_b0_filter3_lsw =
-		acdb_iir->stages[3].b0_lo;
-	acdb_data.preproc_iir->numerator_coeff_b0_filter3_msw =
-		acdb_iir->stages[3].b0_hi;
-	acdb_data.preproc_iir->numerator_coeff_b1_filter3_lsw =
-		acdb_iir->stages[3].b1_lo;
-	acdb_data.preproc_iir->numerator_coeff_b1_filter3_msw =
-		acdb_iir->stages[3].b1_hi;
-	acdb_data.preproc_iir->numerator_coeff_b2_filter3_lsw =
-		acdb_iir->stages[3].b2_lo;
-	acdb_data.preproc_iir->numerator_coeff_b2_filter3_msw =
-		acdb_iir->stages[3].b2_hi;
-
-	acdb_data.preproc_iir->denominator_coeff_a0_filter0_lsw =
-		acdb_iir->stages_a[0].a1_lo;
-	acdb_data.preproc_iir->denominator_coeff_a0_filter0_msw =
-		acdb_iir->stages_a[0].a1_hi;
-	acdb_data.preproc_iir->denominator_coeff_a1_filter0_lsw =
-		acdb_iir->stages_a[0].a2_lo;
-	acdb_data.preproc_iir->denominator_coeff_a1_filter0_msw =
-		acdb_iir->stages_a[0].a2_hi;
-
-	acdb_data.preproc_iir->denominator_coeff_a0_filter1_lsw =
-		acdb_iir->stages_a[1].a1_lo;
-	acdb_data.preproc_iir->denominator_coeff_a0_filter1_msw =
-		acdb_iir->stages_a[1].a1_hi;
-	acdb_data.preproc_iir->denominator_coeff_a1_filter1_lsw =
-		acdb_iir->stages_a[1].a2_lo;
-	acdb_data.preproc_iir->denominator_coeff_a1_filter1_msw =
-		acdb_iir->stages_a[1].a2_hi;
-
-	acdb_data.preproc_iir->denominator_coeff_a0_filter2_lsw =
-		acdb_iir->stages_a[2].a1_lo;
-	acdb_data.preproc_iir->denominator_coeff_a0_filter2_msw =
-		acdb_iir->stages_a[2].a1_hi;
-	acdb_data.preproc_iir->denominator_coeff_a1_filter2_lsw =
-		acdb_iir->stages_a[2].a2_lo;
-	acdb_data.preproc_iir->denominator_coeff_a1_filter2_msw =
-		acdb_iir->stages_a[2].a2_hi;
-
-	acdb_data.preproc_iir->denominator_coeff_a0_filter3_lsw =
-		acdb_iir->stages_a[3].a1_lo;
-	acdb_data.preproc_iir->denominator_coeff_a0_filter3_msw =
-		acdb_iir->stages_a[3].a1_hi;
-	acdb_data.preproc_iir->denominator_coeff_a1_filter3_lsw =
-		acdb_iir->stages_a[3].a2_lo;
-	acdb_data.preproc_iir->denominator_coeff_a1_filter3_msw =
-		acdb_iir->stages_a[3].a2_hi;
-
-	acdb_data.preproc_iir->shift_factor_filter0 =
-		acdb_iir->shift_factor[0];
-	acdb_data.preproc_iir->shift_factor_filter1 =
-		acdb_iir->shift_factor[1];
-	acdb_data.preproc_iir->shift_factor_filter2 =
-		acdb_iir->shift_factor[2];
-	acdb_data.preproc_iir->shift_factor_filter3 =
-		acdb_iir->shift_factor[3];
-
-	acdb_data.preproc_iir->pan_of_filter0 =
-		acdb_iir->pan[0];
-	acdb_data.preproc_iir->pan_of_filter1 =
-		acdb_iir->pan[1];
-	acdb_data.preproc_iir->pan_of_filter2 =
-		acdb_iir->pan[2];
-	acdb_data.preproc_iir->pan_of_filter3 =
-		acdb_iir->pan[3];
-	return 0;
-}
-
-static struct acdb_calib_gain_tx *get_audpreproc_cal_gain(void)
-{
-	struct header *prs_hdr;
-	u32 index = 0;
-
-	while (index < acdb_data.acdb_result.used_bytes) {
-		prs_hdr = (struct header *)(acdb_data.virt_addr + index);
-		if (prs_hdr->dbor_signature == DBOR_SIGNATURE) {
-			if (prs_hdr->abid == ABID_AUDIO_CALIBRATION_GAIN_TX) {
-				if (prs_hdr->iid ==
-					IID_AUDIO_CALIBRATION_GAIN_TX) {
-					MM_DBG("Got audpreproc_calib_gain_tx"
-					" block\n");
-					return (struct acdb_calib_gain_tx *)
-						(acdb_data.virt_addr + index
-						+ sizeof(struct header));
-				}
-			} else {
-				index += prs_hdr->data_len +
-					sizeof(struct header);
-			}
-		} else {
-			break;
-		}
-	}
-	return NULL;
-}
-
-static s32 acdb_fill_audpreproc_cal_gain(void)
-{
-	struct acdb_calib_gain_tx *acdb_calib_gain_tx = NULL;
-
-	acdb_calib_gain_tx = get_audpreproc_cal_gain();
-	if (acdb_calib_gain_tx == NULL) {
-		MM_ERR("unable to find  audpreproc"
-			" calibration block returning\n");
-		return -1;
-	}
-	MM_DBG("Calibration value"
-		" for calib_gain_tx %d\n", acdb_calib_gain_tx->audprecalgain);
-	memset(acdb_data.calib_gain_tx, 0, sizeof(*acdb_data.calib_gain_tx));
-
-	acdb_data.calib_gain_tx->cmd_id =
-					AUDPREPROC_CMD_CFG_CAL_GAIN_PARAMS;
-	acdb_data.calib_gain_tx->stream_id = acdb_data.preproc_stream_id;
-	acdb_data.calib_gain_tx->audprecalgain =
-					acdb_calib_gain_tx->audprecalgain;
-	return 0;
-}
-
-static struct acdb_rmc_block *get_rmc_blk(void)
-{
-	struct header *prs_hdr;
-	u32 index = 0;
-
-	while (index < acdb_data.acdb_result.used_bytes) {
-		prs_hdr = (struct header *)(acdb_data.virt_addr + index);
-		if (prs_hdr->dbor_signature == DBOR_SIGNATURE) {
-			if (prs_hdr->abid == ABID_AUDIO_RMC_TX) {
-				if (prs_hdr->iid ==
-					IID_AUDIO_RMC_PARAM) {
-					MM_DBG("Got afe_rmc block\n");
-					return (struct acdb_rmc_block *)
-						(acdb_data.virt_addr + index
-						+ sizeof(struct header));
-				}
-			} else {
-				index += prs_hdr->data_len +
-					sizeof(struct header);
-			}
-		} else {
-			break;
-		}
-	}
-	return NULL;
-}
-
-struct acdb_fluence_block *get_audpp_fluence_block(void)
-{
-	struct header *prs_hdr;
-	u32 index = 0;
-
-	while (index < acdb_data.acdb_result.used_bytes) {
-		prs_hdr = (struct header *)(acdb_data.virt_addr + index);
-
-		if (prs_hdr->dbor_signature == DBOR_SIGNATURE) {
-			if (prs_hdr->abid == ABID_AUDIO_FLUENCE_TX) {
-				if (prs_hdr->iid == IID_AUDIO_FLUENCE_TX) {
-					MM_DBG("got fluence block\n");
-					return (struct acdb_fluence_block *)
-						(acdb_data.virt_addr + index
-						+ sizeof(struct header));
-				}
-			} else {
-				index += prs_hdr->data_len +
-					sizeof(struct header);
-			}
-		} else {
-			break;
-		}
-	}
-	return NULL;
-}
-
-static s32 acdb_fill_audpreproc_fluence(void)
-{
-	struct acdb_fluence_block *fluence_block = NULL;
-	fluence_block = get_audpp_fluence_block();
-	if (!fluence_block) {
-		MM_ERR("error in finding fluence block\n");
-		return -EPERM;
-	}
-	memset(&acdb_data.preproc_lvnv, 0, sizeof(
-				struct audpreproc_cmd_cfg_lvnv_param));
-	memcpy(acdb_data.fluence_extbuff_virt,
-			&fluence_block->cs_tuningMode,
-			(sizeof(struct acdb_fluence_block) -
-					sizeof(fluence_block->csmode)));
-	acdb_data.preproc_lvnv.cmd_id = AUDPREPROC_CMD_CFG_LVNV_PARMS;
-	acdb_data.preproc_lvnv.stream_id = acdb_data.preproc_stream_id;
-	acdb_data.preproc_lvnv.cs_mode = fluence_block->csmode;
-	acdb_data.preproc_lvnv.lvnv_ext_buf_size = FLUENCE_BUF_SIZE;
-	acdb_data.preproc_lvnv.lvnv_ext_buf_start_lsw =\
-				((u32)(acdb_data.fluence_extbuff)\
-						& 0x0000FFFF);
-	acdb_data.preproc_lvnv.lvnv_ext_buf_start_msw =\
-				(((u32)acdb_data.fluence_extbuff\
-					& 0xFFFF0000) >> 16);
-	return 0;
-}
-
-s32 acdb_calibrate_audpreproc(void)
-{
-	s32	result = 0;
-	struct acdb_rmc_block *acdb_rmc = NULL;
-
-	result = acdb_fill_audpreproc_agc();
-	if (!IS_ERR_VALUE(result)) {
-		result = audpreproc_dsp_set_agc(acdb_data.preproc_agc, sizeof(
-					struct audpreproc_cmd_cfg_agc_params));
-		if (result) {
-			MM_ERR("ACDB=> Failed to send AGC data to preproc)\n");
-			result = -EINVAL;
-			goto done;
-		} else
-			MM_DBG("AUDPREC is calibrated with AGC parameters"
-				" for COPP ID %d and AUDREC session %d\n",
-					acdb_data.device_info->dev_id,
-					acdb_data.preproc_stream_id);
-	}
-	result = acdb_fill_audpreproc_iir();
-	if (!IS_ERR_VALUE(result)) {
-		result = audpreproc_dsp_set_iir(acdb_data.preproc_iir,
-				sizeof(struct\
-				audpreproc_cmd_cfg_iir_tuning_filter_params));
-		if (result) {
-			MM_ERR("ACDB=> Failed to send IIR data to preproc\n");
-			result = -EINVAL;
-			goto done;
-		} else
-			MM_DBG("audpreproc is calibrated with iir parameters"
-			" for COPP ID %d and AUREC session %d\n",
-					acdb_data.device_info->dev_id,
-					acdb_data.preproc_stream_id);
-	}
-	result = acdb_fill_audpreproc_cal_gain();
-	if (!(IS_ERR_VALUE(result))) {
-		result = audpreproc_dsp_set_gain_tx(acdb_data.calib_gain_tx,
-				sizeof(struct audpreproc_cmd_cfg_cal_gain));
-		if (result) {
-			MM_ERR("ACDB=> Failed to send calib_gain_tx"
-				" data to preproc\n");
-			result = -EINVAL;
-			goto done;
-		} else
-			MM_DBG("AUDPREPROC is calibrated"
-				" with calib_gain_tx\n");
-	}
-	if (acdb_data.build_id[17] != '0') {
-		acdb_rmc = get_rmc_blk();
-		if (acdb_rmc != NULL) {
-			result = afe_config_rmc_block(acdb_rmc);
-			if (result) {
-				MM_ERR("ACDB=> Failed to send rmc"
-					" data to afe\n");
-				result = -EINVAL;
-				goto done;
-			} else
-				MM_DBG("AFE is calibrated with rmc params\n");
-		} else
-			MM_DBG("RMC block was not found\n");
-	}
-	if (!acdb_data.fleuce_feature_status[acdb_data.preproc_stream_id]) {
-		result = acdb_fill_audpreproc_fluence();
-		if (!(IS_ERR_VALUE(result))) {
-			result = audpreproc_dsp_set_lvnv(
-					&acdb_data.preproc_lvnv,
-					sizeof(struct\
-					audpreproc_cmd_cfg_lvnv_param));
-			if (result) {
-				MM_ERR("ACDB=> Failed to send lvnv "
-						"data to preproc\n");
-				result = -EINVAL;
-				goto done;
-			} else
-				MM_DBG("AUDPREPROC is calibrated"
-						" with lvnv parameters\n");
-		} else
-			MM_ERR("fluence block is not found\n");
-	} else
-		MM_DBG("fluence block override\n");
-done:
-	return result;
-}
-
-static s32 acdb_send_calibration(void)
-{
-	s32 result = 0;
-
-	if ((acdb_data.device_info->dev_type & RX_DEVICE) == 1) {
-		result = acdb_calibrate_audpp();
-		if (result)
-			goto done;
-	} else if ((acdb_data.device_info->dev_type & TX_DEVICE) == 2) {
-		result = acdb_calibrate_audpreproc();
-		if (result)
-			goto done;
-		if (acdb_data.preproc_stream_id == 0)
-			acdb_data.audrec_applied |= AUDREC0_READY;
-		else if (acdb_data.preproc_stream_id == 1)
-			acdb_data.audrec_applied |= AUDREC1_READY;
-		else if (acdb_data.preproc_stream_id == 2)
-			acdb_data.audrec_applied |= AUDREC2_READY;
-		MM_DBG("acdb_data.audrec_applied = %x\n",
-					acdb_data.audrec_applied);
-	}
-done:
-	return result;
-}
-
-static u8 check_tx_acdb_values_cached(void)
-{
-	u8 stream_id  = acdb_data.preproc_stream_id;
-
-	if ((acdb_data.device_info->dev_id ==
-		acdb_cache_tx[stream_id].device_info.dev_id) &&
-		(acdb_data.device_info->sample_rate ==
-		acdb_cache_tx[stream_id].device_info.sample_rate) &&
-		(acdb_data.device_info->acdb_id ==
-		acdb_cache_tx[stream_id].device_info.acdb_id) &&
-		(acdb_cache_tx[stream_id].node_status ==
-						ACDB_VALUES_FILLED))
-		return 0;
-	else
-		return 1;
-}
-
-static void handle_tx_device_ready_callback(void)
-{
-	u8 i = 0;
-	u8 ret = 0;
-	u8 acdb_value_apply = 0;
-	u8 result = 0;
-	u8 stream_id = acdb_data.preproc_stream_id;
-
-	if (acdb_data.multiple_sessions) {
-		for (i = 0; i < MAX_AUDREC_SESSIONS; i++) {
-			/*check is to exclude copying acdb values in the
-			current node pointed by acdb_data structure*/
-			if (acdb_cache_tx[i].phys_addr_acdb_values !=
-							acdb_data.phys_addr) {
-				ret = check_device_info_already_present(\
-							*acdb_data.device_info,
-							&acdb_cache_tx[i]);
-				if (ret) {
-					memcpy((char *)acdb_cache_tx[i].\
-						virt_addr_acdb_values,
-						(char *)acdb_data.virt_addr,
-								ACDB_BUF_SIZE);
-					acdb_cache_tx[i].node_status =
-							ACDB_VALUES_FILLED;
-				}
-			}
-		}
-		acdb_data.multiple_sessions = 0;
-	}
-	/*check wheather AUDREC enabled before device call backs*/
-	if ((acdb_data.acdb_state & AUDREC0_READY) &&
-			!(acdb_data.audrec_applied & AUDREC0_READY)) {
-		MM_DBG("AUDREC0 already enabled apply acdb values\n");
-		acdb_value_apply |= AUDREC0_READY;
-	} else if ((acdb_data.acdb_state & AUDREC1_READY) &&
-			!(acdb_data.audrec_applied & AUDREC1_READY)) {
-		MM_DBG("AUDREC1 already enabled apply acdb values\n");
-		acdb_value_apply |= AUDREC1_READY;
-	} else if ((acdb_data.acdb_state & AUDREC2_READY) &&
-			!(acdb_data.audrec_applied & AUDREC2_READY)) {
-		MM_DBG("AUDREC2 already enabled apply acdb values\n");
-		acdb_value_apply |= AUDREC2_READY;
-	}
-	if (acdb_value_apply) {
-		if (session_info[stream_id].sampling_freq)
-			acdb_data.device_info->sample_rate =
-					session_info[stream_id].sampling_freq;
-		result = check_tx_acdb_values_cached();
-		if (result) {
-			result = acdb_get_calibration();
-			if (result < 0) {
-				MM_ERR("Not able to get calibration"
-						" data continue\n");
-				return;
-			}
-		}
-		acdb_cache_tx[stream_id].node_status = ACDB_VALUES_FILLED;
-		acdb_send_calibration();
-	}
-}
-
-static struct acdb_cache_node *get_acdb_values_from_cache_tx(u32 stream_id)
-{
-	MM_DBG("searching node with stream_id %d\n", stream_id);
-	if ((acdb_cache_tx[stream_id].stream_id == stream_id) &&
-			(acdb_cache_tx[stream_id].node_status ==
-					ACDB_VALUES_NOT_FILLED)) {
-			return &acdb_cache_tx[stream_id];
-	}
-	MM_DBG("Error! in finding node\n");
-	return NULL;
-}
-
-static void update_acdb_data_struct(struct acdb_cache_node *cur_node)
-{
-	if (cur_node) {
-		acdb_data.device_info = &cur_node->device_info;
-		acdb_data.virt_addr = cur_node->virt_addr_acdb_values;
-		acdb_data.phys_addr = cur_node->phys_addr_acdb_values;
-	} else
-		MM_ERR("error in curent node\n");
-}
-
-static void send_acdb_values_for_active_devices(void)
-{
-	u32 i = 0;
-	for (i = 0; i < MAX_COPP_NODE_SUPPORTED; i++) {
-		if (acdb_cache_rx[i].node_status ==
-					ACDB_VALUES_FILLED) {
-			update_acdb_data_struct(&acdb_cache_rx[i]);
-			if (acdb_data.acdb_state & CAL_DATA_READY)
-				acdb_send_calibration();
-		}
-	}
-}
-
-static s32 initialize_rpc(void)
-{
-	s32 result = 0;
-
-	result = daldevice_attach(DALDEVICEID_ACDB, ACDB_PORT_NAME,
-			ACDB_CPU, &acdb_data.handle);
-
-	if (result) {
-		MM_ERR("ACDB=> Device Attach failed\n");
-		result = -ENODEV;
-		goto done;
-	}
-done:
-	return result;
-}
-
-static u32 allocate_memory_acdb_cache_tx(void)
-{
-	u32 result = 0;
-	u32 i = 0;
-	u32 err = 0;
-	/*initialize local cache */
-	for (i = 0; i < MAX_AUDREC_SESSIONS; i++) {
-		acdb_cache_tx[i].phys_addr_acdb_values =
-				allocate_contiguous_ebi_nomap(ACDB_BUF_SIZE,
-								SZ_4K);
-
-		if (!acdb_cache_tx[i].phys_addr_acdb_values) {
-			MM_ERR("ACDB=> Cannot allocate physical memory\n");
-			result = -ENOMEM;
-			goto error;
-		}
-		acdb_cache_tx[i].map_v_addr = ioremap(
-					acdb_cache_tx[i].phys_addr_acdb_values,
-						ACDB_BUF_SIZE);
-		if (IS_ERR(acdb_cache_tx[i].map_v_addr)) {
-			MM_ERR("ACDB=> Could not map physical address\n");
-			result = -ENOMEM;
-			free_contiguous_memory_by_paddr(
-					acdb_cache_tx[i].phys_addr_acdb_values);
-			goto error;
-		}
-		acdb_cache_tx[i].virt_addr_acdb_values =
-					acdb_cache_tx[i].map_v_addr;
-		memset(acdb_cache_tx[i].virt_addr_acdb_values, 0,
-						ACDB_BUF_SIZE);
-	}
-	return result;
-error:
-	for (err = 0; err < i; err++) {
-		iounmap(acdb_cache_tx[err].map_v_addr);
-		free_contiguous_memory_by_paddr(
-				acdb_cache_tx[err].phys_addr_acdb_values);
-	}
-	return result;
-}
-
-static u32 allocate_memory_acdb_cache_rx(void)
-{
-	u32 result = 0;
-	u32 i = 0;
-	u32 err = 0;
-
-	/*initialize local cache */
-	for (i = 0; i < MAX_COPP_NODE_SUPPORTED; i++) {
-		acdb_cache_rx[i].phys_addr_acdb_values =
-					allocate_contiguous_ebi_nomap(
-						ACDB_BUF_SIZE, SZ_4K);
-
-		if (!acdb_cache_rx[i].phys_addr_acdb_values) {
-			MM_ERR("ACDB=> Can not allocate physical memory\n");
-			result = -ENOMEM;
-			goto error;
-		}
-		acdb_cache_rx[i].map_v_addr =
-				ioremap(acdb_cache_rx[i].phys_addr_acdb_values,
-					ACDB_BUF_SIZE);
-		if (IS_ERR(acdb_cache_rx[i].map_v_addr)) {
-			MM_ERR("ACDB=> Could not map physical address\n");
-			result = -ENOMEM;
-			free_contiguous_memory_by_paddr(
-					acdb_cache_rx[i].phys_addr_acdb_values);
-			goto error;
-		}
-		acdb_cache_rx[i].virt_addr_acdb_values =
-					acdb_cache_rx[i].map_v_addr;
-		memset(acdb_cache_rx[i].virt_addr_acdb_values, 0,
-						ACDB_BUF_SIZE);
-	}
-	return result;
-error:
-	for (err = 0; err < i; err++) {
-		iounmap(acdb_cache_rx[err].map_v_addr);
-		free_contiguous_memory_by_paddr(
-				acdb_cache_rx[err].phys_addr_acdb_values);
-	}
-	return result;
-}
-
-static u32 allocate_memory_acdb_get_blk(void)
-{
-	u32 result = 0;
-	acdb_data.get_blk_paddr = allocate_contiguous_ebi_nomap(
-						ACDB_BUF_SIZE, SZ_4K);
-	if (!acdb_data.get_blk_paddr) {
-		MM_ERR("ACDB=> Cannot allocate physical memory\n");
-		result = -ENOMEM;
-		goto error;
-	}
-	acdb_data.map_v_get_blk = ioremap(acdb_data.get_blk_paddr,
-					ACDB_BUF_SIZE);
-	if (IS_ERR(acdb_data.map_v_get_blk)) {
-		MM_ERR("ACDB=> Could not map physical address\n");
-		result = -ENOMEM;
-		free_contiguous_memory_by_paddr(
-					acdb_data.get_blk_paddr);
-		goto error;
-	}
-	acdb_data.get_blk_kvaddr = acdb_data.map_v_get_blk;
-	memset(acdb_data.get_blk_kvaddr, 0, ACDB_BUF_SIZE);
-error:
-	return result;
-}
-
-static void free_memory_acdb_cache_rx(void)
-{
-	u32 i = 0;
-
-	for (i = 0; i < MAX_COPP_NODE_SUPPORTED; i++) {
-		iounmap(acdb_cache_rx[i].map_v_addr);
-		free_contiguous_memory_by_paddr(
-				acdb_cache_rx[i].phys_addr_acdb_values);
-	}
-}
-
-static void free_memory_acdb_cache_tx(void)
-{
-	u32 i = 0;
-
-	for (i = 0; i < MAX_AUDREC_SESSIONS; i++) {
-		iounmap(acdb_cache_tx[i].map_v_addr);
-		free_contiguous_memory_by_paddr(
-				acdb_cache_tx[i].phys_addr_acdb_values);
-	}
-}
-
-static void free_memory_acdb_get_blk(void)
-{
-	iounmap(acdb_data.map_v_get_blk);
-	free_contiguous_memory_by_paddr(acdb_data.get_blk_paddr);
-}
-
-static s32 initialize_memory(void)
-{
-	s32 result = 0;
-
-	result = allocate_memory_acdb_get_blk();
-	if (result < 0) {
-		MM_ERR("memory allocation for get blk failed\n");
-		goto done;
-	}
-
-	result = allocate_memory_acdb_cache_rx();
-	if (result < 0) {
-		MM_ERR("memory allocation for rx cache is failed\n");
-		free_memory_acdb_get_blk();
-		goto done;
-	}
-	result = allocate_memory_acdb_cache_tx();
-	if (result < 0) {
-		MM_ERR("memory allocation for tx cache is failed\n");
-		free_memory_acdb_get_blk();
-		free_memory_acdb_cache_rx();
-		goto done;
-	}
-	acdb_data.pp_iir = kmalloc(sizeof(*acdb_data.pp_iir),
-		GFP_KERNEL);
-	if (acdb_data.pp_iir == NULL) {
-		MM_ERR("ACDB=> Could not allocate postproc iir memory\n");
-		free_memory_acdb_get_blk();
-		free_memory_acdb_cache_rx();
-		free_memory_acdb_cache_tx();
-		result = -ENOMEM;
-		goto done;
-	}
-
-	acdb_data.pp_mbadrc = kmalloc(sizeof(*acdb_data.pp_mbadrc), GFP_KERNEL);
-	if (acdb_data.pp_mbadrc == NULL) {
-		MM_ERR("ACDB=> Could not allocate postproc mbadrc memory\n");
-		free_memory_acdb_get_blk();
-		free_memory_acdb_cache_rx();
-		free_memory_acdb_cache_tx();
-		kfree(acdb_data.pp_iir);
-		result = -ENOMEM;
-		goto done;
-	}
-	acdb_data.calib_gain_rx = kmalloc(sizeof(*acdb_data.calib_gain_rx),
-							GFP_KERNEL);
-	if (acdb_data.calib_gain_rx == NULL) {
-		MM_ERR("ACDB=> Could not allocate"
-			" postproc calib_gain_rx memory\n");
-		free_memory_acdb_get_blk();
-		free_memory_acdb_cache_rx();
-		free_memory_acdb_cache_tx();
-		kfree(acdb_data.pp_iir);
-		kfree(acdb_data.pp_mbadrc);
-		result = -ENOMEM;
-		goto done;
-	}
-
-	acdb_data.preproc_agc = kmalloc(sizeof(*acdb_data.preproc_agc),
-							GFP_KERNEL);
-	if (acdb_data.preproc_agc == NULL) {
-		MM_ERR("ACDB=> Could not allocate preproc agc memory\n");
-		free_memory_acdb_get_blk();
-		free_memory_acdb_cache_rx();
-		free_memory_acdb_cache_tx();
-		kfree(acdb_data.pp_iir);
-		kfree(acdb_data.pp_mbadrc);
-		kfree(acdb_data.calib_gain_rx);
-		result = -ENOMEM;
-		goto done;
-	}
-
-	acdb_data.preproc_iir = kmalloc(sizeof(*acdb_data.preproc_iir),
-							GFP_KERNEL);
-	if (acdb_data.preproc_iir == NULL) {
-		MM_ERR("ACDB=> Could not allocate preproc iir memory\n");
-		free_memory_acdb_get_blk();
-		free_memory_acdb_cache_rx();
-		free_memory_acdb_cache_tx();
-		kfree(acdb_data.pp_iir);
-		kfree(acdb_data.pp_mbadrc);
-		kfree(acdb_data.calib_gain_rx);
-		kfree(acdb_data.preproc_agc);
-		result = -ENOMEM;
-		goto done;
-	}
-	acdb_data.calib_gain_tx = kmalloc(sizeof(*acdb_data.calib_gain_tx),
-							GFP_KERNEL);
-	if (acdb_data.calib_gain_tx == NULL) {
-		MM_ERR("ACDB=> Could not allocate"
-			" preproc calib_gain_tx memory\n");
-		free_memory_acdb_get_blk();
-		free_memory_acdb_cache_rx();
-		free_memory_acdb_cache_tx();
-		kfree(acdb_data.pp_iir);
-		kfree(acdb_data.pp_mbadrc);
-		kfree(acdb_data.calib_gain_rx);
-		kfree(acdb_data.preproc_agc);
-		kfree(acdb_data.preproc_iir);
-		result = -ENOMEM;
-		goto done;
-	}
-	acdb_data.pbe_block = kmalloc(sizeof(*acdb_data.pbe_block),
-						GFP_KERNEL);
-	if (acdb_data.pbe_block == NULL) {
-		MM_ERR("ACDB=> Could not allocate pbe_block memory\n");
-		free_memory_acdb_get_blk();
-		free_memory_acdb_cache_rx();
-		free_memory_acdb_cache_tx();
-		kfree(acdb_data.pp_iir);
-		kfree(acdb_data.pp_mbadrc);
-		kfree(acdb_data.calib_gain_rx);
-		kfree(acdb_data.preproc_agc);
-		kfree(acdb_data.preproc_iir);
-		kfree(acdb_data.calib_gain_tx);
-		result = -ENOMEM;
-		goto done;
-	}
-	acdb_data.pbe_extbuff = (u16 *) allocate_contiguous_ebi_nomap(
-						PBE_BUF_SIZE, SZ_4K);
-	if (!acdb_data.pbe_extbuff) {
-		MM_ERR("ACDB=> Cannot allocate physical memory\n");
-		free_memory_acdb_get_blk();
-		free_memory_acdb_cache_rx();
-		free_memory_acdb_cache_tx();
-		kfree(acdb_data.pp_iir);
-		kfree(acdb_data.pp_mbadrc);
-		kfree(acdb_data.calib_gain_rx);
-		kfree(acdb_data.preproc_agc);
-		kfree(acdb_data.preproc_iir);
-		kfree(acdb_data.calib_gain_tx);
-		kfree(acdb_data.pbe_block);
-		result = -ENOMEM;
-		goto done;
-	}
-	acdb_data.fluence_extbuff = allocate_contiguous_ebi_nomap(
-					FLUENCE_BUF_SIZE, SZ_4K);
-	if (!acdb_data.fluence_extbuff) {
-		MM_ERR("ACDB=> cannot allocate physical memory for "
-					"fluence block\n");
-		free_memory_acdb_get_blk();
-		free_memory_acdb_cache_rx();
-		free_memory_acdb_cache_tx();
-		kfree(acdb_data.pp_iir);
-		kfree(acdb_data.pp_mbadrc);
-		kfree(acdb_data.calib_gain_rx);
-		kfree(acdb_data.preproc_agc);
-		kfree(acdb_data.preproc_iir);
-		kfree(acdb_data.calib_gain_tx);
-		kfree(acdb_data.pbe_block);
-		free_contiguous_memory_by_paddr((int32_t)acdb_data.pbe_extbuff);
-		result = -ENOMEM;
-		goto done;
-	}
-	acdb_data.map_v_fluence = ioremap(
-				acdb_data.fluence_extbuff,
-				FLUENCE_BUF_SIZE);
-	if (IS_ERR(acdb_data.map_v_fluence)) {
-		MM_ERR("ACDB=> Could not map physical address\n");
-		free_memory_acdb_get_blk();
-		free_memory_acdb_cache_rx();
-		free_memory_acdb_cache_tx();
-		kfree(acdb_data.pp_iir);
-		kfree(acdb_data.pp_mbadrc);
-		kfree(acdb_data.calib_gain_rx);
-		kfree(acdb_data.preproc_agc);
-		kfree(acdb_data.preproc_iir);
-		kfree(acdb_data.calib_gain_tx);
-		kfree(acdb_data.pbe_block);
-		free_contiguous_memory_by_paddr(
-				(int32_t)acdb_data.pbe_extbuff);
-		free_contiguous_memory_by_paddr(
-				(int32_t)acdb_data.fluence_extbuff);
-		result = -ENOMEM;
-		goto done;
-	} else
-		acdb_data.fluence_extbuff_virt =
-					acdb_data.map_v_fluence;
-done:
-	return result;
-}
-
-static u32 free_acdb_cache_node(union auddev_evt_data *evt)
-{
-	u32 session_id;
-	if ((evt->audcal_info.dev_type & TX_DEVICE) == 2) {
-		/*Second argument to find_first_bit should be maximum number
-		of bits interested
-		*/
-		session_id = find_first_bit(
-				(unsigned long *)&(evt->audcal_info.sessions),
-				sizeof(evt->audcal_info.sessions) * 8);
-		MM_DBG("freeing node %d for tx device", session_id);
-		acdb_cache_tx[session_id].
-			node_status = ACDB_VALUES_NOT_FILLED;
-	} else {
-			MM_DBG("freeing rx cache node %d\n",
-						evt->audcal_info.dev_id);
-			acdb_cache_rx[evt->audcal_info.dev_id].
-				node_status = ACDB_VALUES_NOT_FILLED;
-	}
-	return 0;
-}
-
-static u8 check_device_change(struct auddev_evt_audcal_info audcal_info)
-{
-	if (!acdb_data.device_info) {
-		MM_ERR("not pointing to previous valid device detail\n");
-		return 1; /*device info will not be pointing to*/
-			/* valid device when acdb driver comes up*/
-	}
-	if ((audcal_info.dev_id == acdb_data.device_info->dev_id) &&
-		(audcal_info.sample_rate ==
-				acdb_data.device_info->sample_rate) &&
-		(audcal_info.acdb_id == acdb_data.device_info->acdb_id)) {
-		return 0;
-	}
-	return 1;
-}
-
-static void device_cb(u32 evt_id, union auddev_evt_data *evt, void *private)
-{
-	struct auddev_evt_audcal_info	audcal_info;
-	struct acdb_cache_node *acdb_cache_free_node =  NULL;
-	u32 stream_id = 0;
-	u8 ret = 0;
-	u8 count = 0;
-	u8 i = 0;
-	u8 device_change = 0;
-
-	if (!((evt_id == AUDDEV_EVT_DEV_RDY) ||
-		(evt_id == AUDDEV_EVT_DEV_RLS))) {
-		goto done;
-	}
-	/*if session value is zero it indicates that device call back is for
-	voice call we will drop the request as acdb values for voice call is
-	not applied from acdb driver*/
-	if (!evt->audcal_info.sessions) {
-		MM_DBG("no active sessions and call back is for"
-				" voice call\n");
-		goto done;
-	}
-	if (evt_id == AUDDEV_EVT_DEV_RLS) {
-		MM_DBG("got release command for dev %d\n",
-					evt->audcal_info.dev_id);
-		acdb_data.acdb_state &= ~CAL_DATA_READY;
-		free_acdb_cache_node(evt);
-		/*reset the applied flag for the session routed to the device*/
-		acdb_data.audrec_applied &= ~(evt->audcal_info.sessions
-							<< AUDREC_OFFSET);
-		goto done;
-	}
-	if (((evt->audcal_info.dev_type & RX_DEVICE) == 1) &&
-			(evt->audcal_info.acdb_id == PSEUDO_ACDB_ID)) {
-		MM_INFO("device cb is for rx device with pseudo acdb id\n");
-		goto done;
-	}
-	audcal_info = evt->audcal_info;
-	MM_DBG("dev_id = %d\n", audcal_info.dev_id);
-	MM_DBG("sample_rate = %d\n", audcal_info.sample_rate);
-	MM_DBG("acdb_id = %d\n", audcal_info.acdb_id);
-	MM_DBG("sessions = %d\n", audcal_info.sessions);
-	MM_DBG("acdb_state = %x\n", acdb_data.acdb_state);
-	mutex_lock(&acdb_data.acdb_mutex);
-	device_change = check_device_change(audcal_info);
-	if (!device_change) {
-		if ((audcal_info.dev_type & TX_DEVICE) == 2) {
-			if (!(acdb_data.acdb_state & AUDREC0_READY))
-				acdb_data.audrec_applied &= ~AUDREC0_READY;
-			if (!(acdb_data.acdb_state & AUDREC1_READY))
-				acdb_data.audrec_applied &= ~AUDREC1_READY;
-			if (!(acdb_data.acdb_state & AUDREC2_READY))
-				acdb_data.audrec_applied &= ~AUDREC2_READY;
-				acdb_data.acdb_state &= ~CAL_DATA_READY;
-				goto update_cache;
-		}
-	} else
-		/* state is updated to querry the modem for values */
-		acdb_data.acdb_state &= ~CAL_DATA_READY;
-
-update_cache:
-	if ((audcal_info.dev_type & TX_DEVICE) == 2) {
-		/*loop is to take care of use case:- multiple Audrec
-		sessions are routed before enabling the device in this use
-		case we will get the sessions value as bits set for all the
-		sessions routed before device enable, so we should take care
-		of copying device info to all the sessions*/
-		for (i = 0; i < MAX_AUDREC_SESSIONS; i++) {
-			stream_id = ((audcal_info.sessions >> i) & 0x01);
-			if (stream_id) {
-				acdb_cache_free_node =	&acdb_cache_tx[i];
-				ret  = check_device_info_already_present(
-							audcal_info,
-							acdb_cache_free_node);
-				acdb_cache_free_node->stream_id = i;
-				acdb_data.cur_tx_session = i;
-				count++;
-			}
-		}
-		if (count > 1)
-			acdb_data.multiple_sessions = 1;
-	} else {
-		acdb_cache_free_node = &acdb_cache_rx[audcal_info.dev_id];
-		ret = check_device_info_already_present(audcal_info,
-						acdb_cache_free_node);
-		if (ret == 1) {
-			MM_DBG("got device ready call back for another "
-					"audplay task sessions on same COPP\n");
-			/*stream_id is used to keep track of number of active*/
-			/*sessions active on this device*/
-			acdb_cache_free_node->stream_id++;
-			mutex_unlock(&acdb_data.acdb_mutex);
-			goto done;
-		}
-		acdb_cache_free_node->stream_id++;
-	}
-	update_acdb_data_struct(acdb_cache_free_node);
-	acdb_data.device_cb_compl = 1;
-	mutex_unlock(&acdb_data.acdb_mutex);
-	wake_up(&acdb_data.wait);
-done:
-	return;
-}
-
-
-static s32 register_device_cb(void)
-{
-	s32 result = 0;
-
-	result = auddev_register_evt_listner((AUDDEV_EVT_DEV_RDY
-						| AUDDEV_EVT_DEV_RLS),
-		AUDDEV_CLNT_AUDIOCAL, 0, device_cb, (void *)&acdb_data);
-
-	if (result) {
-		MM_ERR("ACDB=> Could not register device callback\n");
-		result = -ENODEV;
-		goto done;
-	}
-done:
-	return result;
-}
-
-static void audpp_cb(void *private, u32 id, u16 *msg)
-{
-	MM_DBG("\n");
-	if (id != AUDPP_MSG_CFG_MSG)
-		goto done;
-
-	if (msg[0] == AUDPP_MSG_ENA_DIS) {
-		if (--acdb_cache_rx[acdb_data.\
-				device_info->dev_id].stream_id <= 0) {
-			acdb_data.acdb_state &= ~AUDPP_READY;
-			acdb_cache_rx[acdb_data.device_info->dev_id]\
-					.stream_id = 0;
-			MM_DBG("AUDPP_MSG_ENA_DIS\n");
-		}
-		goto done;
-	}
-
-	acdb_data.acdb_state |= AUDPP_READY;
-	acdb_data.audpp_cb_compl = 1;
-	wake_up(&acdb_data.wait);
-done:
-	return;
-}
-
-static s8 handle_audpreproc_cb(void)
-{
-	struct acdb_cache_node *acdb_cached_values;
-	s8 result = 0;
-	u8 stream_id = acdb_data.preproc_stream_id;
-	acdb_data.preproc_cb_compl = 0;
-	acdb_cached_values = get_acdb_values_from_cache_tx(stream_id);
-	if (acdb_cached_values == NULL) {
-		MM_DBG("ERROR: to get chached acdb values\n");
-		return -EPERM;
-	}
-	update_acdb_data_struct(acdb_cached_values);
-	if (acdb_data.device_info->dev_id == PSEUDO_ACDB_ID) {
-		MM_INFO("audpreproc is routed to pseudo device\n");
-		return result;
-	}
-	if (acdb_data.build_id[17] == '1') {
-		if (session_info[stream_id].sampling_freq)
-			acdb_data.device_info->sample_rate =
-					session_info[stream_id].sampling_freq;
-	}
-	if (!(acdb_data.acdb_state & CAL_DATA_READY)) {
-		result = check_tx_acdb_values_cached();
-		if (result) {
-			result = acdb_get_calibration();
-			if (result < 0) {
-				MM_ERR("failed to get calibration data\n");
-				return result;
-			}
-		}
-		acdb_cached_values->node_status = ACDB_VALUES_FILLED;
-	}
-	return result;
-}
-
-void fluence_feature_update(int enable, int stream_id)
-{
-	MM_INFO("Fluence feature over ride with = %d\n", enable);
-	acdb_data.fleuce_feature_status[stream_id] = enable;
-}
-EXPORT_SYMBOL(fluence_feature_update);
-
-static void audpreproc_cb(void *private, u32 id, void *msg)
-{
-	struct audpreproc_cmd_enc_cfg_done_msg *tmp;
-	u8 result = 0;
-	int stream_id = 0;
-	if (id != AUDPREPROC_CMD_ENC_CFG_DONE_MSG)
-		goto done;
-
-	tmp = (struct audpreproc_cmd_enc_cfg_done_msg *)msg;
-	acdb_data.preproc_stream_id = tmp->stream_id;
-	stream_id = acdb_data.preproc_stream_id;
-	get_audrec_session_info(stream_id, &session_info[stream_id]);
-	MM_DBG("rec_enc_type = %x\n", tmp->rec_enc_type);
-	if ((tmp->rec_enc_type & 0x8000) ==
-				AUD_PREPROC_CONFIG_DISABLED) {
-		if (acdb_data.preproc_stream_id == 0) {
-			acdb_data.acdb_state &= ~AUDREC0_READY;
-			acdb_data.audrec_applied &= ~AUDREC0_READY;
-		} else if (acdb_data.preproc_stream_id == 1) {
-			acdb_data.acdb_state &= ~AUDREC1_READY;
-			acdb_data.audrec_applied &= ~AUDREC1_READY;
-		} else if (acdb_data.preproc_stream_id == 2) {
-			acdb_data.acdb_state &= ~AUDREC2_READY;
-			acdb_data.audrec_applied &= ~AUDREC2_READY;
-		}
-		acdb_data.fleuce_feature_status[stream_id] = 0;
-		acdb_cache_tx[tmp->stream_id].node_status =\
-						ACDB_VALUES_NOT_FILLED;
-		acdb_data.acdb_state &= ~CAL_DATA_READY;
-		goto done;
-	}
-	/*Following check is added to make sure that device info
-	  is updated. audpre proc layer enabled without device
-	  callback at this scenario we should not access
-	  device information
-	 */
-	if (acdb_data.build_id[17] != '0') {
-		if (acdb_data.device_info &&
-			session_info[stream_id].sampling_freq) {
-			acdb_data.device_info->sample_rate =
-					session_info[stream_id].sampling_freq;
-			result = check_tx_acdb_values_cached();
-			if (!result) {
-				MM_INFO("acdb values for the stream is" \
-							" querried from modem");
-				acdb_data.acdb_state |= CAL_DATA_READY;
-			} else {
-				acdb_data.acdb_state &= ~CAL_DATA_READY;
-			}
-		}
-	}
-	if (acdb_data.preproc_stream_id == 0)
-		acdb_data.acdb_state |= AUDREC0_READY;
-	else if (acdb_data.preproc_stream_id == 1)
-		acdb_data.acdb_state |= AUDREC1_READY;
-	else if (acdb_data.preproc_stream_id == 2)
-		acdb_data.acdb_state |= AUDREC2_READY;
-	acdb_data.preproc_cb_compl = 1;
-	MM_DBG("acdb_data.acdb_state = %x\n", acdb_data.acdb_state);
-	wake_up(&acdb_data.wait);
-done:
-	return;
-}
-
-static s32 register_audpp_cb(void)
-{
-	s32 result = 0;
-
-	acdb_data.audpp_cb.fn = audpp_cb;
-	acdb_data.audpp_cb.private = NULL;
-	result = audpp_register_event_callback(&acdb_data.audpp_cb);
-	if (result) {
-		MM_ERR("ACDB=> Could not register audpp callback\n");
-		result = -ENODEV;
-		goto done;
-	}
-done:
-	return result;
-}
-
-static s32 register_audpreproc_cb(void)
-{
-	s32 result = 0;
-
-	acdb_data.audpreproc_cb.fn = audpreproc_cb;
-	acdb_data.audpreproc_cb.private = NULL;
-	result = audpreproc_register_event_callback(&acdb_data.audpreproc_cb);
-	if (result) {
-		MM_ERR("ACDB=> Could not register audpreproc callback\n");
-		result = -ENODEV;
-		goto done;
-	}
-
-done:
-	return result;
-}
-
-static s32 acdb_initialize_data(void)
-{
-	s32	result = 0;
-
-	mutex_init(&acdb_data.acdb_mutex);
-
-	result = initialize_rpc();
-	if (result)
-		goto err;
-
-	result = initialize_memory();
-	if (result)
-		goto err1;
-
-	result = register_device_cb();
-	if (result)
-		goto err2;
-
-	result = register_audpp_cb();
-	if (result)
-		goto err3;
-
-	result = register_audpreproc_cb();
-	if (result)
-		goto err4;
-
-
-	return result;
-
-err4:
-	result = audpreproc_unregister_event_callback(&acdb_data.audpreproc_cb);
-	if (result)
-		MM_ERR("ACDB=> Could not unregister audpreproc callback\n");
-err3:
-	result = audpp_unregister_event_callback(&acdb_data.audpp_cb);
-	if (result)
-		MM_ERR("ACDB=> Could not unregister audpp callback\n");
-err2:
-	result = auddev_unregister_evt_listner(AUDDEV_CLNT_AUDIOCAL, 0);
-	if (result)
-		MM_ERR("ACDB=> Could not unregister device callback\n");
-err1:
-	daldevice_detach(acdb_data.handle);
-	acdb_data.handle = NULL;
-err:
-	return result;
-}
-
-static s32 initialize_modem_acdb(void)
-{
-	struct acdb_cmd_init_adie acdb_cmd;
-	u8 codec_type = -1;
-	s32 result = 0;
-	u8 iterations = 0;
-
-	codec_type = adie_get_detected_codec_type();
-	if (codec_type == MARIMBA_ID)
-		acdb_cmd.adie_type = ACDB_CURRENT_ADIE_MODE_MARIMBA;
-	else if (codec_type == TIMPANI_ID)
-		acdb_cmd.adie_type = ACDB_CURRENT_ADIE_MODE_TIMPANI;
-	else
-		acdb_cmd.adie_type = ACDB_CURRENT_ADIE_MODE_UNKNOWN;
-	acdb_cmd.command_id = ACDB_CMD_INITIALIZE_FOR_ADIE;
-	do {
-		/*Initialize ACDB software on modem based on codec type*/
-		result = dalrpc_fcn_8(ACDB_DalACDB_ioctl, acdb_data.handle,
-				(const void *)&acdb_cmd, sizeof(acdb_cmd),
-				&acdb_data.acdb_result,
-				sizeof(acdb_data.acdb_result));
-		if (result < 0) {
-			MM_ERR("ACDB=> RPC failure result = %d\n", result);
-			goto error;
-		}
-		/*following check is introduced to handle boot up race
-		condition between AUDCAL SW peers running on apps
-		and modem (ACDB_RES_BADSTATE indicates modem AUDCAL SW is
-		not in initialized sate) we need to retry to get ACDB
-		initialized*/
-		if (acdb_data.acdb_result.result == ACDB_RES_BADSTATE) {
-			msleep(500);
-			iterations++;
-		} else if (acdb_data.acdb_result.result == ACDB_RES_SUCCESS) {
-			MM_DBG("Modem ACDB SW initialized ((iterations = %d)\n",
-							iterations);
-			return result;
-		} else {
-			MM_ERR("ACDB=> Modem ACDB SW failed to initialize"
-					" reuslt = %d, (iterations = %d)\n",
-					acdb_data.acdb_result.result,
-					iterations);
-			goto error;
-		}
-	} while (iterations < MAX_RETRY);
-	MM_ERR("ACDB=> AUDCAL SW on modem is not in intiailized state (%d)\n",
-			acdb_data.acdb_result.result);
-error:
-	result = -EINVAL;
-	return result;
-}
-
-static s32 acdb_calibrate_device(void *data)
-{
-	s32 result = 0;
-
-	/* initialize driver */
-	result = acdb_initialize_data();
-	if (result)
-		goto done;
-	if (acdb_data.build_id[17] != '0') {
-		result = initialize_modem_acdb();
-		if (result < 0)
-			MM_ERR("failed to initialize modem ACDB\n");
-	}
-
-	while (!kthread_should_stop()) {
-		MM_DBG("Waiting for call back events\n");
-		wait_event_interruptible(acdb_data.wait,
-					(acdb_data.device_cb_compl
-					| acdb_data.audpp_cb_compl
-					| acdb_data.preproc_cb_compl));
-		mutex_lock(&acdb_data.acdb_mutex);
-		if (acdb_data.device_cb_compl) {
-			acdb_data.device_cb_compl = 0;
-			if (!(acdb_data.acdb_state & CAL_DATA_READY)) {
-				if ((acdb_data.device_info->dev_type
-							& RX_DEVICE) == 1) {
-					/*we need to get calibration values
-					only for RX device as resampler
-					moved to start of the pre - proc chain
-					tx calibration value will be based on
-					sampling frequency what audrec is
-					configured, calibration values for tx
-					device are fetch in audpreproc
-					callback*/
-					result = acdb_get_calibration();
-					if (result < 0) {
-						mutex_unlock(
-							&acdb_data.acdb_mutex);
-						MM_ERR("Not able to get "
-							"calibration "
-							"data continue\n");
-						continue;
-					}
-				}
-			}
-			MM_DBG("acdb state = %d\n",
-					 acdb_data.acdb_state);
-			if ((acdb_data.device_info->dev_type & TX_DEVICE) == 2)
-				handle_tx_device_ready_callback();
-			else {
-				acdb_cache_rx[acdb_data.device_info->dev_id]\
-						.node_status =
-						ACDB_VALUES_FILLED;
-				if (acdb_data.acdb_state &
-						AUDPP_READY) {
-					MM_DBG("AUDPP already enabled "
-							"apply acdb values\n");
-					goto apply;
-				}
-			}
-		}
-
-		if (!(acdb_data.audpp_cb_compl ||
-				acdb_data.preproc_cb_compl)) {
-			MM_DBG("need to wait for either AUDPP / AUDPREPROC "
-					"Event\n");
-			mutex_unlock(&acdb_data.acdb_mutex);
-			continue;
-		} else {
-			MM_DBG("got audpp / preproc call back\n");
-			if (acdb_data.audpp_cb_compl) {
-				send_acdb_values_for_active_devices();
-				acdb_data.audpp_cb_compl = 0;
-				mutex_unlock(&acdb_data.acdb_mutex);
-				continue;
-			} else {
-				result = handle_audpreproc_cb();
-				if (result < 0) {
-					mutex_unlock(&acdb_data.acdb_mutex);
-					continue;
-				}
-			}
-		}
-apply:
-		if (acdb_data.acdb_state & CAL_DATA_READY)
-			result = acdb_send_calibration();
-
-		mutex_unlock(&acdb_data.acdb_mutex);
-	}
-done:
-	return 0;
-}
-
-static int __init acdb_init(void)
-{
-
-	s32 result = 0;
-
-	memset(&acdb_data, 0, sizeof(acdb_data));
-	spin_lock_init(&acdb_data.dsp_lock);
-	acdb_data.cb_thread_task = kthread_run(acdb_calibrate_device,
-		NULL, "acdb_cb_thread");
-
-	if (IS_ERR(acdb_data.cb_thread_task)) {
-		MM_ERR("ACDB=> Could not register cb thread\n");
-		result = -ENODEV;
-		goto err;
-	}
-
-	acdb_data.build_id = socinfo_get_build_id();
-	MM_INFO("build id used is = %s\n", acdb_data.build_id);
-
-#ifdef CONFIG_DEBUG_FS
-	/*This is RTC specific INIT used only with debugfs*/
-	if (!rtc_acdb_init())
-		MM_ERR("RTC ACDB=>INIT Failure\n");
-
-#endif
-	init_waitqueue_head(&acdb_data.wait);
-
-	return misc_register(&acdb_misc);
-err:
-	return result;
-}
-
-static void __exit acdb_exit(void)
-{
-	s32	result = 0;
-	u32 i = 0;
-
-	result = auddev_unregister_evt_listner(AUDDEV_CLNT_AUDIOCAL, 0);
-	if (result)
-		MM_ERR("ACDB=> Could not unregister device callback\n");
-
-	result = audpp_unregister_event_callback(&acdb_data.audpp_cb);
-	if (result)
-		MM_ERR("ACDB=> Could not unregister audpp callback\n");
-
-	result = audpreproc_unregister_event_callback(&acdb_data.\
-				audpreproc_cb);
-	if (result)
-		MM_ERR("ACDB=> Could not unregister audpreproc callback\n");
-
-	result = kthread_stop(acdb_data.cb_thread_task);
-	if (result)
-		MM_ERR("ACDB=> Could not stop kthread\n");
-
-	free_memory_acdb_get_blk();
-
-	for (i = 0; i < MAX_COPP_NODE_SUPPORTED; i++) {
-		if (i < MAX_AUDREC_SESSIONS) {
-			iounmap(acdb_cache_tx[i].map_v_addr);
-			free_contiguous_memory_by_paddr(
-					acdb_cache_tx[i].phys_addr_acdb_values);
-		}
-		iounmap(acdb_cache_rx[i].map_v_addr);
-		free_contiguous_memory_by_paddr(
-					acdb_cache_rx[i].phys_addr_acdb_values);
-	}
-	kfree(acdb_data.device_info);
-	kfree(acdb_data.pp_iir);
-	kfree(acdb_data.pp_mbadrc);
-	kfree(acdb_data.preproc_agc);
-	kfree(acdb_data.preproc_iir);
-	free_contiguous_memory_by_paddr(
-				(int32_t)acdb_data.pbe_extbuff);
-	iounmap(acdb_data.map_v_fluence);
-	free_contiguous_memory_by_paddr(
-			(int32_t)acdb_data.fluence_extbuff);
-	mutex_destroy(&acdb_data.acdb_mutex);
-	memset(&acdb_data, 0, sizeof(acdb_data));
-	#ifdef CONFIG_DEBUG_FS
-	rtc_acdb_deinit();
-	#endif
-}
-
-late_initcall(acdb_init);
-module_exit(acdb_exit);
-
-MODULE_DESCRIPTION("MSM 7x30 Audio ACDB driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5v2/audio_adpcm.c b/arch/arm/mach-msm/qdsp5v2/audio_adpcm.c
deleted file mode 100644
index 632aa0d..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audio_adpcm.c
+++ /dev/null
@@ -1,1753 +0,0 @@
-/* Copyright (c) 2009-2012, The Linux Foundation. All rights reserved.
- *
- * Based on the mp3 native driver in arch/arm/mach-msm/qdsp5v2/audio_mp3.c
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- *
- * All source code in this file is licensed under the following license except
- * where indicated.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you can find it at http://www.fsf.org
- */
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/list.h>
-#include <linux/earlysuspend.h>
-#include <linux/slab.h>
-#include <linux/msm_audio.h>
-#include <linux/memory_alloc.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-
-#include <mach/msm_adsp.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/qdsp5v2/qdsp5audppmsg.h>
-#include <mach/qdsp5v2/qdsp5audplaycmdi.h>
-#include <mach/qdsp5v2/qdsp5audplaymsg.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/qdsp5v2/audpp.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_memtypes.h>
-
-
-/* Size must be power of 2 */
-#define BUFSZ_MAX 	32768	/* Includes meta in size */
-#define BUFSZ_MIN 	4096	/* Includes meta in size */
-#define DMASZ_MAX 	(BUFSZ_MAX * 2)
-#define DMASZ_MIN 	(BUFSZ_MIN * 2)
-
-#define AUDPLAY_INVALID_READ_PTR_OFFSET	0xFFFF
-#define AUDDEC_DEC_ADPCM 1
-
-#define PCM_BUFSZ_MIN 	8216 	/* Hold one stereo ADPCM frame and meta out*/
-#define PCM_BUF_MAX_COUNT 5	/* DSP only accepts 5 buffers at most
-				   but support 2 buffers currently */
-#define ROUTING_MODE_FTRT 1
-#define ROUTING_MODE_RT 2
-/* Decoder status received from AUDPPTASK */
-#define  AUDPP_DEC_STATUS_SLEEP	0
-#define	 AUDPP_DEC_STATUS_INIT  1
-#define  AUDPP_DEC_STATUS_CFG   2
-#define  AUDPP_DEC_STATUS_PLAY  3
-
-#define AUDADPCM_METAFIELD_MASK 0xFFFF0000
-#define AUDADPCM_EOS_FLG_OFFSET 0x0A /* Offset from beginning of buffer */
-#define AUDADPCM_EOS_FLG_MASK 0x01
-#define AUDADPCM_EOS_NONE 0x0 /* No EOS detected */
-#define AUDADPCM_EOS_SET 0x1 /* EOS set in meta field */
-
-#define AUDADPCM_EVENT_NUM 10 /* Default no. of pre-allocated event packets */
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;		/* Input usage actual DSP produced PCM size  */
-	unsigned addr;
-	unsigned short mfield_sz; /*only useful for data has meta field */
-};
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-struct audadpcm_suspend_ctl {
-	struct early_suspend node;
-	struct audio *audio;
-};
-#endif
-
-struct audadpcm_event{
-	struct list_head list;
-	int event_type;
-	union msm_audio_event_payload payload;
-};
-
-struct audio {
-	struct buffer out[2];
-
-	spinlock_t dsp_lock;
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed; /* number of buffers the dsp is waiting for */
-	unsigned out_dma_sz;
-
-	atomic_t out_bytes;
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-
-	/* Host PCM section */
-	struct buffer in[PCM_BUF_MAX_COUNT];
-	struct mutex read_lock;
-	wait_queue_head_t read_wait;	/* Wait queue for read */
-	char *read_data;	/* pointer to reader buffer */
-	int32_t read_phys;	/* physical address of reader buffer */
-	uint8_t read_next;	/* index to input buffers to be read next */
-	uint8_t fill_next;	/* index to buffer that DSP should be filling */
-	uint8_t pcm_buf_count;	/* number of pcm buffer allocated */
-	/* ---- End of Host PCM section */
-
-	struct msm_adsp_module *audplay;
-
-	/* configuration to use on next enable */
-	uint32_t out_sample_rate;
-	uint32_t out_channel_mode;
-	uint32_t out_block_size;
-
-	/* data allocated for various buffers */
-	char *data;
-	int32_t phys; /* physical address of write buffer */
-	void *map_v_read;
-	void *map_v_write;
-	int mfield; /* meta field embedded in data */
-	int rflush; /* Read  flush */
-	int wflush; /* Write flush */
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped, cleared on flush */
-	int pcm_feedback;
-	int buf_refresh;
-	int teos; /* valid only if tunnel mode & no data left for decoder */
-	enum msm_aud_decoder_state dec_state;	/* Represents decoder state */
-	int reserved; /* A byte is being reserved */
-	char rsv_byte; /* Handle odd length user data */
-
-	const char *module_name;
-	unsigned queue_id;
-	uint16_t dec_id;
-	uint32_t read_ptr_offset;
-	int16_t source;
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	struct audadpcm_suspend_ctl suspend_ctl;
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *dentry;
-#endif
-
-	wait_queue_head_t wait;
-	struct list_head free_event_queue;
-	struct list_head event_queue;
-	wait_queue_head_t event_wait;
-	spinlock_t event_queue_lock;
-	struct mutex get_event_lock;
-	int event_abort;
-	/* AV sync Info */
-	int avsync_flag;              /* Flag to indicate feedback from DSP */
-	wait_queue_head_t avsync_wait;/* Wait queue for AV Sync Message     */
-	/* flags, 48 bits sample/bytes counter per channel */
-	uint16_t avsync[AUDPP_AVSYNC_CH_COUNT * AUDPP_AVSYNC_NUM_WORDS + 1];
-	uint32_t device_events;
-
-	int eq_enable;
-	int eq_needs_commit;
-	struct audpp_cmd_cfg_object_params_eqalizer eq;
-	struct audpp_cmd_cfg_object_params_volume vol_pan;
-};
-
-static int auddec_dsp_config(struct audio *audio, int enable);
-static void audpp_cmd_cfg_adec_params(struct audio *audio);
-static void audpp_cmd_cfg_routing_mode(struct audio *audio);
-static void audplay_send_data(struct audio *audio, unsigned needed);
-static void audplay_config_hostpcm(struct audio *audio);
-static void audplay_buffer_refresh(struct audio *audio);
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audadpcm_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload);
-#endif
-
-/* must be called with audio->lock held */
-static int audio_enable(struct audio *audio)
-{
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled)
-		return 0;
-
-	audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-
-	if (msm_adsp_enable(audio->audplay)) {
-		MM_ERR("msm_adsp_enable(audplay) failed\n");
-		return -ENODEV;
-	}
-
-	if (audpp_enable(audio->dec_id, audio_dsp_event, audio)) {
-		MM_ERR("audpp_enable() failed\n");
-		msm_adsp_disable(audio->audplay);
-		return -ENODEV;
-	}
-
-	audio->enabled = 1;
-	return 0;
-}
-
-static void adpcm_listner(u32 evt_id, union auddev_evt_data *evt_payload,
-			void *private_data)
-{
-	struct audio *audio = (struct audio *) private_data;
-	switch (evt_id) {
-	case AUDDEV_EVT_DEV_RDY:
-		MM_DBG(":AUDDEV_EVT_DEV_RDY\n");
-		audio->source |= (0x1 << evt_payload->routing_id);
-		if (audio->running == 1 && audio->enabled == 1)
-			audpp_route_stream(audio->dec_id, audio->source);
-		break;
-	case AUDDEV_EVT_DEV_RLS:
-		MM_DBG(":AUDDEV_EVT_DEV_RLS\n");
-		if (audio->dec_state == MSM_AUD_DECODER_STATE_SUCCESS &&
-							audio->enabled == 1)
-			audpp_route_stream(audio->dec_id,
-				msm_snddev_route_dec(audio->dec_id));
-		break;
-	case AUDDEV_EVT_STREAM_VOL_CHG:
-		audio->vol_pan.volume = evt_payload->session_vol;
-		MM_DBG(":AUDDEV_EVT_STREAM_VOL_CHG, stream vol %d\n",
-				audio->vol_pan.volume);
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		break;
-	default:
-		MM_ERR(":ERROR:wrong event\n");
-		break;
-	}
-}
-/* must be called with audio->lock held */
-static int audio_disable(struct audio *audio)
-{
-	int rc = 0;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-		auddec_dsp_config(audio, 0);
-		rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-		if (rc == 0)
-			rc = -ETIMEDOUT;
-		else if (audio->dec_state != MSM_AUD_DECODER_STATE_CLOSE)
-			rc = -EFAULT;
-		else
-			rc = 0;
-		wake_up(&audio->write_wait);
-		wake_up(&audio->read_wait);
-		msm_adsp_disable(audio->audplay);
-		audpp_disable(audio->dec_id, audio);
-		audio->out_needed = 0;
-	}
-	return rc;
-}
-
-/* ------------------- dsp --------------------- */
-static void audio_update_pcm_buf_entry(struct audio *audio,
-	uint32_t *payload)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	if (audio->rflush)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < payload[1]; index++) {
-		if (audio->in[audio->fill_next].addr ==
-			payload[2 + index * 2]) {
-			MM_DBG("audio_update_pcm_buf_entry: \
-				in[%d] ready\n", audio->fill_next);
-			audio->in[audio->fill_next].used =
-			payload[3 + index * 2];
-			if ((++audio->fill_next) == audio->pcm_buf_count)
-				audio->fill_next = 0;
-		} else {
-			MM_ERR("audio_update_pcm_buf_entry: \
-				expected=%x ret=%x\n",
-				audio->in[audio->fill_next].addr,
-				payload[1 + index * 2]);
-			break;
-		}
-	}
-	if (audio->in[audio->fill_next].used == 0) {
-		audplay_buffer_refresh(audio);
-	} else {
-		MM_DBG("read cannot keep up\n");
-		audio->buf_refresh = 1;
-	}
-	wake_up(&audio->read_wait);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audplay_dsp_event(void *data, unsigned id, size_t len,
-			      void (*getevent) (void *ptr, size_t len))
-{
-	struct audio *audio = data;
-	uint32_t msg[28];
-
-	getevent(msg, sizeof(msg));
-
-	MM_DBG("msg_id=%x\n", id);
-
-	switch (id) {
-	case AUDPLAY_MSG_DEC_NEEDS_DATA:
-		audplay_send_data(audio, 1);
-		break;
-
-	case AUDPLAY_MSG_BUFFER_UPDATE:
-		audio_update_pcm_buf_entry(audio, msg);
-		break;
-
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audplaytask)\n");
-		break;
-
-	default:
-		MM_ERR("unexpected message from decoder \n");
-		break;
-	}
-}
-
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg)
-{
-	struct audio *audio = private;
-
-	switch (id) {
-	case AUDPP_MSG_STATUS_MSG:{
-			unsigned status = msg[1];
-
-			switch (status) {
-			case AUDPP_DEC_STATUS_SLEEP: {
-				uint16_t reason = msg[2];
-				MM_DBG("decoder status:sleep reason = \
-						0x%04x\n", reason);
-				if ((reason == AUDPP_MSG_REASON_MEM)
-					|| (reason ==
-					AUDPP_MSG_REASON_NODECODER)) {
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_FAILURE;
-					wake_up(&audio->wait);
-				} else if (reason == AUDPP_MSG_REASON_NONE) {
-					/* decoder is in disable state */
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_CLOSE;
-					wake_up(&audio->wait);
-				}
-				break;
-			}
-			case AUDPP_DEC_STATUS_INIT:
-				MM_DBG("decoder status: init\n");
-				if (audio->pcm_feedback)
-					audpp_cmd_cfg_routing_mode(audio);
-				else
-					audpp_cmd_cfg_adec_params(audio);
-				break;
-
-			case AUDPP_DEC_STATUS_CFG:
-				MM_DBG("decoder status: cfg\n");
-				break;
-			case AUDPP_DEC_STATUS_PLAY:
-				MM_DBG("decoder status: play \n");
-				/* send  mixer command */
-				audpp_route_stream(audio->dec_id,
-						audio->source);
-				if (audio->pcm_feedback) {
-					audplay_config_hostpcm(audio);
-					audplay_buffer_refresh(audio);
-				}
-				audio->dec_state =
-					MSM_AUD_DECODER_STATE_SUCCESS;
-				wake_up(&audio->wait);
-				break;
-			default:
-				MM_ERR("unknown decoder status\n");
-			}
-			break;
-		}
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_DBG("CFG_MSG ENABLE\n");
-			auddec_dsp_config(audio, 1);
-			audio->out_needed = 0;
-			audio->running = 1;
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-			audpp_dsp_set_eq(audio->dec_id,	audio->eq_enable,
-					&audio->eq, POPP);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			MM_DBG("CFG_MSG DISABLE\n");
-			audio->running = 0;
-		} else {
-			MM_DBG("CFG_MSG %d?\n", msg[0]);
-		}
-		break;
-	case AUDPP_MSG_ROUTING_ACK:
-		MM_DBG("ROUTING_ACK mode=%d\n", msg[1]);
-		audpp_cmd_cfg_adec_params(audio);
-		break;
-
-	case AUDPP_MSG_FLUSH_ACK:
-		MM_DBG("FLUSH_ACK\n");
-		audio->wflush = 0;
-		audio->rflush = 0;
-		wake_up(&audio->write_wait);
-		if (audio->pcm_feedback)
-			audplay_buffer_refresh(audio);
-		break;
-
-	case AUDPP_MSG_PCMDMAMISSED:
-		MM_DBG("PCMDMAMISSED\n");
-		audio->teos = 1;
-		wake_up(&audio->write_wait);
-		break;
-
-	case AUDPP_MSG_AVSYNC_MSG:
-		MM_DBG("AUDPP_MSG_AVSYNC_MSG\n");
-		memcpy(&audio->avsync[0], msg, sizeof(audio->avsync));
-		audio->avsync_flag = 1;
-		wake_up(&audio->avsync_wait);
-		break;
-
-	default:
-		MM_ERR("UNKNOWN (%d)\n", id);
-	}
-
-}
-
-static struct msm_adsp_ops audplay_adsp_ops_adpcm = {
-	.event = audplay_dsp_event,
-};
-
-#define audplay_send_queue0(audio, cmd, len) \
-	msm_adsp_write(audio->audplay, audio->queue_id, \
-			cmd, len)
-
-static int auddec_dsp_config(struct audio *audio, int enable)
-{
-	struct audpp_cmd_cfg_dec_type cfg_dec_cmd;
-
-	memset(&cfg_dec_cmd, 0, sizeof(cfg_dec_cmd));
-
-	cfg_dec_cmd.cmd_id = AUDPP_CMD_CFG_DEC_TYPE;
-	if (enable)
-		cfg_dec_cmd.dec_cfg = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_ENA_DEC_V | AUDDEC_DEC_ADPCM;
-	else
-		cfg_dec_cmd.dec_cfg = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_DIS_DEC_V;
-	cfg_dec_cmd.dm_mode = 0x0;
-	cfg_dec_cmd.stream_id = audio->dec_id;
-	return audpp_send_queue1(&cfg_dec_cmd, sizeof(cfg_dec_cmd));
-}
-
-static void audpp_cmd_cfg_adec_params(struct audio *audio)
-{
-	struct audpp_cmd_cfg_adec_params_adpcm cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_CMD_CFG_ADEC_PARAMS;
-	cmd.common.length = AUDPP_CMD_CFG_ADEC_PARAMS_ADPCM_LEN;
-	cmd.common.dec_id = audio->dec_id;
-	cmd.common.input_sampling_frequency = audio->out_sample_rate;
-
-	cmd.stereo_cfg =  audio->out_channel_mode;
-	cmd.block_size =  audio->out_block_size;
-
-	audpp_send_queue2(&cmd, sizeof(cmd));
-}
-
-static void audpp_cmd_cfg_routing_mode(struct audio *audio)
-{
-	struct audpp_cmd_routing_mode cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPP_CMD_ROUTING_MODE;
-	cmd.object_number = audio->dec_id;
-	if (audio->pcm_feedback)
-		cmd.routing_mode = ROUTING_MODE_FTRT;
-	else
-		cmd.routing_mode = ROUTING_MODE_RT;
-
-	audpp_send_queue1(&cmd, sizeof(cmd));
-}
-
-static void audplay_buffer_refresh(struct audio *audio)
-{
-	struct audplay_cmd_buffer_refresh refresh_cmd;
-
-	refresh_cmd.cmd_id = AUDPLAY_CMD_BUFFER_REFRESH;
-	refresh_cmd.num_buffers = 1;
-	refresh_cmd.buf0_address = audio->in[audio->fill_next].addr;
-	refresh_cmd.buf0_length = audio->in[audio->fill_next].size;
-	refresh_cmd.buf_read_count = 0;
-
-	MM_DBG("buf0_addr=%x buf0_len=%d\n",
-			refresh_cmd.buf0_address,
-			refresh_cmd.buf0_length);
-
-	(void)audplay_send_queue0(audio, &refresh_cmd, sizeof(refresh_cmd));
-}
-
-static void audplay_config_hostpcm(struct audio *audio)
-{
-	struct audplay_cmd_hpcm_buf_cfg cfg_cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	cfg_cmd.cmd_id = AUDPLAY_CMD_HPCM_BUF_CFG;
-	cfg_cmd.max_buffers = audio->pcm_buf_count;
-	cfg_cmd.byte_swap = 0;
-	cfg_cmd.hostpcm_config = (0x8000) | (0x4000);
-	cfg_cmd.feedback_frequency = 1;
-	cfg_cmd.partition_number = 0;
-
-	(void)audplay_send_queue0(audio, &cfg_cmd, sizeof(cfg_cmd));
-}
-
-
-static int audplay_dsp_send_data_avail(struct audio *audio,
-					unsigned idx, unsigned len)
-{
-	struct audplay_cmd_bitstream_data_avail_nt2 cmd;
-
-	cmd.cmd_id		= AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2;
-	if (audio->mfield)
-		cmd.decoder_id = AUDADPCM_METAFIELD_MASK |
-		(audio->out[idx].mfield_sz >> 1);
-	else
-		cmd.decoder_id		= audio->dec_id;
-	cmd.buf_ptr		= audio->out[idx].addr;
-	cmd.buf_size		= len/2;
-	cmd.partition_number	= 0;
-	return audplay_send_queue0(audio, &cmd, sizeof(cmd));
-}
-
-static void audplay_send_data(struct audio *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (audio->wflush) {
-		audio->out_needed = 1;
-		goto done;
-	}
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			MM_DBG("frame %d free\n", audio->out_tail);
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		MM_DBG("\n"); /* Macro prints the file name and function */
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			MM_DBG("frame %d busy\n", audio->out_tail);
-			audplay_dsp_send_data_avail(audio, audio->out_tail,
-								frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
-done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-
-static void audio_flush(struct audio *audio)
-{
-	audio->out[0].used = 0;
-	audio->out[1].used = 0;
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->reserved = 0;
-	atomic_set(&audio->out_bytes, 0);
-}
-
-static void audio_flush_pcm_buf(struct audio *audio)
-{
-	uint8_t index;
-
-	for (index = 0; index < PCM_BUF_MAX_COUNT; index++)
-		audio->in[index].used = 0;
-	audio->buf_refresh = 0;
-	audio->read_next = 0;
-	audio->fill_next = 0;
-}
-
-static void audio_ioport_reset(struct audio *audio)
-{
-	/* Make sure read/write thread are free from
-	 * sleep and knowing that system is not able
-	 * to process io request at the moment
-	 */
-	wake_up(&audio->write_wait);
-	mutex_lock(&audio->write_lock);
-	audio_flush(audio);
-	mutex_unlock(&audio->write_lock);
-	wake_up(&audio->read_wait);
-	mutex_lock(&audio->read_lock);
-	audio_flush_pcm_buf(audio);
-	mutex_unlock(&audio->read_lock);
-	audio->avsync_flag = 1;
-	wake_up(&audio->avsync_wait);
-}
-
-static int audadpcm_events_pending(struct audio *audio)
-{
-	unsigned long flags;
-	int empty;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	empty = !list_empty(&audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	return empty || audio->event_abort;
-}
-
-static void audadpcm_reset_event_queue(struct audio *audio)
-{
-	unsigned long flags;
-	struct audadpcm_event *drv_evt;
-	struct list_head *ptr, *next;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	list_for_each_safe(ptr, next, &audio->event_queue) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audadpcm_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	list_for_each_safe(ptr, next, &audio->free_event_queue) {
-		drv_evt = list_first_entry(&audio->free_event_queue,
-				struct audadpcm_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	return;
-}
-
-static long audadpcm_process_event_req(struct audio *audio, void __user *arg)
-{
-	long rc;
-	struct msm_audio_event usr_evt;
-	struct audadpcm_event *drv_evt = NULL;
-	int timeout;
-	unsigned long flags;
-
-	if (copy_from_user(&usr_evt, arg, sizeof(struct msm_audio_event)))
-		return -EFAULT;
-
-	timeout = (int) usr_evt.timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(
-			audio->event_wait, audadpcm_events_pending(audio),
-			msecs_to_jiffies(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(
-			audio->event_wait, audadpcm_events_pending(audio));
-	}
-
-	if (rc < 0)
-		return rc;
-
-	if (audio->event_abort) {
-		audio->event_abort = 0;
-		return -ENODEV;
-	}
-
-	rc = 0;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	if (!list_empty(&audio->event_queue)) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audadpcm_event, list);
-		list_del(&drv_evt->list);
-	}
-
-	if (drv_evt) {
-		usr_evt.event_type = drv_evt->event_type;
-		usr_evt.event_payload = drv_evt->payload;
-		list_add_tail(&drv_evt->list, &audio->free_event_queue);
-	} else
-		rc = -1;
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	if (!rc && copy_to_user(arg, &usr_evt, sizeof(usr_evt)))
-		rc = -EFAULT;
-
-	return rc;
-}
-
-static int audio_enable_eq(struct audio *audio, int enable)
-{
-	if (audio->eq_enable == enable && !audio->eq_needs_commit)
-		return 0;
-
-	audio->eq_enable = enable;
-
-	if (audio->running) {
-		audpp_dsp_set_eq(audio->dec_id,	enable, &audio->eq, POPP);
-		audio->eq_needs_commit = 0;
-	}
-	return 0;
-}
-
-static int audio_get_avsync_data(struct audio *audio,
-						struct msm_audio_stats *stats)
-{
-	int rc = -EINVAL;
-	unsigned long flags;
-
-	local_irq_save(flags);
-	if (audio->dec_id == audio->avsync[0] && audio->avsync_flag) {
-		/* av_sync sample count */
-		stats->sample_count = (audio->avsync[2] << 16) |
-						(audio->avsync[3]);
-
-		/* av_sync byte_count */
-		stats->byte_count = (audio->avsync[5] << 16) |
-						(audio->avsync[6]);
-
-		audio->avsync_flag = 0;
-		rc = 0;
-	}
-	local_irq_restore(flags);
-	return rc;
-
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = -EINVAL;
-	unsigned long flags = 0;
-	uint16_t enable_mask;
-	int enable;
-	int prev_state;
-
-	MM_DBG("cmd = %d\n", cmd);
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-
-		audio->avsync_flag = 0;
-		memset(&stats, 0, sizeof(stats));
-		if (audpp_query_avsync(audio->dec_id) < 0)
-			return rc;
-
-		rc = wait_event_interruptible_timeout(audio->avsync_wait,
-				(audio->avsync_flag == 1),
-				msecs_to_jiffies(AUDPP_AVSYNC_EVENT_TIMEOUT));
-
-		if (rc < 0)
-			return rc;
-		else if ((rc > 0) || ((rc == 0) && (audio->avsync_flag == 1))) {
-			if (audio_get_avsync_data(audio, &stats) < 0)
-				return rc;
-
-			if (copy_to_user((void *)arg, &stats, sizeof(stats)))
-				return -EFAULT;
-			return 0;
-		} else
-			return -EAGAIN;
-	}
-
-	switch (cmd) {
-	case AUDIO_ENABLE_AUDPP:
-		if (copy_from_user(&enable_mask, (void *) arg,
-						sizeof(enable_mask))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		enable = (enable_mask & EQ_ENABLE) ? 1 : 0;
-		audio_enable_eq(audio, enable);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-	case AUDIO_SET_VOLUME:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.volume = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_PAN:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.pan = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_EQ:
-		prev_state = audio->eq_enable;
-		audio->eq_enable = 0;
-		if (copy_from_user(&audio->eq.num_bands, (void *) arg,
-				sizeof(audio->eq) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2))) {
-			rc = -EFAULT;
-			break;
-		}
-		audio->eq_enable = prev_state;
-		audio->eq_needs_commit = 1;
-		rc = 0;
-		break;
-	}
-
-	if (-EINVAL != rc)
-		return rc;
-
-	if (cmd == AUDIO_GET_EVENT) {
-		MM_DBG("AUDIO_GET_EVENT\n");
-		if (mutex_trylock(&audio->get_event_lock)) {
-			rc = audadpcm_process_event_req(audio,
-					(void __user *) arg);
-			mutex_unlock(&audio->get_event_lock);
-		} else
-			rc = -EBUSY;
-		return rc;
-	}
-
-	if (cmd == AUDIO_ABORT_GET_EVENT) {
-		audio->event_abort = 1;
-		wake_up(&audio->event_wait);
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		MM_DBG("AUDIO_START\n");
-		rc = audio_enable(audio);
-		if (!rc) {
-			rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-			MM_INFO("dec_state %d rc = %d\n", audio->dec_state, rc);
-
-			if (audio->dec_state != MSM_AUD_DECODER_STATE_SUCCESS)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		break;
-	case AUDIO_STOP:
-		MM_DBG("AUDIO_STOP\n");
-		rc = audio_disable(audio);
-		audio->stopped = 1;
-		audio_ioport_reset(audio);
-		audio->stopped = 0;
-		break;
-	case AUDIO_FLUSH:
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audio_ioport_reset(audio);
-		if (audio->running) {
-			audpp_flush(audio->dec_id);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-	case AUDIO_SET_CONFIG: {
-		struct msm_audio_config config;
-		if (copy_from_user(&config, (void *) arg, sizeof(config))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (config.channel_count == 1) {
-			config.channel_count = AUDPP_CMD_PCM_INTF_MONO_V;
-		} else if (config.channel_count == 2) {
-			config.channel_count = AUDPP_CMD_PCM_INTF_STEREO_V;
-		} else {
-			rc = -EINVAL;
-			break;
-		}
-		audio->mfield = config.meta_field;
-		audio->out_sample_rate = config.sample_rate;
-		audio->out_channel_mode = config.channel_count;
-		audio->out_block_size = config.bits;
-		rc = 0;
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config config;
-		config.buffer_size = (audio->out_dma_sz >> 1);
-		config.buffer_count = 2;
-		config.sample_rate = audio->out_sample_rate;
-		if (audio->out_channel_mode == AUDPP_CMD_PCM_INTF_MONO_V)
-			config.channel_count = 1;
-		else
-			config.channel_count = 2;
-		config.meta_field = 0;
-		config.unused[0] = 0;
-		config.unused[1] = 0;
-		config.unused[2] = 0;
-		if (copy_to_user((void *) arg, &config, sizeof(config)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-
-		break;
-	}
-	case AUDIO_GET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			config.pcm_feedback = audio->pcm_feedback;
-			config.buffer_count = PCM_BUF_MAX_COUNT;
-			config.buffer_size = PCM_BUFSZ_MIN;
-			if (copy_to_user((void *)arg, &config,
-					 sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_SET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			if (copy_from_user
-			    (&config, (void *)arg, sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-			if (config.pcm_feedback != audio->pcm_feedback) {
-				MM_ERR("Not sufficient permission to"
-					 "change the playback mode\n");
-				rc = -EACCES;
-				break;
-			}
-			if ((config.buffer_count > PCM_BUF_MAX_COUNT) ||
-			    (config.buffer_count == 1))
-				config.buffer_count = PCM_BUF_MAX_COUNT;
-
-			if (config.buffer_size < PCM_BUFSZ_MIN)
-				config.buffer_size = PCM_BUFSZ_MIN;
-
-			/* Check if pcm feedback is required */
-			if ((config.pcm_feedback) && (!audio->read_data)) {
-				MM_DBG("allocate PCM buffer %d\n",
-						config.buffer_count *
-						config.buffer_size);
-				audio->read_phys =
-					allocate_contiguous_ebi_nomap(
-							config.buffer_size *
-							config.buffer_count,
-							SZ_4K);
-				if (!audio->read_phys) {
-					rc = -ENOMEM;
-					break;
-				}
-				audio->map_v_read = ioremap(
-							audio->read_phys,
-							config.buffer_size *
-							config.buffer_count);
-				if (IS_ERR(audio->map_v_read)) {
-					MM_ERR("read buf map fail\n");
-					rc = -ENOMEM;
-					free_contiguous_memory_by_paddr(
-							audio->read_phys);
-				} else {
-					uint8_t index;
-					uint32_t offset = 0;
-					audio->read_data =
-						audio->map_v_read;
-					audio->buf_refresh = 0;
-					audio->pcm_buf_count =
-					    config.buffer_count;
-					audio->read_next = 0;
-					audio->fill_next = 0;
-
-					for (index = 0;
-					     index < config.buffer_count;
-					     index++) {
-						audio->in[index].data =
-						    audio->read_data + offset;
-						audio->in[index].addr =
-						    audio->read_phys + offset;
-						audio->in[index].size =
-						    config.buffer_size;
-						audio->in[index].used = 0;
-						offset += config.buffer_size;
-					}
-					MM_DBG("read buf: phy addr \
-						0x%08x kernel addr 0x%08x\n",
-						audio->read_phys,
-						(int)audio->read_data);
-					rc = 0;
-				}
-			} else {
-				rc = 0;
-			}
-			break;
-		}
-	case AUDIO_PAUSE:
-		MM_DBG("AUDIO_PAUSE %ld\n", arg);
-		rc = audpp_pause(audio->dec_id, (int) arg);
-		break;
-	case AUDIO_GET_SESSION_ID:
-		if (copy_to_user((void *) arg, &audio->dec_id,
-					sizeof(unsigned short)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-/* Only useful in tunnel-mode */
-static int audio_fsync(struct file *file, loff_t ppos1, loff_t ppos2, int datasync)
-{
-	struct audio *audio = file->private_data;
-	struct buffer *frame;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	if (!audio->running || audio->pcm_feedback) {
-		rc = -EINVAL;
-		goto done_nolock;
-	}
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(!audio->out[0].used &&
-		!audio->out[1].used &&
-		audio->out_needed) || audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (audio->reserved) {
-		MM_DBG("send reserved byte\n");
-		frame = audio->out + audio->out_tail;
-		((char *) frame->data)[0] = audio->rsv_byte;
-		((char *) frame->data)[1] = 0;
-		frame->used = 2;
-		audplay_send_data(audio, 0);
-
-		rc = wait_event_interruptible(audio->write_wait,
-			(!audio->out[0].used &&
-			!audio->out[1].used &&
-			audio->out_needed) || audio->wflush);
-
-		if (rc < 0)
-			goto done;
-		else if (audio->wflush) {
-			rc = -EBUSY;
-			goto done;
-		}
-	}
-
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		audio->teos || audio->wflush);
-
-	if (audio->wflush)
-		rc = -EBUSY;
-
-done:
-	mutex_unlock(&audio->write_lock);
-done_nolock:
-	return rc;
-}
-
-static ssize_t audio_read(struct file *file, char __user *buf, size_t count,
-			  loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	int rc = 0;
-
-	if (!audio->pcm_feedback)
-		return 0; /* PCM feedback is not enabled. Nothing to read */
-
-	mutex_lock(&audio->read_lock);
-	MM_DBG("%d \n", count);
-	while (count > 0) {
-		rc = wait_event_interruptible(audio->read_wait,
-			(audio->in[audio->read_next].used > 0) ||
-			(audio->stopped) || (audio->rflush));
-
-		if (rc < 0)
-			break;
-
-		if (audio->stopped || audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (count < audio->in[audio->read_next].used) {
-			/* Read must happen in frame boundary. Since driver
-			   does not know frame size, read count must be greater
-			   or equal to size of PCM samples */
-			MM_DBG("audio_read: no partial frame done reading\n");
-			break;
-		} else {
-			MM_DBG("audio_read: read from in[%d]\n",
-					audio->read_next);
-			if (copy_to_user
-			    (buf, audio->in[audio->read_next].data,
-			     audio->in[audio->read_next].used)) {
-				MM_ERR("invalid addr %x \n", (unsigned int)buf);
-				rc = -EFAULT;
-				break;
-			}
-			count -= audio->in[audio->read_next].used;
-			buf += audio->in[audio->read_next].used;
-			audio->in[audio->read_next].used = 0;
-			if ((++audio->read_next) == audio->pcm_buf_count)
-				audio->read_next = 0;
-			break;	/* Force to exit while loop
-				 * to prevent output thread
-				 * sleep too long if data is
-				 * not ready at this moment.
-				 */
-		}
-	}
-
-	/* don't feed output buffer to HW decoder during flushing
-	 * buffer refresh command will be sent once flush completes
-	 * send buf refresh command here can confuse HW decoder
-	 */
-	if (audio->buf_refresh && !audio->rflush) {
-		audio->buf_refresh = 0;
-		MM_DBG("kick start pcm feedback again\n");
-		audplay_buffer_refresh(audio);
-	}
-
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		rc = buf - start;
-
-	MM_DBG("read %d bytes\n", rc);
-	return rc;
-}
-
-static int audadpcm_process_eos(struct audio *audio,
-		const char __user *buf_start, unsigned short mfield_size)
-{
-	int rc = 0;
-	struct buffer *frame;
-	char *buf_ptr;
-
-	if (audio->reserved) {
-		MM_DBG("flush reserve byte\n");
-		frame = audio->out + audio->out_head;
-		buf_ptr = frame->data;
-		rc = wait_event_interruptible(audio->write_wait,
-				(frame->used == 0)
-				|| (audio->stopped)
-				|| (audio->wflush));
-		if (rc < 0)
-			goto done;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			goto done;
-		}
-
-		buf_ptr[0] = audio->rsv_byte;
-		buf_ptr[1] = 0;
-		audio->out_head ^= 1;
-		frame->mfield_sz = 0;
-		frame->used = 2;
-		audio->reserved = 0;
-		audplay_send_data(audio, 0);
-	}
-
-	frame = audio->out + audio->out_head;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	audplay_send_data(audio, 0);
-done:
-	return rc;
-}
-
-static ssize_t audio_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	size_t xfer;
-	char *cpy_ptr;
-	int rc = 0, eos_condition = AUDADPCM_EOS_NONE;
-	unsigned dsize;
-	unsigned short mfield_size = 0;
-
-	MM_DBG("cnt=%d\n", count);
-
-	mutex_lock(&audio->write_lock);
-	while (count > 0) {
-		frame = audio->out + audio->out_head;
-		cpy_ptr = frame->data;
-		dsize = 0;
-		rc = wait_event_interruptible(audio->write_wait,
-					      (frame->used == 0)
-					      || (audio->stopped)
-						  || (audio->wflush));
-		if (rc < 0)
-			break;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			break;
-		}
-		if (audio->mfield) {
-			if (buf == start) {
-				/* Processing beginning of user buffer */
-				if (__get_user(mfield_size,
-					(unsigned short __user *) buf)) {
-					rc = -EFAULT;
-					break;
-				} else  if (mfield_size > count) {
-					rc = -EINVAL;
-					break;
-				}
-				MM_DBG("audio_write: mf offset_val %x\n",
-						mfield_size);
-				if (copy_from_user(cpy_ptr, buf, mfield_size)) {
-					rc = -EFAULT;
-					break;
-				}
-				/* Check if EOS flag is set and buffer has
-				 * contains just meta field
-				 */
-				if (cpy_ptr[AUDADPCM_EOS_FLG_OFFSET] &
-						 AUDADPCM_EOS_FLG_MASK) {
-					MM_DBG("audio_write: EOS SET\n");
-					eos_condition = AUDADPCM_EOS_SET;
-					if (mfield_size == count) {
-						buf += mfield_size;
-						break;
-					} else
-					cpy_ptr[AUDADPCM_EOS_FLG_OFFSET]
-						&= ~AUDADPCM_EOS_FLG_MASK;
-				}
-				cpy_ptr += mfield_size;
-				count -= mfield_size;
-				dsize += mfield_size;
-				buf += mfield_size;
-			} else {
-				mfield_size = 0;
-				MM_DBG("audio_write: continuous buffer\n");
-			}
-			frame->mfield_sz = mfield_size;
-		}
-
-		if (audio->reserved) {
-			MM_DBG("append reserved byte %x\n", audio->rsv_byte);
-			*cpy_ptr = audio->rsv_byte;
-			xfer = (count > ((frame->size - mfield_size) - 1)) ?
-				(frame->size - mfield_size) - 1 : count;
-			cpy_ptr++;
-			dsize += 1;
-			audio->reserved = 0;
-		} else
-			xfer = (count > (frame->size - mfield_size)) ?
-				(frame->size - mfield_size) : count;
-
-		if (copy_from_user(cpy_ptr, buf, xfer)) {
-			rc = -EFAULT;
-			break;
-		}
-
-		dsize += xfer;
-		if (dsize & 1) {
-			audio->rsv_byte = ((char *) frame->data)[dsize - 1];
-			MM_DBG("odd length buf reserve last byte %x\n",
-					audio->rsv_byte);
-			audio->reserved = 1;
-			dsize--;
-		}
-		count -= xfer;
-		buf += xfer;
-
-		if (dsize > 0) {
-			audio->out_head ^= 1;
-			frame->used = dsize;
-			audplay_send_data(audio, 0);
-		}
-	}
-	if (eos_condition == AUDADPCM_EOS_SET)
-		rc = audadpcm_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	if (!rc) {
-		if (buf > start)
-			return buf - start;
-	}
-	return rc;
-}
-
-static int audio_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	MM_INFO("audio instance 0x%08x freeing\n", (int)audio);
-
-	mutex_lock(&audio->lock);
-	auddev_unregister_evt_listner(AUDDEV_CLNT_DEC, audio->dec_id);
-	audio_disable(audio);
-	audio_flush(audio);
-	audio_flush_pcm_buf(audio);
-	msm_adsp_put(audio->audplay);
-	audpp_adec_free(audio->dec_id);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	unregister_early_suspend(&audio->suspend_ctl.node);
-#endif
-	audio->event_abort = 1;
-	wake_up(&audio->event_wait);
-	audadpcm_reset_event_queue(audio);
-	iounmap(audio->map_v_write);
-	free_contiguous_memory_by_paddr(audio->phys);
-	if (audio->read_data) {
-		iounmap(audio->map_v_read);
-		free_contiguous_memory_by_paddr(audio->read_phys);
-	}
-	mutex_unlock(&audio->lock);
-#ifdef CONFIG_DEBUG_FS
-	if (audio->dentry)
-		debugfs_remove(audio->dentry);
-#endif
-	kfree(audio);
-	return 0;
-}
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audadpcm_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload)
-{
-	struct audadpcm_event *e_node = NULL;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-
-	if (!list_empty(&audio->free_event_queue)) {
-		e_node = list_first_entry(&audio->free_event_queue,
-				struct audadpcm_event, list);
-		list_del(&e_node->list);
-	} else {
-		e_node = kmalloc(sizeof(struct audadpcm_event), GFP_ATOMIC);
-		if (!e_node) {
-			MM_ERR("No mem to post event %d\n", type);
-			return;
-		}
-	}
-
-	e_node->event_type = type;
-	e_node->payload = payload;
-
-	list_add_tail(&e_node->list, &audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	wake_up(&audio->event_wait);
-}
-
-static void audadpcm_suspend(struct early_suspend *h)
-{
-	struct audadpcm_suspend_ctl *ctl =
-		container_of(h, struct audadpcm_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audadpcm_post_event(ctl->audio, AUDIO_EVENT_SUSPEND, payload);
-}
-
-static void audadpcm_resume(struct early_suspend *h)
-{
-	struct audadpcm_suspend_ctl *ctl =
-		container_of(h, struct audadpcm_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audadpcm_post_event(ctl->audio, AUDIO_EVENT_RESUME, payload);
-}
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-static ssize_t audadpcm_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static ssize_t audadpcm_debug_read(struct file *file, char __user *buf,
-			  size_t count, loff_t *ppos)
-{
-	const int debug_bufmax = 4096;
-	static char buffer[4096];
-	int n = 0, i;
-	struct audio *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	n = scnprintf(buffer, debug_bufmax, "opened %d\n", audio->opened);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "enabled %d\n", audio->enabled);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "stopped %d\n", audio->stopped);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "pcm_feedback %d\n", audio->pcm_feedback);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_buf_sz %d\n", audio->out[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "pcm_buf_count %d \n", audio->pcm_buf_count);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "pcm_buf_sz %d \n", audio->in[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "volume %x \n", audio->vol_pan.volume);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "sample rate %d \n", audio->out_sample_rate);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-		"channel mode %d \n", audio->out_channel_mode);
-	mutex_unlock(&audio->lock);
-	/* Following variables are only useful for debugging when
-	 * when playback halts unexpectedly. Thus, no mutual exclusion
-	 * enforced
-	 */
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "wflush %d\n", audio->wflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "rflush %d\n", audio->rflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "running %d \n", audio->running);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"dec state %d \n", audio->dec_state);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_needed %d \n", audio->out_needed);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_head %d \n", audio->out_head);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_tail %d \n", audio->out_tail);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out[0].used %d \n", audio->out[0].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out[1].used %d \n", audio->out[1].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "buffer_refresh %d \n", audio->buf_refresh);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "read_next %d \n", audio->read_next);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "fill_next %d \n", audio->fill_next);
-	for (i = 0; i < audio->pcm_buf_count; i++)
-		n += scnprintf(buffer + n, debug_bufmax - n,
-			"in[%d].size %d \n", i, audio->in[i].used);
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations audadpcm_debug_fops = {
-	.read = audadpcm_debug_read,
-	.open = audadpcm_debug_open,
-};
-#endif
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = NULL;
-	int rc, dec_attrb, decid, i;
-	unsigned pmem_sz = DMASZ_MAX;
-	struct audadpcm_event *e_node = NULL;
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_adpcm_" + 5];
-#endif
-
-	/* Allocate Mem for audio instance */
-	audio = kzalloc(sizeof(struct audio), GFP_KERNEL);
-	if (!audio) {
-		MM_ERR("no memory to allocate audio instance \n");
-		rc = -ENOMEM;
-		goto done;
-	}
-	MM_INFO("audio instance 0x%08x created\n", (int)audio);
-
-	/* Allocate the decoder */
-	dec_attrb = AUDDEC_DEC_ADPCM;
-	if ((file->f_mode & FMODE_WRITE) &&
-			(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_NONTUNNEL;
-		audio->pcm_feedback = NON_TUNNEL_MODE_PLAYBACK;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_TUNNEL;
-		audio->pcm_feedback = TUNNEL_MODE_PLAYBACK;
-	} else {
-		kfree(audio);
-		rc = -EACCES;
-		goto done;
-	}
-
-	decid = audpp_adec_alloc(dec_attrb, &audio->module_name,
-			&audio->queue_id);
-
-	if (decid < 0) {
-		MM_ERR("No free decoder available, freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENODEV;
-		kfree(audio);
-		goto done;
-	}
-	audio->dec_id = decid & MSM_AUD_DECODER_MASK;
-
-	while (pmem_sz >= DMASZ_MIN) {
-		MM_DBG("pmemsz = %d\n", pmem_sz);
-		audio->phys = allocate_contiguous_ebi_nomap(pmem_sz,
-									SZ_4K);
-		if (audio->phys) {
-			audio->map_v_write = ioremap(audio->phys, pmem_sz);
-			if (IS_ERR(audio->map_v_write)) {
-				MM_ERR("could not map write phys address, \
-						freeing instance 0x%08x\n",
-						(int)audio);
-				rc = -ENOMEM;
-				free_contiguous_memory_by_paddr(audio->phys);
-				audpp_adec_free(audio->dec_id);
-				kfree(audio);
-				goto done;
-			}
-			audio->data = audio->map_v_write;
-			MM_DBG("write buf: phy addr 0x%08x kernel addr \
-				0x%08x\n", audio->phys, (int)audio->data);
-			break;
-		} else if (pmem_sz == DMASZ_MIN) {
-			MM_ERR("could not allocate write buffers, freeing \
-					instance 0x%08x\n", (int)audio);
-			rc = -ENOMEM;
-			audpp_adec_free(audio->dec_id);
-			kfree(audio);
-			goto done;
-		} else
-		pmem_sz >>= 1;
-	}
-	audio->out_dma_sz = pmem_sz;
-
-	rc = msm_adsp_get(audio->module_name, &audio->audplay,
-			&audplay_adsp_ops_adpcm, audio);
-	if (rc) {
-		MM_ERR("failed to get %s module, freeing instance 0x%08x\n",
-				audio->module_name, (int)audio);
-		goto err;
-	}
-
-	mutex_init(&audio->lock);
-	mutex_init(&audio->write_lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->get_event_lock);
-	spin_lock_init(&audio->dsp_lock);
-	init_waitqueue_head(&audio->write_wait);
-	init_waitqueue_head(&audio->read_wait);
-	INIT_LIST_HEAD(&audio->free_event_queue);
-	INIT_LIST_HEAD(&audio->event_queue);
-	init_waitqueue_head(&audio->wait);
-	init_waitqueue_head(&audio->event_wait);
-	spin_lock_init(&audio->event_queue_lock);
-	init_waitqueue_head(&audio->avsync_wait);
-
-	audio->out[0].data = audio->data + 0;
-	audio->out[0].addr = audio->phys + 0;
-	audio->out[0].size = audio->out_dma_sz >> 1;
-
-	audio->out[1].data = audio->data + audio->out[0].size;
-	audio->out[1].addr = audio->phys + audio->out[0].size;
-	audio->out[1].size = audio->out[0].size;
-
-	audio->out_sample_rate = 44100;
-	audio->out_channel_mode = AUDPP_CMD_PCM_INTF_STEREO_V;
-
-	audio->vol_pan.volume = 0x2000;
-
-	audio_flush(audio);
-
-	file->private_data = audio;
-	audio->opened = 1;
-
-	audio->device_events = AUDDEV_EVT_DEV_RDY
-				|AUDDEV_EVT_DEV_RLS|
-				AUDDEV_EVT_STREAM_VOL_CHG;
-
-	rc = auddev_register_evt_listner(audio->device_events,
-					AUDDEV_CLNT_DEC,
-					audio->dec_id,
-					adpcm_listner,
-					(void *)audio);
-	if (rc) {
-		MM_ERR("%s: failed to register listner\n", __func__);
-		goto event_err;
-	}
-
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof name, "msm_adpcm_%04x", audio->dec_id);
-	audio->dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
-				NULL, (void *) audio,
-				&audadpcm_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		MM_DBG("debugfs_create_file failed\n");
-#endif
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	audio->suspend_ctl.node.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
-	audio->suspend_ctl.node.resume = audadpcm_resume;
-	audio->suspend_ctl.node.suspend = audadpcm_suspend;
-	audio->suspend_ctl.audio = audio;
-	register_early_suspend(&audio->suspend_ctl.node);
-#endif
-	for (i = 0; i < AUDADPCM_EVENT_NUM; i++) {
-		e_node = kmalloc(sizeof(struct audadpcm_event), GFP_KERNEL);
-		if (e_node)
-			list_add_tail(&e_node->list, &audio->free_event_queue);
-		else {
-			MM_ERR("event pkt alloc failed\n");
-			break;
-		}
-	}
-done:
-	return rc;
-event_err:
-	msm_adsp_put(audio->audplay);
-err:
-	iounmap(audio->map_v_write);
-	free_contiguous_memory_by_paddr(audio->phys);
-	audpp_adec_free(audio->dec_id);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_adpcm_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audio_open,
-	.release	= audio_release,
-	.read 		= audio_read,
-	.write		= audio_write,
-	.unlocked_ioctl	= audio_ioctl,
-	.fsync 		= audio_fsync,
-};
-
-struct miscdevice audio_adpcm_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_adpcm",
-	.fops	= &audio_adpcm_fops,
-};
-
-static int __init audio_init(void)
-{
-	return misc_register(&audio_adpcm_misc);
-}
-
-device_initcall(audio_init);
diff --git a/arch/arm/mach-msm/qdsp5v2/audio_amrnb.c b/arch/arm/mach-msm/qdsp5v2/audio_amrnb.c
deleted file mode 100644
index bd4f6e1..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audio_amrnb.c
+++ /dev/null
@@ -1,1644 +0,0 @@
-/*
- * amrnb audio decoder device
- *
- * Copyright (c) 2008-2012, The Linux Foundation. All rights reserved.
- *
- * Based on the mp3 native driver in arch/arm/mach-msm/qdsp5/audio_mp3.c
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- *
- * All source code in this file is licensed under the following license except
- * where indicated.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you can find it at http://www.fsf.org
- */
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/list.h>
-#include <linux/earlysuspend.h>
-#include <linux/memory_alloc.h>
-#include <linux/msm_audio.h>
-#include <linux/slab.h>
-#include <mach/msm_adsp.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/qdsp5v2/qdsp5audppmsg.h>
-#include <mach/qdsp5v2/qdsp5audplaycmdi.h>
-#include <mach/qdsp5v2/qdsp5audplaymsg.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/qdsp5v2/audpp.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_memtypes.h>
-
-#define BUFSZ 1024 /* Hold minimum 700ms voice data and 14 bytes of meta in*/
-#define DMASZ (BUFSZ * 2)
-
-#define AUDPLAY_INVALID_READ_PTR_OFFSET	0xFFFF
-#define AUDDEC_DEC_AMRNB 10
-
-#define PCM_BUFSZ_MIN 1624 /* 100ms worth of data and 24 bytes of meta out*/
-#define AMRNB_DECODED_FRSZ 320 /* AMR-NB 20ms 8KHz mono PCM size */
-#define PCM_BUF_MAX_COUNT 5	/* DSP only accepts 5 buffers at most
-				   but support 2 buffers currently */
-#define ROUTING_MODE_FTRT 1
-#define ROUTING_MODE_RT 2
-/* Decoder status received from AUDPPTASK */
-#define  AUDPP_DEC_STATUS_SLEEP	0
-#define	 AUDPP_DEC_STATUS_INIT  1
-#define  AUDPP_DEC_STATUS_CFG   2
-#define  AUDPP_DEC_STATUS_PLAY  3
-
-#define AUDAMRNB_METAFIELD_MASK 0xFFFF0000
-#define AUDAMRNB_EOS_FLG_OFFSET 0x0A /* Offset from beginning of buffer */
-#define AUDAMRNB_EOS_FLG_MASK 0x01
-#define AUDAMRNB_EOS_NONE 0x0 /* No EOS detected */
-#define AUDAMRNB_EOS_SET 0x1 /* EOS set in meta field */
-
-#define AUDAMRNB_EVENT_NUM 10 /* Default number of pre-allocated event pkts */
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;		/* Input usage actual DSP produced PCM size  */
-	unsigned addr;
-	unsigned short mfield_sz; /*only useful for data has meta field */
-};
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-struct audamrnb_suspend_ctl {
-	struct early_suspend node;
-	struct audio *audio;
-};
-#endif
-
-struct audamrnb_event{
-	struct list_head list;
-	int event_type;
-	union msm_audio_event_payload payload;
-};
-
-struct audio {
-	struct buffer out[2];
-
-	spinlock_t dsp_lock;
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed;	/* number of buffers the dsp is waiting for */
-
-	atomic_t out_bytes;
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-
-	/* Host PCM section */
-	struct buffer in[PCM_BUF_MAX_COUNT];
-	struct mutex read_lock;
-	wait_queue_head_t read_wait;	/* Wait queue for read */
-	char *read_data;	/* pointer to reader buffer */
-	int32_t read_phys;	/* physical address of reader buffer */
-	uint8_t read_next;	/* index to input buffers to be read next */
-	uint8_t fill_next;	/* index to buffer that DSP should be filling */
-	uint8_t pcm_buf_count;	/* number of pcm buffer allocated */
-	/* ---- End of Host PCM section */
-
-	struct msm_adsp_module *audplay;
-
-	/* data allocated for various buffers */
-	char *data;
-	int32_t phys; /* physical address of write buffer */
-	void *map_v_read;
-	void *map_v_write;
-
-	int mfield; /* meta field embedded in data */
-	int rflush; /* Read  flush */
-	int wflush; /* Write flush */
-	uint8_t opened:1;
-	uint8_t enabled:1;
-	uint8_t running:1;
-	uint8_t stopped:1;	/* set when stopped, cleared on flush */
-	uint8_t pcm_feedback:1;
-	uint8_t buf_refresh:1;
-	int teos; /* valid only if tunnel mode & no data left for decoder */
-	enum msm_aud_decoder_state dec_state;	/* Represents decoder state */
-
-	const char *module_name;
-	unsigned queue_id;
-	uint16_t dec_id;
-	uint32_t read_ptr_offset;
-	int16_t source;
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	struct audamrnb_suspend_ctl suspend_ctl;
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *dentry;
-#endif
-
-	wait_queue_head_t wait;
-	struct list_head free_event_queue;
-	struct list_head event_queue;
-	wait_queue_head_t event_wait;
-	spinlock_t event_queue_lock;
-	struct mutex get_event_lock;
-	int event_abort;
-	/* AV sync Info */
-	int avsync_flag;              /* Flag to indicate feedback from DSP */
-	wait_queue_head_t avsync_wait;/* Wait queue for AV Sync Message     */
-	/* flags, 48 bits sample/bytes counter per channel */
-	uint16_t avsync[AUDPP_AVSYNC_CH_COUNT * AUDPP_AVSYNC_NUM_WORDS + 1];
-
-	uint32_t device_events;
-
-	int eq_enable;
-	int eq_needs_commit;
-	struct audpp_cmd_cfg_object_params_eqalizer eq;
-	struct audpp_cmd_cfg_object_params_volume vol_pan;
-};
-
-struct audpp_cmd_cfg_adec_params_amrnb {
-   struct audpp_cmd_cfg_adec_params_common  common;
-   unsigned short                       stereo_cfg;
-} __attribute__((packed)) ;
-
-static int auddec_dsp_config(struct audio *audio, int enable);
-static void audpp_cmd_cfg_adec_params(struct audio *audio);
-static void audpp_cmd_cfg_routing_mode(struct audio *audio);
-static void audamrnb_send_data(struct audio *audio, unsigned needed);
-static void audamrnb_config_hostpcm(struct audio *audio);
-static void audamrnb_buffer_refresh(struct audio *audio);
-static void audamrnb_dsp_event(void *private, unsigned id, uint16_t *msg);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audamrnb_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload);
-#endif
-
-/* must be called with audio->lock held */
-static int audamrnb_enable(struct audio *audio)
-{
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled)
-		return 0;
-
-	audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-
-	if (msm_adsp_enable(audio->audplay)) {
-		MM_ERR("msm_adsp_enable(audplay) failed\n");
-		return -ENODEV;
-	}
-
-	if (audpp_enable(audio->dec_id, audamrnb_dsp_event, audio)) {
-		MM_ERR("audpp_enable() failed\n");
-		msm_adsp_disable(audio->audplay);
-		return -ENODEV;
-	}
-	audio->enabled = 1;
-	return 0;
-}
-
-static void amrnb_listner(u32 evt_id, union auddev_evt_data *evt_payload,
-			void *private_data)
-{
-	struct audio *audio = (struct audio *) private_data;
-	switch (evt_id) {
-	case AUDDEV_EVT_DEV_RDY:
-		MM_DBG(":AUDDEV_EVT_DEV_RDY\n");
-		audio->source |= (0x1 << evt_payload->routing_id);
-		if (audio->running == 1 && audio->enabled == 1)
-			audpp_route_stream(audio->dec_id, audio->source);
-		break;
-	case AUDDEV_EVT_DEV_RLS:
-		MM_DBG(":AUDDEV_EVT_DEV_RLS\n");
-		audio->source &= ~(0x1 << evt_payload->routing_id);
-		if (audio->running == 1 && audio->enabled == 1)
-			audpp_route_stream(audio->dec_id, audio->source);
-		break;
-	case AUDDEV_EVT_STREAM_VOL_CHG:
-		audio->vol_pan.volume = evt_payload->session_vol;
-		MM_DBG(":AUDDEV_EVT_STREAM_VOL_CHG, stream vol %d\n",
-				audio->vol_pan.volume);
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		break;
-	default:
-		MM_ERR(":ERROR:wrong event\n");
-		break;
-	}
-}
-/* must be called with audio->lock held */
-static int audamrnb_disable(struct audio *audio)
-{
-	int rc = 0;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-		auddec_dsp_config(audio, 0);
-		rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-		if (rc == 0)
-			rc = -ETIMEDOUT;
-		else if (audio->dec_state != MSM_AUD_DECODER_STATE_CLOSE)
-			rc = -EFAULT;
-		else
-			rc = 0;
-		wake_up(&audio->write_wait);
-		wake_up(&audio->read_wait);
-		msm_adsp_disable(audio->audplay);
-		audpp_disable(audio->dec_id, audio);
-		audio->out_needed = 0;
-	}
-	return rc;
-}
-
-/* ------------------- dsp --------------------- */
-static void audamrnb_update_pcm_buf_entry(struct audio *audio,
-		uint32_t *payload)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	if (audio->rflush)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < payload[1]; index++) {
-		if (audio->in[audio->fill_next].addr ==
-		    payload[2 + index * 2]) {
-			MM_DBG("in[%d] ready\n", audio->fill_next);
-			audio->in[audio->fill_next].used =
-			    payload[3 + index * 2];
-			if ((++audio->fill_next) == audio->pcm_buf_count)
-				audio->fill_next = 0;
-
-		} else {
-			MM_ERR("expected=%x ret=%x\n",
-				audio->in[audio->fill_next].addr,
-				payload[1 + index * 2]);
-			break;
-		}
-	}
-	if (audio->in[audio->fill_next].used == 0) {
-		audamrnb_buffer_refresh(audio);
-	} else {
-		MM_DBG("read cannot keep up\n");
-		audio->buf_refresh = 1;
-	}
-	wake_up(&audio->read_wait);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audplay_dsp_event(void *data, unsigned id, size_t len,
-			      void (*getevent) (void *ptr, size_t len))
-{
-	struct audio *audio = data;
-	uint32_t msg[28];
-	getevent(msg, sizeof(msg));
-
-	MM_DBG("msg_id=%x\n", id);
-
-	switch (id) {
-	case AUDPLAY_MSG_DEC_NEEDS_DATA:
-		audamrnb_send_data(audio, 1);
-		break;
-
-	case AUDPLAY_MSG_BUFFER_UPDATE:
-		audamrnb_update_pcm_buf_entry(audio, msg);
-		break;
-
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audplaytask)\n");
-		break;
-
-	default:
-		MM_ERR("unexpected message from decoder\n");
-	}
-}
-
-static void audamrnb_dsp_event(void *private, unsigned id, uint16_t *msg)
-{
-	struct audio *audio = private;
-
-	switch (id) {
-	case AUDPP_MSG_STATUS_MSG:{
-			unsigned status = msg[1];
-
-			switch (status) {
-			case AUDPP_DEC_STATUS_SLEEP: {
-				uint16_t reason = msg[2];
-				MM_DBG("decoder status:sleep reason = \
-						0x%04x\n", reason);
-				if ((reason == AUDPP_MSG_REASON_MEM)
-					|| (reason ==
-					AUDPP_MSG_REASON_NODECODER)) {
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_FAILURE;
-					wake_up(&audio->wait);
-				} else if (reason == AUDPP_MSG_REASON_NONE) {
-					/* decoder is in disable state */
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_CLOSE;
-					wake_up(&audio->wait);
-				}
-				break;
-			}
-			case AUDPP_DEC_STATUS_INIT:
-				MM_DBG("decoder status: init \n");
-				if (audio->pcm_feedback)
-					audpp_cmd_cfg_routing_mode(audio);
-				else
-					audpp_cmd_cfg_adec_params(audio);
-				break;
-
-			case AUDPP_DEC_STATUS_CFG:
-				MM_DBG("decoder status: cfg \n");
-				break;
-			case AUDPP_DEC_STATUS_PLAY:
-				MM_DBG("decoder status: play \n");
-				/* send  mixer command */
-				audpp_route_stream(audio->dec_id,
-						audio->source);
-				if (audio->pcm_feedback) {
-					audamrnb_config_hostpcm(audio);
-					audamrnb_buffer_refresh(audio);
-				}
-				audio->dec_state =
-					MSM_AUD_DECODER_STATE_SUCCESS;
-				wake_up(&audio->wait);
-				break;
-			default:
-				MM_ERR("unknown decoder status \n");
-				break;
-			}
-			break;
-		}
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_DBG("CFG_MSG ENABLE\n");
-			auddec_dsp_config(audio, 1);
-			audio->out_needed = 0;
-			audio->running = 1;
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-			audpp_dsp_set_eq(audio->dec_id, audio->eq_enable,
-					&audio->eq, POPP);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			MM_DBG("CFG_MSG DISABLE\n");
-			audio->running = 0;
-		} else {
-			MM_DBG("CFG_MSG %d?\n", msg[0]);
-		}
-		break;
-	case AUDPP_MSG_ROUTING_ACK:
-		MM_DBG("ROUTING_ACK mode=%d\n", msg[1]);
-		audpp_cmd_cfg_adec_params(audio);
-		break;
-	case AUDPP_MSG_FLUSH_ACK:
-		MM_DBG("FLUSH_ACK\n");
-		audio->wflush = 0;
-		audio->rflush = 0;
-		wake_up(&audio->write_wait);
-		if (audio->pcm_feedback)
-			audamrnb_buffer_refresh(audio);
-		break;
-	case AUDPP_MSG_PCMDMAMISSED:
-		MM_DBG("PCMDMAMISSED\n");
-		audio->teos = 1;
-		wake_up(&audio->write_wait);
-		break;
-
-	case AUDPP_MSG_AVSYNC_MSG:
-		MM_DBG("AUDPP_MSG_AVSYNC_MSG\n");
-		memcpy(&audio->avsync[0], msg, sizeof(audio->avsync));
-		audio->avsync_flag = 1;
-		wake_up(&audio->avsync_wait);
-		break;
-
-	default:
-		MM_ERR("UNKNOWN (%d)\n", id);
-	}
-
-}
-
-struct msm_adsp_ops audplay_adsp_ops_amrnb = {
-	.event = audplay_dsp_event,
-};
-
-#define audplay_send_queue0(audio, cmd, len) \
-	msm_adsp_write(audio->audplay, audio->queue_id, \
-			cmd, len)
-
-static int auddec_dsp_config(struct audio *audio, int enable)
-{
-	struct audpp_cmd_cfg_dec_type cfg_dec_cmd;
-
-	memset(&cfg_dec_cmd, 0, sizeof(cfg_dec_cmd));
-
-	cfg_dec_cmd.cmd_id = AUDPP_CMD_CFG_DEC_TYPE;
-	if (enable)
-		cfg_dec_cmd.dec_cfg = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_ENA_DEC_V | AUDDEC_DEC_AMRNB;
-	else
-		cfg_dec_cmd.dec_cfg = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_DIS_DEC_V;
-	cfg_dec_cmd.dm_mode = 0x0;
-	cfg_dec_cmd.stream_id = audio->dec_id;
-
-	return audpp_send_queue1(&cfg_dec_cmd, sizeof(cfg_dec_cmd));
-}
-
-static void audpp_cmd_cfg_adec_params(struct audio *audio)
-{
-	struct audpp_cmd_cfg_adec_params_amrnb cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_CMD_CFG_ADEC_PARAMS;
-	cmd.common.length = AUDPP_CMD_CFG_ADEC_PARAMS_V13K_LEN;
-	cmd.common.dec_id = audio->dec_id;
-	cmd.common.input_sampling_frequency = 8000;
-	cmd.stereo_cfg = AUDPP_CMD_PCM_INTF_MONO_V;
-
-	audpp_send_queue2(&cmd, sizeof(cmd));
-}
-
-static void audpp_cmd_cfg_routing_mode(struct audio *audio)
-{
-	struct audpp_cmd_routing_mode cmd;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPP_CMD_ROUTING_MODE;
-	cmd.object_number = audio->dec_id;
-	if (audio->pcm_feedback)
-		cmd.routing_mode = ROUTING_MODE_FTRT;
-	else
-		cmd.routing_mode = ROUTING_MODE_RT;
-
-	audpp_send_queue1(&cmd, sizeof(cmd));
-}
-
-static int audplay_dsp_send_data_avail(struct audio *audio,
-				       unsigned idx, unsigned len)
-{
-	struct audplay_cmd_bitstream_data_avail_nt2 cmd;
-
-	cmd.cmd_id = AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2;
-	if (audio->mfield)
-		cmd.decoder_id = AUDAMRNB_METAFIELD_MASK |
-			(audio->out[idx].mfield_sz >> 1);
-	else
-		cmd.decoder_id = audio->dec_id;
-	cmd.buf_ptr = audio->out[idx].addr;
-	cmd.buf_size = len / 2;
-	cmd.partition_number = 0;
-	return audplay_send_queue0(audio, &cmd, sizeof(cmd));
-}
-
-static void audamrnb_buffer_refresh(struct audio *audio)
-{
-	struct audplay_cmd_buffer_refresh refresh_cmd;
-
-	refresh_cmd.cmd_id = AUDPLAY_CMD_BUFFER_REFRESH;
-	refresh_cmd.num_buffers = 1;
-	refresh_cmd.buf0_address = audio->in[audio->fill_next].addr;
-	refresh_cmd.buf0_length = audio->in[audio->fill_next].size -
-	  (audio->in[audio->fill_next].size % AMRNB_DECODED_FRSZ) +
-	  (audio->mfield ? 24 : 0);
-	refresh_cmd.buf_read_count = 0;
-	MM_DBG("buf0_addr=%x buf0_len=%d\n", refresh_cmd.buf0_address,
-			refresh_cmd.buf0_length);
-	(void)audplay_send_queue0(audio, &refresh_cmd, sizeof(refresh_cmd));
-}
-
-static void audamrnb_config_hostpcm(struct audio *audio)
-{
-	struct audplay_cmd_hpcm_buf_cfg cfg_cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	cfg_cmd.cmd_id = AUDPLAY_CMD_HPCM_BUF_CFG;
-	cfg_cmd.max_buffers = audio->pcm_buf_count;
-	cfg_cmd.byte_swap = 0;
-	cfg_cmd.hostpcm_config = (0x8000) | (0x4000);
-	cfg_cmd.feedback_frequency = 1;
-	cfg_cmd.partition_number = 0;
-	(void)audplay_send_queue0(audio, &cfg_cmd, sizeof(cfg_cmd));
-
-}
-
-static void audamrnb_send_data(struct audio *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			MM_DBG("frame %d busy\n", audio->out_tail);
-			audplay_dsp_send_data_avail(audio, audio->out_tail,
-						    frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
- done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-
-static void audamrnb_flush(struct audio *audio)
-{
-	audio->out[0].used = 0;
-	audio->out[1].used = 0;
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-	atomic_set(&audio->out_bytes, 0);
-}
-
-static void audamrnb_flush_pcm_buf(struct audio *audio)
-{
-	uint8_t index;
-
-	for (index = 0; index < PCM_BUF_MAX_COUNT; index++)
-		audio->in[index].used = 0;
-
-	audio->buf_refresh = 0;
-	audio->read_next = 0;
-	audio->fill_next = 0;
-}
-
-static void audamrnb_ioport_reset(struct audio *audio)
-{
-	/* Make sure read/write thread are free from
-	 * sleep and knowing that system is not able
-	 * to process io request at the moment
-	 */
-	wake_up(&audio->write_wait);
-	mutex_lock(&audio->write_lock);
-	audamrnb_flush(audio);
-	mutex_unlock(&audio->write_lock);
-	wake_up(&audio->read_wait);
-	mutex_lock(&audio->read_lock);
-	audamrnb_flush_pcm_buf(audio);
-	mutex_unlock(&audio->read_lock);
-	audio->avsync_flag = 1;
-	wake_up(&audio->avsync_wait);
-}
-
-static int audamrnb_events_pending(struct audio *audio)
-{
-	unsigned long flags;
-	int empty;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	empty = !list_empty(&audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	return empty || audio->event_abort;
-}
-
-static void audamrnb_reset_event_queue(struct audio *audio)
-{
-	unsigned long flags;
-	struct audamrnb_event *drv_evt;
-	struct list_head *ptr, *next;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	list_for_each_safe(ptr, next, &audio->event_queue) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audamrnb_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	list_for_each_safe(ptr, next, &audio->free_event_queue) {
-		drv_evt = list_first_entry(&audio->free_event_queue,
-				struct audamrnb_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	return;
-}
-
-static long audamrnb_process_event_req(struct audio *audio, void __user *arg)
-{
-	long rc;
-	struct msm_audio_event usr_evt;
-	struct audamrnb_event *drv_evt = NULL;
-	int timeout;
-	unsigned long flags;
-
-	if (copy_from_user(&usr_evt, arg, sizeof(struct msm_audio_event)))
-		return -EFAULT;
-
-	timeout = (int) usr_evt.timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(
-			audio->event_wait, audamrnb_events_pending(audio),
-			msecs_to_jiffies(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(
-			audio->event_wait, audamrnb_events_pending(audio));
-	}
-
-	if (rc < 0)
-		return rc;
-
-	if (audio->event_abort) {
-		audio->event_abort = 0;
-		return -ENODEV;
-	}
-
-	rc = 0;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	if (!list_empty(&audio->event_queue)) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audamrnb_event, list);
-		list_del(&drv_evt->list);
-	}
-
-	if (drv_evt) {
-		usr_evt.event_type = drv_evt->event_type;
-		usr_evt.event_payload = drv_evt->payload;
-		list_add_tail(&drv_evt->list, &audio->free_event_queue);
-	} else
-		rc = -1;
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	if (!rc && copy_to_user(arg, &usr_evt, sizeof(usr_evt)))
-		rc = -EFAULT;
-
-	return rc;
-}
-
-static int audio_enable_eq(struct audio *audio, int enable)
-{
-	if (audio->eq_enable == enable && !audio->eq_needs_commit)
-		return 0;
-
-	audio->eq_enable = enable;
-
-	if (audio->running) {
-		audpp_dsp_set_eq(audio->dec_id,	enable, &audio->eq, POPP);
-		audio->eq_needs_commit = 0;
-	}
-	return 0;
-}
-
-static int audio_get_avsync_data(struct audio *audio,
-						struct msm_audio_stats *stats)
-{
-	int rc = -EINVAL;
-	unsigned long flags;
-
-	local_irq_save(flags);
-	if (audio->dec_id == audio->avsync[0] && audio->avsync_flag) {
-		/* av_sync sample count */
-		stats->sample_count = (audio->avsync[2] << 16) |
-						(audio->avsync[3]);
-
-		/* av_sync byte_count */
-		stats->byte_count = (audio->avsync[5] << 16) |
-						(audio->avsync[6]);
-
-		audio->avsync_flag = 0;
-		rc = 0;
-	}
-	local_irq_restore(flags);
-	return rc;
-
-}
-
-static long audamrnb_ioctl(struct file *file, unsigned int cmd,
-		unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = -EINVAL;
-	unsigned long flags = 0;
-	uint16_t enable_mask;
-	int enable;
-	int prev_state;
-
-	MM_DBG("cmd = %d\n", cmd);
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-
-		audio->avsync_flag = 0;
-		memset(&stats, 0, sizeof(stats));
-		if (audpp_query_avsync(audio->dec_id) < 0)
-			return rc;
-
-		rc = wait_event_interruptible_timeout(audio->avsync_wait,
-				(audio->avsync_flag == 1),
-				msecs_to_jiffies(AUDPP_AVSYNC_EVENT_TIMEOUT));
-
-		if (rc < 0)
-			return rc;
-		else if ((rc > 0) || ((rc == 0) && (audio->avsync_flag == 1))) {
-			if (audio_get_avsync_data(audio, &stats) < 0)
-				return rc;
-
-			if (copy_to_user((void *)arg, &stats, sizeof(stats)))
-				return -EFAULT;
-			return 0;
-		} else
-			return -EAGAIN;
-	}
-
-	switch (cmd) {
-	case AUDIO_ENABLE_AUDPP:
-		if (copy_from_user(&enable_mask, (void *) arg,
-						sizeof(enable_mask))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		enable = (enable_mask & EQ_ENABLE) ? 1 : 0;
-		audio_enable_eq(audio, enable);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-	case AUDIO_SET_VOLUME:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.volume = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_PAN:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.pan = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_EQ:
-		prev_state = audio->eq_enable;
-		audio->eq_enable = 0;
-		if (copy_from_user(&audio->eq.num_bands, (void *) arg,
-				sizeof(audio->eq) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2))) {
-			rc = -EFAULT;
-			break;
-		}
-		audio->eq_enable = prev_state;
-		audio->eq_needs_commit = 1;
-		rc = 0;
-		break;
-	}
-
-	if (-EINVAL != rc)
-		return rc;
-
-	if (cmd == AUDIO_GET_EVENT) {
-		MM_DBG("AUDIO_GET_EVENT\n");
-		if (mutex_trylock(&audio->get_event_lock)) {
-			rc = audamrnb_process_event_req(audio,
-					(void __user *) arg);
-			mutex_unlock(&audio->get_event_lock);
-		} else
-			rc = -EBUSY;
-		return rc;
-	}
-
-	if (cmd == AUDIO_ABORT_GET_EVENT) {
-		audio->event_abort = 1;
-		wake_up(&audio->event_wait);
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		MM_DBG("AUDIO_START\n");
-		rc = audamrnb_enable(audio);
-		if (!rc) {
-			rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-			MM_INFO("dec_state %d rc = %d\n", audio->dec_state, rc);
-
-			if (audio->dec_state != MSM_AUD_DECODER_STATE_SUCCESS)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		break;
-	case AUDIO_STOP:
-		MM_DBG("AUDIO_STOP\n");
-		rc = audamrnb_disable(audio);
-		audio->stopped = 1;
-		audamrnb_ioport_reset(audio);
-		audio->stopped = 0;
-		break;
-	case AUDIO_FLUSH:
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audamrnb_ioport_reset(audio);
-		if (audio->running) {
-			audpp_flush(audio->dec_id);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-	case AUDIO_SET_CONFIG:{
-			struct msm_audio_config config;
-			if (copy_from_user
-			    (&config, (void *)arg, sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-			audio->mfield = config.meta_field;
-			rc = 0;
-			break;
-		}
-	case AUDIO_GET_CONFIG:{
-			struct msm_audio_config config;
-			config.buffer_size = BUFSZ;
-			config.buffer_count = 2;
-			config.sample_rate = 8000;
-			config.channel_count = 1;
-			config.meta_field = 0;
-			config.unused[0] = 0;
-			config.unused[1] = 0;
-			config.unused[2] = 0;
-			if (copy_to_user((void *)arg, &config,
-					 sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-
-			break;
-		}
-	case AUDIO_GET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			config.pcm_feedback = audio->pcm_feedback;
-			config.buffer_count = PCM_BUF_MAX_COUNT;
-			config.buffer_size = PCM_BUFSZ_MIN;
-			if (copy_to_user((void *)arg, &config,
-					 sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_SET_PCM_CONFIG:{
-		struct msm_audio_pcm_config config;
-		if (copy_from_user
-		    (&config, (void *)arg, sizeof(config))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (config.pcm_feedback != audio->pcm_feedback) {
-			MM_ERR("Not sufficient permission to"
-				 "change the playback mode\n");
-			rc = -EACCES;
-			break;
-		}
-		if ((config.buffer_count > PCM_BUF_MAX_COUNT) ||
-		    (config.buffer_count == 1))
-			config.buffer_count = PCM_BUF_MAX_COUNT;
-
-		if (config.buffer_size < PCM_BUFSZ_MIN)
-			config.buffer_size = PCM_BUFSZ_MIN;
-
-			/* Check if pcm feedback is required */
-		if ((config.pcm_feedback) && (!audio->read_data)) {
-			MM_DBG("allocate PCM buf %d\n",
-					config.buffer_count *
-					config.buffer_size);
-			audio->read_phys = allocate_contiguous_ebi_nomap(
-						config.buffer_size *
-						config.buffer_count,
-						SZ_4K);
-			if (!audio->read_phys) {
-					rc = -ENOMEM;
-					break;
-			}
-			audio->map_v_read = ioremap(
-						audio->read_phys,
-						config.buffer_size *
-						config.buffer_count);
-			if (IS_ERR(audio->map_v_read)) {
-				MM_ERR("failed to map read phys address\n");
-				rc = -ENOMEM;
-				free_contiguous_memory_by_paddr(
-							audio->read_phys);
-			} else {
-				uint8_t index;
-				uint32_t offset = 0;
-				audio->read_data = audio->map_v_read;
-				audio->buf_refresh = 0;
-				audio->pcm_buf_count =
-					config.buffer_count;
-				audio->read_next = 0;
-				audio->fill_next = 0;
-
-				for (index = 0;
-				index < config.buffer_count; index++) {
-					audio->in[index].data =
-						audio->read_data + offset;
-					audio->in[index].addr =
-					    audio->read_phys + offset;
-					audio->in[index].size =
-					    config.buffer_size;
-					audio->in[index].used = 0;
-					offset += config.buffer_size;
-				}
-				MM_DBG("read buf: phy addr 0x%08x kernel \
-					addr 0x%08x\n", audio->read_phys,
-					(int)audio->read_data);
-				rc = 0;
-			}
-		} else {
-			rc = 0;
-		}
-		break;
-	}
-	case AUDIO_GET_SESSION_ID:
-		if (copy_to_user((void *) arg, &audio->dec_id,
-			sizeof(unsigned short)))
-			rc =  -EFAULT;
-		else
-			rc = 0;
-		break;
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-/* Only useful in tunnel-mode */
-static int audamrnb_fsync(struct file *file, loff_t ppos1, loff_t ppos2, int datasync)
-{
-	struct audio *audio = file->private_data;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	if (!audio->running || audio->pcm_feedback) {
-		rc = -EINVAL;
-		goto done_nolock;
-	}
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(!audio->out[0].used &&
-		!audio->out[1].used &&
-		audio->out_needed) || audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		audio->teos || audio->wflush);
-
-	if (audio->wflush)
-		rc = -EBUSY;
-
-done:
-	mutex_unlock(&audio->write_lock);
-done_nolock:
-	return rc;
-}
-
-static ssize_t audamrnb_read(struct file *file, char __user *buf, size_t count,
-			  loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	int rc = 0;
-
-	if (!audio->pcm_feedback)
-		return 0; /* PCM feedback is not enabled. Nothing to read */
-
-	mutex_lock(&audio->read_lock);
-	MM_DBG("%d \n",	count);
-	while (count > 0) {
-		rc = wait_event_interruptible(audio->read_wait,
-			(audio->in[audio->read_next].used > 0) ||
-			(audio->stopped) || (audio->rflush));
-
-		if (rc < 0)
-			break;
-
-		if (audio->stopped || audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (count < audio->in[audio->read_next].used) {
-			/* Read must happen in frame boundary. Since driver does
-			 * not know frame size, read count must be greater or
-			 * equal to size of PCM samples
-			 */
-			MM_DBG("read stop - partial frame\n");
-			break;
-		} else {
-			MM_DBG("read from in[%d]\n", audio->read_next);
-
-			if (copy_to_user
-			    (buf, audio->in[audio->read_next].data,
-			     audio->in[audio->read_next].used)) {
-				MM_ERR("invalid addr %x \n", (unsigned int)buf);
-				rc = -EFAULT;
-				break;
-			}
-			count -= audio->in[audio->read_next].used;
-			buf += audio->in[audio->read_next].used;
-			audio->in[audio->read_next].used = 0;
-			if ((++audio->read_next) == audio->pcm_buf_count)
-				audio->read_next = 0;
-			break;
-		}
-	}
-
-	/* don't feed output buffer to HW decoder during flushing
-	 * buffer refresh command will be sent once flush completes
-	 * send buf refresh command here can confuse HW decoder
-	 */
-	if (audio->buf_refresh && !audio->rflush) {
-		audio->buf_refresh = 0;
-		MM_DBG("kick start pcm feedback again\n");
-		audamrnb_buffer_refresh(audio);
-	}
-
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		rc = buf - start;
-
-	MM_DBG("read %d bytes\n", rc);
-	return rc;
-}
-
-static int audamrnb_process_eos(struct audio *audio,
-		const char __user *buf_start, unsigned short mfield_size)
-{
-	int rc = 0;
-	struct buffer *frame;
-
-	frame = audio->out + audio->out_head;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	audamrnb_send_data(audio, 0);
-
-done:
-	return rc;
-}
-
-static ssize_t audamrnb_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	size_t xfer;
-	char *cpy_ptr;
-	int rc = 0, eos_condition = AUDAMRNB_EOS_NONE;
-	unsigned short mfield_size = 0;
-
-	MM_DBG("cnt=%d\n", count);
-
-	if (count & 1)
-		return -EINVAL;
-
-	mutex_lock(&audio->write_lock);
-	while (count > 0) {
-		frame = audio->out + audio->out_head;
-		cpy_ptr = frame->data;
-		rc = wait_event_interruptible(audio->write_wait,
-					      (frame->used == 0)
-						|| (audio->stopped)
-						|| (audio->wflush));
-
-		MM_DBG("buffer available\n");
-		if (rc < 0)
-			break;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (audio->mfield) {
-			if (buf == start) {
-				/* Processing beginning of user buffer */
-				if (__get_user(mfield_size,
-					(unsigned short __user *) buf)) {
-					rc = -EFAULT;
-					break;
-				} else 	if (mfield_size > count) {
-					rc = -EINVAL;
-					break;
-				}
-				MM_DBG("mf offset_val %x\n", mfield_size);
-				if (copy_from_user(cpy_ptr, buf, mfield_size)) {
-					rc = -EFAULT;
-					break;
-				}
-				/* Check if EOS flag is set and buffer
-				 * contains just meta field
-				 */
-				if (cpy_ptr[AUDAMRNB_EOS_FLG_OFFSET] &
-						AUDAMRNB_EOS_FLG_MASK) {
-					MM_DBG("eos set\n");
-					eos_condition = AUDAMRNB_EOS_SET;
-					if (mfield_size == count) {
-						buf += mfield_size;
-						break;
-					} else
-					cpy_ptr[AUDAMRNB_EOS_FLG_OFFSET] &=
-							~AUDAMRNB_EOS_FLG_MASK;
-				}
-				cpy_ptr += mfield_size;
-				count -= mfield_size;
-				buf += mfield_size;
-			} else {
-				mfield_size = 0;
-				MM_DBG("continuous buffer\n");
-			}
-			frame->mfield_sz = mfield_size;
-		}
-
-		xfer = (count > (frame->size - mfield_size)) ?
-			(frame->size - mfield_size) : count;
-		if (copy_from_user(cpy_ptr, buf, xfer)) {
-			rc = -EFAULT;
-			break;
-		}
-
-		frame->used = (xfer + mfield_size);
-		audio->out_head ^= 1;
-		count -= xfer;
-		buf += xfer;
-
-		audamrnb_send_data(audio, 0);
-
-	}
-	if (eos_condition == AUDAMRNB_EOS_SET)
-		rc = audamrnb_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	if (!rc) {
-		if (buf > start)
-			return buf - start;
-	}
-	return rc;
-}
-
-static int audamrnb_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	MM_INFO("audio instance 0x%08x freeing\n", (int)audio);
-
-	mutex_lock(&audio->lock);
-	auddev_unregister_evt_listner(AUDDEV_CLNT_DEC, audio->dec_id);
-	audamrnb_disable(audio);
-	audamrnb_flush(audio);
-	audamrnb_flush_pcm_buf(audio);
-	msm_adsp_put(audio->audplay);
-	audpp_adec_free(audio->dec_id);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	unregister_early_suspend(&audio->suspend_ctl.node);
-#endif
-	audio->event_abort = 1;
-	wake_up(&audio->event_wait);
-	audamrnb_reset_event_queue(audio);
-	iounmap(audio->map_v_write);
-	free_contiguous_memory_by_paddr(audio->phys);
-	if (audio->read_data) {
-		iounmap(audio->map_v_read);
-		free_contiguous_memory_by_paddr(audio->read_phys);
-	}
-	mutex_unlock(&audio->lock);
-#ifdef CONFIG_DEBUG_FS
-	if (audio->dentry)
-		debugfs_remove(audio->dentry);
-#endif
-	kfree(audio);
-	return 0;
-}
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audamrnb_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload)
-{
-	struct audamrnb_event *e_node = NULL;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-
-	if (!list_empty(&audio->free_event_queue)) {
-		e_node = list_first_entry(&audio->free_event_queue,
-				struct audamrnb_event, list);
-		list_del(&e_node->list);
-	} else {
-		e_node = kmalloc(sizeof(struct audamrnb_event), GFP_ATOMIC);
-		if (!e_node) {
-			MM_ERR("No mem to post event %d\n", type);
-			return;
-		}
-	}
-
-	e_node->event_type = type;
-	e_node->payload = payload;
-
-	list_add_tail(&e_node->list, &audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	wake_up(&audio->event_wait);
-}
-
-static void audamrnb_suspend(struct early_suspend *h)
-{
-	struct audamrnb_suspend_ctl *ctl =
-		container_of(h, struct audamrnb_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audamrnb_post_event(ctl->audio, AUDIO_EVENT_SUSPEND, payload);
-}
-
-static void audamrnb_resume(struct early_suspend *h)
-{
-	struct audamrnb_suspend_ctl *ctl =
-		container_of(h, struct audamrnb_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audamrnb_post_event(ctl->audio, AUDIO_EVENT_RESUME, payload);
-}
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-static ssize_t audamrnb_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static ssize_t audamrnb_debug_read(struct file *file, char __user *buf,
-					size_t count, loff_t *ppos)
-{
-	const int debug_bufmax = 1024;
-	static char buffer[1024];
-	int n = 0, i;
-	struct audio *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	n = scnprintf(buffer, debug_bufmax, "opened %d\n", audio->opened);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"enabled %d\n", audio->enabled);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"stopped %d\n", audio->stopped);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_feedback %d\n", audio->pcm_feedback);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_buf_sz %d\n", audio->out[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_buf_count %d \n", audio->pcm_buf_count);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_buf_sz %d \n", audio->in[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"volume %x \n", audio->vol_pan.volume);
-	mutex_unlock(&audio->lock);
-	/* Following variables are only useful for debugging when
-	 * when playback halts unexpectedly. Thus, no mutual exclusion
-	 * enforced
-	 */
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"wflush %d\n", audio->wflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"rflush %d\n", audio->rflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"running %d \n", audio->running);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"dec state %d \n", audio->dec_state);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_needed %d \n", audio->out_needed);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_head %d \n", audio->out_head);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_tail %d \n", audio->out_tail);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out[0].used %d \n", audio->out[0].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out[1].used %d \n", audio->out[1].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"buffer_refresh %d \n", audio->buf_refresh);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"read_next %d \n", audio->read_next);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"fill_next %d \n", audio->fill_next);
-	for (i = 0; i < audio->pcm_buf_count; i++)
-		n += scnprintf(buffer + n, debug_bufmax - n,
-				"in[%d].used %d \n", i, audio->in[i].used);
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations audamrnb_debug_fops = {
-	.read = audamrnb_debug_read,
-	.open = audamrnb_debug_open,
-};
-#endif
-
-static int audamrnb_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = NULL;
-	int rc, dec_attrb, decid, i;
-	struct audamrnb_event *e_node = NULL;
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_amrnb_" + 5];
-#endif
-
-	/* Allocate Mem for audio instance */
-	audio = kzalloc(sizeof(struct audio), GFP_KERNEL);
-	if (!audio) {
-		MM_ERR("no memory to allocate audio instance \n");
-		rc = -ENOMEM;
-		goto done;
-	}
-	MM_INFO("audio instance 0x%08x created\n", (int)audio);
-
-	/* Allocate the decoder */
-	dec_attrb = AUDDEC_DEC_AMRNB;
-	if ((file->f_mode & FMODE_WRITE) &&
-			(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_NONTUNNEL;
-		audio->pcm_feedback = NON_TUNNEL_MODE_PLAYBACK;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_TUNNEL;
-		audio->pcm_feedback = TUNNEL_MODE_PLAYBACK;
-	} else {
-		kfree(audio);
-		rc = -EACCES;
-		goto done;
-	}
-
-	decid = audpp_adec_alloc(dec_attrb, &audio->module_name,
-			&audio->queue_id);
-
-	if (decid < 0) {
-		MM_ERR("No free decoder available, freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENODEV;
-		kfree(audio);
-		goto done;
-	}
-
-	audio->dec_id = decid & MSM_AUD_DECODER_MASK;
-
-	audio->phys = allocate_contiguous_ebi_nomap(DMASZ, SZ_4K);
-	if (!audio->phys) {
-		MM_ERR("could not allocate write buffers, freeing instance \
-				0x%08x\n", (int)audio);
-		rc = -ENOMEM;
-		audpp_adec_free(audio->dec_id);
-		kfree(audio);
-		goto done;
-	} else {
-		audio->map_v_write = ioremap(audio->phys, DMASZ);
-		if (IS_ERR(audio->map_v_write)) {
-			MM_ERR("could not map write phys address, freeing \
-					instance 0x%08x\n", (int)audio);
-			rc = -ENOMEM;
-			free_contiguous_memory_by_paddr(audio->phys);
-			audpp_adec_free(audio->dec_id);
-			free_contiguous_memory_by_paddr(audio->phys);
-			kfree(audio);
-			goto done;
-		}
-		audio->data = audio->map_v_write;
-		MM_DBG("write buf: phy addr 0x%08x kernel addr \
-				0x%08x\n", audio->phys, (int)audio->data);
-	}
-
-	rc = msm_adsp_get(audio->module_name, &audio->audplay,
-		&audplay_adsp_ops_amrnb, audio);
-	if (rc) {
-		MM_ERR("failed to get %s module freeing instance 0x%08x\n",
-				audio->module_name, (int)audio);
-		goto err;
-	}
-
-	mutex_init(&audio->lock);
-	mutex_init(&audio->write_lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->get_event_lock);
-	spin_lock_init(&audio->dsp_lock);
-	spin_lock_init(&audio->event_queue_lock);
-	INIT_LIST_HEAD(&audio->free_event_queue);
-	INIT_LIST_HEAD(&audio->event_queue);
-	init_waitqueue_head(&audio->write_wait);
-	init_waitqueue_head(&audio->read_wait);
-	init_waitqueue_head(&audio->wait);
-	init_waitqueue_head(&audio->event_wait);
-	init_waitqueue_head(&audio->avsync_wait);
-
-	audio->out[0].data = audio->data + 0;
-	audio->out[0].addr = audio->phys + 0;
-	audio->out[0].size = BUFSZ;
-
-	audio->out[1].data = audio->data + BUFSZ;
-	audio->out[1].addr = audio->phys + BUFSZ;
-	audio->out[1].size = BUFSZ;
-
-	audio->vol_pan.volume = 0x2000;
-
-	audamrnb_flush(audio);
-
-	file->private_data = audio;
-	audio->opened = 1;
-
-	audio->device_events = AUDDEV_EVT_DEV_RDY
-				|AUDDEV_EVT_DEV_RLS|
-				AUDDEV_EVT_STREAM_VOL_CHG;
-
-	rc = auddev_register_evt_listner(audio->device_events,
-					AUDDEV_CLNT_DEC,
-					audio->dec_id,
-					amrnb_listner,
-					(void *)audio);
-	if (rc) {
-		MM_ERR("%s: failed to register listner\n", __func__);
-		goto event_err;
-	}
-
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof name, "msm_amrnb_%04x", audio->dec_id);
-	audio->dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
-			NULL, (void *) audio, &audamrnb_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		MM_DBG("debugfs_create_file failed\n");
-#endif
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	audio->suspend_ctl.node.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
-	audio->suspend_ctl.node.resume = audamrnb_resume;
-	audio->suspend_ctl.node.suspend = audamrnb_suspend;
-	audio->suspend_ctl.audio = audio;
-	register_early_suspend(&audio->suspend_ctl.node);
-#endif
-	for (i = 0; i < AUDAMRNB_EVENT_NUM; i++) {
-		e_node = kmalloc(sizeof(struct audamrnb_event), GFP_KERNEL);
-		if (e_node)
-			list_add_tail(&e_node->list, &audio->free_event_queue);
-		else {
-			MM_ERR("event pkt alloc failed\n");
-			break;
-		}
-	}
-done:
-	return rc;
-event_err:
-	msm_adsp_put(audio->audplay);
-err:
-	iounmap(audio->map_v_write);
-	free_contiguous_memory_by_paddr(audio->phys);
-	audpp_adec_free(audio->dec_id);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_amrnb_fops = {
-	.owner = THIS_MODULE,
-	.open = audamrnb_open,
-	.release = audamrnb_release,
-	.read = audamrnb_read,
-	.write = audamrnb_write,
-	.unlocked_ioctl = audamrnb_ioctl,
-	.fsync = audamrnb_fsync,
-};
-
-struct miscdevice audio_amrnb_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_amrnb",
-	.fops = &audio_amrnb_fops,
-};
-
-static int __init audamrnb_init(void)
-{
-	return misc_register(&audio_amrnb_misc);
-}
-
-static void __exit audamrnb_exit(void)
-{
-	misc_deregister(&audio_amrnb_misc);
-}
-
-module_init(audamrnb_init);
-module_exit(audamrnb_exit);
-
-MODULE_DESCRIPTION("MSM AMR-NB driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5v2/audio_amrnb_in.c b/arch/arm/mach-msm/qdsp5v2/audio_amrnb_in.c
deleted file mode 100644
index cb3c3ea..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audio_amrnb_in.c
+++ /dev/null
@@ -1,950 +0,0 @@
-/*
- * amrnb audio input device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/msm_audio_amrnb.h>
-#include <linux/msm_ion.h>
-#include <linux/memory_alloc.h>
-
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/msm_adsp.h>
-#include <mach/socinfo.h>
-#include <mach/qdsp5v2/qdsp5audreccmdi.h>
-#include <mach/qdsp5v2/qdsp5audrecmsg.h>
-#include <mach/qdsp5v2/audpreproc.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_memtypes.h>
-
-/* FRAME_NUM must be a power of two */
-#define FRAME_NUM		(8)
-#define FRAME_SIZE		(22 * 2) /* 36 bytes data */
-#define DMASZ 			(FRAME_SIZE * FRAME_NUM)
-
-struct buffer {
-	void *data;
-	uint32_t size;
-	uint32_t read;
-	uint32_t addr;
-};
-
-struct audio_in {
-	struct buffer in[FRAME_NUM];
-
-	spinlock_t dsp_lock;
-
-	atomic_t in_bytes;
-	atomic_t in_samples;
-
-	struct mutex lock;
-	struct mutex read_lock;
-	wait_queue_head_t wait;
-	wait_queue_head_t wait_enable;
-
-	struct msm_adsp_module *audrec;
-	struct audrec_session_info session_info; /*audrec session info*/
-
-	/* configuration to use on next enable */
-	uint32_t buffer_size; /* Frame size (36 bytes) */
-	uint32_t enc_type;
-
-	int dtx_mode;
-	uint32_t frame_format;
-	uint32_t used_mode;
-	uint32_t rec_mode;
-
-	uint32_t dsp_cnt;
-	uint32_t in_head; /* next buffer dsp will write */
-	uint32_t in_tail; /* next buffer read() will read */
-	uint32_t in_count; /* number of buffers available to read() */
-	uint32_t mode;
-
-	const char *module_name;
-	unsigned queue_ids;
-	uint16_t enc_id;
-
-	uint16_t source; /* Encoding source bit mask */
-	uint32_t device_events;
-	uint32_t in_call;
-	uint32_t dev_cnt;
-	int voice_state;
-	spinlock_t dev_lock;
-
-	/* data allocated for various buffers */
-	char *data;
-	dma_addr_t phys;
-	void *map_v_read;
-
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped, cleared on flush */
-	char *build_id;
-	struct ion_client *client;
-	struct ion_handle *buff_handle;
-};
-
-struct audio_frame {
-	uint16_t frame_count_lsw;
-	uint16_t frame_count_msw;
-	uint16_t frame_length;
-	uint16_t erased_pcm;
-	unsigned char raw_bitstream[]; /* samples */
-} __attribute__((packed));
-
-/* Audrec Queue command sent macro's */
-#define audrec_send_bitstreamqueue(audio, cmd, len) \
-	msm_adsp_write(audio->audrec, ((audio->queue_ids & 0xFFFF0000) >> 16),\
-			cmd, len)
-
-#define audrec_send_audrecqueue(audio, cmd, len) \
-	msm_adsp_write(audio->audrec, (audio->queue_ids & 0x0000FFFF),\
-			cmd, len)
-
-struct audio_in the_audio_amrnb_in;
-
-/* DSP command send functions */
-static int audamrnb_in_enc_config(struct audio_in *audio, int enable);
-static int audamrnb_in_param_config(struct audio_in *audio);
-static int audamrnb_in_mem_config(struct audio_in *audio);
-static int audamrnb_in_record_config(struct audio_in *audio, int enable);
-static int audamrnb_dsp_read_buffer(struct audio_in *audio, uint32_t read_cnt);
-
-static void audamrnb_in_get_dsp_frames(struct audio_in *audio);
-
-static void audamrnb_in_flush(struct audio_in *audio);
-
-static void amrnb_in_listener(u32 evt_id, union auddev_evt_data *evt_payload,
-				void *private_data)
-{
-	struct audio_in *audio = (struct audio_in *) private_data;
-	unsigned long flags;
-
-	MM_DBG("evt_id = 0x%8x\n", evt_id);
-	switch (evt_id) {
-	case AUDDEV_EVT_DEV_RDY: {
-		MM_DBG("AUDDEV_EVT_DEV_RDY\n");
-		spin_lock_irqsave(&audio->dev_lock, flags);
-		audio->dev_cnt++;
-		if (!audio->in_call)
-			audio->source |= (0x1 << evt_payload->routing_id);
-		spin_unlock_irqrestore(&audio->dev_lock, flags);
-
-		if ((audio->running == 1) && (audio->enabled == 1))
-			audamrnb_in_record_config(audio, 1);
-
-		break;
-	}
-	case AUDDEV_EVT_DEV_RLS: {
-		MM_DBG("AUDDEV_EVT_DEV_RLS\n");
-		spin_lock_irqsave(&audio->dev_lock, flags);
-		audio->dev_cnt--;
-		if (!audio->in_call)
-			audio->source &= ~(0x1 << evt_payload->routing_id);
-		spin_unlock_irqrestore(&audio->dev_lock, flags);
-
-		if ((!audio->running) || (!audio->enabled))
-			break;
-
-		/* Turn of as per source */
-		if (audio->source)
-			audamrnb_in_record_config(audio, 1);
-		else
-			/* Turn off all */
-			audamrnb_in_record_config(audio, 0);
-
-		break;
-	}
-	case AUDDEV_EVT_VOICE_STATE_CHG: {
-		MM_DBG("AUDDEV_EVT_VOICE_STATE_CHG, state = %d\n",
-				evt_payload->voice_state);
-		audio->voice_state = evt_payload->voice_state;
-		if (audio->in_call && audio->running) {
-			if (audio->voice_state == VOICE_STATE_INCALL)
-				audamrnb_in_record_config(audio, 1);
-			else if (audio->voice_state == VOICE_STATE_OFFCALL) {
-				audamrnb_in_record_config(audio, 0);
-				wake_up(&audio->wait);
-			}
-		}
-
-		break;
-	}
-	default:
-		MM_ERR("wrong event %d\n", evt_id);
-		break;
-	}
-}
-
-/* ------------------- dsp preproc event handler--------------------- */
-static void audpreproc_dsp_event(void *data, unsigned id,  void *msg)
-{
-	struct audio_in *audio = data;
-
-	switch (id) {
-	case AUDPREPROC_ERROR_MSG: {
-		struct audpreproc_err_msg *err_msg = msg;
-
-		MM_ERR("ERROR_MSG: stream id %d err idx %d\n",
-		err_msg->stream_id, err_msg->aud_preproc_err_idx);
-		/* Error case */
-		wake_up(&audio->wait_enable);
-		break;
-	}
-	case AUDPREPROC_CMD_CFG_DONE_MSG: {
-		MM_DBG("CMD_CFG_DONE_MSG \n");
-		break;
-	}
-	case AUDPREPROC_CMD_ENC_CFG_DONE_MSG: {
-		struct audpreproc_cmd_enc_cfg_done_msg *enc_cfg_msg = msg;
-
-		MM_DBG("CMD_ENC_CFG_DONE_MSG: stream id %d enc type \
-			0x%8x\n", enc_cfg_msg->stream_id,
-			enc_cfg_msg->rec_enc_type);
-		/* Encoder enable success */
-		if (enc_cfg_msg->rec_enc_type & ENCODE_ENABLE)
-			audamrnb_in_param_config(audio);
-		else { /* Encoder disable success */
-			audio->running = 0;
-			audamrnb_in_record_config(audio, 0);
-		}
-		break;
-	}
-	case AUDPREPROC_CMD_ENC_PARAM_CFG_DONE_MSG: {
-		MM_DBG("CMD_ENC_PARAM_CFG_DONE_MSG \n");
-		audamrnb_in_mem_config(audio);
-		break;
-	}
-	case AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG_DONE_MSG: {
-		MM_DBG("AFE_CMD_AUDIO_RECORD_CFG_DONE_MSG \n");
-		wake_up(&audio->wait_enable);
-		break;
-	}
-	default:
-		MM_ERR("Unknown Event id %d\n", id);
-	}
-}
-
-/* ------------------- dsp audrec event handler--------------------- */
-static void audrec_dsp_event(void *data, unsigned id, size_t len,
-			    void (*getevent)(void *ptr, size_t len))
-{
-	struct audio_in *audio = data;
-
-	switch (id) {
-	case AUDREC_CMD_MEM_CFG_DONE_MSG: {
-		MM_DBG("CMD_MEM_CFG_DONE MSG DONE\n");
-		audio->running = 1;
-		if ((!audio->in_call && (audio->dev_cnt > 0)) ||
-			(audio->in_call &&
-				(audio->voice_state == VOICE_STATE_INCALL)))
-			audamrnb_in_record_config(audio, 1);
-		break;
-	}
-	case AUDREC_FATAL_ERR_MSG: {
-		struct audrec_fatal_err_msg fatal_err_msg;
-
-		getevent(&fatal_err_msg, AUDREC_FATAL_ERR_MSG_LEN);
-		MM_ERR("FATAL_ERR_MSG: err id %d\n",
-				fatal_err_msg.audrec_err_id);
-		/* Error stop the encoder */
-		audio->stopped = 1;
-		wake_up(&audio->wait);
-		break;
-	}
-	case AUDREC_UP_PACKET_READY_MSG: {
-		struct audrec_up_pkt_ready_msg pkt_ready_msg;
-
-		getevent(&pkt_ready_msg, AUDREC_UP_PACKET_READY_MSG_LEN);
-		MM_DBG("UP_PACKET_READY_MSG: write cnt lsw  %d \
-		write cnt msw %d read cnt lsw %d  read cnt msw %d \n",\
-		pkt_ready_msg.audrec_packet_write_cnt_lsw, \
-		pkt_ready_msg.audrec_packet_write_cnt_msw, \
-		pkt_ready_msg.audrec_up_prev_read_cnt_lsw, \
-		pkt_ready_msg.audrec_up_prev_read_cnt_msw);
-
-		audamrnb_in_get_dsp_frames(audio);
-		break;
-	}
-	case ADSP_MESSAGE_ID: {
-		MM_DBG("Received ADSP event:module audrectask\n");
-		break;
-	}
-	default:
-		MM_ERR("Unknown Event id %d\n", id);
-	}
-}
-
-static void audamrnb_in_get_dsp_frames(struct audio_in *audio)
-{
-	struct audio_frame *frame;
-	uint32_t index;
-	unsigned long flags;
-
-	index = audio->in_head;
-
-	frame = (void *) (((char *)audio->in[index].data) - \
-			 sizeof(*frame));
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->in[index].size = frame->frame_length;
-
-	/* statistics of read */
-	atomic_add(audio->in[index].size, &audio->in_bytes);
-	atomic_add(1, &audio->in_samples);
-
-	audio->in_head = (audio->in_head + 1) & (FRAME_NUM - 1);
-
-	/* If overflow, move the tail index foward. */
-	if (audio->in_head == audio->in_tail)
-		audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
-	else
-		audio->in_count++;
-
-	audamrnb_dsp_read_buffer(audio, audio->dsp_cnt++);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-
-	wake_up(&audio->wait);
-}
-struct msm_adsp_ops audrec_amrnb_adsp_ops = {
-	.event = audrec_dsp_event,
-};
-
-static int audamrnb_in_enc_config(struct audio_in *audio, int enable)
-{
-	struct audpreproc_audrec_cmd_enc_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	if (audio->build_id[17] == '1') {
-		cmd.cmd_id = AUDPREPROC_AUDREC_CMD_ENC_CFG_2;
-		MM_ERR("sending AUDPREPROC_AUDREC_CMD_ENC_CFG_2 command");
-	} else {
-		cmd.cmd_id = AUDPREPROC_AUDREC_CMD_ENC_CFG;
-		MM_ERR("sending AUDPREPROC_AUDREC_CMD_ENC_CFG command");
-	}
-	cmd.stream_id = audio->enc_id;
-
-	if (enable)
-		cmd.audrec_enc_type = audio->enc_type | ENCODE_ENABLE;
-	else
-		cmd.audrec_enc_type &= ~(ENCODE_ENABLE);
-
-	return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd));
-}
-
-static int audamrnb_in_param_config(struct audio_in *audio)
-{
-	struct audpreproc_audrec_cmd_parm_cfg_amrnb cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPREPROC_AUDREC_CMD_PARAM_CFG;
-	cmd.common.stream_id = audio->enc_id;
-
-	cmd.dtx_mode = audio->dtx_mode;
-	cmd.test_mode = -1; /* Default set to -1 */
-	cmd.used_mode = audio->used_mode;
-
-	return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd));
-}
-
-/* To Do: msm_snddev_route_enc(audio->enc_id); */
-static int audamrnb_in_record_config(struct audio_in *audio, int enable)
-{
-	struct audpreproc_afe_cmd_audio_record_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG;
-	cmd.stream_id = audio->enc_id;
-	if (enable)
-		cmd.destination_activity = AUDIO_RECORDING_TURN_ON;
-	else
-		cmd.destination_activity = AUDIO_RECORDING_TURN_OFF;
-
-	cmd.source_mix_mask = audio->source;
-	if (audio->enc_id == 2) {
-		if ((cmd.source_mix_mask &
-				INTERNAL_CODEC_TX_SOURCE_MIX_MASK) ||
-			(cmd.source_mix_mask & AUX_CODEC_TX_SOURCE_MIX_MASK) ||
-			(cmd.source_mix_mask & VOICE_UL_SOURCE_MIX_MASK) ||
-			(cmd.source_mix_mask & VOICE_DL_SOURCE_MIX_MASK)) {
-			cmd.pipe_id = SOURCE_PIPE_1;
-		}
-		if (cmd.source_mix_mask &
-				AUDPP_A2DP_PIPE_SOURCE_MIX_MASK)
-			cmd.pipe_id |= SOURCE_PIPE_0;
-	}
-
-	return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd));
-}
-
-static int audamrnb_in_mem_config(struct audio_in *audio)
-{
-	struct audrec_cmd_arecmem_cfg cmd;
-	uint16_t *data = (void *) audio->data;
-	int n;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_MEM_CFG_CMD;
-	cmd.audrec_up_pkt_intm_count = 1;
-	cmd.audrec_ext_pkt_start_addr_msw = audio->phys >> 16;
-	cmd.audrec_ext_pkt_start_addr_lsw = audio->phys;
-	cmd.audrec_ext_pkt_buf_number = FRAME_NUM;
-
-	/* prepare buffer pointers:
-	 * 36 bytes amrnb packet + 4 halfword header
-	 */
-	for (n = 0; n < FRAME_NUM; n++) {
-		audio->in[n].data = data + 4;
-		data += (FRAME_SIZE/2); /* word increment */
-		MM_DBG("0x%8x\n", (int)(audio->in[n].data - 8));
-	}
-
-	return audrec_send_audrecqueue(audio, &cmd, sizeof(cmd));
-}
-
-static int audamrnb_dsp_read_buffer(struct audio_in *audio, uint32_t read_cnt)
-{
-	struct up_audrec_packet_ext_ptr cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = UP_AUDREC_PACKET_EXT_PTR;
-	cmd.audrec_up_curr_read_count_msw = read_cnt >> 16;
-	cmd.audrec_up_curr_read_count_lsw = read_cnt;
-
-	return audrec_send_bitstreamqueue(audio, &cmd, sizeof(cmd));
-}
-
-/* must be called with audio->lock held */
-static int audamrnb_in_enable(struct audio_in *audio)
-{
-	if (audio->enabled)
-		return 0;
-
-	if (audpreproc_enable(audio->enc_id, &audpreproc_dsp_event, audio)) {
-		MM_ERR("msm_adsp_enable(audpreproc) failed\n");
-		return -ENODEV;
-	}
-
-	if (msm_adsp_enable(audio->audrec)) {
-		MM_ERR("msm_adsp_enable(audrec) failed\n");
-		audpreproc_disable(audio->enc_id, audio);
-		return -ENODEV;
-	}
-	audio->enabled = 1;
-	audamrnb_in_enc_config(audio, 1);
-
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audamrnb_in_disable(struct audio_in *audio)
-{
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audamrnb_in_enc_config(audio, 0);
-		wake_up(&audio->wait);
-		wait_event_interruptible_timeout(audio->wait_enable,
-				audio->running == 0, 1*HZ);
-		msm_adsp_disable(audio->audrec);
-		audpreproc_disable(audio->enc_id, audio);
-	}
-	return 0;
-}
-
-static void audamrnb_in_flush(struct audio_in *audio)
-{
-	int i;
-
-	audio->dsp_cnt = 0;
-	audio->in_head = 0;
-	audio->in_tail = 0;
-	audio->in_count = 0;
-	for (i = 0; i < FRAME_NUM; i++) {
-		audio->in[i].size = 0;
-		audio->in[i].read = 0;
-	}
-	MM_DBG("in_bytes %d\n", atomic_read(&audio->in_bytes));
-	MM_DBG("in_samples %d\n", atomic_read(&audio->in_samples));
-	atomic_set(&audio->in_bytes, 0);
-	atomic_set(&audio->in_samples, 0);
-}
-
-/* ------------------- device --------------------- */
-static long audamrnb_in_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct audio_in *audio = file->private_data;
-	int rc = 0;
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		memset(&stats, 0, sizeof(stats));
-		stats.byte_count = atomic_read(&audio->in_bytes);
-		stats.sample_count = atomic_read(&audio->in_samples);
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return rc;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START: {
-		uint32_t freq;
-		freq = 48000;
-		MM_DBG("AUDIO_START\n");
-		if (audio->in_call && (audio->voice_state !=
-				VOICE_STATE_INCALL)) {
-			rc = -EPERM;
-			break;
-		}
-		rc = msm_snddev_request_freq(&freq, audio->enc_id,
-					SNDDEV_CAP_TX, AUDDEV_CLNT_ENC);
-		MM_DBG("sample rate configured %d\n", freq);
-		if (rc < 0) {
-			MM_DBG(" Sample rate can not be set, return code %d\n",
-								 rc);
-			msm_snddev_withdraw_freq(audio->enc_id,
-					SNDDEV_CAP_TX, AUDDEV_CLNT_ENC);
-			MM_DBG("msm_snddev_withdraw_freq\n");
-			break;
-		}
-		/*update aurec session info in audpreproc layer*/
-		audio->session_info.session_id = audio->enc_id;
-		/*amrnb works only on 8KHz*/
-		audio->session_info.sampling_freq = 8000;
-		audpreproc_update_audrec_info(&audio->session_info);
-		rc = audamrnb_in_enable(audio);
-		if (!rc) {
-			rc =
-			wait_event_interruptible_timeout(audio->wait_enable,
-				audio->running != 0, 1*HZ);
-			MM_DBG("state %d rc = %d\n", audio->running, rc);
-
-			if (audio->running == 0)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		audio->stopped = 0;
-		break;
-	}
-	case AUDIO_STOP: {
-		/*reset the sampling frequency information at audpreproc layer*/
-		audio->session_info.sampling_freq = 0;
-		audpreproc_update_audrec_info(&audio->session_info);
-		rc = audamrnb_in_disable(audio);
-		rc = msm_snddev_withdraw_freq(audio->enc_id,
-					SNDDEV_CAP_TX, AUDDEV_CLNT_ENC);
-		MM_DBG("msm_snddev_withdraw_freq\n");
-		audio->stopped = 1;
-		break;
-	}
-	case AUDIO_FLUSH: {
-		if (audio->stopped) {
-			/* Make sure we're stopped and we wake any threads
-			 * that might be blocked holding the read_lock.
-			 * While audio->stopped read threads will always
-			 * exit immediately.
-			 */
-			wake_up(&audio->wait);
-			mutex_lock(&audio->read_lock);
-			audamrnb_in_flush(audio);
-			mutex_unlock(&audio->read_lock);
-		}
-		break;
-	}
-	case AUDIO_SET_STREAM_CONFIG: {
-		struct msm_audio_stream_config cfg;
-		if (copy_from_user(&cfg, (void *) arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		/* Allow only single frame */
-		if (cfg.buffer_size != (FRAME_SIZE - 8))
-			rc = -EINVAL;
-		else
-			audio->buffer_size = cfg.buffer_size;
-		break;
-	}
-	case AUDIO_GET_STREAM_CONFIG: {
-		struct msm_audio_stream_config cfg;
-		memset(&cfg, 0, sizeof(cfg));
-		cfg.buffer_size = audio->buffer_size;
-		cfg.buffer_count = FRAME_NUM;
-		if (copy_to_user((void *) arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		break;
-	}
-	case AUDIO_GET_AMRNB_ENC_CONFIG_V2: {
-		struct msm_audio_amrnb_enc_config_v2 cfg;
-		memset(&cfg, 0, sizeof(cfg));
-		cfg.dtx_enable = ((audio->dtx_mode == -1) ? 1 : 0);
-		cfg.band_mode = audio->used_mode;
-		cfg.frame_format = audio->frame_format;
-		if (copy_to_user((void *) arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		break;
-	}
-	case AUDIO_SET_AMRNB_ENC_CONFIG_V2: {
-		struct msm_audio_amrnb_enc_config_v2 cfg;
-		if (copy_from_user(&cfg, (void *) arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		/* DSP does not support any other than default format */
-		if (audio->frame_format != cfg.frame_format) {
-			rc = -EINVAL;
-			break;
-		}
-		if (cfg.dtx_enable == 0)
-			audio->dtx_mode = 0;
-		else if (cfg.dtx_enable == 1)
-			audio->dtx_mode = -1;
-		else {
-			rc = -EINVAL;
-			break;
-		}
-		audio->used_mode = cfg.band_mode;
-		break;
-	}
-	case AUDIO_SET_INCALL: {
-		struct msm_voicerec_mode cfg;
-		unsigned long flags;
-		if (copy_from_user(&cfg, (void *) arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (cfg.rec_mode != VOC_REC_BOTH &&
-			cfg.rec_mode != VOC_REC_UPLINK &&
-			cfg.rec_mode != VOC_REC_DOWNLINK) {
-			MM_ERR("invalid rec_mode\n");
-			rc = -EINVAL;
-			break;
-		} else {
-			spin_lock_irqsave(&audio->dev_lock, flags);
-			if (cfg.rec_mode == VOC_REC_UPLINK)
-				audio->source = VOICE_UL_SOURCE_MIX_MASK;
-			else if (cfg.rec_mode == VOC_REC_DOWNLINK)
-				audio->source = VOICE_DL_SOURCE_MIX_MASK;
-			else
-				audio->source = VOICE_DL_SOURCE_MIX_MASK |
-						VOICE_UL_SOURCE_MIX_MASK ;
-			audio->in_call = 1;
-			spin_unlock_irqrestore(&audio->dev_lock, flags);
-		}
-		break;
-	}
-	case AUDIO_GET_SESSION_ID: {
-		if (copy_to_user((void *) arg, &audio->enc_id,
-			sizeof(unsigned short))) {
-			rc = -EFAULT;
-		}
-		break;
-	}
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static ssize_t audamrnb_in_read(struct file *file,
-				char __user *buf,
-				size_t count, loff_t *pos)
-{
-	struct audio_in *audio = file->private_data;
-	unsigned long flags;
-	const char __user *start = buf;
-	void *data;
-	uint32_t index;
-	uint32_t size;
-	int rc = 0;
-
-	mutex_lock(&audio->read_lock);
-	while (count > 0) {
-		rc = wait_event_interruptible(
-			audio->wait, (audio->in_count > 0) || audio->stopped
-			|| (audio->in_call && audio->running &&
-				(audio->voice_state == VOICE_STATE_OFFCALL)));
-		if (rc < 0)
-			break;
-
-		if (!audio->in_count) {
-			if (audio->stopped)  {
-				rc = 0;/* End of File */
-				break;
-			} else if (audio->in_call && audio->running &&
-				(audio->voice_state == VOICE_STATE_OFFCALL)) {
-				MM_DBG("Not Permitted Voice Terminated\n");
-				rc = -EPERM; /* Voice Call stopped */
-				break;
-			}
-		}
-
-		index = audio->in_tail;
-		data = (uint8_t *) audio->in[index].data;
-		size = audio->in[index].size;
-		if (count >= size) {
-			if (copy_to_user(buf, data, size)) {
-				rc = -EFAULT;
-				break;
-			}
-			spin_lock_irqsave(&audio->dsp_lock, flags);
-			if (index != audio->in_tail) {
-				/* overrun -- data is
-				 * invalid and we need to retry */
-				spin_unlock_irqrestore(&audio->dsp_lock, flags);
-				continue;
-			}
-			audio->in[index].size = 0;
-			audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
-			audio->in_count--;
-			spin_unlock_irqrestore(&audio->dsp_lock, flags);
-			count -= size;
-			buf += size;
-		} else {
-			MM_ERR("short read\n");
-			break;
-		}
-	}
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		return buf - start;
-
-	return rc;
-}
-
-static ssize_t audamrnb_in_write(struct file *file,
-				const char __user *buf,
-				size_t count, loff_t *pos)
-{
-	return -EINVAL;
-}
-
-static int audamrnb_in_release(struct inode *inode, struct file *file)
-{
-	struct audio_in *audio = file->private_data;
-
-	MM_DBG("\n");
-	mutex_lock(&audio->lock);
-	audio->in_call = 0;
-	/* with draw frequency for session
-	   incase not stopped the driver */
-	msm_snddev_withdraw_freq(audio->enc_id, SNDDEV_CAP_TX,
-					AUDDEV_CLNT_ENC);
-	auddev_unregister_evt_listner(AUDDEV_CLNT_ENC, audio->enc_id);
-	/*reset the sampling frequency information at audpreproc layer*/
-	audio->session_info.sampling_freq = 0;
-	audpreproc_update_audrec_info(&audio->session_info);
-	audamrnb_in_disable(audio);
-	audamrnb_in_flush(audio);
-	msm_adsp_put(audio->audrec);
-	audpreproc_aenc_free(audio->enc_id);
-	audio->audrec = NULL;
-	audio->opened = 0;
-	if (audio->data) {
-		ion_unmap_kernel(audio->client, audio->buff_handle);
-		ion_free(audio->client, audio->buff_handle);
-		ion_client_destroy(audio->client);
-		audio->data = NULL;
-	}
-	mutex_unlock(&audio->lock);
-	return 0;
-}
-
-static int audamrnb_in_open(struct inode *inode, struct file *file)
-{
-	struct audio_in *audio = &the_audio_amrnb_in;
-	int rc;
-	int encid;
-	int len = 0;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	struct ion_client *client = NULL;
-
-	mutex_lock(&audio->lock);
-	if (audio->opened) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	client = msm_ion_client_create(UINT_MAX, "Audio_AMR_In_Client");
-	if (IS_ERR_OR_NULL(client)) {
-		MM_ERR("Unable to create ION client\n");
-		rc = -ENOMEM;
-		goto client_create_error;
-	}
-	audio->client = client;
-
-	handle = ion_alloc(client, DMASZ, SZ_4K,
-		ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-	if (IS_ERR_OR_NULL(handle)) {
-		MM_ERR("Unable to create allocate O/P buffers\n");
-		rc = -ENOMEM;
-		goto buff_alloc_error;
-	}
-	audio->buff_handle = handle;
-
-	rc = ion_phys(client, handle, &addr, &len);
-	if (rc) {
-		MM_ERR("O/P buffers:Invalid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-		goto buff_get_phys_error;
-	} else {
-		MM_INFO("O/P buffers:valid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-	}
-	audio->phys = (int32_t)addr;
-
-	rc = ion_handle_get_flags(client, handle, &ionflag);
-	if (rc) {
-		MM_ERR("could not get flags for the handle\n");
-		goto buff_get_flags_error;
-	}
-
-	audio->map_v_read = ion_map_kernel(client, handle);
-	if (IS_ERR(audio->map_v_read)) {
-		MM_ERR("could not map write buffers\n");
-		rc = -ENOMEM;
-		goto buff_map_error;
-	}
-	audio->data = audio->map_v_read;
-	MM_DBG("write buf: phy addr 0x%08x kernel addr 0x%08x\n",
-		audio->phys, (int)audio->data);
-
-	MM_DBG("Memory addr = 0x%8x  phy addr = 0x%8x\n",\
-		(int) audio->data, (int) audio->phys);
-	if ((file->f_mode & FMODE_WRITE) &&
-			(file->f_mode & FMODE_READ)) {
-		rc = -EACCES;
-		MM_ERR("Non tunnel encoding is not supported\n");
-		goto done;
-	} else if (!(file->f_mode & FMODE_WRITE) &&
-					(file->f_mode & FMODE_READ)) {
-		audio->mode = MSM_AUD_ENC_MODE_TUNNEL;
-		MM_DBG("Opened for tunnel mode encoding\n");
-	} else {
-		rc = -EACCES;
-		goto done;
-	}
-
-
-	/* Settings will be re-config at AUDIO_SET_CONFIG,
-	 * but at least we need to have initial config
-	 */
-	audio->buffer_size = (FRAME_SIZE - 8);
-	audio->enc_type = ENC_TYPE_AMRNB | audio->mode;
-	audio->dtx_mode = -1;
-	audio->frame_format = 0;
-	audio->used_mode = 7; /* Bit Rate 12.2 kbps MR122 */
-
-	encid = audpreproc_aenc_alloc(audio->enc_type, &audio->module_name,
-			&audio->queue_ids);
-	if (encid < 0) {
-		MM_ERR("No free encoder available\n");
-		rc = -ENODEV;
-		goto done;
-	}
-	audio->enc_id = encid;
-
-	rc = msm_adsp_get(audio->module_name, &audio->audrec,
-			   &audrec_amrnb_adsp_ops, audio);
-
-	if (rc) {
-		audpreproc_aenc_free(audio->enc_id);
-		goto done;
-	}
-
-	audio->stopped = 0;
-	audio->source = 0;
-
-	audamrnb_in_flush(audio);
-
-	audio->device_events = AUDDEV_EVT_DEV_RDY | AUDDEV_EVT_DEV_RLS |
-				AUDDEV_EVT_VOICE_STATE_CHG;
-
-	audio->voice_state = msm_get_voice_state();
-	rc = auddev_register_evt_listner(audio->device_events,
-					AUDDEV_CLNT_ENC, audio->enc_id,
-					amrnb_in_listener, (void *) audio);
-	if (rc) {
-		MM_ERR("failed to register device event listener\n");
-		goto evt_error;
-	}
-	audio->build_id = socinfo_get_build_id();
-	MM_DBG("Modem build id = %s\n", audio->build_id);
-
-	file->private_data = audio;
-	audio->opened = 1;
-done:
-	mutex_unlock(&audio->lock);
-	return rc;
-evt_error:
-	msm_adsp_put(audio->audrec);
-	audpreproc_aenc_free(audio->enc_id);
-	mutex_unlock(&audio->lock);
-	ion_unmap_kernel(client, audio->buff_handle);
-buff_map_error:
-buff_get_phys_error:
-buff_get_flags_error:
-	ion_free(client, audio->buff_handle);
-buff_alloc_error:
-	ion_client_destroy(client);
-client_create_error:
-	return rc;
-}
-
-static const struct file_operations audio_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audamrnb_in_open,
-	.release	= audamrnb_in_release,
-	.read		= audamrnb_in_read,
-	.write		= audamrnb_in_write,
-	.unlocked_ioctl	= audamrnb_in_ioctl,
-};
-
-struct miscdevice audio_amrnb_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_amrnb_in",
-	.fops	= &audio_in_fops,
-};
-
-static int __init audamrnb_in_init(void)
-{
-	mutex_init(&the_audio_amrnb_in.lock);
-	mutex_init(&the_audio_amrnb_in.read_lock);
-	spin_lock_init(&the_audio_amrnb_in.dsp_lock);
-	spin_lock_init(&the_audio_amrnb_in.dev_lock);
-	init_waitqueue_head(&the_audio_amrnb_in.wait);
-	init_waitqueue_head(&the_audio_amrnb_in.wait_enable);
-	return misc_register(&audio_amrnb_in_misc);
-}
-
-device_initcall(audamrnb_in_init);
diff --git a/arch/arm/mach-msm/qdsp5v2/audio_amrwb.c b/arch/arm/mach-msm/qdsp5v2/audio_amrwb.c
deleted file mode 100644
index e5706c7..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audio_amrwb.c
+++ /dev/null
@@ -1,1726 +0,0 @@
-/* amrwb audio decoder device
- *
- * Copyright (c) 2008-2012, The Linux Foundation. All rights reserved.
- *
- * Based on the mp3 native driver in arch/arm/mach-msm/qdsp5v2/audio_mp3.c
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- *
- * All source code in this file is licensed under the following license except
- * where indicated.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you can find it at http://www.fsf.org
- */
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/list.h>
-#include <linux/earlysuspend.h>
-#include <linux/memory_alloc.h>
-#include <linux/msm_audio.h>
-#include <linux/slab.h>
-
-#include <mach/msm_adsp.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/qdsp5v2/qdsp5audppmsg.h>
-#include <mach/qdsp5v2/qdsp5audplaycmdi.h>
-#include <mach/qdsp5v2/qdsp5audplaymsg.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/qdsp5v2/audpp.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_memtypes.h>
-
-#define BUFSZ 4110 /* Hold minimum 700ms voice data and 14 bytes of meta in*/
-#define DMASZ (BUFSZ * 2)
-
-#define AUDPLAY_INVALID_READ_PTR_OFFSET	0xFFFF
-#define AUDDEC_DEC_AMRWB 11
-
-#define PCM_BUFSZ_MIN 8216 /* 100ms worth of data and 24 bytes of meta out*/
-#define PCM_BUF_MAX_COUNT 5	/* DSP only accepts 5 buffers at most
-				   but support 2 buffers currently */
-#define ROUTING_MODE_FTRT 1
-#define ROUTING_MODE_RT 2
-/* Decoder status received from AUDPPTASK */
-#define  AUDPP_DEC_STATUS_SLEEP	0
-#define	 AUDPP_DEC_STATUS_INIT  1
-#define  AUDPP_DEC_STATUS_CFG   2
-#define  AUDPP_DEC_STATUS_PLAY  3
-
-#define AUDAMRWB_METAFIELD_MASK 0xFFFF0000
-#define AUDAMRWB_EOS_FLG_OFFSET 0x0A /* Offset from beginning of buffer */
-#define AUDAMRWB_EOS_FLG_MASK 0x01
-#define AUDAMRWB_EOS_NONE 0x0 /* No EOS detected */
-#define AUDAMRWB_EOS_SET 0x1 /* EOS set in meta field */
-
-#define AUDAMRWB_EVENT_NUM 10 /* Default number of pre-allocated event pkts */
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;		/* Input usage actual DSP produced PCM size  */
-	unsigned addr;
-	unsigned short mfield_sz; /*only useful for data has meta field */
-};
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-struct audamrwb_suspend_ctl {
-	struct early_suspend node;
-	struct audio *audio;
-};
-#endif
-
-struct audamrwb_event{
-	struct list_head list;
-	int event_type;
-	union msm_audio_event_payload payload;
-};
-
-struct audio {
-	struct buffer out[2];
-
-	spinlock_t dsp_lock;
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed;	/* number of buffers the dsp is waiting for */
-
-	atomic_t out_bytes;
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-
-	/* Host PCM section */
-	struct buffer in[PCM_BUF_MAX_COUNT];
-	struct mutex read_lock;
-	wait_queue_head_t read_wait;	/* Wait queue for read */
-	char *read_data;	/* pointer to reader buffer */
-	int32_t read_phys;	/* physical address of reader buffer */
-	uint8_t read_next;	/* index to input buffers to be read next */
-	uint8_t fill_next;	/* index to buffer that DSP should be filling */
-	uint8_t pcm_buf_count;	/* number of pcm buffer allocated */
-	/* ---- End of Host PCM section */
-
-	struct msm_adsp_module *audplay;
-
-	/* configuration to use on next enable */
-	uint32_t out_sample_rate;
-	uint32_t out_channel_mode;
-
-	/* data allocated for various buffers */
-	char *data;
-	int32_t phys; /* physical address of write buffer */
-
-	void *map_v_read;
-	void *map_v_write;
-
-	int mfield; /* meta field embedded in data */
-	int rflush; /* Read  flush */
-	int wflush; /* Write flush */
-	int opened;
-	int enabled;
-	int running;
-	int stopped;	/* set when stopped, cleared on flush */
-	int pcm_feedback;
-	int buf_refresh;
-	int teos; /* valid only if tunnel mode & no data left for decoder */
-	enum msm_aud_decoder_state dec_state;	/* Represents decoder state */
-	int reserved; /* A byte is being reserved */
-	char rsv_byte; /* Handle odd length user data */
-
-	const char *module_name;
-	unsigned queue_id;
-	uint16_t dec_id;
-	uint32_t read_ptr_offset;
-	int16_t source;
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	struct audamrwb_suspend_ctl suspend_ctl;
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *dentry;
-#endif
-
-	wait_queue_head_t wait;
-	struct list_head free_event_queue;
-	struct list_head event_queue;
-	wait_queue_head_t event_wait;
-	spinlock_t event_queue_lock;
-	struct mutex get_event_lock;
-	int event_abort;
-	/* AV sync Info */
-	int avsync_flag;              /* Flag to indicate feedback from DSP */
-	wait_queue_head_t avsync_wait;/* Wait queue for AV Sync Message     */
-	/* flags, 48 bits sample/bytes counter per channel */
-	uint16_t avsync[AUDPP_AVSYNC_CH_COUNT * AUDPP_AVSYNC_NUM_WORDS + 1];
-
-	uint32_t device_events;
-
-	int eq_enable;
-	int eq_needs_commit;
-	struct audpp_cmd_cfg_object_params_eqalizer eq;
-	struct audpp_cmd_cfg_object_params_volume vol_pan;
-};
-
-static int auddec_dsp_config(struct audio *audio, int enable);
-static void audpp_cmd_cfg_adec_params(struct audio *audio);
-static void audpp_cmd_cfg_routing_mode(struct audio *audio);
-static void audamrwb_send_data(struct audio *audio, unsigned needed);
-static void audamrwb_config_hostpcm(struct audio *audio);
-static void audamrwb_buffer_refresh(struct audio *audio);
-static void audamrwb_dsp_event(void *private, unsigned id, uint16_t *msg);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audamrwb_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload);
-#endif
-
-/* must be called with audio->lock held */
-static int audamrwb_enable(struct audio *audio)
-{
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	if (audio->enabled)
-		return 0;
-
-	audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-
-	if (msm_adsp_enable(audio->audplay)) {
-		MM_ERR("msm_adsp_enable(audplay) failed\n");
-		return -ENODEV;
-	}
-
-	if (audpp_enable(audio->dec_id, audamrwb_dsp_event, audio)) {
-		MM_ERR("audpp_enable() failed\n");
-		msm_adsp_disable(audio->audplay);
-		return -ENODEV;
-	}
-	audio->enabled = 1;
-	return 0;
-}
-
-static void amrwb_listner(u32 evt_id, union auddev_evt_data *evt_payload,
-			void *private_data)
-{
-	struct audio *audio = (struct audio *) private_data;
-	switch (evt_id) {
-	case AUDDEV_EVT_DEV_RDY:
-		MM_DBG("AUDDEV_EVT_DEV_RDY\n");
-		audio->source |= (0x1 << evt_payload->routing_id);
-		if (audio->running == 1 && audio->enabled == 1)
-			audpp_route_stream(audio->dec_id, audio->source);
-		break;
-	case AUDDEV_EVT_DEV_RLS:
-		MM_DBG("AUDDEV_EVT_DEV_RLS\n");
-		audio->source &= ~(0x1 << evt_payload->routing_id);
-		if (audio->running == 1 && audio->enabled == 1)
-			audpp_route_stream(audio->dec_id, audio->source);
-		break;
-	case AUDDEV_EVT_STREAM_VOL_CHG:
-		audio->vol_pan.volume = evt_payload->session_vol;
-		MM_DBG("AUDDEV_EVT_STREAM_VOL_CHG, stream vol %d\n",
-				audio->vol_pan.volume);
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		break;
-	default:
-		MM_ERR("ERROR:wrong event\n");
-		break;
-	}
-}
-
-/* must be called with audio->lock held */
-static int audamrwb_disable(struct audio *audio)
-{
-	int rc = 0;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-		auddec_dsp_config(audio, 0);
-		rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-		if (rc == 0)
-			rc = -ETIMEDOUT;
-		else if (audio->dec_state != MSM_AUD_DECODER_STATE_CLOSE)
-			rc = -EFAULT;
-		else
-			rc = 0;
-		wake_up(&audio->write_wait);
-		wake_up(&audio->read_wait);
-		msm_adsp_disable(audio->audplay);
-		audpp_disable(audio->dec_id, audio);
-		audio->out_needed = 0;
-	}
-	return rc;
-}
-
-/* ------------------- dsp --------------------- */
-static void audamrwb_update_pcm_buf_entry(struct audio *audio,
-		uint32_t *payload)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	if (audio->rflush)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < payload[1]; index++) {
-		if (audio->in[audio->fill_next].addr ==
-		    payload[2 + index * 2]) {
-			MM_DBG("audamrwb_update_pcm_buf_entry: \
-				in[%d] ready\n", audio->fill_next);
-			audio->in[audio->fill_next].used =
-			    payload[3 + index * 2];
-			if ((++audio->fill_next) == audio->pcm_buf_count)
-				audio->fill_next = 0;
-
-		} else {
-			MM_ERR("expected=%x ret=%x\n",
-				audio->in[audio->fill_next].addr,
-				payload[1 + index * 2]);
-			break;
-		}
-	}
-	if (audio->in[audio->fill_next].used == 0) {
-		audamrwb_buffer_refresh(audio);
-	} else {
-		MM_DBG("audamrwb_update_pcm_buf_entry: \
-				read cannot keep up\n");
-		audio->buf_refresh = 1;
-	}
-	wake_up(&audio->read_wait);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audplay_dsp_event(void *data, unsigned id, size_t len,
-			      void (*getevent) (void *ptr, size_t len))
-{
-	struct audio *audio = data;
-	uint32_t msg[28];
-	getevent(msg, sizeof(msg));
-
-	MM_DBG("audplay_dsp_event: msg_id=%x\n", id);
-
-	switch (id) {
-	case AUDPLAY_MSG_DEC_NEEDS_DATA:
-		audamrwb_send_data(audio, 1);
-		break;
-
-	case AUDPLAY_MSG_BUFFER_UPDATE:
-		audamrwb_update_pcm_buf_entry(audio, msg);
-		break;
-
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event:module audplaytask\n");
-		break;
-
-	default:
-		MM_DBG("unexpected message from decoder\n");
-	}
-}
-
-static void audamrwb_dsp_event(void *private, unsigned id, uint16_t *msg)
-{
-	struct audio *audio = private;
-
-	switch (id) {
-	case AUDPP_MSG_STATUS_MSG:{
-			unsigned status = msg[1];
-
-			switch (status) {
-			case AUDPP_DEC_STATUS_SLEEP: {
-				uint16_t reason = msg[2];
-				MM_DBG("decoder status:sleep reason=0x%04x\n",
-					reason);
-				if ((reason == AUDPP_MSG_REASON_MEM)
-					|| (reason ==
-					AUDPP_MSG_REASON_NODECODER)) {
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_FAILURE;
-					wake_up(&audio->wait);
-				} else if (reason == AUDPP_MSG_REASON_NONE) {
-					/* decoder is in disable state */
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_CLOSE;
-					wake_up(&audio->wait);
-				}
-				break;
-			}
-			case AUDPP_DEC_STATUS_INIT:
-				MM_DBG("decoder status: init\n");
-				if (audio->pcm_feedback)
-					audpp_cmd_cfg_routing_mode(audio);
-				else
-					audpp_cmd_cfg_adec_params(audio);
-				break;
-
-			case AUDPP_DEC_STATUS_CFG:
-				MM_DBG("decoder status: cfg\n");
-				break;
-			case AUDPP_DEC_STATUS_PLAY:
-				MM_DBG("decoder status: play\n");
-				/* send  mixer command */
-				audpp_route_stream(audio->dec_id,
-						audio->source);
-				if (audio->pcm_feedback) {
-					audamrwb_config_hostpcm(audio);
-					audamrwb_buffer_refresh(audio);
-				}
-				audio->dec_state =
-					MSM_AUD_DECODER_STATE_SUCCESS;
-				wake_up(&audio->wait);
-				break;
-			default:
-				MM_DBG("unknown decoder status\n");
-				break;
-			}
-			break;
-		}
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_DBG("CFG_MSG ENABLE\n");
-			auddec_dsp_config(audio, 1);
-			audio->out_needed = 0;
-			audio->running = 1;
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-			audpp_dsp_set_eq(audio->dec_id,	audio->eq_enable,
-					&audio->eq, POPP);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			MM_DBG("CFG_MSG DISABLE\n");
-			audio->running = 0;
-		} else {
-			MM_DBG("CFG_MSG %d?\n", msg[0]);
-		}
-		break;
-	case AUDPP_MSG_ROUTING_ACK:
-		MM_DBG("ROUTING_ACK mode=%d\n", msg[1]);
-		audpp_cmd_cfg_adec_params(audio);
-		break;
-	case AUDPP_MSG_FLUSH_ACK:
-		MM_DBG("FLUSH_ACK\n");
-		audio->wflush = 0;
-		audio->rflush = 0;
-		wake_up(&audio->write_wait);
-		if (audio->pcm_feedback)
-			audamrwb_buffer_refresh(audio);
-		break;
-	case AUDPP_MSG_PCMDMAMISSED:
-		MM_DBG("PCMDMAMISSED\n");
-		audio->teos = 1;
-		wake_up(&audio->write_wait);
-		break;
-
-	case AUDPP_MSG_AVSYNC_MSG:
-		MM_DBG("AUDPP_MSG_AVSYNC_MSG\n");
-		memcpy(&audio->avsync[0], msg, sizeof(audio->avsync));
-		audio->avsync_flag = 1;
-		wake_up(&audio->avsync_wait);
-		break;
-
-	default:
-		MM_DBG("UNKNOWN (%d)\n", id);
-	}
-
-}
-
-struct msm_adsp_ops audplay_adsp_ops_amrwb = {
-	.event = audplay_dsp_event,
-};
-
-#define audplay_send_queue0(audio, cmd, len) \
-	msm_adsp_write(audio->audplay, audio->queue_id, \
-			cmd, len)
-
-static int auddec_dsp_config(struct audio *audio, int enable)
-{
-	struct audpp_cmd_cfg_dec_type cfg_dec_cmd;
-
-	memset(&cfg_dec_cmd, 0, sizeof(cfg_dec_cmd));
-
-	cfg_dec_cmd.cmd_id = AUDPP_CMD_CFG_DEC_TYPE;
-	if (enable)
-		cfg_dec_cmd.dec_cfg = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_ENA_DEC_V | AUDDEC_DEC_AMRWB;
-	else
-		cfg_dec_cmd.dec_cfg = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_DIS_DEC_V;
-	cfg_dec_cmd.dm_mode = 0x0;
-	cfg_dec_cmd.stream_id = audio->dec_id;
-	return audpp_send_queue1(&cfg_dec_cmd, sizeof(cfg_dec_cmd));
-}
-
-static void audpp_cmd_cfg_adec_params(struct audio *audio)
-{
-	struct audpp_cmd_cfg_adec_params_amrwb cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_CMD_CFG_ADEC_PARAMS;
-	cmd.common.length = AUDPP_CMD_CFG_ADEC_PARAMS_AMRWB_LEN;
-	cmd.common.dec_id = audio->dec_id;
-	cmd.common.input_sampling_frequency = audio->out_sample_rate;
-	cmd.stereo_cfg = audio->out_channel_mode;
-	audpp_send_queue2(&cmd, sizeof(cmd));
-}
-
-static void audpp_cmd_cfg_routing_mode(struct audio *audio)
-{
-	struct audpp_cmd_routing_mode cmd;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPP_CMD_ROUTING_MODE;
-	cmd.object_number = audio->dec_id;
-	if (audio->pcm_feedback)
-		cmd.routing_mode = ROUTING_MODE_FTRT;
-	else
-		cmd.routing_mode = ROUTING_MODE_RT;
-
-	audpp_send_queue1(&cmd, sizeof(cmd));
-}
-
-static int audplay_dsp_send_data_avail(struct audio *audio,
-				       unsigned idx, unsigned len)
-{
-	struct audplay_cmd_bitstream_data_avail_nt2 cmd;
-
-	cmd.cmd_id = AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2;
-	if (audio->mfield)
-		cmd.decoder_id = AUDAMRWB_METAFIELD_MASK |
-			(audio->out[idx].mfield_sz >> 1);
-	else
-		cmd.decoder_id = audio->dec_id;
-	cmd.buf_ptr = audio->out[idx].addr;
-	cmd.buf_size = len / 2;
-	cmd.partition_number = 0;
-	return audplay_send_queue0(audio, &cmd, sizeof(cmd));
-}
-
-static void audamrwb_buffer_refresh(struct audio *audio)
-{
-	struct audplay_cmd_buffer_refresh refresh_cmd;
-
-	refresh_cmd.cmd_id = AUDPLAY_CMD_BUFFER_REFRESH;
-	refresh_cmd.num_buffers = 1;
-	refresh_cmd.buf0_address = audio->in[audio->fill_next].addr;
-	refresh_cmd.buf0_length = audio->in[audio->fill_next].size;
-	refresh_cmd.buf_read_count = 0;
-	MM_DBG("buf0_addr=%x buf0_len=%d\n", refresh_cmd.buf0_address,
-			refresh_cmd.buf0_length);
-	(void)audplay_send_queue0(audio, &refresh_cmd, sizeof(refresh_cmd));
-}
-
-static void audamrwb_config_hostpcm(struct audio *audio)
-{
-	struct audplay_cmd_hpcm_buf_cfg cfg_cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	cfg_cmd.cmd_id = AUDPLAY_CMD_HPCM_BUF_CFG;
-	cfg_cmd.max_buffers = audio->pcm_buf_count;
-	cfg_cmd.byte_swap = 0;
-	cfg_cmd.hostpcm_config = (0x8000) | (0x4000);
-	cfg_cmd.feedback_frequency = 1;
-	cfg_cmd.partition_number = 0;
-	(void)audplay_send_queue0(audio, &cfg_cmd, sizeof(cfg_cmd));
-
-}
-
-static void audamrwb_send_data(struct audio *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			MM_DBG("frame %d busy\n", audio->out_tail);
-			audplay_dsp_send_data_avail(audio, audio->out_tail,
-						    frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
- done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-
-static void audamrwb_flush(struct audio *audio)
-{
-	audio->out[0].used = 0;
-	audio->out[1].used = 0;
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->reserved = 0;
-	audio->out_needed = 0;
-	atomic_set(&audio->out_bytes, 0);
-}
-
-static void audamrwb_flush_pcm_buf(struct audio *audio)
-{
-	uint8_t index;
-
-	for (index = 0; index < PCM_BUF_MAX_COUNT; index++)
-		audio->in[index].used = 0;
-
-	audio->buf_refresh = 0;
-	audio->read_next = 0;
-	audio->fill_next = 0;
-}
-
-static void audamrwb_ioport_reset(struct audio *audio)
-{
-	/* Make sure read/write thread are free from
-	 * sleep and knowing that system is not able
-	 * to process io request at the moment
-	 */
-	wake_up(&audio->write_wait);
-	mutex_lock(&audio->write_lock);
-	audamrwb_flush(audio);
-	mutex_unlock(&audio->write_lock);
-	wake_up(&audio->read_wait);
-	mutex_lock(&audio->read_lock);
-	audamrwb_flush_pcm_buf(audio);
-	mutex_unlock(&audio->read_lock);
-	audio->avsync_flag = 1;
-	wake_up(&audio->avsync_wait);
-}
-
-static int audamrwb_events_pending(struct audio *audio)
-{
-	unsigned long flags;
-	int empty;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	empty = !list_empty(&audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	return empty || audio->event_abort;
-}
-
-static void audamrwb_reset_event_queue(struct audio *audio)
-{
-	unsigned long flags;
-	struct audamrwb_event *drv_evt;
-	struct list_head *ptr, *next;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	list_for_each_safe(ptr, next, &audio->event_queue) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audamrwb_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	list_for_each_safe(ptr, next, &audio->free_event_queue) {
-		drv_evt = list_first_entry(&audio->free_event_queue,
-				struct audamrwb_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	return;
-}
-
-static long audamrwb_process_event_req(struct audio *audio, void __user *arg)
-{
-	long rc;
-	struct msm_audio_event usr_evt;
-	struct audamrwb_event *drv_evt = NULL;
-	int timeout;
-	unsigned long flags;
-
-	if (copy_from_user(&usr_evt, arg, sizeof(struct msm_audio_event)))
-		return -EFAULT;
-
-	timeout = (int) usr_evt.timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(
-			audio->event_wait, audamrwb_events_pending(audio),
-			msecs_to_jiffies(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(
-			audio->event_wait, audamrwb_events_pending(audio));
-	}
-
-	if (rc < 0)
-		return rc;
-
-	if (audio->event_abort) {
-		audio->event_abort = 0;
-		return -ENODEV;
-	}
-
-	rc = 0;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	if (!list_empty(&audio->event_queue)) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audamrwb_event, list);
-		list_del(&drv_evt->list);
-	}
-
-	if (drv_evt) {
-		usr_evt.event_type = drv_evt->event_type;
-		usr_evt.event_payload = drv_evt->payload;
-		list_add_tail(&drv_evt->list, &audio->free_event_queue);
-	} else
-		rc = -1;
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	if (!rc && copy_to_user(arg, &usr_evt, sizeof(usr_evt)))
-		rc = -EFAULT;
-
-	return rc;
-}
-
-static int audio_enable_eq(struct audio *audio, int enable)
-{
-	if (audio->eq_enable == enable && !audio->eq_needs_commit)
-		return 0;
-
-	audio->eq_enable = enable;
-
-	if (audio->running) {
-		audpp_dsp_set_eq(audio->dec_id, enable, &audio->eq, POPP);
-		audio->eq_needs_commit = 0;
-	}
-	return 0;
-}
-
-static int audio_get_avsync_data(struct audio *audio,
-						struct msm_audio_stats *stats)
-{
-	int rc = -EINVAL;
-	unsigned long flags;
-
-	local_irq_save(flags);
-	if (audio->dec_id == audio->avsync[0] && audio->avsync_flag) {
-		/* av_sync sample count */
-		stats->sample_count = (audio->avsync[2] << 16) |
-						(audio->avsync[3]);
-
-		/* av_sync byte_count */
-		stats->byte_count = (audio->avsync[5] << 16) |
-						(audio->avsync[6]);
-
-		audio->avsync_flag = 0;
-		rc = 0;
-	}
-	local_irq_restore(flags);
-	return rc;
-
-}
-
-static long audamrwb_ioctl(struct file *file, unsigned int cmd,
-		unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = -EINVAL;
-	unsigned long flags = 0;
-	uint16_t enable_mask;
-	int enable;
-	int prev_state;
-
-	MM_DBG("cmd = %d\n", cmd);
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-
-		audio->avsync_flag = 0;
-		memset(&stats, 0, sizeof(stats));
-		if (audpp_query_avsync(audio->dec_id) < 0)
-			return rc;
-
-		rc = wait_event_interruptible_timeout(audio->avsync_wait,
-				(audio->avsync_flag == 1),
-				msecs_to_jiffies(AUDPP_AVSYNC_EVENT_TIMEOUT));
-
-		if (rc < 0)
-			return rc;
-		else if ((rc > 0) || ((rc == 0) && (audio->avsync_flag == 1))) {
-			if (audio_get_avsync_data(audio, &stats) < 0)
-				return rc;
-
-			if (copy_to_user((void *)arg, &stats, sizeof(stats)))
-				return -EFAULT;
-			return 0;
-		} else
-			return -EAGAIN;
-	}
-
-	switch (cmd) {
-	case AUDIO_ENABLE_AUDPP:
-		if (copy_from_user(&enable_mask, (void *) arg,
-						sizeof(enable_mask))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		enable = (enable_mask & EQ_ENABLE) ? 1 : 0;
-		audio_enable_eq(audio, enable);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-	case AUDIO_SET_VOLUME:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.volume = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_PAN:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.pan = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_EQ:
-		prev_state = audio->eq_enable;
-		audio->eq_enable = 0;
-		if (copy_from_user(&audio->eq.num_bands, (void *) arg,
-				sizeof(audio->eq) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2))) {
-			rc = -EFAULT;
-			break;
-		}
-		audio->eq_enable = prev_state;
-		audio->eq_needs_commit = 1;
-		rc = 0;
-		break;
-	}
-
-	if (-EINVAL != rc)
-		return rc;
-
-	if (cmd == AUDIO_GET_EVENT) {
-		MM_DBG("AUDIO_GET_EVENT\n");
-		if (mutex_trylock(&audio->get_event_lock)) {
-			rc = audamrwb_process_event_req(audio,
-					(void __user *) arg);
-			mutex_unlock(&audio->get_event_lock);
-		} else
-			rc = -EBUSY;
-		return rc;
-	}
-
-	if (cmd == AUDIO_ABORT_GET_EVENT) {
-		audio->event_abort = 1;
-		wake_up(&audio->event_wait);
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		MM_DBG("AUDIO_START\n");
-		rc = audamrwb_enable(audio);
-		if (!rc) {
-			rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-			MM_INFO("dec_state %d rc = %d\n", audio->dec_state, rc);
-
-			if (audio->dec_state != MSM_AUD_DECODER_STATE_SUCCESS)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		break;
-	case AUDIO_STOP:
-		MM_DBG("AUDIO_STOP\n");
-		rc = audamrwb_disable(audio);
-		audio->stopped = 1;
-		audamrwb_ioport_reset(audio);
-		audio->stopped = 0;
-		break;
-	case AUDIO_FLUSH:
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audamrwb_ioport_reset(audio);
-		if (audio->running) {
-			audpp_flush(audio->dec_id);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-	case AUDIO_SET_CONFIG:{
-			struct msm_audio_config config;
-			if (copy_from_user
-			    (&config, (void *)arg, sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-			if (config.channel_count == 1)
-				config.channel_count =
-					AUDPP_CMD_PCM_INTF_MONO_V;
-			else if (config.channel_count == 2)
-				config.channel_count =
-					AUDPP_CMD_PCM_INTF_STEREO_V;
-			else
-				rc = -EINVAL;
-			audio->out_channel_mode = config.channel_count;
-			audio->out_sample_rate = config.sample_rate;
-			audio->mfield = config.meta_field;
-			rc = 0;
-			break;
-		}
-	case AUDIO_GET_CONFIG:{
-			struct msm_audio_config config;
-			config.buffer_size = BUFSZ;
-			config.buffer_count = 2;
-			config.sample_rate = audio->out_sample_rate;
-			if (audio->out_channel_mode ==
-					AUDPP_CMD_PCM_INTF_MONO_V)
-				config.channel_count = 1;
-			else
-				config.channel_count = 2;
-			config.meta_field = 0;
-			config.unused[0] = 0;
-			config.unused[1] = 0;
-			config.unused[2] = 0;
-			if (copy_to_user((void *)arg, &config,
-					 sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-
-			break;
-		}
-	case AUDIO_GET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			config.pcm_feedback = 0;
-			config.buffer_count = PCM_BUF_MAX_COUNT;
-			config.buffer_size = PCM_BUFSZ_MIN;
-			if (copy_to_user((void *)arg, &config,
-					 sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_SET_PCM_CONFIG:{
-		struct msm_audio_pcm_config config;
-		if (copy_from_user
-		    (&config, (void *)arg, sizeof(config))) {
-			rc = -EFAULT;
-			break;
-		}
-		if ((config.buffer_count > PCM_BUF_MAX_COUNT) ||
-		    (config.buffer_count == 1))
-			config.buffer_count = PCM_BUF_MAX_COUNT;
-
-		if (config.buffer_size < PCM_BUFSZ_MIN)
-			config.buffer_size = PCM_BUFSZ_MIN;
-
-			/* Check if pcm feedback is required */
-		if ((config.pcm_feedback) && (!audio->read_data)) {
-			MM_DBG("allocate PCM buf %d\n", config.buffer_count *
-					config.buffer_size);
-			audio->read_phys = allocate_contiguous_ebi_nomap(
-						config.buffer_size *
-						config.buffer_count,
-						SZ_4K);
-			if (!audio->read_phys) {
-					rc = -ENOMEM;
-					break;
-			}
-			audio->map_v_read = ioremap(
-						audio->read_phys,
-						config.buffer_size *
-						config.buffer_count);
-			if (IS_ERR(audio->map_v_read)) {
-				MM_ERR("Error could not map read"
-							" phys address\n");
-				rc = -ENOMEM;
-				free_contiguous_memory_by_paddr(
-							audio->read_phys);
-			} else {
-				uint8_t index;
-				uint32_t offset = 0;
-				audio->read_data = audio->map_v_read;
-				audio->pcm_feedback = 1;
-				audio->buf_refresh = 0;
-				audio->pcm_buf_count =
-					config.buffer_count;
-				audio->read_next = 0;
-				audio->fill_next = 0;
-
-				for (index = 0;
-				index < config.buffer_count; index++) {
-					audio->in[index].data =
-						audio->read_data + offset;
-					audio->in[index].addr =
-					    audio->read_phys + offset;
-					audio->in[index].size =
-					    config.buffer_size;
-					audio->in[index].used = 0;
-					offset += config.buffer_size;
-				}
-				MM_DBG("read buf: phy addr 0x%08x \
-						kernel addr 0x%08x\n",
-						audio->read_phys,
-						(int)audio->read_data);
-				rc = 0;
-			}
-		} else {
-			rc = 0;
-		}
-		break;
-	}
-	case AUDIO_GET_SESSION_ID:
-		if (copy_to_user((void *) arg, &audio->dec_id,
-					sizeof(unsigned short)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-/* Only useful in tunnel-mode */
-static int audamrwb_fsync(struct file *file, loff_t ppos1, loff_t ppos2, int datasync)
-{
-	struct audio *audio = file->private_data;
-	struct buffer *frame;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	if (!audio->running || audio->pcm_feedback) {
-		rc = -EINVAL;
-		goto done_nolock;
-	}
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(!audio->out[0].used &&
-		!audio->out[1].used &&
-		audio->out_needed) || audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (audio->reserved) {
-		MM_DBG("send reserved byte\n");
-		frame = audio->out + audio->out_tail;
-		((char *) frame->data)[0] = audio->rsv_byte;
-		((char *) frame->data)[1] = 0;
-		frame->used = 2;
-		audamrwb_send_data(audio, 0);
-
-		rc = wait_event_interruptible(audio->write_wait,
-			(!audio->out[0].used &&
-			!audio->out[1].used &&
-			audio->out_needed) || audio->wflush);
-
-		if (rc < 0)
-			goto done;
-		else if (audio->wflush) {
-			rc = -EBUSY;
-			goto done;
-		}
-	}
-
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		audio->teos || audio->wflush);
-
-	if (audio->wflush)
-		rc = -EBUSY;
-
-done:
-	mutex_unlock(&audio->write_lock);
-done_nolock:
-	return rc;
-}
-
-static ssize_t audamrwb_read(struct file *file, char __user *buf, size_t count,
-			  loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	int rc = 0;
-
-	if (!audio->pcm_feedback)
-		return 0; /* PCM feedback is not enabled. Nothing to read */
-
-	mutex_lock(&audio->read_lock);
-	MM_DBG("count %d\n", count);
-	while (count > 0) {
-		rc = wait_event_interruptible(audio->read_wait,
-			(audio->in[audio->read_next].used > 0) ||
-			(audio->stopped) || (audio->rflush));
-
-		if (rc < 0)
-			break;
-
-		if (audio->stopped || audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (count < audio->in[audio->read_next].used) {
-			/* Read must happen in frame boundary. Since driver does
-			 * not know frame size, read count must be greater or
-			 * equal to size of PCM samples
-			 */
-			MM_DBG("read stop - partial frame\n");
-			break;
-		} else {
-			MM_DBG("read from in[%d]\n", audio->read_next);
-
-			if (copy_to_user
-			    (buf, audio->in[audio->read_next].data,
-			     audio->in[audio->read_next].used)) {
-				MM_ERR("invalid addr %x\n", (unsigned int)buf);
-				rc = -EFAULT;
-				break;
-			}
-			count -= audio->in[audio->read_next].used;
-			buf += audio->in[audio->read_next].used;
-			audio->in[audio->read_next].used = 0;
-			if ((++audio->read_next) == audio->pcm_buf_count)
-				audio->read_next = 0;
-			break;
-		}
-	}
-
-	/* don't feed output buffer to HW decoder during flushing
-	 * buffer refresh command will be sent once flush completes
-	 * send buf refresh command here can confuse HW decoder
-	 */
-	if (audio->buf_refresh && !audio->rflush) {
-		audio->buf_refresh = 0;
-		MM_DBG("kick start pcm feedback again\n");
-		audamrwb_buffer_refresh(audio);
-	}
-
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		rc = buf - start;
-
-	MM_DBG("read %d bytes\n", rc);
-	return rc;
-}
-
-static int audamrwb_process_eos(struct audio *audio,
-		const char __user *buf_start, unsigned short mfield_size)
-{
-	struct buffer *frame;
-	char *buf_ptr;
-	int rc = 0;
-
-	MM_DBG("signal input EOS reserved=%d\n", audio->reserved);
-	if (audio->reserved) {
-		MM_DBG("Pass reserve byte\n");
-		frame = audio->out + audio->out_head;
-		buf_ptr = frame->data;
-		rc = wait_event_interruptible(audio->write_wait,
-					(frame->used == 0)
-					|| (audio->stopped)
-					|| (audio->wflush));
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-	buf_ptr[0] = audio->rsv_byte;
-	buf_ptr[1] = 0;
-	audio->out_head ^= 1;
-	frame->mfield_sz = 0;
-	audio->reserved = 0;
-	frame->used = 2;
-	audamrwb_send_data(audio, 0);
-	}
-
-	MM_DBG("Now signal input EOS after reserved bytes %d %d %d\n",
-		audio->out[0].used, audio->out[1].used, audio->out_needed);
-
-	frame = audio->out + audio->out_head;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	audamrwb_send_data(audio, 0);
-
-done:
-	return rc;
-}
-
-static ssize_t audamrwb_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	size_t xfer;
-	char *cpy_ptr;
-	int rc = 0, eos_condition = AUDAMRWB_EOS_NONE;
-	unsigned short mfield_size = 0;
-	unsigned dsize;
-
-	MM_DBG("cnt=%d\n", count);
-
-	mutex_lock(&audio->write_lock);
-	while (count > 0) {
-		frame = audio->out + audio->out_head;
-		cpy_ptr = frame->data;
-		dsize = 0;
-		rc = wait_event_interruptible(audio->write_wait,
-					      (frame->used == 0)
-						|| (audio->stopped)
-						|| (audio->wflush));
-
-		MM_DBG("buffer available\n");
-		if (rc < 0)
-			break;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (audio->mfield) {
-			if (buf == start) {
-				/* Processing beginning of user buffer */
-				if (__get_user(mfield_size,
-					(unsigned short __user *) buf)) {
-					rc = -EFAULT;
-					break;
-				} else 	if (mfield_size > count) {
-					rc = -EINVAL;
-					break;
-				}
-				MM_DBG("mf offset_val %x\n", mfield_size);
-				if (copy_from_user(cpy_ptr, buf, mfield_size)) {
-					rc = -EFAULT;
-					break;
-				}
-				/* Check if EOS flag is set and buffer
-				 * contains just meta field
-				 */
-				if (cpy_ptr[AUDAMRWB_EOS_FLG_OFFSET] &
-						AUDAMRWB_EOS_FLG_MASK) {
-					MM_DBG("eos set\n");
-					eos_condition = AUDAMRWB_EOS_SET;
-					if (mfield_size == count) {
-						buf += mfield_size;
-						break;
-					} else
-					cpy_ptr[AUDAMRWB_EOS_FLG_OFFSET] &=
-							~AUDAMRWB_EOS_FLG_MASK;
-				}
-				cpy_ptr += mfield_size;
-				count -= mfield_size;
-				dsize += mfield_size;
-				buf += mfield_size;
-			} else {
-				mfield_size = 0;
-				MM_DBG("continuous buffer\n");
-			}
-			frame->mfield_sz = mfield_size;
-		}
-
-		if (audio->reserved) {
-			MM_DBG("append reserved byte %x\n", audio->rsv_byte);
-			*cpy_ptr = audio->rsv_byte;
-			xfer = (count > ((frame->size - mfield_size) - 1)) ?
-				((frame->size - mfield_size) - 1) : count;
-			cpy_ptr++;
-			dsize += 1;
-			audio->reserved = 0;
-		} else
-			xfer = (count > (frame->size - mfield_size)) ?
-				(frame->size - mfield_size) : count;
-
-		if (copy_from_user(cpy_ptr, buf, xfer)) {
-			rc = -EFAULT;
-			break;
-		}
-
-		dsize += xfer;
-		if (dsize & 1) {
-			audio->rsv_byte = ((char *) frame->data)[dsize - 1];
-			MM_DBG("odd length buf reserve last byte %x\n",
-					audio->rsv_byte);
-			audio->reserved = 1;
-			dsize--;
-		}
-		count -= xfer;
-		buf += xfer;
-
-		if (dsize > 0) {
-			audio->out_head ^= 1;
-			frame->used = dsize;
-			audamrwb_send_data(audio, 0);
-		}
-	}
-	MM_DBG("eos_condition %x buf[0x%x] start[0x%x]\n", eos_condition,
-			(int) buf, (int) start);
-	if (eos_condition == AUDAMRWB_EOS_SET)
-		rc = audamrwb_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	if (!rc) {
-		if (buf > start)
-			return buf - start;
-	}
-	return rc;
-}
-
-static int audamrwb_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	MM_INFO("audio instance 0x%08x freeing\n", (int)audio);
-
-	mutex_lock(&audio->lock);
-	auddev_unregister_evt_listner(AUDDEV_CLNT_DEC, audio->dec_id);
-	audamrwb_disable(audio);
-	audamrwb_flush(audio);
-	audamrwb_flush_pcm_buf(audio);
-	msm_adsp_put(audio->audplay);
-	audpp_adec_free(audio->dec_id);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	unregister_early_suspend(&audio->suspend_ctl.node);
-#endif
-	audio->event_abort = 1;
-	wake_up(&audio->event_wait);
-	audamrwb_reset_event_queue(audio);
-	iounmap(audio->map_v_write);
-	free_contiguous_memory_by_paddr(audio->phys);
-	if (audio->read_data) {
-		iounmap(audio->map_v_read);
-		free_contiguous_memory_by_paddr(audio->read_phys);
-	}
-	mutex_unlock(&audio->lock);
-#ifdef CONFIG_DEBUG_FS
-	if (audio->dentry)
-		debugfs_remove(audio->dentry);
-#endif
-	kfree(audio);
-	return 0;
-}
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audamrwb_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload)
-{
-	struct audamrwb_event *e_node = NULL;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-
-	if (!list_empty(&audio->free_event_queue)) {
-		e_node = list_first_entry(&audio->free_event_queue,
-				struct audamrwb_event, list);
-		list_del(&e_node->list);
-	} else {
-		e_node = kmalloc(sizeof(struct audamrwb_event), GFP_ATOMIC);
-		if (!e_node) {
-			MM_ERR("No mem to post event %d\n", type);
-			return;
-		}
-	}
-
-	e_node->event_type = type;
-	e_node->payload = payload;
-
-	list_add_tail(&e_node->list, &audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	wake_up(&audio->event_wait);
-}
-
-static void audamrwb_suspend(struct early_suspend *h)
-{
-	struct audamrwb_suspend_ctl *ctl =
-		container_of(h, struct audamrwb_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audamrwb_post_event(ctl->audio, AUDIO_EVENT_SUSPEND, payload);
-}
-
-static void audamrwb_resume(struct early_suspend *h)
-{
-	struct audamrwb_suspend_ctl *ctl =
-		container_of(h, struct audamrwb_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audamrwb_post_event(ctl->audio, AUDIO_EVENT_RESUME, payload);
-}
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-static ssize_t audamrwb_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static ssize_t audamrwb_debug_read(struct file *file, char __user *buf,
-					size_t count, loff_t *ppos)
-{
-	const int debug_bufmax = 1024;
-	static char buffer[1024];
-	int n = 0, i;
-	struct audio *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	n = scnprintf(buffer, debug_bufmax, "opened %d\n", audio->opened);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"enabled %d\n", audio->enabled);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"stopped %d\n", audio->stopped);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_feedback %d\n", audio->pcm_feedback);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_buf_sz %d\n", audio->out[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_buf_count %d \n", audio->pcm_buf_count);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_buf_sz %d \n", audio->in[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"volume %x \n", audio->vol_pan.volume);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"sample rate %d \n", audio->out_sample_rate);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"channel mode %d \n", audio->out_channel_mode);
-	mutex_unlock(&audio->lock);
-	/* Following variables are only useful for debugging when
-	 * when playback halts unexpectedly. Thus, no mutual exclusion
-	 * enforced
-	 */
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"wflush %d\n", audio->wflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"rflush %d\n", audio->rflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"running %d \n", audio->running);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"dec state %d \n", audio->dec_state);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_needed %d \n", audio->out_needed);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_head %d \n", audio->out_head);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_tail %d \n", audio->out_tail);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out[0].used %d \n", audio->out[0].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out[1].used %d \n", audio->out[1].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"buffer_refresh %d \n", audio->buf_refresh);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"read_next %d \n", audio->read_next);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"fill_next %d \n", audio->fill_next);
-	for (i = 0; i < audio->pcm_buf_count; i++)
-		n += scnprintf(buffer + n, debug_bufmax - n,
-				"in[%d].used %d \n", i, audio->in[i].used);
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations audamrwb_debug_fops = {
-	.read = audamrwb_debug_read,
-	.open = audamrwb_debug_open,
-};
-#endif
-
-static int audamrwb_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = NULL;
-	int rc, dec_attrb, decid, i;
-	struct audamrwb_event *e_node = NULL;
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_amrwb_" + 5];
-#endif
-
-	/* Allocate Mem for audio instance */
-	audio = kzalloc(sizeof(struct audio), GFP_KERNEL);
-	if (!audio) {
-		MM_ERR("no memory to allocate audio instance\n");
-		rc = -ENOMEM;
-		goto done;
-	}
-	MM_INFO("audio instance 0x%08x created\n", (int)audio);
-
-	/* Allocate the decoder */
-	dec_attrb = AUDDEC_DEC_AMRWB;
-	if (file->f_mode & FMODE_READ)
-		dec_attrb |= MSM_AUD_MODE_NONTUNNEL;
-	else
-		dec_attrb |= MSM_AUD_MODE_TUNNEL;
-
-	decid = audpp_adec_alloc(dec_attrb, &audio->module_name,
-			&audio->queue_id);
-
-	if (decid < 0) {
-		MM_ERR("No free decoder available, freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENODEV;
-		kfree(audio);
-		goto done;
-	}
-
-	audio->dec_id = decid & MSM_AUD_DECODER_MASK;
-
-	audio->phys = allocate_contiguous_ebi_nomap(DMASZ, SZ_4K);
-	if (!audio->phys) {
-		MM_ERR("could not allocate write buffers, freeing instance \
-				0x%08x\n", (int)audio);
-		rc = -ENOMEM;
-		audpp_adec_free(audio->dec_id);
-		kfree(audio);
-		goto done;
-	} else {
-		audio->map_v_write = ioremap(audio->phys, DMASZ);
-		if (IS_ERR(audio->map_v_write)) {
-			MM_ERR("could not map write phys buffers, freeing \
-					instance 0x%08x\n", (int)audio);
-			rc = -ENOMEM;
-			free_contiguous_memory_by_paddr(audio->phys);
-			audpp_adec_free(audio->dec_id);
-			kfree(audio);
-			goto done;
-		}
-		audio->data = audio->map_v_write;
-		MM_DBG("write buf: phy addr 0x%08x kernel addr 0x%08x\n",
-				audio->phys, (int)audio->data);
-	}
-
-	rc = msm_adsp_get(audio->module_name, &audio->audplay,
-		&audplay_adsp_ops_amrwb, audio);
-	if (rc) {
-		MM_ERR("failed to get %s module freeing instance 0x%08x\n",
-				audio->module_name, (int)audio);
-		goto err;
-	}
-
-	mutex_init(&audio->lock);
-	mutex_init(&audio->write_lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->get_event_lock);
-	spin_lock_init(&audio->dsp_lock);
-	spin_lock_init(&audio->event_queue_lock);
-	INIT_LIST_HEAD(&audio->free_event_queue);
-	INIT_LIST_HEAD(&audio->event_queue);
-	init_waitqueue_head(&audio->write_wait);
-	init_waitqueue_head(&audio->read_wait);
-	init_waitqueue_head(&audio->wait);
-	init_waitqueue_head(&audio->event_wait);
-	init_waitqueue_head(&audio->avsync_wait);
-
-	audio->out[0].data = audio->data + 0;
-	audio->out[0].addr = audio->phys + 0;
-	audio->out[0].size = BUFSZ;
-
-	audio->out[1].data = audio->data + BUFSZ;
-	audio->out[1].addr = audio->phys + BUFSZ;
-	audio->out[1].size = BUFSZ;
-
-	audio->vol_pan.volume = 0x2000;
-	audio->vol_pan.pan = 0x0;
-	audio->eq_enable = 0;
-	audio->out_sample_rate = 44100;
-	audio->out_channel_mode = AUDPP_CMD_PCM_INTF_STEREO_V;
-
-	audamrwb_flush(audio);
-
-	file->private_data = audio;
-	audio->opened = 1;
-	audio->event_abort = 0;
-	audio->device_events = AUDDEV_EVT_DEV_RDY
-				|AUDDEV_EVT_DEV_RLS|
-				AUDDEV_EVT_STREAM_VOL_CHG;
-
-	rc = auddev_register_evt_listner(audio->device_events,
-					AUDDEV_CLNT_DEC,
-					audio->dec_id,
-					amrwb_listner,
-					(void *)audio);
-	if (rc) {
-		MM_ERR("failed to register listner\n");
-		goto event_err;
-	}
-
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof name, "msm_amrwb_%04x", audio->dec_id);
-	audio->dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
-			NULL, (void *) audio, &audamrwb_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		MM_DBG("debugfs_create_file failed\n");
-#endif
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	audio->suspend_ctl.node.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
-	audio->suspend_ctl.node.resume = audamrwb_resume;
-	audio->suspend_ctl.node.suspend = audamrwb_suspend;
-	audio->suspend_ctl.audio = audio;
-	register_early_suspend(&audio->suspend_ctl.node);
-#endif
-	for (i = 0; i < AUDAMRWB_EVENT_NUM; i++) {
-		e_node = kmalloc(sizeof(struct audamrwb_event), GFP_KERNEL);
-		if (e_node)
-			list_add_tail(&e_node->list, &audio->free_event_queue);
-		else {
-			MM_ERR("event pkt alloc failed\n");
-			break;
-		}
-	}
-done:
-	return rc;
-event_err:
-	msm_adsp_put(audio->audplay);
-err:
-	iounmap(audio->map_v_write);
-	free_contiguous_memory_by_paddr(audio->phys);
-	audpp_adec_free(audio->dec_id);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_amrwb_fops = {
-	.owner = THIS_MODULE,
-	.open = audamrwb_open,
-	.release = audamrwb_release,
-	.read = audamrwb_read,
-	.write = audamrwb_write,
-	.unlocked_ioctl = audamrwb_ioctl,
-	.fsync = audamrwb_fsync,
-};
-
-struct miscdevice audio_amrwb_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_amrwb",
-	.fops = &audio_amrwb_fops,
-};
-
-static int __init audamrwb_init(void)
-{
-	return misc_register(&audio_amrwb_misc);
-}
-
-static void __exit audamrwb_exit(void)
-{
-	misc_deregister(&audio_amrwb_misc);
-}
-
-module_init(audamrwb_init);
-module_exit(audamrwb_exit);
-
-MODULE_DESCRIPTION("MSM AMR-WB driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5v2/audio_dev_ctl.c b/arch/arm/mach-msm/qdsp5v2/audio_dev_ctl.c
deleted file mode 100644
index b1446e8..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audio_dev_ctl.c
+++ /dev/null
@@ -1,1328 +0,0 @@
-/* Copyright (c) 2009-2011, The Linux Foundation. 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.
- *
- */
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/msm_audio.h>
-#include <asm/uaccess.h>
-#include <asm/atomic.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <linux/wait.h>
-#include <linux/sched.h>
-#include <mach/debug_mm.h>
-#include <mach/qdsp5v2/qdsp5audppmsg.h>
-#include <mach/qdsp5v2/audpp.h>
-#include <linux/slab.h>
-#include <linux/debugfs.h>
-
-#ifndef MAX
-#define  MAX(x, y) (((x) > (y)) ? (x) : (y))
-#endif
-
-
-static DEFINE_MUTEX(session_lock);
-
-struct audio_dev_ctrl_state {
-	struct msm_snddev_info *devs[AUDIO_DEV_CTL_MAX_DEV];
-	u32 num_dev;
-	atomic_t opened;
-	struct msm_snddev_info *voice_rx_dev;
-	struct msm_snddev_info *voice_tx_dev;
-	wait_queue_head_t      wait;
-};
-
-static struct audio_dev_ctrl_state audio_dev_ctrl;
-struct event_listner event;
-#define MAX_DEC_SESSIONS	7
-#define MAX_ENC_SESSIONS	3
-
-struct session_freq {
-	int freq;
-	int evt;
-};
-
-
-struct audio_routing_info {
-	unsigned short mixer_mask[MAX_DEC_SESSIONS];
-	unsigned short audrec_mixer_mask[MAX_ENC_SESSIONS];
-	struct session_freq dec_freq[MAX_DEC_SESSIONS];
-	struct session_freq enc_freq[MAX_ENC_SESSIONS];
-	int dual_mic_setting[MAX_ENC_SESSIONS];
-	int voice_tx_dev_id;
-	int voice_rx_dev_id;
-	int voice_tx_sample_rate;
-	int voice_rx_sample_rate;
-	signed int voice_tx_vol;
-	signed int voice_rx_vol;
-	int tx_mute;
-	int rx_mute;
-	int voice_state;
-};
-
-static struct audio_routing_info routing_info;
-
-#ifdef CONFIG_DEBUG_FS
-
-static struct dentry *dentry;
-static int rtc_getdevice_dbg_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	MM_INFO("debug intf %s\n", (char *) file->private_data);
-	return 0;
-}
-bool is_dev_opened(u32 adb_id)
-{
-
-	int dev_id = 0;
-	struct msm_snddev_info *dev_info = NULL;
-
-	for (dev_id = 0; dev_id < audio_dev_ctrl.num_dev; dev_id++) {
-		dev_info = audio_dev_ctrl_find_dev(dev_id);
-	      if (IS_ERR(dev_info)) {
-		MM_ERR("pass invalid dev_id %d\n", dev_id);
-			  return false;
-		}
-		if (dev_info->opened && (dev_info->acdb_id == adb_id))
-			return true;
-	}
-
-  return false;
-}
-static ssize_t rtc_getdevice_dbg_read(struct file *file, char __user *buf,
-			  size_t count, loff_t *ppos)
-{
-	static char buffer[1024];
-	static char swap_buf[1024];
-	const int debug_bufmax = sizeof(buffer);
-	int n = 0;
-	int swap_count = 0;
-	int rc = 0;
-    int dev_count = 0;
-	int dev_id = 0;
-	struct msm_snddev_info *dev_info = NULL;
-
-
-	if (audio_dev_ctrl.num_dev <= 0) {
-		MM_ERR("Invalid no Device present\n");
-		dev_count = 0;
-		n = scnprintf(buffer, debug_bufmax, "DEV_NO:0x%x\n", dev_count);
-	} else {
-	for (dev_id = 0; dev_id < audio_dev_ctrl.num_dev; dev_id++) {
-		dev_info = audio_dev_ctrl_find_dev(dev_id);
-		if (IS_ERR(dev_info)) {
-			MM_ERR("pass invalid dev_id %d\n", dev_id);
-			rc = PTR_ERR(dev_info);
-			return rc;
-		}
-		if (dev_info->opened) {
-			n += scnprintf(swap_buf + n, debug_bufmax - n,
-					"ACDB_ID:0x%x;CAPB:0x%x\n",
-					dev_info->acdb_id,
-					dev_info->capability);
-		      dev_count++;
-		      MM_DBG("RTC Get Device %x COPP %x Session Mask \
-			      %x Capb %x Dev Count %x\n",
-			     dev_id , dev_info->copp_id, dev_info->sessions,
-			     dev_info->capability, dev_count);
-
-		}
-	}
-
-	swap_count = scnprintf(buffer, debug_bufmax, \
-			"DEV_NO:0x%x\n", dev_count);
-
-	memcpy(buffer+swap_count, swap_buf, n*sizeof(char));
-	n = n+swap_count;
-
-	buffer[n] = 0;
-    }
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations rtc_acdb_debug_fops = {
-	.open = rtc_getdevice_dbg_open,
-	.read = rtc_getdevice_dbg_read
-};
-#endif
-int msm_reset_all_device(void)
-{
-	int rc = 0;
-	int dev_id = 0;
-	struct msm_snddev_info *dev_info = NULL;
-
-	for (dev_id = 0; dev_id < audio_dev_ctrl.num_dev; dev_id++) {
-		dev_info = audio_dev_ctrl_find_dev(dev_id);
-		if (IS_ERR(dev_info)) {
-			MM_ERR("pass invalid dev_id %d\n", dev_id);
-			rc = PTR_ERR(dev_info);
-			return rc;
-		}
-		if (!dev_info->opened)
-			continue;
-		MM_DBG("Resetting device %d active on COPP %d"
-			"with  0x%08x as routing\n",
-				dev_id, dev_info->copp_id, dev_info->sessions);
-		broadcast_event(AUDDEV_EVT_REL_PENDING,
-					dev_id,
-					SESSION_IGNORE);
-		rc = dev_info->dev_ops.close(dev_info);
-		if (rc < 0) {
-			MM_ERR("Snd device %d failed close!\n", dev_id);
-			return rc;
-		} else {
-			dev_info->opened = 0;
-			broadcast_event(AUDDEV_EVT_DEV_RLS,
-				dev_id,
-				SESSION_IGNORE);
-		}
-		dev_info->sessions = 0;
-	}
-	return 0;
-}
-EXPORT_SYMBOL(msm_reset_all_device);
-
-int msm_set_dual_mic_config(int enc_session_id, int config)
-{
-	int i;
-	if (enc_session_id >= MAX_ENC_SESSIONS)
-		return -EINVAL;
-	/*config is set(1) dual mic recording is selected */
-	/*config is reset (0) dual mic recording is not selected*/
-	routing_info.dual_mic_setting[enc_session_id] = config;
-	for (i = 0; i < MAX_ENC_SESSIONS; i++)
-		MM_DBG("dual_mic_setting[%d] = %d\n",
-			i, routing_info.dual_mic_setting[i]);
-	return 0;
-}
-EXPORT_SYMBOL(msm_set_dual_mic_config);
-
-int msm_get_dual_mic_config(int enc_session_id)
-{
-	if (enc_session_id >= MAX_ENC_SESSIONS)
-		return -EINVAL;
-	return routing_info.dual_mic_setting[enc_session_id];
-}
-EXPORT_SYMBOL(msm_get_dual_mic_config);
-
-int msm_get_voice_state(void)
-{
-	MM_DBG("voice state %d\n", routing_info.voice_state);
-	return routing_info.voice_state;
-}
-EXPORT_SYMBOL(msm_get_voice_state);
-
-int msm_set_voice_mute(int dir, int mute)
-{
-	MM_DBG("dir %x mute %x\n", dir, mute);
-	if (!audio_dev_ctrl.voice_rx_dev
-		|| !audio_dev_ctrl.voice_tx_dev)
-		return -EPERM;
-	if (dir == DIR_TX) {
-		routing_info.tx_mute = mute;
-		broadcast_event(AUDDEV_EVT_DEVICE_VOL_MUTE_CHG,
-			routing_info.voice_tx_dev_id, SESSION_IGNORE);
-	} else
-		return -EPERM;
-	return 0;
-}
-EXPORT_SYMBOL(msm_set_voice_mute);
-
-int msm_set_voice_vol(int dir, s32 volume)
-{
-	if (!audio_dev_ctrl.voice_rx_dev
-		|| !audio_dev_ctrl.voice_tx_dev)
-		return -EPERM;
-	if (dir == DIR_TX) {
-		routing_info.voice_tx_vol = volume;
-		broadcast_event(AUDDEV_EVT_DEVICE_VOL_MUTE_CHG,
-					routing_info.voice_tx_dev_id,
-					SESSION_IGNORE);
-	} else if (dir == DIR_RX) {
-		routing_info.voice_rx_vol = volume;
-		broadcast_event(AUDDEV_EVT_DEVICE_VOL_MUTE_CHG,
-					routing_info.voice_rx_dev_id,
-					SESSION_IGNORE);
-	} else
-		return -EINVAL;
-	return 0;
-}
-EXPORT_SYMBOL(msm_set_voice_vol);
-
-void msm_snddev_register(struct msm_snddev_info *dev_info)
-{
-	mutex_lock(&session_lock);
-	if (audio_dev_ctrl.num_dev < AUDIO_DEV_CTL_MAX_DEV) {
-		audio_dev_ctrl.devs[audio_dev_ctrl.num_dev] = dev_info;
-		dev_info->dev_volume = 50; /* 50%  */
-		dev_info->sessions = 0x0;
-		dev_info->usage_count = 0;
-		dev_info->set_sample_rate = 0;
-		audio_dev_ctrl.num_dev++;
-	} else
-		MM_ERR("%s: device registry max out\n", __func__);
-	mutex_unlock(&session_lock);
-}
-EXPORT_SYMBOL(msm_snddev_register);
-
-int msm_snddev_devcount(void)
-{
-	return audio_dev_ctrl.num_dev;
-}
-EXPORT_SYMBOL(msm_snddev_devcount);
-
-int msm_snddev_query(int dev_id)
-{
-	if (dev_id <= audio_dev_ctrl.num_dev)
-			return 0;
-	return -ENODEV;
-}
-EXPORT_SYMBOL(msm_snddev_query);
-
-int msm_snddev_is_set(int popp_id, int copp_id)
-{
-	return routing_info.mixer_mask[popp_id] & (0x1 << copp_id);
-}
-EXPORT_SYMBOL(msm_snddev_is_set);
-
-unsigned short msm_snddev_route_enc(int enc_id)
-{
-	if (enc_id >= MAX_ENC_SESSIONS)
-		return -EINVAL;
-	return routing_info.audrec_mixer_mask[enc_id];
-}
-EXPORT_SYMBOL(msm_snddev_route_enc);
-
-unsigned short msm_snddev_route_dec(int popp_id)
-{
-	if (popp_id >= MAX_DEC_SESSIONS)
-		return -EINVAL;
-	return routing_info.mixer_mask[popp_id];
-}
-EXPORT_SYMBOL(msm_snddev_route_dec);
-
-int msm_snddev_set_dec(int popp_id, int copp_id, int set)
-{
-	if (set)
-		routing_info.mixer_mask[popp_id] |= (0x1 << copp_id);
-	else
-		routing_info.mixer_mask[popp_id] &= ~(0x1 << copp_id);
-
-	return 0;
-}
-EXPORT_SYMBOL(msm_snddev_set_dec);
-
-int msm_snddev_set_enc(int popp_id, int copp_id, int set)
-{
-	if (set)
-		routing_info.audrec_mixer_mask[popp_id] |= (0x1 << copp_id);
-	else
-		routing_info.audrec_mixer_mask[popp_id] &= ~(0x1 << copp_id);
-	return 0;
-}
-EXPORT_SYMBOL(msm_snddev_set_enc);
-
-int msm_device_is_voice(int dev_id)
-{
-	if ((dev_id == routing_info.voice_rx_dev_id)
-		|| (dev_id == routing_info.voice_tx_dev_id))
-		return 0;
-	else
-		return -EINVAL;
-}
-EXPORT_SYMBOL(msm_device_is_voice);
-
-int msm_set_voc_route(struct msm_snddev_info *dev_info,
-			int stream_type, int dev_id)
-{
-	int rc = 0;
-	u32 session_mask = 0;
-
-	mutex_lock(&session_lock);
-	switch (stream_type) {
-	case AUDIO_ROUTE_STREAM_VOICE_RX:
-		if (audio_dev_ctrl.voice_rx_dev)
-			audio_dev_ctrl.voice_rx_dev->sessions &= ~0xFF;
-
-		if (!(dev_info->capability & SNDDEV_CAP_RX) |
-		    !(dev_info->capability & SNDDEV_CAP_VOICE)) {
-			rc = -EINVAL;
-			break;
-		}
-		audio_dev_ctrl.voice_rx_dev = dev_info;
-		if (audio_dev_ctrl.voice_rx_dev) {
-			session_mask =
-				0x1 << (8 * ((int)AUDDEV_CLNT_VOC-1));
-			audio_dev_ctrl.voice_rx_dev->sessions |=
-				session_mask;
-		}
-		routing_info.voice_rx_dev_id = dev_id;
-		break;
-	case AUDIO_ROUTE_STREAM_VOICE_TX:
-		if (audio_dev_ctrl.voice_tx_dev)
-			audio_dev_ctrl.voice_tx_dev->sessions &= ~0xFF;
-
-		if (!(dev_info->capability & SNDDEV_CAP_TX) |
-		    !(dev_info->capability & SNDDEV_CAP_VOICE)) {
-			rc = -EINVAL;
-			break;
-		}
-
-		audio_dev_ctrl.voice_tx_dev = dev_info;
-		if (audio_dev_ctrl.voice_rx_dev) {
-			session_mask =
-				0x1 << (8 * ((int)AUDDEV_CLNT_VOC-1));
-			audio_dev_ctrl.voice_tx_dev->sessions |=
-				session_mask;
-		}
-		routing_info.voice_tx_dev_id = dev_id;
-		break;
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&session_lock);
-	return rc;
-}
-EXPORT_SYMBOL(msm_set_voc_route);
-
-void msm_release_voc_thread(void)
-{
-	wake_up(&audio_dev_ctrl.wait);
-}
-EXPORT_SYMBOL(msm_release_voc_thread);
-
-int msm_snddev_get_enc_freq(session_id)
-{
-	return routing_info.enc_freq[session_id].freq;
-}
-EXPORT_SYMBOL(msm_snddev_get_enc_freq);
-
-int msm_get_voc_freq(int *tx_freq, int *rx_freq)
-{
-	*tx_freq = routing_info.voice_tx_sample_rate;
-	*rx_freq = routing_info.voice_rx_sample_rate;
-	return 0;
-}
-EXPORT_SYMBOL(msm_get_voc_freq);
-
-int msm_get_voc_route(u32 *rx_id, u32 *tx_id)
-{
-	int rc = 0;
-
-	if (!rx_id || !tx_id)
-		return -EINVAL;
-
-	mutex_lock(&session_lock);
-	if (!audio_dev_ctrl.voice_rx_dev || !audio_dev_ctrl.voice_tx_dev) {
-		rc = -ENODEV;
-		mutex_unlock(&session_lock);
-		return rc;
-	}
-
-	*rx_id = audio_dev_ctrl.voice_rx_dev->acdb_id;
-	*tx_id = audio_dev_ctrl.voice_tx_dev->acdb_id;
-
-	mutex_unlock(&session_lock);
-
-	return rc;
-}
-EXPORT_SYMBOL(msm_get_voc_route);
-
-struct msm_snddev_info *audio_dev_ctrl_find_dev(u32 dev_id)
-{
-	struct msm_snddev_info *info;
-
-	if ((audio_dev_ctrl.num_dev - 1) < dev_id) {
-		info = ERR_PTR(-ENODEV);
-		goto error;
-	}
-
-	info = audio_dev_ctrl.devs[dev_id];
-error:
-	return info;
-
-}
-EXPORT_SYMBOL(audio_dev_ctrl_find_dev);
-
-int snddev_voice_set_volume(int vol, int path)
-{
-	if (audio_dev_ctrl.voice_rx_dev
-		&& audio_dev_ctrl.voice_tx_dev) {
-		if (path)
-			audio_dev_ctrl.voice_tx_dev->dev_volume = vol;
-		else
-			audio_dev_ctrl.voice_rx_dev->dev_volume = vol;
-	} else
-		return -ENODEV;
-	return 0;
-}
-EXPORT_SYMBOL(snddev_voice_set_volume);
-
-static int audio_dev_ctrl_get_devices(struct audio_dev_ctrl_state *dev_ctrl,
-				      void __user *arg)
-{
-	int rc = 0;
-	u32 index;
-	struct msm_snd_device_list work_list;
-	struct msm_snd_device_info *work_tbl;
-
-	if (copy_from_user(&work_list, arg, sizeof(work_list))) {
-		rc = -EFAULT;
-		goto error;
-	}
-
-	if (work_list.num_dev > dev_ctrl->num_dev) {
-		rc = -EINVAL;
-		goto error;
-	}
-
-	work_tbl = kmalloc(work_list.num_dev *
-		sizeof(struct msm_snd_device_info), GFP_KERNEL);
-	if (!work_tbl) {
-		rc = -ENOMEM;
-		goto error;
-	}
-
-	for (index = 0; index < dev_ctrl->num_dev; index++) {
-		work_tbl[index].dev_id = index;
-		work_tbl[index].dev_cap = dev_ctrl->devs[index]->capability;
-		strlcpy(work_tbl[index].dev_name, dev_ctrl->devs[index]->name,
-		64);
-	}
-
-	if (copy_to_user((void *) (work_list.list), work_tbl,
-		 work_list.num_dev * sizeof(struct msm_snd_device_info)))
-		rc = -EFAULT;
-	kfree(work_tbl);
-error:
-	return rc;
-}
-
-
-int auddev_register_evt_listner(u32 evt_id, u32 clnt_type, u32 clnt_id,
-		void (*listner)(u32 evt_id,
-			union auddev_evt_data *evt_payload,
-			void *private_data),
-		void *private_data)
-{
-	int rc;
-	struct msm_snd_evt_listner *callback = NULL;
-	struct msm_snd_evt_listner *new_cb;
-
-	new_cb = kzalloc(sizeof(struct msm_snd_evt_listner), GFP_KERNEL);
-	if (!new_cb) {
-		MM_ERR("No memory to add new listener node\n");
-		return -ENOMEM;
-	}
-
-	mutex_lock(&session_lock);
-	new_cb->cb_next = NULL;
-	new_cb->auddev_evt_listener = listner;
-	new_cb->evt_id = evt_id;
-	new_cb->clnt_type = clnt_type;
-	new_cb->clnt_id = clnt_id;
-	new_cb->private_data = private_data;
-	if (event.cb == NULL) {
-		event.cb = new_cb;
-		new_cb->cb_prev = NULL;
-	} else {
-		callback = event.cb;
-		for (; ;) {
-			if (callback->cb_next == NULL)
-				break;
-			else {
-				callback = callback->cb_next;
-				continue;
-			}
-		}
-		callback->cb_next = new_cb;
-		new_cb->cb_prev = callback;
-	}
-	event.num_listner++;
-	mutex_unlock(&session_lock);
-	rc = 0;
-	return rc;
-}
-EXPORT_SYMBOL(auddev_register_evt_listner);
-
-int auddev_unregister_evt_listner(u32 clnt_type, u32 clnt_id)
-{
-	struct msm_snd_evt_listner *callback = event.cb;
-	struct msm_snddev_info *info;
-	u32 session_mask = 0;
-	int i = 0;
-
-	mutex_lock(&session_lock);
-	while (callback != NULL) {
-		if ((callback->clnt_type == clnt_type)
-			&& (callback->clnt_id == clnt_id))
-			break;
-		 callback = callback->cb_next;
-	}
-	if (callback == NULL) {
-		mutex_unlock(&session_lock);
-		return -EINVAL;
-	}
-
-	if ((callback->cb_next == NULL) && (callback->cb_prev == NULL))
-		event.cb = NULL;
-	else if (callback->cb_next == NULL)
-		callback->cb_prev->cb_next = NULL;
-	else if (callback->cb_prev == NULL) {
-		callback->cb_next->cb_prev = NULL;
-		event.cb = callback->cb_next;
-	} else {
-		callback->cb_prev->cb_next = callback->cb_next;
-		callback->cb_next->cb_prev = callback->cb_prev;
-	}
-	kfree(callback);
-
-	session_mask = (0x1 << (clnt_id)) << (8 * ((int)clnt_type-1));
-	for (i = 0; i < audio_dev_ctrl.num_dev; i++) {
-		info = audio_dev_ctrl.devs[i];
-		info->sessions &= ~session_mask;
-	}
-	if (clnt_type == AUDDEV_CLNT_ENC)
-		msm_set_dual_mic_config(clnt_id, 0);
-	mutex_unlock(&session_lock);
-	return 0;
-}
-EXPORT_SYMBOL(auddev_unregister_evt_listner);
-
-int msm_snddev_withdraw_freq(u32 session_id, u32 capability, u32 clnt_type)
-{
-	int i = 0;
-	struct msm_snddev_info *info;
-	u32 session_mask = 0;
-
-	if ((clnt_type == AUDDEV_CLNT_VOC) && (session_id != 0))
-		return -EINVAL;
-	if ((clnt_type == AUDDEV_CLNT_DEC)
-			&& (session_id >= MAX_DEC_SESSIONS))
-		return -EINVAL;
-	if ((clnt_type == AUDDEV_CLNT_ENC)
-			&& (session_id >= MAX_ENC_SESSIONS))
-		return -EINVAL;
-
-	session_mask = (0x1 << (session_id)) << (8 * ((int)clnt_type-1));
-
-	for (i = 0; i < audio_dev_ctrl.num_dev; i++) {
-		info = audio_dev_ctrl.devs[i];
-		if ((info->sessions & session_mask)
-			&& (info->capability & capability)) {
-			if (!(info->sessions & ~(session_mask)))
-				info->set_sample_rate = 0;
-		}
-	}
-	if (clnt_type == AUDDEV_CLNT_DEC)
-		routing_info.dec_freq[session_id].freq
-					= 0;
-	else if (clnt_type == AUDDEV_CLNT_ENC)
-		routing_info.enc_freq[session_id].freq
-					= 0;
-	else if (capability == SNDDEV_CAP_TX)
-		routing_info.voice_tx_sample_rate = 0;
-	else
-		routing_info.voice_rx_sample_rate = 48000;
-	return 0;
-}
-
-int msm_snddev_request_freq(int *freq, u32 session_id,
-			u32 capability, u32 clnt_type)
-{
-	int i = 0;
-	int rc = 0;
-	struct msm_snddev_info *info;
-	u32 set_freq;
-	u32 session_mask = 0;
-	u32 clnt_type_mask = 0;
-
-	MM_DBG(": clnt_type 0x%08x\n", clnt_type);
-
-	if ((clnt_type == AUDDEV_CLNT_VOC) && (session_id != 0))
-		return -EINVAL;
-	if ((clnt_type == AUDDEV_CLNT_DEC)
-			&& (session_id >= MAX_DEC_SESSIONS))
-		return -EINVAL;
-	if ((clnt_type == AUDDEV_CLNT_ENC)
-			&& (session_id >= MAX_ENC_SESSIONS))
-		return -EINVAL;
-	session_mask = ((0x1 << session_id)) << (8 * (clnt_type-1));
-	clnt_type_mask = (0xFF << (8 * (clnt_type-1)));
-	if (!(*freq == 8000) && !(*freq == 11025) &&
-		!(*freq == 12000) && !(*freq == 16000) &&
-		!(*freq == 22050) && !(*freq == 24000) &&
-		!(*freq == 32000) && !(*freq == 44100) &&
-		!(*freq == 48000))
-		return -EINVAL;
-
-	for (i = 0; i < audio_dev_ctrl.num_dev; i++) {
-		info = audio_dev_ctrl.devs[i];
-		if ((info->sessions & session_mask)
-			&& (info->capability & capability)) {
-			rc = 0;
-			if ((info->sessions & ~clnt_type_mask)
-				&& ((*freq != 8000) && (*freq != 16000)
-					&& (*freq != 48000))) {
-				if (clnt_type == AUDDEV_CLNT_ENC) {
-					routing_info.enc_freq[session_id].freq
-							= 0;
-					return -EPERM;
-				} else if (clnt_type == AUDDEV_CLNT_DEC) {
-					routing_info.dec_freq[session_id].freq
-							= 0;
-					return -EPERM;
-				}
-			}
-			if (*freq == info->set_sample_rate) {
-				rc = info->set_sample_rate;
-				continue;
-			}
-			set_freq = MAX(*freq, info->set_sample_rate);
-
-
-			if (clnt_type == AUDDEV_CLNT_DEC)
-				routing_info.dec_freq[session_id].freq
-						= set_freq;
-			else if (clnt_type == AUDDEV_CLNT_ENC)
-				routing_info.enc_freq[session_id].freq
-						= set_freq;
-			else if (capability == SNDDEV_CAP_TX)
-				routing_info.voice_tx_sample_rate = set_freq;
-
-			rc = set_freq;
-			*freq = set_freq;
-			/* There is difference in device sample rate to
-			 * requested sample rate. So update device sample rate
-			 * and propagate sample rate change event to active
-			 * sessions of the device.
-			 */
-			if (info->set_sample_rate != set_freq) {
-				info->set_sample_rate = set_freq;
-				if (info->opened) {
-					/* Ignore propagating sample rate
-					 * change event to requested client
-					 * session
-					 */
-					if (clnt_type == AUDDEV_CLNT_DEC)
-						routing_info.\
-						dec_freq[session_id].evt = 1;
-					else if (clnt_type == AUDDEV_CLNT_ENC)
-						routing_info.\
-						enc_freq[session_id].evt = 1;
-					broadcast_event(AUDDEV_EVT_FREQ_CHG, i,
-								SESSION_IGNORE);
-					set_freq = info->dev_ops.set_freq(info,
-								set_freq);
-					broadcast_event(AUDDEV_EVT_DEV_RDY, i,
-								SESSION_IGNORE);
-				}
-			}
-		}
-		MM_DBG("info->set_sample_rate = %d\n", info->set_sample_rate);
-		MM_DBG("routing_info.enc_freq.freq = %d\n",
-					routing_info.enc_freq[session_id].freq);
-	}
-	return rc;
-}
-EXPORT_SYMBOL(msm_snddev_request_freq);
-
-int msm_snddev_enable_sidetone(u32 dev_id, u32 enable)
-{
-	int rc;
-	struct msm_snddev_info *dev_info;
-
-	MM_DBG("dev_id %d enable %d\n", dev_id, enable);
-
-	dev_info = audio_dev_ctrl_find_dev(dev_id);
-
-	if (IS_ERR(dev_info)) {
-		MM_ERR("bad dev_id %d\n", dev_id);
-		rc = -EINVAL;
-	} else if (!dev_info->dev_ops.enable_sidetone) {
-		MM_DBG("dev %d no sidetone support\n", dev_id);
-		rc = -EPERM;
-	} else
-		rc = dev_info->dev_ops.enable_sidetone(dev_info, enable);
-
-	return rc;
-}
-EXPORT_SYMBOL(msm_snddev_enable_sidetone);
-
-static long audio_dev_ctrl_ioctl(struct file *file,
-				 unsigned int cmd, unsigned long arg)
-{
-	int rc = 0;
-	struct audio_dev_ctrl_state *dev_ctrl = file->private_data;
-
-	mutex_lock(&session_lock);
-	switch (cmd) {
-	case AUDIO_GET_NUM_SND_DEVICE:
-		rc = put_user(dev_ctrl->num_dev, (uint32_t __user *) arg);
-		break;
-	case AUDIO_GET_SND_DEVICES:
-		rc = audio_dev_ctrl_get_devices(dev_ctrl, (void __user *) arg);
-		break;
-	case AUDIO_ENABLE_SND_DEVICE: {
-		struct msm_snddev_info *dev_info;
-		u32 dev_id;
-
-		if (get_user(dev_id, (u32 __user *) arg)) {
-			rc = -EFAULT;
-			break;
-		}
-		dev_info = audio_dev_ctrl_find_dev(dev_id);
-		if (IS_ERR(dev_info))
-			rc = PTR_ERR(dev_info);
-		else {
-			rc = dev_info->dev_ops.open(dev_info);
-			if (!rc)
-				dev_info->opened = 1;
-			wake_up(&audio_dev_ctrl.wait);
-		}
-		break;
-
-	}
-
-	case AUDIO_DISABLE_SND_DEVICE: {
-		struct msm_snddev_info *dev_info;
-		u32 dev_id;
-
-		if (get_user(dev_id, (u32 __user *) arg)) {
-			rc = -EFAULT;
-			break;
-		}
-		dev_info = audio_dev_ctrl_find_dev(dev_id);
-		if (IS_ERR(dev_info))
-			rc = PTR_ERR(dev_info);
-		else {
-			rc = dev_info->dev_ops.close(dev_info);
-			dev_info->opened = 0;
-		}
-		break;
-	}
-
-	case AUDIO_ROUTE_STREAM: {
-		struct msm_audio_route_config route_cfg;
-		struct msm_snddev_info *dev_info;
-
-		if (copy_from_user(&route_cfg, (void __user *) arg,
-			sizeof(struct msm_audio_route_config))) {
-			rc = -EFAULT;
-			break;
-		}
-		MM_DBG("%s: route cfg %d %d type\n", __func__,
-		route_cfg.dev_id, route_cfg.stream_type);
-		dev_info = audio_dev_ctrl_find_dev(route_cfg.dev_id);
-		if (IS_ERR(dev_info)) {
-			MM_ERR("%s: pass invalid dev_id\n", __func__);
-			rc = PTR_ERR(dev_info);
-			break;
-		}
-
-		switch (route_cfg.stream_type) {
-
-		case AUDIO_ROUTE_STREAM_VOICE_RX:
-			if (!(dev_info->capability & SNDDEV_CAP_RX) |
-			    !(dev_info->capability & SNDDEV_CAP_VOICE)) {
-				rc = -EINVAL;
-				break;
-			}
-			dev_ctrl->voice_rx_dev = dev_info;
-			break;
-		case AUDIO_ROUTE_STREAM_VOICE_TX:
-			if (!(dev_info->capability & SNDDEV_CAP_TX) |
-			    !(dev_info->capability & SNDDEV_CAP_VOICE)) {
-				rc = -EINVAL;
-				break;
-			}
-			dev_ctrl->voice_tx_dev = dev_info;
-			break;
-		}
-		break;
-	}
-
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&session_lock);
-	return rc;
-}
-
-static int audio_dev_ctrl_open(struct inode *inode, struct file *file)
-{
-	MM_DBG("open audio_dev_ctrl\n");
-	atomic_inc(&audio_dev_ctrl.opened);
-	file->private_data = &audio_dev_ctrl;
-	return 0;
-}
-
-static int audio_dev_ctrl_release(struct inode *inode, struct file *file)
-{
-	MM_DBG("release audio_dev_ctrl\n");
-	atomic_dec(&audio_dev_ctrl.opened);
-	return 0;
-}
-
-static const struct file_operations audio_dev_ctrl_fops = {
-	.owner = THIS_MODULE,
-	.open = audio_dev_ctrl_open,
-	.release = audio_dev_ctrl_release,
-	.unlocked_ioctl = audio_dev_ctrl_ioctl,
-};
-
-
-struct miscdevice audio_dev_ctrl_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_audio_dev_ctrl",
-	.fops	= &audio_dev_ctrl_fops,
-};
-
-/* session id is 32 bit routing mask per device
- * 0-7 for voice clients
- * 8-15 for Decoder clients
- * 16-23 for Encoder clients
- * 24-31 Do not care
- */
-void broadcast_event(u32 evt_id, u32 dev_id, u32 session_id)
-{
-	int clnt_id = 0, i;
-	union auddev_evt_data *evt_payload;
-	struct msm_snd_evt_listner *callback;
-	struct msm_snddev_info *dev_info = NULL;
-	u32 session_mask = 0;
-	static int pending_sent;
-
-	MM_DBG(": evt_id = %d\n", evt_id);
-
-	if ((evt_id != AUDDEV_EVT_START_VOICE)
-		&& (evt_id != AUDDEV_EVT_END_VOICE)
-		&& (evt_id != AUDDEV_EVT_STREAM_VOL_CHG)
-		&& (evt_id != AUDDEV_EVT_VOICE_STATE_CHG)) {
-		dev_info = audio_dev_ctrl_find_dev(dev_id);
-		if (IS_ERR(dev_info)) {
-			MM_ERR("pass invalid dev_id\n");
-			return;
-		}
-	}
-
-	if (event.cb != NULL)
-		callback = event.cb;
-	else
-		return;
-
-	evt_payload = kzalloc(sizeof(union auddev_evt_data),
-			GFP_KERNEL);
-	if (evt_payload == NULL) {
-		MM_ERR("Memory allocation for event payload failed\n");
-		return;
-	}
-
-	mutex_lock(&session_lock);
-
-	if (evt_id == AUDDEV_EVT_VOICE_STATE_CHG)
-		routing_info.voice_state = dev_id;
-
-	for (; ;) {
-		if (!(evt_id & callback->evt_id)) {
-			if (callback->cb_next == NULL)
-				break;
-			else {
-				callback = callback->cb_next;
-				continue;
-			}
-		}
-		clnt_id = callback->clnt_id;
-		memset(evt_payload, 0, sizeof(union auddev_evt_data));
-
-		if ((evt_id == AUDDEV_EVT_START_VOICE)
-			|| (evt_id == AUDDEV_EVT_END_VOICE))
-			goto skip_check;
-		if (callback->clnt_type == AUDDEV_CLNT_AUDIOCAL)
-			goto aud_cal;
-
-		session_mask = (0x1 << (clnt_id))
-				<< (8 * ((int)callback->clnt_type-1));
-
-		if ((evt_id == AUDDEV_EVT_STREAM_VOL_CHG) || \
-			(evt_id == AUDDEV_EVT_VOICE_STATE_CHG)) {
-			MM_DBG("AUDDEV_EVT_STREAM_VOL_CHG or\
-				AUDDEV_EVT_VOICE_STATE_CHG\n");
-			goto volume_strm;
-		}
-
-		MM_DBG("dev_info->sessions = %08x\n", dev_info->sessions);
-
-		if ((!session_id && !(dev_info->sessions & session_mask)) ||
-			(session_id && ((dev_info->sessions & session_mask) !=
-						session_id))) {
-			if (callback->cb_next == NULL)
-				break;
-			else {
-				callback = callback->cb_next;
-				continue;
-			}
-		}
-		if (evt_id == AUDDEV_EVT_DEV_CHG_VOICE)
-			goto voc_events;
-
-volume_strm:
-		if (callback->clnt_type == AUDDEV_CLNT_DEC) {
-			MM_DBG("AUDDEV_CLNT_DEC\n");
-			if (evt_id == AUDDEV_EVT_STREAM_VOL_CHG) {
-				MM_DBG("clnt_id = %d, session_id = 0x%8x\n",
-					clnt_id, session_id);
-				if (session_mask != session_id)
-					goto sent_dec;
-				else
-					evt_payload->session_vol =
-						msm_vol_ctl.volume;
-			} else if (evt_id == AUDDEV_EVT_FREQ_CHG) {
-				if (routing_info.dec_freq[clnt_id].evt) {
-					routing_info.dec_freq[clnt_id].evt
-							= 0;
-					goto sent_dec;
-				} else if (routing_info.dec_freq[clnt_id].freq
-					== dev_info->set_sample_rate)
-					goto sent_dec;
-				else {
-					evt_payload->freq_info.sample_rate
-						= dev_info->set_sample_rate;
-					evt_payload->freq_info.dev_type
-						= dev_info->capability;
-					evt_payload->freq_info.acdb_dev_id
-						= dev_info->acdb_id;
-				}
-			/* Propogate device information to client */
-			} else if (evt_id == AUDDEV_EVT_DEVICE_INFO) {
-				evt_payload->devinfo.dev_id
-					= dev_info->copp_id;
-				evt_payload->devinfo.acdb_id
-					= dev_info->acdb_id;
-				evt_payload->devinfo.dev_type =
-					(dev_info->capability & SNDDEV_CAP_TX) ?
-					SNDDEV_CAP_TX : SNDDEV_CAP_RX;
-				evt_payload->devinfo.sample_rate
-					= dev_info->sample_rate;
-				if (session_id == SESSION_IGNORE)
-					evt_payload->devinfo.sessions
-					= dev_info->sessions;
-				else
-					evt_payload->devinfo.sessions
-					= session_id;
-				evt_payload->devinfo.sessions =
-					(evt_payload->devinfo.sessions >>
-						((AUDDEV_CLNT_DEC-1) * 8));
-			} else if (evt_id == AUDDEV_EVT_VOICE_STATE_CHG)
-				evt_payload->voice_state =
-					routing_info.voice_state;
-			else
-				evt_payload->routing_id = dev_info->copp_id;
-			callback->auddev_evt_listener(
-					evt_id,
-					evt_payload,
-					callback->private_data);
-sent_dec:
-			if ((evt_id != AUDDEV_EVT_STREAM_VOL_CHG) &&
-				(evt_id != AUDDEV_EVT_VOICE_STATE_CHG))
-				routing_info.dec_freq[clnt_id].freq
-						= dev_info->set_sample_rate;
-
-			if (callback->cb_next == NULL)
-				break;
-			else {
-				callback = callback->cb_next;
-				continue;
-			}
-		}
-		if (callback->clnt_type == AUDDEV_CLNT_ENC) {
-
-			MM_DBG("AUDDEV_CLNT_ENC\n");
-			if (evt_id == AUDDEV_EVT_FREQ_CHG) {
-				if (routing_info.enc_freq[clnt_id].evt) {
-					routing_info.enc_freq[clnt_id].evt
-							= 0;
-					goto sent_enc;
-				 } else {
-					evt_payload->freq_info.sample_rate
-						= dev_info->set_sample_rate;
-					evt_payload->freq_info.dev_type
-						= dev_info->capability;
-					evt_payload->freq_info.acdb_dev_id
-						= dev_info->acdb_id;
-				}
-			/* Propogate device information to client */
-			} else if (evt_id == AUDDEV_EVT_DEVICE_INFO) {
-				evt_payload->devinfo.dev_id
-					= dev_info->copp_id;
-				evt_payload->devinfo.acdb_id
-					= dev_info->acdb_id;
-				evt_payload->devinfo.dev_type =
-					(dev_info->capability & SNDDEV_CAP_TX) ?
-					SNDDEV_CAP_TX : SNDDEV_CAP_RX;
-				evt_payload->devinfo.sample_rate
-					= dev_info->sample_rate;
-				if (session_id == SESSION_IGNORE)
-					evt_payload->devinfo.sessions
-					= dev_info->sessions;
-				else
-					evt_payload->devinfo.sessions
-					= session_id;
-				evt_payload->devinfo.sessions =
-					(evt_payload->devinfo.sessions >>
-						((AUDDEV_CLNT_ENC-1) * 8));
-			} else if (evt_id == AUDDEV_EVT_VOICE_STATE_CHG)
-				evt_payload->voice_state =
-					routing_info.voice_state;
-			else
-				evt_payload->routing_id = dev_info->copp_id;
-			callback->auddev_evt_listener(
-					evt_id,
-					evt_payload,
-					callback->private_data);
-sent_enc:
-			if (callback->cb_next == NULL)
-					break;
-			else {
-				callback = callback->cb_next;
-				continue;
-			}
-		}
-aud_cal:
-		if (callback->clnt_type == AUDDEV_CLNT_AUDIOCAL) {
-			int temp_sessions;
-			MM_DBG("AUDDEV_CLNT_AUDIOCAL\n");
-			if (evt_id == AUDDEV_EVT_VOICE_STATE_CHG)
-				evt_payload->voice_state =
-					routing_info.voice_state;
-			else if (!dev_info->sessions)
-				goto sent_aud_cal;
-			else {
-				evt_payload->audcal_info.dev_id =
-						dev_info->copp_id;
-				evt_payload->audcal_info.acdb_id =
-						dev_info->acdb_id;
-				evt_payload->audcal_info.dev_type =
-					(dev_info->capability & SNDDEV_CAP_TX) ?
-					SNDDEV_CAP_TX : SNDDEV_CAP_RX;
-				evt_payload->audcal_info.sample_rate =
-					dev_info->set_sample_rate ?
-					dev_info->set_sample_rate :
-					dev_info->sample_rate;
-			}
-			if (evt_payload->audcal_info.dev_type ==
-						SNDDEV_CAP_TX) {
-				if (session_id == SESSION_IGNORE)
-					temp_sessions = dev_info->sessions;
-				else
-					temp_sessions = session_id;
-				evt_payload->audcal_info.sessions =
-					(temp_sessions >>
-						((AUDDEV_CLNT_ENC-1) * 8));
-			} else {
-				if (session_id == SESSION_IGNORE)
-					temp_sessions = dev_info->sessions;
-				else
-					temp_sessions = session_id;
-				evt_payload->audcal_info.sessions =
-					(temp_sessions >>
-						((AUDDEV_CLNT_DEC-1) * 8));
-			}
-			callback->auddev_evt_listener(
-				evt_id,
-				evt_payload,
-				callback->private_data);
-
-sent_aud_cal:
-			if (callback->cb_next == NULL)
-				break;
-			else {
-				callback = callback->cb_next;
-				continue;
-			}
-		}
-skip_check:
-voc_events:
-		if (callback->clnt_type == AUDDEV_CLNT_VOC) {
-			MM_DBG("AUDDEV_CLNT_VOC\n");
-			if (evt_id == AUDDEV_EVT_DEV_RLS) {
-				if (!pending_sent)
-					goto sent_voc;
-				else
-					pending_sent = 0;
-			}
-			if (evt_id == AUDDEV_EVT_REL_PENDING)
-				pending_sent = 1;
-
-			if (evt_id == AUDDEV_EVT_DEVICE_VOL_MUTE_CHG) {
-				if (dev_info->capability & SNDDEV_CAP_TX) {
-					evt_payload->voc_vm_info.dev_type =
-						SNDDEV_CAP_TX;
-					evt_payload->voc_vm_info.acdb_dev_id =
-						dev_info->acdb_id;
-					evt_payload->
-					voc_vm_info.dev_vm_val.mute =
-						routing_info.tx_mute;
-				} else {
-					evt_payload->voc_vm_info.dev_type =
-						SNDDEV_CAP_RX;
-					evt_payload->voc_vm_info.acdb_dev_id =
-						dev_info->acdb_id;
-					evt_payload->
-					voc_vm_info.dev_vm_val.vol =
-						routing_info.voice_rx_vol;
-				}
-			} else if ((evt_id == AUDDEV_EVT_START_VOICE)
-					|| (evt_id == AUDDEV_EVT_END_VOICE))
-				memset(evt_payload, 0,
-					sizeof(union auddev_evt_data));
-			else if (evt_id == AUDDEV_EVT_FREQ_CHG) {
-				if (routing_info.voice_tx_sample_rate
-						!= dev_info->set_sample_rate) {
-					routing_info.voice_tx_sample_rate
-						= dev_info->set_sample_rate;
-					evt_payload->freq_info.sample_rate
-						= dev_info->set_sample_rate;
-					evt_payload->freq_info.dev_type
-						= dev_info->capability;
-					evt_payload->freq_info.acdb_dev_id
-						= dev_info->acdb_id;
-				} else
-					goto sent_voc;
-			} else if (evt_id == AUDDEV_EVT_VOICE_STATE_CHG)
-				evt_payload->voice_state =
-						routing_info.voice_state;
-			else {
-				evt_payload->voc_devinfo.dev_type =
-					(dev_info->capability & SNDDEV_CAP_TX) ?
-					SNDDEV_CAP_TX : SNDDEV_CAP_RX;
-				evt_payload->voc_devinfo.acdb_dev_id =
-					dev_info->acdb_id;
-				evt_payload->voc_devinfo.dev_sample =
-					dev_info->set_sample_rate ?
-					dev_info->set_sample_rate :
-					dev_info->sample_rate;
-				evt_payload->voc_devinfo.dev_id = dev_id;
-				if (dev_info->capability & SNDDEV_CAP_RX) {
-					for (i = 0; i < VOC_RX_VOL_ARRAY_NUM;
-						i++) {
-						evt_payload->
-						voc_devinfo.max_rx_vol[i] =
-						dev_info->max_voc_rx_vol[i];
-						evt_payload
-						->voc_devinfo.min_rx_vol[i] =
-						dev_info->min_voc_rx_vol[i];
-					}
-				}
-			}
-			callback->auddev_evt_listener(
-				evt_id,
-				evt_payload,
-				callback->private_data);
-			if (evt_id == AUDDEV_EVT_DEV_RLS)
-				dev_info->sessions &= ~(0xFF);
-sent_voc:
-			if (callback->cb_next == NULL)
-				break;
-			else {
-				callback = callback->cb_next;
-				continue;
-			}
-		}
-	}
-	kfree(evt_payload);
-	mutex_unlock(&session_lock);
-}
-EXPORT_SYMBOL(broadcast_event);
-
-
-void mixer_post_event(u32 evt_id, u32 id)
-{
-
-	MM_DBG("evt_id = %d\n", evt_id);
-	switch (evt_id) {
-	case AUDDEV_EVT_DEV_CHG_VOICE: /* Called from Voice_route */
-		broadcast_event(AUDDEV_EVT_DEV_CHG_VOICE, id, SESSION_IGNORE);
-		break;
-	case AUDDEV_EVT_DEV_RDY:
-		broadcast_event(AUDDEV_EVT_DEV_RDY, id, SESSION_IGNORE);
-		break;
-	case AUDDEV_EVT_DEV_RLS:
-		broadcast_event(AUDDEV_EVT_DEV_RLS, id, SESSION_IGNORE);
-		break;
-	case AUDDEV_EVT_REL_PENDING:
-		broadcast_event(AUDDEV_EVT_REL_PENDING, id, SESSION_IGNORE);
-		break;
-	case AUDDEV_EVT_DEVICE_VOL_MUTE_CHG:
-		broadcast_event(AUDDEV_EVT_DEVICE_VOL_MUTE_CHG, id,
-							SESSION_IGNORE);
-		break;
-	case AUDDEV_EVT_STREAM_VOL_CHG:
-		broadcast_event(AUDDEV_EVT_STREAM_VOL_CHG, id,
-							SESSION_IGNORE);
-		break;
-	case AUDDEV_EVT_START_VOICE:
-		broadcast_event(AUDDEV_EVT_START_VOICE,
-				id, SESSION_IGNORE);
-		break;
-	case AUDDEV_EVT_END_VOICE:
-		broadcast_event(AUDDEV_EVT_END_VOICE,
-				id, SESSION_IGNORE);
-		break;
-	case AUDDEV_EVT_FREQ_CHG:
-		broadcast_event(AUDDEV_EVT_FREQ_CHG, id, SESSION_IGNORE);
-		break;
-	default:
-		break;
-	}
-}
-EXPORT_SYMBOL(mixer_post_event);
-
-static int __init audio_dev_ctrl_init(void)
-{
-#ifdef CONFIG_DEBUG_FS
-	char name[sizeof "rtc_get_device"+1];
-#endif
-
-	init_waitqueue_head(&audio_dev_ctrl.wait);
-
-	event.cb = NULL;
-
-	atomic_set(&audio_dev_ctrl.opened, 0);
-	audio_dev_ctrl.num_dev = 0;
-	audio_dev_ctrl.voice_tx_dev = NULL;
-	audio_dev_ctrl.voice_rx_dev = NULL;
-	routing_info.voice_state = VOICE_STATE_INVALID;
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof name, "rtc_get_device");
-	dentry = debugfs_create_file(name, S_IFREG | S_IRUGO | S_IWUGO,
-			NULL, NULL, &rtc_acdb_debug_fops);
-	if (IS_ERR(dentry))
-		MM_DBG("debugfs_create_file failed\n");
-#endif
-
-	return misc_register(&audio_dev_ctrl_misc);
-}
-
-static void __exit audio_dev_ctrl_exit(void)
-{
-#ifdef CONFIG_DEBUG_FS
-	if (dentry)
-		debugfs_remove(dentry);
-#endif
-
-}
-module_init(audio_dev_ctrl_init);
-module_exit(audio_dev_ctrl_exit);
-
-MODULE_DESCRIPTION("MSM 7K Audio Device Control driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5v2/audio_evrc.c b/arch/arm/mach-msm/qdsp5v2/audio_evrc.c
deleted file mode 100644
index ed946f9..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audio_evrc.c
+++ /dev/null
@@ -1,1639 +0,0 @@
-/*
- * Copyright (c) 2008-2012, The Linux Foundation. All rights reserved.
- *
- * This code also borrows from audio_aac.c, which is
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you can find it at http://www.fsf.org.
- */
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/list.h>
-#include <linux/earlysuspend.h>
-#include <linux/memory_alloc.h>
-#include <linux/msm_audio.h>
-#include <linux/slab.h>
-
-#include <mach/msm_adsp.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/qdsp5v2/qdsp5audppmsg.h>
-#include <mach/qdsp5v2/qdsp5audplaycmdi.h>
-#include <mach/qdsp5v2/qdsp5audplaymsg.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/qdsp5v2/audpp.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_memtypes.h>
-
-/* Hold 30 packets of 24 bytes each and 14 bytes of meta in */
-#define BUFSZ 			734
-#define DMASZ 			(BUFSZ * 2)
-
-#define AUDDEC_DEC_EVRC 	12
-
-#define PCM_BUFSZ_MIN 		1624	/* 100ms worth of data and
-					   and 24 bytes of meta out */
-#define PCM_BUF_MAX_COUNT 	5
-/* DSP only accepts 5 buffers at most
- * but support 2 buffers currently
- */
-#define EVRC_DECODED_FRSZ 	320	/* EVRC 20ms 8KHz mono PCM size */
-
-#define ROUTING_MODE_FTRT 	1
-#define ROUTING_MODE_RT 	2
-/* Decoder status received from AUDPPTASK */
-#define  AUDPP_DEC_STATUS_SLEEP	0
-#define	 AUDPP_DEC_STATUS_INIT  1
-#define  AUDPP_DEC_STATUS_CFG   2
-#define  AUDPP_DEC_STATUS_PLAY  3
-
-#define AUDEVRC_METAFIELD_MASK 0xFFFF0000
-#define AUDEVRC_EOS_FLG_OFFSET 0x0A /* Offset from beginning of buffer */
-#define AUDEVRC_EOS_FLG_MASK 0x01
-#define AUDEVRC_EOS_NONE 0x0 /* No EOS detected */
-#define AUDEVRC_EOS_SET 0x1 /* EOS set in meta field */
-
-#define AUDEVRC_EVENT_NUM 10 /* Default number of pre-allocated event packets */
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;		/* Input usage actual DSP produced PCM size  */
-	unsigned addr;
-	unsigned short mfield_sz; /*only useful for data has meta field */
-};
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-struct audevrc_suspend_ctl {
-	struct early_suspend node;
-	struct audio *audio;
-};
-#endif
-
-struct audevrc_event{
-	struct list_head list;
-	int event_type;
-	union msm_audio_event_payload payload;
-};
-
-struct audio {
-	struct buffer out[2];
-
-	spinlock_t dsp_lock;
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed;	/* number of buffers the dsp is waiting for */
-
-	atomic_t out_bytes;
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-
-	/* Host PCM section */
-	struct buffer in[PCM_BUF_MAX_COUNT];
-	struct mutex read_lock;
-	wait_queue_head_t read_wait;	/* Wait queue for read */
-	char *read_data;	/* pointer to reader buffer */
-	int32_t read_phys;	/* physical address of reader buffer */
-	uint8_t read_next;	/* index to input buffers to be read next */
-	uint8_t fill_next;	/* index to buffer that DSP should be filling */
-	uint8_t pcm_buf_count;	/* number of pcm buffer allocated */
-	/* ---- End of Host PCM section */
-
-	struct msm_adsp_module *audplay;
-
-	/* data allocated for various buffers */
-	char *data;
-	int32_t phys;  /* physical address of write buffer */
-	void *map_v_read;
-	void *map_v_write;
-
-	int mfield; /* meta field embedded in data */
-	int rflush; /* Read  flush */
-	int wflush; /* Write flush */
-	uint8_t opened:1;
-	uint8_t enabled:1;
-	uint8_t running:1;
-	uint8_t stopped:1;	/* set when stopped, cleared on flush */
-	uint8_t pcm_feedback:1;
-	uint8_t buf_refresh:1;
-	int teos; /* valid only if tunnel mode & no data left for decoder */
-	enum msm_aud_decoder_state dec_state;	/* Represents decoder state */
-
-	const char *module_name;
-	unsigned queue_id;
-	uint16_t dec_id;
-	uint32_t read_ptr_offset;
-	int16_t source;
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	struct audevrc_suspend_ctl suspend_ctl;
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *dentry;
-#endif
-
-	wait_queue_head_t wait;
-	struct list_head free_event_queue;
-	struct list_head event_queue;
-	wait_queue_head_t event_wait;
-	spinlock_t event_queue_lock;
-	struct mutex get_event_lock;
-	int event_abort;
-	/* AV sync Info */
-	int avsync_flag;              /* Flag to indicate feedback from DSP */
-	wait_queue_head_t avsync_wait;/* Wait queue for AV Sync Message     */
-	/* flags, 48 bits sample/bytes counter per channel */
-	uint16_t avsync[AUDPP_AVSYNC_CH_COUNT * AUDPP_AVSYNC_NUM_WORDS + 1];
-
-	uint32_t device_events;
-
-	int eq_enable;
-	int eq_needs_commit;
-	struct audpp_cmd_cfg_object_params_eqalizer eq;
-	struct audpp_cmd_cfg_object_params_volume vol_pan;
-};
-
-static int auddec_dsp_config(struct audio *audio, int enable);
-static void audpp_cmd_cfg_adec_params(struct audio *audio);
-static void audpp_cmd_cfg_routing_mode(struct audio *audio);
-static void audevrc_send_data(struct audio *audio, unsigned needed);
-static void audevrc_dsp_event(void *private, unsigned id, uint16_t *msg);
-static void audevrc_config_hostpcm(struct audio *audio);
-static void audevrc_buffer_refresh(struct audio *audio);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audevrc_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload);
-#endif
-
-/* must be called with audio->lock held */
-static int audevrc_enable(struct audio *audio)
-{
-	if (audio->enabled)
-		return 0;
-
-	audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-
-	if (msm_adsp_enable(audio->audplay)) {
-		MM_ERR("msm_adsp_enable(audplay) failed\n");
-		return -ENODEV;
-	}
-
-	if (audpp_enable(audio->dec_id, audevrc_dsp_event, audio)) {
-		MM_ERR("audpp_enable() failed\n");
-		msm_adsp_disable(audio->audplay);
-		return -ENODEV;
-	}
-	audio->enabled = 1;
-	return 0;
-}
-
-static void evrc_listner(u32 evt_id, union auddev_evt_data *evt_payload,
-			void *private_data)
-{
-	struct audio *audio = (struct audio *) private_data;
-	switch (evt_id) {
-	case AUDDEV_EVT_DEV_RDY:
-		MM_DBG(":AUDDEV_EVT_DEV_RDY\n");
-		audio->source |= (0x1 << evt_payload->routing_id);
-		if (audio->running == 1 && audio->enabled == 1)
-			audpp_route_stream(audio->dec_id, audio->source);
-		break;
-	case AUDDEV_EVT_DEV_RLS:
-		MM_DBG(":AUDDEV_EVT_DEV_RLS\n");
-		audio->source &= ~(0x1 << evt_payload->routing_id);
-		if (audio->running == 1 && audio->enabled == 1)
-			audpp_route_stream(audio->dec_id, audio->source);
-		break;
-	case AUDDEV_EVT_STREAM_VOL_CHG:
-		audio->vol_pan.volume = evt_payload->session_vol;
-		MM_DBG(":AUDDEV_EVT_STREAM_VOL_CHG, stream vol %d\n",
-				audio->vol_pan.volume);
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		break;
-	default:
-		MM_ERR(":ERROR:wrong event\n");
-		break;
-	}
-}
-/* must be called with audio->lock held */
-static int audevrc_disable(struct audio *audio)
-{
-	int rc = 0;
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-		auddec_dsp_config(audio, 0);
-		rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-		if (rc == 0)
-			rc = -ETIMEDOUT;
-		else if (audio->dec_state != MSM_AUD_DECODER_STATE_CLOSE)
-			rc = -EFAULT;
-		else
-			rc = 0;
-		wake_up(&audio->write_wait);
-		wake_up(&audio->read_wait);
-		msm_adsp_disable(audio->audplay);
-		audpp_disable(audio->dec_id, audio);
-		audio->out_needed = 0;
-	}
-	return rc;
-}
-
-/* ------------------- dsp --------------------- */
-
-static void audevrc_update_pcm_buf_entry(struct audio *audio,
-					 uint32_t *payload)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	if (audio->rflush)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < payload[1]; index++) {
-		if (audio->in[audio->fill_next].addr
-				== payload[2 + index * 2]) {
-			MM_DBG("in[%d] ready\n", audio->fill_next);
-			audio->in[audio->fill_next].used =
-				payload[3 + index * 2];
-			if ((++audio->fill_next) == audio->pcm_buf_count)
-				audio->fill_next = 0;
-
-		} else {
-			MM_ERR("expected=%x ret=%x\n",
-				audio->in[audio->fill_next].addr,
-				payload[1 + index * 2]);
-			break;
-		}
-	}
-	if (audio->in[audio->fill_next].used == 0) {
-		audevrc_buffer_refresh(audio);
-	} else {
-		MM_DBG("read cannot keep up\n");
-		audio->buf_refresh = 1;
-	}
-	wake_up(&audio->read_wait);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audplay_dsp_event(void *data, unsigned id, size_t len,
-			      void (*getevent) (void *ptr, size_t len))
-{
-	struct audio *audio = data;
-	uint32_t msg[28];
-	getevent(msg, sizeof(msg));
-
-	MM_DBG("msg_id=%x\n", id);
-	switch (id) {
-	case AUDPLAY_MSG_DEC_NEEDS_DATA:
-		audevrc_send_data(audio, 1);
-		break;
-	case AUDPLAY_MSG_BUFFER_UPDATE:
-		MM_DBG("\n"); /* Macro prints the file name and function */
-		audevrc_update_pcm_buf_entry(audio, msg);
-		break;
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audplaytask)\n");
-		break;
-	default:
-		MM_ERR("unexpected message from decoder \n");
-	}
-}
-
-static void audevrc_dsp_event(void *private, unsigned id, uint16_t *msg)
-{
-	struct audio *audio = private;
-
-	switch (id) {
-	case AUDPP_MSG_STATUS_MSG:{
-			unsigned status = msg[1];
-
-			switch (status) {
-			case AUDPP_DEC_STATUS_SLEEP: {
-				uint16_t reason = msg[2];
-				MM_DBG("decoder status:sleep reason = \
-						0x%04x\n", reason);
-				if ((reason == AUDPP_MSG_REASON_MEM)
-					|| (reason ==
-					AUDPP_MSG_REASON_NODECODER)) {
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_FAILURE;
-					wake_up(&audio->wait);
-				} else if (reason == AUDPP_MSG_REASON_NONE) {
-					/* decoder is in disable state */
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_CLOSE;
-					wake_up(&audio->wait);
-				}
-				break;
-			}
-			case AUDPP_DEC_STATUS_INIT:
-				MM_DBG("decoder status: init \n");
-				if (audio->pcm_feedback)
-					audpp_cmd_cfg_routing_mode(audio);
-				else
-					audpp_cmd_cfg_adec_params(audio);
-				break;
-
-			case AUDPP_DEC_STATUS_CFG:
-				MM_DBG("decoder status: cfg \n");
-				break;
-			case AUDPP_DEC_STATUS_PLAY:
-				MM_DBG("decoder status: play \n");
-				audpp_route_stream(audio->dec_id,
-						audio->source);
-				if (audio->pcm_feedback) {
-					audevrc_config_hostpcm(audio);
-					audevrc_buffer_refresh(audio);
-				}
-				audio->dec_state =
-					MSM_AUD_DECODER_STATE_SUCCESS;
-				wake_up(&audio->wait);
-				break;
-			default:
-				MM_ERR("unknown decoder status \n");
-			}
-			break;
-		}
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_DBG("CFG_MSG ENABLE\n");
-			auddec_dsp_config(audio, 1);
-			audio->out_needed = 0;
-			audio->running = 1;
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-			audpp_dsp_set_eq(audio->dec_id,	audio->eq_enable,
-					&audio->eq, POPP);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			MM_DBG("CFG_MSG DISABLE\n");
-			audio->running = 0;
-		} else {
-			MM_DBG("CFG_MSG %d?\n", msg[0]);
-		}
-		break;
-	case AUDPP_MSG_ROUTING_ACK:
-		MM_DBG("ROUTING_ACK\n");
-		audpp_cmd_cfg_adec_params(audio);
-		break;
-	case AUDPP_MSG_FLUSH_ACK:
-		MM_DBG("FLUSH_ACK\n");
-		audio->wflush = 0;
-		audio->rflush = 0;
-		wake_up(&audio->write_wait);
-		if (audio->pcm_feedback)
-			audevrc_buffer_refresh(audio);
-		break;
-	case AUDPP_MSG_PCMDMAMISSED:
-		MM_DBG("PCMDMAMISSED\n");
-		audio->teos = 1;
-		wake_up(&audio->write_wait);
-		break;
-
-	case AUDPP_MSG_AVSYNC_MSG:
-		MM_DBG("AUDPP_MSG_AVSYNC_MSG\n");
-		memcpy(&audio->avsync[0], msg, sizeof(audio->avsync));
-		audio->avsync_flag = 1;
-		wake_up(&audio->avsync_wait);
-		break;
-
-	default:
-		MM_ERR("UNKNOWN (%d)\n", id);
-	}
-
-}
-
-struct msm_adsp_ops audplay_adsp_ops_evrc = {
-	.event = audplay_dsp_event,
-};
-
-#define audplay_send_queue0(audio, cmd, len) \
-	msm_adsp_write(audio->audplay, audio->queue_id, \
-			cmd, len)
-
-static int auddec_dsp_config(struct audio *audio, int enable)
-{
-	struct audpp_cmd_cfg_dec_type cfg_dec_cmd;
-
-	memset(&cfg_dec_cmd, 0, sizeof(cfg_dec_cmd));
-
-	cfg_dec_cmd.cmd_id = AUDPP_CMD_CFG_DEC_TYPE;
-	if (enable)
-		cfg_dec_cmd.dec_cfg = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_ENA_DEC_V | AUDDEC_DEC_EVRC;
-	else
-		cfg_dec_cmd.dec_cfg = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_DIS_DEC_V;
-	cfg_dec_cmd.dm_mode = 0x0;
-	cfg_dec_cmd.stream_id = audio->dec_id;
-
-	return audpp_send_queue1(&cfg_dec_cmd, sizeof(cfg_dec_cmd));
-}
-
-static void audpp_cmd_cfg_adec_params(struct audio *audio)
-{
-	struct audpp_cmd_cfg_adec_params_evrc cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_CMD_CFG_ADEC_PARAMS;
-	cmd.common.length = sizeof(cmd);
-	cmd.common.dec_id = audio->dec_id;
-	cmd.common.input_sampling_frequency = 8000;
-	cmd.stereo_cfg = AUDPP_CMD_PCM_INTF_MONO_V;
-
-	audpp_send_queue2(&cmd, sizeof(cmd));
-}
-
-static void audpp_cmd_cfg_routing_mode(struct audio *audio)
-{
-	struct audpp_cmd_routing_mode cmd;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPP_CMD_ROUTING_MODE;
-	cmd.object_number = audio->dec_id;
-	if (audio->pcm_feedback)
-		cmd.routing_mode = ROUTING_MODE_FTRT;
-	else
-		cmd.routing_mode = ROUTING_MODE_RT;
-
-	audpp_send_queue1(&cmd, sizeof(cmd));
-}
-
-static int audplay_dsp_send_data_avail(struct audio *audio,
-				       unsigned idx, unsigned len)
-{
-	struct audplay_cmd_bitstream_data_avail_nt2 cmd;
-
-	cmd.cmd_id = AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2;
-	if (audio->mfield)
-		cmd.decoder_id = AUDEVRC_METAFIELD_MASK |
-			(audio->out[idx].mfield_sz >> 1);
-	else
-		cmd.decoder_id = audio->dec_id;
-	cmd.buf_ptr = audio->out[idx].addr;
-	cmd.buf_size = len / 2;
-	cmd.partition_number = 0;
-	return audplay_send_queue0(audio, &cmd, sizeof(cmd));
-}
-
-static void audevrc_buffer_refresh(struct audio *audio)
-{
-	struct audplay_cmd_buffer_refresh refresh_cmd;
-
-	refresh_cmd.cmd_id = AUDPLAY_CMD_BUFFER_REFRESH;
-	refresh_cmd.num_buffers = 1;
-	refresh_cmd.buf0_address = audio->in[audio->fill_next].addr;
-	refresh_cmd.buf0_length = audio->in[audio->fill_next].size;
-
-	refresh_cmd.buf_read_count = 0;
-	MM_DBG("buf0_addr=%x buf0_len=%d\n", refresh_cmd.buf0_address,
-			refresh_cmd.buf0_length);
-	audplay_send_queue0(audio, &refresh_cmd, sizeof(refresh_cmd));
-}
-
-static void audevrc_config_hostpcm(struct audio *audio)
-{
-	struct audplay_cmd_hpcm_buf_cfg cfg_cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	cfg_cmd.cmd_id = AUDPLAY_CMD_HPCM_BUF_CFG;
-	cfg_cmd.max_buffers = 1;
-	cfg_cmd.byte_swap = 0;
-	cfg_cmd.hostpcm_config = (0x8000) | (0x4000);
-	cfg_cmd.feedback_frequency = 1;
-	cfg_cmd.partition_number = 0;
-	audplay_send_queue0(audio, &cfg_cmd, sizeof(cfg_cmd));
-
-}
-
-static void audevrc_send_data(struct audio *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			MM_DBG("frame %d free\n", audio->out_tail);
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			MM_DBG("frame %d busy\n", audio->out_tail);
-			audplay_dsp_send_data_avail(audio, audio->out_tail,
-						    frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
-done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-
-static void audevrc_flush(struct audio *audio)
-{
-	audio->out[0].used = 0;
-	audio->out[1].used = 0;
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-	atomic_set(&audio->out_bytes, 0);
-}
-
-static void audevrc_flush_pcm_buf(struct audio *audio)
-{
-	uint8_t index;
-
-	for (index = 0; index < PCM_BUF_MAX_COUNT; index++)
-		audio->in[index].used = 0;
-
-	audio->buf_refresh = 0;
-	audio->read_next = 0;
-	audio->fill_next = 0;
-}
-
-static void audevrc_ioport_reset(struct audio *audio)
-{
-	/* Make sure read/write thread are free from
-	 * sleep and knowing that system is not able
-	 * to process io request at the moment
-	 */
-	wake_up(&audio->write_wait);
-	mutex_lock(&audio->write_lock);
-	audevrc_flush(audio);
-	mutex_unlock(&audio->write_lock);
-	wake_up(&audio->read_wait);
-	mutex_lock(&audio->read_lock);
-	audevrc_flush_pcm_buf(audio);
-	mutex_unlock(&audio->read_lock);
-	audio->avsync_flag = 1;
-	wake_up(&audio->avsync_wait);
-}
-
-static int audevrc_events_pending(struct audio *audio)
-{
-	unsigned long flags;
-	int empty;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	empty = !list_empty(&audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	return empty || audio->event_abort;
-}
-
-static void audevrc_reset_event_queue(struct audio *audio)
-{
-	unsigned long flags;
-	struct audevrc_event *drv_evt;
-	struct list_head *ptr, *next;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	list_for_each_safe(ptr, next, &audio->event_queue) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audevrc_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	list_for_each_safe(ptr, next, &audio->free_event_queue) {
-		drv_evt = list_first_entry(&audio->free_event_queue,
-			struct audevrc_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	return;
-}
-
-
-static long audevrc_process_event_req(struct audio *audio, void __user *arg)
-{
-	long rc;
-	struct msm_audio_event usr_evt;
-	struct audevrc_event *drv_evt = NULL;
-	int timeout;
-	unsigned long flags;
-
-	if (copy_from_user(&usr_evt, arg, sizeof(struct msm_audio_event)))
-		return -EFAULT;
-
-	timeout = (int) usr_evt.timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(
-			audio->event_wait, audevrc_events_pending(audio),
-			msecs_to_jiffies(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(
-			audio->event_wait, audevrc_events_pending(audio));
-	}
-
-	if (rc < 0)
-		return rc;
-
-	if (audio->event_abort) {
-		audio->event_abort = 0;
-		return -ENODEV;
-	}
-
-	rc = 0;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	if (!list_empty(&audio->event_queue)) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audevrc_event, list);
-		list_del(&drv_evt->list);
-	}
-	if (drv_evt) {
-		usr_evt.event_type = drv_evt->event_type;
-		usr_evt.event_payload = drv_evt->payload;
-		list_add_tail(&drv_evt->list, &audio->free_event_queue);
-	} else
-		rc = -1;
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	if (!rc && copy_to_user(arg, &usr_evt, sizeof(usr_evt)))
-		rc = -EFAULT;
-
-	return rc;
-}
-
-static int audio_enable_eq(struct audio *audio, int enable)
-{
-	if (audio->eq_enable == enable && !audio->eq_needs_commit)
-		return 0;
-
-	audio->eq_enable = enable;
-
-	if (audio->running) {
-		audpp_dsp_set_eq(audio->dec_id, enable, &audio->eq, POPP);
-		audio->eq_needs_commit = 0;
-	}
-	return 0;
-}
-
-static int audio_get_avsync_data(struct audio *audio,
-						struct msm_audio_stats *stats)
-{
-	int rc = -EINVAL;
-	unsigned long flags;
-
-	local_irq_save(flags);
-	if (audio->dec_id == audio->avsync[0] && audio->avsync_flag) {
-		/* av_sync sample count */
-		stats->sample_count = (audio->avsync[2] << 16) |
-						(audio->avsync[3]);
-
-		/* av_sync byte_count */
-		stats->byte_count = (audio->avsync[5] << 16) |
-						(audio->avsync[6]);
-
-		audio->avsync_flag = 0;
-		rc = 0;
-	}
-	local_irq_restore(flags);
-	return rc;
-
-}
-
-static long audevrc_ioctl(struct file *file, unsigned int cmd,
-			  unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = -EINVAL;
-	unsigned long flags = 0;
-	uint16_t enable_mask;
-	int enable;
-	int prev_state;
-
-	MM_DBG("cmd = %d\n", cmd);
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-
-		audio->avsync_flag = 0;
-		memset(&stats, 0, sizeof(stats));
-		if (audpp_query_avsync(audio->dec_id) < 0)
-			return rc;
-
-		rc = wait_event_interruptible_timeout(audio->avsync_wait,
-				(audio->avsync_flag == 1),
-				msecs_to_jiffies(AUDPP_AVSYNC_EVENT_TIMEOUT));
-
-		if (rc < 0)
-			return rc;
-		else if ((rc > 0) || ((rc == 0) && (audio->avsync_flag == 1))) {
-			if (audio_get_avsync_data(audio, &stats) < 0)
-				return rc;
-
-			if (copy_to_user((void *)arg, &stats, sizeof(stats)))
-				return -EFAULT;
-			return 0;
-		} else
-			return -EAGAIN;
-	}
-
-	switch (cmd) {
-	case AUDIO_ENABLE_AUDPP:
-		if (copy_from_user(&enable_mask, (void *) arg,
-						sizeof(enable_mask))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		enable = (enable_mask & EQ_ENABLE) ? 1 : 0;
-		audio_enable_eq(audio, enable);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-	case AUDIO_SET_VOLUME:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.volume = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_PAN:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.pan = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_EQ:
-		prev_state = audio->eq_enable;
-		audio->eq_enable = 0;
-		if (copy_from_user(&audio->eq.num_bands, (void *) arg,
-				sizeof(audio->eq) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2))) {
-			rc = -EFAULT;
-			break;
-		}
-		audio->eq_enable = prev_state;
-		audio->eq_needs_commit = 1;
-		rc = 0;
-		break;
-	}
-
-	if (-EINVAL != rc)
-		return rc;
-
-	if (cmd == AUDIO_GET_EVENT) {
-		MM_DBG("AUDIO_GET_EVENT\n");
-		if (mutex_trylock(&audio->get_event_lock)) {
-			rc = audevrc_process_event_req(audio,
-					(void __user *) arg);
-			mutex_unlock(&audio->get_event_lock);
-		} else
-			rc = -EBUSY;
-		return rc;
-	}
-
-	if (cmd == AUDIO_ABORT_GET_EVENT) {
-		audio->event_abort = 1;
-		wake_up(&audio->event_wait);
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		MM_DBG("AUDIO_START\n");
-		rc = audevrc_enable(audio);
-		if (!rc) {
-			rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-			MM_INFO("dec_state %d rc = %d\n", audio->dec_state, rc);
-
-			if (audio->dec_state != MSM_AUD_DECODER_STATE_SUCCESS)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		break;
-	case AUDIO_STOP:
-		MM_DBG("AUDIO_STOP\n");
-		rc = audevrc_disable(audio);
-		audio->stopped = 1;
-		audevrc_ioport_reset(audio);
-		audio->stopped = 0;
-		break;
-	case AUDIO_FLUSH:
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audevrc_ioport_reset(audio);
-		if (audio->running) {
-			audpp_flush(audio->dec_id);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-	case AUDIO_SET_CONFIG:{
-			struct msm_audio_config config;
-			if (copy_from_user
-				(&config, (void *)arg, sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-			audio->mfield = config.meta_field;
-			rc = 0;
-			MM_DBG("AUDIO_SET_CONFIG applicable only \
-				for meta field configuration\n");
-			break;
-		}
-	case AUDIO_GET_CONFIG:{
-			struct msm_audio_config config;
-			config.buffer_size = BUFSZ;
-			config.buffer_count = 2;
-			config.sample_rate = 8000;
-			config.channel_count = 1;
-			config.meta_field = 0;
-			config.unused[0] = 0;
-			config.unused[1] = 0;
-			config.unused[2] = 0;
-			if (copy_to_user((void *)arg, &config, sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_GET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			config.pcm_feedback = audio->pcm_feedback;
-			config.buffer_count = PCM_BUF_MAX_COUNT;
-			config.buffer_size = PCM_BUFSZ_MIN;
-			if (copy_to_user((void *)arg, &config, sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_SET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			if (copy_from_user
-			    (&config, (void *)arg, sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-			if (config.pcm_feedback != audio->pcm_feedback) {
-				MM_ERR("Not sufficient permission to"
-					 "change the playback mode\n");
-				rc = -EACCES;
-				break;
-			}
-			if ((config.buffer_count > PCM_BUF_MAX_COUNT) ||
-			    (config.buffer_count == 1))
-				config.buffer_count = PCM_BUF_MAX_COUNT;
-
-			if (config.buffer_size < PCM_BUFSZ_MIN)
-				config.buffer_size = PCM_BUFSZ_MIN;
-
-			/* Check if pcm feedback is required */
-			if ((config.pcm_feedback) && (!audio->read_data)) {
-				MM_DBG("allocate PCM buf %d\n",
-					config.buffer_count *
-					config.buffer_size);
-				audio->read_phys =
-						 allocate_contiguous_ebi_nomap(
-							config.buffer_size *
-							config.buffer_count,
-							SZ_4K);
-				if (!audio->read_phys) {
-					rc = -ENOMEM;
-					break;
-				}
-				audio->map_v_read = ioremap(
-							audio->read_phys,
-							config.buffer_size *
-							config.buffer_count);
-				if (IS_ERR(audio->map_v_read)) {
-					MM_ERR("failed to map read"
-							" phy address\n");
-					rc = -ENOMEM;
-					free_contiguous_memory_by_paddr(
-							audio->read_phys);
-				} else {
-					uint8_t index;
-					uint32_t offset = 0;
-					audio->read_data =
-						audio->map_v_read;
-					audio->buf_refresh = 0;
-					audio->pcm_buf_count =
-					    config.buffer_count;
-					audio->read_next = 0;
-					audio->fill_next = 0;
-
-					for (index = 0;
-					     index < config.buffer_count;
-					     index++) {
-						audio->in[index].data =
-						    audio->read_data + offset;
-						audio->in[index].addr =
-						    audio->read_phys + offset;
-						audio->in[index].size =
-						    config.buffer_size;
-						audio->in[index].used = 0;
-						offset += config.buffer_size;
-					}
-					MM_DBG("read buf: phy addr \
-						0x%08x kernel addr 0x%08x\n",
-						audio->read_phys,
-						(int)audio->read_data);
-					rc = 0;
-				}
-			} else {
-				rc = 0;
-			}
-			break;
-		}
-	case AUDIO_PAUSE:
-		MM_DBG("AUDIO_PAUSE %ld\n", arg);
-		rc = audpp_pause(audio->dec_id, (int) arg);
-		break;
-	case AUDIO_GET_SESSION_ID:
-		if (copy_to_user((void *) arg, &audio->dec_id,
-				sizeof(unsigned short)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-/* Only useful in tunnel-mode */
-static int audevrc_fsync(struct file *file, loff_t ppos1, loff_t ppos2, int datasync)
-{
-	struct audio *audio = file->private_data;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (!audio->running || audio->pcm_feedback) {
-		rc = -EINVAL;
-		goto done_nolock;
-	}
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(!audio->out[0].used &&
-		!audio->out[1].used &&
-		audio->out_needed) || audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		audio->teos || audio->wflush);
-
-	if (audio->wflush)
-		rc = -EBUSY;
-
-done:
-	mutex_unlock(&audio->write_lock);
-done_nolock:
-	return rc;
-}
-
-static ssize_t audevrc_read(struct file *file, char __user *buf, size_t count,
-			    loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	int rc = 0;
-	if (!audio->pcm_feedback) {
-		return 0;
-		/* PCM feedback is not enabled. Nothing to read */
-	}
-	mutex_lock(&audio->read_lock);
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	while (count > 0) {
-		rc = wait_event_interruptible(audio->read_wait,
-				(audio->in[audio->read_next].used > 0) ||
-				(audio->stopped) || (audio->rflush));
-
-		MM_DBG("wait terminated \n");
-		if (rc < 0)
-			break;
-		if (audio->stopped || audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-		if (count < audio->in[audio->read_next].used) {
-			/* Read must happen in frame boundary. Since driver does
-			 * not know frame size, read count must be greater or
-			 * equal to size of PCM samples
-			 */
-			MM_DBG("read stop - partial frame\n");
-			break;
-		} else {
-			MM_DBG("read from in[%d]\n", audio->read_next);
-			if (copy_to_user
-			    (buf, audio->in[audio->read_next].data,
-			     audio->in[audio->read_next].used)) {
-				MM_ERR("invalid addr %x \n",
-				       (unsigned int)buf);
-				rc = -EFAULT;
-				break;
-			}
-			count -= audio->in[audio->read_next].used;
-			buf += audio->in[audio->read_next].used;
-			audio->in[audio->read_next].used = 0;
-			if ((++audio->read_next) == audio->pcm_buf_count)
-				audio->read_next = 0;
-			break;
-				/* Force to exit while loop
-				 * to prevent output thread
-				 * sleep too long if data is
-				 * not ready at this moment
-				 */
-
-		}
-	}
-	/* don't feed output buffer to HW decoder during flushing
-	 * buffer refresh command will be sent once flush completes
-	 * send buf refresh command here can confuse HW decoder
-	 */
-	if (audio->buf_refresh && !audio->rflush) {
-		audio->buf_refresh = 0;
-		MM_DBG("kick start pcm feedback again\n");
-		audevrc_buffer_refresh(audio);
-	}
-	mutex_unlock(&audio->read_lock);
-	if (buf > start)
-		rc = buf - start;
-	MM_DBG("read %d bytes\n", rc);
-	return rc;
-}
-
-static int audevrc_process_eos(struct audio *audio,
-		const char __user *buf_start, unsigned short mfield_size)
-{
-	int rc = 0;
-	struct buffer *frame;
-
-	frame = audio->out + audio->out_head;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	audevrc_send_data(audio, 0);
-
-done:
-	return rc;
-}
-
-static ssize_t audevrc_write(struct file *file, const char __user *buf,
-			     size_t count, loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	size_t xfer;
-	char *cpy_ptr;
-	unsigned short mfield_size = 0;
-	int rc = 0, eos_condition = AUDEVRC_EOS_NONE;
-
-	MM_DBG("cnt=%d\n", count);
-
-	if (count & 1)
-		return -EINVAL;
-
-	mutex_lock(&audio->write_lock);
-	while (count > 0) {
-		frame = audio->out + audio->out_head;
-		cpy_ptr = frame->data;
-		rc = wait_event_interruptible(audio->write_wait,
-					      (frame->used == 0)
-						|| (audio->stopped)
-						|| (audio->wflush));
-		if (rc < 0)
-			break;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (audio->mfield) {
-			if (buf == start) {
-				/* Processing beginning of user buffer */
-				if (__get_user(mfield_size,
-					(unsigned short __user *) buf)) {
-					rc = -EFAULT;
-					break;
-				} else if (mfield_size > count) {
-					rc = -EINVAL;
-					break;
-				}
-				MM_DBG("mf offset_val %x\n", mfield_size);
-				if (copy_from_user(cpy_ptr, buf,
-							mfield_size)) {
-					rc = -EFAULT;
-					break;
-				}
-				/* Check if EOS flag is set and buffer has
-				 * contains just meta field
-				 */
-				if (cpy_ptr[AUDEVRC_EOS_FLG_OFFSET] &
-						AUDEVRC_EOS_FLG_MASK) {
-					MM_DBG("eos set\n");
-					eos_condition = AUDEVRC_EOS_SET;
-					if (mfield_size == count) {
-						buf += mfield_size;
-						break;
-					} else
-					cpy_ptr[AUDEVRC_EOS_FLG_OFFSET] &=
-						~AUDEVRC_EOS_FLG_MASK;
-				}
-				 /* Check EOS to see if */
-				cpy_ptr += mfield_size;
-				count -= mfield_size;
-				buf += mfield_size;
-			 } else {
-				 mfield_size = 0;
-				 MM_DBG("continuous buffer\n");
-			 }
-			 frame->mfield_sz = mfield_size;
-		}
-
-		xfer = (count > (frame->size - mfield_size)) ?
-			(frame->size - mfield_size) : count;
-		if (copy_from_user(cpy_ptr, buf, xfer)) {
-			rc = -EFAULT;
-			break;
-		}
-
-		frame->used = xfer + mfield_size;
-		audio->out_head ^= 1;
-		count -= xfer;
-		buf += xfer;
-		audevrc_send_data(audio, 0);
-	}
-	if (eos_condition == AUDEVRC_EOS_SET)
-		rc = audevrc_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	if (!rc) {
-		if (buf > start)
-			return buf - start;
-	}
-	return rc;
-}
-
-static int audevrc_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	MM_INFO("audio instance 0x%08x freeing\n", (int)audio);
-	mutex_lock(&audio->lock);
-	auddev_unregister_evt_listner(AUDDEV_CLNT_DEC, audio->dec_id);
-	audevrc_disable(audio);
-	audevrc_flush(audio);
-	audevrc_flush_pcm_buf(audio);
-	msm_adsp_put(audio->audplay);
-	audpp_adec_free(audio->dec_id);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	unregister_early_suspend(&audio->suspend_ctl.node);
-#endif
-	audio->event_abort = 1;
-	wake_up(&audio->event_wait);
-	audevrc_reset_event_queue(audio);
-	iounmap(audio->map_v_write);
-	free_contiguous_memory_by_paddr(audio->phys);
-	if (audio->read_data) {
-		iounmap(audio->map_v_read);
-		free_contiguous_memory_by_paddr(audio->read_phys);
-	}
-	mutex_unlock(&audio->lock);
-#ifdef CONFIG_DEBUG_FS
-	if (audio->dentry)
-		debugfs_remove(audio->dentry);
-#endif
-	kfree(audio);
-	return 0;
-}
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audevrc_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload)
-{
-	struct audevrc_event *e_node = NULL;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-
-	if (!list_empty(&audio->free_event_queue)) {
-		e_node = list_first_entry(&audio->free_event_queue,
-				struct audevrc_event, list);
-		list_del(&e_node->list);
-	} else {
-		e_node = kmalloc(sizeof(struct audevrc_event), GFP_ATOMIC);
-		if (!e_node) {
-			MM_ERR("No mem to post event %d\n", type);
-			return;
-		}
-	}
-
-	e_node->event_type = type;
-	e_node->payload = payload;
-
-	list_add_tail(&e_node->list, &audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	wake_up(&audio->event_wait);
-}
-
-static void audevrc_suspend(struct early_suspend *h)
-{
-	struct audevrc_suspend_ctl *ctl =
-		container_of(h, struct audevrc_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audevrc_post_event(ctl->audio, AUDIO_EVENT_SUSPEND, payload);
-}
-
-static void audevrc_resume(struct early_suspend *h)
-{
-	struct audevrc_suspend_ctl *ctl =
-		container_of(h, struct audevrc_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audevrc_post_event(ctl->audio, AUDIO_EVENT_RESUME, payload);
-}
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-static ssize_t audevrc_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static ssize_t audevrc_debug_read(struct file *file, char __user *buf,
-					size_t count, loff_t *ppos)
-{
-	const int debug_bufmax = 1024;
-	static char buffer[1024];
-	int n = 0, i;
-	struct audio *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	n = scnprintf(buffer, debug_bufmax, "opened %d\n", audio->opened);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"enabled %d\n", audio->enabled);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"stopped %d\n", audio->stopped);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_feedback %d\n", audio->pcm_feedback);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_buf_sz %d\n", audio->out[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_buf_count %d \n", audio->pcm_buf_count);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_buf_sz %d \n", audio->in[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"volume %x \n", audio->vol_pan.volume);
-	mutex_unlock(&audio->lock);
-	/* Following variables are only useful for debugging when
-	 * when playback halts unexpectedly. Thus, no mutual exclusion
-	 * enforced
-	 */
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"wflush %d\n", audio->wflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"rflush %d\n", audio->rflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"running %d \n", audio->running);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"dec state %d \n", audio->dec_state);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_needed %d \n", audio->out_needed);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_head %d \n", audio->out_head);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_tail %d \n", audio->out_tail);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out[0].used %d \n", audio->out[0].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out[1].used %d \n", audio->out[1].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"buffer_refresh %d \n", audio->buf_refresh);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"read_next %d \n", audio->read_next);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"fill_next %d \n", audio->fill_next);
-	for (i = 0; i < audio->pcm_buf_count; i++)
-		n += scnprintf(buffer + n, debug_bufmax - n,
-				"in[%d].size %d \n", i, audio->in[i].used);
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations audevrc_debug_fops = {
-	.read = audevrc_debug_read,
-	.open = audevrc_debug_open,
-};
-#endif
-
-static int audevrc_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = NULL;
-	int rc, dec_attrb, decid, i;
-	struct audevrc_event *e_node = NULL;
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_evrc_" + 5];
-#endif
-
-	/* Allocate audio instance, set to zero */
-	audio = kzalloc(sizeof(struct audio), GFP_KERNEL);
-	if (!audio) {
-		MM_ERR("no memory to allocate audio instance\n");
-		rc = -ENOMEM;
-		goto done;
-	}
-	MM_INFO("audio instance 0x%08x created\n", (int)audio);
-
-	/* Allocate the decoder */
-	dec_attrb = AUDDEC_DEC_EVRC;
-	if ((file->f_mode & FMODE_WRITE) &&
-			(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_NONTUNNEL;
-		audio->pcm_feedback = NON_TUNNEL_MODE_PLAYBACK;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_TUNNEL;
-		audio->pcm_feedback = TUNNEL_MODE_PLAYBACK;
-	} else {
-		kfree(audio);
-		rc = -EACCES;
-		goto done;
-	}
-	decid = audpp_adec_alloc(dec_attrb, &audio->module_name,
-			&audio->queue_id);
-
-	if (decid < 0) {
-		MM_ERR("No free decoder available, freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENODEV;
-		kfree(audio);
-		goto done;
-	}
-
-	audio->dec_id = decid & MSM_AUD_DECODER_MASK;
-
-	audio->phys = allocate_contiguous_ebi_nomap(DMASZ, SZ_4K);
-	if (!audio->phys) {
-		MM_ERR("could not allocate write buffers, freeing instance \
-				0x%08x\n", (int)audio);
-		rc = -ENOMEM;
-		audpp_adec_free(audio->dec_id);
-		kfree(audio);
-		goto done;
-	} else {
-		audio->map_v_write = ioremap(audio->phys, DMASZ);
-		if (IS_ERR(audio->map_v_write)) {
-			MM_ERR("failed to map write physical address, freeing \
-					instance 0x%08x\n", (int)audio);
-			rc = -ENOMEM;
-			free_contiguous_memory_by_paddr(audio->phys);
-			audpp_adec_free(audio->dec_id);
-			kfree(audio);
-			goto done;
-		}
-		audio->data = audio->map_v_write;
-		MM_DBG("write buf: phy addr 0x%08x kernel addr 0x%08x\n",
-				audio->phys, (int)audio->data);
-	}
-
-	rc = msm_adsp_get(audio->module_name, &audio->audplay,
-			&audplay_adsp_ops_evrc, audio);
-
-	if (rc) {
-		MM_ERR("failed to get %s module, freeing instance 0x%08x\n",
-				audio->module_name, (int)audio);
-		goto err;
-	}
-
-	/* Initialize all locks of audio instance */
-	mutex_init(&audio->lock);
-	mutex_init(&audio->write_lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->get_event_lock);
-	spin_lock_init(&audio->dsp_lock);
-	init_waitqueue_head(&audio->write_wait);
-	init_waitqueue_head(&audio->read_wait);
-	INIT_LIST_HEAD(&audio->free_event_queue);
-	INIT_LIST_HEAD(&audio->event_queue);
-	init_waitqueue_head(&audio->wait);
-	init_waitqueue_head(&audio->event_wait);
-	spin_lock_init(&audio->event_queue_lock);
-	init_waitqueue_head(&audio->avsync_wait);
-
-	audio->out[0].data = audio->data + 0;
-	audio->out[0].addr = audio->phys + 0;
-	audio->out[0].size = BUFSZ;
-
-	audio->out[1].data = audio->data + BUFSZ;
-	audio->out[1].addr = audio->phys + BUFSZ;
-	audio->out[1].size = BUFSZ;
-
-	audio->vol_pan.volume = 0x3FFF;
-
-	audevrc_flush(audio);
-
-	file->private_data = audio;
-	audio->opened = 1;
-
-	audio->device_events = AUDDEV_EVT_DEV_RDY
-				|AUDDEV_EVT_DEV_RLS|
-				AUDDEV_EVT_STREAM_VOL_CHG;
-
-	rc = auddev_register_evt_listner(audio->device_events,
-					AUDDEV_CLNT_DEC,
-					audio->dec_id,
-					evrc_listner,
-					(void *)audio);
-	if (rc) {
-		MM_ERR("%s: failed to register listner\n", __func__);
-		goto event_err;
-	}
-
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof name, "msm_evrc_%04x", audio->dec_id);
-	audio->dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
-			NULL, (void *) audio, &audevrc_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		MM_DBG("debugfs_create_file failed\n");
-#endif
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	audio->suspend_ctl.node.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
-	audio->suspend_ctl.node.resume = audevrc_resume;
-	audio->suspend_ctl.node.suspend = audevrc_suspend;
-	audio->suspend_ctl.audio = audio;
-	register_early_suspend(&audio->suspend_ctl.node);
-#endif
-	for (i = 0; i < AUDEVRC_EVENT_NUM; i++) {
-		e_node = kmalloc(sizeof(struct audevrc_event), GFP_KERNEL);
-		if (e_node)
-			list_add_tail(&e_node->list, &audio->free_event_queue);
-		else {
-			MM_ERR("event pkt alloc failed\n");
-			break;
-		}
-	}
-done:
-	return rc;
-event_err:
-	msm_adsp_put(audio->audplay);
-err:
-	iounmap(audio->map_v_write);
-	free_contiguous_memory_by_paddr(audio->phys);
-	audpp_adec_free(audio->dec_id);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_evrc_fops = {
-	.owner = THIS_MODULE,
-	.open = audevrc_open,
-	.release = audevrc_release,
-	.read = audevrc_read,
-	.write = audevrc_write,
-	.unlocked_ioctl = audevrc_ioctl,
-	.fsync = audevrc_fsync,
-};
-
-struct miscdevice audio_evrc_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_evrc",
-	.fops = &audio_evrc_fops,
-};
-
-static int __init audevrc_init(void)
-{
-	return misc_register(&audio_evrc_misc);
-
-}
-
-static void __exit audevrc_exit(void)
-{
-	misc_deregister(&audio_evrc_misc);
-}
-
-module_init(audevrc_init);
-module_exit(audevrc_exit);
-
-MODULE_DESCRIPTION("MSM EVRC driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5v2/audio_evrc_in.c b/arch/arm/mach-msm/qdsp5v2/audio_evrc_in.c
deleted file mode 100644
index 7d9b1fa..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audio_evrc_in.c
+++ /dev/null
@@ -1,1584 +0,0 @@
-/*
- * evrc audio input device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2009-2012, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/msm_audio_qcp.h>
-#include <linux/msm_ion.h>
-#include <linux/memory_alloc.h>
-
-#include <mach/msm_adsp.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/socinfo.h>
-#include <mach/qdsp5v2/qdsp5audreccmdi.h>
-#include <mach/qdsp5v2/qdsp5audrecmsg.h>
-#include <mach/qdsp5v2/audpreproc.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_memtypes.h>
-
-#define META_OUT_SIZE	24
-/* FRAME_NUM must be a power of two */
-#define FRAME_NUM	8
-#define EVRC_FRAME_SIZE	36 /* 36 bytes data */
-#define FRAME_SIZE	(22 * 2) /* 36 bytes data */
- /* 36 bytes data  + 24 meta field*/
-#define NT_FRAME_SIZE	(EVRC_FRAME_SIZE + META_OUT_SIZE)
-#define DMASZ		(NT_FRAME_SIZE * FRAME_NUM)
-#define OUT_FRAME_NUM	2
-#define OUT_BUFFER_SIZE (4 * 1024 + META_OUT_SIZE)
-#define BUFFER_SIZE	(OUT_BUFFER_SIZE * OUT_FRAME_NUM)
-
-#define AUDPREPROC_EVRC_EOS_FLG_OFFSET 0x0A /* Offset from beginning of buffer*/
-#define AUDPREPROC_EVRC_EOS_FLG_MASK 0x01
-#define AUDPREPROC_EVRC_EOS_NONE 0x0 /* No EOS detected */
-#define AUDPREPROC_EVRC_EOS_SET 0x1 /* EOS set in meta field */
-
-struct buffer {
-	void *data;
-	uint32_t size;
-	uint32_t read;
-	uint32_t addr;
-	uint32_t used;
-	uint32_t mfield_sz;
-};
-
-struct audio_in {
-	struct buffer in[FRAME_NUM];
-
-	spinlock_t dsp_lock;
-
-	atomic_t in_bytes;
-	atomic_t in_samples;
-
-	struct mutex lock;
-	struct mutex read_lock;
-	wait_queue_head_t wait;
-	wait_queue_head_t wait_enable;
-	/*write section*/
-	struct buffer out[OUT_FRAME_NUM];
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed;	/* number of buffers the dsp is waiting for */
-	uint32_t out_count;
-
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-	int32_t out_phys; /* physical address of write buffer */
-	char *out_data;
-	int mfield; /* meta field embedded in data */
-	int wflush; /*write flush */
-	int rflush; /*read flush*/
-	int out_frame_cnt;
-
-	struct msm_adsp_module *audrec;
-
-	struct audrec_session_info session_info; /*audrec session info*/
-
-	/* configuration to use on next enable */
-	uint32_t buffer_size; /* Frame size (36 bytes) */
-	uint32_t samp_rate;
-	uint32_t channel_mode;
-	uint32_t enc_type;
-
-	struct msm_audio_evrc_enc_config cfg;
-
-	uint32_t dsp_cnt;
-	uint32_t in_head; /* next buffer dsp will write */
-	uint32_t in_tail; /* next buffer read() will read */
-	uint32_t in_count; /* number of buffers available to read() */
-	uint32_t mode;
-	uint32_t eos_ack;
-	uint32_t flush_ack;
-
-	const char *module_name;
-	unsigned queue_ids;
-	uint16_t enc_id;
-
-	uint16_t source; /* Encoding source bit mask */
-	uint32_t device_events;
-	uint32_t in_call;
-	uint32_t dev_cnt;
-	int voice_state;
-	spinlock_t dev_lock;
-
-	/* data allocated for various buffers */
-	char *data;
-	dma_addr_t phys;
-	void *map_v_read;
-	void *map_v_write;
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped, cleared on flush */
-	char *build_id;
-	struct ion_client *client;
-	struct ion_handle *input_buff_handle;
-	struct ion_handle *output_buff_handle;
-};
-
-struct audio_frame {
-	uint16_t frame_count_lsw;
-	uint16_t frame_count_msw;
-	uint16_t frame_length;
-	uint16_t erased_pcm;
-	unsigned char raw_bitstream[]; /* samples */
-} __attribute__((packed));
-
-struct audio_frame_nt {
-	uint16_t metadata_len;
-	uint16_t frame_count_lsw;
-	uint16_t frame_count_msw;
-	uint16_t frame_length;
-	uint16_t erased_pcm;
-	uint16_t reserved;
-	uint16_t time_stamp_dword_lsw;
-	uint16_t time_stamp_dword_msw;
-	uint16_t time_stamp_lsw;
-	uint16_t time_stamp_msw;
-	uint16_t nflag_lsw;
-	uint16_t nflag_msw;
-	unsigned char raw_bitstream[]; /* samples */
-} __attribute__((packed));
-
-struct evrc_encoded_meta_out {
-	uint16_t metadata_len;
-	uint16_t time_stamp_dword_lsw;
-	uint16_t time_stamp_dword_msw;
-	uint16_t time_stamp_lsw;
-	uint16_t time_stamp_msw;
-	uint16_t nflag_lsw;
-	uint16_t nflag_msw;
-};
-
-/* Audrec Queue command sent macro's */
-#define audrec_send_bitstreamqueue(audio, cmd, len) \
-	msm_adsp_write(audio->audrec, ((audio->queue_ids & 0xFFFF0000) >> 16),\
-			cmd, len)
-
-#define audrec_send_audrecqueue(audio, cmd, len) \
-	msm_adsp_write(audio->audrec, (audio->queue_ids & 0x0000FFFF),\
-			cmd, len)
-
-/* DSP command send functions */
-static int audevrc_in_enc_config(struct audio_in *audio, int enable);
-static int audevrc_in_param_config(struct audio_in *audio);
-static int audevrc_in_mem_config(struct audio_in *audio);
-static int audevrc_in_record_config(struct audio_in *audio, int enable);
-static int audevrc_dsp_read_buffer(struct audio_in *audio, uint32_t read_cnt);
-
-static void audevrc_in_get_dsp_frames(struct audio_in *audio);
-static int audpcm_config(struct audio_in *audio);
-static void audevrc_out_flush(struct audio_in *audio);
-static int audpreproc_cmd_cfg_routing_mode(struct audio_in *audio);
-static void audpreproc_pcm_send_data(struct audio_in *audio, unsigned needed);
-static void audevrc_nt_in_get_dsp_frames(struct audio_in *audio);
-
-static void audevrc_in_flush(struct audio_in *audio);
-
-static void evrc_in_listener(u32 evt_id, union auddev_evt_data *evt_payload,
-				void *private_data)
-{
-	struct audio_in *audio = (struct audio_in *) private_data;
-	unsigned long flags;
-
-	MM_DBG("evt_id = 0x%8x\n", evt_id);
-	switch (evt_id) {
-	case AUDDEV_EVT_DEV_RDY: {
-		MM_DBG("AUDDEV_EVT_DEV_RDY\n");
-		spin_lock_irqsave(&audio->dev_lock, flags);
-		audio->dev_cnt++;
-		if (!audio->in_call)
-			audio->source |= (0x1 << evt_payload->routing_id);
-		spin_unlock_irqrestore(&audio->dev_lock, flags);
-
-		if ((audio->running == 1) && (audio->enabled == 1) &&
-			(audio->mode == MSM_AUD_ENC_MODE_TUNNEL))
-			audevrc_in_record_config(audio, 1);
-	}
-		break;
-	case AUDDEV_EVT_DEV_RLS: {
-		MM_DBG("AUDDEV_EVT_DEV_RLS\n");
-		spin_lock_irqsave(&audio->dev_lock, flags);
-		audio->dev_cnt--;
-		if (!audio->in_call)
-			audio->source &= ~(0x1 << evt_payload->routing_id);
-		spin_unlock_irqrestore(&audio->dev_lock, flags);
-
-		if ((!audio->running) || (!audio->enabled))
-			break;
-
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			/* Turn of as per source */
-			if (audio->source)
-				audevrc_in_record_config(audio, 1);
-			else
-				/* Turn off all */
-				audevrc_in_record_config(audio, 0);
-		}
-	}
-		break;
-	case AUDDEV_EVT_VOICE_STATE_CHG: {
-		MM_DBG("AUDDEV_EVT_VOICE_STATE_CHG, state = %d\n",
-				evt_payload->voice_state);
-		audio->voice_state = evt_payload->voice_state;
-		if (audio->in_call && audio->running &&
-		   (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)) {
-			if (audio->voice_state == VOICE_STATE_INCALL)
-				audevrc_in_record_config(audio, 1);
-			else if (audio->voice_state == VOICE_STATE_OFFCALL) {
-				audevrc_in_record_config(audio, 0);
-				wake_up(&audio->wait);
-			}
-		}
-
-		break;
-	}
-	default:
-		MM_ERR("wrong event %d\n", evt_id);
-		break;
-	}
-}
-
-/* ------------------- dsp preproc event handler--------------------- */
-static void audpreproc_dsp_event(void *data, unsigned id,  void *msg)
-{
-	struct audio_in *audio = data;
-
-	switch (id) {
-	case AUDPREPROC_ERROR_MSG: {
-		struct audpreproc_err_msg *err_msg = msg;
-
-		MM_ERR("ERROR_MSG: stream id %d err idx %d\n",
-		err_msg->stream_id, err_msg->aud_preproc_err_idx);
-		/* Error case */
-		wake_up(&audio->wait_enable);
-		break;
-	}
-	case AUDPREPROC_CMD_CFG_DONE_MSG: {
-		MM_DBG("CMD_CFG_DONE_MSG \n");
-		break;
-	}
-	case AUDPREPROC_CMD_ENC_CFG_DONE_MSG: {
-		struct audpreproc_cmd_enc_cfg_done_msg *enc_cfg_msg = msg;
-
-		MM_DBG("CMD_ENC_CFG_DONE_MSG: stream id %d enc type \
-			0x%8x\n", enc_cfg_msg->stream_id,
-			enc_cfg_msg->rec_enc_type);
-		/* Encoder enable success */
-		if (enc_cfg_msg->rec_enc_type & ENCODE_ENABLE) {
-			if(audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) {
-				MM_DBG("routing command\n");
-				audpreproc_cmd_cfg_routing_mode(audio);
-			} else {
-				audevrc_in_param_config(audio);
-			}
-		} else { /* Encoder disable success */
-			audio->running = 0;
-			if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)
-				audevrc_in_record_config(audio, 0);
-			else
-				wake_up(&audio->wait_enable);
-		}
-		break;
-	}
-	case AUDPREPROC_CMD_ENC_PARAM_CFG_DONE_MSG: {
-		MM_DBG("CMD_ENC_PARAM_CFG_DONE_MSG\n");
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)
-			audevrc_in_mem_config(audio);
-		else
-			audpcm_config(audio);
-		break;
-	}
-	case AUDPREPROC_CMD_ROUTING_MODE_DONE_MSG: {
-		struct audpreproc_cmd_routing_mode_done\
-				*routing_cfg_done_msg = msg;
-		if (routing_cfg_done_msg->configuration == 0) {
-			MM_INFO("routing configuration failed\n");
-			audio->running = 0;
-		} else
-			audevrc_in_param_config(audio);
-		break;
-	}
-	case AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG_DONE_MSG: {
-		MM_DBG("AFE_CMD_AUDIO_RECORD_CFG_DONE_MSG \n");
-		wake_up(&audio->wait_enable);
-		break;
-	}
-	default:
-		MM_ERR("Unknown Event id %d\n", id);
-	}
-}
-
-/* ------------------- dsp audrec event handler--------------------- */
-static void audrec_dsp_event(void *data, unsigned id, size_t len,
-			    void (*getevent)(void *ptr, size_t len))
-{
-	struct audio_in *audio = data;
-
-	switch (id) {
-	case AUDREC_CMD_MEM_CFG_DONE_MSG: {
-		MM_DBG("CMD_MEM_CFG_DONE MSG DONE\n");
-		audio->running = 1;
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			if ((!audio->in_call && (audio->dev_cnt > 0)) ||
-				(audio->in_call &&
-					(audio->voice_state \
-						== VOICE_STATE_INCALL)))
-				audevrc_in_record_config(audio, 1);
-		} else {
-			audpreproc_pcm_send_data(audio, 1);
-			wake_up(&audio->wait_enable);
-		}
-		break;
-	}
-	case AUDREC_FATAL_ERR_MSG: {
-		struct audrec_fatal_err_msg fatal_err_msg;
-
-		getevent(&fatal_err_msg, AUDREC_FATAL_ERR_MSG_LEN);
-		MM_ERR("FATAL_ERR_MSG: err id %d\n",
-				fatal_err_msg.audrec_err_id);
-		/* Error stop the encoder */
-		audio->stopped = 1;
-		wake_up(&audio->wait);
-		if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL)
-			wake_up(&audio->write_wait);
-		break;
-	}
-	case AUDREC_UP_PACKET_READY_MSG: {
-		struct audrec_up_pkt_ready_msg pkt_ready_msg;
-
-		getevent(&pkt_ready_msg, AUDREC_UP_PACKET_READY_MSG_LEN);
-		MM_DBG("UP_PACKET_READY_MSG: write cnt lsw  %d \
-		write cnt msw %d read cnt lsw %d  read cnt msw %d \n",\
-		pkt_ready_msg.audrec_packet_write_cnt_lsw, \
-		pkt_ready_msg.audrec_packet_write_cnt_msw, \
-		pkt_ready_msg.audrec_up_prev_read_cnt_lsw, \
-		pkt_ready_msg.audrec_up_prev_read_cnt_msw);
-
-		audevrc_in_get_dsp_frames(audio);
-		break;
-	}
-	case AUDREC_CMD_PCM_BUFFER_PTR_UPDATE_ARM_TO_ENC_MSG: {
-		MM_DBG("ptr_update recieved from DSP\n");
-		audpreproc_pcm_send_data(audio, 1);
-		break;
-	}
-	case AUDREC_CMD_PCM_CFG_ARM_TO_ENC_DONE_MSG: {
-		MM_ERR("AUDREC_CMD_PCM_CFG_ARM_TO_ENC_DONE_MSG");
-		audevrc_in_mem_config(audio);
-		break;
-	}
-	case AUDREC_UP_NT_PACKET_READY_MSG: {
-		struct audrec_up_nt_packet_ready_msg pkt_ready_msg;
-
-		getevent(&pkt_ready_msg, AUDREC_UP_NT_PACKET_READY_MSG_LEN);
-		MM_DBG("UP_NT_PACKET_READY_MSG: write cnt lsw  %d \
-		write cnt msw %d read cnt lsw %d  read cnt msw %d \n",\
-		pkt_ready_msg.audrec_packetwrite_cnt_lsw, \
-		pkt_ready_msg.audrec_packetwrite_cnt_msw, \
-		pkt_ready_msg.audrec_upprev_readcount_lsw, \
-		pkt_ready_msg.audrec_upprev_readcount_msw);
-
-		audevrc_nt_in_get_dsp_frames(audio);
-		break;
-	}
-	case AUDREC_CMD_EOS_ACK_MSG: {
-		MM_DBG("eos ack recieved\n");
-		break;
-	}
-	case AUDREC_CMD_FLUSH_DONE_MSG: {
-		audio->wflush = 0;
-		audio->rflush = 0;
-		audio->flush_ack = 1;
-		wake_up(&audio->write_wait);
-		MM_DBG("flush ack recieved\n");
-		break;
-	}
-	case ADSP_MESSAGE_ID: {
-		MM_DBG("Received ADSP event:module audrectask\n");
-		break;
-	}
-	default:
-		MM_ERR("Unknown Event id %d\n", id);
-	}
-}
-
-static void audevrc_in_get_dsp_frames(struct audio_in *audio)
-{
-	struct audio_frame *frame;
-	uint32_t index;
-	unsigned long flags;
-
-	index = audio->in_head;
-
-	frame = (void *) (((char *)audio->in[index].data) - \
-			 sizeof(*frame));
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->in[index].size = frame->frame_length;
-
-	/* statistics of read */
-	atomic_add(audio->in[index].size, &audio->in_bytes);
-	atomic_add(1, &audio->in_samples);
-
-	audio->in_head = (audio->in_head + 1) & (FRAME_NUM - 1);
-
-	/* If overflow, move the tail index foward. */
-	if (audio->in_head == audio->in_tail) {
-		MM_ERR("Error! not able to keep up the read\n");
-		audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
-		MM_ERR("in_count = %d\n", audio->in_count);
-	} else
-		audio->in_count++;
-
-	audevrc_dsp_read_buffer(audio, audio->dsp_cnt++);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-
-	wake_up(&audio->wait);
-}
-
-static void audevrc_nt_in_get_dsp_frames(struct audio_in *audio)
-{
-	struct audio_frame_nt *nt_frame;
-	uint32_t index;
-	unsigned long flags;
-
-	index = audio->in_head;
-	nt_frame = (void *) (((char *)audio->in[index].data) - \
-				sizeof(struct audio_frame_nt));
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->in[index].size = nt_frame->frame_length;
-	/* statistics of read */
-	atomic_add(audio->in[index].size, &audio->in_bytes);
-	atomic_add(1, &audio->in_samples);
-
-	audio->in_head = (audio->in_head + 1) & (FRAME_NUM - 1);
-
-	/* If overflow, move the tail index foward. */
-	if (audio->in_head == audio->in_tail)
-		MM_DBG("Error! not able to keep up the read\n");
-	else
-		audio->in_count++;
-
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	wake_up(&audio->wait);
-}
-
-
-struct msm_adsp_ops audrec_evrc_adsp_ops = {
-	.event = audrec_dsp_event,
-};
-
-static int audpreproc_pcm_buffer_ptr_refresh(struct audio_in *audio,
-				       unsigned idx, unsigned len)
-{
-	struct audrec_cmd_pcm_buffer_ptr_refresh_arm_enc cmd;
-
-	if (len ==  META_OUT_SIZE)
-		len = len / 2;
-	else
-		len = (len + META_OUT_SIZE) / 2;
-	MM_DBG("len = %d\n", len);
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_PCM_BUFFER_PTR_REFRESH_ARM_TO_ENC;
-	cmd.num_buffers = 1;
-	if (cmd.num_buffers == 1) {
-		cmd.buf_address_length[0] = (audio->out[idx].addr &
-							0xffff0000) >> 16;
-		cmd.buf_address_length[1] = (audio->out[idx].addr &
-							0x0000ffff);
-		cmd.buf_address_length[2] = (len & 0xffff0000) >> 16;
-		cmd.buf_address_length[3] = (len & 0x0000ffff);
-	}
-	audio->out_frame_cnt++;
-	return audrec_send_audrecqueue(audio, (void *)&cmd,
-					(unsigned int)sizeof(cmd));
-}
-
-
-static int audpcm_config(struct audio_in *audio)
-{
-	struct audrec_cmd_pcm_cfg_arm_to_enc cmd;
-	MM_DBG("\n");
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_PCM_CFG_ARM_TO_ENC;
-	cmd.config_update_flag = AUDREC_PCM_CONFIG_UPDATE_FLAG_ENABLE;
-	cmd.enable_flag = AUDREC_ENABLE_FLAG_VALUE;
-	cmd.sampling_freq = audio->samp_rate;
-	if (!audio->channel_mode)
-		cmd.channels = 1;
-	else
-		cmd.channels = 2;
-	cmd.frequency_of_intimation = 1;
-	cmd.max_number_of_buffers = OUT_FRAME_NUM;
-	return audrec_send_audrecqueue(audio, (void *)&cmd,
-					(unsigned int)sizeof(cmd));
-}
-
-
-static int audpreproc_cmd_cfg_routing_mode(struct audio_in *audio)
-{
-	struct audpreproc_audrec_cmd_routing_mode cmd;
-
-	MM_DBG("\n");
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPREPROC_AUDREC_CMD_ROUTING_MODE;
-	cmd.stream_id = audio->enc_id;
-	if (audio->mode == MSM_ADSP_ENC_MODE_NON_TUNNEL)
-		cmd.routing_mode = 1;
-	return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd));
-}
-
-
-
-static int audevrc_in_enc_config(struct audio_in *audio, int enable)
-{
-	struct audpreproc_audrec_cmd_enc_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	if (audio->build_id[17] == '1') {
-		cmd.cmd_id = AUDPREPROC_AUDREC_CMD_ENC_CFG_2;
-		MM_ERR("sending AUDPREPROC_AUDREC_CMD_ENC_CFG_2 command");
-	} else {
-		cmd.cmd_id = AUDPREPROC_AUDREC_CMD_ENC_CFG;
-		MM_ERR("sending AUDPREPROC_AUDREC_CMD_ENC_CFG command");
-	}
-	cmd.stream_id = audio->enc_id;
-
-	if (enable)
-		cmd.audrec_enc_type = audio->enc_type | ENCODE_ENABLE;
-	else
-		cmd.audrec_enc_type &= ~(ENCODE_ENABLE);
-
-	return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd));
-}
-
-static int audevrc_in_param_config(struct audio_in *audio)
-{
-	struct audpreproc_audrec_cmd_parm_cfg_evrc cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPREPROC_AUDREC_CMD_PARAM_CFG;
-	cmd.common.stream_id = audio->enc_id;
-
-	cmd.enc_min_rate = audio->cfg.min_bit_rate;
-	cmd.enc_max_rate = audio->cfg.max_bit_rate;
-	cmd.rate_modulation_cmd = 0;  /* Default set to 0 */
-
-	return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd));
-}
-
-/* To Do: msm_snddev_route_enc(audio->enc_id); */
-static int audevrc_in_record_config(struct audio_in *audio, int enable)
-{
-	struct audpreproc_afe_cmd_audio_record_cfg cmd;
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG;
-	cmd.stream_id = audio->enc_id;
-	if (enable)
-		cmd.destination_activity = AUDIO_RECORDING_TURN_ON;
-	else
-		cmd.destination_activity = AUDIO_RECORDING_TURN_OFF;
-
-	cmd.source_mix_mask = audio->source;
-	if (audio->enc_id == 2) {
-		if ((cmd.source_mix_mask &
-				INTERNAL_CODEC_TX_SOURCE_MIX_MASK) ||
-			(cmd.source_mix_mask & AUX_CODEC_TX_SOURCE_MIX_MASK) ||
-			(cmd.source_mix_mask & VOICE_UL_SOURCE_MIX_MASK) ||
-			(cmd.source_mix_mask & VOICE_DL_SOURCE_MIX_MASK)) {
-			cmd.pipe_id = SOURCE_PIPE_1;
-		}
-		if (cmd.source_mix_mask &
-				AUDPP_A2DP_PIPE_SOURCE_MIX_MASK)
-			cmd.pipe_id |= SOURCE_PIPE_0;
-	}
-	MM_DBG("stream_id %x destination_activity %x \
-	source_mix_mask %x pipe_id %x",\
-	cmd.stream_id, cmd.destination_activity,
-	cmd.source_mix_mask, cmd.pipe_id);
-	return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd));
-}
-
-static int audevrc_in_mem_config(struct audio_in *audio)
-{
-	struct audrec_cmd_arecmem_cfg cmd;
-	uint16_t *data = (void *) audio->data;
-	int n;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_MEM_CFG_CMD;
-	cmd.audrec_up_pkt_intm_count = 1;
-	cmd.audrec_ext_pkt_start_addr_msw = audio->phys >> 16;
-	cmd.audrec_ext_pkt_start_addr_lsw = audio->phys;
-	cmd.audrec_ext_pkt_buf_number = FRAME_NUM;
-	MM_DBG("audio->phys = %x\n", audio->phys);
-	/* prepare buffer pointers:
-	 * T:36 bytes evrc packet + 4 halfword header
-	 * NT:36 bytes evrc packet + 12 halfword header
-	 */
-	for (n = 0; n < FRAME_NUM; n++) {
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			audio->in[n].data = data + 4;
-			data += (FRAME_SIZE/2);
-			MM_DBG("0x%8x\n", (int)(audio->in[n].data - 8));
-		} else  {
-			audio->in[n].data = data + 12;
-			data += ((EVRC_FRAME_SIZE) / 2) + 12;
-			MM_DBG("0x%8x\n", (int)(audio->in[n].data - 24));
-		}
-	}
-	return audrec_send_audrecqueue(audio, &cmd, sizeof(cmd));
-}
-
-static int audevrc_dsp_read_buffer(struct audio_in *audio, uint32_t read_cnt)
-{
-	struct up_audrec_packet_ext_ptr cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = UP_AUDREC_PACKET_EXT_PTR;
-	cmd.audrec_up_curr_read_count_msw = read_cnt >> 16;
-	cmd.audrec_up_curr_read_count_lsw = read_cnt;
-
-	return audrec_send_bitstreamqueue(audio, &cmd, sizeof(cmd));
-}
-static int audevrc_flush_command(struct audio_in *audio)
-{
-	struct audrec_cmd_flush cmd;
-	MM_DBG("\n");
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_FLUSH;
-	return audrec_send_audrecqueue(audio, &cmd, sizeof(cmd));
-}
-
-/* must be called with audio->lock held */
-static int audevrc_in_enable(struct audio_in *audio)
-{
-	if (audio->enabled)
-		return 0;
-
-	if (audpreproc_enable(audio->enc_id, &audpreproc_dsp_event, audio)) {
-		MM_ERR("msm_adsp_enable(audpreproc) failed\n");
-		return -ENODEV;
-	}
-
-	if (msm_adsp_enable(audio->audrec)) {
-		MM_ERR("msm_adsp_enable(audrec) failed\n");
-		audpreproc_disable(audio->enc_id, audio);
-		return -ENODEV;
-	}
-	audio->enabled = 1;
-	audevrc_in_enc_config(audio, 1);
-
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audevrc_in_disable(struct audio_in *audio)
-{
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audevrc_in_enc_config(audio, 0);
-		wake_up(&audio->wait);
-		wait_event_interruptible_timeout(audio->wait_enable,
-				audio->running == 0, 1*HZ);
-		msm_adsp_disable(audio->audrec);
-		audpreproc_disable(audio->enc_id, audio);
-	}
-	return 0;
-}
-
-static void audevrc_ioport_reset(struct audio_in *audio)
-{
-	/* Make sure read/write thread are free from
-	 * sleep and knowing that system is not able
-	 * to process io request at the moment
-	 */
-	wake_up(&audio->write_wait);
-	mutex_lock(&audio->write_lock);
-	audevrc_in_flush(audio);
-	mutex_unlock(&audio->write_lock);
-	wake_up(&audio->wait);
-	mutex_lock(&audio->read_lock);
-	audevrc_out_flush(audio);
-	mutex_unlock(&audio->read_lock);
-}
-
-static void audevrc_in_flush(struct audio_in *audio)
-{
-	int i;
-
-	audio->dsp_cnt = 0;
-	audio->in_head = 0;
-	audio->in_tail = 0;
-	audio->in_count = 0;
-	audio->eos_ack = 0;
-	for (i = 0; i < FRAME_NUM; i++) {
-		audio->in[i].size = 0;
-		audio->in[i].read = 0;
-	}
-	MM_DBG("in_bytes %d\n", atomic_read(&audio->in_bytes));
-	MM_DBG("in_samples %d\n", atomic_read(&audio->in_samples));
-	atomic_set(&audio->in_bytes, 0);
-	atomic_set(&audio->in_samples, 0);
-}
-
-static void audevrc_out_flush(struct audio_in *audio)
-{
-	int i;
-
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->out_count = 0;
-	for (i = 0; i < OUT_FRAME_NUM; i++) {
-		audio->out[i].size = 0;
-		audio->out[i].read = 0;
-		audio->out[i].used = 0;
-	}
-}
-
-/* ------------------- device --------------------- */
-static long audevrc_in_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct audio_in *audio = file->private_data;
-	int rc = 0;
-
-	MM_DBG("\n");
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		stats.byte_count = atomic_read(&audio->in_bytes);
-		stats.sample_count = atomic_read(&audio->in_samples);
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return rc;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START: {
-		uint32_t freq;
-		freq = 48000;
-		MM_DBG("AUDIO_START\n");
-		if (audio->in_call && (audio->voice_state !=
-				VOICE_STATE_INCALL)) {
-			rc = -EPERM;
-			break;
-		}
-		rc = msm_snddev_request_freq(&freq, audio->enc_id,
-					SNDDEV_CAP_TX, AUDDEV_CLNT_ENC);
-		MM_DBG("sample rate configured %d\n", freq);
-		if (rc < 0) {
-			MM_DBG(" Sample rate can not be set, return code %d\n",
-								 rc);
-			msm_snddev_withdraw_freq(audio->enc_id,
-					SNDDEV_CAP_TX, AUDDEV_CLNT_ENC);
-			MM_DBG("msm_snddev_withdraw_freq\n");
-			break;
-		}
-		/*update aurec session info in audpreproc layer*/
-		audio->session_info.session_id = audio->enc_id;
-		audio->session_info.sampling_freq = audio->samp_rate;
-		audpreproc_update_audrec_info(&audio->session_info);
-		rc = audevrc_in_enable(audio);
-		if (!rc) {
-			rc =
-			wait_event_interruptible_timeout(audio->wait_enable,
-				audio->running != 0, 1*HZ);
-			MM_DBG("state %d rc = %d\n", audio->running, rc);
-
-			if (audio->running == 0)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		audio->stopped = 0;
-		break;
-	}
-	case AUDIO_STOP: {
-		/*reset the sampling frequency information at audpreproc layer*/
-		audio->session_info.sampling_freq = 0;
-		audpreproc_update_audrec_info(&audio->session_info);
-		rc = audevrc_in_disable(audio);
-		rc = msm_snddev_withdraw_freq(audio->enc_id,
-					SNDDEV_CAP_TX, AUDDEV_CLNT_ENC);
-		MM_DBG("msm_snddev_withdraw_freq\n");
-		audio->stopped = 1;
-		break;
-	}
-	case AUDIO_FLUSH: {
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audevrc_ioport_reset(audio);
-		if (audio->running) {
-			audevrc_flush_command(audio);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-	}
-	case AUDIO_SET_STREAM_CONFIG: {
-		struct msm_audio_stream_config cfg;
-		if (copy_from_user(&cfg, (void *) arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		/* Allow only single frame */
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			if (cfg.buffer_size != (FRAME_SIZE - 8)) {
-				rc = -EINVAL;
-				break;
-			}
-		} else {
-			if (cfg.buffer_size != (EVRC_FRAME_SIZE + 14)) {
-				rc = -EINVAL;
-				break;
-			}
-		}
-		audio->buffer_size = cfg.buffer_size;
-		break;
-	}
-	case AUDIO_GET_STREAM_CONFIG: {
-		struct msm_audio_stream_config cfg;
-		memset(&cfg, 0, sizeof(cfg));
-		cfg.buffer_size = audio->buffer_size;
-		cfg.buffer_count = FRAME_NUM;
-		if (copy_to_user((void *) arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		break;
-	}
-	case AUDIO_GET_EVRC_ENC_CONFIG: {
-		if (copy_to_user((void *) arg, &audio->cfg, sizeof(audio->cfg)))
-			rc = -EFAULT;
-		break;
-	}
-	case AUDIO_SET_EVRC_ENC_CONFIG: {
-		struct msm_audio_evrc_enc_config cfg;
-		if (copy_from_user(&cfg, (void *) arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		MM_DBG("0X%8x, 0x%8x, 0x%8x\n", cfg.min_bit_rate,
-				cfg.max_bit_rate, cfg.cdma_rate);
-		if (cfg.min_bit_rate > CDMA_RATE_FULL || \
-				 cfg.min_bit_rate < CDMA_RATE_EIGHTH) {
-			MM_ERR("invalid min bitrate\n");
-			rc = -EFAULT;
-			break;
-		}
-		if (cfg.max_bit_rate > CDMA_RATE_FULL || \
-				cfg.max_bit_rate < CDMA_RATE_EIGHTH) {
-			MM_ERR("invalid max bitrate\n");
-			rc = -EFAULT;
-			break;
-		}
-		/* Recording Does not support Erase and Blank */
-		if (cfg.cdma_rate > CDMA_RATE_FULL ||
-			cfg.cdma_rate < CDMA_RATE_EIGHTH) {
-			MM_ERR("invalid qcelp cdma rate\n");
-			rc = -EFAULT;
-			break;
-		}
-		memcpy(&audio->cfg, &cfg, sizeof(cfg));
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config cfg;
-		memset(&cfg, 0, sizeof(cfg));
-		cfg.buffer_size = OUT_BUFFER_SIZE;
-		cfg.buffer_count = OUT_FRAME_NUM;
-		cfg.sample_rate = audio->samp_rate;
-		cfg.channel_count = audio->channel_mode;
-		if (copy_to_user((void *)arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		break;
-	}
-	case AUDIO_SET_INCALL: {
-		struct msm_voicerec_mode cfg;
-		unsigned long flags;
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			if (copy_from_user(&cfg, (void *) arg, sizeof(cfg))) {
-				rc = -EFAULT;
-				break;
-			}
-			if (cfg.rec_mode != VOC_REC_BOTH &&
-				cfg.rec_mode != VOC_REC_UPLINK &&
-				cfg.rec_mode != VOC_REC_DOWNLINK) {
-				MM_ERR("invalid rec_mode\n");
-				rc = -EINVAL;
-				break;
-			} else {
-				spin_lock_irqsave(&audio->dev_lock, flags);
-				if (cfg.rec_mode == VOC_REC_UPLINK)
-					audio->source = \
-						VOICE_UL_SOURCE_MIX_MASK;
-				else if (cfg.rec_mode == VOC_REC_DOWNLINK)
-					audio->source = \
-						VOICE_DL_SOURCE_MIX_MASK;
-				else
-					audio->source = \
-						VOICE_DL_SOURCE_MIX_MASK |
-						VOICE_UL_SOURCE_MIX_MASK ;
-				audio->in_call = 1;
-				spin_unlock_irqrestore(&audio->dev_lock, flags);
-			}
-		}
-		break;
-	}
-	case AUDIO_GET_SESSION_ID: {
-		if (copy_to_user((void *) arg, &audio->enc_id,
-			sizeof(unsigned short))) {
-			rc = -EFAULT;
-		}
-		break;
-	}
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static ssize_t audevrc_in_read(struct file *file,
-				char __user *buf,
-				size_t count, loff_t *pos)
-{
-	struct audio_in *audio = file->private_data;
-	unsigned long flags;
-	const char __user *start = buf;
-	void *data;
-	uint32_t index;
-	uint32_t size;
-	int rc = 0;
-	struct evrc_encoded_meta_out meta_field;
-	struct audio_frame_nt *nt_frame;
-	MM_DBG("count = %d\n", count);
-	mutex_lock(&audio->read_lock);
-	while (count > 0) {
-		rc = wait_event_interruptible(
-			audio->wait, (audio->in_count > 0) || audio->stopped ||
-			audio->rflush ||
-			((audio->mode == MSM_AUD_ENC_MODE_TUNNEL) &&
-			 audio->in_call && audio->running &&
-			(audio->voice_state == VOICE_STATE_OFFCALL)));
-		if (rc < 0)
-			break;
-
-		if (audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-		if (audio->stopped && !audio->in_count) {
-			MM_DBG("Driver in stop state, No more buffer to read");
-			rc = 0;/* End of File */
-			break;
-			} else if ((audio->mode == MSM_AUD_ENC_MODE_TUNNEL) &&
-					audio->in_call && audio->running &&
-					(audio->voice_state \
-						== VOICE_STATE_OFFCALL)) {
-				MM_DBG("Not Permitted Voice Terminated\n");
-				rc = -EPERM; /* Voice Call stopped */
-				break;
-		}
-
-		index = audio->in_tail;
-		data = (uint8_t *) audio->in[index].data;
-		size = audio->in[index].size;
-
-		if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) {
-			nt_frame = (struct audio_frame_nt *)(data -
-					sizeof(struct audio_frame_nt));
-			memcpy((char *)&meta_field.time_stamp_dword_lsw,
-				(char *)&nt_frame->time_stamp_dword_lsw,
-				(sizeof(struct evrc_encoded_meta_out) - \
-				sizeof(uint16_t)));
-			meta_field.metadata_len =
-					sizeof(struct evrc_encoded_meta_out);
-			if (copy_to_user((char *)start, (char *)&meta_field,
-					sizeof(struct evrc_encoded_meta_out))) {
-				rc = -EFAULT;
-				break;
-			}
-			if (nt_frame->nflag_lsw & 0x0001) {
-				MM_ERR("recieved EOS in read call\n");
-				audio->eos_ack = 1;
-			}
-			buf += sizeof(struct evrc_encoded_meta_out);
-			count -= sizeof(struct evrc_encoded_meta_out);
-		}
-		if (count >= size) {
-			if (copy_to_user(buf, data, size)) {
-				rc = -EFAULT;
-				break;
-			}
-			spin_lock_irqsave(&audio->dsp_lock, flags);
-			if (index != audio->in_tail) {
-				/* overrun -- data is
-				 * invalid and we need to retry */
-				spin_unlock_irqrestore(&audio->dsp_lock, flags);
-				continue;
-			}
-			audio->in[index].size = 0;
-			audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
-			audio->in_count--;
-			spin_unlock_irqrestore(&audio->dsp_lock, flags);
-			count -= size;
-			buf += size;
-			if ((audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL)) {
-				if (!audio->eos_ack) {
-					MM_DBG("sending read ptr command \
-							%d %d\n",
-							audio->dsp_cnt,
-							audio->in_tail);
-					audevrc_dsp_read_buffer(audio,
-							audio->dsp_cnt++);
-				}
-			}
-		} else {
-			MM_ERR("short read\n");
-			break;
-		}
-		break;
-	}
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		return buf - start;
-
-	return rc;
-}
-
-static void audpreproc_pcm_send_data(struct audio_in *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-	MM_DBG("\n");
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			MM_DBG("frame %d free\n", audio->out_tail);
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			audpreproc_pcm_buffer_ptr_refresh(audio,
-						 audio->out_tail,
-						    frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
- done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-
-static int audevrc_in_fsync(struct file *file, loff_t ppos1, loff_t ppos2, int datasync)
-
-{
-	struct audio_in *audio = file->private_data;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (!audio->running || (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)) {
-		rc = -EINVAL;
-		goto done_nolock;
-	}
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-			audio->wflush);
-	MM_DBG("waked on by some event audio->wflush = %d\n", audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-done:
-	mutex_unlock(&audio->write_lock);
-done_nolock:
-	return rc;
-
-}
-
- int audpreproc_evrc_process_eos(struct audio_in *audio,
-		const char __user *buf_start, unsigned short mfield_size)
-{
-	struct buffer *frame;
-	int rc = 0;
-
-	frame = audio->out + audio->out_head;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	MM_DBG("copying meta_out frame->used = %d\n", frame->used);
-	audpreproc_pcm_send_data(audio, 0);
-done:
-	return rc;
-}
-
-static ssize_t audevrc_in_write(struct file *file,
-				const char __user *buf,
-				size_t count, loff_t *pos)
-{
-	struct audio_in *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	char *cpy_ptr;
-	int rc = 0, eos_condition = AUDPREPROC_EVRC_EOS_NONE;
-	unsigned short mfield_size = 0;
-	int write_count = 0;
-	MM_DBG("cnt=%d\n", count);
-
-	if (count & 1)
-		return -EINVAL;
-
-	if (audio->mode != MSM_AUD_ENC_MODE_NONTUNNEL)
-		return -EINVAL;
-
-	mutex_lock(&audio->write_lock);
-	frame = audio->out + audio->out_head;
-	/* if supplied count is more than driver buffer size
-	 * then only copy driver buffer size
-	 */
-	if (count > frame->size)
-		count = frame->size;
-
-	write_count = count;
-	cpy_ptr = frame->data;
-	rc = wait_event_interruptible(audio->write_wait,
-				      (frame->used == 0)
-					|| (audio->stopped)
-					|| (audio->wflush));
-	if (rc < 0)
-		goto error;
-
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto error;
-	}
-	if (audio->mfield) {
-		if (buf == start) {
-			/* Processing beginning of user buffer */
-			if (__get_user(mfield_size,
-				(unsigned short __user *) buf)) {
-				rc = -EFAULT;
-				goto error;
-			} else if (mfield_size > count) {
-				rc = -EINVAL;
-				goto error;
-			}
-			MM_DBG("mf offset_val %x\n", mfield_size);
-			if (copy_from_user(cpy_ptr, buf, mfield_size)) {
-				rc = -EFAULT;
-				goto error;
-			}
-			/* Check if EOS flag is set and buffer has
-			 * contains just meta field
-			 */
-			if (cpy_ptr[AUDPREPROC_EVRC_EOS_FLG_OFFSET] &
-					AUDPREPROC_EVRC_EOS_FLG_MASK) {
-				eos_condition = AUDPREPROC_EVRC_EOS_SET;
-				MM_DBG("EOS SET\n");
-				if (mfield_size == count) {
-					buf += mfield_size;
-					eos_condition = 0;
-					goto exit;
-				} else
-				cpy_ptr[AUDPREPROC_EVRC_EOS_FLG_OFFSET] &=
-					~AUDPREPROC_EVRC_EOS_FLG_MASK;
-			}
-			cpy_ptr += mfield_size;
-			count -= mfield_size;
-			buf += mfield_size;
-		} else {
-			mfield_size = 0;
-			MM_DBG("continuous buffer\n");
-		}
-		frame->mfield_sz = mfield_size;
-	}
-	MM_DBG("copying the stream count = %d\n", count);
-	if (copy_from_user(cpy_ptr, buf, count)) {
-		rc = -EFAULT;
-		goto error;
-	}
-exit:
-	frame->used = count;
-	audio->out_head ^= 1;
-	if (!audio->flush_ack)
-		audpreproc_pcm_send_data(audio, 0);
-	else {
-		audpreproc_pcm_send_data(audio, 1);
-		audio->flush_ack = 0;
-	}
-	if (eos_condition == AUDPREPROC_EVRC_EOS_SET)
-		rc = audpreproc_evrc_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	return write_count;
-error:
-	mutex_unlock(&audio->write_lock);
-	return rc;
-}
-
-static int audevrc_in_release(struct inode *inode, struct file *file)
-{
-	struct audio_in *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	audio->in_call = 0;
-	/* with draw frequency for session
-	   incase not stopped the driver */
-	msm_snddev_withdraw_freq(audio->enc_id, SNDDEV_CAP_TX,
-					AUDDEV_CLNT_ENC);
-	auddev_unregister_evt_listner(AUDDEV_CLNT_ENC, audio->enc_id);
-	/*reset the sampling frequency information at audpreproc layer*/
-	audio->session_info.sampling_freq = 0;
-	audpreproc_update_audrec_info(&audio->session_info);
-	audevrc_in_disable(audio);
-	audevrc_in_flush(audio);
-	msm_adsp_put(audio->audrec);
-	audpreproc_aenc_free(audio->enc_id);
-	audio->audrec = NULL;
-	audio->opened = 0;
-	if (audio->data) {
-		ion_unmap_kernel(audio->client, audio->input_buff_handle);
-		ion_free(audio->client, audio->input_buff_handle);
-		audio->data = NULL;
-	}
-	if (audio->out_data) {
-		ion_unmap_kernel(audio->client, audio->output_buff_handle);
-		ion_free(audio->client, audio->output_buff_handle);
-		audio->out_data = NULL;
-	}
-	ion_client_destroy(audio->client);
-	mutex_unlock(&audio->lock);
-	return 0;
-}
-
-struct audio_in the_audio_evrc_in;
-static int audevrc_in_open(struct inode *inode, struct file *file)
-{
-	struct audio_in *audio = &the_audio_evrc_in;
-	int rc;
-	int encid;
-	int len = 0;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	struct ion_client *client = NULL;
-
-	mutex_lock(&audio->lock);
-	if (audio->opened) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	client = msm_ion_client_create(UINT_MAX, "Audio_EVRC_in_client");
-	if (IS_ERR_OR_NULL(client)) {
-		MM_ERR("Unable to create ION client\n");
-		rc = -ENOMEM;
-		goto client_create_error;
-	}
-	audio->client = client;
-
-	MM_DBG("allocating mem sz = %d\n", DMASZ);
-	handle = ion_alloc(client, DMASZ, SZ_4K,
-		ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-	if (IS_ERR_OR_NULL(handle)) {
-		MM_ERR("Unable to create allocate O/P buffers\n");
-		rc = -ENOMEM;
-		goto output_buff_alloc_error;
-	}
-
-	audio->output_buff_handle = handle;
-
-	rc = ion_phys(client , handle, &addr, &len);
-	if (rc) {
-		MM_ERR("O/P buffers:Invalid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-		rc = -ENOMEM;
-		goto output_buff_get_phys_error;
-	} else {
-		MM_INFO("O/P buffers:valid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-	}
-	audio->phys = (int32_t)addr;
-
-	rc = ion_handle_get_flags(client, handle, &ionflag);
-	if (rc) {
-		MM_ERR("could not get flags for the handle\n");
-		rc = -ENOMEM;
-		goto output_buff_get_flags_error;
-	}
-
-	audio->map_v_read = ion_map_kernel(client, handle);
-	if (IS_ERR(audio->map_v_read)) {
-		MM_ERR("could not map read buffers,freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENOMEM;
-		goto output_buff_map_error;
-	}
-	audio->data = audio->map_v_read;
-
-	MM_DBG("Memory addr = 0x%8x  phy addr = 0x%8x\n",\
-		(int) audio->data, (int) audio->phys);
-	if ((file->f_mode & FMODE_WRITE) &&
-		(file->f_mode & FMODE_READ)) {
-		audio->mode = MSM_AUD_ENC_MODE_NONTUNNEL;
-		MM_DBG("Opened for non tunnel mode encoding\n");
-	} else if (!(file->f_mode & FMODE_WRITE) &&
-					(file->f_mode & FMODE_READ)) {
-		audio->mode = MSM_AUD_ENC_MODE_TUNNEL;
-		MM_DBG("Opened for tunnel mode encoding\n");
-	} else {
-		MM_ERR("Invalid mode\n");
-		rc = -EACCES;
-		goto done;
-	}
-
-	/* Settings will be re-config at AUDIO_SET_CONFIG,
-	 * but at least we need to have initial config
-	 */
-	if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL)
-			audio->buffer_size = (EVRC_FRAME_SIZE + 14);
-	else
-			audio->buffer_size = (FRAME_SIZE - 8);
-	audio->enc_type = ENC_TYPE_EVRC | audio->mode;
-	audio->samp_rate = 8000;
-	audio->channel_mode = AUDREC_CMD_MODE_MONO;
-	audio->cfg.cdma_rate = CDMA_RATE_FULL;
-	audio->cfg.min_bit_rate = CDMA_RATE_FULL;
-	audio->cfg.max_bit_rate = CDMA_RATE_FULL;
-
-	encid = audpreproc_aenc_alloc(audio->enc_type, &audio->module_name,
-			&audio->queue_ids);
-	if (encid < 0) {
-		MM_ERR("No free encoder available\n");
-		rc = -ENODEV;
-		goto done;
-	}
-	audio->enc_id = encid;
-
-	rc = msm_adsp_get(audio->module_name, &audio->audrec,
-			   &audrec_evrc_adsp_ops, audio);
-
-	if (rc) {
-		audpreproc_aenc_free(audio->enc_id);
-		goto done;
-	}
-
-	audio->stopped = 0;
-	audio->source = 0;
-	audio->wflush = 0;
-	audio->rflush = 0;
-	audio->flush_ack = 0;
-
-	audevrc_in_flush(audio);
-	audevrc_out_flush(audio);
-
-	MM_DBG("allocating BUFFER_SIZE  %d\n", BUFFER_SIZE);
-	handle = ion_alloc(client, BUFFER_SIZE,
-			SZ_4K, ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-	if (IS_ERR_OR_NULL(handle)) {
-		MM_ERR("Unable to create allocate I/P buffers\n");
-		rc = -ENOMEM;
-		goto input_buff_alloc_error;
-	}
-
-	audio->input_buff_handle = handle;
-
-	rc = ion_phys(client , handle, &addr, &len);
-	if (rc) {
-		MM_ERR("I/P buffers:Invalid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-		rc = -ENOMEM;
-		goto input_buff_alloc_error;
-	} else {
-		MM_INFO("Got valid phy: %x sz: %x\n",
-			(unsigned int) addr,
-			(unsigned int) len);
-	}
-	audio->out_phys = (int32_t)addr;
-
-	rc = ion_handle_get_flags(client,
-		handle, &ionflag);
-	if (rc) {
-		MM_ERR("could not get flags for the handle\n");
-		rc = -ENOMEM;
-		goto input_buff_alloc_error;
-	}
-
-	audio->map_v_write = ion_map_kernel(client, handle);
-	if (IS_ERR(audio->map_v_write)) {
-		MM_ERR("could not map write buffers\n");
-		rc = -ENOMEM;
-		goto input_buff_map_error;
-	}
-	audio->out_data = audio->map_v_write;
-	MM_DBG("write buf: phy addr 0x%08x kernel addr 0x%08x\n",
-				(unsigned int)addr,
-				(unsigned int)audio->out_data);
-
-		/* Initialize buffer */
-	audio->out[0].data = audio->out_data + 0;
-	audio->out[0].addr = audio->out_phys + 0;
-	audio->out[0].size = OUT_BUFFER_SIZE;
-
-	audio->out[1].data = audio->out_data + OUT_BUFFER_SIZE;
-	audio->out[1].addr = audio->out_phys + OUT_BUFFER_SIZE;
-	audio->out[1].size = OUT_BUFFER_SIZE;
-
-	MM_DBG("audio->out[0].data = %d  audio->out[1].data = %d",
-					(unsigned int)audio->out[0].data,
-					(unsigned int)audio->out[1].data);
-	audio->device_events = AUDDEV_EVT_DEV_RDY | AUDDEV_EVT_DEV_RLS |
-				AUDDEV_EVT_VOICE_STATE_CHG;
-
-	audio->voice_state = msm_get_voice_state();
-	rc = auddev_register_evt_listner(audio->device_events,
-					AUDDEV_CLNT_ENC, audio->enc_id,
-					evrc_in_listener, (void *) audio);
-	if (rc) {
-		MM_ERR("failed to register device event listener\n");
-		iounmap(audio->map_v_write);
-		free_contiguous_memory_by_paddr(audio->out_phys);
-		goto evt_error;
-	}
-	audio->mfield = META_OUT_SIZE;
-	file->private_data = audio;
-	audio->opened = 1;
-	audio->out_frame_cnt++;
-	audio->build_id = socinfo_get_build_id();
-	MM_DBG("Modem build id = %s\n", audio->build_id);
-
-done:
-	mutex_unlock(&audio->lock);
-	return rc;
-evt_error:
-	msm_adsp_put(audio->audrec);
-	audpreproc_aenc_free(audio->enc_id);
-	mutex_unlock(&audio->lock);
-input_buff_map_error:
-	ion_free(client, audio->input_buff_handle);
-input_buff_alloc_error:
-	ion_unmap_kernel(client, audio->output_buff_handle);
-output_buff_map_error:
-output_buff_get_phys_error:
-output_buff_get_flags_error:
-	ion_free(client, audio->output_buff_handle);
-output_buff_alloc_error:
-	ion_client_destroy(client);
-client_create_error:
-	return rc;
-}
-
-static const struct file_operations audio_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audevrc_in_open,
-	.release	= audevrc_in_release,
-	.read		= audevrc_in_read,
-	.write		= audevrc_in_write,
-	.fsync		= audevrc_in_fsync,
-	.unlocked_ioctl	= audevrc_in_ioctl,
-};
-
-struct miscdevice audio_evrc_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_evrc_in",
-	.fops	= &audio_in_fops,
-};
-
-static int __init audevrc_in_init(void)
-{
-	mutex_init(&the_audio_evrc_in.lock);
-	mutex_init(&the_audio_evrc_in.read_lock);
-	spin_lock_init(&the_audio_evrc_in.dsp_lock);
-	spin_lock_init(&the_audio_evrc_in.dev_lock);
-	init_waitqueue_head(&the_audio_evrc_in.wait);
-	init_waitqueue_head(&the_audio_evrc_in.wait_enable);
-	mutex_init(&the_audio_evrc_in.write_lock);
-	init_waitqueue_head(&the_audio_evrc_in.write_wait);
-	return misc_register(&audio_evrc_in_misc);
-}
-
-device_initcall(audevrc_in_init);
diff --git a/arch/arm/mach-msm/qdsp5v2/audio_fm.c b/arch/arm/mach-msm/qdsp5v2/audio_fm.c
deleted file mode 100644
index 27548ac..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audio_fm.c
+++ /dev/null
@@ -1,357 +0,0 @@
-/* Copyright (c) 2009-2011, The Linux Foundation. All rights reserved.
- *
- * Based on the mp3 native driver in arch/arm/mach-msm/qdsp5v2/audio_mp3.c
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- *
- * All source code in this file is licensed under the following license except
- * where indicated.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you can find it at http://www.fsf.org
- */
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/delay.h>
-#include <linux/msm_audio.h>
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-#include <mach/msm_adsp.h>
-#include <mach/debug_mm.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/qdsp5v2/afe.h>
-#include <mach/qdsp5v2/acdb_commands.h>
-#include <mach/qdsp5v2/audio_acdbi.h>
-#include <mach/qdsp5v2/audio_acdb_def.h>
-
-#define SESSION_ID_FM 6
-#define FM_ENABLE	0xFFFF
-#define FM_DISABLE	0x0
-#define FM_COPP		0x2
-/* Macro specifies maximum FM routing
-	possible */
-#define FM_MAX_RX_ROUTE	0x2
-
-struct fm_rx_calib_gain {
-	uint16_t device_id;
-	struct auddev_evt_devinfo dev_details;
-	struct  acdb_calib_gain_rx  calib_rx;
-};
-
-struct audio {
-	struct mutex lock;
-
-	int opened;
-	int enabled;
-	int running;
-
-	uint16_t dec_id;
-	uint16_t source;
-	uint16_t fm_source;
-	uint16_t fm_mask;
-	uint32_t device_events;
-	uint16_t volume;
-	struct fm_rx_calib_gain fm_calibration_rx[FM_MAX_RX_ROUTE];
-};
-
-static struct audio fm_audio;
-
-/* must be called with audio->lock held */
-static int audio_enable(struct audio *audio)
-{
-	int rc = 0;
-	if (audio->enabled)
-		return 0;
-
-	MM_DBG("fm mask= %08x fm_source = %08x\n",
-			audio->fm_mask, audio->fm_source);
-	if (audio->fm_mask && audio->fm_source) {
-		rc = afe_config_fm_codec(FM_ENABLE, audio->fm_mask);
-		if (!rc)
-			audio->running = 1;
-		/* Routed to icodec rx path */
-		if ((audio->fm_mask & AFE_HW_PATH_CODEC_RX) ==
-				AFE_HW_PATH_CODEC_RX) {
-			afe_config_fm_calibration_gain(
-			audio->fm_calibration_rx[0].device_id,
-			audio->fm_calibration_rx[0].calib_rx.audppcalgain);
-		}
-		/* Routed to aux codec rx path */
-		if ((audio->fm_mask & AFE_HW_PATH_AUXPCM_RX) ==
-				AFE_HW_PATH_AUXPCM_RX){
-			afe_config_fm_calibration_gain(
-			audio->fm_calibration_rx[1].device_id,
-			audio->fm_calibration_rx[1].calib_rx.audppcalgain);
-		}
-	}
-
-	audio->enabled = 1;
-	return rc;
-}
-
-static void fm_listner(u32 evt_id, union auddev_evt_data *evt_payload,
-			void *private_data)
-{
-	struct audio *audio = (struct audio *) private_data;
-	struct auddev_evt_devinfo *devinfo =
-			(struct auddev_evt_devinfo *)evt_payload;
-	switch (evt_id) {
-	case AUDDEV_EVT_DEV_RDY:
-		MM_DBG(":AUDDEV_EVT_DEV_RDY\n");
-		if (evt_payload->routing_id == FM_COPP)
-			audio->fm_source = 1;
-		else
-			audio->source = (0x1 << evt_payload->routing_id);
-
-		if (audio->source & 0x1)
-			audio->fm_mask = 0x1;
-		else if (audio->source & 0x2)
-			audio->fm_mask = 0x3;
-		else
-			audio->fm_mask = 0x0;
-
-		if (!audio->enabled
-			|| !audio->fm_mask
-			|| !audio->fm_source)
-			break;
-		else {
-			afe_config_fm_codec(FM_ENABLE, audio->fm_mask);
-			audio->running = 1;
-		}
-		break;
-	case AUDDEV_EVT_DEV_RLS:
-		MM_DBG(":AUDDEV_EVT_DEV_RLS\n");
-		if (evt_payload->routing_id == FM_COPP)
-			audio->fm_source = 0;
-		else
-			audio->source &= ~(0x1 << evt_payload->routing_id);
-
-		if (audio->source & 0x1)
-			audio->fm_mask = 0x1;
-		else if (audio->source & 0x2)
-			audio->fm_mask = 0x3;
-		else
-			audio->fm_mask = 0x0;
-
-		if (audio->running
-			&& (!audio->fm_mask || !audio->fm_source)) {
-			afe_config_fm_codec(FM_DISABLE, audio->fm_mask);
-			audio->running = 0;
-		}
-		break;
-	case AUDDEV_EVT_STREAM_VOL_CHG:
-		MM_DBG(":AUDDEV_EVT_STREAM_VOL_CHG, stream vol \n");
-		audio->volume = evt_payload->session_vol;
-		afe_config_fm_volume(audio->volume);
-		break;
-	case AUDDEV_EVT_DEVICE_INFO:{
-		struct acdb_get_block get_block;
-		int rc = 0;
-		MM_DBG(":AUDDEV_EVT_DEVICE_INFO\n");
-		MM_DBG("sample_rate = %d\n", devinfo->sample_rate);
-		MM_DBG("acdb_id = %d\n", devinfo->acdb_id);
-		/* Applucable only for icodec rx and aux codec rx path
-			and fm stream routed to it */
-		if (((devinfo->dev_id == 0x00) || (devinfo->dev_id == 0x01)) &&
-			(devinfo->sessions && (1 << audio->dec_id))) {
-			/* Query ACDB driver for calib gain, only if difference
-				in device */
-			if ((audio->fm_calibration_rx[devinfo->dev_id].
-				dev_details.acdb_id != devinfo->acdb_id) ||
-				(audio->fm_calibration_rx[devinfo->dev_id].
-				dev_details.sample_rate !=
-					devinfo->sample_rate)) {
-				audio->fm_calibration_rx[devinfo->dev_id].
-					dev_details.dev_id = devinfo->dev_id;
-				audio->fm_calibration_rx[devinfo->dev_id].
-					dev_details.sample_rate =
-						devinfo->sample_rate;
-				audio->fm_calibration_rx[devinfo->dev_id].
-					dev_details.dev_type =
-						devinfo->dev_type;
-				audio->fm_calibration_rx[devinfo->dev_id].
-					dev_details.sessions =
-						devinfo->sessions;
-				/* Query ACDB driver for calibration gain */
-				get_block.acdb_id = devinfo->acdb_id;
-				get_block.sample_rate_id = devinfo->sample_rate;
-				get_block.interface_id =
-					IID_AUDIO_CALIBRATION_GAIN_RX;
-				get_block.algorithm_block_id =
-					ABID_AUDIO_CALIBRATION_GAIN_RX;
-				get_block.total_bytes =
-					sizeof(struct  acdb_calib_gain_rx);
-				get_block.buf_ptr = (u32 *)
-				&audio->fm_calibration_rx[devinfo->dev_id].
-				calib_rx;
-
-				rc = acdb_get_calibration_data(&get_block);
-				if (rc < 0) {
-					MM_ERR("Unable to get calibration"\
-						"gain\n");
-					/* Set to unity incase of error */
-					audio->\
-					fm_calibration_rx[devinfo->dev_id].
-					calib_rx.audppcalgain = 0x2000;
-				} else
-					MM_DBG("calibration gain = 0x%8x\n",
-						*(get_block.buf_ptr));
-			}
-			if (audio->running) {
-				afe_config_fm_calibration_gain(
-				audio->fm_calibration_rx[devinfo->dev_id].
-					device_id,
-				audio->fm_calibration_rx[devinfo->dev_id].
-					calib_rx.audppcalgain);
-				}
-			}
-		break;
-	}
-	default:
-		MM_DBG(":ERROR:wrong event\n");
-		break;
-	}
-}
-/* must be called with audio->lock held */
-static int audio_disable(struct audio *audio)
-{
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	return afe_config_fm_codec(FM_DISABLE, audio->source);
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = -EINVAL;
-
-	MM_DBG("cmd = %d\n", cmd);
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		MM_DBG("AUDIO_START\n");
-		rc = audio_enable(audio);
-		break;
-	case AUDIO_STOP:
-		MM_DBG("AUDIO_STOP\n");
-		rc = audio_disable(audio);
-		audio->running = 0;
-		audio->enabled = 0;
-		break;
-	case AUDIO_GET_SESSION_ID:
-		if (copy_to_user((void *) arg, &audio->dec_id,
-					sizeof(unsigned short)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static int audio_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	MM_DBG("audio instance 0x%08x freeing\n", (int)audio);
-	mutex_lock(&audio->lock);
-	auddev_unregister_evt_listner(AUDDEV_CLNT_DEC, audio->dec_id);
-	audio_disable(audio);
-	audio->running = 0;
-	audio->enabled = 0;
-	audio->opened = 0;
-	mutex_unlock(&audio->lock);
-	return 0;
-}
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = &fm_audio;
-	int rc = 0;
-
-
-	if (audio->opened)
-		return -EPERM;
-
-	/* Allocate the decoder */
-	audio->dec_id = SESSION_ID_FM;
-
-	audio->running = 0;
-	audio->fm_source = 0;
-	audio->fm_mask = 0;
-
-	/* Initialize the calibration gain structure */
-	audio->fm_calibration_rx[0].device_id = AFE_HW_PATH_CODEC_RX;
-	audio->fm_calibration_rx[1].device_id = AFE_HW_PATH_AUXPCM_RX;
-	audio->fm_calibration_rx[0].calib_rx.audppcalgain = 0x2000;
-	audio->fm_calibration_rx[1].calib_rx.audppcalgain = 0x2000;
-	audio->fm_calibration_rx[0].dev_details.acdb_id = PSEUDO_ACDB_ID;
-	audio->fm_calibration_rx[1].dev_details.acdb_id = PSEUDO_ACDB_ID;
-
-	audio->device_events = AUDDEV_EVT_DEV_RDY
-				|AUDDEV_EVT_DEV_RLS|
-				AUDDEV_EVT_STREAM_VOL_CHG|
-				AUDDEV_EVT_DEVICE_INFO;
-
-	rc = auddev_register_evt_listner(audio->device_events,
-					AUDDEV_CLNT_DEC,
-					audio->dec_id,
-					fm_listner,
-					(void *)audio);
-
-	if (rc) {
-		MM_ERR("%s: failed to register listnet\n", __func__);
-		goto event_err;
-	}
-
-	audio->opened = 1;
-	file->private_data = audio;
-
-event_err:
-	return rc;
-}
-
-static const struct file_operations audio_fm_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audio_open,
-	.release	= audio_release,
-	.unlocked_ioctl	= audio_ioctl,
-};
-
-struct miscdevice audio_fm_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_fm",
-	.fops	= &audio_fm_fops,
-};
-
-static int __init audio_init(void)
-{
-	struct audio *audio = &fm_audio;
-
-	mutex_init(&audio->lock);
-	return misc_register(&audio_fm_misc);
-}
-
-device_initcall(audio_init);
-
-MODULE_DESCRIPTION("MSM FM driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5v2/audio_interct.c b/arch/arm/mach-msm/qdsp5v2/audio_interct.c
deleted file mode 100644
index 4e4c5d6..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audio_interct.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/* Copyright (c) 2009, 2011 The Linux Foundation. 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.
- *
- */
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <asm/io.h>
-#include <mach/qdsp5v2/audio_interct.h>
-
-#define AUDIO_INTERCT_ADSPLPA_WBRX_SEL_BMSK 0x4
-#define AUDIO_INTERCT_ADSPLPA_WBRX_SEL_SHFT 0x2
-#define AUDIO_INTERCT_ADSPAV_RPCMI2SRX_SEL_BMSK 0x10
-#define AUDIO_INTERCT_ADSPAV_RPCMI2SRX_SEL_SHFT 0x4
-#define AUDIO_INTERCT_ADSPAV_TPCMI2STX_SEL_BMSK 0x40
-#define AUDIO_INTERCT_ADSPAV_TPCMI2STX_SEL_SHFT 0x6
-#define AUDIO_INTERCT_ADSPAV_AUX_REGSEL_BMSK 0x100
-#define AUDIO_INTERCT_ADSPAV_AUX_REGSEL_SHFT 0x8
-
-/* Should look to protect this register */
-void __iomem *aictl_reg;
-
-void audio_interct_codec(u32 source)
-{
-	u32 reg_val;
-
-	reg_val = readl(aictl_reg);
-	reg_val = (reg_val & ~AUDIO_INTERCT_ADSPLPA_WBRX_SEL_BMSK) |
-		(source << AUDIO_INTERCT_ADSPLPA_WBRX_SEL_SHFT);
-	writel(reg_val, aictl_reg);
-	mb();
-}
-EXPORT_SYMBOL(audio_interct_codec);
-
-void audio_interct_aux_regsel(u32 source)
-{
-	u32 reg_val;
-
-	reg_val = readl(aictl_reg);
-	reg_val = (reg_val & ~AUDIO_INTERCT_ADSPAV_AUX_REGSEL_BMSK) |
-		(source << AUDIO_INTERCT_ADSPAV_AUX_REGSEL_SHFT);
-	writel(reg_val, aictl_reg);
-	mb();
-}
-EXPORT_SYMBOL(audio_interct_aux_regsel);
-
-void audio_interct_tpcm_source(u32 source)
-{
-	u32 reg_val;
-
-	reg_val = readl(aictl_reg);
-	reg_val = (reg_val & ~AUDIO_INTERCT_ADSPAV_TPCMI2STX_SEL_BMSK) |
-		(source << AUDIO_INTERCT_ADSPAV_TPCMI2STX_SEL_SHFT);
-	writel(reg_val, aictl_reg);
-	mb();
-}
-EXPORT_SYMBOL(audio_interct_tpcm_source);
-
-void audio_interct_rpcm_source(u32 source)
-{
-	u32 reg_val;
-
-	reg_val = readl(aictl_reg);
-	reg_val = (reg_val & ~AUDIO_INTERCT_ADSPAV_RPCMI2SRX_SEL_BMSK) |
-		(source << AUDIO_INTERCT_ADSPAV_RPCMI2SRX_SEL_SHFT);
-	writel(reg_val, aictl_reg);
-	mb();
-}
-EXPORT_SYMBOL(audio_interct_rpcm_source);
-
-static int audio_interct_probe(struct platform_device *pdev)
-{
-	int rc = 0;
-	struct resource *aictl_mem;
-
-	aictl_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!aictl_mem) {
-		rc = -ENODEV;
-		goto error;
-	}
-	aictl_reg = ioremap(aictl_mem->start,
-			(aictl_mem->end - aictl_mem->start) + 1);
-error:
-	return rc;
-}
-
-
-static int audio_interct_remove(struct platform_device *pdev)
-{
-	iounmap(aictl_reg);
-	return 0;
-}
-
-static struct platform_driver audio_interct_driver = {
-	.probe = audio_interct_probe,
-	.remove = audio_interct_remove,
-	.driver = {
-		.name = "audio_interct",
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init audio_interct_init(void)
-{
-	return platform_driver_register(&audio_interct_driver);
-}
-
-static void __exit audio_interct_exit(void)
-{
-	platform_driver_unregister(&audio_interct_driver);
-}
-
-module_init(audio_interct_init);
-module_exit(audio_interct_exit);
-
-MODULE_DESCRIPTION("MSM Audio Interconnect driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5v2/audio_lpa.c b/arch/arm/mach-msm/qdsp5v2/audio_lpa.c
deleted file mode 100644
index 7ec0617..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audio_lpa.c
+++ /dev/null
@@ -1,1780 +0,0 @@
-/* low power audio output device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/cdev.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/earlysuspend.h>
-#include <linux/list.h>
-#include <linux/msm_ion.h>
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-#include <mach/msm_adsp.h>
-#include <linux/slab.h>
-#include <linux/msm_audio.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <linux/memory_alloc.h>
-
-#include <mach/qdsp5v2/qdsp5audppmsg.h>
-#include <mach/qdsp5v2/qdsp5audplaycmdi.h>
-#include <mach/qdsp5v2/qdsp5audplaymsg.h>
-#include <mach/qdsp5v2/audpp.h>
-#include <mach/qdsp5v2/codec_utils.h>
-#include <mach/qdsp5v2/mp3_funcs.h>
-#include <mach/qdsp5v2/pcm_funcs.h>
-#include <mach/debug_mm.h>
-
-#define ADRV_STATUS_AIO_INTF 0x00000001
-#define ADRV_STATUS_OBUF_GIVEN 0x00000002
-#define ADRV_STATUS_IBUF_GIVEN 0x00000004
-#define ADRV_STATUS_FSYNC 0x00000008
-#define ADRV_STATUS_PAUSE 0x00000010
-
-#define DEVICE_SWITCH_STATE_NONE     0
-#define DEVICE_SWITCH_STATE_PENDING  1
-#define DEVICE_SWITCH_STATE_READY    2
-#define DEVICE_SWITCH_STATE_COMPLETE 3
-
-#define AUDDEC_DEC_PCM 0
-#define AUDDEC_DEC_MP3 2
-
-#define PCM_BUFSZ_MIN 4800	/* Hold one stereo MP3 frame */
-
-/* Decoder status received from AUDPPTASK */
-#define  AUDPP_DEC_STATUS_SLEEP	0
-#define	 AUDPP_DEC_STATUS_INIT  1
-#define  AUDPP_DEC_STATUS_CFG   2
-#define  AUDPP_DEC_STATUS_PLAY  3
-
-#define AUDMP3_METAFIELD_MASK 0xFFFF0000
-#define AUDMP3_EOS_FLG_OFFSET 0x0A /* Offset from beginning of buffer */
-#define AUDMP3_EOS_FLG_MASK 0x01
-#define AUDMP3_EOS_NONE 0x0 /* No EOS detected */
-#define AUDMP3_EOS_SET 0x1 /* EOS set in meta field */
-
-#define AUDLPA_EVENT_NUM 10 /* Default number of pre-allocated event packets */
-
-#define MASK_32BITS     0xFFFFFFFF
-
-#define MAX_BUF 4
-#define BUFSZ (524288)
-
-#define __CONTAINS(r, v, l) ({					\
-	typeof(r) __r = r;					\
-	typeof(v) __v = v;					\
-	typeof(v) __e = __v + l;				\
-	int res = ((__v >= __r->vaddr) && 			\
-		(__e <= __r->vaddr + __r->len));		\
-	res;							\
-})
-
-#define CONTAINS(r1, r2) ({					\
-	typeof(r2) __r2 = r2;					\
-	__CONTAINS(r1, __r2->vaddr, __r2->len);			\
-})
-
-#define IN_RANGE(r, v) ({					\
-	typeof(r) __r = r;					\
-	typeof(v) __vv = v;					\
-	int res = ((__vv >= __r->vaddr) &&			\
-		(__vv < (__r->vaddr + __r->len)));		\
-	res;							\
-})
-
-#define OVERLAPS(r1, r2) ({					\
-	typeof(r1) __r1 = r1;					\
-	typeof(r2) __r2 = r2;					\
-	typeof(__r2->vaddr) __v = __r2->vaddr;			\
-	typeof(__v) __e = __v + __r2->len - 1;			\
-	int res = (IN_RANGE(__r1, __v) || IN_RANGE(__r1, __e));	\
-	res;							\
-})
-
-/* payload[7]; -1 indicates error, 0 indicates no error */
-#define CHECK_ERROR(v) (!v[7])
-
-/* calculates avsync_info from payload */
-#define CALCULATE_AVSYNC_FROM_PAYLOAD(v) ((uint64_t)((((uint64_t)v[10]) \
-					<< 32) | (v[11] & MASK_32BITS)))
-
-/* calculates avsync_info from avsync_info stored in audio */
-#define CALCULATE_AVSYNC(v)					   \
-			((uint64_t)((((uint64_t)v[4]) << 32) | 	   \
-			 (v[5] << 16) | (v[6])))
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-struct audlpa_suspend_ctl {
-	struct early_suspend node;
-	struct audio *audio;
-};
-#endif
-
-struct audlpa_event {
-	struct list_head list;
-	int event_type;
-	union msm_audio_event_payload payload;
-};
-
-struct audlpa_ion_region {
-	struct list_head list;
-	struct ion_handle *handle;
-	int fd;
-	void *vaddr;
-	unsigned long paddr;
-	unsigned long kvaddr;
-	unsigned long len;
-	unsigned ref_cnt;
-};
-
-struct audlpa_buffer_node {
-	struct list_head list;
-	struct msm_audio_aio_buf buf;
-	unsigned long paddr;
-};
-
-struct audlpa_dec {
-	char *name;
-	int dec_attrb;
-	long (*ioctl)(struct file *, unsigned int, unsigned long);
-	void (*adec_params)(struct audio *);
-};
-
-struct audlpa_dec audlpa_decs[] = {
-	{"msm_mp3_lp", AUDDEC_DEC_MP3, &mp3_ioctl, &audpp_cmd_cfg_mp3_params},
-	{"msm_pcm_lp_dec", AUDDEC_DEC_PCM, &pcm_ioctl,
-		&audpp_cmd_cfg_pcm_params},
-};
-
-static int auddec_dsp_config(struct audio *audio, int enable);
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg);
-static void audlpa_post_event(struct audio *audio, int type,
-	union msm_audio_event_payload payload);
-static unsigned long audlpa_ion_fixup(struct audio *audio, void *addr,
-				unsigned long len, int ref_up);
-static void audlpa_async_send_data(struct audio *audio, unsigned needed,
-				uint32_t *payload);
-
-static void lpa_listner(u32 evt_id, union auddev_evt_data *evt_payload,
-			void *private_data)
-{
-	struct audio *audio = (struct audio *) private_data;
-	switch (evt_id) {
-	case AUDDEV_EVT_DEV_RDY:
-		MM_DBG(":AUDDEV_EVT_DEV_RDY routing id = %d\n",
-		evt_payload->routing_id);
-		/* Do not select HLB path for icodec, if there is already COPP3
-		 * routing exists. DSP can not support concurrency of HLB path
-		 * and COPP3 routing as it involves different buffer Path */
-		if (((0x1 << evt_payload->routing_id) == AUDPP_MIXER_ICODEC) &&
-			!(audio->source & AUDPP_MIXER_3)) {
-			audio->source |= AUDPP_MIXER_HLB;
-			MM_DBG("mixer_mask modified for low-power audio\n");
-		} else
-			audio->source |= (0x1 << evt_payload->routing_id);
-
-		MM_DBG("running = %d, enabled = %d, source = 0x%x\n",
-			audio->running, audio->enabled, audio->source);
-		if (audio->running == 1 && audio->enabled == 1) {
-			audpp_route_stream(audio->dec_id, audio->source);
-			if (audio->source & AUDPP_MIXER_HLB) {
-				audpp_dsp_set_vol_pan(
-					AUDPP_CMD_CFG_DEV_MIXER_ID_4,
-					&audio->vol_pan,
-					COPP);
-					/*restore the POPP gain to 0x2000
-					this is needed to avoid use cases
-					where POPP volume is lowered during
-					NON HLB playback, when device moved
-					from NON HLB to HLB POPP is not
-					disabled but POPP gain will be retained
-					as the old one which result
-					in lower volume*/
-					audio->vol_pan.volume = 0x2000;
-					audpp_dsp_set_vol_pan(
-						audio->dec_id,
-						&audio->vol_pan, POPP);
-			} else if (audio->source & AUDPP_MIXER_NONHLB)
-				audpp_dsp_set_vol_pan(
-					audio->dec_id, &audio->vol_pan, POPP);
-			if (audio->device_switch == DEVICE_SWITCH_STATE_READY) {
-				audio->wflush = 1;
-				audio->device_switch =
-					DEVICE_SWITCH_STATE_COMPLETE;
-				audpp_flush(audio->dec_id);
-				if (wait_event_interruptible(audio->write_wait,
-							 !audio->wflush) < 0)
-					MM_DBG("AUDIO_FLUSH interrupted\n");
-
-				if (audio->wflush == 0) {
-					if (audio->drv_status &
-						ADRV_STATUS_PAUSE) {
-						if (audpp_pause(audio->dec_id,
-							1))
-							MM_DBG("audpp_pause"
-								"failed\n");
-					}
-				}
-			}
-		}
-		break;
-	case AUDDEV_EVT_REL_PENDING:
-		MM_DBG(":AUDDEV_EVT_REL_PENDING\n");
-		/* If route to multiple devices like COPP3, not need to
-		 * handle device switch */
-		if ((audio->running == 1) && (audio->enabled == 1) &&
-			!(audio->source & AUDPP_MIXER_3)) {
-			if (audio->device_switch == DEVICE_SWITCH_STATE_NONE) {
-				if (!(audio->drv_status & ADRV_STATUS_PAUSE)) {
-					if (audpp_pause(audio->dec_id, 1))
-						MM_DBG("audpp pause failed\n");
-				}
-				audio->device_switch =
-					DEVICE_SWITCH_STATE_PENDING;
-				audio->avsync_flag = 0;
-				if (audpp_query_avsync(audio->dec_id) < 0)
-					MM_DBG("query avsync failed\n");
-
-				if (wait_event_interruptible_timeout
-					(audio->avsync_wait, audio->avsync_flag,
-				 msecs_to_jiffies(AVSYNC_EVENT_TIMEOUT)) < 0)
-					MM_DBG("AV sync timeout failed\n");
-				if (audio->avsync_flag == 1) {
-					if (audio->device_switch ==
-						DEVICE_SWITCH_STATE_PENDING)
-						audio->device_switch =
-						DEVICE_SWITCH_STATE_READY;
-				}
-			}
-		}
-		break;
-	case AUDDEV_EVT_DEV_RLS:
-		/* If there is already COPP3 routing exists. icodec route
-		 * was not having HLB path. */
-		MM_DBG(":AUDDEV_EVT_DEV_RLS routing id = %d\n",
-			evt_payload->routing_id);
-		if (((0x1 << evt_payload->routing_id) == AUDPP_MIXER_ICODEC) &&
-			!(audio->source & AUDPP_MIXER_3))
-			audio->source &= ~AUDPP_MIXER_HLB;
-		else
-			audio->source &= ~(0x1 << evt_payload->routing_id);
-		MM_DBG("running = %d, enabled = %d, source = 0x%x\n",
-			audio->running, audio->enabled, audio->source);
-
-		if (audio->running == 1 && audio->enabled == 1)
-			audpp_route_stream(audio->dec_id, audio->source);
-		break;
-	case AUDDEV_EVT_STREAM_VOL_CHG:
-		audio->vol_pan.volume = evt_payload->session_vol;
-		MM_DBG("\n:AUDDEV_EVT_STREAM_VOL_CHG, stream vol %d\n"
-			"running = %d, enabled = %d, source = 0x%x",
-			audio->vol_pan.volume, audio->running,
-			audio->enabled, audio->source);
-		if (audio->running == 1 && audio->enabled == 1) {
-			if (audio->source & AUDPP_MIXER_HLB)
-				audpp_dsp_set_vol_pan(
-					AUDPP_CMD_CFG_DEV_MIXER_ID_4,
-					&audio->vol_pan, COPP);
-			else if (audio->source & AUDPP_MIXER_NONHLB)
-				audpp_dsp_set_vol_pan(
-					audio->dec_id, &audio->vol_pan, POPP);
-		}
-		break;
-	default:
-		MM_ERR(":ERROR:wrong event\n");
-		break;
-	}
-}
-
-/* must be called with audio->lock held */
-static int audio_enable(struct audio *audio)
-{
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	if (audio->enabled)
-		return 0;
-
-	audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-	audio->out_needed = 0;
-
-	if (msm_adsp_enable(audio->audplay)) {
-		MM_ERR("msm_adsp_enable(audplay) failed\n");
-		return -ENODEV;
-	}
-
-	if (audpp_enable(audio->dec_id, audio_dsp_event, audio)) {
-		MM_ERR("audpp_enable() failed\n");
-		msm_adsp_disable(audio->audplay);
-		return -ENODEV;
-	}
-
-	audio->enabled = 1;
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audio_disable(struct audio *audio)
-{
-	int rc = 0;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-		auddec_dsp_config(audio, 0);
-		rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-		if (rc == 0)
-			rc = -ETIMEDOUT;
-		else if (audio->dec_state != MSM_AUD_DECODER_STATE_CLOSE)
-			rc = -EFAULT;
-		else
-			rc = 0;
-		wake_up(&audio->write_wait);
-		msm_adsp_disable(audio->audplay);
-		audpp_disable(audio->dec_id, audio);
-		audio->out_needed = 0;
-	}
-	return rc;
-}
-
-/* ------------------- dsp --------------------- */
-static void audplay_dsp_event(void *data, unsigned id, size_t len,
-			      void (*getevent) (void *ptr, size_t len))
-{
-	struct audio *audio = data;
-	uint32_t msg[28];
-	getevent(msg, sizeof(msg));
-
-	MM_DBG("msg_id=%x\n", id);
-
-	switch (id) {
-	case AUDPLAY_MSG_DEC_NEEDS_DATA:
-		audlpa_async_send_data(audio, 1, msg);
-		break;
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audplaytask)\n");
-		break;
-	default:
-		MM_ERR("unexpected message from decoder\n");
-		break;
-	}
-}
-
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg)
-{
-	struct audio *audio = private;
-
-	switch (id) {
-	case AUDPP_MSG_STATUS_MSG:{
-			unsigned status = msg[1];
-
-			switch (status) {
-			case AUDPP_DEC_STATUS_SLEEP: {
-				uint16_t reason = msg[2];
-				MM_DBG("decoder status: sleep reason=0x%04x\n",
-						reason);
-				if ((reason == AUDPP_MSG_REASON_MEM)
-					|| (reason ==
-					AUDPP_MSG_REASON_NODECODER)) {
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_FAILURE;
-					wake_up(&audio->wait);
-				} else if (reason == AUDPP_MSG_REASON_NONE) {
-					/* decoder is in disable state */
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_CLOSE;
-					wake_up(&audio->wait);
-				}
-				break;
-			}
-			case AUDPP_DEC_STATUS_INIT:
-				MM_DBG("decoder status: init\n");
-				audio->codec_ops.adec_params(audio);
-				break;
-			case AUDPP_DEC_STATUS_CFG:
-				MM_DBG("decoder status: cfg\n");
-				break;
-			case AUDPP_DEC_STATUS_PLAY:
-				MM_DBG("decoder status: play\n");
-				/* send  mixer command */
-				audpp_route_stream(audio->dec_id,
-						audio->source);
-				audio->dec_state =
-					MSM_AUD_DECODER_STATE_SUCCESS;
-				wake_up(&audio->wait);
-				break;
-			case AUDPP_DEC_STATUS_EOS:
-				MM_DBG("decoder status: EOS\n");
-				audio->teos = 1;
-				wake_up(&audio->write_wait);
-				break;
-			default:
-				MM_ERR("unknown decoder status\n");
-				break;
-			}
-			break;
-		}
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_DBG("CFG_MSG ENABLE\n");
-			auddec_dsp_config(audio, 1);
-			audio->out_needed = 0;
-			audio->running = 1;
-			MM_DBG("source = 0x%x\n", audio->source);
-			if (audio->source & AUDPP_MIXER_HLB)
-				audpp_dsp_set_vol_pan(
-					AUDPP_CMD_CFG_DEV_MIXER_ID_4,
-					&audio->vol_pan,
-					COPP);
-			else if (audio->source & AUDPP_MIXER_NONHLB)
-				audpp_dsp_set_vol_pan(
-					audio->dec_id, &audio->vol_pan,
-					POPP);
-			audpp_dsp_set_eq(audio->dec_id, audio->eq_enable,
-					&audio->eq, POPP);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			MM_DBG("CFG_MSG DISABLE\n");
-			audio->running = 0;
-		} else {
-			MM_DBG("CFG_MSG %d?\n", msg[0]);
-		}
-		break;
-	case AUDPP_MSG_ROUTING_ACK:
-		MM_DBG("ROUTING_ACK mode=%d\n",	msg[1]);
-		audio->codec_ops.adec_params(audio);
-		break;
-
-	case AUDPP_MSG_FLUSH_ACK:
-		MM_DBG("FLUSH_ACK\n");
-		audio->wflush = 0;
-		wake_up(&audio->write_wait);
-		break;
-
-	case AUDPP_MSG_PCMDMAMISSED:
-		MM_DBG("PCMDMAMISSED\n");
-		wake_up(&audio->write_wait);
-		break;
-
-	case AUDPP_MSG_AVSYNC_MSG:
-		MM_DBG("AVSYNC_MSG\n");
-		memcpy(&audio->avsync[0], msg, sizeof(audio->avsync));
-		audio->avsync_flag = 1;
-		wake_up(&audio->avsync_wait);
-		break;
-
-	default:
-		MM_ERR("UNKNOWN (%d)\n", id);
-	}
-
-}
-
-struct msm_adsp_ops audplay_adsp_ops_lpa = {
-	.event = audplay_dsp_event,
-};
-
-#define audplay_send_queue0(audio, cmd, len) \
-	msm_adsp_write(audio->audplay, audio->queue_id, \
-			cmd, len)
-
-static int auddec_dsp_config(struct audio *audio, int enable)
-{
-	struct audpp_cmd_cfg_dec_type cfg_dec_cmd;
-
-	memset(&cfg_dec_cmd, 0, sizeof(cfg_dec_cmd));
-
-	cfg_dec_cmd.cmd_id = AUDPP_CMD_CFG_DEC_TYPE;
-	if (enable)
-		cfg_dec_cmd.dec_cfg = AUDPP_CMD_UPDATDE_CFG_DEC |
-			AUDPP_CMD_ENA_DEC_V |
-			audlpa_decs[audio->minor_no].dec_attrb;
-	else
-		cfg_dec_cmd.dec_cfg = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_DIS_DEC_V;
-	cfg_dec_cmd.dm_mode = 0x0;
-	cfg_dec_cmd.stream_id = audio->dec_id;
-	return audpp_send_queue1(&cfg_dec_cmd, sizeof(cfg_dec_cmd));
-}
-
-static void audlpa_async_send_buffer(struct audio *audio)
-{
-	int	found = 0;
-	uint64_t temp = 0;
-	struct audplay_cmd_bitstream_data_avail cmd;
-	struct audlpa_buffer_node *next_buf = NULL;
-
-	temp = audio->bytecount_head;
-	if (audio->device_switch == DEVICE_SWITCH_STATE_NONE) {
-		list_for_each_entry(next_buf, &audio->out_queue, list) {
-			if (temp == audio->bytecount_given) {
-				found = 1;
-				break;
-			} else
-				temp += next_buf->buf.data_len;
-		}
-		if (next_buf && found) {
-			cmd.cmd_id = AUDPLAY_CMD_BITSTREAM_DATA_AVAIL;
-			cmd.decoder_id = audio->dec_id;
-			cmd.buf_ptr	= (unsigned) next_buf->paddr;
-			cmd.buf_size = next_buf->buf.data_len >> 1;
-			cmd.partition_number	= 0;
-			audio->bytecount_given += next_buf->buf.data_len;
-			wmb();
-			audplay_send_queue0(audio, &cmd, sizeof(cmd));
-			audio->out_needed = 0;
-			audio->drv_status |= ADRV_STATUS_OBUF_GIVEN;
-		}
-	} else if (audio->device_switch == DEVICE_SWITCH_STATE_COMPLETE) {
-		audio->device_switch = DEVICE_SWITCH_STATE_NONE;
-		next_buf = list_first_entry(&audio->out_queue,
-					struct audlpa_buffer_node, list);
-		if (next_buf) {
-			cmd.cmd_id = AUDPLAY_CMD_BITSTREAM_DATA_AVAIL;
-			cmd.decoder_id = audio->dec_id;
-			temp = audio->bytecount_head +
-				next_buf->buf.data_len -
-				audio->bytecount_consumed;
-			if (audpp_restore_avsync(audio->dec_id,
-						&audio->avsync[0]))
-				MM_DBG("audpp_restore_avsync failed\n");
-
-			if ((signed)(temp >= 0) &&
-			((signed)(next_buf->buf.data_len - temp) >= 0)) {
-				MM_DBG("audlpa_async_send_buffer - sending the"
-					"rest of the buffer bassedon AV sync");
-				cmd.buf_ptr	= (unsigned) (next_buf->paddr +
-						  (next_buf->buf.data_len -
-						   temp));
-				cmd.buf_size = temp >> 1;
-				cmd.partition_number	= 0;
-				audio->bytecount_given =
-					audio->bytecount_consumed + temp;
-				wmb();
-				audplay_send_queue0(audio, &cmd, sizeof(cmd));
-				audio->out_needed = 0;
-				audio->drv_status |= ADRV_STATUS_OBUF_GIVEN;
-			} else if ((signed)(temp >= 0) &&
-				((signed)(next_buf->buf.data_len -
-							temp) < 0)) {
-				MM_DBG("audlpa_async_send_buffer - else case:"
-					"sending the rest of the buffer bassedon"
-					"AV sync");
-				cmd.buf_ptr	= (unsigned) next_buf->paddr;
-				cmd.buf_size = next_buf->buf.data_len >> 1;
-				cmd.partition_number	= 0;
-				audio->bytecount_given = audio->bytecount_head +
-					next_buf->buf.data_len;
-				wmb();
-				audplay_send_queue0(audio, &cmd, sizeof(cmd));
-				audio->out_needed = 0;
-				audio->drv_status |= ADRV_STATUS_OBUF_GIVEN;
-			}
-		}
-	}
-}
-
-static void audlpa_async_send_data(struct audio *audio, unsigned needed,
-				uint32_t *payload)
-{
-	unsigned long flags;
-	uint64_t temp = 0;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (needed && !audio->wflush) {
-		audio->out_needed = 1;
-		if (audio->drv_status & ADRV_STATUS_OBUF_GIVEN) {
-			union msm_audio_event_payload evt_payload;
-			struct audlpa_buffer_node *used_buf = NULL;
-
-			if (CHECK_ERROR(payload))
-				audio->bytecount_consumed =
-					CALCULATE_AVSYNC_FROM_PAYLOAD(payload);
-
-			if ((audio->device_switch ==
-				DEVICE_SWITCH_STATE_COMPLETE) &&
-				(audio->avsync_flag == 1)) {
-				audio->avsync_flag = 0;
-				audio->bytecount_consumed =
-					CALCULATE_AVSYNC(audio->avsync);
-			}
-			BUG_ON(list_empty(&audio->out_queue));
-			temp = audio->bytecount_head;
-			used_buf = list_first_entry(&audio->out_queue,
-					struct audlpa_buffer_node, list);
-			if (audio->device_switch !=
-				DEVICE_SWITCH_STATE_COMPLETE) {
-				audio->bytecount_head +=
-						used_buf->buf.data_len;
-				temp = audio->bytecount_head;
-				list_del(&used_buf->list);
-				evt_payload.aio_buf = used_buf->buf;
-				audlpa_post_event(audio,
-						AUDIO_EVENT_WRITE_DONE,
-						  evt_payload);
-				kfree(used_buf);
-				audio->drv_status &= ~ADRV_STATUS_OBUF_GIVEN;
-			}
-		}
-	}
-	if (audio->out_needed) {
-		if (!list_empty(&audio->out_queue))
-			audlpa_async_send_buffer(audio);
-	}
-done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-static void audlpa_async_flush(struct audio *audio)
-{
-	struct audlpa_buffer_node *buf_node;
-	struct list_head *ptr, *next;
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	list_for_each_safe(ptr, next, &audio->out_queue) {
-		buf_node = list_entry(ptr, struct audlpa_buffer_node, list);
-		list_del(&buf_node->list);
-		payload.aio_buf = buf_node->buf;
-		if ((buf_node->paddr != 0xFFFFFFFF) &&
-			(buf_node->buf.data_len != 0))
-			audlpa_post_event(audio, AUDIO_EVENT_WRITE_DONE,
-							  payload);
-		kfree(buf_node);
-	}
-	audio->drv_status &= ~ADRV_STATUS_OBUF_GIVEN;
-	audio->out_needed = 0;
-	audio->bytecount_consumed = 0;
-	audio->bytecount_head = 0;
-	audio->bytecount_given = 0;
-	audio->device_switch = DEVICE_SWITCH_STATE_NONE;
-	atomic_set(&audio->out_bytes, 0);
-}
-
-static void audio_ioport_reset(struct audio *audio)
-{
-	/* If fsync is in progress, make sure
-	 * return value of fsync indicates
-	 * abort due to flush
-	 */
-	if (audio->drv_status & ADRV_STATUS_FSYNC) {
-		MM_DBG("fsync in progress\n");
-		wake_up(&audio->write_wait);
-		mutex_lock(&audio->write_lock);
-		audlpa_async_flush(audio);
-		mutex_unlock(&audio->write_lock);
-		audio->avsync_flag = 1;
-		wake_up(&audio->avsync_wait);
-	} else
-		audlpa_async_flush(audio);
-}
-
-static int audlpa_events_pending(struct audio *audio)
-{
-	unsigned long flags;
-	int empty;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	empty = !list_empty(&audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	return empty || audio->event_abort;
-}
-
-static void audlpa_reset_event_queue(struct audio *audio)
-{
-	unsigned long flags;
-	struct audlpa_event *drv_evt;
-	struct list_head *ptr, *next;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	list_for_each_safe(ptr, next, &audio->event_queue) {
-		drv_evt = list_first_entry(&audio->event_queue,
-			struct audlpa_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	list_for_each_safe(ptr, next, &audio->free_event_queue) {
-		drv_evt = list_first_entry(&audio->free_event_queue,
-			struct audlpa_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	return;
-}
-
-static long audlpa_process_event_req(struct audio *audio, void __user *arg)
-{
-	long rc;
-	struct msm_audio_event usr_evt;
-	struct audlpa_event *drv_evt = NULL;
-	int timeout;
-	unsigned long flags;
-
-	if (copy_from_user(&usr_evt, arg, sizeof(struct msm_audio_event)))
-		return -EFAULT;
-
-	timeout = (int) usr_evt.timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(
-			audio->event_wait, audlpa_events_pending(audio),
-			msecs_to_jiffies(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(
-			audio->event_wait, audlpa_events_pending(audio));
-	}
-
-	if (rc < 0)
-		return rc;
-
-	if (audio->event_abort) {
-		audio->event_abort = 0;
-		return -ENODEV;
-	}
-
-	rc = 0;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	if (!list_empty(&audio->event_queue)) {
-		drv_evt = list_first_entry(&audio->event_queue,
-			struct audlpa_event, list);
-		list_del(&drv_evt->list);
-	}
-	if (drv_evt) {
-		usr_evt.event_type = drv_evt->event_type;
-		usr_evt.event_payload = drv_evt->payload;
-		list_add_tail(&drv_evt->list, &audio->free_event_queue);
-	} else
-		rc = -1;
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	if (drv_evt->event_type == AUDIO_EVENT_WRITE_DONE ||
-	    drv_evt->event_type == AUDIO_EVENT_READ_DONE) {
-		mutex_lock(&audio->lock);
-		audlpa_ion_fixup(audio, drv_evt->payload.aio_buf.buf_addr,
-				  drv_evt->payload.aio_buf.buf_len, 0);
-		mutex_unlock(&audio->lock);
-	}
-	if (!rc && copy_to_user(arg, &usr_evt, sizeof(usr_evt)))
-		rc = -EFAULT;
-
-	return rc;
-}
-
-static int audlpa_ion_check(struct audio *audio,
-		void *vaddr, unsigned long len)
-{
-	struct audlpa_ion_region *region_elt;
-	struct audlpa_ion_region t = {.vaddr = vaddr, .len = len };
-
-	list_for_each_entry(region_elt, &audio->ion_region_queue, list) {
-		if (CONTAINS(region_elt, &t) || CONTAINS(&t, region_elt) ||
-		    OVERLAPS(region_elt, &t)) {
-			MM_ERR("[%p]:region (vaddr %p len %ld)"
-				" clashes with registered region"
-				" (vaddr %p paddr %p len %ld)\n",
-				audio, vaddr, len,
-				region_elt->vaddr,
-				(void *)region_elt->paddr, region_elt->len);
-			return -EINVAL;
-		}
-	}
-
-	return 0;
-}
-static int audlpa_ion_add(struct audio *audio,
-			struct msm_audio_ion_info *info)
-{
-	ion_phys_addr_t paddr;
-	size_t len;
-	unsigned long kvaddr;
-	struct audlpa_ion_region *region;
-	int rc = -EINVAL;
-	struct ion_handle *handle;
-	unsigned long ionflag;
-
-	MM_ERR("\n"); /* Macro prints the file name and function */
-	region = kmalloc(sizeof(*region), GFP_KERNEL);
-
-	if (!region) {
-		rc = -ENOMEM;
-		goto end;
-	}
-	handle = ion_import_dma_buf(audio->client, info->fd);
-	if (IS_ERR_OR_NULL(handle)) {
-		pr_err("%s: could not get handle of the given fd\n", __func__);
-		goto import_error;
-	}
-	rc = ion_handle_get_flags(audio->client, handle, &ionflag);
-	if (rc) {
-		pr_err("%s: could not get flags for the handle\n", __func__);
-		goto flag_error;
-	}
-	kvaddr = (unsigned long)ion_map_kernel(audio->client, handle);
-	if (IS_ERR_OR_NULL((void *)kvaddr)) {
-		pr_err("%s: could not get virtual address\n", __func__);
-		goto map_error;
-	}
-	rc = ion_phys(audio->client, handle, &paddr, &len);
-	if (rc) {
-		pr_err("%s: could not get physical address\n", __func__);
-		goto ion_error;
-	}
-	rc = audlpa_ion_check(audio, info->vaddr, len);
-	if (rc < 0) {
-		MM_ERR("audpcm_ion_check failed\n");
-		goto ion_error;
-	}
-	region->handle = handle;
-	region->vaddr = info->vaddr;
-	region->fd = info->fd;
-	region->paddr = paddr;
-	region->kvaddr = kvaddr;
-	region->len = len;
-	region->ref_cnt = 0;
-	MM_DBG("[%p]:add region paddr %lx vaddr %p, len %lu kvaddr %lx\n",
-		audio, region->paddr, region->vaddr,
-		region->len, region->kvaddr);
-	list_add_tail(&region->list, &audio->ion_region_queue);
-
-	return rc;
-
-ion_error:
-	ion_unmap_kernel(audio->client, handle);
-map_error:
-flag_error:
-	ion_free(audio->client, handle);
-import_error:
-	kfree(region);
-end:
-	return rc;
-}
-
-static int audlpa_ion_remove(struct audio *audio,
-			struct msm_audio_ion_info *info)
-{
-	struct audlpa_ion_region *region;
-	struct list_head *ptr, *next;
-	int rc = -EINVAL;
-
-	list_for_each_safe(ptr, next, &audio->ion_region_queue) {
-		region = list_entry(ptr, struct audlpa_ion_region, list);
-
-		if (region != NULL && (region->fd == info->fd) &&
-		    (region->vaddr == info->vaddr)) {
-			if (region->ref_cnt) {
-				MM_DBG("%s[%p]:region %p in use ref_cnt %d\n",
-					__func__, audio, region,
-					region->ref_cnt);
-				break;
-			}
-			MM_DBG("remove region fd %d vaddr %p\n",
-				info->fd, info->vaddr);
-			list_del(&region->list);
-			ion_unmap_kernel(audio->client, region->handle);
-			ion_free(audio->client, region->handle);
-			kfree(region);
-			rc = 0;
-			break;
-		}
-	}
-
-	return rc;
-}
-
-static int audlpa_ion_lookup_vaddr(struct audio *audio, void *addr,
-			unsigned long len, struct audlpa_ion_region **region)
-{
-	struct audlpa_ion_region *region_elt;
-	int match_count = 0;
-	*region = NULL;
-
-	/* returns physical address or zero */
-	list_for_each_entry(region_elt, &audio->ion_region_queue, list) {
-		if (addr >= region_elt->vaddr &&
-		    addr < region_elt->vaddr + region_elt->len &&
-		    addr + len <= region_elt->vaddr + region_elt->len) {
-			/* offset since we could pass vaddr inside a registerd
-			 * ion buffer
-			 */
-
-			match_count++;
-			if (!*region)
-				*region = region_elt;
-		}
-	}
-
-	if (match_count > 1) {
-		MM_ERR("%s[%p]:multiple hits for vaddr %p, len %ld\n",
-			 __func__, audio, addr, len);
-		list_for_each_entry(region_elt, &audio->ion_region_queue,
-					list) {
-			if (addr >= region_elt->vaddr &&
-			    addr < region_elt->vaddr + region_elt->len &&
-			    addr + len <= region_elt->vaddr + region_elt->len)
-					MM_ERR("\t%s[%p]:%p, %ld --> %p\n",
-						__func__, audio,
-						region_elt->vaddr,
-						region_elt->len,
-						(void *)region_elt->paddr);
-		}
-	}
-
-	return *region ? 0 : -1;
-}
-static unsigned long audlpa_ion_fixup(struct audio *audio, void *addr,
-		    unsigned long len, int ref_up)
-{
-	struct audlpa_ion_region *region;
-	unsigned long paddr;
-	int ret;
-
-	ret = audlpa_ion_lookup_vaddr(audio, addr, len, &region);
-	if (ret) {
-		MM_ERR("%s[%p]:lookup (%p, %ld) failed\n",
-			__func__, audio, addr, len);
-		return 0;
-	}
-	if (ref_up)
-		region->ref_cnt++;
-	else
-		region->ref_cnt--;
-	MM_DBG("found region %p ref_cnt %d\n", region, region->ref_cnt);
-	paddr = region->paddr + (addr - region->vaddr);
-	return paddr;
-}
-
-/* audio -> lock must be held at this point */
-static int audlpa_aio_buf_add(struct audio *audio, unsigned dir,
-	void __user *arg)
-{
-	unsigned long flags;
-	struct audlpa_buffer_node *buf_node;
-
-	buf_node = kmalloc(sizeof(*buf_node), GFP_KERNEL);
-
-	if (!buf_node)
-		return -ENOMEM;
-
-	if (copy_from_user(&buf_node->buf, arg, sizeof(buf_node->buf))) {
-		kfree(buf_node);
-		return -EFAULT;
-	}
-
-	MM_DBG("node %p dir %x buf_addr %p buf_len %d data_len"
-			"%d\n", buf_node, dir,
-			buf_node->buf.buf_addr, buf_node->buf.buf_len,
-			buf_node->buf.data_len);
-
-	buf_node->paddr = audlpa_ion_fixup(
-		audio, buf_node->buf.buf_addr,
-		buf_node->buf.buf_len, 1);
-
-	if (dir) {
-		/* write */
-		if (!buf_node->paddr ||
-		    (buf_node->paddr & 0x1) ||
-		    (buf_node->buf.data_len & 0x1)) {
-			kfree(buf_node);
-			return -EINVAL;
-		}
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		list_add_tail(&buf_node->list, &audio->out_queue);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		audlpa_async_send_data(audio, 0, 0);
-	} else {
-		/* read */
-	}
-
-	MM_DBG("Add buf_node %p paddr %lx\n", buf_node, buf_node->paddr);
-
-	return 0;
-}
-
-static int audio_enable_eq(struct audio *audio, int enable)
-{
-	if (audio->eq_enable == enable && !audio->eq_needs_commit)
-		return 0;
-
-	audio->eq_enable = enable;
-
-	if (audio->running) {
-		audpp_dsp_set_eq(audio->dec_id, enable, &audio->eq, POPP);
-		audio->eq_needs_commit = 0;
-	}
-	return 0;
-}
-
-static int audio_get_avsync_data(struct audio *audio,
-						struct msm_audio_stats *stats)
-{
-	int rc = -EINVAL;
-	unsigned long flags;
-
-	local_irq_save(flags);
-	if (audio->dec_id == audio->avsync[0] && audio->avsync_flag) {
-		/* av_sync sample count */
-		stats->sample_count = (audio->avsync[2] << 16) |
-						(audio->avsync[3]);
-
-		/* av_sync byte_count */
-		stats->byte_count = (audio->avsync[5] << 16) |
-						(audio->avsync[6]);
-
-		audio->avsync_flag = 0;
-		rc = 0;
-	}
-	local_irq_restore(flags);
-	return rc;
-
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = -EINVAL;
-	unsigned long flags = 0;
-	uint16_t enable_mask;
-	int enable;
-	int prev_state;
-
-	MM_DBG("audio_ioctl() cmd = %d\n", cmd);
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-
-		audio->avsync_flag = 0;
-		memset(&stats, 0, sizeof(stats));
-		if (audpp_query_avsync(audio->dec_id) < 0)
-			return rc;
-
-		rc = wait_event_interruptible_timeout(audio->avsync_wait,
-				(audio->avsync_flag == 1),
-				msecs_to_jiffies(AVSYNC_EVENT_TIMEOUT));
-
-		if (rc < 0)
-			return rc;
-		else if ((rc > 0) || ((rc == 0) && (audio->avsync_flag == 1))) {
-			if (audio_get_avsync_data(audio, &stats) < 0)
-				return rc;
-
-			if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-				return -EFAULT;
-			return 0;
-		} else
-			return -EAGAIN;
-	}
-
-	switch (cmd) {
-	case AUDIO_ENABLE_AUDPP:
-		if (copy_from_user(&enable_mask, (void *) arg,
-						sizeof(enable_mask))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		enable = (enable_mask & EQ_ENABLE) ? 1 : 0;
-		audio_enable_eq(audio, enable);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_VOLUME:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.volume = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(AUDPP_CMD_CFG_DEV_MIXER_ID_4,
-						&audio->vol_pan,
-						COPP);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_PAN:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.pan = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(AUDPP_CMD_CFG_DEV_MIXER_ID_4,
-						&audio->vol_pan,
-						COPP);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_EQ:
-		prev_state = audio->eq_enable;
-		audio->eq_enable = 0;
-		if (copy_from_user(&audio->eq.num_bands, (void *) arg,
-				sizeof(audio->eq) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2))) {
-			rc = -EFAULT;
-			break;
-		}
-		audio->eq_enable = prev_state;
-		audio->eq_needs_commit = 1;
-		rc = 0;
-		break;
-	}
-
-	if (-EINVAL != rc)
-		return rc;
-
-	if (cmd == AUDIO_GET_EVENT) {
-		MM_DBG(" AUDIO_GET_EVENT\n");
-		if (mutex_trylock(&audio->get_event_lock)) {
-			rc = audlpa_process_event_req(audio,
-				(void __user *) arg);
-			mutex_unlock(&audio->get_event_lock);
-		} else
-			rc = -EBUSY;
-		return rc;
-	}
-
-	if (cmd == AUDIO_ABORT_GET_EVENT) {
-		audio->event_abort = 1;
-		wake_up(&audio->event_wait);
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		MM_DBG("AUDIO_START\n");
-		rc = audio_enable(audio);
-		if (!rc) {
-			rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-			MM_DBG("dec_state %d rc = %d\n", audio->dec_state, rc);
-
-			if (audio->dec_state != MSM_AUD_DECODER_STATE_SUCCESS)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		break;
-
-	case AUDIO_STOP:
-		MM_DBG("AUDIO_STOP\n");
-		rc = audio_disable(audio);
-		audio->stopped = 1;
-		audio_ioport_reset(audio);
-		audio->stopped = 0;
-		audio->drv_status &= ~ADRV_STATUS_PAUSE;
-		break;
-
-	case AUDIO_FLUSH:
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->wflush = 1;
-		audio_ioport_reset(audio);
-		if (audio->running) {
-			if (!(audio->drv_status & ADRV_STATUS_PAUSE)) {
-				rc = audpp_pause(audio->dec_id, (int) arg);
-				if (rc < 0) {
-					MM_ERR("%s: pause cmd failed rc=%d\n",
-						__func__, rc);
-					rc = -EINTR;
-					break;
-				}
-			}
-			audpp_flush(audio->dec_id);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->wflush = 0;
-		}
-		break;
-
-	case AUDIO_SET_CONFIG:{
-		struct msm_audio_config config;
-		MM_INFO("AUDIO_SET_CONFIG\n");
-		if (copy_from_user(&config, (void *) arg, sizeof(config))) {
-			rc = -EFAULT;
-			MM_INFO("ERROR: copy from user\n");
-			break;
-		}
-		if (config.channel_count == 1) {
-			config.channel_count = AUDPP_CMD_PCM_INTF_MONO_V;
-		} else if (config.channel_count == 2) {
-			config.channel_count = AUDPP_CMD_PCM_INTF_STEREO_V;
-		} else {
-			rc = -EINVAL;
-			MM_INFO("ERROR: config.channel_count == %d\n",
-					config.channel_count);
-			break;
-		}
-
-		if (config.bits == 8)
-			config.bits = AUDPP_CMD_WAV_PCM_WIDTH_8;
-		else if (config.bits == 16)
-			config.bits = AUDPP_CMD_WAV_PCM_WIDTH_16;
-		else if (config.bits == 24)
-			config.bits = AUDPP_CMD_WAV_PCM_WIDTH_24;
-		else {
-			rc = -EINVAL;
-			MM_INFO("ERROR: config.bits == %d\n", config.bits);
-			break;
-		}
-		audio->out_sample_rate = config.sample_rate;
-		audio->out_channel_mode = config.channel_count;
-		audio->out_bits = config.bits;
-		audio->buffer_count = config.buffer_count;
-		audio->buffer_size = config.buffer_size;
-		MM_DBG("AUDIO_SET_CONFIG: config.bits = %d\n", config.bits);
-		rc = 0;
-		break;
-	}
-
-	case AUDIO_GET_CONFIG:{
-		struct msm_audio_config config;
-		config.buffer_count = audio->buffer_count;
-		config.buffer_size = audio->buffer_size;
-		config.sample_rate = audio->out_sample_rate;
-		if (audio->out_channel_mode == AUDPP_CMD_PCM_INTF_MONO_V)
-			config.channel_count = 1;
-		else
-			config.channel_count = 2;
-		if (audio->out_bits == AUDPP_CMD_WAV_PCM_WIDTH_8)
-			config.bits = 8;
-		else if (audio->out_bits == AUDPP_CMD_WAV_PCM_WIDTH_24)
-			config.bits = 24;
-		else
-			config.bits = 16;
-		config.meta_field = 0;
-		config.unused[0] = 0;
-		config.unused[1] = 0;
-		config.unused[2] = 0;
-		MM_DBG("AUDIO_GET_CONFIG: config.bits = %d\n", config.bits);
-		if (copy_to_user((void *) arg, &config, sizeof(config)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-
-	case AUDIO_PAUSE:
-		MM_DBG("AUDIO_PAUSE %ld\n", arg);
-		rc = audpp_pause(audio->dec_id, (int) arg);
-		if (arg == 1)
-			audio->drv_status |= ADRV_STATUS_PAUSE;
-		else if (arg == 0)
-			audio->drv_status &= ~ADRV_STATUS_PAUSE;
-		break;
-
-	case AUDIO_REGISTER_ION: {
-		struct msm_audio_ion_info info;
-		MM_DBG("AUDIO_REGISTER_ION\n");
-		if (copy_from_user(&info, (void *) arg, sizeof(info)))
-				rc = -EFAULT;
-			else
-				rc = audlpa_ion_add(audio, &info);
-			break;
-		}
-
-	case AUDIO_DEREGISTER_ION: {
-		struct msm_audio_ion_info info;
-		MM_DBG("AUDIO_DEREGISTER_ION\n");
-		if (copy_from_user(&info, (void *) arg, sizeof(info)))
-				rc = -EFAULT;
-			else
-				rc = audlpa_ion_remove(audio, &info);
-			break;
-		}
-
-	case AUDIO_ASYNC_WRITE:
-		if (audio->drv_status & ADRV_STATUS_FSYNC)
-			rc = -EBUSY;
-		else
-			rc = audlpa_aio_buf_add(audio, 1, (void __user *) arg);
-		break;
-
-	case AUDIO_GET_SESSION_ID:
-		if (copy_to_user((void *) arg, &audio->dec_id,
-					sizeof(unsigned short)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	default:
-		rc = audio->codec_ops.ioctl(file, cmd, arg);
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-/* Only useful in tunnel-mode */
-int audlpa_async_fsync(struct audio *audio)
-{
-	int rc = 0, empty = 0;
-	struct audlpa_buffer_node *buf_node;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	/* Blocking client sends more data */
-	mutex_lock(&audio->lock);
-	audio->drv_status |= ADRV_STATUS_FSYNC;
-	mutex_unlock(&audio->lock);
-
-	mutex_lock(&audio->write_lock);
-	audio->teos = 0;
-	empty = list_empty(&audio->out_queue);
-	buf_node = kmalloc(sizeof(*buf_node), GFP_KERNEL);
-	if (!buf_node)
-		goto done;
-
-	buf_node->paddr = 0xFFFFFFFF;
-	buf_node->buf.data_len = 0;
-	buf_node->buf.buf_addr = NULL;
-	buf_node->buf.buf_len = 0;
-	buf_node->buf.private_data = NULL;
-	list_add_tail(&buf_node->list, &audio->out_queue);
-	if ((empty != 0) && (audio->out_needed == 1))
-		audlpa_async_send_data(audio, 0, 0);
-
-	rc = wait_event_interruptible(audio->write_wait,
-				  audio->teos || audio->wflush ||
-				  audio->stopped);
-
-	if (rc < 0)
-		goto done;
-
-	if (audio->teos == 1) {
-		/* Releasing all the pending buffers to user */
-		audio->teos = 0;
-		audlpa_async_flush(audio);
-	}
-
-	if (audio->stopped || audio->wflush)
-		rc = -EBUSY;
-
-done:
-	mutex_unlock(&audio->write_lock);
-	mutex_lock(&audio->lock);
-	audio->drv_status &= ~ADRV_STATUS_FSYNC;
-	mutex_unlock(&audio->lock);
-
-	return rc;
-}
-
-int audlpa_fsync(struct file *file, loff_t ppos1, loff_t ppos2, int datasync)
-{
-	struct audio *audio = file->private_data;
-
-	if (!audio->running)
-		return -EINVAL;
-
-	return audlpa_async_fsync(audio);
-}
-
-static void audpcm_reset_ion_region(struct audio *audio)
-{
-	struct audlpa_ion_region *region;
-	struct list_head *ptr, *next;
-
-	list_for_each_safe(ptr, next, &audio->ion_region_queue) {
-		region = list_entry(ptr, struct audlpa_ion_region, list);
-		list_del(&region->list);
-		ion_unmap_kernel(audio->client, region->handle);
-		ion_free(audio->client, region->handle);
-		kfree(region);
-	}
-
-	return;
-}
-
-static int audio_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	MM_INFO("audio instance 0x%08x freeing\n", (int)audio);
-	mutex_lock(&audio->lock);
-	auddev_unregister_evt_listner(AUDDEV_CLNT_DEC, audio->dec_id);
-	audio_disable(audio);
-	audlpa_async_flush(audio);
-	audpcm_reset_ion_region(audio);
-
-	msm_adsp_put(audio->audplay);
-	audpp_adec_free(audio->dec_id);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	unregister_early_suspend(&audio->suspend_ctl.node);
-#endif
-	audio->opened = 0;
-	audio->event_abort = 1;
-	wake_up(&audio->event_wait);
-	audlpa_reset_event_queue(audio);
-	mutex_unlock(&audio->lock);
-#ifdef CONFIG_DEBUG_FS
-	if (audio->dentry)
-		debugfs_remove(audio->dentry);
-#endif
-	ion_client_destroy(audio->client);
-	kfree(audio);
-	return 0;
-}
-
-static void audlpa_post_event(struct audio *audio, int type,
-	union msm_audio_event_payload payload)
-{
-	struct audlpa_event *e_node = NULL;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-
-	if (!list_empty(&audio->free_event_queue)) {
-		e_node = list_first_entry(&audio->free_event_queue,
-			struct audlpa_event, list);
-		list_del(&e_node->list);
-	} else {
-		e_node = kmalloc(sizeof(struct audlpa_event), GFP_ATOMIC);
-		if (!e_node) {
-			MM_ERR("No mem to post event %d\n", type);
-			return;
-		}
-	}
-
-	e_node->event_type = type;
-	e_node->payload = payload;
-
-	list_add_tail(&e_node->list, &audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	wake_up(&audio->event_wait);
-}
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audlpa_suspend(struct early_suspend *h)
-{
-	struct audlpa_suspend_ctl *ctl =
-		container_of(h, struct audlpa_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audlpa_post_event(ctl->audio, AUDIO_EVENT_SUSPEND, payload);
-}
-
-static void audlpa_resume(struct early_suspend *h)
-{
-	struct audlpa_suspend_ctl *ctl =
-		container_of(h, struct audlpa_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audlpa_post_event(ctl->audio, AUDIO_EVENT_RESUME, payload);
-}
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-static ssize_t audlpa_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static ssize_t audlpa_debug_read(struct file *file, char __user *buf,
-			  size_t count, loff_t *ppos)
-{
-	const int debug_bufmax = 4096;
-	static char buffer[4096];
-	int n = 0;
-	struct audio *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	n = scnprintf(buffer, debug_bufmax, "opened %d\n", audio->opened);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-					"enabled %d\n", audio->enabled);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-					"stopped %d\n", audio->stopped);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-					"volume %x\n", audio->vol_pan.volume);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-					"sample rate %d\n",
-					audio->out_sample_rate);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-					"channel mode %d\n",
-					audio->out_channel_mode);
-	mutex_unlock(&audio->lock);
-	/* Following variables are only useful for debugging when
-	 * when playback halts unexpectedly. Thus, no mutual exclusion
-	 * enforced
-	 */
-	n += scnprintf(buffer + n, debug_bufmax - n,
-					"wflush %d\n", audio->wflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-					"running %d\n", audio->running);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-					"dec state %d\n", audio->dec_state);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-					"out_needed %d\n", audio->out_needed);
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations audlpa_debug_fops = {
-	.read = audlpa_debug_read,
-	.open = audlpa_debug_open,
-};
-#endif
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = NULL;
-	int rc, i, dec_attrb = 0, decid;
-	struct audlpa_event *e_node = NULL;
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_lpa_" + 5];
-#endif
-
-	/* Allocate audio instance, set to zero */
-	audio = kzalloc(sizeof(struct audio), GFP_KERNEL);
-	if (!audio) {
-		MM_ERR("no memory to allocate audio instance\n");
-		rc = -ENOMEM;
-		goto done;
-	}
-	MM_INFO("audio instance 0x%08x created\n", (int)audio);
-
-	if ((file->f_mode & FMODE_WRITE) && !(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_TUNNEL;
-	} else {
-		kfree(audio);
-		rc = -EACCES;
-		goto done;
-	}
-
-	/* Allocate the decoder based on inode minor number*/
-	audio->minor_no = iminor(inode);
-	dec_attrb |= audlpa_decs[audio->minor_no].dec_attrb;
-	audio->codec_ops.ioctl = audlpa_decs[audio->minor_no].ioctl;
-	audio->codec_ops.adec_params = audlpa_decs[audio->minor_no].adec_params;
-	audio->buffer_size = BUFSZ;
-	audio->buffer_count = MAX_BUF;
-
-	dec_attrb |= MSM_AUD_MODE_LP;
-
-	decid = audpp_adec_alloc(dec_attrb, &audio->module_name,
-			&audio->queue_id);
-	if (decid < 0) {
-		MM_ERR("No free decoder available\n");
-		rc = -ENODEV;
-		MM_INFO("audio instance 0x%08x freeing\n", (int)audio);
-		kfree(audio);
-		goto done;
-	}
-	audio->dec_id = decid & MSM_AUD_DECODER_MASK;
-
-	MM_DBG("set to aio interface\n");
-	audio->drv_status |= ADRV_STATUS_AIO_INTF;
-
-	rc = msm_adsp_get(audio->module_name, &audio->audplay,
-		&audplay_adsp_ops_lpa, audio);
-
-	if (rc) {
-		MM_ERR("failed to get %s module\n", audio->module_name);
-		goto err;
-	}
-
-	/* Initialize all locks of audio instance */
-	mutex_init(&audio->lock);
-	mutex_init(&audio->write_lock);
-	mutex_init(&audio->get_event_lock);
-	spin_lock_init(&audio->dsp_lock);
-	init_waitqueue_head(&audio->write_wait);
-	INIT_LIST_HEAD(&audio->out_queue);
-	INIT_LIST_HEAD(&audio->ion_region_queue);
-	INIT_LIST_HEAD(&audio->free_event_queue);
-	INIT_LIST_HEAD(&audio->event_queue);
-	init_waitqueue_head(&audio->wait);
-	init_waitqueue_head(&audio->event_wait);
-	spin_lock_init(&audio->event_queue_lock);
-	init_waitqueue_head(&audio->avsync_wait);
-
-	audio->out_sample_rate = 44100;
-	audio->out_channel_mode = AUDPP_CMD_PCM_INTF_STEREO_V;
-	audio->out_bits = AUDPP_CMD_WAV_PCM_WIDTH_16;
-	audio->vol_pan.volume = 0x2000;
-
-	audlpa_async_flush(audio);
-
-	file->private_data = audio;
-	audio->opened = 1;
-
-	audio->device_events = AUDDEV_EVT_DEV_RDY
-				|AUDDEV_EVT_DEV_RLS | AUDDEV_EVT_REL_PENDING
-				|AUDDEV_EVT_STREAM_VOL_CHG;
-	audio->device_switch = DEVICE_SWITCH_STATE_NONE;
-	audio->drv_status &= ~ADRV_STATUS_PAUSE;
-	audio->bytecount_consumed = 0;
-	audio->bytecount_head = 0;
-	audio->bytecount_given = 0;
-
-	rc = auddev_register_evt_listner(audio->device_events,
-					AUDDEV_CLNT_DEC,
-					audio->dec_id,
-					lpa_listner,
-					(void *)audio);
-	if (rc) {
-		MM_ERR("%s: failed to register listnet\n", __func__);
-		goto event_err;
-	}
-
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof name, "msm_lpa_%04x", audio->dec_id);
-	audio->dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
-			NULL, (void *) audio, &audlpa_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		MM_DBG("debugfs_create_file failed\n");
-#endif
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	audio->suspend_ctl.node.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
-	audio->suspend_ctl.node.resume = audlpa_resume;
-	audio->suspend_ctl.node.suspend = audlpa_suspend;
-	audio->suspend_ctl.audio = audio;
-	register_early_suspend(&audio->suspend_ctl.node);
-#endif
-	for (i = 0; i < AUDLPA_EVENT_NUM; i++) {
-		e_node = kmalloc(sizeof(struct audlpa_event), GFP_KERNEL);
-		if (e_node)
-			list_add_tail(&e_node->list, &audio->free_event_queue);
-		else {
-			MM_ERR("event pkt alloc failed\n");
-			break;
-		}
-	}
-
-	audio->client = msm_ion_client_create(UINT_MAX, "Audio_LPA_Client");
-	if (IS_ERR_OR_NULL(audio->client)) {
-		pr_err("Unable to create ION client\n");
-		goto err;
-	}
-	MM_DBG("Ion client created\n");
-
-done:
-	return rc;
-event_err:
-	msm_adsp_put(audio->audplay);
-err:
-	audpp_adec_free(audio->dec_id);
-	MM_INFO("audio instance 0x%08x freeing\n", (int)audio);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_lpa_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audio_open,
-	.release	= audio_release,
-	.unlocked_ioctl	= audio_ioctl,
-	.fsync		= audlpa_fsync,
-};
-
-static dev_t audlpa_devno;
-static struct class *audlpa_class;
-struct audlpa_device {
-	const char *name;
-	struct device *device;
-	struct cdev cdev;
-};
-
-static struct audlpa_device *audlpa_devices;
-
-static void audlpa_create(struct audlpa_device *adev, const char *name,
-			struct device *parent, dev_t devt)
-{
-	struct device *dev;
-	int rc;
-
-	dev = device_create(audlpa_class, parent, devt, "%s", name);
-	if (IS_ERR(dev))
-		return;
-
-	cdev_init(&adev->cdev, &audio_lpa_fops);
-	adev->cdev.owner = THIS_MODULE;
-
-	rc = cdev_add(&adev->cdev, devt, 1);
-	if (rc < 0) {
-		device_destroy(audlpa_class, devt);
-	} else {
-		adev->device = dev;
-		adev->name = name;
-	}
-}
-
-static int __init audio_init(void)
-{
-	int rc;
-	int n = ARRAY_SIZE(audlpa_decs);
-
-	audlpa_devices = kzalloc(sizeof(struct audlpa_device) * n, GFP_KERNEL);
-	if (!audlpa_devices)
-		return -ENOMEM;
-
-	audlpa_class = class_create(THIS_MODULE, "audlpa");
-	if (IS_ERR(audlpa_class))
-		goto fail_create_class;
-
-	rc = alloc_chrdev_region(&audlpa_devno, 0, n, "msm_audio_lpa");
-	if (rc < 0)
-		goto fail_alloc_region;
-
-	for (n = 0; n < ARRAY_SIZE(audlpa_decs); n++) {
-		audlpa_create(audlpa_devices + n,
-				audlpa_decs[n].name, NULL,
-				MKDEV(MAJOR(audlpa_devno), n));
-	}
-
-	return 0;
-
-fail_alloc_region:
-	class_unregister(audlpa_class);
-	return rc;
-fail_create_class:
-	kfree(audlpa_devices);
-	return -ENOMEM;
-}
-
-static void __exit audio_exit(void)
-{
-	class_unregister(audlpa_class);
-	kfree(audlpa_devices);
-}
-
-module_init(audio_init);
-module_exit(audio_exit);
-
-MODULE_DESCRIPTION("MSM LPA driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5v2/audio_mp3.c b/arch/arm/mach-msm/qdsp5v2/audio_mp3.c
deleted file mode 100644
index bda2e4d..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audio_mp3.c
+++ /dev/null
@@ -1,2388 +0,0 @@
-/* mp3 audio output device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2009-2012, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/earlysuspend.h>
-#include <linux/list.h>
-#include <linux/slab.h>
-#include <linux/memory_alloc.h>
-#include <linux/msm_audio.h>
-#include <mach/msm_adsp.h>
-
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/qdsp5v2/qdsp5audppmsg.h>
-#include <mach/qdsp5v2/qdsp5audplaycmdi.h>
-#include <mach/qdsp5v2/qdsp5audplaymsg.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/qdsp5v2/audpp.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_memtypes.h>
-
-#define ADRV_STATUS_AIO_INTF 0x00000001
-#define ADRV_STATUS_OBUF_GIVEN 0x00000002
-#define ADRV_STATUS_IBUF_GIVEN 0x00000004
-#define ADRV_STATUS_FSYNC 0x00000008
-
-/* Size must be power of 2 */
-#define BUFSZ_MAX 32768
-#define BUFSZ_MIN 4096
-#define DMASZ_MAX (BUFSZ_MAX * 2)
-#define DMASZ_MIN (BUFSZ_MIN * 2)
-
-#define AUDPLAY_INVALID_READ_PTR_OFFSET	0xFFFF
-#define AUDDEC_DEC_MP3 2
-
-#define PCM_BUFSZ_MIN 4800	/* Hold one stereo MP3 frame */
-#define PCM_BUF_MAX_COUNT 5	/* DSP only accepts 5 buffers at most
-				   but support 2 buffers currently */
-#define ROUTING_MODE_FTRT 1
-#define ROUTING_MODE_RT 2
-/* Decoder status received from AUDPPTASK */
-#define  AUDPP_DEC_STATUS_SLEEP	0
-#define	 AUDPP_DEC_STATUS_INIT  1
-#define  AUDPP_DEC_STATUS_CFG   2
-#define  AUDPP_DEC_STATUS_PLAY  3
-
-#define AUDMP3_METAFIELD_MASK 0xFFFF0000
-#define AUDMP3_EOS_FLG_OFFSET 0x0A /* Offset from beginning of buffer */
-#define AUDMP3_EOS_FLG_MASK 0x01
-#define AUDMP3_EOS_NONE 0x0 /* No EOS detected */
-#define AUDMP3_EOS_SET 0x1 /* EOS set in meta field */
-
-#define AUDMP3_EVENT_NUM 10 /* Default number of pre-allocated event packets */
-
-#define BITSTREAM_ERROR_THRESHOLD_VALUE 0x1 /* DEFAULT THRESHOLD VALUE */
-
-#define __CONTAINS(r, v, l) ({					\
-	typeof(r) __r = r;					\
-	typeof(v) __v = v;					\
-	typeof(v) __e = __v + l;				\
-	int res = ((__v >= __r->vaddr) && 			\
-		(__e <= __r->vaddr + __r->len));		\
-	res;							\
-})
-
-#define CONTAINS(r1, r2) ({					\
-	typeof(r2) __r2 = r2;					\
-	__CONTAINS(r1, __r2->vaddr, __r2->len);			\
-})
-
-#define IN_RANGE(r, v) ({					\
-	typeof(r) __r = r;					\
-	typeof(v) __vv = v;					\
-	int res = ((__vv >= __r->vaddr) &&			\
-		(__vv < (__r->vaddr + __r->len)));		\
-	res;							\
-})
-
-#define OVERLAPS(r1, r2) ({					\
-	typeof(r1) __r1 = r1;					\
-	typeof(r2) __r2 = r2;					\
-	typeof(__r2->vaddr) __v = __r2->vaddr;			\
-	typeof(__v) __e = __v + __r2->len - 1;			\
-	int res = (IN_RANGE(__r1, __v) || IN_RANGE(__r1, __e));	\
-	res;							\
-})
-struct audio;
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;		/* Input usage actual DSP produced PCM size  */
-	unsigned addr;
-	unsigned short mfield_sz; /*only useful for data has meta field */
-};
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-struct audmp3_suspend_ctl {
-  struct early_suspend node;
-  struct audio *audio;
-};
-#endif
-
-struct audmp3_event {
-	struct list_head list;
-	int event_type;
-	union msm_audio_event_payload payload;
-};
-
-struct audmp3_pmem_region {
-	struct list_head list;
-	struct file *file;
-	int fd;
-	void *vaddr;
-	unsigned long paddr;
-	unsigned long kvaddr;
-	unsigned long len;
-	unsigned ref_cnt;
-};
-
-struct audmp3_buffer_node {
-	struct list_head list;
-	struct msm_audio_aio_buf buf;
-	unsigned long paddr;
-};
-
-struct audmp3_drv_operations {
-	void (*pcm_buf_update)(struct audio *, uint32_t *);
-	void (*buffer_refresh)(struct audio *);
-	void (*send_data)(struct audio *, unsigned);
-	void (*out_flush)(struct audio *);
-	void (*in_flush)(struct audio *);
-	int (*fsync)(struct audio *);
-};
-
-struct audio {
-	struct buffer out[2];
-
-	spinlock_t dsp_lock;
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed; /* number of buffers the dsp is waiting for */
-	unsigned out_dma_sz;
-	struct list_head out_queue; /* queue to retain output buffers */
-	atomic_t out_bytes;
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-
-	/* Host PCM section */
-	struct buffer in[PCM_BUF_MAX_COUNT];
-	struct mutex read_lock;
-	wait_queue_head_t read_wait;	/* Wait queue for read */
-	char *read_data;	/* pointer to reader buffer */
-	int32_t read_phys;	/* physical address of reader buffer */
-	uint8_t read_next;	/* index to input buffers to be read next */
-	uint8_t fill_next;	/* index to buffer that DSP should be filling */
-	uint8_t pcm_buf_count;	/* number of pcm buffer allocated */
-	struct list_head in_queue; /* queue to retain input buffers */
-	/* ---- End of Host PCM section */
-
-	struct msm_adsp_module *audplay;
-
-	/* configuration to use on next enable */
-	uint32_t out_sample_rate;
-	uint32_t out_channel_mode;
-
-	/* data allocated for various buffers */
-	char *data;
-	int32_t phys; /* physical address of write buffer */
-	void *map_v_read;
-	void *map_v_write;
-
-	uint32_t drv_status;
-	int mfield; /* meta field embedded in data */
-	int rflush; /* Read  flush */
-	int wflush; /* Write flush */
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped, cleared on flush */
-	int pcm_feedback;
-	int buf_refresh;
-	int teos; /* valid only if tunnel mode & no data left for decoder */
-	enum msm_aud_decoder_state dec_state;	/* Represents decoder state */
-	int reserved; /* A byte is being reserved */
-	char rsv_byte; /* Handle odd length user data */
-
-	const char *module_name;
-	unsigned queue_id;
-	uint16_t dec_id;
-	uint32_t read_ptr_offset;
-	int16_t source;
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	struct audmp3_suspend_ctl suspend_ctl;
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *dentry;
-#endif
-
-	wait_queue_head_t wait;
-	struct list_head free_event_queue;
-	struct list_head event_queue;
-	wait_queue_head_t event_wait;
-	spinlock_t event_queue_lock;
-	struct mutex get_event_lock;
-	int event_abort;
-	/* AV sync Info */
-	int avsync_flag;              /* Flag to indicate feedback from DSP */
-	wait_queue_head_t avsync_wait;/* Wait queue for AV Sync Message     */
-	/* flags, 48 bits sample/bytes counter per channel */
-	uint16_t avsync[AUDPP_AVSYNC_CH_COUNT * AUDPP_AVSYNC_NUM_WORDS + 1];
-
-	uint32_t device_events;
-
-	struct list_head pmem_region_queue; /* protected by lock */
-	struct audmp3_drv_operations drv_ops;
-
-	struct msm_audio_bitstream_info stream_info;
-	struct msm_audio_bitstream_error_info bitstream_error_info;
-	uint32_t bitstream_error_threshold_value;
-
-	int eq_enable;
-	int eq_needs_commit;
-	struct audpp_cmd_cfg_object_params_eqalizer eq;
-	struct audpp_cmd_cfg_object_params_volume vol_pan;
-};
-
-static int auddec_dsp_config(struct audio *audio, int enable);
-static void audpp_cmd_cfg_adec_params(struct audio *audio);
-static void audpp_cmd_cfg_routing_mode(struct audio *audio);
-static void audplay_send_data(struct audio *audio, unsigned needed);
-static void audplay_error_threshold_config(struct audio *audio);
-static void audplay_config_hostpcm(struct audio *audio);
-static void audplay_buffer_refresh(struct audio *audio);
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg);
-static void audmp3_post_event(struct audio *audio, int type,
-	union msm_audio_event_payload payload);
-static unsigned long audmp3_pmem_fixup(struct audio *audio, void *addr,
-				unsigned long len, int ref_up);
-
-static void mp3_listner(u32 evt_id, union auddev_evt_data *evt_payload,
-			void *private_data)
-{
-	struct audio *audio = (struct audio *) private_data;
-	switch (evt_id) {
-	case AUDDEV_EVT_DEV_RDY:
-		MM_DBG(":AUDDEV_EVT_DEV_RDY\n");
-		audio->source |= (0x1 << evt_payload->routing_id);
-		if (audio->running == 1 && audio->enabled == 1)
-			audpp_route_stream(audio->dec_id, audio->source);
-
-		break;
-	case AUDDEV_EVT_DEV_RLS:
-		MM_DBG(":AUDDEV_EVT_DEV_RLS\n");
-		audio->source &= ~(0x1 << evt_payload->routing_id);
-		if (audio->running == 1 && audio->enabled == 1)
-			audpp_route_stream(audio->dec_id, audio->source);
-		break;
-	case AUDDEV_EVT_STREAM_VOL_CHG:
-		audio->vol_pan.volume = evt_payload->session_vol;
-		MM_DBG(":AUDDEV_EVT_STREAM_VOL_CHG, stream vol %d\n",
-				audio->vol_pan.volume);
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		break;
-	default:
-		MM_ERR(":ERROR:wrong event\n");
-		break;
-	}
-}
-/* must be called with audio->lock held */
-static int audio_enable(struct audio *audio)
-{
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	if (audio->enabled)
-		return 0;
-
-	audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-
-	if (msm_adsp_enable(audio->audplay)) {
-		MM_ERR("msm_adsp_enable(audplay) failed\n");
-		return -ENODEV;
-	}
-
-	if (audpp_enable(audio->dec_id, audio_dsp_event, audio)) {
-		MM_ERR("audpp_enable() failed\n");
-		msm_adsp_disable(audio->audplay);
-		return -ENODEV;
-	}
-
-	audio->enabled = 1;
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audio_disable(struct audio *audio)
-{
-	int rc = 0;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-		auddec_dsp_config(audio, 0);
-		rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-		if (rc == 0)
-			rc = -ETIMEDOUT;
-		else if (audio->dec_state != MSM_AUD_DECODER_STATE_CLOSE)
-			rc = -EFAULT;
-		else
-			rc = 0;
-		wake_up(&audio->write_wait);
-		wake_up(&audio->read_wait);
-		msm_adsp_disable(audio->audplay);
-		audpp_disable(audio->dec_id, audio);
-		audio->out_needed = 0;
-	}
-	return rc;
-}
-
-/* ------------------- dsp --------------------- */
-static void audmp3_async_pcm_buf_update(struct audio *audio, uint32_t *payload)
-{
-	unsigned long flags;
-	union msm_audio_event_payload event_payload;
-	struct audmp3_buffer_node *filled_buf;
-	uint8_t index;
-
-	if (audio->rflush)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < payload[1]; index++) {
-		BUG_ON(list_empty(&audio->in_queue));
-		filled_buf = list_first_entry(&audio->in_queue,
-					struct audmp3_buffer_node, list);
-		if (filled_buf->paddr == payload[2 + index * 2]) {
-			list_del(&filled_buf->list);
-			event_payload.aio_buf = filled_buf->buf;
-			event_payload.aio_buf.data_len =
-				payload[3 + index * 2];
-			MM_DBG("pcm buf %p data_len %d\n", filled_buf,
-					event_payload.aio_buf.data_len);
-			audmp3_post_event(audio, AUDIO_EVENT_READ_DONE,
-						event_payload);
-			kfree(filled_buf);
-		} else {
-			MM_ERR("expected=%lx ret=%x\n", filled_buf->paddr,
-					payload[2 + index * 2]);
-			break;
-		}
-	}
-
-	audio->drv_status &= ~ADRV_STATUS_IBUF_GIVEN;
-	audio->drv_ops.buffer_refresh(audio);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-
-}
-
-static void audio_update_pcm_buf_entry(struct audio *audio, uint32_t *payload)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	if (audio->rflush)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < payload[1]; index++) {
-		if (audio->in[audio->fill_next].addr ==
-		    payload[2 + index * 2]) {
-			MM_DBG("in[%d] ready\n", audio->fill_next);
-			audio->in[audio->fill_next].used =
-			  payload[3 + index * 2];
-			if ((++audio->fill_next) == audio->pcm_buf_count)
-				audio->fill_next = 0;
-
-		} else {
-			MM_ERR("expected=%x ret=%x\n",
-					audio->in[audio->fill_next].addr,
-					payload[2 + index * 2]);
-			break;
-		}
-	}
-	if (audio->in[audio->fill_next].used == 0) {
-		audio->drv_ops.buffer_refresh(audio);
-	} else {
-		MM_DBG("read cannot keep up\n");
-		audio->buf_refresh = 1;
-	}
-	wake_up(&audio->read_wait);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-
-}
-
-static void audmp3_bitstream_error_info(struct audio *audio, uint32_t *payload)
-{
-	unsigned long flags;
-	union msm_audio_event_payload e_payload;
-
-	if (payload[0] != AUDDEC_DEC_MP3) {
-		MM_ERR("Unexpected bitstream error info from DSP:\
-				Invalid decoder\n");
-		return;
-	}
-
-	/* get stream info from DSP msg */
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-
-	audio->bitstream_error_info.dec_id = payload[0];
-	audio->bitstream_error_info.err_msg_indicator = payload[1];
-	audio->bitstream_error_info.err_type = payload[2];
-
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	MM_ERR("bit_stream_error_type=%d error_count=%d\n",
-			audio->bitstream_error_info.err_type, (0x0000FFFF &
-			audio->bitstream_error_info.err_msg_indicator));
-
-	/* send event to ARM to notify error info coming */
-	e_payload.error_info = audio->bitstream_error_info;
-	audmp3_post_event(audio, AUDIO_EVENT_BITSTREAM_ERROR_INFO, e_payload);
-}
-
-static void audmp3_update_stream_info(struct audio *audio, uint32_t *payload)
-{
-	unsigned long flags;
-	union msm_audio_event_payload e_payload;
-
-	/* get stream info from DSP msg */
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-
-	audio->stream_info.codec_type = AUDIO_CODEC_TYPE_MP3;
-	audio->stream_info.chan_info = (0x0000FFFF & payload[1]);
-	audio->stream_info.sample_rate = (0x0000FFFF & payload[2]);
-	audio->stream_info.bit_stream_info = (0x0000FFFF & payload[3]);
-	audio->stream_info.bit_rate = payload[4];
-
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	MM_DBG("chan_info=%d, sample_rate=%d, bit_stream_info=%d\n",
-			audio->stream_info.chan_info,
-			audio->stream_info.sample_rate,
-			audio->stream_info.bit_stream_info);
-
-	/* send event to ARM to notify steam info coming */
-	e_payload.stream_info = audio->stream_info;
-	audmp3_post_event(audio, AUDIO_EVENT_STREAM_INFO, e_payload);
-}
-
-static void audplay_dsp_event(void *data, unsigned id, size_t len,
-			      void (*getevent) (void *ptr, size_t len))
-{
-	struct audio *audio = data;
-	uint32_t msg[28];
-	getevent(msg, sizeof(msg));
-
-	MM_DBG("msg_id=%x\n", id);
-
-	switch (id) {
-	case AUDPLAY_MSG_DEC_NEEDS_DATA:
-		audio->drv_ops.send_data(audio, 1);
-		break;
-
-	case AUDPLAY_MSG_BUFFER_UPDATE:
-		audio->drv_ops.pcm_buf_update(audio, msg);
-		break;
-
-	case AUDPLAY_UP_STREAM_INFO:
-		if ((msg[1] & AUDPLAY_STREAM_INFO_MSG_MASK) ==
-				AUDPLAY_STREAM_INFO_MSG_MASK) {
-			audmp3_bitstream_error_info(audio, msg);
-		} else {
-			audmp3_update_stream_info(audio, msg);
-		}
-		break;
-
-	case AUDPLAY_UP_OUTPORT_FLUSH_ACK:
-		MM_DBG("OUTPORT_FLUSH_ACK\n");
-		audio->rflush = 0;
-		wake_up(&audio->read_wait);
-		if (audio->pcm_feedback)
-			audio->drv_ops.buffer_refresh(audio);
-		break;
-
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audplaytask)\n");
-		break;
-
-	default:
-		MM_ERR("unexpected message from decoder \n");
-		break;
-	}
-}
-
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg)
-{
-	struct audio *audio = private;
-
-	switch (id) {
-	case AUDPP_MSG_STATUS_MSG:{
-			unsigned status = msg[1];
-
-			switch (status) {
-			case AUDPP_DEC_STATUS_SLEEP: {
-				uint16_t reason = msg[2];
-				MM_DBG("decoder status: sleep reason=0x%04x\n",
-						reason);
-				if ((reason == AUDPP_MSG_REASON_MEM)
-					|| (reason ==
-					AUDPP_MSG_REASON_NODECODER)) {
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_FAILURE;
-					wake_up(&audio->wait);
-				} else if (reason == AUDPP_MSG_REASON_NONE) {
-					/* decoder is in disable state */
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_CLOSE;
-					wake_up(&audio->wait);
-				}
-				break;
-			}
-			case AUDPP_DEC_STATUS_INIT:
-				MM_DBG("decoder status: init \n");
-				if (audio->pcm_feedback)
-					audpp_cmd_cfg_routing_mode(audio);
-				else
-					audpp_cmd_cfg_adec_params(audio);
-				break;
-
-			case AUDPP_DEC_STATUS_CFG:
-				MM_DBG("decoder status: cfg \n");
-				break;
-			case AUDPP_DEC_STATUS_PLAY:
-				MM_DBG("decoder status: play \n");
-				/* send  mixer command */
-				audpp_route_stream(audio->dec_id,
-						audio->source);
-				if (audio->pcm_feedback) {
-					audplay_error_threshold_config(audio);
-					audplay_config_hostpcm(audio);
-					audio->drv_ops.buffer_refresh(audio);
-				}
-				audio->dec_state =
-					MSM_AUD_DECODER_STATE_SUCCESS;
-				wake_up(&audio->wait);
-				break;
-			default:
-				MM_ERR("unknown decoder status \n");
-				break;
-			}
-			break;
-		}
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_DBG("CFG_MSG ENABLE\n");
-			auddec_dsp_config(audio, 1);
-			audio->out_needed = 0;
-			audio->running = 1;
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-			audpp_dsp_set_eq(audio->dec_id, audio->eq_enable,
-					&audio->eq, POPP);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			MM_DBG("CFG_MSG DISABLE\n");
-			audio->running = 0;
-		} else {
-			MM_DBG("CFG_MSG %d?\n", msg[0]);
-		}
-		break;
-	case AUDPP_MSG_ROUTING_ACK:
-		MM_DBG("ROUTING_ACK mode=%d\n",	msg[1]);
-		audpp_cmd_cfg_adec_params(audio);
-		break;
-
-	case AUDPP_MSG_FLUSH_ACK:
-		MM_DBG("FLUSH_ACK\n");
-		audio->wflush = 0;
-		audio->rflush = 0;
-		wake_up(&audio->write_wait);
-		if (audio->pcm_feedback)
-			audio->drv_ops.buffer_refresh(audio);
-		break;
-
-	case AUDPP_MSG_PCMDMAMISSED:
-		MM_DBG("PCMDMAMISSED\n");
-		audio->teos = 1;
-		wake_up(&audio->write_wait);
-		break;
-
-	case AUDPP_MSG_AVSYNC_MSG:
-		MM_DBG("AUDPP_MSG_AVSYNC_MSG\n");
-		memcpy(&audio->avsync[0], msg, sizeof(audio->avsync));
-		audio->avsync_flag = 1;
-		wake_up(&audio->avsync_wait);
-		break;
-
-	default:
-		MM_ERR("UNKNOWN (%d)\n", id);
-	}
-
-}
-
-
-struct msm_adsp_ops audplay_adsp_ops = {
-	.event = audplay_dsp_event,
-};
-
-
-#define audplay_send_queue0(audio, cmd, len) \
-	msm_adsp_write(audio->audplay, audio->queue_id, \
-			cmd, len)
-
-static int auddec_dsp_config(struct audio *audio, int enable)
-{
-	struct audpp_cmd_cfg_dec_type cfg_dec_cmd;
-
-	memset(&cfg_dec_cmd, 0, sizeof(cfg_dec_cmd));
-
-	cfg_dec_cmd.cmd_id = AUDPP_CMD_CFG_DEC_TYPE;
-	if (enable)
-		cfg_dec_cmd.dec_cfg = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_ENA_DEC_V | AUDDEC_DEC_MP3;
-	else
-		cfg_dec_cmd.dec_cfg = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_DIS_DEC_V;
-	cfg_dec_cmd.dm_mode = 0x0;
-	cfg_dec_cmd.stream_id = audio->dec_id;
-	return audpp_send_queue1(&cfg_dec_cmd, sizeof(cfg_dec_cmd));
-}
-
-static void audpp_cmd_cfg_adec_params(struct audio *audio)
-{
-	struct audpp_cmd_cfg_adec_params_mp3 cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_CMD_CFG_ADEC_PARAMS;
-	cmd.common.length = AUDPP_CMD_CFG_ADEC_PARAMS_MP3_LEN;
-	cmd.common.dec_id = audio->dec_id;
-	cmd.common.input_sampling_frequency = audio->out_sample_rate;
-
-	audpp_send_queue2(&cmd, sizeof(cmd));
-}
-
-static void audpp_cmd_cfg_routing_mode(struct audio *audio)
-{
-	struct audpp_cmd_routing_mode cmd;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPP_CMD_ROUTING_MODE;
-	cmd.object_number = audio->dec_id;
-	if (audio->pcm_feedback)
-		cmd.routing_mode = ROUTING_MODE_FTRT;
-	else
-		cmd.routing_mode = ROUTING_MODE_RT;
-
-	audpp_send_queue1(&cmd, sizeof(cmd));
-}
-
-static int audplay_dsp_send_data_avail(struct audio *audio,
-					unsigned idx, unsigned len)
-{
-	struct audplay_cmd_bitstream_data_avail_nt2 cmd;
-
-	cmd.cmd_id		= AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2;
-	if (audio->mfield)
-		cmd.decoder_id = AUDMP3_METAFIELD_MASK |
-			(audio->out[idx].mfield_sz >> 1);
-	else
-		cmd.decoder_id		= audio->dec_id;
-	cmd.buf_ptr		= audio->out[idx].addr;
-	cmd.buf_size		= len/2;
-	cmd.partition_number	= 0;
-	return audplay_send_queue0(audio, &cmd, sizeof(cmd));
-}
-/* Caller holds irq_lock */
-static void audmp3_async_buffer_refresh(struct audio *audio)
-{
-	struct audplay_cmd_buffer_refresh refresh_cmd;
-	struct audmp3_buffer_node *next_buf;
-
-	if (!audio->running ||
-	    audio->drv_status & ADRV_STATUS_IBUF_GIVEN)
-		return;
-
-	if (!list_empty(&audio->in_queue)) {
-		next_buf = list_first_entry(&audio->in_queue,
-		    struct audmp3_buffer_node, list);
-		if (!next_buf)
-			return;
-		MM_DBG("next buf %p phy %lx len %d\n", next_buf,
-				next_buf->paddr, next_buf->buf.buf_len);
-		refresh_cmd.cmd_id = AUDPLAY_CMD_BUFFER_REFRESH;
-		refresh_cmd.num_buffers = 1;
-		refresh_cmd.buf0_address = next_buf->paddr;
-		refresh_cmd.buf0_length = next_buf->buf.buf_len -
-			(next_buf->buf.buf_len % 576) +
-			(audio->mfield ? 24 : 0); /* Mp3 frame size */
-		refresh_cmd.buf_read_count = 0;
-		audio->drv_status |= ADRV_STATUS_IBUF_GIVEN;
-		(void) audplay_send_queue0(audio, &refresh_cmd,
-			sizeof(refresh_cmd));
-	}
-
-}
-
-static void audplay_buffer_refresh(struct audio *audio)
-{
-	struct audplay_cmd_buffer_refresh refresh_cmd;
-
-	refresh_cmd.cmd_id = AUDPLAY_CMD_BUFFER_REFRESH;
-	refresh_cmd.num_buffers = 1;
-	refresh_cmd.buf0_address = audio->in[audio->fill_next].addr;
-	refresh_cmd.buf0_length = audio->in[audio->fill_next].size -
-		(audio->in[audio->fill_next].size % 576) +
-		(audio->mfield ? 24 : 0); /* Mp3 frame size */
-	refresh_cmd.buf_read_count = 0;
-	MM_DBG("buf0_addr=%x buf0_len=%d\n", refresh_cmd.buf0_address,
-			refresh_cmd.buf0_length);
-	(void)audplay_send_queue0(audio, &refresh_cmd, sizeof(refresh_cmd));
-}
-
-static void audplay_error_threshold_config(struct audio *audio)
-{
-	union audplay_cmd_channel_info ch_cfg_cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	ch_cfg_cmd.thr_update.cmd_id = AUDPLAY_CMD_CHANNEL_INFO;
-	ch_cfg_cmd.thr_update.threshold_update = AUDPLAY_ERROR_THRESHOLD_ENABLE;
-	ch_cfg_cmd.thr_update.threshold_value =
-		audio->bitstream_error_threshold_value;
-	(void)audplay_send_queue0(audio, &ch_cfg_cmd, sizeof(ch_cfg_cmd));
-}
-
-static void audplay_config_hostpcm(struct audio *audio)
-{
-	struct audplay_cmd_hpcm_buf_cfg cfg_cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	cfg_cmd.cmd_id = AUDPLAY_CMD_HPCM_BUF_CFG;
-	cfg_cmd.max_buffers = 1;
-	cfg_cmd.byte_swap = 0;
-	cfg_cmd.hostpcm_config = (0x8000) | (0x4000);
-	cfg_cmd.feedback_frequency = 1;
-	cfg_cmd.partition_number = 0;
-	(void)audplay_send_queue0(audio, &cfg_cmd, sizeof(cfg_cmd));
-
-}
-
-static void audplay_outport_flush(struct audio *audio)
-{
-	struct audplay_cmd_outport_flush op_flush_cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	op_flush_cmd.cmd_id = AUDPLAY_CMD_OUTPORT_FLUSH;
-	(void)audplay_send_queue0(audio, &op_flush_cmd, sizeof(op_flush_cmd));
-}
-
-static void audmp3_async_send_data(struct audio *audio, unsigned needed)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (needed && !audio->wflush) {
-		audio->out_needed = 1;
-		if (audio->drv_status & ADRV_STATUS_OBUF_GIVEN) {
-			/* pop one node out of queue */
-			union msm_audio_event_payload payload;
-			struct audmp3_buffer_node *used_buf;
-
-			MM_DBG("consumed\n");
-			BUG_ON(list_empty(&audio->out_queue));
-			used_buf = list_first_entry(&audio->out_queue,
-				struct audmp3_buffer_node, list);
-			list_del(&used_buf->list);
-			payload.aio_buf = used_buf->buf;
-			audmp3_post_event(audio, AUDIO_EVENT_WRITE_DONE,
-				payload);
-			kfree(used_buf);
-			audio->drv_status &= ~ADRV_STATUS_OBUF_GIVEN;
-		}
-
-	}
-
-	if (audio->out_needed) {
-		struct audmp3_buffer_node *next_buf;
-		struct audplay_cmd_bitstream_data_avail_nt2 cmd;
-		if (!list_empty(&audio->out_queue)) {
-			next_buf = list_first_entry(&audio->out_queue,
-					struct audmp3_buffer_node, list);
-			MM_DBG("next_buf %p\n", next_buf);
-			if (next_buf) {
-				MM_DBG("next buf phy %lx len %d\n",
-						next_buf->paddr,
-						next_buf->buf.data_len);
-
-				cmd.cmd_id =
-					AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2;
-				if (audio->mfield)
-					cmd.decoder_id = AUDMP3_METAFIELD_MASK |
-						(next_buf->buf.mfield_sz >> 1);
-				else
-					cmd.decoder_id = audio->dec_id;
-				cmd.buf_ptr	= (unsigned) next_buf->paddr;
-				cmd.buf_size = next_buf->buf.data_len >> 1;
-				cmd.partition_number	= 0;
-				audplay_send_queue0(audio, &cmd, sizeof(cmd));
-				audio->out_needed = 0;
-				audio->drv_status |= ADRV_STATUS_OBUF_GIVEN;
-			}
-		}
-	}
-
-done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audplay_send_data(struct audio *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			MM_DBG("frame %d free\n", audio->out_tail);
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			MM_DBG("frame %d busy\n", audio->out_tail);
-			audplay_dsp_send_data_avail(audio, audio->out_tail,
-					frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
-done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-static void audmp3_async_flush(struct audio *audio)
-{
-	struct audmp3_buffer_node *buf_node;
-	struct list_head *ptr, *next;
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	list_for_each_safe(ptr, next, &audio->out_queue) {
-		buf_node = list_entry(ptr, struct audmp3_buffer_node, list);
-		list_del(&buf_node->list);
-		payload.aio_buf = buf_node->buf;
-		audmp3_post_event(audio, AUDIO_EVENT_WRITE_DONE,
-				payload);
-		kfree(buf_node);
-	}
-	audio->drv_status &= ~ADRV_STATUS_OBUF_GIVEN;
-	audio->out_needed = 0;
-	atomic_set(&audio->out_bytes, 0);
-}
-
-static void audio_flush(struct audio *audio)
-{
-	audio->out[0].used = 0;
-	audio->out[1].used = 0;
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->reserved = 0;
-	audio->out_needed = 0;
-	atomic_set(&audio->out_bytes, 0);
-}
-
-static void audmp3_async_flush_pcm_buf(struct audio *audio)
-{
-	struct audmp3_buffer_node *buf_node;
-	struct list_head *ptr, *next;
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	list_for_each_safe(ptr, next, &audio->in_queue) {
-		buf_node = list_entry(ptr, struct audmp3_buffer_node, list);
-		list_del(&buf_node->list);
-		payload.aio_buf = buf_node->buf;
-		payload.aio_buf.data_len = 0;
-		audmp3_post_event(audio, AUDIO_EVENT_READ_DONE,
-				payload);
-		kfree(buf_node);
-	}
-	audio->drv_status &= ~ADRV_STATUS_IBUF_GIVEN;
-
-}
-
-static void audio_flush_pcm_buf(struct audio *audio)
-{
-	uint8_t index;
-
-	for (index = 0; index < PCM_BUF_MAX_COUNT; index++)
-		audio->in[index].used = 0;
-
-	audio->buf_refresh = 0;
-	audio->read_next = 0;
-	audio->fill_next = 0;
-}
-
-static void audio_ioport_reset(struct audio *audio)
-{
-	if (audio->drv_status & ADRV_STATUS_AIO_INTF) {
-		/* If fsync is in progress, make sure
-		 * return value of fsync indicates
-		 * abort due to flush
-		 */
-		if (audio->drv_status & ADRV_STATUS_FSYNC) {
-			MM_DBG("fsync in progress\n");
-			wake_up(&audio->write_wait);
-			mutex_lock(&audio->write_lock);
-			audio->drv_ops.out_flush(audio);
-			mutex_unlock(&audio->write_lock);
-		} else
-			audio->drv_ops.out_flush(audio);
-		audio->drv_ops.in_flush(audio);
-	} else {
-		/* Make sure read/write thread are free from
-		 * sleep and knowing that system is not able
-		 * to process io request at the moment
-		 */
-		wake_up(&audio->write_wait);
-		mutex_lock(&audio->write_lock);
-		audio->drv_ops.out_flush(audio);
-		mutex_unlock(&audio->write_lock);
-		wake_up(&audio->read_wait);
-		mutex_lock(&audio->read_lock);
-		audio->drv_ops.in_flush(audio);
-		mutex_unlock(&audio->read_lock);
-	}
-	audio->avsync_flag = 1;
-	wake_up(&audio->avsync_wait);
-}
-
-static int audmp3_events_pending(struct audio *audio)
-{
-	unsigned long flags;
-	int empty;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	empty = !list_empty(&audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	return empty || audio->event_abort;
-}
-
-static void audmp3_reset_event_queue(struct audio *audio)
-{
-	unsigned long flags;
-	struct audmp3_event *drv_evt;
-	struct list_head *ptr, *next;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	list_for_each_safe(ptr, next, &audio->event_queue) {
-		drv_evt = list_first_entry(&audio->event_queue,
-			struct audmp3_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	list_for_each_safe(ptr, next, &audio->free_event_queue) {
-		drv_evt = list_first_entry(&audio->free_event_queue,
-			struct audmp3_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	return;
-}
-
-static long audmp3_process_event_req(struct audio *audio, void __user *arg)
-{
-	long rc;
-	struct msm_audio_event usr_evt;
-	struct audmp3_event *drv_evt = NULL;
-	int timeout;
-	unsigned long flags;
-
-	if (copy_from_user(&usr_evt, arg, sizeof(struct msm_audio_event)))
-		return -EFAULT;
-
-	timeout = (int) usr_evt.timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(
-			audio->event_wait, audmp3_events_pending(audio),
-			msecs_to_jiffies(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(
-			audio->event_wait, audmp3_events_pending(audio));
-	}
-
-	if (rc < 0)
-		return rc;
-
-	if (audio->event_abort) {
-		audio->event_abort = 0;
-		return -ENODEV;
-	}
-
-	rc = 0;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	if (!list_empty(&audio->event_queue)) {
-		drv_evt = list_first_entry(&audio->event_queue,
-			struct audmp3_event, list);
-		list_del(&drv_evt->list);
-	}
-	if (drv_evt) {
-		usr_evt.event_type = drv_evt->event_type;
-		usr_evt.event_payload = drv_evt->payload;
-		list_add_tail(&drv_evt->list, &audio->free_event_queue);
-	} else
-		rc = -1;
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	if (drv_evt->event_type == AUDIO_EVENT_WRITE_DONE ||
-	    drv_evt->event_type == AUDIO_EVENT_READ_DONE) {
-		mutex_lock(&audio->lock);
-		audmp3_pmem_fixup(audio, drv_evt->payload.aio_buf.buf_addr,
-				  drv_evt->payload.aio_buf.buf_len, 0);
-		mutex_unlock(&audio->lock);
-	}
-	if (!rc && copy_to_user(arg, &usr_evt, sizeof(usr_evt)))
-		rc = -EFAULT;
-
-	return rc;
-}
-
-static int audmp3_pmem_lookup_vaddr(struct audio *audio, void *addr,
-		     unsigned long len, struct audmp3_pmem_region **region)
-{
-	struct audmp3_pmem_region *region_elt;
-
-	int match_count = 0;
-
-	*region = NULL;
-
-	/* returns physical address or zero */
-	list_for_each_entry(region_elt, &audio->pmem_region_queue,
-		list) {
-		if (addr >= region_elt->vaddr &&
-		    addr < region_elt->vaddr + region_elt->len &&
-		    addr + len <= region_elt->vaddr + region_elt->len) {
-			/* offset since we could pass vaddr inside a registerd
-			 * pmem buffer
-			 */
-
-			match_count++;
-			if (!*region)
-				*region = region_elt;
-		}
-	}
-
-	if (match_count > 1) {
-		MM_ERR("multiple hits for vaddr %p, len %ld\n", addr, len);
-		list_for_each_entry(region_elt,
-		  &audio->pmem_region_queue, list) {
-			if (addr >= region_elt->vaddr &&
-			    addr < region_elt->vaddr + region_elt->len &&
-			    addr + len <= region_elt->vaddr + region_elt->len)
-				MM_ERR("\t%p, %ld --> %p\n", region_elt->vaddr,
-						region_elt->len,
-						(void *)region_elt->paddr);
-		}
-	}
-
-	return *region ? 0 : -1;
-}
-
-unsigned long audmp3_pmem_fixup(struct audio *audio, void *addr,
-		    unsigned long len, int ref_up)
-{
-	struct audmp3_pmem_region *region;
-	unsigned long paddr;
-	int ret;
-
-	ret = audmp3_pmem_lookup_vaddr(audio, addr, len, &region);
-	if (ret) {
-		MM_ERR("lookup (%p, %ld) failed\n", addr, len);
-		return 0;
-	}
-	if (ref_up)
-		region->ref_cnt++;
-	else
-		region->ref_cnt--;
-	MM_DBG("found region %p ref_cnt %d\n", region, region->ref_cnt);
-	paddr = region->paddr + (addr - region->vaddr);
-	return paddr;
-}
-
-/* audio -> lock must be held at this point */
-static int audmp3_aio_buf_add(struct audio *audio, unsigned dir,
-	void __user *arg)
-{
-	unsigned long flags;
-	struct audmp3_buffer_node *buf_node;
-
-	buf_node = kmalloc(sizeof(*buf_node), GFP_KERNEL);
-
-	if (!buf_node)
-		return -ENOMEM;
-
-	if (copy_from_user(&buf_node->buf, arg, sizeof(buf_node->buf))) {
-		kfree(buf_node);
-		return -EFAULT;
-	}
-
-	MM_DBG("node %p dir %x buf_addr %p buf_len %d data_len \
-			%d\n", buf_node, dir,
-			buf_node->buf.buf_addr, buf_node->buf.buf_len,
-			buf_node->buf.data_len);
-
-	buf_node->paddr = audmp3_pmem_fixup(
-		audio, buf_node->buf.buf_addr,
-		buf_node->buf.buf_len, 1);
-
-	if (dir) {
-		/* write */
-		if (!buf_node->paddr ||
-		    (buf_node->paddr & 0x1) ||
-		    (buf_node->buf.data_len & 0x1) ||
-		    (!audio->pcm_feedback &&
-		    !buf_node->buf.data_len)) {
-			kfree(buf_node);
-			return -EINVAL;
-		}
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		list_add_tail(&buf_node->list, &audio->out_queue);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		audio->drv_ops.send_data(audio, 0);
-	} else {
-		/* read */
-		if (!buf_node->paddr ||
-		    (buf_node->paddr & 0x1) ||
-		    (buf_node->buf.buf_len < PCM_BUFSZ_MIN)) {
-			kfree(buf_node);
-			return -EINVAL;
-		}
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		list_add_tail(&buf_node->list, &audio->in_queue);
-		audio->drv_ops.buffer_refresh(audio);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	}
-
-	MM_DBG("Add buf_node %p paddr %lx\n", buf_node, buf_node->paddr);
-
-	return 0;
-}
-
-static int audio_enable_eq(struct audio *audio, int enable)
-{
-	if (audio->eq_enable == enable && !audio->eq_needs_commit)
-		return 0;
-
-	audio->eq_enable = enable;
-
-	if (audio->running) {
-		audpp_dsp_set_eq(audio->dec_id, enable, &audio->eq, POPP);
-		audio->eq_needs_commit = 0;
-	}
-	return 0;
-}
-
-static int audio_get_avsync_data(struct audio *audio,
-						struct msm_audio_stats *stats)
-{
-	int rc = -EINVAL;
-	unsigned long flags;
-
-	local_irq_save(flags);
-	if (audio->dec_id == audio->avsync[0] && audio->avsync_flag) {
-		/* av_sync sample count */
-		stats->sample_count = (audio->avsync[2] << 16) |
-						(audio->avsync[3]);
-
-		/* av_sync byte_count */
-		stats->byte_count = (audio->avsync[5] << 16) |
-						(audio->avsync[6]);
-
-		audio->avsync_flag = 0;
-		rc = 0;
-	}
-	local_irq_restore(flags);
-	return rc;
-
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = -EINVAL;
-	unsigned long flags = 0;
-	uint16_t enable_mask;
-	int enable;
-	int prev_state;
-
-	MM_DBG("cmd = %d\n", cmd);
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-
-		audio->avsync_flag = 0;
-		memset(&stats, 0, sizeof(stats));
-		if (audpp_query_avsync(audio->dec_id) < 0)
-			return rc;
-
-		rc = wait_event_interruptible_timeout(audio->avsync_wait,
-				(audio->avsync_flag == 1),
-				msecs_to_jiffies(AUDPP_AVSYNC_EVENT_TIMEOUT));
-
-		if (rc < 0)
-			return rc;
-		else if ((rc > 0) || ((rc == 0) && (audio->avsync_flag == 1))) {
-			if (audio_get_avsync_data(audio, &stats) < 0)
-				return rc;
-
-			if (copy_to_user((void *)arg, &stats, sizeof(stats)))
-				return -EFAULT;
-			return 0;
-		} else
-			return -EAGAIN;
-	}
-
-	switch (cmd) {
-	case AUDIO_ENABLE_AUDPP:
-		if (copy_from_user(&enable_mask, (void *) arg,
-						sizeof(enable_mask))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		enable = (enable_mask & EQ_ENABLE) ? 1 : 0;
-		audio_enable_eq(audio, enable);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-	case AUDIO_SET_VOLUME:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.volume = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_PAN:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.pan = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_EQ:
-		prev_state = audio->eq_enable;
-		audio->eq_enable = 0;
-		if (copy_from_user(&audio->eq.num_bands, (void *) arg,
-				sizeof(audio->eq) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2))) {
-			rc = -EFAULT;
-			break;
-		}
-		audio->eq_enable = prev_state;
-		audio->eq_needs_commit = 1;
-		rc = 0;
-		break;
-	}
-
-	if (-EINVAL != rc)
-		return rc;
-
-	if (cmd == AUDIO_GET_EVENT) {
-		MM_DBG(" AUDIO_GET_EVENT\n");
-		if (mutex_trylock(&audio->get_event_lock)) {
-			rc = audmp3_process_event_req(audio,
-				(void __user *) arg);
-			mutex_unlock(&audio->get_event_lock);
-		} else
-			rc = -EBUSY;
-		return rc;
-	}
-
-	if (cmd == AUDIO_ABORT_GET_EVENT) {
-		audio->event_abort = 1;
-		wake_up(&audio->event_wait);
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		MM_DBG("AUDIO_START\n");
-		rc = audio_enable(audio);
-		if (!rc) {
-			rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-			MM_INFO("dec_state %d rc = %d\n", audio->dec_state, rc);
-
-			if (audio->dec_state != MSM_AUD_DECODER_STATE_SUCCESS)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		break;
-	case AUDIO_STOP:
-		MM_DBG("AUDIO_STOP\n");
-		rc = audio_disable(audio);
-		audio->stopped = 1;
-		audio_ioport_reset(audio);
-		audio->stopped = 0;
-		break;
-	case AUDIO_FLUSH:
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audio_ioport_reset(audio);
-		if (audio->running) {
-			audpp_flush(audio->dec_id);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-	case AUDIO_OUTPORT_FLUSH:
-		MM_DBG("AUDIO_OUTPORT_FLUSH\n");
-		audio->rflush = 1;
-		if (audio->drv_status & ADRV_STATUS_AIO_INTF) {
-			audio->drv_ops.in_flush(audio);
-		} else {
-			wake_up(&audio->read_wait);
-			mutex_lock(&audio->read_lock);
-			audio->drv_ops.in_flush(audio);
-			mutex_unlock(&audio->read_lock);
-		}
-		audplay_outport_flush(audio);
-		rc = wait_event_interruptible(audio->read_wait,
-				!audio->rflush);
-		if (rc < 0) {
-			MM_ERR("AUDPLAY_OUTPORT_FLUSH interrupted\n");
-			rc = -EINTR;
-		}
-		break;
-	case AUDIO_SET_CONFIG: {
-		struct msm_audio_config config;
-		if (copy_from_user(&config, (void *) arg, sizeof(config))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (config.channel_count == 1) {
-			config.channel_count = AUDPP_CMD_PCM_INTF_MONO_V;
-		} else if (config.channel_count == 2) {
-			config.channel_count = AUDPP_CMD_PCM_INTF_STEREO_V;
-		} else {
-			rc = -EINVAL;
-			break;
-		}
-		audio->mfield = config.meta_field;
-		audio->out_sample_rate = config.sample_rate;
-		audio->out_channel_mode = config.channel_count;
-		rc = 0;
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config config;
-		config.buffer_size = (audio->out_dma_sz >> 1);
-		config.buffer_count = 2;
-		config.sample_rate = audio->out_sample_rate;
-		if (audio->out_channel_mode == AUDPP_CMD_PCM_INTF_MONO_V)
-			config.channel_count = 1;
-		else
-			config.channel_count = 2;
-		config.meta_field = 0;
-		config.unused[0] = 0;
-		config.unused[1] = 0;
-		config.unused[2] = 0;
-		if (copy_to_user((void *) arg, &config, sizeof(config)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-	case AUDIO_GET_PCM_CONFIG:{
-		struct msm_audio_pcm_config config;
-		config.pcm_feedback = audio->pcm_feedback;
-		config.buffer_count = PCM_BUF_MAX_COUNT;
-		config.buffer_size = PCM_BUFSZ_MIN;
-		if (copy_to_user((void *)arg, &config,
-			 sizeof(config)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-	case AUDIO_SET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			if (copy_from_user
-			    (&config, (void *)arg, sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-
-			if (config.pcm_feedback != audio->pcm_feedback) {
-				MM_ERR("Not sufficient permission to"
-					 "change the playback mode\n");
-				rc = -EACCES;
-				break;
-			}
-			if (audio->drv_status & ADRV_STATUS_AIO_INTF) {
-				rc = 0;
-				break;
-			}
-
-			if ((config.buffer_count > PCM_BUF_MAX_COUNT) ||
-			    (config.buffer_count == 1))
-				config.buffer_count = PCM_BUF_MAX_COUNT;
-
-			if (config.buffer_size < PCM_BUFSZ_MIN)
-				config.buffer_size = PCM_BUFSZ_MIN;
-
-			/* Check if pcm feedback is required */
-			if ((config.pcm_feedback) && (!audio->read_data)) {
-				MM_DBG("allocate PCM buffer %d\n",
-					config.buffer_count *
-					config.buffer_size);
-				audio->read_phys =
-					allocate_contiguous_ebi_nomap(
-							config.buffer_size *
-							config.buffer_count,
-							SZ_4K);
-				if (!audio->read_phys) {
-					rc = -ENOMEM;
-					break;
-				}
-				audio->map_v_read = ioremap(
-							audio->read_phys,
-							config.buffer_size *
-							config.buffer_count);
-				if (IS_ERR(audio->map_v_read)) {
-					MM_ERR("failed to map read buffer"
-							" physical address\n");
-					rc = -ENOMEM;
-					free_contiguous_memory_by_paddr(
-							audio->read_phys);
-				} else {
-					uint8_t index;
-					uint32_t offset = 0;
-					audio->read_data =
-						audio->map_v_read;
-					audio->buf_refresh = 0;
-					audio->pcm_buf_count =
-					    config.buffer_count;
-					audio->read_next = 0;
-					audio->fill_next = 0;
-
-					for (index = 0;
-					     index < config.buffer_count;
-					     index++) {
-						audio->in[index].data =
-						    audio->read_data + offset;
-						audio->in[index].addr =
-						    audio->read_phys + offset;
-						audio->in[index].size =
-						    config.buffer_size;
-						audio->in[index].used = 0;
-						offset += config.buffer_size;
-					}
-					rc = 0;
-					MM_DBG("read buf: phy addr \
-						0x%08x kernel addr 0x%08x\n",
-						audio->read_phys,
-						(int)audio->read_data);
-				}
-			} else {
-				rc = 0;
-			}
-			break;
-		}
-	case AUDIO_PAUSE:
-		MM_DBG("AUDIO_PAUSE %ld\n", arg);
-		rc = audpp_pause(audio->dec_id, (int) arg);
-		break;
-
-	case AUDIO_GET_STREAM_INFO:{
-		if (audio->stream_info.sample_rate == 0) {
-			/* haven't received DSP stream event,
-			the stream info is not updated */
-			rc = -EPERM;
-			break;
-		}
-		if (copy_to_user((void *)arg, &audio->stream_info,
-			sizeof(struct msm_audio_bitstream_info)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-	case AUDIO_GET_BITSTREAM_ERROR_INFO:{
-		if ((audio->bitstream_error_info.err_msg_indicator &
-				AUDPLAY_STREAM_INFO_MSG_MASK) ==
-				AUDPLAY_STREAM_INFO_MSG_MASK) {
-			/* haven't received bitstream error info event,
-			the bitstream error info is not updated */
-			rc = -EPERM;
-			break;
-		}
-		if (copy_to_user((void *)arg, &audio->bitstream_error_info,
-			sizeof(struct msm_audio_bitstream_error_info)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-
-	case AUDIO_ASYNC_WRITE:
-		if (audio->drv_status & ADRV_STATUS_FSYNC)
-			rc = -EBUSY;
-		else
-			rc = audmp3_aio_buf_add(audio, 1, (void __user *) arg);
-		break;
-
-	case AUDIO_ASYNC_READ:
-		if (audio->pcm_feedback)
-			rc = audmp3_aio_buf_add(audio, 0, (void __user *) arg);
-		else
-			rc = -EPERM;
-		break;
-	case AUDIO_GET_SESSION_ID:
-		if (copy_to_user((void *) arg, &audio->dec_id,
-					sizeof(unsigned short)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	case AUDIO_SET_ERR_THRESHOLD_VALUE:
-		if (copy_from_user(&audio->bitstream_error_threshold_value,
-					(void *)arg, sizeof(uint32_t)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-/* Only useful in tunnel-mode */
-int audmp3_async_fsync(struct audio *audio)
-{
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	/* Blocking client sends more data */
-	mutex_lock(&audio->lock);
-	audio->drv_status |= ADRV_STATUS_FSYNC;
-	mutex_unlock(&audio->lock);
-
-	mutex_lock(&audio->write_lock);
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->teos && audio->out_needed &&
-		list_empty(&audio->out_queue))
-		|| audio->wflush || audio->stopped);
-
-	if (audio->stopped || audio->wflush)
-		rc = -EBUSY;
-
-	mutex_unlock(&audio->write_lock);
-	mutex_lock(&audio->lock);
-	audio->drv_status &= ~ADRV_STATUS_FSYNC;
-	mutex_unlock(&audio->lock);
-
-	return rc;
-}
-
-int audmp3_sync_fsync(struct audio *audio)
-{
-	struct buffer *frame;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(!audio->out[0].used &&
-		!audio->out[1].used &&
-		audio->out_needed) || audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (audio->reserved) {
-		MM_DBG("send reserved byte\n");
-		frame = audio->out + audio->out_tail;
-		((char *) frame->data)[0] = audio->rsv_byte;
-		((char *) frame->data)[1] = 0;
-		frame->used = 2;
-		audio->drv_ops.send_data(audio, 0);
-
-		rc = wait_event_interruptible(audio->write_wait,
-			(!audio->out[0].used &&
-			!audio->out[1].used &&
-			audio->out_needed) || audio->wflush);
-
-		if (rc < 0)
-			goto done;
-		else if (audio->wflush) {
-			rc = -EBUSY;
-			goto done;
-		}
-	}
-
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		audio->teos || audio->wflush);
-
-	if (audio->wflush)
-		rc = -EBUSY;
-
-done:
-	mutex_unlock(&audio->write_lock);
-	return rc;
-}
-
-int audmp3_fsync(struct file *file, loff_t ppos1, loff_t ppos2, int datasync)
-{
-	struct audio *audio = file->private_data;
-
-	if (!audio->running || audio->pcm_feedback)
-		return -EINVAL;
-
-	return audio->drv_ops.fsync(audio);
-}
-
-static ssize_t audio_read(struct file *file, char __user *buf, size_t count,
-			  loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	int rc = 0;
-
-	if (audio->drv_status & ADRV_STATUS_AIO_INTF)
-		return -EPERM;
-	else if (!audio->pcm_feedback)
-		return 0; /* PCM feedback disabled. Nothing to read */
-
-	mutex_lock(&audio->read_lock);
-	MM_DBG("%d \n",	count);
-	while (count > 0) {
-		rc = wait_event_interruptible_timeout(
-			audio->read_wait,
-			(audio->in[audio->read_next].
-			used > 0) || (audio->stopped)
-			|| (audio->rflush),
-			msecs_to_jiffies(MSM_AUD_BUFFER_UPDATE_WAIT_MS));
-
-		if (rc == 0) {
-			rc = -ETIMEDOUT;
-			break;
-		} else if (rc < 0)
-			break;
-
-		if (audio->stopped || audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (count < audio->in[audio->read_next].used) {
-			/* Read must happen in frame boundary. Since
-			 * driver does not know frame size, read count
-			 * must be greater or equal
-			 * to size of PCM samples
-			 */
-			MM_DBG("no partial frame done reading\n");
-			break;
-		} else {
-			MM_DBG("read from in[%d]\n", audio->read_next);
-
-			if (copy_to_user
-			    (buf, audio->in[audio->read_next].data,
-			     audio->in[audio->read_next].used)) {
-				MM_ERR("invalid addr %x \n", (unsigned int)buf);
-				rc = -EFAULT;
-				break;
-			}
-			count -= audio->in[audio->read_next].used;
-			buf += audio->in[audio->read_next].used;
-			audio->in[audio->read_next].used = 0;
-			if ((++audio->read_next) == audio->pcm_buf_count)
-				audio->read_next = 0;
-			break;	/* Force to exit while loop
-				 * to prevent output thread
-				 * sleep too long if data is
-				 * not ready at this moment.
-				 */
-		}
-	}
-
-	/* don't feed output buffer to HW decoder during flushing
-	 * buffer refresh command will be sent once flush completes
-	 * send buf refresh command here can confuse HW decoder
-	 */
-	if (audio->buf_refresh && !audio->rflush) {
-		audio->buf_refresh = 0;
-		MM_DBG("kick start pcm feedback again\n");
-		audio->drv_ops.buffer_refresh(audio);
-	}
-
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		rc = buf - start;
-
-	MM_DBG("read %d bytes\n", rc);
-	return rc;
-}
-
-static int audmp3_process_eos(struct audio *audio,
-		const char __user *buf_start, unsigned short mfield_size)
-{
-	int rc = 0;
-	struct buffer *frame;
-	char *buf_ptr;
-
-	if (audio->reserved) {
-		MM_DBG("flush reserve byte\n");
-		frame = audio->out + audio->out_head;
-		buf_ptr = frame->data;
-		rc = wait_event_interruptible(audio->write_wait,
-			(frame->used == 0)
-			|| (audio->stopped)
-			|| (audio->wflush));
-		if (rc < 0)
-			goto done;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			goto done;
-		}
-
-		buf_ptr[0] = audio->rsv_byte;
-		buf_ptr[1] = 0;
-		audio->out_head ^= 1;
-		frame->mfield_sz = 0;
-		frame->used = 2;
-		audio->reserved = 0;
-		audio->drv_ops.send_data(audio, 0);
-	}
-
-	frame = audio->out + audio->out_head;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	audio->drv_ops.send_data(audio, 0);
-done:
-	return rc;
-}
-
-static ssize_t audio_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	size_t xfer;
-	char *cpy_ptr;
-	int rc = 0, eos_condition = AUDMP3_EOS_NONE;
-	unsigned dsize;
-	unsigned short mfield_size = 0;
-
-	if (audio->drv_status & ADRV_STATUS_AIO_INTF)
-		return -EPERM;
-
-	MM_DBG("cnt=%d\n", count);
-
-	mutex_lock(&audio->write_lock);
-	while (count > 0) {
-		frame = audio->out + audio->out_head;
-		cpy_ptr = frame->data;
-		dsize = 0;
-		rc = wait_event_interruptible(audio->write_wait,
-					      (frame->used == 0)
-					      || (audio->stopped)
-						  || (audio->wflush));
-		if (rc < 0)
-			break;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			break;
-		}
-		if (audio->mfield) {
-			if (buf == start) {
-				/* Processing beginning of user buffer */
-				if (__get_user(mfield_size,
-					(unsigned short __user *) buf)) {
-					rc = -EFAULT;
-					break;
-				} else  if (mfield_size > count) {
-					rc = -EINVAL;
-					break;
-				}
-				MM_DBG("mf offset_val %x\n", mfield_size);
-				if (copy_from_user(cpy_ptr, buf, mfield_size)) {
-					rc = -EFAULT;
-					break;
-				}
-				/* Check if EOS flag is set and buffer has
-				 * contains just meta field
-				 */
-				if (cpy_ptr[AUDMP3_EOS_FLG_OFFSET] &
-						 AUDMP3_EOS_FLG_MASK) {
-					MM_DBG("EOS SET\n");
-					eos_condition = AUDMP3_EOS_SET;
-					if (mfield_size == count) {
-						buf += mfield_size;
-						break;
-					} else
-						cpy_ptr[AUDMP3_EOS_FLG_OFFSET]
-							&= ~AUDMP3_EOS_FLG_MASK;
-				}
-				cpy_ptr += mfield_size;
-				count -= mfield_size;
-				dsize += mfield_size;
-				buf += mfield_size;
-			} else {
-				mfield_size = 0;
-				MM_DBG("continuous buffer\n");
-			}
-			frame->mfield_sz = mfield_size;
-		}
-
-		if (audio->reserved) {
-			MM_DBG("append reserved byte %x\n", audio->rsv_byte);
-			*cpy_ptr = audio->rsv_byte;
-			xfer = (count > ((frame->size - mfield_size) - 1)) ?
-				(frame->size - mfield_size) - 1 : count;
-			cpy_ptr++;
-			dsize += 1;
-			audio->reserved = 0;
-		} else
-			xfer = (count > (frame->size - mfield_size)) ?
-				(frame->size - mfield_size) : count;
-
-		if (copy_from_user(cpy_ptr, buf, xfer)) {
-			rc = -EFAULT;
-			break;
-		}
-
-		dsize += xfer;
-		if (dsize & 1) {
-			audio->rsv_byte = ((char *) frame->data)[dsize - 1];
-			MM_DBG("odd length buf reserve last byte %x\n",
-					audio->rsv_byte);
-			audio->reserved = 1;
-			dsize--;
-		}
-		count -= xfer;
-		buf += xfer;
-
-		if (dsize > 0) {
-			audio->out_head ^= 1;
-			frame->used = dsize;
-			audio->drv_ops.send_data(audio, 0);
-		}
-	}
-	if (eos_condition == AUDMP3_EOS_SET)
-		rc = audmp3_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	if (!rc) {
-		if (buf > start)
-			return buf - start;
-	}
-	return rc;
-}
-
-static int audio_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	MM_INFO("audio instance 0x%08x freeing\n", (int)audio);
-	mutex_lock(&audio->lock);
-	auddev_unregister_evt_listner(AUDDEV_CLNT_DEC, audio->dec_id);
-	audio_disable(audio);
-	audio->drv_ops.out_flush(audio);
-	audio->drv_ops.in_flush(audio);
-
-	msm_adsp_put(audio->audplay);
-	audpp_adec_free(audio->dec_id);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	unregister_early_suspend(&audio->suspend_ctl.node);
-#endif
-	audio->opened = 0;
-	audio->event_abort = 1;
-	wake_up(&audio->event_wait);
-	audmp3_reset_event_queue(audio);
-	if (audio->data) {
-		iounmap(audio->map_v_write);
-		free_contiguous_memory_by_paddr(audio->phys);
-	}
-	if (audio->read_data) {
-		iounmap(audio->map_v_read);
-		free_contiguous_memory_by_paddr(audio->read_phys);
-	}
-	mutex_unlock(&audio->lock);
-#ifdef CONFIG_DEBUG_FS
-	if (audio->dentry)
-		debugfs_remove(audio->dentry);
-#endif
-	kfree(audio);
-	return 0;
-}
-
-static void audmp3_post_event(struct audio *audio, int type,
-	union msm_audio_event_payload payload)
-{
-	struct audmp3_event *e_node = NULL;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-
-	if (!list_empty(&audio->free_event_queue)) {
-		e_node = list_first_entry(&audio->free_event_queue,
-			struct audmp3_event, list);
-		list_del(&e_node->list);
-	} else {
-		e_node = kmalloc(sizeof(struct audmp3_event), GFP_ATOMIC);
-		if (!e_node) {
-			MM_ERR("No mem to post event %d\n", type);
-			return;
-		}
-	}
-
-	e_node->event_type = type;
-	e_node->payload = payload;
-
-	list_add_tail(&e_node->list, &audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	wake_up(&audio->event_wait);
-}
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audmp3_suspend(struct early_suspend *h)
-{
-	struct audmp3_suspend_ctl *ctl =
-		container_of(h, struct audmp3_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audmp3_post_event(ctl->audio, AUDIO_EVENT_SUSPEND, payload);
-}
-
-static void audmp3_resume(struct early_suspend *h)
-{
-	struct audmp3_suspend_ctl *ctl =
-		container_of(h, struct audmp3_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audmp3_post_event(ctl->audio, AUDIO_EVENT_RESUME, payload);
-}
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-static ssize_t audmp3_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static ssize_t audmp3_debug_read(struct file *file, char __user *buf,
-			  size_t count, loff_t *ppos)
-{
-	const int debug_bufmax = 4096;
-	static char buffer[4096];
-	int n = 0, i;
-	struct audio *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	n = scnprintf(buffer, debug_bufmax, "opened %d\n", audio->opened);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "enabled %d\n", audio->enabled);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "stopped %d\n", audio->stopped);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "pcm_feedback %d\n", audio->pcm_feedback);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_buf_sz %d\n", audio->out[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "pcm_buf_count %d \n", audio->pcm_buf_count);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "pcm_buf_sz %d \n", audio->in[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "volume %x \n", audio->vol_pan.volume);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "sample rate %d \n", audio->out_sample_rate);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-		"channel mode %d \n", audio->out_channel_mode);
-	mutex_unlock(&audio->lock);
-	/* Following variables are only useful for debugging when
-	 * when playback halts unexpectedly. Thus, no mutual exclusion
-	 * enforced
-	 */
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "wflush %d\n", audio->wflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "rflush %d\n", audio->rflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "running %d \n", audio->running);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				"dec state %d \n", audio->dec_state);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_needed %d \n", audio->out_needed);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_head %d \n", audio->out_head);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_tail %d \n", audio->out_tail);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out[0].used %d \n", audio->out[0].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out[1].used %d \n", audio->out[1].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "buffer_refresh %d \n", audio->buf_refresh);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "read_next %d \n", audio->read_next);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "fill_next %d \n", audio->fill_next);
-	for (i = 0; i < audio->pcm_buf_count; i++)
-		n += scnprintf(buffer + n, debug_bufmax - n,
-			"in[%d].size %d \n", i, audio->in[i].used);
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations audmp3_debug_fops = {
-	.read = audmp3_debug_read,
-	.open = audmp3_debug_open,
-};
-#endif
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-
-	struct audio *audio = NULL;
-	int rc, i, dec_attrb, decid;
-	struct audmp3_event *e_node = NULL;
-	unsigned pmem_sz = DMASZ_MAX;
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_mp3_" + 5];
-#endif
-
-	/* Allocate audio instance, set to zero */
-	audio = kzalloc(sizeof(struct audio), GFP_KERNEL);
-	if (!audio) {
-		MM_ERR("no memory to allocate audio instance \n");
-		rc = -ENOMEM;
-		goto done;
-	}
-	MM_INFO("audio instance 0x%08x created\n", (int)audio);
-
-	/* Allocate the decoder */
-	dec_attrb = AUDDEC_DEC_MP3;
-	if ((file->f_mode & FMODE_WRITE) &&
-			(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_NONTUNNEL;
-		audio->pcm_feedback = NON_TUNNEL_MODE_PLAYBACK;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_TUNNEL;
-		audio->pcm_feedback = TUNNEL_MODE_PLAYBACK;
-	} else {
-		kfree(audio);
-		rc = -EACCES;
-		goto done;
-	}
-
-	decid = audpp_adec_alloc(dec_attrb, &audio->module_name,
-			&audio->queue_id);
-	if (decid < 0) {
-		MM_ERR("No free decoder available, freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENODEV;
-		kfree(audio);
-		goto done;
-	}
-	audio->dec_id = decid & MSM_AUD_DECODER_MASK;
-
-	/* AIO interface */
-	if (file->f_flags & O_NONBLOCK) {
-		MM_DBG("set to aio interface\n");
-		audio->drv_status |= ADRV_STATUS_AIO_INTF;
-		audio->drv_ops.pcm_buf_update = audmp3_async_pcm_buf_update;
-		audio->drv_ops.buffer_refresh = audmp3_async_buffer_refresh;
-		audio->drv_ops.send_data = audmp3_async_send_data;
-		audio->drv_ops.out_flush = audmp3_async_flush;
-		audio->drv_ops.in_flush = audmp3_async_flush_pcm_buf;
-		audio->drv_ops.fsync = audmp3_async_fsync;
-	} else {
-		MM_DBG("set to std io interface\n");
-		while (pmem_sz >= DMASZ_MIN) {
-			MM_DBG("pmemsz = %d\n", pmem_sz);
-			audio->phys = allocate_contiguous_ebi_nomap(pmem_sz,
-									SZ_4K);
-			if (audio->phys) {
-				audio->map_v_write = ioremap(
-							audio->phys, pmem_sz);
-				if (IS_ERR(audio->map_v_write)) {
-					MM_ERR("failed to map write physical"
-						" address , freeing instance"
-						"0x%08x\n", (int)audio);
-					rc = -ENOMEM;
-					free_contiguous_memory_by_paddr(
-								audio->phys);
-					audpp_adec_free(audio->dec_id);
-					kfree(audio);
-					goto done;
-				}
-				audio->data = audio->map_v_write;
-				MM_DBG("write buf: phy addr 0x%08x kernel addr\
-					0x%08x\n", audio->phys,\
-					(int)audio->data);
-				break;
-			} else if (pmem_sz == DMASZ_MIN) {
-				MM_ERR("could not allocate write buffers, \
-						freeing instance 0x%08x\n",
-						(int)audio);
-				rc = -ENOMEM;
-				audpp_adec_free(audio->dec_id);
-				kfree(audio);
-				goto done;
-			} else
-				pmem_sz >>= 1;
-		}
-		audio->out_dma_sz = pmem_sz;
-		audio->drv_ops.pcm_buf_update = audio_update_pcm_buf_entry;
-		audio->drv_ops.buffer_refresh = audplay_buffer_refresh;
-		audio->drv_ops.send_data = audplay_send_data;
-		audio->drv_ops.out_flush = audio_flush;
-		audio->drv_ops.in_flush = audio_flush_pcm_buf;
-		audio->drv_ops.fsync = audmp3_sync_fsync;
-		audio->out[0].data = audio->data + 0;
-		audio->out[0].addr = audio->phys + 0;
-		audio->out[0].size = (audio->out_dma_sz >> 1);
-
-		audio->out[1].data = audio->data + audio->out[0].size;
-		audio->out[1].addr = audio->phys + audio->out[0].size;
-		audio->out[1].size = audio->out[0].size;
-	}
-
-	rc = msm_adsp_get(audio->module_name, &audio->audplay,
-		&audplay_adsp_ops, audio);
-
-	if (rc) {
-		MM_ERR("failed to get %s module freeing instance 0x%08x\n",
-				audio->module_name, (int)audio);
-		goto err;
-	}
-
-	/* Initialize all locks of audio instance */
-	mutex_init(&audio->lock);
-	mutex_init(&audio->write_lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->get_event_lock);
-	spin_lock_init(&audio->dsp_lock);
-	init_waitqueue_head(&audio->write_wait);
-	init_waitqueue_head(&audio->read_wait);
-	INIT_LIST_HEAD(&audio->out_queue);
-	INIT_LIST_HEAD(&audio->in_queue);
-	INIT_LIST_HEAD(&audio->pmem_region_queue);
-	INIT_LIST_HEAD(&audio->free_event_queue);
-	INIT_LIST_HEAD(&audio->event_queue);
-	init_waitqueue_head(&audio->wait);
-	init_waitqueue_head(&audio->event_wait);
-	spin_lock_init(&audio->event_queue_lock);
-	init_waitqueue_head(&audio->avsync_wait);
-
-	audio->out_sample_rate = 44100;
-	audio->out_channel_mode = AUDPP_CMD_PCM_INTF_STEREO_V;
-	audio->vol_pan.volume = 0x2000;
-	audio->bitstream_error_threshold_value =
-		BITSTREAM_ERROR_THRESHOLD_VALUE;
-
-	audio->drv_ops.out_flush(audio);
-
-	file->private_data = audio;
-	audio->opened = 1;
-
-	audio->device_events = AUDDEV_EVT_DEV_RDY
-				|AUDDEV_EVT_DEV_RLS |
-				AUDDEV_EVT_STREAM_VOL_CHG;
-
-	rc = auddev_register_evt_listner(audio->device_events,
-					AUDDEV_CLNT_DEC,
-					audio->dec_id,
-					mp3_listner,
-					(void *)audio);
-	if (rc) {
-		MM_ERR("%s: failed to register listner\n", __func__);
-		goto event_err;
-	}
-
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof name, "msm_mp3_%04x", audio->dec_id);
-	audio->dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
-			NULL, (void *) audio, &audmp3_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		MM_DBG("debugfs_create_file failed\n");
-#endif
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	audio->suspend_ctl.node.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
-	audio->suspend_ctl.node.resume = audmp3_resume;
-	audio->suspend_ctl.node.suspend = audmp3_suspend;
-	audio->suspend_ctl.audio = audio;
-	register_early_suspend(&audio->suspend_ctl.node);
-#endif
-	for (i = 0; i < AUDMP3_EVENT_NUM; i++) {
-		e_node = kmalloc(sizeof(struct audmp3_event), GFP_KERNEL);
-		if (e_node)
-			list_add_tail(&e_node->list, &audio->free_event_queue);
-		else {
-			MM_ERR("event pkt alloc failed\n");
-			break;
-		}
-	}
-	memset(&audio->stream_info, 0, sizeof(struct msm_audio_bitstream_info));
-	memset(&audio->bitstream_error_info, 0,
-			sizeof(struct msm_audio_bitstream_info));
-done:
-	return rc;
-event_err:
-	msm_adsp_put(audio->audplay);
-err:
-	if (audio->data) {
-		iounmap(audio->map_v_write);
-		free_contiguous_memory_by_paddr(audio->phys);
-	}
-	audpp_adec_free(audio->dec_id);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_mp3_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audio_open,
-	.release	= audio_release,
-	.read		= audio_read,
-	.write		= audio_write,
-	.unlocked_ioctl	= audio_ioctl,
-	.fsync = audmp3_fsync,
-};
-
-struct miscdevice audio_mp3_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_mp3",
-	.fops	= &audio_mp3_fops,
-};
-
-static int __init audio_init(void)
-{
-	return misc_register(&audio_mp3_misc);
-}
-
-static void __exit audio_exit(void)
-{
-	misc_deregister(&audio_mp3_misc);
-}
-
-module_init(audio_init);
-module_exit(audio_exit);
-
-MODULE_DESCRIPTION("MSM MP3 driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5v2/audio_mvs.c b/arch/arm/mach-msm/qdsp5v2/audio_mvs.c
deleted file mode 100644
index f211fa0..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audio_mvs.c
+++ /dev/null
@@ -1,1766 +0,0 @@
-/* Copyright (c) 2010-2012, The Linux Foundation. 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.
- *
- */
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/kthread.h>
-#include <linux/list.h>
-#include <linux/uaccess.h>
-#include <linux/mutex.h>
-#include <linux/wakelock.h>
-#include <linux/msm_audio_mvs.h>
-#include <linux/slab.h>
-#include <linux/pm_qos.h>
-
-#include <mach/msm_rpcrouter.h>
-#include <mach/cpuidle.h>
-
-#define MVS_PROG 0x30000014
-#define MVS_VERS 0x00030001
-#define MVS_VERS_COMP_VER4 0x00040001
-#define MVS_VERS_COMP_VER5 0x00050001
-
-#define MVS_CLIENT_ID_VOIP 0x00000003
-
-#define MVS_ACQUIRE_PROC 4
-#define MVS_ENABLE_PROC 5
-#define MVS_RELEASE_PROC 6
-#define MVS_AMR_SET_AMR_MODE_PROC 7
-#define MVS_AMR_SET_AWB_MODE_PROC 8
-#define MVS_VOC_SET_FRAME_RATE_PROC 10
-#define MVS_GSM_SET_DTX_MODE_PROC 11
-#define MVS_G729A_SET_MODE_PROC 12
-#define MVS_G711_GET_MODE_PROC 14
-#define MVS_G711_SET_MODE_PROC 15
-#define MVS_G711A_GET_MODE_PROC 16
-#define MVS_G711A_SET_MODE_PROC 17
-#define MVS_G722_SET_MODE_PROC 20
-#define MVS_G722_GET_MODE_PROC 21
-#define MVS_SET_DTX_MODE_PROC 22
-
-#define MVS_EVENT_CB_TYPE_PROC 1
-#define MVS_PACKET_UL_FN_TYPE_PROC 2
-#define MVS_PACKET_DL_FN_TYPE_PROC 3
-
-#define MVS_CB_FUNC_ID 0xAAAABBBB
-#define MVS_UL_CB_FUNC_ID 0xBBBBCCCC
-#define MVS_DL_CB_FUNC_ID 0xCCCCDDDD
-
-#define MVS_FRAME_MODE_VOC_TX 1
-#define MVS_FRAME_MODE_VOC_RX 2
-#define MVS_FRAME_MODE_AMR_UL 3
-#define MVS_FRAME_MODE_AMR_DL 4
-#define MVS_FRAME_MODE_GSM_UL 5
-#define MVS_FRAME_MODE_GSM_DL 6
-#define MVS_FRAME_MODE_HR_UL 7
-#define MVS_FRAME_MODE_HR_DL 8
-#define MVS_FRAME_MODE_G711_UL 9
-#define MVS_FRAME_MODE_G711_DL 10
-#define MVS_FRAME_MODE_PCM_UL 13
-#define MVS_FRAME_MODE_PCM_DL 14
-#define MVS_FRAME_MODE_G729A_UL 17
-#define MVS_FRAME_MODE_G729A_DL 18
-#define MVS_FRAME_MODE_G711A_UL 19
-#define MVS_FRAME_MODE_G711A_DL 20
-#define MVS_FRAME_MODE_G722_UL 21
-#define MVS_FRAME_MODE_G722_DL 22
-
-
-
-#define MVS_PKT_CONTEXT_ISR 0x00000001
-
-#define RPC_TYPE_REQUEST 0
-#define RPC_TYPE_REPLY 1
-
-#define RPC_STATUS_FAILURE 0
-#define RPC_STATUS_SUCCESS 1
-#define RPC_STATUS_REJECT 1
-
-#define RPC_COMMON_HDR_SZ  (sizeof(uint32_t) * 2)
-#define RPC_REQUEST_HDR_SZ (sizeof(struct rpc_request_hdr))
-#define RPC_REPLY_HDR_SZ   (sizeof(uint32_t) * 3)
-
-enum audio_mvs_state_type {
-	AUDIO_MVS_CLOSED,
-	AUDIO_MVS_OPENED,
-	AUDIO_MVS_STARTED,
-	AUDIO_MVS_STOPPED
-};
-
-enum audio_mvs_event_type {
-	AUDIO_MVS_COMMAND,
-	AUDIO_MVS_MODE,
-	AUDIO_MVS_NOTIFY
-};
-
-enum audio_mvs_cmd_status_type {
-	AUDIO_MVS_CMD_FAILURE,
-	AUDIO_MVS_CMD_BUSY,
-	AUDIO_MVS_CMD_SUCCESS
-};
-
-enum audio_mvs_mode_status_type {
-	AUDIO_MVS_MODE_NOT_AVAIL,
-	AUDIO_MVS_MODE_INIT,
-	AUDIO_MVS_MODE_READY
-};
-
-enum audio_mvs_pkt_status_type {
-	AUDIO_MVS_PKT_NORMAL,
-	AUDIO_MVS_PKT_FAST,
-	AUDIO_MVS_PKT_SLOW
-};
-
-/* Parameters required for MVS acquire. */
-struct rpc_audio_mvs_acquire_args {
-	uint32_t client_id;
-	uint32_t cb_func_id;
-};
-
-struct audio_mvs_acquire_msg {
-	struct rpc_request_hdr rpc_hdr;
-	struct rpc_audio_mvs_acquire_args acquire_args;
-};
-
-/* Parameters required for MVS enable. */
-struct rpc_audio_mvs_enable_args {
-	uint32_t client_id;
-	uint32_t mode;
-	uint32_t ul_cb_func_id;
-	uint32_t dl_cb_func_id;
-	uint32_t context;
-};
-
-struct audio_mvs_enable_msg {
-	struct rpc_request_hdr rpc_hdr;
-	struct rpc_audio_mvs_enable_args enable_args;
-};
-
-/* Parameters required for MVS release. */
-struct audio_mvs_release_msg {
-	struct rpc_request_hdr rpc_hdr;
-	uint32_t client_id;
-};
-
-/* Parameters required for setting AMR mode. */
-struct audio_mvs_set_amr_mode_msg {
-	struct rpc_request_hdr rpc_hdr;
-	uint32_t amr_mode;
-};
-
-/* Parameters required for setting DTX. */
-struct audio_mvs_set_dtx_mode_msg {
-	struct rpc_request_hdr rpc_hdr;
-	uint32_t dtx_mode;
-};
-
-/* Parameters required for setting EVRC mode. */
-struct audio_mvs_set_voc_mode_msg {
-	struct rpc_request_hdr rpc_hdr;
-	uint32_t max_rate;
-	uint32_t min_rate;
-};
-
-/* Parameters for G711 mode */
-struct audio_mvs_set_g711_mode_msg {
-	struct rpc_request_hdr rpc_hdr;
-	uint32_t g711_mode;
-};
-
-/* Parameters for G729 mode */
-struct audio_mvs_set_g729_mode_msg {
-	struct rpc_request_hdr rpc_hdr;
-	uint32_t g729_mode;
-};
-
-/* Parameters for G722 mode */
-struct audio_mvs_set_g722_mode_msg {
-	struct rpc_request_hdr rpc_hdr;
-	uint32_t g722_mode;
-};
-
-
-/* Parameters for G711A mode */
-struct audio_mvs_set_g711A_mode_msg {
-	struct rpc_request_hdr rpc_hdr;
-	uint32_t g711A_mode;
-};
-
-/* Parameters for EFR FR and HR mode */
-struct audio_mvs_set_efr_mode_msg {
-	struct rpc_request_hdr rpc_hdr;
-	uint32_t efr_mode;
-};
-
-union audio_mvs_event_data {
-	struct mvs_ev_command_type {
-		uint32_t event;
-		uint32_t client_id;
-		uint32_t cmd_status;
-	} mvs_ev_command_type;
-
-	struct mvs_ev_mode_type {
-		uint32_t event;
-		uint32_t client_id;
-		uint32_t mode_status;
-		uint32_t mode;
-	} mvs_ev_mode_type;
-
-	struct mvs_ev_notify_type {
-		uint32_t event;
-		uint32_t client_id;
-		uint32_t buf_dir;
-		uint32_t max_frames;
-	} mvs_ev_notify_type;
-};
-
-struct audio_mvs_cb_func_args {
-	uint32_t cb_func_id;
-	uint32_t valid_ptr;
-	uint32_t event;
-	union audio_mvs_event_data event_data;
-};
-
-struct audio_mvs_frame_info_hdr {
-	uint32_t frame_mode;
-	uint32_t mvs_mode;
-	uint16_t buf_free_cnt;
-};
-
-struct audio_mvs_ul_reply {
-	struct rpc_reply_hdr reply_hdr;
-	uint32_t valid_pkt_status_ptr;
-	uint32_t pkt_status;
-};
-
-struct audio_mvs_dl_cb_func_args {
-	uint32_t cb_func_id;
-
-	uint32_t valid_ptr;
-	uint32_t frame_mode;
-	uint32_t frame_mode_ignore;
-
-	struct audio_mvs_frame_info_hdr frame_info_hdr;
-
-	uint32_t amr_frame;
-	uint32_t amr_mode;
-};
-/*general codec parameters includes AMR, G711A, PCM
-G729, VOC and HR vocoders
-*/
-struct gnr_cdc_param {
-	uint32_t param1;
-	uint32_t param2;
-	uint32_t valid_pkt_status_ptr;
-	uint32_t pkt_status;
-};
-/*G711 codec parameter*/
-struct g711_param {
-	uint32_t param1;
-	uint32_t valid_pkt_status_ptr;
-	uint32_t pkt_status;
-};
-
-union codec_param {
-	struct gnr_cdc_param gnr_arg;
-	struct g711_param g711_arg;
-};
-
-struct audio_mvs_dl_reply {
-	struct rpc_reply_hdr reply_hdr;
-
-	uint32_t voc_pkt[Q5V2_MVS_MAX_VOC_PKT_SIZE/4];
-
-	uint32_t valid_frame_info_ptr;
-	uint32_t frame_mode;
-	uint32_t frame_mode_again;
-
-	struct audio_mvs_frame_info_hdr frame_info_hdr;
-	union codec_param cdc_param;
-};
-
-struct audio_mvs_buf_node {
-	struct list_head list;
-	struct q5v2_msm_audio_mvs_frame frame;
-};
-
-/* Each buffer is 20 ms, queue holds 200 ms of data. */
-#define MVS_MAX_Q_LEN 10
-
-struct audio_mvs_info_type {
-	enum audio_mvs_state_type state;
-	uint32_t frame_mode;
-	uint32_t mvs_mode;
-	uint32_t buf_free_cnt;
-	uint32_t rate_type;
-	uint32_t dtx_mode;
-	struct min_max_rate min_max_rate;
-
-	struct msm_rpc_endpoint *rpc_endpt;
-	uint32_t rpc_prog;
-	uint32_t rpc_ver;
-	uint32_t rpc_status;
-
-	uint8_t *mem_chunk;
-
-	struct list_head in_queue;
-	struct list_head free_in_queue;
-
-	struct list_head out_queue;
-	struct list_head free_out_queue;
-
-	struct task_struct *task;
-
-	wait_queue_head_t wait;
-	wait_queue_head_t mode_wait;
-	wait_queue_head_t out_wait;
-
-	struct mutex lock;
-	struct mutex in_lock;
-	struct mutex out_lock;
-
-	struct wake_lock suspend_lock;
-	struct pm_qos_request pm_qos_req;
-};
-
-static struct audio_mvs_info_type audio_mvs_info;
-
-static int audio_mvs_setup_mode(struct audio_mvs_info_type *audio)
-{
-	int rc = 0;
-
-	pr_debug("%s:\n", __func__);
-
-	switch (audio->mvs_mode) {
-	case MVS_MODE_AMR:
-	case MVS_MODE_AMR_WB: {
-		struct audio_mvs_set_amr_mode_msg set_amr_mode_msg;
-		struct audio_mvs_set_dtx_mode_msg set_dtx_mode_msg;
-
-		/* Set AMR mode. */
-		memset(&set_amr_mode_msg, 0, sizeof(set_amr_mode_msg));
-		set_amr_mode_msg.amr_mode = cpu_to_be32(audio->rate_type);
-
-		if (audio->mvs_mode == MVS_MODE_AMR) {
-			msm_rpc_setup_req(&set_amr_mode_msg.rpc_hdr,
-					  audio->rpc_prog,
-					  audio->rpc_ver,
-					  MVS_AMR_SET_AMR_MODE_PROC);
-		} else {
-			msm_rpc_setup_req(&set_amr_mode_msg.rpc_hdr,
-					  audio->rpc_prog,
-					  audio->rpc_ver,
-					  MVS_AMR_SET_AWB_MODE_PROC);
-		}
-
-		audio->rpc_status = RPC_STATUS_FAILURE;
-		rc = msm_rpc_write(audio->rpc_endpt,
-				   &set_amr_mode_msg,
-				   sizeof(set_amr_mode_msg));
-
-		if (rc >= 0) {
-			pr_debug("%s: RPC write for set amr mode done\n",
-					__func__);
-
-			/* Save the MVS configuration information. */
-			audio->frame_mode = MVS_FRAME_MODE_AMR_DL;
-
-			/* Disable DTX. */
-			memset(&set_dtx_mode_msg, 0, sizeof(set_dtx_mode_msg));
-			set_dtx_mode_msg.dtx_mode = cpu_to_be32(0);
-
-			msm_rpc_setup_req(&set_dtx_mode_msg.rpc_hdr,
-					  audio->rpc_prog,
-					  audio->rpc_ver,
-					  MVS_SET_DTX_MODE_PROC);
-
-			audio->rpc_status = RPC_STATUS_FAILURE;
-			rc = msm_rpc_write(audio->rpc_endpt,
-					   &set_dtx_mode_msg,
-					   sizeof(set_dtx_mode_msg));
-
-			if (rc >= 0) {
-				pr_debug("%s: RPC write for set dtx done\n",
-						 __func__);
-
-				rc = 0;
-			}
-		} else {
-			pr_err("%s: RPC write for set amr mode failed %d\n",
-			       __func__, rc);
-		}
-		break;
-	}
-	case MVS_MODE_PCM:
-	case MVS_MODE_LINEAR_PCM: {
-		/* PCM does not have any params to be set.
-		Save the MVS configuration information. */
-		audio->rate_type = MVS_AMR_MODE_UNDEF;
-		audio->frame_mode = MVS_FRAME_MODE_PCM_DL;
-		break;
-	}
-	case MVS_MODE_IS127:
-	case MVS_MODE_IS733:
-	case MVS_MODE_4GV_NB:
-	case MVS_MODE_4GV_WB: {
-		struct audio_mvs_set_voc_mode_msg set_voc_mode_msg;
-
-		/* Set EVRC mode. */
-		memset(&set_voc_mode_msg, 0, sizeof(set_voc_mode_msg));
-		set_voc_mode_msg.min_rate =
-				cpu_to_be32(audio->min_max_rate.min_rate);
-		set_voc_mode_msg.max_rate =
-				cpu_to_be32(audio->min_max_rate.max_rate);
-
-		msm_rpc_setup_req(&set_voc_mode_msg.rpc_hdr,
-				  audio->rpc_prog,
-				  audio->rpc_ver,
-				  MVS_VOC_SET_FRAME_RATE_PROC);
-
-		audio->rpc_status = RPC_STATUS_FAILURE;
-		rc = msm_rpc_write(audio->rpc_endpt,
-				   &set_voc_mode_msg,
-				   sizeof(set_voc_mode_msg));
-
-		if (rc >= 0) {
-			pr_debug("%s: RPC write for set voc mode done\n",
-					__func__);
-
-			/* Save the MVS configuration information. */
-			audio->frame_mode = MVS_FRAME_MODE_VOC_RX;
-
-			rc = 0;
-		} else {
-			pr_err("%s: RPC write for set voc mode failed %d\n",
-			       __func__, rc);
-		}
-		break;
-	}
-	case MVS_MODE_G711: {
-		struct audio_mvs_set_g711_mode_msg set_g711_mode_msg;
-
-		/* Set G711 mode. */
-		memset(&set_g711_mode_msg, 0, sizeof(set_g711_mode_msg));
-		set_g711_mode_msg.g711_mode = cpu_to_be32(audio->rate_type);
-
-		pr_debug("%s: mode of g711:%d\n",
-			       __func__, set_g711_mode_msg.g711_mode);
-
-		msm_rpc_setup_req(&set_g711_mode_msg.rpc_hdr,
-				 audio->rpc_prog,
-				 audio->rpc_ver,
-				 MVS_G711_SET_MODE_PROC);
-
-		audio->rpc_status = RPC_STATUS_FAILURE;
-		rc = msm_rpc_write(audio->rpc_endpt,
-				  &set_g711_mode_msg,
-				  sizeof(set_g711_mode_msg));
-
-		if (rc >= 0) {
-			pr_debug("%s: RPC write for set g711 mode done\n",
-					__func__);
-			/* Save the MVS configuration information. */
-			audio->frame_mode = MVS_FRAME_MODE_G711_DL;
-
-			rc = 0;
-		} else {
-		       pr_err("%s: RPC write for set g711 mode failed %d\n",
-			      __func__, rc);
-		}
-		break;
-	}
-	case MVS_MODE_G729A: {
-		struct audio_mvs_set_g729_mode_msg set_g729_mode_msg;
-
-		/* Set G729 mode. */
-		memset(&set_g729_mode_msg, 0, sizeof(set_g729_mode_msg));
-		set_g729_mode_msg.g729_mode = cpu_to_be32(audio->dtx_mode);
-
-		pr_debug("%s: mode of g729:%d\n",
-			       __func__, set_g729_mode_msg.g729_mode);
-
-		msm_rpc_setup_req(&set_g729_mode_msg.rpc_hdr,
-				 audio->rpc_prog,
-				 audio->rpc_ver,
-				 MVS_G729A_SET_MODE_PROC);
-
-		audio->rpc_status = RPC_STATUS_FAILURE;
-		rc = msm_rpc_write(audio->rpc_endpt,
-				  &set_g729_mode_msg,
-				  sizeof(set_g729_mode_msg));
-
-		if (rc >= 0) {
-			pr_debug("%s: RPC write for set g729 mode done\n",
-			       __func__);
-
-			/* Save the MVS configuration information. */
-			audio->frame_mode = MVS_FRAME_MODE_G729A_DL;
-
-			rc = 0;
-		} else {
-		       pr_err("%s: RPC write for set g729 mode failed %d\n",
-			      __func__, rc);
-		}
-		break;
-	}
-	case MVS_MODE_G722: {
-		struct audio_mvs_set_g722_mode_msg set_g722_mode_msg;
-
-		/* Set G722 mode. */
-		memset(&set_g722_mode_msg, 0, sizeof(set_g722_mode_msg));
-		set_g722_mode_msg.g722_mode = cpu_to_be32(audio->rate_type);
-
-		pr_debug("%s: mode of g722:%d\n",
-		      __func__, set_g722_mode_msg.g722_mode);
-
-		msm_rpc_setup_req(&set_g722_mode_msg.rpc_hdr,
-			audio->rpc_prog,
-			audio->rpc_ver,
-			MVS_G722_SET_MODE_PROC);
-
-		audio->rpc_status = RPC_STATUS_FAILURE;
-		rc = msm_rpc_write(audio->rpc_endpt,
-			 &set_g722_mode_msg,
-			 sizeof(set_g722_mode_msg));
-
-		if (rc >= 0) {
-			pr_debug("%s: RPC write for set g722 mode done\n",
-			__func__);
-
-			/* Save the MVS configuration information. */
-			audio->frame_mode = MVS_FRAME_MODE_G722_DL;
-
-			rc = 0;
-		}
-		break;
-	}
-	case MVS_MODE_G711A: {
-		struct audio_mvs_set_g711A_mode_msg set_g711A_mode_msg;
-		struct audio_mvs_set_dtx_mode_msg set_dtx_mode_msg;
-
-		/* Set G711A mode. */
-		memset(&set_g711A_mode_msg, 0, sizeof(set_g711A_mode_msg));
-		set_g711A_mode_msg.g711A_mode = cpu_to_be32(audio->rate_type);
-
-		pr_debug("%s: mode of g711A:%d\n",
-		       __func__, set_g711A_mode_msg.g711A_mode);
-
-		msm_rpc_setup_req(&set_g711A_mode_msg.rpc_hdr,
-			 audio->rpc_prog,
-			 audio->rpc_ver,
-			 MVS_G711A_SET_MODE_PROC);
-
-		audio->rpc_status = RPC_STATUS_FAILURE;
-		rc = msm_rpc_write(audio->rpc_endpt,
-			  &set_g711A_mode_msg,
-			  sizeof(set_g711A_mode_msg));
-
-		if (rc >= 0) {
-			pr_debug("%s: RPC write for set g711A mode done\n",
-				       __func__);
-
-			/* Save the MVS configuration information. */
-			audio->frame_mode = MVS_FRAME_MODE_G711A_DL;
-			/* Set DTX MODE. */
-			memset(&set_dtx_mode_msg, 0, sizeof(set_dtx_mode_msg));
-			set_dtx_mode_msg.dtx_mode =
-				cpu_to_be32((audio->dtx_mode));
-
-			msm_rpc_setup_req(&set_dtx_mode_msg.rpc_hdr,
-					  audio->rpc_prog,
-					  audio->rpc_ver,
-					  MVS_SET_DTX_MODE_PROC);
-
-			audio->rpc_status = RPC_STATUS_FAILURE;
-			rc = msm_rpc_write(audio->rpc_endpt,
-					   &set_dtx_mode_msg,
-					   sizeof(set_dtx_mode_msg));
-
-			if (rc >= 0) {
-				pr_debug("%s: RPC write for set dtx done\n",
-						 __func__);
-
-				rc = 0;
-			}
-			rc = 0;
-		} else {
-		pr_err("%s: RPC write for set g711A mode failed %d\n",
-		      __func__, rc);
-		}
-		break;
-	}
-	case MVS_MODE_EFR:
-	case MVS_MODE_FR:
-	case MVS_MODE_HR: {
-		struct audio_mvs_set_efr_mode_msg set_efr_mode_msg;
-
-		/* Set G729 mode. */
-		memset(&set_efr_mode_msg, 0, sizeof(set_efr_mode_msg));
-		set_efr_mode_msg.efr_mode = cpu_to_be32(audio->dtx_mode);
-
-		pr_debug("%s: mode of EFR, FR and HR:%d\n",
-			       __func__, set_efr_mode_msg.efr_mode);
-
-		msm_rpc_setup_req(&set_efr_mode_msg.rpc_hdr,
-				 audio->rpc_prog,
-				 audio->rpc_ver,
-				 MVS_GSM_SET_DTX_MODE_PROC);
-
-		audio->rpc_status = RPC_STATUS_FAILURE;
-		rc = msm_rpc_write(audio->rpc_endpt,
-				  &set_efr_mode_msg,
-				  sizeof(set_efr_mode_msg));
-
-		if (rc >= 0) {
-			pr_debug("%s: RPC write for set EFR, FR and HR mode done\n",
-			       __func__);
-
-			/* Save the MVS configuration information. */
-			if ((audio->mvs_mode == MVS_MODE_EFR) ||
-				(audio->mvs_mode == MVS_MODE_FR))
-				audio->frame_mode = MVS_FRAME_MODE_GSM_DL;
-			if (audio->mvs_mode == MVS_MODE_HR)
-				audio->frame_mode = MVS_FRAME_MODE_HR_DL;
-
-			rc = 0;
-		} else {
-		       pr_err("%s: RPC write for set EFR, FR and HR mode failed %d\n",
-			      __func__, rc);
-		}
-		break;
-	}
-	default:
-		rc = -EINVAL;
-		pr_err("Default case\n");
-	}
-	return rc;
-}
-
-static int audio_mvs_setup(struct audio_mvs_info_type *audio)
-{
-	int rc = 0;
-	struct audio_mvs_enable_msg enable_msg;
-
-	pr_debug("%s:\n", __func__);
-
-	/* Enable MVS. */
-	memset(&enable_msg, 0, sizeof(enable_msg));
-	enable_msg.enable_args.client_id = cpu_to_be32(MVS_CLIENT_ID_VOIP);
-	enable_msg.enable_args.mode = cpu_to_be32(audio->mvs_mode);
-	enable_msg.enable_args.ul_cb_func_id = cpu_to_be32(MVS_UL_CB_FUNC_ID);
-	enable_msg.enable_args.dl_cb_func_id = cpu_to_be32(MVS_DL_CB_FUNC_ID);
-	enable_msg.enable_args.context = cpu_to_be32(MVS_PKT_CONTEXT_ISR);
-
-	msm_rpc_setup_req(&enable_msg.rpc_hdr,
-			  audio->rpc_prog,
-			  audio->rpc_ver,
-			  MVS_ENABLE_PROC);
-
-	audio->rpc_status = RPC_STATUS_FAILURE;
-	rc = msm_rpc_write(audio->rpc_endpt, &enable_msg, sizeof(enable_msg));
-
-	if (rc >= 0) {
-		pr_debug("%s: RPC write for enable done\n", __func__);
-
-		rc = wait_event_timeout(audio->mode_wait,
-				(audio->rpc_status != RPC_STATUS_FAILURE),
-				10 * HZ);
-
-		if (rc > 0) {
-			pr_debug("%s: Wait event for enable succeeded\n",
-				 __func__);
-			rc = audio_mvs_setup_mode(audio);
-			if (rc < 0) {
-				pr_err("%s: Unknown MVS mode %d\n",
-				       __func__, audio->mvs_mode);
-			}
-			pr_err("rc value after mode setup: %d\n", rc);
-		} else {
-			pr_err("%s: Wait event for enable failed %d\n",
-			       __func__, rc);
-		}
-	} else {
-		pr_err("%s: RPC write for enable failed %d\n", __func__, rc);
-	}
-
-	return rc;
-}
-
-static int audio_mvs_start(struct audio_mvs_info_type *audio)
-{
-	int rc = 0;
-	struct audio_mvs_acquire_msg acquire_msg;
-
-	pr_info("%s:\n", __func__);
-
-	/* Prevent sleep. */
-	wake_lock(&audio->suspend_lock);
-	pm_qos_update_request(&audio->pm_qos_req,
-			      msm_cpuidle_get_deep_idle_latency());
-
-	/* Acquire MVS. */
-	memset(&acquire_msg, 0, sizeof(acquire_msg));
-	acquire_msg.acquire_args.client_id = cpu_to_be32(MVS_CLIENT_ID_VOIP);
-	acquire_msg.acquire_args.cb_func_id = cpu_to_be32(MVS_CB_FUNC_ID);
-
-	msm_rpc_setup_req(&acquire_msg.rpc_hdr,
-			  audio->rpc_prog,
-			  audio->rpc_ver,
-			  MVS_ACQUIRE_PROC);
-
-	audio->rpc_status = RPC_STATUS_FAILURE;
-	rc = msm_rpc_write(audio->rpc_endpt,
-			   &acquire_msg,
-			   sizeof(acquire_msg));
-
-	if (rc >= 0) {
-		pr_debug("%s: RPC write for acquire done\n", __func__);
-
-		rc = wait_event_timeout(audio->wait,
-			(audio->rpc_status != RPC_STATUS_FAILURE),
-			1 * HZ);
-
-		if (rc > 0) {
-
-			rc = audio_mvs_setup(audio);
-
-			if (rc == 0)
-				audio->state = AUDIO_MVS_STARTED;
-
-		} else {
-			pr_err("%s: Wait event for acquire failed %d\n",
-			       __func__, rc);
-
-			rc = -EBUSY;
-		}
-	} else {
-		pr_err("%s: RPC write for acquire failed %d\n", __func__, rc);
-
-		rc = -EBUSY;
-	}
-
-	return rc;
-}
-
-static int audio_mvs_stop(struct audio_mvs_info_type *audio)
-{
-	int rc = 0;
-	struct audio_mvs_release_msg release_msg;
-
-	pr_info("%s:\n", __func__);
-
-	/* Release MVS. */
-	memset(&release_msg, 0, sizeof(release_msg));
-	release_msg.client_id = cpu_to_be32(MVS_CLIENT_ID_VOIP);
-
-	msm_rpc_setup_req(&release_msg.rpc_hdr,
-			  audio->rpc_prog,
-			  audio->rpc_ver,
-			  MVS_RELEASE_PROC);
-
-	audio->rpc_status = RPC_STATUS_FAILURE;
-	rc = msm_rpc_write(audio->rpc_endpt, &release_msg, sizeof(release_msg));
-
-	if (rc >= 0) {
-		pr_debug("%s: RPC write for release done\n", __func__);
-
-		rc = wait_event_timeout(audio->mode_wait,
-				(audio->rpc_status != RPC_STATUS_FAILURE),
-				1 * HZ);
-
-		if (rc > 0) {
-			pr_debug("%s: Wait event for release succeeded\n",
-				 __func__);
-
-			audio->state = AUDIO_MVS_STOPPED;
-
-			/* Un-block read in case it is waiting for data. */
-			wake_up(&audio->out_wait);
-			rc = 0;
-		} else {
-			pr_err("%s: Wait event for release failed %d\n",
-			       __func__, rc);
-		}
-	} else {
-		pr_err("%s: RPC write for release failed %d\n", __func__, rc);
-	}
-
-	/* Allow sleep. */
-	pm_qos_update_request(&audio->pm_qos_req, PM_QOS_DEFAULT_VALUE);
-	wake_unlock(&audio->suspend_lock);
-
-	return rc;
-}
-
-static void audio_mvs_process_rpc_request(uint32_t procedure,
-					  uint32_t xid,
-					  void *data,
-					  uint32_t length,
-					  struct audio_mvs_info_type *audio)
-{
-	int rc = 0;
-
-	pr_debug("%s:\n", __func__);
-
-	switch (procedure) {
-	case MVS_EVENT_CB_TYPE_PROC: {
-		struct audio_mvs_cb_func_args *args = data;
-		struct rpc_reply_hdr reply_hdr;
-
-		pr_debug("%s: MVS CB CB_FUNC_ID 0x%x\n",
-			 __func__, be32_to_cpu(args->cb_func_id));
-
-		if (be32_to_cpu(args->valid_ptr)) {
-			uint32_t event_type = be32_to_cpu(args->event);
-
-			pr_debug("%s: MVS CB event type %d\n",
-				 __func__, be32_to_cpu(args->event));
-
-			if (event_type == AUDIO_MVS_COMMAND) {
-				uint32_t cmd_status = be32_to_cpu(
-			args->event_data.mvs_ev_command_type.cmd_status);
-
-				pr_debug("%s: MVS CB command status %d\n",
-					 __func__, cmd_status);
-
-				if (cmd_status == AUDIO_MVS_CMD_SUCCESS) {
-					audio->rpc_status = RPC_STATUS_SUCCESS;
-					wake_up(&audio->wait);
-				}
-
-			} else if (event_type == AUDIO_MVS_MODE) {
-				uint32_t mode_status = be32_to_cpu(
-				args->event_data.mvs_ev_mode_type.mode_status);
-
-				pr_debug("%s: MVS CB mode status %d\n",
-					 __func__, mode_status);
-
-				if (mode_status == AUDIO_MVS_MODE_READY) {
-					audio->rpc_status = RPC_STATUS_SUCCESS;
-					wake_up(&audio->mode_wait);
-				}
-			} else {
-				pr_err("%s: MVS CB unknown event type %d\n",
-				       __func__, event_type);
-			}
-		} else {
-			pr_err("%s: MVS CB event pointer not valid\n",
-			       __func__);
-		}
-
-		/* Send ack to modem. */
-		memset(&reply_hdr, 0, sizeof(reply_hdr));
-		reply_hdr.xid = cpu_to_be32(xid);
-		reply_hdr.type = cpu_to_be32(RPC_TYPE_REPLY);
-		reply_hdr.reply_stat = cpu_to_be32(RPCMSG_REPLYSTAT_ACCEPTED);
-
-		reply_hdr.data.acc_hdr.accept_stat = cpu_to_be32(
-			RPC_ACCEPTSTAT_SUCCESS);
-		reply_hdr.data.acc_hdr.verf_flavor = 0;
-		reply_hdr.data.acc_hdr.verf_length = 0;
-
-		rc = msm_rpc_write(audio->rpc_endpt,
-				   &reply_hdr,
-				   sizeof(reply_hdr));
-
-		if (rc < 0)
-			pr_err("%s: RPC write for response failed %d\n",
-			       __func__, rc);
-
-		break;
-	}
-
-	case MVS_PACKET_UL_FN_TYPE_PROC: {
-		uint32_t *args = data;
-		uint32_t pkt_len;
-		uint32_t frame_mode;
-		struct audio_mvs_ul_reply ul_reply;
-		struct audio_mvs_buf_node *buf_node = NULL;
-
-		pr_debug("%s: MVS UL CB_FUNC_ID 0x%x\n",
-			 __func__, be32_to_cpu(*args));
-		args++;
-
-		pkt_len = be32_to_cpu(*args);
-		pr_debug("%s: UL pkt_len %d\n", __func__, pkt_len);
-		args++;
-
-		/* Copy the vocoder packets. */
-		mutex_lock(&audio->out_lock);
-
-		if (!list_empty(&audio->free_out_queue)) {
-			buf_node = list_first_entry(&audio->free_out_queue,
-						    struct audio_mvs_buf_node,
-						    list);
-			list_del(&buf_node->list);
-
-			memcpy(&buf_node->frame.voc_pkt[0], args, pkt_len);
-			buf_node->frame.len = pkt_len;
-			pkt_len = ALIGN(pkt_len, 4);
-			args = args + pkt_len/4;
-
-			pr_debug("%s: UL valid_ptr 0x%x\n",
-				 __func__, be32_to_cpu(*args));
-			args++;
-
-			frame_mode = be32_to_cpu(*args);
-			pr_debug("%s: UL frame_mode %d\n",
-				 __func__, frame_mode);
-			args++;
-
-			pr_debug("%s: UL frame_mode %d\n",
-				 __func__, be32_to_cpu(*args));
-			args++;
-
-			pr_debug("%s: UL frame_mode %d\n",
-				 __func__, be32_to_cpu(*args));
-			args++;
-
-			pr_debug("%s: UL mvs_mode %d\n",
-				 __func__, be32_to_cpu(*args));
-			args++;
-
-			pr_debug("%s: UL buf_free_cnt %d\n",
-				 __func__, be32_to_cpu(*args));
-			args++;
-
-			if (frame_mode == MVS_FRAME_MODE_AMR_UL) {
-				/* Extract AMR frame type. */
-				buf_node->frame.frame_type = be32_to_cpu(*args);
-
-				pr_debug("%s: UL AMR frame_type %d\n",
-					 __func__, be32_to_cpu(*args));
-			} else if (frame_mode == MVS_FRAME_MODE_PCM_UL) {
-				/* PCM don't have frame_type */
-				buf_node->frame.frame_type = 0;
-			} else if (frame_mode == MVS_FRAME_MODE_VOC_TX) {
-				/* Extracting EVRC current buffer frame rate*/
-				buf_node->frame.frame_type = be32_to_cpu(*args);
-
-				pr_debug("%s: UL EVRC frame_type %d\n",
-					__func__, be32_to_cpu(*args));
-			} else if (frame_mode == MVS_FRAME_MODE_G711_UL) {
-				/* Extract G711 frame type. */
-				buf_node->frame.frame_type = be32_to_cpu(*args);
-
-				pr_debug("%s: UL G711 frame_type %d\n",
-					__func__, be32_to_cpu(*args));
-			} else if (frame_mode == MVS_FRAME_MODE_G729A_UL) {
-				/* Extract G729 frame type. */
-				buf_node->frame.frame_type = be32_to_cpu(*args);
-
-				pr_debug("%s: UL G729 frame_type %d\n",
-					__func__, be32_to_cpu(*args));
-			} else if (frame_mode == MVS_FRAME_MODE_G722_UL) {
-				/* Extract G722 frame type. */
-				buf_node->frame.frame_type = be32_to_cpu(*args);
-
-				pr_debug("%s: UL G722 frame_type %d\n",
-				       __func__, be32_to_cpu(*args));
-			} else if (frame_mode == MVS_FRAME_MODE_G711A_UL) {
-				/* Extract G711A frame type. */
-				buf_node->frame.frame_type = be32_to_cpu(*args);
-
-				pr_debug("%s: UL G711A frame_type %d\n",
-				       __func__, be32_to_cpu(*args));
-			} else if ((frame_mode == MVS_FRAME_MODE_GSM_UL) ||
-				   (frame_mode == MVS_FRAME_MODE_HR_UL)) {
-				/* Extract EFR, FR and HR frame type. */
-				buf_node->frame.frame_type = be32_to_cpu(*args);
-
-				pr_debug("%s: UL EFR,FR,HR frame_type %d\n",
-					__func__, be32_to_cpu(*args));
-			} else {
-				pr_debug("%s: UL Unknown frame mode %d\n",
-				       __func__, frame_mode);
-			}
-
-			list_add_tail(&buf_node->list, &audio->out_queue);
-		} else {
-			pr_err("%s: UL data dropped, read is slow\n", __func__);
-		}
-
-		mutex_unlock(&audio->out_lock);
-
-		wake_up(&audio->out_wait);
-
-		/* Send UL message accept to modem. */
-		memset(&ul_reply, 0, sizeof(ul_reply));
-		ul_reply.reply_hdr.xid = cpu_to_be32(xid);
-		ul_reply.reply_hdr.type = cpu_to_be32(RPC_TYPE_REPLY);
-		ul_reply.reply_hdr.reply_stat = cpu_to_be32(
-			RPCMSG_REPLYSTAT_ACCEPTED);
-
-		ul_reply.reply_hdr.data.acc_hdr.accept_stat = cpu_to_be32(
-			RPC_ACCEPTSTAT_SUCCESS);
-		ul_reply.reply_hdr.data.acc_hdr.verf_flavor = 0;
-		ul_reply.reply_hdr.data.acc_hdr.verf_length = 0;
-
-		ul_reply.valid_pkt_status_ptr = cpu_to_be32(0x00000001);
-		ul_reply.pkt_status = cpu_to_be32(0x00000000);
-
-		rc = msm_rpc_write(audio->rpc_endpt,
-				   &ul_reply,
-				   sizeof(ul_reply));
-
-		if (rc < 0)
-			pr_err("%s: RPC write for UL response failed %d\n",
-			       __func__, rc);
-
-		break;
-	}
-
-	case MVS_PACKET_DL_FN_TYPE_PROC: {
-		struct audio_mvs_dl_cb_func_args *args = data;
-		struct audio_mvs_dl_reply dl_reply;
-		uint32_t frame_mode;
-		struct audio_mvs_buf_node *buf_node = NULL;
-
-		pr_debug("%s: MVS DL CB CB_FUNC_ID 0x%x\n",
-			 __func__, be32_to_cpu(args->cb_func_id));
-
-		frame_mode = be32_to_cpu(args->frame_mode);
-		pr_debug("%s: DL frame_mode %d\n", __func__, frame_mode);
-
-		/* Prepare and send the DL packets to modem. */
-		memset(&dl_reply, 0, sizeof(dl_reply));
-		dl_reply.reply_hdr.xid = cpu_to_be32(xid);
-		dl_reply.reply_hdr.type = cpu_to_be32(RPC_TYPE_REPLY);
-		dl_reply.reply_hdr.reply_stat = cpu_to_be32(
-			RPCMSG_REPLYSTAT_ACCEPTED);
-
-		dl_reply.reply_hdr.data.acc_hdr.accept_stat = cpu_to_be32(
-			RPC_ACCEPTSTAT_SUCCESS);
-		dl_reply.reply_hdr.data.acc_hdr.verf_flavor = 0;
-		dl_reply.reply_hdr.data.acc_hdr.verf_length = 0;
-
-		mutex_lock(&audio->in_lock);
-
-		if (!list_empty(&audio->in_queue)) {
-			buf_node = list_first_entry(&audio->in_queue,
-						    struct audio_mvs_buf_node,
-						    list);
-			list_del(&buf_node->list);
-
-			memcpy(&dl_reply.voc_pkt,
-			       &buf_node->frame.voc_pkt[0],
-			       buf_node->frame.len);
-
-			pr_debug("%s:frame mode %d\n", __func__, frame_mode);
-			if (frame_mode == MVS_FRAME_MODE_AMR_DL) {
-				dl_reply.cdc_param.gnr_arg.param1 = cpu_to_be32(
-					buf_node->frame.frame_type);
-				dl_reply.cdc_param.gnr_arg.param2 =
-						cpu_to_be32(audio->rate_type);
-				dl_reply.cdc_param.\
-						gnr_arg.valid_pkt_status_ptr =
-							cpu_to_be32(0x00000001);
-				dl_reply.cdc_param.gnr_arg.pkt_status =
-					cpu_to_be32(AUDIO_MVS_PKT_NORMAL);
-			} else if (frame_mode == MVS_FRAME_MODE_PCM_DL) {
-				dl_reply.cdc_param.gnr_arg.param1 = 0;
-				dl_reply.cdc_param.gnr_arg.param2 = 0;
-				dl_reply.cdc_param.\
-						gnr_arg.valid_pkt_status_ptr =
-							cpu_to_be32(0x00000001);
-				dl_reply.cdc_param.gnr_arg.pkt_status =
-					cpu_to_be32(AUDIO_MVS_PKT_NORMAL);
-			} else if (frame_mode == MVS_FRAME_MODE_VOC_RX) {
-				dl_reply.cdc_param.gnr_arg.param1 =
-				cpu_to_be32(buf_node->frame.frame_type);
-				dl_reply.cdc_param.gnr_arg.param2 = 0;
-				dl_reply.cdc_param.\
-						gnr_arg.valid_pkt_status_ptr =
-							cpu_to_be32(0x00000001);
-				dl_reply.cdc_param.gnr_arg.pkt_status =
-					cpu_to_be32(AUDIO_MVS_PKT_NORMAL);
-			} else if (frame_mode == MVS_FRAME_MODE_G711_DL) {
-				dl_reply.cdc_param.g711_arg.param1 =
-				cpu_to_be32(buf_node->frame.frame_type);
-				dl_reply.cdc_param.\
-						g711_arg.valid_pkt_status_ptr =
-							cpu_to_be32(0x00000001);
-				dl_reply.cdc_param.g711_arg.pkt_status =
-					cpu_to_be32(AUDIO_MVS_PKT_NORMAL);
-			} else if (frame_mode == MVS_FRAME_MODE_G729A_DL) {
-				dl_reply.cdc_param.gnr_arg.param1 = cpu_to_be32(
-				       buf_node->frame.frame_type);
-				dl_reply.cdc_param.gnr_arg.param2 =
-						cpu_to_be32(audio->rate_type);
-				dl_reply.cdc_param.\
-						gnr_arg.valid_pkt_status_ptr =
-							cpu_to_be32(0x00000001);
-				dl_reply.cdc_param.gnr_arg.pkt_status =
-					cpu_to_be32(AUDIO_MVS_PKT_NORMAL);
-			} else if (frame_mode == MVS_FRAME_MODE_G722_DL) {
-				dl_reply.cdc_param.gnr_arg.param1 = cpu_to_be32(
-				      buf_node->frame.frame_type);
-				dl_reply.cdc_param.gnr_arg.param2 =
-						cpu_to_be32(audio->rate_type);
-				dl_reply.cdc_param.\
-						gnr_arg.valid_pkt_status_ptr =
-							cpu_to_be32(0x00000001);
-				dl_reply.cdc_param.gnr_arg.pkt_status =
-					cpu_to_be32(AUDIO_MVS_PKT_NORMAL);
-			} else if (frame_mode == MVS_FRAME_MODE_G711A_DL) {
-				dl_reply.cdc_param.gnr_arg.param1 = cpu_to_be32(
-				       buf_node->frame.frame_type);
-				dl_reply.cdc_param.gnr_arg.param2 =
-						cpu_to_be32(audio->rate_type);
-				dl_reply.cdc_param.\
-						gnr_arg.valid_pkt_status_ptr =
-							cpu_to_be32(0x00000001);
-				dl_reply.cdc_param.gnr_arg.pkt_status =
-					cpu_to_be32(AUDIO_MVS_PKT_NORMAL);
-			} else if ((frame_mode == MVS_FRAME_MODE_GSM_DL) ||
-				   (frame_mode == MVS_FRAME_MODE_HR_DL)) {
-				dl_reply.cdc_param.gnr_arg.param1 = cpu_to_be32(
-				       buf_node->frame.frame_type);
-				dl_reply.cdc_param.gnr_arg.param2 =
-						cpu_to_be32(audio->rate_type);
-				dl_reply.cdc_param.\
-						gnr_arg.valid_pkt_status_ptr =
-							cpu_to_be32(0x00000001);
-				dl_reply.cdc_param.gnr_arg.pkt_status =
-					cpu_to_be32(AUDIO_MVS_PKT_NORMAL);
-			} else {
-				pr_err("%s: DL Unknown frame mode %d\n",
-				       __func__, frame_mode);
-			}
-			list_add_tail(&buf_node->list, &audio->free_in_queue);
-		} else {
-			pr_debug("%s: No DL data available to send to MVS\n",
-				 __func__);
-			if (frame_mode == MVS_FRAME_MODE_G711_DL) {
-				dl_reply.cdc_param.\
-						g711_arg.valid_pkt_status_ptr =
-							cpu_to_be32(0x00000001);
-				dl_reply.cdc_param.g711_arg.pkt_status =
-						cpu_to_be32(AUDIO_MVS_PKT_SLOW);
-			} else {
-				dl_reply.cdc_param.\
-						gnr_arg.valid_pkt_status_ptr =
-							cpu_to_be32(0x00000001);
-				dl_reply.cdc_param.gnr_arg.pkt_status =
-						cpu_to_be32(AUDIO_MVS_PKT_SLOW);
-			}
-		}
-
-		mutex_unlock(&audio->in_lock);
-
-		dl_reply.valid_frame_info_ptr = cpu_to_be32(0x00000001);
-
-		dl_reply.frame_mode = cpu_to_be32(audio->frame_mode);
-		dl_reply.frame_mode_again = cpu_to_be32(audio->frame_mode);
-
-		dl_reply.frame_info_hdr.frame_mode =
-			cpu_to_be32(audio->frame_mode);
-		dl_reply.frame_info_hdr.mvs_mode = cpu_to_be32(audio->mvs_mode);
-		dl_reply.frame_info_hdr.buf_free_cnt = 0;
-
-		rc = msm_rpc_write(audio->rpc_endpt,
-				   &dl_reply,
-				   sizeof(dl_reply));
-
-		if (rc < 0)
-			pr_err("%s: RPC write for DL response failed %d\n",
-			       __func__, rc);
-
-		break;
-	}
-
-	default:
-		pr_err("%s: Unknown CB type %d\n", __func__, procedure);
-	}
-}
-
-static int audio_mvs_thread(void *data)
-{
-	struct audio_mvs_info_type *audio = data;
-	struct rpc_request_hdr *rpc_hdr = NULL;
-
-	pr_info("%s:\n", __func__);
-
-	while (!kthread_should_stop()) {
-
-		int rpc_hdr_len = msm_rpc_read(audio->rpc_endpt,
-					       (void **) &rpc_hdr,
-					       -1,
-					       -1);
-
-		if (rpc_hdr_len < 0) {
-			pr_err("%s: RPC read failed %d\n",
-			       __func__, rpc_hdr_len);
-
-			break;
-		} else if (rpc_hdr_len < RPC_COMMON_HDR_SZ) {
-			continue;
-		} else {
-			uint32_t rpc_type = be32_to_cpu(rpc_hdr->type);
-			if (rpc_type == RPC_TYPE_REPLY) {
-				struct rpc_reply_hdr *rpc_reply =
-					(void *) rpc_hdr;
-				uint32_t reply_status;
-
-				if (rpc_hdr_len < RPC_REPLY_HDR_SZ)
-					continue;
-
-				reply_status =
-					be32_to_cpu(rpc_reply->reply_stat);
-
-				if (reply_status != RPCMSG_REPLYSTAT_ACCEPTED) {
-					/* If the command is not accepted, there
-					 * will be no response callback. Wake
-					 * the caller and report error. */
-					audio->rpc_status = RPC_STATUS_REJECT;
-
-					wake_up(&audio->wait);
-
-					pr_err("%s: RPC reply status denied\n",
-					       __func__);
-				}
-			} else if (rpc_type == RPC_TYPE_REQUEST) {
-				if (rpc_hdr_len < RPC_REQUEST_HDR_SZ)
-					continue;
-
-				audio_mvs_process_rpc_request(
-					be32_to_cpu(rpc_hdr->procedure),
-					be32_to_cpu(rpc_hdr->xid),
-					(void *) (rpc_hdr + 1),
-					(rpc_hdr_len - sizeof(*rpc_hdr)),
-					audio);
-			} else {
-				pr_err("%s: Unexpected RPC type %d\n",
-				       __func__, rpc_type);
-			}
-		}
-
-		kfree(rpc_hdr);
-		rpc_hdr = NULL;
-	}
-
-	pr_info("%s: MVS thread stopped\n", __func__);
-
-	return 0;
-}
-
-static int audio_mvs_alloc_buf(struct audio_mvs_info_type *audio)
-{
-	int i = 0;
-	struct audio_mvs_buf_node *buf_node = NULL;
-	struct list_head *ptr = NULL;
-	struct list_head *next = NULL;
-
-	pr_debug("%s:\n", __func__);
-
-	/* Allocate input buffers. */
-	for (i = 0; i < MVS_MAX_Q_LEN; i++) {
-			buf_node = kmalloc(sizeof(struct audio_mvs_buf_node),
-					   GFP_KERNEL);
-
-			if (buf_node != NULL) {
-				list_add_tail(&buf_node->list,
-					      &audio->free_in_queue);
-			} else {
-				pr_err("%s: No memory for IO buffers\n",
-				       __func__);
-				goto err;
-			}
-			buf_node = NULL;
-	}
-
-	/* Allocate output buffers. */
-	for (i = 0; i < MVS_MAX_Q_LEN; i++) {
-			buf_node = kmalloc(sizeof(struct audio_mvs_buf_node),
-					   GFP_KERNEL);
-
-			if (buf_node != NULL) {
-				list_add_tail(&buf_node->list,
-					      &audio->free_out_queue);
-			} else {
-				pr_err("%s: No memory for IO buffers\n",
-				       __func__);
-				goto err;
-			}
-			buf_node = NULL;
-	}
-
-	return 0;
-
-err:
-	list_for_each_safe(ptr, next, &audio->free_in_queue) {
-		buf_node = list_entry(ptr, struct audio_mvs_buf_node, list);
-		list_del(&buf_node->list);
-		kfree(buf_node);
-		buf_node = NULL;
-	}
-
-	ptr = next = NULL;
-	list_for_each_safe(ptr, next, &audio->free_out_queue) {
-		buf_node = list_entry(ptr, struct audio_mvs_buf_node, list);
-		list_del(&buf_node->list);
-		kfree(buf_node);
-		buf_node = NULL;
-	}
-
-	return -ENOMEM;
-}
-
-static void audio_mvs_free_buf(struct audio_mvs_info_type *audio)
-{
-	struct list_head *ptr = NULL;
-	struct list_head *next = NULL;
-	struct audio_mvs_buf_node *buf_node = NULL;
-
-	pr_debug("%s:\n", __func__);
-
-	mutex_lock(&audio->in_lock);
-	/* Free input buffers. */
-	list_for_each_safe(ptr, next, &audio->in_queue) {
-		buf_node = list_entry(ptr, struct audio_mvs_buf_node, list);
-		list_del(&buf_node->list);
-		kfree(buf_node);
-		buf_node = NULL;
-	}
-
-	ptr = next = NULL;
-	/* Free free_input buffers. */
-	list_for_each_safe(ptr, next, &audio->free_in_queue) {
-		buf_node = list_entry(ptr, struct audio_mvs_buf_node, list);
-		list_del(&buf_node->list);
-		kfree(buf_node);
-		buf_node = NULL;
-	}
-	mutex_unlock(&audio->in_lock);
-
-	mutex_lock(&audio->out_lock);
-	ptr = next = NULL;
-	/* Free output buffers. */
-	list_for_each_safe(ptr, next, &audio->out_queue) {
-		buf_node = list_entry(ptr, struct audio_mvs_buf_node, list);
-		list_del(&buf_node->list);
-		kfree(buf_node);
-		buf_node = NULL;
-	}
-
-	/* Free free_ioutput buffers. */
-	ptr = next = NULL;
-	list_for_each_safe(ptr, next, &audio->free_out_queue) {
-		buf_node = list_entry(ptr, struct audio_mvs_buf_node, list);
-		list_del(&buf_node->list);
-		kfree(buf_node);
-		buf_node = NULL;
-	}
-	mutex_unlock(&audio->out_lock);
-}
-
-static int audio_mvs_open(struct inode *inode, struct file *file)
-{
-	int rc = 0;
-
-	pr_info("%s:\n", __func__);
-
-	mutex_lock(&audio_mvs_info.lock);
-
-	if (audio_mvs_info.state == AUDIO_MVS_CLOSED) {
-
-		if (audio_mvs_info.task != NULL ||
-			audio_mvs_info.rpc_endpt != NULL) {
-			rc = audio_mvs_alloc_buf(&audio_mvs_info);
-
-			if (rc == 0) {
-				audio_mvs_info.state = AUDIO_MVS_OPENED;
-				file->private_data = &audio_mvs_info;
-			}
-		}  else {
-			pr_err("%s: MVS thread and RPC end point do not exist\n",
-				   __func__);
-
-			rc = -ENODEV;
-		}
-	} else {
-		pr_err("%s: MVS driver exists, state %d\n",
-		       __func__, audio_mvs_info.state);
-
-		rc = -EBUSY;
-	}
-
-	mutex_unlock(&audio_mvs_info.lock);
-
-	return rc;
-}
-
-static int audio_mvs_release(struct inode *inode, struct file *file)
-{
-
-	struct audio_mvs_info_type *audio = file->private_data;
-
-	pr_info("%s:\n", __func__);
-
-	mutex_lock(&audio->lock);
-	if (audio->state == AUDIO_MVS_STARTED)
-		audio_mvs_stop(audio);
-	audio_mvs_free_buf(audio);
-	audio->state = AUDIO_MVS_CLOSED;
-	mutex_unlock(&audio->lock);
-
-	pr_debug("%s: Release done\n", __func__);
-	return 0;
-}
-
-static ssize_t audio_mvs_read(struct file *file,
-			      char __user *buf,
-			      size_t count,
-			      loff_t *pos)
-{
-	int rc = 0;
-	struct audio_mvs_buf_node *buf_node = NULL;
-	struct audio_mvs_info_type *audio = file->private_data;
-
-	pr_debug("%s:\n", __func__);
-
-	rc = wait_event_interruptible_timeout(audio->out_wait,
-			(!list_empty(&audio->out_queue) ||
-			 audio->state == AUDIO_MVS_STOPPED),
-			1 * HZ);
-
-	if (rc > 0) {
-		mutex_lock(&audio->out_lock);
-		if ((audio->state == AUDIO_MVS_STARTED) &&
-		    (!list_empty(&audio->out_queue))) {
-
-			if (count >= sizeof(struct q5v2_msm_audio_mvs_frame)) {
-				buf_node = list_first_entry(&audio->out_queue,
-						struct audio_mvs_buf_node,
-						list);
-				list_del(&buf_node->list);
-
-				rc = copy_to_user(buf,
-					&buf_node->frame,
-					sizeof(struct q5v2_msm_audio_mvs_frame)
-					);
-
-				if (rc == 0) {
-					rc = buf_node->frame.len +
-					    sizeof(buf_node->frame.frame_type) +
-					    sizeof(buf_node->frame.len);
-				} else {
-					pr_err("%s: Copy to user retuned %d",
-					       __func__, rc);
-
-					rc = -EFAULT;
-				}
-
-				list_add_tail(&buf_node->list,
-					      &audio->free_out_queue);
-			} else {
-				pr_err("%s: Read count %d < sizeof(frame) %d",
-				       __func__, count,
-				       sizeof(struct q5v2_msm_audio_mvs_frame));
-
-				rc = -ENOMEM;
-			}
-		} else {
-			pr_err("%s: Read performed in state %d\n",
-			       __func__, audio->state);
-
-			rc = -EPERM;
-		}
-		mutex_unlock(&audio->out_lock);
-
-	} else if (rc == 0) {
-		pr_err("%s: No UL data available\n", __func__);
-
-		rc = -ETIMEDOUT;
-	} else {
-		pr_err("%s: Read was interrupted\n", __func__);
-
-		rc = -ERESTARTSYS;
-	}
-
-	return rc;
-}
-
-static ssize_t audio_mvs_write(struct file *file,
-			       const char __user *buf,
-			       size_t count,
-			       loff_t *pos)
-{
-	int rc = 0;
-	struct audio_mvs_buf_node *buf_node = NULL;
-	struct audio_mvs_info_type *audio = file->private_data;
-
-	pr_debug("%s:\n", __func__);
-
-	mutex_lock(&audio->in_lock);
-	if (audio->state == AUDIO_MVS_STARTED) {
-		if (count <= sizeof(struct q5v2_msm_audio_mvs_frame)) {
-			if (!list_empty(&audio->free_in_queue)) {
-				buf_node =
-					list_first_entry(&audio->free_in_queue,
-						struct audio_mvs_buf_node,
-						list);
-				list_del(&buf_node->list);
-
-				rc = copy_from_user(&buf_node->frame,
-						    buf,
-						    count);
-
-				list_add_tail(&buf_node->list,
-					      &audio->in_queue);
-			} else {
-				pr_err("%s: No free DL buffs\n", __func__);
-			}
-		} else {
-			pr_err("%s: Write count %d < sizeof(frame) %d",
-			       __func__, count,
-			       sizeof(struct q5v2_msm_audio_mvs_frame));
-
-			rc = -ENOMEM;
-		}
-	} else {
-		pr_err("%s: Write performed in invalid state %d\n",
-		       __func__, audio->state);
-
-		rc = -EPERM;
-	}
-	mutex_unlock(&audio->in_lock);
-
-	return rc;
-}
-
-static long audio_mvs_ioctl(struct file *file,
-			    unsigned int cmd,
-			    unsigned long arg)
-{
-	int rc = 0;
-
-	struct audio_mvs_info_type *audio = file->private_data;
-
-	pr_info("%s:\n", __func__);
-
-	switch (cmd) {
-	case AUDIO_GET_MVS_CONFIG: {
-		struct msm_audio_mvs_config config;
-
-		pr_debug("%s: IOCTL GET_MVS_CONFIG\n", __func__);
-
-		mutex_lock(&audio->lock);
-		config.mvs_mode = audio->mvs_mode;
-		config.rate_type = audio->rate_type;
-		config.min_max_rate.min_rate = audio->min_max_rate.min_rate;
-		config.min_max_rate.max_rate = audio->min_max_rate.max_rate;
-		mutex_unlock(&audio->lock);
-
-		rc = copy_to_user((void *)arg, &config, sizeof(config));
-		if (rc == 0)
-			rc = sizeof(config);
-		else
-			pr_err("%s: Config copy failed %d\n", __func__, rc);
-
-		break;
-	}
-
-	case AUDIO_SET_MVS_CONFIG: {
-		struct msm_audio_mvs_config config;
-
-		pr_debug("%s: IOCTL SET_MVS_CONFIG\n", __func__);
-
-		rc = copy_from_user(&config, (void *)arg, sizeof(config));
-		if (rc == 0) {
-			mutex_lock(&audio->lock);
-
-			if (audio->state == AUDIO_MVS_OPENED) {
-				audio->mvs_mode = config.mvs_mode;
-				audio->rate_type = config.rate_type;
-				audio->dtx_mode = config.dtx_mode;
-				audio->min_max_rate.min_rate =
-						config.min_max_rate.min_rate;
-				audio->min_max_rate.max_rate =
-						config.min_max_rate.max_rate;
-			} else {
-				pr_err("%s: Set confg called in state %d\n",
-				       __func__, audio->state);
-
-				rc = -EPERM;
-			}
-
-			mutex_unlock(&audio->lock);
-		} else {
-			pr_err("%s: Config copy failed %d\n", __func__, rc);
-		}
-
-		break;
-	}
-
-	case AUDIO_START: {
-		pr_debug("%s: IOCTL START\n", __func__);
-
-		mutex_lock(&audio->lock);
-
-		if (audio->state == AUDIO_MVS_OPENED ||
-		    audio->state == AUDIO_MVS_STOPPED) {
-			rc = audio_mvs_start(audio);
-
-			if (rc != 0)
-				audio_mvs_stop(audio);
-		} else {
-			pr_err("%s: Start called in invalid state %d\n",
-			       __func__, audio->state);
-
-			rc = -EPERM;
-		}
-
-		mutex_unlock(&audio->lock);
-
-		break;
-	}
-
-	case AUDIO_STOP: {
-		pr_debug("%s: IOCTL STOP\n", __func__);
-
-		mutex_lock(&audio->lock);
-
-		if (audio->state == AUDIO_MVS_STARTED) {
-			rc = audio_mvs_stop(audio);
-		} else {
-			pr_err("%s: Stop called in invalid state %d\n",
-			       __func__, audio->state);
-
-			rc = -EPERM;
-		}
-
-		mutex_unlock(&audio->lock);
-		break;
-	}
-
-	default: {
-		pr_err("%s: Unknown IOCTL %d\n", __func__, cmd);
-	}
-	}
-
-	return rc;
-}
-
-static const struct file_operations audio_mvs_fops = {
-	.owner = THIS_MODULE,
-	.open = audio_mvs_open,
-	.release = audio_mvs_release,
-	.read = audio_mvs_read,
-	.write = audio_mvs_write,
-	.unlocked_ioctl = audio_mvs_ioctl
-};
-
-struct miscdevice audio_mvs_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_mvs",
-	.fops = &audio_mvs_fops
-};
-
-static int __init audio_mvs_init(void)
-{
-	int rc;
-
-	pr_info("%s:\n", __func__);
-
-	memset(&audio_mvs_info, 0, sizeof(audio_mvs_info));
-	mutex_init(&audio_mvs_info.lock);
-	mutex_init(&audio_mvs_info.in_lock);
-	mutex_init(&audio_mvs_info.out_lock);
-
-	init_waitqueue_head(&audio_mvs_info.wait);
-	init_waitqueue_head(&audio_mvs_info.mode_wait);
-	init_waitqueue_head(&audio_mvs_info.out_wait);
-
-	INIT_LIST_HEAD(&audio_mvs_info.in_queue);
-	INIT_LIST_HEAD(&audio_mvs_info.free_in_queue);
-	INIT_LIST_HEAD(&audio_mvs_info.out_queue);
-	INIT_LIST_HEAD(&audio_mvs_info.free_out_queue);
-
-	wake_lock_init(&audio_mvs_info.suspend_lock,
-		       WAKE_LOCK_SUSPEND,
-		       "audio_mvs_suspend");
-	pm_qos_add_request(&audio_mvs_info.pm_qos_req, PM_QOS_CPU_DMA_LATENCY,
-				PM_QOS_DEFAULT_VALUE);
-
-	audio_mvs_info.rpc_endpt = msm_rpc_connect_compatible(MVS_PROG,
-					MVS_VERS_COMP_VER5,
-					MSM_RPC_UNINTERRUPTIBLE);
-
-	if (IS_ERR(audio_mvs_info.rpc_endpt)) {
-		pr_err("%s: MVS RPC connect failed ver 0x%x\n", __func__,
-				MVS_VERS_COMP_VER5);
-		audio_mvs_info.rpc_endpt = msm_rpc_connect_compatible(MVS_PROG,
-					MVS_VERS_COMP_VER4,
-					MSM_RPC_UNINTERRUPTIBLE);
-		if (IS_ERR(audio_mvs_info.rpc_endpt)) {
-			pr_err("%s: MVS RPC connect failed ver 0x%x\n",
-				__func__, MVS_VERS_COMP_VER4);
-			audio_mvs_info.rpc_endpt =
-				msm_rpc_connect_compatible(MVS_PROG,
-				MVS_VERS,
-				MSM_RPC_UNINTERRUPTIBLE);
-			if (IS_ERR(audio_mvs_info.rpc_endpt)) {
-				pr_err("%s: MVS RPC connect failed ver 0x%x\n",
-				   __func__, MVS_VERS);
-				rc = PTR_ERR(audio_mvs_info.rpc_endpt);
-				audio_mvs_info.rpc_endpt = NULL;
-				goto done;
-			} else {
-				pr_debug("%s: MVS RPC connect succeeded ver\
-					0x%x\n", __func__, MVS_VERS);
-				audio_mvs_info.rpc_prog = MVS_PROG;
-				audio_mvs_info.rpc_ver = MVS_VERS;
-			}
-		} else {
-			pr_debug("%s: MVS RPC connect succeeded ver 0x%x\n",
-				__func__, MVS_VERS_COMP_VER4);
-			audio_mvs_info.rpc_prog = MVS_PROG;
-			audio_mvs_info.rpc_ver = MVS_VERS_COMP_VER4;
-		}
-	} else {
-		pr_debug("%s: MVS RPC connect succeeded ver 0x%x\n", __func__,
-			MVS_VERS_COMP_VER5);
-		audio_mvs_info.rpc_prog = MVS_PROG;
-		audio_mvs_info.rpc_ver = MVS_VERS_COMP_VER5;
-	}
-	audio_mvs_info.task = kthread_run(audio_mvs_thread,
-					  &audio_mvs_info,
-					  "audio_mvs");
-	if (IS_ERR(audio_mvs_info.task)) {
-		pr_err("%s: MVS thread create failed\n",  __func__);
-		rc = PTR_ERR(audio_mvs_info.task);
-		audio_mvs_info.task = NULL;
-		msm_rpc_close(audio_mvs_info.rpc_endpt);
-		audio_mvs_info.rpc_endpt = NULL;
-		goto done;
-	}
-
-	rc = misc_register(&audio_mvs_misc);
-done:
-	return rc;
-}
-
-static void __exit audio_mvs_exit(void)
-{
-	pr_info("%s:\n", __func__);
-
-	misc_deregister(&audio_mvs_misc);
-}
-
-module_init(audio_mvs_init);
-module_exit(audio_mvs_exit);
-
-MODULE_DESCRIPTION("MSM MVS driver");
-MODULE_LICENSE("GPL v2");
-
diff --git a/arch/arm/mach-msm/qdsp5v2/audio_out.c b/arch/arm/mach-msm/qdsp5v2/audio_out.c
deleted file mode 100644
index 712c9f3..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audio_out.c
+++ /dev/null
@@ -1,774 +0,0 @@
-/*
- * pcm audio output device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2009-2012, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/wakelock.h>
-#include <linux/memory_alloc.h>
-#include <linux/msm_audio.h>
-#include <linux/pm_qos.h>
-
-#include <mach/msm_adsp.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/qdsp5v2/qdsp5audppcmdi.h>
-#include <mach/qdsp5v2/qdsp5audppmsg.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/qdsp5v2/audpp.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/msm_memtypes.h>
-#include <mach/cpuidle.h>
-#include <linux/msm_ion.h>
-#include <mach/htc_pwrsink.h>
-#include <mach/debug_mm.h>
-
-#define BUFSZ (960 * 5)
-#define DMASZ (BUFSZ * 2)
-
-#define HOSTPCM_STREAM_ID 5
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;
-	unsigned addr;
-};
-
-struct audio {
-	struct buffer out[2];
-
-	spinlock_t dsp_lock;
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed; /* number of buffers the dsp is waiting for */
-
-	atomic_t out_bytes;
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t wait;
-
-	/* configuration to use on next enable */
-	uint32_t out_sample_rate;
-	uint32_t out_channel_mode;
-	uint32_t out_weight;
-	uint32_t out_buffer_size;
-	uint32_t device_events;
-	int16_t source;
-
-	/* data allocated for various buffers */
-	char *data;
-	dma_addr_t phys;
-	void *map_v_write;
-	int teos; /* valid only if tunnel mode & no data left for decoder */
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped, cleared on flush */
-	uint16_t dec_id;
-	int voice_state;
-
-	struct wake_lock wakelock;
-	struct pm_qos_request pm_qos_req;
-
-	struct audpp_cmd_cfg_object_params_volume vol_pan;
-	struct ion_client *client;
-	struct ion_handle *buff_handle;
-};
-
-static void audio_out_listener(u32 evt_id, union auddev_evt_data *evt_payload,
-				void *private_data)
-{
-	struct audio *audio = private_data;
-	switch (evt_id) {
-	case AUDDEV_EVT_DEV_RDY:
-		MM_DBG(":AUDDEV_EVT_DEV_RDY\n");
-		audio->source |= (0x1 << evt_payload->routing_id);
-		if (audio->running == 1 && audio->enabled == 1)
-			audpp_route_stream(audio->dec_id, audio->source);
-		break;
-	case AUDDEV_EVT_DEV_RLS:
-		MM_DBG(":AUDDEV_EVT_DEV_RLS\n");
-		audio->source &= ~(0x1 << evt_payload->routing_id);
-		if (audio->running == 1 && audio->enabled == 1)
-			audpp_route_stream(audio->dec_id, audio->source);
-		break;
-	case AUDDEV_EVT_STREAM_VOL_CHG:
-		audio->vol_pan.volume = evt_payload->session_vol;
-		MM_DBG(":AUDDEV_EVT_STREAM_VOL_CHG, stream vol %d\n",
-				audio->vol_pan.volume);
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		break;
-	case AUDDEV_EVT_VOICE_STATE_CHG:
-		MM_DBG("AUDDEV_EVT_VOICE_STATE_CHG, state = %d\n",
-						evt_payload->voice_state);
-		audio->voice_state = evt_payload->voice_state;
-		/* Voice uplink Rx case */
-		if (audio->running &&
-			(audio->source & AUDPP_MIXER_UPLINK_RX) &&
-			(audio->voice_state == VOICE_STATE_OFFCALL)) {
-			MM_DBG("Voice is terminated, Wake up write: %x %x\n",
-					audio->voice_state, audio->source);
-			wake_up(&audio->wait);
-		}
-		break;
-	default:
-		MM_ERR("ERROR:wrong event\n");
-		break;
-       }
-}
-
-static void audio_prevent_sleep(struct audio *audio)
-{
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	wake_lock(&audio->wakelock);
-	pm_qos_update_request(&audio->pm_qos_req,
-			      msm_cpuidle_get_deep_idle_latency());
-}
-
-static void audio_allow_sleep(struct audio *audio)
-{
-	pm_qos_update_request(&audio->pm_qos_req, PM_QOS_DEFAULT_VALUE);
-	wake_unlock(&audio->wakelock);
-	MM_DBG("\n"); /* Macro prints the file name and function */
-}
-
-static int audio_dsp_out_enable(struct audio *audio, int yes);
-static int audio_dsp_send_buffer(struct audio *audio, unsigned id,
-	unsigned len);
-
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg);
-
-/* must be called with audio->lock held */
-static int audio_enable(struct audio *audio)
-{
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	if (audio->enabled)
-		return 0;
-
-	/* refuse to start if we're not ready */
-	if (!audio->out[0].used || !audio->out[1].used)
-		return -EIO;
-
-	/* we start buffers 0 and 1, so buffer 0 will be the
-	 * next one the dsp will want
-	 */
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-
-	audio_prevent_sleep(audio);
-
-	if (audpp_enable(-1, audio_dsp_event, audio)) {
-		MM_ERR("audpp_enable() failed\n");
-		audio_allow_sleep(audio);
-		return -ENODEV;
-	}
-
-	audio->enabled = 1;
-	htc_pwrsink_set(PWRSINK_AUDIO, 100);
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audio_disable(struct audio *audio)
-{
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audio_dsp_out_enable(audio, 0);
-
-		audpp_disable(-1, audio);
-
-		wake_up(&audio->wait);
-		audio->out_needed = 0;
-		audio_allow_sleep(audio);
-	}
-	return 0;
-}
-
-/* ------------------- dsp --------------------- */
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg)
-{
-	struct audio *audio = private;
-	struct buffer *frame;
-	unsigned long flags;
-	static unsigned long pcmdmamsd_time;
-
-	switch (id) {
-	case AUDPP_MSG_HOST_PCM_INTF_MSG: {
-		unsigned id = msg[3];
-		unsigned idx = msg[4] - 1;
-
-		MM_DBG("HOST_PCM id %d idx %d\n", id, idx);
-		if (id != AUDPP_MSG_HOSTPCM_ID_ARM_RX) {
-			MM_ERR("bogus id\n");
-			break;
-		}
-		if (idx > 1) {
-			MM_ERR("bogus buffer idx\n");
-			break;
-		}
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		if (audio->running) {
-			atomic_add(audio->out[idx].used, &audio->out_bytes);
-			audio->out[idx].used = 0;
-			frame = audio->out + audio->out_tail;
-			if (frame->used) {
-				/* Reset teos flag to avoid stale
-				 * PCMDMAMISS been considered
-				 */
-				audio->teos = 0;
-				audio_dsp_send_buffer(
-					audio, audio->out_tail, frame->used);
-				audio->out_tail ^= 1;
-			} else {
-				audio->out_needed++;
-			}
-			wake_up(&audio->wait);
-		}
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		break;
-	}
-	case AUDPP_MSG_PCMDMAMISSED:
-		/* prints only if 1 second is elapsed since the last time
-		 * this message has been printed */
-		if (printk_timed_ratelimit(&pcmdmamsd_time, 1000))
-			printk(KERN_INFO "[%s:%s] PCMDMAMISSED %d\n",
-					__MM_FILE__, __func__, msg[0]);
-		audio->teos++;
-		MM_DBG("PCMDMAMISSED Count per Buffer %d\n", audio->teos);
-		wake_up(&audio->wait);
-		break;
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_DBG("CFG_MSG ENABLE\n");
-			audio->out_needed = 0;
-			audio->running = 1;
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-			audpp_route_stream(audio->dec_id, audio->source);
-			audio_dsp_out_enable(audio, 1);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			MM_DBG("CFG_MSG DISABLE\n");
-			audio->running = 0;
-		} else {
-			MM_ERR("CFG_MSG %d?\n", msg[0]);
-		}
-		break;
-	default:
-		MM_ERR("UNKNOWN (%d)\n", id);
-	}
-}
-
-static int audio_dsp_out_enable(struct audio *audio, int yes)
-{
-	struct audpp_cmd_pcm_intf cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id	= AUDPP_CMD_PCM_INTF;
-	cmd.stream	= AUDPP_CMD_POPP_STREAM;
-	cmd.stream_id	= audio->dec_id;
-	cmd.config	= AUDPP_CMD_PCM_INTF_CONFIG_CMD_V;
-	cmd.intf_type	= AUDPP_CMD_PCM_INTF_RX_ENA_ARMTODSP_V;
-
-	if (yes) {
-		cmd.write_buf1LSW	= audio->out[0].addr;
-		cmd.write_buf1MSW	= audio->out[0].addr >> 16;
-		if (audio->out[0].used)
-			cmd.write_buf1_len	= audio->out[0].used;
-		else
-			cmd.write_buf1_len	= audio->out[0].size;
-		cmd.write_buf2LSW	= audio->out[1].addr;
-		cmd.write_buf2MSW	= audio->out[1].addr >> 16;
-		if (audio->out[1].used)
-			cmd.write_buf2_len	= audio->out[1].used;
-		else
-			cmd.write_buf2_len	= audio->out[1].size;
-		cmd.arm_to_rx_flag	= AUDPP_CMD_PCM_INTF_ENA_V;
-		cmd.weight_decoder_to_rx = audio->out_weight;
-		cmd.weight_arm_to_rx	= 1;
-		cmd.partition_number_arm_to_dsp = 0;
-		cmd.sample_rate		= audio->out_sample_rate;
-		cmd.channel_mode	= audio->out_channel_mode;
-	}
-
-	return audpp_send_queue2(&cmd, sizeof(cmd));
-}
-
-static int audio_dsp_send_buffer(struct audio *audio, unsigned idx,
-	unsigned len)
-{
-	struct audpp_cmd_pcm_intf_send_buffer cmd;
-
-	cmd.cmd_id	= AUDPP_CMD_PCM_INTF;
-	cmd.stream	= AUDPP_CMD_POPP_STREAM;
-	cmd.stream_id	= audio->dec_id;
-	cmd.config	= AUDPP_CMD_PCM_INTF_BUFFER_CMD_V;
-	cmd.intf_type	= AUDPP_CMD_PCM_INTF_RX_ENA_ARMTODSP_V;
-	cmd.dsp_to_arm_buf_id	= 0;
-	cmd.arm_to_dsp_buf_id	= idx + 1;
-	cmd.arm_to_dsp_buf_len	= len;
-
-	return audpp_send_queue2(&cmd, sizeof(cmd));
-}
-
-/* ------------------- device --------------------- */
-static void audio_flush(struct audio *audio)
-{
-	audio->out[0].used = 0;
-	audio->out[1].used = 0;
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->stopped = 0;
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = -EINVAL;
-	unsigned long flags = 0;
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		stats.byte_count = atomic_read(&audio->out_bytes);
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-
-	switch (cmd) {
-	case AUDIO_SET_VOLUME:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.volume = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		return 0;
-
-	case AUDIO_SET_PAN:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.pan = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		if ((audio->voice_state != VOICE_STATE_INCALL)
-			&& (audio->source & AUDPP_MIXER_UPLINK_RX)) {
-			MM_ERR("Unable to Start : state %d source %d\n",
-					audio->voice_state, audio->source);
-			rc = -EPERM;
-			break;
-		}
-		rc = audio_enable(audio);
-		break;
-	case AUDIO_STOP:
-		rc = audio_disable(audio);
-		audio->stopped = 1;
-		break;
-	case AUDIO_FLUSH:
-		if (audio->stopped) {
-			/* Make sure we're stopped and we wake any threads
-			 * that might be blocked holding the write_lock.
-			 * While audio->stopped write threads will always
-			 * exit immediately.
-			 */
-			wake_up(&audio->wait);
-			mutex_lock(&audio->write_lock);
-			audio_flush(audio);
-			mutex_unlock(&audio->write_lock);
-		}
-	case AUDIO_SET_CONFIG: {
-		struct msm_audio_config config;
-		if (copy_from_user(&config, (void *) arg, sizeof(config))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (config.channel_count == 1)
-			config.channel_count = AUDPP_CMD_PCM_INTF_MONO_V;
-		else if (config.channel_count == 2)
-			config.channel_count = AUDPP_CMD_PCM_INTF_STEREO_V;
-		else {
-			rc = -EINVAL;
-			break;
-		}
-		audio->out_sample_rate = config.sample_rate;
-		audio->out_channel_mode = config.channel_count;
-		rc = 0;
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config config;
-		config.buffer_size = BUFSZ;
-		config.buffer_count = 2;
-		config.sample_rate = audio->out_sample_rate;
-		if (audio->out_channel_mode == AUDPP_CMD_PCM_INTF_MONO_V)
-			config.channel_count = 1;
-		else
-			config.channel_count = 2;
-
-		config.unused[0] = 0;
-		config.unused[1] = 0;
-		config.unused[2] = 0;
-		if (copy_to_user((void *) arg, &config, sizeof(config)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-	case AUDIO_GET_SESSION_ID: {
-		if (copy_to_user((void *) arg, &audio->dec_id,
-					sizeof(unsigned short)))
-			return -EFAULT;
-		rc = 0;
-		break;
-	}
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-/* Only useful in tunnel-mode */
-static int audio_fsync(struct file *file, loff_t ppos1, loff_t ppos2, int datasync)
-{
-	struct audio *audio = file->private_data;
-	int rc = 0;
-
-	if (!audio->running)
-		return -EINVAL;
-
-	mutex_lock(&audio->write_lock);
-
-	/* PCM DMAMISS message is sent only once in
-	 * hpcm interface. So, wait for buffer complete
-	 * and teos flag.
-	 */
-	rc = wait_event_interruptible(audio->wait,
-		(!audio->out[0].used &&
-		!audio->out[1].used));
-
-	if (rc < 0)
-		goto done;
-
-	rc = wait_event_interruptible(audio->wait,
-		audio->teos);
-done:
-	mutex_unlock(&audio->write_lock);
-	return rc;
-}
-
-static ssize_t audio_read(struct file *file, char __user *buf,
-		size_t count, loff_t *pos)
-{
-	return -EINVAL;
-}
-
-static inline int rt_policy(int policy)
-{
-	if (unlikely(policy == SCHED_FIFO) || unlikely(policy == SCHED_RR))
-		return 1;
-	return 0;
-}
-
-static inline int task_has_rt_policy(struct task_struct *p)
-{
-	return rt_policy(p->policy);
-}
-
-static ssize_t audio_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct sched_param s = { .sched_priority = 1 };
-	struct audio *audio = file->private_data;
-	unsigned long flags;
-	const char __user *start = buf;
-	struct buffer *frame;
-	size_t xfer;
-	int old_prio = current->rt_priority;
-	int old_policy = current->policy;
-	int cap_nice = cap_raised(current_cap(), CAP_SYS_NICE);
-	int rc = 0;
-
-
-	if ((audio->voice_state == VOICE_STATE_OFFCALL)
-		&& (audio->source & AUDPP_MIXER_UPLINK_RX) &&
-							audio->running) {
-		MM_ERR("Not Permitted Voice Terminated: state %d source %x \
-			running %d\n",
-			audio->voice_state, audio->source, audio->running);
-		return -EPERM;
-	}
-	/* just for this write, set us real-time */
-	if (!task_has_rt_policy(current)) {
-		struct cred *new = prepare_creds();
-		cap_raise(new->cap_effective, CAP_SYS_NICE);
-		commit_creds(new);
-		if ((sched_setscheduler(current, SCHED_RR, &s)) < 0)
-			MM_ERR("sched_setscheduler failed\n");
-	}
-
-	mutex_lock(&audio->write_lock);
-	while (count > 0) {
-		frame = audio->out + audio->out_head;
-
-		rc = wait_event_interruptible(audio->wait,
-		      (frame->used == 0) || (audio->stopped) ||
-			((audio->voice_state == VOICE_STATE_OFFCALL) &&
-			(audio->source & AUDPP_MIXER_UPLINK_RX)));
-
-		if (rc < 0)
-			break;
-		if (audio->stopped) {
-			rc = -EBUSY;
-			break;
-		} else if ((audio->voice_state == VOICE_STATE_OFFCALL) &&
-			(audio->source & AUDPP_MIXER_UPLINK_RX)) {
-			MM_ERR("Not Permitted Voice Terminated: %d\n",
-							audio->voice_state);
-			rc = -EPERM;
-			break;
-		}
-
-		xfer = count > frame->size ? frame->size : count;
-		if (copy_from_user(frame->data, buf, xfer)) {
-			rc = -EFAULT;
-			break;
-		}
-		frame->used = xfer;
-		audio->out_head ^= 1;
-		count -= xfer;
-		buf += xfer;
-
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		frame = audio->out + audio->out_tail;
-		if (frame->used && audio->out_needed) {
-			/* Reset teos flag to avoid stale
-			 * PCMDMAMISS been considered
-			 */
-			audio->teos = 0;
-			audio_dsp_send_buffer(audio, audio->out_tail,
-					frame->used);
-			audio->out_tail ^= 1;
-			audio->out_needed--;
-		}
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	}
-
-	mutex_unlock(&audio->write_lock);
-
-	/* restore scheduling policy and priority */
-	if (!rt_policy(old_policy)) {
-		struct sched_param v = { .sched_priority = old_prio };
-		if ((sched_setscheduler(current, old_policy, &v)) < 0)
-			MM_ERR("sched_setscheduler failed\n");
-		if (likely(!cap_nice)) {
-			struct cred *new = prepare_creds();
-			cap_lower(new->cap_effective, CAP_SYS_NICE);
-			commit_creds(new);
-		}
-	}
-
-	if (buf > start)
-		return buf - start;
-	return rc;
-}
-
-static int audio_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	auddev_unregister_evt_listner(AUDDEV_CLNT_DEC, audio->dec_id);
-	audio_disable(audio);
-	audio_flush(audio);
-	audio->opened = 0;
-	mutex_unlock(&audio->lock);
-	htc_pwrsink_set(PWRSINK_AUDIO, 0);
-	return 0;
-}
-
-static struct audio the_audio;
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = &the_audio;
-	int rc;
-
-	mutex_lock(&audio->lock);
-
-	if (audio->opened) {
-		MM_ERR("busy\n");
-		rc = -EBUSY;
-		goto done;
-	}
-
-
-	audio->dec_id = HOSTPCM_STREAM_ID;
-
-	audio->out_buffer_size = BUFSZ;
-	audio->out_sample_rate = 44100;
-	audio->out_channel_mode = AUDPP_CMD_PCM_INTF_STEREO_V;
-	audio->out_weight = 100;
-
-	audio->out[0].data = audio->data + 0;
-	audio->out[0].addr = audio->phys + 0;
-	audio->out[0].size = BUFSZ;
-
-	audio->out[1].data = audio->data + BUFSZ;
-	audio->out[1].addr = audio->phys + BUFSZ;
-	audio->out[1].size = BUFSZ;
-
-	audio->vol_pan.volume = 0x2000;
-	audio->vol_pan.pan = 0x0;
-	audio->source = 0x0;
-
-	audio_flush(audio);
-	audio->voice_state = msm_get_voice_state();
-	MM_DBG("voice_state = %x\n", audio->voice_state);
-	audio->device_events = AUDDEV_EVT_DEV_RDY
-				|AUDDEV_EVT_DEV_RLS|
-				AUDDEV_EVT_STREAM_VOL_CHG|
-				AUDDEV_EVT_VOICE_STATE_CHG;
-
-	MM_DBG("register for event callback pdata %p\n", audio);
-	rc = auddev_register_evt_listner(audio->device_events,
-					AUDDEV_CLNT_DEC,
-					audio->dec_id,
-					audio_out_listener,
-					(void *)audio);
-	if (rc) {
-		MM_ERR("%s: failed to register listener\n", __func__);
-		goto done;
-	}
-
-	file->private_data = audio;
-	audio->opened = 1;
-	rc = 0;
-done:
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static const struct file_operations audio_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audio_open,
-	.release	= audio_release,
-	.read		= audio_read,
-	.write		= audio_write,
-	.unlocked_ioctl	= audio_ioctl,
-	.fsync		= audio_fsync,
-};
-
-struct miscdevice audio_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_pcm_out",
-	.fops	= &audio_fops,
-};
-
-static int __init audio_init(void)
-{
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	int rc;
-	int len = 0;
-	struct ion_handle *handle = NULL;
-	struct ion_client *client = NULL;
-
-	client = msm_ion_client_create(UINT_MAX, "HostPCM");
-	if (IS_ERR_OR_NULL(client)) {
-		MM_ERR("Unable to create ION client\n");
-		rc = -ENOMEM;
-		goto client_create_error;
-	}
-	the_audio.client = client;
-
-	handle = ion_alloc(client, DMASZ, SZ_4K,
-		ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-	if (IS_ERR_OR_NULL(handle)) {
-		MM_ERR("Unable to create allocate O/P buffers\n");
-		rc = -ENOMEM;
-		goto buff_alloc_error;
-		}
-	the_audio.buff_handle = handle;
-
-	rc = ion_phys(client, handle, &addr, &len);
-	if (rc) {
-		MM_ERR("O/P buffers:Invalid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-		goto buff_get_phys_error;
-	} else
-		MM_INFO("O/P buffers:valid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-	the_audio.phys = (int32_t)addr;
-
-	rc = ion_handle_get_flags(client, handle, &ionflag);
-	if (rc) {
-		MM_ERR("could not get flags for the handle\n");
-		goto buff_get_flags_error;
-	}
-
-	the_audio.map_v_write = ion_map_kernel(client, handle);
-	if (IS_ERR(the_audio.map_v_write)) {
-		MM_ERR("could not map write buffers\n");
-		rc = -ENOMEM;
-		goto buff_map_error;
-	}
-	the_audio.data = (char *)the_audio.map_v_write;
-	MM_DBG("Memory addr = 0x%8x  phy addr = 0x%8x\n",\
-		(int) the_audio.data, (int) the_audio.phys);
-	mutex_init(&the_audio.lock);
-	mutex_init(&the_audio.write_lock);
-	spin_lock_init(&the_audio.dsp_lock);
-	init_waitqueue_head(&the_audio.wait);
-	wake_lock_init(&the_audio.wakelock, WAKE_LOCK_SUSPEND, "audio_pcm");
-	pm_qos_add_request(&the_audio.pm_qos_req, PM_QOS_CPU_DMA_LATENCY,
-				PM_QOS_DEFAULT_VALUE);
-	return misc_register(&audio_misc);
-buff_map_error:
-buff_get_phys_error:
-buff_get_flags_error:
-	ion_free(client, the_audio.buff_handle);
-buff_alloc_error:
-	ion_client_destroy(client);
-client_create_error:
-	return rc;
-
-}
-
-late_initcall(audio_init);
diff --git a/arch/arm/mach-msm/qdsp5v2/audio_pcm.c b/arch/arm/mach-msm/qdsp5v2/audio_pcm.c
deleted file mode 100644
index cbd2913..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audio_pcm.c
+++ /dev/null
@@ -1,1577 +0,0 @@
-/* arch/arm/mach-msm/qdsp5v2/audio_pcm.c
- *
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2009-2012, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <asm/ioctls.h>
-#include <asm/atomic.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/earlysuspend.h>
-#include <linux/list.h>
-#include <linux/memory_alloc.h>
-#include <linux/slab.h>
-#include <linux/msm_audio.h>
-#include <mach/msm_adsp.h>
-
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/qdsp5v2/qdsp5audppcmdi.h>
-#include <mach/qdsp5v2/qdsp5audppmsg.h>
-#include <mach/qdsp5v2/qdsp5audplaycmdi.h>
-#include <mach/qdsp5v2/qdsp5audplaymsg.h>
-#include <mach/qdsp5v2/audpp.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_memtypes.h>
-
-#define ADRV_STATUS_AIO_INTF 0x00000001
-#define ADRV_STATUS_OBUF_GIVEN 0x00000002
-#define ADRV_STATUS_IBUF_GIVEN 0x00000004
-#define ADRV_STATUS_FSYNC 0x00000008
-
-/* Size must be power of 2 */
-#define BUFSZ_MAX 32768
-#define BUFSZ_MIN 4096
-#define DMASZ_MAX (BUFSZ_MAX * 2)
-#define DMASZ_MIN (BUFSZ_MIN * 2)
-
-#define AUDDEC_DEC_PCM 0
-
-/* Decoder status received from AUDPPTASK */
-#define  AUDPP_DEC_STATUS_SLEEP	0
-#define  AUDPP_DEC_STATUS_INIT  1
-#define  AUDPP_DEC_STATUS_CFG   2
-#define  AUDPP_DEC_STATUS_PLAY  3
-
-#define AUDPCM_EVENT_NUM 10 /* Default number of pre-allocated event packets */
-
-#define __CONTAINS(r, v, l) ({					\
-	typeof(r) __r = r;					\
-	typeof(v) __v = v;					\
-	typeof(v) __e = __v + l;				\
-	int res = ((__v >= __r->vaddr) && 			\
-		(__e <= __r->vaddr + __r->len));		\
-	res;							\
-})
-
-#define CONTAINS(r1, r2) ({					\
-	typeof(r2) __r2 = r2;					\
-	__CONTAINS(r1, __r2->vaddr, __r2->len);			\
-})
-
-#define IN_RANGE(r, v) ({					\
-	typeof(r) __r = r;					\
-	typeof(v) __vv = v;					\
-	int res = ((__vv >= __r->vaddr) &&			\
-		(__vv < (__r->vaddr + __r->len)));		\
-	res;							\
-})
-
-#define OVERLAPS(r1, r2) ({					\
-	typeof(r1) __r1 = r1;					\
-	typeof(r2) __r2 = r2;					\
-	typeof(__r2->vaddr) __v = __r2->vaddr;			\
-	typeof(__v) __e = __v + __r2->len - 1;			\
-	int res = (IN_RANGE(__r1, __v) || IN_RANGE(__r1, __e));	\
-	res;							\
-})
-
-struct audio;
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;		/* Input usage actual DSP produced PCM size  */
-	unsigned addr;
-};
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-struct audpcm_suspend_ctl {
-  struct early_suspend node;
-  struct audio *audio;
-};
-#endif
-
-struct audpcm_event {
-	struct list_head list;
-	int event_type;
-	union msm_audio_event_payload payload;
-};
-
-struct audpcm_pmem_region {
-	struct list_head list;
-	struct file *file;
-	int fd;
-	void *vaddr;
-	unsigned long paddr;
-	unsigned long kvaddr;
-	unsigned long len;
-	unsigned ref_cnt;
-};
-
-struct audpcm_buffer_node {
-	struct list_head list;
-	struct msm_audio_aio_buf buf;
-	unsigned long paddr;
-};
-
-struct audpcm_drv_operations {
-	void (*send_data)(struct audio *, unsigned);
-	void (*out_flush)(struct audio *);
-	int (*fsync)(struct audio *);
-};
-
-struct audio {
-	struct buffer out[2];
-
-	spinlock_t dsp_lock;
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed; /* number of buffers the dsp is waiting for */
-	unsigned out_dma_sz;
-	struct list_head out_queue; /* queue to retain output buffers */
-	atomic_t out_bytes;
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-
-	struct msm_adsp_module *audplay;
-
-	/* configuration to use on next enable */
-	uint32_t out_sample_rate;
-	uint32_t out_channel_mode;
-	uint32_t out_bits; /* bits per sample */
-
-	/* data allocated for various buffers */
-	char *data;
-	int32_t phys;
-	void *map_v_write;
-	uint32_t drv_status;
-	int wflush; /* Write flush */
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped, cleared on flush */
-	int teos; /* valid only if tunnel mode & no data left for decoder */
-	enum msm_aud_decoder_state dec_state; /* Represents decoder state */
-	int reserved; /* A byte is being reserved */
-	char rsv_byte; /* Handle odd length user data */
-
-	const char *module_name;
-	unsigned queue_id;
-	uint32_t device_events;
-
-	unsigned volume;
-
-	uint16_t dec_id;
-	int16_t source;
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	struct audpcm_suspend_ctl suspend_ctl;
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *dentry;
-#endif
-	wait_queue_head_t wait;
-	struct list_head free_event_queue;
-	struct list_head event_queue;
-	wait_queue_head_t event_wait;
-	spinlock_t event_queue_lock;
-	struct mutex get_event_lock;
-	int event_abort;
-	/* AV sync Info */
-	int avsync_flag;              /* Flag to indicate feedback from DSP */
-	wait_queue_head_t avsync_wait;/* Wait queue for AV Sync Message     */
-	/* flags, 48 bits sample/bytes counter per channel */
-	uint16_t avsync[AUDPP_AVSYNC_CH_COUNT * AUDPP_AVSYNC_NUM_WORDS + 1];
-
-	struct list_head pmem_region_queue;
-	struct audpcm_drv_operations drv_ops;
-};
-
-static int auddec_dsp_config(struct audio *audio, int enable);
-static void audpp_cmd_cfg_adec_params(struct audio *audio);
-static void audplay_send_data(struct audio *audio, unsigned needed);
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg);
-static void audpcm_post_event(struct audio *audio, int type,
-	union msm_audio_event_payload payload);
-static unsigned long audpcm_pmem_fixup(struct audio *audio, void *addr,
-	unsigned long len, int ref_up);
-
-static void pcm_listner(u32 evt_id, union auddev_evt_data *evt_payload,
-			void *private_data)
-{
-	struct audio *audio = (struct audio *) private_data;
-	switch (evt_id) {
-	case AUDDEV_EVT_DEV_RDY:
-		MM_DBG("AUDDEV_EVT_DEV_RDY\n");
-		audio->source |= (0x1 << evt_payload->routing_id);
-		if (audio->running == 1 && audio->enabled == 1)
-			audpp_route_stream(audio->dec_id, audio->source);
-		break;
-	case AUDDEV_EVT_DEV_RLS:
-		MM_DBG("AUDDEV_EVT_DEV_RLS\n");
-		audio->source &= ~(0x1 << evt_payload->routing_id);
-		if (audio->running == 1 && audio->enabled == 1)
-			audpp_route_stream(audio->dec_id, audio->source);
-		break;
-	case AUDDEV_EVT_STREAM_VOL_CHG:
-		audio->volume = evt_payload->session_vol;
-		MM_DBG("AUDDEV_EVT_STREAM_VOL_CHG, stream vol %d\n",
-				audio->volume);
-		if (audio->running)
-			audpp_set_volume_and_pan(audio->dec_id, audio->volume,
-					0, POPP);
-		break;
-	default:
-		MM_ERR("ERROR:wrong event\n");
-		break;
-	}
-}
-/* must be called with audio->lock held */
-static int audio_enable(struct audio *audio)
-{
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	if (audio->enabled)
-		return 0;
-
-	audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-
-	if (msm_adsp_enable(audio->audplay)) {
-		MM_ERR("msm_adsp_enable(audplay) failed\n");
-		return -ENODEV;
-	}
-
-	if (audpp_enable(audio->dec_id, audio_dsp_event, audio)) {
-		MM_ERR("audpp_enable() failed\n");
-		msm_adsp_disable(audio->audplay);
-		return -ENODEV;
-	}
-
-	audio->enabled = 1;
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audio_disable(struct audio *audio)
-{
-	int rc = 0;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-		auddec_dsp_config(audio, 0);
-		rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-		if (rc == 0)
-			rc = -ETIMEDOUT;
-		else if (audio->dec_state != MSM_AUD_DECODER_STATE_CLOSE)
-			rc = -EFAULT;
-		else
-			rc = 0;
-		wake_up(&audio->write_wait);
-		msm_adsp_disable(audio->audplay);
-		audpp_disable(audio->dec_id, audio);
-		audio->out_needed = 0;
-	}
-	return rc;
-}
-
-/* ------------------- dsp --------------------- */
-static void audplay_dsp_event(void *data, unsigned id, size_t len,
-			      void (*getevent) (void *ptr, size_t len))
-{
-	struct audio *audio = data;
-	uint32_t msg[28];
-	getevent(msg, sizeof(msg));
-
-	MM_DBG("msg_id=%x\n", id);
-
-	switch (id) {
-	case AUDPLAY_MSG_DEC_NEEDS_DATA:
-		audio->drv_ops.send_data(audio, 1);
-		break;
-
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event:module audplaytask\n");
-		break;
-
-	default:
-		MM_ERR("unexpected message from decoder\n");
-		break;
-	}
-}
-
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg)
-{
-	struct audio *audio = private;
-
-	switch (id) {
-	case AUDPP_MSG_STATUS_MSG:{
-			unsigned status = msg[1];
-
-			switch (status) {
-			case AUDPP_DEC_STATUS_SLEEP: {
-				uint16_t reason = msg[2];
-				MM_DBG("decoder status:sleep reason=0x%04x\n",
-						reason);
-				if ((reason == AUDPP_MSG_REASON_MEM)
-						|| (reason ==
-						AUDPP_MSG_REASON_NODECODER)) {
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_FAILURE;
-					wake_up(&audio->wait);
-				} else if (reason == AUDPP_MSG_REASON_NONE) {
-					/* decoder is in disable state */
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_CLOSE;
-					wake_up(&audio->wait);
-				}
-				break;
-			}
-			case AUDPP_DEC_STATUS_INIT:
-				MM_DBG("decoder status: init \n");
-				audpp_cmd_cfg_adec_params(audio);
-				break;
-
-			case AUDPP_DEC_STATUS_CFG:
-				MM_DBG("decoder status: cfg \n");
-				break;
-			case AUDPP_DEC_STATUS_PLAY:
-				MM_DBG("decoder status: play \n");
-				audpp_route_stream(audio->dec_id,
-						audio->source);
-				audio->dec_state =
-					MSM_AUD_DECODER_STATE_SUCCESS;
-				wake_up(&audio->wait);
-				break;
-			default:
-				MM_ERR("unknown decoder status\n");
-				break;
-			}
-			break;
-		}
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_DBG("CFG_MSG ENABLE\n");
-			auddec_dsp_config(audio, 1);
-			audio->out_needed = 0;
-			audio->running = 1;
-			audpp_set_volume_and_pan(audio->dec_id, audio->volume,
-					0, POPP);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			MM_DBG("CFG_MSG DISABLE\n");
-			audio->running = 0;
-		} else {
-			MM_ERR("audio_dsp_event: CFG_MSG %d?\n", msg[0]);
-		}
-		break;
-	case AUDPP_MSG_FLUSH_ACK:
-		MM_DBG("FLUSH_ACK\n");
-		audio->wflush = 0;
-		wake_up(&audio->write_wait);
-		break;
-
-	case AUDPP_MSG_PCMDMAMISSED:
-		MM_DBG("PCMDMAMISSED\n");
-		audio->teos = 1;
-		wake_up(&audio->write_wait);
-		break;
-
-	case AUDPP_MSG_AVSYNC_MSG:
-		pr_info("%s: AVSYNC_MSG\n", __func__);
-		memcpy(&audio->avsync[0], msg, sizeof(audio->avsync));
-		audio->avsync_flag = 1;
-		wake_up(&audio->avsync_wait);
-		break;
-
-	default:
-		MM_DBG("audio_dsp_event: UNKNOWN (%d)\n", id);
-	}
-
-}
-
-
-struct msm_adsp_ops audpcmdec_adsp_ops = {
-	.event = audplay_dsp_event,
-};
-
-
-#define audplay_send_queue0(audio, cmd, len) \
-	msm_adsp_write(audio->audplay, audio->queue_id, \
-			cmd, len)
-
-static int auddec_dsp_config(struct audio *audio, int enable)
-{
-	struct audpp_cmd_cfg_dec_type cfg_dec_cmd;
-
-	memset(&cfg_dec_cmd, 0, sizeof(cfg_dec_cmd));
-
-	cfg_dec_cmd.cmd_id = AUDPP_CMD_CFG_DEC_TYPE;
-	if (enable)
-		cfg_dec_cmd.dec_cfg = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_ENA_DEC_V | AUDDEC_DEC_PCM;
-	else
-		cfg_dec_cmd.dec_cfg = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_DIS_DEC_V;
-	cfg_dec_cmd.dm_mode = 0x0;
-	cfg_dec_cmd.stream_id = audio->dec_id;
-	return audpp_send_queue1(&cfg_dec_cmd, sizeof(cfg_dec_cmd));
-}
-
-static void audpp_cmd_cfg_adec_params(struct audio *audio)
-{
-	struct audpp_cmd_cfg_adec_params_wav cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_CMD_CFG_ADEC_PARAMS;
-	cmd.common.length = AUDPP_CMD_CFG_ADEC_PARAMS_WAV_LEN >> 1;
-	cmd.common.dec_id = audio->dec_id;
-	cmd.common.input_sampling_frequency = audio->out_sample_rate;
-	cmd.stereo_cfg = audio->out_channel_mode;
-	cmd.pcm_width = audio->out_bits;
-	cmd.sign = 0;
-	audpp_send_queue2(&cmd, sizeof(cmd));
-}
-
-static int audplay_dsp_send_data_avail(struct audio *audio,
-					unsigned idx, unsigned len)
-{
-	struct audplay_cmd_bitstream_data_avail cmd;
-
-	cmd.cmd_id		= AUDPLAY_CMD_BITSTREAM_DATA_AVAIL;
-	cmd.decoder_id		= audio->dec_id;
-	cmd.buf_ptr		= audio->out[idx].addr;
-	cmd.buf_size		= len/2;
-	cmd.partition_number	= 0;
-	/* complete writes to the input buffer */
-	wmb();
-	return audplay_send_queue0(audio, &cmd, sizeof(cmd));
-}
-
-static void audpcm_async_send_data(struct audio *audio, unsigned needed)
-{
-	unsigned long flags;
-
-	if (!audio->running)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-
-	if (needed && !audio->wflush) {
-		audio->out_needed = 1;
-		if (audio->drv_status & ADRV_STATUS_OBUF_GIVEN) {
-			/* pop one node out of queue */
-			union msm_audio_event_payload payload;
-			struct audpcm_buffer_node *used_buf;
-
-			MM_DBG("consumed\n");
-
-			BUG_ON(list_empty(&audio->out_queue));
-			used_buf = list_first_entry(&audio->out_queue,
-				struct audpcm_buffer_node, list);
-			list_del(&used_buf->list);
-			payload.aio_buf = used_buf->buf;
-			audpcm_post_event(audio, AUDIO_EVENT_WRITE_DONE,
-				payload);
-			kfree(used_buf);
-			audio->drv_status &= ~ADRV_STATUS_OBUF_GIVEN;
-		}
-	}
-	if (audio->out_needed) {
-		struct audpcm_buffer_node *next_buf;
-		struct audplay_cmd_bitstream_data_avail cmd;
-		if (!list_empty(&audio->out_queue)) {
-			next_buf = list_first_entry(&audio->out_queue,
-					struct audpcm_buffer_node, list);
-			MM_DBG("next_buf %p\n", next_buf);
-			if (next_buf) {
-				MM_DBG("next buf phy %lx len %d\n",
-				next_buf->paddr, next_buf->buf.data_len);
-
-				cmd.cmd_id = AUDPLAY_CMD_BITSTREAM_DATA_AVAIL;
-				if (next_buf->buf.data_len)
-					cmd.decoder_id = audio->dec_id;
-				else {
-					cmd.decoder_id = -1;
-					MM_DBG("input EOS signaled\n");
-				}
-				cmd.buf_ptr	= (unsigned) next_buf->paddr;
-				cmd.buf_size = next_buf->buf.data_len >> 1;
-				cmd.partition_number	= 0;
-				/* complete writes to the input buffer */
-				wmb();
-				audplay_send_queue0(audio, &cmd, sizeof(cmd));
-				audio->out_needed = 0;
-				audio->drv_status |= ADRV_STATUS_OBUF_GIVEN;
-			}
-		}
-	}
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audplay_send_data(struct audio *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-
-	if (!audio->running)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			MM_DBG("frame %d free\n", audio->out_tail);
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			MM_DBG("frame %d busy\n", audio->out_tail);
-			audplay_dsp_send_data_avail(audio, audio->out_tail,
-					frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-static void audpcm_async_flush(struct audio *audio)
-{
-	struct audpcm_buffer_node *buf_node;
-	struct list_head *ptr, *next;
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	list_for_each_safe(ptr, next, &audio->out_queue) {
-		buf_node = list_entry(ptr, struct audpcm_buffer_node, list);
-		list_del(&buf_node->list);
-		payload.aio_buf = buf_node->buf;
-		audpcm_post_event(audio, AUDIO_EVENT_WRITE_DONE,
-				payload);
-		kfree(buf_node);
-	}
-	audio->drv_status &= ~ADRV_STATUS_OBUF_GIVEN;
-	audio->out_needed = 0;
-	atomic_set(&audio->out_bytes, 0);
-}
-
-static void audio_flush(struct audio *audio)
-{
-	audio->out[0].used = 0;
-	audio->out[1].used = 0;
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->reserved = 0;
-	audio->out_needed = 0;
-	atomic_set(&audio->out_bytes, 0);
-}
-
-static void audio_ioport_reset(struct audio *audio)
-{
-	if (audio->drv_status & ADRV_STATUS_AIO_INTF) {
-		/* If fsync is in progress, make sure
-		 * return value of fsync indicates
-		 * abort due to flush
-		 */
-		if (audio->drv_status & ADRV_STATUS_FSYNC) {
-			MM_DBG("fsync in progress\n");
-			wake_up(&audio->write_wait);
-			mutex_lock(&audio->write_lock);
-			audio->drv_ops.out_flush(audio);
-			mutex_unlock(&audio->write_lock);
-		} else
-			audio->drv_ops.out_flush(audio);
-	} else {
-		/* Make sure read/write thread are free from
-		 * sleep and knowing that system is not able
-		 * to process io request at the moment
-		 */
-		wake_up(&audio->write_wait);
-		mutex_lock(&audio->write_lock);
-		audio->drv_ops.out_flush(audio);
-		mutex_unlock(&audio->write_lock);
-	}
-	audio->avsync_flag = 1;
-	wake_up(&audio->avsync_wait);
-}
-
-static int audpcm_events_pending(struct audio *audio)
-{
-	unsigned long flags;
-	int empty;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	empty = !list_empty(&audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	return empty || audio->event_abort;
-}
-
-static void audpcm_reset_event_queue(struct audio *audio)
-{
-	unsigned long flags;
-	struct audpcm_event *drv_evt;
-	struct list_head *ptr, *next;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	list_for_each_safe(ptr, next, &audio->event_queue) {
-		drv_evt = list_first_entry(&audio->event_queue,
-			struct audpcm_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	list_for_each_safe(ptr, next, &audio->free_event_queue) {
-		drv_evt = list_first_entry(&audio->free_event_queue,
-			struct audpcm_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	return;
-}
-
-static long audpcm_process_event_req(struct audio *audio, void __user *arg)
-{
-	long rc;
-	struct msm_audio_event usr_evt;
-	struct audpcm_event *drv_evt = NULL;
-	int timeout;
-	unsigned long flags;
-
-	if (copy_from_user(&usr_evt, arg, sizeof(struct msm_audio_event)))
-		return -EFAULT;
-
-	timeout = (int) usr_evt.timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(
-			audio->event_wait, audpcm_events_pending(audio),
-			msecs_to_jiffies(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(
-			audio->event_wait, audpcm_events_pending(audio));
-	}
-
-	if (rc < 0)
-		return rc;
-
-	if (audio->event_abort) {
-		audio->event_abort = 0;
-		return -ENODEV;
-	}
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	if (!list_empty(&audio->event_queue)) {
-		drv_evt = list_first_entry(&audio->event_queue,
-			struct audpcm_event, list);
-		list_del(&drv_evt->list);
-	}
-	if (drv_evt) {
-		usr_evt.event_type = drv_evt->event_type;
-		usr_evt.event_payload = drv_evt->payload;
-		list_add_tail(&drv_evt->list, &audio->free_event_queue);
-	} else
-		rc = -1;
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	if (drv_evt && drv_evt->event_type == AUDIO_EVENT_WRITE_DONE) {
-		mutex_lock(&audio->lock);
-		audpcm_pmem_fixup(audio, drv_evt->payload.aio_buf.buf_addr,
-				  drv_evt->payload.aio_buf.buf_len, 0);
-		mutex_unlock(&audio->lock);
-	}
-	if (!rc && copy_to_user(arg, &usr_evt, sizeof(usr_evt)))
-		rc = -EFAULT;
-
-	return rc;
-}
-
-static int audpcm_pmem_lookup_vaddr(struct audio *audio, void *addr,
-		     unsigned long len, struct audpcm_pmem_region **region)
-{
-	struct audpcm_pmem_region *region_elt;
-
-	int match_count = 0;
-
-	*region = NULL;
-
-	/* returns physical address or zero */
-	list_for_each_entry(region_elt, &audio->pmem_region_queue,
-		list) {
-		if (addr >= region_elt->vaddr &&
-		    addr < region_elt->vaddr + region_elt->len &&
-		    addr + len <= region_elt->vaddr + region_elt->len) {
-			/* offset since we could pass vaddr inside a registerd
-			 * pmem buffer
-			 */
-			match_count++;
-			if (!*region)
-				*region = region_elt;
-		}
-	}
-
-	if (match_count > 1) {
-		MM_ERR("multiple hits for vaddr %p, len %ld\n", addr, len);
-		list_for_each_entry(region_elt,
-		  &audio->pmem_region_queue, list) {
-			if (addr >= region_elt->vaddr &&
-			    addr < region_elt->vaddr + region_elt->len &&
-			    addr + len <= region_elt->vaddr + region_elt->len)
-				MM_ERR("\t%p, %ld --> %p\n",
-					region_elt->vaddr,
-					region_elt->len,
-					(void *)region_elt->paddr);
-		}
-	}
-
-	return *region ? 0 : -1;
-}
-
-static unsigned long audpcm_pmem_fixup(struct audio *audio, void *addr,
-		    unsigned long len, int ref_up)
-{
-	struct audpcm_pmem_region *region;
-	unsigned long paddr;
-	int ret;
-
-	ret = audpcm_pmem_lookup_vaddr(audio, addr, len, &region);
-	if (ret) {
-		MM_ERR("lookup (%p, %ld) failed\n", addr, len);
-		return 0;
-	}
-	if (ref_up)
-		region->ref_cnt++;
-	else
-		region->ref_cnt--;
-	MM_DBG("found region %p ref_cnt %d\n", region, region->ref_cnt);
-	paddr = region->paddr + (addr - region->vaddr);
-	return paddr;
-}
-
-/* audio -> lock must be held at this point */
-static int audpcm_aio_buf_add(struct audio *audio, unsigned dir,
-	void __user *arg)
-{
-	unsigned long flags;
-	struct audpcm_buffer_node *buf_node;
-
-	buf_node = kmalloc(sizeof(*buf_node), GFP_KERNEL);
-
-	if (!buf_node)
-		return -ENOMEM;
-
-	if (copy_from_user(&buf_node->buf, arg, sizeof(buf_node->buf))) {
-		kfree(buf_node);
-		return -EFAULT;
-	}
-
-	MM_DBG("node %p dir %x buf_addr %p buf_len %d data_len %d\n",
-			buf_node, dir, buf_node->buf.buf_addr,
-			buf_node->buf.buf_len, buf_node->buf.data_len);
-
-	buf_node->paddr = audpcm_pmem_fixup(
-		audio, buf_node->buf.buf_addr,
-		buf_node->buf.buf_len, 1);
-	if (dir) {
-		/* write */
-		if (!buf_node->paddr ||
-		    (buf_node->paddr & 0x1) ||
-		    (buf_node->buf.data_len & 0x1) ||
-		    (!buf_node->buf.data_len)) {
-			kfree(buf_node);
-			return -EINVAL;
-		}
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		list_add_tail(&buf_node->list, &audio->out_queue);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		audio->drv_ops.send_data(audio, 0);
-	}
-
-	MM_DBG("Add buf_node %p paddr %lx\n", buf_node, buf_node->paddr);
-
-	return 0;
-}
-
-static int audio_get_avsync_data(struct audio *audio,
-						struct msm_audio_stats *stats)
-{
-	int rc = -EINVAL;
-	unsigned long flags;
-
-	local_irq_save(flags);
-	if (audio->dec_id == audio->avsync[0] && audio->avsync_flag) {
-		/* av_sync sample count */
-		stats->sample_count = (audio->avsync[2] << 16) |
-						(audio->avsync[3]);
-
-		/* av_sync byte_count */
-		stats->byte_count = (audio->avsync[5] << 16) |
-						(audio->avsync[6]);
-
-		audio->avsync_flag = 0;
-		rc = 0;
-	}
-	local_irq_restore(flags);
-	return rc;
-
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = 0;
-
-	MM_DBG("cmd = %d\n", cmd);
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-
-		audio->avsync_flag = 0;
-		memset(&stats, 0, sizeof(stats));
-		if (audpp_query_avsync(audio->dec_id) < 0)
-			return rc;
-
-		rc = wait_event_interruptible_timeout(audio->avsync_wait,
-				(audio->avsync_flag == 1),
-				msecs_to_jiffies(AUDPP_AVSYNC_EVENT_TIMEOUT));
-
-		if (rc < 0)
-			return rc;
-		else if ((rc > 0) || ((rc == 0) && (audio->avsync_flag == 1))) {
-			if (audio_get_avsync_data(audio, &stats) < 0)
-				return rc;
-
-			if (copy_to_user((void *)arg, &stats, sizeof(stats)))
-				return -EFAULT;
-			return 0;
-		} else
-			return -EAGAIN;
-	}
-	if (cmd == AUDIO_SET_VOLUME) {
-		unsigned long flags;
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->volume = arg;
-		if (audio->running)
-			audpp_set_volume_and_pan(audio->dec_id, arg, 0,
-					POPP);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		return 0;
-	}
-	if (cmd == AUDIO_GET_EVENT) {
-		MM_DBG("AUDIO_GET_EVENT\n");
-		if (mutex_trylock(&audio->get_event_lock)) {
-			rc = audpcm_process_event_req(audio,
-				(void __user *) arg);
-			mutex_unlock(&audio->get_event_lock);
-		} else
-			rc = -EBUSY;
-		return rc;
-	}
-
-	if (cmd == AUDIO_ABORT_GET_EVENT) {
-		audio->event_abort = 1;
-		wake_up(&audio->event_wait);
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		MM_DBG("AUDIO_START\n");
-		rc = audio_enable(audio);
-		if (!rc) {
-			rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-			MM_INFO("dec_state %d rc = %d\n", audio->dec_state, rc);
-
-			if (audio->dec_state != MSM_AUD_DECODER_STATE_SUCCESS)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		break;
-	case AUDIO_STOP:
-		MM_DBG("AUDIO_STOP\n");
-		rc = audio_disable(audio);
-		audio->stopped = 1;
-		audio_ioport_reset(audio);
-		audio->stopped = 0;
-		break;
-	case AUDIO_FLUSH:
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->wflush = 1;
-		audio_ioport_reset(audio);
-		if (audio->running) {
-			audpp_flush(audio->dec_id);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->wflush = 0;
-		}
-		break;
-
-	case AUDIO_SET_CONFIG: {
-		struct msm_audio_config config;
-		if (copy_from_user(&config, (void *) arg, sizeof(config))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (config.channel_count == 1) {
-			config.channel_count = AUDPP_CMD_PCM_INTF_MONO_V;
-		} else if (config.channel_count == 2) {
-			config.channel_count = AUDPP_CMD_PCM_INTF_STEREO_V;
-		} else {
-			rc = -EINVAL;
-			break;
-		}
-		if (config.bits == 8)
-			config.bits = AUDPP_CMD_WAV_PCM_WIDTH_8;
-		else if (config.bits == 16)
-			config.bits = AUDPP_CMD_WAV_PCM_WIDTH_16;
-		else if (config.bits == 24)
-			config.bits = AUDPP_CMD_WAV_PCM_WIDTH_24;
-		else {
-			rc = -EINVAL;
-			break;
-		}
-		audio->out_sample_rate = config.sample_rate;
-		audio->out_channel_mode = config.channel_count;
-		audio->out_bits = config.bits;
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config config;
-		config.buffer_size = (audio->out_dma_sz >> 1);
-		config.buffer_count = 2;
-		config.sample_rate = audio->out_sample_rate;
-		if (audio->out_channel_mode == AUDPP_CMD_PCM_INTF_MONO_V)
-			config.channel_count = 1;
-		else
-			config.channel_count = 2;
-		if (audio->out_bits == AUDPP_CMD_WAV_PCM_WIDTH_8)
-			config.bits = 8;
-		else if (audio->out_bits == AUDPP_CMD_WAV_PCM_WIDTH_24)
-			config.bits = 24;
-		else
-			config.bits = 16;
-		config.unused[0] = 0;
-		config.unused[1] = 0;
-
-		if (copy_to_user((void *) arg, &config, sizeof(config)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	}
-
-	case AUDIO_PAUSE:
-		MM_DBG("AUDIO_PAUSE %ld\n", arg);
-		rc = audpp_pause(audio->dec_id, (int) arg);
-		break;
-
-	case AUDIO_ASYNC_WRITE:
-		if (audio->drv_status & ADRV_STATUS_FSYNC)
-			rc = -EBUSY;
-		else
-			rc = audpcm_aio_buf_add(audio, 1, (void __user *) arg);
-		break;
-
-	case AUDIO_ASYNC_READ:
-		MM_ERR("AUDIO_ASYNC_READ not supported\n");
-		rc = -EPERM;
-		break;
-
-	case AUDIO_GET_SESSION_ID:
-		if (copy_to_user((void *) arg, &audio->dec_id,
-					sizeof(unsigned short)))
-			return -EFAULT;
-		break;
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-/* Only useful in tunnel-mode */
-int audpcm_async_fsync(struct audio *audio)
-{
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	/* Blocking client sends more data */
-	mutex_lock(&audio->lock);
-	audio->drv_status |= ADRV_STATUS_FSYNC;
-	mutex_unlock(&audio->lock);
-
-	mutex_lock(&audio->write_lock);
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->teos && audio->out_needed &&
-		list_empty(&audio->out_queue))
-		|| audio->wflush || audio->stopped);
-
-	if (audio->stopped || audio->wflush)
-		rc = -EBUSY;
-
-	mutex_unlock(&audio->write_lock);
-	mutex_lock(&audio->lock);
-	audio->drv_status &= ~ADRV_STATUS_FSYNC;
-	mutex_unlock(&audio->lock);
-
-	return rc;
-}
-
-int audpcm_sync_fsync(struct audio *audio)
-{
-	struct buffer *frame;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(!audio->out[0].used &&
-		!audio->out[1].used &&
-		audio->out_needed) || audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (audio->reserved) {
-		MM_DBG("send reserved byte\n");
-		frame = audio->out + audio->out_tail;
-		((char *) frame->data)[0] = audio->rsv_byte;
-		((char *) frame->data)[1] = 0;
-		frame->used = 2;
-		audio->drv_ops.send_data(audio, 0);
-
-		rc = wait_event_interruptible(audio->write_wait,
-			(!audio->out[0].used &&
-			!audio->out[1].used &&
-			audio->out_needed) || audio->wflush);
-
-		if (rc < 0)
-			goto done;
-		else if (audio->wflush) {
-			rc = -EBUSY;
-			goto done;
-		}
-	}
-
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		audio->teos || audio->wflush);
-
-	if (audio->wflush)
-		rc = -EBUSY;
-
-done:
-	mutex_unlock(&audio->write_lock);
-	return rc;
-}
-
-int audpcm_fsync(struct file *file, loff_t ppos1, loff_t ppos2, int datasync)
-{
-	struct audio *audio = file->private_data;
-
-	if (!audio->running)
-		return -EINVAL;
-
-	return audio->drv_ops.fsync(audio);
-}
-
-static ssize_t audio_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	size_t xfer;
-	char *cpy_ptr;
-	int rc = 0;
-	unsigned dsize;
-
-	if (audio->drv_status & ADRV_STATUS_AIO_INTF)
-		return -EPERM;
-
-	MM_DBG("cnt=%d\n", count);
-
-	mutex_lock(&audio->write_lock);
-	while (count > 0) {
-		frame = audio->out + audio->out_head;
-		cpy_ptr = frame->data;
-		dsize = 0;
-		rc = wait_event_interruptible(audio->write_wait,
-					      (frame->used == 0)
-					      || (audio->stopped)
-						  || (audio->wflush));
-		if (rc < 0)
-			break;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (audio->reserved) {
-			MM_DBG("append reserved byte %x\n", audio->rsv_byte);
-			*cpy_ptr = audio->rsv_byte;
-			xfer = (count > (frame->size - 1)) ?
-				frame->size - 1 : count;
-			cpy_ptr++;
-			dsize = 1;
-			audio->reserved = 0;
-		} else
-			xfer = (count > frame->size) ? frame->size : count;
-
-		if (copy_from_user(cpy_ptr, buf, xfer)) {
-			rc = -EFAULT;
-			break;
-		}
-
-		dsize += xfer;
-		if (dsize & 1) {
-			audio->rsv_byte = ((char *) frame->data)[dsize - 1];
-			MM_DBG("odd length buf reserve last byte %x\n",
-					audio->rsv_byte);
-			audio->reserved = 1;
-			dsize--;
-		}
-		count -= xfer;
-		buf += xfer;
-
-		if (dsize > 0) {
-			audio->out_head ^= 1;
-			frame->used = dsize;
-			audio->drv_ops.send_data(audio, 0);
-		}
-	}
-	mutex_unlock(&audio->write_lock);
-	if (buf > start)
-		return buf - start;
-
-	return rc;
-}
-
-static int audio_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	MM_INFO("audio instance 0x%08x freeing\n", (int)audio);
-
-	mutex_lock(&audio->lock);
-	auddev_unregister_evt_listner(AUDDEV_CLNT_DEC, audio->dec_id);
-	audio_disable(audio);
-	audio->drv_ops.out_flush(audio);
-
-	msm_adsp_put(audio->audplay);
-	audpp_adec_free(audio->dec_id);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	unregister_early_suspend(&audio->suspend_ctl.node);
-#endif
-	audio->opened = 0;
-	audio->event_abort = 1;
-	wake_up(&audio->event_wait);
-	audpcm_reset_event_queue(audio);
-	if (audio->data) {
-		iounmap(audio->map_v_write);
-		free_contiguous_memory_by_paddr(audio->phys);
-	}
-	mutex_unlock(&audio->lock);
-#ifdef CONFIG_DEBUG_FS
-	if (audio->dentry)
-		debugfs_remove(audio->dentry);
-#endif
-	kfree(audio);
-	return 0;
-}
-
-static void audpcm_post_event(struct audio *audio, int type,
-	union msm_audio_event_payload payload)
-{
-	struct audpcm_event *e_node = NULL;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-
-	if (!list_empty(&audio->free_event_queue)) {
-		e_node = list_first_entry(&audio->free_event_queue,
-			struct audpcm_event, list);
-		list_del(&e_node->list);
-	} else {
-		e_node = kmalloc(sizeof(struct audpcm_event), GFP_ATOMIC);
-		if (!e_node) {
-			MM_ERR("No mem to post event %d\n", type);
-			return;
-		}
-	}
-
-	e_node->event_type = type;
-	e_node->payload = payload;
-
-	list_add_tail(&e_node->list, &audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	wake_up(&audio->event_wait);
-}
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audpcm_suspend(struct early_suspend *h)
-{
-	struct audpcm_suspend_ctl *ctl =
-		container_of(h, struct audpcm_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audpcm_post_event(ctl->audio, AUDIO_EVENT_SUSPEND, payload);
-}
-
-static void audpcm_resume(struct early_suspend *h)
-{
-	struct audpcm_suspend_ctl *ctl =
-		container_of(h, struct audpcm_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audpcm_post_event(ctl->audio, AUDIO_EVENT_RESUME, payload);
-}
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-static ssize_t audpcm_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static ssize_t audpcm_debug_read(struct file *file, char __user *buf,
-			  size_t count, loff_t *ppos)
-{
-	const int debug_bufmax = 4096;
-	static char buffer[4096];
-	int n = 0;
-	struct audio *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	n = scnprintf(buffer, debug_bufmax, "opened %d\n", audio->opened);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "enabled %d\n", audio->enabled);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "stopped %d\n", audio->stopped);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_buf_sz %d\n", audio->out[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "volume %x \n", audio->volume);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "sample rate %d \n", audio->out_sample_rate);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-		"channel mode %d \n", audio->out_channel_mode);
-	mutex_unlock(&audio->lock);
-	/* Following variables are only useful for debugging when
-	 * when playback halts unexpectedly. Thus, no mutual exclusion
-	 * enforced
-	 */
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "wflush %d\n", audio->wflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "running %d \n", audio->running);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				"dec state %d \n", audio->dec_state);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_needed %d \n", audio->out_needed);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_head %d \n", audio->out_head);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_tail %d \n", audio->out_tail);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out[0].used %d \n", audio->out[0].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out[1].used %d \n", audio->out[1].used);
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations audpcm_debug_fops = {
-	.read = audpcm_debug_read,
-	.open = audpcm_debug_open,
-};
-#endif
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = NULL;
-	int rc, i, dec_attrb, decid;
-	struct audpcm_event *e_node = NULL;
-	unsigned pmem_sz = DMASZ_MAX;
-
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_pcm_dec_" + 5];
-#endif
-
-	/* Allocate audio instance, set to zero */
-	audio = kzalloc(sizeof(struct audio), GFP_KERNEL);
-	if (!audio) {
-		MM_ERR("no memory to allocate audio instance \n");
-		rc = -ENOMEM;
-		goto done;
-	}
-	MM_INFO("audio instance 0x%08x created\n", (int)audio);
-
-	/* Allocate the decoder */
-	dec_attrb = AUDDEC_DEC_PCM;
-	if (file->f_mode & FMODE_READ) {
-		MM_ERR("Non-Tunneled mode not supported\n");
-		rc = -EPERM;
-		kfree(audio);
-		goto done;
-	} else
-		dec_attrb |= MSM_AUD_MODE_TUNNEL;
-
-	decid = audpp_adec_alloc(dec_attrb, &audio->module_name,
-			&audio->queue_id);
-	if (decid < 0) {
-		MM_ERR("No free decoder available, freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENODEV;
-		kfree(audio);
-		goto done;
-	}
-	audio->dec_id = decid & MSM_AUD_DECODER_MASK;
-
-	/* AIO interface */
-	if (file->f_flags & O_NONBLOCK) {
-		MM_DBG("set to aio interface\n");
-		audio->drv_status |= ADRV_STATUS_AIO_INTF;
-		audio->drv_ops.send_data = audpcm_async_send_data;
-		audio->drv_ops.out_flush = audpcm_async_flush;
-		audio->drv_ops.fsync = audpcm_async_fsync;
-	} else {
-		MM_DBG("set to std io interface\n");
-		while (pmem_sz >= DMASZ_MIN) {
-			MM_DBG("pmemsz = %d\n", pmem_sz);
-			audio->phys = allocate_contiguous_ebi_nomap(pmem_sz,
-								SZ_4K);
-			if (audio->phys) {
-				audio->map_v_write = ioremap(
-							audio->phys, pmem_sz);
-				if (IS_ERR(audio->map_v_write)) {
-					MM_ERR("could not map write phys\
-						address freeing instance \
-						0x%08x\n", (int)audio);
-					rc = -ENOMEM;
-					free_contiguous_memory_by_paddr(
-								audio->phys);
-					audpp_adec_free(audio->dec_id);
-					kfree(audio);
-					goto done;
-				}
-				audio->data = audio->map_v_write;
-				MM_DBG("write buf: phy addr 0x%08x \
-						kernel addr 0x%08x\n",
-						audio->phys, (int)audio->data);
-				break;
-			} else if (pmem_sz == DMASZ_MIN) {
-				MM_ERR("could not allocate write buffers \
-					freeing instance 0x%08x\n", (int)audio);
-				rc = -ENOMEM;
-				audpp_adec_free(audio->dec_id);
-				kfree(audio);
-				goto done;
-			} else
-				pmem_sz >>= 1;
-		}
-		audio->out_dma_sz = pmem_sz;
-		audio->drv_ops.send_data = audplay_send_data;
-		audio->drv_ops.out_flush = audio_flush;
-		audio->drv_ops.fsync = audpcm_sync_fsync;
-		audio->out[0].data = audio->data + 0;
-		audio->out[0].addr = audio->phys + 0;
-		audio->out[0].size = (audio->out_dma_sz >> 1);
-
-		audio->out[1].data = audio->data + audio->out[0].size;
-		audio->out[1].addr = audio->phys + audio->out[0].size;
-		audio->out[1].size = audio->out[0].size;
-	}
-
-	rc = msm_adsp_get(audio->module_name, &audio->audplay,
-			&audpcmdec_adsp_ops, audio);
-	if (rc) {
-		MM_ERR("failed to get %s module, freeing instance 0x%08x\n",
-				audio->module_name, (int)audio);
-		goto err;
-	}
-
-	/* Initialize all locks of audio instance */
-	mutex_init(&audio->lock);
-	mutex_init(&audio->write_lock);
-	mutex_init(&audio->get_event_lock);
-	spin_lock_init(&audio->dsp_lock);
-	init_waitqueue_head(&audio->write_wait);
-	INIT_LIST_HEAD(&audio->out_queue);
-	INIT_LIST_HEAD(&audio->pmem_region_queue);
-	INIT_LIST_HEAD(&audio->free_event_queue);
-	INIT_LIST_HEAD(&audio->event_queue);
-	init_waitqueue_head(&audio->wait);
-	init_waitqueue_head(&audio->event_wait);
-	spin_lock_init(&audio->event_queue_lock);
-	init_waitqueue_head(&audio->avsync_wait);
-
-	audio->out_sample_rate = 44100;
-	audio->out_channel_mode = AUDPP_CMD_PCM_INTF_STEREO_V;
-	audio->out_bits = AUDPP_CMD_WAV_PCM_WIDTH_16;
-	audio->volume = 0x7FFF;
-	audio->drv_ops.out_flush(audio);
-
-	file->private_data = audio;
-	audio->opened = 1;
-
-	audio->device_events = AUDDEV_EVT_DEV_RDY
-				|AUDDEV_EVT_DEV_RLS|
-				AUDDEV_EVT_STREAM_VOL_CHG;
-
-	rc = auddev_register_evt_listner(audio->device_events,
-					AUDDEV_CLNT_DEC,
-					audio->dec_id,
-					pcm_listner,
-					(void *)audio);
-	if (rc) {
-		MM_ERR("failed to register listnet\n");
-		goto event_err;
-	}
-
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof name, "msm_pcm_dec_%04x", audio->dec_id);
-	audio->dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
-		NULL, (void *) audio, &audpcm_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		MM_ERR("debugfs_create_file failed\n");
-#endif
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	audio->suspend_ctl.node.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
-	audio->suspend_ctl.node.resume = audpcm_resume;
-	audio->suspend_ctl.node.suspend = audpcm_suspend;
-	audio->suspend_ctl.audio = audio;
-	register_early_suspend(&audio->suspend_ctl.node);
-#endif
-	for (i = 0; i < AUDPCM_EVENT_NUM; i++) {
-		e_node = kmalloc(sizeof(struct audpcm_event), GFP_KERNEL);
-		if (e_node)
-			list_add_tail(&e_node->list, &audio->free_event_queue);
-		else {
-			MM_ERR("event pkt alloc failed\n");
-			break;
-		}
-	}
-done:
-	return rc;
-event_err:
-	msm_adsp_put(audio->audplay);
-err:
-	if (audio->data) {
-		iounmap(audio->map_v_write);
-		free_contiguous_memory_by_paddr(audio->phys);
-	}
-	audpp_adec_free(audio->dec_id);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_pcm_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audio_open,
-	.release	= audio_release,
-	.write		= audio_write,
-	.unlocked_ioctl	= audio_ioctl,
-	.fsync = audpcm_fsync,
-};
-
-struct miscdevice audio_pcm_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_pcm_dec",
-	.fops	= &audio_pcm_fops,
-};
-
-static int __init audio_init(void)
-{
-	return misc_register(&audio_pcm_misc);
-}
-
-device_initcall(audio_init);
diff --git a/arch/arm/mach-msm/qdsp5v2/audio_pcm_in.c b/arch/arm/mach-msm/qdsp5v2/audio_pcm_in.c
deleted file mode 100644
index ff3a696..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audio_pcm_in.c
+++ /dev/null
@@ -1,1027 +0,0 @@
-/*
- * pcm audio input device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2009-2012, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/msm_audio.h>
-#include <linux/msm_ion.h>
-#include <linux/memory_alloc.h>
-#include <mach/msm_memtypes.h>
-
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-
-#include <mach/msm_adsp.h>
-#include <mach/socinfo.h>
-#include <mach/qdsp5v2/qdsp5audreccmdi.h>
-#include <mach/qdsp5v2/qdsp5audrecmsg.h>
-#include <mach/qdsp5v2/audpreproc.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/debug_mm.h>
-#include <mach/qdsp5v2/audio_acdbi.h>
-
-/* FRAME_NUM must be a power of two */
-#define FRAME_NUM		(8)
-#define FRAME_HEADER_SIZE       (8) /*4 half words*/
-/* size of a mono frame with 256 samples */
-#define MONO_DATA_SIZE_256	(512) /* in bytes*/
-/*size of a mono frame with 512 samples */
-#define MONO_DATA_SIZE_512	(1024) /* in bytes*/
-/*size of a mono frame with 1024 samples */
-#define MONO_DATA_SIZE_1024	(2048) /* in bytes */
-
-/*size of a stereo frame with 256 samples per channel */
-#define STEREO_DATA_SIZE_256	(1024) /* in bytes*/
-/*size of a stereo frame with 512 samples per channel */
-#define STEREO_DATA_SIZE_512	(2048) /* in bytes*/
-/*size of a stereo frame with 1024 samples per channel */
-#define STEREO_DATA_SIZE_1024	(4096) /* in bytes */
-
-#define MAX_FRAME_SIZE		((STEREO_DATA_SIZE_1024) + FRAME_HEADER_SIZE)
-#define DMASZ			(MAX_FRAME_SIZE * FRAME_NUM)
-
-struct buffer {
-	void *data;
-	uint32_t size;
-	uint32_t read;
-	uint32_t addr;
-};
-
-struct audio_in {
-	struct buffer in[FRAME_NUM];
-
-	spinlock_t dsp_lock;
-
-	atomic_t in_bytes;
-	atomic_t in_samples;
-
-	struct mutex lock;
-	struct mutex read_lock;
-	wait_queue_head_t wait;
-	wait_queue_head_t wait_enable;
-
-	struct msm_adsp_module *audrec;
-
-	/* configuration to use on next enable */
-	uint32_t samp_rate;
-	uint32_t channel_mode;
-	uint32_t buffer_size; /* 2048 for mono, 4096 for stereo */
-	uint32_t enc_type;
-
-	uint32_t dsp_cnt;
-	uint32_t in_head; /* next buffer dsp will write */
-	uint32_t in_tail; /* next buffer read() will read */
-	uint32_t in_count; /* number of buffers available to read() */
-	uint32_t mode;
-
-	const char *module_name;
-	unsigned queue_ids;
-	uint16_t enc_id; /* Session Id */
-
-	uint16_t source; /* Encoding source bit mask */
-	uint32_t device_events; /* device events interested in */
-	uint32_t in_call;
-	uint32_t dev_cnt;
-	int voice_state;
-	spinlock_t dev_lock;
-
-	struct audrec_session_info session_info; /*audrec session info*/
-	/* data allocated for various buffers */
-	char *data;
-	dma_addr_t phys;
-	void *map_v_read;
-
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped, cleared on flush */
-	int abort; /* set when error, like sample rate mismatch */
-	int dual_mic_config;
-	char *build_id;
-	struct ion_client *client;
-	struct ion_handle *output_buff_handle;
-};
-
-static struct audio_in the_audio_in;
-
-struct audio_frame {
-	uint16_t frame_count_lsw;
-	uint16_t frame_count_msw;
-	uint16_t frame_length;
-	uint16_t erased_pcm;
-	unsigned char raw_bitstream[]; /* samples */
-} __attribute__((packed));
-
-/* Audrec Queue command sent macro's */
-#define audrec_send_bitstreamqueue(audio, cmd, len) \
-	msm_adsp_write(audio->audrec, ((audio->queue_ids & 0xFFFF0000) >> 16),\
-			cmd, len)
-
-#define audrec_send_audrecqueue(audio, cmd, len) \
-	msm_adsp_write(audio->audrec, (audio->queue_ids & 0x0000FFFF),\
-			cmd, len)
-
-/* DSP command send functions */
-static int audpcm_in_enc_config(struct audio_in *audio, int enable);
-static int audpcm_in_param_config(struct audio_in *audio);
-static int audpcm_in_mem_config(struct audio_in *audio);
-static int audpcm_in_record_config(struct audio_in *audio, int enable);
-static int audpcm_dsp_read_buffer(struct audio_in *audio, uint32_t read_cnt);
-
-static void audpcm_in_get_dsp_frames(struct audio_in *audio);
-
-static void audpcm_in_flush(struct audio_in *audio);
-
-static void pcm_in_listener(u32 evt_id, union auddev_evt_data *evt_payload,
-				void *private_data)
-{
-	struct audio_in *audio = (struct audio_in *) private_data;
-	unsigned long flags;
-
-	MM_DBG("evt_id = 0x%8x\n", evt_id);
-	switch (evt_id) {
-	case AUDDEV_EVT_DEV_RDY: {
-		MM_DBG("AUDDEV_EVT_DEV_RDY\n");
-		spin_lock_irqsave(&audio->dev_lock, flags);
-		audio->dev_cnt++;
-		if (!audio->in_call)
-			audio->source |= (0x1 << evt_payload->routing_id);
-		spin_unlock_irqrestore(&audio->dev_lock, flags);
-
-		if ((audio->running == 1) && (audio->enabled == 1))
-			audpcm_in_record_config(audio, 1);
-
-		break;
-	}
-	case AUDDEV_EVT_DEV_RLS: {
-		MM_DBG("AUDDEV_EVT_DEV_RLS\n");
-		spin_lock_irqsave(&audio->dev_lock, flags);
-		audio->dev_cnt--;
-		if (!audio->in_call)
-			audio->source &= ~(0x1 << evt_payload->routing_id);
-		spin_unlock_irqrestore(&audio->dev_lock, flags);
-
-		if (!audio->running || !audio->enabled)
-			break;
-
-		/* Turn of as per source */
-		if (audio->source)
-			audpcm_in_record_config(audio, 1);
-		else
-			/* Turn off all */
-			audpcm_in_record_config(audio, 0);
-
-		break;
-	}
-	case AUDDEV_EVT_VOICE_STATE_CHG: {
-		MM_DBG("AUDDEV_EVT_VOICE_STATE_CHG, state = %d\n",
-				evt_payload->voice_state);
-		audio->voice_state = evt_payload->voice_state;
-		if (audio->in_call && audio->running) {
-			if (audio->voice_state == VOICE_STATE_INCALL)
-				audpcm_in_record_config(audio, 1);
-			else if (audio->voice_state == VOICE_STATE_OFFCALL) {
-				audpcm_in_record_config(audio, 0);
-				wake_up(&audio->wait);
-			}
-		}
-		break;
-	}
-	case AUDDEV_EVT_FREQ_CHG: {
-		MM_DBG("Encoder Driver got sample rate change event\n");
-		MM_DBG("sample rate %d\n", evt_payload->freq_info.sample_rate);
-		MM_DBG("dev_type %d\n", evt_payload->freq_info.dev_type);
-		MM_DBG("acdb_dev_id %d\n", evt_payload->freq_info.acdb_dev_id);
-		if (audio->running == 1) {
-			/* Stop Recording sample rate does not match
-			   with device sample rate */
-			if (evt_payload->freq_info.sample_rate !=
-				audio->samp_rate) {
-				audpcm_in_record_config(audio, 0);
-				audio->abort = 1;
-				wake_up(&audio->wait);
-			}
-		}
-		break;
-	}
-	default:
-		MM_ERR("wrong event %d\n", evt_id);
-		break;
-	}
-}
-
-/* ------------------- dsp preproc event handler--------------------- */
-static void audpreproc_dsp_event(void *data, unsigned id,  void *msg)
-{
-	struct audio_in *audio = data;
-
-	switch (id) {
-	case AUDPREPROC_ERROR_MSG: {
-		struct audpreproc_err_msg *err_msg = msg;
-
-		MM_ERR("ERROR_MSG: stream id %d err idx %d\n",
-		err_msg->stream_id, err_msg->aud_preproc_err_idx);
-		/* Error case */
-		wake_up(&audio->wait_enable);
-		break;
-	}
-	case AUDPREPROC_CMD_CFG_DONE_MSG: {
-		MM_DBG("CMD_CFG_DONE_MSG \n");
-		break;
-	}
-	case AUDPREPROC_CMD_ENC_CFG_DONE_MSG: {
-		struct audpreproc_cmd_enc_cfg_done_msg *enc_cfg_msg = msg;
-
-		MM_DBG("CMD_ENC_CFG_DONE_MSG: stream id %d enc type \
-			0x%8x\n", enc_cfg_msg->stream_id,
-			enc_cfg_msg->rec_enc_type);
-		/* Encoder enable success */
-		if (enc_cfg_msg->rec_enc_type & ENCODE_ENABLE)
-			audpcm_in_param_config(audio);
-		else { /* Encoder disable success */
-			audio->running = 0;
-			audpcm_in_record_config(audio, 0);
-		}
-		break;
-	}
-	case AUDPREPROC_CMD_ENC_PARAM_CFG_DONE_MSG: {
-		MM_DBG("CMD_ENC_PARAM_CFG_DONE_MSG \n");
-		audpcm_in_mem_config(audio);
-		break;
-	}
-	case AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG_DONE_MSG: {
-		MM_DBG("AFE_CMD_AUDIO_RECORD_CFG_DONE_MSG \n");
-		wake_up(&audio->wait_enable);
-		break;
-	}
-	default:
-		MM_ERR("Unknown Event id %d\n", id);
-	}
-}
-
-/* ------------------- dsp audrec event handler--------------------- */
-static void audrec_dsp_event(void *data, unsigned id, size_t len,
-			    void (*getevent)(void *ptr, size_t len))
-{
-	struct audio_in *audio = data;
-
-	switch (id) {
-	case AUDREC_CMD_MEM_CFG_DONE_MSG: {
-		MM_DBG("CMD_MEM_CFG_DONE MSG DONE\n");
-		audio->running = 1;
-		if ((!audio->in_call && (audio->dev_cnt > 0)) ||
-			(audio->in_call &&
-				(audio->voice_state == VOICE_STATE_INCALL)))
-			audpcm_in_record_config(audio, 1);
-		break;
-	}
-	case AUDREC_FATAL_ERR_MSG: {
-		struct audrec_fatal_err_msg fatal_err_msg;
-
-		getevent(&fatal_err_msg, AUDREC_FATAL_ERR_MSG_LEN);
-		MM_ERR("FATAL_ERR_MSG: err id %d\n",
-				fatal_err_msg.audrec_err_id);
-		/* Error stop the encoder */
-		audio->stopped = 1;
-		wake_up(&audio->wait);
-		break;
-	}
-	case AUDREC_UP_PACKET_READY_MSG: {
-		struct audrec_up_pkt_ready_msg pkt_ready_msg;
-
-		getevent(&pkt_ready_msg, AUDREC_UP_PACKET_READY_MSG_LEN);
-		MM_DBG("UP_PACKET_READY_MSG: write cnt lsw  %d \
-		write cnt msw %d read cnt lsw %d  read cnt msw %d \n",\
-		pkt_ready_msg.audrec_packet_write_cnt_lsw, \
-		pkt_ready_msg.audrec_packet_write_cnt_msw, \
-		pkt_ready_msg.audrec_up_prev_read_cnt_lsw, \
-		pkt_ready_msg.audrec_up_prev_read_cnt_msw);
-
-		audpcm_in_get_dsp_frames(audio);
-		break;
-	}
-	case ADSP_MESSAGE_ID: {
-		MM_DBG("Received ADSP event :module audrectask\n");
-		break;
-	}
-	default:
-		MM_ERR("Unknown Event id %d\n", id);
-	}
-}
-
-static void audpcm_in_get_dsp_frames(struct audio_in *audio)
-{
-	struct audio_frame *frame;
-	uint32_t index;
-	unsigned long flags;
-
-	index = audio->in_head;
-
-	frame = (void *) (((char *)audio->in[index].data) - \
-			 sizeof(*frame));
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->in[index].size = frame->frame_length;
-
-	/* statistics of read */
-	atomic_add(audio->in[index].size, &audio->in_bytes);
-	atomic_add(1, &audio->in_samples);
-
-	audio->in_head = (audio->in_head + 1) & (FRAME_NUM - 1);
-
-	/* If overflow, move the tail index foward. */
-	if (audio->in_head == audio->in_tail)
-		audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
-	else
-		audio->in_count++;
-
-	audpcm_dsp_read_buffer(audio, audio->dsp_cnt++);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-
-	wake_up(&audio->wait);
-}
-
-struct msm_adsp_ops audrec_adsp_ops = {
-	.event = audrec_dsp_event,
-};
-
-static int audpcm_in_enc_config(struct audio_in *audio, int enable)
-{
-	struct audpreproc_audrec_cmd_enc_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	if (audio->build_id[17] == '1') {
-		cmd.cmd_id = AUDPREPROC_AUDREC_CMD_ENC_CFG_2;
-		MM_ERR("sending AUDPREPROC_AUDREC_CMD_ENC_CFG_2 command");
-	} else {
-		cmd.cmd_id = AUDPREPROC_AUDREC_CMD_ENC_CFG;
-		MM_ERR("sending AUDPREPROC_AUDREC_CMD_ENC_CFG command");
-	}
-	cmd.stream_id = audio->enc_id;
-
-	if (enable)
-		cmd.audrec_enc_type = audio->enc_type | ENCODE_ENABLE;
-	else
-		cmd.audrec_enc_type &= ~(ENCODE_ENABLE);
-
-	return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd));
-}
-
-static int audpcm_in_param_config(struct audio_in *audio)
-{
-	struct audpreproc_audrec_cmd_parm_cfg_wav cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPREPROC_AUDREC_CMD_PARAM_CFG;
-	cmd.common.stream_id = audio->enc_id;
-
-	cmd.aud_rec_samplerate_idx = audio->samp_rate;
-	if (audio->dual_mic_config)
-		cmd.aud_rec_stereo_mode = DUAL_MIC_STEREO_RECORDING;
-	else
-		cmd.aud_rec_stereo_mode = audio->channel_mode;
-
-	if (audio->channel_mode == AUDREC_CMD_MODE_MONO)
-		cmd.aud_rec_frame_size = audio->buffer_size/2;
-	else
-		cmd.aud_rec_frame_size = audio->buffer_size/4;
-	return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd));
-}
-
-/* To Do: msm_snddev_route_enc(audio->enc_id); */
-static int audpcm_in_record_config(struct audio_in *audio, int enable)
-{
-	struct audpreproc_afe_cmd_audio_record_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG;
-	cmd.stream_id = audio->enc_id;
-	if (enable)
-		cmd.destination_activity = AUDIO_RECORDING_TURN_ON;
-	else
-		cmd.destination_activity = AUDIO_RECORDING_TURN_OFF;
-
-	cmd.source_mix_mask = audio->source;
-	if (audio->enc_id == 2) {
-		if ((cmd.source_mix_mask &
-				INTERNAL_CODEC_TX_SOURCE_MIX_MASK) ||
-			(cmd.source_mix_mask & AUX_CODEC_TX_SOURCE_MIX_MASK) ||
-			(cmd.source_mix_mask & VOICE_UL_SOURCE_MIX_MASK) ||
-			(cmd.source_mix_mask & VOICE_DL_SOURCE_MIX_MASK)) {
-			cmd.pipe_id = SOURCE_PIPE_1;
-		}
-		if (cmd.source_mix_mask &
-				AUDPP_A2DP_PIPE_SOURCE_MIX_MASK)
-			cmd.pipe_id |= SOURCE_PIPE_0;
-	}
-
-	return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd));
-}
-
-static int audpcm_in_mem_config(struct audio_in *audio)
-{
-	struct audrec_cmd_arecmem_cfg cmd;
-	uint16_t *data = (void *) audio->data;
-	int n;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_MEM_CFG_CMD;
-	cmd.audrec_up_pkt_intm_count = 1;
-	cmd.audrec_ext_pkt_start_addr_msw = audio->phys >> 16;
-	cmd.audrec_ext_pkt_start_addr_lsw = audio->phys;
-	cmd.audrec_ext_pkt_buf_number = FRAME_NUM;
-
-	/* prepare buffer pointers:
-	 * Mono: 1024 samples + 4 halfword header
-	 * Stereo: 2048 samples + 4 halfword header
-	 */
-	for (n = 0; n < FRAME_NUM; n++) {
-		/* word increment*/
-		audio->in[n].data = data + (FRAME_HEADER_SIZE/2);
-		data += ((FRAME_HEADER_SIZE/2) + (audio->buffer_size/2));
-		MM_DBG("0x%8x\n", (int)(audio->in[n].data - FRAME_HEADER_SIZE));
-	}
-
-	return audrec_send_audrecqueue(audio, &cmd, sizeof(cmd));
-}
-
-static int audpcm_dsp_read_buffer(struct audio_in *audio, uint32_t read_cnt)
-{
-	struct up_audrec_packet_ext_ptr cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = UP_AUDREC_PACKET_EXT_PTR;
-	cmd.audrec_up_curr_read_count_msw = read_cnt >> 16;
-	cmd.audrec_up_curr_read_count_lsw = read_cnt;
-
-	return audrec_send_bitstreamqueue(audio, &cmd, sizeof(cmd));
-}
-
-/* must be called with audio->lock held */
-static int audpcm_in_enable(struct audio_in *audio)
-{
-	if (audio->enabled)
-		return 0;
-
-	if (audpreproc_enable(audio->enc_id, &audpreproc_dsp_event, audio)) {
-		MM_ERR("msm_adsp_enable(audpreproc) failed\n");
-		return -ENODEV;
-	}
-
-	if (msm_adsp_enable(audio->audrec)) {
-		MM_ERR("msm_adsp_enable(audrec) failed\n");
-		audpreproc_disable(audio->enc_id, audio);
-		return -ENODEV;
-	}
-	audio->enabled = 1;
-	audpcm_in_enc_config(audio, 1);
-
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audpcm_in_disable(struct audio_in *audio)
-{
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audpcm_in_enc_config(audio, 0);
-		wake_up(&audio->wait);
-		wait_event_interruptible_timeout(audio->wait_enable,
-				audio->running == 0, 1*HZ);
-		msm_adsp_disable(audio->audrec);
-		audpreproc_disable(audio->enc_id, audio);
-	}
-	return 0;
-}
-
-static void audpcm_in_flush(struct audio_in *audio)
-{
-	int i;
-
-	audio->dsp_cnt = 0;
-	audio->in_head = 0;
-	audio->in_tail = 0;
-	audio->in_count = 0;
-	for (i = 0; i < FRAME_NUM; i++) {
-		audio->in[i].size = 0;
-		audio->in[i].read = 0;
-	}
-	MM_DBG("in_bytes %d\n", atomic_read(&audio->in_bytes));
-	MM_DBG("in_samples %d\n", atomic_read(&audio->in_samples));
-	atomic_set(&audio->in_bytes, 0);
-	atomic_set(&audio->in_samples, 0);
-}
-
-/* ------------------- device --------------------- */
-static long audpcm_in_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct audio_in *audio = file->private_data;
-	int rc = 0;
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		stats.byte_count = atomic_read(&audio->in_bytes);
-		stats.sample_count = atomic_read(&audio->in_samples);
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return rc;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START: {
-		uint32_t freq;
-		/* Poll at 48KHz always */
-		freq = 48000;
-		MM_DBG("AUDIO_START\n");
-		if (audio->in_call && (audio->voice_state !=
-				VOICE_STATE_INCALL)) {
-			rc = -EPERM;
-			break;
-		}
-		rc = msm_snddev_request_freq(&freq, audio->enc_id,
-					SNDDEV_CAP_TX, AUDDEV_CLNT_ENC);
-		MM_DBG("sample rate configured %d sample rate requested %d\n",
-				freq, audio->samp_rate);
-		if (rc < 0) {
-			MM_DBG("sample rate can not be set, return code %d\n",\
-							rc);
-			msm_snddev_withdraw_freq(audio->enc_id,
-						SNDDEV_CAP_TX, AUDDEV_CLNT_ENC);
-			MM_DBG("msm_snddev_withdraw_freq\n");
-			break;
-		}
-		audio->dual_mic_config = msm_get_dual_mic_config(audio->enc_id);
-		/*DSP supports fluence block and by default ACDB layer will
-		applies the fluence pre-processing feature, if dual MIC config
-		is enabled implies client want to record pure dual MIC sample
-		for this we need to over ride the fluence pre processing
-		feature at ACDB layer to not to apply if fluence preprocessing
-		feature supported*/
-		if (audio->dual_mic_config) {
-			MM_INFO("dual MIC config = %d, over ride the fluence "
-			"feature\n", audio->dual_mic_config);
-			fluence_feature_update(audio->dual_mic_config,
-							audio->enc_id);
-		}
-		/*update aurec session info in audpreproc layer*/
-		audio->session_info.session_id = audio->enc_id;
-		audio->session_info.sampling_freq = audio->samp_rate;
-		audpreproc_update_audrec_info(&audio->session_info);
-		rc = audpcm_in_enable(audio);
-		if (!rc) {
-			rc =
-			wait_event_interruptible_timeout(audio->wait_enable,
-				audio->running != 0, 1*HZ);
-			MM_DBG("state %d rc = %d\n", audio->running, rc);
-
-			if (audio->running == 0)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		audio->stopped = 0;
-		break;
-	}
-	case AUDIO_STOP: {
-		/*reset the sampling frequency information at audpreproc layer*/
-		audio->session_info.sampling_freq = 0;
-		audpreproc_update_audrec_info(&audio->session_info);
-		rc = audpcm_in_disable(audio);
-		rc = msm_snddev_withdraw_freq(audio->enc_id,
-					SNDDEV_CAP_TX, AUDDEV_CLNT_ENC);
-		MM_DBG("msm_snddev_withdraw_freq\n");
-		audio->stopped = 1;
-		audio->abort = 0;
-		break;
-	}
-	case AUDIO_FLUSH: {
-		if (audio->stopped) {
-			/* Make sure we're stopped and we wake any threads
-			 * that might be blocked holding the read_lock.
-			 * While audio->stopped read threads will always
-			 * exit immediately.
-			 */
-			wake_up(&audio->wait);
-			mutex_lock(&audio->read_lock);
-			audpcm_in_flush(audio);
-			mutex_unlock(&audio->read_lock);
-		}
-		break;
-	}
-	case AUDIO_SET_CONFIG: {
-		struct msm_audio_config cfg;
-		if (copy_from_user(&cfg, (void *) arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (audio->build_id[17] == '1') {
-			audio->enc_type = ENC_TYPE_EXT_WAV | audio->mode;
-			if (cfg.channel_count == 1) {
-				cfg.channel_count = AUDREC_CMD_MODE_MONO;
-				if ((cfg.buffer_size == MONO_DATA_SIZE_256) ||
-					(cfg.buffer_size ==
-						MONO_DATA_SIZE_512) ||
-					(cfg.buffer_size ==
-						MONO_DATA_SIZE_1024)) {
-					audio->buffer_size = cfg.buffer_size;
-				} else {
-					rc = -EINVAL;
-					break;
-				}
-			} else if (cfg.channel_count == 2) {
-				cfg.channel_count = AUDREC_CMD_MODE_STEREO;
-				if ((cfg.buffer_size ==
-						STEREO_DATA_SIZE_256) ||
-					(cfg.buffer_size ==
-						STEREO_DATA_SIZE_512) ||
-					(cfg.buffer_size ==
-						STEREO_DATA_SIZE_1024)) {
-					audio->buffer_size = cfg.buffer_size;
-				} else {
-					rc = -EINVAL;
-					break;
-				}
-			} else {
-				rc = -EINVAL;
-				break;
-			}
-		} else if (audio->build_id[17] == '0') {
-			audio->enc_type = ENC_TYPE_WAV | audio->mode;
-			if (cfg.channel_count == 1) {
-				cfg.channel_count = AUDREC_CMD_MODE_MONO;
-				audio->buffer_size = MONO_DATA_SIZE_1024;
-			} else if (cfg.channel_count == 2) {
-				cfg.channel_count = AUDREC_CMD_MODE_STEREO;
-				audio->buffer_size = STEREO_DATA_SIZE_1024;
-			}
-		} else {
-			MM_ERR("wrong build_id = %s\n", audio->build_id);
-			return -ENODEV;
-		}
-		audio->samp_rate = cfg.sample_rate;
-		audio->channel_mode = cfg.channel_count;
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config cfg;
-		memset(&cfg, 0, sizeof(cfg));
-		cfg.buffer_size = audio->buffer_size;
-		cfg.buffer_count = FRAME_NUM;
-		cfg.sample_rate = audio->samp_rate;
-		if (audio->channel_mode == AUDREC_CMD_MODE_MONO)
-			cfg.channel_count = 1;
-		else
-			cfg.channel_count = 2;
-		if (copy_to_user((void *) arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		break;
-	}
-	case AUDIO_SET_INCALL: {
-		struct msm_voicerec_mode cfg;
-		unsigned long flags;
-		if (copy_from_user(&cfg, (void *) arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (cfg.rec_mode != VOC_REC_BOTH &&
-			cfg.rec_mode != VOC_REC_UPLINK &&
-			cfg.rec_mode != VOC_REC_DOWNLINK) {
-			MM_ERR("invalid rec_mode\n");
-			rc = -EINVAL;
-			break;
-		} else {
-			spin_lock_irqsave(&audio->dev_lock, flags);
-			if (cfg.rec_mode == VOC_REC_UPLINK)
-				audio->source = VOICE_UL_SOURCE_MIX_MASK;
-			else if (cfg.rec_mode == VOC_REC_DOWNLINK)
-				audio->source = VOICE_DL_SOURCE_MIX_MASK;
-			else
-				audio->source = VOICE_DL_SOURCE_MIX_MASK |
-						VOICE_UL_SOURCE_MIX_MASK ;
-			audio->in_call = 1;
-			spin_unlock_irqrestore(&audio->dev_lock, flags);
-		}
-		break;
-	}
-	case AUDIO_GET_SESSION_ID: {
-		if (copy_to_user((void *) arg, &audio->enc_id,
-			sizeof(unsigned short))) {
-			rc = -EFAULT;
-		}
-		break;
-	}
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static ssize_t audpcm_in_read(struct file *file,
-				char __user *buf,
-				size_t count, loff_t *pos)
-{
-	struct audio_in *audio = file->private_data;
-	unsigned long flags;
-	const char __user *start = buf;
-	void *data;
-	uint32_t index;
-	uint32_t size;
-	int rc = 0;
-
-	mutex_lock(&audio->read_lock);
-	while (count > 0) {
-		rc = wait_event_interruptible(
-			audio->wait, (audio->in_count > 0) || audio->stopped ||
-			audio->abort || (audio->in_call && audio->running &&
-				(audio->voice_state == VOICE_STATE_OFFCALL)));
-		if (rc < 0)
-			break;
-
-		if (!audio->in_count) {
-			if (audio->stopped) {
-				MM_DBG("Driver in stop state, No more \
-						buffer to read");
-				rc = 0;/* End of File */
-				break;
-			} else if (audio->in_call && audio->running &&
-				(audio->voice_state == VOICE_STATE_OFFCALL)) {
-				MM_DBG("Not Permitted Voice Terminated\n");
-				rc = -EPERM; /* Voice Call stopped */
-				break;
-			}
-		}
-
-		if (audio->abort) {
-			rc = -EPERM; /* Not permitted due to abort */
-			break;
-		}
-
-		index = audio->in_tail;
-		data = (uint8_t *) audio->in[index].data;
-		size = audio->in[index].size;
-		if (count >= size) {
-			if (copy_to_user(buf, data, size)) {
-				rc = -EFAULT;
-				break;
-			}
-			spin_lock_irqsave(&audio->dsp_lock, flags);
-			if (index != audio->in_tail) {
-				/* overrun -- data is
-				 * invalid and we need to retry */
-				spin_unlock_irqrestore(&audio->dsp_lock, flags);
-				continue;
-			}
-			audio->in[index].size = 0;
-			audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
-			audio->in_count--;
-			spin_unlock_irqrestore(&audio->dsp_lock, flags);
-			count -= size;
-			buf += size;
-		} else {
-			MM_ERR("short read count %d\n", count);
-			break;
-		}
-	}
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		return buf - start;
-
-	return rc;
-}
-
-static ssize_t audpcm_in_write(struct file *file,
-				const char __user *buf,
-				size_t count, loff_t *pos)
-{
-	return -EINVAL;
-}
-
-static int audpcm_in_release(struct inode *inode, struct file *file)
-{
-	struct audio_in *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	audio->in_call = 0;
-	/* with draw frequency for session
-	   incase not stopped the driver */
-	msm_snddev_withdraw_freq(audio->enc_id, SNDDEV_CAP_TX,
-					AUDDEV_CLNT_ENC);
-	auddev_unregister_evt_listner(AUDDEV_CLNT_ENC, audio->enc_id);
-	/*reset the sampling frequency information at audpreproc layer*/
-	audio->session_info.sampling_freq = 0;
-	audpreproc_update_audrec_info(&audio->session_info);
-	audpcm_in_disable(audio);
-	audpcm_in_flush(audio);
-	msm_adsp_put(audio->audrec);
-	audpreproc_aenc_free(audio->enc_id);
-	audio->audrec = NULL;
-	audio->opened = 0;
-	if (audio->data) {
-		ion_unmap_kernel(audio->client, audio->output_buff_handle);
-		ion_free(audio->client, audio->output_buff_handle);
-		audio->data = NULL;
-	}
-	ion_client_destroy(audio->client);
-	mutex_unlock(&audio->lock);
-	return 0;
-}
-
-static int audpcm_in_open(struct inode *inode, struct file *file)
-{
-	struct audio_in *audio = &the_audio_in;
-	int rc;
-	int encid;
-	int len = 0;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	struct ion_client *client = NULL;
-
-	mutex_lock(&audio->lock);
-	if (audio->opened) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	client = msm_ion_client_create(UINT_MAX, "Audio_PCM_in_client");
-	if (IS_ERR_OR_NULL(client)) {
-		MM_ERR("Unable to create ION client\n");
-			rc = -ENOMEM;
-		goto client_create_error;
-	}
-	audio->client = client;
-
-	MM_DBG("allocating mem sz = %d\n", DMASZ);
-	handle = ion_alloc(client, DMASZ, SZ_4K,
-		ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-	if (IS_ERR_OR_NULL(handle)) {
-		MM_ERR("Unable to create allocate O/P buffers\n");
-		rc = -ENOMEM;
-		goto output_buff_alloc_error;
-	}
-
-	audio->output_buff_handle = handle;
-
-	rc = ion_phys(client , handle, &addr, &len);
-	if (rc) {
-		MM_ERR("O/P buffers:Invalid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-		rc = -ENOMEM;
-		goto output_buff_get_phys_error;
-	} else {
-		MM_INFO("O/P buffers:valid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-	}
-	audio->phys = (int32_t)addr;
-
-	rc = ion_handle_get_flags(client, handle, &ionflag);
-	if (rc) {
-		MM_ERR("could not get flags for the handle\n");
-		rc = -ENOMEM;
-		goto output_buff_get_flags_error;
-	}
-
-	audio->map_v_read = ion_map_kernel(client, handle);
-	if (IS_ERR(audio->data)) {
-		MM_ERR("could not map read buffers,freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENOMEM;
-		goto output_buff_map_error;
-	}
-	MM_DBG("read buf: phy addr 0x%08x kernel addr 0x%08x\n",
-		audio->phys, (int)audio->data);
-
-	audio->data = (char *)audio->map_v_read;
-
-	MM_DBG("Memory addr = 0x%8x  phy addr = 0x%8x\n",\
-		(int) audio->data, (int) audio->phys);
-	if ((file->f_mode & FMODE_WRITE) &&
-			(file->f_mode & FMODE_READ)) {
-		rc = -EACCES;
-		MM_ERR("Non tunnel encoding is not supported\n");
-		goto done;
-	} else if (!(file->f_mode & FMODE_WRITE) &&
-					(file->f_mode & FMODE_READ)) {
-		audio->mode = MSM_AUD_ENC_MODE_TUNNEL;
-		MM_DBG("Opened for tunnel mode encoding\n");
-	} else {
-		rc = -EACCES;
-		goto done;
-	}
-	/* Settings will be re-config at AUDIO_SET_CONFIG,
-	 * but at least we need to have initial config
-	 */
-	audio->channel_mode = AUDREC_CMD_MODE_MONO;
-	audio->buffer_size = MONO_DATA_SIZE_1024;
-	audio->samp_rate = 8000;
-	audio->enc_type = ENC_TYPE_EXT_WAV | audio->mode;
-
-	encid = audpreproc_aenc_alloc(audio->enc_type, &audio->module_name,
-			&audio->queue_ids);
-	if (encid < 0) {
-		MM_ERR("No free encoder available\n");
-		rc = -ENODEV;
-		goto done;
-	}
-	audio->enc_id = encid;
-
-	rc = msm_adsp_get(audio->module_name, &audio->audrec,
-			   &audrec_adsp_ops, audio);
-
-	if (rc) {
-		audpreproc_aenc_free(audio->enc_id);
-		goto done;
-	}
-
-	audio->stopped = 0;
-	audio->source = 0;
-	audio->abort = 0;
-	audpcm_in_flush(audio);
-	audio->device_events = AUDDEV_EVT_DEV_RDY | AUDDEV_EVT_DEV_RLS |
-				AUDDEV_EVT_FREQ_CHG |
-				AUDDEV_EVT_VOICE_STATE_CHG;
-
-	audio->voice_state = msm_get_voice_state();
-	rc = auddev_register_evt_listner(audio->device_events,
-					AUDDEV_CLNT_ENC, audio->enc_id,
-					pcm_in_listener, (void *) audio);
-	if (rc) {
-		MM_ERR("failed to register device event listener\n");
-		goto evt_error;
-	}
-	file->private_data = audio;
-	audio->opened = 1;
-	rc = 0;
-	audio->build_id = socinfo_get_build_id();
-	MM_DBG("Modem build id = %s\n", audio->build_id);
-done:
-	mutex_unlock(&audio->lock);
-	return rc;
-evt_error:
-output_buff_map_error:
-output_buff_get_phys_error:
-output_buff_get_flags_error:
-	ion_free(client, audio->output_buff_handle);
-output_buff_alloc_error:
-	ion_client_destroy(client);
-client_create_error:
-	msm_adsp_put(audio->audrec);
-	audpreproc_aenc_free(audio->enc_id);
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static const struct file_operations audio_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audpcm_in_open,
-	.release	= audpcm_in_release,
-	.read		= audpcm_in_read,
-	.write		= audpcm_in_write,
-	.unlocked_ioctl	= audpcm_in_ioctl,
-};
-
-struct miscdevice audio_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_pcm_in",
-	.fops	= &audio_in_fops,
-};
-
-static int __init audpcm_in_init(void)
-{
-	mutex_init(&the_audio_in.lock);
-	mutex_init(&the_audio_in.read_lock);
-	spin_lock_init(&the_audio_in.dsp_lock);
-	spin_lock_init(&the_audio_in.dev_lock);
-	init_waitqueue_head(&the_audio_in.wait);
-	init_waitqueue_head(&the_audio_in.wait_enable);
-	return misc_register(&audio_in_misc);
-}
-
-device_initcall(audpcm_in_init);
diff --git a/arch/arm/mach-msm/qdsp5v2/audio_qcelp.c b/arch/arm/mach-msm/qdsp5v2/audio_qcelp.c
deleted file mode 100644
index 33ca7a1..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audio_qcelp.c
+++ /dev/null
@@ -1,1638 +0,0 @@
-/*
- * qcelp 13k audio decoder device
- *
- * Copyright (c) 2008-2012, The Linux Foundation. All rights reserved.
- *
- * This code is based in part on audio_mp3.c, which is
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you can find it at http://www.fsf.org.
- *
- */
-
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/earlysuspend.h>
-#include <linux/list.h>
-#include <linux/slab.h>
-#include <linux/msm_audio.h>
-#include <linux/memory_alloc.h>
-
-#include <mach/msm_adsp.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/qdsp5v2/qdsp5audppmsg.h>
-#include <mach/qdsp5v2/qdsp5audplaycmdi.h>
-#include <mach/qdsp5v2/qdsp5audplaymsg.h>
-#include <mach/qdsp5v2/audpp.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_memtypes.h>
-
-#define BUFSZ 1094 /* QCELP 13K Hold 600ms packet data = 36 * 30 and
-		      14 bytes of meta in */
-#define BUF_COUNT 2
-#define DMASZ (BUFSZ * BUF_COUNT)
-
-#define PCM_BUFSZ_MIN 1624 /* 100ms worth of data and
-			      24 bytes of meta out  */
-#define PCM_BUF_MAX_COUNT 5
-
-#define AUDDEC_DEC_QCELP 9
-
-#define	ROUTING_MODE_FTRT	1
-#define	ROUTING_MODE_RT		2
-/* Decoder status received from AUDPPTASK */
-#define	AUDPP_DEC_STATUS_SLEEP	0
-#define	AUDPP_DEC_STATUS_INIT	1
-#define	AUDPP_DEC_STATUS_CFG	2
-#define	AUDPP_DEC_STATUS_PLAY	3
-
-#define AUDQCELP_METAFIELD_MASK 0xFFFF0000
-#define AUDQCELP_EOS_FLG_OFFSET 0x0A /* Offset from beginning of buffer */
-#define AUDQCELP_EOS_FLG_MASK 0x01
-#define AUDQCELP_EOS_NONE 0x0 /* No EOS detected */
-#define AUDQCELP_EOS_SET 0x1 /* EOS set in meta field */
-
-#define AUDQCELP_EVENT_NUM 10 /* Default number of pre-allocated event pkts */
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;		/* Input usage actual DSP produced PCM size  */
-	unsigned addr;
-	unsigned short mfield_sz; /*only useful for data has meta field */
-};
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-struct audqcelp_suspend_ctl {
-	struct early_suspend node;
-	struct audio *audio;
-};
-#endif
-
-struct audqcelp_event{
-	struct list_head list;
-	int event_type;
-	union msm_audio_event_payload payload;
-};
-
-struct audio {
-	struct buffer out[BUF_COUNT];
-
-	spinlock_t dsp_lock;
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed;	/* number of buffers the dsp is waiting for */
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-
-	/* Host PCM section - START */
-	struct buffer in[PCM_BUF_MAX_COUNT];
-	struct mutex read_lock;
-	wait_queue_head_t read_wait;    /* Wait queue for read */
-	char *read_data;        /* pointer to reader buffer */
-	int32_t read_phys;   /* physical address of reader buffer */
-	uint8_t read_next;      /* index to input buffers to be read next */
-	uint8_t fill_next;      /* index to buffer that DSP should be filling */
-	uint8_t pcm_buf_count;  /* number of pcm buffer allocated */
-	/* Host PCM section - END */
-
-	struct msm_adsp_module *audplay;
-
-	/* data allocated for various buffers */
-	char *data;
-	int32_t phys; /* physical address of write buffer */
-	void *map_v_read;
-	void *map_v_write;
-
-	int mfield; /* meta field embedded in data */
-	int rflush; /* Read  flush */
-	int wflush; /* Write flush */
-	uint8_t opened:1;
-	uint8_t enabled:1;
-	uint8_t running:1;
-	uint8_t stopped:1;	/* set when stopped, cleared on flush */
-	uint8_t pcm_feedback:1; /* set when non-tunnel mode */
-	uint8_t buf_refresh:1;
-	int teos; /* valid only if tunnel mode & no data left for decoder */
-	enum msm_aud_decoder_state dec_state;	/* Represents decoder state */
-
-	const char *module_name;
-	unsigned queue_id;
-	uint16_t dec_id;
-	int16_t source;
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	struct audqcelp_suspend_ctl suspend_ctl;
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *dentry;
-#endif
-
-	wait_queue_head_t wait;
-	struct list_head free_event_queue;
-	struct list_head event_queue;
-	wait_queue_head_t event_wait;
-	spinlock_t event_queue_lock;
-	struct mutex get_event_lock;
-	int event_abort;
-	/* AV sync Info */
-	int avsync_flag;              /* Flag to indicate feedback from DSP */
-	wait_queue_head_t avsync_wait;/* Wait queue for AV Sync Message     */
-	/* flags, 48 bits sample/bytes counter per channel */
-	uint16_t avsync[AUDPP_AVSYNC_CH_COUNT * AUDPP_AVSYNC_NUM_WORDS + 1];
-
-	uint32_t device_events;
-
-	int eq_enable;
-	int eq_needs_commit;
-	struct audpp_cmd_cfg_object_params_eqalizer eq;
-	struct audpp_cmd_cfg_object_params_volume vol_pan;
-};
-
-static int auddec_dsp_config(struct audio *audio, int enable);
-static void audpp_cmd_cfg_adec_params(struct audio *audio);
-static void audpp_cmd_cfg_routing_mode(struct audio *audio);
-static void audqcelp_send_data(struct audio *audio, unsigned needed);
-static void audqcelp_config_hostpcm(struct audio *audio);
-static void audqcelp_buffer_refresh(struct audio *audio);
-static void audqcelp_dsp_event(void *private, unsigned id, uint16_t *msg);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audqcelp_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload);
-#endif
-
-/* must be called with audio->lock held */
-static int audqcelp_enable(struct audio *audio)
-{
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled)
-		return 0;
-
-	audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-
-	if (msm_adsp_enable(audio->audplay)) {
-		MM_ERR("msm_adsp_enable(audplay) failed\n");
-		return -ENODEV;
-	}
-
-	if (audpp_enable(audio->dec_id, audqcelp_dsp_event, audio)) {
-		MM_ERR("audpp_enable() failed\n");
-		msm_adsp_disable(audio->audplay);
-		return -ENODEV;
-	}
-	audio->enabled = 1;
-	return 0;
-}
-
-static void qcelp_listner(u32 evt_id, union auddev_evt_data *evt_payload,
-			void *private_data)
-{
-	struct audio *audio = (struct audio *) private_data;
-	switch (evt_id) {
-	case AUDDEV_EVT_DEV_RDY:
-		MM_DBG(":AUDDEV_EVT_DEV_RDY\n");
-		audio->source |= (0x1 << evt_payload->routing_id);
-		if (audio->running == 1 && audio->enabled == 1)
-			audpp_route_stream(audio->dec_id, audio->source);
-		break;
-	case AUDDEV_EVT_DEV_RLS:
-		MM_DBG(":AUDDEV_EVT_DEV_RLS\n");
-		audio->source &= ~(0x1 << evt_payload->routing_id);
-		if (audio->running == 1 && audio->enabled == 1)
-			audpp_route_stream(audio->dec_id, audio->source);
-		break;
-	case AUDDEV_EVT_STREAM_VOL_CHG:
-		audio->vol_pan.volume = evt_payload->session_vol;
-		MM_DBG(":AUDDEV_EVT_STREAM_VOL_CHG, stream vol %d\n",
-				audio->vol_pan.volume);
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		break;
-	default:
-		MM_ERR(":ERROR:wrong event\n");
-		break;
-	}
-}
-/* must be called with audio->lock held */
-static int audqcelp_disable(struct audio *audio)
-{
-	int rc = 0;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-		auddec_dsp_config(audio, 0);
-		rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-		if (rc == 0)
-			rc = -ETIMEDOUT;
-		else if (audio->dec_state != MSM_AUD_DECODER_STATE_CLOSE)
-			rc = -EFAULT;
-		else
-			rc = 0;
-		wake_up(&audio->write_wait);
-		wake_up(&audio->read_wait);
-		msm_adsp_disable(audio->audplay);
-		audpp_disable(audio->dec_id, audio);
-		audio->out_needed = 0;
-	}
-	return rc;
-}
-
-/* ------------------- dsp --------------------- */
-static void audqcelp_update_pcm_buf_entry(struct audio *audio,
-	uint32_t *payload)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	if (audio->rflush)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < payload[1]; index++) {
-		if (audio->in[audio->fill_next].addr ==
-			payload[2 + index * 2]) {
-			MM_DBG("in[%d] ready\n", audio->fill_next);
-			audio->in[audio->fill_next].used =
-			payload[3 + index * 2];
-			if ((++audio->fill_next) == audio->pcm_buf_count)
-				audio->fill_next = 0;
-		} else {
-			MM_ERR("expected=%x ret=%x\n",
-				audio->in[audio->fill_next].addr,
-				payload[1 + index * 2]);
-			break;
-		}
-	}
-	if (audio->in[audio->fill_next].used == 0) {
-		audqcelp_buffer_refresh(audio);
-	} else {
-		MM_DBG("read cannot keep up\n");
-		audio->buf_refresh = 1;
-	}
-	wake_up(&audio->read_wait);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audplay_dsp_event(void *data, unsigned id, size_t len,
-			      void (*getevent) (void *ptr, size_t len))
-{
-	struct audio *audio = data;
-	uint32_t msg[28];
-	getevent(msg, sizeof(msg));
-
-	MM_DBG("msg_id=%x\n", id);
-
-	switch (id) {
-	case AUDPLAY_MSG_DEC_NEEDS_DATA:
-		audqcelp_send_data(audio, 1);
-		break;
-
-	case AUDPLAY_MSG_BUFFER_UPDATE:
-		audqcelp_update_pcm_buf_entry(audio, msg);
-		break;
-
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audplaytask)\n");
-		break;
-
-	default:
-		MM_ERR("unexpected message from decoder \n");
-	}
-}
-
-static void audqcelp_dsp_event(void *private, unsigned id, uint16_t *msg)
-{
-	struct audio *audio = private;
-
-	switch (id) {
-	case AUDPP_MSG_STATUS_MSG:{
-			unsigned status = msg[1];
-
-			switch (status) {
-			case AUDPP_DEC_STATUS_SLEEP: {
-				uint16_t reason = msg[2];
-				MM_DBG("decoder status:sleep reason = \
-						0x%04x\n", reason);
-				if ((reason == AUDPP_MSG_REASON_MEM)
-					|| (reason ==
-					AUDPP_MSG_REASON_NODECODER)) {
-					audio->dec_state =
-					MSM_AUD_DECODER_STATE_FAILURE;
-					wake_up(&audio->wait);
-				} else if (reason == AUDPP_MSG_REASON_NONE) {
-					/* decoder is in disable state */
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_CLOSE;
-					wake_up(&audio->wait);
-				}
-				break;
-			}
-			case AUDPP_DEC_STATUS_INIT:
-				MM_DBG("decoder status: init \n");
-				if (audio->pcm_feedback)
-					audpp_cmd_cfg_routing_mode(audio);
-				else
-					audpp_cmd_cfg_adec_params(audio);
-				break;
-
-			case AUDPP_DEC_STATUS_CFG:
-				MM_DBG("decoder status: cfg \n");
-				break;
-			case AUDPP_DEC_STATUS_PLAY:
-				MM_DBG("decoder status: play \n");
-				/* send  mixer command */
-				audpp_route_stream(audio->dec_id,
-						audio->source);
-				if (audio->pcm_feedback) {
-					audqcelp_config_hostpcm(audio);
-					audqcelp_buffer_refresh(audio);
-				}
-				audio->dec_state =
-					MSM_AUD_DECODER_STATE_SUCCESS;
-				wake_up(&audio->wait);
-				break;
-			default:
-				MM_ERR("unknown decoder status\n");
-			}
-			break;
-		}
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_DBG("CFG_MSG ENABLE\n");
-			auddec_dsp_config(audio, 1);
-			audio->out_needed = 0;
-			audio->running = 1;
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-			audpp_dsp_set_eq(audio->dec_id,	audio->eq_enable,
-					&audio->eq, POPP);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			MM_DBG("CFG_MSG DISABLE\n");
-			audio->running = 0;
-		} else {
-			MM_DBG("CFG_MSG %d?\n", msg[0]);
-		}
-		break;
-	case AUDPP_MSG_ROUTING_ACK:
-		MM_DBG("ROUTING_ACK mode=%d\n", msg[1]);
-		audpp_cmd_cfg_adec_params(audio);
-		break;
-	case AUDPP_MSG_FLUSH_ACK:
-		MM_DBG("FLUSH_ACK\n");
-		audio->wflush = 0;
-		audio->rflush = 0;
-		wake_up(&audio->write_wait);
-		if (audio->pcm_feedback)
-			audqcelp_buffer_refresh(audio);
-		break;
-	case AUDPP_MSG_PCMDMAMISSED:
-		MM_DBG("PCMDMAMISSED\n");
-		audio->teos = 1;
-		wake_up(&audio->write_wait);
-		break;
-
-	case AUDPP_MSG_AVSYNC_MSG:
-		MM_DBG("AUDPP_MSG_AVSYNC_MSG\n");
-		memcpy(&audio->avsync[0], msg, sizeof(audio->avsync));
-		audio->avsync_flag = 1;
-		wake_up(&audio->avsync_wait);
-		break;
-
-	default:
-		MM_ERR("UNKNOWN (%d)\n", id);
-	}
-
-}
-
-struct msm_adsp_ops audplay_adsp_ops_qcelp = {
-	.event = audplay_dsp_event,
-};
-
-#define audplay_send_queue0(audio, cmd, len) \
-	msm_adsp_write(audio->audplay, audio->queue_id, \
-		cmd, len)
-
-static int auddec_dsp_config(struct audio *audio, int enable)
-{
-	struct audpp_cmd_cfg_dec_type cfg_dec_cmd;
-
-	memset(&cfg_dec_cmd, 0, sizeof(cfg_dec_cmd));
-
-	cfg_dec_cmd.cmd_id = AUDPP_CMD_CFG_DEC_TYPE;
-	if (enable)
-		cfg_dec_cmd.dec_cfg = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_ENA_DEC_V | AUDDEC_DEC_QCELP;
-	else
-		cfg_dec_cmd.dec_cfg = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_DIS_DEC_V;
-	cfg_dec_cmd.dm_mode = 0x0;
-	cfg_dec_cmd.stream_id = audio->dec_id;
-
-	return audpp_send_queue1(&cfg_dec_cmd, sizeof(cfg_dec_cmd));
-}
-
-static void audpp_cmd_cfg_adec_params(struct audio *audio)
-{
-	struct audpp_cmd_cfg_adec_params_v13k cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_CMD_CFG_ADEC_PARAMS;
-	cmd.common.length = AUDPP_CMD_CFG_ADEC_PARAMS_V13K_LEN;
-	cmd.common.dec_id = audio->dec_id;
-	cmd.common.input_sampling_frequency = 8000;
-	cmd.stereo_cfg = AUDPP_CMD_PCM_INTF_MONO_V;
-
-	audpp_send_queue2(&cmd, sizeof(cmd));
-}
-
-static void audpp_cmd_cfg_routing_mode(struct audio *audio)
-{
-	struct audpp_cmd_routing_mode cmd;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPP_CMD_ROUTING_MODE;
-	cmd.object_number = audio->dec_id;
-	if (audio->pcm_feedback)
-		cmd.routing_mode = ROUTING_MODE_FTRT;
-	else
-		cmd.routing_mode = ROUTING_MODE_RT;
-	audpp_send_queue1(&cmd, sizeof(cmd));
-}
-
-static int audplay_dsp_send_data_avail(struct audio *audio,
-				       unsigned idx, unsigned len)
-{
-	struct audplay_cmd_bitstream_data_avail_nt2 cmd;
-
-	cmd.cmd_id = AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2;
-	if (audio->mfield)
-		cmd.decoder_id = AUDQCELP_METAFIELD_MASK |
-			(audio->out[idx].mfield_sz >> 1);
-	else
-		cmd.decoder_id = audio->dec_id;
-	cmd.buf_ptr = audio->out[idx].addr;
-	cmd.buf_size = len / 2;
-	cmd.partition_number = 0;
-	return audplay_send_queue0(audio, &cmd, sizeof(cmd));
-}
-
-static void audqcelp_buffer_refresh(struct audio *audio)
-{
-	struct audplay_cmd_buffer_refresh refresh_cmd;
-
-	refresh_cmd.cmd_id = AUDPLAY_CMD_BUFFER_REFRESH;
-	refresh_cmd.num_buffers = 1;
-	refresh_cmd.buf0_address = audio->in[audio->fill_next].addr;
-	refresh_cmd.buf0_length = audio->in[audio->fill_next].size;
-	refresh_cmd.buf_read_count = 0;
-	MM_DBG("buf0_addr=%x buf0_len=%d\n", refresh_cmd.buf0_address,
-			refresh_cmd.buf0_length);
-
-	(void)audplay_send_queue0(audio, &refresh_cmd, sizeof(refresh_cmd));
-}
-
-static void audqcelp_config_hostpcm(struct audio *audio)
-{
-	struct audplay_cmd_hpcm_buf_cfg cfg_cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	cfg_cmd.cmd_id = AUDPLAY_CMD_HPCM_BUF_CFG;
-	cfg_cmd.max_buffers = 1;
-	cfg_cmd.byte_swap = 0;
-	cfg_cmd.hostpcm_config = (0x8000) | (0x4000);
-	cfg_cmd.feedback_frequency = 1;
-	cfg_cmd.partition_number = 0;
-
-	(void)audplay_send_queue0(audio, &cfg_cmd, sizeof(cfg_cmd));
-}
-
-static void audqcelp_send_data(struct audio *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			MM_DBG("frame %d free\n", audio->out_tail);
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			MM_DBG("frame %d busy\n", audio->out_tail);
-			audplay_dsp_send_data_avail(audio, audio->out_tail,
-						    frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
- done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-
-static void audqcelp_flush(struct audio *audio)
-{
-	audio->out[0].used = 0;
-	audio->out[1].used = 0;
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-}
-
-static void audqcelp_flush_pcm_buf(struct audio *audio)
-{
-	uint8_t index;
-
-	for (index = 0; index < PCM_BUF_MAX_COUNT; index++)
-		audio->in[index].used = 0;
-
-	audio->buf_refresh = 0;
-	audio->read_next = 0;
-	audio->fill_next = 0;
-}
-
-static void audqcelp_ioport_reset(struct audio *audio)
-{
-	/* Make sure read/write thread are free from
-	 * sleep and knowing that system is not able
-	 * to process io request at the moment
-	 */
-	wake_up(&audio->write_wait);
-	mutex_lock(&audio->write_lock);
-	audqcelp_flush(audio);
-	mutex_unlock(&audio->write_lock);
-	wake_up(&audio->read_wait);
-	mutex_lock(&audio->read_lock);
-	audqcelp_flush_pcm_buf(audio);
-	mutex_unlock(&audio->read_lock);
-	audio->avsync_flag = 1;
-	wake_up(&audio->avsync_wait);
-}
-
-static int audqcelp_events_pending(struct audio *audio)
-{
-	unsigned long flags;
-	int empty;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	empty = !list_empty(&audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	return empty || audio->event_abort;
-}
-
-static void audqcelp_reset_event_queue(struct audio *audio)
-{
-	unsigned long flags;
-	struct audqcelp_event *drv_evt;
-	struct list_head *ptr, *next;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	list_for_each_safe(ptr, next, &audio->event_queue) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audqcelp_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	list_for_each_safe(ptr, next, &audio->free_event_queue) {
-		drv_evt = list_first_entry(&audio->free_event_queue,
-				struct audqcelp_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	return;
-}
-
-
-static long audqcelp_process_event_req(struct audio *audio, void __user *arg)
-{
-	long rc;
-	struct msm_audio_event usr_evt;
-	struct audqcelp_event *drv_evt = NULL;
-	int timeout;
-	unsigned long flags;
-
-	if (copy_from_user(&usr_evt, arg, sizeof(struct msm_audio_event)))
-		return -EFAULT;
-
-	timeout = (int) usr_evt.timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(
-			audio->event_wait, audqcelp_events_pending(audio),
-			msecs_to_jiffies(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(
-			audio->event_wait, audqcelp_events_pending(audio));
-	}
-
-	if (rc < 0)
-		return rc;
-
-	if (audio->event_abort) {
-		audio->event_abort = 0;
-		return -ENODEV;
-	}
-
-	rc = 0;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	if (!list_empty(&audio->event_queue)) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audqcelp_event, list);
-		list_del(&drv_evt->list);
-	}
-
-	if (drv_evt) {
-		usr_evt.event_type = drv_evt->event_type;
-		usr_evt.event_payload = drv_evt->payload;
-		list_add_tail(&drv_evt->list, &audio->free_event_queue);
-	} else
-		rc = -1;
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	if (!rc && copy_to_user(arg, &usr_evt, sizeof(usr_evt)))
-		rc = -EFAULT;
-
-	return rc;
-}
-
-static int audio_enable_eq(struct audio *audio, int enable)
-{
-	if (audio->eq_enable == enable && !audio->eq_needs_commit)
-		return 0;
-
-	audio->eq_enable = enable;
-
-	if (audio->running) {
-		audpp_dsp_set_eq(audio->dec_id, enable, &audio->eq, POPP);
-		audio->eq_needs_commit = 0;
-	}
-	return 0;
-}
-
-static int audio_get_avsync_data(struct audio *audio,
-						struct msm_audio_stats *stats)
-{
-	int rc = -EINVAL;
-	unsigned long flags;
-
-	local_irq_save(flags);
-	if (audio->dec_id == audio->avsync[0] && audio->avsync_flag) {
-		/* av_sync sample count */
-		stats->sample_count = (audio->avsync[2] << 16) |
-						(audio->avsync[3]);
-
-		/* av_sync byte_count */
-		stats->byte_count = (audio->avsync[5] << 16) |
-						(audio->avsync[6]);
-
-		audio->avsync_flag = 0;
-		rc = 0;
-	}
-	local_irq_restore(flags);
-	return rc;
-
-}
-
-static long audqcelp_ioctl(struct file *file, unsigned int cmd,
-		unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = -EINVAL;
-	unsigned long flags = 0;
-	uint16_t enable_mask;
-	int enable;
-	int prev_state;
-
-	MM_DBG("cmd = %d\n", cmd);
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-
-		audio->avsync_flag = 0;
-		memset(&stats, 0, sizeof(stats));
-		if (audpp_query_avsync(audio->dec_id) < 0)
-			return rc;
-
-		rc = wait_event_interruptible_timeout(audio->avsync_wait,
-				(audio->avsync_flag == 1),
-				msecs_to_jiffies(AUDPP_AVSYNC_EVENT_TIMEOUT));
-
-		if (rc < 0)
-			return rc;
-		else if ((rc > 0) || ((rc == 0) && (audio->avsync_flag == 1))) {
-			if (audio_get_avsync_data(audio, &stats) < 0)
-				return rc;
-
-			if (copy_to_user((void *)arg, &stats, sizeof(stats)))
-				return -EFAULT;
-			return 0;
-		} else
-			return -EAGAIN;
-	}
-
-	switch (cmd) {
-	case AUDIO_ENABLE_AUDPP:
-		if (copy_from_user(&enable_mask, (void *) arg,
-						sizeof(enable_mask))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		enable = (enable_mask & EQ_ENABLE) ? 1 : 0;
-		audio_enable_eq(audio, enable);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-	case AUDIO_SET_VOLUME:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.volume = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_PAN:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.pan = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_EQ:
-		prev_state = audio->eq_enable;
-		audio->eq_enable = 0;
-		if (copy_from_user(&audio->eq.num_bands, (void *) arg,
-				sizeof(audio->eq) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2))) {
-			rc = -EFAULT;
-			break;
-		}
-		audio->eq_enable = prev_state;
-		audio->eq_needs_commit = 1;
-		rc = 0;
-		break;
-	}
-
-	if (-EINVAL != rc)
-		return rc;
-
-	if (cmd == AUDIO_GET_EVENT) {
-		MM_DBG("AUDIO_GET_EVENT\n");
-		if (mutex_trylock(&audio->get_event_lock)) {
-			rc = audqcelp_process_event_req(audio,
-					(void __user *) arg);
-			mutex_unlock(&audio->get_event_lock);
-		} else
-			rc = -EBUSY;
-		return rc;
-	}
-
-	if (cmd == AUDIO_ABORT_GET_EVENT) {
-		audio->event_abort = 1;
-		wake_up(&audio->event_wait);
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		MM_DBG("AUDIO_START\n");
-		rc = audqcelp_enable(audio);
-		if (!rc) {
-			rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-			MM_INFO("dec_state %d rc = %d\n", audio->dec_state, rc);
-
-			if (audio->dec_state != MSM_AUD_DECODER_STATE_SUCCESS)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		break;
-	case AUDIO_STOP:
-		MM_DBG("AUDIO_STOP\n");
-		rc = audqcelp_disable(audio);
-		audio->stopped = 1;
-		audqcelp_ioport_reset(audio);
-		audio->stopped = 0;
-		break;
-	case AUDIO_FLUSH:
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audqcelp_ioport_reset(audio);
-		if (audio->running) {
-			audpp_flush(audio->dec_id);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-	case AUDIO_SET_CONFIG:{
-			struct msm_audio_config config;
-			if (copy_from_user(&config, (void *)arg,
-				sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-			audio->mfield = config.meta_field;
-			MM_DBG("AUDIO_SET_CONFIG applicable \
-				for metafield configuration\n");
-			rc = 0;
-			break;
-		}
-	case AUDIO_GET_CONFIG:{
-			struct msm_audio_config config;
-			config.buffer_size = BUFSZ;
-			config.buffer_count = BUF_COUNT;
-			config.sample_rate = 8000;
-			config.channel_count = 1;
-			config.meta_field = 0;
-			config.unused[0] = 0;
-			config.unused[1] = 0;
-			config.unused[2] = 0;
-			if (copy_to_user((void *)arg, &config,
-					 sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-
-			break;
-		}
-	case AUDIO_GET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-
-			config.pcm_feedback = audio->pcm_feedback;
-			config.buffer_count = PCM_BUF_MAX_COUNT;
-			config.buffer_size = PCM_BUFSZ_MIN;
-			if (copy_to_user((void *)arg, &config,
-				sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_SET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-
-			if (copy_from_user(&config, (void *)arg,
-				sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-			if (config.pcm_feedback != audio->pcm_feedback) {
-				MM_ERR("Not sufficient permission to"
-					 "change the playback mode\n");
-				rc = -EACCES;
-				break;
-			}
-			if ((config.buffer_count > PCM_BUF_MAX_COUNT) ||
-				(config.buffer_count == 1))
-				config.buffer_count = PCM_BUF_MAX_COUNT;
-
-			if (config.buffer_size < PCM_BUFSZ_MIN)
-				config.buffer_size = PCM_BUFSZ_MIN;
-
-			/* Check if pcm feedback is required */
-			if ((config.pcm_feedback) && (!audio->read_data)) {
-				MM_DBG("allocate PCM buf %d\n",
-				config.buffer_count * config.buffer_size);
-				audio->read_phys =
-						allocate_contiguous_ebi_nomap(
-							config.buffer_size *
-							config.buffer_count,
-							SZ_4K);
-				if (!audio->read_phys) {
-					rc = -ENOMEM;
-					break;
-				}
-				audio->map_v_read = ioremap(
-							audio->read_phys,
-							config.buffer_size *
-							config.buffer_count);
-				if (IS_ERR(audio->map_v_read)) {
-					MM_ERR("failed to map read buf\n");
-					rc = -ENOMEM;
-					free_contiguous_memory_by_paddr(
-							audio->read_phys);
-				} else {
-					uint8_t index;
-					uint32_t offset = 0;
-					audio->read_data =
-						audio->map_v_read;
-					audio->buf_refresh = 0;
-					audio->pcm_buf_count =
-						config.buffer_count;
-					audio->read_next = 0;
-					audio->fill_next = 0;
-
-					for (index = 0;
-					index < config.buffer_count; index++) {
-						audio->in[index].data =
-						audio->read_data + offset;
-						audio->in[index].addr =
-						audio->read_phys + offset;
-						audio->in[index].size =
-						config.buffer_size;
-						audio->in[index].used = 0;
-						offset += config.buffer_size;
-					}
-					MM_DBG("read buf: phy addr 0x%08x \
-						kernel addr 0x%08x\n",
-						audio->read_phys,
-						(int)audio->read_data);
-					rc = 0;
-				}
-			} else {
-				rc = 0;
-			}
-			break;
-		}
-	case AUDIO_PAUSE:
-		MM_DBG("AUDIO_PAUSE %ld\n", arg);
-		rc = audpp_pause(audio->dec_id, (int) arg);
-		break;
-	case AUDIO_GET_SESSION_ID:
-		if (copy_to_user((void *) arg, &audio->dec_id,
-				sizeof(unsigned short)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-/* Only useful in tunnel-mode */
-static int audqcelp_fsync(struct file *file, loff_t ppos1, loff_t ppos2, int datasync)
-{
-	struct audio *audio = file->private_data;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (!audio->running || audio->pcm_feedback) {
-		rc = -EINVAL;
-		goto done_nolock;
-	}
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(!audio->out[0].used &&
-		!audio->out[1].used &&
-		audio->out_needed) || audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		audio->teos || audio->wflush);
-
-	if (audio->wflush)
-		rc = -EBUSY;
-
-done:
-	mutex_unlock(&audio->write_lock);
-done_nolock:
-	return rc;
-}
-
-static ssize_t audqcelp_read(struct file *file, char __user *buf, size_t count,
-			loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	int rc = 0;
-
-	if (!audio->pcm_feedback)
-		return 0; /* PCM feedback is not enabled. Nothing to read */
-
-	mutex_lock(&audio->read_lock);
-	MM_DBG("%d\n", count);
-	while (count > 0) {
-		rc = wait_event_interruptible(audio->read_wait,
-				(audio->in[audio->read_next].used > 0) ||
-				(audio->stopped) || (audio->rflush));
-		if (rc < 0)
-			break;
-
-		if (audio->stopped || audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (count < audio->in[audio->read_next].used) {
-			/* Read must happen in frame boundary. Since driver does
-			not know frame size, read count must be greater or equal
-			to size of PCM samples */
-			MM_DBG("read stop - partial frame\n");
-			break;
-		} else {
-			MM_DBG("read from in[%d]\n", audio->read_next);
-
-			if (copy_to_user(buf,
-				audio->in[audio->read_next].data,
-				audio->in[audio->read_next].used)) {
-				MM_ERR("invalid addr %x\n", (unsigned int)buf);
-				rc = -EFAULT;
-				break;
-			}
-			count -= audio->in[audio->read_next].used;
-			buf += audio->in[audio->read_next].used;
-			audio->in[audio->read_next].used = 0;
-			if ((++audio->read_next) == audio->pcm_buf_count)
-				audio->read_next = 0;
-			break;
-				/* Force to exit while loop
-				 * to prevent output thread
-				 * sleep too long if data is
-				 * not ready at this moment.
-				 */
-		}
-	}
-
-	/* don't feed output buffer to HW decoder during flushing
-	 * buffer refresh command will be sent once flush completes
-	 * send buf refresh command here can confuse HW decoder
-	 */
-	if (audio->buf_refresh && !audio->rflush) {
-		audio->buf_refresh = 0;
-		MM_DBG("kick start pcm feedback again\n");
-		audqcelp_buffer_refresh(audio);
-	}
-
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		rc = buf - start;
-
-	MM_DBG("read %d bytes\n", rc);
-	return rc;
-}
-
-static int audqcelp_process_eos(struct audio *audio,
-		const char __user *buf_start, unsigned short mfield_size)
-{
-	struct buffer *frame;
-	int rc = 0;
-
-	frame = audio->out + audio->out_head;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	audqcelp_send_data(audio, 0);
-
-done:
-	return rc;
-}
-
-static ssize_t audqcelp_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	size_t xfer;
-	char *cpy_ptr;
-	int rc = 0, eos_condition = AUDQCELP_EOS_NONE;
-	unsigned short mfield_size = 0;
-
-	MM_DBG("cnt=%d\n", count);
-
-	if (count & 1)
-		return -EINVAL;
-
-	mutex_lock(&audio->write_lock);
-	while (count > 0) {
-		frame = audio->out + audio->out_head;
-		cpy_ptr = frame->data;
-		rc = wait_event_interruptible(audio->write_wait,
-					      (frame->used == 0)
-						|| (audio->stopped)
-						|| (audio->wflush));
-		MM_DBG("buffer available\n");
-		if (rc < 0)
-			break;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (audio->mfield) {
-			if (buf == start) {
-				/* Processing beginning of user buffer */
-				if (__get_user(mfield_size,
-					(unsigned short __user *) buf)) {
-					rc = -EFAULT;
-					break;
-				} else 	if (mfield_size > count) {
-					rc = -EINVAL;
-					break;
-				}
-				MM_DBG("mf offset_val %x\n", mfield_size);
-				if (copy_from_user(cpy_ptr, buf, mfield_size)) {
-					rc = -EFAULT;
-					break;
-				}
-				/* Check if EOS flag is set and buffer has
-				 * contains just meta field
-				 */
-				if (cpy_ptr[AUDQCELP_EOS_FLG_OFFSET] &
-						AUDQCELP_EOS_FLG_MASK) {
-					MM_DBG("EOS SET\n");
-					eos_condition = AUDQCELP_EOS_SET;
-					if (mfield_size == count) {
-						buf += mfield_size;
-						break;
-					} else
-					cpy_ptr[AUDQCELP_EOS_FLG_OFFSET] &=
-						~AUDQCELP_EOS_FLG_MASK;
-				}
-				cpy_ptr += mfield_size;
-				count -= mfield_size;
-				buf += mfield_size;
-			} else {
-				mfield_size = 0;
-				MM_DBG("continuous buffer\n");
-			}
-			frame->mfield_sz = mfield_size;
-		}
-
-		xfer = (count > (frame->size - mfield_size)) ?
-			(frame->size - mfield_size) : count;
-		if (copy_from_user(cpy_ptr, buf, xfer)) {
-			rc = -EFAULT;
-			break;
-		}
-
-		frame->used = xfer + mfield_size;
-		audio->out_head ^= 1;
-		count -= xfer;
-		buf += xfer;
-		audqcelp_send_data(audio, 0);
-	}
-	if (eos_condition == AUDQCELP_EOS_SET)
-		rc = audqcelp_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	if (!rc) {
-		if (buf > start)
-			return buf - start;
-	}
-	return rc;
-}
-
-static int audqcelp_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	MM_INFO("audio instance 0x%08x freeing\n", (int) audio);
-	mutex_lock(&audio->lock);
-	auddev_unregister_evt_listner(AUDDEV_CLNT_DEC, audio->dec_id);
-	audqcelp_disable(audio);
-	audqcelp_flush(audio);
-	audqcelp_flush_pcm_buf(audio);
-	msm_adsp_put(audio->audplay);
-	audpp_adec_free(audio->dec_id);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	unregister_early_suspend(&audio->suspend_ctl.node);
-#endif
-	audio->opened = 0;
-	audio->event_abort = 1;
-	wake_up(&audio->event_wait);
-	audqcelp_reset_event_queue(audio);
-	iounmap(audio->map_v_write);
-	free_contiguous_memory_by_paddr(audio->phys);
-	if (audio->read_data) {
-		iounmap(audio->map_v_read);
-		free_contiguous_memory_by_paddr(audio->read_phys);
-	}
-	mutex_unlock(&audio->lock);
-#ifdef CONFIG_DEBUG_FS
-	if (audio->dentry)
-		debugfs_remove(audio->dentry);
-#endif
-	kfree(audio);
-	return 0;
-}
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audqcelp_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload)
-{
-	struct audqcelp_event *e_node = NULL;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-
-	if (!list_empty(&audio->free_event_queue)) {
-		e_node = list_first_entry(&audio->free_event_queue,
-				struct audqcelp_event, list);
-		list_del(&e_node->list);
-	} else {
-		e_node = kmalloc(sizeof(struct audqcelp_event), GFP_ATOMIC);
-		if (!e_node) {
-			MM_ERR("No mem to post event %d\n", type);
-			return;
-		}
-	}
-
-	e_node->event_type = type;
-	e_node->payload = payload;
-
-	list_add_tail(&e_node->list, &audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	wake_up(&audio->event_wait);
-}
-
-static void audqcelp_suspend(struct early_suspend *h)
-{
-	struct audqcelp_suspend_ctl *ctl =
-		container_of(h, struct audqcelp_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audqcelp_post_event(ctl->audio, AUDIO_EVENT_SUSPEND, payload);
-}
-
-static void audqcelp_resume(struct early_suspend *h)
-{
-	struct audqcelp_suspend_ctl *ctl =
-		container_of(h, struct audqcelp_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audqcelp_post_event(ctl->audio, AUDIO_EVENT_RESUME, payload);
-}
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-static ssize_t audqcelp_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static ssize_t audqcelp_debug_read(struct file *file, char __user *buf,
-					size_t count, loff_t *ppos)
-{
-	const int debug_bufmax = 1024;
-	static char buffer[1024];
-	int n = 0, i;
-	struct audio *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	n = scnprintf(buffer, debug_bufmax, "opened %d\n", audio->opened);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"enabled %d\n", audio->enabled);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"stopped %d\n", audio->stopped);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_feedback %d\n", audio->pcm_feedback);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_buf_sz %d\n", audio->out[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_buf_count %d \n", audio->pcm_buf_count);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"pcm_buf_sz %d \n", audio->in[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"volume %x \n", audio->vol_pan.volume);
-	mutex_unlock(&audio->lock);
-	/* Following variables are only useful for debugging when
-	 * when playback halts unexpectedly. Thus, no mutual exclusion
-	 * enforced
-	 */
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"wflush %d\n", audio->wflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"rflush %d\n", audio->rflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"running %d \n", audio->running);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"dec state %d \n", audio->dec_state);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_needed %d \n", audio->out_needed);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_head %d \n", audio->out_head);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out_tail %d \n", audio->out_tail);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out[0].used %d \n", audio->out[0].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"out[1].used %d \n", audio->out[1].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"buffer_refresh %d \n", audio->buf_refresh);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"read_next %d \n", audio->read_next);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"fill_next %d \n", audio->fill_next);
-	for (i = 0; i < audio->pcm_buf_count; i++)
-		n += scnprintf(buffer + n, debug_bufmax - n,
-				"in[%d].size %d \n", i, audio->in[i].used);
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations audqcelp_debug_fops = {
-	.read = audqcelp_debug_read,
-	.open = audqcelp_debug_open,
-};
-#endif
-
-static int audqcelp_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = NULL;
-	int rc, dec_attrb, decid, i;
-	struct audqcelp_event *e_node = NULL;
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_qcelp_" + 5];
-#endif
-
-	/* Create audio instance, set to zero */
-	audio = kzalloc(sizeof(struct audio), GFP_KERNEL);
-	if (!audio) {
-		MM_ERR("no memory to allocate audio instance\n");
-		rc = -ENOMEM;
-		goto done;
-	}
-	MM_INFO("audio instance 0x%08x created\n", (int)audio);
-
-	/* Allocate the decoder */
-	dec_attrb = AUDDEC_DEC_QCELP;
-	if ((file->f_mode & FMODE_WRITE) &&
-			(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_NONTUNNEL;
-		audio->pcm_feedback = NON_TUNNEL_MODE_PLAYBACK;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_TUNNEL;
-		audio->pcm_feedback = TUNNEL_MODE_PLAYBACK;
-	} else {
-		kfree(audio);
-		rc = -EACCES;
-		goto done;
-	}
-	decid = audpp_adec_alloc(dec_attrb, &audio->module_name,
-			&audio->queue_id);
-	if (decid < 0) {
-		MM_ERR("No free decoder available, freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENODEV;
-		kfree(audio);
-		goto done;
-	}
-	audio->dec_id = decid & MSM_AUD_DECODER_MASK;
-
-	audio->phys = allocate_contiguous_ebi_nomap(DMASZ, SZ_4K);
-	if (!audio->phys) {
-		MM_ERR("could not allocate write buffers, freeing instance \
-				0x%08x\n", (int)audio);
-		rc = -ENOMEM;
-		audpp_adec_free(audio->dec_id);
-		kfree(audio);
-		goto done;
-	} else {
-		audio->map_v_write = ioremap(audio->phys, DMASZ);
-		if (IS_ERR(audio->map_v_write)) {
-			MM_ERR("could not map write phys address, freeing \
-					instance 0x%08x\n", (int)audio);
-			rc = -ENOMEM;
-			free_contiguous_memory_by_paddr(audio->phys);
-			audpp_adec_free(audio->dec_id);
-			kfree(audio);
-			goto done;
-		}
-		audio->data = audio->map_v_write;
-		MM_DBG("write buf: phy addr 0x%08x kernel addr 0x%08x\n",
-				audio->phys, (int)audio->data);
-	}
-
-	rc = msm_adsp_get(audio->module_name, &audio->audplay,
-		&audplay_adsp_ops_qcelp, audio);
-	if (rc) {
-		MM_ERR("failed to get %s module, freeing instance  0x%08x\n",
-				audio->module_name, (int)audio);
-		goto err;
-	}
-
-	/* Initialize all locks of audio instance */
-	mutex_init(&audio->lock);
-	mutex_init(&audio->write_lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->get_event_lock);
-	spin_lock_init(&audio->dsp_lock);
-	init_waitqueue_head(&audio->write_wait);
-	init_waitqueue_head(&audio->read_wait);
-	INIT_LIST_HEAD(&audio->free_event_queue);
-	INIT_LIST_HEAD(&audio->event_queue);
-	init_waitqueue_head(&audio->wait);
-	init_waitqueue_head(&audio->event_wait);
-	spin_lock_init(&audio->event_queue_lock);
-	init_waitqueue_head(&audio->avsync_wait);
-
-	/* Initialize buffer */
-	audio->out[0].data = audio->data + 0;
-	audio->out[0].addr = audio->phys + 0;
-	audio->out[0].size = BUFSZ;
-
-	audio->out[1].data = audio->data + BUFSZ;
-	audio->out[1].addr = audio->phys + BUFSZ;
-	audio->out[1].size = BUFSZ;
-
-	audio->vol_pan.volume = 0x2000;
-
-	audqcelp_flush(audio);
-
-	file->private_data = audio;
-	audio->opened = 1;
-
-	audio->device_events = AUDDEV_EVT_DEV_RDY
-				|AUDDEV_EVT_DEV_RLS|
-				AUDDEV_EVT_STREAM_VOL_CHG;
-
-	rc = auddev_register_evt_listner(audio->device_events,
-					AUDDEV_CLNT_DEC,
-					audio->dec_id,
-					qcelp_listner,
-					(void *)audio);
-	if (rc) {
-		MM_ERR("%s: failed to register listnet\n", __func__);
-		goto event_err;
-	}
-
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof name, "msm_qcelp_%04x", audio->dec_id);
-	audio->dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
-			NULL, (void *) audio, &audqcelp_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		MM_DBG("debugfs_create_file failed\n");
-#endif
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	audio->suspend_ctl.node.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
-	audio->suspend_ctl.node.resume = audqcelp_resume;
-	audio->suspend_ctl.node.suspend = audqcelp_suspend;
-	audio->suspend_ctl.audio = audio;
-	register_early_suspend(&audio->suspend_ctl.node);
-#endif
-	for (i = 0; i < AUDQCELP_EVENT_NUM; i++) {
-		e_node = kmalloc(sizeof(struct audqcelp_event), GFP_KERNEL);
-		if (e_node)
-			list_add_tail(&e_node->list, &audio->free_event_queue);
-		else {
-			MM_ERR("event pkt alloc failed\n");
-			break;
-		}
-	}
-done:
-	return rc;
-event_err:
-	msm_adsp_put(audio->audplay);
-err:
-	iounmap(audio->map_v_write);
-	free_contiguous_memory_by_paddr(audio->phys);
-	audpp_adec_free(audio->dec_id);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_qcelp_fops = {
-	.owner = THIS_MODULE,
-	.open = audqcelp_open,
-	.release = audqcelp_release,
-	.read = audqcelp_read,
-	.write = audqcelp_write,
-	.unlocked_ioctl = audqcelp_ioctl,
-	.fsync = audqcelp_fsync,
-};
-
-struct miscdevice audio_qcelp_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_qcelp",
-	.fops = &audio_qcelp_fops,
-};
-
-static int __init audqcelp_init(void)
-{
-	return misc_register(&audio_qcelp_misc);
-}
-
-static void __exit audqcelp_exit(void)
-{
-	misc_deregister(&audio_qcelp_misc);
-}
-
-module_init(audqcelp_init);
-module_exit(audqcelp_exit);
-
-MODULE_DESCRIPTION("MSM QCELP 13K driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5v2/audio_qcelp_in.c b/arch/arm/mach-msm/qdsp5v2/audio_qcelp_in.c
deleted file mode 100644
index 37a6726..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audio_qcelp_in.c
+++ /dev/null
@@ -1,1591 +0,0 @@
-/*
- * qcelp audio input device
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/msm_audio_qcp.h>
-#include <linux/msm_ion.h>
-#include <linux/memory_alloc.h>
-
-#include <mach/msm_adsp.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/socinfo.h>
-#include <mach/qdsp5v2/qdsp5audreccmdi.h>
-#include <mach/qdsp5v2/qdsp5audrecmsg.h>
-#include <mach/qdsp5v2/audpreproc.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_memtypes.h>
-
-#define META_OUT_SIZE	24
-/* FRAME_NUM must be a power of two */
-#define FRAME_NUM	8
-#define QCELP_FRAME_SIZE	36 /* 36 bytes data */
-#define FRAME_SIZE	(22 * 2) /* 36 bytes data */
- /* 36 bytes data  + 24 meta field*/
-#define NT_FRAME_SIZE	(QCELP_FRAME_SIZE + META_OUT_SIZE)
-#define DMASZ		(NT_FRAME_SIZE * FRAME_NUM)
-#define OUT_FRAME_NUM	(2)
-#define OUT_BUFFER_SIZE (4 * 1024 + META_OUT_SIZE)
-#define BUFFER_SIZE	(OUT_BUFFER_SIZE * OUT_FRAME_NUM)
-
-
-#define AUDPREPROC_QCELP_EOS_FLG_OFFSET 0x0A
-#define AUDPREPROC_QCELP_EOS_FLG_MASK 0x01
-#define AUDPREPROC_QCELP_EOS_NONE 0x0 /* No EOS detected */
-#define AUDPREPROC_QCELP_EOS_SET 0x1 /* EOS set in meta field */
-
-struct buffer {
-	void *data;
-	uint32_t size;
-	uint32_t read;
-	uint32_t addr;
-	uint32_t used;
-	uint32_t mfield_sz;
-};
-
-struct audio_in {
-	struct buffer in[FRAME_NUM];
-
-	spinlock_t dsp_lock;
-
-	atomic_t in_bytes;
-	atomic_t in_samples;
-
-	struct mutex lock;
-	struct mutex read_lock;
-	wait_queue_head_t wait;
-	wait_queue_head_t wait_enable;
-	/*write section*/
-	struct buffer out[OUT_FRAME_NUM];
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed;	/* number of buffers the dsp is waiting for */
-	uint32_t out_count;
-
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-	int32_t out_phys; /* physical address of write buffer */
-	char *out_data;
-	int mfield; /* meta field embedded in data */
-	int wflush; /*write flush */
-	int rflush; /*read flush*/
-	int out_frame_cnt;
-
-	struct msm_adsp_module *audrec;
-
-	struct audrec_session_info session_info; /*audrec session info*/
-
-	/* configuration to use on next enable */
-	uint32_t buffer_size; /* Frame size (36 bytes) */
-	uint32_t samp_rate;
-	uint32_t channel_mode;
-	uint32_t enc_type;
-
-	struct msm_audio_qcelp_enc_config cfg;
-	uint32_t rec_mode;
-
-	uint32_t dsp_cnt;
-	uint32_t in_head; /* next buffer dsp will write */
-	uint32_t in_tail; /* next buffer read() will read */
-	uint32_t in_count; /* number of buffers available to read() */
-	uint32_t mode;
-	uint32_t eos_ack;
-	uint32_t flush_ack;
-
-	const char *module_name;
-	unsigned queue_ids;
-	uint16_t enc_id;
-
-	uint16_t source; /* Encoding source bit mask */
-	uint32_t device_events;
-	uint32_t in_call;
-	uint32_t dev_cnt;
-	int voice_state;
-	spinlock_t dev_lock;
-
-	/* data allocated for various buffers */
-	char *data;
-	dma_addr_t phys;
-	void *map_v_read;
-	void *map_v_write;
-
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped, cleared on flush */
-	char *build_id;
-	struct ion_client *client;
-	struct ion_handle *input_buff_handle;
-	struct ion_handle *output_buff_handle;
-};
-
-struct audio_frame {
-	uint16_t frame_count_lsw;
-	uint16_t frame_count_msw;
-	uint16_t frame_length;
-	uint16_t erased_pcm;
-	unsigned char raw_bitstream[]; /* samples */
-} __attribute__((packed));
-
-struct audio_frame_nt {
-	uint16_t metadata_len;
-	uint16_t frame_count_lsw;
-	uint16_t frame_count_msw;
-	uint16_t frame_length;
-	uint16_t erased_pcm;
-	uint16_t reserved;
-	uint16_t time_stamp_dword_lsw;
-	uint16_t time_stamp_dword_msw;
-	uint16_t time_stamp_lsw;
-	uint16_t time_stamp_msw;
-	uint16_t nflag_lsw;
-	uint16_t nflag_msw;
-	unsigned char raw_bitstream[]; /* samples */
-} __attribute__((packed));
-
-struct qcelp_encoded_meta_out {
-	uint16_t metadata_len;
-	uint16_t time_stamp_dword_lsw;
-	uint16_t time_stamp_dword_msw;
-	uint16_t time_stamp_lsw;
-	uint16_t time_stamp_msw;
-	uint16_t nflag_lsw;
-	uint16_t nflag_msw;
-};
-
-/* Audrec Queue command sent macro's */
-#define audrec_send_bitstreamqueue(audio, cmd, len) \
-	msm_adsp_write(audio->audrec, ((audio->queue_ids & 0xFFFF0000) >> 16),\
-			cmd, len)
-
-#define audrec_send_audrecqueue(audio, cmd, len) \
-	msm_adsp_write(audio->audrec, (audio->queue_ids & 0x0000FFFF),\
-			cmd, len)
-
-/* DSP command send functions */
-static int audqcelp_in_enc_config(struct audio_in *audio, int enable);
-static int audqcelp_in_param_config(struct audio_in *audio);
-static int audqcelp_in_mem_config(struct audio_in *audio);
-static int audqcelp_in_record_config(struct audio_in *audio, int enable);
-static int audqcelp_dsp_read_buffer(struct audio_in *audio, uint32_t read_cnt);
-
-static void audqcelp_in_get_dsp_frames(struct audio_in *audio);
-static int audpcm_config(struct audio_in *audio);
-static void audqcelp_out_flush(struct audio_in *audio);
-static int audpreproc_cmd_cfg_routing_mode(struct audio_in *audio);
-static void audpreproc_pcm_send_data(struct audio_in *audio, unsigned needed);
-static void audqcelp_nt_in_get_dsp_frames(struct audio_in *audio);
-
-static void audqcelp_in_flush(struct audio_in *audio);
-
-static void qcelp_in_listener(u32 evt_id, union auddev_evt_data *evt_payload,
-				void *private_data)
-{
-	struct audio_in *audio = (struct audio_in *) private_data;
-	unsigned long flags;
-
-	MM_DBG("evt_id = 0x%8x\n", evt_id);
-	switch (evt_id) {
-	case AUDDEV_EVT_DEV_RDY: {
-		MM_DBG("AUDDEV_EVT_DEV_RDY\n");
-		spin_lock_irqsave(&audio->dev_lock, flags);
-		audio->dev_cnt++;
-		if (!audio->in_call)
-			audio->source |= (0x1 << evt_payload->routing_id);
-		spin_unlock_irqrestore(&audio->dev_lock, flags);
-
-		if ((audio->running == 1) && (audio->enabled == 1) &&
-			(audio->mode == MSM_AUD_ENC_MODE_TUNNEL))
-			audqcelp_in_record_config(audio, 1);
-	}
-		break;
-	case AUDDEV_EVT_DEV_RLS: {
-		MM_DBG("AUDDEV_EVT_DEV_RLS\n");
-		spin_lock_irqsave(&audio->dev_lock, flags);
-		audio->dev_cnt--;
-		if (!audio->in_call)
-			audio->source &= ~(0x1 << evt_payload->routing_id);
-		spin_unlock_irqrestore(&audio->dev_lock, flags);
-
-		if ((!audio->running) || (!audio->enabled))
-			break;
-
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			/* Turn of as per source */
-			if (audio->source)
-				audqcelp_in_record_config(audio, 1);
-			else
-				/* Turn off all */
-				audqcelp_in_record_config(audio, 0);
-		}
-	}
-		break;
-	case AUDDEV_EVT_VOICE_STATE_CHG: {
-		MM_DBG("AUDDEV_EVT_VOICE_STATE_CHG, state = %d\n",
-				evt_payload->voice_state);
-		audio->voice_state = evt_payload->voice_state;
-		if (audio->in_call && audio->running &&
-		   (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)) {
-			if (audio->voice_state == VOICE_STATE_INCALL)
-				audqcelp_in_record_config(audio, 1);
-			else if (audio->voice_state == VOICE_STATE_OFFCALL) {
-				audqcelp_in_record_config(audio, 0);
-				wake_up(&audio->wait);
-			}
-		}
-
-		break;
-	}
-	default:
-		MM_ERR("wrong event %d\n", evt_id);
-		break;
-	}
-}
-
-/* ------------------- dsp preproc event handler--------------------- */
-static void audpreproc_dsp_event(void *data, unsigned id,  void *msg)
-{
-	struct audio_in *audio = data;
-
-	switch (id) {
-	case AUDPREPROC_ERROR_MSG: {
-		struct audpreproc_err_msg *err_msg = msg;
-
-		MM_ERR("ERROR_MSG: stream id %d err idx %d\n",
-		err_msg->stream_id, err_msg->aud_preproc_err_idx);
-		/* Error case */
-		wake_up(&audio->wait_enable);
-		break;
-	}
-	case AUDPREPROC_CMD_CFG_DONE_MSG: {
-		MM_DBG("CMD_CFG_DONE_MSG \n");
-		break;
-	}
-	case AUDPREPROC_CMD_ENC_CFG_DONE_MSG: {
-		struct audpreproc_cmd_enc_cfg_done_msg *enc_cfg_msg = msg;
-
-		MM_DBG("CMD_ENC_CFG_DONE_MSG: stream id %d enc type \
-			0x%8x\n", enc_cfg_msg->stream_id,
-			enc_cfg_msg->rec_enc_type);
-		/* Encoder enable success */
-		if (enc_cfg_msg->rec_enc_type & ENCODE_ENABLE) {
-			if(audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) {
-				MM_DBG("routing command\n");
-				audpreproc_cmd_cfg_routing_mode(audio);
-			} else {
-				audqcelp_in_param_config(audio);
-			}
-		} else { /* Encoder disable success */
-			audio->running = 0;
-			if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)
-				audqcelp_in_record_config(audio, 0);
-			else
-				wake_up(&audio->wait_enable);
-		}
-		break;
-	}
-	case AUDPREPROC_CMD_ENC_PARAM_CFG_DONE_MSG: {
-		MM_DBG("CMD_ENC_PARAM_CFG_DONE_MSG\n");
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)
-			audqcelp_in_mem_config(audio);
-		else
-			audpcm_config(audio);
-		break;
-	}
-	case AUDPREPROC_CMD_ROUTING_MODE_DONE_MSG: {
-		struct audpreproc_cmd_routing_mode_done\
-				*routing_cfg_done_msg = msg;
-		if (routing_cfg_done_msg->configuration == 0) {
-			MM_INFO("routing configuration failed\n");
-			audio->running = 0;
-		} else
-			audqcelp_in_param_config(audio);
-		break;
-	}
-	case AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG_DONE_MSG: {
-		MM_DBG("AFE_CMD_AUDIO_RECORD_CFG_DONE_MSG \n");
-		wake_up(&audio->wait_enable);
-		break;
-	}
-	default:
-		MM_ERR("Unknown Event id %d\n", id);
-	}
-}
-
-/* ------------------- dsp audrec event handler--------------------- */
-static void audrec_dsp_event(void *data, unsigned id, size_t len,
-			    void (*getevent)(void *ptr, size_t len))
-{
-	struct audio_in *audio = data;
-
-	switch (id) {
-	case AUDREC_CMD_MEM_CFG_DONE_MSG: {
-		MM_DBG("CMD_MEM_CFG_DONE MSG DONE\n");
-		audio->running = 1;
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			if ((!audio->in_call && (audio->dev_cnt > 0)) ||
-				(audio->in_call &&
-					(audio->voice_state \
-						== VOICE_STATE_INCALL)))
-				audqcelp_in_record_config(audio, 1);
-		} else {
-			audpreproc_pcm_send_data(audio, 1);
-			wake_up(&audio->wait_enable);
-		}
-		break;
-	}
-	case AUDREC_FATAL_ERR_MSG: {
-		struct audrec_fatal_err_msg fatal_err_msg;
-
-		getevent(&fatal_err_msg, AUDREC_FATAL_ERR_MSG_LEN);
-		MM_ERR("FATAL_ERR_MSG: err id %d\n",
-				fatal_err_msg.audrec_err_id);
-		/* Error stop the encoder */
-		audio->stopped = 1;
-		wake_up(&audio->wait);
-		if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL)
-			wake_up(&audio->write_wait);
-		break;
-	}
-	case AUDREC_UP_PACKET_READY_MSG: {
-		struct audrec_up_pkt_ready_msg pkt_ready_msg;
-
-		getevent(&pkt_ready_msg, AUDREC_UP_PACKET_READY_MSG_LEN);
-		MM_DBG("UP_PACKET_READY_MSG: write cnt lsw  %d \
-		write cnt msw %d read cnt lsw %d  read cnt msw %d \n",\
-		pkt_ready_msg.audrec_packet_write_cnt_lsw, \
-		pkt_ready_msg.audrec_packet_write_cnt_msw, \
-		pkt_ready_msg.audrec_up_prev_read_cnt_lsw, \
-		pkt_ready_msg.audrec_up_prev_read_cnt_msw);
-
-		audqcelp_in_get_dsp_frames(audio);
-		break;
-	}
-	case AUDREC_CMD_PCM_BUFFER_PTR_UPDATE_ARM_TO_ENC_MSG: {
-		MM_DBG("ptr_update recieved from DSP\n");
-		audpreproc_pcm_send_data(audio, 1);
-		break;
-	}
-	case AUDREC_CMD_PCM_CFG_ARM_TO_ENC_DONE_MSG: {
-		MM_ERR("AUDREC_CMD_PCM_CFG_ARM_TO_ENC_DONE_MSG");
-		audqcelp_in_mem_config(audio);
-		break;
-	}
-	case AUDREC_UP_NT_PACKET_READY_MSG: {
-		struct audrec_up_nt_packet_ready_msg pkt_ready_msg;
-
-		getevent(&pkt_ready_msg, AUDREC_UP_NT_PACKET_READY_MSG_LEN);
-		MM_DBG("UP_NT_PACKET_READY_MSG: write cnt lsw  %d \
-		write cnt msw %d read cnt lsw %d  read cnt msw %d \n",\
-		pkt_ready_msg.audrec_packetwrite_cnt_lsw, \
-		pkt_ready_msg.audrec_packetwrite_cnt_msw, \
-		pkt_ready_msg.audrec_upprev_readcount_lsw, \
-		pkt_ready_msg.audrec_upprev_readcount_msw);
-
-		audqcelp_nt_in_get_dsp_frames(audio);
-		break;
-	}
-	case AUDREC_CMD_EOS_ACK_MSG: {
-		MM_DBG("eos ack recieved\n");
-		break;
-	}
-	case AUDREC_CMD_FLUSH_DONE_MSG: {
-		audio->wflush = 0;
-		audio->rflush = 0;
-		audio->flush_ack = 1;
-		wake_up(&audio->write_wait);
-		MM_DBG("flush ack recieved\n");
-		break;
-	}
-	case ADSP_MESSAGE_ID: {
-		MM_DBG("Received ADSP event:module audrectask\n");
-		break;
-	}
-	default:
-		MM_ERR("Unknown Event id %d\n", id);
-	}
-}
-
-static void audqcelp_in_get_dsp_frames(struct audio_in *audio)
-{
-	struct audio_frame *frame;
-	uint32_t index;
-	unsigned long flags;
-
-	MM_DBG("head = %d\n", audio->in_head);
-	index = audio->in_head;
-
-	frame = (void *) (((char *)audio->in[index].data) - \
-			 sizeof(*frame));
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->in[index].size = frame->frame_length;
-
-	/* statistics of read */
-	atomic_add(audio->in[index].size, &audio->in_bytes);
-	atomic_add(1, &audio->in_samples);
-
-	audio->in_head = (audio->in_head + 1) & (FRAME_NUM - 1);
-
-	/* If overflow, move the tail index foward. */
-	if (audio->in_head == audio->in_tail) {
-		MM_ERR("Error! not able to keep up the read\n");
-		audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
-		MM_ERR("in_count = %d\n", audio->in_count);
-	} else
-		audio->in_count++;
-
-	audqcelp_dsp_read_buffer(audio, audio->dsp_cnt++);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-
-	wake_up(&audio->wait);
-}
-
-static void audqcelp_nt_in_get_dsp_frames(struct audio_in *audio)
-{
-	struct audio_frame_nt *nt_frame;
-	uint32_t index;
-	unsigned long flags;
-	MM_DBG("head = %d\n", audio->in_head);
-	index = audio->in_head;
-	nt_frame = (void *) (((char *)audio->in[index].data) - \
-				sizeof(struct audio_frame_nt));
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	audio->in[index].size = nt_frame->frame_length;
-	/* statistics of read */
-	atomic_add(audio->in[index].size, &audio->in_bytes);
-	atomic_add(1, &audio->in_samples);
-
-	audio->in_head = (audio->in_head + 1) & (FRAME_NUM - 1);
-
-	/* If overflow, move the tail index foward. */
-	if (audio->in_head == audio->in_tail)
-		MM_DBG("Error! not able to keep up the read\n");
-	else
-		audio->in_count++;
-
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-	wake_up(&audio->wait);
-}
-
-
-struct msm_adsp_ops audrec_qcelp_adsp_ops = {
-	.event = audrec_dsp_event,
-};
-
-static int audpreproc_pcm_buffer_ptr_refresh(struct audio_in *audio,
-				       unsigned idx, unsigned len)
-{
-	struct audrec_cmd_pcm_buffer_ptr_refresh_arm_enc cmd;
-
-	if (len ==  META_OUT_SIZE)
-		len = len / 2;
-	else
-		len = (len + META_OUT_SIZE) / 2;
-	MM_DBG("len = %d\n", len);
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_PCM_BUFFER_PTR_REFRESH_ARM_TO_ENC;
-	cmd.num_buffers = 1;
-	if (cmd.num_buffers == 1) {
-		cmd.buf_address_length[0] = (audio->out[idx].addr &
-							0xffff0000) >> 16;
-		cmd.buf_address_length[1] = (audio->out[idx].addr &
-							0x0000ffff);
-		cmd.buf_address_length[2] = (len & 0xffff0000) >> 16;
-		cmd.buf_address_length[3] = (len & 0x0000ffff);
-	}
-	audio->out_frame_cnt++;
-	return audrec_send_audrecqueue(audio, (void *)&cmd,
-					(unsigned int)sizeof(cmd));
-}
-
-
-static int audpcm_config(struct audio_in *audio)
-{
-	struct audrec_cmd_pcm_cfg_arm_to_enc cmd;
-	MM_DBG("\n");
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_PCM_CFG_ARM_TO_ENC;
-	cmd.config_update_flag = AUDREC_PCM_CONFIG_UPDATE_FLAG_ENABLE;
-	cmd.enable_flag = AUDREC_ENABLE_FLAG_VALUE;
-	cmd.sampling_freq = audio->samp_rate;
-	if (!audio->channel_mode)
-		cmd.channels = 1;
-	else
-		cmd.channels = 2;
-	cmd.frequency_of_intimation = 1;
-	cmd.max_number_of_buffers = OUT_FRAME_NUM;
-	return audrec_send_audrecqueue(audio, (void *)&cmd,
-					(unsigned int)sizeof(cmd));
-}
-
-
-static int audpreproc_cmd_cfg_routing_mode(struct audio_in *audio)
-{
-	struct audpreproc_audrec_cmd_routing_mode cmd;
-
-	MM_DBG("\n");
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPREPROC_AUDREC_CMD_ROUTING_MODE;
-	cmd.stream_id = audio->enc_id;
-	if (audio->mode == MSM_ADSP_ENC_MODE_NON_TUNNEL)
-		cmd.routing_mode = 1;
-	return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd));
-}
-
-
-
-static int audqcelp_in_enc_config(struct audio_in *audio, int enable)
-{
-	struct audpreproc_audrec_cmd_enc_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	if (audio->build_id[17] == '1') {
-		cmd.cmd_id = AUDPREPROC_AUDREC_CMD_ENC_CFG_2;
-		MM_ERR("sending AUDPREPROC_AUDREC_CMD_ENC_CFG_2 command");
-	} else {
-		cmd.cmd_id = AUDPREPROC_AUDREC_CMD_ENC_CFG;
-		MM_ERR("sending AUDPREPROC_AUDREC_CMD_ENC_CFG command");
-	}
-	cmd.stream_id = audio->enc_id;
-
-	if (enable)
-		cmd.audrec_enc_type = audio->enc_type | ENCODE_ENABLE;
-	else
-		cmd.audrec_enc_type &= ~(ENCODE_ENABLE);
-
-	return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd));
-}
-
-static int audqcelp_in_param_config(struct audio_in *audio)
-{
-	struct audpreproc_audrec_cmd_parm_cfg_qcelp13k cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPREPROC_AUDREC_CMD_PARAM_CFG;
-	cmd.common.stream_id = audio->enc_id;
-
-	cmd.enc_min_rate = audio->cfg.min_bit_rate;
-	cmd.enc_max_rate = audio->cfg.max_bit_rate;
-	cmd.rate_modulation_cmd = 0;  /* Default set to 0 */
-	cmd.reduced_rate_level = 0;  /* Default set to 0 */
-
-	return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd));
-}
-
-/* To Do: msm_snddev_route_enc(audio->enc_id); */
-static int audqcelp_in_record_config(struct audio_in *audio, int enable)
-{
-	struct audpreproc_afe_cmd_audio_record_cfg cmd;
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG;
-	cmd.stream_id = audio->enc_id;
-	if (enable)
-		cmd.destination_activity = AUDIO_RECORDING_TURN_ON;
-	else
-		cmd.destination_activity = AUDIO_RECORDING_TURN_OFF;
-
-	cmd.source_mix_mask = audio->source;
-	if (audio->enc_id == 2) {
-		if ((cmd.source_mix_mask &
-				INTERNAL_CODEC_TX_SOURCE_MIX_MASK) ||
-			(cmd.source_mix_mask & AUX_CODEC_TX_SOURCE_MIX_MASK) ||
-			(cmd.source_mix_mask & VOICE_UL_SOURCE_MIX_MASK) ||
-			(cmd.source_mix_mask & VOICE_DL_SOURCE_MIX_MASK)) {
-			cmd.pipe_id = SOURCE_PIPE_1;
-		}
-		if (cmd.source_mix_mask &
-				AUDPP_A2DP_PIPE_SOURCE_MIX_MASK)
-			cmd.pipe_id |= SOURCE_PIPE_0;
-	}
-	MM_DBG("stream_id %x destination_activity %x \
-	source_mix_mask %x pipe_id %x",\
-	cmd.stream_id, cmd.destination_activity,
-	cmd.source_mix_mask, cmd.pipe_id);
-	return audpreproc_send_audreccmdqueue(&cmd, sizeof(cmd));
-}
-
-static int audqcelp_in_mem_config(struct audio_in *audio)
-{
-	struct audrec_cmd_arecmem_cfg cmd;
-	uint16_t *data = (void *) audio->data;
-	int n;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_MEM_CFG_CMD;
-	cmd.audrec_up_pkt_intm_count = 1;
-	cmd.audrec_ext_pkt_start_addr_msw = audio->phys >> 16;
-	cmd.audrec_ext_pkt_start_addr_lsw = audio->phys;
-	cmd.audrec_ext_pkt_buf_number = FRAME_NUM;
-	MM_DBG("audio->phys = %x\n", audio->phys);
-	/* prepare buffer pointers:
-	 * T:36 bytes qcelp ppacket + 4 halfword header
-	 * NT:36 bytes qcelp packet + 12 halfword header
-	 */
-	for (n = 0; n < FRAME_NUM; n++) {
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			audio->in[n].data = data + 4;
-			data += (FRAME_SIZE/2);
-			MM_DBG("0x%8x\n", (int)(audio->in[n].data - 8));
-		} else  {
-			audio->in[n].data = data + 12;
-			data += ((QCELP_FRAME_SIZE) / 2) + 12;
-			MM_DBG("0x%8x\n", (int)(audio->in[n].data - 24));
-		}
-	}
-	return audrec_send_audrecqueue(audio, &cmd, sizeof(cmd));
-}
-
-static int audqcelp_dsp_read_buffer(struct audio_in *audio, uint32_t read_cnt)
-{
-	struct up_audrec_packet_ext_ptr cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = UP_AUDREC_PACKET_EXT_PTR;
-	cmd.audrec_up_curr_read_count_msw = read_cnt >> 16;
-	cmd.audrec_up_curr_read_count_lsw = read_cnt;
-
-	return audrec_send_bitstreamqueue(audio, &cmd, sizeof(cmd));
-}
-static int audqcelp_flush_command(struct audio_in *audio)
-{
-	struct audrec_cmd_flush cmd;
-	MM_DBG("\n");
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDREC_CMD_FLUSH;
-	return audrec_send_audrecqueue(audio, &cmd, sizeof(cmd));
-}
-
-/* must be called with audio->lock held */
-static int audqcelp_in_enable(struct audio_in *audio)
-{
-	if (audio->enabled)
-		return 0;
-
-	if (audpreproc_enable(audio->enc_id, &audpreproc_dsp_event, audio)) {
-		MM_ERR("msm_adsp_enable(audpreproc) failed\n");
-		return -ENODEV;
-	}
-
-	if (msm_adsp_enable(audio->audrec)) {
-		MM_ERR("msm_adsp_enable(audrec) failed\n");
-		audpreproc_disable(audio->enc_id, audio);
-		return -ENODEV;
-	}
-	audio->enabled = 1;
-	audqcelp_in_enc_config(audio, 1);
-
-	return 0;
-}
-
-/* must be called with audio->lock held */
-static int audqcelp_in_disable(struct audio_in *audio)
-{
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audqcelp_in_enc_config(audio, 0);
-		wake_up(&audio->wait);
-		wait_event_interruptible_timeout(audio->wait_enable,
-				audio->running == 0, 1*HZ);
-		msm_adsp_disable(audio->audrec);
-		audpreproc_disable(audio->enc_id, audio);
-	}
-	return 0;
-}
-
-static void audqcelp_ioport_reset(struct audio_in *audio)
-{
-	/* Make sure read/write thread are free from
-	 * sleep and knowing that system is not able
-	 * to process io request at the moment
-	 */
-	wake_up(&audio->write_wait);
-	mutex_lock(&audio->write_lock);
-	audqcelp_in_flush(audio);
-	mutex_unlock(&audio->write_lock);
-	wake_up(&audio->wait);
-	mutex_lock(&audio->read_lock);
-	audqcelp_out_flush(audio);
-	mutex_unlock(&audio->read_lock);
-}
-
-static void audqcelp_in_flush(struct audio_in *audio)
-{
-	int i;
-
-	audio->dsp_cnt = 0;
-	audio->in_head = 0;
-	audio->in_tail = 0;
-	audio->in_count = 0;
-	audio->eos_ack = 0;
-	for (i = 0; i < FRAME_NUM; i++) {
-		audio->in[i].size = 0;
-		audio->in[i].read = 0;
-	}
-	MM_DBG("in_bytes %d\n", atomic_read(&audio->in_bytes));
-	MM_DBG("in_samples %d\n", atomic_read(&audio->in_samples));
-	atomic_set(&audio->in_bytes, 0);
-	atomic_set(&audio->in_samples, 0);
-}
-
-static void audqcelp_out_flush(struct audio_in *audio)
-{
-	int i;
-
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->out_count = 0;
-	for (i = 0; i < OUT_FRAME_NUM; i++) {
-		audio->out[i].size = 0;
-		audio->out[i].read = 0;
-		audio->out[i].used = 0;
-	}
-}
-
-/* ------------------- device --------------------- */
-static long audqcelp_in_ioctl(struct file *file,
-				unsigned int cmd, unsigned long arg)
-{
-	struct audio_in *audio = file->private_data;
-	int rc = 0;
-
-	MM_DBG("\n");
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		memset(&stats, 0, sizeof(stats));
-		stats.byte_count = atomic_read(&audio->in_bytes);
-		stats.sample_count = atomic_read(&audio->in_samples);
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return rc;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START: {
-		uint32_t freq;
-		freq = 48000;
-		MM_DBG("AUDIO_START\n");
-		if (audio->in_call && (audio->voice_state !=
-				VOICE_STATE_INCALL)) {
-			rc = -EPERM;
-			break;
-		}
-		rc = msm_snddev_request_freq(&freq, audio->enc_id,
-					SNDDEV_CAP_TX, AUDDEV_CLNT_ENC);
-		MM_DBG("sample rate configured %d\n", freq);
-		if (rc < 0) {
-			MM_DBG(" Sample rate can not be set, return code %d\n",
-								 rc);
-			msm_snddev_withdraw_freq(audio->enc_id,
-					SNDDEV_CAP_TX, AUDDEV_CLNT_ENC);
-			MM_DBG("msm_snddev_withdraw_freq\n");
-			break;
-		}
-		/*update aurec session info in audpreproc layer*/
-		audio->session_info.session_id = audio->enc_id;
-		audio->session_info.sampling_freq = audio->samp_rate;
-		audpreproc_update_audrec_info(&audio->session_info);
-		rc = audqcelp_in_enable(audio);
-		if (!rc) {
-			rc =
-			wait_event_interruptible_timeout(audio->wait_enable,
-				audio->running != 0, 1*HZ);
-			MM_DBG("state %d rc = %d\n", audio->running, rc);
-
-			if (audio->running == 0)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		audio->stopped = 0;
-		break;
-	}
-	case AUDIO_STOP: {
-		/*reset the sampling frequency information at audpreproc layer*/
-		audio->session_info.sampling_freq = 0;
-		audpreproc_update_audrec_info(&audio->session_info);
-		rc = audqcelp_in_disable(audio);
-		rc = msm_snddev_withdraw_freq(audio->enc_id,
-					SNDDEV_CAP_TX, AUDDEV_CLNT_ENC);
-		MM_DBG("msm_snddev_withdraw_freq\n");
-		audio->stopped = 1;
-		break;
-	}
-	case AUDIO_FLUSH: {
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audqcelp_ioport_reset(audio);
-		if (audio->running) {
-			audqcelp_flush_command(audio);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-	}
-	case AUDIO_SET_STREAM_CONFIG: {
-		struct msm_audio_stream_config cfg;
-		if (copy_from_user(&cfg, (void *) arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		/* Allow only single frame */
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			if (cfg.buffer_size != (FRAME_SIZE - 8)) {
-				rc = -EINVAL;
-				break;
-			}
-		} else {
-			if (cfg.buffer_size != (QCELP_FRAME_SIZE + 14)) {
-				rc = -EINVAL;
-				break;
-			}
-		}
-		audio->buffer_size = cfg.buffer_size;
-		break;
-	}
-	case AUDIO_GET_STREAM_CONFIG: {
-		struct msm_audio_stream_config cfg;
-		memset(&cfg, 0, sizeof(cfg));
-		cfg.buffer_size = audio->buffer_size;
-		cfg.buffer_count = FRAME_NUM;
-		if (copy_to_user((void *) arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		break;
-	}
-	case AUDIO_GET_QCELP_ENC_CONFIG: {
-		if (copy_to_user((void *) arg, &audio->cfg, sizeof(audio->cfg)))
-			rc = -EFAULT;
-		break;
-	}
-	case AUDIO_SET_QCELP_ENC_CONFIG: {
-		struct msm_audio_qcelp_enc_config cfg;
-		if (copy_from_user(&cfg, (void *) arg, sizeof(cfg))) {
-			rc = -EFAULT;
-			break;
-		}
-		MM_DBG("0X%8x, 0x%8x, 0x%8x\n", cfg.min_bit_rate, \
-				cfg.max_bit_rate, cfg.cdma_rate);
-		if (cfg.min_bit_rate > CDMA_RATE_FULL || \
-				 cfg.min_bit_rate < CDMA_RATE_EIGHTH) {
-			MM_ERR("invalid min bitrate\n");
-			rc = -EFAULT;
-			break;
-		}
-		if (cfg.max_bit_rate > CDMA_RATE_FULL || \
-				cfg.max_bit_rate < CDMA_RATE_EIGHTH) {
-			MM_ERR("invalid max bitrate\n");
-			rc = -EFAULT;
-			break;
-		}
-		/* Recording Does not support Erase and Blank */
-		if (cfg.cdma_rate > CDMA_RATE_FULL ||
-			cfg.cdma_rate < CDMA_RATE_EIGHTH) {
-			MM_ERR("invalid qcelp cdma rate\n");
-			rc = -EFAULT;
-			break;
-		}
-		memcpy(&audio->cfg, &cfg, sizeof(cfg));
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config cfg;
-		memset(&cfg, 0, sizeof(cfg));
-		cfg.buffer_size = OUT_BUFFER_SIZE;
-		cfg.buffer_count = OUT_FRAME_NUM;
-		cfg.sample_rate = audio->samp_rate;
-		cfg.channel_count = audio->channel_mode;
-		if (copy_to_user((void *)arg, &cfg, sizeof(cfg)))
-			rc = -EFAULT;
-		break;
-	}
-	case AUDIO_SET_INCALL: {
-		struct msm_voicerec_mode cfg;
-		unsigned long flags;
-		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
-			if (copy_from_user(&cfg, (void *) arg, sizeof(cfg))) {
-				rc = -EFAULT;
-				break;
-			}
-			if (cfg.rec_mode != VOC_REC_BOTH &&
-				cfg.rec_mode != VOC_REC_UPLINK &&
-				cfg.rec_mode != VOC_REC_DOWNLINK) {
-				MM_ERR("invalid rec_mode\n");
-				rc = -EINVAL;
-				break;
-			} else {
-				spin_lock_irqsave(&audio->dev_lock, flags);
-				if (cfg.rec_mode == VOC_REC_UPLINK)
-					audio->source = \
-						VOICE_UL_SOURCE_MIX_MASK;
-				else if (cfg.rec_mode == VOC_REC_DOWNLINK)
-					audio->source = \
-						VOICE_DL_SOURCE_MIX_MASK;
-				else
-					audio->source = \
-						VOICE_DL_SOURCE_MIX_MASK |
-						VOICE_UL_SOURCE_MIX_MASK ;
-				audio->in_call = 1;
-				spin_unlock_irqrestore(&audio->dev_lock, flags);
-			}
-		}
-		break;
-	}
-	case AUDIO_GET_SESSION_ID: {
-		if (copy_to_user((void *) arg, &audio->enc_id,
-			sizeof(unsigned short))) {
-			rc = -EFAULT;
-		}
-		break;
-	}
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-static ssize_t audqcelp_in_read(struct file *file,
-				char __user *buf,
-				size_t count, loff_t *pos)
-{
-	struct audio_in *audio = file->private_data;
-	unsigned long flags;
-	const char __user *start = buf;
-	void *data;
-	uint32_t index;
-	uint32_t size;
-	int rc = 0;
-	struct qcelp_encoded_meta_out meta_field;
-	struct audio_frame_nt *nt_frame;
-	MM_DBG(" count = %d\n", count);
-	mutex_lock(&audio->read_lock);
-	while (count > 0) {
-		rc = wait_event_interruptible(
-			audio->wait, (audio->in_count > 0) || audio->stopped ||
-			audio->rflush ||
-			((audio->mode == MSM_AUD_ENC_MODE_TUNNEL) &&
-			 audio->in_call && audio->running &&
-			(audio->voice_state == VOICE_STATE_OFFCALL)));
-		if (rc < 0)
-			break;
-
-		if (audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-		if (audio->stopped && !audio->in_count) {
-			MM_DBG("Driver in stop state, No more buffer to read");
-			rc = 0;/* End of File */
-			break;
-			} else if ((audio->mode == MSM_AUD_ENC_MODE_TUNNEL) &&
-					audio->in_call && audio->running &&
-					(audio->voice_state \
-						== VOICE_STATE_OFFCALL)) {
-				MM_DBG("Not Permitted Voice Terminated\n");
-				rc = -EPERM; /* Voice Call stopped */
-				break;
-		}
-
-		index = audio->in_tail;
-		data = (uint8_t *) audio->in[index].data;
-		size = audio->in[index].size;
-
-		if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL) {
-			nt_frame = (struct audio_frame_nt *)(data -
-					sizeof(struct audio_frame_nt));
-			memcpy((char *)&meta_field.time_stamp_dword_lsw,
-				(char *)&nt_frame->time_stamp_dword_lsw,
-				(sizeof(struct qcelp_encoded_meta_out) - \
-				sizeof(uint16_t)));
-			meta_field.metadata_len =
-					sizeof(struct qcelp_encoded_meta_out);
-			if (copy_to_user((char *)start,
-				(char *)&meta_field,
-				sizeof(struct qcelp_encoded_meta_out))) {
-				rc = -EFAULT;
-				break;
-			}
-			if (nt_frame->nflag_lsw & 0x0001) {
-				MM_ERR("recieved EOS in read call\n");
-				audio->eos_ack = 1;
-			}
-			buf += sizeof(struct qcelp_encoded_meta_out);
-			count -= sizeof(struct qcelp_encoded_meta_out);
-		}
-		if (count >= size) {
-			if (copy_to_user(buf, data, size)) {
-				rc = -EFAULT;
-				break;
-			}
-			spin_lock_irqsave(&audio->dsp_lock, flags);
-			if (index != audio->in_tail) {
-				/* overrun -- data is
-				 * invalid and we need to retry */
-				spin_unlock_irqrestore(&audio->dsp_lock, flags);
-				continue;
-			}
-			audio->in[index].size = 0;
-			audio->in_tail = (audio->in_tail + 1) & (FRAME_NUM - 1);
-			audio->in_count--;
-			spin_unlock_irqrestore(&audio->dsp_lock, flags);
-			count -= size;
-			buf += size;
-			if ((audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL)) {
-				if (!audio->eos_ack) {
-					MM_DBG("sending read ptr command\
-							%d %d\n",
-							audio->dsp_cnt,
-							audio->in_tail);
-					audqcelp_dsp_read_buffer(audio,
-							audio->dsp_cnt++);
-				}
-			}
-		} else {
-			MM_ERR("short read\n");
-			break;
-		}
-		break;
-	}
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		return buf - start;
-
-	return rc;
-}
-
-static void audpreproc_pcm_send_data(struct audio_in *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-	MM_DBG("\n");
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			MM_DBG("frame %d free\n", audio->out_tail);
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			audpreproc_pcm_buffer_ptr_refresh(audio,
-						 audio->out_tail,
-						    frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
- done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-
-static int audqcelp_in_fsync(struct file *file, loff_t ppos1, loff_t ppos2, int datasync)
-
-{
-	struct audio_in *audio = file->private_data;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (!audio->running || (audio->mode == MSM_AUD_ENC_MODE_TUNNEL)) {
-		rc = -EINVAL;
-		goto done_nolock;
-	}
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-			audio->wflush);
-	MM_DBG("waked on by some event audio->wflush = %d\n", audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-done:
-	mutex_unlock(&audio->write_lock);
-done_nolock:
-	return rc;
-
-}
-
- int audpreproc_qcelp_process_eos(struct audio_in *audio,
-		const char __user *buf_start, unsigned short mfield_size)
-{
-	struct buffer *frame;
-	int rc = 0;
-
-	frame = audio->out + audio->out_head;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	MM_DBG("copying meta_out frame->used = %d\n", frame->used);
-	audpreproc_pcm_send_data(audio, 0);
-done:
-	return rc;
-}
-
-static ssize_t audqcelp_in_write(struct file *file,
-				const char __user *buf,
-				size_t count, loff_t *pos)
-{
-	struct audio_in *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	char *cpy_ptr;
-	int rc = 0, eos_condition = AUDPREPROC_QCELP_EOS_NONE;
-	unsigned short mfield_size = 0;
-	int write_count = 0;
-
-	MM_DBG("cnt=%d\n", count);
-	if (count & 1)
-		return -EINVAL;
-
-	if (audio->mode != MSM_AUD_ENC_MODE_NONTUNNEL)
-		return -EINVAL;
-
-	mutex_lock(&audio->write_lock);
-	frame = audio->out + audio->out_head;
-	/* if supplied count is more than driver buffer size
-	 * then only copy driver buffer size
-	 */
-	if (count > frame->size)
-		count = frame->size;
-
-	write_count = count;
-	cpy_ptr = frame->data;
-	rc = wait_event_interruptible(audio->write_wait,
-				      (frame->used == 0)
-					|| (audio->stopped)
-					|| (audio->wflush));
-	if (rc < 0)
-		goto error;
-
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto error;
-	}
-	if (audio->mfield) {
-		if (buf == start) {
-			/* Processing beginning of user buffer */
-			if (__get_user(mfield_size,
-				(unsigned short __user *) buf)) {
-				rc = -EFAULT;
-				goto error;
-			} else if (mfield_size > count) {
-				rc = -EINVAL;
-				goto error;
-			}
-			MM_DBG("mf offset_val %x\n", mfield_size);
-			if (copy_from_user(cpy_ptr, buf, mfield_size)) {
-				rc = -EFAULT;
-				goto error;
-			}
-			/* Check if EOS flag is set and buffer has
-			 * contains just meta field
-			 */
-			if (cpy_ptr[AUDPREPROC_QCELP_EOS_FLG_OFFSET] &
-					AUDPREPROC_QCELP_EOS_FLG_MASK) {
-				eos_condition = AUDPREPROC_QCELP_EOS_SET;
-				MM_DBG("EOS SET\n");
-				if (mfield_size == count) {
-					buf += mfield_size;
-					eos_condition = 0;
-					goto exit;
-				} else
-				cpy_ptr[AUDPREPROC_QCELP_EOS_FLG_OFFSET] &=
-					~AUDPREPROC_QCELP_EOS_FLG_MASK;
-			}
-			cpy_ptr += mfield_size;
-			count -= mfield_size;
-			buf += mfield_size;
-		} else {
-			mfield_size = 0;
-			MM_DBG("continuous buffer\n");
-		}
-		frame->mfield_sz = mfield_size;
-	}
-	MM_DBG("copying the stream count = %d\n", count);
-	if (copy_from_user(cpy_ptr, buf, count)) {
-		rc = -EFAULT;
-		goto error;
-	}
-exit:
-	frame->used = count;
-	audio->out_head ^= 1;
-	if (!audio->flush_ack)
-		audpreproc_pcm_send_data(audio, 0);
-	else {
-		audpreproc_pcm_send_data(audio, 1);
-		audio->flush_ack = 0;
-	}
-	if (eos_condition == AUDPREPROC_QCELP_EOS_SET)
-		rc = audpreproc_qcelp_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	return write_count;
-error:
-	mutex_unlock(&audio->write_lock);
-	return rc;
-}
-
-static int audqcelp_in_release(struct inode *inode, struct file *file)
-{
-	struct audio_in *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	audio->in_call = 0;
-	/* with draw frequency for session
-	   incase not stopped the driver */
-	msm_snddev_withdraw_freq(audio->enc_id, SNDDEV_CAP_TX,
-					AUDDEV_CLNT_ENC);
-	auddev_unregister_evt_listner(AUDDEV_CLNT_ENC, audio->enc_id);
-	/*reset the sampling frequency information at audpreproc layer*/
-	audio->session_info.sampling_freq = 0;
-	audpreproc_update_audrec_info(&audio->session_info);
-	audqcelp_in_disable(audio);
-	audqcelp_in_flush(audio);
-	msm_adsp_put(audio->audrec);
-	audpreproc_aenc_free(audio->enc_id);
-	audio->audrec = NULL;
-	audio->opened = 0;
-	if (audio->data) {
-		ion_unmap_kernel(audio->client, audio->input_buff_handle);
-		ion_free(audio->client, audio->input_buff_handle);
-		audio->data = NULL;
-	}
-	if (audio->out_data) {
-		ion_unmap_kernel(audio->client, audio->output_buff_handle);
-		ion_free(audio->client, audio->output_buff_handle);
-		audio->out_data = NULL;
-	}
-	ion_client_destroy(audio->client);
-	mutex_unlock(&audio->lock);
-	return 0;
-}
-
-struct audio_in the_audio_qcelp_in;
-static int audqcelp_in_open(struct inode *inode, struct file *file)
-{
-	struct audio_in *audio = &the_audio_qcelp_in;
-	int rc;
-	int encid;
-	int len = 0;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	struct ion_client *client = NULL;
-
-	mutex_lock(&audio->lock);
-	if (audio->opened) {
-		rc = -EBUSY;
-		goto done;
-	}
-	client = msm_ion_client_create(UINT_MAX, "Audio_EVRC_in_client");
-	if (IS_ERR_OR_NULL(client)) {
-		MM_ERR("Unable to create ION client\n");
-		rc = -ENOMEM;
-		goto client_create_error;
-	}
-	audio->client = client;
-
-	MM_DBG("allocating mem sz = %d\n", DMASZ);
-	handle = ion_alloc(client, DMASZ, SZ_4K,
-		ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-	if (IS_ERR_OR_NULL(handle)) {
-		MM_ERR("Unable to create allocate O/P buffers\n");
-		rc = -ENOMEM;
-		goto output_buff_alloc_error;
-	}
-
-	audio->output_buff_handle = handle;
-
-	rc = ion_phys(client , handle, &addr, &len);
-	if (rc) {
-		MM_ERR("O/P buffers:Invalid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-		rc = -ENOMEM;
-		goto output_buff_get_phys_error;
-	} else {
-		MM_INFO("O/P buffers:valid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-	}
-	audio->phys = (int32_t)addr;
-
-	rc = ion_handle_get_flags(client, handle, &ionflag);
-	if (rc) {
-		MM_ERR("could not get flags for the handle\n");
-		rc = -ENOMEM;
-		goto output_buff_get_flags_error;
-	}
-
-	audio->map_v_read = ion_map_kernel(client, handle);
-	if (IS_ERR(audio->map_v_read)) {
-		MM_ERR("could not map read buffers,freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENOMEM;
-		goto output_buff_map_error;
-	}
-	audio->data = audio->map_v_read;
-
-	MM_DBG("Memory addr = 0x%8x  phy addr = 0x%8x\n",\
-		(int) audio->data, (int) audio->phys);
-	if ((file->f_mode & FMODE_WRITE) &&
-		(file->f_mode & FMODE_READ)) {
-		audio->mode = MSM_AUD_ENC_MODE_NONTUNNEL;
-		MM_DBG("Opened for non tunnel mode encoding\n");
-	} else if (!(file->f_mode & FMODE_WRITE) &&
-					(file->f_mode & FMODE_READ)) {
-		audio->mode = MSM_AUD_ENC_MODE_TUNNEL;
-		MM_DBG("Opened for tunnel mode encoding\n");
-	} else {
-		MM_ERR("Invalid mode\n");
-		rc = -EACCES;
-		goto done;
-	}
-
-	/* Settings will be re-config at AUDIO_SET_CONFIG,
-	 * but at least we need to have initial config
-	 */
-	if (audio->mode == MSM_AUD_ENC_MODE_NONTUNNEL)
-			audio->buffer_size = (QCELP_FRAME_SIZE + 14);
-	else
-			audio->buffer_size = (FRAME_SIZE - 8);
-	audio->enc_type = ENC_TYPE_V13K | audio->mode;
-	audio->samp_rate = 8000;
-	audio->channel_mode = AUDREC_CMD_MODE_MONO;
-	audio->cfg.cdma_rate = CDMA_RATE_FULL;
-	audio->cfg.min_bit_rate = CDMA_RATE_FULL;
-	audio->cfg.max_bit_rate = CDMA_RATE_FULL;
-	audio->source = INTERNAL_CODEC_TX_SOURCE_MIX_MASK;
-	audio->rec_mode = VOC_REC_UPLINK;
-
-	encid = audpreproc_aenc_alloc(audio->enc_type, &audio->module_name,
-			&audio->queue_ids);
-	if (encid < 0) {
-		MM_ERR("No free encoder available\n");
-		rc = -ENODEV;
-		goto done;
-	}
-	audio->enc_id = encid;
-
-	rc = msm_adsp_get(audio->module_name, &audio->audrec,
-			   &audrec_qcelp_adsp_ops, audio);
-
-	if (rc) {
-		audpreproc_aenc_free(audio->enc_id);
-		goto done;
-	}
-
-	audio->stopped = 0;
-	audio->source = 0;
-	audio->wflush = 0;
-	audio->rflush = 0;
-	audio->flush_ack = 0;
-
-	audqcelp_in_flush(audio);
-	audqcelp_out_flush(audio);
-
-	MM_DBG("allocating BUFFER_SIZE  %d\n", BUFFER_SIZE);
-	handle = ion_alloc(client, BUFFER_SIZE,
-			SZ_4K, ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-	if (IS_ERR_OR_NULL(handle)) {
-		MM_ERR("Unable to create allocate I/P buffers\n");
-		rc = -ENOMEM;
-		goto input_buff_alloc_error;
-	}
-
-	audio->input_buff_handle = handle;
-
-	rc = ion_phys(client , handle, &addr, &len);
-	if (rc) {
-		MM_ERR("I/P buffers:Invalid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-		rc = -ENOMEM;
-		goto input_buff_alloc_error;
-	} else {
-		MM_INFO("Got valid phy: %x sz: %x\n",
-			(unsigned int) addr,
-			(unsigned int) len);
-	}
-	audio->out_phys = (int32_t)addr;
-
-	rc = ion_handle_get_flags(client,
-		handle, &ionflag);
-	if (rc) {
-		MM_ERR("could not get flags for the handle\n");
-		rc = -ENOMEM;
-		goto input_buff_alloc_error;
-	}
-
-	audio->map_v_write = ion_map_kernel(client, handle);
-	if (IS_ERR(audio->map_v_write)) {
-		MM_ERR("could not map write buffers\n");
-		rc = -ENOMEM;
-		goto input_buff_map_error;
-	}
-	audio->out_data = audio->map_v_write;
-	MM_DBG("write buf: phy addr 0x%08x kernel addr 0x%08x\n",
-				(unsigned int)addr,
-				(unsigned int)audio->out_data);
-
-		/* Initialize buffer */
-	audio->out[0].data = audio->out_data + 0;
-	audio->out[0].addr = audio->out_phys + 0;
-	audio->out[0].size = OUT_BUFFER_SIZE;
-
-	audio->out[1].data = audio->out_data + OUT_BUFFER_SIZE;
-	audio->out[1].addr = audio->out_phys + OUT_BUFFER_SIZE;
-	audio->out[1].size = OUT_BUFFER_SIZE;
-
-	MM_DBG("audio->out[0].data = %d  audio->out[1].data = %d",
-					(unsigned int)audio->out[0].data,
-					(unsigned int)audio->out[1].data);
-	audio->device_events = AUDDEV_EVT_DEV_RDY | AUDDEV_EVT_DEV_RLS |
-				AUDDEV_EVT_VOICE_STATE_CHG;
-
-	audio->voice_state = msm_get_voice_state();
-	rc = auddev_register_evt_listner(audio->device_events,
-					AUDDEV_CLNT_ENC, audio->enc_id,
-					qcelp_in_listener, (void *) audio);
-	if (rc) {
-		MM_ERR("failed to register device event listener\n");
-		iounmap(audio->map_v_write);
-		free_contiguous_memory_by_paddr(audio->out_phys);
-		goto evt_error;
-	}
-	audio->mfield = META_OUT_SIZE;
-	file->private_data = audio;
-	audio->opened = 1;
-	audio->out_frame_cnt++;
-	audio->build_id = socinfo_get_build_id();
-	MM_DBG("Modem build id = %s\n", audio->build_id);
-done:
-	mutex_unlock(&audio->lock);
-	return rc;
-evt_error:
-	msm_adsp_put(audio->audrec);
-	audpreproc_aenc_free(audio->enc_id);
-	mutex_unlock(&audio->lock);
-input_buff_map_error:
-	ion_free(client, audio->input_buff_handle);
-input_buff_alloc_error:
-	ion_unmap_kernel(client, audio->output_buff_handle);
-output_buff_map_error:
-output_buff_get_phys_error:
-output_buff_get_flags_error:
-	ion_free(client, audio->output_buff_handle);
-output_buff_alloc_error:
-	ion_client_destroy(client);
-client_create_error:
-	return rc;
-}
-
-static const struct file_operations audio_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audqcelp_in_open,
-	.release	= audqcelp_in_release,
-	.read		= audqcelp_in_read,
-	.write		= audqcelp_in_write,
-	.fsync		= audqcelp_in_fsync,
-	.unlocked_ioctl	= audqcelp_in_ioctl,
-};
-
-struct miscdevice audio_qcelp_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_qcelp_in",
-	.fops	= &audio_in_fops,
-};
-
-static int __init audqcelp_in_init(void)
-{
-	mutex_init(&the_audio_qcelp_in.lock);
-	mutex_init(&the_audio_qcelp_in.read_lock);
-	spin_lock_init(&the_audio_qcelp_in.dsp_lock);
-	spin_lock_init(&the_audio_qcelp_in.dev_lock);
-	init_waitqueue_head(&the_audio_qcelp_in.wait);
-	init_waitqueue_head(&the_audio_qcelp_in.wait_enable);
-	mutex_init(&the_audio_qcelp_in.write_lock);
-	init_waitqueue_head(&the_audio_qcelp_in.write_wait);
-	return misc_register(&audio_qcelp_in_misc);
-}
-
-device_initcall(audqcelp_in_init);
diff --git a/arch/arm/mach-msm/qdsp5v2/audio_wma.c b/arch/arm/mach-msm/qdsp5v2/audio_wma.c
deleted file mode 100644
index 4e5dcd3..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audio_wma.c
+++ /dev/null
@@ -1,1860 +0,0 @@
-/* Copyright (c) 2009-2012, The Linux Foundation. All rights reserved.
- *
- * Based on the mp3 native driver in arch/arm/mach-msm/qdsp5v2/audio_mp3.c
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- *
- * All source code in this file is licensed under the following license except
- * where indicated.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you can find it at http://www.fsf.org
- */
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/list.h>
-#include <linux/earlysuspend.h>
-#include <linux/slab.h>
-#include <linux/msm_audio.h>
-#include <linux/msm_audio_wma.h>
-#include <linux/memory_alloc.h>
-#include <linux/msm_ion.h>
-
-#include <mach/msm_adsp.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/qdsp5v2/qdsp5audppmsg.h>
-#include <mach/qdsp5v2/qdsp5audplaycmdi.h>
-#include <mach/qdsp5v2/qdsp5audplaymsg.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/qdsp5v2/audpp.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_memtypes.h>
-
-/* Size must be power of 2 */
-#define BUFSZ_MAX 	4110	/* Includes meta in size */
-#define BUFSZ_MIN 	1038	/* Includes meta in size */
-#define DMASZ_MAX 	(BUFSZ_MAX * 2)
-#define DMASZ_MIN 	(BUFSZ_MIN * 2)
-
-#define AUDPLAY_INVALID_READ_PTR_OFFSET	0xFFFF
-#define AUDDEC_DEC_WMA 4
-
-#define PCM_BUFSZ_MIN 	8216 	/* Hold one stereo WMA frame and meta out*/
-#define PCM_BUF_MAX_COUNT 5	/* DSP only accepts 5 buffers at most
-				   but support 2 buffers currently */
-#define ROUTING_MODE_FTRT 1
-#define ROUTING_MODE_RT 2
-/* Decoder status received from AUDPPTASK */
-#define  AUDPP_DEC_STATUS_SLEEP	0
-#define	 AUDPP_DEC_STATUS_INIT  1
-#define  AUDPP_DEC_STATUS_CFG   2
-#define  AUDPP_DEC_STATUS_PLAY  3
-
-#define AUDWMA_METAFIELD_MASK 0xFFFF0000
-#define AUDWMA_EOS_FLG_OFFSET 0x0A /* Offset from beginning of buffer */
-#define AUDWMA_EOS_FLG_MASK 0x01
-#define AUDWMA_EOS_NONE 0x0 /* No EOS detected */
-#define AUDWMA_EOS_SET 0x1 /* EOS set in meta field */
-
-#define AUDWMA_EVENT_NUM 10 /* Default number of pre-allocated event packets */
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;		/* Input usage actual DSP produced PCM size  */
-	unsigned addr;
-	unsigned short mfield_sz; /*only useful for data has meta field */
-};
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-struct audwma_suspend_ctl {
-	struct early_suspend node;
-	struct audio *audio;
-};
-#endif
-
-struct audwma_event{
-	struct list_head list;
-	int event_type;
-	union msm_audio_event_payload payload;
-};
-
-struct audio {
-	struct buffer out[2];
-
-	spinlock_t dsp_lock;
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed; /* number of buffers the dsp is waiting for */
-	unsigned out_dma_sz;
-
-	atomic_t out_bytes;
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-
-	/* Host PCM section */
-	struct buffer in[PCM_BUF_MAX_COUNT];
-	struct mutex read_lock;
-	wait_queue_head_t read_wait;	/* Wait queue for read */
-	char *read_data;	/* pointer to reader buffer */
-	int32_t read_phys;	/* physical address of reader buffer */
-	uint8_t read_next;	/* index to input buffers to be read next */
-	uint8_t fill_next;	/* index to buffer that DSP should be filling */
-	uint8_t pcm_buf_count;	/* number of pcm buffer allocated */
-	/* ---- End of Host PCM section */
-
-	struct msm_adsp_module *audplay;
-
-	/* configuration to use on next enable */
-	uint32_t out_sample_rate;
-	uint32_t out_channel_mode;
-
-	struct msm_audio_wma_config wma_config;
-
-	/* data allocated for various buffers */
-	char *data;
-	int32_t phys; /* physical address of write buffer */
-	void *map_v_read;
-	void *map_v_write;
-
-	int mfield; /* meta field embedded in data */
-	int rflush; /* Read  flush */
-	int wflush; /* Write flush */
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped, cleared on flush */
-	int pcm_feedback;
-	int buf_refresh;
-	int teos; /* valid only if tunnel mode & no data left for decoder */
-	enum msm_aud_decoder_state dec_state;	/* Represents decoder state */
-	int reserved; /* A byte is being reserved */
-	char rsv_byte; /* Handle odd length user data */
-
-	const char *module_name;
-	unsigned queue_id;
-	uint16_t dec_id;
-	uint32_t read_ptr_offset;
-	int16_t source;
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	struct audwma_suspend_ctl suspend_ctl;
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *dentry;
-#endif
-
-	wait_queue_head_t wait;
-	struct list_head free_event_queue;
-	struct list_head event_queue;
-	wait_queue_head_t event_wait;
-	spinlock_t event_queue_lock;
-	struct mutex get_event_lock;
-	int event_abort;
-	/* AV sync Info */
-	int avsync_flag;              /* Flag to indicate feedback from DSP */
-	wait_queue_head_t avsync_wait;/* Wait queue for AV Sync Message     */
-	/* flags, 48 bits sample/bytes counter per channel */
-	uint16_t avsync[AUDPP_AVSYNC_CH_COUNT * AUDPP_AVSYNC_NUM_WORDS + 1];
-
-	uint32_t device_events;
-
-	int eq_enable;
-	int eq_needs_commit;
-	struct audpp_cmd_cfg_object_params_eqalizer eq;
-	struct audpp_cmd_cfg_object_params_volume vol_pan;
-	struct ion_client *client;
-	struct ion_handle *input_buff_handle;
-	struct ion_handle *output_buff_handle;
-};
-
-static int auddec_dsp_config(struct audio *audio, int enable);
-static void audpp_cmd_cfg_adec_params(struct audio *audio);
-static void audpp_cmd_cfg_routing_mode(struct audio *audio);
-static void audplay_send_data(struct audio *audio, unsigned needed);
-static void audplay_config_hostpcm(struct audio *audio);
-static void audplay_buffer_refresh(struct audio *audio);
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audwma_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload);
-#endif
-/* must be called with audio->lock held */
-static int audio_enable(struct audio *audio)
-{
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled)
-		return 0;
-
-	audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-
-	if (msm_adsp_enable(audio->audplay)) {
-		MM_ERR("msm_adsp_enable(audplay) failed\n");
-		return -ENODEV;
-	}
-
-	if (audpp_enable(audio->dec_id, audio_dsp_event, audio)) {
-		MM_ERR("audpp_enable() failed\n");
-		msm_adsp_disable(audio->audplay);
-		return -ENODEV;
-	}
-
-	audio->enabled = 1;
-	return 0;
-}
-
-static void wma_listner(u32 evt_id, union auddev_evt_data *evt_payload,
-			void *private_data)
-{
-	struct audio *audio = (struct audio *) private_data;
-	switch (evt_id) {
-	case AUDDEV_EVT_DEV_RDY:
-		MM_DBG(":AUDDEV_EVT_DEV_RDY\n");
-		audio->source |= (0x1 << evt_payload->routing_id);
-		if (audio->running == 1 && audio->enabled == 1)
-			audpp_route_stream(audio->dec_id, audio->source);
-		break;
-	case AUDDEV_EVT_DEV_RLS:
-		MM_DBG(":AUDDEV_EVT_DEV_RLS\n");
-		audio->source &= ~(0x1 << evt_payload->routing_id);
-		if (audio->running == 1 && audio->enabled == 1)
-			audpp_route_stream(audio->dec_id, audio->source);
-		break;
-	case AUDDEV_EVT_STREAM_VOL_CHG:
-		audio->vol_pan.volume = evt_payload->session_vol;
-		MM_DBG(":AUDDEV_EVT_STREAM_VOL_CHG, stream vol %d\n",
-				audio->vol_pan.volume);
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		break;
-	default:
-		MM_ERR(":ERROR:wrong event\n");
-		break;
-	}
-}
-/* must be called with audio->lock held */
-static int audio_disable(struct audio *audio)
-{
-	int rc = 0;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-		auddec_dsp_config(audio, 0);
-		rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-		if (rc == 0)
-			rc = -ETIMEDOUT;
-		else if (audio->dec_state != MSM_AUD_DECODER_STATE_CLOSE)
-			rc = -EFAULT;
-		else
-			rc = 0;
-		wake_up(&audio->write_wait);
-		wake_up(&audio->read_wait);
-		msm_adsp_disable(audio->audplay);
-		audpp_disable(audio->dec_id, audio);
-		audio->out_needed = 0;
-	}
-	return rc;
-}
-
-/* ------------------- dsp --------------------- */
-static void audio_update_pcm_buf_entry(struct audio *audio,
-	uint32_t *payload)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	if (audio->rflush)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < payload[1]; index++) {
-		if (audio->in[audio->fill_next].addr ==
-			payload[2 + index * 2]) {
-			MM_DBG("audio_update_pcm_buf_entry: \
-				in[%d] ready\n", audio->fill_next);
-			audio->in[audio->fill_next].used =
-			payload[3 + index * 2];
-			if ((++audio->fill_next) == audio->pcm_buf_count)
-				audio->fill_next = 0;
-		} else {
-			MM_ERR("audio_update_pcm_buf_entry: \
-				expected=%x ret=%x\n",
-				audio->in[audio->fill_next].addr,
-				payload[1 + index * 2]);
-			break;
-		}
-	}
-	if (audio->in[audio->fill_next].used == 0) {
-		audplay_buffer_refresh(audio);
-	} else {
-		MM_DBG("read cannot keep up\n");
-		audio->buf_refresh = 1;
-	}
-	wake_up(&audio->read_wait);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audplay_dsp_event(void *data, unsigned id, size_t len,
-			      void (*getevent) (void *ptr, size_t len))
-{
-	struct audio *audio = data;
-	uint32_t msg[28];
-
-	getevent(msg, sizeof(msg));
-
-	MM_DBG("msg_id=%x\n", id);
-
-	switch (id) {
-	case AUDPLAY_MSG_DEC_NEEDS_DATA:
-		audplay_send_data(audio, 1);
-		break;
-
-	case AUDPLAY_MSG_BUFFER_UPDATE:
-		audio_update_pcm_buf_entry(audio, msg);
-		break;
-
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audplaytask)\n");
-		break;
-
-	default:
-		MM_ERR("unexpected message from decoder \n");
-		break;
-	}
-}
-
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg)
-{
-	struct audio *audio = private;
-
-	switch (id) {
-	case AUDPP_MSG_STATUS_MSG:{
-			unsigned status = msg[1];
-
-			switch (status) {
-			case AUDPP_DEC_STATUS_SLEEP: {
-				uint16_t reason = msg[2];
-				MM_DBG("decoder status:sleep reason = \
-						0x%04x\n", reason);
-				if ((reason == AUDPP_MSG_REASON_MEM)
-					|| (reason ==
-					AUDPP_MSG_REASON_NODECODER)) {
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_FAILURE;
-					wake_up(&audio->wait);
-				} else if (reason == AUDPP_MSG_REASON_NONE) {
-					/* decoder is in disable state */
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_CLOSE;
-					wake_up(&audio->wait);
-				}
-				break;
-			}
-			case AUDPP_DEC_STATUS_INIT:
-				MM_DBG("decoder status: init\n");
-				if (audio->pcm_feedback)
-					audpp_cmd_cfg_routing_mode(audio);
-				else
-					audpp_cmd_cfg_adec_params(audio);
-				break;
-
-			case AUDPP_DEC_STATUS_CFG:
-				MM_DBG("decoder status: cfg\n");
-				break;
-			case AUDPP_DEC_STATUS_PLAY:
-				MM_DBG("decoder status: play \n");
-				/* send  mixer command */
-				audpp_route_stream(audio->dec_id,
-						audio->source);
-				if (audio->pcm_feedback) {
-					audplay_config_hostpcm(audio);
-					audplay_buffer_refresh(audio);
-				}
-				audio->dec_state =
-					MSM_AUD_DECODER_STATE_SUCCESS;
-				wake_up(&audio->wait);
-				break;
-			default:
-				MM_ERR("unknown decoder status\n");
-			}
-			break;
-		}
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_DBG("CFG_MSG ENABLE\n");
-			auddec_dsp_config(audio, 1);
-			audio->out_needed = 0;
-			audio->running = 1;
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-			audpp_dsp_set_eq(audio->dec_id, audio->eq_enable,
-					&audio->eq, POPP);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			MM_DBG("CFG_MSG DISABLE\n");
-			audio->running = 0;
-		} else {
-			MM_DBG("CFG_MSG %d?\n", msg[0]);
-		}
-		break;
-	case AUDPP_MSG_ROUTING_ACK:
-		MM_DBG("ROUTING_ACK mode=%d\n", msg[1]);
-		audpp_cmd_cfg_adec_params(audio);
-		break;
-
-	case AUDPP_MSG_FLUSH_ACK:
-		MM_DBG("FLUSH_ACK\n");
-		audio->wflush = 0;
-		audio->rflush = 0;
-		wake_up(&audio->write_wait);
-		if (audio->pcm_feedback)
-			audplay_buffer_refresh(audio);
-		break;
-
-	case AUDPP_MSG_PCMDMAMISSED:
-		MM_DBG("PCMDMAMISSED\n");
-		audio->teos = 1;
-		wake_up(&audio->write_wait);
-		break;
-
-	case AUDPP_MSG_AVSYNC_MSG:
-		MM_DBG("AUDPP_MSG_AVSYNC_MSG\n");
-		memcpy(&audio->avsync[0], msg, sizeof(audio->avsync));
-		audio->avsync_flag = 1;
-		wake_up(&audio->avsync_wait);
-		break;
-
-	default:
-		MM_ERR("UNKNOWN (%d)\n", id);
-	}
-
-}
-
-static struct msm_adsp_ops audplay_adsp_ops_wma = {
-	.event = audplay_dsp_event,
-};
-
-#define audplay_send_queue0(audio, cmd, len) \
-	msm_adsp_write(audio->audplay, audio->queue_id, \
-			cmd, len)
-
-static int auddec_dsp_config(struct audio *audio, int enable)
-{
-	struct audpp_cmd_cfg_dec_type cfg_dec_cmd;
-
-	memset(&cfg_dec_cmd, 0, sizeof(cfg_dec_cmd));
-
-	cfg_dec_cmd.cmd_id = AUDPP_CMD_CFG_DEC_TYPE;
-	if (enable)
-		cfg_dec_cmd.dec_cfg = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_ENA_DEC_V | AUDDEC_DEC_WMA;
-	else
-		cfg_dec_cmd.dec_cfg = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_DIS_DEC_V;
-	cfg_dec_cmd.dm_mode = 0x0;
-	cfg_dec_cmd.stream_id = audio->dec_id;
-	return audpp_send_queue1(&cfg_dec_cmd, sizeof(cfg_dec_cmd));
-}
-
-static void audpp_cmd_cfg_adec_params(struct audio *audio)
-{
-	struct audpp_cmd_cfg_adec_params_wma cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_CMD_CFG_ADEC_PARAMS;
-	cmd.common.length = AUDPP_CMD_CFG_ADEC_PARAMS_WMA_LEN;
-	cmd.common.dec_id = audio->dec_id;
-	cmd.common.input_sampling_frequency = audio->out_sample_rate;
-
-	/*
-	 * Test done for sample with the following configuration
-	 * armdatareqthr 	= 1262
-	 * channelsdecoded 	= 1(MONO)/2(STEREO)
-	 * wmabytespersec 	= Tested with 6003 Bytes per sec
-	 * wmasamplingfreq	= 44100
-	 * wmaencoderopts	= 31
-	 */
-
-	cmd.armdatareqthr = audio->wma_config.armdatareqthr;
-	cmd.channelsdecoded = audio->wma_config.channelsdecoded;
-	cmd.wmabytespersec = audio->wma_config.wmabytespersec;
-	cmd.wmasamplingfreq = audio->wma_config.wmasamplingfreq;
-	cmd.wmaencoderopts = audio->wma_config.wmaencoderopts;
-
-	audpp_send_queue2(&cmd, sizeof(cmd));
-}
-
-static void audpp_cmd_cfg_routing_mode(struct audio *audio)
-{
-	struct audpp_cmd_routing_mode cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPP_CMD_ROUTING_MODE;
-	cmd.object_number = audio->dec_id;
-	if (audio->pcm_feedback)
-		cmd.routing_mode = ROUTING_MODE_FTRT;
-	else
-		cmd.routing_mode = ROUTING_MODE_RT;
-
-	audpp_send_queue1(&cmd, sizeof(cmd));
-}
-
-static void audplay_buffer_refresh(struct audio *audio)
-{
-	struct audplay_cmd_buffer_refresh refresh_cmd;
-
-	refresh_cmd.cmd_id = AUDPLAY_CMD_BUFFER_REFRESH;
-	refresh_cmd.num_buffers = 1;
-	refresh_cmd.buf0_address = audio->in[audio->fill_next].addr;
-	refresh_cmd.buf0_length = audio->in[audio->fill_next].size;
-	refresh_cmd.buf_read_count = 0;
-
-	MM_DBG("buf0_addr=%x buf0_len=%d\n",
-			refresh_cmd.buf0_address,
-			refresh_cmd.buf0_length);
-
-	(void)audplay_send_queue0(audio, &refresh_cmd, sizeof(refresh_cmd));
-}
-
-static void audplay_config_hostpcm(struct audio *audio)
-{
-	struct audplay_cmd_hpcm_buf_cfg cfg_cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	cfg_cmd.cmd_id = AUDPLAY_CMD_HPCM_BUF_CFG;
-	cfg_cmd.max_buffers = audio->pcm_buf_count;
-	cfg_cmd.byte_swap = 0;
-	cfg_cmd.hostpcm_config = (0x8000) | (0x4000);
-	cfg_cmd.feedback_frequency = 1;
-	cfg_cmd.partition_number = 0;
-
-	(void)audplay_send_queue0(audio, &cfg_cmd, sizeof(cfg_cmd));
-}
-
-
-static int audplay_dsp_send_data_avail(struct audio *audio,
-					unsigned idx, unsigned len)
-{
-	struct audplay_cmd_bitstream_data_avail_nt2 cmd;
-
-	cmd.cmd_id		= AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2;
-	if (!audio->pcm_feedback)
-		cmd.decoder_id = 0;
-	else {
-		if (audio->mfield)
-			cmd.decoder_id = AUDWMA_METAFIELD_MASK |
-			(audio->out[idx].mfield_sz >> 1);
-		else
-			cmd.decoder_id		= audio->dec_id;
-	}
-	cmd.buf_ptr		= audio->out[idx].addr;
-	cmd.buf_size		= len/2;
-	cmd.partition_number	= 0;
-	return audplay_send_queue0(audio, &cmd, sizeof(cmd));
-}
-
-static void audplay_send_data(struct audio *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (audio->wflush) {
-		audio->out_needed = 1;
-		goto done;
-	}
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			MM_DBG("frame %d free\n", audio->out_tail);
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		MM_DBG("\n"); /* Macro prints the file name and function */
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			MM_DBG("frame %d busy\n", audio->out_tail);
-			audplay_dsp_send_data_avail(audio, audio->out_tail,
-								frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
-done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-
-static void audio_flush(struct audio *audio)
-{
-	audio->out[0].used = 0;
-	audio->out[1].used = 0;
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->reserved = 0;
-	atomic_set(&audio->out_bytes, 0);
-}
-
-static void audio_flush_pcm_buf(struct audio *audio)
-{
-	uint8_t index;
-
-	for (index = 0; index < PCM_BUF_MAX_COUNT; index++)
-		audio->in[index].used = 0;
-	audio->buf_refresh = 0;
-	audio->read_next = 0;
-	audio->fill_next = 0;
-}
-
-static void audio_ioport_reset(struct audio *audio)
-{
-	/* Make sure read/write thread are free from
-	 * sleep and knowing that system is not able
-	 * to process io request at the moment
-	 */
-	wake_up(&audio->write_wait);
-	mutex_lock(&audio->write_lock);
-	audio_flush(audio);
-	mutex_unlock(&audio->write_lock);
-	wake_up(&audio->read_wait);
-	mutex_lock(&audio->read_lock);
-	audio_flush_pcm_buf(audio);
-	mutex_unlock(&audio->read_lock);
-	audio->avsync_flag = 1;
-	wake_up(&audio->avsync_wait);
-}
-
-static int audwma_events_pending(struct audio *audio)
-{
-	unsigned long flags;
-	int empty;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	empty = !list_empty(&audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	return empty || audio->event_abort;
-}
-
-static void audwma_reset_event_queue(struct audio *audio)
-{
-	unsigned long flags;
-	struct audwma_event *drv_evt;
-	struct list_head *ptr, *next;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	list_for_each_safe(ptr, next, &audio->event_queue) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audwma_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	list_for_each_safe(ptr, next, &audio->free_event_queue) {
-		drv_evt = list_first_entry(&audio->free_event_queue,
-				struct audwma_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	return;
-}
-
-static long audwma_process_event_req(struct audio *audio, void __user *arg)
-{
-	long rc;
-	struct msm_audio_event usr_evt;
-	struct audwma_event *drv_evt = NULL;
-	int timeout;
-	unsigned long flags;
-
-	if (copy_from_user(&usr_evt, arg, sizeof(struct msm_audio_event)))
-		return -EFAULT;
-
-	timeout = (int) usr_evt.timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(
-				audio->event_wait, audwma_events_pending(audio),
-				msecs_to_jiffies(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(
-			audio->event_wait, audwma_events_pending(audio));
-	}
-
-	if (rc < 0)
-		return rc;
-
-	if (audio->event_abort) {
-		audio->event_abort = 0;
-		return -ENODEV;
-	}
-
-	rc = 0;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	if (!list_empty(&audio->event_queue)) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audwma_event, list);
-		list_del(&drv_evt->list);
-	}
-
-	if (drv_evt) {
-		usr_evt.event_type = drv_evt->event_type;
-		usr_evt.event_payload = drv_evt->payload;
-		list_add_tail(&drv_evt->list, &audio->free_event_queue);
-	} else
-		rc = -1;
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	if (!rc && copy_to_user(arg, &usr_evt, sizeof(usr_evt)))
-		rc = -EFAULT;
-
-	return rc;
-}
-
-static int audio_enable_eq(struct audio *audio, int enable)
-{
-	if (audio->eq_enable == enable && !audio->eq_needs_commit)
-		return 0;
-
-	audio->eq_enable = enable;
-
-	if (audio->running) {
-		audpp_dsp_set_eq(audio->dec_id, enable, &audio->eq, POPP);
-		audio->eq_needs_commit = 0;
-	}
-	return 0;
-}
-
-static int audio_get_avsync_data(struct audio *audio,
-						struct msm_audio_stats *stats)
-{
-	int rc = -EINVAL;
-	unsigned long flags;
-
-	local_irq_save(flags);
-	if (audio->dec_id == audio->avsync[0] && audio->avsync_flag) {
-		/* av_sync sample count */
-		stats->sample_count = (audio->avsync[2] << 16) |
-						(audio->avsync[3]);
-
-		/* av_sync byte_count */
-		stats->byte_count = (audio->avsync[5] << 16) |
-						(audio->avsync[6]);
-
-		audio->avsync_flag = 0;
-		rc = 0;
-	}
-	local_irq_restore(flags);
-	return rc;
-
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = -EINVAL;
-	unsigned long flags = 0;
-	uint16_t enable_mask;
-	int enable;
-	int prev_state;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	int len = 0;
-
-	MM_DBG("cmd = %d\n", cmd);
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-
-		audio->avsync_flag = 0;
-		memset(&stats, 0, sizeof(stats));
-		if (audpp_query_avsync(audio->dec_id) < 0)
-			return rc;
-
-		rc = wait_event_interruptible_timeout(audio->avsync_wait,
-				(audio->avsync_flag == 1),
-				msecs_to_jiffies(AUDPP_AVSYNC_EVENT_TIMEOUT));
-
-		if (rc < 0)
-			return rc;
-		else if ((rc > 0) || ((rc == 0) && (audio->avsync_flag == 1))) {
-			if (audio_get_avsync_data(audio, &stats) < 0)
-				return rc;
-
-			if (copy_to_user((void *)arg, &stats, sizeof(stats)))
-				return -EFAULT;
-			return 0;
-		} else
-			return -EAGAIN;
-	}
-
-	switch (cmd) {
-	case AUDIO_ENABLE_AUDPP:
-		if (copy_from_user(&enable_mask, (void *) arg,
-						sizeof(enable_mask))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		enable = (enable_mask & EQ_ENABLE) ? 1 : 0;
-		audio_enable_eq(audio, enable);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-	case AUDIO_SET_VOLUME:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.volume = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_PAN:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.pan = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_EQ:
-		prev_state = audio->eq_enable;
-		audio->eq_enable = 0;
-		if (copy_from_user(&audio->eq.num_bands, (void *) arg,
-				sizeof(audio->eq) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2))) {
-			rc = -EFAULT;
-			break;
-		}
-		audio->eq_enable = prev_state;
-		audio->eq_needs_commit = 1;
-		rc = 0;
-		break;
-	}
-
-	if (-EINVAL != rc)
-		return rc;
-
-	if (cmd == AUDIO_GET_EVENT) {
-		MM_DBG("AUDIO_GET_EVENT\n");
-		if (mutex_trylock(&audio->get_event_lock)) {
-			rc = audwma_process_event_req(audio,
-					(void __user *) arg);
-			mutex_unlock(&audio->get_event_lock);
-		} else
-			rc = -EBUSY;
-		return rc;
-	}
-
-	if (cmd == AUDIO_ABORT_GET_EVENT) {
-		audio->event_abort = 1;
-		wake_up(&audio->event_wait);
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		MM_DBG("AUDIO_START\n");
-		rc = audio_enable(audio);
-		if (!rc) {
-			rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-			MM_INFO("dec_state %d rc = %d\n", audio->dec_state, rc);
-
-			if (audio->dec_state != MSM_AUD_DECODER_STATE_SUCCESS)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		break;
-	case AUDIO_STOP:
-		MM_DBG("AUDIO_STOP\n");
-		rc = audio_disable(audio);
-		audio->stopped = 1;
-		audio_ioport_reset(audio);
-		audio->stopped = 0;
-		break;
-	case AUDIO_FLUSH:
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audio_ioport_reset(audio);
-		if (audio->running) {
-			audpp_flush(audio->dec_id);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-	case AUDIO_SET_CONFIG: {
-		struct msm_audio_config config;
-		if (copy_from_user(&config, (void *) arg, sizeof(config))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (config.channel_count == 1) {
-			config.channel_count = AUDPP_CMD_PCM_INTF_MONO_V;
-		} else if (config.channel_count == 2) {
-			config.channel_count = AUDPP_CMD_PCM_INTF_STEREO_V;
-		} else {
-			rc = -EINVAL;
-			break;
-		}
-		audio->mfield = config.meta_field;
-		audio->out_sample_rate = config.sample_rate;
-		audio->out_channel_mode = config.channel_count;
-		rc = 0;
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config config;
-		config.buffer_size = (audio->out_dma_sz >> 1);
-		config.buffer_count = 2;
-		config.sample_rate = audio->out_sample_rate;
-		if (audio->out_channel_mode == AUDPP_CMD_PCM_INTF_MONO_V)
-			config.channel_count = 1;
-		else
-			config.channel_count = 2;
-		config.meta_field = 0;
-		config.unused[0] = 0;
-		config.unused[1] = 0;
-		config.unused[2] = 0;
-		if (copy_to_user((void *) arg, &config, sizeof(config)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-
-		break;
-	}
-	case AUDIO_GET_WMA_CONFIG:{
-			if (copy_to_user((void *)arg, &audio->wma_config,
-				sizeof(audio->wma_config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_SET_WMA_CONFIG:{
-		struct msm_audio_wma_config usr_config;
-
-		if (copy_from_user
-			(&usr_config, (void *)arg,
-			sizeof(usr_config))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		audio->wma_config = usr_config;
-		rc = 0;
-		break;
-	}
-	case AUDIO_GET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			config.pcm_feedback = audio->pcm_feedback;
-			config.buffer_count = PCM_BUF_MAX_COUNT;
-			config.buffer_size = PCM_BUFSZ_MIN;
-			if (copy_to_user((void *)arg, &config,
-					 sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_SET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			if (copy_from_user
-			    (&config, (void *)arg, sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-			if (config.pcm_feedback != audio->pcm_feedback) {
-				MM_ERR("Not sufficient permission to"
-					 "change the playback mode\n");
-				rc = -EACCES;
-				break;
-			}
-			if ((config.buffer_count > PCM_BUF_MAX_COUNT) ||
-			    (config.buffer_count == 1))
-				config.buffer_count = PCM_BUF_MAX_COUNT;
-
-			if (config.buffer_size < PCM_BUFSZ_MIN)
-				config.buffer_size = PCM_BUFSZ_MIN;
-
-			/* Check if pcm feedback is required */
-			if ((config.pcm_feedback) && (!audio->read_data)) {
-				MM_DBG("allocate PCM buffer %d\n",
-						config.buffer_count *
-						config.buffer_size);
-				handle = ion_alloc(audio->client,
-					(config.buffer_size *
-					config.buffer_count),
-					SZ_4K, ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-				if (IS_ERR_OR_NULL(handle)) {
-					MM_ERR("Unable to alloc I/P buffs\n");
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-					break;
-				}
-
-				audio->input_buff_handle = handle;
-
-				rc = ion_phys(audio->client ,
-					handle, &addr, &len);
-				if (rc) {
-					MM_ERR("Invalid phy: %x sz: %x\n",
-						(unsigned int) addr,
-						(unsigned int) len);
-					ion_free(audio->client, handle);
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-					break;
-				} else {
-					MM_INFO("Got valid phy: %x sz: %x\n",
-						(unsigned int) audio->read_phys,
-						(unsigned int) len);
-				}
-				audio->read_phys = (int32_t)addr;
-
-				rc = ion_handle_get_flags(audio->client,
-					handle, &ionflag);
-				if (rc) {
-					MM_ERR("could not get flags\n");
-					ion_free(audio->client, handle);
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-					break;
-				}
-
-				audio->map_v_read = ion_map_kernel(
-					audio->client, handle);
-				if (IS_ERR(audio->map_v_read)) {
-					MM_ERR("map of read buf failed\n");
-					ion_free(audio->client, handle);
-					audio->input_buff_handle = NULL;
-					rc = -ENOMEM;
-				} else {
-					uint8_t index;
-					uint32_t offset = 0;
-					audio->read_data =
-						audio->map_v_read;
-					audio->buf_refresh = 0;
-					audio->pcm_buf_count =
-					    config.buffer_count;
-					audio->read_next = 0;
-					audio->fill_next = 0;
-
-					for (index = 0;
-					     index < config.buffer_count;
-					     index++) {
-						audio->in[index].data =
-						    audio->read_data + offset;
-						audio->in[index].addr =
-						    audio->read_phys + offset;
-						audio->in[index].size =
-						    config.buffer_size;
-						audio->in[index].used = 0;
-						offset += config.buffer_size;
-					}
-					MM_DBG("read buf: phy addr \
-						0x%08x kernel addr 0x%08x\n",
-						audio->read_phys,
-						(int)audio->read_data);
-					rc = 0;
-				}
-			} else {
-				rc = 0;
-			}
-			break;
-		}
-	case AUDIO_PAUSE:
-		MM_DBG("AUDIO_PAUSE %ld\n", arg);
-		rc = audpp_pause(audio->dec_id, (int) arg);
-		break;
-	case AUDIO_GET_SESSION_ID:
-		if (copy_to_user((void *) arg, &audio->dec_id,
-					sizeof(unsigned short)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-/* Only useful in tunnel-mode */
-static int audio_fsync(struct file *file, loff_t ppos1, loff_t ppos2, int datasync)
-{
-	struct audio *audio = file->private_data;
-	struct buffer *frame;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	if (!audio->running || audio->pcm_feedback) {
-		rc = -EINVAL;
-		goto done_nolock;
-	}
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(!audio->out[0].used &&
-		!audio->out[1].used &&
-		audio->out_needed) || audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (audio->reserved) {
-		MM_DBG("send reserved byte\n");
-		frame = audio->out + audio->out_tail;
-		((char *) frame->data)[0] = audio->rsv_byte;
-		((char *) frame->data)[1] = 0;
-		frame->used = 2;
-		audplay_send_data(audio, 0);
-
-		rc = wait_event_interruptible(audio->write_wait,
-			(!audio->out[0].used &&
-			!audio->out[1].used &&
-			audio->out_needed) || audio->wflush);
-
-		if (rc < 0)
-			goto done;
-		else if (audio->wflush) {
-			rc = -EBUSY;
-			goto done;
-		}
-	}
-
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		audio->teos || audio->wflush);
-
-	if (audio->wflush)
-		rc = -EBUSY;
-
-done:
-	mutex_unlock(&audio->write_lock);
-done_nolock:
-	return rc;
-}
-
-static ssize_t audio_read(struct file *file, char __user *buf, size_t count,
-			  loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	int rc = 0;
-
-	if (!audio->pcm_feedback)
-		return 0; /* PCM feedback is not enabled. Nothing to read */
-
-	mutex_lock(&audio->read_lock);
-	MM_DBG("%d \n", count);
-	while (count > 0) {
-		rc = wait_event_interruptible(audio->read_wait,
-			(audio->in[audio->read_next].used > 0) ||
-			(audio->stopped) || (audio->rflush));
-
-		if (rc < 0)
-			break;
-
-		if (audio->stopped || audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (count < audio->in[audio->read_next].used) {
-			/* Read must happen in frame boundary. Since driver
-			   does not know frame size, read count must be greater
-			   or equal to size of PCM samples */
-			MM_DBG("audio_read: no partial frame done reading\n");
-			break;
-		} else {
-			MM_DBG("audio_read: read from in[%d]\n",
-					audio->read_next);
-			if (copy_to_user
-			    (buf, audio->in[audio->read_next].data,
-			     audio->in[audio->read_next].used)) {
-				MM_ERR("invalid addr %x \n", (unsigned int)buf);
-				rc = -EFAULT;
-				break;
-			}
-			count -= audio->in[audio->read_next].used;
-			buf += audio->in[audio->read_next].used;
-			audio->in[audio->read_next].used = 0;
-			if ((++audio->read_next) == audio->pcm_buf_count)
-				audio->read_next = 0;
-			break;	/* Force to exit while loop
-				 * to prevent output thread
-				 * sleep too long if data is
-				 * not ready at this moment.
-				 */
-		}
-	}
-
-	/* don't feed output buffer to HW decoder during flushing
-	 * buffer refresh command will be sent once flush completes
-	 * send buf refresh command here can confuse HW decoder
-	 */
-	if (audio->buf_refresh && !audio->rflush) {
-		audio->buf_refresh = 0;
-		MM_DBG("kick start pcm feedback again\n");
-		audplay_buffer_refresh(audio);
-	}
-
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		rc = buf - start;
-
-	MM_DBG("read %d bytes\n", rc);
-	return rc;
-}
-
-static int audwma_process_eos(struct audio *audio,
-		const char __user *buf_start, unsigned short mfield_size)
-{
-	int rc = 0;
-	struct buffer *frame;
-	char *buf_ptr;
-
-	if (audio->reserved) {
-		MM_DBG("flush reserve byte\n");
-		frame = audio->out + audio->out_head;
-		buf_ptr = frame->data;
-		rc = wait_event_interruptible(audio->write_wait,
-				(frame->used == 0)
-				|| (audio->stopped)
-				|| (audio->wflush));
-		if (rc < 0)
-			goto done;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			goto done;
-		}
-
-		buf_ptr[0] = audio->rsv_byte;
-		buf_ptr[1] = 0;
-		audio->out_head ^= 1;
-		frame->mfield_sz = 0;
-		frame->used = 2;
-		audio->reserved = 0;
-		audplay_send_data(audio, 0);
-	}
-
-	frame = audio->out + audio->out_head;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	audplay_send_data(audio, 0);
-done:
-	return rc;
-}
-
-static ssize_t audio_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	size_t xfer;
-	char *cpy_ptr;
-	int rc = 0, eos_condition = AUDWMA_EOS_NONE;
-	unsigned dsize;
-	unsigned short mfield_size = 0;
-
-	MM_DBG("cnt=%d\n", count);
-
-	mutex_lock(&audio->write_lock);
-	while (count > 0) {
-		frame = audio->out + audio->out_head;
-		cpy_ptr = frame->data;
-		dsize = 0;
-		rc = wait_event_interruptible(audio->write_wait,
-					      (frame->used == 0)
-					      || (audio->stopped)
-						  || (audio->wflush));
-		if (rc < 0)
-			break;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			break;
-		}
-		if (audio->mfield) {
-			if (buf == start) {
-				/* Processing beginning of user buffer */
-				if (__get_user(mfield_size,
-					(unsigned short __user *) buf)) {
-					rc = -EFAULT;
-					break;
-				} else  if (mfield_size > count) {
-					rc = -EINVAL;
-					break;
-				}
-				MM_DBG("audio_write: mf offset_val %x\n",
-						mfield_size);
-				if (copy_from_user(cpy_ptr, buf, mfield_size)) {
-					rc = -EFAULT;
-					break;
-				}
-				/* Check if EOS flag is set and buffer has
-				 * contains just meta field
-				 */
-				if (cpy_ptr[AUDWMA_EOS_FLG_OFFSET] &
-						 AUDWMA_EOS_FLG_MASK) {
-					MM_DBG("audio_write: EOS SET\n");
-					eos_condition = AUDWMA_EOS_SET;
-					if (mfield_size == count) {
-						buf += mfield_size;
-						break;
-					} else
-						cpy_ptr[AUDWMA_EOS_FLG_OFFSET]
-							&= ~AUDWMA_EOS_FLG_MASK;
-				}
-				cpy_ptr += mfield_size;
-				count -= mfield_size;
-				dsize += mfield_size;
-				buf += mfield_size;
-			} else {
-				mfield_size = 0;
-				MM_DBG("audio_write: continuous buffer\n");
-			}
-			frame->mfield_sz = mfield_size;
-		}
-
-		if (audio->reserved) {
-			MM_DBG("append reserved byte %x\n", audio->rsv_byte);
-			*cpy_ptr = audio->rsv_byte;
-			xfer = (count > ((frame->size - mfield_size) - 1)) ?
-				(frame->size - mfield_size) - 1 : count;
-			cpy_ptr++;
-			dsize += 1;
-			audio->reserved = 0;
-		} else
-			xfer = (count > (frame->size - mfield_size)) ?
-				(frame->size - mfield_size) : count;
-
-		if (copy_from_user(cpy_ptr, buf, xfer)) {
-			rc = -EFAULT;
-			break;
-		}
-
-		dsize += xfer;
-		if (dsize & 1) {
-			audio->rsv_byte = ((char *) frame->data)[dsize - 1];
-			MM_DBG("odd length buf reserve last byte %x\n",
-					audio->rsv_byte);
-			audio->reserved = 1;
-			dsize--;
-		}
-		count -= xfer;
-		buf += xfer;
-
-		if (dsize > 0) {
-			audio->out_head ^= 1;
-			frame->used = dsize;
-			audplay_send_data(audio, 0);
-		}
-	}
-	if (eos_condition == AUDWMA_EOS_SET)
-		rc = audwma_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	if (!rc) {
-		if (buf > start)
-			return buf - start;
-	}
-	return rc;
-}
-
-static int audio_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	MM_INFO("audio instance 0x%08x freeing\n", (int)audio);
-	mutex_lock(&audio->lock);
-	auddev_unregister_evt_listner(AUDDEV_CLNT_DEC, audio->dec_id);
-	audio_disable(audio);
-	audio_flush(audio);
-	audio_flush_pcm_buf(audio);
-	msm_adsp_put(audio->audplay);
-	audpp_adec_free(audio->dec_id);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	unregister_early_suspend(&audio->suspend_ctl.node);
-#endif
-	audio->event_abort = 1;
-	wake_up(&audio->event_wait);
-	audwma_reset_event_queue(audio);
-	ion_unmap_kernel(audio->client, audio->output_buff_handle);
-	ion_free(audio->client, audio->output_buff_handle);
-	if (audio->input_buff_handle != NULL) {
-		ion_unmap_kernel(audio->client, audio->input_buff_handle);
-		ion_free(audio->client, audio->input_buff_handle);
-	}
-	ion_client_destroy(audio->client);
-	mutex_unlock(&audio->lock);
-#ifdef CONFIG_DEBUG_FS
-	if (audio->dentry)
-		debugfs_remove(audio->dentry);
-#endif
-	kfree(audio);
-	return 0;
-}
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audwma_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload)
-{
-	struct audwma_event *e_node = NULL;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-
-	if (!list_empty(&audio->free_event_queue)) {
-		e_node = list_first_entry(&audio->free_event_queue,
-				struct audwma_event, list);
-		list_del(&e_node->list);
-	} else {
-		e_node = kmalloc(sizeof(struct audwma_event), GFP_ATOMIC);
-		if (!e_node) {
-			MM_ERR("No mem to post event %d\n", type);
-			return;
-		}
-	}
-
-	e_node->event_type = type;
-	e_node->payload = payload;
-
-	list_add_tail(&e_node->list, &audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	wake_up(&audio->event_wait);
-}
-
-static void audwma_suspend(struct early_suspend *h)
-{
-	struct audwma_suspend_ctl *ctl =
-		container_of(h, struct audwma_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audwma_post_event(ctl->audio, AUDIO_EVENT_SUSPEND, payload);
-}
-
-static void audwma_resume(struct early_suspend *h)
-{
-	struct audwma_suspend_ctl *ctl =
-		container_of(h, struct audwma_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audwma_post_event(ctl->audio, AUDIO_EVENT_RESUME, payload);
-}
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-static ssize_t audwma_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static ssize_t audwma_debug_read(struct file *file, char __user *buf,
-			  size_t count, loff_t *ppos)
-{
-	const int debug_bufmax = 4096;
-	static char buffer[4096];
-	int n = 0, i;
-	struct audio *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	n = scnprintf(buffer, debug_bufmax, "opened %d\n", audio->opened);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "enabled %d\n", audio->enabled);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "stopped %d\n", audio->stopped);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "pcm_feedback %d\n", audio->pcm_feedback);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_buf_sz %d\n", audio->out[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "pcm_buf_count %d \n", audio->pcm_buf_count);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "pcm_buf_sz %d \n", audio->in[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "volume %x \n", audio->vol_pan.volume);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "sample rate %d \n", audio->out_sample_rate);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-		"channel mode %d \n", audio->out_channel_mode);
-	mutex_unlock(&audio->lock);
-	/* Following variables are only useful for debugging when
-	 * when playback halts unexpectedly. Thus, no mutual exclusion
-	 * enforced
-	 */
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "wflush %d\n", audio->wflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "rflush %d\n", audio->rflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "running %d \n", audio->running);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"dec state %d \n", audio->dec_state);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_needed %d \n", audio->out_needed);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_head %d \n", audio->out_head);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_tail %d \n", audio->out_tail);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out[0].used %d \n", audio->out[0].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out[1].used %d \n", audio->out[1].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "buffer_refresh %d \n", audio->buf_refresh);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "read_next %d \n", audio->read_next);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "fill_next %d \n", audio->fill_next);
-	for (i = 0; i < audio->pcm_buf_count; i++)
-		n += scnprintf(buffer + n, debug_bufmax - n,
-			"in[%d].size %d \n", i, audio->in[i].used);
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations audwma_debug_fops = {
-	.read = audwma_debug_read,
-	.open = audwma_debug_open,
-};
-#endif
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = NULL;
-	int rc, dec_attrb, decid, i;
-	unsigned mem_sz = DMASZ_MAX;
-	struct audwma_event *e_node = NULL;
-	unsigned long ionflag = 0;
-	ion_phys_addr_t addr = 0;
-	struct ion_handle *handle = NULL;
-	struct ion_client *client = NULL;
-	int len = 0;
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_wma_" + 5];
-#endif
-
-	/* Allocate Mem for audio instance */
-	audio = kzalloc(sizeof(struct audio), GFP_KERNEL);
-	if (!audio) {
-		MM_ERR("no memory to allocate audio instance \n");
-		rc = -ENOMEM;
-		goto done;
-	}
-	MM_INFO("audio instance 0x%08x created\n", (int)audio);
-
-	/* Allocate the decoder */
-	dec_attrb = AUDDEC_DEC_WMA;
-	if ((file->f_mode & FMODE_WRITE) &&
-			(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_NONTUNNEL;
-		audio->pcm_feedback = NON_TUNNEL_MODE_PLAYBACK;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_TUNNEL;
-		audio->pcm_feedback = TUNNEL_MODE_PLAYBACK;
-	} else {
-		kfree(audio);
-		rc = -EACCES;
-		goto done;
-	}
-
-	decid = audpp_adec_alloc(dec_attrb, &audio->module_name,
-			&audio->queue_id);
-
-	if (decid < 0) {
-		MM_ERR("No free decoder available, freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENODEV;
-		kfree(audio);
-		goto done;
-	}
-	audio->dec_id = decid & MSM_AUD_DECODER_MASK;
-
-	client = msm_ion_client_create(UINT_MAX, "Audio_WMA_Client");
-	if (IS_ERR_OR_NULL(client)) {
-		pr_err("Unable to create ION client\n");
-		rc = -ENOMEM;
-		goto client_create_error;
-	}
-	audio->client = client;
-
-	handle = ion_alloc(client, mem_sz, SZ_4K,
-		ION_HEAP(ION_AUDIO_HEAP_ID), 0);
-	if (IS_ERR_OR_NULL(handle)) {
-		MM_ERR("Unable to create allocate O/P buffers\n");
-		rc = -ENOMEM;
-		goto output_buff_alloc_error;
-	}
-	audio->output_buff_handle = handle;
-
-	rc = ion_phys(client, handle, &addr, &len);
-	if (rc) {
-		MM_ERR("O/P buffers:Invalid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-		goto output_buff_get_phys_error;
-	} else {
-		MM_INFO("O/P buffers:valid phy: %x sz: %x\n",
-			(unsigned int) addr, (unsigned int) len);
-	}
-	audio->phys = (int32_t)addr;
-
-
-	rc = ion_handle_get_flags(client, handle, &ionflag);
-	if (rc) {
-		MM_ERR("could not get flags for the handle\n");
-		goto output_buff_get_flags_error;
-	}
-
-	audio->map_v_write = ion_map_kernel(client, handle);
-	if (IS_ERR(audio->map_v_write)) {
-		MM_ERR("could not map write buffers\n");
-		rc = -ENOMEM;
-		goto output_buff_map_error;
-	}
-			audio->data = audio->map_v_write;
-	MM_DBG("write buf: phy addr 0x%08x kernel addr 0x%08x\n",
-		audio->phys, (int)audio->data);
-
-	audio->out_dma_sz = mem_sz;
-
-	rc = msm_adsp_get(audio->module_name, &audio->audplay,
-			&audplay_adsp_ops_wma, audio);
-	if (rc) {
-		MM_ERR("failed to get %s module, freeing instance 0x%08x\n",
-				audio->module_name, (int)audio);
-		goto err;
-	}
-
-	mutex_init(&audio->lock);
-	mutex_init(&audio->write_lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->get_event_lock);
-	spin_lock_init(&audio->dsp_lock);
-	init_waitqueue_head(&audio->write_wait);
-	init_waitqueue_head(&audio->read_wait);
-	INIT_LIST_HEAD(&audio->free_event_queue);
-	INIT_LIST_HEAD(&audio->event_queue);
-	init_waitqueue_head(&audio->wait);
-	init_waitqueue_head(&audio->event_wait);
-	spin_lock_init(&audio->event_queue_lock);
-	init_waitqueue_head(&audio->avsync_wait);
-
-	audio->out[0].data = audio->data + 0;
-	audio->out[0].addr = audio->phys + 0;
-	audio->out[0].size = audio->out_dma_sz >> 1;
-
-	audio->out[1].data = audio->data + audio->out[0].size;
-	audio->out[1].addr = audio->phys + audio->out[0].size;
-	audio->out[1].size = audio->out[0].size;
-
-	audio->wma_config.armdatareqthr =  1262;
-	audio->wma_config.channelsdecoded = 2;
-	audio->wma_config.wmabytespersec = 6003;
-	audio->wma_config.wmasamplingfreq = 44100;
-	audio->wma_config.wmaencoderopts = 31;
-
-	audio->out_sample_rate = 44100;
-	audio->out_channel_mode = AUDPP_CMD_PCM_INTF_STEREO_V;
-
-	audio->vol_pan.volume = 0x2000;
-
-	audio_flush(audio);
-
-	file->private_data = audio;
-	audio->opened = 1;
-
-	audio->device_events = AUDDEV_EVT_DEV_RDY
-				|AUDDEV_EVT_DEV_RLS|
-				AUDDEV_EVT_STREAM_VOL_CHG;
-
-	rc = auddev_register_evt_listner(audio->device_events,
-					AUDDEV_CLNT_DEC,
-					audio->dec_id,
-					wma_listner,
-					(void *)audio);
-	if (rc) {
-		MM_ERR("%s: failed to register listner\n", __func__);
-		goto event_err;
-	}
-
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof name, "msm_wma_%04x", audio->dec_id);
-	audio->dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
-				NULL, (void *) audio,
-				&audwma_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		MM_DBG("debugfs_create_file failed\n");
-#endif
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	audio->suspend_ctl.node.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
-	audio->suspend_ctl.node.resume = audwma_resume;
-	audio->suspend_ctl.node.suspend = audwma_suspend;
-	audio->suspend_ctl.audio = audio;
-	register_early_suspend(&audio->suspend_ctl.node);
-#endif
-	for (i = 0; i < AUDWMA_EVENT_NUM; i++) {
-		e_node = kmalloc(sizeof(struct audwma_event), GFP_KERNEL);
-		if (e_node)
-			list_add_tail(&e_node->list, &audio->free_event_queue);
-		else {
-			MM_ERR("event pkt alloc failed\n");
-			break;
-		}
-	}
-done:
-	return rc;
-event_err:
-	msm_adsp_put(audio->audplay);
-err:
-	ion_unmap_kernel(client, audio->output_buff_handle);
-output_buff_map_error:
-output_buff_get_phys_error:
-output_buff_get_flags_error:
-	ion_free(client, audio->output_buff_handle);
-output_buff_alloc_error:
-	ion_client_destroy(client);
-client_create_error:
-	audpp_adec_free(audio->dec_id);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_wma_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audio_open,
-	.release	= audio_release,
-	.read 		= audio_read,
-	.write		= audio_write,
-	.unlocked_ioctl	= audio_ioctl,
-	.fsync 		= audio_fsync,
-};
-
-struct miscdevice audio_wma_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_wma",
-	.fops	= &audio_wma_fops,
-};
-
-static int __init audio_init(void)
-{
-	return misc_register(&audio_wma_misc);
-}
-
-device_initcall(audio_init);
diff --git a/arch/arm/mach-msm/qdsp5v2/audio_wmapro.c b/arch/arm/mach-msm/qdsp5v2/audio_wmapro.c
deleted file mode 100644
index 44fc10f..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audio_wmapro.c
+++ /dev/null
@@ -1,1814 +0,0 @@
-/* Copyright (c) 2009-2012, The Linux Foundation. All rights reserved.
- *
- * Based on the mp3 native driver in arch/arm/mach-msm/qdsp5v2/audio_mp3.c
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (C) 2008 HTC Corporation
- *
- * All source code in this file is licensed under the following license except
- * where indicated.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, you can find it at http://www.fsf.org
- */
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/list.h>
-#include <linux/earlysuspend.h>
-#include <linux/msm_audio.h>
-#include <linux/slab.h>
-#include <linux/msm_audio_wmapro.h>
-#include <linux/memory_alloc.h>
-
-#include <mach/msm_adsp.h>
-#include <mach/iommu.h>
-#include <mach/iommu_domains.h>
-#include <mach/qdsp5v2/qdsp5audppmsg.h>
-#include <mach/qdsp5v2/qdsp5audplaycmdi.h>
-#include <mach/qdsp5v2/qdsp5audplaymsg.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/qdsp5v2/audpp.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_memtypes.h>
-
-
-/* Size must be power of 2 */
-#define BUFSZ_MAX 	4110	/* Includes meta in size */
-#define BUFSZ_MIN 	2062	/* Includes meta in size */
-#define DMASZ_MAX 	(BUFSZ_MAX * 2)
-#define DMASZ_MIN 	(BUFSZ_MIN * 2)
-
-#define AUDPLAY_INVALID_READ_PTR_OFFSET	0xFFFF
-#define AUDDEC_DEC_WMAPRO 13
-
-#define PCM_BUFSZ_MIN 	8216 	/* Hold one stereo WMAPRO frame and meta out*/
-#define PCM_BUF_MAX_COUNT 5	/* DSP only accepts 5 buffers at most
-				   but support 2 buffers currently */
-#define ROUTING_MODE_FTRT 1
-#define ROUTING_MODE_RT 2
-/* Decoder status received from AUDPPTASK */
-#define  AUDPP_DEC_STATUS_SLEEP	0
-#define	 AUDPP_DEC_STATUS_INIT  1
-#define  AUDPP_DEC_STATUS_CFG   2
-#define  AUDPP_DEC_STATUS_PLAY  3
-
-#define AUDWMAPRO_METAFIELD_MASK 0xFFFF0000
-#define AUDWMAPRO_EOS_FLG_OFFSET 0x0A /* Offset from beginning of buffer */
-#define AUDWMAPRO_EOS_FLG_MASK 0x01
-#define AUDWMAPRO_EOS_NONE 0x0 /* No EOS detected */
-#define AUDWMAPRO_EOS_SET 0x1 /* EOS set in meta field */
-
-#define AUDWMAPRO_EVENT_NUM 10 /* Default no. of pre-allocated event packets */
-
-struct buffer {
-	void *data;
-	unsigned size;
-	unsigned used;		/* Input usage actual DSP produced PCM size  */
-	unsigned addr;
-	unsigned short mfield_sz; /*only useful for data has meta field */
-};
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-struct audwmapro_suspend_ctl {
-	struct early_suspend node;
-	struct audio *audio;
-};
-#endif
-
-struct audwmapro_event{
-	struct list_head list;
-	int event_type;
-	union msm_audio_event_payload payload;
-};
-
-struct audio {
-	struct buffer out[2];
-
-	spinlock_t dsp_lock;
-
-	uint8_t out_head;
-	uint8_t out_tail;
-	uint8_t out_needed; /* number of buffers the dsp is waiting for */
-	unsigned out_dma_sz;
-
-	atomic_t out_bytes;
-
-	struct mutex lock;
-	struct mutex write_lock;
-	wait_queue_head_t write_wait;
-
-	/* Host PCM section */
-	struct buffer in[PCM_BUF_MAX_COUNT];
-	struct mutex read_lock;
-	wait_queue_head_t read_wait;	/* Wait queue for read */
-	char *read_data;	/* pointer to reader buffer */
-	int32_t read_phys;	/* physical address of reader buffer */
-	uint8_t read_next;	/* index to input buffers to be read next */
-	uint8_t fill_next;	/* index to buffer that DSP should be filling */
-	uint8_t pcm_buf_count;	/* number of pcm buffer allocated */
-	/* ---- End of Host PCM section */
-
-	struct msm_adsp_module *audplay;
-
-	/* configuration to use on next enable */
-	uint32_t out_sample_rate;
-	uint32_t out_channel_mode;
-
-	struct msm_audio_wmapro_config wmapro_config;
-
-	/* data allocated for various buffers */
-	char *data;
-	int32_t phys; /* physical address of write buffer */
-	void *map_v_read;
-	void *map_v_write;
-
-	int mfield; /* meta field embedded in data */
-	int rflush; /* Read  flush */
-	int wflush; /* Write flush */
-	int opened;
-	int enabled;
-	int running;
-	int stopped; /* set when stopped, cleared on flush */
-	int pcm_feedback;
-	int buf_refresh;
-	int teos; /* valid only if tunnel mode & no data left for decoder */
-	enum msm_aud_decoder_state dec_state;	/* Represents decoder state */
-	int reserved; /* A byte is being reserved */
-	char rsv_byte; /* Handle odd length user data */
-
-	const char *module_name;
-	unsigned queue_id;
-	uint16_t dec_id;
-	uint32_t read_ptr_offset;
-	int16_t source;
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	struct audwmapro_suspend_ctl suspend_ctl;
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-	struct dentry *dentry;
-#endif
-
-	wait_queue_head_t wait;
-	struct list_head free_event_queue;
-	struct list_head event_queue;
-	wait_queue_head_t event_wait;
-	spinlock_t event_queue_lock;
-	struct mutex get_event_lock;
-	int event_abort;
-	/* AV sync Info */
-	int avsync_flag;              /* Flag to indicate feedback from DSP */
-	wait_queue_head_t avsync_wait;/* Wait queue for AV Sync Message     */
-	/* flags, 48 bits sample/bytes counter per channel */
-	uint16_t avsync[AUDPP_AVSYNC_CH_COUNT * AUDPP_AVSYNC_NUM_WORDS + 1];
-
-	uint32_t device_events;
-
-	int eq_enable;
-	int eq_needs_commit;
-	struct audpp_cmd_cfg_object_params_eqalizer eq;
-	struct audpp_cmd_cfg_object_params_volume vol_pan;
-};
-
-static int auddec_dsp_config(struct audio *audio, int enable);
-static void audpp_cmd_cfg_adec_params(struct audio *audio);
-static void audpp_cmd_cfg_routing_mode(struct audio *audio);
-static void audplay_send_data(struct audio *audio, unsigned needed);
-static void audplay_config_hostpcm(struct audio *audio);
-static void audplay_buffer_refresh(struct audio *audio);
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audwmapro_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload);
-#endif
-
-/* must be called with audio->lock held */
-static int audio_enable(struct audio *audio)
-{
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled)
-		return 0;
-
-	audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-	audio->out_tail = 0;
-	audio->out_needed = 0;
-
-	if (msm_adsp_enable(audio->audplay)) {
-		MM_ERR("msm_adsp_enable(audplay) failed\n");
-		return -ENODEV;
-	}
-
-	if (audpp_enable(audio->dec_id, audio_dsp_event, audio)) {
-		MM_ERR("audpp_enable() failed\n");
-		msm_adsp_disable(audio->audplay);
-		return -ENODEV;
-	}
-
-	audio->enabled = 1;
-	return 0;
-}
-
-static void wmapro_listner(u32 evt_id, union auddev_evt_data *evt_payload,
-			void *private_data)
-{
-	struct audio *audio = (struct audio *) private_data;
-	switch (evt_id) {
-	case AUDDEV_EVT_DEV_RDY:
-		MM_DBG(":AUDDEV_EVT_DEV_RDY\n");
-		audio->source |= (0x1 << evt_payload->routing_id);
-		if (audio->running == 1 && audio->enabled == 1)
-			audpp_route_stream(audio->dec_id, audio->source);
-		break;
-	case AUDDEV_EVT_DEV_RLS:
-		MM_DBG(":AUDDEV_EVT_DEV_RLS\n");
-		audio->source &= ~(0x1 << evt_payload->routing_id);
-		if (audio->running == 1 && audio->enabled == 1)
-			audpp_route_stream(audio->dec_id, audio->source);
-		break;
-	case AUDDEV_EVT_STREAM_VOL_CHG:
-		audio->vol_pan.volume = evt_payload->session_vol;
-		MM_DBG(":AUDDEV_EVT_STREAM_VOL_CHG, stream vol %d\n",
-				audio->vol_pan.volume);
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		break;
-	default:
-		MM_ERR(":ERROR:wrong event\n");
-		break;
-	}
-}
-
-/* must be called with audio->lock held */
-static int audio_disable(struct audio *audio)
-{
-	int rc = 0;
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	if (audio->enabled) {
-		audio->enabled = 0;
-		audio->dec_state = MSM_AUD_DECODER_STATE_NONE;
-		auddec_dsp_config(audio, 0);
-		rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-		if (rc == 0)
-			rc = -ETIMEDOUT;
-		else if (audio->dec_state != MSM_AUD_DECODER_STATE_CLOSE)
-			rc = -EFAULT;
-		else
-			rc = 0;
-		wake_up(&audio->write_wait);
-		wake_up(&audio->read_wait);
-		msm_adsp_disable(audio->audplay);
-		audpp_disable(audio->dec_id, audio);
-		audio->out_needed = 0;
-	}
-	return rc;
-}
-
-/* ------------------- dsp --------------------- */
-static void audio_update_pcm_buf_entry(struct audio *audio,
-	uint32_t *payload)
-{
-	uint8_t index;
-	unsigned long flags;
-
-	if (audio->rflush)
-		return;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	for (index = 0; index < payload[1]; index++) {
-		if (audio->in[audio->fill_next].addr ==
-			payload[2 + index * 2]) {
-			MM_DBG("audio_update_pcm_buf_entry: \
-				in[%d] ready\n", audio->fill_next);
-			audio->in[audio->fill_next].used =
-			payload[3 + index * 2];
-			if ((++audio->fill_next) == audio->pcm_buf_count)
-				audio->fill_next = 0;
-		} else {
-			MM_ERR("audio_update_pcm_buf_entry: \
-				expected=%x ret=%x\n",
-				audio->in[audio->fill_next].addr,
-				payload[1 + index * 2]);
-			break;
-		}
-	}
-	if (audio->in[audio->fill_next].used == 0) {
-		audplay_buffer_refresh(audio);
-	} else {
-		MM_DBG("read cannot keep up\n");
-		audio->buf_refresh = 1;
-	}
-	wake_up(&audio->read_wait);
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-static void audplay_dsp_event(void *data, unsigned id, size_t len,
-			      void (*getevent) (void *ptr, size_t len))
-{
-	struct audio *audio = data;
-	uint32_t msg[28];
-
-	getevent(msg, sizeof(msg));
-
-	MM_DBG("msg_id=%x\n", id);
-
-	switch (id) {
-	case AUDPLAY_MSG_DEC_NEEDS_DATA:
-		audplay_send_data(audio, 1);
-		break;
-
-	case AUDPLAY_MSG_BUFFER_UPDATE:
-		audio_update_pcm_buf_entry(audio, msg);
-		break;
-
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable(audplaytask)\n");
-		break;
-
-	default:
-		MM_ERR("unexpected message from decoder \n");
-		break;
-	}
-}
-
-static void audio_dsp_event(void *private, unsigned id, uint16_t *msg)
-{
-	struct audio *audio = private;
-
-	switch (id) {
-	case AUDPP_MSG_STATUS_MSG:{
-			unsigned status = msg[1];
-
-			switch (status) {
-			case AUDPP_DEC_STATUS_SLEEP: {
-				uint16_t reason = msg[2];
-				MM_DBG("decoder status:sleep reason = \
-						0x%04x\n", reason);
-				if ((reason == AUDPP_MSG_REASON_MEM)
-					|| (reason ==
-					AUDPP_MSG_REASON_NODECODER)) {
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_FAILURE;
-					wake_up(&audio->wait);
-				} else if (reason == AUDPP_MSG_REASON_NONE) {
-					/* decoder is in disable state */
-					audio->dec_state =
-						MSM_AUD_DECODER_STATE_CLOSE;
-					wake_up(&audio->wait);
-				}
-				break;
-			}
-			case AUDPP_DEC_STATUS_INIT:
-				MM_DBG("decoder status: init\n");
-				if (audio->pcm_feedback)
-					audpp_cmd_cfg_routing_mode(audio);
-				else
-					audpp_cmd_cfg_adec_params(audio);
-				break;
-
-			case AUDPP_DEC_STATUS_CFG:
-				MM_DBG("decoder status: cfg\n");
-				break;
-			case AUDPP_DEC_STATUS_PLAY:
-				MM_DBG("decoder status: play \n");
-				audpp_route_stream(audio->dec_id,
-						audio->source);
-				if (audio->pcm_feedback) {
-					audplay_config_hostpcm(audio);
-					audplay_buffer_refresh(audio);
-				}
-				audio->dec_state =
-					MSM_AUD_DECODER_STATE_SUCCESS;
-				wake_up(&audio->wait);
-				break;
-			default:
-				MM_ERR("unknown decoder status\n");
-			}
-			break;
-		}
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_DBG("CFG_MSG ENABLE\n");
-			auddec_dsp_config(audio, 1);
-			audio->out_needed = 0;
-			audio->running = 1;
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-			audpp_dsp_set_eq(audio->dec_id, audio->eq_enable,
-					&audio->eq, POPP);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			MM_DBG("CFG_MSG DISABLE\n");
-			audio->running = 0;
-		} else {
-			MM_DBG("CFG_MSG %d?\n", msg[0]);
-		}
-		break;
-	case AUDPP_MSG_ROUTING_ACK:
-		MM_DBG("ROUTING_ACK mode=%d\n", msg[1]);
-		audpp_cmd_cfg_adec_params(audio);
-		break;
-
-	case AUDPP_MSG_FLUSH_ACK:
-		MM_DBG("FLUSH_ACK\n");
-		audio->wflush = 0;
-		audio->rflush = 0;
-		wake_up(&audio->write_wait);
-		if (audio->pcm_feedback)
-			audplay_buffer_refresh(audio);
-		break;
-
-	case AUDPP_MSG_PCMDMAMISSED:
-		MM_DBG("PCMDMAMISSED\n");
-		audio->teos = 1;
-		wake_up(&audio->write_wait);
-		break;
-
-	case AUDPP_MSG_AVSYNC_MSG:
-		MM_DBG("AUDPP_MSG_AVSYNC_MSG\n");
-		memcpy(&audio->avsync[0], msg, sizeof(audio->avsync));
-		audio->avsync_flag = 1;
-		wake_up(&audio->avsync_wait);
-		break;
-
-	default:
-		MM_ERR("UNKNOWN (%d)\n", id);
-	}
-
-}
-
-static struct msm_adsp_ops audplay_adsp_ops_wmapro = {
-	.event = audplay_dsp_event,
-};
-
-#define audplay_send_queue0(audio, cmd, len) \
-	msm_adsp_write(audio->audplay, audio->queue_id, \
-			cmd, len)
-
-static int auddec_dsp_config(struct audio *audio, int enable)
-{
-	struct audpp_cmd_cfg_dec_type cfg_dec_cmd;
-
-	memset(&cfg_dec_cmd, 0, sizeof(cfg_dec_cmd));
-
-	cfg_dec_cmd.cmd_id = AUDPP_CMD_CFG_DEC_TYPE;
-	if (enable)
-		cfg_dec_cmd.dec_cfg = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_ENA_DEC_V | AUDDEC_DEC_WMAPRO;
-	else
-		cfg_dec_cmd.dec_cfg = AUDPP_CMD_UPDATDE_CFG_DEC |
-				AUDPP_CMD_DIS_DEC_V;
-	cfg_dec_cmd.dm_mode = 0x0;
-	cfg_dec_cmd.stream_id = audio->dec_id;
-	return audpp_send_queue1(&cfg_dec_cmd, sizeof(cfg_dec_cmd));
-}
-
-static void audpp_cmd_cfg_adec_params(struct audio *audio)
-{
-	struct audpp_cmd_cfg_adec_params_wmapro cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_CMD_CFG_ADEC_PARAMS;
-	cmd.common.length = AUDPP_CMD_CFG_ADEC_PARAMS_WMAPRO_LEN;
-	cmd.common.dec_id = audio->dec_id;
-	cmd.common.input_sampling_frequency = audio->out_sample_rate;
-
-	/*
-	 * Test done for sample with the following configuration
-	 * armdatareqthr 	= 1262
-	 * channelsdecoded 	= 1(MONO)/2(STEREO)
-	 * wmaprobytespersec 	= Tested with 6003 Bytes per sec
-	 * wmaprosamplingfreq	= 44100
-	 * wmaproencoderopts	= 31
-	 */
-
-	cmd.armdatareqthr = audio->wmapro_config.armdatareqthr;
-	cmd.numchannels = audio->wmapro_config.numchannels;
-	cmd.validbitspersample = audio->wmapro_config.validbitspersample;
-	cmd.formattag = audio->wmapro_config.formattag;
-	cmd.samplingrate = audio->wmapro_config.samplingrate;
-	cmd.avgbytespersecond = audio->wmapro_config.avgbytespersecond;
-	cmd.asfpacketlength = audio->wmapro_config.asfpacketlength;
-	cmd.channelmask = audio->wmapro_config.channelmask;
-	cmd.encodeopt = audio->wmapro_config.encodeopt;
-	cmd.advancedencodeopt = audio->wmapro_config.advancedencodeopt;
-	cmd.advancedencodeopt2 = audio->wmapro_config.advancedencodeopt2;
-
-	audpp_send_queue2(&cmd, sizeof(cmd));
-}
-
-static void audpp_cmd_cfg_routing_mode(struct audio *audio)
-{
-	struct audpp_cmd_routing_mode cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPP_CMD_ROUTING_MODE;
-	cmd.object_number = audio->dec_id;
-	if (audio->pcm_feedback)
-		cmd.routing_mode = ROUTING_MODE_FTRT;
-	else
-		cmd.routing_mode = ROUTING_MODE_RT;
-
-	audpp_send_queue1(&cmd, sizeof(cmd));
-}
-
-static void audplay_buffer_refresh(struct audio *audio)
-{
-	struct audplay_cmd_buffer_refresh refresh_cmd;
-
-	refresh_cmd.cmd_id = AUDPLAY_CMD_BUFFER_REFRESH;
-	refresh_cmd.num_buffers = 1;
-	refresh_cmd.buf0_address = audio->in[audio->fill_next].addr;
-	refresh_cmd.buf0_length = audio->in[audio->fill_next].size;
-	refresh_cmd.buf_read_count = 0;
-
-	MM_DBG("buf0_addr=%x buf0_len=%d\n",
-			refresh_cmd.buf0_address,
-			refresh_cmd.buf0_length);
-
-	(void)audplay_send_queue0(audio, &refresh_cmd, sizeof(refresh_cmd));
-}
-
-static void audplay_config_hostpcm(struct audio *audio)
-{
-	struct audplay_cmd_hpcm_buf_cfg cfg_cmd;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	cfg_cmd.cmd_id = AUDPLAY_CMD_HPCM_BUF_CFG;
-	cfg_cmd.max_buffers = audio->pcm_buf_count;
-	cfg_cmd.byte_swap = 0;
-	cfg_cmd.hostpcm_config = (0x8000) | (0x4000);
-	cfg_cmd.feedback_frequency = 1;
-	cfg_cmd.partition_number = 0;
-
-	(void)audplay_send_queue0(audio, &cfg_cmd, sizeof(cfg_cmd));
-}
-
-
-static int audplay_dsp_send_data_avail(struct audio *audio,
-					unsigned idx, unsigned len)
-{
-	struct audplay_cmd_bitstream_data_avail_nt2 cmd;
-
-	cmd.cmd_id		= AUDPLAY_CMD_BITSTREAM_DATA_AVAIL_NT2;
-	if (audio->mfield)
-		cmd.decoder_id = AUDWMAPRO_METAFIELD_MASK |
-			(audio->out[idx].mfield_sz >> 1);
-	else
-		cmd.decoder_id		= audio->dec_id;
-	cmd.buf_ptr		= audio->out[idx].addr;
-	cmd.buf_size		= len/2;
-	cmd.partition_number	= 0;
-	return audplay_send_queue0(audio, &cmd, sizeof(cmd));
-}
-
-static void audplay_send_data(struct audio *audio, unsigned needed)
-{
-	struct buffer *frame;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->dsp_lock, flags);
-	if (!audio->running)
-		goto done;
-
-	if (audio->wflush) {
-		audio->out_needed = 1;
-		goto done;
-	}
-
-	if (needed && !audio->wflush) {
-		/* We were called from the callback because the DSP
-		 * requested more data.  Note that the DSP does want
-		 * more data, and if a buffer was in-flight, mark it
-		 * as available (since the DSP must now be done with
-		 * it).
-		 */
-		audio->out_needed = 1;
-		frame = audio->out + audio->out_tail;
-		if (frame->used == 0xffffffff) {
-			MM_DBG("frame %d free\n", audio->out_tail);
-			frame->used = 0;
-			audio->out_tail ^= 1;
-			wake_up(&audio->write_wait);
-		}
-	}
-
-	if (audio->out_needed) {
-		/* If the DSP currently wants data and we have a
-		 * buffer available, we will send it and reset
-		 * the needed flag.  We'll mark the buffer as in-flight
-		 * so that it won't be recycled until the next buffer
-		 * is requested
-		 */
-
-		MM_DBG("\n"); /* Macro prints the file name and function */
-		frame = audio->out + audio->out_tail;
-		if (frame->used) {
-			BUG_ON(frame->used == 0xffffffff);
-			MM_DBG("frame %d busy\n", audio->out_tail);
-			audplay_dsp_send_data_avail(audio, audio->out_tail,
-								frame->used);
-			frame->used = 0xffffffff;
-			audio->out_needed = 0;
-		}
-	}
-done:
-	spin_unlock_irqrestore(&audio->dsp_lock, flags);
-}
-
-/* ------------------- device --------------------- */
-
-static void audio_flush(struct audio *audio)
-{
-	audio->out[0].used = 0;
-	audio->out[1].used = 0;
-	audio->out_head = 0;
-	audio->out_tail = 0;
-	audio->reserved = 0;
-	atomic_set(&audio->out_bytes, 0);
-}
-
-static void audio_flush_pcm_buf(struct audio *audio)
-{
-	uint8_t index;
-
-	for (index = 0; index < PCM_BUF_MAX_COUNT; index++)
-		audio->in[index].used = 0;
-	audio->buf_refresh = 0;
-	audio->read_next = 0;
-	audio->fill_next = 0;
-}
-
-static void audio_ioport_reset(struct audio *audio)
-{
-	/* Make sure read/write thread are free from
-	 * sleep and knowing that system is not able
-	 * to process io request at the moment
-	 */
-	wake_up(&audio->write_wait);
-	mutex_lock(&audio->write_lock);
-	audio_flush(audio);
-	mutex_unlock(&audio->write_lock);
-	wake_up(&audio->read_wait);
-	mutex_lock(&audio->read_lock);
-	audio_flush_pcm_buf(audio);
-	mutex_unlock(&audio->read_lock);
-	audio->avsync_flag = 1;
-	wake_up(&audio->avsync_wait);
-}
-
-static int audwmapro_events_pending(struct audio *audio)
-{
-	unsigned long flags;
-	int empty;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	empty = !list_empty(&audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	return empty || audio->event_abort;
-}
-
-static void audwmapro_reset_event_queue(struct audio *audio)
-{
-	unsigned long flags;
-	struct audwmapro_event *drv_evt;
-	struct list_head *ptr, *next;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	list_for_each_safe(ptr, next, &audio->event_queue) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audwmapro_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	list_for_each_safe(ptr, next, &audio->free_event_queue) {
-		drv_evt = list_first_entry(&audio->free_event_queue,
-				struct audwmapro_event, list);
-		list_del(&drv_evt->list);
-		kfree(drv_evt);
-	}
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	return;
-}
-
-static long audwmapro_process_event_req(struct audio *audio, void __user *arg)
-{
-	long rc;
-	struct msm_audio_event usr_evt;
-	struct audwmapro_event *drv_evt = NULL;
-	int timeout;
-	unsigned long flags;
-
-	if (copy_from_user(&usr_evt, arg, sizeof(struct msm_audio_event)))
-		return -EFAULT;
-
-	timeout = (int) usr_evt.timeout_ms;
-
-	if (timeout > 0) {
-		rc = wait_event_interruptible_timeout(audio->event_wait,
-				audwmapro_events_pending(audio),
-				msecs_to_jiffies(timeout));
-		if (rc == 0)
-			return -ETIMEDOUT;
-	} else {
-		rc = wait_event_interruptible(
-			audio->event_wait, audwmapro_events_pending(audio));
-	}
-
-	if (rc < 0)
-		return rc;
-
-	if (audio->event_abort) {
-		audio->event_abort = 0;
-		return -ENODEV;
-	}
-
-	rc = 0;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-	if (!list_empty(&audio->event_queue)) {
-		drv_evt = list_first_entry(&audio->event_queue,
-				struct audwmapro_event, list);
-		list_del(&drv_evt->list);
-	}
-
-	if (drv_evt) {
-		usr_evt.event_type = drv_evt->event_type;
-		usr_evt.event_payload = drv_evt->payload;
-		list_add_tail(&drv_evt->list, &audio->free_event_queue);
-	} else
-		rc = -1;
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-
-	if (!rc && copy_to_user(arg, &usr_evt, sizeof(usr_evt)))
-		rc = -EFAULT;
-
-	return rc;
-}
-
-static int audio_enable_eq(struct audio *audio, int enable)
-{
-	if (audio->eq_enable == enable && !audio->eq_needs_commit)
-		return 0;
-
-	audio->eq_enable = enable;
-
-	if (audio->running) {
-		audpp_dsp_set_eq(audio->dec_id, enable, &audio->eq, POPP);
-		audio->eq_needs_commit = 0;
-	}
-	return 0;
-}
-
-static int audio_get_avsync_data(struct audio *audio,
-						struct msm_audio_stats *stats)
-{
-	int rc = -EINVAL;
-	unsigned long flags;
-
-	local_irq_save(flags);
-	if (audio->dec_id == audio->avsync[0] && audio->avsync_flag) {
-		/* av_sync sample count */
-		stats->sample_count = (audio->avsync[2] << 16) |
-						(audio->avsync[3]);
-
-		/* av_sync byte_count */
-		stats->byte_count = (audio->avsync[5] << 16) |
-						(audio->avsync[6]);
-
-		audio->avsync_flag = 0;
-		rc = 0;
-	}
-	local_irq_restore(flags);
-	return rc;
-
-}
-
-static long audio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct audio *audio = file->private_data;
-	int rc = -EINVAL;
-	unsigned long flags = 0;
-	uint16_t enable_mask;
-	int enable;
-	int prev_state;
-
-	MM_DBG("cmd = %d\n", cmd);
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-
-		audio->avsync_flag = 0;
-		memset(&stats, 0, sizeof(stats));
-		if (audpp_query_avsync(audio->dec_id) < 0)
-			return rc;
-
-		rc = wait_event_interruptible_timeout(audio->avsync_wait,
-				(audio->avsync_flag == 1),
-				msecs_to_jiffies(AUDPP_AVSYNC_EVENT_TIMEOUT));
-
-		if (rc < 0)
-			return rc;
-		else if ((rc > 0) || ((rc == 0) && (audio->avsync_flag == 1))) {
-			if (audio_get_avsync_data(audio, &stats) < 0)
-				return rc;
-
-			if (copy_to_user((void *)arg, &stats, sizeof(stats)))
-				return -EFAULT;
-			return 0;
-		} else
-			return -EAGAIN;
-	}
-
-	switch (cmd) {
-	case AUDIO_ENABLE_AUDPP:
-		if (copy_from_user(&enable_mask, (void *) arg,
-						sizeof(enable_mask))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		enable = (enable_mask & EQ_ENABLE) ? 1 : 0;
-		audio_enable_eq(audio, enable);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-	case AUDIO_SET_VOLUME:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.volume = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_PAN:
-		spin_lock_irqsave(&audio->dsp_lock, flags);
-		audio->vol_pan.pan = arg;
-		if (audio->running)
-			audpp_dsp_set_vol_pan(audio->dec_id, &audio->vol_pan,
-					POPP);
-		spin_unlock_irqrestore(&audio->dsp_lock, flags);
-		rc = 0;
-		break;
-
-	case AUDIO_SET_EQ:
-		prev_state = audio->eq_enable;
-		audio->eq_enable = 0;
-		if (copy_from_user(&audio->eq.num_bands, (void *) arg,
-				sizeof(audio->eq) -
-				(AUDPP_CMD_CFG_OBJECT_PARAMS_COMMON_LEN + 2))) {
-			rc = -EFAULT;
-			break;
-		}
-		audio->eq_enable = prev_state;
-		audio->eq_needs_commit = 1;
-		rc = 0;
-		break;
-	}
-
-	if (-EINVAL != rc)
-		return rc;
-
-	if (cmd == AUDIO_GET_EVENT) {
-		MM_DBG("AUDIO_GET_EVENT\n");
-		if (mutex_trylock(&audio->get_event_lock)) {
-			rc = audwmapro_process_event_req(audio,
-					(void __user *) arg);
-			mutex_unlock(&audio->get_event_lock);
-		} else
-			rc = -EBUSY;
-		return rc;
-	}
-
-	if (cmd == AUDIO_ABORT_GET_EVENT) {
-		audio->event_abort = 1;
-		wake_up(&audio->event_wait);
-		return 0;
-	}
-
-	mutex_lock(&audio->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		MM_DBG("AUDIO_START\n");
-		rc = audio_enable(audio);
-		if (!rc) {
-			rc = wait_event_interruptible_timeout(audio->wait,
-				audio->dec_state != MSM_AUD_DECODER_STATE_NONE,
-				msecs_to_jiffies(MSM_AUD_DECODER_WAIT_MS));
-			MM_INFO("dec_state %d rc = %d\n", audio->dec_state, rc);
-
-			if (audio->dec_state != MSM_AUD_DECODER_STATE_SUCCESS)
-				rc = -ENODEV;
-			else
-				rc = 0;
-		}
-		break;
-	case AUDIO_STOP:
-		MM_DBG("AUDIO_STOP\n");
-		rc = audio_disable(audio);
-		audio->stopped = 1;
-		audio_ioport_reset(audio);
-		audio->stopped = 0;
-		break;
-	case AUDIO_FLUSH:
-		MM_DBG("AUDIO_FLUSH\n");
-		audio->rflush = 1;
-		audio->wflush = 1;
-		audio_ioport_reset(audio);
-		if (audio->running) {
-			audpp_flush(audio->dec_id);
-			rc = wait_event_interruptible(audio->write_wait,
-				!audio->wflush);
-			if (rc < 0) {
-				MM_ERR("AUDIO_FLUSH interrupted\n");
-				rc = -EINTR;
-			}
-		} else {
-			audio->rflush = 0;
-			audio->wflush = 0;
-		}
-		break;
-	case AUDIO_SET_CONFIG: {
-		struct msm_audio_config config;
-		if (copy_from_user(&config, (void *) arg, sizeof(config))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (config.channel_count == 1) {
-			config.channel_count = AUDPP_CMD_PCM_INTF_MONO_V;
-		} else if (config.channel_count == 2) {
-			config.channel_count = AUDPP_CMD_PCM_INTF_STEREO_V;
-		} else {
-			rc = -EINVAL;
-			break;
-		}
-		audio->mfield = config.meta_field;
-		audio->out_sample_rate = config.sample_rate;
-		audio->out_channel_mode = config.channel_count;
-		rc = 0;
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config config;
-		config.buffer_size = (audio->out_dma_sz >> 1);
-		config.buffer_count = 2;
-		config.sample_rate = audio->out_sample_rate;
-		if (audio->out_channel_mode == AUDPP_CMD_PCM_INTF_MONO_V)
-			config.channel_count = 1;
-		else
-			config.channel_count = 2;
-		config.meta_field = 0;
-		config.unused[0] = 0;
-		config.unused[1] = 0;
-		config.unused[2] = 0;
-		if (copy_to_user((void *) arg, &config, sizeof(config)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-
-		break;
-	}
-	case AUDIO_GET_WMAPRO_CONFIG:{
-			if (copy_to_user((void *)arg, &audio->wmapro_config,
-				sizeof(audio->wmapro_config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_SET_WMAPRO_CONFIG:{
-		struct msm_audio_wmapro_config usr_config;
-
-		if (copy_from_user
-			(&usr_config, (void *)arg,
-			sizeof(usr_config))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		audio->wmapro_config = usr_config;
-
-		/* Need to swap the first and last words of advancedencodeopt2
-		 * as DSP cannot read 32-bit variable at a time. Need to be
-		 * split into two 16-bit and swap them as required by DSP */
-
-		audio->wmapro_config.advancedencodeopt2 =
-			((audio->wmapro_config.advancedencodeopt2 & 0xFFFF0000)
-			 >> 16) | ((audio->wmapro_config.advancedencodeopt2
-			 << 16) & 0xFFFF0000);
-		rc = 0;
-		break;
-	}
-	case AUDIO_GET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			config.pcm_feedback = audio->pcm_feedback;
-			config.buffer_count = PCM_BUF_MAX_COUNT;
-			config.buffer_size = PCM_BUFSZ_MIN;
-			if (copy_to_user((void *)arg, &config,
-					 sizeof(config)))
-				rc = -EFAULT;
-			else
-				rc = 0;
-			break;
-		}
-	case AUDIO_SET_PCM_CONFIG:{
-			struct msm_audio_pcm_config config;
-			if (copy_from_user
-			    (&config, (void *)arg, sizeof(config))) {
-				rc = -EFAULT;
-				break;
-			}
-			if (config.pcm_feedback != audio->pcm_feedback) {
-				MM_ERR("Not sufficient permission to"
-						"change the playback mode\n");
-				rc = -EACCES;
-				break;
-			}
-			if ((config.buffer_count > PCM_BUF_MAX_COUNT) ||
-			    (config.buffer_count == 1))
-				config.buffer_count = PCM_BUF_MAX_COUNT;
-
-			if (config.buffer_size < PCM_BUFSZ_MIN)
-				config.buffer_size = PCM_BUFSZ_MIN;
-
-			/* Check if pcm feedback is required */
-			if ((config.pcm_feedback) && (!audio->read_data)) {
-				MM_DBG("allocate PCM buffer %d\n",
-						config.buffer_count *
-						config.buffer_size);
-				audio->read_phys =
-						allocate_contiguous_ebi_nomap(
-							config.buffer_size *
-							config.buffer_count,
-							SZ_4K);
-				if (!audio->read_phys) {
-					rc = -ENOMEM;
-					break;
-				}
-				audio->map_v_read = ioremap(
-							audio->read_phys,
-							config.buffer_size *
-							config.buffer_count);
-				if (IS_ERR(audio->map_v_read)) {
-					MM_ERR("read buf map fail\n");
-					rc = -ENOMEM;
-					free_contiguous_memory_by_paddr(
-							audio->read_phys);
-				} else {
-					uint8_t index;
-					uint32_t offset = 0;
-					audio->read_data =
-						audio->map_v_read;
-					audio->pcm_feedback = 1;
-					audio->buf_refresh = 0;
-					audio->pcm_buf_count =
-					    config.buffer_count;
-					audio->read_next = 0;
-					audio->fill_next = 0;
-
-					for (index = 0;
-					     index < config.buffer_count;
-					     index++) {
-						audio->in[index].data =
-						    audio->read_data + offset;
-						audio->in[index].addr =
-						    audio->read_phys + offset;
-						audio->in[index].size =
-						    config.buffer_size;
-						audio->in[index].used = 0;
-						offset += config.buffer_size;
-					}
-					MM_DBG("read buf: phy addr \
-						0x%08x kernel addr 0x%08x\n",
-						audio->read_phys,
-						(int)audio->read_data);
-					rc = 0;
-				}
-			} else {
-				rc = 0;
-			}
-			break;
-		}
-	case AUDIO_PAUSE:
-		MM_DBG("AUDIO_PAUSE %ld\n", arg);
-		rc = audpp_pause(audio->dec_id, (int) arg);
-		break;
-	case AUDIO_GET_SESSION_ID:
-		if (copy_to_user((void *) arg, &audio->dec_id,
-					sizeof(unsigned short)))
-			rc = -EFAULT;
-		else
-			rc = 0;
-		break;
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&audio->lock);
-	return rc;
-}
-
-/* Only useful in tunnel-mode */
-static int audio_fsync(struct file *file, loff_t ppos1, loff_t ppos2, int datasync)
-{
-	struct audio *audio = file->private_data;
-	struct buffer *frame;
-	int rc = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	if (!audio->running || audio->pcm_feedback) {
-		rc = -EINVAL;
-		goto done_nolock;
-	}
-
-	mutex_lock(&audio->write_lock);
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(!audio->out[0].used &&
-		!audio->out[1].used &&
-		audio->out_needed) || audio->wflush);
-
-	if (rc < 0)
-		goto done;
-	else if (audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (audio->reserved) {
-		MM_DBG("send reserved byte\n");
-		frame = audio->out + audio->out_tail;
-		((char *) frame->data)[0] = audio->rsv_byte;
-		((char *) frame->data)[1] = 0;
-		frame->used = 2;
-		audplay_send_data(audio, 0);
-
-		rc = wait_event_interruptible(audio->write_wait,
-			(!audio->out[0].used &&
-			!audio->out[1].used &&
-			audio->out_needed) || audio->wflush);
-
-		if (rc < 0)
-			goto done;
-		else if (audio->wflush) {
-			rc = -EBUSY;
-			goto done;
-		}
-	}
-
-	/* pcm dmamiss message is sent continously
-	 * when decoder is starved so no race
-	 * condition concern
-	 */
-	audio->teos = 0;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		audio->teos || audio->wflush);
-
-	if (audio->wflush)
-		rc = -EBUSY;
-
-done:
-	mutex_unlock(&audio->write_lock);
-done_nolock:
-	return rc;
-}
-
-static ssize_t audio_read(struct file *file, char __user *buf, size_t count,
-			  loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	int rc = 0;
-
-	if (!audio->pcm_feedback)
-		return 0; /* PCM feedback is not enabled. Nothing to read */
-
-	mutex_lock(&audio->read_lock);
-	MM_DBG("%d \n", count);
-	while (count > 0) {
-		rc = wait_event_interruptible(audio->read_wait,
-			(audio->in[audio->read_next].used > 0) ||
-			(audio->stopped) || (audio->rflush));
-
-		if (rc < 0)
-			break;
-
-		if (audio->stopped || audio->rflush) {
-			rc = -EBUSY;
-			break;
-		}
-
-		if (count < audio->in[audio->read_next].used) {
-			/* Read must happen in frame boundary. Since driver
-			   does not know frame size, read count must be greater
-			   or equal to size of PCM samples */
-			MM_DBG("audio_read: no partial frame done reading\n");
-			break;
-		} else {
-			MM_DBG("audio_read: read from in[%d]\n",
-					audio->read_next);
-			if (copy_to_user
-			    (buf, audio->in[audio->read_next].data,
-			     audio->in[audio->read_next].used)) {
-				MM_ERR("invalid addr %x \n", (unsigned int)buf);
-				rc = -EFAULT;
-				break;
-			}
-			count -= audio->in[audio->read_next].used;
-			buf += audio->in[audio->read_next].used;
-			audio->in[audio->read_next].used = 0;
-			if ((++audio->read_next) == audio->pcm_buf_count)
-				audio->read_next = 0;
-			break;	/* Force to exit while loop
-				 * to prevent output thread
-				 * sleep too long if data is
-				 * not ready at this moment.
-				 */
-		}
-	}
-
-	/* don't feed output buffer to HW decoder during flushing
-	 * buffer refresh command will be sent once flush completes
-	 * send buf refresh command here can confuse HW decoder
-	 */
-	if (audio->buf_refresh && !audio->rflush) {
-		audio->buf_refresh = 0;
-		MM_DBG("kick start pcm feedback again\n");
-		audplay_buffer_refresh(audio);
-	}
-
-	mutex_unlock(&audio->read_lock);
-
-	if (buf > start)
-		rc = buf - start;
-
-	MM_DBG("read %d bytes\n", rc);
-	return rc;
-}
-
-static int audwmapro_process_eos(struct audio *audio,
-		const char __user *buf_start, unsigned short mfield_size)
-{
-	int rc = 0;
-	struct buffer *frame;
-	char *buf_ptr;
-
-	if (audio->reserved) {
-		MM_DBG("flush reserve byte\n");
-		frame = audio->out + audio->out_head;
-		buf_ptr = frame->data;
-		rc = wait_event_interruptible(audio->write_wait,
-				(frame->used == 0)
-				|| (audio->stopped)
-				|| (audio->wflush));
-		if (rc < 0)
-			goto done;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			goto done;
-		}
-
-		buf_ptr[0] = audio->rsv_byte;
-		buf_ptr[1] = 0;
-		audio->out_head ^= 1;
-		frame->mfield_sz = 0;
-		frame->used = 2;
-		audio->reserved = 0;
-		audplay_send_data(audio, 0);
-	}
-
-	frame = audio->out + audio->out_head;
-
-	rc = wait_event_interruptible(audio->write_wait,
-		(audio->out_needed &&
-		audio->out[0].used == 0 &&
-		audio->out[1].used == 0)
-		|| (audio->stopped)
-		|| (audio->wflush));
-
-	if (rc < 0)
-		goto done;
-	if (audio->stopped || audio->wflush) {
-		rc = -EBUSY;
-		goto done;
-	}
-
-	if (copy_from_user(frame->data, buf_start, mfield_size)) {
-		rc = -EFAULT;
-		goto done;
-	}
-
-	frame->mfield_sz = mfield_size;
-	audio->out_head ^= 1;
-	frame->used = mfield_size;
-	audplay_send_data(audio, 0);
-done:
-	return rc;
-}
-
-static ssize_t audio_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct audio *audio = file->private_data;
-	const char __user *start = buf;
-	struct buffer *frame;
-	size_t xfer;
-	char *cpy_ptr;
-	int rc = 0, eos_condition = AUDWMAPRO_EOS_NONE;
-	unsigned dsize;
-	unsigned short mfield_size = 0;
-
-	MM_DBG("cnt=%d\n", count);
-
-	mutex_lock(&audio->write_lock);
-	while (count > 0) {
-		frame = audio->out + audio->out_head;
-		cpy_ptr = frame->data;
-		dsize = 0;
-		rc = wait_event_interruptible(audio->write_wait,
-					      (frame->used == 0)
-					      || (audio->stopped)
-						  || (audio->wflush));
-		if (rc < 0)
-			break;
-		if (audio->stopped || audio->wflush) {
-			rc = -EBUSY;
-			break;
-		}
-		if (audio->mfield) {
-			if (buf == start) {
-				/* Processing beginning of user buffer */
-				if (__get_user(mfield_size,
-					(unsigned short __user *) buf)) {
-					rc = -EFAULT;
-					break;
-				} else  if (mfield_size > count) {
-					rc = -EINVAL;
-					break;
-				}
-				MM_DBG("audio_write: mf offset_val %x\n",
-						mfield_size);
-				if (copy_from_user(cpy_ptr, buf, mfield_size)) {
-					rc = -EFAULT;
-					break;
-				}
-				/* Check if EOS flag is set and buffer has
-				 * contains just meta field
-				 */
-				if (cpy_ptr[AUDWMAPRO_EOS_FLG_OFFSET] &
-						 AUDWMAPRO_EOS_FLG_MASK) {
-					MM_DBG("audio_write: EOS SET\n");
-					eos_condition = AUDWMAPRO_EOS_SET;
-					if (mfield_size == count) {
-						buf += mfield_size;
-						break;
-					} else
-					cpy_ptr[AUDWMAPRO_EOS_FLG_OFFSET]
-						&= ~AUDWMAPRO_EOS_FLG_MASK;
-				}
-				cpy_ptr += mfield_size;
-				count -= mfield_size;
-				dsize += mfield_size;
-				buf += mfield_size;
-			} else {
-				mfield_size = 0;
-				MM_DBG("audio_write: continuous buffer\n");
-			}
-			frame->mfield_sz = mfield_size;
-		}
-
-		if (audio->reserved) {
-			MM_DBG("append reserved byte %x\n", audio->rsv_byte);
-			*cpy_ptr = audio->rsv_byte;
-			xfer = (count > ((frame->size - mfield_size) - 1)) ?
-				(frame->size - mfield_size) - 1 : count;
-			cpy_ptr++;
-			dsize += 1;
-			audio->reserved = 0;
-		} else
-			xfer = (count > (frame->size - mfield_size)) ?
-				(frame->size - mfield_size) : count;
-
-		if (copy_from_user(cpy_ptr, buf, xfer)) {
-			rc = -EFAULT;
-			break;
-		}
-
-		dsize += xfer;
-		if (dsize & 1) {
-			audio->rsv_byte = ((char *) frame->data)[dsize - 1];
-			MM_DBG("odd length buf reserve last byte %x\n",
-					audio->rsv_byte);
-			audio->reserved = 1;
-			dsize--;
-		}
-		count -= xfer;
-		buf += xfer;
-
-		if (dsize > 0) {
-			audio->out_head ^= 1;
-			frame->used = dsize;
-			audplay_send_data(audio, 0);
-		}
-	}
-	if (eos_condition == AUDWMAPRO_EOS_SET)
-		rc = audwmapro_process_eos(audio, start, mfield_size);
-	mutex_unlock(&audio->write_lock);
-	if (!rc) {
-		if (buf > start)
-			return buf - start;
-	}
-	return rc;
-}
-
-static int audio_release(struct inode *inode, struct file *file)
-{
-	struct audio *audio = file->private_data;
-
-	MM_INFO("audio instance 0x%08x freeing\n", (int)audio);
-	mutex_lock(&audio->lock);
-	auddev_unregister_evt_listner(AUDDEV_CLNT_DEC, audio->dec_id);
-	audio_disable(audio);
-	audio_flush(audio);
-	audio_flush_pcm_buf(audio);
-	msm_adsp_put(audio->audplay);
-	audpp_adec_free(audio->dec_id);
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	unregister_early_suspend(&audio->suspend_ctl.node);
-#endif
-	audio->event_abort = 1;
-	wake_up(&audio->event_wait);
-	audwmapro_reset_event_queue(audio);
-	iounmap(audio->map_v_write);
-	free_contiguous_memory_by_paddr(audio->phys);
-	if (audio->read_data) {
-		iounmap(audio->map_v_read);
-		free_contiguous_memory_by_paddr(audio->read_phys);
-	}
-	mutex_unlock(&audio->lock);
-#ifdef CONFIG_DEBUG_FS
-	if (audio->dentry)
-		debugfs_remove(audio->dentry);
-#endif
-	kfree(audio);
-	return 0;
-}
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-static void audwmapro_post_event(struct audio *audio, int type,
-		union msm_audio_event_payload payload)
-{
-	struct audwmapro_event *e_node = NULL;
-	unsigned long flags;
-
-	spin_lock_irqsave(&audio->event_queue_lock, flags);
-
-	if (!list_empty(&audio->free_event_queue)) {
-		e_node = list_first_entry(&audio->free_event_queue,
-				struct audwmapro_event, list);
-		list_del(&e_node->list);
-	} else {
-		e_node = kmalloc(sizeof(struct audwmapro_event), GFP_ATOMIC);
-		if (!e_node) {
-			MM_ERR("No mem to post event %d\n", type);
-			return;
-		}
-	}
-
-	e_node->event_type = type;
-	e_node->payload = payload;
-
-	list_add_tail(&e_node->list, &audio->event_queue);
-	spin_unlock_irqrestore(&audio->event_queue_lock, flags);
-	wake_up(&audio->event_wait);
-}
-
-static void audwmapro_suspend(struct early_suspend *h)
-{
-	struct audwmapro_suspend_ctl *ctl =
-		container_of(h, struct audwmapro_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audwmapro_post_event(ctl->audio, AUDIO_EVENT_SUSPEND, payload);
-}
-
-static void audwmapro_resume(struct early_suspend *h)
-{
-	struct audwmapro_suspend_ctl *ctl =
-		container_of(h, struct audwmapro_suspend_ctl, node);
-	union msm_audio_event_payload payload;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-	audwmapro_post_event(ctl->audio, AUDIO_EVENT_RESUME, payload);
-}
-#endif
-
-#ifdef CONFIG_DEBUG_FS
-static ssize_t audwmapro_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static ssize_t audwmapro_debug_read(struct file *file, char __user *buf,
-			  size_t count, loff_t *ppos)
-{
-	const int debug_bufmax = 4096;
-	static char buffer[4096];
-	int n = 0, i;
-	struct audio *audio = file->private_data;
-
-	mutex_lock(&audio->lock);
-	n = scnprintf(buffer, debug_bufmax, "opened %d\n", audio->opened);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "enabled %d\n", audio->enabled);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "stopped %d\n", audio->stopped);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "pcm_feedback %d\n", audio->pcm_feedback);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_buf_sz %d\n", audio->out[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "pcm_buf_count %d \n", audio->pcm_buf_count);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "pcm_buf_sz %d \n", audio->in[0].size);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "volume %x \n", audio->vol_pan.volume);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "sample rate %d \n", audio->out_sample_rate);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-		"channel mode %d \n", audio->out_channel_mode);
-	mutex_unlock(&audio->lock);
-	/* Following variables are only useful for debugging when
-	 * when playback halts unexpectedly. Thus, no mutual exclusion
-	 * enforced
-	 */
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "wflush %d\n", audio->wflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "rflush %d\n", audio->rflush);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "running %d \n", audio->running);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-			"dec state %d \n", audio->dec_state);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_needed %d \n", audio->out_needed);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_head %d \n", audio->out_head);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out_tail %d \n", audio->out_tail);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out[0].used %d \n", audio->out[0].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "out[1].used %d \n", audio->out[1].used);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "buffer_refresh %d \n", audio->buf_refresh);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "read_next %d \n", audio->read_next);
-	n += scnprintf(buffer + n, debug_bufmax - n,
-				   "fill_next %d \n", audio->fill_next);
-	for (i = 0; i < audio->pcm_buf_count; i++)
-		n += scnprintf(buffer + n, debug_bufmax - n,
-			"in[%d].size %d \n", i, audio->in[i].used);
-	buffer[n] = 0;
-	return simple_read_from_buffer(buf, count, ppos, buffer, n);
-}
-
-static const struct file_operations audwmapro_debug_fops = {
-	.read = audwmapro_debug_read,
-	.open = audwmapro_debug_open,
-};
-#endif
-
-static int audio_open(struct inode *inode, struct file *file)
-{
-	struct audio *audio = NULL;
-	int rc, dec_attrb, decid, i;
-	unsigned pmem_sz = DMASZ_MAX;
-	struct audwmapro_event *e_node = NULL;
-#ifdef CONFIG_DEBUG_FS
-	/* 4 bytes represents decoder number, 1 byte for terminate string */
-	char name[sizeof "msm_wmapro_" + 5];
-#endif
-
-	/* Allocate Mem for audio instance */
-	audio = kzalloc(sizeof(struct audio), GFP_KERNEL);
-	if (!audio) {
-		MM_ERR("no memory to allocate audio instance \n");
-		rc = -ENOMEM;
-		goto done;
-	}
-	MM_INFO("audio instance 0x%08x created\n", (int)audio);
-
-	/* Allocate the decoder */
-	dec_attrb = AUDDEC_DEC_WMAPRO;
-	if ((file->f_mode & FMODE_WRITE) &&
-			(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_NONTUNNEL;
-		audio->pcm_feedback = NON_TUNNEL_MODE_PLAYBACK;
-	} else if ((file->f_mode & FMODE_WRITE) &&
-			!(file->f_mode & FMODE_READ)) {
-		dec_attrb |= MSM_AUD_MODE_TUNNEL;
-		audio->pcm_feedback = TUNNEL_MODE_PLAYBACK;
-	} else {
-		kfree(audio);
-		rc = -EACCES;
-		goto done;
-	}
-
-	decid = audpp_adec_alloc(dec_attrb, &audio->module_name,
-			&audio->queue_id);
-
-	if (decid < 0) {
-		MM_ERR("No free decoder available, freeing instance 0x%08x\n",
-				(int)audio);
-		rc = -ENODEV;
-		kfree(audio);
-		goto done;
-	}
-	audio->dec_id = decid & MSM_AUD_DECODER_MASK;
-
-	while (pmem_sz >= DMASZ_MIN) {
-		MM_DBG("pmemsz = %d\n", pmem_sz);
-		audio->phys = allocate_contiguous_ebi_nomap(pmem_sz, SZ_4K);
-		if (audio->phys) {
-			audio->map_v_write = ioremap(audio->phys, pmem_sz);
-			if (IS_ERR(audio->map_v_write)) {
-				MM_ERR("could not map write buffers, \
-						freeing instance 0x%08x\n",
-						(int)audio);
-				rc = -ENOMEM;
-				free_contiguous_memory_by_paddr(audio->phys);
-				audpp_adec_free(audio->dec_id);
-				kfree(audio);
-				goto done;
-			}
-			audio->data = audio->map_v_write;
-			MM_DBG("write buf: phy addr 0x%08x kernel addr \
-				0x%08x\n", audio->phys, (int)audio->data);
-			break;
-		} else if (pmem_sz == DMASZ_MIN) {
-			MM_ERR("could not allocate write buffers, freeing \
-					instance 0x%08x\n", (int)audio);
-			rc = -ENOMEM;
-			audpp_adec_free(audio->dec_id);
-			kfree(audio);
-			goto done;
-		} else
-		pmem_sz >>= 1;
-	}
-	audio->out_dma_sz = pmem_sz;
-
-	rc = msm_adsp_get(audio->module_name, &audio->audplay,
-			&audplay_adsp_ops_wmapro, audio);
-	if (rc) {
-		MM_ERR("failed to get %s module, freeing instance 0x%08x\n",
-				audio->module_name, (int)audio);
-		goto err;
-	}
-
-	mutex_init(&audio->lock);
-	mutex_init(&audio->write_lock);
-	mutex_init(&audio->read_lock);
-	mutex_init(&audio->get_event_lock);
-	spin_lock_init(&audio->dsp_lock);
-	init_waitqueue_head(&audio->write_wait);
-	init_waitqueue_head(&audio->read_wait);
-	INIT_LIST_HEAD(&audio->free_event_queue);
-	INIT_LIST_HEAD(&audio->event_queue);
-	init_waitqueue_head(&audio->wait);
-	init_waitqueue_head(&audio->event_wait);
-	spin_lock_init(&audio->event_queue_lock);
-	init_waitqueue_head(&audio->avsync_wait);
-
-	audio->out[0].data = audio->data + 0;
-	audio->out[0].addr = audio->phys + 0;
-	audio->out[0].size = audio->out_dma_sz >> 1;
-
-	audio->out[1].data = audio->data + audio->out[0].size;
-	audio->out[1].addr = audio->phys + audio->out[0].size;
-	audio->out[1].size = audio->out[0].size;
-
-	/*audio->wmapro_config.armdatareqthr =  1268;
-	audio->wmapro_config.numchannels = 2;
-	audio->wmapro_config.avgbytespersecond = 6003;
-	audio->wmapro_config.samplingrate = 44100;
-	audio->wmapro_config.encodeopt = 224;
-	audio->wmapro_config.validbitspersample = 16;
-	audio->wmapro_config.formattag = 354;
-	audio->wmapro_config.asfpacketlength = 2230;
-	audio->wmapro_config.channelmask = 3;
-	audio->wmapro_config.advancedencodeopt = 32834;
-	audio->wmapro_config.advancedencodeopt2 = 0;*/
-
-	audio->out_sample_rate = 44100;
-	audio->out_channel_mode = AUDPP_CMD_PCM_INTF_STEREO_V;
-
-	audio->vol_pan.volume = 0x2000;
-
-	audio_flush(audio);
-
-	file->private_data = audio;
-	audio->opened = 1;
-	audio->device_events = AUDDEV_EVT_DEV_RDY
-				|AUDDEV_EVT_DEV_RLS|
-				AUDDEV_EVT_STREAM_VOL_CHG;
-
-	rc = auddev_register_evt_listner(audio->device_events,
-					AUDDEV_CLNT_DEC,
-					audio->dec_id,
-					wmapro_listner,
-					(void *)audio);
-	if (rc) {
-		MM_ERR("%s: failed to register listner\n", __func__);
-		goto event_err;
-	}
-
-#ifdef CONFIG_DEBUG_FS
-	snprintf(name, sizeof name, "msm_wmapro_%04x", audio->dec_id);
-	audio->dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
-				NULL, (void *) audio,
-				&audwmapro_debug_fops);
-
-	if (IS_ERR(audio->dentry))
-		MM_DBG("debugfs_create_file failed\n");
-#endif
-#ifdef CONFIG_HAS_EARLYSUSPEND
-	audio->suspend_ctl.node.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
-	audio->suspend_ctl.node.resume = audwmapro_resume;
-	audio->suspend_ctl.node.suspend = audwmapro_suspend;
-	audio->suspend_ctl.audio = audio;
-	register_early_suspend(&audio->suspend_ctl.node);
-#endif
-	for (i = 0; i < AUDWMAPRO_EVENT_NUM; i++) {
-		e_node = kmalloc(sizeof(struct audwmapro_event), GFP_KERNEL);
-		if (e_node)
-			list_add_tail(&e_node->list, &audio->free_event_queue);
-		else {
-			MM_ERR("event pkt alloc failed\n");
-			break;
-		}
-	}
-done:
-	return rc;
-event_err:
-	msm_adsp_put(audio->audplay);
-err:
-	iounmap(audio->map_v_write);
-	free_contiguous_memory_by_paddr(audio->phys);
-	audpp_adec_free(audio->dec_id);
-	kfree(audio);
-	return rc;
-}
-
-static const struct file_operations audio_wmapro_fops = {
-	.owner		= THIS_MODULE,
-	.open		= audio_open,
-	.release	= audio_release,
-	.read 		= audio_read,
-	.write		= audio_write,
-	.unlocked_ioctl	= audio_ioctl,
-	.fsync 		= audio_fsync,
-};
-
-struct miscdevice audio_wmapro_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_wmapro",
-	.fops	= &audio_wmapro_fops,
-};
-
-static int __init audio_init(void)
-{
-	return misc_register(&audio_wmapro_misc);
-}
-
-device_initcall(audio_init);
diff --git a/arch/arm/mach-msm/qdsp5v2/audpp.c b/arch/arm/mach-msm/qdsp5v2/audpp.c
deleted file mode 100644
index 7a40156..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audpp.c
+++ /dev/null
@@ -1,1140 +0,0 @@
-/* arch/arm/mach-msm/qdsp5/audpp.c
- *
- * common code to deal with the AUDPP dsp task (audio postproc)
- *
- * Copyright (C) 2008 Google, Inc.
- * Copyright (c) 2009-2011, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/wait.h>
-#include <linux/delay.h>
-#include <linux/sched.h>
-#include <linux/platform_device.h>
-#include <linux/wakelock.h>
-
-
-#include <asm/atomic.h>
-#include <asm/ioctls.h>
-#include <mach/board.h>
-#include <mach/msm_adsp.h>
-#include <mach/qdsp5v2/audio_acdbi.h>
-#include <mach/qdsp5v2/qdsp5audppcmdi.h>
-#include <mach/qdsp5v2/qdsp5audppmsg.h>
-#include <mach/qdsp5v2/audpp.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-
-#include "../qdsp5/evlog.h"
-#include <mach/debug_mm.h>
-
-enum {
-	EV_NULL,
-	EV_ENABLE,
-	EV_DISABLE,
-	EV_EVENT,
-	EV_DATA,
-};
-
-static const char *dsp_log_strings[] = {
-	"NULL",
-	"ENABLE",
-	"DISABLE",
-	"EVENT",
-	"DATA",
-};
-
-DECLARE_LOG(dsp_log, 64, dsp_log_strings);
-
-static int __init _dsp_log_init(void)
-{
-	return ev_log_init(&dsp_log);
-}
-
-module_init(_dsp_log_init);
-#define LOG(id, arg) ev_log_write(&dsp_log, id, arg)
-
-static DEFINE_MUTEX(audpp_lock);
-static DEFINE_MUTEX(audpp_dec_lock);
-static struct wake_lock audpp_wake_lock;
-
-#define CH_COUNT 5
-#define AUDPP_CLNT_MAX_COUNT 6
-
-#define AUDPP_CMD_CFG_OBJ_UPDATE 0x8000
-#define AUDPP_CMD_EQ_FLAG_DIS	0x0000
-#define AUDPP_CMD_EQ_FLAG_ENA	-1
-#define AUDPP_CMD_IIR_FLAG_DIS	  0x0000
-#define AUDPP_CMD_IIR_FLAG_ENA	  -1
-#define AUDPP_CMD_STF_FLAG_ENA -1
-#define AUDPP_CMD_STF_FLAG_DIS 0x0000
-
-#define MAX_EVENT_CALLBACK_CLIENTS 	1
-
-#define AUDPP_CONCURRENCY_DEFAULT 0	/* Set default to LPA mode */
-#define AUDPP_MAX_DECODER_CNT 5
-#define AUDPP_CODEC_MASK 0x000000FF
-#define AUDPP_MODE_MASK 0x00000F00
-#define AUDPP_OP_MASK 0xF0000000
-
-struct audpp_decoder_info {
-	unsigned int codec;
-	pid_t pid;
-};
-
-struct audpp_state {
-	struct msm_adsp_module *mod;
-	audpp_event_func func[AUDPP_CLNT_MAX_COUNT];
-	void *private[AUDPP_CLNT_MAX_COUNT];
-	struct mutex *lock;
-	unsigned open_count;
-	unsigned enabled;
-
-	/* Related to decoder allocation */
-	struct mutex *lock_dec;
-	struct msm_adspdec_database *dec_database;
-	struct audpp_decoder_info dec_info_table[AUDPP_MAX_DECODER_CNT];
-	unsigned dec_inuse;
-	unsigned long concurrency;
-
-	struct audpp_event_callback *cb_tbl[MAX_EVENT_CALLBACK_CLIENTS];
-
-	/* Related to decoder instances */
-	uint8_t op_mode; /* Specifies Turbo/Non Turbo mode */
-	uint8_t decoder_count; /* No. of decoders active running */
-	uint8_t codec_max_instances; /* Max codecs allowed currently */
-	uint8_t codec_cnt[MSM_MAX_DEC_CNT]; /* Nr of each codec
-						 type enabled */
-
-	wait_queue_head_t event_wait;
-};
-
-struct audpp_state the_audpp_state = {
-	.lock = &audpp_lock,
-	.lock_dec = &audpp_dec_lock,
-};
-
-static inline void prevent_suspend(void)
-{
-	wake_lock(&audpp_wake_lock);
-}
-static inline void allow_suspend(void)
-{
-	wake_unlock(&audpp_wake_lock);
-}
-
-int audpp_send_queue1(void *cmd, unsigned len)
-{
-	return msm_adsp_write(the_audpp_state.mod,
-			      QDSP_uPAudPPCmd1Queue, cmd, len);
-}
-EXPORT_SYMBOL(audpp_send_queue1);
-
-int audpp_send_queue2(void *cmd, unsigned len)
-{
-	return msm_adsp_write(the_audpp_state.mod,
-			      QDSP_uPAudPPCmd2Queue, cmd, len);
-}
-EXPORT_SYMBOL(audpp_send_queue2);
-
-int audpp_send_queue3(void *cmd, unsigned len)
-{
-	return msm_adsp_write(the_audpp_state.mod,
-			      QDSP_uPAudPPCmd3Queue, cmd, len);
-}
-EXPORT_SYMBOL(audpp_send_queue3);
-
-static int audpp_dsp_config(int enable)
-{
-	struct audpp_cmd_cfg cmd;
-
-	cmd.cmd_id = AUDPP_CMD_CFG;
-	cmd.cfg = enable ? AUDPP_CMD_CFG_ENABLE : AUDPP_CMD_CFG_SLEEP;
-
-	return audpp_send_queue1(&cmd, sizeof(cmd));
-}
-
-void audpp_route_stream(unsigned short dec_id, unsigned short mixer_mask)
-{
-	struct audpp_cmd_cfg_dev_mixer_params mixer_params_cmd;
-
-	memset(&mixer_params_cmd, 0, sizeof(mixer_params_cmd));
-
-	mixer_params_cmd.cmd_id = AUDPP_CMD_CFG_DEV_MIXER;
-	mixer_params_cmd.stream_id = dec_id;
-	mixer_params_cmd.mixer_cmd = mixer_mask;
-	audpp_send_queue1(&mixer_params_cmd, sizeof(mixer_params_cmd));
-
-}
-EXPORT_SYMBOL(audpp_route_stream);
-
-int is_audpp_enable(void)
-{
-	struct audpp_state *audpp = &the_audpp_state;
-
-	return audpp->enabled;
-}
-EXPORT_SYMBOL(is_audpp_enable);
-
-int audpp_register_event_callback(struct audpp_event_callback *ecb)
-{
-	struct audpp_state *audpp = &the_audpp_state;
-	int i;
-
-	for (i = 0; i < MAX_EVENT_CALLBACK_CLIENTS; ++i) {
-		if (NULL == audpp->cb_tbl[i]) {
-			audpp->cb_tbl[i] = ecb;
-			return 0;
-		}
-	}
-	return -1;
-}
-EXPORT_SYMBOL(audpp_register_event_callback);
-
-
-int audpp_unregister_event_callback(struct audpp_event_callback *ecb)
-{
-	struct audpp_state *audpp = &the_audpp_state;
-	int i;
-
-	for (i = 0; i < MAX_EVENT_CALLBACK_CLIENTS; ++i) {
-		if (ecb == audpp->cb_tbl[i]) {
-			audpp->cb_tbl[i] = NULL;
-			return 0;
-		}
-	}
-	return -1;
-}
-EXPORT_SYMBOL(audpp_unregister_event_callback);
-
-static void audpp_broadcast(struct audpp_state *audpp, unsigned id,
-			    uint16_t *msg)
-{
-	unsigned n;
-	for (n = 0; n < AUDPP_CLNT_MAX_COUNT; n++) {
-		if (audpp->func[n])
-			audpp->func[n] (audpp->private[n], id, msg);
-	}
-
-	for (n = 0; n < MAX_EVENT_CALLBACK_CLIENTS; ++n)
-		if (audpp->cb_tbl[n] && audpp->cb_tbl[n]->fn)
-			audpp->cb_tbl[n]->fn(audpp->cb_tbl[n]->private, id,
-					     msg);
-}
-
-static void audpp_notify_clnt(struct audpp_state *audpp, unsigned clnt_id,
-			      unsigned id, uint16_t *msg)
-{
-	if (clnt_id < AUDPP_CLNT_MAX_COUNT && audpp->func[clnt_id])
-		audpp->func[clnt_id] (audpp->private[clnt_id], id, msg);
-}
-
-static void audpp_handle_pcmdmamiss(struct audpp_state *audpp,
-				    uint16_t bit_mask)
-{
-	uint8_t b_index;
-
-	for (b_index = 0; b_index < AUDPP_CLNT_MAX_COUNT; b_index++) {
-		if (bit_mask & (0x1 << b_index))
-			if (audpp->func[b_index])
-				audpp->func[b_index] (audpp->private[b_index],
-						      AUDPP_MSG_PCMDMAMISSED,
-						      &bit_mask);
-	}
-}
-
-static void audpp_dsp_event(void *data, unsigned id, size_t len,
-			    void (*getevent) (void *ptr, size_t len))
-{
-	struct audpp_state *audpp = data;
-	uint16_t msg[8];
-
-	getevent(msg, sizeof(msg));
-
-	LOG(EV_EVENT, (id << 16) | msg[0]);
-	LOG(EV_DATA, (msg[1] << 16) | msg[2]);
-
-	switch (id) {
-	case AUDPP_MSG_STATUS_MSG:{
-			unsigned cid = msg[0];
-			MM_DBG("status %d %d %d\n", cid, msg[1], msg[2]);
-
-			if ((cid < 5) && audpp->func[cid])
-				audpp->func[cid] (audpp->private[cid], id, msg);
-			break;
-		}
-	case AUDPP_MSG_HOST_PCM_INTF_MSG:
-		if (audpp->func[5])
-			audpp->func[5] (audpp->private[5], id, msg);
-		break;
-	case AUDPP_MSG_PCMDMAMISSED:
-		audpp_handle_pcmdmamiss(audpp, msg[0]);
-		break;
-	case AUDPP_MSG_CFG_MSG:
-		if (msg[0] == AUDPP_MSG_ENA_ENA) {
-			MM_INFO("ENABLE\n");
-			audpp->enabled = 1;
-			audpp_broadcast(audpp, id, msg);
-		} else if (msg[0] == AUDPP_MSG_ENA_DIS) {
-			MM_INFO("DISABLE\n");
-			audpp->enabled = 0;
-			wake_up(&audpp->event_wait);
-			audpp_broadcast(audpp, id, msg);
-		} else {
-			MM_ERR("invalid config msg %d\n", msg[0]);
-		}
-		break;
-	case AUDPP_MSG_ROUTING_ACK:
-		audpp_notify_clnt(audpp, msg[0], id, msg);
-		break;
-	case AUDPP_MSG_FLUSH_ACK:
-		audpp_notify_clnt(audpp, msg[0], id, msg);
-		break;
-	case ADSP_MESSAGE_ID:
-		MM_DBG("Received ADSP event: module enable/disable \
-				(audpptask)");
-		break;
-	case AUDPP_MSG_AVSYNC_MSG:
-		audpp_notify_clnt(audpp, msg[0], id, msg);
-		break;
-#ifdef CONFIG_DEBUG_FS
-	case AUDPP_MSG_FEAT_QUERY_DM_DONE:
-		MM_INFO(" RTC ACK --> %x %x %x %x %x %x %x %x\n", msg[0],\
-			msg[1], msg[2], msg[3], msg[4], \
-			msg[5], msg[6], msg[7]);
-		acdb_rtc_set_err(msg[3]);
-		break;
-#endif
-	default:
-		MM_INFO("unhandled msg id %x\n", id);
-	}
-}
-
-static struct msm_adsp_ops adsp_ops = {
-	.event = audpp_dsp_event,
-};
-
-static void audpp_fake_event(struct audpp_state *audpp, int id,
-			     unsigned event, unsigned arg)
-{
-	uint16_t msg[1];
-	uint16_t n = 0;
-	msg[0] = arg;
-	audpp->func[id] (audpp->private[id], event, msg);
-	if (audpp->enabled == 1) {
-		for (n = 0; n < MAX_EVENT_CALLBACK_CLIENTS; ++n)
-			if (audpp->cb_tbl[n] && audpp->cb_tbl[n]->fn)
-				audpp->cb_tbl[n]->fn(audpp->cb_tbl[n]->private,
-					 AUDPP_MSG_CFG_MSG, msg);
-	}
-}
-
-int audpp_enable(int id, audpp_event_func func, void *private)
-{
-	struct audpp_state *audpp = &the_audpp_state;
-	int res = 0;
-
-	if (id < -1 || id > 4)
-		return -EINVAL;
-
-	if (id == -1)
-		id = 5;
-
-	mutex_lock(audpp->lock);
-	if (audpp->func[id]) {
-		res = -EBUSY;
-		goto out;
-	}
-
-	audpp->func[id] = func;
-	audpp->private[id] = private;
-
-	LOG(EV_ENABLE, 1);
-	if (audpp->open_count++ == 0) {
-		MM_DBG("enable\n");
-		res = msm_adsp_get("AUDPPTASK", &audpp->mod, &adsp_ops, audpp);
-		if (res < 0) {
-			MM_ERR("audpp: cannot open AUDPPTASK\n");
-			audpp->open_count = 0;
-			audpp->func[id] = NULL;
-			audpp->private[id] = NULL;
-			goto out;
-		}
-		LOG(EV_ENABLE, 2);
-		prevent_suspend();
-		msm_adsp_enable(audpp->mod);
-		audpp_dsp_config(1);
-	} else {
-		unsigned long flags;
-		local_irq_save(flags);
-		if (audpp->enabled)
-			audpp_fake_event(audpp, id,
-					 AUDPP_MSG_CFG_MSG, AUDPP_MSG_ENA_ENA);
-		local_irq_restore(flags);
-	}
-
-	res = 0;
-out:
-	mutex_unlock(audpp->lock);
-	return res;
-}
-EXPORT_SYMBOL(audpp_enable);
-
-void audpp_disable(int id, void *private)
-{
-	struct audpp_state *audpp = &the_audpp_state;
-	unsigned long flags;
-	int rc;
-
-	if (id < -1 || id > 4)
-		return;
-
-	if (id == -1)
-		id = 5;
-
-	mutex_lock(audpp->lock);
-	LOG(EV_DISABLE, 1);
-	if (!audpp->func[id])
-		goto out;
-	if (audpp->private[id] != private)
-		goto out;
-
-	local_irq_save(flags);
-	audpp_fake_event(audpp, id, AUDPP_MSG_CFG_MSG, AUDPP_MSG_ENA_DIS);
-	audpp->func[id] = NULL;
-	audpp->private[id] = NULL;
-	local_irq_restore(flags);
-
-	if (--audpp->open_count == 0) {
-		MM_DBG("disable\n");
-		LOG(EV_DISABLE, 2);
-		audpp_dsp_config(0);
-		rc = wait_event_interruptible(audpp->event_wait,
-				(audpp->enabled == 0));
-		if (audpp->enabled == 0)
-			MM_INFO("Received CFG_MSG_DISABLE from ADSP\n");
-		else
-			MM_ERR("Didn't receive CFG_MSG DISABLE \
-					message from ADSP\n");
-		msm_adsp_disable(audpp->mod);
-		msm_adsp_put(audpp->mod);
-		audpp->mod = NULL;
-		allow_suspend();
-	}
-out:
-	mutex_unlock(audpp->lock);
-}
-EXPORT_SYMBOL(audpp_disable);
-
-#define BAD_ID(id) ((id < 0) || (id >= CH_COUNT))
-
-int audpp_restore_avsync(int id, uint16_t *avsync)
-{
-	struct audpp_cmd_avsync cmd;
-
-	if (BAD_ID(id))
-		return -1;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPP_CMD_AVSYNC;
-	cmd.stream_id = id;
-	cmd.interrupt_interval = 0; /* Setting it to Zero as there won't be
-					periodic update */
-	cmd.sample_counter_dlsw = avsync[3];
-	cmd.sample_counter_dmsw = avsync[2];
-	cmd.sample_counter_msw = avsync[1];
-	cmd.byte_counter_dlsw = avsync[6];
-	cmd.byte_counter_dmsw = avsync[5];
-	cmd.byte_counter_msw = avsync[4];
-
-	return audpp_send_queue1(&cmd, sizeof(cmd));
-}
-EXPORT_SYMBOL(audpp_restore_avsync);
-
-int audpp_query_avsync(int id)
-{
-	struct audpp_cmd_query_avsync cmd;
-
-	if (BAD_ID(id))
-		return -EINVAL;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.cmd_id = AUDPP_CMD_QUERY_AVSYNC;
-	cmd.stream_id = id;
-	return audpp_send_queue1(&cmd, sizeof(cmd));
-
-}
-EXPORT_SYMBOL(audpp_query_avsync);
-
-int audpp_set_volume_and_pan(unsigned id, unsigned volume, int pan,
-			enum obj_type objtype)
-{
-	/* cmd, obj_cfg[7], cmd_type, volume, pan */
-	uint16_t cmd[7];
-
-	if (objtype) {
-		if (id > 5) {
-			MM_ERR("Wrong POPP decoder id: %d\n", id);
-			return -EINVAL;
-		}
-	} else {
-		if (id > 3) {
-			MM_ERR("Wrong COPP decoder id: %d\n", id);
-			return -EINVAL;
-		}
-	}
-
-	memset(cmd, 0, sizeof(cmd));
-	cmd[0] = AUDPP_CMD_CFG_OBJECT_PARAMS;
-	if (objtype)
-		cmd[1] = AUDPP_CMD_POPP_STREAM;
-	else
-		cmd[1] = AUDPP_CMD_COPP_STREAM;
-	cmd[2] = id;
-	cmd[3] = AUDPP_CMD_CFG_OBJ_UPDATE;
-	cmd[4] = AUDPP_CMD_VOLUME_PAN;
-	cmd[5] = volume;
-	cmd[6] = pan;
-
-	return audpp_send_queue3(cmd, sizeof(cmd));
-}
-EXPORT_SYMBOL(audpp_set_volume_and_pan);
-
-/* Implementation of COPP features */
-int audpp_dsp_set_mbadrc(unsigned id, unsigned enable,
-	struct audpp_cmd_cfg_object_params_mbadrc *mbadrc,
-	enum obj_type objtype)
-{
-	if (objtype) {
-		if (id > 5) {
-			MM_ERR("Wrong POPP decoder id: %d\n", id);
-			return -EINVAL;
-		}
-	} else {
-		if (id > 3) {
-			MM_ERR("Wrong COPP decoder id: %d\n", id);
-			return -EINVAL;
-		}
-	}
-
-	mbadrc->common.cmd_id = AUDPP_CMD_CFG_OBJECT_PARAMS;
-	if (objtype)
-		mbadrc->common.stream = AUDPP_CMD_POPP_STREAM;
-	else
-		mbadrc->common.stream = AUDPP_CMD_COPP_STREAM;
-
-	mbadrc->common.stream_id = id;
-	mbadrc->common.obj_cfg = AUDPP_CMD_CFG_OBJ_UPDATE;
-	mbadrc->common.command_type = AUDPP_CMD_MBADRC;
-
-	if (enable)
-		mbadrc->enable = AUDPP_CMD_ADRC_FLAG_ENA;
-	else
-		mbadrc->enable = AUDPP_CMD_ADRC_FLAG_DIS;
-
-	return audpp_send_queue3(mbadrc,
-			sizeof(struct audpp_cmd_cfg_object_params_mbadrc));
-}
-EXPORT_SYMBOL(audpp_dsp_set_mbadrc);
-
-int audpp_dsp_set_qconcert_plus(unsigned id, unsigned enable,
-	struct audpp_cmd_cfg_object_params_qconcert *qconcert_plus,
-	enum obj_type objtype)
-{
-	if (objtype) {
-		if (id > 5) {
-			MM_ERR("Wrong POPP decoder id: %d\n", id);
-			return -EINVAL;
-		}
-	} else {
-		if (id > 3) {
-			MM_ERR("Wrong COPP decoder id: %d\n", id);
-			return -EINVAL;
-		}
-	}
-
-	qconcert_plus->common.cmd_id = AUDPP_CMD_CFG_OBJECT_PARAMS;
-	if (objtype)
-		qconcert_plus->common.stream = AUDPP_CMD_POPP_STREAM;
-	else
-		qconcert_plus->common.stream = AUDPP_CMD_COPP_STREAM;
-
-	qconcert_plus->common.stream_id = id;
-	qconcert_plus->common.obj_cfg = AUDPP_CMD_CFG_OBJ_UPDATE;
-	qconcert_plus->common.command_type = AUDPP_CMD_QCONCERT;
-
-	if (enable)
-		qconcert_plus->enable_flag = AUDPP_CMD_ADRC_FLAG_ENA;
-	else
-		qconcert_plus->enable_flag = AUDPP_CMD_ADRC_FLAG_DIS;
-
-	return audpp_send_queue3(qconcert_plus,
-		sizeof(struct audpp_cmd_cfg_object_params_qconcert));
-}
-EXPORT_SYMBOL(audpp_dsp_set_qconcert_plus);
-
-int audpp_dsp_set_rx_iir(unsigned id, unsigned enable,
-	struct audpp_cmd_cfg_object_params_pcm *iir,
-	enum obj_type objtype)
-{
-
-	if (objtype) {
-		if (id > 5) {
-			MM_ERR("Wrong POPP decoder id: %d\n", id);
-			return -EINVAL;
-		}
-	} else {
-		if (id > 3) {
-			MM_ERR("Wrong COPP decoder id: %d\n", id);
-			return -EINVAL;
-		}
-	}
-
-	iir->common.cmd_id = AUDPP_CMD_CFG_OBJECT_PARAMS;
-	if (objtype)
-		iir->common.stream = AUDPP_CMD_POPP_STREAM;
-	else
-		iir->common.stream = AUDPP_CMD_COPP_STREAM;
-
-	iir->common.stream_id = id;
-	iir->common.obj_cfg = AUDPP_CMD_CFG_OBJ_UPDATE;
-	iir->common.command_type = AUDPP_CMD_IIR_TUNING_FILTER;
-
-	if (enable)
-		iir->active_flag = AUDPP_CMD_IIR_FLAG_ENA;
-	else
-		iir->active_flag = AUDPP_CMD_IIR_FLAG_DIS;
-
-	return audpp_send_queue3(iir,
-		sizeof(struct audpp_cmd_cfg_object_params_pcm));
-}
-EXPORT_SYMBOL(audpp_dsp_set_rx_iir);
-
-int audpp_dsp_set_gain_rx(unsigned id,
-			struct audpp_cmd_cfg_cal_gain *calib_gain_rx,
-			enum obj_type objtype)
-{
-	if (objtype) {
-		return -EINVAL;
-	} else {
-		if (id > 3) {
-			MM_ERR("Wrong COPP decoder id: %d\n", id);
-			return -EINVAL;
-		}
-	}
-	calib_gain_rx->common.cmd_id = AUDPP_CMD_CFG_OBJECT_PARAMS;
-	calib_gain_rx->common.stream = AUDPP_CMD_COPP_STREAM;
-
-	calib_gain_rx->common.stream_id = id;
-	calib_gain_rx->common.obj_cfg = AUDPP_CMD_CFG_OBJ_UPDATE;
-	calib_gain_rx->common.command_type = AUDPP_CMD_CALIB_GAIN_RX;
-
-	return audpp_send_queue3(calib_gain_rx,
-			sizeof(struct audpp_cmd_cfg_cal_gain));
-}
-EXPORT_SYMBOL(audpp_dsp_set_gain_rx);
-
-int audpp_dsp_set_pbe(unsigned id, unsigned enable,
-			struct audpp_cmd_cfg_pbe *pbe_block,
-			enum obj_type objtype)
-{
-	if (objtype) {
-		if (id > 5) {
-			MM_ERR("Wrong POPP decoder id: %d\n", id);
-			return -EINVAL;
-		}
-	} else {
-		if (id > 3) {
-			MM_ERR("Wrong COPP decoder id: %d\n", id);
-			return -EINVAL;
-		}
-	}
-
-	pbe_block->common.cmd_id = AUDPP_CMD_CFG_OBJECT_PARAMS;
-	if (objtype)
-		pbe_block->common.stream = AUDPP_CMD_POPP_STREAM;
-	else
-		pbe_block->common.stream = AUDPP_CMD_COPP_STREAM;
-
-	pbe_block->common.stream_id = id;
-	pbe_block->common.obj_cfg = AUDPP_CMD_CFG_OBJ_UPDATE;
-	pbe_block->common.command_type = AUDPP_CMD_PBE;
-
-	if (enable)
-		pbe_block->pbe_enable = AUDPP_CMD_PBE_FLAG_ENA;
-	else
-		pbe_block->pbe_enable = AUDPP_CMD_PBE_FLAG_DIS;
-
-	return audpp_send_queue3(pbe_block,
-			sizeof(struct audpp_cmd_cfg_pbe));
-}
-EXPORT_SYMBOL(audpp_dsp_set_pbe);
-
-int audpp_dsp_set_spa(unsigned id,
-     struct audpp_cmd_cfg_object_params_spectram *spa,
-			enum obj_type objtype){
-	struct audpp_cmd_cfg_object_params_spectram cmd;
-
-	if (objtype) {
-		if (id > 5) {
-			MM_ERR("Wrong POPP decoder id: %d\n", id);
-			return -EINVAL;
-		}
-	} else {
-		if (id > 3) {
-			MM_ERR("Wrong COPP decoder id: %d\n", id);
-			return -EINVAL;
-		}
-	}
-
-	memset(&cmd, 0, sizeof(cmd));
-	if (objtype)
-		cmd.common.stream = AUDPP_CMD_POPP_STREAM;
-	else
-		cmd.common.stream = AUDPP_CMD_COPP_STREAM;
-
-	cmd.common.stream_id = id;
-	cmd.common.obj_cfg = AUDPP_CMD_CFG_OBJ_UPDATE;
-	cmd.common.command_type = AUDPP_CMD_SPECTROGRAM;
-       cmd.sample_interval = spa->sample_interval;
-	cmd.num_coeff = spa->num_coeff;
-	return audpp_send_queue3(&cmd, sizeof(cmd));
-
-}
-EXPORT_SYMBOL(audpp_dsp_set_spa);
-
-int audpp_dsp_set_stf(unsigned id, unsigned enable,
-     struct audpp_cmd_cfg_object_params_sidechain *stf,
-			enum obj_type objtype){
-	if (objtype) {
-		if (id > 5) {
-			MM_ERR("Wrong POPP decoder id: %d\n", id);
-			return -EINVAL;
-		}
-	} else {
-		if (id > 3) {
-			MM_ERR("Wrong COPP decoder id: %d\n", id);
-			return -EINVAL;
-		}
-	}
-
-	stf->common.cmd_id = AUDPP_CMD_CFG_OBJECT_PARAMS;
-	if (objtype)
-		stf->common.stream = AUDPP_CMD_POPP_STREAM;
-	else
-		stf->common.stream = AUDPP_CMD_COPP_STREAM;
-
-	stf->common.stream_id = id;
-	stf->common.obj_cfg = AUDPP_CMD_CFG_OBJ_UPDATE;
-	stf->common.command_type = AUDPP_CMD_SIDECHAIN_TUNING_FILTER;
-
-	if (enable)
-		stf->active_flag = AUDPP_CMD_STF_FLAG_ENA;
-	else
-		stf->active_flag = AUDPP_CMD_STF_FLAG_DIS;
-	return audpp_send_queue3(stf,
-		sizeof(struct audpp_cmd_cfg_object_params_sidechain));
-}
-EXPORT_SYMBOL(audpp_dsp_set_stf);
-
-/* Implementation Of COPP + POPP */
-int audpp_dsp_set_eq(unsigned id, unsigned enable,
-		     struct audpp_cmd_cfg_object_params_eqalizer *eq,
-				enum obj_type objtype)
-{
-	struct audpp_cmd_cfg_object_params_eqalizer cmd;
-
-	if (objtype) {
-		if (id > 5) {
-			MM_ERR("Wrong POPP decoder id: %d\n", id);
-			return -EINVAL;
-		}
-	} else {
-		if (id > 3) {
-			MM_ERR("Wrong COPP decoder id: %d\n", id);
-			return -EINVAL;
-		}
-	}
-
-	memset(&cmd, 0, sizeof(cmd));
-	if (objtype)
-		cmd.common.stream = AUDPP_CMD_POPP_STREAM;
-	else
-		cmd.common.stream = AUDPP_CMD_COPP_STREAM;
-
-	cmd.common.stream_id = id;
-	cmd.common.obj_cfg = AUDPP_CMD_CFG_OBJ_UPDATE;
-	cmd.common.command_type = AUDPP_CMD_EQUALIZER;
-	if (enable) {
-		cmd.eq_flag = AUDPP_CMD_EQ_FLAG_ENA;
-		cmd.num_bands = eq->num_bands;
-		memcpy(&cmd.eq_coeff, &eq->eq_coeff, sizeof(eq->eq_coeff));
-	} else
-		cmd.eq_flag = AUDPP_CMD_EQ_FLAG_DIS;
-
-	return audpp_send_queue3(&cmd, sizeof(cmd));
-}
-EXPORT_SYMBOL(audpp_dsp_set_eq);
-
-int audpp_dsp_set_vol_pan(unsigned id,
-			  struct audpp_cmd_cfg_object_params_volume *vol_pan,
-					enum obj_type objtype)
-{
-	struct audpp_cmd_cfg_object_params_volume cmd;
-
-	if (objtype) {
-		if (id > 5) {
-			MM_ERR("Wrong POPP decoder id: %d\n", id);
-			return -EINVAL;
-		}
-	} else {
-		if (id > AUDPP_MAX_COPP_DEVICES) {
-			MM_ERR("Wrong COPP decoder id: %d\n", id);
-			return -EINVAL;
-		}
-	}
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_CMD_CFG_OBJECT_PARAMS;
-	if (objtype)
-		cmd.common.stream = AUDPP_CMD_POPP_STREAM;
-	else
-		cmd.common.stream = AUDPP_CMD_COPP_STREAM;
-
-	cmd.common.stream_id = id;
-	cmd.common.obj_cfg = AUDPP_CMD_CFG_OBJ_UPDATE;
-	cmd.common.command_type = AUDPP_CMD_VOLUME_PAN;
-
-	cmd.volume = vol_pan->volume;
-	cmd.pan = vol_pan->pan;
-
-	return audpp_send_queue3(&cmd, sizeof(cmd));
-}
-EXPORT_SYMBOL(audpp_dsp_set_vol_pan);
-
-int audpp_pause(unsigned id, int pause)
-{
-	/* pause 1 = pause 0 = resume */
-	u16 pause_cmd[AUDPP_CMD_DEC_CTRL_LEN / sizeof(unsigned short)];
-
-	if (id >= CH_COUNT)
-		return -EINVAL;
-
-	memset(pause_cmd, 0, sizeof(pause_cmd));
-
-	pause_cmd[0] = AUDPP_CMD_DEC_CTRL;
-	pause_cmd[1] = id;
-	if (pause == 1)
-		pause_cmd[2] = AUDPP_CMD_UPDATE_V | AUDPP_CMD_PAUSE_V;
-	else if (pause == 0)
-		pause_cmd[2] = AUDPP_CMD_UPDATE_V | AUDPP_CMD_RESUME_V;
-	else
-		return -EINVAL;
-
-	return audpp_send_queue1(pause_cmd, sizeof(pause_cmd));
-}
-EXPORT_SYMBOL(audpp_pause);
-
-int audpp_flush(unsigned id)
-{
-	u16 flush_cmd[AUDPP_CMD_DEC_CTRL_LEN / sizeof(unsigned short)];
-
-	if (id >= CH_COUNT)
-		return -EINVAL;
-
-	memset(flush_cmd, 0, sizeof(flush_cmd));
-
-	flush_cmd[0] = AUDPP_CMD_DEC_CTRL;
-	flush_cmd[1] = id;
-	flush_cmd[2] = AUDPP_CMD_UPDATE_V | AUDPP_CMD_FLUSH_V;
-
-	return audpp_send_queue1(flush_cmd, sizeof(flush_cmd));
-}
-EXPORT_SYMBOL(audpp_flush);
-
-/* dec_attrb = 7:0, 0 - No Decoder, else supported decoder *
- * like mp3, aac, wma etc ... *
- *           =  15:8, bit[8] = 1 - Tunnel, bit[9] = 1 - NonTunnel *
- *           =  31:16, reserved */
-int audpp_adec_alloc(unsigned dec_attrb, const char **module_name,
-		     unsigned *queueid)
-{
-	struct audpp_state *audpp = &the_audpp_state;
-	int decid = -1, idx, lidx, mode, codec;
-	int codecs_supported, min_codecs_supported;
-	unsigned int *concurrency_entry;
-	u8 max_instance, codec_type;
-
-	struct dec_instance_table *dec_instance_list;
-	dec_instance_list = (struct dec_instance_table *)
-				(audpp->dec_database->dec_instance_list);
-
-	mutex_lock(audpp->lock_dec);
-	/* Represents in bit mask */
-	mode = ((dec_attrb & AUDPP_MODE_MASK) << 16);
-	codec = (1 << (dec_attrb & AUDPP_CODEC_MASK));
-	codec_type = (dec_attrb & AUDPP_CODEC_MASK);
-
-	/* Find  whether same/different codec instances are running */
-	audpp->decoder_count++;
-	audpp->codec_cnt[codec_type]++;
-	max_instance = 0;
-
-	/*if different instance of codec*/
-	if (audpp->codec_cnt[codec_type] < audpp->decoder_count) {
-		max_instance = audpp->codec_max_instances;
-		/* Get the maximum no. of instances that can be supported */
-		for (idx = 0; idx < MSM_MAX_DEC_CNT; idx++) {
-			if (audpp->codec_cnt[idx]) {
-				if ((dec_instance_list +
-					audpp->op_mode * MSM_MAX_DEC_CNT +
-						idx)->
-						max_instances_diff_dec <
-						max_instance) {
-						max_instance =
-						(dec_instance_list +
-							 audpp->op_mode *
-								MSM_MAX_DEC_CNT
-								+ idx)->
-							max_instances_diff_dec;
-				}
-			}
-		}
-		/* if different codec type, should not cross maximum other
-		   supported */
-		if (audpp->decoder_count > (max_instance + 1)) {
-			MM_ERR("Can not support, already reached max\n");
-			audpp->decoder_count--;
-			audpp->codec_cnt[codec_type]--;
-			goto done;
-		}
-		audpp->codec_max_instances = max_instance;
-		MM_DBG("different codec running\n");
-	} else {
-		max_instance = (dec_instance_list + audpp->op_mode *
-						MSM_MAX_DEC_CNT +
-						 codec_type)->
-							max_instances_same_dec;
-		/* if same codec type, should not cross maximum supported */
-		if (audpp->decoder_count > max_instance) {
-			MM_ERR("Can not support, already reached max\n");
-			audpp->decoder_count--;
-			audpp->codec_cnt[codec_type]--;
-			goto done;
-		}
-		audpp->codec_max_instances = max_instance;
-		MM_DBG("same codec running\n");
-	}
-
-	/* Point to Last entry of the row */
-	concurrency_entry = ((audpp->dec_database->dec_concurrency_table +
-			      ((audpp->concurrency + 1) *
-			       (audpp->dec_database->num_dec))) - 1);
-
-	lidx = audpp->dec_database->num_dec;
-	min_codecs_supported = sizeof(unsigned int) * 8;
-
-	MM_DBG("mode = 0x%08x codec = 0x%08x\n", mode, codec);
-
-	for (idx = lidx; idx > 0; idx--, concurrency_entry--) {
-		if (!(audpp->dec_inuse & (1 << (idx - 1)))) {
-			if (((mode & *concurrency_entry) == mode) &&
-			    (codec & *concurrency_entry)) {
-				/* Check supports minimum number codecs */
-				codecs_supported =
-				    audpp->dec_database->dec_info_list[idx -
-								       1].
-				    nr_codec_support;
-				if (codecs_supported < min_codecs_supported) {
-					lidx = idx - 1;
-					min_codecs_supported = codecs_supported;
-				}
-			}
-		}
-	}
-
-	if (lidx < audpp->dec_database->num_dec) {
-		audpp->dec_inuse |= (1 << lidx);
-		*module_name =
-		    audpp->dec_database->dec_info_list[lidx].module_name;
-		*queueid =
-		    audpp->dec_database->dec_info_list[lidx].module_queueid;
-		decid = audpp->dec_database->dec_info_list[lidx].module_decid;
-		audpp->dec_info_table[lidx].codec =
-		    (dec_attrb & AUDPP_CODEC_MASK);
-		audpp->dec_info_table[lidx].pid = current->pid;
-		/* point to row to get supported operation */
-		concurrency_entry =
-		    ((audpp->dec_database->dec_concurrency_table +
-		      ((audpp->concurrency) * (audpp->dec_database->num_dec))) +
-		     lidx);
-		decid |= ((*concurrency_entry & AUDPP_OP_MASK) >> 12);
-		MM_INFO("decid =0x%08x module_name=%s, queueid=%d \n", decid,
-				*module_name, *queueid);
-	}
-done:
-	mutex_unlock(audpp->lock_dec);
-	return decid;
-
-}
-EXPORT_SYMBOL(audpp_adec_alloc);
-
-void audpp_adec_free(int decid)
-{
-	struct audpp_state *audpp = &the_audpp_state;
-	int idx;
-	mutex_lock(audpp->lock_dec);
-	for (idx = audpp->dec_database->num_dec; idx > 0; idx--) {
-		if (audpp->dec_database->dec_info_list[idx - 1].module_decid ==
-		    decid) {
-			audpp->decoder_count--;
-			audpp->\
-			codec_cnt[audpp->dec_info_table[idx - 1].codec]--;
-			audpp->dec_inuse &= ~(1 << (idx - 1));
-			audpp->dec_info_table[idx - 1].codec = -1;
-			audpp->dec_info_table[idx - 1].pid = 0;
-			MM_INFO("free decid =%d \n", decid);
-			break;
-		}
-	}
-	mutex_unlock(audpp->lock_dec);
-	return;
-
-}
-EXPORT_SYMBOL(audpp_adec_free);
-
-static ssize_t concurrency_show(struct device *dev,
-				struct device_attribute *attr, char *buf)
-{
-	struct audpp_state *audpp = &the_audpp_state;
-	int rc;
-	mutex_lock(audpp->lock_dec);
-	rc = sprintf(buf, "%ld\n", audpp->concurrency);
-	mutex_unlock(audpp->lock_dec);
-	return rc;
-}
-
-static ssize_t concurrency_store(struct device *dev,
-				 struct device_attribute *attr,
-				 const char *buf, size_t count)
-{
-	struct audpp_state *audpp = &the_audpp_state;
-	unsigned long concurrency;
-	int rc = -1;
-	mutex_lock(audpp->lock_dec);
-	if (audpp->dec_inuse) {
-		MM_ERR("Can not change profile, while playback in progress\n");
-		goto done;
-	}
-	rc = strict_strtoul(buf, 10, &concurrency);
-	if (!rc &&
-		(concurrency < audpp->dec_database->num_concurrency_support)) {
-		audpp->concurrency = concurrency;
-		MM_DBG("Concurrency case %ld\n", audpp->concurrency);
-		rc = count;
-	} else {
-		MM_ERR("Not a valid Concurrency case\n");
-		rc = -EINVAL;
-	}
-done:
-	mutex_unlock(audpp->lock_dec);
-	return rc;
-}
-
-static ssize_t decoder_info_show(struct device *dev,
-				 struct device_attribute *attr, char *buf);
-static struct device_attribute dev_attr_decoder[AUDPP_MAX_DECODER_CNT] = {
-	__ATTR(decoder0, S_IRUGO, decoder_info_show, NULL),
-	__ATTR(decoder1, S_IRUGO, decoder_info_show, NULL),
-	__ATTR(decoder2, S_IRUGO, decoder_info_show, NULL),
-	__ATTR(decoder3, S_IRUGO, decoder_info_show, NULL),
-	__ATTR(decoder4, S_IRUGO, decoder_info_show, NULL),
-};
-
-static ssize_t decoder_info_show(struct device *dev,
-				 struct device_attribute *attr, char *buf)
-{
-	int cpy_sz = 0;
-	struct audpp_state *audpp = &the_audpp_state;
-	const ptrdiff_t off = attr - dev_attr_decoder;	/* decoder number */
-	mutex_lock(audpp->lock_dec);
-	cpy_sz += scnprintf(buf + cpy_sz, PAGE_SIZE - cpy_sz, "%d:",
-			    audpp->dec_info_table[off].codec);
-	cpy_sz += scnprintf(buf + cpy_sz, PAGE_SIZE - cpy_sz, "%d\n",
-			    audpp->dec_info_table[off].pid);
-	mutex_unlock(audpp->lock_dec);
-	return cpy_sz;
-}
-
-static DEVICE_ATTR(concurrency, S_IWUSR | S_IRUGO, concurrency_show,
-	    concurrency_store);
-static int audpp_probe(struct platform_device *pdev)
-{
-	int rc, idx;
-	struct audpp_state *audpp = &the_audpp_state;
-	audpp->concurrency = AUDPP_CONCURRENCY_DEFAULT;
-	audpp->dec_database =
-	    (struct msm_adspdec_database *)pdev->dev.platform_data;
-
-	MM_INFO("Number of decoder supported  %d\n",
-		audpp->dec_database->num_dec);
-	MM_INFO("Number of concurrency supported  %d\n",
-		audpp->dec_database->num_concurrency_support);
-	init_waitqueue_head(&audpp->event_wait);
-	for (idx = 0; idx < audpp->dec_database->num_dec; idx++) {
-		audpp->dec_info_table[idx].codec = -1;
-		audpp->dec_info_table[idx].pid = 0;
-		MM_INFO("module_name:%s\n",
-			audpp->dec_database->dec_info_list[idx].module_name);
-		MM_INFO("queueid:%d\n",
-			audpp->dec_database->dec_info_list[idx].module_queueid);
-		MM_INFO("decid:%d\n",
-			audpp->dec_database->dec_info_list[idx].module_decid);
-		MM_INFO("nr_codec_support:%d\n",
-			audpp->dec_database->dec_info_list[idx].
-			nr_codec_support);
-	}
-
-	wake_lock_init(&audpp_wake_lock, WAKE_LOCK_SUSPEND, "audpp");
-	for (idx = 0; idx < audpp->dec_database->num_dec; idx++) {
-		rc = device_create_file(&pdev->dev, &dev_attr_decoder[idx]);
-		if (rc)
-			goto err;
-	}
-	rc = device_create_file(&pdev->dev, &dev_attr_concurrency);
-	audpp->op_mode = 0; /* Consider as non turbo mode */
-	if (rc)
-		goto err;
-	else
-		goto done;
-err:
-	while (idx--)
-		device_remove_file(&pdev->dev, &dev_attr_decoder[idx]);
-done:
-	return rc;
-}
-
-static struct platform_driver audpp_plat_driver = {
-	.probe = audpp_probe,
-	.driver = {
-		   .name = "msm_adspdec",
-		   .owner = THIS_MODULE,
-		   },
-};
-
-static int __init audpp_init(void)
-{
-	return platform_driver_register(&audpp_plat_driver);
-}
-
-device_initcall(audpp_init);
diff --git a/arch/arm/mach-msm/qdsp5v2/audpreproc.c b/arch/arm/mach-msm/qdsp5v2/audpreproc.c
deleted file mode 100644
index 28eead0..0000000
--- a/arch/arm/mach-msm/qdsp5v2/audpreproc.c
+++ /dev/null
@@ -1,527 +0,0 @@
-/*
- * Common code to deal with the AUDPREPROC dsp task (audio preprocessing)
- *
- * Copyright (c) 2009-2011, The Linux Foundation. All rights reserved.
- *
- * Based on the audpp layer in arch/arm/mach-msm/qdsp5/audpp.c
- *
- * Copyright (C) 2008 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/wakelock.h>
-#include <linux/pm_qos.h>
-
-#include <mach/msm_adsp.h>
-#include <mach/qdsp5v2/audio_acdbi.h>
-#include <mach/qdsp5v2/audpreproc.h>
-#include <mach/debug_mm.h>
-#include <mach/qdsp5v2/qdsp5audpreprocmsg.h>
-#include <mach/cpuidle.h>
-
-static DEFINE_MUTEX(audpreproc_lock);
-static struct wake_lock audpre_wake_lock;
-static struct pm_qos_request audpre_pm_qos_req;
-
-struct msm_adspenc_info {
-	const char *module_name;
-	unsigned module_queueids;
-	int module_encid; /* streamid */
-	int enc_formats; /* supported formats */
-	int nr_codec_support; /* number of codec suported */
-};
-
-#define ENC_MODULE_INFO(name, queueids, encid, formats, nr_codec) \
-	{.module_name = name, .module_queueids = queueids, \
-	 .module_encid = encid, .enc_formats = formats, \
-	 .nr_codec_support = nr_codec }
-
-#define MAX_EVENT_CALLBACK_CLIENTS 1
-
-#define ENC0_FORMAT ((1<<MSM_ADSP_ENC_CODEC_WAV)| \
-	(1<<MSM_ADSP_ENC_CODEC_SBC) | (1<<MSM_ADSP_ENC_CODEC_EXT_WAV))
-
-#define ENC1_FORMAT ((1<<MSM_ADSP_ENC_CODEC_WAV)| \
-	(1<<MSM_ADSP_ENC_CODEC_AAC) | (1<<MSM_ADSP_ENC_CODEC_AMRNB) | \
-	(1<<MSM_ADSP_ENC_CODEC_EVRC) | (1<<MSM_ADSP_ENC_CODEC_QCELP) | \
-	(1<<MSM_ADSP_ENC_CODEC_EXT_WAV))
-
-#define ENC2_FORMAT ((1<<MSM_ADSP_ENC_CODEC_WAV) | \
-	(1<<MSM_ADSP_ENC_CODEC_EXT_WAV))
-
-struct msm_adspenc_database {
-	unsigned num_enc;
-	struct msm_adspenc_info *enc_info_list;
-};
-
-static struct msm_adspenc_info enc_info_list[] = {
-	ENC_MODULE_INFO("AUDREC0TASK", \
-			((QDSP_uPAudRec0BitStreamQueue << 16)| \
-			   QDSP_uPAudRec0CmdQueue), 0, \
-			 (ENC0_FORMAT  | (1 << MSM_ADSP_ENC_MODE_TUNNEL)), 3),
-
-	ENC_MODULE_INFO("AUDREC1TASK", \
-			 ((QDSP_uPAudRec1BitStreamQueue << 16)| \
-			   QDSP_uPAudRec1CmdQueue), 1, \
-			 (ENC1_FORMAT | (1 << MSM_ADSP_ENC_MODE_TUNNEL) | \
-			  (1 << MSM_ADSP_ENC_MODE_NON_TUNNEL)), 6),
-
-	ENC_MODULE_INFO("AUDREC2TASK", \
-			 ((QDSP_uPAudRec2BitStreamQueue << 16)| \
-			   QDSP_uPAudRec2CmdQueue), 2, \
-			 (ENC2_FORMAT  | (1 << MSM_ADSP_ENC_MODE_TUNNEL)), 2),
-
-};
-
-static struct msm_adspenc_database msm_enc_database = {
-	.num_enc = ARRAY_SIZE(enc_info_list),
-	.enc_info_list = enc_info_list,
-};
-
-
-static struct audrec_session_info
-		session_info[MAX_ENC_COUNT] = { {0, 0}, {0, 0}, {0, 0} };
-
-struct audpreproc_state {
-	struct msm_adsp_module *mod;
-	audpreproc_event_func func[MAX_ENC_COUNT];
-	void *private[MAX_ENC_COUNT];
-	struct mutex *lock;
-	unsigned open_count;
-	unsigned enc_inuse;
-	struct audpreproc_event_callback *cb_tbl[MAX_EVENT_CALLBACK_CLIENTS];
-};
-
-static struct audpreproc_state the_audpreproc_state = {
-	.lock = &audpreproc_lock,
-};
-
-static inline void prevent_suspend(void)
-{
-	wake_lock(&audpre_wake_lock);
-	pm_qos_update_request(&audpre_pm_qos_req,
-			      msm_cpuidle_get_deep_idle_latency());
-}
-static inline void allow_suspend(void)
-{
-	pm_qos_update_request(&audpre_pm_qos_req, PM_QOS_DEFAULT_VALUE);
-	wake_unlock(&audpre_wake_lock);
-}
-
-/* DSP preproc event handler */
-static void audpreproc_dsp_event(void *data, unsigned id, size_t len,
-			    void (*getevent)(void *ptr, size_t len))
-{
-	struct audpreproc_state *audpreproc = data;
-	int n = 0;
-
-	switch (id) {
-	case AUDPREPROC_CMD_CFG_DONE_MSG: {
-		struct audpreproc_cmd_cfg_done_msg cfg_done_msg;
-
-		getevent(&cfg_done_msg, AUDPREPROC_CMD_CFG_DONE_MSG_LEN);
-		MM_DBG("AUDPREPROC_CMD_CFG_DONE_MSG: stream id %d preproc \
-			type %x\n", cfg_done_msg.stream_id, \
-			cfg_done_msg.aud_preproc_type);
-		if ((cfg_done_msg.stream_id < MAX_ENC_COUNT) &&
-				audpreproc->func[cfg_done_msg.stream_id])
-			audpreproc->func[cfg_done_msg.stream_id](
-			audpreproc->private[cfg_done_msg.stream_id], id,
-			&cfg_done_msg);
-		break;
-	}
-	case AUDPREPROC_ERROR_MSG: {
-		struct audpreproc_err_msg err_msg;
-
-		getevent(&err_msg, AUDPREPROC_ERROR_MSG_LEN);
-		MM_DBG("AUDPREPROC_ERROR_MSG: stream id %d err idx %d\n",
-		err_msg.stream_id, err_msg.aud_preproc_err_idx);
-		if ((err_msg.stream_id < MAX_ENC_COUNT) &&
-				audpreproc->func[err_msg.stream_id])
-			audpreproc->func[err_msg.stream_id](
-			audpreproc->private[err_msg.stream_id], id,
-			&err_msg);
-		break;
-	}
-	case AUDPREPROC_CMD_ENC_CFG_DONE_MSG: {
-		struct audpreproc_cmd_enc_cfg_done_msg enc_cfg_msg;
-
-		getevent(&enc_cfg_msg, AUDPREPROC_CMD_ENC_CFG_DONE_MSG_LEN);
-		MM_DBG("AUDPREPROC_CMD_ENC_CFG_DONE_MSG: stream id %d enc type \
-			%d\n", enc_cfg_msg.stream_id, enc_cfg_msg.rec_enc_type);
-		if ((enc_cfg_msg.stream_id < MAX_ENC_COUNT) &&
-				audpreproc->func[enc_cfg_msg.stream_id])
-			audpreproc->func[enc_cfg_msg.stream_id](
-			audpreproc->private[enc_cfg_msg.stream_id], id,
-			&enc_cfg_msg);
-		for (n = 0; n < MAX_EVENT_CALLBACK_CLIENTS; ++n) {
-			if (audpreproc->cb_tbl[n] &&
-					audpreproc->cb_tbl[n]->fn) {
-				audpreproc->cb_tbl[n]->fn( \
-					audpreproc->cb_tbl[n]->private, \
-					id, (void *) &enc_cfg_msg);
-			}
-		}
-		break;
-	}
-	case AUDPREPROC_CMD_ENC_PARAM_CFG_DONE_MSG: {
-		struct audpreproc_cmd_enc_param_cfg_done_msg enc_param_msg;
-
-		getevent(&enc_param_msg,
-				AUDPREPROC_CMD_ENC_PARAM_CFG_DONE_MSG_LEN);
-		MM_DBG("AUDPREPROC_CMD_ENC_PARAM_CFG_DONE_MSG: stream id %d\n",
-				 enc_param_msg.stream_id);
-		if ((enc_param_msg.stream_id < MAX_ENC_COUNT) &&
-				audpreproc->func[enc_param_msg.stream_id])
-			audpreproc->func[enc_param_msg.stream_id](
-			audpreproc->private[enc_param_msg.stream_id], id,
-			&enc_param_msg);
-		break;
-	}
-	case AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG_DONE_MSG: {
-		struct audpreproc_afe_cmd_audio_record_cfg_done
-						record_cfg_done;
-		getevent(&record_cfg_done,
-			AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG_DONE_MSG_LEN);
-		MM_DBG("AUDPREPROC_AFE_CMD_AUDIO_RECORD_CFG_DONE_MSG: \
-			stream id %d\n", record_cfg_done.stream_id);
-		if ((record_cfg_done.stream_id < MAX_ENC_COUNT) &&
-				audpreproc->func[record_cfg_done.stream_id])
-			audpreproc->func[record_cfg_done.stream_id](
-			audpreproc->private[record_cfg_done.stream_id], id,
-			&record_cfg_done);
-		break;
-	}
-	case AUDPREPROC_CMD_ROUTING_MODE_DONE_MSG: {
-		struct audpreproc_cmd_routing_mode_done  routing_mode_done;
-
-		getevent(&routing_mode_done,
-			AUDPREPROC_CMD_ROUTING_MODE_DONE_MSG_LEN);
-		MM_DBG("AUDPREPROC_CMD_ROUTING_MODE_DONE_MSG: \
-			stream id %d\n", routing_mode_done.stream_id);
-		if ((routing_mode_done.stream_id < MAX_ENC_COUNT) &&
-				audpreproc->func[routing_mode_done.stream_id])
-			audpreproc->func[routing_mode_done.stream_id](
-			audpreproc->private[routing_mode_done.stream_id], id,
-			&routing_mode_done);
-		break;
-	}
-#ifdef CONFIG_DEBUG_FS
-	case AUDPREPROC_MSG_FEAT_QUERY_DM_DONE:
-	   {
-	    uint16_t msg[3];
-	    getevent(msg, sizeof(msg));
-	    MM_INFO("RTC ACK --> %x %x %x\n", msg[0], msg[1], msg[2]);
-	    acdb_rtc_set_err(msg[2]);
-	   }
-	break;
-#endif
-	case ADSP_MESSAGE_ID: {
-		MM_DBG("Received ADSP event:module audpreproctask\n");
-		break;
-	}
-	default:
-		MM_ERR("Unknown Event %d\n", id);
-	}
-	return;
-}
-
-static struct msm_adsp_ops adsp_ops = {
-	.event = audpreproc_dsp_event,
-};
-
-/* EXPORTED API's */
-int audpreproc_enable(int enc_id, audpreproc_event_func func, void *private)
-{
-	struct audpreproc_state *audpreproc = &the_audpreproc_state;
-	int res = 0;
-
-	if (enc_id < 0 || enc_id > (MAX_ENC_COUNT - 1))
-		return -EINVAL;
-
-	mutex_lock(audpreproc->lock);
-	if (audpreproc->func[enc_id]) {
-		res = -EBUSY;
-		goto out;
-	}
-
-	audpreproc->func[enc_id] = func;
-	audpreproc->private[enc_id] = private;
-
-	/* First client to enable preproc task */
-	if (audpreproc->open_count++ == 0) {
-		MM_DBG("Get AUDPREPROCTASK\n");
-		res = msm_adsp_get("AUDPREPROCTASK", &audpreproc->mod,
-				&adsp_ops, audpreproc);
-		if (res < 0) {
-			MM_ERR("Can not get AUDPREPROCTASK\n");
-			audpreproc->open_count = 0;
-			audpreproc->func[enc_id] = NULL;
-			audpreproc->private[enc_id] = NULL;
-			goto out;
-		}
-		prevent_suspend();
-		if (msm_adsp_enable(audpreproc->mod)) {
-			MM_ERR("Can not enable AUDPREPROCTASK\n");
-			audpreproc->open_count = 0;
-			audpreproc->func[enc_id] = NULL;
-			audpreproc->private[enc_id] = NULL;
-			msm_adsp_put(audpreproc->mod);
-			audpreproc->mod = NULL;
-			res = -ENODEV;
-			allow_suspend();
-			goto out;
-		}
-	}
-	res = 0;
-out:
-	mutex_unlock(audpreproc->lock);
-	return res;
-}
-EXPORT_SYMBOL(audpreproc_enable);
-
-int audpreproc_update_audrec_info(
-			struct audrec_session_info *audrec_session_info)
-{
-	if (!audrec_session_info) {
-		MM_ERR("error in audrec session info address\n");
-		return -EINVAL;
-	}
-	if (audrec_session_info->session_id < MAX_ENC_COUNT) {
-		memcpy(&session_info[audrec_session_info->session_id],
-				audrec_session_info,
-				sizeof(struct audrec_session_info));
-		return 0;
-	}
-	return -EINVAL;
-}
-EXPORT_SYMBOL(audpreproc_update_audrec_info);
-
-void audpreproc_disable(int enc_id, void *private)
-{
-	struct audpreproc_state *audpreproc = &the_audpreproc_state;
-
-	if (enc_id < 0 || enc_id > (MAX_ENC_COUNT - 1))
-		return;
-
-	mutex_lock(audpreproc->lock);
-	if (!audpreproc->func[enc_id])
-		goto out;
-	if (audpreproc->private[enc_id] != private)
-		goto out;
-
-	audpreproc->func[enc_id] = NULL;
-	audpreproc->private[enc_id] = NULL;
-
-	/* Last client then disable preproc task */
-	if (--audpreproc->open_count == 0) {
-		msm_adsp_disable(audpreproc->mod);
-		MM_DBG("Put AUDPREPROCTASK\n");
-		msm_adsp_put(audpreproc->mod);
-		audpreproc->mod = NULL;
-		allow_suspend();
-	}
-out:
-	mutex_unlock(audpreproc->lock);
-	return;
-}
-EXPORT_SYMBOL(audpreproc_disable);
-
-
-int audpreproc_register_event_callback(struct audpreproc_event_callback *ecb)
-{
-	struct audpreproc_state *audpreproc = &the_audpreproc_state;
-	int i;
-
-	for (i = 0; i < MAX_EVENT_CALLBACK_CLIENTS; ++i) {
-		if (NULL == audpreproc->cb_tbl[i]) {
-			audpreproc->cb_tbl[i] = ecb;
-			return 0;
-		}
-	}
-	return -1;
-}
-EXPORT_SYMBOL(audpreproc_register_event_callback);
-
-int audpreproc_unregister_event_callback(struct audpreproc_event_callback *ecb)
-{
-	struct audpreproc_state *audpreproc = &the_audpreproc_state;
-	int i;
-
-	for (i = 0; i < MAX_EVENT_CALLBACK_CLIENTS; ++i) {
-		if (ecb == audpreproc->cb_tbl[i]) {
-			audpreproc->cb_tbl[i] = NULL;
-			return 0;
-		}
-	}
-	return -1;
-}
-EXPORT_SYMBOL(audpreproc_unregister_event_callback);
-
-
-/* enc_type = supported encode format *
- * like pcm, aac, sbc, evrc, qcelp, amrnb etc ... *
- */
-int audpreproc_aenc_alloc(unsigned enc_type, const char **module_name,
-		     unsigned *queue_ids)
-{
-	struct audpreproc_state *audpreproc = &the_audpreproc_state;
-	int encid = -1, idx, lidx, mode, codec;
-	int codecs_supported, min_codecs_supported;
-	static int wakelock_init;
-
-	mutex_lock(audpreproc->lock);
-	/* Represents in bit mask */
-	mode = ((enc_type & AUDPREPROC_MODE_MASK) << 16);
-	codec = (1 << (enc_type & AUDPREPROC_CODEC_MASK));
-
-	lidx = msm_enc_database.num_enc;
-	min_codecs_supported = sizeof(unsigned int) * 8;
-	MM_DBG("mode = 0x%08x codec = 0x%08x\n", mode, codec);
-
-	for (idx = lidx-1; idx >= 0; idx--) {
-		/* encoder free and supports the format */
-		if (!(audpreproc->enc_inuse & (1 << (idx))) &&
-		((mode & msm_enc_database.enc_info_list[idx].enc_formats)
-		== mode) && ((codec &
-		msm_enc_database.enc_info_list[idx].enc_formats)
-		== codec)){
-			/* Check supports minimum number codecs */
-			codecs_supported =
-			msm_enc_database.enc_info_list[idx].nr_codec_support;
-			if (codecs_supported < min_codecs_supported) {
-				lidx = idx;
-				min_codecs_supported = codecs_supported;
-			}
-		}
-	}
-
-	if (lidx < msm_enc_database.num_enc) {
-		audpreproc->enc_inuse |= (1 << lidx);
-		*module_name =
-		    msm_enc_database.enc_info_list[lidx].module_name;
-		*queue_ids =
-		    msm_enc_database.enc_info_list[lidx].module_queueids;
-		encid = msm_enc_database.enc_info_list[lidx].module_encid;
-	}
-
-	if (!wakelock_init) {
-		wake_lock_init(&audpre_wake_lock, WAKE_LOCK_SUSPEND, "audpre");
-		pm_qos_add_request(&audpre_pm_qos_req, PM_QOS_CPU_DMA_LATENCY,
-					PM_QOS_DEFAULT_VALUE);
-		wakelock_init = 1;
-	}
-
-	mutex_unlock(audpreproc->lock);
-	return encid;
-}
-EXPORT_SYMBOL(audpreproc_aenc_alloc);
-
-void audpreproc_aenc_free(int enc_id)
-{
-	struct audpreproc_state *audpreproc = &the_audpreproc_state;
-	int idx;
-
-	mutex_lock(audpreproc->lock);
-	for (idx = 0; idx < msm_enc_database.num_enc; idx++) {
-		if (msm_enc_database.enc_info_list[idx].module_encid ==
-		    enc_id) {
-			audpreproc->enc_inuse &= ~(1 << idx);
-			break;
-		}
-	}
-	mutex_unlock(audpreproc->lock);
-	return;
-
-}
-EXPORT_SYMBOL(audpreproc_aenc_free);
-
-int audpreproc_send_preproccmdqueue(void *cmd, unsigned len)
-{
-	return msm_adsp_write(the_audpreproc_state.mod,
-				QDSP_uPAudPreProcCmdQueue, cmd, len);
-}
-EXPORT_SYMBOL(audpreproc_send_preproccmdqueue);
-
-int audpreproc_send_audreccmdqueue(void *cmd, unsigned len)
-{
-	return msm_adsp_write(the_audpreproc_state.mod,
-			      QDSP_uPAudPreProcAudRecCmdQueue, cmd, len);
-}
-EXPORT_SYMBOL(audpreproc_send_audreccmdqueue);
-
-int audpreproc_send_audrec2cmdqueue(void *cmd, unsigned len)
-{
-	return msm_adsp_write(the_audpreproc_state.mod,
-			      QDSP_uPAudRec2CmdQueue, cmd, len);
-}
-EXPORT_SYMBOL(audpreproc_send_audrec2cmdqueue);
-
-int audpreproc_dsp_set_agc(struct audpreproc_cmd_cfg_agc_params *agc,
-				unsigned len)
-{
-	return msm_adsp_write(the_audpreproc_state.mod,
-				QDSP_uPAudPreProcCmdQueue, agc, len);
-}
-EXPORT_SYMBOL(audpreproc_dsp_set_agc);
-
-int audpreproc_dsp_set_agc2(struct audpreproc_cmd_cfg_agc_params_2 *agc2,
-				unsigned len)
-{
-	return msm_adsp_write(the_audpreproc_state.mod,
-				QDSP_uPAudPreProcCmdQueue, agc2, len);
-}
-EXPORT_SYMBOL(audpreproc_dsp_set_agc2);
-
-int audpreproc_dsp_set_ns(struct audpreproc_cmd_cfg_ns_params *ns,
-				unsigned len)
-{
-	return msm_adsp_write(the_audpreproc_state.mod,
-				QDSP_uPAudPreProcCmdQueue, ns, len);
-}
-EXPORT_SYMBOL(audpreproc_dsp_set_ns);
-
-int audpreproc_dsp_set_iir(
-struct audpreproc_cmd_cfg_iir_tuning_filter_params *iir, unsigned len)
-{
-	return msm_adsp_write(the_audpreproc_state.mod,
-				QDSP_uPAudPreProcCmdQueue, iir, len);
-}
-EXPORT_SYMBOL(audpreproc_dsp_set_iir);
-
-int audpreproc_dsp_set_gain_tx(
-		struct audpreproc_cmd_cfg_cal_gain *calib_gain_tx, unsigned len)
-{
-	return msm_adsp_write(the_audpreproc_state.mod,
-			QDSP_uPAudPreProcCmdQueue, calib_gain_tx, len);
-}
-EXPORT_SYMBOL(audpreproc_dsp_set_gain_tx);
-
-void get_audrec_session_info(int id, struct audrec_session_info *info)
-{
-	if (id >= MAX_ENC_COUNT) {
-		MM_ERR("invalid session id = %d\n", id);
-		return;
-	}
-	memcpy(info, &session_info[id], sizeof(struct audrec_session_info));
-}
-EXPORT_SYMBOL(get_audrec_session_info);
-
-int audpreproc_dsp_set_lvnv(
-	struct audpreproc_cmd_cfg_lvnv_param *preproc_lvnv, unsigned len)
-{
-	return msm_adsp_write(the_audpreproc_state.mod,
-		QDSP_uPAudPreProcCmdQueue, preproc_lvnv, len);
-}
-EXPORT_SYMBOL(audpreproc_dsp_set_lvnv);
-
diff --git a/arch/arm/mach-msm/qdsp5v2/aux_pcm.c b/arch/arm/mach-msm/qdsp5v2/aux_pcm.c
deleted file mode 100644
index 06318bc..0000000
--- a/arch/arm/mach-msm/qdsp5v2/aux_pcm.c
+++ /dev/null
@@ -1,280 +0,0 @@
-/* Copyright (c) 2009-2011, The Linux Foundation. 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.
- *
- */
-#include <linux/module.h>
-#include <linux/mutex.h>
-#include <linux/platform_device.h>
-#include <linux/io.h>
-#include <linux/err.h>
-#include <linux/gpio.h>
-#include <mach/qdsp5v2/aux_pcm.h>
-#include <linux/delay.h>
-#include <mach/debug_mm.h>
-
-/*----------------------------------------------------------------------------
- * Preprocessor Definitions and Constants
- * -------------------------------------------------------------------------*/
-
-/* define offset of registers here, may put them into platform data */
-#define AUX_CODEC_CTL_OFFSET 0x00
-#define PCM_PATH_CTL_OFFSET 0x04
-#define AUX_CODEC_CTL_OUT_OFFSET 0x08
-
-/* define some bit values in PCM_PATH_CTL register */
-#define PCM_PATH_CTL__ADSP_CTL_EN_BMSK 0x8
-
-/* mask and shift */
-#define AUX_CODEC_CTL_ADSP_CODEC_CTL_EN_BMSK 0x800
-#define AUX_CODEC_CTL_PCM_SYNC_LONG_BMSK 0x400
-#define AUX_CODEC_CTL_PCM_SYNC_SHORT_BMSK 0x200
-#define AUX_CODEC_CTL_I2S_SAMPLE_CLK_SRC_BMSK 0x80
-#define AUX_CODEC_CTL_I2S_SAMPLE_CLK_MODE_BMSK 0x40
-#define AUX_CODEC_CTL_I2S_RX_MODE_BMSK 0x20
-#define AUX_CODEC_CTL_I2S_CLK_MODE_BMSK 0x10
-#define AUX_CODEC_CTL_AUX_PCM_MODE_BMSK 0x0b
-#define AUX_CODEC_CTL_AUX_CODEC_MODE_BMSK 0x02
-
-/* AUX PCM MODE */
-#define MASTER_PRIM_PCM_SHORT 0
-#define MASTER_AUX_PCM_LONG 1
-#define SLAVE_PRIM_PCM_SHORT 2
-
-struct aux_pcm_state {
-	void __iomem *aux_pcm_base;  /* configure aux pcm through Scorpion */
-	int     dout;
-	int     din;
-	int     syncout;
-	int     clkin_a;
-};
-
-static struct aux_pcm_state the_aux_pcm_state;
-
-static void __iomem *get_base_addr(struct aux_pcm_state *aux_pcm)
-{
-	return aux_pcm->aux_pcm_base;
-}
-
-/* Set who control aux pcm : adsp or MSM */
-void aux_codec_adsp_codec_ctl_en(bool msm_adsp_en)
-{
-	void __iomem *baddr = get_base_addr(&the_aux_pcm_state);
-	uint32_t val;
-
-	if (!IS_ERR(baddr)) {
-		val = readl(baddr + AUX_CODEC_CTL_OFFSET);
-		if (msm_adsp_en) { /* adsp */
-			writel(
-			((val & ~AUX_CODEC_CTL_ADSP_CODEC_CTL_EN_BMSK) |
-			AUX_CODEC_CTL__ADSP_CODEC_CTL_EN__ADSP_V),
-			baddr + AUX_CODEC_CTL_OFFSET);
-		} else { /* MSM */
-			writel(
-			((val & ~AUX_CODEC_CTL_ADSP_CODEC_CTL_EN_BMSK) |
-			AUX_CODEC_CTL__ADSP_CODEC_CTL_EN__MSM_V),
-			baddr + AUX_CODEC_CTL_OFFSET);
-		}
-	}
-	mb();
-}
-
-/* Set who control aux pcm path: adsp or MSM */
-void aux_codec_pcm_path_ctl_en(bool msm_adsp_en)
-{
-	void __iomem *baddr = get_base_addr(&the_aux_pcm_state);
-	uint32_t val;
-
-	 if (!IS_ERR(baddr)) {
-		val = readl(baddr + PCM_PATH_CTL_OFFSET);
-		if (msm_adsp_en) { /* adsp */
-			writel(
-			((val & ~PCM_PATH_CTL__ADSP_CTL_EN_BMSK) |
-			PCM_PATH_CTL__ADSP_CTL_EN__ADSP_V),
-			baddr + PCM_PATH_CTL_OFFSET);
-		} else { /* MSM */
-			writel(
-			((val & ~PCM_PATH_CTL__ADSP_CTL_EN_BMSK) |
-			PCM_PATH_CTL__ADSP_CTL_EN__MSM_V),
-			baddr + PCM_PATH_CTL_OFFSET);
-		}
-	}
-	mb();
-	return;
-}
-EXPORT_SYMBOL(aux_codec_pcm_path_ctl_en);
-
-int aux_pcm_gpios_request(void)
-{
-	int rc = 0;
-
-	MM_DBG("aux_pcm_gpios_request\n");
-	rc = gpio_request(the_aux_pcm_state.dout, "AUX PCM DOUT");
-	if (rc) {
-		MM_ERR("GPIO request for AUX PCM DOUT failed\n");
-		return rc;
-	}
-
-	rc = gpio_request(the_aux_pcm_state.din, "AUX PCM DIN");
-	if (rc) {
-		MM_ERR("GPIO request for AUX PCM DIN failed\n");
-		gpio_free(the_aux_pcm_state.dout);
-		return rc;
-	}
-
-	rc = gpio_request(the_aux_pcm_state.syncout, "AUX PCM SYNC OUT");
-	if (rc) {
-		MM_ERR("GPIO request for AUX PCM SYNC OUT failed\n");
-		gpio_free(the_aux_pcm_state.dout);
-		gpio_free(the_aux_pcm_state.din);
-		return rc;
-	}
-
-	rc = gpio_request(the_aux_pcm_state.clkin_a, "AUX PCM CLKIN A");
-	if (rc) {
-		MM_ERR("GPIO request for AUX PCM CLKIN A failed\n");
-		gpio_free(the_aux_pcm_state.dout);
-		gpio_free(the_aux_pcm_state.din);
-		gpio_free(the_aux_pcm_state.syncout);
-		return rc;
-	}
-
-	return rc;
-}
-EXPORT_SYMBOL(aux_pcm_gpios_request);
-
-
-void aux_pcm_gpios_free(void)
-{
-	MM_DBG(" aux_pcm_gpios_free \n");
-
-	/*
-	 * Feed silence frames before close to prevent buzzing sound in BT at
-	 * call end. This fix is applicable only to Marimba BT.
-	 */
-	gpio_tlmm_config(GPIO_CFG(the_aux_pcm_state.dout, 0, GPIO_CFG_OUTPUT,
-		GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
-	gpio_set_value(the_aux_pcm_state.dout, 0);
-	msleep(20);
-	gpio_tlmm_config(GPIO_CFG(the_aux_pcm_state.dout, 1, GPIO_CFG_OUTPUT,
-		GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
-
-	gpio_free(the_aux_pcm_state.dout);
-	gpio_free(the_aux_pcm_state.din);
-	gpio_free(the_aux_pcm_state.syncout);
-	gpio_free(the_aux_pcm_state.clkin_a);
-}
-EXPORT_SYMBOL(aux_pcm_gpios_free);
-
-
-static int get_aux_pcm_gpios(struct platform_device *pdev)
-{
-	int rc = 0;
-	struct resource         *res;
-
-	/* Claim all of the GPIOs. */
-	res = platform_get_resource_byname(pdev, IORESOURCE_IO,
-					"aux_pcm_dout");
-	if  (!res) {
-		MM_ERR("%s: failed to get gpio AUX PCM DOUT\n", __func__);
-		return -ENODEV;
-	}
-
-	the_aux_pcm_state.dout = res->start;
-
-	res = platform_get_resource_byname(pdev, IORESOURCE_IO,
-					"aux_pcm_din");
-	if  (!res) {
-		MM_ERR("%s: failed to get gpio AUX PCM DIN\n", __func__);
-		return -ENODEV;
-	}
-
-	the_aux_pcm_state.din = res->start;
-
-	res = platform_get_resource_byname(pdev, IORESOURCE_IO,
-					"aux_pcm_syncout");
-	if  (!res) {
-		MM_ERR("%s: failed to get gpio AUX PCM SYNC OUT\n", __func__);
-		return -ENODEV;
-	}
-
-	the_aux_pcm_state.syncout = res->start;
-
-	res = platform_get_resource_byname(pdev, IORESOURCE_IO,
-					"aux_pcm_clkin_a");
-	if  (!res) {
-		MM_ERR("%s: failed to get gpio AUX PCM CLKIN A\n", __func__);
-		return -ENODEV;
-	}
-
-	the_aux_pcm_state.clkin_a = res->start;
-
-	return rc;
-}
-static int aux_pcm_probe(struct platform_device *pdev)
-{
-	int rc = 0;
-	struct resource *mem_src;
-
-	MM_DBG("aux_pcm_probe \n");
-	mem_src = platform_get_resource_byname(pdev, IORESOURCE_MEM,
-						"aux_codec_reg_addr");
-	if (!mem_src) {
-		rc = -ENODEV;
-		goto done;
-	}
-
-	the_aux_pcm_state.aux_pcm_base = ioremap(mem_src->start,
-		(mem_src->end - mem_src->start) + 1);
-	if (!the_aux_pcm_state.aux_pcm_base) {
-		rc = -ENOMEM;
-		goto done;
-	}
-	rc = get_aux_pcm_gpios(pdev);
-	if (rc) {
-		MM_ERR("GPIO configuration failed\n");
-		rc = -ENODEV;
-	}
-
-done:	return rc;
-
-}
-
-static int aux_pcm_remove(struct platform_device *pdev)
-{
-	iounmap(the_aux_pcm_state.aux_pcm_base);
-	return 0;
-}
-
-static struct platform_driver aux_pcm_driver = {
-	.probe = aux_pcm_probe,
-	.remove = aux_pcm_remove,
-	.driver = {
-		.name = "msm_aux_pcm",
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init aux_pcm_init(void)
-{
-
-	return platform_driver_register(&aux_pcm_driver);
-}
-
-static void __exit aux_pcm_exit(void)
-{
-	platform_driver_unregister(&aux_pcm_driver);
-}
-
-module_init(aux_pcm_init);
-module_exit(aux_pcm_exit);
-
-MODULE_DESCRIPTION("MSM AUX PCM driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5v2/lpa.c b/arch/arm/mach-msm/qdsp5v2/lpa.c
deleted file mode 100644
index 5ffda8a..0000000
--- a/arch/arm/mach-msm/qdsp5v2/lpa.c
+++ /dev/null
@@ -1,608 +0,0 @@
-/* Copyright (c) 2009-2011, The Linux Foundation. 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.
- *
- */
-#include <linux/module.h>
-#include <linux/mutex.h>
-#include <linux/platform_device.h>
-#include <linux/io.h>
-#include <linux/err.h>
-#include <linux/delay.h>
-#include <linux/clk.h>
-#include <mach/qdsp5v2/lpa.h>
-#include <mach/qdsp5v2/lpa_hw.h>
-#include <mach/qdsp5v2/msm_lpa.h>
-#include <mach/debug_mm.h>
-
-#define LPA_REG_WRITEL(drv, val, reg)  writel(val, drv->baseaddr + reg)
-#define LPA_REG_READL(drv, reg)  readl(drv->baseaddr + reg)
-
-/* bit 2:0 is reserved because watermarks have to be 64-bit aligned */
-#define LLB_WATERMARK_VAL_MASK 0x00000003
-
-#define LPA_STATUS_SBUF_EN 0x01
-
-struct lpa_drv {
-	void __iomem *baseaddr;
-	u32 obuf_hlb_size;
-	u32 dsp_proc_id;
-	u32 app_proc_id;
-	struct lpa_mem_config nosb_config;
-	struct lpa_mem_config sb_config;
-	u32 status;
-	u32 watermark_bytes;
-	u32 watermark_aheadtime;
-	u32 sample_boundary;
-};
-
-struct lpa_state {
-	struct lpa_drv lpa_drv; /* One instance for now */
-	u32 assigned;
-	struct mutex lpa_lock;
-};
-
-struct lpa_state the_lpa_state;
-
-static void lpa_enable_codec(struct lpa_drv *lpa, bool enable)
-{
-	u32 val;
-
-	val = LPA_REG_READL(lpa, LPA_OBUF_CODEC);
-	val = enable ? (val | LPA_OBUF_CODEC_CODEC_INTF_EN_BMSK) :
-		(val & ~LPA_OBUF_CODEC_CODEC_INTF_EN_BMSK);
-	val |= LPA_OBUF_CODEC_LOAD_BMSK;
-	LPA_REG_WRITEL(lpa, val, LPA_OBUF_CODEC);
-	mb();
-}
-
-static void lpa_reset(struct lpa_drv *lpa)
-{
-	u32 status;
-	struct clk *adsp_clk;
-	/* Need to make sure not disable clock while other device is enabled */
-	adsp_clk = clk_get(NULL, "adsp_clk");
-	if (!adsp_clk) {
-		MM_ERR("failed to get adsp clk\n");
-		goto error;
-	}
-	clk_prepare_enable(adsp_clk);
-	lpa_enable_codec(lpa, 0);
-	LPA_REG_WRITEL(lpa, (LPA_OBUF_RESETS_MISR_RESET |
-		LPA_OBUF_RESETS_OVERALL_RESET), LPA_OBUF_RESETS);
-	do {
-		status = LPA_REG_READL(lpa, LPA_OBUF_STATUS);
-	} while (!(status & LPA_OBUF_STATUS_RESET_DONE));
-
-	LPA_REG_WRITEL(lpa, LPA_OBUF_ACK_RESET_DONE_BMSK, LPA_OBUF_ACK);
-	mb();
-	clk_disable_unprepare(adsp_clk);
-	clk_put(adsp_clk);
-error:
-	return;
-}
-
-static void lpa_config_hlb_addr(struct lpa_drv *lpa)
-{
-	u32 val, min_addr = 0, max_addr = min_addr + lpa->obuf_hlb_size;
-
-	val = (min_addr & LPA_OBUF_HLB_MIN_ADDR_SEG_BMSK) |
-	LPA_OBUF_HLB_MIN_ADDR_LOAD_BMSK;
-	LPA_REG_WRITEL(lpa, val, LPA_OBUF_HLB_MIN_ADDR);
-	val = max_addr & LPA_OBUF_HLB_MAX_ADDR_SEG_BMSK;
-	LPA_REG_WRITEL(lpa, val, LPA_OBUF_HLB_MAX_ADDR);
-}
-
-static void lpa_powerup_mem_bank(struct lpa_drv *lpa,
-	struct lpa_mem_bank_select *bank)
-{
-	u32 status, val;
-
-	status = LPA_REG_READL(lpa, LPA_OBUF_MEMORY_CONTROL);
-	val = ((*((u32 *) bank)) << LPA_OBUF_MEM_CTL_PWRUP_SHFT) &
-	LPA_OBUF_MEM_CTL_PWRUP_BMSK;
-	val |= status;
-	LPA_REG_WRITEL(lpa, val, LPA_OBUF_MEMORY_CONTROL);
-}
-
-static void lpa_enable_interrupt(struct lpa_drv *lpa, u32 proc_id)
-{
-	u32 val;
-
-	proc_id &= LPA_OBUF_INTR_EN_BMSK;
-	val = 0x1 << proc_id;
-	LPA_REG_WRITEL(lpa, val, LPA_OBUF_INTR_ENABLE);
-}
-
-static void lpa_config_llb_addr(struct lpa_drv *lpa, u32 min_addr, u32 max_addr)
-{
-	u32 val;
-
-	val = (min_addr & LPA_OBUF_LLB_MIN_ADDR_SEG_BMSK) |
-	LPA_OBUF_LLB_MIN_ADDR_LOAD_BMSK;
-	LPA_REG_WRITEL(lpa, val, LPA_OBUF_LLB_MIN_ADDR);
-	val = max_addr & LPA_OBUF_LLB_MAX_ADDR_SEG_BMSK;
-	LPA_REG_WRITEL(lpa, val, LPA_OBUF_LLB_MAX_ADDR);
-}
-
-static void lpa_config_sb_addr(struct lpa_drv *lpa, u32 min_addr, u32 max_addr)
-{
-	u32 val;
-
-	val = (min_addr & LPA_OBUF_SB_MIN_ADDR_SEG_BMSK) |
-	LPA_OBUF_SB_MIN_ADDR_LOAD_BMSK;
-	LPA_REG_WRITEL(lpa, val, LPA_OBUF_SB_MIN_ADDR);
-	val = max_addr & LPA_OBUF_SB_MAX_ADDR_SEG_BMSK;
-	LPA_REG_WRITEL(lpa, val, LPA_OBUF_SB_MAX_ADDR);
-}
-
-static void lpa_switch_sb(struct lpa_drv *lpa)
-{
-	if (lpa->status & LPA_STATUS_SBUF_EN) {
-		lpa_config_llb_addr(lpa, lpa->sb_config.llb_min_addr,
-		lpa->sb_config.llb_max_addr);
-		lpa_config_sb_addr(lpa, lpa->sb_config.sb_min_addr,
-		lpa->sb_config.sb_max_addr);
-	} else {
-		lpa_config_llb_addr(lpa, lpa->nosb_config.llb_min_addr,
-		lpa->nosb_config.llb_max_addr);
-		lpa_config_sb_addr(lpa, lpa->nosb_config.sb_min_addr,
-		lpa->nosb_config.sb_max_addr);
-	}
-}
-
-static u8 lpa_req_wmark_id(struct lpa_drv *lpa)
-{
-  return (u8) (LPA_REG_READL(lpa, LPA_OBUF_WMARK_ASSIGN) &
-	LPA_OBUF_WMARK_ASSIGN_BMSK);
-}
-
-static void lpa_enable_llb_wmark(struct lpa_drv *lpa, u32 wmark_ctrl,
-	u32 wmark_id, u32 cpu_id)
-{
-	u32 val;
-
-	wmark_id = (wmark_id > 3) ? 0 : wmark_id;
-	val = LPA_REG_READL(lpa, LPA_OBUF_WMARK_n_LLB_ADDR(wmark_id));
-	val &= ~LPA_OBUF_LLB_WMARK_CTRL_BMSK;
-	val &= ~LPA_OBUF_LLB_WMARK_MAP_BMSK;
-	val |= (wmark_ctrl << LPA_OBUF_LLB_WMARK_CTRL_SHFT) &
-	LPA_OBUF_LLB_WMARK_CTRL_BMSK;
-	val |= (cpu_id << LPA_OBUF_LLB_WMARK_MAP_SHFT) &
-	LPA_OBUF_LLB_WMARK_MAP_BMSK;
-	LPA_REG_WRITEL(lpa, val, LPA_OBUF_WMARK_n_LLB_ADDR(wmark_id));
-}
-
-static void lpa_enable_sb_wmark(struct lpa_drv *lpa, u32 wmark_ctrl,
-	u32 cpu_id)
-{
-	u32 val;
-
-	val = LPA_REG_READL(lpa, LPA_OBUF_WMARK_SB);
-	val &= ~LPA_OBUF_SB_WMARK_CTRL_BMSK;
-	val &= ~LPA_OBUF_SB_WMARK_MAP_BMSK;
-	val |= (wmark_ctrl << LPA_OBUF_SB_WMARK_CTRL_SHFT) &
-	LPA_OBUF_SB_WMARK_CTRL_BMSK;
-	val |= (cpu_id << LPA_OBUF_SB_WMARK_MAP_SHFT) &
-	LPA_OBUF_SB_WMARK_MAP_BMSK;
-	LPA_REG_WRITEL(lpa, val, LPA_OBUF_WMARK_SB);
-}
-static void lpa_enable_hlb_wmark(struct lpa_drv *lpa, u32 wmark_ctrl,
-	u32 cpu_id)
-{
-	u32 val;
-
-	val = LPA_REG_READL(lpa, LPA_OBUF_WMARK_HLB);
-	val &= ~LPA_OBUF_HLB_WMARK_CTRL_BMSK;
-	val &= ~LPA_OBUF_HLB_WMARK_MAP_BMSK;
-	val |= (wmark_ctrl << LPA_OBUF_HLB_WMARK_CTRL_SHFT) &
-	LPA_OBUF_HLB_WMARK_CTRL_BMSK;
-	val |= (cpu_id << LPA_OBUF_HLB_WMARK_MAP_SHFT) &
-	LPA_OBUF_HLB_WMARK_MAP_BMSK;
-	LPA_REG_WRITEL(lpa, val, LPA_OBUF_WMARK_HLB);
-}
-
-static void lpa_enable_utc(struct lpa_drv *lpa, bool enable, u32 cpu_id)
-{
-	u32 val;
-
-	val = (cpu_id << LPA_OBUF_UTC_CONFIG_MAP_SHFT) &
-	LPA_OBUF_UTC_CONFIG_MAP_BMSK;
-	enable = (enable ? 1 : 0);
-	val = (enable << LPA_OBUF_UTC_CONFIG_EN_SHFT) &
-	LPA_OBUF_UTC_CONFIG_EN_BMSK;
-	LPA_REG_WRITEL(lpa, val, LPA_OBUF_UTC_CONFIG);
-}
-
-static void lpa_enable_mixing(struct lpa_drv *lpa, bool enable)
-{
-	u32 val;
-
-	val = LPA_REG_READL(lpa, LPA_OBUF_CONTROL);
-	val = (enable ? val | LPA_OBUF_CONTROL_LLB_EN_BMSK :
-		val & ~LPA_OBUF_CONTROL_LLB_EN_BMSK);
-	LPA_REG_WRITEL(lpa, val, LPA_OBUF_CONTROL);
-}
-
-static void lpa_enable_mixer_saturation(struct lpa_drv *lpa, u32 buf_id,
-	bool enable)
-{
-	u32 val;
-
-	val = LPA_REG_READL(lpa, LPA_OBUF_CONTROL);
-
-	switch (buf_id) {
-	case LPA_BUF_ID_LLB:
-		val = enable ? (val | LPA_OBUF_CONTROL_LLB_SAT_EN_BMSK) :
-		(val & ~LPA_OBUF_CONTROL_LLB_SAT_EN_BMSK);
-		break;
-
-	case LPA_BUF_ID_SB:
-		val = enable ? (val | LPA_OBUF_CONTROL_SB_SAT_EN_BMSK) :
-		(val & ~LPA_OBUF_CONTROL_SB_SAT_EN_BMSK);
-		break;
-	}
-
-	LPA_REG_WRITEL(lpa, val, LPA_OBUF_CONTROL);
-}
-
-static void lpa_enable_obuf(struct lpa_drv *lpa, u32 buf_id, bool enable)
-{
-	u32 val;
-
-	val = LPA_REG_READL(lpa, LPA_OBUF_CONTROL);
-
-	switch (buf_id) {
-	case LPA_BUF_ID_HLB:
-		val = enable ? (val | LPA_OBUF_CONTROL_HLB_EN_BMSK) :
-			(val & ~LPA_OBUF_CONTROL_HLB_EN_BMSK);
-		break;
-
-	case LPA_BUF_ID_LLB:
-		val = enable ? (val | LPA_OBUF_CONTROL_LLB_EN_BMSK) :
-		(val & ~LPA_OBUF_CONTROL_LLB_EN_BMSK);
-		break;
-
-	case LPA_BUF_ID_SB:
-		val = enable ? (val | LPA_OBUF_CONTROL_SB_EN_BMSK) :
-			(val & ~LPA_OBUF_CONTROL_SB_EN_BMSK);
-		break;
-	}
-	LPA_REG_WRITEL(lpa, val, LPA_OBUF_CONTROL);
-}
-
-struct lpa_drv *lpa_get(void)
-{
-	struct lpa_mem_bank_select mem_bank;
-	struct lpa_drv *ret_lpa = &the_lpa_state.lpa_drv;
-
-	mutex_lock(&the_lpa_state.lpa_lock);
-	if (the_lpa_state.assigned) {
-		MM_ERR("LPA HW accupied\n");
-		ret_lpa = ERR_PTR(-EBUSY);
-		goto error;
-	}
-	/* perform initialization */
-	lpa_reset(ret_lpa);
-	/* Config adec param */
-	/* Initialize LLB/SB min/max address */
-	lpa_switch_sb(ret_lpa);
-	/* Config HLB minx/max address */
-	lpa_config_hlb_addr(ret_lpa);
-
-	/* Power up all memory bank for now */
-	mem_bank.b0 = 1;
-	mem_bank.b1 = 1;
-	mem_bank.b2 = 1;
-	mem_bank.b3 = 1;
-	mem_bank.b4 = 1;
-	mem_bank.b5 = 1;
-	mem_bank.b6 = 1;
-	mem_bank.b7 = 1;
-	mem_bank.b8 = 1;
-	mem_bank.b9 = 1;
-	mem_bank.b10 = 1;
-	mem_bank.llb = 1;
-	lpa_powerup_mem_bank(ret_lpa, &mem_bank);
-
-	while
-	(lpa_req_wmark_id(ret_lpa) != LPA_OBUF_WMARK_ASSIGN_DONE);
-
-	lpa_enable_llb_wmark(ret_lpa, LPA_WMARK_CTL_DISABLED, 0,
-	ret_lpa->dsp_proc_id);
-	lpa_enable_llb_wmark(ret_lpa, LPA_WMARK_CTL_DISABLED, 1,
-	ret_lpa->dsp_proc_id);
-	lpa_enable_llb_wmark(ret_lpa, LPA_WMARK_CTL_DISABLED, 2,
-	ret_lpa->app_proc_id);
-	lpa_enable_llb_wmark(ret_lpa, LPA_WMARK_CTL_DISABLED, 3,
-	ret_lpa->app_proc_id);
-	lpa_enable_hlb_wmark(ret_lpa, LPA_WMARK_CTL_DISABLED,
-	ret_lpa->dsp_proc_id);
-	lpa_enable_sb_wmark(ret_lpa, LPA_WMARK_CTL_DISABLED,
-	ret_lpa->dsp_proc_id);
-	lpa_enable_utc(ret_lpa, 0, LPA_OBUF_UTC_CONFIG_NO_INTR);
-
-	lpa_enable_mixing(ret_lpa, 1);
-	lpa_enable_mixer_saturation(ret_lpa, LPA_BUF_ID_LLB, 1);
-
-	lpa_enable_obuf(ret_lpa, LPA_BUF_ID_HLB, 0);
-	lpa_enable_obuf(ret_lpa, LPA_BUF_ID_LLB, 1);
-	if (ret_lpa->status & LPA_STATUS_SBUF_EN) {
-		lpa_enable_mixer_saturation(ret_lpa, LPA_BUF_ID_SB, 1);
-		lpa_enable_obuf(ret_lpa, LPA_BUF_ID_SB, 1);
-	}
-
-	lpa_enable_interrupt(ret_lpa, ret_lpa->dsp_proc_id);
-	mb();
-	the_lpa_state.assigned++;
-error:
-	mutex_unlock(&the_lpa_state.lpa_lock);
-	return ret_lpa;
-}
-EXPORT_SYMBOL(lpa_get);
-
-void lpa_put(struct lpa_drv *lpa)
-{
-
-	mutex_lock(&the_lpa_state.lpa_lock);
-	if (!lpa || &the_lpa_state.lpa_drv != lpa) {
-		MM_ERR("invalid arg\n");
-		goto error;
-	}
-	/* Deinitialize */
-	the_lpa_state.assigned--;
-error:
-	mutex_unlock(&the_lpa_state.lpa_lock);
-}
-EXPORT_SYMBOL(lpa_put);
-
-int lpa_cmd_codec_config(struct lpa_drv *lpa,
-	struct lpa_codec_config *config_ptr)
-{
-	u32 sample_rate;
-	u32 num_channels;
-	u32 width;
-	u32 val = 0;
-
-	if (!lpa || !config_ptr) {
-		MM_ERR("invalid parameters\n");
-		return -EINVAL;
-	}
-
-	switch (config_ptr->num_channels) {
-	case 8:
-		num_channels = LPA_NUM_CHAN_7P1;
-		break;
-	case 6:
-		num_channels = LPA_NUM_CHAN_5P1;
-		break;
-	case 4:
-		num_channels = LPA_NUM_CHAN_4_CHANNEL;
-		break;
-	case 2:
-		num_channels = LPA_NUM_CHAN_STEREO;
-		break;
-	case 1:
-		num_channels = LPA_NUM_CHAN_MONO;
-		break;
-	default:
-		MM_ERR("unsupported number of channel\n");
-		goto error;
-	}
-	val |= (num_channels << LPA_OBUF_CODEC_NUM_CHAN_SHFT) &
-	LPA_OBUF_CODEC_NUM_CHAN_BMSK;
-
-	switch (config_ptr->sample_rate) {
-	case 96000:
-		sample_rate = LPA_SAMPLE_RATE_96KHZ;
-		break;
-	case 64000:
-		sample_rate = LPA_SAMPLE_RATE_64KHZ;
-		break;
-	case 48000:
-		sample_rate = LPA_SAMPLE_RATE_48KHZ;
-		break;
-	case 44100:
-		sample_rate = LPA_SAMPLE_RATE_44P1KHZ;
-		break;
-	case 32000:
-		sample_rate = LPA_SAMPLE_RATE_32KHZ;
-		break;
-	case 22050:
-		sample_rate = LPA_SAMPLE_RATE_22P05KHZ;
-		break;
-	case 16000:
-		sample_rate = LPA_SAMPLE_RATE_16KHZ;
-		break;
-	case 11025:
-		sample_rate = LPA_SAMPLE_RATE_11P025KHZ;
-		break;
-	case 8000:
-		sample_rate = LPA_SAMPLE_RATE_8KHZ;
-		break;
-	default:
-		MM_ERR("unsupported sample rate \n");
-		goto error;
-	}
-	val |= (sample_rate << LPA_OBUF_CODEC_SAMP_SHFT) &
-		LPA_OBUF_CODEC_SAMP_BMSK;
-	switch (config_ptr->sample_width) {
-	case 32:
-		width = LPA_BITS_PER_CHAN_32BITS;
-		break;
-	case 24:
-		width = LPA_BITS_PER_CHAN_24BITS;
-		break;
-	case 16:
-		width = LPA_BITS_PER_CHAN_16BITS;
-		break;
-	default:
-		MM_ERR("unsupported sample width \n");
-		goto error;
-	}
-	val |= (width << LPA_OBUF_CODEC_BITS_PER_CHAN_SHFT) &
-		LPA_OBUF_CODEC_BITS_PER_CHAN_BMSK;
-
-	val |= LPA_OBUF_CODEC_LOAD_BMSK;
-	val |= (config_ptr->output_interface << LPA_OBUF_CODEC_INTF_SHFT) &
-	LPA_OBUF_CODEC_INTF_BMSK;
-
-	LPA_REG_WRITEL(lpa, val, LPA_OBUF_CODEC);
-	mb();
-
-	return 0;
-error:
-	return -EINVAL;
-}
-EXPORT_SYMBOL(lpa_cmd_codec_config);
-
-static int lpa_check_llb_clear(struct lpa_drv *lpa)
-{
-	u32 val;
-	val = LPA_REG_READL(lpa, LPA_OBUF_STATUS);
-
-	return !(val & LPA_OBUF_STATUS_LLB_CLR_BMSK);
-}
-
-static void lpa_clear_llb(struct lpa_drv *lpa)
-{
-	u32 val;
-
-	val = LPA_REG_READL(lpa, LPA_OBUF_CONTROL);
-	LPA_REG_WRITEL(lpa, (val | LPA_OBUF_CONTROL_LLB_CLR_CMD_BMSK),
-	LPA_OBUF_CONTROL);
-	lpa_enable_obuf(lpa, LPA_BUF_ID_LLB, 0);
-
-	while (!lpa_check_llb_clear(lpa))
-		udelay(100);
-	LPA_REG_WRITEL(lpa, val, LPA_OBUF_CONTROL);
-}
-
-int lpa_cmd_enable_codec(struct lpa_drv *lpa, bool enable)
-{
-	u32 val;
-	struct lpa_mem_bank_select mem_bank;
-
-	MM_DBG(" %s\n", (enable ? "enable" : "disable"));
-
-	if (!lpa)
-		return -EINVAL;
-
-	val = LPA_REG_READL(lpa, LPA_OBUF_CODEC);
-
-	if (enable) {
-		if (val & LPA_OBUF_CODEC_CODEC_INTF_EN_BMSK)
-			return -EBUSY;
-		/* Power up all memory bank for now */
-		mem_bank.b0 = 1;
-		mem_bank.b1 = 1;
-		mem_bank.b2 = 1;
-		mem_bank.b3 = 1;
-		mem_bank.b4 = 1;
-		mem_bank.b5 = 1;
-		mem_bank.b6 = 1;
-		mem_bank.b7 = 1;
-		mem_bank.b8 = 1;
-		mem_bank.b9 = 1;
-		mem_bank.b10 = 1;
-		mem_bank.llb = 1;
-		lpa_powerup_mem_bank(lpa, &mem_bank);
-
-		/*clear LLB*/
-		lpa_clear_llb(lpa);
-
-		lpa_enable_codec(lpa, 1);
-		MM_DBG("LPA codec is enabled\n");
-	} else {
-		if (val & LPA_OBUF_CODEC_CODEC_INTF_EN_BMSK) {
-			lpa_enable_codec(lpa, 0);
-			MM_DBG("LPA codec is disabled\n");
-		} else
-			MM_ERR("LPA codec is already disable\n");
-	}
-	mb();
-	return 0;
-}
-EXPORT_SYMBOL(lpa_cmd_enable_codec);
-
-static int lpa_probe(struct platform_device *pdev)
-{
-	int rc = 0;
-	struct resource *mem_src;
-	struct msm_lpa_platform_data *pdata;
-
-	MM_INFO("lpa probe\n");
-
-	if (!pdev || !pdev->dev.platform_data) {
-		MM_ERR("no plaform data\n");
-		rc = -ENODEV;
-		goto error;
-	}
-
-	mem_src = platform_get_resource_byname(pdev, IORESOURCE_MEM, "lpa");
-	if (!mem_src) {
-		MM_ERR("LPA base address undefined\n");
-		rc = -ENODEV;
-		goto error;
-	}
-
-	pdata = pdev->dev.platform_data;
-	the_lpa_state.lpa_drv.baseaddr = ioremap(mem_src->start,
-	(mem_src->end - mem_src->start) + 1);
-	if (!the_lpa_state.lpa_drv.baseaddr) {
-		rc = -ENOMEM;
-		goto error;
-	}
-
-	the_lpa_state.lpa_drv.obuf_hlb_size = pdata->obuf_hlb_size;
-	the_lpa_state.lpa_drv.dsp_proc_id = pdata->dsp_proc_id;
-	the_lpa_state.lpa_drv.app_proc_id = pdata->app_proc_id;
-	the_lpa_state.lpa_drv.nosb_config = pdata->nosb_config;
-	the_lpa_state.lpa_drv.sb_config = pdata->sb_config;
-	/* default to enable summing buffer */
-	the_lpa_state.lpa_drv.status = LPA_STATUS_SBUF_EN;
-
-error:
-	return rc;
-
-}
-
-static int lpa_remove(struct platform_device *pdev)
-{
-	iounmap(the_lpa_state.lpa_drv.baseaddr);
-	return 0;
-}
-
-static struct platform_driver lpa_driver = {
-	.probe = lpa_probe,
-	.remove = lpa_remove,
-	.driver = {
-		.name = "lpa",
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init lpa_init(void)
-{
-	the_lpa_state.assigned = 0;
-	mutex_init(&the_lpa_state.lpa_lock);
-	return platform_driver_register(&lpa_driver);
-}
-
-static void __exit lpa_exit(void)
-{
-	platform_driver_unregister(&lpa_driver);
-}
-
-module_init(lpa_init);
-module_exit(lpa_exit);
-
-MODULE_DESCRIPTION("MSM LPA driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5v2/mi2s.c b/arch/arm/mach-msm/qdsp5v2/mi2s.c
deleted file mode 100644
index b649ec1..0000000
--- a/arch/arm/mach-msm/qdsp5v2/mi2s.c
+++ /dev/null
@@ -1,885 +0,0 @@
-/* Copyright (c) 2009,2011 The Linux Foundation. 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/mutex.h>
-#include <linux/platform_device.h>
-#include <linux/io.h>
-#include <linux/err.h>
-
-#include <mach/qdsp5v2/mi2s.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-
-#define DEBUG
-#ifdef DEBUG
-#define dprintk(format, arg...) \
-printk(KERN_DEBUG format, ## arg)
-#else
-#define dprintk(format, arg...) do {} while (0)
-#endif
-
-/*----------------------------------------------------------------------------
- * Preprocessor Definitions and Constants
- * -------------------------------------------------------------------------*/
-
-/* Device Types */
-#define HDMI 0
-#define CODEC_RX 1
-#define CODEC_TX 2
-
-/* Static offset for now. If different target have different
- * offset, update to platform data model
- */
-#define MI2S_RESET_OFFSET   0x0
-#define MI2S_MODE_OFFSET    0x4
-#define MI2S_TX_MODE_OFFSET 0x8
-#define MI2S_RX_MODE_OFFSET 0xc
-
-#define MI2S_SD_N_EN_MASK 0xF0
-#define MI2S_TX_RX_N_MASK 0x0F
-
-#define MI2S_RESET__MI2S_RESET__RESET  0x1
-#define MI2S_RESET__MI2S_RESET__ACTIVE 0x0
-#define MI2S_MODE__MI2S_MASTER__MASTER 0x1
-#define MI2S_MODE__MI2S_MASTER__SLAVE  0x0
-#define MI2S_MODE__MI2S_TX_RX_WORD_TYPE__16_BIT 0x1
-#define MI2S_MODE__MI2S_TX_RX_WORD_TYPE__24_BIT 0x2
-#define MI2S_MODE__MI2S_TX_RX_WORD_TYPE__32_BIT 0x3
-#define MI2S_TX_MODE__MI2S_TX_CODEC_16_MONO_MODE__RAW 0x0
-#define MI2S_TX_MODE__MI2S_TX_CODEC_16_MONO_MODE__PACKED 0x1
-#define MI2S_TX_MODE__MI2S_TX_STEREO_MODE__MONO_SAMPLE   0x0
-#define MI2S_TX_MODE__MI2S_TX_STEREO_MODE__STEREO_SAMPLE 0x1
-#define MI2S_TX_MODE__MI2S_TX_CH_TYPE__2_CHANNEL 0x0
-#define MI2S_TX_MODE__MI2S_TX_CH_TYPE__4_CHANNEL 0x1
-#define MI2S_TX_MODE__MI2S_TX_CH_TYPE__6_CHANNEL 0x2
-#define MI2S_TX_MODE__MI2S_TX_CH_TYPE__8_CHANNEL 0x3
-#define MI2S_TX_MODE__MI2S_TX_DMA_ACK_SYNCH_EN__SYNC_ENABLE 0x1
-#define MI2S_RX_MODE__MI2S_RX_CODEC_16_MONO_MODE__RAW 0x0
-#define MI2S_RX_MODE__MI2S_RX_CODEC_16_MONO_MODE__PACKED 0x1
-#define MI2S_RX_MODE__MI2S_RX_STEREO_MODE__MONO_SAMPLE   0x0
-#define MI2S_RX_MODE__MI2S_RX_STEREO_MODE__STEREO_SAMPLE 0x1
-#define MI2S_RX_MODE__MI2S_RX_CH_TYPE__2_CH 0x0
-#define MI2S_RX_MODE__MI2S_RX_DMA_ACK_SYNCH_EN__SYNC_ENABLE 0x1
-
-#define HWIO_AUDIO1_MI2S_MODE_MI2S_MASTER_BMSK				0x1000
-#define HWIO_AUDIO1_MI2S_MODE_MI2S_MASTER_SHFT				0xC
-#define HWIO_AUDIO1_MI2S_MODE_MI2S_TX_RX_WORD_TYPE_BMSK  		0x300
-#define HWIO_AUDIO1_MI2S_MODE_MI2S_TX_RX_WORD_TYPE_SHFT  		0x8
-#define HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_STEREO_MODE_BMSK		0x4
-#define HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_STEREO_MODE_SHFT		0x2
-#define HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_P_MONO_BMSK                    0x2
-#define HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_P_MONO_SHFT                    0x1
-#define HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_CH_TYPE_BMSK			0x18
-#define HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_CH_TYPE_SHFT			0x3
-#define HWIO_AUDIO1_MI2S_TX_MODE_MI2S_4_0_CH_MAP_BMSK			0x80
-#define HWIO_AUDIO1_MI2S_TX_MODE_MI2S_4_0_CH_MAP_SHFT			0x7
-#define HWIO_AUDIO1_MI2S_TX_MODE_MI2S_2_0_CH_MAP_BMSK			0x60
-#define HWIO_AUDIO1_MI2S_TX_MODE_MI2S_2_0_CH_MAP_SHFT			0x5
-#define HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_DMA_ACK_SYNCH_EN_BMSK		0x1
-#define HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_I2S_LINE_BMSK			0x60
-#define HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_I2S_LINE_SHFT			0x5
-#define HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_STEREO_MODE_BMSK		0x4
-#define HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_STEREO_MODE_SHFT		0x2
-#define HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_CODEC_P_MONO_BMSK              0x2
-#define HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_CODEC_P_MONO_SHFT              0x1
-#define HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_CH_TYPE_BMSK			0x18
-#define HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_CH_TYPE_SHFT			0x3
-#define HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_DMA_ACK_SYNCH_EN_BMSK		0x1
-
-/* Max number of channels */
-#define MAX_NUM_CHANNELS_OUT 8
-#define MAX_NUM_CHANNELS_IN  2
-
-/* Num of SD Lines */
-#define MAX_SD_LINES 4
-
-#define MI2S_SD_0_EN_MAP  0x10
-#define MI2S_SD_1_EN_MAP  0x20
-#define MI2S_SD_2_EN_MAP  0x40
-#define MI2S_SD_3_EN_MAP  0x80
-#define MI2S_SD_0_TX_MAP  0x01
-#define MI2S_SD_1_TX_MAP  0x02
-#define MI2S_SD_2_TX_MAP  0x04
-#define MI2S_SD_3_TX_MAP  0x08
-
-struct mi2s_state {
-	void __iomem *mi2s_hdmi_base;
-	void __iomem *mi2s_rx_base;
-	void __iomem *mi2s_tx_base;
-	struct mutex mutex_lock;
-
-};
-
-static struct mi2s_state the_mi2s_state;
-
-static void __iomem *get_base_addr(struct mi2s_state *mi2s, uint8_t dev_id)
-{
-	switch (dev_id) {
-	case HDMI:
-		return mi2s->mi2s_hdmi_base;
-	case CODEC_RX:
-		return mi2s->mi2s_rx_base;
-	case CODEC_TX:
-		return mi2s->mi2s_tx_base;
-	default:
-		break;
-	}
-	return ERR_PTR(-ENODEV);
-}
-
-static void mi2s_reset(struct mi2s_state *mi2s, uint8_t dev_id)
-{
-	void __iomem *baddr = get_base_addr(mi2s, dev_id);
-	if (!IS_ERR(baddr))
-		writel(MI2S_RESET__MI2S_RESET__RESET,
-		baddr + MI2S_RESET_OFFSET);
-}
-
-static void mi2s_release(struct mi2s_state *mi2s, uint8_t dev_id)
-{
-	void __iomem *baddr = get_base_addr(mi2s, dev_id);
-	if (!IS_ERR(baddr))
-		writel(MI2S_RESET__MI2S_RESET__ACTIVE,
-		baddr + MI2S_RESET_OFFSET);
-}
-
-static void mi2s_master(struct mi2s_state *mi2s, uint8_t dev_id, bool master)
-{
-	void __iomem *baddr = get_base_addr(mi2s, dev_id);
-	uint32_t val;
-	if (!IS_ERR(baddr)) {
-		val = readl(baddr + MI2S_MODE_OFFSET);
-		if (master) {
-			writel(
-			((val & ~HWIO_AUDIO1_MI2S_MODE_MI2S_MASTER_BMSK) |
-			 (MI2S_MODE__MI2S_MASTER__MASTER <<
-			  HWIO_AUDIO1_MI2S_MODE_MI2S_MASTER_SHFT)),
-			baddr + MI2S_MODE_OFFSET);
-		} else {
-			writel(
-			((val & ~HWIO_AUDIO1_MI2S_MODE_MI2S_MASTER_BMSK) |
-			 (MI2S_MODE__MI2S_MASTER__SLAVE <<
-			  HWIO_AUDIO1_MI2S_MODE_MI2S_MASTER_SHFT)),
-			baddr + MI2S_MODE_OFFSET);
-		}
-	}
-}
-
-static void mi2s_set_word_type(struct mi2s_state *mi2s, uint8_t dev_id,
-	uint8_t size)
-{
-	void __iomem *baddr = get_base_addr(mi2s, dev_id);
-	uint32_t val;
-	if (!IS_ERR(baddr)) {
-		val = readl(baddr + MI2S_MODE_OFFSET);
-		switch (size) {
-		case WT_16_BIT:
-			writel(
-			((val &
-			~HWIO_AUDIO1_MI2S_MODE_MI2S_TX_RX_WORD_TYPE_BMSK) |
-			(MI2S_MODE__MI2S_TX_RX_WORD_TYPE__16_BIT <<
-			HWIO_AUDIO1_MI2S_MODE_MI2S_TX_RX_WORD_TYPE_SHFT)),
-			baddr + MI2S_MODE_OFFSET);
-			break;
-		case WT_24_BIT:
-			writel(
-			((val &
-			~HWIO_AUDIO1_MI2S_MODE_MI2S_TX_RX_WORD_TYPE_BMSK) |
-			(MI2S_MODE__MI2S_TX_RX_WORD_TYPE__24_BIT <<
-			HWIO_AUDIO1_MI2S_MODE_MI2S_TX_RX_WORD_TYPE_SHFT)),
-			baddr + MI2S_MODE_OFFSET);
-			break;
-		case WT_32_BIT:
-			writel(
-			((val &
-			~HWIO_AUDIO1_MI2S_MODE_MI2S_TX_RX_WORD_TYPE_BMSK) |
-			(MI2S_MODE__MI2S_TX_RX_WORD_TYPE__32_BIT <<
-			HWIO_AUDIO1_MI2S_MODE_MI2S_TX_RX_WORD_TYPE_SHFT)),
-			baddr + MI2S_MODE_OFFSET);
-			break;
-		default:
-			break;
-		}
-	}
-}
-
-static void mi2s_set_sd(struct mi2s_state *mi2s, uint8_t dev_id, uint8_t sd_map)
-{
-	void __iomem *baddr = get_base_addr(mi2s, dev_id);
-	uint32_t val;
-	if (!IS_ERR(baddr)) {
-		val = readl(baddr + MI2S_MODE_OFFSET) &
-			~(MI2S_SD_N_EN_MASK | MI2S_TX_RX_N_MASK);
-		writel(val | sd_map, baddr + MI2S_MODE_OFFSET);
-	}
-}
-
-static void mi2s_set_output_num_channels(struct mi2s_state *mi2s,
-	uint8_t dev_id, uint8_t channels)
-{
-	void __iomem *baddr = get_base_addr(mi2s, dev_id);
-	uint32_t val;
-	if (!IS_ERR(baddr)) {
-		val = readl(baddr + MI2S_TX_MODE_OFFSET);
-		if (channels == MI2S_CHAN_MONO_RAW) {
-			val = (val &
-			~(HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_STEREO_MODE_BMSK |
-			HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_P_MONO_BMSK)) |
-			((MI2S_TX_MODE__MI2S_TX_STEREO_MODE__MONO_SAMPLE <<
-			HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_STEREO_MODE_SHFT) |
-			(MI2S_TX_MODE__MI2S_TX_CODEC_16_MONO_MODE__RAW <<
-			HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_P_MONO_SHFT));
-		} else if (channels == MI2S_CHAN_MONO_PACKED) {
-			val = (val &
-			~(HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_STEREO_MODE_BMSK |
-			HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_P_MONO_BMSK)) |
-			((MI2S_TX_MODE__MI2S_TX_STEREO_MODE__MONO_SAMPLE <<
-			HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_STEREO_MODE_SHFT) |
-			(MI2S_TX_MODE__MI2S_TX_CODEC_16_MONO_MODE__PACKED <<
-			HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_P_MONO_SHFT));
-		} else if (channels == MI2S_CHAN_STEREO) {
-			val = (val &
-			~(HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_STEREO_MODE_BMSK |
-			HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_CH_TYPE_BMSK)) |
-			((MI2S_TX_MODE__MI2S_TX_STEREO_MODE__STEREO_SAMPLE <<
-			HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_STEREO_MODE_SHFT) |
-			(MI2S_TX_MODE__MI2S_TX_CH_TYPE__2_CHANNEL <<
-			HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_CH_TYPE_SHFT));
-		} else if (channels == MI2S_CHAN_4CHANNELS) {
-			val = (val &
-			~(HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_STEREO_MODE_BMSK |
-			HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_CH_TYPE_BMSK)) |
-			((MI2S_TX_MODE__MI2S_TX_STEREO_MODE__STEREO_SAMPLE <<
-			HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_STEREO_MODE_SHFT) |
-			(MI2S_TX_MODE__MI2S_TX_CH_TYPE__4_CHANNEL <<
-			HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_CH_TYPE_SHFT));
-		} else if (channels == MI2S_CHAN_6CHANNELS) {
-			val = (val &
-			~(HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_STEREO_MODE_BMSK |
-			HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_CH_TYPE_BMSK)) |
-			((MI2S_TX_MODE__MI2S_TX_STEREO_MODE__STEREO_SAMPLE <<
-			HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_STEREO_MODE_SHFT) |
-			(MI2S_TX_MODE__MI2S_TX_CH_TYPE__6_CHANNEL <<
-			HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_CH_TYPE_SHFT));
-		} else if (channels == MI2S_CHAN_8CHANNELS) {
-			val = (val &
-			~(HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_STEREO_MODE_BMSK |
-			HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_CH_TYPE_BMSK)) |
-			((MI2S_TX_MODE__MI2S_TX_STEREO_MODE__STEREO_SAMPLE <<
-			HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_STEREO_MODE_SHFT) |
-			(MI2S_TX_MODE__MI2S_TX_CH_TYPE__8_CHANNEL <<
-			HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_CH_TYPE_SHFT));
-		}
-		writel(val, baddr + MI2S_TX_MODE_OFFSET);
-	}
-}
-
-static void mi2s_set_output_4ch_map(struct mi2s_state *mi2s, uint8_t dev_id,
-	bool high_low)
-{
-	void __iomem *baddr = get_base_addr(mi2s, dev_id);
-	uint32_t val;
-	if (!IS_ERR(baddr)) {
-		val = readl(baddr + MI2S_TX_MODE_OFFSET);
-		val = (val & ~HWIO_AUDIO1_MI2S_TX_MODE_MI2S_4_0_CH_MAP_BMSK) |
-			(high_low <<
-			HWIO_AUDIO1_MI2S_TX_MODE_MI2S_4_0_CH_MAP_SHFT);
-		writel(val, baddr + MI2S_TX_MODE_OFFSET);
-	}
-}
-
-static void mi2s_set_output_2ch_map(struct mi2s_state *mi2s, uint8_t dev_id,
-	uint8_t sd_line)
-{
-	void __iomem *baddr = get_base_addr(mi2s, dev_id);
-	uint32_t val;
-
-	if (!IS_ERR(baddr)) {
-		val = readl(baddr + MI2S_TX_MODE_OFFSET);
-		if (sd_line < 4) {
-			val = (val &
-			~HWIO_AUDIO1_MI2S_TX_MODE_MI2S_2_0_CH_MAP_BMSK) |
-			(sd_line <<
-			HWIO_AUDIO1_MI2S_TX_MODE_MI2S_2_0_CH_MAP_SHFT);
-			writel(val, baddr + MI2S_TX_MODE_OFFSET);
-		}
-	}
-}
-
-static void mi2s_set_output_clk_synch(struct mi2s_state *mi2s, uint8_t dev_id)
-{
-	void __iomem *baddr = get_base_addr(mi2s, dev_id);
-	uint32_t val;
-
-	if (!IS_ERR(baddr)) {
-		val = readl(baddr + MI2S_TX_MODE_OFFSET);
-		writel(((val &
-		~HWIO_AUDIO1_MI2S_TX_MODE_MI2S_TX_DMA_ACK_SYNCH_EN_BMSK) |
-		MI2S_TX_MODE__MI2S_TX_DMA_ACK_SYNCH_EN__SYNC_ENABLE),
-		baddr + MI2S_TX_MODE_OFFSET);
-	}
-}
-
-static void mi2s_set_input_sd_line(struct mi2s_state *mi2s, uint8_t dev_id,
-	uint8_t sd_line)
-{
-	void __iomem *baddr = get_base_addr(mi2s, dev_id);
-	uint32_t val;
-
-	if (!IS_ERR(baddr)) {
-		val = readl(baddr + MI2S_RX_MODE_OFFSET);
-		if (sd_line < 4) {
-			val = (val &
-			~HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_I2S_LINE_BMSK) |
-			(sd_line <<
-			HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_I2S_LINE_SHFT);
-			writel(val, baddr + MI2S_RX_MODE_OFFSET);
-		}
-	}
-}
-
-static void mi2s_set_input_num_channels(struct mi2s_state *mi2s, uint8_t dev_id,
-	uint8_t channels)
-{
-	void __iomem *baddr = get_base_addr(mi2s, dev_id);
-	uint32_t val;
-
-	if (!IS_ERR(baddr)) {
-		val = readl(baddr + MI2S_RX_MODE_OFFSET);
-		if (channels == MI2S_CHAN_MONO_RAW) {
-			val = (val &
-			~(HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_STEREO_MODE_BMSK |
-			HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_CODEC_P_MONO_BMSK)) |
-			((MI2S_RX_MODE__MI2S_RX_STEREO_MODE__MONO_SAMPLE <<
-			HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_STEREO_MODE_SHFT) |
-			(MI2S_RX_MODE__MI2S_RX_CODEC_16_MONO_MODE__RAW <<
-			HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_CODEC_P_MONO_SHFT));
-		} else if (channels == MI2S_CHAN_MONO_PACKED) {
-			val = (val &
-			~(HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_STEREO_MODE_BMSK |
-			HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_CODEC_P_MONO_BMSK)) |
-			((MI2S_RX_MODE__MI2S_RX_STEREO_MODE__MONO_SAMPLE <<
-			HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_STEREO_MODE_SHFT) |
-			(MI2S_RX_MODE__MI2S_RX_CODEC_16_MONO_MODE__PACKED <<
-			HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_CODEC_P_MONO_SHFT));
-		} else if (channels == MI2S_CHAN_STEREO) {
-
-			if (dev_id == HDMI)
-				val = (val &
-			~(HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_STEREO_MODE_BMSK |
-			HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_CH_TYPE_BMSK)) |
-			((MI2S_RX_MODE__MI2S_RX_STEREO_MODE__STEREO_SAMPLE <<
-			HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_STEREO_MODE_SHFT) |
-			(MI2S_RX_MODE__MI2S_RX_CH_TYPE__2_CH <<
-			HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_CH_TYPE_SHFT));
-
-			else
-				val = (val &
-			~(HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_STEREO_MODE_BMSK |
-			HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_CH_TYPE_BMSK)) |
-			((MI2S_RX_MODE__MI2S_RX_STEREO_MODE__STEREO_SAMPLE <<
-			HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_STEREO_MODE_SHFT) |
-			(MI2S_RX_MODE__MI2S_RX_CODEC_16_MONO_MODE__PACKED <<
-			HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_CODEC_P_MONO_SHFT) |
-			(MI2S_RX_MODE__MI2S_RX_CH_TYPE__2_CH <<
-			HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_CH_TYPE_SHFT));
-
-
-		}
-		writel(val, baddr + MI2S_RX_MODE_OFFSET);
-	}
-}
-
-static void mi2s_set_input_clk_synch(struct mi2s_state *mi2s, uint8_t dev_id)
-{
-	void __iomem *baddr = get_base_addr(mi2s, dev_id);
-	uint32_t val;
-
-	if (!IS_ERR(baddr)) {
-		val = readl(baddr + MI2S_RX_MODE_OFFSET);
-		writel(
-		((val &
-		~HWIO_AUDIO1_MI2S_RX_MODE_MI2S_RX_DMA_ACK_SYNCH_EN_BMSK) |
-		MI2S_RX_MODE__MI2S_RX_DMA_ACK_SYNCH_EN__SYNC_ENABLE),
-		baddr + MI2S_RX_MODE_OFFSET);
-	}
-}
-
-
-static u8 num_of_bits_set(u8 sd_line_mask)
-{
-	u8 num_bits_set = 0;
-
-	while (sd_line_mask) {
-
-		if (sd_line_mask & 1)
-			num_bits_set++;
-		sd_line_mask = sd_line_mask >> 1;
-	}
-	return num_bits_set;
-}
-
-
-bool mi2s_set_hdmi_output_path(uint8_t channels, uint8_t size,
-		uint8_t sd_line_mask)
-{
-	bool ret_val = MI2S_TRUE;
-	struct mi2s_state *mi2s = &the_mi2s_state;
-	u8 sd_line, num_of_sd_lines = 0;
-	void __iomem *baddr;
-	uint32_t val;
-
-	pr_debug("%s: channels = %u size = %u sd_line_mask = 0x%x\n", __func__,
-		channels, size, sd_line_mask);
-
-	if ((channels == 0) ||  (channels > MAX_NUM_CHANNELS_OUT) ||
-		((channels != 1) && (channels % 2 != 0))) {
-
-		pr_err("%s: invalid number of channels. channels = %u\n",
-				__func__, channels);
-		return  MI2S_FALSE;
-	}
-
-	sd_line_mask &=  MI2S_SD_LINE_MASK;
-
-	if (!sd_line_mask) {
-		pr_err("%s: Did not set any data lines to use "
-			" sd_line_mask =0x%x\n", __func__, sd_line_mask);
-		return  MI2S_FALSE;
-	}
-
-	mutex_lock(&mi2s->mutex_lock);
-	/* Put device in reset */
-	mi2s_reset(mi2s, HDMI);
-
-	mi2s_master(mi2s, HDMI, 1);
-
-	/* Set word type */
-	if (size <= WT_MAX)
-		mi2s_set_word_type(mi2s, HDMI, size);
-	else
-		ret_val = MI2S_FALSE;
-
-	/* Enable clock crossing synchronization of RD DMA ACK */
-	mi2s_set_output_clk_synch(mi2s, HDMI);
-
-	mi2s_set_output_num_channels(mi2s, HDMI, channels);
-
-	num_of_sd_lines = num_of_bits_set(sd_line_mask);
-	/*Second argument to find_first_bit should be maximum number of
-	bit*/
-
-	sd_line = find_first_bit((unsigned long *)&sd_line_mask,
-			sizeof(sd_line_mask) * 8);
-	pr_debug("sd_line = %d\n", sd_line);
-
-	if (channels == 1) {
-
-		if (num_of_sd_lines != 1) {
-			pr_err("%s: for one channel only one SD lines is"
-				" needed. num_of_sd_lines = %u\n",
-				__func__, num_of_sd_lines);
-
-			ret_val = MI2S_FALSE;
-			goto error;
-		}
-
-		if (sd_line != 0) {
-			pr_err("%s: for one channel tx, need to use SD_0 "
-					"sd_line = %u\n", __func__, sd_line);
-
-			ret_val = MI2S_FALSE;
-			goto error;
-		}
-
-		/* Enable SD line 0 for Tx (only option for
-			 * mono audio)
-		 */
-		mi2s_set_sd(mi2s, HDMI, MI2S_SD_0_EN_MAP | MI2S_SD_0_TX_MAP);
-
-	} else if (channels == 2) {
-
-		if (num_of_sd_lines != 1) {
-			pr_err("%s: for two channel only one SD lines is"
-				" needed. num_of_sd_lines = %u\n",
-				__func__, num_of_sd_lines);
-			ret_val = MI2S_FALSE;
-			goto error;
-		}
-
-		/* Enable single SD line for Tx */
-		mi2s_set_sd(mi2s, HDMI, (MI2S_SD_0_EN_MAP << sd_line) |
-				(MI2S_SD_0_TX_MAP << sd_line));
-
-		/* Set 2-channel mapping */
-		mi2s_set_output_2ch_map(mi2s, HDMI, sd_line);
-
-	} else if (channels == 4) {
-
-		if (num_of_sd_lines != 2) {
-			pr_err("%s: for 4 channels two SD lines are"
-				" needed. num_of_sd_lines = %u\\n",
-				__func__, num_of_sd_lines);
-			ret_val = MI2S_FALSE;
-			goto error;
-		}
-
-		if ((sd_line_mask && MI2S_SD_0) &&
-				(sd_line_mask && MI2S_SD_1)) {
-
-			mi2s_set_sd(mi2s, HDMI, (MI2S_SD_0_EN_MAP |
-				MI2S_SD_1_EN_MAP) | (MI2S_SD_0_TX_MAP |
-				MI2S_SD_1_TX_MAP));
-			mi2s_set_output_4ch_map(mi2s, HDMI, MI2S_FALSE);
-
-		} else if ((sd_line_mask && MI2S_SD_2) &&
-				(sd_line_mask && MI2S_SD_3)) {
-
-			mi2s_set_sd(mi2s, HDMI, (MI2S_SD_2_EN_MAP |
-				MI2S_SD_3_EN_MAP) | (MI2S_SD_2_TX_MAP |
-				MI2S_SD_3_TX_MAP));
-
-			mi2s_set_output_4ch_map(mi2s, HDMI, MI2S_TRUE);
-		} else {
-
-			pr_err("%s: for 4 channels invalid SD lines usage"
-				" sd_line_mask = 0x%x\n",
-				__func__, sd_line_mask);
-			ret_val = MI2S_FALSE;
-			goto error;
-		}
-	} else if (channels == 6) {
-
-		if (num_of_sd_lines != 3) {
-			pr_err("%s: for 6 channels three SD lines are"
-				" needed. num_of_sd_lines = %u\n",
-				__func__, num_of_sd_lines);
-			ret_val = MI2S_FALSE;
-			goto error;
-		}
-
-		if ((sd_line_mask && MI2S_SD_0) &&
-			(sd_line_mask && MI2S_SD_1) &&
-			(sd_line_mask && MI2S_SD_2)) {
-
-			mi2s_set_sd(mi2s, HDMI, (MI2S_SD_0_EN_MAP |
-				MI2S_SD_1_EN_MAP | MI2S_SD_2_EN_MAP) |
-				(MI2S_SD_0_TX_MAP | MI2S_SD_1_TX_MAP |
-				MI2S_SD_2_TX_MAP));
-
-		} else if ((sd_line_mask && MI2S_SD_1) &&
-				(sd_line_mask && MI2S_SD_2) &&
-				(sd_line_mask && MI2S_SD_3)) {
-
-			mi2s_set_sd(mi2s, HDMI, (MI2S_SD_1_EN_MAP |
-				MI2S_SD_2_EN_MAP | MI2S_SD_3_EN_MAP) |
-				(MI2S_SD_1_TX_MAP | MI2S_SD_2_TX_MAP |
-				MI2S_SD_3_TX_MAP));
-
-		} else {
-
-			pr_err("%s: for 6 channels invalid SD lines usage"
-				" sd_line_mask = 0x%x\n",
-				__func__, sd_line_mask);
-			ret_val = MI2S_FALSE;
-			goto error;
-		}
-	} else if (channels == 8) {
-
-		if (num_of_sd_lines != 4) {
-			pr_err("%s: for 8 channels four SD lines are"
-				" needed. num_of_sd_lines = %u\n",
-				__func__, num_of_sd_lines);
-			ret_val = MI2S_FALSE;
-			goto error;
-		}
-
-		mi2s_set_sd(mi2s, HDMI, (MI2S_SD_0_EN_MAP |
-			MI2S_SD_1_EN_MAP | MI2S_SD_2_EN_MAP |
-			MI2S_SD_3_EN_MAP) | (MI2S_SD_0_TX_MAP |
-			MI2S_SD_1_TX_MAP | MI2S_SD_2_TX_MAP |
-			MI2S_SD_3_TX_MAP));
-	} else {
-		pr_err("%s: invalid number channels = %u\n",
-				__func__, channels);
-			ret_val = MI2S_FALSE;
-			goto error;
-	}
-
-	baddr = get_base_addr(mi2s, HDMI);
-
-	val = readl(baddr + MI2S_MODE_OFFSET);
-	pr_debug("%s(): MI2S_MODE = 0x%x\n", __func__, val);
-
-	val = readl(baddr + MI2S_TX_MODE_OFFSET);
-	pr_debug("%s(): MI2S_TX_MODE = 0x%x\n", __func__, val);
-
-
-error:
-	/* Release device from reset */
-	mi2s_release(mi2s, HDMI);
-
-	mutex_unlock(&mi2s->mutex_lock);
-	mb();
-	return ret_val;
-}
-EXPORT_SYMBOL(mi2s_set_hdmi_output_path);
-
-bool mi2s_set_hdmi_input_path(uint8_t channels, uint8_t size,
-		uint8_t sd_line_mask)
-{
-	bool ret_val = MI2S_TRUE;
-	struct mi2s_state *mi2s = &the_mi2s_state;
-	u8 sd_line, num_of_sd_lines = 0;
-	void __iomem *baddr;
-	uint32_t val;
-
-	pr_debug("%s: channels = %u size = %u sd_line_mask = 0x%x\n", __func__,
-		channels, size, sd_line_mask);
-
-	if ((channels != 1) && (channels != MAX_NUM_CHANNELS_IN)) {
-
-		pr_err("%s: invalid number of channels. channels = %u\n",
-				__func__, channels);
-		return  MI2S_FALSE;
-	}
-
-	if (size > WT_MAX) {
-
-		pr_err("%s: mi2s word size can not be greater than 32 bits\n",
-				__func__);
-		return MI2S_FALSE;
-	}
-
-	sd_line_mask &=  MI2S_SD_LINE_MASK;
-
-	if (!sd_line_mask) {
-		pr_err("%s: Did not set any data lines to use "
-			" sd_line_mask =0x%x\n", __func__, sd_line_mask);
-		return  MI2S_FALSE;
-	}
-
-	num_of_sd_lines = num_of_bits_set(sd_line_mask);
-
-	if (num_of_sd_lines != 1) {
-		pr_err("%s: for two channel input only one SD lines is"
-			" needed. num_of_sd_lines = %u sd_line_mask = 0x%x\n",
-			__func__, num_of_sd_lines, sd_line_mask);
-		return MI2S_FALSE;
-	}
-
-	/*Second argument to find_first_bit should be maximum number of
-	bits interested*/
-	sd_line = find_first_bit((unsigned long *)&sd_line_mask,
-			sizeof(sd_line_mask) * 8);
-	pr_debug("sd_line = %d\n", sd_line);
-
-	/* Ensure sd_line parameter is valid (0-max) */
-	if (sd_line > MAX_SD_LINES) {
-		pr_err("%s: Line number can not be greater than = %u\n",
-			__func__, MAX_SD_LINES);
-		return MI2S_FALSE;
-	}
-
-	mutex_lock(&mi2s->mutex_lock);
-	/* Put device in reset */
-	mi2s_reset(mi2s, HDMI);
-
-	mi2s_master(mi2s, HDMI, 1);
-
-	/* Set word type */
-	mi2s_set_word_type(mi2s, HDMI, size);
-
-	/* Enable clock crossing synchronization of WR DMA ACK */
-	mi2s_set_input_clk_synch(mi2s, HDMI);
-
-	/* Ensure channels parameter is valid (non-zero, less than max,
-	 * and even or mono)
-	 */
-	mi2s_set_input_num_channels(mi2s, HDMI, channels);
-
-	mi2s_set_input_sd_line(mi2s, HDMI, sd_line);
-
-	mi2s_set_sd(mi2s, HDMI, (MI2S_SD_0_EN_MAP << sd_line));
-
-	baddr = get_base_addr(mi2s, HDMI);
-
-	val = readl(baddr + MI2S_MODE_OFFSET);
-	pr_debug("%s(): MI2S_MODE = 0x%x\n", __func__, val);
-
-	val = readl(baddr + MI2S_RX_MODE_OFFSET);
-	pr_debug("%s(): MI2S_RX_MODE = 0x%x\n", __func__, val);
-
-	/* Release device from reset */
-	mi2s_release(mi2s, HDMI);
-
-	mutex_unlock(&mi2s->mutex_lock);
-	mb();
-	return ret_val;
-}
-EXPORT_SYMBOL(mi2s_set_hdmi_input_path);
-
-bool mi2s_set_codec_output_path(uint8_t channels, uint8_t size)
-{
-	bool ret_val = MI2S_TRUE;
-	struct mi2s_state *mi2s = &the_mi2s_state;
-
-	mutex_lock(&mi2s->mutex_lock);
-	/* Put device in reset */
-	mi2s_reset(mi2s, CODEC_TX);
-
-	mi2s_master(mi2s, CODEC_TX, 1);
-
-	/* Enable clock crossing synchronization of RD DMA ACK */
-	mi2s_set_output_clk_synch(mi2s, CODEC_TX);
-
-	/* Set word type */
-	if (size <= WT_MAX)
-		mi2s_set_word_type(mi2s, CODEC_TX, size);
-	else
-		ret_val = MI2S_FALSE;
-
-	mi2s_set_output_num_channels(mi2s, CODEC_TX, channels);
-
-	/* Enable SD line */
-	mi2s_set_sd(mi2s, CODEC_TX, MI2S_SD_0_EN_MAP | MI2S_SD_0_TX_MAP);
-
-	/* Release device from reset */
-	mi2s_release(mi2s, CODEC_TX);
-
-	mutex_unlock(&mi2s->mutex_lock);
-	mb();
-	return ret_val;
-}
-EXPORT_SYMBOL(mi2s_set_codec_output_path);
-
-bool mi2s_set_codec_input_path(uint8_t channels, uint8_t size)
-{
-	bool ret_val = MI2S_TRUE;
-	struct mi2s_state *mi2s = &the_mi2s_state;
-
-	mutex_lock(&the_mi2s_state.mutex_lock);
-	/* Put device in reset */
-	mi2s_reset(mi2s, CODEC_RX);
-
-	mi2s_master(mi2s, CODEC_RX, 1);
-
-	/* Enable clock crossing synchronization of WR DMA ACK */
-	mi2s_set_input_clk_synch(mi2s, CODEC_RX);
-
-	/* Set word type */
-	if (size <= WT_MAX)
-		mi2s_set_word_type(mi2s, CODEC_RX, size);
-	else
-		ret_val = MI2S_FALSE;
-
-	mi2s_set_input_num_channels(mi2s, CODEC_RX, channels);
-
-	/* Enable SD line */
-	mi2s_set_sd(mi2s, CODEC_RX, MI2S_SD_0_EN_MAP);
-
-	/* Release device from reset */
-	mi2s_release(mi2s, CODEC_RX);
-
-	mutex_unlock(&mi2s->mutex_lock);
-	mb();
-	return ret_val;
-}
-EXPORT_SYMBOL(mi2s_set_codec_input_path);
-
-
-static int mi2s_probe(struct platform_device *pdev)
-{
-	int rc = 0;
-	struct resource *mem_src;
-
-	mem_src = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hdmi");
-	if (!mem_src) {
-		rc = -ENODEV;
-		goto error_hdmi;
-	}
-	the_mi2s_state.mi2s_hdmi_base = ioremap(mem_src->start,
-		(mem_src->end - mem_src->start) + 1);
-	if (!the_mi2s_state.mi2s_hdmi_base) {
-		rc = -ENOMEM;
-		goto error_hdmi;
-	}
-	mem_src = platform_get_resource_byname(pdev,
-		IORESOURCE_MEM, "codec_rx");
-	if (!mem_src) {
-		rc = -ENODEV;
-		goto error_codec_rx;
-	}
-	the_mi2s_state.mi2s_rx_base = ioremap(mem_src->start,
-		(mem_src->end - mem_src->start) + 1);
-	if (!the_mi2s_state.mi2s_rx_base) {
-		rc = -ENOMEM;
-		goto error_codec_rx;
-	}
-	mem_src = platform_get_resource_byname(pdev,
-		IORESOURCE_MEM, "codec_tx");
-	if (!mem_src) {
-		rc = -ENODEV;
-		goto error_codec_tx;
-	}
-	the_mi2s_state.mi2s_tx_base = ioremap(mem_src->start,
-		(mem_src->end - mem_src->start) + 1);
-	if (!the_mi2s_state.mi2s_tx_base) {
-		rc = -ENOMEM;
-		goto error_codec_tx;
-	}
-	mutex_init(&the_mi2s_state.mutex_lock);
-
-	return rc;
-
-error_codec_tx:
-	iounmap(the_mi2s_state.mi2s_rx_base);
-error_codec_rx:
-	iounmap(the_mi2s_state.mi2s_hdmi_base);
-error_hdmi:
-	return rc;
-
-}
-
-static int mi2s_remove(struct platform_device *pdev)
-{
-	iounmap(the_mi2s_state.mi2s_tx_base);
-	iounmap(the_mi2s_state.mi2s_rx_base);
-	iounmap(the_mi2s_state.mi2s_hdmi_base);
-	return 0;
-}
-
-static struct platform_driver mi2s_driver = {
-	.probe = mi2s_probe,
-	.remove = mi2s_remove,
-	.driver = {
-		.name = "mi2s",
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init mi2s_init(void)
-{
-	return platform_driver_register(&mi2s_driver);
-}
-
-static void __exit mi2s_exit(void)
-{
-	platform_driver_unregister(&mi2s_driver);
-}
-
-module_init(mi2s_init);
-module_exit(mi2s_exit);
-
-MODULE_DESCRIPTION("MSM MI2S driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5v2/mp3_funcs.c b/arch/arm/mach-msm/qdsp5v2/mp3_funcs.c
deleted file mode 100644
index f857e5c..0000000
--- a/arch/arm/mach-msm/qdsp5v2/mp3_funcs.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/* Copyright (c) 2010, The Linux Foundation. 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.
- */
-
-#include <linux/fs.h>
-#include <linux/uaccess.h>
-#include <linux/wait.h>
-
-#include <linux/msm_audio.h>
-
-#include <mach/qdsp5v2/qdsp5audppmsg.h>
-#include <mach/qdsp5v2/qdsp5audplaycmdi.h>
-#include <mach/qdsp5v2/qdsp5audplaymsg.h>
-#include <mach/qdsp5v2/audpp.h>
-#include <mach/qdsp5v2/codec_utils.h>
-#include <mach/qdsp5v2/mp3_funcs.h>
-#include <mach/debug_mm.h>
-
-long mp3_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	MM_DBG("mp3_ioctl() cmd = %d\b", cmd);
-
-	return -EINVAL;
-}
-
-void audpp_cmd_cfg_mp3_params(struct audio *audio)
-{
-	struct audpp_cmd_cfg_adec_params_mp3 cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_CMD_CFG_ADEC_PARAMS;
-	cmd.common.length = AUDPP_CMD_CFG_ADEC_PARAMS_MP3_LEN;
-	cmd.common.dec_id = audio->dec_id;
-	cmd.common.input_sampling_frequency = audio->out_sample_rate;
-
-	audpp_send_queue2(&cmd, sizeof(cmd));
-}
diff --git a/arch/arm/mach-msm/qdsp5v2/pcm_funcs.c b/arch/arm/mach-msm/qdsp5v2/pcm_funcs.c
deleted file mode 100644
index 866b71d..0000000
--- a/arch/arm/mach-msm/qdsp5v2/pcm_funcs.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/* Copyright (c) 2010, The Linux Foundation. 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.
- */
-
-#include <linux/fs.h>
-#include <linux/uaccess.h>
-#include <linux/wait.h>
-
-#include <linux/msm_audio.h>
-
-#include <mach/qdsp5v2/qdsp5audppmsg.h>
-#include <mach/qdsp5v2/qdsp5audplaycmdi.h>
-#include <mach/qdsp5v2/qdsp5audplaymsg.h>
-#include <mach/qdsp5v2/audpp.h>
-#include <mach/qdsp5v2/codec_utils.h>
-#include <mach/qdsp5v2/pcm_funcs.h>
-#include <mach/debug_mm.h>
-
-long pcm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	MM_DBG("pcm_ioctl() cmd = %d\n", cmd);
-
-	return -EINVAL;
-}
-
-void audpp_cmd_cfg_pcm_params(struct audio *audio)
-{
-	struct audpp_cmd_cfg_adec_params_wav cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.common.cmd_id = AUDPP_CMD_CFG_ADEC_PARAMS;
-	cmd.common.length = AUDPP_CMD_CFG_ADEC_PARAMS_WAV_LEN >> 1;
-	cmd.common.dec_id = audio->dec_id;
-	cmd.common.input_sampling_frequency = audio->out_sample_rate;
-	cmd.stereo_cfg = audio->out_channel_mode;
-	cmd.pcm_width = audio->out_bits;
-	cmd.sign = 0;
-	audpp_send_queue2(&cmd, sizeof(cmd));
-}
diff --git a/arch/arm/mach-msm/qdsp5v2/snddev_data_marimba.c b/arch/arm/mach-msm/qdsp5v2/snddev_data_marimba.c
deleted file mode 100644
index b11cdb0..0000000
--- a/arch/arm/mach-msm/qdsp5v2/snddev_data_marimba.c
+++ /dev/null
@@ -1,1537 +0,0 @@
-/* Copyright (c) 2009-2011, The Linux Foundation. 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.
- *
- */
-#include <linux/platform_device.h>
-#include <linux/debugfs.h>
-#include <linux/mfd/msm-adie-codec.h>
-#include <linux/uaccess.h>
-#include <mach/qdsp5v2/snddev_icodec.h>
-#include <mach/qdsp5v2/marimba_profile.h>
-#include <mach/qdsp5v2/aux_pcm.h>
-#include <mach/qdsp5v2/snddev_ecodec.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/qdsp5v2/snddev_virtual.h>
-#include <mach/board.h>
-#include <asm/mach-types.h>
-#include <mach/gpio.h>
-#include <mach/qdsp5v2/snddev_mi2s.h>
-#include <mach/qdsp5v2/mi2s.h>
-#include <mach/qdsp5v2/audio_acdb_def.h>
-
-/* define the value for BT_SCO */
-#define BT_SCO_PCM_CTL_VAL (PCM_CTL__RPCM_WIDTH__LINEAR_V |\
-				PCM_CTL__TPCM_WIDTH__LINEAR_V)
-#define BT_SCO_DATA_FORMAT_PADDING (DATA_FORMAT_PADDING_INFO__RPCM_FORMAT_V |\
-				DATA_FORMAT_PADDING_INFO__TPCM_FORMAT_V)
-#define BT_SCO_AUX_CODEC_INTF   AUX_CODEC_INTF_CTL__PCMINTF_DATA_EN_V
-
-#ifdef CONFIG_DEBUG_FS
-static struct dentry *debugfs_hsed_config;
-static void snddev_hsed_config_modify_setting(int type);
-static void snddev_hsed_config_restore_setting(void);
-#endif
-
-static struct adie_codec_action_unit iearpiece_48KHz_osr256_actions[] =
-	HANDSET_RX_48000_OSR_256;
-
-static struct adie_codec_hwsetting_entry iearpiece_settings[] = {
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = iearpiece_48KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(iearpiece_48KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_dev_profile iearpiece_profile = {
-	.path_type = ADIE_CODEC_RX,
-	.settings = iearpiece_settings,
-	.setting_sz = ARRAY_SIZE(iearpiece_settings),
-};
-
-static struct snddev_icodec_data snddev_iearpiece_data = {
-	.capability = (SNDDEV_CAP_RX | SNDDEV_CAP_VOICE),
-	.name = "handset_rx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_HANDSET_SPKR,
-	.profile = &iearpiece_profile,
-	.channel_mode = 1,
-	.pmctl_id = NULL,
-	.pmctl_id_sz = 0,
-	.default_sample_rate = 48000,
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-	.property = SIDE_TONE_MASK,
-	.max_voice_rx_vol[VOC_NB_INDEX] = -200,
-	.min_voice_rx_vol[VOC_NB_INDEX] = -1700,
-	.max_voice_rx_vol[VOC_WB_INDEX] = -200,
-	.min_voice_rx_vol[VOC_WB_INDEX] = -1700
-};
-
-static struct platform_device msm_iearpiece_device = {
-	.name = "snddev_icodec",
-	.id = 0,
-	.dev = { .platform_data = &snddev_iearpiece_data },
-};
-
-static struct adie_codec_action_unit imic_8KHz_osr256_actions[] =
-	HANDSET_TX_8000_OSR_256;
-
-static struct adie_codec_action_unit imic_16KHz_osr256_actions[] =
-	HANDSET_TX_16000_OSR_256;
-
-static struct adie_codec_action_unit imic_48KHz_osr256_actions[] =
-	HANDSET_TX_48000_OSR_256;
-
-static struct adie_codec_hwsetting_entry imic_settings[] = {
-	{
-		.freq_plan = 8000,
-		.osr = 256,
-		.actions = imic_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(imic_8KHz_osr256_actions),
-	},
-	{
-		.freq_plan = 16000,
-		.osr = 256,
-		.actions = imic_16KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(imic_16KHz_osr256_actions),
-	},
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = imic_48KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(imic_48KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_dev_profile imic_profile = {
-	.path_type = ADIE_CODEC_TX,
-	.settings = imic_settings,
-	.setting_sz = ARRAY_SIZE(imic_settings),
-};
-
-static enum hsed_controller imic_pmctl_id[] = {PM_HSED_CONTROLLER_0};
-
-static struct snddev_icodec_data snddev_imic_data = {
-	.capability = (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE),
-	.name = "handset_tx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_HANDSET_MIC,
-	.profile = &imic_profile,
-	.channel_mode = 1,
-	.pmctl_id = imic_pmctl_id,
-	.pmctl_id_sz = ARRAY_SIZE(imic_pmctl_id),
-	.default_sample_rate = 48000,
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-};
-
-static struct platform_device msm_imic_device = {
-	.name = "snddev_icodec",
-	.id = 1,
-	.dev = { .platform_data = &snddev_imic_data },
-};
-
-static struct adie_codec_action_unit ihs_stereo_rx_48KHz_osr256_actions[] =
-	HEADSET_STEREO_RX_LEGACY_48000_OSR_256;
-
-static struct adie_codec_hwsetting_entry ihs_stereo_rx_settings[] = {
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = ihs_stereo_rx_48KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(ihs_stereo_rx_48KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_dev_profile ihs_stereo_rx_profile = {
-	.path_type = ADIE_CODEC_RX,
-	.settings = ihs_stereo_rx_settings,
-	.setting_sz = ARRAY_SIZE(ihs_stereo_rx_settings),
-};
-
-static struct snddev_icodec_data snddev_ihs_stereo_rx_data = {
-	.capability = (SNDDEV_CAP_RX | SNDDEV_CAP_VOICE),
-	.name = "headset_stereo_rx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_HEADSET_SPKR_STEREO,
-	.profile = &ihs_stereo_rx_profile,
-	.channel_mode = 2,
-	.default_sample_rate = 48000,
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-	.property = SIDE_TONE_MASK,
-	.max_voice_rx_vol[VOC_NB_INDEX] = -700,
-	.min_voice_rx_vol[VOC_NB_INDEX] = -2200,
-	.max_voice_rx_vol[VOC_WB_INDEX] = -900,
-	.min_voice_rx_vol[VOC_WB_INDEX] = -2400
-};
-
-static struct platform_device msm_ihs_stereo_rx_device = {
-	.name = "snddev_icodec",
-	.id = 2,
-	.dev = { .platform_data = &snddev_ihs_stereo_rx_data },
-};
-
-static struct adie_codec_action_unit ihs_mono_rx_48KHz_osr256_actions[] =
-	HEADSET_RX_LEGACY_48000_OSR_256;
-
-static struct adie_codec_hwsetting_entry ihs_mono_rx_settings[] = {
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = ihs_mono_rx_48KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(ihs_mono_rx_48KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_dev_profile ihs_mono_rx_profile = {
-	.path_type = ADIE_CODEC_RX,
-	.settings = ihs_mono_rx_settings,
-	.setting_sz = ARRAY_SIZE(ihs_mono_rx_settings),
-};
-
-static struct snddev_icodec_data snddev_ihs_mono_rx_data = {
-	.capability = (SNDDEV_CAP_RX | SNDDEV_CAP_VOICE),
-	.name = "headset_mono_rx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_HEADSET_SPKR_MONO,
-	.profile = &ihs_mono_rx_profile,
-	.channel_mode = 1,
-	.default_sample_rate = 48000,
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-	.property = SIDE_TONE_MASK,
-	.max_voice_rx_vol[VOC_NB_INDEX] = -700,
-	.min_voice_rx_vol[VOC_NB_INDEX] = -2200,
-	.max_voice_rx_vol[VOC_WB_INDEX] = -900,
-	.min_voice_rx_vol[VOC_WB_INDEX] = -2400,
-
-};
-
-static struct platform_device msm_ihs_mono_rx_device = {
-	.name = "snddev_icodec",
-	.id = 3,
-	.dev = { .platform_data = &snddev_ihs_mono_rx_data },
-};
-
-static struct adie_codec_action_unit ihs_ffa_stereo_rx_48KHz_osr256_actions[] =
-	HEADSET_STEREO_RX_CAPLESS_48000_OSR_256;
-
-static struct adie_codec_hwsetting_entry ihs_ffa_stereo_rx_settings[] = {
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = ihs_ffa_stereo_rx_48KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(ihs_ffa_stereo_rx_48KHz_osr256_actions),
-	}
-};
-
-#ifdef CONFIG_DEBUG_FS
-static struct adie_codec_action_unit
-	ihs_ffa_stereo_rx_class_d_legacy_48KHz_osr256_actions[] =
-	HEADSET_STEREO_RX_CLASS_D_LEGACY_48000_OSR_256;
-
-static struct adie_codec_hwsetting_entry
-	ihs_ffa_stereo_rx_class_d_legacy_settings[] = {
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions =
-		ihs_ffa_stereo_rx_class_d_legacy_48KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE
-		(ihs_ffa_stereo_rx_class_d_legacy_48KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_action_unit
-	ihs_ffa_stereo_rx_class_ab_legacy_48KHz_osr256_actions[] =
-	HEADSET_STEREO_RX_LEGACY_48000_OSR_256;
-
-static struct adie_codec_hwsetting_entry
-	ihs_ffa_stereo_rx_class_ab_legacy_settings[] = {
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions =
-		ihs_ffa_stereo_rx_class_ab_legacy_48KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE
-		(ihs_ffa_stereo_rx_class_ab_legacy_48KHz_osr256_actions),
-	}
-};
-#endif
-
-static struct adie_codec_dev_profile ihs_ffa_stereo_rx_profile = {
-	.path_type = ADIE_CODEC_RX,
-	.settings = ihs_ffa_stereo_rx_settings,
-	.setting_sz = ARRAY_SIZE(ihs_ffa_stereo_rx_settings),
-};
-
-static struct snddev_icodec_data snddev_ihs_ffa_stereo_rx_data = {
-	.capability = (SNDDEV_CAP_RX | SNDDEV_CAP_VOICE),
-	.name = "headset_stereo_rx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_HEADSET_SPKR_STEREO,
-	.profile = &ihs_ffa_stereo_rx_profile,
-	.channel_mode = 2,
-	.default_sample_rate = 48000,
-	.voltage_on = msm_snddev_hsed_voltage_on,
-	.voltage_off = msm_snddev_hsed_voltage_off,
-	.max_voice_rx_vol[VOC_NB_INDEX] = -700,
-	.min_voice_rx_vol[VOC_NB_INDEX] = -2200,
-	.max_voice_rx_vol[VOC_WB_INDEX] = -900,
-	.min_voice_rx_vol[VOC_WB_INDEX] = -2400,
-};
-
-static struct platform_device msm_ihs_ffa_stereo_rx_device = {
-	.name = "snddev_icodec",
-	.id = 4,
-	.dev = { .platform_data = &snddev_ihs_ffa_stereo_rx_data },
-};
-
-static struct adie_codec_action_unit ihs_ffa_mono_rx_48KHz_osr256_actions[] =
-	HEADSET_RX_CAPLESS_48000_OSR_256;
-
-static struct adie_codec_hwsetting_entry ihs_ffa_mono_rx_settings[] = {
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = ihs_ffa_mono_rx_48KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(ihs_ffa_mono_rx_48KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_dev_profile ihs_ffa_mono_rx_profile = {
-	.path_type = ADIE_CODEC_RX,
-	.settings = ihs_ffa_mono_rx_settings,
-	.setting_sz = ARRAY_SIZE(ihs_ffa_mono_rx_settings),
-};
-
-static struct snddev_icodec_data snddev_ihs_ffa_mono_rx_data = {
-	.capability = (SNDDEV_CAP_RX | SNDDEV_CAP_VOICE),
-	.name = "headset_mono_rx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_HEADSET_SPKR_MONO,
-	.profile = &ihs_ffa_mono_rx_profile,
-	.channel_mode = 1,
-	.default_sample_rate = 48000,
-	.pamp_on = msm_snddev_hsed_voltage_on,
-	.pamp_off = msm_snddev_hsed_voltage_off,
-	.max_voice_rx_vol[VOC_NB_INDEX] = -700,
-	.min_voice_rx_vol[VOC_NB_INDEX] = -2200,
-	.max_voice_rx_vol[VOC_WB_INDEX] = -900,
-	.min_voice_rx_vol[VOC_WB_INDEX] = -2400,
-};
-
-static struct platform_device msm_ihs_ffa_mono_rx_device = {
-	.name = "snddev_icodec",
-	.id = 5,
-	.dev = { .platform_data = &snddev_ihs_ffa_mono_rx_data },
-};
-
-static struct adie_codec_action_unit ihs_mono_tx_8KHz_osr256_actions[] =
-	HEADSET_MONO_TX_8000_OSR_256;
-
-static struct adie_codec_action_unit ihs_mono_tx_16KHz_osr256_actions[] =
-	HEADSET_MONO_TX_16000_OSR_256;
-
-static struct adie_codec_action_unit ihs_mono_tx_48KHz_osr256_actions[] =
-	HEADSET_MONO_TX_48000_OSR_256;
-
-static struct adie_codec_hwsetting_entry ihs_mono_tx_settings[] = {
-	{
-		.freq_plan = 8000,
-		.osr = 256,
-		.actions = ihs_mono_tx_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(ihs_mono_tx_8KHz_osr256_actions),
-	},
-	{
-		.freq_plan = 16000,
-		.osr = 256,
-		.actions = ihs_mono_tx_16KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(ihs_mono_tx_16KHz_osr256_actions),
-	},
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = ihs_mono_tx_48KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(ihs_mono_tx_48KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_dev_profile ihs_mono_tx_profile = {
-	.path_type = ADIE_CODEC_TX,
-	.settings = ihs_mono_tx_settings,
-	.setting_sz = ARRAY_SIZE(ihs_mono_tx_settings),
-};
-
-static struct snddev_icodec_data snddev_ihs_mono_tx_data = {
-	.capability = (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE),
-	.name = "headset_mono_tx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_HEADSET_MIC,
-	.profile = &ihs_mono_tx_profile,
-	.channel_mode = 1,
-	.pmctl_id = NULL,
-	.pmctl_id_sz = 0,
-	.default_sample_rate = 48000,
-	.pamp_on = msm_snddev_tx_route_config,
-	.pamp_off = msm_snddev_tx_route_deconfig,
-};
-
-static struct platform_device msm_ihs_mono_tx_device = {
-	.name = "snddev_icodec",
-	.id = 6,
-	.dev = { .platform_data = &snddev_ihs_mono_tx_data },
-};
-
-static struct adie_codec_action_unit ifmradio_handset_osr64_actions[] =
-	FM_HANDSET_OSR_64;
-
-static struct adie_codec_hwsetting_entry ifmradio_handset_settings[] = {
-	{
-		.freq_plan = 8000,
-		.osr = 256,
-		.actions = ifmradio_handset_osr64_actions,
-		.action_sz = ARRAY_SIZE(ifmradio_handset_osr64_actions),
-	}
-};
-
-static struct adie_codec_dev_profile ifmradio_handset_profile = {
-	.path_type = ADIE_CODEC_RX,
-	.settings = ifmradio_handset_settings,
-	.setting_sz = ARRAY_SIZE(ifmradio_handset_settings),
-};
-
-static struct snddev_icodec_data snddev_ifmradio_handset_data = {
-	.capability = (SNDDEV_CAP_RX | SNDDEV_CAP_FM),
-	.name = "fmradio_handset_rx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_LP_FM_SPKR_PHONE_STEREO_RX,
-	.profile = &ifmradio_handset_profile,
-	.channel_mode = 1,
-	.default_sample_rate = 8000,
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-	.dev_vol_type = SNDDEV_DEV_VOL_DIGITAL,
-};
-
-static struct platform_device msm_ifmradio_handset_device = {
-	.name = "snddev_icodec",
-	.id = 7,
-	.dev = { .platform_data = &snddev_ifmradio_handset_data },
-};
-
-
-static struct adie_codec_action_unit ispeaker_rx_48KHz_osr256_actions[] =
-   SPEAKER_STEREO_RX_48000_OSR_256;
-
-static struct adie_codec_hwsetting_entry ispeaker_rx_settings[] = {
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = ispeaker_rx_48KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(ispeaker_rx_48KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_dev_profile ispeaker_rx_profile = {
-	.path_type = ADIE_CODEC_RX,
-	.settings = ispeaker_rx_settings,
-	.setting_sz = ARRAY_SIZE(ispeaker_rx_settings),
-};
-
-static struct snddev_icodec_data snddev_ispeaker_rx_data = {
-	.capability = (SNDDEV_CAP_RX | SNDDEV_CAP_VOICE),
-	.name = "speaker_stereo_rx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_SPKR_PHONE_STEREO,
-	.profile = &ispeaker_rx_profile,
-	.channel_mode = 2,
-	.pmctl_id = NULL,
-	.pmctl_id_sz = 0,
-	.default_sample_rate = 48000,
-	.pamp_on = &msm_snddev_poweramp_on,
-	.pamp_off = &msm_snddev_poweramp_off,
-	.max_voice_rx_vol[VOC_NB_INDEX] = 1000,
-	.min_voice_rx_vol[VOC_NB_INDEX] = -500,
-	.max_voice_rx_vol[VOC_WB_INDEX] = 1000,
-	.min_voice_rx_vol[VOC_WB_INDEX] = -500,
-};
-
-static struct platform_device msm_ispeaker_rx_device = {
-	.name = "snddev_icodec",
-	.id = 8,
-	.dev = { .platform_data = &snddev_ispeaker_rx_data },
-
-};
-
-static struct adie_codec_action_unit ifmradio_speaker_osr64_actions[] =
-	FM_SPEAKER_OSR_64;
-
-static struct adie_codec_hwsetting_entry ifmradio_speaker_settings[] = {
-	{
-		.freq_plan = 8000,
-		.osr = 256,
-		.actions = ifmradio_speaker_osr64_actions,
-		.action_sz = ARRAY_SIZE(ifmradio_speaker_osr64_actions),
-	}
-};
-
-static struct adie_codec_dev_profile ifmradio_speaker_profile = {
-	.path_type = ADIE_CODEC_RX,
-	.settings = ifmradio_speaker_settings,
-	.setting_sz = ARRAY_SIZE(ifmradio_speaker_settings),
-};
-
-static struct snddev_icodec_data snddev_ifmradio_speaker_data = {
-	.capability = (SNDDEV_CAP_RX | SNDDEV_CAP_FM),
-	.name = "fmradio_speaker_rx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_LP_FM_SPKR_PHONE_STEREO_RX,
-	.profile = &ifmradio_speaker_profile,
-	.channel_mode = 1,
-	.default_sample_rate = 8000,
-	.pamp_on = &msm_snddev_poweramp_on,
-	.pamp_off = &msm_snddev_poweramp_off,
-	.dev_vol_type = SNDDEV_DEV_VOL_DIGITAL,
-};
-
-static struct platform_device msm_ifmradio_speaker_device = {
-	.name = "snddev_icodec",
-	.id = 9,
-	.dev = { .platform_data = &snddev_ifmradio_speaker_data },
-};
-
-static struct adie_codec_action_unit ifmradio_headset_osr64_actions[] =
-	FM_HEADSET_STEREO_CLASS_D_LEGACY_OSR_64;
-
-static struct adie_codec_hwsetting_entry ifmradio_headset_settings[] = {
-	{
-		.freq_plan = 8000,
-		.osr = 256,
-		.actions = ifmradio_headset_osr64_actions,
-		.action_sz = ARRAY_SIZE(ifmradio_headset_osr64_actions),
-	}
-};
-
-static struct adie_codec_dev_profile ifmradio_headset_profile = {
-	.path_type = ADIE_CODEC_RX,
-	.settings = ifmradio_headset_settings,
-	.setting_sz = ARRAY_SIZE(ifmradio_headset_settings),
-};
-
-static struct snddev_icodec_data snddev_ifmradio_headset_data = {
-	.capability = (SNDDEV_CAP_RX | SNDDEV_CAP_FM),
-	.name = "fmradio_headset_rx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_LP_FM_HEADSET_SPKR_STEREO_RX,
-	.profile = &ifmradio_headset_profile,
-	.channel_mode = 1,
-	.default_sample_rate = 8000,
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-	.dev_vol_type = SNDDEV_DEV_VOL_DIGITAL,
-};
-
-static struct platform_device msm_ifmradio_headset_device = {
-	.name = "snddev_icodec",
-	.id = 10,
-	.dev = { .platform_data = &snddev_ifmradio_headset_data },
-};
-
-
-static struct adie_codec_action_unit ifmradio_ffa_headset_osr64_actions[] =
-	FM_HEADSET_CLASS_AB_STEREO_CAPLESS_OSR_64;
-
-static struct adie_codec_hwsetting_entry ifmradio_ffa_headset_settings[] = {
-	{
-		.freq_plan = 8000,
-		.osr = 256,
-		.actions = ifmradio_ffa_headset_osr64_actions,
-		.action_sz = ARRAY_SIZE(ifmradio_ffa_headset_osr64_actions),
-	}
-};
-
-static struct adie_codec_dev_profile ifmradio_ffa_headset_profile = {
-	.path_type = ADIE_CODEC_RX,
-	.settings = ifmradio_ffa_headset_settings,
-	.setting_sz = ARRAY_SIZE(ifmradio_ffa_headset_settings),
-};
-
-static struct snddev_icodec_data snddev_ifmradio_ffa_headset_data = {
-	.capability = (SNDDEV_CAP_RX | SNDDEV_CAP_FM),
-	.name = "fmradio_headset_rx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_LP_FM_HEADSET_SPKR_STEREO_RX,
-	.profile = &ifmradio_ffa_headset_profile,
-	.channel_mode = 1,
-	.default_sample_rate = 8000,
-	.pamp_on = msm_snddev_hsed_voltage_on,
-	.pamp_off = msm_snddev_hsed_voltage_off,
-	.dev_vol_type = SNDDEV_DEV_VOL_DIGITAL,
-};
-
-static struct platform_device msm_ifmradio_ffa_headset_device = {
-	.name = "snddev_icodec",
-	.id = 11,
-	.dev = { .platform_data = &snddev_ifmradio_ffa_headset_data },
-};
-
-static struct snddev_ecodec_data snddev_bt_sco_earpiece_data = {
-	.capability = (SNDDEV_CAP_RX | SNDDEV_CAP_VOICE),
-	.name = "bt_sco_rx",
-	.copp_id = 1,
-	.acdb_id = ACDB_ID_BT_SCO_SPKR,
-	.channel_mode = 1,
-	.conf_pcm_ctl_val = BT_SCO_PCM_CTL_VAL,
-	.conf_aux_codec_intf = BT_SCO_AUX_CODEC_INTF,
-	.conf_data_format_padding_val = BT_SCO_DATA_FORMAT_PADDING,
-	.max_voice_rx_vol[VOC_NB_INDEX] = 400,
-	.min_voice_rx_vol[VOC_NB_INDEX] = -1100,
-	.max_voice_rx_vol[VOC_WB_INDEX] = 400,
-	.min_voice_rx_vol[VOC_WB_INDEX] = -1100,
-};
-
-static struct snddev_ecodec_data snddev_bt_sco_mic_data = {
-	.capability = (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE),
-	.name = "bt_sco_tx",
-	.copp_id = 1,
-	.acdb_id = ACDB_ID_BT_SCO_MIC,
-	.channel_mode = 1,
-	.conf_pcm_ctl_val = BT_SCO_PCM_CTL_VAL,
-	.conf_aux_codec_intf = BT_SCO_AUX_CODEC_INTF,
-	.conf_data_format_padding_val = BT_SCO_DATA_FORMAT_PADDING,
-};
-
-struct platform_device msm_bt_sco_earpiece_device = {
-	.name = "msm_snddev_ecodec",
-	.id = 0,
-	.dev = { .platform_data = &snddev_bt_sco_earpiece_data },
-};
-
-struct platform_device msm_bt_sco_mic_device = {
-	.name = "msm_snddev_ecodec",
-	.id = 1,
-	.dev = { .platform_data = &snddev_bt_sco_mic_data },
-};
-
-static struct adie_codec_action_unit idual_mic_endfire_8KHz_osr256_actions[] =
-	MIC1_LEFT_LINE_IN_RIGHT_8000_OSR_256;
-
-static struct adie_codec_hwsetting_entry idual_mic_endfire_settings[] = {
-	{
-		.freq_plan = 8000,
-		.osr = 256,
-		.actions = idual_mic_endfire_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(idual_mic_endfire_8KHz_osr256_actions),
-	}, /* 8KHz profile can be used for 16KHz */
-	{
-		.freq_plan = 16000,
-		.osr = 256,
-		.actions = idual_mic_endfire_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(idual_mic_endfire_8KHz_osr256_actions),
-	}, /* 8KHz profile can be used for 48KHz */
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = idual_mic_endfire_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(idual_mic_endfire_8KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_dev_profile idual_mic_endfire_profile = {
-	.path_type = ADIE_CODEC_TX,
-	.settings = idual_mic_endfire_settings,
-	.setting_sz = ARRAY_SIZE(idual_mic_endfire_settings),
-};
-
-static enum hsed_controller idual_mic_endfire_pmctl_id[] = {
-	PM_HSED_CONTROLLER_0, PM_HSED_CONTROLLER_2
-};
-
-static struct snddev_icodec_data snddev_idual_mic_endfire_data = {
-	.capability = (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE),
-	.name = "handset_dual_mic_endfire_tx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_HANDSET_MIC_ENDFIRE,
-	.profile = &idual_mic_endfire_profile,
-	.channel_mode = 2,
-	.default_sample_rate = 48000,
-	.pmctl_id = idual_mic_endfire_pmctl_id,
-	.pmctl_id_sz = ARRAY_SIZE(idual_mic_endfire_pmctl_id),
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-};
-
-static struct platform_device msm_idual_mic_endfire_device = {
-	.name = "snddev_icodec",
-	.id = 12,
-	.dev = { .platform_data = &snddev_idual_mic_endfire_data },
-};
-
-
-static struct snddev_icodec_data\
-		snddev_idual_mic_endfire_real_stereo_data = {
-	.capability = (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE),
-	.name = "handset_dual_mic_endfire_tx_real_stereo",
-	.copp_id = 0,
-	.acdb_id = PSEUDO_ACDB_ID,
-	.profile = &idual_mic_endfire_profile,
-	.channel_mode = REAL_STEREO_CHANNEL_MODE,
-	.default_sample_rate = 48000,
-	.pmctl_id = idual_mic_endfire_pmctl_id,
-	.pmctl_id_sz = ARRAY_SIZE(idual_mic_endfire_pmctl_id),
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-};
-
-static struct platform_device msm_real_stereo_tx_device = {
-	.name = "snddev_icodec",
-	.id = 26,
-	.dev = { .platform_data =
-			&snddev_idual_mic_endfire_real_stereo_data },
-};
-
-static struct adie_codec_action_unit idual_mic_bs_8KHz_osr256_actions[] =
-	MIC1_LEFT_AUX_IN_RIGHT_8000_OSR_256;
-
-static struct adie_codec_hwsetting_entry idual_mic_broadside_settings[] = {
-	{
-		.freq_plan = 8000,
-		.osr = 256,
-		.actions = idual_mic_bs_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(idual_mic_bs_8KHz_osr256_actions),
-	}, /* 8KHz profile can be used for 16KHz */
-	{
-		.freq_plan = 16000,
-		.osr = 256,
-		.actions = idual_mic_bs_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(idual_mic_bs_8KHz_osr256_actions),
-	}, /* 8KHz profile can be used for 16KHz */
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = idual_mic_bs_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(idual_mic_bs_8KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_dev_profile idual_mic_broadside_profile = {
-	.path_type = ADIE_CODEC_TX,
-	.settings = idual_mic_broadside_settings,
-	.setting_sz = ARRAY_SIZE(idual_mic_broadside_settings),
-};
-
-static enum hsed_controller idual_mic_broadside_pmctl_id[] = {
-	PM_HSED_CONTROLLER_0, PM_HSED_CONTROLLER_2
-};
-
-static struct snddev_icodec_data snddev_idual_mic_broadside_data = {
-	.capability = (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE),
-	.name = "handset_dual_mic_broadside_tx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_HANDSET_MIC_BROADSIDE,
-	.profile = &idual_mic_broadside_profile,
-	.channel_mode = 2,
-	.default_sample_rate = 48000,
-	.pmctl_id = idual_mic_broadside_pmctl_id,
-	.pmctl_id_sz = ARRAY_SIZE(idual_mic_broadside_pmctl_id),
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-};
-
-static struct platform_device msm_idual_mic_broadside_device = {
-	.name = "snddev_icodec",
-	.id = 13,
-	.dev = { .platform_data = &snddev_idual_mic_broadside_data },
-};
-
-static struct adie_codec_action_unit ispk_dual_mic_ef_8KHz_osr256_actions[] =
-	SPEAKER_MIC1_LEFT_LINE_IN_RIGHT_8000_OSR_256;
-
-static struct adie_codec_hwsetting_entry ispk_dual_mic_ef_settings[] = {
-	{
-		.freq_plan = 8000,
-		.osr = 256,
-		.actions = ispk_dual_mic_ef_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(ispk_dual_mic_ef_8KHz_osr256_actions),
-	}, /* 8KHz profile can be used for 16Khz */
-	{
-		.freq_plan = 16000,
-		.osr = 256,
-		.actions = ispk_dual_mic_ef_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(ispk_dual_mic_ef_8KHz_osr256_actions),
-	}, /* 8KHz profile can be used for 48KHz */
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = ispk_dual_mic_ef_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(ispk_dual_mic_ef_8KHz_osr256_actions),
-	},
-};
-
-static struct adie_codec_dev_profile ispk_dual_mic_ef_profile = {
-	.path_type = ADIE_CODEC_TX,
-	.settings = ispk_dual_mic_ef_settings,
-	.setting_sz = ARRAY_SIZE(ispk_dual_mic_ef_settings),
-};
-
-static struct snddev_icodec_data snddev_spk_idual_mic_endfire_data = {
-	.capability = (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE),
-	.name = "speaker_dual_mic_endfire_tx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_SPKR_PHONE_MIC_ENDFIRE,
-	.profile = &ispk_dual_mic_ef_profile,
-	.channel_mode = 2,
-	.default_sample_rate = 48000,
-	.pmctl_id = idual_mic_endfire_pmctl_id,
-	.pmctl_id_sz = ARRAY_SIZE(idual_mic_endfire_pmctl_id),
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-};
-
-static struct platform_device msm_spk_idual_mic_endfire_device = {
-	.name = "snddev_icodec",
-	.id = 14,
-	.dev = { .platform_data = &snddev_spk_idual_mic_endfire_data },
-};
-
-static struct adie_codec_action_unit ispk_dual_mic_bs_8KHz_osr256_actions[] =
-	SPEAKER_MIC1_LEFT_AUX_IN_RIGHT_8000_OSR_256;
-
-static struct adie_codec_hwsetting_entry ispk_dual_mic_bs_settings[] = {
-	{
-		.freq_plan = 8000,
-		.osr = 256,
-		.actions = ispk_dual_mic_bs_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(ispk_dual_mic_bs_8KHz_osr256_actions),
-	}, /* 8KHz profile can be used for 16Khz */
-	{
-		.freq_plan = 16000,
-		.osr = 256,
-		.actions = ispk_dual_mic_bs_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(ispk_dual_mic_bs_8KHz_osr256_actions),
-	}, /* 8KHz profile can be used for 48KHz */
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = ispk_dual_mic_bs_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(ispk_dual_mic_bs_8KHz_osr256_actions),
-	},
-};
-
-static struct adie_codec_dev_profile ispk_dual_mic_bs_profile = {
-	.path_type = ADIE_CODEC_TX,
-	.settings = ispk_dual_mic_bs_settings,
-	.setting_sz = ARRAY_SIZE(ispk_dual_mic_bs_settings),
-};
-static struct snddev_icodec_data snddev_spk_idual_mic_broadside_data = {
-	.capability = (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE),
-	.name = "speaker_dual_mic_broadside_tx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_SPKR_PHONE_MIC_BROADSIDE,
-	.profile = &ispk_dual_mic_bs_profile,
-	.channel_mode = 2,
-	.default_sample_rate = 48000,
-	.pmctl_id = idual_mic_broadside_pmctl_id,
-	.pmctl_id_sz = ARRAY_SIZE(idual_mic_broadside_pmctl_id),
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-};
-
-static struct platform_device msm_spk_idual_mic_broadside_device = {
-	.name = "snddev_icodec",
-	.id = 15,
-	.dev = { .platform_data = &snddev_spk_idual_mic_broadside_data },
-};
-
-static struct adie_codec_action_unit itty_hs_mono_tx_8KHz_osr256_actions[] =
-	TTY_HEADSET_MONO_TX_8000_OSR_256;
-
-static struct adie_codec_hwsetting_entry itty_hs_mono_tx_settings[] = {
-	/* 8KHz, 16KHz, 48KHz TTY Tx devices can shared same set of actions */
-	{
-		.freq_plan = 8000,
-		.osr = 256,
-		.actions = itty_hs_mono_tx_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(itty_hs_mono_tx_8KHz_osr256_actions),
-	},
-	{
-		.freq_plan = 16000,
-		.osr = 256,
-		.actions = itty_hs_mono_tx_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(itty_hs_mono_tx_8KHz_osr256_actions),
-	},
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = itty_hs_mono_tx_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(itty_hs_mono_tx_8KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_dev_profile itty_hs_mono_tx_profile = {
-	.path_type = ADIE_CODEC_TX,
-	.settings = itty_hs_mono_tx_settings,
-	.setting_sz = ARRAY_SIZE(itty_hs_mono_tx_settings),
-};
-
-static struct snddev_icodec_data snddev_itty_hs_mono_tx_data = {
-	.capability = (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE | SNDDEV_CAP_TTY),
-	.name = "tty_headset_mono_tx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_TTY_HEADSET_MIC,
-	.profile = &itty_hs_mono_tx_profile,
-	.channel_mode = 1,
-	.default_sample_rate = 48000,
-	.pmctl_id = NULL,
-	.pmctl_id_sz = 0,
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-};
-
-static struct platform_device msm_itty_hs_mono_tx_device = {
-	.name = "snddev_icodec",
-	.id = 16,
-	.dev = { .platform_data = &snddev_itty_hs_mono_tx_data },
-};
-
-static struct adie_codec_action_unit itty_hs_mono_rx_8KHz_osr256_actions[] =
-	TTY_HEADSET_MONO_RX_CLASS_D_8000_OSR_256;
-
-static struct adie_codec_action_unit itty_hs_mono_rx_16KHz_osr256_actions[] =
-	TTY_HEADSET_MONO_RX_CLASS_D_16000_OSR_256;
-
-static struct adie_codec_action_unit itty_hs_mono_rx_48KHz_osr256_actions[] =
-	TTY_HEADSET_MONO_RX_CLASS_D_48000_OSR_256;
-
-static struct adie_codec_hwsetting_entry itty_hs_mono_rx_settings[] = {
-	{
-		.freq_plan = 8000,
-		.osr = 256,
-		.actions = itty_hs_mono_rx_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(itty_hs_mono_rx_8KHz_osr256_actions),
-	},
-	{
-		.freq_plan = 16000,
-		.osr = 256,
-		.actions = itty_hs_mono_rx_16KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(itty_hs_mono_rx_16KHz_osr256_actions),
-	},
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = itty_hs_mono_rx_48KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(itty_hs_mono_rx_48KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_dev_profile itty_hs_mono_rx_profile = {
-	.path_type = ADIE_CODEC_RX,
-	.settings = itty_hs_mono_rx_settings,
-	.setting_sz = ARRAY_SIZE(itty_hs_mono_rx_settings),
-};
-
-static struct snddev_icodec_data snddev_itty_hs_mono_rx_data = {
-	.capability = (SNDDEV_CAP_RX | SNDDEV_CAP_VOICE | SNDDEV_CAP_TTY),
-	.name = "tty_headset_mono_rx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_TTY_HEADSET_SPKR,
-	.profile = &itty_hs_mono_rx_profile,
-	.channel_mode = 1,
-	.default_sample_rate = 48000,
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-	.max_voice_rx_vol[VOC_NB_INDEX] = 0,
-	.min_voice_rx_vol[VOC_NB_INDEX] = 0,
-	.max_voice_rx_vol[VOC_WB_INDEX] = 0,
-	.min_voice_rx_vol[VOC_WB_INDEX] = 0,
-};
-
-static struct platform_device msm_itty_hs_mono_rx_device = {
-	.name = "snddev_icodec",
-	.id = 17,
-	.dev = { .platform_data = &snddev_itty_hs_mono_rx_data },
-};
-
-static struct adie_codec_action_unit ispeaker_tx_8KHz_osr256_actions[] =
-	SPEAKER_TX_8000_OSR_256;
-
-static struct adie_codec_action_unit ispeaker_tx_48KHz_osr256_actions[] =
-	SPEAKER_TX_48000_OSR_256;
-
-static struct adie_codec_hwsetting_entry ispeaker_tx_settings[] = {
-	{
-		.freq_plan = 8000,
-		.osr = 256,
-		.actions = ispeaker_tx_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(ispeaker_tx_8KHz_osr256_actions),
-	},
-	{ /* 8KHz profile is good for 16KHz */
-		.freq_plan = 16000,
-		.osr = 256,
-		.actions = ispeaker_tx_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(ispeaker_tx_8KHz_osr256_actions),
-	},
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = ispeaker_tx_48KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(ispeaker_tx_48KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_dev_profile ispeaker_tx_profile = {
-	.path_type = ADIE_CODEC_TX,
-	.settings = ispeaker_tx_settings,
-	.setting_sz = ARRAY_SIZE(ispeaker_tx_settings),
-};
-
-static enum hsed_controller ispk_pmctl_id[] = {PM_HSED_CONTROLLER_0};
-
-static struct snddev_icodec_data snddev_ispeaker_tx_data = {
-	.capability = (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE),
-	.name = "speaker_mono_tx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_SPKR_PHONE_MIC,
-	.profile = &ispeaker_tx_profile,
-	.channel_mode = 1,
-	.pmctl_id = ispk_pmctl_id,
-	.pmctl_id_sz = ARRAY_SIZE(ispk_pmctl_id),
-	.default_sample_rate = 48000,
-	.pamp_on = msm_snddev_tx_route_config,
-	.pamp_off = msm_snddev_tx_route_deconfig,
-};
-
-static struct platform_device msm_ispeaker_tx_device = {
-	.name = "snddev_icodec",
-	.id = 18,
-	.dev = { .platform_data = &snddev_ispeaker_tx_data },
-};
-
-static struct adie_codec_action_unit iearpiece_ffa_48KHz_osr256_actions[] =
-	HANDSET_RX_48000_OSR_256_FFA;
-
-static struct adie_codec_hwsetting_entry iearpiece_ffa_settings[] = {
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = iearpiece_ffa_48KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(iearpiece_ffa_48KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_dev_profile iearpiece_ffa_profile = {
-	.path_type = ADIE_CODEC_RX,
-	.settings = iearpiece_ffa_settings,
-	.setting_sz = ARRAY_SIZE(iearpiece_ffa_settings),
-};
-
-static struct snddev_icodec_data snddev_iearpiece_ffa_data = {
-	.capability = (SNDDEV_CAP_RX | SNDDEV_CAP_VOICE),
-	.name = "handset_rx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_HANDSET_SPKR,
-	.profile = &iearpiece_ffa_profile,
-	.channel_mode = 1,
-	.pmctl_id = NULL,
-	.pmctl_id_sz = 0,
-	.default_sample_rate = 48000,
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-	.max_voice_rx_vol[VOC_NB_INDEX] = -700,
-	.min_voice_rx_vol[VOC_NB_INDEX] = -2200,
-	.max_voice_rx_vol[VOC_WB_INDEX] = -1400,
-	.min_voice_rx_vol[VOC_WB_INDEX] = -2900,
-};
-
-static struct platform_device msm_iearpiece_ffa_device = {
-	.name = "snddev_icodec",
-	.id = 19,
-	.dev = { .platform_data = &snddev_iearpiece_ffa_data },
-};
-
-static struct adie_codec_action_unit imic_ffa_8KHz_osr256_actions[] =
-	HANDSET_TX_8000_OSR_256_FFA;
-
-static struct adie_codec_action_unit imic_ffa_16KHz_osr256_actions[] =
-	HANDSET_TX_16000_OSR_256_FFA;
-
-static struct adie_codec_action_unit imic_ffa_48KHz_osr256_actions[] =
-	HANDSET_TX_48000_OSR_256_FFA;
-
-static struct adie_codec_hwsetting_entry imic_ffa_settings[] = {
-	{
-		.freq_plan = 8000,
-		.osr = 256,
-		.actions = imic_ffa_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(imic_ffa_8KHz_osr256_actions),
-	},
-	{
-		.freq_plan = 16000,
-		.osr = 256,
-		.actions = imic_ffa_16KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(imic_ffa_16KHz_osr256_actions),
-	},
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = imic_ffa_48KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(imic_ffa_48KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_dev_profile imic_ffa_profile = {
-	.path_type = ADIE_CODEC_TX,
-	.settings = imic_ffa_settings,
-	.setting_sz = ARRAY_SIZE(imic_ffa_settings),
-};
-
-static struct snddev_icodec_data snddev_imic_ffa_data = {
-	.capability = (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE),
-	.name = "handset_tx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_HANDSET_MIC,
-	.profile = &imic_ffa_profile,
-	.channel_mode = 1,
-	.pmctl_id = imic_pmctl_id,
-	.pmctl_id_sz = ARRAY_SIZE(imic_pmctl_id),
-	.default_sample_rate = 48000,
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-};
-
-static struct platform_device msm_imic_ffa_device = {
-	.name = "snddev_icodec",
-	.id = 20,
-	.dev = { .platform_data = &snddev_imic_ffa_data },
-};
-
-
-static struct adie_codec_action_unit
-	ihs_stereo_speaker_stereo_rx_48KHz_osr256_actions[] =
-	HEADSET_STEREO_SPEAKER_STEREO_RX_CAPLESS_48000_OSR_256;
-
-
-static struct adie_codec_hwsetting_entry
-	ihs_stereo_speaker_stereo_rx_settings[] = {
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = ihs_stereo_speaker_stereo_rx_48KHz_osr256_actions,
-		.action_sz =
-		ARRAY_SIZE(ihs_stereo_speaker_stereo_rx_48KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_dev_profile ihs_stereo_speaker_stereo_rx_profile = {
-	.path_type = ADIE_CODEC_RX,
-	.settings = ihs_stereo_speaker_stereo_rx_settings,
-	.setting_sz = ARRAY_SIZE(ihs_stereo_speaker_stereo_rx_settings),
-};
-
-static struct snddev_icodec_data snddev_ihs_stereo_speaker_stereo_rx_data = {
-	.capability = (SNDDEV_CAP_RX | SNDDEV_CAP_VOICE),
-	.name = "headset_stereo_speaker_stereo_rx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_HEADSET_STEREO_PLUS_SPKR_STEREO_RX,
-	.profile = &ihs_stereo_speaker_stereo_rx_profile,
-	.channel_mode = 2,
-	.default_sample_rate = 48000,
-	.pamp_on = msm_snddev_poweramp_on,
-	.pamp_off = msm_snddev_poweramp_off,
-	.voltage_on = msm_snddev_hsed_voltage_on,
-	.voltage_off = msm_snddev_hsed_voltage_off,
-	.max_voice_rx_vol[VOC_NB_INDEX] = -500,
-	.min_voice_rx_vol[VOC_NB_INDEX] = -2000,
-	.max_voice_rx_vol[VOC_WB_INDEX] = -500,
-	.min_voice_rx_vol[VOC_WB_INDEX] = -2000,
-};
-
-static struct platform_device msm_ihs_stereo_speaker_stereo_rx_device = {
-	.name = "snddev_icodec",
-	.id = 21,
-	.dev = { .platform_data = &snddev_ihs_stereo_speaker_stereo_rx_data },
-};
-
-static struct snddev_mi2s_data snddev_mi2s_stereo_rx_data = {
-	.capability = SNDDEV_CAP_RX ,
-	.name = "hdmi_stereo_rx",
-	.copp_id = 3,
-	.acdb_id = ACDB_ID_HDMI,
-	.channel_mode = 2,
-	.sd_lines = MI2S_SD_0,
-	.route = msm_snddev_tx_route_config,
-	.deroute = msm_snddev_tx_route_deconfig,
-	.default_sample_rate = 48000,
-};
-
-static struct platform_device msm_snddev_mi2s_stereo_rx_device = {
-	.name = "snddev_mi2s",
-	.id = 0,
-	.dev = { .platform_data = &snddev_mi2s_stereo_rx_data },
-};
-
-
-static struct snddev_mi2s_data snddev_mi2s_fm_tx_data = {
-	.capability = SNDDEV_CAP_TX ,
-	.name = "fmradio_stereo_tx",
-	.copp_id = 2,
-	.acdb_id = ACDB_ID_FM_TX,
-	.channel_mode = 2,
-	.sd_lines = MI2S_SD_3,
-	.route = NULL,
-	.deroute = NULL,
-	.default_sample_rate = 48000,
-};
-
-static struct platform_device  msm_snddev_mi2s_fm_tx_device = {
-	.name = "snddev_mi2s",
-	.id = 1,
-	.dev = { .platform_data = &snddev_mi2s_fm_tx_data},
-};
-
-static struct snddev_icodec_data snddev_fluid_imic_tx_data = {
-	.capability = (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE),
-	.name = "handset_tx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_SPKR_PHONE_MIC,
-	.profile = &ispeaker_tx_profile,
-	.channel_mode = 1,
-	.pmctl_id = ispk_pmctl_id,
-	.pmctl_id_sz = ARRAY_SIZE(ispk_pmctl_id),
-	.default_sample_rate = 48000,
-	.pamp_on = msm_snddev_tx_route_config,
-	.pamp_off = msm_snddev_tx_route_deconfig,
-};
-
-static struct platform_device msm_fluid_imic_tx_device = {
-	.name = "snddev_icodec",
-	.id = 22,
-	.dev = { .platform_data = &snddev_fluid_imic_tx_data },
-};
-
-static struct snddev_icodec_data snddev_fluid_iearpiece_rx_data = {
-	.capability = (SNDDEV_CAP_RX | SNDDEV_CAP_VOICE),
-	.name = "handset_rx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_SPKR_PHONE_STEREO,
-	.profile = &ispeaker_rx_profile,
-	.channel_mode = 2,
-	.pmctl_id = NULL,
-	.pmctl_id_sz = 0,
-	.default_sample_rate = 48000,
-	.pamp_on = &msm_snddev_poweramp_on,
-	.pamp_off = &msm_snddev_poweramp_off,
-	.max_voice_rx_vol[VOC_NB_INDEX] = -500,
-	.min_voice_rx_vol[VOC_NB_INDEX] = -1000,
-	.max_voice_rx_vol[VOC_WB_INDEX] = -500,
-	.min_voice_rx_vol[VOC_WB_INDEX] = -1000,
-};
-
-static struct platform_device msm_fluid_iearpeice_rx_device = {
-	.name = "snddev_icodec",
-	.id = 23,
-	.dev = { .platform_data = &snddev_fluid_iearpiece_rx_data },
-};
-
-static struct adie_codec_action_unit fluid_idual_mic_ef_8KHz_osr256_actions[] =
-	MIC1_LEFT_AUX_IN_RIGHT_8000_OSR_256;
-
-static struct adie_codec_hwsetting_entry fluid_idual_mic_endfire_settings[] = {
-	{
-		.freq_plan = 8000,
-		.osr = 256,
-		.actions = fluid_idual_mic_ef_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(fluid_idual_mic_ef_8KHz_osr256_actions),
-	}, /* 8KHz profile can be used for 16KHz */
-	{
-		.freq_plan = 16000,
-		.osr = 256,
-		.actions = fluid_idual_mic_ef_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(fluid_idual_mic_ef_8KHz_osr256_actions),
-	}, /* 8KHz profile can also be used for 48KHz */
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = fluid_idual_mic_ef_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(fluid_idual_mic_ef_8KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_dev_profile fluid_idual_mic_endfire_profile = {
-	.path_type = ADIE_CODEC_TX,
-	.settings = fluid_idual_mic_endfire_settings,
-	.setting_sz = ARRAY_SIZE(fluid_idual_mic_endfire_settings),
-};
-
-static enum hsed_controller fluid_idual_mic_endfire_pmctl_id[] = {
-	PM_HSED_CONTROLLER_0, PM_HSED_CONTROLLER_2
-};
-
-static struct snddev_icodec_data snddev_fluid_idual_mic_endfire_data = {
-	.capability = (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE),
-	.name = "handset_dual_mic_endfire_tx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_SPKR_PHONE_MIC_ENDFIRE,
-	.profile = &fluid_idual_mic_endfire_profile,
-	.channel_mode = 2,
-	.default_sample_rate = 48000,
-	.pmctl_id = fluid_idual_mic_endfire_pmctl_id,
-	.pmctl_id_sz = ARRAY_SIZE(fluid_idual_mic_endfire_pmctl_id),
-	.pamp_on = msm_snddev_tx_route_config,
-	.pamp_off = msm_snddev_tx_route_deconfig,
-};
-
-static struct platform_device msm_fluid_idual_mic_endfire_device = {
-	.name = "snddev_icodec",
-	.id = 24,
-	.dev = { .platform_data = &snddev_fluid_idual_mic_endfire_data },
-};
-
-static struct snddev_icodec_data snddev_fluid_spk_idual_mic_endfire_data = {
-	.capability = (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE),
-	.name = "speaker_dual_mic_endfire_tx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_SPKR_PHONE_MIC_ENDFIRE,
-	.profile = &fluid_idual_mic_endfire_profile,
-	.channel_mode = 2,
-	.default_sample_rate = 48000,
-	.pmctl_id = fluid_idual_mic_endfire_pmctl_id,
-	.pmctl_id_sz = ARRAY_SIZE(fluid_idual_mic_endfire_pmctl_id),
-	.pamp_on = msm_snddev_tx_route_config,
-	.pamp_off = msm_snddev_tx_route_deconfig,
-};
-
-static struct platform_device msm_fluid_spk_idual_mic_endfire_device = {
-	.name = "snddev_icodec",
-	.id = 25,
-	.dev = { .platform_data = &snddev_fluid_spk_idual_mic_endfire_data },
-};
-
-static struct snddev_virtual_data snddev_a2dp_tx_data = {
-	.capability = SNDDEV_CAP_TX,
-	.name = "a2dp_tx",
-	.copp_id = 5,
-	.acdb_id = PSEUDO_ACDB_ID,
-};
-
-static struct snddev_virtual_data snddev_a2dp_rx_data = {
-	.capability = SNDDEV_CAP_RX,
-	.name = "a2dp_rx",
-	.copp_id = 2,
-	.acdb_id = PSEUDO_ACDB_ID,
-};
-
-static struct platform_device msm_a2dp_rx_device = {
-	.name = "snddev_virtual",
-	.id = 0,
-	.dev = { .platform_data = &snddev_a2dp_rx_data },
-};
-
-static struct platform_device msm_a2dp_tx_device = {
-	.name = "snddev_virtual",
-	.id = 1,
-	.dev = { .platform_data = &snddev_a2dp_tx_data },
-};
-
-static struct snddev_virtual_data snddev_uplink_rx_data = {
-	.capability = SNDDEV_CAP_RX,
-	.name = "uplink_rx",
-	.copp_id = 5,
-	.acdb_id = PSEUDO_ACDB_ID,
-};
-
-static struct platform_device msm_uplink_rx_device = {
-	.name = "snddev_virtual",
-	.id = 2,
-	.dev = { .platform_data = &snddev_uplink_rx_data },
-};
-
-static struct platform_device *snd_devices_ffa[] __initdata = {
-	&msm_iearpiece_ffa_device,
-	&msm_imic_ffa_device,
-	&msm_ifmradio_handset_device,
-	&msm_ihs_ffa_stereo_rx_device,
-	&msm_ihs_ffa_mono_rx_device,
-	&msm_ihs_mono_tx_device,
-	&msm_bt_sco_earpiece_device,
-	&msm_bt_sco_mic_device,
-	&msm_ispeaker_rx_device,
-	&msm_ifmradio_speaker_device,
-	&msm_ifmradio_ffa_headset_device,
-	&msm_idual_mic_endfire_device,
-	&msm_idual_mic_broadside_device,
-	&msm_spk_idual_mic_endfire_device,
-	&msm_spk_idual_mic_broadside_device,
-	&msm_itty_hs_mono_tx_device,
-	&msm_itty_hs_mono_rx_device,
-	&msm_ispeaker_tx_device,
-	&msm_ihs_stereo_speaker_stereo_rx_device,
-	&msm_a2dp_rx_device,
-	&msm_a2dp_tx_device,
-	&msm_snddev_mi2s_stereo_rx_device,
-	&msm_snddev_mi2s_fm_tx_device,
-	&msm_uplink_rx_device,
-	&msm_real_stereo_tx_device,
-};
-
-static struct platform_device *snd_devices_surf[] __initdata = {
-	&msm_iearpiece_device,
-	&msm_imic_device,
-	&msm_ihs_stereo_rx_device,
-	&msm_ihs_mono_rx_device,
-	&msm_ihs_mono_tx_device,
-	&msm_bt_sco_earpiece_device,
-	&msm_bt_sco_mic_device,
-	&msm_ifmradio_handset_device,
-	&msm_ispeaker_rx_device,
-	&msm_ifmradio_speaker_device,
-	&msm_ifmradio_headset_device,
-	&msm_itty_hs_mono_tx_device,
-	&msm_itty_hs_mono_rx_device,
-	&msm_ispeaker_tx_device,
-	&msm_ihs_stereo_speaker_stereo_rx_device,
-	&msm_a2dp_rx_device,
-	&msm_a2dp_tx_device,
-	&msm_snddev_mi2s_stereo_rx_device,
-	&msm_snddev_mi2s_fm_tx_device,
-	&msm_uplink_rx_device,
-};
-
-static struct platform_device *snd_devices_fluid[] __initdata = {
-	&msm_ihs_stereo_rx_device,
-	&msm_ihs_mono_rx_device,
-	&msm_ihs_mono_tx_device,
-	&msm_ispeaker_rx_device,
-	&msm_ispeaker_tx_device,
-	&msm_fluid_imic_tx_device,
-	&msm_fluid_iearpeice_rx_device,
-	&msm_fluid_idual_mic_endfire_device,
-	&msm_fluid_spk_idual_mic_endfire_device,
-	&msm_a2dp_rx_device,
-	&msm_a2dp_tx_device,
-	&msm_snddev_mi2s_stereo_rx_device,
-	&msm_uplink_rx_device,
-	&msm_ifmradio_speaker_device,
-	&msm_ifmradio_headset_device,
-};
-
-#ifdef CONFIG_DEBUG_FS
-static void snddev_hsed_config_modify_setting(int type)
-{
-	struct platform_device *device;
-	struct snddev_icodec_data *icodec_data;
-
-	device = &msm_ihs_ffa_stereo_rx_device;
-	icodec_data = (struct snddev_icodec_data *)device->dev.platform_data;
-
-	if (icodec_data) {
-		if (type == 1) {
-			icodec_data->voltage_on = NULL;
-			icodec_data->voltage_off = NULL;
-			icodec_data->profile->settings =
-				ihs_ffa_stereo_rx_class_d_legacy_settings;
-			icodec_data->profile->setting_sz =
-			ARRAY_SIZE(ihs_ffa_stereo_rx_class_d_legacy_settings);
-		} else if (type == 2) {
-			icodec_data->voltage_on = NULL;
-			icodec_data->voltage_off = NULL;
-			icodec_data->profile->settings =
-				ihs_ffa_stereo_rx_class_ab_legacy_settings;
-			icodec_data->profile->setting_sz =
-			ARRAY_SIZE(ihs_ffa_stereo_rx_class_ab_legacy_settings);
-		}
-	}
-}
-
-static void snddev_hsed_config_restore_setting(void)
-{
-	struct platform_device *device;
-	struct snddev_icodec_data *icodec_data;
-
-	device = &msm_ihs_ffa_stereo_rx_device;
-	icodec_data = (struct snddev_icodec_data *)device->dev.platform_data;
-
-	if (icodec_data) {
-		icodec_data->voltage_on = msm_snddev_hsed_voltage_on;
-		icodec_data->voltage_off = msm_snddev_hsed_voltage_off;
-		icodec_data->profile->settings = ihs_ffa_stereo_rx_settings;
-		icodec_data->profile->setting_sz =
-			ARRAY_SIZE(ihs_ffa_stereo_rx_settings);
-	}
-}
-
-static ssize_t snddev_hsed_config_debug_write(struct file *filp,
-	const char __user *ubuf, size_t cnt, loff_t *ppos)
-{
-	char *lb_str = filp->private_data;
-	char cmd;
-
-	if (get_user(cmd, ubuf))
-		return -EFAULT;
-
-	if (!strcmp(lb_str, "msm_hsed_config")) {
-		switch (cmd) {
-		case '0':
-			snddev_hsed_config_restore_setting();
-			break;
-
-		case '1':
-			snddev_hsed_config_modify_setting(1);
-			break;
-
-		case '2':
-			snddev_hsed_config_modify_setting(2);
-			break;
-
-		default:
-			break;
-		}
-	}
-	return cnt;
-}
-
-static int snddev_hsed_config_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static const struct file_operations snddev_hsed_config_debug_fops = {
-	.open = snddev_hsed_config_debug_open,
-	.write = snddev_hsed_config_debug_write
-};
-#endif
-
-void __ref msm_snddev_init(void)
-{
-	if (machine_is_msm7x30_ffa() || machine_is_msm8x55_ffa() ||
-		machine_is_msm8x55_svlte_ffa()) {
-		platform_add_devices(snd_devices_ffa,
-		ARRAY_SIZE(snd_devices_ffa));
-#ifdef CONFIG_DEBUG_FS
-		debugfs_hsed_config = debugfs_create_file("msm_hsed_config",
-					S_IFREG | S_IRUGO, NULL,
-		(void *) "msm_hsed_config", &snddev_hsed_config_debug_fops);
-#endif
-	} else if (machine_is_msm7x30_surf() || machine_is_msm8x55_surf() ||
-		machine_is_msm8x55_svlte_surf())
-		platform_add_devices(snd_devices_surf,
-		ARRAY_SIZE(snd_devices_surf));
-	else if (machine_is_msm7x30_fluid())
-		platform_add_devices(snd_devices_fluid,
-		ARRAY_SIZE(snd_devices_fluid));
-	else
-		pr_err("%s: Unknown machine type\n", __func__);
-}
diff --git a/arch/arm/mach-msm/qdsp5v2/snddev_data_timpani.c b/arch/arm/mach-msm/qdsp5v2/snddev_data_timpani.c
deleted file mode 100644
index a4e4dad..0000000
--- a/arch/arm/mach-msm/qdsp5v2/snddev_data_timpani.c
+++ /dev/null
@@ -1,1006 +0,0 @@
-/* Copyright (c) 2010-2011, The Linux Foundation. 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.
- *
- */
-#include <linux/platform_device.h>
-#include <linux/debugfs.h>
-#include <linux/mfd/msm-adie-codec.h>
-#include <linux/uaccess.h>
-#include <asm/mach-types.h>
-#include <mach/qdsp5v2/aux_pcm.h>
-#include <mach/qdsp5v2/snddev_ecodec.h>
-#include <mach/board.h>
-#include <mach/qdsp5v2/snddev_icodec.h>
-#include <mach/qdsp5v2/snddev_mi2s.h>
-#include <mach/qdsp5v2/mi2s.h>
-#include <mach/qdsp5v2/audio_acdb_def.h>
-#include <mach/qdsp5v2/snddev_virtual.h>
-#include "timpani_profile_7x30.h"
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-
-/* define the value for BT_SCO */
-#define BT_SCO_PCM_CTL_VAL (PCM_CTL__RPCM_WIDTH__LINEAR_V |\
-		PCM_CTL__TPCM_WIDTH__LINEAR_V)
-#define BT_SCO_DATA_FORMAT_PADDING (DATA_FORMAT_PADDING_INFO__RPCM_FORMAT_V |\
-		DATA_FORMAT_PADDING_INFO__TPCM_FORMAT_V)
-#define BT_SCO_AUX_CODEC_INTF   AUX_CODEC_INTF_CTL__PCMINTF_DATA_EN_V
-
-#ifdef CONFIG_DEBUG_FS
-static struct dentry *debugfs_hsed_config;
-static void snddev_hsed_config_modify_setting(int type);
-static void snddev_hsed_config_restore_setting(void);
-#endif
-
-static struct adie_codec_action_unit iearpiece_ffa_48KHz_osr256_actions[] =
-	EAR_PRI_MONO_8000_OSR_256; /* 8000 profile also works for 48k */
-
-static struct adie_codec_hwsetting_entry iearpiece_ffa_settings[] = {
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = iearpiece_ffa_48KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(iearpiece_ffa_48KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_dev_profile iearpiece_ffa_profile = {
-	.path_type = ADIE_CODEC_RX,
-	.settings = iearpiece_ffa_settings,
-	.setting_sz = ARRAY_SIZE(iearpiece_ffa_settings),
-};
-
-static struct snddev_icodec_data snddev_iearpiece_ffa_data = {
-	.capability = (SNDDEV_CAP_RX | SNDDEV_CAP_VOICE),
-	.name = "handset_rx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_HANDSET_SPKR,
-	.profile = &iearpiece_ffa_profile,
-	.channel_mode = 1,
-	.pmctl_id = NULL,
-	.pmctl_id_sz = 0,
-	.default_sample_rate = 48000,
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-	.property = SIDE_TONE_MASK,
-	.max_voice_rx_vol[VOC_NB_INDEX] = -700,
-	.min_voice_rx_vol[VOC_NB_INDEX] = -2200,
-	.max_voice_rx_vol[VOC_WB_INDEX] = -1400,
-	.min_voice_rx_vol[VOC_WB_INDEX] = -2900,
-};
-
-static struct platform_device msm_iearpiece_ffa_device = {
-	.name = "snddev_icodec",
-	.id = 19,
-	.dev = { .platform_data = &snddev_iearpiece_ffa_data },
-};
-
-static struct adie_codec_action_unit imic_ffa_48KHz_osr256_actions[] =
-	AMIC_PRI_MONO_8000_OSR_256; /* 8000 profile also works for 48k */
-
-static struct adie_codec_hwsetting_entry imic_ffa_settings[] = {
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = imic_ffa_48KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(imic_ffa_48KHz_osr256_actions),
-	}
-};
-
-static enum hsed_controller imic_pmctl_id[] = {PM_HSED_CONTROLLER_0};
-
-static struct adie_codec_dev_profile imic_ffa_profile = {
-	.path_type = ADIE_CODEC_TX,
-	.settings = imic_ffa_settings,
-	.setting_sz = ARRAY_SIZE(imic_ffa_settings),
-};
-
-static struct snddev_icodec_data snddev_imic_ffa_data = {
-	.capability = (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE),
-	.name = "handset_tx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_HANDSET_MIC,
-	.profile = &imic_ffa_profile,
-	.channel_mode = 1,
-	.pmctl_id = imic_pmctl_id,
-	.pmctl_id_sz = ARRAY_SIZE(imic_pmctl_id),
-	.default_sample_rate = 48000,
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-};
-
-static struct platform_device msm_imic_ffa_device = {
-	.name = "snddev_icodec",
-	.id = 20,
-	.dev = { .platform_data = &snddev_imic_ffa_data },
-};
-
-static struct adie_codec_action_unit ispkr_stereo_48KHz_osr256_actions[] =
-	SPEAKER_PRI_STEREO_48000_OSR_256;
-
-static struct adie_codec_hwsetting_entry ispkr_stereo_settings[] = {
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = ispkr_stereo_48KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(ispkr_stereo_48KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_dev_profile ispkr_stereo_profile = {
-	.path_type = ADIE_CODEC_RX,
-	.settings = ispkr_stereo_settings,
-	.setting_sz = ARRAY_SIZE(ispkr_stereo_settings),
-};
-
-static struct snddev_icodec_data snddev_ispkr_stereo_data = {
-	.capability = (SNDDEV_CAP_RX | SNDDEV_CAP_VOICE),
-	.name = "speaker_stereo_rx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_SPKR_PHONE_STEREO,
-	.profile = &ispkr_stereo_profile,
-	.channel_mode = 2,
-	.pmctl_id = NULL,
-	.pmctl_id_sz = 0,
-	.default_sample_rate = 48000,
-	.pamp_on = msm_snddev_poweramp_on,
-	.pamp_off = msm_snddev_poweramp_off,
-	.max_voice_rx_vol[VOC_NB_INDEX] = 1000,
-	.min_voice_rx_vol[VOC_NB_INDEX] = -500,
-	.max_voice_rx_vol[VOC_WB_INDEX] = 1000,
-	.min_voice_rx_vol[VOC_WB_INDEX] = -500
-};
-
-static struct platform_device msm_ispkr_stereo_device = {
-	.name = "snddev_icodec",
-	.id = 8,
-	.dev = { .platform_data = &snddev_ispkr_stereo_data },
-};
-
-static struct adie_codec_action_unit iheadset_mic_tx_osr256_actions[] =
-	AMIC1_HEADSET_TX_MONO_PRIMARY_OSR256;
-
-static struct adie_codec_hwsetting_entry iheadset_mic_tx_settings[] = {
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = iheadset_mic_tx_osr256_actions,
-		.action_sz = ARRAY_SIZE(iheadset_mic_tx_osr256_actions),
-	}
-};
-
-static struct adie_codec_dev_profile iheadset_mic_profile = {
-	.path_type = ADIE_CODEC_TX,
-	.settings = iheadset_mic_tx_settings,
-	.setting_sz = ARRAY_SIZE(iheadset_mic_tx_settings),
-};
-
-static struct snddev_icodec_data snddev_headset_mic_data = {
-	.capability = (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE),
-	.name = "headset_mono_tx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_HEADSET_MIC,
-	.profile = &iheadset_mic_profile,
-	.channel_mode = 1,
-	.pmctl_id = NULL,
-	.pmctl_id_sz = 0,
-	.default_sample_rate = 48000,
-	.pamp_on = msm_snddev_tx_route_config,
-	.pamp_off = msm_snddev_tx_route_deconfig,
-};
-
-static struct platform_device msm_headset_mic_device = {
-	.name = "snddev_icodec",
-	.id = 6,
-	.dev = { .platform_data = &snddev_headset_mic_data },
-};
-
-static struct snddev_mi2s_data snddev_mi2s_fm_tx_data = {
-	.capability = SNDDEV_CAP_TX ,
-	.name = "fmradio_stereo_tx",
-	.copp_id = 2,
-	.acdb_id = ACDB_ID_FM_TX,
-	.channel_mode = 2,
-	.sd_lines = MI2S_SD_3,
-	.route = NULL,
-	.deroute = NULL,
-	.default_sample_rate = 48000,
-};
-
-static struct platform_device  msm_snddev_mi2s_fm_tx_device = {
-	.name = "snddev_mi2s",
-	.id = 1,
-	.dev = { .platform_data = &snddev_mi2s_fm_tx_data},
-};
-
-static struct snddev_mi2s_data snddev_mi2s_fm_rx_data = {
-	.capability = SNDDEV_CAP_RX ,
-	.name = "fmradio_stereo_rx",
-	.copp_id = 3,
-	.acdb_id = ACDB_ID_FM_RX,
-	.channel_mode = 2,
-	.sd_lines = MI2S_SD_3,
-	.route = NULL,
-	.deroute = NULL,
-	.default_sample_rate = 48000,
-};
-
-static struct platform_device  msm_snddev_mi2s_fm_rx_device = {
-	.name = "snddev_mi2s",
-	.id = 2,
-	.dev = { .platform_data = &snddev_mi2s_fm_rx_data},
-};
-
-static struct snddev_ecodec_data snddev_bt_sco_earpiece_data = {
-	.capability = (SNDDEV_CAP_RX | SNDDEV_CAP_VOICE),
-	.name = "bt_sco_rx",
-	.copp_id = 1,
-	.acdb_id = ACDB_ID_BT_SCO_SPKR,
-	.channel_mode = 1,
-	.conf_pcm_ctl_val = BT_SCO_PCM_CTL_VAL,
-	.conf_aux_codec_intf = BT_SCO_AUX_CODEC_INTF,
-	.conf_data_format_padding_val = BT_SCO_DATA_FORMAT_PADDING,
-	.max_voice_rx_vol[VOC_NB_INDEX] = 400,
-	.min_voice_rx_vol[VOC_NB_INDEX] = -1100,
-	.max_voice_rx_vol[VOC_WB_INDEX] = 400,
-	.min_voice_rx_vol[VOC_WB_INDEX] = -1100,
-};
-
-static struct snddev_ecodec_data snddev_bt_sco_mic_data = {
-	.capability = (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE),
-	.name = "bt_sco_tx",
-	.copp_id = 1,
-	.acdb_id = ACDB_ID_BT_SCO_MIC,
-	.channel_mode = 1,
-	.conf_pcm_ctl_val = BT_SCO_PCM_CTL_VAL,
-	.conf_aux_codec_intf = BT_SCO_AUX_CODEC_INTF,
-	.conf_data_format_padding_val = BT_SCO_DATA_FORMAT_PADDING,
-};
-
-static struct platform_device msm_bt_sco_earpiece_device = {
-	.name = "msm_snddev_ecodec",
-	.id = 0,
-	.dev = { .platform_data = &snddev_bt_sco_earpiece_data },
-};
-
-static struct platform_device msm_bt_sco_mic_device = {
-	.name = "msm_snddev_ecodec",
-	.id = 1,
-	.dev = { .platform_data = &snddev_bt_sco_mic_data },
-};
-
-static struct adie_codec_action_unit headset_ab_cpls_48KHz_osr256_actions[] =
-	HEADSET_AB_CPLS_48000_OSR_256;
-
-static struct adie_codec_hwsetting_entry headset_ab_cpls_settings[] = {
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = headset_ab_cpls_48KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(headset_ab_cpls_48KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_dev_profile headset_ab_cpls_profile = {
-	.path_type = ADIE_CODEC_RX,
-	.settings = headset_ab_cpls_settings,
-	.setting_sz = ARRAY_SIZE(headset_ab_cpls_settings),
-};
-
-static struct snddev_icodec_data snddev_ihs_stereo_rx_data = {
-	.capability = (SNDDEV_CAP_RX | SNDDEV_CAP_VOICE),
-	.name = "headset_stereo_rx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_HEADSET_SPKR_STEREO,
-	.profile = &headset_ab_cpls_profile,
-	.channel_mode = 2,
-	.pmctl_id = NULL,
-	.pmctl_id_sz = 0,
-	.default_sample_rate = 48000,
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-	.property = SIDE_TONE_MASK,
-	.voltage_on = msm_snddev_hsed_voltage_on,
-	.voltage_off = msm_snddev_hsed_voltage_off,
-	.max_voice_rx_vol[VOC_NB_INDEX] = -700,
-	.min_voice_rx_vol[VOC_NB_INDEX] = -2200,
-	.max_voice_rx_vol[VOC_WB_INDEX] = -900,
-	.min_voice_rx_vol[VOC_WB_INDEX] = -2400,
-};
-
-static struct platform_device msm_headset_stereo_device = {
-	.name = "snddev_icodec",
-	.id = 2,
-	.dev = { .platform_data = &snddev_ihs_stereo_rx_data },
-};
-
-/*debug FS interface is exposed to test Class D and class AB mode
- * amplifers for headset device folloowing options are supported
- * 0 -> settings will be restored
- * 1 -> Cladd D mode is selected
- * 2 -> Class AB mode is selected
-*/
-#ifdef CONFIG_DEBUG_FS
-static struct adie_codec_action_unit
-	ihs_stereo_rx_class_d_legacy_48KHz_osr256_actions[] =
-	HPH_PRI_D_LEG_STEREO;
-
-static struct adie_codec_hwsetting_entry
-	ihs_stereo_rx_class_d_legacy_settings[] = {
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions =
-		ihs_stereo_rx_class_d_legacy_48KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE
-		(ihs_stereo_rx_class_d_legacy_48KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_action_unit
-	ihs_stereo_rx_class_ab_legacy_48KHz_osr256_actions[] =
-	HPH_PRI_AB_LEG_STEREO;
-
-static struct adie_codec_hwsetting_entry
-	ihs_stereo_rx_class_ab_legacy_settings[] = {
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions =
-		ihs_stereo_rx_class_ab_legacy_48KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE
-		(ihs_stereo_rx_class_ab_legacy_48KHz_osr256_actions),
-	}
-};
-
-static void snddev_hsed_config_modify_setting(int type)
-{
-	struct platform_device *device;
-	struct snddev_icodec_data *icodec_data;
-
-	device = &msm_headset_stereo_device;
-	icodec_data = (struct snddev_icodec_data *)device->dev.platform_data;
-
-	if (icodec_data) {
-		if (type == 1) {
-			icodec_data->voltage_on = NULL;
-			icodec_data->voltage_off = NULL;
-			icodec_data->profile->settings =
-				ihs_stereo_rx_class_d_legacy_settings;
-			icodec_data->profile->setting_sz =
-			ARRAY_SIZE(ihs_stereo_rx_class_d_legacy_settings);
-		} else if (type == 2) {
-			icodec_data->voltage_on = NULL;
-			icodec_data->voltage_off = NULL;
-			icodec_data->profile->settings =
-				ihs_stereo_rx_class_ab_legacy_settings;
-			icodec_data->profile->setting_sz =
-			ARRAY_SIZE(ihs_stereo_rx_class_ab_legacy_settings);
-		}
-	}
-}
-
-static void snddev_hsed_config_restore_setting(void)
-{
-	struct platform_device *device;
-	struct snddev_icodec_data *icodec_data;
-
-	device = &msm_headset_stereo_device;
-	icodec_data = device->dev.platform_data;
-
-	if (icodec_data) {
-		icodec_data->voltage_on = msm_snddev_hsed_voltage_on;
-		icodec_data->voltage_off = msm_snddev_hsed_voltage_off;
-		icodec_data->profile->settings = headset_ab_cpls_settings;
-		icodec_data->profile->setting_sz =
-			ARRAY_SIZE(headset_ab_cpls_settings);
-	}
-}
-
-static ssize_t snddev_hsed_config_debug_write(struct file *filp,
-	const char __user *ubuf, size_t cnt, loff_t *ppos)
-{
-	char *lb_str = filp->private_data;
-	char cmd;
-
-	if (get_user(cmd, ubuf))
-		return -EFAULT;
-
-	if (!strcmp(lb_str, "msm_hsed_config")) {
-		switch (cmd) {
-		case '0':
-			snddev_hsed_config_restore_setting();
-			break;
-
-		case '1':
-			snddev_hsed_config_modify_setting(1);
-			break;
-
-		case '2':
-			snddev_hsed_config_modify_setting(2);
-			break;
-
-		default:
-			break;
-		}
-	}
-	return cnt;
-}
-
-static int snddev_hsed_config_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	return 0;
-}
-
-static const struct file_operations snddev_hsed_config_debug_fops = {
-	.open = snddev_hsed_config_debug_open,
-	.write = snddev_hsed_config_debug_write
-};
-#endif
-
-static enum hsed_controller ispk_pmctl_id[] = {PM_HSED_CONTROLLER_0};
-
-static struct snddev_icodec_data snddev_ispkr_mic_data = {
-	.capability = (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE),
-	.name = "speaker_mono_tx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_SPKR_PHONE_MIC,
-	.profile = &imic_ffa_profile,
-	.channel_mode = 1,
-	.pmctl_id = ispk_pmctl_id,
-	.pmctl_id_sz = ARRAY_SIZE(ispk_pmctl_id),
-	.default_sample_rate = 48000,
-	.pamp_on = msm_snddev_tx_route_config,
-	.pamp_off = msm_snddev_tx_route_deconfig,
-};
-
-static struct platform_device msm_ispkr_mic_device = {
-	.name = "snddev_icodec",
-	.id = 18,
-	.dev = { .platform_data = &snddev_ispkr_mic_data },
-};
-
-static struct adie_codec_action_unit idual_mic_endfire_8KHz_osr256_actions[] =
-	AMIC_DUAL_8000_OSR_256;
-
-static struct adie_codec_hwsetting_entry idual_mic_endfire_settings[] = {
-	{
-		.freq_plan = 8000,
-		.osr = 256,
-		.actions = idual_mic_endfire_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(idual_mic_endfire_8KHz_osr256_actions),
-	}, /* 8KHz profile can be used for 16KHz */
-	{
-		.freq_plan = 16000,
-		.osr = 256,
-		.actions = idual_mic_endfire_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(idual_mic_endfire_8KHz_osr256_actions),
-	}, /* 8KHz profile can be used for 48KHz */
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = idual_mic_endfire_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(idual_mic_endfire_8KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_dev_profile idual_mic_endfire_profile = {
-	.path_type = ADIE_CODEC_TX,
-	.settings = idual_mic_endfire_settings,
-	.setting_sz = ARRAY_SIZE(idual_mic_endfire_settings),
-};
-
-static enum hsed_controller idual_mic_endfire_pmctl_id[] = {
-	PM_HSED_CONTROLLER_0, PM_HSED_CONTROLLER_2
-};
-
-static struct snddev_icodec_data snddev_idual_mic_endfire_data = {
-	.capability = (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE),
-	.name = "handset_dual_mic_endfire_tx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_HANDSET_MIC_ENDFIRE,
-	.profile = &idual_mic_endfire_profile,
-	.channel_mode = 2,
-	.default_sample_rate = 48000,
-	.pmctl_id = idual_mic_endfire_pmctl_id,
-	.pmctl_id_sz = ARRAY_SIZE(idual_mic_endfire_pmctl_id),
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-};
-
-static struct platform_device msm_idual_mic_endfire_device = {
-	.name = "snddev_icodec",
-	.id = 12,
-	.dev = { .platform_data = &snddev_idual_mic_endfire_data },
-};
-
-static struct snddev_icodec_data snddev_spk_idual_mic_endfire_data = {
-	.capability = (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE),
-	.name = "speaker_dual_mic_endfire_tx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_SPKR_PHONE_MIC_ENDFIRE,
-	.profile = &idual_mic_endfire_profile,
-	.channel_mode = 2,
-	.default_sample_rate = 48000,
-	.pmctl_id = idual_mic_endfire_pmctl_id,
-	.pmctl_id_sz = ARRAY_SIZE(idual_mic_endfire_pmctl_id),
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-};
-
-static struct platform_device msm_spk_idual_mic_endfire_device = {
-	.name = "snddev_icodec",
-	.id = 14,
-	.dev = { .platform_data = &snddev_spk_idual_mic_endfire_data },
-};
-
-static struct adie_codec_action_unit itty_mono_tx_actions[] =
-	TTY_HEADSET_MONO_TX_8000_OSR_256;
-
-static struct adie_codec_hwsetting_entry itty_mono_tx_settings[] = {
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = itty_mono_tx_actions,
-		.action_sz = ARRAY_SIZE(itty_mono_tx_actions),
-	},
-};
-
-static struct adie_codec_dev_profile itty_mono_tx_profile = {
-	.path_type = ADIE_CODEC_TX,
-	.settings = itty_mono_tx_settings,
-	.setting_sz = ARRAY_SIZE(itty_mono_tx_settings),
-};
-
-static struct snddev_icodec_data snddev_itty_mono_tx_data = {
-	.capability = (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE | SNDDEV_CAP_TTY),
-	.name = "tty_headset_mono_tx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_TTY_HEADSET_MIC,
-	.profile = &itty_mono_tx_profile,
-	.channel_mode = 1,
-	.default_sample_rate = 48000,
-	.pmctl_id = NULL,
-	.pmctl_id_sz = 0,
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-};
-
-static struct platform_device msm_itty_mono_tx_device = {
-	.name = "snddev_icodec",
-	.id = 16,
-	.dev = { .platform_data = &snddev_itty_mono_tx_data },
-};
-
-static struct adie_codec_action_unit itty_mono_rx_actions[] =
-	TTY_HEADSET_MONO_RX_8000_OSR_256;
-
-static struct adie_codec_hwsetting_entry itty_mono_rx_settings[] = {
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = itty_mono_rx_actions,
-		.action_sz = ARRAY_SIZE(itty_mono_rx_actions),
-	},
-};
-
-static struct adie_codec_dev_profile itty_mono_rx_profile = {
-	.path_type = ADIE_CODEC_RX,
-	.settings = itty_mono_rx_settings,
-	.setting_sz = ARRAY_SIZE(itty_mono_rx_settings),
-};
-
-static struct snddev_icodec_data snddev_itty_mono_rx_data = {
-	.capability = (SNDDEV_CAP_RX | SNDDEV_CAP_VOICE | SNDDEV_CAP_TTY),
-	.name = "tty_headset_mono_rx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_TTY_HEADSET_SPKR,
-	.profile = &itty_mono_rx_profile,
-	.channel_mode = 1,
-	.default_sample_rate = 48000,
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-	.max_voice_rx_vol[VOC_NB_INDEX] = 0,
-	.min_voice_rx_vol[VOC_NB_INDEX] = 0,
-	.max_voice_rx_vol[VOC_WB_INDEX] = 0,
-	.min_voice_rx_vol[VOC_WB_INDEX] = 0,
-};
-
-static struct platform_device msm_itty_mono_rx_device = {
-	.name = "snddev_icodec",
-	.id = 17,
-	.dev = { .platform_data = &snddev_itty_mono_rx_data },
-};
-
-static struct snddev_virtual_data snddev_a2dp_tx_data = {
-	.capability = SNDDEV_CAP_TX,
-	.name = "a2dp_tx",
-	.copp_id = 5,
-	.acdb_id = PSEUDO_ACDB_ID,
-};
-
-static struct snddev_virtual_data snddev_a2dp_rx_data = {
-	.capability = SNDDEV_CAP_RX,
-	.name = "a2dp_rx",
-	.copp_id = 2,
-	.acdb_id = PSEUDO_ACDB_ID,
-};
-
-static struct platform_device msm_a2dp_rx_device = {
-	.name = "snddev_virtual",
-	.id = 0,
-	.dev = { .platform_data = &snddev_a2dp_rx_data },
-};
-
-static struct platform_device msm_a2dp_tx_device = {
-	.name = "snddev_virtual",
-	.id = 1,
-	.dev = { .platform_data = &snddev_a2dp_tx_data },
-};
-
-static struct snddev_virtual_data snddev_uplink_rx_data = {
-	.capability = SNDDEV_CAP_RX,
-	.name = "uplink_rx",
-	.copp_id = 5,
-	.acdb_id = PSEUDO_ACDB_ID,
-};
-
-static struct platform_device msm_uplink_rx_device = {
-	.name = "snddev_virtual",
-	.id = 2,
-	.dev = { .platform_data = &snddev_uplink_rx_data },
-};
-
-static struct snddev_icodec_data\
-		snddev_idual_mic_endfire_real_stereo_data = {
-	.capability = (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE),
-	.name = "handset_dual_mic_endfire_tx_real_stereo",
-	.copp_id = 0,
-	.acdb_id = PSEUDO_ACDB_ID,
-	.profile = &idual_mic_endfire_profile,
-	.channel_mode = REAL_STEREO_CHANNEL_MODE,
-	.default_sample_rate = 48000,
-	.pmctl_id = idual_mic_endfire_pmctl_id,
-	.pmctl_id_sz = ARRAY_SIZE(idual_mic_endfire_pmctl_id),
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-};
-
-static struct platform_device msm_real_stereo_tx_device = {
-	.name = "snddev_icodec",
-	.id = 26,
-	.dev = { .platform_data =
-			&snddev_idual_mic_endfire_real_stereo_data },
-};
-
-static struct adie_codec_action_unit ihs_ffa_mono_rx_48KHz_osr256_actions[] =
-	HEADSET_RX_CAPLESS_48000_OSR_256;
-
-static struct adie_codec_hwsetting_entry ihs_ffa_mono_rx_settings[] = {
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = ihs_ffa_mono_rx_48KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(ihs_ffa_mono_rx_48KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_dev_profile ihs_ffa_mono_rx_profile = {
-	.path_type = ADIE_CODEC_RX,
-	.settings = ihs_ffa_mono_rx_settings,
-	.setting_sz = ARRAY_SIZE(ihs_ffa_mono_rx_settings),
-};
-
-static struct snddev_icodec_data snddev_ihs_ffa_mono_rx_data = {
-	.capability = (SNDDEV_CAP_RX | SNDDEV_CAP_VOICE),
-	.name = "headset_mono_rx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_HEADSET_SPKR_MONO,
-	.profile = &ihs_ffa_mono_rx_profile,
-	.channel_mode = 1,
-	.default_sample_rate = 48000,
-	.pamp_on = msm_snddev_hsed_voltage_on,
-	.pamp_off = msm_snddev_hsed_voltage_off,
-	.max_voice_rx_vol[VOC_NB_INDEX] = -700,
-	.min_voice_rx_vol[VOC_NB_INDEX] = -2200,
-	.max_voice_rx_vol[VOC_WB_INDEX] = -900,
-	.min_voice_rx_vol[VOC_WB_INDEX] = -2400,
-	.property = SIDE_TONE_MASK,
-};
-
-static struct platform_device msm_ihs_ffa_mono_rx_device = {
-	.name = "snddev_icodec",
-	.id = 5,
-	.dev = { .platform_data = &snddev_ihs_ffa_mono_rx_data },
-};
-
-static struct adie_codec_action_unit
-	ihs_stereo_speaker_stereo_rx_48KHz_osr256_actions[] =
-	HEADSET_STEREO_SPEAKER_STEREO_RX_CAPLESS_48000_OSR_256;
-
-
-static struct adie_codec_hwsetting_entry
-	ihs_stereo_speaker_stereo_rx_settings[] = {
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = ihs_stereo_speaker_stereo_rx_48KHz_osr256_actions,
-		.action_sz =
-		ARRAY_SIZE(ihs_stereo_speaker_stereo_rx_48KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_dev_profile ihs_stereo_speaker_stereo_rx_profile = {
-	.path_type = ADIE_CODEC_RX,
-	.settings = ihs_stereo_speaker_stereo_rx_settings,
-	.setting_sz = ARRAY_SIZE(ihs_stereo_speaker_stereo_rx_settings),
-};
-
-static struct snddev_icodec_data snddev_ihs_stereo_speaker_stereo_rx_data = {
-	.capability = (SNDDEV_CAP_RX | SNDDEV_CAP_VOICE),
-	.name = "headset_stereo_speaker_stereo_rx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_HEADSET_STEREO_PLUS_SPKR_STEREO_RX,
-	.profile = &ihs_stereo_speaker_stereo_rx_profile,
-	.channel_mode = 2,
-	.default_sample_rate = 48000,
-	.pamp_on = msm_snddev_poweramp_on,
-	.pamp_off = msm_snddev_poweramp_off,
-	.voltage_on = msm_snddev_hsed_voltage_on,
-	.voltage_off = msm_snddev_hsed_voltage_off,
-	.max_voice_rx_vol[VOC_NB_INDEX] = -500,
-	.min_voice_rx_vol[VOC_NB_INDEX] = -2000,
-	.max_voice_rx_vol[VOC_WB_INDEX] = -900,
-	.min_voice_rx_vol[VOC_WB_INDEX] = -2400,
-};
-
-static struct platform_device msm_ihs_stereo_speaker_stereo_rx_device = {
-	.name = "snddev_icodec",
-	.id = 21,
-	.dev = { .platform_data = &snddev_ihs_stereo_speaker_stereo_rx_data },
-};
-
-static struct adie_codec_action_unit ispk_dual_mic_bs_8KHz_osr256_actions[] =
-	HS_DMIC2_STEREO_8000_OSR_256;
-
-static struct adie_codec_hwsetting_entry ispk_dual_mic_bs_settings[] = {
-	{
-		.freq_plan = 8000,
-		.osr = 256,
-		.actions = ispk_dual_mic_bs_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(ispk_dual_mic_bs_8KHz_osr256_actions),
-	}, /* 8KHz profile can be used for 16Khz */
-	{
-		.freq_plan = 16000,
-		.osr = 256,
-		.actions = ispk_dual_mic_bs_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(ispk_dual_mic_bs_8KHz_osr256_actions),
-	}, /* 8KHz profile can be used for 48KHz */
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = ispk_dual_mic_bs_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(ispk_dual_mic_bs_8KHz_osr256_actions),
-	},
-};
-
-static enum hsed_controller idual_mic_broadside_pmctl_id[] = {
-	PM_HSED_CONTROLLER_0, PM_HSED_CONTROLLER_2
-};
-
-static struct adie_codec_dev_profile ispk_dual_mic_bs_profile = {
-	.path_type = ADIE_CODEC_TX,
-	.settings = ispk_dual_mic_bs_settings,
-	.setting_sz = ARRAY_SIZE(ispk_dual_mic_bs_settings),
-};
-static struct snddev_icodec_data snddev_spk_idual_mic_broadside_data = {
-	.capability = (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE),
-	.name = "speaker_dual_mic_broadside_tx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_SPKR_PHONE_MIC_BROADSIDE,
-	.profile = &ispk_dual_mic_bs_profile,
-	.channel_mode = 2,
-	.default_sample_rate = 48000,
-	.pmctl_id = idual_mic_broadside_pmctl_id,
-	.pmctl_id_sz = ARRAY_SIZE(idual_mic_broadside_pmctl_id),
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-};
-
-static struct platform_device msm_spk_idual_mic_broadside_device = {
-	.name = "snddev_icodec",
-	.id = 15,
-	.dev = { .platform_data = &snddev_spk_idual_mic_broadside_data },
-};
-
-static struct adie_codec_action_unit idual_mic_bs_8KHz_osr256_actions[] =
-	HS_DMIC2_STEREO_8000_OSR_256;
-
-static struct adie_codec_hwsetting_entry idual_mic_broadside_settings[] = {
-	{
-		.freq_plan = 8000,
-		.osr = 256,
-		.actions = idual_mic_bs_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(idual_mic_bs_8KHz_osr256_actions),
-	}, /* 8KHz profile can be used for 16KHz */
-	{
-		.freq_plan = 16000,
-		.osr = 256,
-		.actions = idual_mic_bs_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(idual_mic_bs_8KHz_osr256_actions),
-	}, /* 8KHz profile can be used for 16KHz */
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = idual_mic_bs_8KHz_osr256_actions,
-		.action_sz = ARRAY_SIZE(idual_mic_bs_8KHz_osr256_actions),
-	}
-};
-
-static struct adie_codec_dev_profile idual_mic_broadside_profile = {
-	.path_type = ADIE_CODEC_TX,
-	.settings = idual_mic_broadside_settings,
-	.setting_sz = ARRAY_SIZE(idual_mic_broadside_settings),
-};
-
-static struct snddev_icodec_data snddev_idual_mic_broadside_data = {
-	.capability = (SNDDEV_CAP_TX | SNDDEV_CAP_VOICE),
-	.name = "handset_dual_mic_broadside_tx",
-	.copp_id = 0,
-	.acdb_id = ACDB_ID_HANDSET_MIC_BROADSIDE,
-	.profile = &idual_mic_broadside_profile,
-	.channel_mode = 2,
-	.default_sample_rate = 48000,
-	.pmctl_id = idual_mic_broadside_pmctl_id,
-	.pmctl_id_sz = ARRAY_SIZE(idual_mic_broadside_pmctl_id),
-	.pamp_on = NULL,
-	.pamp_off = NULL,
-};
-
-static struct platform_device msm_idual_mic_broadside_device = {
-	.name = "snddev_icodec",
-	.id = 13,
-	.dev = { .platform_data = &snddev_idual_mic_broadside_data },
-};
-
-static struct snddev_mi2s_data snddev_mi2s_stereo_rx_data = {
-	.capability = SNDDEV_CAP_RX ,
-	.name = "hdmi_stereo_rx",
-	.copp_id = 3,
-	.acdb_id = ACDB_ID_HDMI,
-	.channel_mode = 2,
-	.sd_lines = MI2S_SD_0,
-	.route = msm_snddev_tx_route_config,
-	.deroute = msm_snddev_tx_route_deconfig,
-	.default_sample_rate = 48000,
-};
-
-static struct platform_device msm_snddev_mi2s_stereo_rx_device = {
-	.name = "snddev_mi2s",
-	.id = 0,
-	.dev = { .platform_data = &snddev_mi2s_stereo_rx_data },
-};
-
-static struct adie_codec_action_unit auxpga_lb_lo_actions[] =
-	LB_AUXPGA_LO_STEREO;
-
-static struct adie_codec_hwsetting_entry auxpga_lb_lo_settings[] = {
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = auxpga_lb_lo_actions,
-		.action_sz = ARRAY_SIZE(auxpga_lb_lo_actions),
-	},
-};
-
-static struct adie_codec_dev_profile auxpga_lb_lo_profile = {
-	.path_type = ADIE_CODEC_LB,
-	.settings = auxpga_lb_lo_settings,
-	.setting_sz = ARRAY_SIZE(auxpga_lb_lo_settings),
-};
-
-static struct snddev_icodec_data snddev_auxpga_lb_lo_data = {
-	.capability = SNDDEV_CAP_LB,
-	.name = "auxpga_loopback_lo",
-	.copp_id = 0,
-	.acdb_id = PSEUDO_ACDB_ID,
-	.profile = &auxpga_lb_lo_profile,
-	.channel_mode = 2,
-	.default_sample_rate = 48000,
-	.pamp_on = msm_snddev_poweramp_on,
-	.pamp_off = msm_snddev_poweramp_off,
-	.dev_vol_type = SNDDEV_DEV_VOL_ANALOG,
-};
-
-static struct platform_device msm_auxpga_lb_lo_device = {
-	.name = "snddev_icodec",
-	.id = 27,
-	.dev = { .platform_data = &snddev_auxpga_lb_lo_data },
-};
-
-static struct adie_codec_action_unit auxpga_lb_hs_actions[] =
-	LB_AUXPGA_HPH_AB_CPLS_STEREO;
-
-static struct adie_codec_hwsetting_entry auxpga_lb_hs_settings[] = {
-	{
-		.freq_plan = 48000,
-		.osr = 256,
-		.actions = auxpga_lb_hs_actions,
-		.action_sz = ARRAY_SIZE(auxpga_lb_hs_actions),
-	},
-};
-
-static struct adie_codec_dev_profile auxpga_lb_hs_profile = {
-	.path_type = ADIE_CODEC_LB,
-	.settings = auxpga_lb_hs_settings,
-	.setting_sz = ARRAY_SIZE(auxpga_lb_hs_settings),
-};
-
-static struct snddev_icodec_data snddev_auxpga_lb_hs_data = {
-	.capability = SNDDEV_CAP_LB,
-	.name = "auxpga_loopback_hs",
-	.copp_id = 0,
-	.acdb_id = PSEUDO_ACDB_ID,
-	.profile = &auxpga_lb_hs_profile,
-	.channel_mode = 2,
-	.default_sample_rate = 48000,
-	.voltage_on = msm_snddev_hsed_voltage_on,
-	.voltage_off = msm_snddev_hsed_voltage_off,
-	.dev_vol_type = SNDDEV_DEV_VOL_ANALOG,
-};
-
-static struct platform_device msm_auxpga_lb_hs_device = {
-	.name = "snddev_icodec",
-	.id = 25,
-	.dev = { .platform_data = &snddev_auxpga_lb_hs_data },
-};
-
-static struct platform_device *snd_devices_ffa[] __initdata = {
-	&msm_iearpiece_ffa_device,
-	&msm_imic_ffa_device,
-	&msm_ispkr_stereo_device,
-	&msm_headset_mic_device,
-	&msm_ihs_ffa_mono_rx_device,
-	&msm_snddev_mi2s_fm_rx_device,
-	&msm_snddev_mi2s_fm_tx_device,
-	&msm_bt_sco_earpiece_device,
-	&msm_bt_sco_mic_device,
-	&msm_ispkr_mic_device,
-	&msm_headset_stereo_device,
-	&msm_idual_mic_endfire_device,
-	&msm_spk_idual_mic_endfire_device,
-	&msm_itty_mono_tx_device,
-	&msm_itty_mono_rx_device,
-	&msm_a2dp_rx_device,
-	&msm_a2dp_tx_device,
-	&msm_uplink_rx_device,
-	&msm_real_stereo_tx_device,
-	&msm_ihs_stereo_speaker_stereo_rx_device,
-	&msm_spk_idual_mic_broadside_device,
-	&msm_idual_mic_broadside_device,
-	&msm_snddev_mi2s_stereo_rx_device,
-	&msm_auxpga_lb_hs_device,
-	&msm_auxpga_lb_lo_device,
-};
-
-void __ref msm_snddev_init_timpani(void)
-{
-	platform_add_devices(snd_devices_ffa,
-			ARRAY_SIZE(snd_devices_ffa));
-#ifdef CONFIG_DEBUG_FS
-	debugfs_hsed_config = debugfs_create_file("msm_hsed_config",
-				S_IFREG | S_IWUGO, NULL,
-		(void *) "msm_hsed_config", &snddev_hsed_config_debug_fops);
-	if (!debugfs_hsed_config)
-		pr_err("failed to create msm_head_config debug fs entry\n");
-#endif
-
-}
diff --git a/arch/arm/mach-msm/qdsp5v2/snddev_ecodec.c b/arch/arm/mach-msm/qdsp5v2/snddev_ecodec.c
deleted file mode 100644
index d8009aa..0000000
--- a/arch/arm/mach-msm/qdsp5v2/snddev_ecodec.c
+++ /dev/null
@@ -1,484 +0,0 @@
-/* Copyright (c) 2009,2011 The Linux Foundation. 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.
- *
- */
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/clk.h>
-#include <linux/err.h>
-#include <asm/uaccess.h>
-#include <mach/qdsp5v2/snddev_ecodec.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/qdsp5v2/audio_interct.h>
-#include <mach/qdsp5v2/aux_pcm.h>
-#include <mach/qdsp5v2/afe.h>
-#include <mach/debug_mm.h>
-#include <linux/slab.h>
-
-/* Context for each external codec device */
-struct snddev_ecodec_state {
-	struct snddev_ecodec_data *data;
-	u32 sample_rate;
-	bool enabled;
-};
-
-/* Global state for the driver */
-struct snddev_ecodec_drv_state {
-	struct mutex dev_lock;
-	u32 rx_active; /* ensure one rx device at a time */
-	u32 tx_active; /* ensure one tx device at a time */
-	struct clk *lpa_core_clk;
-	struct clk *ecodec_clk;
-};
-
-#define ADSP_CTL 1
-
-static struct snddev_ecodec_drv_state snddev_ecodec_drv;
-
-static int snddev_ecodec_open_rx(struct snddev_ecodec_state *ecodec)
-{
-	int rc = 0;
-	struct snddev_ecodec_drv_state *drv = &snddev_ecodec_drv;
-	struct msm_afe_config afe_config;
-	int ret = 0;
-
-	MM_DBG("snddev_ecodec_open_rx\n");
-
-	if (!drv->tx_active) {
-		/* request GPIO */
-		rc = aux_pcm_gpios_request();
-		if (rc) {
-			MM_ERR("GPIO enable failed\n");
-			goto done;
-		}
-		/* config clocks */
-		clk_prepare_enable(drv->lpa_core_clk);
-
-		/*if long sync is selected in aux PCM interface
-		ecodec clock is updated to work with 128KHz,
-		if short sync is selected ecodec clock is updated to
-		work with 2.048MHz frequency, actual clock output is
-		different than the SW configuration by factor of two*/
-		if (!(ecodec->data->conf_aux_codec_intf &
-			AUX_CODEC_CTL__AUX_CODEC_MODE__I2S_V)) {
-			if (ecodec->data->conf_aux_codec_intf &
-				AUX_CODEC_CTL__AUX_PCM_MODE__AUX_MASTER_V) {
-				MM_DBG("Update ecodec clock to 128 KHz, long "
-					"sync in master mode is selected\n");
-				ret = clk_set_rate(drv->ecodec_clk, 256000);
-				if (ret < 0)
-					MM_ERR("Error updating ecodec clock"
-							" to 128KHz\n");
-			} else if (ecodec->data->conf_aux_codec_intf &
-				AUX_CODEC_CTL__AUX_PCM_MODE__PRIM_SLAVE_V) {
-				MM_DBG("Update ecodec clock to 2 MHz, short"
-					" sync in slave mode is selected\n");
-				ret = clk_set_rate(drv->ecodec_clk, 4096000);
-				if (ret < 0)
-					MM_ERR("Error updating ecodec clock"
-							" to 2.048MHz\n");
-			} else {
-				MM_DBG("Update ecodec clock to 2 MHz, short"
-					" sync in master mode is selected\n");
-				ret = clk_set_rate(drv->ecodec_clk, 4096000);
-				if (ret < 0)
-					MM_ERR("Error updating ecodec clock"
-							" to 2.048MHz\n");
-			}
-		}
-
-		/* enable ecodec clk */
-		clk_prepare_enable(drv->ecodec_clk);
-
-		/* let ADSP confiure AUX PCM regs */
-		aux_codec_adsp_codec_ctl_en(ADSP_CTL);
-
-		/* let adsp configure pcm path */
-		aux_codec_pcm_path_ctl_en(ADSP_CTL);
-
-		/* choose ADSP_A */
-		audio_interct_aux_regsel(AUDIO_ADSP_A);
-		audio_interct_tpcm_source(AUDIO_ADSP_A);
-		audio_interct_rpcm_source(AUDIO_ADSP_A);
-
-		clk_disable_unprepare(drv->lpa_core_clk);
-
-		/* send AUX_CODEC_CONFIG to AFE */
-		rc = afe_config_aux_codec(ecodec->data->conf_pcm_ctl_val,
-				ecodec->data->conf_aux_codec_intf,
-				ecodec->data->conf_data_format_padding_val);
-		if (IS_ERR_VALUE(rc))
-			goto error;
-	}
-	/* send CODEC CONFIG to AFE */
-	afe_config.sample_rate = ecodec->sample_rate / 1000;
-	afe_config.channel_mode = ecodec->data->channel_mode;
-	afe_config.volume = AFE_VOLUME_UNITY;
-	rc = afe_enable(AFE_HW_PATH_AUXPCM_RX, &afe_config);
-	if (IS_ERR_VALUE(rc)) {
-		if (!drv->tx_active) {
-			aux_pcm_gpios_free();
-			clk_disable_unprepare(drv->ecodec_clk);
-		}
-		goto done;
-	}
-
-	ecodec->enabled = 1;
-	return 0;
-
-error:
-	aux_pcm_gpios_free();
-	clk_disable_unprepare(drv->ecodec_clk);
-done:
-	return rc;
-}
-
-static int snddev_ecodec_close_rx(struct snddev_ecodec_state *ecodec)
-{
-	struct snddev_ecodec_drv_state *drv = &snddev_ecodec_drv;
-
-	/* free GPIO */
-	if (!drv->tx_active) {
-		aux_pcm_gpios_free();
-		clk_disable_unprepare(drv->ecodec_clk);
-	}
-
-	/* disable AFE */
-	afe_disable(AFE_HW_PATH_AUXPCM_RX);
-
-	ecodec->enabled = 0;
-
-	return 0;
-}
-
-static int snddev_ecodec_open_tx(struct snddev_ecodec_state *ecodec)
-{
-	int rc = 0;
-	struct snddev_ecodec_drv_state *drv = &snddev_ecodec_drv;
-	struct msm_afe_config afe_config;
-	int ret = 0;
-
-	MM_DBG("snddev_ecodec_open_tx\n");
-
-	/* request GPIO */
-	if (!drv->rx_active) {
-		rc = aux_pcm_gpios_request();
-		if (rc) {
-			MM_ERR("GPIO enable failed\n");
-			goto done;
-		}
-		/* config clocks */
-		clk_prepare_enable(drv->lpa_core_clk);
-
-		/*if long sync is selected in aux PCM interface
-		ecodec clock is updated to work with 128KHz,
-		if short sync is selected ecodec clock is updated to
-		work with 2.048MHz frequency, actual clock output is
-		different than the SW configuration by factor of two*/
-		if (!(ecodec->data->conf_aux_codec_intf &
-			AUX_CODEC_CTL__AUX_CODEC_MODE__I2S_V)) {
-			if (ecodec->data->conf_aux_codec_intf &
-				AUX_CODEC_CTL__AUX_PCM_MODE__AUX_MASTER_V) {
-				MM_DBG("Update ecodec clock to 128 KHz, long "
-					"sync in master mode is selected\n");
-				ret = clk_set_rate(drv->ecodec_clk, 256000);
-				if (ret < 0)
-					MM_ERR("Error updating ecodec clock"
-							" to 128KHz\n");
-			} else if (ecodec->data->conf_aux_codec_intf &
-				AUX_CODEC_CTL__AUX_PCM_MODE__PRIM_SLAVE_V) {
-				MM_DBG("Update ecodec clock to 2 MHz, short"
-					" sync in slave mode is selected\n");
-				ret = clk_set_rate(drv->ecodec_clk, 4096000);
-				if (ret < 0)
-					MM_ERR("Error updating ecodec clock"
-							" to 2.048MHz\n");
-			} else {
-				MM_DBG("Update ecodec clock to 2 MHz, short"
-					" sync in master mode is selected\n");
-				ret = clk_set_rate(drv->ecodec_clk, 4096000);
-				if (ret < 0)
-					MM_ERR("Error updating ecodec clock"
-							" to 2.048MHz\n");
-			}
-		}
-
-		/* enable ecodec clk */
-		clk_prepare_enable(drv->ecodec_clk);
-
-		/* let ADSP confiure AUX PCM regs */
-		aux_codec_adsp_codec_ctl_en(ADSP_CTL);
-
-		/* let adsp configure pcm path */
-		aux_codec_pcm_path_ctl_en(ADSP_CTL);
-
-		/* choose ADSP_A */
-		audio_interct_aux_regsel(AUDIO_ADSP_A);
-		audio_interct_tpcm_source(AUDIO_ADSP_A);
-		audio_interct_rpcm_source(AUDIO_ADSP_A);
-
-		clk_disable_unprepare(drv->lpa_core_clk);
-
-		/* send AUX_CODEC_CONFIG to AFE */
-		rc = afe_config_aux_codec(ecodec->data->conf_pcm_ctl_val,
-			ecodec->data->conf_aux_codec_intf,
-			ecodec->data->conf_data_format_padding_val);
-		if (IS_ERR_VALUE(rc))
-			goto error;
-	}
-	/* send CODEC CONFIG to AFE */
-	afe_config.sample_rate = ecodec->sample_rate / 1000;
-	afe_config.channel_mode = ecodec->data->channel_mode;
-	afe_config.volume = AFE_VOLUME_UNITY;
-	rc = afe_enable(AFE_HW_PATH_AUXPCM_TX, &afe_config);
-	if (IS_ERR_VALUE(rc)) {
-		if (!drv->rx_active) {
-			aux_pcm_gpios_free();
-			clk_disable_unprepare(drv->ecodec_clk);
-		}
-		goto done;
-	}
-
-	ecodec->enabled = 1;
-	return 0;
-
-error:
-	clk_disable_unprepare(drv->ecodec_clk);
-	aux_pcm_gpios_free();
-done:
-	return rc;
-}
-
-static int snddev_ecodec_close_tx(struct snddev_ecodec_state *ecodec)
-{
-	struct snddev_ecodec_drv_state *drv = &snddev_ecodec_drv;
-
-	/* free GPIO */
-	if (!drv->rx_active) {
-		aux_pcm_gpios_free();
-		clk_disable_unprepare(drv->ecodec_clk);
-	}
-
-	/* disable AFE */
-	afe_disable(AFE_HW_PATH_AUXPCM_TX);
-
-	ecodec->enabled = 0;
-
-	return 0;
-}
-
-
-static int snddev_ecodec_open(struct msm_snddev_info *dev_info)
-{
-	int rc = 0;
-	struct snddev_ecodec_state *ecodec;
-	struct snddev_ecodec_drv_state *drv = &snddev_ecodec_drv;
-
-	if (!dev_info) {
-		rc = -EINVAL;
-		goto error;
-	}
-
-	ecodec = dev_info->private_data;
-
-	if (ecodec->data->capability & SNDDEV_CAP_RX) {
-		mutex_lock(&drv->dev_lock);
-		if (drv->rx_active) {
-			mutex_unlock(&drv->dev_lock);
-			rc = -EBUSY;
-			goto error;
-		}
-		rc = snddev_ecodec_open_rx(ecodec);
-		if (!IS_ERR_VALUE(rc))
-			drv->rx_active = 1;
-		mutex_unlock(&drv->dev_lock);
-	} else {
-		mutex_lock(&drv->dev_lock);
-		if (drv->tx_active) {
-			mutex_unlock(&drv->dev_lock);
-			rc = -EBUSY;
-			goto error;
-		}
-		rc = snddev_ecodec_open_tx(ecodec);
-		if (!IS_ERR_VALUE(rc))
-			drv->tx_active = 1;
-		mutex_unlock(&drv->dev_lock);
-	}
-error:
-	return rc;
-}
-
-static int snddev_ecodec_close(struct msm_snddev_info *dev_info)
-{
-	int rc = 0;
-	struct snddev_ecodec_state *ecodec;
-	struct snddev_ecodec_drv_state *drv = &snddev_ecodec_drv;
-	if (!dev_info) {
-		rc = -EINVAL;
-		goto error;
-	}
-
-	ecodec = dev_info->private_data;
-
-	if (ecodec->data->capability & SNDDEV_CAP_RX) {
-		mutex_lock(&drv->dev_lock);
-		if (!drv->rx_active) {
-			mutex_unlock(&drv->dev_lock);
-			rc = -EPERM;
-			goto error;
-		}
-		rc = snddev_ecodec_close_rx(ecodec);
-		if (!IS_ERR_VALUE(rc))
-			drv->rx_active = 0;
-		mutex_unlock(&drv->dev_lock);
-	} else {
-		mutex_lock(&drv->dev_lock);
-		if (!drv->tx_active) {
-			mutex_unlock(&drv->dev_lock);
-			rc = -EPERM;
-			goto error;
-		}
-		rc = snddev_ecodec_close_tx(ecodec);
-		if (!IS_ERR_VALUE(rc))
-			drv->tx_active = 0;
-		mutex_unlock(&drv->dev_lock);
-	}
-
-error:
-	return rc;
-}
-
-static int snddev_ecodec_set_freq(struct msm_snddev_info *dev_info, u32 rate)
-{
-	int rc = 0;
-
-	if (!dev_info) {
-		rc = -EINVAL;
-		goto error;
-	}
-	return 8000;
-
-error:
-	return rc;
-}
-
-static int snddev_ecodec_probe(struct platform_device *pdev)
-{
-	int rc = 0, i;
-	struct snddev_ecodec_data *pdata;
-	struct msm_snddev_info *dev_info;
-	struct snddev_ecodec_state *ecodec;
-
-	if (!pdev || !pdev->dev.platform_data) {
-		printk(KERN_ALERT "Invalid caller \n");
-		rc = -1;
-		goto error;
-	}
-	pdata = pdev->dev.platform_data;
-
-	ecodec = kzalloc(sizeof(struct snddev_ecodec_state), GFP_KERNEL);
-	if (!ecodec) {
-		rc = -ENOMEM;
-		goto error;
-	}
-
-	dev_info = kzalloc(sizeof(struct msm_snddev_info), GFP_KERNEL);
-	if (!dev_info) {
-		kfree(ecodec);
-		rc = -ENOMEM;
-		goto error;
-	}
-
-	dev_info->name = pdata->name;
-	dev_info->copp_id = pdata->copp_id;
-	dev_info->acdb_id = pdata->acdb_id;
-	dev_info->private_data = (void *) ecodec;
-	dev_info->dev_ops.open = snddev_ecodec_open;
-	dev_info->dev_ops.close = snddev_ecodec_close;
-	dev_info->dev_ops.set_freq = snddev_ecodec_set_freq;
-	dev_info->dev_ops.enable_sidetone = NULL;
-	dev_info->capability = pdata->capability;
-	dev_info->opened = 0;
-
-	msm_snddev_register(dev_info);
-	ecodec->data = pdata;
-	ecodec->sample_rate = 8000; /* Default to 8KHz */
-	 if (pdata->capability & SNDDEV_CAP_RX) {
-		for (i = 0; i < VOC_RX_VOL_ARRAY_NUM; i++) {
-			dev_info->max_voc_rx_vol[i] =
-				pdata->max_voice_rx_vol[i];
-			dev_info->min_voc_rx_vol[i] =
-				pdata->min_voice_rx_vol[i];
-		}
-	}
-error:
-	return rc;
-}
-
-static int snddev_ecodec_remove(struct platform_device *pdev)
-{
-	return 0;
-}
-
-static struct platform_driver snddev_ecodec_driver = {
-	.probe = snddev_ecodec_probe,
-	.remove = snddev_ecodec_remove,
-	.driver = { .name = "msm_snddev_ecodec" }
-};
-
-static int __init snddev_ecodec_init(void)
-{
-	int rc = 0;
-	struct snddev_ecodec_drv_state *ecodec_drv = &snddev_ecodec_drv;
-
-	MM_INFO("snddev_ecodec_init\n");
-	rc = platform_driver_register(&snddev_ecodec_driver);
-	if (IS_ERR_VALUE(rc))
-		goto error_platform_driver;
-	ecodec_drv->ecodec_clk = clk_get(NULL, "ecodec_clk");
-	if (IS_ERR(ecodec_drv->ecodec_clk))
-		goto error_ecodec_clk;
-	ecodec_drv->lpa_core_clk = clk_get(NULL, "lpa_core_clk");
-	if (IS_ERR(ecodec_drv->lpa_core_clk))
-		goto error_lpa_core_clk;
-
-
-	mutex_init(&ecodec_drv->dev_lock);
-	ecodec_drv->rx_active = 0;
-	ecodec_drv->tx_active = 0;
-	return 0;
-
-error_lpa_core_clk:
-	clk_put(ecodec_drv->ecodec_clk);
-error_ecodec_clk:
-	platform_driver_unregister(&snddev_ecodec_driver);
-error_platform_driver:
-
-	MM_ERR("encounter error\n");
-	return -ENODEV;
-}
-
-static void __exit snddev_ecodec_exit(void)
-{
-	struct snddev_ecodec_drv_state *ecodec_drv = &snddev_ecodec_drv;
-
-	platform_driver_unregister(&snddev_ecodec_driver);
-	clk_put(ecodec_drv->ecodec_clk);
-
-	return;
-}
-
-module_init(snddev_ecodec_init);
-module_exit(snddev_ecodec_exit);
-
-MODULE_DESCRIPTION("ECodec Sound Device driver");
-MODULE_VERSION("1.0");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5v2/snddev_icodec.c b/arch/arm/mach-msm/qdsp5v2/snddev_icodec.c
deleted file mode 100644
index cbb0587..0000000
--- a/arch/arm/mach-msm/qdsp5v2/snddev_icodec.c
+++ /dev/null
@@ -1,1218 +0,0 @@
-/* Copyright (c) 2009-2011, The Linux Foundation. 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.
- *
- */
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/mfd/msm-adie-codec.h>
-#include <linux/clk.h>
-#include <linux/err.h>
-#include <linux/debugfs.h>
-#include <linux/pm_qos.h>
-
-#include <asm/uaccess.h>
-#include <mach/qdsp5v2/snddev_icodec.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/qdsp5v2/audio_interct.h>
-#include <mach/qdsp5v2/mi2s.h>
-#include <mach/qdsp5v2/afe.h>
-#include <mach/qdsp5v2/lpa.h>
-#include <mach/qdsp5v2/marimba_profile.h>
-#include <mach/vreg.h>
-#include <mach/pmic.h>
-#include <linux/wakelock.h>
-#include <mach/debug_mm.h>
-#include <mach/rpc_pmapp.h>
-#include <mach/qdsp5v2/audio_acdb_def.h>
-#include <linux/slab.h>
-#include <mach/cpuidle.h>
-
-#define SMPS_AUDIO_PLAYBACK_ID	"AUPB"
-#define SMPS_AUDIO_RECORD_ID	"AURC"
-
-#define SNDDEV_ICODEC_PCM_SZ 32 /* 16 bit / sample stereo mode */
-#define SNDDEV_ICODEC_MUL_FACTOR 3 /* Multi by 8 Shift by 3  */
-#define SNDDEV_ICODEC_CLK_RATE(freq) \
-	(((freq) * (SNDDEV_ICODEC_PCM_SZ)) << (SNDDEV_ICODEC_MUL_FACTOR))
-
-#ifdef CONFIG_DEBUG_FS
-static struct adie_codec_action_unit debug_rx_actions[] =
-		HANDSET_RX_8000_OSR_256;
-
-static struct adie_codec_action_unit debug_tx_lb_actions[] = {
-	{ ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF },
-	{ ADIE_CODEC_ACTION_ENTRY,
-	ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x01)},
-	{ ADIE_CODEC_ACTION_ENTRY,
-	ADIE_CODEC_PACK_ENTRY(0x80, 0x01, 0x00) },
-	{ ADIE_CODEC_ACTION_ENTRY,
-	ADIE_CODEC_PACK_ENTRY(0x8A, 0x30, 0x30)},
-	{ ADIE_CODEC_ACTION_ENTRY,
-	ADIE_CODEC_PACK_ENTRY(0x11, 0xfc, 0xfc)},
-	{ ADIE_CODEC_ACTION_ENTRY,
-	ADIE_CODEC_PACK_ENTRY(0x13, 0xfc, 0x58)},
-	{ ADIE_CODEC_ACTION_ENTRY,
-	ADIE_CODEC_PACK_ENTRY(0x14, 0xff, 0x65)},
-	{ ADIE_CODEC_ACTION_ENTRY,
-	ADIE_CODEC_PACK_ENTRY(0x15, 0xff, 0x64)},
-	{ ADIE_CODEC_ACTION_ENTRY,
-	ADIE_CODEC_PACK_ENTRY(0x82, 0xff, 0x5C)},
-	{ ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY },
-	{ ADIE_CODEC_ACTION_ENTRY,
-	ADIE_CODEC_PACK_ENTRY(0x0D, 0xF0, 0xd0)},
-	{ ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8},
-	{ ADIE_CODEC_ACTION_ENTRY,
-	ADIE_CODEC_PACK_ENTRY(0x83, 0x14, 0x14)},
-	{ ADIE_CODEC_ACTION_ENTRY,
-	ADIE_CODEC_PACK_ENTRY(0x86, 0xff, 0x00)},
-	{ ADIE_CODEC_ACTION_ENTRY,
-	ADIE_CODEC_PACK_ENTRY(0x8A, 0x50, 0x40)},
-	{ ADIE_CODEC_ACTION_ENTRY,
-	ADIE_CODEC_PACK_ENTRY(0x91, 0xFF, 0x01)}, /* Start loop back */
-	{ ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY},
-	{ ADIE_CODEC_ACTION_ENTRY,
-	ADIE_CODEC_PACK_ENTRY(0x8A, 0x10, 0x30)},
-	{ ADIE_CODEC_ACTION_ENTRY,
-	ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)},
-	{ ADIE_CODEC_ACTION_ENTRY,
-	ADIE_CODEC_PACK_ENTRY(0x83, 0x14, 0x00)},
-	{ ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF},
-	{ ADIE_CODEC_ACTION_ENTRY,
-	ADIE_CODEC_PACK_ENTRY(0x11, 0xff, 0x00)}
-};
-
-static struct adie_codec_action_unit debug_tx_actions[] =
-		HANDSET_TX_8000_OSR_256;
-
-static struct adie_codec_hwsetting_entry debug_rx_settings[] = {
-	{
-		.freq_plan = 8000,
-		.osr = 256,
-		.actions = debug_rx_actions,
-		.action_sz = ARRAY_SIZE(debug_rx_actions),
-	}
-};
-
-static struct adie_codec_hwsetting_entry debug_tx_settings[] = {
-	{
-		.freq_plan = 8000,
-		.osr = 256,
-		.actions = debug_tx_actions,
-		.action_sz = ARRAY_SIZE(debug_tx_actions),
-	}
-};
-
-static struct adie_codec_hwsetting_entry debug_tx_lb_settings[] = {
-	{
-		.freq_plan = 8000,
-		.osr = 256,
-		.actions = debug_tx_lb_actions,
-		.action_sz = ARRAY_SIZE(debug_tx_lb_actions),
-	}
-};
-
-static struct adie_codec_dev_profile debug_rx_profile = {
-	.path_type = ADIE_CODEC_RX,
-	.settings = debug_rx_settings,
-	.setting_sz = ARRAY_SIZE(debug_rx_settings),
-};
-
-static struct adie_codec_dev_profile debug_tx_profile = {
-	.path_type = ADIE_CODEC_TX,
-	.settings = debug_tx_settings,
-	.setting_sz = ARRAY_SIZE(debug_tx_settings),
-};
-
-static struct adie_codec_dev_profile debug_tx_lb_profile = {
-	.path_type = ADIE_CODEC_TX,
-	.settings = debug_tx_lb_settings,
-	.setting_sz = ARRAY_SIZE(debug_tx_lb_settings),
-};
-#endif /* CONFIG_DEBUG_FS */
-
-/* Context for each internal codec sound device */
-struct snddev_icodec_state {
-	struct snddev_icodec_data *data;
-	struct adie_codec_path *adie_path;
-	u32 sample_rate;
-	u32 enabled;
-};
-
-/* Global state for the driver */
-struct snddev_icodec_drv_state {
-	struct mutex rx_lock;
-	struct mutex lb_lock;
-	struct mutex tx_lock;
-	u32 rx_active; /* ensure one rx device at a time */
-	u32 tx_active; /* ensure one tx device at a time */
-	struct clk *rx_mclk;
-	struct clk *rx_sclk;
-	struct clk *tx_mclk;
-	struct clk *tx_sclk;
-	struct clk *lpa_codec_clk;
-	struct clk *lpa_core_clk;
-	struct clk *lpa_p_clk;
-	struct lpa_drv *lpa;
-
-	struct pm_qos_request rx_pm_qos_req;
-	struct pm_qos_request tx_pm_qos_req;
-};
-
-static struct snddev_icodec_drv_state snddev_icodec_drv;
-
-static int snddev_icodec_open_rx(struct snddev_icodec_state *icodec)
-{
-	int trc, err;
-	int smps_mode = PMAPP_SMPS_MODE_VOTE_PWM;
-	struct msm_afe_config afe_config;
-	struct snddev_icodec_drv_state *drv = &snddev_icodec_drv;
-	struct lpa_codec_config lpa_config;
-
-	pm_qos_update_request(&drv->rx_pm_qos_req,
-			      msm_cpuidle_get_deep_idle_latency());
-
-	if ((icodec->data->acdb_id == ACDB_ID_HEADSET_SPKR_MONO) ||
-		(icodec->data->acdb_id == ACDB_ID_HEADSET_SPKR_STEREO)) {
-		/* Vote PMAPP_SMPS_MODE_VOTE_PFM for headset */
-		smps_mode = PMAPP_SMPS_MODE_VOTE_PFM;
-		MM_DBG("snddev_icodec_open_rx: PMAPP_SMPS_MODE_VOTE_PFM \n");
-	} else
-		MM_DBG("snddev_icodec_open_rx: PMAPP_SMPS_MODE_VOTE_PWM \n");
-
-	/* Vote for SMPS mode*/
-	err = pmapp_smps_mode_vote(SMPS_AUDIO_PLAYBACK_ID,
-				PMAPP_VREG_S4, smps_mode);
-	if (err != 0)
-		MM_ERR("pmapp_smps_mode_vote error %d\n", err);
-
-	/* enable MI2S RX master block */
-	/* enable MI2S RX bit clock */
-	trc = clk_set_rate(drv->rx_mclk,
-		SNDDEV_ICODEC_CLK_RATE(icodec->sample_rate));
-	if (IS_ERR_VALUE(trc))
-		goto error_invalid_freq;
-	clk_prepare_enable(drv->rx_mclk);
-	clk_prepare_enable(drv->rx_sclk);
-	/* clk_set_rate(drv->lpa_codec_clk, 1); */ /* Remove if use pcom */
-	clk_prepare_enable(drv->lpa_p_clk);
-	clk_prepare_enable(drv->lpa_codec_clk);
-	clk_prepare_enable(drv->lpa_core_clk);
-
-	/* Enable LPA sub system
-	 */
-	drv->lpa = lpa_get();
-	if (!drv->lpa)
-		goto error_lpa;
-	lpa_config.sample_rate = icodec->sample_rate;
-	lpa_config.sample_width = 16;
-	lpa_config.output_interface = LPA_OUTPUT_INTF_WB_CODEC;
-	lpa_config.num_channels = icodec->data->channel_mode;
-	lpa_cmd_codec_config(drv->lpa, &lpa_config);
-
-	/* Set audio interconnect reg to LPA */
-	audio_interct_codec(AUDIO_INTERCT_LPA);
-
-	/* Set MI2S */
-	mi2s_set_codec_output_path((icodec->data->channel_mode == 2 ?
-	MI2S_CHAN_STEREO : MI2S_CHAN_MONO_PACKED), WT_16_BIT);
-
-	if (icodec->data->voltage_on)
-		icodec->data->voltage_on();
-
-	/* Configure ADIE */
-	trc = adie_codec_open(icodec->data->profile, &icodec->adie_path);
-	if (IS_ERR_VALUE(trc))
-		goto error_adie;
-	/* OSR default to 256, can be changed for power optimization
-	 * If OSR is to be changed, need clock API for setting the divider
-	 */
-	adie_codec_setpath(icodec->adie_path, icodec->sample_rate, 256);
-	/* Start AFE */
-	afe_config.sample_rate = icodec->sample_rate / 1000;
-	afe_config.channel_mode = icodec->data->channel_mode;
-	afe_config.volume = AFE_VOLUME_UNITY;
-	trc = afe_enable(AFE_HW_PATH_CODEC_RX, &afe_config);
-	if (IS_ERR_VALUE(trc))
-		goto error_afe;
-	lpa_cmd_enable_codec(drv->lpa, 1);
-	/* Enable ADIE */
-	adie_codec_proceed_stage(icodec->adie_path, ADIE_CODEC_DIGITAL_READY);
-	adie_codec_proceed_stage(icodec->adie_path,
-					ADIE_CODEC_DIGITAL_ANALOG_READY);
-
-	/* Enable power amplifier */
-	if (icodec->data->pamp_on)
-		icodec->data->pamp_on();
-
-	icodec->enabled = 1;
-
-	pm_qos_update_request(&drv->rx_pm_qos_req, PM_QOS_DEFAULT_VALUE);
-	return 0;
-
-error_afe:
-	adie_codec_close(icodec->adie_path);
-	icodec->adie_path = NULL;
-error_adie:
-	lpa_put(drv->lpa);
-error_lpa:
-	clk_disable_unprepare(drv->lpa_p_clk);
-	clk_disable_unprepare(drv->lpa_codec_clk);
-	clk_disable_unprepare(drv->lpa_core_clk);
-	clk_disable_unprepare(drv->rx_sclk);
-	clk_disable_unprepare(drv->rx_mclk);
-error_invalid_freq:
-
-	MM_ERR("encounter error\n");
-
-	pm_qos_update_request(&drv->rx_pm_qos_req, PM_QOS_DEFAULT_VALUE);
-	return -ENODEV;
-}
-
-static int snddev_icodec_open_tx(struct snddev_icodec_state *icodec)
-{
-	int trc;
-	int i, err;
-	struct msm_afe_config afe_config;
-	struct snddev_icodec_drv_state *drv = &snddev_icodec_drv;;
-
-	pm_qos_update_request(&drv->tx_pm_qos_req,
-			      msm_cpuidle_get_deep_idle_latency());
-
-	/* Vote for PWM mode*/
-	err = pmapp_smps_mode_vote(SMPS_AUDIO_RECORD_ID,
-			PMAPP_VREG_S4, PMAPP_SMPS_MODE_VOTE_PWM);
-	if (err != 0)
-		MM_ERR("pmapp_smps_mode_vote error %d\n", err);
-
-	/* Reuse pamp_on for TX platform-specific setup  */
-	if (icodec->data->pamp_on)
-		icodec->data->pamp_on();
-
-	for (i = 0; i < icodec->data->pmctl_id_sz; i++) {
-		pmic_hsed_enable(icodec->data->pmctl_id[i],
-			 PM_HSED_ENABLE_PWM_TCXO);
-	}
-
-	/* enable MI2S TX master block */
-	/* enable MI2S TX bit clock */
-	trc = clk_set_rate(drv->tx_mclk,
-		SNDDEV_ICODEC_CLK_RATE(icodec->sample_rate));
-	if (IS_ERR_VALUE(trc))
-		goto error_invalid_freq;
-	clk_prepare_enable(drv->tx_mclk);
-	clk_prepare_enable(drv->tx_sclk);
-
-	/* Set MI2S */
-	mi2s_set_codec_input_path((icodec->data->channel_mode ==
-				REAL_STEREO_CHANNEL_MODE ? MI2S_CHAN_STEREO :
-				(icodec->data->channel_mode == 2 ?
-				 MI2S_CHAN_STEREO : MI2S_CHAN_MONO_RAW)),
-				WT_16_BIT);
-	/* Configure ADIE */
-	trc = adie_codec_open(icodec->data->profile, &icodec->adie_path);
-	if (IS_ERR_VALUE(trc))
-		goto error_adie;
-	/* Enable ADIE */
-	adie_codec_setpath(icodec->adie_path, icodec->sample_rate, 256);
-	adie_codec_proceed_stage(icodec->adie_path, ADIE_CODEC_DIGITAL_READY);
-	adie_codec_proceed_stage(icodec->adie_path,
-	ADIE_CODEC_DIGITAL_ANALOG_READY);
-
-	/* Start AFE */
-	afe_config.sample_rate = icodec->sample_rate / 1000;
-	afe_config.channel_mode = icodec->data->channel_mode;
-	afe_config.volume = AFE_VOLUME_UNITY;
-	trc = afe_enable(AFE_HW_PATH_CODEC_TX, &afe_config);
-	if (IS_ERR_VALUE(trc))
-		goto error_afe;
-
-
-	icodec->enabled = 1;
-
-	pm_qos_update_request(&drv->tx_pm_qos_req, PM_QOS_DEFAULT_VALUE);
-	return 0;
-
-error_afe:
-	adie_codec_close(icodec->adie_path);
-	icodec->adie_path = NULL;
-error_adie:
-	clk_disable_unprepare(drv->tx_sclk);
-	clk_disable_unprepare(drv->tx_mclk);
-error_invalid_freq:
-
-	/* Disable mic bias */
-	for (i = 0; i < icodec->data->pmctl_id_sz; i++) {
-		pmic_hsed_enable(icodec->data->pmctl_id[i],
-			 PM_HSED_ENABLE_OFF);
-	}
-
-	if (icodec->data->pamp_off)
-		icodec->data->pamp_off();
-
-	MM_ERR("encounter error\n");
-
-	pm_qos_update_request(&drv->tx_pm_qos_req, PM_QOS_DEFAULT_VALUE);
-	return -ENODEV;
-}
-
-static int snddev_icodec_close_lb(struct snddev_icodec_state *icodec)
-{
-	/* Disable power amplifier */
-	if (icodec->data->pamp_off)
-		icodec->data->pamp_off();
-
-	if (icodec->adie_path) {
-		adie_codec_proceed_stage(icodec->adie_path,
-						ADIE_CODEC_DIGITAL_OFF);
-		adie_codec_close(icodec->adie_path);
-		icodec->adie_path = NULL;
-	}
-	if (icodec->data->voltage_off)
-		icodec->data->voltage_off();
-
-	return 0;
-}
-
-static int snddev_icodec_close_rx(struct snddev_icodec_state *icodec)
-{
-	int err;
-	struct snddev_icodec_drv_state *drv = &snddev_icodec_drv;
-
-	pm_qos_update_request(&drv->rx_pm_qos_req,
-			      msm_cpuidle_get_deep_idle_latency());
-
-	/* Remove the vote for SMPS mode*/
-	err = pmapp_smps_mode_vote(SMPS_AUDIO_PLAYBACK_ID,
-			PMAPP_VREG_S4, PMAPP_SMPS_MODE_VOTE_DONTCARE);
-	if (err != 0)
-		MM_ERR("pmapp_smps_mode_vote error %d\n", err);
-
-	/* Disable power amplifier */
-	if (icodec->data->pamp_off)
-		icodec->data->pamp_off();
-
-	/* Disable ADIE */
-	adie_codec_proceed_stage(icodec->adie_path, ADIE_CODEC_DIGITAL_OFF);
-	adie_codec_close(icodec->adie_path);
-	icodec->adie_path = NULL;
-
-	afe_disable(AFE_HW_PATH_CODEC_RX);
-
-	if (icodec->data->voltage_off)
-		icodec->data->voltage_off();
-
-	/* Disable LPA Sub system */
-	lpa_cmd_enable_codec(drv->lpa, 0);
-	lpa_put(drv->lpa);
-
-	/* Disable LPA clocks */
-	clk_disable_unprepare(drv->lpa_p_clk);
-	clk_disable_unprepare(drv->lpa_codec_clk);
-	clk_disable_unprepare(drv->lpa_core_clk);
-
-	/* Disable MI2S RX master block */
-	/* Disable MI2S RX bit clock */
-	clk_disable_unprepare(drv->rx_sclk);
-	clk_disable_unprepare(drv->rx_mclk);
-
-	icodec->enabled = 0;
-
-	pm_qos_update_request(&drv->rx_pm_qos_req, PM_QOS_DEFAULT_VALUE);
-	return 0;
-}
-
-static int snddev_icodec_close_tx(struct snddev_icodec_state *icodec)
-{
-	struct snddev_icodec_drv_state *drv = &snddev_icodec_drv;
-	int i, err;
-
-	pm_qos_update_request(&drv->tx_pm_qos_req,
-			      msm_cpuidle_get_deep_idle_latency());
-
-	/* Remove the vote for SMPS mode*/
-	err = pmapp_smps_mode_vote(SMPS_AUDIO_RECORD_ID,
-			PMAPP_VREG_S4, PMAPP_SMPS_MODE_VOTE_DONTCARE);
-	if (err != 0)
-		MM_ERR("pmapp_smps_mode_vote error %d\n", err);
-
-	afe_disable(AFE_HW_PATH_CODEC_TX);
-
-	/* Disable ADIE */
-	adie_codec_proceed_stage(icodec->adie_path, ADIE_CODEC_DIGITAL_OFF);
-	adie_codec_close(icodec->adie_path);
-	icodec->adie_path = NULL;
-
-	/* Disable MI2S TX master block */
-	/* Disable MI2S TX bit clock */
-	clk_disable_unprepare(drv->tx_sclk);
-	clk_disable_unprepare(drv->tx_mclk);
-
-	/* Disable mic bias */
-	for (i = 0; i < icodec->data->pmctl_id_sz; i++) {
-		pmic_hsed_enable(icodec->data->pmctl_id[i],
-			 PM_HSED_ENABLE_OFF);
-	}
-
-	/* Reuse pamp_off for TX platform-specific setup  */
-	if (icodec->data->pamp_off)
-		icodec->data->pamp_off();
-
-	icodec->enabled = 0;
-
-	pm_qos_update_request(&drv->tx_pm_qos_req, PM_QOS_DEFAULT_VALUE);
-	return 0;
-}
-
-static int snddev_icodec_open_lb(struct snddev_icodec_state *icodec)
-{
-	int trc;
-	trc = adie_codec_open(icodec->data->profile, &icodec->adie_path);
-	if (IS_ERR_VALUE(trc))
-		pr_err("%s: adie codec open failed\n", __func__);
-	else
-		adie_codec_setpath(icodec->adie_path,
-						icodec->sample_rate, 256);
-
-	if (icodec->adie_path)
-		adie_codec_proceed_stage(icodec->adie_path,
-					ADIE_CODEC_DIGITAL_ANALOG_READY);
-	if (icodec->data->pamp_on)
-		icodec->data->pamp_on();
-
-	icodec->enabled = 1;
-	return 0;
-}
-
-static int snddev_icodec_set_device_volume_impl(
-		struct msm_snddev_info *dev_info, u32 volume)
-{
-	struct snddev_icodec_state *icodec;
-	u8 afe_path_id;
-
-	int rc = 0;
-
-	icodec = dev_info->private_data;
-
-	if (icodec->data->capability & SNDDEV_CAP_RX)
-		afe_path_id = AFE_HW_PATH_CODEC_RX;
-	else
-		afe_path_id = AFE_HW_PATH_CODEC_TX;
-
-	if (icodec->data->dev_vol_type & SNDDEV_DEV_VOL_DIGITAL) {
-
-		rc = adie_codec_set_device_digital_volume(icodec->adie_path,
-				icodec->data->channel_mode ==
-						REAL_STEREO_CHANNEL_MODE ?
-					2 : icodec->data->channel_mode, volume);
-		if (rc < 0) {
-			MM_ERR("unable to set_device_digital_volume for"
-				"%s volume in percentage = %u\n",
-				dev_info->name, volume);
-			return rc;
-		}
-
-	} else if (icodec->data->dev_vol_type & SNDDEV_DEV_VOL_ANALOG) {
-		rc = adie_codec_set_device_analog_volume(icodec->adie_path,
-				icodec->data->channel_mode ==
-						REAL_STEREO_CHANNEL_MODE ?
-					2 : icodec->data->channel_mode, volume);
-		if (rc < 0) {
-			MM_ERR("unable to set_device_analog_volume for"
-				"%s volume in percentage = %u\n",
-				dev_info->name, volume);
-			return rc;
-		}
-	}
-	else {
-		MM_ERR("Invalid device volume control\n");
-		return -EPERM;
-	}
-	return rc;
-}
-
-static int snddev_icodec_close(struct msm_snddev_info *dev_info)
-{
-	int rc = 0;
-	struct snddev_icodec_state *icodec;
-	struct snddev_icodec_drv_state *drv = &snddev_icodec_drv;
-	if (!dev_info) {
-		rc = -EINVAL;
-		goto error;
-	}
-
-	icodec = dev_info->private_data;
-
-	if (icodec->data->capability & SNDDEV_CAP_RX) {
-		mutex_lock(&drv->rx_lock);
-		if (!drv->rx_active) {
-			mutex_unlock(&drv->rx_lock);
-			rc = -EPERM;
-			goto error;
-		}
-		rc = snddev_icodec_close_rx(icodec);
-		if (!IS_ERR_VALUE(rc))
-			drv->rx_active = 0;
-		mutex_unlock(&drv->rx_lock);
-	} else if (icodec->data->capability & SNDDEV_CAP_LB) {
-		mutex_lock(&drv->lb_lock);
-		rc = snddev_icodec_close_lb(icodec);
-		mutex_unlock(&drv->lb_lock);
-	} else {
-		mutex_lock(&drv->tx_lock);
-		if (!drv->tx_active) {
-			mutex_unlock(&drv->tx_lock);
-			rc = -EPERM;
-			goto error;
-		}
-		rc = snddev_icodec_close_tx(icodec);
-		if (!IS_ERR_VALUE(rc))
-			drv->tx_active = 0;
-		mutex_unlock(&drv->tx_lock);
-	}
-
-error:
-	return rc;
-}
-
-static int snddev_icodec_open(struct msm_snddev_info *dev_info)
-{
-	int rc = 0;
-	struct snddev_icodec_state *icodec;
-	struct snddev_icodec_drv_state *drv = &snddev_icodec_drv;
-
-	if (!dev_info) {
-		rc = -EINVAL;
-		goto error;
-	}
-
-	icodec = dev_info->private_data;
-
-	if (icodec->data->capability & SNDDEV_CAP_RX) {
-		mutex_lock(&drv->rx_lock);
-		if (drv->rx_active) {
-			mutex_unlock(&drv->rx_lock);
-			rc = -EBUSY;
-			goto error;
-		}
-		rc = snddev_icodec_open_rx(icodec);
-
-		if (!IS_ERR_VALUE(rc)) {
-			drv->rx_active = 1;
-			if ((icodec->data->dev_vol_type & (
-				SNDDEV_DEV_VOL_DIGITAL |
-				SNDDEV_DEV_VOL_ANALOG)))
-				rc = snddev_icodec_set_device_volume_impl(
-						dev_info, dev_info->dev_volume);
-				if (IS_ERR_VALUE(rc)) {
-					MM_ERR("Failed to set device volume"
-						" impl for rx device\n");
-					snddev_icodec_close(dev_info);
-					mutex_unlock(&drv->rx_lock);
-					goto error;
-				}
-		}
-		mutex_unlock(&drv->rx_lock);
-	} else if (icodec->data->capability & SNDDEV_CAP_LB) {
-		mutex_lock(&drv->lb_lock);
-		rc = snddev_icodec_open_lb(icodec);
-		if (!IS_ERR_VALUE(rc)) {
-			if ((icodec->data->dev_vol_type & (
-							SNDDEV_DEV_VOL_DIGITAL |
-							SNDDEV_DEV_VOL_ANALOG)))
-				rc = snddev_icodec_set_device_volume_impl(
-							dev_info,
-							 dev_info->dev_volume);
-				if (rc < 0)
-					MM_ERR("failed to set device volume\n");
-		}
-		mutex_unlock(&drv->lb_lock);
-	} else {
-		mutex_lock(&drv->tx_lock);
-		if (drv->tx_active) {
-			mutex_unlock(&drv->tx_lock);
-			rc = -EBUSY;
-			goto error;
-		}
-		rc = snddev_icodec_open_tx(icodec);
-
-		if (!IS_ERR_VALUE(rc)) {
-			drv->tx_active = 1;
-			if ((icodec->data->dev_vol_type & (
-				SNDDEV_DEV_VOL_DIGITAL |
-				SNDDEV_DEV_VOL_ANALOG)))
-				rc = snddev_icodec_set_device_volume_impl(
-						dev_info, dev_info->dev_volume);
-				if (IS_ERR_VALUE(rc)) {
-					MM_ERR("Failed to set device volume"
-						" impl for tx device\n");
-					snddev_icodec_close(dev_info);
-					mutex_unlock(&drv->tx_lock);
-					goto error;
-				}
-		}
-		mutex_unlock(&drv->tx_lock);
-	}
-error:
-	return rc;
-}
-
-static int snddev_icodec_check_freq(u32 req_freq)
-{
-	int rc = -EINVAL;
-
-	if ((req_freq != 0) && (req_freq >= 8000) && (req_freq <= 48000)) {
-		if ((req_freq == 8000) || (req_freq == 11025) ||
-			(req_freq == 12000) || (req_freq == 16000) ||
-			(req_freq == 22050) || (req_freq == 24000) ||
-			(req_freq == 32000) || (req_freq == 44100) ||
-			(req_freq == 48000)) {
-				rc = 0;
-		} else
-			MM_INFO("Unsupported Frequency:%d\n", req_freq);
-		}
-		return rc;
-}
-
-static int snddev_icodec_set_freq(struct msm_snddev_info *dev_info, u32 rate)
-{
-	int rc;
-	struct snddev_icodec_state *icodec;
-
-	if (!dev_info) {
-		rc = -EINVAL;
-		goto error;
-	}
-
-	icodec = dev_info->private_data;
-	if (adie_codec_freq_supported(icodec->data->profile, rate) != 0) {
-		rc = -EINVAL;
-		goto error;
-	} else {
-		if (snddev_icodec_check_freq(rate) != 0) {
-			rc = -EINVAL;
-			goto error;
-		} else
-			icodec->sample_rate = rate;
-	}
-
-	if (icodec->enabled) {
-		snddev_icodec_close(dev_info);
-		snddev_icodec_open(dev_info);
-	}
-
-	return icodec->sample_rate;
-
-error:
-	return rc;
-}
-
-static int snddev_icodec_enable_sidetone(struct msm_snddev_info *dev_info,
-	u32 enable)
-{
-	int rc = 0;
-	struct snddev_icodec_state *icodec;
-	struct snddev_icodec_drv_state *drv = &snddev_icodec_drv;
-
-	if (!dev_info) {
-		MM_ERR("invalid dev_info\n");
-		rc = -EINVAL;
-		goto error;
-	}
-
-	icodec = dev_info->private_data;
-
-	if (icodec->data->capability & SNDDEV_CAP_RX) {
-		mutex_lock(&drv->rx_lock);
-		if (!drv->rx_active || !dev_info->opened) {
-			MM_ERR("dev not active\n");
-			rc = -EPERM;
-			mutex_unlock(&drv->rx_lock);
-			goto error;
-		}
-		rc = adie_codec_enable_sidetone(icodec->adie_path, enable);
-		mutex_unlock(&drv->rx_lock);
-	} else {
-		rc = -EINVAL;
-		MM_ERR("rx device only\n");
-	}
-
-error:
-	return rc;
-
-}
-
-int snddev_icodec_set_device_volume(struct msm_snddev_info *dev_info,
-		u32 volume)
-{
-	struct snddev_icodec_state *icodec;
-	struct mutex *lock;
-	struct snddev_icodec_drv_state *drv = &snddev_icodec_drv;
-	int rc = -EPERM;
-
-	if (!dev_info) {
-		MM_INFO("device not intilized.\n");
-		return  -EINVAL;
-	}
-
-	icodec = dev_info->private_data;
-
-	if (!(icodec->data->dev_vol_type & (SNDDEV_DEV_VOL_DIGITAL
-				| SNDDEV_DEV_VOL_ANALOG))) {
-
-		MM_INFO("device %s does not support device volume "
-				"control.", dev_info->name);
-		return -EPERM;
-	}
-	dev_info->dev_volume =  volume;
-
-	if (icodec->data->capability & SNDDEV_CAP_RX)
-		lock = &drv->rx_lock;
-	else if (icodec->data->capability & SNDDEV_CAP_LB)
-		lock = &drv->lb_lock;
-	else
-		lock = &drv->tx_lock;
-
-	mutex_lock(lock);
-
-	rc = snddev_icodec_set_device_volume_impl(dev_info,
-			dev_info->dev_volume);
-	mutex_unlock(lock);
-	return rc;
-}
-
-static int snddev_icodec_probe(struct platform_device *pdev)
-{
-	int rc = 0, i;
-	struct snddev_icodec_data *pdata;
-	struct msm_snddev_info *dev_info;
-	struct snddev_icodec_state *icodec;
-
-	if (!pdev || !pdev->dev.platform_data) {
-		printk(KERN_ALERT "Invalid caller \n");
-		rc = -1;
-		goto error;
-	}
-	pdata = pdev->dev.platform_data;
-	if ((pdata->capability & SNDDEV_CAP_RX) &&
-	   (pdata->capability & SNDDEV_CAP_TX)) {
-		MM_ERR("invalid device data either RX or TX\n");
-		goto error;
-	}
-	icodec = kzalloc(sizeof(struct snddev_icodec_state), GFP_KERNEL);
-	if (!icodec) {
-		rc = -ENOMEM;
-		goto error;
-	}
-	dev_info = kmalloc(sizeof(struct msm_snddev_info), GFP_KERNEL);
-	if (!dev_info) {
-		kfree(icodec);
-		rc = -ENOMEM;
-		goto error;
-	}
-
-	dev_info->name = pdata->name;
-	dev_info->copp_id = pdata->copp_id;
-	dev_info->acdb_id = pdata->acdb_id;
-	dev_info->private_data = (void *) icodec;
-	dev_info->dev_ops.open = snddev_icodec_open;
-	dev_info->dev_ops.close = snddev_icodec_close;
-	dev_info->dev_ops.set_freq = snddev_icodec_set_freq;
-	dev_info->dev_ops.set_device_volume = snddev_icodec_set_device_volume;
-	dev_info->capability = pdata->capability;
-	dev_info->opened = 0;
-	msm_snddev_register(dev_info);
-	icodec->data = pdata;
-	icodec->sample_rate = pdata->default_sample_rate;
-	dev_info->sample_rate = pdata->default_sample_rate;
-	if (pdata->capability & SNDDEV_CAP_RX) {
-		for (i = 0; i < VOC_RX_VOL_ARRAY_NUM; i++) {
-			dev_info->max_voc_rx_vol[i] =
-				pdata->max_voice_rx_vol[i];
-			dev_info->min_voc_rx_vol[i] =
-				pdata->min_voice_rx_vol[i];
-		}
-		/*sidetone is enabled only for  the device which
-		property set for side tone*/
-		if (pdata->property & SIDE_TONE_MASK)
-			dev_info->dev_ops.enable_sidetone =
-				snddev_icodec_enable_sidetone;
-		else
-			dev_info->dev_ops.enable_sidetone = NULL;
-	} else {
-		dev_info->dev_ops.enable_sidetone = NULL;
-	}
-
-error:
-	return rc;
-}
-
-static int snddev_icodec_remove(struct platform_device *pdev)
-{
-	return 0;
-}
-
-static struct platform_driver snddev_icodec_driver = {
-  .probe = snddev_icodec_probe,
-  .remove = snddev_icodec_remove,
-  .driver = { .name = "snddev_icodec" }
-};
-
-#ifdef CONFIG_DEBUG_FS
-static struct dentry *debugfs_sdev_dent;
-static struct dentry *debugfs_afelb;
-static struct dentry *debugfs_adielb;
-static struct adie_codec_path *debugfs_rx_adie;
-static struct adie_codec_path *debugfs_tx_adie;
-
-static int snddev_icodec_debug_open(struct inode *inode, struct file *file)
-{
-	file->private_data = inode->i_private;
-	MM_INFO("snddev_icodec: debug intf %s\n", (char *) file->private_data);
-	return 0;
-}
-
-static void debugfs_adie_loopback(u32 loop)
-{
-	struct snddev_icodec_drv_state *drv = &snddev_icodec_drv;
-
-	if (loop) {
-
-		/* enable MI2S RX master block */
-		/* enable MI2S RX bit clock */
-		clk_set_rate(drv->rx_mclk,
-			SNDDEV_ICODEC_CLK_RATE(8000));
-		clk_prepare_enable(drv->rx_mclk);
-		clk_prepare_enable(drv->rx_sclk);
-
-		MM_INFO("configure ADIE RX path\n");
-		/* Configure ADIE */
-		adie_codec_open(&debug_rx_profile, &debugfs_rx_adie);
-		adie_codec_setpath(debugfs_rx_adie, 8000, 256);
-		adie_codec_proceed_stage(debugfs_rx_adie,
-		ADIE_CODEC_DIGITAL_ANALOG_READY);
-
-		MM_INFO("Enable Handset Mic bias\n");
-		pmic_hsed_enable(PM_HSED_CONTROLLER_0, PM_HSED_ENABLE_PWM_TCXO);
-		/* enable MI2S TX master block */
-		/* enable MI2S TX bit clock */
-		clk_set_rate(drv->tx_mclk,
-			SNDDEV_ICODEC_CLK_RATE(8000));
-		clk_prepare_enable(drv->tx_mclk);
-		clk_prepare_enable(drv->tx_sclk);
-
-		MM_INFO("configure ADIE TX path\n");
-		/* Configure ADIE */
-		adie_codec_open(&debug_tx_lb_profile, &debugfs_tx_adie);
-		adie_codec_setpath(debugfs_tx_adie, 8000, 256);
-		adie_codec_proceed_stage(debugfs_tx_adie,
-		ADIE_CODEC_DIGITAL_ANALOG_READY);
-	} else {
-		/* Disable ADIE */
-		adie_codec_proceed_stage(debugfs_rx_adie,
-		ADIE_CODEC_DIGITAL_OFF);
-		adie_codec_close(debugfs_rx_adie);
-		adie_codec_proceed_stage(debugfs_tx_adie,
-		ADIE_CODEC_DIGITAL_OFF);
-		adie_codec_close(debugfs_tx_adie);
-
-		pmic_hsed_enable(PM_HSED_CONTROLLER_0, PM_HSED_ENABLE_OFF);
-
-		/* Disable MI2S RX master block */
-		/* Disable MI2S RX bit clock */
-		clk_disable_unprepare(drv->rx_sclk);
-		clk_disable_unprepare(drv->rx_mclk);
-
-		/* Disable MI2S TX master block */
-		/* Disable MI2S TX bit clock */
-		clk_disable_unprepare(drv->tx_sclk);
-		clk_disable_unprepare(drv->tx_mclk);
-	}
-}
-
-static void debugfs_afe_loopback(u32 loop)
-{
-	int trc;
-	struct msm_afe_config afe_config;
-	struct snddev_icodec_drv_state *drv = &snddev_icodec_drv;
-	struct lpa_codec_config lpa_config;
-
-	if (loop) {
-		/* Vote for SMPS mode*/
-		pmapp_smps_mode_vote(SMPS_AUDIO_PLAYBACK_ID,
-				PMAPP_VREG_S4, PMAPP_SMPS_MODE_VOTE_PWM);
-
-		/* enable MI2S RX master block */
-		/* enable MI2S RX bit clock */
-		trc = clk_set_rate(drv->rx_mclk,
-		SNDDEV_ICODEC_CLK_RATE(8000));
-		if (IS_ERR_VALUE(trc))
-			MM_ERR("failed to set clk rate\n");
-		clk_prepare_enable(drv->rx_mclk);
-		clk_prepare_enable(drv->rx_sclk);
-		clk_prepare_enable(drv->lpa_p_clk);
-		clk_prepare_enable(drv->lpa_codec_clk);
-		clk_prepare_enable(drv->lpa_core_clk);
-		/* Enable LPA sub system
-		 */
-		drv->lpa = lpa_get();
-		if (!drv->lpa)
-			MM_ERR("failed to enable lpa\n");
-		lpa_config.sample_rate = 8000;
-		lpa_config.sample_width = 16;
-		lpa_config.output_interface = LPA_OUTPUT_INTF_WB_CODEC;
-		lpa_config.num_channels = 1;
-		lpa_cmd_codec_config(drv->lpa, &lpa_config);
-		/* Set audio interconnect reg to LPA */
-		audio_interct_codec(AUDIO_INTERCT_LPA);
-		mi2s_set_codec_output_path(MI2S_CHAN_MONO_PACKED, WT_16_BIT);
-		MM_INFO("configure ADIE RX path\n");
-		/* Configure ADIE */
-		adie_codec_open(&debug_rx_profile, &debugfs_rx_adie);
-		adie_codec_setpath(debugfs_rx_adie, 8000, 256);
-		lpa_cmd_enable_codec(drv->lpa, 1);
-
-		/* Start AFE for RX */
-		afe_config.sample_rate = 0x8;
-		afe_config.channel_mode = 1;
-		afe_config.volume = AFE_VOLUME_UNITY;
-		MM_INFO("enable afe\n");
-		trc = afe_enable(AFE_HW_PATH_CODEC_RX, &afe_config);
-		if (IS_ERR_VALUE(trc))
-			MM_ERR("fail to enable afe RX\n");
-		adie_codec_proceed_stage(debugfs_rx_adie,
-		ADIE_CODEC_DIGITAL_READY);
-		adie_codec_proceed_stage(debugfs_rx_adie,
-		ADIE_CODEC_DIGITAL_ANALOG_READY);
-
-		/* Vote for PWM mode*/
-		pmapp_smps_mode_vote(SMPS_AUDIO_RECORD_ID,
-			PMAPP_VREG_S4, PMAPP_SMPS_MODE_VOTE_PWM);
-
-		MM_INFO("Enable Handset Mic bias\n");
-		pmic_hsed_enable(PM_HSED_CONTROLLER_0, PM_HSED_ENABLE_PWM_TCXO);
-
-		/* enable MI2S TX master block */
-		/* enable MI2S TX bit clock */
-		clk_set_rate(drv->tx_mclk,
-			SNDDEV_ICODEC_CLK_RATE(8000));
-		clk_prepare_enable(drv->tx_mclk);
-		clk_prepare_enable(drv->tx_sclk);
-		/* Set MI2S */
-		mi2s_set_codec_input_path(MI2S_CHAN_MONO_PACKED, WT_16_BIT);
-		MM_INFO("configure ADIE TX path\n");
-		/* Configure ADIE */
-		adie_codec_open(&debug_tx_profile, &debugfs_tx_adie);
-		adie_codec_setpath(debugfs_tx_adie, 8000, 256);
-		adie_codec_proceed_stage(debugfs_tx_adie,
-		ADIE_CODEC_DIGITAL_READY);
-		adie_codec_proceed_stage(debugfs_tx_adie,
-		ADIE_CODEC_DIGITAL_ANALOG_READY);
-		/* Start AFE for TX */
-		afe_config.sample_rate = 0x8;
-		afe_config.channel_mode = 1;
-		afe_config.volume = AFE_VOLUME_UNITY;
-		trc = afe_enable(AFE_HW_PATH_CODEC_TX, &afe_config);
-		if (IS_ERR_VALUE(trc))
-			MM_ERR("failed to enable AFE TX\n");
-		/* Set the volume level to non unity, to avoid
-		   loopback effect */
-		afe_device_volume_ctrl(AFE_HW_PATH_CODEC_RX, 0x0500);
-
-		/* enable afe loopback */
-		afe_loopback(1);
-		MM_INFO("AFE loopback enabled\n");
-	} else {
-		/* disable afe loopback */
-		afe_loopback(0);
-		/* Remove the vote for SMPS mode*/
-		pmapp_smps_mode_vote(SMPS_AUDIO_PLAYBACK_ID,
-			PMAPP_VREG_S4, PMAPP_SMPS_MODE_VOTE_DONTCARE);
-
-		/* Disable ADIE */
-		adie_codec_proceed_stage(debugfs_rx_adie,
-		ADIE_CODEC_DIGITAL_OFF);
-		adie_codec_close(debugfs_rx_adie);
-		/* Disable AFE for RX */
-		afe_disable(AFE_HW_PATH_CODEC_RX);
-
-		/* Disable LPA Sub system */
-		lpa_cmd_enable_codec(drv->lpa, 0);
-		lpa_put(drv->lpa);
-
-		/* Disable LPA clocks */
-		clk_disable_unprepare(drv->lpa_p_clk);
-		clk_disable_unprepare(drv->lpa_codec_clk);
-		clk_disable_unprepare(drv->lpa_core_clk);
-
-		/* Disable MI2S RX master block */
-		/* Disable MI2S RX bit clock */
-		clk_disable_unprepare(drv->rx_sclk);
-		clk_disable_unprepare(drv->rx_mclk);
-
-		pmapp_smps_mode_vote(SMPS_AUDIO_RECORD_ID,
-			PMAPP_VREG_S4, PMAPP_SMPS_MODE_VOTE_DONTCARE);
-
-		/* Disable AFE for TX */
-		afe_disable(AFE_HW_PATH_CODEC_TX);
-
-		/* Disable ADIE */
-		adie_codec_proceed_stage(debugfs_tx_adie,
-		ADIE_CODEC_DIGITAL_OFF);
-		adie_codec_close(debugfs_tx_adie);
-		/* Disable MI2S TX master block */
-		/* Disable MI2S TX bit clock */
-		clk_disable_unprepare(drv->tx_sclk);
-		clk_disable_unprepare(drv->tx_mclk);
-		pmic_hsed_enable(PM_HSED_CONTROLLER_0, PM_HSED_ENABLE_OFF);
-		MM_INFO("AFE loopback disabled\n");
-	}
-}
-
-static ssize_t snddev_icodec_debug_write(struct file *filp,
-	const char __user *ubuf, size_t cnt, loff_t *ppos)
-{
-	char *lb_str = filp->private_data;
-	char cmd;
-
-	if (get_user(cmd, ubuf))
-		return -EFAULT;
-
-	MM_INFO("%s %c\n", lb_str, cmd);
-
-	if (!strcmp(lb_str, "adie_loopback")) {
-		switch (cmd) {
-		case '1':
-			debugfs_adie_loopback(1);
-			break;
-		case '0':
-			debugfs_adie_loopback(0);
-			break;
-		}
-	} else if (!strcmp(lb_str, "afe_loopback")) {
-		switch (cmd) {
-		case '1':
-			debugfs_afe_loopback(1);
-			break;
-		case '0':
-			debugfs_afe_loopback(0);
-			break;
-		}
-	}
-
-	return cnt;
-}
-
-static const struct file_operations snddev_icodec_debug_fops = {
-	.open = snddev_icodec_debug_open,
-	.write = snddev_icodec_debug_write
-};
-#endif
-
-static int __init snddev_icodec_init(void)
-{
-	s32 rc;
-	struct snddev_icodec_drv_state *icodec_drv = &snddev_icodec_drv;
-
-	rc = platform_driver_register(&snddev_icodec_driver);
-	if (IS_ERR_VALUE(rc))
-		goto error_platform_driver;
-	icodec_drv->rx_mclk = clk_get(NULL, "mi2s_codec_rx_m_clk");
-	if (IS_ERR(icodec_drv->rx_mclk))
-		goto error_rx_mclk;
-	icodec_drv->rx_sclk = clk_get(NULL, "mi2s_codec_rx_s_clk");
-	if (IS_ERR(icodec_drv->rx_sclk))
-		goto error_rx_sclk;
-	icodec_drv->tx_mclk = clk_get(NULL, "mi2s_codec_tx_m_clk");
-	if (IS_ERR(icodec_drv->tx_mclk))
-		goto error_tx_mclk;
-	icodec_drv->tx_sclk = clk_get(NULL, "mi2s_codec_tx_s_clk");
-	if (IS_ERR(icodec_drv->tx_sclk))
-		goto error_tx_sclk;
-	icodec_drv->lpa_codec_clk = clk_get(NULL, "lpa_codec_clk");
-	if (IS_ERR(icodec_drv->lpa_codec_clk))
-		goto error_lpa_codec_clk;
-	icodec_drv->lpa_core_clk = clk_get(NULL, "lpa_core_clk");
-	if (IS_ERR(icodec_drv->lpa_core_clk))
-		goto error_lpa_core_clk;
-	icodec_drv->lpa_p_clk = clk_get(NULL, "lpa_pclk");
-	if (IS_ERR(icodec_drv->lpa_p_clk))
-		goto error_lpa_p_clk;
-
-#ifdef CONFIG_DEBUG_FS
-	debugfs_sdev_dent = debugfs_create_dir("snddev_icodec", 0);
-	if (debugfs_sdev_dent) {
-		debugfs_afelb = debugfs_create_file("afe_loopback",
-		S_IFREG | S_IWUGO, debugfs_sdev_dent,
-		(void *) "afe_loopback", &snddev_icodec_debug_fops);
-		debugfs_adielb = debugfs_create_file("adie_loopback",
-		S_IFREG | S_IWUGO, debugfs_sdev_dent,
-		(void *) "adie_loopback", &snddev_icodec_debug_fops);
-	}
-#endif
-	mutex_init(&icodec_drv->rx_lock);
-	mutex_init(&icodec_drv->lb_lock);
-	mutex_init(&icodec_drv->tx_lock);
-	icodec_drv->rx_active = 0;
-	icodec_drv->tx_active = 0;
-	icodec_drv->lpa = NULL;
-	pm_qos_add_request(&icodec_drv->tx_pm_qos_req, PM_QOS_CPU_DMA_LATENCY,
-				PM_QOS_DEFAULT_VALUE);
-	pm_qos_add_request(&icodec_drv->rx_pm_qos_req, PM_QOS_CPU_DMA_LATENCY,
-				PM_QOS_DEFAULT_VALUE);
-	return 0;
-
-error_lpa_p_clk:
-	clk_put(icodec_drv->lpa_core_clk);
-error_lpa_core_clk:
-	clk_put(icodec_drv->lpa_codec_clk);
-error_lpa_codec_clk:
-	clk_put(icodec_drv->tx_sclk);
-error_tx_sclk:
-	clk_put(icodec_drv->tx_mclk);
-error_tx_mclk:
-	clk_put(icodec_drv->rx_sclk);
-error_rx_sclk:
-	clk_put(icodec_drv->rx_mclk);
-error_rx_mclk:
-	platform_driver_unregister(&snddev_icodec_driver);
-error_platform_driver:
-
-	MM_ERR("encounter error\n");
-	return -ENODEV;
-}
-
-static void __exit snddev_icodec_exit(void)
-{
-	struct snddev_icodec_drv_state *icodec_drv = &snddev_icodec_drv;
-
-#ifdef CONFIG_DEBUG_FS
-	if (debugfs_afelb)
-		debugfs_remove(debugfs_afelb);
-	if (debugfs_adielb)
-		debugfs_remove(debugfs_adielb);
-	if (debugfs_sdev_dent)
-		debugfs_remove(debugfs_sdev_dent);
-#endif
-	platform_driver_unregister(&snddev_icodec_driver);
-
-	clk_put(icodec_drv->rx_sclk);
-	clk_put(icodec_drv->rx_mclk);
-	clk_put(icodec_drv->tx_sclk);
-	clk_put(icodec_drv->tx_mclk);
-	return;
-}
-
-module_init(snddev_icodec_init);
-module_exit(snddev_icodec_exit);
-
-MODULE_DESCRIPTION("ICodec Sound Device driver");
-MODULE_VERSION("1.0");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5v2/snddev_mi2s.c b/arch/arm/mach-msm/qdsp5v2/snddev_mi2s.c
deleted file mode 100644
index 7f4ee26..0000000
--- a/arch/arm/mach-msm/qdsp5v2/snddev_mi2s.c
+++ /dev/null
@@ -1,405 +0,0 @@
-/* Copyright (c) 2010, The Linux Foundation. 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.
- */
-
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/clk.h>
-#include <linux/err.h>
-#include <linux/io.h>
-#include <linux/uaccess.h>
-#include <linux/slab.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/qdsp5v2/audio_interct.h>
-#include <mach/qdsp5v2/mi2s.h>
-#include <mach/qdsp5v2/afe.h>
-#include <mach/debug_mm.h>
-#include <mach/qdsp5v2/snddev_mi2s.h>
-
-/* Global state for the driver */
-struct snddev_mi2s_drv_state {
-	struct clk *mclk;
-	struct clk *sclk;
-	struct mutex lock;
-	u8 sd_lines_used;
-	u8 clocks_enabled;
-};
-
-static struct snddev_mi2s_drv_state snddev_mi2s_drv;
-
-static int snddev_mi2s_open_tx(struct msm_snddev_info *dev_info)
-{
-	u8 channels;
-	struct msm_afe_config afe_config;
-	int rc;
-	struct snddev_mi2s_data *snddev_mi2s_data = dev_info->private_data;
-
-	MM_DBG("%s: channel_mode = %u sd_line_mask = 0x%x "
-		"default_sample_rate = %u\n", __func__,
-		snddev_mi2s_data->channel_mode, snddev_mi2s_data->sd_lines,
-		snddev_mi2s_data->default_sample_rate);
-
-	if (snddev_mi2s_data->channel_mode == 2) {
-		channels = MI2S_CHAN_STEREO;
-	} else {
-		MM_ERR("%s: Invalid number of channels = %u\n", __func__,
-			snddev_mi2s_data->channel_mode);
-		return -EINVAL;
-	}
-
-	/* Set MI2S */
-	mi2s_set_hdmi_input_path(channels, WT_16_BIT,
-				 snddev_mi2s_data->sd_lines);
-
-	afe_config.sample_rate = snddev_mi2s_data->default_sample_rate / 1000;
-	afe_config.channel_mode = snddev_mi2s_data->channel_mode;
-	afe_config.volume = AFE_VOLUME_UNITY;
-	rc = afe_enable(AFE_HW_PATH_MI2S_TX, &afe_config);
-
-	if (IS_ERR_VALUE(rc)) {
-		MM_ERR("%s: afe_enable failed for AFE_HW_PATH_MI2S_TX "
-		       "rc = %d\n", __func__, rc);
-		return -ENODEV;
-	}
-
-	/* Enable audio path */
-	if (snddev_mi2s_data->route)
-		snddev_mi2s_data->route();
-
-	return 0;
-}
-
-static int snddev_mi2s_open_rx(struct msm_snddev_info *dev_info)
-{
-	int rc;
-	struct msm_afe_config afe_config;
-	u8 channels;
-	struct snddev_mi2s_data *snddev_mi2s_data = dev_info->private_data;
-
-	MM_DBG("%s: channel_mode = %u sd_line_mask = 0x%x "
-		"default_sample_rate = %u\n", __func__,
-		snddev_mi2s_data->channel_mode, snddev_mi2s_data->sd_lines,
-		snddev_mi2s_data->default_sample_rate);
-
-	if (snddev_mi2s_data->channel_mode == 2)
-		channels = MI2S_CHAN_STEREO;
-	else if (snddev_mi2s_data->channel_mode == 4)
-		channels = MI2S_CHAN_4CHANNELS;
-	else if (snddev_mi2s_data->channel_mode == 6)
-		channels = MI2S_CHAN_6CHANNELS;
-	else if (snddev_mi2s_data->channel_mode == 8)
-		channels = MI2S_CHAN_8CHANNELS;
-	else
-		channels = MI2S_CHAN_MONO_RAW;
-
-	/* Set MI2S */
-	mi2s_set_hdmi_output_path(channels, WT_16_BIT,
-				  snddev_mi2s_data->sd_lines);
-
-	/* Start AFE */
-	afe_config.sample_rate = snddev_mi2s_data->default_sample_rate / 1000;
-	afe_config.channel_mode = snddev_mi2s_data->channel_mode;
-	afe_config.volume = AFE_VOLUME_UNITY;
-	rc = afe_enable(AFE_HW_PATH_MI2S_RX, &afe_config);
-
-	if (IS_ERR_VALUE(rc)) {
-		MM_ERR("%s: encounter error\n", __func__);
-		return -ENODEV;
-	}
-
-	/* Enable audio path */
-	if (snddev_mi2s_data->route)
-		snddev_mi2s_data->route();
-
-	MM_DBG("%s: enabled %s \n", __func__, snddev_mi2s_data->name);
-
-	return 0;
-}
-
-static int snddev_mi2s_open(struct msm_snddev_info *dev_info)
-{
-	int rc = 0;
-	struct snddev_mi2s_drv_state *drv = &snddev_mi2s_drv;
-	u32 dir;
-	struct snddev_mi2s_data *snddev_mi2s_data = dev_info->private_data;
-
-	if (!dev_info) {
-		MM_ERR("%s:  msm_snddev_info is null \n", __func__);
-		return -EINVAL;
-	}
-
-	mutex_lock(&drv->lock);
-
-	if (drv->sd_lines_used & snddev_mi2s_data->sd_lines) {
-		MM_ERR("%s: conflict in SD data line. can not use the device\n",
-		       __func__);
-		mutex_unlock(&drv->lock);
-		return -EBUSY;
-	}
-
-	if (!drv->clocks_enabled) {
-
-		rc = mi2s_config_clk_gpio();
-		if (rc) {
-			MM_ERR("%s: mi2s GPIO config failed for %s\n",
-			       __func__, snddev_mi2s_data->name);
-			mutex_unlock(&drv->lock);
-			return -EIO;
-		}
-		clk_prepare_enable(drv->mclk);
-		clk_prepare_enable(drv->sclk);
-		drv->clocks_enabled = 1;
-		MM_DBG("%s: clks enabled\n", __func__);
-	} else
-		MM_DBG("%s: clks already enabled\n", __func__);
-
-	if (snddev_mi2s_data->capability & SNDDEV_CAP_RX) {
-
-		dir = DIR_RX;
-		rc = mi2s_config_data_gpio(dir, snddev_mi2s_data->sd_lines);
-
-		if (rc) {
-			rc = -EIO;
-			MM_ERR("%s: mi2s GPIO config failed for %s\n",
-			       __func__, snddev_mi2s_data->name);
-			goto mi2s_data_gpio_failure;
-		}
-
-		MM_DBG("%s: done gpio config rx SD lines\n", __func__);
-
-		rc = snddev_mi2s_open_rx(dev_info);
-
-		if (IS_ERR_VALUE(rc)) {
-			MM_ERR(" snddev_mi2s_open_rx failed \n");
-			goto mi2s_cleanup_open;
-		}
-
-		drv->sd_lines_used |= snddev_mi2s_data->sd_lines;
-
-		MM_DBG("%s: sd_lines_used = 0x%x\n", __func__,
-			drv->sd_lines_used);
-		mutex_unlock(&drv->lock);
-
-	} else {
-		dir = DIR_TX;
-		rc = mi2s_config_data_gpio(dir, snddev_mi2s_data->sd_lines);
-
-		if (rc) {
-			rc = -EIO;
-			MM_ERR("%s: mi2s GPIO config failed for %s\n",
-			       __func__, snddev_mi2s_data->name);
-			goto mi2s_data_gpio_failure;
-		}
-		MM_DBG("%s: done data line gpio config for %s\n",
-			__func__, snddev_mi2s_data->name);
-
-		rc = snddev_mi2s_open_tx(dev_info);
-
-		if (IS_ERR_VALUE(rc)) {
-			MM_ERR(" snddev_mi2s_open_tx failed \n");
-			goto mi2s_cleanup_open;
-		}
-
-		drv->sd_lines_used |= snddev_mi2s_data->sd_lines;
-		MM_DBG("%s: sd_lines_used = 0x%x\n", __func__,
-			drv->sd_lines_used);
-		mutex_unlock(&drv->lock);
-	}
-
-	return 0;
-
-mi2s_cleanup_open:
-	mi2s_unconfig_data_gpio(dir, snddev_mi2s_data->sd_lines);
-
-	/* Disable audio path */
-	if (snddev_mi2s_data->deroute)
-		snddev_mi2s_data->deroute();
-
-mi2s_data_gpio_failure:
-	if (!drv->sd_lines_used) {
-		clk_disable_unprepare(drv->sclk);
-		clk_disable_unprepare(drv->mclk);
-		drv->clocks_enabled = 0;
-		mi2s_unconfig_clk_gpio();
-	}
-	mutex_unlock(&drv->lock);
-	return rc;
-}
-
-static int snddev_mi2s_close(struct msm_snddev_info *dev_info)
-{
-	struct snddev_mi2s_drv_state *drv = &snddev_mi2s_drv;
-	int dir;
-	struct snddev_mi2s_data *snddev_mi2s_data = dev_info->private_data;
-
-	if (!dev_info) {
-		MM_ERR("%s:  msm_snddev_info is null \n", __func__);
-		return -EINVAL;
-	}
-
-	if (!dev_info->opened) {
-		MM_ERR(" %s: calling close device with out opening the"
-		       " device \n", __func__);
-		return -EIO;
-	}
-
-	mutex_lock(&drv->lock);
-
-	drv->sd_lines_used &= ~snddev_mi2s_data->sd_lines;
-
-	MM_DBG("%s: sd_lines in use = 0x%x\n", __func__, drv->sd_lines_used);
-
-	if (snddev_mi2s_data->capability & SNDDEV_CAP_RX) {
-		dir = DIR_RX;
-		afe_disable(AFE_HW_PATH_MI2S_RX);
-	} else {
-		dir = DIR_TX;
-		afe_disable(AFE_HW_PATH_MI2S_TX);
-	}
-
-	mi2s_unconfig_data_gpio(dir, snddev_mi2s_data->sd_lines);
-
-	if (!drv->sd_lines_used) {
-		clk_disable_unprepare(drv->sclk);
-		clk_disable_unprepare(drv->mclk);
-		drv->clocks_enabled = 0;
-		mi2s_unconfig_clk_gpio();
-	}
-
-	/* Disable audio path */
-	if (snddev_mi2s_data->deroute)
-		snddev_mi2s_data->deroute();
-
-	mutex_unlock(&drv->lock);
-
-	return 0;
-}
-
-static int snddev_mi2s_set_freq(struct msm_snddev_info *dev_info, u32 req_freq)
-{
-	if (req_freq != 48000) {
-		MM_DBG("%s: Unsupported Frequency:%d\n", __func__, req_freq);
-		return -EINVAL;
-	}
-	return 48000;
-}
-
-static int snddev_mi2s_probe(struct platform_device *pdev)
-{
-	int rc = 0;
-	struct snddev_mi2s_data *pdata;
-	struct msm_snddev_info *dev_info;
-
-	if (!pdev || !pdev->dev.platform_data) {
-		printk(KERN_ALERT "Invalid caller \n");
-		return -ENODEV;
-	}
-
-	pdata = pdev->dev.platform_data;
-	if ((pdata->capability & SNDDEV_CAP_RX) &&
-	    (pdata->capability & SNDDEV_CAP_TX)) {
-		MM_ERR("%s: invalid device data either RX or TX\n", __func__);
-		return -ENODEV;
-	}
-
-	dev_info = kzalloc(sizeof(struct msm_snddev_info), GFP_KERNEL);
-	if (!dev_info) {
-		MM_ERR("%s: uneable to allocate memeory for msm_snddev_info \n",
-		       __func__);
-
-		return -ENOMEM;
-	}
-
-	dev_info->name = pdata->name;
-	dev_info->copp_id = pdata->copp_id;
-	dev_info->acdb_id = pdata->acdb_id;
-	dev_info->private_data = (void *)pdata;
-	dev_info->dev_ops.open = snddev_mi2s_open;
-	dev_info->dev_ops.close = snddev_mi2s_close;
-	dev_info->dev_ops.set_freq = snddev_mi2s_set_freq;
-	dev_info->capability = pdata->capability;
-	dev_info->opened = 0;
-	msm_snddev_register(dev_info);
-	dev_info->sample_rate = pdata->default_sample_rate;
-
-	MM_DBG("%s: probe done for %s\n", __func__, pdata->name);
-	return rc;
-}
-
-static int snddev_mi2s_remove(struct platform_device *pdev)
-{
-	return 0;
-}
-
-static struct platform_driver snddev_mi2s_driver = {
-	.probe = snddev_mi2s_probe,
-	.remove = snddev_mi2s_remove,
-	.driver = {.name = "snddev_mi2s"}
-};
-
-static int __init snddev_mi2s_init(void)
-{
-	s32 rc;
-	struct snddev_mi2s_drv_state *drv = &snddev_mi2s_drv;
-
-	rc = platform_driver_register(&snddev_mi2s_driver);
-	if (IS_ERR_VALUE(rc)) {
-
-		MM_ERR("%s: platform_driver_register failed  \n", __func__);
-		goto error_platform_driver;
-	}
-
-	drv->mclk = clk_get(NULL, "mi2s_m_clk");
-	if (IS_ERR(drv->mclk)) {
-		MM_ERR("%s:  clk_get mi2s_mclk failed  \n", __func__);
-		goto error_mclk;
-	}
-
-	drv->sclk = clk_get(NULL, "mi2s_s_clk");
-	if (IS_ERR(drv->sclk)) {
-		MM_ERR("%s:  clk_get mi2s_sclk failed  \n", __func__);
-
-		goto error_sclk;
-	}
-
-	mutex_init(&drv->lock);
-
-	MM_DBG("snddev_mi2s_init : done \n");
-
-	return 0;
-
-error_sclk:
-	clk_put(drv->mclk);
-error_mclk:
-	platform_driver_unregister(&snddev_mi2s_driver);
-error_platform_driver:
-
-	MM_ERR("%s: encounter error\n", __func__);
-	return -ENODEV;
-}
-
-static void __exit snddev_mi2s_exit(void)
-{
-	struct snddev_mi2s_drv_state *drv = &snddev_mi2s_drv;
-
-	platform_driver_unregister(&snddev_mi2s_driver);
-
-	clk_put(drv->sclk);
-	clk_put(drv->mclk);
-	return;
-}
-
-module_init(snddev_mi2s_init);
-module_exit(snddev_mi2s_exit);
-
-MODULE_DESCRIPTION("mi2s Sound Device driver");
-MODULE_VERSION("1.0");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5v2/snddev_virtual.c b/arch/arm/mach-msm/qdsp5v2/snddev_virtual.c
deleted file mode 100644
index aa1d557..0000000
--- a/arch/arm/mach-msm/qdsp5v2/snddev_virtual.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/* Copyright (c) 2010, The Linux Foundation. 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/err.h>
-#include <asm/uaccess.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/qdsp5v2/snddev_virtual.h>
-#include <mach/debug_mm.h>
-#include <linux/slab.h>
-
-static int snddev_virtual_open(struct msm_snddev_info *dev_info)
-{
-	int rc = 0;
-
-	if (!dev_info)
-		rc = -EINVAL;
-	return rc;
-}
-
-static int snddev_virtual_close(struct msm_snddev_info *dev_info)
-{
-	int rc = 0;
-
-	if (!dev_info)
-		rc = -EINVAL;
-	return rc;
-}
-
-static int snddev_virtual_set_freq(struct msm_snddev_info *dev_info, u32 rate)
-{
-	int rc = 0;
-
-	if (!dev_info)
-		rc = -EINVAL;
-	return rate;
-}
-
-static int snddev_virtual_probe(struct platform_device *pdev)
-{
-	int rc = 0;
-	struct snddev_virtual_data *pdata;
-	struct msm_snddev_info *dev_info;
-
-	if (!pdev || !pdev->dev.platform_data) {
-		MM_ERR("Invalid caller\n");
-		rc = -EPERM;
-		goto error;
-	}
-	pdata = pdev->dev.platform_data;
-
-	dev_info = kmalloc(sizeof(struct msm_snddev_info), GFP_KERNEL);
-	if (!dev_info) {
-		rc = -ENOMEM;
-		goto error;
-	}
-
-	dev_info->name = pdata->name;
-	dev_info->copp_id = pdata->copp_id;
-	dev_info->acdb_id = pdata->acdb_id;
-	dev_info->private_data = (void *) NULL;
-	dev_info->dev_ops.open = snddev_virtual_open;
-	dev_info->dev_ops.close = snddev_virtual_close;
-	dev_info->dev_ops.set_freq = snddev_virtual_set_freq;
-	dev_info->capability = pdata->capability;
-	dev_info->sample_rate = 8000;
-	dev_info->opened = 0;
-	dev_info->sessions = 0;
-
-	msm_snddev_register(dev_info);
-
-error:
-	return rc;
-}
-
-static int snddev_virtual_remove(struct platform_device *pdev)
-{
-	return 0;
-}
-
-static struct platform_driver snddev_virtual_driver = {
-	.probe = snddev_virtual_probe,
-	.remove = snddev_virtual_remove,
-	.driver = { .name = "snddev_virtual" }
-};
-
-static int __init snddev_virtual_init(void)
-{
-	int rc = 0;
-
-	MM_DBG(" snddev_virtual_init \n");
-	rc = platform_driver_register(&snddev_virtual_driver);
-	if (IS_ERR_VALUE(rc)) {
-		MM_ERR("platform driver register failure\n");
-		return -ENODEV;
-	}
-	return 0;
-}
-
-static void __exit snddev_virtual_exit(void)
-{
-	platform_driver_unregister(&snddev_virtual_driver);
-
-	return;
-}
-
-module_init(snddev_virtual_init);
-module_exit(snddev_virtual_exit);
-
-MODULE_DESCRIPTION("Virtual Sound Device driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp5v2/timpani_profile_7x30.h b/arch/arm/mach-msm/qdsp5v2/timpani_profile_7x30.h
deleted file mode 100644
index e4cf131..0000000
--- a/arch/arm/mach-msm/qdsp5v2/timpani_profile_7x30.h
+++ /dev/null
@@ -1,623 +0,0 @@
-/* Copyright (c) 2010-2011, The Linux Foundation. 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.
- *
- */
-
-#ifndef __MACH_QDSP5_V2_TIMPANI_PROFILE_H__
-#define __MACH_QDSP5_V2_MTIMPANI_PROFILE_H__
-
-/*
- * TX Device Profiles
- */
-
-/* Analog MIC */
-/* AMIC Primary mono */
-#define AMIC_PRI_MONO_8000_OSR_256 \
-	{{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0xD0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0xBC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x1E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x99, 0x0F, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x04, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8b, 0xff, 0xE6)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8c, 0x03, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAB, 0x09, 0x09)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-/* Headset MIC */
-#define AMIC1_HEADSET_TX_MONO_PRIMARY_OSR256 \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x1E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x99, 0x0F, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0xC8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0xBC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8 }, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x04, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8b, 0xff, 0xE7)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8c, 0x03, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0x00)} }
-
-/*
- * RX Device Profiles
- */
-
-/* RX EAR */
-#define EAR_PRI_MONO_8000_OSR_256 \
-	{{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0F)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x97, 0xFF, 0x01)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0xFF, 0x4C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0E)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x03, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x39, 0x01, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-/* RX SPEAKER */
-#define SPEAKER_PRI_STEREO_48000_OSR_256 \
-	{{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x6C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x08)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x1388}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x1388}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0xF8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x24, 0x24)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x10)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x05, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x24, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF},       \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} };
-
-/*
- * RX HPH PRIMARY
- */
-
-/* RX HPH CLASS AB CAPLESS */
-
-#define HEADSET_AB_CPLS_48000_OSR_256 \
-	{{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x6C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x55)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0xFF, 0x29)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xBB8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0xF5)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0xFE, 0xC8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x27, 0x24)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x04)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-/* AMIC dual */
-#define AMIC_DUAL_8000_OSR_256 \
-	{{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x1E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x99, 0x0F, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0xD0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xFF, 0xC2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0xBC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8 }, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8b, 0xff, 0xCE)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB4, 0xFF, 0xCE)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8c, 0xFF, 0x5A)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0E, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-/* TTY RX */
-#define TTY_HEADSET_MONO_RX_8000_OSR_256 \
-	{{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x97, 0xFF, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x06)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x01)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x4C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x45)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0xFF, 0x29)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xBB8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0xC5)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0xFE, 0xC8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x27, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x04)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-/* TTY TX */
-#define TTY_HEADSET_MONO_TX_8000_OSR_256 \
-	{{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0xFF, 0x1E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x93, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x99, 0x0F, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x9F, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0xA8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0xBC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0xBC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x65)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xBB8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x04, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x0D, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x14, 0xFF, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x11, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x12, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HEADSET_RX_CAPLESS_48000_OSR_256 \
-	{{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x4e)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x04, 0xff, 0xBC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x64)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x25, 0x0F, 0x0B)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xfc, 0xfc)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xff, 0xa2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0xFF, 0xab)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x80)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0xf0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x23, 0xff, 0x20)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3B, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xff, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0f, 0x0c)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8a, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3b, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3c, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x34, 0xf0, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x80, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HEADSET_STEREO_SPEAKER_STEREO_RX_CAPLESS_48000_OSR_256 \
-	{{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x6C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x55)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0xFF, 0x29)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x1388}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0xF5)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x48)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x1388}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0xF8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x24, 0x24)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x27, 0x24)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x04)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x24, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF},	\
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HS_DMIC2_STEREO_8000_OSR_256 \
-	{{ADIE_CODEC_ACTION_DELAY_WAIT, 0xbb8 }, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x05, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x82, 0x1F, 0x1E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x0C, 0x0C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x92, 0x3F, 0x19)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0x3F, 0x24)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x39, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA8, 0x0F, 0x0E)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xAB, 0x3F, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x86, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x87, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xC0)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0xF0, 0xF0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0xC0, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x92, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x94, 0xFF, 0x1B)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HPH_PRI_AB_LEG_STEREO \
-	{{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x6C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x09)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x59)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0x186A0}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0xF9)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x27, 0x27)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x10)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define HPH_PRI_D_LEG_STEREO \
-	{{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x80, 0x02, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xA3, 0x02, 0x02)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x84, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x85, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x0C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x81, 0xFF, 0x0E)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x83, 0x03, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x21, 0xFF, 0x60)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x22, 0xFF, 0xE1)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x24, 0x6F, 0x6C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x26, 0xFF, 0xD0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2D, 0xFF, 0x6F)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2E, 0xFF, 0x55)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3F, 0xFF, 0x0F)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x40, 0xFF, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x41, 0x08, 0x08)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x42, 0xFF, 0xBB)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x43, 0xFF, 0xF2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x44, 0xF7, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x45, 0xFF, 0xFF)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x46, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x47, 0xFF, 0xF2)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x48, 0xF7, 0x37)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x49, 0xFF, 0xFF)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4A, 0xFF, 0x77)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0xFF, 0x8C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x0F, 0x0A)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 300000}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x0F, 0x0F)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x04)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3E, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x0F, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define LB_AUXPGA_HPH_AB_CPLS_STEREO \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2F, 0xFF, 0x44)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x30, 0xFF, 0x92)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFD, 0x05)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFD, 0x55)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xFF, 0xAA)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xBB8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFD, 0xF5)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x4C, 0xFF, 0x29)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0x90, 0x90)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x04)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x04)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE2, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE3, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0x30, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3C, 0xFF, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0xFD, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#define LB_AUXPGA_LO_STEREO \
-	{{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_READY},	\
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x2F, 0xFF, 0x44)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x30, 0xFF, 0x92)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x08)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xBB8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x58)}, \
-	{ADIE_CODEC_ACTION_DELAY_WAIT, 0xBB8}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0xF8)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0xF0, 0xF0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x38, 0xFF, 0xAA)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x90, 0x90)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0xF0, 0x30)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xB7, 0x01, 0x01)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x10)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x10)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_ANALOG_READY}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0xF0, 0xF0)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x8A, 0x0F, 0x03)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x1C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFE, 0x3C)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE0, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0xE1, 0xFC, 0xAC)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x33, 0xF0, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x32, 0xF8, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x31, 0x01, 0x00)}, \
-	{ADIE_CODEC_ACTION_ENTRY, ADIE_CODEC_PACK_ENTRY(0x3A, 0x90, 0x00)}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_ANALOG_OFF}, \
-	{ADIE_CODEC_ACTION_STAGE_REACHED, ADIE_CODEC_DIGITAL_OFF} }
-
-#endif
diff --git a/arch/arm/mach-msm/qdsp5v2/voice.c b/arch/arm/mach-msm/qdsp5v2/voice.c
deleted file mode 100644
index 1ac79d4..0000000
--- a/arch/arm/mach-msm/qdsp5v2/voice.c
+++ /dev/null
@@ -1,752 +0,0 @@
-/* Copyright (c) 2009-2011, The Linux Foundation. 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.
- *
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/fs.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/msm_audio.h>
-#include <mach/qdsp5v2/audio_dev_ctl.h>
-#include <mach/dal.h>
-#include <linux/kthread.h>
-#include <linux/completion.h>
-#include <linux/wait.h>
-#include <mach/qdsp5v2/voice.h>
-#include <mach/debug_mm.h>
-
-struct voice_data {
-	void *handle; /* DALRPC handle */
-	void *cb_handle; /* DALRPC callback handle */
-	int network; /* Network information */
-	int dev_state;/*READY, CHANGE, REL_DONE,INIT*/
-	int voc_state;/*INIT, CHANGE, RELEASE, ACQUIRE */
-	struct mutex voc_lock;
-	struct mutex vol_lock;
-	int voc_event;
-	int dev_event;
-	atomic_t rel_start_flag;
-	atomic_t acq_start_flag;
-	atomic_t chg_start_flag;
-	struct task_struct *task;
-	struct completion complete;
-	wait_queue_head_t dev_wait;
-	wait_queue_head_t voc_wait;
-	uint32_t device_events;
-	/* cache the values related to Rx and Tx */
-	struct device_data dev_rx;
-	struct device_data dev_tx;
-	/* these default values are for all devices */
-	uint32_t default_mute_val;
-	uint32_t default_vol_val;
-	uint32_t default_sample_val;
-	/* call status */
-	int v_call_status; /* Start or End */
-	s32 max_rx_vol[VOC_RX_VOL_ARRAY_NUM]; /* [0] is for NB, [1] for WB */
-	s32 min_rx_vol[VOC_RX_VOL_ARRAY_NUM];
-};
-
-static struct voice_data voice;
-
-static int voice_cmd_device_info(struct voice_data *);
-static int voice_cmd_acquire_done(struct voice_data *);
-static void voice_auddev_cb_function(u32 evt_id,
-			union auddev_evt_data *evt_payload,
-			void *private_data);
-
-static int voice_cmd_change(void)
-{
-
-	struct voice_header hdr;
-	struct voice_data *v = &voice;
-	int err;
-
-	hdr.id = CMD_DEVICE_CHANGE;
-	hdr.data_len = 0;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	err = dalrpc_fcn_5(VOICE_DALRPC_CMD, v->handle, &hdr,
-			sizeof(struct voice_header));
-
-	if (err)
-		MM_ERR("Voice change command failed\n");
-	return err;
-}
-
-static void voice_auddev_cb_function(u32 evt_id,
-			union auddev_evt_data *evt_payload,
-			void *private_data)
-{
-	struct voice_data *v = &voice;
-	int rc = 0, i;
-
-	MM_INFO("auddev_cb_function, evt_id=%d, dev_state=%d, voc_state=%d\n",
-		evt_id, v->dev_state, v->voc_state);
-	if ((evt_id != AUDDEV_EVT_START_VOICE) ||
-			(evt_id != AUDDEV_EVT_END_VOICE)) {
-		if (evt_payload == NULL) {
-			MM_ERR(" evt_payload is NULL pointer\n");
-			return;
-		}
-	}
-	switch (evt_id) {
-	case AUDDEV_EVT_START_VOICE:
-		if ((v->dev_state == DEV_INIT) ||
-				(v->dev_state == DEV_REL_DONE)) {
-			v->v_call_status = VOICE_CALL_START;
-			if ((v->dev_rx.enabled == VOICE_DEV_ENABLED)
-				&& (v->dev_tx.enabled == VOICE_DEV_ENABLED)) {
-				v->dev_state = DEV_READY;
-				MM_DBG("dev_state into ready\n");
-				wake_up(&v->dev_wait);
-			}
-			if (v->voc_state == VOICE_CHANGE) {
-				MM_DBG("voc_state is in VOICE_CHANGE\n");
-				v->voc_state = VOICE_ACQUIRE;
-			}
-		}
-		break;
-	case AUDDEV_EVT_DEV_CHG_VOICE:
-		if (v->dev_state == DEV_READY) {
-			v->dev_rx.enabled = VOICE_DEV_DISABLED;
-			v->dev_tx.enabled = VOICE_DEV_DISABLED;
-			v->dev_state = DEV_CHANGE;
-			mutex_lock(&voice.voc_lock);
-			if (v->voc_state == VOICE_ACQUIRE) {
-				/* send device change to modem */
-				voice_cmd_change();
-				mutex_unlock(&voice.voc_lock);
-				msm_snddev_enable_sidetone(v->dev_rx.dev_id,
-				0);
-				/* block to wait for CHANGE_START */
-				rc = wait_event_interruptible(
-				v->voc_wait, (v->voc_state == VOICE_CHANGE)
-				|| (atomic_read(&v->chg_start_flag) == 1)
-				|| (atomic_read(&v->rel_start_flag) == 1));
-			} else {
-				mutex_unlock(&voice.voc_lock);
-				MM_ERR(" Voice is not at ACQUIRE state\n");
-			}
-		} else if ((v->dev_state == DEV_INIT) ||
-				(v->dev_state == DEV_REL_DONE)) {
-				v->dev_rx.enabled = VOICE_DEV_DISABLED;
-				v->dev_tx.enabled = VOICE_DEV_DISABLED;
-		} else
-			MM_ERR(" device is not at proper state\n");
-		break;
-	case AUDDEV_EVT_DEV_RDY:
-		/* update the dev info */
-		if (evt_payload->voc_devinfo.dev_type == DIR_RX) {
-			for (i = 0; i < VOC_RX_VOL_ARRAY_NUM; i++) {
-				v->max_rx_vol[i] =
-					evt_payload->voc_devinfo.max_rx_vol[i];
-				v->min_rx_vol[i] =
-					evt_payload->voc_devinfo.min_rx_vol[i];
-			}
-		}
-		if (v->dev_state == DEV_CHANGE) {
-			if (evt_payload->voc_devinfo.dev_type == DIR_RX) {
-				v->dev_rx.dev_acdb_id =
-					evt_payload->voc_devinfo.acdb_dev_id;
-				v->dev_rx.sample =
-					evt_payload->voc_devinfo.dev_sample;
-				v->dev_rx.dev_id =
-				evt_payload->voc_devinfo.dev_id;
-				v->dev_rx.enabled = VOICE_DEV_ENABLED;
-			} else {
-				v->dev_tx.dev_acdb_id =
-					evt_payload->voc_devinfo.acdb_dev_id;
-				v->dev_tx.sample =
-					evt_payload->voc_devinfo.dev_sample;
-				v->dev_tx.enabled = VOICE_DEV_ENABLED;
-				v->dev_tx.dev_id =
-				evt_payload->voc_devinfo.dev_id;
-			}
-			if ((v->dev_rx.enabled == VOICE_DEV_ENABLED) &&
-				(v->dev_tx.enabled == VOICE_DEV_ENABLED)) {
-				v->dev_state = DEV_READY;
-				MM_DBG("dev state into ready\n");
-				voice_cmd_device_info(v);
-				wake_up(&v->dev_wait);
-				mutex_lock(&voice.voc_lock);
-				if (v->voc_state == VOICE_CHANGE) {
-					v->dev_event = DEV_CHANGE_READY;
-					complete(&v->complete);
-				}
-				mutex_unlock(&voice.voc_lock);
-			}
-		} else if ((v->dev_state == DEV_INIT) ||
-			(v->dev_state == DEV_REL_DONE)) {
-			if (evt_payload->voc_devinfo.dev_type == DIR_RX) {
-				v->dev_rx.dev_acdb_id =
-					evt_payload->voc_devinfo.acdb_dev_id;
-				v->dev_rx.sample =
-					evt_payload->voc_devinfo.dev_sample;
-				v->dev_rx.dev_id =
-				evt_payload->voc_devinfo.dev_id;
-				v->dev_rx.enabled = VOICE_DEV_ENABLED;
-			} else {
-				v->dev_tx.dev_acdb_id =
-					evt_payload->voc_devinfo.acdb_dev_id;
-				v->dev_tx.sample =
-					evt_payload->voc_devinfo.dev_sample;
-				v->dev_tx.dev_id =
-				evt_payload->voc_devinfo.dev_id;
-				v->dev_tx.enabled = VOICE_DEV_ENABLED;
-			}
-			if ((v->dev_rx.enabled == VOICE_DEV_ENABLED) &&
-				(v->dev_tx.enabled == VOICE_DEV_ENABLED) &&
-				(v->v_call_status == VOICE_CALL_START)) {
-				v->dev_state = DEV_READY;
-				MM_DBG("dev state into ready\n");
-				voice_cmd_device_info(v);
-				wake_up(&v->dev_wait);
-				mutex_lock(&voice.voc_lock);
-				if (v->voc_state == VOICE_CHANGE) {
-					v->dev_event = DEV_CHANGE_READY;
-					complete(&v->complete);
-				}
-				mutex_unlock(&voice.voc_lock);
-			}
-		} else
-			MM_ERR("Receive READY not at the proper state =%d\n",
-				v->dev_state);
-		break;
-	case AUDDEV_EVT_DEVICE_VOL_MUTE_CHG:
-		if (evt_payload->voc_devinfo.dev_type == DIR_TX)
-			v->dev_tx.mute =
-				evt_payload->voc_vm_info.dev_vm_val.mute;
-		else
-			v->dev_rx.volume = evt_payload->
-						voc_vm_info.dev_vm_val.vol;
-		/* send device info */
-		voice_cmd_device_info(v);
-		break;
-	case AUDDEV_EVT_REL_PENDING:
-		/* recover the tx mute and rx volume to the default values */
-		if (v->dev_state == DEV_READY) {
-			if (atomic_read(&v->rel_start_flag)) {
-				atomic_dec(&v->rel_start_flag);
-				if (evt_payload->voc_devinfo.dev_type == DIR_RX)
-					v->dev_rx.enabled = VOICE_DEV_DISABLED;
-				else
-					v->dev_tx.enabled = VOICE_DEV_DISABLED;
-				v->dev_state = DEV_REL_DONE;
-				wake_up(&v->dev_wait);
-				break;
-			}
-			mutex_lock(&voice.voc_lock);
-			if ((v->voc_state == VOICE_RELEASE) ||
-					(v->voc_state == VOICE_INIT)) {
-				if (evt_payload->voc_devinfo.dev_type
-							== DIR_RX) {
-					v->dev_rx.enabled = VOICE_DEV_DISABLED;
-				} else {
-					v->dev_tx.enabled = VOICE_DEV_DISABLED;
-				}
-				v->dev_state = DEV_REL_DONE;
-				mutex_unlock(&voice.voc_lock);
-				wake_up(&v->dev_wait);
-			} else {
-				/* send device change to modem */
-				voice_cmd_change();
-				mutex_unlock(&voice.voc_lock);
-				rc = wait_event_interruptible(
-				v->voc_wait, (v->voc_state == VOICE_CHANGE)
-				|| (atomic_read(&v->chg_start_flag) == 1)
-				|| (atomic_read(&v->rel_start_flag) == 1));
-				if (atomic_read(&v->rel_start_flag) == 1)
-					atomic_dec(&v->rel_start_flag);
-				/* clear Rx/Tx to Disable */
-				if (evt_payload->voc_devinfo.dev_type == DIR_RX)
-					v->dev_rx.enabled = VOICE_DEV_DISABLED;
-				else
-					v->dev_tx.enabled = VOICE_DEV_DISABLED;
-				v->dev_state = DEV_REL_DONE;
-				wake_up(&v->dev_wait);
-			}
-		} else if ((v->dev_state == DEV_INIT) ||
-				(v->dev_state == DEV_REL_DONE)) {
-			if (evt_payload->voc_devinfo.dev_type == DIR_RX)
-				v->dev_rx.enabled = VOICE_DEV_DISABLED;
-			else
-				v->dev_tx.enabled = VOICE_DEV_DISABLED;
-		}
-		break;
-	case AUDDEV_EVT_END_VOICE:
-		/* recover the tx mute and rx volume to the default values */
-		v->dev_tx.mute = v->default_mute_val;
-		v->dev_rx.volume = v->default_vol_val;
-
-		if (v->dev_rx.enabled == VOICE_DEV_ENABLED)
-			msm_snddev_enable_sidetone(v->dev_rx.dev_id, 0);
-
-		if ((v->dev_state == DEV_READY) ||
-			(v->dev_state == DEV_CHANGE)) {
-			if (atomic_read(&v->rel_start_flag)) {
-				atomic_dec(&v->rel_start_flag);
-				v->v_call_status = VOICE_CALL_END;
-				v->dev_state = DEV_REL_DONE;
-				wake_up(&v->dev_wait);
-				break;
-			}
-			mutex_lock(&voice.voc_lock);
-			if ((v->voc_state == VOICE_RELEASE) ||
-					(v->voc_state == VOICE_INIT)) {
-				v->v_call_status = VOICE_CALL_END;
-				v->dev_state = DEV_REL_DONE;
-				mutex_unlock(&voice.voc_lock);
-				wake_up(&v->dev_wait);
-			} else {
-				/* send mute and default volume value to MCAD */
-				voice_cmd_device_info(v);
-				/* send device change to modem */
-				voice_cmd_change();
-				mutex_unlock(&voice.voc_lock);
-				/* block to wait for RELEASE_START
-						or CHANGE_START */
-				rc = wait_event_interruptible(
-				v->voc_wait, (v->voc_state == VOICE_CHANGE)
-				|| (atomic_read(&v->chg_start_flag) == 1)
-				|| (atomic_read(&v->rel_start_flag) == 1));
-				if (atomic_read(&v->rel_start_flag) == 1)
-					atomic_dec(&v->rel_start_flag);
-				/* set voice call to END state */
-				v->v_call_status = VOICE_CALL_END;
-				v->dev_state = DEV_REL_DONE;
-				wake_up(&v->dev_wait);
-			}
-		} else
-			v->v_call_status = VOICE_CALL_END;
-		break;
-	case AUDDEV_EVT_FREQ_CHG:
-		MM_DBG("Voice Driver got sample rate change Event\n");
-		MM_DBG("sample rate %d\n", evt_payload->freq_info.sample_rate);
-		MM_DBG("dev_type %d\n", evt_payload->freq_info.dev_type);
-		MM_DBG("acdb_dev_id %d\n", evt_payload->freq_info.acdb_dev_id);
-		if (v->dev_state == DEV_READY) {
-			v->dev_tx.enabled = VOICE_DEV_DISABLED;
-			v->dev_state = DEV_CHANGE;
-			mutex_lock(&voice.voc_lock);
-			if (v->voc_state == VOICE_ACQUIRE) {
-				msm_snddev_enable_sidetone(v->dev_rx.dev_id,
-				0);
-				/* send device change to modem */
-				voice_cmd_change();
-				mutex_unlock(&voice.voc_lock);
-				/* block to wait for CHANGE_START */
-				rc = wait_event_interruptible(
-				v->voc_wait, (v->voc_state == VOICE_CHANGE)
-				|| (atomic_read(&v->chg_start_flag) == 1)
-				|| (atomic_read(&v->rel_start_flag) == 1));
-			} else {
-				mutex_unlock(&voice.voc_lock);
-				MM_ERR(" Voice is not at ACQUIRE state\n");
-			}
-		} else if ((v->dev_state == DEV_INIT) ||
-				(v->dev_state == DEV_REL_DONE)) {
-				v->dev_tx.enabled = VOICE_DEV_DISABLED;
-		} else
-			MM_ERR("Event not at the proper state =%d\n",
-				v->dev_state);
-		break;
-	default:
-		MM_ERR("UNKNOWN EVENT\n");
-	}
-	return;
-}
-EXPORT_SYMBOL(voice_auddev_cb_function);
-
-static void remote_cb_function(void *context, u32 param,
-				void *evt_buf, u32 len)
-{
-	struct voice_header *hdr;
-	struct voice_data *v = context;
-
-	hdr = (struct voice_header *)evt_buf;
-
-	MM_INFO("len=%d id=%d\n", len, hdr->id);
-
-	if (len <= 0) {
-		MM_ERR("unexpected event with length %d \n", len);
-		return;
-	}
-
-	switch (hdr->id) {
-	case EVENT_ACQUIRE_START:
-		atomic_inc(&v->acq_start_flag);
-		wake_up(&v->dev_wait);
-		v->voc_event = VOICE_ACQUIRE_START;
-		v->network = ((struct voice_network *)evt_buf)->network_info;
-		complete(&v->complete);
-		break;
-	case EVENT_RELEASE_START:
-		/* If ACQUIRED come in before the RELEASE,
-		* will only services the RELEASE */
-		atomic_inc(&v->rel_start_flag);
-		wake_up(&v->voc_wait);
-		wake_up(&v->dev_wait);
-		v->voc_event = VOICE_RELEASE_START;
-		complete(&v->complete);
-		break;
-	case EVENT_CHANGE_START:
-		atomic_inc(&v->chg_start_flag);
-		wake_up(&v->voc_wait);
-		v->voc_event = VOICE_CHANGE_START;
-		complete(&v->complete);
-		break;
-	case EVENT_NETWORK_RECONFIG:
-		/* send network change to audio_dev,
-		if sample rate is less than 16k,
-		otherwise, send acquire done */
-		v->voc_event = VOICE_NETWORK_RECONFIG;
-		v->network = ((struct voice_network *)evt_buf)->network_info;
-		complete(&v->complete);
-		break;
-	default:
-		MM_ERR("Undefined event %d \n", hdr->id);
-	}
-
-}
-
-static int voice_cmd_init(struct voice_data *v)
-{
-
-	struct voice_init cmd;
-	int err;
-
-	MM_DBG("\n"); /* Macro prints the file name and function */
-
-	cmd.hdr.id = CMD_VOICE_INIT;
-	cmd.hdr.data_len = sizeof(struct voice_init) -
-				sizeof(struct voice_header);
-	cmd.cb_handle = v->cb_handle;
-
-	err = dalrpc_fcn_5(VOICE_DALRPC_CMD, v->handle, &cmd,
-			 sizeof(struct voice_init));
-
-	if (err)
-		MM_ERR("Voice init command failed\n");
-	return err;
-}
-
-static int voice_cmd_acquire_done(struct voice_data *v)
-{
-	struct voice_header hdr;
-	int err;
-
-	hdr.id = CMD_ACQUIRE_DONE;
-	hdr.data_len = 0;
-
-	MM_INFO("\n"); /* Macro prints the file name and function */
-
-	/* Enable HW sidetone if device supports it  */
-	msm_snddev_enable_sidetone(v->dev_rx.dev_id, 1);
-
-	err = dalrpc_fcn_5(VOICE_DALRPC_CMD, v->handle, &hdr,
-			 sizeof(struct voice_header));
-
-	if (err)
-		MM_ERR("Voice acquire done command failed\n");
-	return err;
-}
-
-static int voice_cmd_device_info(struct voice_data *v)
-{
-	struct voice_device cmd;
-	int err, vol;
-
-	MM_INFO("tx_dev=%d, rx_dev=%d, tx_sample=%d, tx_mute=%d\n",
-			v->dev_tx.dev_acdb_id, v->dev_rx.dev_acdb_id,
-			v->dev_tx.sample, v->dev_tx.mute);
-
-	mutex_lock(&voice.vol_lock);
-
-	cmd.hdr.id = CMD_DEVICE_INFO;
-	cmd.hdr.data_len = sizeof(struct voice_device) -
-			sizeof(struct voice_header);
-	cmd.tx_device = v->dev_tx.dev_acdb_id;
-	cmd.rx_device = v->dev_rx.dev_acdb_id;
-	if (v->network == NETWORK_WCDMA_WB)
-		vol = v->min_rx_vol[VOC_WB_INDEX] +
-			((v->max_rx_vol[VOC_WB_INDEX] -
-			v->min_rx_vol[VOC_WB_INDEX]) * v->dev_rx.volume)/100;
-	else
-		vol = v->min_rx_vol[VOC_NB_INDEX] +
-			((v->max_rx_vol[VOC_NB_INDEX] -
-			v->min_rx_vol[VOC_NB_INDEX]) * v->dev_rx.volume)/100;
-	cmd.rx_volume = (u32)vol; /* in mb */
-	cmd.rx_mute = 0;
-	cmd.tx_mute = v->dev_tx.mute;
-	cmd.rx_sample = v->dev_rx.sample/1000;
-	cmd.tx_sample = v->dev_tx.sample/1000;
-
-	MM_DBG("rx_vol=%d, rx_sample=%d\n", cmd.rx_volume, v->dev_rx.sample);
-
-	err = dalrpc_fcn_5(VOICE_DALRPC_CMD, v->handle, &cmd,
-			 sizeof(struct voice_device));
-
-	mutex_unlock(&voice.vol_lock);
-
-	if (err)
-		MM_ERR("Voice device command failed\n");
-	return err;
-}
-EXPORT_SYMBOL(voice_cmd_device_info);
-
-void voice_change_sample_rate(struct voice_data *v)
-{
-	int freq = 48000;
-	int rc = 0;
-
-	MM_DBG("network =%d, vote freq=%d\n", v->network, freq);
-	if (freq != v->dev_tx.sample) {
-		rc = msm_snddev_request_freq(&freq, 0,
-				SNDDEV_CAP_TX, AUDDEV_CLNT_VOC);
-		if (rc >= 0) {
-			v->dev_tx.sample = freq;
-			MM_DBG(" vote for freq=%d successfully \n", freq);
-		} else
-			MM_ERR(" voting for freq=%d failed.\n", freq);
-	}
-}
-
-static int voice_thread(void *data)
-{
-	struct voice_data *v = (struct voice_data *)data;
-	int rc = 0;
-
-	MM_INFO("voice_thread() start\n");
-
-	while (!kthread_should_stop()) {
-		wait_for_completion(&v->complete);
-		init_completion(&v->complete);
-
-		MM_DBG(" voc_event=%d, voice state =%d, dev_event=%d\n",
-				v->voc_event, v->voc_state, v->dev_event);
-		switch (v->voc_event) {
-		case VOICE_ACQUIRE_START:
-			/* check if dev_state = READY */
-			/* if ready, send device_info and acquire_done */
-			/* if not ready, block to wait the dev_state = READY */
-			if ((v->voc_state == VOICE_INIT) ||
-				(v->voc_state == VOICE_RELEASE)) {
-				if (v->dev_state == DEV_READY) {
-					mutex_lock(&voice.voc_lock);
-					voice_change_sample_rate(v);
-					rc = voice_cmd_device_info(v);
-					rc = voice_cmd_acquire_done(v);
-					v->voc_state = VOICE_ACQUIRE;
-					mutex_unlock(&voice.voc_lock);
-					broadcast_event(
-					AUDDEV_EVT_VOICE_STATE_CHG,
-					VOICE_STATE_INCALL, SESSION_IGNORE);
-				} else {
-					rc = wait_event_interruptible(
-					v->dev_wait,
-					(v->dev_state == DEV_READY)
-					|| (atomic_read(&v->rel_start_flag)
-						== 1));
-					if (atomic_read(&v->rel_start_flag)
-						== 1) {
-						v->voc_state = VOICE_RELEASE;
-						atomic_dec(&v->rel_start_flag);
-						msm_snddev_withdraw_freq(0,
-						SNDDEV_CAP_TX, AUDDEV_CLNT_VOC);
-						broadcast_event(
-						AUDDEV_EVT_VOICE_STATE_CHG,
-						VOICE_STATE_OFFCALL,
-						SESSION_IGNORE);
-					} else {
-						mutex_lock(&voice.voc_lock);
-						voice_change_sample_rate(v);
-						rc = voice_cmd_device_info(v);
-						rc = voice_cmd_acquire_done(v);
-						v->voc_state = VOICE_ACQUIRE;
-						mutex_unlock(&voice.voc_lock);
-						broadcast_event(
-						AUDDEV_EVT_VOICE_STATE_CHG,
-						VOICE_STATE_INCALL,
-						SESSION_IGNORE);
-					}
-				}
-			} else
-				MM_ERR("Get this event at the wrong state\n");
-			if (atomic_read(&v->acq_start_flag))
-				atomic_dec(&v->acq_start_flag);
-			break;
-		case VOICE_RELEASE_START:
-			MM_DBG("broadcast voice call end\n");
-			broadcast_event(AUDDEV_EVT_VOICE_STATE_CHG,
-					VOICE_STATE_OFFCALL, SESSION_IGNORE);
-			if ((v->dev_state == DEV_REL_DONE) ||
-					(v->dev_state == DEV_INIT)) {
-				v->voc_state = VOICE_RELEASE;
-				msm_snddev_withdraw_freq(0, SNDDEV_CAP_TX,
-					AUDDEV_CLNT_VOC);
-			} else {
-				/* wait for the dev_state = RELEASE */
-				rc = wait_event_interruptible(v->dev_wait,
-					(v->dev_state == DEV_REL_DONE)
-				|| (atomic_read(&v->acq_start_flag) == 1));
-				if (atomic_read(&v->acq_start_flag) == 1)
-					atomic_dec(&v->acq_start_flag);
-				v->voc_state = VOICE_RELEASE;
-				msm_snddev_withdraw_freq(0, SNDDEV_CAP_TX,
-					AUDDEV_CLNT_VOC);
-			}
-			if (atomic_read(&v->rel_start_flag))
-				atomic_dec(&v->rel_start_flag);
-			break;
-		case VOICE_CHANGE_START:
-			if (v->voc_state == VOICE_ACQUIRE)
-				v->voc_state = VOICE_CHANGE;
-			else
-				MM_ERR("Get this event at the wrong state\n");
-			wake_up(&v->voc_wait);
-			if (atomic_read(&v->chg_start_flag))
-				atomic_dec(&v->chg_start_flag);
-			break;
-		case VOICE_NETWORK_RECONFIG:
-			if ((v->voc_state == VOICE_ACQUIRE)
-				|| (v->voc_state == VOICE_CHANGE)) {
-				voice_change_sample_rate(v);
-				rc = voice_cmd_device_info(v);
-				rc = voice_cmd_acquire_done(v);
-			}
-			break;
-		default:
-			break;
-		}
-
-		switch (v->dev_event) {
-		case DEV_CHANGE_READY:
-			if (v->voc_state == VOICE_CHANGE) {
-				mutex_lock(&voice.voc_lock);
-				msm_snddev_enable_sidetone(v->dev_rx.dev_id,
-				1);
-				/* update voice state */
-				v->voc_state = VOICE_ACQUIRE;
-				v->dev_event = 0;
-				mutex_unlock(&voice.voc_lock);
-				broadcast_event(AUDDEV_EVT_VOICE_STATE_CHG,
-					VOICE_STATE_INCALL, SESSION_IGNORE);
-			} else {
-				mutex_lock(&voice.voc_lock);
-				v->dev_event = 0;
-				mutex_unlock(&voice.voc_lock);
-				MM_ERR("Get this event at the wrong state\n");
-			}
-			break;
-		default:
-			mutex_lock(&voice.voc_lock);
-			v->dev_event = 0;
-			mutex_unlock(&voice.voc_lock);
-			break;
-		}
-	}
-	return 0;
-}
-
-static int __init voice_init(void)
-{
-	int rc, i;
-	struct voice_data *v = &voice;
-	MM_INFO("\n"); /* Macro prints the file name and function */
-
-	mutex_init(&voice.voc_lock);
-	mutex_init(&voice.vol_lock);
-	v->handle = NULL;
-	v->cb_handle = NULL;
-
-	/* set default value */
-	v->default_mute_val = 1;  /* default is mute */
-	v->default_vol_val = 0;
-	v->default_sample_val = 8000;
-	for (i = 0; i < VOC_RX_VOL_ARRAY_NUM; i++) {
-		v->max_rx_vol[i] = 0;
-		v->min_rx_vol[i] = 0;
-	}
-	v->network = NETWORK_GSM;
-
-	/* initialize dev_rx and dev_tx */
-	memset(&v->dev_tx, 0, sizeof(struct device_data));
-	memset(&v->dev_rx, 0, sizeof(struct device_data));
-	v->dev_rx.volume = v->default_vol_val;
-	v->dev_tx.mute = v->default_mute_val;
-
-	v->dev_state = DEV_INIT;
-	v->voc_state = VOICE_INIT;
-	atomic_set(&v->rel_start_flag, 0);
-	atomic_set(&v->acq_start_flag, 0);
-	v->dev_event = 0;
-	v->voc_event = 0;
-	init_completion(&voice.complete);
-	init_waitqueue_head(&v->dev_wait);
-	init_waitqueue_head(&v->voc_wait);
-
-	 /* get device handle */
-	rc = daldevice_attach(VOICE_DALRPC_DEVICEID,
-				VOICE_DALRPC_PORT_NAME,
-				VOICE_DALRPC_CPU,
-				&v->handle);
-	if (rc) {
-		MM_ERR("Voc DALRPC call to Modem attach failed\n");
-		goto done;
-	}
-
-	/* Allocate the callback handle */
-	v->cb_handle = dalrpc_alloc_cb(v->handle, remote_cb_function, v);
-	if (v->cb_handle == NULL) {
-		MM_ERR("Allocate Callback failure\n");
-		goto err;
-	}
-
-	/* setup the callback */
-	rc = voice_cmd_init(v);
-	if (rc)
-		goto err1;
-
-	v->device_events = AUDDEV_EVT_DEV_CHG_VOICE |
-			AUDDEV_EVT_DEV_RDY |
-			AUDDEV_EVT_REL_PENDING |
-			AUDDEV_EVT_START_VOICE |
-			AUDDEV_EVT_END_VOICE |
-			AUDDEV_EVT_DEVICE_VOL_MUTE_CHG |
-			AUDDEV_EVT_FREQ_CHG;
-
-	MM_DBG(" to register call back \n");
-	/* register callback to auddev */
-	auddev_register_evt_listner(v->device_events, AUDDEV_CLNT_VOC,
-				0, voice_auddev_cb_function, v);
-
-	/* create and start thread */
-	v->task = kthread_run(voice_thread, v, "voice");
-	if (IS_ERR(v->task)) {
-		rc = PTR_ERR(v->task);
-		v->task = NULL;
-	} else
-		goto done;
-
-err1:   dalrpc_dealloc_cb(v->handle, v->cb_handle);
-err:
-	daldevice_detach(v->handle);
-	v->handle = NULL;
-done:
-	return rc;
-}
-
-late_initcall(voice_init);
diff --git a/arch/arm/mach-msm/qdsp6/Makefile b/arch/arm/mach-msm/qdsp6/Makefile
deleted file mode 100644
index 9a55612..0000000
--- a/arch/arm/mach-msm/qdsp6/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-obj-y += dal.o
-obj-y += q6audio.o
-obj-y += analog_audio.o
-obj-y += pcm_out.o
-obj-y += pcm_in.o
-obj-y += auxpcm_lb_out.o
-obj-y += auxpcm_lb_in.o
-obj-y += aac_in.o
-obj-y += qcelp_in.o
-obj-y += evrc_in.o
-obj-y += amrnb_in.o
-obj-y += mp3.o
-obj-y += dtmf.o
-obj-y += routing.o
-obj-y += audio_ctl.o
-obj-y += msm_q6vdec.o
-obj-y += msm_q6venc.o
-obj-y += dsp_debug.o
-obj-$(CONFIG_QSD_AUDIO) += audiov2/
diff --git a/arch/arm/mach-msm/qdsp6/aac_in.c b/arch/arm/mach-msm/qdsp6/aac_in.c
deleted file mode 100644
index 6e3bf94..0000000
--- a/arch/arm/mach-msm/qdsp6/aac_in.c
+++ /dev/null
@@ -1,470 +0,0 @@
-/*
- * Copyright (C) 2009 Google, Inc.
- * Copyright (C) 2009 HTC Corporation
- * Copyright (c) 2010, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/slab.h>
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/time.h>
-#include <linux/wait.h>
-
-#include <linux/msm_audio.h>
-#include <linux/msm_audio_aac.h>
-#include <mach/msm_qdsp6_audio.h>
-#include <mach/debug_mm.h>
-
-#define AAC_FC_BUFF_CNT 10
-#define AAC_READ_TIMEOUT 2000
-struct aac_fc_buff {
-	struct mutex lock;
-	int empty;
-	void *data;
-	int size;
-	int actual_size;
-};
-
-struct aac_fc {
-	struct task_struct *task;
-	wait_queue_head_t fc_wq;
-	struct aac_fc_buff fc_buff[AAC_FC_BUFF_CNT];
-	int buff_index;
-};
-struct aac {
-	struct mutex lock;
-	struct msm_audio_aac_enc_config cfg;
-	struct msm_audio_stream_config str_cfg;
-	struct audio_client *audio_client;
-	struct msm_voicerec_mode voicerec_mode;
-	struct aac_fc *aac_fc;
-};
-
-static int q6_aac_flowcontrol(void *data)
-{
-	struct audio_client *ac;
-	struct audio_buffer *ab;
-	struct aac *aac = data;
-	int buff_index = 0;
-	int xfer = 0;
-	struct aac_fc *fc;
-
-
-	ac = aac->audio_client;
-	fc = aac->aac_fc;
-	if (!ac) {
-		pr_err("[%s:%s] audio_client is NULL\n", __MM_FILE__, __func__);
-		return 0;
-	}
-
-	while (!kthread_should_stop()) {
-		ab = ac->buf + ac->cpu_buf;
-		if (ab->used)
-			wait_event(ac->wait, (ab->used == 0));
-		pr_debug("[%s:%s] ab->data = %p, cpu_buf = %d\n", __MM_FILE__,
-			 __func__, ab->data, ac->cpu_buf);
-		xfer = ab->actual_size;
-
-		mutex_lock(&(fc->fc_buff[buff_index].lock));
-		if (!fc->fc_buff[buff_index].empty) {
-			pr_err("[%s:%s] flow control buffer[%d] not read!\n",
-					__MM_FILE__, __func__, buff_index);
-		}
-
-		if (fc->fc_buff[buff_index].size < xfer) {
-			pr_err("[%s:%s] buffer %d too small\n", __MM_FILE__,
-					__func__, buff_index);
-			memcpy(fc->fc_buff[buff_index].data,
-				ab->data, fc->fc_buff[buff_index].size);
-			fc->fc_buff[buff_index].empty = 0;
-			fc->fc_buff[buff_index].actual_size =
-				fc->fc_buff[buff_index].size;
-		} else {
-			memcpy(fc->fc_buff[buff_index].data, ab->data, xfer);
-			fc->fc_buff[buff_index].empty = 0;
-			fc->fc_buff[buff_index].actual_size = xfer;
-		}
-		mutex_unlock(&(fc->fc_buff[buff_index].lock));
-		/*wake up client, if any*/
-		wake_up(&fc->fc_wq);
-
-		buff_index++;
-		if (buff_index >= AAC_FC_BUFF_CNT)
-			buff_index = 0;
-
-		ab->used = 1;
-
-		q6audio_read(ac, ab);
-		ac->cpu_buf ^= 1;
-	}
-
-	return 0;
-}
-static long q6_aac_in_ioctl(struct file *file,
-				 unsigned int cmd, unsigned long arg)
-{
-	struct aac *aac = file->private_data;
-	int rc = 0;
-	int i = 0;
-	struct aac_fc *fc;
-	int size = 0;
-
-	mutex_lock(&aac->lock);
-	switch (cmd) {
-	case AUDIO_SET_VOLUME:
-		break;
-	case AUDIO_GET_STATS:
-	{
-		struct msm_audio_stats stats;
-		pr_debug("[%s:%s] GET_STATS\n", __MM_FILE__, __func__);
-		memset(&stats, 0, sizeof(stats));
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-	case AUDIO_START:
-	{
-		uint32_t acdb_id;
-		pr_debug("[%s:%s] AUDIO_START\n", __MM_FILE__, __func__);
-		if (arg == 0) {
-			acdb_id = 0;
-		} else {
-			if (copy_from_user(&acdb_id, (void *) arg,
-					sizeof(acdb_id))) {
-				rc = -EFAULT;
-				break;
-			}
-		}
-		if (aac->audio_client) {
-			rc = -EBUSY;
-			pr_err("[%s:%s] active session already existing\n",
-				__MM_FILE__, __func__);
-			break;
-		} else {
-			aac->audio_client = q6audio_open_aac(
-					aac->str_cfg.buffer_size,
-					aac->cfg.sample_rate,
-					aac->cfg.channels,
-					aac->cfg.bit_rate,
-					aac->cfg.stream_format,
-					aac->voicerec_mode.rec_mode, acdb_id);
-
-			if (aac->audio_client < 0) {
-				pr_err("[%s:%s] aac open session failed\n",
-					__MM_FILE__, __func__);
-				rc = -ENOMEM;
-				break;
-			}
-		}
-
-		/*allocate flow control buffers*/
-		fc = aac->aac_fc;
-		size = ((aac->str_cfg.buffer_size < 1543) ? 1543 :
-				aac->str_cfg.buffer_size);
-		for (i = 0; i < AAC_FC_BUFF_CNT; ++i) {
-			mutex_init(&(fc->fc_buff[i].lock));
-			fc->fc_buff[i].empty = 1;
-			fc->fc_buff[i].data = kmalloc(size, GFP_KERNEL);
-			if (fc->fc_buff[i].data == NULL) {
-				pr_err("[%s:%s] No memory for FC buffers\n",
-						__MM_FILE__, __func__);
-				rc = -ENOMEM;
-				goto fc_fail;
-			}
-			fc->fc_buff[i].size = size;
-			fc->fc_buff[i].actual_size = 0;
-		}
-
-		/*create flow control thread*/
-		fc->task = kthread_run(q6_aac_flowcontrol,
-				aac, "aac_flowcontrol");
-		if (IS_ERR(fc->task)) {
-			rc = PTR_ERR(fc->task);
-			pr_err("[%s:%s] error creating flow control thread\n",
-					__MM_FILE__, __func__);
-			goto fc_fail;
-		}
-		break;
-fc_fail:
-		/*free flow control buffers*/
-		--i;
-		for (; i >=  0; i--) {
-			kfree(fc->fc_buff[i].data);
-			fc->fc_buff[i].data = NULL;
-		}
-		break;
-	}
-	case AUDIO_STOP:
-		pr_debug("[%s:%s] AUDIO_STOP\n", __MM_FILE__, __func__);
-		break;
-	case AUDIO_FLUSH:
-		break;
-	case AUDIO_SET_INCALL: {
-		pr_debug("[%s:%s] SET_INCALL\n", __MM_FILE__, __func__);
-		if (copy_from_user(&aac->voicerec_mode,
-			(void *)arg, sizeof(struct msm_voicerec_mode)))
-			rc = -EFAULT;
-
-		if (aac->voicerec_mode.rec_mode != AUDIO_FLAG_READ
-			&& aac->voicerec_mode.rec_mode !=
-			AUDIO_FLAG_INCALL_MIXED) {
-			aac->voicerec_mode.rec_mode = AUDIO_FLAG_READ;
-			pr_err("[%s:%s] Invalid rec_mode\n", __MM_FILE__,
-					__func__);
-			rc = -EINVAL;
-		}
-		break;
-	}
-	case AUDIO_GET_STREAM_CONFIG:
-		if (copy_to_user((void *)arg, &aac->str_cfg,
-			sizeof(struct msm_audio_stream_config)))
-			rc = -EFAULT;
-		pr_debug("[%s:%s] GET_STREAM_CONFIG: buffsz=%d, buffcnt=%d\n",
-			 __MM_FILE__, __func__, aac->str_cfg.buffer_size,
-			aac->str_cfg.buffer_count);
-		break;
-	case AUDIO_SET_STREAM_CONFIG:
-		if (copy_from_user(&aac->str_cfg, (void *)arg,
-			sizeof(struct msm_audio_stream_config))) {
-			rc = -EFAULT;
-			break;
-		}
-		pr_debug("[%s:%s] SET_STREAM_CONFIG: buffsz=%d, buffcnt=%d\n",
-			 __MM_FILE__, __func__, aac->str_cfg.buffer_size,
-			aac->str_cfg.buffer_count);
-		if (aac->str_cfg.buffer_size < 1543) {
-			pr_err("[%s:%s] Buffer size too small\n", __MM_FILE__,
-					__func__);
-			rc = -EINVAL;
-			break;
-		}
-		if (aac->str_cfg.buffer_count != 2)
-			pr_info("[%s:%s] Buffer count set to 2\n", __MM_FILE__,
-					__func__);
-
-		break;
-	case AUDIO_SET_AAC_ENC_CONFIG:
-		if (copy_from_user(&aac->cfg, (void *) arg,
-				 sizeof(struct msm_audio_aac_enc_config))) {
-			rc = -EFAULT;
-		}
-		pr_debug("[%s:%s] SET_AAC_ENC_CONFIG: channels=%d, rate=%d\n",
-			__MM_FILE__, __func__, aac->cfg.channels,
-			aac->cfg.sample_rate);
-		if (aac->cfg.channels < 1 || aac->cfg.channels > 2) {
-			pr_err("[%s:%s]invalid number of channels\n",
-				 __MM_FILE__, __func__);
-			rc = -EINVAL;
-		}
-		if (aac->cfg.sample_rate != 48000) {
-			pr_err("[%s:%s] only 48KHz is supported\n",
-					__MM_FILE__, __func__);
-			rc = -EINVAL;
-		}
-		if (aac->cfg.stream_format != AUDIO_AAC_FORMAT_RAW &&
-			aac->cfg.stream_format != AUDIO_AAC_FORMAT_ADTS) {
-			pr_err("[%s:%s] unsupported AAC format\n", __MM_FILE__,
-					__func__);
-			rc = -EINVAL;
-		}
-		break;
-	case AUDIO_GET_AAC_ENC_CONFIG:
-		if (copy_to_user((void *) arg, &aac->cfg,
-				 sizeof(struct msm_audio_aac_enc_config))) {
-			rc = -EFAULT;
-		}
-		pr_debug("[%s:%s] GET_AAC_ENC_CONFIG: channels=%d, rate=%d\n",
-			__MM_FILE__, __func__, aac->cfg.channels,
-			aac->cfg.sample_rate);
-		break;
-	default:
-		rc = -EINVAL;
-	}
-
-	mutex_unlock(&aac->lock);
-	pr_debug("[%s:%s] rc = %d\n", __MM_FILE__, __func__, rc);
-	return rc;
-}
-
-static int q6_aac_in_open(struct inode *inode, struct file *file)
-{
-
-	struct aac *aac;
-	struct aac_fc *fc;
-	int i;
-	pr_info("[%s:%s] open\n", __MM_FILE__, __func__);
-	aac = kmalloc(sizeof(struct aac), GFP_KERNEL);
-	if (aac == NULL) {
-		pr_err("[%s:%s] Could not allocate memory for aac driver\n",
-				__MM_FILE__, __func__);
-		return -ENOMEM;
-	}
-
-	mutex_init(&aac->lock);
-	file->private_data = aac;
-	aac->audio_client = NULL;
-	aac->str_cfg.buffer_size = 1543;
-	aac->str_cfg.buffer_count = 2;
-	aac->cfg.channels = 1;
-	aac->cfg.bit_rate = 192000;
-	aac->cfg.stream_format = AUDIO_AAC_FORMAT_ADTS;
-	aac->cfg.sample_rate = 48000;
-	aac->voicerec_mode.rec_mode = AUDIO_FLAG_READ;
-
-	aac->aac_fc = kmalloc(sizeof(struct aac_fc), GFP_KERNEL);
-	if (aac->aac_fc == NULL) {
-		pr_err("[%s:%s] Could not allocate memory for aac_fc\n",
-				__MM_FILE__, __func__);
-		kfree(aac);
-		return -ENOMEM;
-	}
-	fc = aac->aac_fc;
-	fc->task = NULL;
-	fc->buff_index = 0;
-	for (i = 0; i < AAC_FC_BUFF_CNT; ++i) {
-		fc->fc_buff[i].data = NULL;
-		fc->fc_buff[i].size = 0;
-		fc->fc_buff[i].actual_size = 0;
-	}
-	/*initialize wait queue head*/
-	init_waitqueue_head(&fc->fc_wq);
-	return 0;
-}
-
-static ssize_t q6_aac_in_read(struct file *file, char __user *buf,
-			  size_t count, loff_t *pos)
-{
-	struct audio_client *ac;
-	const char __user *start = buf;
-	struct aac *aac = file->private_data;
-	struct aac_fc *fc;
-	int xfer = 0;
-	int res = 0;
-
-	pr_debug("[%s:%s] count = %d\n", __MM_FILE__, __func__, count);
-	mutex_lock(&aac->lock);
-	ac = aac->audio_client;
-
-	if (!ac) {
-		res = -ENODEV;
-		goto fail;
-	}
-	fc = aac->aac_fc;
-
-	/*wait for buffer to full*/
-	if (fc->fc_buff[fc->buff_index].empty != 0) {
-		res = wait_event_interruptible_timeout(fc->fc_wq,
-			(fc->fc_buff[fc->buff_index].empty == 0),
-				msecs_to_jiffies(AAC_READ_TIMEOUT));
-
-		pr_debug("[%s:%s] buff_index = %d\n", __MM_FILE__,
-			__func__, fc->buff_index);
-		if (res == 0) {
-			pr_err("[%s:%s] Timeout!\n", __MM_FILE__, __func__);
-			res = -ETIMEDOUT;
-			goto fail;
-		} else if (res < 0) {
-			pr_err("[%s:%s] Returning on Interrupt\n", __MM_FILE__,
-				__func__);
-			goto fail;
-		}
-	}
-	/*lock the buffer*/
-	mutex_lock(&(fc->fc_buff[fc->buff_index].lock));
-	xfer = fc->fc_buff[fc->buff_index].actual_size;
-
-	if (xfer > count) {
-		mutex_unlock(&(fc->fc_buff[fc->buff_index].lock));
-		pr_err("[%s:%s] read failed! byte count too small\n",
-				__MM_FILE__, __func__);
-		res = -EINVAL;
-		goto fail;
-	}
-
-	if (copy_to_user(buf, fc->fc_buff[fc->buff_index].data,	xfer)) {
-		mutex_unlock(&(fc->fc_buff[fc->buff_index].lock));
-		pr_err("[%s:%s] copy_to_user failed at index %d\n",
-				__MM_FILE__, __func__, fc->buff_index);
-		res = -EFAULT;
-		goto fail;
-	}
-
-	buf += xfer;
-
-	fc->fc_buff[fc->buff_index].empty = 1;
-	fc->fc_buff[fc->buff_index].actual_size = 0;
-
-	mutex_unlock(&(fc->fc_buff[fc->buff_index].lock));
-	++(fc->buff_index);
-	if (fc->buff_index >= AAC_FC_BUFF_CNT)
-		fc->buff_index = 0;
-
-	res = buf - start;
-fail:
-	mutex_unlock(&aac->lock);
-
-	return res;
-}
-
-static int q6_aac_in_release(struct inode *inode, struct file *file)
-{
-	int rc = 0;
-	struct aac *aac = file->private_data;
-	int i = 0;
-	struct aac_fc *fc;
-
-	mutex_lock(&aac->lock);
-	fc = aac->aac_fc;
-	kthread_stop(fc->task);
-	fc->task = NULL;
-
-	/*free flow control buffers*/
-	for (i = 0; i < AAC_FC_BUFF_CNT; ++i) {
-		kfree(fc->fc_buff[i].data);
-		fc->fc_buff[i].data = NULL;
-	}
-	kfree(fc);
-	if (aac->audio_client)
-		rc = q6audio_close(aac->audio_client);
-	mutex_unlock(&aac->lock);
-	kfree(aac);
-	pr_info("[%s:%s] release\n", __MM_FILE__, __func__);
-	return rc;
-}
-
-static const struct file_operations q6_aac_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= q6_aac_in_open,
-	.read		= q6_aac_in_read,
-	.release	= q6_aac_in_release,
-	.unlocked_ioctl	= q6_aac_in_ioctl,
-};
-
-struct miscdevice q6_aac_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_aac_in",
-	.fops	= &q6_aac_in_fops,
-};
-
-static int __init q6_aac_in_init(void)
-{
-	return misc_register(&q6_aac_in_misc);
-}
-
-device_initcall(q6_aac_in_init);
diff --git a/arch/arm/mach-msm/qdsp6/amrnb_in.c b/arch/arm/mach-msm/qdsp6/amrnb_in.c
deleted file mode 100644
index e20bf5b..0000000
--- a/arch/arm/mach-msm/qdsp6/amrnb_in.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * Copyright (C) 2009 Google, Inc.
- * Copyright (C) 2009 HTC Corporation
- * Copyright (c) 2010, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/slab.h>
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/uaccess.h>
-
-#include <linux/msm_audio.h>
-#include <linux/msm_audio_amrnb.h>
-#include <mach/msm_qdsp6_audio.h>
-#include "dal_audio_format.h"
-#include <mach/debug_mm.h>
-
-struct amrnb {
-	struct mutex lock;
-	struct msm_audio_amrnb_enc_config_v2 cfg;
-	struct msm_audio_stream_config str_cfg;
-	struct audio_client *audio_client;
-	struct msm_voicerec_mode voicerec_mode;
-};
-
-
-static long q6_amrnb_in_ioctl(struct file *file, unsigned int cmd,
-				unsigned long arg)
-{
-	struct amrnb *amrnb = file->private_data;
-	int rc = 0;
-
-	mutex_lock(&amrnb->lock);
-	switch (cmd) {
-	case AUDIO_SET_VOLUME:
-		pr_debug("[%s:%s] SET_VOLUME\n", __MM_FILE__, __func__);
-		break;
-	case AUDIO_GET_STATS:
-	{
-		struct msm_audio_stats stats;
-		pr_debug("[%s:%s] GET_STATS\n", __MM_FILE__, __func__);
-		memset(&stats, 0, sizeof(stats));
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-	case AUDIO_START:
-	{
-		uint32_t acdb_id;
-		pr_debug("[%s:%s] AUDIO_START\n", __MM_FILE__, __func__);
-		if (arg == 0) {
-			acdb_id = 0;
-		} else {
-			if (copy_from_user(&acdb_id, (void *) arg,
-						sizeof(acdb_id))) {
-				rc = -EFAULT;
-				break;
-			}
-		}
-		if (amrnb->audio_client) {
-			rc = -EBUSY;
-			pr_err("[%s:%s] active session already existing\n",
-				__MM_FILE__, __func__);
-			break;
-		} else {
-			amrnb->audio_client = q6audio_open_amrnb(
-					amrnb->str_cfg.buffer_size,
-					amrnb->cfg.band_mode,
-					amrnb->cfg.dtx_enable,
-					amrnb->voicerec_mode.rec_mode,
-					acdb_id);
-			if (!amrnb->audio_client) {
-				pr_err("[%s:%s] amrnb open session failed\n",
-					__MM_FILE__, __func__);
-				kfree(amrnb);
-				rc = -ENOMEM;
-				break;
-			}
-		}
-		break;
-	}
-	case AUDIO_STOP:
-		pr_debug("[%s:%s] AUDIO_STOP\n", __MM_FILE__, __func__);
-		break;
-	case AUDIO_FLUSH:
-		break;
-	case AUDIO_SET_INCALL: {
-		pr_debug("[%s:%s] SET_INCALL\n", __MM_FILE__, __func__);
-		if (copy_from_user(&amrnb->voicerec_mode,
-			(void *)arg, sizeof(struct msm_voicerec_mode)))
-			rc = -EFAULT;
-
-		if (amrnb->voicerec_mode.rec_mode != AUDIO_FLAG_READ
-				&& amrnb->voicerec_mode.rec_mode !=
-				AUDIO_FLAG_INCALL_MIXED) {
-			amrnb->voicerec_mode.rec_mode = AUDIO_FLAG_READ;
-			pr_err("[%s:%s] Invalid rec_mode\n", __MM_FILE__,
-					__func__);
-			rc = -EINVAL;
-		}
-		break;
-	}
-	case AUDIO_GET_STREAM_CONFIG:
-		if (copy_to_user((void *)arg, &amrnb->str_cfg,
-			sizeof(struct msm_audio_stream_config)))
-			rc = -EFAULT;
-		pr_debug("[%s:%s] GET_STREAM_CONFIG: buffsz=%d, buffcnt = %d\n",
-			 __MM_FILE__, __func__, amrnb->str_cfg.buffer_size,
-			amrnb->str_cfg.buffer_count);
-		break;
-	case AUDIO_SET_STREAM_CONFIG:
-		if (copy_from_user(&amrnb->str_cfg, (void *)arg,
-			sizeof(struct msm_audio_stream_config))) {
-			rc = -EFAULT;
-			break;
-		}
-		pr_debug("[%s:%s] SET_STREAM_CONFIG: buffsz=%d, buffcnt = %d\n",
-			 __MM_FILE__, __func__, amrnb->str_cfg.buffer_size,
-			amrnb->str_cfg.buffer_count);
-
-		if (amrnb->str_cfg.buffer_size < 768) {
-			pr_err("[%s:%s] Buffer size too small\n", __MM_FILE__,
-					__func__);
-			rc = -EINVAL;
-			break;
-		}
-
-		if (amrnb->str_cfg.buffer_count != 2)
-			pr_info("[%s:%s] Buffer count set to 2\n", __MM_FILE__,
-					__func__);
-		break;
-	case AUDIO_SET_AMRNB_ENC_CONFIG:
-		if (copy_from_user(&amrnb->cfg, (void *) arg,
-			sizeof(struct msm_audio_amrnb_enc_config_v2)))
-			rc = -EFAULT;
-		pr_debug("[%s:%s] SET_AMRNB_ENC_CONFIG\n", __MM_FILE__,
-			__func__);
-		break;
-	case AUDIO_GET_AMRNB_ENC_CONFIG:
-		if (copy_to_user((void *) arg, &amrnb->cfg,
-				 sizeof(struct msm_audio_amrnb_enc_config_v2)))
-			rc = -EFAULT;
-		pr_debug("[%s:%s] GET_AMRNB_ENC_CONFIG\n", __MM_FILE__,
-			__func__);
-		break;
-
-	default:
-		rc = -EINVAL;
-	}
-
-	mutex_unlock(&amrnb->lock);
-	pr_debug("[%s:%s] rc= %d\n", __MM_FILE__, __func__, rc);
-	return rc;
-}
-
-static int q6_amrnb_in_open(struct inode *inode, struct file *file)
-{
-	struct amrnb *amrnb;
-
-	pr_info("[%s:%s] open\n", __MM_FILE__, __func__);
-	amrnb = kmalloc(sizeof(struct amrnb), GFP_KERNEL);
-	if (amrnb == NULL) {
-		pr_err("[%s:%s] Could not allocate memory for amrnb driver\n",
-				__MM_FILE__, __func__);
-		return -ENOMEM;
-	}
-
-	mutex_init(&amrnb->lock);
-	file->private_data = amrnb;
-	amrnb->audio_client = NULL;
-	amrnb->str_cfg.buffer_size = 768;
-	amrnb->str_cfg.buffer_count = 2;
-	amrnb->cfg.band_mode = 7;
-	amrnb->cfg.dtx_enable  = 3;
-	amrnb->cfg.frame_format = ADSP_AUDIO_FORMAT_AMRNB_FS;
-	amrnb->voicerec_mode.rec_mode = AUDIO_FLAG_READ;
-
-	return 0;
-}
-
-static ssize_t q6_amrnb_in_read(struct file *file, char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct audio_client *ac;
-	struct audio_buffer *ab;
-	const char __user *start = buf;
-	struct amrnb *amrnb = file->private_data;
-	int xfer = 0;
-	int res;
-
-	pr_debug("[%s:%s] count = %d\n", __MM_FILE__, __func__, count);
-	mutex_lock(&amrnb->lock);
-	ac = amrnb->audio_client;
-	if (!ac) {
-		res = -ENODEV;
-		goto fail;
-	}
-	while (count > xfer) {
-		ab = ac->buf + ac->cpu_buf;
-
-		if (ab->used)
-			wait_event(ac->wait, (ab->used == 0));
-
-		pr_debug("[%s:%s] ab->data = %p, cpu_buf = %d\n", __MM_FILE__,
-			__func__, ab->data, ac->cpu_buf);
-		xfer = ab->actual_size;
-
-		if (copy_to_user(buf, ab->data, xfer)) {
-			pr_err("[%s:%s] copy_to_user failed\n",
-				__MM_FILE__, __func__);
-			res = -EFAULT;
-			goto fail;
-		}
-
-		buf += xfer;
-		count -= xfer;
-
-		ab->used = 1;
-		q6audio_read(ac, ab);
-		ac->cpu_buf ^= 1;
-	}
-
-	res = buf - start;
-fail:
-	mutex_unlock(&amrnb->lock);
-
-	return res;
-}
-
-static int q6_amrnb_in_release(struct inode *inode, struct file *file)
-{
-	int rc = 0;
-	struct amrnb *amrnb = file->private_data;
-
-	mutex_lock(&amrnb->lock);
-	if (amrnb->audio_client)
-		rc = q6audio_close(amrnb->audio_client);
-	mutex_unlock(&amrnb->lock);
-	kfree(amrnb);
-	pr_info("[%s:%s] release\n", __MM_FILE__, __func__);
-	return rc;
-}
-
-static const struct file_operations q6_amrnb_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= q6_amrnb_in_open,
-	.read		= q6_amrnb_in_read,
-	.release	= q6_amrnb_in_release,
-	.unlocked_ioctl	= q6_amrnb_in_ioctl,
-};
-
-struct miscdevice q6_amrnb_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_amr_in",
-	.fops	= &q6_amrnb_in_fops,
-};
-
-static int __init q6_amrnb_in_init(void)
-{
-	return misc_register(&q6_amrnb_in_misc);
-}
-
-device_initcall(q6_amrnb_in_init);
diff --git a/arch/arm/mach-msm/qdsp6/analog_audio.c b/arch/arm/mach-msm/qdsp6/analog_audio.c
deleted file mode 100644
index d3a6baa..0000000
--- a/arch/arm/mach-msm/qdsp6/analog_audio.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/* Copyright (c) 2010, The Linux Foundation. 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.
- */
-
-#include <linux/init.h>
-#include <linux/wait.h>
-#include <linux/gpio.h>
-#include <mach/pmic.h>
-#include <mach/msm_qdsp6_audio.h>
-#include <asm/string.h>
-#include <asm/mach-types.h>
-#include <mach/debug_mm.h>
-
-#define GPIO_HEADSET_AMP 157
-#define GPIO_SPEAKER_AMP 39
-#define GPIO_HEADSET_SHDN_N 48
-
-void analog_init(void)
-{
-	/* stereo pmic init */
-	pmic_spkr_set_gain(LEFT_SPKR, SPKR_GAIN_PLUS12DB);
-	pmic_spkr_set_gain(RIGHT_SPKR, SPKR_GAIN_PLUS12DB);
-	pmic_mic_set_volt(MIC_VOLT_1_80V);
-	gpio_direction_output(GPIO_HEADSET_AMP, 1);
-	gpio_set_value(GPIO_HEADSET_AMP, 0);
-}
-
-void analog_headset_enable(int en)
-{
-	pr_debug("[%s:%s] en = %d\n", __MM_FILE__, __func__, en);
-	/* enable audio amp */
-	gpio_set_value(GPIO_HEADSET_AMP, !!en);
-}
-
-void analog_speaker_enable(int en)
-{
-	struct spkr_config_mode scm;
-	memset(&scm, 0, sizeof(scm));
-
-	pr_debug("[%s:%s] en = %d\n", __MM_FILE__, __func__, en);
-	if (en) {
-		scm.is_right_chan_en = 1;
-		scm.is_left_chan_en = 1;
-		scm.is_stereo_en = 1;
-		scm.is_hpf_en = 1;
-		pmic_spkr_en_mute(LEFT_SPKR, 0);
-		pmic_spkr_en_mute(RIGHT_SPKR, 0);
-		pmic_set_spkr_configuration(&scm);
-		pmic_spkr_en(LEFT_SPKR, 1);
-		pmic_spkr_en(RIGHT_SPKR, 1);
-		
-		/* unmute */
-		pmic_spkr_en_mute(LEFT_SPKR, 1);
-		pmic_spkr_en_mute(RIGHT_SPKR, 1);
-	} else {
-		pmic_spkr_en_mute(LEFT_SPKR, 0);
-		pmic_spkr_en_mute(RIGHT_SPKR, 0);
-
-		pmic_spkr_en(LEFT_SPKR, 0);
-		pmic_spkr_en(RIGHT_SPKR, 0);
-
-		pmic_set_spkr_configuration(&scm);
-	}
-}
-
-void analog_mic_enable(int en)
-{
-	pr_debug("[%s:%s] en = %d\n", __MM_FILE__, __func__, en);
-	pmic_mic_en(en);
-}
-
-static struct q6audio_analog_ops ops = {
-	.init = analog_init,
-	.speaker_enable = analog_speaker_enable,
-	.headset_enable = analog_headset_enable,
-	.int_mic_enable = analog_mic_enable,
-	.ext_mic_enable = analog_mic_enable,
-};
-
-static int __init init(void)
-{
-	q6audio_register_analog_ops(&ops);
-	return 0;
-}
-
-device_initcall(init);
diff --git a/arch/arm/mach-msm/qdsp6/audio_ctl.c b/arch/arm/mach-msm/qdsp6/audio_ctl.c
deleted file mode 100644
index ab1df39..0000000
--- a/arch/arm/mach-msm/qdsp6/audio_ctl.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright (C) 2009 Google, Inc.
- * Copyright (C) 2009 HTC Corporation
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/msm_audio.h>
-
-#include <mach/msm_qdsp6_audio.h>
-#include <mach/debug_mm.h>
-
-#define BUFSZ (0)
-
-static DEFINE_MUTEX(voice_lock);
-static int voice_started;
-
-static struct audio_client *voc_tx_clnt;
-static struct audio_client *voc_rx_clnt;
-
-static int q6_voice_start(void)
-{
-	int rc = 0;
-
-	mutex_lock(&voice_lock);
-
-	if (voice_started) {
-		pr_err("[%s:%s] busy\n", __MM_FILE__, __func__);
-		rc = -EBUSY;
-		goto done;
-	}
-
-	voc_tx_clnt = q6voice_open(AUDIO_FLAG_WRITE);
-	if (!voc_tx_clnt) {
-		pr_err("[%s:%s] open voice tx failed.\n", __MM_FILE__,
-				__func__);
-		rc = -ENOMEM;
-		goto done;
-	}
-
-	voc_rx_clnt = q6voice_open(AUDIO_FLAG_READ);
-	if (!voc_rx_clnt) {
-		pr_err("[%s:%s] open voice rx failed.\n", __MM_FILE__,
-				__func__);
-		q6voice_close(voc_tx_clnt);
-		rc = -ENOMEM;
-	}
-
-	voice_started = 1;
-done:
-	mutex_unlock(&voice_lock);
-	return rc;
-}
-
-static int q6_voice_stop(void)
-{
-	mutex_lock(&voice_lock);
-	if (voice_started) {
-		q6voice_close(voc_tx_clnt);
-		q6voice_close(voc_rx_clnt);
-		voice_started = 0;
-	}
-	mutex_unlock(&voice_lock);
-	return 0;
-}
-
-static int q6_open(struct inode *inode, struct file *file)
-{
-	pr_debug("[%s:%s]\n", __MM_FILE__, __func__);
-	return 0;
-}
-
-static long q6_ioctl(struct file *file,
-		    unsigned int cmd, unsigned long arg)
-{
-	int rc;
-	uint32_t n;
-	uint32_t id[2];
-	uint32_t mute_status;
-
-	switch (cmd) {
-	case AUDIO_SWITCH_DEVICE:
-		rc = copy_from_user(&id, (void *)arg, sizeof(id));
-		pr_info("[%s:%s] SWITCH_DEV: id[0] = 0x%x, id[1] = 0x%x",
-			__MM_FILE__, __func__, id[0], id[1]);
-		if (!rc)
-			rc = q6audio_do_routing(id[0], id[1]);
-		break;
-	case AUDIO_SET_VOLUME:
-		rc = copy_from_user(&n, (void *)arg, sizeof(n));
-		pr_debug("[%s:%s] SET_VOLUME: vol = %d\n", __MM_FILE__,
-				__func__, n);
-		if (!rc)
-			rc = q6audio_set_rx_volume(n);
-		break;
-	case AUDIO_SET_MUTE:
-		rc = copy_from_user(&n, (void *)arg, sizeof(n));
-		if (!rc) {
-			if (voice_started) {
-				if (n == 1)
-					mute_status = STREAM_MUTE;
-				else
-					mute_status = STREAM_UNMUTE;
-			} else {
-				if (n == 1)
-					mute_status = DEVICE_MUTE;
-				else
-					mute_status = DEVICE_UNMUTE;
-			}
-
-			pr_debug("[%s:%s] SET_MUTE: mute_status = %d\n",
-				__MM_FILE__, __func__, mute_status);
-			rc = q6audio_set_tx_mute(mute_status);
-		}
-		break;
-	case AUDIO_UPDATE_ACDB:
-		rc = copy_from_user(&id, (void *)arg, sizeof(id));
-		pr_debug("[%s:%s] UPDATE_ACDB: id[0] = 0x%x, id[1] = 0x%x\n",
-				__MM_FILE__, __func__, id[0], id[1]);
-		if (!rc)
-			rc = q6audio_update_acdb(id[0], 0);
-		break;
-	case AUDIO_START_VOICE:
-		pr_debug("[%s:%s] START_VOICE\n", __MM_FILE__, __func__);
-		rc = q6_voice_start();
-		break;
-	case AUDIO_STOP_VOICE:
-		pr_debug("[%s:%s] STOP_VOICE\n", __MM_FILE__, __func__);
-		rc = q6_voice_stop();
-		break;
-	case AUDIO_REINIT_ACDB:
-		pr_debug("[%s:%s] REINIT_ACDB\n", __MM_FILE__, __func__);
-		rc = 0;
-		break;
-	default:
-		rc = -EINVAL;
-	}
-
-	return rc;
-}
-
-
-static int q6_release(struct inode *inode, struct file *file)
-{
-	pr_debug("[%s:%s]\n", __MM_FILE__, __func__);
-	return 0;
-}
-
-static struct file_operations q6_dev_fops = {
-	.owner		= THIS_MODULE,
-	.open		= q6_open,
-	.unlocked_ioctl	= q6_ioctl,
-	.release	= q6_release,
-};
-
-struct miscdevice q6_control_device = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_audio_ctl",
-	.fops	= &q6_dev_fops,
-};
-
-
-static int __init q6_audio_ctl_init(void) {
-	return misc_register(&q6_control_device);
-}
-
-device_initcall(q6_audio_ctl_init);
diff --git a/arch/arm/mach-msm/qdsp6/audiov2/Makefile b/arch/arm/mach-msm/qdsp6/audiov2/Makefile
deleted file mode 100644
index 86ab9ae..0000000
--- a/arch/arm/mach-msm/qdsp6/audiov2/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-obj-y += q6audio.o
-obj-y += aac_in.o
-obj-y += voice.o
-obj-y += pcm_out.o
-obj-y += pcm_in.o
-obj-y += mp3.o
-obj-y += audio_ctl.o
-obj-y += analog_audio.o
-obj-y += routing.o
-obj-y += evrc_in.o
-obj-y += qcelp_in.o
-obj-y += amrnb_in.o
diff --git a/arch/arm/mach-msm/qdsp6/audiov2/aac_in.c b/arch/arm/mach-msm/qdsp6/audiov2/aac_in.c
deleted file mode 100644
index ef566c9..0000000
--- a/arch/arm/mach-msm/qdsp6/audiov2/aac_in.c
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright (C) 2009 Google, Inc.
- * Copyright (C) 2009 HTC Corporation
- * Copyright (c) 2009, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/uaccess.h>
-
-#include <linux/msm_audio_aac.h>
-
-#include <mach/msm_qdsp6_audiov2.h>
-#include "dal_audio.h"
-#include "dal_audio_format.h"
-
-struct aac {
-	struct mutex lock;
-	struct msm_audio_aac_enc_config cfg;
-	struct msm_audio_stream_config str_cfg;
-	struct audio_client *audio_client;
-};
-
-static long q6_aac_in_ioctl(struct file *file,
-				 unsigned int cmd, unsigned long arg)
-{
-	struct aac *aac = file->private_data;
-	struct adsp_open_command rpc;
-
-	int sample_rate;
-	int audio_object_type;
-	int index = sizeof(u32);
-	int rc = 0;
-	u32 *aac_type = NULL;
-
-
-	mutex_lock(&aac->lock);
-	switch (cmd) {
-
-	case AUDIO_START:
-		if (aac->audio_client) {
-			rc = -EBUSY;
-			break;
-		} else {
-			tx_clk_freq = 48000;
-			aac->audio_client = q6audio_open(AUDIO_FLAG_READ,
-						aac->str_cfg.buffer_size);
-
-			if (aac->audio_client < 0) {
-
-				tx_clk_freq = 8000;
-				rc = -ENOMEM;
-				break;
-			}
-		}
-		memset(&rpc, 0, sizeof(rpc));
-
-		rpc.format_block.binary.format = ADSP_AUDIO_FORMAT_MPEG4_AAC;
-		/* only 48k sample rate is supported */
-		sample_rate = 3;
-
-		/* AAC OBJECT LC */
-		audio_object_type = 2;
-
-		aac_type = (u32 *)rpc.format_block.binary.data;
-		switch (aac->cfg.stream_format) {
-
-		case AUDIO_AAC_FORMAT_ADTS:
-			/* AAC Encoder expect MPEG4_ADTS media type */
-			*aac_type = ADSP_AUDIO_AAC_MPEG4_ADTS;
-			break;
-		case AUDIO_AAC_FORMAT_RAW:
-			/* for ADIF recording */
-			*aac_type = ADSP_AUDIO_AAC_RAW;
-			break;
-		}
-
-		rpc.format_block.binary.data[index++] = (u8)(
-			((audio_object_type & 0x1F) << 3) |
-			((sample_rate >> 1) & 0x7));
-		rpc.format_block.binary.data[index] = (u8)(
-			((sample_rate & 0x1) << 7) |
-			((aac->cfg.channels & 0x7) << 3));
-
-		rpc.format_block.binary.num_bytes = index + 1;
-		rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_OPEN_READ;
-		rpc.device = ADSP_AUDIO_DEVICE_ID_DEFAULT;
-		rpc.stream_context = ADSP_AUDIO_DEVICE_CONTEXT_RECORD;
-		rpc.buf_max_size = aac->str_cfg.buffer_size;
-		rpc.config.aac.bit_rate = aac->cfg.bit_rate;
-		rpc.config.aac.encoder_mode = ADSP_AUDIO_ENC_AAC_LC_ONLY_MODE;
-		q6audio_start(aac->audio_client, &rpc, sizeof(rpc));
-		break;
-	case AUDIO_STOP:
-		break;
-	case AUDIO_FLUSH:
-		break;
-	case AUDIO_SET_VOLUME:
-		break;
-	case AUDIO_GET_STREAM_CONFIG:
-		if (copy_to_user((void *)arg, &aac->str_cfg,
-			sizeof(struct msm_audio_stream_config)))
-			rc = -EFAULT;
-		break;
-	case AUDIO_SET_STREAM_CONFIG:
-		if (copy_from_user(&aac->str_cfg, (void *)arg,
-			sizeof(struct msm_audio_stream_config))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (aac->str_cfg.buffer_size < 519) {
-			pr_err("Buffer size too small\n");
-			rc = -EINVAL;
-			break;
-		}
-		if (aac->str_cfg.buffer_count != 2)
-			pr_info("Buffer count set to 2\n");
-
-		break;
-	case AUDIO_SET_AAC_ENC_CONFIG:
-		if (copy_from_user(&aac->cfg, (void *) arg,
-				 sizeof(struct msm_audio_aac_enc_config))) {
-			rc = -EFAULT;
-		}
-		if (aac->cfg.channels != 1) {
-			pr_err("only mono is supported\n");
-			rc = -EINVAL;
-		}
-		if (aac->cfg.sample_rate != 48000) {
-			pr_err("only 48KHz is supported\n");
-			rc = -EINVAL;
-		}
-		if (aac->cfg.stream_format != AUDIO_AAC_FORMAT_RAW &&
-			aac->cfg.stream_format != AUDIO_AAC_FORMAT_ADTS) {
-			pr_err("unsupported AAC format\n");
-			rc = -EINVAL;
-		}
-		break;
-	case AUDIO_GET_AAC_ENC_CONFIG:
-		if (copy_to_user((void *) arg, &aac->cfg,
-				 sizeof(struct msm_audio_aac_enc_config))) {
-			rc = -EFAULT;
-		}
-		break;
-	default:
-		rc = -EINVAL;
-	}
-
-	mutex_unlock(&aac->lock);
-	return rc;
-}
-
-static int q6_aac_in_open(struct inode *inode, struct file *file)
-{
-
-	struct aac *aac;
-	aac = kmalloc(sizeof(struct aac), GFP_KERNEL);
-	if (aac == NULL) {
-		pr_err("Could not allocate memory for aac driver\n");
-		return -ENOMEM;
-	}
-
-	mutex_init(&aac->lock);
-	file->private_data = aac;
-	aac->audio_client = NULL;
-	aac->str_cfg.buffer_size = 519;
-	aac->str_cfg.buffer_count = 2;
-	aac->cfg.channels = 1;
-	aac->cfg.bit_rate = 192000;
-	aac->cfg.stream_format = AUDIO_AAC_FORMAT_ADTS;
-	aac->cfg.sample_rate = 48000;
-
-	return 0;
-}
-
-static ssize_t q6_aac_in_read(struct file *file, char __user *buf,
-			  size_t count, loff_t *pos)
-{
-	struct audio_client *ac;
-	struct audio_buffer *ab;
-	const char __user *start = buf;
-	struct aac *aac = file->private_data;
-	int xfer = 0;
-	int res;
-
-	mutex_lock(&aac->lock);
-	ac = aac->audio_client;
-	if (!ac) {
-		res = -ENODEV;
-		goto fail;
-	}
-	while (count > xfer) {
-		ab = ac->buf + ac->cpu_buf;
-
-		if (ab->used)
-			wait_event(ac->wait, (ab->used == 0));
-
-		xfer = ab->actual_size;
-
-		if (copy_to_user(buf, ab->data, xfer)) {
-			res = -EFAULT;
-			goto fail;
-		}
-
-		buf += xfer;
-		count -= xfer;
-
-		ab->used = 1;
-		q6audio_read(ac, ab);
-		ac->cpu_buf ^= 1;
-	}
-	res = buf - start;
-fail:
-	mutex_unlock(&aac->lock);
-
-	return res;
-}
-
-static int q6_aac_in_release(struct inode *inode, struct file *file)
-{
-	int rc = 0;
-	struct aac *aac = file->private_data;
-
-	mutex_lock(&aac->lock);
-	if (aac->audio_client)
-		rc = q6audio_close(aac->audio_client);
-	mutex_unlock(&aac->lock);
-	kfree(aac);
-	tx_clk_freq = 8000;
-	return rc;
-}
-
-static const struct file_operations q6_aac_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= q6_aac_in_open,
-	.read		= q6_aac_in_read,
-	.release	= q6_aac_in_release,
-	.unlocked_ioctl	= q6_aac_in_ioctl,
-};
-
-struct miscdevice q6_aac_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_aac_in",
-	.fops	= &q6_aac_in_fops,
-};
-
-static int __init q6_aac_in_init(void)
-{
-	return misc_register(&q6_aac_in_misc);
-}
-
-device_initcall(q6_aac_in_init);
diff --git a/arch/arm/mach-msm/qdsp6/audiov2/amrnb_in.c b/arch/arm/mach-msm/qdsp6/audiov2/amrnb_in.c
deleted file mode 100644
index e552ada..0000000
--- a/arch/arm/mach-msm/qdsp6/audiov2/amrnb_in.c
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Copyright (C) 2009 Google, Inc.
- * Copyright (C) 2009 HTC Corporation
- * Copyright (c) 2010, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/uaccess.h>
-
-#include <linux/msm_audio_amrnb.h>
-#include <mach/msm_qdsp6_audiov2.h>
-#include "dal_audio.h"
-#include "dal_audio_format.h"
-#include <mach/debug_mm.h>
-
-
-struct amrnb {
-	struct mutex lock;
-	struct msm_audio_amrnb_enc_config_v2 cfg;
-	struct msm_audio_stream_config str_cfg;
-	struct audio_client *audio_client;
-};
-
-
-static long q6_amrnb_in_ioctl(struct file *file, unsigned int cmd,
-				unsigned long arg)
-{
-	struct amrnb *amrnb = file->private_data;
-	struct adsp_open_command rpc;
-	int rc = 0;
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		memset(&stats, 0, sizeof(stats));
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-
-	mutex_lock(&amrnb->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		if (amrnb->audio_client) {
-			rc = -EBUSY;
-			break;
-		} else {
-			amrnb->audio_client = q6audio_open(AUDIO_FLAG_READ,
-						amrnb->str_cfg.buffer_size);
-
-			if (!amrnb->audio_client) {
-				kfree(amrnb);
-				rc = -ENOMEM;
-				break;
-			}
-		}
-
-		tx_clk_freq = 8000;
-
-		memset(&rpc, 0, sizeof(rpc));
-
-		rpc.format_block.standard.format = ADSP_AUDIO_FORMAT_AMRNB_FS;
-		rpc.format_block.standard.channels = 1;
-		rpc.format_block.standard.bits_per_sample = 16;
-		rpc.format_block.standard.sampling_rate = 8000;
-		rpc.format_block.standard.is_signed = 1;
-		rpc.format_block.standard.is_interleaved = 0;
-
-		rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_OPEN_READ;
-		rpc.device = ADSP_AUDIO_DEVICE_ID_DEFAULT;
-		rpc.stream_context = ADSP_AUDIO_DEVICE_CONTEXT_RECORD;
-		rpc.buf_max_size = amrnb->str_cfg.buffer_size;
-		rpc.config.amr.mode = amrnb->cfg.band_mode;
-		rpc.config.amr.dtx_mode = amrnb->cfg.dtx_enable;
-		rpc.config.amr.enable = 1;
-		q6audio_start(amrnb->audio_client, &rpc, sizeof(rpc));
-		break;
-	case AUDIO_STOP:
-		break;
-	case AUDIO_FLUSH:
-		break;
-	case AUDIO_SET_VOLUME:
-		break;
-	case AUDIO_GET_STREAM_CONFIG:
-		if (copy_to_user((void *)arg, &amrnb->str_cfg,
-			sizeof(struct msm_audio_stream_config)))
-			rc = -EFAULT;
-		break;
-	case AUDIO_SET_STREAM_CONFIG:
-		if (copy_from_user(&amrnb->str_cfg, (void *)arg,
-			sizeof(struct msm_audio_stream_config))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		if (amrnb->str_cfg.buffer_size < 768) {
-			pr_err("[%s:%s] Buffer size too small\n", __MM_FILE__,
-					__func__);
-			rc = -EINVAL;
-			break;
-		}
-
-		if (amrnb->str_cfg.buffer_count != 2)
-			pr_info("[%s:%s] Buffer count set to 2\n", __MM_FILE__,
-					__func__);
-		break;
-	case AUDIO_SET_AMRNB_ENC_CONFIG:
-		if (copy_from_user(&amrnb->cfg, (void *) arg,
-			sizeof(struct msm_audio_amrnb_enc_config_v2)))
-			rc = -EFAULT;
-		break;
-	case AUDIO_GET_AMRNB_ENC_CONFIG:
-		if (copy_to_user((void *) arg, &amrnb->cfg,
-				 sizeof(struct msm_audio_amrnb_enc_config_v2)))
-			rc = -EFAULT;
-		break;
-
-	default:
-		rc = -EINVAL;
-	}
-
-	mutex_unlock(&amrnb->lock);
-	return rc;
-}
-
-static int q6_amrnb_in_open(struct inode *inode, struct file *file)
-{
-	struct amrnb *amrnb;
-	amrnb = kmalloc(sizeof(struct amrnb), GFP_KERNEL);
-	if (amrnb == NULL) {
-		pr_err("[%s:%s] Could not allocate memory for amrnb driver\n",
-				__MM_FILE__, __func__);
-		return -ENOMEM;
-	}
-
-	mutex_init(&amrnb->lock);
-	file->private_data = amrnb;
-	amrnb->audio_client = NULL;
-	amrnb->str_cfg.buffer_size = 768;
-	amrnb->str_cfg.buffer_count = 2;
-	amrnb->cfg.band_mode = ADSP_AUDIO_AMR_MR475;
-	amrnb->cfg.dtx_enable  = ADSP_AUDIO_AMR_DTX_MODE_ON_AUTO;
-	amrnb->cfg.frame_format  = ADSP_AUDIO_FORMAT_AMRNB_FS;
-	return 0;
-}
-
-static ssize_t q6_amrnb_in_read(struct file *file, char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct audio_client *ac;
-	struct audio_buffer *ab;
-	const char __user *start = buf;
-	struct amrnb *amrnb = file->private_data;
-	int xfer = 0;
-	int res;
-
-	mutex_lock(&amrnb->lock);
-	ac = amrnb->audio_client;
-	if (!ac) {
-		res = -ENODEV;
-		goto fail;
-	}
-	while (count > xfer) {
-		ab = ac->buf + ac->cpu_buf;
-
-		if (ab->used)
-			wait_event(ac->wait, (ab->used == 0));
-
-		xfer = ab->actual_size;
-
-		if (copy_to_user(buf, ab->data, xfer)) {
-			res = -EFAULT;
-			goto fail;
-		}
-
-		buf += xfer;
-		count -= xfer;
-
-		ab->used = 1;
-		q6audio_read(ac, ab);
-		ac->cpu_buf ^= 1;
-	}
-
-	res = buf - start;
-fail:
-	mutex_unlock(&amrnb->lock);
-
-	return res;
-}
-
-static int q6_amrnb_in_release(struct inode *inode, struct file *file)
-{
-	int rc = 0;
-	struct amrnb *amrnb = file->private_data;
-
-	mutex_lock(&amrnb->lock);
-	if (amrnb->audio_client)
-		rc = q6audio_close(amrnb->audio_client);
-	mutex_unlock(&amrnb->lock);
-	kfree(amrnb);
-	return rc;
-}
-
-static const struct file_operations q6_amrnb_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= q6_amrnb_in_open,
-	.read		= q6_amrnb_in_read,
-	.release	= q6_amrnb_in_release,
-	.unlocked_ioctl	= q6_amrnb_in_ioctl,
-};
-
-struct miscdevice q6_amrnb_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_amr_in",
-	.fops	= &q6_amrnb_in_fops,
-};
-
-static int __init q6_amrnb_in_init(void)
-{
-	return misc_register(&q6_amrnb_in_misc);
-}
-
-device_initcall(q6_amrnb_in_init);
diff --git a/arch/arm/mach-msm/qdsp6/audiov2/analog_audio.c b/arch/arm/mach-msm/qdsp6/audiov2/analog_audio.c
deleted file mode 100644
index 5bf2cea..0000000
--- a/arch/arm/mach-msm/qdsp6/audiov2/analog_audio.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/gpio.h>
-#include <mach/pmic.h>
-#include <mach/msm_qdsp6_audiov2.h>
-
-#define GPIO_HEADSET_AMP 157
-
-void analog_init(void)
-{
-	/* stereo pmic init */
-	pmic_spkr_set_gain(LEFT_SPKR, SPKR_GAIN_PLUS12DB);
-	pmic_spkr_set_gain(RIGHT_SPKR, SPKR_GAIN_PLUS12DB);
-	pmic_mic_set_volt(MIC_VOLT_1_80V);
-
-	gpio_direction_output(GPIO_HEADSET_AMP, 1);
-	gpio_set_value(GPIO_HEADSET_AMP, 0);
-}
-
-void analog_headset_enable(int en)
-{
-	/* enable audio amp */
-	gpio_set_value(GPIO_HEADSET_AMP, !!en);
-}
-
-void analog_speaker_enable(int en)
-{
-	struct spkr_config_mode scm;
-	memset(&scm, 0, sizeof(scm));
-
-	if (en) {
-		scm.is_right_chan_en = 1;
-		scm.is_left_chan_en = 1;
-		scm.is_stereo_en = 1;
-		scm.is_hpf_en = 1;
-		pmic_spkr_en_mute(LEFT_SPKR, 0);
-		pmic_spkr_en_mute(RIGHT_SPKR, 0);
-		pmic_set_spkr_configuration(&scm);
-		pmic_spkr_en(LEFT_SPKR, 1);
-		pmic_spkr_en(RIGHT_SPKR, 1);
-
-		/* unmute */
-		pmic_spkr_en_mute(LEFT_SPKR, 1);
-		pmic_spkr_en_mute(RIGHT_SPKR, 1);
-	} else {
-		pmic_spkr_en_mute(LEFT_SPKR, 0);
-		pmic_spkr_en_mute(RIGHT_SPKR, 0);
-
-		pmic_spkr_en(LEFT_SPKR, 0);
-		pmic_spkr_en(RIGHT_SPKR, 0);
-
-		pmic_set_spkr_configuration(&scm);
-	}
-}
-
-void analog_mic_enable(int en)
-{
-	pmic_mic_en(en);
-}
-
-static struct q6audio_analog_ops ops = {
-	.init = analog_init,
-	.speaker_enable = analog_speaker_enable,
-	.headset_enable = analog_headset_enable,
-	.int_mic_enable = analog_mic_enable,
-};
-
-static int __init init(void)
-{
-	q6audio_register_analog_ops(&ops);
-	return 0;
-}
-
-device_initcall(init);
diff --git a/arch/arm/mach-msm/qdsp6/audiov2/audio_ctl.c b/arch/arm/mach-msm/qdsp6/audiov2/audio_ctl.c
deleted file mode 100644
index 4ebfc02..0000000
--- a/arch/arm/mach-msm/qdsp6/audiov2/audio_ctl.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/* arch/arm/mach-msm/qdsp6/audiov2/audio_ctrl.c
- *
- * Copyright (C) 2009 Google, Inc.
- * Copyright (C) 2009 HTC Corporation
- * Copyright (c) 2009, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/msm_audio.h>
-
-#include <mach/msm_qdsp6_audiov2.h>
-
-#define BUFSZ (0)
-
-static DEFINE_MUTEX(voice_lock);
-static int voice_started;
-
-static struct audio_client *voc_clnt;
-
-static int q6_voice_start(void)
-{
-	int rc = 0;
-
-	mutex_lock(&voice_lock);
-
-	if (voice_started) {
-		pr_err("voice: busy\n");
-		rc = -EBUSY;
-		goto done;
-	}
-
-	voc_clnt = q6voice_open();
-	if (!voc_clnt) {
-		pr_err("voice: open voice failed.\n");
-		rc = -ENOMEM;
-		goto done;
-	}
-
-	voice_started = 1;
-done:
-	mutex_unlock(&voice_lock);
-	return rc;
-}
-
-static int q6_voice_stop(void)
-{
-	mutex_lock(&voice_lock);
-	if (voice_started) {
-		q6voice_close(voc_clnt);
-		voice_started = 0;
-	}
-	mutex_unlock(&voice_lock);
-	return 0;
-}
-
-static int q6_open(struct inode *inode, struct file *file)
-{
-	return 0;
-}
-
-static int q6_ioctl(struct inode *inode, struct file *file,
-		    unsigned int cmd, unsigned long arg)
-{
-	int rc;
-	uint32_t n;
-	uint32_t id[2];
-
-	switch (cmd) {
-	case AUDIO_SWITCH_DEVICE:
-		rc = copy_from_user(&n, (void *)arg, sizeof(n));
-		if (!rc)
-			rc = q6audio_do_routing(n);
-		break;
-	case AUDIO_SET_VOLUME:
-		rc = copy_from_user(&n, (void *)arg, sizeof(n));
-		if (!rc)
-			rc = q6audio_set_rx_volume(n);
-		break;
-	case AUDIO_SET_MUTE:
-		rc = copy_from_user(&n, (void *)arg, sizeof(n));
-		if (!rc)
-			rc = q6audio_set_tx_mute(n);
-		break;
-	case AUDIO_UPDATE_ACDB:
-		rc = copy_from_user(&id, (void *)arg, sizeof(id));
-		if (!rc)
-			rc = q6audio_update_acdb(id[0], id[1]);
-		break;
-	case AUDIO_START_VOICE:
-		rc = q6_voice_start();
-		break;
-	case AUDIO_STOP_VOICE:
-		rc = q6_voice_stop();
-		break;
-	default:
-		rc = -EINVAL;
-	}
-
-	return rc;
-}
-
-
-static int q6_release(struct inode *inode, struct file *file)
-{
-	return 0;
-}
-
-static const struct file_operations q6_dev_fops = {
-	.owner		= THIS_MODULE,
-	.open		= q6_open,
-	.ioctl		= q6_ioctl,
-	.release	= q6_release,
-};
-
-struct miscdevice q6_control_device = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_audio_ctl",
-	.fops	= &q6_dev_fops,
-};
-
-
-static int __init q6_audio_ctl_init(void)
-{
-	return misc_register(&q6_control_device);
-}
-
-device_initcall(q6_audio_ctl_init);
diff --git a/arch/arm/mach-msm/qdsp6/audiov2/dal_acdb.h b/arch/arm/mach-msm/qdsp6/audiov2/dal_acdb.h
deleted file mode 100644
index b4949f9..0000000
--- a/arch/arm/mach-msm/qdsp6/audiov2/dal_acdb.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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 ACDB_DAL_DEVICE		0x02000069
-#define ACDB_DAL_PORT		"DAL_AM_AUD"
-#define ACDB_DAL_VERSION	0x00010000
-
-#define ACDB_OP_IOCTL		DAL_OP_FIRST_DEVICE_API
-
-/* ioctls */
-#define ACDB_GET_DEVICE		0x0108bb92
-#define ACDB_SET_DEVICE		0x0108bb93
-#define ACDB_GET_STREAM		0x0108bb95
-#define ACDB_SET_STREAM		0x0108bb96
-#define ACDB_GET_DEVICE_TABLE	0x0108bb97
-#define ACDB_GET_STREAM_TABLE	0x0108bb98
-
-#define ACDB_RES_SUCCESS	0
-#define ACDB_RES_FAILURE	-1
-#define ACDB_RES_BADPARM	-2
-#define ACDB_RES_BADSTATE	-3
-
-struct acdb_cmd_device {
-	uint32_t size;
-
-	uint32_t command_id;
-	uint32_t device_id;
-	uint32_t network_id;
-	uint32_t sample_rate_id;
-	uint32_t interface_id;
-	uint32_t algorithm_block_id;
-
-	/* physical page aligned buffer */
-	uint32_t total_bytes;
-	uint32_t unmapped_buf;
-} __attribute__((packed));
-
-struct acdb_cmd_device_table {
-	uint32_t size;
-
-	uint32_t command_id;
-	uint32_t device_id;
-	uint32_t network_id;
-	uint32_t sample_rate_id;
-
-	/* physical page aligned buffer */
-	uint32_t total_bytes;
-	uint32_t unmapped_buf;
-
-	uint32_t res_size;
-} __attribute__((packed));
-
-struct acdb_result {
-	uint32_t dal_status;
-	uint32_t size;
-
-	uint32_t total_devices;
-	uint32_t unmapped_buf;
-	uint32_t used_bytes;
-	uint32_t result;
-} __attribute__((packed));
diff --git a/arch/arm/mach-msm/qdsp6/audiov2/dal_adie.h b/arch/arm/mach-msm/qdsp6/audiov2/dal_adie.h
deleted file mode 100644
index aac484c..0000000
--- a/arch/arm/mach-msm/qdsp6/audiov2/dal_adie.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-
-#ifndef _MACH_MSM_QDSP6_ADIE_
-#define _MACH_MSM_QDSP6_ADIE_
-
-#include "../dal.h"
-
-#define ADIE_DAL_DEVICE		0x02000029
-#define ADIE_DAL_PORT		"DAL_AM_AUD"
-#define ADIE_DAL_VERSION	0x00010000
-
-enum {
-	ADIE_OP_SET_PATH =  DAL_OP_FIRST_DEVICE_API,
-	ADIE_OP_PROCEED_TO_STAGE,
-	ADIE_OP_IOCTL
-};
-
-/* Path IDs for normal operation. */
-#define ADIE_PATH_HANDSET_TX			0x010740f6
-#define ADIE_PATH_HANDSET_RX			0x010740f7
-#define ADIE_PATH_HEADSET_MONO_TX		0x010740f8
-#define ADIE_PATH_HEADSET_STEREO_TX		0x010740f9
-#define ADIE_PATH_HEADSET_MONO_RX		0x010740fa
-#define ADIE_PATH_HEADSET_STEREO_RX		0x010740fb
-#define ADIE_PATH_SPEAKER_TX			0x010740fc
-#define ADIE_PATH_SPEAKER_RX			0x010740fd
-#define ADIE_PATH_SPEAKER_STEREO_RX		0x01074101
-
-/* Path IDs used for TTY */
-#define ADIE_PATH_TTY_HEADSET_TX		0x010740fe
-#define ADIE_PATH_TTY_HEADSET_RX		0x010740ff
-
-/* Path IDs used by Factory Test Mode. */
-#define ADIE_PATH_FTM_MIC1_TX			0x01074108
-#define ADIE_PATH_FTM_MIC2_TX			0x01074107
-#define ADIE_PATH_FTM_HPH_L_RX			0x01074106
-#define ADIE_PATH_FTM_HPH_R_RX			0x01074104
-#define ADIE_PATH_FTM_EAR_RX			0x01074103
-#define ADIE_PATH_FTM_SPKR_RX			0x01074102
-
-/* Path IDs for Loopback */
-/* Path IDs used for Line in -> AuxPGA -> Line Out Stereo Mode*/
-#define ADIE_PATH_AUXPGA_LINEOUT_STEREO_LB	0x01074100
-/* Line in -> AuxPGA -> LineOut Mono */
-#define ADIE_PATH_AUXPGA_LINEOUT_MONO_LB	0x01073d82
-/* Line in -> AuxPGA -> Stereo Headphone */
-#define ADIE_PATH_AUXPGA_HDPH_STEREO_LB		0x01074109
-/* Line in -> AuxPGA -> Mono Headphone */
-#define ADIE_PATH_AUXPGA_HDPH_MONO_LB		0x01073d85
-/* Line in -> AuxPGA -> Earpiece */
-#define ADIE_PATH_AUXPGA_EAP_LB			0x01073d81
-/* Line in -> AuxPGA -> AuxOut */
-#define ADIE_PATH_AUXPGA_AUXOUT_LB		0x01073d86
-
-/* Concurrency Profiles */
-#define ADIE_PATH_SPKR_STEREO_HDPH_MONO_RX	0x01073d83
-#define ADIE_PATH_SPKR_MONO_HDPH_MONO_RX	0x01073d84
-#define ADIE_PATH_SPKR_MONO_HDPH_STEREO_RX	0x01073d88
-#define ADIE_PATH_SPKR_STEREO_HDPH_STEREO_RX	0x01073d89
-
-/* stages */
-#define ADIE_STAGE_PATH_OFF			0x0050
-#define ADIE_STAGE_DIGITAL_READY		0x0100
-#define ADIE_STAGE_DIGITAL_ANALOG_READY		0x1000
-#define ADIE_STAGE_ANALOG_OFF			0x0750
-#define ADIE_STAGE_DIGITAL_OFF			0x0600
-
-/* path types */
-#define ADIE_PATH_RX		0
-#define ADIE_PATH_TX		1
-#define ADIE_PATH_LOOPBACK	2
-
-/* mute states */
-#define ADIE_MUTE_OFF		0
-#define ADIE_MUTE_ON		1
-
-
-#endif
diff --git a/arch/arm/mach-msm/qdsp6/audiov2/dal_audio.h b/arch/arm/mach-msm/qdsp6/audiov2/dal_audio.h
deleted file mode 100644
index 2f9510b..0000000
--- a/arch/arm/mach-msm/qdsp6/audiov2/dal_audio.h
+++ /dev/null
@@ -1,546 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-
-#ifndef __DAL_AUDIO_H__
-#define __DAL_AUDIO_H__
-
-#include "../dal.h"
-#include "dal_audio_format.h"
-
-#define AUDIO_DAL_DEVICE 0x02000028
-#define AUDIO_DAL_PORT "DAL_AQ_AUD"
-#define AUDIO_DAL_VERSION	0x00030001
-
-enum {
-	AUDIO_OP_CONTROL = DAL_OP_FIRST_DEVICE_API,
-	AUDIO_OP_DATA,
-	AUDIO_OP_INIT,
-};
-
-/* ---- common audio structures ---- */
-
-/* This flag, if set, indicates that the beginning of the data in the*/
-/* buffer is a synchronization point or key frame, meaning no data */
-/* before it in the stream is required in order to render the stream */
-/* from this point onward. */
-#define ADSP_AUDIO_BUFFER_FLAG_SYNC_POINT        0x01
-
-/* This flag, if set, indicates that the buffer object is using valid */
-/* physical address used to store the media data */
-#define ADSP_AUDIO_BUFFER_FLAG_PHYS_ADDR         0x04
-
-/* This flag, if set, indicates that a media start timestamp has been */
-/* set for a buffer. */
-#define ADSP_AUDIO_BUFFER_FLAG_START_SET         0x08
-
-/* This flag, if set, indicates that a media stop timestamp has been set */
-/* for a buffer. */
-#define ADSP_AUDIO_BUFFER_FLAG_STOP_SET          0x10
-
-/* This flag, if set, indicates that a preroll timestamp has been set */
-/* for a buffer. */
-#define ADSP_AUDIO_BUFFER_FLAG_PREROLL_SET       0x20
-
-/* This flag, if set, indicates that the data in the buffer is a fragment of */
-/* a larger block of data, and will be continued by the data in the next */
-/* buffer to be delivered. */
-#define ADSP_AUDIO_BUFFER_FLAG_CONTINUATION      0x40
-
-struct adsp_audio_buffer {
-	u32 addr;		/* Physical Address of buffer */
-	u32 max_size;		/* Maximum size of buffer */
-	u32 actual_size;	/* Actual size of valid data in the buffer */
-	u32 offset;		/* Offset to the first valid byte */
-	u32 flags;		/* ADSP_AUDIO_BUFFER_FLAGs that has been set */
-	s64 start;		/* Start timestamp, if any */
-	s64 stop;		/* Stop timestamp, if any */
-	s64 preroll;		/* Preroll timestamp, if any */
-} __attribute__ ((packed));
-
-
-
-/* ---- audio commands ---- */
-
-/* Command/event response types */
-#define ADSP_AUDIO_RESPONSE_COMMAND   0
-#define ADSP_AUDIO_RESPONSE_ASYNC     1
-
-struct adsp_command_hdr {
-	u32 size;		/* sizeof(cmd) - sizeof(u32) */
-
-	u32 dest;
-	u32 src;
-	u32 opcode;
-	u32 response_type;
-	u32 seq_number;
-
-	u32 context;		/* opaque to DSP */
-	u32 data;
-	u32 padding;
-} __attribute__ ((packed));
-
-
-#define DOMAIN_APP	0
-#define DOMAIN_MODEM	1
-#define DOMAIN_DSP	2
-
-
-/* adsp audio addresses are (byte order) major, minor, domain */
-#define AUDIO_ADDR(dmn, maj, min) (((maj & 0xff) << 16) \
-		| ((min & 0xff) << 24) | (dmn & 0xff))
-
-/* AAC Encoder modes */
-#define ADSP_AUDIO_ENC_AAC_LC_ONLY_MODE		0
-#define ADSP_AUDIO_ENC_AAC_PLUS_MODE		1
-#define ADSP_AUDIO_ENC_ENHANCED_AAC_PLUS_MODE	2
-
-struct adsp_audio_aac_enc_cfg {
-	u32 bit_rate;		/* bits per second */
-	u32 encoder_mode;	/* ADSP_AUDIO_ENC_* */
-} __attribute__ ((packed));
-
-#define ADSP_AUDIO_ENC_SBC_ALLOCATION_METHOD_LOUNDNESS     0
-#define ADSP_AUDIO_ENC_SBC_ALLOCATION_METHOD_SNR           1
-
-#define ADSP_AUDIO_ENC_SBC_CHANNEL_MODE_MONO                1
-#define ADSP_AUDIO_ENC_SBC_CHANNEL_MODE_STEREO              2
-#define ADSP_AUDIO_ENC_SBC_CHANNEL_MODE_DUAL                8
-#define ADSP_AUDIO_ENC_SBC_CHANNEL_MODE_JOINT_STEREO        9
-
-struct adsp_audio_sbc_encoder_cfg {
-	u32 num_subbands;
-	u32 block_len;
-	u32 channel_mode;
-	u32 allocation_method;
-	u32 bit_rate;
-} __attribute__ ((packed));
-
-/* AMR NB encoder modes */
-#define ADSP_AUDIO_AMR_MR475	0
-#define ADSP_AUDIO_AMR_MR515	1
-#define ADSP_AUDIO_AMR_MMR59	2
-#define ADSP_AUDIO_AMR_MMR67	3
-#define ADSP_AUDIO_AMR_MMR74	4
-#define ADSP_AUDIO_AMR_MMR795	5
-#define ADSP_AUDIO_AMR_MMR102	6
-#define ADSP_AUDIO_AMR_MMR122	7
-
-/* The following are valid AMR NB DTX modes */
-#define ADSP_AUDIO_AMR_DTX_MODE_OFF		0
-#define ADSP_AUDIO_AMR_DTX_MODE_ON_VAD1		1
-#define ADSP_AUDIO_AMR_DTX_MODE_ON_VAD2		2
-#define ADSP_AUDIO_AMR_DTX_MODE_ON_AUTO		3
-
-/* AMR Encoder configuration */
-struct adsp_audio_amr_enc_cfg {
-	u32	mode;		/* ADSP_AUDIO_AMR_MR* */
-	u32	dtx_mode;	/* ADSP_AUDIO_AMR_DTX_MODE* */
-	u32	enable;		/* 1 = enable, 0 = disable */
-} __attribute__ ((packed));
-
-struct adsp_audio_qcelp13k_enc_cfg {
-	u16	min_rate;
-	u16	max_rate;
-} __attribute__ ((packed));
-
-struct adsp_audio_evrc_enc_cfg {
-	u16	min_rate;
-	u16	max_rate;
-} __attribute__ ((packed));
-
-union adsp_audio_codec_config {
-	struct adsp_audio_amr_enc_cfg amr;
-	struct adsp_audio_aac_enc_cfg aac;
-	struct adsp_audio_qcelp13k_enc_cfg qcelp13k;
-	struct adsp_audio_evrc_enc_cfg evrc;
-	struct adsp_audio_sbc_encoder_cfg sbc;
-} __attribute__ ((packed));
-
-
-/* This is the default value. */
-#define ADSP_AUDIO_OPEN_STREAM_MODE_NONE		0x0000
-
-/* This bit, if set, indicates that the AVSync mode is activated. */
-#define ADSP_AUDIO_OPEN_STREAM_MODE_AVSYNC		0x0001
-
-/* This bit, if set, indicates that the Sample Rate/Channel Mode */
-/* Change Notification mode is activated. */
-#define ADSP_AUDIO_OPEN_STREAM_MODE_SR_CM_NOTIFY	0x0002
-
-#define  ADSP_AUDIO_OPEN_STREAM_MODE_ENABLE_SYNC_CLOCK	0x0004
-
-#define ADSP_AUDIO_MAX_DEVICES 1
-
-struct adsp_open_command {
-	struct adsp_command_hdr hdr;
-	u32 device;
-	u32 end_point;
-	u32 stream_context;
-	u32 mode;
-	u32 buf_max_size;
-	union adsp_audio_format format_block;
-	union adsp_audio_codec_config config;
-
-} __attribute__ ((packed));
-
-
-/* --- audio control and stream session ioctls ---- */
-
-/* Opcode to open a device stream session to capture audio */
-#define ADSP_AUDIO_IOCTL_CMD_OPEN_READ			0x0108dd79
-
-/* Opcode to open a device stream session to render audio */
-#define ADSP_AUDIO_IOCTL_CMD_OPEN_WRITE			0x0108dd7a
-
-/* Opcode to open a device session, must open a device */
-#define ADSP_AUDIO_IOCTL_CMD_OPEN_DEVICE		0x0108dd7b
-
-/* Close an existing stream or device */
-#define ADSP_AUDIO_IOCTL_CMD_CLOSE			0x0108d8bc
-
-
-
-/* A device switch requires three IOCTL */
-/* commands in the following sequence: PREPARE, STANDBY, COMMIT */
-
-/* adsp_audio_device_switch_command structure is needed for */
-/* DEVICE_SWITCH_PREPARE */
-
-/* Device switch protocol step #1. Pause old device and */
-/* generate silence for the old device. */
-#define ADSP_AUDIO_IOCTL_CMD_DEVICE_SWITCH_PREPARE	0x010815c4
-
-/* Device switch protocol step #2. Release old device, */
-/* create new device and generate silence for the new device. */
-
-/* When client receives ack for this IOCTL, the client can */
-/* start sending IOCTL commands to configure, calibrate and */
-/* change filter settings on the new device. */
-#define ADSP_AUDIO_IOCTL_CMD_DEVICE_SWITCH_STANDBY	0x010815c5
-
-/* Device switch protocol step #3. Start normal operations on new device */
-#define ADSP_AUDIO_IOCTL_CMD_DEVICE_SWITCH_COMMIT	0x01075ee7
-
-struct adsp_device_switch_command {
-	struct adsp_command_hdr hdr;
-	u32 old_device;
-	u32 new_device;
-	u8 device_class; /* 0 = i.rx, 1 = i.tx, 2 = e.rx, 3 = e.tx */
-	u8 device_type; /* 0 = rx, 1 = tx, 2 = both */
-} __attribute__ ((packed));
-
-
-
-/* --- audio control session ioctls ---- */
-
-#define ADSP_PATH_RX	0
-#define ADSP_PATH_TX	1
-#define ADSP_PATH_BOTH	2
-
-/* These commands will affect a logical device and all its associated */
-/* streams. */
-
-
-/* Set device volume. */
-#define ADSP_AUDIO_IOCTL_CMD_SET_DEVICE_VOL		0x0107605c
-
-struct adsp_set_dev_volume_command {
-	struct adsp_command_hdr hdr;
-	u32 device_id;
-	u32 path; /* 0 = rx, 1 = tx, 2 = both */
-	s32 volume;
-} __attribute__ ((packed));
-
-/* Set Device stereo volume. This command has data payload, */
-/* struct adsp_audio_set_dev_stereo_volume_command. */
-#define ADSP_AUDIO_IOCTL_SET_DEVICE_STEREO_VOL		0x0108df3e
-
-/* Set L, R cross channel gain for a Device. This command has */
-/* data payload, struct adsp_audio_set_dev_x_chan_gain_command. */
-#define ADSP_AUDIO_IOCTL_SET_DEVICE_XCHAN_GAIN		0x0108df40
-
-/* Set device mute state. */
-#define ADSP_AUDIO_IOCTL_CMD_SET_DEVICE_MUTE		0x0107605f
-
-struct adsp_set_dev_mute_command {
-	struct adsp_command_hdr hdr;
-	u32 device_id;
-	u32 path; /* 0 = rx, 1 = tx, 2 = both */
-	u32 mute; /* 1 = mute */
-} __attribute__ ((packed));
-
-/* Configure Equalizer for a device. */
-/* This command has payload struct adsp_audio_set_dev_equalizer_command. */
-#define ADSP_AUDIO_IOCTL_CMD_SET_DEVICE_EQ_CONFIG	0x0108b10e
-
-/* Set configuration data for an algorithm aspect of a device. */
-/* This command has payload struct adsp_audio_set_dev_cfg_command. */
-#define ADSP_AUDIO_IOCTL_SET_DEVICE_CONFIG		0x0108b6cb
-
-struct adsp_set_dev_cfg_command {
-	struct adsp_command_hdr hdr;
-	u32 device_id;
-	u32 block_id;
-	u32 interface_id;
-	u32 phys_addr;
-	u32 phys_size;
-	u32 phys_used;
-} __attribute__ ((packed));
-
-/* Set configuration data for all interfaces of a device. */
-#define ADSP_AUDIO_IOCTL_SET_DEVICE_CONFIG_TABLE	0x0108b6bf
-
-struct adsp_set_dev_cfg_table_command {
-	struct adsp_command_hdr hdr;
-	u32 device_id;
-	u32 phys_addr;
-	u32 phys_size;
-	u32 phys_used;
-} __attribute__ ((packed));
-
-/* ---- audio stream data commands ---- */
-
-#define ADSP_AUDIO_IOCTL_CMD_DATA_TX			0x0108dd7f
-#define ADSP_AUDIO_IOCTL_CMD_DATA_RX			0x0108dd80
-
-struct adsp_buffer_command {
-	struct adsp_command_hdr hdr;
-	struct adsp_audio_buffer buffer;
-} __attribute__ ((packed));
-
-
-
-/* ---- audio stream ioctls (only affect a single stream in a session) ---- */
-
-/* Stop stream for audio device. */
-#define ADSP_AUDIO_IOCTL_CMD_STREAM_STOP		0x01075c54
-
-/* End of stream reached. Client will not send any more data. */
-#define ADSP_AUDIO_IOCTL_CMD_STREAM_EOS			0x0108b150
-
-/* Do sample slipping/stuffing on AAC outputs. The payload of */
-/* this command is struct adsp_audio_slip_sample_command. */
-#define ADSP_AUDIO_IOCTL_CMD_STREAM_SLIPSAMPLE		0x0108d40e
-
-/* Set stream volume. */
-/* This command has data payload, struct adsp_audio_set_volume_command. */
-#define ADSP_AUDIO_IOCTL_CMD_SET_STREAM_VOL		0x0108c0de
-
-/* Set stream stereo volume. This command has data payload, */
-/* struct adsp_audio_set_stereo_volume_command. */
-#define ADSP_AUDIO_IOCTL_SET_STREAM_STEREO_VOL		0x0108dd7c
-
-/* Set L, R cross channel gain for a Stream. This command has */
-/* data payload, struct adsp_audio_set_x_chan_gain_command. */
-#define ADSP_AUDIO_IOCTL_SET_STREAM_XCHAN_GAIN		0x0108dd7d
-
-/* Set stream mute state. */
-/* This command has data payload, struct adsp_audio_set_stream_mute. */
-#define ADSP_AUDIO_IOCTL_CMD_SET_STREAM_MUTE		0x0108c0df
-
-/* Reconfigure bit rate information. This command has data */
-/* payload, struct adsp_audio_set_bit_rate_command */
-#define ADSP_AUDIO_IOCTL_SET_STREAM_BITRATE		0x0108ccf1
-
-/* Set Channel Mapping. This command has data payload, struct */
-/* This command has data payload struct adsp_audio_set_channel_map_command. */
-#define ADSP_AUDIO_IOCTL_SET_STREAM_CHANNELMAP		0x0108d32a
-
-/* Enable/disable AACPlus SBR. */
-/* This command has data payload struct adsp_audio_set_sbr_command */
-#define ADSP_AUDIO_IOCTL_SET_STREAM_SBR			0x0108d416
-
-/* Enable/disable WMA Pro Chex and Fex. This command has data payload */
-/* struct adsp_audio_stream_set_wma_command. */
-#define ADSP_AUDIO_IOCTL_SET_STREAM_WMAPRO		0x0108d417
-
-
-/* ---- audio session ioctls (affect all streams in a session) --- */
-
-/* Start stream for audio device. */
-#define ADSP_AUDIO_IOCTL_CMD_SESSION_START		0x010815c6
-
-/* Stop all stream(s) for audio session as indicated by major id. */
-#define ADSP_AUDIO_IOCTL_CMD_SESSION_STOP		0x0108dd7e
-
-/* Pause the data flow for a session as indicated by major id. */
-#define ADSP_AUDIO_IOCTL_CMD_SESSION_PAUSE		0x01075ee8
-
-/* Resume the data flow for a session as indicated by major id. */
-#define ADSP_AUDIO_IOCTL_CMD_SESSION_RESUME		0x01075ee9
-
-/* Drop any unprocessed data buffers for a session as indicated by major id. */
-#define ADSP_AUDIO_IOCTL_CMD_SESSION_FLUSH		0x01075eea
-
-/* Start Stream DTMF tone */
-#define ADSP_AUDIO_IOCTL_CMD_SESSION_DTMF_START		0x0108c0dd
-
-/* Stop Stream DTMF tone */
-#define ADSP_AUDIO_IOCTL_CMD_SESSION_DTMF_STOP		0x01087554
-
-/* Set Session volume. */
-/* This command has data payload, struct adsp_audio_set_volume_command. */
-#define ADSP_AUDIO_IOCTL_SET_SESSION_VOL		0x0108d8bd
-
-/* Set session stereo volume. This command has data payload, */
-/* struct adsp_audio_set_stereo_volume_command. */
-#define ADSP_AUDIO_IOCTL_SET_SESSION_STEREO_VOL		0x0108df3d
-
-/* Set L, R cross channel gain for a session. This command has */
-/* data payload, struct adsp_audio_set_x_chan_gain_command. */
-#define ADSP_AUDIO_IOCTL_SET_SESSION_XCHAN_GAIN		0x0108df3f
-
-/* Set Session mute state. */
-/* This command has data payload, struct adsp_audio_set_mute_command. */
-#define ADSP_AUDIO_IOCTL_SET_SESSION_MUTE		0x0108d8be
-
-/* Configure Equalizer for a stream. */
-/* This command has payload struct adsp_audio_set_equalizer_command. */
-#define ADSP_AUDIO_IOCTL_SET_SESSION_EQ_CONFIG		0x0108c0e0
-
-/* Set Audio Video sync information. */
-/* This command has data payload, struct adsp_audio_set_av_sync_command. */
-#define ADSP_AUDIO_IOCTL_SET_SESSION_AVSYNC		0x0108d1e2
-
-/* Get Audio Media Session time. */
-/* This command returns the audioTime in adsp_audio_unsigned64_event */
-#define ADSP_AUDIO_IOCTL_CMD_GET_AUDIO_TIME		0x0108c26c
-
-
-/* these command structures are used for both STREAM and SESSION ioctls */
-
-struct adsp_set_volume_command {
-	struct adsp_command_hdr hdr;
-	s32 volume;
-} __attribute__ ((packed));
-
-struct adsp_set_mute_command {
-	struct adsp_command_hdr hdr;
-	u32 mute; /* 1 == mute */
-} __attribute__ ((packed));
-
-
-
-/* ---- audio events ---- */
-
-/* All IOCTL commands generate an event with the IOCTL opcode as the */
-/* event id after the IOCTL command has been executed. */
-
-/* This event is generated after a media stream session is opened. */
-#define ADSP_AUDIO_EVT_STATUS_OPEN				0x0108c0d6
-
-/* This event is generated after a media stream  session is closed. */
-#define ADSP_AUDIO_EVT_STATUS_CLOSE				0x0108c0d7
-
-/* Asyncronous buffer consumption. This event is generated after a */
-/* recived  buffer is consumed during rendering or filled during */
-/* capture opeartion. */
-#define ADSP_AUDIO_EVT_STATUS_BUF_DONE				0x0108c0d8
-
-/* This event is generated when rendering operation is starving for */
-/* data. In order to avoid audio loss at the end of a plauback, the */
-/* client should wait for this event before issuing the close command. */
-#define ADSP_AUDIO_EVT_STATUS_BUF_UNDERRUN			0x0108c0d9
-
-/* This event is generated during capture operation when there are no */
-/* buffers available to copy the captured audio data */
-#define ADSP_AUDIO_EVT_STATUS_BUF_OVERFLOW			0x0108c0da
-
-/* This asynchronous event is generated as a result of an input */
-/* sample rate change and/or channel mode change detected by the */
-/* decoder. The event payload data is an array of 2 uint32 */
-/* values containing the sample rate in Hz and channel mode. */
-#define ADSP_AUDIO_EVT_SR_CM_CHANGE				0x0108d329
-
-struct adsp_event_hdr {
-	u32 evt_handle;		/* DAL common header */
-	u32 evt_cookie;
-	u32 evt_length;
-
-	u32 dest;
-	u32 src;
-
-	u32 event_id;
-	u32 response_type;
-	u32 seq_number;
-
-	u32 context;		/* opaque to DSP */
-	u32 data;
-
-	u32 status;
-} __attribute__ ((packed));
-
-struct adsp_buffer_event {
-	struct adsp_event_hdr hdr;
-	struct adsp_audio_buffer buffer;
-} __attribute__ ((packed));
-
-
-/* ---- audio device IDs ---- */
-
-/* Device direction Rx/Tx flag */
-#define ADSP_AUDIO_RX_DEVICE		0x00
-#define ADSP_AUDIO_TX_DEVICE		0x01
-
-#define ADSP_AUDIO_DEVICE_ID_DEFAULT		0x1081679
-
-/* Default RX or TX device */
-
-#define ADSP_AUDIO_DEVICE_ID_HANDSET_MIC	0x107ac8d
-#define ADSP_AUDIO_DEVICE_ID_HANDSET_DUAL_MIC		0x108f9c3
-#define ADSP_AUDIO_DEVICE_ID_HEADSET_MIC	0x1081510
-#define ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MIC	0x1081512
-#define ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_DUAL_MIC	0x108f9c5
-#define ADSP_AUDIO_DEVICE_ID_BT_SCO_MIC		0x1081518
-#define ADSP_AUDIO_DEVICE_ID_TTY_HEADSET_MIC	0x108151b
-#define ADSP_AUDIO_DEVICE_ID_I2S_MIC		0x1089bf3
-
-/* Special loopback pseudo device to be paired with an RX device */
-/* with usage ADSP_AUDIO_DEVICE_USAGE_MIXED_PCM_LOOPBACK */
-#define ADSP_AUDIO_DEVICE_ID_MIXED_PCM_LOOPBACK_TX	0x1089bf2
-
-/* Sink (RX) devices */
-#define ADSP_AUDIO_DEVICE_ID_HANDSET_SPKR			0x107ac88
-#define ADSP_AUDIO_DEVICE_ID_HEADSET_SPKR_MONO			0x1081511
-#define ADSP_AUDIO_DEVICE_ID_HEADSET_SPKR_STEREO		0x107ac8a
-#define ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MONO			0x1081513
-#define ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MONO_W_MONO_HEADSET     0x108c508
-#define ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MONO_W_STEREO_HEADSET   0x108c894
-#define ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_STEREO			0x1081514
-#define ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_STEREO_W_MONO_HEADSET   0x108c895
-#define ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_STEREO_W_STEREO_HEADSET	0x108c509
-#define ADSP_AUDIO_DEVICE_ID_BT_SCO_SPKR			0x1081519
-#define ADSP_AUDIO_DEVICE_ID_TTY_HEADSET_SPKR			0x108151c
-#define ADSP_AUDIO_DEVICE_ID_I2S_SPKR				0x1089bf4
-#define ADSP_AUDIO_DEVICE_ID_NULL_SINK				0x108e512
-
-/* BT A2DP playback device. */
-/* This device must be paired with */
-/* ADSP_AUDIO_DEVICE_ID_MIXED_PCM_LOOPBACK_TX using  */
-/* ADSP_AUDIO_DEVICE_USAGE_MIXED_PCM_LOOPBACK mode */
-#define ADSP_AUDIO_DEVICE_ID_BT_A2DP_SPKR	0x108151a
-
-/* Voice Destination identifier - specifically used for */
-/* controlling Voice module from the Device Control Session */
-#define ADSP_AUDIO_DEVICE_ID_VOICE		0x0108df3c
-
-/*  Audio device usage types. */
-/*  This is a bit mask to determine which topology to use in the */
-/* device session */
-#define ADSP_AUDIO_DEVICE_CONTEXT_VOICE			0x01
-#define ADSP_AUDIO_DEVICE_CONTEXT_PLAYBACK		0x02
-#define ADSP_AUDIO_DEVICE_CONTEXT_MIXED_RECORD		0x10
-#define ADSP_AUDIO_DEVICE_CONTEXT_RECORD		0x20
-#define ADSP_AUDIO_DEVICE_CONTEXT_PCM_LOOPBACK		0x40
-
-#endif
diff --git a/arch/arm/mach-msm/qdsp6/audiov2/dal_audio_format.h b/arch/arm/mach-msm/qdsp6/audiov2/dal_audio_format.h
deleted file mode 100644
index 218fa53..0000000
--- a/arch/arm/mach-msm/qdsp6/audiov2/dal_audio_format.h
+++ /dev/null
@@ -1,284 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-
-#ifndef __ADSP_AUDIO_MEDIA_FORMAT_H
-#define __ADSP_AUDIO_MEDIA_FORMAT_H
-
-/* Supported audio media formats */
-
-/* format block in shmem */
-#define ADSP_AUDIO_FORMAT_SHAREDMEMORY	0x01091a78
-
-/* adsp_audio_format_raw_pcm type */
-#define ADSP_AUDIO_FORMAT_PCM		0x0103d2fd
-
-/* adsp_audio_format_raw_pcm type */
-#define ADSP_AUDIO_FORMAT_DTMF		0x01087725
-
-/* adsp_audio_format_adpcm type */
-#define ADSP_AUDIO_FORMAT_ADPCM		0x0103d2ff
-
-/* Yamaha PCM format */
-#define ADSP_AUDIO_FORMAT_YADPCM	0x0108dc07
-
-/* ISO/IEC 11172 */
-#define ADSP_AUDIO_FORMAT_MP3		0x0103d308
-
-/* ISO/IEC 14496 */
-#define ADSP_AUDIO_FORMAT_MPEG4_AAC	0x010422f1
-
-/* AMR-NB audio in FS format */
-#define ADSP_AUDIO_FORMAT_AMRNB_FS	0x0105c16c
-
-/* AMR-WB audio in FS format */
-#define ADSP_AUDIO_FORMAT_AMRWB_FS	0x0105c16e
-
-/* QCELP 13k, IS733 */
-#define ADSP_AUDIO_FORMAT_V13K_FS	0x01080b8a
-
-/* EVRC   8k, IS127 */
-#define ADSP_AUDIO_FORMAT_EVRC_FS	0x01080b89
-
-/* EVRC-B   8k, 4GV */
-#define ADSP_AUDIO_FORMAT_EVRCB_FS	0x0108f2a3
-
-/* MIDI command stream */
-#define ADSP_AUDIO_FORMAT_MIDI		0x0103d300
-
-/* A2DP SBC stream */
-#define ADSP_AUDIO_FORMAT_SBC		0x0108c4d8
-
-/* Version 10 Professional */
-#define ADSP_AUDIO_FORMAT_WMA_V10PRO	0x0108aa92
-
-/* Version 9 Starndard */
-#define ADSP_AUDIO_FORMAT_WMA_V9	0x0108d430
-
-/* AMR WideBand Plus */
-#define ADSP_AUDIO_FORMAT_AMR_WB_PLUS   0x0108f3da
-
-/* AC3 Decoder */
-#define ADSP_AUDIO_FORMAT_AC3_DECODER   0x0108d5f9
-
-/* Not yet supported audio media formats */
-
-/* ISO/IEC 13818 */
-#define ADSP_AUDIO_FORMAT_MPEG2_AAC	0x0103d309
-
-/* 3GPP TS 26.101 Sec 4.0 */
-#define ADSP_AUDIO_FORMAT_AMRNB_IF1	0x0103d305
-
-/* 3GPP TS 26.101 Annex A */
-#define ADSP_AUDIO_FORMAT_AMRNB_IF2	0x01057b31
-
-/* 3GPP TS 26.201 */
-#define ADSP_AUDIO_FORMAT_AMRWB_IF1	0x0103d306
-
-/* 3GPP TS 26.201 */
-#define ADSP_AUDIO_FORMAT_AMRWB_IF2	0x0105c16d
-
-/* G.711 */
-#define ADSP_AUDIO_FORMAT_G711		0x0106201d
-
-/* QCELP  8k, IS96A */
-#define ADSP_AUDIO_FORMAT_V8K_FS	0x01081d29
-
-/* Version 1 codec */
-#define ADSP_AUDIO_FORMAT_WMA_V1	0x01055b2b
-
-/* Version 2, 7 & 8 codec */
-#define ADSP_AUDIO_FORMAT_WMA_V8	0x01055b2c
-
-/* Version 9 Professional codec */
-#define ADSP_AUDIO_FORMAT_WMA_V9PRO	0x01055b2d
-
-/* Version 9 Voice codec */
-#define ADSP_AUDIO_FORMAT_WMA_SP1	0x01055b2e
-
-/* Version 9 Lossless codec */
-#define ADSP_AUDIO_FORMAT_WMA_LOSSLESS	0x01055b2f
-
-/* Real Media content, low-bitrate */
-#define ADSP_AUDIO_FORMAT_RA_SIPR	0x01042a0f
-
-/* Real Media content */
-#define ADSP_AUDIO_FORMAT_RA_COOK	0x01042a0e
-
-
-/* For all of the audio formats, unless specified otherwise, */
-/* the following apply: */
-/* Format block bits are arranged in bytes and words in little-endian */
-/* order, i.e., least-significant bit first and least-significant */
-/* byte first. */
-
-
-/* AAC Format Block. */
-
-/* AAC format block consist of a format identifier followed by */
-/* AudioSpecificConfig formatted according to ISO/IEC 14496-3 */
-
-/* The following AAC format identifiers are supported */
-#define ADSP_AUDIO_AAC_ADTS		0x010619cf
-#define ADSP_AUDIO_AAC_MPEG4_ADTS	0x010619d0
-#define ADSP_AUDIO_AAC_LOAS		0x010619d1
-#define ADSP_AUDIO_AAC_ADIF		0x010619d2
-#define ADSP_AUDIO_AAC_RAW		0x010619d3
-#define ADSP_AUDIO_AAC_FRAMED_RAW	0x0108c1fb
-
-struct adsp_audio_no_payload_format {
-	/* Media Format Code (must always be first element) */
-	u32 format;
-	/* no payload for this format type */
-} __attribute__ ((packed));
-
-/* Maxmum number of bytes allowed in a format block */
-#define ADSP_AUDIO_FORMAT_DATA_MAX 16
-
-/* For convenience, to be used as a standard format block */
-/* for various media types that don't need a unique format block */
-/* ie. PCM, DTMF, etc. */
-struct adsp_audio_standard_format {
-	/* Media Format Code (must always be first element) */
-	u32 format;
-
-	/* payload */
-	u16 channels;
-	u16 bits_per_sample;
-	u32 sampling_rate;
-	u8 is_signed;
-	u8 is_interleaved;
-} __attribute__ ((packed));
-
-/* ADPCM format block */
-struct adsp_audio_adpcm_format {
-	/* Media Format Code (must always be first element) */
-	u32 format;
-
-	/* payload */
-	u16 channels;
-	u16 bits_per_sample;
-	u32 sampling_rate;
-	u8 is_signed;
-	u8 is_interleaved;
-	u32 block_size;
-} __attribute__ ((packed));
-
-/* MIDI format block */
-struct adsp_audio_midi_format {
-	/* Media Format Code (must always be first element) */
-	u32 format;
-
-	/* payload */
-	u32 sampling_rate;
-	u16 channels;
-	u16 mode;
-} __attribute__ ((packed));
-
-#define ADSP_AUDIO_COMPANDING_ALAW	0x10619cd
-#define ADSP_AUDIO_COMPANDING_MLAW	0x10619ce
-
-/* G711 format block */
-struct adsp_audio_g711_format {
-	/* Media Format Code (must always be first element) */
-	u32 format;
-
-	/* payload */
-	u32 companding;
-} __attribute__ ((packed));
-
-
-struct adsp_audio_wma_pro_format {
-	/* Media Format Code (must always be first element) */
-	u32 format;
-
-	/* payload */
-	u16 format_tag;
-	u16 channels;
-	u32 samples_per_sec;
-	u32 avg_bytes_per_sec;
-	u16 block_align;
-	u16 valid_bits_per_sample;
-	u32 channel_mask;
-	u16 encode_opt;
-	u16 advanced_encode_opt;
-	u32 advanced_encode_opt2;
-	u32 drc_peak_reference;
-	u32 drc_peak_target;
-	u32 drc_average_reference;
-	u32 drc_average_target;
-} __attribute__ ((packed));
-
-struct adsp_audio_amrwb_plus_format {
-	/* Media Format Code (must always be first element) */
-	u32		format;
-
-	/* payload */
-	u32		size;
-	u32		version;
-	u32		channels;
-	u32		amr_band_mode;
-	u32		amr_dtx_mode;
-	u32		amr_frame_format;
-	u32		amr_isf_index;
-} __attribute__ ((packed));
-
-/* Binary Byte Stream Format */
-/* Binary format type that defines a byte stream, */
-/* can be used to specify any format (ie. AAC) */
-struct adsp_audio_binary_format {
-	/* Media Format Code (must always be first element) */
-	u32 format;
-
-	/* payload */
-	/* number of bytes set in byte stream */
-	u32 num_bytes;
-	/* Byte stream binary data */
-	u8 data[ADSP_AUDIO_FORMAT_DATA_MAX];
-} __attribute__ ((packed));
-
-struct adsp_audio_shared_memory_format {
-	/* Media Format Code (must always be first element) */
-	u32		format;
-
-	/* Number of bytes in shared memory */
-	u32		len;
-	/* Phyisical address to data in shared memory */
-	u32		address;
-} __attribute__ ((packed));
-
-
-/* Union of all format types */
-union adsp_audio_format {
-	/* Basic format block with no payload */
-	struct adsp_audio_no_payload_format	no_payload;
-	/* Generic format block PCM, DTMF */
-	struct adsp_audio_standard_format	standard;
-	/* ADPCM format block */
-	struct adsp_audio_adpcm_format		adpcm;
-	/* MIDI format block */
-	struct adsp_audio_midi_format		midi;
-	/* G711 format block */
-	struct adsp_audio_g711_format		g711;
-	/* WmaPro format block */
-	struct adsp_audio_wma_pro_format	wma_pro;
-	/* WmaPro format block */
-	struct adsp_audio_amrwb_plus_format	amrwb_plus;
-	/* binary (byte stream) format block, used for AAC */
-	struct adsp_audio_binary_format		binary;
-	/* format block in shared memory */
-	struct adsp_audio_shared_memory_format	shared_mem;
-};
-
-#endif
-
-
diff --git a/arch/arm/mach-msm/qdsp6/audiov2/dal_voice.h b/arch/arm/mach-msm/qdsp6/audiov2/dal_voice.h
deleted file mode 100644
index 6836de4..0000000
--- a/arch/arm/mach-msm/qdsp6/audiov2/dal_voice.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-
-#ifndef __DAL_VOICE_H__
-#define __DAL_VOICE_H__
-
-#define VOICE_DAL_DEVICE 0x02000075
-#define VOICE_DAL_PORT "DAL_AM_AUD"
-#define VOICE_DAL_VERSION 0x00010000
-
-#define APR_PKTV1_TYPE_EVENT_V 0
-#define APR_UNDEFINED -1
-#define APR_PKTV1_TYPE_MASK 0x00000010
-#define APR_PKTV1_TYPE_SHFT 4
-
-#define APR_SET_BITMASK(mask, shift, value) \
-	(((value) << (shift)) & (mask))
-
-#define APR_SET_FIELD(field, value) \
-	APR_SET_BITMASK((field##_MASK), (field##_SHFT), (value))
-
-
-enum {
-	VOICE_OP_INIT = DAL_OP_FIRST_DEVICE_API,
-	VOICE_OP_CONTROL,
-};
-
-struct apr_command_pkt {
-	uint32_t size;
-	uint32_t header;
-	uint16_t reserved1;
-	uint16_t src_addr;
-	uint16_t dst_addr;
-	uint16_t ret_addr;
-	uint32_t src_token;
-	uint32_t dst_token;
-	uint32_t ret_token;
-	uint32_t context;
-	uint32_t opcode;
-} __attribute__ ((packed));
-
-
-#define APR_IBASIC_RSP_RESULT 0x00010000
-
-#define APR_OP_CMD_CREATE 0x0001001B
-
-#define APR_OP_CMD_DESTROY 0x0001001C
-
-#define VOICE_OP_CMD_BRINGUP 0x0001001E
-
-#define VOICE_OP_CMD_TEARDOWN 0x0001001F
-
-#define VOICE_OP_CMD_SET_NETWORK 0x0001001D
-
-#define VOICE_OP_CMD_STREAM_SETUP 0x00010027
-
-#define VOICE_OP_CMD_STREAM_TEARDOWN 0x00010028
-
-#endif
diff --git a/arch/arm/mach-msm/qdsp6/audiov2/evrc_in.c b/arch/arm/mach-msm/qdsp6/audiov2/evrc_in.c
deleted file mode 100644
index 9c54455..0000000
--- a/arch/arm/mach-msm/qdsp6/audiov2/evrc_in.c
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright (C) 2009 Google, Inc.
- * Copyright (C) 2009 HTC Corporation
- * Copyright (c) 2009, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/uaccess.h>
-
-#include <linux/msm_audio_qcp.h>
-#include <mach/msm_qdsp6_audiov2.h>
-#include "dal_audio.h"
-#include "dal_audio_format.h"
-#include <mach/debug_mm.h>
-
-
-struct evrc {
-	struct mutex lock;
-	struct msm_audio_evrc_enc_config cfg;
-	struct msm_audio_stream_config str_cfg;
-	struct audio_client *audio_client;
-};
-
-
-static long q6_evrc_in_ioctl(struct file *file, unsigned int cmd,
-				unsigned long arg)
-{
-	struct evrc *evrc = file->private_data;
-	struct adsp_open_command rpc;
-	int rc = 0;
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		memset(&stats, 0, sizeof(stats));
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-
-	mutex_lock(&evrc->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		if (evrc->audio_client) {
-			rc = -EBUSY;
-			break;
-		} else {
-			evrc->audio_client = q6audio_open(AUDIO_FLAG_READ,
-						evrc->str_cfg.buffer_size);
-
-			if (!evrc->audio_client) {
-				kfree(evrc);
-				rc = -ENOMEM;
-				break;
-			}
-		}
-
-		tx_clk_freq = 8000;
-
-		memset(&rpc, 0, sizeof(rpc));
-
-		rpc.format_block.standard.format = ADSP_AUDIO_FORMAT_EVRC_FS;
-		rpc.format_block.standard.channels = 1;
-		rpc.format_block.standard.bits_per_sample = 16;
-		rpc.format_block.standard.sampling_rate = 8000;
-		rpc.format_block.standard.is_signed = 1;
-		rpc.format_block.standard.is_interleaved = 0;
-
-		rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_OPEN_READ;
-		rpc.device = ADSP_AUDIO_DEVICE_ID_DEFAULT;
-		rpc.stream_context = ADSP_AUDIO_DEVICE_CONTEXT_RECORD;
-		rpc.buf_max_size = evrc->str_cfg.buffer_size;
-		rpc.config.evrc.min_rate = evrc->cfg.min_bit_rate;
-		rpc.config.evrc.max_rate = evrc->cfg.max_bit_rate;
-
-		q6audio_start(evrc->audio_client, &rpc, sizeof(rpc));
-		break;
-	case AUDIO_STOP:
-		break;
-	case AUDIO_FLUSH:
-		break;
-	case AUDIO_SET_VOLUME:
-		break;
-	case AUDIO_GET_STREAM_CONFIG:
-		if (copy_to_user((void *)arg, &evrc->str_cfg,
-				sizeof(struct msm_audio_stream_config)))
-			rc = -EFAULT;
-		break;
-	case AUDIO_SET_STREAM_CONFIG:
-		if (copy_from_user(&evrc->str_cfg, (void *)arg,
-			sizeof(struct msm_audio_stream_config))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		if (evrc->str_cfg.buffer_size < 23) {
-			pr_err("[%s:%s] Buffer size too small\n", __MM_FILE__,
-					__func__);
-			rc = -EINVAL;
-			break;
-		}
-
-		if (evrc->str_cfg.buffer_count != 2)
-			pr_info("[%s:%s] Buffer count set to 2\n", __MM_FILE__,
-					__func__);
-		break;
-	case AUDIO_SET_EVRC_ENC_CONFIG:
-		if (copy_from_user(&evrc->cfg, (void *) arg,
-				 sizeof(struct msm_audio_evrc_enc_config)))
-			rc = -EFAULT;
-
-		if (evrc->cfg.min_bit_rate > 4 || evrc->cfg.min_bit_rate < 1) {
-			pr_err("[%s:%s] invalid min bitrate\n", __MM_FILE__,
-					__func__);
-			rc = -EINVAL;
-		}
-		if (evrc->cfg.max_bit_rate > 4 || evrc->cfg.max_bit_rate < 1) {
-			pr_err("[%s:%s] invalid max bitrate\n", __MM_FILE__,
-					__func__);
-			rc = -EINVAL;
-		}
-		break;
-	case AUDIO_GET_EVRC_ENC_CONFIG:
-		if (copy_to_user((void *) arg, &evrc->cfg,
-				 sizeof(struct msm_audio_evrc_enc_config)))
-			rc = -EFAULT;
-		break;
-
-	default:
-		rc = -EINVAL;
-	}
-
-	mutex_unlock(&evrc->lock);
-	return rc;
-}
-
-static int q6_evrc_in_open(struct inode *inode, struct file *file)
-{
-	struct evrc *evrc;
-	evrc = kmalloc(sizeof(struct evrc), GFP_KERNEL);
-	if (evrc == NULL) {
-		pr_err("[%s:%s] Could not allocate memory for evrc driver\n",
-				__MM_FILE__, __func__);
-		return -ENOMEM;
-	}
-
-	mutex_init(&evrc->lock);
-	file->private_data = evrc;
-	evrc->audio_client = NULL;
-	evrc->str_cfg.buffer_size = 23;
-	evrc->str_cfg.buffer_count = 2;
-	evrc->cfg.cdma_rate = CDMA_RATE_FULL;
-	evrc->cfg.min_bit_rate = 1;
-	evrc->cfg.max_bit_rate = 4;
-
-	return 0;
-}
-
-static ssize_t q6_evrc_in_read(struct file *file, char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct audio_client *ac;
-	struct audio_buffer *ab;
-	const char __user *start = buf;
-	struct evrc *evrc = file->private_data;
-	int xfer = 0;
-	int res;
-
-	mutex_lock(&evrc->lock);
-	ac = evrc->audio_client;
-	if (!ac) {
-		res = -ENODEV;
-		goto fail;
-	}
-	while (count > xfer) {
-		ab = ac->buf + ac->cpu_buf;
-
-		if (ab->used)
-			wait_event(ac->wait, (ab->used == 0));
-
-		xfer = ab->actual_size;
-
-		if (copy_to_user(buf, ab->data, xfer)) {
-			res = -EFAULT;
-			goto fail;
-		}
-
-		buf += xfer;
-		count -= xfer;
-
-		ab->used = 1;
-		q6audio_read(ac, ab);
-		ac->cpu_buf ^= 1;
-	}
-
-	res = buf - start;
-
-fail:
-	mutex_unlock(&evrc->lock);
-
-	return res;
-}
-
-static int q6_evrc_in_release(struct inode *inode, struct file *file)
-{
-	int rc = 0;
-	struct evrc *evrc = file->private_data;
-
-	mutex_lock(&evrc->lock);
-	if (evrc->audio_client)
-		rc = q6audio_close(evrc->audio_client);
-	mutex_unlock(&evrc->lock);
-	kfree(evrc);
-	return rc;
-}
-
-static const struct file_operations q6_evrc_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= q6_evrc_in_open,
-	.read		= q6_evrc_in_read,
-	.release	= q6_evrc_in_release,
-	.unlocked_ioctl	= q6_evrc_in_ioctl,
-};
-
-struct miscdevice q6_evrc_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_evrc_in",
-	.fops	= &q6_evrc_in_fops,
-};
-
-static int __init q6_evrc_in_init(void)
-{
-	return misc_register(&q6_evrc_in_misc);
-}
-
-device_initcall(q6_evrc_in_init);
diff --git a/arch/arm/mach-msm/qdsp6/audiov2/mp3.c b/arch/arm/mach-msm/qdsp6/audiov2/mp3.c
deleted file mode 100644
index 7d9cfa2..0000000
--- a/arch/arm/mach-msm/qdsp6/audiov2/mp3.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/* arch/arm/mach-msm/qdsp6/audiov2/mp3.c
- *
- * Copyright (C) 2009 Google, Inc.
- * Copyright (C) 2009 HTC Corporation
- * Copyright (c) 2009, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/uaccess.h>
-
-#include <linux/msm_audio.h>
-
-#include <mach/msm_qdsp6_audiov2.h>
-#include "dal_audio.h"
-#include "dal_audio_format.h"
-
-#define BUFSZ (8192)
-#define DMASZ (BUFSZ * 2)
-
-struct mp3 {
-	struct mutex lock;
-	struct audio_client *ac;
-	struct msm_audio_config cfg;
-};
-
-static long mp3_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct mp3 *mp3 = file->private_data;
-	struct adsp_open_command rpc;
-	int rc = 0;
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		memset(&stats, 0, sizeof(stats));
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-
-	mutex_lock(&mp3->lock);
-	switch (cmd) {
-	case AUDIO_SET_VOLUME:
-		break;
-	case AUDIO_START:
-		memset(&rpc, 0, sizeof(rpc));
-		rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_OPEN_WRITE;
-		rpc.stream_context = ADSP_AUDIO_DEVICE_CONTEXT_PLAYBACK;
-		rpc.device = ADSP_AUDIO_DEVICE_ID_DEFAULT;
-		rpc.format_block.standard.format = ADSP_AUDIO_FORMAT_MP3;
-		rpc.format_block.standard.channels = mp3->cfg.channel_count;
-		rpc.format_block.standard.bits_per_sample = 16;
-		rpc.format_block.standard.sampling_rate = mp3->cfg.sample_rate;
-		rpc.format_block.standard.is_signed = 1;
-		rpc.format_block.standard.is_interleaved = 0;
-		rpc.buf_max_size = BUFSZ;
-		q6audio_start(mp3->ac, (void *) &rpc, sizeof(rpc));
-		break;
-	case AUDIO_STOP:
-		break;
-	case AUDIO_FLUSH:
-		break;
-	case AUDIO_SET_CONFIG:
-		if (copy_from_user(&mp3->cfg, (void *) arg,
-			sizeof(struct msm_audio_config))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (mp3->cfg.channel_count < 1 || mp3->cfg.channel_count > 2) {
-			rc = -EINVAL;
-			break;
-		}
-		break;
-	case AUDIO_GET_CONFIG:
-		if (copy_to_user((void *) arg, &mp3->cfg,
-			sizeof(struct msm_audio_config))) {
-			rc = -EFAULT;
-		}
-		break;
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&mp3->lock);
-	return rc;
-}
-
-static int mp3_open(struct inode *inode, struct file *file)
-{
-
-	struct mp3 *mp3;
-	mp3 = kzalloc(sizeof(struct mp3), GFP_KERNEL);
-
-	if (!mp3)
-		return -ENOMEM;
-
-	mutex_init(&mp3->lock);
-	file->private_data = mp3;
-	mp3->ac = q6audio_open(AUDIO_FLAG_WRITE, BUFSZ);
-	if (!mp3->ac) {
-		kfree(mp3);
-		return -ENOMEM;
-	}
-	mp3->cfg.channel_count = 2;
-	mp3->cfg.buffer_count = 2;
-	mp3->cfg.buffer_size = BUFSZ;
-	mp3->cfg.unused[0] = 0;
-	mp3->cfg.unused[1] = 0;
-	mp3->cfg.unused[2] = 0;
-	mp3->cfg.sample_rate = 48000;
-
-	return 0;
-}
-
-static ssize_t mp3_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct mp3 *mp3 = file->private_data;
-	struct audio_client *ac;
-	struct audio_buffer *ab;
-	const char __user *start = buf;
-	int xfer;
-
-	if (!mp3->ac)
-		mp3_ioctl(file, AUDIO_START, 0);
-
-	ac = mp3->ac;
-	if (!ac)
-		return -ENODEV;
-
-	while (count > 0) {
-		ab = ac->buf + ac->cpu_buf;
-
-		if (ab->used)
-			wait_event(ac->wait, (ab->used == 0));
-
-		xfer = count;
-		if (xfer > ab->size)
-			xfer = ab->size;
-
-		if (copy_from_user(ab->data, buf, xfer))
-			return -EFAULT;
-
-		buf += xfer;
-		count -= xfer;
-
-		ab->used = xfer;
-		q6audio_write(ac, ab);
-		ac->cpu_buf ^= 1;
-	}
-
-	return buf - start;
-}
-
-static int mp3_fsync(struct file *f, int datasync)
-{
-	struct mp3 *mp3 = f->private_data;
-	if (mp3->ac)
-		return q6audio_async(mp3->ac);
-	return -ENODEV;
-}
-
-static int mp3_release(struct inode *inode, struct file *file)
-{
-	struct mp3 *mp3 = file->private_data;
-	if (mp3->ac)
-		q6audio_close(mp3->ac);
-	kfree(mp3);
-	return 0;
-}
-
-static const struct file_operations mp3_fops = {
-	.owner		= THIS_MODULE,
-	.open		= mp3_open,
-	.write		= mp3_write,
-	.fsync		= mp3_fsync,
-	.release	= mp3_release,
-	.unlocked_ioctl	= mp3_ioctl,
-};
-
-struct miscdevice mp3_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_mp3",
-	.fops	= &mp3_fops,
-};
-
-static int __init mp3_init(void)
-{
-	return misc_register(&mp3_misc);
-}
-
-device_initcall(mp3_init);
diff --git a/arch/arm/mach-msm/qdsp6/audiov2/pcm_in.c b/arch/arm/mach-msm/qdsp6/audiov2/pcm_in.c
deleted file mode 100644
index 4de2199..0000000
--- a/arch/arm/mach-msm/qdsp6/audiov2/pcm_in.c
+++ /dev/null
@@ -1,208 +0,0 @@
-/* arch/arm/mach-msm/qdsp6/audiov2/pcm_in.c
- *
- * Copyright (C) 2009 Google, Inc.
- * Copyright (C) 2009 HTC Corporation
- * Copyright (c) 2009, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/uaccess.h>
-
-#include <linux/msm_audio.h>
-
-#include <mach/msm_qdsp6_audiov2.h>
-#include "dal_audio.h"
-#include "dal_audio_format.h"
-
-#define BUFSZ (4096)
-#define DMASZ (BUFSZ * 2)
-
-
-struct pcm {
-	struct mutex lock;
-	struct msm_audio_config cfg;
-	struct audio_client *audio_client;
-};
-
-static long q6_in_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct pcm *pcm = file->private_data;
-	struct adsp_open_command rpc;
-	int rc = 0;
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		memset(&stats, 0, sizeof(stats));
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-
-	mutex_lock(&pcm->lock);
-	switch (cmd) {
-
-	case AUDIO_START:
-		tx_clk_freq = pcm->cfg.sample_rate;
-
-		memset(&rpc, 0, sizeof(rpc));
-
-		rpc.format_block.standard.format = ADSP_AUDIO_FORMAT_PCM;
-		rpc.format_block.standard.channels = pcm->cfg.channel_count;
-		rpc.format_block.standard.bits_per_sample = 16;
-		rpc.format_block.standard.sampling_rate = pcm->cfg.sample_rate;
-		rpc.format_block.standard.is_signed = 1;
-		rpc.format_block.standard.is_interleaved = 1;
-
-		rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_OPEN_READ;
-		rpc.device = ADSP_AUDIO_DEVICE_ID_DEFAULT;
-		rpc.stream_context = ADSP_AUDIO_DEVICE_CONTEXT_RECORD;
-		rpc.buf_max_size = BUFSZ;
-		q6audio_start(pcm->audio_client, &rpc, sizeof(rpc));
-		break;
-	case AUDIO_STOP:
-		break;
-	case AUDIO_FLUSH:
-		break;
-	case AUDIO_SET_VOLUME:
-		break;
-	case AUDIO_SET_CONFIG:
-		if (copy_from_user(&pcm->cfg, (void *) arg,
-				 sizeof(struct msm_audio_config))) {
-			rc = -EFAULT;
-			break;
-		}
-		break;
-	case AUDIO_GET_CONFIG:
-		if (copy_to_user((void *) arg, &pcm->cfg,
-				 sizeof(struct msm_audio_config))) {
-			rc = -EFAULT;
-		}
-		break;
-	default:
-		rc = -EINVAL;
-	}
-
-	mutex_unlock(&pcm->lock);
-	return rc;
-}
-
-static int q6_in_open(struct inode *inode, struct file *file)
-{
-
-	struct pcm *pcm;
-	pcm = kmalloc(sizeof(struct pcm), GFP_KERNEL);
-	if (pcm == NULL) {
-		pr_err("Could not allocate memory for pcm driver\n");
-		return -ENOMEM;
-	}
-	mutex_init(&pcm->lock);
-	file->private_data = pcm;
-	pcm->audio_client = q6audio_open(AUDIO_FLAG_READ, BUFSZ);
-	if (!pcm->audio_client) {
-		kfree(pcm);
-		return -ENOMEM;
-	}
-	pcm->cfg.channel_count = 1;
-	pcm->cfg.buffer_count = 2;
-	pcm->cfg.buffer_size = BUFSZ;
-	pcm->cfg.unused[0] = 0;
-	pcm->cfg.unused[1] = 0;
-	pcm->cfg.unused[2] = 0;
-	pcm->cfg.sample_rate = 8000;
-
-	return 0;
-}
-
-static ssize_t q6_in_read(struct file *file, char __user *buf,
-			  size_t count, loff_t *pos)
-{
-	struct audio_client *ac;
-	struct audio_buffer *ab;
-	const char __user *start = buf;
-	struct pcm *pcm = file->private_data;
-	int xfer;
-	int res;
-
-	mutex_lock(&pcm->lock);
-	ac = pcm->audio_client;
-	if (!ac) {
-		res = -ENODEV;
-		goto fail;
-	}
-	while (count > 0) {
-		ab = ac->buf + ac->cpu_buf;
-
-		if (ab->used)
-			wait_event(ac->wait, (ab->used == 0));
-
-		xfer = count;
-		if (xfer > ab->size)
-			xfer = ab->size;
-
-		if (copy_to_user(buf, ab->data, xfer)) {
-			res = -EFAULT;
-			goto fail;
-		}
-
-		buf += xfer;
-		count -= xfer;
-
-		ab->used = 1;
-		q6audio_read(ac, ab);
-		ac->cpu_buf ^= 1;
-	}
-fail:
-	res = buf - start;
-	mutex_unlock(&pcm->lock);
-
-	return res;
-}
-
-static int q6_in_release(struct inode *inode, struct file *file)
-{
-	int rc = 0;
-	struct pcm *pcm = file->private_data;
-
-	mutex_lock(&pcm->lock);
-	if (pcm->audio_client)
-		rc = q6audio_close(pcm->audio_client);
-	mutex_unlock(&pcm->lock);
-	kfree(pcm);
-	return rc;
-}
-
-static const struct file_operations q6_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= q6_in_open,
-	.read		= q6_in_read,
-	.release	= q6_in_release,
-	.unlocked_ioctl	= q6_in_ioctl,
-};
-
-struct miscdevice q6_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_pcm_in",
-	.fops	= &q6_in_fops,
-};
-
-static int __init q6_in_init(void)
-{
-	return misc_register(&q6_in_misc);
-}
-
-device_initcall(q6_in_init);
diff --git a/arch/arm/mach-msm/qdsp6/audiov2/pcm_out.c b/arch/arm/mach-msm/qdsp6/audiov2/pcm_out.c
deleted file mode 100644
index effd119..0000000
--- a/arch/arm/mach-msm/qdsp6/audiov2/pcm_out.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/* arch/arm/mach-msm/qdsp6/audiov2/pcm_out.c
- *
- * Copyright (C) 2009 Google, Inc.
- * Copyright (c) 2009, The Linux Foundation. All rights reserved.
- *
- * Author: Brian Swetland <swetland@google.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/uaccess.h>
-
-#include <linux/msm_audio.h>
-
-#include <mach/msm_qdsp6_audiov2.h>
-#include "dal_audio.h"
-#include "dal_audio_format.h"
-
-#define BUFSZ (8192)
-#define DMASZ (BUFSZ * 2)
-
-struct pcm {
-	struct mutex lock;
-	struct audio_client *ac;
-	struct msm_audio_config cfg;
-
-};
-
-static long pcm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct pcm *pcm = file->private_data;
-	struct adsp_open_command rpc;
-	int rc = 0;
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		memset(&stats, 0, sizeof(stats));
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-
-	mutex_lock(&pcm->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		memset(&rpc, 0, sizeof(rpc));
-		rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_OPEN_WRITE;
-		rpc.stream_context = ADSP_AUDIO_DEVICE_CONTEXT_PLAYBACK;
-		rpc.device = ADSP_AUDIO_DEVICE_ID_DEFAULT;
-		rpc.format_block.standard.format = ADSP_AUDIO_FORMAT_PCM;
-		rpc.format_block.standard.channels = pcm->cfg.channel_count;
-		rpc.format_block.standard.bits_per_sample = 16;
-		rpc.format_block.standard.sampling_rate = pcm->cfg.sample_rate;
-		rpc.format_block.standard.is_signed = 1;
-		rpc.format_block.standard.is_interleaved = 1;
-		rpc.buf_max_size = BUFSZ;
-		q6audio_start(pcm->ac, (void *) &rpc, sizeof(rpc));
-		break;
-	case AUDIO_STOP:
-		break;
-	case AUDIO_FLUSH:
-		break;
-	case AUDIO_SET_CONFIG:
-		if (copy_from_user(&pcm->cfg, (void *) arg,
-				 sizeof(struct msm_audio_config))) {
-			rc = -EFAULT;
-			break;
-		}
-		if (pcm->cfg.channel_count < 1 || pcm->cfg.channel_count > 2) {
-			rc = -EINVAL;
-			break;
-		}
-
-		break;
-	case AUDIO_GET_CONFIG:
-		if (copy_to_user((void *) arg, &pcm->cfg,
-				 sizeof(struct msm_audio_config))) {
-			rc = -EFAULT;
-		}
-		break;
-
-	default:
-		rc = -EINVAL;
-	}
-
-	mutex_unlock(&pcm->lock);
-	return rc;
-}
-
-static int pcm_open(struct inode *inode, struct file *file)
-{
-	struct pcm *pcm;
-	pcm = kzalloc(sizeof(struct pcm), GFP_KERNEL);
-
-	if (!pcm)
-		return -ENOMEM;
-
-	mutex_init(&pcm->lock);
-	file->private_data = pcm;
-	pcm->ac = q6audio_open(AUDIO_FLAG_WRITE, BUFSZ);
-	if (!pcm->ac) {
-		kfree(pcm);
-		return -ENOMEM;
-	}
-	pcm->cfg.channel_count = 2;
-	pcm->cfg.buffer_count = 2;
-	pcm->cfg.buffer_size = BUFSZ;
-	pcm->cfg.unused[0] = 0;
-	pcm->cfg.unused[1] = 0;
-	pcm->cfg.unused[2] = 0;
-	pcm->cfg.sample_rate = 48000;
-
-	return 0;
-}
-
-static ssize_t pcm_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct pcm *pcm = file->private_data;
-	struct audio_client *ac;
-	struct audio_buffer *ab;
-	const char __user *start = buf;
-	int xfer;
-
-	ac = pcm->ac;
-	if (!ac)
-		return -ENODEV;
-
-	while (count > 0) {
-		ab = ac->buf + ac->cpu_buf;
-
-		if (ab->used)
-			wait_event(ac->wait, (ab->used == 0));
-
-		xfer = count;
-		if (xfer > ab->size)
-			xfer = ab->size;
-
-		if (copy_from_user(ab->data, buf, xfer))
-			return -EFAULT;
-
-		buf += xfer;
-		count -= xfer;
-
-		ab->used = 1;
-		ab->actual_size = xfer;
-		q6audio_write(ac, ab);
-		ac->cpu_buf ^= 1;
-	}
-
-	return buf - start;
-}
-
-static int pcm_release(struct inode *inode, struct file *file)
-{
-	struct pcm *pcm = file->private_data;
-	if (pcm->ac)
-		q6audio_close(pcm->ac);
-	kfree(pcm);
-	return 0;
-}
-
-static const struct file_operations pcm_fops = {
-	.owner		= THIS_MODULE,
-	.open		= pcm_open,
-	.write		= pcm_write,
-	.release	= pcm_release,
-	.unlocked_ioctl	= pcm_ioctl,
-};
-
-struct miscdevice pcm_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_pcm_out",
-	.fops	= &pcm_fops,
-};
-
-static int __init pcm_init(void)
-{
-	return misc_register(&pcm_misc);
-}
-
-device_initcall(pcm_init);
diff --git a/arch/arm/mach-msm/qdsp6/audiov2/q6audio.c b/arch/arm/mach-msm/qdsp6/audiov2/q6audio.c
deleted file mode 100644
index 9143b5a..0000000
--- a/arch/arm/mach-msm/qdsp6/audiov2/q6audio.c
+++ /dev/null
@@ -1,1315 +0,0 @@
-/* arch/arm/mach-msm/qdsp6/audiov2/q6audio.c
- *
- * Copyright (C) 2009 Google, Inc.
- * Copyright (c) 2009, The Linux Foundation. All rights reserved.
- *
- * Author: Brian Swetland <swetland@google.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/clk.h>
-#include <linux/delay.h>
-#include <linux/wakelock.h>
-#include <linux/gpio.h>
-#include <linux/pm_qos.h>
-
-#include <mach/msm_qdsp6_audiov2.h>
-#include <mach/cpuidle.h>
-
-#include "../dal.h"
-#include "dal_audio.h"
-#include "dal_audio_format.h"
-#include "dal_acdb.h"
-#include "dal_adie.h"
-#include "q6audio_devices.h"
-
-struct q6_hw_info {
-	int min_gain;
-	int max_gain;
-};
-
-/* TODO: provide mechanism to configure from board file */
-
-static struct q6_hw_info q6_audio_hw[Q6_HW_COUNT] = {
-	[Q6_HW_HANDSET] = {
-		.min_gain = -2000,
-		.max_gain = 0,
-	},
-	[Q6_HW_HEADSET] = {
-		.min_gain = -2000,
-		.max_gain = 0,
-	},
-	[Q6_HW_SPEAKER] = {
-		.min_gain = -1500,
-		.max_gain = 0,
-	},
-	[Q6_HW_TTY] = {
-		.min_gain = -2000,
-		.max_gain = 0,
-	},
-	[Q6_HW_BT_SCO] = {
-		.min_gain = -2000,
-		.max_gain = 0,
-	},
-	[Q6_HW_BT_A2DP] = {
-		.min_gain = -2000,
-		.max_gain = 0,
-	},
-};
-
-static struct pm_qos_request pm_qos_req;
-static int idlecount;
-static DEFINE_MUTEX(idlecount_lock);
-
-void audio_prevent_sleep(void)
-{
-	mutex_lock(&idlecount_lock);
-	if (++idlecount == 1)
-		pm_qos_update_request(&pm_qos_req,
-				      msm_cpuidle_get_deep_idle_latency());
-	mutex_unlock(&idlecount_lock);
-}
-
-void audio_allow_sleep(void)
-{
-	mutex_lock(&idlecount_lock);
-	if (--idlecount == 0)
-		pm_qos_update_request(&pm_qos_req, PM_QOS_DEFAULT_VALUE);
-	mutex_unlock(&idlecount_lock);
-}
-
-static struct clk *icodec_rx_clk;
-static struct clk *icodec_tx_clk;
-static struct clk *ecodec_clk;
-static struct clk *sdac_clk;
-
-static struct q6audio_analog_ops default_analog_ops;
-static struct q6audio_analog_ops *analog_ops = &default_analog_ops;
-uint32_t tx_clk_freq = 8000;
-static int tx_mute_status;
-
-void q6audio_register_analog_ops(struct q6audio_analog_ops *ops)
-{
-	analog_ops = ops;
-}
-
-static struct q6_device_info *q6_lookup_device(uint32_t device_id)
-{
-	struct q6_device_info *di = q6_audio_devices;
-	for (;;) {
-		if (di->id == device_id)
-			return di;
-		if (di->id == 0) {
-			pr_err("q6_lookup_device: bogus id 0x%08x\n",
-			       device_id);
-			return di;
-		}
-		di++;
-	}
-}
-
-static uint32_t q6_device_to_codec(uint32_t device_id)
-{
-	struct q6_device_info *di = q6_lookup_device(device_id);
-	return di->codec;
-}
-
-static uint32_t q6_device_to_dir(uint32_t device_id)
-{
-	struct q6_device_info *di = q6_lookup_device(device_id);
-	return di->dir;
-}
-
-static uint32_t q6_device_to_cad_id(uint32_t device_id)
-{
-	struct q6_device_info *di = q6_lookup_device(device_id);
-	return di->cad_id;
-}
-
-static uint32_t q6_device_to_path(uint32_t device_id)
-{
-	struct q6_device_info *di = q6_lookup_device(device_id);
-	return di->path;
-}
-
-static uint32_t q6_device_to_rate(uint32_t device_id)
-{
-	struct q6_device_info *di = q6_lookup_device(device_id);
-	return di->rate;
-}
-
-int q6_device_volume(uint32_t device_id, int level)
-{
-	struct q6_device_info *di = q6_lookup_device(device_id);
-	struct q6_hw_info *hw;
-
-	hw = &q6_audio_hw[di->hw];
-
-	return hw->min_gain + ((hw->max_gain - hw->min_gain) * level) / 100;
-}
-
-static inline int adie_open(struct dal_client *client)
-{
-	return dal_call_f0(client, DAL_OP_OPEN, 0);
-}
-
-static inline int adie_close(struct dal_client *client)
-{
-	return dal_call_f0(client, DAL_OP_CLOSE, 0);
-}
-
-static inline int adie_set_path(struct dal_client *client,
-				uint32_t *adie_params, uint32_t size)
-{
-	uint32_t tmp;
-	return dal_call(client, ADIE_OP_SET_PATH, 5, adie_params, size,
-		(void *)&tmp, sizeof(uint32_t));
-
-}
-
-static inline int adie_proceed_to_stage(struct dal_client *client,
-					uint32_t path_type, uint32_t stage)
-{
-	return dal_call_f1(client, ADIE_OP_PROCEED_TO_STAGE,
-			   path_type, stage);
-}
-
-static int adie_refcount;
-
-static struct dal_client *adie;
-static struct dal_client *adsp;
-static struct dal_client *acdb;
-
-static int adie_enable(void)
-{
-	adie_refcount++;
-	if (adie_refcount == 1)
-		adie_open(adie);
-	return 0;
-}
-
-static int adie_disable(void)
-{
-	adie_refcount--;
-	if (adie_refcount == 0)
-		adie_close(adie);
-	return 0;
-}
-
-/* 4k DMA scratch page used for exchanging acdb device config tables
- * and stream format descriptions with the DSP.
- */
-char *audio_data;
-int32_t audio_phys;
-
-#define SESSION_MIN 0
-#define SESSION_MAX 64
-
-static DEFINE_MUTEX(session_lock);
-static DEFINE_MUTEX(audio_lock);
-
-static struct audio_client *session[SESSION_MAX];
-
-static int session_alloc(struct audio_client *ac)
-{
-	int n;
-
-	mutex_lock(&session_lock);
-	for (n = SESSION_MIN; n < SESSION_MAX; n++) {
-		if (!session[n]) {
-			session[n] = ac;
-			mutex_unlock(&session_lock);
-			return n;
-		}
-	}
-	mutex_unlock(&session_lock);
-	return -ENOMEM;
-}
-
-static void session_free(int n, struct audio_client *ac)
-{
-	mutex_lock(&session_lock);
-	if (session[n] == ac)
-		session[n] = 0;
-	mutex_unlock(&session_lock);
-}
-
-static void audio_client_free(struct audio_client *ac)
-{
-	session_free(ac->session, ac);
-
-	if (ac->buf[0].data)
-		pmem_kfree(ac->buf[0].phys);
-	if (ac->buf[1].data)
-		pmem_kfree(ac->buf[1].phys);
-	kfree(ac);
-}
-
-static struct audio_client *audio_client_alloc(unsigned bufsz)
-{
-	struct audio_client *ac;
-	int n;
-
-	ac = kzalloc(sizeof(*ac), GFP_KERNEL);
-	if (!ac)
-		return 0;
-
-	n = session_alloc(ac);
-	if (n < 0)
-		goto fail_session;
-	ac->session = n;
-
-	if (bufsz > 0) {
-		ac->buf[0].phys = pmem_kalloc(bufsz,
-					PMEM_MEMTYPE_EBI1|PMEM_ALIGNMENT_4K);
-		ac->buf[0].data = ioremap(ac->buf[0].phys, bufsz);
-		if (!ac->buf[0].data)
-			goto fail;
-
-		ac->buf[1].phys = pmem_kalloc(bufsz,
-					PMEM_MEMTYPE_EBI1|PMEM_ALIGNMENT_4K);
-		ac->buf[1].data = ioremap(ac->buf[1].phys, bufsz);
-		if (!ac->buf[1].data)
-			goto fail;
-
-		ac->buf[0].size = bufsz;
-		ac->buf[1].size = bufsz;
-	}
-
-	init_waitqueue_head(&ac->wait);
-	ac->client = adsp;
-
-	return ac;
-
-fail:
-	pr_err("pmem_kalloc failed\n");
-	session_free(n, ac);
-fail_session:
-	audio_client_free(ac);
-	return 0;
-}
-
-static int audio_ioctl(struct audio_client *ac, void *ptr, uint32_t len)
-{
-	struct adsp_command_hdr *hdr = ptr;
-	uint32_t tmp;
-	int r;
-
-	hdr->size = len - sizeof(u32);
-	hdr->dest = AUDIO_ADDR(DOMAIN_DSP, ac->session, 0);
-	hdr->src = AUDIO_ADDR(DOMAIN_APP, ac->session, 0);
-	hdr->context = ac->session;
-	ac->cb_status = -EBUSY;
-	r = dal_call(ac->client, AUDIO_OP_CONTROL, 5, ptr, len,
-						&tmp, sizeof(tmp));
-	if (r != 4)
-		return -EIO;
-	wait_event(ac->wait, (ac->cb_status != -EBUSY));
-	return tmp;
-}
-
-static int audio_command(struct audio_client *ac, uint32_t cmd)
-{
-	struct adsp_command_hdr rpc;
-	memset(&rpc, 0, sizeof(rpc));
-	rpc.opcode = cmd;
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-static int audio_open_control(struct audio_client *ac)
-{
-	struct adsp_open_command rpc;
-
-	memset(&rpc, 0, sizeof(rpc));
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_OPEN_DEVICE;
-	rpc.hdr.dest = AUDIO_ADDR(DOMAIN_DSP, ac->session, 0);
-	rpc.hdr.src = AUDIO_ADDR(DOMAIN_APP, ac->session, 0);
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-
-static int audio_close(struct audio_client *ac)
-{
-	audio_command(ac, ADSP_AUDIO_IOCTL_CMD_STREAM_STOP);
-	audio_command(ac, ADSP_AUDIO_IOCTL_CMD_CLOSE);
-	return 0;
-}
-
-static int audio_set_table(struct audio_client *ac,
-			   uint32_t device_id, int size)
-{
-	struct adsp_set_dev_cfg_table_command rpc;
-
-	memset(&rpc, 0, sizeof(rpc));
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_SET_DEVICE_CONFIG_TABLE;
-	rpc.hdr.dest = AUDIO_ADDR(DOMAIN_DSP, ac->session, 0);
-	rpc.hdr.src = AUDIO_ADDR(DOMAIN_APP, ac->session, 0);
-	rpc.device_id = device_id;
-	rpc.phys_addr = audio_phys;
-	rpc.phys_size = size;
-	rpc.phys_used = size;
-
-	if (q6_device_to_dir(device_id) == Q6_TX)
-		rpc.hdr.data = tx_clk_freq;
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-int q6audio_read(struct audio_client *ac, struct audio_buffer *ab)
-{
-	struct adsp_buffer_command rpc;
-	uint32_t res;
-	int r;
-
-	memset(&rpc, 0, sizeof(rpc));
-	rpc.hdr.size = sizeof(rpc) - sizeof(u32);
-	rpc.hdr.dest = AUDIO_ADDR(DOMAIN_DSP, ac->session, 0);
-	rpc.hdr.src = AUDIO_ADDR(DOMAIN_APP, ac->session, 0);
-	rpc.hdr.context = ac->session;
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_DATA_TX;
-	rpc.buffer.addr = ab->phys;
-	rpc.buffer.max_size = ab->size;
-	rpc.buffer.actual_size = ab->actual_size;
-
-	r = dal_call(ac->client, AUDIO_OP_DATA, 5, &rpc, sizeof(rpc),
-		     &res, sizeof(res));
-
-	if ((r == sizeof(res)))
-		return 0;
-
-	return -EIO;
-
-}
-
-int q6audio_write(struct audio_client *ac, struct audio_buffer *ab)
-{
-	struct adsp_buffer_command rpc;
-	uint32_t res;
-	int r;
-
-	memset(&rpc, 0, sizeof(rpc));
-	rpc.hdr.size = sizeof(rpc) - sizeof(u32);
-	rpc.hdr.src = AUDIO_ADDR(DOMAIN_APP, ac->session, 0);
-	rpc.hdr.dest = AUDIO_ADDR(DOMAIN_DSP, ac->session, 0);
-	rpc.hdr.context = ac->session;
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_DATA_RX;
-	rpc.buffer.addr = ab->phys;
-	rpc.buffer.max_size = ab->size;
-	rpc.buffer.actual_size = ab->actual_size;
-
-	r = dal_call(ac->client, AUDIO_OP_DATA, 5, &rpc, sizeof(rpc),
-		     &res, sizeof(res));
-	return 0;
-}
-
-static int audio_rx_volume(struct audio_client *ac, uint32_t dev_id,
-				 int32_t volume)
-{
-	struct adsp_set_dev_volume_command rpc;
-
-	memset(&rpc, 0, sizeof(rpc));
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_SET_DEVICE_VOL;
-	rpc.hdr.dest = AUDIO_ADDR(DOMAIN_DSP, ac->session, 0);
-	rpc.hdr.src = AUDIO_ADDR(DOMAIN_APP, ac->session, 0);
-	rpc.device_id = dev_id;
-	rpc.path = ADSP_PATH_RX;
-	rpc.volume = volume;
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-static int audio_rx_mute(struct audio_client *ac, uint32_t dev_id, int mute)
-{
-	struct adsp_set_dev_mute_command rpc;
-
-	memset(&rpc, 0, sizeof(rpc));
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_SET_DEVICE_MUTE;
-	rpc.hdr.dest = AUDIO_ADDR(DOMAIN_DSP, ac->session, 0);
-	rpc.hdr.src = AUDIO_ADDR(DOMAIN_APP, ac->session, 0);
-	rpc.device_id = dev_id;
-	rpc.path = ADSP_PATH_RX;
-	rpc.mute = !!mute;
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-static int audio_tx_volume(struct audio_client *ac, uint32_t dev_id,
-				 int32_t volume)
-{
-	struct adsp_set_dev_volume_command rpc;
-
-	memset(&rpc, 0, sizeof(rpc));
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_SET_DEVICE_VOL;
-	rpc.hdr.dest = AUDIO_ADDR(DOMAIN_DSP, ac->session, 0);
-	rpc.hdr.src = AUDIO_ADDR(DOMAIN_APP, ac->session, 0);
-	rpc.device_id = dev_id;
-	rpc.path = ADSP_PATH_TX;
-	rpc.volume = volume;
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-static int audio_tx_mute(struct audio_client *ac, uint32_t dev_id, int mute)
-{
-	struct adsp_set_dev_mute_command rpc;
-
-	memset(&rpc, 0, sizeof(rpc));
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_SET_DEVICE_MUTE;
-	rpc.hdr.dest = AUDIO_ADDR(DOMAIN_DSP, ac->session, 0);
-	rpc.hdr.src = AUDIO_ADDR(DOMAIN_APP, ac->session, 0);
-	rpc.device_id = dev_id;
-	rpc.path = ADSP_PATH_TX;
-	rpc.mute = !!mute;
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-static void callback(void *data, int len, void *cookie)
-{
-	struct adsp_event_hdr *e = data;
-	struct audio_client *ac;
-	struct adsp_buffer_event *abe = data;
-
-	if (e->context >= SESSION_MAX) {
-		pr_err("audio callback: bogus session %d\n",
-		       e->context);
-		return;
-	}
-	ac = session[e->context];
-	if (!ac) {
-		pr_err("audio callback: unknown session %d\n",
-		       e->context);
-		return;
-	}
-
-	if (e->event_id == ADSP_AUDIO_IOCTL_CMD_STREAM_EOS) {
-		pr_info("playback done\n");
-		if (e->status)
-			pr_err("playback status %d\n", e->status);
-		if (ac->cb_status == -EBUSY) {
-			ac->cb_status = e->status;
-			wake_up(&ac->wait);
-		}
-		return;
-	}
-
-	if (e->event_id == ADSP_AUDIO_EVT_STATUS_BUF_DONE) {
-		if (e->status)
-			pr_err("buffer status %d\n", e->status);
-
-		ac->buf[ac->dsp_buf].actual_size = abe->buffer.actual_size;
-		ac->buf[ac->dsp_buf].used = 0;
-		ac->dsp_buf ^= 1;
-		wake_up(&ac->wait);
-		return;
-	}
-
-	if (e->status)
-		pr_warning("audio_cb: s=%d e=%08x status=%d\n",
-			   e->context, e->event_id, e->status);
-
-	if (ac->cb_status == -EBUSY) {
-		ac->cb_status = e->status;
-		wake_up(&ac->wait);
-	}
-}
-
-static void audio_init(struct dal_client *client)
-{
-	u32 tmp[3];
-
-	tmp[0] = 2 * sizeof(u32);
-	tmp[1] = 0;
-	tmp[2] = 0;
-	dal_call(client, AUDIO_OP_INIT, 5, tmp, sizeof(tmp),
-		 tmp, sizeof(u32));
-}
-
-static struct audio_client *ac_control;
-
-static int q6audio_init(void)
-{
-	struct audio_client *ac = 0;
-	int res = -ENODEV;
-
-	mutex_lock(&audio_lock);
-	if (ac_control) {
-		res = 0;
-		goto done;
-	}
-
-	icodec_rx_clk = clk_get(0, "icodec_rx_clk");
-	icodec_tx_clk = clk_get(0, "icodec_tx_clk");
-	ecodec_clk = clk_get(0, "ecodec_clk");
-	sdac_clk = clk_get(0, "sdac_clk");
-
-	tx_mute_status = 0;
-	audio_phys = pmem_kalloc(4096, PMEM_MEMTYPE_EBI1|PMEM_ALIGNMENT_4K);
-	audio_data = ioremap(audio_phys, 4096);
-	if (!audio_data) {
-		pr_err("pmem kalloc failed\n");
-		res = -ENOMEM;
-		goto done;
-	}
-
-	adsp = dal_attach(AUDIO_DAL_DEVICE, AUDIO_DAL_PORT, 1,
-			  callback, 0);
-	if (!adsp) {
-		pr_err("audio_init: cannot attach to adsp\n");
-		res = -ENODEV;
-		goto done;
-	}
-	if (check_version(adsp, AUDIO_DAL_VERSION) != 0) {
-		pr_err("Incompatible adsp version\n");
-		res = -ENODEV;
-		goto done;
-	}
-
-	audio_init(adsp);
-
-	ac = audio_client_alloc(0);
-	if (!ac) {
-		pr_err("audio_init: cannot allocate client\n");
-		res = -ENOMEM;
-		goto done;
-	}
-
-	if (audio_open_control(ac)) {
-		pr_err("audio_init: cannot open control channel\n");
-		res = -ENODEV;
-		goto done;
-	}
-
-	acdb = dal_attach(ACDB_DAL_DEVICE, ACDB_DAL_PORT, 0, 0, 0);
-	if (!acdb) {
-		pr_err("audio_init: cannot attach to acdb channel\n");
-		res = -ENODEV;
-		goto done;
-	}
-	if (check_version(acdb, ACDB_DAL_VERSION) != 0) {
-		pr_err("Incompatablie acdb version\n");
-		res = -ENODEV;
-		goto done;
-	}
-
-
-	adie = dal_attach(ADIE_DAL_DEVICE, ADIE_DAL_PORT, 0, 0, 0);
-	if (!adie) {
-		pr_err("audio_init: cannot attach to adie\n");
-		res = -ENODEV;
-		goto done;
-	}
-	if (check_version(adie, ADIE_DAL_VERSION) != 0) {
-		pr_err("Incompatablie adie version\n");
-		res = -ENODEV;
-		goto done;
-	}
-	if (analog_ops->init)
-		analog_ops->init();
-
-	res = 0;
-	ac_control = ac;
-
-	pm_qos_add_request(&pm_qos_req, PM_QOS_CPU_DMA_LATENCY,
-				PM_QOS_DEFAULT_VALUE);
-done:
-	if ((res < 0) && ac)
-		audio_client_free(ac);
-	mutex_unlock(&audio_lock);
-
-	return res;
-}
-
-static int acdb_get_config_table(uint32_t device_id, uint32_t sample_rate)
-{
-	struct acdb_cmd_device_table rpc;
-	struct acdb_result res;
-	int r;
-
-	if (q6audio_init())
-		return 0;
-
-	memset(audio_data, 0, 4096);
-	memset(&rpc, 0, sizeof(rpc));
-
-	rpc.size = sizeof(rpc) - (2 * sizeof(uint32_t));
-	rpc.command_id = ACDB_GET_DEVICE_TABLE;
-	rpc.device_id = q6_device_to_cad_id(device_id);
-	rpc.network_id = 0x00010023;
-	rpc.sample_rate_id = sample_rate;
-	rpc.total_bytes = 4096;
-	rpc.unmapped_buf = audio_phys;
-	rpc.res_size = sizeof(res) - (2 * sizeof(uint32_t));
-
-	r = dal_call(acdb, ACDB_OP_IOCTL, 8, &rpc, sizeof(rpc),
-		     &res, sizeof(res));
-
-	if ((r == sizeof(res)) && (res.dal_status == 0))
-		return res.used_bytes;
-
-	return -EIO;
-}
-
-static uint32_t audio_rx_path_id = ADIE_PATH_HANDSET_RX;
-static uint32_t audio_rx_device_id = ADSP_AUDIO_DEVICE_ID_HANDSET_SPKR;
-static uint32_t audio_rx_device_group = -1;
-static uint32_t audio_tx_path_id = ADIE_PATH_HANDSET_TX;
-static uint32_t audio_tx_device_id = ADSP_AUDIO_DEVICE_ID_HANDSET_MIC;
-static uint32_t audio_tx_device_group = -1;
-
-static int qdsp6_devchg_notify(struct audio_client *ac,
-			       uint32_t dev_type, uint32_t dev_id)
-{
-	struct adsp_device_switch_command rpc;
-
-	if (dev_type != ADSP_AUDIO_RX_DEVICE &&
-	    dev_type != ADSP_AUDIO_TX_DEVICE)
-		return -EINVAL;
-
-	memset(&rpc, 0, sizeof(rpc));
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_DEVICE_SWITCH_PREPARE;
-	rpc.hdr.dest = AUDIO_ADDR(DOMAIN_DSP, ac->session, 0);
-	rpc.hdr.src = AUDIO_ADDR(DOMAIN_APP, ac->session, 0);
-
-	if (dev_type == ADSP_AUDIO_RX_DEVICE) {
-		rpc.old_device = audio_rx_device_id;
-		rpc.new_device = dev_id;
-	} else {
-		rpc.old_device = audio_tx_device_id;
-		rpc.new_device = dev_id;
-	}
-	rpc.device_class = 0;
-	rpc.device_type = dev_type;
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-static int qdsp6_standby(struct audio_client *ac)
-{
-	return audio_command(ac, ADSP_AUDIO_IOCTL_CMD_DEVICE_SWITCH_STANDBY);
-}
-
-static int qdsp6_start(struct audio_client *ac)
-{
-	return audio_command(ac, ADSP_AUDIO_IOCTL_CMD_DEVICE_SWITCH_COMMIT);
-}
-
-static void audio_rx_analog_enable(int en)
-{
-	switch (audio_rx_device_id) {
-	case ADSP_AUDIO_DEVICE_ID_HEADSET_SPKR_MONO:
-	case ADSP_AUDIO_DEVICE_ID_HEADSET_SPKR_STEREO:
-	case ADSP_AUDIO_DEVICE_ID_TTY_HEADSET_SPKR:
-		if (analog_ops->headset_enable)
-			analog_ops->headset_enable(en);
-		break;
-	case ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MONO_W_MONO_HEADSET:
-	case ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MONO_W_STEREO_HEADSET:
-	case ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_STEREO_W_MONO_HEADSET:
-	case ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_STEREO_W_STEREO_HEADSET:
-		if (analog_ops->headset_enable)
-			analog_ops->headset_enable(en);
-		if (analog_ops->speaker_enable)
-			analog_ops->speaker_enable(en);
-		break;
-	case ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MONO:
-	case ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_STEREO:
-		if (analog_ops->speaker_enable)
-			analog_ops->speaker_enable(en);
-		break;
-	case ADSP_AUDIO_DEVICE_ID_BT_SCO_SPKR:
-		if (analog_ops->bt_sco_enable)
-			analog_ops->bt_sco_enable(en);
-		break;
-	}
-}
-
-static void audio_tx_analog_enable(int en)
-{
-	switch (audio_tx_device_id) {
-	case ADSP_AUDIO_DEVICE_ID_HANDSET_MIC:
-	case ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MIC:
-		if (analog_ops->int_mic_enable)
-			analog_ops->int_mic_enable(en);
-		break;
-	case ADSP_AUDIO_DEVICE_ID_HEADSET_MIC:
-	case ADSP_AUDIO_DEVICE_ID_TTY_HEADSET_MIC:
-		if (analog_ops->ext_mic_enable)
-			analog_ops->ext_mic_enable(en);
-		break;
-	case ADSP_AUDIO_DEVICE_ID_BT_SCO_MIC:
-		if (analog_ops->bt_sco_enable)
-			analog_ops->bt_sco_enable(en);
-		break;
-	}
-}
-
-static void _audio_rx_path_enable(void)
-{
-	uint32_t adev, sample_rate;
-	int sz;
-	uint32_t adie_params[5];
-
-	adev = audio_rx_device_id;
-	sample_rate = q6_device_to_rate(adev);
-
-	sz = acdb_get_config_table(adev, sample_rate);
-	audio_set_table(ac_control, adev, sz);
-
-	adie_params[0] = 4*sizeof(uint32_t);
-	adie_params[1] = audio_rx_path_id;
-	adie_params[2] = ADIE_PATH_RX;
-	adie_params[3] = 48000;
-	adie_params[4] = 256;
-	/*check for errors here*/
-	if (!adie_set_path(adie, adie_params, sizeof(adie_params)))
-		pr_err("adie set rx path failed\n");
-
-	adie_proceed_to_stage(adie, ADIE_PATH_RX,
-				ADIE_STAGE_DIGITAL_READY);
-	adie_proceed_to_stage(adie, ADIE_PATH_RX,
-				ADIE_STAGE_DIGITAL_ANALOG_READY);
-
-	audio_rx_analog_enable(1);
-
-	audio_rx_mute(ac_control, adev, 0);
-
-	audio_rx_volume(ac_control, adev, q6_device_volume(adev, 100));
-}
-
-static void _audio_tx_path_enable(void)
-{
-	uint32_t adev;
-	int sz;
-	uint32_t adie_params[5];
-
-	adev = audio_tx_device_id;
-
-	pr_info("audiolib: load %08x cfg table\n", adev);
-
-	if (tx_clk_freq > 16000) {
-		adie_params[3] = 48000;
-		sz = acdb_get_config_table(adev, 48000);
-
-	} else if (tx_clk_freq > 8000) {
-		adie_params[3] = 16000;
-		sz = acdb_get_config_table(adev, 16000);
-	} else {
-
-		adie_params[3] = 8000;
-		sz = acdb_get_config_table(adev, 8000);
-	}
-
-	pr_info("cfg table is %d bytes\n", sz);
-	audio_set_table(ac_control, adev, sz);
-
-	pr_info("audiolib: set adie tx path\n");
-
-	adie_params[0] = 4*sizeof(uint32_t);
-	adie_params[1] = audio_tx_path_id;
-	adie_params[2] = ADIE_PATH_TX;
-	adie_params[4] = 256;
-
-	if (!adie_set_path(adie, adie_params, sizeof(adie_params)))
-		pr_err("adie set tx path failed\n");
-
-	adie_proceed_to_stage(adie, ADIE_PATH_TX,
-					 ADIE_STAGE_DIGITAL_READY);
-	adie_proceed_to_stage(adie, ADIE_PATH_TX,
-					 ADIE_STAGE_DIGITAL_ANALOG_READY);
-
-	audio_tx_analog_enable(1);
-	audio_tx_mute(ac_control, adev, tx_mute_status);
-
-	if (!tx_mute_status)
-		audio_tx_volume(ac_control, adev, q6_device_volume(adev, 100));
-}
-
-static void _audio_rx_path_disable(void)
-{
-	audio_rx_analog_enable(0);
-
-	adie_proceed_to_stage(adie, ADIE_PATH_RX, ADIE_STAGE_ANALOG_OFF);
-	adie_proceed_to_stage(adie, ADIE_PATH_RX, ADIE_STAGE_DIGITAL_OFF);
-}
-
-static void _audio_tx_path_disable(void)
-{
-	audio_tx_analog_enable(0);
-
-	adie_proceed_to_stage(adie, ADIE_PATH_TX, ADIE_STAGE_ANALOG_OFF);
-	adie_proceed_to_stage(adie, ADIE_PATH_TX, ADIE_STAGE_DIGITAL_OFF);
-}
-
-static int icodec_rx_clk_refcount;
-static int icodec_tx_clk_refcount;
-static int ecodec_clk_refcount;
-static int sdac_clk_refcount;
-
-static void _audio_rx_clk_enable(void)
-{
-	uint32_t device_group = q6_device_to_codec(audio_rx_device_id);
-
-	switch (device_group) {
-	case Q6_ICODEC_RX:
-		icodec_rx_clk_refcount++;
-		if (icodec_rx_clk_refcount == 1) {
-			clk_set_rate(icodec_rx_clk, 12288000);
-			clk_enable(icodec_rx_clk);
-		}
-		break;
-	case Q6_ECODEC_RX:
-		ecodec_clk_refcount++;
-		if (ecodec_clk_refcount == 1) {
-			clk_set_rate(ecodec_clk, 2048000);
-			clk_enable(ecodec_clk);
-		}
-		break;
-	case Q6_SDAC_RX:
-		sdac_clk_refcount++;
-		if (sdac_clk_refcount == 1) {
-			clk_set_rate(sdac_clk, 12288000);
-			clk_enable(sdac_clk);
-		}
-		break;
-	default:
-		return;
-	}
-	audio_rx_device_group = device_group;
-}
-
-static void _audio_tx_clk_enable(void)
-{
-	uint32_t device_group = q6_device_to_codec(audio_tx_device_id);
-
-	switch (device_group) {
-	case Q6_ICODEC_TX:
-		icodec_tx_clk_refcount++;
-		if (icodec_tx_clk_refcount == 1) {
-			clk_set_rate(icodec_tx_clk, tx_clk_freq * 256);
-			clk_enable(icodec_tx_clk);
-		}
-		break;
-	case Q6_ECODEC_TX:
-		ecodec_clk_refcount++;
-		if (ecodec_clk_refcount == 1) {
-			clk_set_rate(ecodec_clk, 2048000);
-			clk_enable(ecodec_clk);
-		}
-		break;
-	case Q6_SDAC_TX:
-		/* TODO: In QCT BSP, clk rate was set to 20480000 */
-		sdac_clk_refcount++;
-		if (sdac_clk_refcount == 1) {
-			clk_set_rate(sdac_clk, 12288000);
-			clk_enable(sdac_clk);
-		}
-		break;
-	default:
-		return;
-	}
-	audio_tx_device_group = device_group;
-}
-
-static void _audio_rx_clk_disable(void)
-{
-	switch (audio_rx_device_group) {
-	case Q6_ICODEC_RX:
-		icodec_rx_clk_refcount--;
-		if (icodec_rx_clk_refcount == 0) {
-			clk_disable(icodec_rx_clk);
-			audio_rx_device_group = -1;
-		}
-		break;
-	case Q6_ECODEC_RX:
-		ecodec_clk_refcount--;
-		if (ecodec_clk_refcount == 0) {
-			clk_disable(ecodec_clk);
-			audio_rx_device_group = -1;
-		}
-		break;
-	case Q6_SDAC_RX:
-		sdac_clk_refcount--;
-		if (sdac_clk_refcount == 0) {
-			clk_disable(sdac_clk);
-			audio_rx_device_group = -1;
-		}
-		break;
-	default:
-		pr_err("audiolib: invalid rx device group %d\n",
-			audio_rx_device_group);
-		break;
-	}
-}
-
-static void _audio_tx_clk_disable(void)
-{
-	switch (audio_tx_device_group) {
-	case Q6_ICODEC_TX:
-		icodec_tx_clk_refcount--;
-		if (icodec_tx_clk_refcount == 0) {
-			clk_disable(icodec_tx_clk);
-			audio_tx_device_group = -1;
-		}
-		break;
-	case Q6_ECODEC_TX:
-		ecodec_clk_refcount--;
-		if (ecodec_clk_refcount == 0) {
-			clk_disable(ecodec_clk);
-			audio_tx_device_group = -1;
-		}
-		break;
-	case Q6_SDAC_TX:
-		sdac_clk_refcount--;
-		if (sdac_clk_refcount == 0) {
-			clk_disable(sdac_clk);
-			audio_tx_device_group = -1;
-		}
-		break;
-	default:
-		pr_err("audiolib: invalid tx device group %d\n",
-			audio_tx_device_group);
-		break;
-	}
-}
-
-static void _audio_rx_clk_reinit(uint32_t rx_device)
-{
-	uint32_t device_group = q6_device_to_codec(rx_device);
-
-	if (device_group != audio_rx_device_group)
-		_audio_rx_clk_disable();
-
-	audio_rx_device_id = rx_device;
-	audio_rx_path_id = q6_device_to_path(rx_device);
-
-	if (device_group != audio_rx_device_group)
-		_audio_rx_clk_enable();
-
-}
-
-static void _audio_tx_clk_reinit(uint32_t tx_device)
-{
-	uint32_t device_group = q6_device_to_codec(tx_device);
-
-	if (device_group != audio_tx_device_group)
-		_audio_tx_clk_disable();
-
-	audio_tx_device_id = tx_device;
-	audio_tx_path_id = q6_device_to_path(tx_device);
-
-	if (device_group != audio_tx_device_group)
-		_audio_tx_clk_enable();
-}
-
-static DEFINE_MUTEX(audio_path_lock);
-static int audio_rx_path_refcount;
-static int audio_tx_path_refcount;
-
-static int audio_rx_path_enable(int en)
-{
-	mutex_lock(&audio_path_lock);
-	if (en) {
-		audio_rx_path_refcount++;
-		if (audio_rx_path_refcount == 1) {
-			adie_enable();
-			_audio_rx_clk_enable();
-			_audio_rx_path_enable();
-		}
-	} else {
-		audio_rx_path_refcount--;
-		if (audio_rx_path_refcount == 0) {
-			_audio_rx_path_disable();
-			_audio_rx_clk_disable();
-			adie_disable();
-		}
-	}
-	mutex_unlock(&audio_path_lock);
-	return 0;
-}
-
-static int audio_tx_path_enable(int en)
-{
-	mutex_lock(&audio_path_lock);
-	if (en) {
-		audio_tx_path_refcount++;
-		if (audio_tx_path_refcount == 1) {
-			adie_enable();
-			_audio_tx_clk_enable();
-			_audio_tx_path_enable();
-		}
-	} else {
-		audio_tx_path_refcount--;
-		if (audio_tx_path_refcount == 0) {
-			_audio_tx_path_disable();
-			_audio_tx_clk_disable();
-			adie_disable();
-		}
-	}
-	mutex_unlock(&audio_path_lock);
-	return 0;
-}
-
-int q6audio_update_acdb(uint32_t id_src, uint32_t id_dst)
-{
-	mutex_lock(&audio_path_lock);
-	mutex_unlock(&audio_path_lock);
-	return 0;
-}
-
-int q6audio_set_tx_mute(int mute)
-{
-	uint32_t adev;
-	int rc;
-
-	if (q6audio_init())
-		return 0;
-
-	mutex_lock(&audio_path_lock);
-
-	if (mute == tx_mute_status) {
-		mutex_unlock(&audio_path_lock);
-		return 0;
-	}
-
-	adev = audio_tx_device_id;
-	rc = audio_tx_mute(ac_control, adev, mute);
-	if (!rc)
-		tx_mute_status = mute;
-	mutex_unlock(&audio_path_lock);
-	return 0;
-}
-
-int q6audio_set_rx_volume(int level)
-{
-	uint32_t adev;
-	int vol;
-
-	if (q6audio_init())
-		return 0;
-
-	if (level < 0 || level > 100)
-		return -EINVAL;
-
-	mutex_lock(&audio_path_lock);
-	adev = audio_rx_device_id;
-	vol = q6_device_volume(adev, level);
-	audio_rx_mute(ac_control, adev, 0);
-	audio_rx_volume(ac_control, adev, vol);
-	mutex_unlock(&audio_path_lock);
-	return 0;
-}
-
-static void do_rx_routing(uint32_t device_id)
-{
-	int sz;
-	uint32_t sample_rate;
-
-	if (device_id == audio_rx_device_id)
-		return;
-
-	if (audio_rx_path_refcount > 0) {
-		qdsp6_devchg_notify(ac_control, ADSP_AUDIO_RX_DEVICE,
-					 device_id);
-		_audio_rx_path_disable();
-		_audio_rx_clk_reinit(device_id);
-		_audio_rx_path_enable();
-	} else {
-		sample_rate = q6_device_to_rate(device_id);
-		sz = acdb_get_config_table(device_id, sample_rate);
-		if (sz < 0)
-			pr_err("could not get ACDB config table\n");
-
-		audio_set_table(ac_control, device_id, sz);
-		qdsp6_devchg_notify(ac_control, ADSP_AUDIO_RX_DEVICE,
-					 device_id);
-		qdsp6_standby(ac_control);
-		qdsp6_start(ac_control);
-		audio_rx_device_id = device_id;
-		audio_rx_path_id = q6_device_to_path(device_id);
-	}
-}
-
-static void do_tx_routing(uint32_t device_id)
-{
-	int sz;
-	uint32_t sample_rate;
-
-	if (device_id == audio_tx_device_id)
-		return;
-
-	if (audio_tx_path_refcount > 0) {
-		qdsp6_devchg_notify(ac_control, ADSP_AUDIO_TX_DEVICE,
-					 device_id);
-		_audio_tx_path_disable();
-		_audio_tx_clk_reinit(device_id);
-		_audio_tx_path_enable();
-	} else {
-		sample_rate = q6_device_to_rate(device_id);
-		sz = acdb_get_config_table(device_id, sample_rate);
-		audio_set_table(ac_control, device_id, sz);
-		qdsp6_devchg_notify(ac_control, ADSP_AUDIO_TX_DEVICE,
-					 device_id);
-		qdsp6_standby(ac_control);
-		qdsp6_start(ac_control);
-		audio_tx_device_id = device_id;
-		audio_tx_path_id = q6_device_to_path(device_id);
-	}
-}
-
-int q6audio_do_routing(uint32_t device_id)
-{
-	if (q6audio_init())
-		return 0;
-
-	mutex_lock(&audio_path_lock);
-
-	switch (q6_device_to_dir(device_id)) {
-	case Q6_RX:
-		do_rx_routing(device_id);
-		break;
-	case Q6_TX:
-		do_tx_routing(device_id);
-		break;
-	}
-
-	mutex_unlock(&audio_path_lock);
-	return 0;
-}
-
-int q6audio_set_route(const char *name)
-{
-	uint32_t route;
-	if (!strcmp(name, "speaker"))
-		route = ADIE_PATH_SPEAKER_STEREO_RX;
-	else if (!strcmp(name, "headphones"))
-		route = ADIE_PATH_HEADSET_STEREO_RX;
-	else if (!strcmp(name, "handset"))
-		route = ADIE_PATH_HANDSET_RX;
-	else
-		return -EINVAL;
-
-	mutex_lock(&audio_path_lock);
-	if (route == audio_rx_path_id)
-		goto done;
-
-	audio_rx_path_id = route;
-
-	if (audio_rx_path_refcount > 0) {
-		_audio_rx_path_disable();
-		_audio_rx_path_enable();
-	}
-	if (audio_tx_path_refcount > 0) {
-		_audio_tx_path_disable();
-		_audio_tx_path_enable();
-	}
-done:
-	mutex_unlock(&audio_path_lock);
-	return 0;
-}
-
-struct audio_client *q6audio_open(uint32_t flags, uint32_t bufsz)
-{
-	struct audio_client *ac;
-
-	if (q6audio_init())
-		return 0;
-
-	ac = audio_client_alloc(bufsz);
-	if (!ac)
-		return 0;
-
-	ac->flags = flags;
-	if (ac->flags & AUDIO_FLAG_WRITE)
-		audio_rx_path_enable(1);
-	else
-		audio_tx_path_enable(1);
-
-	return ac;
-}
-
-int q6audio_start(struct audio_client *ac, void *rpc,
-						uint32_t len)
-{
-
-	audio_ioctl(ac, rpc, len);
-
-	audio_command(ac, ADSP_AUDIO_IOCTL_CMD_SESSION_START);
-
-	if (!(ac->flags & AUDIO_FLAG_WRITE)) {
-		ac->buf[0].used = 1;
-		ac->buf[1].used = 1;
-		q6audio_read(ac, &ac->buf[0]);
-		q6audio_read(ac, &ac->buf[1]);
-	}
-
-	audio_prevent_sleep();
-	return 0;
-}
-
-int q6audio_close(struct audio_client *ac)
-{
-	audio_close(ac);
-
-	if (ac->flags & AUDIO_FLAG_WRITE)
-		audio_rx_path_enable(0);
-	else
-		audio_tx_path_enable(0);
-
-	audio_client_free(ac);
-	audio_allow_sleep();
-	return 0;
-}
-
-struct audio_client *q6voice_open(void)
-{
-	struct audio_client *ac;
-
-	if (q6audio_init())
-		return 0;
-
-	ac = audio_client_alloc(0);
-	if (!ac)
-		return 0;
-
-	return ac;
-}
-
-int q6voice_setup(void)
-{
-	audio_rx_path_enable(1);
-	tx_clk_freq = 8000;
-	audio_tx_path_enable(1);
-
-	return 0;
-}
-
-int q6voice_teardown(void)
-{
-	audio_rx_path_enable(0);
-	audio_tx_path_enable(0);
-	return 0;
-}
-
-
-int q6voice_close(struct audio_client *ac)
-{
-	audio_client_free(ac);
-	return 0;
-}
-
-int q6audio_async(struct audio_client *ac)
-{
-	struct adsp_command_hdr rpc;
-	memset(&rpc, 0, sizeof(rpc));
-	rpc.opcode = ADSP_AUDIO_IOCTL_CMD_STREAM_EOS;
-	rpc.response_type = ADSP_AUDIO_RESPONSE_ASYNC;
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
diff --git a/arch/arm/mach-msm/qdsp6/audiov2/q6audio_devices.h b/arch/arm/mach-msm/qdsp6/audiov2/q6audio_devices.h
deleted file mode 100644
index 3786cca..0000000
--- a/arch/arm/mach-msm/qdsp6/audiov2/q6audio_devices.h
+++ /dev/null
@@ -1,276 +0,0 @@
-/* arch/arm/mach-msm/qdsp6/audiov2/q6audio_devices.h
- *
- * Copyright (C) 2009 Google, Inc.
- * Copyright (c) 2009, The Linux Foundation. All rights reserved.
- *
- * Author: Brian Swetland <swetland@google.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-struct q6_device_info {
-	uint32_t id;
-	uint32_t cad_id;
-	uint32_t path;
-	uint32_t rate;
-	uint8_t dir;
-	uint8_t codec;
-	uint8_t hw;
-};
-
-#define Q6_ICODEC_RX		0
-#define Q6_ICODEC_TX		1
-#define Q6_ECODEC_RX		2
-#define Q6_ECODEC_TX		3
-#define Q6_SDAC_RX		6
-#define Q6_SDAC_TX		7
-#define Q6_CODEC_NONE		255
-
-#define Q6_TX		1
-#define Q6_RX		2
-#define Q6_TX_RX	3
-
-#define Q6_HW_HANDSET	0
-#define Q6_HW_HEADSET	1
-#define Q6_HW_SPEAKER	2
-#define Q6_HW_TTY	3
-#define Q6_HW_BT_SCO	4
-#define Q6_HW_BT_A2DP	5
-
-#define Q6_HW_COUNT	6
-
-#define CAD_HW_DEVICE_ID_HANDSET_MIC		0x01
-#define CAD_HW_DEVICE_ID_HANDSET_SPKR		0x02
-#define CAD_HW_DEVICE_ID_HEADSET_MIC		0x03
-#define CAD_HW_DEVICE_ID_HEADSET_SPKR_MONO	0x04
-#define CAD_HW_DEVICE_ID_HEADSET_SPKR_STEREO	0x05
-#define CAD_HW_DEVICE_ID_SPKR_PHONE_MIC		0x06
-#define CAD_HW_DEVICE_ID_SPKR_PHONE_MONO	0x07
-#define CAD_HW_DEVICE_ID_SPKR_PHONE_STEREO	0x08
-#define CAD_HW_DEVICE_ID_BT_SCO_MIC		0x09
-#define CAD_HW_DEVICE_ID_BT_SCO_SPKR		0x0A
-#define CAD_HW_DEVICE_ID_BT_A2DP_SPKR		0x0B
-#define CAD_HW_DEVICE_ID_TTY_HEADSET_MIC	0x0C
-#define CAD_HW_DEVICE_ID_TTY_HEADSET_SPKR	0x0D
-
-#define CAD_HW_DEVICE_ID_DEFAULT_TX		0x0E
-#define CAD_HW_DEVICE_ID_DEFAULT_RX		0x0F
-
-/* Logical Device to indicate A2DP routing */
-#define CAD_HW_DEVICE_ID_BT_A2DP_TX             0x10
-#define CAD_HW_DEVICE_ID_HEADSET_MONO_PLUS_SPKR_MONO_RX		0x11
-#define CAD_HW_DEVICE_ID_HEADSET_MONO_PLUS_SPKR_STEREO_RX	0x12
-#define CAD_HW_DEVICE_ID_HEADSET_STEREO_PLUS_SPKR_MONO_RX	0x13
-#define CAD_HW_DEVICE_ID_HEADSET_STEREO_PLUS_SPKR_STEREO_RX	0x14
-
-#define CAD_HW_DEVICE_ID_VOICE			0x15
-
-#define CAD_HW_DEVICE_ID_I2S_RX                 0x20
-#define CAD_HW_DEVICE_ID_I2S_TX                 0x21
-
-/* AUXPGA */
-#define CAD_HW_DEVICE_ID_HEADSET_SPKR_STEREO_LB 0x22
-#define CAD_HW_DEVICE_ID_HEADSET_SPKR_MONO_LB   0x23
-#define CAD_HW_DEVICE_ID_SPEAKER_SPKR_STEREO_LB 0x24
-#define CAD_HW_DEVICE_ID_SPEAKER_SPKR_MONO_LB   0x25
-
-#define CAD_HW_DEVICE_ID_NULL_RX		0x2A
-
-#define CAD_HW_DEVICE_ID_MAX_NUM                0x2F
-
-#define CAD_HW_DEVICE_ID_INVALID                0xFF
-
-#define CAD_RX_DEVICE  0x00
-#define CAD_TX_DEVICE  0x01
-
-static struct q6_device_info q6_audio_devices[] = {
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_HANDSET_SPKR,
-		.cad_id	= CAD_HW_DEVICE_ID_HANDSET_SPKR,
-		.path	= ADIE_PATH_HANDSET_RX,
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ICODEC_RX,
-		.hw	= Q6_HW_HANDSET,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_HEADSET_SPKR_MONO,
-		.cad_id	= CAD_HW_DEVICE_ID_HEADSET_SPKR_MONO,
-		.path	= ADIE_PATH_HEADSET_MONO_RX,
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ICODEC_RX,
-		.hw	= Q6_HW_HEADSET,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_HEADSET_SPKR_STEREO,
-		.cad_id	= CAD_HW_DEVICE_ID_HEADSET_SPKR_STEREO,
-		.path	= ADIE_PATH_HEADSET_STEREO_RX,
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ICODEC_RX,
-		.hw	= Q6_HW_HEADSET,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MONO,
-		.cad_id	= CAD_HW_DEVICE_ID_SPKR_PHONE_MONO,
-		.path	= ADIE_PATH_SPEAKER_RX,
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ICODEC_RX,
-		.hw	= Q6_HW_HEADSET,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_STEREO,
-		.cad_id	= CAD_HW_DEVICE_ID_SPKR_PHONE_STEREO,
-		.path	= ADIE_PATH_SPEAKER_STEREO_RX,
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ICODEC_RX,
-		.hw	= Q6_HW_SPEAKER,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MONO_W_MONO_HEADSET,
-		.cad_id	= CAD_HW_DEVICE_ID_HEADSET_MONO_PLUS_SPKR_MONO_RX,
-		.path	= ADIE_PATH_SPKR_MONO_HDPH_MONO_RX,
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ICODEC_RX,
-		.hw	= Q6_HW_SPEAKER,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MONO_W_STEREO_HEADSET,
-		.cad_id	= CAD_HW_DEVICE_ID_HEADSET_MONO_PLUS_SPKR_STEREO_RX,
-		.path	= ADIE_PATH_SPKR_MONO_HDPH_STEREO_RX,
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ICODEC_RX,
-		.hw	= Q6_HW_SPEAKER,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_STEREO_W_MONO_HEADSET,
-		.cad_id	= CAD_HW_DEVICE_ID_HEADSET_STEREO_PLUS_SPKR_MONO_RX,
-		.path	= ADIE_PATH_SPKR_STEREO_HDPH_MONO_RX,
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ICODEC_RX,
-		.hw	= Q6_HW_SPEAKER,
-	},
-	{
-		.id = ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_STEREO_W_STEREO_HEADSET,
-		.cad_id	= CAD_HW_DEVICE_ID_HEADSET_STEREO_PLUS_SPKR_STEREO_RX,
-		.path	= ADIE_PATH_SPKR_STEREO_HDPH_STEREO_RX,
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ICODEC_RX,
-		.hw	= Q6_HW_SPEAKER,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_TTY_HEADSET_SPKR,
-		.cad_id	= CAD_HW_DEVICE_ID_TTY_HEADSET_SPKR,
-		.path	= ADIE_PATH_TTY_HEADSET_RX,
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ICODEC_RX,
-		.hw	= Q6_HW_TTY,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_HANDSET_MIC,
-		.cad_id	= CAD_HW_DEVICE_ID_HANDSET_MIC,
-		.path	= ADIE_PATH_HANDSET_TX,
-		.rate   = 8000,
-		.dir	= Q6_TX,
-		.codec	= Q6_ICODEC_TX,
-		.hw	= Q6_HW_HANDSET,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_HEADSET_MIC,
-		.cad_id	= CAD_HW_DEVICE_ID_HEADSET_MIC,
-		.path	= ADIE_PATH_HEADSET_MONO_TX,
-		.rate   = 8000,
-		.dir	= Q6_TX,
-		.codec	= Q6_ICODEC_TX,
-		.hw	= Q6_HW_HEADSET,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MIC,
-		.cad_id	= CAD_HW_DEVICE_ID_SPKR_PHONE_MIC,
-		.path	= ADIE_PATH_SPEAKER_TX,
-		.rate   = 8000,
-		.dir	= Q6_TX,
-		.codec	= Q6_ICODEC_TX,
-		.hw	= Q6_HW_SPEAKER,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_TTY_HEADSET_MIC,
-		.cad_id	= CAD_HW_DEVICE_ID_TTY_HEADSET_MIC,
-		.path	= ADIE_PATH_TTY_HEADSET_TX,
-		.rate   = 8000,
-		.dir	= Q6_TX,
-		.codec	= Q6_ICODEC_TX,
-		.hw	= Q6_HW_HEADSET,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_BT_SCO_SPKR,
-		.cad_id	= CAD_HW_DEVICE_ID_BT_SCO_SPKR,
-		.path	= 0, /* XXX */
-		.rate   = 8000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ECODEC_RX,
-		.hw	= Q6_HW_BT_SCO,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_BT_A2DP_SPKR,
-		.cad_id	= CAD_HW_DEVICE_ID_BT_A2DP_SPKR,
-		.path	= 0, /* XXX */
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ECODEC_RX,
-		.hw	= Q6_HW_BT_A2DP,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_BT_SCO_MIC,
-		.cad_id	= CAD_HW_DEVICE_ID_BT_SCO_MIC,
-		.path	= 0, /* XXX */
-		.rate   = 8000,
-		.dir	= Q6_TX,
-		.codec	= Q6_ECODEC_TX,
-		.hw	= Q6_HW_BT_SCO,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_I2S_SPKR,
-		.cad_id	= CAD_HW_DEVICE_ID_I2S_RX,
-		.path	= 0, /* XXX */
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_SDAC_RX,
-		.hw	= Q6_HW_SPEAKER,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_I2S_MIC,
-		.cad_id	= CAD_HW_DEVICE_ID_I2S_TX,
-		.path	= 0, /* XXX */
-		.rate   = 16000,
-		.dir	= Q6_TX,
-		.codec	= Q6_SDAC_TX,
-		.hw	= Q6_HW_SPEAKER,
-	},
-	{
-		.id	= 0,
-		.cad_id	= 0,
-		.path	= 0,
-		.rate   = 8000,
-		.dir	= 0,
-		.codec	= Q6_CODEC_NONE,
-		.hw	= 0,
-	},
-};
-
diff --git a/arch/arm/mach-msm/qdsp6/audiov2/qcelp_in.c b/arch/arm/mach-msm/qdsp6/audiov2/qcelp_in.c
deleted file mode 100644
index 40ae37d..0000000
--- a/arch/arm/mach-msm/qdsp6/audiov2/qcelp_in.c
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- * Copyright (C) 2009 Google, Inc.
- * Copyright (C) 2009 HTC Corporation
- * Copyright (c) 2009, The Linux Foundation. All rights reserved.
- *
- * Author: Brian Swetland <swetland@google.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/uaccess.h>
-
-#include <linux/msm_audio_qcp.h>
-#include <mach/msm_qdsp6_audiov2.h>
-#include "dal_audio.h"
-#include "dal_audio_format.h"
-#include <mach/debug_mm.h>
-
-
-struct qcelp {
-	struct mutex lock;
-	struct msm_audio_qcelp_enc_config cfg;
-	struct msm_audio_stream_config str_cfg;
-	struct audio_client *audio_client;
-};
-
-
-static long q6_qcelp_in_ioctl(struct file *file, unsigned int cmd,
-				 unsigned long arg)
-{
-	struct qcelp *qcelp = file->private_data;
-	struct adsp_open_command rpc;
-	int rc = 0;
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		memset(&stats, 0, sizeof(stats));
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-
-	mutex_lock(&qcelp->lock);
-	switch (cmd) {
-	case AUDIO_START:
-		if (qcelp->audio_client) {
-			rc = -EBUSY;
-			break;
-		} else {
-			qcelp->audio_client = q6audio_open(AUDIO_FLAG_READ,
-						qcelp->str_cfg.buffer_size);
-
-			if (!qcelp->audio_client) {
-				kfree(qcelp);
-				rc = -ENOMEM;
-				break;
-			}
-		}
-
-		tx_clk_freq = 8000;
-
-		memset(&rpc, 0, sizeof(rpc));
-
-		rpc.format_block.standard.format = ADSP_AUDIO_FORMAT_V13K_FS;
-		rpc.format_block.standard.channels = 1;
-		rpc.format_block.standard.bits_per_sample = 16;
-		rpc.format_block.standard.sampling_rate = 8000;
-		rpc.format_block.standard.is_signed = 1;
-		rpc.format_block.standard.is_interleaved = 0;
-		rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_OPEN_READ;
-		rpc.device = ADSP_AUDIO_DEVICE_ID_DEFAULT;
-		rpc.stream_context = ADSP_AUDIO_DEVICE_CONTEXT_RECORD;
-		rpc.buf_max_size = qcelp->str_cfg.buffer_size;
-		rpc.config.qcelp13k.min_rate = qcelp->cfg.min_bit_rate;
-		rpc.config.qcelp13k.max_rate = qcelp->cfg.max_bit_rate;
-
-		q6audio_start(qcelp->audio_client, &rpc, sizeof(rpc));
-		break;
-	case AUDIO_STOP:
-		break;
-	case AUDIO_FLUSH:
-		break;
-	case AUDIO_SET_VOLUME:
-		break;
-	case AUDIO_GET_STREAM_CONFIG:
-		if (copy_to_user((void *)arg, &qcelp->str_cfg,
-				sizeof(struct msm_audio_stream_config)))
-			rc = -EFAULT;
-		break;
-	case AUDIO_SET_STREAM_CONFIG:
-		if (copy_from_user(&qcelp->str_cfg, (void *)arg,
-			sizeof(struct msm_audio_stream_config))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		if (qcelp->str_cfg.buffer_size < 35) {
-			pr_err("[%s:%s] Buffer size too small\n", __MM_FILE__,
-					__func__);
-			rc = -EINVAL;
-			break;
-		}
-
-		if (qcelp->str_cfg.buffer_count != 2)
-			pr_info("[%s:%s] Buffer count set to 2\n", __MM_FILE__,
-					__func__);
-		break;
-	case AUDIO_SET_QCELP_ENC_CONFIG:
-		if (copy_from_user(&qcelp->cfg, (void *) arg,
-				sizeof(struct msm_audio_qcelp_enc_config)))
-			rc = -EFAULT;
-
-		if (qcelp->cfg.min_bit_rate > 4 ||
-			 qcelp->cfg.min_bit_rate < 1) {
-
-			pr_err("[%s:%s] invalid min bitrate\n", __MM_FILE__,
-					__func__);
-			rc = -EINVAL;
-		}
-		if (qcelp->cfg.max_bit_rate > 4 ||
-			 qcelp->cfg.max_bit_rate < 1) {
-
-			pr_err("[%s:%s] invalid max bitrate\n", __MM_FILE__,
-					__func__);
-			rc = -EINVAL;
-		}
-
-		break;
-	case AUDIO_GET_QCELP_ENC_CONFIG:
-		if (copy_to_user((void *) arg, &qcelp->cfg,
-			 sizeof(struct msm_audio_qcelp_enc_config)))
-			rc = -EFAULT;
-		break;
-
-	default:
-		rc = -EINVAL;
-	}
-
-	mutex_unlock(&qcelp->lock);
-	return rc;
-}
-
-static int q6_qcelp_in_open(struct inode *inode, struct file *file)
-{
-	struct qcelp *qcelp;
-	qcelp = kmalloc(sizeof(struct qcelp), GFP_KERNEL);
-	if (qcelp == NULL) {
-		pr_err("[%s:%s] Could not allocate memory for qcelp driver\n",
-				__MM_FILE__, __func__);
-		return -ENOMEM;
-	}
-
-	mutex_init(&qcelp->lock);
-	file->private_data = qcelp;
-	qcelp->audio_client = NULL;
-	qcelp->str_cfg.buffer_size = 35;
-	qcelp->str_cfg.buffer_count = 2;
-	qcelp->cfg.cdma_rate = CDMA_RATE_FULL;
-	qcelp->cfg.min_bit_rate = 1;
-	qcelp->cfg.max_bit_rate = 4;
-	return 0;
-}
-
-static ssize_t q6_qcelp_in_read(struct file *file, char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct audio_client *ac;
-	struct audio_buffer *ab;
-	const char __user *start = buf;
-	struct qcelp *qcelp = file->private_data;
-	int xfer = 0;
-	int res;
-
-	mutex_lock(&qcelp->lock);
-	ac = qcelp->audio_client;
-	if (!ac) {
-		res = -ENODEV;
-		goto fail;
-	}
-	while (count > xfer) {
-		ab = ac->buf + ac->cpu_buf;
-
-		if (ab->used)
-			wait_event(ac->wait, (ab->used == 0));
-
-		xfer = ab->actual_size;
-
-		if (copy_to_user(buf, ab->data, xfer)) {
-			res = -EFAULT;
-			goto fail;
-		}
-
-		buf += xfer;
-		count -= xfer;
-
-		ab->used = 1;
-		q6audio_read(ac, ab);
-		ac->cpu_buf ^= 1;
-	}
-
-	res = buf - start;
-
-fail:
-	mutex_unlock(&qcelp->lock);
-
-	return res;
-}
-
-static int q6_qcelp_in_release(struct inode *inode, struct file *file)
-{
-	int rc = 0;
-	struct qcelp *qcelp = file->private_data;
-
-	mutex_lock(&qcelp->lock);
-	if (qcelp->audio_client)
-		rc = q6audio_close(qcelp->audio_client);
-	mutex_unlock(&qcelp->lock);
-	kfree(qcelp);
-	return rc;
-}
-
-static const struct file_operations q6_qcelp_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= q6_qcelp_in_open,
-	.read		= q6_qcelp_in_read,
-	.release	= q6_qcelp_in_release,
-	.unlocked_ioctl	= q6_qcelp_in_ioctl,
-};
-
-struct miscdevice q6_qcelp_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_qcelp_in",
-	.fops	= &q6_qcelp_in_fops,
-};
-
-static int __init q6_qcelp_in_init(void)
-{
-	return misc_register(&q6_qcelp_in_misc);
-}
-
-device_initcall(q6_qcelp_in_init);
diff --git a/arch/arm/mach-msm/qdsp6/audiov2/routing.c b/arch/arm/mach-msm/qdsp6/audiov2/routing.c
deleted file mode 100644
index 1ba128c..0000000
--- a/arch/arm/mach-msm/qdsp6/audiov2/routing.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* arch/arm/mach-msm/qdsp6/audiov2/routing.c
- *
- * Copyright (C) 2009 Google, Inc.
- * Copyright (c) 2009, The Linux Foundation. All rights reserved.
- *
- * Author: Brian Swetland <swetland@google.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <mach/msm_qdsp6_audiov2.h>
-
-static int q6_open(struct inode *inode, struct file *file)
-{
-	return 0;
-}
-
-static ssize_t q6_write(struct file *file, const char __user *buf,
-			size_t count, loff_t *pos)
-{
-	char cmd[32];
-
-	if (count >= sizeof(cmd))
-		return -EINVAL;
-	if (copy_from_user(cmd, buf, count))
-		return -EFAULT;
-	cmd[count] = 0;
-
-	if ((count > 1) && (cmd[count-1] == '\n'))
-		cmd[count-1] = 0;
-
-	q6audio_set_route(cmd);
-
-	return count;
-}
-
-static int q6_release(struct inode *inode, struct file *file)
-{
-	return 0;
-}
-
-static const struct file_operations q6_fops = {
-	.owner		= THIS_MODULE,
-	.open		= q6_open,
-	.write		= q6_write,
-	.release	= q6_release,
-};
-
-static struct miscdevice q6_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_audio_route",
-	.fops	= &q6_fops,
-};
-
-
-static int __init q6_init(void)
-{
-	return misc_register(&q6_misc);
-}
-
-device_initcall(q6_init);
diff --git a/arch/arm/mach-msm/qdsp6/audiov2/voice.c b/arch/arm/mach-msm/qdsp6/audiov2/voice.c
deleted file mode 100644
index ccb2bad..0000000
--- a/arch/arm/mach-msm/qdsp6/audiov2/voice.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/* Copyright (c) 2010, The Linux Foundation. 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.
- *
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/fs.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/kthread.h>
-#include <linux/completion.h>
-#include <linux/wait.h>
-#include <mach/msm_qdsp6_audiov2.h>
-#include "../dal.h"
-#include "dal_voice.h"
-#include <mach/debug_mm.h>
-
-struct voice_struct {
-	struct dal_client *cvd;
-	struct apr_command_pkt apr_pkt;
-	struct completion compl;
-};
-
-static struct voice_struct voice;
-
-static int cvd_send_response(void)
-{
-	struct apr_command_pkt *pkt;
-	uint16_t src_addr;
-	uint16_t src_token;
-	uint16_t dst_token;
-	uint16_t dst_addr;
-
-	pkt = &voice.apr_pkt;
-	src_addr = pkt->dst_addr;
-	dst_addr = pkt->src_addr;
-	src_token = pkt->dst_token;
-	dst_token = pkt->src_token;
-
-	pkt->header &= ~APR_PKTV1_TYPE_MASK;
-	pkt->header |= APR_SET_FIELD(APR_PKTV1_TYPE, APR_PKTV1_TYPE_EVENT_V);
-	pkt->src_addr = src_addr;
-	pkt->dst_addr = dst_addr;
-	pkt->src_token = src_token;
-	pkt->dst_token = dst_token;
-	pkt->opcode = APR_IBASIC_RSP_RESULT;
-
-	dal_call(voice.cvd, VOICE_OP_CONTROL, 5, pkt,
-			sizeof(struct apr_command_pkt),
-			pkt, sizeof(u32));
-	return 0;
-}
-
-static int cvd_process_voice_setup(void)
-{
-	q6voice_setup();
-	cvd_send_response();
-	return 0;
-}
-
-static int cvd_process_voice_teardown(void)
-{
-	q6voice_teardown();
-	cvd_send_response();
-	return 0;
-}
-
-static int cvd_process_set_network(void)
-{
-	cvd_send_response();
-	return 0;
-}
-
-static int voice_thread(void *data)
-{
-	while (!kthread_should_stop()) {
-		wait_for_completion(&voice.compl);
-		init_completion(&voice.compl);
-
-		switch (voice.apr_pkt.opcode) {
-
-		case APR_OP_CMD_CREATE:
-			cvd_send_response();
-			break;
-		case VOICE_OP_CMD_BRINGUP:
-			cvd_process_voice_setup();
-			break;
-		case APR_OP_CMD_DESTROY:
-			cvd_send_response();
-			break;
-		case VOICE_OP_CMD_TEARDOWN:
-			cvd_process_voice_teardown();
-			break;
-		case VOICE_OP_CMD_SET_NETWORK:
-			cvd_process_set_network();
-			break;
-		default:
-			pr_err("[%s:%s] Undefined event\n", __MM_FILE__,
-					__func__);
-
-		}
-	}
-	return 0;
-}
-
-static void remote_cb_function(void *data, int len, void *cookie)
-{
-	struct apr_command_pkt *apr = data + 2*sizeof(uint32_t);
-
-	memcpy(&voice.apr_pkt, apr, sizeof(struct apr_command_pkt));
-
-	if (len <= 0) {
-		pr_err("[%s:%s] unexpected event with length %d\n",
-				__MM_FILE__, __func__, len);
-		return;
-	}
-
-	pr_debug("[%s:%s] APR = %x,%x,%x,%x,%x,%x,%x,%x,%x,%x\n", __MM_FILE__,
-			__func__,
-	apr->header,
-	apr->reserved1,
-	apr->src_addr,
-	apr->dst_addr,
-	apr->ret_addr,
-	apr->src_token,
-	apr->dst_token,
-	apr->ret_token,
-	apr->context,
-	apr->opcode);
-
-	complete(&voice.compl);
-}
-
-static int __init voice_init(void)
-{
-	int res = 0;
-	struct task_struct *task;
-	u32 tmp[2];
-
-	tmp[0] = sizeof(u32);
-	tmp[1] = 0;
-
-	voice.cvd = dal_attach(VOICE_DAL_DEVICE, VOICE_DAL_PORT, 0,
-			remote_cb_function, 0);
-
-	if (!voice.cvd) {
-		pr_err("[%s:%s] audio_init: cannot attach to cvd\n",
-				__MM_FILE__, __func__);
-		res = -ENODEV;
-		goto done;
-	}
-
-	if (check_version(voice.cvd, VOICE_DAL_VERSION) != 0) {
-		pr_err("[%s:%s] Incompatible cvd version\n",
-				__MM_FILE__, __func__);
-		res = -ENODEV;
-		goto done;
-	}
-	dal_call(voice.cvd, VOICE_OP_INIT, 5, tmp, sizeof(tmp),
-		tmp, sizeof(u32));
-
-	init_completion(&voice.compl);
-	task = kthread_run(voice_thread, &voice, "voice_thread");
-
-	if (IS_ERR(task)) {
-		pr_err("[%s:%s] Cannot start the voice thread\n", __MM_FILE__,
-				__func__);
-		res = PTR_ERR(task);
-		task = NULL;
-	} else
-		goto done;
-
-done:
-	return res;
-}
-
-late_initcall(voice_init);
diff --git a/arch/arm/mach-msm/qdsp6/auxpcm_lb_in.c b/arch/arm/mach-msm/qdsp6/auxpcm_lb_in.c
deleted file mode 100644
index ff254a6..0000000
--- a/arch/arm/mach-msm/qdsp6/auxpcm_lb_in.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/* arch/arm/mach-msm/qdsp6/auxpcm_lb_in.c
- *
- * Copyright (C) 2009 Google, Inc.
- * Copyright (C) 2009 HTC Corporation
- * Copyright (c) 2010, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/slab.h>
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/uaccess.h>
-
-#include <linux/msm_audio.h>
-
-#include <mach/msm_qdsp6_audio.h>
-#include <mach/debug_mm.h>
-
-struct auxpcm {
-	struct mutex lock;
-	struct audio_client *ac;
-	uint32_t sample_rate;
-	uint32_t channel_count;
-	int opened;;
-};
-
-static long auxpcmin_ioctl(struct file *file, unsigned int cmd,
-		unsigned long arg)
-{
-	struct auxpcm *auxpcmin = file->private_data;
-	int rc = 0;
-
-	mutex_lock(&auxpcmin->lock);
-	switch (cmd) {
-	case AUDIO_START: {
-		uint32_t acdb_id;
-		pr_debug("[%s:%s] AUDIO_START\n", __MM_FILE__, __func__);
-		if (arg == 0) {
-			acdb_id = 0;
-		} else if (copy_from_user(&acdb_id, (void *) arg,
-					sizeof(acdb_id))) {
-			pr_info("[%s:%s] copy acdb_id from user failed\n",
-					__MM_FILE__, __func__);
-			rc = -EFAULT;
-			break;
-		}
-		if (auxpcmin->ac) {
-			pr_err("[%s:%s] active session already existing\n",
-				__MM_FILE__, __func__);
-			rc = -EBUSY;
-		} else {
-			auxpcmin->ac =
-				q6audio_open_auxpcm(auxpcmin->sample_rate,
-						auxpcmin->channel_count,
-						AUDIO_FLAG_READ, acdb_id);
-			if (!auxpcmin->ac) {
-				pr_err("[%s:%s] auxpcm open session failed\n",
-					__MM_FILE__, __func__);
-				rc = -ENOMEM;
-			}
-		}
-		break;
-	}
-	case AUDIO_STOP:
-		pr_debug("[%s:%s] AUDIO_STOP\n", __MM_FILE__, __func__);
-		break;
-	case AUDIO_FLUSH:
-		break;
-	case AUDIO_SET_CONFIG: {
-		struct msm_audio_config config;
-		if (auxpcmin->ac) {
-			rc = -EBUSY;
-			pr_err("[%s:%s] active session already existing\n",
-				__MM_FILE__, __func__);
-			break;
-		}
-		if (copy_from_user(&config, (void *) arg, sizeof(config))) {
-			rc = -EFAULT;
-			break;
-		}
-		pr_debug("[%s:%s] SET_CONFIG: samplerate = %d, channels = %d\n",
-			__MM_FILE__, __func__, config.sample_rate,
-			config.channel_count);
-		if (config.channel_count != 1) {
-			rc = -EINVAL;
-			pr_err("[%s:%s] invalid channelcount %d\n",
-				__MM_FILE__, __func__, config.channel_count);
-			break;
-		}
-		if (config.sample_rate != 8000) {
-			rc = -EINVAL;
-			pr_err("[%s:%s] invalid samplerate %d\n", __MM_FILE__,
-				__func__, config.sample_rate);
-			break;
-		}
-		auxpcmin->sample_rate = config.sample_rate;
-		auxpcmin->channel_count = config.channel_count;
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config config;
-		config.buffer_size = 0;
-		config.buffer_count = 0;
-		config.sample_rate = auxpcmin->sample_rate;
-		config.channel_count = auxpcmin->channel_count;
-		config.unused[0] = 0;
-		config.unused[1] = 0;
-		config.unused[2] = 0;
-		if (copy_to_user((void *) arg, &config, sizeof(config)))
-			rc = -EFAULT;
-		pr_debug("[%s:%s] GET_CONFIG: samplerate = %d, channels = %d\n",
-			__MM_FILE__, __func__, config.sample_rate,
-			config.channel_count);
-		break;
-	}
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&auxpcmin->lock);
-	pr_debug("[%s:%s] rc = %d\n", __MM_FILE__, __func__, rc);
-	return rc;
-}
-
-static struct auxpcm the_auxpcmin;
-
-static int auxpcmin_open(struct inode *inode, struct file *file)
-{
-	struct auxpcm *auxpcmin = &the_auxpcmin;
-
-	pr_info("[%s:%s] open\n", __MM_FILE__, __func__);
-	mutex_lock(&auxpcmin->lock);
-	if (auxpcmin->opened) {
-		pr_err("aux pcm loopback tx already open!\n");
-		mutex_unlock(&auxpcmin->lock);
-		return -EBUSY;
-	}
-	auxpcmin->channel_count = 1;
-	auxpcmin->sample_rate = 8000;
-	auxpcmin->opened = 1;
-	file->private_data = auxpcmin;
-	mutex_unlock(&auxpcmin->lock);
-	return 0;
-}
-
-static int auxpcmin_release(struct inode *inode, struct file *file)
-{
-	struct auxpcm *auxpcmin = file->private_data;
-	mutex_lock(&auxpcmin->lock);
-	if (auxpcmin->ac)
-		q6audio_auxpcm_close(auxpcmin->ac);
-	auxpcmin->ac = NULL;
-	auxpcmin->opened = 0;
-	mutex_unlock(&auxpcmin->lock);
-	pr_info("[%s:%s] release\n", __MM_FILE__, __func__);
-	return 0;
-}
-
-static const struct file_operations auxpcmin_fops = {
-	.owner		= THIS_MODULE,
-	.open		= auxpcmin_open,
-	.release	= auxpcmin_release,
-	.unlocked_ioctl	= auxpcmin_ioctl,
-};
-
-struct miscdevice auxpcmin_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_aux_pcm_lb_in",
-	.fops	= &auxpcmin_fops,
-};
-
-static int __init auxpcmin_init(void)
-{
-	mutex_init(&the_auxpcmin.lock);
-	return misc_register(&auxpcmin_misc);
-}
-
-device_initcall(auxpcmin_init);
diff --git a/arch/arm/mach-msm/qdsp6/auxpcm_lb_out.c b/arch/arm/mach-msm/qdsp6/auxpcm_lb_out.c
deleted file mode 100644
index bba6b94..0000000
--- a/arch/arm/mach-msm/qdsp6/auxpcm_lb_out.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/* arch/arm/mach-msm/qdsp6/auxpcm_lb_out.c
- *
- * Copyright (C) 2009 Google, Inc.
- * Author: Brian Swetland <swetland@google.com>
- * Copyright (c) 2010, The Linux Foundation. All rights reserved.
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/slab.h>
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/uaccess.h>
-
-#include <linux/msm_audio.h>
-
-#include <mach/msm_qdsp6_audio.h>
-#include <mach/debug_mm.h>
-
-struct auxpcm {
-	struct mutex lock;
-	struct audio_client *ac;
-	uint32_t sample_rate;
-	uint32_t channel_count;
-	int opened;;
-};
-
-static long auxpcmout_ioctl(struct file *file, unsigned int cmd,
-				unsigned long arg)
-{
-	struct auxpcm *auxpcmout = file->private_data;
-	int rc = 0;
-
-	mutex_lock(&auxpcmout->lock);
-	switch (cmd) {
-	case AUDIO_START: {
-		uint32_t acdb_id;
-		pr_debug("[%s:%s] AUDIO_START\n", __MM_FILE__, __func__);
-		if (arg == 0) {
-			acdb_id = 0;
-		} else if (copy_from_user(&acdb_id, (void *) arg,
-					sizeof(acdb_id))) {
-			pr_info("[%s:%s] copy acdb_id from user failed\n",
-					__MM_FILE__, __func__);
-			rc = -EFAULT;
-			break;
-		}
-		if (auxpcmout->ac) {
-			rc = -EBUSY;
-			pr_err("[%s:%s] active session already existing\n",
-				__MM_FILE__, __func__);
-		} else {
-			auxpcmout->ac =
-				q6audio_open_auxpcm(auxpcmout->sample_rate,
-						auxpcmout->channel_count,
-						AUDIO_FLAG_WRITE, acdb_id);
-			if (!auxpcmout->ac) {
-				pr_err("[%s:%s] auxpcm open session failed\n",
-					__MM_FILE__, __func__);
-				rc = -ENOMEM;
-			}
-		}
-		break;
-	}
-	case AUDIO_STOP:
-		pr_debug("[%s:%s] AUDIO_STOP\n", __MM_FILE__, __func__);
-		break;
-	case AUDIO_FLUSH:
-		break;
-	case AUDIO_SET_CONFIG: {
-		struct msm_audio_config config;
-		if (auxpcmout->ac) {
-			rc = -EBUSY;
-			pr_err("[%s:%s] active session already existing\n",
-				__MM_FILE__, __func__);
-			break;
-		}
-		if (copy_from_user(&config, (void *) arg, sizeof(config))) {
-			rc = -EFAULT;
-			break;
-		}
-		pr_debug("[%s:%s] SET_CONFIG: samplerate = %d, channels = %d\n",
-			__MM_FILE__, __func__, config.sample_rate,
-			config.channel_count);
-		if (config.channel_count != 1) {
-			rc = -EINVAL;
-			pr_err("[%s:%s] invalid channelcount %d\n",
-			__MM_FILE__, __func__, config.channel_count);
-			break;
-		}
-		if (config.sample_rate != 8000) {
-			rc = -EINVAL;
-			pr_err("[%s:%s] invalid samplerate %d\n", __MM_FILE__,
-				__func__, config.sample_rate);
-			break;
-		}
-		auxpcmout->sample_rate = config.sample_rate;
-		auxpcmout->channel_count = config.channel_count;
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config config;
-		config.buffer_size = 0;
-		config.buffer_count = 0;
-		config.sample_rate = auxpcmout->sample_rate;
-		config.channel_count = auxpcmout->channel_count;
-		config.unused[0] = 0;
-		config.unused[1] = 0;
-		config.unused[2] = 0;
-		if (copy_to_user((void *) arg, &config, sizeof(config)))
-			rc = -EFAULT;
-		pr_debug("[%s:%s] GET_CONFIG: samplerate = %d, channels= %d\n",
-			__MM_FILE__, __func__, config.sample_rate,
-			config.channel_count);
-		break;
-	}
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&auxpcmout->lock);
-	pr_debug("[%s:%s] rc = %d\n", __MM_FILE__, __func__, rc);
-	return rc;
-}
-
-static struct auxpcm the_auxpcmout;
-
-static int auxpcmout_open(struct inode *inode, struct file *file)
-{
-	struct auxpcm *auxpcmout = &the_auxpcmout;
-
-	pr_info("[%s:%s] open\n", __MM_FILE__, __func__);
-
-	mutex_lock(&auxpcmout->lock);
-
-	if (auxpcmout->opened) {
-		pr_err("aux pcm loopback rx already open!\n");
-		mutex_unlock(&auxpcmout->lock);
-		return -EBUSY;
-	}
-	auxpcmout->channel_count = 1;
-	auxpcmout->sample_rate = 8000;
-	auxpcmout->opened = 1;
-	file->private_data = auxpcmout;
-	mutex_unlock(&auxpcmout->lock);
-	return 0;
-}
-
-static int auxpcmout_release(struct inode *inode, struct file *file)
-{
-	struct auxpcm *auxpcmout = file->private_data;
-	mutex_lock(&auxpcmout->lock);
-	if (auxpcmout->ac)
-		q6audio_auxpcm_close(auxpcmout->ac);
-	auxpcmout->ac = NULL;
-	auxpcmout->opened = 0;
-	mutex_unlock(&auxpcmout->lock);
-	pr_info("[%s:%s] release\n", __MM_FILE__, __func__);
-	return 0;
-}
-
-static const struct file_operations auxpcmout_fops = {
-	.owner		= THIS_MODULE,
-	.open		= auxpcmout_open,
-	.release	= auxpcmout_release,
-	.unlocked_ioctl	= auxpcmout_ioctl,
-};
-
-struct miscdevice auxpcmout_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_aux_pcm_lb_out",
-	.fops	= &auxpcmout_fops,
-};
-
-static int __init auxpcmout_init(void)
-{
-	mutex_init(&the_auxpcmout.lock);
-	return misc_register(&auxpcmout_misc);
-}
-
-device_initcall(auxpcmout_init);
diff --git a/arch/arm/mach-msm/qdsp6/dal.c b/arch/arm/mach-msm/qdsp6/dal.c
deleted file mode 100644
index 378432b..0000000
--- a/arch/arm/mach-msm/qdsp6/dal.c
+++ /dev/null
@@ -1,727 +0,0 @@
-/* arch/arm/mach-msm/qdsp6/dal.c
- *
- * Copyright (C) 2009 Google, Inc.
- * Author: Brian Swetland <swetland@google.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/slab.h>
-#include <linux/kernel.h>
-#include <linux/spinlock.h>
-#include <linux/mutex.h>
-#include <linux/list.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/errno.h>
-
-#include <linux/delay.h>
-
-#include <mach/msm_smd.h>
-#include <mach/debug_mm.h>
-#include <mach/msm_qdsp6_audio.h>
-
-#include "dal.h"
-
-#define DAL_TRACE 0
-
-struct dal_hdr {
-	uint32_t length:16;	/* message length (header inclusive) */
-	uint32_t version:8;	/* DAL protocol version */
-	uint32_t priority:7;
-	uint32_t async:1;
-	uint32_t ddi:16;	/* DDI method number */
-	uint32_t prototype:8;	/* DDI serialization format */
-	uint32_t msgid:8;	/* message id (DDI, ATTACH, DETACH, ...) */
-	void *from;
-	void *to;
-} __attribute__((packed));
-
-#define TRACE_DATA_MAX	128
-#define TRACE_LOG_MAX	32
-#define TRACE_LOG_MASK	(TRACE_LOG_MAX - 1)
-
-struct dal_trace {
-	unsigned timestamp;
-	struct dal_hdr hdr;
-	uint32_t data[TRACE_DATA_MAX];
-};
-
-#define DAL_HDR_SIZE		(sizeof(struct dal_hdr))
-#define DAL_DATA_MAX		512
-#define DAL_MSG_MAX		(DAL_HDR_SIZE + DAL_DATA_MAX)
-
-#define DAL_VERSION		0x11
-
-#define DAL_MSGID_DDI		0x00
-#define DAL_MSGID_ATTACH	0x01
-#define DAL_MSGID_DETACH	0x02
-#define DAL_MSGID_ASYNCH	0xC0
-#define DAL_MSGID_REPLY		0x80
-
-struct dal_channel {
-	struct list_head list;
-	struct list_head clients;
-
-	/* synchronization for changing channel state,
-	 * adding/removing clients, smd callbacks, etc
-	 */
-	spinlock_t lock;
-
-	struct smd_channel *sch;
-	char *name;
-
-	/* events are delivered at IRQ context immediately, so
-	 * we only need one assembly buffer for the entire channel
-	 */
-	struct dal_hdr hdr;
-	unsigned char data[DAL_DATA_MAX];
-
-	unsigned count;
-	void *ptr;
-
-	/* client which the current inbound message is for */
-	struct dal_client *active;
-};
-
-struct dal_client {
-	struct list_head list;
-	struct dal_channel *dch;
-	void *cookie;
-	dal_event_func_t event;
-
-	/* opaque handle for the far side */
-	void *remote;
-
-	/* dal rpc calls are fully synchronous -- only one call may be
-	 * active per client at a time
-	 */
-	struct mutex write_lock;
-	wait_queue_head_t wait;
-
-	unsigned char data[DAL_DATA_MAX];
-
-	void *reply;
-	int reply_max;
-	int status;
-	unsigned msgid; /* msgid of expected reply */
-
-	spinlock_t tr_lock;
-	unsigned tr_head;
-	unsigned tr_tail;
-	struct dal_trace *tr_log;
-};
-
-static unsigned now(void)
-{
-	struct timespec ts;
-	ktime_get_ts(&ts);
-	return (ts.tv_nsec / 1000000) + (ts.tv_sec * 1000);
-}
-
-void dal_trace(struct dal_client *c)
-{
-	if (c->tr_log)
-		return;
-	c->tr_log = kzalloc(sizeof(struct dal_trace) * TRACE_LOG_MAX,
-			    GFP_KERNEL);
-}
-
-void dal_trace_print(struct dal_hdr *hdr, unsigned *data, int len, unsigned when)
-{
-	int i;
-	printk("DAL %08x -> %08x L=%03x A=%d D=%04x P=%02x M=%02x T=%d",
-	       (unsigned) hdr->from, (unsigned) hdr->to,
-	       hdr->length, hdr->async,
-	       hdr->ddi, hdr->prototype, hdr->msgid,
-	       when);
-	len /= 4;
-	for (i = 0; i < len; i++) {
-		if (!(i & 7))
-			printk("\n%03x", i * 4);
-		printk(" %08x", data[i]);
-	}
-	printk("\n");
-}
-
-void dal_trace_dump(struct dal_client *c)
-{
-	struct dal_trace *dt;
-	unsigned n, len;
-
-	if (!c->tr_log)
-		return;
-
-	for (n = c->tr_tail; n != c->tr_head; n = (n + 1) & TRACE_LOG_MASK) {
-		dt = c->tr_log + n;
-		len = dt->hdr.length - sizeof(dt->hdr);
-		if (len > TRACE_DATA_MAX)
-			len = TRACE_DATA_MAX;
-		dal_trace_print(&dt->hdr, dt->data, len, dt->timestamp);
-	}
-}
-
-static void dal_trace_log(struct dal_client *c,
-			  struct dal_hdr *hdr, void *data, unsigned len)
-{
-	unsigned long flags;
-	unsigned t, n;
-	struct dal_trace *dt;
-
-	t = now();
-	if (len > TRACE_DATA_MAX)
-		len = TRACE_DATA_MAX;
-
-	spin_lock_irqsave(&c->tr_lock, flags);
-	n = (c->tr_head + 1) & TRACE_LOG_MASK;
-	if (c->tr_tail == n)
-		c->tr_tail = (c->tr_tail + 1) & TRACE_LOG_MASK;
-	dt = c->tr_log + n;
-	dt->timestamp = t;
-	memcpy(&dt->hdr, hdr, sizeof(struct dal_hdr));
-	memcpy(dt->data, data, len);
-	c->tr_head = n;
-
-	spin_unlock_irqrestore(&c->tr_lock, flags);
-}
-
-
-static void dal_channel_notify(void *priv, unsigned event)
-{
-	struct dal_channel *dch = priv;
-	struct dal_hdr *hdr = &dch->hdr;
-	struct dal_client *client;
-	unsigned long flags;
-	int len;
-	int r;
-
-	spin_lock_irqsave(&dch->lock, flags);
-
-again:
-	if (dch->count == 0) {
-		if (smd_read_avail(dch->sch) < DAL_HDR_SIZE)
-			goto done;
-
-		smd_read(dch->sch, hdr, DAL_HDR_SIZE);
-
-		if (hdr->length < DAL_HDR_SIZE)
-			goto done;
-
-		if (hdr->length > DAL_MSG_MAX)
-			panic("oversize message");
-
-		dch->count = hdr->length - DAL_HDR_SIZE;
-
-		/* locate the client this message is targeted to */
-		list_for_each_entry(client, &dch->clients, list) {
-			if (dch->hdr.to == client) {
-				dch->active = client;
-				dch->ptr = client->data;
-				goto check_data;
-			}
-		}
-		pr_err("[%s:%s] $$$ receiving unknown message len = %d $$$\n",
-				__MM_FILE__, __func__, dch->count);
-		dch->active = 0;
-		dch->ptr = dch->data;
-	}
-
-check_data:
-	len = dch->count;
-	if (len > 0) {
-		if (smd_read_avail(dch->sch) < len)
-			goto done;
-
-		r = smd_read(dch->sch, dch->ptr, len);
-		if (r != len)
-			panic("invalid read");
-
-#if DAL_TRACE
-		pr_info("[%s:%s] dal recv %p <- %p %02x:%04x:%02x %d\n",
-			__MM_FILE__, __func__, hdr->to, hdr->from, hdr->msgid,
-			hdr->ddi, hdr->prototype, hdr->length - sizeof(*hdr));
-		print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, dch->ptr, len);
-#endif
-		dch->count = 0;
-
-		client = dch->active;
-		if (!client) {
-			pr_err("[%s:%s] message to %p discarded\n",
-				__MM_FILE__, __func__, dch->hdr.to);
-			goto again;
-		}
-
-		if (client->tr_log)
-			dal_trace_log(client, hdr, dch->ptr, len);
-
-		if (hdr->msgid == DAL_MSGID_ASYNCH) {
-			if (client->event)
-				client->event(dch->ptr, len, client->cookie);
-			else
-				pr_err("[%s:%s] client %p has no event \
-					handler\n", __MM_FILE__, __func__,
-					client);
-			goto again;
-		}
-
-		if (hdr->msgid == client->msgid) {
-			if (!client->remote)
-				client->remote = hdr->from;
-			if (len > client->reply_max)
-				len = client->reply_max;
-			memcpy(client->reply, client->data, len);
-			client->status = len;
-			wake_up(&client->wait);
-			goto again;
-		}
-
-		pr_err("[%s:%s] cannot find client %p\n", __MM_FILE__,
-				__func__, dch->hdr.to);
-		goto again;
-	}
-
-done:
-	spin_unlock_irqrestore(&dch->lock, flags);
-}
-
-static LIST_HEAD(dal_channel_list);
-static DEFINE_MUTEX(dal_channel_list_lock);
-
-static struct dal_channel *dal_open_channel(const char *name, uint32_t cpu)
-{
-	struct dal_channel *dch;
-
-	pr_debug("[%s:%s]\n", __MM_FILE__, __func__);
-	mutex_lock(&dal_channel_list_lock);
-
-	list_for_each_entry(dch, &dal_channel_list, list) {
-		if (!strcmp(dch->name, name))
-			goto found_it;
-	}
-
-	dch = kzalloc(sizeof(*dch) + strlen(name) + 1, GFP_KERNEL);
-	if (!dch)
-		goto fail;
-
-	dch->name = (char *) (dch + 1);
-	strcpy(dch->name, name);
-	spin_lock_init(&dch->lock);
-	INIT_LIST_HEAD(&dch->clients);
-
-	list_add(&dch->list, &dal_channel_list);
-
-found_it:
-	if (!dch->sch) {
-		if (smd_named_open_on_edge(name, cpu, &dch->sch,
-					dch, dal_channel_notify)) {
-			pr_err("[%s:%s] smd open failed\n", __MM_FILE__,
-					__func__);
-			dch = NULL;
-		}
-		/* FIXME: wait for channel to open before returning */
-		msleep(100);
-	}
-
-fail:
-	mutex_unlock(&dal_channel_list_lock);
-
-	return dch;
-}
-
-int dal_call_raw(struct dal_client *client,
-		 struct dal_hdr *hdr,
-		 void *data, int data_len,
-		 void *reply, int reply_max)
-{
-	struct dal_channel *dch = client->dch;
-	unsigned long flags;
-
-	client->reply = reply;
-	client->reply_max = reply_max;
-	client->msgid = hdr->msgid | DAL_MSGID_REPLY;
-	client->status = -EBUSY;
-
-#if DAL_TRACE
-	pr_info("[%s:%s:%x] dal send %p -> %p %02x:%04x:%02x %d\n",
-		__MM_FILE__, __func__, (unsigned int)client, hdr->from, hdr->to,
-		hdr->msgid, hdr->ddi, hdr->prototype,
-		hdr->length - sizeof(*hdr));
-	print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, data, data_len);
-#endif
-
-	if (client->tr_log)
-		dal_trace_log(client, hdr, data, data_len);
-
-	spin_lock_irqsave(&dch->lock, flags);
-	/* FIXME: ensure entire message is written or none. */
-	smd_write(dch->sch, hdr, sizeof(*hdr));
-	smd_write(dch->sch, data, data_len);
-	spin_unlock_irqrestore(&dch->lock, flags);
-
-	if (!wait_event_timeout(client->wait, (client->status != -EBUSY), 5*HZ)) {
-		dal_trace_dump(client);
-		pr_err("[%s:%s] call timed out. dsp is probably dead.\n",
-				__MM_FILE__, __func__);
-		dal_trace_print(hdr, data, data_len, 0);
-		q6audio_dsp_not_responding();
-	}
-
-	return client->status;
-}
-
-int dal_call(struct dal_client *client,
-	     unsigned ddi, unsigned prototype,
-	     void *data, int data_len,
-	     void *reply, int reply_max)
-{
-	struct dal_hdr hdr;
-	int r;
-
-	memset(&hdr, 0, sizeof(hdr));
-
-	hdr.length = data_len + sizeof(hdr);
-	hdr.version = DAL_VERSION;
-	hdr.msgid = DAL_MSGID_DDI;
-	hdr.ddi = ddi;
-	hdr.prototype = prototype;
-	hdr.from = client;
-	hdr.to = client->remote;
-
-	if (hdr.length > DAL_MSG_MAX)
-		return -EINVAL;
-
-	mutex_lock(&client->write_lock);
-	r = dal_call_raw(client, &hdr, data, data_len, reply, reply_max);
-	mutex_unlock(&client->write_lock);
-
-	return r;
-}
-
-struct dal_msg_attach {
-	uint32_t device_id;
-	char attach[64];
-	char service_name[32];
-} __attribute__((packed));
-
-struct dal_reply_attach {
-	uint32_t status;
-	char name[64];
-};
-
-struct dal_client *dal_attach(uint32_t device_id, const char *name,
-			      uint32_t cpu, dal_event_func_t func, void *cookie)
-{
-	struct dal_hdr hdr;
-	struct dal_msg_attach msg;
-	struct dal_reply_attach reply;
-	struct dal_channel *dch;
-	struct dal_client *client;
-	unsigned long flags;
-	int r;
-
-	pr_debug("[%s:%s]\n", __MM_FILE__, __func__);
-	dch = dal_open_channel(name, cpu);
-	if (!dch)
-		return 0;
-
-	client = kzalloc(sizeof(*client), GFP_KERNEL);
-	if (!client)
-		return 0;
-
-	client->dch = dch;
-	client->event = func;
-	client->cookie = cookie;
-	mutex_init(&client->write_lock);
-	spin_lock_init(&client->tr_lock);
-	init_waitqueue_head(&client->wait);
-
-	spin_lock_irqsave(&dch->lock, flags);
-	list_add(&client->list, &dch->clients);
-	spin_unlock_irqrestore(&dch->lock, flags);
-
-	memset(&hdr, 0, sizeof(hdr));
-	memset(&msg, 0, sizeof(msg));
-
-	hdr.length = sizeof(hdr) + sizeof(msg);
-	hdr.version = DAL_VERSION;
-	hdr.msgid = DAL_MSGID_ATTACH;
-	hdr.from = client;
-	msg.device_id = device_id;
-
-	r = dal_call_raw(client, &hdr, &msg, sizeof(msg),
-			 &reply, sizeof(reply));
-
-	if ((r == sizeof(reply)) && (reply.status == 0)) {
-		reply.name[63] = 0;
-		pr_info("[%s:%s] status = %d, name = '%s' dal_client %x\n",
-			__MM_FILE__, __func__, reply.status,
-			reply.name, (unsigned int)client);
-		return client;
-	}
-
-	pr_err("[%s:%s] failure\n", __MM_FILE__, __func__);
-
-	dal_detach(client);
-	return 0;
-}
-
-int dal_detach(struct dal_client *client)
-{
-	struct dal_channel *dch;
-	unsigned long flags;
-
-	pr_debug("[%s:%s]\n", __MM_FILE__, __func__);
-	mutex_lock(&client->write_lock);
-	if (client->remote) {
-		struct dal_hdr hdr;
-		uint32_t data;
-
-		memset(&hdr, 0, sizeof(hdr));
-		hdr.length = sizeof(hdr) + sizeof(data);
-		hdr.version = DAL_VERSION;
-		hdr.msgid = DAL_MSGID_DETACH;
-		hdr.from = client;
-		hdr.to = client->remote;
-		data = (uint32_t) client;
-
-		dal_call_raw(client, &hdr, &data, sizeof(data),
-			     &data, sizeof(data));
-	}
-
-	dch = client->dch;
-	spin_lock_irqsave(&dch->lock, flags);
-	if (dch->active == client) {
-		/* We have received a message header for this client
-		 * but not the body of the message.  Ensure that when
-		 * the body arrives we don't write it into the now-closed
-		 * client.  In *theory* this should never happen.
-		 */
-		dch->active = 0;
-		dch->ptr = dch->data;
-	}
-	list_del(&client->list);
-	spin_unlock_irqrestore(&dch->lock, flags);
-
-	mutex_unlock(&client->write_lock);
-
-	kfree(client);
-	return 0;
-}
-
-void *dal_get_remote_handle(struct dal_client *client)
-{
-	return client->remote;
-}
-
-/* convenience wrappers */
-
-int dal_call_f0(struct dal_client *client, uint32_t ddi, uint32_t arg1)
-{
-	uint32_t tmp = arg1;
-	int res;
-	res = dal_call(client, ddi, 0, &tmp, sizeof(tmp), &tmp, sizeof(tmp));
-	if (res >= 4)
-		return (int) tmp;
-	return res;
-}
-
-int dal_call_f1(struct dal_client *client, uint32_t ddi, uint32_t arg1,
-		uint32_t arg2)
-{
-	uint32_t tmp[2];
-	int res;
-	tmp[0] = arg1;
-	tmp[1] = arg2;
-	res = dal_call(client, ddi, 1, tmp, sizeof(tmp), tmp, sizeof(uint32_t));
-	if (res >= 4)
-		return (int) tmp[0];
-	return res;
-}
-
-int dal_call_f5(struct dal_client *client, uint32_t ddi, void *ibuf, uint32_t ilen)
-{
-	uint32_t tmp[128];
-	int res;
-	int param_idx = 0;
-
-	if (ilen + 4 > DAL_DATA_MAX)
-		return -EINVAL;
-
-	tmp[param_idx] = ilen;
-	param_idx++;
-
-	memcpy(&tmp[param_idx], ibuf, ilen);
-	param_idx += DIV_ROUND_UP(ilen, 4);
-
-	res = dal_call(client, ddi, 5, tmp, param_idx * 4, tmp, sizeof(tmp));
-
-	if (res >= 4)
-		return (int) tmp[0];
-	return res;
-}
-
-int dal_call_f6(struct dal_client *client, uint32_t ddi, uint32_t s1,
-		void *ibuf, uint32_t ilen)
-{
-	uint32_t tmp[128];
-	int res;
-	int param_idx = 0;
-
-	if (ilen + 8 > DAL_DATA_MAX)
-		return -EINVAL;
-
-	tmp[param_idx] = s1;
-	param_idx++;
-	tmp[param_idx] = ilen;
-	param_idx++;
-	memcpy(&tmp[param_idx], ibuf, ilen);
-	param_idx += DIV_ROUND_UP(ilen, 4);
-
-	res = dal_call(client, ddi, 6, tmp, param_idx * 4, tmp, sizeof(tmp));
-
-	if (res >= 4)
-		return (int) tmp[0];
-
-	return res;
-}
-
-int dal_call_f9(struct dal_client *client, uint32_t ddi, void *obuf,
-		uint32_t olen)
-{
-	uint32_t tmp[128];
-	int res;
-
-	if (olen > sizeof(tmp) - 8)
-		return -EINVAL;
-	tmp[0] = olen;
-
-	res = dal_call(client, ddi, 9, tmp, sizeof(uint32_t), tmp,
-		sizeof(tmp));
-
-	if (res >= 4)
-		res = (int)tmp[0];
-
-	if (!res) {
-		if (tmp[1] > olen)
-			return -EIO;
-		memcpy(obuf, &tmp[2], tmp[1]);
-	}
-	return res;
-}
-
-int dal_call_f11(struct dal_client *client, uint32_t ddi, uint32_t s1,
-		void *obuf, uint32_t olen)
-{
-	uint32_t tmp[DAL_DATA_MAX/4] = {0};
-	int res;
-	int param_idx = 0;
-	int num_bytes = 4;
-
-	num_bytes += (DIV_ROUND_UP(olen, 4)) * 4;
-
-	if ((num_bytes > DAL_DATA_MAX - 12) || (olen > DAL_DATA_MAX - 8))
-		return -EINVAL;
-
-	tmp[param_idx] = s1;
-	param_idx++;
-	tmp[param_idx] = olen;
-	param_idx += DIV_ROUND_UP(olen, 4);
-
-	res = dal_call(client, ddi, 11, tmp, param_idx * 4, tmp, sizeof(tmp));
-
-	if (res >= 4)
-		res = (int) tmp[0];
-	if (!res) {
-		if (tmp[1] > olen)
-			return -EIO;
-		memcpy(obuf, &tmp[2], tmp[1]);
-	}
-	return res;
-}
-
-int dal_call_f13(struct dal_client *client, uint32_t ddi, void *ibuf1,
-		 uint32_t ilen1, void *ibuf2, uint32_t ilen2, void *obuf,
-		 uint32_t olen)
-{
-	uint32_t tmp[DAL_DATA_MAX/4];
-	int res;
-	int param_idx = 0;
-	int num_bytes = 0;
-
-	num_bytes = (DIV_ROUND_UP(ilen1, 4)) * 4;
-	num_bytes += (DIV_ROUND_UP(ilen2, 4)) * 4;
-
-	if ((num_bytes > DAL_DATA_MAX - 12) || (olen > DAL_DATA_MAX - 8) ||
-			(ilen1 > DAL_DATA_MAX) || (ilen2 > DAL_DATA_MAX))
-		return -EINVAL;
-
-	tmp[param_idx] = ilen1;
-	param_idx++;
-
-	memcpy(&tmp[param_idx], ibuf1, ilen1);
-	param_idx += DIV_ROUND_UP(ilen1, 4);
-
-	tmp[param_idx++] = ilen2;
-	memcpy(&tmp[param_idx], ibuf2, ilen2);
-	param_idx += DIV_ROUND_UP(ilen2, 4);
-
-	tmp[param_idx++] = olen;
-	res = dal_call(client, ddi, 13, tmp, param_idx * 4, tmp,
-			sizeof(tmp));
-
-	if (res >= 4)
-		res = (int)tmp[0];
-
-	if (!res) {
-		if (tmp[1] > olen)
-			return -EIO;
-		memcpy(obuf, &tmp[2], tmp[1]);
-	}
-	return res;
-}
-int dal_call_f14(struct dal_client *client, uint32_t ddi, void *ibuf,
-		 uint32_t ilen, void *obuf1, uint32_t olen1, void *obuf2,
-		 uint32_t olen2, uint32_t *oalen2)
-{
-	uint32_t tmp[128];
-	int res;
-	int param_idx = 0;
-
-	if (olen1 + olen2 + 8 > DAL_DATA_MAX ||
-		ilen + 12 > DAL_DATA_MAX)
-		return -EINVAL;
-
-	tmp[param_idx] = ilen;
-	param_idx++;
-
-	memcpy(&tmp[param_idx], ibuf, ilen);
-	param_idx += DIV_ROUND_UP(ilen, 4);
-
-	tmp[param_idx++] = olen1;
-	tmp[param_idx++] = olen2;
-	res = dal_call(client, ddi, 14, tmp, param_idx * 4, tmp, sizeof(tmp));
-
-	if (res >= 4)
-		res = (int)tmp[0];
-
-	if (!res) {
-		if (tmp[1] > olen1)
-			return -EIO;
-		param_idx = DIV_ROUND_UP(tmp[1], 4) + 2;
-		if (tmp[param_idx] > olen2)
-			return -EIO;
-
-		memcpy(obuf1, &tmp[2], tmp[1]);
-		memcpy(obuf2, &tmp[param_idx+1], tmp[param_idx]);
-		*oalen2 = tmp[param_idx];
-	}
-	return res;
-}
diff --git a/arch/arm/mach-msm/qdsp6/dal.h b/arch/arm/mach-msm/qdsp6/dal.h
deleted file mode 100644
index 1176eb9..0000000
--- a/arch/arm/mach-msm/qdsp6/dal.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* arch/arm/mach-msm/qdsp6/dal.h
- *
- * Copyright (C) 2009 Google, Inc.
- * Author: Brian Swetland <swetland@google.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#ifndef _MACH_MSM_DAL_
-#define _MACH_MSM_DAL_
-
-struct dal_client;
-
-struct dal_info {
-	uint32_t size;
-	uint32_t version;
-	char name[32];
-};
-
-typedef void (*dal_event_func_t)(void *data, int len, void *cookie);
-
-struct dal_client *dal_attach(uint32_t device_id, const char *name,
-			uint32_t cpu, dal_event_func_t func, void *cookie);
-
-int dal_detach(struct dal_client *client);
-
-int dal_call(struct dal_client *client,
-	     unsigned ddi, unsigned prototype,
-	     void *data, int data_len,
-	     void *reply, int reply_max);
-
-void dal_trace(struct dal_client *client);
-void dal_trace_dump(struct dal_client *client);
-
-/* function to call before panic on stalled dal calls */
-void dal_set_oops(struct dal_client *client, void (*oops)(void));
-
-/* convenience wrappers */
-int dal_call_f0(struct dal_client *client, uint32_t ddi,
-		uint32_t arg1);
-int dal_call_f1(struct dal_client *client, uint32_t ddi,
-		uint32_t arg1, uint32_t arg2);
-int dal_call_f5(struct dal_client *client, uint32_t ddi,
-		void *ibuf, uint32_t ilen);
-int dal_call_f6(struct dal_client *client, uint32_t ddi,
-		uint32_t s1, void *ibuf, uint32_t ilen);
-int dal_call_f9(struct dal_client *client, uint32_t ddi,
-		void *obuf, uint32_t olen);
-int dal_call_f11(struct dal_client *client, uint32_t ddi,
-		uint32_t s1, void *obuf, uint32_t olen);
-int dal_call_f13(struct dal_client *client, uint32_t ddi, void *ibuf1,
-		 uint32_t ilen1, void *ibuf2, uint32_t ilen2, void *obuf,
-		 uint32_t olen);
-int dal_call_f14(struct dal_client *client, uint32_t ddi, void *ibuf,
-		 uint32_t ilen, void *obuf1, uint32_t olen1, void *obuf2,
-		 uint32_t olen2, uint32_t *oalen2);
-
-/* common DAL operations */
-enum {
-	DAL_OP_ATTACH = 0,
-	DAL_OP_DETACH,
-	DAL_OP_INIT,
-	DAL_OP_DEINIT,
-	DAL_OP_OPEN,
-	DAL_OP_CLOSE,
-	DAL_OP_INFO,
-	DAL_OP_POWEREVENT,
-	DAL_OP_SYSREQUEST,
-	DAL_OP_FIRST_DEVICE_API,
-};
-
-static inline int check_version(struct dal_client *client, uint32_t version)
-{
-	struct dal_info info;
-	int res;
-
-	res = dal_call_f9(client, DAL_OP_INFO, &info, sizeof(struct dal_info));
-	if (!res) {
-		if (((info.version & 0xFFFF0000) != (version & 0xFFFF0000)) ||
-		((info.version & 0x0000FFFF) <
-		(version & 0x0000FFFF))) {
-			res = -EINVAL;
-		}
-	}
-	return res;
-}
-
-#endif
diff --git a/arch/arm/mach-msm/qdsp6/dal_acdb.h b/arch/arm/mach-msm/qdsp6/dal_acdb.h
deleted file mode 100644
index 511879c..0000000
--- a/arch/arm/mach-msm/qdsp6/dal_acdb.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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 ACDB_DAL_DEVICE		0x02000069
-#define ACDB_DAL_PORT		"DAL_AM_AUD"
-
-#define ACDB_OP_IOCTL		DAL_OP_FIRST_DEVICE_API
-
-/* ioctls */
-#define ACDB_GET_DEVICE		0x0108bb92
-#define ACDB_SET_DEVICE		0x0108bb93
-#define ACDB_GET_STREAM		0x0108bb95
-#define ACDB_SET_STREAM		0x0108bb96
-#define ACDB_GET_DEVICE_TABLE	0x0108bb97
-#define ACDB_GET_STREAM_TABLE	0x0108bb98
-
-#define ACDB_RES_SUCCESS	0
-#define ACDB_RES_FAILURE	-1
-#define ACDB_RES_BADPARM	-2
-#define ACDB_RES_BADSTATE	-3
-
-struct acdb_cmd_device {
-	uint32_t size;
-
-	uint32_t command_id;
-	uint32_t device_id;
-	uint32_t network_id;
-	uint32_t sample_rate_id;
-	uint32_t interface_id;
-	uint32_t algorithm_block_id;
-
-	/* physical page aligned buffer */
-	uint32_t total_bytes;
-	uint32_t unmapped_buf;
-} __attribute__((packed));
-
-struct acdb_cmd_device_table {
-	uint32_t size;
-
-	uint32_t command_id;
-	uint32_t device_id;
-	uint32_t network_id;
-	uint32_t sample_rate_id;
-
-	/* physical page aligned buffer */
-	uint32_t total_bytes;
-	uint32_t unmapped_buf;
-
-	uint32_t res_size;
-} __attribute__((packed));
-
-struct acdb_result {
-	uint32_t dal_status;
-	uint32_t size;
-
-	uint32_t unmapped_buf;
-	uint32_t used_bytes;
-	uint32_t result;
-} __attribute__((packed));
diff --git a/arch/arm/mach-msm/qdsp6/dal_adie.h b/arch/arm/mach-msm/qdsp6/dal_adie.h
deleted file mode 100644
index 78db05f..0000000
--- a/arch/arm/mach-msm/qdsp6/dal_adie.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-
-#ifndef _MACH_MSM_QDSP6_ADIE_
-#define _MACH_MSM_QDSP6_ADIE_
-
-#include "dal.h"
-
-#define ADIE_DAL_DEVICE		0x02000029
-#define ADIE_DAL_PORT		"DAL_AM_AUD"
-
-enum {
-	ADIE_OP_GET_NUM_PATHS = DAL_OP_FIRST_DEVICE_API,
-	ADIE_OP_GET_ALL_PATH_IDS,
-	ADIE_OP_SET_PATH,
-	ADIE_OP_GET_NUM_PATH_FREQUENCY_PLANS,
-	ADIE_OP_GET_PATH_FREQUENCY_PLANS,
-	ADIE_OP_SET_PATH_FREQUENCY_PLAN,
-	ADIE_OP_PROCEED_TO_STAGE,
-	ADIE_OP_MUTE_PATH
-};
-
-/* Path IDs for normal operation. */
-#define ADIE_PATH_HANDSET_TX			0x010740f6
-#define ADIE_PATH_HANDSET_RX			0x010740f7
-#define ADIE_PATH_HEADSET_MONO_TX		0x010740f8
-#define ADIE_PATH_HEADSET_STEREO_TX		0x010740f9
-#define ADIE_PATH_HEADSET_MONO_RX		0x010740fa
-#define ADIE_PATH_HEADSET_STEREO_RX		0x010740fb
-#define ADIE_PATH_SPEAKER_TX			0x010740fc
-#define ADIE_PATH_SPEAKER_RX			0x010740fd
-#define ADIE_PATH_SPEAKER_STEREO_RX		0x01074101
-
-/* Path IDs used for TTY */
-#define ADIE_PATH_TTY_HEADSET_TX		0x010740fe
-#define ADIE_PATH_TTY_HEADSET_RX		0x010740ff
-
-/* Path IDs used by Factory Test Mode. */
-#define ADIE_PATH_FTM_MIC1_TX			0x01074108
-#define ADIE_PATH_FTM_MIC2_TX			0x01074107
-#define ADIE_PATH_FTM_HPH_L_RX			0x01074106
-#define ADIE_PATH_FTM_HPH_R_RX			0x01074104
-#define ADIE_PATH_FTM_EAR_RX			0x01074103
-#define ADIE_PATH_FTM_SPKR_RX			0x01074102
-
-/* Path IDs for Loopback */
-/* Path IDs used for Line in -> AuxPGA -> Line Out Stereo Mode*/
-#define ADIE_PATH_AUXPGA_LINEOUT_STEREO_LB	0x01074100
-/* Line in -> AuxPGA -> LineOut Mono */
-#define ADIE_PATH_AUXPGA_LINEOUT_MONO_LB	0x01073d82
-/* Line in -> AuxPGA -> Stereo Headphone */
-#define ADIE_PATH_AUXPGA_HDPH_STEREO_LB		0x01074109
-/* Line in -> AuxPGA -> Mono Headphone */
-#define ADIE_PATH_AUXPGA_HDPH_MONO_LB		0x01073d85
-/* Line in -> AuxPGA -> Earpiece */
-#define ADIE_PATH_AUXPGA_EAP_LB			0x01073d81
-/* Line in -> AuxPGA -> AuxOut */
-#define ADIE_PATH_AUXPGA_AUXOUT_LB		0x01073d86
-
-/* Concurrency Profiles */
-#define ADIE_PATH_SPKR_STEREO_HDPH_MONO_RX	0x01073d83
-#define ADIE_PATH_SPKR_MONO_HDPH_MONO_RX	0x01073d84
-#define ADIE_PATH_SPKR_MONO_HDPH_STEREO_RX	0x01073d88
-#define ADIE_PATH_SPKR_STEREO_HDPH_STEREO_RX	0x01073d89
-
-
-/** Fluence Profiles **/
-
-/* Broadside/Bowsetalk profile,
- * For Handset and Speaker phone Tx*/
-#define ADIE_CODEC_HANDSET_SPKR_BS_TX          0x0108fafa
-/* EndFire profile,
- * For Handset and Speaker phone Tx*/
-#define ADIE_CODEC_HANDSET_SPKR_EF_TX          0x0108fafb
-
-
-/* stages */
-#define ADIE_STAGE_PATH_OFF			0x0050
-#define ADIE_STAGE_DIGITAL_READY		0x0100
-#define ADIE_STAGE_DIGITAL_ANALOG_READY		0x1000
-#define ADIE_STAGE_ANALOG_OFF			0x0750
-#define ADIE_STAGE_DIGITAL_OFF			0x0600
-
-/* path types */
-#define ADIE_PATH_RX		0
-#define ADIE_PATH_TX		1
-#define ADIE_PATH_LOOPBACK	2
-
-/* mute states */
-#define ADIE_MUTE_OFF		0
-#define ADIE_MUTE_ON		1
-
-
-#endif
diff --git a/arch/arm/mach-msm/qdsp6/dal_audio.h b/arch/arm/mach-msm/qdsp6/dal_audio.h
deleted file mode 100644
index 6c353db..0000000
--- a/arch/arm/mach-msm/qdsp6/dal_audio.h
+++ /dev/null
@@ -1,604 +0,0 @@
-/* Copyright (c) 2009-2010, The Linux Foundation. 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.
- *
- */
-
-#ifndef __DAL_AUDIO_H__
-#define __DAL_AUDIO_H__
-
-#include "dal_audio_format.h"
-
-#define AUDIO_DAL_DEVICE 0x02000028
-#define AUDIO_DAL_PORT "DAL_AQ_AUD"
-
-enum {
-	AUDIO_OP_CONTROL = DAL_OP_FIRST_DEVICE_API,
-	AUDIO_OP_DATA,
-	AUDIO_OP_INIT,
-};	
-
-/* ---- common audio structures ---- */
-
-/* This flag, if set, indicates that the beginning of the data in the*/
-/* buffer is a synchronization point or key frame, meaning no data */
-/* before it in the stream is required in order to render the stream */
-/* from this point onward. */
-#define ADSP_AUDIO_BUFFER_FLAG_SYNC_POINT        0x01
-
-/* This flag, if set, indicates that the buffer object is using valid */
-/* physical address used to store the media data */
-#define ADSP_AUDIO_BUFFER_FLAG_PHYS_ADDR         0x04
-
-/* This flag, if set, indicates that a media start timestamp has been */
-/* set for a buffer. */
-#define ADSP_AUDIO_BUFFER_FLAG_START_SET         0x08
-
-/* This flag, if set, indicates that a media stop timestamp has been set */
-/* for a buffer. */
-#define ADSP_AUDIO_BUFFER_FLAG_STOP_SET          0x10
-
-/* This flag, if set, indicates that a preroll timestamp has been set */
-/* for a buffer. */
-#define ADSP_AUDIO_BUFFER_FLAG_PREROLL_SET       0x20
-
-/* This flag, if set, indicates that the data in the buffer is a fragment of */
-/* a larger block of data, and will be continued by the data in the next */
-/* buffer to be delivered. */
-#define ADSP_AUDIO_BUFFER_FLAG_CONTINUATION      0x40
-
-struct adsp_audio_buffer {
-	u32 addr;		/* Physical Address of buffer */
-	u32 max_size;		/* Maximum size of buffer */
-	u32 actual_size;	/* Actual size of valid data in the buffer */
-	u32 offset;		/* Offset to the first valid byte */
-	u32 flags;		/* ADSP_AUDIO_BUFFER_FLAGs that has been set */
-	s64 start;		/* Start timestamp, if any */
-	s64 stop;		/* Stop timestamp, if any */
-	s64 preroll;		/* Preroll timestamp, if any */
-} __attribute__ ((packed));
-
-
-
-/* ---- audio commands ---- */
-
-/* Command/event response types */
-#define ADSP_AUDIO_RESPONSE_COMMAND   0
-#define ADSP_AUDIO_RESPONSE_ASYNC     1
-
-struct adsp_command_hdr {
-	u32 size;		/* sizeof(cmd) - sizeof(u32) */
-
-	u32 dst;
-	u32 src;
-
-	u32 opcode;
-	u32 response_type;
-	u32 seq_number;
-
-	u32 context;		/* opaque to DSP */
-	u32 data;
-
-	u32 padding;
-} __attribute__ ((packed));
-
-
-#define AUDIO_DOMAIN_APP	0
-#define AUDIO_DOMAIN_MODEM	1
-#define AUDIO_DOMAIN_DSP	2
-
-#define AUDIO_SERVICE_AUDIO	0
-#define AUDIO_SERVICE_VIDEO	1 /* really? */
-
-/* adsp audio addresses are (byte order) domain, service, major, minor */
-//#define AUDIO_ADDR(maj,min) ( (((maj) & 0xff) << 16) | (((min) & 0xff) << 24) | (1) )
-
-#define AUDIO_ADDR(maj,min,dom) ( (((min) & 0xff) << 24) | (((maj) & 0xff) << 16) | ((AUDIO_SERVICE_AUDIO) << 8) | (dom) )
-
-
-/* AAC Encoder modes */
-#define ADSP_AUDIO_ENC_AAC_LC_ONLY_MODE		0
-#define ADSP_AUDIO_ENC_AAC_PLUS_MODE		1
-#define ADSP_AUDIO_ENC_ENHANCED_AAC_PLUS_MODE	2
-
-struct adsp_audio_aac_enc_cfg {
-	u32 bit_rate;		/* bits per second */
-	u32 encoder_mode;	/* ADSP_AUDIO_ENC_* */
-} __attribute__ ((packed));
-
-#define ADSP_AUDIO_ENC_SBC_ALLOCATION_METHOD_LOUNDNESS     0
-#define ADSP_AUDIO_ENC_SBC_ALLOCATION_METHOD_SNR           1
-
-#define ADSP_AUDIO_ENC_SBC_CHANNEL_MODE_MONO                1
-#define ADSP_AUDIO_ENC_SBC_CHANNEL_MODE_STEREO              2
-#define ADSP_AUDIO_ENC_SBC_CHANNEL_MODE_DUAL                8
-#define ADSP_AUDIO_ENC_SBC_CHANNEL_MODE_JOINT_STEREO        9
-
-struct adsp_audio_sbc_encoder_cfg {
-	u32 num_subbands;
-	u32 block_len;
-	u32 channel_mode;
-	u32 allocation_method;
-	u32 bit_rate;
-} __attribute__ ((packed));
-
-/* AMR NB encoder modes */
-#define ADSP_AUDIO_AMR_MR475	0
-#define ADSP_AUDIO_AMR_MR515	1
-#define ADSP_AUDIO_AMR_MMR59	2
-#define ADSP_AUDIO_AMR_MMR67	3
-#define ADSP_AUDIO_AMR_MMR74	4
-#define ADSP_AUDIO_AMR_MMR795	5
-#define ADSP_AUDIO_AMR_MMR102	6
-#define ADSP_AUDIO_AMR_MMR122	7
-
-/* The following are valid AMR NB DTX modes */
-#define ADSP_AUDIO_AMR_DTX_MODE_OFF		0
-#define ADSP_AUDIO_AMR_DTX_MODE_ON_VAD1		1
-#define ADSP_AUDIO_AMR_DTX_MODE_ON_VAD2		2
-#define ADSP_AUDIO_AMR_DTX_MODE_ON_AUTO		3
-
-/* AMR Encoder configuration */
-struct adsp_audio_amr_enc_cfg {
-	u32	mode;		/* ADSP_AUDIO_AMR_MR* */
-	u32	dtx_mode;	/* ADSP_AUDIO_AMR_DTX_MODE* */
-	u32	enable;		/* 1 = enable, 0 = disable */
-} __attribute__ ((packed));
-
-struct adsp_audio_qcelp13k_enc_cfg {
-	u16	min_rate;
-	u16	max_rate;
-} __attribute__ ((packed));
-
-struct adsp_audio_evrc_enc_cfg {
-	u16	min_rate;
-	u16	max_rate;
-} __attribute__ ((packed));
-
-union adsp_audio_codec_config {
-	struct adsp_audio_amr_enc_cfg amr;
-	struct adsp_audio_aac_enc_cfg aac;
-	struct adsp_audio_qcelp13k_enc_cfg qcelp13k;
-	struct adsp_audio_evrc_enc_cfg evrc;
-	struct adsp_audio_sbc_encoder_cfg sbc;
-} __attribute__ ((packed));
-
-
-/* This is the default value. */
-#define ADSP_AUDIO_OPEN_STREAM_MODE_NONE		0x0000
-
-/* This bit, if set, indicates that the AVSync mode is activated. */
-#define ADSP_AUDIO_OPEN_STREAM_MODE_AVSYNC		0x0001
-
-/* This bit, if set, indicates that the Sample Rate/Channel Mode */
-/* Change Notification mode is activated. */
-#define ADSP_AUDIO_OPEN_STREAM_MODE_SR_CM_NOTIFY	0x0002
-
-/* This bit, if set, indicates that the sync clock is enabled */
-#define  ADSP_AUDIO_OPEN_STREAM_MODE_ENABLE_SYNC_CLOCK	0x0004
-
-/* This bit, if set, indicates that the AUX PCM loopback is enabled */
-#define  ADSP_AUDIO_OPEN_STREAM_MODE_AUX_PCM		0x0040
-
-struct adsp_open_command {
-	struct adsp_command_hdr hdr;
-
-	u32 device;
-	u32 endpoint; /* address */
-
-	u32 stream_context;
-	u32 mode;
-
-	u32 buf_max_size;
-
-	union adsp_audio_format format;
-	union adsp_audio_codec_config config;
-} __attribute__ ((packed));
-
-
-/* --- audio control and stream session ioctls ---- */
-
-/* Opcode to open a device stream session to capture audio */
-#define ADSP_AUDIO_IOCTL_CMD_OPEN_READ			0x0108dd79
-
-/* Opcode to open a device stream session to render audio */
-#define ADSP_AUDIO_IOCTL_CMD_OPEN_WRITE			0x0108dd7a
-
-/* Opcode to open a device session, must open a device */
-#define ADSP_AUDIO_IOCTL_CMD_OPEN_DEVICE		0x0108dd7b
-
-/* Close an existing stream or device */
-#define ADSP_AUDIO_IOCTL_CMD_CLOSE			0x0108d8bc
-
-
-
-/* A device switch requires three IOCTL */
-/* commands in the following sequence: PREPARE, STANDBY, COMMIT */
-
-/* adsp_audio_device_switch_command structure is needed for */
-/* DEVICE_SWITCH_PREPARE */
-
-/* Device switch protocol step #1. Pause old device and */
-/* generate silence for the old device. */
-#define ADSP_AUDIO_IOCTL_CMD_DEVICE_SWITCH_PREPARE	0x010815c4
-
-/* Device switch protocol step #2. Release old device, */
-/* create new device and generate silence for the new device. */
-
-/* When client receives ack for this IOCTL, the client can */
-/* start sending IOCTL commands to configure, calibrate and */
-/* change filter settings on the new device. */
-#define ADSP_AUDIO_IOCTL_CMD_DEVICE_SWITCH_STANDBY	0x010815c5
-
-/* Device switch protocol step #3. Start normal operations on new device */
-#define ADSP_AUDIO_IOCTL_CMD_DEVICE_SWITCH_COMMIT	0x01075ee7
-
-struct adsp_device_switch_command {
-	struct adsp_command_hdr hdr;
-	u32 old_device;
-	u32 new_device;
-	u8 device_class; /* 0 = i.rx, 1 = i.tx, 2 = e.rx, 3 = e.tx */
-	u8 device_type; /* 0 = rx, 1 = tx, 2 = both */
-} __attribute__ ((packed));
-
-
-
-/* --- audio control session ioctls ---- */
-
-#define ADSP_PATH_RX	0
-#define ADSP_PATH_TX	1
-#define ADSP_PATH_BOTH	2
-#define ADSP_PATH_TX_CNG_DIS 3
-
-struct adsp_audio_dtmf_start_command {
-	struct adsp_command_hdr hdr;
-	u32 tone1_hz;
-	u32 tone2_hz;
-	u32 duration_usec;
-	s32 gain_mb;
-} __attribute__ ((packed));
-
-/* These commands will affect a logical device and all its associated */
-/* streams. */
-
-#define ADSP_AUDIO_MAX_EQ_BANDS 12
-
-struct adsp_audio_eq_band {
-	u16     band_idx; /* The band index, 0 .. 11 */
-	u32     filter_type; /* Filter band type */
-	u32     center_freq_hz; /* Filter band center frequency */
-	s32     filter_gain; /* Filter band initial gain (dB) */
-			/* Range is +12 dB to -12 dB with 1dB increments. */
-	s32     q_factor;
-		/* Filter band quality factor expressed as q-8 number, */
-		/* e.g. 3000/(2^8) */
-} __attribute__ ((packed));
-
-struct adsp_audio_eq_stream_config {
-	uint32_t  enable; /* Number of consequtive bands specified */
-	uint32_t  num_bands;
-	struct adsp_audio_eq_band  eq_bands[ADSP_AUDIO_MAX_EQ_BANDS];
-} __attribute__ ((packed));
-
-/* set device equalizer */
-struct adsp_set_dev_equalizer_command {
-	struct adsp_command_hdr hdr;
-	u32    device_id;
-	u32    enable;
-	u32    num_bands;
-	struct adsp_audio_eq_band eq_bands[ADSP_AUDIO_MAX_EQ_BANDS];
-} __attribute__ ((packed));
-
-/* Set device volume. */
-#define ADSP_AUDIO_IOCTL_CMD_SET_DEVICE_VOL		0x0107605c
-
-struct adsp_set_dev_volume_command {
-	struct adsp_command_hdr hdr;
-	u32 device_id;
-	u32 path; /* 0 = rx, 1 = tx, 2 = both */
-	s32 volume;
-} __attribute__ ((packed));
-
-/* Set Device stereo volume. This command has data payload, */
-/* struct adsp_audio_set_dev_stereo_volume_command. */
-#define ADSP_AUDIO_IOCTL_SET_DEVICE_STEREO_VOL		0x0108df3e
-
-/* Set L, R cross channel gain for a Device. This command has */
-/* data payload, struct adsp_audio_set_dev_x_chan_gain_command. */
-#define ADSP_AUDIO_IOCTL_SET_DEVICE_XCHAN_GAIN		0x0108df40
-
-/* Set device mute state. */
-#define ADSP_AUDIO_IOCTL_CMD_SET_DEVICE_MUTE		0x0107605f
-
-struct adsp_set_dev_mute_command {
-	struct adsp_command_hdr hdr;
-	u32 device_id;
-	u32 path; /* 0 = rx, 1 = tx, 2 = both */
-	u32 mute; /* 1 = mute */
-} __attribute__ ((packed));
-
-/* Configure Equalizer for a device. */
-/* This command has payload struct adsp_audio_set_dev_equalizer_command. */
-#define ADSP_AUDIO_IOCTL_CMD_SET_DEVICE_EQ_CONFIG	0x0108b10e
-
-/* Set configuration data for an algorithm aspect of a device. */
-/* This command has payload struct adsp_audio_set_dev_cfg_command. */
-#define ADSP_AUDIO_IOCTL_SET_DEVICE_CONFIG		0x0108b6cb
-
-struct adsp_set_dev_cfg_command {
-	struct adsp_command_hdr hdr;
-	u32 device_id;
-	u32 block_id;
-	u32 interface_id;
-	u32 phys_addr;
-	u32 phys_size;
-	u32 phys_used;
-} __attribute__ ((packed));
-
-/* Set configuration data for all interfaces of a device. */
-#define ADSP_AUDIO_IOCTL_SET_DEVICE_CONFIG_TABLE	0x0108b6bf
-
-struct adsp_set_dev_cfg_table_command {
-	struct adsp_command_hdr hdr;
-	u32 device_id;
-	u32 phys_addr;
-	u32 phys_size;
-	u32 phys_used;
-} __attribute__ ((packed));
-
-/* ---- audio stream data commands ---- */
-
-#define ADSP_AUDIO_IOCTL_CMD_DATA_TX			0x0108dd7f
-#define ADSP_AUDIO_IOCTL_CMD_DATA_RX			0x0108dd80
-
-struct adsp_buffer_command {
-	struct adsp_command_hdr hdr;
-	struct adsp_audio_buffer buffer;
-} __attribute__ ((packed));
-
-
-
-/* ---- audio stream ioctls (only affect a single stream in a session) ---- */
-
-/* Stop stream for audio device. */
-#define ADSP_AUDIO_IOCTL_CMD_STREAM_STOP		0x01075c54
-
-/* End of stream reached. Client will not send any more data. */
-#define ADSP_AUDIO_IOCTL_CMD_STREAM_EOS			0x0108b150
-
-/* Do sample slipping/stuffing on AAC outputs. The payload of */
-/* this command is struct adsp_audio_slip_sample_command. */
-#define ADSP_AUDIO_IOCTL_CMD_STREAM_SLIPSAMPLE		0x0108d40e
-
-/* Set stream volume. */
-/* This command has data payload, struct adsp_audio_set_volume_command. */
-#define ADSP_AUDIO_IOCTL_CMD_SET_STREAM_VOL		0x0108c0de
-
-/* Set stream stereo volume. This command has data payload, */
-/* struct adsp_audio_set_stereo_volume_command. */
-#define ADSP_AUDIO_IOCTL_SET_STREAM_STEREO_VOL		0x0108dd7c
-
-/* Set L, R cross channel gain for a Stream. This command has */
-/* data payload, struct adsp_audio_set_x_chan_gain_command. */
-#define ADSP_AUDIO_IOCTL_SET_STREAM_XCHAN_GAIN		0x0108dd7d
-
-/* Set stream mute state. */
-/* This command has data payload, struct adsp_audio_set_stream_mute. */
-#define ADSP_AUDIO_IOCTL_CMD_SET_STREAM_MUTE		0x0108c0df
-
-/* Reconfigure bit rate information. This command has data */
-/* payload, struct adsp_audio_set_bit_rate_command */
-#define ADSP_AUDIO_IOCTL_SET_STREAM_BITRATE		0x0108ccf1
-
-/* Set Channel Mapping. This command has data payload, struct */
-/* This command has data payload struct adsp_audio_set_channel_map_command. */
-#define ADSP_AUDIO_IOCTL_SET_STREAM_CHANNELMAP		0x0108d32a
-
-/* Enable/disable AACPlus SBR. */
-/* This command has data payload struct adsp_audio_set_sbr_command */
-#define ADSP_AUDIO_IOCTL_SET_STREAM_SBR			0x0108d416
-
-/* Enable/disable WMA Pro Chex and Fex. This command has data payload */
-/* struct adsp_audio_stream_set_wma_command. */
-#define ADSP_AUDIO_IOCTL_SET_STREAM_WMAPRO		0x0108d417
-
-
-/* ---- audio session ioctls (affect all streams in a session) --- */
-
-/* Start stream for audio device. */
-#define ADSP_AUDIO_IOCTL_CMD_SESSION_START		0x010815c6
-
-/* Stop all stream(s) for audio session as indicated by major id. */
-#define ADSP_AUDIO_IOCTL_CMD_SESSION_STOP		0x0108dd7e
-
-/* Pause the data flow for a session as indicated by major id. */
-#define ADSP_AUDIO_IOCTL_CMD_SESSION_PAUSE		0x01075ee8
-
-/* Resume the data flow for a session as indicated by major id. */
-#define ADSP_AUDIO_IOCTL_CMD_SESSION_RESUME		0x01075ee9
-
-/* Drop any unprocessed data buffers for a session as indicated by major id. */
-#define ADSP_AUDIO_IOCTL_CMD_SESSION_FLUSH		0x01075eea
-
-/* Start Stream DTMF tone */
-#define ADSP_AUDIO_IOCTL_CMD_SESSION_DTMF_START		0x0108c0dd
-
-/* Stop Stream DTMF tone */
-#define ADSP_AUDIO_IOCTL_CMD_SESSION_DTMF_STOP		0x01087554
-
-/* Set Session volume. */
-/* This command has data payload, struct adsp_audio_set_volume_command. */
-#define ADSP_AUDIO_IOCTL_SET_SESSION_VOL		0x0108d8bd
-
-/* Set session stereo volume. This command has data payload, */
-/* struct adsp_audio_set_stereo_volume_command. */
-#define ADSP_AUDIO_IOCTL_SET_SESSION_STEREO_VOL		0x0108df3d
-
-/* Set L, R cross channel gain for a session. This command has */
-/* data payload, struct adsp_audio_set_x_chan_gain_command. */
-#define ADSP_AUDIO_IOCTL_SET_SESSION_XCHAN_GAIN		0x0108df3f
-
-/* Set Session mute state. */
-/* This command has data payload, struct adsp_audio_set_mute_command. */
-#define ADSP_AUDIO_IOCTL_SET_SESSION_MUTE		0x0108d8be
-
-/* Configure Equalizer for a stream. */
-/* This command has payload struct adsp_audio_set_equalizer_command. */
-#define ADSP_AUDIO_IOCTL_SET_SESSION_EQ_CONFIG		0x0108c0e0
-
-/* Set Audio Video sync information. */
-/* This command has data payload, struct adsp_audio_set_av_sync_command. */
-#define ADSP_AUDIO_IOCTL_SET_SESSION_AVSYNC		0x0108d1e2
-
-/* Get Audio Media Session time. */
-/* This command returns the audioTime in adsp_audio_unsigned64_event */
-#define ADSP_AUDIO_IOCTL_CMD_GET_AUDIO_TIME		0x0108c26c
-
-
-/* these command structures are used for both STREAM and SESSION ioctls */
-
-struct adsp_set_volume_command {
-	struct adsp_command_hdr hdr;
-	s32 volume;
-} __attribute__ ((packed));
-	
-struct adsp_set_mute_command {
-	struct adsp_command_hdr hdr;
-	u32 mute; /* 1 == mute */
-} __attribute__ ((packed));
-
-
-struct adsp_set_equalizer_command {
-	struct adsp_command_hdr hdr;
-	u32    enable;
-	u32    num_bands;
-	struct adsp_audio_eq_band eq_bands[ADSP_AUDIO_MAX_EQ_BANDS];
-} __attribute__ ((packed));
-
-/* ---- audio events ---- */
-
-/* All IOCTL commands generate an event with the IOCTL opcode as the */
-/* event id after the IOCTL command has been executed. */
-
-/* This event is generated after a media stream session is opened. */
-#define ADSP_AUDIO_EVT_STATUS_OPEN				0x0108c0d6
-
-/* This event is generated after a media stream  session is closed. */
-#define ADSP_AUDIO_EVT_STATUS_CLOSE				0x0108c0d7
-
-/* Asyncronous buffer consumption. This event is generated after a */
-/* recived  buffer is consumed during rendering or filled during */
-/* capture opeartion. */
-#define ADSP_AUDIO_EVT_STATUS_BUF_DONE				0x0108c0d8
-
-/* This event is generated when rendering operation is starving for */
-/* data. In order to avoid audio loss at the end of a plauback, the */
-/* client should wait for this event before issuing the close command. */
-#define ADSP_AUDIO_EVT_STATUS_BUF_UNDERRUN			0x0108c0d9
-
-/* This event is generated during capture operation when there are no */
-/* buffers available to copy the captured audio data */
-#define ADSP_AUDIO_EVT_STATUS_BUF_OVERFLOW			0x0108c0da
-
-/* This asynchronous event is generated as a result of an input */
-/* sample rate change and/or channel mode change detected by the */
-/* decoder. The event payload data is an array of 2 uint32 */
-/* values containing the sample rate in Hz and channel mode. */
-#define ADSP_AUDIO_EVT_SR_CM_CHANGE				0x0108d329
-
-struct adsp_event_hdr {
-	u32 evt_handle;		/* DAL common header */
-	u32 evt_cookie;
-	u32 evt_length;
-
-	u32 src;		/* "source" audio address */
-	u32 dst;		/* "destination" audio address */
-
-	u32 event_id;
-	u32 response_type;
-	u32 seq_number;
-
-	u32 context;		/* opaque to DSP */
-	u32 data;
-
-	u32 status;
-} __attribute__ ((packed));
-
-struct adsp_buffer_event {
-	struct adsp_event_hdr hdr;
-	struct adsp_audio_buffer buffer;
-} __attribute__ ((packed));
-
-
-/* ---- audio device IDs ---- */
-
-/* Device direction Rx/Tx flag */
-#define ADSP_AUDIO_RX_DEVICE		0x00
-#define ADSP_AUDIO_TX_DEVICE		0x01
-
-/* Default RX or TX device */
-#define ADSP_AUDIO_DEVICE_ID_DEFAULT		0x1081679
-
-/* Source (TX) devices */
-#define ADSP_AUDIO_DEVICE_ID_HANDSET_MIC	0x107ac8d
-#define ADSP_AUDIO_DEVICE_ID_HEADSET_MIC	0x1081510
-#define ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MIC	0x1081512
-#define ADSP_AUDIO_DEVICE_ID_BT_SCO_MIC		0x1081518
-#define ADSP_AUDIO_DEVICE_ID_AUXPCM_TX		0x1081518
-#define ADSP_AUDIO_DEVICE_ID_TTY_HEADSET_MIC	0x108151b
-#define ADSP_AUDIO_DEVICE_ID_I2S_MIC		0x1089bf3
-
-#define ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_DUAL_MIC	0x108f9c5
-#define ADSP_AUDIO_DEVICE_ID_HANDSET_DUAL_MIC		0x108f9c3
-
-/* Special loopback pseudo device to be paired with an RX device */
-/* with usage ADSP_AUDIO_DEVICE_USAGE_MIXED_PCM_LOOPBACK */
-#define ADSP_AUDIO_DEVICE_ID_MIXED_PCM_LOOPBACK_TX	0x1089bf2
-
-/* Sink (RX) devices */
-#define ADSP_AUDIO_DEVICE_ID_HANDSET_SPKR			0x107ac88
-#define ADSP_AUDIO_DEVICE_ID_HEADSET_SPKR_MONO			0x1081511
-#define ADSP_AUDIO_DEVICE_ID_HEADSET_SPKR_STEREO		0x107ac8a
-#define ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MONO			0x1081513
-#define ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MONO_W_MONO_HEADSET     0x108c508
-#define ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MONO_W_STEREO_HEADSET   0x108c894
-#define ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_STEREO			0x1081514
-#define ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_STEREO_W_MONO_HEADSET   0x108c895
-#define ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_STEREO_W_STEREO_HEADSET	0x108c509
-#define ADSP_AUDIO_DEVICE_ID_BT_SCO_SPKR			0x1081519
-#define ADSP_AUDIO_DEVICE_ID_AUXPCM_RX				0x1081519
-#define ADSP_AUDIO_DEVICE_ID_TTY_HEADSET_SPKR			0x108151c
-#define ADSP_AUDIO_DEVICE_ID_I2S_SPKR				0x1089bf4
-#define ADSP_AUDIO_DEVICE_ID_NULL_SINK				0x108e512
-
-/* BT A2DP playback device. */
-/* This device must be paired with */
-/* ADSP_AUDIO_DEVICE_ID_MIXED_PCM_LOOPBACK_TX using  */
-/* ADSP_AUDIO_DEVICE_USAGE_MIXED_PCM_LOOPBACK mode */
-#define ADSP_AUDIO_DEVICE_ID_BT_A2DP_SPKR	0x108151a
-
-/* Voice Destination identifier - specifically used for */
-/* controlling Voice module from the Device Control Session */
-#define ADSP_AUDIO_DEVICE_ID_VOICE		0x0108df3c
-
-/*  Audio device usage types. */
-/*  This is a bit mask to determine which topology to use in the */
-/* device session */
-#define ADSP_AUDIO_DEVICE_CONTEXT_VOICE			0x01
-#define ADSP_AUDIO_DEVICE_CONTEXT_PLAYBACK		0x02
-#define ADSP_AUDIO_DEVICE_CONTEXT_MIXED_RECORD		0x10
-#define ADSP_AUDIO_DEVICE_CONTEXT_RECORD		0x20
-#define ADSP_AUDIO_DEVICE_CONTEXT_PCM_LOOPBACK		0x40
-
-/* ADSP audio driver return codes */
-#define ADSP_AUDIO_STATUS_SUCCESS               0
-#define ADSP_AUDIO_STATUS_EUNSUPPORTED          20
-
-#endif
diff --git a/arch/arm/mach-msm/qdsp6/dal_audio_format.h b/arch/arm/mach-msm/qdsp6/dal_audio_format.h
deleted file mode 100644
index 4223974..0000000
--- a/arch/arm/mach-msm/qdsp6/dal_audio_format.h
+++ /dev/null
@@ -1,270 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-
-#ifndef __ADSP_AUDIO_MEDIA_FORMAT_H
-#define __ADSP_AUDIO_MEDIA_FORMAT_H
-
-
-
-/* Supported audio media formats */
-
-/* format block in shmem */
-#define ADSP_AUDIO_FORMAT_SHAREDMEMORY	0x01091a78
-/* adsp_audio_format_raw_pcm type */
-#define ADSP_AUDIO_FORMAT_PCM		0x0103d2fd
-/* adsp_audio_format_raw_pcm type */
-#define ADSP_AUDIO_FORMAT_DTMF		0x01087725
-/* adsp_audio_format_adpcm type */
-#define ADSP_AUDIO_FORMAT_ADPCM		0x0103d2ff
-/* Yamaha PCM format */
-#define ADSP_AUDIO_FORMAT_YADPCM	0x0108dc07
-/* ISO/IEC 11172 */
-#define ADSP_AUDIO_FORMAT_MP3		0x0103d308
-/* ISO/IEC 14496 */
-#define ADSP_AUDIO_FORMAT_MPEG4_AAC	0x010422f1
-/* AMR-NB audio in FS format */
-#define ADSP_AUDIO_FORMAT_AMRNB_FS	0x0105c16c
-/* AMR-WB audio in FS format */
-#define ADSP_AUDIO_FORMAT_AMRWB_FS	0x0105c16e
-/* QCELP 13k, IS733 */
-#define ADSP_AUDIO_FORMAT_V13K_FS	0x01080b8a
-/* EVRC   8k, IS127 */
-#define ADSP_AUDIO_FORMAT_EVRC_FS	0x01080b89
-/* EVRC-B   8k, 4GV */
-#define ADSP_AUDIO_FORMAT_EVRCB_FS	0x0108f2a3
-/* MIDI command stream */
-#define ADSP_AUDIO_FORMAT_MIDI		0x0103d300
-/* A2DP SBC stream */
-#define ADSP_AUDIO_FORMAT_SBC		0x0108c4d8
-/* Version 10 Professional */
-#define ADSP_AUDIO_FORMAT_WMA_V10PRO	0x0108aa92
-/* Version 9 Starndard */
-#define ADSP_AUDIO_FORMAT_WMA_V9	0x0108d430
-/* AMR WideBand Plus */
-#define ADSP_AUDIO_FORMAT_AMR_WB_PLUS	0x0108f3da
-/* AC3 Decoder */
-#define ADSP_AUDIO_FORMAT_AC3_DECODER	0x0108d5f9
-
-
-/* Not yet supported audio media formats */
-
-
-
-/* ISO/IEC 13818 */
-#define ADSP_AUDIO_FORMAT_MPEG2_AAC	0x0103d309
-/* 3GPP TS 26.101 Sec 4.0 */
-#define ADSP_AUDIO_FORMAT_AMRNB_IF1	0x0103d305
-/* 3GPP TS 26.101 Annex A */
-#define ADSP_AUDIO_FORMAT_AMRNB_IF2	0x01057b31
-/* 3GPP TS 26.201 */
-#define ADSP_AUDIO_FORMAT_AMRWB_IF1	0x0103d306
-/* 3GPP TS 26.201 */
-#define ADSP_AUDIO_FORMAT_AMRWB_IF2	0x0105c16d
-/* G.711 */
-#define ADSP_AUDIO_FORMAT_G711		0x0106201d
-/* QCELP  8k, IS96A */
-#define ADSP_AUDIO_FORMAT_V8K_FS	0x01081d29
-/* Version 1 codec */
-#define ADSP_AUDIO_FORMAT_WMA_V1	0x01055b2b
-/* Version 2, 7 & 8 codec */
-#define ADSP_AUDIO_FORMAT_WMA_V8	0x01055b2c
-/* Version 9 Professional codec */
-#define ADSP_AUDIO_FORMAT_WMA_V9PRO	0x01055b2d
-/* Version 9 Voice codec */
-#define ADSP_AUDIO_FORMAT_WMA_SP1	0x01055b2e
-/* Version 9 Lossless codec */
-#define ADSP_AUDIO_FORMAT_WMA_LOSSLESS	0x01055b2f
-/* Real Media content, low-bitrate */
-#define ADSP_AUDIO_FORMAT_RA_SIPR	0x01042a0f
-/* Real Media content */
-#define ADSP_AUDIO_FORMAT_RA_COOK	0x01042a0e
-
-
-/* For all of the audio formats, unless specified otherwise, */
-/* the following apply: */
-/* Format block bits are arranged in bytes and words in little-endian */
-/* order, i.e., least-significant bit first and least-significant */
-/* byte first. */
-
-
-
-/* AAC Format Block. */
-
-/* AAC format block consist of a format identifier followed by */
-/* AudioSpecificConfig formatted according to ISO/IEC 14496-3 */
-
-/* The following AAC format identifiers are supported */
-#define ADSP_AUDIO_AAC_ADTS		0x010619cf
-#define ADSP_AUDIO_AAC_MPEG4_ADTS	0x010619d0
-#define ADSP_AUDIO_AAC_LOAS		0x010619d1
-#define ADSP_AUDIO_AAC_ADIF		0x010619d2
-#define ADSP_AUDIO_AAC_RAW		0x010619d3
-#define ADSP_AUDIO_AAC_FRAMED_RAW	0x0108c1fb
-
-
-#define ADSP_AUDIO_COMPANDING_ALAW	0x10619cd
-#define ADSP_AUDIO_COMPANDING_MLAW	0x10619ce
-
-/* Maxmum number of bytes allowed in a format block */
-#define ADSP_AUDIO_FORMAT_DATA_MAX 16
-
-
-struct adsp_audio_no_payload_format {
-	/* Media Format Code (must always be first element) */
-	u32		format;
-
-	/* no payload for this format type */
-} __attribute__ ((packed));
-
-
-/* For convenience, to be used as a standard format block */
-/* for various media types that don't need a unique format block */
-/* ie. PCM, DTMF, etc. */
-struct adsp_audio_standard_format {
-	/* Media Format Code (must always be first element) */
-	u32		format;
-
-	/* payload */
-	u16		channels;
-	u16		bits_per_sample;
-	u32		sampling_rate;
-	u8		is_signed;
-	u8		is_interleaved;
-} __attribute__ ((packed));
-
-
-
-/* ADPCM format block */
-struct adsp_audio_adpcm_format {
-	/* Media Format Code (must always be first element) */
-	u32		format;
-
-	/* payload */
-	u16		channels;
-	u16		bits_per_sample;
-	u32		sampling_rate;
-	u8		is_signed;
-	u8		is_interleaved;
-	u32		block_size;
-} __attribute__ ((packed));
-
-
-/* MIDI format block */
-struct adsp_audio_midi_format {
-	/* Media Format Code (must always be first element) */
-	u32		format;
-
-	/* payload */
-	u32		sampling_rate;
-	u16		channels;
-	u16		mode;
-} __attribute__ ((packed));
-
-
-/* G711 format block */
-struct adsp_audio_g711_format {
-	/* Media Format Code (must always be first element) */
-	u32		format;
-
-	/* payload */
-	u32		companding;
-} __attribute__ ((packed));
-
-
-struct adsp_audio_wma_pro_format {
-	/* Media Format Code (must always be first element) */
-	u32		format;
-
-	/* payload */
-	u16		format_tag;
-	u16		channels;
-	u32		samples_per_sec;
-	u32		avg_bytes_per_sec;
-	u16		block_align;
-	u16		valid_bits_per_sample;
-	u32		channel_mask;
-	u16		encode_opt;
-	u16		advanced_encode_opt;
-	u32		advanced_encode_opt2;
-	u32		drc_peak_reference;
-	u32		drc_peak_target;
-	u32		drc_average_reference;
-	u32		drc_average_target;
-} __attribute__ ((packed));
-
-
-struct adsp_audio_amrwb_plus_format {
-	/* Media Format Code (must always be first element) */
-	u32		format;
-
-	/* payload */
-	u32		size;
-	u32		version;
-	u32		channels;
-	u32		amr_band_mode;
-	u32		amr_dtx_mode;
-	u32		amr_frame_format;
-	u32		amr_isf_index;
-} __attribute__ ((packed));
-
-
-/* Binary Byte Stream Format */
-/* Binary format type that defines a byte stream, */
-/* can be used to specify any format (ie. AAC) */
-struct adsp_audio_binary_format {
-	/* Media Format Code (must always be first element) */
-	u32		format;
-
-	/* payload */
-	/* number of bytes set in byte stream */
-	u32		num_bytes;
-	/* Byte stream binary data */
-	u8		data[ADSP_AUDIO_FORMAT_DATA_MAX];
-} __attribute__ ((packed));
-
-
-struct adsp_audio_shared_memory_format {
-	/* Media Format Code (must always be first element) */
-	u32		format;
-
-	/* Number of bytes in shared memory */
-	u32		len;
-	/* Phyisical address to data in shared memory */
-	u32		address;
-} __attribute__ ((packed));
-
-
-/* Union of all format types */
-union adsp_audio_format {
-	/* Basic format block with no payload */
-	struct adsp_audio_no_payload_format	no_payload;
-	/* Generic format block PCM, DTMF */
-	struct adsp_audio_standard_format	standard;
-	/* ADPCM format block */
-	struct adsp_audio_adpcm_format		adpcm;
-	/* MIDI format block */
-	struct adsp_audio_midi_format		midi;
-	/* G711 format block */
-	struct adsp_audio_g711_format		g711;
-	/* WmaPro format block */
-	struct adsp_audio_wma_pro_format	wma_pro;
-	/* WmaPro format block */
-	struct adsp_audio_amrwb_plus_format	amrwb_plus;
-	/* binary (byte stream) format block, used for AAC */
-	struct adsp_audio_binary_format		binary;
-	/* format block in shared memory */
-	struct adsp_audio_shared_memory_format	shared_mem;
-};
-
-#endif
-
diff --git a/arch/arm/mach-msm/qdsp6/dsp_debug.c b/arch/arm/mach-msm/qdsp6/dsp_debug.c
deleted file mode 100644
index 922f8cd..0000000
--- a/arch/arm/mach-msm/qdsp6/dsp_debug.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/* arch/arm/mach-msm/qdsp6/dsp_dump.c
- *
- * Copyright (C) 2009 Google, Inc.
- * Author: Brian Swetland <swetland@google.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/io.h>
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/delay.h>
-#include <asm/atomic.h>
-
-#include <mach/proc_comm.h>
-#include <mach/debug_mm.h>
-
-static wait_queue_head_t dsp_wait;
-static int dsp_has_crashed;
-static int dsp_wait_count;
-
-static atomic_t dsp_crash_count = ATOMIC_INIT(0);
-
-void q6audio_dsp_not_responding(void)
-{
-
-	if (atomic_add_return(1, &dsp_crash_count) != 1) {
-		pr_err("q6audio_dsp_not_responding() - parking additional crasher...\n");
-		for (;;)
-			msleep(1000);
-	}
-	if (dsp_wait_count) {
-		dsp_has_crashed = 1;
-		wake_up(&dsp_wait);
-
-		while (dsp_has_crashed != 2)
-			wait_event(dsp_wait, dsp_has_crashed == 2);
-	} else {
-		pr_err("q6audio_dsp_not_responding() - no waiter?\n");
-	}
-	BUG();
-}
-
-static int dsp_open(struct inode *inode, struct file *file)
-{
-	return 0;
-}
-
-static ssize_t dsp_write(struct file *file, const char __user *buf,
-			 size_t count, loff_t *pos)
-{
-	char cmd[32];
-
-	if (count >= sizeof(cmd))
-		return -EINVAL;
-	if (copy_from_user(cmd, buf, count))
-		return -EFAULT;
-	cmd[count] = 0;
-
-	if ((count > 1) && (cmd[count-1] == '\n'))
-		cmd[count-1] = 0;
-
-	if (!strcmp(cmd, "wait-for-crash")) {
-		while (!dsp_has_crashed) {
-			int res;
-			dsp_wait_count++;
-			res = wait_event_interruptible(dsp_wait, dsp_has_crashed);
-			if (res < 0) {
-				dsp_wait_count--;
-				return res;
-			}
-		}
-#if defined(CONFIG_MACH_MAHIMAHI)
-		/* assert DSP NMI */
-		msm_proc_comm(PCOM_CUSTOMER_CMD1, 0, 0);
-		msleep(250);
-#endif
-	} else if (!strcmp(cmd, "boom")) {
-		q6audio_dsp_not_responding();
-	} else if (!strcmp(cmd, "continue-crash")) {
-		dsp_has_crashed = 2;
-		wake_up(&dsp_wait);
-	} else {
-		pr_err("[%s:%s] unknown dsp_debug command: %s\n", __MM_FILE__,
-				__func__, cmd);
-	}
-
-	return count;
-}
-
-#define DSP_RAM_BASE 0x2E800000
-#define DSP_RAM_SIZE 0x01800000
-
-static unsigned copy_ok_count;
-
-static ssize_t dsp_read(struct file *file, char __user *buf,
-			size_t count, loff_t *pos)
-{
-	size_t actual = 0;
-	size_t mapsize = PAGE_SIZE;
-	unsigned addr;
-	void __iomem *ptr;
-
-	if (*pos >= DSP_RAM_SIZE)
-		return 0;
-
-	if (*pos & (PAGE_SIZE - 1))
-		return -EINVAL;
-
-	addr = (*pos + DSP_RAM_BASE);
-
-	/* don't blow up if we're unaligned */
-	if (addr & (PAGE_SIZE - 1))
-		mapsize *= 2;
-
-	while (count >= PAGE_SIZE) {
-		ptr = ioremap(addr, mapsize);
-		if (!ptr) {
-			pr_err("[%s:%s] map error @ %x\n", __MM_FILE__,
-					__func__, addr);
-			return -EFAULT;
-		}
-		if (copy_to_user(buf, ptr, PAGE_SIZE)) {
-			iounmap(ptr);
-			pr_err("[%s:%s] copy error @ %p\n", __MM_FILE__,
-					__func__, buf);
-			return -EFAULT;
-		}
-		copy_ok_count += PAGE_SIZE;
-		iounmap(ptr);
-		addr += PAGE_SIZE;
-		buf += PAGE_SIZE;
-		actual += PAGE_SIZE;
-		count -= PAGE_SIZE;
-	}
-
-	*pos += actual;
-	return actual;
-}
-
-static int dsp_release(struct inode *inode, struct file *file)
-{
-	return 0;
-}
-
-static const struct file_operations dsp_fops = {
-	.owner		= THIS_MODULE,
-	.open		= dsp_open,
-	.read		= dsp_read,
-	.write		= dsp_write,
-	.release	= dsp_release,
-};
-
-static struct miscdevice dsp_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "dsp_debug",
-	.fops	= &dsp_fops,
-};
-
-
-static int __init dsp_init(void)
-{
-	init_waitqueue_head(&dsp_wait);
-	return misc_register(&dsp_misc);
-}
-
-device_initcall(dsp_init);
diff --git a/arch/arm/mach-msm/qdsp6/dtmf.c b/arch/arm/mach-msm/qdsp6/dtmf.c
deleted file mode 100644
index 30978df..0000000
--- a/arch/arm/mach-msm/qdsp6/dtmf.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/* Copyright (c) 2010, The Linux Foundation. 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.
- *
- */
-
-#include <linux/slab.h>
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/uaccess.h>
-
-#include <linux/msm_audio.h>
-
-#include <mach/msm_qdsp6_audio.h>
-#include <mach/debug_mm.h>
-
-struct dtmf {
-	struct mutex lock;
-	struct audio_client *ac;
-	struct msm_dtmf_config cfg;
-};
-
-static long dtmf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct dtmf *dtmf = file->private_data;
-	int rc = 0;
-
-	mutex_lock(&dtmf->lock);
-	switch (cmd) {
-
-	case AUDIO_START: {
-		pr_debug("[%s:%s] AUDIO_START\n", __MM_FILE__, __func__);
-		if (dtmf->ac) {
-			pr_err("[%s:%s] active session already existing\n",
-				__MM_FILE__, __func__);
-			rc = -EBUSY;
-		} else {
-			dtmf->ac = q6audio_open_dtmf(48000, 2, 0);
-			if (!dtmf->ac)
-				rc = -ENOMEM;
-		}
-		break;
-	}
-	case AUDIO_PLAY_DTMF: {
-		rc = copy_from_user((void *)&dtmf->cfg, (void *)arg,
-					sizeof(struct msm_dtmf_config));
-
-		pr_debug("[%s:%s] PLAY_DTMF: high = %d, low = %d\n",
-			__MM_FILE__, __func__, dtmf->cfg.dtmf_hi,
-			dtmf->cfg.dtmf_low);
-		rc = q6audio_play_dtmf(dtmf->ac, dtmf->cfg.dtmf_hi,
-					dtmf->cfg.dtmf_low, dtmf->cfg.duration,
-					dtmf->cfg.rx_gain);
-		if (rc) {
-			pr_err("[%s:%s] DTMF_START failed\n", __MM_FILE__,
-					__func__);
-			break;
-		}
-		break;
-	}
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&dtmf->lock);
-
-	pr_debug("[%s:%s] rc = %d\n", __MM_FILE__, __func__, rc) ;
-	return rc;
-}
-
-static int dtmf_open(struct inode *inode, struct file *file)
-{
-	int rc = 0;
-
-	struct dtmf *dtmf;
-	pr_info("[%s:%s] open\n", __MM_FILE__, __func__);
-	dtmf = kzalloc(sizeof(struct dtmf), GFP_KERNEL);
-
-	if (!dtmf)
-		return -ENOMEM;
-
-	mutex_init(&dtmf->lock);
-
-	file->private_data = dtmf;
-	return rc;
-}
-
-static int dtmf_release(struct inode *inode, struct file *file)
-{
-	struct dtmf *dtmf = file->private_data;
-	if (dtmf->ac)
-		q6audio_close(dtmf->ac);
-	kfree(dtmf);
-	pr_info("[%s:%s] release\n", __MM_FILE__, __func__);
-	return 0;
-}
-
-static const struct file_operations dtmf_fops = {
-	.owner		= THIS_MODULE,
-	.open		= dtmf_open,
-	.release	= dtmf_release,
-	.unlocked_ioctl	= dtmf_ioctl,
-};
-
-struct miscdevice dtmf_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_dtmf",
-	.fops	= &dtmf_fops,
-};
-
-static int __init dtmf_init(void)
-{
-	return misc_register(&dtmf_misc);
-}
-
-device_initcall(dtmf_init);
diff --git a/arch/arm/mach-msm/qdsp6/evrc_in.c b/arch/arm/mach-msm/qdsp6/evrc_in.c
deleted file mode 100644
index e059efa..0000000
--- a/arch/arm/mach-msm/qdsp6/evrc_in.c
+++ /dev/null
@@ -1,468 +0,0 @@
-/*
- * Copyright (C) 2009 Google, Inc.
- * Copyright (C) 2009 HTC Corporation
- * Copyright (c) 2010, The Linux Foundation. All rights reserved.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/slab.h>
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/time.h>
-#include <linux/wait.h>
-
-#include <linux/msm_audio_qcp.h>
-#include <mach/msm_qdsp6_audio.h>
-#include "dal_audio_format.h"
-#include <mach/debug_mm.h>
-
-#define EVRC_FC_BUFF_CNT 10
-#define EVRC_READ_TIMEOUT 2000
-struct evrc_fc_buff {
-	struct mutex lock;
-	int empty;
-	void *data;
-	int size;
-	int actual_size;
-};
-
-struct evrc_fc {
-	struct task_struct *task;
-	wait_queue_head_t fc_wq;
-	struct evrc_fc_buff fc_buff[EVRC_FC_BUFF_CNT];
-	int buff_index;
-};
-
-struct evrc {
-	struct mutex lock;
-	struct msm_audio_evrc_enc_config cfg;
-	struct msm_audio_stream_config str_cfg;
-	struct audio_client *audio_client;
-	struct msm_voicerec_mode voicerec_mode;
-	struct evrc_fc *evrc_fc;
-};
-
-
-static int q6_evrc_flowcontrol(void *data)
-{
-	struct audio_client *ac;
-	struct audio_buffer *ab;
-	struct evrc *evrc = data;
-	int buff_index = 0;
-	int xfer = 0;
-	struct evrc_fc *fc;
-
-
-	ac = evrc->audio_client;
-	fc = evrc->evrc_fc;
-	if (!ac) {
-		pr_err("[%s:%s] audio_client is NULL\n", __MM_FILE__, __func__);
-		return 0;
-	}
-
-	while (!kthread_should_stop()) {
-		ab = ac->buf + ac->cpu_buf;
-		if (ab->used)
-			wait_event(ac->wait, (ab->used == 0));
-		pr_debug("[%s:%s] ab->data = %p, cpu_buf = %d\n", __MM_FILE__,
-			__func__, ab->data, ac->cpu_buf);
-		xfer = ab->actual_size;
-
-
-		mutex_lock(&(fc->fc_buff[buff_index].lock));
-		if (!fc->fc_buff[buff_index].empty) {
-			pr_err("[%s:%s] flow control buffer[%d] not read!\n",
-					__MM_FILE__, __func__, buff_index);
-		}
-
-		if (fc->fc_buff[buff_index].size < xfer) {
-			pr_err("[%s:%s] buffer %d too small\n", __MM_FILE__,
-					__func__, buff_index);
-			memcpy(fc->fc_buff[buff_index].data, ab->data,
-					fc->fc_buff[buff_index].size);
-			fc->fc_buff[buff_index].empty = 0;
-			fc->fc_buff[buff_index].actual_size =
-					fc->fc_buff[buff_index].size;
-		} else {
-			memcpy(fc->fc_buff[buff_index].data, ab->data, xfer);
-			fc->fc_buff[buff_index].empty = 0;
-			fc->fc_buff[buff_index].actual_size = xfer;
-		}
-		mutex_unlock(&(fc->fc_buff[buff_index].lock));
-		/*wake up client, if any*/
-		wake_up(&fc->fc_wq);
-
-		buff_index++;
-		if (buff_index >= EVRC_FC_BUFF_CNT)
-			buff_index = 0;
-
-		ab->used = 1;
-
-		q6audio_read(ac, ab);
-		ac->cpu_buf ^= 1;
-	}
-
-	return 0;
-}
-static long q6_evrc_in_ioctl(struct file *file, unsigned int cmd,
-				unsigned long arg)
-{
-	struct evrc *evrc = file->private_data;
-	int rc = 0;
-	int i = 0;
-	struct evrc_fc *fc;
-	int size = 0;
-
-	mutex_lock(&evrc->lock);
-	switch (cmd) {
-	case AUDIO_SET_VOLUME:
-		pr_debug("[%s:%s] SET_VOLUME\n", __MM_FILE__, __func__);
-		break;
-	case AUDIO_GET_STATS:
-	{
-		struct msm_audio_stats stats;
-		pr_debug("[%s:%s] GET_STATS\n", __MM_FILE__, __func__);
-		memset(&stats, 0, sizeof(stats));
-		if (copy_to_user((void *) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-	case AUDIO_START:
-	{
-		uint32_t acdb_id;
-		pr_debug("[%s:%s] AUDIO_START\n", __MM_FILE__, __func__);
-		if (arg == 0) {
-			acdb_id = 0;
-		} else {
-			if (copy_from_user(&acdb_id, (void *) arg,
-				sizeof(acdb_id))) {
-				rc = -EFAULT;
-				break;
-			}
-		}
-		if (evrc->audio_client) {
-			rc = -EBUSY;
-			pr_err("[%s:%s] active session already existing\n",
-				__MM_FILE__, __func__);
-			break;
-		} else {
-			evrc->audio_client = q6audio_open_qcp(
-					evrc->str_cfg.buffer_size,
-					evrc->cfg.min_bit_rate,
-					evrc->cfg.max_bit_rate,
-					evrc->voicerec_mode.rec_mode,
-					ADSP_AUDIO_FORMAT_EVRC_FS,
-					acdb_id);
-
-			if (!evrc->audio_client) {
-				pr_err("[%s:%s] evrc open session failed\n",
-					__MM_FILE__, __func__);
-				kfree(evrc);
-				rc = -ENOMEM;
-				break;
-			}
-		}
-
-		/*allocate flow control buffers*/
-		fc = evrc->evrc_fc;
-		size = evrc->str_cfg.buffer_size;
-		for (i = 0; i < EVRC_FC_BUFF_CNT; ++i) {
-			mutex_init(&(fc->fc_buff[i].lock));
-			fc->fc_buff[i].empty = 1;
-			fc->fc_buff[i].data = kmalloc(size, GFP_KERNEL);
-			if (fc->fc_buff[i].data == NULL) {
-				pr_err("[%s:%s] No memory for FC buffers\n",
-						__MM_FILE__, __func__);
-				rc = -ENOMEM;
-				goto fc_fail;
-			}
-			fc->fc_buff[i].size = size;
-			fc->fc_buff[i].actual_size = 0;
-		}
-
-		/*create flow control thread*/
-		fc->task = kthread_run(q6_evrc_flowcontrol,
-				evrc, "evrc_flowcontrol");
-		if (IS_ERR(fc->task)) {
-			rc = PTR_ERR(fc->task);
-			pr_err("[%s:%s] error creating flow control thread\n",
-					__MM_FILE__, __func__);
-			goto fc_fail;
-		}
-		break;
-fc_fail:
-		/*free flow control buffers*/
-		--i;
-		for (; i >=  0; i--) {
-			kfree(fc->fc_buff[i].data);
-			fc->fc_buff[i].data = NULL;
-		}
-		break;
-	}
-	case AUDIO_STOP:
-		pr_debug("[%s:%s] AUDIO_STOP\n", __MM_FILE__, __func__);
-		break;
-	case AUDIO_FLUSH:
-		break;
-	case AUDIO_SET_INCALL: {
-		pr_debug("[%s:%s] SET_INCALL\n", __MM_FILE__, __func__);
-		if (copy_from_user(&evrc->voicerec_mode,
-			(void *)arg, sizeof(struct msm_voicerec_mode)))
-			rc = -EFAULT;
-
-		if (evrc->voicerec_mode.rec_mode != AUDIO_FLAG_READ
-				&& evrc->voicerec_mode.rec_mode !=
-				AUDIO_FLAG_INCALL_MIXED) {
-			evrc->voicerec_mode.rec_mode = AUDIO_FLAG_READ;
-			pr_err("[%s:%s] Invalid rec_mode\n", __MM_FILE__,
-					__func__);
-			rc = -EINVAL;
-		}
-		break;
-	}
-	case AUDIO_GET_STREAM_CONFIG:
-		if (copy_to_user((void *)arg, &evrc->str_cfg,
-				sizeof(struct msm_audio_stream_config)))
-			rc = -EFAULT;
-
-		pr_debug("[%s:%s] GET_STREAM_CONFIG: buffsz=%d, buffcnt=%d\n",
-			 __MM_FILE__, __func__, evrc->str_cfg.buffer_size,
-			evrc->str_cfg.buffer_count);
-		break;
-	case AUDIO_SET_STREAM_CONFIG:
-		if (copy_from_user(&evrc->str_cfg, (void *)arg,
-			sizeof(struct msm_audio_stream_config))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		pr_debug("[%s:%s] SET_STREAM_CONFIG: buffsz=%d, buffcnt=%d\n",
-			 __MM_FILE__, __func__, evrc->str_cfg.buffer_size,
-			evrc->str_cfg.buffer_count);
-
-		if (evrc->str_cfg.buffer_size < 23) {
-			pr_err("[%s:%s] Buffer size too small\n", __MM_FILE__,
-					__func__);
-			rc = -EINVAL;
-			break;
-		}
-
-		if (evrc->str_cfg.buffer_count != 2)
-			pr_info("[%s:%s] Buffer count set to 2\n", __MM_FILE__,
-					__func__);
-		break;
-	case AUDIO_SET_EVRC_ENC_CONFIG:
-		if (copy_from_user(&evrc->cfg, (void *) arg,
-				 sizeof(struct msm_audio_evrc_enc_config)))
-			rc = -EFAULT;
-		pr_debug("[%s:%s] SET_EVRC_ENC_CONFIG\n", __MM_FILE__,
-				__func__);
-
-		if (evrc->cfg.min_bit_rate > 4 || evrc->cfg.min_bit_rate < 1) {
-			pr_err("[%s:%s] invalid min bitrate\n", __MM_FILE__,
-					__func__);
-			rc = -EINVAL;
-		}
-		if (evrc->cfg.max_bit_rate > 4 || evrc->cfg.max_bit_rate < 1) {
-			pr_err("[%s:%s] invalid max bitrate\n", __MM_FILE__,
-					__func__);
-			rc = -EINVAL;
-		}
-		break;
-	case AUDIO_GET_EVRC_ENC_CONFIG:
-		if (copy_to_user((void *) arg, &evrc->cfg,
-				 sizeof(struct msm_audio_evrc_enc_config)))
-			rc = -EFAULT;
-		pr_debug("[%s:%s] GET_EVRC_ENC_CONFIG\n", __MM_FILE__,
-			__func__);
-		break;
-
-	default:
-		rc = -EINVAL;
-	}
-
-	mutex_unlock(&evrc->lock);
-	pr_debug("[%s:%s] rc = %d\n", __MM_FILE__, __func__, rc);
-	return rc;
-}
-
-static int q6_evrc_in_open(struct inode *inode, struct file *file)
-{
-	struct evrc *evrc;
-	struct evrc_fc *fc;
-	int i;
-
-	pr_info("[%s:%s] open\n", __MM_FILE__, __func__);
-	evrc = kmalloc(sizeof(struct evrc), GFP_KERNEL);
-	if (evrc == NULL) {
-		pr_err("[%s:%s] Could not allocate memory for evrc driver\n",
-				__MM_FILE__, __func__);
-		return -ENOMEM;
-	}
-
-	mutex_init(&evrc->lock);
-	file->private_data = evrc;
-	evrc->audio_client = NULL;
-	evrc->str_cfg.buffer_size = 23;
-	evrc->str_cfg.buffer_count = 2;
-	evrc->cfg.cdma_rate = CDMA_RATE_FULL;
-	evrc->cfg.min_bit_rate = 1;
-	evrc->cfg.max_bit_rate = 4;
-	evrc->voicerec_mode.rec_mode = AUDIO_FLAG_READ;
-
-	evrc->evrc_fc = kmalloc(sizeof(struct evrc_fc), GFP_KERNEL);
-	if (evrc->evrc_fc == NULL) {
-		pr_err("[%s:%s] Could not allocate memory for evrc_fc\n",
-				__MM_FILE__, __func__);
-		kfree(evrc);
-		return -ENOMEM;
-	}
-	fc = evrc->evrc_fc;
-	fc->task = NULL;
-	fc->buff_index = 0;
-	for (i = 0; i < EVRC_FC_BUFF_CNT; ++i) {
-		fc->fc_buff[i].data = NULL;
-		fc->fc_buff[i].size = 0;
-		fc->fc_buff[i].actual_size = 0;
-	}
-	/*initialize wait queue head*/
-	init_waitqueue_head(&fc->fc_wq);
-	return 0;
-}
-
-static ssize_t q6_evrc_in_read(struct file *file, char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct audio_client *ac;
-	const char __user *start = buf;
-	struct evrc *evrc = file->private_data;
-	struct evrc_fc *fc;
-	int xfer = 0;
-	int res = 0;
-
-	pr_debug("[%s:%s] count = %d\n", __MM_FILE__, __func__, count);
-	mutex_lock(&evrc->lock);
-	ac = evrc->audio_client;
-	if (!ac) {
-		res = -ENODEV;
-		goto fail;
-	}
-	fc = evrc->evrc_fc;
-	while (count > xfer) {
-		/*wait for buffer to full*/
-		if (fc->fc_buff[fc->buff_index].empty != 0) {
-			res = wait_event_interruptible_timeout(fc->fc_wq,
-				(fc->fc_buff[fc->buff_index].empty == 0),
-				msecs_to_jiffies(EVRC_READ_TIMEOUT));
-
-			pr_debug("[%s:%s] buff_index = %d\n", __MM_FILE__,
-				__func__, fc->buff_index);
-			if (res == 0) {
-				pr_err("[%s:%s] Timeout!\n", __MM_FILE__,
-						__func__);
-				res = -ETIMEDOUT;
-				goto fail;
-			} else if (res < 0) {
-				pr_err("[%s:%s] Returning on Interrupt\n",
-					__MM_FILE__, __func__);
-				goto fail;
-			}
-		}
-		/*lock the buffer*/
-		mutex_lock(&(fc->fc_buff[fc->buff_index].lock));
-		xfer = fc->fc_buff[fc->buff_index].actual_size;
-
-		if (xfer > count) {
-			mutex_unlock(&(fc->fc_buff[fc->buff_index].lock));
-			pr_err("[%s:%s] read failed! byte count too small\n",
-					__MM_FILE__, __func__);
-			res = -EINVAL;
-			goto fail;
-		}
-
-		if (copy_to_user(buf, fc->fc_buff[fc->buff_index].data,	xfer)) {
-			mutex_unlock(&(fc->fc_buff[fc->buff_index].lock));
-			pr_err("[%s:%s] copy_to_user failed at index %d\n",
-					__MM_FILE__, __func__, fc->buff_index);
-			res = -EFAULT;
-			goto fail;
-		}
-		buf += xfer;
-		count -= xfer;
-
-		fc->fc_buff[fc->buff_index].empty = 1;
-		fc->fc_buff[fc->buff_index].actual_size = 0;
-
-		mutex_unlock(&(fc->fc_buff[fc->buff_index].lock));
-		++(fc->buff_index);
-		if (fc->buff_index >= EVRC_FC_BUFF_CNT)
-			fc->buff_index = 0;
-	}
-	res = buf - start;
-
-fail:
-	mutex_unlock(&evrc->lock);
-
-	return res;
-}
-
-static int q6_evrc_in_release(struct inode *inode, struct file *file)
-{
-	int rc = 0;
-	struct evrc *evrc = file->private_data;
-	int i = 0;
-	struct evrc_fc *fc;
-
-	mutex_lock(&evrc->lock);
-	fc = evrc->evrc_fc;
-	kthread_stop(fc->task);
-	fc->task = NULL;
-	/*free flow control buffers*/
-	for (i = 0; i < EVRC_FC_BUFF_CNT; ++i) {
-		kfree(fc->fc_buff[i].data);
-		fc->fc_buff[i].data = NULL;
-	}
-	kfree(fc);
-	if (evrc->audio_client)
-		rc = q6audio_close(evrc->audio_client);
-	mutex_unlock(&evrc->lock);
-	kfree(evrc);
-	pr_info("[%s:%s] release\n", __MM_FILE__, __func__);
-	return rc;
-}
-
-static const struct file_operations q6_evrc_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= q6_evrc_in_open,
-	.read		= q6_evrc_in_read,
-	.release	= q6_evrc_in_release,
-	.unlocked_ioctl	= q6_evrc_in_ioctl,
-};
-
-struct miscdevice q6_evrc_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_evrc_in",
-	.fops	= &q6_evrc_in_fops,
-};
-
-static int __init q6_evrc_in_init(void)
-{
-	return misc_register(&q6_evrc_in_misc);
-}
-
-device_initcall(q6_evrc_in_init);
diff --git a/arch/arm/mach-msm/qdsp6/mp3.c b/arch/arm/mach-msm/qdsp6/mp3.c
deleted file mode 100644
index 16f6204..0000000
--- a/arch/arm/mach-msm/qdsp6/mp3.c
+++ /dev/null
@@ -1,249 +0,0 @@
-/* arch/arm/mach-msm/qdsp6/mp3.c
- *
- * Copyright (C) 2009 Google, Inc.
- * Copyright (C) 2009 HTC Corporation
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/slab.h>
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/uaccess.h>
-
-#include <linux/msm_audio.h>
-
-#include <mach/msm_qdsp6_audio.h>
-#include <mach/debug_mm.h>
-
-#define BUFSZ (8192)
-#define DMASZ (BUFSZ * 2)
-
-struct mp3 {
-	struct mutex lock;
-	struct audio_client *ac;
-	uint32_t sample_rate;
-	uint32_t channel_count;
-};
-
-static long mp3_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct mp3 *mp3 = file->private_data;
-	int rc = 0;
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		memset(&stats, 0, sizeof(stats));
-		if (copy_to_user((void*) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-
-	mutex_lock(&mp3->lock);
-	switch (cmd) {
-	case AUDIO_SET_VOLUME: {
-		int vol;
-		pr_debug("[%s:%s] SET_VOLUME = %d\n", __MM_FILE__,
-			__func__, vol);
-		if (copy_from_user(&vol, (void*) arg, sizeof(vol))) {
-			rc = -EFAULT;
-			break;
-		}
-		rc = q6audio_set_stream_volume(mp3->ac, vol);
-		break;
-	}
-	case AUDIO_START: {
-		uint32_t acdb_id;
-		pr_debug("[%s:%s] AUDIO_START\n", __MM_FILE__, __func__);
-		if (arg == 0) {
-			acdb_id = 0;
-		} else if (copy_from_user(&acdb_id, (void*) arg, sizeof(acdb_id))) {
-			pr_info("[%s:%s] copy acdb_id from user failed\n",
-					__MM_FILE__, __func__);
-			rc = -EFAULT;
-			break;
-		}
-		if (mp3->ac) {
-			pr_err("[%s:%s] active session already existing\n",
-				__MM_FILE__, __func__);
-			rc = -EBUSY;
-		} else {
-			mp3->ac = q6audio_open_mp3(BUFSZ,
-				mp3->sample_rate, mp3->channel_count, acdb_id);
-			if (!mp3->ac) {
-				pr_err("[%s:%s] mp3 open session failed\n",
-					__MM_FILE__, __func__);
-				rc = -ENOMEM;
-			}
-		}
-		break;
-	}
-	case AUDIO_STOP:
-		pr_debug("[%s:%s] AUDIO_STOP\n", __MM_FILE__, __func__);
-		break;
-	case AUDIO_FLUSH:
-		break;
-	case AUDIO_SET_CONFIG: {
-		struct msm_audio_config config;
-		if (mp3->ac) {
-			rc = -EBUSY;
-			pr_err("[%s:%s] active session already existing\n",
-				__MM_FILE__, __func__);
-			break;
-		}
-		if (copy_from_user(&config, (void*) arg, sizeof(config))) {
-			rc = -EFAULT;
-			break;
-		}
-		pr_debug("[%s:%s] SET_CONFIG: buffsize = %d, samplerate = %d, \
-			channelcount = %d\n", __MM_FILE__, __func__,
-			config.buffer_size, config.sample_rate,
-			config.channel_count);
-		if (config.channel_count < 1 || config.channel_count > 2) {
-			rc = -EINVAL;
-			pr_err("[%s:%s] invalid channelcount\n", __MM_FILE__,
-				__func__);
-			break;
-		}
-		mp3->sample_rate = config.sample_rate;
-		mp3->channel_count = config.channel_count;
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config config;
-		config.buffer_size = BUFSZ;
-		config.buffer_count = 2;
-		config.sample_rate = mp3->sample_rate;
-		config.channel_count = mp3->channel_count;
-		config.unused[0] = 0;
-		config.unused[1] = 0;
-		config.unused[2] = 0;
-		if (copy_to_user((void*) arg, &config, sizeof(config))) {
-			rc = -EFAULT;
-		}
-		pr_debug("[%s:%s] GET_CONFIG: buffsize = %d, samplerate = %d, \
-			channelcount = %d\n", __MM_FILE__, __func__,
-			config.buffer_size, config.sample_rate,
-			config.channel_count);
-		break;
-	}
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&mp3->lock);
-	pr_debug("[%s:%s] rc = %d\n", __MM_FILE__, __func__, rc);
-	return rc;
-}
-
-static int mp3_open(struct inode *inode, struct file *file)
-{
-	int rc = 0;
-
-	struct mp3 *mp3;
-	pr_info("[%s:%s] open\n", __MM_FILE__, __func__);
-	mp3 = kzalloc(sizeof(struct mp3), GFP_KERNEL);
-
-	if (!mp3)
-		return -ENOMEM;
-
-	mutex_init(&mp3->lock);
-	mp3->channel_count = 2;
-	mp3->sample_rate = 44100;
-
-	file->private_data = mp3;
-	return rc;
-}
-
-static ssize_t mp3_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct mp3 *mp3 = file->private_data;
-	struct audio_client *ac;
-	struct audio_buffer *ab;
-	const char __user *start = buf;
-	int xfer;
-
-	pr_debug("[%s:%s] count = %d\n", __MM_FILE__, __func__, count);
-	if (!mp3->ac)
-		mp3_ioctl(file, AUDIO_START, 0);
-
-	ac = mp3->ac;
-	if (!ac)
-		return -ENODEV;
-
-	while (count > 0) {
-		ab = ac->buf + ac->cpu_buf;
-
-		if (ab->used)
-			wait_event(ac->wait, (ab->used == 0));
-
-		pr_debug("[%s:%s] ab->data = %p, ac->cpu_buf = %d\n",
-			__MM_FILE__, __func__, ab->data, ac->cpu_buf);
-		xfer = count;
-		if (xfer > ab->size)
-			xfer = ab->size;
-
-		if (copy_from_user(ab->data, buf, xfer))
-			return -EFAULT;
-
-		buf += xfer;
-		count -= xfer;
-
-		ab->used = xfer;
-		q6audio_write(ac, ab);
-		ac->cpu_buf ^= 1;
-	}
-
-	return buf - start;
-}
-
-static int mp3_fsync(struct file *f, int datasync)
-{
-	struct mp3 *mp3 = f->private_data;
-	if (mp3->ac)
-		return q6audio_async(mp3->ac);
-	return -ENODEV;
-}
-
-static int mp3_release(struct inode *inode, struct file *file)
-{
-	struct mp3 *mp3 = file->private_data;
-	if (mp3->ac)
-		q6audio_mp3_close(mp3->ac);
-	kfree(mp3);
-	pr_info("[%s:%s] release\n", __MM_FILE__, __func__);
-	return 0;
-}
-
-static struct file_operations mp3_fops = {
-	.owner		= THIS_MODULE,
-	.open		= mp3_open,
-	.write		= mp3_write,
-	.fsync		= mp3_fsync,
-	.release	= mp3_release,
-	.unlocked_ioctl	= mp3_ioctl,
-};
-
-struct miscdevice mp3_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_mp3",
-	.fops	= &mp3_fops,
-};
-
-static int __init mp3_init(void) {
-	return misc_register(&mp3_misc);
-}
-
-device_initcall(mp3_init);
diff --git a/arch/arm/mach-msm/qdsp6/msm_q6vdec.c b/arch/arm/mach-msm/qdsp6/msm_q6vdec.c
deleted file mode 100644
index 1cb9775..0000000
--- a/arch/arm/mach-msm/qdsp6/msm_q6vdec.c
+++ /dev/null
@@ -1,1509 +0,0 @@
-/* Copyright (c) 2008-2010, The Linux Foundation. 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_TRACE_VDEC
-#define DEBUG
-*/
-
-#include <linux/slab.h>
-#include <linux/cdev.h>
-#include <linux/delay.h>
-#include <linux/file.h>
-#include <linux/fs.h>
-#include <linux/list.h>
-#include <linux/miscdevice.h>
-#include <linux/module.h>
-#include <linux/mutex.h>
-#include <linux/platform_device.h>
-#include <linux/sched.h>
-#include <linux/spinlock.h>
-#include <linux/uaccess.h>
-#include <linux/wakelock.h>
-#include <linux/pm_qos.h>
-
-#include <linux/msm_q6vdec.h>
-
-#include <mach/cpuidle.h>
-
-#include "dal.h"
-
-#define DALDEVICEID_VDEC_DEVICE		0x02000026
-#define DALDEVICEID_VDEC_PORTNAME	"DAL_AQ_VID"
-
-#define VDEC_INTERFACE_VERSION		0x00020000
-
-#define MAJOR_MASK			0xFFFF0000
-#define MINOR_MASK			0x0000FFFF
-
-#define VDEC_GET_MAJOR_VERSION(version)	(((version)&MAJOR_MASK)>>16)
-
-#define VDEC_GET_MINOR_VERSION(version)	((version)&MINOR_MASK)
-
-#ifdef DEBUG_TRACE_VDEC
-#define TRACE(fmt,x...)			\
-	do { pr_debug("%s:%d " fmt, __func__, __LINE__, ##x); } while (0)
-#else
-#define TRACE(fmt,x...)		do { } while (0)
-#endif
-
-#define YAMATO_COLOR_FORMAT  0x02
-#define MAX_Q6_LOAD        ((720*1280)/256)  /* 720p */
-#define MAX_Q6_LOAD_YAMATO ((736*1280)/256)
-#define MAX_Q6_LOAD_VP6    ((800*480)/256)
-
-#define VDEC_MAX_PORTS 4
-
-/*
- *why magic number 300?
-
- *the Maximum size of the DAL payload is 512 bytes according to DAL protocol
- *Initialize call to QDSP6 from scorpion need to send sequence header as part of
- *the DAL payload. DAL payload to initialize contains the following
-
- *1) configuration data- 52 bytes 2) length field of config data - 4 bytes
- *3) sequence header data ( that is from the bit stream)
- *4) length field for sequence header - 4 bytes
- *5) length field for output structure - 4 bytes
-
- *that left with 512 - 68 = 448 bytes. It is unusual that we get a sequence
- *header with such a big length unless the bit stream has multiple sequence
- *headers.We estimated 300 is good enough which gives enough room for rest
- *of the payload and even reserves some space for future payload.
- */
-
-#define VDEC_MAX_SEQ_HEADER_SIZE 300
-
-char *Q6Portnames[] = {
-"DAL_AQ_VID_0",
-"DAL_AQ_VID_1",
-"DAL_AQ_VID_2",
-"DAL_AQ_VID_3"
-};
-
-
-
-#define DALDEVICEID_VDEC_DEVICE_0        0x020000D2
-#define DALDEVICEID_VDEC_DEVICE_1        0x020000D3
-#define DALDEVICEID_VDEC_DEVICE_2        0x020000D4
-#define DALDEVICEID_VDEC_DEVICE_3        0x020000D5
-#define DALDEVICEID_VDEC_DEVICE_4        0x020000D6
-#define DALDEVICEID_VDEC_DEVICE_5        0x020000D7
-#define DALDEVICEID_VDEC_DEVICE_6        0x020000D8
-#define DALDEVICEID_VDEC_DEVICE_7        0x020000D9
-#define DALDEVICEID_VDEC_DEVICE_8        0x020000DA
-#define DALDEVICEID_VDEC_DEVICE_9        0x020000DB
-#define DALDEVICEID_VDEC_DEVICE_10        0x020000DC
-#define DALDEVICEID_VDEC_DEVICE_11        0x020000DD
-#define DALDEVICEID_VDEC_DEVICE_12        0x020000DE
-#define DALDEVICEID_VDEC_DEVICE_13        0x020000DF
-#define DALDEVICEID_VDEC_DEVICE_14        0x020000E0
-#define DALDEVICEID_VDEC_DEVICE_15        0x020000E1
-#define DALDEVICEID_VDEC_DEVICE_16        0x020000E2
-#define DALDEVICEID_VDEC_DEVICE_17        0x020000E3
-#define DALDEVICEID_VDEC_DEVICE_18        0x020000E4
-#define DALDEVICEID_VDEC_DEVICE_19        0x020000E5
-#define DALDEVICEID_VDEC_DEVICE_20        0x020000E6
-#define DALDEVICEID_VDEC_DEVICE_21        0x020000E7
-#define DALDEVICEID_VDEC_DEVICE_22        0x020000E8
-#define DALDEVICEID_VDEC_DEVICE_23        0x020000E9
-#define DALDEVICEID_VDEC_DEVICE_24        0x020000EA
-#define DALDEVICEID_VDEC_DEVICE_25        0x020000EB
-#define DALDEVICEID_VDEC_DEVICE_26        0x020000EC
-#define DALDEVICEID_VDEC_DEVICE_27        0x020000ED
-#define DALDEVICEID_VDEC_DEVICE_28        0x020000EE
-#define DALDEVICEID_VDEC_DEVICE_29        0x020000EF
-#define DALDEVICEID_VDEC_DEVICE_30        0x020000F0
-#define DALDEVICEID_VDEC_DEVICE_31        0x020000F1
-
-#define DALVDEC_MAX_DEVICE_IDS        32
-
-
-static int numOfPorts;
-
-
-static char loadOnPorts[VDEC_MAX_PORTS];
-
-static char deviceIdRegistry[DALVDEC_MAX_DEVICE_IDS];
-
-
-#define VDEC_DEVID_FREE 0
-#define VDEC_DEVID_OCCUPIED 1
-
-#define MAX_SUPPORTED_INSTANCES 6
-
-#define  MAKEFOURCC(ch0, ch1, ch2, ch3) ((unsigned int)(unsigned char)(ch0) | \
-	((unsigned int)(unsigned char)(ch1) << 8) | \
-	((unsigned int)(unsigned char)(ch2) << 16) | \
-	((unsigned int)(unsigned char)(ch3) << 24))
-
-#define FOURCC_MPEG4 MAKEFOURCC('m', 'p', '4', 'v')
-#define FOURCC_H263 MAKEFOURCC('h', '2', '6', '3')
-#define FOURCC_H264 MAKEFOURCC('h', '2', '6', '4')
-#define FOURCC_VC1 MAKEFOURCC('w', 'm', 'v', '3')
-#define FOURCC_DIVX MAKEFOURCC('D', 'I', 'V', 'X')
-#define FOURCC_SPARK MAKEFOURCC('F', 'L', 'V', '1')
-#define FOURCC_VP6 MAKEFOURCC('V', 'P', '6', '0')
-
-/* static struct vdec_data *multiInstances[MAX_SUPPORTED_INSTANCES];*/
-
-static int totalPlaybackQ6load;
-static int totalTnailQ6load;
-
-#define FLAG_THUMBNAIL_MODE  0x8
-#define MAX_TNAILS  3
-
-#define TRUE 1
-#define FALSE 0
-
-enum {
-	VDEC_DALRPC_INITIALIZE = DAL_OP_FIRST_DEVICE_API,
-	VDEC_DALRPC_SETBUFFERS,
-	VDEC_DALRPC_FREEBUFFERS,
-	VDEC_DALRPC_QUEUE,
-	VDEC_DALRPC_SIGEOFSTREAM,
-	VDEC_DALRPC_FLUSH,
-	VDEC_DALRPC_REUSEFRAMEBUFFER,
-	VDEC_DALRPC_GETDECATTRIBUTES,
-	VDEC_DALRPC_SUSPEND,
-	VDEC_DALRPC_RESUME,
-	VDEC_DALRPC_INITIALIZE_00,
-	VDEC_DALRPC_GETINTERNALBUFFERREQ,
-	VDEC_DALRPC_SETBUFFERS_00,
-	VDEC_DALRPC_FREEBUFFERS_00,
-	VDEC_DALRPC_GETPROPERTY,
-	VDEC_DALRPC_SETPROPERTY,
-	VDEC_DALRPC_GETDECATTRIBUTES_00,
-	VDEC_DALRPC_PERFORMANCE_CHANGE_REQUEST
-};
-
-enum {
-	VDEC_ASYNCMSG_DECODE_DONE = 0xdec0de00,
-	VDEC_ASYNCMSG_REUSE_FRAME,
-};
-
-struct vdec_init_cfg {
-	u32			decode_done_evt;
-	u32			reuse_frame_evt;
-	struct vdec_config	cfg;
-};
-
-struct vdec_buffer_status {
-	u32			data;
-	u32			status;
-};
-
-#define VDEC_MSG_MAX		128
-
-struct vdec_msg_list {
-	struct list_head	list;
-	struct vdec_msg		vdec_msg;
-};
-
-struct vdec_mem_info {
-	u32			buf_type;
-	u32			id;
-	unsigned long		phys_addr;
-	unsigned long		len;
-	struct file		*file;
-};
-
-struct vdec_mem_list {
-	struct list_head	list;
-	struct vdec_mem_info	mem;
-};
-
-struct videoStreamDetails{
-	int height;
-	int width;
-	unsigned int fourcc;
-	int Q6usage;
-	bool isThisTnail;
-	bool isTnailGranted;
-};
-
-struct vdec_data {
-	struct dal_client	*vdec_handle;
-	unsigned int Q6deviceId;
-	struct videoStreamDetails streamDetails;
-	struct list_head	vdec_msg_list_head;
-	struct list_head	vdec_msg_list_free;
-	wait_queue_head_t	vdec_msg_evt;
-	spinlock_t		vdec_list_lock;
-	struct list_head	vdec_mem_list_head;
-	spinlock_t		vdec_mem_list_lock;
-	int			mem_initialized;
-	int			running;
-	int			close_decode;
-};
-
-static struct class *driver_class;
-static dev_t vdec_device_no;
-static struct cdev vdec_cdev;
-static int ref_cnt;
-static DEFINE_MUTEX(vdec_ref_lock);
-
-static DEFINE_MUTEX(idlecount_lock);
-
-static DEFINE_MUTEX(vdec_rm_lock);
-
-static int idlecount;
-static struct wake_lock wakelock;
-static struct pm_qos_request pm_qos_req;
-
-static void prevent_sleep(void)
-{
-	mutex_lock(&idlecount_lock);
-	if (++idlecount == 1) {
-		pm_qos_update_request(&pm_qos_req,
-				      msm_cpuidle_get_deep_idle_latency());
-		wake_lock(&wakelock);
-	}
-	mutex_unlock(&idlecount_lock);
-}
-
-static void allow_sleep(void)
-{
-	mutex_lock(&idlecount_lock);
-	if (--idlecount == 0) {
-		wake_unlock(&wakelock);
-		pm_qos_update_request(&pm_qos_req, PM_QOS_DEFAULT_VALUE);
-	}
-	mutex_unlock(&idlecount_lock);
-}
-
-static inline int vdec_check_version(u32 client, u32 server)
-{
-	int ret = -EINVAL;
-	if ((VDEC_GET_MAJOR_VERSION(client) == VDEC_GET_MAJOR_VERSION(server))
-	    && (VDEC_GET_MINOR_VERSION(client) <=
-		VDEC_GET_MINOR_VERSION(server)))
-		ret = 0;
-	return ret;
-}
-
-static int vdec_get_msg(struct vdec_data *vd, void *msg)
-{
-	struct vdec_msg_list *l;
-	unsigned long flags;
-	int ret = 0;
-
-	if (!vd->running)
-		return -EPERM;
-
-	spin_lock_irqsave(&vd->vdec_list_lock, flags);
-	list_for_each_entry_reverse(l, &vd->vdec_msg_list_head, list) {
-		if (copy_to_user(msg, &l->vdec_msg, sizeof(struct vdec_msg)))
-			pr_err("vdec_get_msg failed to copy_to_user!\n");
-		if (l->vdec_msg.id == VDEC_MSG_REUSEINPUTBUFFER)
-			TRACE("reuse_input_buffer %d\n", l->vdec_msg.buf_id);
-		else if (l->vdec_msg.id == VDEC_MSG_FRAMEDONE)
-			TRACE("frame_done (stat=%d)\n",
-			      l->vdec_msg.vfr_info.status);
-		else
-			TRACE("unknown msg (msgid=%d)\n", l->vdec_msg.id);
-		list_del(&l->list);
-		list_add(&l->list, &vd->vdec_msg_list_free);
-		ret = 1;
-		break;
-	}
-	spin_unlock_irqrestore(&vd->vdec_list_lock, flags);
-
-	if (vd->close_decode)
-		ret = 1;
-
-	return ret;
-}
-
-static void vdec_put_msg(struct vdec_data *vd, struct vdec_msg *msg)
-{
-	struct vdec_msg_list *l;
-	unsigned long flags;
-	int found = 0;
-
-	spin_lock_irqsave(&vd->vdec_list_lock, flags);
-	list_for_each_entry(l, &vd->vdec_msg_list_free, list) {
-		memcpy(&l->vdec_msg, msg, sizeof(struct vdec_msg));
-		list_del(&l->list);
-		list_add(&l->list, &vd->vdec_msg_list_head);
-		found = 1;
-		break;
-	}
-	spin_unlock_irqrestore(&vd->vdec_list_lock, flags);
-
-	if (found)
-		wake_up(&vd->vdec_msg_evt);
-	else
-		pr_err("vdec_put_msg can't find free list!\n");
-}
-
-static struct vdec_mem_list *vdec_get_mem_from_list(struct vdec_data *vd,
-						    u32 pmem_id, u32 buf_type)
-{
-	struct vdec_mem_list *l;
-	unsigned long flags;
-	int found = 0;
-
-	spin_lock_irqsave(&vd->vdec_mem_list_lock, flags);
-	list_for_each_entry(l, &vd->vdec_mem_list_head, list) {
-		if (l->mem.buf_type == buf_type && l->mem.id == pmem_id) {
-			found = 1;
-			break;
-		}
-	}
-	spin_unlock_irqrestore(&vd->vdec_mem_list_lock, flags);
-
-	if (found)
-		return l;
-	else
-		return NULL;
-
-}
-static int vdec_setproperty(struct vdec_data *vd, void *argp)
-{
-	struct vdec_property_info property;
-	int res;
-
-   if (copy_from_user(&property, argp, sizeof(struct vdec_property_info)))
-		return -1;
-
-	res = dal_call_f6(vd->vdec_handle, VDEC_DALRPC_SETPROPERTY,
-      property.id, &(property.property), sizeof(union vdec_property));
-	if (res)
-		TRACE("Set Property failed");
-	else
-		TRACE("Set Property succeeded");
-	return res;
-}
-static int vdec_getproperty(struct vdec_data *vd, void *argp)
-{
-	int res;
-	union vdec_property property = {0};
-
-	res = dal_call_f11(vd->vdec_handle, VDEC_DALRPC_GETPROPERTY,
-		((struct vdec_property_info *)argp)->id, &property,
-		sizeof(union vdec_property));
-
-	if (res)
-		TRACE("get Property failed");
-	else
-		TRACE("get Property succeeded");
-
-	res = copy_to_user(
-		(&((struct vdec_property_info *)argp)->property),
-		&property, sizeof(property));
-
-	return res;
-}
-static int vdec_performance_change_request(struct vdec_data *vd, void* argp)
-{
-	u32 request_type;
-	int ret;
-
-	ret = copy_from_user(&request_type, argp, sizeof(request_type));
-	if (ret) {
-		pr_err("%s: copy_from_user failed\n", __func__);
-		return ret;
-	}
-	ret = dal_call_f0(vd->vdec_handle,
-			VDEC_DALRPC_PERFORMANCE_CHANGE_REQUEST,
-			request_type);
-	if (ret) {
-		pr_err("%s: remote function failed (%d)\n", __func__, ret);
-		return ret;
-	}
-	return ret;
-}
-
-#ifdef TRACE_PORTS
-static void printportsanddeviceids(void)
-{
-	int i;
-
-	pr_err("\n\n%s:loadOnPorts", __func__);
-	for (i = 0; i < numOfPorts; i++)
-		pr_err("\t%d", loadOnPorts[i]);
-
-	pr_err("\n\n");
-
-	pr_err("\n\n%s:Devids", __func__);
-	for (i = 0; i < DALVDEC_MAX_DEVICE_IDS; i++)
-		pr_err("Devid[%d]:%d\n", i, deviceIdRegistry[i]);
-
-
-	pr_err("\n\n");
-}
-#endif /*TRACE_PORTS*/
-
-
-/*
- *
- * This method is used to get the number of ports supported on the Q6
- *
- */
-static int vdec_get_numberofq6ports(void)
-{
-	struct dal_client *vdec_handle = NULL;
-	int retval = 0;
-	union vdec_property property = {0};
-
-	vdec_handle = dal_attach(DALDEVICEID_VDEC_DEVICE,
-			     DALDEVICEID_VDEC_PORTNAME, 1, NULL, NULL);
-	if (!vdec_handle) {
-		pr_err("%s: failed to attach\n", __func__);
-		return 1;/* default setting */
-	}
-
-	retval = dal_call_f6(vdec_handle, VDEC_DALRPC_GETPROPERTY,
-      VDEC_NUM_DAL_PORTS, (void *)&property, sizeof(union vdec_property));
-	if (retval) {
-		pr_err("%s: Q6get prperty failed\n", __func__);
-		return 1;/* default setting */
-	}
-
-	dal_detach(vdec_handle);
-	return property.num_dal_ports ;
-}
-
-
-/**
-  * This method is used to get the find the least loaded port and a corresponding
-  * free device id in that port.
-  *
-  * Prerequisite: vdec_open should have been called.
-  *
-  *  @param[in] deviceid
-  *     device id will be populated here.
-  *
-  *  @param[in] portname
-  *     portname will be populated here.
-  */
-static void vdec_get_next_portanddevid(int *deviceid, char **portname)
-{
-
-	int i = 0;
-	int leastLoad = 0;
-	int leastLoadedIndex = 0;
-
-	if (0 == numOfPorts) {
-		numOfPorts = vdec_get_numberofq6ports();
-		pr_err("%s: Q6get numOfPorts %d\n", __func__, numOfPorts);
-		numOfPorts = 4;
-		/*fix: me currently hard coded to 4 as
-		 *the Q6 getproperty is failing
-		 */
-	}
-
-	if ((NULL == deviceid) || (NULL == portname))
-		return;
-	else
-		*deviceid = 0; /* init value */
-
-	if (numOfPorts > 1) {
-		/* multi ports mode*/
-
-		/* find the least loaded port*/
-		for (i = 1, leastLoad = loadOnPorts[0], leastLoadedIndex = 0;
-					i < numOfPorts; i++) {
-			if (leastLoad > loadOnPorts[i]) {
-				leastLoadedIndex = i;
-				leastLoad = loadOnPorts[i];
-			}
-		}
-
-		/* register the load */
-		loadOnPorts[leastLoadedIndex]++;
-		*portname = Q6Portnames[leastLoadedIndex];
-
-		/* find a free device id corresponding to the port*/
-		for (i = leastLoadedIndex; i < DALVDEC_MAX_DEVICE_IDS;
-					i += numOfPorts) {
-			if (VDEC_DEVID_FREE == deviceIdRegistry[i]) {
-				deviceIdRegistry[i] = VDEC_DEVID_OCCUPIED;
-				*deviceid = DALDEVICEID_VDEC_DEVICE_0 + i;
-				break;
-			}
-		}
-
-#ifdef TRACE_PORTS
-		printportsanddeviceids();
-#endif /*TRACE_PORTS*/
-	} else if (1 == numOfPorts) {
-		/* single port mode */
-		*deviceid = DALDEVICEID_VDEC_DEVICE;
-		*portname = DALDEVICEID_VDEC_PORTNAME;
-	} else if (numOfPorts <= 0) {
-		pr_err("%s: FATAL error numOfPorts cannot be \
-			less than or equal to zero\n", __func__);
-	}
-
-
-}
-
-
-/**
-  * This method frees up the used dev id and decrements the port load.
-  *
-  */
-
-static void vdec_freeup_portanddevid(int deviceid)
-{
-
-	if (numOfPorts > 1) {
-		/* multi ports mode*/
-		if (VDEC_DEVID_FREE ==
-			deviceIdRegistry[deviceid - DALDEVICEID_VDEC_DEVICE_0])
-			pr_err("device id cannot be already free\n");
-		deviceIdRegistry[deviceid - DALDEVICEID_VDEC_DEVICE_0] =
-			VDEC_DEVID_FREE;
-
-		loadOnPorts[(deviceid - DALDEVICEID_VDEC_DEVICE_0)
-			% numOfPorts]--;
-
-		if (loadOnPorts[(deviceid - DALDEVICEID_VDEC_DEVICE_0)
-			% numOfPorts] < 0)
-			pr_err("Warning:load cannot be negative\n");
-
-		pr_err("dettaching on deviceid %x portname %s\n", deviceid,
-			Q6Portnames[(deviceid - DALDEVICEID_VDEC_DEVICE_0)
-			% numOfPorts]);
-
-#ifdef TRACE_PORTS
-		printportsanddeviceids();
-#endif /*TRACE_PORTS*/
-	} else {
-		/*single port mode, nothing to be done here*/
-	}
-
-}
-
-
-/**
-  * This method validates whether a new instance can be houred or not.
-  *
-  */
-static int vdec_rm_checkWithRm(struct vdec_data *vdecInstance,
-				unsigned int color_format)
-{
-
-	unsigned int maxQ6load = 0;/* in the units of macro blocks per second */
-	unsigned int currentq6load = 0;
-	struct videoStreamDetails *streamDetails = &vdecInstance->streamDetails;
-
-
-
-	if (streamDetails->isThisTnail) {
-		if (totalTnailQ6load < MAX_TNAILS) {
-
-			totalTnailQ6load++;
-			streamDetails->isTnailGranted = TRUE;
-			pr_info("%s: thumbnail granted %d\n", __func__,
-				totalTnailQ6load);
-			return 0;
-
-		} else {
-
-			pr_err("%s: thumbnails load max this instance cannot \
-					be supported\n", __func__);
-			streamDetails->isTnailGranted = FALSE;
-			return -ENOSPC;
-
-		}
-	}
-
-	/* calculate the Q6 percentage instance would need */
-	if ((streamDetails->fourcc == FOURCC_MPEG4) ||
-		 (streamDetails->fourcc  == FOURCC_H264) ||
-		 (streamDetails->fourcc  == FOURCC_DIVX) ||
-		 (streamDetails->fourcc  == FOURCC_VC1) ||
-		 (streamDetails->fourcc  == FOURCC_SPARK) ||
-		 (streamDetails->fourcc  == FOURCC_H263)
-		){
-
-		/* is yamato color format,
-		  Rounds the H & W --> mutiple of 32 */
-		if (color_format == YAMATO_COLOR_FORMAT)
-			maxQ6load = MAX_Q6_LOAD_YAMATO;
-		else
-			maxQ6load = MAX_Q6_LOAD; /* 720p */
-
-	} else if (streamDetails->fourcc  == FOURCC_VP6) {
-
-		maxQ6load = MAX_Q6_LOAD_VP6;    /* FWVGA */
-
-	} else {
-
-		pr_err("%s: unknown fourcc %d  maxQ6load %u\n", __func__,
-			streamDetails->fourcc, maxQ6load);
-		return -EINVAL;
-
-	}
-
-	currentq6load = ((streamDetails->height)*(streamDetails->width) / 256);
-	currentq6load = ((currentq6load * 100)/maxQ6load);
-	if ((currentq6load+totalPlaybackQ6load) > 100) {
-		/* reject this instance */
-		pr_err("%s: too much Q6load [cur+tot] = [%d + %d] = %d",
-		__func__, currentq6load, totalPlaybackQ6load,
-		(currentq6load+totalPlaybackQ6load));
-		pr_err("rejecting the instance,[WxH] = [%d x %d],color_fmt=0x%x\n",
-		streamDetails->width, streamDetails->height, color_format);
-		pr_err("VDEC_fmt=%s\n", (char *)(&streamDetails->fourcc));
-		streamDetails->Q6usage = 0;
-		return -ENOSPC;
-	}
-
-	totalPlaybackQ6load += currentq6load;
-	streamDetails->Q6usage = currentq6load;
-
-	pr_info("%s: adding a load [%d%%] bringing total Q6load to [%d%%]\n",
-		__func__, currentq6load, totalPlaybackQ6load);
-
-	return 0;
-}
-
-
-static int vdec_initialize(struct vdec_data *vd, void *argp)
-{
-	struct vdec_config_sps vdec_cfg_sps;
-	struct vdec_init_cfg vi_cfg;
-	struct vdec_buf_req vdec_buf_req;
-	struct u8 *header;
-	int ret = 0;
-
-	ret = copy_from_user(&vdec_cfg_sps,
-			     &((struct vdec_init *)argp)->sps_cfg,
-			     sizeof(vdec_cfg_sps));
-
-	if (ret) {
-		pr_err("%s: copy_from_user failed\n", __func__);
-		return ret;
-	}
-
-	vi_cfg.decode_done_evt = VDEC_ASYNCMSG_DECODE_DONE;
-	vi_cfg.reuse_frame_evt = VDEC_ASYNCMSG_REUSE_FRAME;
-	memcpy(&vi_cfg.cfg, &vdec_cfg_sps.cfg, sizeof(struct vdec_config));
-
-	/*
-	 * restricting the max value of the seq header
-	 */
-	if (vdec_cfg_sps.seq.len > VDEC_MAX_SEQ_HEADER_SIZE)
-		vdec_cfg_sps.seq.len = VDEC_MAX_SEQ_HEADER_SIZE;
-
-	header = kmalloc(vdec_cfg_sps.seq.len, GFP_KERNEL);
-	if (!header) {
-		pr_err("%s: kmalloc failed\n", __func__);
-		return -ENOMEM;
-	}
-
-	ret = copy_from_user(header,
-			     ((struct vdec_init *)argp)->sps_cfg.seq.header,
-			     vdec_cfg_sps.seq.len);
-
-	if (ret) {
-		pr_err("%s: copy_from_user failed\n", __func__);
-		kfree(header);
-		return ret;
-	}
-
-	TRACE("vi_cfg: handle=%p fourcc=0x%x w=%d h=%d order=%d notify_en=%d "
-	      "vc1_rb=%d h264_sd=%d h264_nls=%d pp_flag=%d fruc_en=%d\n",
-	      vd->vdec_handle, vi_cfg.cfg.fourcc, vi_cfg.cfg.width,
-	      vi_cfg.cfg.height, vi_cfg.cfg.order, vi_cfg.cfg.notify_enable,
-	      vi_cfg.cfg.vc1_rowbase, vi_cfg.cfg.h264_startcode_detect,
-	      vi_cfg.cfg.h264_nal_len_size, vi_cfg.cfg.postproc_flag,
-	      vi_cfg.cfg.fruc_enable);
-
-	vd->streamDetails.height = vi_cfg.cfg.height;
-	vd->streamDetails.width = vi_cfg.cfg.width;
-	vd->streamDetails.fourcc = vi_cfg.cfg.fourcc;
-	if (FLAG_THUMBNAIL_MODE == vi_cfg.cfg.postproc_flag)
-		vd->streamDetails.isThisTnail = TRUE;
-	else
-		vd->streamDetails.isThisTnail = FALSE;
-
-	mutex_lock(&vdec_rm_lock);
-	ret = vdec_rm_checkWithRm(vd, vi_cfg.cfg.color_format);
-	mutex_unlock(&vdec_rm_lock);
-	if (ret)
-		return ret;
-
-	ret = dal_call_f13(vd->vdec_handle, VDEC_DALRPC_INITIALIZE,
-			   &vi_cfg, sizeof(vi_cfg),
-			   header, vdec_cfg_sps.seq.len,
-			   &vdec_buf_req, sizeof(vdec_buf_req));
-
-	kfree(header);
-
-	if (ret)
-		pr_err("%s: remote function failed (%d)\n", __func__, ret);
-	else
-		ret = copy_to_user(((struct vdec_init *)argp)->buf_req,
-				   &vdec_buf_req, sizeof(vdec_buf_req));
-
-	vd->close_decode = 0;
-	return ret;
-}
-
-static void vdec_rm_freeupResources(struct vdec_data *vdecInstance)
-{
-	struct videoStreamDetails *streamDetails = &vdecInstance->streamDetails;
-
-
-
-	if ((streamDetails->isThisTnail) &&
-		 (streamDetails->isTnailGranted)) {
-
-			totalTnailQ6load--;
-			pr_info("%s: Thumbnail released %d\n", __func__,
-				totalTnailQ6load);
-
-	} else if (streamDetails->Q6usage > 0) {
-
-		totalPlaybackQ6load -= streamDetails->Q6usage;
-		if (totalPlaybackQ6load < 0)
-			pr_err("Warning:Q6load cannot be negative\n");
-
-		pr_info("%s:Releasing [%d%%] of Q6load from a total of [%d%%]\n"
-			, __func__, streamDetails->Q6usage,
-			(streamDetails->Q6usage+totalPlaybackQ6load));
-	}
-
-}
-
-static int vdec_setbuffers(struct vdec_data *vd, void *argp)
-{
-	struct vdec_buffer vmem;
-	struct vdec_mem_list *l;
-	unsigned long vstart;
-	unsigned long flags;
-	struct {
-		uint32_t size;
-		struct vdec_buf_info buf;
-	} rpc;
-	uint32_t res;
-
-	int ret = 0;
-
-	vd->mem_initialized = 0;
-
-	ret = copy_from_user(&vmem, argp, sizeof(vmem));
-	if (ret) {
-		pr_err("%s: copy_from_user failed\n", __func__);
-		return ret;
-	}
-
-	l = kzalloc(sizeof(struct vdec_mem_list), GFP_KERNEL);
-	if (!l) {
-		pr_err("%s: kzalloc failed!\n", __func__);
-		return -ENOMEM;
-	}
-
-	l->mem.id = vmem.pmem_id;
-	l->mem.buf_type = vmem.buf.buf_type;
-
-	ret = get_pmem_file(l->mem.id, &l->mem.phys_addr, &vstart,
-			    &l->mem.len, &l->mem.file);
-	if (ret) {
-		pr_err("%s: get_pmem_fd failed\n", __func__);
-		goto err_get_pmem_file;
-	}
-
-	TRACE("pmem_id=%d (phys=0x%08lx len=0x%lx) buftype=%d num_buf=%d "
-	      "islast=%d src_id=%d offset=0x%08x size=0x%x\n",
-	      vmem.pmem_id, l->mem.phys_addr, l->mem.len,
-	      vmem.buf.buf_type, vmem.buf.num_buf, vmem.buf.islast,
-	      vmem.buf.region.src_id, vmem.buf.region.offset,
-	      vmem.buf.region.size);
-
-	/* input buffers */
-	if ((vmem.buf.region.offset + vmem.buf.region.size) > l->mem.len) {
-		pr_err("%s: invalid input buffer offset!\n", __func__);
-		ret = -EINVAL;
-		goto err_bad_offset;
-
-	}
-	vmem.buf.region.offset += l->mem.phys_addr;
-
-	rpc.size = sizeof(vmem.buf);
-	memcpy(&rpc.buf, &vmem.buf, sizeof(struct vdec_buf_info));
-
-
-	ret = dal_call(vd->vdec_handle, VDEC_DALRPC_SETBUFFERS, 5,
-		       &rpc, sizeof(rpc), &res, sizeof(res));
-
-	if (ret < 4) {
-		pr_err("%s: remote function failed (%d)\n", __func__, ret);
-		ret = -EIO;
-		goto err_dal_call;
-	}
-
-	spin_lock_irqsave(&vd->vdec_mem_list_lock, flags);
-	list_add(&l->list, &vd->vdec_mem_list_head);
-	spin_unlock_irqrestore(&vd->vdec_mem_list_lock, flags);
-
-	vd->mem_initialized = 1;
-	return ret;
-
-err_dal_call:
-err_bad_offset:
-	put_pmem_file(l->mem.file);
-err_get_pmem_file:
-	kfree(l);
-	return ret;
-}
-
-static int vdec_queue(struct vdec_data *vd, void *argp)
-{
-	struct {
-		uint32_t size;
-		struct vdec_input_buf_info buf_info;
-		uint32_t osize;
-	} rpc;
-	struct vdec_mem_list *l;
-	struct {
-		uint32_t result;
-		uint32_t size;
-		struct vdec_queue_status status;
-	} rpc_res;
-
-	u32 pmem_id;
-	int ret = 0;
-
-	if (!vd->mem_initialized) {
-		pr_err("%s: memory is not being initialized!\n", __func__);
-		return -EPERM;
-	}
-
-	ret = copy_from_user(&rpc.buf_info,
-			     &((struct vdec_input_buf *)argp)->buffer,
-			     sizeof(rpc.buf_info));
-	if (ret) {
-		pr_err("%s: copy_from_user failed\n", __func__);
-		return ret;
-	}
-
-	ret = copy_from_user(&pmem_id,
-			     &((struct vdec_input_buf *)argp)->pmem_id,
-			     sizeof(u32));
-	if (ret) {
-		pr_err("%s: copy_from_user failed\n", __func__);
-		return ret;
-	}
-
-	l = vdec_get_mem_from_list(vd, pmem_id, VDEC_BUFFER_TYPE_INPUT);
-
-	if (NULL == l) {
-		pr_err("%s: not able to find the buffer from list\n", __func__);
-		return -EPERM;
-	}
-
-	if ((rpc.buf_info.size + rpc.buf_info.offset) >= l->mem.len) {
-		pr_err("%s: invalid queue buffer offset!\n", __func__);
-		return -EINVAL;
-	}
-
-	rpc.buf_info.offset += l->mem.phys_addr;
-	rpc.size = sizeof(struct vdec_input_buf_info);
-	rpc.osize = sizeof(struct vdec_queue_status);
-
-	/* complete the writes to the buffer */
-	wmb();
-	ret = dal_call(vd->vdec_handle, VDEC_DALRPC_QUEUE, 8,
-		       &rpc, sizeof(rpc), &rpc_res, sizeof(rpc_res));
-	if (ret < 4) {
-		pr_err("%s: remote function failed (%d)\n", __func__, ret);
-		ret = -EIO;
-	}
-	return ret;
-}
-
-static int vdec_reuse_framebuffer(struct vdec_data *vd, void *argp)
-{
-	u32 buf_id;
-	int ret = 0;
-
-	ret = copy_from_user(&buf_id, argp, sizeof(buf_id));
-	if (ret) {
-		pr_err("%s: copy_from_user failed\n", __func__);
-		return ret;
-	}
-
-	ret = dal_call_f0(vd->vdec_handle, VDEC_DALRPC_REUSEFRAMEBUFFER,
-			  buf_id);
-	if (ret)
-		pr_err("%s: remote function failed (%d)\n", __func__, ret);
-
-	return ret;
-}
-
-static int vdec_flush(struct vdec_data *vd, void *argp)
-{
-	u32 flush_type;
-	int ret = 0;
-
-	if (!vd->mem_initialized) {
-		pr_err("%s: memory is not being initialized!\n", __func__);
-		return -EPERM;
-	}
-
-	ret = copy_from_user(&flush_type, argp, sizeof(flush_type));
-	if (ret) {
-		pr_err("%s: copy_from_user failed\n", __func__);
-		return ret;
-	}
-
-	TRACE("flush_type=%d\n", flush_type);
-	ret = dal_call_f0(vd->vdec_handle, VDEC_DALRPC_FLUSH, flush_type);
-	if (ret) {
-		pr_err("%s: remote function failed (%d)\n", __func__, ret);
-		return ret;
-	}
-
-	return ret;
-}
-
-static int vdec_close(struct vdec_data *vd, void *argp)
-{
-	struct vdec_mem_list *l;
-	int ret = 0;
-
-	pr_info("q6vdec_close()\n");
-	vd->close_decode = 1;
-	wake_up(&vd->vdec_msg_evt);
-
-	ret = dal_call_f0(vd->vdec_handle, DAL_OP_CLOSE, 0);
-	if (ret)
-		pr_err("%s: failed to close daldevice (%d)\n", __func__, ret);
-
-	if (vd->mem_initialized) {
-		list_for_each_entry(l, &vd->vdec_mem_list_head, list)
-			put_pmem_file(l->mem.file);
-	}
-
-	return ret;
-}
-static int vdec_getdecattributes(struct vdec_data *vd, void *argp)
-{
-	struct {
-		uint32_t status;
-		uint32_t size;
-		struct vdec_dec_attributes dec_attr;
-	} rpc;
-	uint32_t inp;
-	int ret = 0;
-	inp = sizeof(struct vdec_dec_attributes);
-
-	ret = dal_call(vd->vdec_handle, VDEC_DALRPC_GETDECATTRIBUTES, 9,
-		       &inp, sizeof(inp), &rpc, sizeof(rpc));
-	if (ret < 4 || rpc.size != sizeof(struct vdec_dec_attributes)) {
-		pr_err("%s: remote function failed (%d)\n", __func__, ret);
-		ret = -EIO;
-	} else
-		ret =
-		    copy_to_user(((struct vdec_dec_attributes *)argp),
-				 &rpc.dec_attr, sizeof(rpc.dec_attr));
-	return ret;
-}
-
-static int vdec_freebuffers(struct vdec_data *vd, void *argp)
-{
-	struct vdec_buffer vmem;
-	struct vdec_mem_list *l;
-	struct {
-		uint32_t size;
-		struct vdec_buf_info buf;
-	} rpc;
-	uint32_t res;
-
-	int ret = 0;
-
-	if (!vd->mem_initialized) {
-		pr_err("%s: memory is not being initialized!\n", __func__);
-		return -EPERM;
-	}
-
-	ret = copy_from_user(&vmem, argp, sizeof(vmem));
-	if (ret) {
-		pr_err("%s: copy_from_user failed\n", __func__);
-		return ret;
-	}
-
-	l = vdec_get_mem_from_list(vd, vmem.pmem_id, vmem.buf.buf_type);
-
-	if (NULL == l) {
-		pr_err("%s: not able to find the buffer from list\n", __func__);
-		return -EPERM;
-	}
-
-	/* input buffers */
-	if ((vmem.buf.region.offset + vmem.buf.region.size) > l->mem.len) {
-		pr_err("%s: invalid input buffer offset!\n", __func__);
-		return -EINVAL;
-
-	}
-	vmem.buf.region.offset += l->mem.phys_addr;
-
-	rpc.size = sizeof(vmem.buf);
-	memcpy(&rpc.buf, &vmem.buf, sizeof(struct vdec_buf_info));
-
-	ret = dal_call(vd->vdec_handle, VDEC_DALRPC_FREEBUFFERS, 5,
-		       &rpc, sizeof(rpc), &res, sizeof(res));
-	if (ret < 4) {
-		pr_err("%s: remote function failed (%d)\n", __func__, ret);
-	}
-
-	return ret;
-}
-
-static int vdec_getversion(struct vdec_data *vd, void *argp)
-{
-	struct vdec_version ver_info;
-	int ret = 0;
-
-	ver_info.major = VDEC_GET_MAJOR_VERSION(VDEC_INTERFACE_VERSION);
-	ver_info.minor = VDEC_GET_MINOR_VERSION(VDEC_INTERFACE_VERSION);
-
-	ret = copy_to_user(((struct vdec_version *)argp),
-				&ver_info, sizeof(ver_info));
-
-	return ret;
-
-}
-
-static long vdec_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct vdec_data *vd = file->private_data;
-	void __user *argp = (void __user *)arg;
-	int ret = 0;
-
-	if (!vd->running)
-		return -EPERM;
-
-	switch (cmd) {
-	case VDEC_IOCTL_INITIALIZE:
-		ret = vdec_initialize(vd, argp);
-		break;
-
-	case VDEC_IOCTL_SETBUFFERS:
-		ret = vdec_setbuffers(vd, argp);
-		break;
-
-	case VDEC_IOCTL_QUEUE:
-		TRACE("VDEC_IOCTL_QUEUE (pid=%d tid=%d)\n",
-		      current->group_leader->pid, current->pid);
-		ret = vdec_queue(vd, argp);
-		break;
-
-	case VDEC_IOCTL_REUSEFRAMEBUFFER:
-		TRACE("VDEC_IOCTL_REUSEFRAMEBUFFER (pid=%d tid=%d)\n",
-		      current->group_leader->pid, current->pid);
-		ret = vdec_reuse_framebuffer(vd, argp);
-		break;
-
-	case VDEC_IOCTL_FLUSH:
-		TRACE("IOCTL flush\n");
-		ret = vdec_flush(vd, argp);
-		break;
-
-	case VDEC_IOCTL_EOS:
-		TRACE("VDEC_IOCTL_EOS (pid=%d tid=%d)\n",
-		      current->group_leader->pid, current->pid);
-		ret = dal_call_f0(vd->vdec_handle, VDEC_DALRPC_SIGEOFSTREAM, 0);
-		if (ret)
-			pr_err("%s: remote function failed (%d)\n",
-			       __func__, ret);
-		break;
-
-	case VDEC_IOCTL_GETMSG:
-		TRACE("VDEC_IOCTL_GETMSG (pid=%d tid=%d)\n",
-		      current->group_leader->pid, current->pid);
-		wait_event_interruptible(vd->vdec_msg_evt,
-					 vdec_get_msg(vd, argp));
-
-		if (vd->close_decode)
-			ret = -EINTR;
-		else
-			/* order the reads from the buffer */
-			rmb();
-		break;
-
-	case VDEC_IOCTL_CLOSE:
-		ret = vdec_close(vd, argp);
-		break;
-
-	case VDEC_IOCTL_GETDECATTRIBUTES:
-		TRACE("VDEC_IOCTL_GETDECATTRIBUTES (pid=%d tid=%d)\n",
-		      current->group_leader->pid, current->pid);
-		ret = vdec_getdecattributes(vd, argp);
-
-		if (ret)
-			pr_err("%s: remote function failed (%d)\n",
-			       __func__, ret);
-		break;
-
-	case VDEC_IOCTL_FREEBUFFERS:
-		TRACE("VDEC_IOCTL_FREEBUFFERS (pid=%d tid=%d)\n",
-		      current->group_leader->pid, current->pid);
-		ret = vdec_freebuffers(vd, argp);
-
-		if (ret)
-			pr_err("%s: remote function failed (%d)\n",
-			       __func__, ret);
-		break;
-	case VDEC_IOCTL_GETVERSION:
-		TRACE("VDEC_IOCTL_GETVERSION (pid=%d tid=%d)\n",
-			current->group_leader->pid, current->pid);
-		ret = vdec_getversion(vd, argp);
-
-		if (ret)
-			pr_err("%s: remote function failed (%d)\n",
-				__func__, ret);
-		break;
-	case VDEC_IOCTL_GETPROPERTY:
-		TRACE("VDEC_IOCTL_GETPROPERTY (pid=%d tid=%d)\n",
-		      current->group_leader->pid, current->pid);
-		ret = vdec_getproperty(vd, argp);
-		break;
-	case VDEC_IOCTL_SETPROPERTY:
-		TRACE("VDEC_IOCTL_SETPROPERTY (pid=%d tid=%d)\n",
-		      current->group_leader->pid, current->pid);
-		ret = vdec_setproperty(vd, argp);
-		break;
-	case VDEC_IOCTL_PERFORMANCE_CHANGE_REQ:
-		ret = vdec_performance_change_request(vd, argp);
-		break;
-	default:
-		pr_err("%s: invalid ioctl!\n", __func__);
-		ret = -EINVAL;
-		break;
-	}
-
-	TRACE("ioctl done (pid=%d tid=%d)\n",
-	      current->group_leader->pid, current->pid);
-
-	return ret;
-}
-
-static void vdec_dcdone_handler(struct vdec_data *vd, void *frame,
-				uint32_t frame_size)
-{
-	struct vdec_msg msg;
-	struct vdec_mem_list *l;
-	unsigned long flags;
-	int found = 0;
-
-	if (frame_size < sizeof(struct vdec_frame_info)) {
-		pr_warning("%s: msg size mismatch %d != %d\n", __func__,
-			   frame_size, sizeof(struct vdec_frame_info));
-		return;
-	}
-
-	memcpy(&msg.vfr_info, (struct vdec_frame_info *)frame,
-	       sizeof(struct vdec_frame_info));
-
-	if (msg.vfr_info.status == VDEC_FRAME_DECODE_OK) {
-		spin_lock_irqsave(&vd->vdec_mem_list_lock, flags);
-		list_for_each_entry(l, &vd->vdec_mem_list_head, list) {
-			if ((l->mem.buf_type == VDEC_BUFFER_TYPE_OUTPUT) &&
-			    (msg.vfr_info.offset >= l->mem.phys_addr) &&
-			    (msg.vfr_info.offset <
-			     (l->mem.phys_addr + l->mem.len))) {
-				found = 1;
-				msg.vfr_info.offset -= l->mem.phys_addr;
-				msg.vfr_info.data2 = l->mem.id;
-				break;
-			}
-		}
-		spin_unlock_irqrestore(&vd->vdec_mem_list_lock, flags);
-	}
-
-	if (found || (msg.vfr_info.status != VDEC_FRAME_DECODE_OK)) {
-		msg.id = VDEC_MSG_FRAMEDONE;
-		vdec_put_msg(vd, &msg);
-	} else {
-		pr_err("%s: invalid phys addr = 0x%x\n",
-		       __func__, msg.vfr_info.offset);
-	}
-
-}
-
-static void vdec_reuseibuf_handler(struct vdec_data *vd, void *bufstat,
-				   uint32_t bufstat_size)
-{
-	struct vdec_buffer_status *vdec_bufstat;
-	struct vdec_msg msg;
-
-	/* TODO: how do we signal the client? If they are waiting on a
-	 * message in an ioctl, they may block forever */
-	if (bufstat_size != sizeof(struct vdec_buffer_status)) {
-		pr_warning("%s: msg size mismatch %d != %d\n", __func__,
-			   bufstat_size, sizeof(struct vdec_buffer_status));
-		return;
-	}
-	vdec_bufstat = (struct vdec_buffer_status *)bufstat;
-	msg.id = VDEC_MSG_REUSEINPUTBUFFER;
-	msg.buf_id = vdec_bufstat->data;
-	vdec_put_msg(vd, &msg);
-}
-
-static void callback(void *data, int len, void *cookie)
-{
-	struct vdec_data *vd = (struct vdec_data *)cookie;
-	uint32_t *tmp = (uint32_t *) data;
-
-	if (!vd->mem_initialized) {
-		pr_err("%s:memory not initialize but callback called!\n",
-		       __func__);
-		return;
-	}
-
-	TRACE("vdec_async: tmp=0x%08x 0x%08x 0x%08x\n", tmp[0], tmp[1], tmp[2]);
-	switch (tmp[0]) {
-	case VDEC_ASYNCMSG_DECODE_DONE:
-		vdec_dcdone_handler(vd, &tmp[3], tmp[2]);
-		break;
-	case VDEC_ASYNCMSG_REUSE_FRAME:
-		vdec_reuseibuf_handler(vd, &tmp[3], tmp[2]);
-		break;
-	default:
-		pr_err("%s: Unknown async message from DSP id=0x%08x sz=%u\n",
-		       __func__, tmp[0], tmp[2]);
-	}
-}
-
-static int vdec_open(struct inode *inode, struct file *file)
-{
-	int ret;
-	int i;
-	struct vdec_msg_list *l;
-	struct vdec_data *vd;
-	struct dal_info version_info;
-	char *portname = NULL;
-
-	pr_info("q6vdec_open()\n");
-	mutex_lock(&vdec_ref_lock);
-	if (ref_cnt >= MAX_SUPPORTED_INSTANCES) {
-		pr_err("%s: Max allowed instances exceeded \n", __func__);
-		mutex_unlock(&vdec_ref_lock);
-		return -EBUSY;
-	}
-	ref_cnt++;
-	mutex_unlock(&vdec_ref_lock);
-
-	vd = kmalloc(sizeof(struct vdec_data), GFP_KERNEL);
-	if (!vd) {
-		pr_err("%s: kmalloc failed\n", __func__);
-		ret = -ENOMEM;
-		goto vdec_open_err_handle_vd;
-	}
-	file->private_data = vd;
-
-	vd->mem_initialized = 0;
-	INIT_LIST_HEAD(&vd->vdec_msg_list_head);
-	INIT_LIST_HEAD(&vd->vdec_msg_list_free);
-	INIT_LIST_HEAD(&vd->vdec_mem_list_head);
-	init_waitqueue_head(&vd->vdec_msg_evt);
-
-	spin_lock_init(&vd->vdec_list_lock);
-	spin_lock_init(&vd->vdec_mem_list_lock);
-	for (i = 0; i < VDEC_MSG_MAX; i++) {
-		l = kzalloc(sizeof(struct vdec_msg_list), GFP_KERNEL);
-		if (!l) {
-			pr_err("%s: kzalloc failed!\n", __func__);
-			ret = -ENOMEM;
-			goto vdec_open_err_handle_list;
-		}
-		list_add(&l->list, &vd->vdec_msg_list_free);
-	}
-
-	memset(&vd->streamDetails, 0, sizeof(struct videoStreamDetails));
-
-	mutex_lock(&vdec_ref_lock);
-	vdec_get_next_portanddevid(&vd->Q6deviceId, &portname);
-	mutex_unlock(&vdec_ref_lock);
-
-	if ((0 == vd->Q6deviceId) || (NULL == portname)) {
-		pr_err("%s: FATAL error portname %s or deviceId %d not picked properly\n",
-			__func__, portname, vd->Q6deviceId);
-		ret = -EIO;
-		goto vdec_open_err_handle_list;
-	} else {
-		pr_err("attaching on deviceid %x portname %s\n",
-			vd->Q6deviceId, portname);
-		vd->vdec_handle = dal_attach(vd->Q6deviceId,
-					     portname, 1, callback, vd);
-	}
-
-	if (!vd->vdec_handle) {
-		pr_err("%s: failed to attach\n", __func__);
-		ret = -EIO;
-		goto vdec_open_err_handle_list;
-	}
-	ret = dal_call_f9(vd->vdec_handle, DAL_OP_INFO,
-				&version_info, sizeof(struct dal_info));
-
-	if (ret) {
-		pr_err("%s: failed to get version \n", __func__);
-		goto vdec_open_err_handle_version;
-	}
-
-	TRACE("q6vdec_open() interface version 0x%x\n", version_info.version);
-	if (vdec_check_version(VDEC_INTERFACE_VERSION,
-			version_info.version)) {
-		pr_err("%s: driver version mismatch !\n", __func__);
-		goto vdec_open_err_handle_version;
-	}
-
-	vd->running = 1;
-	prevent_sleep();
-
-	return 0;
-vdec_open_err_handle_version:
-	dal_detach(vd->vdec_handle);
-vdec_open_err_handle_list:
-	{
-		struct vdec_msg_list *l, *n;
-		list_for_each_entry_safe(l, n, &vd->vdec_msg_list_free, list) {
-			list_del(&l->list);
-			kfree(l);
-		}
-	}
-vdec_open_err_handle_vd:
-	mutex_lock(&vdec_ref_lock);
-	vdec_freeup_portanddevid(vd->Q6deviceId);
-	ref_cnt--;
-	mutex_unlock(&vdec_ref_lock);
-	kfree(vd);
-	return ret;
-}
-
-static int vdec_release(struct inode *inode, struct file *file)
-{
-	int ret;
-	struct vdec_msg_list *l, *n;
-	struct vdec_mem_list *m, *k;
-	struct vdec_data *vd = file->private_data;
-
-	vd->running = 0;
-	wake_up_all(&vd->vdec_msg_evt);
-
-	if (!vd->close_decode)
-		vdec_close(vd, NULL);
-
-	ret = dal_detach(vd->vdec_handle);
-	if (ret)
-		printk(KERN_INFO "%s: failed to detach (%d)\n", __func__, ret);
-
-	list_for_each_entry_safe(l, n, &vd->vdec_msg_list_free, list) {
-		list_del(&l->list);
-		kfree(l);
-	}
-
-	list_for_each_entry_safe(l, n, &vd->vdec_msg_list_head, list) {
-		list_del(&l->list);
-		kfree(l);
-	}
-
-	list_for_each_entry_safe(m, k, &vd->vdec_mem_list_head, list) {
-		list_del(&m->list);
-		kfree(m);
-	}
-	mutex_lock(&vdec_ref_lock);
-	BUG_ON(ref_cnt <= 0);
-	ref_cnt--;
-	vdec_freeup_portanddevid(vd->Q6deviceId);
-	mutex_unlock(&vdec_ref_lock);
-
-	mutex_lock(&vdec_rm_lock);
-	vdec_rm_freeupResources(vd);
-	mutex_unlock(&vdec_rm_lock);
-
-
-	kfree(vd);
-	allow_sleep();
-	return 0;
-}
-
-static const struct file_operations vdec_fops = {
-	.owner = THIS_MODULE,
-	.open = vdec_open,
-	.release = vdec_release,
-	.unlocked_ioctl = vdec_ioctl,
-};
-
-static int __init vdec_init(void)
-{
-	struct device *class_dev;
-	int rc = 0;
-
-	pm_qos_add_request(&pm_qos_req, PM_QOS_CPU_DMA_LATENCY,
-				PM_QOS_DEFAULT_VALUE);
-	wake_lock_init(&wakelock, WAKE_LOCK_SUSPEND, "vdec_suspend");
-
-	rc = alloc_chrdev_region(&vdec_device_no, 0, 1, "vdec");
-	if (rc < 0) {
-		pr_err("%s: alloc_chrdev_region failed %d\n", __func__, rc);
-		return rc;
-	}
-
-	driver_class = class_create(THIS_MODULE, "vdec");
-	if (IS_ERR(driver_class)) {
-		rc = -ENOMEM;
-		pr_err("%s: class_create failed %d\n", __func__, rc);
-		goto vdec_init_err_unregister_chrdev_region;
-	}
-	class_dev = device_create(driver_class, NULL,
-				  vdec_device_no, NULL, "vdec");
-	if (!class_dev) {
-		pr_err("%s: class_device_create failed %d\n", __func__, rc);
-		rc = -ENOMEM;
-		goto vdec_init_err_class_destroy;
-	}
-
-	cdev_init(&vdec_cdev, &vdec_fops);
-	vdec_cdev.owner = THIS_MODULE;
-	rc = cdev_add(&vdec_cdev, MKDEV(MAJOR(vdec_device_no), 0), 1);
-
-	if (rc < 0) {
-		pr_err("%s: cdev_add failed %d\n", __func__, rc);
-		goto vdec_init_err_class_device_destroy;
-	}
-
-	memset(&deviceIdRegistry, 0, sizeof(deviceIdRegistry));
-	memset(&loadOnPorts, 0, sizeof(loadOnPorts));
-	numOfPorts = 0;
-
-	return 0;
-
-vdec_init_err_class_device_destroy:
-	device_destroy(driver_class, vdec_device_no);
-vdec_init_err_class_destroy:
-	class_destroy(driver_class);
-vdec_init_err_unregister_chrdev_region:
-	unregister_chrdev_region(vdec_device_no, 1);
-	return rc;
-}
-
-static void __exit vdec_exit(void)
-{
-	device_destroy(driver_class, vdec_device_no);
-	class_destroy(driver_class);
-	unregister_chrdev_region(vdec_device_no, 1);
-}
-
-MODULE_DESCRIPTION("video decoder driver for QSD platform");
-MODULE_VERSION("2.00");
-
-module_init(vdec_init);
-module_exit(vdec_exit);
diff --git a/arch/arm/mach-msm/qdsp6/msm_q6venc.c b/arch/arm/mach-msm/qdsp6/msm_q6venc.c
deleted file mode 100644
index a2b4b6e..0000000
--- a/arch/arm/mach-msm/qdsp6/msm_q6venc.c
+++ /dev/null
@@ -1,1200 +0,0 @@
-/* Copyright (c) 2008-2009, The Linux Foundation. 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.
- *
- */
-
-#include <linux/slab.h>
-#include <linux/cdev.h>
-#include <linux/file.h>
-#include <linux/device.h>
-#include <linux/fs.h>
-#include <linux/list.h>
-#include <linux/module.h>
-#include <linux/sched.h>
-#include <linux/spinlock.h>
-#include <linux/uaccess.h>
-#include <linux/wakelock.h>
-#include <linux/msm_q6venc.h>
-#include <linux/pm_qos.h>
-
-#include <mach/cpuidle.h>
-
-#include "dal.h"
-
-#define DALDEVICEID_VENC_DEVICE         0x0200002D
-#define DALDEVICEID_VENC_PORTNAME       "DAL_AQ_VID"
-
-#define VENC_NAME		        "q6venc"
-#define VENC_MSG_MAX                    128
-
-#define VENC_INTERFACE_VERSION		0x00020000
-#define MAJOR_MASK			0xFFFF0000
-#define MINOR_MASK			0x0000FFFF
-#define VENC_GET_MAJOR_VERSION(version) ((version & MAJOR_MASK)>>16)
-#define VENC_GET_MINOR_VERSION(version) (version & MINOR_MASK)
-
-enum {
-	VENC_BUFFER_TYPE_INPUT,
-	VENC_BUFFER_TYPE_OUTPUT,
-	VENC_BUFFER_TYPE_QDSP6,
-	VENC_BUFFER_TYPE_HDR
-};
-enum {
-	VENC_DALRPC_GET_SYNTAX_HEADER = DAL_OP_FIRST_DEVICE_API,
-	VENC_DALRPC_UPDATE_INTRA_REFRESH,
-	VENC_DALRPC_UPDATE_FRAME_RATE,
-	VENC_DALRPC_UPDATE_BITRATE,
-	VENC_DALRPC_UPDATE_QP_RANGE,
-	VENC_DALRPC_UPDATE_INTRA_PERIOD,
-	VENC_DALRPC_REQUEST_IFRAME,
-	VENC_DALRPC_START,
-	VENC_DALRPC_STOP,
-	VENC_DALRPC_SUSPEND,
-	VENC_DALRPC_RESUME,
-	VENC_DALRPC_FLUSH,
-	VENC_DALRPC_QUEUE_INPUT,
-	VENC_DALRPC_QUEUE_OUTPUT
-};
-struct venc_input_payload {
-	u32 data;
-};
-struct venc_output_payload {
-	u32 size;
-	long long time_stamp;
-	u32 flags;
-	u32 data;
-	u32 client_data_from_input;
-};
-union venc_payload {
-	struct venc_input_payload input_payload;
-	struct venc_output_payload output_payload;
-};
-struct venc_msg_type {
-	u32 event;
-	u32 status;
-	union venc_payload payload;
-};
-struct venc_input_buf {
-	struct venc_buf_type yuv_buf;
-	u32 data_size;
-	long long time_stamp;
-	u32 flags;
-	u32 dvs_offsetx;
-	u32 dvs_offsety;
-	u32 client_data;
-	u32 op_client_data;
-};
-struct venc_output_buf {
-	struct venc_buf_type bit_stream_buf;
-	u32 client_data;
-};
-
-struct venc_msg_list {
-	struct list_head list;
-	struct venc_msg msg_data;
-};
-struct venc_buf {
-	int fd;
-	u32 src;
-	u32 offset;
-	u32 size;
-	u32 btype;
-	unsigned long paddr;
-	struct file *file;
-};
-struct venc_pmem_list {
-	struct list_head list;
-	struct venc_buf buf;
-};
-struct venc_dev {
-	bool is_active;
-	bool pmem_freed;
-	enum venc_state_type state;
-	struct list_head venc_msg_list_head;
-	struct list_head venc_msg_list_free;
-	spinlock_t venc_msg_list_lock;
-	struct list_head venc_pmem_list_head;
-	spinlock_t venc_pmem_list_lock;
-	struct dal_client *q6_handle;
-	wait_queue_head_t venc_msg_evt;
-	struct device *class_devp;
-};
-
-#define DEBUG_VENC 0
-#if DEBUG_VENC
-#define TRACE(fmt, x...)     \
-	do { pr_debug("%s:%d " fmt, __func__, __LINE__, ##x); } while (0)
-#else
-#define TRACE(fmt, x...)         do { } while (0)
-#endif
-
-static struct cdev cdev;
-static dev_t venc_dev_num;
-static struct class *venc_class;
-static struct venc_dev *venc_device_p;
-static int venc_ref;
-
-static DEFINE_MUTEX(idlecount_lock);
-static int idlecount;
-static struct wake_lock wakelock;
-static struct pm_qos_request pm_qos_req;
-
-static void prevent_sleep(void)
-{
-	mutex_lock(&idlecount_lock);
-	if (++idlecount == 1) {
-		pm_qos_update_request(&pm_qos_req,
-				      msm_cpuidle_get_deep_idle_latency());
-		wake_lock(&wakelock);
-	}
-	mutex_unlock(&idlecount_lock);
-}
-
-static void allow_sleep(void)
-{
-	mutex_lock(&idlecount_lock);
-	if (--idlecount == 0) {
-		wake_unlock(&wakelock);
-		pm_qos_update_request(&pm_qos_req, PM_QOS_DEFAULT_VALUE);
-	}
-	mutex_unlock(&idlecount_lock);
-}
-
-static inline int venc_check_version(u32 client, u32 server)
-{
-	int ret = -EINVAL;
-
-	if ((VENC_GET_MAJOR_VERSION(client) == VENC_GET_MAJOR_VERSION(server))
-	     && (VENC_GET_MINOR_VERSION(client) <=
-		 VENC_GET_MINOR_VERSION(server)))
-		ret = 0;
-
-	return ret;
-}
-
-static int venc_get_msg(struct venc_dev *dvenc, void *msg)
-{
-	struct venc_msg_list *l;
-	unsigned long flags;
-	int ret = 0;
-	struct venc_msg qdsp_msg;
-
-	if (!dvenc->is_active)
-		return -EPERM;
-	spin_lock_irqsave(&dvenc->venc_msg_list_lock, flags);
-	list_for_each_entry_reverse(l, &dvenc->venc_msg_list_head, list) {
-		memcpy(&qdsp_msg, &l->msg_data, sizeof(struct venc_msg));
-		list_del(&l->list);
-		list_add(&l->list, &dvenc->venc_msg_list_free);
-		ret = 1;
-		break;
-	}
-	spin_unlock_irqrestore(&dvenc->venc_msg_list_lock, flags);
-	if (copy_to_user(msg, &qdsp_msg, sizeof(struct venc_msg)))
-		pr_err("%s failed to copy_to_user\n", __func__);
-	return ret;
-}
-
-static void venc_put_msg(struct venc_dev *dvenc, struct venc_msg *msg)
-{
-	struct venc_msg_list *l;
-	unsigned long flags;
-	int found = 0;
-
-	spin_lock_irqsave(&dvenc->venc_msg_list_lock, flags);
-	list_for_each_entry(l, &dvenc->venc_msg_list_free, list) {
-		memcpy(&l->msg_data, msg, sizeof(struct venc_msg));
-		list_del(&l->list);
-		list_add(&l->list, &dvenc->venc_msg_list_head);
-		found = 1;
-		break;
-	}
-	spin_unlock_irqrestore(&dvenc->venc_msg_list_lock, flags);
-	if (found)
-		wake_up(&dvenc->venc_msg_evt);
-	else
-		pr_err("%s: failed to find a free node\n", __func__);
-
-}
-
-static struct venc_pmem_list *venc_add_pmem_to_list(struct venc_dev *dvenc,
-						      struct venc_pmem *mptr,
-						      u32 btype)
-{
-	int ret = 0;
-	unsigned long flags;
-	unsigned long len;
-	unsigned long vaddr;
-	struct venc_pmem_list *plist = NULL;
-
-	plist = kzalloc(sizeof(struct venc_pmem_list), GFP_KERNEL);
-	if (!plist) {
-		pr_err("%s: kzalloc failed\n", __func__);
-		return NULL;
-	}
-
-	ret = get_pmem_file(mptr->fd, &(plist->buf.paddr),
-		&vaddr, &len, &(plist->buf.file));
-	if (ret) {
-		pr_err("%s: get_pmem_file failed for fd=%d offset=%d\n",
-			__func__, mptr->fd, mptr->offset);
-		goto err_venc_add_pmem;
-	} else if (mptr->offset >= len) {
-		pr_err("%s: invalid offset (%d > %ld) for fd=%d\n",
-		       __func__, mptr->offset, len, mptr->fd);
-		ret = -EINVAL;
-		goto err_venc_get_pmem;
-	}
-
-	plist->buf.fd = mptr->fd;
-	plist->buf.paddr += mptr->offset;
-	plist->buf.size = mptr->size;
-	plist->buf.btype = btype;
-	plist->buf.offset = mptr->offset;
-	plist->buf.src = mptr->src;
-
-	spin_lock_irqsave(&dvenc->venc_pmem_list_lock, flags);
-	list_add(&plist->list, &dvenc->venc_pmem_list_head);
-	spin_unlock_irqrestore(&dvenc->venc_pmem_list_lock, flags);
-	return plist;
-
-err_venc_get_pmem:
-	put_pmem_file(plist->buf.file);
-err_venc_add_pmem:
-	kfree(plist);
-	return NULL;
-}
-
-static struct venc_pmem_list *venc_get_pmem_from_list(
-		struct venc_dev *dvenc, u32 pmem_fd,
-		u32 offset, u32 btype)
-{
-	struct venc_pmem_list *plist;
-	unsigned long flags;
-	struct file *file;
-	int found = 0;
-
-	file = fget(pmem_fd);
-	if (!file) {
-		pr_err("%s: invalid encoder buffer fd(%d)\n", __func__,
-			pmem_fd);
-		return NULL;
-	}
-	spin_lock_irqsave(&dvenc->venc_pmem_list_lock, flags);
-	list_for_each_entry(plist, &dvenc->venc_pmem_list_head, list) {
-		if (plist->buf.btype == btype && plist->buf.file == file &&
-			plist->buf.offset == offset) {
-			found = 1;
-			break;
-		}
-	}
-	spin_unlock_irqrestore(&dvenc->venc_pmem_list_lock, flags);
-	fput(file);
-	if (found)
-		return plist;
-
-	else
-		return NULL;
-}
-
-static int venc_set_buffer(struct venc_dev *dvenc, void *argp,
-			     u32 btype)
-{
-	struct venc_pmem pmem;
-	struct venc_pmem_list *plist;
-	int ret = 0;
-
-	ret = copy_from_user(&pmem, argp, sizeof(pmem));
-	if (ret) {
-		pr_err("%s: copy_from_user failed\n", __func__);
-		return ret;
-	}
-	plist = venc_add_pmem_to_list(dvenc, &pmem, btype);
-	if (plist == NULL) {
-		pr_err("%s: buffer add_to_pmem_list failed\n",
-			__func__);
-		return -EPERM;
-	}
-	return ret;
-}
-
-static int venc_assign_q6_buffers(struct venc_dev *dvenc,
-				    struct venc_buffers *pbufs,
-				    struct venc_nonio_buf_config *pcfg)
-{
-	int ret = 0;
-	struct venc_pmem_list *plist;
-
-	plist = venc_add_pmem_to_list(dvenc, &(pbufs->recon_buf[0]),
-				  VENC_BUFFER_TYPE_QDSP6);
-	if (plist == NULL) {
-		pr_err("%s: recon_buf0 failed to add_to_pmem_list\n",
-			__func__);
-		return -EPERM;
-	}
-	pcfg->recon_buf1.region = pbufs->recon_buf[0].src;
-	pcfg->recon_buf1.phys = plist->buf.paddr;
-	pcfg->recon_buf1.size = plist->buf.size;
-	pcfg->recon_buf1.offset = 0;
-
-	plist = venc_add_pmem_to_list(dvenc, &(pbufs->recon_buf[1]),
-				  VENC_BUFFER_TYPE_QDSP6);
-	if (plist == NULL) {
-		pr_err("%s: recons_buf1 failed to add_to_pmem_list\n",
-			__func__);
-		return -EPERM;
-	}
-	pcfg->recon_buf2.region = pbufs->recon_buf[1].src;
-	pcfg->recon_buf2.phys = plist->buf.paddr;
-	pcfg->recon_buf2.size = plist->buf.size;
-	pcfg->recon_buf2.offset = 0;
-
-	plist = venc_add_pmem_to_list(dvenc, &(pbufs->wb_buf),
-				  VENC_BUFFER_TYPE_QDSP6);
-	if (plist == NULL) {
-		pr_err("%s: wb_buf failed to add_to_pmem_list\n",
-			__func__);
-		return -EPERM;
-	}
-	pcfg->wb_buf.region = pbufs->wb_buf.src;
-	pcfg->wb_buf.phys = plist->buf.paddr;
-	pcfg->wb_buf.size = plist->buf.size;
-	pcfg->wb_buf.offset = 0;
-
-	plist = venc_add_pmem_to_list(dvenc, &(pbufs->cmd_buf),
-				  VENC_BUFFER_TYPE_QDSP6);
-	if (plist == NULL) {
-		pr_err("%s: cmd_buf failed to add_to_pmem_list\n",
-			__func__);
-		return -EPERM;
-	}
-	pcfg->cmd_buf.region = pbufs->cmd_buf.src;
-	pcfg->cmd_buf.phys = plist->buf.paddr;
-	pcfg->cmd_buf.size = plist->buf.size;
-	pcfg->cmd_buf.offset = 0;
-
-	plist = venc_add_pmem_to_list(dvenc, &(pbufs->vlc_buf),
-				  VENC_BUFFER_TYPE_QDSP6);
-	if (plist == NULL) {
-		pr_err("%s: vlc_buf failed to add_to_pmem_list"
-		" failed\n", __func__);
-		return -EPERM;
-	}
-	pcfg->vlc_buf.region = pbufs->vlc_buf.src;
-	pcfg->vlc_buf.phys = plist->buf.paddr;
-	pcfg->vlc_buf.size = plist->buf.size;
-	pcfg->vlc_buf.offset = 0;
-
-	return ret;
-}
-
-static int venc_start(struct venc_dev *dvenc, void *argp)
-{
-	int ret = 0;
-	struct venc_q6_config q6_config;
-	struct venc_init_config vconfig;
-
-	dvenc->state = VENC_STATE_START;
-	ret = copy_from_user(&vconfig, argp, sizeof(struct venc_init_config));
-	if (ret) {
-		pr_err("%s: copy_from_user failed\n", __func__);
-		return ret;
-	}
-	memcpy(&q6_config, &(vconfig.q6_config), sizeof(q6_config));
-	ret = venc_assign_q6_buffers(dvenc, &(vconfig.q6_bufs),
-		&(q6_config.buf_params));
-	if (ret != 0) {
-		pr_err("%s: assign_q6_buffers failed\n", __func__);
-		return -EPERM;
-	}
-
-	q6_config.callback_event = dvenc->q6_handle;
-	TRACE("%s: parameters: handle:%p, config:%p, callback:%p \n", __func__,
-		dvenc->q6_handle, &q6_config, q6_config.callback_event);
-	TRACE("%s: parameters:recon1:0x%x, recon2:0x%x,"
-		" wb_buf:0x%x, cmd:0x%x, vlc:0x%x\n", __func__,
-		q6_config.buf_params.recon_buf1.phys,
-		q6_config.buf_params.recon_buf2.phys,
-		q6_config.buf_params.wb_buf.phys,
-		q6_config.buf_params.cmd_buf.phys,
-		q6_config.buf_params.vlc_buf.phys);
-	TRACE("%s: size of param:%d \n", __func__, sizeof(q6_config));
-	ret = dal_call_f5(dvenc->q6_handle, VENC_DALRPC_START, &q6_config,
-		sizeof(q6_config));
-	if (ret != 0) {
-		pr_err("%s: remote function failed (%d)\n", __func__, ret);
-		return ret;
-	}
-	return ret;
-}
-
-static int venc_encode_frame(struct venc_dev *dvenc, void *argp)
-{
-	int ret = 0;
-	struct venc_pmem buf;
-	struct venc_input_buf q6_input;
-	struct venc_pmem_list *plist;
-	struct venc_buffer input;
-
-	ret = copy_from_user(&input, argp, sizeof(struct venc_buffer));
-	if (ret) {
-		pr_err("%s: copy_from_user failed\n", __func__);
-		return ret;
-	}
-	ret = copy_from_user(&buf,
-			       ((struct venc_buffer *)argp)->ptr_buffer,
-			       sizeof(struct venc_pmem));
-	if (ret) {
-		pr_err("%s: copy_from_user failed\n", __func__);
-		return ret;
-	}
-
-	plist = venc_get_pmem_from_list(dvenc, buf.fd, buf.offset,
-			VENC_BUFFER_TYPE_INPUT);
-	if (NULL == plist) {
-		plist = venc_add_pmem_to_list(dvenc, &buf,
-			VENC_BUFFER_TYPE_INPUT);
-		if (plist == NULL) {
-			pr_err("%s: buffer add_to_pmem_list failed\n",
-				__func__);
-			return -EPERM;
-		}
-	}
-
-	q6_input.flags = 0;
-	if (input.flags & VENC_FLAG_EOS)
-		q6_input.flags |= 0x00000001;
-	q6_input.yuv_buf.region = plist->buf.src;
-	q6_input.yuv_buf.phys = plist->buf.paddr;
-	q6_input.yuv_buf.size = plist->buf.size;
-	q6_input.yuv_buf.offset = 0;
-	q6_input.data_size = plist->buf.size;
-	q6_input.client_data = (u32)input.client_data;
-	q6_input.time_stamp = input.time_stamp;
-	q6_input.dvs_offsetx = 0;
-	q6_input.dvs_offsety = 0;
-
-	TRACE("Pushing down input phys=0x%x fd= %d, client_data: 0x%x,"
-		" time_stamp:%lld \n", q6_input.yuv_buf.phys, plist->buf.fd,
-		input.client_data, input.time_stamp);
-	ret = dal_call_f5(dvenc->q6_handle, VENC_DALRPC_QUEUE_INPUT,
-		&q6_input, sizeof(q6_input));
-
-	if (ret != 0)
-		pr_err("%s: Q6 queue_input failed (%d)\n", __func__,
-		(int)ret);
-	return ret;
-}
-
-static int venc_fill_output(struct venc_dev *dvenc, void *argp)
-{
-	int ret = 0;
-	struct venc_pmem buf;
-	struct venc_output_buf q6_output;
-	struct venc_pmem_list *plist;
-	struct venc_buffer output;
-
-	ret = copy_from_user(&output, argp, sizeof(struct venc_buffer));
-	if (ret) {
-		pr_err("%s: copy_from_user failed\n", __func__);
-		return ret;
-	}
-	ret = copy_from_user(&buf,
-			       ((struct venc_buffer *)argp)->ptr_buffer,
-			       sizeof(struct venc_pmem));
-	if (ret) {
-		pr_err("%s: copy_from_user failed\n", __func__);
-		return ret;
-	}
-	plist =	venc_get_pmem_from_list(dvenc, buf.fd, buf.offset,
-			VENC_BUFFER_TYPE_OUTPUT);
-	if (NULL == plist) {
-		plist = venc_add_pmem_to_list(dvenc, &buf,
-				VENC_BUFFER_TYPE_OUTPUT);
-		if (NULL == plist) {
-			pr_err("%s: output buffer failed to add_to_pmem_list"
-				"\n", __func__);
-			return -EPERM;
-		}
-	}
-	q6_output.bit_stream_buf.region = plist->buf.src;
-	q6_output.bit_stream_buf.phys = (u32)plist->buf.paddr;
-	q6_output.bit_stream_buf.size = plist->buf.size;
-	q6_output.bit_stream_buf.offset = 0;
-	q6_output.client_data = (u32)output.client_data;
-	ret =
-	    dal_call_f5(dvenc->q6_handle, VENC_DALRPC_QUEUE_OUTPUT, &q6_output,
-			sizeof(q6_output));
-	if (ret != 0)
-		pr_err("%s: remote function failed (%d)\n", __func__, ret);
-	return ret;
-}
-
-static int venc_stop(struct venc_dev *dvenc)
-{
-	int ret = 0;
-	struct venc_msg msg;
-
-	ret = dal_call_f0(dvenc->q6_handle, VENC_DALRPC_STOP, 1);
-	if (ret) {
-		pr_err("%s: remote runction failed (%d)\n", __func__, ret);
-		msg.msg_code = VENC_MSG_STOP;
-		msg.msg_data_size = 0;
-		msg.status_code = VENC_S_EFAIL;
-		venc_put_msg(dvenc, &msg);
-	}
-	return ret;
-}
-
-static int venc_pause(struct venc_dev *dvenc)
-{
-	int ret = 0;
-	struct venc_msg msg;
-
-	ret = dal_call_f0(dvenc->q6_handle, VENC_DALRPC_SUSPEND, 1);
-	if (ret) {
-		pr_err("%s: remote function failed (%d)\n", __func__, ret);
-		msg.msg_code = VENC_MSG_PAUSE;
-		msg.status_code = VENC_S_EFAIL;
-		msg.msg_data_size = 0;
-		venc_put_msg(dvenc, &msg);
-	}
-	return ret;
-}
-
-static int venc_resume(struct venc_dev *dvenc)
-{
-	int ret = 0;
-	struct venc_msg msg;
-
-	ret = dal_call_f0(dvenc->q6_handle, VENC_DALRPC_RESUME, 1);
-	if (ret) {
-		pr_err("%s: remote function failed (%d)\n", __func__, ret);
-		msg.msg_code = VENC_MSG_RESUME;
-		msg.msg_data_size = 0;
-		msg.status_code = VENC_S_EFAIL;
-		venc_put_msg(dvenc, &msg);
-	}
-	return ret;
-}
-
-static int venc_flush(struct venc_dev *dvenc, void *argp)
-{
-	int ret = 0;
-	struct venc_msg msg;
-	union venc_msg_data smsg;
-	int status = VENC_S_SUCCESS;
-	struct venc_buffer_flush flush;
-
-	if (copy_from_user(&flush, argp, sizeof(struct venc_buffer_flush)))
-		return -EFAULT;
-	if (flush.flush_mode == VENC_FLUSH_ALL) {
-		ret = dal_call_f0(dvenc->q6_handle, VENC_DALRPC_FLUSH, 1);
-		if (ret)
-			status = VENC_S_EFAIL;
-	} else
-		status = VENC_S_ENOTSUPP;
-
-	if (status != VENC_S_SUCCESS) {
-		if ((flush.flush_mode == VENC_FLUSH_INPUT) ||
-		     (flush.flush_mode == VENC_FLUSH_ALL)) {
-			smsg.flush_ret.flush_mode = VENC_FLUSH_INPUT;
-			msg.msg_data = smsg;
-			msg.status_code = status;
-			msg.msg_code = VENC_MSG_FLUSH;
-			msg.msg_data_size = sizeof(union venc_msg_data);
-			venc_put_msg(dvenc, &msg);
-		}
-		if (flush.flush_mode == VENC_FLUSH_OUTPUT ||
-		     (flush.flush_mode == VENC_FLUSH_ALL)) {
-			smsg.flush_ret.flush_mode = VENC_FLUSH_OUTPUT;
-			msg.msg_data = smsg;
-			msg.status_code = status;
-			msg.msg_code = VENC_MSG_FLUSH;
-			msg.msg_data_size = sizeof(union venc_msg_data);
-			venc_put_msg(dvenc, &msg);
-		}
-		return -EIO;
-	}
-	return ret;
-}
-
-static int venc_get_sequence_hdr(struct venc_dev *dvenc, void *argp)
-{
-	pr_err("%s not supported\n", __func__);
-	return -EIO;
-}
-
-static int venc_set_qp_range(struct venc_dev *dvenc, void *argp)
-{
-	int ret = 0;
-	struct venc_qp_range qp;
-
-	ret = copy_from_user(&qp, argp, sizeof(struct venc_qp_range));
-	if (ret) {
-		pr_err("%s: copy_from_user failed\n", __func__);
-		return ret;
-	}
-
-	if (dvenc->state == VENC_STATE_START ||
-		dvenc->state == VENC_STATE_PAUSE) {
-		ret =
-		    dal_call_f5(dvenc->q6_handle, VENC_DALRPC_UPDATE_QP_RANGE,
-				&qp, sizeof(struct venc_qp_range));
-		if (ret) {
-			pr_err("%s: remote function failed (%d) \n", __func__,
-				ret);
-			return ret;
-		}
-	}
-	return ret;
-}
-
-static int venc_set_intra_period(struct venc_dev *dvenc, void *argp)
-{
-	int ret = 0;
-	u32 pnum = 0;
-
-	ret = copy_from_user(&pnum, argp, sizeof(int));
-	if (ret) {
-		pr_err("%s: copy_from_user failed\n", __func__);
-		return ret;
-	}
-	if (dvenc->state == VENC_STATE_START ||
-		dvenc->state == VENC_STATE_PAUSE) {
-		ret = dal_call_f0(dvenc->q6_handle,
-			VENC_DALRPC_UPDATE_INTRA_PERIOD, pnum);
-		if (ret)
-			pr_err("%s: remote function failed (%d)\n", __func__,
-				ret);
-	}
-	return ret;
-}
-
-static int venc_set_intra_refresh(struct venc_dev *dvenc, void *argp)
-{
-	int ret = 0;
-	u32 mb_num = 0;
-
-	ret = copy_from_user(&mb_num, argp, sizeof(int));
-	if (ret) {
-		pr_err("%s: copy_from_user failed\n", __func__);
-		return ret;
-	}
-	if (dvenc->state == VENC_STATE_START ||
-		dvenc->state == VENC_STATE_PAUSE) {
-		ret = dal_call_f0(dvenc->q6_handle,
-			VENC_DALRPC_UPDATE_INTRA_REFRESH, mb_num);
-		if (ret)
-			pr_err("%s: remote function failed (%d)\n", __func__,
-				ret);
-	}
-	return ret;
-}
-
-static int venc_set_frame_rate(struct venc_dev *dvenc, void *argp)
-{
-	int ret = 0;
-	struct venc_frame_rate pdata;
-	ret = copy_from_user(&pdata, argp, sizeof(struct venc_frame_rate));
-	if (ret) {
-		pr_err("%s: copy_from_user failed\n", __func__);
-		return ret;
-	}
-	if (dvenc->state == VENC_STATE_START ||
-		dvenc->state == VENC_STATE_PAUSE) {
-		ret = dal_call_f5(dvenc->q6_handle,
-				VENC_DALRPC_UPDATE_FRAME_RATE,
-				(void *)&(pdata),
-				sizeof(struct venc_frame_rate));
-		if (ret)
-			pr_err("%s: remote function failed (%d)\n", __func__,
-				ret);
-	}
-	return ret;
-}
-
-static int venc_set_target_bitrate(struct venc_dev *dvenc, void *argp)
-{
-	int ret = 0;
-	u32 pdata = 0;
-
-	ret = copy_from_user(&pdata, argp, sizeof(int));
-	if (ret) {
-		pr_err("%s: copy_from_user failed\n", __func__);
-		return ret;
-	}
-	if (dvenc->state == VENC_STATE_START ||
-		dvenc->state == VENC_STATE_PAUSE) {
-		ret = dal_call_f0(dvenc->q6_handle,
-			VENC_DALRPC_UPDATE_BITRATE, pdata);
-		if (ret)
-			pr_err("%s: remote function failed (%d)\n", __func__,
-				ret);
-	}
-	return ret;
-}
-
-static int venc_request_iframe(struct venc_dev *dvenc)
-{
-	int ret = 0;
-
-	if (dvenc->state != VENC_STATE_START)
-		return -EINVAL;
-
-	ret = dal_call_f0(dvenc->q6_handle, VENC_DALRPC_REQUEST_IFRAME, 1);
-	if (ret)
-		pr_err("%s: remote function failed (%d)\n", __func__, ret);
-	return ret;
-}
-
-static int venc_stop_read_msg(struct venc_dev *dvenc)
-{
-	struct venc_msg msg;
-	int ret = 0;
-
-	msg.status_code = 0;
-	msg.msg_code = VENC_MSG_STOP_READING_MSG;
-	msg.msg_data_size = 0;
-	venc_put_msg(dvenc, &msg);
-	return ret;
-}
-
-static int venc_q6_stop(struct venc_dev *dvenc)
-{
-	int ret = 0;
-	struct venc_pmem_list *plist;
-	unsigned long flags;
-
-	wake_up(&dvenc->venc_msg_evt);
-	spin_lock_irqsave(&dvenc->venc_pmem_list_lock, flags);
-	if (!dvenc->pmem_freed) {
-		list_for_each_entry(plist, &dvenc->venc_pmem_list_head, list)
-			put_pmem_file(plist->buf.file);
-		dvenc->pmem_freed = 1;
-	}
-	spin_unlock_irqrestore(&dvenc->venc_pmem_list_lock, flags);
-
-	dvenc->state = VENC_STATE_STOP;
-	return ret;
-}
-
-static int venc_translate_error(enum venc_status_code q6_status)
-{
-	int ret = 0;
-
-	switch (q6_status) {
-	case VENC_STATUS_SUCCESS:
-		ret = VENC_S_SUCCESS;
-		break;
-	case VENC_STATUS_ERROR:
-		ret = VENC_S_EFAIL;
-		break;
-	case VENC_STATUS_INVALID_STATE:
-		ret = VENC_S_EINVALSTATE;
-		break;
-	case VENC_STATUS_FLUSHING:
-		ret = VENC_S_EFLUSHED;
-		break;
-	case VENC_STATUS_INVALID_PARAM:
-		ret = VENC_S_EBADPARAM;
-		break;
-	case VENC_STATUS_CMD_QUEUE_FULL:
-		ret = VENC_S_ECMDQFULL;
-		break;
-	case VENC_STATUS_CRITICAL:
-		ret = VENC_S_EFATAL;
-		break;
-	case VENC_STATUS_INSUFFICIENT_RESOURCES:
-		ret = VENC_S_ENOHWRES;
-		break;
-	case VENC_STATUS_TIMEOUT:
-		ret = VENC_S_ETIMEOUT;
-		break;
-	}
-	if (q6_status != VENC_STATUS_SUCCESS)
-		pr_err("%s: Q6 failed (%d)", __func__, (int)q6_status);
-	return ret;
-}
-
-static void venc_q6_callback(void *data, int len, void *cookie)
-{
-	int status = 0;
-	struct venc_dev *dvenc = (struct venc_dev *)cookie;
-	struct venc_msg_type *q6_msg = NULL;
-	struct venc_msg msg, msg1;
-	union venc_msg_data smsg1, smsg2;
-	unsigned long msg_code = 0;
-	struct venc_input_payload *pload1;
-	struct venc_output_payload *pload2;
-	uint32_t * tmp = (uint32_t *) data;
-
-	if (dvenc == NULL) {
-		pr_err("%s: empty driver parameter\n", __func__);
-		return;
-	}
-	if (tmp[2] == sizeof(struct venc_msg_type)) {
-		q6_msg = (struct venc_msg_type *)&tmp[3];
-	} else {
-		pr_err("%s: callback with empty message (%d, %d)\n",
-			__func__, tmp[2], sizeof(struct venc_msg_type));
-		return;
-	}
-	msg.msg_data_size = 0;
-	status = venc_translate_error(q6_msg->status);
-	switch ((enum venc_event_type_enum)q6_msg->event) {
-	case VENC_EVENT_START_STATUS:
-		dvenc->state = VENC_STATE_START;
-		msg_code = VENC_MSG_START;
-		break;
-	case VENC_EVENT_STOP_STATUS:
-		venc_q6_stop(dvenc);
-		msg_code = VENC_MSG_STOP;
-		break;
-	case VENC_EVENT_SUSPEND_STATUS:
-		dvenc->state = VENC_STATE_PAUSE;
-		msg_code = VENC_MSG_PAUSE;
-		break;
-	case VENC_EVENT_RESUME_STATUS:
-		dvenc->state = VENC_STATE_START;
-		msg_code = VENC_MSG_RESUME;
-		break;
-	case VENC_EVENT_FLUSH_STATUS:
-		smsg1.flush_ret.flush_mode = VENC_FLUSH_INPUT;
-		msg1.status_code = status;
-		msg1.msg_code = VENC_MSG_FLUSH;
-		msg1.msg_data = smsg1;
-		msg1.msg_data_size = sizeof(union venc_msg_data);
-		venc_put_msg(dvenc, &msg1);
-		smsg2.flush_ret.flush_mode = VENC_FLUSH_OUTPUT;
-		msg_code = VENC_MSG_FLUSH;
-		msg.msg_data = smsg2;
-		msg.msg_data_size = sizeof(union venc_msg_data);
-		break;
-	case VENC_EVENT_RELEASE_INPUT:
-		pload1 = &((q6_msg->payload).input_payload);
-		TRACE("Release_input: data: 0x%x \n", pload1->data);
-		if (pload1 != NULL) {
-			msg.msg_data.buf.client_data = pload1->data;
-			msg_code = VENC_MSG_INPUT_BUFFER_DONE;
-			msg.msg_data_size = sizeof(union venc_msg_data);
-		}
-		break;
-	case VENC_EVENT_DELIVER_OUTPUT:
-		pload2 = &((q6_msg->payload).output_payload);
-		smsg1.buf.flags = 0;
-		if (pload2->flags & VENC_FLAG_SYNC_FRAME)
-			smsg1.buf.flags |= VENC_FLAG_SYNC_FRAME;
-		if (pload2->flags & VENC_FLAG_CODEC_CONFIG)
-			smsg1.buf.flags |= VENC_FLAG_CODEC_CONFIG;
-		if (pload2->flags & VENC_FLAG_END_OF_FRAME)
-			smsg1.buf.flags |= VENC_FLAG_END_OF_FRAME;
-		if (pload2->flags & VENC_FLAG_EOS)
-			smsg1.buf.flags |= VENC_FLAG_EOS;
-		smsg1.buf.len = pload2->size;
-		smsg1.buf.offset = 0;
-		smsg1.buf.time_stamp = pload2->time_stamp;
-		smsg1.buf.client_data = pload2->data;
-		msg_code = VENC_MSG_OUTPUT_BUFFER_DONE;
-		msg.msg_data = smsg1;
-		msg.msg_data_size = sizeof(union venc_msg_data);
-		break;
-	default:
-		pr_err("%s: invalid response from Q6 (%d)\n", __func__,
-			(int)q6_msg->event);
-		return;
-	}
-	msg.status_code = status;
-	msg.msg_code = msg_code;
-	venc_put_msg(dvenc, &msg);
-	return;
-}
-
-static int venc_get_version(struct venc_dev *dvenc, void *argp)
-{
-	struct venc_version ver_info;
-	int ret = 0;
-
-	ver_info.major = VENC_GET_MAJOR_VERSION(VENC_INTERFACE_VERSION);
-	ver_info.minor = VENC_GET_MINOR_VERSION(VENC_INTERFACE_VERSION);
-
-	ret = copy_to_user(((struct venc_version *)argp),
-				&ver_info, sizeof(ver_info));
-	if (ret)
-		pr_err("%s failed to copy_to_user\n", __func__);
-
-	return ret;
-
-}
-
-static long q6venc_ioctl(struct file *file, u32 cmd,
-			   unsigned long arg)
-{
-	long ret = 0;
-	void __user *argp = (void __user *)arg;
-	struct venc_dev *dvenc = file->private_data;
-
-	if (!dvenc || !dvenc->is_active)
-		return -EPERM;
-
-	switch (cmd) {
-	case VENC_IOCTL_SET_INPUT_BUFFER:
-		ret = venc_set_buffer(dvenc, argp, VENC_BUFFER_TYPE_INPUT);
-		break;
-	case VENC_IOCTL_SET_OUTPUT_BUFFER:
-		ret = venc_set_buffer(dvenc, argp, VENC_BUFFER_TYPE_OUTPUT);
-		break;
-	case VENC_IOCTL_GET_SEQUENCE_HDR:
-		ret = venc_get_sequence_hdr(dvenc, argp);
-		break;
-	case VENC_IOCTL_SET_QP_RANGE:
-		ret = venc_set_qp_range(dvenc, argp);
-		break;
-	case VENC_IOCTL_SET_INTRA_PERIOD:
-		ret = venc_set_intra_period(dvenc, argp);
-		break;
-	case VENC_IOCTL_SET_INTRA_REFRESH:
-		ret = venc_set_intra_refresh(dvenc, argp);
-		break;
-	case VENC_IOCTL_SET_FRAME_RATE:
-		ret = venc_set_frame_rate(dvenc, argp);
-		break;
-	case VENC_IOCTL_SET_TARGET_BITRATE:
-		ret = venc_set_target_bitrate(dvenc, argp);
-		break;
-	case VENC_IOCTL_CMD_REQUEST_IFRAME:
-		if (dvenc->state == VENC_STATE_START)
-			ret = venc_request_iframe(dvenc);
-		break;
-	case VENC_IOCTL_CMD_START:
-		ret = venc_start(dvenc, argp);
-		break;
-	case VENC_IOCTL_CMD_STOP:
-		ret = venc_stop(dvenc);
-		break;
-	case VENC_IOCTL_CMD_PAUSE:
-		ret = venc_pause(dvenc);
-		break;
-	case VENC_IOCTL_CMD_RESUME:
-		ret = venc_resume(dvenc);
-		break;
-	case VENC_IOCTL_CMD_ENCODE_FRAME:
-		ret = venc_encode_frame(dvenc, argp);
-		break;
-	case VENC_IOCTL_CMD_FILL_OUTPUT_BUFFER:
-		ret = venc_fill_output(dvenc, argp);
-		break;
-	case VENC_IOCTL_CMD_FLUSH:
-		ret = venc_flush(dvenc, argp);
-		break;
-	case VENC_IOCTL_CMD_READ_NEXT_MSG:
-		wait_event_interruptible(dvenc->venc_msg_evt,
-					  venc_get_msg(dvenc, argp));
-		break;
-	case VENC_IOCTL_CMD_STOP_READ_MSG:
-		ret = venc_stop_read_msg(dvenc);
-		break;
-	case VENC_IOCTL_GET_VERSION:
-		ret = venc_get_version(dvenc, argp);
-		break;
-	default:
-		pr_err("%s: invalid ioctl code (%d)\n", __func__, cmd);
-		ret = -ENOTTY;
-		break;
-	}
-	return ret;
-}
-
-static int q6venc_open(struct inode *inode, struct file *file)
-{
-	int i;
-	int ret = 0;
-	struct venc_dev *dvenc;
-	struct venc_msg_list *plist, *tmp;
-	struct dal_info version_info;
-
-	dvenc = kzalloc(sizeof(struct venc_dev), GFP_KERNEL);
-	if (!dvenc) {
-		pr_err("%s: unable to allocate memory for struct venc_dev\n",
-			__func__);
-		return -ENOMEM;
-	}
-	file->private_data = dvenc;
-	INIT_LIST_HEAD(&dvenc->venc_msg_list_head);
-	INIT_LIST_HEAD(&dvenc->venc_msg_list_free);
-	INIT_LIST_HEAD(&dvenc->venc_pmem_list_head);
-	init_waitqueue_head(&dvenc->venc_msg_evt);
-	spin_lock_init(&dvenc->venc_msg_list_lock);
-	spin_lock_init(&dvenc->venc_pmem_list_lock);
-	venc_ref++;
-	for (i = 0; i < VENC_MSG_MAX; i++) {
-		plist = kzalloc(sizeof(struct venc_msg_list), GFP_KERNEL);
-		if (!plist) {
-			pr_err("%s: kzalloc failed\n", __func__);
-			ret = -ENOMEM;
-			goto err_venc_create_msg_list;
-		}
-		list_add(&plist->list, &dvenc->venc_msg_list_free);
-	}
-	dvenc->q6_handle =
-	    dal_attach(DALDEVICEID_VENC_DEVICE, DALDEVICEID_VENC_PORTNAME, 1,
-		       venc_q6_callback, (void *)dvenc);
-	if (!(dvenc->q6_handle)) {
-		pr_err("%s: daldevice_attach failed (%d)\n", __func__, ret);
-		goto err_venc_dal_attach;
-	}
-	ret = dal_call_f9(dvenc->q6_handle, DAL_OP_INFO, &version_info,
-		sizeof(struct dal_info));
-	if (ret) {
-		pr_err("%s: failed to get version\n", __func__);
-		goto err_venc_dal_open;
-	}
-	if (venc_check_version(VENC_INTERFACE_VERSION, version_info.version)) {
-		pr_err("%s: driver version mismatch\n", __func__);
-		goto err_venc_dal_open;
-	}
-	ret = dal_call_f0(dvenc->q6_handle, DAL_OP_OPEN, 1);
-	if (ret) {
-		pr_err("%s: dal_call_open failed (%d)\n", __func__, ret);
-		goto err_venc_dal_open;
-	}
-	dvenc->state = VENC_STATE_STOP;
-	dvenc->is_active = 1;
-	prevent_sleep();
-	return ret;
-err_venc_dal_open:
-	dal_detach(dvenc->q6_handle);
-err_venc_dal_attach:
-	list_for_each_entry_safe(plist, tmp, &dvenc->venc_msg_list_free, list) {
-		list_del(&plist->list);
-		kfree(plist);
-	}
-err_venc_create_msg_list:
-	kfree(dvenc);
-	venc_ref--;
-	return ret;
-}
-
-static int q6venc_release(struct inode *inode, struct file *file)
-{
-	int ret = 0;
-	struct venc_msg_list *l, *n;
-	struct venc_pmem_list *plist, *m;
-	struct venc_dev *dvenc;
-	unsigned long flags;
-
-	venc_ref--;
-	dvenc = file->private_data;
-	dvenc->is_active = 0;
-	wake_up_all(&dvenc->venc_msg_evt);
-	dal_call_f0(dvenc->q6_handle, VENC_DALRPC_STOP, 1);
-	dal_call_f0(dvenc->q6_handle, DAL_OP_CLOSE, 1);
-	dal_detach(dvenc->q6_handle);
-	list_for_each_entry_safe(l, n, &dvenc->venc_msg_list_free, list) {
-		list_del(&l->list);
-		kfree(l);
-	}
-	list_for_each_entry_safe(l, n, &dvenc->venc_msg_list_head, list) {
-		list_del(&l->list);
-		kfree(l);
-	}
-	spin_lock_irqsave(&dvenc->venc_pmem_list_lock, flags);
-	if (!dvenc->pmem_freed) {
-		list_for_each_entry(plist, &dvenc->venc_pmem_list_head, list)
-			put_pmem_file(plist->buf.file);
-		dvenc->pmem_freed = 1;
-	}
-	spin_unlock_irqrestore(&dvenc->venc_pmem_list_lock, flags);
-
-	list_for_each_entry_safe(plist, m, &dvenc->venc_pmem_list_head, list) {
-		list_del(&plist->list);
-		kfree(plist);
-	}
-	kfree(dvenc);
-	allow_sleep();
-	return ret;
-}
-
-const struct file_operations q6venc_fops = {
-	.owner = THIS_MODULE,
-	.open = q6venc_open,
-	.release = q6venc_release,
-	.unlocked_ioctl = q6venc_ioctl,
-};
-
-static int __init q6venc_init(void)
-{
-	int ret = 0;
-
-	pm_qos_add_request(&pm_qos_req, PM_QOS_CPU_DMA_LATENCY,
-				PM_QOS_DEFAULT_VALUE);
-	wake_lock_init(&wakelock, WAKE_LOCK_SUSPEND, "venc_suspend");
-
-	venc_device_p = kzalloc(sizeof(struct venc_dev), GFP_KERNEL);
-	if (!venc_device_p) {
-		pr_err("%s: unable to allocate memory for venc_device_p\n",
-			__func__);
-		return -ENOMEM;
-	}
-	ret = alloc_chrdev_region(&venc_dev_num, 0, 1, VENC_NAME);
-	if (ret < 0) {
-		pr_err("%s: alloc_chrdev_region failed (%d)\n", __func__,
-			ret);
-		return ret;
-	}
-	venc_class = class_create(THIS_MODULE, VENC_NAME);
-	if (IS_ERR(venc_class)) {
-		ret = PTR_ERR(venc_class);
-		pr_err("%s: failed to create venc_class (%d)\n",
-			__func__, ret);
-		goto err_venc_class_create;
-	}
-	venc_device_p->class_devp =
-	    device_create(venc_class, NULL, venc_dev_num, NULL,
-			  VENC_NAME);
-	if (IS_ERR(venc_device_p->class_devp)) {
-		ret = PTR_ERR(venc_device_p->class_devp);
-		pr_err("%s: failed to create class_device (%d)\n", __func__,
-			ret);
-		goto err_venc_class_device_create;
-	}
-	cdev_init(&cdev, &q6venc_fops);
-	cdev.owner = THIS_MODULE;
-	ret = cdev_add(&cdev, venc_dev_num, 1);
-	if (ret < 0) {
-		pr_err("%s: cdev_add failed (%d)\n", __func__, ret);
-		goto err_venc_cdev_add;
-	}
-	init_waitqueue_head(&venc_device_p->venc_msg_evt);
-	return ret;
-
-err_venc_cdev_add:
-	device_destroy(venc_class, venc_dev_num);
-err_venc_class_device_create:
-	class_destroy(venc_class);
-err_venc_class_create:
-	unregister_chrdev_region(venc_dev_num, 1);
-	return ret;
-}
-
-static void __exit q6venc_exit(void)
-{
-	cdev_del(&(cdev));
-	device_destroy(venc_class, venc_dev_num);
-	class_destroy(venc_class);
-	unregister_chrdev_region(venc_dev_num, 1);
-}
-
-MODULE_LICENSE("GPL v2");
-MODULE_DESCRIPTION("Video encoder driver for QDSP6");
-MODULE_VERSION("2.0");
-module_init(q6venc_init);
-module_exit(q6venc_exit);
diff --git a/arch/arm/mach-msm/qdsp6/pcm_in.c b/arch/arm/mach-msm/qdsp6/pcm_in.c
deleted file mode 100644
index 288e1dc..0000000
--- a/arch/arm/mach-msm/qdsp6/pcm_in.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/* arch/arm/mach-msm/qdsp6/pcm_in.c
- *
- * Copyright (C) 2009 Google, Inc.
- * Copyright (C) 2009 HTC Corporation
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/slab.h>
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/uaccess.h>
-
-#include <linux/msm_audio.h>
-
-#include <mach/msm_qdsp6_audio.h>
-#include <mach/debug_mm.h>
-
-struct pcm {
-	struct audio_client *ac;
-	uint32_t sample_rate;
-	uint32_t channel_count;
-	uint32_t buffer_size;
-	uint32_t rec_mode;
-};
-
-#define BUFSZ (256)
-
-void audio_client_dump(struct audio_client *ac);
-
-static long q6_in_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct pcm *pcm = file->private_data;
-	int rc = 0;
-
-	switch (cmd) {
-	case AUDIO_SET_VOLUME:
-		pr_debug("[%s:%s] SET_VOLUME\n", __MM_FILE__, __func__);
-		break;
-	case AUDIO_GET_STATS: {
-		struct msm_audio_stats stats;
-		pr_debug("[%s:%s] GET_STATS\n", __MM_FILE__, __func__);
-		memset(&stats, 0, sizeof(stats));
-		if (copy_to_user((void*) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-	case AUDIO_START: {
-		uint32_t acdb_id;
-		pr_debug("[%s:%s] AUDIO_START\n", __MM_FILE__, __func__);
-		rc = 0;
-
-		if (arg == 0) {
-			acdb_id = 0;
-		} else if (copy_from_user(&acdb_id, (void*) arg, sizeof(acdb_id))) {
-			rc = -EFAULT;
-			break;
-		}
-
-		if (pcm->ac) {
-			pr_err("[%s:%s] active session already existing\n",
-				__MM_FILE__, __func__);
-			rc = -EBUSY;
-		} else {
-			pcm->ac = q6audio_open_pcm(pcm->buffer_size,
-					pcm->sample_rate, pcm->channel_count,
-					pcm->rec_mode, acdb_id);
-			if (!pcm->ac) {
-				pr_err("[%s:%s] pcm open session failed\n",
-					__MM_FILE__, __func__);
-				rc = -ENOMEM;
-			}
-		}
-		break;
-	}
-	case AUDIO_STOP:
-		pr_debug("[%s:%s] AUDIO_STOP\n", __MM_FILE__, __func__);
-		break;
-	case AUDIO_FLUSH:
-		break;
-	case AUDIO_SET_CONFIG: {
-		struct msm_audio_config config;
-		if (copy_from_user(&config, (void*) arg, sizeof(config))) {
-			rc = -EFAULT;
-			break;
-		}
-		pr_debug("[%s:%s] SET_CONFIG: samplerate = %d, channels = %d\n",
-			__MM_FILE__, __func__, config.sample_rate,
-			config.channel_count);
-		if (!config.channel_count || config.channel_count > 2) {
-			rc = -EINVAL;
-			pr_err("[%s:%s] invalid channelcount %d\n",
-			__MM_FILE__, __func__, config.channel_count);
-			break;
-		}
-		if (config.sample_rate < 8000 || config.sample_rate > 48000) {
-			rc = -EINVAL;
-			pr_err("[%s:%s] invalid samplerate %d\n", __MM_FILE__,
-				__func__, config.sample_rate);
-			break;
-		}
-		if (config.buffer_size < 128 || config.buffer_size > 8192) {
-			rc = -EINVAL;
-			pr_err("[%s:%s] invalid buffsize %d\n", __MM_FILE__,
-				__func__, config.buffer_size);
-			break;
-		}
-
-		pcm->sample_rate = config.sample_rate;
-		pcm->channel_count = config.channel_count;
-		pcm->buffer_size = config.buffer_size;
-		break;
-	}
-	case AUDIO_SET_INCALL: {
-		struct msm_voicerec_mode voicerec_mode;
-		pr_debug("[%s:%s] SET_INCALL\n", __MM_FILE__, __func__);
-		if (copy_from_user(&voicerec_mode, (void *)arg,
-			sizeof(struct msm_voicerec_mode)))
-			return -EFAULT;
-		if (voicerec_mode.rec_mode != AUDIO_FLAG_READ &&
-			voicerec_mode.rec_mode != AUDIO_FLAG_INCALL_MIXED) {
-			pcm->rec_mode = AUDIO_FLAG_READ;
-			pr_err("[%s:%s] invalid rec_mode\n", __MM_FILE__,
-					__func__);
-			rc = -EINVAL;
-		} else
-			pcm->rec_mode = voicerec_mode.rec_mode;
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config config;
-		memset(&config, 0, sizeof(config));
-		config.buffer_size = pcm->buffer_size;
-		config.buffer_count = 2;
-		config.sample_rate = pcm->sample_rate;
-		config.channel_count = pcm->channel_count;
-		config.unused[0] = 0;
-		config.unused[1] = 0;
-		config.unused[2] = 0;
-		if (copy_to_user((void*) arg, &config, sizeof(config))) {
-			rc = -EFAULT;
-		}
-		pr_debug("[%s:%s] GET_CONFIG: samplerate = %d, channels = %d\n",
-			__MM_FILE__, __func__, config.sample_rate,
-			config.channel_count);
-		break;
-	}
-	default:
-		rc = -EINVAL;
-	}
-	pr_debug("[%s:%s] rc = %d\n", __MM_FILE__, __func__, rc);
-	return rc;
-}
-
-static int q6_in_open(struct inode *inode, struct file *file)
-{
-	struct pcm *pcm;
-
-	pr_info("[%s:%s] open\n", __MM_FILE__, __func__);
-	pcm = kzalloc(sizeof(struct pcm), GFP_KERNEL);
-
-	if (!pcm)
-		return -ENOMEM;
-
-	pcm->channel_count = 1;
-	pcm->sample_rate = 8000;
-	pcm->buffer_size = BUFSZ;
-	pcm->rec_mode = AUDIO_FLAG_READ;
-	file->private_data = pcm;
-	return 0;
-}
-
-static ssize_t q6_in_read(struct file *file, char __user *buf,
-			  size_t count, loff_t *pos)
-{
-	struct pcm *pcm = file->private_data;
-	struct audio_client *ac;
-	struct audio_buffer *ab;
-	const char __user *start = buf;
-	int xfer;
-	int res;
-
-	pr_debug("[%s:%s] count = %d\n", __MM_FILE__, __func__, count);
-	ac = pcm->ac;
-	if (!ac) {
-		res = -ENODEV;
-		goto fail;
-	}
-	while (count > 0) {
-		ab = ac->buf + ac->cpu_buf;
-
-		if (ab->used)
-			if (!wait_event_timeout(ac->wait, (ab->used == 0), 5*HZ)) {
-				audio_client_dump(ac);
-				pr_err("[%s:%s] timeout. dsp dead?\n",
-						__MM_FILE__, __func__);
-				q6audio_dsp_not_responding();
-			}
-		pr_debug("[%s:%s] ab->data = %p, cpu_buf = %d", __MM_FILE__,
-			__func__, ab->data, ac->cpu_buf);
-		xfer = count;
-		if (xfer > ab->size)
-			xfer = ab->size;
-
-		if (copy_to_user(buf, ab->data, xfer)) {
-			res = -EFAULT;
-			goto fail;
-		}
-
-		buf += xfer;
-		count -= xfer;
-
-		ab->used = 1;
-		q6audio_read(ac, ab);
-		ac->cpu_buf ^= 1;
-	}
-fail:
-	res = buf - start;
-	return res;
-}
-
-static int q6_in_release(struct inode *inode, struct file *file)
-{
-
-	int rc = 0;
-	struct pcm *pcm = file->private_data;
-	if (pcm->ac)
-		rc = q6audio_close(pcm->ac);
-	kfree(pcm);
-	pr_info("[%s:%s] release\n", __MM_FILE__, __func__);
-	return rc;
-}
-
-static struct file_operations q6_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= q6_in_open,
-	.read		= q6_in_read,
-	.release	= q6_in_release,
-	.unlocked_ioctl	= q6_in_ioctl,
-};
-
-struct miscdevice q6_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_pcm_in",
-	.fops	= &q6_in_fops,
-};
-
-static int __init q6_in_init(void) {
-	return misc_register(&q6_in_misc);
-}
-
-device_initcall(q6_in_init);
diff --git a/arch/arm/mach-msm/qdsp6/pcm_out.c b/arch/arm/mach-msm/qdsp6/pcm_out.c
deleted file mode 100644
index 2e91cb2..0000000
--- a/arch/arm/mach-msm/qdsp6/pcm_out.c
+++ /dev/null
@@ -1,276 +0,0 @@
-/* arch/arm/mach-msm/qdsp6/pcm_out.c
- *
- * Copyright (C) 2009 Google, Inc.
- * Author: Brian Swetland <swetland@google.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/slab.h>
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/uaccess.h>
-
-#include <linux/msm_audio.h>
-
-#include <mach/msm_qdsp6_audio.h>
-#include <mach/debug_mm.h>
-
-void audio_client_dump(struct audio_client *ac);
-
-#define BUFSZ (3072)
-
-struct pcm {
-	struct mutex lock;
-	struct audio_client *ac;
-	uint32_t sample_rate;
-	uint32_t channel_count;
-	size_t buffer_size;
-};
-
-static long pcm_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct pcm *pcm = file->private_data;
-	int rc = 0;
-
-	if (cmd == AUDIO_GET_STATS) {
-		struct msm_audio_stats stats;
-		memset(&stats, 0, sizeof(stats));
-		if (copy_to_user((void*) arg, &stats, sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-
-	mutex_lock(&pcm->lock);
-	switch (cmd) {
-	case AUDIO_SET_VOLUME: {
-		int vol;
-		if (!pcm->ac) {
-			pr_err("%s: cannot set volume before AUDIO_START!\n",
-				__func__);
-			rc = -EINVAL;
-			break;
-		}
-		if (copy_from_user(&vol, (void*) arg, sizeof(vol))) {
-			rc = -EFAULT;
-			break;
-		}
-		pr_debug("[%s:%s] SET_VOLUME: vol = %d\n", __MM_FILE__,
-			__func__, vol);
-		rc = q6audio_set_stream_volume(pcm->ac, vol);
-		break;
-	}
-	case AUDIO_START: {
-		uint32_t acdb_id;
-		pr_debug("[%s:%s] AUDIO_START\n", __MM_FILE__, __func__);
-		if (arg == 0) {
-			acdb_id = 0;
-		} else if (copy_from_user(&acdb_id, (void*) arg, sizeof(acdb_id))) {
-			pr_info("[%s:%s] copy acdb_id from user failed\n",
-					__MM_FILE__, __func__);
-			rc = -EFAULT;
-			break;
-		}
-		if (pcm->ac) {
-			pr_err("[%s:%s] active session already existing\n",
-				__MM_FILE__, __func__);
-			rc = -EBUSY;
-		} else {
-			pcm->ac = q6audio_open_pcm(pcm->buffer_size,
-						pcm->sample_rate,
-						pcm->channel_count,
-						AUDIO_FLAG_WRITE, acdb_id);
-			if (!pcm->ac) {
-				pr_err("[%s:%s] pcm open session failed\n",
-					__MM_FILE__, __func__);
-				rc = -ENOMEM;
-			}
-		}
-		break;
-	}
-	case AUDIO_STOP:
-		pr_debug("[%s:%s] AUDIO_STOP\n", __MM_FILE__, __func__);
-		break;
-	case AUDIO_FLUSH:
-		break;
-	case AUDIO_SET_CONFIG: {
-		struct msm_audio_config config;
-		if (pcm->ac) {
-			rc = -EBUSY;
-			pr_err("[%s:%s] active session already existing\n",
-				__MM_FILE__, __func__);
-			break;
-		}
-		if (copy_from_user(&config, (void*) arg, sizeof(config))) {
-			rc = -EFAULT;
-			break;
-		}
-		pr_debug("[%s:%s] SET_CONFIG: samplerate = %d, channels = %d\n",
-			__MM_FILE__, __func__, config.sample_rate,
-			config.channel_count);
-		if (config.channel_count < 1 || config.channel_count > 2) {
-			rc = -EINVAL;
-			pr_err("[%s:%s] invalid channelcount %d\n",
-			__MM_FILE__, __func__, config.channel_count);
-			break;
-		}
-		if (config.sample_rate < 8000 || config.sample_rate > 48000) {
-			rc = -EINVAL;
-			pr_err("[%s:%s] invalid samplerate %d\n", __MM_FILE__,
-				__func__, config.sample_rate);
-			break;
-		}
-		if (config.buffer_size < 128 || config.buffer_size > 8192) {
-			rc = -EINVAL;
-			pr_err("[%s:%s] invalid buffsize %d\n", __MM_FILE__,
-				__func__, config.buffer_size);
-			break;
-		}
-		pcm->sample_rate = config.sample_rate;
-		pcm->channel_count = config.channel_count;
-		pcm->buffer_size = config.buffer_size;
-		break;
-	}
-	case AUDIO_GET_CONFIG: {
-		struct msm_audio_config config;
-		config.buffer_size = pcm->buffer_size;
-		config.buffer_count = 2;
-		config.sample_rate = pcm->sample_rate;
-		config.channel_count = pcm->channel_count;
-		config.unused[0] = 0;
-		config.unused[1] = 0;
-		config.unused[2] = 0;
-		if (copy_to_user((void*) arg, &config, sizeof(config))) {
-			rc = -EFAULT;
-		}
-		pr_debug("[%s:%s] GET_CONFIG: samplerate = %d, channels = %d\n",
-			__MM_FILE__, __func__, config.sample_rate,
-			config.channel_count);
-		break;
-	}
-	case AUDIO_SET_EQ: {
-		struct msm_audio_eq_stream_config eq_config;
-		pr_debug("[%s:%s] SET_EQ\n", __MM_FILE__, __func__);
-		if (copy_from_user(&eq_config, (void *) arg,
-						sizeof(eq_config))) {
-			rc = -EFAULT;
-			break;
-		}
-		rc = q6audio_set_stream_eq_pcm(pcm->ac, (void *) &eq_config);
-		break;
-	}
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&pcm->lock);
-	pr_debug("[%s:%s] rc = %d\n", __MM_FILE__, __func__, rc);
-	return rc;
-}
-
-static int pcm_open(struct inode *inode, struct file *file)
-{
-	struct pcm *pcm;
-
-	pr_info("[%s:%s] open\n", __MM_FILE__, __func__);
-	pcm = kzalloc(sizeof(struct pcm), GFP_KERNEL);
-
-	if (!pcm)
-		return -ENOMEM;
-
-	mutex_init(&pcm->lock);
-	pcm->channel_count = 2;
-	pcm->sample_rate = 44100;
-	pcm->buffer_size = BUFSZ;
-	file->private_data = pcm;
-	return 0;
-}
-
-static ssize_t pcm_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct pcm *pcm = file->private_data;
-	struct audio_client *ac;
-	struct audio_buffer *ab;
-	const char __user *start = buf;
-	int xfer;
-
-	pr_debug("[%s:%s] count = %d\n", __MM_FILE__, __func__, count);
-	if (!pcm->ac)
-		pcm_ioctl(file, AUDIO_START, 0);
-
-	ac = pcm->ac;
-	if (!ac)
-		return -ENODEV;
-
-	while (count > 0) {
-		ab = ac->buf + ac->cpu_buf;
-
-		if (ab->used)
-			if (!wait_event_timeout(ac->wait, (ab->used == 0), 5*HZ)) {
-				audio_client_dump(ac);
-				pr_err("[%s:%s] timeout. dsp dead?\n",
-						__MM_FILE__, __func__);
-				q6audio_dsp_not_responding();
-			}
-		pr_debug("[%s:%s] ab->data = %p, cpu_buf = %d", __MM_FILE__,
-			__func__, ab->data, ac->cpu_buf);
-		xfer = count;
-		if (xfer > ab->size)
-			xfer = ab->size;
-
-		if (copy_from_user(ab->data, buf, xfer)) 
-			return -EFAULT;
-
-		buf += xfer;
-		count -= xfer;
-
-		ab->used = 1;
-		ab->actual_size = xfer;
-		q6audio_write(ac, ab);
-		ac->cpu_buf ^= 1;
-	}
-
-	return buf - start;
-}
-
-static int pcm_release(struct inode *inode, struct file *file)
-{
-	struct pcm *pcm = file->private_data;
-	if (pcm->ac)
-		q6audio_close(pcm->ac);
-	kfree(pcm);
-	pr_info("[%s:%s] release\n", __MM_FILE__, __func__);
-	return 0;
-}
-
-static struct file_operations pcm_fops = {
-	.owner		= THIS_MODULE,
-	.open		= pcm_open,
-	.write		= pcm_write,
-	.release	= pcm_release,
-	.unlocked_ioctl	= pcm_ioctl,
-};
-
-struct miscdevice pcm_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_pcm_out",
-	.fops	= &pcm_fops,
-};
-
-static int __init pcm_init(void) {
-	return misc_register(&pcm_misc);
-}
-
-device_initcall(pcm_init);
diff --git a/arch/arm/mach-msm/qdsp6/q6audio.c b/arch/arm/mach-msm/qdsp6/q6audio.c
deleted file mode 100644
index 9404c3d..0000000
--- a/arch/arm/mach-msm/qdsp6/q6audio.c
+++ /dev/null
@@ -1,2157 +0,0 @@
-/*
- * Copyright (C) 2009 Google, Inc.
- * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
- * Author: Brian Swetland <swetland@google.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/slab.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/dma-mapping.h>
-#include <linux/clk.h>
-#include <linux/delay.h>
-#include <linux/wakelock.h>
-#include <linux/firmware.h>
-#include <linux/miscdevice.h>
-#include <linux/pm_qos.h>
-
-#include "dal.h"
-#include "dal_audio.h"
-#include "dal_audio_format.h"
-#include "dal_acdb.h"
-#include "dal_adie.h"
-#include <mach/msm_qdsp6_audio.h>
-#include <mach/cpuidle.h>
-
-#include <linux/msm_audio_aac.h>
-
-#include <linux/gpio.h>
-
-#include "q6audio_devices.h"
-#include <mach/debug_mm.h>
-
-
-struct q6_hw_info {
-	int min_gain;
-	int max_gain;
-};
-
-/* TODO: provide mechanism to configure from board file */
-
-static struct q6_hw_info q6_audio_hw[Q6_HW_COUNT] = {
-	[Q6_HW_HANDSET] = {
-		.min_gain = -400,
-		.max_gain = 1100,
-	},
-	[Q6_HW_HEADSET] = {
-		.min_gain = -1100,
-		.max_gain = 400,
-	},
-	[Q6_HW_SPEAKER] = {
-		.min_gain = -1000,
-		.max_gain = 500,
-	},
-	[Q6_HW_TTY] = {
-		.min_gain = 0,
-		.max_gain = 0,
-	},
-	[Q6_HW_BT_SCO] = {
-		.min_gain = -1100,
-		.max_gain = 400,
-	},
-	[Q6_HW_BT_A2DP] = {
-		.min_gain = -1100,
-		.max_gain = 400,
-	},
-};
-
-static struct wake_lock wakelock;
-static struct pm_qos_request pm_qos_req;
-static int idlecount;
-static DEFINE_MUTEX(idlecount_lock);
-
-void audio_prevent_sleep(void)
-{
-	mutex_lock(&idlecount_lock);
-	if (++idlecount == 1) {
-		wake_lock(&wakelock);
-		pm_qos_update_request(&pm_qos_req,
-				      msm_cpuidle_get_deep_idle_latency());
-	}
-	mutex_unlock(&idlecount_lock);
-}
-
-void audio_allow_sleep(void)
-{
-	mutex_lock(&idlecount_lock);
-	if (--idlecount == 0) {
-		pm_qos_update_request(&pm_qos_req, PM_QOS_DEFAULT_VALUE);
-		wake_unlock(&wakelock);
-	}
-	mutex_unlock(&idlecount_lock);
-}
-
-static struct clk *icodec_rx_clk;
-static struct clk *icodec_tx_clk;
-static struct clk *ecodec_clk;
-static struct clk *sdac_clk;
-
-static struct q6audio_analog_ops default_analog_ops;
-static struct q6audio_analog_ops *analog_ops = &default_analog_ops;
-static uint32_t tx_clk_freq = 8000;
-static int tx_mute_status = 0;
-static int rx_vol_level = 100;
-static uint32_t tx_acdb = 0;
-static uint32_t rx_acdb = 0;
-
-void q6audio_register_analog_ops(struct q6audio_analog_ops *ops)
-{
-	analog_ops = ops;
-}
-
-static struct q6_device_info *q6_lookup_device(uint32_t device_id,
-						uint32_t acdb_id)
-{
-	struct q6_device_info *di = q6_audio_devices;
-
-	pr_debug("[%s:%s] device_id = 0x%x, acdb_id = %d\n", __MM_FILE__,
-		__func__, device_id, acdb_id);
-	if (acdb_id) {
-		for (;;) {
-			if (di->cad_id == acdb_id && di->id == device_id)
-				return di;
-			if (di->id == 0) {
-				pr_err("[%s:%s] bogus id 0x%08x\n",
-					__MM_FILE__, __func__, device_id);
-				return di;
-			}
-			di++;
-		}
-	} else {
-		for (;;) {
-			if (di->id == device_id)
-				return di;
-			if (di->id == 0) {
-				pr_err("[%s:%s] bogus id 0x%08x\n",
-					__MM_FILE__, __func__, device_id);
-				return di;
-			}
-			di++;
-		}
-	}
-}
-
-static uint32_t q6_device_to_codec(uint32_t device_id)
-{
-	struct q6_device_info *di = q6_lookup_device(device_id, 0);
-	return di->codec;
-}
-
-static uint32_t q6_device_to_dir(uint32_t device_id)
-{
-	struct q6_device_info *di = q6_lookup_device(device_id, 0);
-	return di->dir;
-}
-
-static uint32_t q6_device_to_cad_id(uint32_t device_id)
-{
-	struct q6_device_info *di = q6_lookup_device(device_id, 0);
-	return di->cad_id;
-}
-
-static uint32_t q6_device_to_path(uint32_t device_id, uint32_t acdb_id)
-{
-	struct q6_device_info *di = q6_lookup_device(device_id, acdb_id);
-	return di->path;
-}
-
-static uint32_t q6_device_to_rate(uint32_t device_id)
-{
-	struct q6_device_info *di = q6_lookup_device(device_id, 0);
-	return di->rate;
-}
-
-int q6_device_volume(uint32_t device_id, int level)
-{
-	struct q6_device_info *di = q6_lookup_device(device_id, 0);
-	struct q6_hw_info *hw;
-
-	hw = &q6_audio_hw[di->hw];
-
-	return hw->min_gain + ((hw->max_gain - hw->min_gain) * level) / 100;
-}
-
-static inline int adie_open(struct dal_client *client) 
-{
-	pr_debug("[%s:%s]\n", __MM_FILE__, __func__);
-	return dal_call_f0(client, DAL_OP_OPEN, 0);
-}
-
-static inline int adie_close(struct dal_client *client) 
-{
-	pr_debug("[%s:%s]\n", __MM_FILE__, __func__);
-	return dal_call_f0(client, DAL_OP_CLOSE, 0);
-}
-
-static inline int adie_set_path(struct dal_client *client,
-				uint32_t id, uint32_t path_type)
-{
-	pr_debug("[%s:%s] id = 0x%x, path_type = %d\n", __MM_FILE__,
-		__func__, id, path_type);
-	return dal_call_f1(client, ADIE_OP_SET_PATH, id, path_type);
-}
-
-static inline int adie_set_path_freq_plan(struct dal_client *client,
-					  uint32_t path_type, uint32_t plan) 
-{
-	pr_debug("[%s:%s] path_type = %d, plan = %d\n",	__MM_FILE__,
-		__func__, path_type, plan);
-	return dal_call_f1(client, ADIE_OP_SET_PATH_FREQUENCY_PLAN,
-			   path_type, plan);
-}
-
-static inline int adie_proceed_to_stage(struct dal_client *client,
-					uint32_t path_type, uint32_t stage)
-{
-	pr_debug("[%s:%s] path_type = %d, stage = 0x%x\n", __MM_FILE__,
-		__func__, path_type, stage);
-	return dal_call_f1(client, ADIE_OP_PROCEED_TO_STAGE,
-			   path_type, stage);
-}
-
-static inline int adie_mute_path(struct dal_client *client,
-				 uint32_t path_type, uint32_t mute_state)
-{
-	pr_debug("[%s:%s] path_type = %d, mute = %d\n",	__MM_FILE__, __func__,
-		 path_type, mute_state);
-	return dal_call_f1(client, ADIE_OP_MUTE_PATH, path_type, mute_state);
-}
-
-static int adie_refcount;
-
-static struct dal_client *adie;
-static struct dal_client *adsp;
-static struct dal_client *acdb;
-
-static int adie_enable(void)
-{
-	adie_refcount++;
-	if (adie_refcount == 1)
-		adie_open(adie);
-	return 0;
-}
-
-static int adie_disable(void)
-{
-	adie_refcount--;
-	if (adie_refcount == 0)
-		adie_close(adie);
-	return 0;
-}
-
-/* 4k PMEM used for exchanging acdb device config tables
- * and stream format descriptions with the DSP.
- */
-static char *audio_data;
-static int32_t audio_phys;
-
-#define SESSION_MIN 0
-#define SESSION_MAX 64
-
-static DEFINE_MUTEX(session_lock);
-static DEFINE_MUTEX(audio_lock);
-
-static struct audio_client *session[SESSION_MAX];
-
-static int session_alloc(struct audio_client *ac)
-{
-	int n;
-
-	mutex_lock(&session_lock);
-	for (n = SESSION_MIN; n < SESSION_MAX; n++) {
-		if (!session[n]) {
-			session[n] = ac;
-			mutex_unlock(&session_lock);
-			pr_debug("[%s:%s] session = %d\n", __MM_FILE__,
-				__func__, n);
-			return n;
-		}
-	}
-	mutex_unlock(&session_lock);
-	return -ENOMEM;
-}
-
-static void session_free(int n, struct audio_client *ac)
-{
-	mutex_lock(&session_lock);
-	if (session[n] == ac) {
-		session[n] = 0;
-		pr_debug("[%s:%s] session = %d\n", __MM_FILE__, __func__, n);
-	}
-	mutex_unlock(&session_lock);
-}
-
-static void audio_client_free(struct audio_client *ac)
-{
-	pr_debug("[%s:%s] ac = %p\n", __MM_FILE__, __func__, ac);
-	session_free(ac->session, ac);
-
-	if (ac->buf[0].data) {
-		iounmap(ac->buf[0].data);
-		pmem_kfree(ac->buf[0].phys);
-	}
-	if (ac->buf[1].data) {
-		iounmap(ac->buf[1].data);
-		pmem_kfree(ac->buf[1].phys);
-	}
-	kfree(ac);
-}
-
-static struct audio_client *audio_client_alloc(unsigned bufsz)
-{
-	struct audio_client *ac;
-	int n;
-
-	pr_debug("[%s:%s] bufsz = %d\n", __MM_FILE__, __func__, bufsz);
-	ac = kzalloc(sizeof(*ac), GFP_KERNEL);
-	if (!ac)
-		return 0;
-
-	n = session_alloc(ac);
-	if (n < 0)
-		goto fail_session;
-	ac->session = n;
-
-	if (bufsz > 0) {
-		ac->buf[0].phys = pmem_kalloc(bufsz,
-					PMEM_MEMTYPE_EBI1|PMEM_ALIGNMENT_4K);
-		ac->buf[0].data = ioremap(ac->buf[0].phys, bufsz);
-		if (!ac->buf[0].data)
-			goto fail;
-		ac->buf[1].phys = pmem_kalloc(bufsz,
-					PMEM_MEMTYPE_EBI1|PMEM_ALIGNMENT_4K);
-		ac->buf[1].data = ioremap(ac->buf[1].phys, bufsz);
-		if (!ac->buf[1].data)
-			goto fail;
-
-		ac->buf[0].size = bufsz;
-		ac->buf[1].size = bufsz;
-	}
-
-	init_waitqueue_head(&ac->wait);
-	ac->client = adsp;
-
-	return ac;
-
-fail:
-	session_free(n, ac);
-fail_session:
-	audio_client_free(ac);
-	return 0;
-}
-
-void audio_client_dump(struct audio_client *ac)
-{
-	dal_trace_dump(ac->client);
-}
-
-static int audio_ioctl(struct audio_client *ac, void *ptr, uint32_t len)
-{
-	struct adsp_command_hdr *hdr = ptr;
-	uint32_t tmp;
-	int r;
-
-	hdr->size = len - sizeof(u32);
-	hdr->dst = AUDIO_ADDR(ac->session, 0, AUDIO_DOMAIN_DSP);
-	hdr->src = AUDIO_ADDR(ac->session, 0, AUDIO_DOMAIN_APP);
-	hdr->context = ac->session;
-	ac->cb_status = -EBUSY;
-	r = dal_call(ac->client, AUDIO_OP_CONTROL, 5, ptr, len, &tmp, sizeof(tmp));
-	if (r != 4)
-		return -EIO;
-	if (!wait_event_timeout(ac->wait, (ac->cb_status != -EBUSY), 5*HZ)) {
-		dal_trace_dump(ac->client);
-		pr_err("[%s:%s] timeout. dsp dead?\n", __MM_FILE__, __func__);
-		q6audio_dsp_not_responding();
-	}
-	return ac->cb_status;
-}
-
-static int audio_command(struct audio_client *ac, uint32_t cmd)
-{
-	struct adsp_command_hdr rpc;
-	memset(&rpc, 0, sizeof(rpc));
-	rpc.opcode = cmd;
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-static int audio_open_control(struct audio_client *ac)
-{
-	struct adsp_open_command rpc;
-
-	pr_debug("[%s:%s] ac = %p\n", __MM_FILE__, __func__, ac);
-	memset(&rpc, 0, sizeof(rpc));
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_OPEN_DEVICE;
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-static int audio_out_open(struct audio_client *ac, uint32_t bufsz,
-			  uint32_t rate, uint32_t channels)
-{
-	struct adsp_open_command rpc;
-
-	memset(&rpc, 0, sizeof(rpc));
-
-	rpc.format.standard.format = ADSP_AUDIO_FORMAT_PCM;
-	rpc.format.standard.channels = channels;
-	rpc.format.standard.bits_per_sample = 16;
-	rpc.format.standard.sampling_rate = rate;
-	rpc.format.standard.is_signed = 1;
-	rpc.format.standard.is_interleaved = 1;
-
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_OPEN_WRITE;
-	rpc.device = ADSP_AUDIO_DEVICE_ID_DEFAULT;
-	rpc.stream_context = ADSP_AUDIO_DEVICE_CONTEXT_PLAYBACK;
-	rpc.buf_max_size = bufsz;
-
-	pr_debug("[%s:%s]ac = %p\n", __MM_FILE__, __func__, ac);
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-static int audio_in_open(struct audio_client *ac, uint32_t bufsz,
-			 uint32_t flags, uint32_t rate, uint32_t channels)
-{
-	struct adsp_open_command rpc;
-
-	memset(&rpc, 0, sizeof(rpc));
-
-	rpc.format.standard.format = ADSP_AUDIO_FORMAT_PCM;
-	rpc.format.standard.channels = channels;
-	rpc.format.standard.bits_per_sample = 16;
-	rpc.format.standard.sampling_rate = rate;
-	rpc.format.standard.is_signed = 1;
-	rpc.format.standard.is_interleaved = 1;
-
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_OPEN_READ;
-	rpc.device = ADSP_AUDIO_DEVICE_ID_DEFAULT;
-	if (flags == AUDIO_FLAG_READ)
-		rpc.stream_context = ADSP_AUDIO_DEVICE_CONTEXT_RECORD;
-	else
-		rpc.stream_context = ADSP_AUDIO_DEVICE_CONTEXT_MIXED_RECORD;
-
-	rpc.buf_max_size = bufsz;
-
-	pr_debug("[%s:%s] ac = %p\n", __MM_FILE__, __func__, ac);
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-static int audio_auxpcm_out_open(struct audio_client *ac,
-			  uint32_t rate, uint32_t channels)
-{
-	struct adsp_open_command rpc;
-
-	memset(&rpc, 0, sizeof(rpc));
-
-	rpc.format.standard.format = ADSP_AUDIO_FORMAT_PCM;
-	rpc.format.standard.channels = channels;
-	rpc.format.standard.bits_per_sample = 16;
-	rpc.format.standard.sampling_rate = rate;
-	rpc.format.standard.is_signed = 1;
-	rpc.format.standard.is_interleaved = 1;
-
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_OPEN_READ;
-	rpc.device = ADSP_AUDIO_DEVICE_ID_DEFAULT;
-	rpc.mode =  ADSP_AUDIO_OPEN_STREAM_MODE_AUX_PCM;
-	rpc.stream_context = ADSP_AUDIO_DEVICE_CONTEXT_RECORD;
-
-	pr_debug("[%s:%s] ac = %p\n", __MM_FILE__, __func__, ac);
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-static int audio_auxpcm_in_open(struct audio_client *ac, uint32_t rate,
-		uint32_t channels)
-{
-	struct adsp_open_command rpc;
-
-	memset(&rpc, 0, sizeof(rpc));
-
-	rpc.format.standard.format = ADSP_AUDIO_FORMAT_PCM;
-	rpc.format.standard.channels = channels;
-	rpc.format.standard.bits_per_sample = 16;
-	rpc.format.standard.sampling_rate = rate;
-	rpc.format.standard.is_signed = 1;
-	rpc.format.standard.is_interleaved = 1;
-
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_OPEN_WRITE;
-	rpc.device = ADSP_AUDIO_DEVICE_ID_DEFAULT;
-	rpc.mode =  ADSP_AUDIO_OPEN_STREAM_MODE_AUX_PCM;
-	rpc.stream_context = ADSP_AUDIO_DEVICE_CONTEXT_PLAYBACK;
-
-	pr_debug("[%s:%s] ac = %p\n", __MM_FILE__, __func__, ac);
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-static int audio_mp3_open(struct audio_client *ac, uint32_t bufsz,
-			  uint32_t rate, uint32_t channels)
-{
-	struct adsp_open_command rpc;
-
-	memset(&rpc, 0, sizeof(rpc));
-
-	rpc.format.standard.format = ADSP_AUDIO_FORMAT_MP3;
-	rpc.format.standard.channels = channels;
-	rpc.format.standard.bits_per_sample = 16;
-	rpc.format.standard.sampling_rate = rate;
-	rpc.format.standard.is_signed = 1;
-	rpc.format.standard.is_interleaved = 0;
-
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_OPEN_WRITE;
-	rpc.device = ADSP_AUDIO_DEVICE_ID_DEFAULT;
-	rpc.stream_context = ADSP_AUDIO_DEVICE_CONTEXT_PLAYBACK;
-	rpc.buf_max_size = bufsz;
-
-	pr_debug("[%s:%s] ac = %p\n", __MM_FILE__, __func__, ac);
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-static int audio_dtmf_open(struct audio_client *ac,
-			  uint32_t rate, uint32_t channels)
-{
-	struct adsp_open_command rpc;
-
-	memset(&rpc, 0, sizeof(rpc));
-
-	rpc.format.standard.format = ADSP_AUDIO_FORMAT_DTMF;
-	rpc.format.standard.channels = channels;
-	rpc.format.standard.bits_per_sample = 16;
-	rpc.format.standard.sampling_rate = rate;
-	rpc.format.standard.is_signed = 1;
-	rpc.format.standard.is_interleaved = 0;
-
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_OPEN_WRITE;
-	rpc.device = ADSP_AUDIO_DEVICE_ID_DEFAULT;
-	rpc.stream_context = ADSP_AUDIO_DEVICE_CONTEXT_PLAYBACK;
-
-	pr_debug("[%s:%s] ac = %p\n", __MM_FILE__, __func__, ac);
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-static int audio_aac_open(struct audio_client *ac, uint32_t bufsz,
-			  uint32_t sample_rate, uint32_t channels,
-			  uint32_t bit_rate, uint32_t flags,
-					uint32_t stream_format)
-{
-	struct adsp_open_command rpc;
-	int audio_object_type;
-	int index = sizeof(u32);
-	u32 *aac_type = NULL;
-
-	memset(&rpc, 0, sizeof(rpc));
-
-	rpc.format.binary.format = ADSP_AUDIO_FORMAT_MPEG4_AAC;
-	/* only 48k sample rate is supported */
-	sample_rate = 3;
-	/* AAC OBJECT LC */
-	audio_object_type = 2;
-
-	aac_type = (u32 *)rpc.format.binary.data;
-	switch (stream_format) {
-	case AUDIO_AAC_FORMAT_ADTS:
-		/* AAC Encoder expect MPEG4_ADTS media type */
-		*aac_type = ADSP_AUDIO_AAC_MPEG4_ADTS;
-	break;
-	case AUDIO_AAC_FORMAT_RAW:
-		/* for ADIF recording */
-		*aac_type = ADSP_AUDIO_AAC_RAW;
-	break;
-	}
-
-	rpc.format.binary.data[index++] = (u8)(
-			((audio_object_type & 0x1F) << 3) |
-			((sample_rate >> 1) & 0x7));
-			rpc.format.binary.data[index] = (u8)(
-			((sample_rate & 0x1) << 7) |
-			((channels & 0x7) << 3));
-	rpc.format.binary.num_bytes = index + 1;
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_OPEN_READ;
-	rpc.device = ADSP_AUDIO_DEVICE_ID_DEFAULT;
-
-	if (flags == AUDIO_FLAG_READ)
-		rpc.stream_context = ADSP_AUDIO_DEVICE_CONTEXT_RECORD;
-	else
-		rpc.stream_context = ADSP_AUDIO_DEVICE_CONTEXT_MIXED_RECORD;
-
-	rpc.buf_max_size = bufsz;
-	rpc.config.aac.bit_rate = bit_rate;
-	rpc.config.aac.encoder_mode = ADSP_AUDIO_ENC_AAC_LC_ONLY_MODE;
-	pr_debug("[%s:%s] ac = %p\n", __MM_FILE__, __func__, ac);
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-static int audio_qcp_open(struct audio_client *ac, uint32_t bufsz,
-				uint32_t min_rate, uint32_t max_rate,
-				uint32_t flags, uint32_t format)
-{
-	struct adsp_open_command rpc;
-
-	memset(&rpc, 0, sizeof(rpc));
-
-	rpc.format.standard.format = format;
-	rpc.format.standard.channels = 1;
-	rpc.format.standard.bits_per_sample = 16;
-	rpc.format.standard.sampling_rate = 8000;
-	rpc.format.standard.is_signed = 1;
-	rpc.format.standard.is_interleaved = 0;
-
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_OPEN_READ;
-	rpc.device = ADSP_AUDIO_DEVICE_ID_DEFAULT;
-
-	if (flags == AUDIO_FLAG_READ)
-		rpc.stream_context = ADSP_AUDIO_DEVICE_CONTEXT_RECORD;
-	else
-		rpc.stream_context = ADSP_AUDIO_DEVICE_CONTEXT_MIXED_RECORD;
-	rpc.buf_max_size = bufsz;
-	rpc.config.evrc.min_rate = min_rate;
-	rpc.config.evrc.max_rate = max_rate;
-
-	pr_debug("[%s:%s] ac = %p\n", __MM_FILE__, __func__, ac);
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-static int audio_amrnb_open(struct audio_client *ac, uint32_t bufsz,
-					uint32_t enc_mode, uint32_t flags,
-					uint32_t dtx_enable)
-{
-	struct adsp_open_command rpc;
-
-	memset(&rpc, 0, sizeof(rpc));
-
-	rpc.format.standard.format = ADSP_AUDIO_FORMAT_AMRNB_FS;
-	rpc.format.standard.channels = 1;
-	rpc.format.standard.bits_per_sample = 16;
-	rpc.format.standard.sampling_rate = 8000;
-	rpc.format.standard.is_signed = 1;
-	rpc.format.standard.is_interleaved = 0;
-
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_OPEN_READ;
-	rpc.device = ADSP_AUDIO_DEVICE_ID_DEFAULT;
-
-	if (flags == AUDIO_FLAG_READ)
-		rpc.stream_context = ADSP_AUDIO_DEVICE_CONTEXT_RECORD;
-	else
-		rpc.stream_context = ADSP_AUDIO_DEVICE_CONTEXT_MIXED_RECORD;
-
-	rpc.buf_max_size = bufsz;
-	rpc.config.amr.mode = enc_mode;
-	rpc.config.amr.dtx_mode = dtx_enable;
-	rpc.config.amr.enable = 1;
-
-	pr_debug("[%s:%s] ac = %p\n", __MM_FILE__, __func__, ac);
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-
-
-static int audio_close(struct audio_client *ac)
-{
-	pr_debug("[%s:%s] ac = %p\n", __MM_FILE__, __func__, ac);
-	audio_command(ac, ADSP_AUDIO_IOCTL_CMD_STREAM_STOP);
-	audio_command(ac, ADSP_AUDIO_IOCTL_CMD_CLOSE);
-	return 0;
-}
-
-static int audio_set_table(struct audio_client *ac,
-			   uint32_t device_id, int size)
-{
-	struct adsp_set_dev_cfg_table_command rpc;
-
-	memset(&rpc, 0, sizeof(rpc));
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_SET_DEVICE_CONFIG_TABLE;
-	if (q6_device_to_dir(device_id) == Q6_TX) {
-		if (tx_clk_freq > 16000)
-			rpc.hdr.data = 48000;
-		else if (tx_clk_freq > 8000)
-			rpc.hdr.data = 16000;
-		else
-			rpc.hdr.data = 8000;
-	}
-	rpc.device_id = device_id;
-	rpc.phys_addr = audio_phys;
-	rpc.phys_size = size;
-	rpc.phys_used = size;
-
-	pr_debug("[%s:%s] ac = %p, device_id = 0x%x, size = %d\n", __MM_FILE__,
-		__func__, ac, device_id, size);
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-int q6audio_read(struct audio_client *ac, struct audio_buffer *ab)
-{
-	struct adsp_buffer_command rpc;
-	uint32_t res;
-	int r;
-
-	memset(&rpc, 0, sizeof(rpc));
-	rpc.hdr.size = sizeof(rpc) - sizeof(u32);
-	rpc.hdr.dst = AUDIO_ADDR(ac->session, 0, AUDIO_DOMAIN_DSP);
-	rpc.hdr.src = AUDIO_ADDR(ac->session, 0, AUDIO_DOMAIN_APP);
-	rpc.hdr.context = ac->session;
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_DATA_TX;
-	rpc.buffer.addr = ab->phys;
-	rpc.buffer.max_size = ab->size;
-	rpc.buffer.actual_size = ab->actual_size;
-
-	pr_debug("[%s:%s] ac = %p\n", __MM_FILE__, __func__, ac);
-	r = dal_call(ac->client, AUDIO_OP_DATA, 5, &rpc, sizeof(rpc),
-		     &res, sizeof(res));
-	return 0;
-}
-
-int q6audio_write(struct audio_client *ac, struct audio_buffer *ab)
-{
-	struct adsp_buffer_command rpc;
-	uint32_t res;
-	int r;
-
-	memset(&rpc, 0, sizeof(rpc));
-	rpc.hdr.size = sizeof(rpc) - sizeof(u32);
-	rpc.hdr.dst = AUDIO_ADDR(ac->session, 0, AUDIO_DOMAIN_DSP);
-	rpc.hdr.src = AUDIO_ADDR(ac->session, 0, AUDIO_DOMAIN_APP);
-	rpc.hdr.context = ac->session;
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_DATA_RX;
-	rpc.buffer.addr = ab->phys;
-	rpc.buffer.max_size = ab->size;
-	rpc.buffer.actual_size = ab->actual_size;
-
-	pr_debug("[%s:%s] ac = %p\n", __MM_FILE__, __func__, ac);
-	r = dal_call(ac->client, AUDIO_OP_DATA, 5, &rpc, sizeof(rpc),
-		     &res, sizeof(res));
-	return 0;
-}
-
-static int audio_rx_volume(struct audio_client *ac, uint32_t dev_id, int32_t volume)
-{
-	struct adsp_set_dev_volume_command rpc;
-
-	pr_debug("[%s:%s] volume = %d\n", __MM_FILE__, __func__, volume);
-	memset(&rpc, 0, sizeof(rpc));
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_SET_DEVICE_VOL;
-	rpc.device_id = dev_id;
-	rpc.path = ADSP_PATH_RX;
-	rpc.volume = volume;
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-static int audio_rx_mute(struct audio_client *ac, uint32_t dev_id, int mute)
-{
-	struct adsp_set_dev_mute_command rpc;
-
-	pr_debug("[%s:%s] mute = %d, dev_id = 0x%x\n", __MM_FILE__,
-			__func__, mute, dev_id);
-	memset(&rpc, 0, sizeof(rpc));
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_SET_DEVICE_MUTE;
-	rpc.device_id = dev_id;
-	rpc.path = ADSP_PATH_RX;
-	rpc.mute = !!mute;
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-static int audio_tx_mute(struct audio_client *ac, uint32_t dev_id, int mute)
-{
-	struct adsp_set_dev_mute_command rpc;
-
-	pr_debug("[%s:%s] mute = %d\n", __MM_FILE__, __func__, mute);
-	if (mute < 0  ||  mute > 3) {
-		pr_err("[%s:%s] invalid mute status %d\n", __MM_FILE__,
-				__func__, mute);
-		return -EINVAL;
-	}
-
-	memset(&rpc, 0, sizeof(rpc));
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_SET_DEVICE_MUTE;
-	if ((mute == STREAM_UNMUTE) || (mute == STREAM_MUTE)) {
-		rpc.device_id = ADSP_AUDIO_DEVICE_ID_VOICE;
-		rpc.path = ADSP_PATH_TX_CNG_DIS;
-	} else {
-		rpc.device_id = dev_id;
-		rpc.path = ADSP_PATH_TX;
-	}
-	mute &= 0x01;
-	rpc.mute = !!mute;
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-static int audio_stream_volume(struct audio_client *ac, int volume)
-{
-	struct adsp_set_volume_command rpc;
-	int rc;
-
-	pr_debug("[%s:%s] volume = %d\n", __MM_FILE__, __func__, volume);
-	memset(&rpc, 0, sizeof(rpc));
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_SET_STREAM_VOL;
-	rpc.volume = volume;
-	rc = audio_ioctl(ac, &rpc, sizeof(rpc));
-	return rc;
-}
-
-static int audio_stream_mute(struct audio_client *ac, int mute)
-{
-	struct adsp_set_mute_command rpc;
-	int rc;
-
-	pr_debug("[%s:%s] mute = %d\n", __MM_FILE__, __func__, mute);
-	memset(&rpc, 0, sizeof(rpc));
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_SET_STREAM_MUTE;
-	rpc.mute = mute;
-	rc = audio_ioctl(ac, &rpc, sizeof(rpc));
-	return rc;
-}
-
-static void callback(void *data, int len, void *cookie)
-{
-	struct adsp_event_hdr *e = data;
-	struct audio_client *ac;
-	struct adsp_buffer_event *abe = data;
-
-	if (e->context >= SESSION_MAX) {
-		pr_err("[%s:%s] bogus session %d\n", __MM_FILE__, __func__,
-				e->context);
-		return;
-	}
-	ac = session[e->context];
-	if (!ac) {
-		pr_err("[%s:%s] unknown session %d\n", __MM_FILE__, __func__,
-				e->context);
-		return;
-	}
-
-	if (e->event_id == ADSP_AUDIO_IOCTL_CMD_STREAM_EOS) {
-		pr_debug("[%s:%s] CB Stream eos, ac = %p\n",
-			__MM_FILE__, __func__, ac);
-		if (e->status)
-			pr_err("[%s:%s] playback status %d\n", __MM_FILE__,
-					__func__, e->status);
-		if (ac->cb_status == -EBUSY) {
-			ac->cb_status = e->status;
-			wake_up(&ac->wait);
-		}
-		return;
-	}
-
-	if (e->event_id == ADSP_AUDIO_EVT_STATUS_BUF_DONE) {
-		pr_debug("[%s:%s] CB done, ac = %p, status = %d\n",
-				__MM_FILE__, __func__, ac, e->status);
-		if (e->status)
-			pr_err("[%s:%s] buffer status %d\n", __MM_FILE__,
-					__func__, e->status);
-
-		ac->buf[ac->dsp_buf].actual_size = abe->buffer.actual_size;
-		ac->buf[ac->dsp_buf].used = 0;
-		ac->dsp_buf ^= 1;
-		wake_up(&ac->wait);
-		return;
-	}
-
-	pr_debug("[%s:%s] ac = %p, event_id = 0x%x, status = %d\n",
-			__MM_FILE__, __func__, ac, e->event_id, e->status);
-	if (e->status)
-		pr_warning("audio_cb: s=%d e=%08x status=%d\n",
-			   e->context, e->event_id, e->status);
-	if (ac->cb_status == -EBUSY) {
-		ac->cb_status = e->status;
-		wake_up(&ac->wait);
-	}
-}
-
-static void audio_init(struct dal_client *client)
-{
-	u32 tmp[3];
-
-	pr_debug("[%s:%s]\n", __MM_FILE__, __func__);
-	tmp[0] = 2 * sizeof(u32);
-	tmp[1] = 0;
-	tmp[2] = 0;
-	dal_call(client, AUDIO_OP_INIT, 5, tmp, sizeof(tmp),
-		 tmp, sizeof(u32));
-}
-
-static struct audio_client *ac_control;
-
-static int q6audio_init(void)
-{
-	struct audio_client *ac = 0;
-	int res;
-
-	pr_debug("[%s:%s]\n", __MM_FILE__, __func__);
-	mutex_lock(&audio_lock);
-	if (ac_control) {
-		res = 0;
-		goto done;
-	}
-
-	pr_info("[%s:%s] codecs\n", __MM_FILE__, __func__);
-	icodec_rx_clk = clk_get(0, "icodec_rx_clk");
-	icodec_tx_clk = clk_get(0, "icodec_tx_clk");
-	ecodec_clk = clk_get(0, "ecodec_clk");
-	sdac_clk = clk_get(0, "sdac_clk");
-	audio_phys = pmem_kalloc(4096, PMEM_MEMTYPE_EBI1|PMEM_ALIGNMENT_4K);
-	audio_data = ioremap(audio_phys, 4096);
-
-	pr_info("[%s:%s] attach ADSP\n", __MM_FILE__, __func__);
-	adsp = dal_attach(AUDIO_DAL_DEVICE, AUDIO_DAL_PORT, 1,
-			  callback, 0);
-	if (!adsp) {
-		pr_err("[%s:%s] cannot attach to adsp\n", __MM_FILE__,
-				__func__);
-		res = -ENODEV;
-		goto done;
-	}
-	pr_info("[%s:%s] INIT\n", __MM_FILE__, __func__);
-	audio_init(adsp);
-	dal_trace(adsp);
-
-	ac = audio_client_alloc(0);
-	if (!ac) {
-		pr_err("[%s:%s] cannot allocate client\n",
-				__MM_FILE__, __func__);
-		res = -ENOMEM;
-		goto done;
-	}
-
-	pr_info("[%s:%s] OPEN control\n", __MM_FILE__, __func__);
-	if (audio_open_control(ac)) {
-		pr_err("[%s:%s] cannot open control channel\n",
-				__MM_FILE__, __func__);
-		res = -ENODEV;
-		goto done;
-	}
-
-	pr_info("[%s:%s] attach ACDB\n", __MM_FILE__, __func__);
-	acdb = dal_attach(ACDB_DAL_DEVICE, ACDB_DAL_PORT, 0, 0, 0);
-	if (!acdb) {
-		pr_err("[%s:%s] cannot attach to acdb channel\n",
-				__MM_FILE__, __func__);
-		res = -ENODEV;
-		goto done;
-	}
-
-	pr_info("[%s:%s] attach ADIE\n", __MM_FILE__, __func__);
-	adie = dal_attach(ADIE_DAL_DEVICE, ADIE_DAL_PORT, 0, 0, 0);
-	if (!adie) {
-		pr_err("[%s:%s] cannot attach to adie\n",
-				__MM_FILE__, __func__);
-		res = -ENODEV;
-		goto done;
-	}
-	if (analog_ops->init)
-		analog_ops->init();
-
-	res = 0;
-	ac_control = ac;
-
-	pm_qos_add_request(&pm_qos_req, PM_QOS_CPU_DMA_LATENCY,
-				PM_QOS_DEFAULT_VALUE);
-	wake_lock_init(&wakelock, WAKE_LOCK_SUSPEND, "audio_pcm_suspend");
-done:
-	if ((res < 0) && ac)
-		audio_client_free(ac);
-	mutex_unlock(&audio_lock);
-
-	pr_debug("[%s:%s] res = %d\n", __MM_FILE__, __func__, res);
-	return res;
-}
-
-struct audio_config_data {
-	uint32_t device_id;
-	uint32_t sample_rate;
-	uint32_t offset;
-	uint32_t length;
-};
-
-struct audio_config_database {
-	uint8_t magic[8];
-	uint32_t entry_count;
-	uint32_t unused;
-	struct audio_config_data entry[0];
-};
-
-void *acdb_data;
-const struct firmware *acdb_fw;
-extern struct miscdevice q6_control_device;
-
-static int acdb_get_config_table(uint32_t device_id, uint32_t sample_rate)
-{
-	struct acdb_cmd_device_table rpc;
-	struct acdb_result res;
-	int r;
-
-	pr_debug("[%s:%s] device_id = 0x%x, samplerate = %d\n", __MM_FILE__,
-		__func__, device_id, sample_rate);
-	if (q6audio_init())
-		return 0;
-
-	memset(audio_data, 0, 4096);
-	memset(&rpc, 0, sizeof(rpc));
-
-	rpc.size = sizeof(rpc) - (2 * sizeof(uint32_t));
-	rpc.command_id = ACDB_GET_DEVICE_TABLE;
-	rpc.device_id = device_id;
-	rpc.sample_rate_id = sample_rate;
-	rpc.total_bytes = 4096;
-	rpc.unmapped_buf = audio_phys;
-	rpc.res_size = sizeof(res) - (2 * sizeof(uint32_t));
-
-	r = dal_call(acdb, ACDB_OP_IOCTL, 8, &rpc, sizeof(rpc),
-		&res, sizeof(res));
-
-	if ((r == sizeof(res)) && (res.dal_status == 0))
-		return res.used_bytes;
-
-	return -EIO;
-}
-
-static uint32_t audio_rx_path_id = ADIE_PATH_HANDSET_RX;
-static uint32_t audio_rx_device_id = ADSP_AUDIO_DEVICE_ID_HANDSET_SPKR;
-static uint32_t audio_rx_device_group = -1;
-static uint32_t audio_tx_path_id = ADIE_PATH_HANDSET_TX;
-static uint32_t audio_tx_device_id = ADSP_AUDIO_DEVICE_ID_HANDSET_MIC;
-static uint32_t audio_tx_device_group = -1;
-
-static int qdsp6_devchg_notify(struct audio_client *ac,
-			       uint32_t dev_type, uint32_t dev_id)
-{
-	struct adsp_device_switch_command rpc;
-
-	if (dev_type != ADSP_AUDIO_RX_DEVICE &&
-	    dev_type != ADSP_AUDIO_TX_DEVICE)
-		return -EINVAL;
-
-	memset(&rpc, 0, sizeof(rpc));
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_DEVICE_SWITCH_PREPARE;
-	if (dev_type == ADSP_AUDIO_RX_DEVICE) {
-		rpc.old_device = audio_rx_device_id;
-		rpc.new_device = dev_id;
-	} else {
-		rpc.old_device = audio_tx_device_id;
-		rpc.new_device = dev_id;
-	}
-	rpc.device_class = 0;
-	rpc.device_type = dev_type;
-	pr_debug("[%s:%s] dev_id = 0x%x\n", __MM_FILE__, __func__, dev_id);
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-static int qdsp6_standby(struct audio_client *ac)
-{
-	pr_debug("[%s:%s]\n", __MM_FILE__, __func__);
-	return audio_command(ac, ADSP_AUDIO_IOCTL_CMD_DEVICE_SWITCH_STANDBY);
-}
-
-static int qdsp6_start(struct audio_client *ac)
-{
-	pr_debug("[%s:%s]\n", __MM_FILE__, __func__);
-	return audio_command(ac, ADSP_AUDIO_IOCTL_CMD_DEVICE_SWITCH_COMMIT);
-}
-
-static void audio_rx_analog_enable(int en)
-{
-	pr_debug("[%s:%s] audio_rx_device_id = 0x%x, en = %d\n", __MM_FILE__,
-		__func__, audio_rx_device_id, en);
-	switch (audio_rx_device_id) {
-	case ADSP_AUDIO_DEVICE_ID_HEADSET_SPKR_MONO:
-	case ADSP_AUDIO_DEVICE_ID_HEADSET_SPKR_STEREO:
-	case ADSP_AUDIO_DEVICE_ID_TTY_HEADSET_SPKR:
-		if (analog_ops->headset_enable)
-			analog_ops->headset_enable(en);
-		break;
-	case ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MONO_W_MONO_HEADSET:
-	case ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MONO_W_STEREO_HEADSET:
-	case ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_STEREO_W_MONO_HEADSET:
-	case ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_STEREO_W_STEREO_HEADSET:
-		if (analog_ops->headset_enable)
-			analog_ops->headset_enable(en);
-		if (analog_ops->speaker_enable)
-			analog_ops->speaker_enable(en);
-		break;
-	case ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MONO:
-	case ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_STEREO:
-		if (analog_ops->speaker_enable)
-			analog_ops->speaker_enable(en);
-		break;
-	case ADSP_AUDIO_DEVICE_ID_BT_SCO_SPKR:
-		if (analog_ops->bt_sco_enable)
-			analog_ops->bt_sco_enable(en);
-		break;
-	case ADSP_AUDIO_DEVICE_ID_HANDSET_SPKR:
-		if (analog_ops->receiver_enable)
-			analog_ops->receiver_enable(en);
-		break;
-	}
-}
-
-static void audio_tx_analog_enable(int en)
-{
-	pr_debug("[%s:%s] audio_tx_device_id = 0x%x, en = %d\n", __MM_FILE__,
-		__func__, audio_tx_device_id, en);
-	switch (audio_tx_device_id) {
-	case ADSP_AUDIO_DEVICE_ID_HANDSET_MIC:
-	case ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MIC:
-		if (analog_ops->int_mic_enable)
-			analog_ops->int_mic_enable(en);
-		break;
-	case ADSP_AUDIO_DEVICE_ID_HEADSET_MIC:
-	case ADSP_AUDIO_DEVICE_ID_TTY_HEADSET_MIC:
-	case ADSP_AUDIO_DEVICE_ID_HANDSET_DUAL_MIC:
-	case ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_DUAL_MIC:
-		if (analog_ops->ext_mic_enable)
-			analog_ops->ext_mic_enable(en);
-		break;
-	case ADSP_AUDIO_DEVICE_ID_BT_SCO_MIC:
-		if (analog_ops->bt_sco_enable)
-			analog_ops->bt_sco_enable(en);
-		break;
-	}
-}
-
-static int audio_update_acdb(uint32_t adev, uint32_t acdb_id)
-{
-	uint32_t sample_rate;
-	int sz;
-
-	pr_debug("[%s:%s] adev = 0x%x, acdb_id = 0x%x\n", __MM_FILE__,
-		__func__, adev, acdb_id);
-	if (q6_device_to_dir(adev) == Q6_RX) {
-		rx_acdb = acdb_id;
-		sample_rate = q6_device_to_rate(adev);
-	} else {
-
-		tx_acdb = acdb_id;
-		if (tx_clk_freq > 16000)
-			sample_rate = 48000;
-		else if (tx_clk_freq > 8000)
-			sample_rate = 16000;
-		else
-			sample_rate = 8000;
-	}
-
-	if (acdb_id == 0)
-		acdb_id = q6_device_to_cad_id(adev);
-
-	sz = acdb_get_config_table(acdb_id, sample_rate);
-	audio_set_table(ac_control, adev, sz);
-
-	return 0;
-}
-
-static void adie_rx_path_enable(uint32_t acdb_id)
-{
-	pr_debug("[%s:%s]\n", __MM_FILE__, __func__);
-	if (audio_rx_path_id) {
-		adie_enable();
-		adie_set_path(adie, audio_rx_path_id, ADIE_PATH_RX);
-		adie_set_path_freq_plan(adie, ADIE_PATH_RX, 48000);
-
-		adie_proceed_to_stage(adie, ADIE_PATH_RX,
-				ADIE_STAGE_DIGITAL_READY);
-		adie_proceed_to_stage(adie, ADIE_PATH_RX,
-				ADIE_STAGE_DIGITAL_ANALOG_READY);
-	}
-}
-
-static void q6_rx_path_enable(int reconf, uint32_t acdb_id)
-{
-	pr_debug("[%s:%s]\n", __MM_FILE__, __func__);
-	if (!reconf)
-		qdsp6_devchg_notify(ac_control, ADSP_AUDIO_RX_DEVICE, audio_rx_device_id);
-	audio_update_acdb(audio_rx_device_id, acdb_id);
-	qdsp6_standby(ac_control);
-	qdsp6_start(ac_control);
-}
-
-static void _audio_rx_path_enable(int reconf, uint32_t acdb_id)
-{
-	pr_debug("[%s:%s] reconf = %d\n", __MM_FILE__, __func__, reconf);
-	q6_rx_path_enable(reconf, acdb_id);
-	if (audio_rx_path_id)
-		adie_rx_path_enable(acdb_id);
-	audio_rx_analog_enable(1);
-}
-
-static void _audio_tx_path_enable(int reconf, uint32_t acdb_id)
-{
-	pr_debug("[%s:%s] reconf = %d, tx_clk_freq = %d\n", __MM_FILE__,
-			__func__, reconf, tx_clk_freq);
-	audio_tx_analog_enable(1);
-
-	if (audio_tx_path_id) {
-		adie_enable();
-		adie_set_path(adie, audio_tx_path_id, ADIE_PATH_TX);
-
-		if (tx_clk_freq > 16000)
-			adie_set_path_freq_plan(adie, ADIE_PATH_TX, 48000);
-		else if (tx_clk_freq > 8000)
-			adie_set_path_freq_plan(adie, ADIE_PATH_TX, 16000);
-		else
-			adie_set_path_freq_plan(adie, ADIE_PATH_TX, 8000);
-
-		adie_proceed_to_stage(adie, ADIE_PATH_TX,
-				ADIE_STAGE_DIGITAL_READY);
-		adie_proceed_to_stage(adie, ADIE_PATH_TX,
-				ADIE_STAGE_DIGITAL_ANALOG_READY);
-	}
-
-
-	if (!reconf)
-		qdsp6_devchg_notify(ac_control, ADSP_AUDIO_TX_DEVICE,
-				audio_tx_device_id);
-	audio_update_acdb(audio_tx_device_id, acdb_id);
-	qdsp6_standby(ac_control);
-	qdsp6_start(ac_control);
-
-	audio_tx_mute(ac_control, audio_tx_device_id, tx_mute_status);
-}
-
-static void _audio_rx_path_disable(void)
-{
-	pr_debug("[%s:%s]\n", __MM_FILE__, __func__);
-	audio_rx_analog_enable(0);
-
-	if (audio_rx_path_id) {
-		adie_proceed_to_stage(adie, ADIE_PATH_RX,
-				ADIE_STAGE_ANALOG_OFF);
-		adie_proceed_to_stage(adie, ADIE_PATH_RX,
-				ADIE_STAGE_DIGITAL_OFF);
-		adie_disable();
-	}
-}
-
-static void _audio_tx_path_disable(void)
-{
-	pr_debug("[%s:%s]\n", __MM_FILE__, __func__);
-	audio_tx_analog_enable(0);
-
-	if (audio_tx_path_id) {
-		adie_proceed_to_stage(adie, ADIE_PATH_TX,
-				ADIE_STAGE_ANALOG_OFF);
-		adie_proceed_to_stage(adie, ADIE_PATH_TX,
-				ADIE_STAGE_DIGITAL_OFF);
-		adie_disable();
-	}
-}
-
-static int icodec_rx_clk_refcount;
-static int icodec_tx_clk_refcount;
-static int ecodec_clk_refcount;
-static int sdac_clk_refcount;
-
-static void ecodec_clk_enable(void)
-{
-	ecodec_clk_refcount++;
-	if (ecodec_clk_refcount == 1) {
-		clk_set_rate(ecodec_clk, 2048000);
-		clk_enable(ecodec_clk);
-	}
-}
-static void ecodec_clk_disable(int group_reset, int path)
-{
-	ecodec_clk_refcount--;
-	if (ecodec_clk_refcount == 0) {
-		clk_disable(ecodec_clk);
-		if (group_reset) {
-			if (path == ADSP_PATH_TX)
-				audio_tx_device_group = -1;
-			else
-				audio_rx_device_group = -1;
-		}
-	}
-}
-static void _audio_rx_clk_enable(void)
-{
-	uint32_t device_group = q6_device_to_codec(audio_rx_device_id);
-
-	pr_debug("[%s:%s] rx_clk_refcount = %d\n", __MM_FILE__, __func__,
-		icodec_rx_clk_refcount);
-	switch(device_group) {
-	case Q6_ICODEC_RX:
-		icodec_rx_clk_refcount++;
-		if (icodec_rx_clk_refcount == 1) {
-			clk_set_rate(icodec_rx_clk, 12288000);
-			clk_enable(icodec_rx_clk);
-		}
-		break;
-	case Q6_ECODEC_RX:
-		ecodec_clk_enable();
-		break;
-	case Q6_SDAC_RX:
-		sdac_clk_refcount++;
-		if (sdac_clk_refcount == 1) {
-			clk_set_rate(sdac_clk, 12288000);
-			clk_enable(sdac_clk);
-		}
-		break;
-	default:
-		return;
-	}
-	audio_rx_device_group = device_group;
-}
-
-static void _audio_tx_clk_enable(void)
-{
-	uint32_t device_group = q6_device_to_codec(audio_tx_device_id);
-	uint32_t icodec_tx_clk_rate;
-
-	pr_debug("[%s:%s] tx_clk_refcount = %d\n", __MM_FILE__, __func__,
-		icodec_tx_clk_refcount);
-	switch (device_group) {
-	case Q6_ICODEC_TX:
-		icodec_tx_clk_refcount++;
-		if (icodec_tx_clk_refcount == 1) {
-			if (tx_clk_freq > 16000)
-				icodec_tx_clk_rate = 48000;
-			else if (tx_clk_freq > 8000)
-				icodec_tx_clk_rate = 16000;
-			else
-				icodec_tx_clk_rate = 8000;
-
-			clk_set_rate(icodec_tx_clk, icodec_tx_clk_rate * 256);
-			clk_enable(icodec_tx_clk);
-		}
-		break;
-	case Q6_ECODEC_TX:
-		ecodec_clk_enable();
-		break;
-	case Q6_SDAC_TX:
-		/* TODO: In QCT BSP, clk rate was set to 20480000 */
-		sdac_clk_refcount++;
-		if (sdac_clk_refcount == 1) {
-			clk_set_rate(sdac_clk, 12288000);
-			clk_enable(sdac_clk);
-		}
-		break;
-	default:
-		return;
-	}
-	audio_tx_device_group = device_group;
-}
-
-static void _audio_rx_clk_disable(void)
-{
-	pr_debug("[%s:%s] rx_clk_refcount = %d\n", __MM_FILE__, __func__,
-		icodec_rx_clk_refcount);
-	switch (audio_rx_device_group) {
-	case Q6_ICODEC_RX:
-		icodec_rx_clk_refcount--;
-		if (icodec_rx_clk_refcount == 0) {
-			clk_disable(icodec_rx_clk);
-			audio_rx_device_group = -1;
-		}
-		break;
-	case Q6_ECODEC_RX:
-		ecodec_clk_disable(1, ADSP_PATH_RX);
-		break;
-	case Q6_SDAC_RX:
-		sdac_clk_refcount--;
-		if (sdac_clk_refcount == 0) {
-			clk_disable(sdac_clk);
-			audio_rx_device_group = -1;
-		}
-		break;
-	default:
-		pr_err("[%s:%s] invalid rx device group %d\n", __MM_FILE__,
-				__func__, audio_rx_device_group);
-		break;
-	}
-}
-
-static void _audio_tx_clk_disable(void)
-{
-	pr_debug("[%s:%s] tx_clk_refcount = %d\n", __MM_FILE__, __func__,
-		icodec_tx_clk_refcount);
-	switch (audio_tx_device_group) {
-	case Q6_ICODEC_TX:
-		icodec_tx_clk_refcount--;
-		if (icodec_tx_clk_refcount == 0) {
-			clk_disable(icodec_tx_clk);
-			audio_tx_device_group = -1;
-		}
-		break;
-	case Q6_ECODEC_TX:
-		ecodec_clk_disable(1, ADSP_PATH_TX);
-		break;
-	case Q6_SDAC_TX:
-		sdac_clk_refcount--;
-		if (sdac_clk_refcount == 0) {
-			clk_disable(sdac_clk);
-			audio_tx_device_group = -1;
-		}
-		break;
-	default:
-		pr_err("[%s:%s] invalid tx device group %d\n",
-			__MM_FILE__, __func__, audio_tx_device_group);
-		break;
-	}
-}
-
-static void _audio_rx_clk_reinit(uint32_t rx_device, uint32_t acdb_id)
-{
-	uint32_t device_group = q6_device_to_codec(rx_device);
-
-	pr_debug("[%s:%s] rx_device = 0x%x\n", __MM_FILE__, __func__,
-		rx_device);
-	if (device_group != audio_rx_device_group)
-		_audio_rx_clk_disable();
-
-	audio_rx_device_id = rx_device;
-	audio_rx_path_id = q6_device_to_path(rx_device, acdb_id);
-
-	if (device_group != audio_rx_device_group)
-		_audio_rx_clk_enable();
-
-}
-
-static void _audio_tx_clk_reinit(uint32_t tx_device, uint32_t acdb_id)
-{
-	uint32_t device_group = q6_device_to_codec(tx_device);
-
-	pr_debug("[%s:%s] tx_device = 0x%x\n", __MM_FILE__, __func__,
-		tx_device);
-	if (device_group != audio_tx_device_group)
-		_audio_tx_clk_disable();
-
-	audio_tx_device_id = tx_device;
-	audio_tx_path_id = q6_device_to_path(tx_device, acdb_id);
-
-	if (device_group != audio_tx_device_group)
-		_audio_tx_clk_enable();
-}
-
-static DEFINE_MUTEX(audio_path_lock);
-static int audio_rx_path_refcount;
-static int audio_tx_path_refcount;
-
-static int audio_rx_path_enable(int en, uint32_t acdb_id)
-{
-	pr_debug("[%s:%s] en = %d\n", __MM_FILE__, __func__, en);
-	mutex_lock(&audio_path_lock);
-	if (en) {
-		audio_rx_path_refcount++;
-		if (audio_rx_path_refcount == 1) {
-			_audio_rx_clk_enable();
-			_audio_rx_path_enable(0, acdb_id);
-		}
-	} else {
-		audio_rx_path_refcount--;
-		if (audio_rx_path_refcount == 0) {
-			_audio_rx_path_disable();
-			_audio_rx_clk_disable();
-		}
-	}
-	mutex_unlock(&audio_path_lock);
-	return 0;
-}
-
-static int audio_tx_path_enable(int en, uint32_t acdb_id)
-{
-	pr_debug("[%s:%s] en = %d\n", __MM_FILE__, __func__, en);
-	mutex_lock(&audio_path_lock);
-	if (en) {
-		audio_tx_path_refcount++;
-		if (audio_tx_path_refcount == 1) {
-			_audio_tx_clk_enable();
-			_audio_tx_path_enable(0, acdb_id);
-		}
-	} else {
-		audio_tx_path_refcount--;
-		if (audio_tx_path_refcount == 0) {
-			_audio_tx_path_disable();
-			_audio_tx_clk_disable();
-		}
-	}
-	mutex_unlock(&audio_path_lock);
-	return 0;
-}
-
-int q6audio_update_acdb(uint32_t id_src, uint32_t id_dst)
-{
-	int res;
-
-	pr_debug("[%s:%s] id_src = 0x%x\n, id_dst = 0x%x\n", __MM_FILE__,
-		__func__, id_src, id_dst);
-	if (q6audio_init())
-		return 0;
-
-	mutex_lock(&audio_path_lock);
-
-	if (q6_device_to_dir(id_dst) == Q6_RX)
-		qdsp6_devchg_notify(ac_control, ADSP_AUDIO_RX_DEVICE, id_dst);
-	else
-		qdsp6_devchg_notify(ac_control, ADSP_AUDIO_TX_DEVICE, id_dst);
-	res = audio_update_acdb(id_dst, id_src);
-	if (res)
-		goto done;
-
-	qdsp6_standby(ac_control);
-	qdsp6_start(ac_control);
-done:
-	mutex_unlock(&audio_path_lock);
-	return res;
-}
-
-int q6audio_set_tx_mute(int mute)
-{
-	uint32_t adev;
-	int rc;
-
-	if (q6audio_init())
-		return 0;
-
-	mutex_lock(&audio_path_lock);
-
-	if (mute == tx_mute_status) {
-		mutex_unlock(&audio_path_lock);
-		return 0;
-	}
-
-	adev = audio_tx_device_id;
-	rc = audio_tx_mute(ac_control, adev, mute);
-
-	/* DSP caches the requested MUTE state when it cannot apply the state
-	  immediately. In that case, it returns EUNSUPPORTED and applies the
-	  cached state later */
-	if ((rc == ADSP_AUDIO_STATUS_SUCCESS) ||
-			(rc == ADSP_AUDIO_STATUS_EUNSUPPORTED)) {
-		pr_debug("[%s:%s] return status = %d\n",
-			__MM_FILE__, __func__, rc);
-		tx_mute_status = mute;
-	}
-	mutex_unlock(&audio_path_lock);
-	return 0;
-}
-
-int q6audio_set_stream_volume(struct audio_client *ac, int vol)
-{
-	if (vol > 1200 || vol < -4000) {
-		pr_err("[%s:%s] unsupported volume level %d\n", __MM_FILE__,
-				__func__, vol);
-		return -EINVAL;
-	}
-	mutex_lock(&audio_path_lock);
-	audio_stream_mute(ac, 0);
-	audio_stream_volume(ac, vol);
-	mutex_unlock(&audio_path_lock);
-	return 0;
-}
-
-int q6audio_set_rx_volume(int level)
-{
-	uint32_t adev;
-	int vol;
-
-	pr_debug("[%s:%s] level = %d\n", __MM_FILE__, __func__, level);
-	if (q6audio_init())
-		return 0;
-
-	if (level < 0 || level > 100)
-		return -EINVAL;
-
-	mutex_lock(&audio_path_lock);
-	adev = ADSP_AUDIO_DEVICE_ID_VOICE;
-
-	if (level) {
-		vol = q6_device_volume(audio_rx_device_id, level);
-		audio_rx_mute(ac_control, adev, 0);
-		audio_rx_volume(ac_control, adev, vol);
-	} else
-		audio_rx_mute(ac_control, adev, 1);
-
-	rx_vol_level = level;
-	mutex_unlock(&audio_path_lock);
-	return 0;
-}
-
-static void do_rx_routing(uint32_t device_id, uint32_t acdb_id)
-{
-	pr_debug("[%s:%s] device_id = 0x%x, acdb_id = 0x%x\n", __MM_FILE__,
-		__func__, device_id, acdb_id);
-	if (device_id == audio_rx_device_id &&
-		audio_rx_path_id == q6_device_to_path(device_id, acdb_id)) {
-		if (acdb_id != rx_acdb) {
-			qdsp6_devchg_notify(ac_control, ADSP_AUDIO_RX_DEVICE, device_id);
-			audio_update_acdb(device_id, acdb_id);
-			qdsp6_standby(ac_control);
-			qdsp6_start(ac_control);
-		}
-		return;
-	}
-
-	if (audio_rx_path_refcount > 0) {
-		qdsp6_devchg_notify(ac_control, ADSP_AUDIO_RX_DEVICE, device_id);
-		_audio_rx_path_disable();
-		_audio_rx_clk_reinit(device_id, acdb_id);
-		_audio_rx_path_enable(1, acdb_id);
-	} else {
-		qdsp6_devchg_notify(ac_control, ADSP_AUDIO_RX_DEVICE,
-					 device_id);
-		audio_update_acdb(device_id, acdb_id);
-		qdsp6_standby(ac_control);
-		qdsp6_start(ac_control);
-		audio_rx_device_id = device_id;
-		audio_rx_path_id = q6_device_to_path(device_id, acdb_id);
-	}
-}
-
-static void do_tx_routing(uint32_t device_id, uint32_t acdb_id)
-{
-	pr_debug("[%s:%s] device_id = 0x%x, acdb_id = 0x%x\n", __MM_FILE__,
-		__func__, device_id, acdb_id);
-	if (device_id == audio_tx_device_id &&
-		audio_tx_path_id == q6_device_to_path(device_id, acdb_id)) {
-		if (acdb_id != tx_acdb) {
-			qdsp6_devchg_notify(ac_control, ADSP_AUDIO_TX_DEVICE,
-						 device_id);
-			audio_update_acdb(device_id, acdb_id);
-			qdsp6_standby(ac_control);
-			qdsp6_start(ac_control);
-		}
-		return;
-	}
-
-	if (audio_tx_path_refcount > 0) {
-		qdsp6_devchg_notify(ac_control, ADSP_AUDIO_TX_DEVICE, device_id);
-		_audio_tx_path_disable();
-		_audio_tx_clk_reinit(device_id, acdb_id);
-		_audio_tx_path_enable(1, acdb_id);
-	} else {
-		qdsp6_devchg_notify(ac_control, ADSP_AUDIO_TX_DEVICE,
-					 device_id);
-		audio_update_acdb(device_id, acdb_id);
-		qdsp6_standby(ac_control);
-		qdsp6_start(ac_control);
-		audio_tx_device_id = device_id;
-		audio_tx_path_id = q6_device_to_path(device_id, acdb_id);
-		tx_acdb = acdb_id;
-	}
-}
-
-int q6audio_do_routing(uint32_t device_id, uint32_t acdb_id)
-{
-	if (q6audio_init())
-		return 0;
-
-	mutex_lock(&audio_path_lock);
-
-	switch(q6_device_to_dir(device_id)) {
-	case Q6_RX:
-		do_rx_routing(device_id, acdb_id);
-		break;
-	case Q6_TX:
-		do_tx_routing(device_id, acdb_id);
-		break;
-	}
-
-	mutex_unlock(&audio_path_lock);
-	return 0;
-}
-
-int q6audio_set_route(const char *name)
-{
-	uint32_t route;
-	if (!strcmp(name, "speaker")) {
-		route = ADIE_PATH_SPEAKER_STEREO_RX;
-	} else if (!strcmp(name, "headphones")) {
-		route = ADIE_PATH_HEADSET_STEREO_RX;
-	} else if (!strcmp(name, "handset")) {
-		route = ADIE_PATH_HANDSET_RX;
-	} else {
-		return -EINVAL;
-	}
-
-	mutex_lock(&audio_path_lock);
-	if (route == audio_rx_path_id)
-		goto done;
-
-	audio_rx_path_id = route;
-
-	if (audio_rx_path_refcount > 0) {
-		_audio_rx_path_disable();
-		_audio_rx_path_enable(1, 0);
-	}
-	if (audio_tx_path_refcount > 0) {
-		_audio_tx_path_disable();
-		_audio_tx_path_enable(1, 0);
-	}
-done:
-	mutex_unlock(&audio_path_lock);
-	return 0;
-}
-
-static int audio_stream_equalizer(struct audio_client *ac, void *eq_config)
-{
-	int i;
-	struct adsp_set_equalizer_command rpc;
-	struct adsp_audio_eq_stream_config *eq_cfg;
-	eq_cfg = (struct adsp_audio_eq_stream_config *) eq_config;
-
-	memset(&rpc, 0, sizeof(rpc));
-
-	rpc.hdr.opcode = ADSP_AUDIO_IOCTL_SET_SESSION_EQ_CONFIG;
-	rpc.enable = eq_cfg->enable;
-	rpc.num_bands = eq_cfg->num_bands;
-	for (i = 0; i < eq_cfg->num_bands; i++) {
-		rpc.eq_bands[i].band_idx = eq_cfg->eq_bands[i].band_idx;
-		rpc.eq_bands[i].filter_type = eq_cfg->eq_bands[i].filter_type;
-		rpc.eq_bands[i].center_freq_hz =
-					eq_cfg->eq_bands[i].center_freq_hz;
-		rpc.eq_bands[i].filter_gain = eq_cfg->eq_bands[i].filter_gain;
-		rpc.eq_bands[i].q_factor = eq_cfg->eq_bands[i].q_factor;
-	}
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
-
-int q6audio_set_stream_eq_pcm(struct audio_client *ac, void *eq_config)
-{
-	int rc = 0;
-	mutex_lock(&audio_path_lock);
-	rc = audio_stream_equalizer(ac, eq_config);
-	mutex_unlock(&audio_path_lock);
-	return rc;
-}
-
-struct audio_client *q6audio_open_auxpcm(uint32_t rate,
-				      uint32_t channels, uint32_t flags, uint32_t acdb_id)
-{
-	int rc, retry = 5;
-	struct audio_client *ac;
-
-	pr_debug("[%s:%s] rate = %d, channels = %d\n", __MM_FILE__, __func__,
-		rate, channels);
-	if (q6audio_init())
-		return NULL;
-	ac = audio_client_alloc(0);
-	if (!ac)
-		return NULL;
-
-	ac->flags = flags;
-
-	mutex_lock(&audio_path_lock);
-
-	if (ac->flags & AUDIO_FLAG_WRITE) {
-		audio_tx_path_refcount++;
-		if (audio_tx_path_refcount == 1) {
-			tx_clk_freq = rate;
-			_audio_tx_clk_enable();
-			_audio_tx_path_enable(0, acdb_id);
-		}
-	} else {
-		audio_rx_path_refcount++;
-		if (audio_rx_path_refcount == 1) {
-			_audio_rx_clk_enable();
-			_audio_rx_path_enable(0, acdb_id);
-		}
-	}
-
-	ecodec_clk_enable();
-
-	for (retry = 5;; retry--) {
-		if (ac->flags & AUDIO_FLAG_WRITE)
-			rc = audio_auxpcm_out_open(ac, rate, channels);
-		else
-			rc = audio_auxpcm_in_open(ac, rate, channels);
-		if (rc == 0)
-			break;
-		if (retry == 0)
-			q6audio_dsp_not_responding();
-
-		pr_err("[%s:%s] open pcm error %d, retrying\n",
-			__MM_FILE__, __func__, rc);
-		msleep(1);
-	}
-
-	mutex_unlock(&audio_path_lock);
-
-	for (retry = 5;; retry--) {
-		rc = audio_command(ac, ADSP_AUDIO_IOCTL_CMD_SESSION_START);
-		if (rc == 0)
-			break;
-		if (retry == 0)
-			q6audio_dsp_not_responding();
-
-		pr_err("[%s:%s] stream start error %d, retrying\n",
-			__MM_FILE__, __func__, rc);
-	}
-	audio_prevent_sleep();
-	return ac;
-
-}
-
-struct audio_client *q6audio_open_pcm(uint32_t bufsz, uint32_t rate,
-		      uint32_t channels, uint32_t flags, uint32_t acdb_id)
-{
-	int rc, retry = 5;
-	struct audio_client *ac;
-
-	pr_debug("[%s:%s] bufsz = %d, rate = %d, channels = %d\n", __MM_FILE__,
-		__func__, bufsz, rate, channels);
-	if (q6audio_init())
-		return 0;
-
-	ac = audio_client_alloc(bufsz);
-	if (!ac)
-		return 0;
-
-	ac->flags = flags;
-
-	mutex_lock(&audio_path_lock);
-
-	if (ac->flags & AUDIO_FLAG_WRITE) {
-		audio_rx_path_refcount++;
-		if (audio_rx_path_refcount == 1) {
-			_audio_rx_clk_enable();
-			q6_rx_path_enable(0, acdb_id);
-			adie_rx_path_enable(acdb_id);
-		}
-	} else {
-		/* TODO: consider concurrency with voice call */
-		audio_tx_path_refcount++;
-		if (audio_tx_path_refcount == 1) {
-			tx_clk_freq = rate;
-			_audio_tx_clk_enable();
-			_audio_tx_path_enable(0, acdb_id);
-		}
-	}
-
-	for (retry = 5;;retry--) {
-		if (ac->flags & AUDIO_FLAG_WRITE)
-			rc = audio_out_open(ac, bufsz, rate, channels);
-		else
-			rc = audio_in_open(ac, bufsz, flags, rate, channels);
-		if (rc == 0)
-			break;
-		if (retry == 0)
-			q6audio_dsp_not_responding();
-
-		pr_err("[%s:%s] open pcm error %d, retrying\n",
-			__MM_FILE__, __func__, rc);
-		msleep(1);
-	}
-
-	if (ac->flags & AUDIO_FLAG_WRITE) {
-		if (audio_rx_path_refcount == 1)
-			audio_rx_analog_enable(1);
-	}
-	mutex_unlock(&audio_path_lock);
-
-	for (retry = 5;;retry--) {
-		rc = audio_command(ac, ADSP_AUDIO_IOCTL_CMD_SESSION_START);
-		if (rc == 0)
-			break;
-		if (retry == 0)
-			q6audio_dsp_not_responding();
-
-		pr_err("[%s:%s] stream start error %d, retrying\n",
-			__MM_FILE__, __func__, rc);
-	}
-
-	if (!(ac->flags & AUDIO_FLAG_WRITE)) {
-		ac->buf[0].used = 1;
-		ac->buf[1].used = 1;
-		q6audio_read(ac, &ac->buf[0]);
-		q6audio_read(ac, &ac->buf[1]);
-	}
-
-	audio_prevent_sleep();
-	return ac;
-}
-
-int q6audio_close(struct audio_client *ac)
-{
-	audio_close(ac);
-	if (ac->flags & AUDIO_FLAG_WRITE)
-		audio_rx_path_enable(0, 0);
-	else
-		audio_tx_path_enable(0, 0);
-	audio_client_free(ac);
-	audio_allow_sleep();
-	pr_debug("[%s:%s] ac = %p\n", __MM_FILE__, __func__, ac);
-	return 0;
-}
-
-int q6audio_auxpcm_close(struct audio_client *ac)
-{
-	audio_close(ac);
-	if (ac->flags & AUDIO_FLAG_WRITE) {
-		audio_tx_path_enable(0, 0);
-		ecodec_clk_disable(0, ADSP_PATH_RX);
-	} else {
-		audio_rx_path_enable(0, 0);
-		ecodec_clk_disable(0, ADSP_PATH_TX);
-	}
-
-	audio_client_free(ac);
-	audio_allow_sleep();
-	pr_debug("[%s:%s] ac = %p\n", __MM_FILE__, __func__, ac);
-	return 0;
-}
-struct audio_client *q6voice_open(uint32_t flags)
-{
-	struct audio_client *ac;
-
-	pr_debug("[%s:%s] flags = %d\n", __MM_FILE__, __func__, flags);
-	if (q6audio_init())
-		return 0;
-
-	ac = audio_client_alloc(0);
-	if (!ac)
-		return 0;
-
-	ac->flags = flags;
-	if (ac->flags & AUDIO_FLAG_WRITE)
-		audio_rx_path_enable(1, rx_acdb);
-	else {
-		if (!audio_tx_path_refcount)
-			tx_clk_freq = 8000;
-		audio_tx_path_enable(1, tx_acdb);
-	}
-
-	return ac;
-}
-
-int q6voice_close(struct audio_client *ac)
-{
-	if (ac->flags & AUDIO_FLAG_WRITE)
-		audio_rx_path_enable(0, 0);
-	else
-		audio_tx_path_enable(0, 0);
-
-	tx_mute_status = 0;
-	audio_client_free(ac);
-	pr_debug("[%s:%s]\n", __MM_FILE__, __func__);
-	return 0;
-}
-
-struct audio_client *q6audio_open_mp3(uint32_t bufsz, uint32_t rate,
-				      uint32_t channels, uint32_t acdb_id)
-{
-	struct audio_client *ac;
-
-	pr_debug("[%s:%s] bufsz = %d, rate = %d\n, channels = %d",
-		__MM_FILE__, __func__, bufsz, rate, channels);
-
-	if (q6audio_init())
-		return 0;
-
-	ac = audio_client_alloc(bufsz);
-	if (!ac)
-		return 0;
-
-	ac->flags = AUDIO_FLAG_WRITE;
-	audio_rx_path_enable(1, acdb_id);
-
-	audio_mp3_open(ac, bufsz, rate, channels);
-	audio_command(ac, ADSP_AUDIO_IOCTL_CMD_SESSION_START);
-
-	mutex_lock(&audio_path_lock);
-	audio_rx_mute(ac_control, audio_rx_device_id, 0);
-	audio_rx_volume(ac_control, audio_rx_device_id,
-			q6_device_volume(audio_rx_device_id, rx_vol_level));
-	mutex_unlock(&audio_path_lock);
-	return ac;
-}
-
-struct audio_client *q6audio_open_dtmf(uint32_t rate,
-				      uint32_t channels, uint32_t acdb_id)
-{
-	struct audio_client *ac;
-
-	pr_debug("[%s:%s] rate = %d\n, channels = %d", __MM_FILE__, __func__,
-		 rate, channels);
-	if (q6audio_init())
-		return 0;
-
-	ac = audio_client_alloc(0);
-	if (!ac)
-		return 0;
-
-	ac->flags = AUDIO_FLAG_WRITE;
-	audio_rx_path_enable(1, acdb_id);
-
-	audio_dtmf_open(ac, rate, channels);
-	audio_command(ac, ADSP_AUDIO_IOCTL_CMD_SESSION_START);
-
-	mutex_lock(&audio_path_lock);
-	audio_rx_mute(ac_control, audio_rx_device_id, 0);
-	audio_rx_volume(ac_control, audio_rx_device_id,
-		q6_device_volume(audio_rx_device_id, rx_vol_level));
-	mutex_unlock(&audio_path_lock);
-
-	return ac;
-}
-
-int q6audio_play_dtmf(struct audio_client *ac, uint16_t dtmf_hi,
-			 uint16_t dtmf_low, uint16_t duration, uint16_t rx_gain)
-{
-	struct adsp_audio_dtmf_start_command dtmf_cmd;
-
-	pr_debug("[%s:%s] high = %d, low = %d\n", __MM_FILE__, __func__,
-		dtmf_hi, dtmf_low);
-
-	dtmf_cmd.hdr.opcode = ADSP_AUDIO_IOCTL_CMD_SESSION_DTMF_START;
-	dtmf_cmd.hdr.response_type = ADSP_AUDIO_RESPONSE_COMMAND;
-	dtmf_cmd.tone1_hz = dtmf_hi;
-	dtmf_cmd.tone2_hz = dtmf_low;
-	dtmf_cmd.duration_usec = duration * 1000;
-	dtmf_cmd.gain_mb = rx_gain;
-
-	return audio_ioctl(ac, &dtmf_cmd,
-		 sizeof(struct adsp_audio_dtmf_start_command));
-
-}
-
-int q6audio_mp3_close(struct audio_client *ac)
-{
-	pr_debug("[%s:%s]\n", __MM_FILE__, __func__);
-	audio_close(ac);
-	audio_rx_path_enable(0, 0);
-	audio_client_free(ac);
-	return 0;
-}
-
-
-struct audio_client *q6audio_open_aac(uint32_t bufsz, uint32_t samplerate,
-					uint32_t channels, uint32_t bitrate,
-					uint32_t stream_format, uint32_t flags,
-					uint32_t acdb_id)
-{
-	struct audio_client *ac;
-
-	pr_debug("[%s:%s] bufsz = %d, samplerate = %d, channels = %d\n",
-		__MM_FILE__, __func__, bufsz, samplerate, channels);
-
-	if (q6audio_init())
-		return 0;
-
-	ac = audio_client_alloc(bufsz);
-	if (!ac)
-		return 0;
-
-	ac->flags = flags;
-
-	if (ac->flags & AUDIO_FLAG_WRITE)
-		audio_rx_path_enable(1, acdb_id);
-	else{
-		if (!audio_tx_path_refcount)
-			tx_clk_freq = 48000;
-		audio_tx_path_enable(1, acdb_id);
-	}
-
-	audio_aac_open(ac, bufsz, samplerate, channels, bitrate, flags,
-							stream_format);
-	audio_command(ac, ADSP_AUDIO_IOCTL_CMD_SESSION_START);
-
-	if (!(ac->flags & AUDIO_FLAG_WRITE)) {
-		ac->buf[0].used = 1;
-		ac->buf[1].used = 1;
-		q6audio_read(ac, &ac->buf[0]);
-		q6audio_read(ac, &ac->buf[1]);
-	}
-	audio_prevent_sleep();
-	return ac;
-}
-
-
-struct audio_client *q6audio_open_qcp(uint32_t bufsz, uint32_t min_rate,
-					uint32_t max_rate, uint32_t flags,
-					uint32_t format, uint32_t acdb_id)
-{
-	struct audio_client *ac;
-
-	pr_debug("[%s:%s] bufsz = %d\n", __MM_FILE__, __func__, bufsz);
-
-	if (q6audio_init())
-		return 0;
-
-	ac = audio_client_alloc(bufsz);
-	if (!ac)
-		return 0;
-
-	ac->flags = flags;
-
-	if (ac->flags & AUDIO_FLAG_WRITE)
-		audio_rx_path_enable(1, acdb_id);
-	else{
-		if (!audio_tx_path_refcount)
-			tx_clk_freq = 8000;
-		audio_tx_path_enable(1, acdb_id);
-	}
-
-	audio_qcp_open(ac, bufsz, min_rate, max_rate, flags, format);
-	audio_command(ac, ADSP_AUDIO_IOCTL_CMD_SESSION_START);
-
-	if (!(ac->flags & AUDIO_FLAG_WRITE)) {
-		ac->buf[0].used = 1;
-		ac->buf[1].used = 1;
-		q6audio_read(ac, &ac->buf[0]);
-		q6audio_read(ac, &ac->buf[1]);
-	}
-	audio_prevent_sleep();
-	return ac;
-}
-
-struct audio_client *q6audio_open_amrnb(uint32_t bufsz, uint32_t enc_mode,
-					uint32_t dtx_mode_enable,
-					uint32_t flags, uint32_t acdb_id)
-{
-	struct audio_client *ac;
-
-	pr_debug("[%s:%s] bufsz = %d, dtx_mode = %d\n", __MM_FILE__,
-			__func__, bufsz, dtx_mode_enable);
-
-	if (q6audio_init())
-		return 0;
-
-	ac = audio_client_alloc(bufsz);
-	if (!ac)
-		return 0;
-
-	ac->flags = flags;
-	if (ac->flags & AUDIO_FLAG_WRITE)
-		audio_rx_path_enable(1, acdb_id);
-	else{
-		if (!audio_tx_path_refcount)
-			tx_clk_freq = 8000;
-		audio_tx_path_enable(1, acdb_id);
-	}
-
-	audio_amrnb_open(ac, bufsz, enc_mode, flags, dtx_mode_enable);
-	audio_command(ac, ADSP_AUDIO_IOCTL_CMD_SESSION_START);
-
-	if (!(ac->flags & AUDIO_FLAG_WRITE)) {
-		ac->buf[0].used = 1;
-		ac->buf[1].used = 1;
-		q6audio_read(ac, &ac->buf[0]);
-		q6audio_read(ac, &ac->buf[1]);
-	}
-	audio_prevent_sleep();
-	return ac;
-}
-
-int q6audio_async(struct audio_client *ac)
-{
-	struct adsp_command_hdr rpc;
-	pr_debug("[%s:%s] ac = %p\n", __MM_FILE__, __func__, ac);
-	memset(&rpc, 0, sizeof(rpc));
-	rpc.opcode = ADSP_AUDIO_IOCTL_CMD_STREAM_EOS;
-	rpc.response_type = ADSP_AUDIO_RESPONSE_ASYNC;
-	return audio_ioctl(ac, &rpc, sizeof(rpc));
-}
diff --git a/arch/arm/mach-msm/qdsp6/q6audio_devices.h b/arch/arm/mach-msm/qdsp6/q6audio_devices.h
deleted file mode 100644
index d316ab0..0000000
--- a/arch/arm/mach-msm/qdsp6/q6audio_devices.h
+++ /dev/null
@@ -1,334 +0,0 @@
-/* arch/arm/mach-msm/qdsp6/q6audio_devices.h
- *
- * Copyright (C) 2009 Google, Inc.
- * Author: Brian Swetland <swetland@google.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-struct q6_device_info {
-	uint32_t id;
-	uint32_t cad_id;
-	uint32_t path;
-	uint32_t rate;
-	uint8_t dir;
-	uint8_t codec;
-	uint8_t hw;
-};
-
-#define Q6_ICODEC_RX		0
-#define Q6_ICODEC_TX		1
-#define Q6_ECODEC_RX		2
-#define Q6_ECODEC_TX		3
-#define Q6_SDAC_RX		6
-#define Q6_SDAC_TX		7
-#define Q6_CODEC_NONE		255
-
-#define Q6_TX		1
-#define Q6_RX		2
-#define Q6_TX_RX	3
-
-#define Q6_HW_HANDSET	0
-#define Q6_HW_HEADSET	1
-#define Q6_HW_SPEAKER	2
-#define Q6_HW_TTY	3
-#define Q6_HW_BT_SCO	4
-#define Q6_HW_BT_A2DP	5
-
-#define Q6_HW_COUNT	6
-
-#define CAD_HW_DEVICE_ID_HANDSET_MIC		0x01
-#define CAD_HW_DEVICE_ID_HANDSET_SPKR		0x02
-#define CAD_HW_DEVICE_ID_HEADSET_MIC		0x03
-#define CAD_HW_DEVICE_ID_HEADSET_SPKR_MONO	0x04
-#define CAD_HW_DEVICE_ID_HEADSET_SPKR_STEREO	0x05
-#define CAD_HW_DEVICE_ID_SPKR_PHONE_MIC		0x06
-#define CAD_HW_DEVICE_ID_SPKR_PHONE_MONO	0x07
-#define CAD_HW_DEVICE_ID_SPKR_PHONE_STEREO	0x08
-#define CAD_HW_DEVICE_ID_BT_SCO_MIC		0x09
-#define CAD_HW_DEVICE_ID_BT_SCO_SPKR		0x0A
-#define CAD_HW_DEVICE_ID_BT_A2DP_SPKR		0x0B
-#define CAD_HW_DEVICE_ID_TTY_HEADSET_MIC	0x0C
-#define CAD_HW_DEVICE_ID_TTY_HEADSET_SPKR	0x0D
-
-#define CAD_HW_DEVICE_ID_DEFAULT_TX		0x0E
-#define CAD_HW_DEVICE_ID_DEFAULT_RX		0x0F
-
-
-#define CAD_HW_DEVICE_ID_SPKR_PHONE_DUAL_MIC_BROADSIDE      0x2B
-#define CAD_HW_DEVICE_ID_SPKR_PHONE_DUAL_MIC_ENDFIRE        0x2D
-#define CAD_HW_DEVICE_ID_HANDSET_DUAL_MIC_BROADSIDE         0x2C
-#define CAD_HW_DEVICE_ID_HANDSET_DUAL_MIC_ENDFIRE           0x2E
-
-/* Logical Device to indicate A2DP routing */
-#define CAD_HW_DEVICE_ID_BT_A2DP_TX             0x10
-#define CAD_HW_DEVICE_ID_HEADSET_MONO_PLUS_SPKR_MONO_RX		0x11
-#define CAD_HW_DEVICE_ID_HEADSET_MONO_PLUS_SPKR_STEREO_RX	0x12
-#define CAD_HW_DEVICE_ID_HEADSET_STEREO_PLUS_SPKR_MONO_RX	0x13
-#define CAD_HW_DEVICE_ID_HEADSET_STEREO_PLUS_SPKR_STEREO_RX	0x14
-
-#define CAD_HW_DEVICE_ID_VOICE			0x15
-
-#define CAD_HW_DEVICE_ID_I2S_RX                 0x20
-#define CAD_HW_DEVICE_ID_I2S_TX                 0x21
-
-/* AUXPGA */
-#define CAD_HW_DEVICE_ID_HEADSET_SPKR_STEREO_LB 0x22
-#define CAD_HW_DEVICE_ID_HEADSET_SPKR_MONO_LB   0x23
-#define CAD_HW_DEVICE_ID_SPEAKER_SPKR_STEREO_LB 0x24
-#define CAD_HW_DEVICE_ID_SPEAKER_SPKR_MONO_LB   0x25
-
-#define CAD_HW_DEVICE_ID_NULL_RX		0x2A
-
-#define CAD_HW_DEVICE_ID_MAX_NUM                0x2F
-
-#define CAD_HW_DEVICE_ID_INVALID                0xFF
-
-#define CAD_RX_DEVICE  0x00
-#define CAD_TX_DEVICE  0x01
-
-static struct q6_device_info q6_audio_devices[] = {
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_HANDSET_SPKR,
-		.cad_id	= CAD_HW_DEVICE_ID_HANDSET_SPKR,
-		.path	= ADIE_PATH_HANDSET_RX,
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ICODEC_RX,
-		.hw	= Q6_HW_HANDSET,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_HEADSET_SPKR_MONO,
-		.cad_id	= CAD_HW_DEVICE_ID_HEADSET_SPKR_MONO,
-		.path	= ADIE_PATH_HEADSET_MONO_RX,
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ICODEC_RX,
-		.hw	= Q6_HW_HEADSET,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_HEADSET_SPKR_STEREO,
-		.cad_id	= CAD_HW_DEVICE_ID_HEADSET_SPKR_STEREO,
-		.path	= ADIE_PATH_HEADSET_STEREO_RX,
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ICODEC_RX,
-		.hw	= Q6_HW_HEADSET,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MONO,
-		.cad_id	= CAD_HW_DEVICE_ID_SPKR_PHONE_MONO,
-		.path	= ADIE_PATH_SPEAKER_RX,
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ICODEC_RX,
-		.hw	= Q6_HW_SPEAKER,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_STEREO,
-		.cad_id	= CAD_HW_DEVICE_ID_SPKR_PHONE_STEREO,
-		.path	= ADIE_PATH_SPEAKER_STEREO_RX,
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ICODEC_RX,
-		.hw	= Q6_HW_SPEAKER,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MONO_W_MONO_HEADSET,
-		.cad_id	= CAD_HW_DEVICE_ID_HEADSET_MONO_PLUS_SPKR_MONO_RX,
-		.path	= ADIE_PATH_SPKR_MONO_HDPH_MONO_RX,
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ICODEC_RX,
-		.hw	= Q6_HW_SPEAKER,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MONO_W_STEREO_HEADSET,
-		.cad_id	= CAD_HW_DEVICE_ID_HEADSET_STEREO_PLUS_SPKR_MONO_RX,
-		.path	= ADIE_PATH_SPKR_MONO_HDPH_STEREO_RX,
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ICODEC_RX,
-		.hw	= Q6_HW_SPEAKER,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_STEREO_W_MONO_HEADSET,
-		.cad_id	= CAD_HW_DEVICE_ID_HEADSET_MONO_PLUS_SPKR_STEREO_RX,
-		.path	= ADIE_PATH_SPKR_STEREO_HDPH_MONO_RX,
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ICODEC_RX,
-		.hw	= Q6_HW_SPEAKER,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_STEREO_W_STEREO_HEADSET,
-		.cad_id	= CAD_HW_DEVICE_ID_HEADSET_STEREO_PLUS_SPKR_STEREO_RX,
-		.path	= ADIE_PATH_SPKR_STEREO_HDPH_STEREO_RX,
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ICODEC_RX,
-		.hw	= Q6_HW_SPEAKER,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_TTY_HEADSET_SPKR,
-		.cad_id	= CAD_HW_DEVICE_ID_TTY_HEADSET_SPKR,
-		.path	= ADIE_PATH_TTY_HEADSET_RX,
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ICODEC_RX,
-		.hw	= Q6_HW_TTY,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_HANDSET_MIC,
-		.cad_id	= CAD_HW_DEVICE_ID_HANDSET_MIC,
-		.path	= ADIE_PATH_HANDSET_TX,
-		.rate   = 8000,
-		.dir	= Q6_TX,
-		.codec	= Q6_ICODEC_TX,
-		.hw	= Q6_HW_HANDSET,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_HEADSET_MIC,
-		.cad_id	= CAD_HW_DEVICE_ID_HEADSET_MIC,
-		.path	= ADIE_PATH_HEADSET_MONO_TX,
-		.rate   = 8000,
-		.dir	= Q6_TX,
-		.codec	= Q6_ICODEC_TX,
-		.hw	= Q6_HW_HEADSET,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_MIC,
-		.cad_id	= CAD_HW_DEVICE_ID_SPKR_PHONE_MIC,
-		.path	= ADIE_PATH_SPEAKER_TX,
-		.rate   = 8000,
-		.dir	= Q6_TX,
-		.codec	= Q6_ICODEC_TX,
-		.hw	= Q6_HW_SPEAKER,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_HANDSET_DUAL_MIC,
-		.cad_id	= CAD_HW_DEVICE_ID_HANDSET_DUAL_MIC_ENDFIRE,
-		.path	= ADIE_CODEC_HANDSET_SPKR_EF_TX,
-		.rate	= 8000,
-		.dir	= Q6_TX,
-		.codec	= Q6_ICODEC_TX,
-		.hw	= Q6_HW_HANDSET,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_HANDSET_DUAL_MIC,
-		.cad_id	= CAD_HW_DEVICE_ID_HANDSET_DUAL_MIC_BROADSIDE,
-		.path	= ADIE_CODEC_HANDSET_SPKR_BS_TX,
-		.rate	= 8000,
-		.dir	= Q6_TX,
-		.codec	= Q6_ICODEC_TX,
-		.hw	= Q6_HW_HANDSET,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_DUAL_MIC,
-		.cad_id	= CAD_HW_DEVICE_ID_SPKR_PHONE_DUAL_MIC_ENDFIRE,
-		.path	= ADIE_CODEC_HANDSET_SPKR_EF_TX,
-		.rate	= 8000,
-		.dir	= Q6_TX,
-		.codec	= Q6_ICODEC_TX,
-		.hw	= Q6_HW_SPEAKER,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_SPKR_PHONE_DUAL_MIC,
-		.cad_id	= CAD_HW_DEVICE_ID_SPKR_PHONE_DUAL_MIC_BROADSIDE,
-		.path	= ADIE_CODEC_HANDSET_SPKR_BS_TX,
-		.rate	= 8000,
-		.dir	= Q6_TX,
-		.codec	= Q6_ICODEC_TX,
-		.hw	= Q6_HW_SPEAKER,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_TTY_HEADSET_MIC,
-		.cad_id	= CAD_HW_DEVICE_ID_TTY_HEADSET_MIC,
-		.path	= ADIE_PATH_TTY_HEADSET_TX,
-		.rate   = 8000,
-		.dir	= Q6_TX,
-		.codec	= Q6_ICODEC_TX,
-		.hw	= Q6_HW_HEADSET,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_BT_SCO_SPKR,
-		.cad_id	= CAD_HW_DEVICE_ID_BT_SCO_SPKR,
-		.path	= 0, /* XXX */
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ECODEC_RX,
-		.hw	= Q6_HW_BT_SCO,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_BT_A2DP_SPKR,
-		.cad_id	= CAD_HW_DEVICE_ID_BT_A2DP_SPKR,
-		.path	= 0, /* XXX */
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ECODEC_RX,
-		.hw	= Q6_HW_BT_A2DP,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_BT_SCO_MIC,
-		.cad_id	= CAD_HW_DEVICE_ID_BT_SCO_MIC,
-		.path	= 0, /* XXX */
-		.rate   = 8000,
-		.dir	= Q6_TX,
-		.codec	= Q6_ECODEC_TX,
-		.hw	= Q6_HW_BT_SCO,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_I2S_SPKR,
-		.cad_id	= CAD_HW_DEVICE_ID_I2S_RX,
-		.path	= 0, /* XXX */
-		.rate   = 48000,
-		.dir	= Q6_RX,
-		.codec	= Q6_SDAC_RX,
-		.hw	= Q6_HW_SPEAKER,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_I2S_MIC,
-		.cad_id	= CAD_HW_DEVICE_ID_I2S_TX,
-		.path	= 0, /* XXX */
-		.rate   = 16000,
-		.dir	= Q6_TX,
-		.codec	= Q6_SDAC_TX,
-		.hw	= Q6_HW_SPEAKER,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_AUXPCM_RX,
-		.cad_id	= CAD_HW_DEVICE_ID_BT_SCO_SPKR,
-		.path	= 0, /* XXX */
-		.rate   = 8000,
-		.dir	= Q6_RX,
-		.codec	= Q6_ECODEC_RX,
-		.hw	= Q6_HW_BT_SCO,
-	},
-	{
-		.id	= ADSP_AUDIO_DEVICE_ID_AUXPCM_TX,
-		.cad_id	= CAD_HW_DEVICE_ID_BT_SCO_MIC,
-		.path	= 0, /* XXX */
-		.rate   = 8000,
-		.dir	= Q6_TX,
-		.codec	= Q6_ECODEC_TX,
-		.hw	= Q6_HW_BT_SCO,
-	},
-	{
-		.id	= 0,
-		.cad_id	= 0,
-		.path	= 0,
-		.rate   = 8000,
-		.dir	= 0,
-		.codec	= Q6_CODEC_NONE,
-		.hw	= 0,
-	},
-};
-
diff --git a/arch/arm/mach-msm/qdsp6/qcelp_in.c b/arch/arm/mach-msm/qdsp6/qcelp_in.c
deleted file mode 100644
index 4289612..0000000
--- a/arch/arm/mach-msm/qdsp6/qcelp_in.c
+++ /dev/null
@@ -1,475 +0,0 @@
-/*
- * Copyright (C) 2009 Google, Inc.
- * Copyright (C) 2009 HTC Corporation
- * Copyright (c) 2010, The Linux Foundation. All rights reserved.
- *
- * Author: Brian Swetland <swetland@google.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/slab.h>
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/uaccess.h>
-#include <linux/kthread.h>
-#include <linux/time.h>
-#include <linux/wait.h>
-
-#include <linux/msm_audio_qcp.h>
-#include <mach/msm_qdsp6_audio.h>
-#include "dal_audio_format.h"
-#include <mach/debug_mm.h>
-
-#define QCELP_FC_BUFF_CNT 10
-#define QCELP_READ_TIMEOUT 2000
-struct qcelp_fc_buff {
-	struct mutex lock;
-	int empty;
-	void *data;
-	int size;
-	int actual_size;
-};
-
-struct qcelp_fc {
-	struct task_struct *task;
-	wait_queue_head_t fc_wq;
-	struct qcelp_fc_buff fc_buff[QCELP_FC_BUFF_CNT];
-	int buff_index;
-};
-
-struct qcelp {
-	struct mutex lock;
-	struct msm_audio_qcelp_enc_config cfg;
-	struct msm_audio_stream_config str_cfg;
-	struct audio_client *audio_client;
-	struct msm_voicerec_mode voicerec_mode;
-	struct qcelp_fc *qcelp_fc;
-};
-
-
-static int q6_qcelp_flowcontrol(void *data)
-{
-	struct audio_client *ac;
-	struct audio_buffer *ab;
-	struct qcelp *qcelp = data;
-	int buff_index = 0;
-	int xfer = 0;
-	struct qcelp_fc *fc;
-
-
-	ac = qcelp->audio_client;
-	fc = qcelp->qcelp_fc;
-	if (!ac) {
-		pr_err("[%s:%s] audio_client is NULL\n", __MM_FILE__, __func__);
-		return 0;
-	}
-
-	while (!kthread_should_stop()) {
-		ab = ac->buf + ac->cpu_buf;
-		if (ab->used)
-			wait_event(ac->wait, (ab->used == 0));
-
-		pr_debug("[%s:%s] ab->data = %p, cpu_buf = %d", __MM_FILE__,
-			__func__, ab->data, ac->cpu_buf);
-		xfer = ab->actual_size;
-
-
-		mutex_lock(&(fc->fc_buff[buff_index].lock));
-		if (!fc->fc_buff[buff_index].empty) {
-			pr_err("[%s:%s] flow control buffer[%d] not read!\n",
-					__MM_FILE__, __func__, buff_index);
-		}
-
-		if (fc->fc_buff[buff_index].size < xfer) {
-			pr_err("[%s:%s] buffer %d too small\n", __MM_FILE__,
-					__func__, buff_index);
-			memcpy(fc->fc_buff[buff_index].data, ab->data,
-					fc->fc_buff[buff_index].size);
-			fc->fc_buff[buff_index].empty = 0;
-			fc->fc_buff[buff_index].actual_size =
-					fc->fc_buff[buff_index].size;
-		} else {
-			memcpy(fc->fc_buff[buff_index].data, ab->data, xfer);
-			fc->fc_buff[buff_index].empty = 0;
-			fc->fc_buff[buff_index].actual_size = xfer;
-		}
-		mutex_unlock(&(fc->fc_buff[buff_index].lock));
-		/*wake up client, if any*/
-		wake_up(&fc->fc_wq);
-
-		buff_index++;
-		if (buff_index >= QCELP_FC_BUFF_CNT)
-			buff_index = 0;
-
-		ab->used = 1;
-
-		q6audio_read(ac, ab);
-		ac->cpu_buf ^= 1;
-	}
-
-	return 0;
-}
-static long q6_qcelp_in_ioctl(struct file *file, unsigned int cmd,
-				 unsigned long arg)
-{
-	struct qcelp *qcelp = file->private_data;
-	int rc = 0;
-	int i = 0;
-	struct qcelp_fc *fc;
-	int size = 0;
-
-	mutex_lock(&qcelp->lock);
-	switch (cmd) {
-	case AUDIO_SET_VOLUME:
-		pr_debug("[%s:%s] SET_VOLUME\n", __MM_FILE__, __func__);
-		break;
-	case AUDIO_GET_STATS:
-	{
-		struct msm_audio_stats stats;
-		pr_debug("[%s:%s] GET_STATS\n", __MM_FILE__, __func__);
-		memset(&stats, 0, sizeof(stats));
-		if (copy_to_user((void *) arg, &stats,
-					sizeof(stats)))
-			return -EFAULT;
-		return 0;
-	}
-	case AUDIO_START:
-	{
-		uint32_t acdb_id;
-		pr_debug("[%s:%s] AUDIO_START\n", __MM_FILE__, __func__);
-		if (arg == 0) {
-			acdb_id = 0;
-		} else {
-			if (copy_from_user(&acdb_id,
-				(void *) arg, sizeof(acdb_id))) {
-				rc = -EFAULT;
-				break;
-			}
-		}
-		if (qcelp->audio_client) {
-			pr_err("[%s:%s] active session already existing\n",
-				__MM_FILE__, __func__);
-			rc = -EBUSY;
-			break;
-		} else {
-			qcelp->audio_client = q6audio_open_qcp(
-				qcelp->str_cfg.buffer_size,
-				qcelp->cfg.min_bit_rate,
-				qcelp->cfg.max_bit_rate,
-				qcelp->voicerec_mode.rec_mode,
-				ADSP_AUDIO_FORMAT_V13K_FS,
-				acdb_id);
-
-			if (!qcelp->audio_client) {
-				pr_err("[%s:%s] qcelp open session failed\n",
-					__MM_FILE__, __func__);
-				kfree(qcelp);
-				rc = -ENOMEM;
-				break;
-			}
-		}
-
-		/*allocate flow control buffers*/
-		fc = qcelp->qcelp_fc;
-		size = qcelp->str_cfg.buffer_size;
-		for (i = 0; i < QCELP_FC_BUFF_CNT; ++i) {
-			mutex_init(&(fc->fc_buff[i].lock));
-			fc->fc_buff[i].empty = 1;
-			fc->fc_buff[i].data = kmalloc(size, GFP_KERNEL);
-			if (fc->fc_buff[i].data == NULL) {
-				pr_err("[%s:%s] No memory for FC buffers\n",
-						__MM_FILE__, __func__);
-				rc = -ENOMEM;
-				goto fc_fail;
-			}
-			fc->fc_buff[i].size = size;
-			fc->fc_buff[i].actual_size = 0;
-		}
-
-		/*create flow control thread*/
-		fc->task = kthread_run(q6_qcelp_flowcontrol,
-				qcelp, "qcelp_flowcontrol");
-		if (IS_ERR(fc->task)) {
-			rc = PTR_ERR(fc->task);
-			pr_err("[%s:%s] error creating flow control thread\n",
-					__MM_FILE__, __func__);
-			goto fc_fail;
-		}
-		break;
-fc_fail:
-		/*free flow control buffers*/
-		--i;
-		for (; i >=  0; i--) {
-			kfree(fc->fc_buff[i].data);
-			fc->fc_buff[i].data = NULL;
-		}
-		break;
-	}
-	case AUDIO_STOP:
-		pr_debug("[%s:%s] AUDIO_STOP\n", __MM_FILE__, __func__);
-		break;
-	case AUDIO_FLUSH:
-		break;
-	case AUDIO_SET_INCALL: {
-		pr_debug("[%s:%s] SET_INCALL\n", __MM_FILE__, __func__);
-		if (copy_from_user(&qcelp->voicerec_mode,
-			(void *)arg, sizeof(struct msm_voicerec_mode)))
-			rc = -EFAULT;
-
-		if (qcelp->voicerec_mode.rec_mode != AUDIO_FLAG_READ
-			&& qcelp->voicerec_mode.rec_mode !=
-			AUDIO_FLAG_INCALL_MIXED) {
-			qcelp->voicerec_mode.rec_mode = AUDIO_FLAG_READ;
-			pr_err("[%s:%s] Invalid rec_mode\n", __MM_FILE__,
-					__func__);
-			rc = -EINVAL;
-		}
-		break;
-	}
-	case AUDIO_GET_STREAM_CONFIG:
-		if (copy_to_user((void *)arg, &qcelp->str_cfg,
-				sizeof(struct msm_audio_stream_config)))
-			rc = -EFAULT;
-		pr_debug("[%s:%s] GET_STREAM_CONFIG: buffsz=%d, buffcnt=%d\n",
-			 __MM_FILE__, __func__, qcelp->str_cfg.buffer_size,
-			qcelp->str_cfg.buffer_count);
-		break;
-	case AUDIO_SET_STREAM_CONFIG:
-		if (copy_from_user(&qcelp->str_cfg, (void *)arg,
-			sizeof(struct msm_audio_stream_config))) {
-			rc = -EFAULT;
-			break;
-		}
-		pr_debug("[%s:%s] SET_STREAM_CONFIG: buffsz=%d, buffcnt=%d\n",
-			 __MM_FILE__, __func__, qcelp->str_cfg.buffer_size,
-			qcelp->str_cfg.buffer_count);
-
-		if (qcelp->str_cfg.buffer_size < 35) {
-			pr_err("[%s:%s] Buffer size too small\n", __MM_FILE__,
-					__func__);
-			rc = -EINVAL;
-			break;
-		}
-
-		if (qcelp->str_cfg.buffer_count != 2)
-			pr_info("[%s:%s] Buffer count set to 2\n", __MM_FILE__,
-					__func__);
-		break;
-	case AUDIO_SET_QCELP_ENC_CONFIG:
-		if (copy_from_user(&qcelp->cfg, (void *) arg,
-				sizeof(struct msm_audio_qcelp_enc_config)))
-			rc = -EFAULT;
-		pr_debug("[%s:%s] SET_QCELP_ENC_CONFIG\n", __MM_FILE__,
-			__func__);
-
-		if (qcelp->cfg.min_bit_rate > 4 ||
-			 qcelp->cfg.min_bit_rate < 1) {
-
-			pr_err("[%s:%s] invalid min bitrate\n", __MM_FILE__,
-					__func__);
-			rc = -EINVAL;
-		}
-		if (qcelp->cfg.max_bit_rate > 4 ||
-			 qcelp->cfg.max_bit_rate < 1) {
-
-			pr_err("[%s:%s] invalid max bitrate\n", __MM_FILE__,
-					__func__);
-			rc = -EINVAL;
-		}
-
-		break;
-	case AUDIO_GET_QCELP_ENC_CONFIG:
-		if (copy_to_user((void *) arg, &qcelp->cfg,
-			 sizeof(struct msm_audio_qcelp_enc_config)))
-			rc = -EFAULT;
-		pr_debug("[%s:%s] GET_QCELP_ENC_CONFIG\n", __MM_FILE__,
-			__func__);
-		break;
-
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&qcelp->lock);
-	pr_debug("[%s:%s] rc = %d\n", __MM_FILE__, __func__, rc);
-	return rc;
-}
-
-static int q6_qcelp_in_open(struct inode *inode, struct file *file)
-{
-	struct qcelp *qcelp;
-	struct qcelp_fc *fc;
-	int i;
-	pr_info("[%s:%s] open\n", __MM_FILE__, __func__);
-	qcelp = kmalloc(sizeof(struct qcelp), GFP_KERNEL);
-	if (qcelp == NULL) {
-		pr_err("[%s:%s] Could not allocate memory for qcelp driver\n",
-				__MM_FILE__, __func__);
-		return -ENOMEM;
-	}
-
-	mutex_init(&qcelp->lock);
-	file->private_data = qcelp;
-	qcelp->audio_client = NULL;
-	qcelp->str_cfg.buffer_size = 35;
-	qcelp->str_cfg.buffer_count = 2;
-	qcelp->cfg.cdma_rate = CDMA_RATE_FULL;
-	qcelp->cfg.min_bit_rate = 1;
-	qcelp->cfg.max_bit_rate = 4;
-	qcelp->voicerec_mode.rec_mode = AUDIO_FLAG_READ;
-
-	qcelp->qcelp_fc = kmalloc(sizeof(struct qcelp_fc), GFP_KERNEL);
-	if (qcelp->qcelp_fc == NULL) {
-		pr_err("[%s:%s] Could not allocate memory for qcelp_fc\n",
-				__MM_FILE__, __func__);
-		kfree(qcelp);
-		return -ENOMEM;
-	}
-	fc = qcelp->qcelp_fc;
-	fc->task = NULL;
-	fc->buff_index = 0;
-	for (i = 0; i < QCELP_FC_BUFF_CNT; ++i) {
-		fc->fc_buff[i].data = NULL;
-		fc->fc_buff[i].size = 0;
-		fc->fc_buff[i].actual_size = 0;
-	}
-	/*initialize wait queue head*/
-	init_waitqueue_head(&fc->fc_wq);
-	return 0;
-}
-
-static ssize_t q6_qcelp_in_read(struct file *file, char __user *buf,
-			   size_t count, loff_t *pos)
-{
-	struct audio_client *ac;
-	const char __user *start = buf;
-	struct qcelp *qcelp = file->private_data;
-	struct qcelp_fc *fc;
-	int xfer = 0;
-	int res = 0;
-
-	pr_debug("[%s:%s] count = %d\n", __MM_FILE__, __func__, count);
-	mutex_lock(&qcelp->lock);
-	ac = qcelp->audio_client;
-	if (!ac) {
-		res = -ENODEV;
-		goto fail;
-	}
-	fc = qcelp->qcelp_fc;
-	while (count > xfer) {
-		/*wait for buffer to full*/
-		if (fc->fc_buff[fc->buff_index].empty != 0) {
-			res = wait_event_interruptible_timeout(fc->fc_wq,
-				(fc->fc_buff[fc->buff_index].empty == 0),
-				msecs_to_jiffies(QCELP_READ_TIMEOUT));
-
-			pr_debug("[%s:%s] buff_index = %d\n", __MM_FILE__,
-				__func__, fc->buff_index);
-			if (res == 0) {
-				pr_err("[%s:%s] Timeout!\n", __MM_FILE__,
-						__func__);
-				res = -ETIMEDOUT;
-				goto fail;
-			} else if (res < 0) {
-				pr_err("[%s:%s] Returning on Interrupt\n",
-					__MM_FILE__, __func__);
-				goto fail;
-			}
-		}
-		/*lock the buffer*/
-		mutex_lock(&(fc->fc_buff[fc->buff_index].lock));
-		xfer = fc->fc_buff[fc->buff_index].actual_size;
-
-		if (xfer > count) {
-			mutex_unlock(&(fc->fc_buff[fc->buff_index].lock));
-			pr_err("[%s:%s] read failed! byte count too small\n",
-					__MM_FILE__, __func__);
-			res = -EINVAL;
-			goto fail;
-		}
-
-		if (copy_to_user(buf, fc->fc_buff[fc->buff_index].data,	xfer)) {
-			mutex_unlock(&(fc->fc_buff[fc->buff_index].lock));
-			pr_err("[%s:%s] copy_to_user failed at index %d\n",
-					__MM_FILE__, __func__, fc->buff_index);
-			res = -EFAULT;
-			goto fail;
-		}
-		buf += xfer;
-		count -= xfer;
-
-		fc->fc_buff[fc->buff_index].empty = 1;
-		fc->fc_buff[fc->buff_index].actual_size = 0;
-
-		mutex_unlock(&(fc->fc_buff[fc->buff_index].lock));
-		++(fc->buff_index);
-		if (fc->buff_index >= QCELP_FC_BUFF_CNT)
-			fc->buff_index = 0;
-	}
-	res = buf - start;
-
-fail:
-	mutex_unlock(&qcelp->lock);
-
-	return res;
-}
-
-static int q6_qcelp_in_release(struct inode *inode, struct file *file)
-{
-	int rc = 0;
-	struct qcelp *qcelp = file->private_data;
-	int i = 0;
-	struct qcelp_fc *fc;
-
-	mutex_lock(&qcelp->lock);
-	fc = qcelp->qcelp_fc;
-	kthread_stop(fc->task);
-	fc->task = NULL;
-
-	/*free flow control buffers*/
-	for (i = 0; i < QCELP_FC_BUFF_CNT; ++i) {
-		kfree(fc->fc_buff[i].data);
-		fc->fc_buff[i].data = NULL;
-	}
-	kfree(fc);
-
-	if (qcelp->audio_client)
-		rc = q6audio_close(qcelp->audio_client);
-	mutex_unlock(&qcelp->lock);
-	kfree(qcelp);
-	pr_info("[%s:%s] release\n", __MM_FILE__, __func__);
-	return rc;
-}
-
-static const struct file_operations q6_qcelp_in_fops = {
-	.owner		= THIS_MODULE,
-	.open		= q6_qcelp_in_open,
-	.read		= q6_qcelp_in_read,
-	.release	= q6_qcelp_in_release,
-	.unlocked_ioctl	= q6_qcelp_in_ioctl,
-};
-
-struct miscdevice q6_qcelp_in_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_qcelp_in",
-	.fops	= &q6_qcelp_in_fops,
-};
-
-static int __init q6_qcelp_in_init(void)
-{
-	return misc_register(&q6_qcelp_in_misc);
-}
-
-device_initcall(q6_qcelp_in_init);
diff --git a/arch/arm/mach-msm/qdsp6/routing.c b/arch/arm/mach-msm/qdsp6/routing.c
deleted file mode 100644
index f6533a4..0000000
--- a/arch/arm/mach-msm/qdsp6/routing.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/* arch/arm/mach-msm/qdsp6/routing.c
- *
- * Copyright (C) 2009 Google, Inc.
- * Author: Brian Swetland <swetland@google.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- */
-
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/uaccess.h>
-#include <mach/debug_mm.h>
-
-extern int q6audio_set_route(const char *name);
-
-static int q6_open(struct inode *inode, struct file *file)
-{
-	pr_debug("[%s:%s]\n", __MM_FILE__, __func__);
-	return 0;
-}
-
-static ssize_t q6_write(struct file *file, const char __user *buf,
-			size_t count, loff_t *pos)
-{
-	char cmd[32];
-
-	pr_debug("[%s:%s] count = %d", __MM_FILE__, __func__, count);
-	if (count >= sizeof(cmd)) {
-		pr_err("[%s:%s] invalid count %d\n", __MM_FILE__,
-			__func__, count);
-			return -EINVAL;
-	}
-	if (copy_from_user(cmd, buf, count))
-		return -EFAULT;
-	cmd[count] = 0;
-
-	if ((count > 1) && (cmd[count-1] == '\n'))
-		cmd[count-1] = 0;
-
-	q6audio_set_route(cmd);
-
-	return count;
-}
-
-static int q6_release(struct inode *inode, struct file *file)
-{
-	pr_debug("[%s:%s]\n", __MM_FILE__, __func__);
-	return 0;
-}
-
-static struct file_operations q6_fops = {
-	.owner		= THIS_MODULE,
-	.open		= q6_open,
-	.write		= q6_write,
-	.release	= q6_release,
-};
-
-static struct miscdevice q6_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_audio_route",
-	.fops	= &q6_fops,
-};
-
-
-static int __init q6_init(void) {
-	return misc_register(&q6_misc);
-}
-
-device_initcall(q6_init);
diff --git a/arch/arm/mach-msm/qdsp6v2/aac_in.c b/arch/arm/mach-msm/qdsp6v2/aac_in.c
index 0741538..865f6f2 100644
--- a/arch/arm/mach-msm/qdsp6v2/aac_in.c
+++ b/arch/arm/mach-msm/qdsp6v2/aac_in.c
@@ -58,11 +58,33 @@
 			break;
 		}
 
-		rc = audio_in_buf_alloc(audio);
-		if (rc < 0) {
-			pr_err("%s:session id %d: buffer allocation failed\n",
-				__func__, audio->ac->session);
-			break;
+		if (audio->opened) {
+			rc = audio_in_buf_alloc(audio);
+			if (rc < 0) {
+				pr_err("%s:session id %d: buffer allocation failed\n",
+					 __func__, audio->ac->session);
+				break;
+			}
+		} else {
+			if(audio->feedback == NON_TUNNEL_MODE){
+				pr_debug("%s: starting in non_tunnel mode",__func__);
+				rc = q6asm_open_read_write(audio->ac, FORMAT_MPEG4_AAC,
+						FORMAT_LINEAR_PCM);
+				if (rc < 0) {
+					pr_err("%s:open read write failed\n", __func__);
+					break;
+				}
+			}
+			if(audio->feedback == TUNNEL_MODE){
+				pr_debug("%s: starting in tunnel mode",__func__);
+				rc = q6asm_open_read(audio->ac,FORMAT_MPEG4_AAC);
+
+				if (rc < 0) {
+					pr_err("%s:open read failed\n", __func__);
+					break;
+				}
+			}
+		audio->stopped = 0;
 		}
 
 		pr_debug("%s:sbr_ps_flag = %d, sbr_flag = %d\n", __func__,
diff --git a/arch/arm/mach-msm/qdsp6v2/audio_amrwbplus.c b/arch/arm/mach-msm/qdsp6v2/audio_amrwbplus.c
index 902e06d..544bf9c 100644
--- a/arch/arm/mach-msm/qdsp6v2/audio_amrwbplus.c
+++ b/arch/arm/mach-msm/qdsp6v2/audio_amrwbplus.c
@@ -36,7 +36,7 @@
 	}
 }
 #else
-static void config_debug_fs(struct q6audio_aio *)
+static void config_debug_fs(struct q6audio_aio *audio)
 {
 }
 #endif
diff --git a/arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c b/arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c
deleted file mode 100644
index 8aacb56..0000000
--- a/arch/arm/mach-msm/qdsp6v2/audio_dev_ctl.c
+++ /dev/null
@@ -1,1731 +0,0 @@
-/* Copyright (c) 2010-2012, The Linux Foundation. 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.
- *
- */
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/miscdevice.h>
-#include <linux/msm_audio.h>
-#include <linux/slab.h>
-#include <linux/wait.h>
-#include <linux/sched.h>
-#include <linux/workqueue.h>
-#include <asm/uaccess.h>
-#include <asm/atomic.h>
-#include <mach/qdsp6v2/audio_dev_ctl.h>
-#include <mach/debug_mm.h>
-#include <mach/qdsp6v2/q6voice.h>
-#include <sound/apr_audio.h>
-#include <sound/q6adm.h>
-
-#ifndef MAX
-#define  MAX(x, y) (((x) > (y)) ? (x) : (y))
-#endif
-
-
-static DEFINE_MUTEX(session_lock);
-static struct workqueue_struct *msm_reset_device_work_queue;
-static void reset_device_work(struct work_struct *work);
-static DECLARE_WORK(msm_reset_device_work, reset_device_work);
-
-struct audio_dev_ctrl_state {
-	struct msm_snddev_info *devs[AUDIO_DEV_CTL_MAX_DEV];
-	u32 num_dev;
-	atomic_t opened;
-	struct msm_snddev_info *voice_rx_dev;
-	struct msm_snddev_info *voice_tx_dev;
-	wait_queue_head_t      wait;
-};
-
-static struct audio_dev_ctrl_state audio_dev_ctrl;
-struct event_listner event;
-
-struct session_freq {
-	int freq;
-	int evt;
-};
-
-struct audio_routing_info {
-	unsigned short mixer_mask[MAX_SESSIONS];
-	unsigned short audrec_mixer_mask[MAX_SESSIONS];
-	struct session_freq dec_freq[MAX_SESSIONS];
-	struct session_freq enc_freq[MAX_SESSIONS];
-	unsigned int copp_list[MAX_SESSIONS][AFE_MAX_PORTS];
-	int voice_tx_dev_id;
-	int voice_rx_dev_id;
-	int voice_tx_sample_rate;
-	int voice_rx_sample_rate;
-	signed int voice_tx_vol;
-	signed int voice_rx_vol;
-	int tx_mute;
-	int rx_mute;
-	int voice_state;
-	struct mutex copp_list_mutex;
-	struct mutex adm_mutex;
-};
-
-static struct audio_routing_info routing_info;
-
-struct audio_copp_topology {
-	struct mutex lock;
-	int session_cnt;
-	int session_id[MAX_SESSIONS];
-	int topolog_id[MAX_SESSIONS];
-};
-static struct audio_copp_topology adm_tx_topology_tbl;
-
-int msm_reset_all_device(void)
-{
-	int rc = 0;
-	int dev_id = 0;
-	struct msm_snddev_info *dev_info = NULL;
-
-	for (dev_id = 0; dev_id < audio_dev_ctrl.num_dev; dev_id++) {
-		dev_info = audio_dev_ctrl_find_dev(dev_id);
-		if (IS_ERR(dev_info)) {
-			pr_err("%s:pass invalid dev_id\n", __func__);
-			rc = PTR_ERR(dev_info);
-			return rc;
-		}
-		if (!dev_info->opened)
-			continue;
-		pr_debug("%s:Resetting device %d active on COPP %d"
-			"with  %lld as routing\n", __func__,
-				dev_id, dev_info->copp_id, dev_info->sessions);
-		broadcast_event(AUDDEV_EVT_REL_PENDING,
-					dev_id,
-					SESSION_IGNORE);
-		rc = dev_info->dev_ops.close(dev_info);
-		if (rc < 0) {
-			pr_err("%s:Snd device failed close!\n", __func__);
-			return rc;
-		} else {
-			dev_info->opened = 0;
-			broadcast_event(AUDDEV_EVT_DEV_RLS,
-				dev_id,
-				SESSION_IGNORE);
-
-			if (dev_info->copp_id == VOICE_PLAYBACK_TX)
-				voice_start_playback(0);
-		}
-		dev_info->sessions = 0;
-	}
-	msm_clear_all_session();
-	return 0;
-}
-EXPORT_SYMBOL(msm_reset_all_device);
-
-static void reset_device_work(struct work_struct *work)
-{
-	msm_reset_all_device();
-}
-
-int reset_device(void)
-{
-	queue_work(msm_reset_device_work_queue, &msm_reset_device_work);
-	return 0;
-}
-EXPORT_SYMBOL(reset_device);
-
-int msm_set_copp_id(int session_id, int copp_id)
-{
-	int rc = 0;
-	int index;
-
-	if (session_id < 1 || session_id > 8)
-		return -EINVAL;
-	if (afe_validate_port(copp_id) < 0)
-		return -EINVAL;
-
-	index = afe_get_port_index(copp_id);
-	if (index < 0 || index > AFE_MAX_PORTS)
-		return -EINVAL;
-	pr_debug("%s: session[%d] copp_id[%d] index[%d]\n", __func__,
-			session_id, copp_id, index);
-	mutex_lock(&routing_info.copp_list_mutex);
-	if (routing_info.copp_list[session_id][index] == COPP_IGNORE)
-		routing_info.copp_list[session_id][index] = copp_id;
-	mutex_unlock(&routing_info.copp_list_mutex);
-
-	return rc;
-}
-EXPORT_SYMBOL(msm_set_copp_id);
-
-int msm_clear_copp_id(int session_id, int copp_id)
-{
-	int rc = 0;
-	int index = afe_get_port_index(copp_id);
-
-	if (session_id < 1 || session_id > 8)
-		return -EINVAL;
-	pr_debug("%s: session[%d] copp_id[%d] index[%d]\n", __func__,
-			session_id, copp_id, index);
-	mutex_lock(&routing_info.copp_list_mutex);
-	if (routing_info.copp_list[session_id][index] == copp_id)
-		routing_info.copp_list[session_id][index] = COPP_IGNORE;
-#ifdef CONFIG_MSM8X60_RTAC
-	rtac_remove_adm_device(copp_id, session_id);
-#endif
-	mutex_unlock(&routing_info.copp_list_mutex);
-
-	return rc;
-}
-EXPORT_SYMBOL(msm_clear_copp_id);
-
-int msm_clear_session_id(int session_id)
-{
-	int rc = 0;
-	int i = 0;
-	if (session_id < 1 || session_id > 8)
-		return -EINVAL;
-	pr_debug("%s: session[%d]\n", __func__, session_id);
-	mutex_lock(&routing_info.adm_mutex);
-	mutex_lock(&routing_info.copp_list_mutex);
-	for (i = 0; i < AFE_MAX_PORTS; i++) {
-		if (routing_info.copp_list[session_id][i] != COPP_IGNORE) {
-			rc = adm_close(routing_info.copp_list[session_id][i]);
-			if (rc < 0) {
-				pr_err("%s: adm close fail port[%d] rc[%d]\n",
-					__func__,
-					routing_info.copp_list[session_id][i],
-					rc);
-				continue;
-			}
-#ifdef CONFIG_MSM8X60_RTAC
-			rtac_remove_adm_device(
-			routing_info.copp_list[session_id][i], session_id);
-#endif
-			routing_info.copp_list[session_id][i] = COPP_IGNORE;
-			rc = 0;
-		}
-	}
-	mutex_unlock(&routing_info.copp_list_mutex);
-	mutex_unlock(&routing_info.adm_mutex);
-
-	return rc;
-}
-EXPORT_SYMBOL(msm_clear_session_id);
-
-int msm_clear_all_session()
-{
-	int rc = 0;
-	int i = 0, j = 0;
-	pr_info("%s:\n", __func__);
-	mutex_lock(&routing_info.adm_mutex);
-	mutex_lock(&routing_info.copp_list_mutex);
-	for (j = 1; j < MAX_SESSIONS; j++) {
-		for (i = 0; i < AFE_MAX_PORTS; i++) {
-			if (routing_info.copp_list[j][i] != COPP_IGNORE) {
-				rc = adm_close(
-					routing_info.copp_list[j][i]);
-				if (rc < 0) {
-					pr_err("%s: adm close fail copp[%d]"
-					"session[%d] rc[%d]\n",
-					__func__,
-					routing_info.copp_list[j][i],
-					j, rc);
-					continue;
-				}
-				routing_info.copp_list[j][i] = COPP_IGNORE;
-				rc = 0;
-			}
-		}
-	}
-	mutex_unlock(&routing_info.copp_list_mutex);
-	mutex_unlock(&routing_info.adm_mutex);
-	return rc;
-}
-EXPORT_SYMBOL(msm_clear_all_session);
-
-int msm_get_voice_state(void)
-{
-	pr_debug("voice state %d\n", routing_info.voice_state);
-	return routing_info.voice_state;
-}
-EXPORT_SYMBOL(msm_get_voice_state);
-
-int msm_set_voice_mute(int dir, int mute, u32 session_id)
-{
-	pr_debug("dir %x mute %x\n", dir, mute);
-	if (dir == DIR_TX) {
-		routing_info.tx_mute = mute;
-		broadcast_event(AUDDEV_EVT_DEVICE_VOL_MUTE_CHG,
-			routing_info.voice_tx_dev_id, session_id);
-	} else
-		return -EPERM;
-	return 0;
-}
-EXPORT_SYMBOL(msm_set_voice_mute);
-
-int msm_set_voice_vol(int dir, s32 volume, u32 session_id)
-{
-	if (dir == DIR_TX) {
-		routing_info.voice_tx_vol = volume;
-		broadcast_event(AUDDEV_EVT_DEVICE_VOL_MUTE_CHG,
-					routing_info.voice_tx_dev_id,
-					session_id);
-	} else if (dir == DIR_RX) {
-		routing_info.voice_rx_vol = volume;
-		broadcast_event(AUDDEV_EVT_DEVICE_VOL_MUTE_CHG,
-					routing_info.voice_rx_dev_id,
-					session_id);
-	} else
-		return -EINVAL;
-	return 0;
-}
-EXPORT_SYMBOL(msm_set_voice_vol);
-
-void msm_snddev_register(struct msm_snddev_info *dev_info)
-{
-	mutex_lock(&session_lock);
-	if (audio_dev_ctrl.num_dev < AUDIO_DEV_CTL_MAX_DEV) {
-		audio_dev_ctrl.devs[audio_dev_ctrl.num_dev] = dev_info;
-		/* roughly 0 DB for digital gain
-		 * If default gain is not desirable, it is expected that
-		 * application sets desired gain before activating sound
-		 * device
-		 */
-		dev_info->dev_volume = 75;
-		dev_info->sessions = 0x0;
-		dev_info->usage_count = 0;
-		audio_dev_ctrl.num_dev++;
-	} else
-		pr_err("%s: device registry max out\n", __func__);
-	mutex_unlock(&session_lock);
-}
-EXPORT_SYMBOL(msm_snddev_register);
-
-int msm_snddev_devcount(void)
-{
-	return audio_dev_ctrl.num_dev;
-}
-EXPORT_SYMBOL(msm_snddev_devcount);
-
-int msm_snddev_query(int dev_id)
-{
-	if (dev_id <= audio_dev_ctrl.num_dev)
-			return 0;
-	return -ENODEV;
-}
-EXPORT_SYMBOL(msm_snddev_query);
-
-int msm_snddev_is_set(int popp_id, int copp_id)
-{
-	return routing_info.mixer_mask[popp_id] & (0x1 << copp_id);
-}
-EXPORT_SYMBOL(msm_snddev_is_set);
-
-unsigned short msm_snddev_route_enc(int enc_id)
-{
-	if (enc_id >= MAX_SESSIONS)
-		return -EINVAL;
-	return routing_info.audrec_mixer_mask[enc_id];
-}
-EXPORT_SYMBOL(msm_snddev_route_enc);
-
-unsigned short msm_snddev_route_dec(int popp_id)
-{
-	if (popp_id >= MAX_SESSIONS)
-		return -EINVAL;
-	return routing_info.mixer_mask[popp_id];
-}
-EXPORT_SYMBOL(msm_snddev_route_dec);
-
-/*To check one->many case*/
-int msm_check_multicopp_per_stream(int session_id,
-				struct route_payload *payload)
-{
-	int i = 0;
-	int flag = 0;
-	pr_debug("%s: session_id=%d\n", __func__, session_id);
-	mutex_lock(&routing_info.copp_list_mutex);
-	for (i = 0; i < AFE_MAX_PORTS; i++) {
-		if (routing_info.copp_list[session_id][i] == COPP_IGNORE)
-			continue;
-		else {
-			pr_debug("Device enabled\n");
-			payload->copp_ids[flag++] =
-				routing_info.copp_list[session_id][i];
-		}
-	}
-	mutex_unlock(&routing_info.copp_list_mutex);
-	if (flag > 1) {
-		pr_debug("Multiple copp per stream case num_copps=%d\n", flag);
-	} else {
-		pr_debug("Stream routed to single copp\n");
-	}
-	payload->num_copps = flag;
-	return flag;
-}
-
-int msm_snddev_set_dec(int popp_id, int copp_id, int set,
-					int rate, int mode)
-{
-	int rc = 0, i = 0, num_copps;
-	struct route_payload payload;
-
-	if ((popp_id >= MAX_SESSIONS) || (popp_id <= 0)) {
-		pr_err("%s: Invalid session id %d\n", __func__, popp_id);
-		return 0;
-	}
-
-	mutex_lock(&routing_info.adm_mutex);
-	if (set) {
-		rc = adm_open(copp_id, ADM_PATH_PLAYBACK, rate, mode,
-			DEFAULT_COPP_TOPOLOGY);
-		if (rc < 0) {
-			pr_err("%s: adm open fail rc[%d]\n", __func__, rc);
-			rc = -EINVAL;
-			mutex_unlock(&routing_info.adm_mutex);
-			return rc;
-		}
-		msm_set_copp_id(popp_id, copp_id);
-		pr_debug("%s:Session id=%d copp_id=%d\n",
-			__func__, popp_id, copp_id);
-		memset(payload.copp_ids, COPP_IGNORE,
-				(sizeof(unsigned int) * AFE_MAX_PORTS));
-		num_copps = msm_check_multicopp_per_stream(popp_id, &payload);
-		/* Multiple streams per copp is handled, one stream at a time */
-		rc = adm_matrix_map(popp_id, ADM_PATH_PLAYBACK, num_copps,
-					payload.copp_ids, copp_id);
-		if (rc < 0) {
-			pr_err("%s: matrix map failed rc[%d]\n",
-				__func__, rc);
-			adm_close(copp_id);
-			rc = -EINVAL;
-			mutex_unlock(&routing_info.adm_mutex);
-			return rc;
-		}
-#ifdef CONFIG_MSM8X60_RTAC
-		for (i = 0; i < num_copps; i++)
-			rtac_add_adm_device(payload.copp_ids[i], popp_id);
-#endif
-	} else {
-		for (i = 0; i < AFE_MAX_PORTS; i++) {
-			if (routing_info.copp_list[popp_id][i] == copp_id) {
-				rc = adm_close(copp_id);
-				if (rc < 0) {
-					pr_err("%s: adm close fail copp[%d]"
-						"rc[%d]\n",
-						__func__, copp_id, rc);
-					rc = -EINVAL;
-					mutex_unlock(&routing_info.adm_mutex);
-					return rc;
-				}
-				msm_clear_copp_id(popp_id, copp_id);
-				break;
-			}
-		}
-	}
-
-	if (copp_id == VOICE_PLAYBACK_TX) {
-		/* Signal uplink playback. */
-		rc = voice_start_playback(set);
-	}
-	mutex_unlock(&routing_info.adm_mutex);
-	return rc;
-}
-EXPORT_SYMBOL(msm_snddev_set_dec);
-
-
-static int check_tx_copp_topology(int session_id)
-{
-	int cnt;
-	int ret_val = -ENOENT;
-
-	cnt = adm_tx_topology_tbl.session_cnt;
-	if (cnt) {
-		do {
-			if (adm_tx_topology_tbl.session_id[cnt-1]
-				== session_id)
-				ret_val = cnt-1;
-		} while (--cnt);
-	}
-
-	return ret_val;
-}
-
-static int add_to_tx_topology_lists(int session_id, int topology)
-{
-	int idx = 0, tbl_idx;
-	int ret_val = -ENOSPC;
-
-	mutex_lock(&adm_tx_topology_tbl.lock);
-
-	tbl_idx = check_tx_copp_topology(session_id);
-	if (tbl_idx == -ENOENT) {
-		while (adm_tx_topology_tbl.session_id[idx++])
-			;
-		tbl_idx = idx-1;
-	}
-
-	if (tbl_idx < MAX_SESSIONS) {
-		adm_tx_topology_tbl.session_id[tbl_idx] = session_id;
-		adm_tx_topology_tbl.topolog_id[tbl_idx] = topology;
-		adm_tx_topology_tbl.session_cnt++;
-
-		ret_val = 0;
-	}
-	mutex_unlock(&adm_tx_topology_tbl.lock);
-	return ret_val;
-}
-
-static void remove_from_tx_topology_lists(int session_id)
-{
-	int tbl_idx;
-
-	mutex_lock(&adm_tx_topology_tbl.lock);
-	tbl_idx = check_tx_copp_topology(session_id);
-	if (tbl_idx != -ENOENT) {
-
-		adm_tx_topology_tbl.session_cnt--;
-		adm_tx_topology_tbl.session_id[tbl_idx] = 0;
-		adm_tx_topology_tbl.topolog_id[tbl_idx] = 0;
-	}
-	mutex_unlock(&adm_tx_topology_tbl.lock);
-}
-
-int auddev_cfg_tx_copp_topology(int session_id, int cfg)
-{
-	int ret = 0;
-
-	if (cfg == DEFAULT_COPP_TOPOLOGY)
-		remove_from_tx_topology_lists(session_id);
-	else {
-		switch (cfg) {
-		case VPM_TX_SM_ECNS_COPP_TOPOLOGY:
-		case VPM_TX_DM_FLUENCE_COPP_TOPOLOGY:
-			ret = add_to_tx_topology_lists(session_id, cfg);
-			break;
-
-		default:
-			ret = -ENODEV;
-			break;
-		}
-	}
-	return ret;
-}
-
-int msm_snddev_set_enc(int popp_id, int copp_id, int set,
-					int rate, int mode)
-{
-	int topology;
-	int tbl_idx;
-	int rc = 0, i = 0;
-	mutex_lock(&routing_info.adm_mutex);
-	if (set) {
-		mutex_lock(&adm_tx_topology_tbl.lock);
-		tbl_idx = check_tx_copp_topology(popp_id);
-		if (tbl_idx == -ENOENT)
-			topology = DEFAULT_COPP_TOPOLOGY;
-		else {
-			topology = adm_tx_topology_tbl.topolog_id[tbl_idx];
-			rate = 16000;
-		}
-		mutex_unlock(&adm_tx_topology_tbl.lock);
-		rc = adm_open(copp_id, ADM_PATH_LIVE_REC, rate, mode, topology);
-		if (rc < 0) {
-			pr_err("%s: adm open fail rc[%d]\n", __func__, rc);
-			rc = -EINVAL;
-			goto fail_cmd;
-		}
-
-		rc = adm_matrix_map(popp_id, ADM_PATH_LIVE_REC, 1,
-					(unsigned int *)&copp_id, copp_id);
-		if (rc < 0) {
-			pr_err("%s: matrix map failed rc[%d]\n", __func__, rc);
-			adm_close(copp_id);
-			rc = -EINVAL;
-			goto fail_cmd;
-		}
-		msm_set_copp_id(popp_id, copp_id);
-#ifdef CONFIG_MSM8X60_RTAC
-	rtac_add_adm_device(copp_id, popp_id);
-#endif
-
-	} else {
-		for (i = 0; i < AFE_MAX_PORTS; i++) {
-			if (routing_info.copp_list[popp_id][i] == copp_id) {
-				rc = adm_close(copp_id);
-				if (rc < 0) {
-					pr_err("%s: adm close fail copp[%d]"
-					"rc[%d]\n",
-							__func__, copp_id, rc);
-					rc = -EINVAL;
-					goto fail_cmd;
-				}
-				msm_clear_copp_id(popp_id, copp_id);
-				break;
-			}
-		}
-	}
-fail_cmd:
-	mutex_unlock(&routing_info.adm_mutex);
-	return rc;
-}
-EXPORT_SYMBOL(msm_snddev_set_enc);
-
-int msm_device_is_voice(int dev_id)
-{
-	if ((dev_id == routing_info.voice_rx_dev_id)
-		|| (dev_id == routing_info.voice_tx_dev_id))
-		return 0;
-	else
-		return -EINVAL;
-}
-EXPORT_SYMBOL(msm_device_is_voice);
-
-int msm_set_voc_route(struct msm_snddev_info *dev_info,
-			int stream_type, int dev_id)
-{
-	int rc = 0;
-	u64 session_mask = 0;
-
-	mutex_lock(&session_lock);
-	switch (stream_type) {
-	case AUDIO_ROUTE_STREAM_VOICE_RX:
-		if (audio_dev_ctrl.voice_rx_dev)
-			audio_dev_ctrl.voice_rx_dev->sessions &= ~0xFFFF;
-
-		if (!(dev_info->capability & SNDDEV_CAP_RX) |
-		    !(dev_info->capability & SNDDEV_CAP_VOICE)) {
-			rc = -EINVAL;
-			break;
-		}
-		audio_dev_ctrl.voice_rx_dev = dev_info;
-		if (audio_dev_ctrl.voice_rx_dev) {
-			session_mask =
-				((u64)0x1) << (MAX_BIT_PER_CLIENT * \
-				((int)AUDDEV_CLNT_VOC-1));
-			audio_dev_ctrl.voice_rx_dev->sessions |=
-				session_mask;
-		}
-		routing_info.voice_rx_dev_id = dev_id;
-		break;
-	case AUDIO_ROUTE_STREAM_VOICE_TX:
-		if (audio_dev_ctrl.voice_tx_dev)
-			audio_dev_ctrl.voice_tx_dev->sessions &= ~0xFFFF;
-
-		if (!(dev_info->capability & SNDDEV_CAP_TX) |
-		    !(dev_info->capability & SNDDEV_CAP_VOICE)) {
-			rc = -EINVAL;
-			break;
-		}
-
-		audio_dev_ctrl.voice_tx_dev = dev_info;
-		if (audio_dev_ctrl.voice_rx_dev) {
-			session_mask =
-				((u64)0x1) << (MAX_BIT_PER_CLIENT * \
-					((int)AUDDEV_CLNT_VOC-1));
-			audio_dev_ctrl.voice_tx_dev->sessions |=
-				session_mask;
-		}
-		routing_info.voice_tx_dev_id = dev_id;
-		break;
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&session_lock);
-	return rc;
-}
-EXPORT_SYMBOL(msm_set_voc_route);
-
-void msm_release_voc_thread(void)
-{
-	wake_up(&audio_dev_ctrl.wait);
-}
-EXPORT_SYMBOL(msm_release_voc_thread);
-
-int msm_snddev_get_enc_freq(session_id)
-{
-	return routing_info.enc_freq[session_id].freq;
-}
-EXPORT_SYMBOL(msm_snddev_get_enc_freq);
-
-int msm_get_voc_freq(int *tx_freq, int *rx_freq)
-{
-	*tx_freq = routing_info.voice_tx_sample_rate;
-	*rx_freq = routing_info.voice_rx_sample_rate;
-	return 0;
-}
-EXPORT_SYMBOL(msm_get_voc_freq);
-
-int msm_get_voc_route(u32 *rx_id, u32 *tx_id)
-{
-	int rc = 0;
-
-	if (!rx_id || !tx_id)
-		return -EINVAL;
-
-	mutex_lock(&session_lock);
-	if (!audio_dev_ctrl.voice_rx_dev || !audio_dev_ctrl.voice_tx_dev) {
-		rc = -ENODEV;
-		mutex_unlock(&session_lock);
-		return rc;
-	}
-
-	*rx_id = audio_dev_ctrl.voice_rx_dev->acdb_id;
-	*tx_id = audio_dev_ctrl.voice_tx_dev->acdb_id;
-
-	mutex_unlock(&session_lock);
-
-	return rc;
-}
-EXPORT_SYMBOL(msm_get_voc_route);
-
-struct msm_snddev_info *audio_dev_ctrl_find_dev(u32 dev_id)
-{
-	struct msm_snddev_info *info;
-
-	if ((audio_dev_ctrl.num_dev - 1) < dev_id) {
-		info = ERR_PTR(-ENODEV);
-		goto error;
-	}
-
-	info = audio_dev_ctrl.devs[dev_id];
-error:
-	return info;
-
-}
-EXPORT_SYMBOL(audio_dev_ctrl_find_dev);
-
-int snddev_voice_set_volume(int vol, int path)
-{
-	if (audio_dev_ctrl.voice_rx_dev
-		&& audio_dev_ctrl.voice_tx_dev) {
-		if (path)
-			audio_dev_ctrl.voice_tx_dev->dev_volume = vol;
-		else
-			audio_dev_ctrl.voice_rx_dev->dev_volume = vol;
-	} else
-		return -ENODEV;
-	return 0;
-}
-EXPORT_SYMBOL(snddev_voice_set_volume);
-
-static int audio_dev_ctrl_get_devices(struct audio_dev_ctrl_state *dev_ctrl,
-				      void __user *arg)
-{
-	int rc = 0;
-	u32 index;
-	struct msm_snd_device_list work_list;
-	struct msm_snd_device_info *work_tbl;
-
-	if (copy_from_user(&work_list, arg, sizeof(work_list))) {
-		rc = -EFAULT;
-		goto error;
-	}
-
-	if (work_list.num_dev > dev_ctrl->num_dev) {
-		rc = -EINVAL;
-		goto error;
-	}
-
-	work_tbl = kmalloc(work_list.num_dev *
-		sizeof(struct msm_snd_device_info), GFP_KERNEL);
-	if (!work_tbl) {
-		rc = -ENOMEM;
-		goto error;
-	}
-
-	for (index = 0; index < dev_ctrl->num_dev; index++) {
-		work_tbl[index].dev_id = index;
-		work_tbl[index].dev_cap = dev_ctrl->devs[index]->capability;
-		strlcpy(work_tbl[index].dev_name, dev_ctrl->devs[index]->name,
-		64);
-	}
-
-	if (copy_to_user((void *) (work_list.list), work_tbl,
-		 work_list.num_dev * sizeof(struct msm_snd_device_info)))
-		rc = -EFAULT;
-	kfree(work_tbl);
-error:
-	return rc;
-}
-
-
-int auddev_register_evt_listner(u32 evt_id, u32 clnt_type, u32 clnt_id,
-		void (*listner)(u32 evt_id,
-			union auddev_evt_data *evt_payload,
-			void *private_data),
-		void *private_data)
-{
-	int rc;
-	struct msm_snd_evt_listner *callback = NULL;
-	struct msm_snd_evt_listner *new_cb;
-
-	new_cb = kzalloc(sizeof(struct msm_snd_evt_listner), GFP_KERNEL);
-	if (!new_cb) {
-		pr_err("No memory to add new listener node\n");
-		return -ENOMEM;
-	}
-
-	mutex_lock(&session_lock);
-	new_cb->cb_next = NULL;
-	new_cb->auddev_evt_listener = listner;
-	new_cb->evt_id = evt_id;
-	new_cb->clnt_type = clnt_type;
-	new_cb->clnt_id = clnt_id;
-	new_cb->private_data = private_data;
-	if (event.cb == NULL) {
-		event.cb = new_cb;
-		new_cb->cb_prev = NULL;
-	} else {
-		callback = event.cb;
-		for (; ;) {
-			if (callback->cb_next == NULL)
-				break;
-			else {
-				callback = callback->cb_next;
-				continue;
-			}
-		}
-		callback->cb_next = new_cb;
-		new_cb->cb_prev = callback;
-	}
-	event.num_listner++;
-	mutex_unlock(&session_lock);
-	rc = 0;
-	return rc;
-}
-EXPORT_SYMBOL(auddev_register_evt_listner);
-
-int auddev_unregister_evt_listner(u32 clnt_type, u32 clnt_id)
-{
-	struct msm_snd_evt_listner *callback = event.cb;
-	struct msm_snddev_info *info;
-	u64 session_mask = 0;
-	int i = 0;
-
-	mutex_lock(&session_lock);
-	while (callback != NULL) {
-		if ((callback->clnt_type == clnt_type)
-			&& (callback->clnt_id == clnt_id))
-			break;
-		 callback = callback->cb_next;
-	}
-	if (callback == NULL) {
-		mutex_unlock(&session_lock);
-		return -EINVAL;
-	}
-
-	if ((callback->cb_next == NULL) && (callback->cb_prev == NULL))
-		event.cb = NULL;
-	else if (callback->cb_next == NULL)
-		callback->cb_prev->cb_next = NULL;
-	else if (callback->cb_prev == NULL) {
-		callback->cb_next->cb_prev = NULL;
-		event.cb = callback->cb_next;
-	} else {
-		callback->cb_prev->cb_next = callback->cb_next;
-		callback->cb_next->cb_prev = callback->cb_prev;
-	}
-	kfree(callback);
-
-	session_mask = (((u64)0x1) << clnt_id) << (MAX_BIT_PER_CLIENT * \
-				((int)clnt_type-1));
-	for (i = 0; i < audio_dev_ctrl.num_dev; i++) {
-		info = audio_dev_ctrl.devs[i];
-		info->sessions &= ~session_mask;
-	}
-	mutex_unlock(&session_lock);
-	return 0;
-}
-EXPORT_SYMBOL(auddev_unregister_evt_listner);
-
-int msm_snddev_withdraw_freq(u32 session_id, u32 capability, u32 clnt_type)
-{
-	int i = 0;
-	struct msm_snddev_info *info;
-	u64 session_mask = 0;
-
-	if ((clnt_type == AUDDEV_CLNT_VOC) && (session_id != 0))
-		return -EINVAL;
-	if ((clnt_type == AUDDEV_CLNT_DEC)
-			&& (session_id >= MAX_SESSIONS))
-		return -EINVAL;
-	if ((clnt_type == AUDDEV_CLNT_ENC)
-			&& (session_id >= MAX_SESSIONS))
-		return -EINVAL;
-
-	session_mask = (((u64)0x1) << session_id) << (MAX_BIT_PER_CLIENT * \
-				((int)clnt_type-1));
-
-	for (i = 0; i < audio_dev_ctrl.num_dev; i++) {
-		info = audio_dev_ctrl.devs[i];
-		if ((info->sessions & session_mask)
-			&& (info->capability & capability)) {
-			if (!(info->sessions & ~(session_mask)))
-				info->set_sample_rate = 0;
-		}
-	}
-	if (clnt_type == AUDDEV_CLNT_DEC)
-		routing_info.dec_freq[session_id].freq
-					= 0;
-	else if (clnt_type == AUDDEV_CLNT_ENC)
-		routing_info.enc_freq[session_id].freq
-					= 0;
-	else if (capability == SNDDEV_CAP_TX)
-		routing_info.voice_tx_sample_rate = 0;
-	else
-		routing_info.voice_rx_sample_rate = 48000;
-	return 0;
-}
-
-int msm_snddev_request_freq(int *freq, u32 session_id,
-			u32 capability, u32 clnt_type)
-{
-	int i = 0;
-	int rc = 0;
-	struct msm_snddev_info *info;
-	u32 set_freq;
-	u64 session_mask = 0;
-	u64 clnt_type_mask = 0;
-
-	pr_debug(": clnt_type 0x%08x\n", clnt_type);
-
-	if ((clnt_type == AUDDEV_CLNT_VOC) && (session_id != 0))
-		return -EINVAL;
-	if ((clnt_type == AUDDEV_CLNT_DEC)
-			&& (session_id >= MAX_SESSIONS))
-		return -EINVAL;
-	if ((clnt_type == AUDDEV_CLNT_ENC)
-			&& (session_id >= MAX_SESSIONS))
-		return -EINVAL;
-	session_mask = (((u64)0x1) << session_id) << (MAX_BIT_PER_CLIENT * \
-				((int)clnt_type-1));
-	clnt_type_mask = (0xFFFF << (MAX_BIT_PER_CLIENT * (clnt_type-1)));
-	if (!(*freq == 8000) && !(*freq == 11025) &&
-		!(*freq == 12000) && !(*freq == 16000) &&
-		!(*freq == 22050) && !(*freq == 24000) &&
-		!(*freq == 32000) && !(*freq == 44100) &&
-		!(*freq == 48000))
-		return -EINVAL;
-
-	for (i = 0; i < audio_dev_ctrl.num_dev; i++) {
-		info = audio_dev_ctrl.devs[i];
-		if ((info->sessions & session_mask)
-			&& (info->capability & capability)) {
-			rc = 0;
-			if ((info->sessions & ~clnt_type_mask)
-				&& ((*freq != 8000) && (*freq != 16000)
-					&& (*freq != 48000))) {
-				if (clnt_type == AUDDEV_CLNT_ENC) {
-					routing_info.enc_freq[session_id].freq
-							= 0;
-					return -EPERM;
-				} else if (clnt_type == AUDDEV_CLNT_DEC) {
-					routing_info.dec_freq[session_id].freq
-							= 0;
-					return -EPERM;
-				}
-			}
-			if (*freq == info->set_sample_rate) {
-				rc = info->set_sample_rate;
-				continue;
-			}
-			set_freq = MAX(*freq, info->set_sample_rate);
-
-
-			if (clnt_type == AUDDEV_CLNT_DEC) {
-				routing_info.dec_freq[session_id].evt = 1;
-				routing_info.dec_freq[session_id].freq
-						= set_freq;
-			} else if (clnt_type == AUDDEV_CLNT_ENC) {
-				routing_info.enc_freq[session_id].evt = 1;
-				routing_info.enc_freq[session_id].freq
-						= set_freq;
-			} else if (capability == SNDDEV_CAP_TX)
-				routing_info.voice_tx_sample_rate = set_freq;
-
-			rc = set_freq;
-			info->set_sample_rate = set_freq;
-			*freq = info->set_sample_rate;
-
-			if (info->opened) {
-				broadcast_event(AUDDEV_EVT_FREQ_CHG, i,
-							SESSION_IGNORE);
-				set_freq = info->dev_ops.set_freq(info,
-								set_freq);
-				broadcast_event(AUDDEV_EVT_DEV_RDY, i,
-							SESSION_IGNORE);
-			}
-		}
-		pr_debug("info->set_sample_rate = %d\n", info->set_sample_rate);
-		pr_debug("routing_info.enc_freq.freq = %d\n",
-					routing_info.enc_freq[session_id].freq);
-	}
-	return rc;
-}
-EXPORT_SYMBOL(msm_snddev_request_freq);
-
-int msm_snddev_enable_sidetone(u32 dev_id, u32 enable, uint16_t gain)
-{
-	int rc;
-	struct msm_snddev_info *dev_info;
-
-	pr_debug("dev_id %d enable %d\n", dev_id, enable);
-
-	dev_info = audio_dev_ctrl_find_dev(dev_id);
-
-	if (IS_ERR(dev_info)) {
-		pr_err("bad dev_id %d\n", dev_id);
-		rc = -EINVAL;
-	} else if (!dev_info->dev_ops.enable_sidetone) {
-		pr_debug("dev %d no sidetone support\n", dev_id);
-		rc = -EPERM;
-	} else
-		rc = dev_info->dev_ops.enable_sidetone(dev_info, enable, gain);
-
-	return rc;
-}
-EXPORT_SYMBOL(msm_snddev_enable_sidetone);
-
-int msm_enable_incall_recording(int popp_id, int rec_mode, int rate,
-				int channel_mode)
-{
-	int rc = 0;
-	unsigned int port_id[2];
-	port_id[0] = VOICE_RECORD_TX;
-	port_id[1] = VOICE_RECORD_RX;
-
-	pr_debug("%s: popp_id %d, rec_mode %d, rate %d, channel_mode %d\n",
-		 __func__, popp_id, rec_mode, rate, channel_mode);
-
-	mutex_lock(&routing_info.adm_mutex);
-
-	if (rec_mode == VOC_REC_UPLINK) {
-		rc = afe_start_pseudo_port(port_id[0]);
-		if (rc < 0) {
-			pr_err("%s: Error %d in Tx pseudo port start\n",
-			       __func__, rc);
-
-			goto fail_cmd;
-		}
-
-		rc = adm_open(port_id[0], ADM_PATH_LIVE_REC, rate, channel_mode,
-				DEFAULT_COPP_TOPOLOGY);
-		if (rc < 0) {
-			pr_err("%s: Error %d in ADM open %d\n",
-			       __func__, rc, port_id[0]);
-
-			goto fail_cmd;
-		}
-
-		rc = adm_matrix_map(popp_id, ADM_PATH_LIVE_REC, 1,
-				&port_id[0], port_id[0]);
-		if (rc < 0) {
-			pr_err("%s: Error %d in ADM matrix map %d\n",
-			       __func__, rc, port_id[0]);
-
-			goto fail_cmd;
-		}
-
-		msm_set_copp_id(popp_id, port_id[0]);
-
-	} else if (rec_mode == VOC_REC_DOWNLINK) {
-		rc = afe_start_pseudo_port(port_id[1]);
-		if (rc < 0) {
-			pr_err("%s: Error %d in Rx pseudo port start\n",
-			       __func__, rc);
-
-			goto fail_cmd;
-		}
-
-		rc = adm_open(port_id[1], ADM_PATH_LIVE_REC, rate, channel_mode,
-				DEFAULT_COPP_TOPOLOGY);
-		if (rc < 0) {
-			pr_err("%s: Error %d in ADM open %d\n",
-			       __func__, rc, port_id[1]);
-
-			goto fail_cmd;
-		}
-
-		rc = adm_matrix_map(popp_id, ADM_PATH_LIVE_REC, 1,
-				&port_id[1], port_id[1]);
-		if (rc < 0) {
-			pr_err("%s: Error %d in ADM matrix map %d\n",
-			       __func__, rc, port_id[1]);
-
-			goto fail_cmd;
-		}
-
-		msm_set_copp_id(popp_id, port_id[1]);
-
-	} else if (rec_mode == VOC_REC_BOTH) {
-		rc = afe_start_pseudo_port(port_id[0]);
-		if (rc < 0) {
-			pr_err("%s: Error %d in Tx pseudo port start\n",
-			       __func__, rc);
-
-			goto fail_cmd;
-		}
-
-		rc = adm_open(port_id[0], ADM_PATH_LIVE_REC, rate, channel_mode,
-				DEFAULT_COPP_TOPOLOGY);
-		if (rc < 0) {
-			pr_err("%s: Error %d in ADM open %d\n",
-			       __func__, rc, port_id[0]);
-
-			goto fail_cmd;
-		}
-
-		msm_set_copp_id(popp_id, port_id[0]);
-
-		rc = afe_start_pseudo_port(port_id[1]);
-		if (rc < 0) {
-			pr_err("%s: Error %d in Rx pseudo port start\n",
-			       __func__, rc);
-
-			goto fail_cmd;
-		}
-
-		rc = adm_open(port_id[1], ADM_PATH_LIVE_REC, rate, channel_mode,
-				DEFAULT_COPP_TOPOLOGY);
-		if (rc < 0) {
-			pr_err("%s: Error %d in ADM open %d\n",
-			       __func__, rc, port_id[0]);
-
-			goto fail_cmd;
-		}
-
-		rc = adm_matrix_map(popp_id, ADM_PATH_LIVE_REC, 2,
-				&port_id[0], port_id[1]);
-		if (rc < 0) {
-			pr_err("%s: Error %d in ADM matrix map\n",
-			       __func__, rc);
-
-			goto fail_cmd;
-		}
-
-		msm_set_copp_id(popp_id, port_id[1]);
-	} else {
-		pr_err("%s Unknown rec_mode %d\n", __func__, rec_mode);
-
-		goto fail_cmd;
-	}
-
-	rc = voice_start_record(rec_mode, 1);
-
-fail_cmd:
-	mutex_unlock(&routing_info.adm_mutex);
-	return rc;
-}
-
-int msm_disable_incall_recording(uint32_t popp_id, uint32_t rec_mode)
-{
-	int rc = 0;
-	uint32_t port_id[2];
-	port_id[0] = VOICE_RECORD_TX;
-	port_id[1] = VOICE_RECORD_RX;
-
-	pr_debug("%s: popp_id %d, rec_mode %d\n", __func__, popp_id, rec_mode);
-
-	mutex_lock(&routing_info.adm_mutex);
-
-	rc = voice_start_record(rec_mode, 0);
-	if (rc < 0) {
-		pr_err("%s: Error %d stopping record\n", __func__, rc);
-
-		goto fail_cmd;
-	}
-
-	if (rec_mode == VOC_REC_UPLINK) {
-		rc = adm_close(port_id[0]);
-		if (rc < 0) {
-			pr_err("%s: Error %d in ADM close %d\n",
-			       __func__, rc, port_id[0]);
-
-			goto fail_cmd;
-		}
-
-		msm_clear_copp_id(popp_id, port_id[0]);
-
-		rc = afe_stop_pseudo_port(port_id[0]);
-		if (rc < 0) {
-			pr_err("%s: Error %d in Tx pseudo port stop\n",
-			       __func__, rc);
-			goto fail_cmd;
-		}
-
-	} else if (rec_mode == VOC_REC_DOWNLINK) {
-		rc = adm_close(port_id[1]);
-		if (rc < 0) {
-			pr_err("%s: Error %d in ADM close %d\n",
-			       __func__, rc, port_id[1]);
-
-			goto fail_cmd;
-		}
-
-		msm_clear_copp_id(popp_id, port_id[1]);
-
-		rc = afe_stop_pseudo_port(port_id[1]);
-		if (rc < 0) {
-			pr_err("%s: Error %d in Rx pseudo port stop\n",
-			       __func__, rc);
-			goto fail_cmd;
-		}
-	} else if (rec_mode == VOC_REC_BOTH) {
-		rc = adm_close(port_id[0]);
-		if (rc < 0) {
-			pr_err("%s: Error %d in ADM close %d\n",
-			       __func__, rc, port_id[0]);
-
-			goto fail_cmd;
-		}
-
-		msm_clear_copp_id(popp_id, port_id[0]);
-
-		rc = afe_stop_pseudo_port(port_id[0]);
-		if (rc < 0) {
-			pr_err("%s: Error %d in Tx pseudo port stop\n",
-			       __func__, rc);
-			goto fail_cmd;
-		}
-
-		rc = adm_close(port_id[1]);
-		if (rc < 0) {
-			pr_err("%s: Error %d in ADM close %d\n",
-			       __func__, rc, port_id[1]);
-
-			goto fail_cmd;
-		}
-
-		msm_clear_copp_id(popp_id, port_id[1]);
-
-		rc = afe_stop_pseudo_port(port_id[1]);
-		if (rc < 0) {
-			pr_err("%s: Error %d in Rx pseudo port stop\n",
-			       __func__, rc);
-			goto fail_cmd;
-		}
-	} else {
-		pr_err("%s Unknown rec_mode %d\n", __func__, rec_mode);
-
-		goto fail_cmd;
-	}
-
-fail_cmd:
-	mutex_unlock(&routing_info.adm_mutex);
-	return rc;
-}
-
-static long audio_dev_ctrl_ioctl(struct file *file,
-	unsigned int cmd, unsigned long arg)
-{
-	int rc = 0;
-	struct audio_dev_ctrl_state *dev_ctrl = file->private_data;
-
-	mutex_lock(&session_lock);
-	switch (cmd) {
-	case AUDIO_GET_NUM_SND_DEVICE:
-		rc = put_user(dev_ctrl->num_dev, (uint32_t __user *) arg);
-		break;
-	case AUDIO_GET_SND_DEVICES:
-		rc = audio_dev_ctrl_get_devices(dev_ctrl, (void __user *) arg);
-		break;
-	case AUDIO_ENABLE_SND_DEVICE: {
-		struct msm_snddev_info *dev_info;
-		u32 dev_id;
-
-		if (get_user(dev_id, (u32 __user *) arg)) {
-			rc = -EFAULT;
-			break;
-		}
-		dev_info = audio_dev_ctrl_find_dev(dev_id);
-		if (IS_ERR(dev_info))
-			rc = PTR_ERR(dev_info);
-		else {
-			rc = dev_info->dev_ops.open(dev_info);
-			if (!rc)
-				dev_info->opened = 1;
-			wake_up(&audio_dev_ctrl.wait);
-		}
-		break;
-
-	}
-
-	case AUDIO_DISABLE_SND_DEVICE: {
-		struct msm_snddev_info *dev_info;
-		u32 dev_id;
-
-		if (get_user(dev_id, (u32 __user *) arg)) {
-			rc = -EFAULT;
-			break;
-		}
-		dev_info = audio_dev_ctrl_find_dev(dev_id);
-		if (IS_ERR(dev_info))
-			rc = PTR_ERR(dev_info);
-		else {
-			rc = dev_info->dev_ops.close(dev_info);
-			dev_info->opened = 0;
-		}
-		break;
-	}
-
-	case AUDIO_ROUTE_STREAM: {
-		struct msm_audio_route_config route_cfg;
-		struct msm_snddev_info *dev_info;
-
-		if (copy_from_user(&route_cfg, (void __user *) arg,
-			sizeof(struct msm_audio_route_config))) {
-			rc = -EFAULT;
-			break;
-		}
-		pr_debug("%s: route cfg %d %d type\n", __func__,
-		route_cfg.dev_id, route_cfg.stream_type);
-		dev_info = audio_dev_ctrl_find_dev(route_cfg.dev_id);
-		if (IS_ERR(dev_info)) {
-			pr_err("%s: pass invalid dev_id\n", __func__);
-			rc = PTR_ERR(dev_info);
-			break;
-		}
-
-		switch (route_cfg.stream_type) {
-
-		case AUDIO_ROUTE_STREAM_VOICE_RX:
-			if (!(dev_info->capability & SNDDEV_CAP_RX) |
-			    !(dev_info->capability & SNDDEV_CAP_VOICE)) {
-				rc = -EINVAL;
-				break;
-			}
-			dev_ctrl->voice_rx_dev = dev_info;
-			break;
-		case AUDIO_ROUTE_STREAM_VOICE_TX:
-			if (!(dev_info->capability & SNDDEV_CAP_TX) |
-			    !(dev_info->capability & SNDDEV_CAP_VOICE)) {
-				rc = -EINVAL;
-				break;
-			}
-			dev_ctrl->voice_tx_dev = dev_info;
-			break;
-		}
-		break;
-	}
-
-	default:
-		rc = -EINVAL;
-	}
-	mutex_unlock(&session_lock);
-	return rc;
-}
-
-static int audio_dev_ctrl_open(struct inode *inode, struct file *file)
-{
-	pr_debug("open audio_dev_ctrl\n");
-	atomic_inc(&audio_dev_ctrl.opened);
-	file->private_data = &audio_dev_ctrl;
-	return 0;
-}
-
-static int audio_dev_ctrl_release(struct inode *inode, struct file *file)
-{
-	pr_debug("release audio_dev_ctrl\n");
-	atomic_dec(&audio_dev_ctrl.opened);
-	return 0;
-}
-
-static const struct file_operations audio_dev_ctrl_fops = {
-	.owner = THIS_MODULE,
-	.open = audio_dev_ctrl_open,
-	.release = audio_dev_ctrl_release,
-	.unlocked_ioctl = audio_dev_ctrl_ioctl,
-};
-
-
-struct miscdevice audio_dev_ctrl_misc = {
-	.minor	= MISC_DYNAMIC_MINOR,
-	.name	= "msm_audio_dev_ctrl",
-	.fops	= &audio_dev_ctrl_fops,
-};
-
-/* session id is 64 bit routing mask per device
- * 0-15 for voice clients
- * 16-31 for Decoder clients
- * 32-47 for Encoder clients
- * 48-63 Do not care
- */
-void broadcast_event(u32 evt_id, u32 dev_id, u64 session_id)
-{
-	int clnt_id = 0, i;
-	union auddev_evt_data *evt_payload;
-	struct msm_snd_evt_listner *callback;
-	struct msm_snddev_info *dev_info = NULL;
-	u64 session_mask = 0;
-	static int pending_sent;
-
-	pr_debug(": evt_id = %d\n", evt_id);
-
-	if ((evt_id != AUDDEV_EVT_START_VOICE)
-		&& (evt_id != AUDDEV_EVT_END_VOICE)
-		&& (evt_id != AUDDEV_EVT_STREAM_VOL_CHG)
-		&& (evt_id != AUDDEV_EVT_VOICE_STATE_CHG)) {
-		dev_info = audio_dev_ctrl_find_dev(dev_id);
-		if (IS_ERR(dev_info)) {
-			pr_err("%s: pass invalid dev_id(%d)\n",
-					 __func__, dev_id);
-			return;
-		}
-	}
-
-	if (event.cb != NULL)
-		callback = event.cb;
-	else
-		return;
-	mutex_lock(&session_lock);
-
-	if (evt_id == AUDDEV_EVT_VOICE_STATE_CHG)
-		routing_info.voice_state = dev_id;
-
-	evt_payload = kzalloc(sizeof(union auddev_evt_data),
-			GFP_KERNEL);
-
-	if (evt_payload == NULL) {
-		pr_err("broadcast_event: cannot allocate memory\n");
-		mutex_unlock(&session_lock);
-		return;
-	}
-	for (; ;) {
-		if (!(evt_id & callback->evt_id)) {
-			if (callback->cb_next == NULL)
-				break;
-			else {
-				callback = callback->cb_next;
-				continue;
-			}
-		}
-		clnt_id = callback->clnt_id;
-		memset(evt_payload, 0, sizeof(union auddev_evt_data));
-
-		if ((evt_id == AUDDEV_EVT_START_VOICE)
-			|| (evt_id == AUDDEV_EVT_END_VOICE)
-			|| evt_id == AUDDEV_EVT_DEVICE_VOL_MUTE_CHG)
-			goto skip_check;
-		if (callback->clnt_type == AUDDEV_CLNT_AUDIOCAL)
-			goto aud_cal;
-
-		session_mask = (((u64)0x1) << clnt_id)
-				<< (MAX_BIT_PER_CLIENT * \
-				((int)callback->clnt_type-1));
-
-		if ((evt_id == AUDDEV_EVT_STREAM_VOL_CHG) || \
-			(evt_id == AUDDEV_EVT_VOICE_STATE_CHG)) {
-			pr_debug("AUDDEV_EVT_STREAM_VOL_CHG or\
-				AUDDEV_EVT_VOICE_STATE_CHG\n");
-			goto volume_strm;
-		}
-
-		pr_debug("dev_info->sessions = %llu\n", dev_info->sessions);
-
-		if ((!session_id && !(dev_info->sessions & session_mask)) ||
-			(session_id && ((dev_info->sessions & session_mask) !=
-						session_id))) {
-			if (callback->cb_next == NULL)
-				break;
-			else {
-				callback = callback->cb_next;
-				continue;
-			}
-		}
-		if (evt_id == AUDDEV_EVT_DEV_CHG_VOICE)
-			goto voc_events;
-
-volume_strm:
-		if (callback->clnt_type == AUDDEV_CLNT_DEC) {
-			pr_debug("AUDDEV_CLNT_DEC\n");
-			if (evt_id == AUDDEV_EVT_STREAM_VOL_CHG) {
-				pr_debug("clnt_id = %d, session_id = %llu\n",
-					clnt_id, session_id);
-				if (session_mask != session_id)
-					goto sent_dec;
-				else
-					evt_payload->session_vol =
-						msm_vol_ctl.volume;
-			} else if (evt_id == AUDDEV_EVT_FREQ_CHG) {
-				if (routing_info.dec_freq[clnt_id].evt) {
-					routing_info.dec_freq[clnt_id].evt
-							= 0;
-					goto sent_dec;
-				} else if (routing_info.dec_freq[clnt_id].freq
-					== dev_info->set_sample_rate)
-					goto sent_dec;
-				else {
-					evt_payload->freq_info.sample_rate
-						= dev_info->set_sample_rate;
-					evt_payload->freq_info.dev_type
-						= dev_info->capability;
-					evt_payload->freq_info.acdb_dev_id
-						= dev_info->acdb_id;
-				}
-			} else if (evt_id == AUDDEV_EVT_VOICE_STATE_CHG)
-				evt_payload->voice_state =
-					routing_info.voice_state;
-			else
-				evt_payload->routing_id = dev_info->copp_id;
-			callback->auddev_evt_listener(
-					evt_id,
-					evt_payload,
-					callback->private_data);
-sent_dec:
-			if ((evt_id != AUDDEV_EVT_STREAM_VOL_CHG) &&
-				(evt_id != AUDDEV_EVT_VOICE_STATE_CHG))
-				routing_info.dec_freq[clnt_id].freq
-						= dev_info->set_sample_rate;
-
-			if (callback->cb_next == NULL)
-				break;
-			else {
-				callback = callback->cb_next;
-				continue;
-			}
-		}
-		if (callback->clnt_type == AUDDEV_CLNT_ENC) {
-			pr_debug("AUDDEV_CLNT_ENC\n");
-			if (evt_id == AUDDEV_EVT_FREQ_CHG) {
-				if (routing_info.enc_freq[clnt_id].evt) {
-					routing_info.enc_freq[clnt_id].evt
-							= 0;
-					goto sent_enc;
-				 } else {
-					evt_payload->freq_info.sample_rate
-						= dev_info->set_sample_rate;
-					evt_payload->freq_info.dev_type
-						= dev_info->capability;
-					evt_payload->freq_info.acdb_dev_id
-						= dev_info->acdb_id;
-				}
-			} else if (evt_id == AUDDEV_EVT_VOICE_STATE_CHG)
-				evt_payload->voice_state =
-					routing_info.voice_state;
-			else
-				evt_payload->routing_id = dev_info->copp_id;
-			callback->auddev_evt_listener(
-					evt_id,
-					evt_payload,
-					callback->private_data);
-sent_enc:
-			if (callback->cb_next == NULL)
-					break;
-			else {
-				callback = callback->cb_next;
-				continue;
-			}
-		}
-aud_cal:
-		if (callback->clnt_type == AUDDEV_CLNT_AUDIOCAL) {
-			pr_debug("AUDDEV_CLNT_AUDIOCAL\n");
-			if (evt_id == AUDDEV_EVT_VOICE_STATE_CHG)
-				evt_payload->voice_state =
-					routing_info.voice_state;
-			else if (!dev_info->sessions)
-				goto sent_aud_cal;
-			else {
-				evt_payload->audcal_info.dev_id =
-						dev_info->copp_id;
-				evt_payload->audcal_info.acdb_id =
-						dev_info->acdb_id;
-				evt_payload->audcal_info.dev_type =
-					(dev_info->capability & SNDDEV_CAP_TX) ?
-					SNDDEV_CAP_TX : SNDDEV_CAP_RX;
-				evt_payload->audcal_info.sample_rate =
-					dev_info->set_sample_rate ?
-					dev_info->set_sample_rate :
-					dev_info->sample_rate;
-			}
-			callback->auddev_evt_listener(
-				evt_id,
-				evt_payload,
-				callback->private_data);
-
-sent_aud_cal:
-			if (callback->cb_next == NULL)
-				break;
-			else {
-				callback = callback->cb_next;
-				continue;
-			}
-		}
-skip_check:
-voc_events:
-		if (callback->clnt_type == AUDDEV_CLNT_VOC) {
-			pr_debug("AUDDEV_CLNT_VOC\n");
-			if (evt_id == AUDDEV_EVT_DEV_RLS) {
-				if (!pending_sent)
-					goto sent_voc;
-				else
-					pending_sent = 0;
-			}
-			if (evt_id == AUDDEV_EVT_REL_PENDING)
-				pending_sent = 1;
-
-			if (evt_id == AUDDEV_EVT_DEVICE_VOL_MUTE_CHG) {
-				evt_payload->voc_vm_info.voice_session_id =
-								session_id;
-
-				if (dev_info->capability & SNDDEV_CAP_TX) {
-					evt_payload->voc_vm_info.dev_type =
-						SNDDEV_CAP_TX;
-					evt_payload->voc_vm_info.acdb_dev_id =
-						dev_info->acdb_id;
-					evt_payload->
-					voc_vm_info.dev_vm_val.mute =
-						routing_info.tx_mute;
-				} else {
-					evt_payload->voc_vm_info.dev_type =
-						SNDDEV_CAP_RX;
-					evt_payload->voc_vm_info.acdb_dev_id =
-						dev_info->acdb_id;
-					evt_payload->
-					voc_vm_info.dev_vm_val.vol =
-						routing_info.voice_rx_vol;
-				}
-			} else if ((evt_id == AUDDEV_EVT_START_VOICE)
-					|| (evt_id == AUDDEV_EVT_END_VOICE)) {
-				memset(evt_payload, 0,
-					sizeof(union auddev_evt_data));
-
-				evt_payload->voice_session_id = session_id;
-			} else if (evt_id == AUDDEV_EVT_FREQ_CHG) {
-				if (routing_info.voice_tx_sample_rate
-						!= dev_info->set_sample_rate) {
-					routing_info.voice_tx_sample_rate
-						= dev_info->set_sample_rate;
-					evt_payload->freq_info.sample_rate
-						= dev_info->set_sample_rate;
-					evt_payload->freq_info.dev_type
-						= dev_info->capability;
-					evt_payload->freq_info.acdb_dev_id
-						= dev_info->acdb_id;
-				} else
-					goto sent_voc;
-			} else if (evt_id == AUDDEV_EVT_VOICE_STATE_CHG)
-				evt_payload->voice_state =
-						routing_info.voice_state;
-			else {
-				evt_payload->voc_devinfo.dev_type =
-					(dev_info->capability & SNDDEV_CAP_TX) ?
-					SNDDEV_CAP_TX : SNDDEV_CAP_RX;
-				evt_payload->voc_devinfo.acdb_dev_id =
-					dev_info->acdb_id;
-				evt_payload->voc_devinfo.dev_port_id =
-					dev_info->copp_id;
-				evt_payload->voc_devinfo.dev_sample =
-					dev_info->set_sample_rate ?
-					dev_info->set_sample_rate :
-					dev_info->sample_rate;
-				evt_payload->voc_devinfo.dev_id = dev_id;
-				if (dev_info->capability & SNDDEV_CAP_RX) {
-					for (i = 0; i < VOC_RX_VOL_ARRAY_NUM;
-						i++) {
-						evt_payload->
-						voc_devinfo.max_rx_vol[i] =
-						dev_info->max_voc_rx_vol[i];
-						evt_payload
-						->voc_devinfo.min_rx_vol[i] =
-						dev_info->min_voc_rx_vol[i];
-					}
-				}
-			}
-			callback->auddev_evt_listener(
-				evt_id,
-				evt_payload,
-				callback->private_data);
-			if (evt_id == AUDDEV_EVT_DEV_RLS)
-				dev_info->sessions &= ~(0xFFFF);
-sent_voc:
-			if (callback->cb_next == NULL)
-				break;
-			else {
-				callback = callback->cb_next;
-				continue;
-			}
-		}
-	}
-	kfree(evt_payload);
-	mutex_unlock(&session_lock);
-}
-EXPORT_SYMBOL(broadcast_event);
-
-
-void mixer_post_event(u32 evt_id, u32 id)
-{
-
-	pr_debug("evt_id = %d\n", evt_id);
-	switch (evt_id) {
-	case AUDDEV_EVT_DEV_CHG_VOICE: /* Called from Voice_route */
-		broadcast_event(AUDDEV_EVT_DEV_CHG_VOICE, id, SESSION_IGNORE);
-		break;
-	case AUDDEV_EVT_DEV_RDY:
-		broadcast_event(AUDDEV_EVT_DEV_RDY, id, SESSION_IGNORE);
-		break;
-	case AUDDEV_EVT_DEV_RLS:
-		broadcast_event(AUDDEV_EVT_DEV_RLS, id, SESSION_IGNORE);
-		break;
-	case AUDDEV_EVT_REL_PENDING:
-		broadcast_event(AUDDEV_EVT_REL_PENDING, id, SESSION_IGNORE);
-		break;
-	case AUDDEV_EVT_DEVICE_VOL_MUTE_CHG:
-		broadcast_event(AUDDEV_EVT_DEVICE_VOL_MUTE_CHG, id,
-							SESSION_IGNORE);
-		break;
-	case AUDDEV_EVT_STREAM_VOL_CHG:
-		broadcast_event(AUDDEV_EVT_STREAM_VOL_CHG, id,
-							SESSION_IGNORE);
-		break;
-	case AUDDEV_EVT_START_VOICE:
-		broadcast_event(AUDDEV_EVT_START_VOICE,
-				id, SESSION_IGNORE);
-		break;
-	case AUDDEV_EVT_END_VOICE:
-		broadcast_event(AUDDEV_EVT_END_VOICE,
-				id, SESSION_IGNORE);
-		break;
-	case AUDDEV_EVT_FREQ_CHG:
-		broadcast_event(AUDDEV_EVT_FREQ_CHG, id, SESSION_IGNORE);
-		break;
-	default:
-		break;
-	}
-}
-EXPORT_SYMBOL(mixer_post_event);
-
-static int __init audio_dev_ctrl_init(void)
-{
-	init_waitqueue_head(&audio_dev_ctrl.wait);
-
-	event.cb = NULL;
-	msm_reset_device_work_queue = create_workqueue("reset_device");
-	if (msm_reset_device_work_queue == NULL)
-		return -ENOMEM;
-	atomic_set(&audio_dev_ctrl.opened, 0);
-	audio_dev_ctrl.num_dev = 0;
-	audio_dev_ctrl.voice_tx_dev = NULL;
-	audio_dev_ctrl.voice_rx_dev = NULL;
-	routing_info.voice_state = VOICE_STATE_INVALID;
-
-	mutex_init(&adm_tx_topology_tbl.lock);
-	mutex_init(&routing_info.copp_list_mutex);
-	mutex_init(&routing_info.adm_mutex);
-
-	memset(routing_info.copp_list, COPP_IGNORE,
-		(sizeof(unsigned int) * MAX_SESSIONS * AFE_MAX_PORTS));
-	return misc_register(&audio_dev_ctrl_misc);
-}
-
-static void __exit audio_dev_ctrl_exit(void)
-{
-	destroy_workqueue(msm_reset_device_work_queue);
-}
-module_init(audio_dev_ctrl_init);
-module_exit(audio_dev_ctrl_exit);
-
-MODULE_DESCRIPTION("MSM 8K Audio Device Control driver");
-MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/qdsp6v2/audio_lpa.c b/arch/arm/mach-msm/qdsp6v2/audio_lpa.c
index f6dd9fab..afdfd6d 100644
--- a/arch/arm/mach-msm/qdsp6v2/audio_lpa.c
+++ b/arch/arm/mach-msm/qdsp6v2/audio_lpa.c
@@ -921,6 +921,7 @@
 
 	case AUDIO_GET_CONFIG:{
 		struct msm_audio_config config;
+		memset(&config, 0, sizeof(config));
 		config.buffer_count = audio->buffer_count;
 		config.buffer_size = audio->buffer_size;
 		config.sample_rate = audio->out_sample_rate;
diff --git a/arch/arm/mach-msm/qdsp6v2/audio_utils.c b/arch/arm/mach-msm/qdsp6v2/audio_utils.c
index 5355de1..ccacd3e 100644
--- a/arch/arm/mach-msm/qdsp6v2/audio_utils.c
+++ b/arch/arm/mach-msm/qdsp6v2/audio_utils.c
@@ -99,7 +99,7 @@
 int audio_in_disable(struct q6audio_in  *audio)
 {
 	int rc = 0;
-	if (audio->opened) {
+	if (!audio->stopped) {
 		audio->enabled = 0;
 		audio->opened = 0;
 		pr_debug("%s:session id %d: inbytes[%d] insamples[%d]\n",
@@ -260,14 +260,16 @@
 		}
 		audio->str_cfg.buffer_size = cfg.buffer_size;
 		audio->str_cfg.buffer_count = cfg.buffer_count;
-		rc = q6asm_audio_client_buf_alloc(OUT, audio->ac,
+		if(audio->opened){
+			rc = q6asm_audio_client_buf_alloc(OUT,audio->ac,
 				ALIGN_BUF_SIZE(audio->str_cfg.buffer_size),
 				audio->str_cfg.buffer_count);
-		if (rc < 0) {
+			if (rc < 0) {
 			pr_err("%s: session id %d: Buffer Alloc failed rc=%d\n",
-					__func__, audio->ac->session, rc);
+				__func__, audio->ac->session, rc);
 			rc = -ENOMEM;
 			break;
+			}
 		}
 		audio->buf_alloc |= BUF_ALLOC_OUT;
 		rc = 0;
@@ -349,14 +351,16 @@
 		audio->pcm_cfg.buffer_size  = cfg.buffer_size;
 		audio->pcm_cfg.channel_count = cfg.channel_count;
 		audio->pcm_cfg.sample_rate = cfg.sample_rate;
-		rc = q6asm_audio_client_buf_alloc(IN, audio->ac,
-			ALIGN_BUF_SIZE(audio->pcm_cfg.buffer_size),
-			audio->pcm_cfg.buffer_count);
-		if (rc < 0) {
-			pr_err("%s:session id %d: Buffer Alloc failed\n",
-				__func__, audio->ac->session);
-			rc = -ENOMEM;
-			break;
+		if(audio->opened && audio->feedback == NON_TUNNEL_MODE){
+			rc = q6asm_audio_client_buf_alloc(IN, audio->ac,
+				ALIGN_BUF_SIZE(audio->pcm_cfg.buffer_size),
+				audio->pcm_cfg.buffer_count);
+			if(rc < 0){
+				pr_err("%s:session id %d: Buffer Alloc failed\n",
+						__func__,audio->ac->session);
+				rc = -ENOMEM;
+				break;
+			}
 		}
 		audio->buf_alloc |= BUF_ALLOC_IN;
 		rc = 0;
diff --git a/arch/arm/mach-msm/qdsp6v2/audio_utils_aio.c b/arch/arm/mach-msm/qdsp6v2/audio_utils_aio.c
index a1463bc..5bdd10a 100644
--- a/arch/arm/mach-msm/qdsp6v2/audio_utils_aio.c
+++ b/arch/arm/mach-msm/qdsp6v2/audio_utils_aio.c
@@ -179,6 +179,16 @@
 			pr_err("%s[%p]: pause cmd failed rc=%d\n",
 				__func__, audio, rc);
 
+		if (rc == 0) {
+			/* Send suspend only if pause was successful */
+			rc = q6asm_cmd(audio->ac, CMD_SUSPEND);
+			if (rc < 0)
+				pr_err("%s[%p]: suspend cmd failed rc=%d\n",
+					__func__, audio, rc);
+		} else
+			pr_err("%s[%p]: not sending suspend since pause failed\n",
+				__func__, audio);
+
 	} else
 		pr_err("%s[%p]: Driver not enabled\n", __func__, audio);
 	return rc;
@@ -1189,6 +1199,7 @@
 	case AUDIO_GET_STATS: {
 		struct msm_audio_stats stats;
 		uint64_t timestamp;
+		memset(&stats, 0, sizeof(struct msm_audio_stats));
 		stats.byte_count = atomic_read(&audio->in_bytes);
 		stats.sample_count = atomic_read(&audio->in_samples);
 		rc = q6asm_get_session_time(audio->ac, &timestamp);
diff --git a/arch/arm/mach-msm/qdsp6v2/lpa_if_hdmi.c b/arch/arm/mach-msm/qdsp6v2/lpa_if_hdmi.c
deleted file mode 100644
index c6def46..0000000
--- a/arch/arm/mach-msm/qdsp6v2/lpa_if_hdmi.c
+++ /dev/null
@@ -1,464 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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 pr_fmt(fmt) "%s: " fmt, __func__
-
-#include <linux/fs.h>
-#include <linux/module.h>
-#include <linux/miscdevice.h>
-#include <linux/mutex.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/slab.h>
-#include <linux/interrupt.h>
-#include <linux/uaccess.h>
-#include <linux/dma-mapping.h>
-#include <linux/msm_audio.h>
-#include <mach/msm_hdmi_audio.h>
-#include <mach/audio_dma_msm8k.h>
-#include <sound/dai.h>
-#include <mach/qdsp6v2/q6core.h>
-
-#define DMA_ALLOC_BUF_SZ		(SZ_4K * 16)
-
-#define HDMI_AUDIO_FIFO_WATER_MARK	4
-
-struct audio_buffer {
-	dma_addr_t phys;
-	void *data;
-	uint32_t size;
-	uint32_t used;	/* 1 = CPU is waiting for DMA to consume this buf */
-	uint32_t actual_size;	/* actual number of bytes read by DMA */
-};
-
-struct lpa_if {
-	struct mutex lock;
-	struct msm_audio_config cfg;
-	struct audio_buffer audio_buf[6];
-	int cpu_buf;		/* next buffer the CPU will touch */
-	int dma_buf;		/* next buffer the DMA will touch */
-	u8 *buffer;
-	dma_addr_t buffer_phys;
-	u32 dma_ch;
-	wait_queue_head_t wait;
-	u32 config;
-	u32 dma_period_sz;
-	unsigned int num_periods;
-};
-
-static struct lpa_if  *lpa_if_ptr;
-
-static unsigned int dma_buf_index;
-
-static irqreturn_t lpa_if_irq(int intrsrc, void *data)
-{
-	struct lpa_if *lpa_if = data;
-	int dma_ch = 0;
-	unsigned int pending;
-
-	if (lpa_if)
-		dma_ch = lpa_if->dma_ch;
-	else {
-		pr_err("invalid lpa_if\n");
-		return IRQ_NONE;
-	}
-
-	pending = (intrsrc
-		   & (UNDER_CH(dma_ch) | PER_CH(dma_ch) | ERR_CH(dma_ch)));
-
-	if (pending & UNDER_CH(dma_ch))
-		pr_err("under run\n");
-	if (pending & ERR_CH(dma_ch))
-		pr_err("DMA %x Master Error\n", dma_ch);
-
-	if (pending & PER_CH(dma_ch)) {
-
-		lpa_if->audio_buf[lpa_if->dma_buf].used = 0;
-
-		pr_debug("dma_buf %d  used %d\n", lpa_if->dma_buf,
-			lpa_if->audio_buf[lpa_if->dma_buf].used);
-		lpa_if->dma_buf++;
-		lpa_if->dma_buf = lpa_if->dma_buf % lpa_if->cfg.buffer_count;
-
-		if (lpa_if->dma_buf == lpa_if->cpu_buf)
-			pr_err("Err:both dma_buf and cpu_buf are on same index\n");
-		wake_up(&lpa_if->wait);
-	}
-	return IRQ_HANDLED;
-}
-
-
-int lpa_if_start(struct lpa_if *lpa_if)
-{
-	pr_debug("buf1 0x%x, buf2 0x%x dma_ch %d\n",
-		(unsigned int)lpa_if->audio_buf[0].data,
-		(unsigned int)lpa_if->audio_buf[1].data, lpa_if->dma_ch);
-
-	dai_start_hdmi(lpa_if->dma_ch);
-
-	hdmi_audio_enable(1, HDMI_AUDIO_FIFO_WATER_MARK);
-
-	hdmi_audio_packet_enable(1);
-	return 0;
-}
-
-int lpa_if_config(struct lpa_if *lpa_if)
-{
-	struct dai_dma_params dma_params;
-
-	dma_params.src_start = lpa_if->buffer_phys;
-	dma_params.buffer = lpa_if->buffer;
-	dma_params.buffer_size = lpa_if->dma_period_sz * lpa_if->num_periods;
-	dma_params.period_size = lpa_if->dma_period_sz;
-	dma_params.channels = 2;
-
-	lpa_if->dma_ch = 4;
-	dai_set_params(lpa_if->dma_ch, &dma_params);
-
-	register_dma_irq_handler(lpa_if->dma_ch, lpa_if_irq, (void *)lpa_if);
-
-	mb();
-	pr_debug("lpa_if 0x%08x  buf_vir 0x%08x   buf_phys 0x%08x  "
-		"config %u\n", (u32)lpa_if, (u32) (lpa_if->buffer),
-		lpa_if->buffer_phys, lpa_if->config);
-
-	pr_debug("user_buf_cnt %u user_buf_size %u\n",
-			lpa_if->cfg.buffer_count, lpa_if->cfg.buffer_size);
-
-	lpa_if->config = 1;
-
-	lpa_if_start(lpa_if);
-
-	return 0;
-}
-
-
-static long lpa_if_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
-{
-	struct lpa_if *lpa_if = file->private_data;
-	int rc = 0;
-	unsigned int i;
-	pr_debug("cmd %u\n", cmd);
-
-	mutex_lock(&lpa_if->lock);
-
-	switch (cmd) {
-	case AUDIO_START:
-		pr_debug("AUDIO_START\n");
-
-		if (dma_buf_index == 2) {
-			if (!lpa_if->config) {
-				rc = lpa_if_config(lpa_if);
-				if (rc)
-					pr_err("lpa_if_config failed\n");
-			}
-		} else {
-			pr_err("did not receved two buffer for "
-				"AUDIO_STAR\n");
-			rc =  -EPERM;
-		}
-		break;
-
-	case AUDIO_STOP:
-		pr_debug("AUDIO_STOP\n");
-		break;
-
-	case AUDIO_FLUSH:
-		pr_debug("AUDIO_FLUSH\n");
-		break;
-
-
-	case AUDIO_GET_CONFIG:
-		pr_debug("AUDIO_GET_CONFIG\n");
-		if (copy_to_user((void *)arg, &lpa_if->cfg,
-				 sizeof(struct msm_audio_config))) {
-			rc = -EFAULT;
-		}
-		break;
-	case AUDIO_SET_CONFIG: {
-		/*  Setting default rate as 48khz */
-		unsigned int cur_sample_rate =
-			HDMI_SAMPLE_RATE_48KHZ;
-		struct msm_audio_config config;
-
-		pr_debug("AUDIO_SET_CONFIG\n");
-		if (copy_from_user(&config, (void *)arg, sizeof(config))) {
-			rc = -EFAULT;
-			break;
-		}
-		lpa_if->dma_period_sz = config.buffer_size;
-		if ((lpa_if->dma_period_sz * lpa_if->num_periods) >
-			DMA_ALLOC_BUF_SZ) {
-			pr_err("Dma buffer size greater than allocated size\n");
-			return -EINVAL;
-		}
-		pr_debug("Dma_period_sz %d\n", lpa_if->dma_period_sz);
-		if (lpa_if->dma_period_sz < (2 * SZ_4K))
-			lpa_if->num_periods = 6;
-		pr_debug("No. of Periods %d\n", lpa_if->num_periods);
-
-		lpa_if->cfg.buffer_count = lpa_if->num_periods;
-		lpa_if->cfg.buffer_size = lpa_if->dma_period_sz *
-						lpa_if->num_periods;
-
-		for (i = 0; i < lpa_if->cfg.buffer_count; i++) {
-			lpa_if->audio_buf[i].phys =
-				lpa_if->buffer_phys + i * lpa_if->dma_period_sz;
-			lpa_if->audio_buf[i].data =
-				lpa_if->buffer + i * lpa_if->dma_period_sz;
-			lpa_if->audio_buf[i].size = lpa_if->dma_period_sz;
-			lpa_if->audio_buf[i].used = 0;
-		}
-
-		pr_debug("Sample rate %d\n", config.sample_rate);
-		switch (config.sample_rate) {
-		case 48000:
-			cur_sample_rate = HDMI_SAMPLE_RATE_48KHZ;
-			break;
-		case 44100:
-			cur_sample_rate = HDMI_SAMPLE_RATE_44_1KHZ;
-			break;
-		case 32000:
-			cur_sample_rate = HDMI_SAMPLE_RATE_32KHZ;
-			break;
-		case 88200:
-			cur_sample_rate = HDMI_SAMPLE_RATE_88_2KHZ;
-			break;
-		case 96000:
-			cur_sample_rate = HDMI_SAMPLE_RATE_96KHZ;
-			break;
-		case 176400:
-			cur_sample_rate = HDMI_SAMPLE_RATE_176_4KHZ;
-			break;
-		case 192000:
-			cur_sample_rate = HDMI_SAMPLE_RATE_192KHZ;
-			break;
-		default:
-			cur_sample_rate = HDMI_SAMPLE_RATE_48KHZ;
-		}
-		if (cur_sample_rate != hdmi_msm_audio_get_sample_rate())
-			hdmi_msm_audio_sample_rate_reset(cur_sample_rate);
-		else
-			pr_debug("Previous sample rate and current"
-				"sample rate are same\n");
-		break;
-	}
-	default:
-		pr_err("UnKnown Ioctl\n");
-		rc = -EINVAL;
-	}
-
-	mutex_unlock(&lpa_if->lock);
-
-	return rc;
-}
-
-
-static int lpa_if_open(struct inode *inode, struct file *file)
-{
-	pr_debug("\n");
-
-	file->private_data = lpa_if_ptr;
-	dma_buf_index = 0;
-	lpa_if_ptr->cpu_buf = 2;
-	lpa_if_ptr->dma_buf = 0;
-	lpa_if_ptr->num_periods = 4;
-
-	core_req_bus_bandwith(AUDIO_IF_BUS_ID, 100000, 0);
-	mb();
-
-	return 0;
-}
-
-static inline int rt_policy(int policy)
-{
-	if (unlikely(policy == SCHED_FIFO) || unlikely(policy == SCHED_RR))
-		return 1;
-	return 0;
-}
-
-static inline int task_has_rt_policy(struct task_struct *p)
-{
-	return rt_policy(p->policy);
-}
-static ssize_t lpa_if_write(struct file *file, const char __user *buf,
-		size_t count, loff_t *pos)
-{
-	struct lpa_if *lpa_if = file->private_data;
-	struct audio_buffer *ab;
-	const char __user *start = buf;
-	int xfer, rc;
-	struct sched_param s = { .sched_priority = 1 };
-	int old_prio = current->rt_priority;
-	int old_policy = current->policy;
-	int cap_nice = cap_raised(current_cap(), CAP_SYS_NICE);
-
-	 /* just for this write, set us real-time */
-	if (!task_has_rt_policy(current)) {
-		struct cred *new = prepare_creds();
-		cap_raise(new->cap_effective, CAP_SYS_NICE);
-		commit_creds(new);
-		if ((sched_setscheduler(current, SCHED_RR, &s)) < 0)
-			pr_err("sched_setscheduler failed\n");
-	}
-	mutex_lock(&lpa_if->lock);
-
-	if (dma_buf_index < 2) {
-
-		ab = lpa_if->audio_buf + dma_buf_index;
-
-		if (copy_from_user(ab->data, buf, count)) {
-			pr_err("copy from user failed\n");
-			rc = 0;
-			goto end;
-
-		}
-		mb();
-		pr_debug("prefill: count %u  audio_buf[%u].size %u\n",
-			 count, dma_buf_index, ab->size);
-
-		ab->used = 1;
-		dma_buf_index++;
-		rc =  count;
-		goto end;
-	}
-
-	if (lpa_if->config != 1) {
-		pr_err("AUDIO_START did not happen\n");
-		rc = 0;
-		goto end;
-	}
-
-	while (count > 0) {
-
-		ab = lpa_if->audio_buf + lpa_if->cpu_buf;
-
-		rc = wait_event_timeout(lpa_if->wait, (ab->used == 0), 10 * HZ);
-		if (!rc) {
-			pr_err("wait_event_timeout failed\n");
-			rc =  buf - start;
-			goto end;
-		}
-
-		xfer = count;
-
-		if (xfer > lpa_if->dma_period_sz)
-			xfer = lpa_if->dma_period_sz;
-
-		if (copy_from_user(ab->data, buf, xfer)) {
-			pr_err("copy from user failed\n");
-			rc = buf - start;
-			goto end;
-		}
-
-		mb();
-		buf += xfer;
-		count -= xfer;
-		ab->used = 1;
-
-		pr_debug("xfer %d, size %d, used %d cpu_buf %d\n",
-			xfer, ab->size, ab->used, lpa_if->cpu_buf);
-		lpa_if->cpu_buf++;
-		lpa_if->cpu_buf = lpa_if->cpu_buf % lpa_if->cfg.buffer_count;
-	}
-	rc = buf - start;
-end:
-	mutex_unlock(&lpa_if->lock);
-	/* restore old scheduling policy */
-	if (!rt_policy(old_policy)) {
-		struct sched_param v = { .sched_priority = old_prio };
-		if ((sched_setscheduler(current, old_policy, &v)) < 0)
-			pr_err("sched_setscheduler failed\n");
-		if (likely(!cap_nice)) {
-			struct cred *new = prepare_creds();
-			cap_lower(new->cap_effective, CAP_SYS_NICE);
-			commit_creds(new);
-		}
-	}
-	return rc;
-}
-
-static int lpa_if_release(struct inode *inode, struct file *file)
-{
-	struct lpa_if *lpa_if = file->private_data;
-
-	hdmi_audio_packet_enable(0);
-
-	wait_for_dma_cnt_stop(lpa_if->dma_ch);
-
-	hdmi_audio_enable(0, HDMI_AUDIO_FIFO_WATER_MARK);
-
-	if (lpa_if->config) {
-		unregister_dma_irq_handler(lpa_if->dma_ch);
-		dai_stop_hdmi(lpa_if->dma_ch);
-		lpa_if->config = 0;
-	}
-	core_req_bus_bandwith(AUDIO_IF_BUS_ID, 0, 0);
-
-	if (hdmi_msm_audio_get_sample_rate() != HDMI_SAMPLE_RATE_48KHZ)
-		hdmi_msm_audio_sample_rate_reset(HDMI_SAMPLE_RATE_48KHZ);
-
-	return 0;
-}
-
-static const struct file_operations lpa_if_fops = {
-	.owner = THIS_MODULE,
-	.open = lpa_if_open,
-	.write = lpa_if_write,
-	.release = lpa_if_release,
-	.unlocked_ioctl = lpa_if_ioctl,
-};
-
-struct miscdevice lpa_if_misc = {
-	.minor = MISC_DYNAMIC_MINOR,
-	.name = "msm_lpa_if_out",
-	.fops = &lpa_if_fops,
-};
-
-static int __init lpa_if_init(void)
-{
-	int rc;
-
-	lpa_if_ptr = kzalloc(sizeof(struct lpa_if), GFP_KERNEL);
-	if (!lpa_if_ptr) {
-		pr_info("No mem for lpa-if\n");
-		return -ENOMEM;
-	}
-
-	mutex_init(&lpa_if_ptr->lock);
-	init_waitqueue_head(&lpa_if_ptr->wait);
-
-	lpa_if_ptr->buffer = dma_alloc_coherent(NULL, DMA_ALLOC_BUF_SZ,
-				    &(lpa_if_ptr->buffer_phys), GFP_KERNEL);
-	if (!lpa_if_ptr->buffer) {
-		pr_err("dma_alloc_coherent failed\n");
-		kfree(lpa_if_ptr);
-		return -ENOMEM;
-	}
-
-	pr_info("lpa_if_ptr 0x%08x   buf_vir 0x%08x   buf_phy 0x%08x "
-		" buf_zise %u\n", (u32)lpa_if_ptr,
-		(u32)(lpa_if_ptr->buffer), lpa_if_ptr->buffer_phys,
-		DMA_ALLOC_BUF_SZ);
-
-	rc =  misc_register(&lpa_if_misc);
-	if (rc < 0) {
-		pr_err("misc_register failed\n");
-
-		dma_free_coherent(NULL, DMA_ALLOC_BUF_SZ, lpa_if_ptr->buffer,
-				lpa_if_ptr->buffer_phys);
-		kfree(lpa_if_ptr);
-	}
-	return rc;
-}
-
-device_initcall(lpa_if_init);
diff --git a/arch/arm/mach-msm/qdsp6v2/msm_audio_ion.c b/arch/arm/mach-msm/qdsp6v2/msm_audio_ion.c
index 0a50bcc..fc6de64 100644
--- a/arch/arm/mach-msm/qdsp6v2/msm_audio_ion.c
+++ b/arch/arm/mach-msm/qdsp6v2/msm_audio_ion.c
@@ -269,6 +269,7 @@
 	} else {
 		ion_phys_addr_t phys_addr;
 		size_t phys_len;
+		size_t va_len = 0;
 		pr_debug("%s: page is NULL\n", __func__);
 
 		ret = ion_phys(ab->client, ab->handle, &phys_addr, &phys_len);
@@ -282,6 +283,12 @@
 			vma, (unsigned int)vma->vm_start,
 			(unsigned int)vma->vm_end, vma->vm_pgoff,
 			(unsigned long int)vma->vm_page_prot);
+		va_len = vma->vm_end - vma->vm_start;
+		if ((offset > phys_len) || (va_len > phys_len-offset)) {
+			pr_err("wrong offset size %ld, lens= %d, va_len=%d\n",
+				offset, phys_len, va_len);
+			return -EINVAL;
+		}
 		ret =  remap_pfn_range(vma, vma->vm_start,
 				__phys_to_pfn(phys_addr) + vma->vm_pgoff,
 				vma->vm_end - vma->vm_start,
@@ -321,6 +328,11 @@
 			ion_phys_addr_t *paddr, size_t *pa_len, void **vaddr)
 {
 	int rc = 0;
+	if (!name || !client || !handle || !paddr || !vaddr || !pa_len) {
+		pr_err("%s: Invalid params\n", __func__);
+		rc = -EINVAL;
+		goto err;
+	}
 	/* client is already created for legacy and given*/
 	/* name should be audio_acdb_client or Audio_Dec_Client,
 	bufsz should be 0 and fd shouldn't be 0 as of now
@@ -331,14 +343,16 @@
 	if (IS_ERR_OR_NULL((void *)(*handle))) {
 		pr_err("%s: ion import dma buffer failed\n",
 			__func__);
-		goto err_ion_handle;
-		}
+		rc = -EINVAL;
+		goto err_destroy_client;
+	}
 
 	if (ionflag != NULL) {
 		rc = ion_handle_get_flags(client, *handle, ionflag);
 		if (rc) {
 			pr_err("%s: could not get flags for the handle\n",
 							__func__);
+			rc = -EINVAL;
 			goto err_ion_handle;
 		}
 	}
@@ -347,6 +361,7 @@
 	if (rc) {
 		pr_err("%s: ION Get Physical for AUDIO failed, rc = %d\n",
 			__func__, rc);
+		rc = -EINVAL;
 		goto err_ion_handle;
 	}
 
@@ -354,6 +369,7 @@
 	*vaddr = ion_map_kernel(client, *handle);
 	if (IS_ERR_OR_NULL((void *)*vaddr)) {
 		pr_err("%s: ION memory mapping for AUDIO failed\n", __func__);
+		rc = -EINVAL;
 		goto err_ion_handle;
 	}
 
@@ -364,8 +380,12 @@
 
 err_ion_handle:
 	ion_free(client, *handle);
-	return -EINVAL;
-
+err_destroy_client:
+	msm_audio_ion_client_destroy(client);
+	client = NULL;
+	*handle = NULL;
+err:
+	return rc;
 }
 
 int msm_audio_ion_free_legacy(struct ion_client *client,
diff --git a/arch/arm/mach-msm/qdsp6v2/pcm_in.c b/arch/arm/mach-msm/qdsp6v2/pcm_in.c
index 0db4894..cf7548d 100644
--- a/arch/arm/mach-msm/qdsp6v2/pcm_in.c
+++ b/arch/arm/mach-msm/qdsp6v2/pcm_in.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2009 Google, Inc.
  * Copyright (C) 2009 HTC Corporation
- * Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
  *
  * This software is licensed under the terms of the GNU General Public
  * License version 2, as published by the Free Software Foundation, and
@@ -256,6 +256,7 @@
 	}
 	case AUDIO_GET_CONFIG: {
 		struct msm_audio_config config;
+		memset(&config, 0, sizeof(config));
 		config.buffer_size = pcm->buffer_size;
 		config.buffer_count = pcm->buffer_count;
 		config.sample_rate = pcm->sample_rate;
diff --git a/arch/arm/mach-msm/qdsp6v2/pcm_in_proxy.c b/arch/arm/mach-msm/qdsp6v2/pcm_in_proxy.c
index 5faee21..f7bf1ae 100644
--- a/arch/arm/mach-msm/qdsp6v2/pcm_in_proxy.c
+++ b/arch/arm/mach-msm/qdsp6v2/pcm_in_proxy.c
@@ -1,5 +1,5 @@
 
-/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2013, The Linux Foundation. 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
@@ -475,6 +475,7 @@
 	}
 	case AUDIO_GET_CONFIG: {
 		struct msm_audio_config config;
+		memset(&config, 0, sizeof(config));
 		config.buffer_size = pcm->buffer_size;
 		config.buffer_count = pcm->buffer_count;
 		config.sample_rate = pcm->sample_rate;
diff --git a/arch/arm/mach-msm/qdsp6v2/pcm_out.c b/arch/arm/mach-msm/qdsp6v2/pcm_out.c
index 4097b72..c6ae427 100644
--- a/arch/arm/mach-msm/qdsp6v2/pcm_out.c
+++ b/arch/arm/mach-msm/qdsp6v2/pcm_out.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2009 Google, Inc.
- * Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
  * Author: Brian Swetland <swetland@google.com>
  *
  * This software is licensed under the terms of the GNU General Public
@@ -260,6 +260,7 @@
 	case AUDIO_GET_CONFIG: {
 		struct msm_audio_config config;
 		pr_debug("%s: AUDIO_GET_CONFIG\n", __func__);
+		memset(&config, 0, sizeof(config));
 		config.buffer_size = pcm->buffer_size;
 		config.buffer_count = pcm->buffer_count;
 		config.sample_rate = pcm->sample_rate;
diff --git a/arch/arm/mach-msm/rpm-regulator-smd.c b/arch/arm/mach-msm/rpm-regulator-smd.c
index 923e647..faf774f 100644
--- a/arch/arm/mach-msm/rpm-regulator-smd.c
+++ b/arch/arm/mach-msm/rpm-regulator-smd.c
@@ -1266,14 +1266,16 @@
 {
 	struct device *dev = &pdev->dev;
 	struct rpm_regulator *reg;
+	struct rpm_vreg *rpm_vreg;
 
 	reg = platform_get_drvdata(pdev);
 	if (reg) {
-		rpm_vreg_lock(reg->rpm_vreg);
+		rpm_vreg = reg->rpm_vreg;
+		rpm_vreg_lock(rpm_vreg);
 		regulator_unregister(reg->rdev);
 		list_del(&reg->list);
 		kfree(reg);
-		rpm_vreg_unlock(reg->rpm_vreg);
+		rpm_vreg_unlock(rpm_vreg);
 	} else {
 		dev_err(dev, "%s: drvdata missing\n", __func__);
 		return -EINVAL;
diff --git a/arch/arm/mach-msm/scm.c b/arch/arm/mach-msm/scm.c
index 266b759..601c42c 100644
--- a/arch/arm/mach-msm/scm.c
+++ b/arch/arm/mach-msm/scm.c
@@ -114,6 +114,7 @@
 
 static int scm_remap_error(int err)
 {
+	pr_err("scm_call failed with error code %d\n", err);
 	switch (err) {
 	case SCM_ERROR:
 		return -EIO;
diff --git a/arch/arm/mach-msm/sensors_adsp.c b/arch/arm/mach-msm/sensors_adsp.c
index 1534358..ad19e16 100644
--- a/arch/arm/mach-msm/sensors_adsp.c
+++ b/arch/arm/mach-msm/sensors_adsp.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2013, The Linux Foundation. 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
@@ -38,6 +38,7 @@
 #include <mach/msm_bus.h>
 #include <mach/msm_bus_board.h>
 
+#define CLASS_NAME	"ssc"
 #define DRV_NAME	"sensors"
 #define DRV_VERSION	"1.00"
 
@@ -355,6 +356,7 @@
 	if (temp == NULL) {
 		pr_err("%s: allocation failure\n", __func__);
 		rv = -ENOMEM;
+		goto out;
 	}
 
 	hdr->dst_module = SNS_OCMEM_MODULE_ADSP;
@@ -387,6 +389,7 @@
 
 	kfree(temp);
 
+out:
 	return rv;
 }
 
@@ -874,7 +877,7 @@
 
 	vectors = ocmem_get_vectors(SNS_OCMEM_CLIENT_ID, sns_ctl.buf);
 	if ((vectors != NULL)) {
-		memcpy(&msg.vectors, vectors, sizeof(vectors));
+		memcpy(&msg.vectors, vectors, sizeof(*vectors));
 		/* TODO: set vectors_len */
 		msg.vectors_valid = true;
 		msg.vectors_len = 0;
@@ -1077,7 +1080,7 @@
 static int sensors_adsp_probe(struct platform_device *pdev)
 {
 	int ret = 0;
-	sns_ctl.dev_class = class_create(THIS_MODULE, DRV_NAME);
+	sns_ctl.dev_class = class_create(THIS_MODULE, CLASS_NAME);
 	if (sns_ctl.dev_class == NULL) {
 		pr_err("%s: class_create fail.\n", __func__);
 		goto res_err;
diff --git a/arch/arm/mach-msm/smd.c b/arch/arm/mach-msm/smd.c
index 110ab87..cb9697d 100644
--- a/arch/arm/mach-msm/smd.c
+++ b/arch/arm/mach-msm/smd.c
@@ -3243,7 +3243,7 @@
  */
 void smd_set_edge_subsys_name(uint32_t edge, const char *subsys_name)
 {
-	if (edge <= ARRAY_SIZE(edge_to_pids))
+	if (edge < ARRAY_SIZE(edge_to_pids))
 		strlcpy(edge_to_pids[edge].subsys_name,
 			subsys_name, SMD_MAX_CH_NAME_LEN);
 	else
@@ -3258,7 +3258,7 @@
  */
 void smd_set_edge_initialized(uint32_t edge)
 {
-	if (edge <= ARRAY_SIZE(edge_to_pids))
+	if (edge < ARRAY_SIZE(edge_to_pids))
 		edge_to_pids[edge].initialized = true;
 	else
 		pr_err("%s: Invalid edge type[%d]\n", __func__, edge);
diff --git a/arch/arm/mach-msm/socinfo.c b/arch/arm/mach-msm/socinfo.c
index 249c768..4b68e66 100644
--- a/arch/arm/mach-msm/socinfo.c
+++ b/arch/arm/mach-msm/socinfo.c
@@ -41,6 +41,7 @@
 #define SMEM_IMAGE_VERSION_VARIANT_OFFSET 75
 #define SMEM_IMAGE_VERSION_OEM_SIZE 32
 #define SMEM_IMAGE_VERSION_OEM_OFFSET 96
+#define SMEM_IMAGE_VERSION_PARTITION_APPS 10
 
 enum {
 	HW_PLATFORM_UNKNOWN = 0,
@@ -859,23 +860,28 @@
 	}
 	string_address += current_image * SMEM_IMAGE_VERSION_SINGLE_BLOCK_SIZE;
 	string_address += SMEM_IMAGE_VERSION_NAME_OFFSET;
-	return snprintf(buf, SMEM_IMAGE_VERSION_NAME_SIZE, "%-.75s",
+	return snprintf(buf, SMEM_IMAGE_VERSION_NAME_SIZE, "%-.72s\n",
 			string_address);
 }
 
 static ssize_t
-msm_store_image_type(struct device *dev, struct device_attribute *attr,
-			const char *buf, size_t count)
+msm_set_image_version(struct device *dev,
+			struct device_attribute *attr,
+			const char *buf,
+			size_t count)
 {
-	int ret, digit;
+	char *store_address;
 
-	ret = kstrtoint(buf, 10, &digit);
-	if (ret)
-		return ret;
-	if (0 <= digit && digit < SMEM_IMAGE_VERSION_BLOCKS_COUNT)
-		current_image = digit;
-	else
-		current_image = 0;
+	if (current_image != SMEM_IMAGE_VERSION_PARTITION_APPS)
+		return count;
+	store_address = socinfo_get_image_version_base_address();
+	if (store_address == NULL) {
+		pr_err("%s : Failed to get image version base address",
+				__func__);
+		return count;
+	}
+	store_address += current_image * SMEM_IMAGE_VERSION_SINGLE_BLOCK_SIZE;
+	snprintf(store_address, SMEM_IMAGE_VERSION_NAME_SIZE, "%-.75s", buf);
 	return count;
 }
 
@@ -895,11 +901,33 @@
 	}
 	string_address += current_image * SMEM_IMAGE_VERSION_SINGLE_BLOCK_SIZE;
 	string_address += SMEM_IMAGE_VERSION_VARIANT_OFFSET;
-	return snprintf(buf, SMEM_IMAGE_VERSION_VARIANT_SIZE, "%-.20s",
+	return snprintf(buf, SMEM_IMAGE_VERSION_VARIANT_SIZE, "%-.20s\n",
 			string_address);
 }
 
 static ssize_t
+msm_set_image_variant(struct device *dev,
+			struct device_attribute *attr,
+			const char *buf,
+			size_t count)
+{
+	char *store_address;
+
+	if (current_image != SMEM_IMAGE_VERSION_PARTITION_APPS)
+		return count;
+	store_address = socinfo_get_image_version_base_address();
+	if (store_address == NULL) {
+		pr_err("%s : Failed to get image version base address",
+				__func__);
+		return count;
+	}
+	store_address += current_image * SMEM_IMAGE_VERSION_SINGLE_BLOCK_SIZE;
+	store_address += SMEM_IMAGE_VERSION_VARIANT_OFFSET;
+	snprintf(store_address, SMEM_IMAGE_VERSION_VARIANT_SIZE, "%-.20s", buf);
+	return count;
+}
+
+static ssize_t
 msm_get_image_crm_version(struct device *dev,
 			struct device_attribute *attr,
 			char *buf)
@@ -955,6 +983,54 @@
 			socinfo_show_pmic_die_revision, NULL),
 };
 
+static ssize_t
+msm_set_image_crm_version(struct device *dev,
+			struct device_attribute *attr,
+			const char *buf,
+			size_t count)
+{
+	char *store_address;
+
+	if (current_image != SMEM_IMAGE_VERSION_PARTITION_APPS)
+		return count;
+	store_address = socinfo_get_image_version_base_address();
+	if (store_address == NULL) {
+		pr_err("%s : Failed to get image version base address",
+				__func__);
+		return count;
+	}
+	store_address += current_image * SMEM_IMAGE_VERSION_SINGLE_BLOCK_SIZE;
+	store_address += SMEM_IMAGE_VERSION_OEM_OFFSET;
+	snprintf(store_address, SMEM_IMAGE_VERSION_OEM_SIZE, "%-.32s", buf);
+	return count;
+}
+
+static ssize_t
+msm_get_image_number(struct device *dev,
+			struct device_attribute *attr,
+			char *buf)
+{
+	return snprintf(buf, PAGE_SIZE, "%d\n",
+			current_image);
+}
+
+static ssize_t
+msm_select_image(struct device *dev, struct device_attribute *attr,
+			const char *buf, size_t count)
+{
+	int ret, digit;
+
+	ret = kstrtoint(buf, 10, &digit);
+	if (ret)
+		return ret;
+	if (0 <= digit && digit < SMEM_IMAGE_VERSION_BLOCKS_COUNT)
+		current_image = digit;
+	else
+		current_image = 0;
+	return count;
+}
+
+
 static struct device_attribute msm_soc_attr_raw_version =
 	__ATTR(raw_version, S_IRUGO, msm_get_raw_version,  NULL);
 
@@ -993,15 +1069,19 @@
 
 static struct device_attribute image_version =
 	__ATTR(image_version, S_IRUGO | S_IWUSR,
-			msm_get_image_version, msm_store_image_type);
+			msm_get_image_version, msm_set_image_version);
 
 static struct device_attribute image_variant =
-	__ATTR(image_variant, S_IRUGO,
-			msm_get_image_variant, NULL);
+	__ATTR(image_variant, S_IRUGO | S_IWUSR,
+			msm_get_image_variant, msm_set_image_variant);
 
 static struct device_attribute image_crm_version =
-	__ATTR(image_crm_version, S_IRUGO,
-			msm_get_image_crm_version, NULL);
+	__ATTR(image_crm_version, S_IRUGO | S_IWUSR,
+			msm_get_image_crm_version, msm_set_image_crm_version);
+
+static struct device_attribute select_image =
+	__ATTR(select_image, S_IRUGO | S_IWUSR,
+			msm_get_image_number, msm_select_image);
 
 static struct sysdev_class soc_sysdev_class = {
 	.name = "soc",
@@ -1060,6 +1140,7 @@
 	device_create_file(msm_soc_device, &image_version);
 	device_create_file(msm_soc_device, &image_variant);
 	device_create_file(msm_soc_device, &image_crm_version);
+	device_create_file(msm_soc_device, &select_image);
 
 	switch (legacy_format) {
 	case 8:
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 34ae4e6..ac6ccf3b 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -885,8 +885,9 @@
 		   MLM(VMALLOC_START, VMALLOC_END),
 		   MLM(PAGE_OFFSET, (unsigned long)high_memory));
 #endif
-#ifdef CONFIG_HIGHMEM
+
 	printk(KERN_NOTICE
+#ifdef CONFIG_HIGHMEM
 		   "    pkmap   : 0x%08lx - 0x%08lx   (%4ld MB)\n"
 #endif
 #ifdef CONFIG_MODULES
diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c
index 1d12b07..9a1a2eb 100644
--- a/arch/arm/vfp/vfpmodule.c
+++ b/arch/arm/vfp/vfpmodule.c
@@ -85,6 +85,7 @@
 	}
 #ifdef CONFIG_SMP
 	thread->vfpstate.hard.cpu = NR_CPUS;
+	vfp_current_hw_state[cpu] = NULL;
 #endif
 }
 
diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c
index c5f9021..fbf4eeb 100644
--- a/arch/sparc/mm/init_32.c
+++ b/arch/sparc/mm/init_32.c
@@ -77,7 +77,7 @@
 	printk("Mem-info:\n");
 	show_free_areas(filter);
 	printk("Free swap:       %6ldkB\n",
-	       nr_swap_pages << (PAGE_SHIFT-10));
+	       get_nr_swap_pages() << (PAGE_SHIFT-10));
 	printk("%ld pages of RAM\n", totalram_pages);
 	printk("%ld free pages\n", nr_free_pages());
 #if 0 /* undefined pgtable_cache_size, pgd_cache_size */
diff --git a/arch/tile/mm/pgtable.c b/arch/tile/mm/pgtable.c
index 2410aa8..ea7dd38 100644
--- a/arch/tile/mm/pgtable.c
+++ b/arch/tile/mm/pgtable.c
@@ -61,7 +61,7 @@
 	       global_page_state(NR_PAGETABLE),
 	       global_page_state(NR_BOUNCE),
 	       global_page_state(NR_FILE_PAGES),
-	       nr_swap_pages);
+	       get_nr_swap_pages());
 
 	for_each_zone(zone) {
 		unsigned long flags, order, total = 0, largest_order = -1;
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index e2864ec..02d76fc 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -650,14 +650,13 @@
           different function.
 
 config MSM_ADSPRPC
-        tristate "Qualcomm ADSP RPC driver"
-        depends on MSM_AUDIO_QDSP6 || MSM_AUDIO_QDSP6V2
-        default m
-        help
-          Provides a communication mechanism that allows for clients to
-          make remote method invocations across processor boundary to
-          applications DSP processor. Say M if you want to enable this
-          module.
+	tristate "Qualcomm ADSP RPC driver"
+	depends on MSM_AUDIO_QDSP6 || MSM_AUDIO_QDSP6V2
+	help
+	  Provides a communication mechanism that allows for clients to
+	  make remote method invocations across processor boundary to
+	  applications DSP processor. Say M if you want to enable this
+	  module.
 
 config MMC_GENERIC_CSDIO
 	tristate "Generic sdio driver"
diff --git a/drivers/char/adsprpc.c b/drivers/char/adsprpc.c
index 4507f80..921b80c 100644
--- a/drivers/char/adsprpc.c
+++ b/drivers/char/adsprpc.c
@@ -33,6 +33,7 @@
 #include <linux/device.h>
 #include <linux/of.h>
 #include <linux/iommu.h>
+#include <linux/kref.h>
 
 #ifndef ION_ADSPRPC_HEAP_ID
 #define ION_ADSPRPC_HEAP_ID ION_AUDIO_HEAP_ID
@@ -152,9 +153,11 @@
 	struct class *class;
 	struct device *dev;
 	struct fastrpc_smmu smmu;
+	struct mutex smd_mutex;
 	dev_t dev_no;
 	spinlock_t wrlock;
 	spinlock_t hlock;
+	struct kref kref;
 	struct hlist_head htbl[RPC_HASH_SZ];
 };
 
@@ -661,6 +664,7 @@
 		spin_lock_init(&me->hlock);
 		spin_lock_init(&me->wrlock);
 		init_completion(&me->work);
+		mutex_init(&me->smd_mutex);
 		for (i = 0; i < RPC_HASH_SZ; ++i)
 			INIT_HLIST_HEAD(&me->htbl[i]);
 		VERIFY(err, 0 == context_list_ctor(&me->clst, SZ_4K));
@@ -687,23 +691,10 @@
 			if (me->smmu.domain_id >= 0)
 				me->smmu.enabled = enabled;
 		}
-		VERIFY(err, 0 == smd_named_open_on_edge(FASTRPC_SMD_GUID,
-						SMD_APPS_QDSP, &me->chan,
-						me, smd_event_handler));
-		if (err)
-			goto smd_bail;
-		VERIFY(err, 0 != wait_for_completion_timeout(&me->work,
-							RPC_TIMEOUT));
-		if (err)
-			goto completion_bail;
 	}
 
 	return 0;
 
-completion_bail:
-	smd_close(me->chan);
-smd_bail:
-	ion_client_destroy(me->iclient);
 ion_bail:
 	context_list_dtor(&me->clst);
 context_list_bail:
@@ -1087,9 +1078,22 @@
 	return;
 }
 
+static void fastrpc_channel_close(struct kref *kref)
+{
+	struct fastrpc_apps *me = &gfa;
+
+	smd_close(me->chan);
+	me->chan = 0;
+	mutex_unlock(&me->smd_mutex);
+	pr_info("'closed /dev/%s c %d 0'\n", DEVICE_NAME,
+						MAJOR(me->dev_no));
+}
+
 static int fastrpc_device_release(struct inode *inode, struct file *file)
 {
 	struct file_data *fdata = (struct file_data *)file->private_data;
+	struct fastrpc_apps *me = &gfa;
+
 	(void)fastrpc_release_current_dsp_process();
 	cleanup_current_dev();
 	if (fdata) {
@@ -1102,6 +1106,8 @@
 			kfree(map);
 		}
 		kfree(fdata);
+		kref_put_mutex(&me->kref, fastrpc_channel_close,
+				&me->smd_mutex);
 	}
 	return 0;
 }
@@ -1109,6 +1115,25 @@
 static int fastrpc_device_open(struct inode *inode, struct file *filp)
 {
 	int err = 0;
+	struct fastrpc_apps *me = &gfa;
+
+	mutex_lock(&me->smd_mutex);
+	if (kref_get_unless_zero(&me->kref) == 0) {
+		VERIFY(err, 0 == smd_named_open_on_edge(FASTRPC_SMD_GUID,
+						SMD_APPS_QDSP, &me->chan,
+						me, smd_event_handler));
+		if (err)
+			goto smd_bail;
+		VERIFY(err, 0 != wait_for_completion_timeout(&me->work,
+							RPC_TIMEOUT));
+		if (err)
+			goto completion_bail;
+		kref_init(&me->kref);
+		pr_info("'opened /dev/%s c %d 0'\n", DEVICE_NAME,
+						MAJOR(me->dev_no));
+	}
+	mutex_unlock(&me->smd_mutex);
+
 	filp->private_data = 0;
 	if (0 != try_module_get(THIS_MODULE)) {
 		struct file_data *fdata = 0;
@@ -1130,10 +1155,19 @@
 		if (err) {
 			cleanup_current_dev();
 			kfree(fdata);
+			kref_put_mutex(&me->kref, fastrpc_channel_close,
+					&me->smd_mutex);
 		}
 		module_put(THIS_MODULE);
 	}
 	return err;
+
+completion_bail:
+	smd_close(me->chan);
+	me->chan = 0;
+smd_bail:
+	mutex_unlock(&me->smd_mutex);
+	return err;
 }
 
 
@@ -1242,7 +1276,7 @@
 	VERIFY(err, 0 == cdev_add(&me->cdev, MKDEV(MAJOR(me->dev_no), 0), 1));
 	if (err)
 		goto cdev_init_bail;
-	me->class = class_create(THIS_MODULE, "chardrv");
+	me->class = class_create(THIS_MODULE, "fastrpc");
 	VERIFY(err, !IS_ERR(me->class));
 	if (err)
 		goto class_create_bail;
@@ -1251,7 +1285,6 @@
 	VERIFY(err, !IS_ERR(me->dev));
 	if (err)
 		goto device_create_bail;
-	pr_info("'created /dev/%s c %d 0'\n", DEVICE_NAME, MAJOR(me->dev_no));
 
 	return 0;
 
diff --git a/drivers/char/diag/diag_dci.c b/drivers/char/diag/diag_dci.c
index 97dc26d..91b90a8 100644
--- a/drivers/char/diag/diag_dci.c
+++ b/drivers/char/diag/diag_dci.c
@@ -419,6 +419,8 @@
 
 	/* Notify the DCI process that the peripheral DCI Channel is up */
 	for (i = 0; i < MAX_DCI_CLIENTS; i++) {
+		if (!driver->dci_client_tbl[i].client)
+			continue;
 		if (driver->dci_client_tbl[i].list & peripheral_mask) {
 			info.si_signo = driver->dci_client_tbl[i].signal_type;
 			stat = send_sig_info(
diff --git a/drivers/char/diag/diag_masks.c b/drivers/char/diag/diag_masks.c
index 69e6250..c28b3bd 100644
--- a/drivers/char/diag/diag_masks.c
+++ b/drivers/char/diag/diag_masks.c
@@ -229,83 +229,90 @@
 static void diag_disable_log_mask(void)
 {
 	int i = 0;
-	struct mask_info *parse_ptr = (struct mask_info *)(driver->log_masks);
+	struct diag_log_mask_t *log_item = NULL;
 
-	pr_debug("diag: disable log masks\n");
-	mutex_lock(&driver->diagchar_mutex);
-	for (i = 0; i < MAX_EQUIP_ID; i++) {
-		pr_debug("diag: equip id %d\n", parse_ptr->equip_id);
-		if (!(parse_ptr->equip_id)) /* Reached a null entry */
-			break;
-		memset(driver->log_masks + parse_ptr->index, 0,
-			    (parse_ptr->num_items + 7)/8);
-		parse_ptr++;
-	}
+	mutex_lock(&driver->log_mask_mutex);
+	log_item = (struct diag_log_mask_t *)driver->log_masks;
+	for (i = 0; i < MAX_EQUIP_ID; i++, log_item++)
+		memset(log_item->ptr, 0, MAX_ITEMS_PER_EQUIP_ID);
+
 	driver->log_status = DIAG_CTRL_MASK_ALL_DISABLED;
-	mutex_unlock(&driver->diagchar_mutex);
+	mutex_unlock(&driver->log_mask_mutex);
 }
 
-int chk_equip_id_and_mask(int equip_id, uint8_t *buf)
+static int copy_log_mask_equip(int equip_id, uint8_t *buf)
 {
-	int i = 0, flag = 0, num_items, offset;
-	unsigned char *ptr_data;
-	struct mask_info *ptr = (struct mask_info *)(driver->log_masks);
+	int i, ret = 0;
+	uint8_t *temp = buf;
+	struct diag_log_mask_t *log_item = NULL;
+	uint32_t mask_size = 0;
 
-	pr_debug("diag: received equip id = %d\n", equip_id);
-	/* Check if this is valid equipment ID */
-	for (i = 0; i < MAX_EQUIP_ID; i++) {
-		if ((ptr->equip_id == equip_id) && (ptr->index != 0)) {
-			offset = ptr->index;
-			num_items = ptr->num_items;
-			flag = 1;
+	if (!buf)
+		return ret;
+
+	log_item = (struct diag_log_mask_t *)driver->log_masks;
+	for (i = 0; i < MAX_EQUIP_ID; i++, log_item++) {
+		if (log_item->equip_id != equip_id)
+			continue;
+		*(int *)temp = log_item->equip_id;
+		temp += sizeof(int);
+		*(int *)(temp) = log_item->num_items;
+		temp += sizeof(int);
+		mask_size = LOG_ITEMS_TO_SIZE(log_item->num_items);
+		if (mask_size > MAX_ITEMS_PER_EQUIP_ID) {
+			pr_err("diag: Invalid length: %d in %s, perimissible: %d",
+				mask_size, __func__, MAX_ITEMS_PER_EQUIP_ID);
 			break;
 		}
-		ptr++;
+		if (mask_size > 0) {
+			memcpy(temp, log_item->ptr, mask_size);
+			/*
+			 * Return the total number of bytes copied = size of
+			 * equip_id (int) + size of num_items (int) + mask_size
+			 */
+			ret = (2 * sizeof(int)) + mask_size;
+		}
+		break;
 	}
-	if (!flag)
-		return -EPERM;
-	ptr_data = driver->log_masks + offset;
-	memcpy(buf, ptr_data, (num_items+7)/8);
-	return 0;
+
+	return ret;
 }
 
 static void diag_update_log_mask(int equip_id, uint8_t *buf, int num_items)
 {
-	uint8_t *temp = buf;
 	int i = 0;
-	unsigned char *ptr_data;
-	int offset = (sizeof(struct mask_info))*MAX_EQUIP_ID;
-	struct mask_info *ptr = (struct mask_info *)(driver->log_masks);
+	struct diag_log_mask_t *log_item = NULL;
+	uint32_t mask_size = 0;
 
-	pr_debug("diag: received equip id = %d\n", equip_id);
-	mutex_lock(&driver->diagchar_mutex);
-	/* Check if we already know index of this equipment ID */
-	for (i = 0; i < MAX_EQUIP_ID; i++) {
-		if ((ptr->equip_id == equip_id) && (ptr->index != 0)) {
-			offset = ptr->index;
-			break;
-		}
-		if ((ptr->equip_id == 0) && (ptr->index == 0)) {
-			/* Reached a null entry */
-			ptr->equip_id = equip_id;
-			ptr->num_items = num_items;
-			ptr->index = driver->log_masks_length;
-			offset = driver->log_masks_length;
-			driver->log_masks_length += ((num_items+7)/8);
-			break;
-		}
-		ptr++;
+	mutex_lock(&driver->log_mask_mutex);
+	driver->log_status = DIAG_CTRL_MASK_INVALID;
+	if (!buf || (equip_id < 0 || equip_id >= MAX_EQUIP_ID) ||
+							num_items < 1) {
+		pr_err("diag: Invalid params in %s, buf: %x equip_id: %d, num_items: %d\n",
+		       __func__, (unsigned int)buf, equip_id, num_items);
+		mutex_unlock(&driver->log_mask_mutex);
+		return;
 	}
-	ptr_data = driver->log_masks + offset;
-	if (CHK_OVERFLOW(driver->log_masks, ptr_data, driver->log_masks
-					 + LOG_MASK_SIZE, (num_items+7)/8)) {
-		memcpy(ptr_data, temp, (num_items+7)/8);
+	mask_size = LOG_ITEMS_TO_SIZE(num_items);
+	if (mask_size > MAX_ITEMS_PER_EQUIP_ID) {
+		pr_err("diag: In %s, Invalid mask_size %d\n", __func__,
+								mask_size);
+		mutex_unlock(&driver->log_mask_mutex);
+		return;
+	}
+
+	log_item = (struct diag_log_mask_t *)driver->log_masks;
+	for (i = 0; i < MAX_EQUIP_ID; i++, log_item++) {
+		if (log_item->equip_id != equip_id)
+			continue;
+		/* Found the equip id */
+		log_item->num_items = num_items;
+		if (mask_size > 0)
+			memcpy(log_item->ptr, buf, mask_size);
 		driver->log_status = DIAG_CTRL_MASK_VALID;
-	} else {
-		pr_err("diag: Not enough buffer space for LOG_MASK\n");
-		driver->log_status = DIAG_CTRL_MASK_INVALID;
+		break;
 	}
-	mutex_unlock(&driver->diagchar_mutex);
+	mutex_unlock(&driver->log_mask_mutex);
 }
 
 void diag_mask_update_fn(struct work_struct *work)
@@ -335,72 +342,76 @@
 void diag_send_log_mask_update(smd_channel_t *ch, int equip_id)
 {
 	void *buf = driver->buf_log_mask_update;
-	int header_size = sizeof(struct diag_ctrl_log_mask);
-	struct mask_info *ptr = (struct mask_info *)driver->log_masks;
-	int i, size, wr_size = -ENOMEM, retry_count = 0;
+	struct diag_log_mask_t *log_item = NULL;
+	struct diag_ctrl_log_mask ctrl_pkt;
+	uint32_t log_mask_size = 0;
+	int wr_size = -ENOMEM, retry_count = 0;
+	int i, header_size, send_once = 0;
 
+	header_size = sizeof(struct diag_ctrl_log_mask);
+	log_item = (struct diag_log_mask_t *)driver->log_masks;
 	mutex_lock(&driver->diag_cntl_mutex);
-	for (i = 0; i < MAX_EQUIP_ID; i++) {
-		size = (ptr->num_items+7)/8;
-		/* reached null entry */
-		if ((ptr->equip_id == 0) && (ptr->index == 0))
-			break;
-		driver->log_mask->cmd_type = DIAG_CTRL_MSG_LOG_MASK;
-		driver->log_mask->num_items = ptr->num_items;
-		driver->log_mask->data_len  = 11 + size;
-		driver->log_mask->stream_id = 1; /* 2, if dual stream */
-		driver->log_mask->equip_id = ptr->equip_id;
-		driver->log_mask->status = driver->log_status;
+	for (i = 0; i < MAX_EQUIP_ID; i++, log_item++) {
+		if (equip_id != i && equip_id != ALL_EQUIP_ID)
+			continue;
+		log_mask_size = LOG_ITEMS_TO_SIZE(log_item->num_items);
+		ctrl_pkt.cmd_type = DIAG_CTRL_MSG_LOG_MASK;
+		ctrl_pkt.data_len = 11 + log_mask_size;
+		ctrl_pkt.stream_id = 1;
+		ctrl_pkt.status = driver->log_status;
 		switch (driver->log_status) {
 		case DIAG_CTRL_MASK_ALL_DISABLED:
-			driver->log_mask->log_mask_size = 0;
+			ctrl_pkt.equip_id = 0;
+			ctrl_pkt.num_items = 0;
+			ctrl_pkt.log_mask_size = 0;
+			send_once = 1;
 			break;
 		case DIAG_CTRL_MASK_ALL_ENABLED:
-			driver->log_mask->log_mask_size = 0;
+			ctrl_pkt.equip_id = 0;
+			ctrl_pkt.num_items = 0;
+			ctrl_pkt.log_mask_size = 0;
+			send_once = 1;
 			break;
 		case DIAG_CTRL_MASK_VALID:
-			driver->log_mask->log_mask_size = size;
+			ctrl_pkt.equip_id = i;
+			ctrl_pkt.num_items = log_item->num_items;
+			ctrl_pkt.log_mask_size = log_mask_size;
+			send_once = 0;
 			break;
 		default:
-			/* Log status is not set or the buffer is corrupted */
 			pr_err("diag: In %s, invalid status %d", __func__,
-							driver->log_status);
-			driver->log_mask->status = DIAG_CTRL_MASK_INVALID;
-		}
-
-		if (driver->log_mask->status == DIAG_CTRL_MASK_INVALID) {
+				 driver->log_status);
 			mutex_unlock(&driver->diag_cntl_mutex);
 			return;
 		}
-		/* send only desired update, NOT ALL */
-		if (equip_id == ALL_EQUIP_ID || equip_id ==
-					 driver->log_mask->equip_id) {
-			memcpy(buf, driver->log_mask, header_size);
-			if (driver->log_status == DIAG_CTRL_MASK_VALID)
-				memcpy(buf + header_size,
-				       driver->log_masks+ptr->index, size);
-			if (ch) {
-				while (retry_count < 3) {
-					wr_size = smd_write(ch, buf,
-							 header_size + size);
-					if (wr_size == -ENOMEM) {
-						retry_count++;
-						usleep_range(10000, 10100);
-					} else
-						break;
-				}
-				if (wr_size != header_size + size)
-					pr_err("diag: log mask update failed %d, tried %d",
-						wr_size, header_size + size);
-				else
-					pr_debug("diag: updated log equip ID %d,len %d\n",
-					driver->log_mask->equip_id,
-					driver->log_mask->log_mask_size);
-			} else
-				pr_err("diag: ch not valid for log update\n");
+		memcpy(buf, &ctrl_pkt, header_size);
+		if (log_mask_size > 0) {
+			memcpy(buf + header_size, log_item->ptr,
+			       log_mask_size);
 		}
-		ptr++;
+
+		if (ch) {
+			while (retry_count < 3) {
+				wr_size = smd_write(ch, buf,
+						header_size + log_mask_size);
+				if (wr_size == -ENOMEM) {
+					retry_count++;
+					usleep_range(10000, 10100);
+				} else
+				break;
+			}
+			if (wr_size != header_size + log_mask_size)
+				pr_err("diag: log mask update failed %d, tried %d",
+					wr_size, header_size + log_mask_size);
+			else
+				pr_debug("diag: updated log equip ID %d,len %d\n",
+					 i, log_mask_size);
+		} else
+			pr_err("diag: ch not valid for log update\n");
+		if (send_once)
+			break;
 	}
+
 	mutex_unlock(&driver->diag_cntl_mutex);
 }
 
@@ -623,7 +634,7 @@
 	int ssid_first, ssid_last, ssid_range;
 	int rt_mask, rt_first_ssid, rt_last_ssid, rt_mask_size;
 	uint8_t *rt_mask_ptr;
-	int equip_id, num_items;
+	int equip_id, copy_len;
 #if defined(CONFIG_DIAG_OVER_USB)
 	int payload_length;
 #endif
@@ -631,7 +642,6 @@
 	/* Set log masks */
 	if (*buf == 0x73 && *(int *)(buf+4) == 3) {
 		buf += 8;
-		/* Read Equip ID and pass as first param below*/
 		diag_update_log_mask(*(int *)buf, buf+8, *(int *)(buf+4));
 		diag_update_userspace_clients(LOG_MASKS_TYPE);
 #if defined(CONFIG_DIAG_OVER_USB)
@@ -639,7 +649,8 @@
 			driver->apps_rsp_buf[0] = 0x73;
 			*(int *)(driver->apps_rsp_buf + 4) = 0x3; /* op. ID */
 			*(int *)(driver->apps_rsp_buf + 8) = 0x0; /* success */
-			payload_length = 8 + ((*(int *)(buf + 4)) + 7)/8;
+			payload_length = 8 +
+					LOG_ITEMS_TO_SIZE(*(int *)(buf + 4));
 			if (payload_length > APPS_BUF_SIZE - 12) {
 				pr_err("diag: log masks: buffer overflow\n");
 				return -EIO;
@@ -663,20 +674,16 @@
 		if (!(driver->smd_data[MODEM_DATA].ch) &&
 						chk_apps_only()) {
 			equip_id = *(int *)(buf + 8);
-			num_items = *(int *)(buf + 12);
 			driver->apps_rsp_buf[0] = 0x73;
 			driver->apps_rsp_buf[1] = 0x0;
 			driver->apps_rsp_buf[2] = 0x0;
 			driver->apps_rsp_buf[3] = 0x0;
 			*(int *)(driver->apps_rsp_buf + 4) = 0x4;
-			if (!chk_equip_id_and_mask(equip_id,
-				driver->apps_rsp_buf+20))
-				*(int *)(driver->apps_rsp_buf + 8) = 0x0;
-			else
-				*(int *)(driver->apps_rsp_buf + 8) = 0x1;
-			*(int *)(driver->apps_rsp_buf + 12) = equip_id;
-			*(int *)(driver->apps_rsp_buf + 16) = num_items;
-			encode_rsp_and_send(20+(num_items+7)/8-1);
+			copy_len = copy_log_mask_equip(equip_id,
+						driver->apps_rsp_buf + 12);
+			*(int *)(driver->apps_rsp_buf + 8) =
+						(copy_len == 0) ? 1 : 0;
+			encode_rsp_and_send(12 + copy_len);
 			return 0;
 		}
 #endif
@@ -858,6 +865,19 @@
 	return  packet_type;
 }
 
+static void diag_log_mask_init(void)
+{
+	struct diag_log_mask_t *log_item = NULL;
+	uint8_t i;
+
+	mutex_init(&driver->log_mask_mutex);
+	log_item = (struct diag_log_mask_t *)driver->log_masks;
+	for (i = 0; i < MAX_EQUIP_ID; i++, log_item++) {
+		log_item->equip_id = i;
+		log_item->num_items = LOG_GET_ITEM_NUM(log_code_last_tbl[i]);
+	}
+}
+
 void diag_masks_init(void)
 {
 	driver->event_status = DIAG_CTRL_MASK_INVALID;
@@ -936,7 +956,7 @@
 			goto err;
 		kmemleak_not_leak(driver->log_masks);
 	}
-	driver->log_masks_length = (sizeof(struct mask_info))*MAX_EQUIP_ID;
+	diag_log_mask_init();
 	if (driver->event_masks == NULL) {
 		driver->event_masks = kzalloc(EVENT_MASK_SIZE, GFP_KERNEL);
 		if (driver->event_masks == NULL)
diff --git a/drivers/char/diag/diag_masks.h b/drivers/char/diag/diag_masks.h
index c66a4b6..856d4fc 100644
--- a/drivers/char/diag/diag_masks.h
+++ b/drivers/char/diag/diag_masks.h
@@ -15,7 +15,12 @@
 
 #include "diagfwd.h"
 
-int chk_equip_id_and_mask(int equip_id, uint8_t *buf);
+struct diag_log_mask_t {
+	uint8_t equip_id;
+	uint32_t num_items;
+	uint8_t ptr[MAX_ITEMS_PER_EQUIP_ID];
+} __packed;
+
 void diag_send_event_mask_update(smd_channel_t *, int num_bytes);
 void diag_send_msg_mask_update(smd_channel_t *, int ssid_first,
 					 int ssid_last, int proc);
diff --git a/drivers/char/diag/diagchar.h b/drivers/char/diag/diagchar.h
index 9d9d89b..5be77c4 100644
--- a/drivers/char/diag/diagchar.h
+++ b/drivers/char/diag/diagchar.h
@@ -82,11 +82,14 @@
  * And there are MSG_MASK_TBL_CNT rows.
  */
 #define MSG_MASK_SIZE		((MAX_SSID_PER_RANGE+3) * 4 * MSG_MASK_TBL_CNT)
-#define LOG_MASK_SIZE 8000
+#define MAX_EQUIP_ID		16
+#define MAX_ITEMS_PER_EQUIP_ID	512
+#define LOG_MASK_ITEM_SIZE	(5 + MAX_ITEMS_PER_EQUIP_ID)
+#define LOG_MASK_SIZE		(MAX_EQUIP_ID * LOG_MASK_ITEM_SIZE)
 #define EVENT_MASK_SIZE 1000
 #define USER_SPACE_DATA 8192
 #define PKT_SIZE 4096
-#define MAX_EQUIP_ID 15
+
 #define DIAG_CTRL_MSG_LOG_MASK	9
 #define DIAG_CTRL_MSG_EVENT_MASK	10
 #define DIAG_CTRL_MSG_F3_MASK	11
@@ -334,6 +337,7 @@
 	struct diag_ctrl_log_mask *log_mask;
 	struct diag_ctrl_msg_mask *msg_mask;
 	struct diag_ctrl_feature_mask *feature_mask;
+	struct mutex log_mask_mutex;
 	/* State for diag forwarding */
 	struct diag_smd_info smd_data[NUM_SMD_DATA_CHANNELS];
 	struct diag_smd_info smd_cntl[NUM_SMD_CONTROL_CHANNELS];
@@ -380,7 +384,6 @@
 	uint8_t msg_status;
 	uint8_t *log_masks;
 	uint8_t log_status;
-	int log_masks_length;
 	uint8_t *event_masks;
 	uint8_t event_status;
 	uint8_t log_on_demand_support;
diff --git a/drivers/char/diag/diagchar_core.c b/drivers/char/diag/diagchar_core.c
index 19ff6f4..f7c0d24 100644
--- a/drivers/char/diag/diagchar_core.c
+++ b/drivers/char/diag/diagchar_core.c
@@ -1485,26 +1485,25 @@
 		return err;
 	}
 	if (pkt_type == CALLBACK_DATA_TYPE) {
-		if (payload_size > itemsize) {
+		if (payload_size > driver->itemsize) {
 			pr_err("diag: Dropping packet, packet payload size crosses 4KB limit. Current payload size %d\n",
 				payload_size);
 			driver->dropped_count++;
 			return -EBADMSG;
 		}
 
-		mutex_lock(&driver->diagchar_mutex);
 		buf_copy = diagmem_alloc(driver, payload_size, POOL_TYPE_COPY);
 		if (!buf_copy) {
 			driver->dropped_count++;
-			mutex_unlock(&driver->diagchar_mutex);
 			return -ENOMEM;
 		}
 
 		err = copy_from_user(buf_copy, buf + 4, payload_size);
 		if (err) {
 			pr_err("diag: copy failed for user space data\n");
-			ret = -EIO;
-			goto fail_free_copy;
+			diagmem_free(driver, buf_copy, POOL_TYPE_COPY);
+			buf_copy = NULL;
+			return -EIO;
 		}
 		/* Check for proc_type */
 		remote_proc = diag_get_remote(*(int *)buf_copy);
@@ -1513,7 +1512,9 @@
 			wait_event_interruptible(driver->wait_q,
 				 (driver->in_busy_pktdata == 0));
 			ret = diag_process_apps_pkt(buf_copy, payload_size);
-			goto fail_free_copy;
+			diagmem_free(driver, buf_copy, POOL_TYPE_COPY);
+			buf_copy = NULL;
+			return ret;
 		}
 		/* The packet is for the remote processor */
 		token_offset = 4;
@@ -1526,7 +1527,7 @@
 							1 + payload_size);
 		send.terminate = 1;
 
-
+		mutex_lock(&driver->diagchar_mutex);
 		if (!buf_hdlc)
 			buf_hdlc = diagmem_alloc(driver, HDLC_OUT_BUF_SIZE,
 							POOL_TYPE_HDLC);
diff --git a/drivers/char/diag/diagchar_hdlc.c b/drivers/char/diag/diagchar_hdlc.c
index 7b24591..3e38a3c 100644
--- a/drivers/char/diag/diagchar_hdlc.c
+++ b/drivers/char/diag/diagchar_hdlc.c
@@ -207,15 +207,11 @@
 							  ^ ESC_MASK;
 				}
 			} else if (src_byte == CONTROL_CHAR) {
-				dest_ptr[len++] = src_byte;
-				/*
-				 * If this is the first byte in the message,
-				 * then it is part of the command. Otherwise,
-				 * consider it as the last byte of the
-				 * message.
-				 */
 				if (msg_start && i == 0 && src_length > 1)
 					continue;
+				/* Byte 0x7E will be considered
+					as end of packet */
+				dest_ptr[len++] = src_byte;
 				i++;
 				pkt_bnd = 1;
 				break;
diff --git a/drivers/char/diag/diagfwd.c b/drivers/char/diag/diagfwd.c
index 1a7b2f8..447cb39 100644
--- a/drivers/char/diag/diagfwd.c
+++ b/drivers/char/diag/diagfwd.c
@@ -390,7 +390,7 @@
 	 * Do not work with ref_count here in case
 	 * of spurious interrupt
 	 */
-	if (lock->enabled)
+	if (lock->enabled && !wake_lock_active(&lock->read_lock))
 		wake_lock(&lock->read_lock);
 	spin_unlock_irqrestore(&lock->read_spinlock, read_lock_flags);
 }
@@ -1051,9 +1051,10 @@
 	return is_mode_reset;
 }
 
-void diag_send_data(struct diag_master_table entry, unsigned char *buf,
+int diag_send_data(struct diag_master_table entry, unsigned char *buf,
 					 int len, int type)
 {
+	int success = 1;
 	driver->pkt_length = len;
 
 	/* If the process_id corresponds to an apps process */
@@ -1069,13 +1070,19 @@
 			if (entry.client_id < NUM_SMD_DATA_CHANNELS) {
 				struct diag_smd_info *smd_info;
 				int index = entry.client_id;
+				if (!driver->rcvd_feature_mask[
+					entry.client_id]) {
+					pr_debug("diag: In %s, feature mask for peripheral: %d not received yet\n",
+						__func__, entry.client_id);
+					return 0;
+				}
 				/*
 				 * Mode reset should work even if
 				 * modem is down
 				 */
 				if ((index == MODEM_DATA) &&
 					diag_check_mode_reset(buf)) {
-					return;
+					return 1;
 				}
 				smd_info = (driver->separate_cmdrsp[index] &&
 						index < NUM_SMD_CMD_CHANNELS) ?
@@ -1095,9 +1102,12 @@
 			} else {
 				pr_alert("diag: In %s, incorrect channel: %d",
 					__func__, entry.client_id);
+				success = 0;
 			}
 		}
 	}
+
+	return success;
 }
 
 void diag_process_stm_mask(uint8_t cmd, uint8_t data_mask, int data_type,
@@ -1191,6 +1201,7 @@
 	unsigned char *temp = buf;
 	int data_type;
 	int mask_ret;
+	int status = 0;
 #if defined(CONFIG_DIAG_OVER_USB)
 	unsigned char *ptr;
 #endif
@@ -1217,14 +1228,15 @@
 	pr_debug("diag: %d %d %d", cmd_code, subsys_id, subsys_cmd_code);
 	for (i = 0; i < diag_max_reg; i++) {
 		entry = driver->table[i];
-		if (entry.process_id != NO_PROCESS &&
-				driver->rcvd_feature_mask[entry.client_id]) {
+		if (entry.process_id != NO_PROCESS) {
 			if (entry.cmd_code == cmd_code && entry.subsys_id ==
 				 subsys_id && entry.cmd_code_lo <=
 							 subsys_cmd_code &&
 				  entry.cmd_code_hi >= subsys_cmd_code) {
-				diag_send_data(entry, buf, len, data_type);
-				packet_type = 0;
+				status = diag_send_data(entry, buf, len,
+								data_type);
+				if (status)
+					packet_type = 0;
 			} else if (entry.cmd_code == 255
 				  && cmd_code == 75) {
 				if (entry.subsys_id ==
@@ -1233,9 +1245,10 @@
 					subsys_cmd_code &&
 					 entry.cmd_code_hi >=
 					subsys_cmd_code) {
-					diag_send_data(entry, buf, len,
-								 data_type);
-					packet_type = 0;
+					status = diag_send_data(entry, buf,
+								len, data_type);
+					if (status)
+						packet_type = 0;
 				}
 			} else if (entry.cmd_code == 255 &&
 				  entry.subsys_id == 255) {
@@ -1243,9 +1256,10 @@
 						 cmd_code &&
 						 entry.
 						cmd_code_hi >= cmd_code) {
-					diag_send_data(entry, buf, len,
+					status = diag_send_data(entry, buf, len,
 								 data_type);
-					packet_type = 0;
+					if (status)
+						packet_type = 0;
 				}
 			}
 		}
@@ -1280,22 +1294,38 @@
 		driver->apps_rsp_buf[0] = 0x73;
 		*(int *)(driver->apps_rsp_buf + 4) = 0x1; /* operation ID */
 		*(int *)(driver->apps_rsp_buf + 8) = 0x0; /* success code */
-		*(int *)(driver->apps_rsp_buf + 12) = LOG_GET_ITEM_NUM(LOG_0);
-		*(int *)(driver->apps_rsp_buf + 16) = LOG_GET_ITEM_NUM(LOG_1);
-		*(int *)(driver->apps_rsp_buf + 20) = LOG_GET_ITEM_NUM(LOG_2);
-		*(int *)(driver->apps_rsp_buf + 24) = LOG_GET_ITEM_NUM(LOG_3);
-		*(int *)(driver->apps_rsp_buf + 28) = LOG_GET_ITEM_NUM(LOG_4);
-		*(int *)(driver->apps_rsp_buf + 32) = LOG_GET_ITEM_NUM(LOG_5);
-		*(int *)(driver->apps_rsp_buf + 36) = LOG_GET_ITEM_NUM(LOG_6);
-		*(int *)(driver->apps_rsp_buf + 40) = LOG_GET_ITEM_NUM(LOG_7);
-		*(int *)(driver->apps_rsp_buf + 44) = LOG_GET_ITEM_NUM(LOG_8);
-		*(int *)(driver->apps_rsp_buf + 48) = LOG_GET_ITEM_NUM(LOG_9);
-		*(int *)(driver->apps_rsp_buf + 52) = LOG_GET_ITEM_NUM(LOG_10);
-		*(int *)(driver->apps_rsp_buf + 56) = LOG_GET_ITEM_NUM(LOG_11);
-		*(int *)(driver->apps_rsp_buf + 60) = LOG_GET_ITEM_NUM(LOG_12);
-		*(int *)(driver->apps_rsp_buf + 64) = LOG_GET_ITEM_NUM(LOG_13);
-		*(int *)(driver->apps_rsp_buf + 68) = LOG_GET_ITEM_NUM(LOG_14);
-		*(int *)(driver->apps_rsp_buf + 72) = LOG_GET_ITEM_NUM(LOG_15);
+		*(int *)(driver->apps_rsp_buf + 12) =
+				LOG_GET_ITEM_NUM(log_code_last_tbl[0]);
+		*(int *)(driver->apps_rsp_buf + 16) =
+				LOG_GET_ITEM_NUM(log_code_last_tbl[1]);
+		*(int *)(driver->apps_rsp_buf + 20) =
+				LOG_GET_ITEM_NUM(log_code_last_tbl[2]);
+		*(int *)(driver->apps_rsp_buf + 24) =
+				LOG_GET_ITEM_NUM(log_code_last_tbl[3]);
+		*(int *)(driver->apps_rsp_buf + 28) =
+				LOG_GET_ITEM_NUM(log_code_last_tbl[4]);
+		*(int *)(driver->apps_rsp_buf + 32) =
+				LOG_GET_ITEM_NUM(log_code_last_tbl[5]);
+		*(int *)(driver->apps_rsp_buf + 36) =
+				LOG_GET_ITEM_NUM(log_code_last_tbl[6]);
+		*(int *)(driver->apps_rsp_buf + 40) =
+				LOG_GET_ITEM_NUM(log_code_last_tbl[7]);
+		*(int *)(driver->apps_rsp_buf + 44) =
+				LOG_GET_ITEM_NUM(log_code_last_tbl[8]);
+		*(int *)(driver->apps_rsp_buf + 48) =
+				LOG_GET_ITEM_NUM(log_code_last_tbl[9]);
+		*(int *)(driver->apps_rsp_buf + 52) =
+				LOG_GET_ITEM_NUM(log_code_last_tbl[10]);
+		*(int *)(driver->apps_rsp_buf + 56) =
+				LOG_GET_ITEM_NUM(log_code_last_tbl[11]);
+		*(int *)(driver->apps_rsp_buf + 60) =
+				LOG_GET_ITEM_NUM(log_code_last_tbl[12]);
+		*(int *)(driver->apps_rsp_buf + 64) =
+				LOG_GET_ITEM_NUM(log_code_last_tbl[13]);
+		*(int *)(driver->apps_rsp_buf + 68) =
+				LOG_GET_ITEM_NUM(log_code_last_tbl[14]);
+		*(int *)(driver->apps_rsp_buf + 72) =
+				LOG_GET_ITEM_NUM(log_code_last_tbl[15]);
 		encode_rsp_and_send(75);
 		return 0;
 	}
@@ -2450,7 +2480,7 @@
 	driver->buf_tbl_size = (buf_tbl_size < driver->poolsize_hdlc) ?
 				driver->poolsize_hdlc : buf_tbl_size;
 	driver->supports_separate_cmdrsp = device_supports_separate_cmdrsp();
-	driver->supports_apps_hdlc_encoding = 0;
+	driver->supports_apps_hdlc_encoding = 1;
 	mutex_init(&driver->diag_hdlc_mutex);
 	mutex_init(&driver->diag_cntl_mutex);
 
diff --git a/drivers/char/diag/diagfwd_cntl.c b/drivers/char/diag/diagfwd_cntl.c
index d784678..d3c311d 100644
--- a/drivers/char/diag/diagfwd_cntl.c
+++ b/drivers/char/diag/diagfwd_cntl.c
@@ -347,12 +347,17 @@
 	char buf[sizeof(struct diag_ctrl_msg_diagmode)];
 	int msg_size = sizeof(struct diag_ctrl_msg_diagmode);
 	int wr_size = -ENOMEM, retry_count = 0, timer;
+	struct diag_smd_info *data = NULL;
 
 	/* For now only allow the modem to receive the message */
 	if (!smd_info || smd_info->type != SMD_CNTL_TYPE ||
 		(smd_info->peripheral != MODEM_DATA))
 		return;
 
+	data = &driver->smd_data[smd_info->peripheral];
+	if (!data)
+		return;
+
 	mutex_lock(&driver->diag_cntl_mutex);
 	diagmode.ctrl_pkt_id = DIAG_CTRL_MSG_DIAGMODE;
 	diagmode.ctrl_pkt_data_len = 36;
@@ -388,11 +393,9 @@
 				for (timer = 0; timer < 5; timer++)
 					udelay(2000);
 			} else {
-				struct diag_smd_info *data =
+				data =
 				&driver->smd_data[smd_info->peripheral];
 				driver->real_time_mode = real_time;
-				process_lock_enabling(&data->nrt_lock,
-								real_time);
 				break;
 			}
 		}
@@ -404,6 +407,7 @@
 		pr_err("diag: ch invalid, feature update on proc %d\n",
 				smd_info->peripheral);
 	}
+	process_lock_enabling(&data->nrt_lock, real_time);
 
 	mutex_unlock(&driver->diag_cntl_mutex);
 }
diff --git a/drivers/coresight/coresight-tmc.c b/drivers/coresight/coresight-tmc.c
index 8267293..f35ba53 100644
--- a/drivers/coresight/coresight-tmc.c
+++ b/drivers/coresight/coresight-tmc.c
@@ -1407,32 +1407,39 @@
 
 	ret = alloc_chrdev_region(&dev, 0, 1, drvdata->byte_cntr_node);
 	if (ret)
-		goto dev_err0;
+		goto err0;
+
 	cdev_init(&drvdata->byte_cntr_dev, &byte_cntr_fops);
+
 	drvdata->byte_cntr_dev.owner = THIS_MODULE;
 	drvdata->byte_cntr_dev.ops = &byte_cntr_fops;
 	ret = cdev_add(&drvdata->byte_cntr_dev, dev, 1);
 	if (ret)
-		goto dev_err1;
+		goto err1;
+
 	drvdata->byte_cntr_class = class_create(THIS_MODULE,
 						drvdata->byte_cntr_node);
-	if (!drvdata->byte_cntr_class)
-		goto dev_err2;
+	if (IS_ERR(drvdata->byte_cntr_class)) {
+		ret = PTR_ERR(drvdata->byte_cntr_class);
+		goto err2;
+	}
+
 	device = device_create(drvdata->byte_cntr_class, NULL,
 			       drvdata->byte_cntr_dev.dev, drvdata,
 			       drvdata->byte_cntr_node);
 	if (IS_ERR(device)) {
 		ret = PTR_ERR(device);
-		goto dev_err3;
+		goto err3;
 	}
+
 	return 0;
-dev_err3:
+err3:
 	class_destroy(drvdata->byte_cntr_class);
-dev_err2:
+err2:
 	cdev_del(&drvdata->byte_cntr_dev);
-dev_err1:
+err1:
 	unregister_chrdev_region(drvdata->byte_cntr_dev.dev, 1);
-dev_err0:
+err0:
 	return ret;
 }
 
@@ -1466,6 +1473,7 @@
 		dev_err(&pdev->dev, "Byte-cntr-irq not specified\n");
 		goto err;
 	}
+
 	ret = devm_request_irq(&pdev->dev, drvdata->byte_cntr_irq,
 			tmc_etr_byte_cntr_irq,
 			IRQF_TRIGGER_RISING | IRQF_SHARED,
@@ -1474,17 +1482,27 @@
 		dev_err(&pdev->dev, "Request irq failed\n");
 		goto err;
 	}
+
 	init_waitqueue_head(&drvdata->wq);
 	node_size += strlen(node_name);
+
 	drvdata->byte_cntr_node = devm_kzalloc(&pdev->dev,
-				node_size, GFP_KERNEL);
+					       node_size, GFP_KERNEL);
+	if (!drvdata->byte_cntr_node) {
+		dev_err(&pdev->dev, "Byte cntr node name allocation failed\n");
+		ret = -ENOMEM;
+		goto err;
+	}
+
 	strlcpy(drvdata->byte_cntr_node, node_name, node_size);
 	strlcat(drvdata->byte_cntr_node, "-stream", node_size);
+
 	ret = tmc_etr_byte_cntr_dev_register(drvdata);
 	if (ret) {
 		dev_err(&pdev->dev, "Byte cntr node not registered\n");
 		goto err;
 	}
+
 	dev_info(&pdev->dev, "Byte Counter feature enabled\n");
 	return 0;
 err:
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index e6b2a3c..af494c6 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -144,6 +144,7 @@
 	unsigned int sampling_down_factor;
 	int          powersave_bias;
 	unsigned int io_is_busy;
+	unsigned int input_boost;
 } dbs_tuners_ins = {
 	.up_threshold_multi_core = DEF_FREQUENCY_UP_THRESHOLD,
 	.up_threshold = DEF_FREQUENCY_UP_THRESHOLD,
@@ -155,6 +156,7 @@
 	.powersave_bias = 0,
 	.sync_freq = 0,
 	.optimal_freq = 0,
+	.input_boost = 0,
 };
 
 static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall)
@@ -319,6 +321,7 @@
 show_one(optimal_freq, optimal_freq);
 show_one(up_threshold_any_cpu_load, up_threshold_any_cpu_load);
 show_one(sync_freq, sync_freq);
+show_one(input_boost, input_boost);
 
 static ssize_t show_powersave_bias
 (struct kobject *kobj, struct attribute *attr, char *buf)
@@ -396,6 +399,18 @@
 	return count;
 }
 
+static ssize_t store_input_boost(struct kobject *a, struct attribute *b,
+				const char *buf, size_t count)
+{
+	unsigned int input;
+	int ret;
+	ret = sscanf(buf, "%u", &input);
+	if (ret != 1)
+		return -EINVAL;
+	dbs_tuners_ins.input_boost = input;
+	return count;
+}
+
 static ssize_t store_sync_freq(struct kobject *a, struct attribute *b,
 				   const char *buf, size_t count)
 {
@@ -680,6 +695,7 @@
 define_one_global_rw(optimal_freq);
 define_one_global_rw(up_threshold_any_cpu_load);
 define_one_global_rw(sync_freq);
+define_one_global_rw(input_boost);
 
 static struct attribute *dbs_attributes[] = {
 	&sampling_rate_min.attr,
@@ -694,6 +710,7 @@
 	&optimal_freq.attr,
 	&up_threshold_any_cpu_load.attr,
 	&sync_freq.attr,
+	&input_boost.attr,
 	NULL
 };
 
@@ -1006,6 +1023,7 @@
 	struct cpu_dbs_info_s *this_dbs_info;
 	struct dbs_work_struct *dbs_work;
 	unsigned int cpu;
+	unsigned int target_freq;
 
 	dbs_work = container_of(work, struct dbs_work_struct, work);
 	cpu = dbs_work->cpu;
@@ -1022,14 +1040,19 @@
 		goto bail_incorrect_governor;
 	}
 
-	if (policy->cur < policy->max) {
+	if (dbs_tuners_ins.input_boost)
+		target_freq = dbs_tuners_ins.input_boost;
+	else
+		target_freq = policy->max;
+
+	if (policy->cur < target_freq) {
 		/*
 		 * Arch specific cpufreq driver may fail.
 		 * Don't update governor frequency upon failure.
 		 */
-		if (__cpufreq_driver_target(policy, policy->max,
+		if (__cpufreq_driver_target(policy, target_freq,
 					CPUFREQ_RELATION_L) >= 0)
-			policy->cur = policy->max;
+			policy->cur = target_freq;
 
 		this_dbs_info->prev_cpu_idle = get_cpu_idle_time(cpu,
 				&this_dbs_info->prev_cpu_wall);
diff --git a/drivers/crypto/msm/qce.c b/drivers/crypto/msm/qce.c
index 7778477..8037187 100644
--- a/drivers/crypto/msm/qce.c
+++ b/drivers/crypto/msm/qce.c
@@ -1949,6 +1949,12 @@
 	else
 		q_req->cryptlen = areq->cryptlen - authsize;
 
+	if ((q_req->cryptlen > ULONG_MAX - ivsize) ||
+		(q_req->cryptlen + ivsize > ULONG_MAX - areq->assoclen)) {
+		pr_err("Integer overflow on total aead req length.\n");
+		return -EINVAL;
+	}
+
 	totallen = q_req->cryptlen + ivsize + areq->assoclen;
 	pad_len = ALIGN(totallen, ADM_CE_BLOCK_SIZE) - totallen;
 
diff --git a/drivers/crypto/msm/qce50.c b/drivers/crypto/msm/qce50.c
index 4c05978..a4154c1 100644
--- a/drivers/crypto/msm/qce50.c
+++ b/drivers/crypto/msm/qce50.c
@@ -43,13 +43,17 @@
 #define QCE_MAX_NUM_DSCR    0x500
 #define QCE_SECTOR_SIZE	    0x200
 
-static DEFINE_MUTEX(bam_register_cnt);
+static DEFINE_MUTEX(bam_register_lock);
 struct bam_registration_info {
+	struct list_head qlist;
 	uint32_t handle;
 	uint32_t cnt;
+	uint32_t bam_mem;
+	void __iomem *bam_iobase;
+	bool support_cmd_dscr;
 };
-static struct bam_registration_info bam_registry;
-static bool ce_bam_registered;
+static LIST_HEAD(qce50_bam_list);
+
 /*
  * CE HW device structure.
  * Each engine has an instance of the structure.
@@ -58,11 +62,14 @@
  */
 struct qce_device {
 	struct device *pdev;        /* Handle to platform_device structure */
+	struct bam_registration_info *pbam;
 
 	unsigned char *coh_vmem;    /* Allocated coherent virtual memory */
 	dma_addr_t coh_pmem;	    /* Allocated coherent physical memory */
 	int memsize;				/* Memory allocated */
-	int is_shared;				/* CE HW is shared */
+	uint32_t bam_mem;		/* bam physical address, from DT */
+	uint32_t bam_mem_size;		/* bam io size, from DT */
+	int is_shared;			/* CE HW is shared */
 	bool support_cmd_dscr;
 	bool support_hw_key;
 
@@ -2162,25 +2169,93 @@
 			sps_connect_info->desc.phys_base);
 	sps_free_endpoint(sps_pipe_info);
 }
-/**
- * Initialize SPS HW connected with CE core
- *
- * This function register BAM HW resources with
- * SPS driver and then initialize 2 SPS endpoints
- *
- * This function should only be called once typically
- * during driver probe.
- *
- * @pce_dev - Pointer to qce_device structure
- *
- * @return - 0 if successful else negative value.
- *
- */
-static int qce_sps_init(struct qce_device *pce_dev)
+
+static void qce_sps_release_bam(struct qce_device *pce_dev)
+{
+	struct bam_registration_info *pbam;
+
+	mutex_lock(&bam_register_lock);
+	pbam = pce_dev->pbam;
+	if (pbam == NULL)
+		goto ret;
+
+	pbam->cnt--;
+	if (pbam->cnt > 0)
+		goto ret;
+
+	if (pce_dev->ce_sps.bam_handle) {
+		sps_deregister_bam_device(pce_dev->ce_sps.bam_handle);
+
+		pr_debug("deregister bam handle %x\n",
+					pce_dev->ce_sps.bam_handle);
+		pce_dev->ce_sps.bam_handle = 0;
+	}
+	iounmap(pbam->bam_iobase);
+	pr_debug("delete bam 0x%x\n", pbam->bam_mem);
+	list_del(&pbam->qlist);
+	kfree(pbam);
+
+	pce_dev->pbam = NULL;
+ret:
+	mutex_unlock(&bam_register_lock);
+}
+
+static int qce_sps_get_bam(struct qce_device *pce_dev)
 {
 	int rc = 0;
 	struct sps_bam_props bam = {0};
-	bool register_bam = false;
+	struct bam_registration_info *pbam = NULL;
+	struct bam_registration_info *p;
+	uint32_t bam_cfg = 0 ;
+
+
+	mutex_lock(&bam_register_lock);
+
+	list_for_each_entry(p, &qce50_bam_list, qlist) {
+		if (p->bam_mem == pce_dev->bam_mem) {
+			pbam = p;  /* found */
+			break;
+		}
+	}
+
+	if (pbam) {
+		pr_debug("found bam 0x%x\n", pbam->bam_mem);
+		pbam->cnt++;
+		pce_dev->ce_sps.bam_handle =  pbam->handle;
+		pce_dev->ce_sps.bam_mem = pbam->bam_mem;
+		pce_dev->ce_sps.bam_iobase = pbam->bam_iobase;
+		pce_dev->pbam = pbam;
+		pce_dev->support_cmd_dscr = pbam->support_cmd_dscr;
+		goto ret;
+	}
+
+	pbam = kzalloc(sizeof(struct  bam_registration_info), GFP_KERNEL);
+	if (!pbam) {
+		pr_err("qce50 Memory allocation of bam FAIL, error %ld\n",
+						PTR_ERR(pbam));
+
+		rc = -ENOMEM;
+		goto ret;
+	}
+	pbam->cnt = 1;
+	pbam->bam_mem = pce_dev->bam_mem;
+	pbam->bam_iobase = ioremap_nocache(pce_dev->bam_mem,
+					pce_dev->bam_mem_size);
+	if (!pbam->bam_iobase) {
+		kfree(pbam);
+		rc = -ENOMEM;
+		pr_err("Can not map BAM io memory\n");
+		goto ret;
+	}
+	pce_dev->ce_sps.bam_mem = pbam->bam_mem;
+	pce_dev->ce_sps.bam_iobase = pbam->bam_iobase;
+	pbam->handle = 0;
+	pr_debug("allocate bam 0x%x\n", pbam->bam_mem);
+	bam_cfg = readl_relaxed(pce_dev->ce_sps.bam_iobase +
+					CRYPTO_BAM_CNFG_BITS_REG);
+	pbam->support_cmd_dscr =  (bam_cfg & CRYPTO_BAM_CD_ENABLE_MASK) ?
+					true : false;
+	pce_dev->support_cmd_dscr = pbam->support_cmd_dscr;
 
 	bam.phys_addr = pce_dev->ce_sps.bam_mem;
 	bam.virt_addr = pce_dev->ce_sps.bam_iobase;
@@ -2212,27 +2287,46 @@
 	pr_debug("bam physical base=0x%x\n", (u32)bam.phys_addr);
 	pr_debug("bam virtual base=0x%x\n", (u32)bam.virt_addr);
 
-	mutex_lock(&bam_register_cnt);
-	if (ce_bam_registered == false) {
-		bam_registry.handle = 0;
-		bam_registry.cnt = 0;
+	/* Register CE Peripheral BAM device to SPS driver */
+	rc = sps_register_bam_device(&bam, &pbam->handle);
+	if (rc) {
+		pr_err("sps_register_bam_device() failed! err=%d", rc);
+		rc = -EIO;
+		iounmap(pbam->bam_iobase);
+		kfree(pbam);
+		goto ret;
 	}
-	if ((bam_registry.handle == 0) && (bam_registry.cnt == 0)) {
-		/* Register CE Peripheral BAM device to SPS driver */
-		rc = sps_register_bam_device(&bam, &bam_registry.handle);
-		if (rc) {
-			mutex_unlock(&bam_register_cnt);
-			pr_err("sps_register_bam_device() failed! err=%d", rc);
-			return -EIO;
-		}
-		bam_registry.cnt++;
-		register_bam = true;
-		ce_bam_registered = true;
-	} else {
-		   bam_registry.cnt++;
-	}
-	mutex_unlock(&bam_register_cnt);
-	pce_dev->ce_sps.bam_handle =  bam_registry.handle;
+
+	pce_dev->pbam = pbam;
+	list_add_tail(&pbam->qlist, &qce50_bam_list);
+	pce_dev->ce_sps.bam_handle =  pbam->handle;
+
+ret:
+	mutex_unlock(&bam_register_lock);
+
+	return rc;
+}
+/**
+ * Initialize SPS HW connected with CE core
+ *
+ * This function register BAM HW resources with
+ * SPS driver and then initialize 2 SPS endpoints
+ *
+ * This function should only be called once typically
+ * during driver probe.
+ *
+ * @pce_dev - Pointer to qce_device structure
+ *
+ * @return - 0 if successful else negative value.
+ *
+ */
+static int qce_sps_init(struct qce_device *pce_dev)
+{
+	int rc = 0;
+
+	rc = qce_sps_get_bam(pce_dev);
+	if (rc)
+		return rc;
 	pr_debug("BAM device registered. bam_handle=0x%x",
 		pce_dev->ce_sps.bam_handle);
 
@@ -2253,14 +2347,7 @@
 sps_connect_consumer_err:
 	qce_sps_exit_ep_conn(pce_dev, &pce_dev->ce_sps.producer);
 sps_connect_producer_err:
-	if (register_bam) {
-		mutex_lock(&bam_register_cnt);
-		sps_deregister_bam_device(pce_dev->ce_sps.bam_handle);
-		ce_bam_registered = false;
-		bam_registry.handle = 0;
-		bam_registry.cnt = 0;
-		mutex_unlock(&bam_register_cnt);
-	}
+	qce_sps_release_bam(pce_dev);
 	return rc;
 }
 
@@ -2280,17 +2367,7 @@
 {
 	qce_sps_exit_ep_conn(pce_dev, &pce_dev->ce_sps.consumer);
 	qce_sps_exit_ep_conn(pce_dev, &pce_dev->ce_sps.producer);
-	mutex_lock(&bam_register_cnt);
-	if ((bam_registry.handle != 0) && (bam_registry.cnt == 1)) {
-		sps_deregister_bam_device(pce_dev->ce_sps.bam_handle);
-		bam_registry.cnt = 0;
-		bam_registry.handle = 0;
-	}
-	if ((bam_registry.handle != 0) && (bam_registry.cnt > 1))
-		bam_registry.cnt--;
-	mutex_unlock(&bam_register_cnt);
-
-	iounmap(pce_dev->ce_sps.bam_iobase);
+	qce_sps_release_bam(pce_dev);
 }
 
 static void _aead_sps_producer_callback(struct sps_event_notify *notify)
@@ -4069,22 +4146,15 @@
 	resource = platform_get_resource_byname(pdev, IORESOURCE_MEM,
 							"crypto-bam-base");
 	if (resource) {
-		pce_dev->ce_sps.bam_mem = resource->start;
-		pce_dev->ce_sps.bam_iobase = ioremap_nocache(resource->start,
-					resource_size(resource));
-		if (!pce_dev->ce_sps.bam_iobase) {
-			rc = -ENOMEM;
-			pr_err("Can not map BAM io memory\n");
-			goto err_getting_bam_info;
-		}
+		pce_dev->bam_mem = resource->start;
+		pce_dev->bam_mem_size = resource_size(resource);
 	} else {
 		pr_err("CRYPTO BAM mem unavailable.\n");
 		rc = -ENODEV;
 		goto err_getting_bam_info;
 	}
-	pr_warn("ce_bam_phy_reg_base=0x%x  ", pce_dev->ce_sps.bam_mem);
-	pr_warn("ce_bam_virt_reg_base=0x%x\n",
-				(uint32_t)pce_dev->ce_sps.bam_iobase);
+	pr_warn("ce_bam_phy_reg_base=0x%x  ", pce_dev->bam_mem);
+
 	resource  = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
 	if (resource) {
 		pce_dev->ce_sps.bam_irq = resource->start;
@@ -4250,7 +4320,6 @@
 void *qce_open(struct platform_device *pdev, int *rc)
 {
 	struct qce_device *pce_dev;
-	uint32_t bam_cfg = 0 ;
 
 	pce_dev = kzalloc(sizeof(struct qce_device), GFP_KERNEL);
 	if (!pce_dev) {
@@ -4293,15 +4362,9 @@
 	}
 	*rc = 0;
 
-	bam_cfg = readl_relaxed(pce_dev->ce_sps.bam_iobase +
-					CRYPTO_BAM_CNFG_BITS_REG);
-	pce_dev->support_cmd_dscr = (bam_cfg & CRYPTO_BAM_CD_ENABLE_MASK) ?
-								true : false;
 	qce_init_ce_cfg_val(pce_dev);
-	qce_setup_ce_sps_data(pce_dev);
 	qce_sps_init(pce_dev);
-
-
+	qce_setup_ce_sps_data(pce_dev);
 	qce_disable_clk(pce_dev);
 
 	return pce_dev;
@@ -4313,8 +4376,6 @@
 		dma_free_coherent(pce_dev->pdev, pce_dev->memsize,
 			pce_dev->coh_vmem, pce_dev->coh_pmem);
 err_iobase:
-	if (pce_dev->ce_sps.bam_iobase)
-		iounmap(pce_dev->ce_sps.bam_iobase);
 	if (pce_dev->iobase)
 		iounmap(pce_dev->iobase);
 err_pce_dev:
diff --git a/drivers/crypto/msm/qcedev.c b/drivers/crypto/msm/qcedev.c
index 81a90fe..4845f11 100644
--- a/drivers/crypto/msm/qcedev.c
+++ b/drivers/crypto/msm/qcedev.c
@@ -1339,7 +1339,7 @@
 				areq->cipher_op_req.vbuf.src[0].len))
 		return -EFAULT;
 
-	k_align_src += areq->cipher_op_req.vbuf.src[0].len;
+	k_align_src += byteoffset + areq->cipher_op_req.vbuf.src[0].len;
 
 	for (i = 1; i < areq->cipher_op_req.entries; i++) {
 		user_src =
@@ -1602,11 +1602,6 @@
 static int qcedev_check_cipher_key(struct qcedev_cipher_op_req *req,
 						struct qcedev_control *podev)
 {
-
-	if (req->encklen < 0) {
-		pr_err("%s: Invalid key size: %d\n", __func__, req->encklen);
-		return -EINVAL;
-	}
 	/* if intending to use HW key make sure key fields are set
 	 * correctly and HW key is indeed supported in target
 	 */
@@ -1701,6 +1696,13 @@
 			goto error;
 		}
 	}
+
+	if (req->data_len < req->byteoffset) {
+		pr_err("%s: req data length %u is less than byteoffset %u\n",
+				__func__, req->data_len, req->byteoffset);
+		goto error;
+	}
+
 	/* Ensure zer ivlen for ECB  mode  */
 	if (req->ivlen > 0) {
 		if ((req->mode == QCEDEV_AES_MODE_ECB) ||
@@ -1716,16 +1718,28 @@
 		}
 	}
 	/* Check for sum of all dst length is equal to data_len  */
-	for (i = 0; (i < QCEDEV_MAX_BUFFERS) && (total < req->data_len); i++)
+	for (i = 0; (i < QCEDEV_MAX_BUFFERS) && (total < req->data_len); i++) {
+		if (req->vbuf.dst[i].len > ULONG_MAX - total) {
+			pr_err("%s: Integer overflow on total req dst vbuf length\n",
+				__func__);
+			goto error;
+		}
 		total += req->vbuf.dst[i].len;
+	}
 	if (total != req->data_len) {
 		pr_err("%s: Total (i=%d) dst(%d) buf size != data_len (%d)\n",
 			__func__, i, total, req->data_len);
 		goto error;
 	}
 	/* Check for sum of all src length is equal to data_len  */
-	for (i = 0, total = 0; i < req->entries; i++)
+	for (i = 0, total = 0; i < req->entries; i++) {
+		if (req->vbuf.src[i].len > ULONG_MAX - total) {
+			pr_err("%s: Integer overflow on total req src vbuf length\n",
+				__func__);
+			goto error;
+		}
 		total += req->vbuf.src[i].len;
+	}
 	if (total != req->data_len) {
 		pr_err("%s: Total src(%d) buf size != data_len (%d)\n",
 			__func__, total, req->data_len);
@@ -1781,8 +1795,15 @@
 	}
 
 	/* Check for sum of all src length is equal to data_len  */
-	for (i = 0, total = 0; i < req->entries; i++)
+	for (i = 0, total = 0; i < req->entries; i++) {
+		if (req->data[i].len > ULONG_MAX - total) {
+			pr_err("%s: Integer overflow on total req buf length\n",
+				__func__);
+			goto sha_error;
+		}
 		total += req->data[i].len;
+	}
+
 	if (total != req->data_len) {
 		pr_err("%s: Total src(%d) buf size != data_len (%d)\n",
 			__func__, total, req->data_len);
@@ -2112,21 +2133,21 @@
 	int len = 0;
 
 	pstat = &_qcedev_stat;
-	len = snprintf(_debug_read_buf, DEBUG_MAX_RW_BUF - 1,
+	len = scnprintf(_debug_read_buf, DEBUG_MAX_RW_BUF - 1,
 			"\nQualcomm QCE dev driver %d Statistics:\n",
 				id + 1);
 
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   Encryption operation success       : %d\n",
 					pstat->qcedev_enc_success);
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   Encryption operation fail   : %d\n",
 					pstat->qcedev_enc_fail);
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   Decryption operation success     : %d\n",
 					pstat->qcedev_dec_success);
 
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   Encryption operation fail          : %d\n",
 					pstat->qcedev_dec_fail);
 
diff --git a/drivers/crypto/msm/qcrypto.c b/drivers/crypto/msm/qcrypto.c
index ae57d6c..6606706 100644
--- a/drivers/crypto/msm/qcrypto.c
+++ b/drivers/crypto/msm/qcrypto.c
@@ -409,7 +409,7 @@
 {
 	int i;
 
-	for (i = 0; nbytes > 0; i++, sg = scatterwalk_sg_next(sg))
+	for (i = 0; nbytes > 0 && sg != NULL; i++, sg = scatterwalk_sg_next(sg))
 		nbytes -= sg->length;
 
 	return i;
@@ -628,98 +628,98 @@
 	int len = 0;
 
 	pstat = &_qcrypto_stat;
-	len = snprintf(_debug_read_buf, DEBUG_MAX_RW_BUF - 1,
+	len = scnprintf(_debug_read_buf, DEBUG_MAX_RW_BUF - 1,
 			"\nQualcomm crypto accelerator %d Statistics:\n",
 				id + 1);
 
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   ABLK AES CIPHER encryption   : %d\n",
 					pstat->ablk_cipher_aes_enc);
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   ABLK AES CIPHER decryption   : %d\n",
 					pstat->ablk_cipher_aes_dec);
 
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   ABLK DES CIPHER encryption   : %d\n",
 					pstat->ablk_cipher_des_enc);
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   ABLK DES CIPHER decryption   : %d\n",
 					pstat->ablk_cipher_des_dec);
 
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   ABLK 3DES CIPHER encryption  : %d\n",
 					pstat->ablk_cipher_3des_enc);
 
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   ABLK 3DES CIPHER decryption  : %d\n",
 					pstat->ablk_cipher_3des_dec);
 
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   ABLK CIPHER operation success: %d\n",
 					pstat->ablk_cipher_op_success);
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   ABLK CIPHER operation fail   : %d\n",
 					pstat->ablk_cipher_op_fail);
 
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   AEAD SHA1-AES encryption      : %d\n",
 					pstat->aead_sha1_aes_enc);
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   AEAD SHA1-AES decryption      : %d\n",
 					pstat->aead_sha1_aes_dec);
 
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   AEAD SHA1-DES encryption      : %d\n",
 					pstat->aead_sha1_des_enc);
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   AEAD SHA1-DES decryption      : %d\n",
 					pstat->aead_sha1_des_dec);
 
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   AEAD SHA1-3DES encryption     : %d\n",
 					pstat->aead_sha1_3des_enc);
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   AEAD SHA1-3DES decryption     : %d\n",
 					pstat->aead_sha1_3des_dec);
 
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   AEAD CCM-AES encryption     : %d\n",
 					pstat->aead_ccm_aes_enc);
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   AEAD CCM-AES decryption     : %d\n",
 					pstat->aead_ccm_aes_dec);
 
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   AEAD operation success       : %d\n",
 					pstat->aead_op_success);
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   AEAD operation fail          : %d\n",
 					pstat->aead_op_fail);
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   AEAD bad message             : %d\n",
 					pstat->aead_bad_msg);
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   SHA1 digest			 : %d\n",
 					pstat->sha1_digest);
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   SHA256 digest		 : %d\n",
 					pstat->sha256_digest);
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   SHA  operation fail          : %d\n",
 					pstat->sha_op_fail);
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   SHA  operation success          : %d\n",
 					pstat->sha_op_success);
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   SHA1 HMAC digest			 : %d\n",
 					pstat->sha1_hmac_digest);
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   SHA256 HMAC digest		 : %d\n",
 					pstat->sha256_hmac_digest);
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   SHA HMAC operation fail          : %d\n",
 					pstat->sha_hmac_op_fail);
-	len += snprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
+	len += scnprintf(_debug_read_buf + len, DEBUG_MAX_RW_BUF - len - 1,
 			"   SHA HMAC operation success          : %d\n",
 					pstat->sha_hmac_op_success);
 	return len;
@@ -1423,8 +1423,20 @@
 
 			rctx->orig_src = req->src;
 			rctx->orig_dst = req->dst;
+
+			if ((MAX_ALIGN_SIZE*2 > ULONG_MAX - req->assoclen) ||
+				((MAX_ALIGN_SIZE*2 + req->assoclen) >
+						ULONG_MAX - qreq.authsize) ||
+				((MAX_ALIGN_SIZE*2 + req->assoclen +
+						qreq.authsize) >
+						ULONG_MAX - req->cryptlen)) {
+				pr_err("Integer overflow on aead req length.\n");
+				return -EINVAL;
+			}
+
 			rctx->data = kzalloc((req->cryptlen + qreq.assoclen +
-					qreq.authsize + 64*2), GFP_ATOMIC);
+					qreq.authsize + MAX_ALIGN_SIZE*2),
+					GFP_ATOMIC);
 			if (rctx->data == NULL) {
 				pr_err("Mem Alloc fail rctx->data, err %ld\n",
 							PTR_ERR(rctx->data));
@@ -1486,6 +1498,16 @@
 			 * include  assoicated data, ciphering data stream,
 			 * generated MAC, and CCM padding.
 			 */
+			if ((MAX_ALIGN_SIZE * 2 > ULONG_MAX - req->assoclen) ||
+				((MAX_ALIGN_SIZE * 2 + req->assoclen) >
+						ULONG_MAX - qreq.ivsize) ||
+				((MAX_ALIGN_SIZE * 2 + req->assoclen
+					+ qreq.ivsize)
+						> ULONG_MAX - req->cryptlen)) {
+				pr_err("Integer overflow on aead req length.\n");
+				return -EINVAL;
+			}
+
 			rctx->data = kzalloc(
 					(req->cryptlen +
 						req->assoclen +
diff --git a/drivers/gpu/ion/msm/ion_iommu_map.c b/drivers/gpu/ion/msm/ion_iommu_map.c
index 3e1a7ee..c2b65ba 100644
--- a/drivers/gpu/ion/msm/ion_iommu_map.c
+++ b/drivers/gpu/ion/msm/ion_iommu_map.c
@@ -285,7 +285,7 @@
 static struct ion_iommu_map *__ion_iommu_map(struct ion_iommu_meta *meta,
 		int domain_num, int partition_num, unsigned long align,
 		unsigned long iova_length, unsigned long flags,
-		unsigned long *iova)
+		ion_phys_addr_t *iova)
 {
 	struct ion_iommu_map *data;
 	int ret;
@@ -367,7 +367,7 @@
 
 int ion_map_iommu(struct ion_client *client, struct ion_handle *handle,
 			int domain_num, int partition_num, unsigned long align,
-			unsigned long iova_length, unsigned long *iova,
+			unsigned long iova_length, ion_phys_addr_t *iova,
 			unsigned long *buffer_size,
 			unsigned long flags, unsigned long iommu_flags)
 {
diff --git a/drivers/gpu/msm/a3xx_reg.h b/drivers/gpu/msm/a3xx_reg.h
index b5945da..728e90c 100644
--- a/drivers/gpu/msm/a3xx_reg.h
+++ b/drivers/gpu/msm/a3xx_reg.h
@@ -772,6 +772,9 @@
 #define SP0_ICL1_MISSES                0x1A
 #define SP_FS_CFLOW_INSTRUCTIONS       0x0C
 
+/* COUNTABLE FOR TSE PERFCOUNTER */
+#define TSE_INPUT_PRIM_NUM             0x0
+
 /* VBIF PERFCOUNTER ENA/CLR values */
 #define VBIF_PERF_CNT_0 BIT(0)
 #define VBIF_PERF_CNT_1 BIT(1)
diff --git a/drivers/gpu/msm/adreno.c b/drivers/gpu/msm/adreno.c
index 79fbd2c..becb611 100644
--- a/drivers/gpu/msm/adreno.c
+++ b/drivers/gpu/msm/adreno.c
@@ -120,6 +120,7 @@
 	.ft_pf_policy = KGSL_FT_PAGEFAULT_DEFAULT_POLICY,
 	.fast_hang_detect = 1,
 	.long_ib_detect = 1,
+	.intr_mask = 0xFFFFFFFF,
 };
 
 /* This set of registers are used for Hang detection
@@ -287,7 +288,7 @@
  */
 
 int adreno_perfcounter_read_group(struct adreno_device *adreno_dev,
-	struct kgsl_perfcounter_read_group *reads, unsigned int count)
+	struct kgsl_perfcounter_read_group __user *reads, unsigned int count)
 {
 	struct adreno_perfcounters *counters = adreno_dev->gpudev->perfcounters;
 	struct adreno_perfcount_group *group;
@@ -307,12 +308,6 @@
 	if (reads == NULL || count == 0 || count > 100)
 		return -EINVAL;
 
-	/* verify valid inputs group ids and countables */
-	for (i = 0; i < count; i++) {
-		if (reads[i].groupid >= counters->group_count)
-			return -EINVAL;
-	}
-
 	list = kmalloc(sizeof(struct kgsl_perfcounter_read_group) * count,
 			GFP_KERNEL);
 	if (!list)
@@ -326,8 +321,15 @@
 
 	/* list iterator */
 	for (j = 0; j < count; j++) {
+
 		list[j].value = 0;
 
+		/* Verify that the group ID is within range */
+		if (list[j].groupid >= counters->group_count) {
+			ret = -EINVAL;
+			goto done;
+		}
+
 		group = &(counters->groups[list[j].groupid]);
 
 		/* group/counter iterator */
@@ -335,8 +337,7 @@
 			if (group->regs[i].countable == list[j].countable) {
 				list[j].value =
 					adreno_dev->gpudev->perfcounter_read(
-					adreno_dev, list[j].groupid,
-					i, group->regs[i].offset);
+					adreno_dev, list[j].groupid, i);
 				break;
 			}
 		}
@@ -599,6 +600,33 @@
 	return -EINVAL;
 }
 
+/**
+ * adreno_perfcounter_restore() - Restore performance counters
+ * @adreno_dev: adreno device to configure
+ *
+ * Load the physical performance counters with 64 bit value which are
+ * saved on GPU power collapse.
+ */
+static inline void adreno_perfcounter_restore(struct adreno_device *adreno_dev)
+{
+	if (adreno_dev->gpudev->perfcounter_restore)
+		adreno_dev->gpudev->perfcounter_restore(adreno_dev);
+}
+
+/**
+ * adreno_perfcounter_save() - Save performance counters
+ * @adreno_dev: adreno device to configure
+ *
+ * Save the performance counter values before GPU power collapse.
+ * The saved values are restored on restart.
+ * This ensures physical counters are coherent across power-collapse.
+ */
+static inline void adreno_perfcounter_save(struct adreno_device *adreno_dev)
+{
+	if (adreno_dev->gpudev->perfcounter_save)
+		adreno_dev->gpudev->perfcounter_save(adreno_dev);
+}
+
 static irqreturn_t adreno_irq_handler(struct kgsl_device *device)
 {
 	irqreturn_t result;
@@ -951,8 +979,11 @@
 	num_iommu_units = kgsl_mmu_get_num_iommu_units(&device->mmu);
 
 	context = kgsl_context_get(device, context_id);
-	if (context == NULL)
+
+	if (context == NULL) {
+		kgsl_mmu_device_setstate(&device->mmu, KGSL_CONTEXT_INVALID);
 		return;
+	}
 
 	adreno_ctx = ADRENO_CONTEXT(context);
 
@@ -1338,7 +1369,12 @@
 		&pdata->init_level))
 		pdata->init_level = 1;
 
-	if (adreno_of_read_property(parent, "qcom,step-pwrlevel",
+	/*
+	 * qcom,step-pwrlevel isn't required so don't spam the kernel log
+	 * if it isn't found
+	 */
+
+	if (of_property_read_u32(parent, "qcom,step-pwrlevel",
 		&pdata->step_mul))
 		pdata->step_mul = 1;
 
@@ -1699,6 +1735,9 @@
 
 	adreno_perfcounter_init(device);
 
+	if (adreno_dev->gpudev->irq_init)
+		adreno_dev->gpudev->irq_init(adreno_dev);
+
 	/* Power down the device */
 	kgsl_pwrctrl_disable(device);
 
@@ -1763,11 +1802,15 @@
 		adreno_dev->gpudev->soft_reset(adreno_dev);
 	}
 
+	/* Restore performance counter registers with saved values */
+	adreno_perfcounter_restore(adreno_dev);
+
 	/* Start the GPU */
 	adreno_dev->gpudev->start(adreno_dev);
 
+	kgsl_atomic_set(&adreno_dev->hang_intr_set, 0);
 	kgsl_pwrctrl_irq(device, KGSL_PWRFLAGS_ON);
-	device->ftbl->irqctrl(device, 1);
+	device->ftbl->irqctrl(device, adreno_dev->intr_mask);
 
 	status = adreno_ringbuffer_start(&adreno_dev->ringbuffer);
 	if (status)
@@ -1818,6 +1861,9 @@
 
 	adreno_ocmem_gmem_free(adreno_dev);
 
+	/* Save physical performance counter values before GPU power down*/
+	adreno_perfcounter_save(adreno_dev);
+
 	/* Power down the device */
 	kgsl_pwrctrl_disable(device);
 
@@ -2201,8 +2247,7 @@
 	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
 	int ret;
 
-	/* If the jump table index is 0 soft reset is not supported */
-	if ((!adreno_dev->pm4_jt_idx) || (!adreno_dev->gpudev->soft_reset)) {
+	if (!adreno_dev->gpudev->soft_reset) {
 		dev_WARN_ONCE(device->dev, 1, "Soft reset not supported");
 		return -EINVAL;
 	}
@@ -2221,21 +2266,32 @@
 	/* Make sure we are totally awake */
 	kgsl_pwrctrl_enable(device);
 
+	/* save physical performance counter values before GPU soft reset */
+	adreno_perfcounter_save(adreno_dev);
+
 	/* Reset the GPU */
 	adreno_dev->gpudev->soft_reset(adreno_dev);
 
+	/* Restore physical performance counter values after soft reset */
+	adreno_perfcounter_restore(adreno_dev);
+
 	/* Reinitialize the GPU */
 	adreno_dev->gpudev->start(adreno_dev);
 
 	/* Enable IRQ */
+	kgsl_atomic_set(&adreno_dev->hang_intr_set, 0);
 	kgsl_pwrctrl_irq(device, KGSL_PWRFLAGS_ON);
-	device->ftbl->irqctrl(device, 1);
+	device->ftbl->irqctrl(device, adreno_dev->intr_mask);
 
 	/*
-	 * Restart the ringbuffer - we can go down the warm start path because
-	 * power was never yanked
+	 * If we have offsets for the jump tables we can try to do a warm start,
+	 * otherwise do a full ringbuffer restart
 	 */
-	ret = adreno_ringbuffer_warm_start(&adreno_dev->ringbuffer);
+	if (adreno_dev->pm4_jt_idx)
+		ret = adreno_ringbuffer_warm_start(&adreno_dev->ringbuffer);
+	else
+		ret = adreno_ringbuffer_start(&adreno_dev->ringbuffer);
+
 	if (ret)
 		return ret;
 
@@ -2248,12 +2304,18 @@
 _adreno_ft_restart_device(struct kgsl_device *device,
 			   struct kgsl_context *context)
 {
-	/* If device soft reset fails try hard reset */
-	if (adreno_soft_reset(device))
-		KGSL_DEV_ERR_ONCE(device, "Device soft reset failed\n");
-	else
-		/* Soft reset is successful */
-		goto reset_done;
+	/*
+	 * If device soft reset fails try hard reset, but don't attempt
+	 * soft reset on page faults. In cases of page faults, go straight
+	 * to hard reset.
+	 */
+	if (!(device->mmu.fault)) {
+		if (adreno_soft_reset(device))
+			KGSL_DEV_ERR_ONCE(device, "Device soft reset failed\n");
+		else
+			/* Soft reset is successful */
+			goto reset_done;
+	}
 
 	/* restart device */
 	if (adreno_stop(device)) {
@@ -2376,7 +2438,6 @@
 	struct adreno_context *last_active_ctx = adreno_dev->drawctxt_active;
 	unsigned int long_ib = 0;
 	static int no_context_ft;
-	struct kgsl_mmu *mmu = &device->mmu;
 
 	context = kgsl_context_get(device, ft_data->context_id);
 
@@ -2451,8 +2512,6 @@
 
 	/* Do not try to replay if hang is due to a pagefault */
 	if (context && test_bit(KGSL_CONTEXT_PAGEFAULT, &context->priv)) {
-		/* Resume MMU */
-		mmu->mmu_ops->mmu_pagefault_resume(mmu);
 		if ((ft_data->context_id == context->id) &&
 			(ft_data->global_eop == context->pagefault_ts)) {
 			ft_data->ft_policy &= ~KGSL_FT_REPLAY;
@@ -2968,6 +3027,52 @@
 				(adreno_dev->long_ib_detect ? 1 : 0));
 }
 
+/**
+ * _ft_hang_intr_status_store() -  Routine to configure GPU
+ * hang interrupt
+ * @dev: device ptr
+ * @attr: Device attribute
+ * @buf: value to write
+ * @count: size of the value to write
+ */
+static int _ft_hang_intr_status_store(struct device *dev,
+				     struct device_attribute *attr,
+				     const char *buf, size_t count)
+{
+	struct adreno_device *adreno_dev = _get_adreno_dev(dev);
+	int ret = 0;
+
+	if (adreno_dev == NULL)
+		return 0;
+
+	mutex_lock(&adreno_dev->dev.mutex);
+	if (adreno_hang_intr_supported(adreno_dev))
+		ret = _ft_sysfs_store(buf, count, &adreno_dev->hang_intr_en);
+	mutex_unlock(&adreno_dev->dev.mutex);
+
+	return ret;
+
+}
+
+/**
+ * _ft_hang_intr_status_show() -  Routine to show GPU hang
+ * interrupt enable status
+ * @dev: device ptr
+ * @attr: Device attribute
+ * @buf: value read
+ */
+static int _ft_hang_intr_status_show(struct device *dev,
+					struct device_attribute *attr,
+					char *buf)
+{
+	struct adreno_device *adreno_dev = _get_adreno_dev(dev);
+	if (adreno_dev == NULL)
+		return 0;
+
+	return snprintf(buf, PAGE_SIZE, "%d\n", (adreno_dev->hang_intr_en &&
+			(adreno_hang_intr_supported(adreno_dev))) ? 1 : 0);
+
+}
 
 #define FT_DEVICE_ATTR(name) \
 	DEVICE_ATTR(name, 0644,	_ ## name ## _show, _ ## name ## _store);
@@ -2976,6 +3081,7 @@
 FT_DEVICE_ATTR(ft_pagefault_policy);
 FT_DEVICE_ATTR(ft_fast_hang_detect);
 FT_DEVICE_ATTR(ft_long_ib_detect);
+FT_DEVICE_ATTR(ft_hang_intr_status);
 
 
 const struct device_attribute *ft_attr_list[] = {
@@ -2983,6 +3089,7 @@
 	&dev_attr_ft_pagefault_policy,
 	&dev_attr_ft_fast_hang_detect,
 	&dev_attr_ft_long_ib_detect,
+	&dev_attr_ft_hang_intr_status,
 	NULL,
 };
 
@@ -3146,6 +3253,10 @@
 	unsigned int rptr;
 
 	do {
+
+		if (kgsl_atomic_read(&adreno_dev->hang_intr_set))
+			return -ETIMEDOUT;
+
 		/*
 		 * Wait is "jiffies" first time in the loop to start
 		 * GPU stall detection immediately.
@@ -3196,6 +3307,9 @@
 			return 0;
 
 		/* Dont wait for timeout, detect hang faster.  */
+		if (kgsl_atomic_read(&adreno_dev->hang_intr_set))
+			goto err;
+
 		if (time_after(jiffies, wait_time_part)) {
 			wait_time_part = jiffies +
 				msecs_to_jiffies(KGSL_TIMEOUT_PART);
@@ -3675,16 +3789,8 @@
 				fast_hang_detected = 0;
 		}
 
-		if (fast_hang_detected) {
-			KGSL_FT_ERR(device,
-				"Proc %s, ctxt_id %d ts %d triggered fault tolerance"
-				" on global ts %d\n",
-				pid_name, context ? context->id : 0,
-				(kgsl_readtimestamp(device, context,
-				KGSL_TIMESTAMP_RETIRED) + 1),
-				curr_global_ts + 1);
+		if (fast_hang_detected)
 			return 1;
-		}
 
 		if (curr_context != NULL) {
 
@@ -4060,10 +4166,10 @@
 	}
 }
 
-void adreno_irqctrl(struct kgsl_device *device, int state)
+void adreno_irqctrl(struct kgsl_device *device, unsigned int mask)
 {
 	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
-	adreno_dev->gpudev->irq_control(adreno_dev, state);
+	adreno_dev->gpudev->irq_control(adreno_dev, mask);
 }
 
 static unsigned int adreno_gpuid(struct kgsl_device *device,
diff --git a/drivers/gpu/msm/adreno.h b/drivers/gpu/msm/adreno.h
index a837574..0ee54d0 100644
--- a/drivers/gpu/msm/adreno.h
+++ b/drivers/gpu/msm/adreno.h
@@ -127,6 +127,9 @@
 	unsigned int pix_shader_start;
 	unsigned int instruction_size;
 	unsigned int ib_check_level;
+	atomic_t hang_intr_set;
+	unsigned int hang_intr_en;
+	unsigned int intr_mask;
 	unsigned int fast_hang_detect;
 	unsigned int ft_policy;
 	unsigned int long_ib_detect;
@@ -164,12 +167,18 @@
  * @kernelcount: number of user space users of the register
  * @usercount: number of kernel users of the register
  * @offset: register hardware offset
+ * @load_bit: The bit number in LOAD register which corresponds to this counter
+ * @select: The countable register offset
+ * @value: The 64 bit countable register value
  */
 struct adreno_perfcount_register {
 	unsigned int countable;
 	unsigned int kernelcount;
 	unsigned int usercount;
 	unsigned int offset;
+	int load_bit;
+	unsigned int select;
+	uint64_t value;
 };
 
 /**
@@ -194,6 +203,9 @@
 	unsigned int group_count;
 };
 
+#define ADRENO_PERFCOUNTER_GROUP(core, name) { core##_perfcounters_##name, \
+	ARRAY_SIZE(core##_perfcounters_##name), __stringify(name) }
+
 /**
  * adreno_regs: List of registers that are used in kgsl driver for all
  * 3D devices. Each device type has different offset value for the same
@@ -286,18 +298,22 @@
 	void (*ctxt_draw_workaround)(struct adreno_device *,
 					struct adreno_context *);
 	irqreturn_t (*irq_handler)(struct adreno_device *);
-	void (*irq_control)(struct adreno_device *, int);
+	void (*irq_control)(struct adreno_device *, unsigned int);
 	unsigned int (*irq_pending)(struct adreno_device *);
+	void (*irq_init)(struct adreno_device *);
 	void * (*snapshot)(struct adreno_device *, void *, int *, int);
 	int (*rb_init)(struct adreno_device *, struct adreno_ringbuffer *);
 	void (*perfcounter_init)(struct adreno_device *);
+	void (*perfcounter_save)(struct adreno_device *);
+	void (*perfcounter_restore)(struct adreno_device *);
 	void (*start)(struct adreno_device *);
 	unsigned int (*busy_cycles)(struct adreno_device *);
 	void (*perfcounter_enable)(struct adreno_device *, unsigned int group,
 		unsigned int counter, unsigned int countable);
 	uint64_t (*perfcounter_read)(struct adreno_device *adreno_dev,
-		unsigned int group, unsigned int counter,
-		unsigned int offset);
+		unsigned int group, unsigned int counter);
+	void (*perfcounter_write)(struct adreno_device *adreno_dev,
+		unsigned int group, unsigned int counter);
 	int (*coresight_enable) (struct kgsl_device *device);
 	void (*coresight_disable) (struct kgsl_device *device);
 	void (*coresight_config_debug_reg) (struct kgsl_device *device,
@@ -346,7 +362,7 @@
 	unsigned int replay_for_snapshot;
 };
 
-#define FT_DETECT_REGS_COUNT 12
+#define FT_DETECT_REGS_COUNT 14
 
 struct log_field {
 	bool show;
@@ -367,8 +383,7 @@
 #define KGSL_FT_PAGEFAULT_GPUHALT_ENABLE     BIT(1)
 #define KGSL_FT_PAGEFAULT_LOG_ONE_PER_PAGE   BIT(2)
 #define KGSL_FT_PAGEFAULT_LOG_ONE_PER_INT    BIT(3)
-#define KGSL_FT_PAGEFAULT_DEFAULT_POLICY     (KGSL_FT_PAGEFAULT_INT_ENABLE + \
-					KGSL_FT_PAGEFAULT_GPUHALT_ENABLE)
+#define KGSL_FT_PAGEFAULT_DEFAULT_POLICY     KGSL_FT_PAGEFAULT_INT_ENABLE
 
 extern struct adreno_gpudev adreno_a2xx_gpudev;
 extern struct adreno_gpudev adreno_a3xx_gpudev;
@@ -755,4 +770,29 @@
 static inline void adreno_debugfs_init(struct kgsl_device *device) { }
 #endif
 
+/* 
+ * adreno_hang_intr_supported() - Returns if hang interrupt is supported
+ * @adreno_dev:		Pointer to the the adreno device
+ */
+static inline bool adreno_hang_intr_supported(struct adreno_device *adreno_dev)
+{
+	bool ret = 0;
+	if (adreno_is_a330v2(adreno_dev))
+		ret = 1;
+	return ret;
+}
+
+/*
+ * adreno_fatal_err_work() - Schedules a work to do GFT on fatal error
+ * @adreno_dev:		Pointer to the the adreno device
+ */
+static inline void adreno_fatal_err_work(struct adreno_device *adreno_dev)
+{
+	struct kgsl_device *device = &adreno_dev->dev;
+
+	/* If hang_intr_set is 0, set it to 1 and queue work */
+	if (!atomic_cmpxchg(&adreno_dev->hang_intr_set, 0, 1))
+		/* Schedule work to do fault tolerance */
+		queue_work(device->work_queue, &device->hang_intr_ws);
+}
 #endif /*__ADRENO_H */
diff --git a/drivers/gpu/msm/adreno_a2xx.c b/drivers/gpu/msm/adreno_a2xx.c
index 3d72c5c..63e3871 100644
--- a/drivers/gpu/msm/adreno_a2xx.c
+++ b/drivers/gpu/msm/adreno_a2xx.c
@@ -1833,11 +1833,12 @@
 	return result;
 }
 
-static void a2xx_irq_control(struct adreno_device *adreno_dev, int state)
+static void a2xx_irq_control(struct adreno_device *adreno_dev,
+							 unsigned int mask)
 {
 	struct kgsl_device *device = &adreno_dev->dev;
 
-	if (state) {
+	if (mask) {
 		kgsl_regwrite(device, REG_RBBM_INT_CNTL, RBBM_INT_MASK);
 		kgsl_regwrite(device, REG_CP_INT_CNTL, CP_INT_MASK);
 		kgsl_regwrite(device, MH_INTERRUPT_MASK,
diff --git a/drivers/gpu/msm/adreno_a3xx.c b/drivers/gpu/msm/adreno_a3xx.c
index f9110ea..f316664 100644
--- a/drivers/gpu/msm/adreno_a3xx.c
+++ b/drivers/gpu/msm/adreno_a3xx.c
@@ -13,6 +13,7 @@
 
 #include <linux/delay.h>
 #include <linux/sched.h>
+#include <linux/ratelimit.h>
 #include <mach/socinfo.h>
 
 #include "kgsl.h"
@@ -3022,6 +3023,8 @@
 {
 	struct kgsl_device *device = &adreno_dev->dev;
 	const char *err = "";
+	/* Limit to 10 messages every 5 seconds */
+	static DEFINE_RATELIMIT_STATE(ratelimit_state, 5 * HZ, 10);
 
 	switch (bit) {
 	case A3XX_INT_RBBM_AHB_ERROR: {
@@ -3033,8 +3036,8 @@
 		 * Return the word address of the erroring register so that it
 		 * matches the register specification
 		 */
-
-		KGSL_DRV_CRIT(device,
+		if (!__ratelimit(&ratelimit_state))
+			KGSL_DRV_CRIT(device,
 			"RBBM | AHB bus error | %s | addr=%x | ports=%x:%x\n",
 			reg & (1 << 28) ? "WRITE" : "READ",
 			(reg & 0xFFFFF) >> 2, (reg >> 20) & 0x3,
@@ -3059,34 +3062,17 @@
 	case A3XX_INT_VFD_ERROR:
 		err = "VFD: Out of bounds access";
 		break;
-	case A3XX_INT_CP_T0_PACKET_IN_IB:
-		err = "ringbuffer TO packet in IB interrupt";
-		break;
-	case A3XX_INT_CP_OPCODE_ERROR:
-		err = "ringbuffer opcode error interrupt";
-		break;
-	case A3XX_INT_CP_RESERVED_BIT_ERROR:
-		err = "ringbuffer reserved bit error interrupt";
-		break;
-	case A3XX_INT_CP_HW_FAULT:
-		err = "ringbuffer hardware fault";
-		break;
-	case A3XX_INT_CP_REG_PROTECT_FAULT:
-		err = "ringbuffer protected mode error interrupt";
-		break;
-	case A3XX_INT_CP_AHB_ERROR_HALT:
-		err = "ringbuffer AHB error interrupt";
-		break;
-	case A3XX_INT_MISC_HANG_DETECT:
-		err = "MISC: GPU hang detected";
-		break;
 	case A3XX_INT_UCHE_OOB_ACCESS:
 		err = "UCHE:  Out of bounds access";
 		break;
 	}
 
-	KGSL_DRV_CRIT(device, "%s\n", err);
-	kgsl_pwrctrl_irq(device, KGSL_PWRFLAGS_OFF);
+	/*
+	 * Limit error interrupt reporting to prevent
+	 * kernel logs causing watchdog timeout
+	 */
+	if (!__ratelimit(&ratelimit_state))
+		KGSL_DRV_CRIT(device, "%s\n", err);
 }
 
 static void a3xx_cp_callback(struct adreno_device *adreno_dev, int irq)
@@ -3101,116 +3087,47 @@
 }
 
 /**
- * struct a3xx_perfcounter_register - Define a performance counter register
- * @load_bit: the bit to set in RBBM_LOAD_CMD0/RBBM_LOAD_CMD1 to force the RBBM
- * to load the reset value into the appropriate counter
- * @select: The dword offset of the register to write the selected
- * countable into
+ * a3xx_fatal_err_callback -  Routine for GPU fatal interrupts
+ * @adreno_dev: adreno device ptr
+ * @bit: interrupt bit
  */
+static void a3xx_fatal_err_callback(struct adreno_device *adreno_dev, int bit)
+{
+	struct kgsl_device *device = &adreno_dev->dev;
+	const char *err = "";
 
-struct a3xx_perfcounter_register {
-	unsigned int load_bit;
-	unsigned int select;
-};
+	switch (bit) {
+	case A3XX_INT_CP_OPCODE_ERROR:
+		err = "ringbuffer opcode error interrupt";
+		break;
+	case A3XX_INT_CP_RESERVED_BIT_ERROR:
+		err = "ringbuffer reserved bit error interrupt";
+		break;
+	case A3XX_INT_CP_T0_PACKET_IN_IB:
+		err = "ringbuffer TO packet in IB interrupt";
+		break;
+	case A3XX_INT_CP_HW_FAULT:
+		err = "ringbuffer hardware fault";
+		break;
+	case A3XX_INT_CP_REG_PROTECT_FAULT:
+		err = "ringbuffer protected mode error interrupt";
+		break;
+	case A3XX_INT_CP_AHB_ERROR_HALT:
+		err = "ringbuffer AHB error interrupt";
+		break;
+	case A3XX_INT_MISC_HANG_DETECT:
+		if (!adreno_dev->hang_intr_en)
+			return;
+		err = "stall interrupt";
+		break;
+	}
 
-static struct a3xx_perfcounter_register a3xx_perfcounter_reg_cp[] = {
-	{ 0, A3XX_CP_PERFCOUNTER_SELECT },
-};
+	KGSL_DRV_CRIT(device, "%s\n", err);
+	if ((!device->mmu.fault) &&
+		(adreno_dev->ft_pf_policy & KGSL_FT_PAGEFAULT_GPUHALT_ENABLE))
+		adreno_fatal_err_work(adreno_dev);
+}
 
-static struct a3xx_perfcounter_register a3xx_perfcounter_reg_rbbm[] = {
-	{ 1, A3XX_RBBM_PERFCOUNTER0_SELECT },
-	{ 2, A3XX_RBBM_PERFCOUNTER1_SELECT },
-};
-
-static struct a3xx_perfcounter_register a3xx_perfcounter_reg_pc[] = {
-	{ 3, A3XX_PC_PERFCOUNTER0_SELECT },
-	{ 4, A3XX_PC_PERFCOUNTER1_SELECT },
-	{ 5, A3XX_PC_PERFCOUNTER2_SELECT },
-	{ 6, A3XX_PC_PERFCOUNTER3_SELECT },
-};
-
-static struct a3xx_perfcounter_register a3xx_perfcounter_reg_vfd[] = {
-	{ 7, A3XX_VFD_PERFCOUNTER0_SELECT },
-	{ 8, A3XX_VFD_PERFCOUNTER1_SELECT },
-};
-
-static struct a3xx_perfcounter_register a3xx_perfcounter_reg_hlsq[] = {
-	{ 9, A3XX_HLSQ_PERFCOUNTER0_SELECT },
-	{ 10, A3XX_HLSQ_PERFCOUNTER1_SELECT },
-	{ 11, A3XX_HLSQ_PERFCOUNTER2_SELECT },
-	{ 12, A3XX_HLSQ_PERFCOUNTER3_SELECT },
-	{ 13, A3XX_HLSQ_PERFCOUNTER4_SELECT },
-	{ 14, A3XX_HLSQ_PERFCOUNTER5_SELECT },
-};
-
-static struct a3xx_perfcounter_register a3xx_perfcounter_reg_vpc[] = {
-	{ 15, A3XX_VPC_PERFCOUNTER0_SELECT },
-	{ 16, A3XX_VPC_PERFCOUNTER1_SELECT },
-};
-
-static struct a3xx_perfcounter_register a3xx_perfcounter_reg_tse[] = {
-	{ 17, A3XX_GRAS_PERFCOUNTER0_SELECT },
-	{ 18, A3XX_GRAS_PERFCOUNTER1_SELECT },
-};
-
-static struct a3xx_perfcounter_register a3xx_perfcounter_reg_ras[] = {
-	{ 19, A3XX_GRAS_PERFCOUNTER2_SELECT },
-	{ 20, A3XX_GRAS_PERFCOUNTER3_SELECT },
-};
-
-static struct a3xx_perfcounter_register a3xx_perfcounter_reg_uche[] = {
-	{ 21, A3XX_UCHE_PERFCOUNTER0_SELECT },
-	{ 22, A3XX_UCHE_PERFCOUNTER1_SELECT },
-	{ 23, A3XX_UCHE_PERFCOUNTER2_SELECT },
-	{ 24, A3XX_UCHE_PERFCOUNTER3_SELECT },
-	{ 25, A3XX_UCHE_PERFCOUNTER4_SELECT },
-	{ 26, A3XX_UCHE_PERFCOUNTER5_SELECT },
-};
-
-static struct a3xx_perfcounter_register a3xx_perfcounter_reg_tp[] = {
-	{ 27, A3XX_TP_PERFCOUNTER0_SELECT },
-	{ 28, A3XX_TP_PERFCOUNTER1_SELECT },
-	{ 29, A3XX_TP_PERFCOUNTER2_SELECT },
-	{ 30, A3XX_TP_PERFCOUNTER3_SELECT },
-	{ 31, A3XX_TP_PERFCOUNTER4_SELECT },
-	{ 32, A3XX_TP_PERFCOUNTER5_SELECT },
-};
-
-static struct a3xx_perfcounter_register a3xx_perfcounter_reg_sp[] = {
-	{ 33, A3XX_SP_PERFCOUNTER0_SELECT },
-	{ 34, A3XX_SP_PERFCOUNTER1_SELECT },
-	{ 35, A3XX_SP_PERFCOUNTER2_SELECT },
-	{ 36, A3XX_SP_PERFCOUNTER3_SELECT },
-	{ 37, A3XX_SP_PERFCOUNTER4_SELECT },
-	{ 38, A3XX_SP_PERFCOUNTER5_SELECT },
-	{ 39, A3XX_SP_PERFCOUNTER6_SELECT },
-	{ 40, A3XX_SP_PERFCOUNTER7_SELECT },
-};
-
-static struct a3xx_perfcounter_register a3xx_perfcounter_reg_rb[] = {
-	{ 41, A3XX_RB_PERFCOUNTER0_SELECT },
-	{ 42, A3XX_RB_PERFCOUNTER1_SELECT },
-};
-
-#define REGCOUNTER_GROUP(_x) { (_x), ARRAY_SIZE((_x)) }
-
-static struct {
-	struct a3xx_perfcounter_register *regs;
-	int count;
-} a3xx_perfcounter_reglist[] = {
-	REGCOUNTER_GROUP(a3xx_perfcounter_reg_cp),
-	REGCOUNTER_GROUP(a3xx_perfcounter_reg_rbbm),
-	REGCOUNTER_GROUP(a3xx_perfcounter_reg_pc),
-	REGCOUNTER_GROUP(a3xx_perfcounter_reg_vfd),
-	REGCOUNTER_GROUP(a3xx_perfcounter_reg_hlsq),
-	REGCOUNTER_GROUP(a3xx_perfcounter_reg_vpc),
-	REGCOUNTER_GROUP(a3xx_perfcounter_reg_tse),
-	REGCOUNTER_GROUP(a3xx_perfcounter_reg_ras),
-	REGCOUNTER_GROUP(a3xx_perfcounter_reg_uche),
-	REGCOUNTER_GROUP(a3xx_perfcounter_reg_tp),
-	REGCOUNTER_GROUP(a3xx_perfcounter_reg_sp),
-	REGCOUNTER_GROUP(a3xx_perfcounter_reg_rb),
-};
 
 static void a3xx_perfcounter_enable_pwr(struct kgsl_device *device,
 	unsigned int countable)
@@ -3309,7 +3226,7 @@
 {
 	struct kgsl_device *device = &adreno_dev->dev;
 	unsigned int val = 0;
-	struct a3xx_perfcounter_register *reg;
+	struct adreno_perfcount_register *reg;
 
 	/* Special cases */
 	if (group == KGSL_PERFCOUNTER_GROUP_PWR)
@@ -3319,13 +3236,14 @@
 	else if (group == KGSL_PERFCOUNTER_GROUP_VBIF_PWR)
 		return a3xx_perfcounter_enable_vbif_pwr(device, countable);
 
-	if (group >= ARRAY_SIZE(a3xx_perfcounter_reglist))
+	if (group >= adreno_dev->gpudev->perfcounters->group_count)
 		return;
 
-	if (counter >= a3xx_perfcounter_reglist[group].count)
+	if (counter >=
+		adreno_dev->gpudev->perfcounters->groups[group].reg_count)
 		return;
 
-	reg = &(a3xx_perfcounter_reglist[group].regs[counter]);
+	reg = &(adreno_dev->gpudev->perfcounters->groups[group].regs[counter]);
 
 	/* Select the desired perfcounter */
 	kgsl_regwrite(device, reg->select, countable);
@@ -3340,27 +3258,29 @@
 }
 
 static uint64_t a3xx_perfcounter_read(struct adreno_device *adreno_dev,
-	unsigned int group, unsigned int counter,
-	unsigned int offset)
+	unsigned int group, unsigned int counter)
 {
 	struct kgsl_device *device = &adreno_dev->dev;
-	struct a3xx_perfcounter_register *reg = NULL;
+	struct adreno_perfcount_register *reg;
 	unsigned int lo = 0, hi = 0;
 	unsigned int val;
+	unsigned int offset;
 
-	if (group >= ARRAY_SIZE(a3xx_perfcounter_reglist))
+	if (group >= adreno_dev->gpudev->perfcounters->group_count)
 		return 0;
 
-	if (counter >= a3xx_perfcounter_reglist[group].count)
+	if (counter >=
+		adreno_dev->gpudev->perfcounters->groups[group].reg_count)
 		return 0;
 
-	reg = &(a3xx_perfcounter_reglist[group].regs[counter]);
+	reg = &(adreno_dev->gpudev->perfcounters->groups[group].regs[counter]);
 
 	/* Freeze the counter */
 	kgsl_regread(device, A3XX_RBBM_PERFCTR_CTL, &val);
 	val &= ~reg->load_bit;
 	kgsl_regwrite(device, A3XX_RBBM_PERFCTR_CTL, val);
 
+	offset = reg->offset;
 	/* Read the values */
 	kgsl_regread(device, offset, &lo);
 	kgsl_regread(device, offset + 1, &hi);
@@ -3372,6 +3292,136 @@
 	return (((uint64_t) hi) << 32) | lo;
 }
 
+/*
+ * values cannot be loaded into physical performance
+ * counters belonging to these groups.
+ */
+static inline int loadable_perfcounter_group(unsigned int groupid)
+{
+	return ((groupid == KGSL_PERFCOUNTER_GROUP_VBIF_PWR) ||
+		(groupid == KGSL_PERFCOUNTER_GROUP_VBIF) ||
+		(groupid == KGSL_PERFCOUNTER_GROUP_PWR)) ? 0 : 1;
+}
+
+/*
+ * Return true if the countable is used and not broken
+ */
+static inline int active_countable(unsigned int countable)
+{
+	return ((countable != KGSL_PERFCOUNTER_NOT_USED) &&
+		(countable != KGSL_PERFCOUNTER_BROKEN));
+}
+
+/**
+ * a3xx_perfcounter_save() - Save the physical performance counter values
+ * @adreno_dev -  Adreno device whose registers need to be saved
+ *
+ * Read all the physical performance counter's values and save them
+ * before GPU power collapse.
+ */
+static void a3xx_perfcounter_save(struct adreno_device *adreno_dev)
+{
+	struct adreno_perfcounters *counters = adreno_dev->gpudev->perfcounters;
+	struct adreno_perfcount_group *group;
+	unsigned int regid, groupid;
+
+	for (groupid = 0; groupid < counters->group_count; groupid++) {
+		if (!loadable_perfcounter_group(groupid))
+			continue;
+
+		group = &(counters->groups[groupid]);
+
+		/* group/counter iterator */
+		for (regid = 0; regid < group->reg_count; regid++) {
+			if (!active_countable(group->regs[regid].countable))
+				continue;
+
+			group->regs[regid].value =
+				adreno_dev->gpudev->perfcounter_read(
+				adreno_dev, groupid, regid);
+		}
+	}
+}
+
+/**
+ * a3xx_perfcounter_write() - Write the physical performance counter values.
+ * @adreno_dev -  Adreno device whose registers are to be written to.
+ * @group - group to which the physical counter belongs to.
+ * @counter - register id of the physical counter to which the value is
+ *		written to.
+ *
+ * This function loads the 64 bit saved value into the particular physical
+ * counter by enabling the corresponding bit in A3XX_RBBM_PERFCTR_LOAD_CMD*
+ * register.
+ */
+static void a3xx_perfcounter_write(struct adreno_device *adreno_dev,
+				unsigned int group, unsigned int counter)
+{
+	struct kgsl_device *device = &(adreno_dev->dev);
+	struct adreno_perfcount_register *reg;
+	unsigned int val;
+
+	reg = &(adreno_dev->gpudev->perfcounters->groups[group].regs[counter]);
+
+	/* Clear the load cmd registers */
+	kgsl_regwrite(device, A3XX_RBBM_PERFCTR_LOAD_CMD0, 0);
+	kgsl_regwrite(device, A3XX_RBBM_PERFCTR_LOAD_CMD1, 0);
+
+	/* Write the saved value to PERFCTR_LOAD_VALUE* registers. */
+	kgsl_regwrite(device, A3XX_RBBM_PERFCTR_LOAD_VALUE_LO,
+			(uint32_t)reg->value);
+	kgsl_regwrite(device, A3XX_RBBM_PERFCTR_LOAD_VALUE_HI,
+			(uint32_t)(reg->value >> 32));
+
+	/*
+	 * Set the load bit in PERFCTR_LOAD_CMD for the physical counter
+	 * we want to restore. The value in PERFCTR_LOAD_VALUE* is loaded
+	 * into the corresponding physical counter.
+	 */
+	if (reg->load_bit < 32)	{
+		val = 1 << reg->load_bit;
+		kgsl_regwrite(device, A3XX_RBBM_PERFCTR_LOAD_CMD0, val);
+	} else {
+		val  = 1 << (reg->load_bit - 32);
+		kgsl_regwrite(device, A3XX_RBBM_PERFCTR_LOAD_CMD1, val);
+	}
+}
+
+/**
+ * a3xx_perfcounter_restore() - Restore the physical performance counter values.
+ * @adreno_dev -  Adreno device whose registers are to be restored.
+ *
+ * This function together with a3xx_perfcounter_save make sure that performance
+ * counters are coherent across GPU power collapse.
+ */
+static void a3xx_perfcounter_restore(struct adreno_device *adreno_dev)
+{
+	struct kgsl_device *device = &adreno_dev->dev;
+	struct adreno_perfcounters *counters = adreno_dev->gpudev->perfcounters;
+	struct adreno_perfcount_group *group;
+	unsigned int regid, groupid;
+
+	for (groupid = 0; groupid < counters->group_count; groupid++) {
+		if (!loadable_perfcounter_group(groupid))
+			continue;
+
+		group = &(counters->groups[groupid]);
+
+		/* group/counter iterator */
+		for (regid = 0; regid < group->reg_count; regid++) {
+			if (!active_countable(group->regs[regid].countable))
+				continue;
+
+			a3xx_perfcounter_write(adreno_dev, groupid, regid);
+		}
+	}
+
+	/* Clear the load cmd registers */
+	kgsl_regwrite(device, A3XX_RBBM_PERFCTR_LOAD_CMD0, 0);
+	kgsl_regwrite(device, A3XX_RBBM_PERFCTR_LOAD_CMD1, 0);
+
+}
+
 #define A3XX_IRQ_CALLBACK(_c) { .func = _c }
 
 #define A3XX_INT_MASK \
@@ -3399,23 +3449,25 @@
 	A3XX_IRQ_CALLBACK(a3xx_err_callback),  /* 5 - RBBM_ATB_BUS_OVERFLOW */
 	A3XX_IRQ_CALLBACK(a3xx_err_callback),  /* 6 - RBBM_VFD_ERROR */
 	A3XX_IRQ_CALLBACK(NULL),	       /* 7 - CP_SW */
-	A3XX_IRQ_CALLBACK(a3xx_err_callback),  /* 8 - CP_T0_PACKET_IN_IB */
-	A3XX_IRQ_CALLBACK(a3xx_err_callback),  /* 9 - CP_OPCODE_ERROR */
-	A3XX_IRQ_CALLBACK(a3xx_err_callback),  /* 10 - CP_RESERVED_BIT_ERROR */
+	A3XX_IRQ_CALLBACK(a3xx_fatal_err_callback),/* 8 - CP_T0_PACKET_IN_IB */
+	A3XX_IRQ_CALLBACK(a3xx_fatal_err_callback),/* 9 - CP_OPCODE_ERROR */
+	/* 10 - CP_RESERVED_BIT_ERROR */
+	A3XX_IRQ_CALLBACK(a3xx_fatal_err_callback),
 	A3XX_IRQ_CALLBACK(a3xx_err_callback),  /* 11 - CP_HW_FAULT */
 	A3XX_IRQ_CALLBACK(NULL),	       /* 12 - CP_DMA */
 	A3XX_IRQ_CALLBACK(a3xx_cp_callback),   /* 13 - CP_IB2_INT */
 	A3XX_IRQ_CALLBACK(a3xx_cp_callback),   /* 14 - CP_IB1_INT */
 	A3XX_IRQ_CALLBACK(a3xx_cp_callback),   /* 15 - CP_RB_INT */
-	A3XX_IRQ_CALLBACK(a3xx_err_callback),  /* 16 - CP_REG_PROTECT_FAULT */
+	/* 16 - CP_REG_PROTECT_FAULT */
+	A3XX_IRQ_CALLBACK(a3xx_fatal_err_callback),
 	A3XX_IRQ_CALLBACK(NULL),	       /* 17 - CP_RB_DONE_TS */
 	A3XX_IRQ_CALLBACK(NULL),	       /* 18 - CP_VS_DONE_TS */
 	A3XX_IRQ_CALLBACK(NULL),	       /* 19 - CP_PS_DONE_TS */
 	A3XX_IRQ_CALLBACK(NULL),	       /* 20 - CP_CACHE_FLUSH_TS */
-	A3XX_IRQ_CALLBACK(a3xx_err_callback),  /* 21 - CP_AHB_ERROR_FAULT */
+	A3XX_IRQ_CALLBACK(a3xx_fatal_err_callback),/* 21 - CP_AHB_ERROR_FAULT */
 	A3XX_IRQ_CALLBACK(NULL),	       /* 22 - Unused */
 	A3XX_IRQ_CALLBACK(NULL),	       /* 23 - Unused */
-	A3XX_IRQ_CALLBACK(NULL),	       /* 24 - MISC_HANG_DETECT */
+	A3XX_IRQ_CALLBACK(a3xx_fatal_err_callback),/* 24 - MISC_HANG_DETECT */
 	A3XX_IRQ_CALLBACK(a3xx_err_callback),  /* 25 - UCHE_OOB_ACCESS */
 	/* 26 to 31 - Unused */
 };
@@ -3451,14 +3503,27 @@
 	return ret;
 }
 
-static void a3xx_irq_control(struct adreno_device *adreno_dev, int state)
+/**
+ * a3xx_irq_init() -  Routine to init a3xx irq
+ * @adreno_dev: adreno device ptr
+ */
+static void a3xx_irq_init(struct adreno_device *adreno_dev)
+{
+	if (adreno_hang_intr_supported(adreno_dev)) {
+		adreno_dev->intr_mask = (A3XX_INT_MASK |
+			(1 << A3XX_INT_MISC_HANG_DETECT));
+		adreno_dev->hang_intr_en = 1;
+	} else
+		adreno_dev->intr_mask = A3XX_INT_MASK;
+
+}
+
+static void a3xx_irq_control(struct adreno_device *adreno_dev,
+							 unsigned int mask)
 {
 	struct kgsl_device *device = &adreno_dev->dev;
 
-	if (state)
-		kgsl_regwrite(device, A3XX_RBBM_INT_0_MASK, A3XX_INT_MASK);
-	else
-		kgsl_regwrite(device, A3XX_RBBM_INT_0_MASK, 0);
+	kgsl_regwrite(device, A3XX_RBBM_INT_0_MASK, mask);
 }
 
 static unsigned int a3xx_irq_pending(struct adreno_device *adreno_dev)
@@ -3624,118 +3689,160 @@
  */
 
 static struct adreno_perfcount_register a3xx_perfcounters_cp[] = {
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_CP_0_LO },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_CP_0_LO,
+		0, A3XX_CP_PERFCOUNTER_SELECT },
 };
 
 static struct adreno_perfcount_register a3xx_perfcounters_rbbm[] = {
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_RBBM_0_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_RBBM_1_LO },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_RBBM_0_LO,
+		1, A3XX_RBBM_PERFCOUNTER0_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_RBBM_1_LO,
+		2, A3XX_RBBM_PERFCOUNTER1_SELECT },
 };
 
 static struct adreno_perfcount_register a3xx_perfcounters_pc[] = {
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_PC_0_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_PC_1_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_PC_2_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_PC_3_LO },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_PC_0_LO,
+		3, A3XX_PC_PERFCOUNTER0_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_PC_1_LO,
+		4, A3XX_PC_PERFCOUNTER1_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_PC_2_LO,
+		5, A3XX_PC_PERFCOUNTER2_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_PC_3_LO,
+		6, A3XX_PC_PERFCOUNTER3_SELECT },
 };
 
 static struct adreno_perfcount_register a3xx_perfcounters_vfd[] = {
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_VFD_0_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_VFD_1_LO },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_VFD_0_LO,
+		7, A3XX_VFD_PERFCOUNTER0_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_VFD_1_LO,
+		8, A3XX_VFD_PERFCOUNTER1_SELECT },
 };
 
 static struct adreno_perfcount_register a3xx_perfcounters_hlsq[] = {
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_HLSQ_0_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_HLSQ_1_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_HLSQ_2_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_HLSQ_3_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_HLSQ_4_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_HLSQ_5_LO },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_HLSQ_0_LO,
+		9, A3XX_HLSQ_PERFCOUNTER0_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_HLSQ_1_LO,
+		10, A3XX_HLSQ_PERFCOUNTER1_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_HLSQ_2_LO,
+		11, A3XX_HLSQ_PERFCOUNTER2_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_HLSQ_3_LO,
+		12, A3XX_HLSQ_PERFCOUNTER3_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_HLSQ_4_LO,
+		13, A3XX_HLSQ_PERFCOUNTER4_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_HLSQ_5_LO,
+		14, A3XX_HLSQ_PERFCOUNTER5_SELECT },
 };
 
 static struct adreno_perfcount_register a3xx_perfcounters_vpc[] = {
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_VPC_0_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_VPC_1_LO },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_VPC_0_LO,
+		15, A3XX_VPC_PERFCOUNTER0_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_VPC_1_LO,
+		16, A3XX_VPC_PERFCOUNTER1_SELECT },
 };
 
 static struct adreno_perfcount_register a3xx_perfcounters_tse[] = {
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_TSE_0_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_TSE_1_LO },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_TSE_0_LO,
+		17, A3XX_GRAS_PERFCOUNTER0_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_TSE_1_LO,
+		18, A3XX_GRAS_PERFCOUNTER1_SELECT },
 };
 
 static struct adreno_perfcount_register a3xx_perfcounters_ras[] = {
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_RAS_0_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_RAS_1_LO },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_RAS_0_LO,
+		19, A3XX_GRAS_PERFCOUNTER2_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_RAS_1_LO,
+		20, A3XX_GRAS_PERFCOUNTER3_SELECT },
 };
 
 static struct adreno_perfcount_register a3xx_perfcounters_uche[] = {
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_UCHE_0_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_UCHE_1_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_UCHE_2_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_UCHE_3_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_UCHE_4_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_UCHE_5_LO },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_UCHE_0_LO,
+		21, A3XX_UCHE_PERFCOUNTER0_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_UCHE_1_LO,
+		22, A3XX_UCHE_PERFCOUNTER1_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_UCHE_2_LO,
+		23, A3XX_UCHE_PERFCOUNTER2_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_UCHE_3_LO,
+		24, A3XX_UCHE_PERFCOUNTER3_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_UCHE_4_LO,
+		25, A3XX_UCHE_PERFCOUNTER4_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_UCHE_5_LO,
+		26, A3XX_UCHE_PERFCOUNTER5_SELECT },
 };
 
 static struct adreno_perfcount_register a3xx_perfcounters_tp[] = {
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_TP_0_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_TP_1_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_TP_2_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_TP_3_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_TP_4_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_TP_5_LO },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_TP_0_LO,
+		27, A3XX_TP_PERFCOUNTER0_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_TP_1_LO,
+		28, A3XX_TP_PERFCOUNTER1_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_TP_2_LO,
+		29, A3XX_TP_PERFCOUNTER2_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_TP_3_LO,
+		30, A3XX_TP_PERFCOUNTER3_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_TP_4_LO,
+		31, A3XX_TP_PERFCOUNTER4_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_TP_5_LO,
+		32, A3XX_TP_PERFCOUNTER5_SELECT },
 };
 
 static struct adreno_perfcount_register a3xx_perfcounters_sp[] = {
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_SP_0_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_SP_1_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_SP_2_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_SP_3_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_SP_4_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_SP_5_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_SP_6_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_SP_7_LO },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_SP_0_LO,
+		33, A3XX_SP_PERFCOUNTER0_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_SP_1_LO,
+		34, A3XX_SP_PERFCOUNTER1_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_SP_2_LO,
+		35, A3XX_SP_PERFCOUNTER2_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_SP_3_LO,
+		36, A3XX_SP_PERFCOUNTER3_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_SP_4_LO,
+		37, A3XX_SP_PERFCOUNTER4_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_SP_5_LO,
+		38, A3XX_SP_PERFCOUNTER5_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_SP_6_LO,
+		39, A3XX_SP_PERFCOUNTER6_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_SP_7_LO,
+		40, A3XX_SP_PERFCOUNTER7_SELECT },
 };
 
 static struct adreno_perfcount_register a3xx_perfcounters_rb[] = {
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_RB_0_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_RB_1_LO },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_RB_0_LO,
+		41, A3XX_RB_PERFCOUNTER0_SELECT },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_RB_1_LO,
+		42, A3XX_RB_PERFCOUNTER1_SELECT },
 };
 
 static struct adreno_perfcount_register a3xx_perfcounters_pwr[] = {
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_PWR_0_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_PWR_1_LO },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_PWR_0_LO,
+		-1, 0 },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_RBBM_PERFCTR_PWR_1_LO,
+		-1, 0 },
 };
 
 static struct adreno_perfcount_register a3xx_perfcounters_vbif[] = {
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_VBIF_PERF_CNT0_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_VBIF_PERF_CNT1_LO },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_VBIF_PERF_CNT0_LO, -1, 0 },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_VBIF_PERF_CNT1_LO, -1, 0 },
 };
 static struct adreno_perfcount_register a3xx_perfcounters_vbif_pwr[] = {
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_VBIF_PERF_PWR_CNT0_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_VBIF_PERF_PWR_CNT1_LO },
-	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_VBIF_PERF_PWR_CNT2_LO },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_VBIF_PERF_PWR_CNT0_LO, -1, 0 },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_VBIF_PERF_PWR_CNT1_LO, -1, 0 },
+	{ KGSL_PERFCOUNTER_NOT_USED, 0, 0, A3XX_VBIF_PERF_PWR_CNT2_LO, -1, 0 },
 };
 
-#define A3XX_PERFCOUNTER_GROUP(name) { a3xx_perfcounters_##name, \
-	ARRAY_SIZE(a3xx_perfcounters_##name), __stringify(name) }
-
 static struct adreno_perfcount_group a3xx_perfcounter_groups[] = {
-	A3XX_PERFCOUNTER_GROUP(cp),
-	A3XX_PERFCOUNTER_GROUP(rbbm),
-	A3XX_PERFCOUNTER_GROUP(pc),
-	A3XX_PERFCOUNTER_GROUP(vfd),
-	A3XX_PERFCOUNTER_GROUP(hlsq),
-	A3XX_PERFCOUNTER_GROUP(vpc),
-	A3XX_PERFCOUNTER_GROUP(tse),
-	A3XX_PERFCOUNTER_GROUP(ras),
-	A3XX_PERFCOUNTER_GROUP(uche),
-	A3XX_PERFCOUNTER_GROUP(tp),
-	A3XX_PERFCOUNTER_GROUP(sp),
-	A3XX_PERFCOUNTER_GROUP(rb),
-	A3XX_PERFCOUNTER_GROUP(pwr),
-	A3XX_PERFCOUNTER_GROUP(vbif),
-	A3XX_PERFCOUNTER_GROUP(vbif_pwr),
+	ADRENO_PERFCOUNTER_GROUP(a3xx, cp),
+	ADRENO_PERFCOUNTER_GROUP(a3xx, rbbm),
+	ADRENO_PERFCOUNTER_GROUP(a3xx, pc),
+	ADRENO_PERFCOUNTER_GROUP(a3xx, vfd),
+	ADRENO_PERFCOUNTER_GROUP(a3xx, hlsq),
+	ADRENO_PERFCOUNTER_GROUP(a3xx, vpc),
+	ADRENO_PERFCOUNTER_GROUP(a3xx, tse),
+	ADRENO_PERFCOUNTER_GROUP(a3xx, ras),
+	ADRENO_PERFCOUNTER_GROUP(a3xx, uche),
+	ADRENO_PERFCOUNTER_GROUP(a3xx, tp),
+	ADRENO_PERFCOUNTER_GROUP(a3xx, sp),
+	ADRENO_PERFCOUNTER_GROUP(a3xx, rb),
+	ADRENO_PERFCOUNTER_GROUP(a3xx, pwr),
+	ADRENO_PERFCOUNTER_GROUP(a3xx, vbif),
+	ADRENO_PERFCOUNTER_GROUP(a3xx, vbif_pwr),
 };
 
 static struct adreno_perfcounters a3xx_perfcounters = {
@@ -3756,7 +3863,9 @@
 	 * USP L1 instruction miss request.
 	 * Set SP to count SP_FS_FULL_ALU_INSTRUCTIONS, it
 	 * counts USP flow control instruction execution.
-	 * we will use this to augment our hang detection
+	 * Set TSE to count TSE_INPUT_PRIM_NUM, it counts
+	 * number of input primitives in TSE.
+	 * we will use above countables for our hang detection
 	 */
 	if (adreno_dev->fast_hang_detect) {
 		adreno_perfcounter_get(adreno_dev, KGSL_PERFCOUNTER_GROUP_SP,
@@ -3771,6 +3880,10 @@
 			SP_FS_CFLOW_INSTRUCTIONS, &ft_detect_regs[10],
 			PERFCOUNTER_FLAG_KERNEL);
 		ft_detect_regs[11] = ft_detect_regs[10] + 1;
+		adreno_perfcounter_get(adreno_dev, KGSL_PERFCOUNTER_GROUP_TSE,
+			TSE_INPUT_PRIM_NUM, &ft_detect_regs[12],
+			PERFCOUNTER_FLAG_KERNEL);
+		ft_detect_regs[13] = ft_detect_regs[12] + 1;
 	}
 
 	adreno_perfcounter_get(adreno_dev, KGSL_PERFCOUNTER_GROUP_SP,
@@ -3857,8 +3970,11 @@
 
 	/* Turn on hang detection - this spews a lot of useful information
 	 * into the RBBM registers on a hang */
-
-	kgsl_regwrite(device, A3XX_RBBM_INTERFACE_HANG_INT_CTL,
+	if (adreno_is_a330v2(adreno_dev))
+		kgsl_regwrite(device, A3XX_RBBM_INTERFACE_HANG_INT_CTL,
+			(1 << 31) | 0xFFFF);
+	else
+		kgsl_regwrite(device, A3XX_RBBM_INTERFACE_HANG_INT_CTL,
 			(1 << 16) | 0xFFF);
 
 	/* Enable 64-byte cacheline size. HW Default is 32-byte (0x000000E0). */
@@ -4257,14 +4373,18 @@
 	.ctxt_draw_workaround = NULL,
 	.rb_init = a3xx_rb_init,
 	.perfcounter_init = a3xx_perfcounter_init,
+	.perfcounter_save = a3xx_perfcounter_save,
+	.perfcounter_restore = a3xx_perfcounter_restore,
 	.irq_control = a3xx_irq_control,
 	.irq_handler = a3xx_irq_handler,
 	.irq_pending = a3xx_irq_pending,
+	.irq_init = a3xx_irq_init,
 	.busy_cycles = a3xx_busy_cycles,
 	.start = a3xx_start,
 	.snapshot = a3xx_snapshot,
 	.perfcounter_enable = a3xx_perfcounter_enable,
 	.perfcounter_read = a3xx_perfcounter_read,
+	.perfcounter_write = a3xx_perfcounter_write,
 	.coresight_enable = a3xx_coresight_enable,
 	.coresight_disable = a3xx_coresight_disable,
 	.coresight_config_debug_reg = a3xx_coresight_config_debug_reg,
diff --git a/drivers/gpu/msm/adreno_postmortem.c b/drivers/gpu/msm/adreno_postmortem.c
index 32dbd51..b8c451e 100644
--- a/drivers/gpu/msm/adreno_postmortem.c
+++ b/drivers/gpu/msm/adreno_postmortem.c
@@ -406,9 +406,11 @@
 	const uint32_t *rb_vaddr;
 	int num_item = 0;
 	int read_idx, write_idx;
-	unsigned int ts_processed = 0xdeaddead;
+	unsigned int ts_processed = 0;
+	unsigned int curr_global_ts = 0;
 	struct kgsl_context *context;
 	unsigned int context_id;
+	static char pid_name[TASK_COMM_LEN] = "unknown";
 	unsigned int rbbm_status;
 
 	static struct ib_list ib_list;
@@ -459,8 +461,36 @@
 		adreno_getreg(adreno_dev, ADRENO_REG_CP_IB2_BUFSZ),
 		&cp_ib2_bufsz);
 
+	kgsl_sharedmem_readl(&device->memstore,
+			(unsigned int *) &context_id,
+			KGSL_MEMSTORE_OFFSET(KGSL_MEMSTORE_GLOBAL,
+				current_context));
+	context = idr_find(&device->context_idr, context_id);
+	if (context)
+		ts_processed = kgsl_readtimestamp(device, context,
+					  KGSL_TIMESTAMP_RETIRED);
+
 	/* If postmortem dump is not enabled, dump minimal set and return */
 	if (!device->pm_dump_enable) {
+		struct task_struct *task = NULL;
+		/* Read the current global timestamp here */
+		kgsl_sharedmem_readl(&device->memstore,
+			&curr_global_ts,
+			KGSL_MEMSTORE_OFFSET(KGSL_MEMSTORE_GLOBAL,
+			eoptimestamp));
+
+		if (context)
+			task = find_task_by_vpid(context->pid);
+
+		if (task)
+			get_task_comm(pid_name, task);
+
+		KGSL_LOG_DUMP(device,
+			"Proc %s, ctxt_id %d ts %d triggered fault tolerance"
+			" on global ts %d\n", pid_name,
+			context ? context->id : 0,
+			ts_processed ? ts_processed + 1 : 0,
+			curr_global_ts ? curr_global_ts + 1 : 0);
 
 		KGSL_LOG_DUMP(device,
 			"STATUS %08X | IB1:%08X/%08X | IB2: %08X/%08X"
@@ -471,19 +501,10 @@
 		return 0;
 	}
 
-	kgsl_sharedmem_readl(&device->memstore,
-			(unsigned int *) &context_id,
-			KGSL_MEMSTORE_OFFSET(KGSL_MEMSTORE_GLOBAL,
-				current_context));
-
-	context = kgsl_context_get(device, context_id);
-
-	if (context) {
-		ts_processed = kgsl_readtimestamp(device, context,
-						  KGSL_TIMESTAMP_RETIRED);
+	if (ts_processed)
 		KGSL_LOG_DUMP(device, "FT CTXT: %d  TIMESTM RTRD: %08X\n",
 				context->id, ts_processed);
-	} else
+	else
 		KGSL_LOG_DUMP(device, "BAD CTXT: %d\n", context_id);
 
 	kgsl_context_put(context);
diff --git a/drivers/gpu/msm/adreno_ringbuffer.c b/drivers/gpu/msm/adreno_ringbuffer.c
index 8aec755..8871a23 100644
--- a/drivers/gpu/msm/adreno_ringbuffer.c
+++ b/drivers/gpu/msm/adreno_ringbuffer.c
@@ -69,6 +69,7 @@
 	unsigned long wait_time_part;
 	unsigned int prev_reg_val[FT_DETECT_REGS_COUNT];
 	unsigned int rptr;
+	struct adreno_device *adreno_dev = ADRENO_DEVICE(rb->device);
 
 	memset(prev_reg_val, 0, sizeof(prev_reg_val));
 
@@ -107,17 +108,16 @@
 
 		/* Dont wait for timeout, detect hang faster.
 		 */
+
+		if (kgsl_atomic_read(&adreno_dev->hang_intr_set))
+			goto hang_detected;
+
 		if (time_after(jiffies, wait_time_part)) {
 			wait_time_part = jiffies +
 				msecs_to_jiffies(KGSL_TIMEOUT_PART);
-			if ((adreno_ft_detect(rb->device,
-						prev_reg_val))){
-				KGSL_DRV_ERR(rb->device,
-				"Hang detected while waiting for freespace in"
-				"ringbuffer rptr: 0x%x, wptr: 0x%x\n",
-				rptr, rb->wptr);
-				goto err;
-			}
+
+			if ((adreno_ft_detect(rb->device, prev_reg_val)))
+				goto hang_detected;
 		}
 
 		if (time_after(jiffies, wait_time)) {
@@ -129,6 +129,12 @@
 
 		continue;
 
+hang_detected:
+		KGSL_DRV_ERR(rb->device,
+			"Hang detected while waiting for freespace in"
+			"ringbuffer rptr: 0x%x, wptr: 0x%x\n",
+			rptr, rb->wptr);
+
 err:
 		if (!adreno_dump_and_exec_ft(rb->device)) {
 			if (context && context->flags & CTXT_FLAGS_GPU_HANG) {
diff --git a/drivers/gpu/msm/kgsl.c b/drivers/gpu/msm/kgsl.c
index 298b36e..2eb5300 100644
--- a/drivers/gpu/msm/kgsl.c
+++ b/drivers/gpu/msm/kgsl.c
@@ -59,6 +59,9 @@
 	struct sg_table *table;
 };
 
+static void kgsl_put_process_private(struct kgsl_device *device,
+			 struct kgsl_process_private *private);
+
 static void kgsl_mem_entry_detach_process(struct kgsl_mem_entry *entry);
 
 /**
@@ -110,6 +113,29 @@
 }
 
 /**
+ * kgsl_hang_intr_work() - GPU hang interrupt work
+ * @dev: device ptr
+ *
+ * This function is called when GPU hang interrupt happens. In
+ * this fuction we check the device state and trigger fault
+ * tolerance.
+ */
+void kgsl_hang_intr_work(struct work_struct *work)
+{
+	struct kgsl_device *device = container_of(work, struct kgsl_device,
+							hang_intr_ws);
+	struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
+
+	/* If hang_intr_set is set, turn it off and trigger FT */
+	mutex_lock(&device->mutex);
+	if ((device->state == KGSL_STATE_ACTIVE) &&
+		(atomic_cmpxchg(&adreno_dev->hang_intr_set, 1, 0)))
+			adreno_dump_and_exec_ft(device);
+	mutex_unlock(&device->mutex);
+
+}
+
+/**
  * kgsl_trace_issueibcmds() - Call trace_issueibcmds by proxy
  * device: KGSL device
  * id: ID of the context submitting the command
@@ -386,14 +412,19 @@
  */
 static int
 kgsl_mem_entry_attach_process(struct kgsl_mem_entry *entry,
-				   struct kgsl_process_private *process)
+				   struct kgsl_device_private *dev_priv)
 {
 	int ret;
+	struct kgsl_process_private *process = dev_priv->process_priv;
+	
+	ret = kref_get_unless_zero(&process->refcount);
+	if (!ret)
+		return -EBADF;
 
 	while (1) {
 		if (idr_pre_get(&process->mem_idr, GFP_KERNEL) == 0) {
 			ret = -ENOMEM;
-			goto err;
+			goto err_put_proc_priv;
 		}
 
 		spin_lock(&process->mem_lock);
@@ -404,9 +435,10 @@
 		if (ret == 0)
 			break;
 		else if (ret != -EAGAIN)
-			goto err;
+			goto err_put_proc_priv;
 	}
 	entry->priv = process;
+	entry->dev_priv = dev_priv;
 
 	spin_lock(&process->mem_lock);
 	ret = kgsl_mem_entry_track_gpuaddr(process, entry);
@@ -414,14 +446,17 @@
 		idr_remove(&process->mem_idr, entry->id);
 	spin_unlock(&process->mem_lock);
 	if (ret)
-		goto err;
+		goto err_put_proc_priv;
 	/* map the memory after unlocking if gpuaddr has been assigned */
 	if (entry->memdesc.gpuaddr) {
 		ret = kgsl_mmu_map(process->pagetable, &entry->memdesc);
 		if (ret)
 			kgsl_mem_entry_detach_process(entry);
 	}
-err:
+	return ret;
+
+err_put_proc_priv:
+	kgsl_put_process_private(dev_priv->device, process);
 	return ret;
 }
 
@@ -444,6 +479,7 @@
 
 	entry->priv->stats[entry->memtype].cur -= entry->memdesc.size;
 	spin_unlock(&entry->priv->mem_lock);
+	kgsl_put_process_private(entry->dev_priv->device, entry->priv);
 
 	entry->priv = NULL;
 }
@@ -790,11 +826,6 @@
  */
 static void kgsl_destroy_process_private(struct kref *kref)
 {
-
-	struct kgsl_mem_entry *entry = NULL;
-	int next = 0;
-
-
 	struct kgsl_process_private *private = container_of(kref,
 			struct kgsl_process_private, refcount);
 
@@ -818,20 +849,6 @@
 	if (private->debug_root)
 		debugfs_remove_recursive(private->debug_root);
 
-	while (1) {
-		spin_lock(&private->mem_lock);
-		entry = idr_get_next(&private->mem_idr, &next);
-		spin_unlock(&private->mem_lock);
-		if (entry == NULL)
-			break;
-		kgsl_mem_entry_put(entry);
-		/*
-		 * Always start back at the beginning, to
-		 * ensure all entries are removed,
-		 * like list_for_each_entry_safe.
-		 */
-		next = 0;
-	}
 	idr_destroy(&private->mem_idr);
 	kgsl_mmu_putpagetable(private->pagetable);
 
@@ -981,6 +998,7 @@
 	struct kgsl_process_private *private = dev_priv->process_priv;
 	struct kgsl_device *device = dev_priv->device;
 	struct kgsl_context *context;
+	struct kgsl_mem_entry *entry;
 	int next = 0;
 
 	filep->private_data = NULL;
@@ -1001,6 +1019,25 @@
 
 		next = next + 1;
 	}
+	next = 0;
+	while (1) {
+		spin_lock(&private->mem_lock);
+		entry = idr_get_next(&private->mem_idr, &next);
+		spin_unlock(&private->mem_lock);
+		if (entry == NULL)
+			break;
+		/*
+		 * If the free pending flag is not set it means that user space
+		 * did not free it's reference to this entry, in that case
+		 * free a reference to this entry, other references are from
+		 * within kgsl so they will be freed eventually by kgsl
+		 */
+		if (entry->dev_priv == dev_priv && !entry->pending_free) {
+			entry->pending_free = 1;
+			kgsl_mem_entry_put(entry);
+		}
+		next = next + 1;
+	}
 	/*
 	 * Clean up any to-be-freed entries that belong to this
 	 * process and this device. This is done after the context
@@ -2223,7 +2260,7 @@
 	/* echo back flags */
 	param->flags = entry->memdesc.flags;
 
-	result = kgsl_mem_entry_attach_process(entry, private);
+	result = kgsl_mem_entry_attach_process(entry, dev_priv);
 	if (result)
 		goto error_attach;
 
@@ -2511,7 +2548,7 @@
 	if (result)
 		return result;
 
-	result = kgsl_mem_entry_attach_process(entry, private);
+	result = kgsl_mem_entry_attach_process(entry, dev_priv);
 	if (result != 0)
 		goto err;
 
@@ -2544,7 +2581,7 @@
 	if (result != 0)
 		goto err;
 
-	result = kgsl_mem_entry_attach_process(entry, private);
+	result = kgsl_mem_entry_attach_process(entry, dev_priv);
 	if (result != 0)
 		goto err;
 
diff --git a/drivers/gpu/msm/kgsl.h b/drivers/gpu/msm/kgsl.h
index 0525eab..3f4dde7 100644
--- a/drivers/gpu/msm/kgsl.h
+++ b/drivers/gpu/msm/kgsl.h
@@ -197,6 +197,7 @@
 	struct kgsl_process_private *priv;
 	/* Initialized to 0, set to 1 when entry is marked for freeing */
 	int pending_free;
+	struct kgsl_device_private *dev_priv;
 };
 
 #ifdef CONFIG_MSM_KGSL_MMU_PAGE_FAULT
@@ -205,10 +206,25 @@
 #define MMU_CONFIG 1
 #endif
 
+void kgsl_hang_intr_work(struct work_struct *work);
 void kgsl_hang_check(struct work_struct *work);
 void kgsl_mem_entry_destroy(struct kref *kref);
 int kgsl_postmortem_dump(struct kgsl_device *device, int manual);
 
+static inline void kgsl_atomic_set(atomic_t *addr, unsigned int val)
+{
+	atomic_set(addr, val);
+	/* make sure above write is posted */
+	wmb();
+}
+
+static inline int kgsl_atomic_read(atomic_t *addr)
+{
+	/* make sure below read is read from memory */
+	rmb();
+	return atomic_read(addr);
+}
+
 struct kgsl_mem_entry *kgsl_get_mem_entry(struct kgsl_device *device,
 		phys_addr_t ptbase, unsigned int gpuaddr, unsigned int size);
 
diff --git a/drivers/gpu/msm/kgsl_device.h b/drivers/gpu/msm/kgsl_device.h
index 0b5fe52..40e4e39 100644
--- a/drivers/gpu/msm/kgsl_device.h
+++ b/drivers/gpu/msm/kgsl_device.h
@@ -110,7 +110,7 @@
 		struct kgsl_pagetable *pagetable);
 	void (*power_stats)(struct kgsl_device *device,
 		struct kgsl_power_stats *stats);
-	void (*irqctrl)(struct kgsl_device *device, int state);
+	void (*irqctrl)(struct kgsl_device *device, unsigned int mask);
 	unsigned int (*gpuid)(struct kgsl_device *device, unsigned int *chipid);
 	void * (*snapshot)(struct kgsl_device *device, void *snapshot,
 		int *remain, int hang);
@@ -191,6 +191,7 @@
 	const struct kgsl_functable *ftbl;
 	struct work_struct idle_check_ws;
 	struct work_struct hang_check_ws;
+	struct work_struct hang_intr_ws;
 	struct timer_list idle_timer;
 	struct timer_list hang_timer;
 	struct kgsl_pwrctrl pwrctrl;
@@ -259,6 +260,8 @@
 			kgsl_idle_check),\
 	.hang_check_ws = __WORK_INITIALIZER((_dev).hang_check_ws,\
 			kgsl_hang_check),\
+	.hang_intr_ws = __WORK_INITIALIZER((_dev).hang_intr_ws,\
+			kgsl_hang_intr_work),\
 	.ts_expired_ws  = __WORK_INITIALIZER((_dev).ts_expired_ws,\
 			kgsl_process_events),\
 	.context_idr = IDR_INIT((_dev).context_idr),\
diff --git a/drivers/gpu/msm/kgsl_iommu.c b/drivers/gpu/msm/kgsl_iommu.c
index a06ebbf..6275a72 100644
--- a/drivers/gpu/msm/kgsl_iommu.c
+++ b/drivers/gpu/msm/kgsl_iommu.c
@@ -344,6 +344,9 @@
 	device = mmu->device;
 	adreno_dev = ADRENO_DEVICE(device);
 
+	mmu->fault = 1;
+	iommu_dev->fault = 1;
+
 	ptbase = KGSL_IOMMU_GET_CTX_REG(iommu, iommu_unit,
 					iommu_dev->ctx_id, TTBR0);
 
@@ -394,9 +397,6 @@
 
 	}
 
-	mmu->fault = 1;
-	iommu_dev->fault = 1;
-
 	kgsl_sharedmem_readl(&device->memstore, &curr_context_id,
 		KGSL_MEMSTORE_OFFSET(KGSL_MEMSTORE_GLOBAL, current_context));
 
@@ -425,8 +425,10 @@
 	 * the GPU and trigger a snapshot. To stall the transaction return
 	 * EBUSY error.
 	 */
-	if (adreno_dev->ft_pf_policy & KGSL_FT_PAGEFAULT_GPUHALT_ENABLE)
+	if (adreno_dev->ft_pf_policy & KGSL_FT_PAGEFAULT_GPUHALT_ENABLE) {
+		adreno_fatal_err_work(adreno_dev);
 		ret = -EBUSY;
+	}
 done:
 	return ret;
 }
@@ -1803,6 +1805,10 @@
 						iommu_unit,
 						iommu_unit->dev[j].ctx_id,
 						RESUME, 1);
+					KGSL_IOMMU_SET_CTX_REG(iommu,
+						iommu_unit,
+						iommu_unit->dev[j].ctx_id,
+						FSR, 0);
 					_iommu_unlock(iommu);
 					iommu_unit->dev[j].fault = 0;
 				}
@@ -2046,7 +2052,6 @@
 	.mmu_setstate = kgsl_iommu_setstate,
 	.mmu_device_setstate = kgsl_iommu_default_setstate,
 	.mmu_pagefault = NULL,
-	.mmu_pagefault_resume = kgsl_iommu_pagefault_resume,
 	.mmu_get_current_ptbase = kgsl_iommu_get_current_ptbase,
 	.mmu_enable_clk = kgsl_iommu_enable_clk,
 	.mmu_disable_clk_on_ts = kgsl_iommu_disable_clk_on_ts,
diff --git a/drivers/gpu/msm/kgsl_mmu.h b/drivers/gpu/msm/kgsl_mmu.h
index faba81e..64705f8 100644
--- a/drivers/gpu/msm/kgsl_mmu.h
+++ b/drivers/gpu/msm/kgsl_mmu.h
@@ -141,8 +141,6 @@
 	void (*mmu_pagefault) (struct kgsl_mmu *mmu);
 	phys_addr_t (*mmu_get_current_ptbase)
 			(struct kgsl_mmu *mmu);
-	void (*mmu_pagefault_resume)
-			(struct kgsl_mmu *mmu);
 	void (*mmu_disable_clk_on_ts)
 		(struct kgsl_mmu *mmu, uint32_t ts, bool ts_valid);
 	int (*mmu_enable_clk)
diff --git a/drivers/gpu/msm/z180.c b/drivers/gpu/msm/z180.c
index 103a751..ccb2e00 100644
--- a/drivers/gpu/msm/z180.c
+++ b/drivers/gpu/msm/z180.c
@@ -927,11 +927,11 @@
 	}
 }
 
-static void z180_irqctrl(struct kgsl_device *device, int state)
+static void z180_irqctrl(struct kgsl_device *device, unsigned int mask)
 {
 	/* Control interrupts for Z180 and the Z180 MMU */
 
-	if (state) {
+	if (mask) {
 		z180_regwrite(device, (ADDR_VGC_IRQENABLE >> 2), 3);
 		z180_regwrite(device, MH_INTERRUPT_MASK,
 			kgsl_mmu_get_int_mask());
diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c
index 74a252f..57aa835 100644
--- a/drivers/i2c/busses/i2c-qup.c
+++ b/drivers/i2c/busses/i2c-qup.c
@@ -192,6 +192,10 @@
 	struct qup_i2c_clk_path_vote clk_path_vote;
 };
 
+#ifdef CONFIG_PM
+static int i2c_qup_pm_resume_runtime(struct device *device);
+#endif
+
 #ifdef DEBUG
 static void
 qup_print_status(struct qup_i2c_dev *dev)
@@ -944,7 +948,13 @@
 	long timeout;
 	int err;
 
-	pm_runtime_get_sync(dev->dev);
+	/* Alternate if runtime power management is disabled */
+	if (!pm_runtime_enabled(dev->dev)) {
+		dev_dbg(dev->dev, "Runtime PM is disabled\n");
+		i2c_qup_pm_resume_runtime(dev->dev);
+	} else {
+		pm_runtime_get_sync(dev->dev);
+	}
 	mutex_lock(&dev->mlock);
 
 	if (dev->suspended) {
@@ -1754,22 +1764,24 @@
 	if (!pm_runtime_enabled(device) || !pm_runtime_suspended(device)) {
 		dev_dbg(device, "system suspend");
 		i2c_qup_pm_suspend_runtime(device);
+		/*
+		 * set the device's runtime PM status to 'suspended'
+		 */
+		pm_runtime_disable(device);
+		pm_runtime_set_suspended(device);
+		pm_runtime_enable(device);
 	}
 	return 0;
 }
 
 static int qup_i2c_resume(struct device *device)
 {
-	int ret = 0;
-	if (!pm_runtime_enabled(device) || !pm_runtime_suspended(device)) {
-		dev_dbg(device, "system resume");
-		ret = i2c_qup_pm_resume_runtime(device);
-		if (!ret) {
-			pm_runtime_mark_last_busy(device);
-			pm_request_autosuspend(device);
-		}
-		return ret;
-	}
+	/*
+	 * Rely on runtime-PM to call resume in case it is enabled
+	 * Even if it's not enabled, rely on 1st client transaction to do
+	 * clock ON and gpio configuration
+	 */
+	dev_dbg(device, "system resume");
 	return 0;
 }
 #endif /* CONFIG_PM */
diff --git a/drivers/input/misc/cm36283.c b/drivers/input/misc/cm36283.c
index 17127a8..8516ea5 100644
--- a/drivers/input/misc/cm36283.c
+++ b/drivers/input/misc/cm36283.c
@@ -674,17 +674,9 @@
 {
 	int ret = -EIO;
 	unsigned int delay;
-	
-	mutex_lock(&als_enable_mutex);
 
-	if (lpi->als_enable) {
-		dev_err(&lpi->i2c_client->dev, "%s: already enabled\n",
-			       __func__);
-		ret = 0;
-	} else {
-		ret = control_and_report(lpi, CONTROL_ALS, 1, 0);
-	}
-	
+	mutex_lock(&als_enable_mutex);
+	ret = control_and_report(lpi, CONTROL_ALS, 1, 0);
 	mutex_unlock(&als_enable_mutex);
 
 	delay = atomic_read(&lpi->ls_poll_delay);
@@ -1565,7 +1557,7 @@
 		__func__, lpi->ls_cmd);
 	
 	if (pdata->ls_cmd == 0) {
-		lpi->ls_cmd  = CM36283_ALS_IT_160ms | CM36283_ALS_GAIN_2;
+		lpi->ls_cmd  = CM36283_ALS_IT_80ms | CM36283_ALS_GAIN_2;
 	}
 
 	lp_info = lpi;
@@ -1582,17 +1574,17 @@
 	mutex_init(&ps_get_adc_mutex);
 
 
-  //SET LUX STEP FACTOR HERE
-  // if adc raw value one step = 5/100 = 1/20 = 0.05 lux
-  // the following will set the factor 0.05 = 1/20
-  // and lpi->golden_adc = 1;  
-  // set als_kadc = (ALS_CALIBRATED <<16) | 20;
+	/*
+	 * SET LUX STEP FACTOR HERE
+	 * if adc raw value one step = 5/100 = 1/20 = 0.05 lux
+	 * the following will set the factor 0.05 = 1/20
+	 * and lpi->golden_adc = 1;
+	 * set als_kadc = (ALS_CALIBRATED << 16) | 20;
+	 */
 
-  als_kadc = (ALS_CALIBRATED <<16) | 20;
-  lpi->golden_adc = 1;
-
-  //ls calibrate always set to 1 
-  lpi->ls_calibrate = 1;
+	als_kadc = (ALS_CALIBRATED << 16) | 10;
+	lpi->golden_adc = 100;
+	lpi->ls_calibrate = 0;
 
 	lightsensor_set_kvalue(lpi);
 	ret = lightsensor_update_table(lpi);
@@ -2009,27 +2001,40 @@
 	struct cm36283_info *lpi = lp_info;
 
 	if (lpi->als_enable) {
-		lightsensor_disable(lpi);
+		if (lightsensor_disable(lpi))
+			goto out;
 		lpi->als_enable = 1;
 	}
-	cm36283_power_set(lpi, 0);
+	if (cm36283_power_set(lpi, 0))
+		goto out;
 
 	return 0;
+
+out:
+	dev_err(&lpi->i2c_client->dev, "%s:failed during resume operation.\n",
+			__func__);
+	return -EIO;
 }
 
 static int cm36283_resume(struct device *dev)
 {
 	struct cm36283_info *lpi = lp_info;
 
-	cm36283_power_set(lpi, 1);
+	if (cm36283_power_set(lpi, 1))
+		goto out;
 
 	if (lpi->als_enable) {
-		cm36283_setup(lpi);
-		lightsensor_setup(lpi);
-		psensor_setup(lpi);
-		lightsensor_enable(lpi);
+		ls_initial_cmd(lpi);
+		psensor_initial_cmd(lpi);
+		if (lightsensor_enable(lpi))
+			goto out;
 	}
 	return 0;
+
+out:
+	dev_err(&lpi->i2c_client->dev, "%s:failed during resume operation.\n",
+			__func__);
+	return -EIO;
 }
 #endif
 
diff --git a/drivers/input/misc/kxtj9.c b/drivers/input/misc/kxtj9.c
index f879d78..94cc943 100644
--- a/drivers/input/misc/kxtj9.c
+++ b/drivers/input/misc/kxtj9.c
@@ -415,19 +415,16 @@
 		}
 	}
 
-	tj9->enable = true;
 	return 0;
 
 fail:
 	kxtj9_device_power_off(tj9);
-	tj9->enable = false;
 	return err;
 }
 
 static void kxtj9_disable(struct kxtj9_data *tj9)
 {
 	kxtj9_device_power_off(tj9);
-	tj9->enable = false;
 }
 
 
@@ -496,18 +493,21 @@
 	if (error)
 		return error;
 	mutex_lock(&input_dev->mutex);
-	disable_irq(client->irq);
 
-	if (data == 0)
+	if (data == 0) {
+		disable_irq(client->irq);
 		kxtj9_disable(tj9);
-	else if (data == 1)
-		kxtj9_enable(tj9);
-	else {
+		tj9->enable = false;
+	} else if (data == 1) {
+		if (!kxtj9_enable(tj9)) {
+			enable_irq(client->irq);
+			tj9->enable = true;
+		}
+	} else {
 		dev_err(&tj9->client->dev,
 			"Invalid value of input, input=%ld\n", data);
 	}
 
-	enable_irq(client->irq);
 	mutex_unlock(&input_dev->mutex);
 
 	return count;
@@ -555,7 +555,8 @@
 	/* Lock the device to prevent races with open/close (and itself) */
 	mutex_lock(&input_dev->mutex);
 
-	disable_irq(client->irq);
+	if (tj9->enable)
+		disable_irq(client->irq);
 
 	/*
 	 * Set current interval to the greater of the minimum interval or
@@ -563,9 +564,10 @@
 	 */
 	tj9->last_poll_interval = max(interval, tj9->pdata.min_interval);
 
-	kxtj9_update_odr(tj9, tj9->last_poll_interval);
-
-	enable_irq(client->irq);
+	if (tj9->enable) {
+		kxtj9_update_odr(tj9, tj9->last_poll_interval);
+		enable_irq(client->irq);
+	}
 	mutex_unlock(&input_dev->mutex);
 
 	return count;
@@ -857,6 +859,8 @@
 			goto err_destroy_input;
 		}
 
+		disable_irq(tj9->client->irq);
+
 		err = sysfs_create_group(&client->dev.kobj, &kxtj9_attribute_group);
 		if (err) {
 			dev_err(&client->dev, "sysfs create failed: %d\n", err);
@@ -923,7 +927,7 @@
 
 	mutex_lock(&input_dev->mutex);
 
-	if (input_dev->users)
+	if (input_dev->users && tj9->enable)
 		kxtj9_disable(tj9);
 
 	mutex_unlock(&input_dev->mutex);
@@ -939,7 +943,7 @@
 
 	mutex_lock(&input_dev->mutex);
 
-	if (input_dev->users)
+	if (input_dev->users && tj9->enable)
 		kxtj9_enable(tj9);
 
 	mutex_unlock(&input_dev->mutex);
diff --git a/drivers/input/misc/mma8x5x.c b/drivers/input/misc/mma8x5x.c
index a325d54..91aa928 100644
--- a/drivers/input/misc/mma8x5x.c
+++ b/drivers/input/misc/mma8x5x.c
@@ -53,6 +53,7 @@
 #define MMA8X5X_BUF_SIZE	7
 
 #define	MMA_SHUTTEDDOWN		(1 << 31)
+#define MMA_STATE_MASK		(~MMA_SHUTTEDDOWN)
 
 struct sensor_regulator {
 	struct regulator *vreg;
@@ -349,7 +350,7 @@
 	struct input_polled_dev *poll_dev = pdata->poll_dev;
 	struct mma8x5x_data_axis data;
 	mutex_lock(&pdata->data_lock);
-	if (pdata->active == MMA_STANDBY) {
+	if ((pdata->active & MMA_STATE_MASK) == MMA_STANDBY) {
 		poll_dev->poll_interval = POLL_STOP_TIME;
 		/* if standby ,set as 10s to slow the poll. */
 		goto out;
diff --git a/drivers/input/misc/stk3x1x.c b/drivers/input/misc/stk3x1x.c
index 937bf6c..b753d55 100644
--- a/drivers/input/misc/stk3x1x.c
+++ b/drivers/input/misc/stk3x1x.c
@@ -190,6 +190,7 @@
 
 struct stk3x1x_data {
 	struct i2c_client *client;
+	struct stk3x1x_platform_data *pdata;
 #if (!defined(STK_POLL_PS) || !defined(STK_POLL_ALS))
     int32_t irq;
     struct work_struct stk_work;
@@ -257,6 +258,7 @@
 static int32_t stk3x1x_set_ps_thd_h(struct stk3x1x_data *ps_data, uint16_t thd_h);
 static int32_t stk3x1x_set_als_thd_l(struct stk3x1x_data *ps_data, uint16_t thd_l);
 static int32_t stk3x1x_set_als_thd_h(struct stk3x1x_data *ps_data, uint16_t thd_h);
+static int stk3x1x_device_ctl(struct stk3x1x_data *ps_data, bool enable);
 //static int32_t stk3x1x_set_ps_aoffset(struct stk3x1x_data *ps_data, uint16_t offset);
 
 inline uint32_t stk_alscode2lux(struct stk3x1x_data *ps_data, uint32_t alscode)
@@ -600,6 +602,12 @@
 	if(curr_ps_enable == enable)
 		return 0;
 
+	if (enable) {
+		ret = stk3x1x_device_ctl(ps_data, enable);
+		if (ret)
+			return ret;
+	}
+
     ret = i2c_smbus_read_byte_data(ps_data->client, STK_STATE_REG);
     if (ret < 0)
     {
@@ -662,6 +670,12 @@
 #endif
 		ps_data->ps_enabled = false;
 	}
+	if (!enable) {
+		ret = stk3x1x_device_ctl(ps_data, enable);
+		if (ret)
+			return ret;
+	}
+
 	return ret;
 }
 
@@ -674,6 +688,11 @@
 	if(curr_als_enable == enable)
 		return 0;
 
+	if (enable) {
+		ret = stk3x1x_device_ctl(ps_data, enable);
+		if (ret)
+			return ret;
+	}
 #ifndef STK_POLL_ALS
     if (enable)
 	{
@@ -724,6 +743,12 @@
 			disable_irq(ps_data->irq);
 #endif
 	}
+	if (!enable) {
+		ret = stk3x1x_device_ctl(ps_data, enable);
+		if (ret)
+			return ret;
+	}
+
     return ret;
 }
 
@@ -1817,11 +1842,6 @@
 	int32_t ret;
 	struct stk3x1x_data *ps_data = i2c_get_clientdata(client);
 
-	mutex_lock(&ps_data->io_lock);
-	ps_data->als_enabled = false;
-	ps_data->ps_enabled = false;
-	mutex_unlock(&ps_data->io_lock);
-
 	ret = stk3x1x_software_reset(ps_data);
 	if(ret < 0)
 		return ret;
@@ -1946,7 +1966,7 @@
 }
 #endif	//#ifdef CONFIG_HAS_EARLYSUSPEND
 
-static int stk3x1x_power_on(struct stk3x1x_data *data, bool on)
+static int stk3x1x_power_ctl(struct stk3x1x_data *data, bool on)
 {
 	int ret = 0;
 
@@ -1963,7 +1983,11 @@
 			dev_err(&data->client->dev,
 				"Regulator vio disable failed ret=%d\n", ret);
 			regulator_enable(data->vdd);
+			return ret;
 		}
+		data->power_enabled = on;
+		dev_dbg(&data->client->dev, "stk3x1x_power_ctl on=%d\n",
+				on);
 	} else if (on && !data->power_enabled) {
 
 		ret = regulator_enable(data->vdd);
@@ -1978,7 +2002,11 @@
 			dev_err(&data->client->dev,
 				"Regulator vio enable failed ret=%d\n", ret);
 			regulator_disable(data->vdd);
+			return ret;
 		}
+		data->power_enabled = on;
+		dev_dbg(&data->client->dev, "stk3x1x_power_ctl on=%d\n",
+				on);
 	} else {
 		dev_warn(&data->client->dev,
 				"Power on=%d. enabled=%d\n",
@@ -2057,6 +2085,43 @@
 	return ret;
 }
 
+static int stk3x1x_device_ctl(struct stk3x1x_data *ps_data, bool enable)
+{
+	int ret;
+	struct device *dev = &ps_data->client->dev;
+
+	if (enable && !ps_data->power_enabled) {
+		ret = stk3x1x_power_ctl(ps_data, true);
+		if (ret) {
+			dev_err(dev, "Failed to enable device power\n");
+			goto err_exit;
+		}
+		ret = stk3x1x_init_all_setting(ps_data->client, ps_data->pdata);
+		if (ret < 0) {
+			stk3x1x_power_ctl(ps_data, false);
+			dev_err(dev, "Failed to re-init device setting\n");
+			goto err_exit;
+		}
+	} else if (!enable && ps_data->power_enabled) {
+		if (!ps_data->als_enabled && !ps_data->ps_enabled) {
+			ret = stk3x1x_power_ctl(ps_data, false);
+			if (ret) {
+				dev_err(dev, "Failed to disable device power\n");
+				goto err_exit;
+			}
+		} else {
+			dev_dbg(dev, "device control: als_enabled=%d, ps_enabled=%d\n",
+				ps_data->als_enabled, ps_data->ps_enabled);
+		}
+	} else {
+		dev_dbg(dev, "device control: enable=%d, power_enabled=%d\n",
+			enable, ps_data->power_enabled);
+	}
+	return 0;
+
+err_exit:
+	return ret;
+}
 #ifdef CONFIG_OF
 static int stk3x1x_parse_dt(struct device *dev,
 			struct stk3x1x_platform_data *pdata)
@@ -2205,6 +2270,7 @@
 	ps_data->als_transmittance = plat_data->transmittance;
 	ps_data->int_pin = plat_data->int_pin;
 	ps_data->use_fir = plat_data->use_fir;
+	ps_data->pdata = plat_data;
 
 	if (ps_data->als_transmittance == 0) {
 		dev_err(&client->dev,
@@ -2285,24 +2351,28 @@
 	if (err)
 		goto err_power_init;
 
-	err = stk3x1x_power_on(ps_data, true);
+	err = stk3x1x_power_ctl(ps_data, true);
 	if (err)
 		goto err_power_on;
 
-	err = stk3x1x_init_all_setting(client, plat_data);
-	if(err < 0)
-		goto err_init_all_setting;
+	ps_data->als_enabled = false;
+	ps_data->ps_enabled = false;
 #ifdef CONFIG_HAS_EARLYSUSPEND
 	ps_data->stk_early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
 	ps_data->stk_early_suspend.suspend = stk3x1x_early_suspend;
 	ps_data->stk_early_suspend.resume = stk3x1x_late_resume;
 	register_early_suspend(&ps_data->stk_early_suspend);
 #endif
-	printk(KERN_INFO "%s: probe successfully", __func__);
+	/* enable device power only when it is enabled */
+	err = stk3x1x_power_ctl(ps_data, false);
+	if (err)
+		goto err_init_all_setting;
+
+	dev_dbg(&client->dev, "%s: probe successfully", __func__);
 	return 0;
 
 err_init_all_setting:
-	stk3x1x_power_on(ps_data, false);
+	stk3x1x_power_ctl(ps_data, false);
 err_power_on:
 	stk3x1x_power_init(ps_data, false);
 err_power_init:
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index 4dbe5c1..3731561 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -1727,7 +1727,7 @@
 	}
 
 	ret = request_firmware(&fw, fn, dev);
-	if (ret < 0) {
+	if (ret < 0 || !fw) {
 		dev_err(dev, "Unable to open firmware %s\n", fn);
 		goto free_frame;
 	}
diff --git a/drivers/input/touchscreen/cyttsp-i2c-qc.c b/drivers/input/touchscreen/cyttsp-i2c-qc.c
index 6c4e6b7..2b1360e 100644
--- a/drivers/input/touchscreen/cyttsp-i2c-qc.c
+++ b/drivers/input/touchscreen/cyttsp-i2c-qc.c
@@ -2873,6 +2873,21 @@
 	return rc;
 }
 
+static void cyttsp_release_all(struct cyttsp *ts)
+{
+	int id;
+
+	for (id = 0; id < CY_NUM_MT_TCH_ID; id++) {
+		input_mt_slot(ts->input, id);
+		input_mt_report_slot_state(ts->input, MT_TOOL_FINGER, 0);
+	}
+
+	input_report_key(ts->input, BTN_TOUCH, 0);
+	input_report_key(ts->input, BTN_TOOL_FINGER, 0);
+
+	input_sync(ts->input);
+}
+
 /* Function to manage power-on resume */
 static int cyttsp_resume(struct device *dev)
 {
@@ -2978,6 +2993,8 @@
 	else
 		disable_irq(ts->client->irq);
 
+	cyttsp_release_all(ts);
+
 	if (!(retval < CY_OK)) {
 		if (ts->platform_data->use_sleep &&
 			(ts->platform_data->power_state == CY_ACTIVE_STATE)) {
diff --git a/drivers/input/touchscreen/ft5x06_ts.c b/drivers/input/touchscreen/ft5x06_ts.c
index aa50d44..9a4301e 100644
--- a/drivers/input/touchscreen/ft5x06_ts.c
+++ b/drivers/input/touchscreen/ft5x06_ts.c
@@ -131,8 +131,9 @@
 #define FT_FW_PKT_DLY_MS	20
 #define FT_FW_LAST_PKT		0x6ffa
 #define FT_EARSE_DLY_MS		100
+#define FT_55_AA_DLY_NS		5000
 
-#define FT_UPGRADE_LOOP		10
+#define FT_UPGRADE_LOOP		30
 #define FT_CAL_START		0x04
 #define FT_CAL_FIN		0x00
 #define FT_CAL_STORE		0x05
@@ -142,6 +143,30 @@
 
 #define FT_INFO_MAX_LEN		512
 
+#define FT_BLOADER_SIZE_OFF	12
+#define FT_BLOADER_NEW_SIZE	30
+#define FT_DATA_LEN_OFF_OLD_FW	8
+#define FT_DATA_LEN_OFF_NEW_FW	14
+#define FT_FINISHING_PKT_LEN_OLD_FW	6
+#define FT_FINISHING_PKT_LEN_NEW_FW	12
+#define FT_MAGIC_BLOADER_Z7	0x7bfa
+#define FT_MAGIC_BLOADER_LZ4	0x6ffa
+#define FT_MAGIC_BLOADER_GZF_30	0x7ff4
+#define FT_MAGIC_BLOADER_GZF	0x7bf4
+
+enum {
+	FT_BLOADER_VERSION_LZ4 = 0,
+	FT_BLOADER_VERSION_Z7 = 1,
+	FT_BLOADER_VERSION_GZF = 2,
+};
+
+enum {
+	FT_FT5336_FAMILY_ID_0x11 = 0x11,
+	FT_FT5336_FAMILY_ID_0x12 = 0x12,
+	FT_FT5336_FAMILY_ID_0x13 = 0x13,
+	FT_FT5336_FAMILY_ID_0x14 = 0x14,
+};
+
 #define FT_STORE_TS_INFO(buf, id, name, max_tch, group_id, fw_vkey_support, \
 			fw_name, fw_maj, fw_min, fw_sub_min) \
 			snprintf(buf, FT_INFO_MAX_LEN, \
@@ -288,7 +313,7 @@
 	struct ft5x06_ts_data *data = dev_id;
 	struct input_dev *ip_dev;
 	int rc, i;
-	u32 id, x, y, pressure, status, num_touches;
+	u32 id, x, y, status, num_touches;
 	u8 reg = 0x00, *buf;
 	bool update_input = false;
 
@@ -329,11 +354,9 @@
 
 		input_mt_slot(ip_dev, id);
 		if (status == FT_TOUCH_DOWN || status == FT_TOUCH_CONTACT) {
-			pressure = FT_PRESS;
 			input_mt_report_slot_state(ip_dev, MT_TOOL_FINGER, 1);
 			input_report_abs(ip_dev, ABS_MT_POSITION_X, x);
 			input_report_abs(ip_dev, ABS_MT_POSITION_Y, y);
-			input_report_abs(ip_dev, ABS_MT_PRESSURE, pressure);
 		} else {
 			input_mt_report_slot_state(ip_dev, MT_TOOL_FINGER, 0);
 		}
@@ -479,7 +502,7 @@
 		input_mt_slot(data->input_dev, i);
 		input_mt_report_slot_state(data->input_dev, MT_TOOL_FINGER, 0);
 	}
-	input_report_key(data->input_dev, BTN_TOUCH, 0);
+	input_mt_report_pointer_emulation(data->input_dev, false);
 	input_sync(data->input_dev);
 
 	if (gpio_is_valid(data->pdata->reset_gpio)) {
@@ -647,11 +670,20 @@
 	u8 reset_reg;
 	u8 w_buf[FT_MAX_WR_BUF] = {0}, r_buf[FT_MAX_RD_BUF] = {0};
 	u8 pkt_buf[FT_FW_PKT_LEN + FT_FW_PKT_META_LEN];
-	int rc, i, j, temp;
+	int i, j, temp;
 	u32 pkt_num, pkt_len;
+	u8 is_5336_new_bootloader = false;
+	u8 is_5336_fwsize_30 = false;
 	u8 fw_ecc;
 
+	/* determine firmware size */
+	if (*(data + data_len - FT_BLOADER_SIZE_OFF) == FT_BLOADER_NEW_SIZE)
+		is_5336_fwsize_30 = true;
+	else
+		is_5336_fwsize_30 = false;
+
 	for (i = 0, j = 0; i < FT_UPGRADE_LOOP; i++) {
+		msleep(FT_EARSE_DLY_MS);
 		/* reset - write 0xaa and 0x55 to reset register */
 		if (ts_data->family_id == FT6X06_ID)
 			reset_reg = FT_RST_CMD_REG2;
@@ -662,16 +694,17 @@
 		msleep(info.delay_aa);
 
 		ft5x0x_write_reg(client, reset_reg, FT_UPGRADE_55);
-		msleep(info.delay_55);
+		if (i <= (FT_UPGRADE_LOOP / 2))
+			msleep(info.delay_55 + i * 3);
+		else
+			msleep(info.delay_55 - (i - (FT_UPGRADE_LOOP / 2)) * 2);
 
 		/* Enter upgrade mode */
 		w_buf[0] = FT_UPGRADE_55;
-		w_buf[1] = FT_UPGRADE_AA;
-		do {
-			j++;
-			rc = ft5x06_i2c_write(client, w_buf, 2);
-			msleep(FT_RETRY_DLY);
-		} while (rc <= 0 && j < FT_MAX_TRIES);
+		ft5x06_i2c_write(client, w_buf, 1);
+		usleep(FT_55_AA_DLY_NS);
+		w_buf[0] = FT_UPGRADE_AA;
+		ft5x06_i2c_write(client, w_buf, 1);
 
 		/* check READ_ID */
 		msleep(info.delay_readid);
@@ -684,7 +717,9 @@
 
 		if (r_buf[0] != info.upgrade_id_1
 			|| r_buf[1] != info.upgrade_id_2) {
-			dev_err(&client->dev, "Upgrade ID mismatch(%d)\n", i);
+			dev_err(&client->dev, "Upgrade ID mismatch(%d), IC=0x%x 0x%x, info=0x%x 0x%x\n",
+				i, r_buf[0], r_buf[1],
+				info.upgrade_id_1, info.upgrade_id_2);
 		} else
 			break;
 	}
@@ -694,17 +729,44 @@
 		return -EIO;
 	}
 
+	w_buf[0] = 0xcd;
+	ft5x06_i2c_read(client, w_buf, 1, r_buf, 1);
+
+	if (r_buf[0] <= 4)
+		is_5336_new_bootloader = FT_BLOADER_VERSION_LZ4;
+	else if (r_buf[0] == 7)
+		is_5336_new_bootloader = FT_BLOADER_VERSION_Z7;
+	else if (r_buf[0] >= 0x0f &&
+		((ts_data->family_id == FT_FT5336_FAMILY_ID_0x11) ||
+		(ts_data->family_id == FT_FT5336_FAMILY_ID_0x12) ||
+		(ts_data->family_id == FT_FT5336_FAMILY_ID_0x13) ||
+		(ts_data->family_id == FT_FT5336_FAMILY_ID_0x14)))
+		is_5336_new_bootloader = FT_BLOADER_VERSION_GZF;
+	else
+		is_5336_new_bootloader = FT_BLOADER_VERSION_LZ4;
+
+	dev_dbg(&client->dev, "bootloader type=%d, r_buf=0x%x, family_id=0x%x\n",
+		is_5336_new_bootloader, r_buf[0], ts_data->family_id);
+	/* is_5336_new_bootloader = FT_BLOADER_VERSION_GZF; */
+
 	/* erase app and panel paramenter area */
 	w_buf[0] = FT_ERASE_APP_REG;
 	ft5x06_i2c_write(client, w_buf, 1);
 	msleep(info.delay_erase_flash);
 
-	w_buf[0] = FT_ERASE_PANEL_REG;
-	ft5x06_i2c_write(client, w_buf, 1);
+	if (is_5336_fwsize_30) {
+		w_buf[0] = FT_ERASE_PANEL_REG;
+		ft5x06_i2c_write(client, w_buf, 1);
+	}
 	msleep(FT_EARSE_DLY_MS);
 
 	/* program firmware */
-	data_len = data_len - 8;
+	if (is_5336_new_bootloader == FT_BLOADER_VERSION_LZ4
+		|| is_5336_new_bootloader == FT_BLOADER_VERSION_Z7)
+		data_len = data_len - FT_DATA_LEN_OFF_OLD_FW;
+	else
+		data_len = data_len - FT_DATA_LEN_OFF_NEW_FW;
+
 	pkt_num = (data_len) / FT_FW_PKT_LEN;
 	pkt_len = FT_FW_PKT_LEN;
 	pkt_buf[0] = FT_FW_START_REG;
@@ -747,17 +809,45 @@
 	}
 
 	/* send the finishing packet */
-	for (i = 0; i < 6; i++) {
-		temp = FT_FW_LAST_PKT + i;
-		pkt_buf[2] = (u8) (temp >> 8);
-		pkt_buf[3] = (u8) temp;
-		temp = 1;
-		pkt_buf[4] = (u8) (temp >> 8);
-		pkt_buf[5] = (u8) temp;
-		pkt_buf[6] = data[data_len + i];
-		fw_ecc ^= pkt_buf[6];
-		ft5x06_i2c_write(client, pkt_buf, temp + FT_FW_PKT_META_LEN);
-		msleep(FT_FW_PKT_DLY_MS);
+	if (is_5336_new_bootloader == FT_BLOADER_VERSION_LZ4 ||
+		is_5336_new_bootloader == FT_BLOADER_VERSION_Z7) {
+		for (i = 0; i < FT_FINISHING_PKT_LEN_OLD_FW; i++) {
+			if (is_5336_new_bootloader  == FT_BLOADER_VERSION_Z7)
+				temp = FT_MAGIC_BLOADER_Z7 + i;
+			else if (is_5336_new_bootloader ==
+						FT_BLOADER_VERSION_LZ4)
+				temp = FT_MAGIC_BLOADER_LZ4 + i;
+			pkt_buf[2] = (u8)(temp >> 8);
+			pkt_buf[3] = (u8)temp;
+			temp = 1;
+			pkt_buf[4] = (u8)(temp >> 8);
+			pkt_buf[5] = (u8)temp;
+			pkt_buf[6] = data[data_len + i];
+			fw_ecc ^= pkt_buf[6];
+
+			ft5x06_i2c_write(client,
+				pkt_buf, temp + FT_FW_PKT_META_LEN);
+			msleep(FT_FW_PKT_DLY_MS);
+		}
+	} else if (is_5336_new_bootloader == FT_BLOADER_VERSION_GZF) {
+		for (i = 0; i < FT_FINISHING_PKT_LEN_NEW_FW; i++) {
+			if (is_5336_fwsize_30)
+				temp = FT_MAGIC_BLOADER_GZF_30 + i;
+			else
+				temp = FT_MAGIC_BLOADER_GZF + i;
+			pkt_buf[2] = (u8)(temp >> 8);
+			pkt_buf[3] = (u8)temp;
+			temp = 1;
+			pkt_buf[4] = (u8)(temp >> 8);
+			pkt_buf[5] = (u8)temp;
+			pkt_buf[6] = data[data_len + i];
+			fw_ecc ^= pkt_buf[6];
+
+			ft5x06_i2c_write(client,
+				pkt_buf, temp + FT_FW_PKT_META_LEN);
+			msleep(FT_FW_PKT_DLY_MS);
+
+		}
 	}
 
 	/* verify checksum */
@@ -1369,7 +1459,6 @@
 			     pdata->x_max, 0, 0);
 	input_set_abs_params(input_dev, ABS_MT_POSITION_Y, pdata->y_min,
 			     pdata->y_max, 0, 0);
-	input_set_abs_params(input_dev, ABS_MT_PRESSURE, 0, FT_PRESS, 0, 0);
 
 	err = input_register_device(input_dev);
 	if (err) {
@@ -1454,7 +1543,7 @@
 		goto free_reset_gpio;
 	}
 
-	data->family_id = reg_value;
+	data->family_id = pdata->family_id;
 
 	err = request_threaded_irq(client->irq, NULL,
 				   ft5x06_ts_interrupt, pdata->irqflags,
diff --git a/drivers/input/touchscreen/gt9xx/gt9xx.c b/drivers/input/touchscreen/gt9xx/gt9xx.c
index 8b08ac9..ba38061 100644
--- a/drivers/input/touchscreen/gt9xx/gt9xx.c
+++ b/drivers/input/touchscreen/gt9xx/gt9xx.c
@@ -95,6 +95,8 @@
 static void gtp_reset_guitar(struct goodix_ts_data *ts, int ms);
 static void gtp_int_sync(struct goodix_ts_data *ts, int ms);
 static int gtp_i2c_test(struct i2c_client *client);
+static int goodix_power_off(struct goodix_ts_data *ts);
+static int goodix_power_on(struct goodix_ts_data *ts);
 
 #if defined(CONFIG_FB)
 static int fb_notifier_callback(struct notifier_block *self,
@@ -758,7 +760,7 @@
 	ts: private data.
 Output:
 	Executive outcomes.
-	1: succeed, otherwise failed.
+	>0: succeed, otherwise failed.
 *******************************************************/
 static s8 gtp_enter_sleep(struct goodix_ts_data  *ts)
 {
@@ -769,20 +771,37 @@
 		(u8)GTP_REG_SLEEP, 5};
 
 	ret = gpio_direction_output(ts->pdata->irq_gpio, 0);
-	usleep(5000);
-	while (retry++ < 5) {
-		ret = gtp_i2c_write(ts->client, i2c_control_buf, 3);
-		if (ret > 0) {
-			dev_dbg(&ts->client->dev,
-				"GTP enter sleep!");
-			return ret;
+	if (ret)
+		dev_err(&ts->client->dev,
+			"GTP sleep: Cannot reconfig gpio %d.\n",
+			ts->pdata->irq_gpio);
+	if (ts->pdata->enable_power_off) {
+		ret = gpio_direction_output(ts->pdata->reset_gpio, 0);
+		if (ret)
+			dev_err(&ts->client->dev,
+				"GTP sleep: Cannot reconfig gpio %d.\n",
+				ts->pdata->reset_gpio);
+		ret = goodix_power_off(ts);
+		if (ret) {
+			dev_err(&ts->client->dev, "GTP power off failed.\n");
+			return 0;
 		}
-		msleep(20);
+		return 1;
+	} else {
+		usleep(5000);
+		while (retry++ < 5) {
+			ret = gtp_i2c_write(ts->client, i2c_control_buf, 3);
+			if (ret == 1) {
+				dev_dbg(&ts->client->dev, "GTP enter sleep!");
+				return ret;
+			}
+			msleep(20);
+		}
+		dev_err(&ts->client->dev, "GTP send sleep cmd failed.\n");
+		return ret;
 	}
-	dev_err(&ts->client->dev, "GTP send sleep cmd failed.\n");
-	return ret;
 }
-#endif
+#endif /* !GTP_SLIDE_WAKEUP */
 
 /*******************************************************
 Function:
@@ -798,17 +817,36 @@
 	u8 retry = 0;
 	s8 ret = -1;
 
-#if GTP_POWER_CTRL_SLEEP
-	gtp_reset_guitar(ts, 20);
+	if (ts->pdata->enable_power_off) {
+		ret = gpio_direction_output(ts->pdata->irq_gpio, 0);
+		if (ret)
+			dev_err(&ts->client->dev,
+				"GTP wakeup: Cannot reconfig gpio %d.\n",
+				ts->pdata->irq_gpio);
+		ret = gpio_direction_output(ts->pdata->reset_gpio, 0);
+		if (ret)
+			dev_err(&ts->client->dev,
+				"GTP wakeup: Cannot reconfig gpio %d.\n",
+				ts->pdata->reset_gpio);
+		ret = goodix_power_on(ts);
+		if (ret) {
+			dev_err(&ts->client->dev, "GTP power on failed.\n");
+			return 0;
+		}
 
-	ret = gtp_send_cfg(ts);
-	if (ret > 0) {
+		gtp_reset_guitar(ts, 20);
+
+		ret = gtp_send_cfg(ts);
+		if (ret <= 0) {
+			dev_err(&ts->client->dev,
+				"GTP wakeup sleep failed.\n");
+			return ret;
+		}
+
 		dev_dbg(&ts->client->dev,
-			"Wakeup sleep send config success.");
-		return 1;
-	}
-#else
-	while (retry++ < 10) {
+				"Wakeup sleep send config success.");
+	} else {
+err_retry:
 #if GTP_SLIDE_WAKEUP
 		/* wakeup not by slide */
 		if (DOZE_WAKEUP != doze_status)
@@ -825,7 +863,7 @@
 		}
 #endif
 		ret = gtp_i2c_test(ts->client);
-		if (ret > 0) {
+		if (ret == 2) {
 			dev_dbg(&ts->client->dev, "GTP wakeup sleep.");
 #if (!GTP_SLIDE_WAKEUP)
 			if (chip_gt9xxs == 0) {
@@ -839,10 +877,10 @@
 			return ret;
 		}
 		gtp_reset_guitar(ts, 20);
+		if (retry++ < 10)
+			goto err_retry;
+		dev_err(&ts->client->dev, "GTP wakeup sleep failed.\n");
 	}
-#endif
-
-	dev_err(&ts->client->dev, "GTP wakeup sleep failed.\n");
 	return ret;
 }
 #endif /* !CONFIG_HAS_EARLYSUSPEND && !CONFIG_FB*/
@@ -1055,9 +1093,7 @@
 
 	dev_info(&client->dev, "Goodix Product ID = %s\n", product_id);
 
-	if (!IS_ERR(ts->pdata->product_id))
-		ret = strcmp(product_id, ts->pdata->product_id);
-
+	ret = strcmp(product_id, ts->pdata->product_id);
 	if (ret != 0)
 		return -EINVAL;
 
@@ -1292,6 +1328,12 @@
 {
 	int ret;
 
+	if (ts->power_on) {
+		dev_info(&ts->client->dev,
+				"Device already power on\n");
+		return 0;
+	}
+
 	if (!IS_ERR(ts->avdd)) {
 		ret = reg_set_optimum_mode_check(ts->avdd,
 			GOODIX_VDD_LOAD_MAX_UA);
@@ -1358,6 +1400,7 @@
 			}
 	}
 
+	ts->power_on = true;
 	return 0;
 
 err_enable_vcc_i2c:
@@ -1376,6 +1419,7 @@
 		regulator_disable(ts->avdd);
 err_enable_avdd:
 err_set_opt_avdd:
+	ts->power_on = false;
 	return ret;
 }
 
@@ -1389,6 +1433,12 @@
 {
 	int ret;
 
+	if (!ts->power_on) {
+		dev_info(&ts->client->dev,
+				"Device already power off\n");
+		return 0;
+	}
+
 	if (!IS_ERR(ts->vcc_i2c)) {
 		ret = regulator_set_voltage(ts->vcc_i2c, 0,
 			GOODIX_I2C_VTG_MAX_UV);
@@ -1421,6 +1471,7 @@
 				"Regulator avdd disable failed ret=%d\n", ret);
 	}
 
+	ts->power_on = false;
 	return 0;
 }
 
@@ -1473,6 +1524,50 @@
 	return 0;
 }
 
+static ssize_t gtp_fw_name_show(struct device *dev,
+				struct device_attribute *attr, char *buf)
+{
+	struct goodix_ts_data *ts = dev_get_drvdata(dev);
+
+	if (!strlen(ts->fw_name))
+		return snprintf(buf, GTP_FW_NAME_MAXSIZE - 1,
+			"No fw name has been given.");
+	else
+		return snprintf(buf, GTP_FW_NAME_MAXSIZE - 1,
+			"%s\n", ts->fw_name);
+}
+
+static ssize_t gtp_fw_name_store(struct device *dev,
+				struct device_attribute *attr,
+				const char *buf, size_t size)
+{
+	struct goodix_ts_data *ts = dev_get_drvdata(dev);
+
+	if (size > GTP_FW_NAME_MAXSIZE - 1) {
+		dev_err(dev, "FW name size exceeds the limit.");
+		return -EINVAL;
+	}
+
+	strlcpy(ts->fw_name, buf, size);
+	if (ts->fw_name[size-1] == '\n')
+		ts->fw_name[size-1] = '\0';
+
+	return size;
+}
+
+static DEVICE_ATTR(fw_name, (S_IRUGO | S_IWUSR | S_IWGRP),
+			gtp_fw_name_show,
+			gtp_fw_name_store);
+
+static struct attribute *gtp_attrs[] = {
+	&dev_attr_fw_name.attr,
+	NULL
+};
+
+static const struct attribute_group gtp_attr_grp = {
+	.attrs = gtp_attrs,
+};
+
 static int goodix_ts_get_dt_coords(struct device *dev, char *name,
 				struct goodix_ts_platform_data *pdata)
 {
@@ -1536,6 +1631,9 @@
 
 	pdata->no_force_update = of_property_read_bool(np,
 						"goodix,no-force-update");
+
+	pdata->enable_power_off = of_property_read_bool(np,
+						"goodix,enable-power-off");
 	/* reset, irq gpio info */
 	pdata->reset_gpio = of_get_named_gpio_flags(np, "reset-gpios",
 				0, &pdata->reset_gpio_flags);
@@ -1549,8 +1647,17 @@
 
 	rc = of_property_read_string(np, "goodix,product-id",
 						&pdata->product_id);
-	if (rc < 0 || strlen(pdata->product_id) > GTP_PRODUCT_ID_MAXSIZE)
-		return rc;
+	if (rc && (rc != -EINVAL)) {
+		dev_err(dev, "Failed to parse product_id.");
+		return -EINVAL;
+	}
+
+	rc = of_property_read_string(np, "goodix,fw_name",
+						&pdata->fw_name);
+	if (rc && (rc != -EINVAL)) {
+		dev_err(dev, "Failed to parse firmware name.\n");
+		return -EINVAL;
+	}
 
 	prop = of_find_property(np, "goodix,button-map", NULL);
 	if (prop) {
@@ -1662,6 +1769,7 @@
 	spin_lock_init(&ts->irq_lock);
 	i2c_set_clientdata(client, ts);
 	ts->gtp_rawdiff_mode = 0;
+	ts->power_on = false;
 
 	ret = goodix_power_init(ts);
 	if (ret) {
@@ -1689,12 +1797,16 @@
 		goto exit_free_io_port;
 	}
 
+	if (pdata->fw_name)
+		strlcpy(ts->fw_name, pdata->fw_name,
+						strlen(pdata->fw_name) + 1);
+
 #if GTP_AUTO_UPDATE
 	ret = gup_init_update_proc(ts);
 	if (ret < 0) {
 		dev_err(&client->dev,
 			"GTP Create firmware update thread error.\n");
-		goto exit_free_io_port;
+		goto exit_power_off;
 	}
 #endif
 
@@ -1711,7 +1823,9 @@
 		dev_err(&client->dev, "GTP request input dev failed.\n");
 		goto exit_free_inputdev;
 	}
+	input_set_drvdata(ts->input_dev, ts);
 
+	mutex_init(&ts->lock);
 #if defined(CONFIG_FB)
 	ts->fb_notif.notifier_call = fb_notifier_callback;
 	ret = fb_register_client(&ts->fb_notif);
@@ -1754,9 +1868,16 @@
 #if GTP_ESD_PROTECT
 	gtp_esd_switch(client, SWITCH_ON);
 #endif
+	ret = sysfs_create_group(&client->dev.kobj, &gtp_attr_grp);
+	if (ret < 0) {
+		dev_err(&client->dev, "sys file creation failed.\n");
+		goto exit_free_irq;
+	}
+
 	init_done = true;
 	return 0;
 exit_free_irq:
+	mutex_destroy(&ts->lock);
 #if defined(CONFIG_FB)
 	if (fb_unregister_client(&ts->fb_notif))
 		dev_err(&client->dev,
@@ -1806,6 +1927,8 @@
 {
 	struct goodix_ts_data *ts = i2c_get_clientdata(client);
 
+	sysfs_remove_group(&ts->input_dev->dev.kobj, &gtp_attr_grp);
+
 #if defined(CONFIG_FB)
 	if (fb_unregister_client(&ts->fb_notif))
 		dev_err(&client->dev,
@@ -1813,6 +1936,7 @@
 #elif defined(CONFIG_HAS_EARLYSUSPEND)
 	unregister_early_suspend(&ts->early_suspend);
 #endif
+	mutex_destroy(&ts->lock);
 
 #if GTP_CREATE_WR_NODE
 	uninit_wr_node();
@@ -1868,6 +1992,7 @@
 {
 	int ret = -1, i;
 
+	mutex_lock(&ts->lock);
 #if GTP_ESD_PROTECT
 	ts->gtp_is_suspend = 1;
 	gtp_esd_switch(ts->client, SWITCH_OFF);
@@ -1888,12 +2013,13 @@
 
 	ret = gtp_enter_sleep(ts);
 #endif
-	if (ret < 0)
+	if (ret <= 0)
 		dev_err(&ts->client->dev, "GTP early suspend failed.\n");
 	/* to avoid waking up while not sleeping,
 	 * delay 48 + 10ms to ensure reliability
 	 */
 	msleep(58);
+	mutex_unlock(&ts->lock);
 }
 
 /*******************************************************
@@ -1908,13 +2034,14 @@
 {
 	int ret = -1;
 
+	mutex_lock(&ts->lock);
 	ret = gtp_wakeup_sleep(ts);
 
 #if GTP_SLIDE_WAKEUP
 	doze_status = DOZE_DISABLED;
 #endif
 
-	if (ret < 0)
+	if (ret <= 0)
 		dev_err(&ts->client->dev, "GTP resume failed.\n");
 
 	if (ts->use_irq)
@@ -1927,6 +2054,7 @@
 	ts->gtp_is_suspend = 0;
 	gtp_esd_switch(ts->client, SWITCH_ON);
 #endif
+	mutex_unlock(&ts->lock);
 }
 
 #if defined(CONFIG_FB)
diff --git a/drivers/input/touchscreen/gt9xx/gt9xx.h b/drivers/input/touchscreen/gt9xx/gt9xx.h
index 1fdbfa3..1d31f2a 100644
--- a/drivers/input/touchscreen/gt9xx/gt9xx.h
+++ b/drivers/input/touchscreen/gt9xx/gt9xx.h
@@ -36,6 +36,7 @@
 #include <linux/regulator/consumer.h>
 #include <linux/firmware.h>
 #include <linux/debugfs.h>
+#include <linux/mutex.h>
 
 #if defined(CONFIG_FB)
 #include <linux/notifier.h>
@@ -46,12 +47,15 @@
 #endif
 
 #define GOODIX_MAX_CFG_GROUP	6
+#define GTP_FW_NAME_MAXSIZE	50
+
 struct goodix_ts_platform_data {
 	int irq_gpio;
 	u32 irq_gpio_flags;
 	int reset_gpio;
 	u32 reset_gpio_flags;
 	const char *product_id;
+	const char *fw_name;
 	u32 x_max;
 	u32 y_max;
 	u32 x_min;
@@ -62,6 +66,7 @@
 	u32 panel_maxy;
 	bool no_force_update;
 	bool i2c_pull_up;
+	bool enable_power_off;
 	size_t config_data_len[GOODIX_MAX_CFG_GROUP];
 	u8 *config_data[GOODIX_MAX_CFG_GROUP];
 };
@@ -73,6 +78,7 @@
 	struct hrtimer timer;
 	struct workqueue_struct *goodix_wq;
 	struct work_struct	work;
+	char fw_name[GTP_FW_NAME_MAXSIZE];
 	s32 irq_is_disabled;
 	s32 use_irq;
 	u16 abs_x_max;
@@ -89,6 +95,8 @@
 	u8  fixed_cfg;
 	u8  esd_running;
 	u8  fw_error;
+	bool power_on;
+	struct mutex lock;
 	struct regulator *avdd;
 	struct regulator *vdd;
 	struct regulator *vcc_i2c;
@@ -107,7 +115,6 @@
 #define GTP_CHANGE_X2Y			0
 #define GTP_DRIVER_SEND_CFG		1
 #define GTP_HAVE_TOUCH_KEY		1
-#define GTP_POWER_CTRL_SLEEP	0
 
 /* auto updated by .bin file as default */
 #define GTP_AUTO_UPDATE			0
@@ -119,6 +126,7 @@
 #define GTP_ESD_PROTECT			0
 #define GTP_WITH_PEN			0
 
+/* This cannot work when enable-power-off is on */
 #define GTP_SLIDE_WAKEUP		0
 /* double-click wakeup, function together with GTP_SLIDE_WAKEUP */
 #define GTP_DBL_CLK_WAKEUP		0
diff --git a/drivers/input/touchscreen/synaptics_fw_update.c b/drivers/input/touchscreen/synaptics_fw_update.c
index 70c1307..e4e3aca 100644
--- a/drivers/input/touchscreen/synaptics_fw_update.c
+++ b/drivers/input/touchscreen/synaptics_fw_update.c
@@ -352,8 +352,7 @@
 		(data->options_firmware_id == (1 << OPTION_BUILD_INFO));
 
 	if (img->is_contain_build_info) {
-		img->firmware_id = extract_uint(data->firmware_id);
-		img->package_id = (data->pkg_id_rev_msb << 8) |
+		img->package_id = (data->pkg_id_msb << 8) |
 				data->pkg_id_lsb;
 		img->package_revision_id = (data->pkg_id_rev_msb << 8) |
 				data->pkg_id_rev_lsb;
diff --git a/drivers/input/touchscreen/synaptics_i2c_rmi4.c b/drivers/input/touchscreen/synaptics_i2c_rmi4.c
index 4e75971..ea3fe2c 100644
--- a/drivers/input/touchscreen/synaptics_i2c_rmi4.c
+++ b/drivers/input/touchscreen/synaptics_i2c_rmi4.c
@@ -67,10 +67,10 @@
 #define F11_STD_CTRL_LEN 10
 #define F11_STD_DATA_LEN 12
 
-#define NORMAL_OPERATION (0 << 0)
-#define SENSOR_SLEEP (1 << 0)
-#define NO_SLEEP_OFF (0 << 2)
-#define NO_SLEEP_ON (1 << 2)
+#define NORMAL_OPERATION 0
+#define SENSOR_SLEEP 1
+#define NO_SLEEP_OFF 0
+#define NO_SLEEP_ON 1
 
 enum device_status {
 	STATUS_NO_ERROR = 0x00,
@@ -79,9 +79,12 @@
 	STATUS_DEVICE_FAILURE = 0x03,
 	STATUS_CONFIG_CRC_FAILURE = 0x04,
 	STATUS_FIRMWARE_CRC_FAILURE = 0x05,
-	STATUS_CRC_IN_PROGRESS = 0x06
+	STATUS_CRC_IN_PROGRESS = 0x06,
+	STATUS_UNCONFIGURED = 0x80
 };
 
+#define DEVICE_CONFIGURED 0x1
+
 #define RMI4_VTG_MIN_UV		2700000
 #define RMI4_VTG_MAX_UV		3300000
 #define RMI4_ACTIVE_LOAD_UA	15000
@@ -108,6 +111,13 @@
 
 static int synaptics_rmi4_reset_device(struct synaptics_rmi4_data *rmi4_data);
 
+static void synaptics_rmi4_sensor_wake(struct synaptics_rmi4_data *rmi4_data);
+
+static void synaptics_rmi4_sensor_sleep(struct synaptics_rmi4_data *rmi4_data);
+
+static int synaptics_rmi4_check_configuration(struct synaptics_rmi4_data
+		*rmi4_data);
+
 #ifdef CONFIG_PM
 static int synaptics_rmi4_suspend(struct device *dev);
 
@@ -172,6 +182,20 @@
 	};
 };
 
+struct synaptics_rmi4_f01_device_control_0 {
+	union {
+		struct {
+			unsigned char sleep_mode:2;
+			unsigned char nosleep:1;
+			unsigned char reserved:2;
+			unsigned char charger_input:1;
+			unsigned char report_rate:1;
+			unsigned char configured:1;
+		} __packed;
+		unsigned char data[1];
+	};
+};
+
 struct synaptics_rmi4_f12_query_5 {
 	union {
 		struct {
@@ -2034,6 +2058,30 @@
 	return 0;
 }
 
+/*
+* This function checks whether the fhandler already existis in the
+* support_fn_list or not.
+* If it exists then return 1 as found or return 0 as not found.
+*
+* Called by synaptics_rmi4_query_device().
+*/
+static int synaptics_rmi4_check_fn_list(struct synaptics_rmi4_data *rmi4_data,
+				struct synaptics_rmi4_fn *fhandler)
+{
+	int found = 0;
+	struct synaptics_rmi4_fn *new_fhandler;
+	struct synaptics_rmi4_device_info *rmi;
+
+	rmi = &(rmi4_data->rmi4_mod_info);
+
+	if (!list_empty(&rmi->support_fn_list))
+		list_for_each_entry(new_fhandler, &rmi->support_fn_list, link)
+			if (new_fhandler->fn_number == fhandler->fn_number)
+				found = 1;
+
+	return found;
+}
+
  /**
  * synaptics_rmi4_query_device()
  *
@@ -2049,7 +2097,7 @@
  */
 static int synaptics_rmi4_query_device(struct synaptics_rmi4_data *rmi4_data)
 {
-	int retval;
+	int retval, found;
 	unsigned char ii;
 	unsigned char page_number;
 	unsigned char intr_count = 0;
@@ -2063,8 +2111,6 @@
 
 	rmi = &(rmi4_data->rmi4_mod_info);
 
-	INIT_LIST_HEAD(&rmi->support_fn_list);
-
 	/* Scan the page description tables of the pages to service */
 	for (page_number = 0; page_number < PAGES_TO_SERVICE; page_number++) {
 		for (pdt_entry_addr = PDT_START; pdt_entry_addr > PDT_END;
@@ -2079,7 +2125,7 @@
 				return retval;
 
 			fhandler = NULL;
-
+			found = 0;
 			if (rmi_fd.fn_number == 0) {
 				dev_dbg(&rmi4_data->i2c_client->dev,
 						"%s: Reached end of PDT\n",
@@ -2198,8 +2244,28 @@
 			intr_count += (rmi_fd.intr_src_count & MASK_3BIT);
 
 			if (fhandler && rmi_fd.intr_src_count) {
-				list_add_tail(&fhandler->link,
+				/* Want to check whether the fhandler already
+				exists in the support_fn_list or not.
+				If not found then add it to the list, otherwise
+				free the memory allocated to it.
+				*/
+				found = synaptics_rmi4_check_fn_list(rmi4_data,
+						fhandler);
+
+				if (!found) {
+					list_add_tail(&fhandler->link,
 						&rmi->support_fn_list);
+				} else {
+					if (fhandler->fn_number ==
+							SYNAPTICS_RMI4_F1A)
+						synaptics_rmi4_f1a_kfree(
+							fhandler);
+					else {
+						kfree(fhandler->data);
+						kfree(fhandler->extra);
+					}
+					kfree(fhandler);
+				}
 			}
 		}
 	}
@@ -2654,8 +2720,6 @@
 				goto err_reset_gpio_dir;
 			}
 
-			gpio_set_value(rmi4_data->board->reset_gpio, 0);
-			usleep(RMI4_GPIO_SLEEP_LOW_US);
 			gpio_set_value(rmi4_data->board->reset_gpio, 1);
 			msleep(rmi4_data->board->reset_delay);
 		} else
@@ -2666,8 +2730,22 @@
 		if (rmi4_data->board->disable_gpios) {
 			if (gpio_is_valid(rmi4_data->board->irq_gpio))
 				gpio_free(rmi4_data->board->irq_gpio);
-			if (gpio_is_valid(rmi4_data->board->reset_gpio))
+			if (gpio_is_valid(rmi4_data->board->reset_gpio)) {
+				/*
+				 * This is intended to save leakage current
+				 * only. Even if the call(gpio_direction_input)
+				 * fails, only leakage current will be more but
+				 * functionality will not be affected.
+				 */
+				retval = gpio_direction_input(rmi4_data->
+							board->reset_gpio);
+				if (retval) {
+					dev_err(&rmi4_data->i2c_client->dev,
+					"unable to set direction for gpio "
+					"[%d]\n", rmi4_data->board->irq_gpio);
+				}
 				gpio_free(rmi4_data->board->reset_gpio);
+			}
 		}
 
 		return 0;
@@ -2822,6 +2900,8 @@
 	init_waitqueue_head(&rmi4_data->wait);
 	mutex_init(&(rmi4_data->rmi4_io_ctrl_mutex));
 
+	INIT_LIST_HEAD(&rmi->support_fn_list);
+
 	retval = synaptics_rmi4_query_device(rmi4_data);
 	if (retval < 0) {
 		dev_err(&client->dev,
@@ -2958,6 +3038,9 @@
 			goto err_sysfs;
 		}
 	}
+
+	synaptics_rmi4_sensor_wake(rmi4_data);
+
 	retval = synaptics_rmi4_irq_enable(rmi4_data, true);
 	if (retval < 0) {
 		dev_err(&client->dev,
@@ -2966,6 +3049,12 @@
 		goto err_sysfs;
 	}
 
+	retval = synaptics_rmi4_check_configuration(rmi4_data);
+	if (retval < 0) {
+		dev_err(&client->dev, "Failed to check configuration\n");
+		return retval;
+	}
+
 	return retval;
 
 err_sysfs:
@@ -3088,12 +3177,12 @@
 static void synaptics_rmi4_sensor_sleep(struct synaptics_rmi4_data *rmi4_data)
 {
 	int retval;
-	unsigned char device_ctrl;
+	struct synaptics_rmi4_f01_device_control_0 device_ctrl;
 
 	retval = synaptics_rmi4_i2c_read(rmi4_data,
 			rmi4_data->f01_ctrl_base_addr,
-			&device_ctrl,
-			sizeof(device_ctrl));
+			device_ctrl.data,
+			sizeof(device_ctrl.data));
 	if (retval < 0) {
 		dev_err(&(rmi4_data->input_dev->dev),
 				"%s: Failed to enter sleep mode\n",
@@ -3102,13 +3191,13 @@
 		return;
 	}
 
-	device_ctrl = (device_ctrl & ~MASK_3BIT);
-	device_ctrl = (device_ctrl | NO_SLEEP_OFF | SENSOR_SLEEP);
+	device_ctrl.sleep_mode = SENSOR_SLEEP;
+	device_ctrl.nosleep = NO_SLEEP_OFF;
 
 	retval = synaptics_rmi4_i2c_write(rmi4_data,
 			rmi4_data->f01_ctrl_base_addr,
-			&device_ctrl,
-			sizeof(device_ctrl));
+			device_ctrl.data,
+			sizeof(device_ctrl.data));
 	if (retval < 0) {
 		dev_err(&(rmi4_data->input_dev->dev),
 				"%s: Failed to enter sleep mode\n",
@@ -3132,12 +3221,12 @@
 static void synaptics_rmi4_sensor_wake(struct synaptics_rmi4_data *rmi4_data)
 {
 	int retval;
-	unsigned char device_ctrl;
+	struct synaptics_rmi4_f01_device_control_0 device_ctrl;
 
 	retval = synaptics_rmi4_i2c_read(rmi4_data,
 			rmi4_data->f01_ctrl_base_addr,
-			&device_ctrl,
-			sizeof(device_ctrl));
+			device_ctrl.data,
+			sizeof(device_ctrl.data));
 	if (retval < 0) {
 		dev_err(&(rmi4_data->input_dev->dev),
 				"%s: Failed to wake from sleep mode\n",
@@ -3146,13 +3235,19 @@
 		return;
 	}
 
-	device_ctrl = (device_ctrl & ~MASK_3BIT);
-	device_ctrl = (device_ctrl | NO_SLEEP_OFF | NORMAL_OPERATION);
+	if (device_ctrl.nosleep == NO_SLEEP_OFF &&
+		device_ctrl.sleep_mode == NORMAL_OPERATION) {
+		rmi4_data->sensor_sleep = false;
+		return;
+	}
+
+	device_ctrl.sleep_mode = NORMAL_OPERATION;
+	device_ctrl.nosleep = NO_SLEEP_OFF;
 
 	retval = synaptics_rmi4_i2c_write(rmi4_data,
 			rmi4_data->f01_ctrl_base_addr,
-			&device_ctrl,
-			sizeof(device_ctrl));
+			device_ctrl.data,
+			sizeof(device_ctrl.data));
 	if (retval < 0) {
 		dev_err(&(rmi4_data->input_dev->dev),
 				"%s: Failed to wake from sleep mode\n",
@@ -3365,6 +3460,51 @@
 	return retval;
 }
 
+static int synaptics_rmi4_check_configuration(struct synaptics_rmi4_data
+						*rmi4_data)
+{
+	int retval;
+	struct synaptics_rmi4_f01_device_control_0 device_control;
+	struct synaptics_rmi4_f01_device_status device_status;
+
+	retval = synaptics_rmi4_i2c_read(rmi4_data,
+			rmi4_data->f01_data_base_addr,
+			device_status.data,
+			sizeof(device_status.data));
+	if (retval < 0) {
+		dev_err(&rmi4_data->i2c_client->dev,
+			"Failed to read device status, rc=%d\n", retval);
+		return retval;
+	}
+
+	if (device_status.unconfigured) {
+		retval = synaptics_rmi4_query_device(rmi4_data);
+		if (retval < 0) {
+			dev_err(&rmi4_data->i2c_client->dev,
+				"Failed to query device, rc=%d\n", retval);
+			return retval;
+		}
+
+		retval = synaptics_rmi4_i2c_read(rmi4_data,
+				rmi4_data->f01_ctrl_base_addr,
+				device_control.data,
+				sizeof(device_control.data));
+		if (retval < 0)
+			return retval;
+
+		device_control.configured = DEVICE_CONFIGURED;
+
+		retval = synaptics_rmi4_i2c_write(rmi4_data,
+				rmi4_data->f01_ctrl_base_addr,
+				device_control.data,
+				sizeof(device_control.data));
+		if (retval < 0)
+			return retval;
+	}
+
+	return 0;
+}
+
  /**
  * synaptics_rmi4_suspend()
  *
@@ -3447,24 +3587,29 @@
 		return 0;
 	}
 
+	retval = synaptics_rmi4_regulator_lpm(rmi4_data, false);
+	if (retval < 0) {
+		dev_err(dev, "Failed to enter active power mode\n");
+		return retval;
+	}
+
 	if (rmi4_data->board->disable_gpios) {
 		retval = synaptics_rmi4_gpio_configure(rmi4_data, true);
 		if (retval < 0) {
-			dev_err(dev, "failed to put gpios in active state\n");
+			dev_err(dev, "Failed to put gpios in active state\n");
 			return retval;
 		}
 	}
 
-	retval = synaptics_rmi4_regulator_lpm(rmi4_data, false);
-	if (retval < 0) {
-		dev_err(dev, "failed to enter active power mode\n");
-		return retval;
-	}
-
 	synaptics_rmi4_sensor_wake(rmi4_data);
 	rmi4_data->touch_stopped = false;
 	synaptics_rmi4_irq_enable(rmi4_data, true);
 
+	retval = synaptics_rmi4_check_configuration(rmi4_data);
+	if (retval < 0) {
+		dev_err(dev, "Failed to check configuration\n");
+		return retval;
+	}
 	rmi4_data->suspended = false;
 
 	return 0;
@@ -3479,6 +3624,22 @@
 static const struct dev_pm_ops synaptics_rmi4_dev_pm_ops = {
 };
 #endif
+#else
+static void synaptics_rmi4_sensor_wake(struct synaptics_rmi4_data *rmi4_data)
+{
+	return;
+};
+
+static void synaptics_rmi4_sensor_sleep(struct synaptics_rmi4_data *rmi4_data)
+{
+	return;
+};
+
+static int synaptics_rmi4_check_configuration(struct synaptics_rmi4_data
+						*rmi4_data)
+{
+	return 0;
+};
 #endif
 
 static const struct i2c_device_id synaptics_rmi4_id_table[] = {
diff --git a/drivers/iommu/msm_iommu-v1.c b/drivers/iommu/msm_iommu-v1.c
index c81aa0ac..84f81bf 100644
--- a/drivers/iommu/msm_iommu-v1.c
+++ b/drivers/iommu/msm_iommu-v1.c
@@ -956,7 +956,8 @@
 			__print_ctx_regs(drvdata->base, ctx_drvdata->num, fsr);
 		}
 
-		SET_FSR(drvdata->base, ctx_drvdata->num, fsr);
+		if (ret != -EBUSY)
+			SET_FSR(drvdata->base, ctx_drvdata->num, fsr);
 		ret = IRQ_HANDLED;
 	} else
 		ret = IRQ_NONE;
diff --git a/drivers/leds/leds-qpnp.c b/drivers/leds/leds-qpnp.c
index cf6c6e2..8ae5671 100644
--- a/drivers/leds/leds-qpnp.c
+++ b/drivers/leds/leds-qpnp.c
@@ -3355,7 +3355,6 @@
 		if (led->default_on) {
 			led->cdev.brightness = led->cdev.max_brightness;
 			__qpnp_led_work(led, led->cdev.brightness);
-			schedule_work(&led->work);
 			if (led->turn_off_delay_ms > 0)
 				qpnp_led_turn_off(led);
 		} else
diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c
index 9d606a1..65387ba 100644
--- a/drivers/media/dvb/dvb-core/dvb_demux.c
+++ b/drivers/media/dvb/dvb-core/dvb_demux.c
@@ -3118,7 +3118,7 @@
 	struct dvb_demux *dvbdemux = (struct dvb_demux *)demux;
 
 	mutex_lock(&dvbdemux->mutex);
-
+	dvbdemux->sw_filter_abort = 0;
 	demux->frontend = NULL;
 	mutex_unlock(&dvbdemux->mutex);
 	return 0;
@@ -3203,6 +3203,7 @@
 		return -ENOMEM;
 	}
 
+	dvbdemux->sw_filter_abort = 0;
 	dvbdemux->total_process_time = 0;
 	dvbdemux->total_crc_time = 0;
 	snprintf(dvbdemux->alias,
diff --git a/drivers/media/platform/msm/Kconfig b/drivers/media/platform/msm/Kconfig
index e344719..adef2b9 100644
--- a/drivers/media/platform/msm/Kconfig
+++ b/drivers/media/platform/msm/Kconfig
@@ -19,10 +19,6 @@
 	help
 	  Enable printk() debug for msm camera
 
-if MSM_CAMERA
-source "drivers/media/platform/msm/camera_v1/Kconfig"
-endif # MSM_CAMERA
-
 menuconfig MSMB_CAMERA
 	bool "Qualcomm MSM camera and video capture 2.0 support"
 	depends on ARCH_MSM && VIDEO_V4L2 && I2C
diff --git a/drivers/media/platform/msm/Makefile b/drivers/media/platform/msm/Makefile
index c1d86df..8ea6a4a 100644
--- a/drivers/media/platform/msm/Makefile
+++ b/drivers/media/platform/msm/Makefile
@@ -1,6 +1,6 @@
 obj-$(CONFIG_MSM_VIDC_V4L2) += vidc/
 obj-$(CONFIG_MSM_WFD) += wfd/
 obj-$(CONFIG_DVB_MPQ) += dvb/
-obj-$(CONFIG_MSM_CAMERA) += camera_v1/
+
 obj-$(CONFIG_MSMB_CAMERA) += camera_v2/
 obj-y += vcap/
diff --git a/drivers/media/platform/msm/camera_v1/Kconfig b/drivers/media/platform/msm/camera_v1/Kconfig
deleted file mode 100644
index ac449cc..0000000
--- a/drivers/media/platform/msm/camera_v1/Kconfig
+++ /dev/null
@@ -1,409 +0,0 @@
-config MSM_CAMERA_V4L2
-        bool "MSM Camera V4L2 Interface"
-        depends on MSM_CAMERA
-        default n
-        ---help---
-          This flag enables V4L2 interface of MSM
-          camera driver. If enabled, application interacts
-          with /dev/video0 through V4L2 APIs. Otherwise,
-          native APIs are used through /dev/config0, /dev/frame0,
-          and /dev/control0.
-
-comment "Camera Sensor Selection"
-config MT9T013
-	bool "Sensor mt9t013 (BAYER 3M)"
-	depends on MSM_CAMERA && !ARCH_MSM8X60 && !ARCH_MSM8960 && !MSM_CAMERA_V4L2
-	default y
-	---help---
-	  MICRON 3M Bayer Sensor with AutoFocus
-config MT9D113
-	bool "Sensor mt9d113 (YUV 2M)"
-	depends on MSM_CAMERA && ARCH_MSM8X60 && !MSM_CAMERA_V4L2
-	default y
-	---help---
-	  MICRON 2M YUV Sensor
-	  This sensor is the front camera on QT8660.
-	  This uses csi mipi interface.
-	  This sensor is used only on QT device.
-config MT9D112
-	bool "Sensor mt9d112 (YUV 2M)"
-	depends on MSM_CAMERA && !ARCH_MSM8X60 && !ARCH_MSM8960 && !MSM_CAMERA_V4L2
-	default y
-	---help---
-	  MICRON 2M YUV Sensor
-config IMX074
-	bool "Sensor IMX074 (BAYER 13.5M)"
-	depends on MSM_CAMERA
-	---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 OV5647
-	bool "Sensor ov5647 (BAYER 5M)"
-	depends on MSM_CAMERA
-	---help---
-	  OV 5M Bayer Sensor with AutoFocus
-
-config AD5046_ACT
-	bool "Lens actuator ad5046"
-	depends on MSM_CAMERA && OV5647
-	---help---
-	  ad5046 lens actuator driver for ov5647.
-	  Say Y here if this is msm7627A variant platform.
-config WEBCAM_OV7692_QRD
-	bool "Sensor OV7692 QRD(VGA YUV)"
-	depends on MSM_CAMERA && (ARCH_MSM7X27A || ARCH_MSM8X60)
-	default n
-	---help---
-	  Omni Vision VGA YUV Sensor for QRD Devices
-config MT9M114
-        bool "Sensor MT9M114 (YUV 1.26M)"
-        depends on MSM_CAMERA
-        ---help---
-        APTINA 1.26 MP yuv Sensor
-config WEBCAM_OV7692
-	bool "Sensor OV7692 (VGA YUV)"
-	depends on MSM_CAMERA && ARCH_MSM8X60 && !MSM_CAMERA_V4L2
-	default y
-	---help---
-	  Omni Vision VGA YUV Sensor.
-config WEBCAM_OV9726
-	bool "Sensor OV9726 (VGA Bayer)"
-	depends on MSM_CAMERA && (ARCH_MSM8X60 || ARCH_MSM7X30 || ARCH_MSM7X27A)
-	default n
-	---help---
-	  Omni Vision VGA Bayer Sensor.
-#	This Senosr is used as a webcam.
-#	This uses the CSI interface.
-config VX6953
-	bool "Sensor VX6953 (BAYER 5M)"
-	depends on MSM_CAMERA && (ARCH_MSM7X30 || ARCH_MSM8X60) && !MSM_CAMERA_V4L2
-	default y
-	---help---
-	STM 5M Bayer Sensor with EDOF
-config SN12M0PZ
-	bool "Sensor sn12m0pz (Bayer 12 MP)"
-	depends on MSM_CAMERA && ARCH_MSM7X30 && !MSM_CAMERA_V4L2
-	default y
-	---help---
-	  Sony 12 MP Bayer Sensor
-config MT9P012
-	bool "Sensor mt9p012 (BAYER 5M)"
-	depends on MSM_CAMERA && !ARCH_MSM8X60 && !MSM_CAMERA_V4L2
-	default y
-	---help---
-	  MICRON 5M Bayer Sensor with Autofocus
-
-choice
-	prompt "AF module"
-	depends on MT9P012 && !ARCH_MSM8X60 && !MSM_CAMERA_V4L2
-	default MSM_CAMERA_AF_FOXCONN
-
-config MSM_CAMERA_AF_FOXCONN
-	bool "FOXCONN Module"
-	help
-	  This driver supports FOXCONN AF module for 5M Bayer sensor
-
-config MSM_CAMERA_AF_BAM
-	bool "BAM Module"
-	help
-	  This driver supports BAM AF module for 5M Bayer sensor
-
-endchoice
-
-config MT9P012_KM
-	bool "Sensor mt9p012 KM module (BAYER 5M)"
-	depends on MSM_CAMERA && !ARCH_MSM8X60 && !MSM_CAMERA_V4L2
-	default y
-	---help---
-	  MICRON 5M Bayer Sensor KM modules with Autofocus
-
-config MT9E013
-	bool "Sensor mt9e013 module (BAYER 8M)"
-	depends on MSM_CAMERA && (ARCH_MSM7X30 || ARCH_MSM8X60 || ARCH_MSM7X27A)
-	default n
-	---help---
-	  Aptina 8M Bayer Sensor modules with Autofocus
-
-config IMX074_ACT
-	bool "Actuator IMX074 (BAYER 13.5M)"
-	depends on MSM_CAMERA
-	---help---
-	Actuator for SONY 13.5 MP Bayer Sensor
-
-config S5K3E2FX
-	bool "Sensor s5k3e2fx (Samsung 5M)"
-	depends on MSM_CAMERA && !ARCH_MSM8X60 && !MSM_CAMERA_V4L2
-	default y
-	---help---
-	  Samsung 5M with Autofocus
-
-config QS_S5K4E1
-	bool "Sensor qs_s5k4e1 (Samsung 5M)"
-	depends on MSM_CAMERA && ARCH_MSM8X60 && !MSM_CAMERA_V4L2
-	default y
-	---help---
-	  Samsung 5M with Autofocus
-
-config S5K4E1
-	bool "Sensor Sensor s5k4e1 (Samsung 5M)"
-	depends on MSM_CAMERA
-	default n
-	---help---
-	  Support for S5k4E1 samsung sensor driver.
-	  It is a Bayer 5MP sensor with auto focus and it supports
-	  two mipi lanes, required for msm7x2xA platform.
-	  Say Y here if this is msm7x2xA variant platform.
-
-config DW9712_ACT
-	bool "Lens actuator dw9721"
-	depends on MSM_CAMERA && S5K4E1
-	---help---
-	  dw9721 lens actuator driver for S5K4E1.
-	  Say Y here if this is msm7627A variant platform.
-
-config MSM_CAMERA_FLASH_SC628A
-	bool "Qualcomm MSM camera sc628a flash support"
-	depends on MSM_CAMERA
-	default n
-	---help---
-	  Enable support for LED flash for msm camera.
-	  It is a samtech charge pump flash driver and it
-	  supports spotlight and flash light modes with
-	  differrent current levels.
-
-config MSM_CAMERA_FLASH_TPS61310
-	bool "Qualcomm MSM camera tps61310 flash support"
-	depends on MSM_CAMERA
-	default n
-	---help---
-	  Enable support for LED flash for msm camera.
-	  It is a Texas Instruments multiple LED Flash
-	  for camera flash and video light applications.
-
-config MSM_CAMERA_LED_TRIGGER_FLASH
-	bool "Qualcomm MSM LED trigger flash support"
-	depends on MSM_CAMERA
-	default n
-	---help---
-	  Enable support for LED flash for msm camera.
-	  It creates LED trigger client, reads LED flash
-	  hardware properties provided in board file /
-	  device tree and uses these information to configure
-	  LED flash using LED trigger event function.
-
-config IMX072
-	bool "Sensor imx072 (Sony 5M)"
-	default n
-	---help---
-	  Support for IMX072 sony sensor driver.
-	  It is a Bayer 5MP sensor with auto focus and it supports
-	  two mipi lanes, required for msm7x2xA platform.
-	  Say Y here if this is msm7x2xA variant platform.
-
-config OV2720
-	bool "Sensor ov2720 (Omnivision 2MP)"
-	depends on MSM_CAMERA
-
-config OV8825
-	bool "Sensor ov8825 (Omnivision 8M)"
-	depends on MSM_CAMERA
-	---help---
-	  Support for OV8825 sensor driver.
-	  It is a Bayer 8MP sensor with auto focus and it supports
-	  two mipi lanes, required for msm8625 platform.
-	  Say Y here if this is msm8625 variant platform.
-
-config IMX135
-	bool "Sensor imx135 (Sony 13MP)"
-	depends on MSM_CAMERA
-	---help---
-	  Support for IMX135 sensor driver.
-	  This is a Sony 13MP Bayer Sensor with autofocus and video HDR
-	  support.
-	  Say Y if the platform uses IMX135 sensor.
-
-config VB6801
-	bool "Sensor vb6801"
-	depends on MSM_CAMERA && !ARCH_MSM8X60 && !MSM_CAMERA_V4L2
-	---help---
-	  5M with flash
-
-config MSM_CAMERA_FLASH
-	bool "Qualcomm MSM camera flash support"
-	depends on MSM_CAMERA
-	default y
-	---help---
-	  Enable support for LED flash for msm camera
-
-config MSM_CAMERA_SENSOR
-	bool "Qualcomm MSM camera sensor support"
-	depends on MSM_CAMERA
-
-config MSM_ACTUATOR
-	bool "Qualcomm MSM actuator support"
-	depends on MSM_CAMERA
-
-config MSM_EEPROM
-	bool "Qualcomm MSM EEPROM support"
-	depends on MSM_CAMERA
-
-config IMX074_EEPROM
-	bool "IMX074 EEPROM support"
-	depends on MSM_CAMERA
-
-config IMX091_EEPROM
-	bool "IMX091 EEPROM support"
-	depends on MSM_CAMERA
-
-config MSM_GEMINI
-	tristate "Qualcomm MSM Gemini Jpeg Engine support"
-	depends on MSM_CAMERA && (ARCH_MSM7X30 || ARCH_MSM8X60 || ARCH_MSM8960)
-	default n
-	---help---
-	  Enable support for Gemini Jpeg Engine
-
-config MSM_MERCURY
-        tristate "Qualcomm MSM Mercury Jpeg Decoder Engine support"
-        depends on MSM_CAMERA && ARCH_MSM8960
-        ---help---
-          Enable support for Mercury Jpeg Engine
-
-config MSM_VPE
-	tristate "Qualcomm MSM Video Pre-processing Engine support"
-	depends on MSM_CAMERA && (ARCH_MSM7X30 || ARCH_MSM8X60)
-	default y
-	---help---
-	  Enable support for Video Pre-processing Engine
-
-config MSM_CAM_IRQ_ROUTER
-	bool "Enable MSM CAM IRQ Router"
-	depends on MSM_CAMERA
-	---help---
-	Enable IRQ Router for Camera. Depending on the
-	configuration, this module can handle the
-	interrupts from multiple camera hardware
-	cores and composite them into a single
-	interrupt to the MSM.
-
-config MSM_CPP
-        bool "Qualcomm MSM Camera Post Processing Engine support"
-        depends on MSM_CAMERA && MSM_CAMERA_V4L2
-        ---help---
-          Enable support for Camera Post-processing Engine
-          The Post processing engine is capable of scaling
-          and cropping image. The driver support V4L2 subdev
-          APIs.
-
-config MSM_CCI
-        bool "Qualcomm MSM Camera Control Interface support"
-        depends on MSM_CAMERA
-        ---help---
-          Enable support for Camera Control Interface driver only
-          for those platforms that have hardware support. This driver
-          is responsible for handling I2C read and write on the I2C
-          bus. It is also responsible for synchronization with
-          GPIO and data frames.
-
-config QUP_EXCLUSIVE_TO_CAMERA
-	bool "QUP exclusive to camera"
-	depends on MSM_CAMERA
-	default y
-	---help---
-	  This flag enabled states that QUP
-	  is exclusive to camera. In case this
-	  is disabled, the lvs1 voltage is enabled
-	  by QUP in the board file as QUP is used by
-	  applications other than camera.
-
-config MSM_CSI20_HEADER
-        bool "Qualcomm MSM CSI 2.0 Header"
-        depends on MSM_CAMERA
-        ---help---
-          Enable support for CSI drivers to include 2.0
-          header. This header has register macros and its
-          values and bit mask for register configuration bits
-          This config macro is required targets based on 8960,
-          8930 and 8064 platforms.
-
-config MSM_CSI30_HEADER
-        bool "Qualcomm MSM CSI 3.0 Header"
-        depends on MSM_CAMERA
-        ---help---
-          Enable support for CSI drivers to include 3.0
-          header. This header has register macros and its
-          values and bit mask for register configuration bits
-          This config macro is required for targets based on
-          8064 platforms.
-
-config MSM_CSIPHY
-        bool "Qualcomm MSM Camera Serial Interface Physical receiver support"
-        depends on MSM_CAMERA
-        ---help---
-          Enable support for Camera Serial Interface
-          Physical receiver. It deserializes packets and
-          supports detection of packet start and stop
-          signalling.
-
-config MSM_CSID
-        bool "Qualcomm MSM Camera Serial Interface decoder support"
-        depends on MSM_CAMERA
-        ---help---
-          Enable support for Camera Serial Interface decoder.
-          It supports lane merging and decoding of packets
-          based on cid which is mapped to a virtual channel
-          and datatype.
-
-config MSM_CSI2_REGISTER
-        bool "Qualcomm MSM CSI2 Register"
-        depends on MSM_CAMERA
-        ---help---
-          Register CSIPHY, CSID and ISPIF subdevices during
-          msm_open. Different CSI components are registered
-          based on platform. This macro specifies registering
-          of CSIPHY, CSID and ISPIF subdevices to receive data
-          from sensor.
-
-config MSM_ISPIF
-        bool "Qualcomm MSM Image Signal Processing interface support"
-        depends on MSM_CAMERA
-        ---help---
-          Enable support for Image Signal Processing interface module.
-          This module acts as a crossbar between CSID and VFE. Output
-          of any CID of CSID can be routed to of of pixel or raw
-          data interface in VFE.
-
-config S5K3L1YX
-	bool "Sensor S5K3L1YX (BAYER 12M)"
-	depends on MSM_CAMERA
-	---help---
-		Samsung 12 MP Bayer Sensor with auto focus, uses
-		4 mipi lanes, preview config = 1984 * 1508 at 30 fps,
-		snapshot config = 4000 * 3000 at 20 fps,
-		hfr video at 60, 90 and 120 fps.
-
-config IMX091
-        bool "Sensor imx091 (Sony 13MP)"
-        depends on MSM_CAMERA
-	---help---
-	  Sony 13MP sensor back camera that uses 4 mipi lanes,
-	  runs at 30 fps preview and 14 fps snapshot
-
-config MSM_V4L2_VIDEO_OVERLAY_DEVICE
-	tristate "Qualcomm MSM V4l2 video overlay device"
-	---help---
-	  Enables support for the MSM V4L2 video
-	  overlay driver. This allows video rendering
-	  apps to render overlaid video using Video4Linux2
-	  APIs, by using /dev/videoX device
-
-config OV7692
-	bool "Sensor OV7692 (VGA YUV)"
-	depends on MSM_CAMERA
-	---help---
-	  Omni Vision VGA YUV Sensor
diff --git a/drivers/media/platform/msm/camera_v1/Makefile b/drivers/media/platform/msm/camera_v1/Makefile
deleted file mode 100644
index eb66b29..0000000
--- a/drivers/media/platform/msm/camera_v1/Makefile
+++ /dev/null
@@ -1,59 +0,0 @@
-GCC_VERSION      := $(shell $(CONFIG_SHELL) $(PWD)/scripts/gcc-version.sh $(CROSS_COMPILE)gcc)
-
-ccflags-y += -Idrivers/media/platform/msm/camera_v1/io
-ccflags-y += -Idrivers/media/platform/msm/camera_v1/vfe
-obj-$(CONFIG_MSM_CAMERA) += io/
-ifeq ($(CONFIG_MSM_CAMERA_V4L2),y)
-  EXTRA_CFLAGS += -Idrivers/media/platform/msm/camera_v1/cci
-  EXTRA_CFLAGS += -Idrivers/media/platform/msm/camera_v1/csi
-  EXTRA_CFLAGS += -Idrivers/media/platform/msm/camera_v1/eeprom
-  EXTRA_CFLAGS += -Idrivers/media/platform/msm/camera_v1/sensors
-  EXTRA_CFLAGS += -Idrivers/media/platform/msm/camera_v1/actuators
-  EXTRA_CFLAGS += -Idrivers/media/platform/msm/camera_v1/server
-  EXTRA_CFLAGS += -Idrivers/media/platform/msm/camera_v1/flash
-  obj-$(CONFIG_MSM_CAMERA) += msm_isp.o msm.o msm_mem.o msm_mctl.o msm_mctl_buf.o msm_mctl_pp.o
-  obj-$(CONFIG_MSM_CAMERA) += server/
-  obj-$(CONFIG_MSM_CAM_IRQ_ROUTER) += msm_camirq_router.o
-  obj-$(CONFIG_MSM_CAMERA) += cci/ eeprom/ sensors/ actuators/ csi/
-  obj-$(CONFIG_MSM_CPP) += cpp/
-  obj-$(CONFIG_MSM_CAMERA) += msm_gesture.o
-  obj-$(CONFIG_MSM_CAMERA) += flash/
-else
-  obj-$(CONFIG_MSM_CAMERA) += msm_camera.o
-endif
-obj-$(CONFIG_MSM_CAMERA) += vfe/
-obj-$(CONFIG_MSM_CAMERA) += msm_axi_qos.o gemini/ mercury/
-ifeq ($(CONFIG_MSM_CAMERA_V4L2),y)
-  obj-$(CONFIG_ARCH_MSM8X60) += msm_vpe.o
-  obj-$(CONFIG_ARCH_MSM7X30) += msm_vpe.o msm_axi_qos.o
-else
-  obj-$(CONFIG_ARCH_MSM8X60) += msm_vpe1.o
-  obj-$(CONFIG_ARCH_MSM7X30) += msm_vpe1.o
-endif
-obj-$(CONFIG_ARCH_MSM8960) += msm_vpe.o
-obj-$(CONFIG_MT9T013) += mt9t013.o mt9t013_reg.o
-obj-$(CONFIG_SN12M0PZ) += sn12m0pz.o sn12m0pz_reg.o
-obj-$(CONFIG_MT9P012) += mt9p012_reg.o
-obj-$(CONFIG_MSM_CAMERA_AF_FOXCONN) += mt9p012_fox.o
-obj-$(CONFIG_MSM_CAMERA_AF_BAM) += mt9p012_bam.o
-obj-$(CONFIG_MT9P012_KM) += mt9p012_km.o mt9p012_km_reg.o
-obj-$(CONFIG_S5K3E2FX) += s5k3e2fx.o
-#FIXME: Merge the two ifeq causes VX6953 preview not coming up.
-ifneq ($(CONFIG_MSM_CAMERA_V4L2),y)
-  obj-$(CONFIG_VX6953) += vx6953.o vx6953_reg.o
-  obj-$(CONFIG_IMX074) += imx074.o imx074_reg.o
-  obj-$(CONFIG_MT9E013) += mt9e013.o mt9e013_reg.o
-  obj-$(CONFIG_WEBCAM_OV9726) += ov9726.o ov9726_reg.o
-  obj-$(CONFIG_OV5647) += ov5647.o ov5647_reg.o
-  obj-$(CONFIG_S5K4E1) += s5k4e1.o s5k4e1_reg.o
-  obj-$(CONFIG_WEBCAM_OV7692) += ov7692.o
-  obj-$(CONFIG_WEBCAM_OV7692_QRD) += ov7692_qrd.o
-endif
-obj-$(CONFIG_QS_S5K4E1) += qs_s5k4e1.o qs_s5k4e1_reg.o
-obj-$(CONFIG_VB6801) += vb6801.o
-obj-$(CONFIG_IMX072) += imx072.o imx072_reg.o
-obj-$(CONFIG_OV5640) += ov5640.o
-obj-$(CONFIG_MT9D112) += mt9d112.o mt9d112_reg.o
-
-obj-$(CONFIG_MT9D113) += mt9d113.o mt9d113_reg.o
-obj-$(CONFIG_MSM_V4L2_VIDEO_OVERLAY_DEVICE) += msm_v4l2_video.o
diff --git a/drivers/media/platform/msm/camera_v1/actuators/Makefile b/drivers/media/platform/msm/camera_v1/actuators/Makefile
deleted file mode 100644
index 95713a1..0000000
--- a/drivers/media/platform/msm/camera_v1/actuators/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-GCC_VERSION      := $(shell $(CONFIG_SHELL) $(PWD)/scripts/gcc-version.sh $(CROSS_COMPILE)gcc)
-EXTRA_CFLAGS += -Idrivers/media/platform/msm/camera_v1
-EXTRA_CFLAGS += -Idrivers/media/platform/msm/camera_v1/io
-obj-$(CONFIG_MSM_ACTUATOR) += msm_actuator.o
diff --git a/drivers/media/platform/msm/camera_v1/actuators/msm_actuator.c b/drivers/media/platform/msm/camera_v1/actuators/msm_actuator.c
deleted file mode 100644
index 29a4866..0000000
--- a/drivers/media/platform/msm/camera_v1/actuators/msm_actuator.c
+++ /dev/null
@@ -1,692 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-
-#include <linux/module.h>
-#include "msm_actuator.h"
-
-static struct msm_actuator_ctrl_t msm_actuator_t;
-static struct msm_actuator msm_vcm_actuator_table;
-static struct msm_actuator msm_piezo_actuator_table;
-
-static struct msm_actuator *actuators[] = {
-	&msm_vcm_actuator_table,
-	&msm_piezo_actuator_table,
-};
-
-static int32_t msm_actuator_piezo_set_default_focus(
-	struct msm_actuator_ctrl_t *a_ctrl,
-	struct msm_actuator_move_params_t *move_params)
-{
-	int32_t rc = 0;
-
-	if (a_ctrl->curr_step_pos != 0) {
-		a_ctrl->i2c_tbl_index = 0;
-		rc = a_ctrl->func_tbl->actuator_parse_i2c_params(a_ctrl,
-			a_ctrl->initial_code, 0, 0);
-		rc = a_ctrl->func_tbl->actuator_parse_i2c_params(a_ctrl,
-			a_ctrl->initial_code, 0, 0);
-		rc = msm_camera_i2c_write_table_w_microdelay(
-			&a_ctrl->i2c_client, a_ctrl->i2c_reg_tbl,
-			a_ctrl->i2c_tbl_index, a_ctrl->i2c_data_type);
-		if (rc < 0) {
-			pr_err("%s: i2c write error:%d\n",
-				__func__, rc);
-			return rc;
-		}
-		a_ctrl->i2c_tbl_index = 0;
-		a_ctrl->curr_step_pos = 0;
-	}
-	return rc;
-}
-
-static int32_t msm_actuator_parse_i2c_params(struct msm_actuator_ctrl_t *a_ctrl,
-	int16_t next_lens_position, uint32_t hw_params, uint16_t delay)
-{
-	struct msm_actuator_reg_params_t *write_arr = a_ctrl->reg_tbl;
-	uint32_t hw_dword = hw_params;
-	uint16_t i2c_byte1 = 0, i2c_byte2 = 0;
-	uint16_t value = 0;
-	uint32_t size = a_ctrl->reg_tbl_size, i = 0;
-	int32_t rc = 0;
-	struct msm_camera_i2c_reg_tbl *i2c_tbl = a_ctrl->i2c_reg_tbl;
-	CDBG("%s: IN\n", __func__);
-	for (i = 0; i < size; i++) {
-		if (write_arr[i].reg_write_type == MSM_ACTUATOR_WRITE_DAC) {
-			value = (next_lens_position <<
-				write_arr[i].data_shift) |
-				((hw_dword & write_arr[i].hw_mask) >>
-				write_arr[i].hw_shift);
-
-			if (write_arr[i].reg_addr != 0xFFFF) {
-				i2c_byte1 = write_arr[i].reg_addr;
-				i2c_byte2 = value;
-				if (size != (i+1)) {
-					i2c_byte2 = value & 0xFF;
-					CDBG("%s: byte1:0x%x, byte2:0x%x\n",
-					__func__, i2c_byte1, i2c_byte2);
-					i2c_tbl[a_ctrl->i2c_tbl_index].
-						reg_addr = i2c_byte1;
-					i2c_tbl[a_ctrl->i2c_tbl_index].
-						reg_data = i2c_byte2;
-					i2c_tbl[a_ctrl->i2c_tbl_index].
-						delay = 0;
-					a_ctrl->i2c_tbl_index++;
-					i++;
-					i2c_byte1 = write_arr[i].reg_addr;
-					i2c_byte2 = (value & 0xFF00) >> 8;
-				}
-			} else {
-				i2c_byte1 = (value & 0xFF00) >> 8;
-				i2c_byte2 = value & 0xFF;
-			}
-		} else {
-			i2c_byte1 = write_arr[i].reg_addr;
-			i2c_byte2 = (hw_dword & write_arr[i].hw_mask) >>
-				write_arr[i].hw_shift;
-		}
-		CDBG("%s: i2c_byte1:0x%x, i2c_byte2:0x%x\n", __func__,
-			i2c_byte1, i2c_byte2);
-		i2c_tbl[a_ctrl->i2c_tbl_index].reg_addr = i2c_byte1;
-		i2c_tbl[a_ctrl->i2c_tbl_index].reg_data = i2c_byte2;
-		i2c_tbl[a_ctrl->i2c_tbl_index].delay = delay;
-		a_ctrl->i2c_tbl_index++;
-	}
-		CDBG("%s: OUT\n", __func__);
-	return rc;
-}
-
-static int32_t msm_actuator_init_focus(struct msm_actuator_ctrl_t *a_ctrl,
-	uint16_t size, enum msm_actuator_data_type type,
-	struct reg_settings_t *settings)
-{
-	int32_t rc = -EFAULT;
-	int32_t i = 0;
-	CDBG("%s called\n", __func__);
-
-	for (i = 0; i < size; i++) {
-		switch (type) {
-		case MSM_ACTUATOR_BYTE_DATA:
-			rc = msm_camera_i2c_write(
-				&a_ctrl->i2c_client,
-				settings[i].reg_addr,
-				settings[i].reg_data, MSM_CAMERA_I2C_BYTE_DATA);
-			break;
-		case MSM_ACTUATOR_WORD_DATA:
-			rc = msm_camera_i2c_write(
-				&a_ctrl->i2c_client,
-				settings[i].reg_addr,
-				settings[i].reg_data, MSM_CAMERA_I2C_WORD_DATA);
-			break;
-		default:
-			pr_err("%s: Unsupport data type: %d\n",
-				__func__, type);
-			break;
-		}
-		if (rc < 0)
-			break;
-	}
-
-	a_ctrl->curr_step_pos = 0;
-	CDBG("%s Exit:%d\n", __func__, rc);
-	return rc;
-}
-
-static int32_t msm_actuator_write_focus(
-	struct msm_actuator_ctrl_t *a_ctrl,
-	uint16_t curr_lens_pos,
-	struct damping_params_t *damping_params,
-	int8_t sign_direction,
-	int16_t code_boundary)
-{
-	int32_t rc = 0;
-	int16_t next_lens_pos = 0;
-	uint16_t damping_code_step = 0;
-	uint16_t wait_time = 0;
-
-	damping_code_step = damping_params->damping_step;
-	wait_time = damping_params->damping_delay;
-
-	/* Write code based on damping_code_step in a loop */
-	for (next_lens_pos =
-		curr_lens_pos + (sign_direction * damping_code_step);
-		(sign_direction * next_lens_pos) <=
-			(sign_direction * code_boundary);
-		next_lens_pos =
-			(next_lens_pos +
-				(sign_direction * damping_code_step))) {
-		rc = a_ctrl->func_tbl->
-			actuator_parse_i2c_params(a_ctrl, next_lens_pos,
-				damping_params->hw_params, wait_time);
-		if (rc < 0) {
-			pr_err("%s: error:%d\n",
-				__func__, rc);
-			return rc;
-		}
-		curr_lens_pos = next_lens_pos;
-	}
-
-	if (curr_lens_pos != code_boundary) {
-		rc = a_ctrl->func_tbl->
-			actuator_parse_i2c_params(a_ctrl, code_boundary,
-				damping_params->hw_params, wait_time);
-	}
-	return rc;
-}
-
-static int32_t msm_actuator_piezo_move_focus(
-	struct msm_actuator_ctrl_t *a_ctrl,
-	struct msm_actuator_move_params_t *move_params)
-{
-	int32_t dest_step_position = move_params->dest_step_pos;
-	int32_t rc = 0;
-	int32_t num_steps = move_params->num_steps;
-
-	if (num_steps == 0)
-		return rc;
-
-	a_ctrl->i2c_tbl_index = 0;
-	rc = a_ctrl->func_tbl->
-		actuator_parse_i2c_params(a_ctrl,
-		(num_steps *
-		a_ctrl->region_params[0].code_per_step),
-		move_params->ringing_params[0].hw_params, 0);
-
-	rc = msm_camera_i2c_write_table_w_microdelay(&a_ctrl->i2c_client,
-		a_ctrl->i2c_reg_tbl, a_ctrl->i2c_tbl_index,
-		a_ctrl->i2c_data_type);
-	if (rc < 0) {
-		pr_err("%s: i2c write error:%d\n",
-			__func__, rc);
-		return rc;
-	}
-	a_ctrl->i2c_tbl_index = 0;
-	a_ctrl->curr_step_pos = dest_step_position;
-	return rc;
-}
-
-static int32_t msm_actuator_move_focus(
-	struct msm_actuator_ctrl_t *a_ctrl,
-	struct msm_actuator_move_params_t *move_params)
-{
-	int32_t rc = 0;
-	int8_t sign_dir = move_params->sign_dir;
-	uint16_t step_boundary = 0;
-	uint16_t target_step_pos = 0;
-	uint16_t target_lens_pos = 0;
-	int16_t dest_step_pos = move_params->dest_step_pos;
-	uint16_t curr_lens_pos = 0;
-	int dir = move_params->dir;
-	int32_t num_steps = move_params->num_steps;
-
-	CDBG("%s called, dir %d, num_steps %d\n",
-		__func__,
-		dir,
-		num_steps);
-
-	if (dest_step_pos == a_ctrl->curr_step_pos)
-		return rc;
-
-	curr_lens_pos = a_ctrl->step_position_table[a_ctrl->curr_step_pos];
-	a_ctrl->i2c_tbl_index = 0;
-	CDBG("curr_step_pos =%d dest_step_pos =%d curr_lens_pos=%d\n",
-		a_ctrl->curr_step_pos, dest_step_pos, curr_lens_pos);
-
-	while (a_ctrl->curr_step_pos != dest_step_pos) {
-		step_boundary =
-			a_ctrl->region_params[a_ctrl->curr_region_index].
-			step_bound[dir];
-		if ((dest_step_pos * sign_dir) <=
-			(step_boundary * sign_dir)) {
-
-			target_step_pos = dest_step_pos;
-			target_lens_pos =
-				a_ctrl->step_position_table[target_step_pos];
-			rc = a_ctrl->func_tbl->
-				actuator_write_focus(
-					a_ctrl,
-					curr_lens_pos,
-					&(move_params->
-						ringing_params[a_ctrl->
-						curr_region_index]),
-					sign_dir,
-					target_lens_pos);
-			if (rc < 0) {
-				pr_err("%s: error:%d\n",
-					__func__, rc);
-				return rc;
-			}
-			curr_lens_pos = target_lens_pos;
-
-		} else {
-			target_step_pos = step_boundary;
-			target_lens_pos =
-				a_ctrl->step_position_table[target_step_pos];
-			rc = a_ctrl->func_tbl->
-				actuator_write_focus(
-					a_ctrl,
-					curr_lens_pos,
-					&(move_params->
-						ringing_params[a_ctrl->
-						curr_region_index]),
-					sign_dir,
-					target_lens_pos);
-			if (rc < 0) {
-				pr_err("%s: error:%d\n",
-					__func__, rc);
-				return rc;
-			}
-			curr_lens_pos = target_lens_pos;
-
-			a_ctrl->curr_region_index += sign_dir;
-		}
-		a_ctrl->curr_step_pos = target_step_pos;
-	}
-
-	rc = msm_camera_i2c_write_table_w_microdelay(&a_ctrl->i2c_client,
-		a_ctrl->i2c_reg_tbl, a_ctrl->i2c_tbl_index,
-		a_ctrl->i2c_data_type);
-	if (rc < 0) {
-		pr_err("%s: i2c write error:%d\n",
-			__func__, rc);
-		return rc;
-	}
-	a_ctrl->i2c_tbl_index = 0;
-
-	return rc;
-}
-
-static int32_t msm_actuator_init_step_table(struct msm_actuator_ctrl_t *a_ctrl,
-	struct msm_actuator_set_info_t *set_info)
-{
-	int16_t code_per_step = 0;
-	int32_t rc = 0;
-	int16_t cur_code = 0;
-	int16_t step_index = 0, region_index = 0;
-	uint16_t step_boundary = 0;
-	uint32_t max_code_size = 1;
-	uint16_t data_size = set_info->actuator_params.data_size;
-	CDBG("%s called\n", __func__);
-
-	for (; data_size > 0; data_size--)
-		max_code_size *= 2;
-
-	kfree(a_ctrl->step_position_table);
-	a_ctrl->step_position_table = NULL;
-
-	/* Fill step position table */
-	a_ctrl->step_position_table =
-		kmalloc(sizeof(uint16_t) *
-		(set_info->af_tuning_params.total_steps + 1), GFP_KERNEL);
-
-	if (a_ctrl->step_position_table == NULL)
-		return -EFAULT;
-
-	cur_code = set_info->af_tuning_params.initial_code;
-	a_ctrl->step_position_table[step_index++] = cur_code;
-	for (region_index = 0;
-		region_index < a_ctrl->region_size;
-		region_index++) {
-		code_per_step =
-			a_ctrl->region_params[region_index].code_per_step;
-		step_boundary =
-			a_ctrl->region_params[region_index].
-			step_bound[MOVE_NEAR];
-		for (; step_index <= step_boundary;
-			step_index++) {
-			cur_code += code_per_step;
-			if (cur_code < max_code_size)
-				a_ctrl->step_position_table[step_index] =
-					cur_code;
-			else {
-				for (; step_index <
-					set_info->af_tuning_params.total_steps;
-					step_index++)
-					a_ctrl->
-						step_position_table[
-						step_index] =
-						max_code_size;
-
-				return rc;
-			}
-		}
-	}
-
-	return rc;
-}
-
-static int32_t msm_actuator_set_default_focus(
-	struct msm_actuator_ctrl_t *a_ctrl,
-	struct msm_actuator_move_params_t *move_params)
-{
-	int32_t rc = 0;
-	CDBG("%s called\n", __func__);
-
-	if (a_ctrl->curr_step_pos != 0)
-		rc = a_ctrl->func_tbl->actuator_move_focus(a_ctrl, move_params);
-	return rc;
-}
-
-static int32_t msm_actuator_power_down(struct msm_actuator_ctrl_t *a_ctrl)
-{
-	int32_t rc = 0;
-	if (a_ctrl->vcm_enable) {
-		rc = gpio_direction_output(a_ctrl->vcm_pwd, 0);
-		if (!rc)
-			gpio_free(a_ctrl->vcm_pwd);
-	}
-
-	kfree(a_ctrl->step_position_table);
-	a_ctrl->step_position_table = NULL;
-	kfree(a_ctrl->i2c_reg_tbl);
-	a_ctrl->i2c_reg_tbl = NULL;
-	a_ctrl->i2c_tbl_index = 0;
-	return rc;
-}
-
-static int32_t msm_actuator_init(struct msm_actuator_ctrl_t *a_ctrl,
-	struct msm_actuator_set_info_t *set_info) {
-	struct reg_settings_t *init_settings = NULL;
-	int32_t rc = -EFAULT;
-	uint16_t i = 0;
-	CDBG("%s: IN\n", __func__);
-
-	for (i = 0; i < ARRAY_SIZE(actuators); i++) {
-		if (set_info->actuator_params.act_type ==
-			actuators[i]->act_type) {
-			a_ctrl->func_tbl = &actuators[i]->func_tbl;
-			rc = 0;
-		}
-	}
-
-	if (rc < 0) {
-		pr_err("%s: Actuator function table not found\n", __func__);
-		return rc;
-	}
-
-	a_ctrl->region_size = set_info->af_tuning_params.region_size;
-	if (a_ctrl->region_size > MAX_ACTUATOR_REGION) {
-		pr_err("%s: MAX_ACTUATOR_REGION is exceeded.\n", __func__);
-		return -EFAULT;
-	}
-	a_ctrl->pwd_step = set_info->af_tuning_params.pwd_step;
-	a_ctrl->total_steps = set_info->af_tuning_params.total_steps;
-
-	if (copy_from_user(&a_ctrl->region_params,
-		(void *)set_info->af_tuning_params.region_params,
-		a_ctrl->region_size * sizeof(struct region_params_t)))
-		return -EFAULT;
-
-	a_ctrl->i2c_data_type = set_info->actuator_params.i2c_data_type;
-	a_ctrl->i2c_client.client->addr = set_info->actuator_params.i2c_addr;
-	a_ctrl->i2c_client.addr_type = set_info->actuator_params.i2c_addr_type;
-	a_ctrl->reg_tbl_size = set_info->actuator_params.reg_tbl_size;
-	if (a_ctrl->reg_tbl_size > MAX_ACTUATOR_REG_TBL_SIZE) {
-		pr_err("%s: MAX_ACTUATOR_REG_TBL_SIZE is exceeded.\n",
-			__func__);
-		return -EFAULT;
-	}
-
-	a_ctrl->i2c_reg_tbl =
-		kmalloc(sizeof(struct msm_camera_i2c_reg_tbl) *
-		(set_info->af_tuning_params.total_steps + 1), GFP_KERNEL);
-	if (!a_ctrl->i2c_reg_tbl) {
-		pr_err("%s kmalloc fail\n", __func__);
-		return -EFAULT;
-	}
-
-	if (copy_from_user(&a_ctrl->reg_tbl,
-		(void *)set_info->actuator_params.reg_tbl_params,
-		a_ctrl->reg_tbl_size *
-		sizeof(struct msm_actuator_reg_params_t))) {
-		kfree(a_ctrl->i2c_reg_tbl);
-		return -EFAULT;
-	}
-
-	if (set_info->actuator_params.init_setting_size) {
-		if (a_ctrl->func_tbl->actuator_init_focus) {
-			init_settings = kmalloc(sizeof(struct reg_settings_t) *
-				(set_info->actuator_params.init_setting_size),
-				GFP_KERNEL);
-			if (init_settings == NULL) {
-				kfree(a_ctrl->i2c_reg_tbl);
-				pr_err("%s Error allocating memory for init_settings\n",
-					__func__);
-				return -EFAULT;
-			}
-			if (copy_from_user(init_settings,
-				(void *)set_info->actuator_params.init_settings,
-				set_info->actuator_params.init_setting_size *
-				sizeof(struct reg_settings_t))) {
-				kfree(init_settings);
-				kfree(a_ctrl->i2c_reg_tbl);
-				pr_err("%s Error copying init_settings\n",
-					__func__);
-				return -EFAULT;
-			}
-			rc = a_ctrl->func_tbl->actuator_init_focus(a_ctrl,
-				set_info->actuator_params.init_setting_size,
-				a_ctrl->i2c_data_type,
-				init_settings);
-			kfree(init_settings);
-			if (rc < 0) {
-				kfree(a_ctrl->i2c_reg_tbl);
-				pr_err("%s Error actuator_init_focus\n",
-					__func__);
-				return -EFAULT;
-			}
-		}
-	}
-
-	a_ctrl->initial_code = set_info->af_tuning_params.initial_code;
-	if (a_ctrl->func_tbl->actuator_init_step_table)
-		rc = a_ctrl->func_tbl->
-			actuator_init_step_table(a_ctrl, set_info);
-
-	a_ctrl->curr_step_pos = 0;
-	a_ctrl->curr_region_index = 0;
-
-	return rc;
-}
-
-
-static int32_t msm_actuator_config(struct msm_actuator_ctrl_t *a_ctrl,
-							void __user *argp)
-{
-	struct msm_actuator_cfg_data cdata;
-	int32_t rc = 0;
-	if (copy_from_user(&cdata,
-		(void *)argp,
-		sizeof(struct msm_actuator_cfg_data)))
-		return -EFAULT;
-	mutex_lock(a_ctrl->actuator_mutex);
-	CDBG("%s called, type %d\n", __func__, cdata.cfgtype);
-	switch (cdata.cfgtype) {
-	case CFG_SET_ACTUATOR_INFO:
-		rc = msm_actuator_init(a_ctrl, &cdata.cfg.set_info);
-		if (rc < 0)
-			pr_err("%s init table failed %d\n", __func__, rc);
-		break;
-
-	case CFG_SET_DEFAULT_FOCUS:
-		rc = a_ctrl->func_tbl->actuator_set_default_focus(a_ctrl,
-			&cdata.cfg.move);
-		if (rc < 0)
-			pr_err("%s move focus failed %d\n", __func__, rc);
-		break;
-
-	case CFG_MOVE_FOCUS:
-		rc = a_ctrl->func_tbl->actuator_move_focus(a_ctrl,
-			&cdata.cfg.move);
-		if (rc < 0)
-			pr_err("%s move focus failed %d\n", __func__, rc);
-		break;
-
-	default:
-		break;
-	}
-	mutex_unlock(a_ctrl->actuator_mutex);
-	return rc;
-}
-
-static int32_t msm_actuator_i2c_probe(
-	struct i2c_client *client,
-	const struct i2c_device_id *id)
-{
-	int rc = 0;
-	struct msm_actuator_ctrl_t *act_ctrl_t = NULL;
-	CDBG("%s called\n", __func__);
-
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		pr_err("i2c_check_functionality failed\n");
-		goto probe_failure;
-	}
-
-	act_ctrl_t = (struct msm_actuator_ctrl_t *)(id->driver_data);
-	CDBG("%s client = %x\n",
-		__func__, (unsigned int) client);
-	act_ctrl_t->i2c_client.client = client;
-
-	/* Assign name for sub device */
-	snprintf(act_ctrl_t->sdev.name, sizeof(act_ctrl_t->sdev.name),
-			 "%s", act_ctrl_t->i2c_driver->driver.name);
-
-	/* Initialize sub device */
-	v4l2_i2c_subdev_init(&act_ctrl_t->sdev,
-		act_ctrl_t->i2c_client.client,
-		act_ctrl_t->act_v4l2_subdev_ops);
-
-	CDBG("%s succeeded\n", __func__);
-	return rc;
-
-probe_failure:
-	pr_err("%s failed! rc = %d\n", __func__, rc);
-	return rc;
-}
-
-static int32_t msm_actuator_power_up(struct msm_actuator_ctrl_t *a_ctrl)
-{
-	int rc = 0;
-	CDBG("%s called\n", __func__);
-
-	CDBG("vcm info: %x %x\n", a_ctrl->vcm_pwd,
-		a_ctrl->vcm_enable);
-	if (a_ctrl->vcm_enable) {
-		rc = gpio_request(a_ctrl->vcm_pwd, "msm_actuator");
-		if (!rc) {
-			CDBG("Enable VCM PWD\n");
-			gpio_direction_output(a_ctrl->vcm_pwd, 1);
-		}
-	}
-	return rc;
-}
-
-DEFINE_MUTEX(msm_actuator_mutex);
-
-static const struct i2c_device_id msm_actuator_i2c_id[] = {
-	{"msm_actuator", (kernel_ulong_t)&msm_actuator_t},
-	{ }
-};
-
-static struct i2c_driver msm_actuator_i2c_driver = {
-	.id_table = msm_actuator_i2c_id,
-	.probe  = msm_actuator_i2c_probe,
-	.remove = __exit_p(msm_actuator_i2c_remove),
-	.driver = {
-		.name = "msm_actuator",
-	},
-};
-
-static int __init msm_actuator_i2c_add_driver(
-	void)
-{
-	CDBG("%s called\n", __func__);
-	return i2c_add_driver(msm_actuator_t.i2c_driver);
-}
-
-static long msm_actuator_subdev_ioctl(struct v4l2_subdev *sd,
-			unsigned int cmd, void *arg)
-{
-	struct msm_actuator_ctrl_t *a_ctrl = get_actrl(sd);
-	void __user *argp = (void __user *)arg;
-	switch (cmd) {
-	case VIDIOC_MSM_ACTUATOR_CFG:
-		return msm_actuator_config(a_ctrl, argp);
-	default:
-		return -ENOIOCTLCMD;
-	}
-}
-
-static int32_t msm_actuator_power(struct v4l2_subdev *sd, int on)
-{
-	int rc = 0;
-	struct msm_actuator_ctrl_t *a_ctrl = get_actrl(sd);
-	mutex_lock(a_ctrl->actuator_mutex);
-	if (on)
-		rc = msm_actuator_power_up(a_ctrl);
-	else
-		rc = msm_actuator_power_down(a_ctrl);
-	mutex_unlock(a_ctrl->actuator_mutex);
-	return rc;
-}
-
-struct msm_actuator_ctrl_t *get_actrl(struct v4l2_subdev *sd)
-{
-	return container_of(sd, struct msm_actuator_ctrl_t, sdev);
-}
-
-static struct v4l2_subdev_core_ops msm_actuator_subdev_core_ops = {
-	.ioctl = msm_actuator_subdev_ioctl,
-	.s_power = msm_actuator_power,
-};
-
-static struct v4l2_subdev_ops msm_actuator_subdev_ops = {
-	.core = &msm_actuator_subdev_core_ops,
-};
-
-static struct msm_actuator_ctrl_t msm_actuator_t = {
-	.i2c_driver = &msm_actuator_i2c_driver,
-	.act_v4l2_subdev_ops = &msm_actuator_subdev_ops,
-
-	.curr_step_pos = 0,
-	.curr_region_index = 0,
-	.actuator_mutex = &msm_actuator_mutex,
-
-};
-
-static struct msm_actuator msm_vcm_actuator_table = {
-	.act_type = ACTUATOR_VCM,
-	.func_tbl = {
-		.actuator_init_step_table = msm_actuator_init_step_table,
-		.actuator_move_focus = msm_actuator_move_focus,
-		.actuator_write_focus = msm_actuator_write_focus,
-		.actuator_set_default_focus = msm_actuator_set_default_focus,
-		.actuator_init_focus = msm_actuator_init_focus,
-		.actuator_parse_i2c_params = msm_actuator_parse_i2c_params,
-	},
-};
-
-static struct msm_actuator msm_piezo_actuator_table = {
-	.act_type = ACTUATOR_PIEZO,
-	.func_tbl = {
-		.actuator_init_step_table = NULL,
-		.actuator_move_focus = msm_actuator_piezo_move_focus,
-		.actuator_write_focus = NULL,
-		.actuator_set_default_focus =
-			msm_actuator_piezo_set_default_focus,
-		.actuator_init_focus = msm_actuator_init_focus,
-		.actuator_parse_i2c_params = msm_actuator_parse_i2c_params,
-	},
-};
-
-subsys_initcall(msm_actuator_i2c_add_driver);
-MODULE_DESCRIPTION("MSM ACTUATOR");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/actuators/msm_actuator.h b/drivers/media/platform/msm/camera_v1/actuators/msm_actuator.h
deleted file mode 100644
index 19b71a6..0000000
--- a/drivers/media/platform/msm/camera_v1/actuators/msm_actuator.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-#ifndef MSM_ACTUATOR_H
-#define MSM_ACTUATOR_H
-
-#include <linux/i2c.h>
-#include <mach/camera.h>
-#include <mach/gpio.h>
-#include <media/v4l2-subdev.h>
-#include <media/msm_camera.h>
-#include "msm_camera_i2c.h"
-
-#ifdef LERROR
-#undef LERROR
-#endif
-
-#ifdef LINFO
-#undef LINFO
-#endif
-
-#define LERROR(fmt, args...) pr_err(fmt, ##args)
-
-#define CONFIG_MSM_CAMERA_ACT_DBG 0
-
-#if CONFIG_MSM_CAMERA_ACT_DBG
-#define LINFO(fmt, args...) printk(fmt, ##args)
-#else
-#define LINFO(fmt, args...) CDBG(fmt, ##args)
-#endif
-
-struct msm_actuator_ctrl_t;
-
-struct msm_actuator_func_tbl {
-	int32_t (*actuator_i2c_write_b_af)(struct msm_actuator_ctrl_t *,
-			uint8_t,
-			uint8_t);
-	int32_t (*actuator_init_step_table)(struct msm_actuator_ctrl_t *,
-		struct msm_actuator_set_info_t *);
-	int32_t (*actuator_init_focus)(struct msm_actuator_ctrl_t *,
-		uint16_t, enum msm_actuator_data_type, struct reg_settings_t *);
-	int32_t (*actuator_set_default_focus) (struct msm_actuator_ctrl_t *,
-			struct msm_actuator_move_params_t *);
-	int32_t (*actuator_move_focus) (struct msm_actuator_ctrl_t *,
-			struct msm_actuator_move_params_t *);
-	int32_t (*actuator_parse_i2c_params)(struct msm_actuator_ctrl_t *,
-			int16_t, uint32_t, uint16_t);
-	int32_t (*actuator_write_focus)(struct msm_actuator_ctrl_t *,
-			uint16_t,
-			struct damping_params_t *,
-			int8_t,
-			int16_t);
-};
-
-struct msm_actuator {
-	enum actuator_type act_type;
-	struct msm_actuator_func_tbl func_tbl;
-};
-
-struct msm_actuator_ctrl_t {
-	struct i2c_driver *i2c_driver;
-	struct msm_camera_i2c_client i2c_client;
-	struct mutex *actuator_mutex;
-	struct msm_actuator_func_tbl *func_tbl;
-	enum msm_actuator_data_type i2c_data_type;
-	struct v4l2_subdev sdev;
-	struct v4l2_subdev_ops *act_v4l2_subdev_ops;
-
-	int16_t curr_step_pos;
-	uint16_t curr_region_index;
-	uint16_t *step_position_table;
-	struct region_params_t region_params[MAX_ACTUATOR_REGION];
-	uint16_t reg_tbl_size;
-	struct msm_actuator_reg_params_t reg_tbl[MAX_ACTUATOR_REG_TBL_SIZE];
-	uint16_t region_size;
-	void *user_data;
-	uint32_t vcm_pwd;
-	uint32_t vcm_enable;
-	uint32_t total_steps;
-	uint16_t pwd_step;
-	uint16_t initial_code;
-	struct msm_camera_i2c_reg_tbl *i2c_reg_tbl;
-	uint16_t i2c_tbl_index;
-};
-
-struct msm_actuator_ctrl_t *get_actrl(struct v4l2_subdev *sd);
-
-#define VIDIOC_MSM_ACTUATOR_CFG \
-	_IOWR('V', BASE_VIDIOC_PRIVATE + 11, void __user *)
-
-#endif
diff --git a/drivers/media/platform/msm/camera_v1/cci/Makefile b/drivers/media/platform/msm/camera_v1/cci/Makefile
deleted file mode 100644
index 0f23f6c..0000000
--- a/drivers/media/platform/msm/camera_v1/cci/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-GCC_VERSION      := $(shell $(CONFIG_SHELL) $(PWD)/scripts/gcc-version.sh $(CROSS_COMPILE)gcc)
-ccflags-y += -Idrivers/media/platform/msm/camera_v1 -Idrivers/media/platform/msm/camera_v1/server
-obj-$(CONFIG_MSM_CCI) += msm_cci.o
diff --git a/drivers/media/platform/msm/camera_v1/cci/msm_cam_cci_hwreg.h b/drivers/media/platform/msm/camera_v1/cci/msm_cam_cci_hwreg.h
deleted file mode 100644
index 0262eb4..0000000
--- a/drivers/media/platform/msm/camera_v1/cci/msm_cam_cci_hwreg.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#ifndef __MSM_CAM_CCI_HWREG__
-#define __MSM_CAM_CCI_HWREG__
-
-#define CCI_HW_VERSION_ADDR                                         0x00000000
-#define CCI_RESET_CMD_ADDR                                          0x00000004
-#define CCI_RESET_CMD_RMSK                                          0xcf73f3f7
-#define CCI_M0_RESET_RMSK                                                0x3F1
-#define CCI_M1_RESET_RMSK                                              0x3F001
-#define CCI_QUEUE_START_ADDR                                        0x00000008
-#define CCI_SET_CID_SYNC_TIMER_0_ADDR                               0x00000010
-#define CCI_I2C_M0_SCL_CTL_ADDR                                     0x00000100
-#define CCI_I2C_M0_SDA_CTL_0_ADDR                                   0x00000104
-#define CCI_I2C_M0_SDA_CTL_1_ADDR                                   0x00000108
-#define CCI_I2C_M0_SDA_CTL_2_ADDR                                   0x0000010c
-#define CCI_I2C_M0_READ_DATA_ADDR                                   0x00000118
-#define CCI_I2C_M0_MISC_CTL_ADDR                                    0x00000110
-#define CCI_I2C_M0_READ_BUF_LEVEL_ADDR                              0x0000011C
-#define CCI_HALT_REQ_ADDR                                           0x00000034
-#define CCI_M0_HALT_REQ_RMSK                                               0x1
-#define CCI_M1_HALT_REQ_RMSK                                              0x01
-#define CCI_HALT_REQ_ADDR                                           0x00000034
-#define CCI_I2C_M1_SCL_CTL_ADDR                                     0x00000200
-#define CCI_I2C_M1_SDA_CTL_0_ADDR                                   0x00000204
-#define CCI_I2C_M1_SDA_CTL_1_ADDR                                   0x00000208
-#define CCI_I2C_M1_SDA_CTL_2_ADDR                                   0x0000020c
-#define CCI_I2C_M1_MISC_CTL_ADDR                                    0x00000210
-#define CCI_I2C_M0_Q0_CUR_WORD_CNT_ADDR                             0x00000304
-#define CCI_I2C_M0_Q0_CUR_CMD_ADDR                                  0x00000308
-#define CCI_I2C_M0_Q0_EXEC_WORD_CNT_ADDR                            0x00000300
-#define CCI_I2C_M0_Q0_LOAD_DATA_ADDR                                0x00000310
-#define CCI_IRQ_MASK_0_ADDR                                         0x00000c04
-#define CCI_IRQ_CLEAR_0_ADDR                                        0x00000c08
-#define CCI_IRQ_STATUS_0_ADDR                                       0x00000c0c
-#define CCI_IRQ_STATUS_0_I2C_M1_Q1_NACK_ERR_BMSK                    0x40000000
-#define CCI_IRQ_STATUS_0_I2C_M1_Q0_NACK_ERR_BMSK                    0x20000000
-#define CCI_IRQ_STATUS_0_I2C_M0_Q1_NACK_ERR_BMSK                    0x10000000
-#define CCI_IRQ_STATUS_0_I2C_M0_Q0_NACK_ERR_BMSK                     0x8000000
-#define CCI_IRQ_STATUS_0_I2C_M1_Q0Q1_HALT_ACK_BMSK                   0x4000000
-#define CCI_IRQ_STATUS_0_I2C_M0_Q0Q1_HALT_ACK_BMSK                   0x2000000
-#define CCI_IRQ_STATUS_0_RST_DONE_ACK_BMSK                           0x1000000
-#define CCI_IRQ_STATUS_0_I2C_M1_Q1_REPORT_BMSK                        0x100000
-#define CCI_IRQ_STATUS_0_I2C_M1_Q0_REPORT_BMSK                         0x10000
-#define CCI_IRQ_STATUS_0_I2C_M1_RD_DONE_BMSK                            0x1000
-#define CCI_IRQ_STATUS_0_I2C_M0_Q1_REPORT_BMSK                           0x100
-#define CCI_IRQ_STATUS_0_I2C_M0_Q0_REPORT_BMSK                            0x10
-#define CCI_IRQ_STATUS_0_I2C_M0_RD_DONE_BMSK                               0x1
-#define CCI_IRQ_GLOBAL_CLEAR_CMD_ADDR                               0x00000c00
-#endif /* __MSM_CAM_CCI_HWREG__ */
diff --git a/drivers/media/platform/msm/camera_v1/cci/msm_cci.c b/drivers/media/platform/msm/camera_v1/cci/msm_cci.c
deleted file mode 100644
index 4da5897..0000000
--- a/drivers/media/platform/msm/camera_v1/cci/msm_cci.c
+++ /dev/null
@@ -1,769 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#include <linux/delay.h>
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <linux/module.h>
-#include <linux/of.h>
-#include <mach/board.h>
-#include <mach/camera.h>
-#include <media/msm_isp.h>
-#include "msm_cci.h"
-#include "msm.h"
-#include "msm_cam_server.h"
-#include "msm_cam_cci_hwreg.h"
-
-#define V4L2_IDENT_CCI 50005
-#define CCI_I2C_QUEUE_0_SIZE 64
-#define CCI_I2C_QUEUE_1_SIZE 16
-
-#define CCI_TIMEOUT msecs_to_jiffies(100)
-
-static void msm_cci_set_clk_param(struct cci_device *cci_dev)
-{
-	uint16_t THIGH = 78;
-	uint16_t TLOW = 114;
-	uint16_t TSUSTO = 28;
-	uint16_t TSUSTA = 28;
-	uint16_t THDDAT = 10;
-	uint16_t THDSTA = 77;
-	uint16_t TBUF = 118;
-	uint8_t HW_SCL_STRETCH_EN = 0; /*enable or disable SCL clock
-					* stretching */
-	uint8_t HW_RDHLD = 6; /* internal hold time 1-6 cycles of SDA to bridge
-			       * undefined falling SCL region */
-	uint8_t HW_TSP = 1; /* glitch filter 1-3 cycles */
-
-	msm_camera_io_w(THIGH << 16 | TLOW, cci_dev->base +
-		CCI_I2C_M0_SCL_CTL_ADDR);
-	msm_camera_io_w(TSUSTO << 16 | TSUSTA, cci_dev->base +
-		CCI_I2C_M0_SDA_CTL_0_ADDR);
-	msm_camera_io_w(THDDAT << 16 | THDSTA, cci_dev->base +
-		CCI_I2C_M0_SDA_CTL_1_ADDR);
-	msm_camera_io_w(TBUF, cci_dev->base +
-		CCI_I2C_M0_SDA_CTL_2_ADDR);
-	msm_camera_io_w(HW_SCL_STRETCH_EN << 8 | HW_RDHLD << 4 | HW_TSP,
-		cci_dev->base + CCI_I2C_M0_MISC_CTL_ADDR);
-	msm_camera_io_w(THIGH << 16 | TLOW, cci_dev->base +
-		CCI_I2C_M1_SCL_CTL_ADDR);
-	msm_camera_io_w(TSUSTO << 16 | TSUSTA, cci_dev->base +
-		CCI_I2C_M1_SDA_CTL_0_ADDR);
-	msm_camera_io_w(THDDAT << 16 | THDSTA, cci_dev->base +
-		CCI_I2C_M1_SDA_CTL_1_ADDR);
-	msm_camera_io_w(TBUF, cci_dev->base + CCI_I2C_M1_SDA_CTL_2_ADDR);
-	msm_camera_io_w(HW_SCL_STRETCH_EN << 8 | HW_RDHLD << 4 | HW_TSP,
-		cci_dev->base + CCI_I2C_M1_MISC_CTL_ADDR);
-}
-
-static int32_t msm_cci_i2c_config_sync_timer(struct v4l2_subdev *sd,
-	struct msm_camera_cci_ctrl *c_ctrl)
-{
-	struct cci_device *cci_dev;
-	cci_dev = v4l2_get_subdevdata(sd);
-	msm_camera_io_w(c_ctrl->cci_info->cid, cci_dev->base +
-		CCI_SET_CID_SYNC_TIMER_0_ADDR + (c_ctrl->cci_info->cid * 0x4));
-	return 0;
-}
-
-static int32_t msm_cci_i2c_set_freq(struct v4l2_subdev *sd,
-	struct msm_camera_cci_ctrl *c_ctrl)
-{
-	struct cci_device *cci_dev;
-	uint32_t val;
-	cci_dev = v4l2_get_subdevdata(sd);
-	val = c_ctrl->cci_info->freq;
-	msm_camera_io_w(val, cci_dev->base + CCI_I2C_M0_SCL_CTL_ADDR +
-		c_ctrl->cci_info->cci_i2c_master*0x100);
-	msm_camera_io_w(val, cci_dev->base + CCI_I2C_M0_SDA_CTL_0_ADDR +
-		c_ctrl->cci_info->cci_i2c_master*0x100);
-	msm_camera_io_w(val, cci_dev->base + CCI_I2C_M0_SDA_CTL_1_ADDR +
-		c_ctrl->cci_info->cci_i2c_master*0x100);
-	msm_camera_io_w(val, cci_dev->base + CCI_I2C_M0_SDA_CTL_2_ADDR +
-		c_ctrl->cci_info->cci_i2c_master*0x100);
-	msm_camera_io_w(val, cci_dev->base + CCI_I2C_M0_MISC_CTL_ADDR +
-		c_ctrl->cci_info->cci_i2c_master*0x100);
-	return 0;
-}
-
-static int32_t msm_cci_validate_queue(struct cci_device *cci_dev,
-	uint32_t len,
-	enum cci_i2c_master_t master,
-	enum cci_i2c_queue_t queue)
-{
-	int32_t rc = 0;
-	uint32_t read_val = 0;
-	uint32_t reg_offset = master * 0x200 + queue * 0x100;
-	read_val = msm_camera_io_r(cci_dev->base +
-		CCI_I2C_M0_Q0_CUR_WORD_CNT_ADDR + reg_offset);
-	CDBG("%s line %d CCI_I2C_M0_Q0_CUR_WORD_CNT_ADDR %d len %d max %d\n",
-		__func__, __LINE__, read_val, len,
-		cci_dev->cci_i2c_queue_info[master][queue].max_queue_size);
-	if ((read_val + len + 1) > cci_dev->
-		cci_i2c_queue_info[master][queue].max_queue_size) {
-		uint32_t reg_val = 0;
-		uint32_t report_val = CCI_I2C_REPORT_CMD | (1 << 8);
-		CDBG("%s:%d CCI_I2C_REPORT_CMD\n", __func__, __LINE__);
-		msm_camera_io_w(report_val,
-			cci_dev->base + CCI_I2C_M0_Q0_LOAD_DATA_ADDR +
-			reg_offset);
-		read_val++;
-		CDBG("%s:%d CCI_I2C_M0_Q0_EXEC_WORD_CNT_ADDR %d\n",
-			__func__, __LINE__, read_val);
-		msm_camera_io_w(read_val, cci_dev->base +
-			CCI_I2C_M0_Q0_EXEC_WORD_CNT_ADDR + reg_offset);
-		reg_val = 1 << ((master * 2) + queue);
-		CDBG("%s:%d CCI_QUEUE_START_ADDR\n", __func__, __LINE__);
-		msm_camera_io_w(reg_val, cci_dev->base + CCI_QUEUE_START_ADDR);
-		CDBG("%s line %d wait_for_completion_interruptible\n",
-			__func__, __LINE__);
-		wait_for_completion_interruptible_timeout(&cci_dev->
-			cci_master_info[master].reset_complete, CCI_TIMEOUT);
-
-		rc = cci_dev->cci_master_info[master].status;
-		if (rc < 0)
-			pr_err("%s failed rc %d\n", __func__, rc);
-	}
-	return rc;
-}
-
-static int32_t msm_cci_data_queue(struct cci_device *cci_dev,
-	struct msm_camera_cci_ctrl *c_ctrl, enum cci_i2c_queue_t queue)
-{
-	uint16_t i = 0, j = 0, k = 0, h = 0, len = 0;
-	uint32_t cmd = 0;
-	uint8_t data[10];
-	uint16_t reg_addr = 0;
-	struct msm_camera_cci_i2c_write_cfg *i2c_msg =
-		&c_ctrl->cfg.cci_i2c_write_cfg;
-	uint16_t cmd_size = i2c_msg->size;
-	struct msm_camera_i2c_reg_conf *i2c_cmd = i2c_msg->reg_conf_tbl;
-	enum cci_i2c_master_t master = c_ctrl->cci_info->cci_i2c_master;
-	CDBG("%s addr type %d data type %d\n", __func__,
-		i2c_msg->addr_type, i2c_msg->data_type);
-	/* assume total size within the max queue */
-	while (cmd_size) {
-		CDBG("%s cmd_size %d addr 0x%x data 0x%x", __func__,
-			cmd_size, i2c_cmd->reg_addr, i2c_cmd->reg_data);
-		data[i++] = CCI_I2C_WRITE_CMD;
-		if (i2c_cmd->reg_addr)
-			reg_addr = i2c_cmd->reg_addr;
-		/* either byte or word addr */
-		if (i2c_msg->addr_type == MSM_CAMERA_I2C_BYTE_ADDR)
-			data[i++] = reg_addr;
-		else {
-			data[i++] = (reg_addr & 0xFF00) >> 8;
-			data[i++] = reg_addr & 0x00FF;
-		}
-		/* max of 10 data bytes */
-		do {
-			if (i2c_msg->data_type == MSM_CAMERA_I2C_BYTE_DATA) {
-				data[i++] = i2c_cmd->reg_data;
-				reg_addr++;
-			} else {
-				if ((i + 1) <= 10) {
-					data[i++] = (i2c_cmd->reg_data &
-						0xFF00) >> 8; /* MSB */
-					data[i++] = i2c_cmd->reg_data &
-						0x00FF; /* LSB */
-					reg_addr += 2;
-				} else
-					break;
-			}
-			i2c_cmd++;
-		} while (--cmd_size && !i2c_cmd->reg_addr && (i <= 10));
-		data[0] |= ((i-1) << 4);
-		len = ((i-1)/4) + 1;
-		msm_cci_validate_queue(cci_dev, len, master, queue);
-		for (h = 0, k = 0; h < len; h++) {
-			cmd = 0;
-			for (j = 0; (j < 4 && k < i); j++)
-				cmd |= (data[k++] << (j * 8));
-			CDBG("%s CCI_I2C_M0_Q0_LOAD_DATA_ADDR 0x%x\n",
-				__func__, cmd);
-			msm_camera_io_w(cmd, cci_dev->base +
-				CCI_I2C_M0_Q0_LOAD_DATA_ADDR +
-				master * 0x200 + queue * 0x100);
-		}
-		i = 0;
-	}
-	return 0;
-}
-
-static int32_t msm_cci_write_i2c_queue(struct cci_device *cci_dev,
-	uint32_t val,
-	enum cci_i2c_master_t master,
-	enum cci_i2c_queue_t queue)
-{
-	int32_t rc = 0;
-	uint32_t reg_offset = master * 0x200 + queue * 0x100;
-	CDBG("%s:%d called\n", __func__, __LINE__);
-	msm_cci_validate_queue(cci_dev, 1, master, queue);
-	CDBG("%s CCI_I2C_M0_Q0_LOAD_DATA_ADDR:val %x:%x\n",
-		__func__, CCI_I2C_M0_Q0_LOAD_DATA_ADDR +
-		reg_offset, val);
-	msm_camera_io_w(val, cci_dev->base + CCI_I2C_M0_Q0_LOAD_DATA_ADDR +
-		reg_offset);
-	return rc;
-}
-
-static int32_t msm_cci_i2c_read(struct v4l2_subdev *sd,
-	struct msm_camera_cci_ctrl *c_ctrl)
-{
-	uint32_t rc = 0;
-	uint32_t val = 0;
-	int32_t read_words = 0, exp_words = 0;
-	int32_t index = 0, first_byte = 0;
-	uint32_t i = 0;
-	enum cci_i2c_master_t master;
-	enum cci_i2c_queue_t queue = QUEUE_1;
-	struct cci_device *cci_dev = NULL;
-	struct msm_camera_cci_i2c_read_cfg *read_cfg = NULL;
-	CDBG("%s line %d\n", __func__, __LINE__);
-	cci_dev = v4l2_get_subdevdata(sd);
-	master = c_ctrl->cci_info->cci_i2c_master;
-	read_cfg = &c_ctrl->cfg.cci_i2c_read_cfg;
-	mutex_lock(&cci_dev->cci_master_info[master].mutex);
-	CDBG("%s master %d, queue %d\n", __func__, master, queue);
-	CDBG("%s set param sid 0x%x retries %d id_map %d\n", __func__,
-		c_ctrl->cci_info->sid, c_ctrl->cci_info->retries,
-		c_ctrl->cci_info->id_map);
-	val = CCI_I2C_SET_PARAM_CMD | c_ctrl->cci_info->sid << 4 |
-		c_ctrl->cci_info->retries << 16 |
-		c_ctrl->cci_info->id_map << 18;
-	rc = msm_cci_write_i2c_queue(cci_dev, val, master, queue);
-	if (rc < 0) {
-		CDBG("%s failed line %d\n", __func__, __LINE__);
-		goto ERROR;
-	}
-
-	val = CCI_I2C_LOCK_CMD;
-	rc = msm_cci_write_i2c_queue(cci_dev, val, master, queue);
-	if (rc < 0) {
-		CDBG("%s failed line %d\n", __func__, __LINE__);
-		goto ERROR;
-	}
-
-	if (read_cfg->addr_type == MSM_CAMERA_I2C_BYTE_ADDR)
-		val = CCI_I2C_WRITE_CMD | (read_cfg->addr_type << 4) |
-			((read_cfg->addr & 0xFF) << 8);
-	if (read_cfg->addr_type == MSM_CAMERA_I2C_WORD_ADDR)
-		val = CCI_I2C_WRITE_CMD | (read_cfg->addr_type << 4) |
-			(((read_cfg->addr & 0xFF00) >> 8) << 8) |
-			((read_cfg->addr & 0xFF) << 16);
-	rc = msm_cci_write_i2c_queue(cci_dev, val, master, queue);
-	if (rc < 0) {
-		CDBG("%s failed line %d\n", __func__, __LINE__);
-		goto ERROR;
-	}
-
-	val = CCI_I2C_READ_CMD | (read_cfg->num_byte << 4);
-	rc = msm_cci_write_i2c_queue(cci_dev, val, master, queue);
-	if (rc < 0) {
-		CDBG("%s failed line %d\n", __func__, __LINE__);
-		goto ERROR;
-	}
-
-	val = CCI_I2C_UNLOCK_CMD;
-	rc = msm_cci_write_i2c_queue(cci_dev, val, master, queue);
-	if (rc < 0) {
-		CDBG("%s failed line %d\n", __func__, __LINE__);
-		goto ERROR;
-	}
-
-	val = msm_camera_io_r(cci_dev->base + CCI_I2C_M0_Q0_CUR_WORD_CNT_ADDR +
-		master * 0x200 + queue * 0x100);
-	CDBG("%s cur word cnt %x\n", __func__, val);
-	msm_camera_io_w(val, cci_dev->base + CCI_I2C_M0_Q0_EXEC_WORD_CNT_ADDR +
-		master * 0x200 + queue * 0x100);
-
-	val = 1 << ((master * 2) + queue);
-	msm_camera_io_w(val, cci_dev->base + CCI_QUEUE_START_ADDR);
-	wait_for_completion_interruptible_timeout(&cci_dev->
-		cci_master_info[master].reset_complete, CCI_TIMEOUT);
-
-	read_words = msm_camera_io_r(cci_dev->base +
-		CCI_I2C_M0_READ_BUF_LEVEL_ADDR + master * 0x100);
-	exp_words = ((read_cfg->num_byte / 4) + 1);
-	if (read_words != exp_words) {
-		pr_err("%s:%d read_words = %d, exp words = %d\n", __func__,
-			__LINE__, read_words, exp_words);
-		memset(read_cfg->data, 0, read_cfg->num_byte);
-		goto ERROR;
-	}
-	index = 0;
-	CDBG("%s index %d num_type %d\n", __func__, index,
-		read_cfg->num_byte);
-	first_byte = 0;
-	do {
-		val = msm_camera_io_r(cci_dev->base +
-			CCI_I2C_M0_READ_DATA_ADDR + master * 0x100);
-		CDBG("%s read val %x\n", __func__, val);
-		for (i = 0; (i < 4) && (index < read_cfg->num_byte); i++) {
-			CDBG("%s i %d index %d\n", __func__, i, index);
-			if (!first_byte) {
-				CDBG("%s sid %x\n", __func__, val & 0xFF);
-				first_byte++;
-			} else {
-				read_cfg->data[index] =
-					(val  >> (i * 8)) & 0xFF;
-				CDBG("%s data[%d] %x\n", __func__, index,
-					read_cfg->data[index]);
-				index++;
-			}
-		}
-	} while (--read_words > 0);
-ERROR:
-	mutex_unlock(&cci_dev->cci_master_info[master].mutex);
-	return rc;
-}
-
-static int32_t msm_cci_i2c_write(struct v4l2_subdev *sd,
-	struct msm_camera_cci_ctrl *c_ctrl)
-{
-	int32_t rc = 0;
-	struct cci_device *cci_dev;
-	uint32_t val;
-	enum cci_i2c_master_t master;
-	enum cci_i2c_queue_t queue = QUEUE_0;
-	cci_dev = v4l2_get_subdevdata(sd);
-	master = c_ctrl->cci_info->cci_i2c_master;
-	CDBG("%s master %d, queue %d\n", __func__, master, queue);
-	CDBG("%s set param sid 0x%x retries %d id_map %d\n", __func__,
-		c_ctrl->cci_info->sid, c_ctrl->cci_info->retries,
-		c_ctrl->cci_info->id_map);
-	mutex_lock(&cci_dev->cci_master_info[master].mutex);
-	val = CCI_I2C_SET_PARAM_CMD | c_ctrl->cci_info->sid << 4 |
-		c_ctrl->cci_info->retries << 16 |
-		c_ctrl->cci_info->id_map << 18;
-	CDBG("%s:%d CCI_I2C_SET_PARAM_CMD\n", __func__, __LINE__);
-	rc = msm_cci_write_i2c_queue(cci_dev, val, master, queue);
-	if (rc < 0) {
-		CDBG("%s failed line %d\n", __func__, __LINE__);
-		goto ERROR;
-	}
-
-	val = CCI_I2C_LOCK_CMD;
-	CDBG("%s:%d CCI_I2C_LOCK_CMD\n", __func__, __LINE__);
-	rc = msm_cci_write_i2c_queue(cci_dev, val, master, queue);
-	if (rc < 0) {
-		CDBG("%s failed line %d\n", __func__, __LINE__);
-		goto ERROR;
-	}
-
-	msm_cci_data_queue(cci_dev, c_ctrl, queue);
-	val = CCI_I2C_UNLOCK_CMD;
-	CDBG("%s:%d CCI_I2C_UNLOCK_CMD\n", __func__, __LINE__);
-	rc = msm_cci_write_i2c_queue(cci_dev, val, master, queue);
-	if (rc < 0) {
-		CDBG("%s failed line %d\n", __func__, __LINE__);
-		goto ERROR;
-	}
-
-	val = CCI_I2C_REPORT_CMD | (1 << 8);
-	CDBG("%s:%d CCI_I2C_REPORT_CMD\n", __func__, __LINE__);
-	rc = msm_cci_write_i2c_queue(cci_dev, val, master, queue);
-	if (rc < 0) {
-		CDBG("%s failed line %d\n", __func__, __LINE__);
-		goto ERROR;
-	}
-
-	val = msm_camera_io_r(cci_dev->base + CCI_I2C_M0_Q0_CUR_WORD_CNT_ADDR +
-		master * 0x200 + queue * 0x100);
-	CDBG("%s:%d cur word count %d\n", __func__, __LINE__, val);
-	CDBG("%s:%d CCI_I2C_M0_Q0_EXEC_WORD_CNT_ADDR\n", __func__, __LINE__);
-	msm_camera_io_w(val, cci_dev->base + CCI_I2C_M0_Q0_EXEC_WORD_CNT_ADDR +
-		master * 0x200 + queue * 0x100);
-
-	val = 1 << ((master * 2) + queue);
-	CDBG("%s:%d CCI_QUEUE_START_ADDR\n", __func__, __LINE__);
-	msm_camera_io_w(val, cci_dev->base + CCI_QUEUE_START_ADDR +
-		master*0x200 + queue * 0x100);
-
-	CDBG("%s line %d wait_for_completion_interruptible\n",
-		__func__, __LINE__);
-	wait_for_completion_interruptible_timeout(&cci_dev->
-		cci_master_info[master].reset_complete, CCI_TIMEOUT);
-
-ERROR:
-	mutex_unlock(&cci_dev->cci_master_info[master].mutex);
-	return rc;
-}
-
-static int msm_cci_subdev_g_chip_ident(struct v4l2_subdev *sd,
-			struct v4l2_dbg_chip_ident *chip)
-{
-	BUG_ON(!chip);
-	chip->ident = V4L2_IDENT_CCI;
-	chip->revision = 0;
-	return 0;
-}
-
-static struct msm_cam_clk_info cci_clk_info[] = {
-	{"camss_top_ahb_clk", -1},
-	{"cci_src_clk", 19200000},
-	{"cci_ahb_clk", -1},
-	{"cci_clk", -1},
-};
-
-static int32_t msm_cci_init(struct v4l2_subdev *sd)
-{
-	int rc = 0;
-	struct cci_device *cci_dev;
-	cci_dev = v4l2_get_subdevdata(sd);
-	CDBG("%s line %d\n", __func__, __LINE__);
-	if (cci_dev == NULL) {
-		rc = -ENOMEM;
-		return rc;
-	}
-	rc = msm_cam_clk_enable(&cci_dev->pdev->dev, cci_clk_info,
-		cci_dev->cci_clk, ARRAY_SIZE(cci_clk_info), 1);
-	if (rc < 0) {
-		CDBG("%s: clk enable failed\n", __func__);
-		goto clk_enable_failed;
-	}
-
-	enable_irq(cci_dev->irq->start);
-	cci_dev->hw_version = msm_camera_io_r(cci_dev->base +
-		CCI_HW_VERSION_ADDR);
-	cci_dev->cci_master_info[MASTER_0].reset_pending = TRUE;
-	msm_camera_io_w(0xFFFFFFFF, cci_dev->base + CCI_RESET_CMD_ADDR);
-	msm_camera_io_w(0x1, cci_dev->base + CCI_RESET_CMD_ADDR);
-	wait_for_completion_interruptible_timeout(
-		&cci_dev->cci_master_info[MASTER_0].reset_complete,
-		CCI_TIMEOUT);
-	msm_cci_set_clk_param(cci_dev);
-	msm_camera_io_w(0xFFFFFFFF, cci_dev->base + CCI_IRQ_MASK_0_ADDR);
-	msm_camera_io_w(0xFFFFFFFF, cci_dev->base + CCI_IRQ_CLEAR_0_ADDR);
-	msm_camera_io_w(0x1, cci_dev->base + CCI_IRQ_GLOBAL_CLEAR_CMD_ADDR);
-	msm_camera_io_w(0x0, cci_dev->base + CCI_IRQ_GLOBAL_CLEAR_CMD_ADDR);
-	msm_camera_io_w(0x0, cci_dev->base + CCI_IRQ_CLEAR_0_ADDR);
-	return 0;
-
-clk_enable_failed:
-	return rc;
-}
-
-static int32_t msm_cci_release(struct v4l2_subdev *sd)
-{
-	struct cci_device *cci_dev;
-	cci_dev = v4l2_get_subdevdata(sd);
-
-	disable_irq(cci_dev->irq->start);
-
-	msm_cam_clk_enable(&cci_dev->pdev->dev, cci_clk_info,
-		cci_dev->cci_clk, ARRAY_SIZE(cci_clk_info), 0);
-
-	return 0;
-}
-
-static int32_t msm_cci_config(struct v4l2_subdev *sd,
-	struct msm_camera_cci_ctrl *cci_ctrl)
-{
-	int32_t rc = 0;
-	CDBG("%s line %d cmd %d\n", __func__, __LINE__,
-		cci_ctrl->cmd);
-	switch (cci_ctrl->cmd) {
-	case MSM_CCI_INIT:
-		rc = msm_cci_init(sd);
-		break;
-	case MSM_CCI_RELEASE:
-		rc = msm_cci_release(sd);
-		break;
-	case MSM_CCI_SET_SID:
-		break;
-	case MSM_CCI_SET_FREQ:
-		rc = msm_cci_i2c_set_freq(sd, cci_ctrl);
-		break;
-	case MSM_CCI_SET_SYNC_CID:
-		rc = msm_cci_i2c_config_sync_timer(sd, cci_ctrl);
-		break;
-	case MSM_CCI_I2C_READ:
-		rc = msm_cci_i2c_read(sd, cci_ctrl);
-		break;
-	case MSM_CCI_I2C_WRITE:
-		rc = msm_cci_i2c_write(sd, cci_ctrl);
-		break;
-	case MSM_CCI_GPIO_WRITE:
-		break;
-	default:
-		rc = -ENOIOCTLCMD;
-	}
-	CDBG("%s line %d rc %d\n", __func__, __LINE__, rc);
-	cci_ctrl->status = rc;
-	return rc;
-}
-
-static irqreturn_t msm_cci_irq(int irq_num, void *data)
-{
-	uint32_t irq;
-	struct cci_device *cci_dev = data;
-	irq = msm_camera_io_r(cci_dev->base + CCI_IRQ_STATUS_0_ADDR);
-	msm_camera_io_w(irq, cci_dev->base + CCI_IRQ_CLEAR_0_ADDR);
-	msm_camera_io_w(0x1, cci_dev->base + CCI_IRQ_GLOBAL_CLEAR_CMD_ADDR);
-	msm_camera_io_w(0x0, cci_dev->base + CCI_IRQ_GLOBAL_CLEAR_CMD_ADDR);
-	CDBG("%s CCI_I2C_M0_STATUS_ADDR = 0x%x\n", __func__, irq);
-	if (irq & CCI_IRQ_STATUS_0_RST_DONE_ACK_BMSK) {
-		if (cci_dev->cci_master_info[MASTER_0].reset_pending == TRUE) {
-			cci_dev->cci_master_info[MASTER_0].reset_pending =
-				FALSE;
-			complete(&cci_dev->cci_master_info[MASTER_0].
-				reset_complete);
-		}
-		if (cci_dev->cci_master_info[MASTER_1].reset_pending == TRUE) {
-			cci_dev->cci_master_info[MASTER_1].reset_pending =
-				FALSE;
-			complete(&cci_dev->cci_master_info[MASTER_1].
-				reset_complete);
-		}
-	} else if ((irq & CCI_IRQ_STATUS_0_I2C_M0_RD_DONE_BMSK) ||
-		(irq & CCI_IRQ_STATUS_0_I2C_M0_Q0_REPORT_BMSK) ||
-		(irq & CCI_IRQ_STATUS_0_I2C_M0_Q1_REPORT_BMSK)) {
-		cci_dev->cci_master_info[MASTER_0].status = 0;
-		complete(&cci_dev->cci_master_info[MASTER_0].reset_complete);
-	} else if ((irq & CCI_IRQ_STATUS_0_I2C_M1_RD_DONE_BMSK) ||
-		(irq & CCI_IRQ_STATUS_0_I2C_M1_Q0_REPORT_BMSK) ||
-		(irq & CCI_IRQ_STATUS_0_I2C_M1_Q1_REPORT_BMSK)) {
-		cci_dev->cci_master_info[MASTER_1].status = 0;
-		complete(&cci_dev->cci_master_info[MASTER_1].reset_complete);
-	} else if ((irq & CCI_IRQ_STATUS_0_I2C_M0_Q0_NACK_ERR_BMSK) ||
-		(irq & CCI_IRQ_STATUS_0_I2C_M0_Q1_NACK_ERR_BMSK)) {
-		cci_dev->cci_master_info[MASTER_0].status = -EINVAL;
-		msm_camera_io_w(CCI_M0_HALT_REQ_RMSK,
-			cci_dev->base + CCI_HALT_REQ_ADDR);
-	} else if ((irq & CCI_IRQ_STATUS_0_I2C_M1_Q0_NACK_ERR_BMSK) ||
-		(irq & CCI_IRQ_STATUS_0_I2C_M1_Q1_NACK_ERR_BMSK)) {
-		cci_dev->cci_master_info[MASTER_1].status = -EINVAL;
-		msm_camera_io_w(CCI_M1_HALT_REQ_RMSK,
-			cci_dev->base + CCI_HALT_REQ_ADDR);
-	} else if (irq & CCI_IRQ_STATUS_0_I2C_M0_Q0Q1_HALT_ACK_BMSK) {
-		cci_dev->cci_master_info[MASTER_0].reset_pending = TRUE;
-		msm_camera_io_w(CCI_M0_RESET_RMSK,
-			cci_dev->base + CCI_RESET_CMD_ADDR);
-	} else if (irq & CCI_IRQ_STATUS_0_I2C_M1_Q0Q1_HALT_ACK_BMSK) {
-		cci_dev->cci_master_info[MASTER_1].reset_pending = TRUE;
-		msm_camera_io_w(CCI_M1_RESET_RMSK,
-			cci_dev->base + CCI_RESET_CMD_ADDR);
-	} else {
-		pr_err("%s unhandled irq 0x%x\n", __func__, irq);
-		cci_dev->cci_master_info[MASTER_0].status = 0;
-		complete(&cci_dev->cci_master_info[MASTER_0].reset_complete);
-		cci_dev->cci_master_info[MASTER_1].status = 0;
-		complete(&cci_dev->cci_master_info[MASTER_1].reset_complete);
-	}
-	return IRQ_HANDLED;
-}
-
-int msm_cci_irq_routine(struct v4l2_subdev *sd, u32 status, bool *handled)
-{
-	struct cci_device *cci_dev = v4l2_get_subdevdata(sd);
-	irqreturn_t ret;
-	CDBG("%s line %d\n", __func__, __LINE__);
-	ret = msm_cci_irq(cci_dev->irq->start, cci_dev);
-	*handled = TRUE;
-	return 0;
-}
-
-static long msm_cci_subdev_ioctl(struct v4l2_subdev *sd,
-	unsigned int cmd, void *arg)
-{
-	int32_t rc = 0;
-	CDBG("%s line %d\n", __func__, __LINE__);
-	switch (cmd) {
-	case VIDIOC_MSM_CCI_CFG:
-		rc = msm_cci_config(sd, arg);
-		break;
-	default:
-		rc = -ENOIOCTLCMD;
-	}
-	CDBG("%s line %d rc %d\n", __func__, __LINE__, rc);
-	return rc;
-}
-
-static struct v4l2_subdev_core_ops msm_cci_subdev_core_ops = {
-	.g_chip_ident = &msm_cci_subdev_g_chip_ident,
-	.ioctl = &msm_cci_subdev_ioctl,
-	.interrupt_service_routine = msm_cci_irq_routine,
-};
-
-static const struct v4l2_subdev_ops msm_cci_subdev_ops = {
-	.core = &msm_cci_subdev_core_ops,
-};
-
-static const struct v4l2_subdev_internal_ops msm_cci_internal_ops;
-
-static void msm_cci_initialize_cci_params(struct cci_device *new_cci_dev)
-{
-	uint8_t i = 0, j = 0;
-	for (i = 0; i < NUM_MASTERS; i++) {
-		new_cci_dev->cci_master_info[i].status = 0;
-		mutex_init(&new_cci_dev->cci_master_info[i].mutex);
-		init_completion(&new_cci_dev->
-			cci_master_info[i].reset_complete);
-		for (j = 0; j < NUM_QUEUES; j++) {
-			if (j == QUEUE_0)
-				new_cci_dev->cci_i2c_queue_info[i][j].
-					max_queue_size = CCI_I2C_QUEUE_0_SIZE;
-			else
-				new_cci_dev->cci_i2c_queue_info[i][j].
-					max_queue_size = CCI_I2C_QUEUE_1_SIZE;
-			}
-	}
-	return;
-}
-
-static int __devinit msm_cci_probe(struct platform_device *pdev)
-{
-	struct cci_device *new_cci_dev;
-	int rc = 0;
-	struct msm_cam_subdev_info sd_info;
-	struct intr_table_entry irq_req;
-	CDBG("%s: pdev %p device id = %d\n", __func__, pdev, pdev->id);
-	new_cci_dev = kzalloc(sizeof(struct cci_device), GFP_KERNEL);
-	if (!new_cci_dev) {
-		CDBG("%s: no enough memory\n", __func__);
-		return -ENOMEM;
-	}
-	v4l2_subdev_init(&new_cci_dev->subdev, &msm_cci_subdev_ops);
-	new_cci_dev->subdev.internal_ops = &msm_cci_internal_ops;
-	new_cci_dev->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	snprintf(new_cci_dev->subdev.name,
-			ARRAY_SIZE(new_cci_dev->subdev.name), "msm_cci");
-	v4l2_set_subdevdata(&new_cci_dev->subdev, new_cci_dev);
-	platform_set_drvdata(pdev, &new_cci_dev->subdev);
-	CDBG("%s sd %p\n", __func__, &new_cci_dev->subdev);
-	if (pdev->dev.of_node)
-		of_property_read_u32((&pdev->dev)->of_node,
-			"cell-index", &pdev->id);
-
-	new_cci_dev->mem = platform_get_resource_byname(pdev,
-					IORESOURCE_MEM, "cci");
-	if (!new_cci_dev->mem) {
-		CDBG("%s: no mem resource?\n", __func__);
-		rc = -ENODEV;
-		goto cci_no_resource;
-	}
-	new_cci_dev->irq = platform_get_resource_byname(pdev,
-					IORESOURCE_IRQ, "cci");
-	CDBG("%s line %d cci irq start %d end %d\n", __func__,
-		__LINE__,
-		new_cci_dev->irq->start,
-		new_cci_dev->irq->end);
-	if (!new_cci_dev->irq) {
-		CDBG("%s: no irq resource?\n", __func__);
-		rc = -ENODEV;
-		goto cci_no_resource;
-	}
-	new_cci_dev->io = request_mem_region(new_cci_dev->mem->start,
-		resource_size(new_cci_dev->mem), pdev->name);
-	if (!new_cci_dev->io) {
-		CDBG("%s: no valid mem region\n", __func__);
-		rc = -EBUSY;
-		goto cci_no_resource;
-	}
-
-	new_cci_dev->base = ioremap(new_cci_dev->mem->start,
-		resource_size(new_cci_dev->mem));
-	if (!new_cci_dev->base) {
-		rc = -ENOMEM;
-		goto cci_release_mem;
-	}
-
-	sd_info.sdev_type = CCI_DEV;
-	sd_info.sd_index = pdev->id;
-	sd_info.irq_num = new_cci_dev->irq->start;
-	msm_cam_register_subdev_node(&new_cci_dev->subdev, &sd_info);
-
-	irq_req.cam_hw_idx       = MSM_CAM_HW_CCI;
-	irq_req.dev_name         = "msm_cci";
-	irq_req.irq_idx          = CAMERA_SS_IRQ_1;
-	irq_req.irq_num          = new_cci_dev->irq->start;
-	irq_req.is_composite     = 0;
-	irq_req.irq_trigger_type = IRQF_TRIGGER_RISING;
-	irq_req.num_hwcore       = 1;
-	irq_req.subdev_list[0]   = &new_cci_dev->subdev;
-	irq_req.data             = (void *)new_cci_dev;
-	rc = msm_cam_server_request_irq(&irq_req);
-	if (rc == -ENXIO) {
-		/* IRQ Router hardware is not present on this hardware.
-		 * Request for the IRQ and register the interrupt handler. */
-		rc = request_irq(new_cci_dev->irq->start, msm_cci_irq,
-			IRQF_TRIGGER_RISING, "cci", new_cci_dev);
-		if (rc < 0) {
-			CDBG("%s: irq request fail\n", __func__);
-			rc = -EBUSY;
-			goto cci_release_mem;
-		}
-		disable_irq(new_cci_dev->irq->start);
-	} else if (rc < 0) {
-		CDBG("%s Error registering irq ", __func__);
-		rc = -EBUSY;
-		goto cci_release_mem;
-	}
-
-	new_cci_dev->pdev = pdev;
-	msm_cci_initialize_cci_params(new_cci_dev);
-	rc = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
-	if (rc)
-		pr_err("%s: failed to add child nodes, rc=%d\n", __func__, rc);
-	CDBG("%s line %d\n", __func__, __LINE__);
-	return 0;
-
-cci_release_mem:
-	release_mem_region(new_cci_dev->mem->start,
-		resource_size(new_cci_dev->mem));
-cci_no_resource:
-	kfree(new_cci_dev);
-	return 0;
-}
-
-static int __exit msm_cci_exit(struct platform_device *pdev)
-{
-	struct v4l2_subdev *subdev = platform_get_drvdata(pdev);
-	struct cci_device *cci_dev =
-		v4l2_get_subdevdata(subdev);
-	release_mem_region(cci_dev->mem->start, resource_size(cci_dev->mem));
-	kfree(cci_dev);
-	return 0;
-}
-
-static const struct of_device_id msm_cci_dt_match[] = {
-	{.compatible = "qcom,cci"},
-	{}
-};
-
-MODULE_DEVICE_TABLE(of, msm_cci_dt_match);
-
-static struct platform_driver cci_driver = {
-	.probe = msm_cci_probe,
-	.remove = msm_cci_exit,
-	.driver = {
-		.name = MSM_CCI_DRV_NAME,
-		.owner = THIS_MODULE,
-		.of_match_table = msm_cci_dt_match,
-	},
-};
-
-static int __init msm_cci_init_module(void)
-{
-	return platform_driver_register(&cci_driver);
-}
-
-static void __exit msm_cci_exit_module(void)
-{
-	platform_driver_unregister(&cci_driver);
-}
-
-module_init(msm_cci_init_module);
-module_exit(msm_cci_exit_module);
-MODULE_DESCRIPTION("MSM CCI driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/cci/msm_cci.h b/drivers/media/platform/msm/camera_v1/cci/msm_cci.h
deleted file mode 100644
index 827916d..0000000
--- a/drivers/media/platform/msm/camera_v1/cci/msm_cci.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#ifndef MSM_CCI_H
-#define MSM_CCI_H
-
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <media/v4l2-subdev.h>
-#include <mach/camera.h>
-
-#define NUM_MASTERS 2
-#define NUM_QUEUES 2
-
-#define TRUE  1
-#define FALSE 0
-
-struct msm_camera_cci_master_info {
-	uint32_t status;
-	uint8_t reset_pending;
-	struct mutex mutex;
-	struct completion reset_complete;
-};
-
-struct cci_device {
-	struct platform_device *pdev;
-	struct v4l2_subdev subdev;
-	struct resource *mem;
-	struct resource *irq;
-	struct resource *io;
-	void __iomem *base;
-	uint32_t hw_version;
-	struct clk *cci_clk[5];
-	struct msm_camera_cci_i2c_queue_info
-		cci_i2c_queue_info[NUM_MASTERS][NUM_QUEUES];
-	struct msm_camera_cci_master_info cci_master_info[NUM_MASTERS];
-};
-
-enum msm_cci_i2c_cmd_type {
-	CCI_I2C_SET_PARAM_CMD = 1,
-	CCI_I2C_WAIT_CMD,
-	CCI_I2C_WAIT_SYNC_CMD,
-	CCI_I2C_WAIT_GPIO_EVENT_CMD,
-	CCI_I2C_TRIG_I2C_EVENT_CMD,
-	CCI_I2C_LOCK_CMD,
-	CCI_I2C_UNLOCK_CMD,
-	CCI_I2C_REPORT_CMD,
-	CCI_I2C_WRITE_CMD,
-	CCI_I2C_READ_CMD,
-	CCI_I2C_WRITE_DISABLE_P_CMD,
-	CCI_I2C_READ_DISABLE_P_CMD,
-	CCI_I2C_WRITE_CMD2,
-	CCI_I2C_WRITE_CMD3,
-	CCI_I2C_REPEAT_CMD,
-	CCI_I2C_INVALID_CMD,
-};
-
-enum msm_cci_gpio_cmd_type {
-	CCI_GPIO_SET_PARAM_CMD = 1,
-	CCI_GPIO_WAIT_CMD,
-	CCI_GPIO_WAIT_SYNC_CMD,
-	CCI_GPIO_WAIT_GPIO_IN_EVENT_CMD,
-	CCI_GPIO_WAIT_I2C_Q_TRIG_EVENT_CMD,
-	CCI_GPIO_OUT_CMD,
-	CCI_GPIO_TRIG_EVENT_CMD,
-	CCI_GPIO_REPORT_CMD,
-	CCI_GPIO_REPEAT_CMD,
-	CCI_GPIO_CONTINUE_CMD,
-	CCI_GPIO_INVALID_CMD,
-};
-
-#define VIDIOC_MSM_CCI_CFG \
-	_IOWR('V', BASE_VIDIOC_PRIVATE + 23, struct msm_camera_cci_ctrl *)
-
-#endif
-
diff --git a/drivers/media/platform/msm/camera_v1/cpp/Makefile b/drivers/media/platform/msm/camera_v1/cpp/Makefile
deleted file mode 100644
index aa4c362..0000000
--- a/drivers/media/platform/msm/camera_v1/cpp/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-GCC_VERSION      := $(shell $(CONFIG_SHELL) $(PWD)/scripts/gcc-version.sh $(CROSS_COMPILE)gcc)
-ccflags-y += -Idrivers/media/platform/msm/camera_v1
-ccflags-y += -Idrivers/media/platform/msm/camera_v1/io
-obj-$(CONFIG_MSM_CPP) += msm_cpp.o
-
diff --git a/drivers/media/platform/msm/camera_v1/cpp/msm_cpp.c b/drivers/media/platform/msm/camera_v1/cpp/msm_cpp.c
deleted file mode 100644
index cd932bd..0000000
--- a/drivers/media/platform/msm/camera_v1/cpp/msm_cpp.c
+++ /dev/null
@@ -1,412 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#include <linux/delay.h>
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <linux/module.h>
-#include <mach/board.h>
-#include <mach/camera.h>
-#include <mach/vreg.h>
-#include <media/msm_isp.h>
-#include <linux/proc_fs.h>
-#include <linux/debugfs.h>
-
-#include "msm_cpp.h"
-#include "msm.h"
-
-#define CONFIG_MSM_CPP_DBG 0
-
-#if CONFIG_MSM_CPP_DBG
-#define CPP_DBG(fmt, args...) pr_info(fmt, ##args)
-#else
-#define CPP_DBG(fmt, args...) pr_debug(fmt, ##args)
-#endif
-
-static int cpp_open_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
-{
-	uint32_t i;
-	struct cpp_device *cpp_dev = v4l2_get_subdevdata(sd);
-	CPP_DBG("%s\n", __func__);
-
-	mutex_lock(&cpp_dev->mutex);
-	if (cpp_dev->cpp_open_cnt == MAX_ACTIVE_CPP_INSTANCE) {
-		pr_err("No free CPP instance\n");
-		mutex_unlock(&cpp_dev->mutex);
-		return -ENODEV;
-	}
-
-	for (i = 0; i < MAX_ACTIVE_CPP_INSTANCE; i++) {
-		if (cpp_dev->cpp_subscribe_list[i].active == 0) {
-			cpp_dev->cpp_subscribe_list[i].active = 1;
-			cpp_dev->cpp_subscribe_list[i].vfh = &fh->vfh;
-			break;
-		}
-	}
-	if (i == MAX_ACTIVE_CPP_INSTANCE) {
-		pr_err("No free instance\n");
-		mutex_unlock(&cpp_dev->mutex);
-		return -ENODEV;
-	}
-
-	CPP_DBG("open %d %p\n", i, &fh->vfh);
-	cpp_dev->cpp_open_cnt++;
-	mutex_unlock(&cpp_dev->mutex);
-	return 0;
-}
-
-static int cpp_close_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
-{
-	uint32_t i;
-	struct cpp_device *cpp_dev = v4l2_get_subdevdata(sd);
-	mutex_lock(&cpp_dev->mutex);
-	for (i = 0; i < MAX_ACTIVE_CPP_INSTANCE; i++) {
-		if (cpp_dev->cpp_subscribe_list[i].vfh == &fh->vfh) {
-			cpp_dev->cpp_subscribe_list[i].active = 0;
-			cpp_dev->cpp_subscribe_list[i].vfh = NULL;
-			break;
-		}
-	}
-	if (i == MAX_ACTIVE_CPP_INSTANCE) {
-		pr_err("Invalid close\n");
-		mutex_unlock(&cpp_dev->mutex);
-		return -ENODEV;
-	}
-
-	CPP_DBG("close %d %p\n", i, &fh->vfh);
-	cpp_dev->cpp_open_cnt--;
-	mutex_unlock(&cpp_dev->mutex);
-	return 0;
-}
-
-static const struct v4l2_subdev_internal_ops msm_cpp_internal_ops = {
-	.open = cpp_open_node,
-	.close = cpp_close_node,
-};
-
-static int msm_cpp_notify_frame_done(struct cpp_device *cpp_dev)
-{
-	struct v4l2_event v4l2_evt;
-	struct msm_queue_cmd *frame_qcmd;
-	struct msm_queue_cmd *event_qcmd;
-	struct msm_cpp_frame_info_t *processed_frame;
-	struct msm_device_queue *queue = &cpp_dev->processing_q;
-
-	if (queue->len > 0) {
-		frame_qcmd = msm_dequeue(queue, list_frame);
-		processed_frame = frame_qcmd->command;
-
-		event_qcmd = kzalloc(sizeof(struct msm_queue_cmd), GFP_KERNEL);
-		if (!event_qcmd) {
-			pr_err("%s Insufficient memory. return", __func__);
-			return -ENOMEM;
-		}
-		atomic_set(&event_qcmd->on_heap, 1);
-		event_qcmd->command = processed_frame;
-		CPP_DBG("fid %d\n", processed_frame->frame_id);
-		msm_enqueue(&cpp_dev->eventData_q, &event_qcmd->list_eventdata);
-
-		v4l2_evt.id = processed_frame->inst_id;
-		v4l2_evt.type = V4L2_EVENT_CPP_FRAME_DONE;
-		v4l2_event_queue(cpp_dev->subdev.devnode, &v4l2_evt);
-	}
-	return 0;
-}
-
-static int msm_cpp_send_frame_to_hardware(struct cpp_device *cpp_dev)
-{
-	struct msm_queue_cmd *frame_qcmd;
-	struct msm_cpp_frame_info_t *process_frame;
-	struct msm_device_queue *queue;
-
-	if (cpp_dev->processing_q.len < MAX_CPP_PROCESSING_FRAME) {
-		while (cpp_dev->processing_q.len < MAX_CPP_PROCESSING_FRAME) {
-			if (cpp_dev->realtime_q.len != 0) {
-				queue = &cpp_dev->realtime_q;
-			} else if (cpp_dev->offline_q.len != 0) {
-				queue = &cpp_dev->offline_q;
-			} else {
-				pr_debug("%s: All frames queued\n", __func__);
-				break;
-			}
-			frame_qcmd = msm_dequeue(queue, list_frame);
-			/*TBD Code to actually sending to harware*/
-			process_frame = frame_qcmd->command;
-
-			msm_enqueue(&cpp_dev->processing_q,
-						&frame_qcmd->list_frame);
-		}
-	}
-	return 0;
-}
-
-long msm_cpp_subdev_ioctl(struct v4l2_subdev *sd,
-			unsigned int cmd, void *arg)
-{
-	struct cpp_device *cpp_dev = v4l2_get_subdevdata(sd);
-	struct msm_camera_v4l2_ioctl_t *ioctl_ptr = arg;
-	int rc = 0;
-
-	CPP_DBG("%s: %d\n", __func__, __LINE__);
-	mutex_lock(&cpp_dev->mutex);
-	CPP_DBG("%s cmd: %d\n", __func__, cmd);
-	switch (cmd) {
-	case VIDIOC_MSM_CPP_CFG: {
-		struct msm_queue_cmd *frame_qcmd;
-		struct msm_cpp_frame_info_t *new_frame =
-			kzalloc(sizeof(struct msm_cpp_frame_info_t),
-					GFP_KERNEL);
-		if (!new_frame) {
-			pr_err("%s Insufficient memory. return", __func__);
-			mutex_unlock(&cpp_dev->mutex);
-			return -ENOMEM;
-		}
-
-		COPY_FROM_USER(rc, new_frame,
-			       (void __user *)ioctl_ptr->ioctl_ptr,
-			       sizeof(struct msm_cpp_frame_info_t));
-		if (rc) {
-			ERR_COPY_FROM_USER();
-			kfree(new_frame);
-			mutex_unlock(&cpp_dev->mutex);
-			return -EINVAL;
-		}
-
-		frame_qcmd = kzalloc(sizeof(struct msm_queue_cmd), GFP_KERNEL);
-		if (!frame_qcmd) {
-			pr_err("%s Insufficient memory. return", __func__);
-			kfree(new_frame);
-			mutex_unlock(&cpp_dev->mutex);
-			return -ENOMEM;
-		}
-
-		atomic_set(&frame_qcmd->on_heap, 1);
-		frame_qcmd->command = new_frame;
-		if (new_frame->frame_type == MSM_CPP_REALTIME_FRAME) {
-			msm_enqueue(&cpp_dev->realtime_q,
-						&frame_qcmd->list_frame);
-		} else if (new_frame->frame_type == MSM_CPP_OFFLINE_FRAME) {
-			msm_enqueue(&cpp_dev->offline_q,
-						&frame_qcmd->list_frame);
-		} else {
-			pr_err("%s: Invalid frame type\n", __func__);
-			kfree(new_frame);
-			kfree(frame_qcmd);
-			mutex_unlock(&cpp_dev->mutex);
-			return -EINVAL;
-		}
-		break;
-	}
-	case VIDIOC_MSM_CPP_GET_EVENTPAYLOAD: {
-		struct msm_device_queue *queue = &cpp_dev->eventData_q;
-		struct msm_queue_cmd *event_qcmd;
-		struct msm_cpp_frame_info_t *process_frame;
-		event_qcmd = msm_dequeue(queue, list_eventdata);
-		process_frame = event_qcmd->command;
-		CPP_DBG("fid %d\n", process_frame->frame_id);
-		if (copy_to_user((void __user *)ioctl_ptr->ioctl_ptr,
-				process_frame,
-				sizeof(struct msm_cpp_frame_info_t))) {
-					mutex_unlock(&cpp_dev->mutex);
-					return -EINVAL;
-		}
-		kfree(process_frame);
-		kfree(event_qcmd);
-		break;
-	}
-	}
-	mutex_unlock(&cpp_dev->mutex);
-	CPP_DBG("%s: %d\n", __func__, __LINE__);
-	return 0;
-}
-
-int msm_cpp_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
-	struct v4l2_event_subscription *sub)
-{
-	CPP_DBG("%s\n", __func__);
-	return v4l2_event_subscribe(fh, sub, MAX_CPP_V4l2_EVENTS);
-}
-
-int msm_cpp_unsubscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
-	struct v4l2_event_subscription *sub)
-{
-	CPP_DBG("%s\n", __func__);
-	return v4l2_event_unsubscribe(fh, sub);
-}
-
-static struct v4l2_subdev_core_ops msm_cpp_subdev_core_ops = {
-	.ioctl = msm_cpp_subdev_ioctl,
-	.subscribe_event = msm_cpp_subscribe_event,
-	.unsubscribe_event = msm_cpp_unsubscribe_event,
-};
-
-static const struct v4l2_subdev_ops msm_cpp_subdev_ops = {
-	.core = &msm_cpp_subdev_core_ops,
-};
-
-static int msm_cpp_enable_debugfs(struct cpp_device *cpp_dev);
-
-static struct v4l2_file_operations msm_cpp_v4l2_subdev_fops;
-
-static long msm_cpp_subdev_do_ioctl(
-	struct file *file, unsigned int cmd, void *arg)
-{
-	struct video_device *vdev = video_devdata(file);
-	struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
-	struct v4l2_fh *vfh = file->private_data;
-
-	switch (cmd) {
-	case VIDIOC_DQEVENT:
-		if (!(sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS))
-			return -ENOIOCTLCMD;
-
-		return v4l2_event_dequeue(vfh, arg, file->f_flags & O_NONBLOCK);
-
-	case VIDIOC_SUBSCRIBE_EVENT:
-		return v4l2_subdev_call(sd, core, subscribe_event, vfh, arg);
-
-	case VIDIOC_UNSUBSCRIBE_EVENT:
-		return v4l2_subdev_call(sd, core, unsubscribe_event, vfh, arg);
-
-	case VIDIOC_MSM_CPP_GET_INST_INFO: {
-		uint32_t i;
-		struct cpp_device *cpp_dev = v4l2_get_subdevdata(sd);
-		struct msm_camera_v4l2_ioctl_t *ioctl_ptr = arg;
-		struct msm_cpp_frame_info_t inst_info;
-		for (i = 0; i < MAX_ACTIVE_CPP_INSTANCE; i++) {
-			if (cpp_dev->cpp_subscribe_list[i].vfh == vfh) {
-				inst_info.inst_id = i;
-				break;
-			}
-		}
-		if (copy_to_user(
-				(void __user *)ioctl_ptr->ioctl_ptr, &inst_info,
-				sizeof(struct msm_cpp_frame_info_t))) {
-			return -EINVAL;
-		}
-	}
-	break;
-	default:
-		return v4l2_subdev_call(sd, core, ioctl, cmd, arg);
-	}
-
-	return 0;
-}
-
-static long msm_cpp_subdev_fops_ioctl(struct file *file, unsigned int cmd,
-	unsigned long arg)
-{
-	return video_usercopy(file, cmd, arg, msm_cpp_subdev_do_ioctl);
-}
-
-static int __devinit cpp_probe(struct platform_device *pdev)
-{
-	struct cpp_device *cpp_dev;
-	struct msm_cam_subdev_info sd_info;
-	int rc = 0;
-	CDBG("%s: device id = %d\n", __func__, pdev->id);
-	cpp_dev = kzalloc(sizeof(struct cpp_device), GFP_KERNEL);
-	if (!cpp_dev) {
-		pr_err("%s: no enough memory\n", __func__);
-		return -ENOMEM;
-	}
-	v4l2_subdev_init(&cpp_dev->subdev, &msm_cpp_subdev_ops);
-	cpp_dev->subdev.internal_ops = &msm_cpp_internal_ops;
-	snprintf(cpp_dev->subdev.name, ARRAY_SIZE(cpp_dev->subdev.name),
-		 "cpp");
-	cpp_dev->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	cpp_dev->subdev.flags |= V4L2_SUBDEV_FL_HAS_EVENTS;
-	v4l2_set_subdevdata(&cpp_dev->subdev, cpp_dev);
-	platform_set_drvdata(pdev, &cpp_dev->subdev);
-	mutex_init(&cpp_dev->mutex);
-
-	cpp_dev->pdev = pdev;
-
-	media_entity_init(&cpp_dev->subdev.entity, 0, NULL, 0);
-	cpp_dev->subdev.entity.type = MEDIA_ENT_T_DEVNODE_V4L;
-	cpp_dev->subdev.entity.group_id = CPP_DEV;
-	cpp_dev->subdev.entity.name = pdev->name;
-	sd_info.sdev_type = CPP_DEV;
-	sd_info.sd_index = pdev->id;
-	msm_cam_register_subdev_node(&cpp_dev->subdev, &sd_info);
-	msm_cpp_v4l2_subdev_fops.owner = v4l2_subdev_fops.owner;
-	msm_cpp_v4l2_subdev_fops.open = v4l2_subdev_fops.open;
-	msm_cpp_v4l2_subdev_fops.unlocked_ioctl = msm_cpp_subdev_fops_ioctl;
-	msm_cpp_v4l2_subdev_fops.release = v4l2_subdev_fops.release;
-	msm_cpp_v4l2_subdev_fops.poll = v4l2_subdev_fops.poll;
-
-	cpp_dev->subdev.devnode->fops = &msm_cpp_v4l2_subdev_fops;
-	cpp_dev->subdev.entity.revision = cpp_dev->subdev.devnode->num;
-	msm_cpp_enable_debugfs(cpp_dev);
-	msm_queue_init(&cpp_dev->eventData_q, "eventdata");
-	msm_queue_init(&cpp_dev->offline_q, "frame");
-	msm_queue_init(&cpp_dev->realtime_q, "frame");
-	msm_queue_init(&cpp_dev->processing_q, "frame");
-	cpp_dev->cpp_open_cnt = 0;
-
-	return rc;
-}
-
-static struct platform_driver cpp_driver = {
-	.probe = cpp_probe,
-	.driver = {
-		.name = MSM_CPP_DRV_NAME,
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init msm_cpp_init_module(void)
-{
-	return platform_driver_register(&cpp_driver);
-}
-
-static void __exit msm_cpp_exit_module(void)
-{
-	platform_driver_unregister(&cpp_driver);
-}
-
-static int msm_cpp_debugfs_stream_s(void *data, u64 val)
-{
-	struct cpp_device *cpp_dev = data;
-	CPP_DBG("CPP processing frame E\n");
-	while (1) {
-		mutex_lock(&cpp_dev->mutex);
-		msm_cpp_notify_frame_done(cpp_dev);
-		msm_cpp_send_frame_to_hardware(cpp_dev);
-		mutex_unlock(&cpp_dev->mutex);
-		msleep(20);
-	}
-	CPP_DBG("CPP processing frame X\n");
-	return 0;
-}
-
-DEFINE_SIMPLE_ATTRIBUTE(cpp_debugfs_stream, NULL,
-			msm_cpp_debugfs_stream_s, "%llu\n");
-
-static int msm_cpp_enable_debugfs(struct cpp_device *cpp_dev)
-{
-	struct dentry *debugfs_base;
-	debugfs_base = debugfs_create_dir("msm_camera", NULL);
-	if (!debugfs_base)
-		return -ENOMEM;
-
-	if (!debugfs_create_file("test", S_IRUGO | S_IWUSR, debugfs_base,
-			(void *)cpp_dev, &cpp_debugfs_stream))
-		return -ENOMEM;
-
-	return 0;
-}
-
-module_init(msm_cpp_init_module);
-module_exit(msm_cpp_exit_module);
-MODULE_DESCRIPTION("MSM CPP driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/cpp/msm_cpp.h b/drivers/media/platform/msm/camera_v1/cpp/msm_cpp.h
deleted file mode 100644
index f585569..0000000
--- a/drivers/media/platform/msm/camera_v1/cpp/msm_cpp.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <linux/list.h>
-#include <media/v4l2-subdev.h>
-
-#define MAX_ACTIVE_CPP_INSTANCE 8
-#define MAX_CPP_PROCESSING_FRAME 2
-#define MAX_CPP_V4l2_EVENTS 30
-
-#define MSM_CPP_MICRO_BASE          0x4000
-#define MSM_CPP_MICRO_HW_VERSION    0x0000
-#define MSM_CPP_MICRO_IRQGEN_STAT   0x0004
-#define MSM_CPP_MICRO_IRQGEN_CLR    0x0008
-#define MSM_CPP_MICRO_IRQGEN_MASK   0x000C
-#define MSM_CPP_MICRO_FIFO_TX_DATA  0x0010
-#define MSM_CPP_MICRO_FIFO_TX_STAT  0x0014
-#define MSM_CPP_MICRO_FIFO_RX_DATA  0x0018
-#define MSM_CPP_MICRO_FIFO_RX_STAT  0x001C
-#define MSM_CPP_MICRO_BOOT_START    0x0020
-#define MSM_CPP_MICRO_BOOT_LDORG    0x0024
-#define MSM_CPP_MICRO_CLKEN_CTL     0x0030
-
-struct cpp_subscribe_info {
-	struct v4l2_fh *vfh;
-	uint32_t active;
-};
-
-struct cpp_device {
-	struct platform_device *pdev;
-	struct v4l2_subdev subdev;
-	struct resource *mem;
-	struct resource *irq;
-	struct resource *io;
-	void __iomem *base;
-	struct clk *cpp_clk[2];
-	struct mutex mutex;
-
-	struct cpp_subscribe_info cpp_subscribe_list[MAX_ACTIVE_CPP_INSTANCE];
-	uint32_t cpp_open_cnt;
-
-	struct msm_device_queue eventData_q; /*V4L2 Event Payload Queue*/
-
-	/*Offline Frame Queue
-	  process when realtime queue is empty*/
-	struct msm_device_queue offline_q;
-	/*Realtime Frame Queue
-	  process with highest priority*/
-	struct msm_device_queue realtime_q;
-	/*Processing Queue
-	  store frame info for frames sent to microcontroller*/
-	struct msm_device_queue processing_q;
-};
-
diff --git a/drivers/media/platform/msm/camera_v1/csi/Makefile b/drivers/media/platform/msm/camera_v1/csi/Makefile
deleted file mode 100644
index 6284511..0000000
--- a/drivers/media/platform/msm/camera_v1/csi/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-GCC_VERSION      := $(shell $(CONFIG_SHELL) $(PWD)/scripts/gcc-version.sh $(CROSS_COMPILE)gcc)
-ccflags-y += -Idrivers/media/platform/msm/camera_v1 -Idrivers/media/platform/msm/camera_v1/server
-ifeq ($(CONFIG_MSM_CSI20_HEADER),y)
-  ccflags-y += -Idrivers/media/platform/msm/camera_v1/csi/include/csi2.0
-else ifeq ($(CONFIG_MSM_CSI30_HEADER),y)
-  ccflags-y += -Idrivers/media/platform/msm/camera_v1/csi/include/csi3.0
-endif
-obj-$(CONFIG_MSM_CSI2_REGISTER) += msm_csi2_register.o
-obj-$(CONFIG_MSM_CSIPHY) += msm_csiphy.o
-obj-$(CONFIG_MSM_CSID) += msm_csid.o
-obj-$(CONFIG_MSM_ISPIF) += msm_ispif.o
-obj-$(CONFIG_ARCH_MSM8960) += msm_csi2_register.o msm_csiphy.o msm_csid.o msm_ispif.o
-obj-$(CONFIG_ARCH_MSM7X27A) += msm_csic_register.o msm_csic.o
-obj-$(CONFIG_ARCH_MSM8X60) += msm_csic_register.o msm_csic.o
-obj-$(CONFIG_ARCH_MSM7X30) += msm_csic_register.o msm_csic.o
diff --git a/drivers/media/platform/msm/camera_v1/csi/include/csi2.0/msm_csid_hwreg.h b/drivers/media/platform/msm/camera_v1/csi/include/csi2.0/msm_csid_hwreg.h
deleted file mode 100644
index cc8a9cf..0000000
--- a/drivers/media/platform/msm/camera_v1/csi/include/csi2.0/msm_csid_hwreg.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#ifndef MSM_CSID_HWREG_H
-#define MSM_CSID_HWREG_H
-
-/* MIPI	CSID registers */
-#define CSID_HW_VERSION_ADDR                        0x0
-#define CSID_CORE_CTRL_0_ADDR                       0x4
-#define CSID_CORE_CTRL_1_ADDR                       0x4
-#define CSID_RST_CMD_ADDR                           0x8
-#define CSID_CID_LUT_VC_0_ADDR                      0xc
-#define CSID_CID_LUT_VC_1_ADDR                      0x10
-#define CSID_CID_LUT_VC_2_ADDR                      0x14
-#define CSID_CID_LUT_VC_3_ADDR                      0x18
-#define CSID_CID_n_CFG_ADDR                         0x1C
-#define CSID_IRQ_CLEAR_CMD_ADDR                     0x5c
-#define CSID_IRQ_MASK_ADDR                          0x60
-#define CSID_IRQ_STATUS_ADDR                        0x64
-#define CSID_CAPTURED_UNMAPPED_LONG_PKT_HDR_ADDR    0x68
-#define CSID_CAPTURED_MMAPPED_LONG_PKT_HDR_ADDR     0x6c
-#define CSID_CAPTURED_SHORT_PKT_ADDR                0x70
-#define CSID_CAPTURED_LONG_PKT_HDR_ADDR             0x74
-#define CSID_CAPTURED_LONG_PKT_FTR_ADDR             0x78
-#define CSID_PIF_MISR_DL0_ADDR                      0x7C
-#define CSID_PIF_MISR_DL1_ADDR                      0x80
-#define CSID_PIF_MISR_DL2_ADDR                      0x84
-#define CSID_PIF_MISR_DL3_ADDR                      0x88
-#define CSID_STATS_TOTAL_PKTS_RCVD_ADDR             0x8C
-#define CSID_STATS_ECC_ADDR                         0x90
-#define CSID_STATS_CRC_ADDR                         0x94
-#define CSID_TG_CTRL_ADDR                           0x9C
-#define CSID_TG_VC_CFG_ADDR                         0xA0
-#define CSID_TG_DT_n_CFG_0_ADDR                     0xA8
-#define CSID_TG_DT_n_CFG_1_ADDR                     0xAC
-#define CSID_TG_DT_n_CFG_2_ADDR                     0xB0
-#define CSID_RST_DONE_IRQ_BITSHIFT                  11
-#define CSID_RST_STB_ALL                            0x7FFF
-#define CSID_DL_INPUT_SEL_SHIFT                     0x2
-#define CSID_PHY_SEL_SHIFT                          17
-#define CSID_VERSION                                0x02000011
-
-#endif
diff --git a/drivers/media/platform/msm/camera_v1/csi/include/csi2.0/msm_csiphy_hwreg.h b/drivers/media/platform/msm/camera_v1/csi/include/csi2.0/msm_csiphy_hwreg.h
deleted file mode 100644
index 9263483..0000000
--- a/drivers/media/platform/msm/camera_v1/csi/include/csi2.0/msm_csiphy_hwreg.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#ifndef MSM_CSIPHY_HWREG_H
-#define MSM_CSIPHY_HWREG_H
-
-/*MIPI CSI PHY registers*/
-#define MIPI_CSIPHY_HW_VERSION_ADDR              0x180
-#define MIPI_CSIPHY_LNn_CFG1_ADDR                0x0
-#define MIPI_CSIPHY_LNn_CFG2_ADDR                0x4
-#define MIPI_CSIPHY_LNn_CFG3_ADDR                0x8
-#define MIPI_CSIPHY_LNn_CFG4_ADDR                0xC
-#define MIPI_CSIPHY_LNn_CFG5_ADDR                0x10
-#define MIPI_CSIPHY_LNCK_CFG1_ADDR               0x100
-#define MIPI_CSIPHY_LNCK_CFG2_ADDR               0x104
-#define MIPI_CSIPHY_LNCK_CFG3_ADDR               0x108
-#define MIPI_CSIPHY_LNCK_CFG4_ADDR               0x10C
-#define MIPI_CSIPHY_LNCK_CFG5_ADDR               0x110
-#define MIPI_CSIPHY_LNCK_MISC1_ADDR              0x128
-#define MIPI_CSIPHY_GLBL_RESET_ADDR              0x140
-#define MIPI_CSIPHY_GLBL_PWR_CFG_ADDR            0x144
-#define MIPI_CSIPHY_GLBL_IRQ_CMD_ADDR            0x164
-#define MIPI_CSIPHY_INTERRUPT_STATUS0_ADDR       0x180
-#define MIPI_CSIPHY_INTERRUPT_MASK0_ADDR         0x1A0
-#define MIPI_CSIPHY_INTERRUPT_MASK_VAL           0x6F
-#define MIPI_CSIPHY_INTERRUPT_MASK_ADDR          0x1A4
-#define MIPI_CSIPHY_INTERRUPT_CLEAR0_ADDR        0x1C0
-#define MIPI_CSIPHY_INTERRUPT_CLEAR_ADDR         0x1C4
-#define MIPI_CSIPHY_MODE_CONFIG_SHIFT            0x4
-#define MIPI_CSIPHY_GLBL_T_INIT_CFG0_ADDR        0x1E0
-#define MIPI_CSIPHY_T_WAKEUP_CFG0_ADDR           0x1E8
-#define CSIPHY_VERSION                           0x0
-
-#endif
diff --git a/drivers/media/platform/msm/camera_v1/csi/include/csi2.0/msm_ispif_hwreg.h b/drivers/media/platform/msm/camera_v1/csi/include/csi2.0/msm_ispif_hwreg.h
deleted file mode 100644
index 1864d40..0000000
--- a/drivers/media/platform/msm/camera_v1/csi/include/csi2.0/msm_ispif_hwreg.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#ifndef MSM_ISPIF_HWREG_H
-#define MSM_ISPIF_HWREG_H
-
-
-/* ISPIF registers */
-
-#define ISPIF_RST_CMD_ADDR                        0x00
-#define ISPIF_RST_CMD_1_ADDR                      0x00
-#define ISPIF_INTF_CMD_ADDR                       0x04
-#define ISPIF_INTF_CMD_1_ADDR                     0x30
-#define ISPIF_CTRL_ADDR                           0x08
-#define ISPIF_INPUT_SEL_ADDR                      0x0C
-#define ISPIF_PIX_0_INTF_CID_MASK_ADDR            0x10
-#define ISPIF_RDI_0_INTF_CID_MASK_ADDR            0x14
-#define ISPIF_PIX_1_INTF_CID_MASK_ADDR            0x38
-#define ISPIF_RDI_1_INTF_CID_MASK_ADDR            0x3C
-#define ISPIF_RDI_2_INTF_CID_MASK_ADDR            0x44
-#define ISPIF_PIX_0_STATUS_ADDR                   0x24
-#define ISPIF_RDI_0_STATUS_ADDR                   0x28
-#define ISPIF_PIX_1_STATUS_ADDR                   0x60
-#define ISPIF_RDI_1_STATUS_ADDR                   0x64
-#define ISPIF_RDI_2_STATUS_ADDR                   0x6C
-#define ISPIF_IRQ_MASK_ADDR                     0x0100
-#define ISPIF_IRQ_CLEAR_ADDR                    0x0104
-#define ISPIF_IRQ_STATUS_ADDR                   0x0108
-#define ISPIF_IRQ_MASK_1_ADDR                   0x010C
-#define ISPIF_IRQ_CLEAR_1_ADDR                  0x0110
-#define ISPIF_IRQ_STATUS_1_ADDR                 0x0114
-#define ISPIF_IRQ_MASK_2_ADDR                   0x0118
-#define ISPIF_IRQ_CLEAR_2_ADDR                  0x011C
-#define ISPIF_IRQ_STATUS_2_ADDR                 0x0120
-#define ISPIF_IRQ_GLOBAL_CLEAR_CMD_ADDR         0x0124
-
-/*ISPIF RESET BITS*/
-
-#define VFE_CLK_DOMAIN_RST           31
-#define RDI_CLK_DOMAIN_RST           30
-#define PIX_CLK_DOMAIN_RST           29
-#define AHB_CLK_DOMAIN_RST           28
-#define RDI_1_CLK_DOMAIN_RST         27
-#define RDI_2_VFE_RST_STB            19
-#define RDI_2_CSID_RST_STB           18
-#define RDI_1_VFE_RST_STB            13
-#define RDI_1_CSID_RST_STB           12
-#define RDI_0_VFE_RST_STB            7
-#define RDI_0_CSID_RST_STB           6
-#define PIX_1_VFE_RST_STB            10
-#define PIX_1_CSID_RST_STB           9
-#define PIX_0_VFE_RST_STB            4
-#define PIX_0_CSID_RST_STB           3
-#define SW_REG_RST_STB               2
-#define MISC_LOGIC_RST_STB           1
-#define STROBED_RST_EN               0
-
-#define ISPIF_RST_CMD_MASK           0xFE0F1FFF
-#define ISPIF_RST_CMD_1_MASK         0xFC0F1FF9
-
-#define PIX_INTF_0_OVERFLOW_IRQ      12
-#define RAW_INTF_0_OVERFLOW_IRQ      25
-#define RAW_INTF_1_OVERFLOW_IRQ      25
-#define RAW_INTF_2_OVERFLOW_IRQ      12
-#define RESET_DONE_IRQ               27
-
-#define ISPIF_IRQ_STATUS_MASK        0x0A493249
-#define ISPIF_IRQ_STATUS_1_MASK      0x02493249
-#define ISPIF_IRQ_STATUS_2_MASK      0x00001249
-
-#define ISPIF_IRQ_STATUS_PIX_SOF_MASK	0x249
-#define ISPIF_IRQ_STATUS_RDI0_SOF_MASK	0x492000
-#define ISPIF_IRQ_STATUS_RDI1_SOF_MASK	0x492000
-#define ISPIF_IRQ_STATUS_RDI2_SOF_MASK	0x249
-
-#define ISPIF_IRQ_STATUS_SOF_MASK	0x492249
-#define ISPIF_IRQ_GLOBAL_CLEAR_CMD     0x1
-
-#endif
diff --git a/drivers/media/platform/msm/camera_v1/csi/include/csi3.0/msm_csid_hwreg.h b/drivers/media/platform/msm/camera_v1/csi/include/csi3.0/msm_csid_hwreg.h
deleted file mode 100644
index 7f35c2c..0000000
--- a/drivers/media/platform/msm/camera_v1/csi/include/csi3.0/msm_csid_hwreg.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#ifndef MSM_CSID_HWREG_H
-#define MSM_CSID_HWREG_H
-
-/* MIPI	CSID registers */
-#define CSID_HW_VERSION_ADDR                        0x0
-#define CSID_CORE_CTRL_0_ADDR                       0x4
-#define CSID_CORE_CTRL_1_ADDR                       0x8
-#define CSID_RST_CMD_ADDR                           0xC
-#define CSID_CID_LUT_VC_0_ADDR                      0x10
-#define CSID_CID_LUT_VC_1_ADDR                      0x14
-#define CSID_CID_LUT_VC_2_ADDR                      0x18
-#define CSID_CID_LUT_VC_3_ADDR                      0x1C
-#define CSID_CID_n_CFG_ADDR                         0x20
-#define CSID_IRQ_CLEAR_CMD_ADDR                     0x60
-#define CSID_IRQ_MASK_ADDR                          0x64
-#define CSID_IRQ_STATUS_ADDR                        0x68
-#define CSID_CAPTURED_UNMAPPED_LONG_PKT_HDR_ADDR    0x6C
-#define CSID_CAPTURED_MMAPPED_LONG_PKT_HDR_ADDR     0x70
-#define CSID_CAPTURED_SHORT_PKT_ADDR                0x74
-#define CSID_CAPTURED_LONG_PKT_HDR_ADDR             0x78
-#define CSID_CAPTURED_LONG_PKT_FTR_ADDR             0x7C
-#define CSID_PIF_MISR_DL0_ADDR                      0x80
-#define CSID_PIF_MISR_DL1_ADDR                      0x84
-#define CSID_PIF_MISR_DL2_ADDR                      0x88
-#define CSID_PIF_MISR_DL3_ADDR                      0x8C
-#define CSID_STATS_TOTAL_PKTS_RCVD_ADDR             0x90
-#define CSID_STATS_ECC_ADDR                         0x94
-#define CSID_STATS_CRC_ADDR                         0x98
-#define CSID_TG_CTRL_ADDR                           0xA0
-#define CSID_TG_VC_CFG_ADDR                         0xA4
-#define CSID_TG_DT_n_CFG_0_ADDR                     0xAC
-#define CSID_TG_DT_n_CFG_1_ADDR                     0xB0
-#define CSID_TG_DT_n_CFG_2_ADDR                     0xB4
-#define CSID_RST_DONE_IRQ_BITSHIFT                  11
-#define CSID_RST_STB_ALL                            0x7FFF
-#define CSID_DL_INPUT_SEL_SHIFT                     0x4
-#define CSID_PHY_SEL_SHIFT                          17
-#define CSID_VERSION                                0x30000000
-
-#endif
diff --git a/drivers/media/platform/msm/camera_v1/csi/include/csi3.0/msm_csiphy_hwreg.h b/drivers/media/platform/msm/camera_v1/csi/include/csi3.0/msm_csiphy_hwreg.h
deleted file mode 100644
index c290731..0000000
--- a/drivers/media/platform/msm/camera_v1/csi/include/csi3.0/msm_csiphy_hwreg.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#ifndef MSM_CSIPHY_HWREG_H
-#define MSM_CSIPHY_HWREG_H
-
-/*MIPI CSI PHY registers*/
-#define MIPI_CSIPHY_LNn_CFG1_ADDR                0x0
-#define MIPI_CSIPHY_LNn_CFG2_ADDR                0x4
-#define MIPI_CSIPHY_LNn_CFG3_ADDR                0x8
-#define MIPI_CSIPHY_LNn_CFG4_ADDR                0xC
-#define MIPI_CSIPHY_LNn_CFG5_ADDR                0x10
-#define MIPI_CSIPHY_LNCK_CFG1_ADDR               0x100
-#define MIPI_CSIPHY_LNCK_CFG2_ADDR               0x104
-#define MIPI_CSIPHY_LNCK_CFG3_ADDR               0x108
-#define MIPI_CSIPHY_LNCK_CFG4_ADDR               0x10C
-#define MIPI_CSIPHY_LNCK_CFG5_ADDR               0x110
-#define MIPI_CSIPHY_LNCK_MISC1_ADDR              0x128
-#define MIPI_CSIPHY_GLBL_RESET_ADDR              0x140
-#define MIPI_CSIPHY_GLBL_PWR_CFG_ADDR            0x144
-#define MIPI_CSIPHY_GLBL_IRQ_CMD_ADDR            0x164
-#define MIPI_CSIPHY_HW_VERSION_ADDR              0x188
-#define MIPI_CSIPHY_INTERRUPT_STATUS0_ADDR       0x18C
-#define MIPI_CSIPHY_INTERRUPT_MASK0_ADDR         0x1AC
-#define MIPI_CSIPHY_INTERRUPT_MASK_VAL           0x3F
-#define MIPI_CSIPHY_INTERRUPT_MASK_ADDR          0x1AC
-#define MIPI_CSIPHY_INTERRUPT_CLEAR0_ADDR        0x1CC
-#define MIPI_CSIPHY_INTERRUPT_CLEAR_ADDR         0x1CC
-#define MIPI_CSIPHY_MODE_CONFIG_SHIFT            0x4
-#define MIPI_CSIPHY_GLBL_T_INIT_CFG0_ADDR        0x1EC
-#define MIPI_CSIPHY_T_WAKEUP_CFG0_ADDR           0x1F4
-#define CSIPHY_VERSION                           0x10
-
-#endif
diff --git a/drivers/media/platform/msm/camera_v1/csi/include/csi3.0/msm_ispif_hwreg.h b/drivers/media/platform/msm/camera_v1/csi/include/csi3.0/msm_ispif_hwreg.h
deleted file mode 100644
index 4b69dda..0000000
--- a/drivers/media/platform/msm/camera_v1/csi/include/csi3.0/msm_ispif_hwreg.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#ifndef MSM_ISPIF_HWREG_H
-#define MSM_ISPIF_HWREG_H
-
-
-/* ISPIF registers */
-
-#define ISPIF_RST_CMD_ADDR                        0x08
-#define ISPIF_RST_CMD_1_ADDR                      0x0C
-#define ISPIF_INTF_CMD_ADDR                      0x248
-#define ISPIF_INTF_CMD_1_ADDR                    0x24C
-#define ISPIF_CTRL_ADDR                           0x08
-#define ISPIF_INPUT_SEL_ADDR                     0x244
-#define ISPIF_PIX_0_INTF_CID_MASK_ADDR           0x254
-#define ISPIF_RDI_0_INTF_CID_MASK_ADDR           0x264
-#define ISPIF_PIX_1_INTF_CID_MASK_ADDR           0x258
-#define ISPIF_RDI_1_INTF_CID_MASK_ADDR           0x268
-#define ISPIF_RDI_2_INTF_CID_MASK_ADDR           0x26C
-#define ISPIF_PIX_0_STATUS_ADDR                  0x2C0
-#define ISPIF_RDI_0_STATUS_ADDR                  0x2D0
-#define ISPIF_PIX_1_STATUS_ADDR                  0x2C4
-#define ISPIF_RDI_1_STATUS_ADDR                  0x2D4
-#define ISPIF_RDI_2_STATUS_ADDR                  0x2D8
-#define ISPIF_IRQ_MASK_ADDR                      0x208
-#define ISPIF_IRQ_CLEAR_ADDR                     0x230
-#define ISPIF_IRQ_STATUS_ADDR                    0x21C
-#define ISPIF_IRQ_MASK_1_ADDR                    0x20C
-#define ISPIF_IRQ_CLEAR_1_ADDR                   0x234
-#define ISPIF_IRQ_STATUS_1_ADDR                  0x220
-#define ISPIF_IRQ_MASK_2_ADDR                    0x210
-#define ISPIF_IRQ_CLEAR_2_ADDR                   0x238
-#define ISPIF_IRQ_STATUS_2_ADDR                  0x224
-#define ISPIF_IRQ_GLOBAL_CLEAR_CMD_ADDR           0x1C
-
-/* new */
-#define ISPIF_VFE_m_CTRL_0_ADDR                  0x200
-#define ISPIF_VFE_m_IRQ_MASK_0                   0x208
-#define ISPIF_VFE_m_IRQ_MASK_1                   0x20C
-#define ISPIF_VFE_m_IRQ_MASK_2                   0x210
-#define ISPIF_VFE_m_IRQ_STATUS_0                 0x21C
-#define ISPIF_VFE_m_IRQ_STATUS_1                 0x220
-#define ISPIF_VFE_m_IRQ_STATUS_2                 0x224
-#define ISPIF_VFE_m_IRQ_CLEAR_0                  0x230
-#define ISPIF_VFE_m_IRQ_CLEAR_1                  0x234
-#define ISPIF_VFE_m_IRQ_CLEAR_2                  0x238
-
-/*ISPIF RESET BITS*/
-
-#define VFE_CLK_DOMAIN_RST           31
-#define RDI_CLK_DOMAIN_RST           26
-#define RDI_1_CLK_DOMAIN_RST         27
-#define RDI_2_CLK_DOMAIN_RST         28
-#define PIX_CLK_DOMAIN_RST           29
-#define PIX_1_CLK_DOMAIN_RST         30
-#define AHB_CLK_DOMAIN_RST           25
-#define RDI_2_VFE_RST_STB            12
-#define RDI_2_CSID_RST_STB           11
-#define RDI_1_VFE_RST_STB            10
-#define RDI_1_CSID_RST_STB           9
-#define RDI_0_VFE_RST_STB            8
-#define RDI_0_CSID_RST_STB           7
-#define PIX_1_VFE_RST_STB            6
-#define PIX_1_CSID_RST_STB           5
-#define PIX_0_VFE_RST_STB            4
-#define PIX_0_CSID_RST_STB           3
-#define SW_REG_RST_STB               2
-#define MISC_LOGIC_RST_STB           1
-#define STROBED_RST_EN               0
-
-#define ISPIF_RST_CMD_MASK           0xFE0F1FFF
-#define ISPIF_RST_CMD_1_MASK         0xFC0F1FF9
-
-#define PIX_INTF_0_OVERFLOW_IRQ      12
-#define RAW_INTF_0_OVERFLOW_IRQ      25
-#define RAW_INTF_1_OVERFLOW_IRQ      25
-#define RAW_INTF_2_OVERFLOW_IRQ      12
-#define RESET_DONE_IRQ               27
-
-#define ISPIF_IRQ_STATUS_MASK        0x0A493249
-#define ISPIF_IRQ_STATUS_1_MASK      0x02493249
-#define ISPIF_IRQ_STATUS_2_MASK      0x00001249
-
-#define ISPIF_IRQ_STATUS_PIX_SOF_MASK	0x249
-#define ISPIF_IRQ_STATUS_RDI0_SOF_MASK	0x492000
-#define ISPIF_IRQ_STATUS_RDI1_SOF_MASK	0x492000
-#define ISPIF_IRQ_STATUS_RDI2_SOF_MASK	0x249
-
-#define ISPIF_IRQ_STATUS_SOF_MASK	0x492249
-#define ISPIF_IRQ_GLOBAL_CLEAR_CMD     0x1
-
-#endif
diff --git a/drivers/media/platform/msm/camera_v1/csi/msm_csi2_register.c b/drivers/media/platform/msm/camera_v1/csi/msm_csi2_register.c
deleted file mode 100644
index cebfa7f..0000000
--- a/drivers/media/platform/msm/camera_v1/csi/msm_csi2_register.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/device.h>
-#include "msm.h"
-#include "msm_csi_register.h"
-
-int msm_csi_register_subdevs(struct msm_cam_media_controller *p_mctl,
-	uint8_t csiphy_code_index, uint8_t csid_core_index,
-	struct msm_cam_server_dev *server_dev)
-{
-	int rc = -ENODEV;
-
-	CDBG("%s csiphy sel %d csid sel %d\n", __func__, csiphy_code_index,
-		csid_core_index);
-	/* register csiphy subdev */
-	p_mctl->csiphy_sdev = server_dev->csiphy_device[csiphy_code_index];
-	if (!p_mctl->csiphy_sdev)
-		goto out;
-	v4l2_set_subdev_hostdata(p_mctl->csiphy_sdev, p_mctl);
-
-	/* register csid subdev */
-	p_mctl->csid_sdev = server_dev->csid_device[csid_core_index];
-	if (!p_mctl->csid_sdev)
-		goto out;
-	v4l2_set_subdev_hostdata(p_mctl->csid_sdev, p_mctl);
-
-	/* register ispif subdev */
-	p_mctl->ispif_sdev = server_dev->ispif_device[0];
-	if (!p_mctl->ispif_sdev)
-		goto out;
-	v4l2_set_subdev_hostdata(p_mctl->ispif_sdev, p_mctl);
-
-	rc = 0;
-	return rc;
-out:
-	p_mctl->ispif_sdev = NULL;
-	return rc;
-}
-
diff --git a/drivers/media/platform/msm/camera_v1/csi/msm_csi_register.h b/drivers/media/platform/msm/camera_v1/csi/msm_csi_register.h
deleted file mode 100644
index b276267..0000000
--- a/drivers/media/platform/msm/camera_v1/csi/msm_csi_register.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- *
- */
-
-int msm_csi_register_subdevs(struct msm_cam_media_controller *p_mctl,
-	uint8_t csiphy_code_index, uint8_t csid_core_index,
-	struct msm_cam_server_dev *server_dev);
diff --git a/drivers/media/platform/msm/camera_v1/csi/msm_csic.c b/drivers/media/platform/msm/camera_v1/csi/msm_csic.c
deleted file mode 100644
index 34489cb..0000000
--- a/drivers/media/platform/msm/camera_v1/csi/msm_csic.c
+++ /dev/null
@@ -1,523 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#include <linux/delay.h>
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <linux/module.h>
-#include <mach/clk.h>
-#include <mach/board.h>
-#include <mach/camera.h>
-#include <media/msm_isp.h>
-#include "msm_csic.h"
-#include "msm.h"
-
-#define DBG_CSIC 0
-
-#define V4L2_IDENT_CSIC			50004
-/* MIPI	CSI controller registers */
-#define	MIPI_PHY_CONTROL		0x00000000
-#define	MIPI_PROTOCOL_CONTROL		0x00000004
-#define	MIPI_INTERRUPT_STATUS		0x00000008
-#define	MIPI_INTERRUPT_MASK		0x0000000C
-#define	MIPI_CAMERA_CNTL		0x00000024
-#define	MIPI_CALIBRATION_CONTROL	0x00000018
-#define	MIPI_PHY_D0_CONTROL2		0x00000038
-#define	MIPI_PHY_D1_CONTROL2		0x0000003C
-#define	MIPI_PHY_D2_CONTROL2		0x00000040
-#define	MIPI_PHY_D3_CONTROL2		0x00000044
-#define	MIPI_PHY_CL_CONTROL		0x00000048
-#define	MIPI_PHY_D0_CONTROL		0x00000034
-#define	MIPI_PHY_D1_CONTROL		0x00000020
-#define	MIPI_PHY_D2_CONTROL		0x0000002C
-#define	MIPI_PHY_D3_CONTROL		0x00000030
-#define	MIPI_PWR_CNTL			0x00000054
-
-/*
- * MIPI_PROTOCOL_CONTROL register bits to enable/disable the features of
- * CSI Rx Block
- */
-
-/* DPCM scheme */
-#define	MIPI_PROTOCOL_CONTROL_DPCM_SCHEME_SHFT			0x1e
-/* SW_RST to issue a SW reset to the CSI core */
-#define	MIPI_PROTOCOL_CONTROL_SW_RST_BMSK			0x8000000
-/* To Capture Long packet Header Info in MIPI_PROTOCOL_STATUS register */
-#define	MIPI_PROTOCOL_CONTROL_LONG_PACKET_HEADER_CAPTURE_BMSK	0x200000
-/* Data format for unpacking purpose */
-#define	MIPI_PROTOCOL_CONTROL_DATA_FORMAT_SHFT			0x13
-/* Enable decoding of payload based on data type filed of packet hdr */
-#define	MIPI_PROTOCOL_CONTROL_DECODE_ID_BMSK			0x40000
-/* Enable error correction on packet headers */
-#define	MIPI_PROTOCOL_CONTROL_ECC_EN_BMSK			0x20000
-
-/*
- * MIPI_CALIBRATION_CONTROL register contains control info for
- * calibration impledence controller
-*/
-
-/* Enable bit for calibration pad */
-#define	MIPI_CALIBRATION_CONTROL_SWCAL_CAL_EN_SHFT		0x16
-/* With SWCAL_STRENGTH_OVERRIDE_EN, SW_CAL_EN and MANUAL_OVERRIDE_EN
- * the hardware calibration circuitry associated with CAL_SW_HW_MODE
- * is bypassed
-*/
-#define	MIPI_CALIBRATION_CONTROL_SWCAL_STRENGTH_OVERRIDE_EN_SHFT	0x15
-/* To indicate the Calibration process is in the control of HW/SW */
-#define	MIPI_CALIBRATION_CONTROL_CAL_SW_HW_MODE_SHFT		0x14
-/* When this is set the strength value of the data and clk lane impedence
- * termination is updated with MANUAL_STRENGTH settings and calibration
- * sensing logic is idle.
-*/
-#define	MIPI_CALIBRATION_CONTROL_MANUAL_OVERRIDE_EN_SHFT	0x7
-
-/* Data lane0 control */
-/* T-hs Settle count value  for Rx */
-#define	MIPI_PHY_D0_CONTROL2_SETTLE_COUNT_SHFT			0x18
-/* Rx termination control */
-#define	MIPI_PHY_D0_CONTROL2_HS_TERM_IMP_SHFT			0x10
-/* LP Rx enable */
-#define	MIPI_PHY_D0_CONTROL2_LP_REC_EN_SHFT			0x4
-/*
- * Enable for error in sync sequence
- * 1 - one bit error in sync seq
- * 0 - requires all 8 bit correct seq
-*/
-#define	MIPI_PHY_D0_CONTROL2_ERR_SOT_HS_EN_SHFT			0x3
-
-/* Comments are same as D0 */
-#define	MIPI_PHY_D1_CONTROL2_SETTLE_COUNT_SHFT			0x18
-#define	MIPI_PHY_D1_CONTROL2_HS_TERM_IMP_SHFT			0x10
-#define	MIPI_PHY_D1_CONTROL2_LP_REC_EN_SHFT			0x4
-#define	MIPI_PHY_D1_CONTROL2_ERR_SOT_HS_EN_SHFT			0x3
-
-/* Comments are same as D0 */
-#define	MIPI_PHY_D2_CONTROL2_SETTLE_COUNT_SHFT			0x18
-#define	MIPI_PHY_D2_CONTROL2_HS_TERM_IMP_SHFT			0x10
-#define	MIPI_PHY_D2_CONTROL2_LP_REC_EN_SHFT			0x4
-#define	MIPI_PHY_D2_CONTROL2_ERR_SOT_HS_EN_SHFT			0x3
-
-/* Comments are same as D0 */
-#define	MIPI_PHY_D3_CONTROL2_SETTLE_COUNT_SHFT			0x18
-#define	MIPI_PHY_D3_CONTROL2_HS_TERM_IMP_SHFT			0x10
-#define	MIPI_PHY_D3_CONTROL2_LP_REC_EN_SHFT			0x4
-#define	MIPI_PHY_D3_CONTROL2_ERR_SOT_HS_EN_SHFT			0x3
-
-/* PHY_CL_CTRL programs the parameters of clk lane of CSIRXPHY */
-/* HS Rx termination control */
-#define	MIPI_PHY_CL_CONTROL_HS_TERM_IMP_SHFT			0x18
-/* Start signal for T-hs delay */
-#define	MIPI_PHY_CL_CONTROL_LP_REC_EN_SHFT			0x2
-
-/* PHY DATA lane 0 control */
-/*
- * HS RX equalizer strength control
- * 00 - 0db 01 - 3db 10 - 5db 11 - 7db
-*/
-#define	MIPI_PHY_D0_CONTROL_HS_REC_EQ_SHFT			0x1c
-/* PHY DATA lane 1 control */
-/* Shutdown signal for MIPI clk phy line */
-#define	MIPI_PHY_D1_CONTROL_MIPI_CLK_PHY_SHUTDOWNB_SHFT		0x9
-/* Shutdown signal for MIPI data phy line */
-#define	MIPI_PHY_D1_CONTROL_MIPI_DATA_PHY_SHUTDOWNB_SHFT	0x8
-
-#define MSM_AXI_QOS_PREVIEW 200000
-#define MSM_AXI_QOS_SNAPSHOT 200000
-#define MSM_AXI_QOS_RECORDING 200000
-
-#define MIPI_PWR_CNTL_EN	0x07
-#define MIPI_PWR_CNTL_DIS	0x0
-
-static int msm_csic_config(struct v4l2_subdev *sd,
-	struct msm_camera_csi_params *csic_params)
-{
-	int rc = 0;
-	uint32_t val = 0;
-	struct csic_device *csic_dev;
-	void __iomem *csicbase;
-	int i;
-
-	csic_dev = v4l2_get_subdevdata(sd);
-	csicbase = csic_dev->base;
-
-	/* Enable error correction for DATA lane. Applies to all data lanes */
-	msm_camera_io_w(0x4, csicbase + MIPI_PHY_CONTROL);
-
-	msm_camera_io_w(MIPI_PROTOCOL_CONTROL_SW_RST_BMSK,
-		csicbase + MIPI_PROTOCOL_CONTROL);
-
-	val = MIPI_PROTOCOL_CONTROL_LONG_PACKET_HEADER_CAPTURE_BMSK |
-		MIPI_PROTOCOL_CONTROL_DECODE_ID_BMSK |
-		MIPI_PROTOCOL_CONTROL_ECC_EN_BMSK;
-	val |= (uint32_t)(csic_params->data_format) <<
-		MIPI_PROTOCOL_CONTROL_DATA_FORMAT_SHFT;
-	val |= csic_params->dpcm_scheme <<
-		MIPI_PROTOCOL_CONTROL_DPCM_SCHEME_SHFT;
-	CDBG("%s MIPI_PROTOCOL_CONTROL val=0x%x\n", __func__, val);
-	msm_camera_io_w(val, csicbase + MIPI_PROTOCOL_CONTROL);
-
-	val = (csic_params->settle_cnt <<
-		MIPI_PHY_D0_CONTROL2_SETTLE_COUNT_SHFT) |
-		(0x0F << MIPI_PHY_D0_CONTROL2_HS_TERM_IMP_SHFT) |
-		(0x1 << MIPI_PHY_D0_CONTROL2_LP_REC_EN_SHFT) |
-		(0x1 << MIPI_PHY_D0_CONTROL2_ERR_SOT_HS_EN_SHFT);
-	CDBG("%s MIPI_PHY_D0_CONTROL2 val=0x%x\n", __func__, val);
-	for (i = 0; i < csic_params->lane_cnt; i++)
-		msm_camera_io_w(val, csicbase + MIPI_PHY_D0_CONTROL2 + i * 4);
-
-
-	val = (0x0F << MIPI_PHY_CL_CONTROL_HS_TERM_IMP_SHFT) |
-		(0x1 << MIPI_PHY_CL_CONTROL_LP_REC_EN_SHFT);
-	CDBG("%s MIPI_PHY_CL_CONTROL val=0x%x\n", __func__, val);
-	msm_camera_io_w(val, csicbase + MIPI_PHY_CL_CONTROL);
-
-	val = 0 << MIPI_PHY_D0_CONTROL_HS_REC_EQ_SHFT;
-	msm_camera_io_w(val, csicbase + MIPI_PHY_D0_CONTROL);
-
-	val = (0x1 << MIPI_PHY_D1_CONTROL_MIPI_CLK_PHY_SHUTDOWNB_SHFT) |
-		(0x1 << MIPI_PHY_D1_CONTROL_MIPI_DATA_PHY_SHUTDOWNB_SHFT);
-	CDBG("%s MIPI_PHY_D1_CONTROL val=0x%x\n", __func__, val);
-	msm_camera_io_w(val, csicbase + MIPI_PHY_D1_CONTROL);
-
-	msm_camera_io_w(0x00000000, csicbase + MIPI_PHY_D2_CONTROL);
-	msm_camera_io_w(0x00000000, csicbase + MIPI_PHY_D3_CONTROL);
-
-	/* program number of lanes and lane mapping */
-	switch (csic_params->lane_cnt) {
-	case 1:
-		msm_camera_io_w(csic_params->lane_assign << 8 | 0x4,
-			csicbase + MIPI_CAMERA_CNTL);
-		break;
-	case 2:
-		msm_camera_io_w(csic_params->lane_assign << 8 | 0x5,
-			csicbase + MIPI_CAMERA_CNTL);
-		break;
-	case 3:
-		msm_camera_io_w(csic_params->lane_assign << 8 | 0x6,
-			csicbase + MIPI_CAMERA_CNTL);
-		break;
-	case 4:
-		msm_camera_io_w(csic_params->lane_assign << 8 | 0x7,
-			csicbase + MIPI_CAMERA_CNTL);
-		break;
-	}
-
-	msm_camera_io_w(0xF077F3C0, csicbase + MIPI_INTERRUPT_MASK);
-	/*clear IRQ bits*/
-	msm_camera_io_w(0xF077F3C0, csicbase + MIPI_INTERRUPT_STATUS);
-
-	return rc;
-}
-
-static irqreturn_t msm_csic_irq(int irq_num, void *data)
-{
-	uint32_t irq;
-	struct csic_device *csic_dev = data;
-
-	pr_info("msm_csic_irq: %x\n", (unsigned int)csic_dev->base);
-	irq = msm_camera_io_r(csic_dev->base + MIPI_INTERRUPT_STATUS);
-	pr_info("%s MIPI_INTERRUPT_STATUS = 0x%x 0x%x\n",
-		__func__, irq,
-		msm_camera_io_r(csic_dev->base + MIPI_PROTOCOL_CONTROL));
-	msm_camera_io_w(irq, csic_dev->base + MIPI_INTERRUPT_STATUS);
-
-	/* TODO: Needs to send this info to upper layers */
-	if ((irq >> 19) & 0x1)
-		pr_info("Unsupported packet format is received\n");
-	return IRQ_HANDLED;
-}
-
-static int msm_csic_subdev_g_chip_ident(struct v4l2_subdev *sd,
-			struct v4l2_dbg_chip_ident *chip)
-{
-	BUG_ON(!chip);
-	chip->ident = V4L2_IDENT_CSIC;
-	chip->revision = 0;
-	return 0;
-}
-
-static struct msm_cam_clk_info csic_8x_clk_info[] = {
-	{"csi_src_clk", 384000000},
-	{"csi_clk", -1},
-	{"csi_vfe_clk", -1},
-	{"csi_pclk", -1},
-};
-
-static struct msm_cam_clk_info csic_7x_clk_info[] = {
-	{"csi_clk", 400000000},
-	{"csi_vfe_clk", -1},
-	{"csi_pclk", -1},
-};
-
-static int msm_csic_init(struct v4l2_subdev *sd)
-{
-	int rc = 0;
-	struct csic_device *csic_dev;
-	csic_dev = v4l2_get_subdevdata(sd);
-	if (csic_dev == NULL) {
-		rc = -ENOMEM;
-		return rc;
-	}
-
-	csic_dev->base = ioremap(csic_dev->mem->start,
-		resource_size(csic_dev->mem));
-	if (!csic_dev->base) {
-		rc = -ENOMEM;
-		return rc;
-	}
-
-	csic_dev->hw_version = CSIC_8X;
-	rc = msm_cam_clk_enable(&csic_dev->pdev->dev, csic_8x_clk_info,
-		csic_dev->csic_clk, ARRAY_SIZE(csic_8x_clk_info), 1);
-	if (rc < 0) {
-		csic_dev->hw_version = CSIC_7X;
-		rc = msm_cam_clk_enable(&csic_dev->pdev->dev, csic_7x_clk_info,
-			csic_dev->csic_clk, ARRAY_SIZE(csic_7x_clk_info), 1);
-		if (rc < 0) {
-			csic_dev->hw_version = 0;
-			iounmap(csic_dev->base);
-			csic_dev->base = NULL;
-			return rc;
-		}
-	}
-	if (csic_dev->hw_version == CSIC_7X)
-		msm_camio_vfe_blk_reset_3();
-
-#if DBG_CSIC
-	enable_irq(csic_dev->irq->start);
-#endif
-
-	return 0;
-}
-
-static void msm_csic_disable(struct v4l2_subdev *sd)
-{
-	uint32_t val;
-	struct csic_device *csic_dev;
-	csic_dev = v4l2_get_subdevdata(sd);
-
-	val = 0x0;
-	if (csic_dev->base != NULL) {
-		CDBG("%s MIPI_PHY_D0_CONTROL2 val=0x%x\n", __func__, val);
-		msm_camera_io_w(val, csic_dev->base + MIPI_PHY_D0_CONTROL2);
-		msm_camera_io_w(val, csic_dev->base + MIPI_PHY_D1_CONTROL2);
-		msm_camera_io_w(val, csic_dev->base + MIPI_PHY_D2_CONTROL2);
-		msm_camera_io_w(val, csic_dev->base + MIPI_PHY_D3_CONTROL2);
-		CDBG("%s MIPI_PHY_CL_CONTROL val=0x%x\n", __func__, val);
-		msm_camera_io_w(val, csic_dev->base + MIPI_PHY_CL_CONTROL);
-		msleep(20);
-		val = msm_camera_io_r(csic_dev->base + MIPI_PHY_D1_CONTROL);
-		val &=
-		~((0x1 << MIPI_PHY_D1_CONTROL_MIPI_CLK_PHY_SHUTDOWNB_SHFT)
-		|(0x1 << MIPI_PHY_D1_CONTROL_MIPI_DATA_PHY_SHUTDOWNB_SHFT));
-		CDBG("%s MIPI_PHY_D1_CONTROL val=0x%x\n", __func__, val);
-		msm_camera_io_w(val, csic_dev->base + MIPI_PHY_D1_CONTROL);
-		usleep_range(5000, 6000);
-		msm_camera_io_w(0x0, csic_dev->base + MIPI_INTERRUPT_MASK);
-		msm_camera_io_w(0x0, csic_dev->base + MIPI_INTERRUPT_STATUS);
-		msm_camera_io_w(MIPI_PROTOCOL_CONTROL_SW_RST_BMSK,
-			csic_dev->base + MIPI_PROTOCOL_CONTROL);
-
-		msm_camera_io_w(0xE400, csic_dev->base + MIPI_CAMERA_CNTL);
-	}
-}
-
-static int msm_csic_release(struct v4l2_subdev *sd)
-{
-	struct csic_device *csic_dev;
-	csic_dev = v4l2_get_subdevdata(sd);
-
-	msm_csic_disable(sd);
-#if DBG_CSIC
-	disable_irq(csic_dev->irq->start);
-#endif
-
-	if (csic_dev->hw_version == CSIC_8X) {
-		msm_cam_clk_enable(&csic_dev->pdev->dev, csic_8x_clk_info,
-			csic_dev->csic_clk, ARRAY_SIZE(csic_8x_clk_info), 0);
-	} else if (csic_dev->hw_version == CSIC_7X) {
-		msm_cam_clk_enable(&csic_dev->pdev->dev, csic_7x_clk_info,
-			csic_dev->csic_clk, ARRAY_SIZE(csic_7x_clk_info), 0);
-	}
-
-	iounmap(csic_dev->base);
-	csic_dev->base = NULL;
-	return 0;
-}
-
-static long msm_csic_cmd(struct v4l2_subdev *sd, void *arg)
-{
-	long rc = 0;
-	struct csic_cfg_data cdata;
-	struct msm_camera_csi_params csic_params;
-	if (copy_from_user(&cdata,
-		(void *)arg,
-		sizeof(struct csic_cfg_data)))
-		return -EFAULT;
-	CDBG("%s cfgtype = %d\n", __func__, cdata.cfgtype);
-	switch (cdata.cfgtype) {
-	case CSIC_INIT:
-		rc = msm_csic_init(sd);
-		break;
-	case CSIC_CFG:
-		if (copy_from_user(&csic_params,
-			(void *)cdata.csic_params,
-			sizeof(struct msm_camera_csi_params)))
-			return -EFAULT;
-		rc = msm_csic_config(sd, &csic_params);
-		break;
-	default:
-		rc = -EINVAL;
-		break;
-	}
-	return rc;
-}
-
-static long msm_csic_subdev_ioctl(struct v4l2_subdev *sd,
-			unsigned int cmd, void *arg)
-{
-	switch (cmd) {
-	case VIDIOC_MSM_CSIC_CFG:
-		return msm_csic_cmd(sd, arg);
-	case VIDIOC_MSM_CSIC_RELEASE:
-		return msm_csic_release(sd);
-	default:
-		return -ENOIOCTLCMD;
-	}
-}
-
-static struct v4l2_subdev_core_ops msm_csic_subdev_core_ops = {
-	.g_chip_ident = &msm_csic_subdev_g_chip_ident,
-	.ioctl = &msm_csic_subdev_ioctl,
-};
-
-static const struct v4l2_subdev_ops msm_csic_subdev_ops = {
-	.core = &msm_csic_subdev_core_ops,
-};
-
-static const struct v4l2_subdev_internal_ops msm_csic_internal_ops;
-
-static int __devinit csic_probe(struct platform_device *pdev)
-{
-	struct csic_device *new_csic_dev;
-	int rc = 0;
-	struct msm_cam_subdev_info sd_info;
-
-	CDBG("%s: device id = %d\n", __func__, pdev->id);
-	new_csic_dev = kzalloc(sizeof(struct csic_device), GFP_KERNEL);
-	if (!new_csic_dev) {
-		pr_err("%s: no enough memory\n", __func__);
-		return -ENOMEM;
-	}
-
-	v4l2_subdev_init(&new_csic_dev->subdev, &msm_csic_subdev_ops);
-	new_csic_dev->subdev.internal_ops = &msm_csic_internal_ops;
-	new_csic_dev->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	snprintf(new_csic_dev->subdev.name,
-			ARRAY_SIZE(new_csic_dev->subdev.name), "msm_csic");
-	v4l2_set_subdevdata(&new_csic_dev->subdev, new_csic_dev);
-	platform_set_drvdata(pdev, &new_csic_dev->subdev);
-	mutex_init(&new_csic_dev->mutex);
-
-	new_csic_dev->mem = platform_get_resource_byname(pdev,
-					IORESOURCE_MEM, "csic");
-	if (!new_csic_dev->mem) {
-		pr_err("%s: no mem resource?\n", __func__);
-		rc = -ENODEV;
-		goto csic_no_resource;
-	}
-	new_csic_dev->irq = platform_get_resource_byname(pdev,
-					IORESOURCE_IRQ, "csic");
-	if (!new_csic_dev->irq) {
-		pr_err("%s: no irq resource?\n", __func__);
-		rc = -ENODEV;
-		goto csic_no_resource;
-	}
-	new_csic_dev->io = request_mem_region(new_csic_dev->mem->start,
-		resource_size(new_csic_dev->mem), pdev->name);
-	if (!new_csic_dev->io) {
-		pr_err("%s: no valid mem region\n", __func__);
-		rc = -EBUSY;
-		goto csic_no_resource;
-	}
-
-	rc = request_irq(new_csic_dev->irq->start, msm_csic_irq,
-		IRQF_TRIGGER_HIGH, "csic", new_csic_dev);
-	if (rc < 0) {
-		release_mem_region(new_csic_dev->mem->start,
-			resource_size(new_csic_dev->mem));
-		pr_err("%s: irq request fail\n", __func__);
-		rc = -EBUSY;
-		goto csic_no_resource;
-	}
-	disable_irq(new_csic_dev->irq->start);
-
-	new_csic_dev->pdev = pdev;
-
-	rc = msm_cam_clk_enable(&new_csic_dev->pdev->dev, &csic_7x_clk_info[2],
-				new_csic_dev->csic_clk, 1, 1);
-	new_csic_dev->base = ioremap(new_csic_dev->mem->start,
-		resource_size(new_csic_dev->mem));
-	if (!new_csic_dev->base) {
-		rc = -ENOMEM;
-		return rc;
-	}
-
-	msm_camera_io_w(MIPI_PWR_CNTL_DIS, new_csic_dev->base + MIPI_PWR_CNTL);
-
-	rc = msm_cam_clk_enable(&new_csic_dev->pdev->dev, &csic_7x_clk_info[2],
-				new_csic_dev->csic_clk, 1, 0);
-
-	iounmap(new_csic_dev->base);
-	new_csic_dev->base = NULL;
-	sd_info.sdev_type = CSIC_DEV;
-	sd_info.sd_index = pdev->id;
-	sd_info.irq_num = new_csic_dev->irq->start;
-	msm_cam_register_subdev_node(
-		&new_csic_dev->subdev, &sd_info);
-
-	media_entity_init(&new_csic_dev->subdev.entity, 0, NULL, 0);
-	new_csic_dev->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
-	new_csic_dev->subdev.entity.group_id = CSIC_DEV;
-	new_csic_dev->subdev.entity.name = pdev->name;
-	new_csic_dev->subdev.entity.revision =
-		new_csic_dev->subdev.devnode->num;
-	return 0;
-
-csic_no_resource:
-	mutex_destroy(&new_csic_dev->mutex);
-	kfree(new_csic_dev);
-	return 0;
-}
-
-static struct platform_driver csic_driver = {
-	.probe = csic_probe,
-	.driver = {
-		.name = MSM_CSIC_DRV_NAME,
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init msm_csic_init_module(void)
-{
-	return platform_driver_register(&csic_driver);
-}
-
-static void __exit msm_csic_exit_module(void)
-{
-	platform_driver_unregister(&csic_driver);
-}
-
-module_init(msm_csic_init_module);
-module_exit(msm_csic_exit_module);
-MODULE_DESCRIPTION("MSM csic driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/csi/msm_csic.h b/drivers/media/platform/msm/camera_v1/csi/msm_csic.h
deleted file mode 100644
index f8aa92a..0000000
--- a/drivers/media/platform/msm/camera_v1/csi/msm_csic.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#ifndef MSM_CSIC_H
-#define MSM_CSIC_H
-
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <media/v4l2-subdev.h>
-
-#define CSIC_7X 0x1
-#define CSIC_8X (0x1 << 1)
-
-struct csic_device {
-	struct platform_device *pdev;
-	struct v4l2_subdev subdev;
-	struct resource *mem;
-	struct resource *irq;
-	struct resource *io;
-	void __iomem *base;
-	struct mutex mutex;
-	uint32_t hw_version;
-
-	struct clk *csic_clk[5];
-};
-
-#define VIDIOC_MSM_CSIC_CFG \
-	_IOWR('V', BASE_VIDIOC_PRIVATE + 4, struct csic_cfg_data*)
-
-#define VIDIOC_MSM_CSIC_RELEASE \
-	_IOWR('V', BASE_VIDIOC_PRIVATE + 5, struct v4l2_subdev*)
-
-#endif
diff --git a/drivers/media/platform/msm/camera_v1/csi/msm_csic_register.c b/drivers/media/platform/msm/camera_v1/csi/msm_csic_register.c
deleted file mode 100644
index 660fdaf..0000000
--- a/drivers/media/platform/msm/camera_v1/csi/msm_csic_register.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/device.h>
-#include "msm.h"
-#include "msm_csi_register.h"
-
-int msm_csi_register_subdevs(struct msm_cam_media_controller *p_mctl,
-	uint8_t csiphy_code_index, uint8_t csid_core_index,
-	struct msm_cam_server_dev *server_dev)
-{
-	int rc = -ENODEV;
-
-	p_mctl->csic_sdev = server_dev->csic_device[csid_core_index];
-	if (!p_mctl->csic_sdev)
-		goto out;
-	v4l2_set_subdev_hostdata(p_mctl->csic_sdev, p_mctl);
-
-	rc = 0;
-	p_mctl->ispif_sdev = NULL;
-	return rc;
-
-out:
-	p_mctl->ispif_sdev = NULL;
-	return rc;
-}
-
diff --git a/drivers/media/platform/msm/camera_v1/csi/msm_csid.c b/drivers/media/platform/msm/camera_v1/csi/msm_csid.c
deleted file mode 100644
index c1ffac3..0000000
--- a/drivers/media/platform/msm/camera_v1/csi/msm_csid.c
+++ /dev/null
@@ -1,649 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-
-#include <linux/delay.h>
-#include <linux/module.h>
-#include <linux/of.h>
-#include <mach/board.h>
-#include <mach/camera.h>
-#include <media/msm_isp.h>
-#include "msm_csid.h"
-#include "msm_csid_hwreg.h"
-#include "msm.h"
-#include "msm_cam_server.h"
-
-#define V4L2_IDENT_CSID                            50002
-#define CSID_VERSION_V2                      0x02000011
-#define CSID_VERSION_V3                      0x30000000
-
-#define DBG_CSID 0
-
-#define TRUE   1
-#define FALSE  0
-
-static int msm_csid_cid_lut(
-	struct msm_camera_csid_lut_params *csid_lut_params,
-	void __iomem *csidbase)
-{
-	int rc = 0, i = 0;
-	uint32_t val = 0;
-
-	if (!csid_lut_params) {
-		pr_err("%s:%d csid_lut_params NULL\n", __func__, __LINE__);
-		return -EINVAL;
-	}
-	for (i = 0; i < csid_lut_params->num_cid && i < 16; i++) {
-		CDBG("%s lut params num_cid = %d, cid = %d, dt = %x, df = %d\n",
-			__func__,
-			csid_lut_params->num_cid,
-			csid_lut_params->vc_cfg[i].cid,
-			csid_lut_params->vc_cfg[i].dt,
-			csid_lut_params->vc_cfg[i].decode_format);
-		if (csid_lut_params->vc_cfg[i].dt < 0x12 ||
-			csid_lut_params->vc_cfg[i].dt > 0x37) {
-			CDBG("%s: unsupported data type 0x%x\n",
-				 __func__, csid_lut_params->vc_cfg[i].dt);
-			return rc;
-		}
-		val = msm_camera_io_r(csidbase + CSID_CID_LUT_VC_0_ADDR +
-			(csid_lut_params->vc_cfg[i].cid >> 2) * 4)
-			& ~(0xFF << ((csid_lut_params->vc_cfg[i].cid % 4) * 8));
-		val |= (csid_lut_params->vc_cfg[i].dt <<
-			((csid_lut_params->vc_cfg[i].cid % 4) * 8));
-		msm_camera_io_w(val, csidbase + CSID_CID_LUT_VC_0_ADDR +
-			(csid_lut_params->vc_cfg[i].cid >> 2) * 4);
-
-		val = (csid_lut_params->vc_cfg[i].decode_format << 4) | 0x3;
-		msm_camera_io_w(val, csidbase + CSID_CID_n_CFG_ADDR +
-			(csid_lut_params->vc_cfg[i].cid * 4));
-	}
-	return rc;
-}
-
-#if DBG_CSID
-static void msm_csid_set_debug_reg(void __iomem *csidbase,
-	struct msm_camera_csid_params *csid_params)
-{
-	uint32_t val = 0;
-	val = ((1 << csid_params->lane_cnt) - 1) << 20;
-	msm_camera_io_w(0x7f010800 | val, csidbase + CSID_IRQ_MASK_ADDR);
-	msm_camera_io_w(0x7f010800 | val, csidbase + CSID_IRQ_CLEAR_CMD_ADDR);
-}
-#else
-static void msm_csid_set_debug_reg(void __iomem *csidbase,
-	struct msm_camera_csid_params *csid_params) {}
-#endif
-
-static int msm_csid_config(struct csid_device *csid_dev,
-	struct msm_camera_csid_params *csid_params)
-{
-	int rc = 0;
-	uint32_t val = 0;
-	void __iomem *csidbase;
-	csidbase = csid_dev->base;
-	if (!csidbase || !csid_params) {
-		pr_err("%s:%d csidbase %p, csid params %p\n", __func__,
-			__LINE__, csidbase, csid_params);
-		return -EINVAL;
-	}
-
-	CDBG("%s csid_params, lane_cnt = %d, lane_assign = %x, phy sel = %d\n",
-		__func__,
-		csid_params->lane_cnt,
-		csid_params->lane_assign,
-		csid_params->phy_sel);
-	val = csid_params->lane_cnt - 1;
-	val |= csid_params->lane_assign << CSID_DL_INPUT_SEL_SHIFT;
-	if (csid_dev->hw_version < 0x30000000) {
-		val |= (0xF << 10);
-		msm_camera_io_w(val, csidbase + CSID_CORE_CTRL_0_ADDR);
-	} else {
-		msm_camera_io_w(val, csidbase + CSID_CORE_CTRL_0_ADDR);
-		val = csid_params->phy_sel << CSID_PHY_SEL_SHIFT;
-		val |= 0xF;
-		msm_camera_io_w(val, csidbase + CSID_CORE_CTRL_1_ADDR);
-	}
-
-	rc = msm_csid_cid_lut(&csid_params->lut_params, csidbase);
-	if (rc < 0)
-		return rc;
-
-	msm_csid_set_debug_reg(csidbase, csid_params);
-	return rc;
-}
-
-static irqreturn_t msm_csid_irq(int irq_num, void *data)
-{
-	uint32_t irq;
-	struct csid_device *csid_dev = data;
-	if (!csid_dev) {
-		pr_err("%s:%d csid_dev NULL\n", __func__, __LINE__);
-		return IRQ_HANDLED;
-	}
-	irq = msm_camera_io_r(csid_dev->base + CSID_IRQ_STATUS_ADDR);
-	CDBG("%s CSID%d_IRQ_STATUS_ADDR = 0x%x\n",
-		 __func__, csid_dev->pdev->id, irq);
-	if (irq & (0x1 << CSID_RST_DONE_IRQ_BITSHIFT))
-			complete(&csid_dev->reset_complete);
-	msm_camera_io_w(irq, csid_dev->base + CSID_IRQ_CLEAR_CMD_ADDR);
-	return IRQ_HANDLED;
-}
-
-int msm_csid_irq_routine(struct v4l2_subdev *sd, u32 status, bool *handled)
-{
-	struct csid_device *csid_dev = v4l2_get_subdevdata(sd);
-	irqreturn_t ret;
-	CDBG("%s E\n", __func__);
-	ret = msm_csid_irq(csid_dev->irq->start, csid_dev);
-	*handled = TRUE;
-	return 0;
-}
-
-static void msm_csid_reset(struct csid_device *csid_dev)
-{
-	msm_camera_io_w(CSID_RST_STB_ALL, csid_dev->base + CSID_RST_CMD_ADDR);
-	wait_for_completion_interruptible(&csid_dev->reset_complete);
-	return;
-}
-
-static int msm_csid_subdev_g_chip_ident(struct v4l2_subdev *sd,
-			struct v4l2_dbg_chip_ident *chip)
-{
-	BUG_ON(!chip);
-	chip->ident = V4L2_IDENT_CSID;
-	chip->revision = 0;
-	return 0;
-}
-
-static struct msm_cam_clk_info csid_8960_clk_info[] = {
-	{"csi_src_clk", 177780000},
-	{"csi_clk", -1},
-	{"csi_phy_clk", -1},
-	{"csi_pclk", -1},
-};
-
-static struct msm_cam_clk_info csid0_8974_clk_info[] = {
-	{"csi0_ahb_clk", -1},
-	{"csi0_src_clk", 200000000},
-	{"csi0_clk", -1},
-	{"csi0_phy_clk", -1},
-	{"csi0_pix_clk", -1},
-	{"csi0_rdi_clk", -1},
-};
-
-static struct msm_cam_clk_info csid1_8974_clk_info[] = {
-	{"csi1_ahb_clk", -1},
-	{"csi1_src_clk", 200000000},
-	{"csi1_clk", -1},
-	{"csi1_phy_clk", -1},
-	{"csi1_pix_clk", -1},
-	{"csi1_rdi_clk", -1},
-};
-
-static struct msm_cam_clk_info csid2_8974_clk_info[] = {
-	{"csi2_ahb_clk", -1},
-	{"csi2_src_clk", 200000000},
-	{"csi2_clk", -1},
-	{"csi2_phy_clk", -1},
-	{"csi2_pix_clk", -1},
-	{"csi2_rdi_clk", -1},
-};
-
-static struct msm_cam_clk_info csid3_8974_clk_info[] = {
-	{"csi3_ahb_clk", -1},
-	{"csi3_src_clk", 200000000},
-	{"csi3_clk", -1},
-	{"csi3_phy_clk", -1},
-	{"csi3_pix_clk", -1},
-	{"csi3_rdi_clk", -1},
-};
-
-static struct msm_cam_clk_setting csid_8974_clk_info[] = {
-	{&csid0_8974_clk_info[0], ARRAY_SIZE(csid0_8974_clk_info)},
-	{&csid1_8974_clk_info[0], ARRAY_SIZE(csid1_8974_clk_info)},
-	{&csid2_8974_clk_info[0], ARRAY_SIZE(csid2_8974_clk_info)},
-	{&csid3_8974_clk_info[0], ARRAY_SIZE(csid3_8974_clk_info)},
-};
-
-static struct camera_vreg_t csid_8960_vreg_info[] = {
-	{"mipi_csi_vdd", REG_LDO, 1200000, 1200000, 20000},
-};
-
-static struct camera_vreg_t csid_8974_vreg_info[] = {
-	{"mipi_csi_vdd", REG_LDO, 1800000, 1800000, 12000},
-};
-
-static int msm_csid_init(struct csid_device *csid_dev, uint32_t *csid_version)
-{
-	int rc = 0;
-	uint8_t core_id = 0;
-
-	if (!csid_version) {
-		pr_err("%s:%d csid_version NULL\n", __func__, __LINE__);
-		rc = -EINVAL;
-		return rc;
-	}
-
-	if (csid_dev->csid_state == CSID_POWER_UP) {
-		pr_err("%s: csid invalid state %d\n", __func__,
-			csid_dev->csid_state);
-		rc = -EINVAL;
-		return rc;
-	}
-
-	csid_dev->base = ioremap(csid_dev->mem->start,
-		resource_size(csid_dev->mem));
-	if (!csid_dev->base) {
-		pr_err("%s csid_dev->base NULL\n", __func__);
-		rc = -ENOMEM;
-		return rc;
-	}
-
-	if (CSID_VERSION <= CSID_VERSION_V2) {
-		rc = msm_camera_config_vreg(&csid_dev->pdev->dev,
-			csid_8960_vreg_info, ARRAY_SIZE(csid_8960_vreg_info),
-			NULL, 0, &csid_dev->csi_vdd, 1);
-		if (rc < 0) {
-			pr_err("%s: regulator on failed\n", __func__);
-			goto vreg_config_failed;
-		}
-
-		rc = msm_camera_enable_vreg(&csid_dev->pdev->dev,
-			csid_8960_vreg_info, ARRAY_SIZE(csid_8960_vreg_info),
-			NULL, 0, &csid_dev->csi_vdd, 1);
-		if (rc < 0) {
-			pr_err("%s: regulator enable failed\n", __func__);
-			goto vreg_enable_failed;
-		}
-
-		rc = msm_cam_clk_enable(&csid_dev->pdev->dev,
-			csid_8960_clk_info, csid_dev->csid_clk,
-			ARRAY_SIZE(csid_8960_clk_info), 1);
-		if (rc < 0) {
-			pr_err("%s: clock enable failed\n", __func__);
-			goto clk_enable_failed;
-		}
-	} else if (CSID_VERSION == CSID_VERSION_V3) {
-		rc = msm_camera_config_vreg(&csid_dev->pdev->dev,
-			csid_8974_vreg_info, ARRAY_SIZE(csid_8974_vreg_info),
-			NULL, 0, &csid_dev->csi_vdd, 1);
-		if (rc < 0) {
-			pr_err("%s: regulator on failed\n", __func__);
-			goto vreg_config_failed;
-		}
-
-		rc = msm_camera_enable_vreg(&csid_dev->pdev->dev,
-			csid_8974_vreg_info, ARRAY_SIZE(csid_8974_vreg_info),
-			NULL, 0, &csid_dev->csi_vdd, 1);
-		if (rc < 0) {
-			pr_err("%s: regulator enable failed\n", __func__);
-			goto vreg_enable_failed;
-		}
-
-		rc = msm_cam_clk_enable(&csid_dev->pdev->dev,
-			csid_8974_clk_info[0].clk_info, csid_dev->csid0_clk,
-			csid_8974_clk_info[0].num_clk_info, 1);
-		if (rc < 0) {
-			pr_err("%s: clock enable failed\n", __func__);
-			goto csid0_clk_enable_failed;
-		}
-		core_id = csid_dev->pdev->id;
-		if (core_id) {
-			rc = msm_cam_clk_enable(&csid_dev->pdev->dev,
-				csid_8974_clk_info[core_id].clk_info,
-				csid_dev->csid_clk,
-				csid_8974_clk_info[core_id].num_clk_info, 1);
-			if (rc < 0) {
-				pr_err("%s: clock enable failed\n",
-					__func__);
-				goto clk_enable_failed;
-			}
-		}
-	}
-
-	csid_dev->hw_version =
-		msm_camera_io_r(csid_dev->base + CSID_HW_VERSION_ADDR);
-	*csid_version = csid_dev->hw_version;
-
-	init_completion(&csid_dev->reset_complete);
-
-	enable_irq(csid_dev->irq->start);
-
-	msm_csid_reset(csid_dev);
-	csid_dev->csid_state = CSID_POWER_UP;
-	return rc;
-
-clk_enable_failed:
-	if (CSID_VERSION == CSID_VERSION_V3) {
-		msm_cam_clk_enable(&csid_dev->pdev->dev,
-			csid_8974_clk_info[0].clk_info, csid_dev->csid0_clk,
-			csid_8974_clk_info[0].num_clk_info, 0);
-	}
-csid0_clk_enable_failed:
-	if (CSID_VERSION <= CSID_VERSION_V2) {
-		msm_camera_enable_vreg(&csid_dev->pdev->dev,
-			csid_8960_vreg_info, ARRAY_SIZE(csid_8960_vreg_info),
-			NULL, 0, &csid_dev->csi_vdd, 0);
-	} else if (CSID_VERSION == CSID_VERSION_V3) {
-		msm_camera_enable_vreg(&csid_dev->pdev->dev,
-			csid_8974_vreg_info, ARRAY_SIZE(csid_8974_vreg_info),
-			NULL, 0, &csid_dev->csi_vdd, 0);
-	}
-vreg_enable_failed:
-	if (CSID_VERSION <= CSID_VERSION_V2) {
-		msm_camera_config_vreg(&csid_dev->pdev->dev,
-			csid_8960_vreg_info, ARRAY_SIZE(csid_8960_vreg_info),
-			NULL, 0, &csid_dev->csi_vdd, 0);
-	} else if (CSID_VERSION == CSID_VERSION_V3) {
-		msm_camera_config_vreg(&csid_dev->pdev->dev,
-			csid_8974_vreg_info, ARRAY_SIZE(csid_8974_vreg_info),
-			NULL, 0, &csid_dev->csi_vdd, 0);
-	}
-vreg_config_failed:
-	iounmap(csid_dev->base);
-	csid_dev->base = NULL;
-	return rc;
-}
-
-static int msm_csid_release(struct csid_device *csid_dev)
-{
-	uint32_t irq;
-	uint8_t core_id = 0;
-
-	if (csid_dev->csid_state != CSID_POWER_UP) {
-		pr_err("%s: csid invalid state %d\n", __func__,
-			csid_dev->csid_state);
-		return -EINVAL;
-	}
-
-	irq = msm_camera_io_r(csid_dev->base + CSID_IRQ_STATUS_ADDR);
-	msm_camera_io_w(irq, csid_dev->base + CSID_IRQ_CLEAR_CMD_ADDR);
-	msm_camera_io_w(0, csid_dev->base + CSID_IRQ_MASK_ADDR);
-
-	disable_irq(csid_dev->irq->start);
-
-	if (csid_dev->hw_version <= CSID_VERSION_V2) {
-		msm_cam_clk_enable(&csid_dev->pdev->dev, csid_8960_clk_info,
-			csid_dev->csid_clk, ARRAY_SIZE(csid_8960_clk_info), 0);
-
-		msm_camera_enable_vreg(&csid_dev->pdev->dev,
-			csid_8960_vreg_info, ARRAY_SIZE(csid_8960_vreg_info),
-			NULL, 0, &csid_dev->csi_vdd, 0);
-
-		msm_camera_config_vreg(&csid_dev->pdev->dev,
-			csid_8960_vreg_info, ARRAY_SIZE(csid_8960_vreg_info),
-			NULL, 0, &csid_dev->csi_vdd, 0);
-	} else if (csid_dev->hw_version == CSID_VERSION_V3) {
-		core_id = csid_dev->pdev->id;
-		if (core_id)
-			msm_cam_clk_enable(&csid_dev->pdev->dev,
-				csid_8974_clk_info[core_id].clk_info,
-				csid_dev->csid_clk,
-				csid_8974_clk_info[core_id].num_clk_info, 0);
-
-		msm_cam_clk_enable(&csid_dev->pdev->dev,
-			csid_8974_clk_info[0].clk_info, csid_dev->csid0_clk,
-			csid_8974_clk_info[0].num_clk_info, 0);
-
-		msm_camera_enable_vreg(&csid_dev->pdev->dev,
-			csid_8974_vreg_info, ARRAY_SIZE(csid_8974_vreg_info),
-			NULL, 0, &csid_dev->csi_vdd, 0);
-
-		msm_camera_config_vreg(&csid_dev->pdev->dev,
-			csid_8974_vreg_info, ARRAY_SIZE(csid_8974_vreg_info),
-			NULL, 0, &csid_dev->csi_vdd, 0);
-	}
-
-	iounmap(csid_dev->base);
-	csid_dev->base = NULL;
-	csid_dev->csid_state = CSID_POWER_DOWN;
-	return 0;
-}
-
-static long msm_csid_cmd(struct csid_device *csid_dev, void *arg)
-{
-	int rc = 0;
-	struct csid_cfg_data cdata;
-
-	if (!csid_dev) {
-		pr_err("%s:%d csid_dev NULL\n", __func__, __LINE__);
-		return -EINVAL;
-	}
-
-	if (copy_from_user(&cdata,
-		(void *)arg,
-		sizeof(struct csid_cfg_data))) {
-		pr_err("%s: %d failed\n", __func__, __LINE__);
-		return -EFAULT;
-	}
-	CDBG("%s cfgtype = %d\n", __func__, cdata.cfgtype);
-	switch (cdata.cfgtype) {
-	case CSID_INIT:
-		rc = msm_csid_init(csid_dev, &cdata.cfg.csid_version);
-		if (copy_to_user((void *)arg,
-			&cdata,
-			sizeof(struct csid_cfg_data))) {
-			pr_err("%s: %d failed\n", __func__, __LINE__);
-			rc = -EFAULT;
-		}
-		break;
-	case CSID_CFG: {
-		struct msm_camera_csid_params csid_params;
-		struct msm_camera_csid_vc_cfg *vc_cfg = NULL;
-		if (copy_from_user(&csid_params,
-			(void *)cdata.cfg.csid_params,
-			sizeof(struct msm_camera_csid_params))) {
-			pr_err("%s: %d failed\n", __func__, __LINE__);
-			rc = -EFAULT;
-			break;
-		}
-		vc_cfg = kzalloc(csid_params.lut_params.num_cid *
-			sizeof(struct msm_camera_csid_vc_cfg),
-			GFP_KERNEL);
-		if (!vc_cfg) {
-			pr_err("%s: %d failed\n", __func__, __LINE__);
-			rc = -ENOMEM;
-			break;
-		}
-		if (copy_from_user(vc_cfg,
-			(void *)csid_params.lut_params.vc_cfg,
-			(csid_params.lut_params.num_cid *
-			sizeof(struct msm_camera_csid_vc_cfg)))) {
-			pr_err("%s: %d failed\n", __func__, __LINE__);
-			kfree(vc_cfg);
-			rc = -EFAULT;
-			break;
-		}
-		csid_params.lut_params.vc_cfg = vc_cfg;
-		rc = msm_csid_config(csid_dev, &csid_params);
-		kfree(vc_cfg);
-		break;
-	}
-	default:
-		pr_err("%s: %d failed\n", __func__, __LINE__);
-		rc = -ENOIOCTLCMD;
-		break;
-	}
-	return rc;
-}
-
-static long msm_csid_subdev_ioctl(struct v4l2_subdev *sd,
-			unsigned int cmd, void *arg)
-{
-	int rc = -ENOIOCTLCMD;
-	struct csid_device *csid_dev = v4l2_get_subdevdata(sd);
-	mutex_lock(&csid_dev->mutex);
-	switch (cmd) {
-	case VIDIOC_MSM_CSID_CFG:
-		rc = msm_csid_cmd(csid_dev, arg);
-		break;
-	case VIDIOC_MSM_CSID_RELEASE:
-		rc = msm_csid_release(csid_dev);
-		break;
-	default:
-		pr_err("%s: command not found\n", __func__);
-	}
-	mutex_unlock(&csid_dev->mutex);
-	return rc;
-}
-
-static const struct v4l2_subdev_internal_ops msm_csid_internal_ops;
-
-static struct v4l2_subdev_core_ops msm_csid_subdev_core_ops = {
-	.g_chip_ident = &msm_csid_subdev_g_chip_ident,
-	.ioctl = &msm_csid_subdev_ioctl,
-	.interrupt_service_routine = msm_csid_irq_routine,
-};
-
-static const struct v4l2_subdev_ops msm_csid_subdev_ops = {
-	.core = &msm_csid_subdev_core_ops,
-};
-
-static int __devinit csid_probe(struct platform_device *pdev)
-{
-	struct csid_device *new_csid_dev;
-	struct msm_cam_subdev_info sd_info;
-	struct intr_table_entry irq_req;
-
-	int rc = 0;
-	CDBG("%s:%d called\n", __func__, __LINE__);
-	new_csid_dev = kzalloc(sizeof(struct csid_device), GFP_KERNEL);
-	if (!new_csid_dev) {
-		pr_err("%s: no enough memory\n", __func__);
-		return -ENOMEM;
-	}
-
-	v4l2_subdev_init(&new_csid_dev->subdev, &msm_csid_subdev_ops);
-	new_csid_dev->subdev.internal_ops = &msm_csid_internal_ops;
-	new_csid_dev->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	snprintf(new_csid_dev->subdev.name,
-			ARRAY_SIZE(new_csid_dev->subdev.name), "msm_csid");
-	v4l2_set_subdevdata(&new_csid_dev->subdev, new_csid_dev);
-	platform_set_drvdata(pdev, &new_csid_dev->subdev);
-	mutex_init(&new_csid_dev->mutex);
-
-	if (pdev->dev.of_node)
-		of_property_read_u32((&pdev->dev)->of_node,
-			"cell-index", &pdev->id);
-
-	CDBG("%s device id %d\n", __func__, pdev->id);
-	new_csid_dev->mem = platform_get_resource_byname(pdev,
-					IORESOURCE_MEM, "csid");
-	if (!new_csid_dev->mem) {
-		pr_err("%s: no mem resource?\n", __func__);
-		rc = -ENODEV;
-		goto csid_no_resource;
-	}
-	new_csid_dev->irq = platform_get_resource_byname(pdev,
-					IORESOURCE_IRQ, "csid");
-	if (!new_csid_dev->irq) {
-		pr_err("%s: no irq resource?\n", __func__);
-		rc = -ENODEV;
-		goto csid_no_resource;
-	}
-	new_csid_dev->io = request_mem_region(new_csid_dev->mem->start,
-		resource_size(new_csid_dev->mem), pdev->name);
-	if (!new_csid_dev->io) {
-		pr_err("%s: no valid mem region\n", __func__);
-		rc = -EBUSY;
-		goto csid_no_resource;
-	}
-
-	new_csid_dev->pdev = pdev;
-	sd_info.sdev_type = CSID_DEV;
-	sd_info.sd_index = pdev->id;
-	sd_info.irq_num = new_csid_dev->irq->start;
-	msm_cam_register_subdev_node(&new_csid_dev->subdev, &sd_info);
-
-	media_entity_init(&new_csid_dev->subdev.entity, 0, NULL, 0);
-	new_csid_dev->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
-	new_csid_dev->subdev.entity.group_id = CSID_DEV;
-	new_csid_dev->subdev.entity.name = pdev->name;
-	new_csid_dev->subdev.entity.revision =
-		new_csid_dev->subdev.devnode->num;
-
-	/* Request for this device irq from the camera server. If the
-	 * IRQ Router is present on this target, the interrupt will be
-	 * handled by the camera server and the interrupt service
-	 * routine called. If the request_irq call returns ENXIO, then
-	 * the IRQ Router hardware is not present on this target. We
-	 * have to request for the irq ourselves and register the
-	 * appropriate interrupt handler. */
-	irq_req.cam_hw_idx       = MSM_CAM_HW_CSI0 + pdev->id;
-	irq_req.dev_name         = "csid";
-	irq_req.irq_idx          = CAMERA_SS_IRQ_2 + pdev->id;
-	irq_req.irq_num          = new_csid_dev->irq->start;
-	irq_req.is_composite     = 0;
-	irq_req.irq_trigger_type = IRQF_TRIGGER_RISING;
-	irq_req.num_hwcore       = 1;
-	irq_req.subdev_list[0]   = &new_csid_dev->subdev;
-	irq_req.data             = (void *)new_csid_dev;
-	rc = msm_cam_server_request_irq(&irq_req);
-	if (rc == -ENXIO) {
-		/* IRQ Router hardware is not present on this hardware.
-		 * Request for the IRQ and register the interrupt handler. */
-		rc = request_irq(new_csid_dev->irq->start, msm_csid_irq,
-			IRQF_TRIGGER_RISING, "csid", new_csid_dev);
-		if (rc < 0) {
-			release_mem_region(new_csid_dev->mem->start,
-				resource_size(new_csid_dev->mem));
-			pr_err("%s: irq request fail\n", __func__);
-			rc = -EBUSY;
-			goto csid_no_resource;
-		}
-		disable_irq(new_csid_dev->irq->start);
-	} else if (rc < 0) {
-		release_mem_region(new_csid_dev->mem->start,
-			resource_size(new_csid_dev->mem));
-		pr_err("%s Error registering irq ", __func__);
-		goto csid_no_resource;
-	}
-
-	new_csid_dev->csid_state = CSID_POWER_DOWN;
-	return 0;
-
-csid_no_resource:
-	mutex_destroy(&new_csid_dev->mutex);
-	kfree(new_csid_dev);
-	return 0;
-}
-
-static const struct of_device_id msm_csid_dt_match[] = {
-	{.compatible = "qcom,csid"},
-	{}
-};
-
-MODULE_DEVICE_TABLE(of, msm_csid_dt_match);
-
-static struct platform_driver csid_driver = {
-	.probe = csid_probe,
-	.driver = {
-		.name = MSM_CSID_DRV_NAME,
-		.owner = THIS_MODULE,
-		.of_match_table = msm_csid_dt_match,
-	},
-};
-
-static int __init msm_csid_init_module(void)
-{
-	return platform_driver_register(&csid_driver);
-}
-
-static void __exit msm_csid_exit_module(void)
-{
-	platform_driver_unregister(&csid_driver);
-}
-
-module_init(msm_csid_init_module);
-module_exit(msm_csid_exit_module);
-MODULE_DESCRIPTION("MSM CSID driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/csi/msm_csid.h b/drivers/media/platform/msm/camera_v1/csi/msm_csid.h
deleted file mode 100644
index 252f5fd..0000000
--- a/drivers/media/platform/msm/camera_v1/csi/msm_csid.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-
-#ifndef MSM_CSID_H
-#define MSM_CSID_H
-
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <media/v4l2-subdev.h>
-#include <media/msm_camera.h>
-
-enum msm_csid_state_t {
-	CSID_POWER_UP,
-	CSID_POWER_DOWN,
-};
-
-struct csid_device {
-	struct platform_device *pdev;
-	struct v4l2_subdev subdev;
-	struct resource *mem;
-	struct resource *irq;
-	struct resource *io;
-	struct regulator *csi_vdd;
-	void __iomem *base;
-	struct mutex mutex;
-	struct completion reset_complete;
-	uint32_t hw_version;
-	enum msm_csid_state_t csid_state;
-
-	struct clk *csid0_clk[6];
-	struct clk *csid_clk[6];
-};
-
-#define VIDIOC_MSM_CSID_CFG \
-	_IOWR('V', BASE_VIDIOC_PRIVATE + 4, struct csic_cfg_data*)
-
-#define VIDIOC_MSM_CSID_RELEASE \
-	_IOWR('V', BASE_VIDIOC_PRIVATE + 5, struct v4l2_subdev*)
-#endif
-
diff --git a/drivers/media/platform/msm/camera_v1/csi/msm_csiphy.c b/drivers/media/platform/msm/camera_v1/csi/msm_csiphy.c
deleted file mode 100644
index 0c754e9..0000000
--- a/drivers/media/platform/msm/camera_v1/csi/msm_csiphy.c
+++ /dev/null
@@ -1,465 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-
-#include <linux/delay.h>
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <linux/of.h>
-#include <linux/module.h>
-#include <mach/board.h>
-#include <mach/vreg.h>
-#include <media/msm_isp.h>
-#include "msm_csiphy.h"
-#include "msm.h"
-#include "msm_csiphy_hwreg.h"
-#define DBG_CSIPHY 0
-
-#define V4L2_IDENT_CSIPHY                        50003
-#define CSIPHY_VERSION_V3                        0x10
-
-int msm_csiphy_lane_config(struct csiphy_device *csiphy_dev,
-	struct msm_camera_csiphy_params *csiphy_params)
-{
-	int rc = 0;
-	int j = 0;
-	uint32_t val = 0;
-	uint8_t lane_cnt = 0;
-	uint16_t lane_mask = 0;
-	void __iomem *csiphybase;
-	csiphybase = csiphy_dev->base;
-	if (!csiphybase) {
-		pr_err("%s: csiphybase NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	csiphy_dev->lane_mask[csiphy_dev->pdev->id] |= csiphy_params->lane_mask;
-	lane_mask = csiphy_dev->lane_mask[csiphy_dev->pdev->id];
-	lane_cnt = csiphy_params->lane_cnt;
-	if (csiphy_params->lane_cnt < 1 || csiphy_params->lane_cnt > 4) {
-		pr_err("%s: unsupported lane cnt %d\n",
-			__func__, csiphy_params->lane_cnt);
-		return rc;
-	}
-
-	CDBG("%s csiphy_params, mask = %x, cnt = %d, settle cnt = %x\n",
-		__func__,
-		csiphy_params->lane_mask,
-		csiphy_params->lane_cnt,
-		csiphy_params->settle_cnt);
-	msm_camera_io_w(0x1, csiphybase + MIPI_CSIPHY_GLBL_T_INIT_CFG0_ADDR);
-	msm_camera_io_w(0x1, csiphybase + MIPI_CSIPHY_T_WAKEUP_CFG0_ADDR);
-
-	if (csiphy_dev->hw_version != CSIPHY_VERSION_V3) {
-		val = 0x3;
-		msm_camera_io_w((lane_mask << 2) | val,
-				csiphybase + MIPI_CSIPHY_GLBL_PWR_CFG_ADDR);
-		msm_camera_io_w(0x10, csiphybase + MIPI_CSIPHY_LNCK_CFG2_ADDR);
-		msm_camera_io_w(csiphy_params->settle_cnt,
-			 csiphybase + MIPI_CSIPHY_LNCK_CFG3_ADDR);
-		msm_camera_io_w(0x24,
-			csiphybase + MIPI_CSIPHY_INTERRUPT_MASK0_ADDR);
-		msm_camera_io_w(0x24,
-			csiphybase + MIPI_CSIPHY_INTERRUPT_CLEAR0_ADDR);
-	} else {
-		val = 0x1;
-		msm_camera_io_w((lane_mask << 1) | val,
-				csiphybase + MIPI_CSIPHY_GLBL_PWR_CFG_ADDR);
-		msm_camera_io_w(csiphy_params->combo_mode <<
-			MIPI_CSIPHY_MODE_CONFIG_SHIFT,
-			csiphybase + MIPI_CSIPHY_GLBL_RESET_ADDR);
-	}
-
-	lane_mask &= 0x1f;
-	while (lane_mask & 0x1f) {
-		if (!(lane_mask & 0x1)) {
-			j++;
-			lane_mask >>= 1;
-			continue;
-		}
-		msm_camera_io_w(0x10,
-			csiphybase + MIPI_CSIPHY_LNn_CFG2_ADDR + 0x40*j);
-		msm_camera_io_w(csiphy_params->settle_cnt,
-			csiphybase + MIPI_CSIPHY_LNn_CFG3_ADDR + 0x40*j);
-		msm_camera_io_w(MIPI_CSIPHY_INTERRUPT_MASK_VAL, csiphybase +
-			MIPI_CSIPHY_INTERRUPT_MASK_ADDR + 0x4*j);
-		msm_camera_io_w(MIPI_CSIPHY_INTERRUPT_MASK_VAL, csiphybase +
-			MIPI_CSIPHY_INTERRUPT_CLEAR_ADDR + 0x4*j);
-		j++;
-		lane_mask >>= 1;
-	}
-	msleep(20);
-	return rc;
-}
-
-static irqreturn_t msm_csiphy_irq(int irq_num, void *data)
-{
-	uint32_t irq;
-	int i;
-	struct csiphy_device *csiphy_dev = data;
-
-	for (i = 0; i < 8; i++) {
-		irq = msm_camera_io_r(
-			csiphy_dev->base +
-			MIPI_CSIPHY_INTERRUPT_STATUS0_ADDR + 0x4*i);
-		msm_camera_io_w(irq,
-			csiphy_dev->base +
-			MIPI_CSIPHY_INTERRUPT_CLEAR0_ADDR + 0x4*i);
-		pr_err("%s MIPI_CSIPHY%d_INTERRUPT_STATUS%d = 0x%x\n",
-			 __func__, csiphy_dev->pdev->id, i, irq);
-		msm_camera_io_w(0x1, csiphy_dev->base +
-			MIPI_CSIPHY_GLBL_IRQ_CMD_ADDR);
-		msm_camera_io_w(0x0, csiphy_dev->base +
-			MIPI_CSIPHY_GLBL_IRQ_CMD_ADDR);
-		msm_camera_io_w(0x0,
-			csiphy_dev->base +
-			MIPI_CSIPHY_INTERRUPT_CLEAR0_ADDR + 0x4*i);
-	}
-	return IRQ_HANDLED;
-}
-
-static void msm_csiphy_reset(struct csiphy_device *csiphy_dev)
-{
-	msm_camera_io_w(0x1, csiphy_dev->base + MIPI_CSIPHY_GLBL_RESET_ADDR);
-	usleep_range(5000, 8000);
-	msm_camera_io_w(0x0, csiphy_dev->base + MIPI_CSIPHY_GLBL_RESET_ADDR);
-}
-
-static int msm_csiphy_subdev_g_chip_ident(struct v4l2_subdev *sd,
-			struct v4l2_dbg_chip_ident *chip)
-{
-	BUG_ON(!chip);
-	chip->ident = V4L2_IDENT_CSIPHY;
-	chip->revision = 0;
-	return 0;
-}
-
-static struct msm_cam_clk_info csiphy_8960_clk_info[] = {
-	{"csiphy_timer_src_clk", 177780000},
-	{"csiphy_timer_clk", -1},
-};
-
-static struct msm_cam_clk_info csiphy_8974_clk_info[] = {
-	{"ispif_ahb_clk", -1},
-	{"csiphy_timer_src_clk", 200000000},
-	{"csiphy_timer_clk", -1},
-};
-
-static int msm_csiphy_init(struct csiphy_device *csiphy_dev)
-{
-	int rc = 0;
-	if (csiphy_dev == NULL) {
-		pr_err("%s: csiphy_dev NULL\n", __func__);
-		rc = -ENOMEM;
-		return rc;
-	}
-
-	if (csiphy_dev->csiphy_state == CSIPHY_POWER_UP) {
-		pr_err("%s: csiphy invalid state %d\n", __func__,
-			csiphy_dev->csiphy_state);
-		rc = -EINVAL;
-		return rc;
-	}
-
-	if (csiphy_dev->ref_count++) {
-		CDBG("%s csiphy refcount = %d\n", __func__,
-			csiphy_dev->ref_count);
-		return rc;
-	}
-
-	csiphy_dev->base = ioremap(csiphy_dev->mem->start,
-		resource_size(csiphy_dev->mem));
-	if (!csiphy_dev->base) {
-		pr_err("%s: csiphy_dev->base NULL\n", __func__);
-		csiphy_dev->ref_count--;
-		rc = -ENOMEM;
-		return rc;
-	}
-
-	if (CSIPHY_VERSION != CSIPHY_VERSION_V3)
-		rc = msm_cam_clk_enable(&csiphy_dev->pdev->dev,
-			csiphy_8960_clk_info, csiphy_dev->csiphy_clk,
-			ARRAY_SIZE(csiphy_8960_clk_info), 1);
-	else
-		rc = msm_cam_clk_enable(&csiphy_dev->pdev->dev,
-			csiphy_8974_clk_info, csiphy_dev->csiphy_clk,
-			ARRAY_SIZE(csiphy_8974_clk_info), 1);
-
-	if (rc < 0) {
-		pr_err("%s: csiphy clk enable failed\n", __func__);
-		csiphy_dev->ref_count--;
-		iounmap(csiphy_dev->base);
-		csiphy_dev->base = NULL;
-		return rc;
-	}
-
-#if DBG_CSIPHY
-	enable_irq(csiphy_dev->irq->start);
-#endif
-	msm_csiphy_reset(csiphy_dev);
-
-	csiphy_dev->hw_version =
-		msm_camera_io_r(csiphy_dev->base + MIPI_CSIPHY_HW_VERSION_ADDR);
-
-	csiphy_dev->csiphy_state = CSIPHY_POWER_UP;
-	return 0;
-}
-
-static int msm_csiphy_release(struct csiphy_device *csiphy_dev, void *arg)
-{
-	int i = 0;
-	struct msm_camera_csi_lane_params *csi_lane_params;
-	uint16_t csi_lane_mask;
-	csi_lane_params = (struct msm_camera_csi_lane_params *)arg;
-	csi_lane_mask = csi_lane_params->csi_lane_mask;
-
-	if (!csiphy_dev || !csiphy_dev->ref_count) {
-		pr_err("%s csiphy dev NULL / ref_count ZERO\n", __func__);
-		return 0;
-	}
-
-	if (csiphy_dev->csiphy_state != CSIPHY_POWER_UP) {
-		pr_err("%s: csiphy invalid state %d\n", __func__,
-			csiphy_dev->csiphy_state);
-		return -EINVAL;
-	}
-
-	CDBG("%s csiphy_params, lane assign %x mask = %x\n",
-		__func__,
-		csi_lane_params->csi_lane_assign,
-		csi_lane_params->csi_lane_mask);
-
-	if (csiphy_dev->hw_version != CSIPHY_VERSION_V3) {
-		csiphy_dev->lane_mask[csiphy_dev->pdev->id] = 0;
-		for (i = 0; i < 4; i++)
-			msm_camera_io_w(0x0, csiphy_dev->base +
-				MIPI_CSIPHY_LNn_CFG2_ADDR + 0x40*i);
-	} else {
-		csiphy_dev->lane_mask[csiphy_dev->pdev->id] &=
-			~(csi_lane_params->csi_lane_mask);
-		i = 0;
-		while (csi_lane_mask & 0x1F) {
-			if (csi_lane_mask & 0x1) {
-				msm_camera_io_w(0x0, csiphy_dev->base +
-					MIPI_CSIPHY_LNn_CFG2_ADDR + 0x40*i);
-			}
-			csi_lane_mask >>= 1;
-			i++;
-		}
-	}
-
-	if (--csiphy_dev->ref_count) {
-		CDBG("%s csiphy refcount = %d\n", __func__,
-			csiphy_dev->ref_count);
-		return 0;
-	}
-
-	msm_camera_io_w(0x0, csiphy_dev->base + MIPI_CSIPHY_LNCK_CFG2_ADDR);
-	msm_camera_io_w(0x0, csiphy_dev->base + MIPI_CSIPHY_GLBL_PWR_CFG_ADDR);
-
-#if DBG_CSIPHY
-	disable_irq(csiphy_dev->irq->start);
-#endif
-	if (CSIPHY_VERSION != CSIPHY_VERSION_V3)
-		msm_cam_clk_enable(&csiphy_dev->pdev->dev,
-			csiphy_8960_clk_info, csiphy_dev->csiphy_clk,
-			ARRAY_SIZE(csiphy_8960_clk_info), 0);
-	else
-		msm_cam_clk_enable(&csiphy_dev->pdev->dev,
-			csiphy_8974_clk_info, csiphy_dev->csiphy_clk,
-			ARRAY_SIZE(csiphy_8974_clk_info), 0);
-
-	iounmap(csiphy_dev->base);
-	csiphy_dev->base = NULL;
-	csiphy_dev->csiphy_state = CSIPHY_POWER_DOWN;
-	return 0;
-}
-
-static long msm_csiphy_cmd(struct csiphy_device *csiphy_dev, void *arg)
-{
-	int rc = 0;
-	struct csiphy_cfg_data cdata;
-	struct msm_camera_csiphy_params csiphy_params;
-	if (!csiphy_dev) {
-		pr_err("%s: csiphy_dev NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (copy_from_user(&cdata,
-		(void *)arg,
-		sizeof(struct csiphy_cfg_data))) {
-		pr_err("%s: %d failed\n", __func__, __LINE__);
-		return -EFAULT;
-	}
-	switch (cdata.cfgtype) {
-	case CSIPHY_INIT:
-		rc = msm_csiphy_init(csiphy_dev);
-		break;
-	case CSIPHY_CFG:
-		if (copy_from_user(&csiphy_params,
-			(void *)cdata.csiphy_params,
-			sizeof(struct msm_camera_csiphy_params))) {
-			pr_err("%s: %d failed\n", __func__, __LINE__);
-			rc = -EFAULT;
-			break;
-		}
-		rc = msm_csiphy_lane_config(csiphy_dev, &csiphy_params);
-		break;
-	default:
-		pr_err("%s: %d failed\n", __func__, __LINE__);
-		rc = -ENOIOCTLCMD;
-		break;
-	}
-	return rc;
-}
-
-static long msm_csiphy_subdev_ioctl(struct v4l2_subdev *sd,
-			unsigned int cmd, void *arg)
-{
-	int rc = -ENOIOCTLCMD;
-	struct csiphy_device *csiphy_dev = v4l2_get_subdevdata(sd);
-	mutex_lock(&csiphy_dev->mutex);
-	switch (cmd) {
-	case VIDIOC_MSM_CSIPHY_CFG:
-		rc = msm_csiphy_cmd(csiphy_dev, arg);
-		break;
-	case VIDIOC_MSM_CSIPHY_RELEASE:
-		rc = msm_csiphy_release(csiphy_dev, arg);
-		break;
-	default:
-		pr_err("%s: command not found\n", __func__);
-	}
-	mutex_unlock(&csiphy_dev->mutex);
-	return rc;
-}
-
-static const struct v4l2_subdev_internal_ops msm_csiphy_internal_ops;
-
-static struct v4l2_subdev_core_ops msm_csiphy_subdev_core_ops = {
-	.g_chip_ident = &msm_csiphy_subdev_g_chip_ident,
-	.ioctl = &msm_csiphy_subdev_ioctl,
-};
-
-static const struct v4l2_subdev_ops msm_csiphy_subdev_ops = {
-	.core = &msm_csiphy_subdev_core_ops,
-};
-
-static int __devinit csiphy_probe(struct platform_device *pdev)
-{
-	struct csiphy_device *new_csiphy_dev;
-	int rc = 0;
-	struct msm_cam_subdev_info sd_info;
-
-	new_csiphy_dev = kzalloc(sizeof(struct csiphy_device), GFP_KERNEL);
-	if (!new_csiphy_dev) {
-		pr_err("%s: no enough memory\n", __func__);
-		return -ENOMEM;
-	}
-
-	v4l2_subdev_init(&new_csiphy_dev->subdev, &msm_csiphy_subdev_ops);
-	new_csiphy_dev->subdev.internal_ops = &msm_csiphy_internal_ops;
-	new_csiphy_dev->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	snprintf(new_csiphy_dev->subdev.name,
-			ARRAY_SIZE(new_csiphy_dev->subdev.name), "msm_csiphy");
-	v4l2_set_subdevdata(&new_csiphy_dev->subdev, new_csiphy_dev);
-	platform_set_drvdata(pdev, &new_csiphy_dev->subdev);
-
-	mutex_init(&new_csiphy_dev->mutex);
-
-	if (pdev->dev.of_node)
-		of_property_read_u32((&pdev->dev)->of_node,
-			"cell-index", &pdev->id);
-	CDBG("%s: device id = %d\n", __func__, pdev->id);
-
-	new_csiphy_dev->mem = platform_get_resource_byname(pdev,
-					IORESOURCE_MEM, "csiphy");
-	if (!new_csiphy_dev->mem) {
-		pr_err("%s: no mem resource?\n", __func__);
-		rc = -ENODEV;
-		goto csiphy_no_resource;
-	}
-	new_csiphy_dev->irq = platform_get_resource_byname(pdev,
-					IORESOURCE_IRQ, "csiphy");
-	if (!new_csiphy_dev->irq) {
-		pr_err("%s: no irq resource?\n", __func__);
-		rc = -ENODEV;
-		goto csiphy_no_resource;
-	}
-	new_csiphy_dev->io = request_mem_region(new_csiphy_dev->mem->start,
-		resource_size(new_csiphy_dev->mem), pdev->name);
-	if (!new_csiphy_dev->io) {
-		pr_err("%s: no valid mem region\n", __func__);
-		rc = -EBUSY;
-		goto csiphy_no_resource;
-	}
-
-	rc = request_irq(new_csiphy_dev->irq->start, msm_csiphy_irq,
-		IRQF_TRIGGER_RISING, "csiphy", new_csiphy_dev);
-	if (rc < 0) {
-		release_mem_region(new_csiphy_dev->mem->start,
-			resource_size(new_csiphy_dev->mem));
-		pr_err("%s: irq request fail\n", __func__);
-		rc = -EBUSY;
-		goto csiphy_no_resource;
-	}
-	disable_irq(new_csiphy_dev->irq->start);
-
-	new_csiphy_dev->pdev = pdev;
-	sd_info.sdev_type = CSIPHY_DEV;
-	sd_info.sd_index = pdev->id;
-	sd_info.irq_num = new_csiphy_dev->irq->start;
-	msm_cam_register_subdev_node(
-		&new_csiphy_dev->subdev, &sd_info);
-
-	media_entity_init(&new_csiphy_dev->subdev.entity, 0, NULL, 0);
-	new_csiphy_dev->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
-	new_csiphy_dev->subdev.entity.group_id = CSIPHY_DEV;
-	new_csiphy_dev->subdev.entity.name = pdev->name;
-	new_csiphy_dev->subdev.entity.revision =
-		new_csiphy_dev->subdev.devnode->num;
-	new_csiphy_dev->csiphy_state = CSIPHY_POWER_DOWN;
-	return 0;
-
-csiphy_no_resource:
-	mutex_destroy(&new_csiphy_dev->mutex);
-	kfree(new_csiphy_dev);
-	return 0;
-}
-
-static const struct of_device_id msm_csiphy_dt_match[] = {
-	{.compatible = "qcom,csiphy"},
-	{}
-};
-
-MODULE_DEVICE_TABLE(of, msm_csiphy_dt_match);
-
-static struct platform_driver csiphy_driver = {
-	.probe = csiphy_probe,
-	.driver = {
-		.name = MSM_CSIPHY_DRV_NAME,
-		.owner = THIS_MODULE,
-		.of_match_table = msm_csiphy_dt_match,
-	},
-};
-
-static int __init msm_csiphy_init_module(void)
-{
-	return platform_driver_register(&csiphy_driver);
-}
-
-static void __exit msm_csiphy_exit_module(void)
-{
-	platform_driver_unregister(&csiphy_driver);
-}
-
-module_init(msm_csiphy_init_module);
-module_exit(msm_csiphy_exit_module);
-MODULE_DESCRIPTION("MSM CSIPHY driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/csi/msm_csiphy.h b/drivers/media/platform/msm/camera_v1/csi/msm_csiphy.h
deleted file mode 100644
index 93c9758..0000000
--- a/drivers/media/platform/msm/camera_v1/csi/msm_csiphy.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-
-#ifndef MSM_CSIPHY_H
-#define MSM_CSIPHY_H
-
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <media/v4l2-subdev.h>
-#include <media/msm_camera.h>
-
-#define MAX_CSIPHY 3
-
-enum msm_csiphy_state_t {
-	CSIPHY_POWER_UP,
-	CSIPHY_POWER_DOWN,
-};
-
-struct csiphy_device {
-	struct platform_device *pdev;
-	struct v4l2_subdev subdev;
-	struct resource *mem;
-	struct resource *irq;
-	struct resource *io;
-	void __iomem *base;
-	struct mutex mutex;
-	uint32_t hw_version;
-	enum msm_csiphy_state_t csiphy_state;
-
-	struct clk *csiphy_clk[3];
-	uint8_t ref_count;
-	uint16_t lane_mask[MAX_CSIPHY];
-};
-
-#define VIDIOC_MSM_CSIPHY_CFG \
-	_IOWR('V', BASE_VIDIOC_PRIVATE + 7, struct csiphy_cfg_data*)
-
-#define VIDIOC_MSM_CSIPHY_RELEASE \
-	_IOWR('V', BASE_VIDIOC_PRIVATE + 9, void *)
-#endif
diff --git a/drivers/media/platform/msm/camera_v1/csi/msm_ispif.c b/drivers/media/platform/msm/camera_v1/csi/msm_ispif.c
deleted file mode 100644
index 009a8d0..0000000
--- a/drivers/media/platform/msm/camera_v1/csi/msm_ispif.c
+++ /dev/null
@@ -1,928 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-
-#include <linux/delay.h>
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <linux/module.h>
-#include <linux/of.h>
-#include <mach/gpio.h>
-#include <mach/camera.h>
-#include "msm_ispif.h"
-#include "msm.h"
-#include "msm_ispif_hwreg.h"
-
-#define V4L2_IDENT_ISPIF                     50001
-#define CSID_VERSION_V2                      0x02000011
-#define CSID_VERSION_V3                      0x30000000
-
-#define MAX_CID 15
-
-static atomic_t ispif_irq_cnt;
-static spinlock_t ispif_tasklet_lock;
-static struct list_head ispif_tasklet_q;
-
-static int msm_ispif_intf_reset(struct ispif_device *ispif,
-	uint16_t intfmask, uint8_t vfe_intf)
-{
-	int rc = 0;
-	uint32_t data = (0x1 << STROBED_RST_EN);
-	uint16_t intfnum = 0, mask = intfmask;
-
-	while (mask != 0) {
-		if (!(intfmask & (0x1 << intfnum))) {
-			mask >>= 1;
-			intfnum++;
-			continue;
-		}
-		switch (intfnum) {
-		case PIX0:
-			data |= (0x1 << PIX_0_VFE_RST_STB) |
-				(0x1 << PIX_0_CSID_RST_STB);
-			ispif->pix_sof_count = 0;
-			break;
-
-		case RDI0:
-			data |= (0x1 << RDI_0_VFE_RST_STB) |
-				(0x1 << RDI_0_CSID_RST_STB);
-			break;
-
-		case PIX1:
-			data |= (0x1 << PIX_1_VFE_RST_STB) |
-				(0x1 << PIX_1_CSID_RST_STB);
-			break;
-
-		case RDI1:
-			data |= (0x1 << RDI_1_VFE_RST_STB) |
-				(0x1 << RDI_1_CSID_RST_STB);
-			break;
-
-		case RDI2:
-			data |= (0x1 << RDI_2_VFE_RST_STB) |
-				(0x1 << RDI_2_CSID_RST_STB);
-			break;
-
-		default:
-			rc = -EINVAL;
-			break;
-		}
-		mask >>= 1;
-		intfnum++;
-	}	/*end while */
-	if (data > 0x1) {
-		if (vfe_intf == VFE0)
-			msm_camera_io_w(data, ispif->base + ISPIF_RST_CMD_ADDR);
-		else
-			msm_camera_io_w(data, ispif->base +
-				ISPIF_RST_CMD_1_ADDR);
-		rc = wait_for_completion_interruptible(&ispif->reset_complete);
-	}
-	return rc;
-}
-
-static int msm_ispif_reset(struct ispif_device *ispif)
-{
-	int rc = 0;
-	ispif->pix_sof_count = 0;
-	msm_camera_io_w(ISPIF_RST_CMD_MASK, ispif->base + ISPIF_RST_CMD_ADDR);
-	if (ispif->csid_version == CSID_VERSION_V3)
-		msm_camera_io_w(ISPIF_RST_CMD_1_MASK, ispif->base +
-				ISPIF_RST_CMD_1_ADDR);
-	rc = wait_for_completion_interruptible(&ispif->reset_complete);
-	return rc;
-}
-
-static int msm_ispif_subdev_g_chip_ident(struct v4l2_subdev *sd,
-			struct v4l2_dbg_chip_ident *chip)
-{
-	BUG_ON(!chip);
-	chip->ident = V4L2_IDENT_ISPIF;
-	chip->revision = 0;
-	return 0;
-}
-
-static void msm_ispif_sel_csid_core(struct ispif_device *ispif,
-	uint8_t intftype, uint8_t csid, uint8_t vfe_intf)
-{
-	int rc = 0;
-	uint32_t data = 0;
-
-	if (ispif->csid_version <= CSID_VERSION_V2) {
-		if (ispif->ispif_clk[intftype] == NULL) {
-			pr_err("%s: ispif NULL clk\n", __func__);
-			return;
-		}
-		rc = clk_set_rate(ispif->ispif_clk[intftype], csid);
-		if (rc < 0)
-			pr_err("%s: clk_set_rate failed %d\n", __func__, rc);
-	}
-	data = msm_camera_io_r(ispif->base + ISPIF_INPUT_SEL_ADDR +
-		(0x200 * vfe_intf));
-	switch (intftype) {
-	case PIX0:
-		data &= ~(0x3);
-		data |= csid;
-		break;
-
-	case RDI0:
-		data &= ~(0x3 << 4);
-		data |= (csid << 4);
-		break;
-
-	case PIX1:
-		data &= ~(0x3 << 8);
-		data |= (csid << 8);
-		break;
-
-	case RDI1:
-		data &= ~(0x3 << 12);
-		data |= (csid << 12);
-		break;
-
-	case RDI2:
-		data &= ~(0x3 << 20);
-		data |= (csid << 20);
-		break;
-	}
-	if (data) {
-		msm_camera_io_w(data, ispif->base + ISPIF_INPUT_SEL_ADDR +
-			(0x200 * vfe_intf));
-	}
-}
-
-static void msm_ispif_enable_intf_cids(struct ispif_device *ispif,
-	uint8_t intftype, uint16_t cid_mask, uint8_t vfe_intf)
-{
-	uint32_t data = 0;
-	mutex_lock(&ispif->mutex);
-	switch (intftype) {
-	case PIX0:
-		data = msm_camera_io_r(ispif->base +
-			ISPIF_PIX_0_INTF_CID_MASK_ADDR + (0x200 * vfe_intf));
-		data |= cid_mask;
-		msm_camera_io_w(data, ispif->base +
-			ISPIF_PIX_0_INTF_CID_MASK_ADDR + (0x200 * vfe_intf));
-		break;
-
-	case RDI0:
-		data = msm_camera_io_r(ispif->base +
-			ISPIF_RDI_0_INTF_CID_MASK_ADDR + (0x200 * vfe_intf));
-		data |= cid_mask;
-		msm_camera_io_w(data, ispif->base +
-			ISPIF_RDI_0_INTF_CID_MASK_ADDR + (0x200 * vfe_intf));
-		break;
-
-	case PIX1:
-		data = msm_camera_io_r(ispif->base +
-			ISPIF_PIX_1_INTF_CID_MASK_ADDR + (0x200 * vfe_intf));
-		data |= cid_mask;
-		msm_camera_io_w(data, ispif->base +
-			ISPIF_PIX_1_INTF_CID_MASK_ADDR + (0x200 * vfe_intf));
-		break;
-
-	case RDI1:
-		data = msm_camera_io_r(ispif->base +
-			ISPIF_RDI_1_INTF_CID_MASK_ADDR + (0x200 * vfe_intf));
-		data |= cid_mask;
-		msm_camera_io_w(data, ispif->base +
-			ISPIF_RDI_1_INTF_CID_MASK_ADDR + (0x200 * vfe_intf));
-		break;
-
-	case RDI2:
-		data = msm_camera_io_r(ispif->base +
-			ISPIF_RDI_2_INTF_CID_MASK_ADDR + (0x200 * vfe_intf));
-		data |= cid_mask;
-		msm_camera_io_w(data, ispif->base +
-			ISPIF_RDI_2_INTF_CID_MASK_ADDR + (0x200 * vfe_intf));
-		break;
-	}
-	mutex_unlock(&ispif->mutex);
-}
-
-static int32_t msm_ispif_validate_intf_status(struct ispif_device *ispif,
-	uint8_t intftype, uint8_t vfe_intf)
-{
-	int32_t rc = 0;
-	uint32_t data = 0;
-	mutex_lock(&ispif->mutex);
-	switch (intftype) {
-	case PIX0:
-		data = msm_camera_io_r(ispif->base +
-				ISPIF_PIX_0_STATUS_ADDR + (0x200 * vfe_intf));
-		break;
-
-	case RDI0:
-		data = msm_camera_io_r(ispif->base +
-				ISPIF_RDI_0_STATUS_ADDR + (0x200 * vfe_intf));
-		break;
-
-	case PIX1:
-		data = msm_camera_io_r(ispif->base +
-				ISPIF_PIX_1_STATUS_ADDR + (0x200 * vfe_intf));
-		break;
-
-	case RDI1:
-		data = msm_camera_io_r(ispif->base +
-				ISPIF_RDI_1_STATUS_ADDR + (0x200 * vfe_intf));
-		break;
-
-	case RDI2:
-		data = msm_camera_io_r(ispif->base +
-				ISPIF_RDI_2_STATUS_ADDR + (0x200 * vfe_intf));
-		break;
-	}
-	if ((data & 0xf) != 0xf)
-		rc = -EBUSY;
-	mutex_unlock(&ispif->mutex);
-	return rc;
-}
-
-static int msm_ispif_config(struct ispif_device *ispif,
-	struct msm_ispif_params_list *params_list)
-{
-	uint32_t params_len;
-	struct msm_ispif_params *ispif_params;
-	int rc = 0, i = 0;
-	uint8_t intftype;
-	uint8_t vfe_intf;
-	params_len = params_list->len;
-	ispif_params = params_list->params;
-	CDBG("Enable interface\n");
-	msm_camera_io_w(0x00000000, ispif->base + ISPIF_IRQ_MASK_ADDR);
-	msm_camera_io_w(0x00000000, ispif->base + ISPIF_IRQ_MASK_1_ADDR);
-	msm_camera_io_w(0x00000000, ispif->base + ISPIF_IRQ_MASK_2_ADDR);
-	for (i = 0; i < params_len; i++) {
-		intftype = ispif_params[i].intftype;
-		vfe_intf = ispif_params[i].vfe_intf;
-		CDBG("%s intftype %x, vfe_intf %d, csid %d\n", __func__,
-			intftype, vfe_intf, ispif_params[i].csid);
-		if ((intftype >= INTF_MAX) ||
-			(ispif->csid_version <= CSID_VERSION_V2 &&
-			vfe_intf > VFE0) ||
-			(ispif->csid_version == CSID_VERSION_V3 &&
-			vfe_intf >= VFE_MAX)) {
-			pr_err("%s: intftype / vfe intf not valid\n",
-				__func__);
-			return -EINVAL;
-		}
-
-		rc = msm_ispif_validate_intf_status(ispif, intftype, vfe_intf);
-		if (rc < 0) {
-			pr_err("%s:%d failed rc %d\n", __func__, __LINE__, rc);
-			return rc;
-		}
-		msm_ispif_sel_csid_core(ispif, intftype, ispif_params[i].csid,
-			vfe_intf);
-		msm_ispif_enable_intf_cids(ispif, intftype,
-			ispif_params[i].cid_mask, vfe_intf);
-	}
-
-	msm_camera_io_w(ISPIF_IRQ_STATUS_MASK, ispif->base +
-					ISPIF_IRQ_MASK_ADDR);
-	msm_camera_io_w(ISPIF_IRQ_STATUS_MASK, ispif->base +
-					ISPIF_IRQ_CLEAR_ADDR);
-	msm_camera_io_w(ISPIF_IRQ_STATUS_1_MASK, ispif->base +
-					ISPIF_IRQ_MASK_1_ADDR);
-	msm_camera_io_w(ISPIF_IRQ_STATUS_1_MASK, ispif->base +
-					ISPIF_IRQ_CLEAR_1_ADDR);
-	msm_camera_io_w(ISPIF_IRQ_STATUS_2_MASK, ispif->base +
-					ISPIF_IRQ_MASK_2_ADDR);
-	msm_camera_io_w(ISPIF_IRQ_STATUS_2_MASK, ispif->base +
-					ISPIF_IRQ_CLEAR_2_ADDR);
-	msm_camera_io_w(ISPIF_IRQ_GLOBAL_CLEAR_CMD, ispif->base +
-		 ISPIF_IRQ_GLOBAL_CLEAR_CMD_ADDR);
-	return rc;
-}
-
-static uint32_t msm_ispif_get_cid_mask(struct ispif_device *ispif,
-	uint16_t intftype, uint8_t vfe_intf)
-{
-	uint32_t mask = 0;
-	switch (intftype) {
-	case PIX0:
-		mask = msm_camera_io_r(ispif->base +
-			ISPIF_PIX_0_INTF_CID_MASK_ADDR + (0x200 * vfe_intf));
-		break;
-
-	case RDI0:
-		mask = msm_camera_io_r(ispif->base +
-			ISPIF_RDI_0_INTF_CID_MASK_ADDR + (0x200 * vfe_intf));
-		break;
-
-	case PIX1:
-		mask = msm_camera_io_r(ispif->base +
-			ISPIF_PIX_1_INTF_CID_MASK_ADDR + (0x200 * vfe_intf));
-		break;
-
-	case RDI1:
-		mask = msm_camera_io_r(ispif->base +
-			ISPIF_RDI_1_INTF_CID_MASK_ADDR + (0x200 * vfe_intf));
-		break;
-
-	case RDI2:
-		mask = msm_camera_io_r(ispif->base +
-			ISPIF_RDI_2_INTF_CID_MASK_ADDR + (0x200 * vfe_intf));
-		break;
-
-	default:
-		break;
-	}
-	return mask;
-}
-
-static void msm_ispif_intf_cmd(struct ispif_device *ispif, uint16_t intfmask,
-	uint8_t intf_cmd_mask, uint8_t vfe_intf)
-{
-	uint8_t vc = 0, val = 0;
-	uint16_t mask = intfmask, intfnum = 0;
-	uint32_t cid_mask = 0;
-	uint32_t global_intf_cmd_mask1 = 0xFFFFFFFF;
-	while (mask != 0) {
-		if (!(intfmask & (0x1 << intfnum))) {
-			mask >>= 1;
-			intfnum++;
-			continue;
-		}
-
-		cid_mask = msm_ispif_get_cid_mask(ispif, intfnum, vfe_intf);
-		vc = 0;
-
-		while (cid_mask != 0) {
-			if ((cid_mask & 0xf) != 0x0) {
-				if (intfnum != RDI2) {
-					val = (intf_cmd_mask>>(vc*2)) & 0x3;
-					ispif->global_intf_cmd_mask |=
-						(0x3 << ((vc * 2) +
-						(intfnum * 8)));
-					ispif->global_intf_cmd_mask &=
-						~((0x3 & ~val) << ((vc * 2) +
-						(intfnum * 8)));
-				} else
-					global_intf_cmd_mask1 &=
-						~((0x3 & ~intf_cmd_mask)
-						<< ((vc * 2) + 8));
-			}
-			vc++;
-			cid_mask >>= 4;
-		}
-		mask >>= 1;
-		intfnum++;
-	}
-	msm_camera_io_w(ispif->global_intf_cmd_mask,
-		ispif->base + ISPIF_INTF_CMD_ADDR + (0x200 * vfe_intf));
-	if (global_intf_cmd_mask1 != 0xFFFFFFFF)
-		msm_camera_io_w(global_intf_cmd_mask1,
-			ispif->base + ISPIF_INTF_CMD_1_ADDR +
-			(0x200 * vfe_intf));
-}
-
-static int msm_ispif_abort_intf_transfer(struct ispif_device *ispif,
-	uint16_t intfmask, uint8_t vfe_intf)
-{
-	int rc = 0;
-	uint8_t intf_cmd_mask = 0xAA;
-	uint16_t intfnum = 0, mask = intfmask;
-	mutex_lock(&ispif->mutex);
-	CDBG("%s intfmask %x intf_cmd_mask %x\n", __func__, intfmask,
-		intf_cmd_mask);
-	msm_ispif_intf_cmd(ispif, intfmask, intf_cmd_mask, vfe_intf);
-	while (mask != 0) {
-		if (intfmask & (0x1 << intfnum))
-			ispif->global_intf_cmd_mask |= (0xFF << (intfnum * 8));
-		mask >>= 1;
-		intfnum++;
-		if (intfnum == RDI2)
-			break;
-	}
-	mutex_unlock(&ispif->mutex);
-	return rc;
-}
-
-static int msm_ispif_start_intf_transfer(struct ispif_device *ispif,
-	uint16_t intfmask, uint8_t vfe_intf)
-{
-	uint8_t intf_cmd_mask = 0x55;
-	int rc = 0;
-	mutex_lock(&ispif->mutex);
-	rc = msm_ispif_intf_reset(ispif, intfmask, vfe_intf);
-	CDBG("%s intfmask start after%x intf_cmd_mask %x\n", __func__, intfmask,
-		intf_cmd_mask);
-	msm_ispif_intf_cmd(ispif, intfmask, intf_cmd_mask, vfe_intf);
-	mutex_unlock(&ispif->mutex);
-	return rc;
-}
-
-static int msm_ispif_stop_intf_transfer(struct ispif_device *ispif,
-	uint16_t intfmask, uint8_t vfe_intf)
-{
-	int rc = 0;
-	uint8_t intf_cmd_mask = 0x00;
-	uint16_t intfnum = 0, mask = intfmask;
-	mutex_lock(&ispif->mutex);
-	CDBG("%s intfmask %x intf_cmd_mask %x\n", __func__, intfmask,
-		intf_cmd_mask);
-	msm_ispif_intf_cmd(ispif, intfmask, intf_cmd_mask, vfe_intf);
-	while (mask != 0) {
-		if (intfmask & (0x1 << intfnum)) {
-			switch (intfnum) {
-			case PIX0:
-				while ((msm_camera_io_r(ispif->base +
-					ISPIF_PIX_0_STATUS_ADDR +
-					(0x200 * vfe_intf))
-					& 0xf) != 0xf) {
-					CDBG("Wait for pix0 Idle\n");
-				}
-				break;
-
-			case RDI0:
-				while ((msm_camera_io_r(ispif->base +
-					ISPIF_RDI_0_STATUS_ADDR +
-					(0x200 * vfe_intf))
-					& 0xf) != 0xf) {
-					CDBG("Wait for rdi0 Idle\n");
-				}
-				break;
-
-			case PIX1:
-				while ((msm_camera_io_r(ispif->base +
-					ISPIF_PIX_1_STATUS_ADDR +
-					(0x200 * vfe_intf))
-					& 0xf) != 0xf) {
-					CDBG("Wait for pix1 Idle\n");
-				}
-				break;
-
-			case RDI1:
-				while ((msm_camera_io_r(ispif->base +
-					ISPIF_RDI_1_STATUS_ADDR +
-					(0x200 * vfe_intf))
-					& 0xf) != 0xf) {
-					CDBG("Wait for rdi1 Idle\n");
-				}
-				break;
-
-			case RDI2:
-				while ((msm_camera_io_r(ispif->base +
-					ISPIF_RDI_2_STATUS_ADDR +
-					(0x200 * vfe_intf))
-					& 0xf) != 0xf) {
-					CDBG("Wait for rdi2 Idle\n");
-				}
-				break;
-
-			default:
-				break;
-			}
-			if (intfnum != RDI2)
-				ispif->global_intf_cmd_mask |= (0xFF <<
-					(intfnum * 8));
-		}
-		mask >>= 1;
-		intfnum++;
-	}
-	mutex_unlock(&ispif->mutex);
-	return rc;
-}
-
-static int msm_ispif_subdev_video_s_stream(struct v4l2_subdev *sd,
-	int enable)
-{
-	struct ispif_device *ispif =
-			(struct ispif_device *)v4l2_get_subdevdata(sd);
-	uint32_t cmd = enable & ((1<<ISPIF_S_STREAM_SHIFT)-1);
-	uint16_t intf = enable >> ISPIF_S_STREAM_SHIFT;
-	uint8_t vfe_intf = enable >> ISPIF_VFE_INTF_SHIFT;
-	int rc = -EINVAL;
-	CDBG("%s enable %x, cmd %x, intf %x\n", __func__, enable, cmd, intf);
-	BUG_ON(!ispif);
-	if ((ispif->csid_version <= CSID_VERSION_V2 && vfe_intf > VFE0) ||
-		(ispif->csid_version == CSID_VERSION_V3 &&
-		vfe_intf >= VFE_MAX)) {
-		pr_err("%s invalid csid version %x && vfe intf %d\n", __func__,
-			ispif->csid_version, vfe_intf);
-		return rc;
-	}
-	switch (cmd) {
-	case ISPIF_ON_FRAME_BOUNDARY:
-		rc = msm_ispif_start_intf_transfer(ispif, intf, vfe_intf);
-		break;
-	case ISPIF_OFF_FRAME_BOUNDARY:
-		rc = msm_ispif_stop_intf_transfer(ispif, intf, vfe_intf);
-		break;
-	case ISPIF_OFF_IMMEDIATELY:
-		rc = msm_ispif_abort_intf_transfer(ispif, intf, vfe_intf);
-		break;
-	default:
-		break;
-	}
-	return rc;
-}
-
-static void send_rdi_sof(struct ispif_device *ispif,
-	enum msm_ispif_intftype interface, int count)
-{
-	struct rdi_count_msg sof_msg;
-	sof_msg.rdi_interface = interface;
-	sof_msg.count = count;
-	v4l2_subdev_notify(&ispif->subdev, NOTIFY_AXI_RDI_SOF_COUNT,
-					   (void *)&sof_msg);
-}
-
-static void ispif_do_tasklet(unsigned long data)
-{
-	unsigned long flags;
-
-	struct ispif_isr_queue_cmd *qcmd = NULL;
-	struct ispif_device *ispif;
-
-	ispif = (struct ispif_device *)data;
-	while (atomic_read(&ispif_irq_cnt)) {
-		spin_lock_irqsave(&ispif_tasklet_lock, flags);
-		qcmd = list_first_entry(&ispif_tasklet_q,
-			struct ispif_isr_queue_cmd, list);
-		atomic_sub(1, &ispif_irq_cnt);
-
-		if (!qcmd) {
-			spin_unlock_irqrestore(&ispif_tasklet_lock,
-				flags);
-			return;
-		}
-		list_del(&qcmd->list);
-		spin_unlock_irqrestore(&ispif_tasklet_lock,
-			flags);
-
-		kfree(qcmd);
-	}
-}
-
-static void ispif_process_irq(struct ispif_device *ispif,
-	struct ispif_irq_status *out)
-{
-	unsigned long flags;
-	struct ispif_isr_queue_cmd *qcmd;
-
-	qcmd = kzalloc(sizeof(struct ispif_isr_queue_cmd),
-		GFP_ATOMIC);
-	if (!qcmd) {
-		pr_err("ispif_process_irq: qcmd malloc failed!\n");
-		return;
-	}
-	qcmd->ispifInterruptStatus0 = out->ispifIrqStatus0;
-	qcmd->ispifInterruptStatus1 = out->ispifIrqStatus1;
-	qcmd->ispifInterruptStatus2 = out->ispifIrqStatus2;
-
-	if (qcmd->ispifInterruptStatus0 &
-			ISPIF_IRQ_STATUS_PIX_SOF_MASK) {
-			CDBG("%s: ispif PIX irq status", __func__);
-			ispif->pix_sof_count++;
-			v4l2_subdev_notify(&ispif->subdev,
-				NOTIFY_VFE_PIX_SOF_COUNT,
-				(void *)&ispif->pix_sof_count);
-	}
-
-	if (qcmd->ispifInterruptStatus0 &
-			ISPIF_IRQ_STATUS_RDI0_SOF_MASK) {
-			CDBG("%s: ispif RDI0 irq status", __func__);
-			ispif->rdi0_sof_count++;
-			send_rdi_sof(ispif, RDI_0, ispif->rdi0_sof_count);
-	}
-	if (qcmd->ispifInterruptStatus1 &
-		ISPIF_IRQ_STATUS_RDI1_SOF_MASK) {
-		CDBG("%s: ispif RDI1 irq status", __func__);
-		ispif->rdi1_sof_count++;
-		send_rdi_sof(ispif, RDI_1, ispif->rdi1_sof_count);
-	}
-	if (qcmd->ispifInterruptStatus2 &
-		ISPIF_IRQ_STATUS_RDI2_SOF_MASK) {
-		CDBG("%s: ispif RDI2 irq status", __func__);
-		ispif->rdi2_sof_count++;
-		send_rdi_sof(ispif, RDI_2, ispif->rdi2_sof_count);
-	}
-
-	spin_lock_irqsave(&ispif_tasklet_lock, flags);
-	list_add_tail(&qcmd->list, &ispif_tasklet_q);
-
-	atomic_add(1, &ispif_irq_cnt);
-	spin_unlock_irqrestore(&ispif_tasklet_lock, flags);
-	tasklet_schedule(&ispif->ispif_tasklet);
-	return;
-}
-
-static inline void msm_ispif_read_irq_status(struct ispif_irq_status *out,
-	void *data)
-{
-	uint32_t status0 = 0, status1 = 0, status2 = 0;
-	struct ispif_device *ispif = (struct ispif_device *)data;
-	out->ispifIrqStatus0 = msm_camera_io_r(ispif->base +
-		ISPIF_IRQ_STATUS_ADDR);
-	out->ispifIrqStatus1 = msm_camera_io_r(ispif->base +
-		ISPIF_IRQ_STATUS_1_ADDR);
-	out->ispifIrqStatus2 = msm_camera_io_r(ispif->base +
-		ISPIF_IRQ_STATUS_2_ADDR);
-	msm_camera_io_w(out->ispifIrqStatus0,
-		ispif->base + ISPIF_IRQ_CLEAR_ADDR);
-	msm_camera_io_w(out->ispifIrqStatus1,
-		ispif->base + ISPIF_IRQ_CLEAR_1_ADDR);
-	msm_camera_io_w(out->ispifIrqStatus2,
-		ispif->base + ISPIF_IRQ_CLEAR_2_ADDR);
-
-	CDBG("%s: irq vfe0 Irq_status0 = 0x%x, 1 = 0x%x, 2 = 0x%x\n",
-		__func__, out->ispifIrqStatus0, out->ispifIrqStatus1,
-		out->ispifIrqStatus2);
-	if (out->ispifIrqStatus0 & ISPIF_IRQ_STATUS_MASK) {
-		if (out->ispifIrqStatus0 & (0x1 << RESET_DONE_IRQ))
-			complete(&ispif->reset_complete);
-		if (out->ispifIrqStatus0 & (0x1 << PIX_INTF_0_OVERFLOW_IRQ))
-			pr_err("%s: pix intf 0 overflow.\n", __func__);
-		if (out->ispifIrqStatus0 & (0x1 << RAW_INTF_0_OVERFLOW_IRQ))
-			pr_err("%s: rdi intf 0 overflow.\n", __func__);
-		if (out->ispifIrqStatus1 & (0x1 << RAW_INTF_1_OVERFLOW_IRQ))
-			pr_err("%s: rdi intf 1 overflow.\n", __func__);
-		if (out->ispifIrqStatus2 & (0x1 << RAW_INTF_2_OVERFLOW_IRQ))
-			pr_err("%s: rdi intf 2 overflow.\n", __func__);
-		if ((out->ispifIrqStatus0 & ISPIF_IRQ_STATUS_SOF_MASK) ||
-			(out->ispifIrqStatus1 &	ISPIF_IRQ_STATUS_SOF_MASK) ||
-			(out->ispifIrqStatus2 & ISPIF_IRQ_STATUS_RDI2_SOF_MASK))
-			ispif_process_irq(ispif, out);
-	}
-	if (ispif->csid_version == CSID_VERSION_V3) {
-		status0 = msm_camera_io_r(ispif->base +
-			ISPIF_IRQ_STATUS_ADDR + 0x200);
-		msm_camera_io_w(status0,
-			ispif->base + ISPIF_IRQ_CLEAR_ADDR + 0x200);
-		status1 = msm_camera_io_r(ispif->base +
-			ISPIF_IRQ_STATUS_1_ADDR + 0x200);
-		msm_camera_io_w(status1,
-			ispif->base + ISPIF_IRQ_CLEAR_1_ADDR + 0x200);
-		status2 = msm_camera_io_r(ispif->base +
-			ISPIF_IRQ_STATUS_2_ADDR + 0x200);
-		msm_camera_io_w(status2,
-			ispif->base + ISPIF_IRQ_CLEAR_2_ADDR + 0x200);
-		CDBG("%s: irq vfe1 Irq_status0 = 0x%x, 1 = 0x%x, 2 = 0x%x\n",
-			__func__, status0, status1, status2);
-	}
-	msm_camera_io_w(ISPIF_IRQ_GLOBAL_CLEAR_CMD, ispif->base +
-		ISPIF_IRQ_GLOBAL_CLEAR_CMD_ADDR);
-}
-
-static irqreturn_t msm_io_ispif_irq(int irq_num, void *data)
-{
-	struct ispif_irq_status irq;
-	msm_ispif_read_irq_status(&irq, data);
-	return IRQ_HANDLED;
-}
-
-static struct msm_cam_clk_info ispif_8960_clk_info[] = {
-	{"csi_pix_clk", 0},
-	{"csi_rdi_clk", 0},
-	{"csi_pix1_clk", 0},
-	{"csi_rdi1_clk", 0},
-	{"csi_rdi2_clk", 0},
-};
-
-static int msm_ispif_init(struct ispif_device *ispif,
-	const uint32_t *csid_version)
-{
-	int rc = 0;
-	CDBG("%s called %d\n", __func__, __LINE__);
-
-	if (ispif->ispif_state == ISPIF_POWER_UP) {
-		pr_err("%s: ispif invalid state %d\n", __func__,
-			ispif->ispif_state);
-		rc = -EINVAL;
-		return rc;
-	}
-
-	spin_lock_init(&ispif_tasklet_lock);
-	INIT_LIST_HEAD(&ispif_tasklet_q);
-	rc = request_irq(ispif->irq->start, msm_io_ispif_irq,
-		IRQF_TRIGGER_RISING, "ispif", ispif);
-	ispif->global_intf_cmd_mask = 0xFFFFFFFF;
-	init_completion(&ispif->reset_complete);
-
-	tasklet_init(&ispif->ispif_tasklet,
-		ispif_do_tasklet, (unsigned long)ispif);
-
-	ispif->csid_version = *csid_version;
-	if (ispif->csid_version < CSID_VERSION_V2) {
-		rc = msm_cam_clk_enable(&ispif->pdev->dev, ispif_8960_clk_info,
-			ispif->ispif_clk, 2, 1);
-		if (rc < 0)
-			return rc;
-	} else if (ispif->csid_version == CSID_VERSION_V2) {
-		rc = msm_cam_clk_enable(&ispif->pdev->dev, ispif_8960_clk_info,
-			ispif->ispif_clk, ARRAY_SIZE(ispif_8960_clk_info), 1);
-		if (rc < 0)
-			return rc;
-	}
-	rc = msm_ispif_reset(ispif);
-	ispif->ispif_state = ISPIF_POWER_UP;
-	return rc;
-}
-
-static void msm_ispif_release(struct ispif_device *ispif)
-{
-	if (ispif->ispif_state != ISPIF_POWER_UP) {
-		pr_err("%s: ispif invalid state %d\n", __func__,
-			ispif->ispif_state);
-		return;
-	}
-
-	CDBG("%s, free_irq\n", __func__);
-	free_irq(ispif->irq->start, ispif);
-	tasklet_kill(&ispif->ispif_tasklet);
-
-	if (ispif->csid_version < CSID_VERSION_V2) {
-		msm_cam_clk_enable(&ispif->pdev->dev, ispif_8960_clk_info,
-			ispif->ispif_clk, 2, 0);
-	} else if (ispif->csid_version == CSID_VERSION_V2) {
-		msm_cam_clk_enable(&ispif->pdev->dev, ispif_8960_clk_info,
-			ispif->ispif_clk, ARRAY_SIZE(ispif_8960_clk_info), 0);
-	}
-	ispif->ispif_state = ISPIF_POWER_DOWN;
-}
-
-static long msm_ispif_cmd(struct v4l2_subdev *sd, void *arg)
-{
-	long rc = 0;
-	struct ispif_cfg_data cdata;
-	struct ispif_device *ispif =
-		(struct ispif_device *)v4l2_get_subdevdata(sd);
-	if (copy_from_user(&cdata, (void *)arg, sizeof(struct ispif_cfg_data)))
-		return -EFAULT;
-	CDBG("%s cfgtype = %d\n", __func__, cdata.cfgtype);
-	switch (cdata.cfgtype) {
-	case ISPIF_INIT:
-		CDBG("%s csid_version = %x\n", __func__,
-			cdata.cfg.csid_version);
-		rc = msm_ispif_init(ispif, &cdata.cfg.csid_version);
-		break;
-	case ISPIF_SET_CFG:
-		CDBG("%s len = %d, intftype = %d,.cid_mask = %d, csid = %d\n",
-			__func__,
-			cdata.cfg.ispif_params.len,
-			cdata.cfg.ispif_params.params[0].intftype,
-			cdata.cfg.ispif_params.params[0].cid_mask,
-			cdata.cfg.ispif_params.params[0].csid);
-		rc = msm_ispif_config(ispif, &cdata.cfg.ispif_params);
-		break;
-
-	case ISPIF_SET_ON_FRAME_BOUNDARY:
-	case ISPIF_SET_OFF_FRAME_BOUNDARY:
-	case ISPIF_SET_OFF_IMMEDIATELY:
-		rc = msm_ispif_subdev_video_s_stream(sd, cdata.cfg.cmd);
-		break;
-	case ISPIF_RELEASE:
-		msm_ispif_release(ispif);
-		break;
-	default:
-		break;
-	}
-
-	return rc;
-}
-
-static long msm_ispif_subdev_ioctl(struct v4l2_subdev *sd, unsigned int cmd,
-								void *arg)
-{
-	switch (cmd) {
-	case VIDIOC_MSM_ISPIF_CFG:
-		return msm_ispif_cmd(sd, arg);
-	default:
-		return -ENOIOCTLCMD;
-	}
-}
-
-static struct v4l2_subdev_core_ops msm_ispif_subdev_core_ops = {
-	.g_chip_ident = &msm_ispif_subdev_g_chip_ident,
-	.ioctl = &msm_ispif_subdev_ioctl,
-};
-
-static struct v4l2_subdev_video_ops msm_ispif_subdev_video_ops = {
-	.s_stream = &msm_ispif_subdev_video_s_stream,
-};
-
-static const struct v4l2_subdev_ops msm_ispif_subdev_ops = {
-	.core = &msm_ispif_subdev_core_ops,
-	.video = &msm_ispif_subdev_video_ops,
-};
-
-static const struct v4l2_subdev_internal_ops msm_ispif_internal_ops;
-
-static int __devinit ispif_probe(struct platform_device *pdev)
-{
-	int rc = 0;
-	struct msm_cam_subdev_info sd_info;
-	struct ispif_device *ispif;
-
-	CDBG("%s\n", __func__);
-	ispif = kzalloc(sizeof(struct ispif_device), GFP_KERNEL);
-	if (!ispif) {
-		pr_err("%s: no enough memory\n", __func__);
-		return -ENOMEM;
-	}
-
-	v4l2_subdev_init(&ispif->subdev, &msm_ispif_subdev_ops);
-	ispif->subdev.internal_ops = &msm_ispif_internal_ops;
-	ispif->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	snprintf(ispif->subdev.name,
-			ARRAY_SIZE(ispif->subdev.name), "msm_ispif");
-	v4l2_set_subdevdata(&ispif->subdev, ispif);
-	platform_set_drvdata(pdev, &ispif->subdev);
-	snprintf(ispif->subdev.name, sizeof(ispif->subdev.name),
-								"ispif");
-	mutex_init(&ispif->mutex);
-
-	if (pdev->dev.of_node)
-		of_property_read_u32((&pdev->dev)->of_node,
-			"cell-index", &pdev->id);
-
-	ispif->mem = platform_get_resource_byname(pdev,
-					IORESOURCE_MEM, "ispif");
-	if (!ispif->mem) {
-		pr_err("%s: no mem resource?\n", __func__);
-		rc = -ENODEV;
-		goto ispif_no_resource;
-	}
-	ispif->irq = platform_get_resource_byname(pdev,
-					IORESOURCE_IRQ, "ispif");
-	if (!ispif->irq) {
-		pr_err("%s: no irq resource?\n", __func__);
-		rc = -ENODEV;
-		goto ispif_no_resource;
-	}
-	ispif->io = request_mem_region(ispif->mem->start,
-		resource_size(ispif->mem), pdev->name);
-	if (!ispif->io) {
-		pr_err("%s: no valid mem region\n", __func__);
-		rc = -EBUSY;
-		goto ispif_no_resource;
-	}
-	ispif->base = ioremap(ispif->mem->start,
-		resource_size(ispif->mem));
-	if (!ispif->base) {
-		rc = -ENOMEM;
-		goto ispif_no_mem;
-	}
-
-	ispif->pdev = pdev;
-	sd_info.sdev_type = ISPIF_DEV;
-	sd_info.sd_index = pdev->id;
-	sd_info.irq_num = ispif->irq->start;
-	msm_cam_register_subdev_node(&ispif->subdev, &sd_info);
-
-	media_entity_init(&ispif->subdev.entity, 0, NULL, 0);
-	ispif->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
-	ispif->subdev.entity.group_id = ISPIF_DEV;
-	ispif->subdev.entity.name = pdev->name;
-	ispif->subdev.entity.revision = ispif->subdev.devnode->num;
-	ispif->ispif_state = ISPIF_POWER_DOWN;
-	return 0;
-
-ispif_no_mem:
-	release_mem_region(ispif->mem->start,
-		resource_size(ispif->mem));
-ispif_no_resource:
-	mutex_destroy(&ispif->mutex);
-	kfree(ispif);
-	return rc;
-}
-
-static const struct of_device_id msm_ispif_dt_match[] = {
-	{.compatible = "qcom,ispif"},
-};
-
-MODULE_DEVICE_TABLE(of, msm_ispif_dt_match);
-
-static struct platform_driver ispif_driver = {
-	.probe = ispif_probe,
-	.driver = {
-		.name = MSM_ISPIF_DRV_NAME,
-		.owner = THIS_MODULE,
-		.of_match_table = msm_ispif_dt_match,
-	},
-};
-
-static int __init msm_ispif_init_module(void)
-{
-	return platform_driver_register(&ispif_driver);
-}
-
-static void __exit msm_ispif_exit_module(void)
-{
-	platform_driver_unregister(&ispif_driver);
-}
-
-module_init(msm_ispif_init_module);
-module_exit(msm_ispif_exit_module);
-MODULE_DESCRIPTION("MSM ISP Interface driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/csi/msm_ispif.h b/drivers/media/platform/msm/camera_v1/csi/msm_ispif.h
deleted file mode 100644
index cb7bd80..0000000
--- a/drivers/media/platform/msm/camera_v1/csi/msm_ispif.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-
-#ifndef MSM_ISPIF_H
-#define MSM_ISPIF_H
-
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <media/v4l2-subdev.h>
-
-struct ispif_irq_status {
-	uint32_t ispifIrqStatus0;
-	uint32_t ispifIrqStatus1;
-	uint32_t ispifIrqStatus2;
-};
-
-enum msm_ispif_state_t {
-	ISPIF_POWER_UP,
-	ISPIF_POWER_DOWN,
-};
-
-struct ispif_device {
-	struct platform_device *pdev;
-	struct v4l2_subdev subdev;
-	struct resource *mem;
-	struct resource *irq;
-	struct resource *io;
-	void __iomem *base;
-	struct mutex mutex;
-	uint8_t start_ack_pending;
-	struct completion reset_complete;
-	uint32_t csid_version;
-	struct clk *ispif_clk[5];
-	uint32_t pix_sof_count;
-	uint32_t rdi0_sof_count;
-	uint32_t rdi1_sof_count;
-	uint32_t rdi2_sof_count;
-	uint32_t global_intf_cmd_mask;
-	struct tasklet_struct ispif_tasklet;
-	enum msm_ispif_state_t ispif_state;
-};
-
-struct ispif_isr_queue_cmd {
-	struct list_head list;
-	uint32_t    ispifInterruptStatus0;
-	uint32_t    ispifInterruptStatus1;
-	uint32_t    ispifInterruptStatus2;
-};
-
-#define VIDIOC_MSM_ISPIF_CFG \
-	_IOWR('V', BASE_VIDIOC_PRIVATE + 18, struct ispif_cfg_data*)
-
-#endif
diff --git a/drivers/media/platform/msm/camera_v1/eeprom/Makefile b/drivers/media/platform/msm/camera_v1/eeprom/Makefile
deleted file mode 100644
index 6474aee..0000000
--- a/drivers/media/platform/msm/camera_v1/eeprom/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-GCC_VERSION      := $(shell $(CONFIG_SHELL) $(PWD)/scripts/gcc-version.sh $(CROSS_COMPILE)gcc)
-EXTRA_CFLAGS += -Idrivers/media/platform/msm/camera_v1/io
-obj-$(CONFIG_MSM_EEPROM) += msm_camera_eeprom.o
-obj-$(CONFIG_IMX074_EEPROM) += imx074_eeprom.o
-obj-$(CONFIG_IMX091_EEPROM) += imx091_eeprom.o
\ No newline at end of file
diff --git a/drivers/media/platform/msm/camera_v1/eeprom/imx074_eeprom.c b/drivers/media/platform/msm/camera_v1/eeprom/imx074_eeprom.c
deleted file mode 100644
index eafa9a8..0000000
--- a/drivers/media/platform/msm/camera_v1/eeprom/imx074_eeprom.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/module.h>
-#include "msm_camera_eeprom.h"
-#include "msm_camera_i2c.h"
-
-DEFINE_MUTEX(imx074_eeprom_mutex);
-static struct msm_eeprom_ctrl_t imx074_eeprom_t;
-
-static const struct i2c_device_id imx074_eeprom_i2c_id[] = {
-	{"imx074_eeprom", (kernel_ulong_t)&imx074_eeprom_t},
-	{ }
-};
-
-static struct i2c_driver imx074_eeprom_i2c_driver = {
-	.id_table = imx074_eeprom_i2c_id,
-	.probe  = msm_eeprom_i2c_probe,
-	.remove = __exit_p(imx074_eeprom_i2c_remove),
-	.driver = {
-		.name = "imx074_eeprom",
-	},
-};
-
-static int __init imx074_eeprom_i2c_add_driver(void)
-{
-	int rc = 0;
-	rc = i2c_add_driver(imx074_eeprom_t.i2c_driver);
-	return rc;
-}
-
-static struct v4l2_subdev_core_ops imx074_eeprom_subdev_core_ops = {
-	.ioctl = msm_eeprom_subdev_ioctl,
-};
-
-static struct v4l2_subdev_ops imx074_eeprom_subdev_ops = {
-	.core = &imx074_eeprom_subdev_core_ops,
-};
-
-static uint8_t imx074_wbcalib_data[6];
-static struct msm_calib_wb imx074_wb_data;
-
-static struct msm_camera_eeprom_info_t imx074_calib_supp_info = {
-	{FALSE, 0, 0, 1},
-	{TRUE, 6, 0, 1024},
-	{FALSE, 0, 0, 1},
-	{FALSE, 0, 0, 1},
-	{FALSE, 0, 0, 1},
-};
-
-static struct msm_camera_eeprom_read_t imx074_eeprom_read_tbl[] = {
-	{0x10, &imx074_wbcalib_data[0], 6, 0},
-};
-
-
-static struct msm_camera_eeprom_data_t imx074_eeprom_data_tbl[] = {
-	{&imx074_wb_data, sizeof(struct msm_calib_wb)},
-};
-
-static void imx074_format_wbdata(void)
-{
-	imx074_wb_data.r_over_g = (uint16_t)(imx074_wbcalib_data[0] << 8) |
-		imx074_wbcalib_data[1];
-	imx074_wb_data.b_over_g = (uint16_t)(imx074_wbcalib_data[2] << 8) |
-		imx074_wbcalib_data[3];
-	imx074_wb_data.gr_over_gb = (uint16_t)(imx074_wbcalib_data[4] << 8) |
-		imx074_wbcalib_data[5];
-}
-
-void imx074_format_calibrationdata(void)
-{
-	imx074_format_wbdata();
-}
-static struct msm_eeprom_ctrl_t imx074_eeprom_t = {
-	.i2c_driver = &imx074_eeprom_i2c_driver,
-	.i2c_addr = 0xA4,
-	.eeprom_v4l2_subdev_ops = &imx074_eeprom_subdev_ops,
-
-	.i2c_client = {
-		.addr_type = MSM_CAMERA_I2C_BYTE_ADDR,
-	},
-
-	.eeprom_mutex = &imx074_eeprom_mutex,
-
-	.func_tbl = {
-		.eeprom_init = NULL,
-		.eeprom_release = NULL,
-		.eeprom_get_info = msm_camera_eeprom_get_info,
-		.eeprom_get_data = msm_camera_eeprom_get_data,
-		.eeprom_set_dev_addr = NULL,
-		.eeprom_format_data = imx074_format_calibrationdata,
-	},
-	.info = &imx074_calib_supp_info,
-	.info_size = sizeof(struct msm_camera_eeprom_info_t),
-	.read_tbl = imx074_eeprom_read_tbl,
-	.read_tbl_size = ARRAY_SIZE(imx074_eeprom_read_tbl),
-	.data_tbl = imx074_eeprom_data_tbl,
-	.data_tbl_size = ARRAY_SIZE(imx074_eeprom_data_tbl),
-};
-
-subsys_initcall(imx074_eeprom_i2c_add_driver);
-MODULE_DESCRIPTION("IMX074 EEPROM");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/eeprom/imx091_eeprom.c b/drivers/media/platform/msm/camera_v1/eeprom/imx091_eeprom.c
deleted file mode 100644
index 20624ac..0000000
--- a/drivers/media/platform/msm/camera_v1/eeprom/imx091_eeprom.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/module.h>
-#include "msm_camera_eeprom.h"
-#include "msm_camera_i2c.h"
-
-DEFINE_MUTEX(imx091_eeprom_mutex);
-static struct msm_eeprom_ctrl_t imx091_eeprom_t;
-
-static const struct i2c_device_id imx091_eeprom_i2c_id[] = {
-	{"imx091_eeprom", (kernel_ulong_t)&imx091_eeprom_t},
-	{ }
-};
-
-static struct i2c_driver imx091_eeprom_i2c_driver = {
-	.id_table = imx091_eeprom_i2c_id,
-	.probe  = msm_eeprom_i2c_probe,
-	.remove = __exit_p(imx091_eeprom_i2c_remove),
-	.driver = {
-		.name = "imx091_eeprom",
-	},
-};
-
-static int __init imx091_eeprom_i2c_add_driver(void)
-{
-	int rc = 0;
-	rc = i2c_add_driver(imx091_eeprom_t.i2c_driver);
-	return rc;
-}
-
-static struct v4l2_subdev_core_ops imx091_eeprom_subdev_core_ops = {
-	.ioctl = msm_eeprom_subdev_ioctl,
-};
-
-static struct v4l2_subdev_ops imx091_eeprom_subdev_ops = {
-	.core = &imx091_eeprom_subdev_core_ops,
-};
-
-static uint8_t imx091_wbcalib_data[6];
-static uint8_t imx091_afcalib_data[6];
-static struct msm_calib_wb imx091_wb_data;
-static struct msm_calib_af imx091_af_data;
-
-static struct msm_camera_eeprom_info_t imx091_calib_supp_info = {
-	{TRUE, 6, 1, 1},
-	{TRUE, 6, 0, 32768},
-	{FALSE, 0, 0, 1},
-	{FALSE, 0, 0, 1},
-	{FALSE, 0, 0, 1},
-};
-
-static struct msm_camera_eeprom_read_t imx091_eeprom_read_tbl[] = {
-	{0x05, &imx091_wbcalib_data[0], 6, 0},
-	{0x0B, &imx091_afcalib_data[0], 6, 0},
-};
-
-
-static struct msm_camera_eeprom_data_t imx091_eeprom_data_tbl[] = {
-	{&imx091_wb_data, sizeof(struct msm_calib_wb)},
-	{&imx091_af_data, sizeof(struct msm_calib_af)},
-};
-
-static void imx091_format_wbdata(void)
-{
-	imx091_wb_data.r_over_g = (uint16_t)(imx091_wbcalib_data[1] << 8) |
-		(imx091_wbcalib_data[0] - 0x32);
-	imx091_wb_data.b_over_g = (uint16_t)(imx091_wbcalib_data[3] << 8) |
-		(imx091_wbcalib_data[2] - 0x32);
-	imx091_wb_data.gr_over_gb = (uint16_t)(imx091_wbcalib_data[5] << 8) |
-		(imx091_wbcalib_data[4] - 0x32);
-}
-
-static void imx091_format_afdata(void)
-{
-	imx091_af_data.inf_dac = (uint16_t)(imx091_afcalib_data[1] << 8) |
-		imx091_afcalib_data[0];
-	imx091_af_data.macro_dac = (uint16_t)(imx091_afcalib_data[3] << 8) |
-		imx091_afcalib_data[2];
-	imx091_af_data.start_dac = (uint16_t)(imx091_afcalib_data[5] << 8) |
-		imx091_afcalib_data[4];
-}
-
-void imx091_format_calibrationdata(void)
-{
-	imx091_format_wbdata();
-	imx091_format_afdata();
-}
-static struct msm_eeprom_ctrl_t imx091_eeprom_t = {
-	.i2c_driver = &imx091_eeprom_i2c_driver,
-	.i2c_addr = 0xA1,
-	.eeprom_v4l2_subdev_ops = &imx091_eeprom_subdev_ops,
-
-	.i2c_client = {
-		.addr_type = MSM_CAMERA_I2C_BYTE_ADDR,
-	},
-
-	.eeprom_mutex = &imx091_eeprom_mutex,
-
-	.func_tbl = {
-		.eeprom_init = NULL,
-		.eeprom_release = NULL,
-		.eeprom_get_info = msm_camera_eeprom_get_info,
-		.eeprom_get_data = msm_camera_eeprom_get_data,
-		.eeprom_set_dev_addr = NULL,
-		.eeprom_format_data = imx091_format_calibrationdata,
-	},
-	.info = &imx091_calib_supp_info,
-	.info_size = sizeof(struct msm_camera_eeprom_info_t),
-	.read_tbl = imx091_eeprom_read_tbl,
-	.read_tbl_size = ARRAY_SIZE(imx091_eeprom_read_tbl),
-	.data_tbl = imx091_eeprom_data_tbl,
-	.data_tbl_size = ARRAY_SIZE(imx091_eeprom_data_tbl),
-};
-
-subsys_initcall(imx091_eeprom_i2c_add_driver);
-MODULE_DESCRIPTION("imx091 EEPROM");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/eeprom/msm_camera_eeprom.c b/drivers/media/platform/msm/camera_v1/eeprom/msm_camera_eeprom.c
deleted file mode 100644
index a1b809f..0000000
--- a/drivers/media/platform/msm/camera_v1/eeprom/msm_camera_eeprom.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-#include "msm_camera_eeprom.h"
-
-int32_t msm_camera_eeprom_read(struct msm_eeprom_ctrl_t *ectrl,
-	uint32_t reg_addr, void *data, uint32_t num_byte,
-	uint16_t convert_endian)
-{
-	int rc = 0;
-	if (ectrl->func_tbl.eeprom_set_dev_addr != NULL)
-		ectrl->func_tbl.eeprom_set_dev_addr(ectrl, &reg_addr);
-
-	if (!convert_endian) {
-		rc = msm_camera_i2c_read_seq(
-			&ectrl->i2c_client, reg_addr, data, num_byte);
-	} else {
-		unsigned char buf[num_byte];
-		uint8_t *data_ptr = (uint8_t *) data;
-		int i;
-		rc = msm_camera_i2c_read_seq(
-			&ectrl->i2c_client, reg_addr, buf, num_byte);
-		for (i = 0; i < num_byte; i += 2) {
-			data_ptr[i] = buf[i+1];
-			data_ptr[i+1] = buf[i];
-		}
-	}
-	return rc;
-}
-
-int32_t msm_camera_eeprom_read_tbl(struct msm_eeprom_ctrl_t *ectrl,
-	struct msm_camera_eeprom_read_t *read_tbl, uint16_t tbl_size)
-{
-	int i, rc = 0;
-	CDBG("%s: open\n", __func__);
-	if (read_tbl == NULL)
-		return rc;
-
-	for (i = 0; i < tbl_size; i++) {
-		rc = msm_camera_eeprom_read
-			(ectrl, read_tbl[i].reg_addr,
-			read_tbl[i].dest_ptr, read_tbl[i].num_byte,
-			read_tbl[i].convert_endian);
-		if (rc < 0) {
-			pr_err("%s: read failed\n", __func__);
-			return rc;
-		}
-	}
-	CDBG("%s: done\n", __func__);
-	return rc;
-}
-
-int32_t msm_camera_eeprom_get_info(struct msm_eeprom_ctrl_t *ectrl,
-	struct msm_camera_eeprom_info_t *einfo)
-{
-	int rc = 0;
-	CDBG("%s: open\n", __func__);
-	memcpy(einfo, ectrl->info, ectrl->info_size);
-	CDBG("%s: done =%d\n", __func__, rc);
-	return rc;
-}
-
-int32_t msm_camera_eeprom_get_data(struct msm_eeprom_ctrl_t *ectrl,
-	struct msm_eeprom_data_t *edata)
-{
-	int rc = 0;
-	if (edata->index >= ectrl->data_tbl_size)
-		return -EFAULT;
-	if (copy_to_user(edata->eeprom_data,
-		ectrl->data_tbl[edata->index].data,
-		ectrl->data_tbl[edata->index].size))
-		rc = -EFAULT;
-	return rc;
-}
-
-int32_t msm_eeprom_config(struct msm_eeprom_ctrl_t *e_ctrl,
-	void __user *argp)
-{
-	struct msm_eeprom_cfg_data cdata;
-	int32_t rc = 0;
-	if (copy_from_user(&cdata,
-		(void *)argp,
-		sizeof(struct msm_eeprom_cfg_data)))
-		return -EFAULT;
-	mutex_lock(e_ctrl->eeprom_mutex);
-
-	switch (cdata.cfgtype) {
-	case CFG_GET_EEPROM_INFO:
-		if (e_ctrl->func_tbl.eeprom_get_info == NULL) {
-			rc = -EFAULT;
-			break;
-		}
-		rc = e_ctrl->func_tbl.eeprom_get_info(e_ctrl,
-			&cdata.cfg.get_info);
-		cdata.is_eeprom_supported = 1;
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct msm_eeprom_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_GET_EEPROM_DATA:
-		if (e_ctrl->func_tbl.eeprom_get_data == NULL) {
-			rc = -EFAULT;
-			break;
-		}
-		rc = e_ctrl->func_tbl.eeprom_get_data(e_ctrl,
-			&cdata.cfg.get_data);
-
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct msm_eeprom_cfg_data)))
-			rc = -EFAULT;
-		break;
-	default:
-		break;
-	}
-	mutex_unlock(e_ctrl->eeprom_mutex);
-	return rc;
-}
-
-struct msm_eeprom_ctrl_t *get_ectrl(struct v4l2_subdev *sd)
-{
-	return container_of(sd, struct msm_eeprom_ctrl_t, sdev);
-}
-
-long msm_eeprom_subdev_ioctl(struct v4l2_subdev *sd,
-	unsigned int cmd, void *arg)
-{
-	struct msm_eeprom_ctrl_t *e_ctrl = get_ectrl(sd);
-	void __user *argp = (void __user *)arg;
-	switch (cmd) {
-	case VIDIOC_MSM_EEPROM_CFG:
-		return msm_eeprom_config(e_ctrl, argp);
-	default:
-		return -ENOIOCTLCMD;
-	}
-}
-
-int32_t msm_eeprom_i2c_probe(struct i2c_client *client,
-	const struct i2c_device_id *id)
-{
-	int rc = 0;
-	struct msm_eeprom_ctrl_t *e_ctrl_t = NULL;
-	CDBG("%s called\n", __func__);
-
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		pr_err("i2c_check_functionality failed\n");
-		goto probe_failure;
-	}
-
-	e_ctrl_t = (struct msm_eeprom_ctrl_t *)(id->driver_data);
-	e_ctrl_t->i2c_client.client = client;
-
-	if (e_ctrl_t->i2c_addr != 0)
-		e_ctrl_t->i2c_client.client->addr = e_ctrl_t->i2c_addr;
-
-	CDBG("%s client = %x\n", __func__, (unsigned int) client);
-
-	/* Assign name for sub device */
-	snprintf(e_ctrl_t->sdev.name, sizeof(e_ctrl_t->sdev.name),
-		"%s", e_ctrl_t->i2c_driver->driver.name);
-
-	if (e_ctrl_t->func_tbl.eeprom_init != NULL) {
-		rc = e_ctrl_t->func_tbl.eeprom_init(e_ctrl_t,
-			e_ctrl_t->i2c_client.client->adapter);
-	}
-	msm_camera_eeprom_read_tbl(e_ctrl_t,
-		e_ctrl_t->read_tbl,
-		e_ctrl_t->read_tbl_size);
-
-	if (e_ctrl_t->func_tbl.eeprom_format_data != NULL)
-		e_ctrl_t->func_tbl.eeprom_format_data();
-
-	if (e_ctrl_t->func_tbl.eeprom_release != NULL)
-		rc = e_ctrl_t->func_tbl.eeprom_release(e_ctrl_t);
-
-
-	/* Initialize sub device */
-	v4l2_i2c_subdev_init(&e_ctrl_t->sdev,
-		e_ctrl_t->i2c_client.client,
-		e_ctrl_t->eeprom_v4l2_subdev_ops);
-	CDBG("%s success resut=%d\n", __func__, rc);
-	return rc;
-
-probe_failure:
-	pr_err("%s failed! rc = %d\n", __func__, rc);
-	return rc;
-}
diff --git a/drivers/media/platform/msm/camera_v1/eeprom/msm_camera_eeprom.h b/drivers/media/platform/msm/camera_v1/eeprom/msm_camera_eeprom.h
deleted file mode 100644
index 05b4533..0000000
--- a/drivers/media/platform/msm/camera_v1/eeprom/msm_camera_eeprom.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-#ifndef MSM_CAMERA_EEPROM_H
-#define MSM_CAMERA_EEPROM_H
-
-#include <linux/delay.h>
-#include <mach/camera.h>
-#include <media/v4l2-subdev.h>
-#include "msm_camera_i2c.h"
-
-#define TRUE  1
-#define FALSE 0
-
-struct msm_eeprom_ctrl_t;
-
-struct msm_camera_eeprom_fn_t {
-	int32_t (*eeprom_init)
-		(struct msm_eeprom_ctrl_t *ectrl,
-		struct i2c_adapter *adapter);
-	int32_t (*eeprom_release)
-		(struct msm_eeprom_ctrl_t *ectrl);
-	int32_t (*eeprom_get_info)
-		(struct msm_eeprom_ctrl_t *ectrl,
-		 struct msm_camera_eeprom_info_t *einfo);
-	int32_t (*eeprom_get_data)
-		(struct msm_eeprom_ctrl_t *ectrl,
-		 struct msm_eeprom_data_t *edata);
-	void (*eeprom_set_dev_addr)
-		(struct msm_eeprom_ctrl_t*, uint32_t*);
-	void (*eeprom_format_data)
-		(void);
-};
-
-struct msm_camera_eeprom_read_t {
-	uint32_t reg_addr;
-	void *dest_ptr;
-	uint32_t num_byte;
-	uint16_t convert_endian;
-};
-
-struct msm_camera_eeprom_data_t {
-	void *data;
-	uint16_t size;
-};
-
-struct msm_eeprom_ctrl_t {
-	struct msm_camera_i2c_client i2c_client;
-	uint16_t i2c_addr;
-	struct i2c_driver *i2c_driver;
-	struct mutex *eeprom_mutex;
-	struct v4l2_subdev sdev;
-	struct v4l2_subdev_ops *eeprom_v4l2_subdev_ops;
-	struct msm_camera_eeprom_fn_t func_tbl;
-	struct msm_camera_eeprom_info_t *info;
-	uint16_t info_size;
-	struct msm_camera_eeprom_read_t *read_tbl;
-	uint16_t read_tbl_size;
-	struct msm_camera_eeprom_data_t *data_tbl;
-	uint16_t data_tbl_size;
-};
-
-int32_t msm_camera_eeprom_get_data(struct msm_eeprom_ctrl_t *ectrl,
-	struct msm_eeprom_data_t *edata);
-int32_t msm_camera_eeprom_get_info(struct msm_eeprom_ctrl_t *ectrl,
-	struct msm_camera_eeprom_info_t *einfo);
-int32_t msm_eeprom_i2c_probe(struct i2c_client *client,
-	const struct i2c_device_id *id);
-long msm_eeprom_subdev_ioctl(struct v4l2_subdev *sd,
-	unsigned int cmd, void *arg);
-
-#define VIDIOC_MSM_EEPROM_CFG \
-	_IOWR('V', BASE_VIDIOC_PRIVATE + 12, void __user *)
-#endif
diff --git a/drivers/media/platform/msm/camera_v1/flash/Makefile b/drivers/media/platform/msm/camera_v1/flash/Makefile
deleted file mode 100644
index ad1d452..0000000
--- a/drivers/media/platform/msm/camera_v1/flash/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-GCC_VERSION      := $(shell $(CONFIG_SHELL) $(PWD)/scripts/gcc-version.sh $(CROSS_COMPILE)gcc)
-ccflags-y += -Idrivers/media/platform/msm/camera_v1
-ccflags-y += -Idrivers/media/platform/msm/camera_v1/io
-obj-$(CONFIG_MSM_CAMERA_FLASH) += msm_flash.o
-obj-$(CONFIG_MSM_CAMERA_FLASH_SC628A) += sc628a.o
-obj-$(CONFIG_MSM_CAMERA_FLASH_TPS61310) += tps61310.o
-obj-$(CONFIG_MSM_CAMERA_FLASH_PMIC_FLASH) += pmic8058_flash.o
-obj-$(CONFIG_MSM_CAMERA_FLASH_SGM3141) += sgm3141.o
-obj-$(CONFIG_MSM_CAMERA_FLASH_PMIC8058_PWM) += pmic8058_pwm.o
-obj-$(CONFIG_MSM_CAMERA_LED_TRIGGER_FLASH) += led_trigger_flash.o
diff --git a/drivers/media/platform/msm/camera_v1/flash/led_trigger_flash.c b/drivers/media/platform/msm/camera_v1/flash/led_trigger_flash.c
deleted file mode 100644
index cd34cde..0000000
--- a/drivers/media/platform/msm/camera_v1/flash/led_trigger_flash.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- *
- */
-#include <linux/module.h>
-#include <linux/export.h>
-#include "msm_flash.h"
-
-#define FLASH_NAME "camera-led-flash"
-static struct msm_flash_ctrl_t fctrl;
-
-static int msm_camera_led_trigger_flash(struct msm_flash_ctrl_t *fctrl,
-	uint8_t led_state)
-{
-	int rc = 0;
-	CDBG("%s:%d called led_state %d\n", __func__, __LINE__, led_state);
-
-	if (!fctrl->led_trigger[0]) {
-		pr_err("%s:%d failed\n", __func__, __LINE__);
-		return -EINVAL;
-	}
-	switch (led_state) {
-	case MSM_CAMERA_LED_OFF:
-		led_trigger_event(fctrl->led_trigger[0], 0);
-		break;
-
-	case MSM_CAMERA_LED_LOW:
-		led_trigger_event(fctrl->led_trigger[0],
-			fctrl->max_current[0] / 2);
-		break;
-
-	case MSM_CAMERA_LED_HIGH:
-		led_trigger_event(fctrl->led_trigger[0], fctrl->max_current[0]);
-		break;
-
-	case MSM_CAMERA_LED_INIT:
-	case MSM_CAMERA_LED_RELEASE:
-		led_trigger_event(fctrl->led_trigger[0], 0);
-		break;
-
-	default:
-		rc = -EFAULT;
-		break;
-	}
-	CDBG("flash_set_led_state: return %d\n", rc);
-	return rc;
-}
-
-static const struct of_device_id msm_camera_flash_dt_match[] = {
-	{.compatible = "qcom,camera-led-flash"},
-	{}
-};
-
-MODULE_DEVICE_TABLE(of, msm_camera_flash_dt_match);
-
-static struct platform_driver msm_led_trigger_flash_driver = {
-	.driver = {
-		.name = FLASH_NAME,
-		.owner = THIS_MODULE,
-		.of_match_table = msm_camera_flash_dt_match,
-	},
-};
-
-static int32_t msm_led_trigger_flash_probe(struct platform_device *pdev)
-{
-	int32_t rc = 0, i = 0;
-	struct device_node *of_node = pdev->dev.of_node;
-	struct device_node *flash_src_node = NULL;
-	uint32_t count = 0;
-
-	CDBG("%s called\n", __func__);
-
-	if (!of_node) {
-		pr_err("%s of_node NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	fctrl.pdev = pdev;
-
-	rc = of_property_read_u32(of_node, "cell-index", &pdev->id);
-	if (rc < 0) {
-		pr_err("%s:%d failed\n", __func__, __LINE__);
-		return -EINVAL;
-	}
-	CDBG("%s:%d pdev id %d\n", __func__, __LINE__, pdev->id);
-
-	if (of_get_property(of_node, "qcom,flash-source", &count)) {
-		count /= sizeof(uint32_t);
-		CDBG("%s count %d\n", __func__, count);
-		if (count > MAX_LED_TRIGGERS) {
-			pr_err("%s:%d failed\n", __func__, __LINE__);
-			return -EINVAL;
-		}
-		for (i = 0; i < count; i++) {
-			flash_src_node = of_parse_phandle(of_node,
-				"qcom,flash-source", i);
-			if (!flash_src_node) {
-				pr_err("%s:%d flash_src_node NULL\n", __func__,
-					__LINE__);
-				continue;
-			}
-
-			rc = of_property_read_string(flash_src_node,
-				"linux,default-trigger",
-				&fctrl.led_trigger_name[i]);
-			if (rc < 0) {
-				pr_err("%s:%d failed\n", __func__, __LINE__);
-				of_node_put(flash_src_node);
-				continue;
-			}
-
-			CDBG("%s default trigger %s\n", __func__,
-				fctrl.led_trigger_name[i]);
-
-			rc = of_property_read_u32(flash_src_node,
-				"qcom,max-current", &fctrl.max_current[i]);
-			if (rc < 0) {
-				pr_err("%s:%d failed rc %d\n", __func__,
-					__LINE__, rc);
-				of_node_put(flash_src_node);
-				continue;
-			}
-
-			of_node_put(flash_src_node);
-
-			CDBG("%s max_current[%d] %d\n", __func__, i,
-				fctrl.max_current[i]);
-
-			led_trigger_register_simple(fctrl.led_trigger_name[i],
-				&fctrl.led_trigger[i]);
-		}
-	}
-	rc = msm_flash_platform_probe(pdev, &fctrl);
-	return rc;
-}
-
-static int __init msm_flash_add_driver(void)
-{
-	CDBG("%s called\n", __func__);
-	return platform_driver_probe(&msm_led_trigger_flash_driver,
-		msm_led_trigger_flash_probe);
-}
-
-static struct msm_flash_fn_t msm_led_trigger_flash_func_tbl = {
-	.flash_led_config = msm_camera_led_trigger_flash,
-};
-
-static struct msm_flash_ctrl_t fctrl = {
-	.func_tbl = &msm_led_trigger_flash_func_tbl,
-};
-
-module_init(msm_flash_add_driver);
-MODULE_DESCRIPTION("LED TRIGGER FLASH");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/flash/msm_flash.c b/drivers/media/platform/msm/camera_v1/flash/msm_flash.c
deleted file mode 100644
index 6639a4b..0000000
--- a/drivers/media/platform/msm/camera_v1/flash/msm_flash.c
+++ /dev/null
@@ -1,514 +0,0 @@
-/* Copyright (c) 2009-2012, The Linux Foundation. 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.
- *
- */
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/hrtimer.h>
-#include <linux/export.h>
-#include <linux/of.h>
-#include <mach/pmic.h>
-#include <mach/camera.h>
-#include <mach/gpio.h>
-#include "msm_flash.h"
-#include "msm.h"
-
-static struct timer_list timer_flash;
-
-enum msm_cam_flash_stat {
-	MSM_CAM_FLASH_OFF,
-	MSM_CAM_FLASH_ON,
-};
-
-static int config_flash_gpio_table(enum msm_cam_flash_stat stat,
-			struct msm_camera_sensor_strobe_flash_data *sfdata)
-{
-	int rc = 0, i = 0;
-	int msm_cam_flash_gpio_tbl[][2] = {
-		{sfdata->flash_trigger, 1},
-		{sfdata->flash_charge, 1},
-		{sfdata->flash_charge_done, 0}
-	};
-
-	if (stat == MSM_CAM_FLASH_ON) {
-		for (i = 0; i < ARRAY_SIZE(msm_cam_flash_gpio_tbl); i++) {
-			rc = gpio_request(msm_cam_flash_gpio_tbl[i][0],
-							  "CAM_FLASH_GPIO");
-			if (unlikely(rc < 0)) {
-				pr_err("%s not able to get gpio\n", __func__);
-				for (i--; i >= 0; i--)
-					gpio_free(msm_cam_flash_gpio_tbl[i][0]);
-				break;
-			}
-			if (msm_cam_flash_gpio_tbl[i][1])
-				gpio_direction_output(
-					msm_cam_flash_gpio_tbl[i][0], 0);
-			else
-				gpio_direction_input(
-					msm_cam_flash_gpio_tbl[i][0]);
-		}
-	} else {
-		for (i = 0; i < ARRAY_SIZE(msm_cam_flash_gpio_tbl); i++) {
-			gpio_direction_input(msm_cam_flash_gpio_tbl[i][0]);
-			gpio_free(msm_cam_flash_gpio_tbl[i][0]);
-		}
-	}
-	return rc;
-}
-
-static int msm_strobe_flash_xenon_charge(int32_t flash_charge,
-		int32_t charge_enable, uint32_t flash_recharge_duration)
-{
-	gpio_set_value_cansleep(flash_charge, charge_enable);
-	if (charge_enable) {
-		timer_flash.expires = jiffies +
-			msecs_to_jiffies(flash_recharge_duration);
-		/* add timer for the recharge */
-		if (!timer_pending(&timer_flash))
-			add_timer(&timer_flash);
-	} else
-		del_timer_sync(&timer_flash);
-	return 0;
-}
-
-static void strobe_flash_xenon_recharge_handler(unsigned long data)
-{
-	unsigned long flags;
-	struct msm_camera_sensor_strobe_flash_data *sfdata =
-		(struct msm_camera_sensor_strobe_flash_data *)data;
-
-	spin_lock_irqsave(&sfdata->timer_lock, flags);
-	msm_strobe_flash_xenon_charge(sfdata->flash_charge, 1,
-		sfdata->flash_recharge_duration);
-	spin_unlock_irqrestore(&sfdata->timer_lock, flags);
-
-	return;
-}
-
-static irqreturn_t strobe_flash_charge_ready_irq(int irq_num, void *data)
-{
-	struct msm_camera_sensor_strobe_flash_data *sfdata =
-		(struct msm_camera_sensor_strobe_flash_data *)data;
-
-	/* put the charge signal to low */
-	gpio_set_value_cansleep(sfdata->flash_charge, 0);
-
-	return IRQ_HANDLED;
-}
-
-static int msm_strobe_flash_xenon_init(
-	struct msm_camera_sensor_strobe_flash_data *sfdata)
-{
-	unsigned long flags;
-	int rc = 0;
-
-	spin_lock_irqsave(&sfdata->spin_lock, flags);
-	if (!sfdata->state) {
-
-		rc = config_flash_gpio_table(MSM_CAM_FLASH_ON, sfdata);
-		if (rc < 0) {
-			pr_err("%s: gpio_request failed\n", __func__);
-			goto go_out;
-		}
-		rc = request_irq(sfdata->irq, strobe_flash_charge_ready_irq,
-			IRQF_TRIGGER_RISING, "charge_ready", sfdata);
-		if (rc < 0) {
-			pr_err("%s: request_irq failed %d\n", __func__, rc);
-			goto go_out;
-		}
-
-		spin_lock_init(&sfdata->timer_lock);
-		/* setup timer */
-		init_timer(&timer_flash);
-		timer_flash.function = strobe_flash_xenon_recharge_handler;
-		timer_flash.data = (unsigned long)sfdata;
-	}
-	sfdata->state++;
-go_out:
-	spin_unlock_irqrestore(&sfdata->spin_lock, flags);
-
-	return rc;
-}
-
-static int msm_strobe_flash_xenon_release
-(struct msm_camera_sensor_strobe_flash_data *sfdata, int32_t final_release)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&sfdata->spin_lock, flags);
-	if (sfdata->state > 0) {
-		if (final_release)
-			sfdata->state = 0;
-		else
-			sfdata->state--;
-
-		if (!sfdata->state) {
-			free_irq(sfdata->irq, sfdata);
-			config_flash_gpio_table(MSM_CAM_FLASH_OFF, sfdata);
-			if (timer_pending(&timer_flash))
-				del_timer_sync(&timer_flash);
-		}
-	}
-	spin_unlock_irqrestore(&sfdata->spin_lock, flags);
-	return 0;
-}
-
-static int msm_strobe_flash_ctrl(
-	struct msm_camera_sensor_strobe_flash_data *sfdata,
-	struct strobe_flash_ctrl_data *strobe_ctrl)
-{
-	int rc = 0;
-	switch (strobe_ctrl->type) {
-	case STROBE_FLASH_CTRL_INIT:
-		if (!sfdata)
-			return -ENODEV;
-		rc = msm_strobe_flash_xenon_init(sfdata);
-		break;
-	case STROBE_FLASH_CTRL_CHARGE:
-		rc = msm_strobe_flash_xenon_charge(sfdata->flash_charge,
-			strobe_ctrl->charge_en,
-			sfdata->flash_recharge_duration);
-		break;
-	case STROBE_FLASH_CTRL_RELEASE:
-		if (sfdata)
-			rc = msm_strobe_flash_xenon_release(sfdata, 0);
-		break;
-	default:
-		pr_err("Invalid Strobe Flash State\n");
-		rc = -EINVAL;
-	}
-	return rc;
-}
-
-int msm_flash_led_init(struct msm_flash_ctrl_t *fctrl)
-{
-	int rc = 0;
-	struct msm_camera_sensor_flash_external *external = NULL;
-	CDBG("%s:%d called\n", __func__, __LINE__);
-	if (!fctrl) {
-		pr_err("%s:%d fctrl NULL\n", __func__, __LINE__);
-		return -EINVAL;
-	}
-	external = &fctrl->flash_data->flash_src->_fsrc.ext_driver_src;
-	if (external->expander_info && !fctrl->expander_client) {
-		struct i2c_adapter *adapter =
-		i2c_get_adapter(external->expander_info->bus_id);
-		if (adapter)
-			fctrl->expander_client = i2c_new_device(adapter,
-				external->expander_info->board_info);
-		if (!fctrl->expander_client || !adapter) {
-			pr_err("fctrl->expander_client is not available\n");
-			rc = -ENOTSUPP;
-			return rc;
-		}
-		i2c_put_adapter(adapter);
-	}
-	rc = msm_camera_init_gpio_table(
-		fctrl->flash_data->flash_src->init_gpio_tbl,
-		fctrl->flash_data->flash_src->init_gpio_tbl_size, 1);
-	if (rc < 0)
-		pr_err("%s:%d failed\n", __func__, __LINE__);
-	return rc;
-}
-
-int msm_flash_led_release(struct msm_flash_ctrl_t *fctrl)
-{
-	struct msm_camera_sensor_flash_external *external = NULL;
-	CDBG("%s:%d called\n", __func__, __LINE__);
-	if (!fctrl) {
-		pr_err("%s:%d fctrl NULL\n", __func__, __LINE__);
-		return -EINVAL;
-	}
-	external = &fctrl->flash_data->flash_src->_fsrc.ext_driver_src;
-	msm_camera_set_gpio_table(
-		fctrl->flash_data->flash_src->set_gpio_tbl,
-		fctrl->flash_data->flash_src->set_gpio_tbl_size, 0);
-	msm_camera_init_gpio_table(
-		fctrl->flash_data->flash_src->init_gpio_tbl,
-		fctrl->flash_data->flash_src->init_gpio_tbl_size, 0);
-	if (external->expander_info && fctrl->expander_client) {
-		i2c_unregister_device(fctrl->expander_client);
-		fctrl->expander_client = NULL;
-	}
-	return 0;
-}
-
-int msm_flash_led_off(struct msm_flash_ctrl_t *fctrl)
-{
-	int rc = 0;
-	struct msm_camera_sensor_flash_external *external = NULL;
-	CDBG("%s:%d called\n", __func__, __LINE__);
-	if (!fctrl) {
-		pr_err("%s:%d fctrl NULL\n", __func__, __LINE__);
-		return -EINVAL;
-	}
-	external = &fctrl->flash_data->flash_src->_fsrc.ext_driver_src;
-	if (fctrl->flash_i2c_client && fctrl->reg_setting) {
-		rc = msm_camera_i2c_write_tbl(
-			fctrl->flash_i2c_client,
-			fctrl->reg_setting->off_setting,
-			fctrl->reg_setting->off_setting_size,
-			fctrl->reg_setting->default_data_type);
-		if (rc < 0)
-			pr_err("%s:%d failed\n", __func__, __LINE__);
-	}
-	msm_camera_set_gpio_table(
-		fctrl->flash_data->flash_src->set_gpio_tbl,
-		fctrl->flash_data->flash_src->set_gpio_tbl_size, 0);
-
-	return rc;
-}
-
-int msm_flash_led_low(struct msm_flash_ctrl_t *fctrl)
-{
-	int rc = 0;
-	struct msm_camera_sensor_flash_external *external = NULL;
-	CDBG("%s:%d called\n", __func__, __LINE__);
-	if (!fctrl) {
-		pr_err("%s:%d fctrl NULL\n", __func__, __LINE__);
-		return -EINVAL;
-	}
-	external = &fctrl->flash_data->flash_src->_fsrc.ext_driver_src;
-	msm_camera_set_gpio_table(
-		fctrl->flash_data->flash_src->set_gpio_tbl,
-		fctrl->flash_data->flash_src->set_gpio_tbl_size, 1);
-	if (fctrl->flash_i2c_client && fctrl->reg_setting) {
-		rc = msm_camera_i2c_write_tbl(
-			fctrl->flash_i2c_client,
-			fctrl->reg_setting->low_setting,
-			fctrl->reg_setting->low_setting_size,
-			fctrl->reg_setting->default_data_type);
-		if (rc < 0)
-			pr_err("%s:%d failed\n", __func__, __LINE__);
-	}
-	return rc;
-}
-
-int msm_flash_led_high(struct msm_flash_ctrl_t *fctrl)
-{
-	int rc = 0;
-	struct msm_camera_sensor_flash_external *external = NULL;
-	CDBG("%s:%d called\n", __func__, __LINE__);
-	if (!fctrl) {
-		pr_err("%s:%d fctrl NULL\n", __func__, __LINE__);
-		return -EINVAL;
-	}
-	external = &fctrl->flash_data->flash_src->_fsrc.ext_driver_src;
-	msm_camera_set_gpio_table(
-		fctrl->flash_data->flash_src->set_gpio_tbl,
-		fctrl->flash_data->flash_src->set_gpio_tbl_size, 1);
-	if (fctrl->flash_i2c_client && fctrl->reg_setting) {
-		rc = msm_camera_i2c_write_tbl(
-			fctrl->flash_i2c_client,
-			fctrl->reg_setting->high_setting,
-			fctrl->reg_setting->high_setting_size,
-			fctrl->reg_setting->default_data_type);
-		if (rc < 0)
-			pr_err("%s:%d failed\n", __func__, __LINE__);
-	}
-	return rc;
-}
-
-int msm_camera_flash_led_config(struct msm_flash_ctrl_t *fctrl,
-	uint8_t led_state)
-{
-	int rc = 0;
-
-	CDBG("%s:%d called\n", __func__, __LINE__);
-	if (!fctrl->func_tbl) {
-		pr_err("%s flash func tbl NULL\n", __func__);
-		return 0;
-	}
-	switch (led_state) {
-	case MSM_CAMERA_LED_INIT:
-		if (fctrl->func_tbl->flash_led_init)
-			rc = fctrl->func_tbl->flash_led_init(fctrl);
-		break;
-
-	case MSM_CAMERA_LED_RELEASE:
-		if (fctrl->func_tbl->flash_led_release)
-			rc = fctrl->func_tbl->
-				flash_led_release(fctrl);
-		break;
-
-	case MSM_CAMERA_LED_OFF:
-		if (fctrl->func_tbl->flash_led_off)
-			rc = fctrl->func_tbl->flash_led_off(fctrl);
-		break;
-
-	case MSM_CAMERA_LED_LOW:
-		if (fctrl->func_tbl->flash_led_low)
-			rc = fctrl->func_tbl->flash_led_low(fctrl);
-		break;
-
-	case MSM_CAMERA_LED_HIGH:
-		if (fctrl->func_tbl->flash_led_high)
-			rc = fctrl->func_tbl->flash_led_high(fctrl);
-		break;
-
-	default:
-		rc = -EFAULT;
-		break;
-	}
-	return rc;
-}
-
-static struct msm_flash_ctrl_t *get_fctrl(struct v4l2_subdev *sd)
-{
-	return container_of(sd, struct msm_flash_ctrl_t, v4l2_sdev);
-}
-
-static long msm_flash_config(struct msm_flash_ctrl_t *fctrl, void __user *argp)
-{
-	long rc = 0;
-	struct flash_ctrl_data flash_info;
-	if (!argp) {
-		pr_err("%s argp NULL\n", __func__);
-		return -EINVAL;
-	}
-	if (copy_from_user(&flash_info, argp, sizeof(flash_info))) {
-		pr_err("%s:%d failed\n", __func__, __LINE__);
-		return -EFAULT;
-	}
-	switch (flash_info.flashtype) {
-	case LED_FLASH:
-		if (fctrl->func_tbl->flash_led_config)
-			rc = fctrl->func_tbl->flash_led_config(fctrl,
-				flash_info.ctrl_data.led_state);
-		if (rc < 0)
-			pr_err("%s:%d failed\n", __func__, __LINE__);
-		break;
-	case STROBE_FLASH:
-		rc = msm_strobe_flash_ctrl(fctrl->strobe_flash_data,
-			&(flash_info.ctrl_data.strobe_ctrl));
-		break;
-	default:
-		pr_err("Invalid Flash MODE\n");
-		rc = -EINVAL;
-	}
-	return rc;
-}
-
-static long msm_flash_subdev_ioctl(struct v4l2_subdev *sd,
-			unsigned int cmd, void *arg)
-{
-	struct msm_flash_ctrl_t *fctrl = NULL;
-	void __user *argp = (void __user *)arg;
-	if (!sd) {
-		pr_err("%s:%d sd NULL\n", __func__, __LINE__);
-		return -EINVAL;
-	}
-	fctrl = get_fctrl(sd);
-	if (!fctrl) {
-		pr_err("%s:%d fctrl NULL\n", __func__, __LINE__);
-		return -EINVAL;
-	}
-	switch (cmd) {
-	case VIDIOC_MSM_FLASH_LED_DATA_CFG:
-		fctrl->flash_data = (struct msm_camera_sensor_flash_data *)argp;
-		return 0;
-	case VIDIOC_MSM_FLASH_STROBE_DATA_CFG:
-		fctrl->strobe_flash_data =
-			(struct msm_camera_sensor_strobe_flash_data *)argp;
-		return 0;
-	case VIDIOC_MSM_FLASH_CFG:
-		return msm_flash_config(fctrl, argp);
-	default:
-		return -ENOIOCTLCMD;
-	}
-}
-
-static struct v4l2_subdev_core_ops msm_flash_subdev_core_ops = {
-	.ioctl = msm_flash_subdev_ioctl,
-};
-
-static struct v4l2_subdev_ops msm_flash_subdev_ops = {
-	.core = &msm_flash_subdev_core_ops,
-};
-
-int msm_flash_i2c_probe(struct i2c_client *client,
-		const struct i2c_device_id *id)
-{
-	int rc = 0;
-	struct msm_flash_ctrl_t *fctrl = NULL;
-	CDBG("%s:%d called\n", __func__, __LINE__);
-
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		pr_err("i2c_check_functionality failed\n");
-		goto probe_failure;
-	}
-
-	fctrl = (struct msm_flash_ctrl_t *)(id->driver_data);
-	if (fctrl->flash_i2c_client)
-		fctrl->flash_i2c_client->client = client;
-
-	/* Assign name for sub device */
-	snprintf(fctrl->v4l2_sdev.name, sizeof(fctrl->v4l2_sdev.name),
-		"%s", id->name);
-
-	/* Initialize sub device */
-	v4l2_i2c_subdev_init(&fctrl->v4l2_sdev, client, &msm_flash_subdev_ops);
-
-	CDBG("%s:%d probe success\n", __func__, __LINE__);
-	return 0;
-
-probe_failure:
-	CDBG("%s:%d probe failed\n", __func__, __LINE__);
-	return rc;
-}
-
-int msm_flash_platform_probe(struct platform_device *pdev, void *data)
-{
-	struct msm_flash_ctrl_t *fctrl = (struct msm_flash_ctrl_t *)data;
-	struct msm_cam_subdev_info sd_info;
-	CDBG("%s:%d called\n", __func__, __LINE__);
-
-	if (!fctrl) {
-		pr_err("%s fctrl NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	/* Initialize sub device */
-	v4l2_subdev_init(&fctrl->v4l2_sdev, &msm_flash_subdev_ops);
-
-	/* Assign name for sub device */
-	snprintf(fctrl->v4l2_sdev.name, sizeof(fctrl->v4l2_sdev.name),
-		"%s", "msm_flash");
-
-	fctrl->pdev = pdev;
-	sd_info.sdev_type = FLASH_DEV;
-	sd_info.sd_index = pdev->id;
-	msm_cam_register_subdev_node(&fctrl->v4l2_sdev, &sd_info);
-
-	CDBG("%s:%d probe success\n", __func__, __LINE__);
-	return 0;
-}
-
-int msm_flash_create_v4l2_subdev(void *data, uint8_t sd_index)
-{
-	struct msm_flash_ctrl_t *fctrl = (struct msm_flash_ctrl_t *)data;
-	struct msm_cam_subdev_info sd_info;
-	CDBG("%s:%d called\n", __func__, __LINE__);
-
-	/* Initialize sub device */
-	v4l2_subdev_init(&fctrl->v4l2_sdev, &msm_flash_subdev_ops);
-
-	/* Assign name for sub device */
-	snprintf(fctrl->v4l2_sdev.name, sizeof(fctrl->v4l2_sdev.name),
-		"%s", "msm_flash");
-
-	sd_info.sdev_type = FLASH_DEV;
-	sd_info.sd_index = sd_index;
-	msm_cam_register_subdev_node(&fctrl->v4l2_sdev, &sd_info);
-
-	CDBG("%s:%d probe success\n", __func__, __LINE__);
-	return 0;
-}
diff --git a/drivers/media/platform/msm/camera_v1/flash/msm_flash.h b/drivers/media/platform/msm/camera_v1/flash/msm_flash.h
deleted file mode 100644
index 2513995..0000000
--- a/drivers/media/platform/msm/camera_v1/flash/msm_flash.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* Copyright (c) 2009-2012, The Linux Foundation. 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.
- *
- */
-#ifndef MSM_FLASH_H
-#define MSM_FLASH_H
-
-#include <linux/i2c.h>
-#include <linux/leds.h>
-#include <media/v4l2-subdev.h>
-#include <mach/board.h>
-#include "msm_camera_i2c.h"
-
-#define MAX_LED_TRIGGERS 2
-
-struct msm_flash_ctrl_t;
-
-struct msm_flash_reg_t {
-	enum msm_camera_i2c_data_type default_data_type;
-	struct msm_camera_i2c_reg_conf *init_setting;
-	uint8_t init_setting_size;
-	struct msm_camera_i2c_reg_conf *off_setting;
-	uint8_t off_setting_size;
-	struct msm_camera_i2c_reg_conf *low_setting;
-	uint8_t low_setting_size;
-	struct msm_camera_i2c_reg_conf *high_setting;
-	uint8_t high_setting_size;
-};
-
-struct msm_flash_fn_t {
-	int (*flash_led_config)(struct msm_flash_ctrl_t *, uint8_t);
-	int (*flash_led_init)(struct msm_flash_ctrl_t *);
-	int (*flash_led_release)(struct msm_flash_ctrl_t *);
-	int (*flash_led_off)(struct msm_flash_ctrl_t *);
-	int (*flash_led_low)(struct msm_flash_ctrl_t *);
-	int (*flash_led_high)(struct msm_flash_ctrl_t *);
-};
-
-struct msm_flash_ctrl_t {
-	struct msm_camera_i2c_client *flash_i2c_client;
-	struct platform_device *pdev;
-	struct i2c_client *expander_client;
-	struct v4l2_subdev v4l2_sdev;
-	struct msm_camera_sensor_flash_data *flash_data;
-	struct msm_camera_sensor_strobe_flash_data *strobe_flash_data;
-	struct msm_flash_fn_t *func_tbl;
-	struct msm_flash_reg_t *reg_setting;
-	const char *led_trigger_name[MAX_LED_TRIGGERS];
-	struct led_trigger *led_trigger[MAX_LED_TRIGGERS];
-	uint32_t max_current[MAX_LED_TRIGGERS];
-	void *data;
-};
-
-int msm_flash_i2c_probe(struct i2c_client *client,
-	const struct i2c_device_id *id);
-
-int msm_flash_platform_probe(struct platform_device *pdev, void *data);
-
-int msm_flash_create_v4l2_subdev(void *data, uint8_t sd_index);
-
-int msm_camera_flash_led_config(struct msm_flash_ctrl_t *fctrl,
-	uint8_t led_state);
-
-int msm_flash_led_init(struct msm_flash_ctrl_t *fctrl);
-
-int msm_flash_led_release(struct msm_flash_ctrl_t *fctrl);
-
-int msm_flash_led_off(struct msm_flash_ctrl_t *fctrl);
-
-int msm_flash_led_low(struct msm_flash_ctrl_t *fctrl);
-
-int msm_flash_led_high(struct msm_flash_ctrl_t *fctrl);
-
-#define VIDIOC_MSM_FLASH_LED_DATA_CFG \
-	_IOWR('V', BASE_VIDIOC_PRIVATE + 20, void __user *)
-
-#define VIDIOC_MSM_FLASH_STROBE_DATA_CFG \
-	_IOWR('V', BASE_VIDIOC_PRIVATE + 21, void __user *)
-
-#define VIDIOC_MSM_FLASH_CFG \
-	_IOWR('V', BASE_VIDIOC_PRIVATE + 22, void __user *)
-
-#endif
diff --git a/drivers/media/platform/msm/camera_v1/flash/pmic8058_flash.c b/drivers/media/platform/msm/camera_v1/flash/pmic8058_flash.c
deleted file mode 100644
index 2017bcb..0000000
--- a/drivers/media/platform/msm/camera_v1/flash/pmic8058_flash.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/* Copyright (c) 2009-2012, The Linux Foundation. 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.
- *
- */
-#include <linux/module.h>
-#include <linux/export.h>
-#include "msm_flash.h"
-
-#define SD_INDEX 0
-
-static struct msm_flash_ctrl_t fctrl;
-
-static int msm_camera_pmic_flash(struct msm_flash_ctrl_t *fctrl,
-	uint8_t led_state)
-{
-	int rc = 0;
-	struct msm_camera_sensor_flash_pmic *pmic =
-		&fctrl->flash_data->flash_src->_fsrc.pmic_src;
-
-	switch (led_state) {
-	case MSM_CAMERA_LED_OFF:
-		rc = pmic->pmic_set_current(pmic->led_src_1, 0);
-		if (pmic->num_of_src > 1)
-			rc = pmic->pmic_set_current(pmic->led_src_2, 0);
-		break;
-
-	case MSM_CAMERA_LED_LOW:
-		rc = pmic->pmic_set_current(pmic->led_src_1,
-				pmic->low_current);
-		if (pmic->num_of_src > 1)
-			rc = pmic->pmic_set_current(pmic->led_src_2, 0);
-		break;
-
-	case MSM_CAMERA_LED_HIGH:
-		rc = pmic->pmic_set_current(pmic->led_src_1,
-			pmic->high_current);
-		if (pmic->num_of_src > 1)
-			rc = pmic->pmic_set_current(pmic->led_src_2,
-				pmic->high_current);
-		break;
-
-	case MSM_CAMERA_LED_INIT:
-	case MSM_CAMERA_LED_RELEASE:
-		 break;
-
-	default:
-		rc = -EFAULT;
-		break;
-	}
-	CDBG("flash_set_led_state: return %d\n", rc);
-
-	return rc;
-}
-
-static int __init msm_flash_i2c_add_driver(void)
-{
-	CDBG("%s called\n", __func__);
-	return msm_flash_create_v4l2_subdev(&fctrl, SD_INDEX);
-}
-
-static struct msm_flash_fn_t pmic_flash_func_tbl = {
-	.flash_led_config = msm_camera_pmic_flash,
-};
-
-static struct msm_flash_ctrl_t fctrl = {
-	.func_tbl = &pmic_flash_func_tbl,
-};
-
-module_init(msm_flash_i2c_add_driver);
-MODULE_DESCRIPTION("PMIC FLASH");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/flash/pmic8058_pwm.c b/drivers/media/platform/msm/camera_v1/flash/pmic8058_pwm.c
deleted file mode 100644
index 2215340..0000000
--- a/drivers/media/platform/msm/camera_v1/flash/pmic8058_pwm.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/* Copyright (c) 2009-2012, The Linux Foundation. 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.
- *
- */
-#include <linux/module.h>
-#include <linux/export.h>
-#include <linux/pwm.h>
-
-#include "msm_flash.h"
-#define SD_INDEX 0
-
-static struct msm_flash_ctrl_t fctrl;
-
-static int msm_camera_flash_pwm(struct msm_flash_ctrl_t *fctrl,
-	uint8_t led_state)
-{
-	int rc = 0;
-	struct msm_camera_sensor_flash_pwm *pwm =
-		&fctrl->flash_data->flash_src->_fsrc.pwm_src;
-	int PWM_PERIOD = USEC_PER_SEC / pwm->freq;
-
-	struct pwm_device *flash_pwm = (struct pwm_device *)fctrl->data;
-
-	if (!flash_pwm) {
-		flash_pwm = pwm_request(pwm->channel, "camera-flash");
-		if (flash_pwm == NULL || IS_ERR(flash_pwm)) {
-			pr_err("%s: FAIL pwm_request(): flash_pwm=%p\n",
-			       __func__, flash_pwm);
-			flash_pwm = NULL;
-			return -ENXIO;
-		}
-	}
-
-	switch (led_state) {
-	case MSM_CAMERA_LED_LOW:
-		rc = pwm_config(flash_pwm,
-			(PWM_PERIOD/pwm->max_load)*pwm->low_load,
-			PWM_PERIOD);
-		if (rc >= 0)
-			rc = pwm_enable(flash_pwm);
-		break;
-
-	case MSM_CAMERA_LED_HIGH:
-		rc = pwm_config(flash_pwm,
-			(PWM_PERIOD/pwm->max_load)*pwm->high_load,
-			PWM_PERIOD);
-		if (rc >= 0)
-			rc = pwm_enable(flash_pwm);
-		break;
-
-	case MSM_CAMERA_LED_OFF:
-		pwm_disable(flash_pwm);
-		break;
-	case MSM_CAMERA_LED_INIT:
-	case MSM_CAMERA_LED_RELEASE:
-		break;
-
-	default:
-		rc = -EFAULT;
-		break;
-	}
-	return rc;
-}
-
-static int __init msm_flash_i2c_add_driver(void)
-{
-	CDBG("%s called\n", __func__);
-	return msm_flash_create_v4l2_subdev(&fctrl, SD_INDEX);
-}
-
-static struct msm_flash_fn_t pmic8058_pwm_func_tbl = {
-	.flash_led_config = msm_camera_flash_pwm,
-};
-
-static struct msm_flash_ctrl_t fctrl = {
-	.func_tbl = &pmic8058_pwm_func_tbl,
-};
-
-module_init(msm_flash_i2c_add_driver);
-MODULE_DESCRIPTION("PMIC FLASH");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/flash/sc628a.c b/drivers/media/platform/msm/camera_v1/flash/sc628a.c
deleted file mode 100644
index 58824e1..0000000
--- a/drivers/media/platform/msm/camera_v1/flash/sc628a.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/* Copyright (c) 2009-2012, The Linux Foundation. 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.
- *
- */
-#include <linux/module.h>
-#include <linux/export.h>
-#include "msm_flash.h"
-
-#define FLASH_NAME "sc628a"
-
-static struct msm_flash_ctrl_t fctrl;
-static struct i2c_driver sc628a_i2c_driver;
-
-static struct msm_camera_i2c_reg_conf sc628a_off_setting[] = {
-	{0x02, 0x00},
-};
-
-static struct msm_camera_i2c_reg_conf sc628a_low_setting[] = {
-	{0x02, 0x06},
-};
-
-static struct msm_camera_i2c_reg_conf sc628a_high_setting[] = {
-	{0x02, 0x49},
-};
-
-static int __exit msm_flash_i2c_remove(struct i2c_client *client)
-{
-	i2c_del_driver(&sc628a_i2c_driver);
-	return 0;
-}
-
-static const struct i2c_device_id sc628a_i2c_id[] = {
-	{FLASH_NAME, (kernel_ulong_t)&fctrl},
-	{ }
-};
-
-static struct i2c_driver sc628a_i2c_driver = {
-	.id_table = sc628a_i2c_id,
-	.probe  = msm_flash_i2c_probe,
-	.remove = __exit_p(msm_flash_i2c_remove),
-	.driver = {
-		.name = FLASH_NAME,
-	},
-};
-
-static int __init msm_flash_i2c_add_driver(void)
-{
-	CDBG("%s called\n", __func__);
-	return i2c_add_driver(&sc628a_i2c_driver);
-}
-
-static struct msm_camera_i2c_client sc628a_i2c_client = {
-	.addr_type = MSM_CAMERA_I2C_BYTE_ADDR,
-};
-
-static struct msm_flash_reg_t sc628a_regs = {
-	.default_data_type = MSM_CAMERA_I2C_BYTE_DATA,
-	.off_setting = sc628a_off_setting,
-	.off_setting_size = ARRAY_SIZE(sc628a_off_setting),
-	.low_setting = sc628a_low_setting,
-	.low_setting_size = ARRAY_SIZE(sc628a_low_setting),
-	.high_setting = sc628a_high_setting,
-	.high_setting_size = ARRAY_SIZE(sc628a_high_setting),
-};
-
-static struct msm_flash_fn_t sc628a_func_tbl = {
-	.flash_led_config = msm_camera_flash_led_config,
-	.flash_led_init = msm_flash_led_init,
-	.flash_led_release = msm_flash_led_release,
-	.flash_led_off = msm_flash_led_off,
-	.flash_led_low = msm_flash_led_low,
-	.flash_led_high = msm_flash_led_high,
-};
-
-static struct msm_flash_ctrl_t fctrl = {
-	.flash_i2c_client = &sc628a_i2c_client,
-	.reg_setting = &sc628a_regs,
-	.func_tbl = &sc628a_func_tbl,
-};
-
-subsys_initcall(msm_flash_i2c_add_driver);
-MODULE_DESCRIPTION("SC628A FLASH");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/flash/sgm3141.c b/drivers/media/platform/msm/camera_v1/flash/sgm3141.c
deleted file mode 100644
index a8f8ca0..0000000
--- a/drivers/media/platform/msm/camera_v1/flash/sgm3141.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Copyright (c) 2009-2012, The Linux Foundation. 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.
- *
- */
-#include <linux/module.h>
-#include <linux/export.h>
-#include <mach/gpio.h>
-#include "msm_flash.h"
-
-#define SD_INDEX 0
-
-static struct msm_flash_ctrl_t fctrl;
-
-static int msm_camera_flash_led(struct msm_flash_ctrl_t *fctrl,
-	uint8_t led_state)
-{
-	int rc = 0;
-	struct msm_camera_sensor_flash_external *external =
-		&fctrl->flash_data->flash_src->_fsrc.ext_driver_src;
-
-	CDBG("msm_camera_flash_led: %d\n", led_state);
-	switch (led_state) {
-	case MSM_CAMERA_LED_INIT:
-		rc = gpio_request(external->led_en, "sgm3141");
-		CDBG("MSM_CAMERA_LED_INIT: gpio_req: %d %d\n",
-				external->led_en, rc);
-		if (!rc)
-			gpio_direction_output(external->led_en, 0);
-		else
-			return 0;
-
-		rc = gpio_request(external->led_flash_en, "sgm3141");
-		CDBG("MSM_CAMERA_LED_INIT: gpio_req: %d %d\n",
-				external->led_flash_en, rc);
-		if (!rc)
-			gpio_direction_output(external->led_flash_en, 0);
-
-			break;
-
-	case MSM_CAMERA_LED_RELEASE:
-		CDBG("MSM_CAMERA_LED_RELEASE\n");
-		gpio_set_value_cansleep(external->led_en, 0);
-		gpio_free(external->led_en);
-		gpio_set_value_cansleep(external->led_flash_en, 0);
-		gpio_free(external->led_flash_en);
-		break;
-
-	case MSM_CAMERA_LED_OFF:
-		CDBG("MSM_CAMERA_LED_OFF\n");
-		gpio_set_value_cansleep(external->led_en, 0);
-		gpio_set_value_cansleep(external->led_flash_en, 0);
-		break;
-
-	case MSM_CAMERA_LED_LOW:
-		CDBG("MSM_CAMERA_LED_LOW\n");
-		gpio_set_value_cansleep(external->led_en, 1);
-		gpio_set_value_cansleep(external->led_flash_en, 1);
-		break;
-
-	case MSM_CAMERA_LED_HIGH:
-		CDBG("MSM_CAMERA_LED_HIGH\n");
-		gpio_set_value_cansleep(external->led_en, 1);
-		gpio_set_value_cansleep(external->led_flash_en, 1);
-		break;
-
-	default:
-		rc = -EFAULT;
-		break;
-	}
-
-	return rc;
-}
-
-static int __init msm_flash_i2c_add_driver(void)
-{
-	CDBG("%s called\n", __func__);
-	return msm_flash_create_v4l2_subdev(&fctrl, SD_INDEX);
-}
-
-static struct msm_flash_fn_t sgm3141_func_tbl = {
-	.flash_led_config = msm_camera_flash_led,
-};
-
-static struct msm_flash_ctrl_t fctrl = {
-	.func_tbl = &sgm3141_func_tbl,
-};
-
-module_init(msm_flash_i2c_add_driver);
-MODULE_DESCRIPTION("SGM3141 FLASH");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/flash/tps61310.c b/drivers/media/platform/msm/camera_v1/flash/tps61310.c
deleted file mode 100644
index 63e6955..0000000
--- a/drivers/media/platform/msm/camera_v1/flash/tps61310.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/* Copyright (c) 2009-2012, The Linux Foundation. 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.
- *
- */
-#include <linux/module.h>
-#include <linux/export.h>
-#include "msm_flash.h"
-
-#define FLASH_NAME "tps61310"
-
-static struct msm_flash_ctrl_t fctrl;
-static struct i2c_driver tps61310_i2c_driver;
-
-static struct msm_camera_i2c_reg_conf tps61310_init_setting[] = {
-	{0x01, 0x00},
-};
-
-static struct msm_camera_i2c_reg_conf tps61310_off_setting[] = {
-	{0x01, 0x00},
-};
-
-static struct msm_camera_i2c_reg_conf tps61310_low_setting[] = {
-	{0x01, 0x86},
-};
-
-static struct msm_camera_i2c_reg_conf tps61310_high_setting[] = {
-	{0x01, 0x8B},
-};
-
-static int __exit msm_flash_i2c_remove(struct i2c_client *client)
-{
-	i2c_del_driver(&tps61310_i2c_driver);
-	return 0;
-}
-
-static const struct i2c_device_id tps61310_i2c_id[] = {
-	{FLASH_NAME, (kernel_ulong_t)&fctrl},
-	{ }
-};
-
-static struct i2c_driver tps61310_i2c_driver = {
-	.id_table = tps61310_i2c_id,
-	.probe  = msm_flash_i2c_probe,
-	.remove = __exit_p(msm_flash_i2c_remove),
-	.driver = {
-		.name = FLASH_NAME,
-	},
-};
-
-static int __init msm_flash_i2c_add_driver(void)
-{
-	CDBG("%s called\n", __func__);
-	return i2c_add_driver(&tps61310_i2c_driver);
-}
-
-static struct msm_camera_i2c_client tps61310_i2c_client = {
-	.addr_type = MSM_CAMERA_I2C_BYTE_ADDR,
-};
-
-static struct msm_flash_reg_t tps61310_regs = {
-	.default_data_type = MSM_CAMERA_I2C_BYTE_DATA,
-	.init_setting = tps61310_init_setting,
-	.init_setting_size = ARRAY_SIZE(tps61310_init_setting),
-	.off_setting = tps61310_off_setting,
-	.off_setting_size = ARRAY_SIZE(tps61310_off_setting),
-	.low_setting = tps61310_low_setting,
-	.low_setting_size = ARRAY_SIZE(tps61310_low_setting),
-	.high_setting = tps61310_high_setting,
-	.high_setting_size = ARRAY_SIZE(tps61310_high_setting),
-};
-
-static struct msm_flash_fn_t tps61310_func_tbl = {
-	.flash_led_config = msm_camera_flash_led_config,
-	.flash_led_init = msm_flash_led_init,
-	.flash_led_release = msm_flash_led_release,
-	.flash_led_off = msm_flash_led_off,
-	.flash_led_low = msm_flash_led_low,
-	.flash_led_high = msm_flash_led_high,
-};
-
-static struct msm_flash_ctrl_t fctrl = {
-	.flash_i2c_client = &tps61310_i2c_client,
-	.reg_setting = &tps61310_regs,
-	.func_tbl = &tps61310_func_tbl,
-};
-
-subsys_initcall(msm_flash_i2c_add_driver);
-MODULE_DESCRIPTION("TPS61310 FLASH");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/gemini/Makefile b/drivers/media/platform/msm/camera_v1/gemini/Makefile
deleted file mode 100644
index 6d4166c..0000000
--- a/drivers/media/platform/msm/camera_v1/gemini/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-GCC_VERSION      := $(shell $(CONFIG_SHELL) $(PWD)/scripts/gcc-version.sh $(CROSS_COMPILE)gcc)
-EXTRA_CFLAGS += -Idrivers/media/platform/msm/camera_v1
-obj-$(CONFIG_MSM_GEMINI) += msm_gemini_dev.o msm_gemini_sync.o msm_gemini_core.o msm_gemini_hw.o msm_gemini_platform.o
diff --git a/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_common.h b/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_common.h
deleted file mode 100644
index 95223d80..0000000
--- a/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_common.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright (c) 2010, The Linux Foundation. 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.
- */
-
-#ifndef MSM_GEMINI_COMMON_H
-#define MSM_GEMINI_COMMON_H
-
-#define MSM_GEMINI_DEBUG
-#ifdef MSM_GEMINI_DEBUG
-#define GMN_DBG(fmt, args...) pr_debug(fmt, ##args)
-#else
-#define GMN_DBG(fmt, args...) do { } while (0)
-#endif
-
-#define GMN_PR_ERR   pr_err
-
-enum GEMINI_MODE {
-	GEMINI_MODE_DISABLE,
-	GEMINI_MODE_OFFLINE,
-	GEMINI_MODE_REALTIME,
-	GEMINI_MODE_REALTIME_ROTATION
-};
-
-enum GEMINI_ROTATION {
-	GEMINI_ROTATION_0,
-	GEMINI_ROTATION_90,
-	GEMINI_ROTATION_180,
-	GEMINI_ROTATION_270
-};
-
-#endif /* MSM_GEMINI_COMMON_H */
diff --git a/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_core.c b/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_core.c
deleted file mode 100644
index 9370fc9..0000000
--- a/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_core.c
+++ /dev/null
@@ -1,250 +0,0 @@
-/* Copyright (c) 2010-2013, The Linux Foundation. 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.
- */
-
-#include <linux/module.h>
-#include <linux/sched.h>
-#include "msm_gemini_hw.h"
-#include "msm_gemini_core.h"
-#include "msm_gemini_platform.h"
-#include "msm_gemini_common.h"
-
-static struct msm_gemini_hw_pingpong fe_pingpong_buf;
-static struct msm_gemini_hw_pingpong we_pingpong_buf;
-static int we_pingpong_index;
-static int reset_done_ack;
-static spinlock_t reset_lock;
-static wait_queue_head_t reset_wait;
-
-int msm_gemini_core_reset(uint8_t op_mode, void *base, int size)
-{
-	unsigned long flags;
-	int rc = 0;
-	int tm = 500; /*500ms*/
-	memset(&fe_pingpong_buf, 0, sizeof(fe_pingpong_buf));
-	fe_pingpong_buf.is_fe = 1;
-	we_pingpong_index = 0;
-	memset(&we_pingpong_buf, 0, sizeof(we_pingpong_buf));
-	spin_lock_irqsave(&reset_lock, flags);
-	reset_done_ack = 0;
-	msm_gemini_hw_reset(base, size);
-	spin_unlock_irqrestore(&reset_lock, flags);
-	rc = wait_event_interruptible_timeout(
-			reset_wait,
-			reset_done_ack,
-			msecs_to_jiffies(tm));
-
-	if (!reset_done_ack) {
-		GMN_DBG("%s: reset ACK failed %d", __func__, rc);
-		return -EBUSY;
-	}
-
-	GMN_DBG("%s: reset_done_ack rc %d", __func__, rc);
-	spin_lock_irqsave(&reset_lock, flags);
-	reset_done_ack = 0;
-	spin_unlock_irqrestore(&reset_lock, flags);
-
-	if (op_mode == MSM_GEMINI_MODE_REALTIME_ENCODE) {
-		/* Nothing needed for fe buffer cfg, config we only */
-		msm_gemini_hw_we_buffer_cfg(1);
-	} else {
-		/* Nothing needed for fe buffer cfg, config we only */
-		msm_gemini_hw_we_buffer_cfg(0);
-	}
-
-	/* @todo wait for reset done irq */
-
-	return 0;
-}
-
-void msm_gemini_core_release(int release_buf)
-{
-	int i = 0;
-	for (i = 0; i < 2; i++) {
-		if (we_pingpong_buf.buf_status[i] && release_buf)
-			msm_gemini_platform_p2v(we_pingpong_buf.buf[i].file,
-					&we_pingpong_buf.buf[i].handle);
-		we_pingpong_buf.buf_status[i] = 0;
-	}
-}
-
-void msm_gemini_core_init(void)
-{
-	init_waitqueue_head(&reset_wait);
-	spin_lock_init(&reset_lock);
-}
-
-int msm_gemini_core_fe_start(void)
-{
-	msm_gemini_hw_fe_start();
-	return 0;
-}
-
-/* fetch engine */
-int msm_gemini_core_fe_buf_update(struct msm_gemini_core_buf *buf)
-{
-	GMN_DBG("%s:%d] 0x%08x %d 0x%08x %d\n", __func__, __LINE__,
-		(int) buf->y_buffer_addr, buf->y_len,
-		(int) buf->cbcr_buffer_addr, buf->cbcr_len);
-	return msm_gemini_hw_pingpong_update(&fe_pingpong_buf, buf);
-}
-
-void *msm_gemini_core_fe_pingpong_irq(int gemini_irq_status, void *context)
-{
-	return msm_gemini_hw_pingpong_irq(&fe_pingpong_buf);
-}
-
-/* write engine */
-int msm_gemini_core_we_buf_update(struct msm_gemini_core_buf *buf)
-{
-	int rc;
-	GMN_DBG("%s:%d] 0x%08x 0x%08x %d\n", __func__, __LINE__,
-		(int) buf->y_buffer_addr, (int) buf->cbcr_buffer_addr,
-		buf->y_len);
-	we_pingpong_buf.buf_status[we_pingpong_index] = 0;
-	we_pingpong_index = (we_pingpong_index + 1)%2;
-	rc = msm_gemini_hw_pingpong_update(&we_pingpong_buf, buf);
-	return 0;
-}
-
-int msm_gemini_core_we_buf_reset(struct msm_gemini_hw_buf *buf)
-{
-	int i = 0;
-	for (i = 0; i < 2; i++) {
-		if (we_pingpong_buf.buf[i].y_buffer_addr
-					== buf->y_buffer_addr)
-			we_pingpong_buf.buf_status[i] = 0;
-	}
-	return 0;
-}
-
-void *msm_gemini_core_we_pingpong_irq(int gemini_irq_status, void *context)
-{
-	GMN_DBG("%s:%d]\n", __func__, __LINE__);
-
-	return msm_gemini_hw_pingpong_irq(&we_pingpong_buf);
-}
-
-void *msm_gemini_core_framedone_irq(int gemini_irq_status, void *context)
-{
-	struct msm_gemini_hw_buf *buf_p;
-
-	GMN_DBG("%s:%d]\n", __func__, __LINE__);
-
-	buf_p = msm_gemini_hw_pingpong_active_buffer(&we_pingpong_buf);
-	if (buf_p) {
-		buf_p->framedone_len = msm_gemini_hw_encode_output_size();
-		pr_debug("%s:%d] framedone_len %d\n", __func__, __LINE__,
-			buf_p->framedone_len);
-	}
-
-	return buf_p;
-}
-
-void *msm_gemini_core_reset_ack_irq(int gemini_irq_status, void *context)
-{
-	/* @todo return the status back to msm_gemini_core_reset */
-	GMN_DBG("%s:%d]\n", __func__, __LINE__);
-	return NULL;
-}
-
-void *msm_gemini_core_err_irq(int gemini_irq_status, void *context)
-{
-	GMN_PR_ERR("%s:%d]\n", __func__, gemini_irq_status);
-	return NULL;
-}
-
-static int (*msm_gemini_irq_handler) (int, void *, void *);
-
-irqreturn_t msm_gemini_core_irq(int irq_num, void *context)
-{
-	void *data = NULL;
-	unsigned long flags;
-	int gemini_irq_status;
-
-	GMN_DBG("%s:%d] irq_num = %d\n", __func__, __LINE__, irq_num);
-
-	spin_lock_irqsave(&reset_lock, flags);
-	reset_done_ack = 1;
-	spin_unlock_irqrestore(&reset_lock, flags);
-	gemini_irq_status = msm_gemini_hw_irq_get_status();
-
-	GMN_DBG("%s:%d] gemini_irq_status = %0x\n", __func__, __LINE__,
-		gemini_irq_status);
-
-	/*For reset and framedone IRQs, clear all bits*/
-	if (gemini_irq_status & 0x400) {
-		wake_up(&reset_wait);
-		msm_gemini_hw_irq_clear(HWIO_JPEG_IRQ_CLEAR_RMSK,
-			JPEG_IRQ_CLEAR_ALL);
-	} else if (gemini_irq_status & 0x1) {
-		msm_gemini_hw_irq_clear(HWIO_JPEG_IRQ_CLEAR_RMSK,
-			JPEG_IRQ_CLEAR_ALL);
-	} else {
-		msm_gemini_hw_irq_clear(HWIO_JPEG_IRQ_CLEAR_RMSK,
-			gemini_irq_status);
-	}
-
-	if (msm_gemini_hw_irq_is_frame_done(gemini_irq_status)) {
-		data = msm_gemini_core_framedone_irq(gemini_irq_status,
-			context);
-		if (msm_gemini_irq_handler)
-			msm_gemini_irq_handler(
-				MSM_GEMINI_HW_MASK_COMP_FRAMEDONE,
-				context, data);
-	}
-
-	if (msm_gemini_hw_irq_is_fe_pingpong(gemini_irq_status)) {
-		data = msm_gemini_core_fe_pingpong_irq(gemini_irq_status,
-			context);
-		if (msm_gemini_irq_handler)
-			msm_gemini_irq_handler(MSM_GEMINI_HW_MASK_COMP_FE,
-				context, data);
-	}
-
-	if (msm_gemini_hw_irq_is_we_pingpong(gemini_irq_status) &&
-	    !msm_gemini_hw_irq_is_frame_done(gemini_irq_status)) {
-		data = msm_gemini_core_we_pingpong_irq(gemini_irq_status,
-			context);
-		if (msm_gemini_irq_handler)
-			msm_gemini_irq_handler(MSM_GEMINI_HW_MASK_COMP_WE,
-				context, data);
-	}
-
-	if (msm_gemini_hw_irq_is_reset_ack(gemini_irq_status)) {
-		data = msm_gemini_core_reset_ack_irq(gemini_irq_status,
-			context);
-		if (msm_gemini_irq_handler)
-			msm_gemini_irq_handler(
-				MSM_GEMINI_HW_MASK_COMP_RESET_ACK,
-				context, data);
-	}
-
-	/* Unexpected/unintended HW interrupt */
-	if (msm_gemini_hw_irq_is_err(gemini_irq_status)) {
-		data = msm_gemini_core_err_irq(gemini_irq_status, context);
-		if (msm_gemini_irq_handler)
-			msm_gemini_irq_handler(MSM_GEMINI_HW_MASK_COMP_ERR,
-				context, data);
-	}
-
-	return IRQ_HANDLED;
-}
-
-void msm_gemini_core_irq_install(int (*irq_handler) (int, void *, void *))
-{
-	msm_gemini_irq_handler = irq_handler;
-}
-
-void msm_gemini_core_irq_remove(void)
-{
-	msm_gemini_irq_handler = NULL;
-}
diff --git a/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_core.h b/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_core.h
deleted file mode 100644
index 62dd473..0000000
--- a/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_core.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright (c) 2010, The Linux Foundation. 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.
- */
-
-#ifndef MSM_GEMINI_CORE_H
-#define MSM_GEMINI_CORE_H
-
-#include <linux/interrupt.h>
-#include "msm_gemini_hw.h"
-
-#define msm_gemini_core_buf msm_gemini_hw_buf
-
-irqreturn_t msm_gemini_core_irq(int irq_num, void *context);
-
-void msm_gemini_core_irq_install(int (*irq_handler) (int, void *, void *));
-void msm_gemini_core_irq_remove(void);
-
-int msm_gemini_core_fe_buf_update(struct msm_gemini_core_buf *buf);
-int msm_gemini_core_we_buf_update(struct msm_gemini_core_buf *buf);
-int msm_gemini_core_we_buf_reset(struct msm_gemini_hw_buf *buf);
-
-int msm_gemini_core_reset(uint8_t op_mode, void *base, int size);
-int msm_gemini_core_fe_start(void);
-
-void msm_gemini_core_release(int);
-void msm_gemini_core_init(void);
-#endif /* MSM_GEMINI_CORE_H */
diff --git a/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_dev.c b/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_dev.c
deleted file mode 100644
index 770a28f..0000000
--- a/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_dev.c
+++ /dev/null
@@ -1,266 +0,0 @@
-/* Copyright (c) 2010-2011, The Linux Foundation. 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.
- */
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/platform_device.h>
-#include <mach/board.h>
-
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/device.h>
-#include <linux/uaccess.h>
-#include <media/msm_gemini.h>
-#include <media/v4l2-device.h>
-#include <media/v4l2-subdev.h>
-
-#include "msm.h"
-#include "msm_gemini_sync.h"
-#include "msm_gemini_common.h"
-
-#define MSM_GEMINI_NAME "gemini"
-
-static int msm_gemini_open(struct inode *inode, struct file *filp)
-{
-	int rc;
-
-	struct msm_gemini_device *pgmn_dev = container_of(inode->i_cdev,
-		struct msm_gemini_device, cdev);
-	filp->private_data = pgmn_dev;
-
-	GMN_DBG("%s:%d]\n", __func__, __LINE__);
-
-	rc = __msm_gemini_open(pgmn_dev);
-
-	GMN_DBG(KERN_INFO "%s:%d] %s open_count = %d\n", __func__, __LINE__,
-		filp->f_path.dentry->d_name.name, pgmn_dev->open_count);
-
-	return rc;
-}
-
-static int msm_gemini_release(struct inode *inode, struct file *filp)
-{
-	int rc;
-
-	struct msm_gemini_device *pgmn_dev = filp->private_data;
-
-	GMN_DBG(KERN_INFO "%s:%d]\n", __func__, __LINE__);
-
-	rc = __msm_gemini_release(pgmn_dev);
-
-	GMN_DBG(KERN_INFO "%s:%d] %s open_count = %d\n", __func__, __LINE__,
-		filp->f_path.dentry->d_name.name, pgmn_dev->open_count);
-	return rc;
-}
-
-static long msm_gemini_ioctl(struct file *filp, unsigned int cmd,
-	unsigned long arg)
-{
-	int rc;
-	struct msm_gemini_device *pgmn_dev = filp->private_data;
-
-	GMN_DBG("%s:%d] cmd=%d pgmn_dev=0x%x arg=0x%x\n", __func__,
-		__LINE__, _IOC_NR(cmd), (uint32_t)pgmn_dev, (uint32_t)arg);
-
-	rc = __msm_gemini_ioctl(pgmn_dev, cmd, arg);
-
-	GMN_DBG("%s:%d]\n", __func__, __LINE__);
-	return rc;
-}
-
-static const struct file_operations msm_gemini_fops = {
-	.owner	  = THIS_MODULE,
-	.open	   = msm_gemini_open,
-	.release	= msm_gemini_release,
-	.unlocked_ioctl = msm_gemini_ioctl,
-};
-
-static struct class *msm_gemini_class;
-static dev_t msm_gemini_devno;
-struct msm_gemini_device *msm_gemini_device_p;
-
-int msm_gemini_subdev_init(struct v4l2_subdev *gemini_sd)
-{
-	int rc;
-	struct msm_gemini_device *pgmn_dev =
-		(struct msm_gemini_device *)gemini_sd->host_priv;
-
-	GMN_DBG("%s:%d: gemini_sd=0x%x pgmn_dev=0x%x\n",
-		__func__, __LINE__, (uint32_t)gemini_sd, (uint32_t)pgmn_dev);
-	rc = __msm_gemini_open(pgmn_dev);
-	GMN_DBG("%s:%d: rc=%d\n",
-		__func__, __LINE__, rc);
-	return rc;
-}
-
-static long msm_gemini_subdev_ioctl(struct v4l2_subdev *sd,
-	unsigned int cmd, void *arg)
-{
-	long rc;
-	struct msm_gemini_device *pgmn_dev =
-		(struct msm_gemini_device *)sd->host_priv;
-
-	GMN_DBG("%s: cmd=%d\n", __func__, cmd);
-
-	GMN_DBG("%s: pgmn_dev 0x%x", __func__, (uint32_t)pgmn_dev);
-
-	GMN_DBG("%s: Calling __msm_gemini_ioctl\n", __func__);
-
-	rc = __msm_gemini_ioctl(pgmn_dev, cmd, (unsigned long)arg);
-	pr_debug("%s: X\n", __func__);
-	return rc;
-}
-
-void msm_gemini_subdev_release(struct v4l2_subdev *gemini_sd)
-{
-	int rc;
-	struct msm_gemini_device *pgmn_dev =
-		(struct msm_gemini_device *)gemini_sd->host_priv;
-	GMN_DBG("%s:pgmn_dev=0x%x", __func__, (uint32_t)pgmn_dev);
-	rc = __msm_gemini_release(pgmn_dev);
-	GMN_DBG("%s:rc=%d", __func__, rc);
-}
-
-static const struct v4l2_subdev_core_ops msm_gemini_subdev_core_ops = {
-	.ioctl = msm_gemini_subdev_ioctl,
-};
-
-static const struct v4l2_subdev_ops msm_gemini_subdev_ops = {
-	.core = &msm_gemini_subdev_core_ops,
-};
-
-static int msm_gemini_init(struct platform_device *pdev)
-{
-	int rc = -1;
-	struct device *dev;
-
-	GMN_DBG("%s:\n", __func__);
-	msm_gemini_device_p = __msm_gemini_init(pdev);
-	if (msm_gemini_device_p == NULL) {
-		GMN_PR_ERR("%s: initialization failed\n", __func__);
-		goto fail;
-	}
-
-	v4l2_subdev_init(&msm_gemini_device_p->subdev, &msm_gemini_subdev_ops);
-	v4l2_set_subdev_hostdata(&msm_gemini_device_p->subdev,
-		msm_gemini_device_p);
-	pr_debug("%s: msm_gemini_device_p 0x%x", __func__,
-			(uint32_t)msm_gemini_device_p);
-	GMN_DBG("%s:gemini: platform_set_drvdata\n", __func__);
-	platform_set_drvdata(pdev, &msm_gemini_device_p->subdev);
-
-	rc = alloc_chrdev_region(&msm_gemini_devno, 0, 1, MSM_GEMINI_NAME);
-	if (rc < 0) {
-		GMN_PR_ERR("%s: failed to allocate chrdev\n", __func__);
-		goto fail_1;
-	}
-
-	if (!msm_gemini_class) {
-		msm_gemini_class = class_create(THIS_MODULE, MSM_GEMINI_NAME);
-		if (IS_ERR(msm_gemini_class)) {
-			rc = PTR_ERR(msm_gemini_class);
-			GMN_PR_ERR("%s: create device class failed\n",
-				__func__);
-			goto fail_2;
-		}
-	}
-
-	dev = device_create(msm_gemini_class, NULL,
-		MKDEV(MAJOR(msm_gemini_devno), MINOR(msm_gemini_devno)), NULL,
-		"%s%d", MSM_GEMINI_NAME, 0);
-
-	if (IS_ERR(dev)) {
-		GMN_PR_ERR("%s: error creating device\n", __func__);
-		rc = -ENODEV;
-		goto fail_3;
-	}
-
-	cdev_init(&msm_gemini_device_p->cdev, &msm_gemini_fops);
-	msm_gemini_device_p->cdev.owner = THIS_MODULE;
-	msm_gemini_device_p->cdev.ops   =
-		(const struct file_operations *) &msm_gemini_fops;
-	rc = cdev_add(&msm_gemini_device_p->cdev, msm_gemini_devno, 1);
-	if (rc < 0) {
-		GMN_PR_ERR("%s: error adding cdev\n", __func__);
-		rc = -ENODEV;
-		goto fail_4;
-	}
-
-	GMN_DBG("%s %s: success\n", __func__, MSM_GEMINI_NAME);
-
-	return rc;
-
-fail_4:
-	device_destroy(msm_gemini_class, msm_gemini_devno);
-
-fail_3:
-	class_destroy(msm_gemini_class);
-
-fail_2:
-	unregister_chrdev_region(msm_gemini_devno, 1);
-
-fail_1:
-	__msm_gemini_exit(msm_gemini_device_p);
-
-fail:
-	return rc;
-}
-
-static void msm_gemini_exit(void)
-{
-	cdev_del(&msm_gemini_device_p->cdev);
-	device_destroy(msm_gemini_class, msm_gemini_devno);
-	class_destroy(msm_gemini_class);
-	unregister_chrdev_region(msm_gemini_devno, 1);
-
-	__msm_gemini_exit(msm_gemini_device_p);
-}
-
-static int __msm_gemini_probe(struct platform_device *pdev)
-{
-	return msm_gemini_init(pdev);
-}
-
-static int __msm_gemini_remove(struct platform_device *pdev)
-{
-	msm_gemini_exit();
-	return 0;
-}
-
-static struct platform_driver msm_gemini_driver = {
-	.probe  = __msm_gemini_probe,
-	.remove = __msm_gemini_remove,
-	.driver = {
-		.name = MSM_GEMINI_DRV_NAME,
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init msm_gemini_driver_init(void)
-{
-	int rc;
-	rc = platform_driver_register(&msm_gemini_driver);
-	return rc;
-}
-
-static void __exit msm_gemini_driver_exit(void)
-{
-	platform_driver_unregister(&msm_gemini_driver);
-}
-
-MODULE_DESCRIPTION("msm gemini jpeg driver");
-MODULE_VERSION("msm gemini 0.1");
-
-module_init(msm_gemini_driver_init);
-module_exit(msm_gemini_driver_exit);
-
diff --git a/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_hw.c b/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_hw.c
deleted file mode 100644
index de0ed97..0000000
--- a/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_hw.c
+++ /dev/null
@@ -1,525 +0,0 @@
-/* Copyright (c) 2010,2013 The Linux Foundation. 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.
- */
-
-#include <linux/module.h>
-#include <linux/delay.h>
-#include "msm_gemini_hw.h"
-#include "msm_gemini_common.h"
-
-#include <linux/io.h>
-
-static void *gemini_region_base;
-static uint32_t gemini_region_size;
-
-int msm_gemini_hw_pingpong_update(struct msm_gemini_hw_pingpong *pingpong_hw,
-	struct msm_gemini_hw_buf *buf)
-{
-	int buf_free_index = -1;
-
-	if (!pingpong_hw->buf_status[0]) {
-		buf_free_index = 0;
-	} else if (!pingpong_hw->buf_status[1]) {
-		buf_free_index = 1;
-	} else {
-		GMN_PR_ERR("%s:%d: pingpong buffer busy\n", __func__, __LINE__);
-		return -1;
-	}
-
-	pingpong_hw->buf[buf_free_index] = *buf;
-	pingpong_hw->buf_status[buf_free_index] = 1;
-
-	if (pingpong_hw->is_fe) {
-		/* it is fe */
-		msm_gemini_hw_fe_buffer_update(
-			&pingpong_hw->buf[buf_free_index], buf_free_index);
-	} else {
-		/* it is we */
-		msm_gemini_hw_we_buffer_update(
-			&pingpong_hw->buf[buf_free_index], buf_free_index);
-	}
-	return 0;
-}
-
-void *msm_gemini_hw_pingpong_irq(struct msm_gemini_hw_pingpong *pingpong_hw)
-{
-	struct msm_gemini_hw_buf *buf_p = NULL;
-
-	if (pingpong_hw->buf_status[pingpong_hw->buf_active_index]) {
-		buf_p = &pingpong_hw->buf[pingpong_hw->buf_active_index];
-		pingpong_hw->buf_status[pingpong_hw->buf_active_index] = 0;
-	}
-
-	pingpong_hw->buf_active_index = !pingpong_hw->buf_active_index;
-
-	return (void *) buf_p;
-}
-
-void *msm_gemini_hw_pingpong_active_buffer(
-	struct msm_gemini_hw_pingpong *pingpong_hw)
-{
-	struct msm_gemini_hw_buf *buf_p = NULL;
-
-	if (pingpong_hw->buf_status[pingpong_hw->buf_active_index])
-		buf_p = &pingpong_hw->buf[pingpong_hw->buf_active_index];
-
-	return (void *) buf_p;
-}
-
-struct msm_gemini_hw_cmd hw_cmd_irq_get_status[] = {
-	/* type, repeat n times, offset, mask, data or pdata */
-	{MSM_GEMINI_HW_CMD_TYPE_READ, 1, HWIO_JPEG_IRQ_STATUS_ADDR,
-		HWIO_JPEG_IRQ_STATUS_RMSK, {0} },
-};
-
-int msm_gemini_hw_irq_get_status(void)
-{
-	uint32_t n_irq_status = 0;
-	rmb();
-	n_irq_status = msm_gemini_hw_read(&hw_cmd_irq_get_status[0]);
-	rmb();
-	return n_irq_status;
-}
-
-struct msm_gemini_hw_cmd hw_cmd_encode_output_size[] = {
-	/* type, repeat n times, offset, mask, data or pdata */
-	{MSM_GEMINI_HW_CMD_TYPE_READ, 1,
-		HWIO_JPEG_STATUS_ENCODE_OUTPUT_SIZE_ADDR,
-		HWIO_JPEG_STATUS_ENCODE_OUTPUT_SIZE_RMSK, {0} },
-};
-
-long msm_gemini_hw_encode_output_size(void)
-{
-	uint32_t encode_output_size = 0;
-
-	encode_output_size = msm_gemini_hw_read(&hw_cmd_encode_output_size[0]);
-
-	return encode_output_size;
-}
-
-struct msm_gemini_hw_cmd hw_cmd_irq_clear[] = {
-	/* type, repeat n times, offset, mask, data or pdata */
-	{MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_IRQ_CLEAR_ADDR,
-		HWIO_JPEG_IRQ_CLEAR_RMSK, {JPEG_IRQ_CLEAR_ALL} },
-};
-
-void msm_gemini_hw_irq_clear(uint32_t mask, uint32_t data)
-{
-	GMN_DBG("%s:%d] mask %0x data %0x", __func__, __LINE__, mask, data);
-	hw_cmd_irq_clear[0].mask = mask;
-	hw_cmd_irq_clear[0].data = data;
-	msm_gemini_hw_write(&hw_cmd_irq_clear[0]);
-}
-
-struct msm_gemini_hw_cmd hw_cmd_fe_ping_update[] = {
-	/* type, repeat n times, offset, mask, data or pdata */
-	{MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_FE_BUFFER_CFG_ADDR,
-		HWIO_JPEG_FE_BUFFER_CFG_RMSK, {0} },
-	{MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_FE_Y_PING_ADDR_ADDR,
-		HWIO_JPEG_FE_Y_PING_ADDR_RMSK, {0} },
-	{MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_FE_CBCR_PING_ADDR_ADDR,
-		HWIO_JPEG_FE_CBCR_PING_ADDR_RMSK, {0} },
-	{MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_FE_CMD_ADDR,
-		HWIO_JPEG_FE_CMD_RMSK, {JPEG_FE_CMD_BUFFERRELOAD} },
-};
-
-struct msm_gemini_hw_cmd hw_cmd_fe_pong_update[] = {
-	/* type, repeat n times, offset, mask, data or pdata */
-	{MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_FE_BUFFER_CFG_ADDR,
-		HWIO_JPEG_FE_BUFFER_CFG_RMSK, {0} },
-	{MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_FE_Y_PONG_ADDR_ADDR,
-		HWIO_JPEG_FE_Y_PONG_ADDR_RMSK, {0} },
-	{MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_FE_CBCR_PONG_ADDR_ADDR,
-		HWIO_JPEG_FE_CBCR_PONG_ADDR_RMSK, {0} },
-	{MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_FE_CMD_ADDR,
-		HWIO_JPEG_FE_CMD_RMSK, {JPEG_FE_CMD_BUFFERRELOAD} },
-};
-
-void msm_gemini_hw_fe_buffer_update(struct msm_gemini_hw_buf *p_input,
-	uint8_t pingpong_index)
-{
-	uint32_t n_reg_val = 0;
-
-	struct msm_gemini_hw_cmd *hw_cmd_p;
-
-	if (pingpong_index == 0) {
-		hw_cmd_p = &hw_cmd_fe_ping_update[0];
-		n_reg_val = ((((p_input->num_of_mcu_rows - 1) <<
-			HWIO_JPEG_FE_BUFFER_CFG_CBCR_MCU_ROWS_SHFT) &
-			HWIO_JPEG_FE_BUFFER_CFG_CBCR_MCU_ROWS_BMSK) |
-			(((p_input->num_of_mcu_rows - 1) <<
-			HWIO_JPEG_FE_BUFFER_CFG_Y_MCU_ROWS_SHFT) &
-			HWIO_JPEG_FE_BUFFER_CFG_Y_MCU_ROWS_BMSK));
-		hw_cmd_p->data = n_reg_val;
-		msm_gemini_hw_write(hw_cmd_p++);
-
-		n_reg_val = ((p_input->y_buffer_addr <<
-			HWIO_JPEG_FE_Y_PING_ADDR_FE_Y_PING_START_ADDR_SHFT) &
-			HWIO_JPEG_FE_Y_PING_ADDR_FE_Y_PING_START_ADDR_BMSK);
-		hw_cmd_p->data = n_reg_val;
-		msm_gemini_hw_write(hw_cmd_p++);
-
-		n_reg_val = ((p_input->cbcr_buffer_addr<<
-		HWIO_JPEG_FE_CBCR_PING_ADDR_FE_CBCR_PING_START_ADDR_SHFT) &
-		HWIO_JPEG_FE_CBCR_PING_ADDR_FE_CBCR_PING_START_ADDR_BMSK);
-		hw_cmd_p->data = n_reg_val;
-		msm_gemini_hw_write(hw_cmd_p++);
-
-		msm_gemini_hw_write(hw_cmd_p);
-	} else if (pingpong_index == 1) {
-		hw_cmd_p = &hw_cmd_fe_pong_update[0];
-		n_reg_val = ((((p_input->num_of_mcu_rows - 1) <<
-			HWIO_JPEG_FE_BUFFER_CFG_CBCR_MCU_ROWS_SHFT) &
-			HWIO_JPEG_FE_BUFFER_CFG_CBCR_MCU_ROWS_BMSK) |
-			(((p_input->num_of_mcu_rows - 1) <<
-			HWIO_JPEG_FE_BUFFER_CFG_Y_MCU_ROWS_SHFT) &
-			HWIO_JPEG_FE_BUFFER_CFG_Y_MCU_ROWS_BMSK));
-		hw_cmd_p->data = n_reg_val;
-		msm_gemini_hw_write(hw_cmd_p++);
-
-		n_reg_val = ((p_input->y_buffer_addr <<
-			HWIO_JPEG_FE_Y_PONG_ADDR_FE_Y_PONG_START_ADDR_SHFT) &
-			HWIO_JPEG_FE_Y_PONG_ADDR_FE_Y_PONG_START_ADDR_BMSK);
-		hw_cmd_p->data = n_reg_val;
-		msm_gemini_hw_write(hw_cmd_p++);
-
-		n_reg_val = ((p_input->cbcr_buffer_addr<<
-		HWIO_JPEG_FE_CBCR_PONG_ADDR_FE_CBCR_PONG_START_ADDR_SHFT) &
-		HWIO_JPEG_FE_CBCR_PONG_ADDR_FE_CBCR_PONG_START_ADDR_BMSK);
-		hw_cmd_p->data = n_reg_val;
-		msm_gemini_hw_write(hw_cmd_p++);
-
-		msm_gemini_hw_write(hw_cmd_p);
-	} else {
-		/* shall not get to here */
-	}
-
-	return;
-}
-
-struct msm_gemini_hw_cmd hw_cmd_fe_start[] = {
-	/* type, repeat n times, offset, mask, data or pdata */
-	{MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_FE_CMD_ADDR,
-		HWIO_JPEG_FE_CMD_RMSK, {JPEG_OFFLINE_CMD_START} },
-};
-
-void msm_gemini_hw_fe_start(void)
-{
-	msm_gemini_hw_write(&hw_cmd_fe_start[0]);
-
-	return;
-}
-
-struct msm_gemini_hw_cmd hw_cmd_we_buffer_cfg[] = {
-	/* type, repeat n times, offset, mask, data or pdata */
-	{MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_WE_Y_THRESHOLD_ADDR,
-		HWIO_JPEG_WE_Y_THRESHOLD_RMSK, {0} },
-	{MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_WE_Y_UB_CFG_ADDR,
-		HWIO_JPEG_WE_Y_UB_CFG_RMSK, {JPEG_WE_YUB_ENCODE} },
-	{MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_WE_CBCR_THRESHOLD_ADDR,
-		HWIO_JPEG_WE_CBCR_THRESHOLD_RMSK, {0} },
-};
-
-/* first dimension is WE_ASSERT_STALL_TH and WE_DEASSERT_STALL_TH
-   second dimension is for offline and real-time settings
- */
-static const uint32_t GEMINI_WE_Y_THRESHOLD[2][2] = {
-	{ 0x00000190, 0x000001ff },
-	{ 0x0000016a, 0x000001ff }
-};
-
-/* first dimension is WE_ASSERT_STALL_TH and WE_DEASSERT_STALL_TH
-   second dimension is for offline and real-time settings
- */
-static const uint32_t GEMINI_WE_CBCR_THRESHOLD[2][2] = {
-	{ 0x00000190, 0x000001ff },
-	{ 0x0000016a, 0x000001ff }
-};
-
-void msm_gemini_hw_we_buffer_cfg(uint8_t is_realtime)
-{
-	uint32_t              n_reg_val = 0;
-
-	struct msm_gemini_hw_cmd *hw_cmd_p = &hw_cmd_we_buffer_cfg[0];
-
-	n_reg_val = (((GEMINI_WE_Y_THRESHOLD[1][is_realtime] <<
-		HWIO_JPEG_WE_Y_THRESHOLD_WE_DEASSERT_STALL_TH_SHFT) &
-		HWIO_JPEG_WE_Y_THRESHOLD_WE_DEASSERT_STALL_TH_BMSK) |
-		((GEMINI_WE_Y_THRESHOLD[0][is_realtime] <<
-		HWIO_JPEG_WE_Y_THRESHOLD_WE_ASSERT_STALL_TH_SHFT) &
-		HWIO_JPEG_WE_Y_THRESHOLD_WE_ASSERT_STALL_TH_BMSK));
-	hw_cmd_p->data = n_reg_val;
-	msm_gemini_hw_write(hw_cmd_p++);
-
-	msm_gemini_hw_write(hw_cmd_p++);
-
-	/* @todo maybe not for realtime? */
-	n_reg_val = (((GEMINI_WE_CBCR_THRESHOLD[1][is_realtime] <<
-		HWIO_JPEG_WE_CBCR_THRESHOLD_WE_DEASSERT_STALL_TH_SHFT) &
-		HWIO_JPEG_WE_CBCR_THRESHOLD_WE_DEASSERT_STALL_TH_BMSK) |
-		((GEMINI_WE_CBCR_THRESHOLD[0][is_realtime] <<
-		HWIO_JPEG_WE_CBCR_THRESHOLD_WE_ASSERT_STALL_TH_SHFT) &
-		HWIO_JPEG_WE_CBCR_THRESHOLD_WE_ASSERT_STALL_TH_BMSK));
-	hw_cmd_p->data = n_reg_val;
-	msm_gemini_hw_write(hw_cmd_p);
-
-	return;
-}
-
-struct msm_gemini_hw_cmd hw_cmd_we_ping_update[] = {
-	/* type, repeat n times, offset, mask, data or pdata */
-	{MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_WE_Y_PING_BUFFER_CFG_ADDR,
-		HWIO_JPEG_WE_Y_PING_BUFFER_CFG_RMSK, {0} },
-	{MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_WE_Y_PING_ADDR_ADDR,
-		HWIO_JPEG_WE_Y_PING_ADDR_RMSK, {0} },
-};
-
-struct msm_gemini_hw_cmd hw_cmd_we_pong_update[] = {
-	/* type, repeat n times, offset, mask, data or pdata */
-	{MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_WE_Y_PONG_BUFFER_CFG_ADDR,
-		HWIO_JPEG_WE_Y_PONG_BUFFER_CFG_RMSK, {0} },
-	{MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_WE_Y_PONG_ADDR_ADDR,
-		HWIO_JPEG_WE_Y_PONG_ADDR_RMSK, {0} },
-};
-
-void msm_gemini_hw_we_buffer_update(struct msm_gemini_hw_buf *p_input,
-	uint8_t pingpong_index)
-{
-	uint32_t n_reg_val = 0;
-
-	struct msm_gemini_hw_cmd *hw_cmd_p;
-
-	pr_debug("%s:%d] pingpong index %d", __func__, __LINE__,
-		pingpong_index);
-	if (pingpong_index == 0) {
-		hw_cmd_p = &hw_cmd_we_ping_update[0];
-
-		n_reg_val = ((p_input->y_len <<
-			HWIO_JPEG_WE_Y_PING_BUFFER_CFG_WE_BUFFER_LENGTH_SHFT) &
-			HWIO_JPEG_WE_Y_PING_BUFFER_CFG_WE_BUFFER_LENGTH_BMSK);
-		hw_cmd_p->data = n_reg_val;
-		msm_gemini_hw_write(hw_cmd_p++);
-
-		n_reg_val = p_input->y_buffer_addr;
-		hw_cmd_p->data = n_reg_val;
-		msm_gemini_hw_write(hw_cmd_p++);
-	} else if (pingpong_index == 1) {
-		hw_cmd_p = &hw_cmd_we_pong_update[0];
-
-		n_reg_val = ((p_input->y_len <<
-			HWIO_JPEG_WE_Y_PONG_BUFFER_CFG_WE_BUFFER_LENGTH_SHFT) &
-			HWIO_JPEG_WE_Y_PONG_BUFFER_CFG_WE_BUFFER_LENGTH_BMSK);
-		hw_cmd_p->data = n_reg_val;
-		msm_gemini_hw_write(hw_cmd_p++);
-
-		n_reg_val = p_input->y_buffer_addr;
-		hw_cmd_p->data = n_reg_val;
-		msm_gemini_hw_write(hw_cmd_p++);
-	} else {
-		/* shall not get to here */
-	}
-
-	return;
-}
-
-struct msm_gemini_hw_cmd hw_cmd_reset[] = {
-	/* type, repeat n times, offset, mask, data or pdata */
-	{MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_IRQ_MASK_ADDR,
-		HWIO_JPEG_IRQ_MASK_RMSK, {JPEG_IRQ_DISABLE_ALL} },
-	{MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_IRQ_CLEAR_ADDR,
-		HWIO_JPEG_IRQ_MASK_RMSK, {JPEG_IRQ_CLEAR_ALL} },
-	{MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_IRQ_MASK_ADDR,
-		HWIO_JPEG_IRQ_MASK_RMSK, {JPEG_IRQ_ALLSOURCES_ENABLE} },
-	{MSM_GEMINI_HW_CMD_TYPE_WRITE, 1, HWIO_JPEG_RESET_CMD_ADDR,
-		HWIO_JPEG_RESET_CMD_RMSK, {JPEG_RESET_DEFAULT} },
-};
-
-void msm_gemini_hw_init(void *base, int size)
-{
-	gemini_region_base = base;
-	gemini_region_size = size;
-}
-
-void msm_gemini_hw_reset(void *base, int size)
-{
-	struct msm_gemini_hw_cmd *hw_cmd_p;
-
-	hw_cmd_p = &hw_cmd_reset[0];
-
-	wmb();
-	msm_gemini_hw_write(hw_cmd_p++);
-	msm_gemini_hw_write(hw_cmd_p++);
-	msm_gemini_hw_write(hw_cmd_p++);
-	msm_gemini_hw_write(hw_cmd_p);
-	wmb();
-
-	return;
-}
-
-uint32_t msm_gemini_hw_read(struct msm_gemini_hw_cmd *hw_cmd_p)
-{
-	uint32_t *paddr;
-	uint32_t data;
-
-	paddr = gemini_region_base + hw_cmd_p->offset;
-
-	data = readl(paddr);
-	data &= hw_cmd_p->mask;
-
-	GMN_DBG("%s:%d] type-%d n-%d offset-0x%4x mask-0x%8x data-0x%8x\n",
-		__func__, __LINE__, hw_cmd_p->type, hw_cmd_p->n,
-		hw_cmd_p->offset, hw_cmd_p->mask, data);
-	return data;
-}
-
-void msm_gemini_hw_write(struct msm_gemini_hw_cmd *hw_cmd_p)
-{
-	uint32_t *paddr;
-	uint32_t old_data, new_data;
-
-	/* type, repeat n times, offset, mask, data or pdata */
-	GMN_DBG("%s:%d] type-%d n-%d offset-0x%4x mask-0x%8x data-0x%8x\n",
-		__func__, __LINE__, hw_cmd_p->type, hw_cmd_p->n,
-		hw_cmd_p->offset, hw_cmd_p->mask, hw_cmd_p->data);
-
-	paddr = gemini_region_base + hw_cmd_p->offset;
-
-	if (hw_cmd_p->mask == 0xffffffff) {
-		old_data = 0;
-	} else {
-		old_data = readl(paddr);
-		old_data &= ~hw_cmd_p->mask;
-	}
-
-	new_data = hw_cmd_p->data & hw_cmd_p->mask;
-	new_data |= old_data;
-	writel(new_data, paddr);
-}
-
-int msm_gemini_hw_wait(struct msm_gemini_hw_cmd *hw_cmd_p, int m_us)
-{
-	int tm = hw_cmd_p->n;
-	uint32_t data;
-	uint32_t wait_data = hw_cmd_p->data & hw_cmd_p->mask;
-
-	data = msm_gemini_hw_read(hw_cmd_p);
-	if (data != wait_data) {
-		while (tm) {
-			udelay(m_us);
-			data = msm_gemini_hw_read(hw_cmd_p);
-			if (data == wait_data)
-				break;
-			tm--;
-		}
-	}
-	hw_cmd_p->data = data;
-	return tm;
-}
-
-void msm_gemini_hw_delay(struct msm_gemini_hw_cmd *hw_cmd_p, int m_us)
-{
-	int tm = hw_cmd_p->n;
-	while (tm) {
-		udelay(m_us);
-		tm--;
-	}
-}
-
-int msm_gemini_hw_exec_cmds(struct msm_gemini_hw_cmd *hw_cmd_p, uint32_t m_cmds)
-{
-	int is_copy_to_user = -1;
-	uint32_t data;
-
-	while (m_cmds--) {
-		if (hw_cmd_p->offset > gemini_region_size) {
-			GMN_PR_ERR("%s:%d] %d exceed hw region %d\n", __func__,
-				__LINE__, hw_cmd_p->offset, gemini_region_size);
-			return -EFAULT;
-		}
-
-		switch (hw_cmd_p->type) {
-		case MSM_GEMINI_HW_CMD_TYPE_READ:
-			hw_cmd_p->data = msm_gemini_hw_read(hw_cmd_p);
-			is_copy_to_user = 1;
-			break;
-
-		case MSM_GEMINI_HW_CMD_TYPE_WRITE:
-			msm_gemini_hw_write(hw_cmd_p);
-			break;
-
-		case MSM_GEMINI_HW_CMD_TYPE_WRITE_OR:
-			data = msm_gemini_hw_read(hw_cmd_p);
-			hw_cmd_p->data = (hw_cmd_p->data & hw_cmd_p->mask) |
-				data;
-			msm_gemini_hw_write(hw_cmd_p);
-			break;
-
-		case MSM_GEMINI_HW_CMD_TYPE_UWAIT:
-			msm_gemini_hw_wait(hw_cmd_p, 1);
-			break;
-
-		case MSM_GEMINI_HW_CMD_TYPE_MWAIT:
-			msm_gemini_hw_wait(hw_cmd_p, 1000);
-			break;
-
-		case MSM_GEMINI_HW_CMD_TYPE_UDELAY:
-			msm_gemini_hw_delay(hw_cmd_p, 1);
-			break;
-
-		case MSM_GEMINI_HW_CMD_TYPE_MDELAY:
-			msm_gemini_hw_delay(hw_cmd_p, 1000);
-			break;
-
-		default:
-			GMN_PR_ERR("wrong hw command type\n");
-			break;
-		}
-
-		hw_cmd_p++;
-	}
-	return is_copy_to_user;
-}
-
-#ifdef MSM_GMN_DBG_DUMP
-void msm_gemini_io_dump(int size)
-{
-	char line_str[128], *p_str;
-	void __iomem *addr = gemini_region_base;
-	int i;
-	u32 *p = (u32 *) addr;
-	u32 data;
-	pr_info("%s: %p %d reg_size %d\n", __func__, addr, size,
-							gemini_region_size);
-	line_str[0] = '\0';
-	p_str = line_str;
-	for (i = 0; i < size/4; i++) {
-		if (i % 4 == 0) {
-			snprintf(p_str, 12, "%08x: ", (u32) p);
-			p_str += 10;
-		}
-		data = readl_relaxed(p++);
-		snprintf(p_str, 12, "%08x ", data);
-		p_str += 9;
-		if ((i + 1) % 4 == 0) {
-			pr_info("%s\n", line_str);
-			line_str[0] = '\0';
-			p_str = line_str;
-		}
-	}
-	if (line_str[0] != '\0')
-		pr_info("%s\n", line_str);
-}
-#else
-void msm_gemini_io_dump(int size)
-{
-
-}
-#endif
diff --git a/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_hw.h b/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_hw.h
deleted file mode 100644
index 4d08282..0000000
--- a/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_hw.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* Copyright (c) 2010-2013, The Linux Foundation. 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.
- */
-
-#ifndef MSM_GEMINI_HW_H
-#define MSM_GEMINI_HW_H
-
-#include <media/msm_gemini.h>
-#include "msm_gemini_hw_reg.h"
-#include <linux/msm_ion.h>
-#include <mach/iommu_domains.h>
-
-struct msm_gemini_hw_buf {
-	struct msm_gemini_buf vbuf;
-	struct file  *file;
-	uint32_t framedone_len;
-	uint32_t y_buffer_addr;
-	uint32_t y_len;
-	uint32_t cbcr_buffer_addr;
-	uint32_t cbcr_len;
-	uint32_t num_of_mcu_rows;
-	struct ion_handle *handle;
-};
-
-struct msm_gemini_hw_pingpong {
-	uint8_t is_fe; /* 1: fe; 0: we */
-	struct  msm_gemini_hw_buf buf[2];
-	int     buf_status[2];
-	int     buf_active_index;
-};
-
-int msm_gemini_hw_pingpong_update(struct msm_gemini_hw_pingpong *pingpong_hw,
-	struct msm_gemini_hw_buf *buf);
-void *msm_gemini_hw_pingpong_irq(struct msm_gemini_hw_pingpong *pingpong_hw);
-void *msm_gemini_hw_pingpong_active_buffer(struct msm_gemini_hw_pingpong
-	*pingpong_hw);
-
-void msm_gemini_hw_irq_clear(uint32_t, uint32_t);
-int msm_gemini_hw_irq_get_status(void);
-long msm_gemini_hw_encode_output_size(void);
-#define MSM_GEMINI_HW_MASK_COMP_FRAMEDONE \
-		MSM_GEMINI_HW_IRQ_STATUS_FRAMEDONE_MASK
-#define MSM_GEMINI_HW_MASK_COMP_FE \
-		MSM_GEMINI_HW_IRQ_STATUS_FE_RD_DONE_MASK
-#define MSM_GEMINI_HW_MASK_COMP_WE \
-		(MSM_GEMINI_HW_IRQ_STATUS_WE_Y_PINGPONG_MASK | \
-		 MSM_GEMINI_HW_IRQ_STATUS_WE_CBCR_PINGPONG_MASK)
-#define MSM_GEMINI_HW_MASK_COMP_RESET_ACK \
-		MSM_GEMINI_HW_IRQ_STATUS_RESET_ACK_MASK
-#define MSM_GEMINI_HW_MASK_COMP_ERR \
-		(MSM_GEMINI_HW_IRQ_STATUS_FE_RTOVF_MASK | \
-		MSM_GEMINI_HW_IRQ_STATUS_FE_VFE_OVERFLOW_MASK | \
-		MSM_GEMINI_HW_IRQ_STATUS_WE_Y_BUFFER_OVERFLOW_MASK | \
-		MSM_GEMINI_HW_IRQ_STATUS_WE_CBCR_BUFFER_OVERFLOW_MASK | \
-		MSM_GEMINI_HW_IRQ_STATUS_WE_CH0_DATAFIFO_OVERFLOW_MASK | \
-		MSM_GEMINI_HW_IRQ_STATUS_WE_CH1_DATAFIFO_OVERFLOW_MASK | \
-		MSM_GEMINI_HW_IRQ_STATUS_BUS_ERROR_MASK | \
-		MSM_GEMINI_HW_IRQ_STATUS_VIOLATION_MASK)
-
-#define msm_gemini_hw_irq_is_frame_done(gemini_irq_status) \
-	(gemini_irq_status & MSM_GEMINI_HW_MASK_COMP_FRAMEDONE)
-#define msm_gemini_hw_irq_is_fe_pingpong(gemini_irq_status) \
-	(gemini_irq_status & MSM_GEMINI_HW_MASK_COMP_FE)
-#define msm_gemini_hw_irq_is_we_pingpong(gemini_irq_status) \
-	(gemini_irq_status & MSM_GEMINI_HW_MASK_COMP_WE)
-#define msm_gemini_hw_irq_is_reset_ack(gemini_irq_status) \
-	(gemini_irq_status & MSM_GEMINI_HW_MASK_COMP_RESET_ACK)
-#define msm_gemini_hw_irq_is_err(gemini_irq_status) \
-	(gemini_irq_status & MSM_GEMINI_HW_MASK_COMP_ERR)
-
-void msm_gemini_hw_fe_buffer_update(struct msm_gemini_hw_buf *p_input,
-	uint8_t pingpong_index);
-void msm_gemini_hw_we_buffer_update(struct msm_gemini_hw_buf *p_input,
-	uint8_t pingpong_index);
-
-void msm_gemini_hw_we_buffer_cfg(uint8_t is_realtime);
-
-void msm_gemini_hw_fe_start(void);
-void msm_gemini_hw_clk_cfg(void);
-
-void msm_gemini_hw_reset(void *base, int size);
-void msm_gemini_hw_irq_cfg(void);
-void msm_gemini_hw_init(void *base, int size);
-
-uint32_t msm_gemini_hw_read(struct msm_gemini_hw_cmd *hw_cmd_p);
-void msm_gemini_hw_write(struct msm_gemini_hw_cmd *hw_cmd_p);
-int msm_gemini_hw_wait(struct msm_gemini_hw_cmd *hw_cmd_p, int m_us);
-void msm_gemini_hw_delay(struct msm_gemini_hw_cmd *hw_cmd_p, int m_us);
-int msm_gemini_hw_exec_cmds(struct msm_gemini_hw_cmd *hw_cmd_p,
-	uint32_t m_cmds);
-void msm_gemini_io_dump(int size);
-
-#define MSM_GEMINI_PIPELINE_CLK_128MHZ 128 /* 8MP  128MHz */
-#define MSM_GEMINI_PIPELINE_CLK_140MHZ 140 /* 9MP  140MHz */
-#define MSM_GEMINI_PIPELINE_CLK_200MHZ 153 /* 12MP 153MHz */
-
-#endif /* MSM_GEMINI_HW_H */
diff --git a/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_hw_reg.h b/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_hw_reg.h
deleted file mode 100644
index 2fe6038..0000000
--- a/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_hw_reg.h
+++ /dev/null
@@ -1,176 +0,0 @@
-/* Copyright (c) 2010, 2013, The Linux Foundation. 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.
- */
-
-#ifndef MSM_GEMINI_HW_REG_H
-#define MSM_GEMINI_HW_REG_H
-
-#define GEMINI_REG_BASE 0
-
-#define MSM_GEMINI_HW_IRQ_MASK_ADDR 0x00000014
-#define MSM_GEMINI_HW_IRQ_MASK_RMSK 0xffffffff
-#define MSM_GEMINI_HW_IRQ_MASK_SHFT 0
-#define MSM_GEMINI_HW_IRQ_DISABLE 0
-#define MSM_GEMINI_HW_IRQ_ENABLE 0xffffffff
-
-#define MSM_GEMINI_HW_IRQ_CLEAR_ADDR 0x00000018
-#define MSM_GEMINI_HW_IRQ_CLEAR_RMSK 0xffffffff
-#define MSM_GEMINI_HW_IRQ_CLEAR_SHFT 0
-#define MSM_GEMINI_HW_IRQ_CLEAR  0xffffffff
-
-#define MSM_GEMINI_HW_IRQ_STATUS_FRAMEDONE_MASK 0x00000001
-#define MSM_GEMINI_HW_IRQ_STATUS_FRAMEDONE_SHIFT 0x00000000
-
-#define MSM_GEMINI_HW_IRQ_STATUS_FE_RD_DONE_MASK 0x00000002
-#define MSM_GEMINI_HW_IRQ_STATUS_FE_RD_DONE_SHIFT 0x00000001
-
-#define MSM_GEMINI_HW_IRQ_STATUS_FE_RTOVF_MASK 0x00000004
-#define MSM_GEMINI_HW_IRQ_STATUS_FE_RTOVF_SHIFT 0x00000002
-
-#define MSM_GEMINI_HW_IRQ_STATUS_FE_VFE_OVERFLOW_MASK 0x00000008
-#define MSM_GEMINI_HW_IRQ_STATUS_FE_VFE_OVERFLOW_SHIFT 0x00000003
-
-#define MSM_GEMINI_HW_IRQ_STATUS_WE_Y_PINGPONG_MASK 0x00000010
-#define MSM_GEMINI_HW_IRQ_STATUS_WE_Y_PINGPONG_SHIFT 0x00000004
-
-#define MSM_GEMINI_HW_IRQ_STATUS_WE_CBCR_PINGPONG_MASK 0x00000020
-#define MSM_GEMINI_HW_IRQ_STATUS_WE_CBCR_PINGPONG_SHIFT 0x00000005
-
-#define MSM_GEMINI_HW_IRQ_STATUS_WE_Y_BUFFER_OVERFLOW_MASK 0x00000040
-#define MSM_GEMINI_HW_IRQ_STATUS_WE_Y_BUFFER_OVERFLOW_SHIFT 0x00000006
-
-#define MSM_GEMINI_HW_IRQ_STATUS_WE_CBCR_BUFFER_OVERFLOW_MASK 0x00000080
-#define MSM_GEMINI_HW_IRQ_STATUS_WE_CBCR_BUFFER_OVERFLOW_SHIFT 0x00000007
-
-#define MSM_GEMINI_HW_IRQ_STATUS_WE_CH0_DATAFIFO_OVERFLOW_MASK 0x00000100
-#define MSM_GEMINI_HW_IRQ_STATUS_WE_CH0_DATAFIFO_OVERFLOW_SHIFT 0x00000008
-
-#define MSM_GEMINI_HW_IRQ_STATUS_WE_CH1_DATAFIFO_OVERFLOW_MASK 0x00000200
-#define MSM_GEMINI_HW_IRQ_STATUS_WE_CH1_DATAFIFO_OVERFLOW_SHIFT 0x00000009
-
-#define MSM_GEMINI_HW_IRQ_STATUS_RESET_ACK_MASK 0x00000400
-#define MSM_GEMINI_HW_IRQ_STATUS_RESET_ACK_SHIFT 0x0000000a
-
-#define MSM_GEMINI_HW_IRQ_STATUS_BUS_ERROR_MASK 0x00000800
-#define MSM_GEMINI_HW_IRQ_STATUS_BUS_ERROR_SHIFT 0x0000000b
-
-#define MSM_GEMINI_HW_IRQ_STATUS_VIOLATION_MASK 0x00001000
-#define MSM_GEMINI_HW_IRQ_STATUS_VIOLATION_SHIFT 0x0000000c
-
-#define JPEG_BUS_CMD_HALT_REQ 0x00000001
-
-#define JPEG_REALTIME_CMD_STOP_FB 0x00000000
-#define JPEG_REALTIME_CMD_STOP_IM 0x00000003
-#define JPEG_REALTIME_CMD_START 0x00000001
-
-#define JPEG_OFFLINE_CMD_START 0x00000003
-
-#define JPEG_DMI_CFG_DISABLE 0x00000000
-#define JPEG_DMI_ADDR_START 0x00000000
-
-#define JPEG_FE_CMD_BUFFERRELOAD 0x00000001
-
-#define JPEG_WE_YUB_ENCODE 0x01ff0000
-
-#define JPEG_RESET_DEFAULT 0x0004ffff /* cfff? */
-
-#define JPEG_IRQ_DISABLE_ALL 0x00000000
-#define JPEG_IRQ_CLEAR_ALL 0xffffffff
-#define JPEG_IRQ_ALLSOURCES_ENABLE 0xffffffff
-
-#define HWIO_JPEG_FE_BUFFER_CFG_ADDR (GEMINI_REG_BASE + 0x00000080)
-#define HWIO_JPEG_FE_BUFFER_CFG_RMSK 0x1fff1fff
-
-#define HWIO_JPEG_FE_Y_PING_ADDR_ADDR (GEMINI_REG_BASE + 0x00000084)
-#define HWIO_JPEG_FE_Y_PING_ADDR_RMSK 0xffffffff
-
-#define HWIO_JPEG_FE_Y_PONG_ADDR_ADDR (GEMINI_REG_BASE + 0x00000088)
-#define HWIO_JPEG_FE_Y_PONG_ADDR_RMSK 0xffffffff
-
-#define HWIO_JPEG_FE_CBCR_PING_ADDR_ADDR (GEMINI_REG_BASE + 0x0000008c)
-#define HWIO_JPEG_FE_CBCR_PING_ADDR_RMSK 0xffffffff
-
-#define HWIO_JPEG_FE_CBCR_PONG_ADDR_ADDR (GEMINI_REG_BASE + 0x00000090)
-#define HWIO_JPEG_FE_CBCR_PONG_ADDR_RMSK 0xffffffff
-
-#define HWIO_JPEG_FE_CMD_ADDR (GEMINI_REG_BASE + 0x00000094)
-#define HWIO_JPEG_FE_CMD_RMSK 0x3
-
-#define HWIO_JPEG_FE_BUFFER_CFG_CBCR_MCU_ROWS_BMSK 0x1fff0000
-#define HWIO_JPEG_FE_BUFFER_CFG_CBCR_MCU_ROWS_SHFT 0x10
-#define HWIO_JPEG_FE_BUFFER_CFG_Y_MCU_ROWS_BMSK 0x1fff
-#define HWIO_JPEG_FE_BUFFER_CFG_Y_MCU_ROWS_SHFT 0
-
-#define HWIO_JPEG_FE_Y_PING_ADDR_FE_Y_PING_START_ADDR_BMSK 0xffffffff
-#define HWIO_JPEG_FE_Y_PING_ADDR_FE_Y_PING_START_ADDR_SHFT 0
-
-#define HWIO_JPEG_FE_CBCR_PING_ADDR_FE_CBCR_PING_START_ADDR_BMSK 0xffffffff
-#define HWIO_JPEG_FE_CBCR_PING_ADDR_FE_CBCR_PING_START_ADDR_SHFT 0
-
-#define HWIO_JPEG_FE_Y_PONG_ADDR_FE_Y_PONG_START_ADDR_BMSK 0xffffffff
-#define HWIO_JPEG_FE_Y_PONG_ADDR_FE_Y_PONG_START_ADDR_SHFT 0
-
-#define HWIO_JPEG_FE_CBCR_PONG_ADDR_FE_CBCR_PONG_START_ADDR_BMSK 0xffffffff
-#define HWIO_JPEG_FE_CBCR_PONG_ADDR_FE_CBCR_PONG_START_ADDR_SHFT 0
-
-#define HWIO_JPEG_WE_Y_THRESHOLD_ADDR (GEMINI_REG_BASE + 0x000000c0)
-#define HWIO_JPEG_WE_Y_THRESHOLD_RMSK 0x1ff01ff
-
-#define HWIO_JPEG_WE_CBCR_THRESHOLD_ADDR (GEMINI_REG_BASE      + 0x000000c4)
-#define HWIO_JPEG_WE_CBCR_THRESHOLD_RMSK 0x1ff01ff
-
-#define HWIO_JPEG_WE_Y_UB_CFG_ADDR (GEMINI_REG_BASE + 0x000000e8)
-#define HWIO_JPEG_WE_Y_UB_CFG_RMSK 0x1ff01ff
-
-#define HWIO_JPEG_WE_Y_THRESHOLD_WE_DEASSERT_STALL_TH_BMSK 0x1ff0000
-#define HWIO_JPEG_WE_Y_THRESHOLD_WE_DEASSERT_STALL_TH_SHFT 0x10
-#define HWIO_JPEG_WE_Y_THRESHOLD_WE_ASSERT_STALL_TH_BMSK 0x1ff
-#define HWIO_JPEG_WE_Y_THRESHOLD_WE_ASSERT_STALL_TH_SHFT 0
-
-#define HWIO_JPEG_WE_CBCR_THRESHOLD_WE_DEASSERT_STALL_TH_BMSK 0x1ff0000
-#define HWIO_JPEG_WE_CBCR_THRESHOLD_WE_DEASSERT_STALL_TH_SHFT 0x10
-#define HWIO_JPEG_WE_CBCR_THRESHOLD_WE_ASSERT_STALL_TH_BMSK 0x1ff
-#define HWIO_JPEG_WE_CBCR_THRESHOLD_WE_ASSERT_STALL_TH_SHFT 0
-
-#define HWIO_JPEG_WE_Y_PING_BUFFER_CFG_ADDR (GEMINI_REG_BASE + 0x000000c8)
-#define HWIO_JPEG_WE_Y_PING_BUFFER_CFG_RMSK 0x7fffff
-
-#define HWIO_JPEG_WE_Y_PING_ADDR_ADDR (GEMINI_REG_BASE + 0x000000d8)
-#define HWIO_JPEG_WE_Y_PING_ADDR_RMSK 0xfffffff8
-
-#define HWIO_JPEG_WE_Y_PONG_BUFFER_CFG_ADDR (GEMINI_REG_BASE + 0x000000cc)
-#define HWIO_JPEG_WE_Y_PONG_BUFFER_CFG_RMSK 0x7fffff
-
-#define HWIO_JPEG_WE_Y_PONG_ADDR_ADDR (GEMINI_REG_BASE + 0x000000dc)
-#define HWIO_JPEG_WE_Y_PONG_ADDR_RMSK 0xfffffff8
-
-#define HWIO_JPEG_WE_Y_PING_BUFFER_CFG_WE_BUFFER_LENGTH_BMSK 0x7fffff
-#define HWIO_JPEG_WE_Y_PING_BUFFER_CFG_WE_BUFFER_LENGTH_SHFT 0
-
-#define HWIO_JPEG_WE_Y_PONG_BUFFER_CFG_WE_BUFFER_LENGTH_BMSK 0x7fffff
-#define HWIO_JPEG_WE_Y_PONG_BUFFER_CFG_WE_BUFFER_LENGTH_SHFT 0
-
-#define HWIO_JPEG_IRQ_MASK_ADDR (GEMINI_REG_BASE + 0x00000014)
-#define HWIO_JPEG_IRQ_MASK_RMSK 0xffffffff
-
-#define HWIO_JPEG_IRQ_CLEAR_ADDR (GEMINI_REG_BASE + 0x00000018)
-#define HWIO_JPEG_IRQ_CLEAR_RMSK 0xffffffff
-
-#define HWIO_JPEG_RESET_CMD_ADDR (GEMINI_REG_BASE + 0x00000004)
-#define HWIO_JPEG_RESET_CMD_RMSK 0xe004ffff
-
-#define HWIO_JPEG_IRQ_STATUS_ADDR (GEMINI_REG_BASE + 0x0000001c)
-#define HWIO_JPEG_IRQ_STATUS_RMSK 0xffffffff
-
-#define HWIO_JPEG_STATUS_ENCODE_OUTPUT_SIZE_ADDR (GEMINI_REG_BASE + 0x00000034)
-#define HWIO_JPEG_STATUS_ENCODE_OUTPUT_SIZE_RMSK 0xffffffff
-
-#endif /* MSM_GEMINI_HW_REG_H */
diff --git a/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_platform.c b/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_platform.c
deleted file mode 100644
index f0882f7..0000000
--- a/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_platform.c
+++ /dev/null
@@ -1,250 +0,0 @@
-/* Copyright (c) 2010-2012, The Linux Foundation. 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.
- */
-
-#include <linux/module.h>
-#include <linux/pm_qos.h>
-#include <linux/clk.h>
-#include <mach/clk.h>
-#include <linux/io.h>
-
-#include <mach/camera.h>
-#include <mach/iommu_domains.h>
-
-#include "msm_gemini_platform.h"
-#include "msm_gemini_sync.h"
-#include "msm_gemini_common.h"
-#include "msm_gemini_hw.h"
-
-/* AXI rate in KHz */
-#define MSM_SYSTEM_BUS_RATE	160000
-struct ion_client *gemini_client;
-
-void msm_gemini_platform_p2v(struct file  *file,
-				struct ion_handle **ionhandle)
-{
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-	ion_unmap_iommu(gemini_client, *ionhandle, CAMERA_DOMAIN, GEN_POOL);
-	ion_free(gemini_client, *ionhandle);
-	*ionhandle = NULL;
-#endif
-}
-
-uint32_t msm_gemini_platform_v2p(int fd, uint32_t len, struct file **file_p,
-				struct ion_handle **ionhandle)
-{
-	unsigned long paddr;
-	unsigned long size;
-	int rc;
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-	*ionhandle = ion_import_dma_buf(gemini_client, fd);
-	if (IS_ERR_OR_NULL(*ionhandle))
-		return 0;
-
-	rc = ion_map_iommu(gemini_client, *ionhandle, CAMERA_DOMAIN, GEN_POOL,
-			SZ_4K, 0, &paddr, (unsigned long *)&size, 0, 0);
-#else
-	rc = 0;
-	paddr = 0;
-	size = 0;
-#endif
-	if (rc < 0) {
-		GMN_PR_ERR("%s: get_pmem_file fd %d error %d\n", __func__, fd,
-			rc);
-		goto error1;
-	}
-
-	/* validate user input */
-	if (len > size) {
-		GMN_PR_ERR("%s: invalid offset + len\n", __func__);
-		goto error1;
-	}
-
-	return paddr;
-error1:
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-	ion_free(gemini_client, *ionhandle);
-#endif
-	return 0;
-}
-
-static struct msm_cam_clk_info gemini_8x_clk_info[] = {
-	{"core_clk", 228571000},
-	{"iface_clk", -1},
-};
-
-static struct msm_cam_clk_info gemini_7x_clk_info[] = {
-	{"core_clk", 153600000},
-	{"iface_clk", -1},
-};
-
-static struct msm_cam_clk_info gemini_imem_clk_info[] = {
-	{"mem_clk", -1},
-};
-
-int msm_gemini_platform_init(struct platform_device *pdev,
-	struct resource **mem,
-	void **base,
-	int *irq,
-	irqreturn_t (*handler) (int, void *),
-	void *context)
-{
-	int rc = -1;
-	int gemini_irq;
-	struct resource *gemini_mem, *gemini_io, *gemini_irq_res;
-	void *gemini_base;
-	struct msm_gemini_device *pgmn_dev =
-		(struct msm_gemini_device *) context;
-
-	gemini_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!gemini_mem) {
-		GMN_PR_ERR("%s: no mem resource?\n", __func__);
-		return -ENODEV;
-	}
-
-	gemini_irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	if (!gemini_irq_res) {
-		GMN_PR_ERR("no irq resource?\n");
-		return -ENODEV;
-	}
-	gemini_irq = gemini_irq_res->start;
-
-	gemini_io = request_mem_region(gemini_mem->start,
-		resource_size(gemini_mem), pdev->name);
-	if (!gemini_io) {
-		GMN_PR_ERR("%s: region already claimed\n", __func__);
-		return -EBUSY;
-	}
-
-	gemini_base = ioremap(gemini_mem->start, resource_size(gemini_mem));
-	if (!gemini_base) {
-		rc = -ENOMEM;
-		GMN_PR_ERR("%s: ioremap failed\n", __func__);
-		goto fail1;
-	}
-
-	pgmn_dev->hw_version = GEMINI_8X60;
-	rc = msm_cam_clk_enable(&pgmn_dev->pdev->dev, gemini_8x_clk_info,
-	 pgmn_dev->gemini_clk, ARRAY_SIZE(gemini_8x_clk_info), 1);
-	if (rc < 0) {
-		pgmn_dev->hw_version = GEMINI_7X;
-		rc = msm_cam_clk_enable(&pgmn_dev->pdev->dev,
-			gemini_7x_clk_info, pgmn_dev->gemini_clk,
-			ARRAY_SIZE(gemini_7x_clk_info), 1);
-		if (rc < 0) {
-			GMN_PR_ERR("%s: clk failed rc = %d\n", __func__, rc);
-			goto fail2;
-		}
-	} else {
-		rc = msm_cam_clk_enable(&pgmn_dev->pdev->dev,
-				gemini_imem_clk_info, &pgmn_dev->gemini_clk[2],
-				ARRAY_SIZE(gemini_imem_clk_info), 1);
-		if (!rc)
-			pgmn_dev->hw_version = GEMINI_8960;
-	}
-
-	if (pgmn_dev->hw_version != GEMINI_7X) {
-		if (pgmn_dev->gemini_fs == NULL) {
-			pgmn_dev->gemini_fs =
-				regulator_get(&pgmn_dev->pdev->dev, "vdd");
-			if (IS_ERR(pgmn_dev->gemini_fs)) {
-				pr_err("%s: Regulator FS_ijpeg get failed %ld\n",
-					__func__, PTR_ERR(pgmn_dev->gemini_fs));
-				pgmn_dev->gemini_fs = NULL;
-				goto gemini_fs_failed;
-			} else if (regulator_enable(pgmn_dev->gemini_fs)) {
-				pr_err("%s: Regulator FS_ijpeg enable failed\n",
-								__func__);
-				regulator_put(pgmn_dev->gemini_fs);
-				pgmn_dev->gemini_fs = NULL;
-				goto gemini_fs_failed;
-			}
-		}
-	}
-
-	msm_gemini_hw_init(gemini_base, resource_size(gemini_mem));
-	rc = request_irq(gemini_irq, handler, IRQF_TRIGGER_RISING, "gemini",
-		context);
-	if (rc) {
-		GMN_PR_ERR("%s: request_irq failed, %d\n", __func__,
-			gemini_irq);
-		goto fail3;
-	}
-
-	*mem  = gemini_mem;
-	*base = gemini_base;
-	*irq  = gemini_irq;
-
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-	gemini_client = msm_ion_client_create(-1, "camera/gemini");
-#endif
-	GMN_DBG("%s:%d] success\n", __func__, __LINE__);
-
-	return rc;
-
-fail3:
-	if (pgmn_dev->hw_version != GEMINI_7X) {
-		regulator_disable(pgmn_dev->gemini_fs);
-		regulator_put(pgmn_dev->gemini_fs);
-		pgmn_dev->gemini_fs = NULL;
-	}
-gemini_fs_failed:
-	if (pgmn_dev->hw_version == GEMINI_8960)
-		msm_cam_clk_enable(&pgmn_dev->pdev->dev, gemini_imem_clk_info,
-		 &pgmn_dev->gemini_clk[2], ARRAY_SIZE(gemini_imem_clk_info), 0);
-	if (pgmn_dev->hw_version != GEMINI_7X)
-		msm_cam_clk_enable(&pgmn_dev->pdev->dev, gemini_8x_clk_info,
-		pgmn_dev->gemini_clk, ARRAY_SIZE(gemini_8x_clk_info), 0);
-	else
-		msm_cam_clk_enable(&pgmn_dev->pdev->dev, gemini_7x_clk_info,
-		pgmn_dev->gemini_clk, ARRAY_SIZE(gemini_7x_clk_info), 0);
-fail2:
-	iounmap(gemini_base);
-fail1:
-	release_mem_region(gemini_mem->start, resource_size(gemini_mem));
-	GMN_DBG("%s:%d] fail\n", __func__, __LINE__);
-	return rc;
-}
-
-int msm_gemini_platform_release(struct resource *mem, void *base, int irq,
-	void *context)
-{
-	int result = 0;
-	struct msm_gemini_device *pgmn_dev =
-		(struct msm_gemini_device *) context;
-
-	free_irq(irq, context);
-
-	if (pgmn_dev->hw_version != GEMINI_7X) {
-		regulator_disable(pgmn_dev->gemini_fs);
-		regulator_put(pgmn_dev->gemini_fs);
-		pgmn_dev->gemini_fs = NULL;
-	}
-
-	if (pgmn_dev->hw_version == GEMINI_8960)
-		msm_cam_clk_enable(&pgmn_dev->pdev->dev, gemini_imem_clk_info,
-		 &pgmn_dev->gemini_clk[2], ARRAY_SIZE(gemini_imem_clk_info), 0);
-	if (pgmn_dev->hw_version != GEMINI_7X)
-		msm_cam_clk_enable(&pgmn_dev->pdev->dev, gemini_8x_clk_info,
-		pgmn_dev->gemini_clk, ARRAY_SIZE(gemini_8x_clk_info), 0);
-	else
-		msm_cam_clk_enable(&pgmn_dev->pdev->dev, gemini_7x_clk_info,
-		pgmn_dev->gemini_clk, ARRAY_SIZE(gemini_7x_clk_info), 0);
-
-	iounmap(base);
-	release_mem_region(mem->start, resource_size(mem));
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-	ion_client_destroy(gemini_client);
-#endif
-	GMN_DBG("%s:%d] success\n", __func__, __LINE__);
-	return result;
-}
-
diff --git a/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_platform.h b/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_platform.h
deleted file mode 100644
index f6291dc..0000000
--- a/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_platform.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Copyright (c) 2010-2012, The Linux Foundation. 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.
- */
-
-#ifndef MSM_GEMINI_PLATFORM_H
-#define MSM_GEMINI_PLATFORM_H
-
-#include <linux/interrupt.h>
-#include <linux/platform_device.h>
-#include <linux/msm_ion.h>
-#include <linux/iommu.h>
-void msm_gemini_platform_p2v(struct file  *file,
-				struct ion_handle **ionhandle);
-uint32_t msm_gemini_platform_v2p(int fd, uint32_t len, struct file **file,
-				struct ion_handle **ionhandle);
-
-int msm_gemini_platform_clk_enable(void);
-int msm_gemini_platform_clk_disable(void);
-
-int msm_gemini_platform_init(struct platform_device *pdev,
-	struct resource **mem,
-	void **base,
-	int *irq,
-	irqreturn_t (*handler) (int, void *),
-	void *context);
-int msm_gemini_platform_release(struct resource *mem, void *base, int irq,
-	void *context);
-
-#endif /* MSM_GEMINI_PLATFORM_H */
diff --git a/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_sync.c b/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_sync.c
deleted file mode 100644
index 0796b8d..0000000
--- a/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_sync.c
+++ /dev/null
@@ -1,1084 +0,0 @@
-/* Copyright (c) 2010-2013, The Linux Foundation. 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.
- */
-
-#include <linux/module.h>
-#include <linux/sched.h>
-#include <linux/list.h>
-#include <linux/uaccess.h>
-#include <linux/slab.h>
-#include <media/msm_gemini.h>
-#include <mach/msm_bus.h>
-#include <mach/msm_bus_board.h>
-#include "msm_gemini_sync.h"
-#include "msm_gemini_core.h"
-#include "msm_gemini_platform.h"
-#include "msm_gemini_common.h"
-
-#define UINT32_MAX (0xFFFFFFFFU)
-
-static int release_buf;
-
-/* size is based on 4k page size */
-static const int g_max_out_size = 0x7ff000;
-
-/*************** queue helper ****************/
-inline void msm_gemini_q_init(char const *name, struct msm_gemini_q *q_p)
-{
-	GMN_DBG("%s:%d] %s\n", __func__, __LINE__, name);
-	q_p->name = name;
-	spin_lock_init(&q_p->lck);
-	INIT_LIST_HEAD(&q_p->q);
-	init_waitqueue_head(&q_p->wait);
-	q_p->unblck = 0;
-}
-
-inline void *msm_gemini_q_out(struct msm_gemini_q *q_p)
-{
-	unsigned long flags;
-	struct msm_gemini_q_entry *q_entry_p = NULL;
-	void *data = NULL;
-
-	GMN_DBG("%s:%d] %s\n", __func__, __LINE__, q_p->name);
-	spin_lock_irqsave(&q_p->lck, flags);
-	if (!list_empty(&q_p->q)) {
-		q_entry_p = list_first_entry(&q_p->q, struct msm_gemini_q_entry,
-			list);
-		list_del_init(&q_entry_p->list);
-	}
-	spin_unlock_irqrestore(&q_p->lck, flags);
-
-	if (q_entry_p) {
-		data = q_entry_p->data;
-		kfree(q_entry_p);
-	} else {
-		GMN_DBG("%s:%d] %s no entry\n", __func__, __LINE__,
-			q_p->name);
-	}
-
-	return data;
-}
-
-inline int msm_gemini_q_in(struct msm_gemini_q *q_p, void *data)
-{
-	unsigned long flags;
-
-	struct msm_gemini_q_entry *q_entry_p;
-
-	GMN_DBG("%s:%d] %s\n", __func__, __LINE__, q_p->name);
-
-	q_entry_p = kmalloc(sizeof(struct msm_gemini_q_entry), GFP_ATOMIC);
-	if (!q_entry_p) {
-		GMN_PR_ERR("%s: no mem\n", __func__);
-		return -1;
-	}
-	q_entry_p->data = data;
-
-	spin_lock_irqsave(&q_p->lck, flags);
-	list_add_tail(&q_entry_p->list, &q_p->q);
-	spin_unlock_irqrestore(&q_p->lck, flags);
-
-	return 0;
-}
-
-inline int msm_gemini_q_in_buf(struct msm_gemini_q *q_p,
-	struct msm_gemini_core_buf *buf)
-{
-	struct msm_gemini_core_buf *buf_p;
-
-	GMN_DBG("%s:%d]\n", __func__, __LINE__);
-	buf_p = kmalloc(sizeof(struct msm_gemini_core_buf), GFP_ATOMIC);
-	if (!buf_p) {
-		GMN_PR_ERR("%s: no mem\n", __func__);
-		return -1;
-	}
-
-	memcpy(buf_p, buf, sizeof(struct msm_gemini_core_buf));
-
-	msm_gemini_q_in(q_p, buf_p);
-	return 0;
-}
-
-inline int msm_gemini_q_wait(struct msm_gemini_q *q_p)
-{
-	int tm = MAX_SCHEDULE_TIMEOUT; /* 500ms */
-	int rc;
-
-	GMN_DBG("%s:%d] %s wait\n", __func__, __LINE__, q_p->name);
-	rc = wait_event_interruptible_timeout(q_p->wait,
-		(!list_empty_careful(&q_p->q) || q_p->unblck),
-		msecs_to_jiffies(tm));
-	GMN_DBG("%s:%d] %s wait done\n", __func__, __LINE__, q_p->name);
-	if (list_empty_careful(&q_p->q)) {
-		if (rc == 0) {
-			rc = -ETIMEDOUT;
-			GMN_PR_ERR("%s:%d] %s timeout\n", __func__, __LINE__,
-				q_p->name);
-		} else if (q_p->unblck) {
-			GMN_DBG("%s:%d] %s unblock is true\n", __func__,
-				__LINE__, q_p->name);
-			q_p->unblck = 0;
-			rc = -ECANCELED;
-		} else if (rc < 0) {
-			GMN_PR_ERR("%s:%d] %s rc %d\n", __func__, __LINE__,
-				q_p->name, rc);
-		}
-	}
-	return rc;
-}
-
-inline int msm_gemini_q_wakeup(struct msm_gemini_q *q_p)
-{
-	GMN_DBG("%s:%d] %s\n", __func__, __LINE__, q_p->name);
-	wake_up(&q_p->wait);
-	return 0;
-}
-
-inline int msm_gemini_q_unblock(struct msm_gemini_q *q_p)
-{
-	GMN_DBG("%s:%d] %s\n", __func__, __LINE__, q_p->name);
-	q_p->unblck = 1;
-	wake_up(&q_p->wait);
-	return 0;
-}
-
-inline void msm_gemini_outbuf_q_cleanup(struct msm_gemini_q *q_p)
-{
-	struct msm_gemini_core_buf *buf_p;
-	GMN_DBG("%s:%d] %s\n", __func__, __LINE__, q_p->name);
-	do {
-		buf_p = msm_gemini_q_out(q_p);
-		if (buf_p) {
-			msm_gemini_platform_p2v(buf_p->file,
-				&buf_p->handle);
-			GMN_DBG("%s:%d] %s\n", __func__, __LINE__, q_p->name);
-			kfree(buf_p);
-		}
-	} while (buf_p);
-	q_p->unblck = 0;
-}
-
-inline void msm_gemini_q_cleanup(struct msm_gemini_q *q_p)
-{
-	void *data;
-	GMN_DBG("%s:%d] %s\n", __func__, __LINE__, q_p->name);
-	do {
-		data = msm_gemini_q_out(q_p);
-		if (data) {
-			GMN_DBG("%s:%d] %s\n", __func__, __LINE__, q_p->name);
-			kfree(data);
-		}
-	} while (data);
-	q_p->unblck = 0;
-}
-
-/*************** event queue ****************/
-
-int msm_gemini_framedone_irq(struct msm_gemini_device *pgmn_dev,
-	struct msm_gemini_core_buf *buf_in)
-{
-	int rc = 0;
-
-	pr_debug("%s:%d] buf_in %p", __func__, __LINE__, buf_in);
-
-	if (buf_in) {
-		buf_in->vbuf.framedone_len = buf_in->framedone_len;
-		buf_in->vbuf.type = MSM_GEMINI_EVT_FRAMEDONE;
-		GMN_DBG("%s:%d] 0x%08x %d framedone_len %d\n",
-			__func__, __LINE__,
-			(int) buf_in->y_buffer_addr, buf_in->y_len,
-			buf_in->vbuf.framedone_len);
-		rc = msm_gemini_q_in_buf(&pgmn_dev->evt_q, buf_in);
-	} else {
-		GMN_PR_ERR("%s:%d] no output return buffer\n",
-			__func__, __LINE__);
-		rc = -1;
-	}
-
-	if (buf_in)
-		rc = msm_gemini_q_wakeup(&pgmn_dev->evt_q);
-
-	return rc;
-}
-
-int msm_gemini_evt_get(struct msm_gemini_device *pgmn_dev,
-	void __user *to)
-{
-	struct msm_gemini_core_buf *buf_p;
-	struct msm_gemini_ctrl_cmd ctrl_cmd;
-
-	GMN_DBG("%s:%d] Enter\n", __func__, __LINE__);
-
-	msm_gemini_q_wait(&pgmn_dev->evt_q);
-	buf_p = msm_gemini_q_out(&pgmn_dev->evt_q);
-
-	if (!buf_p) {
-		GMN_DBG("%s:%d] no buffer\n", __func__, __LINE__);
-		return -EAGAIN;
-	}
-
-	memset(&ctrl_cmd, 0, sizeof(struct msm_gemini_ctrl_cmd));
-	ctrl_cmd.type = buf_p->vbuf.type;
-	kfree(buf_p);
-
-	GMN_DBG("%s:%d] 0x%08x %d\n", __func__, __LINE__,
-		(int) ctrl_cmd.value, ctrl_cmd.len);
-
-	if (copy_to_user(to, &ctrl_cmd, sizeof(ctrl_cmd))) {
-		GMN_PR_ERR("%s:%d]\n", __func__, __LINE__);
-		return -EFAULT;
-	}
-
-	return 0;
-}
-
-int msm_gemini_evt_get_unblock(struct msm_gemini_device *pgmn_dev)
-{
-	GMN_DBG("%s:%d] Enter\n", __func__, __LINE__);
-	msm_gemini_q_unblock(&pgmn_dev->evt_q);
-	return 0;
-}
-
-void msm_gemini_reset_ack_irq(struct msm_gemini_device *pgmn_dev)
-{
-	GMN_DBG("%s:%d]\n", __func__, __LINE__);
-}
-
-void msm_gemini_err_irq(struct msm_gemini_device *pgmn_dev,
-	int event)
-{
-	int rc = 0;
-	struct msm_gemini_core_buf buf;
-
-	GMN_PR_ERR("%s:%d] error: %d\n", __func__, __LINE__, event);
-
-	buf.vbuf.type = MSM_GEMINI_EVT_ERR;
-	rc = msm_gemini_q_in_buf(&pgmn_dev->evt_q, &buf);
-	if (!rc)
-		rc = msm_gemini_q_wakeup(&pgmn_dev->evt_q);
-
-	if (!rc)
-		GMN_PR_ERR("%s:%d] err err\n", __func__, __LINE__);
-
-	return;
-}
-
-/*************** output queue ****************/
-
-int msm_gemini_get_out_buffer(struct msm_gemini_device *pgmn_dev,
-	struct msm_gemini_hw_buf *p_outbuf)
-{
-	int buf_size = 0;
-	int bytes_remaining = 0;
-	if (pgmn_dev->out_offset >= pgmn_dev->out_buf.y_len) {
-		GMN_PR_ERR("%s:%d] no more buffers", __func__, __LINE__);
-		return -EINVAL;
-	}
-	bytes_remaining = pgmn_dev->out_buf.y_len - pgmn_dev->out_offset;
-	buf_size = min(bytes_remaining, pgmn_dev->max_out_size);
-
-	pgmn_dev->out_frag_cnt++;
-	pr_debug("%s:%d] buf_size[%d] %d", __func__, __LINE__,
-		pgmn_dev->out_frag_cnt, buf_size);
-	p_outbuf->y_len = buf_size;
-	p_outbuf->y_buffer_addr = pgmn_dev->out_buf.y_buffer_addr +
-		pgmn_dev->out_offset;
-	pgmn_dev->out_offset += buf_size;
-	return 0;
-}
-
-int msm_gemini_outmode_single_we_pingpong_irq(
-	struct msm_gemini_device *pgmn_dev,
-	struct msm_gemini_core_buf *buf_in)
-{
-	int rc = 0;
-	struct msm_gemini_core_buf out_buf;
-	int frame_done = buf_in &&
-		buf_in->vbuf.type == MSM_GEMINI_EVT_FRAMEDONE;
-	pr_debug("%s:%d] framedone %d", __func__, __LINE__, frame_done);
-	if (!pgmn_dev->out_buf_set) {
-		pr_err("%s:%d] output buffer not set",
-			__func__, __LINE__);
-		return -EFAULT;
-	}
-	if (frame_done) {
-		/* send the buffer back */
-		pgmn_dev->out_buf.vbuf.framedone_len = buf_in->framedone_len;
-		pgmn_dev->out_buf.vbuf.type = MSM_GEMINI_EVT_FRAMEDONE;
-		rc = msm_gemini_q_in_buf(&pgmn_dev->output_rtn_q,
-			&pgmn_dev->out_buf);
-		if (rc) {
-			pr_err("%s:%d] cannot queue the output buffer",
-				 __func__, __LINE__);
-			return -EFAULT;
-		}
-		rc =  msm_gemini_q_wakeup(&pgmn_dev->output_rtn_q);
-		/* reset the output buffer since the ownership is
-			transferred to the rtn queue */
-		if (!rc)
-			pgmn_dev->out_buf_set = 0;
-	} else {
-		/* configure ping/pong */
-		rc = msm_gemini_get_out_buffer(pgmn_dev, &out_buf);
-		if (rc)
-			msm_gemini_core_we_buf_reset(&out_buf);
-		else
-			msm_gemini_core_we_buf_update(&out_buf);
-	}
-	return rc;
-}
-
-int msm_gemini_we_pingpong_irq(struct msm_gemini_device *pgmn_dev,
-	struct msm_gemini_core_buf *buf_in)
-{
-	int rc = 0;
-	struct msm_gemini_core_buf *buf_out;
-
-	pr_debug("%s:%d] Enter mode %d", __func__, __LINE__,
-		pgmn_dev->out_mode);
-
-	if (pgmn_dev->out_mode == MSM_GMN_OUTMODE_SINGLE)
-		return msm_gemini_outmode_single_we_pingpong_irq(pgmn_dev,
-			buf_in);
-
-	if (buf_in) {
-		pr_debug("%s:%d] 0x%08x %d\n", __func__, __LINE__,
-			(int) buf_in->y_buffer_addr, buf_in->y_len);
-		rc = msm_gemini_q_in_buf(&pgmn_dev->output_rtn_q, buf_in);
-	} else {
-		pr_debug("%s:%d] no output return buffer\n", __func__,
-			__LINE__);
-		rc = -1;
-		return rc;
-	}
-
-	buf_out = msm_gemini_q_out(&pgmn_dev->output_buf_q);
-
-	if (buf_out) {
-		rc = msm_gemini_core_we_buf_update(buf_out);
-		kfree(buf_out);
-	} else {
-		msm_gemini_core_we_buf_reset(buf_in);
-		pr_debug("%s:%d] no output buffer\n", __func__, __LINE__);
-		rc = -2;
-	}
-
-	if (buf_in)
-		rc = msm_gemini_q_wakeup(&pgmn_dev->output_rtn_q);
-
-	return rc;
-}
-
-int msm_gemini_output_get(struct msm_gemini_device *pgmn_dev, void __user *to)
-{
-	struct msm_gemini_core_buf *buf_p;
-	struct msm_gemini_buf buf_cmd;
-
-	GMN_DBG("%s:%d] Enter\n", __func__, __LINE__);
-
-	msm_gemini_q_wait(&pgmn_dev->output_rtn_q);
-	buf_p = msm_gemini_q_out(&pgmn_dev->output_rtn_q);
-
-	if (!buf_p) {
-		GMN_DBG("%s:%d] no output buffer return\n",
-			__func__, __LINE__);
-		return -EAGAIN;
-	}
-
-	buf_cmd = buf_p->vbuf;
-	msm_gemini_platform_p2v(buf_p->file, &buf_p->handle);
-	kfree(buf_p);
-
-	GMN_DBG("%s:%d] 0x%08x %d\n", __func__, __LINE__,
-		(int) buf_cmd.vaddr, buf_cmd.y_len);
-
-	if (copy_to_user(to, &buf_cmd, sizeof(buf_cmd))) {
-		GMN_PR_ERR("%s:%d]", __func__, __LINE__);
-		return -EFAULT;
-	}
-
-	return 0;
-}
-
-int msm_gemini_output_get_unblock(struct msm_gemini_device *pgmn_dev)
-{
-	GMN_DBG("%s:%d] Enter\n", __func__, __LINE__);
-	msm_gemini_q_unblock(&pgmn_dev->output_rtn_q);
-	return 0;
-}
-
-int msm_gemini_set_output_buf(struct msm_gemini_device *pgmn_dev,
-	void __user *arg)
-{
-	struct msm_gemini_buf buf_cmd;
-
-	if (pgmn_dev->out_buf_set) {
-		pr_err("%s:%d] outbuffer buffer already provided",
-			__func__, __LINE__);
-		return -EINVAL;
-	}
-
-	if (copy_from_user(&buf_cmd, arg, sizeof(struct msm_gemini_buf))) {
-		pr_err("%s:%d] failed\n", __func__, __LINE__);
-		return -EFAULT;
-	}
-
-	GMN_DBG("%s:%d] output addr 0x%08x len %d", __func__, __LINE__,
-		(int) buf_cmd.vaddr,
-		buf_cmd.y_len);
-
-	pgmn_dev->out_buf.y_buffer_addr = msm_gemini_platform_v2p(
-		buf_cmd.fd,
-		buf_cmd.y_len,
-		&pgmn_dev->out_buf.file,
-		&pgmn_dev->out_buf.handle);
-	if (!pgmn_dev->out_buf.y_buffer_addr) {
-		pr_err("%s:%d] cannot map the output address",
-			__func__, __LINE__);
-		return -EFAULT;
-	}
-	pgmn_dev->out_buf.y_len = buf_cmd.y_len;
-	pgmn_dev->out_buf.vbuf = buf_cmd;
-	pgmn_dev->out_buf_set = 1;
-
-	return 0;
-}
-
-int msm_gemini_output_buf_enqueue(struct msm_gemini_device *pgmn_dev,
-	void __user *arg)
-{
-	struct msm_gemini_buf buf_cmd;
-	struct msm_gemini_core_buf *buf_p;
-
-	GMN_DBG("%s:%d] Enter\n", __func__, __LINE__);
-	if (copy_from_user(&buf_cmd, arg, sizeof(struct msm_gemini_buf))) {
-		GMN_PR_ERR("%s:%d] failed\n", __func__, __LINE__);
-		return -EFAULT;
-	}
-
-	buf_p = kmalloc(sizeof(struct msm_gemini_core_buf), GFP_ATOMIC);
-	if (!buf_p) {
-		GMN_PR_ERR("%s:%d] no mem\n", __func__, __LINE__);
-		return -1;
-	}
-
-	GMN_DBG("%s:%d] 0x%08x %d\n", __func__, __LINE__, (int) buf_cmd.vaddr,
-		buf_cmd.y_len);
-
-	buf_p->y_buffer_addr = msm_gemini_platform_v2p(buf_cmd.fd,
-		buf_cmd.y_len, &buf_p->file, &buf_p->handle);
-	if (!buf_p->y_buffer_addr) {
-		GMN_PR_ERR("%s:%d] v2p wrong\n", __func__, __LINE__);
-		kfree(buf_p);
-		return -1;
-	}
-	buf_p->y_len = buf_cmd.y_len;
-	buf_p->vbuf = buf_cmd;
-
-	msm_gemini_q_in(&pgmn_dev->output_buf_q, buf_p);
-	return 0;
-}
-
-/*************** input queue ****************/
-
-int msm_gemini_fe_pingpong_irq(struct msm_gemini_device *pgmn_dev,
-	struct msm_gemini_core_buf *buf_in)
-{
-	struct msm_gemini_core_buf *buf_out;
-	int rc = 0;
-
-	GMN_DBG("%s:%d] Enter\n", __func__, __LINE__);
-	if (buf_in) {
-		GMN_DBG("%s:%d] 0x%08x %d\n", __func__, __LINE__,
-			(int) buf_in->y_buffer_addr, buf_in->y_len);
-		rc = msm_gemini_q_in_buf(&pgmn_dev->input_rtn_q, buf_in);
-	} else {
-		GMN_DBG("%s:%d] no input return buffer\n", __func__,
-			__LINE__);
-		rc = -1;
-	}
-
-	buf_out = msm_gemini_q_out(&pgmn_dev->input_buf_q);
-
-	if (buf_out) {
-		rc = msm_gemini_core_fe_buf_update(buf_out);
-		kfree(buf_out);
-		msm_gemini_core_fe_start();
-	} else {
-		GMN_DBG("%s:%d] no input buffer\n", __func__, __LINE__);
-		rc = -2;
-	}
-
-	if (buf_in)
-		rc = msm_gemini_q_wakeup(&pgmn_dev->input_rtn_q);
-
-	return rc;
-}
-
-int msm_gemini_input_get(struct msm_gemini_device *pgmn_dev, void __user * to)
-{
-	struct msm_gemini_core_buf *buf_p;
-	struct msm_gemini_buf buf_cmd;
-
-	GMN_DBG("%s:%d] Enter\n", __func__, __LINE__);
-	msm_gemini_q_wait(&pgmn_dev->input_rtn_q);
-	buf_p = msm_gemini_q_out(&pgmn_dev->input_rtn_q);
-
-	if (!buf_p) {
-		GMN_DBG("%s:%d] no input buffer return\n",
-			__func__, __LINE__);
-		return -EAGAIN;
-	}
-
-	buf_cmd = buf_p->vbuf;
-	if (pgmn_dev->op_mode == MSM_GEMINI_MODE_OFFLINE_ENCODE ||
-		pgmn_dev->op_mode == MSM_GEMINI_MODE_OFFLINE_ROTATION) {
-		msm_gemini_platform_p2v(buf_p->file, &buf_p->handle);
-	}
-	kfree(buf_p);
-
-	GMN_DBG("%s:%d] 0x%08x %d\n", __func__, __LINE__,
-		(int) buf_cmd.vaddr, buf_cmd.y_len);
-
-	if (copy_to_user(to, &buf_cmd, sizeof(buf_cmd))) {
-		GMN_PR_ERR("%s:%d]\n", __func__, __LINE__);
-		return -EFAULT;
-	}
-
-	return 0;
-}
-
-int msm_gemini_input_get_unblock(struct msm_gemini_device *pgmn_dev)
-{
-	GMN_DBG("%s:%d] Enter\n", __func__, __LINE__);
-	msm_gemini_q_unblock(&pgmn_dev->input_rtn_q);
-	return 0;
-}
-
-int msm_gemini_input_buf_enqueue(struct msm_gemini_device *pgmn_dev,
-	void __user *arg)
-{
-	struct msm_gemini_core_buf *buf_p;
-	struct msm_gemini_buf buf_cmd;
-	int rc = 0;
-	struct msm_bus_scale_pdata *p_bus_scale_data = NULL;
-
-	if (copy_from_user(&buf_cmd, arg, sizeof(struct msm_gemini_buf))) {
-		GMN_PR_ERR("%s:%d] failed\n", __func__, __LINE__);
-		return -EFAULT;
-	}
-
-	buf_p = kmalloc(sizeof(struct msm_gemini_core_buf), GFP_ATOMIC);
-	if (!buf_p) {
-		GMN_PR_ERR("%s:%d] no mem\n", __func__, __LINE__);
-		return -1;
-	}
-
-	GMN_DBG("%s:%d] 0x%08x %d\n", __func__, __LINE__,
-		(int) buf_cmd.vaddr, buf_cmd.y_len);
-
-	if (pgmn_dev->op_mode == MSM_GEMINI_MODE_REALTIME_ENCODE) {
-		rc = msm_iommu_map_contig_buffer(
-			(unsigned long)buf_cmd.y_off, CAMERA_DOMAIN, GEN_POOL,
-			((buf_cmd.y_len + buf_cmd.cbcr_len + 4095) & (~4095)),
-			SZ_4K, IOMMU_WRITE | IOMMU_READ,
-			(unsigned long *)&buf_p->y_buffer_addr);
-		if (rc < 0) {
-			pr_err("%s iommu mapping failed with error %d\n",
-				 __func__, rc);
-			kfree(buf_p);
-			return rc;
-		}
-	} else {
-		buf_p->y_buffer_addr    = msm_gemini_platform_v2p(buf_cmd.fd,
-			buf_cmd.y_len + buf_cmd.cbcr_len, &buf_p->file,
-			&buf_p->handle)	+ buf_cmd.offset + buf_cmd.y_off;
-	}
-	buf_p->y_len          = buf_cmd.y_len;
-
-	buf_p->cbcr_buffer_addr = buf_p->y_buffer_addr + buf_cmd.y_len +
-					buf_cmd.cbcr_off;
-	buf_p->cbcr_len       = buf_cmd.cbcr_len;
-	buf_p->num_of_mcu_rows = buf_cmd.num_of_mcu_rows;
-	GMN_DBG("%s: y_addr=%x,y_len=%x,cbcr_addr=%x,cbcr_len=%x\n", __func__,
-		buf_p->y_buffer_addr, buf_p->y_len, buf_p->cbcr_buffer_addr,
-		buf_p->cbcr_len);
-
-	if (!buf_p->y_buffer_addr || !buf_p->cbcr_buffer_addr) {
-		GMN_PR_ERR("%s:%d] v2p wrong\n", __func__, __LINE__);
-		kfree(buf_p);
-		return -1;
-	}
-	buf_p->vbuf           = buf_cmd;
-	buf_p->vbuf.type      = MSM_GEMINI_EVT_RESET;
-
-	/* Set bus vectors */
-	p_bus_scale_data = (struct msm_bus_scale_pdata *)
-		pgmn_dev->pdev->dev.platform_data;
-	if (pgmn_dev->bus_perf_client &&
-		(MSM_GMN_OUTMODE_SINGLE == pgmn_dev->out_mode)) {
-		int rc;
-		struct msm_bus_paths *path = &(p_bus_scale_data->usecase[1]);
-		GMN_DBG("%s:%d] Update bus bandwidth", __func__, __LINE__);
-		if (pgmn_dev->op_mode & MSM_GEMINI_MODE_OFFLINE_ENCODE) {
-			path->vectors[0].ab = (buf_p->y_len + buf_p->cbcr_len) *
-				15 * 2;
-			path->vectors[0].ib = path->vectors[0].ab;
-			path->vectors[1].ab = 0;
-			path->vectors[1].ib = 0;
-		}
-		rc = msm_bus_scale_client_update_request(
-			pgmn_dev->bus_perf_client, 1);
-		if (rc < 0) {
-			GMN_PR_ERR("%s:%d] update_request fails %d",
-				__func__, __LINE__, rc);
-		}
-	}
-
-	msm_gemini_q_in(&pgmn_dev->input_buf_q, buf_p);
-
-	return 0;
-}
-
-int msm_gemini_irq(int event, void *context, void *data)
-{
-	struct msm_gemini_device *pgmn_dev =
-		(struct msm_gemini_device *) context;
-
-	switch (event) {
-	case MSM_GEMINI_HW_MASK_COMP_FRAMEDONE:
-		msm_gemini_framedone_irq(pgmn_dev, data);
-		msm_gemini_we_pingpong_irq(pgmn_dev, data);
-		break;
-
-	case MSM_GEMINI_HW_MASK_COMP_FE:
-		msm_gemini_fe_pingpong_irq(pgmn_dev, data);
-		break;
-
-	case MSM_GEMINI_HW_MASK_COMP_WE:
-		msm_gemini_we_pingpong_irq(pgmn_dev, data);
-		break;
-
-	case MSM_GEMINI_HW_MASK_COMP_RESET_ACK:
-		msm_gemini_reset_ack_irq(pgmn_dev);
-		break;
-
-	case MSM_GEMINI_HW_MASK_COMP_ERR:
-	default:
-		msm_gemini_err_irq(pgmn_dev, event);
-		break;
-	}
-
-	return 0;
-}
-
-int __msm_gemini_open(struct msm_gemini_device *pgmn_dev)
-{
-	int rc;
-	struct msm_bus_scale_pdata *p_bus_scale_data =
-		(struct msm_bus_scale_pdata *)pgmn_dev->pdev->dev.
-			platform_data;
-
-	mutex_lock(&pgmn_dev->lock);
-	if (pgmn_dev->open_count) {
-		/* only open once */
-		GMN_PR_ERR("%s:%d] busy\n", __func__, __LINE__);
-		mutex_unlock(&pgmn_dev->lock);
-		return -EBUSY;
-	}
-	pgmn_dev->open_count++;
-	mutex_unlock(&pgmn_dev->lock);
-
-	msm_gemini_core_irq_install(msm_gemini_irq);
-	rc = msm_gemini_platform_init(pgmn_dev->pdev,
-		&pgmn_dev->mem, &pgmn_dev->base,
-		&pgmn_dev->irq, msm_gemini_core_irq, pgmn_dev);
-	if (rc) {
-		GMN_PR_ERR("%s:%d] platform_init fail %d\n", __func__,
-			__LINE__, rc);
-		return rc;
-	}
-
-	GMN_DBG("%s:%d] platform resources - mem %p, base %p, irq %d\n",
-		__func__, __LINE__,
-		pgmn_dev->mem, pgmn_dev->base, pgmn_dev->irq);
-
-	msm_gemini_q_cleanup(&pgmn_dev->evt_q);
-	msm_gemini_q_cleanup(&pgmn_dev->output_rtn_q);
-	msm_gemini_outbuf_q_cleanup(&pgmn_dev->output_buf_q);
-	msm_gemini_q_cleanup(&pgmn_dev->input_rtn_q);
-	msm_gemini_q_cleanup(&pgmn_dev->input_buf_q);
-	msm_gemini_core_init();
-	pgmn_dev->out_mode = MSM_GMN_OUTMODE_FRAGMENTED;
-	pgmn_dev->out_buf_set = 0;
-	pgmn_dev->out_offset = 0;
-	pgmn_dev->max_out_size = g_max_out_size;
-	pgmn_dev->out_frag_cnt = 0;
-	pgmn_dev->bus_perf_client = 0;
-
-	if (p_bus_scale_data) {
-		GMN_DBG("%s:%d] register bus client", __func__, __LINE__);
-		pgmn_dev->bus_perf_client =
-			msm_bus_scale_register_client(p_bus_scale_data);
-		if (!pgmn_dev->bus_perf_client) {
-			GMN_PR_ERR("%s:%d] bus client register failed",
-				__func__, __LINE__);
-			return -EINVAL;
-		}
-	}
-	GMN_DBG("%s:%d] success\n", __func__, __LINE__);
-	return rc;
-}
-
-int __msm_gemini_release(struct msm_gemini_device *pgmn_dev)
-{
-	GMN_DBG("%s:%d] Enter\n", __func__, __LINE__);
-	mutex_lock(&pgmn_dev->lock);
-	if (!pgmn_dev->open_count) {
-		GMN_PR_ERR(KERN_ERR "%s: not opened\n", __func__);
-		mutex_unlock(&pgmn_dev->lock);
-		return -EINVAL;
-	}
-	pgmn_dev->open_count--;
-	mutex_unlock(&pgmn_dev->lock);
-
-	if (pgmn_dev->out_mode == MSM_GMN_OUTMODE_FRAGMENTED) {
-		msm_gemini_core_release(release_buf);
-	} else if (pgmn_dev->out_buf_set) {
-		msm_gemini_platform_p2v(pgmn_dev->out_buf.file,
-			&pgmn_dev->out_buf.handle);
-	}
-	msm_gemini_q_cleanup(&pgmn_dev->evt_q);
-	msm_gemini_q_cleanup(&pgmn_dev->output_rtn_q);
-	msm_gemini_outbuf_q_cleanup(&pgmn_dev->output_buf_q);
-	msm_gemini_q_cleanup(&pgmn_dev->input_rtn_q);
-	msm_gemini_outbuf_q_cleanup(&pgmn_dev->input_buf_q);
-
-	if (pgmn_dev->bus_perf_client) {
-		msm_bus_scale_unregister_client(pgmn_dev->bus_perf_client);
-		pgmn_dev->bus_perf_client = 0;
-	}
-
-	if (pgmn_dev->open_count)
-		GMN_PR_ERR(KERN_ERR "%s: multiple opens\n", __func__);
-
-	msm_gemini_platform_release(pgmn_dev->mem, pgmn_dev->base,
-		pgmn_dev->irq, pgmn_dev);
-
-	return 0;
-}
-
-int msm_gemini_ioctl_hw_cmd(struct msm_gemini_device *pgmn_dev,
-	void * __user arg)
-{
-	struct msm_gemini_hw_cmd hw_cmd;
-	int is_copy_to_user;
-
-	if (copy_from_user(&hw_cmd, arg, sizeof(struct msm_gemini_hw_cmd))) {
-		GMN_PR_ERR("%s:%d] failed\n", __func__, __LINE__);
-		return -EFAULT;
-	}
-
-	is_copy_to_user = msm_gemini_hw_exec_cmds(&hw_cmd, 1);
-	GMN_DBG("%s:%d] type %d, n %d, offset %d, mask %x, data %x, pdata %x\n",
-		__func__, __LINE__, hw_cmd.type, hw_cmd.n, hw_cmd.offset,
-		hw_cmd.mask, hw_cmd.data, (int) hw_cmd.pdata);
-
-	if (is_copy_to_user >= 0) {
-		if (copy_to_user(arg, &hw_cmd, sizeof(hw_cmd))) {
-			GMN_PR_ERR("%s:%d] failed\n", __func__, __LINE__);
-			return -EFAULT;
-		}
-	}
-
-	return 0;
-}
-
-int msm_gemini_ioctl_hw_cmds(struct msm_gemini_device *pgmn_dev,
-	void * __user arg)
-{
-	int is_copy_to_user;
-	uint32_t len;
-	uint32_t m;
-	struct msm_gemini_hw_cmds *hw_cmds_p;
-	struct msm_gemini_hw_cmd *hw_cmd_p;
-
-	if (copy_from_user(&m, arg, sizeof(m))) {
-		GMN_PR_ERR("%s:%d] failed\n", __func__, __LINE__);
-		return -EFAULT;
-	}
-
-	if ((m == 0) || (m > ((UINT32_MAX - sizeof(struct msm_gemini_hw_cmds)) /
-		sizeof(struct msm_gemini_hw_cmd)))) {
-		GMN_PR_ERR("%s:%d] m_cmds out of range\n", __func__, __LINE__);
-		return -EFAULT;
-	}
-
-	len = sizeof(struct msm_gemini_hw_cmds) +
-		sizeof(struct msm_gemini_hw_cmd) * (m - 1);
-	hw_cmds_p = kmalloc(len, GFP_KERNEL);
-	if (!hw_cmds_p) {
-		GMN_PR_ERR("%s:%d] no mem %d\n", __func__, __LINE__, len);
-		return -EFAULT;
-	}
-
-	if (copy_from_user(hw_cmds_p, arg, len)) {
-		GMN_PR_ERR("%s:%d] failed\n", __func__, __LINE__);
-		kfree(hw_cmds_p);
-		return -EFAULT;
-	}
-
-	hw_cmd_p = (struct msm_gemini_hw_cmd *) &(hw_cmds_p->hw_cmd);
-
-	is_copy_to_user = msm_gemini_hw_exec_cmds(hw_cmd_p, m);
-
-	if (is_copy_to_user >= 0) {
-		if (copy_to_user(arg, hw_cmds_p, len)) {
-			GMN_PR_ERR("%s:%d] failed\n", __func__, __LINE__);
-			kfree(hw_cmds_p);
-			return -EFAULT;
-		}
-	}
-	kfree(hw_cmds_p);
-	return 0;
-}
-
-int msm_gemini_start(struct msm_gemini_device *pgmn_dev, void * __user arg)
-{
-	struct msm_gemini_core_buf *buf_out;
-	struct msm_gemini_core_buf *buf_out_free[2] = {NULL, NULL};
-	int i, rc;
-
-	GMN_DBG("%s:%d] Enter\n", __func__, __LINE__);
-
-	release_buf = 1;
-	for (i = 0; i < 2; i++) {
-		buf_out = msm_gemini_q_out(&pgmn_dev->input_buf_q);
-
-		if (buf_out) {
-			msm_gemini_core_fe_buf_update(buf_out);
-			kfree(buf_out);
-		} else {
-			GMN_DBG("%s:%d] no input buffer\n", __func__, __LINE__);
-			break;
-		}
-	}
-
-	if (pgmn_dev->out_mode == MSM_GMN_OUTMODE_FRAGMENTED) {
-		for (i = 0; i < 2; i++) {
-			buf_out_free[i] =
-				msm_gemini_q_out(&pgmn_dev->output_buf_q);
-
-			if (buf_out_free[i]) {
-				msm_gemini_core_we_buf_update(buf_out_free[i]);
-			} else if (i == 1) {
-				/* set the pong to same address as ping */
-				buf_out_free[0]->y_len >>= 1;
-				buf_out_free[0]->y_buffer_addr +=
-					buf_out_free[0]->y_len;
-				msm_gemini_core_we_buf_update(buf_out_free[0]);
-				/*
-				 * since ping and pong are same buf
-				 * release only once
-				 */
-				release_buf = 0;
-			} else {
-				GMN_DBG("%s:%d] no output buffer\n",
-					__func__, __LINE__);
-				break;
-			}
-		}
-		for (i = 0; i < 2; i++)
-			kfree(buf_out_free[i]);
-	} else {
-		struct msm_gemini_core_buf out_buf;
-		/*
-		 * Since the same buffer is fragmented, p2v need not be
-		 * called for all the buffers
-		 */
-		release_buf = 0;
-		if (!pgmn_dev->out_buf_set) {
-			GMN_PR_ERR("%s:%d] output buffer not set",
-				__func__, __LINE__);
-			return -EFAULT;
-		}
-		/* configure ping */
-		rc = msm_gemini_get_out_buffer(pgmn_dev, &out_buf);
-		if (rc) {
-			GMN_PR_ERR("%s:%d] no output buffer for ping",
-				__func__, __LINE__);
-			return rc;
-		}
-		msm_gemini_core_we_buf_update(&out_buf);
-		/* configure pong */
-		rc = msm_gemini_get_out_buffer(pgmn_dev, &out_buf);
-		if (rc) {
-			GMN_DBG("%s:%d] no output buffer for pong",
-				__func__, __LINE__);
-			/* fall through to configure same buffer */
-		}
-		msm_gemini_core_we_buf_update(&out_buf);
-		msm_gemini_io_dump(0x150);
-	}
-
-	rc = msm_gemini_ioctl_hw_cmds(pgmn_dev, arg);
-	GMN_DBG("%s:%d]\n", __func__, __LINE__);
-	return rc;
-}
-
-int msm_gemini_ioctl_reset(struct msm_gemini_device *pgmn_dev,
-	void * __user arg)
-{
-	int rc;
-	struct msm_gemini_ctrl_cmd ctrl_cmd;
-
-	GMN_DBG("%s:%d] Enter\n", __func__, __LINE__);
-	if (copy_from_user(&ctrl_cmd, arg, sizeof(ctrl_cmd))) {
-		GMN_PR_ERR("%s:%d] failed\n", __func__, __LINE__);
-		return -EFAULT;
-	}
-
-	pgmn_dev->op_mode = ctrl_cmd.type;
-
-	rc = msm_gemini_core_reset(pgmn_dev->op_mode, pgmn_dev->base,
-		resource_size(pgmn_dev->mem));
-	return rc;
-}
-
-int msm_gemini_ioctl_set_outmode(struct msm_gemini_device *pgmn_dev,
-	void * __user arg)
-{
-	int rc = 0;
-	enum msm_gmn_out_mode mode;
-
-	if (copy_from_user(&mode, arg, sizeof(mode))) {
-		GMN_PR_ERR("%s:%d] failed\n", __func__, __LINE__);
-		return -EFAULT;
-	}
-	GMN_DBG("%s:%d] mode %d", __func__, __LINE__, mode);
-
-	if ((mode == MSM_GMN_OUTMODE_FRAGMENTED)
-		|| (mode == MSM_GMN_OUTMODE_SINGLE))
-		pgmn_dev->out_mode = mode;
-	return rc;
-}
-
-long __msm_gemini_ioctl(struct msm_gemini_device *pgmn_dev,
-	unsigned int cmd, unsigned long arg)
-{
-	int rc = 0;
-	switch (cmd) {
-	case MSM_GMN_IOCTL_GET_HW_VERSION:
-		GMN_DBG("%s:%d] VERSION 1\n", __func__, __LINE__);
-		rc = msm_gemini_ioctl_hw_cmd(pgmn_dev, (void __user *) arg);
-		break;
-
-	case MSM_GMN_IOCTL_RESET:
-		rc = msm_gemini_ioctl_reset(pgmn_dev, (void __user *) arg);
-		break;
-
-	case MSM_GMN_IOCTL_STOP:
-		rc = msm_gemini_ioctl_hw_cmds(pgmn_dev, (void __user *) arg);
-		break;
-
-	case MSM_GMN_IOCTL_START:
-		rc = msm_gemini_start(pgmn_dev, (void __user *) arg);
-		break;
-
-	case MSM_GMN_IOCTL_INPUT_BUF_ENQUEUE:
-		rc = msm_gemini_input_buf_enqueue(pgmn_dev,
-			(void __user *) arg);
-		break;
-
-	case MSM_GMN_IOCTL_INPUT_GET:
-		rc = msm_gemini_input_get(pgmn_dev, (void __user *) arg);
-		break;
-
-	case MSM_GMN_IOCTL_INPUT_GET_UNBLOCK:
-		rc = msm_gemini_input_get_unblock(pgmn_dev);
-		break;
-
-	case MSM_GMN_IOCTL_OUTPUT_BUF_ENQUEUE:
-		if (pgmn_dev->out_mode == MSM_GMN_OUTMODE_FRAGMENTED)
-			rc = msm_gemini_output_buf_enqueue(pgmn_dev,
-				(void __user *) arg);
-		else
-			rc = msm_gemini_set_output_buf(pgmn_dev,
-				(void __user *) arg);
-		break;
-
-	case MSM_GMN_IOCTL_OUTPUT_GET:
-		rc = msm_gemini_output_get(pgmn_dev, (void __user *) arg);
-		break;
-
-	case MSM_GMN_IOCTL_OUTPUT_GET_UNBLOCK:
-		rc = msm_gemini_output_get_unblock(pgmn_dev);
-		break;
-
-	case MSM_GMN_IOCTL_EVT_GET:
-		rc = msm_gemini_evt_get(pgmn_dev, (void __user *) arg);
-		break;
-
-	case MSM_GMN_IOCTL_EVT_GET_UNBLOCK:
-		rc = msm_gemini_evt_get_unblock(pgmn_dev);
-		break;
-
-	case MSM_GMN_IOCTL_HW_CMD:
-		rc = msm_gemini_ioctl_hw_cmd(pgmn_dev, (void __user *) arg);
-		break;
-
-	case MSM_GMN_IOCTL_HW_CMDS:
-		rc = msm_gemini_ioctl_hw_cmds(pgmn_dev, (void __user *) arg);
-		break;
-
-	case MSM_GMN_IOCTL_SET_MODE:
-		rc = msm_gemini_ioctl_set_outmode(pgmn_dev, (void __user *)arg);
-		break;
-
-	default:
-		GMN_PR_ERR(KERN_INFO "%s:%d] cmd = %d not supported\n",
-			__func__, __LINE__, _IOC_NR(cmd));
-		rc = -EINVAL;
-		break;
-	}
-	return rc;
-}
-
-struct msm_gemini_device *__msm_gemini_init(struct platform_device *pdev)
-{
-	struct msm_gemini_device *pgmn_dev;
-
-	pgmn_dev = kzalloc(sizeof(struct msm_gemini_device), GFP_ATOMIC);
-	if (!pgmn_dev) {
-		GMN_PR_ERR("%s:%d]no mem\n", __func__, __LINE__);
-		return NULL;
-	}
-
-	mutex_init(&pgmn_dev->lock);
-
-	pgmn_dev->pdev = pdev;
-
-	msm_gemini_q_init("evt_q", &pgmn_dev->evt_q);
-	msm_gemini_q_init("output_rtn_q", &pgmn_dev->output_rtn_q);
-	msm_gemini_q_init("output_buf_q", &pgmn_dev->output_buf_q);
-	msm_gemini_q_init("input_rtn_q", &pgmn_dev->input_rtn_q);
-	msm_gemini_q_init("input_buf_q", &pgmn_dev->input_buf_q);
-
-	return pgmn_dev;
-}
-
-int __msm_gemini_exit(struct msm_gemini_device *pgmn_dev)
-{
-	mutex_destroy(&pgmn_dev->lock);
-	kfree(pgmn_dev);
-	return 0;
-}
-
diff --git a/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_sync.h b/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_sync.h
deleted file mode 100644
index 88e9615..0000000
--- a/drivers/media/platform/msm/camera_v1/gemini/msm_gemini_sync.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Copyright (c) 2010,2013, The Linux Foundation. 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.
- */
-
-#ifndef MSM_GEMINI_SYNC_H
-#define MSM_GEMINI_SYNC_H
-
-#include <linux/fs.h>
-#include <linux/list.h>
-#include <linux/cdev.h>
-#include <linux/platform_device.h>
-#include <media/v4l2-device.h>
-#include <media/v4l2-subdev.h>
-#include "msm_gemini_core.h"
-
-#define GEMINI_7X 0x1
-#define GEMINI_8X60 (0x1 << 1)
-#define GEMINI_8960 (0x1 << 2)
-
-struct msm_gemini_q {
-	char const	*name;
-	struct list_head  q;
-	spinlock_t	lck;
-	wait_queue_head_t wait;
-	int	       unblck;
-};
-
-struct msm_gemini_q_entry {
-	struct list_head list;
-	void   *data;
-};
-
-struct msm_gemini_device {
-	struct platform_device *pdev;
-	struct resource        *mem;
-	int                     irq;
-	void                   *base;
-	struct clk *gemini_clk[3];
-	struct regulator *gemini_fs;
-	uint32_t hw_version;
-
-	struct device *device;
-	struct cdev   cdev;
-	struct mutex  lock;
-	char	  open_count;
-	uint8_t       op_mode;
-
-	/* event queue including frame done & err indications
-	 */
-	struct msm_gemini_q evt_q;
-
-	/* output return queue
-	 */
-	struct msm_gemini_q output_rtn_q;
-
-	/* output buf queue
-	 */
-	struct msm_gemini_q output_buf_q;
-
-	/* input return queue
-	 */
-	struct msm_gemini_q input_rtn_q;
-
-	/* input buf queue
-	 */
-	struct msm_gemini_q input_buf_q;
-
-	struct v4l2_subdev subdev;
-	enum msm_gmn_out_mode out_mode;
-
-	/* single out mode parameters */
-	struct msm_gemini_hw_buf out_buf;
-	int out_offset;
-	int out_buf_set;
-	int max_out_size;
-	int out_frag_cnt;
-
-	uint32_t bus_perf_client;
-};
-
-int __msm_gemini_open(struct msm_gemini_device *pgmn_dev);
-int __msm_gemini_release(struct msm_gemini_device *pgmn_dev);
-
-long __msm_gemini_ioctl(struct msm_gemini_device *pgmn_dev,
-	unsigned int cmd, unsigned long arg);
-
-struct msm_gemini_device *__msm_gemini_init(struct platform_device *pdev);
-int __msm_gemini_exit(struct msm_gemini_device *pgmn_dev);
-
-#endif /* MSM_GEMINI_SYNC_H */
diff --git a/drivers/media/platform/msm/camera_v1/imx072.c b/drivers/media/platform/msm/camera_v1/imx072.c
deleted file mode 100644
index 29d2118..0000000
--- a/drivers/media/platform/msm/camera_v1/imx072.c
+++ /dev/null
@@ -1,1184 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- *
- */
-
-#include <linux/delay.h>
-#include <linux/debugfs.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/gpio.h>
-#include <mach/camera.h>
-#include "imx072.h"
-
-/* SENSOR REGISTER DEFINES */
-#define REG_GROUPED_PARAMETER_HOLD		0x0104
-#define GROUPED_PARAMETER_HOLD_OFF		0x00
-#define GROUPED_PARAMETER_HOLD			0x01
-/* Integration Time */
-#define REG_COARSE_INTEGRATION_TIME		0x0202
-/* Gain */
-#define REG_GLOBAL_GAIN					0x0204
-
-/* PLL registers */
-#define REG_FRAME_LENGTH_LINES			0x0340
-#define REG_LINE_LENGTH_PCK				0x0342
-
-/* 16bit address - 8 bit context register structure */
-#define Q8  0x00000100
-#define Q10 0x00000400
-#define IMX072_MASTER_CLK_RATE 24000000
-#define IMX072_OFFSET		3
-
-/* AF Total steps parameters */
-#define IMX072_AF_I2C_ADDR	0x18
-#define IMX072_TOTAL_STEPS_NEAR_TO_FAR    30
-
-static uint16_t imx072_step_position_table[IMX072_TOTAL_STEPS_NEAR_TO_FAR+1];
-static uint16_t imx072_nl_region_boundary1;
-static uint16_t imx072_nl_region_code_per_step1;
-static uint16_t imx072_l_region_code_per_step = 12;
-static uint16_t imx072_sw_damping_time_wait = 8;
-static uint16_t imx072_af_initial_code = 350;
-static uint16_t imx072_damping_threshold = 10;
-
-struct imx072_work_t {
-	struct work_struct work;
-};
-
-static struct imx072_work_t *imx072_sensorw;
-static struct i2c_client *imx072_client;
-
-struct imx072_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 */
-	uint16_t fps;
-
-	uint16_t curr_lens_pos;
-	uint16_t curr_step_pos;
-	uint16_t my_reg_gain;
-	uint32_t my_reg_line_count;
-	uint16_t total_lines_per_frame;
-
-	enum imx072_resolution_t prev_res;
-	enum imx072_resolution_t pict_res;
-	enum imx072_resolution_t curr_res;
-	enum imx072_test_mode_t  set_test;
-	enum imx072_cam_mode_t cam_mode;
-};
-
-static uint16_t prev_line_length_pck;
-static uint16_t prev_frame_length_lines;
-static uint16_t snap_line_length_pck;
-static uint16_t snap_frame_length_lines;
-
-static bool CSI_CONFIG;
-static struct imx072_ctrl_t *imx072_ctrl;
-static DECLARE_WAIT_QUEUE_HEAD(imx072_wait_queue);
-DEFINE_MUTEX(imx072_mut);
-
-#ifdef CONFIG_DEBUG_FS
-static int cam_debug_init(void);
-static struct dentry *debugfs_base;
-#endif
-
-static int imx072_i2c_rxdata(unsigned short saddr,
-	unsigned char *rxdata, int length)
-{
-	struct i2c_msg msgs[] = {
-		{
-			.addr  = saddr,
-			.flags = 0,
-			.len   = length,
-			.buf   = rxdata,
-		},
-		{
-			.addr  = saddr,
-			.flags = I2C_M_RD,
-			.len   = length,
-			.buf   = rxdata,
-		},
-	};
-	if (i2c_transfer(imx072_client->adapter, msgs, 2) < 0) {
-		pr_err("imx072_i2c_rxdata faild 0x%x\n", saddr);
-		return -EIO;
-	}
-	return 0;
-}
-
-static int32_t imx072_i2c_txdata(unsigned short saddr,
-				unsigned char *txdata, int length)
-{
-	struct i2c_msg msg[] = {
-		{
-			.addr = saddr,
-			.flags = 0,
-			.len = length,
-			.buf = txdata,
-		 },
-	};
-	if (i2c_transfer(imx072_client->adapter, msg, 1) < 0) {
-		pr_err("imx072_i2c_txdata faild 0x%x\n", saddr);
-		return -EIO;
-	}
-
-	return 0;
-}
-
-static int32_t imx072_i2c_read(unsigned short raddr,
-	unsigned short *rdata, int rlen)
-{
-	int32_t rc = 0;
-	unsigned char buf[2];
-	if (!rdata)
-		return -EIO;
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (raddr & 0xFF00) >> 8;
-	buf[1] = (raddr & 0x00FF);
-	rc = imx072_i2c_rxdata(imx072_client->addr>>1, buf, rlen);
-	if (rc < 0) {
-		pr_err("imx072_i2c_read 0x%x failed!\n", raddr);
-		return rc;
-	}
-	*rdata = (rlen == 2 ? buf[0] << 8 | buf[1] : buf[0]);
-	CDBG("imx072_i2c_read 0x%x val = 0x%x!\n", raddr, *rdata);
-	return rc;
-}
-
-static int32_t imx072_i2c_write_w_sensor(unsigned short waddr,
-	uint16_t wdata)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[4];
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00) >> 8;
-	buf[1] = (waddr & 0x00FF);
-	buf[2] = (wdata & 0xFF00) >> 8;
-	buf[3] = (wdata & 0x00FF);
-	CDBG("i2c_write_b addr = 0x%x, val = 0x%x\n", waddr, wdata);
-	rc = imx072_i2c_txdata(imx072_client->addr>>1, buf, 4);
-	if (rc < 0) {
-		pr_err("i2c_write_b failed, addr = 0x%x, val = 0x%x!\n",
-			waddr, wdata);
-	}
-	return rc;
-}
-
-static int32_t imx072_i2c_write_b_sensor(unsigned short waddr,
-	uint8_t bdata)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[3];
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00) >> 8;
-	buf[1] = (waddr & 0x00FF);
-	buf[2] = bdata;
-	CDBG("i2c_write_b addr = 0x%x, val = 0x%x\n", waddr, bdata);
-	rc = imx072_i2c_txdata(imx072_client->addr>>1, buf, 3);
-	if (rc < 0)
-		pr_err("i2c_write_b failed, addr = 0x%x, val = 0x%x!\n",
-			waddr, bdata);
-	return rc;
-}
-
-static int32_t imx072_i2c_write_b_af(uint8_t msb, uint8_t lsb)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[2];
-
-	buf[0] = msb;
-	buf[1] = lsb;
-	rc = imx072_i2c_txdata(IMX072_AF_I2C_ADDR>>1, buf, 2);
-	if (rc < 0)
-		pr_err("af_i2c_write faield msb = 0x%x lsb = 0x%x",
-			msb, lsb);
-	return rc;
-}
-
-static int32_t imx072_i2c_write_w_table(struct imx072_i2c_reg_conf const
-					 *reg_conf_tbl, int num)
-{
-	int i;
-	int32_t rc = -EIO;
-	for (i = 0; i < num; i++) {
-		rc = imx072_i2c_write_b_sensor(reg_conf_tbl->waddr,
-			reg_conf_tbl->wdata);
-		if (rc < 0)
-			break;
-		reg_conf_tbl++;
-	}
-	return rc;
-}
-
-static void imx072_group_hold_on(void)
-{
-	imx072_i2c_write_b_sensor(REG_GROUPED_PARAMETER_HOLD,
-						GROUPED_PARAMETER_HOLD);
-}
-
-static void imx072_group_hold_off(void)
-{
-	imx072_i2c_write_b_sensor(REG_GROUPED_PARAMETER_HOLD,
-						GROUPED_PARAMETER_HOLD_OFF);
-}
-
-static void imx072_start_stream(void)
-{
-	imx072_i2c_write_b_sensor(0x0100, 0x01);
-}
-
-static void imx072_stop_stream(void)
-{
-	imx072_i2c_write_b_sensor(0x0100, 0x00);
-}
-
-static void imx072_get_pict_fps(uint16_t fps, uint16_t *pfps)
-{
-	/* input fps is preview fps in Q8 format */
-	uint32_t divider, d1, d2;
-
-	d1 = prev_frame_length_lines * 0x00000400 / snap_frame_length_lines;
-	d2 = prev_line_length_pck * 0x00000400 / snap_line_length_pck;
-	divider = d1 * d2 / 0x400;
-
-	/*Verify PCLK settings and frame sizes.*/
-	*pfps = (uint16_t) (fps * divider / 0x400);
-}
-
-static uint16_t imx072_get_prev_lines_pf(void)
-{
-	return prev_frame_length_lines;
-}
-
-static uint16_t imx072_get_prev_pixels_pl(void)
-{
-	return prev_line_length_pck;
-}
-
-static uint16_t imx072_get_pict_lines_pf(void)
-{
-	return snap_frame_length_lines;
-}
-
-static uint16_t imx072_get_pict_pixels_pl(void)
-{
-	return snap_line_length_pck;
-}
-
-static uint32_t imx072_get_pict_max_exp_lc(void)
-{
-	return snap_frame_length_lines  * 24;
-}
-
-static int32_t imx072_set_fps(struct fps_cfg   *fps)
-{
-	uint16_t total_lines_per_frame;
-	int32_t rc = 0;
-	total_lines_per_frame = (uint16_t)
-		((prev_frame_length_lines *
-		imx072_ctrl->fps_divider)/0x400);
-	imx072_ctrl->fps_divider = fps->fps_div;
-	imx072_ctrl->pict_fps_divider = fps->pict_fps_div;
-
-	imx072_group_hold_on();
-	rc = imx072_i2c_write_w_sensor(REG_FRAME_LENGTH_LINES,
-							total_lines_per_frame);
-	imx072_group_hold_off();
-	return rc;
-}
-
-static int32_t imx072_write_exp_gain(uint16_t gain, uint32_t line)
-{
-	uint32_t fl_lines = 0;
-	uint8_t offset;
-	int32_t rc = 0;
-	if (imx072_ctrl->curr_res == imx072_ctrl->prev_res)
-		fl_lines = prev_frame_length_lines;
-	else if (imx072_ctrl->curr_res == imx072_ctrl->pict_res)
-		fl_lines = snap_frame_length_lines;
-	line = (line * imx072_ctrl->fps_divider) / Q10;
-	offset = IMX072_OFFSET;
-	if (line > (fl_lines - offset))
-		fl_lines = line + offset;
-
-	imx072_group_hold_on();
-	rc = imx072_i2c_write_w_sensor(REG_FRAME_LENGTH_LINES, fl_lines);
-	rc = imx072_i2c_write_w_sensor(REG_COARSE_INTEGRATION_TIME, line);
-	rc = imx072_i2c_write_w_sensor(REG_GLOBAL_GAIN, gain);
-	imx072_group_hold_off();
-	return rc;
-}
-
-static int32_t imx072_set_pict_exp_gain(uint16_t gain, uint32_t line)
-{
-	int32_t rc = 0;
-	rc = imx072_write_exp_gain(gain, line);
-	return rc;
-}
-
-static int32_t imx072_sensor_setting(int update_type, int rt)
-{
-
-	int32_t rc = 0;
-	struct msm_camera_csi_params imx072_csi_params;
-
-	imx072_stop_stream();
-	msleep(30);
-	if (update_type == REG_INIT) {
-		msleep(20);
-		CSI_CONFIG = 0;
-		imx072_i2c_write_w_table(imx072_regs.rec_settings,
-			imx072_regs.rec_size);
-	} else if (update_type == UPDATE_PERIODIC) {
-#ifdef CONFIG_DEBUG_FS
-		cam_debug_init();
-#endif
-		msleep(20);
-		if (!CSI_CONFIG) {
-			imx072_csi_params.lane_cnt = 2;
-			imx072_csi_params.data_format = CSI_10BIT;
-			imx072_csi_params.lane_assign = 0xe4;
-			imx072_csi_params.dpcm_scheme = 0;
-			imx072_csi_params.settle_cnt = 0x18;
-			msm_camio_vfe_clk_rate_set(192000000);
-			rc = msm_camio_csi_config(&imx072_csi_params);
-			msleep(100);
-			CSI_CONFIG = 1;
-		}
-		imx072_i2c_write_w_table(
-			imx072_regs.conf_array[rt].conf,
-			imx072_regs.conf_array[rt].size);
-		imx072_start_stream();
-		msleep(30);
-	}
-	return rc;
-}
-
-static int32_t imx072_video_config(int mode)
-{
-
-	int32_t rc = 0;
-	/* change sensor resolution if needed */
-	if (imx072_sensor_setting(UPDATE_PERIODIC,
-		imx072_ctrl->prev_res) < 0)
-		return rc;
-
-	imx072_ctrl->curr_res = imx072_ctrl->prev_res;
-	imx072_ctrl->sensormode = mode;
-	return rc;
-}
-
-static int32_t imx072_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-	/*change sensor resolution if needed */
-	if (imx072_ctrl->curr_res != imx072_ctrl->pict_res) {
-		if (imx072_sensor_setting(UPDATE_PERIODIC,
-					imx072_ctrl->pict_res) < 0)
-			return rc;
-	}
-
-	imx072_ctrl->curr_res = imx072_ctrl->pict_res;
-	imx072_ctrl->sensormode = mode;
-	return rc;
-}
-
-static int32_t imx072_raw_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-	/* change sensor resolution if needed */
-	if (imx072_ctrl->curr_res != imx072_ctrl->pict_res) {
-		if (imx072_sensor_setting(UPDATE_PERIODIC,
-					imx072_ctrl->pict_res) < 0)
-			return rc;
-	}
-
-	imx072_ctrl->curr_res = imx072_ctrl->pict_res;
-	imx072_ctrl->sensormode = mode;
-	return rc;
-}
-
-static int32_t imx072_mode_init(int mode, struct sensor_init_cfg init_info)
-{
-	int32_t rc = 0;
-	CDBG("%s: %d\n", __func__, __LINE__);
-	if (mode != imx072_ctrl->cam_mode) {
-		imx072_ctrl->prev_res = init_info.prev_res;
-		imx072_ctrl->pict_res = init_info.pict_res;
-		imx072_ctrl->cam_mode = mode;
-
-		prev_frame_length_lines =
-			imx072_regs.conf_array[imx072_ctrl->prev_res].
-			conf[IMX072_FRAME_LENGTH_LINES_HI].wdata << 8 |
-			imx072_regs.conf_array[imx072_ctrl->prev_res].
-			conf[IMX072_FRAME_LENGTH_LINES_LO].wdata;
-		prev_line_length_pck =
-			imx072_regs.conf_array[imx072_ctrl->prev_res].
-			conf[IMX072_LINE_LENGTH_PCK_HI].wdata << 8 |
-			imx072_regs.conf_array[imx072_ctrl->prev_res].
-			conf[IMX072_LINE_LENGTH_PCK_LO].wdata;
-		snap_frame_length_lines =
-			imx072_regs.conf_array[imx072_ctrl->pict_res].
-			conf[IMX072_FRAME_LENGTH_LINES_HI].wdata << 8 |
-			imx072_regs.conf_array[imx072_ctrl->pict_res].
-			conf[IMX072_FRAME_LENGTH_LINES_LO].wdata;
-		snap_line_length_pck =
-			imx072_regs.conf_array[imx072_ctrl->pict_res].
-			conf[IMX072_LINE_LENGTH_PCK_HI].wdata << 8 |
-			imx072_regs.conf_array[imx072_ctrl->pict_res].
-			conf[IMX072_LINE_LENGTH_PCK_LO].wdata;
-
-		rc = imx072_sensor_setting(REG_INIT,
-			imx072_ctrl->prev_res);
-	}
-	return rc;
-}
-
-static int32_t imx072_set_sensor_mode(int mode,
-	int res)
-{
-	int32_t rc = 0;
-
-	switch (mode) {
-	case SENSOR_PREVIEW_MODE:
-		imx072_ctrl->prev_res = res;
-		rc = imx072_video_config(mode);
-		break;
-	case SENSOR_SNAPSHOT_MODE:
-		imx072_ctrl->pict_res = res;
-		rc = imx072_snapshot_config(mode);
-		break;
-	case SENSOR_RAW_SNAPSHOT_MODE:
-		imx072_ctrl->pict_res = res;
-		rc = imx072_raw_snapshot_config(mode);
-		break;
-	default:
-		rc = -EINVAL;
-		break;
-	}
-	return rc;
-}
-
-#define DIV_CEIL(x, y) ((x/y + ((x%y) ? 1 : 0)))
-static int32_t imx072_move_focus(int direction,
-	int32_t num_steps)
-{
-	int32_t rc = 0;
-	int16_t step_direction, dest_lens_position, dest_step_position;
-	uint8_t code_val_msb, code_val_lsb;
-	int16_t next_lens_position, target_dist, small_step;
-
-	if (direction == MOVE_NEAR)
-		step_direction = 1;
-	else if (direction == MOVE_FAR)
-		step_direction = -1;
-	else {
-		pr_err("Illegal focus direction\n");
-		return -EINVAL;
-	}
-	dest_step_position = imx072_ctrl->curr_step_pos +
-			(step_direction * num_steps);
-
-	if (dest_step_position < 0)
-		dest_step_position = 0;
-	else if (dest_step_position > IMX072_TOTAL_STEPS_NEAR_TO_FAR)
-		dest_step_position = IMX072_TOTAL_STEPS_NEAR_TO_FAR;
-
-	if (dest_step_position == imx072_ctrl->curr_step_pos) {
-		CDBG("imx072 same position No-Move exit\n");
-		return rc;
-	}
-	CDBG("%s Index = [%d]\n", __func__, dest_step_position);
-
-	dest_lens_position = imx072_step_position_table[dest_step_position];
-	CDBG("%s lens_position value = %d\n", __func__, dest_lens_position);
-	target_dist = step_direction * (dest_lens_position -
-		imx072_ctrl->curr_lens_pos);
-	if (step_direction < 0 && (target_dist >=
-		(imx072_step_position_table[imx072_damping_threshold]
-			- imx072_af_initial_code))) {
-		small_step = DIV_CEIL(target_dist, 10);
-		imx072_sw_damping_time_wait = 30;
-	} else {
-		small_step = DIV_CEIL(target_dist, 4);
-		imx072_sw_damping_time_wait = 20;
-	}
-
-	CDBG("%s: small_step:%d, wait_time:%d\n", __func__, small_step,
-		imx072_sw_damping_time_wait);
-	for (next_lens_position = imx072_ctrl->curr_lens_pos +
-		(step_direction * small_step);
-		(step_direction * next_lens_position) <=
-		(step_direction * dest_lens_position);
-		next_lens_position += (step_direction * small_step)) {
-
-		code_val_msb = ((next_lens_position & 0x03F0) >> 4);
-		code_val_lsb = ((next_lens_position & 0x000F) << 4);
-		CDBG("position value = %d\n", next_lens_position);
-		CDBG("movefocus vcm_msb = %d\n", code_val_msb);
-		CDBG("movefocus vcm_lsb = %d\n", code_val_lsb);
-		rc = imx072_i2c_write_b_af(code_val_msb, code_val_lsb);
-		if (rc < 0) {
-			pr_err("imx072_move_focus failed writing i2c\n");
-			return rc;
-			}
-		imx072_ctrl->curr_lens_pos = next_lens_position;
-		usleep(imx072_sw_damping_time_wait*100);
-	}
-	if (imx072_ctrl->curr_lens_pos != dest_lens_position) {
-		code_val_msb = ((dest_lens_position & 0x03F0) >> 4);
-		code_val_lsb = ((dest_lens_position & 0x000F) << 4);
-		CDBG("position value = %d\n", dest_lens_position);
-		CDBG("movefocus vcm_msb = %d\n", code_val_msb);
-		CDBG("movefocus vcm_lsb = %d\n", code_val_lsb);
-		rc = imx072_i2c_write_b_af(code_val_msb, code_val_lsb);
-		if (rc < 0) {
-			pr_err("imx072_move_focus failed writing i2c\n");
-			return rc;
-			}
-		usleep(imx072_sw_damping_time_wait * 100);
-	}
-	imx072_ctrl->curr_lens_pos = dest_lens_position;
-	imx072_ctrl->curr_step_pos = dest_step_position;
-	return rc;
-
-}
-
-static int32_t imx072_init_focus(void)
-{
-	uint8_t i;
-	int32_t rc = 0;
-
-	imx072_step_position_table[0] = imx072_af_initial_code;
-	for (i = 1; i <= IMX072_TOTAL_STEPS_NEAR_TO_FAR; i++) {
-		if (i <= imx072_nl_region_boundary1)
-			imx072_step_position_table[i] =
-				imx072_step_position_table[i-1]
-				+ imx072_nl_region_code_per_step1;
-		else
-			imx072_step_position_table[i] =
-				imx072_step_position_table[i-1]
-				+ imx072_l_region_code_per_step;
-
-		if (imx072_step_position_table[i] > 1023)
-			imx072_step_position_table[i] = 1023;
-	}
-	imx072_ctrl->curr_lens_pos = 0;
-
-	return rc;
-}
-
-static int32_t imx072_set_default_focus(void)
-{
-	int32_t rc = 0;
-	uint8_t code_val_msb, code_val_lsb;
-	int16_t dest_lens_position = 0;
-
-	CDBG("%s Index = [%d]\n", __func__, 0);
-	if (imx072_ctrl->curr_step_pos != 0)
-		rc = imx072_move_focus(MOVE_FAR,
-		imx072_ctrl->curr_step_pos);
-	else {
-		dest_lens_position = imx072_af_initial_code;
-		code_val_msb = ((dest_lens_position & 0x03F0) >> 4);
-		code_val_lsb = ((dest_lens_position & 0x000F) << 4);
-
-		CDBG("position value = %d\n", dest_lens_position);
-		CDBG("movefocus vcm_msb = %d\n", code_val_msb);
-		CDBG("movefocus vcm_lsb = %d\n", code_val_lsb);
-		rc = imx072_i2c_write_b_af(code_val_msb, code_val_lsb);
-		if (rc < 0) {
-			pr_err("imx072_set_default_focus failed writing i2c\n");
-			return rc;
-		}
-
-		imx072_ctrl->curr_lens_pos = dest_lens_position;
-		imx072_ctrl->curr_step_pos = 0;
-
-	}
-	usleep(5000);
-	return rc;
-}
-
-static int32_t imx072_af_power_down(void)
-{
-	int32_t rc = 0;
-	int32_t i = 0;
-	int16_t dest_lens_position = imx072_af_initial_code;
-
-	if (imx072_ctrl->curr_lens_pos != 0) {
-		rc = imx072_set_default_focus();
-		CDBG("%s after imx072_set_default_focus\n", __func__);
-		msleep(40);
-		/*to avoid the sound during the power off.
-		brings the actuator to mechanical infinity gradually.*/
-		for (i = 0; i < IMX072_TOTAL_STEPS_NEAR_TO_FAR; i++) {
-			dest_lens_position = dest_lens_position -
-				(imx072_af_initial_code /
-					IMX072_TOTAL_STEPS_NEAR_TO_FAR);
-			CDBG("position value = %d\n", dest_lens_position);
-			rc = imx072_i2c_write_b_af(
-				((dest_lens_position & 0x03F0) >> 4),
-				((dest_lens_position & 0x000F) << 4));
-			CDBG("count = %d\n", i);
-			msleep(20);
-			if (rc < 0) {
-				pr_err("imx072_set_default_focus failed writing i2c\n");
-				return rc;
-			}
-		}
-		rc = imx072_i2c_write_b_af(0x00, 00);
-		msleep(40);
-	}
-	rc = imx072_i2c_write_b_af(0x80, 00);
-	return rc;
-}
-
-static int32_t imx072_power_down(void)
-{
-	int32_t rc = 0;
-
-	rc = imx072_af_power_down();
-	return rc;
-}
-
-static int imx072_probe_init_done(const struct msm_camera_sensor_info *data)
-{
-	pr_err("probe done\n");
-	gpio_free(data->sensor_reset);
-	return 0;
-}
-
-static int imx072_probe_init_sensor(
-	const struct msm_camera_sensor_info *data)
-{
-	int32_t rc = 0;
-	uint16_t chipid = 0;
-
-	CDBG("%s: %d\n", __func__, __LINE__);
-	rc = gpio_request(data->sensor_reset, "imx072");
-	CDBG(" imx072_probe_init_sensor\n");
-	if (!rc) {
-		pr_err("sensor_reset = %d\n", rc);
-		gpio_direction_output(data->sensor_reset, 0);
-		msleep(50);
-		gpio_set_value_cansleep(data->sensor_reset, 1);
-		msleep(20);
-	} else
-		goto gpio_req_fail;
-
-	CDBG(" imx072_probe_init_sensor is called\n");
-	rc = imx072_i2c_read(0x0, &chipid, 2);
-	CDBG("ID: %d\n", chipid);
-	/* 4. Compare sensor ID to IMX072 ID: */
-	if (chipid != 0x0045) {
-		rc = -ENODEV;
-		pr_err("imx072_probe_init_sensor chip id doesnot match\n");
-		goto init_probe_fail;
-	}
-
-	return rc;
-init_probe_fail:
-	pr_err(" imx072_probe_init_sensor fails\n");
-	gpio_set_value_cansleep(data->sensor_reset, 0);
-	imx072_probe_init_done(data);
-	if (data->vcm_enable) {
-		int ret = gpio_request(data->vcm_pwd, "imx072_af");
-		if (!ret) {
-			gpio_direction_output(data->vcm_pwd, 0);
-			msleep(20);
-			gpio_free(data->vcm_pwd);
-		}
-	}
-gpio_req_fail:
-	return rc;
-}
-
-int imx072_sensor_open_init(const struct msm_camera_sensor_info *data)
-{
-	int32_t rc = 0;
-
-	CDBG("%s: %d\n", __func__, __LINE__);
-	imx072_ctrl = kzalloc(sizeof(struct imx072_ctrl_t), GFP_KERNEL);
-	if (!imx072_ctrl) {
-		pr_err("imx072_init failed!\n");
-		rc = -ENOMEM;
-		goto init_done;
-	}
-	imx072_ctrl->fps_divider = 1 * 0x00000400;
-	imx072_ctrl->pict_fps_divider = 1 * 0x00000400;
-	imx072_ctrl->set_test = TEST_OFF;
-	imx072_ctrl->cam_mode = MODE_INVALID;
-
-	if (data)
-		imx072_ctrl->sensordata = data;
-	if (rc < 0) {
-		pr_err("Calling imx072_sensor_open_init fail1\n");
-		return rc;
-	}
-	CDBG("%s: %d\n", __func__, __LINE__);
-	/* enable mclk first */
-	msm_camio_clk_rate_set(IMX072_MASTER_CLK_RATE);
-	rc = imx072_probe_init_sensor(data);
-	if (rc < 0)
-		goto init_fail;
-
-	imx072_init_focus();
-	imx072_ctrl->fps = 30*Q8;
-	if (rc < 0) {
-		gpio_set_value_cansleep(data->sensor_reset, 0);
-		goto init_fail;
-	} else
-		goto init_done;
-init_fail:
-	pr_err("init_fail\n");
-	imx072_probe_init_done(data);
-init_done:
-	pr_err("init_done\n");
-	return rc;
-}
-
-static int imx072_init_client(struct i2c_client *client)
-{
-	/* Initialize the MSM_CAMI2C Chip */
-	init_waitqueue_head(&imx072_wait_queue);
-	return 0;
-}
-
-static const struct i2c_device_id imx072_i2c_id[] = {
-	{"imx072", 0},
-	{ }
-};
-
-static int imx072_i2c_probe(struct i2c_client *client,
-	const struct i2c_device_id *id)
-{
-	int rc = 0;
-	CDBG("imx072_probe called!\n");
-
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		pr_err("i2c_check_functionality failed\n");
-		goto probe_failure;
-	}
-
-	imx072_sensorw = kzalloc(sizeof(struct imx072_work_t),
-			GFP_KERNEL);
-	if (!imx072_sensorw) {
-		pr_err("kzalloc failed.\n");
-		rc = -ENOMEM;
-		goto probe_failure;
-	}
-
-	i2c_set_clientdata(client, imx072_sensorw);
-	imx072_init_client(client);
-	imx072_client = client;
-
-	msleep(50);
-
-	CDBG("imx072_probe successed! rc = %d\n", rc);
-	return 0;
-
-probe_failure:
-	pr_err("imx072_probe failed! rc = %d\n", rc);
-	return rc;
-}
-
-static int imx072_send_wb_info(struct wb_info_cfg *wb)
-{
-	return 0;
-
-}
-
-static int __exit imx072_remove(struct i2c_client *client)
-{
-	struct imx072_work_t_t *sensorw = i2c_get_clientdata(client);
-	free_irq(client->irq, sensorw);
-	imx072_client = NULL;
-	kfree(sensorw);
-	return 0;
-}
-
-static struct i2c_driver imx072_i2c_driver = {
-	.id_table = imx072_i2c_id,
-	.probe  = imx072_i2c_probe,
-	.remove = __exit_p(imx072_i2c_remove),
-	.driver = {
-		.name = "imx072",
-	},
-};
-
-int imx072_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(&imx072_mut);
-	CDBG("imx072_sensor_config: cfgtype = %d\n",
-		 cdata.cfgtype);
-	switch (cdata.cfgtype) {
-	case CFG_GET_PICT_FPS:
-		imx072_get_pict_fps(
-			cdata.cfg.gfps.prevfps,
-			&(cdata.cfg.gfps.pictfps));
-
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_GET_PREV_L_PF:
-		cdata.cfg.prevl_pf =
-		imx072_get_prev_lines_pf();
-
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_GET_PREV_P_PL:
-		cdata.cfg.prevp_pl =
-			imx072_get_prev_pixels_pl();
-
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_GET_PICT_L_PF:
-		cdata.cfg.pictl_pf =
-			imx072_get_pict_lines_pf();
-
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_GET_PICT_P_PL:
-		cdata.cfg.pictp_pl =
-			imx072_get_pict_pixels_pl();
-
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_GET_PICT_MAX_EXP_LC:
-		cdata.cfg.pict_max_exp_lc =
-			imx072_get_pict_max_exp_lc();
-
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_SET_FPS:
-	case CFG_SET_PICT_FPS:
-		rc = imx072_set_fps(&(cdata.cfg.fps));
-		break;
-	case CFG_SET_EXP_GAIN:
-		rc = imx072_write_exp_gain(
-			cdata.cfg.exp_gain.gain,
-			cdata.cfg.exp_gain.line);
-		break;
-	case CFG_SET_PICT_EXP_GAIN:
-		rc = imx072_set_pict_exp_gain(
-			cdata.cfg.exp_gain.gain,
-			cdata.cfg.exp_gain.line);
-		break;
-	case CFG_SET_MODE:
-		rc = imx072_set_sensor_mode(cdata.mode, cdata.rs);
-		break;
-	case CFG_PWR_DOWN:
-		rc = imx072_power_down();
-		break;
-	case CFG_MOVE_FOCUS:
-		rc = imx072_move_focus(cdata.cfg.focus.dir,
-				cdata.cfg.focus.steps);
-		break;
-	case CFG_SET_DEFAULT_FOCUS:
-		imx072_set_default_focus();
-		break;
-	case CFG_GET_AF_MAX_STEPS:
-		cdata.max_steps = IMX072_TOTAL_STEPS_NEAR_TO_FAR;
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_SET_EFFECT:
-		break;
-	case CFG_SEND_WB_INFO:
-		rc = imx072_send_wb_info(
-			&(cdata.cfg.wb_info));
-	break;
-	case CFG_SENSOR_INIT:
-		rc = imx072_mode_init(cdata.mode,
-				cdata.cfg.init_info);
-	break;
-	case CFG_SET_LENS_SHADING:
-		break;
-	default:
-		rc = -EFAULT;
-		break;
-	}
-
-	mutex_unlock(&imx072_mut);
-
-	return rc;
-}
-
-static int imx072_sensor_release(void)
-{
-	int rc = -EBADF;
-	mutex_lock(&imx072_mut);
-	imx072_power_down();
-	gpio_set_value_cansleep(imx072_ctrl->sensordata->sensor_reset, 0);
-	msleep(20);
-	gpio_free(imx072_ctrl->sensordata->sensor_reset);
-	if (imx072_ctrl->sensordata->vcm_enable) {
-		gpio_set_value_cansleep(imx072_ctrl->sensordata->vcm_pwd, 0);
-		gpio_free(imx072_ctrl->sensordata->vcm_pwd);
-	}
-	kfree(imx072_ctrl);
-	imx072_ctrl = NULL;
-	pr_err("imx072_release completed\n");
-	mutex_unlock(&imx072_mut);
-
-	return rc;
-}
-
-static int imx072_sensor_probe(const struct msm_camera_sensor_info *info,
-		struct msm_sensor_ctrl *s)
-{
-	int rc = 0;
-	rc = i2c_add_driver(&imx072_i2c_driver);
-	if (rc < 0 || imx072_client == NULL) {
-		rc = -ENOTSUPP;
-		pr_err("I2C add driver failed");
-		goto probe_fail;
-	}
-	msm_camio_clk_rate_set(IMX072_MASTER_CLK_RATE);
-	rc = imx072_probe_init_sensor(info);
-	if (rc < 0)
-		goto probe_fail;
-	s->s_init = imx072_sensor_open_init;
-	s->s_release = imx072_sensor_release;
-	s->s_config  = imx072_sensor_config;
-	s->s_mount_angle = info->sensor_platform_info->mount_angle;
-
-	gpio_set_value_cansleep(info->sensor_reset, 0);
-	imx072_probe_init_done(info);
-	if (info->vcm_enable) {
-		rc = gpio_request(info->vcm_pwd, "imx072_af");
-		if (!rc) {
-			gpio_direction_output(info->vcm_pwd, 0);
-			msleep(20);
-			gpio_free(info->vcm_pwd);
-		} else
-			return rc;
-	}
-	pr_info("imx072_sensor_probe : SUCCESS\n");
-	return rc;
-
-probe_fail:
-	pr_err("imx072_sensor_probe: SENSOR PROBE FAILS!\n");
-	return rc;
-}
-
-static int __imx072_probe(struct platform_device *pdev)
-{
-	return msm_camera_drv_start(pdev, imx072_sensor_probe);
-}
-
-static struct platform_driver msm_camera_driver = {
-	.probe = __imx072_probe,
-	.driver = {
-		.name = "msm_camera_imx072",
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init imx072_init(void)
-{
-	return platform_driver_register(&msm_camera_driver);
-}
-
-module_init(imx072_init);
-void imx072_exit(void)
-{
-	i2c_del_driver(&imx072_i2c_driver);
-}
-MODULE_DESCRIPTION("Aptina 8 MP Bayer sensor driver");
-MODULE_LICENSE("GPL v2");
-
-#ifdef CONFIG_DEBUG_FS
-static bool streaming = 1;
-
-static int cam_debug_stream_set(void *data, u64 val)
-{
-	int rc = 0;
-
-	if (val) {
-		imx072_start_stream();
-		streaming = 1;
-	} else {
-		imx072_stop_stream();
-		streaming = 0;
-	}
-
-	return rc;
-}
-
-static int cam_debug_stream_get(void *data, u64 *val)
-{
-	*val = streaming;
-	return 0;
-}
-DEFINE_SIMPLE_ATTRIBUTE(cam_stream, cam_debug_stream_get,
-			cam_debug_stream_set, "%llu\n");
-
-
-
-static int imx072_set_af_codestep(void *data, u64 val)
-{
-	imx072_l_region_code_per_step = val;
-	imx072_init_focus();
-	return 0;
-}
-
-static int imx072_get_af_codestep(void *data, u64 *val)
-{
-	*val = imx072_l_region_code_per_step;
-	return 0;
-}
-
-static uint16_t imx072_linear_total_step = IMX072_TOTAL_STEPS_NEAR_TO_FAR;
-static int imx072_set_linear_total_step(void *data, u64 val)
-{
-	imx072_linear_total_step = val;
-	return 0;
-}
-
-static int imx072_af_linearity_test(void *data, u64 *val)
-{
-	int i = 0;
-
-	imx072_set_default_focus();
-	msleep(3000);
-	for (i = 0; i < imx072_linear_total_step; i++) {
-		imx072_move_focus(MOVE_NEAR, 1);
-		CDBG("moved to index =[%d]\n", i);
-		msleep(1000);
-	}
-
-	for (i = 0; i < imx072_linear_total_step; i++) {
-		imx072_move_focus(MOVE_FAR, 1);
-		CDBG("moved to index =[%d]\n", i);
-		msleep(1000);
-	}
-	return 0;
-}
-
-static uint16_t imx072_step_val = IMX072_TOTAL_STEPS_NEAR_TO_FAR;
-static uint8_t imx072_step_dir = MOVE_NEAR;
-static int imx072_af_step_config(void *data, u64 val)
-{
-	imx072_step_val = val & 0xFFFF;
-	imx072_step_dir = (val >> 16) & 0x1;
-	return 0;
-}
-
-static int imx072_af_step(void *data, u64 *val)
-{
-	int i = 0;
-	int dir = MOVE_NEAR;
-	imx072_set_default_focus();
-	msleep(3000);
-	if (imx072_step_dir == 1)
-		dir = MOVE_FAR;
-
-	for (i = 0; i < imx072_step_val; i += 4) {
-		imx072_move_focus(dir, 4);
-		msleep(1000);
-	}
-	imx072_set_default_focus();
-	msleep(3000);
-	return 0;
-}
-
-static int imx072_af_set_resolution(void *data, u64 val)
-{
-	imx072_init_focus();
-	return 0;
-}
-
-static int imx072_af_get_resolution(void *data, u64 *val)
-{
-	*val = 0xFF;
-	return 0;
-}
-
-
-
-DEFINE_SIMPLE_ATTRIBUTE(af_codeperstep, imx072_get_af_codestep,
-			imx072_set_af_codestep, "%llu\n");
-
-DEFINE_SIMPLE_ATTRIBUTE(af_linear, imx072_af_linearity_test,
-			imx072_set_linear_total_step, "%llu\n");
-
-DEFINE_SIMPLE_ATTRIBUTE(af_step, imx072_af_step,
-			imx072_af_step_config, "%llu\n");
-
-DEFINE_SIMPLE_ATTRIBUTE(af_step_res, imx072_af_get_resolution,
-			imx072_af_set_resolution, "%llu\n");
-
-static int cam_debug_init(void)
-{
-	struct dentry *cam_dir;
-	debugfs_base = debugfs_create_dir("sensor", NULL);
-	if (!debugfs_base)
-		return -ENOMEM;
-
-	cam_dir = debugfs_create_dir("imx072", debugfs_base);
-	if (!cam_dir)
-		return -ENOMEM;
-
-	if (!debugfs_create_file("stream", S_IRUGO | S_IWUSR, cam_dir,
-							 NULL, &cam_stream))
-		return -ENOMEM;
-
-	if (!debugfs_create_file("af_codeperstep", S_IRUGO | S_IWUSR, cam_dir,
-							 NULL, &af_codeperstep))
-		return -ENOMEM;
-	if (!debugfs_create_file("af_linear", S_IRUGO | S_IWUSR, cam_dir,
-							 NULL, &af_linear))
-		return -ENOMEM;
-	if (!debugfs_create_file("af_step", S_IRUGO | S_IWUSR, cam_dir,
-							 NULL, &af_step))
-		return -ENOMEM;
-
-	if (!debugfs_create_file("af_step_res", S_IRUGO | S_IWUSR, cam_dir,
-							 NULL, &af_step_res))
-		return -ENOMEM;
-
-	return 0;
-}
-#endif
diff --git a/drivers/media/platform/msm/camera_v1/imx072.h b/drivers/media/platform/msm/camera_v1/imx072.h
deleted file mode 100644
index 95f688c..0000000
--- a/drivers/media/platform/msm/camera_v1/imx072.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- *
- */
-
-#ifndef IMX072_H
-#define IMX072_H
-#include <linux/types.h>
-#include <mach/board.h>
-extern struct imx072_reg imx072_regs;
-
-struct imx072_i2c_reg_conf {
-	unsigned short waddr;
-	unsigned short wdata;
-};
-
-struct imx072_i2c_conf_array {
-	struct imx072_i2c_reg_conf *conf;
-	unsigned short size;
-};
-
-enum imx072_test_mode_t {
-	TEST_OFF,
-	TEST_1,
-	TEST_2,
-	TEST_3
-};
-
-enum imx072_resolution_t {
-	QTR_2D_SIZE,
-	FULL_2D_SIZE,
-	QTR_3D_SIZE,
-	FULL_3D_SIZE,
-	INVALID_SIZE
-};
-enum imx072_setting {
-	RES_PREVIEW,
-	RES_CAPTURE,
-	RES_3D_PREVIEW,
-	RES_3D_CAPTURE
-};
-enum imx072_cam_mode_t {
-	MODE_2D_RIGHT,
-	MODE_2D_LEFT,
-	MODE_3D,
-	MODE_INVALID
-};
-enum imx072_reg_update {
-	/* Sensor egisters that need to be updated during initialization */
-	REG_INIT,
-	/* Sensor egisters that needs periodic I2C writes */
-	UPDATE_PERIODIC,
-	/* All the sensor Registers will be updated */
-	UPDATE_ALL,
-	/* Not valid update */
-	UPDATE_INVALID
-};
-
-enum imx072_reg_mode {
-	IMX072_FRAME_LENGTH_LINES_HI = 0,
-	IMX072_FRAME_LENGTH_LINES_LO,
-	IMX072_LINE_LENGTH_PCK_HI,
-	IMX072_LINE_LENGTH_PCK_LO,
-};
-
-struct imx072_reg {
-	const struct imx072_i2c_reg_conf *rec_settings;
-	const unsigned short rec_size;
-	const struct imx072_i2c_conf_array *conf_array;
-};
-#endif /* IMX072_H */
diff --git a/drivers/media/platform/msm/camera_v1/imx072_reg.c b/drivers/media/platform/msm/camera_v1/imx072_reg.c
deleted file mode 100644
index fc07e0f..0000000
--- a/drivers/media/platform/msm/camera_v1/imx072_reg.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- *
- */
-
-#include "imx072.h"
-
-struct imx072_i2c_reg_conf imx072_prev_settings[] = {
-	{0x0340, 0x03},/*frame_length*/
-	{0x0341, 0xF7},/*frame_length*/
-	{0x0342, 0x0A},/*line_length*/
-	{0x0343, 0xE0},/*line_length*/
-	{0x0344, 0x00},/*x_addr_start*/
-	{0x0345, 0x00},/*x_addr_start*/
-	{0x0346, 0x00},/*y_addr_start*/
-	{0x0347, 0x00},/*y_addr_start*/
-	{0x0348, 0x0A},/*x_addr_end*/
-	{0x0349, 0x2F},/*x_addr_end*/
-	{0x034A, 0x07},/*y_addr_end*/
-	{0x034B, 0xA7},/*y_addr_end*/
-	{0x034C, 0x05},/*x_out_size*/
-	{0x034D, 0x18},/*x_out_size*/
-	{0x034E, 0x03},/*y_out_size*/
-	{0x034F, 0xD4},/*y_out_size*/
-	{0x0381, 0x01},/*x_even_inc*/
-	{0x0383, 0x03},/*x_odd_inc*/
-	{0x0385, 0x01},/*y_even_inc*/
-	{0x0387, 0x03},/*y_odd_inc*/
-	{0x3016, 0x06},/*VMODEADD*/
-	{0x3017, 0x40},
-	{0x3069, 0x24},
-	{0x306A, 0x00},
-	{0x306B, 0xCB},
-	{0x306C, 0x07},
-	{0x30E8, 0x86},
-	{0x3304, 0x03},
-	{0x3305, 0x02},
-	{0x3306, 0x0A},
-	{0x3307, 0x02},
-	{0x3308, 0x11},
-	{0x3309, 0x04},
-	{0x330A, 0x05},
-	{0x330B, 0x04},
-	{0x330C, 0x05},
-	{0x330D, 0x04},
-	{0x330E, 0x01},
-	{0x3301, 0x80},
-};
-
-struct imx072_i2c_reg_conf imx072_snap_settings[] = {
-	{0x0340, 0x07},/*frame_length*/
-	{0x0341, 0xEE},/*frame_length*/
-	{0x0342, 0x0A},/*line_length*/
-	{0x0343, 0xE0},/*line_length*/
-	{0x0344, 0x00},/*x_addr_start*/
-	{0x0345, 0x00},/*x_addr_start*/
-	{0x0346, 0x00},/*y_addr_start*/
-	{0x0347, 0x00},/*y_addr_start*/
-	{0x0348, 0x0A},/*x_addr_end*/
-	{0x0349, 0x2F},/*x_addr_end*/
-	{0x034A, 0x07},/*y_addr_end*/
-	{0x034B, 0xA7},/*y_addr_end*/
-	{0x034C, 0x0A},/*x_out_size*/
-	{0x034D, 0x30},/*x_out_size*/
-	{0x034E, 0x07},/*y_out_size*/
-	{0x034F, 0xA8},/*y_out_size*/
-	{0x0381, 0x01},/*x_even_inc*/
-	{0x0383, 0x01},/*x_odd_inc*/
-	{0x0385, 0x01},/*y_even_inc*/
-	{0x0387, 0x01},/*y_odd_inc*/
-	{0x3016, 0x06},/*VMODEADD*/
-	{0x3017, 0x40},
-	{0x3069, 0x24},
-	{0x306A, 0x00},
-	{0x306B, 0xCB},
-	{0x306C, 0x07},
-	{0x30E8, 0x06},
-	{0x3304, 0x05},
-	{0x3305, 0x04},
-	{0x3306, 0x15},
-	{0x3307, 0x02},
-	{0x3308, 0x11},
-	{0x3309, 0x07},
-	{0x330A, 0x05},
-	{0x330B, 0x04},
-	{0x330C, 0x05},
-	{0x330D, 0x04},
-	{0x330E, 0x01},
-	{0x3301, 0x00},
-};
-
-struct imx072_i2c_reg_conf imx072_recommend_settings[] = {
-	{0x0307, 0x12},
-	{0x302B, 0x4B},
-	{0x0101, 0x03},
-	{0x300A, 0x80},
-	{0x3014, 0x08},
-	{0x3015, 0x37},
-	{0x3017, 0x40},
-	{0x301C, 0x01},
-	{0x3031, 0x28},
-	{0x3040, 0x00},
-	{0x3041, 0x60},
-	{0x3051, 0x24},
-	{0x3053, 0x34},
-	{0x3055, 0x3B},
-	{0x3057, 0xC0},
-	{0x3060, 0x30},
-	{0x3065, 0x00},
-	{0x30AA, 0x88},
-	{0x30AB, 0x1C},
-	{0x30B0, 0x32},
-	{0x30B2, 0x83},
-	{0x30D3, 0x04},
-	{0x310E, 0xDD},
-	{0x31A4, 0xD8},
-	{0x31A6, 0x17},
-	{0x31AC, 0xCF},
-	{0x31AE, 0xF1},
-	{0x31B4, 0xD8},
-	{0x31B6, 0x17},
-	{0x3304, 0x05},
-	{0x3305, 0x04},
-	{0x3306, 0x15},
-	{0x3307, 0x02},
-	{0x3308, 0x11},
-	{0x3309, 0x07},
-	{0x330A, 0x05},
-	{0x330B, 0x04},
-	{0x330C, 0x05},
-	{0x330D, 0x04},
-	{0x330E, 0x01},
-	{0x30d8, 0x20},
-};
-
-struct imx072_i2c_conf_array imx072_confs[] = {
-	{&imx072_prev_settings[0], ARRAY_SIZE(imx072_prev_settings)},
-	{&imx072_snap_settings[0], ARRAY_SIZE(imx072_snap_settings)},
-};
-
-struct imx072_reg imx072_regs = {
-	.rec_settings = &imx072_recommend_settings[0],
-	.rec_size = ARRAY_SIZE(imx072_recommend_settings),
-	.conf_array = &imx072_confs[0],
-};
diff --git a/drivers/media/platform/msm/camera_v1/imx074.c b/drivers/media/platform/msm/camera_v1/imx074.c
deleted file mode 100644
index 511c7db..0000000
--- a/drivers/media/platform/msm/camera_v1/imx074.c
+++ /dev/null
@@ -1,1414 +0,0 @@
-/* Copyright (c) 2010-2011, The Linux Foundation. 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.
- */
-
-#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/gpio.h>
-#include <mach/camera.h>
-#include <asm/mach-types.h>
-#include "imx074.h"
-
-/*SENSOR REGISTER DEFINES*/
-#define	IMX074_EEPROM_SLAVE_ADDR			0x52
-#define REG_GROUPED_PARAMETER_HOLD			0x0104
-#define GROUPED_PARAMETER_HOLD_OFF			0x00
-#define GROUPED_PARAMETER_HOLD				0x01
-#define REG_MODE_SELECT					0x100
-#define MODE_SELECT_STANDBY_MODE			0x00
-#define MODE_SELECT_STREAM				0x01
-/* Integration Time */
-#define REG_COARSE_INTEGRATION_TIME_HI			0x0202
-#define REG_COARSE_INTEGRATION_TIME_LO			0x0203
-/* Gain */
-#define REG_ANALOGUE_GAIN_CODE_GLOBAL_HI		0x0204
-#define REG_ANALOGUE_GAIN_CODE_GLOBAL_LO		0x0205
-/* PLL registers */
-#define REG_PLL_MULTIPLIER				0x0307
-#define REG_PRE_PLL_CLK_DIV				0x0305
-#define REG_PLSTATIM					0x302b
-#define REG_3024					0x3024
-#define REG_IMAGE_ORIENTATION				0x0101
-#define REG_VNDMY_ABLMGSHLMT				0x300a
-#define REG_Y_OPBADDR_START_DI				0x3014
-#define REG_3015					0x3015
-#define REG_301C					0x301C
-#define REG_302C					0x302C
-#define REG_3031					0x3031
-#define REG_3041					0x3041
-#define REG_3051					0x3051
-#define REG_3053					0x3053
-#define REG_3057					0x3057
-#define REG_305C					0x305C
-#define REG_305D					0x305D
-#define REG_3060					0x3060
-#define REG_3065					0x3065
-#define REG_30AA					0x30AA
-#define REG_30AB					0x30AB
-#define REG_30B0					0x30B0
-#define REG_30B2					0x30B2
-#define REG_30D3					0x30D3
-#define REG_3106					0x3106
-#define REG_310C					0x310C
-#define REG_3304					0x3304
-#define REG_3305					0x3305
-#define REG_3306					0x3306
-#define REG_3307					0x3307
-#define REG_3308					0x3308
-#define REG_3309					0x3309
-#define REG_330A					0x330A
-#define REG_330B					0x330B
-#define REG_330C					0x330C
-#define REG_330D					0x330D
-#define REG_330F					0x330F
-#define REG_3381					0x3381
-
-/* mode setting */
-#define REG_FRAME_LENGTH_LINES_HI			0x0340
-#define REG_FRAME_LENGTH_LINES_LO			0x0341
-#define REG_YADDR_START					0x0347
-#define REG_YAAAR_END					0x034b
-#define REG_X_OUTPUT_SIZE_MSB				0x034c
-#define REG_X_OUTPUT_SIZE_LSB				0x034d
-#define REG_Y_OUTPUT_SIZE_MSB				0x034e
-#define REG_Y_OUTPUT_SIZE_LSB				0x034f
-#define REG_X_EVEN_INC					0x0381
-#define REG_X_ODD_INC					0x0383
-#define REG_Y_EVEN_INC					0x0385
-#define REG_Y_ODD_INC					0x0387
-#define REG_HMODEADD					0x3001
-#define REG_VMODEADD					0x3016
-#define REG_VAPPLINE_START				0x3069
-#define REG_VAPPLINE_END				0x306b
-#define REG_SHUTTER					0x3086
-#define REG_HADDAVE					0x30e8
-#define REG_LANESEL					0x3301
-/* Test Pattern */
-#define REG_TEST_PATTERN_MODE				0x0601
-
-#define REG_LINE_LENGTH_PCK_HI				0x0342
-#define REG_LINE_LENGTH_PCK_LO				0x0343
-/*..... TYPE DECLARATIONS.....*/
-#define	IMX074_OFFSET					3
-#define	IMX074_DEFAULT_MASTER_CLK_RATE			24000000
-/* Full	Size */
-#define	IMX074_FULL_SIZE_WIDTH				4208
-#define	IMX074_FULL_SIZE_HEIGHT				3120
-#define	IMX074_FULL_SIZE_DUMMY_PIXELS			0
-#define	IMX074_FULL_SIZE_DUMMY_LINES			0
-/* Quarter Size	*/
-#define	IMX074_QTR_SIZE_WIDTH				2104
-#define	IMX074_QTR_SIZE_HEIGHT				1560
-#define	IMX074_QTR_SIZE_DUMMY_PIXELS			0
-#define	IMX074_QTR_SIZE_DUMMY_LINES			0
-/* Blanking as measured	on the scope */
-/* Full	Size */
-#define	IMX074_HRZ_FULL_BLK_PIXELS			264
-#define	IMX074_VER_FULL_BLK_LINES			96
-/* Quarter Size	*/
-#define	IMX074_HRZ_QTR_BLK_PIXELS			2368
-#define	IMX074_VER_QTR_BLK_LINES			21
-#define	Q8						0x100
-#define	Q10						0x400
-#define	IMX074_AF_I2C_SLAVE_ID				0x72
-#define	IMX074_STEPS_NEAR_TO_CLOSEST_INF		52
-#define	IMX074_TOTAL_STEPS_NEAR_TO_FAR			52
-static uint32_t imx074_l_region_code_per_step = 2;
-
-struct imx074_work_t {
-	struct work_struct work;
-};
-
-static struct imx074_work_t *imx074_sensorw;
-static struct i2c_client *imx074_client;
-
-struct imx074_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 */
-	uint16_t fps;
-	int16_t curr_lens_pos;
-	uint16_t curr_step_pos;
-	uint16_t my_reg_gain;
-	uint32_t my_reg_line_count;
-	uint16_t total_lines_per_frame;
-	enum imx074_resolution_t prev_res;
-	enum imx074_resolution_t pict_res;
-	enum imx074_resolution_t curr_res;
-	enum imx074_test_mode_t set_test;
-	unsigned short imgaddr;
-};
-static uint8_t imx074_delay_msecs_stdby = 5;
-static uint16_t imx074_delay_msecs_stream = 5;
-static int32_t config_csi;
-
-static struct imx074_ctrl_t *imx074_ctrl;
-static DECLARE_WAIT_QUEUE_HEAD(imx074_wait_queue);
-DEFINE_MUTEX(imx074_mut);
-
-/*=============================================================*/
-
-static int imx074_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   = 2,
-			.buf   = rxdata,
-		},
-	};
-	if (i2c_transfer(imx074_client->adapter, msgs, 2) < 0) {
-		CDBG("imx074_i2c_rxdata failed!\n");
-		return -EIO;
-	}
-	return 0;
-}
-static int32_t imx074_i2c_txdata(unsigned short saddr,
-				unsigned char *txdata, int length)
-{
-	struct i2c_msg msg[] = {
-		{
-			.addr = saddr,
-			.flags = 0,
-			.len = length,
-			.buf = txdata,
-		 },
-	};
-	if (i2c_transfer(imx074_client->adapter, msg, 1) < 0) {
-		CDBG("imx074_i2c_txdata faild 0x%x\n", imx074_client->addr);
-		return -EIO;
-	}
-
-	return 0;
-}
-
-
-static int32_t imx074_i2c_read(unsigned short raddr,
-	unsigned short *rdata, int rlen)
-{
-	int32_t rc = 0;
-	unsigned char buf[2];
-	if (!rdata)
-		return -EIO;
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (raddr & 0xFF00) >> 8;
-	buf[1] = (raddr & 0x00FF);
-	rc = imx074_i2c_rxdata(imx074_client->addr, buf, rlen);
-	if (rc < 0) {
-		CDBG("imx074_i2c_read 0x%x failed!\n", raddr);
-		return rc;
-	}
-	*rdata = (rlen == 2 ? buf[0] << 8 | buf[1] : buf[0]);
-	return rc;
-}
-
-static int imx074_af_i2c_rxdata_b(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(imx074_client->adapter, msgs, 2) < 0) {
-		CDBG("imx074_i2c_rxdata_b failed!\n");
-		return -EIO;
-	}
-
-	return 0;
-}
-
-static int32_t imx074_i2c_read_w_eeprom(unsigned short raddr,
-	unsigned short *rdata)
-{
-	int32_t rc;
-	unsigned char buf;
-	if (!rdata)
-		return -EIO;
-	/* Read 2 bytes in sequence */
-	buf = (raddr & 0x00FF);
-	rc = imx074_af_i2c_rxdata_b(IMX074_EEPROM_SLAVE_ADDR, &buf, 1);
-	if (rc < 0) {
-		CDBG("imx074_i2c_read_eeprom 0x%x failed!\n", raddr);
-		return rc;
-	}
-	*rdata = buf<<8;
-
-	/* Read Second byte of data */
-	buf = (raddr & 0x00FF) + 1;
-	rc = imx074_af_i2c_rxdata_b(IMX074_EEPROM_SLAVE_ADDR, &buf, 1);
-	if (rc < 0) {
-		CDBG("imx074_i2c_read_eeprom 0x%x failed!\n", raddr);
-		return rc;
-	}
-	*rdata |= buf;
-	return rc;
-}
-
-static int32_t imx074_i2c_write_b_sensor(unsigned short waddr, uint8_t bdata)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[3];
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00) >> 8;
-	buf[1] = (waddr & 0x00FF);
-	buf[2] = bdata;
-	CDBG("i2c_write_b addr = 0x%x, val = 0x%x\n", waddr, bdata);
-	rc = imx074_i2c_txdata(imx074_client->addr, buf, 3);
-	if (rc < 0) {
-		CDBG("i2c_write_b failed, addr = 0x%x, val = 0x%x!\n",
-			waddr, bdata);
-	}
-	return rc;
-}
-static int16_t imx074_i2c_write_b_af(unsigned short saddr,
-	unsigned short baddr, unsigned short bdata)
-{
-	int32_t rc;
-	unsigned char buf[2];
-	memset(buf, 0, sizeof(buf));
-	buf[0] = baddr;
-	buf[1] = bdata;
-	rc = imx074_i2c_txdata(saddr, buf, 2);
-	if (rc < 0)
-		CDBG("AFi2c_write failed, saddr = 0x%x addr = 0x%x, val =0x%x!",
-			saddr, baddr, bdata);
-	return rc;
-}
-
-static int32_t imx074_i2c_write_w_table(struct imx074_i2c_reg_conf const
-					 *reg_conf_tbl, int num)
-{
-	int i;
-	int32_t rc = -EIO;
-	for (i = 0; i < num; i++) {
-		rc = imx074_i2c_write_b_sensor(reg_conf_tbl->waddr,
-			reg_conf_tbl->wdata);
-		if (rc < 0)
-			break;
-		reg_conf_tbl++;
-	}
-	return rc;
-}
-static int16_t imx074_af_init(void)
-{
-	int32_t rc;
-	/* Initialize waveform */
-	rc = imx074_i2c_write_b_af(IMX074_AF_I2C_SLAVE_ID, 0x01, 0xA9);
-	rc = imx074_i2c_write_b_af(IMX074_AF_I2C_SLAVE_ID, 0x02, 0xD2);
-	rc = imx074_i2c_write_b_af(IMX074_AF_I2C_SLAVE_ID, 0x03, 0x0C);
-	rc = imx074_i2c_write_b_af(IMX074_AF_I2C_SLAVE_ID, 0x04, 0x14);
-	rc = imx074_i2c_write_b_af(IMX074_AF_I2C_SLAVE_ID, 0x05, 0xB6);
-	rc = imx074_i2c_write_b_af(IMX074_AF_I2C_SLAVE_ID, 0x06, 0x4F);
-	return rc;
-}
-
-static void imx074_get_pict_fps(uint16_t fps, uint16_t *pfps)
-{
-	/* input fps is preview fps in Q8 format */
-	uint16_t preview_frame_length_lines, snapshot_frame_length_lines;
-	uint32_t divider, d1;
-	uint32_t pclk_mult;/*Q10 */
-	/* Total frame_length_lines and line_length_pck for preview */
-	preview_frame_length_lines = IMX074_QTR_SIZE_HEIGHT +
-		IMX074_VER_QTR_BLK_LINES;
-	/* Total frame_length_lines and line_length_pck for snapshot */
-	snapshot_frame_length_lines = IMX074_FULL_SIZE_HEIGHT +
-		IMX074_VER_FULL_BLK_LINES;
-	d1 = preview_frame_length_lines * 0x00010000 /
-		snapshot_frame_length_lines;
-	pclk_mult =
-		(uint32_t) ((imx074_regs.reg_pat[RES_CAPTURE].pll_multiplier *
-		0x00010000) /
-		(imx074_regs.reg_pat[RES_PREVIEW].pll_multiplier));
-	divider = d1 * pclk_mult / 0x00010000;
-	*pfps = (uint16_t) (fps * divider / 0x00010000);
-}
-
-static uint16_t imx074_get_prev_lines_pf(void)
-{
-	if (imx074_ctrl->prev_res == QTR_SIZE)
-		return IMX074_QTR_SIZE_HEIGHT + IMX074_VER_QTR_BLK_LINES;
-	else
-		return IMX074_FULL_SIZE_HEIGHT + IMX074_VER_FULL_BLK_LINES;
-
-}
-
-static uint16_t imx074_get_prev_pixels_pl(void)
-{
-	if (imx074_ctrl->prev_res == QTR_SIZE)
-		return IMX074_QTR_SIZE_WIDTH + IMX074_HRZ_QTR_BLK_PIXELS;
-	else
-		return IMX074_FULL_SIZE_WIDTH + IMX074_HRZ_FULL_BLK_PIXELS;
-}
-
-static uint16_t imx074_get_pict_lines_pf(void)
-{
-		if (imx074_ctrl->pict_res == QTR_SIZE)
-			return IMX074_QTR_SIZE_HEIGHT +
-				IMX074_VER_QTR_BLK_LINES;
-		else
-			return IMX074_FULL_SIZE_HEIGHT +
-				IMX074_VER_FULL_BLK_LINES;
-}
-
-static uint16_t imx074_get_pict_pixels_pl(void)
-{
-	if (imx074_ctrl->pict_res == QTR_SIZE)
-		return IMX074_QTR_SIZE_WIDTH +
-			IMX074_HRZ_QTR_BLK_PIXELS;
-	else
-		return IMX074_FULL_SIZE_WIDTH +
-			IMX074_HRZ_FULL_BLK_PIXELS;
-}
-
-static uint32_t imx074_get_pict_max_exp_lc(void)
-{
-	if (imx074_ctrl->pict_res == QTR_SIZE)
-		return (IMX074_QTR_SIZE_HEIGHT +
-			IMX074_VER_QTR_BLK_LINES)*24;
-	else
-		return (IMX074_FULL_SIZE_HEIGHT +
-			IMX074_VER_FULL_BLK_LINES)*24;
-}
-
-static int32_t imx074_set_fps(struct fps_cfg	*fps)
-{
-	uint16_t total_lines_per_frame;
-	int32_t rc = 0;
-	imx074_ctrl->fps_divider = fps->fps_div;
-	imx074_ctrl->pict_fps_divider = fps->pict_fps_div;
-	if (imx074_ctrl->curr_res  == QTR_SIZE) {
-		total_lines_per_frame = (uint16_t)(((IMX074_QTR_SIZE_HEIGHT +
-			IMX074_VER_QTR_BLK_LINES) *
-			imx074_ctrl->fps_divider) / 0x400);
-	} else {
-		total_lines_per_frame = (uint16_t)(((IMX074_FULL_SIZE_HEIGHT +
-			IMX074_VER_FULL_BLK_LINES) *
-			imx074_ctrl->pict_fps_divider) / 0x400);
-	}
-	if (imx074_i2c_write_b_sensor(REG_FRAME_LENGTH_LINES_HI,
-		((total_lines_per_frame & 0xFF00) >> 8)) < 0)
-		return rc;
-	if (imx074_i2c_write_b_sensor(REG_FRAME_LENGTH_LINES_LO,
-		(total_lines_per_frame & 0x00FF)) < 0)
-		return rc;
-	return rc;
-}
-
-static int32_t imx074_write_exp_gain(uint16_t gain, uint32_t line)
-{
-	static uint16_t max_legal_gain = 0x00E0;
-	uint8_t gain_msb, gain_lsb;
-	uint8_t intg_time_msb, intg_time_lsb;
-	uint8_t frame_length_line_msb, frame_length_line_lsb;
-	uint16_t frame_length_lines;
-	int32_t rc = -1;
-
-	CDBG("imx074_write_exp_gain : gain = %d line = %d", gain, line);
-	if (imx074_ctrl->curr_res  == QTR_SIZE) {
-		frame_length_lines = IMX074_QTR_SIZE_HEIGHT +
-			IMX074_VER_QTR_BLK_LINES;
-		frame_length_lines = frame_length_lines *
-			imx074_ctrl->fps_divider / 0x400;
-	} else {
-		frame_length_lines = IMX074_FULL_SIZE_HEIGHT +
-			IMX074_VER_FULL_BLK_LINES;
-		frame_length_lines = frame_length_lines *
-			imx074_ctrl->pict_fps_divider / 0x400;
-	}
-	if (line > (frame_length_lines - IMX074_OFFSET))
-		frame_length_lines = line + IMX074_OFFSET;
-
-	CDBG("imx074 setting line = %d\n", line);
-
-
-	CDBG("imx074 setting frame_length_lines = %d\n",
-					frame_length_lines);
-
-	if (gain > max_legal_gain)
-		/* range: 0 to 224 */
-		gain = max_legal_gain;
-
-	/* update gain registers */
-	gain_msb = (uint8_t) ((gain & 0xFF00) >> 8);
-	gain_lsb = (uint8_t) (gain & 0x00FF);
-
-	frame_length_line_msb = (uint8_t) ((frame_length_lines & 0xFF00) >> 8);
-	frame_length_line_lsb = (uint8_t) (frame_length_lines & 0x00FF);
-
-	/* update line count registers */
-	intg_time_msb = (uint8_t) ((line & 0xFF00) >> 8);
-	intg_time_lsb = (uint8_t) (line & 0x00FF);
-
-	rc = imx074_i2c_write_b_sensor(REG_GROUPED_PARAMETER_HOLD,
-					GROUPED_PARAMETER_HOLD);
-	if (rc < 0)
-		return rc;
-	CDBG("imx074 setting REG_ANALOGUE_GAIN_CODE_GLOBAL_HI = 0x%X\n",
-					gain_msb);
-	rc = imx074_i2c_write_b_sensor(REG_ANALOGUE_GAIN_CODE_GLOBAL_HI,
-					gain_msb);
-	if (rc < 0)
-		return rc;
-	CDBG("imx074 setting REG_ANALOGUE_GAIN_CODE_GLOBAL_LO = 0x%X\n",
-					gain_lsb);
-	rc = imx074_i2c_write_b_sensor(REG_ANALOGUE_GAIN_CODE_GLOBAL_LO,
-					gain_lsb);
-	if (rc < 0)
-		return rc;
-
-	CDBG("imx074 setting REG_FRAME_LENGTH_LINES_HI = 0x%X\n",
-					frame_length_line_msb);
-	rc = imx074_i2c_write_b_sensor(REG_FRAME_LENGTH_LINES_HI,
-			frame_length_line_msb);
-	if (rc < 0)
-		return rc;
-
-	CDBG("imx074 setting REG_FRAME_LENGTH_LINES_LO = 0x%X\n",
-			frame_length_line_lsb);
-	rc = imx074_i2c_write_b_sensor(REG_FRAME_LENGTH_LINES_LO,
-			frame_length_line_lsb);
-	if (rc < 0)
-		return rc;
-
-	CDBG("imx074 setting REG_COARSE_INTEGRATION_TIME_HI = 0x%X\n",
-					intg_time_msb);
-	rc = imx074_i2c_write_b_sensor(REG_COARSE_INTEGRATION_TIME_HI,
-					intg_time_msb);
-	if (rc < 0)
-		return rc;
-
-	CDBG("imx074 setting REG_COARSE_INTEGRATION_TIME_LO = 0x%X\n",
-					intg_time_lsb);
-	rc = imx074_i2c_write_b_sensor(REG_COARSE_INTEGRATION_TIME_LO,
-					intg_time_lsb);
-	if (rc < 0)
-		return rc;
-
-	rc = imx074_i2c_write_b_sensor(REG_GROUPED_PARAMETER_HOLD,
-					GROUPED_PARAMETER_HOLD_OFF);
-	if (rc < 0)
-		return rc;
-
-	return rc;
-}
-
-static int32_t imx074_set_pict_exp_gain(uint16_t gain, uint32_t line)
-{
-	int32_t rc = 0;
-	rc = imx074_write_exp_gain(gain, line);
-	return rc;
-}
-
-static int32_t imx074_move_focus(int direction,
-	int32_t num_steps)
-{
-	int32_t step_direction, dest_step_position, bit_mask;
-	int32_t rc = 0;
-
-	if (num_steps == 0)
-		return rc;
-
-	if (direction == MOVE_NEAR) {
-		step_direction = 1;
-		bit_mask = 0x80;
-	} else if (direction == MOVE_FAR) {
-		step_direction = -1;
-		bit_mask = 0x00;
-	} else {
-		CDBG("imx074_move_focus: Illegal focus direction");
-		return -EINVAL;
-	}
-	dest_step_position = imx074_ctrl->curr_step_pos +
-		(step_direction * num_steps);
-	if (dest_step_position < 0)
-		dest_step_position = 0;
-	else if (dest_step_position > IMX074_TOTAL_STEPS_NEAR_TO_FAR)
-		dest_step_position = IMX074_TOTAL_STEPS_NEAR_TO_FAR;
-	rc = imx074_i2c_write_b_af(IMX074_AF_I2C_SLAVE_ID, 0x00,
-		((num_steps * imx074_l_region_code_per_step) | bit_mask));
-	CDBG("%s: Index: %d\n", __func__, dest_step_position);
-	imx074_ctrl->curr_step_pos = dest_step_position;
-	return rc;
-}
-
-
-static int32_t imx074_set_default_focus(uint8_t af_step)
-{
-	int32_t rc;
-	/* Initialize to infinity */
-	rc = imx074_i2c_write_b_af(IMX074_AF_I2C_SLAVE_ID, 0x00, 0x7F);
-	rc = imx074_i2c_write_b_af(IMX074_AF_I2C_SLAVE_ID, 0x00, 0x7F);
-	imx074_ctrl->curr_step_pos = 0;
-	return rc;
-}
-static int32_t imx074_test(enum imx074_test_mode_t mo)
-{
-	int32_t rc = 0;
-	if (mo == TEST_OFF)
-		return rc;
-	else {
-		/* Set mo to 2 inorder to enable test pattern*/
-		if (imx074_i2c_write_b_sensor(REG_TEST_PATTERN_MODE,
-			(uint8_t) mo) < 0) {
-			return rc;
-		}
-	}
-	return rc;
-}
-static int32_t imx074_sensor_setting(int update_type, int rt)
-{
-	int32_t rc = 0;
-	struct msm_camera_csi_params imx074_csi_params;
-	switch (update_type) {
-	case REG_INIT:
-		if (rt == RES_PREVIEW || rt == RES_CAPTURE) {
-			struct imx074_i2c_reg_conf init_tbl[] = {
-				{REG_PRE_PLL_CLK_DIV,
-					imx074_regs.reg_pat_init[0].
-					pre_pll_clk_div},
-				{REG_PLSTATIM,
-					imx074_regs.reg_pat_init[0].
-					plstatim},
-				{REG_3024,
-					imx074_regs.reg_pat_init[0].
-					reg_3024},
-				{REG_IMAGE_ORIENTATION,
-					imx074_regs.reg_pat_init[0].
-					image_orientation},
-				{REG_VNDMY_ABLMGSHLMT,
-					imx074_regs.reg_pat_init[0].
-					vndmy_ablmgshlmt},
-				{REG_Y_OPBADDR_START_DI,
-					imx074_regs.reg_pat_init[0].
-					y_opbaddr_start_di},
-				{REG_3015,
-					imx074_regs.reg_pat_init[0].
-					reg_0x3015},
-				{REG_301C,
-					imx074_regs.reg_pat_init[0].
-					reg_0x301c},
-				{REG_302C,
-					imx074_regs.reg_pat_init[0].
-					reg_0x302c},
-				{REG_3031,
-					imx074_regs.reg_pat_init[0].reg_0x3031},
-				{REG_3041,
-					imx074_regs.reg_pat_init[0].reg_0x3041},
-				{REG_3051,
-					imx074_regs.reg_pat_init[0].reg_0x3051},
-				{REG_3053,
-					imx074_regs.reg_pat_init[0].reg_0x3053},
-				{REG_3057,
-					imx074_regs.reg_pat_init[0].reg_0x3057},
-				{REG_305C,
-					imx074_regs.reg_pat_init[0].reg_0x305c},
-				{REG_305D,
-					imx074_regs.reg_pat_init[0].reg_0x305d},
-				{REG_3060,
-					imx074_regs.reg_pat_init[0].reg_0x3060},
-				{REG_3065,
-					imx074_regs.reg_pat_init[0].reg_0x3065},
-				{REG_30AA,
-					imx074_regs.reg_pat_init[0].reg_0x30aa},
-				{REG_30AB,
-					imx074_regs.reg_pat_init[0].reg_0x30ab},
-				{REG_30B0,
-					imx074_regs.reg_pat_init[0].reg_0x30b0},
-				{REG_30B2,
-					imx074_regs.reg_pat_init[0].reg_0x30b2},
-				{REG_30D3,
-					imx074_regs.reg_pat_init[0].reg_0x30d3},
-				{REG_3106,
-					imx074_regs.reg_pat_init[0].reg_0x3106},
-				{REG_310C,
-					imx074_regs.reg_pat_init[0].reg_0x310c},
-				{REG_3304,
-					imx074_regs.reg_pat_init[0].reg_0x3304},
-				{REG_3305,
-					imx074_regs.reg_pat_init[0].reg_0x3305},
-				{REG_3306,
-					imx074_regs.reg_pat_init[0].reg_0x3306},
-				{REG_3307,
-					imx074_regs.reg_pat_init[0].reg_0x3307},
-				{REG_3308,
-					imx074_regs.reg_pat_init[0].reg_0x3308},
-				{REG_3309,
-					imx074_regs.reg_pat_init[0].reg_0x3309},
-				{REG_330A,
-					imx074_regs.reg_pat_init[0].reg_0x330a},
-				{REG_330B,
-					imx074_regs.reg_pat_init[0].reg_0x330b},
-				{REG_330C,
-					imx074_regs.reg_pat_init[0].reg_0x330c},
-				{REG_330D,
-					imx074_regs.reg_pat_init[0].reg_0x330d},
-				{REG_330F,
-					imx074_regs.reg_pat_init[0].reg_0x330f},
-				{REG_3381,
-					imx074_regs.reg_pat_init[0].reg_0x3381},
-			};
-			struct imx074_i2c_reg_conf init_mode_tbl[] = {
-				{REG_GROUPED_PARAMETER_HOLD,
-					GROUPED_PARAMETER_HOLD},
-				{REG_PLL_MULTIPLIER,
-					imx074_regs.reg_pat[rt].
-					pll_multiplier},
-				{REG_FRAME_LENGTH_LINES_HI,
-					imx074_regs.reg_pat[rt].
-					frame_length_lines_hi},
-				{REG_FRAME_LENGTH_LINES_LO,
-					imx074_regs.reg_pat[rt].
-					frame_length_lines_lo},
-				{REG_YADDR_START ,
-					imx074_regs.reg_pat[rt].
-					y_addr_start},
-				{REG_YAAAR_END,
-					imx074_regs.reg_pat[rt].
-					y_add_end},
-				{REG_X_OUTPUT_SIZE_MSB,
-					imx074_regs.reg_pat[rt].
-					x_output_size_msb},
-				{REG_X_OUTPUT_SIZE_LSB,
-					imx074_regs.reg_pat[rt].
-					x_output_size_lsb},
-				{REG_Y_OUTPUT_SIZE_MSB,
-					imx074_regs.reg_pat[rt].
-					y_output_size_msb},
-				{REG_Y_OUTPUT_SIZE_LSB ,
-					imx074_regs.reg_pat[rt].
-					y_output_size_lsb},
-				{REG_X_EVEN_INC,
-					imx074_regs.reg_pat[rt].
-					x_even_inc},
-				{REG_X_ODD_INC,
-					imx074_regs.reg_pat[rt].
-					x_odd_inc},
-				{REG_Y_EVEN_INC,
-					imx074_regs.reg_pat[rt].
-					y_even_inc},
-				{REG_Y_ODD_INC,
-					imx074_regs.reg_pat[rt].
-					y_odd_inc},
-				{REG_HMODEADD,
-					imx074_regs.reg_pat[rt].
-					hmodeadd},
-				{REG_VMODEADD,
-					imx074_regs.reg_pat[rt].
-					vmodeadd},
-				{REG_VAPPLINE_START,
-					imx074_regs.reg_pat[rt].
-					vapplinepos_start},
-				{REG_VAPPLINE_END,
-					imx074_regs.reg_pat[rt].
-					vapplinepos_end},
-				{REG_SHUTTER,
-					imx074_regs.reg_pat[rt].
-					shutter},
-				{REG_HADDAVE,
-					imx074_regs.reg_pat[rt].
-					haddave},
-				{REG_LANESEL,
-					imx074_regs.reg_pat[rt].
-					lanesel},
-				{REG_GROUPED_PARAMETER_HOLD,
-					GROUPED_PARAMETER_HOLD_OFF},
-
-			};
-			/* reset fps_divider */
-			imx074_ctrl->fps = 30 * Q8;
-			imx074_ctrl->fps_divider = 1 * 0x400;
-			/* stop streaming */
-			rc = imx074_i2c_write_b_sensor(REG_MODE_SELECT,
-				MODE_SELECT_STANDBY_MODE);
-			if (rc < 0)
-				return rc;
-			msleep(imx074_delay_msecs_stdby);
-			rc = imx074_i2c_write_w_table(&init_tbl[0],
-				ARRAY_SIZE(init_tbl));
-			if (rc < 0)
-				return rc;
-			rc = imx074_i2c_write_w_table(&init_mode_tbl[0],
-				ARRAY_SIZE(init_mode_tbl));
-			if (rc < 0)
-				return rc;
-			rc = imx074_test(imx074_ctrl->set_test);
-			return rc;
-		}
-		break;
-	case UPDATE_PERIODIC:
-		if (rt == RES_PREVIEW || rt == RES_CAPTURE) {
-			struct imx074_i2c_reg_conf mode_tbl[] = {
-				{REG_GROUPED_PARAMETER_HOLD,
-					GROUPED_PARAMETER_HOLD},
-				{REG_PLL_MULTIPLIER,
-					imx074_regs.reg_pat[rt].
-					pll_multiplier},
-				{REG_FRAME_LENGTH_LINES_HI,
-					imx074_regs.reg_pat[rt].
-					frame_length_lines_hi},
-				{REG_FRAME_LENGTH_LINES_LO,
-					imx074_regs.reg_pat[rt].
-					frame_length_lines_lo},
-				{REG_YADDR_START ,
-					imx074_regs.reg_pat[rt].
-					y_addr_start},
-				{REG_YAAAR_END,
-					imx074_regs.reg_pat[rt].
-					y_add_end},
-				{REG_X_OUTPUT_SIZE_MSB,
-					imx074_regs.reg_pat[rt].
-					x_output_size_msb},
-				{REG_X_OUTPUT_SIZE_LSB,
-					imx074_regs.reg_pat[rt].
-					x_output_size_lsb},
-				{REG_Y_OUTPUT_SIZE_MSB,
-					imx074_regs.reg_pat[rt].
-					y_output_size_msb},
-				{REG_Y_OUTPUT_SIZE_LSB ,
-					imx074_regs.reg_pat[rt].
-					y_output_size_lsb},
-				{REG_X_EVEN_INC,
-					imx074_regs.reg_pat[rt].
-					x_even_inc},
-				{REG_X_ODD_INC,
-					imx074_regs.reg_pat[rt].
-					x_odd_inc},
-				{REG_Y_EVEN_INC,
-					imx074_regs.reg_pat[rt].
-					y_even_inc},
-				{REG_Y_ODD_INC,
-					imx074_regs.reg_pat[rt].
-					y_odd_inc},
-				{REG_HMODEADD,
-					imx074_regs.reg_pat[rt].
-					hmodeadd},
-				{REG_VMODEADD,
-					imx074_regs.reg_pat[rt].
-					vmodeadd},
-				{REG_VAPPLINE_START,
-					imx074_regs.reg_pat[rt].
-					vapplinepos_start},
-				{REG_VAPPLINE_END,
-					imx074_regs.reg_pat[rt].
-					vapplinepos_end},
-				{REG_SHUTTER,
-					imx074_regs.reg_pat[rt].
-					shutter},
-				{REG_HADDAVE,
-					imx074_regs.reg_pat[rt].
-					haddave},
-				{REG_LANESEL,
-					imx074_regs.reg_pat[rt].
-					lanesel},
-				{REG_GROUPED_PARAMETER_HOLD,
-					GROUPED_PARAMETER_HOLD_OFF},
-			};
-
-			/* stop streaming */
-			rc = imx074_i2c_write_b_sensor(REG_MODE_SELECT,
-				MODE_SELECT_STANDBY_MODE);
-			msleep(imx074_delay_msecs_stdby);
-			if (config_csi == 0) {
-				imx074_csi_params.lane_cnt = 4;
-				imx074_csi_params.data_format = CSI_10BIT;
-				imx074_csi_params.lane_assign = 0xe4;
-				imx074_csi_params.dpcm_scheme = 0;
-				imx074_csi_params.settle_cnt = 0x14;
-				rc = msm_camio_csi_config(&imx074_csi_params);
-				/*imx074_delay_msecs_stdby*/
-				msleep(imx074_delay_msecs_stream);
-				config_csi = 1;
-			}
-			rc = imx074_i2c_write_w_table(&mode_tbl[0],
-				ARRAY_SIZE(mode_tbl));
-			if (rc < 0)
-				return rc;
-			rc = imx074_i2c_write_b_sensor(REG_MODE_SELECT,
-				MODE_SELECT_STREAM);
-			if (rc < 0)
-				return rc;
-			msleep(imx074_delay_msecs_stream);
-		}
-		break;
-	default:
-		rc = -EINVAL;
-		break;
-	}
-
-	return rc;
-}
-
-
-static int32_t imx074_video_config(int mode)
-{
-
-	int32_t	rc = 0;
-	int	rt;
-	/* change sensor resolution	if needed */
-	if (imx074_ctrl->prev_res == QTR_SIZE) {
-		rt = RES_PREVIEW;
-	} else {
-		rt = RES_CAPTURE;
-	}
-	if (imx074_sensor_setting(UPDATE_PERIODIC, rt) < 0)
-		return rc;
-	imx074_ctrl->curr_res = imx074_ctrl->prev_res;
-	imx074_ctrl->sensormode = mode;
-	return rc;
-}
-
-static int32_t imx074_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-	int rt = RES_PREVIEW; /* TODO: Used without initialization, guessing. */
-	/* change sensor resolution if needed */
-	if (imx074_ctrl->curr_res != imx074_ctrl->pict_res) {
-		if (imx074_ctrl->pict_res == QTR_SIZE) {
-			rt = RES_PREVIEW;
-		} else {
-			rt = RES_CAPTURE;
-		}
-	}
-	if (imx074_sensor_setting(UPDATE_PERIODIC, rt) < 0)
-		return rc;
-	imx074_ctrl->curr_res = imx074_ctrl->pict_res;
-	imx074_ctrl->sensormode = mode;
-	return rc;
-}
-static int32_t imx074_raw_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-	int rt = RES_PREVIEW; /* TODO: Used without initialization, guessing. */
-	/* change sensor resolution if needed */
-	if (imx074_ctrl->curr_res != imx074_ctrl->pict_res) {
-		if (imx074_ctrl->pict_res == QTR_SIZE) {
-			rt = RES_PREVIEW;
-		} else {
-			rt = RES_CAPTURE;
-		}
-	}
-	if (imx074_sensor_setting(UPDATE_PERIODIC, rt) < 0)
-		return rc;
-	imx074_ctrl->curr_res = imx074_ctrl->pict_res;
-	imx074_ctrl->sensormode = mode;
-	return rc;
-}
-static int32_t imx074_set_sensor_mode(int mode,
-	int res)
-{
-	int32_t rc = 0;
-	switch (mode) {
-	case SENSOR_PREVIEW_MODE:
-		rc = imx074_video_config(mode);
-		break;
-	case SENSOR_SNAPSHOT_MODE:
-		rc = imx074_snapshot_config(mode);
-		break;
-	case SENSOR_RAW_SNAPSHOT_MODE:
-		rc = imx074_raw_snapshot_config(mode);
-		break;
-	default:
-		rc = -EINVAL;
-		break;
-	}
-	return rc;
-}
-static int32_t imx074_power_down(void)
-{
-	imx074_i2c_write_b_sensor(REG_MODE_SELECT,
-		MODE_SELECT_STANDBY_MODE);
-	msleep(imx074_delay_msecs_stdby);
-	return 0;
-}
-static int imx074_probe_init_done(const struct msm_camera_sensor_info *data)
-{
-	gpio_set_value_cansleep(data->sensor_reset, 0);
-	gpio_direction_input(data->sensor_reset);
-	gpio_free(data->sensor_reset);
-	return 0;
-}
-
-static int imx074_read_eeprom_data(struct sensor_cfg_data *cfg)
-{
-	int32_t rc = 0;
-	uint16_t eepromdata = 0;
-	uint8_t addr = 0;
-
-	addr = 0x10;
-	rc = imx074_i2c_read_w_eeprom(addr, &eepromdata);
-	if (rc < 0) {
-		CDBG("%s: Error Reading EEPROM @ 0x%x\n", __func__, addr);
-		return rc;
-	}
-	cfg->cfg.calib_info.r_over_g = eepromdata;
-
-	addr = 0x12;
-	rc = imx074_i2c_read_w_eeprom(addr, &eepromdata);
-	if (rc < 0) {
-		CDBG("%s: Error Reading EEPROM @ 0x%x\n", __func__, addr);
-		return rc;
-	}
-	cfg->cfg.calib_info.b_over_g = eepromdata;
-
-	addr = 0x14;
-	rc = imx074_i2c_read_w_eeprom(addr, &eepromdata);
-	if (rc < 0) {
-		CDBG("%s: Error Reading EEPROM @ 0x%x\n", __func__, addr);
-		return rc;
-	}
-	cfg->cfg.calib_info.gr_over_gb = eepromdata;
-
-	addr = 0x1A;
-	rc = imx074_i2c_read_w_eeprom(addr, &eepromdata);
-	if (rc < 0) {
-		CDBG("%s: Error Reading EEPROM @ 0x%x\n", __func__, addr);
-		return rc;
-	}
-	cfg->cfg.calib_info.macro_2_inf = eepromdata;
-
-	addr = 0x1C;
-	rc = imx074_i2c_read_w_eeprom(addr, &eepromdata);
-	if (rc < 0) {
-		CDBG("%s: Error Reading EEPROM @ 0x%x\n", __func__, addr);
-		return rc;
-	}
-	cfg->cfg.calib_info.inf_2_macro = eepromdata;
-
-	addr = 0x1E;
-	rc = imx074_i2c_read_w_eeprom(addr, &eepromdata);
-	if (rc < 0) {
-		CDBG("%s: Error Reading EEPROM @ 0x%x\n", __func__, addr);
-		return rc;
-	}
-	cfg->cfg.calib_info.stroke_amt = eepromdata;
-
-	addr = 0x20;
-	rc = imx074_i2c_read_w_eeprom(addr, &eepromdata);
-	if (rc < 0) {
-		CDBG("%s: Error Reading EEPROM @ 0x%x\n", __func__, addr);
-		return rc;
-	}
-	cfg->cfg.calib_info.af_pos_1m = eepromdata;
-
-	addr = 0x22;
-	rc = imx074_i2c_read_w_eeprom(addr, &eepromdata);
-	if (rc < 0) {
-		CDBG("%s: Error Reading EEPROM @ 0x%x\n", __func__, addr);
-		return rc;
-	}
-	cfg->cfg.calib_info.af_pos_inf = eepromdata;
-
-	return rc;
-}
-
-static int imx074_probe_init_sensor(const struct msm_camera_sensor_info *data)
-{
-	int32_t rc = 0;
-	unsigned short chipidl, chipidh;
-	CDBG("%s: %d\n", __func__, __LINE__);
-	rc = gpio_request(data->sensor_reset, "imx074");
-	CDBG(" imx074_probe_init_sensor \n");
-	if (!rc) {
-		CDBG("sensor_reset = %d\n", rc);
-		gpio_direction_output(data->sensor_reset, 0);
-		usleep_range(5000, 6000);
-		gpio_set_value_cansleep(data->sensor_reset, 1);
-		usleep_range(5000, 6000);
-	} else {
-		CDBG("gpio reset fail");
-		goto init_probe_done;
-	}
-	CDBG("imx074_probe_init_sensor is called\n");
-	/* 3. Read sensor Model ID: */
-	rc = imx074_i2c_read(0x0000, &chipidh, 1);
-	if (rc < 0) {
-		CDBG("Model read failed\n");
-		goto init_probe_fail;
-	}
-	rc = imx074_i2c_read(0x0001, &chipidl, 1);
-	if (rc < 0) {
-		CDBG("Model read failed\n");
-		goto init_probe_fail;
-	}
-	CDBG("imx074 model_id = 0x%x  0x%x\n", chipidh, chipidl);
-	/* 4. Compare sensor ID to IMX074 ID: */
-	if (chipidh != 0x00 || chipidl != 0x74) {
-		rc = -ENODEV;
-		CDBG("imx074_probe_init_sensor fail chip id doesnot match\n");
-		goto init_probe_fail;
-	}
-	goto init_probe_done;
-init_probe_fail:
-	CDBG("imx074_probe_init_sensor fails\n");
-	imx074_probe_init_done(data);
-init_probe_done:
-	CDBG(" imx074_probe_init_sensor finishes\n");
-	return rc;
-	}
-static int32_t imx074_poweron_af(void)
-{
-	int32_t rc = 0;
-	CDBG("imx074 enable AF actuator, gpio = %d\n",
-			imx074_ctrl->sensordata->vcm_pwd);
-	rc = gpio_request(imx074_ctrl->sensordata->vcm_pwd, "imx074");
-	if (!rc) {
-		gpio_direction_output(imx074_ctrl->sensordata->vcm_pwd, 1);
-		msleep(20);
-		rc = imx074_af_init();
-		if (rc < 0)
-			CDBG("imx074 AF initialisation failed\n");
-	} else {
-		CDBG("%s: AF PowerON gpio_request failed %d\n", __func__, rc);
-	 }
-	return rc;
-}
-static void imx074_poweroff_af(void)
-{
-	gpio_set_value_cansleep(imx074_ctrl->sensordata->vcm_pwd, 0);
-	gpio_free(imx074_ctrl->sensordata->vcm_pwd);
-}
-/* camsensor_iu060f_imx074_reset */
-int imx074_sensor_open_init(const struct msm_camera_sensor_info *data)
-{
-	int32_t rc = 0;
-	CDBG("%s: %d\n", __func__, __LINE__);
-	CDBG("Calling imx074_sensor_open_init\n");
-	imx074_ctrl = kzalloc(sizeof(struct imx074_ctrl_t), GFP_KERNEL);
-	if (!imx074_ctrl) {
-		CDBG("imx074_init failed!\n");
-		rc = -ENOMEM;
-		goto init_done;
-	}
-	imx074_ctrl->fps_divider = 1 * 0x00000400;
-	imx074_ctrl->pict_fps_divider = 1 * 0x00000400;
-	imx074_ctrl->fps = 30 * Q8;
-	imx074_ctrl->set_test = TEST_OFF;
-	imx074_ctrl->prev_res = QTR_SIZE;
-	imx074_ctrl->pict_res = FULL_SIZE;
-	imx074_ctrl->curr_res = INVALID_SIZE;
-	config_csi = 0;
-
-	if (data)
-		imx074_ctrl->sensordata = data;
-
-	/* enable mclk first */
-	msm_camio_clk_rate_set(IMX074_DEFAULT_MASTER_CLK_RATE);
-	usleep_range(1000, 2000);
-	rc = imx074_probe_init_sensor(data);
-	if (rc < 0) {
-		CDBG("Calling imx074_sensor_open_init fail\n");
-		goto probe_fail;
-	}
-
-	rc = imx074_sensor_setting(REG_INIT, RES_PREVIEW);
-	if (rc < 0) {
-		CDBG("imx074_sensor_setting failed\n");
-		goto init_fail;
-	}
-	if (machine_is_msm8x60_fluid())
-		rc = imx074_poweron_af();
-	else
-		rc = imx074_af_init();
-	if (rc < 0) {
-		CDBG("AF initialisation failed\n");
-		goto init_fail;
-	} else
-		goto init_done;
-probe_fail:
-	CDBG(" imx074_sensor_open_init probe fail\n");
-	kfree(imx074_ctrl);
-	return rc;
-init_fail:
-	CDBG(" imx074_sensor_open_init fail\n");
-	imx074_probe_init_done(data);
-	kfree(imx074_ctrl);
-init_done:
-	CDBG("imx074_sensor_open_init done\n");
-	return rc;
-}
-static int imx074_init_client(struct i2c_client *client)
-{
-	/* Initialize the MSM_CAMI2C Chip */
-	init_waitqueue_head(&imx074_wait_queue);
-	return 0;
-}
-
-static const struct i2c_device_id imx074_i2c_id[] = {
-	{"imx074", 0},
-	{ }
-};
-
-static int imx074_i2c_probe(struct i2c_client *client,
-	const struct i2c_device_id *id)
-{
-	int rc = 0;
-	CDBG("imx074_probe called!\n");
-
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		CDBG("i2c_check_functionality failed\n");
-		goto probe_failure;
-	}
-
-	imx074_sensorw = kzalloc(sizeof(struct imx074_work_t), GFP_KERNEL);
-	if (!imx074_sensorw) {
-		CDBG("kzalloc failed.\n");
-		rc = -ENOMEM;
-		goto probe_failure;
-	}
-
-	i2c_set_clientdata(client, imx074_sensorw);
-	imx074_init_client(client);
-	imx074_client = client;
-
-
-	CDBG("imx074_probe successed! rc = %d\n", rc);
-	return 0;
-
-probe_failure:
-	CDBG("imx074_probe failed! rc = %d\n", rc);
-	return rc;
-}
-
-static int __exit imx074_remove(struct i2c_client *client)
-{
-	struct imx074_work_t_t *sensorw = i2c_get_clientdata(client);
-	free_irq(client->irq, sensorw);
-	imx074_client = NULL;
-	kfree(sensorw);
-	return 0;
-}
-
-static struct i2c_driver imx074_i2c_driver = {
-	.id_table = imx074_i2c_id,
-	.probe  = imx074_i2c_probe,
-	.remove = __exit_p(imx074_i2c_remove),
-	.driver = {
-		.name = "imx074",
-	},
-};
-
-int imx074_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(&imx074_mut);
-	CDBG("imx074_sensor_config: cfgtype = %d\n",
-	cdata.cfgtype);
-	switch (cdata.cfgtype) {
-	case CFG_GET_PICT_FPS:
-		imx074_get_pict_fps(
-			cdata.cfg.gfps.prevfps,
-			&(cdata.cfg.gfps.pictfps));
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-			break;
-	case CFG_GET_PREV_L_PF:
-		cdata.cfg.prevl_pf =
-			imx074_get_prev_lines_pf();
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-			break;
-	case CFG_GET_PREV_P_PL:
-		cdata.cfg.prevp_pl =
-			imx074_get_prev_pixels_pl();
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-			break;
-
-	case CFG_GET_PICT_L_PF:
-		cdata.cfg.pictl_pf =
-			imx074_get_pict_lines_pf();
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-			break;
-	case CFG_GET_PICT_P_PL:
-		cdata.cfg.pictp_pl =
-			imx074_get_pict_pixels_pl();
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-			break;
-	case CFG_GET_PICT_MAX_EXP_LC:
-		cdata.cfg.pict_max_exp_lc =
-			imx074_get_pict_max_exp_lc();
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-			break;
-	case CFG_SET_FPS:
-	case CFG_SET_PICT_FPS:
-		rc = imx074_set_fps(&(cdata.cfg.fps));
-		break;
-	case CFG_SET_EXP_GAIN:
-		rc =
-			imx074_write_exp_gain(
-			cdata.cfg.exp_gain.gain,
-			cdata.cfg.exp_gain.line);
-			break;
-	case CFG_SET_PICT_EXP_GAIN:
-		rc =
-			imx074_set_pict_exp_gain(
-			cdata.cfg.exp_gain.gain,
-			cdata.cfg.exp_gain.line);
-			break;
-	case CFG_SET_MODE:
-		rc = imx074_set_sensor_mode(cdata.mode,
-			cdata.rs);
-			break;
-	case CFG_PWR_DOWN:
-		rc = imx074_power_down();
-			break;
-	case CFG_GET_CALIB_DATA:
-		rc = imx074_read_eeprom_data(&cdata);
-		if (rc < 0)
-			break;
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(cdata)))
-			rc = -EFAULT;
-		break;
-	case CFG_MOVE_FOCUS:
-		rc =
-			imx074_move_focus(
-			cdata.cfg.focus.dir,
-			cdata.cfg.focus.steps);
-			break;
-	case CFG_SET_DEFAULT_FOCUS:
-		rc =
-			imx074_set_default_focus(
-			cdata.cfg.focus.steps);
-			break;
-	case CFG_GET_AF_MAX_STEPS:
-		cdata.max_steps = IMX074_STEPS_NEAR_TO_CLOSEST_INF;
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-			break;
-	case CFG_SET_EFFECT:
-	default:
-		rc = -EFAULT;
-		break;
-	}
-
-	mutex_unlock(&imx074_mut);
-
-	return rc;
-}
-static int imx074_sensor_release(void)
-{
-	int rc = -EBADF;
-	mutex_lock(&imx074_mut);
-	if (machine_is_msm8x60_fluid())
-		imx074_poweroff_af();
-	imx074_power_down();
-	gpio_set_value_cansleep(imx074_ctrl->sensordata->sensor_reset, 0);
-	msleep(5);
-	gpio_direction_input(imx074_ctrl->sensordata->sensor_reset);
-	gpio_free(imx074_ctrl->sensordata->sensor_reset);
-	kfree(imx074_ctrl);
-	imx074_ctrl = NULL;
-	CDBG("imx074_release completed\n");
-	mutex_unlock(&imx074_mut);
-
-	return rc;
-}
-
-static int imx074_sensor_probe(const struct msm_camera_sensor_info *info,
-		struct msm_sensor_ctrl *s)
-{
-	int rc = 0;
-	rc = i2c_add_driver(&imx074_i2c_driver);
-	if (rc < 0 || imx074_client == NULL) {
-		rc = -ENOTSUPP;
-		goto probe_fail;
-	}
-	msm_camio_clk_rate_set(IMX074_DEFAULT_MASTER_CLK_RATE);
-	rc = imx074_probe_init_sensor(info);
-	if (rc < 0)
-		goto probe_fail;
-	s->s_init = imx074_sensor_open_init;
-	s->s_release = imx074_sensor_release;
-	s->s_config  = imx074_sensor_config;
-	s->s_mount_angle = info->sensor_platform_info->mount_angle;
-	imx074_probe_init_done(info);
-	return rc;
-
-probe_fail:
-	CDBG("imx074_sensor_probe: SENSOR PROBE FAILS!\n");
-	i2c_del_driver(&imx074_i2c_driver);
-	return rc;
-}
-
-static int __imx074_probe(struct platform_device *pdev)
-{
-
-	return msm_camera_drv_start(pdev, imx074_sensor_probe);
-}
-
-static struct platform_driver msm_camera_driver = {
-	.probe = __imx074_probe,
-	.driver = {
-		.name = "msm_camera_imx074",
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init imx074_init(void)
-{
-	return platform_driver_register(&msm_camera_driver);
-}
-
-module_init(imx074_init);
-
-MODULE_DESCRIPTION("Sony 13 MP Bayer sensor driver");
-MODULE_LICENSE("GPL v2");
-
diff --git a/drivers/media/platform/msm/camera_v1/imx074.h b/drivers/media/platform/msm/camera_v1/imx074.h
deleted file mode 100644
index 9468cb0..0000000
--- a/drivers/media/platform/msm/camera_v1/imx074.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/* Copyright (c) 2010, The Linux Foundation. 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.
- */
-
-#ifndef IMX074_H
-#define IMX074_H
-#include <linux/types.h>
-#include <mach/board.h>
-extern struct imx074_reg imx074_regs;
-struct reg_struct_init {
-    /* PLL setting */
-	uint8_t pre_pll_clk_div; /* 0x0305 */
-	uint8_t plstatim; /* 0x302b */
-	uint8_t reg_3024; /*ox3024*/
-	uint8_t image_orientation;  /* 0x0101*/
-	uint8_t vndmy_ablmgshlmt; /*0x300a*/
-	uint8_t y_opbaddr_start_di; /*0x3014*/
-	uint8_t reg_0x3015; /*0x3015*/
-	uint8_t reg_0x301c; /*0x301c*/
-	uint8_t reg_0x302c; /*0x302c*/
-	uint8_t reg_0x3031; /*0x3031*/
-	uint8_t reg_0x3041; /* 0x3041 */
-	uint8_t reg_0x3051; /* 0x3051 */
-	uint8_t reg_0x3053; /* 0x3053 */
-	uint8_t reg_0x3057; /* 0x3057 */
-	uint8_t reg_0x305c; /* 0x305c */
-	uint8_t reg_0x305d; /* 0x305d */
-	uint8_t reg_0x3060; /* 0x3060 */
-	uint8_t reg_0x3065; /* 0x3065 */
-	uint8_t reg_0x30aa; /* 0x30aa */
-	uint8_t reg_0x30ab;
-	uint8_t reg_0x30b0;
-	uint8_t reg_0x30b2;
-	uint8_t reg_0x30d3;
-	uint8_t reg_0x3106;
-	uint8_t reg_0x310c;
-	uint8_t reg_0x3304;
-	uint8_t reg_0x3305;
-	uint8_t reg_0x3306;
-	uint8_t reg_0x3307;
-	uint8_t reg_0x3308;
-	uint8_t reg_0x3309;
-	uint8_t reg_0x330a;
-	uint8_t reg_0x330b;
-	uint8_t reg_0x330c;
-	uint8_t reg_0x330d;
-	uint8_t reg_0x330f;
-	uint8_t reg_0x3381;
-};
-
-struct reg_struct {
-	uint8_t pll_multiplier; /* 0x0307 */
-	uint8_t frame_length_lines_hi; /* 0x0340*/
-	uint8_t frame_length_lines_lo; /* 0x0341*/
-	uint8_t y_addr_start;  /* 0x347 */
-	uint8_t y_add_end;  /* 0x034b */
-	uint8_t x_output_size_msb;  /* 0x034c */
-	uint8_t x_output_size_lsb;  /* 0x034d */
-	uint8_t y_output_size_msb; /* 0x034e */
-	uint8_t y_output_size_lsb; /* 0x034f */
-	uint8_t x_even_inc;  /* 0x0381 */
-	uint8_t x_odd_inc; /* 0x0383 */
-	uint8_t y_even_inc;  /* 0x0385 */
-	uint8_t y_odd_inc; /* 0x0387 */
-	uint8_t hmodeadd;   /* 0x3001 */
-	uint8_t vmodeadd;   /* 0x3016 */
-	uint8_t vapplinepos_start;/*ox3069*/
-	uint8_t vapplinepos_end;/*306b*/
-	uint8_t shutter;	/* 0x3086 */
-	uint8_t haddave;	/* 0x30e8 */
-	uint8_t lanesel;    /* 0x3301 */
-};
-
-struct imx074_i2c_reg_conf {
-	unsigned short waddr;
-	unsigned short wdata;
-};
-
-enum imx074_test_mode_t {
-	TEST_OFF,
-	TEST_1,
-	TEST_2,
-	TEST_3
-};
-
-enum imx074_resolution_t {
-	QTR_SIZE,
-	FULL_SIZE,
-	INVALID_SIZE
-};
-enum imx074_setting {
-	RES_PREVIEW,
-	RES_CAPTURE
-};
-enum mt9p012_reg_update {
-	/* Sensor egisters that need to be updated during initialization */
-	REG_INIT,
-	/* Sensor egisters that needs periodic I2C writes */
-	UPDATE_PERIODIC,
-	/* All the sensor Registers will be updated */
-	UPDATE_ALL,
-	/* Not valid update */
-	UPDATE_INVALID
-};
-
-struct imx074_reg {
-	const struct reg_struct_init  *reg_pat_init;
-	const struct reg_struct  *reg_pat;
-};
-#endif /* IMX074_H */
diff --git a/drivers/media/platform/msm/camera_v1/imx074_reg.c b/drivers/media/platform/msm/camera_v1/imx074_reg.c
deleted file mode 100644
index a9d19f2..0000000
--- a/drivers/media/platform/msm/camera_v1/imx074_reg.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/* Copyright (c) 2010, The Linux Foundation. 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.
- */
-
-#include "imx074.h"
-const struct reg_struct_init imx074_reg_init[1] = {
-	{
-		/* PLL setting */
-		0x02,	/* pll_divider 0x0305 */
-		0x4B,	/* plstatim 0x302b */
-		0x03,	/* reg_3024 */
-		0x00,	/* image_orientation 0x0101 */
-		0x80,	/* vndmy_ablmgshlmt 0x300a*/
-		0x08,	/* y_opbaddr_start_di 3014*/
-		0x37,	/* 0x3015*/
-		0x01,	/* 0x301c*/
-		0x05,	/* 0x302c*/
-		0x26,	/* 0x3031*/
-		0x60,	/* 0x3041*/
-		0x24,	/* 0x3051 CLK DIV*/
-		0x34,	/* 0x3053*/
-		0xc0,	/* 0x3057*/
-		0x09,	/* 0x305c*/
-		0x07,	/* 0x305d */
-		0x30,	/* 0x3060 */
-		0x00,	/* 0x3065 */
-		0x08,	/* 0x30aa */
-		0x1c,	/* 0x30ab */
-		0x32,	/* 0x30b0 */
-		0x83,	/* 0x30b2 */
-		0x04,	/* 0x30d3 */
-		0x78,	/* 0x3106 */
-		0x82,	/* 0x310c */
-		0x05,	/* 0x3304 */
-		0x04,	/* 0x3305 */
-		0x11,	/* 0x3306 */
-		0x02,	/* 0x3307 */
-		0x0c,	/* 0x3308 */
-		0x06,	/* 0x3309 */
-		0x08,	/* 0x330a */
-		0x04,	/* 0x330b */
-		0x08,	/* 0x330c */
-		0x06,	/* 0x330d */
-		0x01,	/* 0x330f */
-		0x00,	/* 0x3381 */
-
-	}
-};
-
-/* Preview / Snapshot register settings	*/
-const struct reg_struct	imx074_reg_pat[2] = {
-	/*preview*/
-	{
-		0x2D, /*pll_multiplier*/
-		0x06, /*frame_length_lines_hi 0x0340*/
-		0x2D, /* frame_length_lines_lo 0x0341*/
-		0x00, /* y_addr_start 0x347 */
-		0x2F, /* y_add_end 0x034b */
-		0x08, /* x_output_size_msb0x034c */
-		0x38, /* x_output_size_lsb0x034d */
-		0x06, /*  y_output_size_msb0x034e */
-		0x18, /*  y_output_size_lsb0x034f */
-		0x01, /* x_even_inc 0x0381 */
-		0x03, /* x_odd_inc 0x0383 */
-		0x01, /* y_even_inc 0x0385 */
-		0x03, /* y_odd_inc 0x0387 */
-		0x80, /* hmodeadd0x3001 */
-		0x16, /* vmodeadd0x3016 */
-		0x24, /* vapplinepos_startox3069*/
-		0x53, /* vapplinepos_end306b*/
-		0x00,/*  shutter 0x3086 */
-		0x80, /* haddave 0x30e8 */
-		0x83, /* lanesel 0x3301 */
-	},
-
-	/*snapshot*/
-	{
-		0x26, /*pll_multiplier*/
-		0x0C, /* frame_length_lines_hi 0x0340*/
-		0x90, /* frame_length_lines_lo 0x0341*/
-		0x00, /* y_addr_start 0x347 */
-		0x2F, /* y_add_end 0x034b */
-		0x10, /* x_output_size_msb0x034c */
-		0x70, /* x_output_size_lsb0x034d */
-		0x0c, /* y_output_size_msb0x034e */
-		0x30, /* y_output_size_lsb0x034f */
-		0x01, /* x_even_inc 0x0381 */
-		0x01, /* x_odd_inc 0x0383 */
-		0x01, /* y_even_inc 0x0385 */
-		0x01, /* y_odd_inc 0x0387 */
-		0x00, /* hmodeadd0x3001 */
-		0x06, /* vmodeadd0x3016 */
-		0x24, /* vapplinepos_startox3069*/
-		0x53, /* vapplinepos_end306b*/
-		0x00, /* shutter 0x3086 */
-		0x00, /* haddave 0x30e8 */
-		0x03, /* lanesel 0x3301 */
-	}
-};
-struct imx074_reg imx074_regs = {
-	.reg_pat_init = &imx074_reg_init[0],
-	.reg_pat = &imx074_reg_pat[0],
-};
diff --git a/drivers/media/platform/msm/camera_v1/io/Makefile b/drivers/media/platform/msm/camera_v1/io/Makefile
deleted file mode 100644
index 9ec119c..0000000
--- a/drivers/media/platform/msm/camera_v1/io/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-GCC_VERSION      := $(shell $(CONFIG_SHELL) $(PWD)/scripts/gcc-version.sh $(CROSS_COMPILE)gcc)
-
-ccflags-y += -Idrivers/media/platform/msm/camera_v1 -Idrivers/media/platform/msm/camera_v1/cci
-obj-$(CONFIG_MSM_CAMERA)   += msm_camera_io_util.o msm_camera_i2c.o
-ifeq ($(CONFIG_MSM_CAMERA_V4L2),y)
-  obj-$(CONFIG_MSM_CAMERA) += msm_camera_i2c_mux.o
-  obj-$(CONFIG_ARCH_MSM7X27A) += msm_io_7x27a_v4l2.o
-  obj-$(CONFIG_ARCH_MSM8X60) += msm_io_vfe31_v4l2.o
-  obj-$(CONFIG_ARCH_MSM7X30) += msm_io_vfe31_v4l2.o
-else
-  obj-$(CONFIG_ARCH_MSM7X27A) += msm_io_7x27a.o
-  obj-$(CONFIG_ARCH_MSM8X60) += msm_io_8x60.o
-  obj-$(CONFIG_ARCH_MSM7X30) += msm_io_vfe31.o
-endif
-obj-$(CONFIG_ARCH_MSM_ARM11) += msm_io7x.o
-obj-$(CONFIG_ARCH_QSD8X50) += msm_io8x.o
-obj-$(CONFIG_ARCH_MSM8960) += msm_io_8960.o
diff --git a/drivers/media/platform/msm/camera_v1/io/msm_camera_i2c.c b/drivers/media/platform/msm/camera_v1/io/msm_camera_i2c.c
deleted file mode 100644
index bc826aa..0000000
--- a/drivers/media/platform/msm/camera_v1/io/msm_camera_i2c.c
+++ /dev/null
@@ -1,606 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- */
-
-#include <mach/camera.h>
-#include "msm_camera_i2c.h"
-#include "msm.h"
-#include "msm_cci.h"
-
-int32_t msm_camera_i2c_rxdata(struct msm_camera_i2c_client *dev_client,
-	unsigned char *rxdata, int data_length)
-{
-	int32_t rc = 0;
-	uint16_t saddr = dev_client->client->addr >> 1;
-	struct i2c_msg msgs[] = {
-		{
-			.addr  = saddr,
-			.flags = 0,
-			.len   = dev_client->addr_type,
-			.buf   = rxdata,
-		},
-		{
-			.addr  = saddr,
-			.flags = I2C_M_RD,
-			.len   = data_length,
-			.buf   = rxdata,
-		},
-	};
-	rc = i2c_transfer(dev_client->client->adapter, msgs, 2);
-	if (rc < 0)
-		S_I2C_DBG("msm_camera_i2c_rxdata failed 0x%x\n", saddr);
-	return rc;
-}
-
-int32_t msm_camera_i2c_txdata(struct msm_camera_i2c_client *dev_client,
-				unsigned char *txdata, int length)
-{
-	int32_t rc = 0;
-	uint16_t saddr = dev_client->client->addr >> 1;
-	struct i2c_msg msg[] = {
-		{
-			.addr = saddr,
-			.flags = 0,
-			.len = length,
-			.buf = txdata,
-		 },
-	};
-	rc = i2c_transfer(dev_client->client->adapter, msg, 1);
-	if (rc < 0)
-		S_I2C_DBG("msm_camera_i2c_txdata faild 0x%x\n", saddr);
-	return 0;
-}
-
-int32_t msm_camera_i2c_write(struct msm_camera_i2c_client *client,
-	uint16_t addr, uint16_t data,
-	enum msm_camera_i2c_data_type data_type)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[client->addr_type+data_type];
-	uint8_t len = 0;
-
-	if ((client->addr_type != MSM_CAMERA_I2C_BYTE_ADDR
-		&& client->addr_type != MSM_CAMERA_I2C_WORD_ADDR)
-		|| (data_type != MSM_CAMERA_I2C_BYTE_DATA
-		&& data_type != MSM_CAMERA_I2C_WORD_DATA))
-		return rc;
-
-	S_I2C_DBG("%s reg addr = 0x%x data type: %d\n",
-			  __func__, addr, data_type);
-	if (client->cci_client) {
-		struct msm_camera_cci_ctrl cci_ctrl;
-		struct msm_camera_i2c_reg_conf reg_conf_tbl;
-		reg_conf_tbl.reg_addr = addr;
-		reg_conf_tbl.reg_data = data;
-		cci_ctrl.cmd = MSM_CCI_I2C_WRITE;
-		cci_ctrl.cci_info = client->cci_client;
-		cci_ctrl.cfg.cci_i2c_write_cfg.reg_conf_tbl = &reg_conf_tbl;
-		cci_ctrl.cfg.cci_i2c_write_cfg.data_type = data_type;
-		cci_ctrl.cfg.cci_i2c_write_cfg.addr_type = client->addr_type;
-		cci_ctrl.cfg.cci_i2c_write_cfg.size = 1;
-		rc = v4l2_subdev_call(client->cci_client->cci_subdev,
-				core, ioctl, VIDIOC_MSM_CCI_CFG, &cci_ctrl);
-		CDBG("%s line %d rc = %d\n", __func__, __LINE__, rc);
-		rc = cci_ctrl.status;
-	} else {
-		if (client->addr_type == MSM_CAMERA_I2C_BYTE_ADDR) {
-			buf[0] = addr;
-			S_I2C_DBG("%s byte %d: 0x%x\n", __func__,
-				len, buf[len]);
-			len = 1;
-		} else if (client->addr_type == MSM_CAMERA_I2C_WORD_ADDR) {
-			buf[0] = addr >> BITS_PER_BYTE;
-			buf[1] = addr;
-			S_I2C_DBG("%s byte %d: 0x%x\n", __func__,
-				len, buf[len]);
-			S_I2C_DBG("%s byte %d: 0x%x\n", __func__,
-				len+1, buf[len+1]);
-			len = 2;
-		}
-		S_I2C_DBG("Data: 0x%x\n", data);
-		if (data_type == MSM_CAMERA_I2C_BYTE_DATA) {
-			buf[len] = data;
-			S_I2C_DBG("Byte %d: 0x%x\n", len, buf[len]);
-			len += 1;
-		} else if (data_type == MSM_CAMERA_I2C_WORD_DATA) {
-			buf[len] = data >> BITS_PER_BYTE;
-			buf[len+1] = data;
-			S_I2C_DBG("Byte %d: 0x%x\n", len, buf[len]);
-			S_I2C_DBG("Byte %d: 0x%x\n", len+1, buf[len+1]);
-			len += 2;
-		}
-		rc = msm_camera_i2c_txdata(client, buf, len);
-		if (rc < 0)
-			S_I2C_DBG("%s fail\n", __func__);
-	}
-	return rc;
-}
-
-int32_t msm_camera_i2c_write_seq(struct msm_camera_i2c_client *client,
-	uint16_t addr, uint8_t *data, uint16_t num_byte)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[client->addr_type+num_byte];
-	uint8_t len = 0, i = 0;
-
-	if ((client->addr_type != MSM_CAMERA_I2C_BYTE_ADDR
-		&& client->addr_type != MSM_CAMERA_I2C_WORD_ADDR)
-		|| num_byte == 0)
-		return rc;
-
-	S_I2C_DBG("%s reg addr = 0x%x num bytes: %d\n",
-			  __func__, addr, num_byte);
-	if (client->cci_client) {
-		struct msm_camera_cci_ctrl cci_ctrl;
-		struct msm_camera_i2c_reg_conf reg_conf_tbl[num_byte];
-		reg_conf_tbl[0].reg_addr = addr;
-		for (i = 0; i < num_byte; i++)
-			reg_conf_tbl[i].reg_data = data[i];
-		cci_ctrl.cmd = MSM_CCI_I2C_WRITE;
-		cci_ctrl.cci_info = client->cci_client;
-		cci_ctrl.cfg.cci_i2c_write_cfg.reg_conf_tbl = reg_conf_tbl;
-		cci_ctrl.cfg.cci_i2c_write_cfg.size = num_byte;
-		rc = v4l2_subdev_call(client->cci_client->cci_subdev,
-				core, ioctl, VIDIOC_MSM_CCI_CFG, &cci_ctrl);
-		CDBG("%s line %d rc = %d\n", __func__, __LINE__, rc);
-		rc = cci_ctrl.status;
-	} else {
-		if (client->addr_type == MSM_CAMERA_I2C_BYTE_ADDR) {
-			buf[0] = addr;
-			S_I2C_DBG("%s byte %d: 0x%x\n", __func__,
-				len, buf[len]);
-			len = 1;
-		} else if (client->addr_type == MSM_CAMERA_I2C_WORD_ADDR) {
-			buf[0] = addr >> BITS_PER_BYTE;
-			buf[1] = addr;
-			S_I2C_DBG("%s byte %d: 0x%x\n", __func__,
-				len, buf[len]);
-			S_I2C_DBG("%s byte %d: 0x%x\n", __func__,
-				len+1, buf[len+1]);
-			len = 2;
-		}
-		for (i = 0; i < num_byte; i++) {
-			buf[i+len] = data[i];
-			S_I2C_DBG("Byte %d: 0x%x\n", i+len, buf[i+len]);
-			S_I2C_DBG("Data: 0x%x\n", data[i]);
-		}
-		rc = msm_camera_i2c_txdata(client, buf, len+num_byte);
-		if (rc < 0)
-			S_I2C_DBG("%s fail\n", __func__);
-	}
-	return rc;
-}
-
-int32_t msm_camera_i2c_set_mask(struct msm_camera_i2c_client *client,
-	uint16_t addr, uint16_t mask,
-	enum msm_camera_i2c_data_type data_type, uint16_t set_mask)
-{
-	int32_t rc;
-	uint16_t reg_data;
-
-	rc = msm_camera_i2c_read(client, addr, &reg_data, data_type);
-	if (rc < 0) {
-		S_I2C_DBG("%s read fail\n", __func__);
-		return rc;
-	}
-	S_I2C_DBG("%s addr: 0x%x data: 0x%x setmask: 0x%x\n",
-			__func__, addr, reg_data, mask);
-
-	if (set_mask)
-		reg_data |= mask;
-	else
-		reg_data &= ~mask;
-	S_I2C_DBG("%s write: 0x%x\n", __func__, reg_data);
-
-	rc = msm_camera_i2c_write(client, addr, reg_data, data_type);
-	if (rc < 0)
-		S_I2C_DBG("%s write fail\n", __func__);
-
-	return rc;
-}
-int32_t msm_camera_i2c_set_write_mask_data(struct msm_camera_i2c_client *client,
-	uint16_t addr, uint16_t data, int16_t mask,
-	enum msm_camera_i2c_data_type data_type)
-{
-	int32_t rc;
-	uint16_t reg_data;
-	CDBG("%s\n", __func__);
-	if (mask == -1)
-		return 0;
-	if (mask == 0)
-		rc = msm_camera_i2c_write(client, addr, data, data_type);
-	else{
-		rc = msm_camera_i2c_read(client, addr, &reg_data, data_type);
-		if (rc < 0) {
-			CDBG("%s read fail\n", __func__);
-			return rc;
-		}
-		reg_data  = reg_data & mask;
-		reg_data  = (reg_data | (data & (~mask)));
-		rc = msm_camera_i2c_write(client, addr, reg_data, data_type);
-		if (rc < 0)
-			CDBG("%s write fail\n", __func__);
-	}
-	return rc;
-}
-
-int32_t msm_camera_i2c_compare(struct msm_camera_i2c_client *client,
-	uint16_t addr, uint16_t data,
-	enum msm_camera_i2c_data_type data_type)
-{
-	int32_t rc = -EIO;
-	uint16_t reg_data = 0;
-	int data_len = 0;
-	switch (data_type) {
-	case MSM_CAMERA_I2C_BYTE_DATA:
-	case MSM_CAMERA_I2C_WORD_DATA:
-		data_len = data_type;
-		break;
-	case MSM_CAMERA_I2C_SET_BYTE_MASK:
-	case MSM_CAMERA_I2C_UNSET_BYTE_MASK:
-		data_len = MSM_CAMERA_I2C_BYTE_DATA;
-		break;
-	case MSM_CAMERA_I2C_SET_WORD_MASK:
-	case MSM_CAMERA_I2C_UNSET_WORD_MASK:
-		data_len = MSM_CAMERA_I2C_WORD_DATA;
-		break;
-	default:
-		pr_err("%s: Unsupport data type: %d\n", __func__, data_type);
-		break;
-	}
-
-	rc = msm_camera_i2c_read(client,
-		addr, &reg_data, data_len);
-	if (rc < 0)
-		return rc;
-
-	rc = 0;
-	switch (data_type) {
-	case MSM_CAMERA_I2C_BYTE_DATA:
-	case MSM_CAMERA_I2C_WORD_DATA:
-		if (data == reg_data)
-			return rc;
-		break;
-	case MSM_CAMERA_I2C_SET_BYTE_MASK:
-	case MSM_CAMERA_I2C_SET_WORD_MASK:
-		if ((reg_data & data) == data)
-			return rc;
-		break;
-	case MSM_CAMERA_I2C_UNSET_BYTE_MASK:
-	case MSM_CAMERA_I2C_UNSET_WORD_MASK:
-		if (!(reg_data & data))
-			return rc;
-		break;
-	default:
-		pr_err("%s: Unsupport data type: %d\n", __func__, data_type);
-		break;
-	}
-
-	S_I2C_DBG("%s: Register and data does not match\n", __func__);
-	rc = 1;
-	return rc;
-}
-
-int32_t msm_camera_i2c_poll(struct msm_camera_i2c_client *client,
-	uint16_t addr, uint16_t data,
-	enum msm_camera_i2c_data_type data_type)
-{
-	int32_t rc = -EIO;
-	int i;
-	S_I2C_DBG("%s: addr: 0x%x data: 0x%x dt: %d\n",
-		__func__, addr, data, data_type);
-
-	for (i = 0; i < 20; i++) {
-		rc = msm_camera_i2c_compare(client,
-			addr, data, data_type);
-		if (rc == 0 || rc < 0)
-			break;
-		usleep_range(10000, 11000);
-	}
-	return rc;
-}
-
-int32_t msm_camera_i2c_write_table_w_microdelay(
-	struct msm_camera_i2c_client *client,
-	struct msm_camera_i2c_reg_tbl *reg_tbl, uint16_t size,
-	enum msm_camera_i2c_data_type data_type)
-{
-	int i;
-	int32_t rc = -EFAULT;
-
-	if (!client || !reg_tbl)
-		return rc;
-
-	if ((client->addr_type != MSM_CAMERA_I2C_BYTE_ADDR
-		&& client->addr_type != MSM_CAMERA_I2C_WORD_ADDR)
-		|| (data_type != MSM_CAMERA_I2C_BYTE_DATA
-		&& data_type != MSM_CAMERA_I2C_WORD_DATA))
-		return rc;
-
-	for (i = 0; i < size; i++) {
-		rc = msm_camera_i2c_write(client, reg_tbl->reg_addr,
-			reg_tbl->reg_data, data_type);
-		if (rc < 0)
-			break;
-		if (reg_tbl->delay)
-			usleep_range(reg_tbl->delay, reg_tbl->delay + 1000);
-		reg_tbl++;
-	}
-	return rc;
-}
-
-int32_t msm_camera_i2c_write_bayer_table(
-	struct msm_camera_i2c_client *client,
-	struct msm_camera_i2c_reg_setting *write_setting)
-{
-	int i;
-	int32_t rc = -EFAULT;
-	struct msm_camera_i2c_reg_array *reg_setting;
-
-	if (!client || !write_setting)
-		return rc;
-
-	reg_setting = write_setting->reg_setting;
-	client->addr_type = write_setting->addr_type;
-	if ((write_setting->addr_type != MSM_CAMERA_I2C_BYTE_ADDR
-		&& write_setting->addr_type != MSM_CAMERA_I2C_WORD_ADDR)
-		|| (write_setting->data_type != MSM_CAMERA_I2C_BYTE_DATA
-		&& write_setting->data_type != MSM_CAMERA_I2C_WORD_DATA))
-		return rc;
-	for (i = 0; i < write_setting->size; i++) {
-		rc = msm_camera_i2c_write(client, reg_setting->reg_addr,
-			reg_setting->reg_data, write_setting->data_type);
-		if (rc < 0)
-			break;
-		reg_setting++;
-	}
-	if (write_setting->delay > 20)
-		msleep(write_setting->delay);
-	else if (write_setting->delay)
-		usleep_range(write_setting->delay * 1000, (write_setting->delay
-			* 1000) + 1000);
-	return rc;
-}
-
-int32_t msm_camera_i2c_write_tbl(struct msm_camera_i2c_client *client,
-	struct msm_camera_i2c_reg_conf *reg_conf_tbl, uint16_t size,
-	enum msm_camera_i2c_data_type data_type)
-{
-	int i;
-	int32_t rc = -EFAULT;
-	for (i = 0; i < size; i++) {
-		enum msm_camera_i2c_data_type dt;
-		if (reg_conf_tbl->cmd_type == MSM_CAMERA_I2C_CMD_POLL) {
-			rc = msm_camera_i2c_poll(client,
-				reg_conf_tbl->reg_addr,
-				reg_conf_tbl->reg_data,
-				reg_conf_tbl->dt);
-		} else {
-			if (reg_conf_tbl->dt == 0)
-				dt = data_type;
-			else
-				dt = reg_conf_tbl->dt;
-			switch (dt) {
-			case MSM_CAMERA_I2C_BYTE_DATA:
-			case MSM_CAMERA_I2C_WORD_DATA:
-				rc = msm_camera_i2c_write(
-					client,
-					reg_conf_tbl->reg_addr,
-					reg_conf_tbl->reg_data, dt);
-				break;
-			case MSM_CAMERA_I2C_SET_BYTE_MASK:
-				rc = msm_camera_i2c_set_mask(client,
-					reg_conf_tbl->reg_addr,
-					reg_conf_tbl->reg_data,
-					MSM_CAMERA_I2C_BYTE_DATA, 1);
-				break;
-			case MSM_CAMERA_I2C_UNSET_BYTE_MASK:
-				rc = msm_camera_i2c_set_mask(client,
-					reg_conf_tbl->reg_addr,
-					reg_conf_tbl->reg_data,
-					MSM_CAMERA_I2C_BYTE_DATA, 0);
-				break;
-			case MSM_CAMERA_I2C_SET_WORD_MASK:
-				rc = msm_camera_i2c_set_mask(client,
-					reg_conf_tbl->reg_addr,
-					reg_conf_tbl->reg_data,
-					MSM_CAMERA_I2C_WORD_DATA, 1);
-				break;
-			case MSM_CAMERA_I2C_UNSET_WORD_MASK:
-				rc = msm_camera_i2c_set_mask(client,
-					reg_conf_tbl->reg_addr,
-					reg_conf_tbl->reg_data,
-					MSM_CAMERA_I2C_WORD_DATA, 0);
-				break;
-			case MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA:
-				rc = msm_camera_i2c_set_write_mask_data(
-					client,
-					reg_conf_tbl->reg_addr,
-					reg_conf_tbl->reg_data,
-					reg_conf_tbl->mask,
-					MSM_CAMERA_I2C_BYTE_DATA);
-				break;
-			default:
-				pr_err("%s: Unsupport data type: %d\n",
-					__func__, dt);
-				break;
-			}
-		}
-		if (rc < 0)
-			break;
-		reg_conf_tbl++;
-	}
-	return rc;
-}
-
-int32_t msm_camera_i2c_read(struct msm_camera_i2c_client *client,
-	uint16_t addr, uint16_t *data,
-	enum msm_camera_i2c_data_type data_type)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[client->addr_type+data_type];
-
-	if ((client->addr_type != MSM_CAMERA_I2C_BYTE_ADDR
-		&& client->addr_type != MSM_CAMERA_I2C_WORD_ADDR)
-		|| (data_type != MSM_CAMERA_I2C_BYTE_DATA
-		&& data_type != MSM_CAMERA_I2C_WORD_DATA))
-		return rc;
-
-	if (client->cci_client) {
-		struct msm_camera_cci_ctrl cci_ctrl;
-		cci_ctrl.cmd = MSM_CCI_I2C_READ;
-		cci_ctrl.cci_info = client->cci_client;
-		cci_ctrl.cfg.cci_i2c_read_cfg.addr = addr;
-		cci_ctrl.cfg.cci_i2c_read_cfg.addr_type = client->addr_type;
-		cci_ctrl.cfg.cci_i2c_read_cfg.data = buf;
-		cci_ctrl.cfg.cci_i2c_read_cfg.num_byte = data_type;
-		rc = v4l2_subdev_call(client->cci_client->cci_subdev,
-				core, ioctl, VIDIOC_MSM_CCI_CFG, &cci_ctrl);
-		CDBG("%s line %d rc = %d\n", __func__, __LINE__, rc);
-		rc = cci_ctrl.status;
-	} else {
-		if (client->addr_type == MSM_CAMERA_I2C_BYTE_ADDR) {
-			buf[0] = addr;
-		} else if (client->addr_type == MSM_CAMERA_I2C_WORD_ADDR) {
-			buf[0] = addr >> BITS_PER_BYTE;
-			buf[1] = addr;
-		}
-		rc = msm_camera_i2c_rxdata(client, buf, data_type);
-		if (rc < 0) {
-			S_I2C_DBG("%s fail\n", __func__);
-			return rc;
-		}
-	}
-	if (data_type == MSM_CAMERA_I2C_BYTE_DATA)
-		*data = buf[0];
-	else
-		*data = buf[0] << 8 | buf[1];
-
-	S_I2C_DBG("%s addr = 0x%x data: 0x%x\n", __func__, addr, *data);
-	return rc;
-}
-
-int32_t msm_camera_i2c_read_seq(struct msm_camera_i2c_client *client,
-	uint16_t addr, uint8_t *data, uint16_t num_byte)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[client->addr_type+num_byte];
-	int i;
-
-	if ((client->addr_type != MSM_CAMERA_I2C_BYTE_ADDR
-		&& client->addr_type != MSM_CAMERA_I2C_WORD_ADDR)
-		|| num_byte == 0)
-		return rc;
-
-	if (client->cci_client) {
-		struct msm_camera_cci_ctrl cci_ctrl;
-		cci_ctrl.cmd = MSM_CCI_I2C_READ;
-		cci_ctrl.cci_info = client->cci_client;
-		cci_ctrl.cfg.cci_i2c_read_cfg.addr = addr;
-		cci_ctrl.cfg.cci_i2c_read_cfg.addr_type = client->addr_type;
-		cci_ctrl.cfg.cci_i2c_read_cfg.data = buf;
-		cci_ctrl.cfg.cci_i2c_read_cfg.num_byte = num_byte;
-		rc = v4l2_subdev_call(client->cci_client->cci_subdev,
-				core, ioctl, VIDIOC_MSM_CCI_CFG, &cci_ctrl);
-		CDBG("%s line %d rc = %d\n", __func__, __LINE__, rc);
-		rc = cci_ctrl.status;
-	} else {
-		if (client->addr_type == MSM_CAMERA_I2C_BYTE_ADDR) {
-			buf[0] = addr;
-		} else if (client->addr_type == MSM_CAMERA_I2C_WORD_ADDR) {
-			buf[0] = addr >> BITS_PER_BYTE;
-			buf[1] = addr;
-		}
-		rc = msm_camera_i2c_rxdata(client, buf, num_byte);
-		if (rc < 0) {
-			S_I2C_DBG("%s fail\n", __func__);
-			return rc;
-		}
-	}
-
-	S_I2C_DBG("%s addr = 0x%x", __func__, addr);
-	for (i = 0; i < num_byte; i++) {
-		data[i] = buf[i];
-		S_I2C_DBG("Byte %d: 0x%x\n", i, buf[i]);
-		S_I2C_DBG("Data: 0x%x\n", data[i]);
-	}
-	return rc;
-}
-
-int32_t msm_sensor_write_conf_array(struct msm_camera_i2c_client *client,
-			struct msm_camera_i2c_conf_array *array, uint16_t index)
-{
-	int32_t rc;
-
-	rc = msm_camera_i2c_write_tbl(client,
-		(struct msm_camera_i2c_reg_conf *) array[index].conf,
-		array[index].size, array[index].data_type);
-	if (array[index].delay > 20)
-		msleep(array[index].delay);
-	else
-		usleep_range(array[index].delay*1000,
-					(array[index].delay+1)*1000);
-	return rc;
-}
-
-int32_t msm_sensor_write_enum_conf_array(struct msm_camera_i2c_client *client,
-			struct msm_camera_i2c_enum_conf_array *conf,
-			uint16_t enum_val)
-{
-	int32_t rc = -1, i;
-	for (i = 0; i < conf->num_enum; i++) {
-		if (conf->conf_enum[i] == enum_val)
-			break;
-		if (conf->conf_enum[i] > enum_val)
-			break;
-	}
-	if (i == conf->num_enum)
-		i = conf->num_enum - 1;
-
-	if (i >= conf->num_index)
-		return rc;
-	rc = msm_sensor_write_all_conf_array(client,
-		&conf->conf[i*conf->num_conf], conf->num_conf);
-
-	if (conf->delay > 20)
-		msleep(conf->delay);
-	else
-		usleep_range(conf->delay*1000,
-					(conf->delay+1)*1000);
-	return rc;
-}
-
-int32_t msm_sensor_write_all_conf_array(struct msm_camera_i2c_client *client,
-			struct msm_camera_i2c_conf_array *array, uint16_t size)
-{
-	int32_t rc = 0, i;
-	for (i = 0; i < size; i++) {
-		rc = msm_sensor_write_conf_array(client, array, i);
-		if (rc < 0)
-			break;
-	}
-	return rc;
-}
-
-int32_t msm_sensor_cci_util(struct msm_camera_i2c_client *client,
-	uint16_t cci_cmd)
-{
-	int32_t rc = 0;
-	struct msm_camera_cci_ctrl cci_ctrl;
-
-	CDBG("%s line %d\n", __func__, __LINE__);
-	cci_ctrl.cmd = cci_cmd;
-	cci_ctrl.cci_info = client->cci_client;
-	rc = v4l2_subdev_call(client->cci_client->cci_subdev,
-			core, ioctl, VIDIOC_MSM_CCI_CFG, &cci_ctrl);
-	CDBG("%s line %d rc = %d\n", __func__, __LINE__, rc);
-	return cci_ctrl.status;
-}
diff --git a/drivers/media/platform/msm/camera_v1/io/msm_camera_i2c.h b/drivers/media/platform/msm/camera_v1/io/msm_camera_i2c.h
deleted file mode 100644
index ce42607..0000000
--- a/drivers/media/platform/msm/camera_v1/io/msm_camera_i2c.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-
-#ifndef MSM_CAMERA_I2C_H
-#define MSM_CAMERA_I2C_H
-
-#include <linux/i2c.h>
-#include <linux/delay.h>
-#include <mach/camera.h>
-#include <media/v4l2-subdev.h>
-#include <media/msm_camera.h>
-
-#define CONFIG_MSM_CAMERA_I2C_DBG 0
-
-#if CONFIG_MSM_CAMERA_I2C_DBG
-#define S_I2C_DBG(fmt, args...) printk(fmt, ##args)
-#else
-#define S_I2C_DBG(fmt, args...) CDBG(fmt, ##args)
-#endif
-
-struct msm_camera_i2c_client {
-	struct i2c_client *client;
-	struct msm_camera_cci_client *cci_client;
-	enum msm_camera_i2c_reg_addr_type addr_type;
-};
-
-struct msm_camera_i2c_reg_tbl {
-	uint16_t reg_addr;
-	uint16_t reg_data;
-	uint16_t delay;
-};
-
-struct msm_camera_i2c_conf_array {
-	struct msm_camera_i2c_reg_conf *conf;
-	uint16_t size;
-	uint16_t delay;
-	enum msm_camera_i2c_data_type data_type;
-};
-
-struct msm_camera_i2c_enum_conf_array {
-	struct msm_camera_i2c_conf_array *conf;
-	int *conf_enum;
-	uint16_t num_enum;
-	uint16_t num_index;
-	uint16_t num_conf;
-	uint16_t delay;
-	enum msm_camera_i2c_data_type data_type;
-};
-
-int32_t msm_camera_i2c_rxdata(struct msm_camera_i2c_client *client,
-	unsigned char *rxdata, int data_length);
-
-int32_t msm_camera_i2c_txdata(struct msm_camera_i2c_client *client,
-	unsigned char *txdata, int length);
-
-int32_t msm_camera_i2c_read(struct msm_camera_i2c_client *client,
-	uint16_t addr, uint16_t *data,
-	enum msm_camera_i2c_data_type data_type);
-
-int32_t msm_camera_i2c_read_seq(struct msm_camera_i2c_client *client,
-	uint16_t addr, uint8_t *data, uint16_t num_byte);
-
-int32_t msm_camera_i2c_write(struct msm_camera_i2c_client *client,
-	uint16_t addr, uint16_t data,
-	enum msm_camera_i2c_data_type data_type);
-
-int32_t msm_camera_i2c_write_seq(struct msm_camera_i2c_client *client,
-	uint16_t addr, uint8_t *data, uint16_t num_byte);
-
-int32_t msm_camera_i2c_set_mask(struct msm_camera_i2c_client *client,
-	uint16_t addr, uint16_t mask,
-	enum msm_camera_i2c_data_type data_type, uint16_t flag);
-
-int32_t msm_camera_i2c_compare(struct msm_camera_i2c_client *client,
-	uint16_t addr, uint16_t data,
-	enum msm_camera_i2c_data_type data_type);
-
-int32_t msm_camera_i2c_poll(struct msm_camera_i2c_client *client,
-	uint16_t addr, uint16_t data,
-	enum msm_camera_i2c_data_type data_type);
-
-int32_t msm_camera_i2c_write_table_w_microdelay(
-	struct msm_camera_i2c_client *client,
-	struct msm_camera_i2c_reg_tbl *reg_tbl, uint16_t size,
-	enum msm_camera_i2c_data_type data_type);
-
-int32_t msm_camera_i2c_write_bayer_table(
-	struct msm_camera_i2c_client *client,
-	struct msm_camera_i2c_reg_setting *write_setting);
-
-int32_t msm_camera_i2c_write_tbl(struct msm_camera_i2c_client *client,
-	struct msm_camera_i2c_reg_conf *reg_conf_tbl, uint16_t size,
-	enum msm_camera_i2c_data_type data_type);
-
-int32_t msm_sensor_write_conf_array(struct msm_camera_i2c_client *client,
-	struct msm_camera_i2c_conf_array *array, uint16_t index);
-
-int32_t msm_sensor_write_enum_conf_array(struct msm_camera_i2c_client *client,
-	struct msm_camera_i2c_enum_conf_array *conf, uint16_t enum_val);
-
-int32_t msm_sensor_write_all_conf_array(struct msm_camera_i2c_client *client,
-	struct msm_camera_i2c_conf_array *array, uint16_t size);
-
-int32_t msm_sensor_cci_util(struct msm_camera_i2c_client *client,
-	uint16_t cci_cmd);
-#endif
diff --git a/drivers/media/platform/msm/camera_v1/io/msm_camera_i2c_mux.c b/drivers/media/platform/msm/camera_v1/io/msm_camera_i2c_mux.c
deleted file mode 100644
index b24a91a..0000000
--- a/drivers/media/platform/msm/camera_v1/io/msm_camera_i2c_mux.c
+++ /dev/null
@@ -1,187 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-
-#include <linux/delay.h>
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <linux/module.h>
-#include <mach/board.h>
-#include <mach/camera.h>
-#include "msm.h"
-#include "msm_camera_i2c_mux.h"
-
-static int msm_i2c_mux_config(struct i2c_mux_device *mux_device, uint8_t *mode)
-{
-	uint32_t val;
-	val = msm_camera_io_r(mux_device->ctl_base);
-	if (*mode == MODE_DUAL) {
-		msm_camera_io_w(val | 0x3, mux_device->ctl_base);
-	} else if (*mode == MODE_L) {
-		msm_camera_io_w(((val | 0x2) & ~(0x1)), mux_device->ctl_base);
-		val = msm_camera_io_r(mux_device->ctl_base);
-		CDBG("the camio mode config left value is %d\n", val);
-	} else {
-		msm_camera_io_w(((val | 0x1) & ~(0x2)), mux_device->ctl_base);
-		val = msm_camera_io_r(mux_device->ctl_base);
-		CDBG("the camio mode config right value is %d\n", val);
-	}
-	return 0;
-}
-
-static int msm_i2c_mux_init(struct i2c_mux_device *mux_device)
-{
-	int rc = 0, val = 0;
-	if (mux_device->use_count == 0) {
-		mux_device->ctl_base = ioremap(mux_device->ctl_mem->start,
-			resource_size(mux_device->ctl_mem));
-		if (!mux_device->ctl_base) {
-			rc = -ENOMEM;
-			return rc;
-		}
-		mux_device->rw_base = ioremap(mux_device->rw_mem->start,
-			resource_size(mux_device->rw_mem));
-		if (!mux_device->rw_base) {
-			rc = -ENOMEM;
-			iounmap(mux_device->ctl_base);
-			return rc;
-		}
-		val = msm_camera_io_r(mux_device->rw_base);
-		msm_camera_io_w((val | 0x200), mux_device->rw_base);
-	}
-	mux_device->use_count++;
-	return 0;
-};
-
-static int msm_i2c_mux_release(struct i2c_mux_device *mux_device)
-{
-	int val = 0;
-	mux_device->use_count--;
-	if (mux_device->use_count == 0) {
-		val = msm_camera_io_r(mux_device->rw_base);
-		msm_camera_io_w((val & ~0x200), mux_device->rw_base);
-		iounmap(mux_device->rw_base);
-		iounmap(mux_device->ctl_base);
-	}
-	return 0;
-}
-
-static long msm_i2c_mux_subdev_ioctl(struct v4l2_subdev *sd,
-			unsigned int cmd, void *arg)
-{
-	struct i2c_mux_device *mux_device;
-	int rc = 0;
-	mux_device = v4l2_get_subdevdata(sd);
-	if (mux_device == NULL) {
-		rc = -ENOMEM;
-		return rc;
-	}
-	mutex_lock(&mux_device->mutex);
-	switch (cmd) {
-	case VIDIOC_MSM_I2C_MUX_CFG:
-		rc = msm_i2c_mux_config(mux_device, (uint8_t *) arg);
-		break;
-	case VIDIOC_MSM_I2C_MUX_INIT:
-		rc = msm_i2c_mux_init(mux_device);
-		break;
-	case VIDIOC_MSM_I2C_MUX_RELEASE:
-		rc = msm_i2c_mux_release(mux_device);
-		break;
-	default:
-		rc = -ENOIOCTLCMD;
-	}
-	mutex_unlock(&mux_device->mutex);
-	return rc;
-}
-
-static struct v4l2_subdev_core_ops msm_i2c_mux_subdev_core_ops = {
-	.ioctl = &msm_i2c_mux_subdev_ioctl,
-};
-
-static const struct v4l2_subdev_ops msm_i2c_mux_subdev_ops = {
-	.core = &msm_i2c_mux_subdev_core_ops,
-};
-
-static int __devinit i2c_mux_probe(struct platform_device *pdev)
-{
-	struct i2c_mux_device *mux_device;
-	int rc = 0;
-	CDBG("%s: device id = %d\n", __func__, pdev->id);
-	mux_device = kzalloc(sizeof(struct i2c_mux_device), GFP_KERNEL);
-	if (!mux_device) {
-		pr_err("%s: no enough memory\n", __func__);
-		return -ENOMEM;
-	}
-
-	v4l2_subdev_init(&mux_device->subdev, &msm_i2c_mux_subdev_ops);
-	v4l2_set_subdevdata(&mux_device->subdev, mux_device);
-	platform_set_drvdata(pdev, &mux_device->subdev);
-	mutex_init(&mux_device->mutex);
-
-	mux_device->ctl_mem = platform_get_resource_byname(pdev,
-					IORESOURCE_MEM, "i2c_mux_ctl");
-	if (!mux_device->ctl_mem) {
-		pr_err("%s: no mem resource?\n", __func__);
-		rc = -ENODEV;
-		goto i2c_mux_no_resource;
-	}
-	mux_device->ctl_io = request_mem_region(mux_device->ctl_mem->start,
-		resource_size(mux_device->ctl_mem), pdev->name);
-	if (!mux_device->ctl_io) {
-		pr_err("%s: no valid mem region\n", __func__);
-		rc = -EBUSY;
-		goto i2c_mux_no_resource;
-	}
-	mux_device->rw_mem = platform_get_resource_byname(pdev,
-					IORESOURCE_MEM, "i2c_mux_rw");
-	if (!mux_device->rw_mem) {
-		pr_err("%s: no mem resource?\n", __func__);
-		rc = -ENODEV;
-		goto i2c_mux_no_resource;
-	}
-	mux_device->rw_io = request_mem_region(mux_device->rw_mem->start,
-		resource_size(mux_device->rw_mem), pdev->name);
-	if (!mux_device->rw_io) {
-		pr_err("%s: no valid mem region\n", __func__);
-		rc = -EBUSY;
-		goto i2c_mux_no_resource;
-	}
-	mux_device->pdev = pdev;
-	return 0;
-
-i2c_mux_no_resource:
-	mutex_destroy(&mux_device->mutex);
-	kfree(mux_device);
-	return 0;
-}
-
-static struct platform_driver i2c_mux_driver = {
-	.probe = i2c_mux_probe,
-	.driver = {
-		.name = MSM_I2C_MUX_DRV_NAME,
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init msm_camera_i2c_mux_init_module(void)
-{
-	return platform_driver_register(&i2c_mux_driver);
-}
-
-static void __exit msm_camera_i2c_mux_exit_module(void)
-{
-	platform_driver_unregister(&i2c_mux_driver);
-}
-
-module_init(msm_camera_i2c_mux_init_module);
-module_exit(msm_camera_i2c_mux_exit_module);
-MODULE_DESCRIPTION("MSM Camera I2C mux driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/io/msm_camera_i2c_mux.h b/drivers/media/platform/msm/camera_v1/io/msm_camera_i2c_mux.h
deleted file mode 100644
index 30f908b..0000000
--- a/drivers/media/platform/msm/camera_v1/io/msm_camera_i2c_mux.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-
-#ifndef MSM_I2C_MUX_H
-#define MSM_I2C_MUX_H
-
-#include <linux/io.h>
-#include <media/v4l2-subdev.h>
-
-struct i2c_mux_device {
-	struct platform_device *pdev;
-	struct v4l2_subdev subdev;
-	struct resource *ctl_mem;
-	struct resource *ctl_io;
-	void __iomem *ctl_base;
-	struct resource *rw_mem;
-	struct resource *rw_io;
-	void __iomem *rw_base;
-	struct mutex mutex;
-	unsigned use_count;
-};
-
-struct i2c_mux_cfg_params {
-	struct v4l2_subdev *subdev;
-	void *parms;
-};
-
-#define VIDIOC_MSM_I2C_MUX_CFG \
-	_IOWR('V', BASE_VIDIOC_PRIVATE + 13, struct i2c_mux_cfg_params)
-
-#define VIDIOC_MSM_I2C_MUX_INIT \
-	_IOWR('V', BASE_VIDIOC_PRIVATE + 14, struct v4l2_subdev*)
-
-#define VIDIOC_MSM_I2C_MUX_RELEASE \
-	_IOWR('V', BASE_VIDIOC_PRIVATE + 15, struct v4l2_subdev*)
-
-#endif
diff --git a/drivers/media/platform/msm/camera_v1/io/msm_camera_io_util.c b/drivers/media/platform/msm/camera_v1/io/msm_camera_io_util.c
deleted file mode 100644
index 1e0a013..0000000
--- a/drivers/media/platform/msm/camera_v1/io/msm_camera_io_util.c
+++ /dev/null
@@ -1,535 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundataion. 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.
- */
-
-#include <linux/delay.h>
-#include <linux/clk.h>
-#include <linux/gpio.h>
-#include <linux/regulator/consumer.h>
-#include <linux/io.h>
-#include <mach/board.h>
-#include <mach/camera.h>
-#include <mach/gpiomux.h>
-
-#define BUFF_SIZE_128 128
-static int gpio_ref_count;
-
-void msm_camera_io_w(u32 data, void __iomem *addr)
-{
-	CDBG("%s: %08x %08x\n", __func__, (int) (addr), (data));
-	writel_relaxed((data), (addr));
-}
-
-void msm_camera_io_w_mb(u32 data, void __iomem *addr)
-{
-	CDBG("%s: %08x %08x\n", __func__, (int) (addr), (data));
-	wmb();
-	writel_relaxed((data), (addr));
-	wmb();
-}
-
-u32 msm_camera_io_r(void __iomem *addr)
-{
-	uint32_t data = readl_relaxed(addr);
-	CDBG("%s: %08x %08x\n", __func__, (int) (addr), (data));
-	return data;
-}
-
-u32 msm_camera_io_r_mb(void __iomem *addr)
-{
-	uint32_t data;
-	rmb();
-	data = readl_relaxed(addr);
-	rmb();
-	CDBG("%s: %08x %08x\n", __func__, (int) (addr), (data));
-	return data;
-}
-
-void msm_camera_io_memcpy_toio(void __iomem *dest_addr,
-	void __iomem *src_addr, u32 len)
-{
-	int i;
-	u32 *d = (u32 *) dest_addr;
-	u32 *s = (u32 *) src_addr;
-
-	for (i = 0; i < len; i++)
-		writel_relaxed(*s++, d++);
-}
-
-void msm_camera_io_dump(void __iomem *addr, int size)
-{
-	char line_str[BUFF_SIZE_128], *p_str;
-	int i;
-	u32 *p = (u32 *) addr;
-	u32 data;
-	CDBG("%s: %p %d\n", __func__, addr, size);
-	line_str[0] = '\0';
-	p_str = line_str;
-	for (i = 0; i < size/4; i++) {
-		if (i % 4 == 0) {
-			snprintf(p_str, 12, "%08x: ", (u32) p);
-			p_str += 10;
-		}
-		data = readl_relaxed(p++);
-		snprintf(p_str, 12, "%08x ", data);
-		p_str += 9;
-		if ((i + 1) % 4 == 0) {
-			CDBG("%s\n", line_str);
-			line_str[0] = '\0';
-			p_str = line_str;
-		}
-	}
-	if (line_str[0] != '\0')
-		CDBG("%s\n", line_str);
-}
-
-void msm_camera_io_memcpy(void __iomem *dest_addr,
-	void __iomem *src_addr, u32 len)
-{
-	CDBG("%s: %p %p %d\n", __func__, dest_addr, src_addr, len);
-	msm_camera_io_memcpy_toio(dest_addr, src_addr, len / 4);
-	msm_camera_io_dump(dest_addr, len);
-}
-
-int msm_cam_clk_enable(struct device *dev, struct msm_cam_clk_info *clk_info,
-		struct clk **clk_ptr, int num_clk, int enable)
-{
-	int i;
-	int rc = 0;
-	if (enable) {
-		for (i = 0; i < num_clk; i++) {
-			clk_ptr[i] = clk_get(dev, clk_info[i].clk_name);
-			if (IS_ERR(clk_ptr[i])) {
-				pr_err("%s get failed\n", clk_info[i].clk_name);
-				rc = PTR_ERR(clk_ptr[i]);
-				goto cam_clk_get_err;
-			}
-			if (clk_info[i].clk_rate >= 0) {
-				rc = clk_set_rate(clk_ptr[i],
-							clk_info[i].clk_rate);
-				if (rc < 0) {
-					pr_err("%s set failed\n",
-						   clk_info[i].clk_name);
-					goto cam_clk_set_err;
-				}
-			}
-			rc = clk_prepare(clk_ptr[i]);
-			if (rc < 0) {
-				pr_err("%s prepare failed\n",
-					   clk_info[i].clk_name);
-				goto cam_clk_prepare_err;
-			}
-
-			rc = clk_enable(clk_ptr[i]);
-			if (rc < 0) {
-				pr_err("%s enable failed\n",
-					   clk_info[i].clk_name);
-				goto cam_clk_enable_err;
-			}
-			if (clk_info[i].delay > 20) {
-				msleep(clk_info[i].delay);
-			} else if (clk_info[i].delay) {
-				usleep_range(clk_info[i].delay * 1000,
-					(clk_info[i].delay * 1000) + 1000);
-			}
-		}
-	} else {
-		for (i = num_clk - 1; i >= 0; i--) {
-			if (clk_ptr[i] != NULL) {
-				clk_disable(clk_ptr[i]);
-				clk_unprepare(clk_ptr[i]);
-				clk_put(clk_ptr[i]);
-			}
-		}
-	}
-	return rc;
-
-
-cam_clk_enable_err:
-	clk_unprepare(clk_ptr[i]);
-cam_clk_prepare_err:
-cam_clk_set_err:
-	clk_put(clk_ptr[i]);
-cam_clk_get_err:
-	for (i--; i >= 0; i--) {
-		if (clk_ptr[i] != NULL) {
-			clk_disable(clk_ptr[i]);
-			clk_unprepare(clk_ptr[i]);
-			clk_put(clk_ptr[i]);
-		}
-	}
-	return rc;
-}
-
-int msm_camera_config_vreg(struct device *dev, struct camera_vreg_t *cam_vreg,
-		int num_vreg, enum msm_camera_vreg_name_t *vreg_seq,
-		int num_vreg_seq, struct regulator **reg_ptr, int config)
-{
-	int i = 0, j = 0;
-	int rc = 0;
-	struct camera_vreg_t *curr_vreg;
-
-	if (num_vreg_seq > num_vreg) {
-		pr_err("%s:%d vreg sequence invalid\n", __func__, __LINE__);
-		return -EINVAL;
-	}
-	if (!num_vreg_seq)
-		num_vreg_seq = num_vreg;
-
-	if (config) {
-		for (i = 0; i < num_vreg_seq; i++) {
-			if (vreg_seq) {
-				j = vreg_seq[i];
-				if (j >= num_vreg)
-					continue;
-			} else
-				j = i;
-			curr_vreg = &cam_vreg[j];
-			reg_ptr[j] = regulator_get(dev,
-				curr_vreg->reg_name);
-			if (IS_ERR(reg_ptr[j])) {
-				pr_err("%s: %s get failed\n",
-					 __func__,
-					 curr_vreg->reg_name);
-				reg_ptr[j] = NULL;
-				goto vreg_get_fail;
-			}
-			if (curr_vreg->type == REG_LDO) {
-				rc = regulator_set_voltage(
-					reg_ptr[j],
-					curr_vreg->min_voltage,
-					curr_vreg->max_voltage);
-				if (rc < 0) {
-					pr_err("%s: %s set voltage failed\n",
-						__func__,
-						curr_vreg->reg_name);
-					goto vreg_set_voltage_fail;
-				}
-				if (curr_vreg->op_mode >= 0) {
-					rc = regulator_set_optimum_mode(
-						reg_ptr[j],
-						curr_vreg->op_mode);
-					if (rc < 0) {
-						pr_err(
-						"%s: %s set optimum mode failed\n",
-						__func__,
-						curr_vreg->reg_name);
-						goto vreg_set_opt_mode_fail;
-					}
-				}
-			}
-		}
-	} else {
-		for (i = num_vreg_seq-1; i >= 0; i--) {
-			if (vreg_seq) {
-				j = vreg_seq[i];
-				if (j >= num_vreg)
-					continue;
-			} else
-				j = i;
-			curr_vreg = &cam_vreg[j];
-			if (reg_ptr[j]) {
-				if (curr_vreg->type == REG_LDO) {
-					if (curr_vreg->op_mode >= 0) {
-						regulator_set_optimum_mode(
-							reg_ptr[j], 0);
-					}
-					regulator_set_voltage(
-						reg_ptr[j], 0, curr_vreg->
-						max_voltage);
-				}
-				regulator_put(reg_ptr[j]);
-				reg_ptr[j] = NULL;
-			}
-		}
-	}
-	return 0;
-
-vreg_unconfig:
-if (curr_vreg->type == REG_LDO)
-	regulator_set_optimum_mode(reg_ptr[j], 0);
-
-vreg_set_opt_mode_fail:
-if (curr_vreg->type == REG_LDO)
-	regulator_set_voltage(reg_ptr[j], 0,
-		curr_vreg->max_voltage);
-
-vreg_set_voltage_fail:
-	regulator_put(reg_ptr[j]);
-	reg_ptr[j] = NULL;
-
-vreg_get_fail:
-	for (i--; i >= 0; i--) {
-		if (vreg_seq) {
-			j = vreg_seq[i];
-			if (j >= num_vreg)
-				continue;
-		} else
-			j = i;
-		curr_vreg = &cam_vreg[j];
-		goto vreg_unconfig;
-	}
-	return -ENODEV;
-}
-
-int msm_camera_enable_vreg(struct device *dev, struct camera_vreg_t *cam_vreg,
-		int num_vreg, enum msm_camera_vreg_name_t *vreg_seq,
-		int num_vreg_seq, struct regulator **reg_ptr, int enable)
-{
-	int i = 0, j = 0, rc = 0;
-
-	if (num_vreg_seq > num_vreg) {
-		pr_err("%s:%d vreg sequence invalid\n", __func__, __LINE__);
-		return -EINVAL;
-	}
-	if (!num_vreg_seq)
-		num_vreg_seq = num_vreg;
-
-	if (enable) {
-		for (i = 0; i < num_vreg_seq; i++) {
-			if (vreg_seq) {
-				j = vreg_seq[i];
-				if (j >= num_vreg)
-					continue;
-			} else
-				j = i;
-			if (IS_ERR(reg_ptr[j])) {
-				pr_err("%s: %s null regulator\n",
-					__func__, cam_vreg[j].reg_name);
-				goto disable_vreg;
-			}
-			rc = regulator_enable(reg_ptr[j]);
-			if (rc < 0) {
-				pr_err("%s: %s enable failed\n",
-					__func__, cam_vreg[j].reg_name);
-				goto disable_vreg;
-			}
-			if (cam_vreg[j].delay > 20)
-				msleep(cam_vreg[j].delay);
-			else if (cam_vreg[j].delay)
-				usleep_range(cam_vreg[j].delay * 1000,
-					(cam_vreg[j].delay * 1000) + 1000);
-		}
-	} else {
-		for (i = num_vreg_seq-1; i >= 0; i--) {
-			if (vreg_seq) {
-				j = vreg_seq[i];
-				if (j >= num_vreg)
-					continue;
-			} else
-				j = i;
-			regulator_disable(reg_ptr[j]);
-			if (cam_vreg[j].delay > 20)
-				msleep(cam_vreg[j].delay);
-			else if (cam_vreg[j].delay)
-				usleep_range(cam_vreg[j].delay * 1000,
-					(cam_vreg[j].delay * 1000) + 1000);
-		}
-	}
-	return rc;
-disable_vreg:
-	for (i--; i >= 0; i--) {
-		if (vreg_seq) {
-			j = vreg_seq[i];
-			if (j >= num_vreg)
-				continue;
-		} else
-			j = i;
-		regulator_disable(reg_ptr[j]);
-		if (cam_vreg[j].delay > 20)
-			msleep(cam_vreg[j].delay);
-		else if (cam_vreg[j].delay)
-			usleep_range(cam_vreg[j].delay * 1000,
-				(cam_vreg[j].delay * 1000) + 1000);
-	}
-	return rc;
-}
-
-static int config_gpio_table(struct msm_camera_gpio_conf *gpio)
-{
-	int rc = 0, i = 0;
-	uint32_t *table_on;
-	uint32_t *table_off;
-	uint32_t len;
-
-	table_on = gpio->camera_on_table;
-	table_off = gpio->camera_off_table;
-	len = gpio->camera_on_table_size;
-
-	for (i = 0; i < len; i++) {
-		rc = gpio_tlmm_config(table_on[i], GPIO_CFG_ENABLE);
-		if (rc) {
-			pr_err("%s not able to get gpio\n", __func__);
-			for (i--; i >= 0; i--)
-				gpio_tlmm_config(table_off[i],
-					GPIO_CFG_ENABLE);
-			break;
-		}
-	}
-	return rc;
-}
-
-int msm_camera_request_gpio_table(struct msm_camera_sensor_info *sinfo,
-	int gpio_en)
-{
-	int rc = 0;
-	struct msm_camera_gpio_conf *gpio_conf =
-		sinfo->sensor_platform_info->gpio_conf;
-
-	if (!gpio_conf->gpio_no_mux) {
-		if (gpio_conf->cam_gpio_req_tbl == NULL ||
-			gpio_conf->cam_gpio_common_tbl == NULL) {
-			pr_err("%s: NULL camera gpio table\n", __func__);
-			return -EFAULT;
-		}
-	}
-	if (gpio_conf->gpio_no_mux)
-		config_gpio_table(gpio_conf);
-
-	if (gpio_en) {
-		if (!gpio_conf->gpio_no_mux && !gpio_ref_count) {
-			if (gpio_conf->cam_gpiomux_conf_tbl != NULL) {
-				msm_gpiomux_install(
-					(struct msm_gpiomux_config *)
-					gpio_conf->cam_gpiomux_conf_tbl,
-					gpio_conf->cam_gpiomux_conf_tbl_size);
-			}
-			rc = gpio_request_array(gpio_conf->cam_gpio_common_tbl,
-				gpio_conf->cam_gpio_common_tbl_size);
-			if (rc < 0) {
-				pr_err("%s common gpio request failed\n"
-						, __func__);
-				return rc;
-			}
-		}
-		gpio_ref_count++;
-		if (gpio_conf->cam_gpio_req_tbl_size) {
-			rc = gpio_request_array(gpio_conf->cam_gpio_req_tbl,
-				gpio_conf->cam_gpio_req_tbl_size);
-			if (rc < 0) {
-				pr_err("%s camera gpio"
-					"request failed\n", __func__);
-				gpio_free_array(gpio_conf->cam_gpio_common_tbl,
-					gpio_conf->cam_gpio_common_tbl_size);
-				return rc;
-			}
-		}
-	} else {
-		gpio_ref_count--;
-		gpio_free_array(gpio_conf->cam_gpio_req_tbl,
-				gpio_conf->cam_gpio_req_tbl_size);
-		if (!gpio_conf->gpio_no_mux && !gpio_ref_count)
-			gpio_free_array(gpio_conf->cam_gpio_common_tbl,
-				gpio_conf->cam_gpio_common_tbl_size);
-	}
-	return rc;
-}
-
-int msm_camera_config_gpio_table(struct msm_camera_sensor_info *sinfo,
-	int gpio_en)
-{
-	struct msm_camera_gpio_conf *gpio_conf =
-		sinfo->sensor_platform_info->gpio_conf;
-	int rc = 0, i;
-
-	if (gpio_en) {
-		for (i = 0; i < gpio_conf->cam_gpio_set_tbl_size; i++) {
-			gpio_set_value_cansleep(
-				gpio_conf->cam_gpio_set_tbl[i].gpio,
-				gpio_conf->cam_gpio_set_tbl[i].flags);
-			usleep_range(gpio_conf->cam_gpio_set_tbl[i].delay,
-				gpio_conf->cam_gpio_set_tbl[i].delay + 1000);
-		}
-	} else {
-		for (i = gpio_conf->cam_gpio_set_tbl_size - 1; i >= 0; i--) {
-			if (gpio_conf->cam_gpio_set_tbl[i].flags)
-				gpio_set_value_cansleep(
-					gpio_conf->cam_gpio_set_tbl[i].gpio,
-					GPIOF_OUT_INIT_LOW);
-		}
-	}
-	return rc;
-}
-
-void msm_camera_bus_scale_cfg(uint32_t bus_perf_client,
-		enum msm_bus_perf_setting perf_setting)
-{
-	int rc = 0;
-	if (!bus_perf_client) {
-		pr_err("%s: Bus Client NOT Registered!!!\n", __func__);
-		return;
-	}
-
-	switch (perf_setting) {
-	case S_EXIT:
-		rc = msm_bus_scale_client_update_request(bus_perf_client, 1);
-		msm_bus_scale_unregister_client(bus_perf_client);
-		break;
-	case S_PREVIEW:
-		rc = msm_bus_scale_client_update_request(bus_perf_client, 1);
-		break;
-	case S_VIDEO:
-		rc = msm_bus_scale_client_update_request(bus_perf_client, 2);
-		break;
-	case S_CAPTURE:
-		rc = msm_bus_scale_client_update_request(bus_perf_client, 3);
-		break;
-	case S_ZSL:
-		rc = msm_bus_scale_client_update_request(bus_perf_client, 4);
-		break;
-	case S_LIVESHOT:
-		rc = msm_bus_scale_client_update_request(bus_perf_client, 5);
-		break;
-	case S_DEFAULT:
-		break;
-	default:
-		pr_warning("%s: INVALID CASE\n", __func__);
-	}
-}
-
-int msm_camera_init_gpio_table(struct gpio *gpio_tbl, uint8_t gpio_tbl_size,
-	int gpio_en)
-{
-	int rc = 0;
-
-	if (gpio_en) {
-		rc = gpio_request_array(gpio_tbl, gpio_tbl_size);
-		if (rc < 0) {
-			pr_err("%s:%d failed\n" , __func__, __LINE__);
-			return rc;
-		}
-	} else {
-		gpio_free_array(gpio_tbl, gpio_tbl_size);
-	}
-	return rc;
-}
-
-int msm_camera_set_gpio_table(struct msm_gpio_set_tbl *gpio_tbl,
-	uint8_t gpio_tbl_size, int gpio_en)
-{
-	int rc = 0, i;
-
-	if (gpio_en) {
-		for (i = 0; i < gpio_tbl_size; i++) {
-			gpio_set_value_cansleep(gpio_tbl[i].gpio,
-				gpio_tbl[i].flags);
-			usleep_range(gpio_tbl[i].delay,
-				gpio_tbl[i].delay + 1000);
-		}
-	} else {
-		for (i = gpio_tbl_size - 1; i >= 0; i--) {
-			if (gpio_tbl[i].flags)
-				gpio_set_value_cansleep(gpio_tbl[i].gpio,
-					GPIOF_OUT_INIT_LOW);
-		}
-	}
-	return rc;
-}
diff --git a/drivers/media/platform/msm/camera_v1/io/msm_io7x.c b/drivers/media/platform/msm/camera_v1/io/msm_io7x.c
deleted file mode 100644
index ebdaeb1..0000000
--- a/drivers/media/platform/msm/camera_v1/io/msm_io7x.c
+++ /dev/null
@@ -1,318 +0,0 @@
-/* Copyright (c) 2009-2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/delay.h>
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <mach/gpio.h>
-#include <mach/board.h>
-#include <mach/camera.h>
-#include <mach/clk.h>
-
-#define CAMIF_CFG_RMSK 0x1fffff
-#define CAM_SEL_BMSK 0x2
-#define CAM_PCLK_SRC_SEL_BMSK 0x60000
-#define CAM_PCLK_INVERT_BMSK 0x80000
-#define CAM_PAD_REG_SW_RESET_BMSK 0x100000
-
-#define EXT_CAM_HSYNC_POL_SEL_BMSK 0x10000
-#define EXT_CAM_VSYNC_POL_SEL_BMSK 0x8000
-#define MDDI_CLK_CHICKEN_BIT_BMSK  0x80
-
-#define CAM_SEL_SHFT 0x1
-#define CAM_PCLK_SRC_SEL_SHFT 0x11
-#define CAM_PCLK_INVERT_SHFT 0x13
-#define CAM_PAD_REG_SW_RESET_SHFT 0x14
-
-#define EXT_CAM_HSYNC_POL_SEL_SHFT 0x10
-#define EXT_CAM_VSYNC_POL_SEL_SHFT 0xF
-#define MDDI_CLK_CHICKEN_BIT_SHFT  0x7
-#define APPS_RESET_OFFSET 0x00000210
-
-static struct clk *camio_vfe_mdc_clk;
-static struct clk *camio_mdc_clk;
-static struct clk *camio_vfe_clk;
-
-static struct msm_camera_io_ext camio_ext;
-static struct resource *appio, *mdcio;
-void __iomem *appbase, *mdcbase;
-
-static struct resource *appio, *mdcio;
-void __iomem *appbase, *mdcbase;
-
-int msm_camio_clk_enable(enum msm_camio_clk_type clktype)
-{
-	int rc = -1;
-	struct clk *clk = NULL;
-
-	switch (clktype) {
-	case CAMIO_VFE_MDC_CLK:
-		clk = camio_vfe_mdc_clk = clk_get(NULL, "vfe_mdc_clk");
-		break;
-
-	case CAMIO_MDC_CLK:
-		clk = camio_mdc_clk = clk_get(NULL, "mdc_clk");
-		break;
-
-	case CAMIO_VFE_CLK:
-		clk = camio_vfe_clk = clk_get(NULL, "vfe_clk");
-		break;
-
-	default:
-		break;
-	}
-
-	if (!IS_ERR(clk)) {
-		clk_enable(clk);
-		rc = 0;
-	}
-
-	return rc;
-}
-
-int msm_camio_clk_disable(enum msm_camio_clk_type clktype)
-{
-	int rc = -1;
-	struct clk *clk = NULL;
-
-	switch (clktype) {
-	case CAMIO_VFE_MDC_CLK:
-		clk = camio_vfe_mdc_clk;
-		break;
-
-	case CAMIO_MDC_CLK:
-		clk = camio_mdc_clk;
-		break;
-
-	case CAMIO_VFE_CLK:
-		clk = camio_vfe_clk;
-		break;
-
-	default:
-		break;
-	}
-
-	if (!IS_ERR(clk)) {
-		clk_disable(clk);
-		clk_put(clk);
-		rc = 0;
-	}
-
-	return rc;
-}
-
-void msm_camio_clk_rate_set(int rate)
-{
-	struct clk *clk = camio_vfe_clk;
-
-	if (clk != ERR_PTR(-ENOENT))
-		clk_set_rate(clk, rate);
-}
-
-int msm_camio_enable(struct platform_device *pdev)
-{
-	int rc = 0;
-	struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-
-	camio_ext = camdev->ioext;
-
-	appio = request_mem_region(camio_ext.appphy,
-		camio_ext.appsz, pdev->name);
-	if (!appio) {
-		rc = -EBUSY;
-		goto enable_fail;
-	}
-
-	appbase = ioremap(camio_ext.appphy,
-		camio_ext.appsz);
-	if (!appbase) {
-		rc = -ENOMEM;
-		goto apps_no_mem;
-	}
-
-	msm_camio_clk_enable(CAMIO_VFE_CLK);
-	msm_camio_clk_enable(CAMIO_MDC_CLK);
-	return 0;
-apps_no_mem:
-	release_mem_region(camio_ext.appphy, camio_ext.appsz);
-enable_fail:
-	return rc;
-}
-
-int msm_camio_sensor_clk_on(struct platform_device *pdev)
-{
-	struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-	int32_t rc = 0;
-	camio_ext = camdev->ioext;
-	mdcio = request_mem_region(camio_ext.mdcphy,
-		camio_ext.mdcsz, pdev->name);
-	if (!mdcio)
-		rc = -EBUSY;
-	mdcbase = ioremap(camio_ext.mdcphy,
-		camio_ext.mdcsz);
-	if (!mdcbase) {
-		rc = -EINVAL;
-		goto mdc_no_mem;
-	}
-	camdev->camera_gpio_on();
-	return msm_camio_clk_enable(CAMIO_VFE_MDC_CLK);
-
-mdc_no_mem:
-	release_mem_region(camio_ext.mdcphy, camio_ext.mdcsz);
-	return rc;
-}
-
-int msm_camio_sensor_clk_off(struct platform_device *pdev)
-{
-	struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-	camdev->camera_gpio_off();
-	iounmap(mdcbase);
-	release_mem_region(camio_ext.mdcphy, camio_ext.mdcsz);
-	return msm_camio_clk_disable(CAMIO_VFE_MDC_CLK);
-}
-
-void msm_camio_disable(struct platform_device *pdev)
-{
-	iounmap(appbase);
-	release_mem_region(camio_ext.appphy, camio_ext.appsz);
-	msm_camio_clk_disable(CAMIO_VFE_CLK);
-	msm_camio_clk_disable(CAMIO_MDC_CLK);
-}
-
-void msm_disable_io_gpio_clk(struct platform_device *pdev)
-{
-	return;
-}
-
-void msm_camio_camif_pad_reg_reset(void)
-{
-	uint32_t reg;
-	uint32_t mask, value;
-
-	/* select CLKRGM_VFE_SRC_CAM_VFE_SRC:  internal source */
-	msm_camio_clk_sel(MSM_CAMIO_CLK_SRC_INTERNAL);
-
-	reg = (msm_camera_io_r_mb(mdcbase)) & CAMIF_CFG_RMSK;
-
-	mask = CAM_SEL_BMSK |
-		CAM_PCLK_SRC_SEL_BMSK |
-		CAM_PCLK_INVERT_BMSK;
-
-	value = 1 << CAM_SEL_SHFT |
-		3 << CAM_PCLK_SRC_SEL_SHFT |
-		0 << CAM_PCLK_INVERT_SHFT;
-
-	msm_camera_io_w_mb((reg & (~mask)) | (value & mask), mdcbase);
-	usleep_range(10000, 11000);
-
-	reg = (msm_camera_io_r_mb(mdcbase)) & CAMIF_CFG_RMSK;
-	mask = CAM_PAD_REG_SW_RESET_BMSK;
-	value = 1 << CAM_PAD_REG_SW_RESET_SHFT;
-	msm_camera_io_w_mb((reg & (~mask)) | (value & mask), mdcbase);
-	usleep_range(10000, 11000);
-
-	reg = (msm_camera_io_r_mb(mdcbase)) & CAMIF_CFG_RMSK;
-	mask = CAM_PAD_REG_SW_RESET_BMSK;
-	value = 0 << CAM_PAD_REG_SW_RESET_SHFT;
-	msm_camera_io_w_mb((reg & (~mask)) | (value & mask), mdcbase);
-	usleep_range(10000, 11000);
-
-	msm_camio_clk_sel(MSM_CAMIO_CLK_SRC_EXTERNAL);
-	usleep_range(10000, 11000);
-}
-
-void msm_camio_vfe_blk_reset(void)
-{
-	uint32_t val;
-
-	/* do apps reset */
-	val = msm_camera_io_r_mb(appbase + 0x00000210);
-	val |= 0x1;
-	msm_camera_io_w_mb(val, appbase + 0x00000210);
-	usleep_range(10000, 11000);
-
-	val = msm_camera_io_r_mb(appbase + 0x00000210);
-	val &= ~0x1;
-	msm_camera_io_w_mb(val, appbase + 0x00000210);
-	usleep_range(10000, 11000);
-
-	/* do axi reset */
-	val = msm_camera_io_r_mb(appbase + 0x00000208);
-	val |= 0x1;
-	msm_camera_io_w_mb(val, appbase + 0x00000208);
-	usleep_range(10000, 11000);
-
-	val = msm_camera_io_r_mb(appbase + 0x00000208);
-	val &= ~0x1;
-	msm_camera_io_w_mb(val, appbase + 0x00000208);
-	usleep_range(10000, 11000);
-}
-
-void msm_camio_camif_pad_reg_reset_2(void)
-{
-	uint32_t reg;
-	uint32_t mask, value;
-
-	reg = (msm_camera_io_r_mb(mdcbase)) & CAMIF_CFG_RMSK;
-	mask = CAM_PAD_REG_SW_RESET_BMSK;
-	value = 1 << CAM_PAD_REG_SW_RESET_SHFT;
-	msm_camera_io_w_mb((reg & (~mask)) | (value & mask), mdcbase);
-	usleep_range(10000, 11000);
-
-	reg = (msm_camera_io_r_mb(mdcbase)) & CAMIF_CFG_RMSK;
-	mask = CAM_PAD_REG_SW_RESET_BMSK;
-	value = 0 << CAM_PAD_REG_SW_RESET_SHFT;
-	msm_camera_io_w_mb((reg & (~mask)) | (value & mask), mdcbase);
-	usleep_range(10000, 11000);
-}
-
-void msm_camio_clk_sel(enum msm_camio_clk_src_type srctype)
-{
-	struct clk *clk = NULL;
-
-	clk = camio_vfe_clk;
-
-	if (clk != NULL && clk != ERR_PTR(-ENOENT)) {
-		switch (srctype) {
-		case MSM_CAMIO_CLK_SRC_INTERNAL:
-			clk_set_flags(clk, 0x00000100 << 1);
-			break;
-
-		case MSM_CAMIO_CLK_SRC_EXTERNAL:
-			clk_set_flags(clk, 0x00000100);
-			break;
-
-		default:
-			break;
-		}
-	}
-}
-
-int msm_camio_probe_on(struct platform_device *pdev)
-{
-	struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-	camdev->camera_gpio_on();
-	return msm_camio_clk_enable(CAMIO_VFE_CLK);
-}
-
-int msm_camio_probe_off(struct platform_device *pdev)
-{
-	struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-	camdev->camera_gpio_off();
-	return msm_camio_clk_disable(CAMIO_VFE_CLK);
-}
diff --git a/drivers/media/platform/msm/camera_v1/io/msm_io8x.c b/drivers/media/platform/msm/camera_v1/io/msm_io8x.c
deleted file mode 100644
index dba93a0..0000000
--- a/drivers/media/platform/msm/camera_v1/io/msm_io8x.c
+++ /dev/null
@@ -1,331 +0,0 @@
-/* Copyright (c) 2009-2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/delay.h>
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <mach/gpio.h>
-#include <mach/board.h>
-#include <mach/camera.h>
-#include <mach/clk.h>
-
-#define CAMIF_CFG_RMSK 0x1fffff
-#define CAM_SEL_BMSK 0x2
-#define CAM_PCLK_SRC_SEL_BMSK 0x60000
-#define CAM_PCLK_INVERT_BMSK 0x80000
-#define CAM_PAD_REG_SW_RESET_BMSK 0x100000
-
-#define EXT_CAM_HSYNC_POL_SEL_BMSK 0x10000
-#define EXT_CAM_VSYNC_POL_SEL_BMSK 0x8000
-#define MDDI_CLK_CHICKEN_BIT_BMSK  0x80
-
-#define CAM_SEL_SHFT 0x1
-#define CAM_PCLK_SRC_SEL_SHFT 0x11
-#define CAM_PCLK_INVERT_SHFT 0x13
-#define CAM_PAD_REG_SW_RESET_SHFT 0x14
-
-#define EXT_CAM_HSYNC_POL_SEL_SHFT 0x10
-#define EXT_CAM_VSYNC_POL_SEL_SHFT 0xF
-#define MDDI_CLK_CHICKEN_BIT_SHFT  0x7
-#define APPS_RESET_OFFSET 0x00000214
-
-static struct clk *camio_vfe_mdc_clk;
-static struct clk *camio_mdc_clk;
-static struct clk *camio_vfe_clk;
-static struct clk *camio_vfe_axi_clk;
-static struct msm_camera_io_ext camio_ext;
-static struct resource *appio, *mdcio;
-
-void __iomem *appbase, *mdcbase;
-
-
-int msm_camio_clk_enable(enum msm_camio_clk_type clktype)
-{
-	int rc = 0;
-	struct clk *clk = NULL;
-
-	switch (clktype) {
-	case CAMIO_VFE_MDC_CLK:
-		camio_vfe_mdc_clk = clk = clk_get(NULL, "vfe_mdc_clk");
-		break;
-
-	case CAMIO_MDC_CLK:
-		camio_mdc_clk = clk = clk_get(NULL, "mdc_clk");
-		break;
-
-	case CAMIO_VFE_CLK:
-		camio_vfe_clk = clk = clk_get(NULL, "vfe_clk");
-		break;
-
-	case CAMIO_VFE_AXI_CLK:
-		camio_vfe_axi_clk = clk = clk_get(NULL, "vfe_axi_clk");
-		break;
-
-	default:
-		break;
-	}
-
-	if (!IS_ERR(clk))
-		clk_enable(clk);
-	else
-		rc = -1;
-
-	return rc;
-}
-
-int msm_camio_clk_disable(enum msm_camio_clk_type clktype)
-{
-	int rc = 0;
-	struct clk *clk = NULL;
-
-	switch (clktype) {
-	case CAMIO_VFE_MDC_CLK:
-		clk = camio_vfe_mdc_clk;
-		break;
-
-	case CAMIO_MDC_CLK:
-		clk = camio_mdc_clk;
-		break;
-
-	case CAMIO_VFE_CLK:
-		clk = camio_vfe_clk;
-		break;
-
-	case CAMIO_VFE_AXI_CLK:
-		clk = camio_vfe_axi_clk;
-		break;
-
-	default:
-		break;
-	}
-
-	if (!IS_ERR(clk)) {
-		clk_disable(clk);
-		clk_put(clk);
-	} else
-		rc = -1;
-
-	return rc;
-}
-
-void msm_camio_clk_rate_set(int rate)
-{
-	struct clk *clk = camio_vfe_mdc_clk;
-
-	/* TODO: check return */
-	clk_set_rate(clk, rate);
-}
-
-int msm_camio_enable(struct platform_device *pdev)
-{
-	int rc = 0;
-
-	appio = request_mem_region(camio_ext.appphy,
-		camio_ext.appsz, pdev->name);
-	if (!appio) {
-		rc = -EBUSY;
-		goto enable_fail;
-	}
-
-	appbase = ioremap(camio_ext.appphy, camio_ext.appsz);
-	if (!appbase) {
-		rc = -ENOMEM;
-		goto apps_no_mem;
-	}
-	msm_camio_clk_enable(CAMIO_MDC_CLK);
-	msm_camio_clk_enable(CAMIO_VFE_AXI_CLK);
-	return 0;
-
-apps_no_mem:
-	release_mem_region(camio_ext.appphy, camio_ext.appsz);
-enable_fail:
-	return rc;
-}
-
-void msm_camio_disable(struct platform_device *pdev)
-{
-	iounmap(appbase);
-	release_mem_region(camio_ext.appphy, camio_ext.appsz);
-	msm_camio_clk_disable(CAMIO_MDC_CLK);
-	msm_camio_clk_disable(CAMIO_VFE_AXI_CLK);
-}
-
-int msm_camio_sensor_clk_on(struct platform_device *pdev)
-{
-
-	struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-	int32_t rc = 0;
-	camio_ext = camdev->ioext;
-
-	mdcio = request_mem_region(camio_ext.mdcphy,
-		camio_ext.mdcsz, pdev->name);
-	if (!mdcio)
-		rc = -EBUSY;
-	mdcbase = ioremap(camio_ext.mdcphy,
-		camio_ext.mdcsz);
-	if (!mdcbase)
-		goto mdc_no_mem;
-	camdev->camera_gpio_on();
-
-	msm_camio_clk_enable(CAMIO_VFE_CLK);
-	msm_camio_clk_enable(CAMIO_VFE_MDC_CLK);
-	return rc;
-
-
-mdc_no_mem:
-	release_mem_region(camio_ext.mdcphy, camio_ext.mdcsz);
-	return -EINVAL;
-}
-
-int msm_camio_sensor_clk_off(struct platform_device *pdev)
-{
-	struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-	camdev->camera_gpio_off();
-	iounmap(mdcbase);
-	release_mem_region(camio_ext.mdcphy, camio_ext.mdcsz);
-	msm_camio_clk_disable(CAMIO_VFE_CLK);
-	return msm_camio_clk_disable(CAMIO_VFE_MDC_CLK);
-
-}
-
-void msm_disable_io_gpio_clk(struct platform_device *pdev)
-{
-	return;
-}
-
-void msm_camio_camif_pad_reg_reset(void)
-{
-	uint32_t reg;
-	uint32_t mask, value;
-
-	/* select CLKRGM_VFE_SRC_CAM_VFE_SRC:  internal source */
-	msm_camio_clk_sel(MSM_CAMIO_CLK_SRC_INTERNAL);
-
-	reg = (msm_camera_io_r_mb(mdcbase)) & CAMIF_CFG_RMSK;
-
-	mask = CAM_SEL_BMSK |
-		CAM_PCLK_SRC_SEL_BMSK |
-		CAM_PCLK_INVERT_BMSK |
-		EXT_CAM_HSYNC_POL_SEL_BMSK |
-	    EXT_CAM_VSYNC_POL_SEL_BMSK | MDDI_CLK_CHICKEN_BIT_BMSK;
-
-	value = 1 << CAM_SEL_SHFT |
-		3 << CAM_PCLK_SRC_SEL_SHFT |
-		0 << CAM_PCLK_INVERT_SHFT |
-		0 << EXT_CAM_HSYNC_POL_SEL_SHFT |
-	    0 << EXT_CAM_VSYNC_POL_SEL_SHFT | 0 << MDDI_CLK_CHICKEN_BIT_SHFT;
-	msm_camera_io_w_mb((reg & (~mask)) | (value & mask), mdcbase);
-	usleep_range(10000, 11000);
-
-	reg = (msm_camera_io_r_mb(mdcbase)) & CAMIF_CFG_RMSK;
-	mask = CAM_PAD_REG_SW_RESET_BMSK;
-	value = 1 << CAM_PAD_REG_SW_RESET_SHFT;
-	msm_camera_io_w_mb((reg & (~mask)) | (value & mask), mdcbase);
-	usleep_range(10000, 11000);
-
-	reg = (msm_camera_io_r_mb(mdcbase)) & CAMIF_CFG_RMSK;
-	mask = CAM_PAD_REG_SW_RESET_BMSK;
-	value = 0 << CAM_PAD_REG_SW_RESET_SHFT;
-	msm_camera_io_w_mb((reg & (~mask)) | (value & mask), mdcbase);
-	usleep_range(10000, 11000);
-
-	msm_camio_clk_sel(MSM_CAMIO_CLK_SRC_EXTERNAL);
-
-	usleep_range(10000, 11000);
-
-	/* todo: check return */
-	if (camio_vfe_clk)
-		clk_set_rate(camio_vfe_clk, 96000000);
-}
-
-void msm_camio_vfe_blk_reset(void)
-{
-	uint32_t val;
-
-	val = msm_camera_io_r_mb(appbase + APPS_RESET_OFFSET);
-	val |= 0x1;
-	msm_camera_io_w_mb(val, appbase + APPS_RESET_OFFSET);
-	usleep_range(10000, 11000);
-
-	val = msm_camera_io_r_mb(appbase + APPS_RESET_OFFSET);
-	val &= ~0x1;
-	msm_camera_io_w_mb(val, appbase + APPS_RESET_OFFSET);
-	usleep_range(10000, 11000);
-}
-
-void msm_camio_camif_pad_reg_reset_2(void)
-{
-	uint32_t reg;
-	uint32_t mask, value;
-
-	reg = (msm_camera_io_r_mb(mdcbase)) & CAMIF_CFG_RMSK;
-	mask = CAM_PAD_REG_SW_RESET_BMSK;
-	value = 1 << CAM_PAD_REG_SW_RESET_SHFT;
-	msm_camera_io_w_mb((reg & (~mask)) | (value & mask), mdcbase);
-	usleep_range(10000, 11000);
-
-	reg = (msm_camera_io_r_mb(mdcbase)) & CAMIF_CFG_RMSK;
-	mask = CAM_PAD_REG_SW_RESET_BMSK;
-	value = 0 << CAM_PAD_REG_SW_RESET_SHFT;
-	msm_camera_io_w_mb((reg & (~mask)) | (value & mask), mdcbase);
-	usleep_range(10000, 11000);
-}
-
-void msm_camio_clk_sel(enum msm_camio_clk_src_type srctype)
-{
-	struct clk *clk = NULL;
-
-	clk = camio_vfe_clk;
-
-	if (clk != NULL) {
-		switch (srctype) {
-		case MSM_CAMIO_CLK_SRC_INTERNAL:
-			clk_set_flags(clk, 0x00000100 << 1);
-			break;
-
-		case MSM_CAMIO_CLK_SRC_EXTERNAL:
-			clk_set_flags(clk, 0x00000100);
-			break;
-
-		default:
-			break;
-		}
-	}
-}
-
-void msm_camio_clk_axi_rate_set(int rate)
-{
-	struct clk *clk = camio_vfe_axi_clk;
-	/* todo: check return */
-	clk_set_rate(clk, rate);
-}
-
-int msm_camio_probe_on(struct platform_device *pdev)
-{
-	struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-
-	camdev->camera_gpio_on();
-	return msm_camio_clk_enable(CAMIO_VFE_MDC_CLK);
-}
-
-int msm_camio_probe_off(struct platform_device *pdev)
-{
-	struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-
-	camdev->camera_gpio_off();
-	return msm_camio_clk_disable(CAMIO_VFE_MDC_CLK);
-}
diff --git a/drivers/media/platform/msm/camera_v1/io/msm_io_7x27a.c b/drivers/media/platform/msm/camera_v1/io/msm_io_7x27a.c
deleted file mode 100644
index 6e70d37..0000000
--- a/drivers/media/platform/msm/camera_v1/io/msm_io_7x27a.c
+++ /dev/null
@@ -1,595 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-
-#include <linux/delay.h>
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <linux/pm_qos.h>
-#include <mach/board.h>
-#include <mach/camera.h>
-#include <mach/camera.h>
-#include <mach/clk.h>
-#include <mach/msm_bus.h>
-#include <mach/msm_bus_board.h>
-
-
-/* MIPI	CSI controller registers */
-#define	MIPI_PHY_CONTROL		0x00000000
-#define	MIPI_PROTOCOL_CONTROL		0x00000004
-#define	MIPI_INTERRUPT_STATUS		0x00000008
-#define	MIPI_INTERRUPT_MASK		0x0000000C
-#define	MIPI_CAMERA_CNTL		0x00000024
-#define	MIPI_CALIBRATION_CONTROL	0x00000018
-#define	MIPI_PHY_D0_CONTROL2		0x00000038
-#define	MIPI_PHY_D1_CONTROL2		0x0000003C
-#define	MIPI_PHY_D2_CONTROL2		0x00000040
-#define	MIPI_PHY_D3_CONTROL2		0x00000044
-#define	MIPI_PHY_CL_CONTROL		0x00000048
-#define	MIPI_PHY_D0_CONTROL		0x00000034
-#define	MIPI_PHY_D1_CONTROL		0x00000020
-#define	MIPI_PHY_D2_CONTROL		0x0000002C
-#define	MIPI_PHY_D3_CONTROL		0x00000030
-#define	MIPI_PWR_CNTL			0x00000054
-
-/*
- * MIPI_PROTOCOL_CONTROL register bits to enable/disable the features of
- * CSI Rx Block
- */
-
-/* DPCM scheme */
-#define	MIPI_PROTOCOL_CONTROL_DPCM_SCHEME_SHFT			0x1e
-/* SW_RST to issue a SW reset to the CSI core */
-#define	MIPI_PROTOCOL_CONTROL_SW_RST_BMSK			0x8000000
-/* To Capture Long packet Header Info in MIPI_PROTOCOL_STATUS register */
-#define	MIPI_PROTOCOL_CONTROL_LONG_PACKET_HEADER_CAPTURE_BMSK	0x200000
-/* Data format for unpacking purpose */
-#define	MIPI_PROTOCOL_CONTROL_DATA_FORMAT_SHFT			0x13
-/* Enable decoding of payload based on data type filed of packet hdr */
-#define	MIPI_PROTOCOL_CONTROL_DECODE_ID_BMSK			0x00000
-/* Enable error correction on packet headers */
-#define	MIPI_PROTOCOL_CONTROL_ECC_EN_BMSK			0x20000
-
-/*
- * MIPI_CALIBRATION_CONTROL register contains control info for
- * calibration impledence controller
-*/
-
-/* Enable bit for calibration pad */
-#define	MIPI_CALIBRATION_CONTROL_SWCAL_CAL_EN_SHFT		0x16
-/* With SWCAL_STRENGTH_OVERRIDE_EN, SW_CAL_EN and MANUAL_OVERRIDE_EN
- * the hardware calibration circuitry associated with CAL_SW_HW_MODE
- * is bypassed
-*/
-#define	MIPI_CALIBRATION_CONTROL_SWCAL_STRENGTH_OVERRIDE_EN_SHFT	0x15
-/* To indicate the Calibration process is in the control of HW/SW */
-#define	MIPI_CALIBRATION_CONTROL_CAL_SW_HW_MODE_SHFT		0x14
-/* When this is set the strength value of the data and clk lane impedence
- * termination is updated with MANUAL_STRENGTH settings and calibration
- * sensing logic is idle.
-*/
-#define	MIPI_CALIBRATION_CONTROL_MANUAL_OVERRIDE_EN_SHFT	0x7
-
-/* Data lane0 control */
-/* T-hs Settle count value  for Rx */
-#define	MIPI_PHY_D0_CONTROL2_SETTLE_COUNT_SHFT			0x18
-/* Rx termination control */
-#define	MIPI_PHY_D0_CONTROL2_HS_TERM_IMP_SHFT			0x10
-/* LP Rx enable */
-#define	MIPI_PHY_D0_CONTROL2_LP_REC_EN_SHFT			0x4
-/*
- * Enable for error in sync sequence
- * 1 - one bit error in sync seq
- * 0 - requires all 8 bit correct seq
-*/
-#define	MIPI_PHY_D0_CONTROL2_ERR_SOT_HS_EN_SHFT			0x3
-
-/* Comments are same as D0 */
-#define	MIPI_PHY_D1_CONTROL2_SETTLE_COUNT_SHFT			0x18
-#define	MIPI_PHY_D1_CONTROL2_HS_TERM_IMP_SHFT			0x10
-#define	MIPI_PHY_D1_CONTROL2_LP_REC_EN_SHFT			0x4
-#define	MIPI_PHY_D1_CONTROL2_ERR_SOT_HS_EN_SHFT			0x3
-
-/* Comments are same as D0 */
-#define	MIPI_PHY_D2_CONTROL2_SETTLE_COUNT_SHFT			0x18
-#define	MIPI_PHY_D2_CONTROL2_HS_TERM_IMP_SHFT			0x10
-#define	MIPI_PHY_D2_CONTROL2_LP_REC_EN_SHFT			0x4
-#define	MIPI_PHY_D2_CONTROL2_ERR_SOT_HS_EN_SHFT			0x3
-
-/* Comments are same as D0 */
-#define	MIPI_PHY_D3_CONTROL2_SETTLE_COUNT_SHFT			0x18
-#define	MIPI_PHY_D3_CONTROL2_HS_TERM_IMP_SHFT			0x10
-#define	MIPI_PHY_D3_CONTROL2_LP_REC_EN_SHFT			0x4
-#define	MIPI_PHY_D3_CONTROL2_ERR_SOT_HS_EN_SHFT			0x3
-
-/* PHY_CL_CTRL programs the parameters of clk lane of CSIRXPHY */
-/* HS Rx termination control */
-#define	MIPI_PHY_CL_CONTROL_HS_TERM_IMP_SHFT			0x18
-/* Start signal for T-hs delay */
-#define	MIPI_PHY_CL_CONTROL_LP_REC_EN_SHFT			0x2
-
-/* PHY DATA lane 0 control */
-/*
- * HS RX equalizer strength control
- * 00 - 0db 01 - 3db 10 - 5db 11 - 7db
-*/
-#define	MIPI_PHY_D0_CONTROL_HS_REC_EQ_SHFT			0x1c
-
-/* PHY DATA lane 1 control */
-/* Shutdown signal for MIPI clk phy line */
-#define	MIPI_PHY_D1_CONTROL_MIPI_CLK_PHY_SHUTDOWNB_SHFT		0x9
-/* Shutdown signal for MIPI data phy line */
-#define	MIPI_PHY_D1_CONTROL_MIPI_DATA_PHY_SHUTDOWNB_SHFT	0x8
-
-#define MSM_AXI_QOS_PREVIEW 200000
-#define MSM_AXI_QOS_SNAPSHOT 200000
-#define MSM_AXI_QOS_RECORDING 200000
-
-#define MIPI_PWR_CNTL_ENA	0x07
-#define MIPI_PWR_CNTL_DIS	0x0
-
-static struct clk *camio_cam_clk;
-static struct clk *camio_vfe_clk;
-static struct clk *camio_csi_src_clk;
-static struct clk *camio_csi0_vfe_clk;
-static struct clk *camio_csi1_vfe_clk;
-static struct clk *camio_csi0_clk;
-static struct clk *camio_csi1_clk;
-static struct clk *camio_csi0_pclk;
-static struct clk *camio_csi1_pclk;
-
-static struct msm_camera_io_ext camio_ext;
-static struct msm_camera_io_clk camio_clk;
-static struct platform_device *camio_dev;
-void __iomem *csibase;
-void __iomem *appbase;
-
-
-int msm_camio_vfe_clk_rate_set(int rate)
-{
-	int rc = 0;
-	struct clk *clk = camio_vfe_clk;
-	if (rate > clk_get_rate(clk))
-		rc = clk_set_rate(clk, rate);
-	return rc;
-}
-
-int msm_camio_clk_enable(enum msm_camio_clk_type clktype)
-{
-	int rc = 0;
-	struct clk *clk = NULL;
-
-	switch (clktype) {
-	case CAMIO_CAM_MCLK_CLK:
-		clk = clk_get(NULL, "cam_m_clk");
-		camio_cam_clk = clk;
-		msm_camio_clk_rate_set_2(clk, camio_clk.mclk_clk_rate);
-		break;
-	case CAMIO_VFE_CLK:
-		clk = clk_get(NULL, "vfe_clk");
-		camio_vfe_clk = clk;
-		msm_camio_clk_rate_set_2(clk, camio_clk.vfe_clk_rate);
-		break;
-	case CAMIO_CSI0_VFE_CLK:
-		clk = clk_get(&camio_dev->dev, "csi_vfe_clk");
-		camio_csi0_vfe_clk = clk;
-		break;
-	case CAMIO_CSI1_VFE_CLK:
-		clk = clk_get(NULL, "csi_vfe_clk");
-		camio_csi1_vfe_clk = clk;
-		break;
-	case CAMIO_CSI_SRC_CLK:
-		clk = clk_get(NULL, "csi_src_clk");
-		camio_csi_src_clk = clk;
-		break;
-	case CAMIO_CSI0_CLK:
-		clk = clk_get(&camio_dev->dev, "csi_clk");
-		camio_csi0_clk = clk;
-		msm_camio_clk_rate_set_2(clk, 400000000);
-		break;
-	case CAMIO_CSI1_CLK:
-		clk = clk_get(NULL, "csi_clk");
-		camio_csi1_clk = clk;
-		break;
-	case CAMIO_CSI0_PCLK:
-		clk = clk_get(&camio_dev->dev, "csi_pclk");
-		camio_csi0_pclk = clk;
-		break;
-	case CAMIO_CSI1_PCLK:
-		clk = clk_get(NULL, "csi_pclk");
-		camio_csi1_pclk = clk;
-		break;
-	default:
-		break;
-	}
-
-	if (!IS_ERR(clk))
-		clk_enable(clk);
-	else
-		rc = -1;
-	return rc;
-}
-
-int msm_camio_clk_disable(enum msm_camio_clk_type clktype)
-{
-	int rc = 0;
-	struct clk *clk = NULL;
-
-	switch (clktype) {
-	case CAMIO_CAM_MCLK_CLK:
-		clk = camio_cam_clk;
-		break;
-	case CAMIO_VFE_CLK:
-		clk = camio_vfe_clk;
-		break;
-	case CAMIO_CSI_SRC_CLK:
-		clk = camio_csi_src_clk;
-		break;
-	case CAMIO_CSI0_VFE_CLK:
-		clk = camio_csi0_vfe_clk;
-		break;
-	case CAMIO_CSI1_VFE_CLK:
-		clk = camio_csi1_vfe_clk;
-		break;
-	case CAMIO_CSI0_CLK:
-		clk = camio_csi0_clk;
-		break;
-	case CAMIO_CSI1_CLK:
-		clk = camio_csi1_clk;
-		break;
-	case CAMIO_CSI0_PCLK:
-		clk = camio_csi0_pclk;
-		break;
-	case CAMIO_CSI1_PCLK:
-		clk = camio_csi1_pclk;
-		break;
-	default:
-		break;
-	}
-
-	if (!IS_ERR(clk)) {
-		clk_disable(clk);
-		clk_put(clk);
-	} else
-		rc = -1;
-	return rc;
-}
-
-void msm_camio_clk_rate_set(int rate)
-{
-	struct clk *clk = camio_cam_clk;
-	clk_set_rate(clk, rate);
-}
-
-void msm_camio_clk_rate_set_2(struct clk *clk, int rate)
-{
-	clk_set_rate(clk, rate);
-}
-
-static irqreturn_t msm_io_csi_irq(int irq_num, void *data)
-{
-	uint32_t irq;
-
-	irq = msm_camera_io_r(csibase + MIPI_INTERRUPT_STATUS);
-	CDBG("%s MIPI_INTERRUPT_STATUS = 0x%x\n", __func__, irq);
-	msm_camera_io_w(irq, csibase + MIPI_INTERRUPT_STATUS);
-
-	/* TODO: Needs to send this info to upper layers */
-	if ((irq >> 19) & 0x1)
-		pr_info("Unsupported packet format is received\n");
-	return IRQ_HANDLED;
-}
-
-int msm_camio_enable(struct platform_device *pdev)
-{
-	int rc = 0;
-	const struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-	uint32_t val;
-
-	camio_dev = pdev;
-	camio_ext = camdev->ioext;
-	camio_clk = camdev->ioclk;
-
-	msm_camio_clk_enable(CAMIO_VFE_CLK);
-	msm_camio_clk_enable(CAMIO_CSI0_VFE_CLK);
-	msm_camio_clk_enable(CAMIO_CSI1_VFE_CLK);
-	msm_camio_clk_enable(CAMIO_CSI0_CLK);
-	msm_camio_clk_enable(CAMIO_CSI1_CLK);
-	msm_camio_clk_enable(CAMIO_CSI0_PCLK);
-	msm_camio_clk_enable(CAMIO_CSI1_PCLK);
-
-	csibase = ioremap(camio_ext.csiphy, camio_ext.csisz);
-	if (!csibase) {
-		rc = -ENOMEM;
-		goto csi_busy;
-	}
-	rc = request_irq(camio_ext.csiirq, msm_io_csi_irq,
-				IRQF_TRIGGER_RISING, "csi", 0);
-	if (rc < 0)
-		goto csi_irq_fail;
-
-	msleep(20);
-	val = (20 <<
-		MIPI_PHY_D0_CONTROL2_SETTLE_COUNT_SHFT) |
-		(0x0F << MIPI_PHY_D0_CONTROL2_HS_TERM_IMP_SHFT) |
-		(0x0 << MIPI_PHY_D0_CONTROL2_LP_REC_EN_SHFT) |
-		(0x1 << MIPI_PHY_D0_CONTROL2_ERR_SOT_HS_EN_SHFT);
-	CDBG("%s MIPI_PHY_D0_CONTROL2 val=0x%x\n", __func__, val);
-	msm_camera_io_w(val, csibase + MIPI_PHY_D0_CONTROL2);
-	msm_camera_io_w(val, csibase + MIPI_PHY_D1_CONTROL2);
-	msm_camera_io_w(val, csibase + MIPI_PHY_D2_CONTROL2);
-	msm_camera_io_w(val, csibase + MIPI_PHY_D3_CONTROL2);
-
-	val = (0x0F << MIPI_PHY_CL_CONTROL_HS_TERM_IMP_SHFT) |
-		(0x0 << MIPI_PHY_CL_CONTROL_LP_REC_EN_SHFT);
-	CDBG("%s MIPI_PHY_CL_CONTROL val=0x%x\n", __func__, val);
-	msm_camera_io_w(val, csibase + MIPI_PHY_CL_CONTROL);
-
-	appbase = ioremap(camio_ext.appphy,
-		camio_ext.appsz);
-	if (!appbase) {
-		rc = -ENOMEM;
-		goto csi_irq_fail;
-	}
-	return 0;
-
-csi_irq_fail:
-	iounmap(csibase);
-csi_busy:
-	msm_camio_clk_disable(CAMIO_CAM_MCLK_CLK);
-	msm_camio_clk_disable(CAMIO_VFE_CLK);
-	msm_camio_clk_disable(CAMIO_CSI0_VFE_CLK);
-	msm_camio_clk_disable(CAMIO_CSI1_VFE_CLK);
-	msm_camio_clk_disable(CAMIO_CSI0_CLK);
-	msm_camio_clk_disable(CAMIO_CSI1_CLK);
-	msm_camio_clk_disable(CAMIO_CSI0_PCLK);
-	msm_camio_clk_disable(CAMIO_CSI1_PCLK);
-	camdev->camera_gpio_off();
-	return rc;
-}
-
-void msm_camio_disable(struct platform_device *pdev)
-{
-	uint32_t val;
-
-	val = (20 <<
-		MIPI_PHY_D0_CONTROL2_SETTLE_COUNT_SHFT) |
-		(0x0F << MIPI_PHY_D0_CONTROL2_HS_TERM_IMP_SHFT) |
-		(0x0 << MIPI_PHY_D0_CONTROL2_LP_REC_EN_SHFT) |
-		(0x1 << MIPI_PHY_D0_CONTROL2_ERR_SOT_HS_EN_SHFT);
-	CDBG("%s MIPI_PHY_D0_CONTROL2 val=0x%x\n", __func__, val);
-	msm_camera_io_w(val, csibase + MIPI_PHY_D0_CONTROL2);
-	msm_camera_io_w(val, csibase + MIPI_PHY_D1_CONTROL2);
-	msm_camera_io_w(val, csibase + MIPI_PHY_D2_CONTROL2);
-	msm_camera_io_w(val, csibase + MIPI_PHY_D3_CONTROL2);
-
-	val = (0x0F << MIPI_PHY_CL_CONTROL_HS_TERM_IMP_SHFT) |
-		(0x0 << MIPI_PHY_CL_CONTROL_LP_REC_EN_SHFT);
-	CDBG("%s MIPI_PHY_CL_CONTROL val=0x%x\n", __func__, val);
-	msm_camera_io_w(val, csibase + MIPI_PHY_CL_CONTROL);
-	msleep(20);
-
-	free_irq(camio_ext.csiirq, 0);
-	iounmap(csibase);
-	iounmap(appbase);
-	CDBG("disable clocks\n");
-
-	msm_camio_clk_disable(CAMIO_VFE_CLK);
-	msm_camio_clk_disable(CAMIO_CSI0_CLK);
-	msm_camio_clk_disable(CAMIO_CSI1_CLK);
-	msm_camio_clk_disable(CAMIO_CSI0_VFE_CLK);
-	msm_camio_clk_disable(CAMIO_CSI1_VFE_CLK);
-	msm_camio_clk_disable(CAMIO_CSI0_PCLK);
-	msm_camio_clk_disable(CAMIO_CSI1_PCLK);
-}
-
-int msm_camio_sensor_clk_on(struct platform_device *pdev)
-{
-	int rc = 0;
-	const struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-	camio_dev = pdev;
-	camio_ext = camdev->ioext;
-	camio_clk = camdev->ioclk;
-
-	rc = camdev->camera_gpio_on();
-	if (rc < 0)
-		return rc;
-	return msm_camio_clk_enable(CAMIO_CAM_MCLK_CLK);
-}
-
-int msm_camio_sensor_clk_off(struct platform_device *pdev)
-{
-	const struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-	camdev->camera_gpio_off();
-	return msm_camio_clk_disable(CAMIO_CAM_MCLK_CLK);
-
-}
-
-void msm_camio_vfe_blk_reset(void)
-{
-	uint32_t val;
-
-	/* do apps reset */
-	val = msm_camera_io_r(appbase + 0x00000210);
-	val |= 0x1;
-	msm_camera_io_w(val, appbase + 0x00000210);
-	usleep_range(10000, 11000);
-
-	val = msm_camera_io_r(appbase + 0x00000210);
-	val &= ~0x1;
-	msm_camera_io_w(val, appbase + 0x00000210);
-	usleep_range(10000, 11000);
-
-	/* do axi reset */
-	val = msm_camera_io_r(appbase + 0x00000208);
-	val |= 0x1;
-	msm_camera_io_w(val, appbase + 0x00000208);
-	usleep_range(10000, 11000);
-
-	val = msm_camera_io_r(appbase + 0x00000208);
-	val &= ~0x1;
-	msm_camera_io_w(val, appbase + 0x00000208);
-	mb();
-	usleep_range(10000, 11000);
-	return;
-}
-
-int msm_camio_probe_on(struct platform_device *pdev)
-{
-	int rc = 0;
-	const struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-	camio_dev = pdev;
-	camio_ext = camdev->ioext;
-	camio_clk = camdev->ioclk;
-
-	msm_camio_clk_enable(CAMIO_CSI0_PCLK);
-	msm_camio_clk_enable(CAMIO_CSI1_PCLK);
-
-	rc = camdev->camera_gpio_on();
-	if (rc < 0)
-		return rc;
-	return msm_camio_clk_enable(CAMIO_CAM_MCLK_CLK);
-}
-
-int msm_camio_probe_off(struct platform_device *pdev)
-{
-	const struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-	camdev->camera_gpio_off();
-
-	csibase = ioremap(camdev->ioext.csiphy, camdev->ioext.csisz);
-	if (!csibase) {
-		pr_err("ioremap failed for CSIBASE\n");
-		goto ioremap_fail;
-	}
-	msm_camera_io_w(MIPI_PWR_CNTL_DIS, csibase + MIPI_PWR_CNTL);
-	iounmap(csibase);
-ioremap_fail:
-	msm_camio_clk_disable(CAMIO_CSI0_PCLK);
-	msm_camio_clk_disable(CAMIO_CSI1_PCLK);
-	return msm_camio_clk_disable(CAMIO_CAM_MCLK_CLK);
-}
-
-int msm_camio_csi_config(struct msm_camera_csi_params *csi_params)
-{
-	int rc = 0;
-	uint32_t val = 0;
-
-	CDBG("msm_camio_csi_config\n");
-
-	/* Enable error correction for DATA lane. Applies to all data lanes */
-	msm_camera_io_w(0x4, csibase + MIPI_PHY_CONTROL);
-
-	msm_camera_io_w(MIPI_PROTOCOL_CONTROL_SW_RST_BMSK,
-		csibase + MIPI_PROTOCOL_CONTROL);
-
-	val = MIPI_PROTOCOL_CONTROL_LONG_PACKET_HEADER_CAPTURE_BMSK |
-		MIPI_PROTOCOL_CONTROL_DECODE_ID_BMSK |
-		MIPI_PROTOCOL_CONTROL_ECC_EN_BMSK;
-	val |= (uint32_t)(csi_params->data_format) <<
-		MIPI_PROTOCOL_CONTROL_DATA_FORMAT_SHFT;
-	val |= csi_params->dpcm_scheme <<
-		MIPI_PROTOCOL_CONTROL_DPCM_SCHEME_SHFT;
-	CDBG("%s MIPI_PROTOCOL_CONTROL val=0x%x\n", __func__, val);
-	msm_camera_io_w(val, csibase + MIPI_PROTOCOL_CONTROL);
-
-	val = (0x1 << MIPI_CALIBRATION_CONTROL_SWCAL_CAL_EN_SHFT) |
-		(0x1 <<
-		MIPI_CALIBRATION_CONTROL_SWCAL_STRENGTH_OVERRIDE_EN_SHFT) |
-		(0x1 << MIPI_CALIBRATION_CONTROL_CAL_SW_HW_MODE_SHFT) |
-		(0x1 << MIPI_CALIBRATION_CONTROL_MANUAL_OVERRIDE_EN_SHFT);
-	CDBG("%s MIPI_CALIBRATION_CONTROL val=0x%x\n", __func__, val);
-	msm_camera_io_w(val, csibase + MIPI_CALIBRATION_CONTROL);
-
-	val = (csi_params->settle_cnt <<
-		MIPI_PHY_D0_CONTROL2_SETTLE_COUNT_SHFT) |
-		(0x0F << MIPI_PHY_D0_CONTROL2_HS_TERM_IMP_SHFT) |
-		(0x1 << MIPI_PHY_D0_CONTROL2_LP_REC_EN_SHFT) |
-		(0x1 << MIPI_PHY_D0_CONTROL2_ERR_SOT_HS_EN_SHFT);
-	CDBG("%s MIPI_PHY_D0_CONTROL2 val=0x%x\n", __func__, val);
-	msm_camera_io_w(val, csibase + MIPI_PHY_D0_CONTROL2);
-	msm_camera_io_w(val, csibase + MIPI_PHY_D1_CONTROL2);
-	msm_camera_io_w(val, csibase + MIPI_PHY_D2_CONTROL2);
-	msm_camera_io_w(val, csibase + MIPI_PHY_D3_CONTROL2);
-
-
-	val = (0x0F << MIPI_PHY_CL_CONTROL_HS_TERM_IMP_SHFT) |
-		(0x1 << MIPI_PHY_CL_CONTROL_LP_REC_EN_SHFT);
-	CDBG("%s MIPI_PHY_CL_CONTROL val=0x%x\n", __func__, val);
-	msm_camera_io_w(val, csibase + MIPI_PHY_CL_CONTROL);
-
-	val = 0 << MIPI_PHY_D0_CONTROL_HS_REC_EQ_SHFT;
-	msm_camera_io_w(val, csibase + MIPI_PHY_D0_CONTROL);
-
-	val = (0x1 << MIPI_PHY_D1_CONTROL_MIPI_CLK_PHY_SHUTDOWNB_SHFT) |
-		(0x1 << MIPI_PHY_D1_CONTROL_MIPI_DATA_PHY_SHUTDOWNB_SHFT);
-	CDBG("%s MIPI_PHY_D1_CONTROL val=0x%x\n", __func__, val);
-	msm_camera_io_w(val, csibase + MIPI_PHY_D1_CONTROL);
-
-	msm_camera_io_w(0x00000000, csibase + MIPI_PHY_D2_CONTROL);
-	msm_camera_io_w(0x00000000, csibase + MIPI_PHY_D3_CONTROL);
-
-	/* program number of lanes and lane mapping */
-	switch (csi_params->lane_cnt) {
-	case 1:
-		msm_camera_io_w(csi_params->lane_assign << 8 | 0x4,
-			csibase + MIPI_CAMERA_CNTL);
-		break;
-	case 2:
-		msm_camera_io_w(csi_params->lane_assign << 8 | 0x5,
-			csibase + MIPI_CAMERA_CNTL);
-		break;
-	case 3:
-		msm_camera_io_w(csi_params->lane_assign << 8 | 0x6,
-			csibase + MIPI_CAMERA_CNTL);
-		break;
-	case 4:
-		msm_camera_io_w(csi_params->lane_assign << 8 | 0x7,
-			csibase + MIPI_CAMERA_CNTL);
-		break;
-	}
-
-	msm_camera_io_w(0xFFFFF3FF, csibase + MIPI_INTERRUPT_MASK);
-	/*clear IRQ bits - write 1 clears the status*/
-	msm_camera_io_w(0xFFFFF3FF, csibase + MIPI_INTERRUPT_STATUS);
-
-	return rc;
-}
-
-void msm_camio_set_perf_lvl(enum msm_bus_perf_setting perf_setting)
-{
-	switch (perf_setting) {
-	case S_INIT:
-		add_axi_qos();
-		break;
-	case S_PREVIEW:
-		update_axi_qos(MSM_AXI_QOS_PREVIEW);
-		break;
-	case S_VIDEO:
-		update_axi_qos(MSM_AXI_QOS_RECORDING);
-		break;
-	case S_CAPTURE:
-		update_axi_qos(MSM_AXI_QOS_SNAPSHOT);
-		break;
-	case S_DEFAULT:
-		update_axi_qos(PM_QOS_DEFAULT_VALUE);
-		break;
-	case S_EXIT:
-		release_axi_qos();
-		break;
-	default:
-		CDBG("%s: INVALID CASE\n", __func__);
-	}
-}
diff --git a/drivers/media/platform/msm/camera_v1/io/msm_io_7x27a_v4l2.c b/drivers/media/platform/msm/camera_v1/io/msm_io_7x27a_v4l2.c
deleted file mode 100644
index 6d2a11d..0000000
--- a/drivers/media/platform/msm/camera_v1/io/msm_io_7x27a_v4l2.c
+++ /dev/null
@@ -1,218 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#include <linux/delay.h>
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <linux/pm_qos.h>
-#include <linux/module.h>
-#include <mach/board.h>
-#include <mach/camera.h>
-#include <mach/camera.h>
-#include <mach/clk.h>
-#include <mach/msm_bus.h>
-#include <mach/msm_bus_board.h>
-#include <mach/dal_axi.h>
-
-#define MSM_AXI_QOS_PREVIEW 200000
-#define MSM_AXI_QOS_SNAPSHOT 200000
-#define MSM_AXI_QOS_RECORDING 200000
-
-static struct clk *camio_cam_clk;
-static struct resource *clk_ctrl_mem;
-static struct msm_camera_io_clk camio_clk;
-static int apps_reset;
-void __iomem *appbase;
-
-void msm_camio_clk_rate_set_2(struct clk *clk, int rate)
-{
-	clk_set_rate(clk, rate);
-}
-int msm_camio_clk_enable(enum msm_camio_clk_type clktype)
-{
-	int rc = 0;
-	struct clk *clk = NULL;
-
-	switch (clktype) {
-	case CAMIO_CAM_MCLK_CLK:
-		clk = clk_get(NULL, "cam_m_clk");
-		camio_cam_clk = clk;
-		msm_camio_clk_rate_set_2(clk, camio_clk.mclk_clk_rate);
-		break;
-	default:
-		break;
-	}
-
-	if (!IS_ERR(clk))
-		clk_enable(clk);
-	else
-		rc = -1;
-	return rc;
-}
-
-int msm_camio_clk_disable(enum msm_camio_clk_type clktype)
-{
-	int rc = 0;
-	struct clk *clk = NULL;
-
-	switch (clktype) {
-	case CAMIO_CAM_MCLK_CLK:
-		clk = camio_cam_clk;
-		break;
-	default:
-		break;
-	}
-
-	if (!IS_ERR(clk)) {
-		clk_disable(clk);
-		clk_put(clk);
-	} else
-		rc = -1;
-	return rc;
-}
-
-void msm_camio_clk_rate_set(int rate)
-{
-	struct clk *clk = camio_cam_clk;
-	clk_set_rate(clk, rate);
-}
-
-void msm_camio_vfe_blk_reset_2(void)
-{
-	uint32_t val;
-
-	/* do apps reset */
-	val = readl_relaxed(appbase + 0x00000210);
-	val |= 0x1;
-	writel_relaxed(val, appbase + 0x00000210);
-	usleep_range(10000, 11000);
-
-	val = readl_relaxed(appbase + 0x00000210);
-	val &= ~0x1;
-	writel_relaxed(val, appbase + 0x00000210);
-	usleep_range(10000, 11000);
-
-	/* do axi reset */
-	val = readl_relaxed(appbase + 0x00000208);
-	val |= 0x1;
-	writel_relaxed(val, appbase + 0x00000208);
-	usleep_range(10000, 11000);
-
-	val = readl_relaxed(appbase + 0x00000208);
-	val &= ~0x1;
-	writel_relaxed(val, appbase + 0x00000208);
-	mb();
-	usleep_range(10000, 11000);
-}
-
-void msm_camio_vfe_blk_reset_3(void)
-{
-	uint32_t val;
-
-	if (!apps_reset)
-		return;
-
-	/* do apps reset */
-	val = readl_relaxed(appbase + 0x00000210);
-	val |= 0x10A0000;
-	writel_relaxed(val, appbase + 0x00000210);
-	usleep_range(10000, 11000);
-
-	val = readl_relaxed(appbase + 0x00000210);
-	val &= ~(0x10A0000);
-	writel_relaxed(val, appbase + 0x00000210);
-	usleep_range(10000, 11000);
-	mb();
-}
-
-void msm_camio_set_perf_lvl(enum msm_bus_perf_setting perf_setting)
-{
-	switch (perf_setting) {
-	case S_INIT:
-		add_axi_qos();
-		update_axi_qos(MSM_AXI_QOS_PREVIEW);
-		axi_allocate(AXI_FLOW_VIEWFINDER_HI);
-		break;
-	case S_PREVIEW:
-		break;
-	case S_VIDEO:
-		break;
-	case S_CAPTURE:
-		break;
-	case S_DEFAULT:
-		break;
-	case S_EXIT:
-		axi_free(AXI_FLOW_VIEWFINDER_HI);
-		release_axi_qos();
-		break;
-	default:
-		CDBG("%s: INVALID CASE\n", __func__);
-	}
-}
-
-static int __devinit clkctl_probe(struct platform_device *pdev)
-{
-	int rc = 0;
-
-	apps_reset = *(int *)pdev->dev.platform_data;
-	clk_ctrl_mem = platform_get_resource_byname(pdev,
-					IORESOURCE_MEM, "clk_ctl");
-	if (!clk_ctrl_mem) {
-		pr_err("%s: no mem resource:3?\n", __func__);
-		return -ENODEV;
-	}
-
-	appbase = ioremap(clk_ctrl_mem->start,
-		resource_size(clk_ctrl_mem));
-	if (!appbase) {
-		pr_err("clkctl_probe: appbase:err\n");
-		rc = -ENOMEM;
-		goto ioremap_fail;
-	}
-	return 0;
-
-ioremap_fail:
-	msm_camio_clk_disable(CAMIO_CAM_MCLK_CLK);
-	return rc;
-}
-
-static int clkctl_remove(struct platform_device *pdev)
-{
-	if (clk_ctrl_mem)
-		iounmap(clk_ctrl_mem);
-
-	return 0;
-}
-
-static struct platform_driver clkctl_driver = {
-	.probe  = clkctl_probe,
-	.remove = clkctl_remove,
-	.driver = {
-		.name = "msm_clk_ctl",
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init msm_clkctl_init_module(void)
-{
-	return platform_driver_register(&clkctl_driver);
-}
-
-static void __exit msm_clkctl_exit_module(void)
-{
-	platform_driver_unregister(&clkctl_driver);
-}
-
-module_init(msm_clkctl_init_module);
-module_exit(msm_clkctl_exit_module);
-MODULE_DESCRIPTION("CAM IO driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/io/msm_io_8960.c b/drivers/media/platform/msm/camera_v1/io/msm_io_8960.c
deleted file mode 100644
index 6dc4fa4..0000000
--- a/drivers/media/platform/msm/camera_v1/io/msm_io_8960.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-
-#include <linux/delay.h>
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <linux/regulator/consumer.h>
-#include <linux/mfd/pm8xxx/pm8921.h>
-#include <mach/gpio.h>
-#include <mach/gpiomux.h>
-#include <mach/board.h>
-#include <mach/camera.h>
-#include <mach/vreg.h>
-#include <mach/camera.h>
-#include <mach/clk.h>
-#include <mach/msm_bus.h>
-#include <mach/msm_bus_board.h>
-
-#define BUFF_SIZE_128 128
-
-void msm_camio_clk_rate_set_2(struct clk *clk, int rate)
-{
-	clk_set_rate(clk, rate);
-}
-
-void msm_camio_bus_scale_cfg(struct msm_bus_scale_pdata *cam_bus_scale_table,
-		enum msm_bus_perf_setting perf_setting)
-{
-	static uint32_t bus_perf_client;
-	int rc = 0;
-	switch (perf_setting) {
-	case S_INIT:
-		bus_perf_client =
-			msm_bus_scale_register_client(cam_bus_scale_table);
-		if (!bus_perf_client) {
-			CDBG("%s: Registration Failed!!!\n", __func__);
-			bus_perf_client = 0;
-			return;
-		}
-		CDBG("%s: S_INIT rc = %u\n", __func__, bus_perf_client);
-		break;
-	case S_EXIT:
-		if (bus_perf_client) {
-			CDBG("%s: S_EXIT\n", __func__);
-			msm_bus_scale_unregister_client(bus_perf_client);
-		} else
-			CDBG("%s: Bus Client NOT Registered!!!\n", __func__);
-		break;
-	case S_PREVIEW:
-		if (bus_perf_client) {
-			rc = msm_bus_scale_client_update_request(
-				bus_perf_client, 1);
-			CDBG("%s: S_PREVIEW rc = %d\n", __func__, rc);
-		} else
-			CDBG("%s: Bus Client NOT Registered!!!\n", __func__);
-		break;
-	case S_VIDEO:
-		if (bus_perf_client) {
-			rc = msm_bus_scale_client_update_request(
-				bus_perf_client, 2);
-			CDBG("%s: S_VIDEO rc = %d\n", __func__, rc);
-		} else
-			CDBG("%s: Bus Client NOT Registered!!!\n", __func__);
-		break;
-	case S_CAPTURE:
-		if (bus_perf_client) {
-			rc = msm_bus_scale_client_update_request(
-				bus_perf_client, 3);
-			CDBG("%s: S_CAPTURE rc = %d\n", __func__, rc);
-		} else
-			CDBG("%s: Bus Client NOT Registered!!!\n", __func__);
-		break;
-	case S_ZSL:
-		if (bus_perf_client) {
-			rc = msm_bus_scale_client_update_request(
-				bus_perf_client, 4);
-			CDBG("%s: S_ZSL rc = %d\n", __func__, rc);
-		} else
-			CDBG("%s: Bus Client NOT Registered!!!\n", __func__);
-		break;
-	case S_LIVESHOT:
-		if (bus_perf_client) {
-			rc = msm_bus_scale_client_update_request(
-				bus_perf_client, 5);
-			CDBG("%s: S_LIVESHOT rc = %d\n", __func__, rc);
-		} else
-			CDBG("%s: Bus Client NOT Registered!!!\n", __func__);
-		break;
-	case S_DUAL:
-		if (bus_perf_client) {
-			rc = msm_bus_scale_client_update_request(
-				bus_perf_client, 6);
-			CDBG("%s: S_DUAL rc = %d\n", __func__, rc);
-		} else
-			CDBG("%s: Bus Client NOT Registered!!!\n", __func__);
-		break;
-	case S_ADV_VIDEO:
-		if (bus_perf_client) {
-			rc = msm_bus_scale_client_update_request(
-				bus_perf_client, 7);
-			CDBG("%s: S_ADV_VIDEO rc = %d\n", __func__, rc);
-		} else
-			CDBG("%s: Bus Client NOT Registered!!!\n", __func__);
-		break;
-	case S_DEFAULT:
-		break;
-	default:
-		pr_warning("%s: INVALID CASE\n", __func__);
-	}
-}
diff --git a/drivers/media/platform/msm/camera_v1/io/msm_io_8x60.c b/drivers/media/platform/msm/camera_v1/io/msm_io_8x60.c
deleted file mode 100644
index 6896538..0000000
--- a/drivers/media/platform/msm/camera_v1/io/msm_io_8x60.c
+++ /dev/null
@@ -1,820 +0,0 @@
-/* Copyright (c) 2010-2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/delay.h>
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <linux/regulator/consumer.h>
-#include <mach/gpio.h>
-#include <mach/board.h>
-#include <mach/camera.h>
-#include <mach/vreg.h>
-#include <mach/camera.h>
-#include <mach/clk.h>
-#include <mach/msm_bus.h>
-#include <mach/msm_bus_board.h>
-
-
-/* MIPI	CSI	controller registers */
-#define	MIPI_PHY_CONTROL			0x00000000
-#define	MIPI_PROTOCOL_CONTROL		0x00000004
-#define	MIPI_INTERRUPT_STATUS		0x00000008
-#define	MIPI_INTERRUPT_MASK			0x0000000C
-#define	MIPI_CAMERA_CNTL			0x00000024
-#define	MIPI_CALIBRATION_CONTROL	0x00000018
-#define	MIPI_PHY_D0_CONTROL2		0x00000038
-#define	MIPI_PHY_D1_CONTROL2		0x0000003C
-#define	MIPI_PHY_D2_CONTROL2		0x00000040
-#define	MIPI_PHY_D3_CONTROL2		0x00000044
-#define	MIPI_PHY_CL_CONTROL			0x00000048
-#define	MIPI_PHY_D0_CONTROL			0x00000034
-#define	MIPI_PHY_D1_CONTROL			0x00000020
-#define	MIPI_PHY_D2_CONTROL			0x0000002C
-#define	MIPI_PHY_D3_CONTROL			0x00000030
-#define	MIPI_PROTOCOL_CONTROL_SW_RST_BMSK			0x8000000
-#define	MIPI_PROTOCOL_CONTROL_LONG_PACKET_HEADER_CAPTURE_BMSK	0x200000
-#define	MIPI_PROTOCOL_CONTROL_DATA_FORMAT_BMSK			0x180000
-#define	MIPI_PROTOCOL_CONTROL_DECODE_ID_BMSK			0x40000
-#define	MIPI_PROTOCOL_CONTROL_ECC_EN_BMSK			0x20000
-#define	MIPI_CALIBRATION_CONTROL_SWCAL_CAL_EN_SHFT		0x16
-#define	MIPI_CALIBRATION_CONTROL_SWCAL_STRENGTH_OVERRIDE_EN_SHFT	0x15
-#define	MIPI_CALIBRATION_CONTROL_CAL_SW_HW_MODE_SHFT		0x14
-#define	MIPI_CALIBRATION_CONTROL_MANUAL_OVERRIDE_EN_SHFT	0x7
-#define	MIPI_PROTOCOL_CONTROL_DATA_FORMAT_SHFT			0x13
-#define	MIPI_PROTOCOL_CONTROL_DPCM_SCHEME_SHFT			0x1e
-#define	MIPI_PHY_D0_CONTROL2_SETTLE_COUNT_SHFT			0x18
-#define	MIPI_PHY_D0_CONTROL2_HS_TERM_IMP_SHFT			0x10
-#define	MIPI_PHY_D0_CONTROL2_LP_REC_EN_SHFT				0x4
-#define	MIPI_PHY_D0_CONTROL2_ERR_SOT_HS_EN_SHFT			0x3
-#define	MIPI_PHY_D1_CONTROL2_SETTLE_COUNT_SHFT			0x18
-#define	MIPI_PHY_D1_CONTROL2_HS_TERM_IMP_SHFT			0x10
-#define	MIPI_PHY_D1_CONTROL2_LP_REC_EN_SHFT				0x4
-#define	MIPI_PHY_D1_CONTROL2_ERR_SOT_HS_EN_SHFT			0x3
-#define	MIPI_PHY_D2_CONTROL2_SETTLE_COUNT_SHFT			0x18
-#define	MIPI_PHY_D2_CONTROL2_HS_TERM_IMP_SHFT			0x10
-#define	MIPI_PHY_D2_CONTROL2_LP_REC_EN_SHFT				0x4
-#define	MIPI_PHY_D2_CONTROL2_ERR_SOT_HS_EN_SHFT			0x3
-#define	MIPI_PHY_D3_CONTROL2_SETTLE_COUNT_SHFT			0x18
-#define	MIPI_PHY_D3_CONTROL2_HS_TERM_IMP_SHFT			0x10
-#define	MIPI_PHY_D3_CONTROL2_LP_REC_EN_SHFT				0x4
-#define	MIPI_PHY_D3_CONTROL2_ERR_SOT_HS_EN_SHFT			0x3
-#define	MIPI_PHY_CL_CONTROL_HS_TERM_IMP_SHFT			0x18
-#define	MIPI_PHY_CL_CONTROL_LP_REC_EN_SHFT				0x2
-#define	MIPI_PHY_D0_CONTROL_HS_REC_EQ_SHFT				0x1c
-#define	MIPI_PHY_D1_CONTROL_MIPI_CLK_PHY_SHUTDOWNB_SHFT		0x9
-#define	MIPI_PHY_D1_CONTROL_MIPI_DATA_PHY_SHUTDOWNB_SHFT	0x8
-#define	DBG_CSI	0
-
-static struct clk *camio_cam_clk;
-static struct clk *camio_vfe_clk;
-static struct clk *camio_csi_src_clk;
-static struct clk *camio_csi0_vfe_clk;
-static struct clk *camio_csi1_vfe_clk;
-static struct clk *camio_csi0_clk;
-static struct clk *camio_csi1_clk;
-static struct clk *camio_csi0_pclk;
-static struct clk *camio_csi1_pclk;
-static struct clk *camio_vfe_pclk;
-static struct clk *camio_vpe_clk;
-static struct clk *camio_vpe_pclk;
-static struct regulator *fs_vfe;
-static struct regulator *fs_vpe;
-static struct regulator *ldo15;
-static struct regulator *lvs0;
-static struct regulator *ldo25;
-
-static struct msm_camera_io_ext camio_ext;
-static struct msm_camera_io_clk camio_clk;
-static struct platform_device *camio_dev;
-static struct resource *csiio;
-void __iomem *csibase;
-static int vpe_clk_rate;
-struct msm_bus_scale_pdata *cam_bus_scale_table;
-
-static void msm_camera_vreg_enable(void)
-{
-	ldo15 = regulator_get(NULL, "8058_l15");
-	if (IS_ERR(ldo15)) {
-		pr_err("%s: VREG LDO15 get failed\n", __func__);
-		ldo15 = NULL;
-		return;
-	}
-	if (regulator_set_voltage(ldo15, 2850000, 2850000)) {
-		pr_err("%s: VREG LDO15 set voltage failed\n",  __func__);
-		goto ldo15_disable;
-	}
-	if (regulator_enable(ldo15)) {
-		pr_err("%s: VREG LDO15 enable failed\n", __func__);
-		goto ldo15_put;
-	}
-
-	lvs0 = regulator_get(NULL, "8058_lvs0");
-	if (IS_ERR(lvs0)) {
-		pr_err("%s: VREG LVS0 get failed\n", __func__);
-		lvs0 = NULL;
-		goto ldo15_disable;
-	}
-	if (regulator_enable(lvs0)) {
-		pr_err("%s: VREG LVS0 enable failed\n", __func__);
-		goto lvs0_put;
-	}
-
-	ldo25 = regulator_get(NULL, "8058_l25");
-	if (IS_ERR(ldo25)) {
-		pr_err("%s: VREG LDO25 get failed\n", __func__);
-		ldo25 = NULL;
-		goto lvs0_disable;
-	}
-	if (regulator_set_voltage(ldo25, 1200000, 1200000)) {
-		pr_err("%s: VREG LDO25 set voltage failed\n",  __func__);
-		goto ldo25_disable;
-	}
-	if (regulator_enable(ldo25)) {
-		pr_err("%s: VREG LDO25 enable failed\n", __func__);
-		goto ldo25_put;
-	}
-
-	fs_vfe = regulator_get(NULL, "fs_vfe");
-	if (IS_ERR(fs_vfe)) {
-		CDBG("%s: Regulator FS_VFE get failed %ld\n", __func__,
-			PTR_ERR(fs_vfe));
-		fs_vfe = NULL;
-	} else if (regulator_enable(fs_vfe)) {
-		CDBG("%s: Regulator FS_VFE enable failed\n", __func__);
-		regulator_put(fs_vfe);
-	}
-	return;
-
-ldo25_disable:
-	regulator_disable(ldo25);
-ldo25_put:
-	regulator_put(ldo25);
-lvs0_disable:
-	regulator_disable(lvs0);
-lvs0_put:
-	regulator_put(lvs0);
-ldo15_disable:
-	regulator_disable(ldo15);
-ldo15_put:
-	regulator_put(ldo15);
-}
-
-static void msm_camera_vreg_disable(void)
-{
-	if (ldo15) {
-		regulator_disable(ldo15);
-		regulator_put(ldo15);
-	}
-
-	if (lvs0) {
-		regulator_disable(lvs0);
-		regulator_put(lvs0);
-	}
-
-	if (ldo25) {
-		regulator_disable(ldo25);
-		regulator_put(ldo25);
-	}
-
-	if (fs_vfe) {
-		regulator_disable(fs_vfe);
-		regulator_put(fs_vfe);
-	}
-}
-
-int msm_camio_clk_enable(enum msm_camio_clk_type clktype)
-{
-	int rc = 0;
-	struct clk *clk = NULL;
-
-	switch (clktype) {
-	case CAMIO_CAM_MCLK_CLK:
-		camio_cam_clk =
-		clk = clk_get(NULL, "cam_clk");
-		msm_camio_clk_rate_set_2(clk, camio_clk.mclk_clk_rate);
-		break;
-
-	case CAMIO_VFE_CLK:
-		camio_vfe_clk =
-		clk = clk_get(NULL, "vfe_clk");
-		msm_camio_clk_rate_set_2(clk, camio_clk.vfe_clk_rate);
-		break;
-
-	case CAMIO_CSI0_VFE_CLK:
-		camio_csi0_vfe_clk =
-		clk = clk_get(NULL, "csi_vfe_clk");
-		break;
-
-	case CAMIO_CSI1_VFE_CLK:
-		camio_csi1_vfe_clk =
-		clk = clk_get(&camio_dev->dev, "csi_vfe_clk");
-		break;
-
-	case CAMIO_CSI_SRC_CLK:
-		camio_csi_src_clk =
-		clk = clk_get(NULL, "csi_src_clk");
-		msm_camio_clk_rate_set_2(clk, 384000000);
-		break;
-
-	case CAMIO_CSI0_CLK:
-		camio_csi0_clk =
-		clk = clk_get(NULL, "csi_clk");
-		break;
-
-	case CAMIO_CSI1_CLK:
-		camio_csi1_clk =
-		clk = clk_get(&camio_dev->dev, "csi_clk");
-		break;
-
-	case CAMIO_VFE_PCLK:
-		camio_vfe_pclk =
-		clk = clk_get(NULL, "vfe_pclk");
-		break;
-
-	case CAMIO_CSI0_PCLK:
-		camio_csi0_pclk =
-		clk = clk_get(NULL, "csi_pclk");
-		break;
-
-	case CAMIO_CSI1_PCLK:
-		camio_csi1_pclk =
-		clk = clk_get(&camio_dev->dev, "csi_pclk");
-		break;
-
-	case CAMIO_VPE_CLK:
-		camio_vpe_clk =
-		clk = clk_get(NULL, "vpe_clk");
-		vpe_clk_rate = clk_round_rate(camio_vpe_clk, vpe_clk_rate);
-		clk_set_rate(camio_vpe_clk, vpe_clk_rate);
-		break;
-
-	case CAMIO_VPE_PCLK:
-		camio_vpe_pclk =
-		clk = clk_get(NULL, "vpe_pclk");
-		break;
-
-	default:
-		break;
-	}
-
-	if (!IS_ERR(clk))
-		clk_enable(clk);
-	else
-		rc = -1;
-	return rc;
-}
-
-int msm_camio_clk_disable(enum msm_camio_clk_type clktype)
-{
-	int rc = 0;
-	struct clk *clk = NULL;
-
-	switch (clktype) {
-	case CAMIO_CAM_MCLK_CLK:
-		clk = camio_cam_clk;
-		break;
-
-	case CAMIO_VFE_CLK:
-		clk = camio_vfe_clk;
-		break;
-
-	case CAMIO_CSI_SRC_CLK:
-		clk = camio_csi_src_clk;
-		break;
-
-	case CAMIO_CSI0_VFE_CLK:
-		clk = camio_csi0_vfe_clk;
-		break;
-
-	case CAMIO_CSI1_VFE_CLK:
-		clk = camio_csi1_vfe_clk;
-		break;
-
-	case CAMIO_CSI0_CLK:
-		clk = camio_csi0_clk;
-		break;
-
-	case CAMIO_CSI1_CLK:
-		clk = camio_csi1_clk;
-		break;
-
-	case CAMIO_VFE_PCLK:
-		clk = camio_vfe_pclk;
-		break;
-
-	case CAMIO_CSI0_PCLK:
-		clk = camio_csi0_pclk;
-		break;
-
-	case CAMIO_CSI1_PCLK:
-		clk = camio_csi1_pclk;
-		break;
-
-	case CAMIO_VPE_CLK:
-		clk = camio_vpe_clk;
-		break;
-
-	case CAMIO_VPE_PCLK:
-		clk = camio_vpe_pclk;
-		break;
-
-	default:
-		break;
-	}
-
-	if (!IS_ERR(clk)) {
-		clk_disable(clk);
-		clk_put(clk);
-	} else
-		rc = -1;
-	return rc;
-}
-
-int msm_camio_vfe_clk_rate_set(int rate)
-{
-	int rc = 0;
-	struct clk *clk = camio_vfe_clk;
-	if (rate > clk_get_rate(clk))
-		rc = clk_set_rate(clk, rate);
-	return rc;
-}
-
-void msm_camio_clk_rate_set(int rate)
-{
-	struct clk *clk = camio_cam_clk;
-	clk_set_rate(clk, rate);
-}
-
-void msm_camio_clk_rate_set_2(struct clk *clk, int rate)
-{
-	clk_set_rate(clk, rate);
-}
-
-static irqreturn_t msm_io_csi_irq(int irq_num, void *data)
-{
-	uint32_t irq = 0;
-	if (csibase != NULL)
-		irq = msm_camera_io_r(csibase + MIPI_INTERRUPT_STATUS);
-	CDBG("%s MIPI_INTERRUPT_STATUS = 0x%x\n", __func__, irq);
-	if (csibase != NULL)
-		msm_camera_io_w(irq, csibase + MIPI_INTERRUPT_STATUS);
-	return IRQ_HANDLED;
-}
-
-int msm_camio_vpe_clk_disable(void)
-{
-	int rc = 0;
-	if (fs_vpe) {
-		regulator_disable(fs_vpe);
-		regulator_put(fs_vpe);
-	}
-
-	rc = msm_camio_clk_disable(CAMIO_VPE_CLK);
-	if (rc < 0)
-		return rc;
-	rc = msm_camio_clk_disable(CAMIO_VPE_PCLK);
-	return rc;
-}
-
-int msm_camio_vpe_clk_enable(uint32_t clk_rate)
-{
-	int rc = 0;
-	fs_vpe = regulator_get(NULL, "fs_vpe");
-	if (IS_ERR(fs_vpe)) {
-		CDBG("%s: Regulator FS_VPE get failed %ld\n", __func__,
-			PTR_ERR(fs_vpe));
-		fs_vpe = NULL;
-	} else if (regulator_enable(fs_vpe)) {
-		CDBG("%s: Regulator FS_VPE enable failed\n", __func__);
-		regulator_put(fs_vpe);
-	}
-
-	vpe_clk_rate = clk_rate;
-	rc = msm_camio_clk_enable(CAMIO_VPE_CLK);
-	if (rc < 0)
-		return rc;
-
-	rc = msm_camio_clk_enable(CAMIO_VPE_PCLK);
-	return rc;
-}
-
-#ifdef DBG_CSI
-static int csi_request_irq(void)
-{
-	return request_irq(camio_ext.csiirq, msm_io_csi_irq,
-		IRQF_TRIGGER_HIGH, "csi", 0);
-}
-#else
-static int csi_request_irq(void) { return 0; }
-#endif
-
-#ifdef DBG_CSI
-static void csi_free_irq(void)
-{
-	free_irq(camio_ext.csiirq, 0);
-}
-#else
-static void csi_free_irq(void) { return 0; }
-#endif
-
-int msm_camio_enable(struct platform_device *pdev)
-{
-	int rc = 0;
-	struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-	camio_dev = pdev;
-	camio_ext = camdev->ioext;
-	camio_clk = camdev->ioclk;
-	cam_bus_scale_table = camdev->cam_bus_scale_table;
-
-	msm_camio_clk_enable(CAMIO_VFE_CLK);
-	msm_camio_clk_enable(CAMIO_CSI0_VFE_CLK);
-	msm_camio_clk_enable(CAMIO_CSI1_VFE_CLK);
-	msm_camio_clk_enable(CAMIO_CSI_SRC_CLK);
-	msm_camio_clk_enable(CAMIO_CSI0_CLK);
-	msm_camio_clk_enable(CAMIO_CSI1_CLK);
-	msm_camio_clk_enable(CAMIO_VFE_PCLK);
-	msm_camio_clk_enable(CAMIO_CSI0_PCLK);
-	msm_camio_clk_enable(CAMIO_CSI1_PCLK);
-
-	csiio = request_mem_region(camio_ext.csiphy,
-		camio_ext.csisz, pdev->name);
-	if (!csiio) {
-		rc = -EBUSY;
-		goto common_fail;
-	}
-	csibase = ioremap(camio_ext.csiphy,
-		camio_ext.csisz);
-	if (!csibase) {
-		rc = -ENOMEM;
-		goto csi_busy;
-	}
-	rc = csi_request_irq();
-	if (rc < 0)
-		goto csi_irq_fail;
-
-	return 0;
-
-csi_irq_fail:
-	iounmap(csibase);
-	csibase = NULL;
-csi_busy:
-	release_mem_region(camio_ext.csiphy, camio_ext.csisz);
-	csibase = NULL;
-common_fail:
-	msm_camio_clk_disable(CAMIO_CAM_MCLK_CLK);
-	msm_camio_clk_disable(CAMIO_CSI0_VFE_CLK);
-	msm_camio_clk_disable(CAMIO_CSI0_CLK);
-	msm_camio_clk_disable(CAMIO_CSI1_VFE_CLK);
-	msm_camio_clk_disable(CAMIO_CSI1_CLK);
-	msm_camio_clk_disable(CAMIO_VFE_PCLK);
-	msm_camio_clk_disable(CAMIO_CSI0_PCLK);
-	msm_camio_clk_disable(CAMIO_CSI1_PCLK);
-	msm_camera_vreg_disable();
-	camdev->camera_gpio_off();
-	return rc;
-}
-
-static void msm_camio_csi_disable(void)
-{
-	uint32_t val;
-
-	val = 0x0;
-	if (csibase != NULL) {
-		CDBG("%s MIPI_PHY_D0_CONTROL2 val=0x%x\n", __func__, val);
-		msm_camera_io_w(val, csibase + MIPI_PHY_D0_CONTROL2);
-		msm_camera_io_w(val, csibase + MIPI_PHY_D1_CONTROL2);
-		msm_camera_io_w(val, csibase + MIPI_PHY_D2_CONTROL2);
-		msm_camera_io_w(val, csibase + MIPI_PHY_D3_CONTROL2);
-		CDBG("%s MIPI_PHY_CL_CONTROL val=0x%x\n", __func__, val);
-		msm_camera_io_w(val, csibase + MIPI_PHY_CL_CONTROL);
-		msleep(20);
-		val = msm_camera_io_r(csibase + MIPI_PHY_D1_CONTROL);
-		val &=
-		~((0x1 << MIPI_PHY_D1_CONTROL_MIPI_CLK_PHY_SHUTDOWNB_SHFT)
-		|(0x1 << MIPI_PHY_D1_CONTROL_MIPI_DATA_PHY_SHUTDOWNB_SHFT));
-		CDBG("%s MIPI_PHY_D1_CONTROL val=0x%x\n", __func__, val);
-		msm_camera_io_w(val, csibase + MIPI_PHY_D1_CONTROL);
-		usleep_range(5000, 6000);
-		msm_camera_io_w(0x0, csibase + MIPI_INTERRUPT_MASK);
-		msm_camera_io_w(0x0, csibase + MIPI_INTERRUPT_STATUS);
-		csi_free_irq();
-		iounmap(csibase);
-		csibase = NULL;
-		release_mem_region(camio_ext.csiphy, camio_ext.csisz);
-	}
-}
-void msm_camio_disable(struct platform_device *pdev)
-{
-	CDBG("disable mipi\n");
-	msm_camio_csi_disable();
-	CDBG("disable clocks\n");
-	msm_camio_clk_disable(CAMIO_CSI0_VFE_CLK);
-	msm_camio_clk_disable(CAMIO_CSI0_CLK);
-	msm_camio_clk_disable(CAMIO_CSI1_VFE_CLK);
-	msm_camio_clk_disable(CAMIO_CSI1_CLK);
-	msm_camio_clk_disable(CAMIO_VFE_PCLK);
-	msm_camio_clk_disable(CAMIO_CSI0_PCLK);
-	msm_camio_clk_disable(CAMIO_CSI1_PCLK);
-	msm_camio_clk_disable(CAMIO_CSI_SRC_CLK);
-	msm_camio_clk_disable(CAMIO_VFE_CLK);
-}
-
-int msm_camio_sensor_clk_on(struct platform_device *pdev)
-{
-	int rc = 0;
-	struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-	camio_dev = pdev;
-	camio_ext = camdev->ioext;
-	camio_clk = camdev->ioclk;
-
-	msm_camera_vreg_enable();
-	usleep_range(10000, 11000);
-	rc = camdev->camera_gpio_on();
-	if (rc < 0)
-		return rc;
-	return msm_camio_clk_enable(CAMIO_CAM_MCLK_CLK);
-}
-
-int msm_camio_sensor_clk_off(struct platform_device *pdev)
-{
-	struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-	msm_camera_vreg_disable();
-	camdev->camera_gpio_off();
-	return msm_camio_clk_disable(CAMIO_CAM_MCLK_CLK);
-
-}
-
-void msm_camio_vfe_blk_reset(void)
-{
-	return;
-}
-
-int msm_camio_probe_on(struct platform_device *pdev)
-{
-	int rc = 0;
-	struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-	camio_dev = pdev;
-	camio_ext = camdev->ioext;
-	camio_clk = camdev->ioclk;
-
-	rc = camdev->camera_gpio_on();
-	if (rc < 0)
-		return rc;
-	msm_camera_vreg_enable();
-	return msm_camio_clk_enable(CAMIO_CAM_MCLK_CLK);
-}
-
-int msm_camio_probe_off(struct platform_device *pdev)
-{
-	struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-	msm_camera_vreg_disable();
-	camdev->camera_gpio_off();
-	return msm_camio_clk_disable(CAMIO_CAM_MCLK_CLK);
-}
-
-int msm_camio_csi_config(struct msm_camera_csi_params *csi_params)
-{
-	int rc = 0;
-	uint32_t val = 0;
-	int i;
-
-	CDBG("msm_camio_csi_config\n");
-	if (csibase != NULL) {
-		/* SOT_ECC_EN enable error correction for SYNC (data-lane) */
-		msm_camera_io_w(0x4, csibase + MIPI_PHY_CONTROL);
-
-		/* SW_RST to the CSI core */
-		msm_camera_io_w(MIPI_PROTOCOL_CONTROL_SW_RST_BMSK,
-		csibase + MIPI_PROTOCOL_CONTROL);
-
-		/* PROTOCOL CONTROL */
-		val = MIPI_PROTOCOL_CONTROL_LONG_PACKET_HEADER_CAPTURE_BMSK |
-			MIPI_PROTOCOL_CONTROL_DECODE_ID_BMSK |
-			MIPI_PROTOCOL_CONTROL_ECC_EN_BMSK;
-		val |= (uint32_t)(csi_params->data_format) <<
-			MIPI_PROTOCOL_CONTROL_DATA_FORMAT_SHFT;
-		val |= csi_params->dpcm_scheme <<
-			MIPI_PROTOCOL_CONTROL_DPCM_SCHEME_SHFT;
-		CDBG("%s MIPI_PROTOCOL_CONTROL val=0x%x\n", __func__, val);
-		msm_camera_io_w(val, csibase + MIPI_PROTOCOL_CONTROL);
-
-		/* settle_cnt is very sensitive to speed!
-		increase this value to run at higher speeds */
-		val = (csi_params->settle_cnt <<
-			MIPI_PHY_D0_CONTROL2_SETTLE_COUNT_SHFT) |
-			(0x0F << MIPI_PHY_D0_CONTROL2_HS_TERM_IMP_SHFT) |
-			(0x1 << MIPI_PHY_D0_CONTROL2_LP_REC_EN_SHFT) |
-			(0x1 << MIPI_PHY_D0_CONTROL2_ERR_SOT_HS_EN_SHFT);
-		CDBG("%s MIPI_PHY_D0_CONTROL2 val=0x%x\n", __func__, val);
-		for (i = 0; i < csi_params->lane_cnt; i++)
-			msm_camera_io_w(val,
-				csibase + MIPI_PHY_D0_CONTROL2 + i * 4);
-
-		val = (0x0F << MIPI_PHY_CL_CONTROL_HS_TERM_IMP_SHFT) |
-			(0x1 << MIPI_PHY_CL_CONTROL_LP_REC_EN_SHFT);
-		CDBG("%s MIPI_PHY_CL_CONTROL val=0x%x\n", __func__, val);
-		msm_camera_io_w(val, csibase + MIPI_PHY_CL_CONTROL);
-
-		val = 0 << MIPI_PHY_D0_CONTROL_HS_REC_EQ_SHFT;
-		msm_camera_io_w(val, csibase + MIPI_PHY_D0_CONTROL);
-
-		val =
-		(0x1 << MIPI_PHY_D1_CONTROL_MIPI_CLK_PHY_SHUTDOWNB_SHFT)
-		|(0x1 << MIPI_PHY_D1_CONTROL_MIPI_DATA_PHY_SHUTDOWNB_SHFT);
-		CDBG("%s MIPI_PHY_D1_CONTROL val=0x%x\n", __func__, val);
-		msm_camera_io_w(val, csibase + MIPI_PHY_D1_CONTROL);
-
-		msm_camera_io_w(0x00000000, csibase + MIPI_PHY_D2_CONTROL);
-		msm_camera_io_w(0x00000000, csibase + MIPI_PHY_D3_CONTROL);
-
-		/* halcyon only supports 1 or 2 lane */
-		switch (csi_params->lane_cnt) {
-		case 1:
-			msm_camera_io_w(csi_params->lane_assign << 8 | 0x4,
-				csibase + MIPI_CAMERA_CNTL);
-			break;
-		case 2:
-			msm_camera_io_w(csi_params->lane_assign << 8 | 0x5,
-				csibase + MIPI_CAMERA_CNTL);
-			break;
-		case 3:
-			msm_camera_io_w(csi_params->lane_assign << 8 | 0x6,
-				csibase + MIPI_CAMERA_CNTL);
-			break;
-		case 4:
-			msm_camera_io_w(csi_params->lane_assign << 8 | 0x7,
-				csibase + MIPI_CAMERA_CNTL);
-			break;
-		}
-
-		/* mask out ID_ERROR[19], DATA_CMM_ERR[11]
-		and CLK_CMM_ERR[10] - de-featured */
-		msm_camera_io_w(0xF017F3C0, csibase + MIPI_INTERRUPT_MASK);
-		/*clear IRQ bits*/
-		msm_camera_io_w(0xF017F3C0, csibase + MIPI_INTERRUPT_STATUS);
-	} else {
-		pr_info("CSIBASE is NULL");
-	}
-
-	return rc;
-}
-
-void msm_camio_set_perf_lvl(enum msm_bus_perf_setting perf_setting)
-{
-	static uint32_t bus_perf_client;
-	int rc = 0;
-	switch (perf_setting) {
-	case S_INIT:
-		bus_perf_client =
-			msm_bus_scale_register_client(cam_bus_scale_table);
-		if (!bus_perf_client) {
-			pr_err("%s: Registration Failed!!!\n", __func__);
-			bus_perf_client = 0;
-			return;
-		}
-		CDBG("%s: S_INIT rc = %u\n", __func__, bus_perf_client);
-		break;
-	case S_EXIT:
-		if (bus_perf_client) {
-			CDBG("%s: S_EXIT\n", __func__);
-			msm_bus_scale_unregister_client(bus_perf_client);
-		} else
-			pr_err("%s: Bus Client NOT Registered!!!\n", __func__);
-		break;
-	case S_PREVIEW:
-		if (bus_perf_client) {
-			rc = msm_bus_scale_client_update_request(
-				bus_perf_client, 1);
-			CDBG("%s: S_PREVIEW rc = %d\n", __func__, rc);
-		} else
-			pr_err("%s: Bus Client NOT Registered!!!\n", __func__);
-		break;
-	case S_VIDEO:
-		if (bus_perf_client) {
-			rc = msm_bus_scale_client_update_request(
-				bus_perf_client, 2);
-			CDBG("%s: S_VIDEO rc = %d\n", __func__, rc);
-		} else
-			pr_err("%s: Bus Client NOT Registered!!!\n", __func__);
-		break;
-	case S_CAPTURE:
-		if (bus_perf_client) {
-			rc = msm_bus_scale_client_update_request(
-				bus_perf_client, 3);
-			CDBG("%s: S_CAPTURE rc = %d\n", __func__, rc);
-		} else
-			pr_err("%s: Bus Client NOT Registered!!!\n", __func__);
-		break;
-
-	case S_ZSL:
-		if (bus_perf_client) {
-			rc = msm_bus_scale_client_update_request(
-				bus_perf_client, 4);
-			CDBG("%s: S_ZSL rc = %d\n", __func__, rc);
-		} else
-			pr_err("%s: Bus Client NOT Registered!!!\n", __func__);
-		break;
-	case S_STEREO_VIDEO:
-		if (bus_perf_client) {
-			rc = msm_bus_scale_client_update_request(
-				bus_perf_client, 5);
-			CDBG("%s: S_STEREO_VIDEO rc = %d\n", __func__, rc);
-		} else
-			pr_err("%s: Bus Client NOT Registered!!!\n", __func__);
-		break;
-	case S_STEREO_CAPTURE:
-		if (bus_perf_client) {
-			rc = msm_bus_scale_client_update_request(
-				bus_perf_client, 6);
-			CDBG("%s: S_STEREO_VIDEO rc = %d\n", __func__, rc);
-		} else
-			pr_err("%s: Bus Client NOT Registered!!!\n", __func__);
-		break;
-	case S_DEFAULT:
-		break;
-	default:
-		pr_warning("%s: INVALID CASE\n", __func__);
-	}
-}
-
-int msm_cam_core_reset(void)
-{
-	struct clk *clk1;
-	int rc = 0;
-	clk1 = clk_get(&camio_dev->dev, "csi_vfe_clk");
-	if (IS_ERR(clk1)) {
-		pr_err("%s: did not get csi_vfe_clk\n", __func__);
-		return PTR_ERR(clk1);
-	}
-	rc = clk_reset(clk1, CLK_RESET_ASSERT);
-	if (rc) {
-		pr_err("%s:csi_vfe_clk assert failed\n", __func__);
-		clk_put(clk1);
-		return rc;
-	}
-	usleep_range(1000, 1200);
-	rc = clk_reset(clk1, CLK_RESET_DEASSERT);
-	if (rc) {
-		pr_err("%s:csi_vfe_clk deassert failed\n", __func__);
-		clk_put(clk1);
-		return rc;
-	}
-	clk_put(clk1);
-
-	clk1 = clk_get(&camio_dev->dev, "csi_clk");
-	if (IS_ERR(clk1)) {
-		pr_err("%s: did not get csi_clk\n", __func__);
-		return PTR_ERR(clk1);
-	}
-	rc = clk_reset(clk1, CLK_RESET_ASSERT);
-	if (rc) {
-		pr_err("%s:csi_clk assert failed\n", __func__);
-		clk_put(clk1);
-		return rc;
-	}
-	usleep_range(1000, 1200);
-	rc = clk_reset(clk1, CLK_RESET_DEASSERT);
-	if (rc) {
-		pr_err("%s:csi_clk deassert failed\n", __func__);
-		clk_put(clk1);
-		return rc;
-	}
-	clk_put(clk1);
-
-	clk1 = clk_get(&camio_dev->dev, "csi_pclk");
-	if (IS_ERR(clk1)) {
-		pr_err("%s: did not get csi_pclk\n", __func__);
-		return PTR_ERR(clk1);
-	}
-	rc = clk_reset(clk1, CLK_RESET_ASSERT);
-	if (rc) {
-		pr_err("%s:csi_pclk assert failed\n", __func__);
-		clk_put(clk1);
-		return rc;
-	}
-	usleep_range(1000, 1200);
-	rc = clk_reset(clk1, CLK_RESET_DEASSERT);
-	if (rc) {
-		pr_err("%s:csi_pclk deassert failed\n", __func__);
-		clk_put(clk1);
-		return rc;
-	}
-	clk_put(clk1);
-
-	return rc;
-}
diff --git a/drivers/media/platform/msm/camera_v1/io/msm_io_vfe31.c b/drivers/media/platform/msm/camera_v1/io/msm_io_vfe31.c
deleted file mode 100644
index 1cd2782..0000000
--- a/drivers/media/platform/msm/camera_v1/io/msm_io_vfe31.c
+++ /dev/null
@@ -1,776 +0,0 @@
-/* Copyright (c) 2010-2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/delay.h>
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <linux/pm_qos.h>
-#include <linux/regulator/consumer.h>
-#include <mach/gpio.h>
-#include <mach/board.h>
-#include <mach/camera.h>
-#include <mach/vreg.h>
-#include <mach/clk.h>
-
-#define CAMIF_CFG_RMSK             0x1fffff
-#define CAM_SEL_BMSK               0x2
-#define CAM_PCLK_SRC_SEL_BMSK      0x60000
-#define CAM_PCLK_INVERT_BMSK       0x80000
-#define CAM_PAD_REG_SW_RESET_BMSK  0x100000
-
-#define EXT_CAM_HSYNC_POL_SEL_BMSK 0x10000
-#define EXT_CAM_VSYNC_POL_SEL_BMSK 0x8000
-#define MDDI_CLK_CHICKEN_BIT_BMSK  0x80
-
-#define CAM_SEL_SHFT               0x1
-#define CAM_PCLK_SRC_SEL_SHFT      0x11
-#define CAM_PCLK_INVERT_SHFT       0x13
-#define CAM_PAD_REG_SW_RESET_SHFT  0x14
-
-#define EXT_CAM_HSYNC_POL_SEL_SHFT 0x10
-#define EXT_CAM_VSYNC_POL_SEL_SHFT 0xF
-#define MDDI_CLK_CHICKEN_BIT_SHFT  0x7
-
-/* MIPI	CSI	controller registers */
-#define	MIPI_PHY_CONTROL			0x00000000
-#define	MIPI_PROTOCOL_CONTROL		0x00000004
-#define	MIPI_INTERRUPT_STATUS		0x00000008
-#define	MIPI_INTERRUPT_MASK			0x0000000C
-#define	MIPI_CAMERA_CNTL			0x00000024
-#define	MIPI_CALIBRATION_CONTROL	0x00000018
-#define	MIPI_PHY_D0_CONTROL2		0x00000038
-#define	MIPI_PHY_D1_CONTROL2		0x0000003C
-#define	MIPI_PHY_D2_CONTROL2		0x00000040
-#define	MIPI_PHY_D3_CONTROL2		0x00000044
-#define	MIPI_PHY_CL_CONTROL			0x00000048
-#define	MIPI_PHY_D0_CONTROL			0x00000034
-#define	MIPI_PHY_D1_CONTROL			0x00000020
-#define	MIPI_PHY_D2_CONTROL			0x0000002C
-#define	MIPI_PHY_D3_CONTROL			0x00000030
-#define	MIPI_PROTOCOL_CONTROL_SW_RST_BMSK			0x8000000
-#define	MIPI_PROTOCOL_CONTROL_LONG_PACKET_HEADER_CAPTURE_BMSK	0x200000
-#define	MIPI_PROTOCOL_CONTROL_DATA_FORMAT_BMSK			0x180000
-#define	MIPI_PROTOCOL_CONTROL_DECODE_ID_BMSK			0x40000
-#define	MIPI_PROTOCOL_CONTROL_ECC_EN_BMSK			0x20000
-#define	MIPI_CALIBRATION_CONTROL_SWCAL_CAL_EN_SHFT		0x16
-#define	MIPI_CALIBRATION_CONTROL_SWCAL_STRENGTH_OVERRIDE_EN_SHFT	0x15
-#define	MIPI_CALIBRATION_CONTROL_CAL_SW_HW_MODE_SHFT		0x14
-#define	MIPI_CALIBRATION_CONTROL_MANUAL_OVERRIDE_EN_SHFT	0x7
-#define	MIPI_PROTOCOL_CONTROL_DATA_FORMAT_SHFT			0x13
-#define	MIPI_PROTOCOL_CONTROL_DPCM_SCHEME_SHFT			0x1e
-#define	MIPI_PHY_D0_CONTROL2_SETTLE_COUNT_SHFT			0x18
-#define	MIPI_PHY_D0_CONTROL2_HS_TERM_IMP_SHFT			0x10
-#define	MIPI_PHY_D0_CONTROL2_LP_REC_EN_SHFT				0x4
-#define	MIPI_PHY_D0_CONTROL2_ERR_SOT_HS_EN_SHFT			0x3
-#define	MIPI_PHY_D1_CONTROL2_SETTLE_COUNT_SHFT			0x18
-#define	MIPI_PHY_D1_CONTROL2_HS_TERM_IMP_SHFT			0x10
-#define	MIPI_PHY_D1_CONTROL2_LP_REC_EN_SHFT				0x4
-#define	MIPI_PHY_D1_CONTROL2_ERR_SOT_HS_EN_SHFT			0x3
-#define	MIPI_PHY_D2_CONTROL2_SETTLE_COUNT_SHFT			0x18
-#define	MIPI_PHY_D2_CONTROL2_HS_TERM_IMP_SHFT			0x10
-#define	MIPI_PHY_D2_CONTROL2_LP_REC_EN_SHFT				0x4
-#define	MIPI_PHY_D2_CONTROL2_ERR_SOT_HS_EN_SHFT			0x3
-#define	MIPI_PHY_D3_CONTROL2_SETTLE_COUNT_SHFT			0x18
-#define	MIPI_PHY_D3_CONTROL2_HS_TERM_IMP_SHFT			0x10
-#define	MIPI_PHY_D3_CONTROL2_LP_REC_EN_SHFT				0x4
-#define	MIPI_PHY_D3_CONTROL2_ERR_SOT_HS_EN_SHFT			0x3
-#define	MIPI_PHY_CL_CONTROL_HS_TERM_IMP_SHFT			0x18
-#define	MIPI_PHY_CL_CONTROL_LP_REC_EN_SHFT				0x2
-#define	MIPI_PHY_D0_CONTROL_HS_REC_EQ_SHFT				0x1c
-#define	MIPI_PHY_D1_CONTROL_MIPI_CLK_PHY_SHUTDOWNB_SHFT		0x9
-#define	MIPI_PHY_D1_CONTROL_MIPI_DATA_PHY_SHUTDOWNB_SHFT	0x8
-
-#define	CAMIO_VFE_CLK_SNAP			122880000
-#define	CAMIO_VFE_CLK_PREV			122880000
-
-/* AXI rates in KHz */
-#define MSM_AXI_QOS_PREVIEW     192000
-#define MSM_AXI_QOS_SNAPSHOT    192000
-#define MSM_AXI_QOS_RECORDING   192000
-
-static struct clk *camio_vfe_mdc_clk;
-static struct clk *camio_mdc_clk;
-static struct clk *camio_vfe_clk;
-static struct clk *camio_vfe_camif_clk;
-static struct clk *camio_vfe_pbdg_clk;
-static struct clk *camio_cam_m_clk;
-static struct clk *camio_camif_pad_pbdg_clk;
-static struct clk *camio_csi_clk;
-static struct clk *camio_csi_pclk;
-static struct clk *camio_csi_vfe_clk;
-static struct clk *camio_vpe_clk;
-static struct regulator *fs_vpe;
-static struct msm_camera_io_ext camio_ext;
-static struct msm_camera_io_clk camio_clk;
-static struct resource *camifpadio, *csiio;
-void __iomem *camifpadbase, *csibase;
-static uint32_t vpe_clk_rate;
-
-static struct regulator_bulk_data regs[] = {
-	{ .supply = "gp2",  .min_uV = 2600000, .max_uV = 2600000 },
-	{ .supply = "lvsw1" },
-	{ .supply = "fs_vfe" },
-	/* sn12m0pz regulators */
-	{ .supply = "gp6",  .min_uV = 3050000, .max_uV = 3100000 },
-	{ .supply = "gp16", .min_uV = 1200000, .max_uV = 1200000 },
-};
-
-static int reg_count;
-
-static void msm_camera_vreg_enable(struct platform_device *pdev)
-{
-	int count, rc;
-
-	struct device *dev = &pdev->dev;
-
-	/* Use gp6 and gp16 if and only if dev name matches. */
-	if (!strncmp(pdev->name, "msm_camera_sn12m0pz", 20))
-		count = ARRAY_SIZE(regs);
-	else
-		count = ARRAY_SIZE(regs) - 2;
-
-	rc = regulator_bulk_get(dev, count, regs);
-
-	if (rc) {
-		dev_err(dev, "%s: could not get regulators: %d\n",
-				__func__, rc);
-		return;
-	}
-
-	rc = regulator_bulk_set_voltage(count, regs);
-
-	if (rc) {
-		dev_err(dev, "%s: could not set voltages: %d\n",
-				__func__, rc);
-		goto reg_free;
-	}
-
-	rc = regulator_bulk_enable(count, regs);
-
-	if (rc) {
-		dev_err(dev, "%s: could not enable regulators: %d\n",
-				__func__, rc);
-		goto reg_free;
-	}
-
-	reg_count = count;
-	return;
-
-reg_free:
-	regulator_bulk_free(count, regs);
-	return;
-}
-
-
-static void msm_camera_vreg_disable(void)
-{
-	regulator_bulk_disable(reg_count, regs);
-	regulator_bulk_free(reg_count, regs);
-	reg_count = 0;
-}
-
-int msm_camio_clk_enable(enum msm_camio_clk_type clktype)
-{
-	int rc = 0;
-	struct clk *clk = NULL;
-
-	switch (clktype) {
-	case CAMIO_VFE_MDC_CLK:
-		camio_vfe_mdc_clk =
-		clk = clk_get(NULL, "vfe_mdc_clk");
-		break;
-
-	case CAMIO_MDC_CLK:
-		camio_mdc_clk =
-		clk = clk_get(NULL, "mdc_clk");
-		break;
-
-	case CAMIO_VFE_CLK:
-		camio_vfe_clk =
-		clk = clk_get(NULL, "vfe_clk");
-		msm_camio_clk_rate_set_2(clk, camio_clk.vfe_clk_rate);
-		break;
-
-	case CAMIO_VFE_CAMIF_CLK:
-		camio_vfe_camif_clk =
-		clk = clk_get(NULL, "vfe_camif_clk");
-		break;
-
-	case CAMIO_VFE_PBDG_CLK:
-		camio_vfe_pbdg_clk =
-		clk = clk_get(NULL, "vfe_pclk");
-		break;
-
-	case CAMIO_CAM_MCLK_CLK:
-		camio_cam_m_clk =
-		clk = clk_get(NULL, "cam_m_clk");
-		msm_camio_clk_rate_set_2(clk, camio_clk.mclk_clk_rate);
-		break;
-
-	case CAMIO_CAMIF_PAD_PBDG_CLK:
-		camio_camif_pad_pbdg_clk =
-		clk = clk_get(NULL, "camif_pad_pclk");
-		break;
-
-	case CAMIO_CSI0_CLK:
-		camio_csi_clk =
-		clk = clk_get(NULL, "csi_clk");
-		msm_camio_clk_rate_set_2(clk, 153600000);
-		break;
-	case CAMIO_CSI0_VFE_CLK:
-		camio_csi_vfe_clk =
-		clk = clk_get(NULL, "csi_vfe_clk");
-		break;
-	case CAMIO_CSI0_PCLK:
-		camio_csi_pclk =
-		clk = clk_get(NULL, "csi_pclk");
-		break;
-
-	case CAMIO_VPE_CLK:
-		camio_vpe_clk =
-		clk = clk_get(NULL, "vpe_clk");
-		vpe_clk_rate = clk_round_rate(clk, vpe_clk_rate);
-		clk_set_rate(clk, vpe_clk_rate);
-		break;
-	default:
-		break;
-	}
-
-	if (!IS_ERR(clk))
-		clk_prepare_enable(clk);
-	else
-		rc = -1;
-	return rc;
-}
-
-int msm_camio_clk_disable(enum msm_camio_clk_type clktype)
-{
-	int rc = 0;
-	struct clk *clk = NULL;
-
-	switch (clktype) {
-	case CAMIO_VFE_MDC_CLK:
-		clk = camio_vfe_mdc_clk;
-		break;
-
-	case CAMIO_MDC_CLK:
-		clk = camio_mdc_clk;
-		break;
-
-	case CAMIO_VFE_CLK:
-		clk = camio_vfe_clk;
-		break;
-
-	case CAMIO_VFE_CAMIF_CLK:
-		clk = camio_vfe_camif_clk;
-		break;
-
-	case CAMIO_VFE_PBDG_CLK:
-		clk = camio_vfe_pbdg_clk;
-		break;
-
-	case CAMIO_CAM_MCLK_CLK:
-		clk = camio_cam_m_clk;
-		break;
-
-	case CAMIO_CAMIF_PAD_PBDG_CLK:
-		clk = camio_camif_pad_pbdg_clk;
-		break;
-	case CAMIO_CSI0_CLK:
-		clk = camio_csi_clk;
-		break;
-	case CAMIO_CSI0_VFE_CLK:
-		clk = camio_csi_vfe_clk;
-		break;
-	case CAMIO_CSI0_PCLK:
-		clk = camio_csi_pclk;
-		break;
-	case CAMIO_VPE_CLK:
-		clk = camio_vpe_clk;
-		break;
-	default:
-		break;
-	}
-
-	if (!IS_ERR(clk)) {
-		clk_disable_unprepare(clk);
-		clk_put(clk);
-	} else {
-		rc = -1;
-	}
-
-	return rc;
-}
-
-void msm_camio_clk_rate_set(int rate)
-{
-	struct clk *clk = camio_cam_m_clk;
-	clk_set_rate(clk, rate);
-}
-
-int msm_camio_vfe_clk_rate_set(int rate)
-{
-	struct clk *clk = camio_vfe_clk;
-	return clk_set_rate(clk, rate);
-}
-
-void msm_camio_clk_rate_set_2(struct clk *clk, int rate)
-{
-	clk_set_rate(clk, rate);
-}
-
-static irqreturn_t msm_io_csi_irq(int irq_num, void *data)
-{
-	uint32_t irq;
-	irq = msm_camera_io_r(csibase + MIPI_INTERRUPT_STATUS);
-	CDBG("%s MIPI_INTERRUPT_STATUS = 0x%x\n", __func__, irq);
-	msm_camera_io_w(irq, csibase + MIPI_INTERRUPT_STATUS);
-	return IRQ_HANDLED;
-}
-
-int msm_camio_vpe_clk_disable(void)
-{
-	msm_camio_clk_disable(CAMIO_VPE_CLK);
-
-	if (fs_vpe) {
-		regulator_disable(fs_vpe);
-		regulator_put(fs_vpe);
-	}
-
-	return 0;
-}
-
-int msm_camio_vpe_clk_enable(uint32_t clk_rate)
-{
-	fs_vpe = regulator_get(NULL, "fs_vpe");
-	if (IS_ERR(fs_vpe)) {
-		pr_err("%s: Regulator FS_VPE get failed %ld\n", __func__,
-			PTR_ERR(fs_vpe));
-		fs_vpe = NULL;
-	} else if (regulator_enable(fs_vpe)) {
-		pr_err("%s: Regulator FS_VPE enable failed\n", __func__);
-		regulator_put(fs_vpe);
-	}
-
-	vpe_clk_rate = clk_rate;
-	msm_camio_clk_enable(CAMIO_VPE_CLK);
-	return 0;
-}
-
-int msm_camio_enable(struct platform_device *pdev)
-{
-	int rc = 0;
-	struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	msm_camio_clk_enable(CAMIO_VFE_PBDG_CLK);
-	if (!sinfo->csi_if)
-		msm_camio_clk_enable(CAMIO_VFE_CAMIF_CLK);
-	else {
-		msm_camio_clk_enable(CAMIO_VFE_CLK);
-		csiio = request_mem_region(camio_ext.csiphy,
-			camio_ext.csisz, pdev->name);
-		if (!csiio) {
-			rc = -EBUSY;
-			goto common_fail;
-		}
-		csibase = ioremap(camio_ext.csiphy,
-			camio_ext.csisz);
-		if (!csibase) {
-			rc = -ENOMEM;
-			goto csi_busy;
-		}
-		rc = request_irq(camio_ext.csiirq, msm_io_csi_irq,
-			IRQF_TRIGGER_RISING, "csi", 0);
-		if (rc < 0)
-			goto csi_irq_fail;
-		/* enable required clocks for CSI */
-		msm_camio_clk_enable(CAMIO_CSI0_PCLK);
-		msm_camio_clk_enable(CAMIO_CSI0_VFE_CLK);
-		msm_camio_clk_enable(CAMIO_CSI0_CLK);
-	}
-	return 0;
-csi_irq_fail:
-	iounmap(csibase);
-csi_busy:
-	release_mem_region(camio_ext.csiphy, camio_ext.csisz);
-common_fail:
-	msm_camio_clk_disable(CAMIO_VFE_PBDG_CLK);
-	msm_camio_clk_disable(CAMIO_VFE_CLK);
-	return rc;
-}
-
-static void msm_camio_csi_disable(void)
-{
-	uint32_t val;
-	val = 0x0;
-	CDBG("%s MIPI_PHY_D0_CONTROL2 val=0x%x\n", __func__, val);
-	msm_camera_io_w(val, csibase + MIPI_PHY_D0_CONTROL2);
-	msm_camera_io_w(val, csibase + MIPI_PHY_D1_CONTROL2);
-	msm_camera_io_w(val, csibase + MIPI_PHY_D2_CONTROL2);
-	msm_camera_io_w(val, csibase + MIPI_PHY_D3_CONTROL2);
-
-	CDBG("%s MIPI_PHY_CL_CONTROL val=0x%x\n", __func__, val);
-	msm_camera_io_w(val, csibase + MIPI_PHY_CL_CONTROL);
-	usleep_range(9000, 10000);
-	free_irq(camio_ext.csiirq, 0);
-	iounmap(csibase);
-	release_mem_region(camio_ext.csiphy, camio_ext.csisz);
-}
-
-void msm_camio_disable(struct platform_device *pdev)
-{
-	struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	if (!sinfo->csi_if) {
-		msm_camio_clk_disable(CAMIO_VFE_CAMIF_CLK);
-	} else {
-		CDBG("disable mipi\n");
-		msm_camio_csi_disable();
-		CDBG("disable clocks\n");
-		msm_camio_clk_disable(CAMIO_CSI0_PCLK);
-		msm_camio_clk_disable(CAMIO_CSI0_VFE_CLK);
-		msm_camio_clk_disable(CAMIO_CSI0_CLK);
-		msm_camio_clk_disable(CAMIO_VFE_CLK);
-	}
-	msm_camio_clk_disable(CAMIO_VFE_PBDG_CLK);
-}
-
-void msm_camio_camif_pad_reg_reset(void)
-{
-	uint32_t reg;
-
-	msm_camio_clk_sel(MSM_CAMIO_CLK_SRC_INTERNAL);
-	usleep_range(10000, 11000);
-
-	reg = (msm_camera_io_r(camifpadbase)) & CAMIF_CFG_RMSK;
-	reg |= 0x3;
-	msm_camera_io_w(reg, camifpadbase);
-	usleep_range(10000, 11000);
-
-	reg = (msm_camera_io_r(camifpadbase)) & CAMIF_CFG_RMSK;
-	reg |= 0x10;
-	msm_camera_io_w(reg, camifpadbase);
-	usleep_range(10000, 11000);
-
-	reg = (msm_camera_io_r(camifpadbase)) & CAMIF_CFG_RMSK;
-	/* Need to be uninverted*/
-	reg &= 0x03;
-	msm_camera_io_w(reg, camifpadbase);
-	usleep_range(10000, 11000);
-}
-
-void msm_camio_vfe_blk_reset(void)
-{
-	return;
-
-
-}
-
-void msm_camio_camif_pad_reg_reset_2(void)
-{
-	uint32_t reg;
-	uint32_t mask, value;
-	reg = (msm_camera_io_r(camifpadbase)) & CAMIF_CFG_RMSK;
-	mask = CAM_PAD_REG_SW_RESET_BMSK;
-	value = 1 << CAM_PAD_REG_SW_RESET_SHFT;
-	msm_camera_io_w((reg & (~mask)) | (value & mask), camifpadbase);
-	usleep_range(10000, 11000);
-	reg = (msm_camera_io_r(camifpadbase)) & CAMIF_CFG_RMSK;
-	mask = CAM_PAD_REG_SW_RESET_BMSK;
-	value = 0 << CAM_PAD_REG_SW_RESET_SHFT;
-	msm_camera_io_w((reg & (~mask)) | (value & mask), camifpadbase);
-	usleep_range(10000, 11000);
-}
-
-void msm_camio_clk_sel(enum msm_camio_clk_src_type srctype)
-{
-	struct clk *clk = NULL;
-
-	clk = camio_vfe_clk;
-
-	if (clk != NULL) {
-		switch (srctype) {
-		case MSM_CAMIO_CLK_SRC_INTERNAL:
-			clk_set_flags(clk, 0x00000100 << 1);
-			break;
-
-		case MSM_CAMIO_CLK_SRC_EXTERNAL:
-			clk_set_flags(clk, 0x00000100);
-			break;
-
-		default:
-			break;
-		}
-	}
-}
-int msm_camio_probe_on(struct platform_device *pdev)
-{
-	struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-	camio_clk = camdev->ioclk;
-	camio_ext = camdev->ioext;
-	camdev->camera_gpio_on();
-	msm_camera_vreg_enable(pdev);
-	return msm_camio_clk_enable(CAMIO_CAM_MCLK_CLK);
-}
-
-int msm_camio_probe_off(struct platform_device *pdev)
-{
-	struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-	msm_camera_vreg_disable();
-	camdev->camera_gpio_off();
-	return msm_camio_clk_disable(CAMIO_CAM_MCLK_CLK);
-}
-
-int msm_camio_sensor_clk_on(struct platform_device *pdev)
-{
-	int rc = 0;
-	struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-	camio_clk = camdev->ioclk;
-	camio_ext = camdev->ioext;
-	camdev->camera_gpio_on();
-	msm_camera_vreg_enable(pdev);
-	msm_camio_clk_enable(CAMIO_CAM_MCLK_CLK);
-	msm_camio_clk_enable(CAMIO_CAMIF_PAD_PBDG_CLK);
-	if (!sinfo->csi_if) {
-		camifpadio = request_mem_region(camio_ext.camifpadphy,
-			camio_ext.camifpadsz, pdev->name);
-		msm_camio_clk_enable(CAMIO_VFE_CLK);
-		if (!camifpadio) {
-			rc = -EBUSY;
-			goto common_fail;
-		}
-		camifpadbase = ioremap(camio_ext.camifpadphy,
-			camio_ext.camifpadsz);
-		if (!camifpadbase) {
-			CDBG("msm_camio_sensor_clk_on fail\n");
-			rc = -ENOMEM;
-			goto parallel_busy;
-		}
-	}
-	return rc;
-parallel_busy:
-	release_mem_region(camio_ext.camifpadphy, camio_ext.camifpadsz);
-	goto common_fail;
-common_fail:
-	msm_camio_clk_disable(CAMIO_CAM_MCLK_CLK);
-	msm_camio_clk_disable(CAMIO_VFE_CLK);
-	msm_camio_clk_disable(CAMIO_CAMIF_PAD_PBDG_CLK);
-	msm_camera_vreg_disable();
-	camdev->camera_gpio_off();
-	return rc;
-}
-
-int msm_camio_sensor_clk_off(struct platform_device *pdev)
-{
-	uint32_t rc = 0;
-	struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-	camdev->camera_gpio_off();
-	msm_camera_vreg_disable();
-	rc = msm_camio_clk_disable(CAMIO_CAM_MCLK_CLK);
-	rc = msm_camio_clk_disable(CAMIO_CAMIF_PAD_PBDG_CLK);
-	if (!sinfo->csi_if) {
-		iounmap(camifpadbase);
-		release_mem_region(camio_ext.camifpadphy, camio_ext.camifpadsz);
-		rc = msm_camio_clk_disable(CAMIO_VFE_CLK);
-	}
-	return rc;
-}
-
-int msm_camio_csi_config(struct msm_camera_csi_params *csi_params)
-{
-	int rc = 0;
-	uint32_t val = 0;
-	int i;
-
-	CDBG("msm_camio_csi_config\n");
-
-	/* SOT_ECC_EN enable error correction for SYNC (data-lane) */
-	msm_camera_io_w(0x4, csibase + MIPI_PHY_CONTROL);
-
-	/* SW_RST to the CSI core */
-	msm_camera_io_w(MIPI_PROTOCOL_CONTROL_SW_RST_BMSK,
-		csibase + MIPI_PROTOCOL_CONTROL);
-
-	/* PROTOCOL CONTROL */
-	val = MIPI_PROTOCOL_CONTROL_LONG_PACKET_HEADER_CAPTURE_BMSK |
-		MIPI_PROTOCOL_CONTROL_DECODE_ID_BMSK |
-		MIPI_PROTOCOL_CONTROL_ECC_EN_BMSK;
-	val |= (uint32_t)(csi_params->data_format) <<
-		MIPI_PROTOCOL_CONTROL_DATA_FORMAT_SHFT;
-	val |= csi_params->dpcm_scheme <<
-		MIPI_PROTOCOL_CONTROL_DPCM_SCHEME_SHFT;
-	CDBG("%s MIPI_PROTOCOL_CONTROL val=0x%x\n", __func__, val);
-	msm_camera_io_w(val, csibase + MIPI_PROTOCOL_CONTROL);
-
-	/* SW CAL EN */
-	val = (0x1 << MIPI_CALIBRATION_CONTROL_SWCAL_CAL_EN_SHFT) |
-		(0x1 <<
-		MIPI_CALIBRATION_CONTROL_SWCAL_STRENGTH_OVERRIDE_EN_SHFT) |
-		(0x1 << MIPI_CALIBRATION_CONTROL_CAL_SW_HW_MODE_SHFT) |
-		(0x1 << MIPI_CALIBRATION_CONTROL_MANUAL_OVERRIDE_EN_SHFT);
-	CDBG("%s MIPI_CALIBRATION_CONTROL val=0x%x\n", __func__, val);
-	msm_camera_io_w(val, csibase + MIPI_CALIBRATION_CONTROL);
-
-	/* settle_cnt is very sensitive to speed!
-	increase this value to run at higher speeds */
-	val = (csi_params->settle_cnt <<
-			MIPI_PHY_D0_CONTROL2_SETTLE_COUNT_SHFT) |
-		(0x0F << MIPI_PHY_D0_CONTROL2_HS_TERM_IMP_SHFT) |
-		(0x1 << MIPI_PHY_D0_CONTROL2_LP_REC_EN_SHFT) |
-		(0x1 << MIPI_PHY_D0_CONTROL2_ERR_SOT_HS_EN_SHFT);
-	CDBG("%s MIPI_PHY_D0_CONTROL2 val=0x%x\n", __func__, val);
-	for (i = 0; i < csi_params->lane_cnt; i++)
-		msm_camera_io_w(val, csibase + MIPI_PHY_D0_CONTROL2 + i * 4);
-
-	val = (0x0F << MIPI_PHY_CL_CONTROL_HS_TERM_IMP_SHFT) |
-		(0x1 << MIPI_PHY_CL_CONTROL_LP_REC_EN_SHFT);
-	CDBG("%s MIPI_PHY_CL_CONTROL val=0x%x\n", __func__, val);
-	msm_camera_io_w(val, csibase + MIPI_PHY_CL_CONTROL);
-
-	val = 0 << MIPI_PHY_D0_CONTROL_HS_REC_EQ_SHFT;
-	msm_camera_io_w(val, csibase + MIPI_PHY_D0_CONTROL);
-
-	val = (0x1 << MIPI_PHY_D1_CONTROL_MIPI_CLK_PHY_SHUTDOWNB_SHFT) |
-		(0x1 << MIPI_PHY_D1_CONTROL_MIPI_DATA_PHY_SHUTDOWNB_SHFT);
-	CDBG("%s MIPI_PHY_D1_CONTROL val=0x%x\n", __func__, val);
-	msm_camera_io_w(val, csibase + MIPI_PHY_D1_CONTROL);
-
-	msm_camera_io_w(0x00000000, csibase + MIPI_PHY_D2_CONTROL);
-	msm_camera_io_w(0x00000000, csibase + MIPI_PHY_D3_CONTROL);
-
-	/* halcyon only supports 1 or 2 lane */
-	switch (csi_params->lane_cnt) {
-	case 1:
-		msm_camera_io_w(csi_params->lane_assign << 8 | 0x4,
-			csibase + MIPI_CAMERA_CNTL);
-		break;
-	case 2:
-		msm_camera_io_w(csi_params->lane_assign << 8 | 0x5,
-			csibase + MIPI_CAMERA_CNTL);
-		break;
-	case 3:
-		msm_camera_io_w(csi_params->lane_assign << 8 | 0x6,
-			csibase + MIPI_CAMERA_CNTL);
-		break;
-	case 4:
-		msm_camera_io_w(csi_params->lane_assign << 8 | 0x7,
-			csibase + MIPI_CAMERA_CNTL);
-		break;
-	}
-
-	/* mask out ID_ERROR[19], DATA_CMM_ERR[11]
-	and CLK_CMM_ERR[10] - de-featured */
-	msm_camera_io_w(0xFFF7F3FF, csibase + MIPI_INTERRUPT_MASK);
-	/*clear IRQ bits*/
-	msm_camera_io_w(0xFFF7F3FF, csibase + MIPI_INTERRUPT_STATUS);
-
-	return rc;
-}
-void msm_camio_set_perf_lvl(enum msm_bus_perf_setting perf_setting)
-{
-	switch (perf_setting) {
-	case S_INIT:
-		add_axi_qos();
-		break;
-	case S_PREVIEW:
-		update_axi_qos(MSM_AXI_QOS_PREVIEW);
-		break;
-	case S_VIDEO:
-		update_axi_qos(MSM_AXI_QOS_RECORDING);
-		break;
-	case S_CAPTURE:
-		update_axi_qos(MSM_AXI_QOS_SNAPSHOT);
-		break;
-	case S_DEFAULT:
-		update_axi_qos(PM_QOS_DEFAULT_VALUE);
-		break;
-	case S_EXIT:
-		release_axi_qos();
-		break;
-	default:
-		CDBG("%s: INVALID CASE\n", __func__);
-	}
-}
-
-int msm_cam_core_reset(void)
-{
-	struct clk *clk1;
-	int rc = 0;
-
-	clk1 = clk_get(NULL, "csi_vfe_clk");
-	if (IS_ERR(clk1)) {
-		pr_err("%s: did not get csi_vfe_clk\n", __func__);
-		return PTR_ERR(clk1);
-	}
-
-	rc = clk_reset(clk1, CLK_RESET_ASSERT);
-	if (rc) {
-		pr_err("%s:csi_vfe_clk assert failed\n", __func__);
-		clk_put(clk1);
-		return rc;
-	}
-	usleep_range(1000, 1200);
-	rc = clk_reset(clk1, CLK_RESET_DEASSERT);
-	if (rc) {
-		pr_err("%s:csi_vfe_clk deassert failed\n", __func__);
-		clk_put(clk1);
-		return rc;
-	}
-	clk_put(clk1);
-
-	clk1 = clk_get(NULL, "csi_clk");
-	if (IS_ERR(clk1)) {
-		pr_err("%s: did not get csi_clk\n", __func__);
-		return PTR_ERR(clk1);
-	}
-
-	rc = clk_reset(clk1, CLK_RESET_ASSERT);
-	if (rc) {
-		pr_err("%s:csi_clk assert failed\n", __func__);
-		clk_put(clk1);
-		return rc;
-	}
-	usleep_range(1000, 1200);
-	rc = clk_reset(clk1, CLK_RESET_DEASSERT);
-	if (rc) {
-		pr_err("%s:csi_clk deassert failed\n", __func__);
-		clk_put(clk1);
-		return rc;
-	}
-	clk_put(clk1);
-
-	clk1 = clk_get(NULL, "csi_pclk");
-	if (IS_ERR(clk1)) {
-		pr_err("%s: did not get csi_pclk\n", __func__);
-		return PTR_ERR(clk1);
-	}
-
-	rc = clk_reset(clk1, CLK_RESET_ASSERT);
-	if (rc) {
-		pr_err("%s:csi_pclk assert failed\n", __func__);
-		clk_put(clk1);
-		return rc;
-	}
-	usleep_range(1000, 1200);
-	rc = clk_reset(clk1, CLK_RESET_DEASSERT);
-	if (rc) {
-		pr_err("%s:csi_pclk deassert failed\n", __func__);
-		clk_put(clk1);
-		return rc;
-	}
-	clk_put(clk1);
-
-	return rc;
-}
diff --git a/drivers/media/platform/msm/camera_v1/io/msm_io_vfe31_v4l2.c b/drivers/media/platform/msm/camera_v1/io/msm_io_vfe31_v4l2.c
deleted file mode 100644
index acf87e4..0000000
--- a/drivers/media/platform/msm/camera_v1/io/msm_io_vfe31_v4l2.c
+++ /dev/null
@@ -1,274 +0,0 @@
-/* Copyright (c) 2010-2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/delay.h>
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <linux/regulator/consumer.h>
-#include <linux/export.h>
-#include <mach/gpio.h>
-#include <mach/board.h>
-#include <mach/camera.h>
-#include <mach/vreg.h>
-#include <mach/camera.h>
-#include <mach/clk.h>
-#include <mach/msm_bus.h>
-#include <mach/msm_bus_board.h>
-
-#include <linux/pm_qos.h>
-
-/* AXI rates in KHz */
-#define MSM_AXI_QOS_PREVIEW     192000
-#define MSM_AXI_QOS_SNAPSHOT    192000
-#define MSM_AXI_QOS_RECORDING   192000
-
-#define BUFF_SIZE_128 128
-
-static struct clk *camio_vfe_clk;
-static struct clk *camio_vpe_clk;
-static struct clk *camio_vpe_pclk;
-static struct regulator *fs_vpe;
-
-static int vpe_clk_rate;
-
-int msm_camio_clk_enable(enum msm_camio_clk_type clktype)
-{
-	int rc = 0;
-	struct clk *clk = NULL;
-
-	switch (clktype) {
-	case CAMIO_VPE_CLK:
-		camio_vpe_clk =
-		clk = clk_get(NULL, "vpe_clk");
-		vpe_clk_rate = clk_round_rate(camio_vpe_clk, vpe_clk_rate);
-		clk_set_rate(camio_vpe_clk, vpe_clk_rate);
-		break;
-
-	case CAMIO_VPE_PCLK:
-		camio_vpe_pclk =
-		clk = clk_get(NULL, "vpe_pclk");
-		break;
-
-	default:
-		break;
-	}
-
-	if (!IS_ERR(clk)) {
-		clk_prepare(clk);
-		clk_enable(clk);
-	} else {
-		rc = -1;
-	}
-	return rc;
-}
-
-int msm_camio_clk_disable(enum msm_camio_clk_type clktype)
-{
-	int rc = 0;
-	struct clk *clk = NULL;
-
-	switch (clktype) {
-	case CAMIO_VPE_CLK:
-		clk = camio_vpe_clk;
-		break;
-
-	case CAMIO_VPE_PCLK:
-		clk = camio_vpe_pclk;
-		break;
-
-	default:
-		break;
-	}
-
-	if (!IS_ERR(clk)) {
-		clk_disable(clk);
-		clk_unprepare(clk);
-		clk_put(clk);
-	} else {
-		rc = -1;
-	}
-
-	return rc;
-}
-
-int msm_camio_vfe_clk_rate_set(int rate)
-{
-	int rc = 0;
-	struct clk *clk = camio_vfe_clk;
-	if (rate > clk_get_rate(clk))
-		rc = clk_set_rate(clk, rate);
-	return rc;
-}
-
-void msm_camio_clk_rate_set_2(struct clk *clk, int rate)
-{
-	clk_set_rate(clk, rate);
-}
-
-int msm_camio_vpe_clk_disable(void)
-{
-	int rc = 0;
-	if (fs_vpe) {
-		regulator_disable(fs_vpe);
-		regulator_put(fs_vpe);
-	}
-
-	rc = msm_camio_clk_disable(CAMIO_VPE_CLK);
-	if (rc < 0)
-		return rc;
-	rc = msm_camio_clk_disable(CAMIO_VPE_PCLK);
-	return rc;
-}
-
-int msm_camio_vpe_clk_enable(uint32_t clk_rate)
-{
-	int rc = 0;
-	fs_vpe = regulator_get(NULL, "fs_vpe");
-	if (IS_ERR(fs_vpe)) {
-		CDBG("%s: Regulator FS_VPE get failed %ld\n", __func__,
-			PTR_ERR(fs_vpe));
-		fs_vpe = NULL;
-	} else if (regulator_enable(fs_vpe)) {
-		CDBG("%s: Regulator FS_VPE enable failed\n", __func__);
-		regulator_put(fs_vpe);
-	}
-
-	vpe_clk_rate = clk_rate;
-	rc = msm_camio_clk_enable(CAMIO_VPE_CLK);
-	if (rc < 0)
-		return rc;
-
-	rc = msm_camio_clk_enable(CAMIO_VPE_PCLK);
-	return rc;
-}
-
-void msm_camio_vfe_blk_reset(void)
-{
-	return;
-}
-
-void msm_camio_vfe_blk_reset_3(void)
-{
-	return;
-}
-
-static void msm_camio_axi_cfg(enum msm_bus_perf_setting perf_setting)
-{
-	switch (perf_setting) {
-	case S_INIT:
-		add_axi_qos();
-		break;
-	case S_PREVIEW:
-		update_axi_qos(MSM_AXI_QOS_PREVIEW);
-		break;
-	case S_VIDEO:
-		update_axi_qos(MSM_AXI_QOS_RECORDING);
-		break;
-	case S_CAPTURE:
-		update_axi_qos(MSM_AXI_QOS_SNAPSHOT);
-		break;
-	case S_DEFAULT:
-		update_axi_qos(PM_QOS_DEFAULT_VALUE);
-		break;
-	case S_EXIT:
-		release_axi_qos();
-		break;
-	default:
-		CDBG("%s: INVALID CASE\n", __func__);
-	}
-}
-
-void msm_camio_bus_scale_cfg(struct msm_bus_scale_pdata *cam_bus_scale_table,
-		enum msm_bus_perf_setting perf_setting)
-{
-	static uint32_t bus_perf_client;
-	int rc = 0;
-	if (cam_bus_scale_table == NULL) {
-		msm_camio_axi_cfg(perf_setting);
-		return;
-	}
-
-	switch (perf_setting) {
-	case S_INIT:
-		bus_perf_client =
-			msm_bus_scale_register_client(cam_bus_scale_table);
-		if (!bus_perf_client) {
-			pr_err("%s: Registration Failed!!!\n", __func__);
-			bus_perf_client = 0;
-			return;
-		}
-		CDBG("%s: S_INIT rc = %u\n", __func__, bus_perf_client);
-		break;
-	case S_EXIT:
-		if (bus_perf_client) {
-			CDBG("%s: S_EXIT\n", __func__);
-			msm_bus_scale_unregister_client(bus_perf_client);
-		} else
-			pr_err("%s: Bus Client NOT Registered!!!\n", __func__);
-		break;
-	case S_PREVIEW:
-		if (bus_perf_client) {
-			rc = msm_bus_scale_client_update_request(
-				bus_perf_client, 1);
-			CDBG("%s: S_PREVIEW rc = %d\n", __func__, rc);
-		} else
-			pr_err("%s: Bus Client NOT Registered!!!\n", __func__);
-		break;
-	case S_VIDEO:
-		if (bus_perf_client) {
-			rc = msm_bus_scale_client_update_request(
-				bus_perf_client, 2);
-			CDBG("%s: S_VIDEO rc = %d\n", __func__, rc);
-		} else
-			pr_err("%s: Bus Client NOT Registered!!!\n", __func__);
-		break;
-	case S_CAPTURE:
-		if (bus_perf_client) {
-			rc = msm_bus_scale_client_update_request(
-				bus_perf_client, 3);
-			CDBG("%s: S_CAPTURE rc = %d\n", __func__, rc);
-		} else
-			pr_err("%s: Bus Client NOT Registered!!!\n", __func__);
-		break;
-
-	case S_ZSL:
-		if (bus_perf_client) {
-			rc = msm_bus_scale_client_update_request(
-				bus_perf_client, 4);
-			CDBG("%s: S_ZSL rc = %d\n", __func__, rc);
-		} else
-			pr_err("%s: Bus Client NOT Registered!!!\n", __func__);
-		break;
-	case S_STEREO_VIDEO:
-		if (bus_perf_client) {
-			rc = msm_bus_scale_client_update_request(
-				bus_perf_client, 5);
-			CDBG("%s: S_STEREO_VIDEO rc = %d\n", __func__, rc);
-		} else
-			pr_err("%s: Bus Client NOT Registered!!!\n", __func__);
-		break;
-	case S_STEREO_CAPTURE:
-		if (bus_perf_client) {
-			rc = msm_bus_scale_client_update_request(
-				bus_perf_client, 6);
-			CDBG("%s: S_STEREO_VIDEO rc = %d\n", __func__, rc);
-		} else
-			pr_err("%s: Bus Client NOT Registered!!!\n", __func__);
-		break;
-	case S_DEFAULT:
-		break;
-	default:
-		pr_warning("%s: INVALID CASE\n", __func__);
-	}
-}
-
diff --git a/drivers/media/platform/msm/camera_v1/mercury/Makefile b/drivers/media/platform/msm/camera_v1/mercury/Makefile
deleted file mode 100644
index bc9c950..0000000
--- a/drivers/media/platform/msm/camera_v1/mercury/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-GCC_VERSION      := $(shell $(CONFIG_SHELL) $(PWD)/scripts/gcc-version.sh $(CROSS_COMPILE)gcc)
-EXTRA_CFLAGS += -Idrivers/media/platform/msm/camera_v1
-obj-$(CONFIG_MSM_MERCURY) += msm_mercury_dev.o msm_mercury_core.o msm_mercury_hw.o msm_mercury_platform.o msm_mercury_sync.o
diff --git a/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_common.h b/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_common.h
deleted file mode 100644
index 8ce7f7e..0000000
--- a/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_common.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#ifndef MSM_MERCURY_COMMON_H
-#define MSM_MERCURY_COMMON_H
-
-#define MSM_MERCURY_DEBUG
-#ifdef MSM_MERCURY_DEBUG
-#define MCR_DBG(fmt, args...) pr_debug(fmt, ##args)
-#else
-#define MCR_DBG(fmt, args...) do { } while (0)
-#endif
-
-#define MCR_PR_ERR   pr_err
-#endif /* MSM_MERCURY_COMMON_H */
diff --git a/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_core.c b/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_core.c
deleted file mode 100644
index b0630f0..0000000
--- a/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_core.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#include <linux/module.h>
-#include <linux/sched.h>
-#include <linux/delay.h>
-#include <linux/io.h>
-#include <linux/clk.h>
-#include <mach/clk.h>
-#include <mach/msm_bus.h>
-#include <mach/msm_bus_board.h>
-#include "msm_mercury_hw.h"
-#include "msm_mercury_core.h"
-#include "msm_mercury_platform.h"
-#include "msm_mercury_common.h"
-
-static int reset_done_ack;
-static spinlock_t reset_lock;
-static wait_queue_head_t reset_wait;
-
-int mercury_core_reset(void)
-{
-	struct clk *clk = NULL;
-
-	/*Resettting MMSS Fabric*/
-
-	clk = clk_get(NULL, "jpegd_clk");
-
-	if (!IS_ERR(clk))
-		clk_enable(clk);
-
-	msm_bus_axi_porthalt(MSM_BUS_MASTER_JPEG_DEC);
-	clk_reset(clk, CLK_RESET_ASSERT);
-
-	/*need to have some delay here, there is no
-	 other way to know if hardware reset is complete*/
-	usleep_range(1000, 1200);
-
-	msm_bus_axi_portunhalt(MSM_BUS_MASTER_JPEG_DEC);
-	clk_reset(clk, CLK_RESET_DEASSERT);
-
-	return 0;
-}
-
-int msm_mercury_core_reset(void)
-{
-	unsigned long flags;
-	int rc = 0;
-	int tm = 500;/*500ms*/
-	MCR_DBG("\n%s\n(%d)%s()\n", __FILE__, __LINE__, __func__);
-
-	spin_lock_irqsave(&reset_lock, flags);
-	reset_done_ack = 0;
-	spin_unlock_irqrestore(&reset_lock, flags);
-
-	msm_mercury_hw_reset();
-	rc = wait_event_interruptible_timeout(reset_wait,
-		reset_done_ack,
-		msecs_to_jiffies(tm));
-
-	if (!reset_done_ack) {
-		MCR_DBG("%s: reset ACK failed %d", __func__, rc);
-		return -EBUSY;
-	}
-
-	MCR_DBG("(%d)%s() reset_done_ack rc %d\n\n", __LINE__, __func__, rc);
-	spin_lock_irqsave(&reset_lock, flags);
-	reset_done_ack = 0;
-	spin_unlock_irqrestore(&reset_lock, flags);
-
-	return 0;
-}
-
-void msm_mercury_core_init(void)
-{
-	init_waitqueue_head(&reset_wait);
-	spin_lock_init(&reset_lock);
-}
-
-static int (*msm_mercury_irq_handler) (int, void *, void *);
-
-irqreturn_t msm_mercury_core_irq(int irq_num, void *context)
-{
-	void *data = NULL;
-	unsigned long flags;
-	uint16_t mcr_rd_irq;
-	uint16_t mcr_wr_irq;
-	uint32_t jpeg_status;
-
-	MCR_DBG("\n(%d)%s() irq_number = %d", __LINE__, __func__, irq_num);
-
-	spin_lock_irqsave(&reset_lock, flags);
-	reset_done_ack = 1;
-	spin_unlock_irqrestore(&reset_lock, flags);
-
-	msm_mercury_hw_irq_get_status(&mcr_rd_irq, &mcr_wr_irq);
-	msm_mercury_hw_get_jpeg_status(&jpeg_status);
-	MCR_DBG("mercury_rd_irq = 0x%08X\n", mcr_rd_irq);
-	MCR_DBG("mercury_wr_irq = 0x%08X\n", mcr_wr_irq);
-	MCR_DBG("jpeg_status = 0x%08X\n", jpeg_status);
-	if (mcr_wr_irq & MSM_MERCURY_HW_IRQ_SW_RESET_ACK) {
-		MCR_DBG("*** SW Reset IRQ received ***\n");
-		wake_up(&reset_wait);
-		msm_mercury_hw_wr_irq_clear(MSM_MERCURY_HW_IRQ_SW_RESET_ACK);
-	}
-	if (mcr_wr_irq & MSM_MERCURY_HW_IRQ_WR_ERR_ACK) {
-		MCR_DBG("   *** Error IRQ received ***\n");
-		msm_mercury_irq_handler(MSM_MERCURY_HW_IRQ_WR_ERR_ACK,
-								context, data);
-	}
-	if (mcr_wr_irq & MSM_MERCURY_HW_IRQ_WR_EOI_ACK) {
-		MCR_DBG("   *** WE_EOI IRQ received ***\n");
-		msm_mercury_irq_handler(MSM_MERCURY_HW_IRQ_WR_EOI_ACK,
-								context, data);
-	}
-	return IRQ_HANDLED;
-}
-
-void msm_mercury_core_irq_install(int (*irq_handler) (int, void *, void *))
-{
-	msm_mercury_irq_handler = irq_handler;
-}
-
-void msm_mercury_core_irq_remove(void)
-{
-	msm_mercury_irq_handler = NULL;
-}
diff --git a/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_core.h b/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_core.h
deleted file mode 100644
index 7237e7b..0000000
--- a/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_core.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#ifndef MSM_MERCURY_CORE_H
-#define MSM_MERCURY_CORE_H
-
-#include <linux/interrupt.h>
-#include "msm_mercury_hw.h"
-
-#define msm_mercury_core_buf msm_mercury_hw_buf
-
-irqreturn_t msm_mercury_core_irq(int irq_num, void *context);
-
-void msm_mercury_core_irq_install(int (*irq_handler) (int, void *, void *));
-void msm_mercury_core_irq_remove(void);
-
-int msm_mercury_core_reset(void);
-void msm_mercury_core_init(void);
-
-#endif /* MSM_MERCURY_CORE_H */
diff --git a/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_dev.c b/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_dev.c
deleted file mode 100644
index b245bfd..0000000
--- a/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_dev.c
+++ /dev/null
@@ -1,256 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/platform_device.h>
-#include <linux/fs.h>
-#include <linux/slab.h>
-#include <linux/device.h>
-#include <linux/uaccess.h>
-#include <media/v4l2-device.h>
-#include <media/v4l2-subdev.h>
-#include <media/msm_mercury.h>
-#include <mach/board.h>
-#include "msm_mercury_sync.h"
-#include "msm_mercury_common.h"
-#include "msm.h"
-
-#define MSM_MERCURY_NAME "mercury"
-
-static int msm_mercury_open(struct inode *inode, struct file *filp)
-{
-	int rc;
-
-	struct msm_mercury_device *pmercury_dev = container_of(inode->i_cdev,
-		struct msm_mercury_device, cdev);
-	filp->private_data = pmercury_dev;
-
-	MCR_DBG("\n---(%d)%s()\n", __LINE__, __func__);
-
-	rc = __msm_mercury_open(pmercury_dev);
-
-	MCR_DBG("%s:%d] %s open_count = %d\n", __func__, __LINE__,
-		filp->f_path.dentry->d_name.name, pmercury_dev->open_count);
-
-	return rc;
-}
-
-static int msm_mercury_release(struct inode *inode, struct file *filp)
-{
-	int rc;
-
-	struct msm_mercury_device *pmercury_dev = filp->private_data;
-
-	MCR_DBG("\n---(%d)%s()\n", __LINE__, __func__);
-
-	rc = __msm_mercury_release(pmercury_dev);
-
-	MCR_DBG("%s:%d] %s open_count = %d\n", __func__, __LINE__,
-		filp->f_path.dentry->d_name.name, pmercury_dev->open_count);
-	return rc;
-}
-
-static long msm_mercury_ioctl(struct file *filp, unsigned int cmd,
-	unsigned long arg) {
-	int rc;
-	struct msm_mercury_device *pmercury_dev = filp->private_data;
-	rc = __msm_mercury_ioctl(pmercury_dev, cmd, arg);
-	return rc;
-}
-
-static const struct file_operations msm_mercury_fops = {
-	.owner     = THIS_MODULE,
-	.open    = msm_mercury_open,
-	.release = msm_mercury_release,
-	.unlocked_ioctl = msm_mercury_ioctl,
-};
-
-static struct class *msm_mercury_class;
-static dev_t msm_mercury_devno;
-static struct msm_mercury_device *msm_mercury_device_p;
-
-int msm_mercury_subdev_init(struct v4l2_subdev *mercury_sd)
-{
-	int rc;
-	struct msm_mercury_device *pgmn_dev =
-		(struct msm_mercury_device *)mercury_sd->host_priv;
-
-	MCR_DBG("%s:%d: mercury_sd=0x%x pgmn_dev=0x%x\n",
-		__func__, __LINE__, (uint32_t)mercury_sd, (uint32_t)pgmn_dev);
-	rc = __msm_mercury_open(pgmn_dev);
-	MCR_DBG("%s:%d: rc=%d\n",
-		__func__, __LINE__, rc);
-	return rc;
-}
-
-static long msm_mercury_subdev_ioctl(struct v4l2_subdev *sd,
-	unsigned int cmd, void *arg)
-{
-	long rc;
-	struct msm_mercury_device *pgmn_dev =
-		(struct msm_mercury_device *)sd->host_priv;
-
-	MCR_DBG("%s: cmd=%d\n", __func__, cmd);
-
-	MCR_DBG("%s: pgmn_dev 0x%x", __func__, (uint32_t)pgmn_dev);
-
-	MCR_DBG("%s: Calling __msm_mercury_ioctl\n", __func__);
-
-	rc = __msm_mercury_ioctl(pgmn_dev, cmd, (unsigned long)arg);
-	pr_debug("%s: X\n", __func__);
-	return rc;
-}
-
-void msm_mercury_subdev_release(struct v4l2_subdev *mercury_sd)
-{
-	int rc;
-	struct msm_mercury_device *pgmn_dev =
-		(struct msm_mercury_device *)mercury_sd->host_priv;
-	MCR_DBG("%s:pgmn_dev=0x%x", __func__, (uint32_t)pgmn_dev);
-	rc = __msm_mercury_release(pgmn_dev);
-	MCR_DBG("%s:rc=%d", __func__, rc);
-}
-
-static const struct v4l2_subdev_core_ops msm_mercury_subdev_core_ops = {
-	.ioctl = msm_mercury_subdev_ioctl,
-};
-
-static const struct v4l2_subdev_ops msm_mercury_subdev_ops = {
-	.core = &msm_mercury_subdev_core_ops,
-};
-
-static int msm_mercury_init(struct platform_device *pdev)
-{
-	int rc = -1;
-	struct device *dev;
-
-	MCR_DBG("%s:\n", __func__);
-	msm_mercury_device_p = __msm_mercury_init(pdev);
-	if (msm_mercury_device_p == NULL) {
-		MCR_PR_ERR("%s: initialization failed\n", __func__);
-		goto fail;
-	}
-
-	v4l2_subdev_init(&msm_mercury_device_p->subdev,
-		&msm_mercury_subdev_ops);
-	v4l2_set_subdev_hostdata(&msm_mercury_device_p->subdev,
-		msm_mercury_device_p);
-	pr_debug("%s: msm_mercury_device_p 0x%x", __func__,
-		(uint32_t)msm_mercury_device_p);
-	MCR_DBG("%s:mercury: platform_set_drvdata\n", __func__);
-	platform_set_drvdata(pdev, &msm_mercury_device_p->subdev);
-
-	rc = alloc_chrdev_region(&msm_mercury_devno, 0, 1, MSM_MERCURY_NAME);
-	if (rc < 0) {
-		MCR_PR_ERR("%s: failed to allocate chrdev\n", __func__);
-		goto fail_1;
-	}
-
-	if (!msm_mercury_class) {
-		msm_mercury_class = class_create(THIS_MODULE, MSM_MERCURY_NAME);
-		if (IS_ERR(msm_mercury_class)) {
-			rc = PTR_ERR(msm_mercury_class);
-			MCR_PR_ERR("%s: create device class failed\n",
-				__func__);
-			goto fail_2;
-		}
-	}
-
-	dev = device_create(msm_mercury_class, NULL,
-		MKDEV(MAJOR(msm_mercury_devno), MINOR(msm_mercury_devno)), NULL,
-		"%s%d", MSM_MERCURY_NAME, 0);
-
-	if (IS_ERR(dev)) {
-		MCR_PR_ERR("%s: error creating device\n", __func__);
-		rc = -ENODEV;
-		goto fail_3;
-	}
-
-	cdev_init(&msm_mercury_device_p->cdev, &msm_mercury_fops);
-	msm_mercury_device_p->cdev.owner = THIS_MODULE;
-	msm_mercury_device_p->cdev.ops   =
-		(const struct file_operations *) &msm_mercury_fops;
-	rc = cdev_add(&msm_mercury_device_p->cdev, msm_mercury_devno, 1);
-	if (rc < 0) {
-		MCR_PR_ERR("%s: error adding cdev\n", __func__);
-		rc = -ENODEV;
-		goto fail_4;
-	}
-
-	MCR_DBG("%s %s: success\n", __func__, MSM_MERCURY_NAME);
-
-	return rc;
-
-fail_4:
-	device_destroy(msm_mercury_class, msm_mercury_devno);
-
-fail_3:
-	class_destroy(msm_mercury_class);
-
-fail_2:
-	unregister_chrdev_region(msm_mercury_devno, 1);
-
-fail_1:
-	__msm_mercury_exit(msm_mercury_device_p);
-
-fail:
-	return rc;
-}
-
-static void msm_mercury_exit(void)
-{
-	cdev_del(&msm_mercury_device_p->cdev);
-	device_destroy(msm_mercury_class, msm_mercury_devno);
-	class_destroy(msm_mercury_class);
-	unregister_chrdev_region(msm_mercury_devno, 1);
-
-	__msm_mercury_exit(msm_mercury_device_p);
-}
-
-static int __msm_mercury_probe(struct platform_device *pdev)
-{
-	return msm_mercury_init(pdev);
-}
-
-static int __msm_mercury_remove(struct platform_device *pdev)
-{
-	msm_mercury_exit();
-	return 0;
-}
-
-static struct platform_driver msm_mercury_driver = {
-	.probe  = __msm_mercury_probe,
-	.remove = __msm_mercury_remove,
-	.driver = {
-		.name = MSM_MERCURY_DRV_NAME,
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init msm_mercury_driver_init(void)
-{
-	int rc;
-	rc = platform_driver_register(&msm_mercury_driver);
-	return rc;
-}
-
-static void __exit msm_mercury_driver_exit(void)
-{
-	platform_driver_unregister(&msm_mercury_driver);
-}
-
-MODULE_DESCRIPTION("msm mercury jpeg driver");
-
-module_init(msm_mercury_driver_init);
-module_exit(msm_mercury_driver_exit);
diff --git a/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_hw.c b/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_hw.c
deleted file mode 100644
index 244c038..0000000
--- a/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_hw.c
+++ /dev/null
@@ -1,361 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#include <linux/module.h>
-#include <linux/delay.h>
-#include <linux/io.h>
-#include "msm_mercury_hw.h"
-#include "msm_mercury_common.h"
-#include "msm_mercury_hw_reg.h"
-#include "msm_mercury_macros.h"
-
-static void *mercury_region_base;
-static uint32_t mercury_region_size;
-
-
-void msm_mercury_hw_write(struct msm_mercury_hw_cmd *hw_cmd_p)
-{
-	uint32_t *paddr;
-	uint32_t old_data, new_data;
-
-	paddr = mercury_region_base + hw_cmd_p->offset;
-
-	if (hw_cmd_p->mask == 0xffffffff) {
-		old_data = 0;
-	} else {
-		old_data = readl_relaxed(paddr);
-		old_data &= ~hw_cmd_p->mask;
-	}
-
-	new_data = hw_cmd_p->data & hw_cmd_p->mask;
-	new_data |= old_data;
-	writel_relaxed(new_data, paddr);
-}
-
-uint32_t msm_mercury_hw_read(struct msm_mercury_hw_cmd *hw_cmd_p)
-{
-	uint32_t *paddr;
-	uint32_t data;
-
-	paddr = mercury_region_base + hw_cmd_p->offset;
-
-	data = readl_relaxed(paddr);
-	data &= hw_cmd_p->mask;
-
-	MCR_DBG("MERCURY_READ: offset=0x%04X data=0x%08X\n",
-		hw_cmd_p->offset, data);
-
-	return data;
-}
-
-void msm_mercury_hw_start_decode(void)
-{
-	struct msm_mercury_hw_cmd hw_cmd;
-
-	mercury_kread(JPEG_STATUS);
-	mercury_kread(RTDMA_JPEG_RD_STA_ACK);
-	mercury_kread(RTDMA_JPEG_WR_STA_ACK);
-	mercury_kread(RTDMA_JPEG_RD_BUF_Y_PNTR);
-	mercury_kread(RTDMA_JPEG_WR_BUF_Y_PNTR);
-	mercury_kread(RTDMA_JPEG_WR_BUF_U_PNTR);
-	mercury_kwrite(RTDMA_JPEG_RD_BUF_MNGR_BUF_ID_FIFO, (7<<2));
-	return;
-}
-
-void msm_mercury_hw_bitstream_buf_cfg(uint32_t bitstream_buf_addr)
-{
-	struct msm_mercury_hw_cmd hw_cmd;
-
-	mercury_kwrite(RTDMA_JPEG_RD_BUF_Y_PNTR, bitstream_buf_addr);
-	return;
-}
-
-
-void msm_mercury_hw_output_y_buf_cfg(uint32_t y_buf_addr)
-{
-	struct msm_mercury_hw_cmd hw_cmd;
-
-	mercury_kwrite(RTDMA_JPEG_WR_BUF_Y_PNTR, y_buf_addr);
-	return;
-}
-
-void msm_mercury_hw_output_u_buf_cfg(uint32_t u_buf_addr)
-{
-	struct msm_mercury_hw_cmd hw_cmd;
-
-	mercury_kwrite(RTDMA_JPEG_WR_BUF_U_PNTR, u_buf_addr);
-	return;
-}
-
-void msm_mercury_hw_output_v_buf_cfg(uint32_t v_buf_addr)
-{
-	struct msm_mercury_hw_cmd hw_cmd;
-
-	mercury_kwrite(RTDMA_JPEG_WR_BUF_V_PNTR, v_buf_addr);
-	return;
-}
-
-int msm_mercury_hw_wait(struct msm_mercury_hw_cmd *hw_cmd_p, int m_us)
-{
-	int tm = hw_cmd_p->n;
-	uint32_t data;
-	uint32_t wait_data = hw_cmd_p->data & hw_cmd_p->mask;
-
-	data = msm_mercury_hw_read(hw_cmd_p);
-	if (data != wait_data) {
-		while (tm) {
-			udelay(m_us);
-			data = msm_mercury_hw_read(hw_cmd_p);
-			if (data == wait_data)
-				break;
-			tm--;
-		}
-	}
-	hw_cmd_p->data = data;
-	return tm;
-}
-
-void msm_mercury_hw_irq_get_status(uint16_t *rd_irq, uint16_t *wr_irq)
-{
-	struct msm_mercury_hw_cmd hw_cmd;
-	rmb();
-	mercury_kread(RTDMA_JPEG_RD_STA_ACK);
-	*rd_irq = hw_cmd.data;
-
-	mercury_kread(RTDMA_JPEG_WR_STA_ACK);
-	*wr_irq = hw_cmd.data;
-	rmb();
-}
-
-void msm_mercury_hw_get_jpeg_status(uint32_t *jpeg_status)
-{
-	struct msm_mercury_hw_cmd hw_cmd;
-
-	rmb();
-	mercury_kread(JPEG_STATUS);
-	*jpeg_status = hw_cmd.data;
-	rmb();
-}
-
-uint32_t msm_mercury_get_restartInterval(void)
-{
-	struct msm_mercury_hw_cmd hw_cmd;
-
-	rmb();
-	mercury_kread(JPEG_DRI);
-	rmb();
-	return hw_cmd.data;
-
-}
-
-void msm_mercury_hw_rd_irq_clear(uint32_t val)
-{
-	struct msm_mercury_hw_cmd hw_cmd;
-	mercury_kwrite(RTDMA_JPEG_RD_STA_ACK, val);
-}
-
-void msm_mercury_hw_wr_irq_clear(uint32_t val)
-{
-	struct msm_mercury_hw_cmd hw_cmd;
-
-	mercury_kwrite(RTDMA_JPEG_WR_STA_ACK, val);
-}
-
-void msm_mercury_hw_set_rd_irq_mask(uint32_t val)
-{
-	struct msm_mercury_hw_cmd hw_cmd;
-
-	mercury_kwrite(RTDMA_JPEG_RD_INT_EN, val);
-}
-
-void msm_mercury_hw_set_wr_irq_mask(uint32_t val)
-{
-	struct msm_mercury_hw_cmd hw_cmd;
-
-	mercury_kwrite(RTDMA_JPEG_WR_INT_EN, val);
-}
-
-void msm_mercury_set_jpeg_ctl_common(uint32_t val)
-{
-	struct msm_mercury_hw_cmd hw_cmd;
-
-	mercury_kwrite(JPEG_CTRL_COMMON, val);
-}
-
-void msm_mercury_hw_reset(void)
-{
-	uint32_t val;
-	struct msm_mercury_hw_cmd hw_cmd;
-
-	wmb();
-	/* disable all interrupts*/
-	mercury_kwrite(RTDMA_JPEG_RD_INT_EN, 0);
-
-	mercury_kwrite(RTDMA_JPEG_WR_INT_EN, 0);
-
-	/* clear pending interrupts*/
-	val = 0;
-	MEM_OUTF2(&val, RTDMA_JPEG_WR_STA_ACK,
-		SW_RESET_ABORT_RDY_ACK,
-		ERR_ACK, 1, 1);
-	MEM_OUTF2(&val, RTDMA_JPEG_WR_STA_ACK, EOF_ACK, SOF_ACK, 1, 1);
-	mercury_kwrite(RTDMA_JPEG_WR_STA_ACK, val);
-
-	val = 0;
-	MEM_OUTF2(&val, RTDMA_JPEG_RD_STA_ACK, EOF_ACK, SOF_ACK, 1, 1);
-	mercury_kwrite(RTDMA_JPEG_RD_STA_ACK, val);
-
-	/* enable SWResetAbortRdyInt for core reset*/
-	val = 0;
-	MEM_OUTF(&val, RTDMA_JPEG_WR_INT_EN, SW_RESET_ABORT_RDY_EN, 1);
-	mercury_kwrite(RTDMA_JPEG_WR_INT_EN, val);
-
-	/* Reset Core from MMSS Fabric*/
-	mercury_core_reset();
-
-	/* disable all interrupts*/
-	mercury_kwrite(RTDMA_JPEG_WR_INT_EN, 0);
-
-	/* clear pending interrupts*/
-	val = 0;
-	MEM_OUTF2(&val, RTDMA_JPEG_WR_STA_ACK,
-		SW_RESET_ABORT_RDY_ACK,
-		ERR_ACK, 1, 1);
-	MEM_OUTF2(&val, RTDMA_JPEG_WR_STA_ACK, EOF_ACK, SOF_ACK, 1, 1);
-	mercury_kwrite(RTDMA_JPEG_WR_STA_ACK, val);
-
-	val = 0;
-	MEM_OUTF2(&val, RTDMA_JPEG_RD_STA_ACK, EOF_ACK, SOF_ACK, 1, 1);
-	mercury_kwrite(RTDMA_JPEG_RD_STA_ACK, val);
-
-	/* enable neccessary interrupt source*/
-	val = 0;
-	MEM_OUTF2(&val, RTDMA_JPEG_WR_INT_EN, EOF_EN, ERR_EN, 1, 1);
-	MEM_OUTF(&val, RTDMA_JPEG_WR_INT_EN, SW_RESET_ABORT_RDY_EN, 1);
-	mercury_kwrite(RTDMA_JPEG_WR_INT_EN, val);
-
-	wmb();
-
-}
-
-void msm_mercury_hw_init(void *base, int size)
-{
-	mercury_region_base = base;
-	mercury_region_size = size;
-}
-
-
-void msm_mercury_hw_delay(struct msm_mercury_hw_cmd *hw_cmd_p, int m_us)
-{
-	int tm = hw_cmd_p->n;
-	while (tm) {
-		udelay(m_us);
-		tm--;
-	}
-}
-
-int msm_mercury_hw_exec_cmds(struct msm_mercury_hw_cmd *hw_cmd_p, int m_cmds)
-{
-	int is_copy_to_user = -1;
-	uint32_t data;
-	if (m_cmds > 1)
-		MCR_DBG("m_cmds = %d\n", m_cmds);
-
-	while (m_cmds--) {
-		if (hw_cmd_p->offset > mercury_region_size) {
-			MCR_PR_ERR("%s:%d] %d exceed hw region %d\n",
-					__func__, __LINE__, hw_cmd_p->offset,
-					mercury_region_size);
-			return -EFAULT;
-		}
-
-		switch (hw_cmd_p->type) {
-		case MSM_MERCURY_HW_CMD_TYPE_READ:
-			hw_cmd_p->data = msm_mercury_hw_read(hw_cmd_p);
-			is_copy_to_user = 1;
-			break;
-
-		case MSM_MERCURY_HW_CMD_TYPE_WRITE:
-			msm_mercury_hw_write(hw_cmd_p);
-			break;
-
-		case MSM_MERCURY_HW_CMD_TYPE_WRITE_OR:
-			data = msm_mercury_hw_read(hw_cmd_p);
-			hw_cmd_p->data = (hw_cmd_p->data & hw_cmd_p->mask) |
-				data;
-			msm_mercury_hw_write(hw_cmd_p);
-			break;
-
-		case MSM_MERCURY_HW_CMD_TYPE_UWAIT:
-			msm_mercury_hw_wait(hw_cmd_p, 1);
-			break;
-
-		case MSM_MERCURY_HW_CMD_TYPE_MWAIT:
-			msm_mercury_hw_wait(hw_cmd_p, 1000);
-			break;
-
-		case MSM_MERCURY_HW_CMD_TYPE_UDELAY:
-			msm_mercury_hw_delay(hw_cmd_p, 1);
-			break;
-
-		case MSM_MERCURY_HW_CMD_TYPE_MDELAY:
-			msm_mercury_hw_delay(hw_cmd_p, 1000);
-			break;
-
-		default:
-			MCR_DBG("wrong hw command type\n");
-			break;
-		}
-
-		hw_cmd_p++;
-	}
-	return is_copy_to_user;
-}
-
-void msm_mercury_hw_region_dump(int size)
-{
-	uint32_t *p;
-	uint8_t *p8;
-
-	MCR_DBG("(%d)%s()\n", __LINE__, __func__);
-	if (size > mercury_region_size)
-		MCR_DBG("%s:%d] wrong region dump size\n",
-			__func__, __LINE__);
-
-	p = (uint32_t *) mercury_region_base;
-	while (size >= 16) {
-		MCR_DBG("0x%08X] %08X %08X %08X %08X\n",
-			mercury_region_size - size,
-			readl_relaxed(p), readl_relaxed(p+1),
-			readl_relaxed(p+2), readl_relaxed(p+3));
-		p += 4;
-		size -= 16;
-	}
-
-	if (size > 0) {
-		uint32_t d;
-		MCR_DBG("0x%08X] ", mercury_region_size - size);
-		while (size >= 4) {
-			MCR_DBG("%08X ", readl_relaxed(p++));
-			size -= 4;
-		}
-
-		d = readl_relaxed(p);
-		p8 = (uint8_t *) &d;
-		while (size) {
-			MCR_DBG("%02X", *p8++);
-			size--;
-		}
-
-		MCR_DBG("\n");
-	}
-}
diff --git a/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_hw.h b/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_hw.h
deleted file mode 100644
index 54fc818..0000000
--- a/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_hw.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#ifndef MSM_MERCURY_HW_H
-#define MSM_MERCURY_HW_H
-
-#include <media/msm_mercury.h>
-
-/*number of pel per block (horiz/vert)*/
-#define JPEGDEC_BLOCK_SIZE                 (8)
-/* Hardware alignment*/
-#define JPEGDEC_HW_ALIGN                   (8)
-#define JPEGDEC_HW_SAMPLING_RATIO_MAX      (4)
-
-#define MSM_MERCURY_HW_IRQ_SW_RESET_ACK    (1<<3)
-#define MSM_MERCURY_HW_IRQ_WR_ERR_ACK      (1<<2)
-#define MSM_MERCURY_HW_IRQ_WR_EOI_ACK      (1<<1)
-#define MSM_MERCURY_HW_IRQ_WR_SOF_ACK      (1<<0)
-
-#define MSM_MERCURY_HW_IRQ_RD_EOF_ACK      (1<<1)
-#define MSM_MERCURY_HW_IRQ_RD_SOF_ACK      (1<<0)
-
-extern int mercury_core_reset(void);
-
-struct msm_mercury_hw_buf {
-		struct msm_mercury_buf vbuf;
-		struct file  *file;
-		uint32_t framedone_len;
-		uint32_t y_buffer_addr;
-		uint32_t y_len;
-		uint32_t cbcr_buffer_addr;
-		uint32_t cbcr_len;
-		uint32_t num_of_mcu_rows;
-		struct msm_mapped_buffer *msm_buffer;
-		int *subsystem_id;
-		struct ion_handle *handle;
-};
-
-
-void msm_mercury_hw_reset(void);
-void msm_mercury_hw_init(void *base, int size);
-void msm_mercury_hw_rd_irq_clear(uint32_t val);
-void msm_mercury_hw_wr_irq_clear(uint32_t val);
-
-uint32_t msm_mercury_hw_read(struct msm_mercury_hw_cmd *hw_cmd_p);
-void msm_mercury_hw_write(struct msm_mercury_hw_cmd *hw_cmd_p);
-int msm_mercury_hw_wait(struct msm_mercury_hw_cmd *hw_cmd_p, int m_us);
-void msm_mercury_hw_delay(struct msm_mercury_hw_cmd *hw_cmd_p, int m_us);
-int msm_mercury_hw_exec_cmds(struct msm_mercury_hw_cmd *hw_cmd_p, int m_cmds);
-void msm_mercury_hw_region_dump(int size);
-
-
-void msm_mercury_hw_irq_get_status(uint16_t *rd_irq, uint16_t *wr_irq);
-void msm_mercury_hw_start_decode(void);
-void msm_mercury_hw_get_jpeg_status(uint32_t *jpeg_status);
-void msm_mercury_hw_output_y_buf_cfg(uint32_t y_buf_addr);
-void msm_mercury_hw_output_u_buf_cfg(uint32_t u_buf_addr);
-void msm_mercury_hw_output_v_buf_cfg(uint32_t v_buf_addr);
-void msm_mercury_hw_bitstream_buf_cfg(uint32_t bitstream_buf_addr);
-
-#endif /* MSM_MERCURY_HW_H */
diff --git a/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_hw_reg.h b/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_hw_reg.h
deleted file mode 100644
index 015bf49..0000000
--- a/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_hw_reg.h
+++ /dev/null
@@ -1,715 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#ifndef MSM_MERCURY_HW_REG_H
-#define MSM_MERCURY_HW_REG_H
-
-
-#define JPEGD_BASE  0x00000000
-
-/* Register ADDR, RMSK, and SHFT*/
-/* RW */
-#define JPEG_CTRL_COMMON                        JPEG_CTRL_COMMON
-#define HWIO_JPEG_CTRL_COMMON_ADDR            (JPEGD_BASE+0x00000000)
-#define HWIO_JPEG_CTRL_COMMON__POR                    0x00000000
-#define HWIO_JPEG_CTRL_COMMON__RMSK                   0x0000001F
-#define HWIO_JPEG_CTRL_COMMON__SHFT                            0
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEG_CTRL_COMMON__JPEG_CTRL_COMMON_ZZ_OVERRIDE_EN__BMSK 0x00000010
-#define HWIO_JPEG_CTRL_COMMON__JPEG_CTRL_COMMON_ZZ_OVERRIDE_EN__SHFT          4
-#define HWIO_JPEG_CTRL_COMMON__JPEG_CTRL_COMMON_MODE__BMSK           0x0000000F
-#define HWIO_JPEG_CTRL_COMMON__JPEG_CTRL_COMMON_MODE__SHFT                    0
-
-/* Register Field FMSK and SHFT*/
-/* RW */
-#define JPEG_CTRL_ENCODE                     JPEG_CTRL_ENCODE
-#define HWIO_JPEG_CTRL_ENCODE_ADDR        (JPEGD_BASE+0x00000008)
-#define HWIO_JPEG_CTRL_ENCODE__POR                 0x00000000
-#define HWIO_JPEG_CTRL_ENCODE__RMSK                0x00000010
-#define HWIO_JPEG_CTRL_ENCODE__SHFT                         4
-/* Register Element MIN and MAX*/
-#define HWIO_JPEG_CTRL_ENCODE___S                           4
-
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEG_CTRL_ENCODE__JPEG_CTRL_ENCODE_EOI_MARKER_EN__BMSK  0x00000010
-#define HWIO_JPEG_CTRL_ENCODE__JPEG_CTRL_ENCODE_EOI_MARKER_EN__SHFT           4
-
-/* Register Field FMSK and SHFT*/
-#define JPEG_STATUS                        JPEG_STATUS
-#define HWIO_JPEG_STATUS_ADDR        (JPEGD_BASE+0x00000010)
-#define HWIO_JPEG_STATUS__POR               0x00000000
-#define HWIO_JPEG_STATUS__RMSK              0x00003FF0
-#define HWIO_JPEG_STATUS__SHFT                       4
-/* Register Element MIN and MAX*/
-#define HWIO_JPEG_STATUS___S                         4
-
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEG_STATUS__JPEG_STATUS_REGISTER_TIMEOUT__BMSK       0x00002000
-#define HWIO_JPEG_STATUS__JPEG_STATUS_REGISTER_TIMEOUT__SHFT               13
-#define HWIO_JPEG_STATUS__JPEG_STATUS_DHDQ_EOI__BMSK               0x00001000
-#define HWIO_JPEG_STATUS__JPEG_STATUS_DHDQ_EOI__SHFT                       12
-#define HWIO_JPEG_STATUS__JPEG_STATUS_DHDQ_ERR_UNESCAPED_FF__BMSK  0x00000800
-#define HWIO_JPEG_STATUS__JPEG_STATUS_DHDQ_ERR_UNESCAPED_FF__SHFT          11
-#define HWIO_JPEG_STATUS__JPEG_STATUS_DHDQ_ERR_INV_HUFFCODE__BMSK  0x00000400
-#define HWIO_JPEG_STATUS__JPEG_STATUS_DHDQ_ERR_INV_HUFFCODE__SHFT          10
-#define HWIO_JPEG_STATUS__JPEG_STATUS_DHDQ_ERR_INV_MARKER__BMSK    0x00000200
-#define HWIO_JPEG_STATUS__JPEG_STATUS_DHDQ_ERR_INV_MARKER__SHFT             9
-#define HWIO_JPEG_STATUS__JPEG_STATUS_DHDQ_ERR_RSTRT_SEQ__BMSK     0x00000100
-#define HWIO_JPEG_STATUS__JPEG_STATUS_DHDQ_ERR_RSTRT_SEQ__SHFT              8
-#define HWIO_JPEG_STATUS__JPEG_STATUS_DHDQ_ERR_RSTRT_OVRFLW__BMSK  0x00000080
-#define HWIO_JPEG_STATUS__JPEG_STATUS_DHDQ_ERR_RSTRT_OVRFLW__SHFT           7
-#define HWIO_JPEG_STATUS__JPEG_STATUS_DHDQ_ERR_RSTRT_UNDFLW__BMSK  0x00000040
-#define HWIO_JPEG_STATUS__JPEG_STATUS_DHDQ_ERR_RSTRT_UNDFLW__SHFT           6
-#define HWIO_JPEG_STATUS__JPEG_STATUS_DHDQ_ERR_SCAN_OVRFLW__BMSK   0x00000020
-#define HWIO_JPEG_STATUS__JPEG_STATUS_DHDQ_ERR_SCAN_OVRFLW__SHFT            5
-#define HWIO_JPEG_STATUS__JPEG_STATUS_DHDQ_ERR_SCAN_UNDFLW__BMSK   0x00000010
-#define HWIO_JPEG_STATUS__JPEG_STATUS_DHDQ_ERR_SCAN_UNDFLW__SHFT            4
-
-/* Register ADDR, RMSK, and SHFT*/
-/* R */
-#define JPEG_SOF_REG_0                               JPEG_SOF_REG_0
-#define HWIO_JPEG_SOF_REG_0_ADDR  /* RW */               (JPEGD_BASE+0x00000014)
-#define HWIO_JPEG_SOF_REG_0__POR                         0x00000000
-#define HWIO_JPEG_SOF_REG_0__RMSK                        0x000000FF
-#define HWIO_JPEG_SOF_REG_0__SHFT                                 0
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEG_SOF_REG_0__JPEG_SOF_REG_0_NF__BMSK     0x000000FF
-#define HWIO_JPEG_SOF_REG_0__JPEG_SOF_REG_0_NF__SHFT              0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define JPEG_SOF_REG_1                               JPEG_SOF_REG_1
-#define HWIO_JPEG_SOF_REG_1_ADDR  /* RW */               (JPEGD_BASE+0x00000018)
-#define HWIO_JPEG_SOF_REG_1__POR                         0x00000000
-#define HWIO_JPEG_SOF_REG_1__RMSK                        0x00FFFFFF
-#define HWIO_JPEG_SOF_REG_1__SHFT                                 0
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEG_SOF_REG_1__JPEG_SOF_REG_1_C__BMSK      0x00FF0000
-#define HWIO_JPEG_SOF_REG_1__JPEG_SOF_REG_1_C__SHFT              16
-#define HWIO_JPEG_SOF_REG_1__JPEG_SOF_REG_1_H__BMSK      0x0000F000
-#define HWIO_JPEG_SOF_REG_1__JPEG_SOF_REG_1_H__SHFT              12
-#define HWIO_JPEG_SOF_REG_1__JPEG_SOF_REG_1_V__BMSK      0x00000F00
-#define HWIO_JPEG_SOF_REG_1__JPEG_SOF_REG_1_V__SHFT               8
-#define HWIO_JPEG_SOF_REG_1__JPEG_SOF_REG_1_TQ__BMSK     0x000000FF
-#define HWIO_JPEG_SOF_REG_1__JPEG_SOF_REG_1_TQ__SHFT              0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define JPEG_SOF_REG_2                               JPEG_SOF_REG_2
-#define HWIO_JPEG_SOF_REG_2_ADDR  /* RW */               (JPEGD_BASE+0x0000001C)
-#define HWIO_JPEG_SOF_REG_2__POR                         0x00000000
-#define HWIO_JPEG_SOF_REG_2__RMSK                        0xFFFFFFFF
-#define HWIO_JPEG_SOF_REG_2__SHFT                                 0
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEG_SOF_REG_2__JPEG_SOF_REG_2_Y__BMSK      0xFFFF0000
-#define HWIO_JPEG_SOF_REG_2__JPEG_SOF_REG_2_Y__SHFT              16
-#define HWIO_JPEG_SOF_REG_2__JPEG_SOF_REG_2_X__BMSK      0x0000FFFF
-#define HWIO_JPEG_SOF_REG_2__JPEG_SOF_REG_2_X__SHFT               0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define JPEG_SOS_REG_0                               JPEG_SOS_REG_0
-#define HWIO_JPEG_SOS_REG_0_ADDR  /* RW */               (JPEGD_BASE+0x00000020)
-#define HWIO_JPEG_SOS_REG_0__POR                         0x00000000
-#define HWIO_JPEG_SOS_REG_0__RMSK                        0xFF000000
-#define HWIO_JPEG_SOS_REG_0__SHFT                                24
-/*Register Element MIN and MAX*/
-#define HWIO_JPEG_SOS_REG_0___S                                  24
-#define HWIO_JPEG_SOS_REG_0___S                                  24
-#define HWIO_JPEG_SOS_REG_0___S                                  24
-#define HWIO_JPEG_SOS_REG_0___S                                  24
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEG_SOS_REG_0__JPEG_SOS_REG_0_NS__BMSK       0xFF000000
-#define HWIO_JPEG_SOS_REG_0__JPEG_SOS_REG_0_NS__SHFT               24
-
-/* Register ADDR, RMSK, and SHFT*/
-#define JPEG_SOS_REG_1                                   JPEG_SOS_REG_1
-#define HWIO_JPEG_SOS_REG_1_ADDR  /* RW */              (JPEGD_BASE+0x00000024)
-#define HWIO_JPEG_SOS_REG_1__POR                        0x00000000
-#define HWIO_JPEG_SOS_REG_1__RMSK                       0x0000FFFF
-#define HWIO_JPEG_SOS_REG_1__SHFT                                0
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEG_SOS_REG_1__JPEG_SOS_REG_1_CS__BMSK    0x0000FF00
-#define HWIO_JPEG_SOS_REG_1__JPEG_SOS_REG_1_CS__SHFT             8
-#define HWIO_JPEG_SOS_REG_1__JPEG_SOS_REG_1_TD__BMSK    0x000000F0
-#define HWIO_JPEG_SOS_REG_1__JPEG_SOS_REG_1_TD__SHFT             4
-#define HWIO_JPEG_SOS_REG_1__JPEG_SOS_REG_1_TA__BMSK    0x0000000F
-#define HWIO_JPEG_SOS_REG_1__JPEG_SOS_REG_1_TA__SHFT             0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define JPEG_QT_IDX                                       JPEG_QT_IDX
-#define HWIO_JPEG_QT_IDX_ADDR       (JPEGD_BASE+0x00000030)
-#define HWIO_JPEG_QT_IDX__POR                              0x00000000
-#define HWIO_JPEG_QT_IDX__RMSK                             0x0000FFFF
-#define HWIO_JPEG_QT_IDX__SHFT                                      0
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEG_QT_IDX__JPEG_QT_IDX_TABLE_1__BMSK        0x0000FF00
-#define HWIO_JPEG_QT_IDX__JPEG_QT_IDX_TABLE_1__SHFT                  8
-#define HWIO_JPEG_QT_IDX__JPEG_QT_IDX_TABLE_0__BMSK         0x000000FF
-#define HWIO_JPEG_QT_IDX__JPEG_QT_IDX_TABLE_0__SHFT                  0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define JPEG_DQT                                        JPEG_DQT
-#define HWIO_JPEG_DQT_ADDR  /* RW */                    (JPEGD_BASE+0x00000034)
-#define HWIO_JPEG_DQT__POR                              0x00000000
-#define HWIO_JPEG_DQT__RMSK                             0x0F00FFFF
-#define HWIO_JPEG_DQT__SHFT                             0
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEG_DQT__JPEG_DQT_TQ__BMSK                0x0F000000
-#define HWIO_JPEG_DQT__JPEG_DQT_TQ__SHFT                24
-#define HWIO_JPEG_DQT__JPEG_DQT_QK__BMSK                0x0000FFFF
-#define HWIO_JPEG_DQT__JPEG_DQT_QK__SHFT                0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define JPEG_DRI                                JPEG_DRI
-#define HWIO_JPEG_DRI_ADDR  /* RW */            (JPEGD_BASE+0x00000040)
-#define HWIO_JPEG_DRI__POR                      0x00000000
-#define HWIO_JPEG_DRI__RMSK                     0x0000FFFF
-#define HWIO_JPEG_DRI__SHFT                              0
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEG_DRI__JPEG_DRI_RI__BMSK        0x0000FFFF
-#define HWIO_JPEG_DRI__JPEG_DRI_RI__SHFT                 0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define JPEG_DHT_REG_0                               JPEG_DHT_REG_0
-#define HWIO_JPEG_DHT_REG_0_ADDR  /* RW */               (JPEGD_BASE+0x00000050)
-#define HWIO_JPEG_DHT_REG_0__POR                         0x00000000
-#define HWIO_JPEG_DHT_REG_0__RMSK                        0x000000FF
-#define HWIO_JPEG_DHT_REG_0__SHFT                                 0
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEG_DHT_REG_0__JPEG_DHT_REG_0_TH__BMSK     0x000000F0
-#define HWIO_JPEG_DHT_REG_0__JPEG_DHT_REG_0_TH__SHFT              4
-#define HWIO_JPEG_DHT_REG_0__JPEG_DHT_REG_0_TC__BMSK     0x0000000F
-#define HWIO_JPEG_DHT_REG_0__JPEG_DHT_REG_0_TC__SHFT              0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define JPEG_DHT_IDX                                        JPEG_DHT_IDX
-#define HWIO_JPEG_DHT_IDX_ADDR  /* RW */      (JPEGD_BASE+0x00000054)
-#define HWIO_JPEG_DHT_IDX__POR                                0x00000000
-#define HWIO_JPEG_DHT_IDX__RMSK                               0x00000FFF
-#define HWIO_JPEG_DHT_IDX__SHFT                                        0
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEG_DHT_IDX__JPEG_DHT_IDX_CCC_MAX__BMSK         0x00000F00
-#define HWIO_JPEG_DHT_IDX__JPEG_DHT_IDX_CCC_MAX__SHFT                  8
-#define HWIO_JPEG_DHT_IDX__JPEG_DHT_IDX_VIJ__BMSK             0x000000FF
-#define HWIO_JPEG_DHT_IDX__JPEG_DHT_IDX_VIJ__SHFT                      0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define JPEG_DHT_REG_1                          JPEG_DHT_REG_1
-#define HWIO_JPEG_DHT_REG_1_ADDR  /* RW */          (JPEGD_BASE+0x00000058)
-#define HWIO_JPEG_DHT_REG_1__POR                    0x00000000
-#define HWIO_JPEG_DHT_REG_1__RMSK                   0xFFFFFFFF
-#define HWIO_JPEG_DHT_REG_1__SHFT                            0
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEG_DHT_REG_1__JPEG_DHT_REG_1_VIJ_0__BMSK       0xFF000000
-#define HWIO_JPEG_DHT_REG_1__JPEG_DHT_REG_1_VIJ_0__SHFT               24
-#define HWIO_JPEG_DHT_REG_1__JPEG_DHT_REG_1_VIJ_1__BMSK       0x00FF0000
-#define HWIO_JPEG_DHT_REG_1__JPEG_DHT_REG_1_VIJ_1__SHFT               16
-#define HWIO_JPEG_DHT_REG_1__JPEG_DHT_REG_1_VIJ_2__BMSK       0x0000FF00
-#define HWIO_JPEG_DHT_REG_1__JPEG_DHT_REG_1_VIJ_2__SHFT                8
-#define HWIO_JPEG_DHT_REG_1__JPEG_DHT_REG_1_VIJ_3__BMSK       0x000000FF
-#define HWIO_JPEG_DHT_REG_1__JPEG_DHT_REG_1_VIJ_3__SHFT                0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define JPEG_DHT_CCC_MAX                          JPEG_DHT_CCC_MAX
-#define HWIO_JPEG_DHT_CCC_MAX_ADDR  /* RW */            (JPEGD_BASE+0x0000005C)
-#define HWIO_JPEG_DHT_CCC_MAX__POR                      0x00000000
-#define HWIO_JPEG_DHT_CCC_MAX__RMSK                     0xFFFFFFFF
-#define HWIO_JPEG_DHT_CCC_MAX__SHFT                              0
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEG_DHT_CCC_MAX__JPEG_DHT_CCC_MAX_MAX__BMSK    0xFFFF0000
-#define HWIO_JPEG_DHT_CCC_MAX__JPEG_DHT_CCC_MAX_MAX__SHFT            16
-#define HWIO_JPEG_DHT_CCC_MAX__JPEG_DHT_CCC_MAX_CCC__BMSK    0x0000FFFF
-#define HWIO_JPEG_DHT_CCC_MAX__JPEG_DHT_CCC_MAX_CCC__SHFT             0
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEG_DHT_CCC_MAX__JPEG_DHT_CCC_MAX_MAX__BMSK    0xFFFF0000
-#define HWIO_JPEG_DHT_CCC_MAX__JPEG_DHT_CCC_MAX_MAX__SHFT            16
-#define HWIO_JPEG_DHT_CCC_MAX__JPEG_DHT_CCC_MAX_CCC__BMSK    0x0000FFFF
-#define HWIO_JPEG_DHT_CCC_MAX__JPEG_DHT_CCC_MAX_CCC__SHFT             0
-#define HWIO_JPEG_DHT_CCC_MAX__JPEG_DHT_LI__BMSK       0x000000FF
-#define HWIO_JPEG_DHT_CCC_MAX__JPEG_DHT_LI__SHFT                0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define JPEG_DEC_SCALE                       JPEG_DEC_SCALE
-#define HWIO_JPEG_DEC_SCALE_ADDR  /* RW */       (JPEGD_BASE+0x00000060)
-#define HWIO_JPEG_DEC_SCALE__POR                 0x00000000
-#define HWIO_JPEG_DEC_SCALE__RMSK                0x00000003
-#define HWIO_JPEG_DEC_SCALE__SHFT                         0
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEG_DEC_SCALE__JPEG_DEC_SCALE_RATIO__BMSK       0x00000003
-#define HWIO_JPEG_DEC_SCALE__JPEG_DEC_SCALE_RATIO__SHFT                0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define JPEG_CONVERT                         JPEG_CONVERT
-#define HWIO_JPEG_CONVERT_ADDR  /* RW */       (JPEGD_BASE+0x00000064)
-#define HWIO_JPEG_CONVERT__POR                 0x00000000
-#define HWIO_JPEG_CONVERT__RMSK                0xFFFF13FF
-#define HWIO_JPEG_CONVERT__SHFT                         0
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEG_CONVERT__JPEG_CONVERT_MONO_CB_VALUE__BMSK      0xFF000000
-#define HWIO_JPEG_CONVERT__JPEG_CONVERT_MONO_CB_VALUE__SHFT              24
-#define HWIO_JPEG_CONVERT__JPEG_CONVERT_MONO_CR_VALUE__BMSK      0x00FF0000
-#define HWIO_JPEG_CONVERT__JPEG_CONVERT_MONO_CR_VALUE__SHFT              16
-#define HWIO_JPEG_CONVERT__JPEG_CONVERT_CLAMP_EN__BMSK           0x00001000
-#define HWIO_JPEG_CONVERT__JPEG_CONVERT_CLAMP_EN__SHFT                   12
-#define HWIO_JPEG_CONVERT__JPEG_CONVERT_CBCR_SWITCH__BMSK        0x00000200
-#define HWIO_JPEG_CONVERT__JPEG_CONVERT_CBCR_SWITCH__SHFT                 9
-#define HWIO_JPEG_CONVERT__JPEG_CONVERT_MONOCHROME_EN__BMSK      0x00000100
-#define HWIO_JPEG_CONVERT__JPEG_CONVERT_MONOCHROME_EN__SHFT               8
-#define HWIO_JPEG_CONVERT__JPEG_CONVERT_MEM_ORG__BMSK            0x000000C0
-#define HWIO_JPEG_CONVERT__JPEG_CONVERT_MEM_ORG__SHFT                     6
-#define HWIO_JPEG_CONVERT__JPEG_CONVERT_422_MCU_TYPE__BMSK       0x00000030
-#define HWIO_JPEG_CONVERT__JPEG_CONVERT_422_MCU_TYPE__SHFT                4
-#define HWIO_JPEG_CONVERT__JPEG_CONVERT_OUTPUT_FORMAT__BMSK      0x0000000C
-#define HWIO_JPEG_CONVERT__JPEG_CONVERT_OUTPUT_FORMAT__SHFT               2
-#define HWIO_JPEG_CONVERT__JPEG_CONVERT_INPUT_FORMAT__BMSK       0x00000003
-#define HWIO_JPEG_CONVERT__JPEG_CONVERT_INPUT_FORMAT__SHFT                0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define JPEG_ENC_BYTE_CNT                       JPEG_ENC_BYTE_CNT
-#define HWIO_JPEG_ENC_BYTE_CNT_ADDR  /* RW */          (JPEGD_BASE+0x00000070)
-#define HWIO_JPEG_ENC_BYTE_CNT__POR                    0x00000000
-#define HWIO_JPEG_ENC_BYTE_CNT__RMSK                   0xFFFFFFFF
-#define HWIO_JPEG_ENC_BYTE_CNT__SHFT                            0
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEG_ENC_BYTE_CNT__JPEG_ENC_BYTE_CNT_TOT__BMSK     0xFFFFFFFF
-#define HWIO_JPEG_ENC_BYTE_CNT__JPEG_ENC_BYTE_CNT_TOT__SHFT              0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define JPEG_DEBUG                                  JPEG_DEBUG
-#define HWIO_JPEG_DEBUG_ADDR  /* RW */              (JPEGD_BASE+0x00000080)
-#define HWIO_JPEG_DEBUG__POR                        0x4A504547
-#define HWIO_JPEG_DEBUG__RMSK                       0xFFFFFFFF
-#define HWIO_JPEG_DEBUG__SHFT                                0
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEG_DEBUG__JPEG_DEBUG__BMSK            0xFFFFFFFF
-#define HWIO_JPEG_DEBUG__JPEG_DEBUG__SHFT                     0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define JPEG_SPARE                                JPEG_SPARE
-#define HWIO_JPEG_SPARE_ADDR  /* RW */            (JPEGD_BASE+0x00000084)
-#define HWIO_JPEG_SPARE__POR                      0x00000000
-#define HWIO_JPEG_SPARE__RMSK                     0xFFFFFFFF
-#define HWIO_JPEG_SPARE__SHFT                              0
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEG_SPARE__JPEG_SPARE_00__BMSK            0xFFFFFFFF
-#define HWIO_JPEG_SPARE__JPEG_SPARE_00__SHFT                     0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define JPEG_REGISTER_TIMEOUT                       JPEG_REGISTER_TIMEOUT
-#define HWIO_JPEG_REGISTER_TIMEOUT_ADDR    (JPEGD_BASE+0x00000088)
-#define HWIO_JPEG_REGISTER_TIMEOUT__POR                        0x0000FFFF
-#define HWIO_JPEG_REGISTER_TIMEOUT__RMSK                       0x0000FFFF
-#define HWIO_JPEG_REGISTER_TIMEOUT__SHFT                                0
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEG_REGISTER_TIMEOUT__JPEG_TIMEOUT_VALUE__BMSK        0x0000FFFF
-#define HWIO_JPEG_REGISTER_TIMEOUT__JPEG_TIMEOUT_VALUE__SHFT                 0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define JPEGD_STATUS_BUS_DATA                     JPEGD_STATUS_BUS_DATA
-#define HWIO_JPEGD_STATUS_BUS_DATA_ADDR  /* RW */       (JPEGD_BASE+0x00000258)
-#define HWIO_JPEGD_STATUS_BUS_DATA__POR                      0x00000000
-#define HWIO_JPEGD_STATUS_BUS_DATA__RMSK                     0xFFFFFFFF
-#define HWIO_JPEGD_STATUS_BUS_DATA__SHFT                              0
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEGD_STATUS_BUS_DATA__STATUS_BUS_DATA__BMSK      0xFFFFFFFF
-#define HWIO_JPEGD_STATUS_BUS_DATA__STATUS_BUS_DATA__SHFT               0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define JPEGD_STATUS_BUS_CONFIG                     JPEGD_STATUS_BUS_CONFIG
-#define HWIO_JPEGD_STATUS_BUS_CONFIG_ADDR  /* RW */     (JPEGD_BASE+0x0000025C)
-#define HWIO_JPEGD_STATUS_BUS_CONFIG__POR                        0x00000000
-#define HWIO_JPEGD_STATUS_BUS_CONFIG__RMSK                       0x0000001F
-#define HWIO_JPEGD_STATUS_BUS_CONFIG__SHFT                                0
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEGD_STATUS_BUS_CONFIG__STATUS_BUS_SEL__BMSK         0x0000001F
-#define HWIO_JPEGD_STATUS_BUS_CONFIG__STATUS_BUS_SEL__SHFT                  0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define RTDMA_JPEG_AXI_CONFIG                       RTDMA_JPEG_AXI_CONFIG
-#define HWIO_RTDMA_JPEG_AXI_CONFIG_ADDR  /* RW */        (JPEGD_BASE+0x00000260)
-#define HWIO_RTDMA_JPEG_AXI_CONFIG__POR                        0x00000024
-#define HWIO_RTDMA_JPEG_AXI_CONFIG__RMSK                       0x00000FFF
-#define HWIO_RTDMA_JPEG_AXI_CONFIG__SHFT                                0
-/* Register Field FMSK and SHFT*/
-#define HWIO_RTDMA_JPEG_AXI_CONFIG__OUT_OF_ORDER_WR__BMSK          0x00000800
-#define HWIO_RTDMA_JPEG_AXI_CONFIG__OUT_OF_ORDER_WR__SHFT                  11
-#define HWIO_RTDMA_JPEG_AXI_CONFIG__OUT_OF_ORDER_RD__BMSK          0x00000400
-#define HWIO_RTDMA_JPEG_AXI_CONFIG__OUT_OF_ORDER_RD__SHFT                  10
-#define HWIO_RTDMA_JPEG_AXI_CONFIG__BOUND_LIMIT__BMSK              0x00000300
-#define HWIO_RTDMA_JPEG_AXI_CONFIG__BOUND_LIMIT__SHFT                       8
-#define HWIO_RTDMA_JPEG_AXI_CONFIG__PACK_TIMEOUT__BMSK             0x000000F0
-#define HWIO_RTDMA_JPEG_AXI_CONFIG__PACK_TIMEOUT__SHFT                      4
-#define HWIO_RTDMA_JPEG_AXI_CONFIG__PACK_MAX_BLEN__BMSK            0x0000000F
-#define HWIO_RTDMA_JPEG_AXI_CONFIG__PACK_MAX_BLEN__SHFT                     0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define JPEGD_CLK_CONTROL                             JPEGD_CLK_CONTROL
-#define HWIO_JPEGD_CLK_CONTROL_ADDR  /* RW */   (JPEGD_BASE+0x00000264)
-#define HWIO_JPEGD_CLK_CONTROL__POR             0x00000005
-#define HWIO_JPEGD_CLK_CONTROL__RMSK                         0x0000000F
-#define HWIO_JPEGD_CLK_CONTROL__SHFT                                  0
-/* Register Field FMSK and SHFT*/
-#define HWIO_JPEGD_CLK_CONTROL__JPEG_CLKIDLE__BMSK           0x00000008
-#define HWIO_JPEGD_CLK_CONTROL__JPEG_CLKIDLE__SHFT                    3
-#define HWIO_JPEGD_CLK_CONTROL__JPEG_CLKON__BMSK             0x00000004
-#define HWIO_JPEGD_CLK_CONTROL__JPEG_CLKON__SHFT                      2
-#define HWIO_JPEGD_CLK_CONTROL__AXI_CLKIDLE__BMSK            0x00000002
-#define HWIO_JPEGD_CLK_CONTROL__AXI_CLKIDLE__SHFT                     1
-#define HWIO_JPEGD_CLK_CONTROL__AXI_CLKON__BMSK              0x00000001
-#define HWIO_JPEGD_CLK_CONTROL__AXI_CLKON__SHFT                       0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define RTDMA_JPEG_WR_BUF_CONFIG                     RTDMA_JPEG_WR_BUF_CONFIG
-#define HWIO_RTDMA_JPEG_WR_BUF_CONFIG_ADDR  /* RW */   (JPEGD_BASE+0x00000200)
-#define HWIO_RTDMA_JPEG_WR_BUF_CONFIG__POR             0x00000000
-#define HWIO_RTDMA_JPEG_WR_BUF_CONFIG__RMSK            0x0000001F
-#define HWIO_RTDMA_JPEG_WR_BUF_CONFIG__SHFT                     0
-/* Register Field FMSK and SHFT*/
-#define HWIO_RTDMA_JPEG_WR_BUF_CONFIG__BUF_FORMAT__BMSK         0x0000001C
-#define HWIO_RTDMA_JPEG_WR_BUF_CONFIG__BUF_FORMAT__SHFT                  2
-#define HWIO_RTDMA_JPEG_WR_BUF_CONFIG__NUM_OF_PLANES__BMSK      0x00000003
-#define HWIO_RTDMA_JPEG_WR_BUF_CONFIG__NUM_OF_PLANES__SHFT               0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define RTDMA_JPEG_WR_OP                               RTDMA_JPEG_WR_OP
-#define HWIO_RTDMA_JPEG_WR_OP_ADDR  /* RW */        (JPEGD_BASE+0x00000204)
-#define HWIO_RTDMA_JPEG_WR_OP__POR                  0x00000000
-#define HWIO_RTDMA_JPEG_WR_OP__RMSK                 0x00000013
-#define HWIO_RTDMA_JPEG_WR_OP__SHFT                          0
-/* Register Field FMSK and SHFT*/
-#define HWIO_RTDMA_JPEG_WR_OP__ALIGN__BMSK          0x00000010
-#define HWIO_RTDMA_JPEG_WR_OP__ALIGN__SHFT                   4
-#define HWIO_RTDMA_JPEG_WR_OP__FLIP__BMSK           0x00000002
-#define HWIO_RTDMA_JPEG_WR_OP__FLIP__SHFT                    1
-#define HWIO_RTDMA_JPEG_WR_OP__MIRROR__BMSK         0x00000001
-#define HWIO_RTDMA_JPEG_WR_OP__MIRROR__SHFT                  0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define RTDMA_JPEG_WR_BUF_Y_PNTR                      RTDMA_JPEG_WR_BUF_Y_PNTR
-#define HWIO_RTDMA_JPEG_WR_BUF_Y_PNTR_ADDR    (JPEGD_BASE+0x00000208)
-#define HWIO_RTDMA_JPEG_WR_BUF_Y_PNTR__POR                0x00000000
-#define HWIO_RTDMA_JPEG_WR_BUF_Y_PNTR__RMSK               0xFFFFFFF8
-#define HWIO_RTDMA_JPEG_WR_BUF_Y_PNTR__SHFT                        3
-/* Register Element MIN and MAX*/
-#define HWIO_RTDMA_JPEG_WR_BUF_Y_PNTR___S                          3
-#define HWIO_RTDMA_JPEG_WR_BUF_Y_PNTR___S                          3
-#define HWIO_RTDMA_JPEG_WR_BUF_Y_PNTR___S                          3
-#define HWIO_RTDMA_JPEG_WR_BUF_Y_PNTR___S                          3
-
-/* Register Field FMSK and SHFT*/
-#define HWIO_RTDMA_JPEG_WR_BUF_Y_PNTR__PNTR__BMSK         0xFFFFFFF8
-#define HWIO_RTDMA_JPEG_WR_BUF_Y_PNTR__PNTR__SHFT                  3
-
-/* Register ADDR, RMSK, and SHFT*/
-#define RTDMA_JPEG_WR_BUF_U_PNTR                      RTDMA_JPEG_WR_BUF_U_PNTR
-#define HWIO_RTDMA_JPEG_WR_BUF_U_PNTR_ADDR  /* RW */     (JPEGD_BASE+0x0000020C)
-#define HWIO_RTDMA_JPEG_WR_BUF_U_PNTR__POR               0x00000000
-#define HWIO_RTDMA_JPEG_WR_BUF_U_PNTR__RMSK              0xFFFFFFF8
-#define HWIO_RTDMA_JPEG_WR_BUF_U_PNTR__SHFT                       3
-
-/* Register Element MIN and MAX*/
-#define HWIO_RTDMA_JPEG_WR_BUF_U_PNTR___S                         3
-#define HWIO_RTDMA_JPEG_WR_BUF_U_PNTR___S                         3
-#define HWIO_RTDMA_JPEG_WR_BUF_U_PNTR___S                         3
-#define HWIO_RTDMA_JPEG_WR_BUF_U_PNTR___S                         3
-
-/* Register Field FMSK and SHFT*/
-#define HWIO_RTDMA_JPEG_WR_BUF_U_PNTR__PNTR__BMSK        0xFFFFFFF8
-#define HWIO_RTDMA_JPEG_WR_BUF_U_PNTR__PNTR__SHFT                 3
-
-/* Register ADDR, RMSK, and SHFT*/
-#define RTDMA_JPEG_WR_BUF_V_PNTR                       RTDMA_JPEG_WR_BUF_V_PNTR
-#define HWIO_RTDMA_JPEG_WR_BUF_V_PNTR_ADDR   (JPEGD_BASE+0x00000210)
-#define HWIO_RTDMA_JPEG_WR_BUF_V_PNTR__POR                0x00000000
-#define HWIO_RTDMA_JPEG_WR_BUF_V_PNTR__RMSK               0xFFFFFFF8
-#define HWIO_RTDMA_JPEG_WR_BUF_V_PNTR__SHFT                        3
-
-/* Register Element MIN and MAX*/
-#define HWIO_RTDMA_JPEG_WR_BUF_V_PNTR___S                          3
-#define HWIO_RTDMA_JPEG_WR_BUF_V_PNTR___S                          3
-#define HWIO_RTDMA_JPEG_WR_BUF_V_PNTR___S                          3
-#define HWIO_RTDMA_JPEG_WR_BUF_V_PNTR___S                          3
-
-/* Register Field FMSK and SHFT*/
-#define HWIO_RTDMA_JPEG_WR_BUF_V_PNTR__PNTR__BMSK         0xFFFFFFF8
-#define HWIO_RTDMA_JPEG_WR_BUF_V_PNTR__PNTR__SHFT                  3
-
-/* Register ADDR, RMSK, and SHFT*/
-#define RTDMA_JPEG_WR_BUF_PITCH                         RTDMA_JPEG_WR_BUF_PITCH
-#define HWIO_RTDMA_JPEG_WR_BUF_PITCH_ADDR  /* RW */    (JPEGD_BASE+0x00000214)
-#define HWIO_RTDMA_JPEG_WR_BUF_PITCH__POR              0x00000000
-#define HWIO_RTDMA_JPEG_WR_BUF_PITCH__RMSK             0x00003FF8
-#define HWIO_RTDMA_JPEG_WR_BUF_PITCH__SHFT                      3
-
-/* Register Element MIN and MAX*/
-#define HWIO_RTDMA_JPEG_WR_BUF_PITCH___S                        3
-#define HWIO_RTDMA_JPEG_WR_BUF_PITCH___S                        3
-#define HWIO_RTDMA_JPEG_WR_BUF_PITCH___S                        3
-#define HWIO_RTDMA_JPEG_WR_BUF_PITCH___S                        3
-
-/* Register Field FMSK and SHFT*/
-#define HWIO_RTDMA_JPEG_WR_BUF_PITCH__PITCH__BMSK          0x00003FF8
-#define HWIO_RTDMA_JPEG_WR_BUF_PITCH__PITCH__SHFT                   3
-
-/* Register ADDR, RMSK, and SHFT*/
-#define RTDMA_JPEG_WR_PLANE_SIZE                      RTDMA_JPEG_WR_PLANE_SIZE
-#define HWIO_RTDMA_JPEG_WR_PLANE_SIZE_ADDR  /* RW */  (JPEGD_BASE+0x00000218)
-#define HWIO_RTDMA_JPEG_WR_PLANE_SIZE__POR            0x00000000
-#define HWIO_RTDMA_JPEG_WR_PLANE_SIZE__RMSK           0x1FFF1FFF
-#define HWIO_RTDMA_JPEG_WR_PLANE_SIZE__SHFT                    0
-
-/* Register Field FMSK and SHFT*/
-#define HWIO_RTDMA_JPEG_WR_PLANE_SIZE__PLANE_VSIZE__BMSK       0x1FFF0000
-#define HWIO_RTDMA_JPEG_WR_PLANE_SIZE__PLANE_VSIZE__SHFT               16
-#define HWIO_RTDMA_JPEG_WR_PLANE_SIZE__PLANE_HSIZE__BMSK       0x00001FFF
-#define HWIO_RTDMA_JPEG_WR_PLANE_SIZE__PLANE_HSIZE__SHFT                0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define RTDMA_JPEG_WR_BLOCK_SIZE                      RTDMA_JPEG_WR_BLOCK_SIZE
-#define HWIO_RTDMA_JPEG_WR_BLOCK_SIZE_ADDR  /* RW */    (JPEGD_BASE+0x0000021C)
-#define HWIO_RTDMA_JPEG_WR_BLOCK_SIZE__POR              0x00000000
-#define HWIO_RTDMA_JPEG_WR_BLOCK_SIZE__RMSK             0x00000FFF
-#define HWIO_RTDMA_JPEG_WR_BLOCK_SIZE__SHFT                      0
-
-/* Register Field FMSK and SHFT*/
-#define HWIO_RTDMA_JPEG_WR_BLOCK_SIZE__BLOCK_VSIZE__BMSK           0x00000FC0
-#define HWIO_RTDMA_JPEG_WR_BLOCK_SIZE__BLOCK_VSIZE__SHFT                    6
-#define HWIO_RTDMA_JPEG_WR_BLOCK_SIZE__BLOCK_HSIZE__BMSK           0x0000003F
-#define HWIO_RTDMA_JPEG_WR_BLOCK_SIZE__BLOCK_HSIZE__SHFT                    0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define RTDMA_JPEG_WR_BUFFER_SIZE                      RTDMA_JPEG_WR_BUFFER_SIZE
-#define HWIO_RTDMA_JPEG_WR_BUFFER_SIZE_ADDR  /* RW */   (JPEGD_BASE+0x00000220)
-#define HWIO_RTDMA_JPEG_WR_BUFFER_SIZE__POR             0x00000000
-#define HWIO_RTDMA_JPEG_WR_BUFFER_SIZE__RMSK            0x00001FFF
-#define HWIO_RTDMA_JPEG_WR_BUFFER_SIZE__SHFT                     0
-
-/* Register Field FMSK and SHFT*/
-#define HWIO_RTDMA_JPEG_WR_BUFFER_SIZE__BUFFER_VSIZE__BMSK         0x00001FFF
-#define HWIO_RTDMA_JPEG_WR_BUFFER_SIZE__BUFFER_VSIZE__SHFT                  0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define RTDMA_JPEG_WR_STA_ACK                      RTDMA_JPEG_WR_STA_ACK
-#define HWIO_RTDMA_JPEG_WR_STA_ACK_ADDR  /* RW */   (JPEGD_BASE+0x00000224)
-#define HWIO_RTDMA_JPEG_WR_STA_ACK__POR             0x00000000
-#define HWIO_RTDMA_JPEG_WR_STA_ACK__RMSK            0x0000000F
-#define HWIO_RTDMA_JPEG_WR_STA_ACK__SHFT                     3
-
-/* Register Element MIN and MAX*/
-#define HWIO_RTDMA_JPEG_WR_STA_ACK___S                       3
-#define HWIO_RTDMA_JPEG_WR_STA_ACK___S                       3
-#define HWIO_RTDMA_JPEG_WR_STA_ACK___S                       3
-#define HWIO_RTDMA_JPEG_WR_STA_ACK___S                       3
-
-/* Register Field FMSK and SHFT*/
-#define HWIO_RTDMA_JPEG_WR_STA_ACK__SW_RESET_ABORT_RDY_STA__BMSK   0x00000008
-#define HWIO_RTDMA_JPEG_WR_STA_ACK__SW_RESET_ABORT_RDY_STA__SHFT            3
-#define HWIO_RTDMA_JPEG_WR_STA_ACK__SW_RESET_ABORT_RDY_ACK__BMSK   0x00000008
-#define HWIO_RTDMA_JPEG_WR_STA_ACK__SW_RESET_ABORT_RDY_ACK__SHFT            3
-#define HWIO_RTDMA_JPEG_WR_STA_ACK__ERR_STA__BMSK                  0x00000004
-#define HWIO_RTDMA_JPEG_WR_STA_ACK__ERR_STA__SHFT                           2
-#define HWIO_RTDMA_JPEG_WR_STA_ACK__ERR_ACK__BMSK                  0x00000004
-#define HWIO_RTDMA_JPEG_WR_STA_ACK__ERR_ACK__SHFT                           2
-#define HWIO_RTDMA_JPEG_WR_STA_ACK__EOF_STA__BMSK                  0x00000002
-#define HWIO_RTDMA_JPEG_WR_STA_ACK__EOF_STA__SHFT                           1
-#define HWIO_RTDMA_JPEG_WR_STA_ACK__EOF_ACK__BMSK                  0x00000002
-#define HWIO_RTDMA_JPEG_WR_STA_ACK__EOF_ACK__SHFT                           1
-#define HWIO_RTDMA_JPEG_WR_STA_ACK__SOF_STA__BMSK                  0x00000001
-#define HWIO_RTDMA_JPEG_WR_STA_ACK__SOF_STA__SHFT                           0
-#define HWIO_RTDMA_JPEG_WR_STA_ACK__SOF_ACK__BMSK           0x00000001
-#define HWIO_RTDMA_JPEG_WR_STA_ACK__SOF_ACK__SHFT                    0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define RTDMA_JPEG_WR_INT_EN                      RTDMA_JPEG_WR_INT_EN
-#define HWIO_RTDMA_JPEG_WR_INT_EN_ADDR  /* W */        (JPEGD_BASE+0x00000228)
-#define HWIO_RTDMA_JPEG_WR_INT_EN__POR                 0x00000000
-#define HWIO_RTDMA_JPEG_WR_INT_EN__RMSK                0x0000000F
-#define HWIO_RTDMA_JPEG_WR_INT_EN__SHFT                         0
-
-/* Register Field FMSK and SHFT*/
-#define HWIO_RTDMA_JPEG_WR_INT_EN__SW_RESET_ABORT_RDY_EN__BMSK 0x00000008
-#define HWIO_RTDMA_JPEG_WR_INT_EN__SW_RESET_ABORT_RDY_EN__SHFT          3
-#define HWIO_RTDMA_JPEG_WR_INT_EN__ERR_EN__BMSK                0x00000004
-#define HWIO_RTDMA_JPEG_WR_INT_EN__ERR_EN__SHFT                         2
-#define HWIO_RTDMA_JPEG_WR_INT_EN__EOF_EN__BMSK                0x00000002
-#define HWIO_RTDMA_JPEG_WR_INT_EN__EOF_EN__SHFT                         1
-#define HWIO_RTDMA_JPEG_WR_INT_EN__SOF_EN__BMSK                0x00000001
-#define HWIO_RTDMA_JPEG_WR_INT_EN__SOF_EN__SHFT                         0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define RTDMA_JPEG_RD_BUF_CONFIG                     RTDMA_JPEG_RD_BUF_CONFIG
-#define HWIO_RTDMA_JPEG_RD_BUF_CONFIG_ADDR  /* RW */     (JPEGD_BASE+0x00000100)
-#define HWIO_RTDMA_JPEG_RD_BUF_CONFIG__POR               0x00000000
-#define HWIO_RTDMA_JPEG_RD_BUF_CONFIG__RMSK              0x0000001F
-#define HWIO_RTDMA_JPEG_RD_BUF_CONFIG__SHFT                       0
-
-/* Register Field FMSK and SHFT*/
-#define HWIO_RTDMA_JPEG_RD_BUF_CONFIG__BUF_FORMAT__BMSK          0x0000001C
-#define HWIO_RTDMA_JPEG_RD_BUF_CONFIG__BUF_FORMAT__SHFT                   2
-#define HWIO_RTDMA_JPEG_RD_BUF_CONFIG__NUM_OF_PLANES__BMSK       0x00000003
-#define HWIO_RTDMA_JPEG_RD_BUF_CONFIG__NUM_OF_PLANES__SHFT                0
-
-/* Register ADDR, RMSK, and SHFT, W */
-#define RTDMA_JPEG_RD_BUF_MNGR_BUF_ID_FIFO   RTDMA_JPEG_RD_BUF_MNGR_BUF_ID_FIFO
-#define HWIO_RTDMA_JPEG_RD_BUF_MNGR_BUF_ID_FIFO_ADDR  (JPEGD_BASE+0x00000104)
-#define HWIO_RTDMA_JPEG_RD_BUF_MNGR_BUF_ID_FIFO__POR            0x00000000
-#define HWIO_RTDMA_JPEG_RD_BUF_MNGR_BUF_ID_FIFO__RMSK           0x0000001C
-#define HWIO_RTDMA_JPEG_RD_BUF_MNGR_BUF_ID_FIFO__SHFT                    2
-
-/* Register Element MIN and MAX*/
-#define HWIO_RTDMA_JPEG_RD_BUF_MNGR_BUF_ID_FIFO___S                      2
-#define HWIO_RTDMA_JPEG_RD_BUF_MNGR_BUF_ID_FIFO___S                      2
-#define HWIO_RTDMA_JPEG_RD_BUF_MNGR_BUF_ID_FIFO___S                      2
-#define HWIO_RTDMA_JPEG_RD_BUF_MNGR_BUF_ID_FIFO___S                      2
-
-/* Register Field FMSK and SHFT*/
-#define HWIO_RTDMA_JPEG_RD_BUF_MNGR_BUF_ID_FIFO__BUF_APPLY__BMSK   0x00000010
-#define HWIO_RTDMA_JPEG_RD_BUF_MNGR_BUF_ID_FIFO__BUF_APPLY__SHFT            4
-#define HWIO_RTDMA_JPEG_RD_BUF_MNGR_BUF_ID_FIFO__BUF_EOF__BMSK     0x00000008
-#define HWIO_RTDMA_JPEG_RD_BUF_MNGR_BUF_ID_FIFO__BUF_EOF__SHFT              3
-#define HWIO_RTDMA_JPEG_RD_BUF_MNGR_BUF_ID_FIFO__BUF_SOF__BMSK     0x00000004
-#define HWIO_RTDMA_JPEG_RD_BUF_MNGR_BUF_ID_FIFO__BUF_SOF__SHFT              2
-
-/* Register ADDR, RMSK, and SHFT*/
-#define RTDMA_JPEG_RD_BUF_Y_PNTR                        RTDMA_JPEG_RD_BUF_Y_PNTR
-#define HWIO_RTDMA_JPEG_RD_BUF_Y_PNTR_ADDR  /* RW */   (JPEGD_BASE+0x0000010C)
-#define HWIO_RTDMA_JPEG_RD_BUF_Y_PNTR__POR             0x00000000
-#define HWIO_RTDMA_JPEG_RD_BUF_Y_PNTR__RMSK            0xFFFFFFF8
-#define HWIO_RTDMA_JPEG_RD_BUF_Y_PNTR__SHFT                     3
-
-/* Register Element MIN and MAX*/
-#define HWIO_RTDMA_JPEG_RD_BUF_Y_PNTR___S                       3
-#define HWIO_RTDMA_JPEG_RD_BUF_Y_PNTR___S                       3
-#define HWIO_RTDMA_JPEG_RD_BUF_Y_PNTR___S                       3
-#define HWIO_RTDMA_JPEG_RD_BUF_Y_PNTR___S                       3
-
-/* Register Field FMSK and SHFT*/
-#define HWIO_RTDMA_JPEG_RD_BUF_Y_PNTR__PNTR__BMSK      0xFFFFFFF8
-#define HWIO_RTDMA_JPEG_RD_BUF_Y_PNTR__PNTR__SHFT               3
-
-/* Register ADDR, RMSK, and SHFT*/
-#define RTDMA_JPEG_RD_BUF_U_PNTR                     RTDMA_JPEG_RD_BUF_U_PNTR
-#define HWIO_RTDMA_JPEG_RD_BUF_U_PNTR_ADDR  /* RW */ (JPEGD_BASE+0x00000110)
-#define HWIO_RTDMA_JPEG_RD_BUF_U_PNTR__POR           0x00000000
-#define HWIO_RTDMA_JPEG_RD_BUF_U_PNTR__RMSK          0xFFFFFFF8
-#define HWIO_RTDMA_JPEG_RD_BUF_U_PNTR__SHFT                   3
-
-/* Register Element MIN and MAX*/
-#define HWIO_RTDMA_JPEG_RD_BUF_U_PNTR___S                     3
-#define HWIO_RTDMA_JPEG_RD_BUF_U_PNTR___S                     3
-#define HWIO_RTDMA_JPEG_RD_BUF_U_PNTR___S                     3
-#define HWIO_RTDMA_JPEG_RD_BUF_U_PNTR___S                     3
-
-/* Register Field FMSK and SHFT*/
-#define HWIO_RTDMA_JPEG_RD_BUF_U_PNTR__PNTR__BMSK        0xFFFFFFF8
-#define HWIO_RTDMA_JPEG_RD_BUF_U_PNTR__PNTR__SHFT               3
-
-/* Register ADDR, RMSK, and SHFT*/
-#define RTDMA_JPEG_RD_BUF_V_PNTR                     RTDMA_JPEG_RD_BUF_V_PNTR
-#define HWIO_RTDMA_JPEG_RD_BUF_V_PNTR_ADDR  /* RW */    (JPEGD_BASE+0x00000114)
-#define HWIO_RTDMA_JPEG_RD_BUF_V_PNTR__POR              0x00000000
-#define HWIO_RTDMA_JPEG_RD_BUF_V_PNTR__RMSK             0xFFFFFFF8
-#define HWIO_RTDMA_JPEG_RD_BUF_V_PNTR__SHFT                      3
-
-/* Register Element MIN and MAX*/
-#define HWIO_RTDMA_JPEG_RD_BUF_V_PNTR___S                        3
-#define HWIO_RTDMA_JPEG_RD_BUF_V_PNTR___S                        3
-#define HWIO_RTDMA_JPEG_RD_BUF_V_PNTR___S                        3
-#define HWIO_RTDMA_JPEG_RD_BUF_V_PNTR___S                        3
-
-/* Register Field FMSK and SHFT*/
-#define HWIO_RTDMA_JPEG_RD_BUF_V_PNTR__PNTR__BMSK       0xFFFFFFF8
-#define HWIO_RTDMA_JPEG_RD_BUF_V_PNTR__PNTR__SHFT                3
-
-/* Register ADDR, RMSK, and SHFT*/
-#define RTDMA_JPEG_RD_BUF_PITCH                       RTDMA_JPEG_RD_BUF_PITCH
-#define HWIO_RTDMA_JPEG_RD_BUF_PITCH_ADDR  /* RW */    (JPEGD_BASE+0x00000118)
-#define HWIO_RTDMA_JPEG_RD_BUF_PITCH__POR              0x00000000
-#define HWIO_RTDMA_JPEG_RD_BUF_PITCH__RMSK             0x00003FF8
-#define HWIO_RTDMA_JPEG_RD_BUF_PITCH__SHFT                      3
-
-/* Register Element MIN and MAX*/
-#define HWIO_RTDMA_JPEG_RD_BUF_PITCH___S                        3
-#define HWIO_RTDMA_JPEG_RD_BUF_PITCH___S                        3
-#define HWIO_RTDMA_JPEG_RD_BUF_PITCH___S                        3
-#define HWIO_RTDMA_JPEG_RD_BUF_PITCH___S                        3
-
-/* Register Field FMSK and SHFT*/
-#define HWIO_RTDMA_JPEG_RD_BUF_PITCH__PITCH__BMSK            0x00003FF8
-#define HWIO_RTDMA_JPEG_RD_BUF_PITCH__PITCH__SHFT                     3
-
-/* Register ADDR, RMSK, and SHFT*/
-#define RTDMA_JPEG_RD_PLANE_SIZE                     RTDMA_JPEG_RD_PLANE_SIZE
-#define HWIO_RTDMA_JPEG_RD_PLANE_SIZE_ADDR  /* RW */  (JPEGD_BASE+0x0000011C)
-#define HWIO_RTDMA_JPEG_RD_PLANE_SIZE__POR            0x00000000
-#define HWIO_RTDMA_JPEG_RD_PLANE_SIZE__RMSK            0x1FFF1FFF
-#define HWIO_RTDMA_JPEG_RD_PLANE_SIZE__SHFT                     0
-
-/* Register Field FMSK and SHFT*/
-#define HWIO_RTDMA_JPEG_RD_PLANE_SIZE__PLANE_VSIZE__BMSK         0x1FFF0000
-#define HWIO_RTDMA_JPEG_RD_PLANE_SIZE__PLANE_VSIZE__SHFT                 16
-#define HWIO_RTDMA_JPEG_RD_PLANE_SIZE__PLANE_HSIZE__BMSK         0x00001FFF
-#define HWIO_RTDMA_JPEG_RD_PLANE_SIZE__PLANE_HSIZE__SHFT                  0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define RTDMA_JPEG_RD_BLOCK_SIZE                       RTDMA_JPEG_RD_BLOCK_SIZE
-#define HWIO_RTDMA_JPEG_RD_BLOCK_SIZE_ADDR  /* RW */    (JPEGD_BASE+0x00000120)
-#define HWIO_RTDMA_JPEG_RD_BLOCK_SIZE__POR              0x000003CF
-#define HWIO_RTDMA_JPEG_RD_BLOCK_SIZE__RMSK             0x00000FFF
-#define HWIO_RTDMA_JPEG_RD_BLOCK_SIZE__SHFT                      0
-
-/* Register Field FMSK and SHFT*/
-#define HWIO_RTDMA_JPEG_RD_BLOCK_SIZE__BLOCK_VSIZE__BMSK       0x00000FC0
-#define HWIO_RTDMA_JPEG_RD_BLOCK_SIZE__BLOCK_VSIZE__SHFT                6
-#define HWIO_RTDMA_JPEG_RD_BLOCK_SIZE__BLOCK_HSIZE__BMSK       0x0000003F
-#define HWIO_RTDMA_JPEG_RD_BLOCK_SIZE__BLOCK_HSIZE__SHFT                0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define RTDMA_JPEG_RD_BUFFER_SIZE               RTDMA_JPEG_RD_BUFFER_SIZE
-#define HWIO_RTDMA_JPEG_RD_BUFFER_SIZE_ADDR  (JPEGD_BASE+0x00000124)
-#define HWIO_RTDMA_JPEG_RD_BUFFER_SIZE__POR               0x00000000
-#define HWIO_RTDMA_JPEG_RD_BUFFER_SIZE__RMSK              0x00001FFF
-#define HWIO_RTDMA_JPEG_RD_BUFFER_SIZE__SHFT                       0
-
-/* Register Field FMSK and SHFT*/
-#define HWIO_RTDMA_JPEG_RD_BUFFER_SIZE__BUFFER_VSIZE__BMSK      0x00001FFF
-#define HWIO_RTDMA_JPEG_RD_BUFFER_SIZE__BUFFER_VSIZE__SHFT                0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define RTDMA_JPEG_RD_STA_ACK                     RTDMA_JPEG_RD_STA_ACK
-#define HWIO_RTDMA_JPEG_RD_STA_ACK_ADDR         (JPEGD_BASE+0x00000128)
-#define HWIO_RTDMA_JPEG_RD_STA_ACK__POR                     0x00000000
-#define HWIO_RTDMA_JPEG_RD_STA_ACK__RMSK                    0x00000003
-#define HWIO_RTDMA_JPEG_RD_STA_ACK__SHFT                             0
-
-/* Register Field FMSK and SHFT*/
-#define HWIO_RTDMA_JPEG_RD_STA_ACK__EOF_STA__BMSK           0x00000002
-#define HWIO_RTDMA_JPEG_RD_STA_ACK__EOF_STA__SHFT                    1
-#define HWIO_RTDMA_JPEG_RD_STA_ACK__SOF_STA__BMSK           0x00000001
-#define HWIO_RTDMA_JPEG_RD_STA_ACK__SOF_STA__SHFT                    0
-#define HWIO_RTDMA_JPEG_RD_STA_ACK__EOF_ACK__BMSK           0x00000002
-#define HWIO_RTDMA_JPEG_RD_STA_ACK__EOF_ACK__SHFT                    1
-#define HWIO_RTDMA_JPEG_RD_STA_ACK__SOF_ACK__BMSK           0x00000001
-#define HWIO_RTDMA_JPEG_RD_STA_ACK__SOF_ACK__SHFT                    0
-
-/* Register ADDR, RMSK, and SHFT*/
-#define RTDMA_JPEG_RD_INT_EN                      RTDMA_JPEG_RD_INT_EN
-#define HWIO_RTDMA_JPEG_RD_INT_EN_ADDR  /* W */        (JPEGD_BASE+0x0000012C)
-#define HWIO_RTDMA_JPEG_RD_INT_EN__POR                      0x00000000
-#define HWIO_RTDMA_JPEG_RD_INT_EN__RMSK                     0x00000003
-#define HWIO_RTDMA_JPEG_RD_INT_EN__SHFT                              0
-
-/* Register Field FMSK and SHFT*/
-#define HWIO_RTDMA_JPEG_RD_INT_EN__EOF_EN__BMSK             0x00000002
-#define HWIO_RTDMA_JPEG_RD_INT_EN__EOF_EN__SHFT                      1
-#define HWIO_RTDMA_JPEG_RD_INT_EN__SOF_EN__BMSK             0x00000001
-#define HWIO_RTDMA_JPEG_RD_INT_EN__SOF_EN__SHFT                      0
-
-#endif /* MSM_MERCURY_HW_REG_H */
diff --git a/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_macros.h b/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_macros.h
deleted file mode 100644
index 0ab07cd..0000000
--- a/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_macros.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#ifndef MSM_MERCURY_MACROS_H
-#define MSM_MERCURY_MACROS_H
-
-#include <media/msm_mercury.h>
-
-#define mercury_kread(reg) \
-	hw_cmd.type = MSM_MERCURY_HW_CMD_TYPE_READ; \
-	hw_cmd.n = 1; \
-	hw_cmd.offset = HWIO_##reg##_ADDR; \
-	hw_cmd.mask = HWIO_##reg##__RMSK; \
-	hw_cmd.data = 0x0; \
-	msm_mercury_hw_exec_cmds(&hw_cmd, 1);
-
-#define mercury_kwrite(reg, val) \
-	hw_cmd.offset = HWIO_##reg##_ADDR; \
-	hw_cmd.mask = HWIO_##reg##__RMSK; \
-	hw_cmd.type = MSM_MERCURY_HW_CMD_TYPE_WRITE; \
-	hw_cmd.n = 1; \
-	hw_cmd.data = val; \
-	msm_mercury_hw_exec_cmds(&hw_cmd, 1);
-
-#define GET_FVAL(val, reg, field) ((val & HWIO_FMSK(reg, field)) >> \
-	HWIO_SHFT(reg, field))
-
-#define byte unsigned char
-#define word unsigned short
-#define dword unsigned long
-
-#define inp(port)    (*((dword *) (port)))
-#define inpb(port)     (*((byte *) (port)))
-#define inpw(port)   (*((word *) (port)))
-#define inpdw(port)   (*((dword *)(port)))
-
-#define outp(port, val)   (*((dword *) (port)) = ((dword) (val)))
-#define outpb(port, val)   (*((byte *) (port)) = ((byte) (val)))
-#define outpw(port, val)  (*((word *) (port)) = ((word) (val)))
-#define outpdw(port, val) (*((dword *) (port)) = ((dword) (val)))
-
-
-#define in_byte(addr)				(inp(addr))
-#define in_byte_masked(addr, mask)	(inp(addr) & (byte)mask)
-#define out_byte(addr, val)			 outp(addr, val)
-#define in_word(addr)				(inpw(addr))
-#define in_word_masked(addr, mask)	(inpw(addr) & (word)mask)
-#define out_word(addr, val)			 outpw(addr, val)
-#define in_dword(addr)				(inpdw(addr))
-#define in_dword_masked(addr, mask)	(inpdw(addr) & mask)
-#define out_dword(addr, val)			 outpdw(addr, val)
-
-/* shadowed, masked output for write-only registers */
-#define out_byte_masked(io, mask, val, shadow)  \
-	do { \
-		shadow = (shadow & (word)(~(mask))) | \
-		((word)((val) & (mask))); \
-		(void) out_byte(io, shadow);\
-	} while (0);
-
-#define out_word_masked(io, mask, val, shadow)  \
-	do { \
-		shadow = (shadow & (word)(~(mask))) | \
-		((word)((val) & (mask))); \
-		(void) out_word(io, shadow); \
-	} while (0);
-
-#define out_dword_masked(io, mask, val, shadow)  \
-	do { \
-		shadow = (shadow & (dword)(~(mask))) | \
-		((dword)((val) & (mask))); \
-		(void) out_dword(io, shadow);\
-	} while (0);
-
-#define out_byte_masked_ns(io, mask, val, current_reg_content)  \
-	(void) out_byte(io, ((current_reg_content & \
-	(word)(~(mask))) | ((word)((val) & (mask)))))
-
-#define out_word_masked_ns(io, mask, val, current_reg_content)  \
-	(void) out_word(io, ((current_reg_content & \
-	(word)(~(mask))) | ((word)((val) & (mask)))))
-
-#define out_dword_masked_ns(io, mask, val, current_reg_content) \
-	(void) out_dword(io, ((current_reg_content & \
-	(dword)(~(mask))) | ((dword)((val) & (mask)))))
-
-#define MEM_INF(val, reg, field)	((val & HWIO_FMSK(reg, field)) >> \
-	HWIO_SHFT(reg, field))
-
-#define MEM_OUTF(mem, reg, field, val)\
-	out_dword_masked_ns(mem, HWIO_FMSK(reg, field), \
-	(unsigned  int)val<<HWIO_SHFT(reg, field), in_dword(mem))
-
-#define MEM_OUTF2(mem, reg, field2, field1, val2, val1)  \
-	out_dword_masked_ns(mem, (HWIO_FMSK(reg, field2)| \
-	HWIO_FMSK(reg, field1)), \
-	(((unsigned int)val2<<HWIO_SHFT(reg, field2))| \
-	((unsigned int)val1<<HWIO_SHFT(reg, field1))), in_dword(mem))
-
-#define MEM_OUTF3(mem, reg, fld3, fld2, fld1, val3, val2, val1)  \
-	out_dword_masked_ns(mem, (HWIO_FMSK(reg, fld3)| \
-	HWIO_FMSK(reg, fld2)|HWIO_FMSK(reg, fld1)), \
-	(((unsigned int)val3<<HWIO_SHFT(reg, fld3))| \
-	((unsigned int)val2<<HWIO_SHFT(reg, fld2))| \
-	((unsigned int)val1<<HWIO_SHFT(reg, fld1))), in_dword(mem))
-
-#define HWIO_FMSK(reg, field)   HWIO_##reg##__##field##__BMSK
-#define HWIO_SHFT(reg, field)   HWIO_##reg##__##field##__SHFT
-#endif
diff --git a/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_platform.c b/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_platform.c
deleted file mode 100644
index cda36d9..0000000
--- a/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_platform.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#include <linux/module.h>
-#include <linux/clk.h>
-#include <linux/io.h>
-
-#include <mach/clk.h>
-#include <mach/camera.h>
-
-#include "msm_mercury_platform.h"
-#include "msm_mercury_sync.h"
-#include "msm_mercury_common.h"
-#include "msm_mercury_hw.h"
-
-
-struct ion_client *mercury_client;
-
-static struct msm_cam_clk_info mercury_jpegd_clk_info[] = {
-	{"core_clk", 200000000},
-	{"iface_clk", -1}
-};
-
-void msm_mercury_platform_p2v(struct file  *file,
-	struct ion_handle **ionhandle)
-{
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-	ion_unmap_iommu(mercury_client, *ionhandle, CAMERA_DOMAIN,
-		GEN_POOL);
-	ion_free(mercury_client, *ionhandle);
-	*ionhandle = NULL;
-#endif
-}
-
-uint32_t msm_mercury_platform_v2p(int fd, uint32_t len,
-	struct file **file_p,
-	struct ion_handle **ionhandle)
-{
-	unsigned long paddr;
-	unsigned long size;
-	int rc;
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-	*ionhandle = ion_import_dma_buf(mercury_client, fd);
-	if (IS_ERR_OR_NULL(*ionhandle))
-		return 0;
-
-	rc = ion_map_iommu(mercury_client, *ionhandle, CAMERA_DOMAIN,
-		GEN_POOL, SZ_4K, 0, &paddr,
-		(unsigned long *)&size, 0, 0);
-	rc = 0;
-	paddr = 0;
-	size = 0;
-#endif
-	if (rc < 0) {
-		MCR_PR_ERR("%s: get_pmem_file fd %d error %d\n", __func__, fd,
-			rc);
-		goto error1;
-	}
-
-	/* validate user input */
-	if (len > size) {
-		MCR_PR_ERR("%s: invalid offset + len\n", __func__);
-		goto error1;
-	}
-
-	return paddr;
-error1:
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-	ion_free(mercury_client, *ionhandle);
-#endif
-	return 0;
-}
-
-int msm_mercury_platform_init(struct platform_device *pdev,
-	struct resource **mem,
-	void **base,
-	int *irq,
-	irqreturn_t (*handler) (int, void *),
-	void *context)
-{
-	int rc = 0;
-	int mercury_irq;
-	struct resource *mercury_mem, *mercury_io, *mercury_irq_res;
-	void *mercury_base;
-	struct msm_mercury_device *pmercury_dev =
-		(struct msm_mercury_device *) context;
-
-	MCR_DBG("%s:%d]\n", __func__, __LINE__);
-
-	mercury_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!mercury_mem) {
-		MCR_PR_ERR("%s: no mem resource?\n", __func__);
-		return -ENODEV;
-	}
-
-	mercury_irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	if (!mercury_irq_res) {
-		MCR_PR_ERR("no irq resource?\n");
-		return -ENODEV;
-	}
-	mercury_irq = mercury_irq_res->start;
-
-	mercury_io = request_mem_region(mercury_mem->start,
-		resource_size(mercury_mem), pdev->name);
-	if (!mercury_io) {
-		MCR_PR_ERR("%s: region already claimed\n", __func__);
-		return -EBUSY;
-	}
-	MCR_DBG("%s:%d]\n", __func__, __LINE__);
-	mercury_base = ioremap(mercury_mem->start,
-		resource_size(mercury_mem));
-	if (!mercury_base) {
-		rc = -ENOMEM;
-		MCR_PR_ERR("%s: ioremap failed\n", __func__);
-		goto fail1;
-	}
-	MCR_DBG("%s:%d]\n", __func__, __LINE__);
-
-	rc = msm_cam_clk_enable(&pmercury_dev->pdev->dev,
-		mercury_jpegd_clk_info, pmercury_dev->mercury_clk,
-		ARRAY_SIZE(mercury_jpegd_clk_info), 1);
-	if (rc < 0)
-		MCR_PR_ERR("%s:%d] rc = %d\n", __func__, __LINE__, rc);
-
-	MCR_DBG("%s:%d]\n", __func__, __LINE__);
-	msm_mercury_hw_init(mercury_base, resource_size(mercury_mem));
-	rc = request_irq(mercury_irq, handler, IRQF_TRIGGER_RISING,
-		"mercury", context);
-	if (rc) {
-		MCR_PR_ERR("%s: request_irq failed, %d\n", __func__,
-			mercury_irq);
-		goto fail3;
-	}
-	MCR_DBG("%s:%d]\n", __func__, __LINE__);
-	*mem  = mercury_mem;
-	*base = mercury_base;
-	*irq  = mercury_irq;
-	MCR_DBG("%s:%d]\n", __func__, __LINE__);
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-	mercury_client = msm_ion_client_create(-1, "camera/mercury");
-#endif
-	MCR_PR_ERR("%s:%d] success\n", __func__, __LINE__);
-	return rc;
-fail3:
-	MCR_DBG("%s:%d]\n", __func__, __LINE__);
-	msm_cam_clk_enable(&pmercury_dev->pdev->dev, mercury_jpegd_clk_info,
-		pmercury_dev->mercury_clk,
-		ARRAY_SIZE(mercury_jpegd_clk_info), 0);
-	MCR_DBG("%s:%d]\n", __func__, __LINE__);
-	iounmap(mercury_base);
-fail1:
-	MCR_DBG("%s:%d]\n", __func__, __LINE__);
-	release_mem_region(mercury_mem->start, resource_size(mercury_mem));
-	MCR_DBG("%s:%d]\n", __func__, __LINE__);
-	return rc;
-}
-
-int msm_mercury_platform_release(struct resource *mem, void *base,
-	int irq, void *context)
-{
-	int result = 0;
-	struct msm_mercury_device *pmercury_dev =
-		(struct msm_mercury_device *) context;
-
-	free_irq(irq, context);
-	msm_cam_clk_enable(&pmercury_dev->pdev->dev, mercury_jpegd_clk_info,
-		pmercury_dev->mercury_clk, ARRAY_SIZE(mercury_jpegd_clk_info),
-		0);
-	iounmap(base);
-	release_mem_region(mem->start, resource_size(mem));
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-	ion_client_destroy(mercury_client);
-#endif
-	MCR_DBG("%s:%d] success\n", __func__, __LINE__);
-	return result;
-}
-
diff --git a/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_platform.h b/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_platform.h
deleted file mode 100644
index dfdea3c..0000000
--- a/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_platform.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#ifndef MSM_MERCURY_PLATFORM_H
-#define MSM_MERCURY_PLATFORM_H
-
-#include <linux/interrupt.h>
-#include <linux/platform_device.h>
-#include <linux/msm_ion.h>
-
-int msm_mercury_platform_clk_enable(void);
-int msm_mercury_platform_clk_disable(void);
-
-void msm_mercury_platform_p2v(struct file  *file,
-	struct ion_handle **ionhandle);
-
-uint32_t msm_mercury_platform_v2p(int fd, uint32_t len, struct file **file,
-	struct ion_handle **ionhandle);
-
-int msm_mercury_platform_init(struct platform_device *pdev,
-	struct resource **mem,
-	void **base,
-	int *irq,
-	irqreturn_t (*handler) (int, void *),
-	void *context);
-
-int msm_mercury_platform_release(struct resource *mem, void *base, int irq,
-	void *context);
-
-#endif /* MSM_MERCURY_PLATFORM_H */
diff --git a/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_sync.c b/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_sync.c
deleted file mode 100644
index e6483c1..0000000
--- a/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_sync.c
+++ /dev/null
@@ -1,615 +0,0 @@
-/* Copyright (c) 2012-2013, The Linux Foundation. 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.
- */
-
-#include <linux/module.h>
-#include <linux/sched.h>
-#include <linux/list.h>
-#include <linux/uaccess.h>
-#include <linux/slab.h>
-#include <media/msm_mercury.h>
-
-#include "msm_mercury_sync.h"
-#include "msm_mercury_core.h"
-#include "msm_mercury_platform.h"
-#include "msm_mercury_common.h"
-#include "msm_mercury_macros.h"
-#include "msm_mercury_hw_reg.h"
-
-static struct msm_mercury_core_buf out_buf_local;
-static struct msm_mercury_core_buf in_buf_local;
-
-/*************** queue helper ****************/
-inline void msm_mercury_q_init(char const *name, struct msm_mercury_q *q_p)
-{
-	MCR_DBG("%s:%d] %s\n", __func__, __LINE__, name);
-	q_p->name = name;
-	spin_lock_init(&q_p->lck);
-	INIT_LIST_HEAD(&q_p->q);
-	init_waitqueue_head(&q_p->wait);
-	q_p->unblck = 0;
-}
-
-inline void *msm_mercury_q_out(struct msm_mercury_q *q_p)
-{
-	unsigned long flags;
-	struct msm_mercury_q_entry *q_entry_p = NULL;
-	void *data = NULL;
-
-	MCR_DBG("(%d)%s()  %s\n", __LINE__, __func__, q_p->name);
-	spin_lock_irqsave(&q_p->lck, flags);
-	if (!list_empty(&q_p->q)) {
-		q_entry_p = list_first_entry(&q_p->q,
-			struct msm_mercury_q_entry,
-			list);
-		list_del_init(&q_entry_p->list);
-	}
-	spin_unlock_irqrestore(&q_p->lck, flags);
-
-	if (q_entry_p) {
-		data = q_entry_p->data;
-		kfree(q_entry_p);
-	} else {
-		MCR_DBG("%s:%d] %s no entry\n", __func__, __LINE__, q_p->name);
-	}
-
-	return data;
-}
-
-inline int msm_mercury_q_in(struct msm_mercury_q *q_p, void *data)
-{
-	unsigned long flags;
-
-	struct msm_mercury_q_entry *q_entry_p;
-
-	MCR_DBG("%s:%d] %s\n", __func__, __LINE__, q_p->name);
-
-	q_entry_p = kmalloc(sizeof(struct msm_mercury_q_entry), GFP_ATOMIC);
-	if (!q_entry_p) {
-		MCR_PR_ERR("%s: no mem\n", __func__);
-		return -EFAULT;
-	}
-	q_entry_p->data = data;
-
-	spin_lock_irqsave(&q_p->lck, flags);
-	list_add_tail(&q_entry_p->list, &q_p->q);
-	spin_unlock_irqrestore(&q_p->lck, flags);
-
-	return 0;
-}
-
-inline int msm_mercury_q_in_buf(struct msm_mercury_q *q_p,
-	struct msm_mercury_core_buf *buf)
-{
-	struct msm_mercury_core_buf *buf_p;
-
-	MCR_DBG("%s:%d]\n", __func__, __LINE__);
-	buf_p = kmalloc(sizeof(struct msm_mercury_core_buf), GFP_ATOMIC);
-	if (!buf_p) {
-		MCR_PR_ERR("%s: no mem\n", __func__);
-		return -EFAULT;
-	}
-
-	memcpy(buf_p, buf, sizeof(struct msm_mercury_core_buf));
-
-	msm_mercury_q_in(q_p, buf_p);
-	return 0;
-}
-
-inline int msm_mercury_q_wait(struct msm_mercury_q *q_p)
-{
-	int tm = MAX_SCHEDULE_TIMEOUT; /* 500ms */
-	int rc;
-
-	MCR_DBG("%s:%d %s wait\n", __func__, __LINE__, q_p->name);
-	rc = wait_event_interruptible_timeout(q_p->wait,
-		(!list_empty_careful(&q_p->q) || q_p->unblck),
-		msecs_to_jiffies(tm));
-
-	MCR_DBG("%s:%d %s wait done (rc=%d)\n", __func__,
-		__LINE__, q_p->name, rc);
-	if (list_empty_careful(&q_p->q)) {
-		if (rc == 0) {
-			rc = -ETIMEDOUT;
-			MCR_PR_ERR("%s:%d] %s timeout\n", __func__,
-				__LINE__, q_p->name);
-		} else if (q_p->unblck) {
-			MCR_DBG("%s:%d %s unblock is true", __func__,
-				__LINE__, q_p->name);
-			rc = q_p->unblck;
-			q_p->unblck = 0;
-		} else if (rc < 0) {
-			MCR_PR_ERR("%s:%d %s rc %d\n", __func__, __LINE__,
-				q_p->name, rc);
-		}
-	}
-	return rc;
-}
-
-inline int msm_mercury_q_wakeup(struct msm_mercury_q *q_p)
-{
-	MCR_DBG("%s:%d] %s\n", __func__, __LINE__, q_p->name);
-	wake_up(&q_p->wait);
-	return 0;
-}
-
-inline int msm_mercury_q_wr_eoi(struct msm_mercury_q *q_p)
-{
-	MCR_DBG("%s:%d] Wake up %s\n", __func__, __LINE__, q_p->name);
-	q_p->unblck = MSM_MERCURY_EVT_FRAMEDONE;
-	wake_up(&q_p->wait);
-	return 0;
-}
-
-inline int msm_mercury_q_wr_err(struct msm_mercury_q *q_p)
-{
-	MCR_DBG("%s:%d] Wake up %s\n", __func__, __LINE__, q_p->name);
-	q_p->unblck = MSM_MERCURY_EVT_ERR;
-	wake_up(&q_p->wait);
-	return 0;
-}
-
-inline int msm_mercury_q_unblock(struct msm_mercury_q *q_p)
-{
-	MCR_DBG("%s:%d] Wake up %s\n", __func__, __LINE__, q_p->name);
-	q_p->unblck = MSM_MERCURY_EVT_UNBLOCK;
-	wake_up(&q_p->wait);
-	return 0;
-}
-
-inline void msm_mercury_q_cleanup(struct msm_mercury_q *q_p)
-{
-	void *data;
-	MCR_DBG("\n%s:%d] %s\n", __func__, __LINE__, q_p->name);
-	do {
-		data = msm_mercury_q_out(q_p);
-		if (data) {
-			MCR_DBG("%s:%d] %s\n", __func__, __LINE__, q_p->name);
-			kfree(data);
-		}
-	} while (data);
-	q_p->unblck = 0;
-}
-
-/*************** event queue ****************/
-int msm_mercury_framedone_irq(struct msm_mercury_device *pmercury_dev)
-{
-	MCR_DBG("%s:%d] Enter\n", __func__, __LINE__);
-	msm_mercury_q_unblock(&pmercury_dev->evt_q);
-
-	MCR_DBG("%s:%d] Exit\n", __func__, __LINE__);
-	return 0;
-}
-
-int msm_mercury_evt_get(struct msm_mercury_device *pmercury_dev,
-	void __user *arg)
-{
-	struct msm_mercury_ctrl_cmd ctrl_cmd;
-	int rc = 0;
-
-	MCR_DBG("(%d)%s() Enter\n", __LINE__, __func__);
-	memset(&ctrl_cmd, 0, sizeof(ctrl_cmd));
-	ctrl_cmd.type = (uint32_t)msm_mercury_q_wait(&pmercury_dev->evt_q);
-
-	rc = copy_to_user(arg, &ctrl_cmd, sizeof(ctrl_cmd));
-
-	if (rc) {
-		MCR_PR_ERR("%s:%d] failed\n", __func__, __LINE__);
-		return -EFAULT;
-	}
-
-	return 0;
-}
-
-int msm_mercury_evt_get_unblock(struct msm_mercury_device *pmercury_dev)
-{
-	MCR_DBG("--(%d)%s() Enter\n", __LINE__, __func__);
-	msm_mercury_q_unblock(&pmercury_dev->evt_q);
-	return 0;
-}
-
-int msm_mercury_output_buf_cfg(struct msm_mercury_device *pmercury_dev,
-	void __user *arg)
-{
-	struct msm_mercury_buf buf_cmd;
-
-
-	MCR_DBG("%s:%d] Enter\n", __func__, __LINE__);
-	if (copy_from_user(&buf_cmd, arg, sizeof(struct msm_mercury_buf))) {
-		MCR_PR_ERR("%s:%d] failed\n", __func__, __LINE__);
-		return -EFAULT;
-	}
-
-	out_buf_local.y_buffer_addr = msm_mercury_platform_v2p(buf_cmd.fd,
-		buf_cmd.y_len, &out_buf_local.file, &out_buf_local.handle);
-	out_buf_local.cbcr_buffer_addr = out_buf_local.y_buffer_addr +
-		buf_cmd.y_len;
-
-	if (!out_buf_local.y_buffer_addr) {
-		MCR_PR_ERR("%s:%d] v2p wrong\n", __func__, __LINE__);
-		return -EFAULT;
-	}
-
-	msm_mercury_hw_output_y_buf_cfg(out_buf_local.y_buffer_addr);
-	msm_mercury_hw_output_u_buf_cfg(out_buf_local.cbcr_buffer_addr);
-
-	MCR_DBG("(%d)%s()\n  y_buf=0x%08X, y_len=0x%08X, vaddr=0x%08X\n"
-		"  u_buf=0x%08X, u_len=0x%08X\n\n", __LINE__, __func__,
-		out_buf_local.y_buffer_addr, buf_cmd.y_len, (int) buf_cmd.vaddr,
-		out_buf_local.cbcr_buffer_addr, buf_cmd.cbcr_len);
-
-	return 0;
-}
-
-int msm_mercury_input_buf_cfg(struct msm_mercury_device *pmercury_dev,
-	void __user *arg)
-{
-	struct msm_mercury_buf buf_cmd;
-
-
-	MCR_DBG("%s:%d] Enter\n", __func__, __LINE__);
-	if (copy_from_user(&buf_cmd, arg, sizeof(struct msm_mercury_buf))) {
-		MCR_PR_ERR("%s:%d] failed\n", __func__, __LINE__);
-		return -EFAULT;
-	}
-
-	in_buf_local.y_buffer_addr = msm_mercury_platform_v2p(buf_cmd.fd,
-		buf_cmd.y_len, &in_buf_local.file, &in_buf_local.handle);
-
-	if (!in_buf_local.y_buffer_addr) {
-		MCR_PR_ERR("%s:%d] v2p wrong\n", __func__, __LINE__);
-		return -EFAULT;
-	}
-
-	msm_mercury_hw_bitstream_buf_cfg(in_buf_local.y_buffer_addr);
-
-	MCR_DBG("(%d)%s()\n  bitstream_buf=0x%08X, len=0x%08X, vaddr=0x%08X\n",
-		__LINE__, __func__, in_buf_local.y_buffer_addr, buf_cmd.y_len,
-		(int) buf_cmd.vaddr);
-
-	return 0;
-}
-
-int msm_mercury_output_get(struct msm_mercury_device *pmercury_dev,
-	void __user *to)
-{
-	MCR_DBG("%s:%d] Enter\n", __func__, __LINE__);
-	msm_mercury_platform_p2v(out_buf_local.file, &out_buf_local.handle);
-	return 0;
-}
-
-int msm_mercury_input_get(struct msm_mercury_device *pmercury_dev,
-	void __user *to)
-{
-
-
-	MCR_DBG("%s:%d] Enter\n", __func__, __LINE__);
-	msm_mercury_platform_p2v(in_buf_local.file, &in_buf_local.handle);
-	return 0;
-}
-
-int msm_mercury_ioctl_dump_regs(void)
-{
-	uint32_t mercury_regs[] = {
-		0x0000, 0x0008, 0x0010, 0x0014, 0x0018, 0x001C, 0x0020, 0x0024,
-		0x0030, 0x0034, 0x0040, 0x0050, 0x0054, 0x0058, 0x005C, 0x0060,
-		0x0064, 0x0070, 0x0080, 0x0084, 0x0088, 0x0258, 0x025C, 0x0260,
-		0x0264, 0x0200, 0x0204, 0x0208, 0x020C, 0x0210, 0x0214, 0x0218,
-		0x021C, 0x0220, 0x0224, 0x0228, 0x0100, 0x0104, 0x010C, 0x0110,
-		0x0114, 0x0118, 0x011C, 0x0120, 0x0124, 0x0128, 0x012C};
-
-	struct msm_mercury_hw_cmd hw_cmd;
-	int len = sizeof(mercury_regs)/4;
-	int i;
-
-	MCR_DBG("\n%s\n  (%d)%s()\n", __FILE__, __LINE__, __func__);
-
-	hw_cmd.mask = 0xFFFFFFFF;
-	hw_cmd.type = MSM_MERCURY_HW_CMD_TYPE_READ;
-	hw_cmd.n = 1;
-
-	for (i = 0; i < len; i++) {
-		hw_cmd.offset = mercury_regs[i];
-		msm_mercury_hw_exec_cmds(&hw_cmd, 1);
-	}
-
-	return 0;
-}
-
-int msm_mercury_ioctl_magic_code(struct msm_mercury_device *pmercury_dev,
-	void * __user arg)
-{
-	struct msm_mercury_hw_cmd hw_cmd;
-	int rc = 0;
-
-	rc = copy_from_user(&hw_cmd, arg, sizeof(struct msm_mercury_hw_cmd));
-	if (rc) {
-		printk(KERN_ERR "%s:%d] failed\n", __func__, __LINE__);
-		return -EFAULT;
-	}
-
-	hw_cmd.data = 0x600D600D;
-	rc = copy_to_user(arg, &hw_cmd, sizeof(hw_cmd));
-
-	if (rc) {
-		printk(KERN_ERR "%s:%d] failed\n", __func__, __LINE__);
-		return -EFAULT;
-	}
-
-	return 0;
-}
-
-int msm_mercury_irq(int event, void *context, void *data)
-{
-	struct msm_mercury_device *pmercury_dev =
-		(struct msm_mercury_device *) context;
-
-	switch (event) {
-	case MSM_MERCURY_HW_IRQ_SW_RESET_ACK:
-		/* wake up evt_q*/
-		MCR_DBG("(%d)%s Wake up event q from Reset IRQ\n", __LINE__,
-			__func__);
-		msm_mercury_q_wakeup(&pmercury_dev->evt_q);
-		break;
-	case MSM_MERCURY_HW_IRQ_WR_EOI_ACK:
-		/*wake up evt_q*/
-		MCR_DBG("%d%s Wake up eventq from WR_EOI IRQ\n", __LINE__,
-			__func__);
-		msm_mercury_q_wr_eoi(&pmercury_dev->evt_q);
-		break;
-	case MSM_MERCURY_HW_IRQ_WR_ERR_ACK:
-		MCR_DBG("(%d)%s Wake up eventq from WR_ERR IRQ\n",
-			__LINE__, __func__);
-		msm_mercury_q_wr_err(&pmercury_dev->evt_q);
-		break;
-	default:
-		MCR_DBG("(%d)%s (default) Wake up event q from WR_ERR IRQ\n",
-			__LINE__, __func__);
-		msm_mercury_q_wr_err(&pmercury_dev->evt_q);
-	}
-	return 0;
-}
-
-int __msm_mercury_open(struct msm_mercury_device *pmercury_dev)
-{
-	int rc = 0;
-
-	mutex_lock(&pmercury_dev->lock);
-	if (pmercury_dev->open_count) {
-		/* only open once */
-		MCR_PR_ERR("%s:%d] busy\n", __func__, __LINE__);
-		mutex_unlock(&pmercury_dev->lock);
-		return -EBUSY;
-	}
-	pmercury_dev->open_count++;
-	mutex_unlock(&pmercury_dev->lock);
-
-	msm_mercury_core_irq_install(msm_mercury_irq);
-
-	rc = msm_mercury_platform_init(pmercury_dev->pdev,
-		&pmercury_dev->mem, &pmercury_dev->base,
-		&pmercury_dev->irq, msm_mercury_core_irq, pmercury_dev);
-	if (rc) {
-		MCR_PR_ERR("%s:%d] platform_init fail %d\n", __func__,
-			__LINE__, rc);
-		return rc;
-	}
-
-	MCR_DBG("\n%s:%d] platform resources - mem 0x%p, base 0x%p, irq %d\n",
-		__func__, __LINE__, pmercury_dev->mem, pmercury_dev->base,
-		pmercury_dev->irq);
-
-	msm_mercury_q_cleanup(&pmercury_dev->evt_q);
-	msm_mercury_core_init();
-
-	MCR_DBG("\n%s:%d] success\n", __func__, __LINE__);
-	return rc;
-}
-
-int __msm_mercury_release(struct msm_mercury_device *pmercury_dev)
-{
-	MCR_DBG("%s:%d] Enter\n", __func__, __LINE__);
-	mutex_lock(&pmercury_dev->lock);
-	if (!pmercury_dev->open_count) {
-		MCR_PR_ERR(KERN_ERR "%s: not opened\n", __func__);
-		mutex_unlock(&pmercury_dev->lock);
-		return -EINVAL;
-	}
-	pmercury_dev->open_count--;
-	mutex_unlock(&pmercury_dev->lock);
-
-	msm_mercury_q_cleanup(&pmercury_dev->evt_q);
-
-	if (pmercury_dev->open_count)
-		MCR_PR_ERR(KERN_ERR "%s: multiple opens\n", __func__);
-
-	if (pmercury_dev->open_count)
-		MCR_PR_ERR(KERN_ERR "%s: multiple opens\n", __func__);
-
-
-	msm_mercury_platform_release(pmercury_dev->mem, pmercury_dev->base,
-		pmercury_dev->irq, pmercury_dev);
-
-	return 0;
-}
-
-int msm_mercury_ioctl_hw_cmd(struct msm_mercury_device *pmercury_dev,
-	void * __user arg)
-{
-	struct msm_mercury_hw_cmd hw_cmd;
-	int is_copy_to_user;
-	int rc = 0;
-
-	rc = copy_from_user(&hw_cmd, arg, sizeof(struct msm_mercury_hw_cmd));
-	if (rc) {
-		MCR_PR_ERR("%s:%d] failed\n", __func__, __LINE__);
-		return -EFAULT;
-	}
-
-	is_copy_to_user = msm_mercury_hw_exec_cmds(&hw_cmd, 1);
-	if (is_copy_to_user >= 0) {
-		rc = copy_to_user(arg, &hw_cmd, sizeof(hw_cmd));
-
-		if (rc) {
-			MCR_PR_ERR("%s:%d] failed\n", __func__, __LINE__);
-			return -EFAULT;
-		}
-	}
-
-	return 0;
-}
-
-int msm_mercury_ioctl_hw_cmds(struct msm_mercury_device *pmercury_dev,
-	void * __user arg)
-{
-	int is_copy_to_user;
-	int len;
-	uint32_t m;
-	struct msm_mercury_hw_cmds *hw_cmds_p;
-	struct msm_mercury_hw_cmd *hw_cmd_p;
-
-	if (copy_from_user(&m, arg, sizeof(m))) {
-		MCR_PR_ERR("%s:%d] failed\n", __func__, __LINE__);
-		return -EFAULT;
-	}
-
-	len = sizeof(struct msm_mercury_hw_cmds) +
-		sizeof(struct msm_mercury_hw_cmd) * (m - 1);
-	hw_cmds_p = kmalloc(len, GFP_KERNEL);
-	if (!hw_cmds_p) {
-		MCR_PR_ERR("[%d]%s() no mem %d\n", __LINE__, __func__, len);
-		return -EFAULT;
-	}
-
-	if (copy_from_user(hw_cmds_p, arg, len)) {
-		MCR_PR_ERR("[%d]%s Fail to copy hw_cmds of len %d from user\n",
-			__LINE__, __func__, len);
-		kfree(hw_cmds_p);
-		return -EFAULT;
-	}
-
-	hw_cmd_p = (struct msm_mercury_hw_cmd *) &(hw_cmds_p->hw_cmd);
-
-	is_copy_to_user = msm_mercury_hw_exec_cmds(hw_cmd_p, m);
-
-	if (is_copy_to_user >= 0) {
-		if (copy_to_user(arg, hw_cmds_p, len)) {
-			MCR_PR_ERR("%s:%d] failed\n", __func__, __LINE__);
-			kfree(hw_cmds_p);
-			return -EFAULT;
-		}
-	}
-	kfree(hw_cmds_p);
-	return 0;
-}
-
-int msm_mercury_ioctl_reset(struct msm_mercury_device *pmercury_dev,
-	void * __user arg)
-{
-	int rc = 0;
-
-	MCR_DBG("(%d)%s() Enter\n", __LINE__, __func__);
-	rc = msm_mercury_core_reset();
-
-	return rc;
-}
-
-long __msm_mercury_ioctl(struct msm_mercury_device *pmercury_dev,
-	unsigned int cmd, unsigned long arg)
-{
-	int rc = 0;
-
-	switch (cmd) {
-	case MSM_MCR_IOCTL_GET_HW_VERSION:
-		rc = msm_mercury_ioctl_magic_code(pmercury_dev,
-			(void __user *) arg);
-		break;
-
-	case MSM_MCR_IOCTL_RESET:
-		rc = msm_mercury_ioctl_reset(pmercury_dev, (void __user *) arg);
-		break;
-
-	case MSM_MCR_IOCTL_EVT_GET:
-		rc = msm_mercury_evt_get(pmercury_dev, (void __user *) arg);
-		break;
-
-	case MSM_MCR_IOCTL_EVT_GET_UNBLOCK:
-		rc = msm_mercury_evt_get_unblock(pmercury_dev);
-		break;
-
-	case MSM_MCR_IOCTL_HW_CMD:
-		rc = msm_mercury_ioctl_hw_cmd(pmercury_dev,
-			(void __user *) arg);
-		break;
-
-	case MSM_MCR_IOCTL_HW_CMDS:
-		rc = msm_mercury_ioctl_hw_cmds(pmercury_dev,
-			(void __user *) arg);
-		break;
-
-	case MSM_MCR_IOCTL_INPUT_BUF_CFG:
-		rc = msm_mercury_input_buf_cfg(pmercury_dev,
-			(void __user *) arg);
-		break;
-
-	case MSM_MCR_IOCTL_OUTPUT_BUF_CFG:
-		rc = msm_mercury_output_buf_cfg(pmercury_dev,
-			(void __user *) arg);
-		break;
-
-	case MSM_MCR_IOCTL_OUTPUT_GET:
-		rc = msm_mercury_output_get(pmercury_dev,
-			(void __user *) arg);
-		break;
-
-	case MSM_MCR_IOCTL_INPUT_GET:
-		rc = msm_mercury_input_get(pmercury_dev,
-			(void __user *) arg);
-		break;
-
-	case MSM_MCR_IOCTL_TEST_DUMP_REGION:
-		rc = msm_mercury_ioctl_dump_regs();
-		break;
-
-	default:
-		printk(KERN_ERR "(%d)%s()  cmd = %d not supported\n",
-			__LINE__, __func__, _IOC_NR(cmd));
-		rc = -EINVAL;
-		break;
-	}
-	return rc;
-}
-
-struct msm_mercury_device *__msm_mercury_init(struct platform_device *pdev)
-{
-	struct msm_mercury_device *pmercury_dev;
-	pmercury_dev = kzalloc(sizeof(struct msm_mercury_device), GFP_ATOMIC);
-	if (!pmercury_dev) {
-		printk(KERN_ERR "%s:%d]no mem\n", __func__, __LINE__);
-		return NULL;
-	}
-
-	mutex_init(&pmercury_dev->lock);
-
-	pmercury_dev->pdev = pdev;
-
-	msm_mercury_q_init("evt_q", &pmercury_dev->evt_q);
-
-	return pmercury_dev;
-}
-
-int __msm_mercury_exit(struct msm_mercury_device *pmercury_dev)
-{
-	mutex_destroy(&pmercury_dev->lock);
-	kfree(pmercury_dev);
-	return 0;
-}
-
diff --git a/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_sync.h b/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_sync.h
deleted file mode 100644
index a44092f..0000000
--- a/drivers/media/platform/msm/camera_v1/mercury/msm_mercury_sync.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#ifndef MSM_MERCURY_SYNC_H
-#define MSM_MERCURY_SYNC_H
-
-#include <linux/fs.h>
-#include <linux/list.h>
-#include <linux/cdev.h>
-#include <linux/platform_device.h>
-#include <media/v4l2-device.h>
-#include <media/v4l2-subdev.h>
-#include "msm_mercury_core.h"
-
-struct msm_mercury_q {
-		char const  *name;
-		struct list_head  q;
-		spinlock_t  lck;
-		wait_queue_head_t wait;
-		int        unblck;
-};
-
-struct msm_mercury_q_entry {
-		struct list_head list;
-		void   *data;
-};
-
-struct msm_mercury_device {
-		struct platform_device *pdev;
-		struct resource        *mem;
-		int                     irq;
-		void                   *base;
-		struct clk *mercury_clk[2];
-		struct device *device;
-		struct cdev   cdev;
-		struct mutex  lock;
-		char      open_count;
-		uint8_t       op_mode;
-
-		/* event queue including frame done & err indications*/
-		struct msm_mercury_q evt_q;
-		struct v4l2_subdev subdev;
-
-};
-
-int __msm_mercury_open(struct msm_mercury_device *pmcry_dev);
-int __msm_mercury_release(struct msm_mercury_device *pmcry_dev);
-
-long __msm_mercury_ioctl(struct msm_mercury_device *pmcry_dev,
-	unsigned int cmd, unsigned long arg);
-
-struct msm_mercury_device *__msm_mercury_init(struct platform_device *pdev);
-int __msm_mercury_exit(struct msm_mercury_device *pmcry_dev);
-int msm_mercury_ioctl_hw_cmds(struct msm_mercury_device *pmcry_dev,
-	void * __user arg);
-int msm_mercury_ioctl_hw_cmds_wo(struct msm_mercury_device *pmcry_dev,
-	void * __user arg);
-#endif /* MSM_MERCURY_SYNC_H */
diff --git a/drivers/media/platform/msm/camera_v1/msm.c b/drivers/media/platform/msm/camera_v1/msm.c
deleted file mode 100644
index ef1edae..0000000
--- a/drivers/media/platform/msm/camera_v1/msm.c
+++ /dev/null
@@ -1,1590 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/workqueue.h>
-#include <linux/delay.h>
-#include <linux/types.h>
-#include <linux/list.h>
-#include <linux/ioctl.h>
-#include <linux/spinlock.h>
-#include <linux/proc_fs.h>
-#include "msm.h"
-#include "msm_cam_server.h"
-#include "msm_sensor.h"
-#include "msm_actuator.h"
-#include "msm_camera_eeprom.h"
-
-#define MSM_MAX_CAMERA_SENSORS 5
-
-#ifdef CONFIG_MSM_CAMERA_DEBUG
-#define D(fmt, args...) pr_debug("msm: " fmt, ##args)
-#else
-#define D(fmt, args...) do {} while (0)
-#endif
-
-static unsigned msm_camera_v4l2_nr = -1;
-static int vnode_count;
-
-module_param(msm_camera_v4l2_nr, uint, 0644);
-MODULE_PARM_DESC(msm_camera_v4l2_nr, "videoX start number, -1 is autodetect");
-
-/* callback function from all subdevices of a msm_cam_v4l2_device */
-static void msm_cam_v4l2_subdev_notify(struct v4l2_subdev *sd,
-				unsigned int notification, void *arg)
-{
-	struct msm_cam_v4l2_device *pcam;
-	struct msm_cam_media_controller *pmctl;
-
-	if (sd == NULL)
-		return;
-
-	pcam = to_pcam(sd->v4l2_dev);
-
-	if (pcam == NULL)
-		return;
-
-	pmctl = msm_cam_server_get_mctl(pcam->mctl_handle);
-	if (pmctl == NULL)
-		return;
-}
-
-/*
- *
- * implementation of v4l2_ioctl_ops
- *
- */
-static int msm_camera_v4l2_querycap(struct file *f, void *pctx,
-				struct v4l2_capability *pcaps)
-{
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	/* some other day, some other time */
-	/*cap->version = LINUX_VERSION_CODE; */
-	pcaps->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
-	return 0;
-}
-
-static int msm_camera_v4l2_queryctrl(struct file *f, void *pctx,
-				struct v4l2_queryctrl *pqctrl)
-{
-	int rc = 0;
-	struct msm_cam_v4l2_device *pcam  = video_drvdata(f);
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	mutex_lock(&pcam->vid_lock);
-	rc = msm_server_q_ctrl(pcam, pqctrl);
-	mutex_unlock(&pcam->vid_lock);
-	return rc;
-}
-
-static int msm_camera_v4l2_private_general(struct file *f, void *pctx,
-	struct msm_camera_v4l2_ioctl_t *ioctl_ptr)
-{
-	int rc = 0;
-	struct msm_cam_v4l2_device *pcam  = video_drvdata(f);
-
-	WARN_ON(pctx != f->private_data);
-
-	rc = msm_server_private_general(pcam, ioctl_ptr);
-	if (rc < 0)
-		pr_err("%s: Private command failed rc %d\n", __func__, rc);
-	return rc;
-}
-
-static int msm_camera_v4l2_private_g_ctrl(struct file *f, void *pctx,
-	struct msm_camera_v4l2_ioctl_t *ioctl_ptr)
-{
-	int rc = -EINVAL;
-	struct msm_cam_v4l2_device *pcam  = video_drvdata(f);
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	WARN_ON(pctx != f->private_data);
-
-	mutex_lock(&pcam->vid_lock);
-	switch (ioctl_ptr->id) {
-	case MSM_V4L2_PID_INST_HANDLE:
-		COPY_TO_USER(rc, (void __user *)ioctl_ptr->ioctl_ptr,
-			(void *)&pcam_inst->inst_handle, sizeof(uint32_t));
-		if (rc)
-			ERR_COPY_TO_USER();
-		break;
-	default:
-		pr_err("%s Unsupported ioctl %d ", __func__, ioctl_ptr->id);
-		break;
-	}
-	mutex_unlock(&pcam->vid_lock);
-	return rc;
-}
-
-static int msm_camera_v4l2_g_ctrl(struct file *f, void *pctx,
-					struct v4l2_control *c)
-{
-	int rc = 0;
-	struct msm_cam_v4l2_device *pcam  = video_drvdata(f);
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	mutex_lock(&pcam->vid_lock);
-	rc = msm_server_g_ctrl(pcam, c);
-	mutex_unlock(&pcam->vid_lock);
-
-	return rc;
-}
-
-static int msm_camera_v4l2_private_s_ctrl(struct file *f, void *pctx,
-			struct msm_camera_v4l2_ioctl_t *ioctl_ptr)
-{
-	int rc = -EINVAL;
-	struct msm_cam_v4l2_device *pcam  = video_drvdata(f);
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-	WARN_ON(pctx != f->private_data);
-	mutex_lock(&pcam->vid_lock);
-	switch (ioctl_ptr->id) {
-	case MSM_V4L2_PID_CTRL_CMD:
-		rc = msm_server_proc_ctrl_cmd(pcam, ioctl_ptr, 1);
-		break;
-	}
-	mutex_unlock(&pcam->vid_lock);
-	return rc;
-}
-
-static int msm_camera_v4l2_s_ctrl(struct file *f, void *pctx,
-					struct v4l2_control *ctrl)
-{
-	int rc = 0;
-	struct msm_cam_v4l2_device *pcam  = video_drvdata(f);
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	D("%s\n", __func__);
-
-	WARN_ON(pctx != f->private_data);
-	mutex_lock(&pcam->vid_lock);
-	switch (ctrl->id) {
-	case MSM_V4L2_PID_MMAP_INST:
-		D("%s: mmap_inst=(0x%p, %d)\n",
-			 __func__, pcam_inst, pcam_inst->my_index);
-		pcam_inst->is_mem_map_inst = 1;
-		break;
-	default:
-		if (ctrl->id == MSM_V4L2_PID_CAM_MODE)
-			pcam->op_mode = ctrl->value;
-		rc = msm_server_s_ctrl(pcam, ctrl);
-		break;
-	}
-	mutex_unlock(&pcam->vid_lock);
-
-	return rc;
-}
-
-static int msm_camera_v4l2_reqbufs(struct file *f, void *pctx,
-				struct v4l2_requestbuffers *pb)
-{
-	int rc = 0, i, j;
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	struct msm_cam_media_controller *pmctl;
-	struct msm_cam_v4l2_device *pcam = video_drvdata(f);
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	mutex_lock(&pcam_inst->inst_lock);
-	if (!pcam_inst->vbqueue_initialized && pb->count) {
-		pmctl = msm_cam_server_get_mctl(pcam->mctl_handle);
-		if (pmctl == NULL) {
-			pr_err("%s Invalid mctl ptr", __func__);
-			return -EINVAL;
-		}
-		pmctl->mctl_vbqueue_init(pcam_inst, &pcam_inst->vid_bufq,
-			pb->type);
-		pcam_inst->vbqueue_initialized = 1;
-	}
-
-	rc = vb2_reqbufs(&pcam_inst->vid_bufq, pb);
-	if (rc < 0) {
-		pr_err("%s reqbufs failed %d ", __func__, rc);
-		mutex_unlock(&pcam_inst->inst_lock);
-		return rc;
-	}
-	if (!pb->count) {
-		/* Deallocation. free buf_offset array */
-		D("%s Inst %p freeing buffer offsets array",
-			__func__, pcam_inst);
-		for (j = 0 ; j < pcam_inst->buf_count ; j++) {
-			kfree(pcam_inst->buf_offset[j]);
-			pcam_inst->buf_offset[j] = NULL;
-		}
-		kfree(pcam_inst->buf_offset);
-		pcam_inst->buf_offset = NULL;
-		/* If the userspace has deallocated all the
-		 * buffers, then release the vb2 queue */
-		if (pcam_inst->vbqueue_initialized) {
-			vb2_queue_release(&pcam_inst->vid_bufq);
-			pcam_inst->vbqueue_initialized = 0;
-		}
-	} else {
-		D("%s Inst %p Allocating buf_offset array",
-			__func__, pcam_inst);
-		/* Allocation. allocate buf_offset array */
-		pcam_inst->buf_offset = (struct msm_cam_buf_offset **)
-			kzalloc(pb->count * sizeof(struct msm_cam_buf_offset *),
-							GFP_KERNEL);
-		if (!pcam_inst->buf_offset) {
-			pr_err("%s out of memory ", __func__);
-			mutex_unlock(&pcam_inst->inst_lock);
-			return -ENOMEM;
-		}
-		for (i = 0; i < pb->count; i++) {
-			pcam_inst->buf_offset[i] =
-				kzalloc(sizeof(struct msm_cam_buf_offset) *
-				pcam_inst->plane_info.num_planes, GFP_KERNEL);
-			if (!pcam_inst->buf_offset[i]) {
-				pr_err("%s out of memory ", __func__);
-				for (j = i-1 ; j >= 0; j--) {
-					kfree(pcam_inst->buf_offset[j]);
-					pcam_inst->buf_offset[j] = NULL;
-				}
-				kfree(pcam_inst->buf_offset);
-				pcam_inst->buf_offset = NULL;
-				mutex_unlock(&pcam_inst->inst_lock);
-				return -ENOMEM;
-			}
-		}
-	}
-	pcam_inst->buf_count = pb->count;
-	mutex_unlock(&pcam_inst->inst_lock);
-	return rc;
-}
-
-static int msm_camera_v4l2_querybuf(struct file *f, void *pctx,
-					struct v4l2_buffer *pb)
-{
-	/* get the video device */
-	int rc = 0;
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-	mutex_lock(&pcam_inst->inst_lock);
-	rc = vb2_querybuf(&pcam_inst->vid_bufq, pb);
-	mutex_unlock(&pcam_inst->inst_lock);
-	return rc;
-}
-
-static int msm_camera_v4l2_qbuf(struct file *f, void *pctx,
-					struct v4l2_buffer *pb)
-{
-	int rc = 0, i = 0;
-	/* get the camera device */
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	D("%s Inst=%p, mode=%d, idx=%d\n", __func__, pcam_inst,
-		pcam_inst->image_mode, pb->index);
-	WARN_ON(pctx != f->private_data);
-
-	mutex_lock(&pcam_inst->inst_lock);
-	if (!pcam_inst->buf_offset) {
-		pr_err("%s Buffer is already released. Returning.\n", __func__);
-		mutex_unlock(&pcam_inst->inst_lock);
-		return -EINVAL;
-	}
-
-	if (pb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
-		/* Reject the buffer if planes array was not allocated */
-		if (pb->m.planes == NULL) {
-			pr_err("%s Planes array is null\n", __func__);
-			mutex_unlock(&pcam_inst->inst_lock);
-			return -EINVAL;
-		}
-		for (i = 0; i < pcam_inst->plane_info.num_planes; i++) {
-			D("%s stored offsets for plane %d as"
-				"addr offset %d, data offset %d\n",
-				__func__, i, pb->m.planes[i].reserved[0],
-				pb->m.planes[i].data_offset);
-			pcam_inst->buf_offset[pb->index][i].data_offset =
-				pb->m.planes[i].data_offset;
-			pcam_inst->buf_offset[pb->index][i].addr_offset =
-				pb->m.planes[i].reserved[0];
-		}
-	} else {
-		D("%s stored reserved info %d\n", __func__, pb->reserved);
-		pcam_inst->buf_offset[pb->index][0].addr_offset = pb->reserved;
-	}
-
-	rc = vb2_qbuf(&pcam_inst->vid_bufq, pb);
-	D("%s, videobuf_qbuf mode %d and idx %d returns %d\n", __func__,
-		pcam_inst->image_mode, pb->index, rc);
-	mutex_unlock(&pcam_inst->inst_lock);
-	return rc;
-}
-
-static int msm_camera_v4l2_dqbuf(struct file *f, void *pctx,
-					struct v4l2_buffer *pb)
-{
-	int rc = 0, i = 0;
-	/* get the camera device */
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	mutex_lock(&pcam_inst->inst_lock);
-	if (0 == pcam_inst->streamon) {
-		mutex_unlock(&pcam_inst->inst_lock);
-		return -EACCES;
-	}
-	rc = vb2_dqbuf(&pcam_inst->vid_bufq, pb,  f->f_flags & O_NONBLOCK);
-	D("%s, videobuf_dqbuf returns %d\n", __func__, rc);
-
-	if (pb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
-		/* Reject the buffer if planes array was not allocated */
-		if (pb->m.planes == NULL) {
-			pr_err("%s Planes array is null\n", __func__);
-			mutex_unlock(&pcam_inst->inst_lock);
-			return -EINVAL;
-		}
-		for (i = 0; i < pcam_inst->plane_info.num_planes; i++) {
-			pb->m.planes[i].data_offset =
-				pcam_inst->buf_offset[pb->index][i].data_offset;
-			pb->m.planes[i].reserved[0] =
-				pcam_inst->buf_offset[pb->index][i].addr_offset;
-			D("%s stored offsets for plane %d as "
-				"addr offset %d, data offset %d\n",
-				__func__, i, pb->m.planes[i].reserved[0],
-				pb->m.planes[i].data_offset);
-		}
-	} else {
-		D("%s stored reserved info %d\n", __func__, pb->reserved);
-		pb->reserved = pcam_inst->buf_offset[pb->index][0].addr_offset;
-	}
-
-	mutex_unlock(&pcam_inst->inst_lock);
-	return rc;
-}
-
-static int msm_camera_v4l2_streamon(struct file *f, void *pctx,
-					enum v4l2_buf_type buf_type)
-{
-	int rc = 0;
-	/* get the camera device */
-	struct msm_cam_v4l2_device *pcam  = video_drvdata(f);
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	D("%s Inst %p\n", __func__, pcam_inst);
-	WARN_ON(pctx != f->private_data);
-
-	mutex_lock(&pcam->vid_lock);
-	mutex_lock(&pcam_inst->inst_lock);
-	if ((buf_type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) &&
-		(buf_type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) {
-		pr_err("%s Invalid buffer type ", __func__);
-		mutex_unlock(&pcam_inst->inst_lock);
-		mutex_unlock(&pcam->vid_lock);
-		return -EINVAL;
-	}
-
-	D("%s Calling videobuf_streamon", __func__);
-	/* if HW streaming on is successful, start buffer streaming */
-	rc = vb2_streamon(&pcam_inst->vid_bufq, buf_type);
-	D("%s, videobuf_streamon returns %d\n", __func__, rc);
-
-	/* turn HW (VFE/sensor) streaming */
-	pcam_inst->streamon = 1;
-	rc = msm_server_streamon(pcam, pcam_inst->my_index);
-	mutex_unlock(&pcam_inst->inst_lock);
-	mutex_unlock(&pcam->vid_lock);
-	D("%s rc = %d\n", __func__, rc);
-	return rc;
-}
-
-static int msm_camera_v4l2_streamoff(struct file *f, void *pctx,
-					enum v4l2_buf_type buf_type)
-{
-	int rc = 0;
-	/* get the camera device */
-	struct msm_cam_v4l2_device *pcam  = video_drvdata(f);
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	D("%s Inst %p\n", __func__, pcam_inst);
-	WARN_ON(pctx != f->private_data);
-
-	if ((buf_type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) &&
-		(buf_type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) {
-		pr_err("%s Invalid buffer type ", __func__);
-		return -EINVAL;
-	}
-
-	/* first turn of HW (VFE/sensor) streaming so that buffers are
-		not in use when we free the buffers */
-	mutex_lock(&pcam->vid_lock);
-	mutex_lock(&pcam_inst->inst_lock);
-	pcam_inst->streamon = 0;
-	if (msm_server_get_usecount() > 0)
-		rc = msm_server_streamoff(pcam, pcam_inst->my_index);
-
-	if (rc < 0)
-		pr_err("%s: hw failed to stop streaming\n", __func__);
-
-	/* stop buffer streaming */
-	rc = vb2_streamoff(&pcam_inst->vid_bufq, buf_type);
-	D("%s, videobuf_streamoff returns %d\n", __func__, rc);
-
-	mutex_unlock(&pcam_inst->inst_lock);
-	mutex_unlock(&pcam->vid_lock);
-	return rc;
-}
-
-static int msm_camera_v4l2_enum_fmt_cap(struct file *f, void *pctx,
-					struct v4l2_fmtdesc *pfmtdesc)
-{
-	/* get the video device */
-	struct msm_cam_v4l2_device *pcam  = video_drvdata(f);
-	const struct msm_isp_color_fmt *isp_fmt;
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-	if ((pfmtdesc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) &&
-		(pfmtdesc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
-		return -EINVAL;
-
-	if (pfmtdesc->index >= pcam->num_fmts)
-		return -EINVAL;
-
-	isp_fmt = &pcam->usr_fmts[pfmtdesc->index];
-
-	if (isp_fmt->name)
-		strlcpy(pfmtdesc->description, isp_fmt->name,
-						sizeof(pfmtdesc->description));
-
-	pfmtdesc->pixelformat = isp_fmt->fourcc;
-
-	D("%s: [%d] 0x%x, %s\n", __func__, pfmtdesc->index,
-		isp_fmt->fourcc, isp_fmt->name);
-	return 0;
-}
-
-static int msm_camera_v4l2_g_fmt_cap(struct file *f,
-		void *pctx, struct v4l2_format *pfmt)
-{
-	int rc = 0;
-	/* get the video device */
-	struct msm_cam_v4l2_device *pcam  = video_drvdata(f);
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	if (pfmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-		return -EINVAL;
-
-	rc = msm_server_get_fmt(pcam, pcam_inst->my_index, pfmt);
-	D("%s: current_fmt->fourcc: 0x%08x, rc = %d\n", __func__,
-				pfmt->fmt.pix.pixelformat, rc);
-	return rc;
-}
-
-static int msm_camera_v4l2_g_fmt_cap_mplane(struct file *f,
-		void *pctx, struct v4l2_format *pfmt)
-{
-	int rc = 0;
-	/* get the video device */
-	struct msm_cam_v4l2_device *pcam  = video_drvdata(f);
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	if (pfmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
-		return -EINVAL;
-
-	rc = msm_server_get_fmt_mplane(pcam, pcam_inst->my_index, pfmt);
-	D("%s: current_fmt->fourcc: 0x%08x, rc = %d\n", __func__,
-					pfmt->fmt.pix_mp.pixelformat, rc);
-	return rc;
-}
-
-/* This function will readjust the format parameters based in HW
-  capabilities. Called by s_fmt_cap
-*/
-static int msm_camera_v4l2_try_fmt_cap(struct file *f, void *pctx,
-					struct v4l2_format *pfmt)
-{
-	int rc = 0;
-	/* get the video device */
-	struct msm_cam_v4l2_device *pcam  = video_drvdata(f);
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	mutex_lock(&pcam->vid_lock);
-	rc = msm_server_try_fmt(pcam, pfmt);
-	if (rc)
-		pr_err("Format %x not found, rc = %d\n",
-				pfmt->fmt.pix.pixelformat, rc);
-
-	mutex_unlock(&pcam->vid_lock);
-	return rc;
-}
-
-static int msm_camera_v4l2_try_fmt_cap_mplane(struct file *f, void *pctx,
-					struct v4l2_format *pfmt)
-{
-	int rc = 0;
-	/* get the video device */
-	struct msm_cam_v4l2_device *pcam  = video_drvdata(f);
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	mutex_lock(&pcam->vid_lock);
-	rc = msm_server_try_fmt_mplane(pcam, pfmt);
-	if (rc)
-		pr_err("Format %x not found, rc = %d\n",
-				pfmt->fmt.pix_mp.pixelformat, rc);
-
-	mutex_unlock(&pcam->vid_lock);
-	return rc;
-}
-
-/* This function will reconfig the v4l2 driver and HW device, it should be
-   called after the streaming is stopped.
-*/
-static int msm_camera_v4l2_s_fmt_cap(struct file *f, void *pctx,
-					struct v4l2_format *pfmt)
-{
-	int rc;
-	/* get the video device */
-	struct msm_cam_v4l2_device *pcam  = video_drvdata(f);
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	D("%s\n", __func__);
-	D("%s, inst=0x%x,idx=%d,priv = 0x%p\n",
-		__func__, (u32)pcam_inst, pcam_inst->my_index,
-		(void *)pfmt->fmt.pix.priv);
-	WARN_ON(pctx != f->private_data);
-
-	mutex_lock(&pcam->vid_lock);
-
-	rc = msm_server_set_fmt(pcam, pcam_inst->my_index, pfmt);
-	if (rc < 0) {
-		pr_err("%s: msm_server_set_fmt Error: %d\n",
-				__func__, rc);
-	}
-	mutex_unlock(&pcam->vid_lock);
-
-	return rc;
-}
-
-static int msm_camera_v4l2_s_fmt_cap_mplane(struct file *f, void *pctx,
-				struct v4l2_format *pfmt)
-{
-	int rc;
-	struct msm_cam_v4l2_device *pcam = video_drvdata(f);
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-			struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	D("%s Inst %p\n", __func__, pcam_inst);
-	WARN_ON(pctx != f->private_data);
-
-	mutex_lock(&pcam->vid_lock);
-	rc = msm_server_set_fmt_mplane(pcam, pcam_inst->my_index, pfmt);
-	mutex_unlock(&pcam->vid_lock);
-
-	return rc;
-}
-static int msm_camera_v4l2_g_jpegcomp(struct file *f, void *pctx,
-				struct v4l2_jpegcompression *pcomp)
-{
-	int rc = -EINVAL;
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	return rc;
-}
-
-static int msm_camera_v4l2_s_jpegcomp(struct file *f, void *pctx,
-				struct v4l2_jpegcompression *pcomp)
-{
-	int rc = -EINVAL;
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	return rc;
-}
-
-
-static int msm_camera_v4l2_g_crop(struct file *f, void *pctx,
-					struct v4l2_crop *crop)
-{
-	int rc = -EINVAL;
-	struct msm_cam_v4l2_device *pcam  = video_drvdata(f);
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	mutex_lock(&pcam->vid_lock);
-	rc = msm_server_get_crop(pcam, pcam_inst->my_index, crop);
-	mutex_unlock(&pcam->vid_lock);
-	return rc;
-}
-
-static int msm_camera_v4l2_s_crop(struct file *f, void *pctx,
-					struct v4l2_crop *a)
-{
-	int rc = -EINVAL;
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	return rc;
-}
-
-/* Stream type-dependent parameter ioctls */
-static int msm_camera_v4l2_g_parm(struct file *f, void *pctx,
-				struct v4l2_streamparm *a)
-{
-	int rc = -EINVAL;
-	return rc;
-}
-static int msm_vidbuf_get_path(u32 extendedmode)
-{
-	switch (extendedmode) {
-	case MSM_V4L2_EXT_CAPTURE_MODE_THUMBNAIL:
-		return OUTPUT_TYPE_T;
-	case MSM_V4L2_EXT_CAPTURE_MODE_MAIN:
-		return OUTPUT_TYPE_S;
-	case MSM_V4L2_EXT_CAPTURE_MODE_VIDEO:
-		return OUTPUT_TYPE_V;
-	case MSM_V4L2_EXT_CAPTURE_MODE_RDI:
-		return OUTPUT_TYPE_R;
-	case MSM_V4L2_EXT_CAPTURE_MODE_RDI1:
-		return OUTPUT_TYPE_R1;
-	case MSM_V4L2_EXT_CAPTURE_MODE_AEC:
-		return OUTPUT_TYPE_SAEC;
-	case MSM_V4L2_EXT_CAPTURE_MODE_AF:
-		return OUTPUT_TYPE_SAFC;
-	case MSM_V4L2_EXT_CAPTURE_MODE_AWB:
-		return OUTPUT_TYPE_SAWB;
-	case MSM_V4L2_EXT_CAPTURE_MODE_IHIST:
-		return OUTPUT_TYPE_IHST;
-	case MSM_V4L2_EXT_CAPTURE_MODE_CSTA:
-		return OUTPUT_TYPE_CSTA;
-	case MSM_V4L2_EXT_CAPTURE_MODE_DEFAULT:
-	case MSM_V4L2_EXT_CAPTURE_MODE_PREVIEW:
-	default:
-		return OUTPUT_TYPE_P;
-	}
-}
-
-static int msm_camera_v4l2_s_parm(struct file *f, void *pctx,
-				struct v4l2_streamparm *a)
-{
-	int rc = 0;
-	int is_bayer_sensor = 0;
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-	pcam_inst->image_mode = (a->parm.capture.extendedmode & 0x7F);
-	SET_DEVID_MODE(pcam_inst->inst_handle, pcam_inst->pcam->vnode_id);
-	SET_IMG_MODE(pcam_inst->inst_handle, pcam_inst->image_mode);
-	SET_VIDEO_INST_IDX(pcam_inst->inst_handle, pcam_inst->my_index);
-	pcam_inst->pcam->dev_inst_map[pcam_inst->image_mode] = pcam_inst;
-	pcam_inst->path = msm_vidbuf_get_path(pcam_inst->image_mode);
-	if (pcam_inst->pcam->sdata->sensor_type == BAYER_SENSOR)
-		is_bayer_sensor = 1;
-	rc = msm_cam_server_config_interface_map(pcam_inst->image_mode,
-			pcam_inst->pcam->mctl_handle, pcam_inst->pcam->vnode_id,
-			is_bayer_sensor);
-	D("%s path=%d, rc=%d\n", __func__,
-		pcam_inst->path, rc);
-	return rc;
-}
-
-static int msm_camera_v4l2_subscribe_event(struct v4l2_fh *fh,
-			struct v4l2_event_subscription *sub)
-{
-	int rc = 0;
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst =
-		(struct msm_cam_v4l2_dev_inst *)container_of(fh,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	D("%s:fh = 0x%x, type = 0x%x\n", __func__, (u32)fh, sub->type);
-	if (pcam_inst->my_index != 0)
-		return -EINVAL;
-	if (sub->type == V4L2_EVENT_ALL)
-		sub->type = V4L2_EVENT_PRIVATE_START+MSM_CAM_APP_NOTIFY_EVENT;
-	rc = v4l2_event_subscribe(fh, sub, 30);
-	if (rc < 0)
-		D("%s: failed for evtType = 0x%x, rc = %d\n",
-						__func__, sub->type, rc);
-	return rc;
-}
-
-static int msm_camera_v4l2_unsubscribe_event(struct v4l2_fh *fh,
-			struct v4l2_event_subscription *sub)
-{
-	int rc = 0;
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst =
-		(struct msm_cam_v4l2_dev_inst *)container_of(fh,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	D("%s: fh = 0x%x\n", __func__, (u32)fh);
-	if (pcam_inst->my_index != 0)
-		return -EINVAL;
-
-	rc = v4l2_event_unsubscribe(fh, sub);
-	D("%s: rc = %d\n", __func__, rc);
-	return rc;
-}
-
-static long msm_camera_v4l2_private_ioctl(struct file *file, void *fh,
-					  bool valid_prio, int cmd,
-					  void *arg)
-{
-	int rc = -EINVAL;
-	struct msm_camera_v4l2_ioctl_t *ioctl_ptr = arg;
-	struct msm_cam_v4l2_device *pcam  = video_drvdata(file);
-	D("%s: cmd %d\n", __func__, _IOC_NR(cmd));
-
-	switch (cmd) {
-	case MSM_CAM_V4L2_IOCTL_PRIVATE_S_CTRL:
-		rc = msm_camera_v4l2_private_s_ctrl(file, fh, ioctl_ptr);
-		break;
-	case MSM_CAM_V4L2_IOCTL_PRIVATE_G_CTRL:
-		rc = msm_camera_v4l2_private_g_ctrl(file, fh, ioctl_ptr);
-		break;
-	case MSM_CAM_V4L2_IOCTL_PRIVATE_GENERAL:
-		rc = msm_camera_v4l2_private_general(file, fh, ioctl_ptr);
-		break;
-	case MSM_CAM_V4L2_IOCTL_GET_EVENT_PAYLOAD: {
-		struct msm_queue_cmd *event_cmd;
-		void *payload;
-		mutex_lock(&pcam->event_lock);
-		event_cmd = msm_dequeue(&pcam->eventData_q, list_eventdata);
-		if (!event_cmd) {
-			pr_err("%s: No event payload\n", __func__);
-			rc = -EINVAL;
-			mutex_unlock(&pcam->event_lock);
-			return rc;
-		}
-		payload = event_cmd->command;
-		if (event_cmd->trans_code != ioctl_ptr->trans_code) {
-			pr_err("%s: Events don't match\n", __func__);
-			kfree(payload);
-			kfree(event_cmd);
-			rc = -EINVAL;
-			mutex_unlock(&pcam->event_lock);
-			break;
-		}
-		if (ioctl_ptr->len > 0) {
-			if (copy_to_user(ioctl_ptr->ioctl_ptr, payload,
-				 ioctl_ptr->len)) {
-				pr_err("%s Copy to user failed for cmd %d",
-					__func__, cmd);
-				kfree(payload);
-				kfree(event_cmd);
-				rc = -EINVAL;
-				mutex_unlock(&pcam->event_lock);
-				break;
-			}
-		}
-		kfree(payload);
-		kfree(event_cmd);
-		mutex_unlock(&pcam->event_lock);
-		rc = 0;
-		break;
-	}
-	default:
-		pr_err("%s Unsupported ioctl cmd %d ", __func__, cmd);
-		break;
-	}
-	return rc;
-}
-
-/* v4l2_ioctl_ops */
-static const struct v4l2_ioctl_ops g_msm_ioctl_ops = {
-	.vidioc_querycap = msm_camera_v4l2_querycap,
-
-	.vidioc_s_crop = msm_camera_v4l2_s_crop,
-	.vidioc_g_crop = msm_camera_v4l2_g_crop,
-
-	.vidioc_queryctrl = msm_camera_v4l2_queryctrl,
-	.vidioc_g_ctrl = msm_camera_v4l2_g_ctrl,
-	.vidioc_s_ctrl = msm_camera_v4l2_s_ctrl,
-
-	.vidioc_reqbufs = msm_camera_v4l2_reqbufs,
-	.vidioc_querybuf = msm_camera_v4l2_querybuf,
-	.vidioc_qbuf = msm_camera_v4l2_qbuf,
-	.vidioc_dqbuf = msm_camera_v4l2_dqbuf,
-
-	.vidioc_streamon = msm_camera_v4l2_streamon,
-	.vidioc_streamoff = msm_camera_v4l2_streamoff,
-
-	/* format ioctls */
-	.vidioc_enum_fmt_vid_cap = msm_camera_v4l2_enum_fmt_cap,
-	.vidioc_enum_fmt_vid_cap_mplane = msm_camera_v4l2_enum_fmt_cap,
-	.vidioc_try_fmt_vid_cap = msm_camera_v4l2_try_fmt_cap,
-	.vidioc_try_fmt_vid_cap_mplane = msm_camera_v4l2_try_fmt_cap_mplane,
-	.vidioc_g_fmt_vid_cap = msm_camera_v4l2_g_fmt_cap,
-	.vidioc_g_fmt_vid_cap_mplane = msm_camera_v4l2_g_fmt_cap_mplane,
-	.vidioc_s_fmt_vid_cap = msm_camera_v4l2_s_fmt_cap,
-	.vidioc_s_fmt_vid_cap_mplane = msm_camera_v4l2_s_fmt_cap_mplane,
-
-	.vidioc_g_jpegcomp = msm_camera_v4l2_g_jpegcomp,
-	.vidioc_s_jpegcomp = msm_camera_v4l2_s_jpegcomp,
-
-	/* Stream type-dependent parameter ioctls */
-	.vidioc_g_parm =  msm_camera_v4l2_g_parm,
-	.vidioc_s_parm =  msm_camera_v4l2_s_parm,
-
-	/* event subscribe/unsubscribe */
-	.vidioc_subscribe_event = msm_camera_v4l2_subscribe_event,
-	.vidioc_unsubscribe_event = msm_camera_v4l2_unsubscribe_event,
-	.vidioc_default = msm_camera_v4l2_private_ioctl,
-};
-
-/* v4l2_file_operations */
-static int msm_open(struct file *f)
-{
-	int i, rc = -EINVAL;
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-	int ion_client_created = 0;
-#endif
-	int server_q_idx = 0;
-	/* get the video device */
-	struct msm_cam_v4l2_device *pcam  = video_drvdata(f);
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	struct msm_cam_media_controller *pmctl = NULL;
-
-	D("%s\n", __func__);
-
-	if (!pcam) {
-		pr_err("%s NULL pointer passed in!\n", __func__);
-		return rc;
-	}
-	if (!msm_server_get_usecount()) {
-		pr_err("%s: error, daemon not yet started.", __func__);
-		return -EINVAL;
-	}
-	mutex_lock(&pcam->vid_lock);
-	for (i = 0; i < MSM_DEV_INST_MAX; i++) {
-		if (pcam->dev_inst[i] == NULL)
-			break;
-	}
-
-	/* if no instance is available, return error */
-	if (i == MSM_DEV_INST_MAX) {
-		mutex_unlock(&pcam->vid_lock);
-		return rc;
-	}
-	pcam_inst = kzalloc(sizeof(struct msm_cam_v4l2_dev_inst), GFP_KERNEL);
-	if (!pcam_inst) {
-		mutex_unlock(&pcam->vid_lock);
-		return rc;
-	}
-	mutex_init(&pcam_inst->inst_lock);
-	pcam_inst->sensor_pxlcode = pcam->usr_fmts[0].pxlcode;
-	pcam_inst->my_index = i;
-	pcam_inst->pcam = pcam;
-	pcam->dev_inst[i] = pcam_inst;
-
-	D("%s index %d nodeid %d count %d\n", __func__,
-			pcam_inst->my_index,
-			pcam->vnode_id, pcam->use_count);
-	pcam->use_count++;
-	D("%s Inst %p use_count %d\n", __func__, pcam_inst, pcam->use_count);
-	if (pcam->use_count == 1) {
-		server_q_idx = msm_find_free_queue();
-		if (server_q_idx < 0)
-			return server_q_idx;
-		rc = msm_server_begin_session(pcam, server_q_idx);
-		if (rc < 0) {
-			pr_err("%s error starting server session ", __func__);
-			goto msm_cam_server_begin_session_failed;
-		}
-		pmctl = msm_cam_server_get_mctl(pcam->mctl_handle);
-		if (!pmctl) {
-			pr_err("%s mctl ptr is null ", __func__);
-			goto msm_cam_server_begin_session_failed;
-		}
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-		pmctl->client = msm_ion_client_create(-1, "camera");
-		kref_init(&pmctl->refcount);
-		ion_client_created = 1;
-#endif
-
-		/* Should be set to sensor ops if any but right now its OK!! */
-		if (!pmctl->mctl_open) {
-			D("%s: media contoller is not inited\n", __func__);
-			rc = -ENODEV;
-			goto mctl_open_failed;
-		}
-
-		/* Now we really have to activate the camera */
-		D("%s: call mctl_open\n", __func__);
-		rc = pmctl->mctl_open(pmctl, MSM_APPS_ID_V4L2);
-		if (rc < 0) {
-			pr_err("%s: HW open failed rc = 0x%x\n",  __func__, rc);
-			goto mctl_open_failed;
-		}
-		pmctl->pcam_ptr = pcam;
-
-		msm_setup_v4l2_event_queue(&pcam_inst->eventHandle,
-			pcam->pvdev);
-		mutex_init(&pcam->event_lock);
-		msm_queue_init(&pcam->eventData_q, "eventData");
-	}
-	pcam_inst->vbqueue_initialized = 0;
-	rc = 0;
-
-	f->private_data = &pcam_inst->eventHandle;
-
-	D("f->private_data = 0x%x, pcam = 0x%x\n",
-		(u32)f->private_data, (u32)pcam_inst);
-
-	if (pcam->use_count == 1) {
-		rc = msm_send_open_server(pcam);
-		if (rc < 0 && rc != -ERESTARTSYS) {
-			pr_err("%s: msm_send_open_server failed %d\n",
-				__func__, rc);
-			goto msm_send_open_server_failed;
-		}
-	}
-	mutex_unlock(&pcam->vid_lock);
-	D("%s: end\n", __func__);
-	return rc;
-
-msm_send_open_server_failed:
-	msm_drain_eventq(&pcam->eventData_q);
-	msm_destroy_v4l2_event_queue(&pcam_inst->eventHandle);
-
-	if (pmctl->mctl_release)
-		pmctl->mctl_release(pmctl);
-mctl_open_failed:
-	if (pcam->use_count == 1) {
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-		if (ion_client_created) {
-			D("%s: destroy ion client", __func__);
-			kref_put(&pmctl->refcount, msm_release_ion_client);
-		}
-#endif
-		if (msm_server_end_session(pcam) < 0)
-			pr_err("%s: msm_server_end_session failed\n",
-				__func__);
-	}
-msm_cam_server_begin_session_failed:
-	if (pcam->use_count == 1) {
-		pcam->dev_inst[i] = NULL;
-		pcam->use_count = 0;
-	}
-	pcam->dev_inst[i] = NULL;
-	mutex_unlock(&pcam->vid_lock);
-	mutex_destroy(&pcam_inst->inst_lock);
-	kfree(pcam_inst);
-	pr_err("%s: error end", __func__);
-	return rc;
-}
-
-static int msm_addr_remap(struct msm_cam_v4l2_dev_inst *pcam_inst,
-				struct vm_area_struct *vma)
-{
-	int phyaddr;
-	int retval;
-	unsigned long size;
-	int rc = 0;
-	struct msm_cam_media_controller *mctl;
-
-	mctl = msm_cam_server_get_mctl(pcam_inst->pcam->mctl_handle);
-	if (!mctl) {
-		pr_err("%s: invalid mctl pointer", __func__);
-		return -EFAULT;
-	}
-
-	rc = msm_pmem_region_get_phy_addr(&mctl->stats_info.pmem_stats_list,
-			&pcam_inst->mem_map,
-			&phyaddr);
-	if (rc) {
-		pr_err("%s: cannot map vaddr", __func__);
-		return -EFAULT;
-	}
-	size = vma->vm_end - vma->vm_start;
-	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-	retval = remap_pfn_range(vma, vma->vm_start,
-			phyaddr >> PAGE_SHIFT,
-			size, vma->vm_page_prot);
-	if (retval) {
-		pr_err("%s:mmap: remap failed with error %d. ",
-			   __func__, retval);
-		memset(&pcam_inst->mem_map, 0, sizeof(pcam_inst->mem_map));
-		return -ENOMEM;
-	}
-	D("%s:mmap: phy_addr=0x%x: %08lx-%08lx, pgoff %08lx\n",
-		   __func__, (uint32_t)phyaddr,
-		   vma->vm_start, vma->vm_end, vma->vm_pgoff);
-	memset(&pcam_inst->mem_map, 0, sizeof(pcam_inst->mem_map));
-	return 0;
-}
-
-static int msm_mmap(struct file *f, struct vm_area_struct *vma)
-{
-	int rc = 0;
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	D("mmap called, vma=0x%08lx\n", (unsigned long)vma);
-
-	if (pcam_inst->is_mem_map_inst &&
-		pcam_inst->mem_map.cookie) {
-		rc = msm_addr_remap(pcam_inst, vma);
-		D("%s: msm_addr_remap ret=%d\n", __func__, rc);
-		return rc;
-	} else
-		rc = vb2_mmap(&pcam_inst->vid_bufq, vma);
-	D("vma start=0x%08lx, size=%ld, ret=%d\n",
-		(unsigned long)vma->vm_start,
-		(unsigned long)vma->vm_end - (unsigned long)vma->vm_start,
-		rc);
-
-	return rc;
-}
-
-void msm_release_ion_client(struct kref *ref)
-{
-	struct msm_cam_media_controller *mctl = container_of(ref,
-		struct msm_cam_media_controller, refcount);
-	pr_err("%s Calling ion_client_destroy\n", __func__);
-	ion_client_destroy(mctl->client);
-}
-
-static int msm_close(struct file *f)
-{
-	int rc = 0;
-	struct msm_cam_v4l2_device *pcam;
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	struct msm_cam_media_controller *pmctl;
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-	pcam = pcam_inst->pcam;
-	if (!pcam) {
-		pr_err("%s NULL pointer of camera device!\n", __func__);
-		return -EINVAL;
-	}
-
-	pmctl = msm_cam_server_get_mctl(pcam->mctl_handle);
-	if (!pmctl) {
-		pr_err("%s NULL mctl pointer\n", __func__);
-		return -EINVAL;
-	}
-
-	mutex_lock(&pcam->vid_lock);
-	mutex_lock(&pcam_inst->inst_lock);
-
-	if (pcam_inst->streamon) {
-		/*something went wrong since instance
-		is closing without streamoff*/
-		if (pmctl->mctl_release)
-			pmctl->mctl_release(pmctl);
-		pmctl->mctl_release = NULL;/*so that it isn't closed again*/
-	}
-
-	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);
-	D("%s index %d nodeid %d count %d\n", __func__, pcam_inst->my_index,
-		pcam->vnode_id, pcam->use_count);
-	pcam->dev_inst[pcam_inst->my_index] = NULL;
-	if (pcam_inst->my_index == 0) {
-		mutex_lock(&pcam->event_lock);
-		msm_drain_eventq(&pcam->eventData_q);
-		mutex_unlock(&pcam->event_lock);
-		mutex_destroy(&pcam->event_lock);
-		msm_destroy_v4l2_event_queue(&pcam_inst->eventHandle);
-	}
-
-	CLR_VIDEO_INST_IDX(pcam_inst->inst_handle);
-	CLR_IMG_MODE(pcam_inst->inst_handle);
-	CLR_DEVID_MODE(pcam_inst->inst_handle);
-	mutex_unlock(&pcam_inst->inst_lock);
-	mutex_destroy(&pcam_inst->inst_lock);
-	kfree(pcam_inst);
-	f->private_data = NULL;
-
-	if (pcam->use_count == 0) {
-		if (msm_server_get_usecount() > 0) {
-			rc = msm_send_close_server(pcam);
-			if (rc < 0)
-				pr_err("msm_send_close_server failed %d\n", rc);
-		}
-
-		if (pmctl->mctl_release)
-			pmctl->mctl_release(pmctl);
-
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-		kref_put(&pmctl->refcount, msm_release_ion_client);
-#endif
-		rc = msm_server_end_session(pcam);
-		if (rc < 0)
-			pr_err("msm_server_end_session fails %d\n", rc);
-	}
-	mutex_unlock(&pcam->vid_lock);
-	return rc;
-}
-
-static unsigned int msm_poll(struct file *f, struct poll_table_struct *wait)
-{
-	int rc = 0;
-	struct msm_cam_v4l2_device *pcam;
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-	pcam = pcam_inst->pcam;
-	D("%s\n", __func__);
-	if (!pcam) {
-		pr_err("%s NULL pointer of camera device!\n", __func__);
-		return -EINVAL;
-	}
-	if (pcam_inst->my_index == 0) {
-		poll_wait(f, &(pcam_inst->eventHandle.wait), wait);
-		if (v4l2_event_pending(&pcam_inst->eventHandle))
-			rc |= POLLPRI;
-	} else {
-		if (!pcam_inst->vid_bufq.streaming) {
-			D("%s vid_bufq.streaming is off, inst=0x%x\n",
-			__func__, (u32)pcam_inst);
-			return -EINVAL;
-		}
-		rc |= vb2_poll(&pcam_inst->vid_bufq, f, wait);
-	}
-	D("%s returns, rc  = 0x%x\n", __func__, rc);
-	return rc;
-}
-
-long msm_v4l2_evt_notify(struct msm_cam_media_controller *mctl,
-	unsigned int cmd, unsigned long evt)
-{
-	struct v4l2_event v4l2_ev;
-	struct v4l2_event_and_payload evt_payload;
-	struct msm_cam_v4l2_device *pcam = NULL;
-	int rc = 0;
-	struct msm_queue_cmd *event_qcmd;
-	void *payload;
-	if (!mctl) {
-		pr_err("%s: mctl is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	if (copy_from_user(&evt_payload, (void __user *)evt,
-		sizeof(struct v4l2_event_and_payload))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-
-	v4l2_ev = evt_payload.evt;
-	v4l2_ev.id = 0;
-	pcam = mctl->pcam_ptr;
-	ktime_get_ts(&v4l2_ev.timestamp);
-	if (evt_payload.payload_length > 0 && evt_payload.payload != NULL) {
-		mutex_lock(&pcam->event_lock);
-		event_qcmd = kzalloc(sizeof(struct msm_queue_cmd), GFP_KERNEL);
-		if (!event_qcmd) {
-			pr_err("%s Insufficient memory. return", __func__);
-			rc = -ENOMEM;
-			goto event_qcmd_alloc_fail;
-		}
-		payload = kzalloc(evt_payload.payload_length, GFP_KERNEL);
-		if (!payload) {
-			pr_err("%s Insufficient memory. return", __func__);
-			rc = -ENOMEM;
-			goto payload_alloc_fail;
-		}
-		if (copy_from_user(payload,
-				(void __user *)evt_payload.payload,
-				evt_payload.payload_length)) {
-			ERR_COPY_FROM_USER();
-			rc = -EFAULT;
-			goto copy_from_user_failed;
-		}
-		event_qcmd->command = payload;
-		event_qcmd->trans_code = evt_payload.transaction_id;
-		msm_enqueue(&pcam->eventData_q, &event_qcmd->list_eventdata);
-		mutex_unlock(&pcam->event_lock);
-	}
-	v4l2_event_queue(pcam->pvdev, &v4l2_ev);
-	return rc;
-copy_from_user_failed:
-	kfree(payload);
-payload_alloc_fail:
-	kfree(event_qcmd);
-event_qcmd_alloc_fail:
-	return rc;
-}
-
-
-static struct v4l2_file_operations g_msm_fops = {
-	.owner   = THIS_MODULE,
-	.open	= msm_open,
-	.poll	= msm_poll,
-	.mmap	= msm_mmap,
-	.release = msm_close,
-	.ioctl   = video_ioctl2,
-};
-
-static int msm_cam_dev_init(struct msm_cam_v4l2_device *pcam)
-{
-	int rc = -ENOMEM;
-	struct video_device *pvdev = NULL;
-	struct i2c_client *client = NULL;
-	struct platform_device *pdev = NULL;
-	D("%s\n", __func__);
-
-	/* first register the v4l2 device */
-	if (pcam->sensor_sdev->flags & V4L2_SUBDEV_FL_IS_I2C) {
-		client = v4l2_get_subdevdata(pcam->sensor_sdev);
-		pcam->v4l2_dev.dev = &client->dev;
-		pcam->media_dev.dev = &client->dev;
-	} else {
-		pdev = v4l2_get_subdevdata(pcam->sensor_sdev);
-		pcam->v4l2_dev.dev = &pdev->dev;
-		pcam->media_dev.dev = &pdev->dev;
-	}
-
-	rc = v4l2_device_register(pcam->v4l2_dev.dev, &pcam->v4l2_dev);
-	if (rc < 0)
-		return -EINVAL;
-	else
-		pcam->v4l2_dev.notify = msm_cam_v4l2_subdev_notify;
-
-
-	/* now setup video device */
-	pvdev = video_device_alloc();
-	if (pvdev == NULL) {
-		pr_err("%s: video_device_alloc failed\n", __func__);
-		return rc;
-	}
-
-	strlcpy(pcam->media_dev.model, QCAMERA_NAME,
-			sizeof(pcam->media_dev.model));
-	rc = media_device_register(&pcam->media_dev);
-	pvdev->v4l2_dev = &pcam->v4l2_dev;
-	pcam->v4l2_dev.mdev = &pcam->media_dev;
-
-	/* init video device's driver interface */
-	D("sensor name = %s, sizeof(pvdev->name)=%d\n",
-		pcam->sensor_sdev->name, sizeof(pvdev->name));
-
-	/* device info - strlcpy is safer than strncpy but
-	   only if architecture supports*/
-	strlcpy(pvdev->name, pcam->sensor_sdev->name, sizeof(pvdev->name));
-
-	pvdev->release   = video_device_release;
-	pvdev->fops	     = &g_msm_fops;
-	pvdev->ioctl_ops = &g_msm_ioctl_ops;
-	pvdev->minor	 = -1;
-	pvdev->vfl_type  = VFL_TYPE_GRABBER;
-
-	media_entity_init(&pvdev->entity, 0, NULL, 0);
-	pvdev->entity.type = MEDIA_ENT_T_DEVNODE_V4L;
-	pvdev->entity.group_id = QCAMERA_VNODE_GROUP_ID;
-
-	/* register v4l2 video device to kernel as /dev/videoXX */
-	D("video_register_device\n");
-	rc = video_register_device(pvdev,
-					VFL_TYPE_GRABBER,
-					msm_camera_v4l2_nr);
-	if (rc) {
-		pr_err("%s: video_register_device failed\n", __func__);
-		goto reg_fail;
-	}
-	pvdev->entity.name = video_device_node_name(pvdev);
-	D("%s: video device registered as /dev/video%d\n",
-		__func__, pvdev->num);
-
-	/* connect pcam and video dev to each other */
-	pcam->pvdev	= pvdev;
-	video_set_drvdata(pcam->pvdev, pcam);
-
-	return rc;
-
-reg_fail:
-	video_device_release(pvdev);
-	v4l2_device_unregister(&pcam->v4l2_dev);
-	pcam->v4l2_dev.dev = NULL;
-	return rc;
-}
-
-static struct v4l2_subdev *msm_actuator_probe(
-	struct msm_actuator_info *actuator_info)
-{
-	struct v4l2_subdev *act_sdev;
-	struct i2c_adapter *adapter = NULL;
-	struct msm_actuator_ctrl_t *actrl;
-	void *act_client = NULL;
-
-	D("%s called\n", __func__);
-
-	if (!actuator_info || !actuator_info->board_info)
-		goto probe_fail;
-
-	adapter = i2c_get_adapter(actuator_info->bus_id);
-	if (!adapter)
-		goto probe_fail;
-
-	act_client = i2c_new_device(adapter, actuator_info->board_info);
-	if (!act_client)
-		goto device_fail;
-
-	act_sdev = (struct v4l2_subdev *)i2c_get_clientdata(act_client);
-	if (act_sdev == NULL)
-		goto client_fail;
-
-	if (actuator_info->vcm_enable) {
-		actrl = get_actrl(act_sdev);
-		if (actrl) {
-			actrl->vcm_enable = actuator_info->vcm_enable;
-			actrl->vcm_pwd = actuator_info->vcm_pwd;
-		}
-	}
-
-	i2c_put_adapter(adapter);
-	return act_sdev;
-
-client_fail:
-	i2c_unregister_device(act_client);
-device_fail:
-	i2c_put_adapter(adapter);
-	adapter = NULL;
-probe_fail:
-	return NULL;
-}
-
-static struct v4l2_subdev *msm_eeprom_probe(
-	struct msm_eeprom_info *eeprom_info)
-{
-	struct v4l2_subdev *eeprom_sdev;
-	struct i2c_adapter *adapter = NULL;
-	void *eeprom_client = NULL;
-
-	D("%s called\n", __func__);
-
-	if (!eeprom_info || !eeprom_info->board_info)
-		goto probe_fail;
-
-	adapter = i2c_get_adapter(eeprom_info->bus_id);
-	if (!adapter)
-		goto probe_fail;
-
-	eeprom_client = i2c_new_device(adapter, eeprom_info->board_info);
-	if (!eeprom_client)
-		goto device_fail;
-
-	eeprom_sdev = (struct v4l2_subdev *)i2c_get_clientdata(eeprom_client);
-	if (eeprom_sdev == NULL)
-		goto client_fail;
-
-	i2c_put_adapter(adapter);
-	return eeprom_sdev;
-client_fail:
-	pr_err("%s client_fail\n", __func__);
-	i2c_unregister_device(eeprom_client);
-device_fail:
-	pr_err("%s device_fail\n", __func__);
-	i2c_put_adapter(adapter);
-	adapter = NULL;
-probe_fail:
-	pr_err("%s probe_fail\n", __func__);
-	return NULL;
-}
-
-static struct v4l2_subdev *msm_flash_probe(
-	struct msm_camera_sensor_flash_data *flash_info)
-{
-	struct v4l2_subdev *flash_sdev = NULL;
-	struct i2c_adapter *adapter = NULL;
-	void *flash_client = NULL;
-
-	D("%s called\n", __func__);
-
-	if (!flash_info || !flash_info->board_info)
-		goto probe_fail;
-
-	adapter = i2c_get_adapter(flash_info->bus_id);
-	if (!adapter)
-		goto probe_fail;
-
-	flash_client = i2c_new_device(adapter, flash_info->board_info);
-	if (!flash_client)
-		goto device_fail;
-
-	flash_sdev = (struct v4l2_subdev *)i2c_get_clientdata(flash_client);
-	if (flash_sdev == NULL)
-		goto client_fail;
-
-	i2c_put_adapter(adapter);
-	return flash_sdev;
-
-client_fail:
-	pr_err("%s client_fail\n", __func__);
-	i2c_unregister_device(flash_client);
-device_fail:
-	pr_err("%s device_fail\n", __func__);
-	i2c_put_adapter(adapter);
-	adapter = NULL;
-probe_fail:
-	pr_err("%s probe_fail\n", __func__);
-	return NULL;
-}
-
-/* register a msm sensor into the msm device, which will probe the
- * sensor HW. if the HW exist then create a video device (/dev/videoX/)
- * to represent this sensor */
-int msm_sensor_register(struct v4l2_subdev *sensor_sd)
-{
-	int rc = -EINVAL;
-	struct msm_camera_sensor_info *sdata;
-	struct msm_cam_v4l2_device *pcam;
-	struct msm_sensor_ctrl_t *s_ctrl;
-	struct msm_cam_subdev_info sd_info;
-
-	D("%s for %s\n", __func__, sensor_sd->name);
-
-	/* allocate the memory for the camera device first */
-	pcam = kzalloc(sizeof(*pcam), GFP_KERNEL);
-	if (!pcam) {
-		pr_err("%s: could not allocate mem for msm_cam_v4l2_device\n",
-			__func__);
-		return -ENOMEM;
-	}
-
-	pcam->sensor_sdev = sensor_sd;
-	s_ctrl = get_sctrl(sensor_sd);
-	sdata = (struct msm_camera_sensor_info *) s_ctrl->sensordata;
-
-	pcam->act_sdev = msm_actuator_probe(sdata->actuator_info);
-	pcam->eeprom_sdev = msm_eeprom_probe(sdata->eeprom_info);
-	pcam->flash_sdev = msm_flash_probe(sdata->flash_data);
-
-	D("%s: pcam =0x%p\n", __func__, pcam);
-
-	pcam->sdata = sdata;
-
-	/* init the user count and lock*/
-	pcam->use_count = 0;
-	mutex_init(&pcam->vid_lock);
-	mutex_init(&pcam->mctl_node.dev_lock);
-
-	/* Initialize the formats supported */
-	rc  = msm_mctl_init_user_formats(pcam);
-	if (rc < 0)
-		goto failure;
-
-	rc  = msm_cam_dev_init(pcam);
-	if (rc < 0)
-		goto failure;
-
-	rc = msm_setup_mctl_node(pcam);
-	if (rc < 0) {
-		pr_err("%s:failed to create mctl device: %d\n",
-			 __func__, rc);
-		goto failure;
-	}
-	msm_server_update_sensor_info(pcam, sdata);
-
-	sd_info.sdev_type = SENSOR_DEV;
-	sd_info.sd_index = vnode_count;
-	sd_info.irq_num = 0;
-	/* register the subdevice, must be done for callbacks */
-	rc = msm_cam_register_subdev_node(sensor_sd, &sd_info);
-	if (rc < 0) {
-		D("%s sensor sub device register failed\n",
-			__func__);
-		goto failure;
-	}
-
-	if (pcam->act_sdev) {
-		rc = v4l2_device_register_subdev(&pcam->v4l2_dev,
-				pcam->act_sdev);
-		if (rc < 0) {
-			D("%s actuator sub device register failed\n",
-			  __func__);
-			goto failure;
-		}
-	}
-
-	if (pcam->eeprom_sdev) {
-		rc = v4l2_device_register_subdev(&pcam->v4l2_dev,
-			pcam->eeprom_sdev);
-		if (rc < 0) {
-			D("%s eeprom sub device register failed\n", __func__);
-			goto failure;
-		}
-	}
-
-	if (pcam->flash_sdev) {
-		rc = v4l2_device_register_subdev(&pcam->v4l2_dev,
-			pcam->flash_sdev);
-		if (rc < 0) {
-			D("%s flash sub device register failed\n", __func__);
-			goto failure;
-		}
-	}
-
-	pcam->vnode_id = vnode_count++;
-	return rc;
-
-failure:
-	kzfree(pcam);
-	return rc;
-}
-EXPORT_SYMBOL(msm_sensor_register);
-
diff --git a/drivers/media/platform/msm/camera_v1/msm.h b/drivers/media/platform/msm/camera_v1/msm.h
deleted file mode 100644
index 1198f17..0000000
--- a/drivers/media/platform/msm/camera_v1/msm.h
+++ /dev/null
@@ -1,746 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- *
- */
-
-#ifndef _MSM_H
-#define _MSM_H
-
-#ifdef __KERNEL__
-
-/* Header files */
-#include <linux/i2c.h>
-#include <linux/videodev2.h>
-#include <linux/pm_qos.h>
-#include <linux/wakelock.h>
-#include <media/v4l2-dev.h>
-#include <media/v4l2-ioctl.h>
-#include <media/v4l2-device.h>
-#include <media/v4l2-fh.h>
-#include <media/v4l2-event.h>
-#include <media/v4l2-mediabus.h>
-#include <media/videobuf2-dma-contig.h>
-#include <media/videobuf2-msm-mem.h>
-#include <media/msm_isp.h>
-#include <mach/camera.h>
-#include <mach/iommu.h>
-#include <media/msm_isp.h>
-#include <linux/msm_ion.h>
-#include <linux/iommu.h>
-#include <media/msm_gestures.h>
-
-#define MSM_V4L2_DIMENSION_SIZE 96
-#define MAX_DEV_NAME_LEN 50
-
-#define ERR_USER_COPY(to) pr_err("%s(%d): copy %s user\n", \
-				__func__, __LINE__, ((to) ? "to" : "from"))
-#define ERR_COPY_FROM_USER() ERR_USER_COPY(0)
-#define ERR_COPY_TO_USER() ERR_USER_COPY(1)
-
-#define COPY_FROM_USER(error, dest, src, size) \
-	(error = (copy_from_user(dest, src, size) ? -EFAULT : 0))
-#define COPY_TO_USER(error, dest, src, size) \
-	(error = (copy_to_user(dest, src, size) ? -EFAULT : 0))
-
-#define MSM_CSIPHY_DRV_NAME "msm_csiphy"
-#define MSM_CSID_DRV_NAME "msm_csid"
-#define MSM_CSIC_DRV_NAME "msm_csic"
-#define MSM_ISPIF_DRV_NAME "msm_ispif"
-#define MSM_VFE_DRV_NAME "msm_vfe"
-#define MSM_VPE_DRV_NAME "msm_vpe"
-#define MSM_GEMINI_DRV_NAME "msm_gemini"
-#define MSM_MERCURY_DRV_NAME "msm_mercury"
-#define MSM_JPEG_DRV_NAME "msm_jpeg"
-#define MSM_I2C_MUX_DRV_NAME "msm_cam_i2c_mux"
-#define MSM_IRQ_ROUTER_DRV_NAME "msm_cam_irq_router"
-#define MSM_CPP_DRV_NAME "msm_cpp"
-#define MSM_CCI_DRV_NAME "msm_cci"
-
-#define MAX_NUM_SENSOR_DEV 3
-#define MAX_NUM_CSIPHY_DEV 3
-#define MAX_NUM_CSID_DEV 4
-#define MAX_NUM_CSIC_DEV 3
-#define MAX_NUM_ISPIF_DEV 1
-#define MAX_NUM_VFE_DEV 2
-#define MAX_NUM_AXI_DEV 2
-#define MAX_NUM_VPE_DEV 1
-#define MAX_NUM_JPEG_DEV 3
-#define MAX_NUM_CPP_DEV 1
-#define MAX_NUM_CCI_DEV 1
-#define MAX_NUM_FLASH_DEV 4
-
-/* msm queue management APIs*/
-
-#define msm_dequeue(queue, member) ({	   \
-	unsigned long flags;		  \
-	struct msm_device_queue *__q = (queue);	 \
-	struct msm_queue_cmd *qcmd = 0;	   \
-	spin_lock_irqsave(&__q->lock, flags);	 \
-	if (!list_empty(&__q->list)) {		\
-		__q->len--;		 \
-		qcmd = list_first_entry(&__q->list,   \
-		struct msm_queue_cmd, member);  \
-		list_del_init(&qcmd->member);	 \
-	}			 \
-	spin_unlock_irqrestore(&__q->lock, flags);  \
-	qcmd;			 \
-})
-
-#define msm_queue_drain(queue, member) do {	 \
-	unsigned long flags;		  \
-	struct msm_device_queue *__q = (queue);	 \
-	struct msm_queue_cmd *qcmd;	   \
-	spin_lock_irqsave(&__q->lock, flags);	 \
-	while (!list_empty(&__q->list)) {	 \
-		qcmd = list_first_entry(&__q->list,   \
-			struct msm_queue_cmd, member);	\
-			list_del_init(&qcmd->member);	 \
-			kfree(qcmd->command);		\
-			free_qcmd(qcmd);		\
-	 };			  \
-	spin_unlock_irqrestore(&__q->lock, flags);	\
-} while (0)
-
-static inline void free_qcmd(struct msm_queue_cmd *qcmd)
-{
-	if (!qcmd || !atomic_read(&qcmd->on_heap))
-		return;
-	if (!atomic_sub_return(1, &qcmd->on_heap))
-		kfree(qcmd);
-}
-
-struct isp_msg_stats {
-	uint32_t    id;
-	uint32_t    buffer;
-	uint32_t    frameCounter;
-	int32_t     buf_idx;
-	int32_t     fd;
-};
-
-struct msm_free_buf {
-	uint8_t num_planes;
-	uint32_t inst_handle;
-	uint32_t ch_paddr[VIDEO_MAX_PLANES];
-	uint32_t vb;
-};
-
-struct isp_msg_event {
-	uint32_t msg_id;
-	uint32_t sof_count;
-};
-
-struct isp_msg_output {
-	uint8_t   output_id;
-	struct msm_free_buf buf;
-	uint32_t  frameCounter;
-};
-
-struct rdi_count_msg {
-	uint32_t rdi_interface;
-	uint32_t count;
-};
-
-/* message id for v4l2_subdev_notify*/
-enum msm_camera_v4l2_subdev_notify {
-	NOTIFY_ISP_MSG_EVT, /* arg = enum ISP_MESSAGE_ID */
-	NOTIFY_VFE_MSG_OUT, /* arg = struct isp_msg_output */
-	NOTIFY_VFE_MSG_STATS,  /* arg = struct isp_msg_stats */
-	NOTIFY_VFE_MSG_COMP_STATS, /* arg = struct msm_stats_buf */
-	NOTIFY_VFE_BUF_EVT, /* arg = struct msm_vfe_resp */
-	NOTIFY_VFE_CAMIF_ERROR,
-	NOTIFY_VFE_PIX_SOF_COUNT, /*arg = int*/
-	NOTIFY_AXI_RDI_SOF_COUNT, /*arg = struct rdi_count_msg*/
-	NOTIFY_PCLK_CHANGE, /* arg = pclk */
-	NOTIFY_VFE_IRQ,
-	NOTIFY_AXI_IRQ,
-	NOTIFY_GESTURE_EVT, /* arg = v4l2_event */
-	NOTIFY_GESTURE_CAM_EVT, /* arg = int */
-	NOTIFY_INVALID
-};
-
-enum isp_vfe_cmd_id {
-	/*
-	*Important! Command_ID are arranged in order.
-	*Don't change!*/
-	ISP_VFE_CMD_ID_STREAM_ON,
-	ISP_VFE_CMD_ID_STREAM_OFF,
-	ISP_VFE_CMD_ID_FRAME_BUF_RELEASE
-};
-
-struct msm_cam_v4l2_device;
-struct msm_cam_v4l2_dev_inst;
-#define MSM_MAX_IMG_MODE                MSM_V4L2_EXT_CAPTURE_MODE_MAX
-
-enum msm_buffer_state {
-	MSM_BUFFER_STATE_UNUSED,
-	MSM_BUFFER_STATE_INITIALIZED,
-	MSM_BUFFER_STATE_PREPARED,
-	MSM_BUFFER_STATE_QUEUED,
-	MSM_BUFFER_STATE_RESERVED,
-	MSM_BUFFER_STATE_DEQUEUED
-};
-
-/* buffer for one video frame */
-struct msm_frame_buffer {
-	/* common v4l buffer stuff -- must be first */
-	struct vb2_buffer         vidbuf;
-	struct list_head		  list;
-	enum v4l2_mbus_pixelcode  pxlcode;
-	enum msm_buffer_state state;
-	int active;
-};
-
-struct msm_isp_color_fmt {
-	char *name;
-	int depth;
-	int bitsperpxl;
-	u32 fourcc;
-	enum v4l2_mbus_pixelcode pxlcode;
-	enum v4l2_colorspace colorspace;
-};
-
-struct msm_cam_return_frame_info {
-	int dirty;
-	int node_type;
-	struct timeval timestamp;
-	uint32_t frame_id;
-};
-
-struct msm_cam_timestamp {
-	uint8_t present;
-	struct timeval timestamp;
-	uint32_t frame_id;
-};
-
-struct msm_cam_buf_map_info {
-	int fd;
-	uint32_t data_offset;
-	unsigned long paddr;
-	unsigned long len;
-	struct file *file;
-	struct ion_handle *handle;
-};
-
-struct msm_cam_meta_frame {
-	struct msm_pp_frame frame;
-	/* Mapping information per plane */
-	struct msm_cam_buf_map_info map[VIDEO_MAX_PLANES];
-};
-
-struct msm_mctl_pp_frame_info {
-	int user_cmd;
-	struct msm_cam_meta_frame src_frame;
-	struct msm_cam_meta_frame dest_frame;
-	struct msm_mctl_pp_frame_cmd pp_frame_cmd;
-	struct msm_cam_media_controller *p_mctl;
-};
-
-struct msm_mctl_pp_ctrl {
-	int pp_msg_type;
-	struct msm_mctl_pp_frame_info *pp_frame_info;
-
-};
-struct msm_mctl_pp_info {
-	spinlock_t lock;
-	uint32_t cnt;
-	uint32_t pp_key;
-	uint32_t cur_frame_id[MSM_MAX_IMG_MODE];
-	struct msm_free_buf div_frame[MSM_MAX_IMG_MODE];
-	struct msm_mctl_pp_ctrl pp_ctrl;
-
-};
-/* "Media Controller" represents a camera steaming session,
- * which consists of a "sensor" device and an "isp" device
- * (such as VFE, if needed), connected via an "IO" device,
- * (such as IPIF on 8960, or none on 8660) plus other extra
- * sub devices such as VPE and flash.
- */
-
-struct msm_cam_media_controller {
-
-	int (*mctl_open)(struct msm_cam_media_controller *p_mctl,
-					 const char *const apps_id);
-	int (*mctl_cb)(void);
-	int (*mctl_cmd)(struct msm_cam_media_controller *p_mctl,
-					unsigned int cmd, unsigned long arg);
-	void (*mctl_release)(struct msm_cam_media_controller *p_mctl);
-	int (*mctl_buf_init)(struct msm_cam_v4l2_dev_inst *pcam);
-	int (*mctl_vbqueue_init)(struct msm_cam_v4l2_dev_inst *pcam,
-				struct vb2_queue *q, enum v4l2_buf_type type);
-	int (*mctl_ufmt_init)(struct msm_cam_media_controller *p_mctl);
-	int (*isp_config)(struct msm_cam_media_controller *pmctl,
-		 unsigned int cmd, unsigned long arg);
-	int (*isp_notify)(struct msm_cam_media_controller *pmctl,
-		struct v4l2_subdev *sd, unsigned int notification, void *arg);
-
-	/* the following reflect the HW topology information*/
-	struct v4l2_subdev *sensor_sdev; /* sensor sub device */
-	struct v4l2_subdev *act_sdev; /* actuator sub device */
-	struct v4l2_subdev *csiphy_sdev; /*csiphy sub device*/
-	struct v4l2_subdev *csid_sdev; /*csid sub device*/
-	struct v4l2_subdev *csic_sdev; /*csid sub device*/
-	struct v4l2_subdev *ispif_sdev; /* ispif sub device */
-	struct v4l2_subdev *gemini_sdev; /* gemini sub device */
-	struct v4l2_subdev *vpe_sdev; /* vpe sub device */
-	struct v4l2_subdev *axi_sdev; /* axi sub device */
-	struct v4l2_subdev *vfe_sdev; /* vfe sub device */
-	struct v4l2_subdev *eeprom_sdev; /* eeprom sub device */
-	struct v4l2_subdev *cpp_sdev;/*cpp sub device*/
-	struct v4l2_subdev *flash_sdev;/*flash sub device*/
-
-	struct msm_cam_config_dev *config_device;
-
-	/*mctl session control information*/
-	uint8_t opencnt; /*mctl ref count*/
-	const char *apps_id; /*ID for app that open this session*/
-	struct mutex lock;
-	struct wake_lock wake_lock; /*avoid low power mode when active*/
-	struct pm_qos_request pm_qos_req_list;
-	struct msm_mctl_pp_info pp_info;
-	struct msm_mctl_stats_t stats_info; /*stats pmem info*/
-	uint32_t vfe_output_mode; /* VFE output mode */
-	struct ion_client *client;
-	struct kref refcount;
-
-	/*pcam ptr*/
-	struct msm_cam_v4l2_device *pcam_ptr;
-
-	/*sensor info*/
-	struct msm_camera_sensor_info *sdata;
-
-	/*IOMMU mapped IMEM addresses*/
-	uint32_t ping_imem_y;
-	uint32_t ping_imem_cbcr;
-	uint32_t pong_imem_y;
-	uint32_t pong_imem_cbcr;
-
-	/*IOMMU domain for this session*/
-	int domain_num;
-	struct iommu_domain *domain;
-};
-
-struct msm_isp_buf_info {
-	int type;
-	unsigned long buffer;
-	int fd;
-};
-struct msm_cam_buf_offset {
-	uint32_t addr_offset;
-	uint32_t data_offset;
-};
-
-#define MSM_DEV_INST_MAX                    24
-struct msm_cam_v4l2_dev_inst {
-	struct v4l2_fh  eventHandle;
-	struct vb2_queue vid_bufq;
-	spinlock_t vq_irqlock;
-	struct list_head free_vq;
-	struct v4l2_format vid_fmt;
-	/* sensor pixel code*/
-	enum v4l2_mbus_pixelcode sensor_pxlcode;
-	struct msm_cam_v4l2_device *pcam;
-	int my_index;
-	uint32_t image_mode;
-	int path;
-	int buf_count;
-	/* buffer offsets, if any */
-	struct msm_cam_buf_offset **buf_offset;
-	struct v4l2_crop crop;
-	int streamon;
-	struct msm_mem_map_info mem_map;
-	int is_mem_map_inst;
-	struct img_plane_info plane_info;
-	int vbqueue_initialized;
-	struct mutex inst_lock;
-	uint32_t inst_handle;
-};
-
-struct msm_cam_mctl_node {
-	/* MCTL V4l2 device */
-	struct v4l2_device v4l2_dev;
-	struct video_device *pvdev;
-	struct msm_cam_v4l2_dev_inst *dev_inst[MSM_DEV_INST_MAX];
-	struct msm_cam_v4l2_dev_inst *dev_inst_map[MSM_MAX_IMG_MODE];
-	struct mutex dev_lock;
-	int active;
-	int use_count;
-};
-
-/* abstract camera device for each sensor successfully probed*/
-struct msm_cam_v4l2_device {
-
-	/* device node information */
-	int vnode_id;
-	struct v4l2_device v4l2_dev; /* V4l2 device */
-	struct video_device *pvdev; /* registered as /dev/video*/
-	struct msm_cam_mctl_node mctl_node; /* node for buffer management */
-	struct media_device media_dev; /* node to get video node info*/
-
-	/* device session information */
-	int use_count;
-	struct mutex vid_lock;
-	uint32_t server_queue_idx;
-	uint32_t mctl_handle;
-	struct msm_cam_v4l2_dev_inst *dev_inst[MSM_DEV_INST_MAX];
-	struct msm_cam_v4l2_dev_inst *dev_inst_map[MSM_MAX_IMG_MODE];
-	int op_mode;
-
-	/* v4l2 format support */
-	struct msm_isp_color_fmt *usr_fmts;
-	int num_fmts;
-
-	struct v4l2_subdev *sensor_sdev; /* sensor sub device */
-	struct v4l2_subdev *act_sdev; /* actuator sub device */
-	struct v4l2_subdev *eeprom_sdev; /* actuator sub device */
-	struct v4l2_subdev *flash_sdev; /* flash sub device */
-	struct msm_camera_sensor_info *sdata;
-
-	struct msm_device_queue eventData_q; /*payload for events sent to app*/
-	struct mutex event_lock;
-};
-
-static inline struct msm_cam_v4l2_device *to_pcam(
-	struct v4l2_device *v4l2_dev)
-{
-	return container_of(v4l2_dev, struct msm_cam_v4l2_device, v4l2_dev);
-}
-
-/*pseudo v4l2 device and v4l2 event queue
-  for server and config cdevs*/
-struct v4l2_queue_util {
-	struct video_device *pvdev;
-	struct v4l2_fh  eventHandle;
-};
-
-/* abstract config device for all sensor successfully probed*/
-struct msm_cam_config_dev {
-	struct cdev config_cdev;
-	struct v4l2_queue_util config_stat_event_queue;
-	int use_count;
-	struct msm_cam_media_controller *p_mctl;
-	struct msm_mem_map_info mem_map;
-	int dev_num;
-	int domain_num;
-	struct iommu_domain *domain;
-};
-
-struct msm_cam_subdev_info {
-	uint8_t sdev_type;
-	/* Subdev index. For eg: CSIPHY0, CSIPHY1 etc */
-	uint8_t sd_index;
-	/* This device/subdev's interrupt number, assigned
-	 * from the hardware document. */
-	uint8_t irq_num;
-};
-
-/* 2 for camera, 1 for gesture */
-#define MAX_NUM_ACTIVE_CAMERA 3
-
-struct msm_cam_server_queue {
-	uint32_t queue_active;
-	struct msm_device_queue ctrl_q;
-	struct msm_device_queue eventData_q;
-	uint8_t *ctrl_data;
-	uint32_t evt_id;
-};
-
-struct msm_cam_server_mctl_inst {
-	struct msm_cam_media_controller mctl;
-	uint32_t handle;
-};
-
-struct msm_cam_server_irqmap_entry {
-	int irq_num;
-	int irq_idx;
-	uint8_t cam_hw_idx;
-	uint8_t is_composite;
-};
-
-struct intr_table_entry {
-	/* irq_num as understood by msm.
-	 * Unique for every camera hw core & target. Use a mapping function
-	 * to map this irq number to its equivalent index in camera side. */
-	int irq_num;
-	/* Camera hw core idx, in case of non-composite IRQs*/
-	uint8_t cam_hw_idx;
-	/* Camera hw core mask, in case of composite IRQs. */
-	uint32_t cam_hw_mask;
-	/* Each interrupt is mapped to an index, which is used
-	 * to add/delete entries into the lookup table. Both the information
-	 * are needed in the lookup table to avoid another subdev call into
-	 * the IRQ Router subdev to get the irq_idx in the interrupt context */
-	int irq_idx;
-	/* Is this irq composite? */
-	uint8_t is_composite;
-	/* IRQ Trigger type: TRIGGER_RAISING, TRIGGER_HIGH, etc. */
-	uint32_t irq_trigger_type;
-	/* If IRQ Router hw is present,
-	 * this field holds the number of camera hw core
-	 * which are bundled together in the above
-	 * interrupt. > 1 in case of composite irqs.
-	 * If IRQ Router hw is not present, this field should be set to 1. */
-	int num_hwcore;
-	/* Pointers to the subdevs composited in this
-	 * irq. If not composite, the 0th index stores the subdev to which
-	 * this irq needs to be dispatched to. */
-	struct v4l2_subdev *subdev_list[CAMERA_SS_IRQ_MAX];
-	/* Device requesting the irq. */
-	const char *dev_name;
-	/* subdev private data, if any */
-	void *data;
-};
-
-struct irqmgr_intr_lkup_table {
-	/* Individual(hw) interrupt lookup table:
-	 * This table is populated during initialization and doesnt
-	 * change, unless the IRQ Router has been configured
-	 * for composite IRQs. If the IRQ Router has been configured
-	 * for composite IRQs, the is_composite field of that IRQ will
-	 * be set to 1(default 0). And when there is an interrupt on
-	 * that line, the composite interrupt lookup table is used
-	 * for handling the interrupt. */
-	struct intr_table_entry ind_intr_tbl[CAMERA_SS_IRQ_MAX];
-
-	/* Composite interrupt lookup table:
-	 * This table can be dynamically modified based on the usecase.
-	 * If the usecase requires two or more HW core IRQs to be bundled
-	 * into a single composite IRQ, then this table is populated
-	 * accordingly. Also when this is done, the composite field
-	 * in the intr_lookup_table has to be updated to reflect that
-	 * the irq 'irq_num' will now  be triggered in composite mode. */
-	struct intr_table_entry comp_intr_tbl[CAMERA_SS_IRQ_MAX];
-};
-
-struct interface_map {
-	/* The interface a particular stream belongs to.
-	 * PIX0, RDI0, RDI1, or RDI2
-	 */
-	int interface;
-	/* The handle of the mctl instance, interface runs on */
-	uint32_t mctl_handle;
-	int vnode_id;
-	int is_bayer_sensor;
-};
-
-/* abstract camera server device for all sensor successfully probed*/
-struct msm_cam_server_dev {
-
-	/* config node device*/
-	struct platform_device *server_pdev;
-	/* server node v4l2 device */
-	struct v4l2_device v4l2_dev;
-	struct video_device *video_dev;
-	struct media_device media_dev;
-
-	/* info of sensors successfully probed*/
-	struct msm_camera_info camera_info;
-	/* info of configs successfully created*/
-	struct msm_cam_config_dev_info config_info;
-	/* active working camera device - only one allowed at this time*/
-	struct msm_cam_v4l2_device *pcam_active[MAX_NUM_ACTIVE_CAMERA];
-	/* save the opened pcam for finding the mctl when doing buf lookup */
-	struct msm_cam_v4l2_device *opened_pcam[MAX_NUM_ACTIVE_CAMERA];
-	/* number of camera devices opened*/
-	atomic_t number_pcam_active;
-	struct v4l2_queue_util server_command_queue;
-
-	/* This queue used by the config thread to send responses back to the
-	 * control thread.  It is accessed only from a process context.
-	 */
-	struct msm_cam_server_queue server_queue[MAX_NUM_ACTIVE_CAMERA];
-	uint32_t server_evt_id;
-
-	struct msm_cam_server_mctl_inst mctl[MAX_NUM_ACTIVE_CAMERA];
-	uint32_t mctl_handle_cnt;
-
-	struct interface_map interface_map_table[INTF_MAX];
-
-	int use_count;
-	/* all the registered ISP subdevice*/
-	struct msm_isp_ops *isp_subdev[MSM_MAX_CAMERA_CONFIGS];
-	/* info of MCTL nodes successfully probed*/
-	struct msm_mctl_node_info mctl_node_info;
-	struct mutex server_lock;
-	struct mutex server_queue_lock;
-	/*v4l2 subdevs*/
-	struct v4l2_subdev *sensor_device[MAX_NUM_SENSOR_DEV];
-	struct v4l2_subdev *csiphy_device[MAX_NUM_CSIPHY_DEV];
-	struct v4l2_subdev *csid_device[MAX_NUM_CSID_DEV];
-	struct v4l2_subdev *csic_device[MAX_NUM_CSIC_DEV];
-	struct v4l2_subdev *ispif_device[MAX_NUM_ISPIF_DEV];
-	struct v4l2_subdev *vfe_device[MAX_NUM_VFE_DEV];
-	struct v4l2_subdev *axi_device[MAX_NUM_AXI_DEV];
-	struct v4l2_subdev *vpe_device[MAX_NUM_VPE_DEV];
-	struct v4l2_subdev *gesture_device;
-	struct v4l2_subdev *cpp_device[MAX_NUM_CPP_DEV];
-	struct v4l2_subdev *irqr_device;
-	struct v4l2_subdev *cci_device;
-	struct v4l2_subdev *flash_device[MAX_NUM_FLASH_DEV];
-
-	spinlock_t  intr_table_lock;
-	struct irqmgr_intr_lkup_table irq_lkup_table;
-	/* Stores the pointer to the subdev when the individual
-	 * subdevices register themselves with the server. This
-	 * will be used while dispatching composite irqs. The
-	 * cam_hw_idx will serve as the index into this array to
-	 * dispatch the irq to the corresponding subdev. */
-	struct v4l2_subdev *subdev_table[MSM_CAM_HW_MAX];
-	struct msm_cam_server_irqmap_entry hw_irqmap[CAMERA_SS_IRQ_MAX];
-
-    /*IOMMU domain (Page table)*/
-	int domain_num;
-	struct iommu_domain *domain;
-};
-
-enum msm_cam_buf_lookup_type {
-	BUF_LOOKUP_INVALID,
-	BUF_LOOKUP_BY_IMG_MODE,
-	BUF_LOOKUP_BY_INST_HANDLE,
-};
-
-struct msm_cam_buf_handle {
-	uint16_t buf_lookup_type;
-	uint32_t image_mode;
-	uint32_t inst_handle;
-};
-
-/* ISP related functions */
-void msm_isp_vfe_dev_init(struct v4l2_subdev *vd);
-int msm_isp_config(struct msm_cam_media_controller *pmctl,
-			 unsigned int cmd, unsigned long arg);
-int msm_isp_notify(struct msm_cam_media_controller *pmctl,
-	struct v4l2_subdev *sd, unsigned int notification, void *arg);
-/*
-int msm_isp_register(struct msm_cam_v4l2_device *pcam);
-*/
-int msm_sensor_register(struct v4l2_subdev *);
-int msm_isp_init_module(int g_num_config_nodes);
-
-int msm_mctl_init(struct msm_cam_v4l2_device *pcam);
-int msm_mctl_free(struct msm_cam_v4l2_device *pcam);
-int msm_mctl_buf_init(struct msm_cam_v4l2_device *pcam);
-int msm_mctl_init_user_formats(struct msm_cam_v4l2_device *pcam);
-int msm_mctl_buf_done(struct msm_cam_media_controller *pmctl,
-	struct msm_cam_buf_handle *buf_handle,
-	struct msm_free_buf *buf,
-	uint32_t frame_id);
-int msm_mctl_buf_done_pp(struct msm_cam_media_controller *pmctl,
-	struct msm_cam_buf_handle *buf_handle,
-	struct msm_free_buf *frame,
-	struct msm_cam_return_frame_info *ret_frame);
-int msm_mctl_reserve_free_buf(struct msm_cam_media_controller *pmctl,
-	struct msm_cam_v4l2_dev_inst *pcam_inst,
-	struct msm_cam_buf_handle *buf_handle,
-	struct msm_free_buf *free_buf);
-int msm_mctl_release_free_buf(struct msm_cam_media_controller *pmctl,
-	struct msm_cam_v4l2_dev_inst *pcam_inst,
-	struct msm_free_buf *free_buf);
-/*Memory(PMEM) functions*/
-int msm_register_pmem(struct hlist_head *ptype, void __user *arg,
-	struct ion_client *client, int domain_num);
-int msm_pmem_table_del(struct hlist_head *ptype, void __user *arg,
-	struct ion_client *client, int domain_num);
-int msm_pmem_region_get_phy_addr(struct hlist_head *ptype,
-	struct msm_mem_map_info *mem_map, int32_t *phyaddr);
-uint8_t msm_pmem_region_lookup(struct hlist_head *ptype,
-	int pmem_type, struct msm_pmem_region *reg, uint8_t maxcount);
-uint8_t msm_pmem_region_lookup_2(struct hlist_head *ptype,
-	int pmem_type, struct msm_pmem_region *reg,
-	uint8_t maxcount);
-unsigned long msm_pmem_stats_vtop_lookup(
-	struct msm_cam_media_controller *mctl,
-	unsigned long buffer, int fd);
-unsigned long msm_pmem_stats_ptov_lookup(
-	struct msm_cam_media_controller *mctl,
-	unsigned long addr, int *fd);
-
-int msm_vfe_subdev_init(struct v4l2_subdev *sd);
-void msm_vfe_subdev_release(struct v4l2_subdev *sd);
-
-int msm_isp_subdev_ioctl(struct v4l2_subdev *sd,
-	struct msm_vfe_cfg_cmd *cfgcmd, void *data);
-int msm_vpe_subdev_init(struct v4l2_subdev *sd);
-int msm_gemini_subdev_init(struct v4l2_subdev *gemini_sd);
-void msm_vpe_subdev_release(struct v4l2_subdev *sd);
-void msm_gemini_subdev_release(struct v4l2_subdev *gemini_sd);
-int msm_mctl_is_pp_msg_type(struct msm_cam_media_controller *p_mctl,
-	int msg_type);
-int msm_mctl_do_pp(struct msm_cam_media_controller *p_mctl,
-	int msg_type, uint32_t y_phy, uint32_t frame_id);
-int msm_mctl_pp_ioctl(struct msm_cam_media_controller *p_mctl,
-	unsigned int cmd, unsigned long arg);
-int msm_mctl_pp_notify(struct msm_cam_media_controller *pmctl,
-	struct msm_mctl_pp_frame_info *pp_frame_info);
-int msm_mctl_img_mode_to_inst_index(struct msm_cam_media_controller *pmctl,
-	int out_type, int node_type);
-struct msm_frame_buffer *msm_mctl_buf_find(
-	struct msm_cam_media_controller *pmctl,
-	struct msm_cam_v4l2_dev_inst *pcam_inst, int del_buf,
-	struct msm_free_buf *fbuf);
-void msm_mctl_gettimeofday(struct timeval *tv);
-int msm_mctl_check_pp(struct msm_cam_media_controller *p_mctl,
-	int msg_type, int *pp_divert_type, int *pp_type);
-int msm_mctl_do_pp_divert(
-	struct msm_cam_media_controller *p_mctl,
-	struct msm_cam_buf_handle *buf_handle,
-	struct msm_free_buf *fbuf,
-	uint32_t frame_id, int pp_type);
-int msm_mctl_pp_release_free_frame(
-	struct msm_cam_media_controller *p_mctl,
-	void __user *arg);
-int msm_mctl_pp_reserve_free_frame(
-	struct msm_cam_media_controller *p_mctl,
-	void __user *arg);
-int msm_mctl_set_pp_key(struct msm_cam_media_controller *p_mctl,
-	void __user *arg);
-int msm_mctl_pp_done(
-	struct msm_cam_media_controller *p_mctl,
-	void __user *arg);
-int msm_mctl_pp_divert_done(
-	struct msm_cam_media_controller *p_mctl,
-	void __user *arg);
-void msm_setup_v4l2_event_queue(struct v4l2_fh *eventHandle,
-	struct video_device *pvdev);
-void msm_destroy_v4l2_event_queue(struct v4l2_fh *eventHandle);
-int msm_setup_mctl_node(struct msm_cam_v4l2_device *pcam);
-struct msm_cam_v4l2_dev_inst *msm_mctl_get_pcam_inst(
-	struct msm_cam_media_controller *pmctl,
-	struct msm_cam_buf_handle *buf_handle);
-int msm_mctl_buf_return_buf(struct msm_cam_media_controller *pmctl,
-	int image_mode, struct msm_frame_buffer *buf);
-int msm_mctl_map_user_frame(struct msm_cam_meta_frame *meta_frame,
-	struct ion_client *client, int domain_num);
-int msm_mctl_unmap_user_frame(struct msm_cam_meta_frame *meta_frame,
-	struct ion_client *client, int domain_num);
-int msm_mctl_pp_mctl_divert_done(struct msm_cam_media_controller *p_mctl,
-	void __user *arg);
-void msm_release_ion_client(struct kref *ref);
-int msm_cam_register_subdev_node(struct v4l2_subdev *sd,
-	struct msm_cam_subdev_info *sd_info);
-int msm_mctl_find_sensor_subdevs(struct msm_cam_media_controller *p_mctl,
-	uint8_t csiphy_core_index, uint8_t csid_core_index);
-int msm_mctl_find_flash_subdev(struct msm_cam_media_controller *p_mctl,
-	uint8_t index);
-int msm_server_open_client(int *p_qidx);
-int msm_server_send_ctrl(struct msm_ctrl_cmd *out, int ctrl_id);
-int msm_server_close_client(int idx);
-int msm_cam_server_open_mctl_session(struct msm_cam_v4l2_device *pcam,
-	int *p_active);
-int msm_cam_server_close_mctl_session(struct msm_cam_v4l2_device *pcam);
-long msm_v4l2_evt_notify(struct msm_cam_media_controller *mctl,
-	unsigned int cmd, unsigned long evt);
-int msm_mctl_pp_get_vpe_buf_info(struct msm_mctl_pp_frame_info *zoom);
-void msm_queue_init(struct msm_device_queue *queue, const char *name);
-void msm_enqueue(struct msm_device_queue *queue, struct list_head *entry);
-void msm_drain_eventq(struct msm_device_queue *queue);
-#endif /* __KERNEL__ */
-
-#endif /* _MSM_H */
diff --git a/drivers/media/platform/msm/camera_v1/msm_axi_qos.c b/drivers/media/platform/msm/camera_v1/msm_axi_qos.c
deleted file mode 100644
index ac484d3..0000000
--- a/drivers/media/platform/msm/camera_v1/msm_axi_qos.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-
-#include <linux/clk.h>
-#include <mach/camera.h>
-#define MSM_AXI_QOS_NAME "msm_camera"
-
-static struct clk *ebi1_clk;
-
-int add_axi_qos(void)
-{
-	ebi1_clk = clk_get(NULL, "ebi1_vfe_clk");
-	if (IS_ERR(ebi1_clk))
-		ebi1_clk = NULL;
-	else {
-		clk_prepare(ebi1_clk);
-		clk_enable(ebi1_clk);
-	}
-
-	return 0;
-}
-
-int update_axi_qos(uint32_t rate)
-{
-	if (!ebi1_clk)
-		return 0;
-
-	return clk_set_rate(ebi1_clk, rate * 1000);
-}
-
-void release_axi_qos(void)
-{
-	if (!ebi1_clk)
-		return;
-
-	clk_disable(ebi1_clk);
-	clk_unprepare(ebi1_clk);
-	clk_put(ebi1_clk);
-	ebi1_clk = NULL;
-}
diff --git a/drivers/media/platform/msm/camera_v1/msm_camera.c b/drivers/media/platform/msm/camera_v1/msm_camera.c
deleted file mode 100644
index 213ccc7..0000000
--- a/drivers/media/platform/msm/camera_v1/msm_camera.c
+++ /dev/null
@@ -1,4052 +0,0 @@
-/* Copyright (c) 2009-2012, The Linux Foundation. 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.
- *
- */
-//FIXME: most allocations need not be GFP_ATOMIC
-/* FIXME: management of mutexes */
-/* FIXME: msm_pmem_region_lookup return values */
-/* FIXME: way too many copy to/from user */
-/* FIXME: does region->active mean free */
-/* FIXME: check limits on command lenghts passed from userspace */
-/* FIXME: __msm_release: which queues should we flush when opencnt != 0 */
-
-#include <linux/slab.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <mach/board.h>
-
-#include <linux/uaccess.h>
-#include <linux/fs.h>
-#include <linux/list.h>
-#include <linux/uaccess.h>
-
-#include <linux/poll.h>
-#include <media/msm_camera.h>
-#include <mach/camera.h>
-#include <linux/syscalls.h>
-#include <linux/hrtimer.h>
-#include <linux/msm_ion.h>
-
-#include <mach/cpuidle.h>
-DEFINE_MUTEX(ctrl_cmd_lock);
-
-#define CAMERA_STOP_VIDEO 58
-spinlock_t pp_prev_spinlock;
-spinlock_t pp_stereocam_spinlock;
-spinlock_t st_frame_spinlock;
-
-#define ERR_USER_COPY(to) pr_err("%s(%d): copy %s user\n", \
-				__func__, __LINE__, ((to) ? "to" : "from"))
-#define ERR_COPY_FROM_USER() ERR_USER_COPY(0)
-#define ERR_COPY_TO_USER() ERR_USER_COPY(1)
-#define MAX_PMEM_CFG_BUFFERS 10
-
-static struct class *msm_class;
-static dev_t msm_devno;
-static LIST_HEAD(msm_sensors);
-struct  msm_control_device *g_v4l2_control_device;
-int g_v4l2_opencnt;
-static int camera_node;
-static enum msm_camera_type camera_type[MSM_MAX_CAMERA_SENSORS];
-static uint32_t sensor_mount_angle[MSM_MAX_CAMERA_SENSORS];
-
-struct ion_client *client_for_ion;
-
-static const char *vfe_config_cmd[] = {
-	"CMD_GENERAL",  /* 0 */
-	"CMD_AXI_CFG_OUT1",
-	"CMD_AXI_CFG_SNAP_O1_AND_O2",
-	"CMD_AXI_CFG_OUT2",
-	"CMD_PICT_T_AXI_CFG",
-	"CMD_PICT_M_AXI_CFG",  /* 5 */
-	"CMD_RAW_PICT_AXI_CFG",
-	"CMD_FRAME_BUF_RELEASE",
-	"CMD_PREV_BUF_CFG",
-	"CMD_SNAP_BUF_RELEASE",
-	"CMD_SNAP_BUF_CFG",  /* 10 */
-	"CMD_STATS_DISABLE",
-	"CMD_STATS_AEC_AWB_ENABLE",
-	"CMD_STATS_AF_ENABLE",
-	"CMD_STATS_AEC_ENABLE",
-	"CMD_STATS_AWB_ENABLE",  /* 15 */
-	"CMD_STATS_ENABLE",
-	"CMD_STATS_AXI_CFG",
-	"CMD_STATS_AEC_AXI_CFG",
-	"CMD_STATS_AF_AXI_CFG",
-	"CMD_STATS_AWB_AXI_CFG",  /* 20 */
-	"CMD_STATS_RS_AXI_CFG",
-	"CMD_STATS_CS_AXI_CFG",
-	"CMD_STATS_IHIST_AXI_CFG",
-	"CMD_STATS_SKIN_AXI_CFG",
-	"CMD_STATS_BUF_RELEASE",  /* 25 */
-	"CMD_STATS_AEC_BUF_RELEASE",
-	"CMD_STATS_AF_BUF_RELEASE",
-	"CMD_STATS_AWB_BUF_RELEASE",
-	"CMD_STATS_RS_BUF_RELEASE",
-	"CMD_STATS_CS_BUF_RELEASE",  /* 30 */
-	"CMD_STATS_IHIST_BUF_RELEASE",
-	"CMD_STATS_SKIN_BUF_RELEASE",
-	"UPDATE_STATS_INVALID",
-	"CMD_AXI_CFG_SNAP_GEMINI",
-	"CMD_AXI_CFG_SNAP",  /* 35 */
-	"CMD_AXI_CFG_PREVIEW",
-	"CMD_AXI_CFG_VIDEO",
-	"CMD_STATS_IHIST_ENABLE",
-	"CMD_STATS_RS_ENABLE",
-	"CMD_STATS_CS_ENABLE",  /* 40 */
-	"CMD_VPE",
-	"CMD_AXI_CFG_VPE",
-	"CMD_AXI_CFG_SNAP_VPE",
-	"CMD_AXI_CFG_SNAP_THUMB_VPE",
-};
-#define __CONTAINS(r, v, l, field) ({				\
-	typeof(r) __r = r;					\
-	typeof(v) __v = v;					\
-	typeof(v) __e = __v + l;				\
-	int res = __v >= __r->field &&				\
-		__e <= __r->field + __r->len;			\
-	res;							\
-})
-
-#define CONTAINS(r1, r2, field) ({				\
-	typeof(r2) __r2 = r2;					\
-	__CONTAINS(r1, __r2->field, __r2->len, field);		\
-})
-
-#define IN_RANGE(r, v, field) ({				\
-	typeof(r) __r = r;					\
-	typeof(v) __vv = v;					\
-	int res = ((__vv >= __r->field) &&			\
-		(__vv < (__r->field + __r->len)));		\
-	res;							\
-})
-
-#define OVERLAPS(r1, r2, field) ({				\
-	typeof(r1) __r1 = r1;					\
-	typeof(r2) __r2 = r2;					\
-	typeof(__r2->field) __v = __r2->field;			\
-	typeof(__v) __e = __v + __r2->len - 1;			\
-	int res = (IN_RANGE(__r1, __v, field) ||		\
-		   IN_RANGE(__r1, __e, field));                 \
-	res;							\
-})
-
-static inline void free_qcmd(struct msm_queue_cmd *qcmd)
-{
-	if (!qcmd || !atomic_read(&qcmd->on_heap))
-		return;
-	if (!atomic_sub_return(1, &qcmd->on_heap))
-		kfree(qcmd);
-}
-
-static void msm_region_init(struct msm_sync *sync)
-{
-	INIT_HLIST_HEAD(&sync->pmem_frames);
-	INIT_HLIST_HEAD(&sync->pmem_stats);
-	spin_lock_init(&sync->pmem_frame_spinlock);
-	spin_lock_init(&sync->pmem_stats_spinlock);
-}
-
-static void msm_queue_init(struct msm_device_queue *queue, const char *name)
-{
-	spin_lock_init(&queue->lock);
-	queue->len = 0;
-	queue->max = 0;
-	queue->name = name;
-	INIT_LIST_HEAD(&queue->list);
-	init_waitqueue_head(&queue->wait);
-}
-
-static void msm_enqueue(struct msm_device_queue *queue,
-		struct list_head *entry)
-{
-	unsigned long flags;
-	spin_lock_irqsave(&queue->lock, flags);
-	queue->len++;
-	if (queue->len > queue->max) {
-		queue->max = queue->len;
-		CDBG("%s: queue %s new max is %d\n", __func__,
-			queue->name, queue->max);
-	}
-	list_add_tail(entry, &queue->list);
-	wake_up(&queue->wait);
-	CDBG("%s: woke up %s\n", __func__, queue->name);
-	spin_unlock_irqrestore(&queue->lock, flags);
-}
-
-static void msm_enqueue_vpe(struct msm_device_queue *queue,
-		struct list_head *entry)
-{
-	unsigned long flags;
-	spin_lock_irqsave(&queue->lock, flags);
-	queue->len++;
-	if (queue->len > queue->max) {
-		queue->max = queue->len;
-		CDBG("%s: queue %s new max is %d\n", __func__,
-			queue->name, queue->max);
-	}
-	list_add_tail(entry, &queue->list);
-    CDBG("%s: woke up %s\n", __func__, queue->name);
-	spin_unlock_irqrestore(&queue->lock, flags);
-}
-
-#define msm_dequeue(queue, member) ({				\
-	unsigned long flags;					\
-	struct msm_device_queue *__q = (queue);			\
-	struct msm_queue_cmd *qcmd = 0;				\
-	spin_lock_irqsave(&__q->lock, flags);			\
-	if (!list_empty(&__q->list)) {				\
-		__q->len--;					\
-		qcmd = list_first_entry(&__q->list,		\
-				struct msm_queue_cmd, member);	\
-		if ((qcmd) && (&qcmd->member) && (&qcmd->member.next))	\
-			list_del_init(&qcmd->member);			\
-	}							\
-	spin_unlock_irqrestore(&__q->lock, flags);	\
-	qcmd;							\
-})
-
-#define msm_delete_entry(queue, member, q_cmd) ({		\
-	unsigned long flags;					\
-	struct msm_device_queue *__q = (queue);			\
-	struct msm_queue_cmd *qcmd = 0;				\
-	spin_lock_irqsave(&__q->lock, flags);			\
-	if (!list_empty(&__q->list)) {				\
-		list_for_each_entry(qcmd, &__q->list, member)	\
-		if (qcmd == q_cmd) {				\
-			__q->len--;				\
-			list_del_init(&qcmd->member);		\
-			CDBG("msm_delete_entry, match found\n");\
-			kfree(q_cmd);				\
-			q_cmd = NULL;				\
-			break;					\
-		}						\
-	}							\
-	spin_unlock_irqrestore(&__q->lock, flags);		\
-	q_cmd;		\
-})
-
-#define msm_queue_drain(queue, member) do {			\
-	unsigned long flags;					\
-	struct msm_device_queue *__q = (queue);			\
-	struct msm_queue_cmd *qcmd;				\
-	spin_lock_irqsave(&__q->lock, flags);			\
-	while (!list_empty(&__q->list)) {			\
-		__q->len--;					\
-		qcmd = list_first_entry(&__q->list,		\
-			struct msm_queue_cmd, member);		\
-		if (qcmd) {					\
-			if (&qcmd->member)	\
-				list_del_init(&qcmd->member);		\
-			free_qcmd(qcmd);				\
-		}							\
-	}							\
-	spin_unlock_irqrestore(&__q->lock, flags);		\
-} while (0)
-
-static int check_overlap(struct hlist_head *ptype,
-			unsigned long paddr,
-			unsigned long len)
-{
-	struct msm_pmem_region *region;
-	struct msm_pmem_region t = { .paddr = paddr, .len = len };
-	struct hlist_node *node;
-
-	hlist_for_each_entry(region, node, ptype, list) {
-		if (CONTAINS(region, &t, paddr) ||
-				CONTAINS(&t, region, paddr) ||
-				OVERLAPS(region, &t, paddr)) {
-			CDBG(" region (PHYS %p len %ld)"
-				" clashes with registered region"
-				" (paddr %p len %ld)\n",
-				(void *)t.paddr, t.len,
-				(void *)region->paddr, region->len);
-			return -1;
-		}
-	}
-
-	return 0;
-}
-
-static int check_pmem_info(struct msm_pmem_info *info, int len)
-{
-	if (info->offset < len &&
-	    info->offset + info->len <= len &&
-	    info->planar0_off < len &&
-	    info->planar1_off < len &&
-	    info->planar2_off < len)
-		return 0;
-
-	pr_err("%s: check failed: off %d len %d y 0x%x cbcr_p1 0x%x p2_add 0x%x(total len %d)\n",
-		__func__,
-		info->offset,
-		info->len,
-		info->planar0_off,
-		info->planar1_off,
-		info->planar2_off,
-		len);
-	return -EINVAL;
-}
-static int msm_pmem_table_add(struct hlist_head *ptype,
-	struct msm_pmem_info *info, spinlock_t* pmem_spinlock,
-	struct msm_sync *sync)
-{
-	unsigned long paddr;
-#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
-	struct file *file;
-	unsigned long kvstart;
-#endif
-	unsigned long len;
-	int rc = -ENOMEM;
-	struct msm_pmem_region *region;
-	unsigned long flags;
-
-	region = kmalloc(sizeof(struct msm_pmem_region), GFP_KERNEL);
-	if (!region)
-		goto out;
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-		region->handle = ion_import_dma_buf(client_for_ion, info->fd);
-		if (IS_ERR_OR_NULL(region->handle))
-			goto out1;
-		ion_phys(client_for_ion, region->handle,
-			&paddr, (size_t *)&len);
-#endif
-	if (!info->len)
-		info->len = len;
-
-	rc = check_pmem_info(info, len);
-	if (rc < 0)
-		goto out2;
-
-	paddr += info->offset;
-	len = info->len;
-
-	spin_lock_irqsave(pmem_spinlock, flags);
-	if (check_overlap(ptype, paddr, len) < 0) {
-		spin_unlock_irqrestore(pmem_spinlock, flags);
-		rc = -EINVAL;
-		goto out2;
-	}
-	spin_unlock_irqrestore(pmem_spinlock, flags);
-
-	spin_lock_irqsave(pmem_spinlock, flags);
-	INIT_HLIST_NODE(&region->list);
-
-	region->paddr = paddr;
-	region->len = len;
-	memcpy(&region->info, info, sizeof(region->info));
-
-	hlist_add_head(&(region->list), ptype);
-	spin_unlock_irqrestore(pmem_spinlock, flags);
-	CDBG("%s: type %d, paddr 0x%lx, vaddr 0x%lx p0_add = 0x%x"
-		"p1_addr = 0x%x p2_addr = 0x%x\n",
-		__func__, info->type, paddr, (unsigned long)info->vaddr,
-		info->planar0_off, info->planar1_off, info->planar2_off);
-	return 0;
-out2:
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-	ion_free(client_for_ion, region->handle);
-#endif
-out1:
-	kfree(region);
-out:
-	return rc;
-}
-
-/* return of 0 means failure */
-static uint8_t msm_pmem_region_lookup(struct hlist_head *ptype,
-	int pmem_type, struct msm_pmem_region *reg, uint8_t maxcount,
-	spinlock_t *pmem_spinlock)
-{
-	struct msm_pmem_region *region;
-	struct msm_pmem_region *regptr;
-	struct hlist_node *node, *n;
-	unsigned long flags = 0;
-
-	uint8_t rc = 0;
-
-	regptr = reg;
-	spin_lock_irqsave(pmem_spinlock, flags);
-	hlist_for_each_entry_safe(region, node, n, ptype, list) {
-		if (region->info.type == pmem_type && region->info.active) {
-			*regptr = *region;
-			rc += 1;
-			if (rc >= maxcount)
-				break;
-			regptr++;
-		}
-	}
-	spin_unlock_irqrestore(pmem_spinlock, flags);
-	/* After lookup failure, dump all the list entries...*/
-	if (rc == 0) {
-		pr_err("%s: pmem_type = %d\n", __func__, pmem_type);
-		hlist_for_each_entry_safe(region, node, n, ptype, list) {
-			pr_err("listed region->info.type = %d, active = %d",
-				region->info.type, region->info.active);
-		}
-
-	}
-	return rc;
-}
-
-static uint8_t msm_pmem_region_lookup_2(struct hlist_head *ptype,
-					int pmem_type,
-					struct msm_pmem_region *reg,
-					uint8_t maxcount,
-					spinlock_t *pmem_spinlock)
-{
-	struct msm_pmem_region *region;
-	struct msm_pmem_region *regptr;
-	struct hlist_node *node, *n;
-	uint8_t rc = 0;
-	unsigned long flags = 0;
-	regptr = reg;
-	spin_lock_irqsave(pmem_spinlock, flags);
-	hlist_for_each_entry_safe(region, node, n, ptype, list) {
-		CDBG("%s:info.type=%d, pmem_type = %d,"
-						"info.active = %d\n",
-		__func__, region->info.type, pmem_type, region->info.active);
-
-		if (region->info.type == pmem_type && region->info.active) {
-			CDBG("%s:info.type=%d, pmem_type = %d,"
-							"info.active = %d,\n",
-				__func__, region->info.type, pmem_type,
-				region->info.active);
-			*regptr = *region;
-			region->info.type = MSM_PMEM_VIDEO;
-			rc += 1;
-			if (rc >= maxcount)
-				break;
-			regptr++;
-		}
-	}
-	spin_unlock_irqrestore(pmem_spinlock, flags);
-	return rc;
-}
-
-static int msm_pmem_frame_ptov_lookup(struct msm_sync *sync,
-		unsigned long p0addr,
-		unsigned long p1addr,
-		unsigned long p2addr,
-		struct msm_pmem_info *pmem_info,
-		int clear_active)
-{
-	struct msm_pmem_region *region;
-	struct hlist_node *node, *n;
-	unsigned long flags = 0;
-
-	spin_lock_irqsave(&sync->pmem_frame_spinlock, flags);
-	hlist_for_each_entry_safe(region, node, n, &sync->pmem_frames, list) {
-		if (p0addr == (region->paddr + region->info.planar0_off) &&
-			p1addr == (region->paddr + region->info.planar1_off) &&
-			p2addr == (region->paddr + region->info.planar2_off) &&
-			region->info.active) {
-			/* offset since we could pass vaddr inside
-			 * a registerd pmem buffer
-			 */
-			memcpy(pmem_info, &region->info, sizeof(*pmem_info));
-			if (clear_active)
-				region->info.active = 0;
-			spin_unlock_irqrestore(&sync->pmem_frame_spinlock,
-				flags);
-			return 0;
-		}
-	}
-	/* After lookup failure, dump all the list entries... */
-	pr_err("%s, for plane0 addr = 0x%lx, plane1 addr = 0x%lx  plane2 addr = 0x%lx\n",
-			__func__, p0addr, p1addr, p2addr);
-	hlist_for_each_entry_safe(region, node, n, &sync->pmem_frames, list) {
-		pr_err("listed p0addr 0x%lx, p1addr 0x%lx, p2addr 0x%lx, active = %d",
-				(region->paddr + region->info.planar0_off),
-				(region->paddr + region->info.planar1_off),
-				(region->paddr + region->info.planar2_off),
-				region->info.active);
-	}
-
-	spin_unlock_irqrestore(&sync->pmem_frame_spinlock, flags);
-	return -EINVAL;
-}
-
-static int msm_pmem_frame_ptov_lookup2(struct msm_sync *sync,
-		unsigned long p0_phy,
-		struct msm_pmem_info *pmem_info,
-		int clear_active)
-{
-	struct msm_pmem_region *region;
-	struct hlist_node *node, *n;
-	unsigned long flags = 0;
-
-	spin_lock_irqsave(&sync->pmem_frame_spinlock, flags);
-	hlist_for_each_entry_safe(region, node, n, &sync->pmem_frames, list) {
-		if (p0_phy == (region->paddr + region->info.planar0_off) &&
-				region->info.active) {
-			/* offset since we could pass vaddr inside
-			 * a registerd pmem buffer
-			 */
-			memcpy(pmem_info, &region->info, sizeof(*pmem_info));
-			if (clear_active)
-				region->info.active = 0;
-			spin_unlock_irqrestore(&sync->pmem_frame_spinlock,
-				flags);
-			return 0;
-		}
-	}
-
-	spin_unlock_irqrestore(&sync->pmem_frame_spinlock, flags);
-	return -EINVAL;
-}
-
-static unsigned long msm_pmem_stats_ptov_lookup(struct msm_sync *sync,
-		unsigned long addr, int *fd)
-{
-	struct msm_pmem_region *region;
-	struct hlist_node *node, *n;
-	unsigned long flags = 0;
-
-	spin_lock_irqsave(&sync->pmem_stats_spinlock, flags);
-	hlist_for_each_entry_safe(region, node, n, &sync->pmem_stats, list) {
-		if (addr == region->paddr && region->info.active) {
-			/* offset since we could pass vaddr inside a
-			 * registered pmem buffer */
-			*fd = region->info.fd;
-			region->info.active = 0;
-			spin_unlock_irqrestore(&sync->pmem_stats_spinlock,
-				flags);
-			return (unsigned long)(region->info.vaddr);
-		}
-	}
-	/* After lookup failure, dump all the list entries... */
-	pr_err("%s, lookup failure, for paddr 0x%lx\n",
-			__func__, addr);
-	hlist_for_each_entry_safe(region, node, n, &sync->pmem_stats, list) {
-		pr_err("listed paddr 0x%lx, active = %d",
-				region->paddr,
-				region->info.active);
-	}
-	spin_unlock_irqrestore(&sync->pmem_stats_spinlock, flags);
-
-	return 0;
-}
-
-static unsigned long msm_pmem_frame_vtop_lookup(struct msm_sync *sync,
-		unsigned long buffer, uint32_t p0_off, uint32_t p1_off,
-		uint32_t p2_off, int fd, int change_flag)
-{
-	struct msm_pmem_region *region;
-	struct hlist_node *node, *n;
-	unsigned long flags = 0;
-
-	spin_lock_irqsave(&sync->pmem_frame_spinlock, flags);
-	hlist_for_each_entry_safe(region,
-		node, n, &sync->pmem_frames, list) {
-		if (((unsigned long)(region->info.vaddr) == buffer) &&
-				(region->info.planar0_off == p0_off) &&
-				(region->info.planar1_off == p1_off) &&
-				(region->info.planar2_off == p2_off) &&
-				(region->info.fd == fd) &&
-				(region->info.active == 0)) {
-			if (change_flag)
-				region->info.active = 1;
-			spin_unlock_irqrestore(&sync->pmem_frame_spinlock,
-				flags);
-			return region->paddr;
-		}
-	}
-	/* After lookup failure, dump all the list entries... */
-	pr_err("%s, failed for vaddr 0x%lx, p0_off %d p1_off %d\n",
-			__func__, buffer, p0_off, p1_off);
-	hlist_for_each_entry_safe(region, node, n, &sync->pmem_frames, list) {
-		pr_err("%s, listed vaddr 0x%lx, r_p0 = 0x%x p0_off 0x%x"
-			"r_p1 = 0x%x, p1_off 0x%x, r_p2 = 0x%x, p2_off = 0x%x"
-			" active = %d\n", __func__, buffer,
-			region->info.planar0_off,
-			p0_off, region->info.planar1_off,
-			p1_off, region->info.planar2_off, p2_off,
-			region->info.active);
-	}
-
-	spin_unlock_irqrestore(&sync->pmem_frame_spinlock, flags);
-
-	return 0;
-}
-
-static unsigned long msm_pmem_stats_vtop_lookup(
-		struct msm_sync *sync,
-		unsigned long buffer,
-		int fd)
-{
-	struct msm_pmem_region *region;
-	struct hlist_node *node, *n;
-	unsigned long flags = 0;
-
-	spin_lock_irqsave(&sync->pmem_stats_spinlock, flags);
-	hlist_for_each_entry_safe(region, node, n, &sync->pmem_stats, list) {
-		if (((unsigned long)(region->info.vaddr) == buffer) &&
-				(region->info.fd == fd) &&
-				region->info.active == 0) {
-			region->info.active = 1;
-			spin_unlock_irqrestore(&sync->pmem_stats_spinlock,
-				flags);
-			return region->paddr;
-		}
-	}
-	/* After lookup failure, dump all the list entries... */
-	pr_err("%s,look up error for vaddr %ld\n",
-			__func__, buffer);
-	hlist_for_each_entry_safe(region, node, n, &sync->pmem_stats, list) {
-		pr_err("listed vaddr 0x%p, active = %d",
-				region->info.vaddr,
-				region->info.active);
-	}
-	spin_unlock_irqrestore(&sync->pmem_stats_spinlock, flags);
-
-	return 0;
-}
-
-static int __msm_pmem_table_del(struct msm_sync *sync,
-		struct msm_pmem_info *pinfo)
-{
-	int rc = 0;
-	struct msm_pmem_region *region;
-	struct hlist_node *node, *n;
-	unsigned long flags = 0;
-
-	switch (pinfo->type) {
-	case MSM_PMEM_PREVIEW:
-	case MSM_PMEM_THUMBNAIL:
-	case MSM_PMEM_MAINIMG:
-	case MSM_PMEM_RAW_MAINIMG:
-	case MSM_PMEM_C2D:
-	case MSM_PMEM_MAINIMG_VPE:
-	case MSM_PMEM_THUMBNAIL_VPE:
-		spin_lock_irqsave(&sync->pmem_frame_spinlock, flags);
-		hlist_for_each_entry_safe(region, node, n,
-			&sync->pmem_frames, list) {
-
-			if (pinfo->type == region->info.type &&
-					pinfo->vaddr == region->info.vaddr &&
-					pinfo->fd == region->info.fd) {
-				hlist_del(node);
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-				ion_free(client_for_ion, region->handle);
-#endif
-				kfree(region);
-				CDBG("%s: type %d, vaddr  0x%p\n",
-					__func__, pinfo->type, pinfo->vaddr);
-			}
-		}
-		spin_unlock_irqrestore(&sync->pmem_frame_spinlock, flags);
-		break;
-
-	case MSM_PMEM_VIDEO:
-	case MSM_PMEM_VIDEO_VPE:
-		spin_lock_irqsave(&sync->pmem_frame_spinlock, flags);
-		hlist_for_each_entry_safe(region, node, n,
-			&sync->pmem_frames, list) {
-
-			if (((region->info.type == MSM_PMEM_VIDEO) ||
-				(region->info.type == MSM_PMEM_VIDEO_VPE)) &&
-				pinfo->vaddr == region->info.vaddr &&
-				pinfo->fd == region->info.fd) {
-				hlist_del(node);
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-				ion_free(client_for_ion, region->handle);
-#endif
-				kfree(region);
-				CDBG("%s: type %d, vaddr  0x%p\n",
-					__func__, pinfo->type, pinfo->vaddr);
-			}
-		}
-		spin_unlock_irqrestore(&sync->pmem_frame_spinlock, flags);
-		break;
-
-	case MSM_PMEM_AEC_AWB:
-	case MSM_PMEM_AF:
-		spin_lock_irqsave(&sync->pmem_stats_spinlock, flags);
-		hlist_for_each_entry_safe(region, node, n,
-			&sync->pmem_stats, list) {
-
-			if (pinfo->type == region->info.type &&
-					pinfo->vaddr == region->info.vaddr &&
-					pinfo->fd == region->info.fd) {
-				hlist_del(node);
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-				ion_free(client_for_ion, region->handle);
-#endif
-				kfree(region);
-				CDBG("%s: type %d, vaddr  0x%p\n",
-					__func__, pinfo->type, pinfo->vaddr);
-			}
-		}
-		spin_unlock_irqrestore(&sync->pmem_stats_spinlock, flags);
-		break;
-
-	default:
-		rc = -EINVAL;
-		break;
-	}
-
-	return rc;
-}
-
-static int msm_pmem_table_del(struct msm_sync *sync, void __user *arg)
-{
-	struct msm_pmem_info info;
-
-	if (copy_from_user(&info, arg, sizeof(info))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-
-	return __msm_pmem_table_del(sync, &info);
-}
-
-static int __msm_get_frame(struct msm_sync *sync,
-		struct msm_frame *frame)
-{
-	int rc = 0;
-
-	struct msm_pmem_info pmem_info;
-	struct msm_queue_cmd *qcmd = NULL;
-	struct msm_vfe_resp *vdata;
-	struct msm_vfe_phy_info *pphy;
-
-	qcmd = msm_dequeue(&sync->frame_q, list_frame);
-
-	if (!qcmd) {
-		pr_err("%s: no preview frame.\n", __func__);
-		return -EAGAIN;
-	}
-
-	if ((!qcmd->command) && (qcmd->error_code & MSM_CAMERA_ERR_MASK)) {
-		frame->error_code = qcmd->error_code;
-		pr_err("%s: fake frame with camera error code = %d\n",
-			__func__, frame->error_code);
-		goto err;
-	}
-
-	vdata = (struct msm_vfe_resp *)(qcmd->command);
-	pphy = &vdata->phy;
-	CDBG("%s, pphy->p2_phy = 0x%x\n", __func__, pphy->p2_phy);
-
-	rc = msm_pmem_frame_ptov_lookup(sync,
-			pphy->p0_phy,
-			pphy->p1_phy,
-			pphy->p2_phy,
-			&pmem_info,
-			1); /* Clear the active flag */
-
-	if (rc < 0) {
-		pr_err("%s: cannot get frame, invalid lookup address"
-		"plane0 add %x plane1 add %x plane2 add%x\n",
-		__func__,
-		pphy->p0_phy,
-		pphy->p1_phy,
-		pphy->p2_phy);
-		goto err;
-	}
-
-	frame->ts = qcmd->ts;
-	frame->buffer = (unsigned long)pmem_info.vaddr;
-	frame->planar0_off = pmem_info.planar0_off;
-	frame->planar1_off = pmem_info.planar1_off;
-	frame->planar2_off = pmem_info.planar2_off;
-	frame->fd = pmem_info.fd;
-	frame->path = vdata->phy.output_id;
-	frame->frame_id = vdata->phy.frame_id;
-	CDBG("%s: plane0 %x, plane1 %x, plane2 %x,qcmd %x, virt_addr %x\n",
-		__func__, pphy->p0_phy, pphy->p1_phy, pphy->p2_phy,
-		(int) qcmd, (int) frame->buffer);
-
-err:
-	free_qcmd(qcmd);
-	return rc;
-}
-
-static int msm_get_frame(struct msm_sync *sync, void __user *arg)
-{
-	int rc = 0;
-	struct msm_frame frame;
-
-	if (copy_from_user(&frame,
-				arg,
-				sizeof(struct msm_frame))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-
-	rc = __msm_get_frame(sync, &frame);
-	if (rc < 0)
-		return rc;
-
-	mutex_lock(&sync->lock);
-	if (sync->croplen && (!sync->stereocam_enabled)) {
-		if (frame.croplen != sync->croplen) {
-			pr_err("%s: invalid frame croplen %d,"
-				"expecting %d\n",
-				__func__,
-				frame.croplen,
-				sync->croplen);
-			mutex_unlock(&sync->lock);
-			return -EINVAL;
-		}
-
-		if (copy_to_user((void *)frame.cropinfo,
-				sync->cropinfo,
-				sync->croplen)) {
-			ERR_COPY_TO_USER();
-			mutex_unlock(&sync->lock);
-			return -EFAULT;
-		}
-	}
-
-	if (sync->fdroiinfo.info) {
-		if (copy_to_user((void *)frame.roi_info.info,
-			sync->fdroiinfo.info,
-			sync->fdroiinfo.info_len)) {
-			ERR_COPY_TO_USER();
-			mutex_unlock(&sync->lock);
-			return -EFAULT;
-		}
-	}
-
-	if (sync->stereocam_enabled) {
-		frame.stcam_conv_value = sync->stcam_conv_value;
-		frame.stcam_quality_ind = sync->stcam_quality_ind;
-	}
-
-	if (copy_to_user((void *)arg,
-				&frame, sizeof(struct msm_frame))) {
-		ERR_COPY_TO_USER();
-		rc = -EFAULT;
-	}
-
-	mutex_unlock(&sync->lock);
-	CDBG("%s: got frame\n", __func__);
-
-	return rc;
-}
-
-static int msm_enable_vfe(struct msm_sync *sync, void __user *arg)
-{
-	int rc = -EIO;
-	struct camera_enable_cmd cfg;
-
-	if (copy_from_user(&cfg,
-			arg,
-			sizeof(struct camera_enable_cmd))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-
-	if (sync->vfefn.vfe_enable)
-		rc = sync->vfefn.vfe_enable(&cfg);
-
-	return rc;
-}
-
-static int msm_disable_vfe(struct msm_sync *sync, void __user *arg)
-{
-	int rc = -EIO;
-	struct camera_enable_cmd cfg;
-
-	if (copy_from_user(&cfg,
-			arg,
-			sizeof(struct camera_enable_cmd))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-
-	if (sync->vfefn.vfe_disable)
-		rc = sync->vfefn.vfe_disable(&cfg, NULL);
-
-	return rc;
-}
-
-static struct msm_queue_cmd *__msm_control(struct msm_sync *sync,
-		struct msm_device_queue *queue,
-		struct msm_queue_cmd *qcmd,
-		int timeout)
-{
-	int rc;
-
-	CDBG("Inside __msm_control\n");
-	if (sync->event_q.len <= 100 && sync->frame_q.len <= 100) {
-		/* wake up config thread */
-		msm_enqueue(&sync->event_q, &qcmd->list_config);
-	} else {
-		pr_err("%s, Error Queue limit exceeded e_q = %d, f_q = %d\n",
-			__func__, sync->event_q.len, sync->frame_q.len);
-		free_qcmd(qcmd);
-		return NULL;
-	}
-	if (!queue)
-		return NULL;
-
-	/* wait for config status */
-	CDBG("Waiting for config status \n");
-	rc = wait_event_interruptible_timeout(
-			queue->wait,
-			!list_empty_careful(&queue->list),
-			timeout);
-	CDBG("Waiting over for config status\n");
-	if (list_empty_careful(&queue->list)) {
-		if (!rc) {
-			rc = -ETIMEDOUT;
-			pr_err("%s: wait_event error %d\n", __func__, rc);
-			return ERR_PTR(rc);
-		} else if (rc < 0) {
-			pr_err("%s: wait_event error %d\n", __func__, rc);
-			if (msm_delete_entry(&sync->event_q,
-				list_config, qcmd)) {
-				sync->ignore_qcmd = true;
-				sync->ignore_qcmd_type =
-					(int16_t)((struct msm_ctrl_cmd *)
-					(qcmd->command))->type;
-			}
-			return ERR_PTR(rc);
-		}
-	}
-	qcmd = msm_dequeue(queue, list_control);
-	BUG_ON(!qcmd);
-	CDBG("__msm_control done \n");
-	return qcmd;
-}
-
-static struct msm_queue_cmd *__msm_control_nb(struct msm_sync *sync,
-					struct msm_queue_cmd *qcmd_to_copy)
-{
-	/* Since this is a non-blocking command, we cannot use qcmd_to_copy and
-	 * its data, since they are on the stack.  We replicate them on the heap
-	 * and mark them on_heap so that they get freed when the config thread
-	 * dequeues them.
-	 */
-
-	struct msm_ctrl_cmd *udata;
-	struct msm_ctrl_cmd *udata_to_copy = qcmd_to_copy->command;
-
-	struct msm_queue_cmd *qcmd =
-			kmalloc(sizeof(*qcmd_to_copy) +
-				sizeof(*udata_to_copy) +
-				udata_to_copy->length,
-				GFP_KERNEL);
-	if (!qcmd) {
-		pr_err("%s: out of memory\n", __func__);
-		return ERR_PTR(-ENOMEM);
-	}
-	*qcmd = *qcmd_to_copy;
-	udata = qcmd->command = qcmd + 1;
-	memcpy(udata, udata_to_copy, sizeof(*udata));
-	udata->value = udata + 1;
-	memcpy(udata->value, udata_to_copy->value, udata_to_copy->length);
-
-	atomic_set(&qcmd->on_heap, 1);
-
-	/* qcmd_resp will be set to NULL */
-	return __msm_control(sync, NULL, qcmd, 0);
-}
-
-static int msm_control(struct msm_control_device *ctrl_pmsm,
-			int block,
-			void __user *arg)
-{
-	int rc = 0;
-
-	struct msm_sync *sync = ctrl_pmsm->pmsm->sync;
-	void __user *uptr;
-	struct msm_ctrl_cmd udata_resp;
-	struct msm_queue_cmd *qcmd_resp = NULL;
-	uint8_t data[max_control_command_size];
-	struct msm_ctrl_cmd *udata;
-	struct msm_queue_cmd *qcmd =
-		kmalloc(sizeof(struct msm_queue_cmd) +
-			sizeof(struct msm_ctrl_cmd), GFP_ATOMIC);
-	if (!qcmd) {
-		pr_err("%s: out of memory\n", __func__);
-		return -ENOMEM;
-	}
-	udata = (struct msm_ctrl_cmd *)(qcmd + 1);
-	atomic_set(&(qcmd->on_heap), 1);
-	CDBG("Inside msm_control\n");
-	if (copy_from_user(udata, arg, sizeof(struct msm_ctrl_cmd))) {
-		ERR_COPY_FROM_USER();
-		rc = -EFAULT;
-		goto end;
-	}
-
-	uptr = udata->value;
-	udata->value = data;
-	qcmd->type = MSM_CAM_Q_CTRL;
-	qcmd->command = udata;
-
-	if (udata->length) {
-		if (udata->length > sizeof(data)) {
-			pr_err("%s: user data too large (%d, max is %d)\n",
-					__func__,
-					udata->length,
-					sizeof(data));
-			rc = -EIO;
-			goto end;
-		}
-		if (copy_from_user(udata->value, uptr, udata->length)) {
-			ERR_COPY_FROM_USER();
-			rc = -EFAULT;
-			goto end;
-		}
-	}
-
-	if (unlikely(!block)) {
-		qcmd_resp = __msm_control_nb(sync, qcmd);
-		goto end;
-	}
-	msm_queue_drain(&ctrl_pmsm->ctrl_q, list_control);
-	qcmd_resp = __msm_control(sync,
-				  &ctrl_pmsm->ctrl_q,
-				  qcmd, msecs_to_jiffies(10000));
-
-	/* ownership of qcmd will be transfered to event queue */
-	qcmd = NULL;
-
-	if (!qcmd_resp || IS_ERR(qcmd_resp)) {
-		/* Do not free qcmd_resp here.  If the config thread read it,
-		 * then it has already been freed, and we timed out because
-		 * we did not receive a MSM_CAM_IOCTL_CTRL_CMD_DONE.  If the
-		 * config thread itself is blocked and not dequeueing commands,
-		 * then it will either eventually unblock and process them,
-		 * or when it is killed, qcmd will be freed in
-		 * msm_release_config.
-		 */
-		rc = PTR_ERR(qcmd_resp);
-		qcmd_resp = NULL;
-		goto end;
-	}
-
-	if (qcmd_resp->command) {
-		udata_resp = *(struct msm_ctrl_cmd *)qcmd_resp->command;
-		if (udata_resp.length > 0) {
-			if (copy_to_user(uptr,
-					 udata_resp.value,
-					 udata_resp.length)) {
-				ERR_COPY_TO_USER();
-				rc = -EFAULT;
-				goto end;
-			}
-		}
-		udata_resp.value = uptr;
-
-		if (copy_to_user((void *)arg, &udata_resp,
-				sizeof(struct msm_ctrl_cmd))) {
-			ERR_COPY_TO_USER();
-			rc = -EFAULT;
-			goto end;
-		}
-	}
-
-end:
-	free_qcmd(qcmd);
-	CDBG("%s: done rc = %d\n", __func__, rc);
-	return rc;
-}
-
-/* Divert frames for post-processing by delivering them to the config thread;
- * when post-processing is done, it will return the frame to the frame thread.
- */
-static int msm_divert_frame(struct msm_sync *sync,
-		struct msm_vfe_resp *data,
-		struct msm_stats_event_ctrl *se)
-{
-	struct msm_pmem_info pinfo;
-	struct msm_postproc buf;
-	int rc;
-
-	CDBG("%s: Frame PP sync->pp_mask %d\n", __func__, sync->pp_mask);
-
-	if (!(sync->pp_mask & PP_PREV)  && !(sync->pp_mask & PP_SNAP)) {
-		pr_err("%s: diverting frame, not in PP_PREV or PP_SNAP!\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	rc = msm_pmem_frame_ptov_lookup(sync, data->phy.p0_phy,
-			data->phy.p1_phy, data->phy.p2_phy, &pinfo,
-			0); /* do not clear the active flag */
-
-	if (rc < 0) {
-		pr_err("%s: msm_pmem_frame_ptov_lookup failed\n", __func__);
-		return rc;
-	}
-
-	buf.fmain.buffer = (unsigned long)pinfo.vaddr;
-	buf.fmain.planar0_off = pinfo.planar0_off;
-	buf.fmain.planar1_off = pinfo.planar1_off;
-	buf.fmain.fd = pinfo.fd;
-
-	CDBG("%s: buf 0x%x fd %d\n", __func__, (unsigned int)buf.fmain.buffer,
-		 buf.fmain.fd);
-	if (copy_to_user((void *)(se->stats_event.data),
-			&(buf.fmain), sizeof(struct msm_frame))) {
-		ERR_COPY_TO_USER();
-		return -EFAULT;
-	}
-	return 0;
-}
-
-/* Divert stereo frames for post-processing by delivering
- * them to the config thread.
- */
-static int msm_divert_st_frame(struct msm_sync *sync,
-	struct msm_vfe_resp *data, struct msm_stats_event_ctrl *se, int path)
-{
-	struct msm_pmem_info pinfo;
-	struct msm_st_frame buf;
-	struct video_crop_t *crop = NULL;
-	int rc = 0;
-
-	if (se->stats_event.msg_id == OUTPUT_TYPE_ST_L) {
-		buf.type = OUTPUT_TYPE_ST_L;
-	} else if (se->stats_event.msg_id == OUTPUT_TYPE_ST_R) {
-		buf.type = OUTPUT_TYPE_ST_R;
-	} else {
-		if (se->resptype == MSM_CAM_RESP_STEREO_OP_1) {
-			rc = msm_pmem_frame_ptov_lookup(sync, data->phy.p0_phy,
-				data->phy.p1_phy, data->phy.p2_phy, &pinfo,
-				1);  /* do clear the active flag */
-			buf.buf_info.path = path;
-		} else if (se->resptype == MSM_CAM_RESP_STEREO_OP_2) {
-			rc = msm_pmem_frame_ptov_lookup(sync, data->phy.p0_phy,
-				data->phy.p1_phy, data->phy.p2_phy, &pinfo,
-				0); /* do not clear the active flag */
-			buf.buf_info.path = path;
-		} else
-			CDBG("%s: Invalid resptype = %d\n", __func__,
-				se->resptype);
-
-		if (rc < 0) {
-			CDBG("%s: msm_pmem_frame_ptov_lookup failed\n",
-				__func__);
-			return rc;
-		}
-
-		buf.type = OUTPUT_TYPE_ST_D;
-
-		if (sync->cropinfo != NULL) {
-			crop = sync->cropinfo;
-			switch (path) {
-			case OUTPUT_TYPE_P:
-			case OUTPUT_TYPE_T: {
-				buf.L.stCropInfo.in_w = crop->in1_w;
-				buf.L.stCropInfo.in_h = crop->in1_h;
-				buf.L.stCropInfo.out_w = crop->out1_w;
-				buf.L.stCropInfo.out_h = crop->out1_h;
-				buf.R.stCropInfo = buf.L.stCropInfo;
-				break;
-			}
-
-			case OUTPUT_TYPE_V:
-			case OUTPUT_TYPE_S: {
-				buf.L.stCropInfo.in_w = crop->in2_w;
-				buf.L.stCropInfo.in_h = crop->in2_h;
-				buf.L.stCropInfo.out_w = crop->out2_w;
-				buf.L.stCropInfo.out_h = crop->out2_h;
-				buf.R.stCropInfo = buf.L.stCropInfo;
-				break;
-			}
-			default: {
-				pr_warning("%s: invalid frame path %d\n",
-					__func__, path);
-				break;
-			}
-			}
-		} else {
-			buf.L.stCropInfo.in_w = 0;
-			buf.L.stCropInfo.in_h = 0;
-			buf.L.stCropInfo.out_w = 0;
-			buf.L.stCropInfo.out_h = 0;
-			buf.R.stCropInfo = buf.L.stCropInfo;
-		}
-
-		/* hardcode for now. */
-		if ((path == OUTPUT_TYPE_S) || (path == OUTPUT_TYPE_T))
-			buf.packing = sync->sctrl.s_snap_packing;
-		else
-			buf.packing = sync->sctrl.s_video_packing;
-
-		buf.buf_info.buffer = (unsigned long)pinfo.vaddr;
-		buf.buf_info.phy_offset = pinfo.offset;
-		buf.buf_info.planar0_off = pinfo.planar0_off;
-		buf.buf_info.planar1_off = pinfo.planar1_off;
-		buf.buf_info.planar2_off = pinfo.planar2_off;
-		buf.buf_info.fd = pinfo.fd;
-
-		CDBG("%s: buf 0x%x fd %d\n", __func__,
-			(unsigned int)buf.buf_info.buffer, buf.buf_info.fd);
-	}
-
-	if (copy_to_user((void *)(se->stats_event.data),
-			&buf, sizeof(struct msm_st_frame))) {
-		ERR_COPY_TO_USER();
-		return -EFAULT;
-	}
-	return 0;
-}
-
-static int msm_get_stats(struct msm_sync *sync, void __user *arg)
-{
-	int rc = 0;
-
-	struct msm_stats_event_ctrl se;
-
-	struct msm_queue_cmd *qcmd = NULL;
-	struct msm_ctrl_cmd  *ctrl = NULL;
-	struct msm_vfe_resp  *data = NULL;
-	struct msm_vpe_resp  *vpe_data = NULL;
-	struct msm_stats_buf stats;
-
-	if (copy_from_user(&se, arg,
-			sizeof(struct msm_stats_event_ctrl))) {
-		ERR_COPY_FROM_USER();
-		pr_err("%s, ERR_COPY_FROM_USER\n", __func__);
-		return -EFAULT;
-	}
-
-	rc = 0;
-
-	qcmd = msm_dequeue(&sync->event_q, list_config);
-	if (!qcmd) {
-		/* Should be associated with wait_event
-			error -512 from __msm_control*/
-		pr_err("%s, qcmd is Null\n", __func__);
-		rc = -ETIMEDOUT;
-		return rc;
-	}
-
-	CDBG("%s: received from DSP %d\n", __func__, qcmd->type);
-
-	switch (qcmd->type) {
-	case MSM_CAM_Q_VPE_MSG:
-		/* Complete VPE response. */
-		vpe_data = (struct msm_vpe_resp *)(qcmd->command);
-		se.resptype = MSM_CAM_RESP_STEREO_OP_2;
-		se.stats_event.type   = vpe_data->evt_msg.type;
-		se.stats_event.msg_id = vpe_data->evt_msg.msg_id;
-		se.stats_event.len    = vpe_data->evt_msg.len;
-
-		if (vpe_data->type == VPE_MSG_OUTPUT_ST_L) {
-			CDBG("%s: Change msg_id to OUTPUT_TYPE_ST_L\n",
-				__func__);
-			se.stats_event.msg_id = OUTPUT_TYPE_ST_L;
-			rc = msm_divert_st_frame(sync, data, &se,
-				OUTPUT_TYPE_V);
-		} else if (vpe_data->type == VPE_MSG_OUTPUT_ST_R) {
-			CDBG("%s: Change msg_id to OUTPUT_TYPE_ST_R\n",
-				__func__);
-			se.stats_event.msg_id = OUTPUT_TYPE_ST_R;
-			rc = msm_divert_st_frame(sync, data, &se,
-				OUTPUT_TYPE_V);
-		} else {
-			pr_warning("%s: invalid vpe_data->type = %d\n",
-				__func__, vpe_data->type);
-		}
-		break;
-
-	case MSM_CAM_Q_VFE_EVT:
-	case MSM_CAM_Q_VFE_MSG:
-		data = (struct msm_vfe_resp *)(qcmd->command);
-
-		/* adsp event and message */
-		se.resptype = MSM_CAM_RESP_STAT_EVT_MSG;
-
-		/* 0 - msg from aDSP, 1 - event from mARM */
-		se.stats_event.type   = data->evt_msg.type;
-		se.stats_event.msg_id = data->evt_msg.msg_id;
-		se.stats_event.len    = data->evt_msg.len;
-		se.stats_event.frame_id = data->evt_msg.frame_id;
-
-		CDBG("%s: qcmd->type %d length %d msd_id %d\n", __func__,
-			qcmd->type,
-			se.stats_event.len,
-			se.stats_event.msg_id);
-
-		if (data->type == VFE_MSG_COMMON) {
-			stats.status_bits = data->stats_msg.status_bits;
-			stats.awb_ymin = data->stats_msg.awb_ymin;
-
-			if (data->stats_msg.aec_buff) {
-				stats.aec.buff =
-				msm_pmem_stats_ptov_lookup(sync,
-						data->stats_msg.aec_buff,
-						&(stats.aec.fd));
-				if (!stats.aec.buff) {
-					pr_err("%s: msm_pmem_stats_ptov_lookup error\n",
-						__func__);
-					rc = -EINVAL;
-					goto failure;
-				}
-
-			} else {
-				stats.aec.buff = 0;
-			}
-			if (data->stats_msg.awb_buff) {
-				stats.awb.buff =
-				msm_pmem_stats_ptov_lookup(sync,
-						data->stats_msg.awb_buff,
-						&(stats.awb.fd));
-				if (!stats.awb.buff) {
-					pr_err("%s: msm_pmem_stats_ptov_lookup error\n",
-						__func__);
-					rc = -EINVAL;
-					goto failure;
-				}
-
-			} else {
-				stats.awb.buff = 0;
-			}
-			if (data->stats_msg.af_buff) {
-				stats.af.buff =
-				msm_pmem_stats_ptov_lookup(sync,
-						data->stats_msg.af_buff,
-						&(stats.af.fd));
-				if (!stats.af.buff) {
-					pr_err("%s: msm_pmem_stats_ptov_lookup error\n",
-						__func__);
-					rc = -EINVAL;
-					goto failure;
-				}
-
-			} else {
-				stats.af.buff = 0;
-			}
-			if (data->stats_msg.ihist_buff) {
-				stats.ihist.buff =
-				msm_pmem_stats_ptov_lookup(sync,
-						data->stats_msg.ihist_buff,
-						&(stats.ihist.fd));
-				if (!stats.ihist.buff) {
-					pr_err("%s: msm_pmem_stats_ptov_lookup error\n",
-						__func__);
-					rc = -EINVAL;
-					goto failure;
-				}
-
-			} else {
-				stats.ihist.buff = 0;
-			}
-
-			if (data->stats_msg.rs_buff) {
-				stats.rs.buff =
-				msm_pmem_stats_ptov_lookup(sync,
-						data->stats_msg.rs_buff,
-						&(stats.rs.fd));
-				if (!stats.rs.buff) {
-					pr_err("%s: msm_pmem_stats_ptov_lookup error\n",
-						__func__);
-					rc = -EINVAL;
-					goto failure;
-				}
-
-			} else {
-				stats.rs.buff = 0;
-			}
-
-			if (data->stats_msg.cs_buff) {
-				stats.cs.buff =
-				msm_pmem_stats_ptov_lookup(sync,
-						data->stats_msg.cs_buff,
-						&(stats.cs.fd));
-				if (!stats.cs.buff) {
-					pr_err("%s: msm_pmem_stats_ptov_lookup error\n",
-						__func__);
-					rc = -EINVAL;
-					goto failure;
-				}
-			} else {
-				stats.cs.buff = 0;
-			}
-
-			se.stats_event.frame_id = data->phy.frame_id;
-			if (copy_to_user((void *)(se.stats_event.data),
-					&stats,
-					sizeof(struct msm_stats_buf))) {
-				ERR_COPY_TO_USER();
-				rc = -EFAULT;
-				goto failure;
-			}
-		} else if ((data->type >= VFE_MSG_STATS_AEC) &&
-			(data->type <=  VFE_MSG_STATS_WE)) {
-			/* the check above includes all stats type. */
-			stats.awb_ymin = data->stats_msg.awb_ymin;
-			stats.buffer =
-				msm_pmem_stats_ptov_lookup(sync,
-						data->phy.sbuf_phy,
-						&(stats.fd));
-			if (!stats.buffer) {
-					pr_err("%s: msm_pmem_stats_ptov_lookup error\n",
-						__func__);
-					rc = -EINVAL;
-					goto failure;
-			}
-			se.stats_event.frame_id = data->phy.frame_id;
-			if (copy_to_user((void *)(se.stats_event.data),
-					&stats,
-					sizeof(struct msm_stats_buf))) {
-				ERR_COPY_TO_USER();
-				rc = -EFAULT;
-				goto failure;
-			}
-		} else if ((data->evt_msg.len > 0) &&
-				(data->type == VFE_MSG_GENERAL)) {
-			if (copy_to_user((void *)(se.stats_event.data),
-					data->evt_msg.data,
-					data->evt_msg.len)) {
-				ERR_COPY_TO_USER();
-				rc = -EFAULT;
-				goto failure;
-			}
-		} else {
-			if (sync->stereocam_enabled) {
-				if (data->type == VFE_MSG_OUTPUT_P) {
-					CDBG("%s: Preview mark as st op 1\n",
-						__func__);
-					se.resptype = MSM_CAM_RESP_STEREO_OP_1;
-					rc = msm_divert_st_frame(sync, data,
-						&se, OUTPUT_TYPE_P);
-					break;
-				} else if (data->type == VFE_MSG_OUTPUT_V) {
-					CDBG("%s: Video mark as st op 2\n",
-						__func__);
-					se.resptype = MSM_CAM_RESP_STEREO_OP_2;
-					rc = msm_divert_st_frame(sync, data,
-						&se, OUTPUT_TYPE_V);
-					break;
-				} else if (data->type == VFE_MSG_OUTPUT_S) {
-					CDBG("%s: Main img mark as st op 2\n",
-						__func__);
-					se.resptype = MSM_CAM_RESP_STEREO_OP_2;
-					rc = msm_divert_st_frame(sync, data,
-						&se, OUTPUT_TYPE_S);
-					break;
-				} else if (data->type == VFE_MSG_OUTPUT_T) {
-					CDBG("%s: Thumb img mark as st op 2\n",
-						__func__);
-					se.resptype = MSM_CAM_RESP_STEREO_OP_2;
-					rc = msm_divert_st_frame(sync, data,
-						&se, OUTPUT_TYPE_T);
-					break;
-				} else
-					CDBG("%s: VFE_MSG Fall Through\n",
-						__func__);
-			}
-			if ((sync->pp_frame_avail == 1) &&
-				(sync->pp_mask & PP_PREV) &&
-				(data->type == VFE_MSG_OUTPUT_P)) {
-					CDBG("%s:%d:preiew PP\n",
-					__func__, __LINE__);
-					se.stats_event.frame_id =
-							data->phy.frame_id;
-					rc = msm_divert_frame(sync, data, &se);
-					sync->pp_frame_avail = 0;
-			} else {
-				if ((sync->pp_mask & PP_PREV) &&
-					(data->type == VFE_MSG_OUTPUT_P)) {
-					se.stats_event.frame_id =
-							data->phy.frame_id;
-					free_qcmd(qcmd);
-					return 0;
-				} else
-					CDBG("%s:indication type is %d\n",
-						__func__, data->type);
-			}
-			if (sync->pp_mask & PP_SNAP)
-				if (data->type == VFE_MSG_OUTPUT_S ||
-					data->type == VFE_MSG_OUTPUT_T)
-					rc = msm_divert_frame(sync, data, &se);
-		}
-		break;
-
-	case MSM_CAM_Q_CTRL:
-		/* control command from control thread */
-		ctrl = (struct msm_ctrl_cmd *)(qcmd->command);
-
-		CDBG("%s: qcmd->type %d length %d\n", __func__,
-			qcmd->type, ctrl->length);
-
-		if (ctrl->length > 0) {
-			if (copy_to_user((void *)(se.ctrl_cmd.value),
-						ctrl->value,
-						ctrl->length)) {
-				ERR_COPY_TO_USER();
-				rc = -EFAULT;
-				goto failure;
-			}
-		}
-
-		se.resptype = MSM_CAM_RESP_CTRL;
-
-		/* what to control */
-		se.ctrl_cmd.type = ctrl->type;
-		se.ctrl_cmd.length = ctrl->length;
-		se.ctrl_cmd.resp_fd = ctrl->resp_fd;
-		break;
-
-	case MSM_CAM_Q_V4L2_REQ:
-		/* control command from v4l2 client */
-		ctrl = (struct msm_ctrl_cmd *)(qcmd->command);
-		if (ctrl->length > 0) {
-			if (copy_to_user((void *)(se.ctrl_cmd.value),
-					ctrl->value, ctrl->length)) {
-				ERR_COPY_TO_USER();
-				rc = -EFAULT;
-				goto failure;
-			}
-		}
-
-		/* 2 tells config thread this is v4l2 request */
-		se.resptype = MSM_CAM_RESP_V4L2;
-
-		/* what to control */
-		se.ctrl_cmd.type   = ctrl->type;
-		se.ctrl_cmd.length = ctrl->length;
-		break;
-
-	default:
-		rc = -EFAULT;
-		goto failure;
-	} /* switch qcmd->type */
-	if (copy_to_user((void *)arg, &se, sizeof(se))) {
-		ERR_COPY_TO_USER();
-		rc = -EFAULT;
-		goto failure;
-	}
-
-failure:
-	free_qcmd(qcmd);
-
-	CDBG("%s: %d\n", __func__, rc);
-	return rc;
-}
-
-static int msm_ctrl_cmd_done(struct msm_control_device *ctrl_pmsm,
-		void __user *arg)
-{
-	void __user *uptr;
-	struct msm_queue_cmd *qcmd = &ctrl_pmsm->qcmd;
-	struct msm_ctrl_cmd *command = &ctrl_pmsm->ctrl;
-
-	if (copy_from_user(command, arg, sizeof(*command))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-
-	atomic_set(&qcmd->on_heap, 0);
-	qcmd->command = command;
-	uptr = command->value;
-
-	if (command->length > 0) {
-		command->value = ctrl_pmsm->ctrl_data;
-		if (command->length > sizeof(ctrl_pmsm->ctrl_data)) {
-			pr_err("%s: user data %d is too big (max %d)\n",
-				__func__, command->length,
-				sizeof(ctrl_pmsm->ctrl_data));
-			return -EINVAL;
-		}
-
-		if (copy_from_user(command->value,
-					uptr,
-					command->length)) {
-			ERR_COPY_FROM_USER();
-			return -EFAULT;
-		}
-	} else
-		command->value = NULL;
-
-	/* Ignore the command if the ctrl cmd has
-	   return back due to signaling */
-	/* Should be associated with wait_event
-	   error -512 from __msm_control*/
-	if (ctrl_pmsm->pmsm->sync->ignore_qcmd == true &&
-	   ctrl_pmsm->pmsm->sync->ignore_qcmd_type == (int16_t)command->type) {
-		ctrl_pmsm->pmsm->sync->ignore_qcmd = false;
-		ctrl_pmsm->pmsm->sync->ignore_qcmd_type = -1;
-	} else /* wake up control thread */
-		msm_enqueue(&ctrl_pmsm->ctrl_q, &qcmd->list_control);
-
-	return 0;
-}
-
-static int msm_config_vpe(struct msm_sync *sync, void __user *arg)
-{
-	struct msm_vpe_cfg_cmd cfgcmd;
-	if (copy_from_user(&cfgcmd, arg, sizeof(cfgcmd))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-	CDBG("%s: cmd_type %s\n", __func__, vfe_config_cmd[cfgcmd.cmd_type]);
-	switch (cfgcmd.cmd_type) {
-	case CMD_VPE:
-		return sync->vpefn.vpe_config(&cfgcmd, NULL);
-	default:
-		pr_err("%s: unknown command type %d\n",
-			__func__, cfgcmd.cmd_type);
-	}
-	return -EINVAL;
-}
-
-static int msm_config_vfe(struct msm_sync *sync, void __user *arg)
-{
-	struct msm_vfe_cfg_cmd cfgcmd;
-	struct msm_pmem_region region[8];
-	struct axidata axi_data;
-
-	if (!sync->vfefn.vfe_config) {
-		pr_err("%s: no vfe_config!\n", __func__);
-		return -EIO;
-	}
-
-	if (copy_from_user(&cfgcmd, arg, sizeof(cfgcmd))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-
-	memset(&axi_data, 0, sizeof(axi_data));
-	CDBG("%s: cmd_type %s\n", __func__, vfe_config_cmd[cfgcmd.cmd_type]);
-	switch (cfgcmd.cmd_type) {
-	case CMD_STATS_ENABLE:
-		axi_data.bufnum1 =
-			msm_pmem_region_lookup(&sync->pmem_stats,
-				MSM_PMEM_AEC_AWB, &region[0],
-				NUM_STAT_OUTPUT_BUFFERS,
-				&sync->pmem_stats_spinlock);
-		axi_data.bufnum2 =
-			msm_pmem_region_lookup(&sync->pmem_stats,
-				MSM_PMEM_AF, &region[axi_data.bufnum1],
-				NUM_STAT_OUTPUT_BUFFERS,
-				&sync->pmem_stats_spinlock);
-		if (!axi_data.bufnum1 || !axi_data.bufnum2) {
-			pr_err("%s: pmem region lookup error\n", __func__);
-			return -EINVAL;
-		}
-		axi_data.region = &region[0];
-		return sync->vfefn.vfe_config(&cfgcmd, &axi_data);
-	case CMD_STATS_AF_ENABLE:
-		axi_data.bufnum1 =
-			msm_pmem_region_lookup(&sync->pmem_stats,
-				MSM_PMEM_AF, &region[0],
-				NUM_STAT_OUTPUT_BUFFERS,
-				&sync->pmem_stats_spinlock);
-		if (!axi_data.bufnum1) {
-			pr_err("%s %d: pmem region lookup error\n",
-				__func__, __LINE__);
-			return -EINVAL;
-		}
-		axi_data.region = &region[0];
-		return sync->vfefn.vfe_config(&cfgcmd, &axi_data);
-	case CMD_STATS_AEC_AWB_ENABLE:
-		axi_data.bufnum1 =
-			msm_pmem_region_lookup(&sync->pmem_stats,
-				MSM_PMEM_AEC_AWB, &region[0],
-				NUM_STAT_OUTPUT_BUFFERS,
-				&sync->pmem_stats_spinlock);
-		if (!axi_data.bufnum1) {
-			pr_err("%s %d: pmem region lookup error\n",
-				__func__, __LINE__);
-			return -EINVAL;
-		}
-		axi_data.region = &region[0];
-		return sync->vfefn.vfe_config(&cfgcmd, &axi_data);
-	case CMD_STATS_AEC_ENABLE:
-		axi_data.bufnum1 =
-			msm_pmem_region_lookup(&sync->pmem_stats,
-			MSM_PMEM_AEC, &region[0],
-			NUM_STAT_OUTPUT_BUFFERS,
-			&sync->pmem_stats_spinlock);
-		if (!axi_data.bufnum1) {
-			pr_err("%s %d: pmem region lookup error\n",
-				__func__, __LINE__);
-			return -EINVAL;
-		}
-		axi_data.region = &region[0];
-		return sync->vfefn.vfe_config(&cfgcmd, &axi_data);
-	case CMD_STATS_AWB_ENABLE:
-		axi_data.bufnum1 =
-			msm_pmem_region_lookup(&sync->pmem_stats,
-			MSM_PMEM_AWB, &region[0],
-			NUM_STAT_OUTPUT_BUFFERS,
-			&sync->pmem_stats_spinlock);
-		if (!axi_data.bufnum1) {
-			pr_err("%s %d: pmem region lookup error\n",
-				__func__, __LINE__);
-			return -EINVAL;
-		}
-		axi_data.region = &region[0];
-		return sync->vfefn.vfe_config(&cfgcmd, &axi_data);
-
-
-	case CMD_STATS_IHIST_ENABLE:
-		axi_data.bufnum1 =
-			msm_pmem_region_lookup(&sync->pmem_stats,
-			MSM_PMEM_IHIST, &region[0],
-			NUM_STAT_OUTPUT_BUFFERS,
-			&sync->pmem_stats_spinlock);
-		if (!axi_data.bufnum1) {
-			pr_err("%s %d: pmem region lookup error\n",
-				__func__, __LINE__);
-			return -EINVAL;
-		}
-		axi_data.region = &region[0];
-		return sync->vfefn.vfe_config(&cfgcmd, &axi_data);
-
-	case CMD_STATS_RS_ENABLE:
-		axi_data.bufnum1 =
-			msm_pmem_region_lookup(&sync->pmem_stats,
-			MSM_PMEM_RS, &region[0],
-			NUM_STAT_OUTPUT_BUFFERS,
-			&sync->pmem_stats_spinlock);
-		if (!axi_data.bufnum1) {
-			pr_err("%s %d: pmem region lookup error\n",
-				__func__, __LINE__);
-			return -EINVAL;
-		}
-		axi_data.region = &region[0];
-		return sync->vfefn.vfe_config(&cfgcmd, &axi_data);
-
-	case CMD_STATS_CS_ENABLE:
-		axi_data.bufnum1 =
-			msm_pmem_region_lookup(&sync->pmem_stats,
-			MSM_PMEM_CS, &region[0],
-			NUM_STAT_OUTPUT_BUFFERS,
-			&sync->pmem_stats_spinlock);
-		if (!axi_data.bufnum1) {
-			pr_err("%s %d: pmem region lookup error\n",
-				__func__, __LINE__);
-			return -EINVAL;
-		}
-		axi_data.region = &region[0];
-		return sync->vfefn.vfe_config(&cfgcmd, &axi_data);
-
-	case CMD_GENERAL:
-	case CMD_STATS_DISABLE:
-		return sync->vfefn.vfe_config(&cfgcmd, NULL);
-	default:
-		pr_err("%s: unknown command type %d\n",
-			__func__, cfgcmd.cmd_type);
-	}
-
-	return -EINVAL;
-}
-static int msm_vpe_frame_cfg(struct msm_sync *sync,
-				void *cfgcmdin)
-{
-	int rc = -EIO;
-	struct axidata axi_data;
-	void *data = &axi_data;
-	struct msm_pmem_region region[8];
-	int pmem_type;
-
-	struct msm_vpe_cfg_cmd *cfgcmd;
-	cfgcmd = (struct msm_vpe_cfg_cmd *)cfgcmdin;
-
-	memset(&axi_data, 0, sizeof(axi_data));
-	CDBG("In vpe_frame_cfg cfgcmd->cmd_type = %s\n",
-		vfe_config_cmd[cfgcmd->cmd_type]);
-	switch (cfgcmd->cmd_type) {
-	case CMD_AXI_CFG_VPE:
-		pmem_type = MSM_PMEM_VIDEO_VPE;
-		axi_data.bufnum1 =
-			msm_pmem_region_lookup_2(&sync->pmem_frames, pmem_type,
-				&region[0], 8, &sync->pmem_frame_spinlock);
-		CDBG("axi_data.bufnum1 = %d\n", axi_data.bufnum1);
-		if (!axi_data.bufnum1) {
-			pr_err("%s %d: pmem region lookup error\n",
-				__func__, __LINE__);
-			return -EINVAL;
-		}
-		pmem_type = MSM_PMEM_VIDEO;
-		break;
-	case CMD_AXI_CFG_SNAP_THUMB_VPE:
-		CDBG("%s: CMD_AXI_CFG_SNAP_THUMB_VPE", __func__);
-		pmem_type = MSM_PMEM_THUMBNAIL_VPE;
-		axi_data.bufnum1 =
-			msm_pmem_region_lookup(&sync->pmem_frames, pmem_type,
-			&region[0], 8, &sync->pmem_frame_spinlock);
-		if (!axi_data.bufnum1) {
-			pr_err("%s: THUMBNAIL_VPE pmem region lookup error\n",
-				__func__);
-			return -EINVAL;
-		}
-		break;
-	case CMD_AXI_CFG_SNAP_VPE:
-		CDBG("%s: CMD_AXI_CFG_SNAP_VPE", __func__);
-		pmem_type = MSM_PMEM_MAINIMG_VPE;
-		axi_data.bufnum1 =
-			msm_pmem_region_lookup(&sync->pmem_frames, pmem_type,
-				&region[0], 8, &sync->pmem_frame_spinlock);
-		if (!axi_data.bufnum1) {
-			pr_err("%s: MAINIMG_VPE pmem region lookup error\n",
-				__func__);
-			return -EINVAL;
-		}
-		break;
-	default:
-		pr_err("%s: unknown command type %d\n",
-			__func__, cfgcmd->cmd_type);
-		break;
-	}
-	axi_data.region = &region[0];
-	CDBG("out vpe_frame_cfg cfgcmd->cmd_type = %s\n",
-		vfe_config_cmd[cfgcmd->cmd_type]);
-	/* send the AXI configuration command to driver */
-	if (sync->vpefn.vpe_config)
-		rc = sync->vpefn.vpe_config(cfgcmd, data);
-	return rc;
-}
-
-static int msm_frame_axi_cfg(struct msm_sync *sync,
-		struct msm_vfe_cfg_cmd *cfgcmd)
-{
-	int rc = -EIO;
-	struct axidata axi_data;
-	void *data = &axi_data;
-	struct msm_pmem_region region[MAX_PMEM_CFG_BUFFERS];
-	int pmem_type;
-
-	memset(&axi_data, 0, sizeof(axi_data));
-
-	switch (cfgcmd->cmd_type) {
-
-	case CMD_AXI_CFG_PREVIEW:
-		pmem_type = MSM_PMEM_PREVIEW;
-		axi_data.bufnum2 =
-			msm_pmem_region_lookup(&sync->pmem_frames, pmem_type,
-				&region[0], MAX_PMEM_CFG_BUFFERS,
-				&sync->pmem_frame_spinlock);
-		if (!axi_data.bufnum2) {
-			pr_err("%s %d: pmem region lookup error (empty %d)\n",
-				__func__, __LINE__,
-				hlist_empty(&sync->pmem_frames));
-			return -EINVAL;
-		}
-		break;
-
-	case CMD_AXI_CFG_VIDEO_ALL_CHNLS:
-	case CMD_AXI_CFG_VIDEO:
-		pmem_type = MSM_PMEM_PREVIEW;
-		axi_data.bufnum1 =
-			msm_pmem_region_lookup(&sync->pmem_frames, pmem_type,
-				&region[0], MAX_PMEM_CFG_BUFFERS,
-				&sync->pmem_frame_spinlock);
-		if (!axi_data.bufnum1) {
-			pr_err("%s %d: pmem region lookup error\n",
-				__func__, __LINE__);
-			return -EINVAL;
-		}
-
-		pmem_type = MSM_PMEM_VIDEO;
-		axi_data.bufnum2 =
-			msm_pmem_region_lookup(&sync->pmem_frames, pmem_type,
-				&region[axi_data.bufnum1],
-				(MAX_PMEM_CFG_BUFFERS-(axi_data.bufnum1)),
-				&sync->pmem_frame_spinlock);
-		if (!axi_data.bufnum2) {
-			pr_err("%s %d: pmem region lookup error\n",
-				__func__, __LINE__);
-			return -EINVAL;
-		}
-		break;
-
-	case CMD_AXI_CFG_SNAP:
-		CDBG("%s, CMD_AXI_CFG_SNAP, type=%d\n", __func__,
-			cfgcmd->cmd_type);
-		pmem_type = MSM_PMEM_THUMBNAIL;
-		axi_data.bufnum1 =
-			msm_pmem_region_lookup(&sync->pmem_frames, pmem_type,
-				&region[0], MAX_PMEM_CFG_BUFFERS,
-				&sync->pmem_frame_spinlock);
-		if (!axi_data.bufnum1) {
-			pr_err("%s %d: pmem region lookup error\n",
-				__func__, __LINE__);
-			return -EINVAL;
-		}
-
-		pmem_type = MSM_PMEM_MAINIMG;
-		axi_data.bufnum2 =
-			msm_pmem_region_lookup(&sync->pmem_frames, pmem_type,
-				&region[axi_data.bufnum1],
-				(MAX_PMEM_CFG_BUFFERS-(axi_data.bufnum1)),
-				 &sync->pmem_frame_spinlock);
-		if (!axi_data.bufnum2) {
-			pr_err("%s %d: pmem region lookup error\n",
-				__func__, __LINE__);
-			return -EINVAL;
-		}
-		break;
-
-	case CMD_AXI_CFG_ZSL_ALL_CHNLS:
-	case CMD_AXI_CFG_ZSL:
-		CDBG("%s, CMD_AXI_CFG_ZSL, type = %d\n", __func__,
-			cfgcmd->cmd_type);
-		pmem_type = MSM_PMEM_PREVIEW;
-		axi_data.bufnum1 =
-			msm_pmem_region_lookup(&sync->pmem_frames, pmem_type,
-				&region[0], MAX_PMEM_CFG_BUFFERS,
-				&sync->pmem_frame_spinlock);
-		if (!axi_data.bufnum1) {
-			pr_err("%s %d: pmem region lookup error\n",
-				__func__, __LINE__);
-			return -EINVAL;
-		}
-
-		pmem_type = MSM_PMEM_THUMBNAIL;
-		axi_data.bufnum2 =
-			msm_pmem_region_lookup(&sync->pmem_frames, pmem_type,
-				&region[axi_data.bufnum1],
-				(MAX_PMEM_CFG_BUFFERS-(axi_data.bufnum1)),
-				 &sync->pmem_frame_spinlock);
-		if (!axi_data.bufnum2) {
-			pr_err("%s %d: pmem region lookup error\n",
-				__func__, __LINE__);
-			return -EINVAL;
-		}
-
-		pmem_type = MSM_PMEM_MAINIMG;
-		axi_data.bufnum3 =
-			msm_pmem_region_lookup(&sync->pmem_frames, pmem_type,
-				&region[axi_data.bufnum1 + axi_data.bufnum2],
-				(MAX_PMEM_CFG_BUFFERS - axi_data.bufnum1 -
-				axi_data.bufnum2), &sync->pmem_frame_spinlock);
-		if (!axi_data.bufnum3) {
-			pr_err("%s %d: pmem region lookup error\n",
-				__func__, __LINE__);
-			return -EINVAL;
-		}
-		break;
-
-	case CMD_RAW_PICT_AXI_CFG:
-		pmem_type = MSM_PMEM_RAW_MAINIMG;
-		axi_data.bufnum2 =
-			msm_pmem_region_lookup(&sync->pmem_frames, pmem_type,
-				&region[0], MAX_PMEM_CFG_BUFFERS,
-				&sync->pmem_frame_spinlock);
-		if (!axi_data.bufnum2) {
-			pr_err("%s %d: pmem region lookup error\n",
-				__func__, __LINE__);
-			return -EINVAL;
-		}
-		break;
-
-	case CMD_GENERAL:
-		data = NULL;
-		break;
-
-	default:
-		pr_err("%s: unknown command type %d\n",
-			__func__, cfgcmd->cmd_type);
-		return -EINVAL;
-	}
-
-	axi_data.region = &region[0];
-
-	/* send the AXI configuration command to driver */
-	if (sync->vfefn.vfe_config)
-		rc = sync->vfefn.vfe_config(cfgcmd, data);
-
-	return rc;
-}
-
-static int msm_get_sensor_info(struct msm_sync *sync, void __user *arg)
-{
-	int rc = 0;
-	struct msm_camsensor_info info;
-	struct msm_camera_sensor_info *sdata;
-
-	if (copy_from_user(&info,
-			arg,
-			sizeof(struct msm_camsensor_info))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-
-	sdata = sync->pdev->dev.platform_data;
-	if (sync->sctrl.s_camera_type == BACK_CAMERA_3D)
-		info.support_3d = true;
-	else
-		info.support_3d = false;
-	memcpy(&info.name[0],
-		sdata->sensor_name,
-		MAX_SENSOR_NAME);
-	info.flash_enabled = sdata->flash_data->flash_type !=
-		MSM_CAMERA_FLASH_NONE;
-
-	/* copy back to user space */
-	if (copy_to_user((void *)arg,
-			&info,
-			sizeof(struct msm_camsensor_info))) {
-		ERR_COPY_TO_USER();
-		rc = -EFAULT;
-	}
-
-	return rc;
-}
-
-static int msm_get_camera_info(void __user *arg)
-{
-	int rc = 0;
-	int i = 0;
-	struct msm_camera_info info;
-
-	if (copy_from_user(&info, arg, sizeof(struct msm_camera_info))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-
-	CDBG("%s: camera_node %d\n", __func__, camera_node);
-	info.num_cameras = camera_node;
-
-	for (i = 0; i < camera_node; i++) {
-		info.has_3d_support[i] = 0;
-		info.is_internal_cam[i] = 0;
-		info.s_mount_angle[i] = sensor_mount_angle[i];
-		switch (camera_type[i]) {
-		case FRONT_CAMERA_2D:
-			info.is_internal_cam[i] = 1;
-			break;
-		case BACK_CAMERA_3D:
-			info.has_3d_support[i] = 1;
-			break;
-		case BACK_CAMERA_2D:
-		default:
-			break;
-		}
-	}
-	/* copy back to user space */
-	if (copy_to_user((void *)arg, &info, sizeof(struct msm_camera_info))) {
-		ERR_COPY_TO_USER();
-		rc = -EFAULT;
-	}
-	return rc;
-}
-
-static int __msm_put_frame_buf(struct msm_sync *sync,
-		struct msm_frame *pb)
-{
-	unsigned long pphy;
-	struct msm_vfe_cfg_cmd cfgcmd;
-
-	int rc = -EIO;
-
-	/* Change the active flag. */
-	pphy = msm_pmem_frame_vtop_lookup(sync,
-		pb->buffer,
-		pb->planar0_off, pb->planar1_off, pb->planar2_off, pb->fd, 1);
-
-	if (pphy != 0) {
-		CDBG("%s: rel: vaddr %lx, paddr %lx\n",
-			__func__,
-			pb->buffer, pphy);
-		cfgcmd.cmd_type = CMD_FRAME_BUF_RELEASE;
-		cfgcmd.value    = (void *)pb;
-		if (sync->vfefn.vfe_config)
-			rc = sync->vfefn.vfe_config(&cfgcmd, &pphy);
-	} else {
-		pr_err("%s: msm_pmem_frame_vtop_lookup failed\n",
-			__func__);
-		rc = -EINVAL;
-	}
-
-	return rc;
-}
-static int __msm_put_pic_buf(struct msm_sync *sync,
-		struct msm_frame *pb)
-{
-	unsigned long pphy;
-	struct msm_vfe_cfg_cmd cfgcmd;
-
-	int rc = -EIO;
-
-	pphy = msm_pmem_frame_vtop_lookup(sync,
-		pb->buffer,
-		pb->planar0_off, pb->planar1_off, pb->planar2_off, pb->fd, 1);
-
-	if (pphy != 0) {
-		CDBG("%s: rel: vaddr %lx, paddr %lx\n",
-			__func__,
-			pb->buffer, pphy);
-		cfgcmd.cmd_type = CMD_SNAP_BUF_RELEASE;
-		cfgcmd.value    = (void *)pb;
-		if (sync->vfefn.vfe_config)
-			rc = sync->vfefn.vfe_config(&cfgcmd, &pphy);
-	} else {
-		pr_err("%s: msm_pmem_frame_vtop_lookup failed\n",
-			__func__);
-		rc = -EINVAL;
-	}
-
-	return rc;
-}
-
-
-static int msm_put_frame_buffer(struct msm_sync *sync, void __user *arg)
-{
-	struct msm_frame buf_t;
-
-	if (copy_from_user(&buf_t,
-				arg,
-				sizeof(struct msm_frame))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-
-	return __msm_put_frame_buf(sync, &buf_t);
-}
-
-
-static int msm_put_pic_buffer(struct msm_sync *sync, void __user *arg)
-{
-	struct msm_frame buf_t;
-
-	if (copy_from_user(&buf_t,
-				arg,
-				sizeof(struct msm_frame))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-
-	return __msm_put_pic_buf(sync, &buf_t);
-}
-
-static int __msm_register_pmem(struct msm_sync *sync,
-		struct msm_pmem_info *pinfo)
-{
-	int rc = 0;
-
-	switch (pinfo->type) {
-	case MSM_PMEM_VIDEO:
-	case MSM_PMEM_PREVIEW:
-	case MSM_PMEM_THUMBNAIL:
-	case MSM_PMEM_MAINIMG:
-	case MSM_PMEM_RAW_MAINIMG:
-	case MSM_PMEM_VIDEO_VPE:
-	case MSM_PMEM_C2D:
-	case MSM_PMEM_MAINIMG_VPE:
-	case MSM_PMEM_THUMBNAIL_VPE:
-		rc = msm_pmem_table_add(&sync->pmem_frames, pinfo,
-			&sync->pmem_frame_spinlock, sync);
-		break;
-
-	case MSM_PMEM_AEC_AWB:
-	case MSM_PMEM_AF:
-	case MSM_PMEM_AEC:
-	case MSM_PMEM_AWB:
-	case MSM_PMEM_RS:
-	case MSM_PMEM_CS:
-	case MSM_PMEM_IHIST:
-	case MSM_PMEM_SKIN:
-
-		rc = msm_pmem_table_add(&sync->pmem_stats, pinfo,
-			 &sync->pmem_stats_spinlock, sync);
-		break;
-
-	default:
-		rc = -EINVAL;
-		break;
-	}
-
-	return rc;
-}
-
-static int msm_register_pmem(struct msm_sync *sync, void __user *arg)
-{
-	struct msm_pmem_info info;
-
-	if (copy_from_user(&info, arg, sizeof(info))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-
-	return __msm_register_pmem(sync, &info);
-}
-
-static int msm_stats_axi_cfg(struct msm_sync *sync,
-		struct msm_vfe_cfg_cmd *cfgcmd)
-{
-	int rc = -EIO;
-	struct axidata axi_data;
-	void *data = &axi_data;
-
-	struct msm_pmem_region region[3];
-	int pmem_type = MSM_PMEM_MAX;
-
-	memset(&axi_data, 0, sizeof(axi_data));
-
-	switch (cfgcmd->cmd_type) {
-	case CMD_STATS_AXI_CFG:
-		pmem_type = MSM_PMEM_AEC_AWB;
-		break;
-	case CMD_STATS_AF_AXI_CFG:
-		pmem_type = MSM_PMEM_AF;
-		break;
-	case CMD_GENERAL:
-		data = NULL;
-		break;
-	default:
-		pr_err("%s: unknown command type %d\n",
-			__func__, cfgcmd->cmd_type);
-		return -EINVAL;
-	}
-
-	if (cfgcmd->cmd_type != CMD_GENERAL) {
-		axi_data.bufnum1 =
-			msm_pmem_region_lookup(&sync->pmem_stats, pmem_type,
-				&region[0], NUM_STAT_OUTPUT_BUFFERS,
-				&sync->pmem_stats_spinlock);
-		if (!axi_data.bufnum1) {
-			pr_err("%s %d: pmem region lookup error\n",
-				__func__, __LINE__);
-			return -EINVAL;
-		}
-	axi_data.region = &region[0];
-	}
-
-	/* send the AEC/AWB STATS configuration command to driver */
-	if (sync->vfefn.vfe_config)
-		rc = sync->vfefn.vfe_config(cfgcmd, &axi_data);
-
-	return rc;
-}
-
-static int msm_put_stats_buffer(struct msm_sync *sync, void __user *arg)
-{
-	int rc = -EIO;
-
-	struct msm_stats_buf buf;
-	unsigned long pphy;
-	struct msm_vfe_cfg_cmd cfgcmd;
-
-	if (copy_from_user(&buf, arg,
-				sizeof(struct msm_stats_buf))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-
-	CDBG("%s\n", __func__);
-	pphy = msm_pmem_stats_vtop_lookup(sync, buf.buffer, buf.fd);
-
-	if (pphy != 0) {
-		if (buf.type == STAT_AEAW)
-			cfgcmd.cmd_type = CMD_STATS_BUF_RELEASE;
-		else if (buf.type == STAT_AF)
-			cfgcmd.cmd_type = CMD_STATS_AF_BUF_RELEASE;
-		else if (buf.type == STAT_AEC)
-			cfgcmd.cmd_type = CMD_STATS_AEC_BUF_RELEASE;
-		else if (buf.type == STAT_AWB)
-			cfgcmd.cmd_type = CMD_STATS_AWB_BUF_RELEASE;
-		else if (buf.type == STAT_IHIST)
-			cfgcmd.cmd_type = CMD_STATS_IHIST_BUF_RELEASE;
-		else if (buf.type == STAT_RS)
-			cfgcmd.cmd_type = CMD_STATS_RS_BUF_RELEASE;
-		else if (buf.type == STAT_CS)
-			cfgcmd.cmd_type = CMD_STATS_CS_BUF_RELEASE;
-
-		else {
-			pr_err("%s: invalid buf type %d\n",
-				__func__,
-				buf.type);
-			rc = -EINVAL;
-			goto put_done;
-		}
-
-		cfgcmd.value = (void *)&buf;
-
-		if (sync->vfefn.vfe_config) {
-			rc = sync->vfefn.vfe_config(&cfgcmd, &pphy);
-			if (rc < 0)
-				pr_err("%s: vfe_config error %d\n",
-					__func__, rc);
-		} else
-			pr_err("%s: vfe_config is NULL\n", __func__);
-	} else {
-		pr_err("%s: NULL physical address\n", __func__);
-		rc = -EINVAL;
-	}
-
-put_done:
-	return rc;
-}
-
-static int msm_axi_config(struct msm_sync *sync, void __user *arg)
-{
-	struct msm_vfe_cfg_cmd cfgcmd;
-
-	if (copy_from_user(&cfgcmd, arg, sizeof(cfgcmd))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-
-	switch (cfgcmd.cmd_type) {
-	case CMD_AXI_CFG_VIDEO:
-	case CMD_AXI_CFG_PREVIEW:
-	case CMD_AXI_CFG_SNAP:
-	case CMD_RAW_PICT_AXI_CFG:
-	case CMD_AXI_CFG_ZSL:
-	case CMD_AXI_CFG_VIDEO_ALL_CHNLS:
-	case CMD_AXI_CFG_ZSL_ALL_CHNLS:
-		CDBG("%s, cfgcmd.cmd_type = %d\n", __func__, cfgcmd.cmd_type);
-		return msm_frame_axi_cfg(sync, &cfgcmd);
-
-	case CMD_AXI_CFG_VPE:
-	case CMD_AXI_CFG_SNAP_VPE:
-	case CMD_AXI_CFG_SNAP_THUMB_VPE:
-		return msm_vpe_frame_cfg(sync, (void *)&cfgcmd);
-
-	case CMD_STATS_AXI_CFG:
-	case CMD_STATS_AF_AXI_CFG:
-		return msm_stats_axi_cfg(sync, &cfgcmd);
-
-	default:
-		pr_err("%s: unknown command type %d\n",
-			__func__,
-			cfgcmd.cmd_type);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-static int __msm_get_pic(struct msm_sync *sync,
-		struct msm_frame *frame)
-{
-
-	int rc = 0;
-	struct msm_queue_cmd *qcmd = NULL;
-	struct msm_vfe_resp *vdata;
-	struct msm_vfe_phy_info *pphy;
-	struct msm_pmem_info pmem_info;
-	struct msm_frame *pframe;
-
-	qcmd = msm_dequeue(&sync->pict_q, list_pict);
-
-	if (!qcmd) {
-		pr_err("%s: no pic frame.\n", __func__);
-		return -EAGAIN;
-	}
-
-	if (MSM_CAM_Q_PP_MSG != qcmd->type) {
-		vdata = (struct msm_vfe_resp *)(qcmd->command);
-		pphy = &vdata->phy;
-
-		rc = msm_pmem_frame_ptov_lookup2(sync,
-				pphy->p0_phy,
-				&pmem_info,
-				1); /* mark pic frame in use */
-
-		if (rc < 0) {
-			pr_err("%s: cannot get pic frame, invalid lookup"
-				" address p0_phy add  %x p1_phy add%x\n",
-				__func__, pphy->p0_phy, pphy->p1_phy);
-			goto err;
-		}
-
-		frame->ts = qcmd->ts;
-		frame->buffer = (unsigned long)pmem_info.vaddr;
-		frame->planar0_off = pmem_info.planar0_off;
-		frame->planar1_off = pmem_info.planar1_off;
-		frame->fd = pmem_info.fd;
-		if (sync->stereocam_enabled &&
-			sync->stereo_state != STEREO_RAW_SNAP_STARTED) {
-			if (pmem_info.type == MSM_PMEM_THUMBNAIL_VPE)
-				frame->path = OUTPUT_TYPE_T;
-			else
-				frame->path = OUTPUT_TYPE_S;
-		} else
-			frame->path = vdata->phy.output_id;
-
-		CDBG("%s:p0_phy add %x, p0_phy add %x, qcmd %x, virt_addr %x\n",
-			__func__, pphy->p0_phy,
-			pphy->p1_phy, (int) qcmd, (int) frame->buffer);
-	} else { /* PP */
-		pframe = (struct msm_frame *)(qcmd->command);
-		frame->ts = qcmd->ts;
-		frame->buffer = pframe->buffer;
-		frame->planar0_off = pframe->planar0_off;
-		frame->planar1_off = pframe->planar1_off;
-		frame->fd = pframe->fd;
-		frame->path = pframe->path;
-		CDBG("%s: PP y_off %x, cbcr_off %x, path %d vaddr 0x%x\n",
-		__func__, frame->planar0_off, frame->planar1_off, frame->path,
-		(int) frame->buffer);
-	}
-
-err:
-	free_qcmd(qcmd);
-
-	return rc;
-}
-
-static int msm_get_pic(struct msm_sync *sync, void __user *arg)
-{
-	int rc = 0;
-	struct msm_frame frame;
-
-	if (copy_from_user(&frame,
-				arg,
-				sizeof(struct msm_frame))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-
-	rc = __msm_get_pic(sync, &frame);
-	if (rc < 0)
-		return rc;
-
-	if (sync->croplen && (!sync->stereocam_enabled)) {
-		if (frame.croplen != sync->croplen) {
-			pr_err("%s: invalid frame croplen %d,"
-				"expecting %d\n",
-				__func__,
-				frame.croplen,
-				sync->croplen);
-			return -EINVAL;
-		}
-
-		if (copy_to_user((void *)frame.cropinfo,
-				sync->cropinfo,
-				sync->croplen)) {
-			ERR_COPY_TO_USER();
-			return -EFAULT;
-		}
-	}
-	CDBG("%s: copy snapshot frame to user\n", __func__);
-	if (copy_to_user((void *)arg,
-				&frame, sizeof(struct msm_frame))) {
-		ERR_COPY_TO_USER();
-		rc = -EFAULT;
-	}
-
-	CDBG("%s: got pic frame\n", __func__);
-
-	return rc;
-}
-
-static int msm_set_crop(struct msm_sync *sync, void __user *arg)
-{
-	struct crop_info crop;
-
-	mutex_lock(&sync->lock);
-	if (copy_from_user(&crop,
-				arg,
-				sizeof(struct crop_info))) {
-		ERR_COPY_FROM_USER();
-		mutex_unlock(&sync->lock);
-		return -EFAULT;
-	}
-
-	if (crop.len != CROP_LEN) {
-		mutex_unlock(&sync->lock);
-		return -EINVAL;
-	}
-
-	if (!sync->croplen) {
-		sync->cropinfo = kmalloc(crop.len, GFP_KERNEL);
-		if (!sync->cropinfo) {
-			mutex_unlock(&sync->lock);
-			return -ENOMEM;
-		}
-	}
-
-	if (copy_from_user(sync->cropinfo,
-				crop.info,
-				crop.len)) {
-		ERR_COPY_FROM_USER();
-		sync->croplen = 0;
-		kfree(sync->cropinfo);
-		mutex_unlock(&sync->lock);
-		return -EFAULT;
-	}
-
-	sync->croplen = crop.len;
-
-	mutex_unlock(&sync->lock);
-	return 0;
-}
-
-static int msm_error_config(struct msm_sync *sync, void __user *arg)
-{
-	struct msm_queue_cmd *qcmd =
-		kmalloc(sizeof(struct msm_queue_cmd), GFP_KERNEL);
-
-	qcmd->command = NULL;
-
-	if (qcmd)
-		atomic_set(&(qcmd->on_heap), 1);
-
-	if (copy_from_user(&(qcmd->error_code), arg, sizeof(uint32_t))) {
-		ERR_COPY_FROM_USER();
-		free_qcmd(qcmd);
-		return -EFAULT;
-	}
-
-	pr_err("%s: Enqueue Fake Frame with error code = %d\n", __func__,
-		qcmd->error_code);
-	msm_enqueue(&sync->frame_q, &qcmd->list_frame);
-	return 0;
-}
-
-static int msm_set_fd_roi(struct msm_sync *sync, void __user *arg)
-{
-	struct fd_roi_info fd_roi;
-
-	mutex_lock(&sync->lock);
-	if (copy_from_user(&fd_roi,
-			arg,
-			sizeof(struct fd_roi_info))) {
-		ERR_COPY_FROM_USER();
-		mutex_unlock(&sync->lock);
-		return -EFAULT;
-	}
-	if (fd_roi.info_len <= 0) {
-		mutex_unlock(&sync->lock);
-		return -EFAULT;
-	}
-
-	if (!sync->fdroiinfo.info) {
-		sync->fdroiinfo.info = kmalloc(fd_roi.info_len, GFP_KERNEL);
-		if (!sync->fdroiinfo.info) {
-			mutex_unlock(&sync->lock);
-			return -ENOMEM;
-		}
-		sync->fdroiinfo.info_len = fd_roi.info_len;
-	} else if (sync->fdroiinfo.info_len < fd_roi.info_len) {
-		mutex_unlock(&sync->lock);
-		return -EINVAL;
-    }
-
-	if (copy_from_user(sync->fdroiinfo.info,
-			fd_roi.info,
-			fd_roi.info_len)) {
-		ERR_COPY_FROM_USER();
-		kfree(sync->fdroiinfo.info);
-		sync->fdroiinfo.info = NULL;
-		mutex_unlock(&sync->lock);
-		return -EFAULT;
-	}
-	mutex_unlock(&sync->lock);
-	return 0;
-}
-
-static int msm_pp_grab(struct msm_sync *sync, void __user *arg)
-{
-	uint32_t enable;
-	if (copy_from_user(&enable, arg, sizeof(enable))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	} else {
-		enable &= PP_MASK;
-		if (enable & (enable - 1)) {
-			CDBG("%s: more than one PP request!\n",
-				__func__);
-		}
-		if (sync->pp_mask) {
-			if (enable) {
-				CDBG("%s: postproc %x is already enabled\n",
-					__func__, sync->pp_mask & enable);
-			} else {
-				sync->pp_mask &= enable;
-				CDBG("%s: sync->pp_mask %d enable %d\n",
-					__func__, sync->pp_mask, enable);
-			}
-		}
-
-		CDBG("%s: sync->pp_mask %d enable %d\n", __func__,
-			sync->pp_mask, enable);
-		sync->pp_mask |= enable;
-	}
-
-	return 0;
-}
-
-static int msm_put_st_frame(struct msm_sync *sync, void __user *arg)
-{
-	unsigned long flags;
-	unsigned long st_pphy;
-	if (sync->stereocam_enabled) {
-		/* Make stereo frame ready for VPE. */
-		struct msm_st_frame stereo_frame_half;
-
-		if (copy_from_user(&stereo_frame_half, arg,
-			sizeof(stereo_frame_half))) {
-			ERR_COPY_FROM_USER();
-			return -EFAULT;
-		}
-
-		if (stereo_frame_half.type == OUTPUT_TYPE_ST_L) {
-			struct msm_vfe_resp *vfe_rp;
-			struct msm_queue_cmd *qcmd;
-
-			spin_lock_irqsave(&pp_stereocam_spinlock, flags);
-			if (!sync->pp_stereocam) {
-				pr_warning("%s: no stereo frame to deliver!\n",
-					__func__);
-				spin_unlock_irqrestore(&pp_stereocam_spinlock,
-					flags);
-				return -EINVAL;
-			}
-			CDBG("%s: delivering left frame to VPE\n", __func__);
-
-			qcmd = sync->pp_stereocam;
-			sync->pp_stereocam = NULL;
-			spin_unlock_irqrestore(&pp_stereocam_spinlock, flags);
-
-			vfe_rp = (struct msm_vfe_resp *)qcmd->command;
-
-			CDBG("%s: Left Py = 0x%x y_off = %d cbcr_off = %d\n",
-				__func__, vfe_rp->phy.p0_phy,
-				stereo_frame_half.L.buf_p0_off,
-				stereo_frame_half.L.buf_p1_off);
-
-			sync->vpefn.vpe_cfg_offset(stereo_frame_half.packing,
-			vfe_rp->phy.p0_phy + stereo_frame_half.L.buf_p0_off,
-			vfe_rp->phy.p1_phy + stereo_frame_half.L.buf_p1_off,
-			&(qcmd->ts), OUTPUT_TYPE_ST_L, stereo_frame_half.L,
-			stereo_frame_half.frame_id);
-
-			free_qcmd(qcmd);
-		} else if (stereo_frame_half.type == OUTPUT_TYPE_ST_R) {
-			CDBG("%s: delivering right frame to VPE\n", __func__);
-			spin_lock_irqsave(&st_frame_spinlock, flags);
-
-			sync->stcam_conv_value =
-				stereo_frame_half.buf_info.stcam_conv_value;
-			sync->stcam_quality_ind =
-				stereo_frame_half.buf_info.stcam_quality_ind;
-
-			st_pphy = msm_pmem_frame_vtop_lookup(sync,
-				stereo_frame_half.buf_info.buffer,
-				stereo_frame_half.buf_info.planar0_off,
-				stereo_frame_half.buf_info.planar1_off,
-				stereo_frame_half.buf_info.planar2_off,
-				stereo_frame_half.buf_info.fd,
-				0); /* Do not change the active flag. */
-
-			sync->vpefn.vpe_cfg_offset(stereo_frame_half.packing,
-				st_pphy + stereo_frame_half.R.buf_p0_off,
-				st_pphy + stereo_frame_half.R.buf_p1_off,
-				NULL, OUTPUT_TYPE_ST_R, stereo_frame_half.R,
-				stereo_frame_half.frame_id);
-
-			spin_unlock_irqrestore(&st_frame_spinlock, flags);
-		} else {
-			CDBG("%s: Invalid Msg\n", __func__);
-		}
-	}
-
-	return 0;
-}
-
-static struct msm_queue_cmd *msm_get_pp_qcmd(struct msm_frame* frame)
-{
-	struct msm_queue_cmd *qcmd =
-		kmalloc(sizeof(struct msm_queue_cmd) +
-			sizeof(struct msm_frame), GFP_ATOMIC);
-	qcmd->command = (struct msm_frame *)(qcmd + 1);
-
-	qcmd->type = MSM_CAM_Q_PP_MSG;
-
-	ktime_get_ts(&(qcmd->ts));
-	memcpy(qcmd->command, frame, sizeof(struct msm_frame));
-	atomic_set(&(qcmd->on_heap), 1);
-	return qcmd;
-}
-
-static int msm_pp_release(struct msm_sync *sync, void __user *arg)
-{
-	unsigned long flags;
-
-	if (!sync->pp_mask) {
-		pr_warning("%s: pp not in progress for\n", __func__);
-		return -EINVAL;
-	}
-	if (sync->pp_mask & PP_PREV) {
-
-
-		spin_lock_irqsave(&pp_prev_spinlock, flags);
-		if (!sync->pp_prev) {
-			pr_err("%s: no preview frame to deliver!\n",
-				__func__);
-			spin_unlock_irqrestore(&pp_prev_spinlock,
-				flags);
-			return -EINVAL;
-		}
-		CDBG("%s: delivering pp_prev\n", __func__);
-
-			if (sync->frame_q.len <= 100 &&
-				sync->event_q.len <= 100) {
-					msm_enqueue(&sync->frame_q,
-						&sync->pp_prev->list_frame);
-			} else {
-				pr_err("%s, Error Queue limit exceeded f_q=%d,\
-					e_q = %d\n",
-					__func__, sync->frame_q.len,
-					sync->event_q.len);
-				free_qcmd(sync->pp_prev);
-				goto done;
-			}
-
-			sync->pp_prev = NULL;
-			spin_unlock_irqrestore(&pp_prev_spinlock, flags);
-		goto done;
-	}
-
-	if ((sync->pp_mask & PP_SNAP) ||
-		(sync->pp_mask & PP_RAW_SNAP)) {
-		struct msm_frame frame;
-		struct msm_queue_cmd *qcmd;
-
-		if (copy_from_user(&frame,
-			arg,
-			sizeof(struct msm_frame))) {
-			ERR_COPY_FROM_USER();
-			return -EFAULT;
-		}
-		qcmd = msm_get_pp_qcmd(&frame);
-		if (!qcmd) {
-			pr_err("%s: no snapshot to deliver!\n", __func__);
-			return -EINVAL;
-		}
-		CDBG("%s: delivering pp snap\n", __func__);
-		msm_enqueue(&sync->pict_q, &qcmd->list_pict);
-	}
-
-done:
-	return 0;
-}
-
-static long msm_ioctl_common(struct msm_cam_device *pmsm,
-		unsigned int cmd,
-		void __user *argp)
-{
-	switch (cmd) {
-	case MSM_CAM_IOCTL_REGISTER_PMEM:
-		CDBG("%s cmd = MSM_CAM_IOCTL_REGISTER_PMEM\n", __func__);
-		return msm_register_pmem(pmsm->sync, argp);
-	case MSM_CAM_IOCTL_UNREGISTER_PMEM:
-		CDBG("%s cmd = MSM_CAM_IOCTL_UNREGISTER_PMEM\n", __func__);
-		return msm_pmem_table_del(pmsm->sync, argp);
-	case MSM_CAM_IOCTL_RELEASE_FRAME_BUFFER:
-		CDBG("%s cmd = MSM_CAM_IOCTL_RELEASE_FRAME_BUFFER\n", __func__);
-		return msm_put_frame_buffer(pmsm->sync, argp);
-		break;
-	default:
-		CDBG("%s cmd invalid\n", __func__);
-		return -EINVAL;
-	}
-}
-
-static long msm_ioctl_config(struct file *filep, unsigned int cmd,
-	unsigned long arg)
-{
-	int rc = -EINVAL;
-	void __user *argp = (void __user *)arg;
-	struct msm_cam_device *pmsm = filep->private_data;
-
-	CDBG("%s: cmd %d\n", __func__, _IOC_NR(cmd));
-
-	switch (cmd) {
-	case MSM_CAM_IOCTL_GET_SENSOR_INFO:
-		rc = msm_get_sensor_info(pmsm->sync, argp);
-		break;
-
-	case MSM_CAM_IOCTL_CONFIG_VFE:
-		/* Coming from config thread for update */
-		rc = msm_config_vfe(pmsm->sync, argp);
-		break;
-
-	case MSM_CAM_IOCTL_CONFIG_VPE:
-		/* Coming from config thread for update */
-		rc = msm_config_vpe(pmsm->sync, argp);
-		break;
-
-	case MSM_CAM_IOCTL_GET_STATS:
-		/* Coming from config thread wait
-		 * for vfe statistics and control requests */
-		rc = msm_get_stats(pmsm->sync, argp);
-		break;
-
-	case MSM_CAM_IOCTL_ENABLE_VFE:
-		/* This request comes from control thread:
-		 * enable either QCAMTASK or VFETASK */
-		rc = msm_enable_vfe(pmsm->sync, argp);
-		break;
-
-	case MSM_CAM_IOCTL_DISABLE_VFE:
-		/* This request comes from control thread:
-		 * disable either QCAMTASK or VFETASK */
-		rc = msm_disable_vfe(pmsm->sync, argp);
-		break;
-
-	case MSM_CAM_IOCTL_VFE_APPS_RESET:
-		msm_camio_vfe_blk_reset();
-		rc = 0;
-		break;
-
-	case MSM_CAM_IOCTL_RELEASE_STATS_BUFFER:
-		rc = msm_put_stats_buffer(pmsm->sync, argp);
-		break;
-
-	case MSM_CAM_IOCTL_AXI_CONFIG:
-	case MSM_CAM_IOCTL_AXI_VPE_CONFIG:
-		rc = msm_axi_config(pmsm->sync, argp);
-		break;
-
-	case MSM_CAM_IOCTL_SET_CROP:
-		rc = msm_set_crop(pmsm->sync, argp);
-		break;
-
-	case MSM_CAM_IOCTL_SET_FD_ROI:
-		rc = msm_set_fd_roi(pmsm->sync, argp);
-		break;
-
-	case MSM_CAM_IOCTL_PICT_PP:
-		/* Grab one preview frame or one snapshot
-		 * frame.
-		 */
-		rc = msm_pp_grab(pmsm->sync, argp);
-		break;
-
-	case MSM_CAM_IOCTL_PICT_PP_DONE:
-		/* Release the preview of snapshot frame
-		 * that was grabbed.
-		 */
-		rc = msm_pp_release(pmsm->sync, argp);
-		break;
-
-	case MSM_CAM_IOCTL_PUT_ST_FRAME:
-		/* Release the left or right frame
-		 * that was sent for stereo processing.
-		 */
-		rc = msm_put_st_frame(pmsm->sync, argp);
-		break;
-
-	case MSM_CAM_IOCTL_SENSOR_IO_CFG:
-		rc = pmsm->sync->sctrl.s_config(argp);
-		break;
-
-	case MSM_CAM_IOCTL_ERROR_CONFIG:
-		rc = msm_error_config(pmsm->sync, argp);
-		break;
-
-	case MSM_CAM_IOCTL_ABORT_CAPTURE: {
-		unsigned long flags = 0;
-		CDBG("get_pic:MSM_CAM_IOCTL_ABORT_CAPTURE\n");
-		spin_lock_irqsave(&pmsm->sync->abort_pict_lock, flags);
-		pmsm->sync->get_pic_abort = 1;
-		spin_unlock_irqrestore(&pmsm->sync->abort_pict_lock, flags);
-		wake_up(&(pmsm->sync->pict_q.wait));
-		rc = 0;
-		break;
-	}
-
-	default:
-		rc = msm_ioctl_common(pmsm, cmd, argp);
-		break;
-	}
-
-	CDBG("%s: cmd %d DONE\n", __func__, _IOC_NR(cmd));
-	return rc;
-}
-
-static int msm_unblock_poll_frame(struct msm_sync *);
-
-static long msm_ioctl_frame(struct file *filep, unsigned int cmd,
-	unsigned long arg)
-{
-	int rc = -EINVAL;
-	void __user *argp = (void __user *)arg;
-	struct msm_cam_device *pmsm = filep->private_data;
-
-
-	switch (cmd) {
-	case MSM_CAM_IOCTL_GETFRAME:
-		/* Coming from frame thread to get frame
-		 * after SELECT is done */
-		rc = msm_get_frame(pmsm->sync, argp);
-		break;
-	case MSM_CAM_IOCTL_RELEASE_FRAME_BUFFER:
-		rc = msm_put_frame_buffer(pmsm->sync, argp);
-		break;
-	case MSM_CAM_IOCTL_UNBLOCK_POLL_FRAME:
-		rc = msm_unblock_poll_frame(pmsm->sync);
-		break;
-	default:
-		break;
-	}
-
-	return rc;
-}
-
-static int msm_unblock_poll_pic(struct msm_sync *sync);
-static long msm_ioctl_pic(struct file *filep, unsigned int cmd,
-	unsigned long arg)
-{
-	int rc = -EINVAL;
-	void __user *argp = (void __user *)arg;
-	struct msm_cam_device *pmsm = filep->private_data;
-
-
-	switch (cmd) {
-	case MSM_CAM_IOCTL_GET_PICTURE:
-		rc = msm_get_pic(pmsm->sync, argp);
-		break;
-	case MSM_CAM_IOCTL_RELEASE_PIC_BUFFER:
-		rc = msm_put_pic_buffer(pmsm->sync, argp);
-		break;
-	case MSM_CAM_IOCTL_UNBLOCK_POLL_PIC_FRAME:
-		rc = msm_unblock_poll_pic(pmsm->sync);
-		break;
-	default:
-		break;
-	}
-
-	return rc;
-}
-
-
-static long msm_ioctl_control(struct file *filep, unsigned int cmd,
-	unsigned long arg)
-{
-	int rc = -EINVAL;
-	void __user *argp = (void __user *)arg;
-	struct msm_control_device *ctrl_pmsm = filep->private_data;
-	struct msm_cam_device *pmsm = ctrl_pmsm->pmsm;
-
-	switch (cmd) {
-	case MSM_CAM_IOCTL_CTRL_COMMAND:
-		/* Coming from control thread, may need to wait for
-		 * command status */
-		CDBG("calling msm_control kernel msm_ioctl_control\n");
-		mutex_lock(&ctrl_cmd_lock);
-		rc = msm_control(ctrl_pmsm, 1, argp);
-		mutex_unlock(&ctrl_cmd_lock);
-		break;
-	case MSM_CAM_IOCTL_CTRL_COMMAND_2:
-		/* Sends a message, returns immediately */
-		rc = msm_control(ctrl_pmsm, 0, argp);
-		break;
-	case MSM_CAM_IOCTL_CTRL_CMD_DONE:
-		/* Config thread calls the control thread to notify it
-		 * of the result of a MSM_CAM_IOCTL_CTRL_COMMAND.
-		 */
-		rc = msm_ctrl_cmd_done(ctrl_pmsm, argp);
-		break;
-	case MSM_CAM_IOCTL_GET_SENSOR_INFO:
-		rc = msm_get_sensor_info(pmsm->sync, argp);
-		break;
-	case MSM_CAM_IOCTL_GET_CAMERA_INFO:
-		rc = msm_get_camera_info(argp);
-		break;
-	default:
-		rc = msm_ioctl_common(pmsm, cmd, argp);
-		break;
-	}
-
-	return rc;
-}
-
-static int __msm_release(struct msm_sync *sync)
-{
-	struct msm_pmem_region *region;
-	struct hlist_node *hnode;
-	struct hlist_node *n;
-
-	mutex_lock(&sync->lock);
-	if (sync->opencnt)
-		sync->opencnt--;
-	pr_info("%s, open count =%d\n", __func__, sync->opencnt);
-	if (!sync->opencnt) {
-		/* need to clean up system resource */
-		pr_info("%s, release VFE\n", __func__);
-		if (sync->core_powered_on) {
-			if (sync->vfefn.vfe_release)
-				sync->vfefn.vfe_release(sync->pdev);
-			/*sensor release */
-			pr_info("%s, release Sensor\n", __func__);
-			sync->sctrl.s_release();
-			CDBG("%s, msm_camio_sensor_clk_off\n", __func__);
-			msm_camio_sensor_clk_off(sync->pdev);
-			if (sync->sfctrl.strobe_flash_release) {
-				CDBG("%s, strobe_flash_release\n", __func__);
-				sync->sfctrl.strobe_flash_release(
-				sync->sdata->strobe_flash_data, 1);
-			}
-		}
-		kfree(sync->cropinfo);
-		sync->cropinfo = NULL;
-		sync->croplen = 0;
-		CDBG("%s, free frame pmem region\n", __func__);
-		hlist_for_each_entry_safe(region, hnode, n,
-				&sync->pmem_frames, list) {
-			hlist_del(hnode);
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-				ion_free(client_for_ion, region->handle);
-#endif
-			kfree(region);
-		}
-		CDBG("%s, free stats pmem region\n", __func__);
-		hlist_for_each_entry_safe(region, hnode, n,
-				&sync->pmem_stats, list) {
-			hlist_del(hnode);
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-				ion_free(client_for_ion, region->handle);
-#endif
-			kfree(region);
-		}
-		msm_queue_drain(&sync->pict_q, list_pict);
-		msm_queue_drain(&sync->event_q, list_config);
-
-		pm_qos_update_request(&sync->idle_pm_qos, PM_QOS_DEFAULT_VALUE);
-		sync->apps_id = NULL;
-		sync->core_powered_on = 0;
-	}
-	mutex_unlock(&sync->lock);
-	ion_client_destroy(client_for_ion);
-
-	return 0;
-}
-
-static int msm_release_config(struct inode *node, struct file *filep)
-{
-	int rc;
-	struct msm_cam_device *pmsm = filep->private_data;
-	pr_info("%s: %s\n", __func__, filep->f_path.dentry->d_name.name);
-	rc = __msm_release(pmsm->sync);
-	if (!rc) {
-		msm_queue_drain(&pmsm->sync->event_q, list_config);
-		atomic_set(&pmsm->opened, 0);
-	}
-	return rc;
-}
-
-static int msm_release_control(struct inode *node, struct file *filep)
-{
-	int rc;
-	struct msm_control_device *ctrl_pmsm = filep->private_data;
-	struct msm_cam_device *pmsm = ctrl_pmsm->pmsm;
-	pr_info("%s: %s\n", __func__, filep->f_path.dentry->d_name.name);
-	g_v4l2_opencnt--;
-	mutex_lock(&pmsm->sync->lock);
-	if (pmsm->sync->core_powered_on && pmsm->sync->vfefn.vfe_stop) {
-		pr_info("%s, stop vfe if active\n", __func__);
-		pmsm->sync->vfefn.vfe_stop();
-	}
-	mutex_unlock(&pmsm->sync->lock);
-	rc = __msm_release(pmsm->sync);
-	if (!rc) {
-		msm_queue_drain(&ctrl_pmsm->ctrl_q, list_control);
-		kfree(ctrl_pmsm);
-	}
-	return rc;
-}
-
-static int msm_release_frame(struct inode *node, struct file *filep)
-{
-	int rc;
-	struct msm_cam_device *pmsm = filep->private_data;
-	pr_info("%s: %s\n", __func__, filep->f_path.dentry->d_name.name);
-	rc = __msm_release(pmsm->sync);
-	if (!rc) {
-		msm_queue_drain(&pmsm->sync->frame_q, list_frame);
-		atomic_set(&pmsm->opened, 0);
-	}
-	return rc;
-}
-
-
-static int msm_release_pic(struct inode *node, struct file *filep)
-{
-	int rc;
-	struct msm_cam_device *pmsm = filep->private_data;
-	CDBG("%s: %s\n", __func__, filep->f_path.dentry->d_name.name);
-	rc = __msm_release(pmsm->sync);
-	if (!rc) {
-		msm_queue_drain(&pmsm->sync->pict_q, list_pict);
-		atomic_set(&pmsm->opened, 0);
-	}
-	return rc;
-}
-
-static int msm_unblock_poll_pic(struct msm_sync *sync)
-{
-	unsigned long flags;
-	CDBG("%s\n", __func__);
-	spin_lock_irqsave(&sync->pict_q.lock, flags);
-	sync->unblock_poll_pic_frame = 1;
-	wake_up(&sync->pict_q.wait);
-	spin_unlock_irqrestore(&sync->pict_q.lock, flags);
-	return 0;
-}
-
-static int msm_unblock_poll_frame(struct msm_sync *sync)
-{
-	unsigned long flags;
-	CDBG("%s\n", __func__);
-	spin_lock_irqsave(&sync->frame_q.lock, flags);
-	sync->unblock_poll_frame = 1;
-	wake_up(&sync->frame_q.wait);
-	spin_unlock_irqrestore(&sync->frame_q.lock, flags);
-	return 0;
-}
-
-static unsigned int __msm_poll_frame(struct msm_sync *sync,
-		struct file *filep,
-		struct poll_table_struct *pll_table)
-{
-	int rc = 0;
-	unsigned long flags;
-
-	poll_wait(filep, &sync->frame_q.wait, pll_table);
-
-	spin_lock_irqsave(&sync->frame_q.lock, flags);
-	if (!list_empty_careful(&sync->frame_q.list))
-		/* frame ready */
-		rc = POLLIN | POLLRDNORM;
-	if (sync->unblock_poll_frame) {
-		CDBG("%s: sync->unblock_poll_frame is true\n", __func__);
-		rc |= POLLPRI;
-		sync->unblock_poll_frame = 0;
-	}
-	spin_unlock_irqrestore(&sync->frame_q.lock, flags);
-
-	return rc;
-}
-
-static unsigned int __msm_poll_pic(struct msm_sync *sync,
-		struct file *filep,
-		struct poll_table_struct *pll_table)
-{
-	int rc = 0;
-	unsigned long flags;
-
-	poll_wait(filep, &sync->pict_q.wait , pll_table);
-	spin_lock_irqsave(&sync->abort_pict_lock, flags);
-	if (sync->get_pic_abort == 1) {
-		/* TODO: need to pass an error case */
-		sync->get_pic_abort = 0;
-	}
-	spin_unlock_irqrestore(&sync->abort_pict_lock, flags);
-
-	spin_lock_irqsave(&sync->pict_q.lock, flags);
-	if (!list_empty_careful(&sync->pict_q.list))
-		/* frame ready */
-		rc = POLLIN | POLLRDNORM;
-	if (sync->unblock_poll_pic_frame) {
-		CDBG("%s: sync->unblock_poll_pic_frame is true\n", __func__);
-		rc |= POLLPRI;
-		sync->unblock_poll_pic_frame = 0;
-	}
-	spin_unlock_irqrestore(&sync->pict_q.lock, flags);
-
-	return rc;
-}
-
-static unsigned int msm_poll_frame(struct file *filep,
-	struct poll_table_struct *pll_table)
-{
-	struct msm_cam_device *pmsm = filep->private_data;
-	return __msm_poll_frame(pmsm->sync, filep, pll_table);
-}
-
-static unsigned int msm_poll_pic(struct file *filep,
-	struct poll_table_struct *pll_table)
-{
-	struct msm_cam_device *pmsm = filep->private_data;
-	return __msm_poll_pic(pmsm->sync, filep, pll_table);
-}
-
-static unsigned int __msm_poll_config(struct msm_sync *sync,
-		struct file *filep,
-		struct poll_table_struct *pll_table)
-{
-	int rc = 0;
-	unsigned long flags;
-
-	poll_wait(filep, &sync->event_q.wait, pll_table);
-
-	spin_lock_irqsave(&sync->event_q.lock, flags);
-	if (!list_empty_careful(&sync->event_q.list))
-		/* event ready */
-		rc = POLLIN | POLLRDNORM;
-	spin_unlock_irqrestore(&sync->event_q.lock, flags);
-
-	return rc;
-}
-
-static unsigned int msm_poll_config(struct file *filep,
-	struct poll_table_struct *pll_table)
-{
-	struct msm_cam_device *pmsm = filep->private_data;
-	return __msm_poll_config(pmsm->sync, filep, pll_table);
-}
-
-/*
- * This function executes in interrupt context.
- */
-
-static void *msm_vfe_sync_alloc(int size,
-			void *syncdata __attribute__((unused)),
-			gfp_t gfp)
-{
-	struct msm_queue_cmd *qcmd =
-		kzalloc(sizeof(struct msm_queue_cmd) + size, gfp);
-	if (qcmd) {
-		atomic_set(&qcmd->on_heap, 1);
-		return qcmd + 1;
-	}
-	return NULL;
-}
-
-static void *msm_vpe_sync_alloc(int size,
-			void *syncdata __attribute__((unused)),
-			gfp_t gfp)
-{
-	struct msm_queue_cmd *qcmd =
-		kzalloc(sizeof(struct msm_queue_cmd) + size, gfp);
-	if (qcmd) {
-		atomic_set(&qcmd->on_heap, 1);
-		return qcmd + 1;
-	}
-	return NULL;
-}
-
-static void msm_vfe_sync_free(void *ptr)
-{
-	if (ptr) {
-		struct msm_queue_cmd *qcmd =
-			(struct msm_queue_cmd *)ptr;
-		qcmd--;
-		if (atomic_read(&qcmd->on_heap))
-			kfree(qcmd);
-	}
-}
-
-static void msm_vpe_sync_free(void *ptr)
-{
-	if (ptr) {
-		struct msm_queue_cmd *qcmd =
-			(struct msm_queue_cmd *)ptr;
-		qcmd--;
-		if (atomic_read(&qcmd->on_heap))
-			kfree(qcmd);
-	}
-}
-
-/*
- * This function executes in interrupt context.
- */
-
-static void msm_vfe_sync(struct msm_vfe_resp *vdata,
-		enum msm_queue qtype, void *syncdata,
-		gfp_t gfp)
-{
-	struct msm_queue_cmd *qcmd = NULL;
-	struct msm_sync *sync = (struct msm_sync *)syncdata;
-	unsigned long flags;
-
-	if (!sync) {
-		pr_err("%s: no context in dsp callback.\n", __func__);
-		return;
-	}
-
-	qcmd = ((struct msm_queue_cmd *)vdata) - 1;
-	qcmd->type = qtype;
-	qcmd->command = vdata;
-
-	ktime_get_ts(&(qcmd->ts));
-
-	if (qtype != MSM_CAM_Q_VFE_MSG)
-		goto vfe_for_config;
-
-	CDBG("%s: vdata->type %d\n", __func__, vdata->type);
-
-	switch (vdata->type) {
-	case VFE_MSG_OUTPUT_P:
-		if (sync->pp_mask & PP_PREV) {
-			CDBG("%s: PP_PREV in progress: p0_add %x p1_add %x\n",
-				__func__,
-				vdata->phy.p0_phy,
-				vdata->phy.p1_phy);
-			spin_lock_irqsave(&pp_prev_spinlock, flags);
-			if (sync->pp_prev)
-				CDBG("%s: overwriting pp_prev!\n",
-					__func__);
-			CDBG("%s: sending preview to config\n", __func__);
-			sync->pp_prev = qcmd;
-			spin_unlock_irqrestore(&pp_prev_spinlock, flags);
-			sync->pp_frame_avail = 1;
-			if (atomic_read(&qcmd->on_heap))
-				atomic_add(1, &qcmd->on_heap);
-			break;
-		}
-		CDBG("%s: msm_enqueue frame_q\n", __func__);
-		if (sync->stereocam_enabled)
-			CDBG("%s: Enqueue VFE_MSG_OUTPUT_P to event_q for "
-				"stereo processing\n", __func__);
-		else {
-			if (sync->frame_q.len <= 100 &&
-				sync->event_q.len <= 100) {
-				if (atomic_read(&qcmd->on_heap))
-					atomic_add(1, &qcmd->on_heap);
-				msm_enqueue(&sync->frame_q, &qcmd->list_frame);
-			} else {
-				pr_err("%s, Error Queue limit exceeded "
-					"f_q = %d, e_q = %d\n",	__func__,
-					sync->frame_q.len, sync->event_q.len);
-				free_qcmd(qcmd);
-				return;
-			}
-		}
-		break;
-
-	case VFE_MSG_OUTPUT_T:
-		if (sync->stereocam_enabled) {
-			spin_lock_irqsave(&pp_stereocam_spinlock, flags);
-
-			/* if out1/2 is currently in progress, save the qcmd
-			and issue only ionce the 1st one completes the 3D
-			pipeline */
-			if (STEREO_SNAP_BUFFER1_PROCESSING ==
-				sync->stereo_state) {
-				sync->pp_stereocam2 = qcmd;
-				spin_unlock_irqrestore(&pp_stereocam_spinlock,
-					flags);
-				if (atomic_read(&qcmd->on_heap))
-					atomic_add(1, &qcmd->on_heap);
-				CDBG("%s: snapshot stereo in progress\n",
-					__func__);
-				return;
-			}
-
-			if (sync->pp_stereocam)
-				CDBG("%s: overwriting pp_stereocam!\n",
-					__func__);
-
-			CDBG("%s: sending stereo frame to config\n", __func__);
-			sync->pp_stereocam = qcmd;
-			sync->stereo_state =
-				STEREO_SNAP_BUFFER1_PROCESSING;
-
-			spin_unlock_irqrestore(&pp_stereocam_spinlock, flags);
-
-			/* Increament on_heap by one because the same qcmd will
-			be used for VPE in msm_pp_release. */
-			if (atomic_read(&qcmd->on_heap))
-				atomic_add(1, &qcmd->on_heap);
-			CDBG("%s: Enqueue VFE_MSG_OUTPUT_T to event_q for "
-				"stereo processing.\n", __func__);
-			break;
-		}
-		if (sync->pp_mask & PP_SNAP) {
-			CDBG("%s: pp sending thumbnail to config\n",
-				__func__);
-		} else {
-			msm_enqueue(&sync->pict_q, &qcmd->list_pict);
-			return;
-		}
-
-	case VFE_MSG_OUTPUT_S:
-		if (sync->stereocam_enabled &&
-			sync->stereo_state != STEREO_RAW_SNAP_STARTED) {
-			spin_lock_irqsave(&pp_stereocam_spinlock, flags);
-
-			/* if out1/2 is currently in progress, save the qcmd
-			and issue only once the 1st one completes the 3D
-			pipeline */
-			if (STEREO_SNAP_BUFFER1_PROCESSING ==
-				sync->stereo_state) {
-				sync->pp_stereocam2 = qcmd;
-				spin_unlock_irqrestore(&pp_stereocam_spinlock,
-					flags);
-				if (atomic_read(&qcmd->on_heap))
-					atomic_add(1, &qcmd->on_heap);
-				CDBG("%s: snapshot stereo in progress\n",
-					__func__);
-				return;
-			}
-			if (sync->pp_stereocam)
-				CDBG("%s: overwriting pp_stereocam!\n",
-					__func__);
-
-			CDBG("%s: sending stereo frame to config\n", __func__);
-			sync->pp_stereocam = qcmd;
-			sync->stereo_state =
-				STEREO_SNAP_BUFFER1_PROCESSING;
-
-			spin_unlock_irqrestore(&pp_stereocam_spinlock, flags);
-
-			/* Increament on_heap by one because the same qcmd will
-			be used for VPE in msm_pp_release. */
-			if (atomic_read(&qcmd->on_heap))
-				atomic_add(1, &qcmd->on_heap);
-			CDBG("%s: Enqueue VFE_MSG_OUTPUT_S to event_q for "
-				"stereo processing.\n", __func__);
-			break;
-		}
-		if (sync->pp_mask & PP_SNAP) {
-			CDBG("%s: pp sending main image to config\n",
-				__func__);
-		} else {
-			CDBG("%s: enqueue to picture queue\n", __func__);
-			msm_enqueue(&sync->pict_q, &qcmd->list_pict);
-			return;
-		}
-		break;
-
-	case VFE_MSG_OUTPUT_V:
-		if (sync->stereocam_enabled) {
-			spin_lock_irqsave(&pp_stereocam_spinlock, flags);
-
-			if (sync->pp_stereocam)
-				CDBG("%s: overwriting pp_stereocam!\n",
-					__func__);
-
-			CDBG("%s: sending stereo frame to config\n", __func__);
-			sync->pp_stereocam = qcmd;
-
-			spin_unlock_irqrestore(&pp_stereocam_spinlock, flags);
-
-			/* Increament on_heap by one because the same qcmd will
-			be used for VPE in msm_pp_release. */
-			if (atomic_read(&qcmd->on_heap))
-				atomic_add(1, &qcmd->on_heap);
-			CDBG("%s: Enqueue VFE_MSG_OUTPUT_V to event_q for "
-				"stereo processing.\n", __func__);
-			break;
-		}
-		if (sync->vpefn.vpe_cfg_update) {
-			CDBG("dis_en = %d\n", *sync->vpefn.dis);
-			if (*(sync->vpefn.dis)) {
-				memset(&(vdata->vpe_bf), 0,
-					sizeof(vdata->vpe_bf));
-
-				if (sync->cropinfo != NULL)
-					vdata->vpe_bf.vpe_crop =
-				*(struct video_crop_t *)(sync->cropinfo);
-
-				vdata->vpe_bf.p0_phy = vdata->phy.p0_phy;
-				vdata->vpe_bf.p1_phy = vdata->phy.p1_phy;
-				vdata->vpe_bf.ts = (qcmd->ts);
-				vdata->vpe_bf.frame_id = vdata->phy.frame_id;
-				qcmd->command = vdata;
-				msm_enqueue_vpe(&sync->vpe_q,
-					&qcmd->list_vpe_frame);
-				return;
-			} else if (sync->vpefn.vpe_cfg_update(sync->cropinfo)) {
-				CDBG("%s: msm_enqueue video frame to vpe time "
-					"= %ld\n", __func__, qcmd->ts.tv_nsec);
-
-				sync->vpefn.send_frame_to_vpe(
-					vdata->phy.p0_phy,
-					vdata->phy.p1_phy,
-					&(qcmd->ts), OUTPUT_TYPE_V);
-
-				free_qcmd(qcmd);
-				return;
-			} else {
-				CDBG("%s: msm_enqueue video frame_q\n",
-					__func__);
-				if (sync->liveshot_enabled) {
-					CDBG("%s: msm_enqueue liveshot\n",
-						__func__);
-					vdata->phy.output_id |= OUTPUT_TYPE_L;
-					sync->liveshot_enabled = false;
-				}
-				if (sync->frame_q.len <= 100 &&
-					sync->event_q.len <= 100) {
-						msm_enqueue(&sync->frame_q,
-							&qcmd->list_frame);
-				} else {
-					pr_err("%s, Error Queue limit exceeded\
-						f_q = %d, e_q = %d\n",
-						__func__, sync->frame_q.len,
-						sync->event_q.len);
-					free_qcmd(qcmd);
-				}
-
-				return;
-			}
-		} else {
-			CDBG("%s: msm_enqueue video frame_q\n",	__func__);
-			if (sync->frame_q.len <= 100 &&
-				sync->event_q.len <= 100) {
-				msm_enqueue(&sync->frame_q, &qcmd->list_frame);
-			} else {
-				pr_err("%s, Error Queue limit exceeded\
-					f_q = %d, e_q = %d\n",
-					__func__, sync->frame_q.len,
-					sync->event_q.len);
-				free_qcmd(qcmd);
-			}
-
-			return;
-		}
-
-	case VFE_MSG_SNAPSHOT:
-		if (sync->pp_mask & (PP_SNAP | PP_RAW_SNAP)) {
-			CDBG("%s: PP_SNAP in progress: pp_mask %x\n",
-				__func__, sync->pp_mask);
-		} else {
-			if (atomic_read(&qcmd->on_heap))
-				atomic_add(1, &qcmd->on_heap);
-			CDBG("%s: VFE_MSG_SNAPSHOT store\n",
-				__func__);
-			if (sync->stereocam_enabled &&
-				sync->stereo_state != STEREO_RAW_SNAP_STARTED) {
-				sync->pp_stereosnap = qcmd;
-				return;
-			}
-		}
-		break;
-
-	case VFE_MSG_COMMON:
-		CDBG("%s: qtype %d, comp stats, enqueue event_q.\n",
-			__func__, vdata->type);
-		break;
-
-	case VFE_MSG_GENERAL:
-		CDBG("%s: qtype %d, general msg, enqueue event_q.\n",
-			__func__, vdata->type);
-		break;
-
-	default:
-		CDBG("%s: qtype %d not handled\n", __func__, vdata->type);
-		/* fall through, send to config. */
-	}
-
-vfe_for_config:
-	CDBG("%s: msm_enqueue event_q\n", __func__);
-	if (sync->frame_q.len <= 100 && sync->event_q.len <= 100) {
-		msm_enqueue(&sync->event_q, &qcmd->list_config);
-	} else if (sync->event_q.len > 100) {
-		pr_err("%s, Error Event Queue limit exceeded f_q = %d, e_q = %d\n",
-			__func__, sync->frame_q.len, sync->event_q.len);
-		qcmd->error_code = 0xffffffff;
-		qcmd->command = NULL;
-		msm_enqueue(&sync->frame_q, &qcmd->list_frame);
-	} else {
-		pr_err("%s, Error Queue limit exceeded f_q = %d, e_q = %d\n",
-			__func__, sync->frame_q.len, sync->event_q.len);
-		free_qcmd(qcmd);
-	}
-
-}
-
-static void msm_vpe_sync(struct msm_vpe_resp *vdata,
-	enum msm_queue qtype, void *syncdata, void *ts, gfp_t gfp)
-{
-	struct msm_queue_cmd *qcmd = NULL;
-	unsigned long flags;
-
-	struct msm_sync *sync = (struct msm_sync *)syncdata;
-	if (!sync) {
-		pr_err("%s: no context in dsp callback.\n", __func__);
-		return;
-	}
-
-	qcmd = ((struct msm_queue_cmd *)vdata) - 1;
-	qcmd->type = qtype;
-	qcmd->command = vdata;
-	qcmd->ts = *((struct timespec *)ts);
-
-	if (qtype != MSM_CAM_Q_VPE_MSG) {
-		pr_err("%s: Invalid qcmd type = %d.\n", __func__, qcmd->type);
-		free_qcmd(qcmd);
-		return;
-	}
-
-	CDBG("%s: vdata->type %d\n", __func__, vdata->type);
-	switch (vdata->type) {
-	case VPE_MSG_OUTPUT_V:
-		if (sync->liveshot_enabled) {
-			CDBG("%s: msm_enqueue liveshot %d\n", __func__,
-				sync->liveshot_enabled);
-			vdata->phy.output_id |= OUTPUT_TYPE_L;
-			sync->liveshot_enabled = false;
-		}
-		vdata->phy.p2_phy = vdata->phy.p0_phy;
-		if (sync->frame_q.len <= 100 && sync->event_q.len <= 100) {
-			CDBG("%s: enqueue to frame_q from VPE\n", __func__);
-			msm_enqueue(&sync->frame_q, &qcmd->list_frame);
-		} else {
-			pr_err("%s, Error Queue limit exceeded f_q = %d, "
-				"e_q = %d\n", __func__, sync->frame_q.len,
-				sync->event_q.len);
-			free_qcmd(qcmd);
-		}
-		return;
-
-	case VPE_MSG_OUTPUT_ST_L:
-		CDBG("%s: enqueue left frame done msg to event_q from VPE\n",
-			__func__);
-		msm_enqueue(&sync->event_q, &qcmd->list_config);
-		return;
-
-	case VPE_MSG_OUTPUT_ST_R:
-		spin_lock_irqsave(&pp_stereocam_spinlock, flags);
-		CDBG("%s: received VPE_MSG_OUTPUT_ST_R state %d\n", __func__,
-			sync->stereo_state);
-
-		if (STEREO_SNAP_BUFFER1_PROCESSING == sync->stereo_state) {
-			msm_enqueue(&sync->pict_q, &qcmd->list_pict);
-			qcmd = sync->pp_stereocam2;
-			sync->pp_stereocam = sync->pp_stereocam2;
-			sync->pp_stereocam2 = NULL;
-			msm_enqueue(&sync->event_q, &qcmd->list_config);
-			sync->stereo_state =
-				STEREO_SNAP_BUFFER2_PROCESSING;
-		} else if (STEREO_SNAP_BUFFER2_PROCESSING ==
-				sync->stereo_state) {
-			sync->stereo_state = STEREO_SNAP_IDLE;
-			/* Send snapshot DONE */
-			msm_enqueue(&sync->pict_q, &qcmd->list_pict);
-			qcmd = sync->pp_stereosnap;
-			sync->pp_stereosnap = NULL;
-			CDBG("%s: send SNAPSHOT_DONE message\n", __func__);
-			msm_enqueue(&sync->event_q, &qcmd->list_config);
-		} else {
-			if (atomic_read(&qcmd->on_heap))
-				atomic_add(1, &qcmd->on_heap);
-			msm_enqueue(&sync->event_q, &qcmd->list_config);
-			if (sync->stereo_state == STEREO_VIDEO_ACTIVE) {
-				CDBG("%s: st frame to frame_q from VPE\n",
-					__func__);
-				msm_enqueue(&sync->frame_q, &qcmd->list_frame);
-			}
-		}
-		spin_unlock_irqrestore(&pp_stereocam_spinlock, flags);
-		return;
-
-	default:
-		pr_err("%s: qtype %d not handled\n", __func__, vdata->type);
-	}
-	pr_err("%s: Should not come here. Error.\n", __func__);
-}
-
-static struct msm_vpe_callback msm_vpe_s = {
-	.vpe_resp = msm_vpe_sync,
-	.vpe_alloc = msm_vpe_sync_alloc,
-	.vpe_free = msm_vpe_sync_free,
-};
-
-static struct msm_vfe_callback msm_vfe_s = {
-	.vfe_resp = msm_vfe_sync,
-	.vfe_alloc = msm_vfe_sync_alloc,
-	.vfe_free = msm_vfe_sync_free,
-};
-
-static int __msm_open(struct msm_cam_device *pmsm, const char *const apps_id,
-			int is_controlnode)
-{
-	int rc = 0;
-	struct msm_sync *sync = pmsm->sync;
-
-	mutex_lock(&sync->lock);
-	if (sync->apps_id && strcmp(sync->apps_id, apps_id)
-				&& (!strcmp(MSM_APPS_ID_V4L2, apps_id))) {
-		pr_err("%s(%s): sensor %s is already opened for %s\n",
-			__func__,
-			apps_id,
-			sync->sdata->sensor_name,
-			sync->apps_id);
-		rc = -EBUSY;
-		goto msm_open_done;
-	}
-
-	sync->apps_id = apps_id;
-
-	if (!sync->core_powered_on && !is_controlnode) {
-		pm_qos_update_request(&sync->idle_pm_qos,
-			msm_cpuidle_get_deep_idle_latency());
-
-		msm_camvfe_fn_init(&sync->vfefn, sync);
-		if (sync->vfefn.vfe_init) {
-			sync->pp_frame_avail = 0;
-			sync->get_pic_abort = 0;
-			rc = msm_camio_sensor_clk_on(sync->pdev);
-			if (rc < 0) {
-				pr_err("%s: setting sensor clocks failed: %d\n",
-					__func__, rc);
-				goto msm_open_err;
-			}
-			rc = sync->sctrl.s_init(sync->sdata);
-			if (rc < 0) {
-				pr_err("%s: sensor init failed: %d\n",
-					__func__, rc);
-				msm_camio_sensor_clk_off(sync->pdev);
-				goto msm_open_err;
-			}
-			rc = sync->vfefn.vfe_init(&msm_vfe_s,
-				sync->pdev);
-			if (rc < 0) {
-				pr_err("%s: vfe_init failed at %d\n",
-					__func__, rc);
-				sync->sctrl.s_release();
-				msm_camio_sensor_clk_off(sync->pdev);
-				goto msm_open_err;
-			}
-		} else {
-			pr_err("%s: no sensor init func\n", __func__);
-			rc = -ENODEV;
-			goto msm_open_err;
-		}
-		msm_camvpe_fn_init(&sync->vpefn, sync);
-
-		spin_lock_init(&sync->abort_pict_lock);
-		spin_lock_init(&pp_prev_spinlock);
-		spin_lock_init(&pp_stereocam_spinlock);
-		spin_lock_init(&st_frame_spinlock);
-		if (rc >= 0) {
-			msm_region_init(sync);
-			if (sync->vpefn.vpe_reg)
-				sync->vpefn.vpe_reg(&msm_vpe_s);
-			sync->unblock_poll_frame = 0;
-			sync->unblock_poll_pic_frame = 0;
-		}
-		sync->core_powered_on = 1;
-	}
-	sync->opencnt++;
-	client_for_ion = msm_ion_client_create(-1, "camera");
-
-msm_open_done:
-	mutex_unlock(&sync->lock);
-	return rc;
-
-msm_open_err:
-	atomic_set(&pmsm->opened, 0);
-	mutex_unlock(&sync->lock);
-	return rc;
-}
-
-static int msm_open_common(struct inode *inode, struct file *filep,
-			int once, int is_controlnode)
-{
-	int rc;
-	struct msm_cam_device *pmsm =
-		container_of(inode->i_cdev, struct msm_cam_device, cdev);
-
-	CDBG("%s: open %s\n", __func__, filep->f_path.dentry->d_name.name);
-
-	if (atomic_cmpxchg(&pmsm->opened, 0, 1) && once) {
-		pr_err("%s: %s is already opened.\n",
-			__func__,
-			filep->f_path.dentry->d_name.name);
-		return -EBUSY;
-	}
-
-	rc = nonseekable_open(inode, filep);
-	if (rc < 0) {
-		pr_err("%s: nonseekable_open error %d\n", __func__, rc);
-		return rc;
-	}
-
-	rc = __msm_open(pmsm, MSM_APPS_ID_PROP, is_controlnode);
-	if (rc < 0)
-		return rc;
-	filep->private_data = pmsm;
-	CDBG("%s: rc %d\n", __func__, rc);
-	return rc;
-}
-
-static int msm_open_frame(struct inode *inode, struct file *filep)
-{
-	struct msm_cam_device *pmsm =
-		container_of(inode->i_cdev, struct msm_cam_device, cdev);
-	msm_queue_drain(&pmsm->sync->frame_q, list_frame);
-	return msm_open_common(inode, filep, 1, 0);
-}
-
-static int msm_open(struct inode *inode, struct file *filep)
-{
-	return msm_open_common(inode, filep, 1, 0);
-}
-
-static int msm_open_control(struct inode *inode, struct file *filep)
-{
-	int rc;
-
-	struct msm_control_device *ctrl_pmsm =
-		kmalloc(sizeof(struct msm_control_device), GFP_KERNEL);
-	if (!ctrl_pmsm)
-		return -ENOMEM;
-
-	rc = msm_open_common(inode, filep, 0, 1);
-	if (rc < 0) {
-		kfree(ctrl_pmsm);
-		return rc;
-	}
-	ctrl_pmsm->pmsm = filep->private_data;
-	filep->private_data = ctrl_pmsm;
-
-	msm_queue_init(&ctrl_pmsm->ctrl_q, "control");
-
-	if (!g_v4l2_opencnt)
-		g_v4l2_control_device = ctrl_pmsm;
-	g_v4l2_opencnt++;
-	CDBG("%s: rc %d\n", __func__, rc);
-	return rc;
-}
-
-static const struct file_operations msm_fops_config = {
-	.owner = THIS_MODULE,
-	.open = msm_open,
-	.unlocked_ioctl = msm_ioctl_config,
-	.release = msm_release_config,
-	.poll = msm_poll_config,
-};
-
-static const struct file_operations msm_fops_control = {
-	.owner = THIS_MODULE,
-	.open = msm_open_control,
-	.unlocked_ioctl = msm_ioctl_control,
-	.release = msm_release_control,
-};
-
-static const struct file_operations msm_fops_frame = {
-	.owner = THIS_MODULE,
-	.open = msm_open_frame,
-	.unlocked_ioctl = msm_ioctl_frame,
-	.release = msm_release_frame,
-	.poll = msm_poll_frame,
-};
-
-static const struct file_operations msm_fops_pic = {
-	.owner = THIS_MODULE,
-	.open = msm_open,
-	.unlocked_ioctl = msm_ioctl_pic,
-	.release = msm_release_pic,
-	.poll = msm_poll_pic,
-};
-
-static int msm_setup_cdev(struct msm_cam_device *msm,
-			int node,
-			dev_t devno,
-			const char *suffix,
-			const struct file_operations *fops)
-{
-	int rc = -ENODEV;
-
-	struct device *device =
-		device_create(msm_class, NULL,
-			devno, NULL,
-			"%s%d", suffix, node);
-
-	if (IS_ERR(device)) {
-		rc = PTR_ERR(device);
-		pr_err("%s: error creating device: %d\n", __func__, rc);
-		return rc;
-	}
-
-	cdev_init(&msm->cdev, fops);
-	msm->cdev.owner = THIS_MODULE;
-
-	rc = cdev_add(&msm->cdev, devno, 1);
-	if (rc < 0) {
-		pr_err("%s: error adding cdev: %d\n", __func__, rc);
-		device_destroy(msm_class, devno);
-		return rc;
-	}
-
-	return rc;
-}
-
-static int msm_tear_down_cdev(struct msm_cam_device *msm, dev_t devno)
-{
-	cdev_del(&msm->cdev);
-	device_destroy(msm_class, devno);
-	return 0;
-}
-
-static int msm_sync_init(struct msm_sync *sync,
-		struct platform_device *pdev,
-		int (*sensor_probe)(const struct msm_camera_sensor_info *,
-				struct msm_sensor_ctrl *))
-{
-	int rc = 0;
-	struct msm_sensor_ctrl sctrl;
-	sync->sdata = pdev->dev.platform_data;
-
-	msm_queue_init(&sync->event_q, "event");
-	msm_queue_init(&sync->frame_q, "frame");
-	msm_queue_init(&sync->pict_q, "pict");
-	msm_queue_init(&sync->vpe_q, "vpe");
-
-	pm_qos_add_request(&sync->idle_pm_qos, PM_QOS_CPU_DMA_LATENCY,
-					   PM_QOS_DEFAULT_VALUE);
-
-	rc = msm_camio_probe_on(pdev);
-	if (rc < 0) {
-		pm_qos_remove_request(&sync->idle_pm_qos);
-		return rc;
-	}
-	rc = sensor_probe(sync->sdata, &sctrl);
-	if (rc >= 0) {
-		sync->pdev = pdev;
-		sync->sctrl = sctrl;
-	}
-	msm_camio_probe_off(pdev);
-	if (rc < 0) {
-		pr_err("%s: failed to initialize %s\n",
-			__func__,
-			sync->sdata->sensor_name);
-		pm_qos_remove_request(&sync->idle_pm_qos);
-		return rc;
-	}
-
-	sync->opencnt = 0;
-	sync->core_powered_on = 0;
-	sync->ignore_qcmd = false;
-	sync->ignore_qcmd_type = -1;
-	mutex_init(&sync->lock);
-	if (sync->sdata->strobe_flash_data) {
-		sync->sdata->strobe_flash_data->state = 0;
-		spin_lock_init(&sync->sdata->strobe_flash_data->spin_lock);
-	}
-	CDBG("%s: initialized %s\n", __func__, sync->sdata->sensor_name);
-	return rc;
-}
-
-static int msm_sync_destroy(struct msm_sync *sync)
-{
-	pm_qos_remove_request(&sync->idle_pm_qos);
-	return 0;
-}
-
-static int msm_device_init(struct msm_cam_device *pmsm,
-		struct msm_sync *sync,
-		int node)
-{
-	int dev_num = 4 * node;
-	int rc = msm_setup_cdev(pmsm, node,
-		MKDEV(MAJOR(msm_devno), dev_num),
-		"control", &msm_fops_control);
-	if (rc < 0) {
-		pr_err("%s: error creating control node: %d\n", __func__, rc);
-		return rc;
-	}
-
-	rc = msm_setup_cdev(pmsm + 1, node,
-		MKDEV(MAJOR(msm_devno), dev_num + 1),
-		"config", &msm_fops_config);
-	if (rc < 0) {
-		pr_err("%s: error creating config node: %d\n", __func__, rc);
-		msm_tear_down_cdev(pmsm, MKDEV(MAJOR(msm_devno),
-				dev_num));
-		return rc;
-	}
-
-	rc = msm_setup_cdev(pmsm + 2, node,
-		MKDEV(MAJOR(msm_devno), dev_num + 2),
-		"frame", &msm_fops_frame);
-	if (rc < 0) {
-		pr_err("%s: error creating frame node: %d\n", __func__, rc);
-		msm_tear_down_cdev(pmsm,
-			MKDEV(MAJOR(msm_devno), dev_num));
-		msm_tear_down_cdev(pmsm + 1,
-			MKDEV(MAJOR(msm_devno), dev_num + 1));
-		return rc;
-	}
-
-	rc = msm_setup_cdev(pmsm + 3, node,
-		MKDEV(MAJOR(msm_devno), dev_num + 3),
-		"pic", &msm_fops_pic);
-	if (rc < 0) {
-		pr_err("%s: error creating pic node: %d\n", __func__, rc);
-		msm_tear_down_cdev(pmsm,
-			MKDEV(MAJOR(msm_devno), dev_num));
-		msm_tear_down_cdev(pmsm + 1,
-			MKDEV(MAJOR(msm_devno), dev_num + 1));
-		msm_tear_down_cdev(pmsm + 2,
-			MKDEV(MAJOR(msm_devno), dev_num + 2));
-		return rc;
-	}
-
-
-	atomic_set(&pmsm[0].opened, 0);
-	atomic_set(&pmsm[1].opened, 0);
-	atomic_set(&pmsm[2].opened, 0);
-	atomic_set(&pmsm[3].opened, 0);
-
-	pmsm[0].sync = sync;
-	pmsm[1].sync = sync;
-	pmsm[2].sync = sync;
-	pmsm[3].sync = sync;
-
-	return rc;
-}
-
-int msm_camera_drv_start(struct platform_device *dev,
-		int (*sensor_probe)(const struct msm_camera_sensor_info *,
-			struct msm_sensor_ctrl *))
-{
-	struct msm_cam_device *pmsm = NULL;
-	struct msm_sync *sync;
-	int rc = -ENODEV;
-
-	if (camera_node >= MSM_MAX_CAMERA_SENSORS) {
-		pr_err("%s: too many camera sensors\n", __func__);
-		return rc;
-	}
-
-	if (!msm_class) {
-		/* There are three device nodes per sensor */
-		rc = alloc_chrdev_region(&msm_devno, 0,
-				4 * MSM_MAX_CAMERA_SENSORS,
-				"msm_camera");
-		if (rc < 0) {
-			pr_err("%s: failed to allocate chrdev: %d\n", __func__,
-				rc);
-			return rc;
-		}
-
-		msm_class = class_create(THIS_MODULE, "msm_camera");
-		if (IS_ERR(msm_class)) {
-			rc = PTR_ERR(msm_class);
-			pr_err("%s: create device class failed: %d\n",
-				__func__, rc);
-			return rc;
-		}
-	}
-
-	pmsm = kzalloc(sizeof(struct msm_cam_device) * 4 +
-			sizeof(struct msm_sync), GFP_ATOMIC);
-	if (!pmsm)
-		return -ENOMEM;
-	sync = (struct msm_sync *)(pmsm + 4);
-
-	rc = msm_sync_init(sync, dev, sensor_probe);
-	if (rc < 0) {
-		kfree(pmsm);
-		return rc;
-	}
-
-	CDBG("%s: setting camera node %d\n", __func__, camera_node);
-	rc = msm_device_init(pmsm, sync, camera_node);
-	if (rc < 0) {
-		msm_sync_destroy(sync);
-		kfree(pmsm);
-		return rc;
-	}
-
-	camera_type[camera_node] = sync->sctrl.s_camera_type;
-	sensor_mount_angle[camera_node] = sync->sctrl.s_mount_angle;
-	camera_node++;
-
-	list_add(&sync->list, &msm_sensors);
-	return rc;
-}
-EXPORT_SYMBOL(msm_camera_drv_start);
diff --git a/drivers/media/platform/msm/camera_v1/msm_camirq_router.c b/drivers/media/platform/msm/camera_v1/msm_camirq_router.c
deleted file mode 100644
index 37dd6c2..0000000
--- a/drivers/media/platform/msm/camera_v1/msm_camirq_router.c
+++ /dev/null
@@ -1,282 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/interrupt.h>
-#include <linux/of.h>
-#include <mach/irqs.h>
-#include <media/msm_isp.h>
-#include <media/v4l2-device.h>
-#include <media/v4l2-subdev.h>
-#include "msm.h"
-#include "server/msm_cam_server.h"
-#include "msm_camirq_router.h"
-
-#ifdef CONFIG_MSM_CAMERA_DEBUG
-#define D(fmt, args...) pr_debug("msm: " fmt, ##args)
-#else
-#define D(fmt, args...) do {} while (0)
-#endif
-
-static void msm_irqrouter_update_irqmap_entry(
-	struct msm_cam_server_irqmap_entry *entry,
-	int is_composite, int irq_idx, int cam_hw_idx)
-{
-	int rc = 0;
-	entry->irq_idx = irq_idx;
-	entry->is_composite = is_composite;
-	entry->cam_hw_idx = cam_hw_idx;
-	rc = msm_cam_server_update_irqmap(entry);
-	if (rc < 0)
-		pr_err("%s Error updating irq %d information ",
-			__func__, irq_idx);
-}
-
-static void msm_irqrouter_send_default_irqmap(
-	struct irqrouter_ctrl_type *irqrouter_ctrl)
-{
-	struct msm_cam_server_irqmap_entry *irqmap =
-		&irqrouter_ctrl->def_hw_irqmap[0];
-
-	msm_irqrouter_update_irqmap_entry(&irqmap[CAMERA_SS_IRQ_0],
-		0, CAMERA_SS_IRQ_0, MSM_CAM_HW_MICRO);
-
-	msm_irqrouter_update_irqmap_entry(&irqmap[CAMERA_SS_IRQ_1],
-		0, CAMERA_SS_IRQ_1, MSM_CAM_HW_CCI);
-
-	msm_irqrouter_update_irqmap_entry(&irqmap[CAMERA_SS_IRQ_2],
-		0, CAMERA_SS_IRQ_2, MSM_CAM_HW_CSI0);
-
-	msm_irqrouter_update_irqmap_entry(&irqmap[CAMERA_SS_IRQ_3],
-		0, CAMERA_SS_IRQ_3, MSM_CAM_HW_CSI1);
-
-	msm_irqrouter_update_irqmap_entry(&irqmap[CAMERA_SS_IRQ_4],
-		0, CAMERA_SS_IRQ_4, MSM_CAM_HW_CSI2);
-
-	msm_irqrouter_update_irqmap_entry(&irqmap[CAMERA_SS_IRQ_5],
-		0, CAMERA_SS_IRQ_5, MSM_CAM_HW_CSI3);
-
-	msm_irqrouter_update_irqmap_entry(&irqmap[CAMERA_SS_IRQ_6],
-		0, CAMERA_SS_IRQ_6, MSM_CAM_HW_ISPIF);
-
-	msm_irqrouter_update_irqmap_entry(&irqmap[CAMERA_SS_IRQ_7],
-		0, CAMERA_SS_IRQ_7, MSM_CAM_HW_CPP);
-
-	msm_irqrouter_update_irqmap_entry(&irqmap[CAMERA_SS_IRQ_8],
-		0, CAMERA_SS_IRQ_8, MSM_CAM_HW_VFE0);
-
-	msm_irqrouter_update_irqmap_entry(&irqmap[CAMERA_SS_IRQ_9],
-		0, CAMERA_SS_IRQ_9, MSM_CAM_HW_VFE1);
-
-	msm_irqrouter_update_irqmap_entry(&irqmap[CAMERA_SS_IRQ_10],
-		0, CAMERA_SS_IRQ_10, MSM_CAM_HW_JPEG0);
-
-	msm_irqrouter_update_irqmap_entry(&irqmap[CAMERA_SS_IRQ_11],
-		0, CAMERA_SS_IRQ_11, MSM_CAM_HW_JPEG1);
-
-	msm_irqrouter_update_irqmap_entry(&irqmap[CAMERA_SS_IRQ_12],
-		0, CAMERA_SS_IRQ_12, MSM_CAM_HW_JPEG2);
-}
-
-static int msm_irqrouter_open(struct v4l2_subdev *sd,
-	struct v4l2_subdev_fh *fh)
-{
-	struct irqrouter_ctrl_type *irqrouter_ctrl = v4l2_get_subdevdata(sd);
-	/* Only one object of IRQ Router allowed. */
-	if (atomic_read(&irqrouter_ctrl->active) != 0) {
-		pr_err("%s IRQ router is already opened\n", __func__);
-		return -EINVAL;
-	}
-
-	D("%s E ", __func__);
-	atomic_inc(&irqrouter_ctrl->active);
-
-	return 0;
-}
-
-static int msm_irqrouter_close(struct v4l2_subdev *sd,
-	struct v4l2_subdev_fh *fh)
-{
-	struct irqrouter_ctrl_type *irqrouter_ctrl = v4l2_get_subdevdata(sd);
-	if (atomic_read(&irqrouter_ctrl->active) == 0) {
-		pr_err("%s IRQ router is already closed\n", __func__);
-		return -EINVAL;
-	}
-	D("%s E ", __func__);
-	atomic_dec(&irqrouter_ctrl->active);
-	return 0;
-}
-
-static const struct v4l2_subdev_internal_ops msm_irqrouter_internal_ops = {
-	.open = msm_irqrouter_open,
-	.close = msm_irqrouter_close,
-};
-
-long msm_irqrouter_subdev_ioctl(struct v4l2_subdev *sd,
-	unsigned int cmd, void *arg)
-{
-	struct irqrouter_ctrl_type *irqrouter_ctrl = v4l2_get_subdevdata(sd);
-	struct msm_camera_irq_cfg *irq_cfg;
-	struct intr_table_entry irq_req;
-	int rc = 0;
-
-	/* Handle all IRQ Router Subdev IOCTLs here.
-	 * Userspace sends the composite irq configuration.
-	 * IRQ Router subdev then configures the registers to group
-	 * together individual core hw irqs into a composite IRQ
-	 * to the MSM IRQ controller. It also registers them with
-	 * the irq manager in the camera server. */
-	switch (cmd) {
-	case MSM_IRQROUTER_CFG_COMPIRQ:
-		COPY_FROM_USER(rc, &irq_cfg, (void __user *)arg,
-			sizeof(struct msm_camera_irq_cfg));
-		if (rc) {
-			ERR_COPY_FROM_USER();
-			break;
-		}
-
-		if (!irq_cfg ||
-			(irq_cfg->irq_idx < CAMERA_SS_IRQ_0) ||
-			(irq_cfg->irq_idx >= CAMERA_SS_IRQ_MAX)) {
-			pr_err("%s Invalid input", __func__);
-			return -EINVAL;
-		} else {
-			irq_req.cam_hw_mask      = irq_cfg->cam_hw_mask;
-			irq_req.irq_idx          = irq_cfg->irq_idx;
-			irq_req.irq_num          =
-			irqrouter_ctrl->def_hw_irqmap[irq_cfg->irq_idx].irq_num;
-			irq_req.is_composite     = 1;
-			irq_req.irq_trigger_type = IRQF_TRIGGER_RISING;
-			irq_req.num_hwcore       = irq_cfg->num_hwcore;
-			irq_req.data             = NULL;
-			rc = msm_cam_server_request_irq(&irq_req);
-			if (rc < 0) {
-				pr_err("%s Error requesting comp irq %d ",
-					__func__, irq_req.irq_idx);
-				return rc;
-			}
-			irqrouter_ctrl->def_hw_irqmap
-				[irq_cfg->irq_idx].is_composite = 1;
-		}
-		break;
-	default:
-		pr_err("%s Invalid cmd %d ", __func__, cmd);
-		break;
-	}
-
-	return rc;
-}
-
-static const struct v4l2_subdev_core_ops msm_irqrouter_subdev_core_ops = {
-	.ioctl = msm_irqrouter_subdev_ioctl,
-};
-
-static const struct v4l2_subdev_ops msm_irqrouter_subdev_ops = {
-	.core = &msm_irqrouter_subdev_core_ops,
-};
-
-static int __devinit irqrouter_probe(struct platform_device *pdev)
-{
-	int rc = 0;
-	struct irqrouter_ctrl_type *irqrouter_ctrl;
-	struct msm_cam_subdev_info sd_info;
-
-	D("%s: device id = %d\n", __func__, pdev->id);
-
-	irqrouter_ctrl = kzalloc(sizeof(struct irqrouter_ctrl_type),
-				GFP_KERNEL);
-	if (!irqrouter_ctrl) {
-		pr_err("%s: not enough memory\n", __func__);
-		return -ENOMEM;
-	}
-
-	v4l2_subdev_init(&irqrouter_ctrl->subdev, &msm_irqrouter_subdev_ops);
-	irqrouter_ctrl->subdev.internal_ops = &msm_irqrouter_internal_ops;
-	irqrouter_ctrl->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	snprintf(irqrouter_ctrl->subdev.name,
-			 sizeof(irqrouter_ctrl->subdev.name), "msm_irqrouter");
-	v4l2_set_subdevdata(&irqrouter_ctrl->subdev, irqrouter_ctrl);
-	irqrouter_ctrl->pdev = pdev;
-
-	if (pdev->dev.of_node)
-		of_property_read_u32((&pdev->dev)->of_node,
-			"cell-index", &pdev->id);
-
-	msm_irqrouter_send_default_irqmap(irqrouter_ctrl);
-
-	media_entity_init(&irqrouter_ctrl->subdev.entity, 0, NULL, 0);
-	irqrouter_ctrl->subdev.entity.type = MEDIA_ENT_T_DEVNODE_V4L;
-	irqrouter_ctrl->subdev.entity.group_id = IRQ_ROUTER_DEV;
-	irqrouter_ctrl->subdev.entity.name = pdev->name;
-
-	sd_info.sdev_type = IRQ_ROUTER_DEV;
-	sd_info.sd_index = 0;
-	sd_info.irq_num = 0;
-	/* Now register this subdev with the camera server. */
-	rc = msm_cam_register_subdev_node(&irqrouter_ctrl->subdev, &sd_info);
-	if (rc < 0) {
-		pr_err("%s Error registering irqr subdev %d", __func__, rc);
-		goto error;
-	}
-	irqrouter_ctrl->subdev.entity.revision =
-		irqrouter_ctrl->subdev.devnode->num;
-	atomic_set(&irqrouter_ctrl->active, 0);
-
-	platform_set_drvdata(pdev, &irqrouter_ctrl->subdev);
-
-	return rc;
-error:
-	kfree(irqrouter_ctrl);
-	return rc;
-}
-
-static int __exit irqrouter_exit(struct platform_device *pdev)
-{
-	struct v4l2_subdev *subdev = dev_get_drvdata(&pdev->dev);
-	struct irqrouter_ctrl_type *irqrouter_ctrl =
-		v4l2_get_subdevdata(subdev);
-	kfree(irqrouter_ctrl);
-	return 0;
-}
-
-static const struct of_device_id msm_irqrouter_dt_match[] = {
-	{.compatible = "qcom,irqrouter"},
-	{}
-};
-
-MODULE_DEVICE_TABLE(of, msm_irqrouter_dt_match);
-
-static struct platform_driver msm_irqrouter_driver = {
-	.probe = irqrouter_probe,
-	.remove = irqrouter_exit,
-	.driver = {
-		.name = MSM_IRQ_ROUTER_DRV_NAME,
-		.owner = THIS_MODULE,
-		.of_match_table = msm_irqrouter_dt_match,
-	},
-};
-
-static int __init msm_irqrouter_init_module(void)
-{
-	return platform_driver_register(&msm_irqrouter_driver);
-}
-
-static void __exit msm_irqrouter_exit_module(void)
-{
-	platform_driver_unregister(&msm_irqrouter_driver);
-}
-
-module_init(msm_irqrouter_init_module);
-module_exit(msm_irqrouter_exit_module);
-MODULE_DESCRIPTION("msm camera irq router");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/msm_camirq_router.h b/drivers/media/platform/msm/camera_v1/msm_camirq_router.h
deleted file mode 100644
index 3ea3cec..0000000
--- a/drivers/media/platform/msm/camera_v1/msm_camirq_router.h
+++ /dev/null
@@ -1,206 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- *
- */
-
-#ifndef __MSM_CAM_IRQROUTER_H__
-#define __MSM_CAM_IRQROUTER_H__
-
-#include <linux/bitops.h>
-
-/* Camera SS common registers defines - Start */
-/* These registers are not directly related to
- * IRQ Router, but are common to the Camera SS.
- * IRQ Router registers dont have a unique base address
- * in the memory mapped address space. It is offset from
- * the Camera SS base address. So keep the common Camera
- * SS registers also in the IRQ Router subdev for now. */
-
-/* READ ONLY: Camera Subsystem HW version */
-#define CAMSS_HW_VERSION			0x00000000
-
-/* Bits 4:0 of this register can be used to select a desired
- * camera core test bus to drive the Camera_SS test bus output */
-#define CAMSS_TESTBUS_SEL			0x00000004
-
-/* Bits 4:0 of this register is used to allow either Microcontroller
- * or the CCI drive the corresponding GPIO output.
- * For eg: Setting bit 0 of this register allows Microcontroller to
- * drive GPIO #0. Clearing the bit allows CCI to drive GPIO #0. */
-#define CAMSS_GPIO_MUX_SEL			0x00000008
-
-/* Bit 0 of this register is used to set the default AHB master
- * for the AHB Arbiter. 0 - AHB Master 0, 1 - AHB Master 1*/
-#define CAMSS_AHB_ARB_CTL			0x0000000C
-
-/* READ ONLY */
-#define CAMSS_XPU2_STATUS			0x00000010
-
-/* Select the appropriate CSI clock for CSID Pixel pipes */
-#define CAMSS_CSI_PIX_CLK_MUX_SEL		0x00000020
-#define CAMSS_CSI_PIX_CLK_CGC_EN		0x00000024
-
-/* Select the appropriate CSI clock for CSID RDI pipes */
-#define CAMSS_CSI_RDI_CLK_MUX_SEL		0x00000028
-#define CAMSS_CSI_RDI_CLK_CGC_EN		0x0000002C
-
-/* Select the appropriate CSI clock for CSI Phy0 */
-#define CAMSS_CSI_PHY_0_CLK_MUX_SEL		0x00000030
-#define CAMSS_CSI_PHY_0_CLK_CGC_EN		0x00000034
-
-/* Select the appropriate CSI clock for CSI Phy1 */
-#define CAMSS_CSI_PHY_1_CLK_MUX_SEL		0x00000038
-#define CAMSS_CSI_PHY_1_CLK_CGC_EN		0x0000003C
-
-/* Select the appropriate CSI clock for CSI Phy2 */
-#define CAMSS_CSI_PHY_2_CLK_MUX_SEL		0x00000040
-#define CAMSS_CSI_PHY_2_CLK_CGC_EN		0x00000044
-/* Camera SS common registers defines - End */
-
-/* IRQ Router registers defines - Start */
-/* This register is used to reset the composite
- * IRQ outputs of the Camera_SS IRQ Router */
-#define CAMSS_IRQ_COMPOSITE_RESET_CTRL		0x00000060
-
-/* By default, this 'allows' the interrupts from
- * Micro to pass through, unless configured in
- * composite mode. */
-#define CAMSS_IRQ_COMPOSITE_MASK_0		0x00000064
-
-/* By default, this 'allows' the interrupts from
- * CCI to pass through, unless configured in
- * composite mode. */
-#define CAMSS_IRQ_COMPOSITE_MASK_1		0x00000068
-
-/* By default, this 'allows' the interrupts from
- * CSI_0 to pass through, unless configured in
- * composite mode. */
-#define CAMSS_IRQ_COMPOSITE_MASK_2		0x0000006C
-
-/* By default, this 'allows' the interrupts from
- * CSI_1 to pass through, unless configured in
- * composite mode. */
-#define CAMSS_IRQ_COMPOSITE_MASK_3		0x00000070
-
-/* By default, this 'allows' the interrupts from
- * CSI_2 to pass through, unless configured in
- * composite mode. */
-#define CAMSS_IRQ_COMPOSITE_MASK_4		0x00000074
-
-/* By default, this 'allows' the interrupts from
- * CSI_3 to pass through, unless configured in
- * composite mode. */
-#define CAMSS_IRQ_COMPOSITE_MASK_5		0x00000078
-
-/* By default, this 'allows' the interrupts from
- * ISPIF to pass through, unless configured in
- * composite mode. */
-#define CAMSS_IRQ_COMPOSITE_MASK_6		0x0000007C
-
-/* By default, this 'allows' the interrupts from
- * CPP to pass through, unless configured in
- * composite mode. */
-#define CAMSS_IRQ_COMPOSITE_MASK_7		0x00000080
-
-/* By default, this 'allows' the interrupts from
- * VFE_0 to pass through, unless configured in
- * composite mode. */
-#define CAMSS_IRQ_COMPOSITE_MASK_8		0x00000084
-
-/* By default, this 'allows' the interrupts from
- * VFE_1 to pass through, unless configured in
- * composite mode. */
-#define CAMSS_IRQ_COMPOSITE_MASK_9		0x00000088
-
-/* By default, this 'allows' the interrupts from
- * JPEG_0 to pass through, unless configured in
- * composite mode. */
-#define CAMSS_IRQ_COMPOSITE_MASK_10		0x0000008C
-
-/* By default, this 'allows' the interrupts from
- * JPEG_1 to pass through, unless configured in
- * composite mode. */
-#define CAMSS_IRQ_COMPOSITE_MASK_11		0x00000090
-
-/* By default, this 'allows' the interrupts from
- * JPEG_2 to pass through, unless configured in
- * composite mode. */
-#define CAMSS_IRQ_COMPOSITE_MASK_12		0x00000094
-
-/* The following IRQ_COMPOSITE_MICRO_MASK registers
- * allow the interrupts from the individual hw
- * cores to be composited into an IRQ for Micro. */
-#define CAMSS_IRQ_COMPOSITE_MICRO_MASK_0	0x000000A4
-#define CAMSS_IRQ_COMPOSITE_MICRO_MASK_1	0x000000A8
-#define CAMSS_IRQ_COMPOSITE_MICRO_MASK_2	0x000000AC
-#define CAMSS_IRQ_COMPOSITE_MICRO_MASK_3	0x000000B0
-#define CAMSS_IRQ_COMPOSITE_MICRO_MASK_4	0x000000B4
-#define CAMSS_IRQ_COMPOSITE_MICRO_MASK_5	0x000000B8
-/* IRQ Router register defines - End */
-
-/* Writing this mask will reset all the composite
- * IRQs of the Camera_SS IRQ Router */
-#define CAMSS_IRQ_COMPOSITE_RESET_MASK		0x003F1FFF
-
-/* Use this to enable Micro IRQ from IRQ Router
- * composite interrupt */
-#define ENABLE_MICRO_IRQ_IN_COMPOSITE		BIT(0)
-/* Use this to enable CCI IRQ from IRQ Router
- * composite interrupt */
-#define ENABLE_CCI_IRQ_IN_COMPOSITE		BIT(1)
-/* Use this to enable CSI0 IRQ from IRQ Router
- * composite interrupt */
-#define ENABLE_CSI0_IRQ_IN_COMPOSITE		BIT(2)
-/* Use this to enable CSI1 IRQ from IRQ Router
- * composite interrupt */
-#define ENABLE_CSI1_IRQ_IN_COMPOSITE		BIT(3)
-/* Use this to enable CSI2 IRQ from IRQ Router
- * composite interrupt */
-#define ENABLE_CSI2_IRQ_IN_COMPOSITE		BIT(4)
-/* Use this to enable CSI3 IRQ from IRQ Router
- * composite interrupt */
-#define ENABLE_CSI3_IRQ_IN_COMPOSITE		BIT(5)
-/* Use this to enable ISPIF IRQ from IRQ Router
- * composite interrupt */
-#define ENABLE_ISPIF_IRQ_IN_COMPOSITE		BIT(6)
-/* Use this to enable CPP IRQ from IRQ Router
- * composite interrupt */
-#define ENABLE_CPP_IRQ_IN_COMPOSITE		BIT(7)
-/* Use this to enable VFE0 IRQ from IRQ Router
- * composite interrupt */
-#define ENABLE_VFE0_IRQ_IN_COMPOSITE		BIT(8)
-/* Use this to enable VFE1 IRQ from IRQ Router
- * composite interrupt */
-#define ENABLE_VFE1_IRQ_IN_COMPOSITE		BIT(9)
-/* Use this to enable JPEG0 IRQ from IRQ Router
- * composite interrupt */
-#define ENABLE_JPEG0_IRQ_IN_COMPOSITE		BIT(10)
-/* Use this to enable JPEG1 IRQ from IRQ Router
- * composite interrupt */
-#define ENABLE_JPEG1_IRQ_IN_COMPOSITE		BIT(11)
-/* Use this to enable JPEG2 IRQ from IRQ Router
- * composite interrupt */
-#define ENABLE_JPEG2_IRQ_IN_COMPOSITE		BIT(12)
-
-struct irqrouter_ctrl_type {
-	/* v4l2 subdev */
-	struct v4l2_subdev subdev;
-	struct platform_device *pdev;
-
-	void __iomem *irqr_dev_base;
-
-	struct resource	*irqr_dev_mem;
-	struct resource *irqr_dev_io;
-	atomic_t active;
-	struct msm_cam_server_irqmap_entry def_hw_irqmap[CAMERA_SS_IRQ_MAX];
-};
-
-#endif /* __MSM_CAM_IRQROUTER_H__ */
diff --git a/drivers/media/platform/msm/camera_v1/msm_gesture.c b/drivers/media/platform/msm/camera_v1/msm_gesture.c
deleted file mode 100644
index 3ab041e..0000000
--- a/drivers/media/platform/msm/camera_v1/msm_gesture.c
+++ /dev/null
@@ -1,501 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#include <linux/module.h>
-#include <media/v4l2-subdev.h>
-#include <media/msm_camera.h>
-#include <media/msm_gestures.h>
-#include <media/v4l2-ctrls.h>
-#include <mach/camera.h>
-#include "msm.h"
-
-#ifdef CONFIG_MSM_CAMERA_DEBUG
-#define D(fmt, args...) pr_debug("msm_gesture: " fmt, ##args)
-#else
-#define D(fmt, args...) do {} while (0)
-#endif
-
-struct msm_gesture_ctrl {
-	int queue_id;
-	atomic_t active;
-	struct v4l2_ctrl_handler ctrl_handler;
-	int num_ctrls;
-	struct v4l2_fh *p_eventHandle;
-	struct v4l2_subdev *sd;
-	struct msm_ges_evt event;
-	int camera_opened;
-};
-
-static struct msm_gesture_ctrl g_gesture_ctrl;
-
-int msm_gesture_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
-	struct v4l2_event_subscription *sub)
-{
-	D("%s\n", __func__);
-	if (sub->type == V4L2_EVENT_ALL)
-		sub->type = MSM_GES_APP_NOTIFY_EVENT;
-	return v4l2_event_subscribe(fh, sub, 30);
-}
-
-static int msm_gesture_send_ctrl(struct msm_gesture_ctrl *p_gesture_ctrl,
-	int type, void *value, int length, uint32_t timeout)
-{
-	int rc = 0;
-	struct msm_ctrl_cmd ctrlcmd;
-	D("%s qid %d\n", __func__, p_gesture_ctrl->queue_id);
-	ctrlcmd.type = type;
-	ctrlcmd.timeout_ms = timeout;
-	ctrlcmd.length = length;
-	ctrlcmd.value = value;
-	ctrlcmd.vnode_id = 0;
-	ctrlcmd.queue_idx = p_gesture_ctrl->queue_id;
-	ctrlcmd.config_ident = 0;
-
-	rc = msm_server_send_ctrl(&ctrlcmd, MSM_GES_RESP_V4L2);
-	return rc;
-}
-
-static int msm_gesture_proc_ctrl_cmd(struct msm_gesture_ctrl *p_gesture_ctrl,
-	struct v4l2_control *ctrl)
-{
-	int rc = 0;
-	struct msm_ctrl_cmd *tmp_cmd = NULL;
-	uint8_t *ctrl_data = NULL;
-	void __user *uptr_cmd;
-	void __user *uptr_value;
-	uint32_t cmd_len = sizeof(struct msm_ctrl_cmd);
-	uint32_t value_len;
-
-	tmp_cmd = (struct msm_ctrl_cmd *)ctrl->value;
-	uptr_cmd = (void __user *)ctrl->value;
-	uptr_value = (void __user *)tmp_cmd->value;
-	value_len = tmp_cmd->length;
-
-	D("%s: cmd type = %d, up1=0x%x, ulen1=%d, up2=0x%x, ulen2=%d\n",
-		__func__, tmp_cmd->type, (uint32_t)uptr_cmd, cmd_len,
-		(uint32_t)uptr_value, tmp_cmd->length);
-
-	ctrl_data = kzalloc(value_len + cmd_len, GFP_KERNEL);
-	if (ctrl_data == 0) {
-		pr_err("%s could not allocate memory\n", __func__);
-		rc = -ENOMEM;
-		goto end;
-	}
-	tmp_cmd = (struct msm_ctrl_cmd *)ctrl_data;
-	if (copy_from_user((void *)ctrl_data, uptr_cmd,
-			cmd_len)) {
-		pr_err("%s: copy_from_user failed.\n", __func__);
-		rc = -EINVAL;
-		goto end;
-	}
-	tmp_cmd->value = (void *)(ctrl_data + cmd_len);
-	if (uptr_value && tmp_cmd->length > 0) {
-		if (copy_from_user((void *)tmp_cmd->value, uptr_value,
-			value_len)) {
-			pr_err("%s: copy_from_user failed, size=%d\n",
-				__func__, value_len);
-			rc = -EINVAL;
-			goto end;
-		}
-	} else
-		tmp_cmd->value = NULL;
-
-	/* send command to config thread in usersspace, and get return value */
-	rc = msm_server_send_ctrl((struct msm_ctrl_cmd *)ctrl_data,
-			MSM_GES_RESP_V4L2);
-	D("%s: msm_server_control rc=%d\n", __func__, rc);
-	if (rc == 0) {
-		if (uptr_value && tmp_cmd->length > 0 &&
-			copy_to_user((void __user *)uptr_value,
-				(void *)(ctrl_data + cmd_len),
-				tmp_cmd->length)) {
-			pr_err("%s: copy_to_user failed, size=%d\n",
-				__func__, tmp_cmd->length);
-			rc = -EINVAL;
-			goto end;
-		}
-		tmp_cmd->value = uptr_value;
-		if (copy_to_user((void __user *)uptr_cmd,
-			(void *)tmp_cmd, cmd_len)) {
-			pr_err("%s: copy_to_user failed in cpy, size=%d\n",
-				__func__, cmd_len);
-			rc = -EINVAL;
-			goto end;
-		}
-	}
-end:
-	D("%s: END, type = %d, vaddr = 0x%x, vlen = %d, status = %d, rc = %d\n",
-		__func__, tmp_cmd->type, (uint32_t)tmp_cmd->value,
-		tmp_cmd->length, tmp_cmd->status, rc);
-	kfree(ctrl_data);
-	return rc;
-}
-
-static int msm_gesture_s_ctrl(struct v4l2_subdev *sd,
-	struct v4l2_control *ctrl)
-{
-	int rc = 0;
-	struct msm_gesture_ctrl *p_gesture_ctrl = &g_gesture_ctrl;
-	D("%s ctrl->id %d\n", __func__, ctrl->id);
-	rc = msm_gesture_proc_ctrl_cmd(p_gesture_ctrl, ctrl);
-	if (rc != 0) {
-		pr_err("%s set ctrl failed %d\n", __func__, rc);
-		return -EINVAL;
-	}
-	return rc;
-}
-
-static int msm_gesture_s_ctrl_ops(struct v4l2_ctrl *ctrl)
-{
-	int rc = 0;
-	struct v4l2_control control;
-	struct msm_gesture_ctrl *p_gesture_ctrl = &g_gesture_ctrl;
-	control.id = ctrl->id;
-	control.value = ctrl->val;
-	D("%s ctrl->id 0x%x\n", __func__, ctrl->id);
-	rc = msm_gesture_proc_ctrl_cmd(p_gesture_ctrl, &control);
-	if (rc != 0) {
-		pr_err("%s proc ctrl failed %d\n", __func__, rc);
-		return -EINVAL;
-	}
-	return rc;
-}
-
-static int msm_gesture_s_ctrl_ext(struct v4l2_subdev *sd,
-	struct v4l2_ext_controls *ctrls)
-{
-	int rc = 0;
-	struct v4l2_control control;
-	struct msm_gesture_ctrl *p_gesture_ctrl = &g_gesture_ctrl;
-	if ((ctrls->count < 1) || (NULL == ctrls->controls)) {
-		pr_err("%s invalid ctrl failed\n", __func__);
-		return -EINVAL;
-	}
-	control.id = ctrls->controls->id;
-	control.value = ctrls->controls->value;
-	D("%s ctrl->id %d\n", __func__, control.id);
-	rc = msm_gesture_proc_ctrl_cmd(p_gesture_ctrl, &control);
-	if (rc != 0) {
-		pr_err("%s proc ctrl failed %d\n", __func__, rc);
-		return -EINVAL;
-	}
-	return rc;
-}
-
-static int msm_gesture_handle_event(struct v4l2_subdev *sd,
-	struct msm_gesture_ctrl *p_gesture_ctrl, void* arg)
-{
-	int rc = 0;
-	struct v4l2_event *evt = (struct v4l2_event *)arg;
-	struct msm_ges_evt *p_ges_evt = NULL;
-	D("%s: Received gesture evt 0x%x ", __func__, evt->type);
-	p_gesture_ctrl->event.evt_len = 0;
-	p_gesture_ctrl->event.evt_data = NULL;
-
-	p_ges_evt = (struct msm_ges_evt *)evt->u.data;
-	D("%s: event data %p len %d", __func__,
-		p_ges_evt->evt_data,
-		p_ges_evt->evt_len);
-
-	if (p_ges_evt->evt_len > 0) {
-		p_gesture_ctrl->event.evt_data =
-			kzalloc(p_ges_evt->evt_len, GFP_KERNEL);
-
-		if (NULL == p_gesture_ctrl->event.evt_data) {
-			pr_err("%s: cannot allocate event", __func__);
-			rc = -ENOMEM;
-		} else {
-			if (copy_from_user(
-				(void *)p_gesture_ctrl->event.evt_data,
-				(void __user *)p_ges_evt->evt_data,
-				p_ges_evt->evt_len)) {
-				pr_err("%s: copy_from_user failed",
-					__func__);
-				rc = -EFAULT;
-			} else {
-				D("%s: copied the event", __func__);
-				p_gesture_ctrl->event.evt_len =
-					p_ges_evt->evt_len;
-			}
-		}
-	}
-
-	if (rc == 0) {
-		ktime_get_ts(&evt->timestamp);
-		v4l2_event_queue(sd->devnode, evt);
-	}
-	D("%s: exit rc %d ", __func__, rc);
-	return rc;
-}
-
-static int msm_gesture_get_evt_payload(struct v4l2_subdev *sd,
-	struct msm_gesture_ctrl *p_gesture_ctrl, void* arg)
-{
-	int rc = 0;
-	struct msm_ges_evt *p_ges_evt = (struct msm_ges_evt *)arg;
-	D("%s: enter ", __func__);
-	if (NULL != p_gesture_ctrl->event.evt_data) {
-		D("%s: event data %p len %d", __func__,
-			p_gesture_ctrl->event.evt_data,
-			p_gesture_ctrl->event.evt_len);
-
-		if (copy_to_user((void __user *)p_ges_evt->evt_data,
-			p_gesture_ctrl->event.evt_data,
-			p_gesture_ctrl->event.evt_len)) {
-			pr_err("%s: copy_to_user failed.\n", __func__);
-			rc = -EFAULT;
-		} else {
-			D("%s: copied the event", __func__);
-			p_ges_evt->evt_len = p_gesture_ctrl->event.evt_len;
-		}
-	}
-	D("%s: exit rc %d ", __func__, rc);
-	return rc;
-}
-
-static int msm_gesture_handle_cam_event(struct v4l2_subdev *sd,
-	struct msm_gesture_ctrl *p_gesture_ctrl, int cam_evt)
-{
-	int rc = 0;
-	D("%s: cam_evt %d ", __func__, cam_evt);
-
-	if ((cam_evt != MSM_V4L2_GES_CAM_OPEN)
-		&& (cam_evt != MSM_V4L2_GES_CAM_CLOSE)) {
-		pr_err("%s: error invalid event %d ", __func__, cam_evt);
-		return -EINVAL;
-	}
-
-	p_gesture_ctrl->camera_opened =
-		(cam_evt == MSM_V4L2_GES_CAM_OPEN);
-
-	if (atomic_read(&p_gesture_ctrl->active) == 0) {
-		D("%s gesture not active\n", __func__);
-		return 0;
-	}
-
-	rc = msm_gesture_send_ctrl(p_gesture_ctrl, cam_evt, NULL,
-		0, 2000);
-	if (rc != 0) {
-		pr_err("%s gesture ctrl failed %d\n", __func__, rc);
-		rc = -EINVAL;
-	}
-	D("%s exit rc %d\n", __func__, rc);
-	return rc;
-}
-
-long msm_gesture_ioctl(struct v4l2_subdev *sd,
-	 unsigned int cmd, void *arg)
-{
-	int rc = 0;
-	struct msm_gesture_ctrl *p_gesture_ctrl = &g_gesture_ctrl;
-	D("%s\n", __func__);
-	switch (cmd) {
-	case MSM_GES_IOCTL_CTRL_COMMAND: {
-		struct v4l2_control *ctrl = (struct v4l2_control *)arg;
-		D("%s MSM_GES_IOCTL_CTRL_COMMAND arg %p size %d\n", __func__,
-			arg, sizeof(ctrl));
-		rc = msm_gesture_s_ctrl(sd, ctrl);
-		break;
-	}
-	case VIDIOC_MSM_GESTURE_EVT: {
-		rc = msm_gesture_handle_event(sd, p_gesture_ctrl, arg);
-		break;
-	}
-	case VIDIOC_MSM_GESTURE_CAM_EVT: {
-		int cam_evt = *((int *)arg);
-		rc = msm_gesture_handle_cam_event(sd, p_gesture_ctrl, cam_evt);
-		break;
-	}
-	case MSM_GES_GET_EVT_PAYLOAD: {
-		rc = msm_gesture_get_evt_payload(sd, p_gesture_ctrl, arg);
-		break;
-	}
-	default:
-		pr_err("%s: Invalid ioctl %d", __func__, cmd);
-		break;
-	}
-	D("%s exit rc %d\n", __func__, rc);
-	return rc;
-}
-
-static const struct v4l2_ctrl_ops msm_gesture_ctrl_ops = {
-	.s_ctrl = msm_gesture_s_ctrl_ops,
-};
-
-static const struct v4l2_ctrl_config msm_gesture_ctrl_filter = {
-	.ops = &msm_gesture_ctrl_ops,
-	.id = MSM_GESTURE_CID_CTRL_CMD,
-	.name = "Gesture ctrl",
-	.type = V4L2_CTRL_TYPE_INTEGER,
-	.flags = V4L2_CTRL_FLAG_SLIDER,
-	.max = 0x7fffffff,
-	.step = 1,
-	.min = 0x80000000,
-};
-
-static int msm_gesture_init_ctrl(struct v4l2_subdev *sd,
-	struct msm_gesture_ctrl *p_gesture_ctrl)
-{
-	int rc = 0;
-	p_gesture_ctrl->num_ctrls = 1;
-	p_gesture_ctrl->ctrl_handler.error = 0;
-	v4l2_ctrl_handler_init(&p_gesture_ctrl->ctrl_handler,
-		p_gesture_ctrl->num_ctrls);
-	v4l2_ctrl_new_custom(&p_gesture_ctrl->ctrl_handler,
-		&msm_gesture_ctrl_filter, p_gesture_ctrl);
-	if (p_gesture_ctrl->ctrl_handler.error) {
-		int err = p_gesture_ctrl->ctrl_handler.error;
-		D("%s: error adding control %d", __func__, err);
-		p_gesture_ctrl->ctrl_handler.error = 0;
-	}
-	sd->ctrl_handler = &p_gesture_ctrl->ctrl_handler;
-	return rc;
-}
-
-static int msm_gesture_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
-{
-	int rc = 0, rc_err = 0;
-	struct msm_gesture_ctrl *p_gesture_ctrl = &g_gesture_ctrl;
-	D("%s\n", __func__);
-	if (atomic_read(&p_gesture_ctrl->active) != 0) {
-		pr_err("%s already opened\n", __func__);
-		return -EINVAL;
-	}
-	memset(&p_gesture_ctrl->event, 0x0, sizeof(struct msm_ges_evt));
-	rc = msm_server_open_client(&p_gesture_ctrl->queue_id);
-	if (rc != 0) {
-		pr_err("%s open failed %d\n", __func__, rc);
-		rc = -EINVAL;
-		goto err;
-	}
-
-	rc = msm_gesture_init_ctrl(sd, p_gesture_ctrl);
-	if (rc != 0) {
-		pr_err("%s init ctrl failed %d\n", __func__, rc);
-		rc = -EINVAL;
-		goto err;
-	}
-
-	rc = msm_gesture_send_ctrl(p_gesture_ctrl, MSM_V4L2_GES_OPEN, NULL,
-		0, 10000);
-	if (rc != 0) {
-		pr_err("%s gesture ctrl failed %d\n", __func__, rc);
-		rc = -EINVAL;
-		goto err;
-	}
-
-	atomic_inc(&p_gesture_ctrl->active);
-
-	return rc;
-
-err:
-	rc_err = msm_server_close_client(p_gesture_ctrl->queue_id);
-	if (rc_err != 0)
-		pr_err("%s failed %d\n", __func__, rc);
-	return rc;
-}
-
-static int msm_gesture_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
-{
-	int rc = 0;
-	struct msm_gesture_ctrl *p_gesture_ctrl = &g_gesture_ctrl;
-	D("%s\n", __func__);
-	if (atomic_read(&p_gesture_ctrl->active) == 0) {
-		pr_err("%s already closed\n", __func__);
-		return -EINVAL;
-	}
-
-	rc = msm_gesture_send_ctrl(p_gesture_ctrl, MSM_V4L2_GES_CLOSE, NULL,
-		0, 10000);
-	if (rc != 0)
-		pr_err("%s gesture ctrl failed %d\n", __func__, rc);
-
-	rc = msm_server_close_client(p_gesture_ctrl->queue_id);
-	if (rc != 0)
-		pr_err("%s failed %d\n", __func__, rc);
-
-	v4l2_ctrl_handler_free(&p_gesture_ctrl->ctrl_handler);
-	kfree(p_gesture_ctrl->event.evt_data);
-
-	atomic_dec(&p_gesture_ctrl->active);
-	g_gesture_ctrl.queue_id = -1;
-	return 0;
-}
-
-static struct v4l2_subdev_core_ops msm_gesture_core_ops = {
-	.s_ctrl = msm_gesture_s_ctrl,
-	.s_ext_ctrls = msm_gesture_s_ctrl_ext,
-	.ioctl = msm_gesture_ioctl,
-	.subscribe_event = msm_gesture_subscribe_event,
-};
-
-static struct v4l2_subdev_video_ops msm_gesture_video_ops;
-
-static struct v4l2_subdev_ops msm_gesture_subdev_ops = {
-	.core = &msm_gesture_core_ops,
-	.video  = &msm_gesture_video_ops,
-};
-
-static const struct v4l2_subdev_internal_ops msm_gesture_internal_ops = {
-	.open = msm_gesture_open,
-	.close = msm_gesture_close,
-};
-
-static int msm_gesture_node_register(void)
-{
-	struct msm_gesture_ctrl *p_gesture_ctrl = &g_gesture_ctrl;
-	struct v4l2_subdev *gesture_subdev =
-		kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
-	struct msm_cam_subdev_info sd_info;
-
-	D("%s\n", __func__);
-	if (!gesture_subdev) {
-		pr_err("%s: no enough memory\n", __func__);
-		return -ENOMEM;
-	};
-
-	v4l2_subdev_init(gesture_subdev, &msm_gesture_subdev_ops);
-	gesture_subdev->internal_ops = &msm_gesture_internal_ops;
-	gesture_subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	snprintf(gesture_subdev->name,
-			 sizeof(gesture_subdev->name), "gesture");
-
-	media_entity_init(&gesture_subdev->entity, 0, NULL, 0);
-	gesture_subdev->entity.type = MEDIA_ENT_T_DEVNODE_V4L;
-	gesture_subdev->entity.group_id = GESTURE_DEV;
-	gesture_subdev->entity.name = gesture_subdev->name;
-
-	/* events */
-	gesture_subdev->flags |= V4L2_SUBDEV_FL_HAS_EVENTS;
-
-	sd_info.sdev_type = GESTURE_DEV;
-	sd_info.sd_index = 0;
-	sd_info.irq_num = 0;
-	msm_cam_register_subdev_node(gesture_subdev, &sd_info);
-
-	gesture_subdev->entity.revision = gesture_subdev->devnode->num;
-
-	atomic_set(&p_gesture_ctrl->active, 0);
-	p_gesture_ctrl->queue_id = -1;
-	p_gesture_ctrl->event.evt_data = NULL;
-	p_gesture_ctrl->event.evt_len = 0;
-	return 0;
-}
-
-static int __init msm_gesture_init_module(void)
-{
-	return msm_gesture_node_register();
-}
-
-module_init(msm_gesture_init_module);
-MODULE_DESCRIPTION("MSM Gesture driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/msm_isp.c b/drivers/media/platform/msm/camera_v1/msm_isp.c
deleted file mode 100644
index 59290ec..0000000
--- a/drivers/media/platform/msm/camera_v1/msm_isp.c
+++ /dev/null
@@ -1,767 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/export.h>
-#include <linux/workqueue.h>
-#include <linux/delay.h>
-#include <linux/types.h>
-#include <linux/list.h>
-#include <linux/ioctl.h>
-#include <linux/spinlock.h>
-#include <linux/videodev2.h>
-#include <linux/proc_fs.h>
-#include <linux/vmalloc.h>
-
-
-#include <media/v4l2-dev.h>
-#include <media/v4l2-ioctl.h>
-#include <media/v4l2-device.h>
-#include <media/msm_isp.h>
-#include <media/msm_gemini.h>
-
-#include "msm.h"
-
-#ifdef CONFIG_MSM_CAMERA_DEBUG
-#define D(fmt, args...) pr_debug("msm_isp: " fmt, ##args)
-#else
-#define D(fmt, args...) do {} while (0)
-#endif
-
-#define MSM_FRAME_AXI_MAX_BUF 32
-
-/*
- * This function executes in interrupt context.
- */
-
-void *msm_isp_sync_alloc(int size,
-	  gfp_t gfp)
-{
-	struct msm_queue_cmd *qcmd =
-		kmalloc(sizeof(struct msm_queue_cmd) + size, gfp);
-
-	if (qcmd) {
-		atomic_set(&qcmd->on_heap, 1);
-		return qcmd + 1;
-	}
-	return NULL;
-}
-
-void msm_isp_sync_free(void *ptr)
-{
-	if (ptr) {
-		struct msm_queue_cmd *qcmd =
-			(struct msm_queue_cmd *)ptr;
-		qcmd--;
-		if (atomic_read(&qcmd->on_heap))
-			kfree(qcmd);
-	}
-}
-
-static int msm_isp_notify_VFE_SOF_COUNT_EVT(struct v4l2_subdev *sd, void *arg)
-{
-	struct msm_vfe_cfg_cmd cfgcmd;
-	struct msm_camvfe_params vfe_params;
-	int rc;
-
-	cfgcmd.cmd_type = CMD_VFE_PIX_SOF_COUNT_UPDATE;
-	cfgcmd.value = NULL;
-	vfe_params.vfe_cfg = &cfgcmd;
-	vfe_params.data = arg;
-	rc = v4l2_subdev_call(sd, core, ioctl, 0, &vfe_params);
-	return 0;
-}
-
-int msm_isp_vfe_msg_to_img_mode(struct msm_cam_media_controller *pmctl,
-				int vfe_msg)
-{
-	int image_mode;
-	uint32_t vfe_output_mode = pmctl->vfe_output_mode;
-	vfe_output_mode &= ~(VFE_OUTPUTS_RDI0|VFE_OUTPUTS_RDI1);
-	if (vfe_msg == VFE_MSG_OUTPUT_PRIMARY) {
-		switch (vfe_output_mode) {
-		case VFE_OUTPUTS_MAIN_AND_PREVIEW:
-		case VFE_OUTPUTS_MAIN_AND_VIDEO:
-		case VFE_OUTPUTS_MAIN_AND_THUMB:
-		case VFE_OUTPUTS_RAW:
-		case VFE_OUTPUTS_JPEG_AND_THUMB:
-			image_mode = MSM_V4L2_EXT_CAPTURE_MODE_MAIN;
-			break;
-		case VFE_OUTPUTS_THUMB_AND_MAIN:
-			image_mode = MSM_V4L2_EXT_CAPTURE_MODE_THUMBNAIL;
-			break;
-		case VFE_OUTPUTS_VIDEO:
-		case VFE_OUTPUTS_VIDEO_AND_PREVIEW:
-			image_mode = MSM_V4L2_EXT_CAPTURE_MODE_VIDEO;
-			break;
-		case VFE_OUTPUTS_PREVIEW:
-		case VFE_OUTPUTS_PREVIEW_AND_VIDEO:
-			image_mode = MSM_V4L2_EXT_CAPTURE_MODE_PREVIEW;
-			break;
-		default:
-			image_mode = -1;
-			break;
-		}
-	} else if (vfe_msg == VFE_MSG_OUTPUT_SECONDARY) {
-		switch (vfe_output_mode) {
-		case VFE_OUTPUTS_MAIN_AND_PREVIEW:
-		case VFE_OUTPUTS_VIDEO_AND_PREVIEW:
-			image_mode = MSM_V4L2_EXT_CAPTURE_MODE_PREVIEW;
-			break;
-		case VFE_OUTPUTS_MAIN_AND_VIDEO:
-		case VFE_OUTPUTS_PREVIEW_AND_VIDEO:
-			image_mode = MSM_V4L2_EXT_CAPTURE_MODE_VIDEO;
-			break;
-		case VFE_OUTPUTS_MAIN_AND_THUMB:
-			image_mode = MSM_V4L2_EXT_CAPTURE_MODE_THUMBNAIL;
-			break;
-		case VFE_OUTPUTS_THUMB_AND_MAIN:
-			image_mode = MSM_V4L2_EXT_CAPTURE_MODE_MAIN;
-			break;
-		case VFE_OUTPUTS_JPEG_AND_THUMB:
-			image_mode = MSM_V4L2_EXT_CAPTURE_MODE_THUMBNAIL;
-			break;
-		case VFE_OUTPUTS_PREVIEW:
-		case VFE_OUTPUTS_VIDEO:
-			image_mode = MSM_V4L2_EXT_CAPTURE_MODE_PREVIEW;
-			break;
-		default:
-			image_mode = -1;
-			break;
-		}
-	} else if (vfe_msg == VFE_MSG_OUTPUT_TERTIARY1) {
-		if (pmctl->vfe_output_mode & VFE_OUTPUTS_RDI0)
-			image_mode = MSM_V4L2_EXT_CAPTURE_MODE_RDI;
-		else
-			image_mode = -1;
-	} else if (vfe_msg == VFE_MSG_OUTPUT_TERTIARY2) {
-		if (pmctl->vfe_output_mode & VFE_OUTPUTS_RDI1)
-			image_mode = MSM_V4L2_EXT_CAPTURE_MODE_RDI1;
-		else
-			image_mode = -1;
-	} else if (VFE_MSG_V2X_LIVESHOT_PRIMARY == vfe_msg) {
-			image_mode = MSM_V4L2_EXT_CAPTURE_MODE_V2X_LIVESHOT;
-	} else
-		image_mode = -1;
-
-	D("%s Selected image mode %d vfe output mode %d, vfe msg %d\n",
-	  __func__, image_mode, pmctl->vfe_output_mode, vfe_msg);
-	return image_mode;
-}
-
-static int msm_isp_notify_VFE_BUF_EVT(struct msm_cam_media_controller *pmctl,
-					struct v4l2_subdev *sd, void *arg)
-{
-	int rc = -EINVAL;
-	struct msm_vfe_resp *vdata = (struct msm_vfe_resp *)arg;
-	struct msm_free_buf free_buf, temp_free_buf;
-	struct msm_camvfe_params vfe_params;
-	struct msm_vfe_cfg_cmd cfgcmd;
-	struct msm_cam_v4l2_device *pcam = pmctl->pcam_ptr;
-	struct msm_frame_info *frame_info =
-		(struct msm_frame_info *)vdata->evt_msg.data;
-	uint32_t vfe_id;
-	struct msm_cam_buf_handle buf_handle;
-
-	if (!pcam) {
-		pr_err("%s pcam is null. return\n", __func__);
-		msm_isp_sync_free(vdata);
-		return rc;
-	}
-	if (frame_info) {
-		vfe_id = frame_info->path;
-		buf_handle.buf_lookup_type = BUF_LOOKUP_BY_INST_HANDLE;
-		buf_handle.inst_handle = frame_info->inst_handle;
-	} else {
-		vfe_id = vdata->evt_msg.msg_id;
-		buf_handle.buf_lookup_type = BUF_LOOKUP_BY_IMG_MODE;
-		buf_handle.image_mode =
-			msm_isp_vfe_msg_to_img_mode(pmctl, vfe_id);
-	}
-
-	switch (vdata->type) {
-	case VFE_MSG_START:
-	case VFE_MSG_START_RECORDING:
-	case VFE_MSG_PREVIEW:
-		D("%s Got V32_START_*: Getting ping addr id = %d",
-						__func__, vfe_id);
-		msm_mctl_reserve_free_buf(pmctl, NULL,
-					&buf_handle, &free_buf);
-		cfgcmd.cmd_type = CMD_CONFIG_PING_ADDR;
-		cfgcmd.value = &vfe_id;
-		vfe_params.vfe_cfg = &cfgcmd;
-		vfe_params.data = (void *)&free_buf;
-		rc = v4l2_subdev_call(sd, core, ioctl, 0, &vfe_params);
-		msm_mctl_reserve_free_buf(pmctl, NULL,
-					&buf_handle, &free_buf);
-		cfgcmd.cmd_type = CMD_CONFIG_PONG_ADDR;
-		cfgcmd.value = &vfe_id;
-		vfe_params.vfe_cfg = &cfgcmd;
-		vfe_params.data = (void *)&free_buf;
-		rc = v4l2_subdev_call(sd, core, ioctl, 0, &vfe_params);
-		break;
-	case VFE_MSG_CAPTURE:
-		pr_debug("%s Got V32_CAPTURE: getting buffer for id = %d",
-						__func__, vfe_id);
-		msm_mctl_reserve_free_buf(pmctl, NULL,
-					&buf_handle, &free_buf);
-		cfgcmd.cmd_type = CMD_CONFIG_PING_ADDR;
-		cfgcmd.value = &vfe_id;
-		vfe_params.vfe_cfg = &cfgcmd;
-		vfe_params.data = (void *)&free_buf;
-		rc = v4l2_subdev_call(sd, core, ioctl, 0, &vfe_params);
-		temp_free_buf = free_buf;
-		if (msm_mctl_reserve_free_buf(pmctl, NULL,
-					&buf_handle, &free_buf)) {
-			/* Write the same buffer into PONG */
-			free_buf = temp_free_buf;
-		}
-		cfgcmd.cmd_type = CMD_CONFIG_PONG_ADDR;
-		cfgcmd.value = &vfe_id;
-		vfe_params.vfe_cfg = &cfgcmd;
-		vfe_params.data = (void *)&free_buf;
-		rc = v4l2_subdev_call(sd, core, ioctl, 0, &vfe_params);
-		break;
-	case VFE_MSG_JPEG_CAPTURE:
-		D("%s:VFE_MSG_JPEG_CAPTURE vdata->type %d\n", __func__,
-			vdata->type);
-		free_buf.num_planes = 2;
-		free_buf.ch_paddr[0] = pmctl->ping_imem_y;
-		free_buf.ch_paddr[1] = pmctl->ping_imem_cbcr;
-		cfgcmd.cmd_type = CMD_CONFIG_PING_ADDR;
-		cfgcmd.value = &vfe_id;
-		vfe_params.vfe_cfg = &cfgcmd;
-		vfe_params.data = (void *)&free_buf;
-		D("%s:VFE_MSG_JPEG_CAPTURE y_ping=%x cbcr_ping=%x\n",
-			__func__, free_buf.ch_paddr[0], free_buf.ch_paddr[1]);
-		rc = v4l2_subdev_call(sd, core, ioctl, 0, &vfe_params);
-		/* Write the same buffer into PONG */
-		free_buf.ch_paddr[0] = pmctl->pong_imem_y;
-		free_buf.ch_paddr[1] = pmctl->pong_imem_cbcr;
-		cfgcmd.cmd_type = CMD_CONFIG_PONG_ADDR;
-		cfgcmd.value = &vfe_id;
-		vfe_params.vfe_cfg = &cfgcmd;
-		vfe_params.data = (void *)&free_buf;
-		D("%s:VFE_MSG_JPEG_CAPTURE y_pong=%x cbcr_pong=%x\n",
-			__func__, free_buf.ch_paddr[0], free_buf.ch_paddr[1]);
-		rc = v4l2_subdev_call(sd, core, ioctl, 0, &vfe_params);
-		break;
-	case VFE_MSG_OUTPUT_IRQ:
-		D("%s Got OUTPUT_IRQ: Getting free buf id = %d",
-						__func__, vfe_id);
-		msm_mctl_reserve_free_buf(pmctl, NULL,
-					&buf_handle, &free_buf);
-		cfgcmd.cmd_type = CMD_CONFIG_FREE_BUF_ADDR;
-		cfgcmd.value = &vfe_id;
-		vfe_params.vfe_cfg = &cfgcmd;
-		vfe_params.data = (void *)&free_buf;
-		rc = v4l2_subdev_call(sd, core, ioctl, 0, &vfe_params);
-		break;
-	default:
-		pr_err("%s: Invalid vdata type: %d\n", __func__, vdata->type);
-		break;
-	}
-	return rc;
-}
-
-/*
- * This function executes in interrupt context.
- */
-static int msm_isp_notify_vfe(struct msm_cam_media_controller *pmctl,
-	struct v4l2_subdev *sd,	unsigned int notification,  void *arg)
-{
-	int rc = 0;
-	struct v4l2_event v4l2_evt;
-	struct msm_isp_event_ctrl *isp_event;
-	struct msm_free_buf buf;
-
-	if (!pmctl) {
-		pr_err("%s: no context in dsp callback.\n", __func__);
-		rc = -EINVAL;
-		return rc;
-	}
-
-	if (notification == NOTIFY_VFE_BUF_EVT)
-		return msm_isp_notify_VFE_BUF_EVT(pmctl, sd, arg);
-
-	if (notification == NOTIFY_VFE_PIX_SOF_COUNT)
-		return msm_isp_notify_VFE_SOF_COUNT_EVT(sd, arg);
-
-	isp_event = kzalloc(sizeof(struct msm_isp_event_ctrl), GFP_ATOMIC);
-	if (!isp_event) {
-		pr_err("%s Insufficient memory. return", __func__);
-		return -ENOMEM;
-	}
-
-	v4l2_evt.type = V4L2_EVENT_PRIVATE_START +
-					MSM_CAM_RESP_STAT_EVT_MSG;
-	v4l2_evt.id = 0;
-
-	*((uint32_t *)v4l2_evt.u.data) = (uint32_t)isp_event;
-
-	isp_event->resptype = MSM_CAM_RESP_STAT_EVT_MSG;
-	isp_event->isp_data.isp_msg.type = MSM_CAMERA_MSG;
-	isp_event->isp_data.isp_msg.len = 0;
-
-	switch (notification) {
-	case NOTIFY_ISP_MSG_EVT: {
-		struct isp_msg_event *isp_msg = (struct isp_msg_event *)arg;
-
-		isp_event->isp_data.isp_msg.msg_id = isp_msg->msg_id;
-		isp_event->isp_data.isp_msg.frame_id = isp_msg->sof_count;
-		getnstimeofday(&(isp_event->isp_data.isp_msg.timestamp));
-		break;
-	}
-	case NOTIFY_VFE_MSG_OUT: {
-		uint8_t msgid;
-		struct msm_cam_buf_handle buf_handle;
-		struct isp_msg_output *isp_output =
-				(struct isp_msg_output *)arg;
-		if (!isp_output->buf.inst_handle) {
-			switch (isp_output->output_id) {
-			case MSG_ID_OUTPUT_P:
-				msgid = VFE_MSG_OUTPUT_P;
-				break;
-			case MSG_ID_OUTPUT_V:
-				msgid = VFE_MSG_OUTPUT_V;
-				break;
-			case MSG_ID_OUTPUT_T:
-				msgid = VFE_MSG_OUTPUT_T;
-				break;
-			case MSG_ID_OUTPUT_S:
-				msgid = VFE_MSG_OUTPUT_S;
-				break;
-			case MSG_ID_OUTPUT_PRIMARY:
-				msgid = VFE_MSG_OUTPUT_PRIMARY;
-				break;
-			case MSG_ID_OUTPUT_SECONDARY:
-				msgid = VFE_MSG_OUTPUT_SECONDARY;
-				break;
-			case MSG_ID_OUTPUT_TERTIARY1:
-				msgid = VFE_MSG_OUTPUT_TERTIARY1;
-				break;
-			case MSG_ID_OUTPUT_TERTIARY2:
-				msgid = VFE_MSG_OUTPUT_TERTIARY2;
-				break;
-
-			default:
-				pr_err("%s: Invalid VFE output id: %d\n",
-					   __func__, isp_output->output_id);
-				rc = -EINVAL;
-				break;
-			}
-			if (!rc) {
-				buf_handle.buf_lookup_type =
-					BUF_LOOKUP_BY_IMG_MODE;
-				buf_handle.image_mode =
-				msm_isp_vfe_msg_to_img_mode(pmctl, msgid);
-			}
-		} else {
-			buf_handle.buf_lookup_type = BUF_LOOKUP_BY_INST_HANDLE;
-			buf_handle.inst_handle = isp_output->buf.inst_handle;
-		}
-		isp_event->isp_data.isp_msg.msg_id =
-			isp_output->output_id;
-		isp_event->isp_data.isp_msg.frame_id =
-			isp_output->frameCounter;
-		buf = isp_output->buf;
-		msm_mctl_buf_done(pmctl, &buf_handle,
-			&buf, isp_output->frameCounter);
-		}
-		break;
-	case NOTIFY_VFE_MSG_COMP_STATS: {
-		struct msm_stats_buf *stats = (struct msm_stats_buf *)arg;
-		struct msm_stats_buf *stats_buf = NULL;
-
-		isp_event->isp_data.isp_msg.msg_id = MSG_ID_STATS_COMPOSITE;
-		stats->aec.buff = msm_pmem_stats_ptov_lookup(pmctl,
-					stats->aec.buff, &(stats->aec.fd));
-		stats->awb.buff = msm_pmem_stats_ptov_lookup(pmctl,
-					stats->awb.buff, &(stats->awb.fd));
-		stats->af.buff = msm_pmem_stats_ptov_lookup(pmctl,
-					stats->af.buff, &(stats->af.fd));
-		stats->ihist.buff = msm_pmem_stats_ptov_lookup(pmctl,
-					stats->ihist.buff, &(stats->ihist.fd));
-		stats->rs.buff = msm_pmem_stats_ptov_lookup(pmctl,
-					stats->rs.buff, &(stats->rs.fd));
-		stats->cs.buff = msm_pmem_stats_ptov_lookup(pmctl,
-					stats->cs.buff, &(stats->cs.fd));
-
-		stats_buf = kmalloc(sizeof(struct msm_stats_buf), GFP_ATOMIC);
-		if (!stats_buf) {
-			pr_err("%s: out of memory.\n", __func__);
-			rc = -ENOMEM;
-		} else {
-			*stats_buf = *stats;
-			isp_event->isp_data.isp_msg.len	=
-				sizeof(struct msm_stats_buf);
-			isp_event->isp_data.isp_msg.data = stats_buf;
-		}
-		}
-		break;
-	case NOTIFY_VFE_MSG_STATS: {
-		struct msm_stats_buf stats;
-		struct isp_msg_stats *isp_stats = (struct isp_msg_stats *)arg;
-
-		memset(&stats, 0, sizeof(stats));
-		isp_event->isp_data.isp_msg.msg_id = isp_stats->id;
-		isp_event->isp_data.isp_msg.frame_id =
-			isp_stats->frameCounter;
-		stats.buffer = isp_stats->buffer;
-		stats.fd = isp_stats->fd;
-		/* buf_idx used for O(0) lookup */
-		stats.buf_idx = isp_stats->buf_idx;
-		switch (isp_stats->id) {
-		case MSG_ID_STATS_AEC:
-		case MSG_ID_STATS_BG:
-			stats.aec.buff = stats.buffer;
-			stats.aec.fd = stats.fd;
-			break;
-		case MSG_ID_STATS_BE:
-			stats.be.buff = stats.buffer;
-			stats.be.fd = stats.fd;
-			break;
-		case MSG_ID_STATS_AF:
-		case MSG_ID_STATS_BF:
-			stats.af.buff = stats.buffer;
-			stats.af.fd = stats.fd;
-			break;
-		case MSG_ID_STATS_AWB:
-			stats.awb.buff = stats.buffer;
-			stats.awb.fd = stats.fd;
-			break;
-		case MSG_ID_STATS_IHIST:
-			stats.ihist.buff = stats.buffer;
-			stats.ihist.fd = stats.fd;
-			break;
-		case MSG_ID_STATS_RS:
-			stats.rs.buff = stats.buffer;
-			stats.rs.fd = stats.fd;
-			break;
-		case MSG_ID_STATS_CS:
-			stats.cs.buff = stats.buffer;
-			stats.cs.fd = stats.fd;
-			break;
-		case MSG_ID_STATS_BHIST:
-			stats.skin.buff = stats.buffer;
-			stats.skin.fd = stats.fd;
-			break;
-		case MSG_ID_STATS_AWB_AEC:
-			break;
-		default:
-			pr_err("%s: Invalid msg type", __func__);
-			break;
-		}
-		if (!stats.buffer) {
-			pr_err("%s: msm_pmem_stats_ptov_lookup error\n",
-							__func__);
-			isp_event->isp_data.isp_msg.len = 0;
-			rc = -EFAULT;
-		} else {
-			struct msm_stats_buf *stats_buf =
-				kmalloc(sizeof(struct msm_stats_buf),
-							GFP_ATOMIC);
-			if (!stats_buf) {
-				pr_err("%s: out of memory. stats_id = %d\n",
-					__func__, isp_stats->id);
-				rc = -ENOMEM;
-			} else {
-				*stats_buf = stats;
-				isp_event->isp_data.isp_msg.len	=
-					sizeof(struct msm_stats_buf);
-				isp_event->isp_data.isp_msg.data = stats_buf;
-			}
-		}
-		}
-		break;
-	default:
-		pr_err("%s: Unsupport isp notification %d\n",
-			__func__, notification);
-		rc = -EINVAL;
-		break;
-	}
-
-	v4l2_event_queue(pmctl->config_device->config_stat_event_queue.pvdev,
-			 &v4l2_evt);
-
-	return rc;
-}
-
-int msm_isp_notify(struct msm_cam_media_controller *pmctl,
-	struct v4l2_subdev *sd,	unsigned int notification, void *arg)
-{
-	return msm_isp_notify_vfe(pmctl, sd, notification, arg);
-}
-EXPORT_SYMBOL(msm_isp_notify);
-
-static int msm_config_vfe(struct v4l2_subdev *sd,
-	struct msm_cam_media_controller *mctl, void __user *arg)
-{
-	struct msm_vfe_cfg_cmd cfgcmd;
-	struct axidata axi_data;
-
-	if (copy_from_user(&cfgcmd, arg, sizeof(cfgcmd))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-
-	memset(&axi_data, 0, sizeof(axi_data));
-	CDBG("%s: cmd_type %d\n", __func__, cfgcmd.cmd_type);
-	switch (cfgcmd.cmd_type) {
-	case CMD_STATS_BG_ENABLE:
-	case CMD_STATS_BE_ENABLE:
-	case CMD_STATS_BF_ENABLE:
-	case CMD_STATS_BHIST_ENABLE:
-	case CMD_STATS_AF_ENABLE:
-	case CMD_STATS_AEC_ENABLE:
-	case CMD_STATS_AWB_ENABLE:
-	case CMD_STATS_AEC_AWB_ENABLE:
-	case CMD_STATS_IHIST_ENABLE:
-	case CMD_STATS_RS_ENABLE:
-	case CMD_STATS_CS_ENABLE:
-		return msm_isp_subdev_ioctl(sd, &cfgcmd, NULL);
-	case CMD_GENERAL:
-	case CMD_STATS_DISABLE:
-		return msm_isp_subdev_ioctl(sd, &cfgcmd,
-							&axi_data);
-	default:
-		pr_err("%s: unknown command type %d\n",
-			__func__, cfgcmd.cmd_type);
-	}
-
-	return -EINVAL;
-}
-
-static int msm_axi_config(struct v4l2_subdev *sd,
-		struct msm_cam_media_controller *mctl, void __user *arg)
-{
-	struct msm_vfe_cfg_cmd cfgcmd;
-
-	if (copy_from_user(&cfgcmd, arg, sizeof(cfgcmd))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-
-	switch (cfgcmd.cmd_type) {
-	case CMD_AXI_CFG_PRIM:
-	case CMD_AXI_CFG_SEC:
-	case CMD_AXI_CFG_ZSL:
-	case CMD_RAW_PICT_AXI_CFG:
-	case CMD_AXI_CFG_PRIM_ALL_CHNLS:
-	case CMD_AXI_CFG_PRIM|CMD_AXI_CFG_SEC:
-	case CMD_AXI_CFG_PRIM|CMD_AXI_CFG_SEC_ALL_CHNLS:
-	case CMD_AXI_CFG_PRIM_ALL_CHNLS|CMD_AXI_CFG_SEC:
-	case CMD_AXI_START:
-	case CMD_AXI_STOP:
-	case CMD_AXI_RESET:
-	case CMD_AXI_CFG_TERT1:
-	case CMD_AXI_CFG_TERT2:
-		/* Dont need to pass buffer information.
-		 * subdev will get the buffer from media
-		 * controller free queue.
-		 */
-		return msm_isp_subdev_ioctl(sd, &cfgcmd, NULL);
-
-	default:
-		pr_err("%s: unknown command type %d\n",
-			__func__,
-			cfgcmd.cmd_type);
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-static int msm_put_stats_buffer(struct v4l2_subdev *sd,
-			struct msm_cam_media_controller *mctl, void __user *arg)
-{
-	int rc = -EIO;
-
-	struct msm_stats_buf buf;
-	unsigned long pphy;
-	struct msm_vfe_cfg_cmd cfgcmd;
-
-	if (copy_from_user(&buf, arg,
-				sizeof(struct msm_stats_buf))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-
-	CDBG("%s\n", __func__);
-	pphy = msm_pmem_stats_vtop_lookup(mctl, buf.buffer, buf.fd);
-
-	if (pphy != 0) {
-		if (buf.type == STAT_AF)
-			cfgcmd.cmd_type = CMD_STATS_AF_BUF_RELEASE;
-		else if (buf.type == STAT_AEC)
-			cfgcmd.cmd_type = CMD_STATS_AEC_BUF_RELEASE;
-		else if (buf.type == STAT_AWB)
-			cfgcmd.cmd_type = CMD_STATS_AWB_BUF_RELEASE;
-		else if (buf.type == STAT_IHIST)
-			cfgcmd.cmd_type = CMD_STATS_IHIST_BUF_RELEASE;
-		else if (buf.type == STAT_RS)
-			cfgcmd.cmd_type = CMD_STATS_RS_BUF_RELEASE;
-		else if (buf.type == STAT_CS)
-			cfgcmd.cmd_type = CMD_STATS_CS_BUF_RELEASE;
-		else if (buf.type == STAT_AEAW)
-			cfgcmd.cmd_type = CMD_STATS_BUF_RELEASE;
-		else if (buf.type == STAT_BG)
-			cfgcmd.cmd_type = CMD_STATS_BG_BUF_RELEASE;
-		else if (buf.type == STAT_BE)
-			cfgcmd.cmd_type = CMD_STATS_BE_BUF_RELEASE;
-		else if (buf.type == STAT_BF)
-			cfgcmd.cmd_type = CMD_STATS_BF_BUF_RELEASE;
-		else if (buf.type == STAT_BHIST)
-			cfgcmd.cmd_type = CMD_STATS_BHIST_BUF_RELEASE;
-
-		else {
-			pr_err("%s: invalid buf type %d\n",
-				__func__,
-				buf.type);
-			rc = -EINVAL;
-			goto put_done;
-		}
-
-		cfgcmd.value = (void *)&buf;
-
-		rc = msm_isp_subdev_ioctl(sd, &cfgcmd, &pphy);
-	} else {
-		pr_err("%s: NULL physical address\n", __func__);
-		rc = -EINVAL;
-	}
-
-put_done:
-	return rc;
-}
-
-static int msm_vfe_stats_buf_ioctl(struct v4l2_subdev *sd,
-	unsigned int cmd,
-	struct msm_cam_media_controller *mctl,
-	void __user *arg)
-{
-	struct msm_vfe_cfg_cmd cfgcmd;
-	int rc = 0;
-	v4l2_set_subdev_hostdata(sd, mctl);
-	switch (cmd) {
-	case MSM_CAM_IOCTL_STATS_REQBUF: {
-		struct msm_stats_reqbuf reqbuf;
-		if (copy_from_user(&reqbuf, arg,
-			sizeof(struct msm_stats_reqbuf))) {
-			ERR_COPY_FROM_USER();
-			return -EFAULT;
-		}
-	cfgcmd.cmd_type = VFE_CMD_STATS_REQBUF;
-	cfgcmd.value = (void *)&reqbuf;
-	cfgcmd.length = sizeof(struct msm_stats_reqbuf);
-	rc = msm_isp_subdev_ioctl(sd, &cfgcmd, (void *)mctl->client);
-	break;
-	}
-	case MSM_CAM_IOCTL_STATS_ENQUEUEBUF: {
-		struct msm_stats_buf_info buf_info;
-		if (copy_from_user(&buf_info, arg,
-			sizeof(struct msm_stats_buf_info))) {
-			ERR_COPY_FROM_USER();
-			return -EFAULT;
-		}
-	cfgcmd.cmd_type = VFE_CMD_STATS_ENQUEUEBUF;
-	cfgcmd.value = (void *)&buf_info;
-	cfgcmd.length = sizeof(struct msm_stats_buf_info);
-	rc = msm_isp_subdev_ioctl(sd, &cfgcmd, NULL);
-	break;
-	}
-	case MSM_CAM_IOCTL_STATS_FLUSH_BUFQ: {
-		struct msm_stats_flush_bufq bufq_info;
-		if (copy_from_user(&bufq_info, arg,
-			sizeof(struct msm_stats_flush_bufq))) {
-			ERR_COPY_FROM_USER();
-			return -EFAULT;
-		}
-	cfgcmd.cmd_type = VFE_CMD_STATS_FLUSH_BUFQ;
-	cfgcmd.value = (void *)&bufq_info;
-	cfgcmd.length = sizeof(struct msm_stats_flush_bufq);
-	rc = msm_isp_subdev_ioctl(sd, &cfgcmd, NULL);
-	break;
-	}
-	case MSM_CAM_IOCTL_STATS_UNREG_BUF: {
-		struct msm_stats_reqbuf reqbuf;
-		if (copy_from_user(&reqbuf, arg,
-			sizeof(struct msm_stats_reqbuf))) {
-			ERR_COPY_FROM_USER();
-			return -EFAULT;
-		}
-	cfgcmd.cmd_type = VFE_CMD_STATS_UNREGBUF;
-	cfgcmd.value = (void *)&reqbuf;
-	cfgcmd.length = sizeof(struct msm_stats_reqbuf);
-	rc = msm_isp_subdev_ioctl(sd, &cfgcmd, (void *)mctl->client);
-	break;
-	}
-	default:
-		rc = -1;
-	break;
-	}
-	CDBG("%s\n", __func__);
-	return rc;
-}
-/* config function simliar to origanl msm_ioctl_config*/
-int msm_isp_config(struct msm_cam_media_controller *pmctl,
-			 unsigned int cmd, unsigned long arg)
-{
-
-	int rc = -EINVAL;
-	void __user *argp = (void __user *)arg;
-	struct v4l2_subdev *sd;
-	if (!pmctl->vfe_sdev) {
-		pr_err("%s vfe subdev is NULL\n", __func__);
-		return -ENXIO;
-	}
-	sd = pmctl->vfe_sdev;
-	D("%s: cmd %d\n", __func__, _IOC_NR(cmd));
-	switch (cmd) {
-	case MSM_CAM_IOCTL_CONFIG_VFE:
-		/* Coming from config thread for update */
-		rc = msm_config_vfe(sd, pmctl, argp);
-		break;
-
-	case MSM_CAM_IOCTL_AXI_CONFIG:
-		D("Received MSM_CAM_IOCTL_AXI_CONFIG\n");
-		rc = msm_axi_config(sd, pmctl, argp);
-		break;
-
-	case MSM_CAM_IOCTL_RELEASE_STATS_BUFFER:
-		rc = msm_put_stats_buffer(sd, pmctl, argp);
-		break;
-
-	case MSM_CAM_IOCTL_STATS_REQBUF:
-	case MSM_CAM_IOCTL_STATS_ENQUEUEBUF:
-	case MSM_CAM_IOCTL_STATS_FLUSH_BUFQ:
-	case MSM_CAM_IOCTL_STATS_UNREG_BUF:
-		rc = msm_vfe_stats_buf_ioctl(sd, cmd, pmctl, argp);
-		break;
-
-	default:
-		break;
-	}
-
-	D("%s: cmd %d DONE\n", __func__, _IOC_NR(cmd));
-
-	return rc;
-}
-EXPORT_SYMBOL(msm_isp_config);
-
-int msm_isp_subdev_ioctl(struct v4l2_subdev *isp_subdev,
-	struct msm_vfe_cfg_cmd *cfgcmd, void *data)
-{
-	struct msm_camvfe_params vfe_params;
-	vfe_params.vfe_cfg = cfgcmd;
-	vfe_params.data = data;
-	return v4l2_subdev_call(isp_subdev, core, ioctl, 0, &vfe_params);
-}
diff --git a/drivers/media/platform/msm/camera_v1/msm_mctl.c b/drivers/media/platform/msm/camera_v1/msm_mctl.c
deleted file mode 100644
index 95e889d..0000000
--- a/drivers/media/platform/msm/camera_v1/msm_mctl.c
+++ /dev/null
@@ -1,1753 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundataion. 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.
- *
- */
-
-#include <linux/workqueue.h>
-#include <linux/delay.h>
-#include <linux/types.h>
-#include <linux/list.h>
-#include <linux/ioctl.h>
-#include <linux/spinlock.h>
-#include <linux/videodev2.h>
-#include <linux/proc_fs.h>
-#include <linux/vmalloc.h>
-#include <linux/wakelock.h>
-
-#include <media/v4l2-dev.h>
-#include <media/v4l2-ioctl.h>
-#include <media/v4l2-device.h>
-
-
-
-#include "msm.h"
-#include "msm_cam_server.h"
-#include "msm_csid.h"
-#include "msm_csic.h"
-#include "msm_csiphy.h"
-#include "msm_ispif.h"
-#include "msm_sensor.h"
-#include "msm_actuator.h"
-#include "msm_vpe.h"
-#include "msm_vfe32.h"
-#include "msm_camera_eeprom.h"
-#include "msm_csi_register.h"
-#include "msm_flash.h"
-
-#ifdef CONFIG_MSM_CAMERA_DEBUG
-#define D(fmt, args...) pr_debug("msm_mctl: " fmt, ##args)
-#else
-#define D(fmt, args...) do {} while (0)
-#endif
-
-#define MSM_V4L2_SWFI_LATENCY 3
-/* VFE required buffer number for streaming */
-static struct msm_isp_color_fmt msm_isp_formats[] = {
-	{
-	.name	   = "NV12YUV",
-	.depth	  = 12,
-	.bitsperpxl = 8,
-	.fourcc	 = V4L2_PIX_FMT_NV12,
-	.pxlcode	= V4L2_MBUS_FMT_YUYV8_2X8, /* YUV sensor */
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	},
-	{
-	.name	   = "NV21YUV",
-	.depth	  = 12,
-	.bitsperpxl = 8,
-	.fourcc	 = V4L2_PIX_FMT_NV21,
-	.pxlcode	= V4L2_MBUS_FMT_YUYV8_2X8, /* YUV sensor */
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	},
-	{
-	.name	   = "NV12BAYER",
-	.depth	  = 8,
-	.bitsperpxl = 8,
-	.fourcc	 = V4L2_PIX_FMT_NV12,
-	.pxlcode	= V4L2_MBUS_FMT_SBGGR10_1X10, /* Bayer sensor */
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	},
-	{
-	.name	   = "NV21BAYER",
-	.depth	  = 8,
-	.bitsperpxl = 8,
-	.fourcc	 = V4L2_PIX_FMT_NV21,
-	.pxlcode	= V4L2_MBUS_FMT_SBGGR10_1X10, /* Bayer sensor */
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	},
-	{
-	.name	   = "NV16BAYER",
-	.depth	  = 8,
-	.bitsperpxl = 8,
-	.fourcc	 = V4L2_PIX_FMT_NV16,
-	.pxlcode	= V4L2_MBUS_FMT_SBGGR10_1X10, /* Bayer sensor */
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	},
-	{
-	.name	   = "NV61BAYER",
-	.depth	  = 8,
-	.bitsperpxl = 8,
-	.fourcc	 = V4L2_PIX_FMT_NV61,
-	.pxlcode	= V4L2_MBUS_FMT_SBGGR10_1X10, /* Bayer sensor */
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	},
-	{
-	.name	   = "NV21BAYER",
-	.depth	  = 8,
-	.bitsperpxl = 8,
-	.fourcc	 = V4L2_PIX_FMT_NV21,
-	.pxlcode	= V4L2_MBUS_FMT_SGRBG10_1X10, /* Bayer sensor */
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	},
-	{
-	.name	   = "YU12BAYER",
-	.depth	  = 8,
-	.bitsperpxl = 8,
-	.fourcc	 = V4L2_PIX_FMT_YUV420M,
-	.pxlcode	= V4L2_MBUS_FMT_SBGGR10_1X10, /* Bayer sensor */
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	},
-	{
-	.name	   = "RAWBAYER",
-	.depth	  = 10,
-	.bitsperpxl = 10,
-	.fourcc	 = V4L2_PIX_FMT_SBGGR10,
-	.pxlcode	= V4L2_MBUS_FMT_SBGGR10_1X10, /* Bayer sensor */
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	},
-	{
-	.name	   = "RAWBAYER",
-	.depth	  = 10,
-	.bitsperpxl = 10,
-	.fourcc	 = V4L2_PIX_FMT_SBGGR10,
-	.pxlcode	= V4L2_MBUS_FMT_SGRBG10_1X10, /* Bayer sensor */
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	},
-	{
-	.name	   = "YUYV",
-	.depth	  = 16,
-	.bitsperpxl = 16,
-	.fourcc	 = V4L2_PIX_FMT_YUYV,
-	.pxlcode	= V4L2_MBUS_FMT_YUYV8_2X8, /* YUV sensor */
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	},
-	{
-	.name	   = "SAEC",
-	.depth	  = 16,
-	.bitsperpxl = 16,
-	.fourcc	 = V4L2_PIX_FMT_STATS_AE,
-	.pxlcode	= V4L2_MBUS_FMT_SBGGR10_1X10, /* YUV sensor */
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	},
-	{
-	.name	   = "SAWB",
-	.depth	  = 16,
-	.bitsperpxl = 16,
-	.fourcc	 = V4L2_PIX_FMT_STATS_AWB,
-	.pxlcode	= V4L2_MBUS_FMT_SBGGR10_1X10, /* YUV sensor */
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	},
-	{
-	.name	   = "SAFC",
-	.depth	  = 16,
-	.bitsperpxl = 16,
-	.fourcc	 = V4L2_PIX_FMT_STATS_AF,
-	.pxlcode	= V4L2_MBUS_FMT_SBGGR10_1X10, /* YUV sensor */
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	},
-	{
-	.name      = "SHST",
-	.depth    = 16,
-	.bitsperpxl = 16,
-	.fourcc  = V4L2_PIX_FMT_STATS_IHST,
-	.pxlcode        = V4L2_MBUS_FMT_SBGGR10_1X10, /* YUV sensor */
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	},
-};
-
-static int msm_get_sensor_info(
-	struct msm_cam_media_controller *mctl,
-	void __user *arg)
-{
-	int rc = 0;
-	struct msm_camsensor_info info;
-	struct msm_camera_sensor_info *sdata;
-	struct msm_cam_v4l2_device *pcam = mctl->pcam_ptr;
-	if (copy_from_user(&info,
-			arg,
-			sizeof(struct msm_camsensor_info))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-
-	sdata = mctl->sdata;
-	D("%s: sensor_name %s\n", __func__, sdata->sensor_name);
-
-	memcpy(&info.name[0], sdata->sensor_name, MAX_SENSOR_NAME);
-	info.flash_enabled = sdata->flash_data->flash_type !=
-					MSM_CAMERA_FLASH_NONE;
-	info.pxlcode = pcam->usr_fmts[0].pxlcode;
-	info.flashtype = sdata->flash_type; /* two flash_types here? */
-	info.camera_type = sdata->camera_type;
-	/* sensor_type needed to add YUV/SOC in probing */
-	info.sensor_type = sdata->sensor_type;
-	info.mount_angle = sdata->sensor_platform_info->mount_angle;
-	info.actuator_enabled = sdata->actuator_info ? 1 : 0;
-	info.strobe_flash_enabled = sdata->strobe_flash_data ? 1 : 0;
-	info.ispif_supported = mctl->ispif_sdev ? 1 : 0;
-
-	/* copy back to user space */
-	if (copy_to_user((void *)arg,
-				&info,
-				sizeof(struct msm_camsensor_info))) {
-		ERR_COPY_TO_USER();
-		rc = -EFAULT;
-	}
-	return rc;
-}
-
-static int msm_mctl_set_vfe_output_mode(struct msm_cam_media_controller
-					*p_mctl, void __user *arg)
-{
-	int rc = 0;
-	if (copy_from_user(&p_mctl->vfe_output_mode,
-		(void __user *)arg, sizeof(p_mctl->vfe_output_mode))) {
-		pr_err("%s Copy from user failed ", __func__);
-		rc = -EFAULT;
-	} else {
-		pr_debug("%s: mctl=0x%p, vfe output mode =0x%x\n",
-		  __func__, p_mctl, p_mctl->vfe_output_mode);
-	}
-	return rc;
-}
-
-static uint8_t msm_sensor_state_check(
-	struct msm_cam_media_controller *p_mctl)
-{
-	struct msm_sensor_ctrl_t *s_ctrl = NULL;
-	if (!p_mctl)
-		return 0;
-	if (!p_mctl->sensor_sdev)
-		return 0;
-	s_ctrl = get_sctrl(p_mctl->sensor_sdev);
-	if (s_ctrl->sensor_state == MSM_SENSOR_POWER_UP)
-		return 1;
-	return 0;
-}
-
-/* called by the server or the config nodes to handle user space
-	commands*/
-static int msm_mctl_cmd(struct msm_cam_media_controller *p_mctl,
-			unsigned int cmd, unsigned long arg)
-{
-	int rc = -EINVAL;
-	void __user *argp = (void __user *)arg;
-	if (!p_mctl) {
-		pr_err("%s: param is NULL", __func__);
-		return -EINVAL;
-	}
-	D("%s:%d: cmd %d\n", __func__, __LINE__, cmd);
-
-	/* ... call sensor, ISPIF or VEF subdev*/
-	switch (cmd) {
-		/* sensor config*/
-	case MSM_CAM_IOCTL_GET_SENSOR_INFO:
-			rc = msm_get_sensor_info(p_mctl, argp);
-			break;
-
-	case MSM_CAM_IOCTL_SENSOR_IO_CFG:
-		rc = v4l2_subdev_call(p_mctl->sensor_sdev,
-			core, ioctl, VIDIOC_MSM_SENSOR_CFG, argp);
-			break;
-
-	case MSM_CAM_IOCTL_OEM:
-	 rc = v4l2_subdev_call(p_mctl->sensor_sdev,
-		 core, ioctl, VIDIOC_MSM_SENSOR_CFG, argp);
-		 break;
-
-	case MSM_CAM_IOCTL_SENSOR_V4l2_S_CTRL: {
-			struct v4l2_control v4l2_ctrl;
-			CDBG("subdev call\n");
-			if (copy_from_user(&v4l2_ctrl,
-				(void *)argp,
-				sizeof(struct v4l2_control))) {
-				CDBG("copy fail\n");
-				return -EFAULT;
-			}
-			CDBG("subdev call ok\n");
-			rc = v4l2_subdev_call(p_mctl->sensor_sdev,
-				core, s_ctrl, &v4l2_ctrl);
-			break;
-	}
-
-	case MSM_CAM_IOCTL_SENSOR_V4l2_QUERY_CTRL: {
-			struct v4l2_queryctrl v4l2_qctrl;
-			CDBG("query called\n");
-			if (copy_from_user(&v4l2_qctrl,
-				(void *)argp,
-				sizeof(struct v4l2_queryctrl))) {
-				CDBG("copy fail\n");
-				rc = -EFAULT;
-				break;
-			}
-			rc = v4l2_subdev_call(p_mctl->sensor_sdev,
-				core, queryctrl, &v4l2_qctrl);
-			if (rc < 0) {
-				rc = -EFAULT;
-				break;
-			}
-			if (copy_to_user((void *)argp,
-					 &v4l2_qctrl,
-					 sizeof(struct v4l2_queryctrl))) {
-				rc = -EFAULT;
-			}
-			break;
-	}
-
-	case MSM_CAM_IOCTL_GET_ACTUATOR_INFO: {
-		struct msm_actuator_cfg_data cdata;
-		if (copy_from_user(&cdata,
-			(void *)argp,
-			sizeof(struct msm_actuator_cfg_data))) {
-			ERR_COPY_FROM_USER();
-			return -EFAULT;
-		}
-		cdata.is_af_supported = 0;
-		rc = 0;
-
-		if (p_mctl->act_sdev) {
-			struct msm_camera_sensor_info *sdata;
-
-			sdata = p_mctl->sdata;
-			CDBG("%s: Act_cam_Name %d\n", __func__,
-				sdata->actuator_info->cam_name);
-
-			cdata.is_af_supported = 1;
-			cdata.cfg.cam_name =
-				(enum af_camera_name)sdata->
-				actuator_info->cam_name;
-
-			CDBG("%s: Af Support:%d\n", __func__,
-				cdata.is_af_supported);
-			CDBG("%s: Act_name:%d\n", __func__, cdata.cfg.cam_name);
-
-		}
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct msm_actuator_cfg_data))) {
-			ERR_COPY_TO_USER();
-			rc = -EFAULT;
-		}
-		break;
-	}
-
-	case MSM_CAM_IOCTL_ACTUATOR_IO_CFG: {
-		struct msm_actuator_cfg_data act_data;
-		if (p_mctl->act_sdev) {
-			rc = v4l2_subdev_call(p_mctl->act_sdev,
-				core, ioctl, VIDIOC_MSM_ACTUATOR_CFG, argp);
-		} else {
-			rc = copy_from_user(
-				&act_data,
-				(void *)argp,
-				sizeof(struct msm_actuator_cfg_data));
-			if (rc != 0) {
-				rc = -EFAULT;
-				break;
-			}
-			act_data.is_af_supported = 0;
-			rc = copy_to_user((void *)argp,
-					 &act_data,
-					 sizeof(struct msm_actuator_cfg_data));
-			if (rc != 0) {
-				rc = -EFAULT;
-				break;
-			}
-		}
-		break;
-	}
-
-	case MSM_CAM_IOCTL_EEPROM_IO_CFG: {
-		struct msm_eeprom_cfg_data eeprom_data;
-		if (p_mctl->eeprom_sdev) {
-			rc = v4l2_subdev_call(p_mctl->eeprom_sdev,
-				core, ioctl, VIDIOC_MSM_EEPROM_CFG, argp);
-		} else {
-			rc = copy_from_user(
-				&eeprom_data,
-				(void *)argp,
-				sizeof(struct msm_eeprom_cfg_data));
-			if (rc != 0) {
-				rc = -EFAULT;
-				break;
-			}
-			eeprom_data.is_eeprom_supported = 0;
-			rc = copy_to_user((void *)argp,
-					 &eeprom_data,
-					 sizeof(struct msm_eeprom_cfg_data));
-			if (rc != 0) {
-				rc = -EFAULT;
-				break;
-			}
-		}
-		break;
-	}
-
-	case MSM_CAM_IOCTL_GET_KERNEL_SYSTEM_TIME: {
-		struct timeval timestamp;
-		if (copy_from_user(&timestamp, argp, sizeof(timestamp))) {
-			ERR_COPY_FROM_USER();
-			rc = -EFAULT;
-		} else {
-			msm_mctl_gettimeofday(&timestamp);
-			rc = copy_to_user((void *)argp,
-				 &timestamp, sizeof(timestamp));
-		}
-		break;
-	}
-
-	case MSM_CAM_IOCTL_FLASH_CTRL: {
-		if (p_mctl->flash_sdev && msm_sensor_state_check(p_mctl))
-			rc = v4l2_subdev_call(p_mctl->flash_sdev,
-				core, ioctl, VIDIOC_MSM_FLASH_CFG, argp);
-		break;
-	}
-	case MSM_CAM_IOCTL_PICT_PP:
-		rc = msm_mctl_set_pp_key(p_mctl, (void __user *)arg);
-		break;
-	case MSM_CAM_IOCTL_PICT_PP_DIVERT_DONE:
-		rc = msm_mctl_pp_divert_done(p_mctl, (void __user *)arg);
-		break;
-	case MSM_CAM_IOCTL_PICT_PP_DONE:
-		rc = msm_mctl_pp_done(p_mctl, (void __user *)arg);
-		break;
-	case MSM_CAM_IOCTL_MCTL_POST_PROC:
-		rc = msm_mctl_pp_ioctl(p_mctl, cmd, arg);
-		break;
-	case MSM_CAM_IOCTL_RESERVE_FREE_FRAME:
-		rc = msm_mctl_pp_reserve_free_frame(p_mctl,
-			(void __user *)arg);
-		break;
-	case MSM_CAM_IOCTL_RELEASE_FREE_FRAME:
-		rc = msm_mctl_pp_release_free_frame(p_mctl,
-			(void __user *)arg);
-		break;
-	case MSM_CAM_IOCTL_SET_VFE_OUTPUT_TYPE:
-		rc = msm_mctl_set_vfe_output_mode(p_mctl,
-		  (void __user *)arg);
-		break;
-	case MSM_CAM_IOCTL_MCTL_DIVERT_DONE:
-		rc = msm_mctl_pp_mctl_divert_done(p_mctl,
-			(void __user *)arg);
-		break;
-			/* ISFIF config*/
-	case MSM_CAM_IOCTL_AXI_CONFIG:
-		if (p_mctl->axi_sdev) {
-			v4l2_set_subdev_hostdata(p_mctl->axi_sdev, p_mctl);
-			rc = v4l2_subdev_call(p_mctl->axi_sdev, core, ioctl,
-				VIDIOC_MSM_AXI_CFG, (void __user *)arg);
-		} else
-			rc = p_mctl->isp_config(p_mctl, cmd, arg);
-		break;
-	case MSM_CAM_IOCTL_ISPIF_IO_CFG:
-		rc = v4l2_subdev_call(p_mctl->ispif_sdev,
-			core, ioctl, VIDIOC_MSM_ISPIF_CFG, argp);
-		break;
-
-	case MSM_CAM_IOCTL_CSIPHY_IO_CFG:
-		if (p_mctl->csiphy_sdev)
-			rc = v4l2_subdev_call(p_mctl->csiphy_sdev,
-				core, ioctl, VIDIOC_MSM_CSIPHY_CFG, argp);
-		break;
-
-	case MSM_CAM_IOCTL_CSIC_IO_CFG:
-		if (p_mctl->csic_sdev)
-			rc = v4l2_subdev_call(p_mctl->csic_sdev,
-				core, ioctl, VIDIOC_MSM_CSIC_CFG, argp);
-		break;
-
-	case MSM_CAM_IOCTL_CSID_IO_CFG:
-		if (p_mctl->csid_sdev)
-			rc = v4l2_subdev_call(p_mctl->csid_sdev,
-				core, ioctl, VIDIOC_MSM_CSID_CFG, argp);
-		break;
-
-	case MSM_CAM_IOCTL_AXI_INIT:
-		if (p_mctl->axi_sdev) {
-			v4l2_set_subdev_hostdata(p_mctl->axi_sdev, p_mctl);
-			rc = v4l2_subdev_call(p_mctl->axi_sdev, core, ioctl,
-				VIDIOC_MSM_AXI_INIT, (void __user *)arg);
-		}
-		break;
-
-	case MSM_CAM_IOCTL_AXI_RELEASE:
-		if (p_mctl->axi_sdev) {
-			v4l2_set_subdev_hostdata(p_mctl->axi_sdev, p_mctl);
-			rc = v4l2_subdev_call(p_mctl->axi_sdev, core, ioctl,
-				VIDIOC_MSM_AXI_RELEASE, NULL);
-		}
-		break;
-
-	default:
-		/* ISP config*/
-		D("%s:%d: go to default. Calling msm_isp_config\n",
-			__func__, __LINE__);
-		rc = p_mctl->isp_config(p_mctl, cmd, arg);
-		break;
-	}
-	D("%s: !!! cmd = %d, rc = %d\n",
-		__func__, _IOC_NR(cmd), rc);
-	return rc;
-}
-
-static int msm_mctl_open(struct msm_cam_media_controller *p_mctl,
-				 const char *const apps_id)
-{
-	int rc = 0;
-	struct msm_sensor_ctrl_t *s_ctrl = get_sctrl(p_mctl->sensor_sdev);
-	struct msm_camera_sensor_info *sinfo =
-		(struct msm_camera_sensor_info *) s_ctrl->sensordata;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-	struct msm_camera_sensor_flash_data *flash_data = sinfo->flash_data;
-	uint8_t csid_core;
-	D("%s\n", __func__);
-	if (!p_mctl) {
-		pr_err("%s: param is NULL", __func__);
-		return -EINVAL;
-	}
-
-	mutex_lock(&p_mctl->lock);
-	/* open sub devices - once only*/
-	if (!p_mctl->opencnt) {
-		struct msm_sensor_csi_info csi_info;
-		wake_lock(&p_mctl->wake_lock);
-
-		csid_core = camdev->csid_core;
-		rc = msm_mctl_find_sensor_subdevs(p_mctl, camdev->csiphy_core,
-			csid_core);
-		if (rc < 0) {
-			pr_err("%s: msm_mctl_find_sensor_subdevs failed:%d\n",
-				__func__, rc);
-			goto register_sdev_failed;
-		}
-
-		/* then sensor - move sub dev later */
-		rc = v4l2_subdev_call(p_mctl->sensor_sdev, core, s_power, 1);
-		if (rc < 0) {
-			pr_err("%s: sensor powerup failed: %d\n", __func__, rc);
-			goto sensor_sdev_failed;
-		}
-
-		if (p_mctl->act_sdev)
-			rc = v4l2_subdev_call(p_mctl->act_sdev,
-				core, s_power, 1);
-		if (rc < 0) {
-			pr_err("%s: act power failed:%d\n", __func__, rc);
-			goto act_power_up_failed;
-		}
-
-		if (p_mctl->csic_sdev)
-			csi_info.is_csic = 1;
-		else
-			csi_info.is_csic = 0;
-		rc = v4l2_subdev_call(p_mctl->sensor_sdev, core, ioctl,
-				VIDIOC_MSM_SENSOR_CSID_INFO, &csi_info);
-		if (rc < 0) {
-			pr_err("%s: sensor csi version failed %d\n",
-			__func__, rc);
-			goto msm_csi_version;
-		}
-
-		if (!p_mctl->flash_sdev && flash_data) {
-			if ((flash_data->flash_type == MSM_CAMERA_FLASH_LED) &&
-				(flash_data->flash_src_index >= 0))
-				msm_mctl_find_flash_subdev(p_mctl,
-					flash_data->flash_src_index);
-		}
-
-		if (p_mctl->flash_sdev && p_mctl->sdata->flash_data &&
-			p_mctl->sdata->flash_data->flash_type !=
-			MSM_CAMERA_FLASH_NONE) {
-			rc = v4l2_subdev_call(p_mctl->flash_sdev, core, ioctl,
-					VIDIOC_MSM_FLASH_LED_DATA_CFG,
-					p_mctl->sdata->flash_data);
-			if (rc < 0) {
-				pr_err("%s: set flash led failed %d\n",
-				__func__, rc);
-			}
-		}
-
-		if (p_mctl->flash_sdev && p_mctl->sdata->strobe_flash_data) {
-			rc = v4l2_subdev_call(p_mctl->flash_sdev, core, ioctl,
-					VIDIOC_MSM_FLASH_STROBE_DATA_CFG,
-					p_mctl->sdata->strobe_flash_data);
-			if (rc < 0) {
-				pr_err("%s: set strobe flash led failed %d\n",
-				__func__, rc);
-			}
-		}
-
-		pm_qos_add_request(&p_mctl->pm_qos_req_list,
-			PM_QOS_CPU_DMA_LATENCY, PM_QOS_DEFAULT_VALUE);
-		pm_qos_update_request(&p_mctl->pm_qos_req_list,
-			MSM_V4L2_SWFI_LATENCY);
-
-		p_mctl->apps_id = apps_id;
-		p_mctl->opencnt++;
-	} else {
-		D("%s: camera is already open", __func__);
-	}
-	mutex_unlock(&p_mctl->lock);
-	return rc;
-
-msm_csi_version:
-act_power_up_failed:
-	if (v4l2_subdev_call(p_mctl->sensor_sdev, core, s_power, 0) < 0)
-		pr_err("%s: sensor powerdown failed: %d\n", __func__, rc);
-sensor_sdev_failed:
-register_sdev_failed:
-	wake_unlock(&p_mctl->wake_lock);
-	mutex_unlock(&p_mctl->lock);
-	return rc;
-}
-
-static void msm_mctl_release(struct msm_cam_media_controller *p_mctl)
-{
-	struct msm_sensor_ctrl_t *s_ctrl = get_sctrl(p_mctl->sensor_sdev);
-	struct msm_camera_sensor_info *sinfo =
-		(struct msm_camera_sensor_info *) s_ctrl->sensordata;
-	v4l2_subdev_call(p_mctl->sensor_sdev, core, ioctl,
-		VIDIOC_MSM_SENSOR_RELEASE, NULL);
-
-	if (p_mctl->csic_sdev) {
-		v4l2_subdev_call(p_mctl->csic_sdev, core, ioctl,
-			VIDIOC_MSM_CSIC_RELEASE, NULL);
-	}
-
-	if (p_mctl->vpe_sdev) {
-		v4l2_subdev_call(p_mctl->vpe_sdev, core, ioctl,
-			VIDIOC_MSM_VPE_RELEASE, NULL);
-	}
-
-	if (p_mctl->axi_sdev) {
-		v4l2_set_subdev_hostdata(p_mctl->axi_sdev, p_mctl);
-		v4l2_subdev_call(p_mctl->axi_sdev, core, ioctl,
-			VIDIOC_MSM_AXI_RELEASE, NULL);
-	}
-
-	if (p_mctl->csid_sdev) {
-		v4l2_subdev_call(p_mctl->csid_sdev, core, ioctl,
-			VIDIOC_MSM_CSID_RELEASE, NULL);
-	}
-
-	if (p_mctl->csiphy_sdev) {
-		v4l2_subdev_call(p_mctl->csiphy_sdev, core, ioctl,
-			VIDIOC_MSM_CSIPHY_RELEASE,
-			sinfo->sensor_platform_info->csi_lane_params);
-	}
-
-	if (p_mctl->act_sdev) {
-		v4l2_subdev_call(p_mctl->act_sdev, core, s_power, 0);
-		p_mctl->act_sdev = NULL;
-	}
-
-	v4l2_subdev_call(p_mctl->sensor_sdev, core, s_power, 0);
-
-	pm_qos_update_request(&p_mctl->pm_qos_req_list,
-				PM_QOS_DEFAULT_VALUE);
-	pm_qos_remove_request(&p_mctl->pm_qos_req_list);
-
-	wake_unlock(&p_mctl->wake_lock);
-}
-
-int msm_mctl_init_user_formats(struct msm_cam_v4l2_device *pcam)
-{
-	struct v4l2_subdev *sd = pcam->sensor_sdev;
-	enum v4l2_mbus_pixelcode pxlcode;
-	int numfmt_sensor = 0;
-	int numfmt = 0;
-	int rc = 0;
-	int i, j;
-
-	D("%s\n", __func__);
-	while (!v4l2_subdev_call(sd, video, enum_mbus_fmt, numfmt_sensor,
-								&pxlcode))
-		numfmt_sensor++;
-
-	D("%s, numfmt_sensor = %d\n", __func__, numfmt_sensor);
-	if (!numfmt_sensor)
-		return -ENXIO;
-
-	pcam->usr_fmts = vmalloc(numfmt_sensor * ARRAY_SIZE(msm_isp_formats) *
-				sizeof(struct msm_isp_color_fmt));
-	if (!pcam->usr_fmts)
-		return -ENOMEM;
-
-	/* from sensor to ISP.. fill the data structure */
-	for (i = 0; i < numfmt_sensor; i++) {
-		rc = v4l2_subdev_call(sd, video, enum_mbus_fmt, i, &pxlcode);
-		D("rc is  %d\n", rc);
-		if (rc < 0) {
-			vfree(pcam->usr_fmts);
-			return rc;
-		}
-
-		for (j = 0; j < ARRAY_SIZE(msm_isp_formats); j++) {
-			/* find the corresponding format */
-			if (pxlcode == msm_isp_formats[j].pxlcode) {
-				pcam->usr_fmts[numfmt] = msm_isp_formats[j];
-				D("pcam->usr_fmts=0x%x\n", (u32)pcam->usr_fmts);
-				D("format pxlcode 0x%x (0x%x) found\n",
-					  pcam->usr_fmts[numfmt].pxlcode,
-					  pcam->usr_fmts[numfmt].fourcc);
-				numfmt++;
-			}
-		}
-	}
-
-	pcam->num_fmts = numfmt;
-
-	if (numfmt == 0) {
-		pr_err("%s: No supported formats.\n", __func__);
-		vfree(pcam->usr_fmts);
-		return -EINVAL;
-	}
-
-	D("Found %d supported formats.\n", pcam->num_fmts);
-	/* set the default pxlcode, in any case, it will be set through
-	 * setfmt */
-	return 0;
-}
-
-/* this function plug in the implementation of a v4l2_subdev */
-int msm_mctl_init(struct msm_cam_v4l2_device *pcam)
-{
-	struct msm_cam_media_controller *pmctl = NULL;
-	D("%s\n", __func__);
-	if (!pcam) {
-		pr_err("%s: param is NULL", __func__);
-		return -EINVAL;
-	}
-	pcam->mctl_handle = msm_cam_server_get_mctl_handle();
-	if (pcam->mctl_handle == 0) {
-		pr_err("%s: cannot get mctl handle", __func__);
-		return -EINVAL;
-	}
-
-	pmctl = msm_cam_server_get_mctl(pcam->mctl_handle);
-	if (!pmctl) {
-		pr_err("%s: invalid mctl controller", __func__);
-		return -EINVAL;
-	}
-
-	wake_lock_init(&pmctl->wake_lock, WAKE_LOCK_SUSPEND, "msm_camera");
-	mutex_init(&pmctl->lock);
-	pmctl->opencnt = 0;
-
-	/* init module operations*/
-	pmctl->mctl_open = msm_mctl_open;
-	pmctl->mctl_cmd = msm_mctl_cmd;
-	pmctl->mctl_release = msm_mctl_release;
-	pmctl->isp_config = msm_isp_config;
-	pmctl->isp_notify = msm_isp_notify;
-
-	/* init mctl buf */
-	msm_mctl_buf_init(pcam);
-	memset(&pmctl->pp_info, 0, sizeof(pmctl->pp_info));
-	pmctl->vfe_output_mode = 0;
-	spin_lock_init(&pmctl->pp_info.lock);
-
-	pmctl->flash_sdev = pcam->flash_sdev;
-	pmctl->act_sdev = pcam->act_sdev;
-	pmctl->eeprom_sdev = pcam->eeprom_sdev;
-	pmctl->sensor_sdev = pcam->sensor_sdev;
-	pmctl->sdata = pcam->sdata;
-	v4l2_set_subdev_hostdata(pcam->sensor_sdev, pmctl);
-
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-	pmctl->client = msm_ion_client_create(-1, "camera");
-	kref_init(&pmctl->refcount);
-#endif
-
-	return 0;
-}
-
-int msm_mctl_free(struct msm_cam_v4l2_device *pcam)
-{
-	int rc = 0;
-	struct msm_cam_media_controller *pmctl = NULL;
-	D("%s\n", __func__);
-
-	pmctl = msm_cam_server_get_mctl(pcam->mctl_handle);
-	if (!pmctl) {
-		pr_err("%s: invalid mctl controller", __func__);
-		return -EINVAL;
-	}
-
-	mutex_destroy(&pmctl->lock);
-	wake_lock_destroy(&pmctl->wake_lock);
-	/*clear out mctl fields*/
-	memset(pmctl, 0, sizeof(struct msm_cam_media_controller));
-	msm_cam_server_free_mctl(pcam->mctl_handle);
-	return rc;
-}
-
-/* mctl node v4l2_file_operations */
-static int msm_mctl_dev_open(struct file *f)
-{
-	int rc = -EINVAL, i;
-	/* get the video device */
-	struct msm_cam_v4l2_device *pcam  = NULL;
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	struct msm_cam_media_controller *pmctl;
-
-	if (f == NULL) {
-		pr_err("%s :: cannot open video driver data", __func__);
-		return rc;
-	}
-	pcam = video_drvdata(f);
-
-	if (!pcam) {
-		pr_err("%s NULL pointer passed in!\n", __func__);
-		return rc;
-	}
-
-	D("%s : E use_count %d", __func__, pcam->mctl_node.use_count);
-	mutex_lock(&pcam->mctl_node.dev_lock);
-	for (i = 0; i < MSM_DEV_INST_MAX; i++) {
-		if (pcam->mctl_node.dev_inst[i] == NULL)
-			break;
-	}
-	/* if no instance is available, return error */
-	if (i == MSM_DEV_INST_MAX) {
-		mutex_unlock(&pcam->mctl_node.dev_lock);
-		return rc;
-	}
-	pcam_inst = kzalloc(sizeof(struct msm_cam_v4l2_dev_inst), GFP_KERNEL);
-	if (!pcam_inst) {
-		mutex_unlock(&pcam->mctl_node.dev_lock);
-		return rc;
-	}
-
-	pcam_inst->sensor_pxlcode = pcam->usr_fmts[0].pxlcode;
-	pcam_inst->my_index = i;
-	pcam_inst->pcam = pcam;
-	mutex_init(&pcam_inst->inst_lock);
-	pcam->mctl_node.dev_inst[i] = pcam_inst;
-
-	D("%s pcam_inst %p my_index = %d\n", __func__,
-		pcam_inst, pcam_inst->my_index);
-	rc = msm_cam_server_open_mctl_session(pcam,
-		&pcam->mctl_node.active);
-	if (rc < 0) {
-		pr_err("%s: mctl session open failed %d", __func__, rc);
-		mutex_unlock(&pcam->mctl_node.dev_lock);
-		return rc;
-	}
-
-	pmctl = msm_cam_server_get_mctl(pcam->mctl_handle);
-	if (!pmctl) {
-		pr_err("%s mctl NULL!\n", __func__);
-		return rc;
-	}
-
-	D("%s active %d\n", __func__, pcam->mctl_node.active);
-	msm_setup_v4l2_event_queue(&pcam_inst->eventHandle,
-			pcam->mctl_node.pvdev);
-
-	pcam_inst->vbqueue_initialized = 0;
-	kref_get(&pmctl->refcount);
-	f->private_data = &pcam_inst->eventHandle;
-
-	D("f->private_data = 0x%x, pcam = 0x%x\n",
-		(u32)f->private_data, (u32)pcam_inst);
-
-	pcam->mctl_node.use_count++;
-	mutex_unlock(&pcam->mctl_node.dev_lock);
-	D("%s : X ", __func__);
-	return rc;
-}
-
-static unsigned int msm_mctl_dev_poll(struct file *f,
-				struct poll_table_struct *wait)
-{
-	int rc = 0;
-	struct msm_cam_v4l2_device *pcam;
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-			struct msm_cam_v4l2_dev_inst, eventHandle);
-	pcam = pcam_inst->pcam;
-
-	D("%s : E pcam_inst = %p", __func__, pcam_inst);
-	if (!pcam) {
-		pr_err("%s NULL pointer of camera device!\n", __func__);
-		return -EINVAL;
-	}
-
-	poll_wait(f, &(pcam_inst->eventHandle.wait), wait);
-	if (v4l2_event_pending(&pcam_inst->eventHandle)) {
-		rc |= POLLPRI;
-		D("%s Event available on mctl node ", __func__);
-	}
-
-	D("%s poll on vb2\n", __func__);
-	if (!pcam_inst->vid_bufq.streaming) {
-		D("%s vid_bufq.streaming is off, inst=0x%x\n",
-				__func__, (u32)pcam_inst);
-		return rc;
-	}
-	rc |= vb2_poll(&pcam_inst->vid_bufq, f, wait);
-
-	D("%s : X ", __func__);
-	return rc;
-}
-
-static int msm_mctl_dev_close(struct file *f)
-{
-	int rc = 0;
-	struct msm_cam_v4l2_device *pcam;
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	struct msm_cam_media_controller *pmctl;
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-	pcam = pcam_inst->pcam;
-
-	D("%s : E ", __func__);
-	if (!pcam) {
-		pr_err("%s NULL pointer of camera device!\n", __func__);
-		return -EINVAL;
-	}
-
-	pmctl = msm_cam_server_get_mctl(pcam->mctl_handle);
-	mutex_lock(&pcam->mctl_node.dev_lock);
-	mutex_lock(&pcam_inst->inst_lock);
-	D("%s : active %d ", __func__, pcam->mctl_node.active);
-	if (pcam->mctl_node.active == 1) {
-		rc = msm_cam_server_close_mctl_session(pcam);
-		if (rc < 0) {
-			pr_err("%s: mctl session close failed %d",
-				__func__, rc);
-			mutex_unlock(&pcam->mctl_node.dev_lock);
-			return rc;
-		}
-		pmctl = NULL;
-	}
-	pcam_inst->streamon = 0;
-	pcam->mctl_node.use_count--;
-	pcam->mctl_node.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->mctl_node.dev_inst[pcam_inst->my_index] = NULL;
-	msm_destroy_v4l2_event_queue(&pcam_inst->eventHandle);
-	CLR_MCTLPP_INST_IDX(pcam_inst->inst_handle);
-	CLR_DEVID_MODE(pcam_inst->inst_handle);
-	CLR_IMG_MODE(pcam_inst->inst_handle);
-	mutex_unlock(&pcam_inst->inst_lock);
-	mutex_destroy(&pcam_inst->inst_lock);
-
-	kfree(pcam_inst);
-	f->private_data = NULL;
-	if (NULL != pmctl) {
-		D("%s : release ion client", __func__);
-		kref_put(&pmctl->refcount, msm_release_ion_client);
-	}
-	mutex_unlock(&pcam->mctl_node.dev_lock);
-	D("%s : use_count %d X ", __func__, pcam->mctl_node.use_count);
-	return rc;
-}
-
-static struct v4l2_file_operations g_msm_mctl_fops = {
-	.owner   = THIS_MODULE,
-	.open	= msm_mctl_dev_open,
-	.poll	= msm_mctl_dev_poll,
-	.release = msm_mctl_dev_close,
-	.unlocked_ioctl = video_ioctl2,
-};
-
-/*
- *
- * implementation of mctl node v4l2_ioctl_ops
- *
- */
-static int msm_mctl_v4l2_querycap(struct file *f, void *pctx,
-				struct v4l2_capability *pcaps)
-{
-	struct msm_cam_v4l2_device *pcam;
-
-	if (f == NULL) {
-		pr_err("%s :: NULL file pointer", __func__);
-		return -EINVAL;
-	}
-
-	pcam = video_drvdata(f);
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	if (!pcam) {
-		pr_err("%s NULL pointer passed in!\n", __func__);
-		return -EINVAL;
-	}
-
-	strlcpy(pcaps->driver, pcam->media_dev.dev->driver->name,
-			sizeof(pcaps->driver));
-	pcaps->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
-	return 0;
-}
-
-static int msm_mctl_v4l2_queryctrl(struct file *f, void *pctx,
-				struct v4l2_queryctrl *pqctrl)
-{
-	int rc = 0;
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	return rc;
-}
-
-static int msm_mctl_v4l2_g_ctrl(struct file *f, void *pctx,
-					struct v4l2_control *c)
-{
-	int rc = 0;
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	return rc;
-}
-
-static int msm_mctl_v4l2_s_ctrl(struct file *f, void *pctx,
-					struct v4l2_control *ctrl)
-{
-	int rc = 0;
-	struct msm_cam_v4l2_device *pcam  = video_drvdata(f);
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-			struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	D("%s\n", __func__);
-
-	WARN_ON(pctx != f->private_data);
-	mutex_lock(&pcam->mctl_node.dev_lock);
-	if (ctrl->id == MSM_V4L2_PID_PP_PLANE_INFO) {
-		if (copy_from_user(&pcam_inst->plane_info,
-					(void *)ctrl->value,
-					sizeof(struct img_plane_info))) {
-			pr_err("%s inst %p Copying plane_info failed ",
-					__func__, pcam_inst);
-			rc = -EFAULT;
-		}
-		D("%s inst %p got plane info: num_planes = %d,"
-				"plane size = %ld %ld ", __func__, pcam_inst,
-				pcam_inst->plane_info.num_planes,
-				pcam_inst->plane_info.plane[0].size,
-				pcam_inst->plane_info.plane[1].size);
-	} else
-		pr_err("%s Unsupported S_CTRL Value ", __func__);
-
-	mutex_unlock(&pcam->mctl_node.dev_lock);
-
-	return rc;
-}
-
-static int msm_mctl_v4l2_reqbufs(struct file *f, void *pctx,
-				struct v4l2_requestbuffers *pb)
-{
-	int rc = 0, i, j;
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	struct msm_cam_media_controller *pmctl;
-	struct msm_cam_v4l2_device *pcam = video_drvdata(f);
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	mutex_lock(&pcam_inst->inst_lock);
-	if (!pcam_inst->vbqueue_initialized && pb->count) {
-		pmctl = msm_cam_server_get_mctl(pcam->mctl_handle);
-		if (pmctl == NULL) {
-			pr_err("%s Invalid mctl ptr", __func__);
-			return -EINVAL;
-		}
-		pmctl->mctl_vbqueue_init(pcam_inst, &pcam_inst->vid_bufq,
-			pb->type);
-		pcam_inst->vbqueue_initialized = 1;
-	}
-	rc = vb2_reqbufs(&pcam_inst->vid_bufq, pb);
-	if (rc < 0) {
-		pr_err("%s reqbufs failed %d ", __func__, rc);
-		mutex_unlock(&pcam_inst->inst_lock);
-		return rc;
-	}
-	if (!pb->count) {
-		/* Deallocation. free buf_offset array */
-		D("%s Inst %p freeing buffer offsets array",
-			__func__, pcam_inst);
-		for (j = 0 ; j < pcam_inst->buf_count ; j++) {
-			kfree(pcam_inst->buf_offset[j]);
-			pcam_inst->buf_offset[j] = NULL;
-		}
-		kfree(pcam_inst->buf_offset);
-		pcam_inst->buf_offset = NULL;
-		/* If the userspace has deallocated all the
-		 * buffers, then release the vb2 queue */
-		if (pcam_inst->vbqueue_initialized) {
-			vb2_queue_release(&pcam_inst->vid_bufq);
-			pcam_inst->vbqueue_initialized = 0;
-		}
-	} else {
-		D("%s Inst %p Allocating buf_offset array",
-			__func__, pcam_inst);
-		/* Allocation. allocate buf_offset array */
-		pcam_inst->buf_offset = (struct msm_cam_buf_offset **)
-			kzalloc(pb->count * sizeof(struct msm_cam_buf_offset *),
-							GFP_KERNEL);
-		if (!pcam_inst->buf_offset) {
-			pr_err("%s out of memory ", __func__);
-			mutex_unlock(&pcam_inst->inst_lock);
-			return -ENOMEM;
-		}
-		for (i = 0; i < pb->count; i++) {
-			pcam_inst->buf_offset[i] =
-				kzalloc(sizeof(struct msm_cam_buf_offset) *
-				pcam_inst->plane_info.num_planes, GFP_KERNEL);
-			if (!pcam_inst->buf_offset[i]) {
-				pr_err("%s out of memory ", __func__);
-				for (j = i-1 ; j >= 0; j--) {
-					kfree(pcam_inst->buf_offset[j]);
-					pcam_inst->buf_offset[j] = NULL;
-				}
-				kfree(pcam_inst->buf_offset);
-				pcam_inst->buf_offset = NULL;
-				mutex_unlock(&pcam_inst->inst_lock);
-				return -ENOMEM;
-			}
-		}
-	}
-	pcam_inst->buf_count = pb->count;
-	D("%s inst %p, buf count %d ", __func__,
-		pcam_inst, pcam_inst->buf_count);
-	mutex_unlock(&pcam_inst->inst_lock);
-	return rc;
-}
-
-static int msm_mctl_v4l2_querybuf(struct file *f, void *pctx,
-					struct v4l2_buffer *pb)
-{
-	/* get the video device */
-	int rc = 0;
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-	mutex_lock(&pcam_inst->inst_lock);
-	rc = vb2_querybuf(&pcam_inst->vid_bufq, pb);
-	mutex_unlock(&pcam_inst->inst_lock);
-	return rc;
-}
-
-static int msm_mctl_v4l2_qbuf(struct file *f, void *pctx,
-					struct v4l2_buffer *pb)
-{
-	int rc = 0, i = 0;
-	/* get the camera device */
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	D("%s Inst = %p\n", __func__, pcam_inst);
-	WARN_ON(pctx != f->private_data);
-
-	mutex_lock(&pcam_inst->inst_lock);
-	if (!pcam_inst->buf_offset) {
-		pr_err("%s Buffer is already released. Returning. ", __func__);
-		mutex_unlock(&pcam_inst->inst_lock);
-		return -EINVAL;
-	}
-
-	if (pb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
-		/* Reject the buffer if planes array was not allocated */
-		if (pb->m.planes == NULL) {
-			pr_err("%s Planes array is null ", __func__);
-			mutex_unlock(&pcam_inst->inst_lock);
-			return -EINVAL;
-		}
-		for (i = 0; i < pcam_inst->plane_info.num_planes; i++) {
-			D("%s stored offsets for plane %d as"
-				"addr offset %d, data offset %d",
-				__func__, i, pb->m.planes[i].reserved[0],
-				pb->m.planes[i].data_offset);
-			pcam_inst->buf_offset[pb->index][i].data_offset =
-				pb->m.planes[i].data_offset;
-			pcam_inst->buf_offset[pb->index][i].addr_offset =
-				pb->m.planes[i].reserved[0];
-			pcam_inst->plane_info.plane[i].offset = 0;
-			D("%s, len %d user[%d] %p buf_len %d\n",
-				__func__, pb->length, i,
-				(void *)pb->m.planes[i].m.userptr,
-				pb->m.planes[i].length);
-		}
-	} else {
-		D("%s stored reserved info %d", __func__, pb->reserved);
-		pcam_inst->buf_offset[pb->index][0].addr_offset = pb->reserved;
-	}
-
-	rc = vb2_qbuf(&pcam_inst->vid_bufq, pb);
-	D("%s, videobuf_qbuf returns %d\n", __func__, rc);
-
-	mutex_unlock(&pcam_inst->inst_lock);
-	return rc;
-}
-
-static int msm_mctl_v4l2_dqbuf(struct file *f, void *pctx,
-					struct v4l2_buffer *pb)
-{
-	int rc = 0, i;
-	/* get the camera device */
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-	mutex_lock(&pcam_inst->inst_lock);
-	if (0 == pcam_inst->streamon) {
-		mutex_unlock(&pcam_inst->inst_lock);
-		return -EACCES;
-	}
-
-	rc = vb2_dqbuf(&pcam_inst->vid_bufq, pb,  f->f_flags & O_NONBLOCK);
-	D("%s, videobuf_dqbuf returns %d\n", __func__, rc);
-
-	if (pb->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
-		/* Reject the buffer if planes array was not allocated */
-		if (pb->m.planes == NULL) {
-			pr_err("%s Planes array is null\n", __func__);
-			mutex_unlock(&pcam_inst->inst_lock);
-			return -EINVAL;
-		}
-		for (i = 0; i < pcam_inst->plane_info.num_planes; i++) {
-			pb->m.planes[i].data_offset =
-				pcam_inst->buf_offset[pb->index][i].data_offset;
-			pb->m.planes[i].reserved[0] =
-				pcam_inst->buf_offset[pb->index][i].addr_offset;
-			D("%s update offsets for plane %d as A %d D %d\n",
-				__func__, i, pb->m.planes[i].reserved[0],
-				pb->m.planes[i].data_offset);
-		}
-	} else {
-		pb->reserved = pcam_inst->buf_offset[pb->index][0].addr_offset;
-		D("%s stored reserved info %d\n", __func__, pb->reserved);
-	}
-	mutex_unlock(&pcam_inst->inst_lock);
-	return rc;
-}
-
-static int msm_mctl_v4l2_streamon(struct file *f, void *pctx,
-					enum v4l2_buf_type buf_type)
-{
-	int rc = 0;
-	/* get the camera device */
-	struct msm_cam_v4l2_device *pcam  = video_drvdata(f);
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	D("%s Inst %p\n", __func__, pcam_inst);
-	WARN_ON(pctx != f->private_data);
-
-	mutex_lock(&pcam->mctl_node.dev_lock);
-	mutex_lock(&pcam_inst->inst_lock);
-	if ((buf_type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) &&
-		(buf_type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) {
-		pr_err("%s Invalid buffer type ", __func__);
-		mutex_unlock(&pcam_inst->inst_lock);
-		mutex_unlock(&pcam->mctl_node.dev_lock);
-		return -EINVAL;
-	}
-
-	D("%s Calling videobuf_streamon", __func__);
-	/* if HW streaming on is successful, start buffer streaming */
-	rc = vb2_streamon(&pcam_inst->vid_bufq, buf_type);
-	D("%s, videobuf_streamon returns %d\n", __func__, rc);
-
-	/* turn HW (VFE/sensor) streaming */
-	pcam_inst->streamon = 1;
-	mutex_unlock(&pcam_inst->inst_lock);
-	mutex_unlock(&pcam->mctl_node.dev_lock);
-	D("%s rc = %d\n", __func__, rc);
-	return rc;
-}
-
-static int msm_mctl_v4l2_streamoff(struct file *f, void *pctx,
-					enum v4l2_buf_type buf_type)
-{
-	int rc = 0;
-	/* get the camera device */
-	struct msm_cam_v4l2_device *pcam  = video_drvdata(f);
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	D("%s Inst %p\n", __func__, pcam_inst);
-	WARN_ON(pctx != f->private_data);
-
-	if ((buf_type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) &&
-		(buf_type != V4L2_BUF_TYPE_VIDEO_CAPTURE)) {
-		pr_err("%s Invalid buffer type ", __func__);
-		return -EINVAL;
-	}
-
-	/* first turn of HW (VFE/sensor) streaming so that buffers are
-		not in use when we free the buffers */
-	mutex_lock(&pcam->mctl_node.dev_lock);
-	mutex_lock(&pcam_inst->inst_lock);
-	pcam_inst->streamon = 0;
-	if (rc < 0)
-		pr_err("%s: hw failed to stop streaming\n", __func__);
-
-	/* stop buffer streaming */
-	rc = vb2_streamoff(&pcam_inst->vid_bufq, buf_type);
-	D("%s, videobuf_streamoff returns %d\n", __func__, rc);
-	mutex_unlock(&pcam_inst->inst_lock);
-	mutex_unlock(&pcam->mctl_node.dev_lock);
-	return rc;
-}
-
-static int msm_mctl_v4l2_enum_fmt_cap(struct file *f, void *pctx,
-					struct v4l2_fmtdesc *pfmtdesc)
-{
-	/* get the video device */
-	struct msm_cam_v4l2_device *pcam  = video_drvdata(f);
-	const struct msm_isp_color_fmt *isp_fmt;
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-	if ((pfmtdesc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) &&
-		(pfmtdesc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE))
-		return -EINVAL;
-
-	if (pfmtdesc->index >= pcam->num_fmts)
-		return -EINVAL;
-
-	isp_fmt = &pcam->usr_fmts[pfmtdesc->index];
-
-	if (isp_fmt->name)
-		strlcpy(pfmtdesc->description, isp_fmt->name,
-						sizeof(pfmtdesc->description));
-
-	pfmtdesc->pixelformat = isp_fmt->fourcc;
-
-	D("%s: [%d] 0x%x, %s\n", __func__, pfmtdesc->index,
-		isp_fmt->fourcc, isp_fmt->name);
-	return 0;
-}
-
-static int msm_mctl_v4l2_g_fmt_cap(struct file *f,
-		void *pctx, struct v4l2_format *pfmt)
-{
-	int rc = 0;
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	if (pfmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-		return -EINVAL;
-
-	return rc;
-}
-
-static int msm_mctl_v4l2_g_fmt_cap_mplane(struct file *f,
-		void *pctx, struct v4l2_format *pfmt)
-{
-	int rc = 0;
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	if (pfmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
-		return -EINVAL;
-
-	return rc;
-}
-
-/* This function will readjust the format parameters based in HW
-  capabilities. Called by s_fmt_cap
-*/
-static int msm_mctl_v4l2_try_fmt_cap(struct file *f, void *pctx,
-					struct v4l2_format *pfmt)
-{
-	int rc = 0;
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	return rc;
-}
-
-static int msm_mctl_v4l2_try_fmt_cap_mplane(struct file *f, void *pctx,
-					struct v4l2_format *pfmt)
-{
-	int rc = 0;
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	return rc;
-}
-
-/* This function will reconfig the v4l2 driver and HW device, it should be
-   called after the streaming is stopped.
-*/
-static int msm_mctl_v4l2_s_fmt_cap(struct file *f, void *pctx,
-					struct v4l2_format *pfmt)
-{
-	int rc = 0;
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	return rc;
-}
-
-static int msm_mctl_v4l2_s_fmt_cap_mplane(struct file *f, void *pctx,
-				struct v4l2_format *pfmt)
-{
-	int rc = 0, i;
-	struct msm_cam_v4l2_device *pcam = video_drvdata(f);
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-			struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	D("%s Inst %p\n", __func__, pcam_inst);
-	WARN_ON(pctx != f->private_data);
-
-	for (i = 0; i < pcam->num_fmts; i++)
-		if (pcam->usr_fmts[i].fourcc == pfmt->fmt.pix_mp.pixelformat)
-			break;
-	if (i == pcam->num_fmts) {
-		pr_err("%s: User requested pixelformat %x not supported\n",
-			__func__, pfmt->fmt.pix_mp.pixelformat);
-		return -EINVAL;
-	}
-	pcam_inst->vid_fmt = *pfmt;
-	pcam_inst->sensor_pxlcode =
-		pcam->usr_fmts[i].pxlcode;
-	D("%s: inst=%p, width=%d, heigth=%d\n",
-		__func__, pcam_inst,
-		pcam_inst->vid_fmt.fmt.pix_mp.width,
-		pcam_inst->vid_fmt.fmt.pix_mp.height);
-	return rc;
-}
-static int msm_mctl_v4l2_g_jpegcomp(struct file *f, void *pctx,
-				struct v4l2_jpegcompression *pcomp)
-{
-	int rc = -EINVAL;
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	return rc;
-}
-
-static int msm_mctl_v4l2_s_jpegcomp(struct file *f, void *pctx,
-				struct v4l2_jpegcompression *pcomp)
-{
-	int rc = -EINVAL;
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	return rc;
-}
-
-
-static int msm_mctl_v4l2_g_crop(struct file *f, void *pctx,
-					struct v4l2_crop *crop)
-{
-	int rc = -EINVAL;
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	return rc;
-}
-
-static int msm_mctl_v4l2_s_crop(struct file *f, void *pctx,
-					struct v4l2_crop *a)
-{
-	int rc = -EINVAL;
-
-	D("%s\n", __func__);
-	WARN_ON(pctx != f->private_data);
-
-	return rc;
-}
-
-/* Stream type-dependent parameter ioctls */
-static int msm_mctl_v4l2_g_parm(struct file *f, void *pctx,
-				struct v4l2_streamparm *a)
-{
-	int rc = -EINVAL;
-	return rc;
-}
-
-static int msm_mctl_vidbuf_get_path(u32 extendedmode)
-{
-	switch (extendedmode) {
-	case MSM_V4L2_EXT_CAPTURE_MODE_THUMBNAIL:
-		return OUTPUT_TYPE_T;
-	case MSM_V4L2_EXT_CAPTURE_MODE_MAIN:
-		return OUTPUT_TYPE_S;
-	case MSM_V4L2_EXT_CAPTURE_MODE_VIDEO:
-		return OUTPUT_TYPE_V;
-	case MSM_V4L2_EXT_CAPTURE_MODE_RDI:
-		return OUTPUT_TYPE_R;
-	case MSM_V4L2_EXT_CAPTURE_MODE_RDI1:
-		return OUTPUT_TYPE_R1;
-	case MSM_V4L2_EXT_CAPTURE_MODE_DEFAULT:
-	case MSM_V4L2_EXT_CAPTURE_MODE_PREVIEW:
-	default:
-		return OUTPUT_TYPE_P;
-	}
-}
-
-static int msm_mctl_v4l2_s_parm(struct file *f, void *pctx,
-				struct v4l2_streamparm *a)
-{
-	int rc = 0;
-	int is_bayer_sensor = 0;
-	struct msm_cam_media_controller *pmctl = NULL;
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-	pcam_inst->image_mode = (a->parm.capture.extendedmode & 0x7F);
-
-	pmctl = msm_cam_server_get_mctl(pcam_inst->pcam->mctl_handle);
-	if (!pmctl) {
-		pr_err("%s: invalid mctl controller", __func__);
-		return -EINVAL;
-	}
-	/* save msm_dev node idx for subdev notify lookup */
-	SET_DEVID_MODE(pcam_inst->inst_handle, pmctl->pcam_ptr->vnode_id);
-	SET_IMG_MODE(pcam_inst->inst_handle, pcam_inst->image_mode);
-	SET_MCTLPP_INST_IDX(pcam_inst->inst_handle, pcam_inst->my_index);
-	pcam_inst->pcam->mctl_node.dev_inst_map[pcam_inst->image_mode] =
-		pcam_inst;
-	pcam_inst->path = msm_mctl_vidbuf_get_path(pcam_inst->image_mode);
-	if (pcam_inst->pcam->sdata->sensor_type == BAYER_SENSOR)
-		is_bayer_sensor = 1;
-	rc = msm_cam_server_config_interface_map(pcam_inst->image_mode,
-			pcam_inst->pcam->mctl_handle,
-			pcam_inst->pcam->vnode_id, is_bayer_sensor);
-	D("%s path=%d, image mode = %d rc=%d\n", __func__,
-		pcam_inst->path, pcam_inst->image_mode, rc);
-	return rc;
-}
-
-static int msm_mctl_v4l2_subscribe_event(struct v4l2_fh *fh,
-			struct v4l2_event_subscription *sub)
-{
-	int rc = 0;
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst =
-		(struct msm_cam_v4l2_dev_inst *)container_of(fh,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	D("%s:fh = 0x%x, type = 0x%x\n", __func__, (u32)fh, sub->type);
-
-	if (sub->type == V4L2_EVENT_ALL)
-		sub->type = V4L2_EVENT_PRIVATE_START+MSM_CAM_APP_NOTIFY_EVENT;
-	rc = v4l2_event_subscribe(fh, sub, 30);
-	if (rc < 0)
-		pr_err("%s: failed for evtType = 0x%x, rc = %d\n",
-						__func__, sub->type, rc);
-	return rc;
-}
-
-static int msm_mctl_v4l2_unsubscribe_event(struct v4l2_fh *fh,
-			struct v4l2_event_subscription *sub)
-{
-	int rc = 0;
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst =
-		(struct msm_cam_v4l2_dev_inst *)container_of(fh,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	D("%s: fh = 0x%x\n", __func__, (u32)fh);
-
-	rc = v4l2_event_unsubscribe(fh, sub);
-	D("%s: rc = %d\n", __func__, rc);
-	return rc;
-}
-
-static int msm_mctl_v4l2_private_g_ctrl(struct file *f, void *pctx,
-	struct msm_camera_v4l2_ioctl_t *ioctl_ptr)
-{
-	int rc = -EINVAL;
-	struct msm_cam_v4l2_device *pcam  = video_drvdata(f);
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	pcam_inst = container_of(f->private_data,
-		struct msm_cam_v4l2_dev_inst, eventHandle);
-
-	WARN_ON(pctx != f->private_data);
-
-	mutex_lock(&pcam->mctl_node.dev_lock);
-	switch (ioctl_ptr->id) {
-	case MSM_V4L2_PID_INST_HANDLE:
-		COPY_TO_USER(rc, (void __user *)ioctl_ptr->ioctl_ptr,
-			(void *)&pcam_inst->inst_handle, sizeof(uint32_t));
-		if (rc)
-			ERR_COPY_TO_USER();
-		break;
-	default:
-		pr_err("%s Unsupported ioctl %d ", __func__, ioctl_ptr->id);
-		break;
-	}
-	mutex_unlock(&pcam->mctl_node.dev_lock);
-	return rc;
-}
-
-static long msm_mctl_v4l2_private_ioctl(struct file *file, void *fh,
-	  bool valid_prio, int cmd, void *arg)
-{
-	int rc = -EINVAL;
-	struct msm_camera_v4l2_ioctl_t *ioctl_ptr = arg;
-	D("%s: cmd %d\n", __func__, _IOC_NR(cmd));
-
-	switch (cmd) {
-	case MSM_CAM_V4L2_IOCTL_PRIVATE_G_CTRL:
-		rc = msm_mctl_v4l2_private_g_ctrl(file, fh, ioctl_ptr);
-		break;
-	default:
-		pr_err("%s Unsupported ioctl cmd %d ", __func__, cmd);
-		break;
-	}
-	return rc;
-}
-
-/* mctl node v4l2_ioctl_ops */
-static const struct v4l2_ioctl_ops g_msm_mctl_ioctl_ops = {
-	.vidioc_querycap = msm_mctl_v4l2_querycap,
-
-	.vidioc_s_crop = msm_mctl_v4l2_s_crop,
-	.vidioc_g_crop = msm_mctl_v4l2_g_crop,
-
-	.vidioc_queryctrl = msm_mctl_v4l2_queryctrl,
-	.vidioc_g_ctrl = msm_mctl_v4l2_g_ctrl,
-	.vidioc_s_ctrl = msm_mctl_v4l2_s_ctrl,
-
-	.vidioc_reqbufs = msm_mctl_v4l2_reqbufs,
-	.vidioc_querybuf = msm_mctl_v4l2_querybuf,
-	.vidioc_qbuf = msm_mctl_v4l2_qbuf,
-	.vidioc_dqbuf = msm_mctl_v4l2_dqbuf,
-
-	.vidioc_streamon = msm_mctl_v4l2_streamon,
-	.vidioc_streamoff = msm_mctl_v4l2_streamoff,
-
-	/* format ioctls */
-	.vidioc_enum_fmt_vid_cap = msm_mctl_v4l2_enum_fmt_cap,
-	.vidioc_enum_fmt_vid_cap_mplane = msm_mctl_v4l2_enum_fmt_cap,
-	.vidioc_try_fmt_vid_cap = msm_mctl_v4l2_try_fmt_cap,
-	.vidioc_try_fmt_vid_cap_mplane = msm_mctl_v4l2_try_fmt_cap_mplane,
-	.vidioc_g_fmt_vid_cap = msm_mctl_v4l2_g_fmt_cap,
-	.vidioc_g_fmt_vid_cap_mplane = msm_mctl_v4l2_g_fmt_cap_mplane,
-	.vidioc_s_fmt_vid_cap = msm_mctl_v4l2_s_fmt_cap,
-	.vidioc_s_fmt_vid_cap_mplane = msm_mctl_v4l2_s_fmt_cap_mplane,
-
-	.vidioc_g_jpegcomp = msm_mctl_v4l2_g_jpegcomp,
-	.vidioc_s_jpegcomp = msm_mctl_v4l2_s_jpegcomp,
-
-	/* Stream type-dependent parameter ioctls */
-	.vidioc_g_parm =  msm_mctl_v4l2_g_parm,
-	.vidioc_s_parm =  msm_mctl_v4l2_s_parm,
-
-	/* event subscribe/unsubscribe */
-	.vidioc_subscribe_event = msm_mctl_v4l2_subscribe_event,
-	.vidioc_unsubscribe_event = msm_mctl_v4l2_unsubscribe_event,
-	.vidioc_default = msm_mctl_v4l2_private_ioctl,
-};
-
-int msm_setup_mctl_node(struct msm_cam_v4l2_device *pcam)
-{
-	int rc = -EINVAL;
-	struct video_device *pvdev = NULL;
-	struct i2c_client *client = NULL;
-	struct platform_device *pdev = NULL;
-	D("%s\n", __func__);
-
-	/* first register the v4l2 device */
-	if (pcam->sensor_sdev->flags & V4L2_SUBDEV_FL_IS_I2C) {
-		client = v4l2_get_subdevdata(pcam->sensor_sdev);
-		pcam->mctl_node.v4l2_dev.dev = &client->dev;
-	} else {
-		pdev = v4l2_get_subdevdata(pcam->sensor_sdev);
-		pcam->mctl_node.v4l2_dev.dev = &pdev->dev;
-	}
-
-	/* first register the v4l2 device */
-	rc = v4l2_device_register(pcam->mctl_node.v4l2_dev.dev,
-				&pcam->mctl_node.v4l2_dev);
-	if (rc < 0)
-		return -EINVAL;
-	/*	else
-			pcam->v4l2_dev.notify = msm_cam_v4l2_subdev_notify; */
-
-	/* now setup video device */
-	pvdev = video_device_alloc();
-	if (pvdev == NULL) {
-		pr_err("%s: video_device_alloc failed\n", __func__);
-		return rc;
-	}
-
-	/* init video device's driver interface */
-	D("sensor name = %s, sizeof(pvdev->name)=%d\n",
-			pcam->sensor_sdev->name, sizeof(pvdev->name));
-
-	/* device info - strlcpy is safer than strncpy but
-	   only if architecture supports*/
-	strlcpy(pvdev->name, pcam->sensor_sdev->name,
-			sizeof(pvdev->name));
-
-	pvdev->release   = video_device_release;
-	pvdev->fops	  = &g_msm_mctl_fops;
-	pvdev->ioctl_ops  = &g_msm_mctl_ioctl_ops;
-	pvdev->minor	  = -1;
-	pvdev->vfl_type   = 1;
-
-	/* register v4l2 video device to kernel as /dev/videoXX */
-	D("%s video_register_device\n", __func__);
-	rc = video_register_device(pvdev,
-			VFL_TYPE_GRABBER,
-			-1);
-	if (rc) {
-		pr_err("%s: video_register_device failed\n", __func__);
-		goto reg_fail;
-	}
-	D("%s: video device registered as /dev/video%d\n",
-			__func__, pvdev->num);
-
-	/* connect pcam and mctl video dev to each other */
-	pcam->mctl_node.pvdev	= pvdev;
-	video_set_drvdata(pcam->mctl_node.pvdev, pcam);
-
-	return rc ;
-
-reg_fail:
-	video_device_release(pvdev);
-	v4l2_device_unregister(&pcam->mctl_node.v4l2_dev);
-	pcam->mctl_node.v4l2_dev.dev = NULL;
-	return rc;
-}
diff --git a/drivers/media/platform/msm/camera_v1/msm_mctl_buf.c b/drivers/media/platform/msm/camera_v1/msm_mctl_buf.c
deleted file mode 100644
index 041f674..0000000
--- a/drivers/media/platform/msm/camera_v1/msm_mctl_buf.c
+++ /dev/null
@@ -1,1044 +0,0 @@
-/* Copyright (c) 2011-2013, The Linux Foundation. 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.
- */
-
-#include <linux/workqueue.h>
-#include <linux/delay.h>
-#include <linux/types.h>
-#include <linux/list.h>
-#include <linux/ioctl.h>
-#include <linux/spinlock.h>
-#include <linux/videodev2.h>
-#include <linux/vmalloc.h>
-
-#include <media/v4l2-dev.h>
-#include <media/v4l2-ioctl.h>
-#include <media/v4l2-device.h>
-
-
-
-#include "msm.h"
-#include "msm_cam_server.h"
-#include "msm_ispif.h"
-
-#ifdef CONFIG_MSM_CAMERA_DEBUG
-#define D(fmt, args...) pr_debug("msm_mctl_buf: " fmt, ##args)
-#else
-#define D(fmt, args...) do {} while (0)
-#endif
-
-static int msm_vb2_ops_queue_setup(struct vb2_queue *vq,
-				const struct v4l2_format *fmt,
-				unsigned int *num_buffers,
-				unsigned int *num_planes,
-				unsigned int sizes[],
-				void *alloc_ctxs[])
-{
-	/* get the video device */
-	struct msm_cam_v4l2_dev_inst *pcam_inst = vb2_get_drv_priv(vq);
-	struct msm_cam_v4l2_device *pcam = pcam_inst->pcam;
-	int i;
-
-	D("%s\n", __func__);
-	if (!pcam || !(*num_buffers)) {
-		pr_err("%s error : invalid input\n", __func__);
-		return -EINVAL;
-	}
-
-	*num_planes = pcam_inst->plane_info.num_planes;
-	for (i = 0; i < pcam_inst->vid_fmt.fmt.pix_mp.num_planes; i++) {
-		sizes[i] = pcam_inst->plane_info.plane[i].size;
-		D("%s Inst %p : Plane %d Offset = %d Size = %ld"
-			"Aligned Size = %d", __func__, pcam_inst, i,
-			pcam_inst->plane_info.plane[i].offset,
-			pcam_inst->plane_info.plane[i].size, sizes[i]);
-	}
-	return 0;
-}
-
-static void msm_vb2_ops_wait_prepare(struct vb2_queue *q)
-{
-	/* we use polling so do not use this fn now */
-}
-static void msm_vb2_ops_wait_finish(struct vb2_queue *q)
-{
-	/* we use polling so do not use this fn now */
-}
-
-static int msm_vb2_ops_buf_init(struct vb2_buffer *vb)
-{
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	struct msm_cam_v4l2_device *pcam;
-	struct msm_cam_media_controller *pmctl;
-	struct videobuf2_contig_pmem *mem;
-	struct vb2_queue	*vq;
-	uint32_t buf_idx;
-	struct msm_frame_buffer *buf;
-	int rc = 0, i;
-	enum videobuf2_buffer_type buf_type;
-	struct videobuf2_msm_offset offset;
-	vq = vb->vb2_queue;
-	pcam_inst = vb2_get_drv_priv(vq);
-	pcam = pcam_inst->pcam;
-	D("%s\n", __func__);
-	D("%s, inst=0x%x,idx=%d, width = %d\n", __func__,
-		(u32)pcam_inst, pcam_inst->my_index,
-		pcam_inst->vid_fmt.fmt.pix.width);
-	D("%s, inst=0x%x,idx=%d, height = %d\n", __func__,
-		(u32)pcam_inst, pcam_inst->my_index,
-		pcam_inst->vid_fmt.fmt.pix.height);
-
-	buf = container_of(vb, struct msm_frame_buffer, vidbuf);
-	if (buf->state == MSM_BUFFER_STATE_INITIALIZED)
-		return rc;
-
-	if (pcam_inst->plane_info.buffer_type ==
-		V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)
-		buf_type = VIDEOBUF2_MULTIPLE_PLANES;
-	else if (pcam_inst->plane_info.buffer_type ==
-		V4L2_BUF_TYPE_VIDEO_CAPTURE)
-		buf_type = VIDEOBUF2_SINGLE_PLANE;
-	else
-		return -EINVAL;
-
-	if (buf_type == VIDEOBUF2_SINGLE_PLANE) {
-		offset.sp_off.y_off = pcam_inst->plane_info.sp_y_offset;
-		offset.sp_off.cbcr_off =
-			pcam_inst->plane_info.plane[0].offset;
-	}
-	buf_idx = vb->v4l2_buf.index;
-	pmctl = msm_cam_server_get_mctl(pcam->mctl_handle);
-	if (pmctl == NULL) {
-		pr_err("%s No mctl found\n", __func__);
-		return -EINVAL;
-	}
-	for (i = 0; i < vb->num_planes; i++) {
-		mem = vb2_plane_cookie(vb, i);
-		if (mem == NULL) {
-			pr_err("%s Inst %p Buffer %d Plane %d cookie is null",
-				__func__, pcam_inst, buf_idx, i);
-			return -EINVAL;
-		}
-		if (buf_type == VIDEOBUF2_MULTIPLE_PLANES)
-			offset.data_offset =
-				pcam_inst->plane_info.plane[i].offset;
-
-		if (vb->v4l2_buf.memory == V4L2_MEMORY_USERPTR)
-			rc = videobuf2_pmem_contig_user_get(mem, &offset,
-				buf_type,
-				pcam_inst->buf_offset[buf_idx][i].addr_offset,
-				pcam_inst->path, pmctl->client,
-				pmctl->domain_num);
-		else
-			rc = videobuf2_pmem_contig_mmap_get(mem, &offset,
-				buf_type, pcam_inst->path);
-		if (rc < 0) {
-			pr_err("%s error initializing buffer ",
-				__func__);
-			return rc;
-		}
-	}
-	buf->state = MSM_BUFFER_STATE_INITIALIZED;
-	return rc;
-}
-
-static int msm_vb2_ops_buf_prepare(struct vb2_buffer *vb)
-{
-	int i, rc = 0;
-	uint32_t len;
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	struct msm_cam_v4l2_device *pcam;
-	struct msm_frame_buffer *buf;
-	struct vb2_queue *vq;
-
-	D("%s\n", __func__);
-	if (!vb || !vb->vb2_queue) {
-		pr_err("%s error : input is NULL\n", __func__);
-		return -EINVAL;
-	}
-	vq = vb->vb2_queue;
-	pcam_inst = vb2_get_drv_priv(vq);
-	pcam = pcam_inst->pcam;
-	buf = container_of(vb, struct msm_frame_buffer, vidbuf);
-
-	if (!pcam || !buf) {
-		pr_err("%s error : pointer is NULL\n", __func__);
-		return -EINVAL;
-	}
-	/* by this time vid_fmt should be already set.
-	 * return error if it is not. */
-	if ((pcam_inst->vid_fmt.fmt.pix.width == 0) ||
-		(pcam_inst->vid_fmt.fmt.pix.height == 0)) {
-		pr_err("%s error : pcam vid_fmt is not set\n", __func__);
-		return -EINVAL;
-	}
-	/* prefill in the byteused field */
-	for (i = 0; i < vb->num_planes; i++) {
-		len = vb2_plane_size(vb, i);
-		vb2_set_plane_payload(vb, i, len);
-	}
-	buf->state = MSM_BUFFER_STATE_PREPARED;
-	return rc;
-}
-
-static int msm_vb2_ops_buf_finish(struct vb2_buffer *vb)
-{
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	struct msm_cam_v4l2_device *pcam;
-	struct msm_frame_buffer *buf;
-
-	pcam_inst = vb2_get_drv_priv(vb->vb2_queue);
-	pcam = pcam_inst->pcam;
-	buf = container_of(vb, struct msm_frame_buffer, vidbuf);
-	buf->state = MSM_BUFFER_STATE_DEQUEUED;
-	D("%s: inst=0x%x, buf=0x%x, idx=%d\n", __func__,
-	(uint32_t)pcam_inst, (uint32_t)buf, vb->v4l2_buf.index);
-	return 0;
-}
-
-static void msm_vb2_ops_buf_cleanup(struct vb2_buffer *vb)
-{
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	struct msm_cam_media_controller *pmctl;
-	struct msm_cam_v4l2_device *pcam;
-	struct videobuf2_contig_pmem *mem;
-	struct msm_frame_buffer *buf, *tmp;
-	uint32_t i, vb_phyaddr = 0, buf_phyaddr = 0;
-	unsigned long flags = 0;
-
-	pcam_inst = vb2_get_drv_priv(vb->vb2_queue);
-	pcam = pcam_inst->pcam;
-	buf = container_of(vb, struct msm_frame_buffer, vidbuf);
-
-
-	if (pcam_inst->vid_fmt.type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
-		for (i = 0; i < vb->num_planes; i++) {
-			mem = vb2_plane_cookie(vb, i);
-			if (!mem) {
-				D("%s Inst %p memory already freed up. return",
-					__func__, pcam_inst);
-				return;
-			}
-			D("%s: inst=%p, buf=0x%x, idx=%d plane id = %d\n",
-				__func__, pcam_inst,
-				(uint32_t)buf, vb->v4l2_buf.index, i);
-
-			spin_lock_irqsave(&pcam_inst->vq_irqlock, flags);
-			list_for_each_entry_safe(buf, tmp,
-					&pcam_inst->free_vq, list) {
-				if (&buf->vidbuf == vb) {
-					list_del_init(&buf->list);
-					break;
-				}
-			}
-			spin_unlock_irqrestore(&pcam_inst->vq_irqlock, flags);
-		}
-	} else {
-		mem = vb2_plane_cookie(vb, 0);
-		if (!mem)
-			return;
-		D("%s: inst=0x%x, buf=0x%x, idx=%d\n", __func__,
-		(uint32_t)pcam_inst, (uint32_t)buf, vb->v4l2_buf.index);
-		vb_phyaddr = (unsigned long) videobuf2_to_pmem_contig(vb, 0);
-		spin_lock_irqsave(&pcam_inst->vq_irqlock, flags);
-		list_for_each_entry_safe(buf, tmp,
-				&pcam_inst->free_vq, list) {
-			buf_phyaddr = (unsigned long)
-				videobuf2_to_pmem_contig(&buf->vidbuf, 0);
-			D("%s vb_idx=%d,vb_paddr=0x%x,phyaddr=0x%x\n",
-				__func__, buf->vidbuf.v4l2_buf.index,
-				buf_phyaddr, vb_phyaddr);
-			if (vb_phyaddr == buf_phyaddr) {
-				list_del_init(&buf->list);
-				break;
-			}
-		}
-		spin_unlock_irqrestore(&pcam_inst->vq_irqlock, flags);
-	}
-	pmctl = msm_cam_server_get_mctl(pcam->mctl_handle);
-	if (pmctl == NULL) {
-		pr_err("%s No mctl found\n", __func__);
-		buf->state = MSM_BUFFER_STATE_UNUSED;
-		return;
-	}
-	for (i = 0; i < vb->num_planes; i++) {
-		mem = vb2_plane_cookie(vb, i);
-		if (mem) {
-			videobuf2_pmem_contig_user_put(mem, pmctl->client,
-				pmctl->domain_num);
-		} else {
-			pr_err("%s Inst %p buffer plane cookie is null",
-				__func__, pcam_inst);
-			return;
-		}
-	}
-	buf->state = MSM_BUFFER_STATE_UNUSED;
-}
-
-static int msm_vb2_ops_start_streaming(struct vb2_queue *q, unsigned int count)
-{
-	return 0;
-}
-
-static int msm_vb2_ops_stop_streaming(struct vb2_queue *q)
-{
-	return 0;
-}
-
-static void msm_vb2_ops_buf_queue(struct vb2_buffer *vb)
-{
-	struct msm_cam_v4l2_dev_inst *pcam_inst = NULL;
-	struct msm_cam_v4l2_device *pcam = NULL;
-	unsigned long flags = 0;
-	struct vb2_queue *vq;
-	struct msm_frame_buffer *buf;
-	D("%s\n", __func__);
-	if (!vb || !vb->vb2_queue) {
-		pr_err("%s error : input is NULL\n", __func__);
-		return ;
-	}
-	vq = vb->vb2_queue;
-	pcam_inst = vb2_get_drv_priv(vq);
-	pcam = pcam_inst->pcam;
-	D("%s pcam_inst=%p,(vb=0x%p),idx=%d,len=%d\n",
-		__func__, pcam_inst,
-	vb, vb->v4l2_buf.index, vb->v4l2_buf.length);
-	D("%s pcam_inst=%p, idx=%d\n", __func__, pcam_inst,
-		vb->v4l2_buf.index);
-	buf = container_of(vb, struct msm_frame_buffer, vidbuf);
-	spin_lock_irqsave(&pcam_inst->vq_irqlock, flags);
-	/* we are returning a buffer to the queue */
-	list_add_tail(&buf->list, &pcam_inst->free_vq);
-	spin_unlock_irqrestore(&pcam_inst->vq_irqlock, flags);
-	buf->state = MSM_BUFFER_STATE_QUEUED;
-}
-
-static struct vb2_ops msm_vb2_ops = {
-	.queue_setup = msm_vb2_ops_queue_setup,
-	.wait_prepare = msm_vb2_ops_wait_prepare,
-	.wait_finish = msm_vb2_ops_wait_finish,
-	.buf_init = msm_vb2_ops_buf_init,
-	.buf_prepare = msm_vb2_ops_buf_prepare,
-	.buf_finish = msm_vb2_ops_buf_finish,
-	.buf_cleanup = msm_vb2_ops_buf_cleanup,
-	.start_streaming = msm_vb2_ops_start_streaming,
-	.stop_streaming = msm_vb2_ops_stop_streaming,
-	.buf_queue = msm_vb2_ops_buf_queue,
-};
-
-
-/* prepare a video buffer queue for a vl42 device*/
-static int msm_vbqueue_init(struct msm_cam_v4l2_dev_inst *pcam_inst,
-			struct vb2_queue *q, enum v4l2_buf_type type)
-{
-	if (!q) {
-		pr_err("%s error : input is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	spin_lock_init(&pcam_inst->vq_irqlock);
-	INIT_LIST_HEAD(&pcam_inst->free_vq);
-	videobuf2_queue_pmem_contig_init(q, type,
-					&msm_vb2_ops,
-					sizeof(struct msm_frame_buffer),
-					(void *)pcam_inst);
-	return 0;
-}
-
-int msm_mctl_img_mode_to_inst_index(struct msm_cam_media_controller *pmctl,
-					int image_mode, int node_type)
-{
-	if ((image_mode >= 0) && node_type &&
-		pmctl->pcam_ptr->mctl_node.dev_inst_map[image_mode])
-		return pmctl->pcam_ptr->
-				mctl_node.dev_inst_map[image_mode]->my_index;
-	else if ((image_mode >= 0) &&
-		pmctl->pcam_ptr->dev_inst_map[image_mode])
-		return	pmctl->pcam_ptr->
-				dev_inst_map[image_mode]->my_index;
-	else
-		return -EINVAL;
-}
-
-void msm_mctl_gettimeofday(struct timeval *tv)
-{
-	struct timespec ts;
-
-	BUG_ON(!tv);
-
-	ktime_get_ts(&ts);
-	tv->tv_sec = ts.tv_sec;
-	tv->tv_usec = ts.tv_nsec/1000;
-}
-
-struct msm_frame_buffer *msm_mctl_buf_find(
-	struct msm_cam_media_controller *pmctl,
-	struct msm_cam_v4l2_dev_inst *pcam_inst, int del_buf,
-	struct msm_free_buf *fbuf)
-{
-	struct msm_frame_buffer *buf = NULL, *tmp;
-	uint32_t buf_phyaddr = 0;
-	unsigned long flags = 0;
-	uint32_t buf_idx, offset = 0;
-	struct videobuf2_contig_pmem *mem;
-
-	/* we actually need a list, not a queue */
-	spin_lock_irqsave(&pcam_inst->vq_irqlock, flags);
-	list_for_each_entry_safe(buf, tmp,
-			&pcam_inst->free_vq, list) {
-		buf_idx = buf->vidbuf.v4l2_buf.index;
-		mem = vb2_plane_cookie(&buf->vidbuf, 0);
-		if (mem == NULL) {
-			pr_err("%s Inst %p plane cookie is null",
-				__func__, pcam_inst);
-			spin_unlock_irqrestore(&pcam_inst->vq_irqlock, flags);
-			return NULL;
-		}
-		if (mem->buffer_type == VIDEOBUF2_MULTIPLE_PLANES)
-			offset = mem->offset.data_offset +
-				pcam_inst->buf_offset[buf_idx][0].data_offset;
-		else
-			offset = mem->offset.sp_off.y_off;
-		buf_phyaddr = (unsigned long)
-				videobuf2_to_pmem_contig(&buf->vidbuf, 0) +
-				offset;
-		D("%s vb_idx=%d,vb_paddr=0x%x ch0=0x%x\n",
-			__func__, buf->vidbuf.v4l2_buf.index,
-			buf_phyaddr, fbuf->ch_paddr[0]);
-		if (fbuf->ch_paddr[0] == buf_phyaddr) {
-			if (del_buf)
-				list_del_init(&buf->list);
-			spin_unlock_irqrestore(&pcam_inst->vq_irqlock,
-								flags);
-			buf->state = MSM_BUFFER_STATE_RESERVED;
-			return buf;
-		}
-	}
-	spin_unlock_irqrestore(&pcam_inst->vq_irqlock, flags);
-	return NULL;
-}
-
-int msm_mctl_buf_done_proc(
-		struct msm_cam_media_controller *pmctl,
-		struct msm_cam_v4l2_dev_inst *pcam_inst,
-		struct msm_free_buf *fbuf,
-		uint32_t *frame_id,
-		struct msm_cam_timestamp *cam_ts)
-{
-	struct msm_frame_buffer *buf = NULL;
-	int del_buf = 1;
-
-	buf = msm_mctl_buf_find(pmctl, pcam_inst, del_buf, fbuf);
-	if (!buf) {
-		pr_err("%s: buf=0x%x not found\n",
-			__func__, fbuf->ch_paddr[0]);
-		return -EINVAL;
-	}
-	if (!cam_ts->present) {
-		if (frame_id)
-			buf->vidbuf.v4l2_buf.sequence = *frame_id;
-		msm_mctl_gettimeofday(
-			&buf->vidbuf.v4l2_buf.timestamp);
-	} else {
-		D("%s Copying timestamp as %ld.%ld", __func__,
-			cam_ts->timestamp.tv_sec, cam_ts->timestamp.tv_usec);
-		buf->vidbuf.v4l2_buf.timestamp = cam_ts->timestamp;
-		buf->vidbuf.v4l2_buf.sequence  = cam_ts->frame_id;
-	}
-	D("%s Notify user about buffer %d image_mode %d frame_id %d", __func__,
-		buf->vidbuf.v4l2_buf.index, pcam_inst->image_mode,
-		buf->vidbuf.v4l2_buf.sequence);
-	vb2_buffer_done(&buf->vidbuf, VB2_BUF_STATE_DONE);
-	return 0;
-}
-
-
-int msm_mctl_buf_done(struct msm_cam_media_controller *p_mctl,
-	struct msm_cam_buf_handle *buf_handle,
-	struct msm_free_buf *fbuf,
-	uint32_t frame_id)
-{
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	int idx, rc;
-	int pp_divert_type = 0, pp_type = 0;
-	uint32_t image_mode;
-	struct msm_cam_timestamp cam_ts;
-
-	if (!p_mctl || !buf_handle || !fbuf) {
-		pr_err("%s Invalid argument. ", __func__);
-		return -EINVAL;
-	}
-	if (buf_handle->buf_lookup_type == BUF_LOOKUP_BY_IMG_MODE)
-		image_mode = buf_handle->image_mode;
-	else
-		image_mode = GET_IMG_MODE(buf_handle->inst_handle);
-
-	if (image_mode > MSM_V4L2_EXT_CAPTURE_MODE_MAX) {
-		pr_err("%s Invalid image mode %d ", __func__, image_mode);
-		return -EINVAL;
-	}
-
-	msm_mctl_check_pp(p_mctl, image_mode, &pp_divert_type, &pp_type);
-	D("%s: pp_type=%d, pp_divert_type = %d, frame_id = 0x%x image_mode %d",
-		__func__, pp_type, pp_divert_type, frame_id, image_mode);
-	if (pp_type || pp_divert_type) {
-		rc = msm_mctl_do_pp_divert(p_mctl, buf_handle,
-			fbuf, frame_id, pp_type);
-	} else {
-		/* Find the instance on which vb2_buffer_done() needs to be
-		 * called, so that the user can get the buffer.
-		 * If the lookup type is
-		 * - By instance handle:
-		 *    Either mctl_pp inst idx or video inst idx should be set.
-		 *    Try to get the MCTL_PP inst idx first, if its not set,
-		 *    fall back to video inst idx. Once we get the inst idx,
-		 *    get the pcam_inst from the corresponding dev_inst[] map.
-		 *    If neither are set, its a serious error, trigger a BUG_ON.
-		 * - By image mode:
-		 *    Legacy usecase. Use the image mode and get the pcam_inst
-		 *    from the video node.
-		 */
-		if (buf_handle->buf_lookup_type == BUF_LOOKUP_BY_INST_HANDLE) {
-			idx = GET_MCTLPP_INST_IDX(buf_handle->inst_handle);
-			if (idx > MSM_DEV_INST_MAX) {
-				idx = GET_VIDEO_INST_IDX(
-					buf_handle->inst_handle);
-				BUG_ON(idx > MSM_DEV_INST_MAX);
-				pcam_inst = p_mctl->pcam_ptr->dev_inst[idx];
-			} else {
-				pcam_inst = p_mctl->pcam_ptr->mctl_node.
-					dev_inst[idx];
-			}
-		} else if (buf_handle->buf_lookup_type ==
-				BUF_LOOKUP_BY_IMG_MODE) {
-			idx = msm_mctl_img_mode_to_inst_index(p_mctl,
-				buf_handle->image_mode, 0);
-			if (idx < 0) {
-				pr_err("%s Invalid idx %d ", __func__, idx);
-				return -EINVAL;
-			}
-			pcam_inst = p_mctl->pcam_ptr->dev_inst[idx];
-		} else {
-			pr_err("%s Invalid buffer lookup type %d", __func__,
-				buf_handle->buf_lookup_type);
-			return -EINVAL;
-		}
-		if (!pcam_inst) {
-			pr_err("%s Invalid instance, Dropping buffer. ",
-				__func__);
-			return -EINVAL;
-		}
-		memset(&cam_ts, 0, sizeof(cam_ts));
-		rc = msm_mctl_buf_done_proc(p_mctl, pcam_inst,
-			fbuf, &frame_id, &cam_ts);
-	}
-	return rc;
-}
-
-int msm_mctl_buf_init(struct msm_cam_v4l2_device *pcam)
-{
-	struct msm_cam_media_controller *pmctl;
-	pmctl = msm_cam_server_get_mctl(pcam->mctl_handle);
-	if (pmctl == NULL) {
-		pr_err("%s No mctl found\n", __func__);
-		return -EINVAL;
-	}
-	pmctl->mctl_vbqueue_init = msm_vbqueue_init;
-	return 0;
-}
-
-static int is_buffer_queued(struct msm_cam_v4l2_device *pcam, int image_mode)
-{
-	int idx;
-	int ret = 0;
-	struct msm_frame_buffer *buf = NULL;
-	struct msm_cam_v4l2_dev_inst *pcam_inst = NULL;
-	idx = pcam->mctl_node.dev_inst_map[image_mode]->my_index;
-	pcam_inst = pcam->mctl_node.dev_inst[idx];
-	list_for_each_entry(buf, &pcam_inst->free_vq, list) {
-		if (buf->state != MSM_BUFFER_STATE_QUEUED)
-			continue;
-		ret = 1;
-	}
-	return ret;
-}
-
-struct msm_cam_v4l2_dev_inst *msm_mctl_get_inst_by_img_mode(
-	struct msm_cam_media_controller *pmctl, uint32_t img_mode)
-{
-	struct msm_cam_v4l2_dev_inst *pcam_inst = NULL;
-	struct msm_cam_v4l2_device *pcam = pmctl->pcam_ptr;
-	int idx;
-
-		/* Valid image mode. Search the mctl node first.
-		 * If mctl node doesnt have the instance, then
-		 * search in the user's video node */
-		if (pmctl->vfe_output_mode == VFE_OUTPUTS_MAIN_AND_THUMB
-		|| pmctl->vfe_output_mode == VFE_OUTPUTS_THUMB_AND_MAIN) {
-			if (pcam->mctl_node.dev_inst_map[img_mode]
-			&& is_buffer_queued(pcam, img_mode)) {
-				idx = pcam->mctl_node.dev_inst_map[img_mode]
-							->my_index;
-				pcam_inst = pcam->mctl_node.dev_inst[idx];
-				D("%s Found instance %p in mctl node device\n",
-				  __func__, pcam_inst);
-			} else if (pcam->dev_inst_map[img_mode]) {
-				idx = pcam->dev_inst_map[img_mode]->my_index;
-				pcam_inst = pcam->dev_inst[idx];
-				D("%s Found instance %p in video device\n",
-				__func__, pcam_inst);
-			}
-		} else if (img_mode == MSM_V4L2_EXT_CAPTURE_MODE_V2X_LIVESHOT) {
-				img_mode = MSM_V4L2_EXT_CAPTURE_MODE_MAIN;
-			if (pcam->mctl_node.dev_inst_map[img_mode] &&
-					is_buffer_queued(pcam, img_mode)) {
-				idx = pcam->mctl_node.dev_inst_map[img_mode]
-							->my_index;
-				pcam_inst = pcam->mctl_node.dev_inst[idx];
-				D("%s Found instance %p in mctl node device\n",
-				  __func__, pcam_inst);
-			} else if (pcam->dev_inst_map[img_mode]) {
-				idx = pcam->dev_inst_map[img_mode]->my_index;
-				pcam_inst = pcam->dev_inst[idx];
-				D("%s Found instance %p in video device\n",
-				__func__, pcam_inst);
-			}
-		} else {
-			if (pcam->mctl_node.dev_inst_map[img_mode]) {
-				idx = pcam->mctl_node.dev_inst_map[img_mode]
-				->my_index;
-				pcam_inst = pcam->mctl_node.dev_inst[idx];
-				D("%s Found instance %p in mctl node device\n",
-				__func__, pcam_inst);
-			} else if (pcam->dev_inst_map[img_mode]) {
-				idx = pcam->dev_inst_map[img_mode]->my_index;
-				pcam_inst = pcam->dev_inst[idx];
-				D("%s Found instance %p in video device\n",
-					__func__, pcam_inst);
-			}
-		}
-	return pcam_inst;
-}
-
-struct msm_cam_v4l2_dev_inst *msm_mctl_get_pcam_inst(
-				struct msm_cam_media_controller *pmctl,
-				struct msm_cam_buf_handle *buf_handle)
-{
-	struct msm_cam_v4l2_dev_inst *pcam_inst = NULL;
-	struct msm_cam_v4l2_device *pcam = pmctl->pcam_ptr;
-	int idx;
-
-	/* Get the pcam instance on based on the following rules:
-	 * If the lookup type is
-	 * - By instance handle:
-	 *    Either mctl_pp inst idx or video inst idx should be set.
-	 *    Try to get the MCTL_PP inst idx first, if its not set,
-	 *    fall back to video inst idx. Once we get the inst idx,
-	 *    get the pcam_inst from the corresponding dev_inst[] map.
-	 *    If neither are set, its a serious error, trigger a BUG_ON.
-	 * - By image mode:(Legacy usecase)
-	 *    If vfe is in configured in snapshot mode, first check if
-	 *    mctl pp node has a instance created for this image mode
-	 *    and if there is a buffer queued for that instance.
-	 *    If so, return that instance, otherwise get the pcam instance
-	 *    for this image_mode from the video instance.
-	 *    If the vfe is configured in any other mode, then first check
-	 *    if mctl pp node has a instance created for this image mode,
-	 *    otherwise get the pcam instance for this image mode from the
-	 *    video instance.
-	 */
-	if (buf_handle->buf_lookup_type == BUF_LOOKUP_BY_INST_HANDLE) {
-		idx = GET_MCTLPP_INST_IDX(buf_handle->inst_handle);
-		if (idx > MSM_DEV_INST_MAX) {
-			idx = GET_VIDEO_INST_IDX(buf_handle->inst_handle);
-			BUG_ON(idx > MSM_DEV_INST_MAX);
-			pcam_inst = pcam->dev_inst[idx];
-		} else {
-			pcam_inst = pcam->mctl_node.dev_inst[idx];
-		}
-	} else if ((buf_handle->buf_lookup_type == BUF_LOOKUP_BY_IMG_MODE)
-		&& (buf_handle->image_mode >= 0 &&
-		buf_handle->image_mode < MSM_V4L2_EXT_CAPTURE_MODE_MAX)) {
-		pcam_inst = msm_mctl_get_inst_by_img_mode(pmctl,
-				buf_handle->image_mode);
-	} else {
-		pr_err("%s Invalid buffer lookup type %d", __func__,
-			buf_handle->buf_lookup_type);
-	}
-	return pcam_inst;
-}
-
-int msm_mctl_reserve_free_buf(
-	struct msm_cam_media_controller *pmctl,
-	struct msm_cam_v4l2_dev_inst *pref_pcam_inst,
-	struct msm_cam_buf_handle *buf_handle,
-	struct msm_free_buf *free_buf)
-{
-	struct msm_cam_v4l2_dev_inst *pcam_inst = pref_pcam_inst;
-	unsigned long flags = 0;
-	struct videobuf2_contig_pmem *mem;
-	struct msm_frame_buffer *buf = NULL;
-	int rc = -EINVAL, i;
-	uint32_t buf_idx, plane_offset = 0;
-
-	if (!free_buf || !pmctl || !buf_handle) {
-		pr_err("%s: Invalid argument passed\n", __func__);
-		return rc;
-	}
-	memset(free_buf, 0, sizeof(struct msm_free_buf));
-
-	/* If the caller wants to reserve a buffer from a particular
-	 * camera instance, he would send the preferred camera instance.
-	 * If the preferred camera instance is NULL, get the
-	 * camera instance using the image mode passed */
-	if (!pcam_inst)
-		pcam_inst = msm_mctl_get_pcam_inst(pmctl, buf_handle);
-
-	if (!pcam_inst || !pcam_inst->streamon) {
-		pr_err("%s: stream is turned off\n", __func__);
-		return rc;
-	}
-	spin_lock_irqsave(&pcam_inst->vq_irqlock, flags);
-	if (pcam_inst->free_vq.next == NULL) {
-		pr_err("%s Inst %p Free queue head is null",
-			__func__, pcam_inst);
-		spin_unlock_irqrestore(&pcam_inst->vq_irqlock, flags);
-		return rc;
-	}
-	list_for_each_entry(buf, &pcam_inst->free_vq, list) {
-		if (buf == NULL) {
-			pr_err("%s Inst %p Invalid buffer ptr",
-				__func__, pcam_inst);
-			spin_unlock_irqrestore(&pcam_inst->vq_irqlock, flags);
-			return rc;
-		}
-		if (buf->state != MSM_BUFFER_STATE_QUEUED)
-			continue;
-
-		buf_idx = buf->vidbuf.v4l2_buf.index;
-		if (pcam_inst->vid_fmt.type ==
-				V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
-			free_buf->num_planes =
-				pcam_inst->plane_info.num_planes;
-			for (i = 0; i < free_buf->num_planes; i++) {
-				mem = vb2_plane_cookie(&buf->vidbuf, i);
-				if (mem == NULL) {
-					pr_err("%s Inst %p %d invalid cookie",
-						__func__, pcam_inst, buf_idx);
-					spin_unlock_irqrestore(
-						&pcam_inst->vq_irqlock, flags);
-					return rc;
-				}
-				if (mem->buffer_type ==
-						VIDEOBUF2_MULTIPLE_PLANES)
-					plane_offset =
-					mem->offset.data_offset;
-				else
-					plane_offset =
-					mem->offset.sp_off.cbcr_off;
-
-				D("%s: data off %d plane off %d",
-					__func__,
-					pcam_inst->buf_offset[buf_idx][i].
-					data_offset, plane_offset);
-				free_buf->ch_paddr[i] =	(uint32_t)
-				videobuf2_to_pmem_contig(&buf->vidbuf, i) +
-				pcam_inst->buf_offset[buf_idx][i].data_offset +
-				plane_offset;
-
-			}
-		} else {
-			mem = vb2_plane_cookie(&buf->vidbuf, 0);
-			if (mem == NULL) {
-				pr_err("%s Inst %p %d invalid cookie",
-					__func__, pcam_inst, buf_idx);
-				spin_unlock_irqrestore(
-					&pcam_inst->vq_irqlock, flags);
-				return rc;
-			}
-			free_buf->ch_paddr[0] = (uint32_t)
-				videobuf2_to_pmem_contig(&buf->vidbuf, 0) +
-				mem->offset.sp_off.y_off;
-			free_buf->ch_paddr[1] =	free_buf->ch_paddr[0] +
-				mem->offset.sp_off.cbcr_off;
-		}
-		free_buf->vb = (uint32_t)buf;
-		buf->state = MSM_BUFFER_STATE_RESERVED;
-		D("%s inst=0x%p, idx=%d, paddr=0x%x, "
-			"ch1 addr=0x%x\n", __func__,
-			pcam_inst, buf->vidbuf.v4l2_buf.index,
-			free_buf->ch_paddr[0], free_buf->ch_paddr[1]);
-		rc = 0;
-		break;
-	}
-	if (rc != 0)
-		D("%s:No free buffer available: inst = 0x%p ",
-				__func__, pcam_inst);
-	spin_unlock_irqrestore(&pcam_inst->vq_irqlock, flags);
-	return rc;
-}
-
-int msm_mctl_release_free_buf(struct msm_cam_media_controller *pmctl,
-				struct msm_cam_v4l2_dev_inst *pcam_inst,
-				struct msm_free_buf *free_buf)
-{
-	unsigned long flags = 0;
-	struct msm_frame_buffer *buf = NULL;
-	uint32_t buf_phyaddr = 0;
-	int rc = -EINVAL;
-
-	if (!pcam_inst || !free_buf) {
-		pr_err("%s Invalid argument, buffer will not be returned\n",
-			__func__);
-		return rc;
-	}
-
-	spin_lock_irqsave(&pcam_inst->vq_irqlock, flags);
-	list_for_each_entry(buf, &pcam_inst->free_vq, list) {
-		buf_phyaddr =
-			(uint32_t) videobuf2_to_pmem_contig(&buf->vidbuf, 0);
-		if (free_buf->ch_paddr[0] == buf_phyaddr) {
-			D("%s Return buffer %d and mark it as QUEUED\n",
-				__func__, buf->vidbuf.v4l2_buf.index);
-			buf->state = MSM_BUFFER_STATE_QUEUED;
-			rc = 0;
-			break;
-		}
-	}
-	spin_unlock_irqrestore(&pcam_inst->vq_irqlock, flags);
-
-	if (rc)
-		pr_err("%s Cannot find buffer %x", __func__,
-			free_buf->ch_paddr[0]);
-
-	return rc;
-}
-
-int msm_mctl_buf_done_pp(struct msm_cam_media_controller *pmctl,
-	struct msm_cam_buf_handle *buf_handle,
-	struct msm_free_buf *frame,
-	struct msm_cam_return_frame_info *ret_frame)
-{
-	struct msm_cam_v4l2_dev_inst *pcam_inst = NULL;
-	int rc = 0, idx;
-	struct msm_cam_timestamp cam_ts;
-
-	if (!pmctl || !buf_handle || !ret_frame) {
-		pr_err("%s Invalid argument ", __func__);
-		return -EINVAL;
-	}
-
-	if (buf_handle->buf_lookup_type == BUF_LOOKUP_BY_INST_HANDLE) {
-		idx = GET_MCTLPP_INST_IDX(buf_handle->inst_handle);
-		if (idx > MSM_DEV_INST_MAX) {
-			idx = GET_VIDEO_INST_IDX(buf_handle->inst_handle);
-			BUG_ON(idx > MSM_DEV_INST_MAX);
-			pcam_inst = pmctl->pcam_ptr->dev_inst[idx];
-		} else {
-			pcam_inst = pmctl->pcam_ptr->mctl_node.dev_inst[idx];
-		}
-	} else if (buf_handle->buf_lookup_type == BUF_LOOKUP_BY_IMG_MODE) {
-		idx = msm_mctl_img_mode_to_inst_index(pmctl,
-			buf_handle->image_mode, ret_frame->node_type);
-		if (idx < 0) {
-			pr_err("%s Invalid instance, buffer not released\n",
-				__func__);
-			return idx;
-		}
-		if (ret_frame->node_type)
-			pcam_inst = pmctl->pcam_ptr->mctl_node.dev_inst[idx];
-		else
-			pcam_inst = pmctl->pcam_ptr->dev_inst[idx];
-	}
-	if (!pcam_inst) {
-		pr_err("%s Invalid instance, cannot send buf to user",
-			__func__);
-		return -EINVAL;
-	}
-
-	D("%s:inst=0x%p, paddr=0x%x, dirty=%d",
-		__func__, pcam_inst, frame->ch_paddr[0], ret_frame->dirty);
-	cam_ts.present = 1;
-	cam_ts.timestamp = ret_frame->timestamp;
-	cam_ts.frame_id   = ret_frame->frame_id;
-	if (ret_frame->dirty)
-		/* the frame is dirty, not going to disptach to app */
-		rc = msm_mctl_release_free_buf(pmctl, pcam_inst, frame);
-	else
-		rc = msm_mctl_buf_done_proc(pmctl, pcam_inst, frame,
-			NULL, &cam_ts);
-	return rc;
-}
-
-int msm_mctl_buf_return_buf(struct msm_cam_media_controller *pmctl,
-			int image_mode, struct msm_frame_buffer *rbuf)
-{
-	int idx = 0;
-	struct msm_frame_buffer *buf = NULL;
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	struct msm_cam_v4l2_device *pcam = pmctl->pcam_ptr;
-	unsigned long flags = 0;
-
-	if (pcam->mctl_node.dev_inst_map[image_mode]) {
-		idx = pcam->mctl_node.dev_inst_map[image_mode]->my_index;
-		pcam_inst = pcam->mctl_node.dev_inst[idx];
-		D("%s Found instance %p in mctl node device\n",
-			__func__, pcam_inst);
-	} else {
-		pr_err("%s Invalid image mode %d ", __func__, image_mode);
-		return -EINVAL;
-	}
-
-	if (!pcam_inst) {
-		pr_err("%s Invalid instance\n", __func__);
-		return -EINVAL;
-	}
-
-	spin_lock_irqsave(&pcam_inst->vq_irqlock, flags);
-	if (!list_empty(&pcam_inst->free_vq)) {
-		list_for_each_entry(buf, &pcam_inst->free_vq, list) {
-			if (rbuf == buf) {
-				D("%s Return buffer %x in pcam_inst %p ",
-				__func__, (int)rbuf, pcam_inst);
-				buf->state = MSM_BUFFER_STATE_QUEUED;
-				spin_unlock_irqrestore(&pcam_inst->vq_irqlock,
-					flags);
-				return 0;
-			}
-		}
-	}
-	spin_unlock_irqrestore(&pcam_inst->vq_irqlock, flags);
-	return -EINVAL;
-}
-
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-/* Unmap using ION APIs */
-static void __msm_mctl_unmap_user_frame(struct msm_cam_meta_frame *meta_frame,
-	struct ion_client *client, int domain_num)
-{
-	int i = 0;
-	for (i = 0; i < meta_frame->frame.num_planes; i++) {
-		D("%s Plane %d handle %p", __func__, i,
-			meta_frame->map[i].handle);
-		ion_unmap_iommu(client, meta_frame->map[i].handle,
-					domain_num, 0);
-		ion_free(client, meta_frame->map[i].handle);
-	}
-}
-
-/* Map using ION APIs */
-static int __msm_mctl_map_user_frame(struct msm_cam_meta_frame *meta_frame,
-	struct ion_client *client, int domain_num)
-{
-	unsigned long paddr = 0;
-	unsigned long len = 0;
-	int i = 0, j = 0;
-
-	for (i = 0; i < meta_frame->frame.num_planes; i++) {
-		meta_frame->map[i].handle = ion_import_dma_buf(client,
-			meta_frame->frame.mp[i].fd);
-		if (IS_ERR_OR_NULL(meta_frame->map[i].handle)) {
-			pr_err("%s: ion_import failed for plane = %d fd = %d",
-				__func__, i, meta_frame->frame.mp[i].fd);
-			/* Roll back previous plane mappings, if any */
-			for (j = i-1; j >= 0; j--) {
-				ion_unmap_iommu(client,
-					meta_frame->map[j].handle,
-					domain_num, 0);
-				ion_free(client, meta_frame->map[j].handle);
-			}
-			return -EACCES;
-		}
-		D("%s Mapping fd %d plane %d handle %p", __func__,
-			meta_frame->frame.mp[i].fd, i,
-			meta_frame->map[i].handle);
-		if (ion_map_iommu(client, meta_frame->map[i].handle,
-				domain_num, 0, SZ_4K,
-				0, &paddr, &len, 0, 0) < 0) {
-			pr_err("%s: cannot map address plane %d", __func__, i);
-			ion_free(client, meta_frame->map[i].handle);
-			/* Roll back previous plane mappings, if any */
-			for (j = i-1; j >= 0; j--) {
-				if (meta_frame->map[j].handle) {
-					ion_unmap_iommu(client,
-						meta_frame->map[j].handle,
-						domain_num, 0);
-					ion_free(client,
-						meta_frame->map[j].handle);
-				}
-			}
-			return -EFAULT;
-		}
-
-		/* Validate the offsets with the mapped length. */
-		if ((meta_frame->frame.mp[i].addr_offset > len) ||
-			(meta_frame->frame.mp[i].data_offset +
-			meta_frame->frame.mp[i].length > len)) {
-			pr_err("%s: Invalid offsets A %d D %d L %d len %ld",
-				__func__, meta_frame->frame.mp[i].addr_offset,
-				meta_frame->frame.mp[i].data_offset,
-				meta_frame->frame.mp[i].length, len);
-			/* Roll back previous plane mappings, if any */
-			for (j = i; j >= 0; j--) {
-				if (meta_frame->map[j].handle) {
-					ion_unmap_iommu(client,
-						meta_frame->map[j].handle,
-						domain_num, 0);
-					ion_free(client,
-						meta_frame->map[j].handle);
-				}
-			}
-			return -EINVAL;
-		}
-		meta_frame->map[i].data_offset =
-			meta_frame->frame.mp[i].data_offset;
-		/* Add the addr_offset to the paddr here itself. The addr_offset
-		 * will be non-zero only if the user has allocated a buffer with
-		 * a single fd, but logically partitioned it into
-		 * multiple planes or buffers.*/
-		paddr += meta_frame->frame.mp[i].addr_offset;
-		meta_frame->map[i].paddr = paddr;
-		meta_frame->map[i].len = len;
-		D("%s Plane %d fd %d handle %p paddr %x", __func__,
-			i, meta_frame->frame.mp[i].fd,
-			meta_frame->map[i].handle,
-			(uint32_t)meta_frame->map[i].paddr);
-	}
-	D("%s Frame mapped successfully ", __func__);
-	return 0;
-}
-#endif
-
-int msm_mctl_map_user_frame(struct msm_cam_meta_frame *meta_frame,
-	struct ion_client *client, int domain_num)
-{
-
-	if ((NULL == meta_frame) || (NULL == client)) {
-		pr_err("%s Invalid input ", __func__);
-		return -EINVAL;
-	}
-
-	memset(&meta_frame->map[0], 0,
-		sizeof(struct msm_cam_buf_map_info) * VIDEO_MAX_PLANES);
-
-	return __msm_mctl_map_user_frame(meta_frame, client, domain_num);
-}
-
-int msm_mctl_unmap_user_frame(struct msm_cam_meta_frame *meta_frame,
-	struct ion_client *client, int domain_num)
-{
-	if ((NULL == meta_frame) || (NULL == client)) {
-		pr_err("%s Invalid input ", __func__);
-		return -EINVAL;
-	}
-	__msm_mctl_unmap_user_frame(meta_frame, client, domain_num);
-	return 0;
-}
diff --git a/drivers/media/platform/msm/camera_v1/msm_mctl_pp.c b/drivers/media/platform/msm/camera_v1/msm_mctl_pp.c
deleted file mode 100644
index ae3ce63..0000000
--- a/drivers/media/platform/msm/camera_v1/msm_mctl_pp.c
+++ /dev/null
@@ -1,738 +0,0 @@
-/* Copyright (c) 2011-2013, The Linux Foundation. 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.
- *
- */
-
-#include <linux/workqueue.h>
-#include <linux/delay.h>
-#include <linux/types.h>
-#include <linux/list.h>
-#include <linux/ioctl.h>
-#include <linux/spinlock.h>
-#include <linux/videodev2.h>
-#include <linux/proc_fs.h>
-#include <linux/vmalloc.h>
-
-#include <media/v4l2-dev.h>
-#include <media/v4l2-ioctl.h>
-#include <media/v4l2-device.h>
-
-
-
-#include "msm.h"
-#include "msm_vpe.h"
-
-#ifdef CONFIG_MSM_CAMERA_DEBUG
-#define D(fmt, args...) pr_debug("msm_mctl: " fmt, ##args)
-#else
-#define D(fmt, args...) do {} while (0)
-#endif
-
-static int msm_mctl_pp_buf_divert(
-			struct msm_cam_media_controller *pmctl,
-			struct msm_cam_v4l2_dev_inst *pcam_inst,
-			struct msm_cam_evt_divert_frame *div)
-{
-	struct v4l2_event v4l2_evt;
-	struct msm_isp_event_ctrl *isp_event;
-	isp_event = kzalloc(sizeof(struct msm_isp_event_ctrl),
-						GFP_ATOMIC);
-	if (!isp_event) {
-		pr_err("%s Insufficient memory. return", __func__);
-		return -ENOMEM;
-	}
-	D("%s: msm_cam_evt_divert_frame=%d",
-		__func__, sizeof(struct msm_cam_evt_divert_frame));
-	memset(&v4l2_evt, 0, sizeof(v4l2_evt));
-	v4l2_evt.id = 0;
-	v4l2_evt.type = V4L2_EVENT_PRIVATE_START +
-			MSM_CAM_RESP_DIV_FRAME_EVT_MSG;
-	*((uint32_t *)v4l2_evt.u.data) = (uint32_t)isp_event;
-	/* Copy the divert frame struct into event ctrl struct. */
-	isp_event->isp_data.div_frame = *div;
-
-	D("%s inst=%p, img_mode=%d, frame_id=%d\n", __func__,
-		pcam_inst, pcam_inst->image_mode, div->frame.frame_id);
-	v4l2_event_queue(
-		pmctl->config_device->config_stat_event_queue.pvdev,
-		&v4l2_evt);
-	return 0;
-}
-
-int msm_mctl_check_pp(struct msm_cam_media_controller *p_mctl,
-	int image_mode, int *pp_divert_type, int *pp_type)
-{
-	int rc = 0;
-	unsigned long flags;
-	uint32_t pp_key = 0;
-
-	*pp_type = 0;
-	*pp_divert_type = 0;
-	spin_lock_irqsave(&p_mctl->pp_info.lock, flags);
-	switch (image_mode) {
-	case MSM_V4L2_EXT_CAPTURE_MODE_PREVIEW:
-		pp_key = PP_PREV;
-		if (p_mctl->pp_info.pp_key & pp_key)
-			*pp_divert_type = OUTPUT_TYPE_P;
-		if (p_mctl->pp_info.pp_ctrl.pp_msg_type & OUTPUT_TYPE_P)
-			*pp_type = OUTPUT_TYPE_P;
-		break;
-	case MSM_V4L2_EXT_CAPTURE_MODE_MAIN:
-		pp_key = PP_SNAP;
-		if (p_mctl->pp_info.pp_key & pp_key)
-			*pp_divert_type = OUTPUT_TYPE_S;
-		if (p_mctl->pp_info.pp_ctrl.pp_msg_type & OUTPUT_TYPE_S)
-			*pp_type = OUTPUT_TYPE_P;
-		break;
-	case MSM_V4L2_EXT_CAPTURE_MODE_VIDEO:
-		if (p_mctl->pp_info.pp_ctrl.pp_msg_type == OUTPUT_TYPE_V)
-			*pp_type = OUTPUT_TYPE_V;
-		break;
-	case MSM_V4L2_EXT_CAPTURE_MODE_THUMBNAIL:
-		pp_key = PP_THUMB;
-		if (p_mctl->pp_info.pp_key & pp_key)
-			*pp_divert_type = OUTPUT_TYPE_T;
-		if (p_mctl->pp_info.pp_ctrl.pp_msg_type == OUTPUT_TYPE_T)
-			*pp_type = OUTPUT_TYPE_T;
-		break;
-	case MSM_V4L2_EXT_CAPTURE_MODE_RDI:
-		if (p_mctl->pp_info.pp_ctrl.pp_msg_type & OUTPUT_TYPE_R)
-			*pp_type = OUTPUT_TYPE_R;
-		break;
-	default:
-		break;
-	}
-	if (p_mctl->vfe_output_mode != VFE_OUTPUTS_MAIN_AND_THUMB &&
-		p_mctl->vfe_output_mode != VFE_OUTPUTS_THUMB_AND_MAIN) {
-		if (p_mctl->pp_info.div_frame[image_mode].ch_paddr[0])
-			*pp_divert_type = 0;
-	}
-	spin_unlock_irqrestore(&p_mctl->pp_info.lock, flags);
-	D("%s: pp_type=%d, pp_divert_type = %d",
-	__func__, *pp_type, *pp_divert_type);
-	return rc;
-}
-
-static int is_buf_in_queue(struct msm_cam_v4l2_device *pcam,
-	struct msm_free_buf *fbuf, int image_mode)
-{
-	struct msm_frame_buffer *buf = NULL, *tmp;
-	struct msm_cam_v4l2_dev_inst *pcam_inst = NULL;
-	unsigned long flags = 0;
-	struct videobuf2_contig_pmem *mem;
-	uint32_t buf_idx, offset = 0;
-	uint32_t buf_phyaddr = 0;
-	int idx;
-	idx = pcam->mctl_node.dev_inst_map[image_mode]->my_index;
-	pcam_inst = pcam->mctl_node.dev_inst[idx];
-	spin_lock_irqsave(&pcam_inst->vq_irqlock, flags);
-	list_for_each_entry_safe(buf, tmp,
-	&pcam_inst->free_vq, list) {
-		buf_idx = buf->vidbuf.v4l2_buf.index;
-		mem = vb2_plane_cookie(&buf->vidbuf, 0);
-		if (mem == NULL) {
-			pr_err("%s Inst %p Buffer %d invalid plane cookie",
-				__func__, pcam_inst, buf_idx);
-			spin_unlock_irqrestore(&pcam_inst->vq_irqlock, flags);
-			return 0;
-		}
-		if (mem->buffer_type ==	VIDEOBUF2_MULTIPLE_PLANES)
-			offset = mem->offset.data_offset +
-				pcam_inst->buf_offset[buf_idx][0].data_offset;
-		else
-			offset = mem->offset.sp_off.y_off;
-		buf_phyaddr = (unsigned long)
-			videobuf2_to_pmem_contig(&buf->vidbuf, 0) +
-			offset;
-		D("%s vb_idx=%d,vb_paddr=0x%x ch0=0x%x\n",
-		  __func__, buf->vidbuf.v4l2_buf.index,
-		  buf_phyaddr, fbuf->ch_paddr[0]);
-		if (fbuf->ch_paddr[0] == buf_phyaddr) {
-			spin_unlock_irqrestore(&pcam_inst->vq_irqlock, flags);
-			return 1;
-		}
-	}
-	spin_unlock_irqrestore(&pcam_inst->vq_irqlock, flags);
-	return 0;
-}
-
-static struct msm_cam_v4l2_dev_inst *msm_mctl_get_pcam_inst_for_divert(
-	struct msm_cam_media_controller *pmctl,
-	struct msm_cam_buf_handle *buf_handle,
-	struct msm_free_buf *fbuf, int *node_type)
-{
-	struct msm_cam_v4l2_dev_inst *pcam_inst = NULL;
-	struct msm_cam_v4l2_device *pcam = pmctl->pcam_ptr;
-	int idx;
-	uint32_t img_mode;
-
-	if (buf_handle->buf_lookup_type == BUF_LOOKUP_BY_INST_HANDLE) {
-		idx = GET_MCTLPP_INST_IDX(buf_handle->inst_handle);
-		if (idx > MSM_DEV_INST_MAX) {
-			idx = GET_VIDEO_INST_IDX(buf_handle->inst_handle);
-			BUG_ON(idx > MSM_DEV_INST_MAX);
-			pcam_inst = pcam->dev_inst[idx];
-			*node_type = VIDEO_NODE;
-		} else {
-			pcam_inst = pcam->mctl_node.dev_inst[idx];
-			*node_type = MCTL_NODE;
-		}
-	} else if (buf_handle->buf_lookup_type == BUF_LOOKUP_BY_IMG_MODE) {
-		img_mode = buf_handle->image_mode;
-		if (img_mode >= 0 && img_mode < MSM_V4L2_EXT_CAPTURE_MODE_MAX) {
-			/* Valid image mode. Search the mctl node first.
-			 * If mctl node doesnt have the instance, then
-			 * search in the user's video node */
-			if (pcam->mctl_node.dev_inst_map[img_mode]
-				&& is_buf_in_queue(pcam, fbuf, img_mode)) {
-				idx = pcam->mctl_node.
-					dev_inst_map[img_mode]->my_index;
-				pcam_inst = pcam->mctl_node.dev_inst[idx];
-				*node_type = MCTL_NODE;
-				D("%s Found instance %p in mctl node device\n",
-					__func__, pcam_inst);
-			} else if (pcam->dev_inst_map[img_mode]) {
-				idx = pcam->dev_inst_map[img_mode]->my_index;
-				pcam_inst = pcam->dev_inst[idx];
-				*node_type = VIDEO_NODE;
-				D("%s Found instance %p in video device",
-					__func__, pcam_inst);
-			} else {
-				pr_err("%s Cannot find instance for %d.\n",
-					__func__, img_mode);
-			}
-		} else {
-			pr_err("%s Invalid image mode %d. Return NULL\n",
-				__func__, buf_handle->image_mode);
-		}
-	} else {
-		pr_err("%s Invalid buffer lookup type ", __func__);
-	}
-	return pcam_inst;
-}
-
-int msm_mctl_do_pp_divert(
-	struct msm_cam_media_controller *p_mctl,
-	struct msm_cam_buf_handle *buf_handle,
-	struct msm_free_buf *fbuf,
-	uint32_t frame_id, int pp_type)
-{
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	int rc = 0, i, buf_idx, node;
-	int del_buf = 0; /* delete from free queue */
-	struct msm_cam_evt_divert_frame div;
-	struct msm_frame_buffer *vb = NULL;
-	struct videobuf2_contig_pmem *mem;
-	uint32_t image_mode;
-
-	if (buf_handle->buf_lookup_type == BUF_LOOKUP_BY_IMG_MODE) {
-		image_mode = buf_handle->image_mode;
-		div.frame.inst_handle = 0;
-	} else if (buf_handle->buf_lookup_type == BUF_LOOKUP_BY_INST_HANDLE) {
-		image_mode = GET_IMG_MODE(buf_handle->inst_handle);
-		div.frame.inst_handle = buf_handle->inst_handle;
-	} else {
-		pr_err("%s Invalid buffer lookup type %d ", __func__,
-			buf_handle->buf_lookup_type);
-		return -EINVAL;
-	}
-
-	pcam_inst = msm_mctl_get_pcam_inst_for_divert(p_mctl,
-			buf_handle, fbuf, &node);
-	if (!pcam_inst) {
-		pr_err("%s Invalid instance. Cannot divert frame.\n",
-			__func__);
-		return -EINVAL;
-	}
-	vb = msm_mctl_buf_find(p_mctl, pcam_inst, del_buf, fbuf);
-	if (!vb)
-		return -EINVAL;
-
-	vb->vidbuf.v4l2_buf.sequence = frame_id;
-	buf_idx = vb->vidbuf.v4l2_buf.index;
-	D("%s Diverting frame %d %x Image mode %d\n", __func__, buf_idx,
-		(uint32_t)vb, pcam_inst->image_mode);
-	div.image_mode = pcam_inst->image_mode;
-	div.op_mode    = pcam_inst->pcam->op_mode;
-	div.inst_idx   = pcam_inst->my_index;
-	div.node_idx   = pcam_inst->pcam->vnode_id;
-	p_mctl->pp_info.cur_frame_id[pcam_inst->image_mode] = frame_id;
-	div.frame.frame_id =
-		p_mctl->pp_info.cur_frame_id[pcam_inst->image_mode];
-	div.frame.buf_idx  = buf_idx;
-	div.frame.handle = (uint32_t)vb;
-	msm_mctl_gettimeofday(&div.frame.timestamp);
-	vb->vidbuf.v4l2_buf.timestamp = div.frame.timestamp;
-	div.do_pp = pp_type;
-	D("%s Diverting frame %x id %d to userspace ", __func__,
-		(int)div.frame.handle, div.frame.frame_id);
-	/* Get the cookie for 1st plane and store the path.
-	 * Also use this to check the number of planes in
-	 * this buffer.*/
-	mem = vb2_plane_cookie(&vb->vidbuf, 0);
-	if (mem == NULL) {
-		pr_err("%s Inst %p Buffer %d, invalid plane cookie ", __func__,
-			pcam_inst, buf_idx);
-		return -EINVAL;
-	}
-	div.frame.path = mem->path;
-	div.frame.node_type = node;
-	if (mem->buffer_type == VIDEOBUF2_SINGLE_PLANE) {
-		/* This buffer contains only 1 plane. Use the
-		 * single planar structure to store the info.*/
-		div.frame.num_planes	= 1;
-		div.frame.sp.phy_addr	=
-			videobuf2_to_pmem_contig(&vb->vidbuf, 0);
-		div.frame.sp.addr_offset = mem->addr_offset;
-		div.frame.sp.y_off      = 0;
-		div.frame.sp.cbcr_off   = mem->offset.sp_off.cbcr_off;
-		div.frame.sp.fd         = (int)mem->vaddr;
-		div.frame.sp.length     = mem->size;
-		if (!pp_type)
-			p_mctl->pp_info.div_frame[pcam_inst->image_mode].
-			ch_paddr[0] = div.frame.sp.phy_addr;
-	} else {
-		/* This buffer contains multiple planes. Use the mutliplanar
-		 * structure to store the info. */
-		div.frame.num_planes	= pcam_inst->plane_info.num_planes;
-		/* Now traverse through all the planes of the buffer to
-		 * fill out the plane info. */
-		for (i = 0; i < div.frame.num_planes; i++) {
-			mem = vb2_plane_cookie(&vb->vidbuf, i);
-			if (mem == NULL) {
-				pr_err("%s Inst %p %d invalid plane cookie ",
-					__func__, pcam_inst, buf_idx);
-				return -EINVAL;
-			}
-			div.frame.mp[i].phy_addr =
-				videobuf2_to_pmem_contig(&vb->vidbuf, i);
-			if (!pcam_inst->buf_offset)
-				div.frame.mp[i].data_offset = 0;
-			else
-				div.frame.mp[i].data_offset =
-				pcam_inst->buf_offset[buf_idx][i].data_offset;
-			div.frame.mp[i].addr_offset =
-				mem->addr_offset;
-			div.frame.mp[i].fd = (int)mem->vaddr;
-			div.frame.mp[i].length = mem->size;
-		}
-		if (!pp_type)
-			p_mctl->pp_info.div_frame[pcam_inst->image_mode].
-			ch_paddr[0] = div.frame.mp[0].phy_addr +
-					div.frame.mp[0].data_offset;
-	}
-	rc = msm_mctl_pp_buf_divert(p_mctl, pcam_inst, &div);
-	return rc;
-}
-
-static int msm_mctl_pp_get_phy_addr(
-	struct msm_cam_v4l2_dev_inst *pcam_inst,
-	uint32_t frame_handle,
-	struct msm_pp_frame *pp_frame)
-{
-	struct msm_frame_buffer *vb = NULL;
-	struct videobuf2_contig_pmem *mem;
-	int i, buf_idx = 0;
-
-	vb = (struct msm_frame_buffer *)frame_handle;
-	buf_idx = vb->vidbuf.v4l2_buf.index;
-	memset(pp_frame, 0, sizeof(struct msm_pp_frame));
-	pp_frame->handle = (uint32_t)vb;
-	pp_frame->frame_id = vb->vidbuf.v4l2_buf.sequence;
-	pp_frame->timestamp = vb->vidbuf.v4l2_buf.timestamp;
-	pp_frame->buf_idx = buf_idx;
-	pp_frame->inst_handle = pcam_inst->inst_handle;
-	/* Get the cookie for 1st plane and store the path.
-	 * Also use this to check the number of planes in
-	 * this buffer.*/
-	mem = vb2_plane_cookie(&vb->vidbuf, 0);
-	if (mem == NULL) {
-		pr_err("%s Inst %p Buffer %d, invalid plane cookie ", __func__,
-			pcam_inst, buf_idx);
-		return -EINVAL;
-	}
-	pp_frame->image_type = (unsigned short)mem->path;
-	if (mem->buffer_type == VIDEOBUF2_SINGLE_PLANE) {
-		pp_frame->num_planes = 1;
-		pp_frame->sp.addr_offset = mem->addr_offset;
-		pp_frame->sp.phy_addr =
-			videobuf2_to_pmem_contig(&vb->vidbuf, 0);
-		pp_frame->sp.y_off = 0;
-		pp_frame->sp.cbcr_off = mem->offset.sp_off.cbcr_off;
-		pp_frame->sp.length = mem->size;
-		pp_frame->sp.fd = (int)mem->vaddr;
-	} else {
-		pp_frame->num_planes = pcam_inst->plane_info.num_planes;
-		for (i = 0; i < pp_frame->num_planes; i++) {
-			mem = vb2_plane_cookie(&vb->vidbuf, i);
-			pp_frame->mp[i].addr_offset = mem->addr_offset;
-			pp_frame->mp[i].phy_addr =
-				videobuf2_to_pmem_contig(&vb->vidbuf, i);
-			pp_frame->mp[i].data_offset =
-			pcam_inst->buf_offset[buf_idx][i].data_offset;
-			pp_frame->mp[i].fd = (int)mem->vaddr;
-			pp_frame->mp[i].length = mem->size;
-			D("%s frame id %d buffer %d plane %d phy addr 0x%x"
-				" fd %d length %d\n", __func__,
-				pp_frame->frame_id, buf_idx, i,
-				(uint32_t)pp_frame->mp[i].phy_addr,
-				pp_frame->mp[i].fd, pp_frame->mp[i].length);
-		}
-	}
-	return 0;
-}
-
-static int msm_mctl_pp_path_to_img_mode(int path)
-{
-	switch (path) {
-	case OUTPUT_TYPE_P:
-		return MSM_V4L2_EXT_CAPTURE_MODE_PREVIEW;
-	case OUTPUT_TYPE_V:
-		return MSM_V4L2_EXT_CAPTURE_MODE_VIDEO;
-	case OUTPUT_TYPE_S:
-		return MSM_V4L2_EXT_CAPTURE_MODE_MAIN;
-	case OUTPUT_TYPE_T:
-		return MSM_V4L2_EXT_CAPTURE_MODE_THUMBNAIL;
-	case OUTPUT_TYPE_SAEC:
-		return MSM_V4L2_EXT_CAPTURE_MODE_AEC;
-	case OUTPUT_TYPE_SAWB:
-		return MSM_V4L2_EXT_CAPTURE_MODE_AWB;
-	case OUTPUT_TYPE_SAFC:
-		return MSM_V4L2_EXT_CAPTURE_MODE_AF;
-	case OUTPUT_TYPE_IHST:
-		return MSM_V4L2_EXT_CAPTURE_MODE_IHIST;
-	case OUTPUT_TYPE_CSTA:
-		return MSM_V4L2_EXT_CAPTURE_MODE_CSTA;
-	default:
-		return -EINVAL;
-	}
-}
-
-int msm_mctl_pp_proc_cmd(struct msm_cam_media_controller *p_mctl,
-			struct msm_mctl_pp_cmd *pp_cmd)
-{
-	int rc = 0;
-	unsigned long flags;
-
-	switch (pp_cmd->id) {
-	case MCTL_CMD_DIVERT_FRAME_PP_PATH: {
-		struct msm_mctl_pp_divert_pp divert_pp;
-		if (copy_from_user(&divert_pp, pp_cmd->value,
-				sizeof(divert_pp))) {
-			ERR_COPY_FROM_USER();
-			return -EFAULT;
-		}
-		D("%s: Divert Image mode =%d Enable %d",
-			__func__, divert_pp.path, divert_pp.enable);
-		spin_lock_irqsave(&p_mctl->pp_info.lock, flags);
-		if (divert_pp.enable)
-			p_mctl->pp_info.pp_ctrl.pp_msg_type |= divert_pp.path;
-		else
-			p_mctl->pp_info.pp_ctrl.pp_msg_type &= ~divert_pp.path;
-		spin_unlock_irqrestore(&p_mctl->pp_info.lock, flags);
-		D("%s: pp path = 0x%x", __func__,
-			p_mctl->pp_info.pp_ctrl.pp_msg_type);
-		break;
-	}
-	default:
-		rc = -EPERM;
-	break;
-	}
-	return rc;
-}
-
-
-int msm_mctl_pp_ioctl(struct msm_cam_media_controller *p_mctl,
-			unsigned int cmd, unsigned long arg)
-{
-	int rc = -EINVAL;
-	struct msm_mctl_post_proc_cmd pp_cmd;
-	void __user *argp = (void __user *)arg;
-
-	if (copy_from_user(&pp_cmd, argp, sizeof(pp_cmd)))
-		return -EFAULT;
-
-	switch (pp_cmd.type) {
-	case MSM_PP_CMD_TYPE_MCTL:
-		rc = msm_mctl_pp_proc_cmd(p_mctl, &pp_cmd.cmd);
-		break;
-	default:
-		rc = -EPERM;
-		break;
-	}
-	if (!rc) {
-		/* deep copy back the return value */
-		if (copy_to_user((void *)arg,
-			&pp_cmd,
-			sizeof(struct msm_mctl_post_proc_cmd))) {
-			ERR_COPY_TO_USER();
-			rc = -EFAULT;
-		}
-	}
-	return rc;
-}
-
-int msm_mctl_pp_reserve_free_frame(
-	struct msm_cam_media_controller *p_mctl,
-	void __user *arg)
-{
-	struct msm_cam_evt_divert_frame div_frame;
-	int image_mode, rc = 0;
-	struct msm_free_buf free_buf;
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	struct msm_cam_buf_handle buf_handle;
-
-	memset(&free_buf, 0, sizeof(struct msm_free_buf));
-	if (copy_from_user(&div_frame, arg,
-		sizeof(struct msm_cam_evt_divert_frame))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-
-	image_mode = div_frame.image_mode;
-	if (image_mode <= 0) {
-		pr_err("%s Invalid image mode %d", __func__, image_mode);
-		return -EINVAL;
-	}
-	/* Always reserve the buffer from user's video node */
-	pcam_inst = p_mctl->pcam_ptr->dev_inst_map[image_mode];
-	if (!pcam_inst) {
-		pr_err("%s Instance already closed ", __func__);
-		return -EINVAL;
-	}
-	D("%s Reserving free frame using %p inst handle %x ", __func__,
-		pcam_inst, div_frame.frame.inst_handle);
-	if (div_frame.frame.inst_handle) {
-		buf_handle.buf_lookup_type = BUF_LOOKUP_BY_INST_HANDLE;
-		buf_handle.inst_handle = div_frame.frame.inst_handle;
-	} else {
-		buf_handle.buf_lookup_type = BUF_LOOKUP_BY_IMG_MODE;
-		buf_handle.image_mode = image_mode;
-	}
-	rc = msm_mctl_reserve_free_buf(p_mctl, pcam_inst,
-					&buf_handle, &free_buf);
-	if (rc == 0) {
-		msm_mctl_pp_get_phy_addr(pcam_inst,
-			free_buf.vb, &div_frame.frame);
-		if (copy_to_user((void *)arg, &div_frame, sizeof(div_frame))) {
-			ERR_COPY_TO_USER();
-			rc = -EFAULT;
-		}
-	}
-	D("%s: Got buffer %d from Inst %p rc = %d, phy = 0x%x",
-		__func__, div_frame.frame.buf_idx,
-		pcam_inst, rc, free_buf.ch_paddr[0]);
-	return rc;
-}
-
-int msm_mctl_pp_release_free_frame(
-	struct msm_cam_media_controller *p_mctl,
-	void __user *arg)
-{
-	struct msm_cam_evt_divert_frame div_frame;
-	struct msm_cam_v4l2_dev_inst *pcam_inst;
-	struct msm_pp_frame *frame;
-	int image_mode, rc = 0;
-	struct msm_free_buf free_buf;
-	struct msm_cam_buf_handle buf_handle;
-
-	if (copy_from_user(&div_frame, arg,
-		sizeof(struct msm_cam_evt_divert_frame))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-
-	image_mode = div_frame.image_mode;
-	if (image_mode < 0) {
-		pr_err("%s Invalid image mode %d\n", __func__, image_mode);
-		return -EINVAL;
-	}
-	frame = &div_frame.frame;
-	if (frame->num_planes > 1)
-		free_buf.ch_paddr[0] = frame->mp[0].phy_addr;
-	else
-		free_buf.ch_paddr[0] = frame->sp.phy_addr;
-
-	if (div_frame.frame.inst_handle) {
-		buf_handle.buf_lookup_type = BUF_LOOKUP_BY_INST_HANDLE;
-		buf_handle.inst_handle = div_frame.frame.inst_handle;
-	} else {
-		buf_handle.buf_lookup_type = BUF_LOOKUP_BY_IMG_MODE;
-		buf_handle.image_mode = image_mode;
-	}
-	pcam_inst = msm_mctl_get_pcam_inst(p_mctl, &buf_handle);
-	if (!pcam_inst) {
-		pr_err("%s Invalid instance. Cannot release frame.\n",
-			__func__);
-		return -EINVAL;
-	}
-
-	rc = msm_mctl_release_free_buf(p_mctl, pcam_inst, &free_buf);
-	D("%s: release free buf, rc = %d, phy = 0x%x",
-		__func__, rc, free_buf.ch_paddr[0]);
-
-	return rc;
-}
-
-int msm_mctl_set_pp_key(struct msm_cam_media_controller *p_mctl,
-				void __user *arg)
-{
-	int rc = 0;
-	unsigned long flags;
-	spin_lock_irqsave(&p_mctl->pp_info.lock, flags);
-	if (copy_from_user(&p_mctl->pp_info.pp_key,
-			arg, sizeof(p_mctl->pp_info.pp_key))) {
-		ERR_COPY_FROM_USER();
-		rc = -EFAULT;
-	} else {
-		D("%s: mctl=0x%p, pp_key_setting=0x%x",
-			__func__, p_mctl, p_mctl->pp_info.pp_key);
-	}
-	spin_unlock_irqrestore(&p_mctl->pp_info.lock, flags);
-	return rc;
-}
-
-int msm_mctl_pp_done(
-	struct msm_cam_media_controller *p_mctl,
-	void __user *arg)
-{
-	struct msm_pp_frame frame;
-	int image_mode, rc = 0;
-	int dirty = 0;
-	struct msm_free_buf buf;
-	unsigned long flags;
-	struct msm_cam_buf_handle buf_handle;
-	struct msm_cam_return_frame_info ret_frame;
-
-	if (copy_from_user(&frame, arg, sizeof(frame))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-
-	spin_lock_irqsave(&p_mctl->pp_info.lock, flags);
-	if (frame.inst_handle) {
-		buf_handle.buf_lookup_type = BUF_LOOKUP_BY_INST_HANDLE;
-		buf_handle.inst_handle = frame.inst_handle;
-		image_mode = GET_IMG_MODE(frame.inst_handle);
-	} else {
-		buf_handle.buf_lookup_type = BUF_LOOKUP_BY_IMG_MODE;
-		buf_handle.image_mode =
-			msm_mctl_pp_path_to_img_mode(frame.path);
-		image_mode = buf_handle.image_mode;
-	}
-	if (image_mode < 0) {
-		pr_err("%s Invalid image mode\n", __func__);
-		return image_mode;
-	}
-	D("%s Returning frame %x id %d to kernel ", __func__,
-		(int)frame.handle, frame.frame_id);
-	if (p_mctl->pp_info.div_frame[image_mode].ch_paddr[0]) {
-		memcpy(&buf,
-			&p_mctl->pp_info.div_frame[image_mode],
-			sizeof(buf));
-		memset(&p_mctl->pp_info.div_frame[image_mode],
-			0, sizeof(buf));
-		if (p_mctl->pp_info.cur_frame_id[image_mode] !=
-					frame.frame_id) {
-			/* dirty frame. should not pass to app */
-			dirty = 1;
-		}
-	} else {
-		if (frame.num_planes > 1)
-			buf.ch_paddr[0] = frame.mp[0].phy_addr +
-						frame.mp[0].data_offset;
-		else
-			buf.ch_paddr[0] = frame.sp.phy_addr + frame.sp.y_off;
-	}
-	spin_unlock_irqrestore(&p_mctl->pp_info.lock, flags);
-
-	ret_frame.dirty = dirty;
-	ret_frame.node_type = 0;
-	ret_frame.timestamp = frame.timestamp;
-	ret_frame.frame_id   = frame.frame_id;
-	D("%s frame_id: %d buffer idx %d\n", __func__,
-		frame.frame_id, frame.buf_idx);
-	rc = msm_mctl_buf_done_pp(p_mctl, &buf_handle, &buf, &ret_frame);
-	return rc;
-}
-
-int msm_mctl_pp_divert_done(
-	struct msm_cam_media_controller *p_mctl,
-	void __user *arg)
-{
-	struct msm_pp_frame frame;
-	int rc = 0;
-	struct msm_free_buf buf;
-	unsigned long flags;
-	struct msm_cam_buf_handle buf_handle;
-	struct msm_cam_return_frame_info ret_frame;
-
-	D("%s enter\n", __func__);
-
-	if (copy_from_user(&frame, arg, sizeof(frame))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-
-	spin_lock_irqsave(&p_mctl->pp_info.lock, flags);
-	if (frame.inst_handle) {
-		buf_handle.buf_lookup_type = BUF_LOOKUP_BY_INST_HANDLE;
-		buf_handle.inst_handle = frame.inst_handle;
-	} else {
-		buf_handle.buf_lookup_type = BUF_LOOKUP_BY_IMG_MODE;
-		buf_handle.image_mode = frame.image_type;
-	}
-
-	if (frame.num_planes > 1)
-		buf.ch_paddr[0] = frame.mp[0].phy_addr +
-					frame.mp[0].data_offset;
-	else
-		buf.ch_paddr[0] = frame.sp.phy_addr + frame.sp.y_off;
-
-	spin_unlock_irqrestore(&p_mctl->pp_info.lock, flags);
-
-	ret_frame.dirty = 0;
-	ret_frame.node_type = frame.node_type;
-	ret_frame.timestamp = frame.timestamp;
-	ret_frame.frame_id  = frame.frame_id;
-	D("%s Frame done id: %d\n", __func__, frame.frame_id);
-	rc = msm_mctl_buf_done_pp(p_mctl, &buf_handle, &buf, &ret_frame);
-	return rc;
-}
-
-int msm_mctl_pp_mctl_divert_done(
-	struct msm_cam_media_controller *p_mctl,
-	void __user *arg)
-{
-	struct msm_cam_evt_divert_frame div_frame;
-	struct msm_frame_buffer *buf;
-	int image_mode, rc = 0;
-
-	if (copy_from_user(&div_frame, arg,
-			sizeof(struct msm_cam_evt_divert_frame))) {
-		pr_err("%s copy from user failed ", __func__);
-		return -EFAULT;
-	}
-
-	if (!div_frame.frame.handle) {
-		pr_err("%s Invalid buffer handle ", __func__);
-		return -EINVAL;
-	}
-	image_mode = div_frame.image_mode;
-	buf = (struct msm_frame_buffer *)div_frame.frame.handle;
-	D("%s Returning buffer %x Image mode %d ", __func__,
-		(int)buf, image_mode);
-	rc = msm_mctl_buf_return_buf(p_mctl, image_mode, buf);
-	if (rc < 0)
-		pr_err("%s Error returning mctl buffer ", __func__);
-
-	return rc;
-}
diff --git a/drivers/media/platform/msm/camera_v1/msm_mem.c b/drivers/media/platform/msm/camera_v1/msm_mem.c
deleted file mode 100644
index c9a87d7..0000000
--- a/drivers/media/platform/msm/camera_v1/msm_mem.c
+++ /dev/null
@@ -1,392 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/workqueue.h>
-#include <linux/delay.h>
-#include <linux/types.h>
-#include <linux/list.h>
-#include <linux/ioctl.h>
-#include <linux/spinlock.h>
-#include <linux/videodev2.h>
-#include <linux/proc_fs.h>
-#include <linux/vmalloc.h>
-
-#include <media/v4l2-dev.h>
-#include <media/v4l2-ioctl.h>
-#include <media/v4l2-device.h>
-
-
-
-#include "msm.h"
-
-#ifdef CONFIG_MSM_CAMERA_DEBUG
-#define D(fmt, args...) pr_debug("msm_isp: " fmt, ##args)
-#else
-#define D(fmt, args...) do {} while (0)
-#endif
-
-#define PAD_TO_WORD(a)	  (((a) + 3) & ~3)
-
-#define __CONTAINS(r, v, l, field) ({			   \
-	typeof(r) __r = r;				  \
-	typeof(v) __v = v;				  \
-	typeof(v) __e = __v + l;				\
-	int res = __v >= __r->field &&			  \
-		__e <= __r->field + __r->len;		   \
-	res;							\
-})
-
-#define CONTAINS(r1, r2, field) ({			  \
-	typeof(r2) __r2 = r2;				   \
-	__CONTAINS(r1, __r2->field, __r2->len, field);	  \
-})
-
-#define IN_RANGE(r, v, field) ({				\
-	typeof(r) __r = r;				  \
-	typeof(v) __vv = v;				 \
-	int res = ((__vv >= __r->field) &&		  \
-		(__vv < (__r->field + __r->len)));	  \
-	res;							\
-})
-
-#define OVERLAPS(r1, r2, field) ({			  \
-	typeof(r1) __r1 = r1;				   \
-	typeof(r2) __r2 = r2;				   \
-	typeof(__r2->field) __v = __r2->field;		  \
-	typeof(__v) __e = __v + __r2->len - 1;		  \
-	int res = (IN_RANGE(__r1, __v, field) ||		\
-		IN_RANGE(__r1, __e, field));				 \
-	res;							\
-})
-
-static DEFINE_MUTEX(hlist_mut);
-
-static int check_overlap(struct hlist_head *ptype,
-				unsigned long paddr,
-				unsigned long len)
-{
-	struct msm_pmem_region *region;
-	struct msm_pmem_region t = { .paddr = paddr, .len = len };
-	struct hlist_node *node;
-
-	hlist_for_each_entry(region, node, ptype, list) {
-		if (CONTAINS(region, &t, paddr) ||
-			CONTAINS(&t, region, paddr) ||
-			OVERLAPS(region, &t, paddr)) {
-			CDBG(" region (PHYS %p len %ld)"
-				" clashes with registered region"
-				" (paddr %p len %ld)\n",
-				(void *)t.paddr, t.len,
-				(void *)region->paddr, region->len);
-			return -EINVAL;
-		}
-	}
-
-	return 0;
-}
-
-static int msm_pmem_table_add(struct hlist_head *ptype,
-	struct msm_pmem_info *info, struct ion_client *client, int domain_num)
-{
-	unsigned long paddr;
-#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
-	unsigned long kvstart;
-	struct file *file;
-#endif
-	int rc = -ENOMEM;
-
-	unsigned long len;
-	struct msm_pmem_region *region;
-
-	region = kmalloc(sizeof(struct msm_pmem_region), GFP_KERNEL);
-	if (!region)
-		goto out;
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-	region->handle = ion_import_dma_buf(client, info->fd);
-	if (IS_ERR_OR_NULL(region->handle))
-		goto out1;
-	if (ion_map_iommu(client, region->handle, domain_num, 0,
-				  SZ_4K, 0, &paddr, &len, 0, 0) < 0)
-		goto out2;
-#else
-	paddr = 0;
-	file = NULL;
-	kvstart = 0;
-#endif
-	if (!info->len)
-		info->len = len;
-	paddr += info->offset;
-	len = info->len;
-
-	if (check_overlap(ptype, paddr, len) < 0) {
-		rc = -EINVAL;
-		goto out3;
-	}
-
-	CDBG("%s: type %d, active flag %d, paddr 0x%lx, vaddr 0x%lx\n",
-		__func__, info->type, info->active, paddr,
-		(unsigned long)info->vaddr);
-
-	INIT_HLIST_NODE(&region->list);
-	region->paddr = paddr;
-	region->len = len;
-	memcpy(&region->info, info, sizeof(region->info));
-	D("%s Adding region to list with type %d\n", __func__,
-						region->info.type);
-	D("%s pmem_stats address is 0x%p\n", __func__, ptype);
-	hlist_add_head(&(region->list), ptype);
-
-	return 0;
-out3:
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-	ion_unmap_iommu(client, region->handle, domain_num, 0);
-#endif
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-out2:
-	ion_free(client, region->handle);
-#endif
-out1:
-	kfree(region);
-out:
-	return rc;
-}
-
-static int __msm_register_pmem(struct hlist_head *ptype,
-			struct msm_pmem_info *pinfo, struct ion_client *client,
-			int domain_num)
-{
-	int rc = 0;
-
-	switch (pinfo->type) {
-	case MSM_PMEM_AF:
-	case MSM_PMEM_AEC:
-	case MSM_PMEM_AWB:
-	case MSM_PMEM_RS:
-	case MSM_PMEM_CS:
-	case MSM_PMEM_IHIST:
-	case MSM_PMEM_SKIN:
-	case MSM_PMEM_AEC_AWB:
-	case MSM_PMEM_BAYER_GRID:
-	case MSM_PMEM_BAYER_EXPOSURE:
-	case MSM_PMEM_BAYER_FOCUS:
-	case MSM_PMEM_BAYER_HIST:
-		rc = msm_pmem_table_add(ptype, pinfo, client, domain_num);
-		break;
-
-	default:
-		rc = -EINVAL;
-		break;
-	}
-
-	return rc;
-}
-
-static int __msm_pmem_table_del(struct hlist_head *ptype,
-			struct msm_pmem_info *pinfo, struct ion_client *client,
-			int domain_num)
-{
-	int rc = 0;
-	struct msm_pmem_region *region;
-	struct hlist_node *node, *n;
-
-	switch (pinfo->type) {
-	case MSM_PMEM_AF:
-	case MSM_PMEM_AEC:
-	case MSM_PMEM_AWB:
-	case MSM_PMEM_RS:
-	case MSM_PMEM_CS:
-	case MSM_PMEM_IHIST:
-	case MSM_PMEM_SKIN:
-	case MSM_PMEM_AEC_AWB:
-	case MSM_PMEM_BAYER_GRID:
-	case MSM_PMEM_BAYER_EXPOSURE:
-	case MSM_PMEM_BAYER_FOCUS:
-	case MSM_PMEM_BAYER_HIST:
-		hlist_for_each_entry_safe(region, node, n,
-				ptype, list) {
-
-			if (pinfo->type == region->info.type &&
-				pinfo->vaddr == region->info.vaddr &&
-				pinfo->fd == region->info.fd) {
-				hlist_del(node);
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-				ion_unmap_iommu(client, region->handle,
-					domain_num, 0);
-				ion_free(client, region->handle);
-#endif
-				kfree(region);
-			}
-		}
-		break;
-
-	default:
-		rc = -EINVAL;
-		break;
-	}
-
-	return rc;
-}
-
-/* return of 0 means failure */
-uint8_t msm_pmem_region_lookup(struct hlist_head *ptype,
-	int pmem_type, struct msm_pmem_region *reg, uint8_t maxcount)
-{
-	struct msm_pmem_region *region;
-	struct msm_pmem_region *regptr;
-	struct hlist_node *node, *n;
-
-	uint8_t rc = 0;
-	D("%s\n", __func__);
-	regptr = reg;
-	mutex_lock(&hlist_mut);
-	hlist_for_each_entry_safe(region, node, n, ptype, list) {
-		if (region->info.type == pmem_type && region->info.active) {
-			*regptr = *region;
-			rc += 1;
-			if (rc >= maxcount)
-				break;
-			regptr++;
-		}
-	}
-	D("%s finished, rc=%d\n", __func__, rc);
-	mutex_unlock(&hlist_mut);
-	return rc;
-}
-
-int msm_pmem_region_get_phy_addr(struct hlist_head *ptype,
-	struct msm_mem_map_info *mem_map, int32_t *phyaddr)
-{
-	struct msm_pmem_region *region;
-	struct hlist_node *node, *n;
-	int pmem_type = mem_map->mem_type;
-	int rc = -EFAULT;
-
-	D("%s\n", __func__);
-	*phyaddr = 0;
-	mutex_lock(&hlist_mut);
-	hlist_for_each_entry_safe(region, node, n, ptype, list) {
-		if (region->info.type == pmem_type &&
-			(uint32_t)region->info.vaddr == mem_map->cookie) {
-			*phyaddr = (int32_t)region->paddr;
-			rc = 0;
-			break;
-		}
-	}
-	D("%s finished, phy_addr = 0x%x, rc=%d\n", __func__, *phyaddr, rc);
-	mutex_unlock(&hlist_mut);
-	return rc;
-}
-
-uint8_t msm_pmem_region_lookup_2(struct hlist_head *ptype,
-					int pmem_type,
-					struct msm_pmem_region *reg,
-					uint8_t maxcount)
-{
-	struct msm_pmem_region *region;
-	struct msm_pmem_region *regptr;
-	struct hlist_node *node, *n;
-	uint8_t rc = 0;
-	regptr = reg;
-	mutex_lock(&hlist_mut);
-	hlist_for_each_entry_safe(region, node, n, ptype, list) {
-		D("Mio: info.type=%d, pmem_type = %d,"
-						"info.active = %d\n",
-		region->info.type, pmem_type, region->info.active);
-
-		if (region->info.type == pmem_type && region->info.active) {
-			D("info.type=%d, pmem_type = %d,"
-							"info.active = %d,\n",
-				region->info.type, pmem_type,
-				region->info.active);
-			*regptr = *region;
-			region->info.type = MSM_PMEM_VIDEO;
-			rc += 1;
-			if (rc >= maxcount)
-				break;
-			regptr++;
-		}
-	}
-	mutex_unlock(&hlist_mut);
-	return rc;
-}
-
-unsigned long msm_pmem_stats_vtop_lookup(
-				struct msm_cam_media_controller *mctl,
-				unsigned long buffer,
-				int fd)
-{
-	struct msm_pmem_region *region;
-	struct hlist_node *node, *n;
-
-	hlist_for_each_entry_safe(region, node, n,
-	&mctl->stats_info.pmem_stats_list, list) {
-		if (((unsigned long)(region->info.vaddr) == buffer) &&
-						(region->info.fd == fd) &&
-						region->info.active == 0) {
-			region->info.active = 1;
-			return region->paddr;
-		}
-	}
-
-	return 0;
-}
-
-unsigned long msm_pmem_stats_ptov_lookup(
-		struct msm_cam_media_controller *mctl,
-		unsigned long addr, int *fd)
-{
-	struct msm_pmem_region *region;
-	struct hlist_node *node, *n;
-
-	hlist_for_each_entry_safe(region, node, n,
-	&mctl->stats_info.pmem_stats_list, list) {
-		if (addr == region->paddr && region->info.active) {
-			/* offset since we could pass vaddr inside a
-			 * registered pmem buffer */
-			*fd = region->info.fd;
-			region->info.active = 0;
-			return (unsigned long)(region->info.vaddr);
-		}
-	}
-
-	return 0;
-}
-
-int msm_register_pmem(struct hlist_head *ptype, void __user *arg,
-					struct ion_client *client,
-					int domain_num)
-{
-	struct msm_pmem_info info;
-
-	if (copy_from_user(&info, arg, sizeof(info))) {
-		ERR_COPY_FROM_USER();
-			return -EFAULT;
-	}
-
-	return __msm_register_pmem(ptype, &info, client, domain_num);
-}
-//EXPORT_SYMBOL(msm_register_pmem);
-
-int msm_pmem_table_del(struct hlist_head *ptype, void __user *arg,
-			struct ion_client *client, int domain_num)
-{
-	struct msm_pmem_info info;
-
-	if (copy_from_user(&info, arg, sizeof(info))) {
-		ERR_COPY_FROM_USER();
-		return -EFAULT;
-	}
-
-	return __msm_pmem_table_del(ptype, &info, client, domain_num);
-}
-//EXPORT_SYMBOL(msm_pmem_table_del);
diff --git a/drivers/media/platform/msm/camera_v1/msm_v4l2_video.c b/drivers/media/platform/msm/camera_v1/msm_v4l2_video.c
deleted file mode 100644
index 1849bf6..0000000
--- a/drivers/media/platform/msm/camera_v1/msm_v4l2_video.c
+++ /dev/null
@@ -1,966 +0,0 @@
-/* Copyright (c) 2012-2013, The Linux Foundation. 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.
- */
-
-#include <linux/init.h>
-#include <linux/fb.h>
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/time.h>
-#include <linux/videodev2.h>
-#include <linux/platform_device.h>
-#include <linux/file.h>
-#include <linux/fs.h>
-#include <linux/msm_mdp.h>
-#include <linux/sched.h>
-#include <linux/capability.h>
-
-#include <media/v4l2-ioctl.h>
-#include <media/videobuf-dma-sg.h>
-#include <media/v4l2-dev.h>
-#include <media/msm_v4l2_overlay.h>
-
-#include <mach/board.h>
-#include <mach/msm_fb.h>
-
-#include "msm_v4l2_video.h"
-
-#define MSM_VIDEO -1
-
-static struct msm_v4l2_overlay_device	*saved_vout0;
-
-static struct mutex msmfb_lock;
-static char *v4l2_ram_phys;
-static unsigned int v4l2_ram_size;
-
-static int msm_v4l2_overlay_mapformat(uint32_t pixelformat);
-
-static int msm_v4l2_overlay_startstreaming(struct msm_v4l2_overlay_device *vout)
-{
-	vout->req.src.width = vout->pix.width;
-	vout->req.src.height = vout->pix.height;
-
-	vout->req.src_rect.x = vout->crop_rect.left;
-	vout->req.src_rect.y = vout->crop_rect.top;
-	vout->req.src_rect.w = vout->crop_rect.width;
-	vout->req.src_rect.h = vout->crop_rect.height;
-
-	vout->req.src.format =
-		msm_v4l2_overlay_mapformat(vout->pix.pixelformat);
-
-	vout->req.dst_rect.x = vout->win.w.left;
-	vout->req.dst_rect.y = vout->win.w.top;
-	vout->req.dst_rect.w = vout->win.w.width;
-	vout->req.dst_rect.h = vout->win.w.height;
-
-	vout->req.alpha = MDP_ALPHA_NOP;
-	vout->req.transp_mask = MDP_TRANSP_NOP;
-
-	pr_debug("msm_v4l2_overlay:startstreaming:enabling fb\n");
-	mutex_lock(&msmfb_lock);
-	msm_fb_v4l2_enable(&vout->req, true, &vout->par);
-	mutex_unlock(&msmfb_lock);
-
-	vout->streaming = 1;
-
-	return 0;
-}
-
-static int msm_v4l2_overlay_stopstreaming(struct msm_v4l2_overlay_device *vout)
-{
-	if (!vout->streaming)
-		return 0;
-
-	pr_debug("msm_v4l2_overlay:startstreaming:disabling fb\n");
-	mutex_lock(&msmfb_lock);
-	msm_fb_v4l2_enable(&vout->req, false, &vout->par);
-	mutex_unlock(&msmfb_lock);
-
-	vout->streaming = 0;
-
-	return 0;
-}
-
-static int msm_v4l2_overlay_mapformat(uint32_t pixelformat)
-{
-	int mdp_format;
-
-	switch (pixelformat) {
-	case V4L2_PIX_FMT_RGB565:
-		mdp_format = MDP_RGB_565;
-		break;
-	case V4L2_PIX_FMT_RGB32:
-		mdp_format = MDP_ARGB_8888;
-		break;
-	case V4L2_PIX_FMT_RGB24:
-		mdp_format = MDP_RGB_888;
-		break;
-	case V4L2_PIX_FMT_NV12:
-		mdp_format = MDP_Y_CBCR_H2V2;
-		break;
-	case V4L2_PIX_FMT_NV21:
-		mdp_format = MDP_Y_CRCB_H2V2;
-		break;
-	case V4L2_PIX_FMT_YUV420:
-		mdp_format = MDP_Y_CB_CR_H2V2;
-		break;
-	case V4L2_PIX_FMT_UYVY:
-		mdp_format = MDP_CBYCRY_H2V1;
-		break;
-	case V4L2_PIX_FMT_YUYV:
-		mdp_format = MDP_YCBYCR_H2V1;
-		break;
-	case V4L2_PIX_FMT_YVU420:
-		mdp_format = MDP_Y_CR_CB_GH2V2;
-		break;
-	default:
-		pr_err("%s:Unrecognized format %u\n", __func__, pixelformat);
-		mdp_format = MDP_Y_CBCR_H2V2;
-		break;
-	}
-
-	return mdp_format;
-}
-
-static int
-msm_v4l2_overlay_fb_update(struct msm_v4l2_overlay_device *vout,
-	struct v4l2_buffer *buffer)
-{
-	int ret;
-	unsigned long src_addr, src_size;
-	struct msm_v4l2_overlay_userptr_buffer up_buffer;
-
-	if (!buffer ||
-		(buffer->memory == V4L2_MEMORY_MMAP &&
-		 buffer->index >= vout->numbufs))
-		return -EINVAL;
-
-	mutex_lock(&msmfb_lock);
-	switch (buffer->memory) {
-	case V4L2_MEMORY_MMAP:
-		src_addr = (unsigned long)v4l2_ram_phys
-		+ vout->bufs[buffer->index].offset;
-		src_size = buffer->bytesused;
-		ret = msm_fb_v4l2_update(vout->par, false, src_addr, src_size,
-		0, 0, 0, 0);
-		break;
-	case V4L2_MEMORY_USERPTR:
-		if (copy_from_user(&up_buffer,
-		(void __user *)buffer->m.userptr,
-		sizeof(struct msm_v4l2_overlay_userptr_buffer))) {
-			pr_err("%s:copy_from_user for userptr failed\n",
-				__func__);
-			mutex_unlock(&msmfb_lock);
-			return -EINVAL;
-		}
-		ret = msm_fb_v4l2_update(vout->par, true,
-		(unsigned long)up_buffer.fd[0], up_buffer.offset[0],
-		(unsigned long)up_buffer.fd[1], up_buffer.offset[1],
-		(unsigned long)up_buffer.fd[2], up_buffer.offset[2]);
-		break;
-	default:
-		mutex_unlock(&msmfb_lock);
-		return -EINVAL;
-	}
-	mutex_unlock(&msmfb_lock);
-
-	if (buffer->memory == V4L2_MEMORY_MMAP) {
-		vout->bufs[buffer->index].queued = 1;
-		buffer->flags |= V4L2_BUF_FLAG_MAPPED;
-	}
-	buffer->flags |= V4L2_BUF_FLAG_QUEUED;
-
-	return ret;
-}
-
-static int
-msm_v4l2_overlay_vidioc_dqbuf(struct file *file,
-	struct msm_v4l2_overlay_fh *fh, void *arg)
-{
-	struct msm_v4l2_overlay_device *vout = fh->vout;
-	struct v4l2_buffer *buffer = arg;
-	int i;
-
-	if (!vout->streaming) {
-		pr_err("%s: Video Stream not enabled\n", __func__);
-		return -EINVAL;
-	}
-
-	if (!buffer || buffer->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
-		return -EINVAL;
-
-	if (buffer->memory == V4L2_MEMORY_MMAP) {
-		for (i = 0; i < vout->numbufs; i++) {
-			if (vout->bufs[i].queued == 1)  {
-				vout->bufs[i].queued = 0;
-				/* Call into fb to remove this buffer? */
-				break;
-			}
-		}
-
-		/*
-		 * This should actually block, unless O_NONBLOCK was
-		 *  specified in open, but fine for now, especially
-		 *  since this is not a capturing device
-		 */
-		if (i == vout->numbufs)
-			return -EAGAIN;
-	}
-
-	buffer->flags &= ~V4L2_BUF_FLAG_QUEUED;
-
-	return 0;
-}
-
-
-static int
-msm_v4l2_overlay_vidioc_qbuf(struct file *file, struct msm_v4l2_overlay_fh* fh,
-	void *arg, bool bUserPtr)
-{
-	struct msm_v4l2_overlay_device *vout = fh->vout;
-	struct v4l2_buffer *buffer = arg;
-	int ret;
-
-	if (!bUserPtr && buffer->memory != V4L2_MEMORY_MMAP)
-		return -EINVAL;
-
-	if (!vout->streaming) {
-		pr_err("%s: Video Stream not enabled\n", __func__);
-		return -EINVAL;
-	}
-
-	if (!buffer || buffer->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
-		return -EINVAL;
-
-	/* maybe allow only one qbuf at a time? */
-	ret =  msm_v4l2_overlay_fb_update(vout, buffer);
-
-	return 0;
-}
-
-static int
-msm_v4l2_overlay_vidioc_querycap(struct file *file, void *arg)
-{
-	struct v4l2_capability *buffer = arg;
-
-	memset(buffer, 0, sizeof(struct v4l2_capability));
-	strlcpy(buffer->driver, "msm_v4l2_video_overlay",
-		ARRAY_SIZE(buffer->driver));
-	strlcpy(buffer->card, "MSM MDP",
-		ARRAY_SIZE(buffer->card));
-	buffer->capabilities = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_OUTPUT
-		| V4L2_CAP_VIDEO_OVERLAY;
-	return 0;
-}
-
-static int
-msm_v4l2_overlay_vidioc_fbuf(struct file *file,
-	struct msm_v4l2_overlay_device *vout, void *arg, bool get)
-{
-	struct v4l2_framebuffer *fb = arg;
-
-	if (fb == NULL)
-		return -EINVAL;
-
-	if (get) {
-		mutex_lock(&vout->update_lock);
-		memcpy(&fb->fmt, &vout->pix, sizeof(struct v4l2_pix_format));
-		mutex_unlock(&vout->update_lock);
-	}
-	/* The S_FBUF request does not store anything right now */
-	return 0;
-}
-
-static long msm_v4l2_overlay_calculate_bufsize(struct v4l2_pix_format *pix)
-{
-	int bpp;
-	long bufsize;
-	switch (pix->pixelformat) {
-	case V4L2_PIX_FMT_YUV420:
-	case V4L2_PIX_FMT_NV12:
-		bpp = 12;
-		break;
-
-	case V4L2_PIX_FMT_RGB565:
-		bpp = 16;
-		break;
-
-	case V4L2_PIX_FMT_RGB24:
-	case V4L2_PIX_FMT_BGR24:
-	case V4L2_PIX_FMT_YUV444:
-		bpp = 24;
-		break;
-
-	case V4L2_PIX_FMT_RGB32:
-	case V4L2_PIX_FMT_BGR32:
-		bpp = 32;
-		break;
-	default:
-		pr_err("%s: Unrecognized format %u\n", __func__,
-		pix->pixelformat);
-		bpp = 0;
-	}
-
-	bufsize = (pix->width * pix->height * bpp)/8;
-
-	return bufsize;
-}
-
-static long
-msm_v4l2_overlay_vidioc_reqbufs(struct file *file,
-	struct msm_v4l2_overlay_device *vout, void *arg)
-
-{
-	struct v4l2_requestbuffers *rqb = arg;
-	long bufsize;
-	int i;
-
-	if (rqb == NULL || rqb->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
-		return -EINVAL;
-
-	if (rqb->memory == V4L2_MEMORY_MMAP) {
-		if (rqb->count == 0) {
-			/* Deallocate allocated buffers */
-			mutex_lock(&vout->update_lock);
-			vout->numbufs = 0;
-			kfree(vout->bufs);
-			/*
-			 * There should be a way to look at bufs[i]->mapped,
-			 * and prevent userspace from mmaping and directly
-			 * calling this ioctl without unmapping. Maybe kernel
-			 * handles for us, but needs to be checked out
-			 */
-			mutex_unlock(&vout->update_lock);
-		} else {
-			/*
-			 * Keep it simple for now - need to deallocate
-			 * before reallocate
-			 */
-			if (vout->bufs)
-				return -EINVAL;
-
-			mutex_lock(&vout->update_lock);
-			bufsize =
-				msm_v4l2_overlay_calculate_bufsize(&vout->pix);
-			mutex_unlock(&vout->update_lock);
-
-			if (bufsize == 0
-				|| (bufsize * rqb->count) > v4l2_ram_size) {
-				pr_err("%s: Unsupported format or buffer size too large\n",
-				__func__);
-				pr_err("%s: bufsize %lu ram_size %u count %u\n",
-				__func__, bufsize, v4l2_ram_size, rqb->count);
-				return -EINVAL;
-			}
-
-			/*
-			 * We don't support multiple open of one vout,
-			 * but there are probably still some MT problems here,
-			 * (what if same fh is shared between two userspace
-			 * threads and they both call REQBUFS etc)
-			 */
-
-			mutex_lock(&vout->update_lock);
-			vout->numbufs = rqb->count;
-			vout->bufs =
-				kmalloc(rqb->count *
-					sizeof(struct msm_v4l2_overlay_buffer),
-					GFP_KERNEL);
-
-			for (i = 0; i < rqb->count; i++) {
-				struct msm_v4l2_overlay_buffer *b =
-				(struct msm_v4l2_overlay_buffer *)vout->bufs
-				+ i;
-				b->mapped = 0;
-				b->queued = 0;
-				b->offset = PAGE_ALIGN(bufsize*i);
-				b->bufsize = bufsize;
-			}
-
-			mutex_unlock(&vout->update_lock);
-
-		}
-	}
-
-	return 0;
-}
-
-static long
-msm_v4l2_overlay_vidioc_querybuf(struct file *file,
-				 struct msm_v4l2_overlay_device *vout,
-				 void *arg)
-{
-	struct v4l2_buffer *buf = arg;
-	struct msm_v4l2_overlay_buffer *mbuf;
-
-	if (buf == NULL || buf->type != V4L2_BUF_TYPE_VIDEO_OUTPUT
-			|| buf->memory == V4L2_MEMORY_USERPTR
-			|| buf->index >= vout->numbufs)
-		return -EINVAL;
-
-	mutex_lock(&vout->update_lock);
-
-	mbuf = (struct msm_v4l2_overlay_buffer *)vout->bufs + buf->index;
-	buf->flags = 0;
-	if (mbuf->mapped)
-		buf->flags |= V4L2_BUF_FLAG_MAPPED;
-	if (mbuf->queued)
-		buf->flags |= V4L2_BUF_FLAG_QUEUED;
-
-	buf->memory = V4L2_MEMORY_MMAP;
-	buf->length = mbuf->bufsize;
-	buf->m.offset = mbuf->offset;
-
-	mutex_unlock(&vout->update_lock);
-
-	return 0;
-}
-
-static long
-msm_v4l2_overlay_do_ioctl(struct file *file,
-		       unsigned int cmd, void *arg)
-{
-	struct msm_v4l2_overlay_fh *fh = file->private_data;
-	struct msm_v4l2_overlay_device *vout = fh->vout;
-	int ret;
-	struct v4l2_buffer *buffer = arg;
-
-	switch (cmd) {
-	case VIDIOC_QUERYCAP:
-		return msm_v4l2_overlay_vidioc_querycap(file, arg);
-
-	case VIDIOC_G_FBUF:
-		return msm_v4l2_overlay_vidioc_fbuf(file, vout, arg, true);
-
-	case VIDIOC_S_FBUF:
-		return msm_v4l2_overlay_vidioc_fbuf(file, vout, arg, false);
-
-	case VIDIOC_REQBUFS:
-		return msm_v4l2_overlay_vidioc_reqbufs(file, vout, arg);
-
-	case VIDIOC_QUERYBUF:
-		return msm_v4l2_overlay_vidioc_querybuf(file, vout, arg);
-
-	case VIDIOC_QBUF:
-		mutex_lock(&vout->update_lock);
-		if (buffer->memory == V4L2_MEMORY_USERPTR) {
-			if (!capable(CAP_SYS_RAWIO))
-				return -EPERM;
-			ret = msm_v4l2_overlay_vidioc_qbuf(file, fh, arg, true);
-		} else {
-			ret = msm_v4l2_overlay_vidioc_qbuf(file, fh, arg,
-						false);
-		}
-		mutex_unlock(&vout->update_lock);
-
-		return ret;
-
-	case VIDIOC_MSM_USERPTR_QBUF:
-		if (!capable(CAP_SYS_RAWIO))
-			return -EPERM;
-
-		mutex_lock(&vout->update_lock);
-		ret = msm_v4l2_overlay_vidioc_qbuf(file, fh, arg, true);
-		mutex_unlock(&vout->update_lock);
-
-		return ret;
-
-	case VIDIOC_DQBUF:
-		mutex_lock(&vout->update_lock);
-		ret = msm_v4l2_overlay_vidioc_dqbuf(file, fh, arg);
-		mutex_unlock(&vout->update_lock);
-		break;
-
-	case VIDIOC_S_FMT: {
-		struct v4l2_format *f = arg;
-
-		switch (f->type) {
-		case V4L2_BUF_TYPE_VIDEO_OVERLAY:
-			mutex_lock(&vout->update_lock);
-			memcpy(&vout->win, &f->fmt.win,
-				sizeof(struct v4l2_window));
-			mutex_unlock(&vout->update_lock);
-			break;
-
-		case V4L2_BUF_TYPE_VIDEO_OUTPUT:
-			mutex_lock(&vout->update_lock);
-			memcpy(&vout->pix, &f->fmt.pix,
-				sizeof(struct v4l2_pix_format));
-			mutex_unlock(&vout->update_lock);
-			break;
-
-		default:
-			return -EINVAL;
-		}
-		break;
-	}
-	case VIDIOC_G_FMT: {
-		struct v4l2_format *f = arg;
-
-		switch (f->type) {
-		case V4L2_BUF_TYPE_VIDEO_OUTPUT: {
-			struct v4l2_pix_format *pix = &f->fmt.pix;
-			memset(pix, 0, sizeof(*pix));
-			*pix = vout->pix;
-			break;
-		}
-
-		case V4L2_BUF_TYPE_VIDEO_OVERLAY: {
-			struct v4l2_window *win = &f->fmt.win;
-			memset(win, 0, sizeof(*win));
-			win->w = vout->win.w;
-			break;
-		}
-		default:
-			return -EINVAL;
-		}
-		break;
-	}
-
-	case VIDIOC_CROPCAP: {
-		struct v4l2_cropcap *cr = arg;
-		if (cr->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
-			return -EINVAL;
-
-		cr->bounds.left =  0;
-		cr->bounds.top = 0;
-		cr->bounds.width = vout->crop_rect.width;
-		cr->bounds.height = vout->crop_rect.height;
-
-		cr->defrect.left =  0;
-		cr->defrect.top = 0;
-		cr->defrect.width = vout->crop_rect.width;
-		cr->defrect.height = vout->crop_rect.height;
-
-		cr->pixelaspect.numerator = 1;
-		cr->pixelaspect.denominator = 1;
-		break;
-	}
-
-	case VIDIOC_S_CROP: {
-		struct v4l2_crop *crop = arg;
-
-		switch (crop->type) {
-
-		case V4L2_BUF_TYPE_VIDEO_OUTPUT:
-
-			mutex_lock(&vout->update_lock);
-			memcpy(&vout->crop_rect, &crop->c,
-				sizeof(struct v4l2_rect));
-			mutex_unlock(&vout->update_lock);
-
-			break;
-
-		default:
-
-			return -EINVAL;
-		}
-		break;
-	}
-	case VIDIOC_G_CROP: {
-		struct v4l2_crop *crop = arg;
-
-		switch (crop->type) {
-
-		case V4L2_BUF_TYPE_VIDEO_OUTPUT:
-			memcpy(&crop->c, &vout->crop_rect,
-				sizeof(struct v4l2_rect));
-			break;
-
-		default:
-			return -EINVAL;
-		}
-		break;
-	}
-
-	case VIDIOC_S_CTRL: {
-		struct v4l2_control *ctrl = arg;
-		int32_t rotflag;
-
-		switch (ctrl->id) {
-
-		case V4L2_CID_ROTATE:
-			switch (ctrl->value) {
-			case 0:
-				rotflag = MDP_ROT_NOP;
-				break;
-			case 90:
-				rotflag = MDP_ROT_90;
-				break;
-			case 180:
-				rotflag = MDP_ROT_180;
-				break;
-			case 270:
-				rotflag = MDP_ROT_270;
-				break;
-			default:
-				pr_err("%s: V4L2_CID_ROTATE invalid rotation value %d.\n",
-						__func__, ctrl->value);
-				return -ERANGE;
-			}
-
-			mutex_lock(&vout->update_lock);
-			/* Clear the rotation flags */
-			vout->req.flags &= ~MDP_ROT_NOP;
-			vout->req.flags &= ~MDP_ROT_90;
-			vout->req.flags &= ~MDP_ROT_180;
-			vout->req.flags &= ~MDP_ROT_270;
-			/* Set the new rotation flag */
-			vout->req.flags |= rotflag;
-			mutex_unlock(&vout->update_lock);
-
-			break;
-
-		case V4L2_CID_HFLIP:
-			mutex_lock(&vout->update_lock);
-			/* Clear the flip flag */
-			vout->req.flags &= ~MDP_FLIP_LR;
-			if (true == ctrl->value)
-				vout->req.flags |= MDP_FLIP_LR;
-			mutex_unlock(&vout->update_lock);
-
-			break;
-
-		case V4L2_CID_VFLIP:
-			mutex_lock(&vout->update_lock);
-			/* Clear the flip flag */
-			vout->req.flags &= ~MDP_FLIP_UD;
-			if (true == ctrl->value)
-				vout->req.flags |= MDP_FLIP_UD;
-			mutex_unlock(&vout->update_lock);
-
-			break;
-
-		default:
-			pr_err("%s: VIDIOC_S_CTRL invalid control ID %d.\n",
-			__func__, ctrl->id);
-			return -EINVAL;
-		}
-		break;
-	}
-	case VIDIOC_G_CTRL: {
-		struct v4l2_control *ctrl = arg;
-		__s32 rotation;
-
-		switch (ctrl->id) {
-
-		case V4L2_CID_ROTATE:
-			if (MDP_ROT_NOP == (vout->req.flags & MDP_ROT_NOP))
-				rotation = 0;
-			if (MDP_ROT_90 == (vout->req.flags & MDP_ROT_90))
-				rotation = 90;
-			if (MDP_ROT_180 == (vout->req.flags & MDP_ROT_180))
-				rotation = 180;
-			if (MDP_ROT_270 == (vout->req.flags & MDP_ROT_270))
-				rotation = 270;
-
-			ctrl->value = rotation;
-			break;
-
-		case V4L2_CID_HFLIP:
-			if (MDP_FLIP_LR == (vout->req.flags & MDP_FLIP_LR))
-				ctrl->value = true;
-			break;
-
-		case V4L2_CID_VFLIP:
-			if (MDP_FLIP_UD == (vout->req.flags & MDP_FLIP_UD))
-				ctrl->value = true;
-			break;
-
-		default:
-			pr_err("%s: VIDIOC_G_CTRL invalid control ID %d.\n",
-			__func__, ctrl->id);
-			return -EINVAL;
-		}
-		break;
-	}
-
-	case VIDIOC_STREAMON: {
-
-		if (vout->streaming) {
-			pr_err("%s: VIDIOC_STREAMON: already streaming.\n",
-			__func__);
-			return -EBUSY;
-		}
-
-		mutex_lock(&vout->update_lock);
-		msm_v4l2_overlay_startstreaming(vout);
-		mutex_unlock(&vout->update_lock);
-
-		break;
-	}
-
-	case VIDIOC_STREAMOFF: {
-
-		if (!vout->streaming) {
-			pr_err("%s: VIDIOC_STREAMOFF: not currently streaming.\n",
-			__func__);
-			return -EINVAL;
-		}
-
-		mutex_lock(&vout->update_lock);
-		msm_v4l2_overlay_stopstreaming(vout);
-		mutex_unlock(&vout->update_lock);
-
-		break;
-	}
-
-	default:
-		return -ENOIOCTLCMD;
-
-	} /* switch */
-
-	return 0;
-}
-
-static long
-msm_v4l2_overlay_ioctl(struct file *file, unsigned int cmd,
-		    unsigned long arg)
-{
-	return video_usercopy(file, cmd, arg, msm_v4l2_overlay_do_ioctl);
-}
-
-static int
-msm_v4l2_overlay_mmap(struct file *filp, struct vm_area_struct * vma)
-{
-	unsigned long start = (unsigned long)v4l2_ram_phys;
-
-	/*
-	 * vm_pgoff is the offset (>>PAGE_SHIFT) that we provided
-	 * during REQBUFS. off therefore should equal the offset we
-	 * provided in REQBUFS, since last (PAGE_SHIFT) bits of off
-	 * should be 0
-	 */
-	unsigned long off = vma->vm_pgoff << PAGE_SHIFT;
-	u32 len = PAGE_ALIGN((start & ~PAGE_MASK) + v4l2_ram_size);
-
-	/*
-	 * This is probably unnecessary now - the last PAGE_SHIFT
-	 * bits of start should be 0 now, since we are page aligning
-	 * v4l2_ram_phys
-	 */
-	start &= PAGE_MASK;
-
-	pr_debug("v4l2 map req for phys(%p,%p) offset %u to virt (%p,%p)\n",
-	(void *)(start+off), (void *)(start+off+(vma->vm_end - vma->vm_start)),
-	(unsigned int)off, (void *)vma->vm_start, (void *)vma->vm_end);
-
-	if ((vma->vm_end - vma->vm_start + off) > len) {
-		pr_err("v4l2 map request, memory requested too big\n");
-		return -EINVAL;
-	}
-
-	start += off;
-	vma->vm_pgoff = start >> PAGE_SHIFT;
-	/* This is an IO map - tell maydump to skip this VMA */
-	vma->vm_flags |= VM_IO | VM_RESERVED;
-
-	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-
-	/* Remap the frame buffer I/O range */
-	if (io_remap_pfn_range(vma, vma->vm_start, start >> PAGE_SHIFT,
-				vma->vm_end - vma->vm_start,
-				vma->vm_page_prot))
-		return -EAGAIN;
-
-	return 0;
-}
-
-static int
-msm_v4l2_overlay_release(struct file *file)
-{
-	struct msm_v4l2_overlay_fh *fh = file->private_data;
-	struct msm_v4l2_overlay_device *vout = fh->vout;
-
-	if (vout->streaming)
-		msm_v4l2_overlay_stopstreaming(vout);
-
-	vout->ref_count--;
-
-	kfree(vout->bufs);
-	vout->numbufs = 0;
-	kfree(fh);
-
-	return 0;
-}
-
-static int
-msm_v4l2_overlay_open(struct file *file)
-{
-	struct msm_v4l2_overlay_device	*vout = NULL;
-	struct v4l2_pix_format	*pix = NULL;
-	struct msm_v4l2_overlay_fh *fh;
-
-	vout = saved_vout0;
-	vout->id = 0;
-
-	if (vout->ref_count) {
-		pr_err("%s: multiple open currently is not"
-		"supported!\n", __func__);
-		return -EBUSY;
-	}
-
-	vout->ref_count++;
-
-	/* allocate per-filehandle data */
-	fh = kmalloc(sizeof(struct msm_v4l2_overlay_fh), GFP_KERNEL);
-	if (NULL == fh)
-		return -ENOMEM;
-
-	fh->vout = vout;
-	fh->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
-
-	file->private_data = fh;
-
-	vout->streaming		= 0;
-	vout->crop_rect.left	= vout->crop_rect.top = 0;
-	vout->crop_rect.width	= vout->screen_width;
-	vout->crop_rect.height	= vout->screen_height;
-
-	pix				= &vout->pix;
-	pix->width			= vout->screen_width;
-	pix->height		= vout->screen_height;
-	pix->pixelformat	= V4L2_PIX_FMT_RGB32;
-	pix->field			= V4L2_FIELD_NONE;
-	pix->bytesperline	= pix->width * 4;
-	pix->sizeimage		= pix->bytesperline * pix->height;
-	pix->priv			= 0;
-	pix->colorspace		= V4L2_COLORSPACE_SRGB;
-
-	vout->win.w.left	= 0;
-	vout->win.w.top		= 0;
-	vout->win.w.width	= vout->screen_width;
-	vout->win.w.height	= vout->screen_height;
-
-	vout->fb.capability = V4L2_FBUF_CAP_EXTERNOVERLAY
-		| V4L2_FBUF_CAP_LOCAL_ALPHA;
-	vout->fb.flags = V4L2_FBUF_FLAG_LOCAL_ALPHA;
-	vout->fb.base = 0;
-	memcpy(&vout->fb.fmt, pix, sizeof(struct v4l2_format));
-
-	vout->bufs = 0;
-	vout->numbufs = 0;
-
-	mutex_init(&vout->update_lock);
-
-	return 0;
-}
-
-
-static int __devinit
-msm_v4l2_overlay_probe(struct platform_device *pdev)
-{
-	char *v4l2_ram_phys_unaligned;
-	if ((pdev->id == 0) && (pdev->num_resources > 0)) {
-		v4l2_ram_size =
-			pdev->resource[0].end - pdev->resource[0].start + 1;
-		v4l2_ram_phys_unaligned = (char *)pdev->resource[0].start;
-		v4l2_ram_phys =
-		(char *)PAGE_ALIGN((unsigned int)v4l2_ram_phys_unaligned);
-		/*
-		 * We are (fwd) page aligning the start of v4l2 memory.
-		 * Therefore we have that much less physical memory available
-		 */
-		v4l2_ram_size -= (unsigned int)v4l2_ram_phys
-			- (unsigned int)v4l2_ram_phys_unaligned;
-
-
-	}
-	return 0;
-}
-
-static int __devexit
-msm_v4l2_overlay_remove(struct platform_device *pdev)
-{
-	return 0;
-}
-
-static void msm_v4l2_overlay_videodev_release(struct video_device *vfd)
-{
-	return;
-}
-
-static const struct v4l2_file_operations msm_v4l2_overlay_fops = {
-	.owner		= THIS_MODULE,
-	.open		= msm_v4l2_overlay_open,
-	.release	= msm_v4l2_overlay_release,
-	.mmap		= msm_v4l2_overlay_mmap,
-	.ioctl		= msm_v4l2_overlay_ioctl,
-};
-
-static struct video_device msm_v4l2_overlay_vid_device0 = {
-	.name		= "msm_v4l2_overlay",
-	.fops       = &msm_v4l2_overlay_fops,
-	.minor		= -1,
-	.release	= msm_v4l2_overlay_videodev_release,
-};
-
-static struct platform_driver msm_v4l2_overlay_platform_driver = {
-	.probe   = msm_v4l2_overlay_probe,
-	.remove  = msm_v4l2_overlay_remove,
-	.driver  = {
-			 .name = "msm_v4l2_overlay_pd",
-		   },
-};
-
-static int __init msm_v4l2_overlay_init(void)
-{
-	int ret;
-
-
-	saved_vout0 = kzalloc(sizeof(struct msm_v4l2_overlay_device),
-		GFP_KERNEL);
-
-	if (!saved_vout0)
-		return -ENOMEM;
-
-	ret = platform_driver_register(&msm_v4l2_overlay_platform_driver);
-	if (ret < 0)
-		goto end;
-
-	/*
-	 * Register the device with videodev.
-	 * Videodev will make IOCTL calls on application requests
-	 */
-	ret = video_register_device(&msm_v4l2_overlay_vid_device0,
-		VFL_TYPE_GRABBER, MSM_VIDEO);
-
-	if (ret < 0) {
-		pr_err("%s: V4L2 video overlay device registration failure(%d)\n",
-				  __func__, ret);
-		goto end_unregister;
-	}
-
-	mutex_init(&msmfb_lock);
-
-	return 0;
-
-end_unregister:
-	platform_driver_unregister(&msm_v4l2_overlay_platform_driver);
-
-end:
-	kfree(saved_vout0);
-	return ret;
-}
-
-static void __exit msm_v4l2_overlay_exit(void)
-{
-	video_unregister_device(&msm_v4l2_overlay_vid_device0);
-	platform_driver_unregister(&msm_v4l2_overlay_platform_driver);
-	mutex_destroy(&msmfb_lock);
-	kfree(saved_vout0);
-}
-
-module_init(msm_v4l2_overlay_init);
-module_exit(msm_v4l2_overlay_exit);
-
-MODULE_DESCRIPTION("MSM V4L2 Video Overlay Driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/msm_v4l2_video.h b/drivers/media/platform/msm/camera_v1/msm_v4l2_video.h
deleted file mode 100644
index 6de6c80..0000000
--- a/drivers/media/platform/msm/camera_v1/msm_v4l2_video.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-#ifndef MSM_V4L2_VIDEO_H
-#define MSM_V4L2_VIDEO_H
-
-#include <linux/mm.h>
-#include <linux/msm_mdp.h>
-#include <linux/videodev2.h>
-
-
-struct msm_v4l2_overlay_buffer {
-	int mapped;
-	int queued;
-	int offset;
-	int bufsize;
-};
-
-struct msm_v4l2_overlay_device {
-	struct device dev;
-
-	int ref_count;
-	int id;
-
-	int screen_width;
-	int screen_height;
-	int streaming;
-
-	struct v4l2_pix_format pix;
-	struct v4l2_window win;
-	struct v4l2_rect crop_rect;
-	struct v4l2_framebuffer fb;
-	struct msm_v4l2_overlay_buffer *bufs;
-	int numbufs;
-	struct mdp_overlay req;
-	void *par;
-
-	struct mutex update_lock;
-};
-
-struct msm_v4l2_overlay_fh {
-	struct msm_v4l2_overlay_device *vout;
-	enum v4l2_buf_type type;
-};
-
-struct msm_v4l2_overlay_userptr_buffer {
-	uint fd[3]; /* ION fd of frame or plane */
-	size_t offset[3]; /* offset of frame or plane in multi buffer case */
-};
-
-#endif
diff --git a/drivers/media/platform/msm/camera_v1/msm_vpe.c b/drivers/media/platform/msm/camera_v1/msm_vpe.c
deleted file mode 100644
index ea1c819..0000000
--- a/drivers/media/platform/msm/camera_v1/msm_vpe.c
+++ /dev/null
@@ -1,1146 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/uaccess.h>
-#include <linux/interrupt.h>
-#include <mach/irqs.h>
-#include <linux/io.h>
-#include <linux/slab.h>
-#include <linux/regulator/consumer.h>
-#include <linux/clk.h>
-#include <mach/clk.h>
-#include <asm/div64.h>
-#include <linux/workqueue.h>
-#include <linux/delay.h>
-#include <linux/types.h>
-#include <linux/list.h>
-#include <linux/ioctl.h>
-#include <linux/spinlock.h>
-#include "msm.h"
-#include "msm_vpe.h"
-
-#ifdef CONFIG_MSM_CAMERA_DEBUG
-#define D(fmt, args...) pr_debug("msm_vpe: " fmt, ##args)
-#else
-#define D(fmt, args...) do {} while (0)
-#endif
-
-static int vpe_enable(uint32_t, struct msm_cam_media_controller *);
-static int vpe_disable(struct msm_cam_media_controller *);
-static int vpe_update_scaler(struct msm_pp_crop *pcrop);
-struct vpe_ctrl_type *vpe_ctrl;
-static atomic_t vpe_init_done = ATOMIC_INIT(0);
-
-static int msm_vpe_do_pp(struct msm_mctl_pp_frame_info *pp_frame_info);
-
-static long long vpe_do_div(long long num, long long den)
-{
-	do_div(num, den);
-	return num;
-}
-
-static int vpe_start(void)
-{
-	/*  enable the frame irq, bit 0 = Display list 0 ROI done */
-	msm_camera_io_w_mb(1, vpe_ctrl->vpebase + VPE_INTR_ENABLE_OFFSET);
-	msm_camera_io_dump(vpe_ctrl->vpebase, 0x120);
-	msm_camera_io_dump(vpe_ctrl->vpebase + 0x00400, 0x18);
-	msm_camera_io_dump(vpe_ctrl->vpebase + 0x10000, 0x250);
-	msm_camera_io_dump(vpe_ctrl->vpebase + 0x30000, 0x20);
-	msm_camera_io_dump(vpe_ctrl->vpebase + 0x50000, 0x30);
-	msm_camera_io_dump(vpe_ctrl->vpebase + 0x50400, 0x10);
-
-	/* this triggers the operation. */
-	msm_camera_io_w_mb(1, vpe_ctrl->vpebase + VPE_DL0_START_OFFSET);
-	return 0;
-}
-
-void vpe_reset_state_variables(void)
-{
-	/* initialize local variables for state control, etc.*/
-	vpe_ctrl->op_mode = 0;
-	vpe_ctrl->state = VPE_STATE_INIT;
-}
-
-static void vpe_config_axi_default(void)
-{
-	msm_camera_io_w(0x25, vpe_ctrl->vpebase + VPE_AXI_ARB_2_OFFSET);
-	D("%s: yaddr %ld cbcraddr %ld", __func__,
-		 vpe_ctrl->out_y_addr, vpe_ctrl->out_cbcr_addr);
-	if (!vpe_ctrl->out_y_addr || !vpe_ctrl->out_cbcr_addr)
-		return;
-	msm_camera_io_w(vpe_ctrl->out_y_addr,
-		vpe_ctrl->vpebase + VPE_OUTP0_ADDR_OFFSET);
-	/* for video  CbCr address */
-	msm_camera_io_w(vpe_ctrl->out_cbcr_addr,
-		vpe_ctrl->vpebase + VPE_OUTP1_ADDR_OFFSET);
-}
-
-static int vpe_reset(void)
-{
-	uint32_t vpe_version;
-	uint32_t rc = 0;
-	unsigned long flags = 0;
-
-	spin_lock_irqsave(&vpe_ctrl->lock, flags);
-	if (vpe_ctrl->state == VPE_STATE_IDLE) {
-		D("%s: VPE already disabled.", __func__);
-		spin_unlock_irqrestore(&vpe_ctrl->lock, flags);
-		return rc;
-	}
-	spin_unlock_irqrestore(&vpe_ctrl->lock, flags);
-
-	vpe_reset_state_variables();
-	vpe_version = msm_camera_io_r(
-			vpe_ctrl->vpebase + VPE_HW_VERSION_OFFSET);
-	D("vpe_version = 0x%x\n", vpe_version);
-	/* disable all interrupts.*/
-	msm_camera_io_w(0, vpe_ctrl->vpebase + VPE_INTR_ENABLE_OFFSET);
-	/* clear all pending interrupts*/
-	msm_camera_io_w(0x1fffff, vpe_ctrl->vpebase + VPE_INTR_CLEAR_OFFSET);
-	/* write sw_reset to reset the core. */
-	msm_camera_io_w(0x10, vpe_ctrl->vpebase + VPE_SW_RESET_OFFSET);
-	/* then poll the reset bit, it should be self-cleared. */
-	while (1) {
-		rc =
-		msm_camera_io_r(vpe_ctrl->vpebase + VPE_SW_RESET_OFFSET) & 0x10;
-		if (rc == 0)
-			break;
-	}
-	/*  at this point, hardware is reset. Then pogram to default
-		values. */
-	msm_camera_io_w(VPE_AXI_RD_ARB_CONFIG_VALUE,
-			vpe_ctrl->vpebase + VPE_AXI_RD_ARB_CONFIG_OFFSET);
-
-	msm_camera_io_w(VPE_CGC_ENABLE_VALUE,
-			vpe_ctrl->vpebase + VPE_CGC_EN_OFFSET);
-	msm_camera_io_w(1, vpe_ctrl->vpebase + VPE_CMD_MODE_OFFSET);
-	msm_camera_io_w(VPE_DEFAULT_OP_MODE_VALUE,
-			vpe_ctrl->vpebase + VPE_OP_MODE_OFFSET);
-	msm_camera_io_w(VPE_DEFAULT_SCALE_CONFIG,
-			vpe_ctrl->vpebase + VPE_SCALE_CONFIG_OFFSET);
-	vpe_config_axi_default();
-	return rc;
-}
-
-static int msm_vpe_cfg_update(void *pinfo)
-{
-	uint32_t  rot_flag, rc = 0;
-	struct msm_pp_crop *pcrop = (struct msm_pp_crop *)pinfo;
-
-	rot_flag = msm_camera_io_r(vpe_ctrl->vpebase +
-						VPE_OP_MODE_OFFSET) & 0xE00;
-	if (pinfo != NULL) {
-		D("%s: Crop info in2_w = %d, in2_h = %d "
-			"out2_w = %d out2_h = %d\n",
-			__func__, pcrop->src_w, pcrop->src_h,
-			pcrop->dst_w, pcrop->dst_h);
-		rc = vpe_update_scaler(pcrop);
-	}
-	D("return rc = %d rot_flag = %d\n", rc, rot_flag);
-	rc |= rot_flag;
-
-	return rc;
-}
-
-void vpe_update_scale_coef(uint32_t *p)
-{
-	uint32_t i, offset;
-	offset = *p;
-	for (i = offset; i < (VPE_SCALE_COEFF_NUM + offset); i++) {
-		msm_camera_io_w(*(++p),
-			vpe_ctrl->vpebase + VPE_SCALE_COEFF_LSBn(i));
-		msm_camera_io_w(*(++p),
-			vpe_ctrl->vpebase + VPE_SCALE_COEFF_MSBn(i));
-	}
-}
-
-void vpe_input_plane_config(uint32_t *p)
-{
-	msm_camera_io_w(*p, vpe_ctrl->vpebase + VPE_SRC_FORMAT_OFFSET);
-	msm_camera_io_w(*(++p),
-		vpe_ctrl->vpebase + VPE_SRC_UNPACK_PATTERN1_OFFSET);
-	msm_camera_io_w(*(++p), vpe_ctrl->vpebase + VPE_SRC_IMAGE_SIZE_OFFSET);
-	msm_camera_io_w(*(++p), vpe_ctrl->vpebase + VPE_SRC_YSTRIDE1_OFFSET);
-	msm_camera_io_w(*(++p), vpe_ctrl->vpebase + VPE_SRC_SIZE_OFFSET);
-	msm_camera_io_w(*(++p), vpe_ctrl->vpebase + VPE_SRC_XY_OFFSET);
-}
-
-void vpe_output_plane_config(uint32_t *p)
-{
-	msm_camera_io_w(*p, vpe_ctrl->vpebase + VPE_OUT_FORMAT_OFFSET);
-	msm_camera_io_w(*(++p),
-		vpe_ctrl->vpebase + VPE_OUT_PACK_PATTERN1_OFFSET);
-	msm_camera_io_w(*(++p), vpe_ctrl->vpebase + VPE_OUT_YSTRIDE1_OFFSET);
-	msm_camera_io_w(*(++p), vpe_ctrl->vpebase + VPE_OUT_SIZE_OFFSET);
-	msm_camera_io_w(*(++p), vpe_ctrl->vpebase + VPE_OUT_XY_OFFSET);
-}
-
-static int vpe_operation_config(uint32_t *p)
-{
-	uint32_t w, h, temp;
-	msm_camera_io_w(*p, vpe_ctrl->vpebase + VPE_OP_MODE_OFFSET);
-
-	temp = msm_camera_io_r(vpe_ctrl->vpebase + VPE_OUT_SIZE_OFFSET);
-	w = temp & 0xFFF;
-	h = (temp & 0xFFF0000) >> 16;
-	if (*p++ & 0xE00) {
-		/* rotation enabled. */
-		vpe_ctrl->out_w = h;
-		vpe_ctrl->out_h = w;
-	} else {
-		vpe_ctrl->out_w = w;
-		vpe_ctrl->out_h = h;
-	}
-	D("%s: out_w=%d, out_h=%d", __func__, vpe_ctrl->out_w,
-		vpe_ctrl->out_h);
-	return 0;
-}
-
-/* Later we can separate the rotation and scaler calc. If
-*  rotation is enabled, simply swap the destination dimension.
-*  And then pass the already swapped output size to this
-*  function. */
-static int vpe_update_scaler(struct msm_pp_crop *pcrop)
-{
-	uint32_t out_ROI_width, out_ROI_height;
-	uint32_t src_ROI_width, src_ROI_height;
-
-	/*
-	* phase_step_x, phase_step_y, phase_init_x and phase_init_y
-	* are represented in fixed-point, unsigned 3.29 format
-	*/
-	uint32_t phase_step_x = 0;
-	uint32_t phase_step_y = 0;
-	uint32_t phase_init_x = 0;
-	uint32_t phase_init_y = 0;
-
-	uint32_t src_roi, src_x, src_y, src_xy, temp;
-	uint32_t yscale_filter_sel, xscale_filter_sel;
-	uint32_t scale_unit_sel_x, scale_unit_sel_y;
-	uint64_t numerator, denominator;
-
-	/* assumption is both direction need zoom. this can be
-	improved. */
-	temp =
-		msm_camera_io_r(vpe_ctrl->vpebase + VPE_OP_MODE_OFFSET) | 0x3;
-	msm_camera_io_w(temp, vpe_ctrl->vpebase + VPE_OP_MODE_OFFSET);
-
-	src_ROI_width = pcrop->src_w;
-	src_ROI_height = pcrop->src_h;
-	out_ROI_width = pcrop->dst_w;
-	out_ROI_height = pcrop->dst_h;
-
-	D("src w = 0x%x, h=0x%x, dst w = 0x%x, h =0x%x.\n",
-		src_ROI_width, src_ROI_height, out_ROI_width,
-		out_ROI_height);
-	src_roi = (src_ROI_height << 16) + src_ROI_width;
-
-	msm_camera_io_w(src_roi, vpe_ctrl->vpebase + VPE_SRC_SIZE_OFFSET);
-
-	src_x = pcrop->src_x;
-	src_y = pcrop->src_y;
-
-	D("src_x = %d, src_y=%d.\n", src_x, src_y);
-
-	src_xy = src_y*(1<<16) + src_x;
-	msm_camera_io_w(src_xy, vpe_ctrl->vpebase +
-			VPE_SRC_XY_OFFSET);
-	D("src_xy = %d, src_roi=%d.\n", src_xy, src_roi);
-
-	/* decide whether to use FIR or M/N for scaling */
-	if ((out_ROI_width == 1 && src_ROI_width < 4) ||
-		(src_ROI_width < 4 * out_ROI_width - 3))
-		scale_unit_sel_x = 0;/* use FIR scalar */
-	else
-		scale_unit_sel_x = 1;/* use M/N scalar */
-
-	if ((out_ROI_height == 1 && src_ROI_height < 4) ||
-		(src_ROI_height < 4 * out_ROI_height - 3))
-		scale_unit_sel_y = 0;/* use FIR scalar */
-	else
-		scale_unit_sel_y = 1;/* use M/N scalar */
-
-	/* calculate phase step for the x direction */
-
-	/* if destination is only 1 pixel wide,
-	the value of phase_step_x
-	is unimportant. Assigning phase_step_x to
-	src ROI width as an arbitrary value. */
-	if (out_ROI_width == 1)
-		phase_step_x = (uint32_t) ((src_ROI_width) <<
-						SCALER_PHASE_BITS);
-
-		/* if using FIR scalar */
-	else if (scale_unit_sel_x == 0) {
-
-		/* Calculate the quotient ( src_ROI_width - 1 )
-			( out_ROI_width - 1)
-			with u3.29 precision. Quotient is rounded up to
-			the larger 29th decimal point*/
-		numerator = (uint64_t)(src_ROI_width - 1) <<
-			SCALER_PHASE_BITS;
-		/* never equals to 0 because of the
-			"(out_ROI_width == 1 )"*/
-		denominator = (uint64_t)(out_ROI_width - 1);
-		/* divide and round up to the larger 29th
-			decimal point.*/
-		phase_step_x = (uint32_t) vpe_do_div((numerator +
-					denominator - 1), denominator);
-	} else if (scale_unit_sel_x == 1) { /* if M/N scalar */
-		/* Calculate the quotient ( src_ROI_width ) /
-			( out_ROI_width)
-			with u3.29 precision. Quotient is rounded down to the
-			smaller 29th decimal point.*/
-		numerator = (uint64_t)(src_ROI_width) <<
-			SCALER_PHASE_BITS;
-		denominator = (uint64_t)(out_ROI_width);
-		phase_step_x =
-			(uint32_t) vpe_do_div(numerator, denominator);
-	}
-	/* calculate phase step for the y direction */
-
-	/* if destination is only 1 pixel wide, the value of
-		phase_step_x is unimportant. Assigning phase_step_x
-		to src ROI width as an arbitrary value. */
-	if (out_ROI_height == 1)
-		phase_step_y =
-		(uint32_t) ((src_ROI_height) << SCALER_PHASE_BITS);
-
-	/* if FIR scalar */
-	else if (scale_unit_sel_y == 0) {
-		/* Calculate the quotient ( src_ROI_height - 1 ) /
-		( out_ROI_height - 1)
-		with u3.29 precision. Quotient is rounded up to the
-		larger 29th decimal point. */
-		numerator = (uint64_t)(src_ROI_height - 1) <<
-			SCALER_PHASE_BITS;
-		/* never equals to 0 because of the "
-		( out_ROI_height == 1 )" case */
-		denominator = (uint64_t)(out_ROI_height - 1);
-		/* Quotient is rounded up to the larger
-		29th decimal point. */
-		phase_step_y =
-		(uint32_t) vpe_do_div(
-			(numerator + denominator - 1), denominator);
-	} else if (scale_unit_sel_y == 1) { /* if M/N scalar */
-		/* Calculate the quotient ( src_ROI_height )
-			( out_ROI_height)
-			with u3.29 precision. Quotient is rounded down
-			to the smaller 29th decimal point. */
-		numerator = (uint64_t)(src_ROI_height) <<
-			SCALER_PHASE_BITS;
-		denominator = (uint64_t)(out_ROI_height);
-		phase_step_y = (uint32_t) vpe_do_div(
-			numerator, denominator);
-	}
-
-	/* decide which set of FIR coefficients to use */
-	if (phase_step_x > HAL_MDP_PHASE_STEP_2P50)
-		xscale_filter_sel = 0;
-	else if (phase_step_x > HAL_MDP_PHASE_STEP_1P66)
-		xscale_filter_sel = 1;
-	else if (phase_step_x > HAL_MDP_PHASE_STEP_1P25)
-		xscale_filter_sel = 2;
-	else
-		xscale_filter_sel = 3;
-
-	if (phase_step_y > HAL_MDP_PHASE_STEP_2P50)
-		yscale_filter_sel = 0;
-	else if (phase_step_y > HAL_MDP_PHASE_STEP_1P66)
-		yscale_filter_sel = 1;
-	else if (phase_step_y > HAL_MDP_PHASE_STEP_1P25)
-		yscale_filter_sel = 2;
-	else
-		yscale_filter_sel = 3;
-
-	/* calculate phase init for the x direction */
-
-	/* if using FIR scalar */
-	if (scale_unit_sel_x == 0) {
-		if (out_ROI_width == 1)
-			phase_init_x =
-				(uint32_t) ((src_ROI_width - 1) <<
-							SCALER_PHASE_BITS);
-		else
-			phase_init_x = 0;
-	} else if (scale_unit_sel_x == 1) /* M over N scalar  */
-		phase_init_x = 0;
-
-	/* calculate phase init for the y direction
-	if using FIR scalar */
-	if (scale_unit_sel_y == 0) {
-		if (out_ROI_height == 1)
-			phase_init_y =
-			(uint32_t) ((src_ROI_height -
-						1) << SCALER_PHASE_BITS);
-		else
-			phase_init_y = 0;
-	} else if (scale_unit_sel_y == 1) /* M over N scalar   */
-		phase_init_y = 0;
-
-	D("phase step x = %d, step y = %d.\n",
-		 phase_step_x, phase_step_y);
-	D("phase init x = %d, init y = %d.\n",
-		 phase_init_x, phase_init_y);
-
-	msm_camera_io_w(phase_step_x, vpe_ctrl->vpebase +
-			VPE_SCALE_PHASEX_STEP_OFFSET);
-	msm_camera_io_w(phase_step_y, vpe_ctrl->vpebase +
-			VPE_SCALE_PHASEY_STEP_OFFSET);
-
-	msm_camera_io_w(phase_init_x, vpe_ctrl->vpebase +
-			VPE_SCALE_PHASEX_INIT_OFFSET);
-
-	msm_camera_io_w(phase_init_y, vpe_ctrl->vpebase +
-			VPE_SCALE_PHASEY_INIT_OFFSET);
-
-	return 1;
-}
-
-int msm_vpe_is_busy(void)
-{
-	int busy = 0;
-	unsigned long flags;
-	spin_lock_irqsave(&vpe_ctrl->lock, flags);
-	if (vpe_ctrl->state == VPE_STATE_ACTIVE)
-		busy = 1;
-	spin_unlock_irqrestore(&vpe_ctrl->lock, flags);
-	return busy;
-}
-
-static int msm_send_frame_to_vpe(void)
-{
-	int rc = 0;
-	unsigned long flags;
-	unsigned long srcP0, srcP1, outP0, outP1;
-	struct msm_mctl_pp_frame_info *frame_info = vpe_ctrl->pp_frame_info;
-
-	if (!frame_info) {
-		pr_err("%s Invalid frame", __func__);
-		return -EINVAL;
-	}
-
-	spin_lock_irqsave(&vpe_ctrl->lock, flags);
-
-	if (frame_info->src_frame.frame.num_planes > 1) {
-		srcP0 = frame_info->src_frame.map[0].paddr +
-			frame_info->src_frame.map[0].data_offset;
-		srcP1 = frame_info->src_frame.map[1].paddr +
-			frame_info->src_frame.map[1].data_offset;
-		outP0 = frame_info->dest_frame.map[0].paddr +
-			frame_info->dest_frame.map[0].data_offset;
-		outP1 = frame_info->dest_frame.map[1].paddr +
-			frame_info->dest_frame.map[1].data_offset;
-	} else {
-		srcP0 = frame_info->src_frame.map[0].paddr;
-		srcP1 = frame_info->src_frame.map[0].paddr +
-			frame_info->src_frame.map[0].data_offset;
-		outP0 = frame_info->dest_frame.map[0].paddr;
-		outP1 = frame_info->dest_frame.map[0].paddr +
-			frame_info->dest_frame.map[0].data_offset;
-	}
-
-	D("%s VPE Configured with Src %x, %x Dest %x, %x",
-		__func__, (uint32_t)srcP0, (uint32_t)srcP1,
-		(uint32_t)outP0, (uint32_t)outP1);
-
-	msm_camera_io_w(srcP0, vpe_ctrl->vpebase + VPE_SRCP0_ADDR_OFFSET);
-	msm_camera_io_w(srcP1, vpe_ctrl->vpebase + VPE_SRCP1_ADDR_OFFSET);
-	msm_camera_io_w(outP0, vpe_ctrl->vpebase + VPE_OUTP0_ADDR_OFFSET);
-	msm_camera_io_w(outP1, vpe_ctrl->vpebase + VPE_OUTP1_ADDR_OFFSET);
-
-	vpe_ctrl->state = VPE_STATE_ACTIVE;
-	spin_unlock_irqrestore(&vpe_ctrl->lock, flags);
-	vpe_start();
-	return rc;
-}
-
-static void vpe_send_outmsg(void)
-{
-	unsigned long flags;
-	struct v4l2_event v4l2_evt;
-	struct msm_queue_cmd *event_qcmd;
-	spin_lock_irqsave(&vpe_ctrl->lock, flags);
-	if (vpe_ctrl->state == VPE_STATE_IDLE) {
-		pr_err("%s VPE is in IDLE state. Ignore the ack msg", __func__);
-		spin_unlock_irqrestore(&vpe_ctrl->lock, flags);
-		return;
-	}
-	event_qcmd = kzalloc(sizeof(struct msm_queue_cmd), GFP_ATOMIC);
-	atomic_set(&event_qcmd->on_heap, 1);
-	event_qcmd->command = (void *)vpe_ctrl->pp_frame_info;
-	vpe_ctrl->pp_frame_info = NULL;
-	vpe_ctrl->state = VPE_STATE_INIT;   /* put it back to idle. */
-
-	/* Enqueue the event payload. */
-	msm_enqueue(&vpe_ctrl->eventData_q, &event_qcmd->list_eventdata);
-	/* Now queue the event. */
-	v4l2_evt.type = V4L2_EVENT_PRIVATE_START + MSM_CAM_RESP_MCTL_PP_EVENT;
-	v4l2_evt.id = 0;
-	v4l2_event_queue(vpe_ctrl->subdev.devnode, &v4l2_evt);
-	spin_unlock_irqrestore(&vpe_ctrl->lock, flags);
-}
-
-static void vpe_do_tasklet(unsigned long data)
-{
-	D("%s: irq_status = 0x%x",
-		   __func__, vpe_ctrl->irq_status);
-	if (vpe_ctrl->irq_status & 0x1)
-		vpe_send_outmsg();
-
-}
-DECLARE_TASKLET(vpe_tasklet, vpe_do_tasklet, 0);
-
-static irqreturn_t vpe_parse_irq(int irq_num, void *data)
-{
-	vpe_ctrl->irq_status = msm_camera_io_r_mb(vpe_ctrl->vpebase +
-							VPE_INTR_STATUS_OFFSET);
-	msm_camera_io_w_mb(vpe_ctrl->irq_status, vpe_ctrl->vpebase +
-				VPE_INTR_CLEAR_OFFSET);
-	msm_camera_io_w(0, vpe_ctrl->vpebase + VPE_INTR_ENABLE_OFFSET);
-	D("%s: vpe_parse_irq =0x%x.\n", __func__, vpe_ctrl->irq_status);
-	tasklet_schedule(&vpe_tasklet);
-	return IRQ_HANDLED;
-}
-
-static struct msm_cam_clk_info vpe_clk_info[] = {
-	{"vpe_clk", 160000000},
-	{"vpe_pclk", -1},
-};
-
-int vpe_enable(uint32_t clk_rate, struct msm_cam_media_controller *mctl)
-{
-	int rc = 0;
-	unsigned long flags = 0;
-	D("%s", __func__);
-	/* don't change the order of clock and irq.*/
-	spin_lock_irqsave(&vpe_ctrl->lock, flags);
-	if (vpe_ctrl->state != VPE_STATE_IDLE) {
-		pr_err("%s: VPE already enabled", __func__);
-		spin_unlock_irqrestore(&vpe_ctrl->lock, flags);
-		return 0;
-	}
-	vpe_ctrl->state = VPE_STATE_INIT;
-	spin_unlock_irqrestore(&vpe_ctrl->lock, flags);
-	enable_irq(vpe_ctrl->vpeirq->start);
-
-	if (vpe_ctrl->fs_vpe) {
-		rc = regulator_enable(vpe_ctrl->fs_vpe);
-		if (rc) {
-			pr_err("%s: Regulator enable failed\n", __func__);
-			goto vpe_fs_failed;
-		}
-	}
-
-	rc = msm_cam_clk_enable(&vpe_ctrl->pdev->dev, vpe_clk_info,
-			vpe_ctrl->vpe_clk, ARRAY_SIZE(vpe_clk_info), 1);
-	if (rc < 0)
-		goto vpe_clk_failed;
-
-#ifdef CONFIG_MSM_IOMMU
-	rc = iommu_attach_device(mctl->domain, vpe_ctrl->iommu_ctx_src);
-	if (rc < 0) {
-		pr_err("%s: Device attach failed\n", __func__);
-		goto src_attach_failed;
-	}
-	rc = iommu_attach_device(mctl->domain, vpe_ctrl->iommu_ctx_dst);
-	if (rc < 0) {
-		pr_err("%s: Device attach failed\n", __func__);
-		goto dst_attach_failed;
-	}
-#endif
-	return rc;
-
-#ifdef CONFIG_MSM_IOMMU
-dst_attach_failed:
-	iommu_detach_device(mctl->domain, vpe_ctrl->iommu_ctx_src);
-src_attach_failed:
-#endif
-	msm_cam_clk_enable(&vpe_ctrl->pdev->dev, vpe_clk_info,
-		vpe_ctrl->vpe_clk, ARRAY_SIZE(vpe_clk_info), 0);
-vpe_clk_failed:
-	if (vpe_ctrl->fs_vpe)
-		regulator_disable(vpe_ctrl->fs_vpe);
-vpe_fs_failed:
-	disable_irq(vpe_ctrl->vpeirq->start);
-	vpe_ctrl->state = VPE_STATE_IDLE;
-	return rc;
-}
-
-int vpe_disable(struct msm_cam_media_controller *mctl)
-{
-	int rc = 0;
-	unsigned long flags = 0;
-	D("%s", __func__);
-	spin_lock_irqsave(&vpe_ctrl->lock, flags);
-	if (vpe_ctrl->state == VPE_STATE_IDLE) {
-		D("%s: VPE already disabled", __func__);
-		spin_unlock_irqrestore(&vpe_ctrl->lock, flags);
-		return rc;
-	}
-	spin_unlock_irqrestore(&vpe_ctrl->lock, flags);
-#ifdef CONFIG_MSM_IOMMU
-	iommu_detach_device(mctl->domain, vpe_ctrl->iommu_ctx_dst);
-	iommu_detach_device(mctl->domain, vpe_ctrl->iommu_ctx_src);
-#endif
-	disable_irq(vpe_ctrl->vpeirq->start);
-	tasklet_kill(&vpe_tasklet);
-	msm_cam_clk_enable(&vpe_ctrl->pdev->dev, vpe_clk_info,
-			vpe_ctrl->vpe_clk, ARRAY_SIZE(vpe_clk_info), 0);
-
-	regulator_disable(vpe_ctrl->fs_vpe);
-	spin_lock_irqsave(&vpe_ctrl->lock, flags);
-	vpe_ctrl->state = VPE_STATE_IDLE;
-	spin_unlock_irqrestore(&vpe_ctrl->lock, flags);
-	return rc;
-}
-
-static int msm_vpe_do_pp(struct msm_mctl_pp_frame_info *pp_frame_info)
-{
-	int rc = 0;
-	unsigned long flags;
-
-	spin_lock_irqsave(&vpe_ctrl->lock, flags);
-	if (vpe_ctrl->state == VPE_STATE_ACTIVE ||
-		 vpe_ctrl->state == VPE_STATE_IDLE) {
-		spin_unlock_irqrestore(&vpe_ctrl->lock, flags);
-		pr_err(" =====VPE in wrong state:%d!!!  Wrong!========\n",
-		vpe_ctrl->state);
-		return -EBUSY;
-	}
-	spin_unlock_irqrestore(&vpe_ctrl->lock, flags);
-	vpe_ctrl->pp_frame_info = pp_frame_info;
-	msm_vpe_cfg_update(
-		&vpe_ctrl->pp_frame_info->pp_frame_cmd.crop);
-	D("%s Sending frame idx %d id %d to VPE ", __func__,
-		pp_frame_info->src_frame.frame.buf_idx,
-		pp_frame_info->src_frame.frame.frame_id);
-	rc = msm_send_frame_to_vpe();
-	return rc;
-}
-
-static int msm_vpe_resource_init(void);
-
-int msm_vpe_subdev_init(struct v4l2_subdev *sd)
-{
-	int rc = 0;
-	struct msm_cam_media_controller *mctl;
-	mctl = v4l2_get_subdev_hostdata(sd);
-	D("%s:begin", __func__);
-	if (atomic_read(&vpe_init_done)) {
-		pr_err("%s: VPE has been initialized", __func__);
-		return -EBUSY;
-	}
-	atomic_set(&vpe_init_done, 1);
-
-	rc = msm_vpe_resource_init();
-	if (rc < 0) {
-		atomic_set(&vpe_init_done, 0);
-		return rc;
-	}
-	spin_lock_init(&vpe_ctrl->lock);
-	D("%s:end", __func__);
-	return rc;
-}
-EXPORT_SYMBOL(msm_vpe_subdev_init);
-
-static int msm_vpe_resource_init(void)
-{
-	int rc = 0;
-
-	vpe_ctrl->vpebase = ioremap(vpe_ctrl->vpemem->start,
-		resource_size(vpe_ctrl->vpemem));
-
-	if (!vpe_ctrl->vpebase) {
-		rc = -ENOMEM;
-		pr_err("%s: vpe ioremap failed\n", __func__);
-		goto vpe_unmap_mem_region;
-	}
-
-	return rc;
-/* from this part it is error handling. */
-vpe_unmap_mem_region:
-	iounmap(vpe_ctrl->vpebase);
-	vpe_ctrl->vpebase = NULL;
-	return rc;  /* this rc should have error code. */
-}
-
-void msm_vpe_subdev_release(struct v4l2_subdev *sd)
-{
-	struct msm_cam_media_controller *mctl;
-	mctl = v4l2_get_subdev_hostdata(sd);
-	if (!atomic_read(&vpe_init_done)) {
-		/* no VPE object created */
-		pr_err("%s: no VPE object to release", __func__);
-		return;
-	}
-	vpe_reset();
-	vpe_disable(mctl);
-	iounmap(vpe_ctrl->vpebase);
-	vpe_ctrl->vpebase = NULL;
-	atomic_set(&vpe_init_done, 0);
-}
-EXPORT_SYMBOL(msm_vpe_subdev_release);
-
-static int msm_vpe_process_vpe_cmd(struct msm_vpe_cfg_cmd *vpe_cmd,
-				struct msm_cam_media_controller *mctl)
-{
-	int rc = 0;
-
-	switch (vpe_cmd->cmd_type) {
-	case VPE_CMD_RESET:
-		rc = vpe_reset();
-		break;
-
-	case VPE_CMD_OPERATION_MODE_CFG: {
-		struct msm_vpe_op_mode_cfg op_mode_cfg;
-		if (sizeof(struct msm_vpe_op_mode_cfg) != vpe_cmd->length) {
-			pr_err("%s: size mismatch cmd=%d, len=%d, expected=%d",
-				__func__, vpe_cmd->cmd_type, vpe_cmd->length,
-				sizeof(struct msm_vpe_op_mode_cfg));
-			rc = -EINVAL;
-			break;
-		}
-		COPY_FROM_USER(rc, &op_mode_cfg, (void __user *)vpe_cmd->value,
-			sizeof(op_mode_cfg));
-		if (rc) {
-			ERR_COPY_FROM_USER();
-			break;
-		}
-
-		vpe_cmd->value = (void *)&op_mode_cfg;
-		rc = vpe_operation_config(vpe_cmd->value);
-		break;
-		}
-
-	case VPE_CMD_INPUT_PLANE_CFG: {
-		struct msm_vpe_input_plane_cfg input_cfg;
-		if (sizeof(struct msm_vpe_input_plane_cfg) != vpe_cmd->length) {
-			pr_err("%s: mismatch cmd = %d, len = %d, expected = %d",
-				__func__, vpe_cmd->cmd_type, vpe_cmd->length,
-				sizeof(struct msm_vpe_input_plane_cfg));
-			rc = -EINVAL;
-			break;
-		}
-		COPY_FROM_USER(rc, &input_cfg, (void __user *)vpe_cmd->value,
-			sizeof(input_cfg));
-		if (rc) {
-			ERR_COPY_FROM_USER();
-			break;
-		}
-
-		vpe_cmd->value = (void *)&input_cfg;
-		vpe_input_plane_config(vpe_cmd->value);
-		break;
-		}
-
-	case VPE_CMD_OUTPUT_PLANE_CFG: {
-		struct msm_vpe_output_plane_cfg output_cfg;
-		if (sizeof(struct msm_vpe_output_plane_cfg) !=
-			vpe_cmd->length) {
-			pr_err("%s: size mismatch cmd=%d, len=%d, expected=%d",
-				__func__, vpe_cmd->cmd_type, vpe_cmd->length,
-				sizeof(struct msm_vpe_output_plane_cfg));
-				rc = -EINVAL;
-				break;
-		}
-		COPY_FROM_USER(rc, &output_cfg, (void __user *)vpe_cmd->value,
-			sizeof(output_cfg));
-		if (rc) {
-			ERR_COPY_FROM_USER();
-			break;
-		}
-
-		vpe_cmd->value = (void *)&output_cfg;
-		vpe_output_plane_config(vpe_cmd->value);
-		break;
-		}
-
-	case VPE_CMD_SCALE_CFG_TYPE:{
-		struct msm_vpe_scaler_cfg scaler_cfg;
-		if (sizeof(struct msm_vpe_scaler_cfg) != vpe_cmd->length) {
-			pr_err("%s: size mismatch cmd=%d, len=%d, expected=%d",
-				__func__, vpe_cmd->cmd_type, vpe_cmd->length,
-				sizeof(struct msm_vpe_scaler_cfg));
-			rc = -EINVAL;
-			break;
-		}
-		COPY_FROM_USER(rc, &scaler_cfg, (void __user *)vpe_cmd->value,
-			sizeof(scaler_cfg));
-		if (rc) {
-			ERR_COPY_FROM_USER();
-			break;
-		}
-
-		vpe_cmd->value = (void *)&scaler_cfg;
-		vpe_update_scale_coef(vpe_cmd->value);
-		break;
-		}
-
-	case VPE_CMD_ZOOM: {
-		struct msm_mctl_pp_frame_info *zoom;
-		zoom = kmalloc(sizeof(struct msm_mctl_pp_frame_info),
-				GFP_ATOMIC);
-		if (!zoom) {
-			pr_err("%s Not enough memory ", __func__);
-			rc = -ENOMEM;
-			break;
-		}
-
-		if (sizeof(zoom->pp_frame_cmd) != vpe_cmd->length) {
-			pr_err("%s: size mismatch id=%d, len=%d, expected=%d",
-				__func__, vpe_cmd->cmd_type, vpe_cmd->length,
-				sizeof(zoom->pp_frame_cmd));
-			rc = -EINVAL;
-			kfree(zoom);
-			break;
-		}
-		COPY_FROM_USER(rc, &zoom->pp_frame_cmd,
-			(void __user *)vpe_cmd->value,
-			sizeof(zoom->pp_frame_cmd));
-		if (rc) {
-			ERR_COPY_FROM_USER();
-			kfree(zoom);
-			break;
-		}
-
-		zoom->user_cmd = vpe_cmd->cmd_type;
-		zoom->p_mctl = v4l2_get_subdev_hostdata(&vpe_ctrl->subdev);
-		D("%s: cookie=0x%x,action=0x%x,path=0x%x",
-			__func__, zoom->pp_frame_cmd.cookie,
-			zoom->pp_frame_cmd.vpe_output_action,
-			zoom->pp_frame_cmd.path);
-
-		D("%s Mapping Source frame ", __func__);
-		zoom->src_frame.frame = zoom->pp_frame_cmd.src_frame;
-		rc = msm_mctl_map_user_frame(&zoom->src_frame,
-			zoom->p_mctl->client, mctl->domain_num);
-		if (rc < 0) {
-			pr_err("%s Error mapping source buffer rc = %d",
-				__func__, rc);
-			kfree(zoom);
-			break;
-		}
-
-		D("%s Mapping Destination frame ", __func__);
-		zoom->dest_frame.frame = zoom->pp_frame_cmd.dest_frame;
-		rc = msm_mctl_map_user_frame(&zoom->dest_frame,
-			zoom->p_mctl->client, mctl->domain_num);
-		if (rc < 0) {
-			pr_err("%s Error mapping dest buffer rc = %d",
-				__func__, rc);
-			msm_mctl_unmap_user_frame(&zoom->src_frame,
-				zoom->p_mctl->client, mctl->domain_num);
-			kfree(zoom);
-			break;
-		}
-
-		rc = msm_vpe_do_pp(zoom);
-		break;
-		}
-
-	case VPE_CMD_ENABLE: {
-		struct msm_vpe_clock_rate clk_rate;
-		int turbo_mode;
-		if (sizeof(struct msm_vpe_clock_rate) != vpe_cmd->length) {
-			pr_err("%s: size mismatch cmd=%d, len=%d, expected=%d",
-				__func__, vpe_cmd->cmd_type, vpe_cmd->length,
-				sizeof(struct msm_vpe_clock_rate));
-			rc = -EINVAL;
-			break;
-		}
-		if (copy_from_user(&clk_rate, (void __user *)vpe_cmd->value,
-			sizeof(struct msm_vpe_clock_rate))) {
-			pr_err("%s:clk_rate copy failed", __func__);
-			return -EFAULT;
-		}
-		turbo_mode = (int)clk_rate.rate;
-		rc = turbo_mode ? vpe_enable(VPE_TURBO_MODE_CLOCK_RATE, mctl) :
-				vpe_enable(VPE_NORMAL_MODE_CLOCK_RATE, mctl);
-		break;
-		}
-
-	case VPE_CMD_DISABLE:
-		rc = vpe_disable(mctl);
-		break;
-
-	default:
-		break;
-	}
-
-	return rc;
-}
-
-static long msm_vpe_subdev_ioctl(struct v4l2_subdev *sd,
-			unsigned int cmd, void *arg)
-{
-	struct msm_vpe_cfg_cmd *vpe_cmd;
-	int rc = 0;
-	struct msm_cam_media_controller *mctl;
-	mctl = v4l2_get_subdev_hostdata(sd);
-	switch (cmd) {
-	case VIDIOC_MSM_VPE_INIT: {
-		msm_vpe_subdev_init(sd);
-		break;
-		}
-
-	case VIDIOC_MSM_VPE_RELEASE:
-		msm_vpe_subdev_release(sd);
-		break;
-
-	case MSM_CAM_V4L2_IOCTL_CFG_VPE: {
-		vpe_cmd = (struct msm_vpe_cfg_cmd *)arg;
-		rc = msm_vpe_process_vpe_cmd(vpe_cmd, mctl);
-		if (rc < 0) {
-			pr_err("%s Error processing VPE cmd %d ",
-				__func__, vpe_cmd->cmd_type);
-			break;
-		}
-		break;
-		}
-
-	case MSM_CAM_V4L2_IOCTL_GET_EVENT_PAYLOAD: {
-		struct msm_device_queue *queue = &vpe_ctrl->eventData_q;
-		struct msm_queue_cmd *event_qcmd;
-		struct msm_mctl_pp_event_info pp_event_info;
-		struct msm_mctl_pp_frame_info *pp_frame_info;
-		struct msm_camera_v4l2_ioctl_t *v4l2_ioctl = arg;
-
-		event_qcmd = msm_dequeue(queue, list_eventdata);
-		if (!event_qcmd) {
-			pr_err("%s No events in the queue", __func__);
-			return -EFAULT;
-		}
-		pp_frame_info = event_qcmd->command;
-
-		D("%s Unmapping source and destination buffers ",
-			__func__);
-		msm_mctl_unmap_user_frame(&pp_frame_info->src_frame,
-			pp_frame_info->p_mctl->client, mctl->domain_num);
-		msm_mctl_unmap_user_frame(&pp_frame_info->dest_frame,
-			pp_frame_info->p_mctl->client, mctl->domain_num);
-
-		pp_event_info.event = MCTL_PP_EVENT_CMD_ACK;
-		pp_event_info.ack.cmd = pp_frame_info->user_cmd;
-		pp_event_info.ack.status = 0;
-		pp_event_info.ack.cookie = pp_frame_info->pp_frame_cmd.cookie;
-		D("%s Sending payload %d %d %d", __func__,
-			pp_event_info.ack.cmd, pp_event_info.ack.status,
-			pp_event_info.ack.cookie);
-		if (copy_to_user((void __user *)v4l2_ioctl->ioctl_ptr,
-			&pp_event_info,	sizeof(struct msm_mctl_pp_event_info)))
-			pr_err("%s PAYLOAD Copy to user failed ", __func__);
-
-		kfree(pp_frame_info);
-		kfree(event_qcmd);
-		break;
-		}
-
-	default:
-		break;
-	}
-	return rc;
-}
-
-int msm_vpe_subdev_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
-	struct v4l2_event_subscription *sub)
-{
-	D("%s E\n", __func__);
-	return v4l2_event_subscribe(fh, sub, VPE_SUBDEV_MAX_EVENTS);
-}
-
-int msm_vpe_subdev_unsubscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
-	struct v4l2_event_subscription *sub)
-{
-	D("%s E\n", __func__);
-	return v4l2_event_unsubscribe(fh, sub);
-}
-
-static const struct v4l2_subdev_core_ops msm_vpe_subdev_core_ops = {
-	.ioctl = msm_vpe_subdev_ioctl,
-	.subscribe_event = msm_vpe_subdev_subscribe_event,
-	.unsubscribe_event = msm_vpe_subdev_unsubscribe_event,
-};
-
-static const struct v4l2_subdev_ops msm_vpe_subdev_ops = {
-	.core = &msm_vpe_subdev_core_ops,
-};
-
-static int msm_vpe_subdev_open(struct v4l2_subdev *sd,
-	struct v4l2_subdev_fh *fh)
-{
-	struct vpe_ctrl_type *vpe_ctrl = v4l2_get_subdevdata(sd);
-	/* Only one client of VPE allowed. */
-	if (atomic_read(&vpe_ctrl->active) != 0) {
-		pr_err("%s already opened\n", __func__);
-		return -EINVAL;
-	}
-
-	D("%s E ", __func__);
-	atomic_inc(&vpe_ctrl->active);
-	return 0;
-}
-
-static int msm_vpe_subdev_close(struct v4l2_subdev *sd,
-	struct v4l2_subdev_fh *fh)
-{
-	struct vpe_ctrl_type *vpe_ctrl = v4l2_get_subdevdata(sd);
-	struct msm_mctl_pp_frame_info *frame_info = vpe_ctrl->pp_frame_info;
-	struct msm_cam_media_controller *mctl;
-	mctl = v4l2_get_subdev_hostdata(sd);
-	if (atomic_read(&vpe_ctrl->active) == 0) {
-		pr_err("%s already closed\n", __func__);
-		return -EINVAL;
-	}
-
-	D("%s E ", __func__);
-	if (frame_info) {
-		D("%s Unmap the pending item from the queue ", __func__);
-		msm_mctl_unmap_user_frame(&frame_info->src_frame,
-			frame_info->p_mctl->client, mctl->domain_num);
-		msm_mctl_unmap_user_frame(&frame_info->dest_frame,
-			frame_info->p_mctl->client, mctl->domain_num);
-	}
-	/* Drain the payload queue. */
-	msm_queue_drain(&vpe_ctrl->eventData_q, list_eventdata);
-	atomic_dec(&vpe_ctrl->active);
-	return 0;
-}
-
-static const struct v4l2_subdev_internal_ops msm_vpe_internal_ops = {
-	.open = msm_vpe_subdev_open,
-	.close = msm_vpe_subdev_close,
-};
-
-static int __devinit msm_vpe_probe(struct platform_device *pdev)
-{
-	int rc = 0;
-	struct msm_cam_subdev_info sd_info;
-
-	D("%s: device id = %d\n", __func__, pdev->id);
-	vpe_ctrl = kzalloc(sizeof(struct vpe_ctrl_type), GFP_KERNEL);
-	if (!vpe_ctrl) {
-		pr_err("%s: not enough memory\n", __func__);
-		return -ENOMEM;
-	}
-
-	v4l2_subdev_init(&vpe_ctrl->subdev, &msm_vpe_subdev_ops);
-	v4l2_set_subdevdata(&vpe_ctrl->subdev, vpe_ctrl);
-	vpe_ctrl->subdev.internal_ops = &msm_vpe_internal_ops;
-	vpe_ctrl->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	snprintf(vpe_ctrl->subdev.name, sizeof(vpe_ctrl->subdev.name), "vpe");
-	platform_set_drvdata(pdev, &vpe_ctrl->subdev);
-
-	media_entity_init(&vpe_ctrl->subdev.entity, 0, NULL, 0);
-	vpe_ctrl->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
-	vpe_ctrl->subdev.entity.group_id = VPE_DEV;
-	vpe_ctrl->subdev.entity.name = vpe_ctrl->subdev.name;
-
-	vpe_ctrl->subdev.flags |= V4L2_SUBDEV_FL_HAS_EVENTS;
-
-	vpe_ctrl->vpemem = platform_get_resource_byname(pdev,
-					IORESOURCE_MEM, "vpe");
-	if (!vpe_ctrl->vpemem) {
-		pr_err("%s: no mem resource?\n", __func__);
-		rc = -ENODEV;
-		goto vpe_no_resource;
-	}
-	vpe_ctrl->vpeirq = platform_get_resource_byname(pdev,
-					IORESOURCE_IRQ, "vpe");
-	if (!vpe_ctrl->vpeirq) {
-		pr_err("%s: no irq resource?\n", __func__);
-		rc = -ENODEV;
-		goto vpe_no_resource;
-	}
-
-	vpe_ctrl->vpeio = request_mem_region(vpe_ctrl->vpemem->start,
-		resource_size(vpe_ctrl->vpemem), pdev->name);
-	if (!vpe_ctrl->vpeio) {
-		pr_err("%s: no valid mem region\n", __func__);
-		rc = -EBUSY;
-		goto vpe_no_resource;
-	}
-
-	rc = request_irq(vpe_ctrl->vpeirq->start, vpe_parse_irq,
-		IRQF_TRIGGER_RISING, "vpe", 0);
-	if (rc < 0) {
-		release_mem_region(vpe_ctrl->vpemem->start,
-			resource_size(vpe_ctrl->vpemem));
-		pr_err("%s: irq request fail\n", __func__);
-		rc = -EBUSY;
-		goto vpe_no_resource;
-	}
-
-	vpe_ctrl->fs_vpe = regulator_get(&pdev->dev, "vdd");
-	if (IS_ERR(vpe_ctrl->fs_vpe)) {
-		pr_err("%s: Regulator FS_VPE get failed %ld\n", __func__,
-			PTR_ERR(vpe_ctrl->fs_vpe));
-		vpe_ctrl->fs_vpe = NULL;
-	}
-
-	disable_irq(vpe_ctrl->vpeirq->start);
-
-#ifdef CONFIG_MSM_IOMMU
-	/*get device context for IOMMU*/
-	vpe_ctrl->iommu_ctx_src = msm_iommu_get_ctx("vpe_src"); /*re-confirm*/
-	vpe_ctrl->iommu_ctx_dst = msm_iommu_get_ctx("vpe_dst"); /*re-confirm*/
-	if (!vpe_ctrl->iommu_ctx_src || !vpe_ctrl->iommu_ctx_dst) {
-		release_mem_region(vpe_ctrl->vpemem->start,
-			resource_size(vpe_ctrl->vpemem));
-		pr_err("%s: No iommu fw context found\n", __func__);
-		rc = -ENODEV;
-		goto vpe_no_resource;
-	}
-#endif
-
-	atomic_set(&vpe_ctrl->active, 0);
-	vpe_ctrl->pdev = pdev;
-	sd_info.sdev_type = VPE_DEV;
-	sd_info.sd_index = pdev->id;
-	sd_info.irq_num = vpe_ctrl->vpeirq->start;
-	msm_cam_register_subdev_node(&vpe_ctrl->subdev, &sd_info);
-	vpe_ctrl->subdev.entity.revision = vpe_ctrl->subdev.devnode->num;
-	msm_queue_init(&vpe_ctrl->eventData_q, "ackevents");
-
-	return 0;
-
-vpe_no_resource:
-	pr_err("%s: VPE Probe failed.\n", __func__);
-	kfree(vpe_ctrl);
-	return rc;
-}
-
-struct platform_driver msm_vpe_driver = {
-	.probe = msm_vpe_probe,
-	.driver = {
-		.name = MSM_VPE_DRV_NAME,
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init msm_vpe_init_module(void)
-{
-	return platform_driver_register(&msm_vpe_driver);
-}
-
-static void __exit msm_vpe_exit_module(void)
-{
-	platform_driver_unregister(&msm_vpe_driver);
-}
-
-module_init(msm_vpe_init_module);
-module_exit(msm_vpe_exit_module);
-MODULE_DESCRIPTION("VPE driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/msm_vpe.h b/drivers/media/platform/msm/camera_v1/msm_vpe.h
deleted file mode 100644
index 6b89bf0..0000000
--- a/drivers/media/platform/msm/camera_v1/msm_vpe.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- *
- */
-
-#ifndef _MSM_VPE_H_
-#define _MSM_VPE_H_
-
-#include <mach/camera.h>
-
-/***********  start of register offset *********************/
-#define VPE_INTR_ENABLE_OFFSET                0x0020
-#define VPE_INTR_STATUS_OFFSET                0x0024
-#define VPE_INTR_CLEAR_OFFSET                 0x0028
-#define VPE_DL0_START_OFFSET                  0x0030
-#define VPE_HW_VERSION_OFFSET                 0x0070
-#define VPE_SW_RESET_OFFSET                   0x0074
-#define VPE_AXI_RD_ARB_CONFIG_OFFSET          0x0078
-#define VPE_SEL_CLK_OR_HCLK_TEST_BUS_OFFSET   0x007C
-#define VPE_CGC_EN_OFFSET                     0x0100
-#define VPE_CMD_STATUS_OFFSET                 0x10008
-#define VPE_PROFILE_EN_OFFSET                 0x10010
-#define VPE_PROFILE_COUNT_OFFSET              0x10014
-#define VPE_CMD_MODE_OFFSET                   0x10060
-#define VPE_SRC_SIZE_OFFSET                   0x10108
-#define VPE_SRCP0_ADDR_OFFSET                 0x1010C
-#define VPE_SRCP1_ADDR_OFFSET                 0x10110
-#define VPE_SRC_YSTRIDE1_OFFSET               0x1011C
-#define VPE_SRC_FORMAT_OFFSET                 0x10124
-#define VPE_SRC_UNPACK_PATTERN1_OFFSET        0x10128
-#define VPE_OP_MODE_OFFSET                    0x10138
-#define VPE_SCALE_PHASEX_INIT_OFFSET          0x1013C
-#define VPE_SCALE_PHASEY_INIT_OFFSET          0x10140
-#define VPE_SCALE_PHASEX_STEP_OFFSET          0x10144
-#define VPE_SCALE_PHASEY_STEP_OFFSET          0x10148
-#define VPE_OUT_FORMAT_OFFSET                 0x10150
-#define VPE_OUT_PACK_PATTERN1_OFFSET          0x10154
-#define VPE_OUT_SIZE_OFFSET                   0x10164
-#define VPE_OUTP0_ADDR_OFFSET                 0x10168
-#define VPE_OUTP1_ADDR_OFFSET                 0x1016C
-#define VPE_OUT_YSTRIDE1_OFFSET               0x10178
-#define VPE_OUT_XY_OFFSET                     0x1019C
-#define VPE_SRC_XY_OFFSET                     0x10200
-#define VPE_SRC_IMAGE_SIZE_OFFSET             0x10208
-#define VPE_SCALE_CONFIG_OFFSET               0x10230
-#define VPE_DEINT_STATUS_OFFSET               0x30000
-#define VPE_DEINT_DECISION_OFFSET             0x30004
-#define VPE_DEINT_COEFF0_OFFSET               0x30010
-#define VPE_SCALE_STATUS_OFFSET               0x50000
-#define VPE_SCALE_SVI_PARAM_OFFSET            0x50010
-#define VPE_SCALE_SHARPEN_CFG_OFFSET          0x50020
-#define VPE_SCALE_COEFF_LSP_0_OFFSET          0x50400
-#define VPE_SCALE_COEFF_MSP_0_OFFSET          0x50404
-
-#define VPE_AXI_ARB_1_OFFSET                  0x00408
-#define VPE_AXI_ARB_2_OFFSET                  0x0040C
-
-#define VPE_SCALE_COEFF_LSBn(n)	(0x50400 + 8 * (n))
-#define VPE_SCALE_COEFF_MSBn(n)	(0x50404 + 8 * (n))
-#define VPE_SCALE_COEFF_NUM			32
-
-/*********** end of register offset ********************/
-
-
-#define VPE_HARDWARE_VERSION          0x00080308
-#define VPE_SW_RESET_VALUE            0x00000010  /* bit 4 for PPP*/
-#define VPE_AXI_RD_ARB_CONFIG_VALUE   0x124924
-#define VPE_CMD_MODE_VALUE            0x1
-#define VPE_DEFAULT_OP_MODE_VALUE     0x40FC0004
-#define VPE_CGC_ENABLE_VALUE          0xffff
-#define VPE_DEFAULT_SCALE_CONFIG      0x3c
-
-#define VPE_NORMAL_MODE_CLOCK_RATE   150000000
-#define VPE_TURBO_MODE_CLOCK_RATE    200000000
-#define VPE_SUBDEV_MAX_EVENTS        30
-
-/**************************************************/
-/*********** End of command id ********************/
-/**************************************************/
-
-enum vpe_state {
-	VPE_STATE_IDLE,
-	VPE_STATE_INIT,
-	VPE_STATE_ACTIVE,
-};
-
-struct vpe_ctrl_type {
-	spinlock_t        lock;
-	uint32_t          irq_status;
-	void              *syncdata;
-	uint16_t          op_mode;
-	void              *extdata;
-	uint32_t          extlen;
-	struct msm_vpe_callback *resp;
-	uint32_t          out_h;  /* this is BEFORE rotation. */
-	uint32_t          out_w;  /* this is BEFORE rotation. */
-	struct timespec   ts;
-	int               output_type;
-	int               frame_pack;
-	uint8_t           pad_2k_bool;
-	enum vpe_state    state;
-	unsigned long     out_y_addr;
-	unsigned long     out_cbcr_addr;
-	struct v4l2_subdev subdev;
-	struct platform_device *pdev;
-	struct resource   *vpeirq;
-	void __iomem      *vpebase;
-	struct resource	  *vpemem;
-	struct resource   *vpeio;
-	void        *device_extdata;
-	struct regulator *fs_vpe;
-	struct clk	*vpe_clk[2];
-	struct msm_mctl_pp_frame_info *pp_frame_info;
-	atomic_t active;
-	struct msm_device_queue eventData_q; /*V4L2 Event Payload Queue*/
-	struct device *iommu_ctx_src;
-	struct device *iommu_ctx_dst;
-};
-
-/*
-* vpe_input_update
-*
-* Define the parameters for output plane
-*/
-/* this is the dimension of ROI.  width / height. */
-struct vpe_src_size_packed {
-	uint32_t        src_w;
-	uint32_t        src_h;
-};
-
-struct vpe_src_xy_packed {
-	uint32_t        src_x;
-	uint32_t        src_y;
-};
-
-struct vpe_input_plane_update_type {
-	struct vpe_src_size_packed             src_roi_size;
-	/* crop updates this set. */
-	struct vpe_src_xy_packed               src_roi_offset;
-	/* input address*/
-	uint8_t                         *src_p0_addr;
-	uint8_t                         *src_p1_addr;
-};
-
-struct vpe_msg_stats {
-	uint32_t    buffer;
-	uint32_t    frameCounter;
-};
-
-struct vpe_msg_output {
-	uint8_t   output_id;
-	uint32_t  yBuffer;
-	uint32_t  cbcrBuffer;
-	uint32_t  frameCounter;
-};
-
-struct vpe_message {
-	uint8_t  _d;
-	union {
-		struct vpe_msg_output              msgOut;
-		struct vpe_msg_stats               msgStats;
-	} _u;
-};
-
-#define SCALER_PHASE_BITS 29
-#define HAL_MDP_PHASE_STEP_2P50    0x50000000
-#define HAL_MDP_PHASE_STEP_1P66    0x35555555
-#define HAL_MDP_PHASE_STEP_1P25    0x28000000
-
-struct phase_val_t {
-	int32_t phase_init_x;
-	int32_t phase_init_y;
-	int32_t phase_step_x;
-	int32_t phase_step_y;
-};
-
-#endif /*_MSM_VPE_H_*/
-
diff --git a/drivers/media/platform/msm/camera_v1/msm_vpe1.c b/drivers/media/platform/msm/camera_v1/msm_vpe1.c
deleted file mode 100644
index 948f7ac..0000000
--- a/drivers/media/platform/msm/camera_v1/msm_vpe1.c
+++ /dev/null
@@ -1,1469 +0,0 @@
-/* Copyright (c) 2010-2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/uaccess.h>
-#include <linux/interrupt.h>
-#include <mach/irqs.h>
-#include <linux/io.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include "msm_vpe1.h"
-#include <linux/pm_qos.h>
-#include <linux/clk.h>
-#include <mach/clk.h>
-#include <asm/div64.h>
-
-static int vpe_enable(uint32_t);
-static int vpe_disable(void);
-static int vpe_update_scaler(struct video_crop_t *pcrop);
-static struct vpe_device_type  vpe_device_data;
-static struct vpe_device_type  *vpe_device;
-struct vpe_ctrl_type    *vpe_ctrl;
-char *vpe_general_cmd[] = {
-	"VPE_DUMMY_0",  /* 0 */
-	"VPE_SET_CLK",
-	"VPE_RESET",
-	"VPE_START",
-	"VPE_ABORT",
-	"VPE_OPERATION_MODE_CFG",  /* 5 */
-	"VPE_INPUT_PLANE_CFG",
-	"VPE_OUTPUT_PLANE_CFG",
-	"VPE_INPUT_PLANE_UPDATE",
-	"VPE_SCALE_CFG_TYPE",
-	"VPE_ROTATION_CFG_TYPE",  /* 10 */
-	"VPE_AXI_OUT_CFG",
-	"VPE_CMD_DIS_OFFSET_CFG",
-	"VPE_ENABLE",
-	"VPE_DISABLE",
-};
-static uint32_t orig_src_y, orig_src_cbcr;
-
-#define CHECKED_COPY_FROM_USER(in) {					\
-	if (copy_from_user((in), (void __user *)cmd->value,		\
-			cmd->length)) {					\
-		rc = -EFAULT;						\
-		break;							\
-	}								\
-}
-
-#define msm_dequeue_vpe(queue, member) ({			\
-	unsigned long flags;					\
-	struct msm_device_queue *__q = (queue);			\
-	struct msm_queue_cmd *qcmd = 0;				\
-	spin_lock_irqsave(&__q->lock, flags);			\
-	if (!list_empty(&__q->list)) {				\
-		__q->len--;					\
-		qcmd = list_first_entry(&__q->list,		\
-				struct msm_queue_cmd, member);	\
-		list_del_init(&qcmd->member);			\
-	}							\
-	spin_unlock_irqrestore(&__q->lock, flags);		\
-	qcmd;							\
-})
-
-/*
-static   struct vpe_cmd_type vpe_cmd[] = {
-		{VPE_DUMMY_0, 0},
-		{VPE_SET_CLK, 0},
-		{VPE_RESET, 0},
-		{VPE_START, 0},
-		{VPE_ABORT, 0},
-		{VPE_OPERATION_MODE_CFG, VPE_OPERATION_MODE_CFG_LEN},
-		{VPE_INPUT_PLANE_CFG, VPE_INPUT_PLANE_CFG_LEN},
-		{VPE_OUTPUT_PLANE_CFG, VPE_OUTPUT_PLANE_CFG_LEN},
-		{VPE_INPUT_PLANE_UPDATE, VPE_INPUT_PLANE_UPDATE_LEN},
-		{VPE_SCALE_CFG_TYPE, VPE_SCALER_CONFIG_LEN},
-		{VPE_ROTATION_CFG_TYPE, 0},
-		{VPE_AXI_OUT_CFG, 0},
-		{VPE_CMD_DIS_OFFSET_CFG, VPE_DIS_OFFSET_CFG_LEN},
-};
-*/
-
-static long long vpe_do_div(long long num, long long den)
-{
-	do_div(num, den);
-	return num;
-}
-
-static int vpe_start(void)
-{
-	/*  enable the frame irq, bit 0 = Display list 0 ROI done */
-	msm_camera_io_w(1, vpe_device->vpebase + VPE_INTR_ENABLE_OFFSET);
-	msm_camera_io_dump(vpe_device->vpebase + 0x10000, 0x250);
-	/* this triggers the operation. */
-	msm_camera_io_w(1, vpe_device->vpebase + VPE_DL0_START_OFFSET);
-
-	return 0;
-}
-
-void vpe_reset_state_variables(void)
-{
-	/* initialize local variables for state control, etc.*/
-	vpe_ctrl->op_mode = 0;
-	vpe_ctrl->state = VPE_STATE_INIT;
-	spin_lock_init(&vpe_ctrl->tasklet_lock);
-	spin_lock_init(&vpe_ctrl->state_lock);
-	INIT_LIST_HEAD(&vpe_ctrl->tasklet_q);
-}
-
-static void vpe_config_axi_default(void)
-{
-	msm_camera_io_w(0x25, vpe_device->vpebase + VPE_AXI_ARB_2_OFFSET);
-
-	CDBG("%s: yaddr %ld cbcraddr %ld", __func__,
-		 vpe_ctrl->out_y_addr, vpe_ctrl->out_cbcr_addr);
-
-	if (!vpe_ctrl->out_y_addr || !vpe_ctrl->out_cbcr_addr)
-		return;
-
-	msm_camera_io_w(vpe_ctrl->out_y_addr,
-		vpe_device->vpebase + VPE_OUTP0_ADDR_OFFSET);
-	/* for video  CbCr address */
-	msm_camera_io_w(vpe_ctrl->out_cbcr_addr,
-		vpe_device->vpebase + VPE_OUTP1_ADDR_OFFSET);
-
-}
-
-static int vpe_reset(void)
-{
-	uint32_t vpe_version;
-	uint32_t rc;
-
-	vpe_reset_state_variables();
-	vpe_version = msm_camera_io_r(
-			vpe_device->vpebase + VPE_HW_VERSION_OFFSET);
-	CDBG("vpe_version = 0x%x\n", vpe_version);
-
-	/* disable all interrupts.*/
-	msm_camera_io_w(0, vpe_device->vpebase + VPE_INTR_ENABLE_OFFSET);
-	/* clear all pending interrupts*/
-	msm_camera_io_w(0x1fffff, vpe_device->vpebase + VPE_INTR_CLEAR_OFFSET);
-
-	/* write sw_reset to reset the core. */
-	msm_camera_io_w(0x10, vpe_device->vpebase + VPE_SW_RESET_OFFSET);
-
-	/* then poll the reset bit, it should be self-cleared. */
-	while (1) {
-		rc = msm_camera_io_r(vpe_device->vpebase + VPE_SW_RESET_OFFSET)
-				& 0x10;
-		if (rc == 0)
-			break;
-	}
-
-	/*  at this point, hardware is reset. Then pogram to default
-		values. */
-	msm_camera_io_w(VPE_AXI_RD_ARB_CONFIG_VALUE,
-			vpe_device->vpebase + VPE_AXI_RD_ARB_CONFIG_OFFSET);
-
-	msm_camera_io_w(VPE_CGC_ENABLE_VALUE,
-			vpe_device->vpebase + VPE_CGC_EN_OFFSET);
-
-	msm_camera_io_w(1, vpe_device->vpebase + VPE_CMD_MODE_OFFSET);
-
-	msm_camera_io_w(VPE_DEFAULT_OP_MODE_VALUE,
-			vpe_device->vpebase + VPE_OP_MODE_OFFSET);
-
-	msm_camera_io_w(VPE_DEFAULT_SCALE_CONFIG,
-			vpe_device->vpebase + VPE_SCALE_CONFIG_OFFSET);
-
-	vpe_config_axi_default();
-	return 0;
-}
-
-int msm_vpe_cfg_update(void *pinfo)
-{
-	uint32_t  rot_flag, rc = 0;
-	struct video_crop_t *pcrop = (struct video_crop_t *)pinfo;
-
-	rot_flag = msm_camera_io_r(vpe_device->vpebase +
-						VPE_OP_MODE_OFFSET) & 0xE00;
-	if (pinfo != NULL) {
-		CDBG("Crop info in2_w = %d, in2_h = %d "
-			"out2_h = %d out2_w = %d \n", pcrop->in2_w,
-			pcrop->in2_h,
-			pcrop->out2_h, pcrop->out2_w);
-		rc = vpe_update_scaler(pcrop);
-	}
-	CDBG("return rc = %d rot_flag = %d\n", rc, rot_flag);
-	rc |= rot_flag;
-
-	return rc;
-}
-
-void vpe_update_scale_coef(uint32_t *p)
-{
-	uint32_t i, offset;
-	offset = *p;
-	for (i = offset; i < (VPE_SCALE_COEFF_NUM + offset); i++) {
-		msm_camera_io_w(*(++p),
-			vpe_device->vpebase + VPE_SCALE_COEFF_LSBn(i));
-		msm_camera_io_w(*(++p),
-			vpe_device->vpebase + VPE_SCALE_COEFF_MSBn(i));
-	}
-}
-
-void vpe_input_plane_config(uint32_t *p)
-{
-	msm_camera_io_w(*p,
-		vpe_device->vpebase + VPE_SRC_FORMAT_OFFSET);
-	msm_camera_io_w(*(++p),
-		vpe_device->vpebase + VPE_SRC_UNPACK_PATTERN1_OFFSET);
-	msm_camera_io_w(*(++p),
-		vpe_device->vpebase + VPE_SRC_IMAGE_SIZE_OFFSET);
-	msm_camera_io_w(*(++p),
-		vpe_device->vpebase + VPE_SRC_YSTRIDE1_OFFSET);
-	msm_camera_io_w(*(++p),
-		vpe_device->vpebase + VPE_SRC_SIZE_OFFSET);
-	vpe_ctrl->in_h_w = *p;
-	msm_camera_io_w(*(++p),
-		vpe_device->vpebase + VPE_SRC_XY_OFFSET);
-}
-
-void vpe_output_plane_config(uint32_t *p)
-{
-	msm_camera_io_w(*p,
-		vpe_device->vpebase + VPE_OUT_FORMAT_OFFSET);
-	msm_camera_io_w(*(++p),
-		vpe_device->vpebase + VPE_OUT_PACK_PATTERN1_OFFSET);
-	msm_camera_io_w(*(++p),
-		vpe_device->vpebase + VPE_OUT_YSTRIDE1_OFFSET);
-	msm_camera_io_w(*(++p),
-		vpe_device->vpebase + VPE_OUT_SIZE_OFFSET);
-	msm_camera_io_w(*(++p),
-		vpe_device->vpebase + VPE_OUT_XY_OFFSET);
-	vpe_ctrl->pcbcr_dis_offset = *(++p);
-}
-
-static int vpe_operation_config(uint32_t *p)
-{
-	uint32_t  outw, outh, temp;
-	msm_camera_io_w(*p, vpe_device->vpebase + VPE_OP_MODE_OFFSET);
-
-	temp = msm_camera_io_r(vpe_device->vpebase + VPE_OUT_SIZE_OFFSET);
-	outw = temp & 0xFFF;
-	outh = (temp & 0xFFF0000) >> 16;
-
-	if (*p++ & 0xE00) {
-		/* rotation enabled. */
-		vpe_ctrl->out_w = outh;
-		vpe_ctrl->out_h = outw;
-	} else {
-		vpe_ctrl->out_w = outw;
-		vpe_ctrl->out_h = outh;
-	}
-	vpe_ctrl->dis_en = *p;
-	return 0;
-}
-
-/* Later we can separate the rotation and scaler calc. If
-*  rotation is enabled, simply swap the destination dimension.
-*  And then pass the already swapped output size to this
-*  function. */
-static int vpe_update_scaler(struct video_crop_t *pcrop)
-{
-	uint32_t out_ROI_width, out_ROI_height;
-	uint32_t src_ROI_width, src_ROI_height;
-
-	uint32_t rc = 0;  /* default to no zoom. */
-	/*
-	* phase_step_x, phase_step_y, phase_init_x and phase_init_y
-	* are represented in fixed-point, unsigned 3.29 format
-	*/
-	uint32_t phase_step_x = 0;
-	uint32_t phase_step_y = 0;
-	uint32_t phase_init_x = 0;
-	uint32_t phase_init_y = 0;
-
-	uint32_t src_roi, src_x, src_y, src_xy, temp;
-	uint32_t yscale_filter_sel, xscale_filter_sel;
-	uint32_t scale_unit_sel_x, scale_unit_sel_y;
-	uint64_t numerator, denominator;
-
-	if ((pcrop->in2_w >= pcrop->out2_w) &&
-		(pcrop->in2_h >= pcrop->out2_h)) {
-		CDBG(" =======VPE no zoom needed.\n");
-
-		temp = msm_camera_io_r(vpe_device->vpebase + VPE_OP_MODE_OFFSET)
-		& 0xfffffffc;
-		msm_camera_io_w(temp, vpe_device->vpebase + VPE_OP_MODE_OFFSET);
-
-
-		msm_camera_io_w(0, vpe_device->vpebase + VPE_SRC_XY_OFFSET);
-
-		CDBG("vpe_ctrl->in_h_w = %d\n", vpe_ctrl->in_h_w);
-		msm_camera_io_w(vpe_ctrl->in_h_w , vpe_device->vpebase +
-				VPE_SRC_SIZE_OFFSET);
-
-		return rc;
-	}
-	/* If fall through then scaler is needed.*/
-
-	CDBG("========VPE zoom needed.\n");
-	/* assumption is both direction need zoom. this can be
-	improved. */
-	temp =
-		msm_camera_io_r(vpe_device->vpebase + VPE_OP_MODE_OFFSET) | 0x3;
-	msm_camera_io_w(temp, vpe_device->vpebase + VPE_OP_MODE_OFFSET);
-
-	src_ROI_width = pcrop->in2_w;
-	src_ROI_height = pcrop->in2_h;
-	out_ROI_width = pcrop->out2_w;
-	out_ROI_height = pcrop->out2_h;
-
-	CDBG("src w = 0x%x, h=0x%x, dst w = 0x%x, h =0x%x.\n",
-		src_ROI_width, src_ROI_height, out_ROI_width,
-		out_ROI_height);
-	src_roi = (src_ROI_height << 16) + src_ROI_width;
-
-	msm_camera_io_w(src_roi, vpe_device->vpebase + VPE_SRC_SIZE_OFFSET);
-
-	src_x = (out_ROI_width - src_ROI_width)/2;
-	src_y = (out_ROI_height - src_ROI_height)/2;
-
-	CDBG("src_x = %d, src_y=%d.\n", src_x, src_y);
-
-	src_xy = src_y*(1<<16) + src_x;
-	msm_camera_io_w(src_xy, vpe_device->vpebase +
-			VPE_SRC_XY_OFFSET);
-	CDBG("src_xy = %d, src_roi=%d.\n", src_xy, src_roi);
-
-	/* decide whether to use FIR or M/N for scaling */
-	if ((out_ROI_width == 1 && src_ROI_width < 4) ||
-		(src_ROI_width < 4 * out_ROI_width - 3))
-		scale_unit_sel_x = 0;/* use FIR scalar */
-	else
-		scale_unit_sel_x = 1;/* use M/N scalar */
-
-	if ((out_ROI_height == 1 && src_ROI_height < 4) ||
-		(src_ROI_height < 4 * out_ROI_height - 3))
-		scale_unit_sel_y = 0;/* use FIR scalar */
-	else
-		scale_unit_sel_y = 1;/* use M/N scalar */
-
-	/* calculate phase step for the x direction */
-
-	/* if destination is only 1 pixel wide,
-	the value of phase_step_x
-	is unimportant. Assigning phase_step_x to
-	src ROI width as an arbitrary value. */
-	if (out_ROI_width == 1)
-		phase_step_x = (uint32_t) ((src_ROI_width) <<
-						SCALER_PHASE_BITS);
-
-		/* if using FIR scalar */
-	else if (scale_unit_sel_x == 0) {
-
-		/* Calculate the quotient ( src_ROI_width - 1 )
-		/ ( out_ROI_width - 1)
-		with u3.29 precision. Quotient is rounded up to
-		the larger 29th decimal point. */
-		numerator = (uint64_t)(src_ROI_width - 1) <<
-			SCALER_PHASE_BITS;
-		/* never equals to 0 because of the
-		"(out_ROI_width == 1 )"*/
-		denominator = (uint64_t)(out_ROI_width - 1);
-		/* divide and round up to the larger 29th
-		decimal point. */
-		phase_step_x = (uint32_t) vpe_do_div((numerator +
-					denominator - 1), denominator);
-	} else if (scale_unit_sel_x == 1) { /* if M/N scalar */
-		/* Calculate the quotient ( src_ROI_width ) /
-		( out_ROI_width)
-		with u3.29 precision. Quotient is rounded down to the
-		smaller 29th decimal point. */
-		numerator = (uint64_t)(src_ROI_width) <<
-			SCALER_PHASE_BITS;
-		denominator = (uint64_t)(out_ROI_width);
-		phase_step_x =
-			(uint32_t) vpe_do_div(numerator, denominator);
-	}
-	/* calculate phase step for the y direction */
-
-	/* if destination is only 1 pixel wide, the value of
-		phase_step_x is unimportant. Assigning phase_step_x
-		to src ROI width as an arbitrary value. */
-	if (out_ROI_height == 1)
-		phase_step_y =
-		(uint32_t) ((src_ROI_height) << SCALER_PHASE_BITS);
-
-	/* if FIR scalar */
-	else if (scale_unit_sel_y == 0) {
-		/* Calculate the quotient ( src_ROI_height - 1 ) /
-		( out_ROI_height - 1)
-		with u3.29 precision. Quotient is rounded up to the
-		larger 29th decimal point. */
-		numerator = (uint64_t)(src_ROI_height - 1) <<
-			SCALER_PHASE_BITS;
-		/* never equals to 0 because of the "
-		( out_ROI_height == 1 )" case */
-		denominator = (uint64_t)(out_ROI_height - 1);
-		/* Quotient is rounded up to the larger
-		29th decimal point. */
-		phase_step_y =
-		(uint32_t) vpe_do_div(
-			(numerator + denominator - 1), denominator);
-	} else if (scale_unit_sel_y == 1) { /* if M/N scalar */
-		/* Calculate the quotient ( src_ROI_height )
-		/ ( out_ROI_height)
-		with u3.29 precision. Quotient is rounded down
-		to the smaller 29th decimal point. */
-		numerator = (uint64_t)(src_ROI_height) <<
-			SCALER_PHASE_BITS;
-		denominator = (uint64_t)(out_ROI_height);
-		phase_step_y = (uint32_t) vpe_do_div(
-			numerator, denominator);
-	}
-
-	/* decide which set of FIR coefficients to use */
-	if (phase_step_x > HAL_MDP_PHASE_STEP_2P50)
-		xscale_filter_sel = 0;
-	else if (phase_step_x > HAL_MDP_PHASE_STEP_1P66)
-		xscale_filter_sel = 1;
-	else if (phase_step_x > HAL_MDP_PHASE_STEP_1P25)
-		xscale_filter_sel = 2;
-	else
-		xscale_filter_sel = 3;
-
-	if (phase_step_y > HAL_MDP_PHASE_STEP_2P50)
-		yscale_filter_sel = 0;
-	else if (phase_step_y > HAL_MDP_PHASE_STEP_1P66)
-		yscale_filter_sel = 1;
-	else if (phase_step_y > HAL_MDP_PHASE_STEP_1P25)
-		yscale_filter_sel = 2;
-	else
-		yscale_filter_sel = 3;
-
-	/* calculate phase init for the x direction */
-
-	/* if using FIR scalar */
-	if (scale_unit_sel_x == 0) {
-		if (out_ROI_width == 1)
-			phase_init_x =
-				(uint32_t) ((src_ROI_width - 1) <<
-							SCALER_PHASE_BITS);
-		else
-			phase_init_x = 0;
-	} else if (scale_unit_sel_x == 1) /* M over N scalar  */
-		phase_init_x = 0;
-
-	/* calculate phase init for the y direction
-	if using FIR scalar */
-	if (scale_unit_sel_y == 0) {
-		if (out_ROI_height == 1)
-			phase_init_y =
-			(uint32_t) ((src_ROI_height -
-						1) << SCALER_PHASE_BITS);
-		else
-			phase_init_y = 0;
-	} else if (scale_unit_sel_y == 1) /* M over N scalar   */
-		phase_init_y = 0;
-
-	CDBG("phase step x = %d, step y = %d.\n",
-		 phase_step_x, phase_step_y);
-	CDBG("phase init x = %d, init y = %d.\n",
-		 phase_init_x, phase_init_y);
-
-	msm_camera_io_w(phase_step_x, vpe_device->vpebase +
-			VPE_SCALE_PHASEX_STEP_OFFSET);
-	msm_camera_io_w(phase_step_y, vpe_device->vpebase +
-			VPE_SCALE_PHASEY_STEP_OFFSET);
-
-	msm_camera_io_w(phase_init_x, vpe_device->vpebase +
-			VPE_SCALE_PHASEX_INIT_OFFSET);
-
-	msm_camera_io_w(phase_init_y, vpe_device->vpebase +
-			VPE_SCALE_PHASEY_INIT_OFFSET);
-
-	return 1;
-}
-
-static int vpe_update_scaler_with_dis(struct video_crop_t *pcrop,
-				struct dis_offset_type *dis_offset)
-{
-	uint32_t out_ROI_width, out_ROI_height;
-	uint32_t src_ROI_width, src_ROI_height;
-
-	uint32_t rc = 0;  /* default to no zoom. */
-	/*
-	* phase_step_x, phase_step_y, phase_init_x and phase_init_y
-	* are represented in fixed-point, unsigned 3.29 format
-	*/
-	uint32_t phase_step_x = 0;
-	uint32_t phase_step_y = 0;
-	uint32_t phase_init_x = 0;
-	uint32_t phase_init_y = 0;
-
-	uint32_t src_roi, temp;
-	int32_t  src_x, src_y, src_xy;
-	uint32_t yscale_filter_sel, xscale_filter_sel;
-	uint32_t scale_unit_sel_x, scale_unit_sel_y;
-	uint64_t numerator, denominator;
-	int32_t  zoom_dis_x, zoom_dis_y;
-
-	CDBG("%s: pcrop->in2_w = %d, pcrop->in2_h = %d\n", __func__,
-		 pcrop->in2_w, pcrop->in2_h);
-	CDBG("%s: pcrop->out2_w = %d, pcrop->out2_h = %d\n", __func__,
-		 pcrop->out2_w, pcrop->out2_h);
-
-	if ((pcrop->in2_w >= pcrop->out2_w) &&
-		(pcrop->in2_h >= pcrop->out2_h)) {
-		CDBG(" =======VPE no zoom needed, DIS is still enabled.\n");
-
-		temp = msm_camera_io_r(vpe_device->vpebase + VPE_OP_MODE_OFFSET)
-		& 0xfffffffc;
-		msm_camera_io_w(temp, vpe_device->vpebase + VPE_OP_MODE_OFFSET);
-
-		/* no zoom, use dis offset directly. */
-		src_xy = dis_offset->dis_offset_y * (1<<16) +
-			dis_offset->dis_offset_x;
-
-		msm_camera_io_w(src_xy,
-			vpe_device->vpebase + VPE_SRC_XY_OFFSET);
-
-		CDBG("vpe_ctrl->in_h_w = 0x%x\n", vpe_ctrl->in_h_w);
-		msm_camera_io_w(vpe_ctrl->in_h_w,
-			vpe_device->vpebase + VPE_SRC_SIZE_OFFSET);
-		return rc;
-	}
-	/* If fall through then scaler is needed.*/
-
-	CDBG("========VPE zoom needed + DIS enabled.\n");
-	/* assumption is both direction need zoom. this can be
-	 improved. */
-	temp = msm_camera_io_r(vpe_device->vpebase +
-					VPE_OP_MODE_OFFSET) | 0x3;
-	msm_camera_io_w(temp, vpe_device->vpebase +
-			VPE_OP_MODE_OFFSET);
-	zoom_dis_x = dis_offset->dis_offset_x *
-		pcrop->in2_w / pcrop->out2_w;
-	zoom_dis_y = dis_offset->dis_offset_y *
-		pcrop->in2_h / pcrop->out2_h;
-
-	src_x = zoom_dis_x + (pcrop->out2_w-pcrop->in2_w)/2;
-	src_y = zoom_dis_y + (pcrop->out2_h-pcrop->in2_h)/2;
-
-	out_ROI_width = vpe_ctrl->out_w;
-	out_ROI_height = vpe_ctrl->out_h;
-
-	src_ROI_width = out_ROI_width * pcrop->in2_w / pcrop->out2_w;
-	src_ROI_height = out_ROI_height * pcrop->in2_h / pcrop->out2_h;
-
-	/* clamp to output size.  This is because along
-	processing, we mostly do truncation, therefore
-	dis_offset tends to be
-	smaller values.  The intention was to make sure that the
-	offset does not exceed margin.   But in the case it could
-	result src_roi bigger, due to subtract a smaller value. */
-	CDBG("src w = 0x%x, h=0x%x, dst w = 0x%x, h =0x%x.\n",
-		src_ROI_width, src_ROI_height, out_ROI_width,
-		out_ROI_height);
-
-	src_roi = (src_ROI_height << 16) + src_ROI_width;
-
-	msm_camera_io_w(src_roi, vpe_device->vpebase + VPE_SRC_SIZE_OFFSET);
-
-	CDBG("src_x = %d, src_y=%d.\n", src_x, src_y);
-
-	src_xy = src_y*(1<<16) + src_x;
-	msm_camera_io_w(src_xy, vpe_device->vpebase +
-			VPE_SRC_XY_OFFSET);
-	CDBG("src_xy = 0x%x, src_roi=0x%x.\n", src_xy, src_roi);
-
-	/* decide whether to use FIR or M/N for scaling */
-	if ((out_ROI_width == 1 && src_ROI_width < 4) ||
-		(src_ROI_width < 4 * out_ROI_width - 3))
-		scale_unit_sel_x = 0;/* use FIR scalar */
-	else
-		scale_unit_sel_x = 1;/* use M/N scalar */
-
-	if ((out_ROI_height == 1 && src_ROI_height < 4) ||
-		(src_ROI_height < 4 * out_ROI_height - 3))
-		scale_unit_sel_y = 0;/* use FIR scalar */
-	else
-		scale_unit_sel_y = 1;/* use M/N scalar */
-	/* calculate phase step for the x direction */
-
-	/* if destination is only 1 pixel wide, the value of
-	phase_step_x is unimportant. Assigning phase_step_x
-	to src ROI width as an arbitrary value. */
-	if (out_ROI_width == 1)
-		phase_step_x = (uint32_t) ((src_ROI_width) <<
-							SCALER_PHASE_BITS);
-	else if (scale_unit_sel_x == 0) { /* if using FIR scalar */
-		/* Calculate the quotient ( src_ROI_width - 1 )
-		/ ( out_ROI_width - 1)with u3.29 precision.
-		Quotient is rounded up to the larger
-		29th decimal point. */
-		numerator =
-			(uint64_t)(src_ROI_width - 1) <<
-			SCALER_PHASE_BITS;
-		/* never equals to 0 because of the "
-		(out_ROI_width == 1 )"*/
-		denominator = (uint64_t)(out_ROI_width - 1);
-		/* divide and round up to the larger 29th
-		decimal point. */
-		phase_step_x = (uint32_t) vpe_do_div(
-			(numerator + denominator - 1), denominator);
-	} else if (scale_unit_sel_x == 1) { /* if M/N scalar */
-		/* Calculate the quotient
-		( src_ROI_width ) / ( out_ROI_width)
-		with u3.29 precision. Quotient is rounded
-		down to the smaller 29th decimal point. */
-		numerator = (uint64_t)(src_ROI_width) <<
-			SCALER_PHASE_BITS;
-		denominator = (uint64_t)(out_ROI_width);
-		phase_step_x =
-			(uint32_t) vpe_do_div(numerator, denominator);
-	}
-	/* calculate phase step for the y direction */
-
-	/* if destination is only 1 pixel wide, the value of
-		phase_step_x is unimportant. Assigning phase_step_x
-		to src ROI width as an arbitrary value. */
-	if (out_ROI_height == 1)
-		phase_step_y =
-		(uint32_t) ((src_ROI_height) << SCALER_PHASE_BITS);
-	else if (scale_unit_sel_y == 0) { /* if FIR scalar */
-		/* Calculate the quotient
-		( src_ROI_height - 1 ) / ( out_ROI_height - 1)
-		with u3.29 precision. Quotient is rounded up to the
-		larger 29th decimal point. */
-		numerator = (uint64_t)(src_ROI_height - 1) <<
-			SCALER_PHASE_BITS;
-		/* never equals to 0 because of the
-		"( out_ROI_height == 1 )" case */
-		denominator = (uint64_t)(out_ROI_height - 1);
-		/* Quotient is rounded up to the larger 29th
-		decimal point. */
-		phase_step_y =
-		(uint32_t) vpe_do_div(
-		(numerator + denominator - 1), denominator);
-	} else if (scale_unit_sel_y == 1) { /* if M/N scalar */
-		/* Calculate the quotient ( src_ROI_height ) / ( out_ROI_height)
-		with u3.29 precision. Quotient is rounded down to the smaller
-		29th decimal point. */
-		numerator = (uint64_t)(src_ROI_height) <<
-			SCALER_PHASE_BITS;
-		denominator = (uint64_t)(out_ROI_height);
-		phase_step_y = (uint32_t) vpe_do_div(
-			numerator, denominator);
-	}
-
-	/* decide which set of FIR coefficients to use */
-	if (phase_step_x > HAL_MDP_PHASE_STEP_2P50)
-		xscale_filter_sel = 0;
-	else if (phase_step_x > HAL_MDP_PHASE_STEP_1P66)
-		xscale_filter_sel = 1;
-	else if (phase_step_x > HAL_MDP_PHASE_STEP_1P25)
-		xscale_filter_sel = 2;
-	else
-		xscale_filter_sel = 3;
-
-	if (phase_step_y > HAL_MDP_PHASE_STEP_2P50)
-		yscale_filter_sel = 0;
-	else if (phase_step_y > HAL_MDP_PHASE_STEP_1P66)
-		yscale_filter_sel = 1;
-	else if (phase_step_y > HAL_MDP_PHASE_STEP_1P25)
-		yscale_filter_sel = 2;
-	else
-		yscale_filter_sel = 3;
-
-	/* calculate phase init for the x direction */
-
-	/* if using FIR scalar */
-	if (scale_unit_sel_x == 0) {
-		if (out_ROI_width == 1)
-			phase_init_x =
-			(uint32_t) ((src_ROI_width - 1) <<
-						SCALER_PHASE_BITS);
-		else
-			phase_init_x = 0;
-
-	} else if (scale_unit_sel_x == 1) /* M over N scalar  */
-		phase_init_x = 0;
-
-	/* calculate phase init for the y direction
-	if using FIR scalar */
-	if (scale_unit_sel_y == 0) {
-		if (out_ROI_height == 1)
-			phase_init_y =
-			(uint32_t) ((src_ROI_height -
-						1) << SCALER_PHASE_BITS);
-		else
-			phase_init_y = 0;
-
-	} else if (scale_unit_sel_y == 1) /* M over N scalar   */
-		phase_init_y = 0;
-
-	CDBG("phase step x = %d, step y = %d.\n",
-		phase_step_x, phase_step_y);
-	CDBG("phase init x = %d, init y = %d.\n",
-		phase_init_x, phase_init_y);
-
-	msm_camera_io_w(phase_step_x, vpe_device->vpebase +
-			VPE_SCALE_PHASEX_STEP_OFFSET);
-
-	msm_camera_io_w(phase_step_y, vpe_device->vpebase +
-			VPE_SCALE_PHASEY_STEP_OFFSET);
-
-	msm_camera_io_w(phase_init_x, vpe_device->vpebase +
-			VPE_SCALE_PHASEX_INIT_OFFSET);
-
-	msm_camera_io_w(phase_init_y, vpe_device->vpebase +
-			VPE_SCALE_PHASEY_INIT_OFFSET);
-
-	return 1;
-}
-
-void msm_send_frame_to_vpe(uint32_t p0_phy_add, uint32_t p1_phy_add,
-		struct timespec *ts, int output_type)
-{
-	uint32_t temp_pyaddr = 0, temp_pcbcraddr = 0;
-
-	CDBG("vpe input, p0_phy_add = 0x%x, p1_phy_add = 0x%x\n",
-		p0_phy_add, p1_phy_add);
-	msm_camera_io_w(p0_phy_add,
-		vpe_device->vpebase + VPE_SRCP0_ADDR_OFFSET);
-	msm_camera_io_w(p1_phy_add,
-		vpe_device->vpebase + VPE_SRCP1_ADDR_OFFSET);
-
-	if (vpe_ctrl->state == VPE_STATE_ACTIVE)
-		CDBG(" =====VPE is busy!!!  Wrong!========\n");
-
-	if (output_type != OUTPUT_TYPE_ST_R)
-		vpe_ctrl->ts = *ts;
-
-	if (output_type == OUTPUT_TYPE_ST_L) {
-		vpe_ctrl->pcbcr_before_dis =
-			msm_camera_io_r(vpe_device->vpebase +
-			VPE_OUTP1_ADDR_OFFSET);
-		temp_pyaddr = msm_camera_io_r(vpe_device->vpebase +
-			VPE_OUTP0_ADDR_OFFSET);
-		temp_pcbcraddr = temp_pyaddr + PAD_TO_2K(vpe_ctrl->out_w *
-			vpe_ctrl->out_h * 2, vpe_ctrl->pad_2k_bool);
-		msm_camera_io_w(temp_pcbcraddr, vpe_device->vpebase +
-			VPE_OUTP1_ADDR_OFFSET);
-	}
-
-	if (vpe_ctrl->dis_en) {
-		/* Changing the VPE output CBCR address,
-		to make Y/CBCR continuous */
-		vpe_ctrl->pcbcr_before_dis =
-			msm_camera_io_r(vpe_device->vpebase +
-			VPE_OUTP1_ADDR_OFFSET);
-		temp_pyaddr = msm_camera_io_r(vpe_device->vpebase +
-			VPE_OUTP0_ADDR_OFFSET);
-		temp_pcbcraddr = temp_pyaddr + vpe_ctrl->pcbcr_dis_offset;
-		msm_camera_io_w(temp_pcbcraddr, vpe_device->vpebase +
-			VPE_OUTP1_ADDR_OFFSET);
-	}
-
-	vpe_ctrl->output_type = output_type;
-	vpe_ctrl->state = VPE_STATE_ACTIVE;
-	vpe_start();
-}
-
-static int vpe_proc_general(struct msm_vpe_cmd *cmd)
-{
-	int rc = 0;
-	uint32_t *cmdp = NULL;
-	struct msm_queue_cmd *qcmd = NULL;
-	struct msm_vpe_buf_info *vpe_buf;
-	int turbo_mode = 0;
-	struct msm_sync *sync = (struct msm_sync *)vpe_ctrl->syncdata;
-	CDBG("vpe_proc_general: cmdID = %s, length = %d\n",
-		vpe_general_cmd[cmd->id], cmd->length);
-	switch (cmd->id) {
-	case VPE_ENABLE:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto vpe_proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto vpe_proc_general_done;
-		}
-		turbo_mode = *((int *)(cmd->value));
-		rc = turbo_mode ? vpe_enable(VPE_TURBO_MODE_CLOCK_RATE)
-			: vpe_enable(VPE_NORMAL_MODE_CLOCK_RATE);
-		break;
-	case VPE_DISABLE:
-		rc = vpe_disable();
-		break;
-	case VPE_RESET:
-	case VPE_ABORT:
-		rc = vpe_reset();
-		break;
-	case VPE_START:
-		rc = vpe_start();
-		break;
-
-	case VPE_INPUT_PLANE_CFG:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto vpe_proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto vpe_proc_general_done;
-		}
-		vpe_input_plane_config(cmdp);
-		break;
-
-	case VPE_OPERATION_MODE_CFG:
-		CDBG("cmd->length = %d \n", cmd->length);
-		if (cmd->length != VPE_OPERATION_MODE_CFG_LEN) {
-			rc = -EINVAL;
-			goto vpe_proc_general_done;
-		}
-		cmdp = kmalloc(VPE_OPERATION_MODE_CFG_LEN,
-					GFP_ATOMIC);
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			VPE_OPERATION_MODE_CFG_LEN)) {
-			rc = -EFAULT;
-			goto vpe_proc_general_done;
-		}
-		rc = vpe_operation_config(cmdp);
-		CDBG("rc = %d \n", rc);
-		break;
-
-	case VPE_OUTPUT_PLANE_CFG:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto vpe_proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto vpe_proc_general_done;
-		}
-		vpe_output_plane_config(cmdp);
-		break;
-
-	case VPE_SCALE_CFG_TYPE:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto vpe_proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto vpe_proc_general_done;
-		}
-		vpe_update_scale_coef(cmdp);
-		break;
-
-	case VPE_CMD_DIS_OFFSET_CFG: {
-		struct msm_vfe_resp *vdata;
-		/* first get the dis offset and frame id. */
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto vpe_proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto vpe_proc_general_done;
-		}
-		/* get the offset. */
-		vpe_ctrl->dis_offset = *(struct dis_offset_type *)cmdp;
-		qcmd = msm_dequeue_vpe(&sync->vpe_q, list_vpe_frame);
-		if (!qcmd) {
-			pr_err("%s: no video frame.\n", __func__);
-			kfree(cmdp);
-			return -EAGAIN;
-		}
-		vdata = (struct msm_vfe_resp *)(qcmd->command);
-		vpe_buf = &vdata->vpe_bf;
-		vpe_update_scaler_with_dis(&(vpe_buf->vpe_crop),
-					&(vpe_ctrl->dis_offset));
-
-		msm_send_frame_to_vpe(vpe_buf->p0_phy, vpe_buf->p1_phy,
-						&(vpe_buf->ts), OUTPUT_TYPE_V);
-
-		if (!qcmd || !atomic_read(&qcmd->on_heap)) {
-			kfree(cmdp);
-			return -EAGAIN;
-		}
-		if (!atomic_sub_return(1, &qcmd->on_heap))
-			kfree(qcmd);
-		break;
-	}
-
-	default:
-		break;
-	}
-vpe_proc_general_done:
-	kfree(cmdp);
-	return rc;
-}
-
-static void vpe_addr_convert(struct msm_vpe_phy_info *pinfo,
-	enum vpe_resp_msg type, void *data, void **ext, int32_t *elen)
-{
-	CDBG("In vpe_addr_convert type = %d\n", type);
-	switch (type) {
-	case VPE_MSG_OUTPUT_V:
-		pinfo->output_id = OUTPUT_TYPE_V;
-		break;
-	case VPE_MSG_OUTPUT_ST_R:
-		/* output_id will be used by user space only. */
-		pinfo->output_id = OUTPUT_TYPE_V;
-		break;
-	default:
-		break;
-	} /* switch */
-
-	CDBG("In vpe_addr_convert output_id = %d\n", pinfo->output_id);
-
-	pinfo->p0_phy =
-		((struct vpe_message *)data)->_u.msgOut.p0_Buffer;
-	pinfo->p1_phy =
-		((struct vpe_message *)data)->_u.msgOut.p1_Buffer;
-	*ext  = vpe_ctrl->extdata;
-	*elen = vpe_ctrl->extlen;
-}
-
-void vpe_proc_ops(uint8_t id, void *msg, size_t len)
-{
-	struct msm_vpe_resp *rp;
-
-	rp = vpe_ctrl->resp->vpe_alloc(sizeof(struct msm_vpe_resp),
-		vpe_ctrl->syncdata, GFP_ATOMIC);
-	if (!rp) {
-		CDBG("rp: cannot allocate buffer\n");
-		return;
-	}
-
-	CDBG("vpe_proc_ops, msgId = %d rp->evt_msg.msg_id = %d\n",
-		id, rp->evt_msg.msg_id);
-	rp->evt_msg.type   = MSM_CAMERA_MSG;
-	rp->evt_msg.msg_id = id;
-	rp->evt_msg.len    = len;
-	rp->evt_msg.data   = msg;
-
-	switch (rp->evt_msg.msg_id) {
-	case MSG_ID_VPE_OUTPUT_V:
-		rp->type = VPE_MSG_OUTPUT_V;
-		vpe_addr_convert(&(rp->phy), VPE_MSG_OUTPUT_V,
-			rp->evt_msg.data, &(rp->extdata),
-			&(rp->extlen));
-		break;
-
-	case MSG_ID_VPE_OUTPUT_ST_R:
-		rp->type = VPE_MSG_OUTPUT_ST_R;
-		vpe_addr_convert(&(rp->phy), VPE_MSG_OUTPUT_ST_R,
-			rp->evt_msg.data, &(rp->extdata),
-			&(rp->extlen));
-		break;
-
-	case MSG_ID_VPE_OUTPUT_ST_L:
-		rp->type = VPE_MSG_OUTPUT_ST_L;
-		break;
-
-	default:
-		rp->type = VPE_MSG_GENERAL;
-		break;
-	}
-	CDBG("%s: time = %ld\n",
-			__func__, vpe_ctrl->ts.tv_nsec);
-
-	vpe_ctrl->resp->vpe_resp(rp, MSM_CAM_Q_VPE_MSG,
-					vpe_ctrl->syncdata,
-					&(vpe_ctrl->ts), GFP_ATOMIC);
-}
-
-int vpe_config_axi(struct axidata *ad)
-{
-	uint32_t p1;
-	struct msm_pmem_region *regp1 = NULL;
-	CDBG("vpe_config_axi:bufnum1 = %d.\n", ad->bufnum1);
-
-	if (ad->bufnum1 != 1)
-		return -EINVAL;
-
-	regp1 = &(ad->region[0]);
-	/* for video  Y address */
-	p1 = (regp1->paddr + regp1->info.planar0_off);
-	msm_camera_io_w(p1, vpe_device->vpebase + VPE_OUTP0_ADDR_OFFSET);
-	/* for video  CbCr address */
-	p1 = (regp1->paddr + regp1->info.planar1_off);
-	msm_camera_io_w(p1, vpe_device->vpebase + VPE_OUTP1_ADDR_OFFSET);
-
-	return 0;
-}
-
-int msm_vpe_config(struct msm_vpe_cfg_cmd *cmd, void *data)
-{
-	struct msm_vpe_cmd vpecmd;
-	int rc = 0;
-	if (copy_from_user(&vpecmd,
-			(void __user *)(cmd->value),
-			sizeof(vpecmd))) {
-		pr_err("%s %d: copy_from_user failed\n", __func__,
-				__LINE__);
-		return -EFAULT;
-	}
-	CDBG("%s: cmd_type %d\n", __func__, cmd->cmd_type);
-	switch (cmd->cmd_type) {
-	case CMD_VPE:
-		rc = vpe_proc_general(&vpecmd);
-		CDBG(" rc = %d\n", rc);
-		break;
-
-	case CMD_AXI_CFG_VPE:
-	case CMD_AXI_CFG_SNAP_VPE:
-	case CMD_AXI_CFG_SNAP_THUMB_VPE: {
-		struct axidata *axid;
-		axid = data;
-		if (!axid)
-			return -EFAULT;
-		vpe_config_axi(axid);
-		break;
-	}
-	default:
-		break;
-	}
-	CDBG("%s: rc = %d\n", __func__, rc);
-	return rc;
-}
-
-void msm_vpe_offset_update(int frame_pack, uint32_t pyaddr, uint32_t pcbcraddr,
-	struct timespec *ts, int output_id, struct msm_st_half st_half,
-	int frameid)
-{
-	struct msm_vpe_buf_info vpe_buf;
-	uint32_t input_stride;
-
-	vpe_buf.vpe_crop.in2_w = st_half.stCropInfo.in_w;
-	vpe_buf.vpe_crop.in2_h = st_half.stCropInfo.in_h;
-	vpe_buf.vpe_crop.out2_w = st_half.stCropInfo.out_w;
-	vpe_buf.vpe_crop.out2_h = st_half.stCropInfo.out_h;
-	vpe_ctrl->dis_offset.dis_offset_x = st_half.pix_x_off;
-	vpe_ctrl->dis_offset.dis_offset_y = st_half.pix_y_off;
-	vpe_ctrl->dis_offset.frame_id = frameid;
-	vpe_ctrl->frame_pack = frame_pack;
-	vpe_ctrl->output_type = output_id;
-
-	input_stride = (st_half.buf_p1_stride * (1<<16)) +
-		st_half.buf_p0_stride;
-
-	msm_camera_io_w(input_stride,
-		vpe_device->vpebase + VPE_SRC_YSTRIDE1_OFFSET);
-
-	vpe_update_scaler_with_dis(&(vpe_buf.vpe_crop),
-		&(vpe_ctrl->dis_offset));
-
-	msm_send_frame_to_vpe(pyaddr, pcbcraddr, ts, output_id);
-}
-
-static void vpe_send_outmsg(uint8_t msgid, uint32_t p0_addr,
-	uint32_t p1_addr, uint32_t p2_addr)
-{
-	struct vpe_message msg;
-	uint8_t outid;
-	msg._d = outid = msgid;
-	msg._u.msgOut.output_id   = msgid;
-	msg._u.msgOut.p0_Buffer = p0_addr;
-	msg._u.msgOut.p1_Buffer = p1_addr;
-	msg._u.msgOut.p2_Buffer = p2_addr;
-	vpe_proc_ops(outid, &msg, sizeof(struct vpe_message));
-	return;
-}
-
-int msm_vpe_reg(struct msm_vpe_callback *presp)
-{
-	if (presp && presp->vpe_resp)
-		vpe_ctrl->resp = presp;
-
-	return 0;
-}
-
-static void vpe_send_msg_no_payload(enum VPE_MESSAGE_ID id)
-{
-	struct vpe_message msg;
-
-	CDBG("vfe31_send_msg_no_payload\n");
-	msg._d = id;
-	vpe_proc_ops(id, &msg, 0);
-}
-
-static void vpe_do_tasklet(unsigned long data)
-{
-	unsigned long flags;
-	uint32_t pyaddr = 0, pcbcraddr = 0;
-	uint32_t src_y, src_cbcr, temp;
-
-	struct vpe_isr_queue_cmd_type *qcmd = NULL;
-
-	CDBG("=== vpe_do_tasklet start === \n");
-
-	spin_lock_irqsave(&vpe_ctrl->tasklet_lock, flags);
-	qcmd = list_first_entry(&vpe_ctrl->tasklet_q,
-		struct vpe_isr_queue_cmd_type, list);
-
-	if (!qcmd) {
-		spin_unlock_irqrestore(&vpe_ctrl->tasklet_lock, flags);
-		return;
-	}
-
-	list_del(&qcmd->list);
-	spin_unlock_irqrestore(&vpe_ctrl->tasklet_lock, flags);
-
-	/* interrupt to be processed,  *qcmd has the payload.  */
-	if (qcmd->irq_status & 0x1) {
-		if (vpe_ctrl->output_type == OUTPUT_TYPE_ST_L) {
-			CDBG("vpe left frame done.\n");
-			vpe_ctrl->output_type = 0;
-			CDBG("vpe send out msg.\n");
-			orig_src_y = msm_camera_io_r(vpe_device->vpebase +
-				VPE_SRCP0_ADDR_OFFSET);
-			orig_src_cbcr = msm_camera_io_r(vpe_device->vpebase +
-				VPE_SRCP1_ADDR_OFFSET);
-
-			pyaddr = msm_camera_io_r(vpe_device->vpebase +
-				VPE_OUTP0_ADDR_OFFSET);
-			pcbcraddr = msm_camera_io_r(vpe_device->vpebase +
-				VPE_OUTP1_ADDR_OFFSET);
-			CDBG("%s: out_w = %d, out_h = %d\n", __func__,
-				vpe_ctrl->out_w, vpe_ctrl->out_h);
-
-			if ((vpe_ctrl->frame_pack == TOP_DOWN_FULL) ||
-				(vpe_ctrl->frame_pack == TOP_DOWN_HALF)) {
-				msm_camera_io_w(pyaddr + (vpe_ctrl->out_w *
-					vpe_ctrl->out_h), vpe_device->vpebase +
-					VPE_OUTP0_ADDR_OFFSET);
-				msm_camera_io_w(pcbcraddr + (vpe_ctrl->out_w *
-					vpe_ctrl->out_h/2),
-					vpe_device->vpebase +
-					VPE_OUTP1_ADDR_OFFSET);
-			} else if ((vpe_ctrl->frame_pack ==
-				SIDE_BY_SIDE_HALF) || (vpe_ctrl->frame_pack ==
-				SIDE_BY_SIDE_FULL)) {
-				msm_camera_io_w(pyaddr + vpe_ctrl->out_w,
-					vpe_device->vpebase +
-					VPE_OUTP0_ADDR_OFFSET);
-				msm_camera_io_w(pcbcraddr + vpe_ctrl->out_w,
-					vpe_device->vpebase +
-					VPE_OUTP1_ADDR_OFFSET);
-			} else
-				CDBG("%s: Invalid packing = %d\n", __func__,
-					vpe_ctrl->frame_pack);
-
-			vpe_send_msg_no_payload(MSG_ID_VPE_OUTPUT_ST_L);
-			vpe_ctrl->state = VPE_STATE_INIT;
-			kfree(qcmd);
-			return;
-		} else if (vpe_ctrl->output_type == OUTPUT_TYPE_ST_R) {
-			src_y = orig_src_y;
-			src_cbcr = orig_src_cbcr;
-			CDBG("%s: out_w = %d, out_h = %d\n", __func__,
-				vpe_ctrl->out_w, vpe_ctrl->out_h);
-
-			if ((vpe_ctrl->frame_pack == TOP_DOWN_FULL) ||
-				(vpe_ctrl->frame_pack == TOP_DOWN_HALF)) {
-				pyaddr = msm_camera_io_r(vpe_device->vpebase +
-					VPE_OUTP0_ADDR_OFFSET) -
-					(vpe_ctrl->out_w * vpe_ctrl->out_h);
-			} else if ((vpe_ctrl->frame_pack ==
-				SIDE_BY_SIDE_HALF) || (vpe_ctrl->frame_pack ==
-				SIDE_BY_SIDE_FULL)) {
-				pyaddr = msm_camera_io_r(vpe_device->vpebase +
-				VPE_OUTP0_ADDR_OFFSET) - vpe_ctrl->out_w;
-			} else
-				CDBG("%s: Invalid packing = %d\n", __func__,
-					vpe_ctrl->frame_pack);
-
-			pcbcraddr = vpe_ctrl->pcbcr_before_dis;
-		} else {
-			src_y =	msm_camera_io_r(vpe_device->vpebase +
-				VPE_SRCP0_ADDR_OFFSET);
-			src_cbcr = msm_camera_io_r(vpe_device->vpebase +
-				VPE_SRCP1_ADDR_OFFSET);
-			pyaddr = msm_camera_io_r(vpe_device->vpebase +
-				VPE_OUTP0_ADDR_OFFSET);
-			pcbcraddr = msm_camera_io_r(vpe_device->vpebase +
-				VPE_OUTP1_ADDR_OFFSET);
-		}
-
-		if (vpe_ctrl->dis_en)
-			pcbcraddr = vpe_ctrl->pcbcr_before_dis;
-
-		msm_camera_io_w(src_y,
-				vpe_device->vpebase + VPE_OUTP0_ADDR_OFFSET);
-		msm_camera_io_w(src_cbcr,
-				vpe_device->vpebase + VPE_OUTP1_ADDR_OFFSET);
-
-		temp = msm_camera_io_r(vpe_device->vpebase + VPE_OP_MODE_OFFSET)
-				& 0xFFFFFFFC;
-		msm_camera_io_w(temp, vpe_device->vpebase + VPE_OP_MODE_OFFSET);
-
-		/*  now pass this frame to msm_camera.c. */
-		if (vpe_ctrl->output_type == OUTPUT_TYPE_ST_R) {
-			CDBG("vpe send out R msg.\n");
-			vpe_send_outmsg(MSG_ID_VPE_OUTPUT_ST_R, pyaddr,
-				pcbcraddr, pyaddr);
-		} else if (vpe_ctrl->output_type == OUTPUT_TYPE_V) {
-			CDBG("vpe send out V msg.\n");
-			vpe_send_outmsg(MSG_ID_VPE_OUTPUT_V, pyaddr,
-				pcbcraddr, pyaddr);
-		}
-
-		vpe_ctrl->output_type = 0;
-		vpe_ctrl->state = VPE_STATE_INIT;   /* put it back to idle. */
-
-	}
-	kfree(qcmd);
-}
-DECLARE_TASKLET(vpe_tasklet, vpe_do_tasklet, 0);
-
-static irqreturn_t vpe_parse_irq(int irq_num, void *data)
-{
-	unsigned long flags;
-	uint32_t irq_status = 0;
-	struct vpe_isr_queue_cmd_type *qcmd;
-
-	CDBG("vpe_parse_irq.\n");
-	/* read and clear back-to-back. */
-	irq_status = msm_camera_io_r_mb(vpe_device->vpebase +
-							VPE_INTR_STATUS_OFFSET);
-	msm_camera_io_w_mb(irq_status, vpe_device->vpebase +
-				VPE_INTR_CLEAR_OFFSET);
-
-	msm_camera_io_w(0, vpe_device->vpebase + VPE_INTR_ENABLE_OFFSET);
-
-	if (irq_status == 0) {
-		pr_err("%s: irq_status = 0,Something is wrong!\n", __func__);
-		return IRQ_HANDLED;
-	}
-	irq_status &= 0x1;
-	/* apply mask. only interested in bit 0.  */
-	if (irq_status) {
-		qcmd = kzalloc(sizeof(struct vpe_isr_queue_cmd_type),
-			GFP_ATOMIC);
-		if (!qcmd) {
-			pr_err("%s: qcmd malloc failed!\n", __func__);
-			return IRQ_HANDLED;
-		}
-		/* must be 0x1 now. so in bottom half we don't really
-		need to check. */
-		qcmd->irq_status = irq_status & 0x1;
-		spin_lock_irqsave(&vpe_ctrl->tasklet_lock, flags);
-		list_add_tail(&qcmd->list, &vpe_ctrl->tasklet_q);
-		spin_unlock_irqrestore(&vpe_ctrl->tasklet_lock, flags);
-		tasklet_schedule(&vpe_tasklet);
-	}
-	return IRQ_HANDLED;
-}
-
-static int vpe_enable_irq(void)
-{
-	uint32_t   rc = 0;
-	rc = request_irq(vpe_device->vpeirq,
-				vpe_parse_irq,
-				IRQF_TRIGGER_HIGH, "vpe", 0);
-	return rc;
-}
-
-int msm_vpe_open(void)
-{
-	int rc = 0;
-
-	CDBG("%s: In \n", __func__);
-
-	vpe_ctrl = kzalloc(sizeof(struct vpe_ctrl_type), GFP_KERNEL);
-	if (!vpe_ctrl) {
-		pr_err("%s: no memory!\n", __func__);
-		return -ENOMEM;
-	}
-
-	spin_lock_init(&vpe_ctrl->ops_lock);
-	CDBG("%s: Out\n", __func__);
-
-	return rc;
-}
-
-int msm_vpe_release(void)
-{
-	/* clean up....*/
-	int rc = 0;
-	CDBG("%s: state %d\n", __func__, vpe_ctrl->state);
-	if (vpe_ctrl->state != VPE_STATE_IDLE)
-		rc = vpe_disable();
-
-	kfree(vpe_ctrl);
-	return rc;
-}
-
-
-int vpe_enable(uint32_t clk_rate)
-{
-	int rc = 0;
-	unsigned long flags = 0;
-	/* don't change the order of clock and irq.*/
-	CDBG("%s: enable_clock rate %u\n", __func__, clk_rate);
-	spin_lock_irqsave(&vpe_ctrl->ops_lock, flags);
-	if (vpe_ctrl->state != VPE_STATE_IDLE) {
-		CDBG("%s: VPE already enabled", __func__);
-		spin_unlock_irqrestore(&vpe_ctrl->ops_lock, flags);
-		return 0;
-	}
-	vpe_ctrl->state = VPE_STATE_INIT;
-	spin_unlock_irqrestore(&vpe_ctrl->ops_lock, flags);
-
-	rc = msm_camio_vpe_clk_enable(clk_rate);
-	if (rc < 0) {
-		pr_err("%s: msm_camio_vpe_clk_enable failed", __func__);
-		vpe_ctrl->state = VPE_STATE_IDLE;
-		return rc;
-	}
-
-	CDBG("%s: enable_irq\n", __func__);
-	vpe_enable_irq();
-
-	/* initialize the data structure - lock, queue etc. */
-	spin_lock_init(&vpe_ctrl->tasklet_lock);
-	INIT_LIST_HEAD(&vpe_ctrl->tasklet_q);
-
-	return rc;
-}
-
-int vpe_disable(void)
-{
-	int rc = 0;
-	unsigned long flags = 0;
-	CDBG("%s: called", __func__);
-	spin_lock_irqsave(&vpe_ctrl->ops_lock, flags);
-	if (vpe_ctrl->state == VPE_STATE_IDLE) {
-		CDBG("%s: VPE already disabled", __func__);
-		spin_unlock_irqrestore(&vpe_ctrl->ops_lock, flags);
-		return 0;
-	}
-	vpe_ctrl->state = VPE_STATE_IDLE;
-	spin_unlock_irqrestore(&vpe_ctrl->ops_lock, flags);
-	vpe_ctrl->out_y_addr = msm_camera_io_r(vpe_device->vpebase +
-		VPE_OUTP0_ADDR_OFFSET);
-	vpe_ctrl->out_cbcr_addr = msm_camera_io_r(vpe_device->vpebase +
-		VPE_OUTP1_ADDR_OFFSET);
-	free_irq(vpe_device->vpeirq, 0);
-	tasklet_kill(&vpe_tasklet);
-	rc = msm_camio_vpe_clk_disable();
-	return rc;
-}
-
-static int __msm_vpe_probe(struct platform_device *pdev)
-{
-	int rc = 0;
-	struct resource   *vpemem, *vpeirq, *vpeio;
-	void __iomem      *vpebase;
-
-	/* first allocate */
-
-	vpe_device = &vpe_device_data;
-	memset(vpe_device, 0, sizeof(struct vpe_device_type));
-
-	/* does the device exist? */
-	vpeirq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	if (!vpeirq) {
-		pr_err("%s: no vpe irq resource.\n", __func__);
-		rc = -ENODEV;
-		goto vpe_free_device;
-	}
-	vpemem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!vpemem) {
-		pr_err("%s: no vpe mem resource!\n", __func__);
-		rc = -ENODEV;
-		goto vpe_free_device;
-	}
-	vpeio = request_mem_region(vpemem->start,
-			resource_size(vpemem), pdev->name);
-	if (!vpeio) {
-		pr_err("%s: VPE region already claimed.\n", __func__);
-		rc = -EBUSY;
-		goto vpe_free_device;
-	}
-
-	vpebase =
-		ioremap(vpemem->start,
-				(vpemem->end - vpemem->start) + 1);
-	if (!vpebase) {
-		pr_err("%s: vpe ioremap failed.\n", __func__);
-		rc = -ENOMEM;
-		goto vpe_release_mem_region;
-	}
-
-	/* Fall through, _probe is successful. */
-	vpe_device->vpeirq = vpeirq->start;
-	vpe_device->vpemem = vpemem;
-	vpe_device->vpeio = vpeio;
-	vpe_device->vpebase = vpebase;
-	return rc;  /* this rc should be zero.*/
-
-	iounmap(vpe_device->vpebase);  /* this path should never occur */
-	vpe_device->vpebase = NULL;
-/* from this part it is error handling. */
-vpe_release_mem_region:
-	release_mem_region(vpemem->start, (vpemem->end - vpemem->start) + 1);
-vpe_free_device:
-	return rc;  /* this rc should have error code. */
-}
-
-static int __msm_vpe_remove(struct platform_device *pdev)
-{
-	struct resource	*vpemem;
-	vpemem = vpe_device->vpemem;
-
-	iounmap(vpe_device->vpebase);
-	vpe_device->vpebase = NULL;
-	release_mem_region(vpemem->start,
-					(vpemem->end - vpemem->start) + 1);
-	return 0;
-}
-
-static struct platform_driver msm_vpe_driver = {
-	.probe = __msm_vpe_probe,
-	.remove = __msm_vpe_remove,
-	.driver = {
-		.name = "msm_vpe",
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init msm_vpe_init(void)
-{
-	return platform_driver_register(&msm_vpe_driver);
-}
-module_init(msm_vpe_init);
-
-static void __exit msm_vpe_exit(void)
-{
-	platform_driver_unregister(&msm_vpe_driver);
-}
-module_exit(msm_vpe_exit);
-
-MODULE_DESCRIPTION("msm vpe 1.0 driver");
-MODULE_VERSION("msm vpe driver 1.0");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/msm_vpe1.h b/drivers/media/platform/msm/camera_v1/msm_vpe1.h
deleted file mode 100644
index 5fd7a4a..0000000
--- a/drivers/media/platform/msm/camera_v1/msm_vpe1.h
+++ /dev/null
@@ -1,254 +0,0 @@
-/* Copyright (c) 2010, 2012, The Linux Foundation. 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.
- */
-
-#ifndef _msm_vpe1_h_
-#define _msm_vpe1_h_
-
-#include <mach/camera.h>
-
-/***********  start of register offset *********************/
-#define VPE_INTR_ENABLE_OFFSET                0x0020
-#define VPE_INTR_STATUS_OFFSET                0x0024
-#define VPE_INTR_CLEAR_OFFSET                 0x0028
-#define VPE_DL0_START_OFFSET                  0x0030
-#define VPE_HW_VERSION_OFFSET                 0x0070
-#define VPE_SW_RESET_OFFSET                   0x0074
-#define VPE_AXI_RD_ARB_CONFIG_OFFSET          0x0078
-#define VPE_SEL_CLK_OR_HCLK_TEST_BUS_OFFSET   0x007C
-#define VPE_CGC_EN_OFFSET                     0x0100
-#define VPE_CMD_STATUS_OFFSET                 0x10008
-#define VPE_PROFILE_EN_OFFSET                 0x10010
-#define VPE_PROFILE_COUNT_OFFSET              0x10014
-#define VPE_CMD_MODE_OFFSET                   0x10060
-#define VPE_SRC_SIZE_OFFSET                   0x10108
-#define VPE_SRCP0_ADDR_OFFSET                 0x1010C
-#define VPE_SRCP1_ADDR_OFFSET                 0x10110
-#define VPE_SRC_YSTRIDE1_OFFSET               0x1011C
-#define VPE_SRC_FORMAT_OFFSET                 0x10124
-#define VPE_SRC_UNPACK_PATTERN1_OFFSET        0x10128
-#define VPE_OP_MODE_OFFSET                    0x10138
-#define VPE_SCALE_PHASEX_INIT_OFFSET          0x1013C
-#define VPE_SCALE_PHASEY_INIT_OFFSET          0x10140
-#define VPE_SCALE_PHASEX_STEP_OFFSET          0x10144
-#define VPE_SCALE_PHASEY_STEP_OFFSET          0x10148
-#define VPE_OUT_FORMAT_OFFSET                 0x10150
-#define VPE_OUT_PACK_PATTERN1_OFFSET          0x10154
-#define VPE_OUT_SIZE_OFFSET                   0x10164
-#define VPE_OUTP0_ADDR_OFFSET                 0x10168
-#define VPE_OUTP1_ADDR_OFFSET                 0x1016C
-#define VPE_OUT_YSTRIDE1_OFFSET               0x10178
-#define VPE_OUT_XY_OFFSET                     0x1019C
-#define VPE_SRC_XY_OFFSET                     0x10200
-#define VPE_SRC_IMAGE_SIZE_OFFSET             0x10208
-#define VPE_SCALE_CONFIG_OFFSET               0x10230
-#define VPE_DEINT_STATUS_OFFSET               0x30000
-#define VPE_DEINT_DECISION_OFFSET             0x30004
-#define VPE_DEINT_COEFF0_OFFSET               0x30010
-#define VPE_SCALE_STATUS_OFFSET               0x50000
-#define VPE_SCALE_SVI_PARAM_OFFSET            0x50010
-#define VPE_SCALE_SHARPEN_CFG_OFFSET          0x50020
-#define VPE_SCALE_COEFF_LSP_0_OFFSET          0x50400
-#define VPE_SCALE_COEFF_MSP_0_OFFSET          0x50404
-
-#define VPE_AXI_ARB_2_OFFSET                  0x004C
-
-#define VPE_SCALE_COEFF_LSBn(n)	(0x50400 + 8 * (n))
-#define VPE_SCALE_COEFF_MSBn(n)	(0x50404 + 8 * (n))
-#define VPE_SCALE_COEFF_NUM			32
-
-/*********** end of register offset ********************/
-
-
-#define VPE_HARDWARE_VERSION          0x00080308
-#define VPE_SW_RESET_VALUE            0x00000010  /* bit 4 for PPP*/
-#define VPE_AXI_RD_ARB_CONFIG_VALUE   0x124924
-#define VPE_CMD_MODE_VALUE        0x1
-#define VPE_DEFAULT_OP_MODE_VALUE     0x40FC0004
-#define VPE_CGC_ENABLE_VALUE          0xffff
-#define VPE_DEFAULT_SCALE_CONFIG      0x3c
-
-#define VPE_NORMAL_MODE_CLOCK_RATE   150000000
-#define VPE_TURBO_MODE_CLOCK_RATE   200000000
-/**************************************************/
-/*********** Start of command id ******************/
-/**************************************************/
-enum VPE_CMD_ID_ENUM {
-	VPE_DUMMY_0 = 0,
-	VPE_SET_CLK,
-	VPE_RESET,
-	VPE_START,
-	VPE_ABORT,
-	VPE_OPERATION_MODE_CFG, /* 5 */
-	VPE_INPUT_PLANE_CFG,
-	VPE_OUTPUT_PLANE_CFG,
-	VPE_INPUT_PLANE_UPDATE,
-	VPE_SCALE_CFG_TYPE,
-	VPE_ROTATION_CFG_TYPE, /* 10 */
-	VPE_AXI_OUT_CFG,
-	VPE_CMD_DIS_OFFSET_CFG,
-	VPE_ENABLE,
-	VPE_DISABLE,
-};
-
-/* Length of each command.  In bytes.  (payload only) */
-#define VPE_OPERATION_MODE_CFG_LEN 8
-#define VPE_INPUT_PLANE_CFG_LEN    24
-#define VPE_OUTPUT_PLANE_CFG_LEN   20
-#define VPE_INPUT_PLANE_UPDATE_LEN 12
-#define VPE_SCALER_CONFIG_LEN      260
-#define VPE_DIS_OFFSET_CFG_LEN     12
-/**************************************************/
-/*********** End of command id ********************/
-/**************************************************/
-
-struct msm_vpe_cmd {
-	int32_t  id;
-	uint16_t length;
-	void     *value;
-};
-
-struct vpe_cmd_type {
-	uint16_t id;
-	uint32_t length;
-};
-
-struct vpe_isr_queue_cmd_type {
-	struct list_head            list;
-	uint32_t                    irq_status;
-};
-
-enum VPE_MESSAGE_ID {
-	MSG_ID_VPE_OUTPUT_V = 7, /* To match with that of VFE */
-	MSG_ID_VPE_OUTPUT_ST_L,
-	MSG_ID_VPE_OUTPUT_ST_R,
-};
-
-enum vpe_state {
-	VPE_STATE_IDLE,
-	VPE_STATE_INIT,
-	VPE_STATE_ACTIVE,
-};
-
-struct vpe_device_type {
-	/* device related. */
-	int   vpeirq;
-	void __iomem      *vpebase;
-	struct resource	  *vpemem;
-	struct resource   *vpeio;
-	void        *device_extdata;
-};
-
-struct dis_offset_type {
-	int32_t dis_offset_x;
-	int32_t dis_offset_y;
-	uint32_t frame_id;
-};
-
-struct vpe_ctrl_type {
-	spinlock_t        tasklet_lock;
-	spinlock_t        state_lock;
-	spinlock_t        ops_lock;
-
-	struct list_head  tasklet_q;
-	void              *syncdata;
-	uint16_t          op_mode;
-	void              *extdata;
-	uint32_t          extlen;
-	struct msm_vpe_callback *resp;
-	uint32_t          in_h_w;
-	uint32_t          out_h;  /* this is BEFORE rotation. */
-	uint32_t          out_w;  /* this is BEFORE rotation. */
-	uint32_t          dis_en;
-	struct timespec   ts;
-	struct dis_offset_type   dis_offset;
-	uint32_t          pcbcr_before_dis;
-	uint32_t          pcbcr_dis_offset;
-	int               output_type;
-	int               frame_pack;
-	uint8_t           pad_2k_bool;
-	enum vpe_state    state;
-	unsigned long     out_y_addr;
-	unsigned long     out_cbcr_addr;
-};
-
-/*
-* vpe_input_update
-*
-* Define the parameters for output plane
-*/
-/* this is the dimension of ROI.  width / height. */
-struct vpe_src_size_packed {
-	uint32_t        src_w;
-	uint32_t        src_h;
-};
-
-struct vpe_src_xy_packed {
-	uint32_t        src_x;
-	uint32_t        src_y;
-};
-
-struct vpe_input_plane_update_type {
-	struct vpe_src_size_packed             src_roi_size;
-	/* DIS updates this set. */
-	struct vpe_src_xy_packed               src_roi_offset;
-	/* input address*/
-	uint8_t                         *src_p0_addr;
-	uint8_t                         *src_p1_addr;
-};
-
-struct vpe_msg_stats{
-	uint32_t    buffer;
-	uint32_t    frameCounter;
-};
-
-struct vpe_msg_output {
-	uint8_t   output_id;
-	uint32_t  p0_Buffer;
-	uint32_t  p1_Buffer;
-	uint32_t  p2_Buffer;
-	uint32_t  frameCounter;
-};
-
-struct vpe_message {
-	uint8_t  _d;
-	union {
-		struct vpe_msg_output              msgOut;
-		struct vpe_msg_stats               msgStats;
-	} _u;
-};
-
-#define SCALER_PHASE_BITS 29
-#define HAL_MDP_PHASE_STEP_2P50    0x50000000
-#define HAL_MDP_PHASE_STEP_1P66    0x35555555
-#define HAL_MDP_PHASE_STEP_1P25    0x28000000
-
-struct phase_val_t {
-	int32_t phase_init_x;
-	int32_t phase_init_y;
-	int32_t phase_step_x;
-	int32_t phase_step_y;
-};
-
-extern struct vpe_ctrl_type *vpe_ctrl;
-
-int msm_vpe_open(void);
-int msm_vpe_release(void);
-int msm_vpe_reg(struct msm_vpe_callback *presp);
-void msm_send_frame_to_vpe(uint32_t pyaddr, uint32_t pcbcraddr,
-	struct timespec *ts, int output_id);
-int msm_vpe_config(struct msm_vpe_cfg_cmd *cmd, void *data);
-int msm_vpe_cfg_update(void *pinfo);
-void msm_vpe_offset_update(int frame_pack, uint32_t pyaddr, uint32_t pcbcraddr,
-	struct timespec *ts, int output_id, struct msm_st_half st_half,
-	int frameid);
-#endif /*_msm_vpe1_h_*/
-
diff --git a/drivers/media/platform/msm/camera_v1/mt9d112.c b/drivers/media/platform/msm/camera_v1/mt9d112.c
deleted file mode 100644
index 9c19965..0000000
--- a/drivers/media/platform/msm/camera_v1/mt9d112.c
+++ /dev/null
@@ -1,846 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include <linux/types.h>
-#include <linux/i2c.h>
-#include <linux/uaccess.h>
-#include <linux/miscdevice.h>
-#include <linux/module.h>
-#include <media/msm_camera.h>
-#include <mach/gpio.h>
-#include "mt9d112.h"
-
-/* Micron MT9D112 Registers and their values */
-/* Sensor Core Registers */
-#define  REG_MT9D112_MODEL_ID 0x3000
-#define  MT9D112_MODEL_ID     0x1580
-
-/*  SOC Registers Page 1  */
-#define  REG_MT9D112_SENSOR_RESET     0x301A
-#define  REG_MT9D112_STANDBY_CONTROL  0x3202
-#define  REG_MT9D112_MCU_BOOT         0x3386
-
-#define SENSOR_DEBUG 0
-
-struct mt9d112_work {
-	struct work_struct work;
-};
-
-static struct  mt9d112_work *mt9d112_sensorw;
-static struct  i2c_client *mt9d112_client;
-
-struct mt9d112_ctrl {
-	const struct msm_camera_sensor_info *sensordata;
-};
-
-
-static struct mt9d112_ctrl *mt9d112_ctrl;
-
-static DECLARE_WAIT_QUEUE_HEAD(mt9d112_wait_queue);
-DEFINE_SEMAPHORE(mt9d112_sem);
-static int16_t mt9d112_effect = CAMERA_EFFECT_OFF;
-
-/*=============================================================
-	EXTERNAL DECLARATIONS
-==============================================================*/
-extern struct mt9d112_reg mt9d112_regs;
-
-
-/*=============================================================*/
-
-static int mt9d112_reset(const struct msm_camera_sensor_info *dev)
-{
-	int rc = 0;
-
-	rc = gpio_request(dev->sensor_reset, "mt9d112");
-
-	if (!rc) {
-		rc = gpio_direction_output(dev->sensor_reset, 0);
-		msleep(20);
-		gpio_set_value_cansleep(dev->sensor_reset, 1);
-		msleep(20);
-	}
-
-	return rc;
-}
-
-static int32_t mt9d112_i2c_txdata(unsigned short saddr,
-	unsigned char *txdata, int length)
-{
-	struct i2c_msg msg[] = {
-		{
-			.addr = saddr,
-			.flags = 0,
-			.len = length,
-			.buf = txdata,
-		},
-	};
-
-#if SENSOR_DEBUG
-	if (length == 2)
-		CDBG("msm_io_i2c_w: 0x%04x 0x%04x\n",
-			*(u16 *) txdata, *(u16 *) (txdata + 2));
-	else if (length == 4)
-		CDBG("msm_io_i2c_w: 0x%04x\n", *(u16 *) txdata);
-	else
-		CDBG("msm_io_i2c_w: length = %d\n", length);
-#endif
-	if (i2c_transfer(mt9d112_client->adapter, msg, 1) < 0) {
-		CDBG("mt9d112_i2c_txdata failed\n");
-		return -EIO;
-	}
-
-	return 0;
-}
-
-static int32_t mt9d112_i2c_write(unsigned short saddr,
-	unsigned short waddr, unsigned short wdata, enum mt9d112_width width)
-{
-	int32_t rc = -EIO;
-	unsigned char buf[4];
-
-	memset(buf, 0, sizeof(buf));
-	switch (width) {
-	case WORD_LEN: {
-		buf[0] = (waddr & 0xFF00)>>8;
-		buf[1] = (waddr & 0x00FF);
-		buf[2] = (wdata & 0xFF00)>>8;
-		buf[3] = (wdata & 0x00FF);
-
-		rc = mt9d112_i2c_txdata(saddr, buf, 4);
-	}
-		break;
-
-	case BYTE_LEN: {
-		buf[0] = waddr;
-		buf[1] = wdata;
-		rc = mt9d112_i2c_txdata(saddr, buf, 2);
-	}
-		break;
-
-	default:
-		break;
-	}
-
-	if (rc < 0)
-		CDBG(
-		"i2c_write failed, addr = 0x%x, val = 0x%x!\n",
-		waddr, wdata);
-
-	return rc;
-}
-
-static int32_t mt9d112_i2c_write_table(
-	struct mt9d112_i2c_reg_conf const *reg_conf_tbl,
-	int num_of_items_in_table)
-{
-	int i;
-	int32_t rc = -EIO;
-
-	for (i = 0; i < num_of_items_in_table; i++) {
-		rc = mt9d112_i2c_write(mt9d112_client->addr,
-			reg_conf_tbl->waddr, reg_conf_tbl->wdata,
-			reg_conf_tbl->width);
-		if (rc < 0)
-			break;
-		if (reg_conf_tbl->mdelay_time != 0)
-			mdelay(reg_conf_tbl->mdelay_time);
-		reg_conf_tbl++;
-	}
-
-	return rc;
-}
-
-static int mt9d112_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 SENSOR_DEBUG
-	if (length == 2)
-		CDBG("msm_io_i2c_r: 0x%04x 0x%04x\n",
-			*(u16 *) rxdata, *(u16 *) (rxdata + 2));
-	else if (length == 4)
-		CDBG("msm_io_i2c_r: 0x%04x\n", *(u16 *) rxdata);
-	else
-		CDBG("msm_io_i2c_r: length = %d\n", length);
-#endif
-
-	if (i2c_transfer(mt9d112_client->adapter, msgs, 2) < 0) {
-		CDBG("mt9d112_i2c_rxdata failed!\n");
-		return -EIO;
-	}
-
-	return 0;
-}
-
-static int32_t mt9d112_i2c_read(unsigned short   saddr,
-	unsigned short raddr, unsigned short *rdata, enum mt9d112_width width)
-{
-	int32_t rc = 0;
-	unsigned char buf[4];
-
-	if (!rdata)
-		return -EIO;
-
-	memset(buf, 0, sizeof(buf));
-
-	switch (width) {
-	case WORD_LEN: {
-		buf[0] = (raddr & 0xFF00)>>8;
-		buf[1] = (raddr & 0x00FF);
-
-		rc = mt9d112_i2c_rxdata(saddr, buf, 2);
-		if (rc < 0)
-			return rc;
-
-		*rdata = buf[0] << 8 | buf[1];
-	}
-		break;
-
-	default:
-		break;
-	}
-
-	if (rc < 0)
-		CDBG("mt9d112_i2c_read failed!\n");
-
-	return rc;
-}
-
-static int32_t mt9d112_set_lens_roll_off(void)
-{
-	int32_t rc = 0;
-	rc = mt9d112_i2c_write_table(&mt9d112_regs.rftbl[0],
-								 mt9d112_regs.rftbl_size);
-	return rc;
-}
-
-static long mt9d112_reg_init(void)
-{
-	int32_t array_length;
-	int32_t i;
-	long rc;
-
-	/* PLL Setup Start */
-	rc = mt9d112_i2c_write_table(&mt9d112_regs.plltbl[0],
-					mt9d112_regs.plltbl_size);
-
-	if (rc < 0)
-		return rc;
-	/* PLL Setup End   */
-
-	array_length = mt9d112_regs.prev_snap_reg_settings_size;
-
-	/* Configure sensor for Preview mode and Snapshot mode */
-	for (i = 0; i < array_length; i++) {
-		rc = mt9d112_i2c_write(mt9d112_client->addr,
-		  mt9d112_regs.prev_snap_reg_settings[i].register_address,
-		  mt9d112_regs.prev_snap_reg_settings[i].register_value,
-		  WORD_LEN);
-
-		if (rc < 0)
-			return rc;
-	}
-
-	/* Configure for Noise Reduction, Saturation and Aperture Correction */
-	array_length = mt9d112_regs.noise_reduction_reg_settings_size;
-
-	for (i = 0; i < array_length; i++) {
-		rc = mt9d112_i2c_write(mt9d112_client->addr,
-			mt9d112_regs.noise_reduction_reg_settings[i].register_address,
-			mt9d112_regs.noise_reduction_reg_settings[i].register_value,
-			WORD_LEN);
-
-		if (rc < 0)
-			return rc;
-	}
-
-	/* Set Color Kill Saturation point to optimum value */
-	rc =
-	mt9d112_i2c_write(mt9d112_client->addr,
-	0x35A4,
-	0x0593,
-	WORD_LEN);
-	if (rc < 0)
-		return rc;
-
-	rc = mt9d112_i2c_write_table(&mt9d112_regs.stbl[0],
-					mt9d112_regs.stbl_size);
-	if (rc < 0)
-		return rc;
-
-	rc = mt9d112_set_lens_roll_off();
-	if (rc < 0)
-		return rc;
-
-	return 0;
-}
-
-static long mt9d112_set_effect(int mode, int effect)
-{
-	uint16_t reg_addr;
-	uint16_t reg_val;
-	long rc = 0;
-
-	switch (mode) {
-	case SENSOR_PREVIEW_MODE:
-		/* Context A Special Effects */
-		reg_addr = 0x2799;
-		break;
-
-	case SENSOR_RAW_SNAPSHOT_MODE:
-	case SENSOR_SNAPSHOT_MODE:
-		/* Context B Special Effects */
-		reg_addr = 0x279B;
-		break;
-
-	default:
-		reg_addr = 0x2799;
-		break;
-	}
-
-	switch (effect) {
-	case CAMERA_EFFECT_OFF: {
-		reg_val = 0x6440;
-
-		rc = mt9d112_i2c_write(mt9d112_client->addr,
-			0x338C, reg_addr, WORD_LEN);
-		if (rc < 0)
-			return rc;
-
-		rc = mt9d112_i2c_write(mt9d112_client->addr,
-			0x3390, reg_val, WORD_LEN);
-		if (rc < 0)
-			return rc;
-	}
-			break;
-
-	case CAMERA_EFFECT_MONO: {
-		reg_val = 0x6441;
-		rc = mt9d112_i2c_write(mt9d112_client->addr,
-			0x338C, reg_addr, WORD_LEN);
-		if (rc < 0)
-			return rc;
-
-		rc = mt9d112_i2c_write(mt9d112_client->addr,
-			0x3390, reg_val, WORD_LEN);
-		if (rc < 0)
-			return rc;
-	}
-		break;
-
-	case CAMERA_EFFECT_NEGATIVE: {
-		reg_val = 0x6443;
-		rc = mt9d112_i2c_write(mt9d112_client->addr,
-			0x338C, reg_addr, WORD_LEN);
-		if (rc < 0)
-			return rc;
-
-		rc = mt9d112_i2c_write(mt9d112_client->addr,
-			0x3390, reg_val, WORD_LEN);
-		if (rc < 0)
-			return rc;
-	}
-		break;
-
-	case CAMERA_EFFECT_SOLARIZE: {
-		reg_val = 0x6445;
-		rc = mt9d112_i2c_write(mt9d112_client->addr,
-			0x338C, reg_addr, WORD_LEN);
-		if (rc < 0)
-			return rc;
-
-		rc = mt9d112_i2c_write(mt9d112_client->addr,
-			0x3390, reg_val, WORD_LEN);
-		if (rc < 0)
-			return rc;
-	}
-		break;
-
-	case CAMERA_EFFECT_SEPIA: {
-		reg_val = 0x6442;
-		rc = mt9d112_i2c_write(mt9d112_client->addr,
-			0x338C, reg_addr, WORD_LEN);
-		if (rc < 0)
-			return rc;
-
-		rc = mt9d112_i2c_write(mt9d112_client->addr,
-			0x3390, reg_val, WORD_LEN);
-		if (rc < 0)
-			return rc;
-	}
-		break;
-
-	default: {
-		reg_val = 0x6440;
-		rc = mt9d112_i2c_write(mt9d112_client->addr,
-			0x338C, reg_addr, WORD_LEN);
-		if (rc < 0)
-			return rc;
-
-		rc = mt9d112_i2c_write(mt9d112_client->addr,
-			0x3390, reg_val, WORD_LEN);
-		if (rc < 0)
-			return rc;
-
-		return -EINVAL;
-	}
-	}
-	mt9d112_effect = effect;
-	/* Refresh Sequencer */
-	rc = mt9d112_i2c_write(mt9d112_client->addr,
-		0x338C, 0xA103, WORD_LEN);
-	if (rc < 0)
-		return rc;
-
-	rc = mt9d112_i2c_write(mt9d112_client->addr,
-		0x3390, 0x0005, WORD_LEN);
-
-	return rc;
-}
-
-static long mt9d112_set_sensor_mode(int mode)
-{
-	uint16_t clock;
-	long rc = 0;
-
-	switch (mode) {
-	case SENSOR_PREVIEW_MODE:
-		rc =
-			mt9d112_i2c_write(mt9d112_client->addr,
-				0x338C, 0xA20C, WORD_LEN);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9d112_i2c_write(mt9d112_client->addr,
-				0x3390, 0x0004, WORD_LEN);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9d112_i2c_write(mt9d112_client->addr,
-				0x338C, 0xA215, WORD_LEN);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9d112_i2c_write(mt9d112_client->addr,
-				0x3390, 0x0004, WORD_LEN);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9d112_i2c_write(mt9d112_client->addr,
-				0x338C, 0xA20B, WORD_LEN);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9d112_i2c_write(mt9d112_client->addr,
-				0x3390, 0x0000, WORD_LEN);
-		if (rc < 0)
-			return rc;
-
-		clock = 0x23C;
-
-		rc =
-			mt9d112_i2c_write(mt9d112_client->addr,
-				0x341C, clock, WORD_LEN);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9d112_i2c_write(mt9d112_client->addr,
-				0x338C, 0xA103, WORD_LEN);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9d112_i2c_write(mt9d112_client->addr,
-				0x3390, 0x0001, WORD_LEN);
-		if (rc < 0)
-			return rc;
-		mdelay(5);
-
-		break;
-
-	case SENSOR_SNAPSHOT_MODE:
-		/* Switch to lower fps for Snapshot */
-		rc =
-			mt9d112_i2c_write(mt9d112_client->addr,
-				0x341C, 0x0120, WORD_LEN);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9d112_i2c_write(mt9d112_client->addr,
-				0x338C, 0xA120, WORD_LEN);
-		if (rc < 0)
-			return rc;
-
-		msleep(40);/*waiting for the delay of one frame*/
-		rc =
-			mt9d112_i2c_write(mt9d112_client->addr,
-				0x3390, 0x0002, WORD_LEN);
-		if (rc < 0)
-			return rc;
-
-		msleep(80);/*waiting for the delay of two frames*/
-
-		rc =
-			mt9d112_i2c_write(mt9d112_client->addr,
-				0x338C, 0xA103, WORD_LEN);
-		if (rc < 0)
-			return rc;
-
-		msleep(40);/*waiting for the delay of one frame*/
-		rc =
-			mt9d112_i2c_write(mt9d112_client->addr,
-				0x3390, 0x0002, WORD_LEN);
-		if (rc < 0)
-			return rc;
-		break;
-
-	case SENSOR_RAW_SNAPSHOT_MODE:
-		/* Setting the effect to CAMERA_EFFECT_OFF */
-		rc =
-			mt9d112_i2c_write(mt9d112_client->addr,
-				0x338C, 0x279B, WORD_LEN);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9d112_i2c_write(mt9d112_client->addr,
-			0x3390, 0x6440, WORD_LEN);
-		if (rc < 0)
-			return rc;
-		msleep(40);/*waiting for the delay of one frame*/
-		/* Switch to lower fps for Snapshot */
-		rc =
-			mt9d112_i2c_write(mt9d112_client->addr,
-				0x341C, 0x0120, WORD_LEN);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9d112_i2c_write(mt9d112_client->addr,
-				0x338C, 0xA120, WORD_LEN);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9d112_i2c_write(mt9d112_client->addr,
-				0x3390, 0x0002, WORD_LEN);
-		if (rc < 0)
-			return rc;
-		msleep(80);/*waiting for the delay of two frames frame*/
-		rc =
-			mt9d112_i2c_write(mt9d112_client->addr,
-				0x338C, 0xA103, WORD_LEN);
-		if (rc < 0)
-			return rc;
-		msleep(40);/*waiting for the delay of one frame*/
-		rc =
-			mt9d112_i2c_write(mt9d112_client->addr,
-				0x3390, 0x0002, WORD_LEN);
-		if (rc < 0)
-			return rc;
-		break;
-
-	default:
-		return -EINVAL;
-	}
-
-	return 0;
-}
-
-static int mt9d112_sensor_init_probe(const struct msm_camera_sensor_info *data)
-{
-	uint16_t model_id = 0;
-	int rc = 0;
-
-	CDBG("init entry \n");
-	rc = mt9d112_reset(data);
-	if (rc < 0) {
-		CDBG("reset failed!\n");
-		goto init_probe_fail;
-	}
-
-	msm_camio_clk_rate_set(24000000);
-	msleep(20);
-
-	/* Micron suggested Power up block Start:
-	* Put MCU into Reset - Stop MCU */
-	rc = mt9d112_i2c_write(mt9d112_client->addr,
-		REG_MT9D112_MCU_BOOT, 0x0501, WORD_LEN);
-	if (rc < 0)
-		goto init_probe_fail;
-
-	/* Pull MCU from Reset - Start MCU */
-	rc = mt9d112_i2c_write(mt9d112_client->addr,
-		REG_MT9D112_MCU_BOOT, 0x0500, WORD_LEN);
-	if (rc < 0)
-		goto init_probe_fail;
-
-	mdelay(5);
-
-	/* Micron Suggested - Power up block */
-	rc = mt9d112_i2c_write(mt9d112_client->addr,
-		REG_MT9D112_SENSOR_RESET, 0x0ACC, WORD_LEN);
-	if (rc < 0)
-		goto init_probe_fail;
-
-	rc = mt9d112_i2c_write(mt9d112_client->addr,
-		REG_MT9D112_STANDBY_CONTROL, 0x0008, WORD_LEN);
-	if (rc < 0)
-		goto init_probe_fail;
-
-	/* FUSED_DEFECT_CORRECTION */
-	rc = mt9d112_i2c_write(mt9d112_client->addr,
-		0x33F4, 0x031D, WORD_LEN);
-	if (rc < 0)
-		goto init_probe_fail;
-
-	mdelay(5);
-
-	/* Micron suggested Power up block End */
-	/* Read the Model ID of the sensor */
-	rc = mt9d112_i2c_read(mt9d112_client->addr,
-		REG_MT9D112_MODEL_ID, &model_id, WORD_LEN);
-	if (rc < 0)
-		goto init_probe_fail;
-
-	CDBG("mt9d112 model_id = 0x%x\n", model_id);
-
-	/* Check if it matches it with the value in Datasheet */
-	if (model_id != MT9D112_MODEL_ID) {
-		rc = -EINVAL;
-		goto init_probe_fail;
-	}
-
-	rc = mt9d112_reg_init();
-	if (rc < 0)
-		goto init_probe_fail;
-
-	return rc;
-
-init_probe_fail:
-	return rc;
-}
-
-int mt9d112_sensor_init(const struct msm_camera_sensor_info *data)
-{
-	int rc = 0;
-
-	mt9d112_ctrl = kzalloc(sizeof(struct mt9d112_ctrl), GFP_KERNEL);
-	if (!mt9d112_ctrl) {
-		CDBG("mt9d112_init failed!\n");
-		rc = -ENOMEM;
-		goto init_done;
-	}
-
-	if (data)
-		mt9d112_ctrl->sensordata = data;
-
-	/* Input MCLK = 24MHz */
-	msm_camio_clk_rate_set(24000000);
-	mdelay(5);
-
-	msm_camio_camif_pad_reg_reset();
-
-	rc = mt9d112_sensor_init_probe(data);
-	if (rc < 0) {
-		CDBG("mt9d112_sensor_init failed!\n");
-		goto init_fail;
-	}
-
-init_done:
-	return rc;
-
-init_fail:
-	kfree(mt9d112_ctrl);
-	return rc;
-}
-
-static int mt9d112_init_client(struct i2c_client *client)
-{
-	/* Initialize the MSM_CAMI2C Chip */
-	init_waitqueue_head(&mt9d112_wait_queue);
-	return 0;
-}
-
-int mt9d112_sensor_config(void __user *argp)
-{
-	struct sensor_cfg_data cfg_data;
-	long   rc = 0;
-
-	if (copy_from_user(&cfg_data,
-			(void *)argp,
-			sizeof(struct sensor_cfg_data)))
-		return -EFAULT;
-
-	/* down(&mt9d112_sem); */
-
-	CDBG("mt9d112_ioctl, cfgtype = %d, mode = %d\n",
-		cfg_data.cfgtype, cfg_data.mode);
-
-		switch (cfg_data.cfgtype) {
-		case CFG_SET_MODE:
-			rc = mt9d112_set_sensor_mode(
-						cfg_data.mode);
-			break;
-
-		case CFG_SET_EFFECT:
-			rc = mt9d112_set_effect(cfg_data.mode,
-						cfg_data.cfg.effect);
-			break;
-
-		case CFG_GET_AF_MAX_STEPS:
-		default:
-			rc = -EINVAL;
-			break;
-		}
-
-	/* up(&mt9d112_sem); */
-
-	return rc;
-}
-
-int mt9d112_sensor_release(void)
-{
-	int rc = 0;
-
-	/* down(&mt9d112_sem); */
-	gpio_set_value_cansleep(mt9d112_ctrl->sensordata->sensor_reset, 0);
-	msleep(20);
-	gpio_free(mt9d112_ctrl->sensordata->sensor_reset);
-	kfree(mt9d112_ctrl);
-	/* up(&mt9d112_sem); */
-
-	return rc;
-}
-
-static int mt9d112_i2c_probe(struct i2c_client *client,
-	const struct i2c_device_id *id)
-{
-	int rc = 0;
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		rc = -ENOTSUPP;
-		goto probe_failure;
-	}
-
-	mt9d112_sensorw =
-		kzalloc(sizeof(struct mt9d112_work), GFP_KERNEL);
-
-	if (!mt9d112_sensorw) {
-		rc = -ENOMEM;
-		goto probe_failure;
-	}
-
-	i2c_set_clientdata(client, mt9d112_sensorw);
-	mt9d112_init_client(client);
-	mt9d112_client = client;
-
-	CDBG("mt9d112_probe succeeded!\n");
-
-	return 0;
-
-probe_failure:
-	kfree(mt9d112_sensorw);
-	mt9d112_sensorw = NULL;
-	CDBG("mt9d112_probe failed!\n");
-	return rc;
-}
-
-static const struct i2c_device_id mt9d112_i2c_id[] = {
-	{ "mt9d112", 0},
-	{ },
-};
-
-static struct i2c_driver mt9d112_i2c_driver = {
-	.id_table = mt9d112_i2c_id,
-	.probe  = mt9d112_i2c_probe,
-	.remove = __exit_p(mt9d112_i2c_remove),
-	.driver = {
-		.name = "mt9d112",
-	},
-};
-
-static int mt9d112_sensor_probe(const struct msm_camera_sensor_info *info,
-				struct msm_sensor_ctrl *s)
-{
-	int rc = i2c_add_driver(&mt9d112_i2c_driver);
-	if (rc < 0 || mt9d112_client == NULL) {
-		rc = -ENOTSUPP;
-		goto probe_done;
-	}
-
-	/* Input MCLK = 24MHz */
-	msm_camio_clk_rate_set(24000000);
-	mdelay(5);
-
-	rc = mt9d112_sensor_init_probe(info);
-	if (rc < 0) {
-		gpio_free(info->sensor_reset);
-		goto probe_done;
-	}
-	s->s_init = mt9d112_sensor_init;
-	s->s_release = mt9d112_sensor_release;
-	s->s_config  = mt9d112_sensor_config;
-	s->s_camera_type = FRONT_CAMERA_2D;
-	s->s_mount_angle  = 0;
-	gpio_set_value_cansleep(info->sensor_reset, 0);
-	msleep(20);
-	gpio_free(info->sensor_reset);
-
-probe_done:
-	CDBG("%s %s:%d\n", __FILE__, __func__, __LINE__);
-	return rc;
-}
-
-static int __mt9d112_probe(struct platform_device *pdev)
-{
-	return msm_camera_drv_start(pdev, mt9d112_sensor_probe);
-}
-
-static struct platform_driver msm_camera_driver = {
-	.probe = __mt9d112_probe,
-	.driver = {
-		.name = "msm_camera_mt9d112",
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init mt9d112_init(void)
-{
-	return platform_driver_register(&msm_camera_driver);
-}
-
-module_init(mt9d112_init);
diff --git a/drivers/media/platform/msm/camera_v1/mt9d112.h b/drivers/media/platform/msm/camera_v1/mt9d112.h
deleted file mode 100644
index f07d732..0000000
--- a/drivers/media/platform/msm/camera_v1/mt9d112.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-
-#ifndef MT9D112_H
-#define MT9D112_H
-
-#include <linux/types.h>
-#include <mach/camera.h>
-
-extern struct mt9d112_reg mt9d112_regs;
-
-enum mt9d112_width {
-	WORD_LEN,
-	BYTE_LEN
-};
-
-struct mt9d112_i2c_reg_conf {
-	unsigned short waddr;
-	unsigned short wdata;
-	enum mt9d112_width width;
-	unsigned short mdelay_time;
-};
-
-struct mt9d112_reg {
-	const struct register_address_value_pair *prev_snap_reg_settings;
-	uint16_t prev_snap_reg_settings_size;
-	const struct register_address_value_pair *noise_reduction_reg_settings;
-	uint16_t noise_reduction_reg_settings_size;
-	const struct mt9d112_i2c_reg_conf *plltbl;
-	uint16_t plltbl_size;
-	const struct mt9d112_i2c_reg_conf *stbl;
-	uint16_t stbl_size;
-	const struct mt9d112_i2c_reg_conf *rftbl;
-	uint16_t rftbl_size;
-};
-
-#endif /* MT9D112_H */
diff --git a/drivers/media/platform/msm/camera_v1/mt9d112_reg.c b/drivers/media/platform/msm/camera_v1/mt9d112_reg.c
deleted file mode 100644
index 6c35cbc..0000000
--- a/drivers/media/platform/msm/camera_v1/mt9d112_reg.c
+++ /dev/null
@@ -1,319 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-
-#include "mt9d112.h"
-
-
-struct register_address_value_pair const
-preview_snapshot_mode_reg_settings_array[] = {
-	{0x338C, 0x2703},
-	{0x3390, 800},    /* Output Width (P) = 640 */
-	{0x338C, 0x2705},
-	{0x3390, 600},    /* Output Height (P) = 480 */
-	{0x338C, 0x2707},
-	{0x3390, 0x0640}, /* Output Width (S) = 1600 */
-	{0x338C, 0x2709},
-	{0x3390, 0x04B0}, /* Output Height (S) = 1200 */
-	{0x338C, 0x270D},
-	{0x3390, 0x0000}, /* Row Start (P) = 0 */
-	{0x338C, 0x270F},
-	{0x3390, 0x0000}, /* Column Start (P) = 0 */
-	{0x338C, 0x2711},
-	{0x3390, 0x04BD}, /* Row End (P) = 1213 */
-	{0x338C, 0x2713},
-	{0x3390, 0x064D}, /* Column End (P) = 1613 */
-	{0x338C, 0x2715},
-	{0x3390, 0x0000}, /* Extra Delay (P) = 0 */
-	{0x338C, 0x2717},
-	{0x3390, 0x2111}, /* Row Speed (P) = 8465 */
-	{0x338C, 0x2719},
-	{0x3390, 0x046C}, /* Read Mode (P) = 1132 */
-	{0x338C, 0x271B},
-	{0x3390, 0x024F}, /* Sensor_Sample_Time_pck(P) = 591 */
-	{0x338C, 0x271D},
-	{0x3390, 0x0102}, /* Sensor_Fine_Correction(P) = 258 */
-	{0x338C, 0x271F},
-	{0x3390, 0x0279}, /* Sensor_Fine_IT_min(P) = 633 */
-	{0x338C, 0x2721},
-	{0x3390, 0x0155}, /* Sensor_Fine_IT_max_margin(P) = 341 */
-	{0x338C, 0x2723},
-	{0x3390, 659},    /* Frame Lines (P) = 679 */
-	{0x338C, 0x2725},
-	{0x3390, 0x061B}, /* Line Length (P) = 1563 */
-	{0x338C, 0x2727},
-	{0x3390, 0x2020},
-	{0x338C, 0x2729},
-	{0x3390, 0x2020},
-	{0x338C, 0x272B},
-	{0x3390, 0x1020},
-	{0x338C, 0x272D},
-	{0x3390, 0x2007},
-	{0x338C, 0x272F},
-	{0x3390, 0x0004}, /* Row Start(S) = 4 */
-	{0x338C, 0x2731},
-	{0x3390, 0x0004}, /* Column Start(S) = 4 */
-	{0x338C, 0x2733},
-	{0x3390, 0x04BB}, /* Row End(S) = 1211 */
-	{0x338C, 0x2735},
-	{0x3390, 0x064B}, /* Column End(S) = 1611 */
-	{0x338C, 0x2737},
-	{0x3390, 0x04CE}, /* Extra Delay(S) = 1230 */
-	{0x338C, 0x2739},
-	{0x3390, 0x2111}, /* Row Speed(S) = 8465 */
-	{0x338C, 0x273B},
-	{0x3390, 0x0024}, /* Read Mode(S) = 36 */
-	{0x338C, 0x273D},
-	{0x3390, 0x0120}, /* Sensor sample time pck(S) = 288 */
-	{0x338C, 0x2741},
-	{0x3390, 0x0169}, /* Sensor_Fine_IT_min(P) = 361 */
-	{0x338C, 0x2745},
-	{0x3390, 0x04FF}, /* Frame Lines(S) = 1279 */
-	{0x338C, 0x2747},
-	{0x3390, 0x0824}, /* Line Length(S) = 2084 */
-	{0x338C, 0x2751},
-	{0x3390, 0x0000}, /* Crop_X0(P) = 0 */
-	{0x338C, 0x2753},
-	{0x3390, 0x0320}, /* Crop_X1(P) = 800 */
-	{0x338C, 0x2755},
-	{0x3390, 0x0000}, /* Crop_Y0(P) = 0 */
-	{0x338C, 0x2757},
-	{0x3390, 0x0258}, /* Crop_Y1(P) = 600 */
-	{0x338C, 0x275F},
-	{0x3390, 0x0000}, /* Crop_X0(S) = 0 */
-	{0x338C, 0x2761},
-	{0x3390, 0x0640}, /* Crop_X1(S) = 1600 */
-	{0x338C, 0x2763},
-	{0x3390, 0x0000}, /* Crop_Y0(S) = 0 */
-	{0x338C, 0x2765},
-	{0x3390, 0x04B0}, /* Crop_Y1(S) = 1200 */
-	{0x338C, 0x222E},
-	{0x3390, 0x00A0}, /* R9 Step = 160 */
-	{0x338C, 0xA408},
-	{0x3390, 0x001F},
-	{0x338C, 0xA409},
-	{0x3390, 0x0021},
-	{0x338C, 0xA40A},
-	{0x3390, 0x0025},
-	{0x338C, 0xA40B},
-	{0x3390, 0x0027},
-	{0x338C, 0x2411},
-	{0x3390, 0x00A0},
-	{0x338C, 0x2413},
-	{0x3390, 0x00C0},
-	{0x338C, 0x2415},
-	{0x3390, 0x00A0},
-	{0x338C, 0x2417},
-	{0x3390, 0x00C0},
-	{0x338C, 0x2799},
-	{0x3390, 0x6408}, /* MODE_SPEC_EFFECTS(P) */
-	{0x338C, 0x279B},
-	{0x3390, 0x6408}, /* MODE_SPEC_EFFECTS(S) */
-};
-
-static struct register_address_value_pair const
-noise_reduction_reg_settings_array[] = {
-	{0x338C, 0xA76D},
-	{0x3390, 0x0003},
-	{0x338C, 0xA76E},
-	{0x3390, 0x0003},
-	{0x338C, 0xA76F},
-	{0x3390, 0},
-	{0x338C, 0xA770},
-	{0x3390, 21},
-	{0x338C, 0xA771},
-	{0x3390, 37},
-	{0x338C, 0xA772},
-	{0x3390, 63},
-	{0x338C, 0xA773},
-	{0x3390, 100},
-	{0x338C, 0xA774},
-	{0x3390, 128},
-	{0x338C, 0xA775},
-	{0x3390, 151},
-	{0x338C, 0xA776},
-	{0x3390, 169},
-	{0x338C, 0xA777},
-	{0x3390, 186},
-	{0x338C, 0xA778},
-	{0x3390, 199},
-	{0x338C, 0xA779},
-	{0x3390, 210},
-	{0x338C, 0xA77A},
-	{0x3390, 220},
-	{0x338C, 0xA77B},
-	{0x3390, 228},
-	{0x338C, 0xA77C},
-	{0x3390, 234},
-	{0x338C, 0xA77D},
-	{0x3390, 240},
-	{0x338C, 0xA77E},
-	{0x3390, 244},
-	{0x338C, 0xA77F},
-	{0x3390, 248},
-	{0x338C, 0xA780},
-	{0x3390, 252},
-	{0x338C, 0xA781},
-	{0x3390, 255},
-	{0x338C, 0xA782},
-	{0x3390, 0},
-	{0x338C, 0xA783},
-	{0x3390, 21},
-	{0x338C, 0xA784},
-	{0x3390, 37},
-	{0x338C, 0xA785},
-	{0x3390, 63},
-	{0x338C, 0xA786},
-	{0x3390, 100},
-	{0x338C, 0xA787},
-	{0x3390, 128},
-	{0x338C, 0xA788},
-	{0x3390, 151},
-	{0x338C, 0xA789},
-	{0x3390, 169},
-	{0x338C, 0xA78A},
-	{0x3390, 186},
-	{0x338C, 0xA78B},
-	{0x3390, 199},
-	{0x338C, 0xA78C},
-	{0x3390, 210},
-	{0x338C, 0xA78D},
-	{0x3390, 220},
-	{0x338C, 0xA78E},
-	{0x3390, 228},
-	{0x338C, 0xA78F},
-	{0x3390, 234},
-	{0x338C, 0xA790},
-	{0x3390, 240},
-	{0x338C, 0xA791},
-	{0x3390, 244},
-	{0x338C, 0xA793},
-	{0x3390, 252},
-	{0x338C, 0xA794},
-	{0x3390, 255},
-	{0x338C, 0xA103},
-	{0x3390, 6},
-};
-
-static const struct mt9d112_i2c_reg_conf const lens_roll_off_tbl[] = {
-	{ 0x34CE, 0x81A0, WORD_LEN, 0 },
-	{ 0x34D0, 0x6331, WORD_LEN, 0 },
-	{ 0x34D2, 0x3394, WORD_LEN, 0 },
-	{ 0x34D4, 0x9966, WORD_LEN, 0 },
-	{ 0x34D6, 0x4B25, WORD_LEN, 0 },
-	{ 0x34D8, 0x2670, WORD_LEN, 0 },
-	{ 0x34DA, 0x724C, WORD_LEN, 0 },
-	{ 0x34DC, 0xFFFD, WORD_LEN, 0 },
-	{ 0x34DE, 0x00CA, WORD_LEN, 0 },
-	{ 0x34E6, 0x00AC, WORD_LEN, 0 },
-	{ 0x34EE, 0x0EE1, WORD_LEN, 0 },
-	{ 0x34F6, 0x0D87, WORD_LEN, 0 },
-	{ 0x3500, 0xE1F7, WORD_LEN, 0 },
-	{ 0x3508, 0x1CF4, WORD_LEN, 0 },
-	{ 0x3510, 0x1D28, WORD_LEN, 0 },
-	{ 0x3518, 0x1F26, WORD_LEN, 0 },
-	{ 0x3520, 0x2220, WORD_LEN, 0 },
-	{ 0x3528, 0x333D, WORD_LEN, 0 },
-	{ 0x3530, 0x15D9, WORD_LEN, 0 },
-	{ 0x3538, 0xCFB8, WORD_LEN, 0 },
-	{ 0x354C, 0x05FE, WORD_LEN, 0 },
-	{ 0x3544, 0x05F8, WORD_LEN, 0 },
-	{ 0x355C, 0x0596, WORD_LEN, 0 },
-	{ 0x3554, 0x0611, WORD_LEN, 0 },
-	{ 0x34E0, 0x00F2, WORD_LEN, 0 },
-	{ 0x34E8, 0x00A8, WORD_LEN, 0 },
-	{ 0x34F0, 0x0F7B, WORD_LEN, 0 },
-	{ 0x34F8, 0x0CD7, WORD_LEN, 0 },
-	{ 0x3502, 0xFEDB, WORD_LEN, 0 },
-	{ 0x350A, 0x13E4, WORD_LEN, 0 },
-	{ 0x3512, 0x1F2C, WORD_LEN, 0 },
-	{ 0x351A, 0x1D20, WORD_LEN, 0 },
-	{ 0x3522, 0x2422, WORD_LEN, 0 },
-	{ 0x352A, 0x2925, WORD_LEN, 0 },
-	{ 0x3532, 0x1D04, WORD_LEN, 0 },
-	{ 0x353A, 0xFBF2, WORD_LEN, 0 },
-	{ 0x354E, 0x0616, WORD_LEN, 0 },
-	{ 0x3546, 0x0597, WORD_LEN, 0 },
-	{ 0x355E, 0x05CD, WORD_LEN, 0 },
-	{ 0x3556, 0x0529, WORD_LEN, 0 },
-	{ 0x34E4, 0x00B2, WORD_LEN, 0 },
-	{ 0x34EC, 0x005E, WORD_LEN, 0 },
-	{ 0x34F4, 0x0F43, WORD_LEN, 0 },
-	{ 0x34FC, 0x0E2F, WORD_LEN, 0 },
-	{ 0x3506, 0xF9FC, WORD_LEN, 0 },
-	{ 0x350E, 0x0CE4, WORD_LEN, 0 },
-	{ 0x3516, 0x1E1E, WORD_LEN, 0 },
-	{ 0x351E, 0x1B19, WORD_LEN, 0 },
-	{ 0x3526, 0x151B, WORD_LEN, 0 },
-	{ 0x352E, 0x1416, WORD_LEN, 0 },
-	{ 0x3536, 0x10FC, WORD_LEN, 0 },
-	{ 0x353E, 0xC018, WORD_LEN, 0 },
-	{ 0x3552, 0x06B4, WORD_LEN, 0 },
-	{ 0x354A, 0x0506, WORD_LEN, 0 },
-	{ 0x3562, 0x06AB, WORD_LEN, 0 },
-	{ 0x355A, 0x063A, WORD_LEN, 0 },
-	{ 0x34E2, 0x00E5, WORD_LEN, 0 },
-	{ 0x34EA, 0x008B, WORD_LEN, 0 },
-	{ 0x34F2, 0x0E4C, WORD_LEN, 0 },
-	{ 0x34FA, 0x0CA3, WORD_LEN, 0 },
-	{ 0x3504, 0x0907, WORD_LEN, 0 },
-	{ 0x350C, 0x1DFD, WORD_LEN, 0 },
-	{ 0x3514, 0x1E24, WORD_LEN, 0 },
-	{ 0x351C, 0x2529, WORD_LEN, 0 },
-	{ 0x3524, 0x1D20, WORD_LEN, 0 },
-	{ 0x352C, 0x2332, WORD_LEN, 0 },
-	{ 0x3534, 0x10E9, WORD_LEN, 0 },
-	{ 0x353C, 0x0BCB, WORD_LEN, 0 },
-	{ 0x3550, 0x04EF, WORD_LEN, 0 },
-	{ 0x3548, 0x0609, WORD_LEN, 0 },
-	{ 0x3560, 0x0580, WORD_LEN, 0 },
-	{ 0x3558, 0x05DD, WORD_LEN, 0 },
-	{ 0x3540, 0x0000, WORD_LEN, 0 },
-	{ 0x3542, 0x0000, WORD_LEN, 0 }
-};
-
-static const struct mt9d112_i2c_reg_conf const pll_setup_tbl[] = {
-	{ 0x341E, 0x8F09, WORD_LEN, 0 },
-	{ 0x341C, 0x0250, WORD_LEN, 0 },
-	{ 0x341E, 0x8F09, WORD_LEN, 5 },
-	{ 0x341E, 0x8F08, WORD_LEN, 0 }
-};
-
-/* Refresh Sequencer */
-static const struct mt9d112_i2c_reg_conf const sequencer_tbl[] = {
-	{ 0x338C, 0x2799, WORD_LEN, 0},
-	{ 0x3390, 0x6440, WORD_LEN, 5},
-	{ 0x338C, 0x279B, WORD_LEN, 0},
-	{ 0x3390, 0x6440, WORD_LEN, 5},
-	{ 0x338C, 0xA103, WORD_LEN, 0},
-	{ 0x3390, 0x0005, WORD_LEN, 5},
-	{ 0x338C, 0xA103, WORD_LEN, 0},
-	{ 0x3390, 0x0006, WORD_LEN, 5}
-};
-
-struct mt9d112_reg mt9d112_regs = {
-	.prev_snap_reg_settings = &preview_snapshot_mode_reg_settings_array[0],
-	.prev_snap_reg_settings_size = ARRAY_SIZE(
-		preview_snapshot_mode_reg_settings_array),
-	.noise_reduction_reg_settings = &noise_reduction_reg_settings_array[0],
-	.noise_reduction_reg_settings_size = ARRAY_SIZE(
-		noise_reduction_reg_settings_array),
-	.plltbl = pll_setup_tbl,
-	.plltbl_size = ARRAY_SIZE(pll_setup_tbl),
-	.stbl = sequencer_tbl,
-	.stbl_size = ARRAY_SIZE(sequencer_tbl),
-	.rftbl = lens_roll_off_tbl,
-	.rftbl_size = ARRAY_SIZE(lens_roll_off_tbl)
-};
-
-
-
diff --git a/drivers/media/platform/msm/camera_v1/mt9d113.c b/drivers/media/platform/msm/camera_v1/mt9d113.c
deleted file mode 100644
index a32c804..0000000
--- a/drivers/media/platform/msm/camera_v1/mt9d113.c
+++ /dev/null
@@ -1,656 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- *
- */
-
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include <linux/types.h>
-#include <linux/i2c.h>
-#include <linux/uaccess.h>
-#include <linux/miscdevice.h>
-#include <media/msm_camera.h>
-#include <mach/gpio.h>
-#include "mt9d113.h"
-
-/* Micron MT9D113 Registers and their values */
-#define  REG_MT9D113_MODEL_ID	0x0000
-#define  MT9D113_MODEL_ID		0x2580
-#define Q8						0x00000100
-
-struct mt9d113_work {
-	struct work_struct work;
-};
-
-static struct  mt9d113_work *mt9d113_sensorw;
-static struct  i2c_client *mt9d113_client;
-
-struct mt9d113_ctrl {
-	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 */
-	uint16_t fps;
-	uint16_t curr_step_pos;
-	uint16_t my_reg_gain;
-	uint32_t my_reg_line_count;
-	uint16_t total_lines_per_frame;
-	uint16_t config_csi;
-	enum mt9d113_resolution_t prev_res;
-	enum mt9d113_resolution_t pict_res;
-	enum mt9d113_resolution_t curr_res;
-	enum mt9d113_test_mode_t  set_test;
-};
-
-static struct mt9d113_ctrl *mt9d113_ctrl;
-
-static DECLARE_WAIT_QUEUE_HEAD(mt9d113_wait_queue);
-DEFINE_MUTEX(mt9d113_mut);
-
-static int mt9d113_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(mt9d113_client->adapter, msgs, 2) < 0) {
-		CDBG("mt9d113_i2c_rxdata failed!\n");
-		return -EIO;
-	}
-	return 0;
-}
-
-static int32_t mt9d113_i2c_read(unsigned short   saddr,
-				unsigned short raddr,
-				unsigned short *rdata,
-				enum mt9d113_width width)
-{
-	int32_t rc = 0;
-	unsigned char buf[4];
-	if (!rdata)
-		return -EIO;
-	memset(buf, 0, sizeof(buf));
-	switch (width) {
-	case WORD_LEN: {
-			buf[0] = (raddr & 0xFF00)>>8;
-			buf[1] = (raddr & 0x00FF);
-			rc = mt9d113_i2c_rxdata(saddr, buf, 2);
-			if (rc < 0)
-				return rc;
-			*rdata = buf[0] << 8 | buf[1];
-		}
-		break;
-	default:
-		break;
-	}
-	if (rc < 0)
-		CDBG("mt9d113_i2c_read failed !\n");
-	return rc;
-}
-
-static int32_t mt9d113_i2c_txdata(unsigned short saddr,
-				unsigned char *txdata, int length)
-{
-	struct i2c_msg msg[] = {
-		{
-			.addr = saddr,
-			.flags = 0,
-			.len = length,
-			.buf = txdata,
-		},
-	};
-	if (i2c_transfer(mt9d113_client->adapter, msg, 1) < 0) {
-		CDBG("mt9d113_i2c_txdata failed\n");
-		return -EIO;
-	}
-	return 0;
-}
-
-static int32_t mt9d113_i2c_write(unsigned short saddr,
-				unsigned short waddr,
-				unsigned short wdata,
-				enum mt9d113_width width)
-{
-	int32_t rc = -EIO;
-	unsigned char buf[4];
-	memset(buf, 0, sizeof(buf));
-	switch (width) {
-	case WORD_LEN: {
-			buf[0] = (waddr & 0xFF00)>>8;
-			buf[1] = (waddr & 0x00FF);
-			buf[2] = (wdata & 0xFF00)>>8;
-			buf[3] = (wdata & 0x00FF);
-			rc = mt9d113_i2c_txdata(saddr, buf, 4);
-		}
-		break;
-	case BYTE_LEN: {
-			buf[0] = waddr;
-			buf[1] = wdata;
-			rc = mt9d113_i2c_txdata(saddr, buf, 2);
-		}
-		break;
-	default:
-		break;
-	}
-	if (rc < 0)
-		printk(KERN_ERR
-			"i2c_write failed, addr = 0x%x, val = 0x%x!\n",
-			waddr, wdata);
-	return rc;
-}
-
-static int32_t mt9d113_i2c_write_table(
-				struct mt9d113_i2c_reg_conf
-				const *reg_conf_tbl,
-				int num_of_items_in_table)
-{
-	int i;
-	int32_t rc = -EIO;
-	for (i = 0; i < num_of_items_in_table; i++) {
-		rc = mt9d113_i2c_write(mt9d113_client->addr,
-				reg_conf_tbl->waddr, reg_conf_tbl->wdata,
-				WORD_LEN);
-		if (rc < 0)
-			break;
-		reg_conf_tbl++;
-	}
-	return rc;
-}
-
-static long mt9d113_reg_init(void)
-{
-	uint16_t data = 0;
-	int32_t rc = 0;
-	int count = 0;
-	struct msm_camera_csi_params mt9d113_csi_params;
-	if (!mt9d113_ctrl->config_csi) {
-		mt9d113_csi_params.lane_cnt = 1;
-		mt9d113_csi_params.data_format = CSI_8BIT;
-		mt9d113_csi_params.lane_assign = 0xe4;
-		mt9d113_csi_params.dpcm_scheme = 0;
-		mt9d113_csi_params.settle_cnt = 0x14;
-		rc = msm_camio_csi_config(&mt9d113_csi_params);
-		mt9d113_ctrl->config_csi = 1;
-		msleep(50);
-	}
-	/* Disable parallel and enable mipi*/
-	rc = mt9d113_i2c_write(mt9d113_client->addr,
-				0x001A,
-				0x0051, WORD_LEN);
-	rc = mt9d113_i2c_write(mt9d113_client->addr,
-				0x001A,
-				0x0050,
-				WORD_LEN);
-	msleep(20);
-	rc = mt9d113_i2c_write(mt9d113_client->addr,
-				0x001A,
-				0x0058,
-				WORD_LEN);
-
-	/* Preset pll settings begin*/
-	rc = mt9d113_i2c_write_table(&mt9d113_regs.pll_tbl[0],
-				mt9d113_regs.pll_tbl_size);
-	if (rc < 0)
-		return rc;
-	rc = mt9d113_i2c_read(mt9d113_client->addr,
-				0x0014, &data, WORD_LEN);
-	data = data&0x8000;
-	/* Poll*/
-	while (data == 0x0000) {
-		data = 0;
-		rc = mt9d113_i2c_read(mt9d113_client->addr,
-				0x0014, &data, WORD_LEN);
-		data = data & 0x8000;
-		usleep_range(11000, 12000);
-		count++;
-		if (count == 100) {
-			CDBG(" Timeout:1\n");
-			break;
-		}
-	}
-	rc = mt9d113_i2c_write(mt9d113_client->addr,
-				0x0014,
-				0x20FA,
-				WORD_LEN);
-
-	/*Preset pll Ends*/
-	mt9d113_i2c_write(mt9d113_client->addr,
-				0x0018,
-				0x402D,
-				WORD_LEN);
-
-	mt9d113_i2c_write(mt9d113_client->addr,
-				0x0018,
-				0x402C,
-				WORD_LEN);
-	/*POLL_REG=0x0018,0x4000,!=0x0000,DELAY=10,TIMEOUT=100*/
-	data = 0;
-	rc = mt9d113_i2c_read(mt9d113_client->addr,
-		0x0018, &data, WORD_LEN);
-	data = data & 0x4000;
-	count = 0;
-	while (data != 0x0000) {
-		rc = mt9d113_i2c_read(mt9d113_client->addr,
-			0x0018, &data, WORD_LEN);
-		data = data & 0x4000;
-		CDBG(" data is %d\n" , data);
-		usleep_range(11000, 12000);
-		count++;
-		if (count == 100) {
-			CDBG(" Loop2 timeout: MT9D113\n");
-			break;
-		}
-		CDBG(" Not streaming\n");
-	}
-	CDBG("MT9D113: Start stream\n");
-	/*Preset Register Wizard Conf*/
-	rc = mt9d113_i2c_write_table(&mt9d113_regs.register_tbl[0],
-				mt9d113_regs.register_tbl_size);
-	if (rc < 0)
-		return rc;
-	rc = mt9d113_i2c_write_table(&mt9d113_regs.err_tbl[0],
-				mt9d113_regs.err_tbl_size);
-	if (rc < 0)
-		return rc;
-	rc = mt9d113_i2c_write_table(&mt9d113_regs.eeprom_tbl[0],
-				mt9d113_regs.eeprom_tbl_size);
-	if (rc < 0)
-		return rc;
-
-	rc = mt9d113_i2c_write_table(&mt9d113_regs.low_light_tbl[0],
-				mt9d113_regs.low_light_tbl_size);
-	if (rc < 0)
-		return rc;
-
-	rc = mt9d113_i2c_write_table(&mt9d113_regs.awb_tbl[0],
-				mt9d113_regs.awb_tbl_size);
-	if (rc < 0)
-		return rc;
-
-	rc = mt9d113_i2c_write_table(&mt9d113_regs.patch_tbl[0],
-				mt9d113_regs.patch_tbl_size);
-	if (rc < 0)
-		return rc;
-
-	/*check patch load*/
-	mt9d113_i2c_write(mt9d113_client->addr,
-				0x098C,
-				0xA024,
-				WORD_LEN);
-	count = 0;
-	/*To check if patch is loaded properly
-	poll the register 0x990 till the condition is
-	met or till the timeout*/
-	data = 0;
-	rc = mt9d113_i2c_read(mt9d113_client->addr,
-				0x0990, &data, WORD_LEN);
-	while (data == 0) {
-		data = 0;
-		rc = mt9d113_i2c_read(mt9d113_client->addr,
-				0x0990, &data, WORD_LEN);
-		usleep_range(11000, 12000);
-		count++;
-		if (count == 100) {
-			CDBG("Timeout in patch loading\n");
-			break;
-		}
-	}
-		/*BITFIELD=0x0018, 0x0004, 0*/
-	/*Preset continue begin */
-	rc = mt9d113_i2c_write(mt9d113_client->addr, 0x0018, 0x0028,
-				WORD_LEN);
-	CDBG(" mt9d113 wait for seq done\n");
-	/* syncronize the FW with the sensor
-	MCU_ADDRESS [SEQ_CMD]*/
-	rc = mt9d113_i2c_write(mt9d113_client->addr,
-				0x098C, 0xA103, WORD_LEN);
-	rc = mt9d113_i2c_write(mt9d113_client->addr,
-				0x0990, 0x0006, WORD_LEN);
-		/*mt9d113 wait for seq done
-	 syncronize the FW with the sensor */
-	msleep(20);
-	/*Preset continue end */
-	CDBG(" MT9D113: Preset continue end\n");
-	rc = mt9d113_i2c_write(mt9d113_client->addr,
-				0x0012,
-				0x00F5,
-				WORD_LEN);
-	/*continue begin */
-	CDBG(" MT9D113: Preset continue begin\n");
-	rc = mt9d113_i2c_write(mt9d113_client->addr, 0x0018, 0x0028 ,
-				WORD_LEN);
-	/*mt9d113 wait for seq done
-	 syncronize the FW with the sensor
-	MCU_ADDRESS [SEQ_CMD]*/
-	msleep(20);
-	rc = mt9d113_i2c_write(mt9d113_client->addr,
-				0x098C, 0xA103, WORD_LEN);
-	/* MCU DATA */
-	rc = mt9d113_i2c_write(mt9d113_client->addr, 0x0990,
-				0x0006, WORD_LEN);
-	/*mt9d113 wait for seq done
-	syncronize the FW with the sensor */
-	/* MCU_ADDRESS [SEQ_CMD]*/
-	msleep(20);
-	/*Preset continue end*/
-	return rc;
-
-}
-
-static long mt9d113_set_sensor_mode(int mode)
-{
-	long rc = 0;
-	switch (mode) {
-	case SENSOR_PREVIEW_MODE:
-		rc = mt9d113_reg_init();
-		CDBG("MT9D113: configure to preview begin\n");
-		rc =
-		mt9d113_i2c_write(mt9d113_client->addr,
-						0x098C, 0xA115, WORD_LEN);
-		if (rc < 0)
-			return rc;
-		rc =
-		mt9d113_i2c_write(mt9d113_client->addr,
-						0x0990, 0x0000, WORD_LEN);
-		if (rc < 0)
-			return rc;
-		rc =
-		mt9d113_i2c_write(mt9d113_client->addr,
-						0x098C, 0xA103, WORD_LEN);
-		if (rc < 0)
-			return rc;
-		rc =
-		mt9d113_i2c_write(mt9d113_client->addr,
-						0x0990, 0x0001, WORD_LEN);
-		if (rc < 0)
-			return rc;
-		break;
-	case SENSOR_SNAPSHOT_MODE:
-	case SENSOR_RAW_SNAPSHOT_MODE:
-		rc =
-		mt9d113_i2c_write(mt9d113_client->addr,
-						0x098C, 0xA115, WORD_LEN);
-		rc =
-		mt9d113_i2c_write(mt9d113_client->addr,
-						0x0990, 0x0002, WORD_LEN);
-		rc =
-		mt9d113_i2c_write(mt9d113_client->addr,
-						0x098C, 0xA103, WORD_LEN);
-		rc =
-		mt9d113_i2c_write(mt9d113_client->addr,
-						0x0990, 0x0002, WORD_LEN);
-		break;
-	default:
-		return -EINVAL;
-	}
-	return 0;
-}
-
-static int mt9d113_sensor_init_probe(const struct
-				msm_camera_sensor_info * data)
-{
-	uint16_t model_id = 0;
-	int rc = 0;
-	/* Read the Model ID of the sensor */
-	rc = mt9d113_i2c_read(mt9d113_client->addr,
-						REG_MT9D113_MODEL_ID,
-						&model_id, WORD_LEN);
-	if (rc < 0)
-		goto init_probe_fail;
-	/* Check if it matches it with the value in Datasheet */
-	if (model_id != MT9D113_MODEL_ID)
-		printk(KERN_INFO "mt9d113 model_id = 0x%x\n", model_id);
-	if (rc < 0)
-		goto init_probe_fail;
-	return rc;
-init_probe_fail:
-	printk(KERN_INFO "probe fail\n");
-	return rc;
-}
-
-static int mt9d113_init_client(struct i2c_client *client)
-{
-	/* Initialize the MSM_CAMI2C Chip */
-	init_waitqueue_head(&mt9d113_wait_queue);
-	return 0;
-}
-
-int mt9d113_sensor_config(void __user *argp)
-{
-	struct sensor_cfg_data cfg_data;
-	long rc = 0;
-
-	if (copy_from_user(&cfg_data,
-					(void *)argp,
-					(sizeof(struct sensor_cfg_data))))
-		return -EFAULT;
-	mutex_lock(&mt9d113_mut);
-	CDBG("mt9d113_ioctl, cfgtype = %d, mode = %d\n",
-		 cfg_data.cfgtype, cfg_data.mode);
-	switch (cfg_data.cfgtype) {
-	case CFG_SET_MODE:
-		rc = mt9d113_set_sensor_mode(
-						cfg_data.mode);
-		break;
-	case CFG_SET_EFFECT:
-		return rc;
-	case CFG_GET_AF_MAX_STEPS:
-	default:
-		rc = -EINVAL;
-		break;
-	}
-	mutex_unlock(&mt9d113_mut);
-	return rc;
-}
-
-int mt9d113_sensor_release(void)
-{
-	int rc = 0;
-
-	mutex_lock(&mt9d113_mut);
-	gpio_set_value_cansleep(mt9d113_ctrl->sensordata->sensor_reset, 0);
-	msleep(20);
-	gpio_free(mt9d113_ctrl->sensordata->sensor_reset);
-	kfree(mt9d113_ctrl);
-	mutex_unlock(&mt9d113_mut);
-
-	return rc;
-}
-
-static int mt9d113_probe_init_done(const struct msm_camera_sensor_info
-				*data)
-{
-	gpio_free(data->sensor_reset);
-	return 0;
-}
-
-static int mt9d113_probe_init_sensor(const struct msm_camera_sensor_info
-				*data)
-{
-	int32_t rc = 0;
-	uint16_t chipid = 0;
-
-	rc = gpio_request(data->sensor_reset, "mt9d113");
-	printk(KERN_INFO " mt9d113_probe_init_sensor\n");
-	if (!rc) {
-		printk(KERN_INFO "sensor_reset = %d\n", rc);
-		gpio_direction_output(data->sensor_reset, 0);
-		usleep_range(11000, 12000);
-		gpio_set_value_cansleep(data->sensor_reset, 1);
-		usleep_range(11000, 12000);
-	} else
-		goto init_probe_done;
-	printk(KERN_INFO " mt9d113_probe_init_sensor called\n");
-	rc = mt9d113_i2c_read(mt9d113_client->addr, REG_MT9D113_MODEL_ID,
-						&chipid, WORD_LEN);
-	if (rc < 0)
-		goto init_probe_fail;
-	/*Compare sensor ID to MT9D113 ID: */
-	if (chipid != MT9D113_MODEL_ID) {
-		printk(KERN_INFO "mt9d113_probe_init_sensor chip id is%d\n",
-			chipid);
-	}
-	CDBG("mt9d113_probe_init_sensor Success\n");
-	goto init_probe_done;
-init_probe_fail:
-	CDBG(" ov2720_probe_init_sensor fails\n");
-	gpio_set_value_cansleep(data->sensor_reset, 0);
-	mt9d113_probe_init_done(data);
-init_probe_done:
-	printk(KERN_INFO " mt9d113_probe_init_sensor finishes\n");
-	return rc;
-}
-
-static int mt9d113_i2c_probe(struct i2c_client *client,
-				const struct i2c_device_id *id)
-{
-	int rc = 0;
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		rc = -ENOTSUPP;
-		goto probe_failure;
-	}
-	mt9d113_sensorw =
-	kzalloc(sizeof(struct mt9d113_work), GFP_KERNEL);
-	if (!mt9d113_sensorw) {
-		rc = -ENOMEM;
-		goto probe_failure;
-	}
-	i2c_set_clientdata(client, mt9d113_sensorw);
-	mt9d113_init_client(client);
-	mt9d113_client = client;
-	CDBG("mt9d113_probe succeeded!\n");
-	return 0;
-probe_failure:
-	kfree(mt9d113_sensorw);
-	mt9d113_sensorw = NULL;
-	CDBG("mt9d113_probe failed!\n");
-	return rc;
-}
-
-static const struct i2c_device_id mt9d113_i2c_id[] = {
-	{ "mt9d113", 0},
-	{},
-};
-
-static struct i2c_driver mt9d113_i2c_driver = {
-	.id_table = mt9d113_i2c_id,
-	.probe  = mt9d113_i2c_probe,
-	.remove = __exit_p(mt9d113_i2c_remove),
-			  .driver = {
-		.name = "mt9d113",
-	},
-};
-
-int mt9d113_sensor_open_init(const struct msm_camera_sensor_info *data)
-{
-	int32_t rc = 0;
-	mt9d113_ctrl = kzalloc(sizeof(struct mt9d113_ctrl), GFP_KERNEL);
-	if (!mt9d113_ctrl) {
-		printk(KERN_INFO "mt9d113_init failed!\n");
-		rc = -ENOMEM;
-		goto init_done;
-	}
-	mt9d113_ctrl->fps_divider = 1 * 0x00000400;
-	mt9d113_ctrl->pict_fps_divider = 1 * 0x00000400;
-	mt9d113_ctrl->set_test = TEST_OFF;
-	mt9d113_ctrl->config_csi = 0;
-	mt9d113_ctrl->prev_res = QTR_SIZE;
-	mt9d113_ctrl->pict_res = FULL_SIZE;
-	mt9d113_ctrl->curr_res = INVALID_SIZE;
-	if (data)
-		mt9d113_ctrl->sensordata = data;
-	if (rc < 0) {
-		printk(KERN_INFO "mt9d113_sensor_open_init fail\n");
-		return rc;
-	}
-		/* enable mclk first */
-		msm_camio_clk_rate_set(24000000);
-		msleep(20);
-		rc = mt9d113_probe_init_sensor(data);
-		if (rc < 0)
-			goto init_fail;
-		mt9d113_ctrl->fps = 30*Q8;
-		rc = mt9d113_sensor_init_probe(data);
-		if (rc < 0) {
-			gpio_set_value_cansleep(data->sensor_reset, 0);
-			goto init_fail;
-		} else
-			printk(KERN_ERR "%s: %d\n", __func__, __LINE__);
-		goto init_done;
-init_fail:
-		printk(KERN_INFO "init_fail\n");
-		mt9d113_probe_init_done(data);
-init_done:
-		CDBG("init_done\n");
-		return rc;
-}
-
-static int mt9d113_sensor_probe(const struct msm_camera_sensor_info
-				*info,
-				struct msm_sensor_ctrl *s)
-{
-	int rc = 0;
-	rc = i2c_add_driver(&mt9d113_i2c_driver);
-	if (rc < 0 || mt9d113_client == NULL) {
-		rc = -ENOTSUPP;
-		goto probe_fail;
-	}
-	msm_camio_clk_rate_set(24000000);
-	usleep_range(5000, 6000);
-	rc = mt9d113_probe_init_sensor(info);
-	if (rc < 0)
-		goto probe_fail;
-	s->s_init = mt9d113_sensor_open_init;
-	s->s_release = mt9d113_sensor_release;
-	s->s_config  = mt9d113_sensor_config;
-	s->s_camera_type = FRONT_CAMERA_2D;
-	s->s_mount_angle  = 0;
-	gpio_set_value_cansleep(info->sensor_reset, 0);
-	mt9d113_probe_init_done(info);
-	return rc;
-probe_fail:
-	printk(KERN_INFO "mt9d113_sensor_probe: SENSOR PROBE FAILS!\n");
-	return rc;
-}
-
-static int __mt9d113_probe(struct platform_device *pdev)
-{
-	return msm_camera_drv_start(pdev, mt9d113_sensor_probe);
-}
-
-static struct platform_driver msm_camera_driver = {
-	.probe = __mt9d113_probe,
-	.driver = {
-		.name = "msm_cam_mt9d113",
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init mt9d113_init(void)
-{
-	return platform_driver_register(&msm_camera_driver);
-}
-
-module_init(mt9d113_init);
-
-MODULE_DESCRIPTION("Micron 2MP YUV sensor driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/mt9d113.h b/drivers/media/platform/msm/camera_v1/mt9d113.h
deleted file mode 100644
index 4aedc5e..0000000
--- a/drivers/media/platform/msm/camera_v1/mt9d113.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- *
- */
-
-#ifndef MT9D113_H
-#define MT9D113_H
-
-#include <linux/types.h>
-#include <mach/camera.h>
-
-extern struct mt9d113_reg mt9d113_regs;
-
-enum mt9d113_width {
-	WORD_LEN,
-	BYTE_LEN
-};
-
-struct mt9d113_i2c_reg_conf {
-	unsigned short waddr;
-	unsigned short wdata;
-};
-
-struct mt9d113_reg {
-	const struct mt9d113_i2c_reg_conf *pll_tbl;
-	uint16_t pll_tbl_size;
-	const struct mt9d113_i2c_reg_conf *register_tbl;
-	uint16_t register_tbl_size;
-	const struct mt9d113_i2c_reg_conf *err_tbl;
-	uint16_t err_tbl_size;
-	const struct mt9d113_i2c_reg_conf *low_light_tbl;
-	uint16_t low_light_tbl_size;
-	const struct mt9d113_i2c_reg_conf *awb_tbl;
-	uint16_t awb_tbl_size;
-	const struct mt9d113_i2c_reg_conf *patch_tbl;
-	uint16_t patch_tbl_size;
-	const struct mt9d113_i2c_reg_conf *eeprom_tbl ;
-	uint16_t eeprom_tbl_size ;
-};
-
-enum mt9d113_test_mode_t {
-	TEST_OFF,
-	TEST_1,
-	TEST_2,
-	TEST_3
-};
-
-enum mt9d113_resolution_t {
-	QTR_SIZE,
-	FULL_SIZE,
-	INVALID_SIZE
-};
-
-enum mt9d113_setting {
-	RES_PREVIEW,
-	RES_CAPTURE
-};
-#endif /* MT9D113_H */
diff --git a/drivers/media/platform/msm/camera_v1/mt9d113_reg.c b/drivers/media/platform/msm/camera_v1/mt9d113_reg.c
deleted file mode 100644
index 28ff518..0000000
--- a/drivers/media/platform/msm/camera_v1/mt9d113_reg.c
+++ /dev/null
@@ -1,455 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- *
- */
-
-#include "mt9d113.h"
-
-struct mt9d113_i2c_reg_conf const
-	pll_tbl_settings[] = {
-		{0x0014, 0x21F9 }, /*PLL control: BYPASS PLL = 8697*/
-		{0x0010, 0x0115 }, /*PLL Dividers = 277*/
-		{0x0012, 0x0F5  }, /*PLL P Dividers = 245*/
-		{0x0014, 0x21FB }, /*PLL control: PLL_ENABLE on = 8699*/
-		{0x0014, 0x20FB }, /*PLL control: SEL_LOCK_DET on = 8443*/
-};
-
-struct mt9d113_i2c_reg_conf const
-	register_wizard_settings[] = {
-		{0x098C, 0x2719},
-		{0x0990, 0x005A},
-		{0x098C, 0x271B},
-		{0x0990, 0x01BE},
-		{0x098C, 0x271D},
-		{0x0990, 0x0131},
-		{0x098C, 0x271F},
-		{0x0990, 0x02BB},
-		{0x098C, 0x2721},
-		{0x0990, 0x0888},
-		{0x098C, 0x272F},
-		{0x0990, 0x003A},
-		{0x098C, 0x2731},
-		{0x0990, 0x00F6},
-		{0x098C, 0x2733},
-		{0x0990, 0x008B},
-		{0x098C, 0x2735},
-		{0x0990, 0x0521},
-		{0x098C, 0x2737},
-		{0x0990, 0x0888},
-		{0x098C, 0x275F},
-		{0x0990, 0x0194},
-		{0x098C, 0x2761},
-		{0x0990, 0x0014},
-		{0x098C, 0xA765},
-		{0x0990, 0x0044},
-		{0x098C, 0xA24F},
-		{0x0990, 0x0028},
-		{0x098C, 0xA20E},
-		{0x0990, 0x00A0},
-		{0x098C, 0xA20C},
-		{0x0990, 0x000E},
-		{0x098C, 0x2222},
-		{0x0990, 0x00A0},
-		{0x098C, 0x2212},
-		{0x0990, 0x01EE},
-		{0x098C, 0xA408},
-		{0x0990, 0x0026},
-		{0x098C, 0xA409},
-		{0x0990, 0x0029},
-		{0x098C, 0xA40A},
-		{0x0990, 0x002E},
-		{0x098C, 0xA40B},
-		{0x0990, 0x0031},
-		{0x098C, 0x2411},
-		{0x0990, 0x00A0},
-		{0x098C, 0x2413},
-		{0x0990, 0x00C0},
-		{0x098C, 0x2415},
-		{0x0990, 0x00A0},
-		{0x098C, 0x2417},
-		{0x0990, 0x00C0},
-};
-
-struct mt9d113_i2c_reg_conf const
-	err_settings[] = {
-		{0x3084, 0x240C},
-		{0x3092, 0x0A4C},
-		{0x3094, 0x4C4C},
-		{0x3096, 0x4C54},
-};
-
-struct mt9d113_i2c_reg_conf const
-	patch_settings[] = {
-		{0x098C, 0x0415},    /* MCU_ADDRESS*/
-		{0x0990, 0xF601},
-		{0x0992, 0x42C1},
-		{0x0994, 0x0326},
-		{0x0996, 0x11F6},
-		{0x0998, 0x0143},
-		{0x099A, 0xC104},
-		{0x099C, 0x260A},
-		{0x099E, 0xCC04},
-		{0x098C, 0x0425},
-		{0x0990, 0x33BD},
-		{0x0992, 0xA362},
-		{0x0994, 0xBD04},
-		{0x0996, 0x3339},
-		{0x0998, 0xC6FF},
-		{0x099A, 0xF701},
-		{0x099C, 0x6439},
-		{0x099E, 0xFE01},
-		{0x098C, 0x0435},
-		{0x0990, 0x6918},
-		{0x0992, 0xCE03},
-		{0x0994, 0x25CC},
-		{0x0996, 0x0013},
-		{0x0998, 0xBDC2},
-		{0x099A, 0xB8CC},
-		{0x099C, 0x0489},
-		{0x099E, 0xFD03},
-		{0x098C, 0x0445},
-		{0x0990, 0x27CC},
-		{0x0992, 0x0325},
-		{0x0994, 0xFD01},
-		{0x0996, 0x69FE},
-		{0x0998, 0x02BD},
-		{0x099A, 0x18CE},
-		{0x099C, 0x0339},
-		{0x099E, 0xCC00},
-		{0x098C, 0x0455},
-		{0x0990, 0x11BD},
-		{0x0992, 0xC2B8},
-		{0x0994, 0xCC04},
-		{0x0996, 0xC8FD},
-		{0x0998, 0x0347},
-		{0x099A, 0xCC03},
-		{0x099C, 0x39FD},
-		{0x099E, 0x02BD},
-		{0x098C, 0x0465},
-		{0x0990, 0xDE00},
-		{0x0992, 0x18CE},
-		{0x0994, 0x00C2},
-		{0x0996, 0xCC00},
-		{0x0998, 0x37BD},
-		{0x099A, 0xC2B8},
-		{0x099C, 0xCC04},
-		{0x099E, 0xEFDD},
-		{0x098C, 0x0475},
-		{0x0990, 0xE6CC},
-		{0x0992, 0x00C2},
-		{0x0994, 0xDD00},
-		{0x0996, 0xC601},
-		{0x0998, 0xF701},
-		{0x099A, 0x64C6},
-		{0x099C, 0x03F7},
-		{0x099E, 0x0165},
-		{0x098C, 0x0485},
-		{0x0990, 0x7F01},
-		{0x0992, 0x6639},
-		{0x0994, 0x3C3C},
-		{0x0996, 0x3C34},
-		{0x0998, 0xCC32},
-		{0x099A, 0x3EBD},
-		{0x099C, 0xA558},
-		{0x099E, 0x30ED},
-		{0x098C, 0x0495},
-		{0x0990, 0x04BD},
-		{0x0992, 0xB2D7},
-		{0x0994, 0x30E7},
-		{0x0996, 0x06CC},
-		{0x0998, 0x323E},
-		{0x099A, 0xED00},
-		{0x099C, 0xEC04},
-		{0x099E, 0xBDA5},
-		{0x098C, 0x04A5},
-		{0x0990, 0x44CC},
-		{0x0992, 0x3244},
-		{0x0994, 0xBDA5},
-		{0x0996, 0x585F},
-		{0x0998, 0x30ED},
-		{0x099A, 0x02CC},
-		{0x099C, 0x3244},
-		{0x099E, 0xED00},
-		{0x098C, 0x04B5},
-		{0x0990, 0xF601},
-		{0x0992, 0xD54F},
-		{0x0994, 0xEA03},
-		{0x0996, 0xAA02},
-		{0x0998, 0xBDA5},
-		{0x099A, 0x4430},
-		{0x099C, 0xE606},
-		{0x099E, 0x3838},
-		{0x098C, 0x04C5},
-		{0x0990, 0x3831},
-		{0x0992, 0x39BD},
-		{0x0994, 0xD661},
-		{0x0996, 0xF602},
-		{0x0998, 0xF4C1},
-		{0x099A, 0x0126},
-		{0x099C, 0x0BFE},
-		{0x099E, 0x02BD},
-		{0x098C, 0x04D5},
-		{0x0990, 0xEE10},
-		{0x0992, 0xFC02},
-		{0x0994, 0xF5AD},
-		{0x0996, 0x0039},
-		{0x0998, 0xF602},
-		{0x099A, 0xF4C1},
-		{0x099C, 0x0226},
-		{0x099E, 0x0AFE},
-		{0x098C, 0x04E5},
-		{0x0990, 0x02BD},
-		{0x0992, 0xEE10},
-		{0x0994, 0xFC02},
-		{0x0996, 0xF7AD},
-		{0x0998, 0x0039},
-		{0x099A, 0x3CBD},
-		{0x099C, 0xB059},
-		{0x099E, 0xCC00},
-		{0x098C, 0x04F5},
-		{0x0990, 0x28BD},
-		{0x0992, 0xA558},
-		{0x0994, 0x8300},
-		{0x0996, 0x0027},
-		{0x0998, 0x0BCC},
-		{0x099A, 0x0026},
-		{0x099C, 0x30ED},
-		{0x099E, 0x00C6},
-		{0x098C, 0x0505},
-		{0x0990, 0x03BD},
-		{0x0992, 0xA544},
-		{0x0994, 0x3839},
-		{0x098C, 0x2006},
-		{0x0990, 0x0415},
-		{0x098C, 0xA005},
-		{0x0990, 0x0001},
-};
-
-struct mt9d113_i2c_reg_conf const
-	eeprom_settings[] = {
-		{0x3658, 0x0110},
-		{0x365A, 0x1B6D},
-		{0x365C, 0x01F2},
-		{0x365E, 0xFBCD},
-		{0x3660, 0x8C91},
-		{0x3680, 0xB9ED},
-		{0x3682, 0x0EE},
-		{0x3684, 0x256F},
-		{0x3686, 0x824F},
-		{0x3688, 0xD293},
-		{0x36A8, 0x5BF2},
-		{0x36AA, 0x1711},
-		{0x36AC, 0xA095},
-		{0x36AE, 0x642C},
-		{0x36B0, 0x0E38},
-		{0x36D0, 0x88B0},
-		{0x36D2, 0x2EB2},
-		{0x36D4, 0x4C74},
-		{0x36D6, 0x9F96},
-		{0x36D8, 0x9557},
-		{0x36F8, 0xCE51},
-		{0x36FA, 0xB354},
-		{0x36FC, 0x2817},
-		{0x36FE, 0x14B8},
-		{0x3700, 0xB019},
-		{0x364E, 0x0710},
-		{0x3650, 0x30ED},
-		{0x3652, 0x03F2},
-		{0x3654, 0xF12E},
-		{0x3656, 0x8492},
-		{0x3676, 0xD9AD},
-		{0x3678, 0x88D0},
-		{0x367A, 0x7DED},
-		{0x367C, 0x3E31},
-		{0x367E, 0x91B3},
-		{0x369E, 0x7032},
-		{0x36A0, 0x2791},
-		{0x36A2, 0xBB55},
-		{0x36A4, 0xAB32},
-		{0x36A6, 0x1A58},
-		{0x36C6, 0xB50F},
-		{0x36C8, 0x0011},
-		{0x36CA, 0x6DB4},
-		{0x36CC, 0x96F5},
-		{0x36CE, 0x9BB7},
-		{0x36EE, 0x9353},
-		{0x36F0, 0xDF74},
-		{0x36F2, 0x04F8},
-		{0x36F4, 0x0FD8},
-		{0x36F6, 0xA87A},
-		{0x3662, 0x0170},
-		{0x3664, 0x6F0C},
-		{0x3666, 0x0112},
-		{0x3668, 0xCBAB},
-		{0x366A, 0x9111},
-		{0x368A, 0xB38D},
-		{0x368C, 0xE96F},
-		{0x368E, 0xCC0F},
-		{0x3690, 0x5851},
-		{0x3692, 0xFDD2},
-		{0x36B2, 0x5F92},
-		{0x36B4, 0x33B2},
-		{0x36B6, 0x9815},
-		{0x36B8, 0x86F5},
-		{0x36BA, 0x0578},
-		{0x36DA, 0xCD90},
-		{0x36DC, 0x1131},
-		{0x36DE, 0x5275},
-		{0x36E0, 0xE855},
-		{0x36E2, 0xD037},
-		{0x3702, 0xAAD1},
-		{0x3704, 0xEB75},
-		{0x3706, 0x0CD7},
-		{0x3708, 0x2C79},
-		{0x370A, 0xE0B9},
-		{0x366C, 0x0190},
-		{0x366E, 0x1C8D},
-		{0x3670, 0x0052},
-		{0x3672, 0xD66E},
-		{0x3674, 0xF511},
-		{0x3694, 0xB54D},
-		{0x3696, 0x6E4E},
-		{0x3698, 0x142E},
-		{0x369A, 0xC190},
-		{0x369C, 0xA753},
-		{0x36BC, 0x70F2},
-		{0x36BE, 0x04F1},
-		{0x36C0, 0xBD95},
-		{0x36C2, 0x0CEE},
-		{0x36C4, 0x1BF8},
-		{0x36E4, 0x806F},
-		{0x36E6, 0x1672},
-		{0x36E8, 0x2DF4},
-		{0x36EA, 0x8F16},
-		{0x36EC, 0xF776},
-		{0x370C, 0xAD73},
-		{0x370E, 0xB534},
-		{0x3710, 0x0D18},
-		{0x3712, 0x6057},
-		{0x3714, 0xBD1A},
-		{0x3644, 0x0354},
-		{0x3642, 0x0234},
-		{0x3210, 0x01B8},
-};
-
-struct mt9d113_i2c_reg_conf const
-	awb_settings[] = {
-		{0x098C, 0x2306},
-		{0x0990, 0x0180},
-		{0x098C, 0x2308},
-		{0x0990, 0xFF00},
-		{0x098C, 0x230A},
-		{0x0990, 0x0080},
-		{0x098C, 0x230C},
-		{0x0990, 0xFF66},
-		{0x098C, 0x230E},
-		{0x0990, 0x0180},
-		{0x098C, 0x2310},
-		{0x0990, 0xFFEE},
-		{0x098C, 0x2312},
-		{0x0990, 0xFFCD},
-		{0x098C, 0x2314},
-		{0x0990, 0xFECD},
-		{0x098C, 0x2316},
-		{0x0990, 0x019A},
-		{0x098C, 0x2318},
-		{0x0990, 0x0020},
-		{0x098C, 0x231A},
-		{0x0990, 0x0033},
-		{0x098C, 0x231C},
-		{0x0990, 0x0100},
-		{0x098C, 0x231E},
-		{0x0990, 0xFF9A},
-		{0x098C, 0x2320},
-		{0x0990, 0x0000},
-		{0x098C, 0x2322},
-		{0x0990, 0x004D},
-		{0x098C, 0x2324},
-		{0x0990, 0xFFCD},
-		{0x098C, 0x2326},
-		{0x0990, 0xFFB8},
-		{0x098C, 0x2328},
-		{0x0990, 0x004D},
-		{0x098C, 0x232A},
-		{0x0990, 0x0080},
-		{0x098C, 0x232C},
-		{0x0990, 0xFF66},
-		{0x098C, 0x232E},
-		{0x0990, 0x0008},
-		{0x098C, 0x2330},
-		{0x0990, 0xFFF7},
-		{0x098C, 0xA363},
-		{0x0990, 0x00D2},
-		{0x098C, 0xA364},
-		{0x0990, 0x00EE},
-		{0x3244, 0x0328},
-		{0x323E, 0xC22C},
-};
-
-struct mt9d113_i2c_reg_conf const
-	low_light_setting[] = {
-		{0x098C, 0x2B28},
-		{0x0990, 0x35E8},
-		{0x098C, 0x2B2A},
-		{0x0990, 0xB3B0},
-		{0x098C, 0xAB20},
-		{0x0990, 0x004B},
-		{0x098C, 0xAB24},
-		{0x0990, 0x0000},
-		{0x098C, 0xAB25},
-		{0x0990, 0x00FF},
-		{0x098C, 0xAB30},
-		{0x0990, 0x00FF},
-		{0x098C, 0xAB31},
-		{0x0990, 0x00FF},
-		{0x098C, 0xAB32},
-		{0x0990, 0x00FF},
-		{0x098C, 0xAB33},
-		{0x0990, 0x0057},
-		{0x098C, 0xAB34},
-		{0x0990, 0x0080},
-		{0x098C, 0xAB35},
-		{0x0990, 0x00FF},
-		{0x098C, 0xAB36},
-		{0x0990, 0x0014},
-		{0x098C, 0xAB37},
-		{0x0990, 0x0003},
-		{0x098C, 0x2B38},
-		{0x0990, 0x32C8},
-		{0x098C, 0x2B3A},
-		{0x0990, 0x7918},
-		{0x098C, 0x2B62},
-		{0x0990, 0xFFFE},
-		{0x098C, 0x2B64},
-		{0x0990, 0xFFFF},
-};
-
-struct mt9d113_reg mt9d113_regs = {
-		.pll_tbl = pll_tbl_settings,
-		.pll_tbl_size = ARRAY_SIZE(
-			pll_tbl_settings),
-		.register_tbl = register_wizard_settings,
-		.register_tbl_size = ARRAY_SIZE(
-			register_wizard_settings),
-		.err_tbl = err_settings,
-		.err_tbl_size = ARRAY_SIZE(err_settings),
-		.low_light_tbl = low_light_setting,
-		.low_light_tbl_size = ARRAY_SIZE(low_light_setting),
-		.awb_tbl = awb_settings,
-		.awb_tbl_size = ARRAY_SIZE(awb_settings),
-		.patch_tbl = patch_settings,
-		.patch_tbl_size = ARRAY_SIZE(patch_settings),
-		.eeprom_tbl = eeprom_settings,
-		.eeprom_tbl_size = ARRAY_SIZE(eeprom_settings),
-};
-
-
-
diff --git a/drivers/media/platform/msm/camera_v1/mt9e013.c b/drivers/media/platform/msm/camera_v1/mt9e013.c
deleted file mode 100644
index f91bec4..0000000
--- a/drivers/media/platform/msm/camera_v1/mt9e013.c
+++ /dev/null
@@ -1,1140 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- *
- */
-
-#include <linux/delay.h>
-#include <linux/debugfs.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/gpio.h>
-#include <mach/camera.h>
-#include "mt9e013.h"
-/*=============================================================
-	SENSOR REGISTER DEFINES
-==============================================================*/
-#define REG_GROUPED_PARAMETER_HOLD		0x0104
-#define GROUPED_PARAMETER_HOLD_OFF		0x00
-#define GROUPED_PARAMETER_HOLD			0x01
-/* Integration Time */
-#define REG_COARSE_INTEGRATION_TIME		0x3012
-/* Gain */
-#define REG_GLOBAL_GAIN	0x305E
-/* PLL registers */
-#define REG_FRAME_LENGTH_LINES		0x0340
-/* Test Pattern */
-#define REG_TEST_PATTERN_MODE			0x0601
-#define REG_VCM_NEW_CODE			0x30F2
-
-/*============================================================================
-							 TYPE DECLARATIONS
-============================================================================*/
-
-/* 16bit address - 8 bit context register structure */
-#define Q8	0x00000100
-#define Q10	0x00000400
-#define MT9E013_MASTER_CLK_RATE 24000000
-
-/* AF Total steps parameters */
-#define MT9E013_TOTAL_STEPS_NEAR_TO_FAR    32
-
-uint16_t mt9e013_step_position_table[MT9E013_TOTAL_STEPS_NEAR_TO_FAR+1];
-uint16_t mt9e013_nl_region_boundary1;
-uint16_t mt9e013_nl_region_code_per_step1;
-uint16_t mt9e013_l_region_code_per_step = 4;
-uint16_t mt9e013_damping_threshold = 10;
-uint16_t mt9e013_sw_damping_time_wait = 1;
-
-struct mt9e013_work_t {
-	struct work_struct work;
-};
-
-static struct mt9e013_work_t *mt9e013_sensorw;
-static struct i2c_client *mt9e013_client;
-
-struct mt9e013_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 */
-	uint16_t fps;
-
-	uint16_t curr_lens_pos;
-	uint16_t curr_step_pos;
-	uint16_t my_reg_gain;
-	uint32_t my_reg_line_count;
-	uint16_t total_lines_per_frame;
-
-	enum mt9e013_resolution_t prev_res;
-	enum mt9e013_resolution_t pict_res;
-	enum mt9e013_resolution_t curr_res;
-	enum mt9e013_test_mode_t  set_test;
-};
-
-
-static bool CSI_CONFIG;
-static struct mt9e013_ctrl_t *mt9e013_ctrl;
-static DECLARE_WAIT_QUEUE_HEAD(mt9e013_wait_queue);
-DEFINE_MUTEX(mt9e013_mut);
-
-static int cam_debug_init(void);
-static struct dentry *debugfs_base;
-/*=============================================================*/
-
-static int mt9e013_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   = 2,
-			.buf   = rxdata,
-		},
-	};
-	if (i2c_transfer(mt9e013_client->adapter, msgs, 2) < 0) {
-		CDBG("mt9e013_i2c_rxdata faild 0x%x\n", saddr);
-		return -EIO;
-	}
-	return 0;
-}
-
-static int32_t mt9e013_i2c_txdata(unsigned short saddr,
-				unsigned char *txdata, int length)
-{
-	struct i2c_msg msg[] = {
-		{
-			.addr = saddr,
-			.flags = 0,
-			.len = length,
-			.buf = txdata,
-		 },
-	};
-	if (i2c_transfer(mt9e013_client->adapter, msg, 1) < 0) {
-		CDBG("mt9e013_i2c_txdata faild 0x%x\n", saddr);
-		return -EIO;
-	}
-
-	return 0;
-}
-
-static int32_t mt9e013_i2c_read(unsigned short raddr,
-	unsigned short *rdata, int rlen)
-{
-	int32_t rc = 0;
-	unsigned char buf[2];
-	if (!rdata)
-		return -EIO;
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (raddr & 0xFF00) >> 8;
-	buf[1] = (raddr & 0x00FF);
-	rc = mt9e013_i2c_rxdata(mt9e013_client->addr<<1, buf, rlen);
-	if (rc < 0) {
-		CDBG("mt9e013_i2c_read 0x%x failed!\n", raddr);
-		return rc;
-	}
-	*rdata = (rlen == 2 ? buf[0] << 8 | buf[1] : buf[0]);
-	CDBG("mt9e013_i2c_read 0x%x val = 0x%x!\n", raddr, *rdata);
-	return rc;
-}
-
-static int32_t mt9e013_i2c_write_w_sensor(unsigned short waddr, uint16_t wdata)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[4];
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00) >> 8;
-	buf[1] = (waddr & 0x00FF);
-	buf[2] = (wdata & 0xFF00) >> 8;
-	buf[3] = (wdata & 0x00FF);
-	CDBG("i2c_write_b addr = 0x%x, val = 0x%x\n", waddr, wdata);
-	rc = mt9e013_i2c_txdata(mt9e013_client->addr<<1, buf, 4);
-	if (rc < 0) {
-		CDBG("i2c_write_b failed, addr = 0x%x, val = 0x%x!\n",
-			waddr, wdata);
-	}
-	return rc;
-}
-
-static int32_t mt9e013_i2c_write_b_sensor(unsigned short waddr, uint8_t bdata)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[3];
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00) >> 8;
-	buf[1] = (waddr & 0x00FF);
-	buf[2] = bdata;
-	CDBG("i2c_write_b addr = 0x%x, val = 0x%x\n", waddr, bdata);
-	rc = mt9e013_i2c_txdata(mt9e013_client->addr<<1, buf, 3);
-	if (rc < 0) {
-		CDBG("i2c_write_b failed, addr = 0x%x, val = 0x%x!\n",
-			waddr, bdata);
-	}
-	return rc;
-}
-
-static int32_t mt9e013_i2c_write_w_table(struct mt9e013_i2c_reg_conf const
-					 *reg_conf_tbl, int num)
-{
-	int i;
-	int32_t rc = -EIO;
-	for (i = 0; i < num; i++) {
-		rc = mt9e013_i2c_write_w_sensor(reg_conf_tbl->waddr,
-			reg_conf_tbl->wdata);
-		if (rc < 0)
-			break;
-		reg_conf_tbl++;
-	}
-	return rc;
-}
-
-static void mt9e013_group_hold_on(void)
-{
-	mt9e013_i2c_write_b_sensor(REG_GROUPED_PARAMETER_HOLD,
-						GROUPED_PARAMETER_HOLD);
-}
-
-static void mt9e013_group_hold_off(void)
-{
-	mt9e013_i2c_write_b_sensor(REG_GROUPED_PARAMETER_HOLD,
-						GROUPED_PARAMETER_HOLD_OFF);
-}
-
-static void mt9e013_start_stream(void)
-{
-	mt9e013_i2c_write_w_sensor(0x301A, 0x8250);
-	mt9e013_i2c_write_w_sensor(0x301A, 0x8650);
-	mt9e013_i2c_write_w_sensor(0x301A, 0x8658);
-	mt9e013_i2c_write_b_sensor(0x0104, 0x00);
-	mt9e013_i2c_write_w_sensor(0x301A, 0x065C);
-}
-
-static void mt9e013_stop_stream(void)
-{
-	mt9e013_i2c_write_w_sensor(0x301A, 0x0058);
-	mt9e013_i2c_write_w_sensor(0x301A, 0x0050);
-	mt9e013_i2c_write_b_sensor(0x0104, 0x01);
-}
-
-static void mt9e013_get_pict_fps(uint16_t fps, uint16_t *pfps)
-{
-	/* input fps is preview fps in Q8 format */
-	uint32_t divider, d1, d2;
-
-	d1 = mt9e013_regs.reg_prev[E013_FRAME_LENGTH_LINES].wdata
-		* 0x00000400/
-		mt9e013_regs.reg_snap[E013_FRAME_LENGTH_LINES].wdata;
-	d2 = mt9e013_regs.reg_prev[E013_LINE_LENGTH_PCK].wdata
-		* 0x00000400/
-		mt9e013_regs.reg_snap[E013_LINE_LENGTH_PCK].wdata;
-	divider = d1 * d2 / 0x400;
-
-	/*Verify PCLK settings and frame sizes.*/
-	*pfps = (uint16_t) (fps * divider / 0x400);
-	/* 2 is the ratio of no.of snapshot channels
-	to number of preview channels */
-}
-
-static uint16_t mt9e013_get_prev_lines_pf(void)
-{
-	if (mt9e013_ctrl->prev_res == QTR_SIZE)
-		return mt9e013_regs.reg_prev[E013_FRAME_LENGTH_LINES].wdata;
-	else if (mt9e013_ctrl->prev_res == FULL_SIZE)
-		return mt9e013_regs.reg_snap[E013_FRAME_LENGTH_LINES].wdata;
-	else if (mt9e013_ctrl->prev_res == HFR_60FPS)
-		return mt9e013_regs.reg_60fps[E013_FRAME_LENGTH_LINES].wdata;
-	else if (mt9e013_ctrl->prev_res == HFR_90FPS)
-		return mt9e013_regs.reg_120fps[E013_FRAME_LENGTH_LINES].wdata;
-	else
-		return mt9e013_regs.reg_120fps[E013_FRAME_LENGTH_LINES].wdata;
-}
-
-static uint16_t mt9e013_get_prev_pixels_pl(void)
-{
-	if (mt9e013_ctrl->prev_res == QTR_SIZE)
-		return mt9e013_regs.reg_prev[E013_LINE_LENGTH_PCK].wdata;
-	else if (mt9e013_ctrl->prev_res == FULL_SIZE)
-		return mt9e013_regs.reg_snap[E013_LINE_LENGTH_PCK].wdata;
-	else if (mt9e013_ctrl->prev_res == HFR_60FPS)
-		return mt9e013_regs.reg_60fps[E013_LINE_LENGTH_PCK].wdata;
-	else if (mt9e013_ctrl->prev_res == HFR_90FPS)
-		return mt9e013_regs.reg_120fps[E013_LINE_LENGTH_PCK].wdata;
-	else
-		return mt9e013_regs.reg_120fps[E013_LINE_LENGTH_PCK].wdata;
-}
-
-static uint16_t mt9e013_get_pict_lines_pf(void)
-{
-	if (mt9e013_ctrl->pict_res == QTR_SIZE)
-		return mt9e013_regs.reg_prev[E013_FRAME_LENGTH_LINES].wdata;
-	else if (mt9e013_ctrl->pict_res == FULL_SIZE)
-		return mt9e013_regs.reg_snap[E013_FRAME_LENGTH_LINES].wdata;
-	else if (mt9e013_ctrl->pict_res == HFR_60FPS)
-		return mt9e013_regs.reg_60fps[E013_FRAME_LENGTH_LINES].wdata;
-	else if (mt9e013_ctrl->pict_res == HFR_90FPS)
-		return mt9e013_regs.reg_120fps[E013_FRAME_LENGTH_LINES].wdata;
-	else
-		return mt9e013_regs.reg_120fps[E013_FRAME_LENGTH_LINES].wdata;
-}
-
-static uint16_t mt9e013_get_pict_pixels_pl(void)
-{
-	if (mt9e013_ctrl->pict_res == QTR_SIZE)
-		return mt9e013_regs.reg_prev[E013_LINE_LENGTH_PCK].wdata;
-	else if (mt9e013_ctrl->pict_res == FULL_SIZE)
-		return mt9e013_regs.reg_snap[E013_LINE_LENGTH_PCK].wdata;
-	else if (mt9e013_ctrl->pict_res == HFR_60FPS)
-		return mt9e013_regs.reg_60fps[E013_LINE_LENGTH_PCK].wdata;
-	else if (mt9e013_ctrl->pict_res == HFR_90FPS)
-		return mt9e013_regs.reg_120fps[E013_LINE_LENGTH_PCK].wdata;
-	else
-		return mt9e013_regs.reg_120fps[E013_LINE_LENGTH_PCK].wdata;
-}
-
-static uint32_t mt9e013_get_pict_max_exp_lc(void)
-{
-	if (mt9e013_ctrl->pict_res == QTR_SIZE)
-		return mt9e013_regs.reg_prev[E013_FRAME_LENGTH_LINES].wdata
-			* 24;
-	else if (mt9e013_ctrl->pict_res == FULL_SIZE)
-		return mt9e013_regs.reg_snap[E013_FRAME_LENGTH_LINES].wdata
-			* 24;
-	else if (mt9e013_ctrl->pict_res == HFR_60FPS)
-		return mt9e013_regs.reg_60fps[E013_FRAME_LENGTH_LINES].wdata
-			* 24;
-	else if (mt9e013_ctrl->pict_res == HFR_90FPS)
-		return mt9e013_regs.reg_120fps[E013_FRAME_LENGTH_LINES].wdata
-			* 24;
-	else
-		return mt9e013_regs.reg_120fps[E013_FRAME_LENGTH_LINES].wdata
-			* 24;
-}
-
-static int32_t mt9e013_set_fps(struct fps_cfg   *fps)
-{
-	uint16_t total_lines_per_frame;
-	int32_t rc = 0;
-	if (mt9e013_ctrl->curr_res == QTR_SIZE)
-		total_lines_per_frame =
-		mt9e013_regs.reg_prev[E013_FRAME_LENGTH_LINES].wdata;
-	else if (mt9e013_ctrl->curr_res == FULL_SIZE)
-		total_lines_per_frame =
-		mt9e013_regs.reg_snap[E013_FRAME_LENGTH_LINES].wdata;
-	else if (mt9e013_ctrl->curr_res == HFR_60FPS)
-		total_lines_per_frame =
-		mt9e013_regs.reg_60fps[E013_FRAME_LENGTH_LINES].wdata;
-	else if (mt9e013_ctrl->curr_res == HFR_90FPS)
-		total_lines_per_frame =
-		mt9e013_regs.reg_120fps[E013_FRAME_LENGTH_LINES].wdata;
-	else
-		total_lines_per_frame =
-		mt9e013_regs.reg_120fps[E013_FRAME_LENGTH_LINES].wdata;
-
-	mt9e013_ctrl->fps_divider = fps->fps_div;
-	mt9e013_ctrl->pict_fps_divider = fps->pict_fps_div;
-
-	if (mt9e013_ctrl->curr_res == FULL_SIZE) {
-		total_lines_per_frame = (uint16_t)
-		(total_lines_per_frame * mt9e013_ctrl->pict_fps_divider/0x400);
-	} else {
-		total_lines_per_frame = (uint16_t)
-		(total_lines_per_frame * mt9e013_ctrl->fps_divider/0x400);
-	}
-
-	mt9e013_group_hold_on();
-	rc = mt9e013_i2c_write_w_sensor(REG_FRAME_LENGTH_LINES,
-							total_lines_per_frame);
-	mt9e013_group_hold_off();
-	return rc;
-}
-
-static int32_t mt9e013_write_exp_gain(uint16_t gain, uint32_t line)
-{
-	uint16_t max_legal_gain = 0xE7F;
-	int32_t rc = 0;
-	if (gain > max_legal_gain) {
-		CDBG("Max legal gain Line:%d\n", __LINE__);
-		gain = max_legal_gain;
-	}
-
-	if (mt9e013_ctrl->curr_res != FULL_SIZE) {
-		mt9e013_ctrl->my_reg_gain = gain;
-		mt9e013_ctrl->my_reg_line_count = (uint16_t) line;
-		line = (uint32_t) (line * mt9e013_ctrl->fps_divider /
-						   0x00000400);
-	} else {
-		line = (uint32_t) (line * mt9e013_ctrl->pict_fps_divider /
-						   0x00000400);
-	}
-
-	gain |= 0x1000;
-
-	mt9e013_group_hold_on();
-	rc = mt9e013_i2c_write_w_sensor(REG_GLOBAL_GAIN, gain);
-	rc = mt9e013_i2c_write_w_sensor(REG_COARSE_INTEGRATION_TIME, line);
-	mt9e013_group_hold_off();
-	return rc;
-}
-
-static int32_t mt9e013_set_pict_exp_gain(uint16_t gain, uint32_t line)
-{
-	int32_t rc = 0;
-	rc = mt9e013_write_exp_gain(gain, line);
-	mt9e013_i2c_write_w_sensor(0x301A, 0x065C|0x2);
-	return rc;
-}
-
-#define DIV_CEIL(x, y) (x/y + (x%y) ? 1 : 0)
-
-static int32_t mt9e013_move_focus(int direction,
-	int32_t num_steps)
-{
-	int16_t step_direction, dest_lens_position, dest_step_position;
-	int16_t target_dist, small_step, next_lens_position;
-	if (direction == MOVE_NEAR)
-		step_direction = 1;
-	else
-		step_direction = -1;
-
-	dest_step_position = mt9e013_ctrl->curr_step_pos
-						+ (step_direction * num_steps);
-
-	if (dest_step_position < 0)
-		dest_step_position = 0;
-	else if (dest_step_position > MT9E013_TOTAL_STEPS_NEAR_TO_FAR)
-		dest_step_position = MT9E013_TOTAL_STEPS_NEAR_TO_FAR;
-
-	if (dest_step_position == mt9e013_ctrl->curr_step_pos)
-		return 0;
-
-	dest_lens_position = mt9e013_step_position_table[dest_step_position];
-	target_dist = step_direction *
-		(dest_lens_position - mt9e013_ctrl->curr_lens_pos);
-
-	if (step_direction < 0 && (target_dist >=
-		mt9e013_step_position_table[mt9e013_damping_threshold])) {
-		small_step = DIV_CEIL(target_dist, 10);
-		mt9e013_sw_damping_time_wait = 10;
-	} else {
-		small_step = DIV_CEIL(target_dist, 4);
-		mt9e013_sw_damping_time_wait = 4;
-	}
-
-	for (next_lens_position = mt9e013_ctrl->curr_lens_pos
-		+ (step_direction * small_step);
-		(step_direction * next_lens_position) <=
-		(step_direction * dest_lens_position);
-		next_lens_position += (step_direction * small_step)) {
-		mt9e013_i2c_write_w_sensor(REG_VCM_NEW_CODE,
-		next_lens_position);
-		mt9e013_ctrl->curr_lens_pos = next_lens_position;
-		usleep(mt9e013_sw_damping_time_wait*50);
-	}
-
-	if (mt9e013_ctrl->curr_lens_pos != dest_lens_position) {
-		mt9e013_i2c_write_w_sensor(REG_VCM_NEW_CODE,
-		dest_lens_position);
-		usleep(mt9e013_sw_damping_time_wait*50);
-	}
-	mt9e013_ctrl->curr_lens_pos = dest_lens_position;
-	mt9e013_ctrl->curr_step_pos = dest_step_position;
-	return 0;
-}
-
-static int32_t mt9e013_set_default_focus(uint8_t af_step)
-{
-	int32_t rc = 0;
-	if (mt9e013_ctrl->curr_step_pos != 0) {
-		rc = mt9e013_move_focus(MOVE_FAR,
-		mt9e013_ctrl->curr_step_pos);
-	} else {
-		mt9e013_i2c_write_w_sensor(REG_VCM_NEW_CODE, 0x00);
-	}
-
-	mt9e013_ctrl->curr_lens_pos = 0;
-	mt9e013_ctrl->curr_step_pos = 0;
-
-	return rc;
-}
-
-static void mt9e013_init_focus(void)
-{
-	uint8_t i;
-	mt9e013_step_position_table[0] = 0;
-	for (i = 1; i <= MT9E013_TOTAL_STEPS_NEAR_TO_FAR; i++) {
-		if (i <= mt9e013_nl_region_boundary1) {
-			mt9e013_step_position_table[i] =
-				mt9e013_step_position_table[i-1]
-				+ mt9e013_nl_region_code_per_step1;
-		} else {
-			mt9e013_step_position_table[i] =
-				mt9e013_step_position_table[i-1]
-				+ mt9e013_l_region_code_per_step;
-		}
-
-		if (mt9e013_step_position_table[i] > 255)
-			mt9e013_step_position_table[i] = 255;
-	}
-}
-
-static int32_t mt9e013_test(enum mt9e013_test_mode_t mo)
-{
-	int32_t rc = 0;
-	if (mo == TEST_OFF)
-		return rc;
-	else {
-		/* REG_0x30D8[4] is TESBYPEN: 0: Normal Operation,
-		1: Bypass Signal Processing
-		REG_0x30D8[5] is EBDMASK: 0:
-		Output Embedded data, 1: No output embedded data */
-		if (mt9e013_i2c_write_b_sensor(REG_TEST_PATTERN_MODE,
-			(uint8_t) mo) < 0) {
-			return rc;
-		}
-	}
-	return rc;
-}
-
-static int32_t mt9e013_sensor_setting(int update_type, int rt)
-{
-
-	int32_t rc = 0;
-	struct msm_camera_csi_params mt9e013_csi_params;
-	uint8_t stored_af_step = 0;
-	CDBG("sensor_settings\n");
-	stored_af_step = mt9e013_ctrl->curr_step_pos;
-	mt9e013_set_default_focus(0);
-	mt9e013_stop_stream();
-	msleep(15);
-	if (update_type == REG_INIT) {
-		mt9e013_i2c_write_w_table(mt9e013_regs.reg_mipi,
-			mt9e013_regs.reg_mipi_size);
-		mt9e013_i2c_write_w_table(mt9e013_regs.rec_settings,
-			mt9e013_regs.rec_size);
-		cam_debug_init();
-		CSI_CONFIG = 0;
-	} else if (update_type == UPDATE_PERIODIC) {
-		if (rt == QTR_SIZE) {
-			mt9e013_i2c_write_w_table(mt9e013_regs.reg_pll,
-				mt9e013_regs.reg_pll_size);
-			mt9e013_i2c_write_w_table(mt9e013_regs.reg_prev,
-				mt9e013_regs.reg_prev_size);
-		} else if (rt == FULL_SIZE) {
-			mt9e013_i2c_write_w_table(mt9e013_regs.reg_pll,
-				mt9e013_regs.reg_pll_size);
-			mt9e013_i2c_write_w_table(mt9e013_regs.reg_snap,
-				mt9e013_regs.reg_snap_size);
-		} else if (rt == HFR_60FPS) {
-			mt9e013_i2c_write_w_table(mt9e013_regs.reg_pll_120fps,
-				mt9e013_regs.reg_pll_120fps_size);
-			mt9e013_i2c_write_w_sensor(0x0306, 0x0029);
-			mt9e013_i2c_write_w_table(mt9e013_regs.reg_120fps,
-				mt9e013_regs.reg_120fps_size);
-		} else if (rt == HFR_90FPS) {
-			mt9e013_i2c_write_w_table(mt9e013_regs.reg_pll_120fps,
-				mt9e013_regs.reg_pll_120fps_size);
-			mt9e013_i2c_write_w_sensor(0x0306, 0x003D);
-			mt9e013_i2c_write_w_table(mt9e013_regs.reg_120fps,
-				mt9e013_regs.reg_120fps_size);
-		} else if (rt == HFR_120FPS) {
-			msm_camio_vfe_clk_rate_set(266667000);
-			mt9e013_i2c_write_w_table(mt9e013_regs.reg_pll_120fps,
-				mt9e013_regs.reg_pll_120fps_size);
-			mt9e013_i2c_write_w_table(mt9e013_regs.reg_120fps,
-				mt9e013_regs.reg_120fps_size);
-		}
-		if (!CSI_CONFIG) {
-			msm_camio_vfe_clk_rate_set(192000000);
-			mt9e013_csi_params.data_format = CSI_10BIT;
-			mt9e013_csi_params.lane_cnt = 2;
-			mt9e013_csi_params.lane_assign = 0xe4;
-			mt9e013_csi_params.dpcm_scheme = 0;
-			mt9e013_csi_params.settle_cnt = 0x18;
-			rc = msm_camio_csi_config(&mt9e013_csi_params);
-			msleep(10);
-			CSI_CONFIG = 1;
-		}
-		mt9e013_move_focus(MOVE_NEAR, stored_af_step);
-		mt9e013_start_stream();
-	}
-	return rc;
-}
-
-static int32_t mt9e013_video_config(int mode)
-{
-
-	int32_t rc = 0;
-
-	CDBG("video config\n");
-	/* change sensor resolution if needed */
-	if (mt9e013_sensor_setting(UPDATE_PERIODIC,
-			mt9e013_ctrl->prev_res) < 0)
-		return rc;
-	if (mt9e013_ctrl->set_test) {
-		if (mt9e013_test(mt9e013_ctrl->set_test) < 0)
-			return  rc;
-	}
-
-	mt9e013_ctrl->curr_res = mt9e013_ctrl->prev_res;
-	mt9e013_ctrl->sensormode = mode;
-	return rc;
-}
-
-static int32_t mt9e013_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-	/*change sensor resolution if needed */
-	if (mt9e013_ctrl->curr_res != mt9e013_ctrl->pict_res) {
-		if (mt9e013_sensor_setting(UPDATE_PERIODIC,
-				mt9e013_ctrl->pict_res) < 0)
-			return rc;
-	}
-
-	mt9e013_ctrl->curr_res = mt9e013_ctrl->pict_res;
-	mt9e013_ctrl->sensormode = mode;
-	return rc;
-} /*end of mt9e013_snapshot_config*/
-
-static int32_t mt9e013_raw_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-	/* change sensor resolution if needed */
-	if (mt9e013_ctrl->curr_res != mt9e013_ctrl->pict_res) {
-		if (mt9e013_sensor_setting(UPDATE_PERIODIC,
-				mt9e013_ctrl->pict_res) < 0)
-			return rc;
-	}
-
-	mt9e013_ctrl->curr_res = mt9e013_ctrl->pict_res;
-	mt9e013_ctrl->sensormode = mode;
-	return rc;
-} /*end of mt9e013_raw_snapshot_config*/
-
-static int32_t mt9e013_set_sensor_mode(int mode,
-	int res)
-{
-	int32_t rc = 0;
-	switch (mode) {
-	case SENSOR_PREVIEW_MODE:
-	case SENSOR_HFR_60FPS_MODE:
-	case SENSOR_HFR_90FPS_MODE:
-	case SENSOR_HFR_120FPS_MODE:
-		mt9e013_ctrl->prev_res = res;
-		rc = mt9e013_video_config(mode);
-		break;
-	case SENSOR_SNAPSHOT_MODE:
-		mt9e013_ctrl->pict_res = res;
-		rc = mt9e013_snapshot_config(mode);
-		break;
-	case SENSOR_RAW_SNAPSHOT_MODE:
-		mt9e013_ctrl->pict_res = res;
-		rc = mt9e013_raw_snapshot_config(mode);
-		break;
-	default:
-		rc = -EINVAL;
-		break;
-	}
-	return rc;
-}
-
-static int32_t mt9e013_power_down(void)
-{
-	return 0;
-}
-
-static int mt9e013_probe_init_done(const struct msm_camera_sensor_info *data)
-{
-	CDBG("probe done\n");
-	gpio_free(data->sensor_reset);
-	return 0;
-}
-
-static int mt9e013_probe_init_sensor(const struct msm_camera_sensor_info *data)
-{
-	int32_t rc = 0;
-	uint16_t chipid = 0;
-	CDBG("%s: %d\n", __func__, __LINE__);
-	rc = gpio_request(data->sensor_reset, "mt9e013");
-	CDBG(" mt9e013_probe_init_sensor\n");
-	if (!rc) {
-		CDBG("sensor_reset = %d\n", rc);
-		gpio_direction_output(data->sensor_reset, 0);
-		msleep(10);
-		gpio_set_value_cansleep(data->sensor_reset, 1);
-		msleep(10);
-	} else {
-		goto init_probe_done;
-	}
-
-	CDBG(" mt9e013_probe_init_sensor is called\n");
-	rc = mt9e013_i2c_read(0x0000, &chipid, 2);
-	CDBG("ID: %d\n", chipid);
-	/* 4. Compare sensor ID to MT9E013 ID: */
-	if (chipid != 0x4B00) {
-		rc = -ENODEV;
-		CDBG("mt9e013_probe_init_sensor fail chip id doesnot match\n");
-		goto init_probe_fail;
-	}
-
-	mt9e013_ctrl = kzalloc(sizeof(struct mt9e013_ctrl_t), GFP_KERNEL);
-	if (!mt9e013_ctrl) {
-		CDBG("mt9e013_init failed!\n");
-		rc = -ENOMEM;
-	}
-	mt9e013_ctrl->fps_divider = 1 * 0x00000400;
-	mt9e013_ctrl->pict_fps_divider = 1 * 0x00000400;
-	mt9e013_ctrl->set_test = TEST_OFF;
-	mt9e013_ctrl->prev_res = QTR_SIZE;
-	mt9e013_ctrl->pict_res = FULL_SIZE;
-
-	if (data)
-		mt9e013_ctrl->sensordata = data;
-
-	goto init_probe_done;
-init_probe_fail:
-	CDBG(" mt9e013_probe_init_sensor fails\n");
-	gpio_set_value_cansleep(data->sensor_reset, 0);
-	mt9e013_probe_init_done(data);
-init_probe_done:
-	CDBG(" mt9e013_probe_init_sensor finishes\n");
-	return rc;
-}
-/* camsensor_mt9e013_reset */
-
-int mt9e013_sensor_open_init(const struct msm_camera_sensor_info *data)
-{
-	int32_t rc = 0;
-
-	CDBG("%s: %d\n", __func__, __LINE__);
-	CDBG("Calling mt9e013_sensor_open_init\n");
-
-	mt9e013_ctrl = kzalloc(sizeof(struct mt9e013_ctrl_t), GFP_KERNEL);
-	if (!mt9e013_ctrl) {
-		CDBG("mt9e013_init failed!\n");
-		rc = -ENOMEM;
-		goto init_done;
-	}
-	mt9e013_ctrl->fps_divider = 1 * 0x00000400;
-	mt9e013_ctrl->pict_fps_divider = 1 * 0x00000400;
-	mt9e013_ctrl->set_test = TEST_OFF;
-	mt9e013_ctrl->prev_res = QTR_SIZE;
-	mt9e013_ctrl->pict_res = FULL_SIZE;
-
-	if (data)
-		mt9e013_ctrl->sensordata = data;
-	if (rc < 0) {
-		CDBG("Calling mt9e013_sensor_open_init fail1\n");
-		return rc;
-	}
-	CDBG("%s: %d\n", __func__, __LINE__);
-	/* enable mclk first */
-	msm_camio_clk_rate_set(MT9E013_MASTER_CLK_RATE);
-	rc = mt9e013_probe_init_sensor(data);
-	if (rc < 0)
-		goto init_fail;
-
-	CDBG("init settings\n");
-	rc = mt9e013_sensor_setting(REG_INIT, mt9e013_ctrl->prev_res);
-	mt9e013_ctrl->fps = 30*Q8;
-	mt9e013_init_focus();
-	if (rc < 0) {
-		gpio_set_value_cansleep(data->sensor_reset, 0);
-		goto init_fail;
-	} else
-		goto init_done;
-init_fail:
-	CDBG("init_fail\n");
-	mt9e013_probe_init_done(data);
-init_done:
-	CDBG("init_done\n");
-	return rc;
-} /*endof mt9e013_sensor_open_init*/
-
-static int mt9e013_init_client(struct i2c_client *client)
-{
-	/* Initialize the MSM_CAMI2C Chip */
-	init_waitqueue_head(&mt9e013_wait_queue);
-	return 0;
-}
-
-static const struct i2c_device_id mt9e013_i2c_id[] = {
-	{"mt9e013", 0},
-	{ }
-};
-
-static int mt9e013_i2c_probe(struct i2c_client *client,
-	const struct i2c_device_id *id)
-{
-	int rc = 0;
-	CDBG("mt9e013_probe called!\n");
-
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		CDBG("i2c_check_functionality failed\n");
-		goto probe_failure;
-	}
-
-	mt9e013_sensorw = kzalloc(sizeof(struct mt9e013_work_t), GFP_KERNEL);
-	if (!mt9e013_sensorw) {
-		CDBG("kzalloc failed.\n");
-		rc = -ENOMEM;
-		goto probe_failure;
-	}
-
-	i2c_set_clientdata(client, mt9e013_sensorw);
-	mt9e013_init_client(client);
-	mt9e013_client = client;
-
-
-	CDBG("mt9e013_probe successed! rc = %d\n", rc);
-	return 0;
-
-probe_failure:
-	CDBG("mt9e013_probe failed! rc = %d\n", rc);
-	return rc;
-}
-
-static int mt9e013_send_wb_info(struct wb_info_cfg *wb)
-{
-	return 0;
-
-} /*end of mt9e013_snapshot_config*/
-
-static int __exit mt9e013_remove(struct i2c_client *client)
-{
-	struct mt9e013_work_t_t *sensorw = i2c_get_clientdata(client);
-	free_irq(client->irq, sensorw);
-	mt9e013_client = NULL;
-	kfree(sensorw);
-	return 0;
-}
-
-static struct i2c_driver mt9e013_i2c_driver = {
-	.id_table = mt9e013_i2c_id,
-	.probe  = mt9e013_i2c_probe,
-	.remove = __exit_p(mt9e013_i2c_remove),
-	.driver = {
-		.name = "mt9e013",
-	},
-};
-
-int mt9e013_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(&mt9e013_mut);
-	CDBG("mt9e013_sensor_config: cfgtype = %d\n",
-	cdata.cfgtype);
-		switch (cdata.cfgtype) {
-		case CFG_GET_PICT_FPS:
-			mt9e013_get_pict_fps(
-				cdata.cfg.gfps.prevfps,
-				&(cdata.cfg.gfps.pictfps));
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_GET_PREV_L_PF:
-			cdata.cfg.prevl_pf =
-			mt9e013_get_prev_lines_pf();
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_GET_PREV_P_PL:
-			cdata.cfg.prevp_pl =
-				mt9e013_get_prev_pixels_pl();
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_GET_PICT_L_PF:
-			cdata.cfg.pictl_pf =
-				mt9e013_get_pict_lines_pf();
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_GET_PICT_P_PL:
-			cdata.cfg.pictp_pl =
-				mt9e013_get_pict_pixels_pl();
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_GET_PICT_MAX_EXP_LC:
-			cdata.cfg.pict_max_exp_lc =
-				mt9e013_get_pict_max_exp_lc();
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_SET_FPS:
-		case CFG_SET_PICT_FPS:
-			rc = mt9e013_set_fps(&(cdata.cfg.fps));
-			break;
-
-		case CFG_SET_EXP_GAIN:
-			rc =
-				mt9e013_write_exp_gain(
-					cdata.cfg.exp_gain.gain,
-					cdata.cfg.exp_gain.line);
-			break;
-
-		case CFG_SET_PICT_EXP_GAIN:
-			rc =
-				mt9e013_set_pict_exp_gain(
-				cdata.cfg.exp_gain.gain,
-				cdata.cfg.exp_gain.line);
-			break;
-
-		case CFG_SET_MODE:
-			rc = mt9e013_set_sensor_mode(cdata.mode,
-					cdata.rs);
-			break;
-
-		case CFG_PWR_DOWN:
-			rc = mt9e013_power_down();
-			break;
-
-		case CFG_MOVE_FOCUS:
-			rc =
-				mt9e013_move_focus(
-				cdata.cfg.focus.dir,
-				cdata.cfg.focus.steps);
-			break;
-
-		case CFG_SET_DEFAULT_FOCUS:
-			rc =
-				mt9e013_set_default_focus(
-				cdata.cfg.focus.steps);
-			break;
-
-		case CFG_GET_AF_MAX_STEPS:
-			cdata.max_steps = MT9E013_TOTAL_STEPS_NEAR_TO_FAR;
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_SET_EFFECT:
-			rc = mt9e013_set_default_focus(
-				cdata.cfg.effect);
-			break;
-
-
-		case CFG_SEND_WB_INFO:
-			rc = mt9e013_send_wb_info(
-				&(cdata.cfg.wb_info));
-			break;
-
-		default:
-			rc = -EFAULT;
-			break;
-		}
-
-	mutex_unlock(&mt9e013_mut);
-
-	return rc;
-}
-
-static int mt9e013_sensor_release(void)
-{
-	int rc = -EBADF;
-	mutex_lock(&mt9e013_mut);
-	mt9e013_power_down();
-	gpio_set_value_cansleep(mt9e013_ctrl->sensordata->sensor_reset, 0);
-	msleep(5);
-	gpio_free(mt9e013_ctrl->sensordata->sensor_reset);
-	kfree(mt9e013_ctrl);
-	mt9e013_ctrl = NULL;
-	CDBG("mt9e013_release completed\n");
-	mutex_unlock(&mt9e013_mut);
-
-	return rc;
-}
-
-static int mt9e013_sensor_probe(const struct msm_camera_sensor_info *info,
-		struct msm_sensor_ctrl *s)
-{
-	int rc = 0;
-	rc = i2c_add_driver(&mt9e013_i2c_driver);
-	if (rc < 0 || mt9e013_client == NULL) {
-		rc = -ENOTSUPP;
-		CDBG("I2C add driver failed");
-		goto probe_fail;
-	}
-	msm_camio_clk_rate_set(MT9E013_MASTER_CLK_RATE);
-	rc = mt9e013_probe_init_sensor(info);
-	if (rc < 0)
-		goto probe_fail;
-	s->s_init = mt9e013_sensor_open_init;
-	s->s_release = mt9e013_sensor_release;
-	s->s_config  = mt9e013_sensor_config;
-	s->s_mount_angle = info->sensor_platform_info->mount_angle;
-	gpio_set_value_cansleep(info->sensor_reset, 0);
-	mt9e013_probe_init_done(info);
-	return rc;
-
-probe_fail:
-	CDBG("mt9e013_sensor_probe: SENSOR PROBE FAILS!\n");
-	return rc;
-}
-
-static int __mt9e013_probe(struct platform_device *pdev)
-{
-	return msm_camera_drv_start(pdev, mt9e013_sensor_probe);
-}
-
-static struct platform_driver msm_camera_driver = {
-	.probe = __mt9e013_probe,
-	.driver = {
-		.name = "msm_camera_mt9e013",
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init mt9e013_init(void)
-{
-	return platform_driver_register(&msm_camera_driver);
-}
-
-module_init(mt9e013_init);
-void mt9e013_exit(void)
-{
-	i2c_del_driver(&mt9e013_i2c_driver);
-}
-MODULE_DESCRIPTION("Aptina 8 MP Bayer sensor driver");
-MODULE_LICENSE("GPL v2");
-
-static bool streaming = 1;
-
-static int mt9e013_focus_test(void *data, u64 *val)
-{
-	int i = 0;
-	mt9e013_set_default_focus(0);
-
-	for (i = 90; i < 256; i++) {
-		mt9e013_i2c_write_w_sensor(REG_VCM_NEW_CODE, i);
-		msleep(5000);
-	}
-	msleep(5000);
-	for (i = 255; i > 90; i--) {
-		mt9e013_i2c_write_w_sensor(REG_VCM_NEW_CODE, i);
-		msleep(5000);
-	}
-	return 0;
-}
-
-DEFINE_SIMPLE_ATTRIBUTE(cam_focus, mt9e013_focus_test,
-			NULL, "%lld\n");
-
-static int mt9e013_step_test(void *data, u64 *val)
-{
-	int i = 0;
-	mt9e013_set_default_focus(0);
-
-	for (i = 0; i < MT9E013_TOTAL_STEPS_NEAR_TO_FAR; i++) {
-		mt9e013_move_focus(MOVE_NEAR, 1);
-		msleep(5000);
-	}
-
-	mt9e013_move_focus(MOVE_FAR, MT9E013_TOTAL_STEPS_NEAR_TO_FAR);
-	msleep(5000);
-	return 0;
-}
-
-DEFINE_SIMPLE_ATTRIBUTE(cam_step, mt9e013_step_test,
-			NULL, "%lld\n");
-
-static int cam_debug_stream_set(void *data, u64 val)
-{
-	int rc = 0;
-
-	if (val) {
-		mt9e013_start_stream();
-		streaming = 1;
-	} else {
-		mt9e013_stop_stream();
-		streaming = 0;
-	}
-
-	return rc;
-}
-
-static int cam_debug_stream_get(void *data, u64 *val)
-{
-	*val = streaming;
-	return 0;
-}
-DEFINE_SIMPLE_ATTRIBUTE(cam_stream, cam_debug_stream_get,
-			cam_debug_stream_set, "%llu\n");
-
-
-static int cam_debug_init(void)
-{
-	struct dentry *cam_dir;
-	debugfs_base = debugfs_create_dir("sensor", NULL);
-	if (!debugfs_base)
-		return -ENOMEM;
-
-	cam_dir = debugfs_create_dir("mt9e013", debugfs_base);
-	if (!cam_dir)
-		return -ENOMEM;
-
-	if (!debugfs_create_file("focus", S_IRUGO | S_IWUSR, cam_dir,
-							 NULL, &cam_focus))
-		return -ENOMEM;
-	if (!debugfs_create_file("step", S_IRUGO | S_IWUSR, cam_dir,
-							 NULL, &cam_step))
-		return -ENOMEM;
-	if (!debugfs_create_file("stream", S_IRUGO | S_IWUSR, cam_dir,
-							 NULL, &cam_stream))
-		return -ENOMEM;
-
-	return 0;
-}
-
-
-
diff --git a/drivers/media/platform/msm/camera_v1/mt9e013.h b/drivers/media/platform/msm/camera_v1/mt9e013.h
deleted file mode 100644
index 6f43ec4..0000000
--- a/drivers/media/platform/msm/camera_v1/mt9e013.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- *
- */
-
-#ifndef MT9E013_H
-#define MT9E013_H
-#include <linux/types.h>
-#include <mach/board.h>
-extern struct mt9e013_reg mt9e013_regs;
-struct reg_struct_init {
-	uint8_t reg_0x0112;      /* 0x0112*/
-	uint8_t reg_0x0113;      /* 0x0113*/
-	uint8_t vt_pix_clk_div;  /* 0x0301*/
-	uint8_t pre_pll_clk_div; /* 0x0305*/
-	uint8_t pll_multiplier;  /* 0x0307*/
-	uint8_t op_pix_clk_div;  /* 0x0309*/
-	uint8_t reg_0x3030;      /*0x3030*/
-	uint8_t reg_0x0111;      /*0x0111*/
-	uint8_t reg_0x0b00;      /*0x0b00*/
-	uint8_t reg_0x3001;      /*0x3001*/
-	uint8_t reg_0x3004;      /*0x3004*/
-	uint8_t reg_0x3007;      /*0x3007*/
-	uint8_t reg_0x3016;      /*0x3016*/
-	uint8_t reg_0x301d;      /*0x301d*/
-	uint8_t reg_0x317e;      /*0x317E*/
-	uint8_t reg_0x317f;      /*0x317F*/
-	uint8_t reg_0x3400;      /*0x3400*/
-	uint8_t reg_0x0b06;      /*0x0b06*/
-	uint8_t reg_0x0b07;      /*0x0b07*/
-	uint8_t reg_0x0b08;      /*0x0b08*/
-	uint8_t reg_0x0b09;      /*0x0b09*/
-	uint8_t reg_0x0136;
-	uint8_t reg_0x0137;
-	/* Edof */
-	uint8_t reg_0x0b83;      /*0x0b83*/
-	uint8_t reg_0x0b84;      /*0x0b84*/
-	uint8_t reg_0x0b85;      /*0x0b85*/
-	uint8_t reg_0x0b88;      /*0x0b88*/
-	uint8_t reg_0x0b89;      /*0x0b89*/
-	uint8_t reg_0x0b8a;      /*0x0b8a*/
-	};
-struct reg_struct {
-	uint8_t coarse_integration_time_hi; /*REG_COARSE_INTEGRATION_TIME_HI*/
-	uint8_t coarse_integration_time_lo; /*REG_COARSE_INTEGRATION_TIME_LO*/
-	uint8_t analogue_gain_code_global;
-	uint8_t frame_length_lines_hi; /* 0x0340*/
-	uint8_t frame_length_lines_lo; /* 0x0341*/
-	uint8_t line_length_pck_hi;    /* 0x0342*/
-	uint8_t line_length_pck_lo;    /* 0x0343*/
-	uint8_t reg_0x3005;   /* 0x3005*/
-	uint8_t reg_0x3010;  /* 0x3010*/
-	uint8_t reg_0x3011;  /* 0x3011*/
-	uint8_t reg_0x301a;  /* 0x301a*/
-	uint8_t reg_0x3035;  /* 0x3035*/
-	uint8_t reg_0x3036;   /* 0x3036*/
-	uint8_t reg_0x3041;  /*0x3041*/
-	uint8_t reg_0x3042;  /*0x3042*/
-	uint8_t reg_0x3045;  /*0x3045*/
-	uint8_t reg_0x0b80;   /* 0x0b80*/
-	uint8_t reg_0x0900;   /*0x0900*/
-	uint8_t reg_0x0901;   /* 0x0901*/
-	uint8_t reg_0x0902;   /*0x0902*/
-	uint8_t reg_0x0383;   /*0x0383*/
-	uint8_t reg_0x0387;   /* 0x0387*/
-	uint8_t reg_0x034c;   /* 0x034c*/
-	uint8_t reg_0x034d;   /*0x034d*/
-	uint8_t reg_0x034e;   /* 0x034e*/
-	uint8_t reg_0x034f;   /* 0x034f*/
-	uint8_t reg_0x1716; /*0x1716*/
-	uint8_t reg_0x1717; /*0x1717*/
-	uint8_t reg_0x1718; /*0x1718*/
-	uint8_t reg_0x1719; /*0x1719*/
-	uint8_t reg_0x3210;/*0x3210*/
-	uint8_t reg_0x111; /*0x111*/
-	uint8_t reg_0x3410;  /*0x3410*/
-	uint8_t reg_0x3098;
-	uint8_t reg_0x309D;
-	uint8_t reg_0x0200;
-	uint8_t reg_0x0201;
-	};
-struct mt9e013_i2c_reg_conf {
-	unsigned short waddr;
-	unsigned short wdata;
-};
-
-enum mt9e013_test_mode_t {
-	TEST_OFF,
-	TEST_1,
-	TEST_2,
-	TEST_3
-};
-
-enum mt9e013_resolution_t {
-	QTR_SIZE,
-	FULL_SIZE,
-	HFR_60FPS,
-	HFR_90FPS,
-	HFR_120FPS,
-	INVALID_SIZE
-};
-enum mt9e013_setting {
-	RES_PREVIEW,
-	RES_CAPTURE
-};
-enum mt9e013_reg_update {
-	/* Sensor egisters that need to be updated during initialization */
-	REG_INIT,
-	/* Sensor egisters that needs periodic I2C writes */
-	UPDATE_PERIODIC,
-	/* All the sensor Registers will be updated */
-	UPDATE_ALL,
-	/* Not valid update */
-	UPDATE_INVALID
-};
-
-enum mt9e013_reg_pll {
-	E013_VT_PIX_CLK_DIV,
-	E013_VT_SYS_CLK_DIV,
-	E013_PRE_PLL_CLK_DIV,
-	E013_PLL_MULTIPLIER,
-	E013_OP_PIX_CLK_DIV,
-	E013_OP_SYS_CLK_DIV
-};
-
-enum mt9e013_reg_mode {
-	E013_X_ADDR_START,
-	E013_X_ADDR_END,
-	E013_Y_ADDR_START,
-	E013_Y_ADDR_END,
-	E013_X_OUTPUT_SIZE,
-	E013_Y_OUTPUT_SIZE,
-	E013_DATAPATH_SELECT,
-	E013_READ_MODE,
-	E013_ANALOG_CONTROL5,
-	E013_DAC_LD_4_5,
-	E013_SCALING_MODE,
-	E013_SCALE_M,
-	E013_LINE_LENGTH_PCK,
-	E013_FRAME_LENGTH_LINES,
-	E013_COARSE_INTEGRATION_TIME,
-	E013_FINE_INTEGRATION_TIME,
-	E013_FINE_CORRECTION
-};
-
-struct mt9e013_reg {
-	const struct mt9e013_i2c_reg_conf *reg_mipi;
-	const unsigned short reg_mipi_size;
-	const struct mt9e013_i2c_reg_conf *rec_settings;
-	const unsigned short rec_size;
-	const struct mt9e013_i2c_reg_conf *reg_pll;
-	const unsigned short reg_pll_size;
-	const struct mt9e013_i2c_reg_conf *reg_pll_60fps;
-	const unsigned short reg_pll_60fps_size;
-	const struct mt9e013_i2c_reg_conf *reg_pll_120fps;
-	const unsigned short reg_pll_120fps_size;
-	const struct mt9e013_i2c_reg_conf *reg_prev;
-	const unsigned short reg_prev_size;
-	const struct mt9e013_i2c_reg_conf *reg_snap;
-	const unsigned short reg_snap_size;
-	const struct mt9e013_i2c_reg_conf *reg_60fps;
-	const unsigned short reg_60fps_size;
-	const struct mt9e013_i2c_reg_conf *reg_120fps;
-	const unsigned short reg_120fps_size;
-};
-#endif /* MT9E013_H */
diff --git a/drivers/media/platform/msm/camera_v1/mt9e013_reg.c b/drivers/media/platform/msm/camera_v1/mt9e013_reg.c
deleted file mode 100644
index bdcf3f8..0000000
--- a/drivers/media/platform/msm/camera_v1/mt9e013_reg.c
+++ /dev/null
@@ -1,234 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- *
- */
-
-
-#include "mt9e013.h"
-
-static struct mt9e013_i2c_reg_conf mipi_settings[] = {
-	/*Disable embedded data*/
-	{0x3064, 0x7800},/*SMIA_TEST*/
-	/*configure 2-lane MIPI*/
-	{0x31AE, 0x0202},/*SERIAL_FORMAT*/
-	{0x31B8, 0x0E3F},/*MIPI_TIMING_2*/
-	/*set data to RAW10 format*/
-	{0x0112, 0x0A0A},/*CCP_DATA_FORMAT*/
-	{0x30F0, 0x8000},/*VCM CONTROL*/
-};
-
-/*PLL Configuration
-(Ext=24MHz, vt_pix_clk=174MHz, op_pix_clk=69.6MHz)*/
-static struct mt9e013_i2c_reg_conf pll_settings[] = {
-	{0x0300, 0x0004},/*VT_PIX_CLK_DIV*/
-	{0x0302, 0x0001},/*VT_SYS_CLK_DIV*/
-	{0x0304, 0x0002},/*PRE_PLL_CLK_DIV*/
-	{0x0306, 0x003A},/*PLL_MULTIPLIER*/
-	{0x0308, 0x000A},/*OP_PIX_CLK_DIV*/
-	{0x030A, 0x0001},/*OP_SYS_CLK_DIV*/
-};
-
-static struct mt9e013_i2c_reg_conf prev_settings[] = {
-	/*Output Size (1632x1224)*/
-	{0x0344, 0x0008},/*X_ADDR_START*/
-	{0x0348, 0x0CC9},/*X_ADDR_END*/
-	{0x0346, 0x0008},/*Y_ADDR_START*/
-	{0x034A, 0x0999},/*Y_ADDR_END*/
-	{0x034C, 0x0660},/*X_OUTPUT_SIZE*/
-	{0x034E, 0x04C8},/*Y_OUTPUT_SIZE*/
-	{0x306E, 0xFCB0},/*DATAPATH_SELECT*/
-	{0x3040, 0x04C3},/*READ_MODE*/
-	{0x3178, 0x0000},/*ANALOG_CONTROL5*/
-	{0x3ED0, 0x1E24},/*DAC_LD_4_5*/
-	{0x0400, 0x0002},/*SCALING_MODE*/
-	{0x0404, 0x0010},/*SCALE_M*/
-	/*Timing configuration*/
-	{0x0342, 0x1018},/*LINE_LENGTH_PCK*/
-	{0x0340, 0x055B},/*FRAME_LENGTH_LINES*/
-	{0x0202, 0x0557},/*COARSE_INTEGRATION_TIME*/
-	{0x3014, 0x0846},/*FINE_INTEGRATION_TIME_*/
-	{0x3010, 0x0130},/*FINE_CORRECTION*/
-};
-
-static struct mt9e013_i2c_reg_conf snap_settings[] = {
-	/*Output Size (3264x2448)*/
-	{0x0344, 0x0008},/*X_ADDR_START */
-	{0x0348, 0x0CD7},/*X_ADDR_END*/
-	{0x0346, 0x0008},/*Y_ADDR_START */
-	{0x034A, 0x09A7},/*Y_ADDR_END*/
-	{0x034C, 0x0CD0},/*X_OUTPUT_SIZE*/
-	{0x034E, 0x09A0},/*Y_OUTPUT_SIZE*/
-	{0x306E, 0xFC80},/*DATAPATH_SELECT*/
-	{0x3040, 0x0041},/*READ_MODE*/
-	{0x3178, 0x0000},/*ANALOG_CONTROL5*/
-	{0x3ED0, 0x1E24},/*DAC_LD_4_5*/
-	{0x0400, 0x0000},/*SCALING_MODE*/
-	{0x0404, 0x0010},/*SCALE_M*/
-	/*Timing configuration*/
-	{0x0342, 0x13F8},/*LINE_LENGTH_PCK*/
-	{0x0340, 0x0A2F},/*FRAME_LENGTH_LINES*/
-	{0x0202, 0x0A1F},/*COARSE_INTEGRATION_TIME*/
-	{0x3014, 0x03F6},/*FINE_INTEGRATION_TIME_ */
-	{0x3010, 0x0078},/*FINE_CORRECTION*/
-};
-
-static struct mt9e013_i2c_reg_conf pll_settings_60fps[] = {
-	{0x0300, 0x0004},/*VT_PIX_CLK_DIV*/
-	{0x0302, 0x0001},/*VT_SYS_CLK_DIV*/
-	{0x0304, 0x0002},/*PRE_PLL_CLK_DIV*/
-	{0x0306, 0x0042},/*PLL_MULTIPLIER*/
-	{0x0308, 0x000A},/*OP_PIX_CLK_DIV*/
-	{0x030A, 0x0001},/*OP_SYS_CLK_DIV*/
-};
-
-static struct mt9e013_i2c_reg_conf prev_settings_60fps[] = {
-	/*Output Size (1632x1224)*/
-	{0x0344, 0x0008},/*X_ADDR_START*/
-	{0x0348, 0x0CC5},/*X_ADDR_END*/
-	{0x0346, 0x013a},/*Y_ADDR_START*/
-	{0x034A, 0x0863},/*Y_ADDR_END*/
-	{0x034C, 0x0660},/*X_OUTPUT_SIZE*/
-	{0x034E, 0x0396},/*Y_OUTPUT_SIZE*/
-	{0x306E, 0xFC80},/*DATAPATH_SELECT*/
-	{0x3040, 0x00C3},/*READ_MODE*/
-	{0x3178, 0x0000},/*ANALOG_CONTROL5*/
-	{0x3ED0, 0x1E24},/*DAC_LD_4_5*/
-	{0x0400, 0x0000},/*SCALING_MODE*/
-	{0x0404, 0x0010},/*SCALE_M*/
-	/*Timing configuration*/
-	{0x0342, 0x0BE8},/*LINE_LENGTH_PCK*/
-	{0x0340, 0x0425},/*FRAME_LENGTH_LINES*/
-	{0x0202, 0x0425},/*COARSE_INTEGRATION_TIME*/
-	{0x3014, 0x03F6},/*FINE_INTEGRATION_TIME_*/
-	{0x3010, 0x0078},/*FINE_CORRECTION*/
-};
-
-static struct mt9e013_i2c_reg_conf pll_settings_120fps[] = {
-	{0x0300, 0x0005},/*VT_PIX_CLK_DIV*/
-	{0x0302, 0x0001},/*VT_SYS_CLK_DIV*/
-	{0x0304, 0x0002},/*PRE_PLL_CLK_DIV*/
-	{0x0306, 0x0052},/*PLL_MULTIPLIER*/
-	{0x0308, 0x000A},/*OP_PIX_CLK_DIV*/
-	{0x030A, 0x0001},/*OP_SYS_CLK_DIV*/
-};
-
-static struct mt9e013_i2c_reg_conf prev_settings_120fps[] = {
-	{0x0344, 0x0008},/*X_ADDR_START*/
-	{0x0348, 0x0685},/*X_ADDR_END*/
-	{0x0346, 0x013a},/*Y_ADDR_START*/
-	{0x034A, 0x055B},/*Y_ADDR_END*/
-	{0x034C, 0x0340},/*X_OUTPUT_SIZE*/
-	{0x034E, 0x0212},/*Y_OUTPUT_SIZE*/
-	{0x306E, 0xFC80},/*DATAPATH_SELECT*/
-	{0x3040, 0x00C3},/*READ_MODE*/
-	{0x3178, 0x0000},/*ANALOG_CONTROL5*/
-	{0x3ED0, 0x1E24},/*DAC_LD_4_5*/
-	{0x0400, 0x0000},/*SCALING_MODE*/
-	{0x0404, 0x0010},/*SCALE_M*/
-	/*Timing configuration*/
-	{0x0342, 0x0970},/*LINE_LENGTH_PCK*/
-	{0x0340, 0x02A1},/*FRAME_LENGTH_LINES*/
-	{0x0202, 0x02A1},/*COARSE_INTEGRATION_TIME*/
-	{0x3014, 0x03F6},/*FINE_INTEGRATION_TIME_*/
-	{0x3010, 0x0078},/*FINE_CORRECTION*/
-};
-
-static struct mt9e013_i2c_reg_conf recommend_settings[] = {
-	{0x3044, 0x0590},
-	{0x306E, 0xFC80},
-	{0x30B2, 0xC000},
-	{0x30D6, 0x0800},
-	{0x316C, 0xB42F},
-	{0x316E, 0x869C},
-	{0x3170, 0x210E},
-	{0x317A, 0x010E},
-	{0x31E0, 0x1FB9},
-	{0x31E6, 0x07FC},
-	{0x37C0, 0x0000},
-	{0x37C2, 0x0000},
-	{0x37C4, 0x0000},
-	{0x37C6, 0x0000},
-	{0x3E02, 0x8801},
-	{0x3E04, 0x2301},
-	{0x3E06, 0x8449},
-	{0x3E08, 0x6841},
-	{0x3E0A, 0x400C},
-	{0x3E0C, 0x1001},
-	{0x3E0E, 0x2103},
-	{0x3E10, 0x4B41},
-	{0x3E12, 0x4B26},
-	{0x3E16, 0x8802},
-	{0x3E18, 0x84FF},
-	{0x3E1A, 0x8601},
-	{0x3E1C, 0x8401},
-	{0x3E1E, 0x840A},
-	{0x3E20, 0xFF00},
-	{0x3E22, 0x8401},
-	{0x3E24, 0x00FF},
-	{0x3E26, 0x0088},
-	{0x3E28, 0x2E8A},
-	{0x3E32, 0x8801},
-	{0x3E34, 0x4024},
-	{0x3E38, 0x8469},
-	{0x3E3C, 0x2301},
-	{0x3E3E, 0x3E25},
-	{0x3E40, 0x1C01},
-	{0x3E42, 0x8486},
-	{0x3E44, 0x8401},
-	{0x3E46, 0x00FF},
-	{0x3E48, 0x8401},
-	{0x3E4A, 0x8601},
-	{0x3E4C, 0x8402},
-	{0x3E4E, 0x00FF},
-	{0x3E50, 0x6623},
-	{0x3E52, 0x8340},
-	{0x3E54, 0x00FF},
-	{0x3E56, 0x4A42},
-	{0x3E58, 0x2203},
-	{0x3E5A, 0x674D},
-	{0x3E5C, 0x3F25},
-	{0x3E5E, 0x846A},
-	{0x3E60, 0x4C01},
-	{0x3E62, 0x8401},
-	{0x3E66, 0x3901},
-	{0x3ECC, 0x00EB},
-	{0x3ED0, 0x1E24},
-	{0x3ED4, 0xAFC4},
-	{0x3ED6, 0x909B},
-	{0x3ED8, 0x0006},
-	{0x3EDA, 0xCFC6},
-	{0x3EDC, 0x4FE4},
-	{0x3EE0, 0x2424},
-	{0x3EE2, 0x9797},
-	{0x3EE4, 0xC100},
-	{0x3EE6, 0x0540}
-};
-
-struct mt9e013_reg mt9e013_regs = {
-	.reg_mipi = &mipi_settings[0],
-	.reg_mipi_size = ARRAY_SIZE(mipi_settings),
-	.rec_settings = &recommend_settings[0],
-	.rec_size = ARRAY_SIZE(recommend_settings),
-	.reg_pll = &pll_settings[0],
-	.reg_pll_size = ARRAY_SIZE(pll_settings),
-	.reg_prev = &prev_settings[0],
-	.reg_pll_60fps = &pll_settings_60fps[0],
-	.reg_pll_60fps_size = ARRAY_SIZE(pll_settings_60fps),
-	.reg_pll_120fps = &pll_settings_120fps[0],
-	.reg_pll_120fps_size = ARRAY_SIZE(pll_settings_120fps),
-	.reg_prev_size = ARRAY_SIZE(prev_settings),
-	.reg_snap = &snap_settings[0],
-	.reg_snap_size = ARRAY_SIZE(snap_settings),
-	.reg_60fps = &prev_settings_60fps[0],
-	.reg_60fps_size = ARRAY_SIZE(prev_settings_60fps),
-	.reg_120fps = &prev_settings_120fps[0],
-	.reg_120fps_size = ARRAY_SIZE(prev_settings_120fps),
-};
diff --git a/drivers/media/platform/msm/camera_v1/mt9p012.h b/drivers/media/platform/msm/camera_v1/mt9p012.h
deleted file mode 100644
index a30b2f1..0000000
--- a/drivers/media/platform/msm/camera_v1/mt9p012.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Copyright (c) 2009-2012, The Linux Foundation. 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.
- *
- */
-
-#ifndef MT9T012_H
-#define MT9T012_H
-
-#include <linux/types.h>
-#include <mach/board.h>
-
-extern struct mt9p012_reg mt9p012_regs;	/* from mt9p012_reg.c */
-
-struct reg_struct {
-	uint16_t vt_pix_clk_div;     /* 0x0300 */
-	uint16_t vt_sys_clk_div;     /* 0x0302 */
-	uint16_t pre_pll_clk_div;    /* 0x0304 */
-	uint16_t pll_multiplier;     /* 0x0306 */
-	uint16_t op_pix_clk_div;     /* 0x0308 */
-	uint16_t op_sys_clk_div;     /* 0x030A */
-	uint16_t scale_m;            /* 0x0404 */
-	uint16_t row_speed;          /* 0x3016 */
-	uint16_t x_addr_start;       /* 0x3004 */
-	uint16_t x_addr_end;         /* 0x3008 */
-	uint16_t y_addr_start;       /* 0x3002 */
-	uint16_t y_addr_end;         /* 0x3006 */
-	uint16_t read_mode;          /* 0x3040 */
-	uint16_t x_output_size ;     /* 0x034C */
-	uint16_t y_output_size;      /* 0x034E */
-	uint16_t line_length_pck;    /* 0x300C */
-	uint16_t frame_length_lines; /* 0x300A */
-	uint16_t coarse_int_time;    /* 0x3012 */
-	uint16_t fine_int_time;      /* 0x3014 */
-};
-
-
-struct mt9p012_i2c_reg_conf {
-	unsigned short waddr;
-	unsigned short wdata;
-};
-
-
-struct mt9p012_reg {
-	struct reg_struct const *reg_pat;
-	uint16_t reg_pat_size;
-	struct mt9p012_i2c_reg_conf const *ttbl;
-	uint16_t ttbl_size;
-	struct mt9p012_i2c_reg_conf const *rftbl;
-	uint16_t rftbl_size;
-};
-
-#endif /* MT9T012_H */
diff --git a/drivers/media/platform/msm/camera_v1/mt9p012_bam.c b/drivers/media/platform/msm/camera_v1/mt9p012_bam.c
deleted file mode 100644
index 9363893..0000000
--- a/drivers/media/platform/msm/camera_v1/mt9p012_bam.c
+++ /dev/null
@@ -1,1426 +0,0 @@
-/* Copyright (c) 2008-2009, The Linux Foundation. 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.
- *
- */
-
-#include <linux/delay.h>
-#include <linux/types.h>
-#include <linux/i2c.h>
-#include <linux/uaccess.h>
-#include <linux/miscdevice.h>
-#include <linux/kernel.h>
-#include <media/msm_camera.h>
-#include <mach/gpio.h>
-#include <mach/camera.h>
-#include "mt9p012.h"
-
-/*=============================================================
-    SENSOR REGISTER DEFINES
-==============================================================*/
-#define MT9P012_REG_MODEL_ID         0x0000
-#define MT9P012_MODEL_ID             0x2801
-#define REG_GROUPED_PARAMETER_HOLD   0x0104
-#define GROUPED_PARAMETER_HOLD       0x0100
-#define GROUPED_PARAMETER_UPDATE     0x0000
-#define REG_COARSE_INT_TIME          0x3012
-#define REG_VT_PIX_CLK_DIV           0x0300
-#define REG_VT_SYS_CLK_DIV           0x0302
-#define REG_PRE_PLL_CLK_DIV          0x0304
-#define REG_PLL_MULTIPLIER           0x0306
-#define REG_OP_PIX_CLK_DIV           0x0308
-#define REG_OP_SYS_CLK_DIV           0x030A
-#define REG_SCALE_M                  0x0404
-#define REG_FRAME_LENGTH_LINES       0x300A
-#define REG_LINE_LENGTH_PCK          0x300C
-#define REG_X_ADDR_START             0x3004
-#define REG_Y_ADDR_START             0x3002
-#define REG_X_ADDR_END               0x3008
-#define REG_Y_ADDR_END               0x3006
-#define REG_X_OUTPUT_SIZE            0x034C
-#define REG_Y_OUTPUT_SIZE            0x034E
-#define REG_FINE_INTEGRATION_TIME    0x3014
-#define REG_ROW_SPEED                0x3016
-#define MT9P012_REG_RESET_REGISTER   0x301A
-#define MT9P012_RESET_REGISTER_PWON  0x10CC
-#define MT9P012_RESET_REGISTER_PWOFF 0x10C8
-#define REG_READ_MODE                0x3040
-#define REG_GLOBAL_GAIN              0x305E
-#define REG_TEST_PATTERN_MODE        0x3070
-
-#define MT9P012_REV_7
-
-enum mt9p012_test_mode {
-	TEST_OFF,
-	TEST_1,
-	TEST_2,
-	TEST_3
-};
-
-enum mt9p012_resolution {
-	QTR_SIZE,
-	FULL_SIZE,
-	INVALID_SIZE
-};
-
-enum mt9p012_reg_update {
-	/* Sensor egisters that need to be updated during initialization */
-	REG_INIT,
-	/* Sensor egisters that needs periodic I2C writes */
-	UPDATE_PERIODIC,
-	/* All the sensor Registers will be updated */
-	UPDATE_ALL,
-	/* Not valid update */
-	UPDATE_INVALID
-};
-
-enum mt9p012_setting {
-	RES_PREVIEW,
-	RES_CAPTURE
-};
-
-/* actuator's Slave Address */
-#define MT9P012_AF_I2C_ADDR   0x0A
-
-/* AF Total steps parameters */
-#define MT9P012_STEPS_NEAR_TO_CLOSEST_INF  20
-#define MT9P012_TOTAL_STEPS_NEAR_TO_FAR    20
-
-#define MT9P012_MU5M0_PREVIEW_DUMMY_PIXELS 0
-#define MT9P012_MU5M0_PREVIEW_DUMMY_LINES  0
-
-/* Time in milisecs for waiting for the sensor to reset.*/
-#define MT9P012_RESET_DELAY_MSECS   66
-
-/* for 20 fps preview */
-#define MT9P012_DEFAULT_CLOCK_RATE  24000000
-#define MT9P012_DEFAULT_MAX_FPS     26	/* ???? */
-
-struct mt9p012_work {
-	struct work_struct work;
-};
-static struct mt9p012_work *mt9p012_sensorw;
-static struct i2c_client *mt9p012_client;
-
-struct mt9p012_ctrl {
-	const struct msm_camera_sensor_info *sensordata;
-
-	int sensormode;
-	uint32_t fps_divider;	/* init to 1 * 0x00000400 */
-	uint32_t pict_fps_divider;	/* init to 1 * 0x00000400 */
-
-	uint16_t curr_lens_pos;
-	uint16_t init_curr_lens_pos;
-	uint16_t my_reg_gain;
-	uint32_t my_reg_line_count;
-
-	enum mt9p012_resolution prev_res;
-	enum mt9p012_resolution pict_res;
-	enum mt9p012_resolution curr_res;
-	enum mt9p012_test_mode set_test;
-};
-
-static uint16_t bam_macro, bam_infinite;
-static uint16_t bam_step_lookup_table[MT9P012_TOTAL_STEPS_NEAR_TO_FAR + 1];
-static uint16_t update_type = UPDATE_PERIODIC;
-static struct mt9p012_ctrl *mt9p012_ctrl;
-static DECLARE_WAIT_QUEUE_HEAD(mt9p012_wait_queue);
-DEFINE_MUTEX(mt9p012_mut);
-
-/*=============================================================*/
-
-static int mt9p012_i2c_rxdata(unsigned short saddr, int slength,
-			      unsigned char *rxdata, int rxlength)
-{
-	struct i2c_msg msgs[] = {
-		{
-			.addr = saddr,
-			.flags = 0,
-			.len = slength,
-			.buf = rxdata,
-		},
-		{
-			.addr = saddr,
-			.flags = I2C_M_RD,
-			.len = rxlength,
-			.buf = rxdata,
-		},
-	};
-
-	if (i2c_transfer(mt9p012_client->adapter, msgs, 2) < 0) {
-		CDBG("mt9p012_i2c_rxdata failed!\n");
-		return -EIO;
-	}
-
-	return 0;
-}
-static int32_t mt9p012_i2c_read_b(unsigned short saddr, unsigned char raddr,
-				  unsigned short *rdata)
-{
-	int32_t rc = 0;
-	if (!rdata)
-		return -EIO;
-	rc = mt9p012_i2c_rxdata(saddr, 1, &raddr, 1);
-	if (rc < 0)
-		return rc;
-	*rdata = raddr;
-	if (rc < 0)
-		CDBG("mt9p012_i2c_read_b failed!\n");
-	return rc;
-}
-
-static int32_t mt9p012_i2c_read_w(unsigned short saddr, unsigned short raddr,
-				  unsigned short *rdata)
-{
-	int32_t rc = 0;
-	unsigned char buf[4];
-
-	if (!rdata)
-		return -EIO;
-
-	memset(buf, 0, sizeof(buf));
-
-	buf[0] = (raddr & 0xFF00) >> 8;
-	buf[1] = (raddr & 0x00FF);
-
-	rc = mt9p012_i2c_rxdata(saddr, 2, buf, 2);
-	if (rc < 0)
-		return rc;
-
-	*rdata = buf[0] << 8 | buf[1];
-
-	if (rc < 0)
-		CDBG("mt9p012_i2c_read failed!\n");
-
-	return rc;
-}
-
-static int32_t mt9p012_i2c_txdata(unsigned short saddr, unsigned char *txdata,
-				  int length)
-{
-	struct i2c_msg msg[] = {
-		{
-		 .addr = saddr,
-		 .flags = 0,
-		 .len = length,
-		 .buf = txdata,
-		 },
-	};
-
-	if (i2c_transfer(mt9p012_client->adapter, msg, 1) < 0) {
-		CDBG("mt9p012_i2c_txdata failed\n");
-		return -EIO;
-	}
-
-	return 0;
-}
-
-static int32_t mt9p012_i2c_write_b(unsigned short saddr, unsigned short baddr,
-				   unsigned short bdata)
-{
-	int32_t rc = -EIO;
-	unsigned char buf[2];
-
-	memset(buf, 0, sizeof(buf));
-	buf[0] = baddr;
-	buf[1] = bdata;
-	rc = mt9p012_i2c_txdata(saddr, buf, 2);
-
-	if (rc < 0)
-		CDBG("i2c_write failed, saddr = 0x%x addr = 0x%x, val =0x%x!\n",
-		     saddr, baddr, bdata);
-
-	return rc;
-}
-
-static int32_t mt9p012_i2c_write_w(unsigned short saddr, unsigned short waddr,
-				   unsigned short wdata)
-{
-	int32_t rc = -EIO;
-	unsigned char buf[4];
-
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00) >> 8;
-	buf[1] = (waddr & 0x00FF);
-	buf[2] = (wdata & 0xFF00) >> 8;
-	buf[3] = (wdata & 0x00FF);
-
-	rc = mt9p012_i2c_txdata(saddr, buf, 4);
-
-	if (rc < 0)
-		CDBG("i2c_write_w failed, addr = 0x%x, val = 0x%x!\n",
-		     waddr, wdata);
-
-	return rc;
-}
-
-static int32_t mt9p012_i2c_write_w_table(struct mt9p012_i2c_reg_conf const
-					 *reg_conf_tbl, int num)
-{
-	int i;
-	int32_t rc = -EIO;
-
-	for (i = 0; i < num; i++) {
-		rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-					 reg_conf_tbl->waddr,
-					 reg_conf_tbl->wdata);
-		if (rc < 0)
-			break;
-		reg_conf_tbl++;
-	}
-
-	return rc;
-}
-
-static int32_t mt9p012_test(enum mt9p012_test_mode mo)
-{
-	int32_t rc = 0;
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-				 REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_HOLD);
-	if (rc < 0)
-		return rc;
-
-	if (mo == TEST_OFF)
-		return 0;
-	else {
-		rc = mt9p012_i2c_write_w_table(mt9p012_regs.ttbl,
-					       mt9p012_regs.ttbl_size);
-		if (rc < 0)
-			return rc;
-
-		rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-					 REG_TEST_PATTERN_MODE, (uint16_t) mo);
-		if (rc < 0)
-			return rc;
-	}
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-				 REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_UPDATE);
-	if (rc < 0)
-		return rc;
-
-	return rc;
-}
-
-static int32_t mt9p012_lens_shading_enable(uint8_t is_enable)
-{
-	int32_t rc = 0;
-
-	CDBG("%s: entered. enable = %d\n", __func__, is_enable);
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-				 REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_HOLD);
-	if (rc < 0)
-		return rc;
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr, 0x3780,
-				 ((uint16_t) is_enable) << 15);
-	if (rc < 0)
-		return rc;
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-				 REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_UPDATE);
-
-	CDBG("%s: exiting. rc = %d\n", __func__, rc);
-	return rc;
-}
-
-static int32_t mt9p012_set_lc(void)
-{
-	int32_t rc;
-
-	rc = mt9p012_i2c_write_w_table(mt9p012_regs.rftbl,
-				       mt9p012_regs.rftbl_size);
-
-	return rc;
-}
-
-static void mt9p012_get_pict_fps(uint16_t fps, uint16_t *pfps)
-{
-	/* input fps is preview fps in Q8 format */
-	uint32_t divider;	/*Q10 */
-	uint32_t pclk_mult;	/*Q10 */
-
-	if (mt9p012_ctrl->prev_res == QTR_SIZE) {
-		divider = (uint32_t)
-		    (((mt9p012_regs.reg_pat[RES_PREVIEW].frame_length_lines *
-		       mt9p012_regs.reg_pat[RES_PREVIEW].line_length_pck) *
-		      0x00000400) /
-		     (mt9p012_regs.reg_pat[RES_CAPTURE].frame_length_lines *
-		      mt9p012_regs.reg_pat[RES_CAPTURE].line_length_pck));
-
-		pclk_mult =
-		    (uint32_t) ((mt9p012_regs.reg_pat[RES_CAPTURE].
-				 pll_multiplier * 0x00000400) /
-				(mt9p012_regs.reg_pat[RES_PREVIEW].
-				 pll_multiplier));
-	} else {
-		/* full size resolution used for preview. */
-		divider = 0x00000400;	/*1.0 */
-		pclk_mult = 0x00000400;	/*1.0 */
-	}
-
-	/* Verify PCLK settings and frame sizes. */
-	*pfps = (uint16_t) (fps * divider * pclk_mult / 0x00000400 /
-			    0x00000400);
-}
-
-static uint16_t mt9p012_get_prev_lines_pf(void)
-{
-	if (mt9p012_ctrl->prev_res == QTR_SIZE)
-		return mt9p012_regs.reg_pat[RES_PREVIEW].frame_length_lines;
-	else
-		return mt9p012_regs.reg_pat[RES_CAPTURE].frame_length_lines;
-}
-
-static uint16_t mt9p012_get_prev_pixels_pl(void)
-{
-	if (mt9p012_ctrl->prev_res == QTR_SIZE)
-		return mt9p012_regs.reg_pat[RES_PREVIEW].line_length_pck;
-	else
-		return mt9p012_regs.reg_pat[RES_CAPTURE].line_length_pck;
-}
-
-static uint16_t mt9p012_get_pict_lines_pf(void)
-{
-	return mt9p012_regs.reg_pat[RES_CAPTURE].frame_length_lines;
-}
-
-static uint16_t mt9p012_get_pict_pixels_pl(void)
-{
-	return mt9p012_regs.reg_pat[RES_CAPTURE].line_length_pck;
-}
-
-static uint32_t mt9p012_get_pict_max_exp_lc(void)
-{
-	uint16_t snapshot_lines_per_frame;
-
-	if (mt9p012_ctrl->pict_res == QTR_SIZE)
-		snapshot_lines_per_frame =
-		    mt9p012_regs.reg_pat[RES_PREVIEW].frame_length_lines - 1;
-	else
-		snapshot_lines_per_frame =
-		    mt9p012_regs.reg_pat[RES_CAPTURE].frame_length_lines - 1;
-
-	return snapshot_lines_per_frame * 24;
-}
-
-static int32_t mt9p012_set_fps(struct fps_cfg *fps)
-{
-	/* input is new fps in Q10 format */
-	int32_t rc = 0;
-	enum mt9p012_setting setting;
-
-	mt9p012_ctrl->fps_divider = fps->fps_div;
-	mt9p012_ctrl->pict_fps_divider = fps->pict_fps_div;
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-				 REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_HOLD);
-	if (rc < 0)
-		return -EBUSY;
-
-	if (mt9p012_ctrl->sensormode == SENSOR_PREVIEW_MODE)
-		setting = RES_PREVIEW;
-	else
-		setting = RES_CAPTURE;
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-			REG_FRAME_LENGTH_LINES,
-			(mt9p012_regs.reg_pat[setting].frame_length_lines *
-			fps->fps_div / 0x00000400));
-	if (rc < 0)
-		return rc;
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-				 REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_UPDATE);
-
-	return rc;
-}
-
-static int32_t mt9p012_write_exp_gain(uint16_t gain, uint32_t line)
-{
-	uint16_t max_legal_gain = 0x01FF;
-	uint32_t line_length_ratio = 0x00000400;
-	enum mt9p012_setting setting;
-	int32_t rc = 0;
-
-	CDBG("Line:%d mt9p012_write_exp_gain \n", __LINE__);
-
-	if (mt9p012_ctrl->sensormode == SENSOR_PREVIEW_MODE) {
-		mt9p012_ctrl->my_reg_gain = gain;
-		mt9p012_ctrl->my_reg_line_count = (uint16_t) line;
-	}
-
-	if (gain > max_legal_gain) {
-		CDBG("Max legal gain Line:%d \n", __LINE__);
-		gain = max_legal_gain;
-	}
-
-	/* Verify no overflow */
-	if (mt9p012_ctrl->sensormode == SENSOR_PREVIEW_MODE) {
-		line = (uint32_t) (line * mt9p012_ctrl->fps_divider /
-				   0x00000400);
-		setting = RES_PREVIEW;
-	} else {
-		line = (uint32_t) (line * mt9p012_ctrl->pict_fps_divider /
-				   0x00000400);
-		setting = RES_CAPTURE;
-	}
-
-	/* Set digital gain to 1 */
-#ifdef MT9P012_REV_7
-	gain |= 0x1000;
-#else
-	gain |= 0x0200;
-#endif
-
-	if ((mt9p012_regs.reg_pat[setting].frame_length_lines - 1) < line) {
-		line_length_ratio = (uint32_t) (line * 0x00000400) /
-		    (mt9p012_regs.reg_pat[setting].frame_length_lines - 1);
-	} else
-		line_length_ratio = 0x00000400;
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr, REG_GLOBAL_GAIN, gain);
-	if (rc < 0) {
-		CDBG("mt9p012_i2c_write_w failed... Line:%d \n", __LINE__);
-		return rc;
-	}
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-				 REG_COARSE_INT_TIME, line);
-	if (rc < 0) {
-		CDBG("mt9p012_i2c_write_w failed... Line:%d \n", __LINE__);
-		return rc;
-	}
-
-	CDBG("mt9p012_write_exp_gain: gain = %d, line = %d\n", gain, line);
-
-	return rc;
-}
-
-static int32_t mt9p012_set_pict_exp_gain(uint16_t gain, uint32_t line)
-{
-	int32_t rc = 0;
-
-	CDBG("Line:%d mt9p012_set_pict_exp_gain \n", __LINE__);
-
-	rc = mt9p012_write_exp_gain(gain, line);
-	if (rc < 0) {
-		CDBG("Line:%d mt9p012_set_pict_exp_gain failed... \n",
-		     __LINE__);
-		return rc;
-	}
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-				 MT9P012_REG_RESET_REGISTER, 0x10CC | 0x0002);
-	if (rc < 0) {
-		CDBG("mt9p012_i2c_write_w failed... Line:%d \n", __LINE__);
-		return rc;
-	}
-
-	mdelay(5);
-
-	/* camera_timed_wait(snapshot_wait*exposure_ratio); */
-	return rc;
-}
-
-static int32_t mt9p012_setting(enum mt9p012_reg_update rupdate,
-			       enum mt9p012_setting rt)
-{
-	int32_t rc = 0;
-
-	switch (rupdate) {
-	case UPDATE_PERIODIC:
-		if (rt == RES_PREVIEW || rt == RES_CAPTURE) {
-			struct mt9p012_i2c_reg_conf ppc_tbl[] = {
-				{REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_HOLD},
-				{REG_ROW_SPEED,
-				 mt9p012_regs.reg_pat[rt].row_speed},
-				{REG_X_ADDR_START,
-				 mt9p012_regs.reg_pat[rt].x_addr_start},
-				{REG_X_ADDR_END,
-				 mt9p012_regs.reg_pat[rt].x_addr_end},
-				{REG_Y_ADDR_START,
-				 mt9p012_regs.reg_pat[rt].y_addr_start},
-				{REG_Y_ADDR_END,
-				 mt9p012_regs.reg_pat[rt].y_addr_end},
-				{REG_READ_MODE,
-				 mt9p012_regs.reg_pat[rt].read_mode},
-				{REG_SCALE_M, mt9p012_regs.reg_pat[rt].scale_m},
-				{REG_X_OUTPUT_SIZE,
-				 mt9p012_regs.reg_pat[rt].x_output_size},
-				{REG_Y_OUTPUT_SIZE,
-				 mt9p012_regs.reg_pat[rt].y_output_size},
-
-				{REG_LINE_LENGTH_PCK,
-				 mt9p012_regs.reg_pat[rt].line_length_pck},
-				{REG_FRAME_LENGTH_LINES,
-				 (mt9p012_regs.reg_pat[rt].frame_length_lines *
-				  mt9p012_ctrl->fps_divider / 0x00000400)},
-				{REG_COARSE_INT_TIME,
-				 mt9p012_regs.reg_pat[rt].coarse_int_time},
-				{REG_FINE_INTEGRATION_TIME,
-				 mt9p012_regs.reg_pat[rt].fine_int_time},
-				{REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_UPDATE},
-			};
-			if (update_type == REG_INIT) {
-				update_type = rupdate;
-				return rc;
-			}
-			rc = mt9p012_i2c_write_w_table(&ppc_tbl[0],
-						ARRAY_SIZE(ppc_tbl));
-			if (rc < 0)
-				return rc;
-
-			rc = mt9p012_test(mt9p012_ctrl->set_test);
-			if (rc < 0)
-				return rc;
-
-			rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-						 MT9P012_REG_RESET_REGISTER,
-						 MT9P012_RESET_REGISTER_PWON |
-						 0x0002);
-			if (rc < 0)
-				return rc;
-
-			mdelay(5);	/* 15? wait for sensor to transition */
-
-			return rc;
-		}
-		break;		/* UPDATE_PERIODIC */
-
-	case REG_INIT:
-		if (rt == RES_PREVIEW || rt == RES_CAPTURE) {
-			struct mt9p012_i2c_reg_conf ipc_tbl1[] = {
-				{MT9P012_REG_RESET_REGISTER,
-				 MT9P012_RESET_REGISTER_PWOFF},
-				{REG_VT_PIX_CLK_DIV,
-				 mt9p012_regs.reg_pat[rt].vt_pix_clk_div},
-				{REG_VT_SYS_CLK_DIV,
-				 mt9p012_regs.reg_pat[rt].vt_sys_clk_div},
-				{REG_PRE_PLL_CLK_DIV,
-				 mt9p012_regs.reg_pat[rt].pre_pll_clk_div},
-				{REG_PLL_MULTIPLIER,
-				 mt9p012_regs.reg_pat[rt].pll_multiplier},
-				{REG_OP_PIX_CLK_DIV,
-				 mt9p012_regs.reg_pat[rt].op_pix_clk_div},
-				{REG_OP_SYS_CLK_DIV,
-				 mt9p012_regs.reg_pat[rt].op_sys_clk_div},
-#ifdef MT9P012_REV_7
-				{0x30B0, 0x0001},
-				{0x308E, 0xE060},
-				{0x3092, 0x0A52},
-				{0x3094, 0x4656},
-				{0x3096, 0x5652},
-				{0x30CA, 0x8006},
-				{0x312A, 0xDD02},
-				{0x312C, 0x00E4},
-				{0x3170, 0x299A},
-#endif
-				/* optimized settings for noise */
-				{0x3088, 0x6FF6},
-				{0x3154, 0x0282},
-				{0x3156, 0x0381},
-				{0x3162, 0x04CE},
-				{0x0204, 0x0010},
-				{0x0206, 0x0010},
-				{0x0208, 0x0010},
-				{0x020A, 0x0010},
-				{0x020C, 0x0010},
-				{MT9P012_REG_RESET_REGISTER,
-				 MT9P012_RESET_REGISTER_PWON},
-			};
-
-			struct mt9p012_i2c_reg_conf ipc_tbl2[] = {
-				{MT9P012_REG_RESET_REGISTER,
-				 MT9P012_RESET_REGISTER_PWOFF},
-				{REG_VT_PIX_CLK_DIV,
-				 mt9p012_regs.reg_pat[rt].vt_pix_clk_div},
-				{REG_VT_SYS_CLK_DIV,
-				 mt9p012_regs.reg_pat[rt].vt_sys_clk_div},
-				{REG_PRE_PLL_CLK_DIV,
-				 mt9p012_regs.reg_pat[rt].pre_pll_clk_div},
-				{REG_PLL_MULTIPLIER,
-				 mt9p012_regs.reg_pat[rt].pll_multiplier},
-				{REG_OP_PIX_CLK_DIV,
-				 mt9p012_regs.reg_pat[rt].op_pix_clk_div},
-				{REG_OP_SYS_CLK_DIV,
-				 mt9p012_regs.reg_pat[rt].op_sys_clk_div},
-#ifdef MT9P012_REV_7
-				{0x30B0, 0x0001},
-				{0x308E, 0xE060},
-				{0x3092, 0x0A52},
-				{0x3094, 0x4656},
-				{0x3096, 0x5652},
-				{0x30CA, 0x8006},
-				{0x312A, 0xDD02},
-				{0x312C, 0x00E4},
-				{0x3170, 0x299A},
-#endif
-				/* optimized settings for noise */
-				{0x3088, 0x6FF6},
-				{0x3154, 0x0282},
-				{0x3156, 0x0381},
-				{0x3162, 0x04CE},
-				{0x0204, 0x0010},
-				{0x0206, 0x0010},
-				{0x0208, 0x0010},
-				{0x020A, 0x0010},
-				{0x020C, 0x0010},
-				{MT9P012_REG_RESET_REGISTER,
-				 MT9P012_RESET_REGISTER_PWON},
-			};
-
-			struct mt9p012_i2c_reg_conf ipc_tbl3[] = {
-				{REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_HOLD},
-				/* Set preview or snapshot mode */
-				{REG_ROW_SPEED,
-				 mt9p012_regs.reg_pat[rt].row_speed},
-				{REG_X_ADDR_START,
-				 mt9p012_regs.reg_pat[rt].x_addr_start},
-				{REG_X_ADDR_END,
-				 mt9p012_regs.reg_pat[rt].x_addr_end},
-				{REG_Y_ADDR_START,
-				 mt9p012_regs.reg_pat[rt].y_addr_start},
-				{REG_Y_ADDR_END,
-				 mt9p012_regs.reg_pat[rt].y_addr_end},
-				{REG_READ_MODE,
-				 mt9p012_regs.reg_pat[rt].read_mode},
-				{REG_SCALE_M, mt9p012_regs.reg_pat[rt].scale_m},
-				{REG_X_OUTPUT_SIZE,
-				 mt9p012_regs.reg_pat[rt].x_output_size},
-				{REG_Y_OUTPUT_SIZE,
-				 mt9p012_regs.reg_pat[rt].y_output_size},
-				{REG_LINE_LENGTH_PCK,
-				 mt9p012_regs.reg_pat[rt].line_length_pck},
-				{REG_FRAME_LENGTH_LINES,
-				 mt9p012_regs.reg_pat[rt].frame_length_lines},
-				{REG_COARSE_INT_TIME,
-				 mt9p012_regs.reg_pat[rt].coarse_int_time},
-				{REG_FINE_INTEGRATION_TIME,
-				 mt9p012_regs.reg_pat[rt].fine_int_time},
-				{REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_UPDATE},
-			};
-
-			/* reset fps_divider */
-			mt9p012_ctrl->fps_divider = 1 * 0x0400;
-
-			rc = mt9p012_i2c_write_w_table(&ipc_tbl1[0],
-						       ARRAY_SIZE(ipc_tbl1));
-			if (rc < 0)
-				return rc;
-
-			rc = mt9p012_i2c_write_w_table(&ipc_tbl2[0],
-						       ARRAY_SIZE(ipc_tbl2));
-			if (rc < 0)
-				return rc;
-
-			mdelay(5);
-
-			rc = mt9p012_i2c_write_w_table(&ipc_tbl3[0],
-						       ARRAY_SIZE(ipc_tbl3));
-			if (rc < 0)
-				return rc;
-
-			/* load lens shading */
-			rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-						 REG_GROUPED_PARAMETER_HOLD,
-						 GROUPED_PARAMETER_HOLD);
-			if (rc < 0)
-				return rc;
-
-			rc = mt9p012_set_lc();
-			if (rc < 0)
-				return rc;
-
-			rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-						 REG_GROUPED_PARAMETER_HOLD,
-						 GROUPED_PARAMETER_UPDATE);
-
-			if (rc < 0)
-				return rc;
-		}
-		update_type = rupdate;
-		break;		/* case REG_INIT: */
-
-	default:
-		rc = -EINVAL;
-		break;
-	}			/* switch (rupdate) */
-
-	return rc;
-}
-
-static int32_t mt9p012_video_config(int mode, int res)
-{
-	int32_t rc;
-
-	switch (res) {
-	case QTR_SIZE:
-		rc = mt9p012_setting(UPDATE_PERIODIC, RES_PREVIEW);
-		if (rc < 0)
-			return rc;
-
-		CDBG("mt9p012 sensor configuration done!\n");
-		break;
-
-	case FULL_SIZE:
-		rc = mt9p012_setting(UPDATE_PERIODIC, RES_CAPTURE);
-		if (rc < 0)
-			return rc;
-
-		break;
-
-	default:
-		return 0;
-	}			/* switch */
-
-	mt9p012_ctrl->prev_res = res;
-	mt9p012_ctrl->curr_res = res;
-	mt9p012_ctrl->sensormode = mode;
-
-	rc = mt9p012_write_exp_gain(mt9p012_ctrl->my_reg_gain,
-				    mt9p012_ctrl->my_reg_line_count);
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-				 MT9P012_REG_RESET_REGISTER, 0x10cc | 0x0002);
-
-	return rc;
-}
-
-static int32_t mt9p012_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-
-	rc = mt9p012_setting(UPDATE_PERIODIC, RES_CAPTURE);
-	if (rc < 0)
-		return rc;
-
-	mt9p012_ctrl->curr_res = mt9p012_ctrl->pict_res;
-
-	mt9p012_ctrl->sensormode = mode;
-
-	return rc;
-}
-
-static int32_t mt9p012_raw_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-
-	rc = mt9p012_setting(UPDATE_PERIODIC, RES_CAPTURE);
-	if (rc < 0)
-		return rc;
-
-	mt9p012_ctrl->curr_res = mt9p012_ctrl->pict_res;
-
-	mt9p012_ctrl->sensormode = mode;
-
-	return rc;
-}
-
-static int32_t mt9p012_power_down(void)
-{
-	int32_t rc = 0;
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-				 MT9P012_REG_RESET_REGISTER,
-				 MT9P012_RESET_REGISTER_PWOFF);
-
-	mdelay(5);
-	return rc;
-}
-
-static int32_t mt9p012_move_focus(int direction, int32_t num_steps)
-{
-	int32_t rc;
-	int16_t step_direction;
-	int16_t actual_step;
-	int16_t next_position;
-	uint8_t code_val;
-	uint8_t time_out;
-	uint8_t temp_pos;
-
-	uint16_t actual_position_target;
-	if (num_steps > MT9P012_TOTAL_STEPS_NEAR_TO_FAR)
-		num_steps = MT9P012_TOTAL_STEPS_NEAR_TO_FAR;
-	else if (num_steps == 0) {
-		CDBG("mt9p012_move_focus failed at line %d ...\n", __LINE__);
-		return -EINVAL;
-	}
-
-	if (direction == MOVE_NEAR)
-		step_direction = -1;
-	else if (direction == MOVE_FAR)
-		step_direction = 1;
-	else {
-		CDBG("mt9p012_move_focus failed at line %d ...\n", __LINE__);
-		return -EINVAL;
-	}
-
-	if (mt9p012_ctrl->curr_lens_pos < mt9p012_ctrl->init_curr_lens_pos)
-		mt9p012_ctrl->curr_lens_pos = mt9p012_ctrl->init_curr_lens_pos;
-
-	actual_step = (int16_t) (step_direction * (int16_t) num_steps);
-	next_position = (int16_t) (mt9p012_ctrl->curr_lens_pos + actual_step);
-
-	if (next_position > MT9P012_TOTAL_STEPS_NEAR_TO_FAR)
-		next_position = MT9P012_TOTAL_STEPS_NEAR_TO_FAR;
-	else if (next_position < 0)
-		next_position = 0;
-
-	if (num_steps >= 10)
-		time_out = 100;
-	else
-		time_out = 30;
-	code_val = next_position;
-	actual_position_target = bam_step_lookup_table[code_val];
-	rc = mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x01, 0x29);
-	if (rc < 0)
-		return rc;
-	temp_pos = (uint8_t) (actual_position_target >> 8);
-	rc = mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x05, temp_pos);
-	if (rc < 0)
-		return rc;
-	temp_pos = (uint8_t) (actual_position_target & 0x00FF);
-	/* code_val_lsb |= mode_mask; */
-	rc = mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x06, temp_pos);
-	if (rc < 0)
-		return rc;
-
-	rc = mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x0B, time_out);
-	if (rc < 0)
-		return rc;
-	rc = mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x07, 0x27);
-	if (rc < 0)
-		return rc;
-
-	mdelay(time_out);
-
-	/* Storing the current lens Position */
-	mt9p012_ctrl->curr_lens_pos = next_position;
-
-	return rc;
-}
-
-static int32_t mt9p012_set_default_focus(void)
-{
-	int32_t rc = 0;
-
-	uint8_t temp_pos;
-
-	/* Write the digital code for current to the actuator */
-	rc = mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x01, 0x29);
-	if (rc < 0)
-		return rc;
-	temp_pos = (uint8_t) (bam_infinite >> 8);
-
-	rc = mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x05, temp_pos);
-	if (rc < 0)
-		return rc;
-	temp_pos = (uint8_t) (bam_infinite & 0x00FF);
-	rc = mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x06, temp_pos);
-	if (rc < 0)
-		return rc;
-
-	rc = mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x0B, 0x64);
-	if (rc < 0)
-		return rc;
-
-	rc = mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x07, 0x27);
-	if (rc < 0)
-		return rc;
-
-	mdelay(140);
-
-	mt9p012_ctrl->curr_lens_pos = MT9P012_TOTAL_STEPS_NEAR_TO_FAR;
-
-	return rc;
-}
-
-static int mt9p012_probe_init_done(const struct msm_camera_sensor_info *data)
-{
-	gpio_direction_output(data->sensor_reset, 0);
-	gpio_free(data->sensor_reset);
-	return 0;
-}
-
-static int mt9p012_probe_init_sensor(const struct msm_camera_sensor_info *data)
-{
-	int32_t rc;
-	uint16_t chipid;
-
-	rc = gpio_request(data->sensor_reset, "mt9p012");
-	if (!rc)
-		gpio_direction_output(data->sensor_reset, 1);
-	else
-		goto init_probe_done;
-
-	msleep(20);
-
-	/* RESET the sensor image part via I2C command */
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-				 MT9P012_REG_RESET_REGISTER, 0x10CC | 0x0001);
-	if (rc < 0) {
-		CDBG("sensor reset failed. rc = %d\n", rc);
-		goto init_probe_fail;
-	}
-
-	msleep(MT9P012_RESET_DELAY_MSECS);
-
-	/* 3. Read sensor Model ID: */
-	rc = mt9p012_i2c_read_w(mt9p012_client->addr,
-				MT9P012_REG_MODEL_ID, &chipid);
-	if (rc < 0)
-		goto init_probe_fail;
-
-	/* 4. Compare sensor ID to MT9T012VC ID: */
-	if (chipid != MT9P012_MODEL_ID) {
-		rc = -ENODEV;
-		goto init_probe_fail;
-	}
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr, 0x306E, 0x9000);
-	if (rc < 0) {
-		CDBG("REV_7 write failed. rc = %d\n", rc);
-		goto init_probe_fail;
-	}
-
-	/* RESET_REGISTER, enable parallel interface and disable serialiser */
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr, 0x301A, 0x10CC);
-	if (rc < 0) {
-		CDBG("enable parallel interface failed. rc = %d\n", rc);
-		goto init_probe_fail;
-	}
-
-	/* To disable the 2 extra lines */
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr, 0x3064, 0x0805);
-
-	if (rc < 0) {
-		CDBG("disable the 2 extra lines failed. rc = %d\n", rc);
-		goto init_probe_fail;
-	}
-
-	goto init_probe_done;
-
-init_probe_fail:
-	mt9p012_probe_init_done(data);
-init_probe_done:
-	return rc;
-}
-
-static int mt9p012_sensor_open_init(const struct msm_camera_sensor_info *data)
-{
-	int32_t rc;
-	unsigned short temp_pos;
-	uint8_t i;
-	uint16_t temp;
-
-	mt9p012_ctrl = kzalloc(sizeof(struct mt9p012_ctrl), GFP_KERNEL);
-	if (!mt9p012_ctrl) {
-		CDBG("mt9p012_init failed!\n");
-		rc = -ENOMEM;
-		goto init_done;
-	}
-
-	mt9p012_ctrl->fps_divider = 1 * 0x00000400;
-	mt9p012_ctrl->pict_fps_divider = 1 * 0x00000400;
-	mt9p012_ctrl->set_test = TEST_OFF;
-	mt9p012_ctrl->prev_res = QTR_SIZE;
-	mt9p012_ctrl->pict_res = FULL_SIZE;
-
-	if (data)
-		mt9p012_ctrl->sensordata = data;
-
-	msm_camio_camif_pad_reg_reset();
-	mdelay(20);
-
-	rc = mt9p012_probe_init_sensor(data);
-	if (rc < 0)
-		goto init_fail1;
-
-	if (mt9p012_ctrl->prev_res == QTR_SIZE)
-		rc = mt9p012_setting(REG_INIT, RES_PREVIEW);
-	else
-		rc = mt9p012_setting(REG_INIT, RES_CAPTURE);
-
-	if (rc < 0) {
-		CDBG("mt9p012_setting failed. rc = %d\n", rc);
-		goto init_fail1;
-	}
-
-	/* sensor : output enable */
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-				 MT9P012_REG_RESET_REGISTER,
-				 MT9P012_RESET_REGISTER_PWON);
-	if (rc < 0) {
-		CDBG("sensor output enable failed. rc = %d\n", rc);
-		goto init_fail1;
-	}
-
-	/* enable AF actuator */
-	rc = gpio_request(mt9p012_ctrl->sensordata->vcm_pwd, "mt9p012");
-	if (!rc)
-		gpio_direction_output(mt9p012_ctrl->sensordata->vcm_pwd, 1);
-	else {
-		CDBG("mt9p012_ctrl gpio request failed!\n");
-		goto init_fail1;
-	}
-
-	mdelay(20);
-
-	bam_infinite = 0;
-	bam_macro = 0;
-	/*initialize AF actuator */
-	mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x01, 0x09);
-	mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x07, 0x2E);
-	mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x0A, 0x01);
-	mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x17, 0x06);
-	mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x16, 0x0A);
-
-	mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x01, 0x29);
-	mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x05, 0x00);
-	mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x06, 0x00);
-	mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x0B, 0x64);
-	mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x07, 0x27);
-	mdelay(140);
-	mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x01, 0x29);
-	mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x05, 0x03);
-	mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x06, 0xFF);
-	mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x0B, 0x64);
-	mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1, 0x07, 0x27);
-	mdelay(140);
-
-	if (mt9p012_i2c_read_b(MT9P012_AF_I2C_ADDR >> 1, 0x12, &temp_pos)
-	    >= 0) {
-		bam_infinite = (uint16_t) temp_pos;
-		if (mt9p012_i2c_read_b
-		    (MT9P012_AF_I2C_ADDR >> 1, 0x13, &temp_pos) >= 0)
-			bam_infinite =
-			    (bam_infinite << 8) | ((uint16_t) temp_pos);
-	} else {
-		bam_infinite = 100;
-	}
-
-	if (mt9p012_i2c_read_b(MT9P012_AF_I2C_ADDR >> 1, 0x14, &temp_pos)
-	    >= 0) {
-		bam_macro = (uint16_t) temp_pos;
-		if (mt9p012_i2c_read_b
-		    (MT9P012_AF_I2C_ADDR >> 1, 0x15, &temp_pos) >= 0)
-			bam_macro = (bam_macro << 8) | ((uint16_t) temp_pos);
-	}
-	temp = (bam_infinite - bam_macro) / MT9P012_TOTAL_STEPS_NEAR_TO_FAR;
-	for (i = 0; i < MT9P012_TOTAL_STEPS_NEAR_TO_FAR; i++)
-		bam_step_lookup_table[i] = bam_macro + temp * i;
-
-	bam_step_lookup_table[MT9P012_TOTAL_STEPS_NEAR_TO_FAR] = bam_infinite;
-
-	rc = mt9p012_set_default_focus();
-	if (rc >= 0)
-		goto init_done;
-
-init_fail1:
-	mt9p012_probe_init_done(data);
-	kfree(mt9p012_ctrl);
-init_done:
-	return rc;
-}
-
-static int mt9p012_init_client(struct i2c_client *client)
-{
-	/* Initialize the MSM_CAMI2C Chip */
-	init_waitqueue_head(&mt9p012_wait_queue);
-	return 0;
-}
-
-static int32_t mt9p012_set_sensor_mode(int mode, int res)
-{
-	int32_t rc = 0;
-
-	switch (mode) {
-	case SENSOR_PREVIEW_MODE:
-		rc = mt9p012_video_config(mode, res);
-		break;
-
-	case SENSOR_SNAPSHOT_MODE:
-		rc = mt9p012_snapshot_config(mode);
-		break;
-
-	case SENSOR_RAW_SNAPSHOT_MODE:
-		rc = mt9p012_raw_snapshot_config(mode);
-		break;
-
-	default:
-		rc = -EINVAL;
-		break;
-	}
-
-	return rc;
-}
-
-int mt9p012_sensor_config(void __user *argp)
-{
-	struct sensor_cfg_data cdata;
-	int rc = 0;
-
-	if (copy_from_user(&cdata,
-			   (void *)argp, sizeof(struct sensor_cfg_data)))
-		return -EFAULT;
-
-	mutex_lock(&mt9p012_mut);
-
-	CDBG("%s: cfgtype = %d\n", __func__, cdata.cfgtype);
-	switch (cdata.cfgtype) {
-	case CFG_GET_PICT_FPS:
-		mt9p012_get_pict_fps(cdata.cfg.gfps.prevfps,
-				     &(cdata.cfg.gfps.pictfps));
-
-		if (copy_to_user((void *)argp, &cdata,
-				 sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PREV_L_PF:
-		cdata.cfg.prevl_pf = mt9p012_get_prev_lines_pf();
-
-		if (copy_to_user((void *)argp,
-				 &cdata, sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PREV_P_PL:
-		cdata.cfg.prevp_pl = mt9p012_get_prev_pixels_pl();
-
-		if (copy_to_user((void *)argp,
-				 &cdata, sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PICT_L_PF:
-		cdata.cfg.pictl_pf = mt9p012_get_pict_lines_pf();
-
-		if (copy_to_user((void *)argp,
-				 &cdata, sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PICT_P_PL:
-		cdata.cfg.pictp_pl = mt9p012_get_pict_pixels_pl();
-
-		if (copy_to_user((void *)argp,
-				 &cdata, sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PICT_MAX_EXP_LC:
-		cdata.cfg.pict_max_exp_lc = mt9p012_get_pict_max_exp_lc();
-
-		if (copy_to_user((void *)argp,
-				 &cdata, sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_SET_FPS:
-	case CFG_SET_PICT_FPS:
-		rc = mt9p012_set_fps(&(cdata.cfg.fps));
-		break;
-
-	case CFG_SET_EXP_GAIN:
-		rc = mt9p012_write_exp_gain(cdata.cfg.exp_gain.gain,
-					    cdata.cfg.exp_gain.line);
-		break;
-
-	case CFG_SET_PICT_EXP_GAIN:
-		CDBG("Line:%d CFG_SET_PICT_EXP_GAIN \n", __LINE__);
-		rc = mt9p012_set_pict_exp_gain(cdata.cfg.exp_gain.gain,
-					       cdata.cfg.exp_gain.line);
-		break;
-
-	case CFG_SET_MODE:
-		rc = mt9p012_set_sensor_mode(cdata.mode, cdata.rs);
-		break;
-
-	case CFG_PWR_DOWN:
-		rc = mt9p012_power_down();
-		break;
-
-	case CFG_MOVE_FOCUS:
-		CDBG("mt9p012_ioctl: CFG_MOVE_FOCUS: dir=%d steps=%d\n",
-		     cdata.cfg.focus.dir, cdata.cfg.focus.steps);
-		rc = mt9p012_move_focus(cdata.cfg.focus.dir,
-					cdata.cfg.focus.steps);
-		break;
-
-	case CFG_SET_DEFAULT_FOCUS:
-		rc = mt9p012_set_default_focus();
-
-		break;
-
-	case CFG_SET_EFFECT:
-		rc = mt9p012_set_default_focus();
-		break;
-
-	case CFG_SET_LENS_SHADING:
-		CDBG("%s: CFG_SET_LENS_SHADING\n", __func__);
-		rc = mt9p012_lens_shading_enable(cdata.cfg.lens_shading);
-		break;
-
-	case CFG_GET_AF_MAX_STEPS:
-		cdata.max_steps = MT9P012_STEPS_NEAR_TO_CLOSEST_INF;
-		if (copy_to_user((void *)argp,
-				 &cdata, sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	default:
-		rc = -EINVAL;
-		break;
-	}
-
-	mutex_unlock(&mt9p012_mut);
-	return rc;
-}
-
-int mt9p012_sensor_release(void)
-{
-	int rc = -EBADF;
-
-	mutex_lock(&mt9p012_mut);
-
-	mt9p012_power_down();
-
-	gpio_direction_output(mt9p012_ctrl->sensordata->sensor_reset, 0);
-	gpio_free(mt9p012_ctrl->sensordata->sensor_reset);
-
-	gpio_direction_output(mt9p012_ctrl->sensordata->vcm_pwd, 0);
-	gpio_free(mt9p012_ctrl->sensordata->vcm_pwd);
-
-	kfree(mt9p012_ctrl);
-	mt9p012_ctrl = NULL;
-
-	CDBG("mt9p012_release completed\n");
-
-	mutex_unlock(&mt9p012_mut);
-	return rc;
-}
-
-static int mt9p012_i2c_probe(struct i2c_client *client,
-			     const struct i2c_device_id *id)
-{
-	int rc = 0;
-	CDBG("mt9p012_probe called!\n");
-
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		CDBG("i2c_check_functionality failed\n");
-		goto probe_failure;
-	}
-
-	mt9p012_sensorw = kzalloc(sizeof(struct mt9p012_work), GFP_KERNEL);
-	if (!mt9p012_sensorw) {
-		CDBG("kzalloc failed.\n");
-		rc = -ENOMEM;
-		goto probe_failure;
-	}
-
-	i2c_set_clientdata(client, mt9p012_sensorw);
-	mt9p012_init_client(client);
-	mt9p012_client = client;
-
-	mdelay(50);
-
-	CDBG("mt9p012_probe successed! rc = %d\n", rc);
-	return 0;
-
-probe_failure:
-	CDBG("mt9p012_probe failed! rc = %d\n", rc);
-	return rc;
-}
-
-static int __exit mt9p012_remove(struct i2c_client *client)
-{
-	struct mt9p012_work_t *sensorw = i2c_get_clientdata(client);
-	free_irq(client->irq, sensorw);
-	mt9p012_client = NULL;
-	kfree(sensorw);
-	return 0;
-}
-
-static const struct i2c_device_id mt9p012_i2c_id[] = {
-	{"mt9p012", 0}
-};
-
-static struct i2c_driver mt9p012_i2c_driver = {
-	.id_table = mt9p012_i2c_id,
-	.probe = mt9p012_i2c_probe,
-	.remove = __exit_p(mt9p012_i2c_remove),
-	.driver = {
-		.name = "mt9p012",
-	},
-};
-
-static int mt9p012_sensor_probe(const struct msm_camera_sensor_info *info,
-				struct msm_sensor_ctrl *s)
-{
-	int rc = i2c_add_driver(&mt9p012_i2c_driver);
-	if (rc < 0 || mt9p012_client == NULL) {
-		rc = -ENOTSUPP;
-		goto probe_done;
-	}
-
-	msm_camio_clk_rate_set(MT9P012_DEFAULT_CLOCK_RATE);
-	mdelay(20);
-
-	rc = mt9p012_probe_init_sensor(info);
-	if (rc < 0)
-		goto probe_done;
-
-	s->s_init = mt9p012_sensor_open_init;
-	s->s_release = mt9p012_sensor_release;
-	s->s_config = mt9p012_sensor_config;
-	s->s_mount_angle  = 0;
-	mt9p012_probe_init_done(info);
-
-probe_done:
-	CDBG("%s %s:%d\n", __FILE__, __func__, __LINE__);
-	return rc;
-}
-
-static int __mt9p012_probe(struct platform_device *pdev)
-{
-	return msm_camera_drv_start(pdev, mt9p012_sensor_probe);
-}
-
-static struct platform_driver msm_camera_driver = {
-	.probe = __mt9p012_probe,
-	.driver = {
-		.name = "msm_camera_mt9p012",
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init mt9p012_init(void)
-{
-	return platform_driver_register(&msm_camera_driver);
-}
-
-module_init(mt9p012_init);
-void mt9p012_exit(void)
-{
-	i2c_del_driver(&mt9p012_i2c_driver);
-}
diff --git a/drivers/media/platform/msm/camera_v1/mt9p012_fox.c b/drivers/media/platform/msm/camera_v1/mt9p012_fox.c
deleted file mode 100644
index a8d90c1..0000000
--- a/drivers/media/platform/msm/camera_v1/mt9p012_fox.c
+++ /dev/null
@@ -1,1346 +0,0 @@
-/* Copyright (c) 2009, 2011 The Linux Foundation. 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include <linux/types.h>
-#include <linux/i2c.h>
-#include <linux/uaccess.h>
-#include <linux/miscdevice.h>
-#include <linux/kernel.h>
-#include <media/msm_camera.h>
-#include <mach/gpio.h>
-#include <mach/camera.h>
-#include "mt9p012.h"
-
-/*=============================================================
-    SENSOR REGISTER DEFINES
-==============================================================*/
-#define MT9P012_REG_MODEL_ID         0x0000
-#define MT9P012_MODEL_ID             0x2801
-#define REG_GROUPED_PARAMETER_HOLD   0x0104
-#define GROUPED_PARAMETER_HOLD       0x0100
-#define GROUPED_PARAMETER_UPDATE     0x0000
-#define REG_COARSE_INT_TIME          0x3012
-#define REG_VT_PIX_CLK_DIV           0x0300
-#define REG_VT_SYS_CLK_DIV           0x0302
-#define REG_PRE_PLL_CLK_DIV          0x0304
-#define REG_PLL_MULTIPLIER           0x0306
-#define REG_OP_PIX_CLK_DIV           0x0308
-#define REG_OP_SYS_CLK_DIV           0x030A
-#define REG_SCALE_M                  0x0404
-#define REG_FRAME_LENGTH_LINES       0x300A
-#define REG_LINE_LENGTH_PCK          0x300C
-#define REG_X_ADDR_START             0x3004
-#define REG_Y_ADDR_START             0x3002
-#define REG_X_ADDR_END               0x3008
-#define REG_Y_ADDR_END               0x3006
-#define REG_X_OUTPUT_SIZE            0x034C
-#define REG_Y_OUTPUT_SIZE            0x034E
-#define REG_FINE_INTEGRATION_TIME    0x3014
-#define REG_ROW_SPEED                0x3016
-#define MT9P012_REG_RESET_REGISTER   0x301A
-#define MT9P012_RESET_REGISTER_PWON  0x10CC
-#define MT9P012_RESET_REGISTER_PWOFF 0x10C8
-#define REG_READ_MODE                0x3040
-#define REG_GLOBAL_GAIN              0x305E
-#define REG_TEST_PATTERN_MODE        0x3070
-
-#define MT9P012_REV_7
-
-enum mt9p012_test_mode {
-	TEST_OFF,
-	TEST_1,
-	TEST_2,
-	TEST_3
-};
-
-enum mt9p012_resolution {
-	QTR_SIZE,
-	FULL_SIZE,
-	INVALID_SIZE
-};
-
-enum mt9p012_reg_update {
-	/* Sensor egisters that need to be updated during initialization */
-	REG_INIT,
-	/* Sensor egisters that needs periodic I2C writes */
-	UPDATE_PERIODIC,
-	/* All the sensor Registers will be updated */
-	UPDATE_ALL,
-	/* Not valid update */
-	UPDATE_INVALID
-};
-
-enum mt9p012_setting {
-	RES_PREVIEW,
-	RES_CAPTURE
-};
-
-/* actuator's Slave Address */
-#define MT9P012_AF_I2C_ADDR   0x18
-
-/* AF Total steps parameters */
-#define MT9P012_STEPS_NEAR_TO_CLOSEST_INF  32
-#define MT9P012_TOTAL_STEPS_NEAR_TO_FAR    32
-
-#define MT9P012_MU5M0_PREVIEW_DUMMY_PIXELS 0
-#define MT9P012_MU5M0_PREVIEW_DUMMY_LINES  0
-
-/* Time in milisecs for waiting for the sensor to reset.*/
-#define MT9P012_RESET_DELAY_MSECS   66
-
-/* for 20 fps preview */
-#define MT9P012_DEFAULT_CLOCK_RATE  24000000
-#define MT9P012_DEFAULT_MAX_FPS     26	/* ???? */
-
-struct mt9p012_work {
-	struct work_struct work;
-};
-static struct mt9p012_work *mt9p012_sensorw;
-static struct i2c_client *mt9p012_client;
-
-struct mt9p012_ctrl {
-	const struct msm_camera_sensor_info *sensordata;
-
-	int sensormode;
-	uint32_t fps_divider;	/* init to 1 * 0x00000400 */
-	uint32_t pict_fps_divider;	/* init to 1 * 0x00000400 */
-
-	uint16_t curr_lens_pos;
-	uint16_t init_curr_lens_pos;
-	uint16_t my_reg_gain;
-	uint32_t my_reg_line_count;
-
-	enum mt9p012_resolution prev_res;
-	enum mt9p012_resolution pict_res;
-	enum mt9p012_resolution curr_res;
-	enum mt9p012_test_mode set_test;
-};
-static uint16_t update_type = UPDATE_PERIODIC;
-static struct mt9p012_ctrl *mt9p012_ctrl;
-static DECLARE_WAIT_QUEUE_HEAD(mt9p012_wait_queue);
-DEFINE_MUTEX(mt9p012_mut);
-
-
-/*=============================================================*/
-
-static int mt9p012_i2c_rxdata(unsigned short saddr, unsigned char *rxdata,
-			      int length)
-{
-	int retry_cnt = 0;
-	int rc;
-
-	struct i2c_msg msgs[] = {
-		{
-		 .addr = saddr,
-		 .flags = 0,
-		 .len = 2,
-		 .buf = rxdata,
-		 },
-		{
-		 .addr = saddr,
-		 .flags = I2C_M_RD,
-		 .len = length,
-		 .buf = rxdata,
-		 },
-	};
-
-	do {
-		rc = i2c_transfer(mt9p012_client->adapter, msgs, 2);
-		if (rc > 0)
-			break;
-		retry_cnt++;
-	} while (retry_cnt < 3);
-
-	if (rc < 0) {
-		pr_err("mt9p012_i2c_rxdata failed!:%d %d\n", rc, retry_cnt);
-		return -EIO;
-	}
-
-	return 0;
-}
-
-static int32_t mt9p012_i2c_read_w(unsigned short saddr, unsigned short raddr,
-				  unsigned short *rdata)
-{
-	int32_t rc = 0;
-	unsigned char buf[4];
-
-	if (!rdata)
-		return -EIO;
-
-	memset(buf, 0, sizeof(buf));
-
-	buf[0] = (raddr & 0xFF00) >> 8;
-	buf[1] = (raddr & 0x00FF);
-
-	rc = mt9p012_i2c_rxdata(saddr, buf, 2);
-	if (rc < 0)
-		return rc;
-
-	*rdata = buf[0] << 8 | buf[1];
-
-	if (rc < 0)
-		CDBG("mt9p012_i2c_read failed!\n");
-
-	return rc;
-}
-
-static int32_t mt9p012_i2c_txdata(unsigned short saddr, unsigned char *txdata,
-				  int length)
-{
-	int retry_cnt = 0;
-	int rc;
-
-	struct i2c_msg msg[] = {
-		{
-		 .addr = saddr,
-		 .flags = 0,
-		 .len = length,
-		 .buf = txdata,
-		 },
-	};
-
-	do {
-		rc = i2c_transfer(mt9p012_client->adapter, msg, 1);
-		if (rc > 0)
-			break;
-		retry_cnt++;
-	} while (retry_cnt < 3);
-
-	if (rc < 0) {
-		pr_err("mt9p012_i2c_txdata failed: %d %d\n", rc, retry_cnt);
-		return -EIO;
-	}
-
-	return 0;
-}
-
-static int32_t mt9p012_i2c_write_b(unsigned short saddr, unsigned short baddr,
-				   unsigned short bdata)
-{
-	int32_t rc = -EIO;
-	unsigned char buf[2];
-
-	memset(buf, 0, sizeof(buf));
-	buf[0] = baddr;
-	buf[1] = bdata;
-	rc = mt9p012_i2c_txdata(saddr, buf, 2);
-
-	if (rc < 0)
-		CDBG("i2c_write failed, saddr = 0x%x addr = 0x%x, val =0x%x!\n",
-		     saddr, baddr, bdata);
-
-	return rc;
-}
-
-static int32_t mt9p012_i2c_write_w(unsigned short saddr, unsigned short waddr,
-				   unsigned short wdata)
-{
-	int32_t rc = -EIO;
-	unsigned char buf[4];
-
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00) >> 8;
-	buf[1] = (waddr & 0x00FF);
-	buf[2] = (wdata & 0xFF00) >> 8;
-	buf[3] = (wdata & 0x00FF);
-
-	rc = mt9p012_i2c_txdata(saddr, buf, 4);
-
-	if (rc < 0)
-		CDBG("i2c_write_w failed, addr = 0x%x, val = 0x%x!\n",
-		     waddr, wdata);
-
-	return rc;
-}
-
-static int32_t mt9p012_i2c_write_w_table(struct mt9p012_i2c_reg_conf const
-					 *reg_conf_tbl, int num)
-{
-	int i;
-	int32_t rc = -EIO;
-
-	for (i = 0; i < num; i++) {
-		rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-					 reg_conf_tbl->waddr,
-					 reg_conf_tbl->wdata);
-		if (rc < 0)
-			break;
-		reg_conf_tbl++;
-	}
-
-	return rc;
-}
-
-static int32_t mt9p012_test(enum mt9p012_test_mode mo)
-{
-	int32_t rc = 0;
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-				 REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_HOLD);
-	if (rc < 0)
-		return rc;
-
-	if (mo == TEST_OFF)
-		return 0;
-	else {
-		rc = mt9p012_i2c_write_w_table(mt9p012_regs.ttbl,
-					       mt9p012_regs.ttbl_size);
-		if (rc < 0)
-			return rc;
-
-		rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-					 REG_TEST_PATTERN_MODE, (uint16_t) mo);
-		if (rc < 0)
-			return rc;
-	}
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-				 REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_UPDATE);
-	if (rc < 0)
-		return rc;
-
-	return rc;
-}
-
-static int32_t mt9p012_lens_shading_enable(uint8_t is_enable)
-{
-	int32_t rc = 0;
-
-	CDBG("%s: entered. enable = %d\n", __func__, is_enable);
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-				 REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_HOLD);
-	if (rc < 0)
-		return rc;
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr, 0x3780,
-				 ((uint16_t) is_enable) << 15);
-	if (rc < 0)
-		return rc;
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-				 REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_UPDATE);
-
-	CDBG("%s: exiting. rc = %d\n", __func__, rc);
-	return rc;
-}
-
-static int32_t mt9p012_set_lc(void)
-{
-	int32_t rc;
-
-	rc = mt9p012_i2c_write_w_table(mt9p012_regs.rftbl,
-				       mt9p012_regs.rftbl_size);
-
-	return rc;
-}
-
-static void mt9p012_get_pict_fps(uint16_t fps, uint16_t *pfps)
-{
-	/* input fps is preview fps in Q8 format */
-	uint32_t divider;	/*Q10 */
-	uint32_t pclk_mult;	/*Q10 */
-	uint32_t d1;
-	uint32_t d2;
-
-	d1 =
-		(uint32_t)(
-		(mt9p012_regs.reg_pat[RES_PREVIEW].frame_length_lines *
-		0x00000400) /
-		mt9p012_regs.reg_pat[RES_CAPTURE].frame_length_lines);
-
-	d2 =
-		(uint32_t)(
-		(mt9p012_regs.reg_pat[RES_PREVIEW].line_length_pck *
-		0x00000400) /
-		mt9p012_regs.reg_pat[RES_CAPTURE].line_length_pck);
-
-	divider = (uint32_t) (d1 * d2) / 0x00000400;
-
-	pclk_mult =
-		(uint32_t) ((mt9p012_regs.reg_pat[RES_CAPTURE].pll_multiplier *
-		0x00000400) /
-		(mt9p012_regs.reg_pat[RES_PREVIEW].pll_multiplier));
-
-	/* Verify PCLK settings and frame sizes. */
-	*pfps = (uint16_t) (fps * divider * pclk_mult / 0x00000400 /
-			    0x00000400);
-}
-
-static uint16_t mt9p012_get_prev_lines_pf(void)
-{
-	if (mt9p012_ctrl->prev_res == QTR_SIZE)
-		return mt9p012_regs.reg_pat[RES_PREVIEW].frame_length_lines;
-	else
-		return mt9p012_regs.reg_pat[RES_CAPTURE].frame_length_lines;
-}
-
-static uint16_t mt9p012_get_prev_pixels_pl(void)
-{
-	if (mt9p012_ctrl->prev_res == QTR_SIZE)
-		return mt9p012_regs.reg_pat[RES_PREVIEW].line_length_pck;
-	else
-		return mt9p012_regs.reg_pat[RES_CAPTURE].line_length_pck;
-}
-
-static uint16_t mt9p012_get_pict_lines_pf(void)
-{
-	return mt9p012_regs.reg_pat[RES_CAPTURE].frame_length_lines;
-}
-
-static uint16_t mt9p012_get_pict_pixels_pl(void)
-{
-	return mt9p012_regs.reg_pat[RES_CAPTURE].line_length_pck;
-}
-
-static uint32_t mt9p012_get_pict_max_exp_lc(void)
-{
-	uint16_t snapshot_lines_per_frame;
-
-	if (mt9p012_ctrl->pict_res == QTR_SIZE)
-		snapshot_lines_per_frame =
-		    mt9p012_regs.reg_pat[RES_PREVIEW].frame_length_lines - 1;
-	else
-		snapshot_lines_per_frame =
-		    mt9p012_regs.reg_pat[RES_CAPTURE].frame_length_lines - 1;
-
-	return snapshot_lines_per_frame * 24;
-}
-
-static int32_t mt9p012_set_fps(struct fps_cfg *fps)
-{
-	/* input is new fps in Q10 format */
-	int32_t rc = 0;
-	enum mt9p012_setting setting;
-
-	mt9p012_ctrl->fps_divider = fps->fps_div;
-	mt9p012_ctrl->pict_fps_divider = fps->pict_fps_div;
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-				 REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_HOLD);
-	if (rc < 0)
-		return -EBUSY;
-
-	if (mt9p012_ctrl->sensormode == SENSOR_PREVIEW_MODE)
-		setting = RES_PREVIEW;
-	else
-		setting = RES_CAPTURE;
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-		REG_FRAME_LENGTH_LINES,
-		(mt9p012_regs.reg_pat[setting].frame_length_lines *
-		fps->fps_div / 0x00000400));
-	if (rc < 0)
-		return rc;
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-				 REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_UPDATE);
-
-	return rc;
-}
-
-static int32_t mt9p012_write_exp_gain(uint16_t gain, uint32_t line)
-{
-	uint16_t max_legal_gain = 0x01FF;
-	uint32_t line_length_ratio = 0x00000400;
-	enum mt9p012_setting setting;
-	int32_t rc = 0;
-
-	CDBG("Line:%d mt9p012_write_exp_gain \n", __LINE__);
-
-	if (mt9p012_ctrl->sensormode == SENSOR_PREVIEW_MODE) {
-		mt9p012_ctrl->my_reg_gain = gain;
-		mt9p012_ctrl->my_reg_line_count = (uint16_t) line;
-	}
-
-	if (gain > max_legal_gain) {
-		CDBG("Max legal gain Line:%d \n", __LINE__);
-		gain = max_legal_gain;
-	}
-
-	/* Verify no overflow */
-	if (mt9p012_ctrl->sensormode == SENSOR_PREVIEW_MODE) {
-		line = (uint32_t) (line * mt9p012_ctrl->fps_divider /
-				   0x00000400);
-		setting = RES_PREVIEW;
-	} else {
-		line = (uint32_t) (line * mt9p012_ctrl->pict_fps_divider /
-				   0x00000400);
-		setting = RES_CAPTURE;
-	}
-
-	/* Set digital gain to 1 */
-#ifdef MT9P012_REV_7
-	gain |= 0x1000;
-#else
-	gain |= 0x0200;
-#endif
-
-	if ((mt9p012_regs.reg_pat[setting].frame_length_lines - 1) < line) {
-		line_length_ratio = (uint32_t) (line * 0x00000400) /
-		    (mt9p012_regs.reg_pat[setting].frame_length_lines - 1);
-	} else
-		line_length_ratio = 0x00000400;
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr, REG_GLOBAL_GAIN, gain);
-	if (rc < 0) {
-		CDBG("mt9p012_i2c_write_w failed... Line:%d \n", __LINE__);
-		return rc;
-	}
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-				 REG_COARSE_INT_TIME, line);
-	if (rc < 0) {
-		CDBG("mt9p012_i2c_write_w failed... Line:%d \n", __LINE__);
-		return rc;
-	}
-
-	CDBG("mt9p012_write_exp_gain: gain = %d, line = %d\n", gain, line);
-
-	return rc;
-}
-
-static int32_t mt9p012_set_pict_exp_gain(uint16_t gain, uint32_t line)
-{
-	int32_t rc = 0;
-
-	CDBG("Line:%d mt9p012_set_pict_exp_gain \n", __LINE__);
-
-	rc = mt9p012_write_exp_gain(gain, line);
-	if (rc < 0) {
-		CDBG("Line:%d mt9p012_set_pict_exp_gain failed... \n",
-		     __LINE__);
-		return rc;
-	}
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-				 MT9P012_REG_RESET_REGISTER, 0x10CC | 0x0002);
-	if (rc < 0) {
-		CDBG("mt9p012_i2c_write_w failed... Line:%d \n", __LINE__);
-		return rc;
-	}
-
-	mdelay(5);
-
-	/* camera_timed_wait(snapshot_wait*exposure_ratio); */
-	return rc;
-}
-
-static int32_t mt9p012_setting(enum mt9p012_reg_update rupdate,
-			       enum mt9p012_setting rt)
-{
-	int32_t rc = 0;
-	switch (rupdate) {
-	case UPDATE_PERIODIC:
-		if (rt == RES_PREVIEW || rt == RES_CAPTURE) {
-			struct mt9p012_i2c_reg_conf ppc_tbl[] = {
-				{REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_HOLD},
-				{REG_ROW_SPEED,
-				 mt9p012_regs.reg_pat[rt].row_speed},
-				{REG_X_ADDR_START,
-				 mt9p012_regs.reg_pat[rt].x_addr_start},
-				{REG_X_ADDR_END,
-				 mt9p012_regs.reg_pat[rt].x_addr_end},
-				{REG_Y_ADDR_START,
-				 mt9p012_regs.reg_pat[rt].y_addr_start},
-				{REG_Y_ADDR_END,
-				 mt9p012_regs.reg_pat[rt].y_addr_end},
-				{REG_READ_MODE,
-				 mt9p012_regs.reg_pat[rt].read_mode},
-				{REG_SCALE_M, mt9p012_regs.reg_pat[rt].scale_m},
-				{REG_X_OUTPUT_SIZE,
-				 mt9p012_regs.reg_pat[rt].x_output_size},
-				{REG_Y_OUTPUT_SIZE,
-				 mt9p012_regs.reg_pat[rt].y_output_size},
-
-				{REG_LINE_LENGTH_PCK,
-				 mt9p012_regs.reg_pat[rt].line_length_pck},
-				{REG_FRAME_LENGTH_LINES,
-				 (mt9p012_regs.reg_pat[rt].frame_length_lines *
-				  mt9p012_ctrl->fps_divider / 0x00000400)},
-				{REG_COARSE_INT_TIME,
-				 mt9p012_regs.reg_pat[rt].coarse_int_time},
-				{REG_FINE_INTEGRATION_TIME,
-				 mt9p012_regs.reg_pat[rt].fine_int_time},
-				{REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_UPDATE},
-			};
-			if (update_type == REG_INIT) {
-				update_type = rupdate;
-				return rc;
-			}
-			rc = mt9p012_i2c_write_w_table(&ppc_tbl[0],
-						ARRAY_SIZE(ppc_tbl));
-			if (rc < 0)
-				return rc;
-
-			rc = mt9p012_test(mt9p012_ctrl->set_test);
-			if (rc < 0)
-				return rc;
-
-			rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-						 MT9P012_REG_RESET_REGISTER,
-						 MT9P012_RESET_REGISTER_PWON |
-						 0x0002);
-			if (rc < 0)
-				return rc;
-
-			mdelay(5);	/* 15? wait for sensor to transition */
-
-			return rc;
-		}
-		break;		/* UPDATE_PERIODIC */
-
-	case REG_INIT:
-		if (rt == RES_PREVIEW || rt == RES_CAPTURE) {
-			struct mt9p012_i2c_reg_conf ipc_tbl1[] = {
-				{MT9P012_REG_RESET_REGISTER,
-				 MT9P012_RESET_REGISTER_PWOFF},
-				{REG_VT_PIX_CLK_DIV,
-				 mt9p012_regs.reg_pat[rt].vt_pix_clk_div},
-				{REG_VT_SYS_CLK_DIV,
-				 mt9p012_regs.reg_pat[rt].vt_sys_clk_div},
-				{REG_PRE_PLL_CLK_DIV,
-				 mt9p012_regs.reg_pat[rt].pre_pll_clk_div},
-				{REG_PLL_MULTIPLIER,
-				 mt9p012_regs.reg_pat[rt].pll_multiplier},
-				{REG_OP_PIX_CLK_DIV,
-				 mt9p012_regs.reg_pat[rt].op_pix_clk_div},
-				{REG_OP_SYS_CLK_DIV,
-				 mt9p012_regs.reg_pat[rt].op_sys_clk_div},
-#ifdef MT9P012_REV_7
-				{0x30B0, 0x0001},
-				{0x308E, 0xE060},
-				{0x3092, 0x0A52},
-				{0x3094, 0x4656},
-				{0x3096, 0x5652},
-				{0x30CA, 0x8006},
-				{0x312A, 0xDD02},
-				{0x312C, 0x00E4},
-				{0x3170, 0x299A},
-#endif
-				/* optimized settings for noise */
-				{0x3088, 0x6FF6},
-				{0x3154, 0x0282},
-				{0x3156, 0x0381},
-				{0x3162, 0x04CE},
-				{0x0204, 0x0010},
-				{0x0206, 0x0010},
-				{0x0208, 0x0010},
-				{0x020A, 0x0010},
-				{0x020C, 0x0010},
-				{MT9P012_REG_RESET_REGISTER,
-				 MT9P012_RESET_REGISTER_PWON},
-			};
-
-			struct mt9p012_i2c_reg_conf ipc_tbl2[] = {
-				{MT9P012_REG_RESET_REGISTER,
-				 MT9P012_RESET_REGISTER_PWOFF},
-				{REG_VT_PIX_CLK_DIV,
-				 mt9p012_regs.reg_pat[rt].vt_pix_clk_div},
-				{REG_VT_SYS_CLK_DIV,
-				 mt9p012_regs.reg_pat[rt].vt_sys_clk_div},
-				{REG_PRE_PLL_CLK_DIV,
-				 mt9p012_regs.reg_pat[rt].pre_pll_clk_div},
-				{REG_PLL_MULTIPLIER,
-				 mt9p012_regs.reg_pat[rt].pll_multiplier},
-				{REG_OP_PIX_CLK_DIV,
-				 mt9p012_regs.reg_pat[rt].op_pix_clk_div},
-				{REG_OP_SYS_CLK_DIV,
-				 mt9p012_regs.reg_pat[rt].op_sys_clk_div},
-#ifdef MT9P012_REV_7
-				{0x30B0, 0x0001},
-				{0x308E, 0xE060},
-				{0x3092, 0x0A52},
-				{0x3094, 0x4656},
-				{0x3096, 0x5652},
-				{0x30CA, 0x8006},
-				{0x312A, 0xDD02},
-				{0x312C, 0x00E4},
-				{0x3170, 0x299A},
-#endif
-				/* optimized settings for noise */
-				{0x3088, 0x6FF6},
-				{0x3154, 0x0282},
-				{0x3156, 0x0381},
-				{0x3162, 0x04CE},
-				{0x0204, 0x0010},
-				{0x0206, 0x0010},
-				{0x0208, 0x0010},
-				{0x020A, 0x0010},
-				{0x020C, 0x0010},
-				{MT9P012_REG_RESET_REGISTER,
-				 MT9P012_RESET_REGISTER_PWON},
-			};
-
-			struct mt9p012_i2c_reg_conf ipc_tbl3[] = {
-				{REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_HOLD},
-				/* Set preview or snapshot mode */
-				{REG_ROW_SPEED,
-				 mt9p012_regs.reg_pat[rt].row_speed},
-				{REG_X_ADDR_START,
-				 mt9p012_regs.reg_pat[rt].x_addr_start},
-				{REG_X_ADDR_END,
-				 mt9p012_regs.reg_pat[rt].x_addr_end},
-				{REG_Y_ADDR_START,
-				 mt9p012_regs.reg_pat[rt].y_addr_start},
-				{REG_Y_ADDR_END,
-				 mt9p012_regs.reg_pat[rt].y_addr_end},
-				{REG_READ_MODE,
-				 mt9p012_regs.reg_pat[rt].read_mode},
-				{REG_SCALE_M, mt9p012_regs.reg_pat[rt].scale_m},
-				{REG_X_OUTPUT_SIZE,
-				 mt9p012_regs.reg_pat[rt].x_output_size},
-				{REG_Y_OUTPUT_SIZE,
-				 mt9p012_regs.reg_pat[rt].y_output_size},
-				{REG_LINE_LENGTH_PCK,
-				 mt9p012_regs.reg_pat[rt].line_length_pck},
-				{REG_FRAME_LENGTH_LINES,
-				 mt9p012_regs.reg_pat[rt].frame_length_lines},
-				{REG_COARSE_INT_TIME,
-				 mt9p012_regs.reg_pat[rt].coarse_int_time},
-				{REG_FINE_INTEGRATION_TIME,
-				 mt9p012_regs.reg_pat[rt].fine_int_time},
-				{REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_UPDATE},
-			};
-
-			/* reset fps_divider */
-			mt9p012_ctrl->fps_divider = 1 * 0x0400;
-
-			rc = mt9p012_i2c_write_w_table(&ipc_tbl1[0],
-						       ARRAY_SIZE(ipc_tbl1));
-			if (rc < 0)
-				return rc;
-
-			rc = mt9p012_i2c_write_w_table(&ipc_tbl2[0],
-						       ARRAY_SIZE(ipc_tbl2));
-			if (rc < 0)
-				return rc;
-
-			mdelay(5);
-
-			rc = mt9p012_i2c_write_w_table(&ipc_tbl3[0],
-						       ARRAY_SIZE(ipc_tbl3));
-			if (rc < 0)
-				return rc;
-
-			/* load lens shading */
-			rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-						 REG_GROUPED_PARAMETER_HOLD,
-						 GROUPED_PARAMETER_HOLD);
-			if (rc < 0)
-				return rc;
-
-			rc = mt9p012_set_lc();
-			if (rc < 0)
-				return rc;
-
-			rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-						 REG_GROUPED_PARAMETER_HOLD,
-						 GROUPED_PARAMETER_UPDATE);
-
-			if (rc < 0)
-				return rc;
-		}
-		update_type = rupdate;
-		break;		/* case REG_INIT: */
-
-	default:
-		rc = -EINVAL;
-		break;
-	}			/* switch (rupdate) */
-
-	return rc;
-}
-
-static int32_t mt9p012_video_config(int mode, int res)
-{
-	int32_t rc;
-
-	switch (res) {
-	case QTR_SIZE:
-		rc = mt9p012_setting(UPDATE_PERIODIC, RES_PREVIEW);
-		if (rc < 0)
-			return rc;
-
-		CDBG("mt9p012 sensor configuration done!\n");
-		break;
-
-	case FULL_SIZE:
-		rc = mt9p012_setting(UPDATE_PERIODIC, RES_CAPTURE);
-		if (rc < 0)
-			return rc;
-
-		break;
-
-	default:
-		return 0;
-	}			/* switch */
-
-	mt9p012_ctrl->prev_res = res;
-	mt9p012_ctrl->curr_res = res;
-	mt9p012_ctrl->sensormode = mode;
-
-	rc = mt9p012_write_exp_gain(mt9p012_ctrl->my_reg_gain,
-				    mt9p012_ctrl->my_reg_line_count);
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-				 MT9P012_REG_RESET_REGISTER, 0x10cc | 0x0002);
-
-	return rc;
-}
-
-static int32_t mt9p012_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-
-	rc = mt9p012_setting(UPDATE_PERIODIC, RES_CAPTURE);
-	if (rc < 0)
-		return rc;
-
-	mt9p012_ctrl->curr_res = mt9p012_ctrl->pict_res;
-
-	mt9p012_ctrl->sensormode = mode;
-
-	return rc;
-}
-
-static int32_t mt9p012_raw_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-
-	rc = mt9p012_setting(UPDATE_PERIODIC, RES_CAPTURE);
-	if (rc < 0)
-		return rc;
-
-	mt9p012_ctrl->curr_res = mt9p012_ctrl->pict_res;
-
-	mt9p012_ctrl->sensormode = mode;
-
-	return rc;
-}
-
-static int32_t mt9p012_power_down(void)
-{
-	int32_t rc = 0;
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-				 MT9P012_REG_RESET_REGISTER,
-				 MT9P012_RESET_REGISTER_PWOFF);
-
-	mdelay(5);
-	return rc;
-}
-
-static int32_t mt9p012_move_focus(int direction, int32_t num_steps)
-{
-	int16_t step_direction;
-	int16_t actual_step;
-	int16_t next_position;
-	uint8_t code_val_msb, code_val_lsb;
-
-	if (num_steps > MT9P012_TOTAL_STEPS_NEAR_TO_FAR)
-		num_steps = MT9P012_TOTAL_STEPS_NEAR_TO_FAR;
-	else if (num_steps == 0) {
-		CDBG("mt9p012_move_focus failed at line %d ...\n", __LINE__);
-		return -EINVAL;
-	}
-
-	if (direction == MOVE_NEAR)
-		step_direction = 16;	/* 10bit */
-	else if (direction == MOVE_FAR)
-		step_direction = -16;	/* 10 bit */
-	else {
-		CDBG("mt9p012_move_focus failed at line %d ...\n", __LINE__);
-		return -EINVAL;
-	}
-
-	if (mt9p012_ctrl->curr_lens_pos < mt9p012_ctrl->init_curr_lens_pos)
-		mt9p012_ctrl->curr_lens_pos = mt9p012_ctrl->init_curr_lens_pos;
-
-	actual_step = (int16_t) (step_direction * (int16_t) num_steps);
-	next_position = (int16_t) (mt9p012_ctrl->curr_lens_pos + actual_step);
-
-	if (next_position > 1023)
-		next_position = 1023;
-	else if (next_position < 0)
-		next_position = 0;
-
-	code_val_msb = next_position >> 4;
-	code_val_lsb = (next_position & 0x000F) << 4;
-	/* code_val_lsb |= mode_mask; */
-
-	/* Writing the digital code for current to the actuator */
-	if (mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1,
-				code_val_msb, code_val_lsb) < 0) {
-		CDBG("mt9p012_move_focus failed at line %d ...\n", __LINE__);
-		return -EBUSY;
-	}
-
-	/* Storing the current lens Position */
-	mt9p012_ctrl->curr_lens_pos = next_position;
-
-	return 0;
-}
-
-static int32_t mt9p012_set_default_focus(void)
-{
-	int32_t rc = 0;
-	uint8_t code_val_msb, code_val_lsb;
-
-	code_val_msb = 0x00;
-	code_val_lsb = 0x00;
-
-	/* Write the digital code for current to the actuator */
-	rc = mt9p012_i2c_write_b(MT9P012_AF_I2C_ADDR >> 1,
-				 code_val_msb, code_val_lsb);
-
-	mt9p012_ctrl->curr_lens_pos = 0;
-	mt9p012_ctrl->init_curr_lens_pos = 0;
-
-	return rc;
-}
-
-static int mt9p012_probe_init_done(const struct msm_camera_sensor_info *data)
-{
-	gpio_direction_output(data->sensor_reset, 0);
-	gpio_free(data->sensor_reset);
-	return 0;
-}
-
-static int mt9p012_probe_init_sensor(const struct msm_camera_sensor_info *data)
-{
-	int32_t rc;
-	uint16_t chipid;
-
-	rc = gpio_request(data->sensor_reset, "mt9p012");
-	if (!rc)
-		gpio_direction_output(data->sensor_reset, 1);
-	else
-		goto init_probe_done;
-
-	msleep(20);
-
-	/* RESET the sensor image part via I2C command */
-	CDBG("mt9p012_sensor_init(): reseting sensor.\n");
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-				 MT9P012_REG_RESET_REGISTER, 0x10CC | 0x0001);
-	if (rc < 0) {
-		CDBG("sensor reset failed. rc = %d\n", rc);
-		goto init_probe_fail;
-	}
-
-	msleep(MT9P012_RESET_DELAY_MSECS);
-
-	/* 3. Read sensor Model ID: */
-	rc = mt9p012_i2c_read_w(mt9p012_client->addr,
-				MT9P012_REG_MODEL_ID, &chipid);
-	if (rc < 0)
-		goto init_probe_fail;
-
-	/* 4. Compare sensor ID to MT9T012VC ID: */
-	if (chipid != MT9P012_MODEL_ID) {
-		CDBG("mt9p012 wrong model_id = 0x%x\n", chipid);
-		rc = -ENODEV;
-		goto init_probe_fail;
-	}
-
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr, 0x306E, 0x9000);
-	if (rc < 0) {
-		CDBG("REV_7 write failed. rc = %d\n", rc);
-		goto init_probe_fail;
-	}
-
-	/* RESET_REGISTER, enable parallel interface and disable serialiser */
-	CDBG("mt9p012_sensor_init(): enabling parallel interface.\n");
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr, 0x301A, 0x10CC);
-	if (rc < 0) {
-		CDBG("enable parallel interface failed. rc = %d\n", rc);
-		goto init_probe_fail;
-	}
-
-	/* To disable the 2 extra lines */
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr, 0x3064, 0x0805);
-
-	if (rc < 0) {
-		CDBG("disable the 2 extra lines failed. rc = %d\n", rc);
-		goto init_probe_fail;
-	}
-	goto init_probe_done;
-
-init_probe_fail:
-	mt9p012_probe_init_done(data);
-init_probe_done:
-	return rc;
-}
-
-static int mt9p012_sensor_open_init(const struct msm_camera_sensor_info *data)
-{
-	int32_t rc;
-
-	mt9p012_ctrl = kzalloc(sizeof(struct mt9p012_ctrl), GFP_KERNEL);
-	if (!mt9p012_ctrl) {
-		CDBG("mt9p012_init failed!\n");
-		rc = -ENOMEM;
-		goto init_done;
-	}
-
-	mt9p012_ctrl->fps_divider = 1 * 0x00000400;
-	mt9p012_ctrl->pict_fps_divider = 1 * 0x00000400;
-	mt9p012_ctrl->set_test = TEST_OFF;
-	mt9p012_ctrl->prev_res = QTR_SIZE;
-	mt9p012_ctrl->pict_res = FULL_SIZE;
-
-	if (data)
-		mt9p012_ctrl->sensordata = data;
-
-	msm_camio_camif_pad_reg_reset();
-	mdelay(20);
-
-	rc = mt9p012_probe_init_sensor(data);
-	if (rc < 0)
-		goto init_fail1;
-
-	if (mt9p012_ctrl->prev_res == QTR_SIZE)
-		rc = mt9p012_setting(REG_INIT, RES_PREVIEW);
-	else
-		rc = mt9p012_setting(REG_INIT, RES_CAPTURE);
-
-	if (rc < 0) {
-		CDBG("mt9p012_setting failed. rc = %d\n", rc);
-		goto init_fail1;
-	}
-
-	/* sensor : output enable */
-	CDBG("mt9p012_sensor_open_init(): enabling output.\n");
-	rc = mt9p012_i2c_write_w(mt9p012_client->addr,
-				 MT9P012_REG_RESET_REGISTER,
-				 MT9P012_RESET_REGISTER_PWON);
-	if (rc < 0) {
-		CDBG("sensor output enable failed. rc = %d\n", rc);
-		goto init_fail1;
-	}
-
-	/* enable AF actuator */
-	if (mt9p012_ctrl->sensordata->vcm_enable) {
-		CDBG("enable AF actuator, gpio = %d\n",
-			 mt9p012_ctrl->sensordata->vcm_pwd);
-		rc = gpio_request(mt9p012_ctrl->sensordata->vcm_pwd,
-						"mt9p012");
-		if (!rc)
-			gpio_direction_output(
-				mt9p012_ctrl->sensordata->vcm_pwd,
-				 1);
-		else {
-			CDBG("mt9p012_ctrl gpio request failed!\n");
-			goto init_fail1;
-		}
-		msleep(20);
-		rc = mt9p012_set_default_focus();
-		if (rc < 0) {
-			gpio_direction_output(mt9p012_ctrl->sensordata->vcm_pwd,
-								0);
-			gpio_free(mt9p012_ctrl->sensordata->vcm_pwd);
-		}
-	}
-	if (rc >= 0)
-		goto init_done;
-init_fail1:
-	mt9p012_probe_init_done(data);
-	kfree(mt9p012_ctrl);
-init_done:
-	return rc;
-}
-
-static int mt9p012_init_client(struct i2c_client *client)
-{
-	/* Initialize the MSM_CAMI2C Chip */
-	init_waitqueue_head(&mt9p012_wait_queue);
-	return 0;
-}
-
-static int32_t mt9p012_set_sensor_mode(int mode, int res)
-{
-	int32_t rc = 0;
-
-	switch (mode) {
-	case SENSOR_PREVIEW_MODE:
-		rc = mt9p012_video_config(mode, res);
-		break;
-
-	case SENSOR_SNAPSHOT_MODE:
-		rc = mt9p012_snapshot_config(mode);
-		break;
-
-	case SENSOR_RAW_SNAPSHOT_MODE:
-		rc = mt9p012_raw_snapshot_config(mode);
-		break;
-
-	default:
-		rc = -EINVAL;
-		break;
-	}
-
-	return rc;
-}
-
-int mt9p012_sensor_config(void __user *argp)
-{
-	struct sensor_cfg_data cdata;
-	int rc = 0;
-
-	if (copy_from_user(&cdata,
-			   (void *)argp, sizeof(struct sensor_cfg_data)))
-		return -EFAULT;
-
-	mutex_lock(&mt9p012_mut);
-
-	CDBG("%s: cfgtype = %d\n", __func__, cdata.cfgtype);
-	switch (cdata.cfgtype) {
-	case CFG_GET_PICT_FPS:
-		mt9p012_get_pict_fps(cdata.cfg.gfps.prevfps,
-				     &(cdata.cfg.gfps.pictfps));
-
-		if (copy_to_user((void *)argp, &cdata,
-				 sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PREV_L_PF:
-		cdata.cfg.prevl_pf = mt9p012_get_prev_lines_pf();
-
-		if (copy_to_user((void *)argp,
-				 &cdata, sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PREV_P_PL:
-		cdata.cfg.prevp_pl = mt9p012_get_prev_pixels_pl();
-
-		if (copy_to_user((void *)argp,
-				 &cdata, sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PICT_L_PF:
-		cdata.cfg.pictl_pf = mt9p012_get_pict_lines_pf();
-
-		if (copy_to_user((void *)argp,
-				 &cdata, sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PICT_P_PL:
-		cdata.cfg.pictp_pl = mt9p012_get_pict_pixels_pl();
-
-		if (copy_to_user((void *)argp,
-				 &cdata, sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PICT_MAX_EXP_LC:
-		cdata.cfg.pict_max_exp_lc = mt9p012_get_pict_max_exp_lc();
-
-		if (copy_to_user((void *)argp,
-				 &cdata, sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_SET_FPS:
-	case CFG_SET_PICT_FPS:
-		rc = mt9p012_set_fps(&(cdata.cfg.fps));
-		break;
-
-	case CFG_SET_EXP_GAIN:
-		rc = mt9p012_write_exp_gain(cdata.cfg.exp_gain.gain,
-					    cdata.cfg.exp_gain.line);
-		break;
-
-	case CFG_SET_PICT_EXP_GAIN:
-		CDBG("Line:%d CFG_SET_PICT_EXP_GAIN \n", __LINE__);
-		rc = mt9p012_set_pict_exp_gain(cdata.cfg.exp_gain.gain,
-					       cdata.cfg.exp_gain.line);
-		break;
-
-	case CFG_SET_MODE:
-		rc = mt9p012_set_sensor_mode(cdata.mode, cdata.rs);
-		break;
-
-	case CFG_PWR_DOWN:
-		rc = mt9p012_power_down();
-		break;
-
-	case CFG_MOVE_FOCUS:
-		CDBG("mt9p012_ioctl: CFG_MOVE_FOCUS: cdata.cfg.focus.dir=%d \
-				cdata.cfg.focus.steps=%d\n",
-				cdata.cfg.focus.dir, cdata.cfg.focus.steps);
-		rc = mt9p012_move_focus(cdata.cfg.focus.dir,
-					cdata.cfg.focus.steps);
-		break;
-
-	case CFG_SET_DEFAULT_FOCUS:
-		rc = mt9p012_set_default_focus();
-		break;
-
-	case CFG_SET_LENS_SHADING:
-		CDBG("%s: CFG_SET_LENS_SHADING\n", __func__);
-		rc = mt9p012_lens_shading_enable(cdata.cfg.lens_shading);
-		break;
-
-	case CFG_GET_AF_MAX_STEPS:
-		cdata.max_steps = MT9P012_STEPS_NEAR_TO_CLOSEST_INF;
-		if (copy_to_user((void *)argp,
-				 &cdata, sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_SET_EFFECT:
-	default:
-		rc = -EINVAL;
-		break;
-	}
-
-	mutex_unlock(&mt9p012_mut);
-	return rc;
-}
-
-int mt9p012_sensor_release(void)
-{
-	int rc = -EBADF;
-
-	mutex_lock(&mt9p012_mut);
-
-	mt9p012_power_down();
-
-	gpio_direction_output(mt9p012_ctrl->sensordata->sensor_reset, 0);
-	gpio_free(mt9p012_ctrl->sensordata->sensor_reset);
-
-	if (mt9p012_ctrl->sensordata->vcm_enable) {
-		gpio_direction_output(mt9p012_ctrl->sensordata->vcm_pwd, 0);
-		gpio_free(mt9p012_ctrl->sensordata->vcm_pwd);
-	}
-
-	kfree(mt9p012_ctrl);
-	mt9p012_ctrl = NULL;
-
-	CDBG("mt9p012_release completed\n");
-
-	mutex_unlock(&mt9p012_mut);
-	return rc;
-}
-
-static int mt9p012_i2c_probe(struct i2c_client *client,
-			     const struct i2c_device_id *id)
-{
-	int rc = 0;
-	CDBG("mt9p012_probe called!\n");
-
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		CDBG("i2c_check_functionality failed\n");
-		goto probe_failure;
-	}
-
-	mt9p012_sensorw = kzalloc(sizeof(struct mt9p012_work), GFP_KERNEL);
-	if (!mt9p012_sensorw) {
-		CDBG("kzalloc failed.\n");
-		rc = -ENOMEM;
-		goto probe_failure;
-	}
-
-	i2c_set_clientdata(client, mt9p012_sensorw);
-	mt9p012_init_client(client);
-	mt9p012_client = client;
-
-	mdelay(50);
-
-	CDBG("mt9p012_probe successed! rc = %d\n", rc);
-	return 0;
-
-probe_failure:
-	CDBG("mt9p012_probe failed! rc = %d\n", rc);
-	return rc;
-}
-
-static const struct i2c_device_id mt9p012_i2c_id[] = {
-	{"mt9p012", 0},
-	{}
-};
-
-static struct i2c_driver mt9p012_i2c_driver = {
-	.id_table = mt9p012_i2c_id,
-	.probe = mt9p012_i2c_probe,
-	.remove = __exit_p(mt9p012_i2c_remove),
-	.driver = {
-		   .name = "mt9p012",
-		   },
-};
-
-static int mt9p012_sensor_probe(const struct msm_camera_sensor_info *info,
-				struct msm_sensor_ctrl *s)
-{
-	int rc = i2c_add_driver(&mt9p012_i2c_driver);
-	if (rc < 0 || mt9p012_client == NULL) {
-		rc = -ENOTSUPP;
-		goto probe_done;
-	}
-
-	msm_camio_clk_rate_set(MT9P012_DEFAULT_CLOCK_RATE);
-	mdelay(20);
-
-	rc = mt9p012_probe_init_sensor(info);
-	if (rc < 0)
-		goto probe_done;
-
-	s->s_init = mt9p012_sensor_open_init;
-	s->s_release = mt9p012_sensor_release;
-	s->s_config = mt9p012_sensor_config;
-	s->s_mount_angle  = 0;
-	mt9p012_probe_init_done(info);
-
-probe_done:
-	CDBG("%s %s:%d\n", __FILE__, __func__, __LINE__);
-	return rc;
-}
-
-static int __mt9p012_probe(struct platform_device *pdev)
-{
-	return msm_camera_drv_start(pdev, mt9p012_sensor_probe);
-}
-
-static struct platform_driver msm_camera_driver = {
-	.probe = __mt9p012_probe,
-	.driver = {
-		   .name = "msm_camera_mt9p012",
-		   .owner = THIS_MODULE,
-		   },
-};
-
-static int __init mt9p012_init(void)
-{
-	return platform_driver_register(&msm_camera_driver);
-}
-
-module_init(mt9p012_init);
diff --git a/drivers/media/platform/msm/camera_v1/mt9p012_km.c b/drivers/media/platform/msm/camera_v1/mt9p012_km.c
deleted file mode 100644
index 959023b..0000000
--- a/drivers/media/platform/msm/camera_v1/mt9p012_km.c
+++ /dev/null
@@ -1,1296 +0,0 @@
-/* Copyright (c) 2009-2010, The Linux Foundation. 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include <linux/types.h>
-#include <linux/i2c.h>
-#include <linux/uaccess.h>
-#include <linux/miscdevice.h>
-#include <linux/kernel.h>
-#include <media/msm_camera.h>
-#include <mach/gpio.h>
-#include <mach/camera.h>
-#include "mt9p012_km.h"
-
-/*=============================================================
-    SENSOR REGISTER DEFINES
-==============================================================*/
-
-#define MT9P012_KM_REG_MODEL_ID      0x0000
-#define MT9P012_KM_MODEL_ID          0x2800
-#define REG_GROUPED_PARAMETER_HOLD   0x0104
-#define GROUPED_PARAMETER_HOLD       0x0100
-#define GROUPED_PARAMETER_UPDATE     0x0000
-#define REG_COARSE_INT_TIME          0x3012
-#define REG_VT_PIX_CLK_DIV           0x0300
-#define REG_VT_SYS_CLK_DIV           0x0302
-#define REG_PRE_PLL_CLK_DIV          0x0304
-#define REG_PLL_MULTIPLIER           0x0306
-#define REG_OP_PIX_CLK_DIV           0x0308
-#define REG_OP_SYS_CLK_DIV           0x030A
-#define REG_SCALE_M                  0x0404
-#define REG_FRAME_LENGTH_LINES       0x300A
-#define REG_LINE_LENGTH_PCK          0x300C
-#define REG_X_ADDR_START             0x3004
-#define REG_Y_ADDR_START             0x3002
-#define REG_X_ADDR_END               0x3008
-#define REG_Y_ADDR_END               0x3006
-#define REG_X_OUTPUT_SIZE            0x034C
-#define REG_Y_OUTPUT_SIZE            0x034E
-#define REG_FINE_INTEGRATION_TIME    0x3014
-#define REG_ROW_SPEED                0x3016
-#define MT9P012_KM_REG_RESET_REGISTER   0x301A
-#define MT9P012_KM_RESET_REGISTER_PWON  0x10CC
-#define MT9P012_KM_RESET_REGISTER_PWOFF 0x10C8
-#define REG_READ_MODE                0x3040
-#define REG_GLOBAL_GAIN              0x305E
-#define REG_TEST_PATTERN_MODE        0x3070
-
-enum mt9p012_km_test_mode {
-	TEST_OFF,
-	TEST_1,
-	TEST_2,
-	TEST_3
-};
-
-enum mt9p012_km_resolution {
-	QTR_SIZE,
-	FULL_SIZE,
-	INVALID_SIZE
-};
-
-enum mt9p012_km_reg_update {
-	/* Sensor egisters that need to be updated during initialization */
-	REG_INIT,
-	/* Sensor egisters that needs periodic I2C writes */
-	UPDATE_PERIODIC,
-	/* All the sensor Registers will be updated */
-	UPDATE_ALL,
-	/* Not valid update */
-	UPDATE_INVALID
-};
-
-enum mt9p012_km_setting {
-	RES_PREVIEW,
-	RES_CAPTURE
-};
-
-uint8_t mode_mask = 0x04;
-
-/* actuator's Slave Address */
-#define MT9P012_KM_AF_I2C_ADDR   (0x18 >> 1)
-
-/* AF Total steps parameters */
-#define MT9P012_KM_STEPS_NEAR_TO_CLOSEST_INF  30
-#define MT9P012_KM_TOTAL_STEPS_NEAR_TO_FAR    30
-
-/* Time in milisecs for waiting for the sensor to reset.*/
-#define MT9P012_KM_RESET_DELAY_MSECS   66
-
-/* for 20 fps preview */
-#define MT9P012_KM_DEFAULT_CLOCK_RATE  24000000
-
-struct mt9p012_km_work {
-	struct work_struct work;
-};
-static struct mt9p012_km_work *mt9p012_km_sensorw;
-static struct i2c_client *mt9p012_km_client;
-
-struct mt9p012_km_ctrl {
-	const struct msm_camera_sensor_info *sensordata;
-
-	int sensormode;
-	uint32_t fps_divider;	/* init to 1 * 0x00000400 */
-	uint32_t pict_fps_divider;	/* init to 1 * 0x00000400 */
-
-	uint16_t curr_lens_pos;
-	uint16_t init_curr_lens_pos;
-	uint16_t my_reg_gain;
-	uint32_t my_reg_line_count;
-
-	enum mt9p012_km_resolution prev_res;
-	enum mt9p012_km_resolution pict_res;
-	enum mt9p012_km_resolution curr_res;
-	enum mt9p012_km_test_mode set_test;
-};
-static uint16_t update_type = UPDATE_PERIODIC;
-static struct mt9p012_km_ctrl *mt9p012_km_ctrl;
-static DECLARE_WAIT_QUEUE_HEAD(mt9p012_km_wait_queue);
-DEFINE_MUTEX(mt9p012_km_mut);
-
-/*=============================================================*/
-
-static int mt9p012_km_i2c_rxdata(unsigned short saddr, unsigned char *rxdata,
-			int length)
-{
-	struct i2c_msg msgs[] = {
-		{
-			.addr = saddr << 1,
-			.flags = 0,
-			.len = 2,
-			.buf = rxdata,
-		},
-		{
-			.addr = saddr << 1,
-			.flags = I2C_M_RD,
-			.len = length,
-			.buf = rxdata,
-		},
-	};
-
-	if (i2c_transfer(mt9p012_km_client->adapter, msgs, 2) < 0) {
-		CDBG("mt9p012_km_i2c_rxdata failed!\n");
-		return -EIO;
-	}
-
-	return 0;
-}
-
-static int32_t mt9p012_km_i2c_read_w(unsigned short saddr, unsigned short raddr,
-				  unsigned short *rdata)
-{
-	int32_t rc = 0;
-	unsigned char buf[4];
-
-	if (!rdata)
-		return -EIO;
-
-	memset(buf, 0, sizeof(buf));
-
-	buf[0] = (raddr & 0xFF00) >> 8;
-	buf[1] = (raddr & 0x00FF);
-
-	rc = mt9p012_km_i2c_rxdata(saddr, buf, 2);
-	if (rc < 0)
-		return rc;
-
-	*rdata = buf[0] << 8 | buf[1];
-
-	if (rc < 0)
-		CDBG("mt9p012_km_i2c_read failed!\n");
-
-	return rc;
-}
-
-static int32_t mt9p012_km_i2c_txdata(unsigned short saddr,
-				  unsigned char *txdata,
-				  int length)
-{
-	struct i2c_msg msg[] = {
-		{
-		 .addr = saddr << 1,
-		 .flags = 0,
-		 .len = length,
-		 .buf = txdata,
-		 },
-	};
-
-	if (i2c_transfer(mt9p012_km_client->adapter, msg, 1) < 0) {
-		CDBG("mt9p012_km_i2c_txdata failed\n");
-		return -EIO;
-	}
-
-	return 0;
-}
-
-static int32_t mt9p012_km_i2c_write_b(unsigned short saddr,
-				   unsigned short baddr,
-				   unsigned short bdata)
-{
-	int32_t rc = -EIO;
-	unsigned char buf[2];
-
-	memset(buf, 0, sizeof(buf));
-	buf[0] = baddr;
-	buf[1] = bdata;
-	rc = mt9p012_km_i2c_txdata(saddr, buf, 2);
-
-	if (rc < 0)
-		CDBG("i2c_write failed, saddr = 0x%x addr = 0x%x, val =0x%x!\n",
-		     saddr, baddr, bdata);
-
-	return rc;
-}
-
-static int32_t mt9p012_km_i2c_write_w(unsigned short saddr,
-				   unsigned short waddr,
-				   unsigned short wdata)
-{
-	int32_t rc = -EIO;
-	unsigned char buf[4];
-
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00) >> 8;
-	buf[1] = (waddr & 0x00FF);
-	buf[2] = (wdata & 0xFF00) >> 8;
-	buf[3] = (wdata & 0x00FF);
-
-	rc = mt9p012_km_i2c_txdata(saddr, buf, 4);
-
-	if (rc < 0)
-		CDBG("i2c_write_w failed, addr = 0x%x, val = 0x%x!\n",
-		     waddr, wdata);
-
-	return rc;
-}
-
-static int32_t mt9p012_km_i2c_write_w_table(struct mt9p012_km_i2c_reg_conf const
-					 *reg_conf_tbl, int num)
-{
-	int i;
-	int32_t rc = -EIO;
-
-	for (i = 0; i < num; i++) {
-		rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr,
-					 reg_conf_tbl->waddr,
-					 reg_conf_tbl->wdata);
-		if (rc < 0)
-			break;
-		reg_conf_tbl++;
-	}
-
-	return rc;
-}
-
-static int32_t mt9p012_km_test(enum mt9p012_km_test_mode mo)
-{
-	int32_t rc = 0;
-
-	rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr,
-				 REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_HOLD);
-	if (rc < 0)
-		return rc;
-
-	if (mo == TEST_OFF)
-		return 0;
-	else {
-		rc = mt9p012_km_i2c_write_w_table(mt9p012_km_regs.ttbl,
-					 mt9p012_km_regs.ttbl_size);
-		if (rc < 0)
-			return rc;
-
-		rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr,
-					 REG_TEST_PATTERN_MODE, (uint16_t) mo);
-		if (rc < 0)
-			return rc;
-	}
-
-	rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr,
-				 REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_UPDATE);
-	if (rc < 0)
-		return rc;
-
-	return rc;
-}
-
-static int32_t mt9p012_km_lens_shading_enable(uint8_t is_enable)
-{
-	int32_t rc = 0;
-
-	CDBG("%s: entered. enable = %d\n", __func__, is_enable);
-
-	rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr,
-				 REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_HOLD);
-	if (rc < 0)
-		return rc;
-
-	rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr, 0x3780,
-				 ((uint16_t) is_enable) << 15);
-	if (rc < 0)
-		return rc;
-
-	rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr,
-				 REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_UPDATE);
-
-	CDBG("%s: exiting. rc = %d\n", __func__, rc);
-	return rc;
-}
-
-static int32_t mt9p012_km_set_lc(void)
-{
-	int32_t rc;
-
-	rc = mt9p012_km_i2c_write_w_table(mt9p012_km_regs.lctbl,
-				       mt9p012_km_regs.lctbl_size);
-
-	return rc;
-}
-
-static void mt9p012_km_get_pict_fps(uint16_t fps, uint16_t *pfps)
-{
-
-	/* input fps is preview fps in Q8 format */
-	uint32_t divider;   /*Q10 */
-	uint32_t pclk_mult; /*Q10 */
-	uint32_t d1;
-	uint32_t d2;
-
-	d1 =
-		(uint32_t)(
-		(mt9p012_km_regs.reg_pat[RES_PREVIEW].frame_length_lines *
-		0x00000400) /
-		mt9p012_km_regs.reg_pat[RES_CAPTURE].frame_length_lines);
-
-	d2 =
-		(uint32_t)(
-		(mt9p012_km_regs.reg_pat[RES_PREVIEW].line_length_pck *
-		0x00000400) /
-		mt9p012_km_regs.reg_pat[RES_CAPTURE].line_length_pck);
-
-	divider = (uint32_t) (d1 * d2) / 0x00000400;
-
-	pclk_mult =
-		(uint32_t) ((mt9p012_km_regs.reg_pat[RES_CAPTURE].
-		pll_multiplier * 0x00000400) /
-		(mt9p012_km_regs.reg_pat[RES_PREVIEW].pll_multiplier));
-
-
-	/* Verify PCLK settings and frame sizes. */
-	*pfps = (uint16_t)((((fps * pclk_mult) / 0x00000400) * divider)/
-				0x00000400);
-}
-
-static uint16_t mt9p012_km_get_prev_lines_pf(void)
-{
-	if (mt9p012_km_ctrl->prev_res == QTR_SIZE)
-		return  mt9p012_km_regs.reg_pat[RES_PREVIEW].frame_length_lines;
-	else
-		return  mt9p012_km_regs.reg_pat[RES_CAPTURE].frame_length_lines;
-}
-
-static uint16_t mt9p012_km_get_prev_pixels_pl(void)
-{
-	if (mt9p012_km_ctrl->prev_res == QTR_SIZE)
-		return  mt9p012_km_regs.reg_pat[RES_PREVIEW].line_length_pck;
-	else
-		return  mt9p012_km_regs.reg_pat[RES_CAPTURE].line_length_pck;
-}
-
-static uint16_t mt9p012_km_get_pict_lines_pf(void)
-{
-	return  mt9p012_km_regs.reg_pat[RES_CAPTURE].frame_length_lines;
-}
-
-static uint16_t mt9p012_km_get_pict_pixels_pl(void)
-{
-	return  mt9p012_km_regs.reg_pat[RES_CAPTURE].line_length_pck;
-}
-
-static uint32_t mt9p012_km_get_pict_max_exp_lc(void)
-{
-	uint16_t snapshot_lines_per_frame;
-
-	if (mt9p012_km_ctrl->pict_res == QTR_SIZE)
-		snapshot_lines_per_frame =
-	    mt9p012_km_regs.reg_pat[RES_PREVIEW].frame_length_lines - 1;
-	else
-		snapshot_lines_per_frame =
-	    mt9p012_km_regs.reg_pat[RES_CAPTURE].frame_length_lines - 1;
-
-	return snapshot_lines_per_frame * 24;
-}
-
-static int32_t mt9p012_km_set_fps(struct fps_cfg *fps)
-{
-	int32_t rc = 0;
-
-	mt9p012_km_ctrl->fps_divider = fps->fps_div;
-	mt9p012_km_ctrl->pict_fps_divider = fps->pict_fps_div;
-
-	rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr,
-				 REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_HOLD);
-	if (rc < 0)
-		return -EBUSY;
-
-	rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr,
-			REG_FRAME_LENGTH_LINES,
-			mt9p012_km_regs.reg_pat[mt9p012_km_ctrl->sensormode].
-			frame_length_lines *
-			mt9p012_km_ctrl->fps_divider / 0x00000400);
-	if (rc < 0)
-		return rc;
-
-	rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr,
-				 REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_UPDATE);
-
-	return rc;
-}
-
-
-static int32_t mt9p012_km_write_exp_gain(uint16_t gain, uint32_t line)
-{
-	uint16_t max_legal_gain = 0x01FF;
-	uint32_t line_length_ratio = 0x00000400;
-	enum mt9p012_km_setting setting;
-	int32_t rc = 0;
-
-	CDBG("Line:%d mt9p012_km_write_exp_gain \n", __LINE__);
-
-	if (mt9p012_km_ctrl->sensormode == SENSOR_PREVIEW_MODE) {
-		mt9p012_km_ctrl->my_reg_gain = gain;
-		mt9p012_km_ctrl->my_reg_line_count = (uint16_t) line;
-	}
-
-	if (gain > max_legal_gain) {
-		CDBG("Max legal gain Line:%d \n", __LINE__);
-		gain = max_legal_gain;
-	}
-
-	/* Verify no overflow */
-	if (mt9p012_km_ctrl->sensormode == SENSOR_PREVIEW_MODE) {
-		line = (uint32_t) (line * mt9p012_km_ctrl->fps_divider /
-				   0x00000400);
-		setting = RES_PREVIEW;
-	} else {
-		line = (uint32_t) (line * mt9p012_km_ctrl->pict_fps_divider /
-				   0x00000400);
-		setting = RES_CAPTURE;
-	}
-
-	gain |= 0x0200;
-
-	if ((mt9p012_km_regs.reg_pat[setting].frame_length_lines - 1) < line) {
-		line_length_ratio = (uint32_t) (line * 0x00000400) /
-		    (mt9p012_km_regs.reg_pat[setting].frame_length_lines - 1);
-	} else
-		line_length_ratio = 0x00000400;
-
-	rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr,
-				REG_GROUPED_PARAMETER_HOLD,
-				GROUPED_PARAMETER_HOLD);
-	if (rc < 0) {
-		CDBG("mt9p012_km_i2c_write_w failed... Line:%d \n", __LINE__);
-		return rc;
-	}
-
-	rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr,
-				 REG_GLOBAL_GAIN, gain);
-	if (rc < 0) {
-		CDBG("mt9p012_km_i2c_write_w failed... Line:%d \n", __LINE__);
-		return rc;
-	}
-
-	rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr,
-				REG_LINE_LENGTH_PCK,
-			       (uint16_t) (mt9p012_km_regs.reg_pat[setting].
-			    line_length_pck * line_length_ratio / 0x00000400));
-	if (rc < 0)
-		return rc;
-
-	rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr,
-				 REG_COARSE_INT_TIME,
-				 (uint16_t) ((line * 0x00000400)/
-				 line_length_ratio));
-	if (rc < 0) {
-		CDBG("mt9p012_km_i2c_write_w failed... Line:%d \n", __LINE__);
-		return rc;
-	}
-
-	rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr,
-				 REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_UPDATE);
-	if (rc < 0) {
-		CDBG("mt9p012_km_i2c_write_w failed... Line:%d \n", __LINE__);
-		return rc;
-	}
-
-	CDBG("mt9p012_km_write_exp_gain: gain = %d, line = %d\n", gain, line);
-
-	return rc;
-}
-
-static int32_t mt9p012_km_set_pict_exp_gain(uint16_t gain, uint32_t line)
-{
-	int32_t rc = 0;
-
-	CDBG("Line:%d mt9p012_km_set_pict_exp_gain \n", __LINE__);
-
-	rc = mt9p012_km_write_exp_gain(gain, line);
-	if (rc < 0) {
-		CDBG("Line:%d mt9p012_km_set_pict_exp_gain failed... \n",
-		     __LINE__);
-		return rc;
-	}
-
-	rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr,
-				 MT9P012_KM_REG_RESET_REGISTER,
-				 0x10CC | 0x0002);
-	if (rc < 0) {
-		CDBG("mt9p012_km_i2c_write_w failed... Line:%d \n", __LINE__);
-		return rc;
-	}
-
-	mdelay(5);
-
-	/* camera_timed_wait(snapshot_wait*exposure_ratio); */
-	return rc;
-}
-
-static int32_t mt9p012_km_setting(enum mt9p012_km_reg_update rupdate,
-				enum mt9p012_km_setting rt)
-{
-	int32_t rc = 0;
-
-	switch (rupdate) {
-	case UPDATE_PERIODIC:
-		if (rt == RES_PREVIEW || rt == RES_CAPTURE) {
-
-			struct mt9p012_km_i2c_reg_conf ppc_tbl[] = {
-				{REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_HOLD},
-				{REG_ROW_SPEED,
-				 mt9p012_km_regs.reg_pat[rt].row_speed},
-				{REG_X_ADDR_START,
-				 mt9p012_km_regs.reg_pat[rt].x_addr_start},
-				{REG_X_ADDR_END,
-				 mt9p012_km_regs.reg_pat[rt].x_addr_end},
-				{REG_Y_ADDR_START,
-				 mt9p012_km_regs.reg_pat[rt].y_addr_start},
-				{REG_Y_ADDR_END,
-				 mt9p012_km_regs.reg_pat[rt].y_addr_end},
-				{REG_READ_MODE,
-				 mt9p012_km_regs.reg_pat[rt].read_mode},
-				{REG_SCALE_M,
-				 mt9p012_km_regs.reg_pat[rt].scale_m},
-				{REG_X_OUTPUT_SIZE,
-				 mt9p012_km_regs.reg_pat[rt].x_output_size},
-				{REG_Y_OUTPUT_SIZE,
-				 mt9p012_km_regs.reg_pat[rt].y_output_size},
-				{REG_LINE_LENGTH_PCK,
-				 mt9p012_km_regs.reg_pat[rt].line_length_pck},
-				{REG_FRAME_LENGTH_LINES,
-			       (mt9p012_km_regs.reg_pat[rt].frame_length_lines *
-				mt9p012_km_ctrl->fps_divider / 0x00000400)},
-				{REG_COARSE_INT_TIME,
-				 mt9p012_km_regs.reg_pat[rt].coarse_int_time},
-				{REG_FINE_INTEGRATION_TIME,
-				 mt9p012_km_regs.reg_pat[rt].fine_int_time},
-				{REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_UPDATE},
-			};
-
-			if (update_type == REG_INIT) {
-				update_type = rupdate;
-				return rc;
-			}
-
-			rc = mt9p012_km_i2c_write_w_table(&ppc_tbl[0],
-						ARRAY_SIZE(ppc_tbl));
-			if (rc < 0)
-				return rc;
-
-			rc = mt9p012_km_test(mt9p012_km_ctrl->set_test);
-			if (rc < 0)
-				return rc;
-
-			rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr,
-						 MT9P012_KM_REG_RESET_REGISTER,
-						 0x10cc |
-						 0x0002);
-			if (rc < 0)
-				return rc;
-
-			mdelay(15);	/* 15? wait for sensor to transition */
-
-			return rc;
-		}
-		break;	/* UPDATE_PERIODIC */
-
-	case REG_INIT:
-		if (rt == RES_PREVIEW || rt == RES_CAPTURE) {
-			struct mt9p012_km_i2c_reg_conf ipc_tbl1[] = {
-				{MT9P012_KM_REG_RESET_REGISTER,
-				 MT9P012_KM_RESET_REGISTER_PWOFF},
-				{REG_VT_PIX_CLK_DIV,
-				 mt9p012_km_regs.reg_pat[rt].vt_pix_clk_div},
-				{REG_VT_SYS_CLK_DIV,
-				 mt9p012_km_regs.reg_pat[rt].vt_sys_clk_div},
-				{REG_PRE_PLL_CLK_DIV,
-				 mt9p012_km_regs.reg_pat[rt].pre_pll_clk_div},
-				{REG_PLL_MULTIPLIER,
-				 mt9p012_km_regs.reg_pat[rt].pll_multiplier},
-				{REG_OP_PIX_CLK_DIV,
-				 mt9p012_km_regs.reg_pat[rt].op_pix_clk_div},
-				{REG_OP_SYS_CLK_DIV,
-				 mt9p012_km_regs.reg_pat[rt].op_sys_clk_div},
-				{MT9P012_KM_REG_RESET_REGISTER,
-				 MT9P012_KM_RESET_REGISTER_PWON},
-			};
-
-			struct mt9p012_km_i2c_reg_conf ipc_tbl2[] = {
-				{REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_HOLD},
-				/* Optimized register settings for
-				   Rev3 Silicon */
-				{0x308A, 0x6424},
-				{0x3092, 0x0A52},
-				{0x3094, 0x4656},
-				{0x3096, 0x5652},
-				{0x0204, 0x0010},
-				{0x0206, 0x0010},
-				{0x0208, 0x0010},
-				{0x020A, 0x0010},
-				{0x020C, 0x0010},
-				{0x3088, 0x6FF6},
-				{0x3154, 0x0282},
-				{0x3156, 0x0381},
-				{0x3162, 0x04CE},
-			};
-
-			struct mt9p012_km_i2c_reg_conf ipc_tbl3[] = {
-				/* Set preview or snapshot mode */
-				{REG_ROW_SPEED,
-				 mt9p012_km_regs.reg_pat[rt].row_speed},
-				{REG_X_ADDR_START,
-				 mt9p012_km_regs.reg_pat[rt].x_addr_start},
-				{REG_X_ADDR_END,
-				 mt9p012_km_regs.reg_pat[rt].x_addr_end},
-				{REG_Y_ADDR_START,
-				 mt9p012_km_regs.reg_pat[rt].y_addr_start},
-				{REG_Y_ADDR_END,
-				 mt9p012_km_regs.reg_pat[rt].y_addr_end},
-				{REG_READ_MODE,
-				 mt9p012_km_regs.reg_pat[rt].read_mode},
-				{REG_SCALE_M,
-				 mt9p012_km_regs.reg_pat[rt].scale_m},
-				{REG_X_OUTPUT_SIZE,
-				 mt9p012_km_regs.reg_pat[rt].x_output_size},
-				{REG_Y_OUTPUT_SIZE,
-				 mt9p012_km_regs.reg_pat[rt].y_output_size},
-				{REG_LINE_LENGTH_PCK,
-				 mt9p012_km_regs.reg_pat[rt].line_length_pck},
-				{REG_FRAME_LENGTH_LINES,
-				 mt9p012_km_regs.reg_pat[rt].
-				 frame_length_lines},
-				{REG_COARSE_INT_TIME,
-				 mt9p012_km_regs.reg_pat[rt].coarse_int_time},
-				{REG_FINE_INTEGRATION_TIME,
-				 mt9p012_km_regs.reg_pat[rt].fine_int_time},
-				{REG_GROUPED_PARAMETER_HOLD,
-				 GROUPED_PARAMETER_UPDATE},
-			};
-
-			/* reset fps_divider */
-			mt9p012_km_ctrl->fps_divider = 1 * 0x0400;
-
-			rc = mt9p012_km_i2c_write_w_table(&ipc_tbl1[0],
-							ARRAY_SIZE(ipc_tbl1));
-			if (rc < 0)
-				return rc;
-
-			mdelay(15);
-
-			rc = mt9p012_km_i2c_write_w_table(&ipc_tbl2[0],
-							ARRAY_SIZE(ipc_tbl2));
-			if (rc < 0)
-				return rc;
-
-			mdelay(5);
-
-			rc = mt9p012_km_i2c_write_w_table(&ipc_tbl3[0],
-						       ARRAY_SIZE(ipc_tbl3));
-			if (rc < 0)
-				return rc;
-
-			/* load lens shading */
-			rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr,
-						 REG_GROUPED_PARAMETER_HOLD,
-						 GROUPED_PARAMETER_HOLD);
-			if (rc < 0)
-				return rc;
-
-			rc = mt9p012_km_set_lc();
-			if (rc < 0)
-				return rc;
-
-			rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr,
-						 REG_GROUPED_PARAMETER_HOLD,
-						 GROUPED_PARAMETER_UPDATE);
-
-			if (rc < 0)
-				return rc;
-		}
-		update_type = rupdate;
-		break;		/* case REG_INIT: */
-
-	default:
-		rc = -EINVAL;
-		break;
-	}			/* switch (rupdate) */
-
-	return rc;
-}
-
-static int32_t mt9p012_km_video_config(int mode, int res)
-{
-	int32_t rc;
-
-	switch (res) {
-	case QTR_SIZE:
-		rc = mt9p012_km_setting(UPDATE_PERIODIC, RES_PREVIEW);
-		if (rc < 0)
-			return rc;
-
-		CDBG("mt9p012_km sensor configuration done!\n");
-		break;
-
-	case FULL_SIZE:
-		rc = mt9p012_km_setting(UPDATE_PERIODIC, RES_CAPTURE);
-		if (rc < 0)
-			return rc;
-
-		break;
-
-	default:
-		return 0;
-	}			/* switch */
-
-	mt9p012_km_ctrl->prev_res = res;
-	mt9p012_km_ctrl->curr_res = res;
-	mt9p012_km_ctrl->sensormode = mode;
-
-	rc = mt9p012_km_write_exp_gain(mt9p012_km_ctrl->my_reg_gain,
-				    mt9p012_km_ctrl->my_reg_line_count);
-
-	rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr,
-				 MT9P012_KM_REG_RESET_REGISTER,
-				 0x10cc | 0x0002);
-
-	mdelay(15);
-	return rc;
-}
-
-static int32_t mt9p012_km_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-
-	rc = mt9p012_km_setting(UPDATE_PERIODIC, RES_CAPTURE);
-	if (rc < 0)
-		return rc;
-
-	mt9p012_km_ctrl->curr_res = mt9p012_km_ctrl->pict_res;
-
-	mt9p012_km_ctrl->sensormode = mode;
-
-	return rc;
-}
-
-static int32_t mt9p012_km_raw_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-
-	rc = mt9p012_km_setting(UPDATE_PERIODIC, RES_CAPTURE);
-	if (rc < 0)
-		return rc;
-
-	mt9p012_km_ctrl->curr_res = mt9p012_km_ctrl->pict_res;
-
-	mt9p012_km_ctrl->sensormode = mode;
-
-	return rc;
-}
-
-static int32_t mt9p012_km_power_down(void)
-{
-	int32_t rc = 0;
-
-	rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr,
-				 MT9P012_KM_REG_RESET_REGISTER,
-				 MT9P012_KM_RESET_REGISTER_PWOFF);
-
-	mdelay(5);
-	return rc;
-}
-
-static int32_t mt9p012_km_move_focus(int direction, int32_t num_steps)
-{
-	int16_t step_direction;
-	int16_t actual_step;
-	int16_t next_position;
-	uint8_t code_val_msb, code_val_lsb;
-
-	if (num_steps > MT9P012_KM_TOTAL_STEPS_NEAR_TO_FAR)
-		num_steps = MT9P012_KM_TOTAL_STEPS_NEAR_TO_FAR;
-	else if (num_steps == 0) {
-		CDBG("mt9p012_km_move_focus failed at line %d ...\n", __LINE__);
-		return -EINVAL;
-	}
-
-	if (direction == MOVE_NEAR)
-		step_direction = 16;	/* 10bit */
-	else if (direction == MOVE_FAR)
-		step_direction = -16;	/* 10 bit */
-	else {
-		CDBG("mt9p012_km_move_focus failed at line %d ...\n", __LINE__);
-		return -EINVAL;
-	}
-
-	if (mt9p012_km_ctrl->curr_lens_pos <
-				mt9p012_km_ctrl->init_curr_lens_pos)
-		mt9p012_km_ctrl->curr_lens_pos =
-				mt9p012_km_ctrl->init_curr_lens_pos;
-
-	actual_step = (int16_t) (step_direction * (int16_t) num_steps);
-	next_position = (int16_t) (mt9p012_km_ctrl->curr_lens_pos +
-							actual_step);
-
-	if (next_position > 1023)
-		next_position = 1023;
-	else if (next_position < 0)
-		next_position = 0;
-
-	code_val_msb = next_position >> 4;
-	code_val_lsb = (next_position & 0x000F) << 4;
-	code_val_lsb |= mode_mask;
-
-	/* Writing the digital code for current to the actuator */
-	if (mt9p012_km_i2c_write_b(MT9P012_KM_AF_I2C_ADDR >> 1,
-				code_val_msb, code_val_lsb) < 0) {
-		CDBG("mt9p012_km_move_focus failed at line %d ...\n", __LINE__);
-		return -EBUSY;
-	}
-
-	/* Storing the current lens Position */
-	mt9p012_km_ctrl->curr_lens_pos = next_position;
-
-	return 0;
-}
-
-static int32_t mt9p012_km_set_default_focus(void)
-{
-	int32_t rc = 0;
-	uint8_t code_val_msb, code_val_lsb;
-
-	code_val_msb = 0x00;
-	code_val_lsb = 0x04;
-
-	/* Write the digital code for current to the actuator */
-	rc = mt9p012_km_i2c_write_b(MT9P012_KM_AF_I2C_ADDR >> 1,
-				 code_val_msb, code_val_lsb);
-
-	mt9p012_km_ctrl->curr_lens_pos = 0;
-	mt9p012_km_ctrl->init_curr_lens_pos = 0;
-
-	return rc;
-}
-
-static int mt9p012_km_probe_init_done(const struct msm_camera_sensor_info *data)
-{
-	gpio_direction_output(data->sensor_reset, 0);
-	gpio_free(data->sensor_reset);
-	return 0;
-}
-
-static int
-	mt9p012_km_probe_init_sensor(const struct msm_camera_sensor_info *data)
-{
-	int32_t rc;
-	uint16_t chipid;
-
-	rc = gpio_request(data->sensor_reset, "mt9p012_km");
-	if (!rc)
-		gpio_direction_output(data->sensor_reset, 1);
-	else
-		goto init_probe_done;
-
-	msleep(20);
-
-	/* RESET the sensor image part via I2C command */
-	CDBG("mt9p012_km_sensor_init(): reseting sensor.\n");
-	rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr,
-				 MT9P012_KM_REG_RESET_REGISTER,
-				 0x10CC | 0x0001);
-	if (rc < 0) {
-		CDBG("sensor reset failed. rc = %d\n", rc);
-		goto init_probe_fail;
-	}
-
-		msleep(MT9P012_KM_RESET_DELAY_MSECS);
-
-	/* 3. Read sensor Model ID: */
-	rc = mt9p012_km_i2c_read_w(mt9p012_km_client->addr,
-				MT9P012_KM_REG_MODEL_ID, &chipid);
-	if (rc < 0)
-		goto init_probe_fail;
-
-	/* 4. Compare sensor ID to MT9T012VC ID: */
-	if (chipid != MT9P012_KM_MODEL_ID) {
-		CDBG("mt9p012_km wrong model_id = 0x%x\n", chipid);
-		rc = -ENODEV;
-		goto init_probe_fail;
-	}
-
-	rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr, 0x306E, 0x9080);
-	if (rc < 0) {
-		CDBG("REV_7 write failed. rc = %d\n", rc);
-		goto init_probe_fail;
-	}
-
-	/* RESET_REGISTER, enable parallel interface and disable serialiser */
-	CDBG("mt9p012_km_sensor_init(): enabling parallel interface.\n");
-	rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr, 0x301A, 0x10CC);
-	if (rc < 0) {
-		CDBG("enable parallel interface failed. rc = %d\n", rc);
-		goto init_probe_fail;
-	}
-
-	/* To disable the 2 extra lines */
-	rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr, 0x3064, 0x0805);
-
-	if (rc < 0) {
-		CDBG("disable the 2 extra lines failed. rc = %d\n", rc);
-		goto init_probe_fail;
-	}
-
-	goto init_probe_done;
-
-init_probe_fail:
-	mt9p012_km_probe_init_done(data);
-init_probe_done:
-	return rc;
-}
-
-static int
-	mt9p012_km_sensor_open_init(const struct msm_camera_sensor_info *data)
-{
-	int32_t rc;
-
-	mt9p012_km_ctrl = kzalloc(sizeof(struct mt9p012_km_ctrl), GFP_KERNEL);
-	if (!mt9p012_km_ctrl) {
-		CDBG("mt9p012_km_init failed!\n");
-		rc = -ENOMEM;
-		goto init_done;
-	}
-
-	mt9p012_km_ctrl->fps_divider = 1 * 0x00000400;
-	mt9p012_km_ctrl->pict_fps_divider = 1 * 0x00000400;
-	mt9p012_km_ctrl->set_test = TEST_OFF;
-	mt9p012_km_ctrl->prev_res = QTR_SIZE;
-	mt9p012_km_ctrl->pict_res = FULL_SIZE;
-
-	if (data)
-		mt9p012_km_ctrl->sensordata = data;
-
-	msm_camio_camif_pad_reg_reset();
-	mdelay(20);
-
-	rc = mt9p012_km_probe_init_sensor(data);
-	if (rc < 0)
-		goto init_fail1;
-
-	if (mt9p012_km_ctrl->prev_res == QTR_SIZE)
-		rc = mt9p012_km_setting(REG_INIT, RES_PREVIEW);
-	else
-		rc = mt9p012_km_setting(REG_INIT, RES_CAPTURE);
-
-	if (rc < 0) {
-		CDBG("mt9p012_km_setting failed. rc = %d\n", rc);
-		goto init_fail1;
-	}
-
-	/* sensor : output enable */
-	CDBG("mt9p012_km_sensor_open_init(): enabling output.\n");
-	rc = mt9p012_km_i2c_write_w(mt9p012_km_client->addr,
-				 MT9P012_KM_REG_RESET_REGISTER,
-				 MT9P012_KM_RESET_REGISTER_PWON);
-	if (rc < 0) {
-		CDBG("sensor output enable failed. rc = %d\n", rc);
-		goto init_fail1;
-	}
-
-	if (rc >= 0)
-		goto init_done;
-
-init_fail1:
-	mt9p012_km_probe_init_done(data);
-	kfree(mt9p012_km_ctrl);
-init_done:
-	return rc;
-}
-
-static int mt9p012_km_init_client(struct i2c_client *client)
-{
-	/* Initialize the MSM_CAMI2C Chip */
-	init_waitqueue_head(&mt9p012_km_wait_queue);
-	return 0;
-}
-
-static int32_t mt9p012_km_set_sensor_mode(int mode, int res)
-{
-	int32_t rc = 0;
-
-	switch (mode) {
-	case SENSOR_PREVIEW_MODE:
-		rc = mt9p012_km_video_config(mode, res);
-		break;
-
-	case SENSOR_SNAPSHOT_MODE:
-		rc = mt9p012_km_snapshot_config(mode);
-		break;
-
-	case SENSOR_RAW_SNAPSHOT_MODE:
-		rc = mt9p012_km_raw_snapshot_config(mode);
-		break;
-
-	default:
-		rc = -EINVAL;
-		break;
-	}
-
-	return rc;
-}
-
-int mt9p012_km_sensor_config(void __user *argp)
-{
-	struct sensor_cfg_data cdata;
-	int rc = 0;
-
-	if (copy_from_user(&cdata,
-			   (void *)argp, sizeof(struct sensor_cfg_data)))
-		return -EFAULT;
-
-	mutex_lock(&mt9p012_km_mut);
-
-	CDBG("%s: cfgtype = %d\n", __func__, cdata.cfgtype);
-	switch (cdata.cfgtype) {
-	case CFG_GET_PICT_FPS:
-		mt9p012_km_get_pict_fps(cdata.cfg.gfps.prevfps,
-				     &(cdata.cfg.gfps.pictfps));
-
-		if (copy_to_user((void *)argp, &cdata,
-				 sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PREV_L_PF:
-		cdata.cfg.prevl_pf = mt9p012_km_get_prev_lines_pf();
-
-		if (copy_to_user((void *)argp,
-				 &cdata, sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PREV_P_PL:
-		cdata.cfg.prevp_pl = mt9p012_km_get_prev_pixels_pl();
-
-		if (copy_to_user((void *)argp,
-				 &cdata, sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PICT_L_PF:
-		cdata.cfg.pictl_pf = mt9p012_km_get_pict_lines_pf();
-
-		if (copy_to_user((void *)argp,
-				 &cdata, sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PICT_P_PL:
-		cdata.cfg.pictp_pl = mt9p012_km_get_pict_pixels_pl();
-
-		if (copy_to_user((void *)argp,
-				 &cdata, sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PICT_MAX_EXP_LC:
-		cdata.cfg.pict_max_exp_lc = mt9p012_km_get_pict_max_exp_lc();
-
-		if (copy_to_user((void *)argp,
-				 &cdata, sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_SET_FPS:
-	case CFG_SET_PICT_FPS:
-		rc = mt9p012_km_set_fps(&(cdata.cfg.fps));
-		break;
-
-	case CFG_SET_EXP_GAIN:
-		rc = mt9p012_km_write_exp_gain(cdata.cfg.exp_gain.gain,
-					    cdata.cfg.exp_gain.line);
-		break;
-
-	case CFG_SET_PICT_EXP_GAIN:
-		CDBG("Line:%d CFG_SET_PICT_EXP_GAIN \n", __LINE__);
-		rc = mt9p012_km_set_pict_exp_gain(cdata.cfg.exp_gain.gain,
-					       cdata.cfg.exp_gain.line);
-		break;
-
-	case CFG_SET_MODE:
-		rc = mt9p012_km_set_sensor_mode(cdata.mode, cdata.rs);
-		break;
-
-	case CFG_PWR_DOWN:
-		rc = mt9p012_km_power_down();
-		break;
-
-	case CFG_MOVE_FOCUS:
-		CDBG("mt9p012_km_ioctl: CFG_MOVE_FOCUS: cdata.cfg.focus.dir=%d \
-				cdata.cfg.focus.steps=%d\n",
-				cdata.cfg.focus.dir, cdata.cfg.focus.steps);
-		rc = mt9p012_km_move_focus(cdata.cfg.focus.dir,
-					cdata.cfg.focus.steps);
-		break;
-
-	case CFG_SET_DEFAULT_FOCUS:
-		rc = mt9p012_km_set_default_focus();
-		break;
-
-	case CFG_SET_LENS_SHADING:
-		CDBG("%s: CFG_SET_LENS_SHADING\n", __func__);
-		rc = mt9p012_km_lens_shading_enable(cdata.cfg.lens_shading);
-		break;
-
-	case CFG_GET_AF_MAX_STEPS:
-		cdata.max_steps = MT9P012_KM_STEPS_NEAR_TO_CLOSEST_INF;
-		if (copy_to_user((void *)argp,
-				 &cdata, sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_SET_EFFECT:
-	default:
-		rc = -EINVAL;
-		break;
-	}
-
-	mutex_unlock(&mt9p012_km_mut);
-	return rc;
-}
-
-int mt9p012_km_sensor_release(void)
-{
-	int rc = -EBADF;
-
-	mutex_lock(&mt9p012_km_mut);
-
-	mt9p012_km_power_down();
-
-	gpio_direction_output(mt9p012_km_ctrl->sensordata->sensor_reset, 0);
-	gpio_free(mt9p012_km_ctrl->sensordata->sensor_reset);
-
-	gpio_direction_output(mt9p012_km_ctrl->sensordata->vcm_pwd, 0);
-	gpio_free(mt9p012_km_ctrl->sensordata->vcm_pwd);
-
-	kfree(mt9p012_km_ctrl);
-	mt9p012_km_ctrl = NULL;
-
-	CDBG("mt9p012_km_release completed\n");
-
-	mutex_unlock(&mt9p012_km_mut);
-	return rc;
-}
-
-static int mt9p012_km_i2c_probe(struct i2c_client *client,
-			     const struct i2c_device_id *id)
-{
-	int rc = 0;
-	CDBG("mt9p012_km_probe called!\n");
-
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		CDBG("i2c_check_functionality failed\n");
-		goto probe_failure;
-	}
-
-	mt9p012_km_sensorw = kzalloc(sizeof(struct mt9p012_km_work),
-							GFP_KERNEL);
-	if (!mt9p012_km_sensorw) {
-		CDBG("kzalloc failed.\n");
-		rc = -ENOMEM;
-		goto probe_failure;
-	}
-
-	i2c_set_clientdata(client, mt9p012_km_sensorw);
-	mt9p012_km_init_client(client);
-	mt9p012_km_client = client;
-
-	mdelay(50);
-
-	CDBG("mt9p012_km_probe successed! rc = %d\n", rc);
-	return 0;
-
-probe_failure:
-	CDBG("mt9p012_km_probe failed! rc = %d\n", rc);
-	return rc;
-}
-
-static const struct i2c_device_id mt9p012_km_i2c_id[] = {
-	{"mt9p012_km", 0},
-	{}
-};
-
-static struct i2c_driver mt9p012_km_i2c_driver = {
-	.id_table = mt9p012_km_i2c_id,
-	.probe = mt9p012_km_i2c_probe,
-	.remove = __exit_p(mt9p012_km_i2c_remove),
-	.driver = {
-		   .name = "mt9p012_km",
-		   },
-};
-
-static int mt9p012_km_sensor_probe(const struct msm_camera_sensor_info *info,
-				struct msm_sensor_ctrl *s)
-{
-	int rc = i2c_add_driver(&mt9p012_km_i2c_driver);
-	if (rc < 0 || mt9p012_km_client == NULL) {
-		rc = -ENOTSUPP;
-		goto probe_done;
-	}
-
-	msm_camio_clk_rate_set(MT9P012_KM_DEFAULT_CLOCK_RATE);
-	mdelay(20);
-
-	rc = mt9p012_km_probe_init_sensor(info);
-	if (rc < 0)
-		goto probe_done;
-
-	s->s_init = mt9p012_km_sensor_open_init;
-	s->s_release = mt9p012_km_sensor_release;
-	s->s_config = mt9p012_km_sensor_config;
-	s->s_mount_angle  = 0;
-	mt9p012_km_probe_init_done(info);
-
-probe_done:
-	CDBG("%s %s:%d\n", __FILE__, __func__, __LINE__);
-	return rc;
-}
-
-static int __mt9p012_km_probe(struct platform_device *pdev)
-{
-	return msm_camera_drv_start(pdev, mt9p012_km_sensor_probe);
-}
-
-static struct platform_driver msm_camera_driver = {
-	.probe = __mt9p012_km_probe,
-	.driver = {
-		   .name = "msm_camera_mt9p012_km",
-		   .owner = THIS_MODULE,
-		   },
-};
-
-static int __init mt9p012_km_init(void)
-{
-	return platform_driver_register(&msm_camera_driver);
-}
-
-module_init(mt9p012_km_init);
diff --git a/drivers/media/platform/msm/camera_v1/mt9p012_km.h b/drivers/media/platform/msm/camera_v1/mt9p012_km.h
deleted file mode 100644
index d386474..0000000
--- a/drivers/media/platform/msm/camera_v1/mt9p012_km.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Copyright (c) 2009-2012, The Linux Foundation. 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.
- *
- */
-
-#ifndef MT9P012_KM_H
-#define MT9P012_KM_H
-
-#include <linux/types.h>
-#include <mach/board.h>
-
-extern struct mt9p012_km_reg mt9p012_km_regs;	/* from mt9p012_km_reg.c */
-
-struct reg_struct {
-	uint16_t vt_pix_clk_div;     /* 0x0300 */
-	uint16_t vt_sys_clk_div;     /* 0x0302 */
-	uint16_t pre_pll_clk_div;    /* 0x0304 */
-	uint16_t pll_multiplier;     /* 0x0306 */
-	uint16_t op_pix_clk_div;     /* 0x0308 */
-	uint16_t op_sys_clk_div;     /* 0x030A */
-	uint16_t scale_m;            /* 0x0404 */
-	uint16_t row_speed;          /* 0x3016 */
-	uint16_t x_addr_start;       /* 0x3004 */
-	uint16_t x_addr_end;         /* 0x3008 */
-	uint16_t y_addr_start;       /* 0x3002 */
-	uint16_t y_addr_end;         /* 0x3006 */
-	uint16_t read_mode;          /* 0x3040 */
-	uint16_t x_output_size ;     /* 0x034C */
-	uint16_t y_output_size;      /* 0x034E */
-	uint16_t line_length_pck;    /* 0x300C */
-	uint16_t frame_length_lines; /* 0x300A */
-	uint16_t coarse_int_time;    /* 0x3012 */
-	uint16_t fine_int_time;      /* 0x3014 */
-};
-
-
-struct mt9p012_km_i2c_reg_conf {
-	unsigned short waddr;
-	unsigned short wdata;
-};
-
-
-struct mt9p012_km_reg {
-	struct reg_struct const *reg_pat;
-	uint16_t reg_pat_size;
-	struct mt9p012_km_i2c_reg_conf const *ttbl;
-	uint16_t ttbl_size;
-	struct mt9p012_km_i2c_reg_conf const *lctbl;
-	uint16_t lctbl_size;
-	struct mt9p012_km_i2c_reg_conf const *rftbl;
-	uint16_t rftbl_size;
-};
-
-#endif /* MT9P012_KM_H */
diff --git a/drivers/media/platform/msm/camera_v1/mt9p012_km_reg.c b/drivers/media/platform/msm/camera_v1/mt9p012_km_reg.c
deleted file mode 100644
index 5c6318f..0000000
--- a/drivers/media/platform/msm/camera_v1/mt9p012_km_reg.c
+++ /dev/null
@@ -1,375 +0,0 @@
-/* Copyright (c) 2009-2010, The Linux Foundation. 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.
- *
- */
-
-#include "mt9p012_km.h"
-#include <linux/kernel.h>
-
-/*Micron settings from Applications for lower power consumption.*/
-struct reg_struct const mt9p012_km_reg_pat[2] = {
-	{ /* Preview */
-		/* vt_pix_clk_div          REG=0x0300 */
-		6,  /* 5 */
-
-		/* vt_sys_clk_div          REG=0x0302 */
-		1,
-
-		/* pre_pll_clk_div         REG=0x0304 */
-		2,
-
-		/* pll_multiplier          REG=0x0306 */
-		60,
-
-		/* op_pix_clk_div          REG=0x0308 */
-		8,  /* 10 */
-
-		/* op_sys_clk_div          REG=0x030A */
-		1,
-
-		/* scale_m                 REG=0x0404 */
-		16,
-
-		/* row_speed               REG=0x3016 */
-		0x0111,
-
-		/* x_addr_start            REG=0x3004 */
-		8,
-
-		/* x_addr_end              REG=0x3008 */
-		2597,
-
-		/* y_addr_start            REG=0x3002 */
-		8,
-
-		/* y_addr_end              REG=0x3006 */
-		1949,
-
-		/* read_mode               REG=0x3040
-		 * Preview 2x2 skipping */
-		0x006C,
-
-		/* x_output_size           REG=0x034C */
-		1296,
-
-		/* y_output_size           REG=0x034E */
-		972,
-
-		/* line_length_pck         REG=0x300C */
-		3783,
-
-		/* frame_length_lines      REG=0x300A */
-		1074,
-
-		/* coarse_integration_time REG=0x3012 */
-		16,
-
-		/* fine_integration_time   REG=0x3014 */
-		1764
-	},
-	{ /* Snapshot */
-		/* vt_pix_clk_div          REG=0x0300 */
-		6,
-
-		/* vt_sys_clk_div          REG=0x0302 */
-		1,
-
-		/* pre_pll_clk_div         REG=0x0304 */
-		2,
-
-		/* pll_multiplier          REG=0x0306
-		 * 39 for 10fps snapshot */
-		39,
-
-		/* op_pix_clk_div          REG=0x0308 */
-		8,
-
-		/* op_sys_clk_div          REG=0x030A */
-		1,
-
-		/* scale_m                 REG=0x0404 */
-		16,
-
-		/* row_speed               REG=0x3016 */
-		0x0111,
-
-		/* x_addr_start            REG=0x3004 */
-		8,
-
-		/* x_addr_end              REG=0x3008 */
-		2615,
-
-		/* y_addr_start            REG=0x3002 */
-		8,
-
-		/* y_addr_end              REG=0x3006 */
-		1967,
-
-		/* read_mode               REG=0x3040 */
-		0x0024,
-
-		/* x_output_size           REG=0x034C */
-		2608,
-
-		/* y_output_size           REG=0x034E */
-		1960,
-
-		/* line_length_pck         REG=0x300C */
-		3788,
-
-		/* frame_length_lines      REG=0x300A 10 fps snapshot */
-		2045,
-
-		/* coarse_integration_time REG=0x3012 */
-		16,
-
-		/* fine_integration_time   REG=0x3014 */
-		882
-	}
-};
-
-struct mt9p012_km_i2c_reg_conf const mt9p012_km_test_tbl[] = {
-	{0x3044, 0x0544 & 0xFBFF},
-	{0x30CA, 0x0004 | 0x0001},
-	{0x30D4, 0x9020 & 0x7FFF},
-	{0x31E0, 0x0003 & 0xFFFE},
-	{0x3180, 0x91FF & 0x7FFF},
-	{0x301A, (0x10CC | 0x8000) & 0xFFF7},
-	{0x301E, 0x0000},
-	{0x3780, 0x0000},
-};
-
-
-struct mt9p012_km_i2c_reg_conf const mt9p012_km_lc_tbl[] = {
-	{0x360A, 0x00F0},
-	{0x360C, 0x0B29},
-	{0x360E, 0x5ED1},
-	{0x3610, 0x890D},
-	{0x3612, 0x9871},
-	{0x364A, 0xAD2C},
-	{0x364C, 0x0A8C},
-	{0x364E, 0x91EC},
-	{0x3650, 0x94EC},
-	{0x3652, 0xC76B},
-	{0x368A, 0x5931},
-	{0x368C, 0x4FED},
-	{0x368E, 0x8A50},
-	{0x3690, 0x5C0F},
-	{0x3692, 0x8393},
-	{0x36CA, 0xDB8E},
-	{0x36CC, 0xCA4D},
-	{0x36CE, 0x146F},
-	{0x36D0, 0x618F},
-	{0x36D2, 0x014F},
-	{0x370A, 0x1FEE},
-	{0x370C, 0xDD50},
-	{0x370E, 0xDB54},
-	{0x3710, 0xCA92},
-	{0x3712, 0x1896},
-	{0x3600, 0x00F0},
-	{0x3602, 0xA04C},
-	{0x3604, 0x5711},
-	{0x3606, 0x5E6D},
-	{0x3608, 0xA971},
-	{0x3640, 0xDCCC},
-	{0x3642, 0x0529},
-	{0x3644, 0x96ED},
-	{0x3646, 0xF447},
-	{0x3648, 0x4AEE},
-	{0x3680, 0x2171},
-	{0x3682, 0x634F},
-	{0x3684, 0xCC91},
-	{0x3686, 0xA9CE},
-	{0x3688, 0x8751},
-	{0x36C0, 0x8B6D},
-	{0x36C2, 0xE20E},
-	{0x36C4, 0x750F},
-	{0x36C6, 0x0090},
-	{0x36C8, 0x9E91},
-	{0x3700, 0xEAAF},
-	{0x3702, 0xB8AF},
-	{0x3704, 0xE293},
-	{0x3706, 0xAB33},
-	{0x3708, 0x4595},
-	{0x3614, 0x00D0},
-	{0x3616, 0x8AAB},
-	{0x3618, 0x18B1},
-	{0x361A, 0x54AD},
-	{0x361C, 0x9DB0},
-	{0x3654, 0x11EB},
-	{0x3656, 0x332C},
-	{0x3658, 0x316D},
-	{0x365A, 0xF0EB},
-	{0x365C, 0xB4ED},
-	{0x3694, 0x0F31},
-	{0x3696, 0x08D0},
-	{0x3698, 0xA52F},
-	{0x369A, 0xE64F},
-	{0x369C, 0xC9D2},
-	{0x36D4, 0x8C2D},
-	{0x36D6, 0xAD6E},
-	{0x36D8, 0xE1CE},
-	{0x36DA, 0x1750},
-	{0x36DC, 0x8CAD},
-	{0x3714, 0x8CAF},
-	{0x3716, 0x8C11},
-	{0x3718, 0xE453},
-	{0x371A, 0x9693},
-	{0x371C, 0x38B5},
-	{0x361E, 0x00D0},
-	{0x3620, 0xB6CB},
-	{0x3622, 0x4811},
-	{0x3624, 0xB70C},
-	{0x3626, 0xA771},
-	{0x365E, 0xB5A9},
-	{0x3660, 0x05AA},
-	{0x3662, 0x00CF},
-	{0x3664, 0xB86B},
-	{0x3666, 0xA4AF},
-	{0x369E, 0x3E31},
-	{0x36A0, 0x902B},
-	{0x36A2, 0xD251},
-	{0x36A4, 0x5C2F},
-	{0x36A6, 0x8471},
-	{0x36DE, 0x2C6D},
-	{0x36E0, 0xECEE},
-	{0x36E2, 0xB650},
-	{0x36E4, 0x0210},
-	{0x36E6, 0xACAE},
-	{0x371E, 0xAC30},
-	{0x3720, 0x394E},
-	{0x3722, 0xFDD3},
-	{0x3724, 0xBCB2},
-	{0x3726, 0x5AD5},
-	{0x3782, 0x0508},
-	{0x3784, 0x03B4},
-	{0x3780, 0x8000},
-};
-
-struct mt9p012_km_i2c_reg_conf const mt9p012_km_rolloff_tbl[] = {
-	{0x360A, 0x00F0},
-	{0x360C, 0x0B29},
-	{0x360E, 0x5ED1},
-	{0x3610, 0x890D},
-	{0x3612, 0x9871},
-	{0x364A, 0xAD2C},
-	{0x364C, 0x0A8C},
-	{0x364E, 0x91EC},
-	{0x3650, 0x94EC},
-	{0x3652, 0xC76B},
-	{0x368A, 0x5931},
-	{0x368C, 0x4FED},
-	{0x368E, 0x8A50},
-	{0x3690, 0x5C0F},
-	{0x3692, 0x8393},
-	{0x36CA, 0xDB8E},
-	{0x36CC, 0xCA4D},
-	{0x36CE, 0x146F},
-	{0x36D0, 0x618F},
-	{0x36D2, 0x014F},
-	{0x370A, 0x1FEE},
-	{0x370C, 0xDD50},
-	{0x370E, 0xDB54},
-	{0x3710, 0xCA92},
-	{0x3712, 0x1896},
-	{0x3600, 0x00F0},
-	{0x3602, 0xA04C},
-	{0x3604, 0x5711},
-	{0x3606, 0x5E6D},
-	{0x3608, 0xA971},
-	{0x3640, 0xDCCC},
-	{0x3642, 0x0529},
-	{0x3644, 0x96ED},
-	{0x3646, 0xF447},
-	{0x3648, 0x4AEE},
-	{0x3680, 0x2171},
-	{0x3682, 0x634F},
-	{0x3684, 0xCC91},
-	{0x3686, 0xA9CE},
-	{0x3688, 0x8751},
-	{0x36C0, 0x8B6D},
-	{0x36C2, 0xE20E},
-	{0x36C4, 0x750F},
-	{0x36C6, 0x0090},
-	{0x36C8, 0x9E91},
-	{0x3700, 0xEAAF},
-	{0x3702, 0xB8AF},
-	{0x3704, 0xE293},
-	{0x3706, 0xAB33},
-	{0x3708, 0x4595},
-	{0x3614, 0x00D0},
-	{0x3616, 0x8AAB},
-	{0x3618, 0x18B1},
-	{0x361A, 0x54AD},
-	{0x361C, 0x9DB0},
-	{0x3654, 0x11EB},
-	{0x3656, 0x332C},
-	{0x3658, 0x316D},
-	{0x365A, 0xF0EB},
-	{0x365C, 0xB4ED},
-	{0x3694, 0x0F31},
-	{0x3696, 0x08D0},
-	{0x3698, 0xA52F},
-	{0x369A, 0xE64F},
-	{0x369C, 0xC9D2},
-	{0x36D4, 0x8C2D},
-	{0x36D6, 0xAD6E},
-	{0x36D8, 0xE1CE},
-	{0x36DA, 0x1750},
-	{0x36DC, 0x8CAD},
-	{0x3714, 0x8CAF},
-	{0x3716, 0x8C11},
-	{0x3718, 0xE453},
-	{0x371A, 0x9693},
-	{0x371C, 0x38B5},
-	{0x361E, 0x00D0},
-	{0x3620, 0xB6CB},
-	{0x3622, 0x4811},
-	{0x3624, 0xB70C},
-	{0x3626, 0xA771},
-	{0x365E, 0xB5A9},
-	{0x3660, 0x05AA},
-	{0x3662, 0x00CF},
-	{0x3664, 0xB86B},
-	{0x3666, 0xA4AF},
-	{0x369E, 0x3E31},
-	{0x36A0, 0x902B},
-	{0x36A2, 0xD251},
-	{0x36A4, 0x5C2F},
-	{0x36A6, 0x8471},
-	{0x36DE, 0x2C6D},
-	{0x36E0, 0xECEE},
-	{0x36E2, 0xB650},
-	{0x36E4, 0x0210},
-	{0x36E6, 0xACAE},
-	{0x371E, 0xAC30},
-	{0x3720, 0x394E},
-	{0x3722, 0xFDD3},
-	{0x3724, 0xBCB2},
-	{0x3726, 0x5AD5},
-	{0x3782, 0x0508},
-	{0x3784, 0x03B4},
-	{0x3780, 0x8000},
-};
-
-
-struct mt9p012_km_reg mt9p012_km_regs = {
-	.reg_pat = &mt9p012_km_reg_pat[0],
-	.reg_pat_size = ARRAY_SIZE(mt9p012_km_reg_pat),
-	.ttbl = &mt9p012_km_test_tbl[0],
-	.ttbl_size = ARRAY_SIZE(mt9p012_km_test_tbl),
-	.lctbl = &mt9p012_km_lc_tbl[0],
-	.lctbl_size = ARRAY_SIZE(mt9p012_km_lc_tbl),
-	.rftbl = &mt9p012_km_rolloff_tbl[0],
-	.rftbl_size = ARRAY_SIZE(mt9p012_km_rolloff_tbl)
-};
-
-
diff --git a/drivers/media/platform/msm/camera_v1/mt9p012_reg.c b/drivers/media/platform/msm/camera_v1/mt9p012_reg.c
deleted file mode 100644
index b828852..0000000
--- a/drivers/media/platform/msm/camera_v1/mt9p012_reg.c
+++ /dev/null
@@ -1,263 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-
-#include "mt9p012.h"
-#include <linux/kernel.h>
-
-/*Micron settings from Applications for lower power consumption.*/
-struct reg_struct const mt9p012_reg_pat[2] = {
-	{ /* Preview */
-		/* vt_pix_clk_div          REG=0x0300 */
-		6,  /* 5 */
-
-		/* vt_sys_clk_div          REG=0x0302 */
-		1,
-		/* pre_pll_clk_div         REG=0x0304 */
-		2,
-		/* pll_multiplier          REG=0x0306 */
-		60,
-
-		/* op_pix_clk_div          REG=0x0308 */
-		8,  /* 10 */
-
-		/* op_sys_clk_div          REG=0x030A */
-		1,
-
-		/* scale_m                 REG=0x0404 */
-		16,
-
-		/* row_speed               REG=0x3016 */
-		0x0111,
-
-		/* x_addr_start            REG=0x3004 */
-		8,
-
-		/* x_addr_end              REG=0x3008 */
-		2597,
-
-		/* y_addr_start            REG=0x3002 */
-		8,
-
-		/* y_addr_end              REG=0x3006 */
-		1949,
-
-		/* read_mode               REG=0x3040
-		 * Preview 2x2 skipping */
-		0x00C3,
-
-		/* x_output_size           REG=0x034C */
-		1296,
-
-		/* y_output_size           REG=0x034E */
-		972,
-
-		/* line_length_pck         REG=0x300C */
-		3659,
-
-		/* frame_length_lines      REG=0x300A */
-		1074,
-
-		/* coarse_integration_time REG=0x3012 */
-		16,
-
-		/* fine_integration_time   REG=0x3014 */
-		1764
-	},
-	{ /* Snapshot */
-		/* vt_pix_clk_div          REG=0x0300 */
-		6,
-
-		/* vt_sys_clk_div          REG=0x0302 */
-		1,
-
-		/* pre_pll_clk_div         REG=0x0304 */
-		2,
-
-		/* pll_multiplier          REG=0x0306
-		 * 60 for 10fps snapshot */
-		60,
-
-		/* op_pix_clk_div          REG=0x0308 */
-		8,
-
-		/* op_sys_clk_div          REG=0x030A */
-		1,
-
-		/* scale_m                 REG=0x0404 */
-		16,
-
-		/* row_speed               REG=0x3016 */
-		0x0111,
-
-		/* x_addr_start            REG=0x3004 */
-		8,
-
-		/* x_addr_end              REG=0x3008 */
-		2615,
-
-		/* y_addr_start            REG=0x3002 */
-		8,
-
-		/* y_addr_end              REG=0x3006 */
-		1967,
-
-		/* read_mode               REG=0x3040 */
-		0x0041,
-
-		/* x_output_size           REG=0x034C */
-		2608,
-
-		/* y_output_size           REG=0x034E */
-		1960,
-
-		/* line_length_pck         REG=0x300C */
-		3911,
-
-		/* frame_length_lines      REG=0x300A 10 fps snapshot */
-		2045,
-
-		/* coarse_integration_time REG=0x3012 */
-		16,
-
-		/* fine_integration_time   REG=0x3014 */
-		882
-	}
-};
-
-
-struct mt9p012_i2c_reg_conf const mt9p012_test_tbl[] = {
-	{0x3044, 0x0544 & 0xFBFF},
-	{0x30CA, 0x0004 | 0x0001},
-	{0x30D4, 0x9020 & 0x7FFF},
-	{0x31E0, 0x0003 & 0xFFFE},
-	{0x3180, 0x91FF & 0x7FFF},
-	{0x301A, (0x10CC | 0x8000) & 0xFFF7},
-	{0x301E, 0x0000},
-	{0x3780, 0x0000},
-};
-struct mt9p012_i2c_reg_conf const mt9p012_rolloff_tbl[] = {
-	{0x360A, 0x0110},
-	{0x360C, 0x270D},
-	{0x360E, 0x0071},
-	{0x3610, 0xA38D},
-	{0x3612, 0xA610},
-	{0x364A, 0x8F49},
-	{0x364C, 0x696A},
-	{0x364E, 0x0FCD},
-	{0x3650, 0x20ED},
-	{0x3652, 0x81ED},
-	{0x368A, 0x1031},
-	{0x368C, 0xBCAD},
-	{0x368E, 0x77AA},
-	{0x3690, 0xD10E},
-	{0x3692, 0xC133},
-	{0x36CA, 0x4F8D},
-	{0x36CC, 0xAC4D},
-	{0x36CE, 0xC8CE},
-	{0x36D0, 0x73AD},
-	{0x36D2, 0xC150},
-	{0x370A, 0xB590},
-	{0x370C, 0x9010},
-	{0x370E, 0xAC52},
-	{0x3710, 0x4D51},
-	{0x3712, 0x5670},
-	{0x3600, 0x00F0},
-	{0x3602, 0xCE4B},
-	{0x3604, 0x4270},
-	{0x3606, 0x8BC9},
-	{0x3608, 0xFA2F},
-	{0x3640, 0x9A09},
-	{0x3642, 0xB40C},
-	{0x3644, 0x4ECD},
-	{0x3646, 0x1BCC},
-	{0x3648, 0xD68E},
-	{0x3680, 0x1BF0},
-	{0x3682, 0xC94D},
-	{0x3684, 0x714F},
-	{0x3686, 0x1491},
-	{0x3688, 0xB8D3},
-	{0x36C0, 0x3E49},
-	{0x36C2, 0x7A6C},
-	{0x36C4, 0xEF2E},
-	{0x36C6, 0xE0EE},
-	{0x36C8, 0x570F},
-	{0x3700, 0xD6AF},
-	{0x3702, 0x2251},
-	{0x3704, 0x8A33},
-	{0x3706, 0xEFB3},
-	{0x3708, 0x1174},
-	{0x3614, 0x0150},
-	{0x3616, 0xA9AB},
-	{0x3618, 0x1770},
-	{0x361A, 0x8809},
-	{0x361C, 0xE3AE},
-	{0x3654, 0x5ACC},
-	{0x3656, 0x35EA},
-	{0x3658, 0x2DEC},
-	{0x365A, 0xB90B},
-	{0x365C, 0x250C},
-	{0x3694, 0x1630},
-	{0x3696, 0xD88C},
-	{0x3698, 0xBD0E},
-	{0x369A, 0x16D1},
-	{0x369C, 0xE492},
-	{0x36D4, 0x5D6D},
-	{0x36D6, 0x906E},
-	{0x36D8, 0x10AE},
-	{0x36DA, 0x7A8E},
-	{0x36DC, 0x9672},
-	{0x3714, 0x8D90},
-	{0x3716, 0x04F1},
-	{0x3718, 0x23F1},
-	{0x371A, 0xF313},
-	{0x371C, 0xE833},
-	{0x361E, 0x0490},
-	{0x3620, 0x14CD},
-	{0x3622, 0x38F0},
-	{0x3624, 0xBAED},
-	{0x3626, 0xFF6F},
-	{0x365E, 0x358C},
-	{0x3660, 0xA9E9},
-	{0x3662, 0x4A4E},
-	{0x3664, 0x398D},
-	{0x3666, 0x890F},
-	{0x369E, 0x2DF0},
-	{0x36A0, 0xF7CE},
-	{0x36A2, 0xB3CC},
-	{0x36A4, 0x118D},
-	{0x36A6, 0x9CB3},
-	{0x36DE, 0x462D},
-	{0x36E0, 0x74AA},
-	{0x36E2, 0xC8CF},
-	{0x36E4, 0x8DEF},
-	{0x36E6, 0xF130},
-	{0x371E, 0x9250},
-	{0x3720, 0x19CC},
-	{0x3722, 0xDFD1},
-	{0x3724, 0x5B70},
-	{0x3726, 0x34D2},
-	{0x3782, 0x0530},
-	{0x3784, 0x03C8},
-	{0x3780, 0x8000},
-};
-
-struct mt9p012_reg mt9p012_regs = {
-	.reg_pat = &mt9p012_reg_pat[0],
-	.reg_pat_size = ARRAY_SIZE(mt9p012_reg_pat),
-	.ttbl = &mt9p012_test_tbl[0],
-	.ttbl_size = ARRAY_SIZE(mt9p012_test_tbl),
-	.rftbl = &mt9p012_rolloff_tbl[0],
-	.rftbl_size = ARRAY_SIZE(mt9p012_rolloff_tbl)
-};
-
-
diff --git a/drivers/media/platform/msm/camera_v1/mt9t013.c b/drivers/media/platform/msm/camera_v1/mt9t013.c
deleted file mode 100644
index e107930..0000000
--- a/drivers/media/platform/msm/camera_v1/mt9t013.c
+++ /dev/null
@@ -1,1504 +0,0 @@
-/* Copyright (c) 2009-2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include <linux/types.h>
-#include <linux/i2c.h>
-#include <linux/uaccess.h>
-#include <linux/miscdevice.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <media/msm_camera.h>
-#include <mach/gpio.h>
-#include <mach/camera.h>
-#include <asm/mach-types.h>
-#include "mt9t013.h"
-
-/*=============================================================
-	SENSOR REGISTER DEFINES
-==============================================================*/
-#define MT9T013_REG_MODEL_ID 		 0x0000
-#define MT9T013_MODEL_ID     		 0x2600
-#define REG_GROUPED_PARAMETER_HOLD   0x0104
-#define GROUPED_PARAMETER_HOLD       0x0100
-#define GROUPED_PARAMETER_UPDATE     0x0000
-#define REG_COARSE_INT_TIME          0x3012
-#define REG_VT_PIX_CLK_DIV           0x0300
-#define REG_VT_SYS_CLK_DIV           0x0302
-#define REG_PRE_PLL_CLK_DIV          0x0304
-#define REG_PLL_MULTIPLIER           0x0306
-#define REG_OP_PIX_CLK_DIV           0x0308
-#define REG_OP_SYS_CLK_DIV           0x030A
-#define REG_SCALE_M                  0x0404
-#define REG_FRAME_LENGTH_LINES       0x300A
-#define REG_LINE_LENGTH_PCK          0x300C
-#define REG_X_ADDR_START             0x3004
-#define REG_Y_ADDR_START             0x3002
-#define REG_X_ADDR_END               0x3008
-#define REG_Y_ADDR_END               0x3006
-#define REG_X_OUTPUT_SIZE            0x034C
-#define REG_Y_OUTPUT_SIZE            0x034E
-#define REG_FINE_INT_TIME            0x3014
-#define REG_ROW_SPEED                0x3016
-#define MT9T013_REG_RESET_REGISTER   0x301A
-#define MT9T013_RESET_REGISTER_PWON  0x10CC
-#define MT9T013_RESET_REGISTER_PWOFF 0x1008 /* 0x10C8 stop streaming*/
-#define MT9T013_RESET_FAST_TRANSITION 0x0002
-#define REG_READ_MODE                0x3040
-#define REG_GLOBAL_GAIN              0x305E
-#define REG_TEST_PATTERN_MODE        0x3070
-
-
-enum mt9t013_test_mode {
-	TEST_OFF,
-	TEST_1,
-	TEST_2,
-	TEST_3
-};
-
-enum mt9t013_resolution {
-	QTR_SIZE,
-	FULL_SIZE,
-	INVALID_SIZE
-};
-
-enum mt9t013_reg_update {
-	REG_INIT, /* registers that need to be updated during initialization */
-	UPDATE_PERIODIC, /* registers that needs periodic I2C writes */
-	UPDATE_ALL, /* all registers will be updated */
-	UPDATE_INVALID
-};
-
-enum mt9t013_setting {
-	RES_PREVIEW,
-	RES_CAPTURE
-};
-
-/* actuator's Slave Address */
-#define MT9T013_AF_I2C_ADDR   0x18
-
-/*
-* AF Total steps parameters
-*/
-#define MT9T013_TOTAL_STEPS_NEAR_TO_FAR    30
-
-/*
- * Time in milisecs for waiting for the sensor to reset.
- */
-#define MT9T013_RESET_DELAY_MSECS   66
-
-/* for 30 fps preview */
-#define MT9T013_DEFAULT_CLOCK_RATE  24000000
-#define MT9T013_DEFAULT_MAX_FPS     26
-
-
-/* FIXME: Changes from here */
-struct mt9t013_work {
-	struct work_struct work;
-};
-
-static struct  mt9t013_work *mt9t013_sensorw;
-static struct  i2c_client *mt9t013_client;
-
-struct mt9t013_ctrl {
-	const struct msm_camera_sensor_info *sensordata;
-
-	int sensormode;
-	uint32_t fps_divider; 		/* init to 1 * 0x00000400 */
-	uint32_t pict_fps_divider; 	/* init to 1 * 0x00000400 */
-
-	uint16_t curr_lens_pos;
-	uint16_t init_curr_lens_pos;
-	uint16_t my_reg_gain;
-	uint32_t my_reg_line_count;
-
-	enum mt9t013_resolution prev_res;
-	enum mt9t013_resolution pict_res;
-	enum mt9t013_resolution curr_res;
-	enum mt9t013_test_mode  set_test;
-
-	unsigned short imgaddr;
-};
-
-
-static struct mt9t013_ctrl *mt9t013_ctrl;
-static DECLARE_WAIT_QUEUE_HEAD(mt9t013_wait_queue);
-DEFINE_SEMAPHORE(mt9t013_sem);
-
-static int mt9t013_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(mt9t013_client->adapter, msgs, 2) < 0) {
-		pr_err("mt9t013_i2c_rxdata failed!\n");
-		return -EIO;
-	}
-
-	return 0;
-}
-
-static int32_t mt9t013_i2c_read_w(unsigned short saddr,
-	unsigned short raddr, unsigned short *rdata)
-{
-	int32_t rc = 0;
-	unsigned char buf[4];
-
-	if (!rdata)
-		return -EIO;
-
-	memset(buf, 0, sizeof(buf));
-
-	buf[0] = (raddr & 0xFF00)>>8;
-	buf[1] = (raddr & 0x00FF);
-
-	rc = mt9t013_i2c_rxdata(saddr, buf, 2);
-	if (rc < 0)
-		return rc;
-
-	*rdata = buf[0] << 8 | buf[1];
-
-	if (rc < 0)
-		pr_err("mt9t013_i2c_read failed!\n");
-
-	return rc;
-}
-
-static int32_t mt9t013_i2c_txdata(unsigned short saddr,
-	unsigned char *txdata, int length)
-{
-	struct i2c_msg msg[] = {
-	{
-		.addr = saddr,
-		.flags = 0,
-		.len = length,
-		.buf = txdata,
-	},
-	};
-
-	if (i2c_transfer(mt9t013_client->adapter, msg, 1) < 0) {
-		pr_err("mt9t013_i2c_txdata failed\n");
-		return -EIO;
-	}
-
-	return 0;
-}
-
-static int32_t mt9t013_i2c_write_b(unsigned short saddr,
-	unsigned short waddr, unsigned short wdata)
-{
-	int32_t rc = -EIO;
-	unsigned char buf[2];
-
-	memset(buf, 0, sizeof(buf));
-	buf[0] = waddr;
-	buf[1] = wdata;
-	rc = mt9t013_i2c_txdata(saddr, buf, 2);
-
-	if (rc < 0)
-		pr_err("i2c_write failed, addr = 0x%x, val = 0x%x!\n",
-		waddr, wdata);
-
-	return rc;
-}
-
-static int32_t mt9t013_i2c_write_w(unsigned short saddr,
-	unsigned short waddr, unsigned short wdata)
-{
-	int32_t rc = -EIO;
-	unsigned char buf[4];
-
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00)>>8;
-	buf[1] = (waddr & 0x00FF);
-	buf[2] = (wdata & 0xFF00)>>8;
-	buf[3] = (wdata & 0x00FF);
-
-	rc = mt9t013_i2c_txdata(saddr, buf, 4);
-
-	if (rc < 0)
-		pr_err("i2c_write_w failed, addr = 0x%x, val = 0x%x!\n",
-		waddr, wdata);
-
-	return rc;
-}
-
-static int32_t mt9t013_i2c_write_w_table(
-	struct mt9t013_i2c_reg_conf const *reg_conf_tbl,
-	int num_of_items_in_table)
-{
-	int i;
-	int32_t rc = -EIO;
-
-	for (i = 0; i < num_of_items_in_table; i++) {
-		rc = mt9t013_i2c_write_w(mt9t013_client->addr,
-			reg_conf_tbl->waddr, reg_conf_tbl->wdata);
-		if (rc < 0)
-			break;
-		reg_conf_tbl++;
-	}
-
-	return rc;
-}
-
-static int32_t mt9t013_test(enum mt9t013_test_mode mo)
-{
-	int32_t rc = 0;
-
-	rc = mt9t013_i2c_write_w(mt9t013_client->addr,
-			REG_GROUPED_PARAMETER_HOLD,
-			GROUPED_PARAMETER_HOLD);
-	if (rc < 0)
-		return rc;
-
-	if (mo == TEST_OFF)
-		return 0;
-	else {
-		rc = mt9t013_i2c_write_w_table(mt9t013_regs.ttbl,
-				mt9t013_regs.ttbl_size);
-		if (rc < 0)
-			return rc;
-		rc = mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_TEST_PATTERN_MODE, (uint16_t)mo);
-		if (rc < 0)
-			return rc;
-	}
-
-	rc = mt9t013_i2c_write_w(mt9t013_client->addr,
-			REG_GROUPED_PARAMETER_HOLD,
-			GROUPED_PARAMETER_UPDATE);
-	if (rc < 0)
-		return rc;
-
-	return rc;
-}
-
-static int32_t mt9t013_set_lc(void)
-{
-	int32_t rc;
-
-	rc = mt9t013_i2c_write_w_table(mt9t013_regs.lctbl,
-		mt9t013_regs.lctbl_size);
-	if (rc < 0)
-		return rc;
-
-	return rc;
-}
-
-static int32_t mt9t013_set_default_focus(uint8_t af_step)
-{
-	int32_t rc = 0;
-	uint8_t code_val_msb, code_val_lsb;
-	code_val_msb = 0x01;
-	code_val_lsb = af_step;
-
-	/* Write the digital code for current to the actuator */
-	rc = mt9t013_i2c_write_b(MT9T013_AF_I2C_ADDR>>1,
-			code_val_msb, code_val_lsb);
-
-	mt9t013_ctrl->curr_lens_pos = 0;
-	mt9t013_ctrl->init_curr_lens_pos = 0;
-	return rc;
-}
-
-static void mt9t013_get_pict_fps(uint16_t fps, uint16_t *pfps)
-{
-	/* input fps is preview fps in Q8 format */
-	uint32_t divider;   /*Q10 */
-	uint32_t pclk_mult; /*Q10 */
-	uint32_t d1;
-	uint32_t d2;
-
-	d1 =
-		(uint32_t)(
-		(mt9t013_regs.reg_pat[RES_PREVIEW].frame_length_lines *
-		0x00000400) /
-		mt9t013_regs.reg_pat[RES_CAPTURE].frame_length_lines);
-
-	d2 =
-		(uint32_t)(
-		(mt9t013_regs.reg_pat[RES_PREVIEW].line_length_pck *
-		0x00000400) /
-		mt9t013_regs.reg_pat[RES_CAPTURE].line_length_pck);
-
-	divider = (uint32_t) (d1 * d2) / 0x00000400;
-
-	pclk_mult =
-		(uint32_t) ((mt9t013_regs.reg_pat[RES_CAPTURE].pll_multiplier *
-		0x00000400) /
-		(mt9t013_regs.reg_pat[RES_PREVIEW].pll_multiplier));
-
-
-	/* Verify PCLK settings and frame sizes. */
-	*pfps =
-		(uint16_t) (fps * divider * pclk_mult /
-		0x00000400 / 0x00000400);
-}
-
-static uint16_t mt9t013_get_prev_lines_pf(void)
-{
-	if (mt9t013_ctrl->prev_res == QTR_SIZE)
-		return mt9t013_regs.reg_pat[RES_PREVIEW].frame_length_lines;
-	else
-		return mt9t013_regs.reg_pat[RES_CAPTURE].frame_length_lines;
-}
-
-static uint16_t mt9t013_get_prev_pixels_pl(void)
-{
-	if (mt9t013_ctrl->prev_res == QTR_SIZE)
-		return mt9t013_regs.reg_pat[RES_PREVIEW].line_length_pck;
-	else
-		return mt9t013_regs.reg_pat[RES_CAPTURE].line_length_pck;
-}
-
-static uint16_t mt9t013_get_pict_lines_pf(void)
-{
-	return mt9t013_regs.reg_pat[RES_CAPTURE].frame_length_lines;
-}
-
-static uint16_t mt9t013_get_pict_pixels_pl(void)
-{
-	return mt9t013_regs.reg_pat[RES_CAPTURE].line_length_pck;
-}
-
-static uint32_t mt9t013_get_pict_max_exp_lc(void)
-{
-	uint16_t snapshot_lines_per_frame;
-
-	if (mt9t013_ctrl->pict_res == QTR_SIZE) {
-		snapshot_lines_per_frame =
-		mt9t013_regs.reg_pat[RES_PREVIEW].frame_length_lines - 1;
-	} else  {
-		snapshot_lines_per_frame =
-		mt9t013_regs.reg_pat[RES_CAPTURE].frame_length_lines - 1;
-	}
-
-	return snapshot_lines_per_frame * 24;
-}
-
-static int32_t mt9t013_set_fps(struct fps_cfg *fps)
-{
-	/* input is new fps in Q8 format */
-	int32_t rc = 0;
-	enum mt9t013_setting setting;
-
-	mt9t013_ctrl->fps_divider = fps->fps_div;
-	mt9t013_ctrl->pict_fps_divider = fps->pict_fps_div;
-
-	rc = mt9t013_i2c_write_w(mt9t013_client->addr,
-			REG_GROUPED_PARAMETER_HOLD,
-			GROUPED_PARAMETER_HOLD);
-	if (rc < 0)
-		return -EBUSY;
-
-	CDBG("mt9t013_set_fps: fps_div is %d, f_mult is %d\n",
-			fps->fps_div, fps->f_mult);
-
-	if (mt9t013_ctrl->sensormode == SENSOR_PREVIEW_MODE)
-		setting = RES_PREVIEW;
-	else
-		setting = RES_CAPTURE;
-	rc = mt9t013_i2c_write_w(mt9t013_client->addr,
-			REG_FRAME_LENGTH_LINES,
-			(uint16_t) (
-			mt9t013_regs.reg_pat[setting].frame_length_lines *
-			fps->fps_div / 0x00000400));
-
-	if (rc < 0)
-		return rc;
-
-	rc = mt9t013_i2c_write_w(mt9t013_client->addr,
-			REG_GROUPED_PARAMETER_HOLD,
-			GROUPED_PARAMETER_UPDATE);
-	if (rc < 0)
-		return rc;
-
-	return rc;
-}
-
-static int32_t mt9t013_write_exp_gain(uint16_t gain, uint32_t line)
-{
-	uint16_t max_legal_gain = 0x01FF;
-	int32_t rc = 0;
-
-	if (mt9t013_ctrl->sensormode == SENSOR_PREVIEW_MODE) {
-		mt9t013_ctrl->my_reg_gain = gain;
-		mt9t013_ctrl->my_reg_line_count = (uint16_t) line;
-	}
-
-	if (gain > max_legal_gain)
-		gain = max_legal_gain;
-
-	if (mt9t013_ctrl->sensormode != SENSOR_SNAPSHOT_MODE)
-		line = (uint32_t) (line * mt9t013_ctrl->fps_divider /
-				   0x00000400);
-	else
-		line = (uint32_t) (line * mt9t013_ctrl->pict_fps_divider /
-				   0x00000400);
-
-	/*Set digital gain to 1 */
-	gain |= 0x0200;
-
-	/* There used to be PARAMETER_HOLD register write before and
-	 * after REG_GLOBAL_GAIN & REG_COARSE_INIT_TIME. This causes
-	 * aec oscillation. Hence removed. */
-
-	rc = mt9t013_i2c_write_w(mt9t013_client->addr, REG_GLOBAL_GAIN, gain);
-	if (rc < 0)
-		return rc;
-
-	rc = mt9t013_i2c_write_w(mt9t013_client->addr,
-			REG_COARSE_INT_TIME, line);
-	if (rc < 0)
-		return rc;
-
-	return rc;
-}
-
-static int32_t mt9t013_set_pict_exp_gain(uint16_t gain, uint32_t line)
-{
-	int32_t rc = 0;
-
-	rc = mt9t013_write_exp_gain(gain, line);
-	if (rc < 0)
-		return rc;
-
-	rc = mt9t013_i2c_write_w(mt9t013_client->addr,
-			MT9T013_REG_RESET_REGISTER,
-			0x10CC | 0x0002);
-
-	mdelay(5);
-
-	return rc;
-}
-
-static int32_t mt9t013_setting(enum mt9t013_reg_update rupdate,
-	enum mt9t013_setting rt)
-{
-	int32_t rc = 0;
-
-	switch (rupdate) {
-	case UPDATE_PERIODIC: {
-
-	if (rt == RES_PREVIEW || rt == RES_CAPTURE) {
-#if 0
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				MT9T013_REG_RESET_REGISTER,
-				MT9T013_RESET_REGISTER_PWOFF);
-		if (rc < 0)
-			return rc;
-#endif
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_VT_PIX_CLK_DIV,
-				mt9t013_regs.reg_pat[rt].vt_pix_clk_div);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_VT_SYS_CLK_DIV,
-				mt9t013_regs.reg_pat[rt].vt_sys_clk_div);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_PRE_PLL_CLK_DIV,
-				mt9t013_regs.reg_pat[rt].pre_pll_clk_div);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_PLL_MULTIPLIER,
-				mt9t013_regs.reg_pat[rt].pll_multiplier);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_OP_PIX_CLK_DIV,
-				mt9t013_regs.reg_pat[rt].op_pix_clk_div);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_OP_SYS_CLK_DIV,
-				mt9t013_regs.reg_pat[rt].op_sys_clk_div);
-		if (rc < 0)
-			return rc;
-
-		mdelay(5);
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_GROUPED_PARAMETER_HOLD,
-				GROUPED_PARAMETER_HOLD);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_ROW_SPEED,
-				mt9t013_regs.reg_pat[rt].row_speed);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_X_ADDR_START,
-				mt9t013_regs.reg_pat[rt].x_addr_start);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_X_ADDR_END,
-				mt9t013_regs.reg_pat[rt].x_addr_end);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_Y_ADDR_START,
-				mt9t013_regs.reg_pat[rt].y_addr_start);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_Y_ADDR_END,
-				mt9t013_regs.reg_pat[rt].y_addr_end);
-		if (rc < 0)
-			return rc;
-
-		if (machine_is_sapphire()) {
-			if (rt == 0)
-				rc = mt9t013_i2c_write_w(mt9t013_client->addr,
-					REG_READ_MODE,
-					0x046F);
-			else
-				rc = mt9t013_i2c_write_w(mt9t013_client->addr,
-					REG_READ_MODE,
-					0x0027);
-		} else
-			rc = mt9t013_i2c_write_w(mt9t013_client->addr,
-					REG_READ_MODE,
-					mt9t013_regs.reg_pat[rt].read_mode);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_SCALE_M,
-				mt9t013_regs.reg_pat[rt].scale_m);
-		if (rc < 0)
-			return rc;
-
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_X_OUTPUT_SIZE,
-				mt9t013_regs.reg_pat[rt].x_output_size);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_Y_OUTPUT_SIZE,
-				mt9t013_regs.reg_pat[rt].y_output_size);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_LINE_LENGTH_PCK,
-				mt9t013_regs.reg_pat[rt].line_length_pck);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-			REG_FRAME_LENGTH_LINES,
-			(mt9t013_regs.reg_pat[rt].frame_length_lines *
-			mt9t013_ctrl->fps_divider / 0x00000400));
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-			REG_COARSE_INT_TIME,
-			mt9t013_regs.reg_pat[rt].coarse_int_time);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-			REG_FINE_INT_TIME,
-			mt9t013_regs.reg_pat[rt].fine_int_time);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-			REG_GROUPED_PARAMETER_HOLD,
-			GROUPED_PARAMETER_UPDATE);
-		if (rc < 0)
-			return rc;
-
-		rc = mt9t013_test(mt9t013_ctrl->set_test);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-			MT9T013_REG_RESET_REGISTER,
-			MT9T013_RESET_REGISTER_PWON|
-			MT9T013_RESET_FAST_TRANSITION);
-		if (rc < 0)
-			return rc;
-
-		mdelay(5);
-
-		return rc;
-	}
-	}
-		break;
-
-	/*CAMSENSOR_REG_UPDATE_PERIODIC */
-	case REG_INIT: {
-	if (rt == RES_PREVIEW || rt == RES_CAPTURE) {
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				MT9T013_REG_RESET_REGISTER,
-				MT9T013_RESET_REGISTER_PWOFF);
-		if (rc < 0)
-			/* MODE_SELECT, stop streaming */
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_VT_PIX_CLK_DIV,
-				mt9t013_regs.reg_pat[rt].vt_pix_clk_div);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_VT_SYS_CLK_DIV,
-				mt9t013_regs.reg_pat[rt].vt_sys_clk_div);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_PRE_PLL_CLK_DIV,
-				mt9t013_regs.reg_pat[rt].pre_pll_clk_div);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_PLL_MULTIPLIER,
-				mt9t013_regs.reg_pat[rt].pll_multiplier);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_OP_PIX_CLK_DIV,
-				mt9t013_regs.reg_pat[rt].op_pix_clk_div);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_OP_SYS_CLK_DIV,
-				mt9t013_regs.reg_pat[rt].op_sys_clk_div);
-		if (rc < 0)
-			return rc;
-
-		mdelay(5);
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_GROUPED_PARAMETER_HOLD,
-				GROUPED_PARAMETER_HOLD);
-		if (rc < 0)
-			return rc;
-
-		/* additional power saving mode ok around 38.2MHz */
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				0x3084, 0x2409);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				0x3092, 0x0A49);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				0x3094, 0x4949);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				0x3096, 0x4949);
-		if (rc < 0)
-			return rc;
-
-		/* Set preview or snapshot mode */
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_ROW_SPEED,
-				mt9t013_regs.reg_pat[rt].row_speed);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_X_ADDR_START,
-				mt9t013_regs.reg_pat[rt].x_addr_start);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_X_ADDR_END,
-				mt9t013_regs.reg_pat[rt].x_addr_end);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_Y_ADDR_START,
-				mt9t013_regs.reg_pat[rt].y_addr_start);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_Y_ADDR_END,
-				mt9t013_regs.reg_pat[rt].y_addr_end);
-		if (rc < 0)
-			return rc;
-
-		if (machine_is_sapphire()) {
-			if (rt == 0)
-				rc = mt9t013_i2c_write_w(mt9t013_client->addr,
-					REG_READ_MODE,
-					0x046F);
-			else
-				rc = mt9t013_i2c_write_w(mt9t013_client->addr,
-					REG_READ_MODE,
-					0x0027);
-		} else
-			rc = mt9t013_i2c_write_w(mt9t013_client->addr,
-					REG_READ_MODE,
-					mt9t013_regs.reg_pat[rt].read_mode);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_SCALE_M,
-				mt9t013_regs.reg_pat[rt].scale_m);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_X_OUTPUT_SIZE,
-				mt9t013_regs.reg_pat[rt].x_output_size);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_Y_OUTPUT_SIZE,
-				mt9t013_regs.reg_pat[rt].y_output_size);
-		if (rc < 0)
-			return 0;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_LINE_LENGTH_PCK,
-				mt9t013_regs.reg_pat[rt].line_length_pck);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_FRAME_LENGTH_LINES,
-				mt9t013_regs.reg_pat[rt].frame_length_lines);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_COARSE_INT_TIME,
-				mt9t013_regs.reg_pat[rt].coarse_int_time);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_FINE_INT_TIME,
-				mt9t013_regs.reg_pat[rt].fine_int_time);
-		if (rc < 0)
-			return rc;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_GROUPED_PARAMETER_HOLD,
-				GROUPED_PARAMETER_UPDATE);
-			if (rc < 0)
-				return rc;
-
-		/* load lens shading */
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_GROUPED_PARAMETER_HOLD,
-				GROUPED_PARAMETER_HOLD);
-		if (rc < 0)
-			return rc;
-
-		/* most likely needs to be written only once. */
-		rc = mt9t013_set_lc();
-		if (rc < 0)
-			return -EBUSY;
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_GROUPED_PARAMETER_HOLD,
-				GROUPED_PARAMETER_UPDATE);
-		if (rc < 0)
-			return rc;
-
-		rc = mt9t013_test(mt9t013_ctrl->set_test);
-		if (rc < 0)
-			return rc;
-
-		mdelay(5);
-
-		rc =
-			mt9t013_i2c_write_w(mt9t013_client->addr,
-				MT9T013_REG_RESET_REGISTER,
-				MT9T013_RESET_REGISTER_PWON);
-		if (rc < 0)
-			/* MODE_SELECT, stop streaming */
-			return rc;
-
-		CDBG("!!! mt9t013 !!! PowerOn is done!\n");
-		mdelay(5);
-		return rc;
-		}
-	} /* case CAMSENSOR_REG_INIT: */
-	break;
-
-	/*CAMSENSOR_REG_INIT */
-	default:
-		rc = -EINVAL;
-		break;
-	} /* switch (rupdate) */
-
-	return rc;
-}
-
-static int32_t mt9t013_video_config(int mode, int res)
-{
-	int32_t rc;
-
-	switch (res) {
-	case QTR_SIZE:
-		rc = mt9t013_setting(UPDATE_PERIODIC, RES_PREVIEW);
-		if (rc < 0)
-			return rc;
-		CDBG("sensor configuration done!\n");
-		break;
-
-	case FULL_SIZE:
-		rc = mt9t013_setting(UPDATE_PERIODIC, RES_CAPTURE);
-		if (rc < 0)
-			return rc;
-		break;
-
-	default:
-		return -EINVAL;
-	} /* switch */
-
-	mt9t013_ctrl->prev_res = res;
-	mt9t013_ctrl->curr_res = res;
-	mt9t013_ctrl->sensormode = mode;
-
-	rc = mt9t013_write_exp_gain(mt9t013_ctrl->my_reg_gain,
-			mt9t013_ctrl->my_reg_line_count);
-	if (rc < 0)
-		return rc;
-
-	rc = mt9t013_i2c_write_w(mt9t013_client->addr,
-		MT9T013_REG_RESET_REGISTER,
-		MT9T013_RESET_REGISTER_PWON|MT9T013_RESET_FAST_TRANSITION);
-	if (rc < 0)
-		return rc;
-
-	msleep(5);
-	return rc;
-}
-
-static int32_t mt9t013_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-
-	rc = mt9t013_setting(UPDATE_PERIODIC, RES_CAPTURE);
-	if (rc < 0)
-		return rc;
-
-	mt9t013_ctrl->curr_res = mt9t013_ctrl->pict_res;
-	mt9t013_ctrl->sensormode = mode;
-	return rc;
-}
-
-static int32_t mt9t013_raw_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-
-	rc = mt9t013_setting(UPDATE_PERIODIC, RES_CAPTURE);
-	if (rc < 0)
-		return rc;
-
-	mt9t013_ctrl->curr_res = mt9t013_ctrl->pict_res;
-	mt9t013_ctrl->sensormode = mode;
-	return rc;
-}
-
-static int32_t mt9t013_power_down(void)
-{
-	int32_t rc = 0;
-
-	rc = mt9t013_i2c_write_w(mt9t013_client->addr,
-			MT9T013_REG_RESET_REGISTER,
-			MT9T013_RESET_REGISTER_PWOFF);
-	if (rc >= 0)
-		mdelay(5);
-	return rc;
-}
-
-static int32_t mt9t013_move_focus(int direction, int32_t num_steps)
-{
-	int16_t step_direction;
-	int16_t actual_step;
-	int16_t next_position;
-	int16_t break_steps[4];
-	uint8_t code_val_msb, code_val_lsb;
-	int16_t i;
-
-	if (num_steps > MT9T013_TOTAL_STEPS_NEAR_TO_FAR)
-		num_steps = MT9T013_TOTAL_STEPS_NEAR_TO_FAR;
-	else if (num_steps == 0)
-		return -EINVAL;
-
-	if (direction == MOVE_NEAR)
-		step_direction = 4;
-	else if (direction == MOVE_FAR)
-		step_direction = -4;
-	else
-		return -EINVAL;
-
-	if (mt9t013_ctrl->curr_lens_pos < mt9t013_ctrl->init_curr_lens_pos)
-		mt9t013_ctrl->curr_lens_pos = mt9t013_ctrl->init_curr_lens_pos;
-
-	actual_step =
-		(int16_t) (step_direction *
-		(int16_t) num_steps);
-
-	for (i = 0; i < 4; i++)
-		break_steps[i] =
-			actual_step / 4 * (i + 1) - actual_step / 4 * i;
-
-	for (i = 0; i < 4; i++) {
-		next_position =
-		(int16_t)
-		(mt9t013_ctrl->curr_lens_pos + break_steps[i]);
-
-		if (next_position > 255)
-			next_position = 255;
-		else if (next_position < 0)
-			next_position = 0;
-
-		code_val_msb =
-		((next_position >> 4) << 2) |
-		((next_position << 4) >> 6);
-
-		code_val_lsb =
-		((next_position & 0x03) << 6);
-
-		/* Writing the digital code for current to the actuator */
-		if (mt9t013_i2c_write_b(MT9T013_AF_I2C_ADDR>>1,
-				code_val_msb, code_val_lsb) < 0)
-			return -EBUSY;
-
-		/* Storing the current lens Position */
-		mt9t013_ctrl->curr_lens_pos = next_position;
-
-		if (i < 3)
-			mdelay(1);
-	} /* for */
-
-	return 0;
-}
-
-static int mt9t013_sensor_init_done(const struct msm_camera_sensor_info *data)
-{
-	gpio_direction_output(data->sensor_reset, 0);
-	gpio_free(data->sensor_reset);
-	return 0;
-}
-
-static int mt9t013_probe_init_sensor(const struct msm_camera_sensor_info *data)
-{
-	int rc;
-	uint16_t chipid;
-
-	rc = gpio_request(data->sensor_reset, "mt9t013");
-	if (!rc)
-		gpio_direction_output(data->sensor_reset, 1);
-	else
-		goto init_probe_done;
-
-	mdelay(20);
-
-	/* RESET the sensor image part via I2C command */
-	rc = mt9t013_i2c_write_w(mt9t013_client->addr,
-		MT9T013_REG_RESET_REGISTER, 0x1009);
-	if (rc < 0)
-		goto init_probe_fail;
-
-	msleep(10);
-
-	/* 3. Read sensor Model ID: */
-	rc = mt9t013_i2c_read_w(mt9t013_client->addr,
-		MT9T013_REG_MODEL_ID, &chipid);
-
-	if (rc < 0)
-		goto init_probe_fail;
-
-	CDBG("mt9t013 model_id = 0x%x\n", chipid);
-
-	/* 4. Compare sensor ID to MT9T012VC ID: */
-	if (chipid != MT9T013_MODEL_ID) {
-		rc = -ENODEV;
-		goto init_probe_fail;
-	}
-
-	rc = mt9t013_i2c_write_w(mt9t013_client->addr,
-		0x3064, 0x0805);
-	if (rc < 0)
-		goto init_probe_fail;
-
-	mdelay(MT9T013_RESET_DELAY_MSECS);
-
-	goto init_probe_done;
-
-	/* sensor: output enable */
-#if 0
-	rc = mt9t013_i2c_write_w(mt9t013_client->addr,
-		MT9T013_REG_RESET_REGISTER,
-		MT9T013_RESET_REGISTER_PWON);
-
-	/* if this fails, the sensor is not the MT9T013 */
-	rc = mt9t013_set_default_focus(0);
-#endif
-
-init_probe_fail:
-	gpio_direction_output(data->sensor_reset, 0);
-	gpio_free(data->sensor_reset);
-init_probe_done:
-	return rc;
-}
-
-static int32_t mt9t013_poweron_af(void)
-{
-	int32_t rc = 0;
-
-	/* enable AF actuator */
-	CDBG("enable AF actuator, gpio = %d\n",
-			mt9t013_ctrl->sensordata->vcm_pwd);
-	rc = gpio_request(mt9t013_ctrl->sensordata->vcm_pwd, "mt9t013");
-	if (!rc) {
-		gpio_direction_output(mt9t013_ctrl->sensordata->vcm_pwd, 0);
-		mdelay(20);
-		rc = mt9t013_set_default_focus(0);
-	} else
-		pr_err("%s, gpio_request failed (%d)!\n", __func__, rc);
-	return rc;
-}
-
-static void mt9t013_poweroff_af(void)
-{
-	gpio_direction_output(mt9t013_ctrl->sensordata->vcm_pwd, 1);
-	gpio_free(mt9t013_ctrl->sensordata->vcm_pwd);
-}
-
-int mt9t013_sensor_open_init(const struct msm_camera_sensor_info *data)
-{
-	int32_t  rc;
-
-	mt9t013_ctrl = kzalloc(sizeof(struct mt9t013_ctrl), GFP_KERNEL);
-	if (!mt9t013_ctrl) {
-		pr_err("mt9t013_init failed!\n");
-		rc = -ENOMEM;
-		goto init_done;
-	}
-
-	mt9t013_ctrl->fps_divider = 1 * 0x00000400;
-	mt9t013_ctrl->pict_fps_divider = 1 * 0x00000400;
-	mt9t013_ctrl->set_test = TEST_OFF;
-	mt9t013_ctrl->prev_res = QTR_SIZE;
-	mt9t013_ctrl->pict_res = FULL_SIZE;
-
-	if (data)
-		mt9t013_ctrl->sensordata = data;
-
-	/* enable mclk first */
-	msm_camio_clk_rate_set(MT9T013_DEFAULT_CLOCK_RATE);
-	mdelay(20);
-
-	msm_camio_camif_pad_reg_reset();
-	mdelay(20);
-
-	rc = mt9t013_probe_init_sensor(data);
-	if (rc < 0)
-		goto init_fail;
-
-	if (mt9t013_ctrl->prev_res == QTR_SIZE)
-		rc = mt9t013_setting(REG_INIT, RES_PREVIEW);
-	else
-		rc = mt9t013_setting(REG_INIT, RES_CAPTURE);
-
-	if (rc >= 0)
-		if (machine_is_sapphire())
-			rc = mt9t013_poweron_af();
-
-	if (rc < 0)
-		goto init_fail;
-	else
-		goto init_done;
-
-init_fail:
-	kfree(mt9t013_ctrl);
-init_done:
-	return rc;
-}
-
-static int mt9t013_init_client(struct i2c_client *client)
-{
-	/* Initialize the MSM_CAMI2C Chip */
-	init_waitqueue_head(&mt9t013_wait_queue);
-	return 0;
-}
-
-
-static int32_t mt9t013_set_sensor_mode(int mode, int res)
-{
-	int32_t rc = 0;
-	rc = mt9t013_i2c_write_w(mt9t013_client->addr,
-			REG_GROUPED_PARAMETER_HOLD,
-			GROUPED_PARAMETER_HOLD);
-	if (rc < 0)
-		return rc;
-
-	switch (mode) {
-	case SENSOR_PREVIEW_MODE:
-		rc = mt9t013_video_config(mode, res);
-		break;
-
-	case SENSOR_SNAPSHOT_MODE:
-		rc = mt9t013_snapshot_config(mode);
-		break;
-
-	case SENSOR_RAW_SNAPSHOT_MODE:
-		rc = mt9t013_raw_snapshot_config(mode);
-		break;
-
-	default:
-		return -EINVAL;
-	}
-
-	/* FIXME: what should we do if rc < 0? */
-	if (rc >= 0)
-		return mt9t013_i2c_write_w(mt9t013_client->addr,
-				REG_GROUPED_PARAMETER_HOLD,
-				GROUPED_PARAMETER_UPDATE);
-	return rc;
-}
-
-int mt9t013_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;
-
-	down(&mt9t013_sem);
-
-	CDBG("mt9t013_sensor_config: cfgtype = %d\n", cdata.cfgtype);
-	switch (cdata.cfgtype) {
-	case CFG_GET_PICT_FPS:
-		mt9t013_get_pict_fps(cdata.cfg.gfps.prevfps,
-				&(cdata.cfg.gfps.pictfps));
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PREV_L_PF:
-		cdata.cfg.prevl_pf = mt9t013_get_prev_lines_pf();
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PREV_P_PL:
-		cdata.cfg.prevp_pl = mt9t013_get_prev_pixels_pl();
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PICT_L_PF:
-		cdata.cfg.pictl_pf = mt9t013_get_pict_lines_pf();
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PICT_P_PL:
-		cdata.cfg.pictp_pl =
-			mt9t013_get_pict_pixels_pl();
-
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PICT_MAX_EXP_LC:
-		cdata.cfg.pict_max_exp_lc =
-			mt9t013_get_pict_max_exp_lc();
-
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_SET_FPS:
-	case CFG_SET_PICT_FPS:
-		rc = mt9t013_set_fps(&(cdata.cfg.fps));
-		break;
-
-	case CFG_SET_EXP_GAIN:
-		rc = mt9t013_write_exp_gain(cdata.cfg.exp_gain.gain,
-				cdata.cfg.exp_gain.line);
-		break;
-
-	case CFG_SET_PICT_EXP_GAIN:
-		rc = mt9t013_set_pict_exp_gain(cdata.cfg.exp_gain.gain,
-				cdata.cfg.exp_gain.line);
-		break;
-
-	case CFG_SET_MODE:
-		rc = mt9t013_set_sensor_mode(cdata.mode, cdata.rs);
-		break;
-
-	case CFG_PWR_DOWN:
-		rc = mt9t013_power_down();
-		break;
-
-	case CFG_MOVE_FOCUS:
-		rc = mt9t013_move_focus(cdata.cfg.focus.dir,
-				cdata.cfg.focus.steps);
-		break;
-
-	case CFG_SET_DEFAULT_FOCUS:
-		rc = mt9t013_set_default_focus(cdata.cfg.focus.steps);
-		break;
-
-	case CFG_GET_AF_MAX_STEPS:
-		cdata.max_steps = MT9T013_TOTAL_STEPS_NEAR_TO_FAR;
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_SET_EFFECT:
-	default:
-		rc = -EINVAL;
-		break;
-	}
-
-	up(&mt9t013_sem);
-	return rc;
-}
-
-int mt9t013_sensor_release(void)
-{
-	int rc = -EBADF;
-
-	down(&mt9t013_sem);
-
-	if (machine_is_sapphire())
-		mt9t013_poweroff_af();
-	mt9t013_power_down();
-
-	gpio_direction_output(mt9t013_ctrl->sensordata->sensor_reset,
-			0);
-	gpio_free(mt9t013_ctrl->sensordata->sensor_reset);
-
-	kfree(mt9t013_ctrl);
-
-	up(&mt9t013_sem);
-	CDBG("mt9t013_release completed!\n");
-	return rc;
-}
-
-static int mt9t013_i2c_probe(struct i2c_client *client,
-	const struct i2c_device_id *id)
-{
-	int rc = 0;
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		rc = -ENOTSUPP;
-		goto probe_failure;
-	}
-
-	mt9t013_sensorw =
-		kzalloc(sizeof(struct mt9t013_work), GFP_KERNEL);
-
-	if (!mt9t013_sensorw) {
-		rc = -ENOMEM;
-		goto probe_failure;
-	}
-
-	i2c_set_clientdata(client, mt9t013_sensorw);
-	mt9t013_init_client(client);
-	mt9t013_client = client;
-	mt9t013_client->addr = mt9t013_client->addr >> 1;
-	mdelay(50);
-
-	CDBG("i2c probe ok\n");
-	return 0;
-
-probe_failure:
-	kfree(mt9t013_sensorw);
-	mt9t013_sensorw = NULL;
-	pr_err("i2c probe failure %d\n", rc);
-	return rc;
-}
-
-static const struct i2c_device_id mt9t013_i2c_id[] = {
-	{ "mt9t013", 0},
-	{ }
-};
-
-static struct i2c_driver mt9t013_i2c_driver = {
-	.id_table = mt9t013_i2c_id,
-	.probe  = mt9t013_i2c_probe,
-	.remove = __exit_p(mt9t013_i2c_remove),
-	.driver = {
-		.name = "mt9t013",
-	},
-};
-
-static int mt9t013_sensor_probe(
-		const struct msm_camera_sensor_info *info,
-		struct msm_sensor_ctrl *s)
-{
-	/* We expect this driver to match with the i2c device registered
-	 * in the board file immediately. */
-	int rc = i2c_add_driver(&mt9t013_i2c_driver);
-	if (rc < 0 || mt9t013_client == NULL) {
-		rc = -ENOTSUPP;
-		goto probe_done;
-	}
-
-	/* enable mclk first */
-	msm_camio_clk_rate_set(MT9T013_DEFAULT_CLOCK_RATE);
-	mdelay(20);
-
-	rc = mt9t013_probe_init_sensor(info);
-	if (rc < 0) {
-		i2c_del_driver(&mt9t013_i2c_driver);
-		goto probe_done;
-	}
-
-	s->s_init = mt9t013_sensor_open_init;
-	s->s_release = mt9t013_sensor_release;
-	s->s_config  = mt9t013_sensor_config;
-	s->s_mount_angle = 0;
-	mt9t013_sensor_init_done(info);
-
-probe_done:
-	return rc;
-}
-
-static int __mt9t013_probe(struct platform_device *pdev)
-{
-	return msm_camera_drv_start(pdev, mt9t013_sensor_probe);
-}
-
-static struct platform_driver msm_camera_driver = {
-	.probe = __mt9t013_probe,
-	.driver = {
-		.name = "msm_camera_mt9t013",
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init mt9t013_init(void)
-{
-	return platform_driver_register(&msm_camera_driver);
-}
-
-module_init(mt9t013_init);
diff --git a/drivers/media/platform/msm/camera_v1/mt9t013.h b/drivers/media/platform/msm/camera_v1/mt9t013.h
deleted file mode 100644
index e2d0c23..0000000
--- a/drivers/media/platform/msm/camera_v1/mt9t013.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Copyright (c) 2009-2012, The Linux Foundation. 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.
- *
- */
-
-#ifndef MT9T013_H
-#define MT9T013_H
-
-#include <linux/types.h>
-#include <mach/board.h>
-
-extern struct mt9t013_reg mt9t013_regs; /* from mt9t013_reg.c */
-
-struct reg_struct {
-	uint16_t vt_pix_clk_div;        /*  0x0300 */
-	uint16_t vt_sys_clk_div;        /*  0x0302 */
-	uint16_t pre_pll_clk_div;       /*  0x0304 */
-	uint16_t pll_multiplier;        /*  0x0306 */
-	uint16_t op_pix_clk_div;        /*  0x0308 */
-	uint16_t op_sys_clk_div;        /*  0x030A */
-	uint16_t scale_m;               /*  0x0404 */
-	uint16_t row_speed;             /*  0x3016 */
-	uint16_t x_addr_start;          /*  0x3004 */
-	uint16_t x_addr_end;            /*  0x3008 */
-	uint16_t y_addr_start;        	/*  0x3002 */
-	uint16_t y_addr_end;            /*  0x3006 */
-	uint16_t read_mode;             /*  0x3040 */
-	uint16_t x_output_size;         /*  0x034C */
-	uint16_t y_output_size;         /*  0x034E */
-	uint16_t line_length_pck;       /*  0x300C */
-	uint16_t frame_length_lines;	/*  0x300A */
-	uint16_t coarse_int_time; 		/*  0x3012 */
-	uint16_t fine_int_time;   		/*  0x3014 */
-};
-
-struct mt9t013_i2c_reg_conf {
-	unsigned short waddr;
-	unsigned short wdata;
-};
-
-struct mt9t013_reg {
-	struct reg_struct const *reg_pat;
-	uint16_t reg_pat_size;
-	struct mt9t013_i2c_reg_conf const *ttbl;
-	uint16_t ttbl_size;
-	struct mt9t013_i2c_reg_conf const *lctbl;
-	uint16_t lctbl_size;
-	struct mt9t013_i2c_reg_conf const *rftbl;
-	uint16_t rftbl_size;
-};
-
-#endif /* #define MT9T013_H */
diff --git a/drivers/media/platform/msm/camera_v1/mt9t013_reg.c b/drivers/media/platform/msm/camera_v1/mt9t013_reg.c
deleted file mode 100644
index 9031441..0000000
--- a/drivers/media/platform/msm/camera_v1/mt9t013_reg.c
+++ /dev/null
@@ -1,275 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-
-#include "mt9t013.h"
-#include <linux/kernel.h>
-
-struct reg_struct const mt9t013_reg_pat[2] = {
-	{ /* Preview 2x2 binning 20fps, pclk MHz, MCLK 24MHz */
-	/* vt_pix_clk_div:REG=0x0300 update get_snapshot_fps
-	* if this change */
-	8,
-
-	/* vt_sys_clk_div: REG=0x0302  update get_snapshot_fps
-	* if this change */
-	1,
-
-	/* pre_pll_clk_div REG=0x0304  update get_snapshot_fps
-	* if this change */
-	2,
-
-	/* pll_multiplier  REG=0x0306 60 for 30fps preview, 40
-	 * for 20fps preview
-	 * 46 for 30fps preview, try 47/48 to increase further */
-	46,
-
-	/* op_pix_clk_div        REG=0x0308 */
-	8,
-
-	/* op_sys_clk_div        REG=0x030A */
-	1,
-
-	/* scale_m       REG=0x0404 */
-	16,
-
-	/* row_speed     REG=0x3016 */
-	0x0111,
-
-	/* x_addr_start  REG=0x3004 */
-	8,
-
-	/* x_addr_end    REG=0x3008 */
-	2053,
-
-	/* y_addr_start  REG=0x3002 */
-	8,
-
-	/* y_addr_end    REG=0x3006 */
-	1541,
-
-	/* read_mode     REG=0x3040 */
-	0x046C,
-
-	/* x_output_size REG=0x034C */
-	1024,
-
-	/* y_output_size REG=0x034E */
-	768,
-
-	/* line_length_pck    REG=0x300C */
-	2616,
-
-	/* frame_length_lines REG=0x300A */
-	916,
-
-	/* coarse_int_time REG=0x3012 */
-	16,
-
-	/* fine_int_time   REG=0x3014 */
-	1461
-	},
-	{ /*Snapshot */
-	/* vt_pix_clk_div  REG=0x0300 update get_snapshot_fps
-	* if this change */
-	8,
-
-	/* vt_sys_clk_div  REG=0x0302 update get_snapshot_fps
-	* if this change */
-	1,
-
-	/* pre_pll_clk_div REG=0x0304 update get_snapshot_fps
-	 * if this change */
-	2,
-
-	/* pll_multiplier REG=0x0306 50 for 15fps snapshot,
-	 * 40 for 10fps snapshot
-	 * 46 for 30fps snapshot, try 47/48 to increase further */
-	46,
-
-	/* op_pix_clk_div        REG=0x0308 */
-	8,
-
-	/* op_sys_clk_div        REG=0x030A */
-	1,
-
-	/* scale_m       REG=0x0404 */
-	16,
-
-	/* row_speed     REG=0x3016 */
-	0x0111,
-
-	/* x_addr_start  REG=0x3004 */
-	8,
-
-	/* x_addr_end    REG=0x3008 */
-	2071,
-
-	/* y_addr_start  REG=0x3002 */
-	8,
-
-	/* y_addr_end    REG=0x3006 */
-	1551,
-
-	/* read_mode     REG=0x3040 */
-	0x0024,
-
-	/* x_output_size REG=0x034C */
-	2064,
-
-	/* y_output_size REG=0x034E */
-	1544,
-
-	/* line_length_pck REG=0x300C */
-	2952,
-
-	/* frame_length_lines    REG=0x300A */
-	1629,
-
-	/* coarse_int_time REG=0x3012 */
-	16,
-
-	/* fine_int_time REG=0x3014   */
-	733
-	}
-};
-
-struct mt9t013_i2c_reg_conf const mt9t013_test_tbl[] = {
-	{ 0x3044, 0x0544 & 0xFBFF },
-	{ 0x30CA, 0x0004 | 0x0001 },
-	{ 0x30D4, 0x9020 & 0x7FFF },
-	{ 0x31E0, 0x0003 & 0xFFFE },
-	{ 0x3180, 0x91FF & 0x7FFF },
-	{ 0x301A, (0x10CC | 0x8000) & 0xFFF7 },
-	{ 0x301E, 0x0000 },
-	{ 0x3780, 0x0000 },
-};
-
-/* [Lens shading 85 Percent TL84] */
-struct mt9t013_i2c_reg_conf const mt9t013_lc_tbl[] = {
-	{ 0x360A, 0x0290 }, /* P_RD_P0Q0 */
-	{ 0x360C, 0xC92D }, /* P_RD_P0Q1 */
-	{ 0x360E, 0x0771 }, /* P_RD_P0Q2 */
-	{ 0x3610, 0xE38C }, /* P_RD_P0Q3 */
-	{ 0x3612, 0xD74F }, /* P_RD_P0Q4 */
-	{ 0x364A, 0x168C }, /* P_RD_P1Q0 */
-	{ 0x364C, 0xCACB }, /* P_RD_P1Q1 */
-	{ 0x364E, 0x8C4C }, /* P_RD_P1Q2 */
-	{ 0x3650, 0x0BEA }, /* P_RD_P1Q3 */
-	{ 0x3652, 0xDC0F }, /* P_RD_P1Q4 */
-	{ 0x368A, 0x70B0 }, /* P_RD_P2Q0 */
-	{ 0x368C, 0x200B }, /* P_RD_P2Q1 */
-	{ 0x368E, 0x30B2 }, /* P_RD_P2Q2 */
-	{ 0x3690, 0xD04F }, /* P_RD_P2Q3 */
-	{ 0x3692, 0xACF5 }, /* P_RD_P2Q4 */
-	{ 0x36CA, 0xF7C9 }, /* P_RD_P3Q0 */
-	{ 0x36CC, 0x2AED }, /* P_RD_P3Q1 */
-	{ 0x36CE, 0xA652 }, /* P_RD_P3Q2 */
-	{ 0x36D0, 0x8192 }, /* P_RD_P3Q3 */
-	{ 0x36D2, 0x3A15 }, /* P_RD_P3Q4 */
-	{ 0x370A, 0xDA30 }, /* P_RD_P4Q0 */
-	{ 0x370C, 0x2E2F }, /* P_RD_P4Q1 */
-	{ 0x370E, 0xBB56 }, /* P_RD_P4Q2 */
-	{ 0x3710, 0x8195 }, /* P_RD_P4Q3 */
-	{ 0x3712, 0x02F9 }, /* P_RD_P4Q4 */
-	{ 0x3600, 0x0230 }, /* P_GR_P0Q0 */
-	{ 0x3602, 0x58AD }, /* P_GR_P0Q1 */
-	{ 0x3604, 0x18D1 }, /* P_GR_P0Q2 */
-	{ 0x3606, 0x260D }, /* P_GR_P0Q3 */
-	{ 0x3608, 0xF530 }, /* P_GR_P0Q4 */
-	{ 0x3640, 0x17EB }, /* P_GR_P1Q0 */
-	{ 0x3642, 0x3CAB }, /* P_GR_P1Q1 */
-	{ 0x3644, 0x87CE }, /* P_GR_P1Q2 */
-	{ 0x3646, 0xC02E }, /* P_GR_P1Q3 */
-	{ 0x3648, 0xF48F }, /* P_GR_P1Q4 */
-	{ 0x3680, 0x5350 }, /* P_GR_P2Q0 */
-	{ 0x3682, 0x7EAF }, /* P_GR_P2Q1 */
-	{ 0x3684, 0x4312 }, /* P_GR_P2Q2 */
-	{ 0x3686, 0xC652 }, /* P_GR_P2Q3 */
-	{ 0x3688, 0xBC15 }, /* P_GR_P2Q4 */
-	{ 0x36C0, 0xB8AD }, /* P_GR_P3Q0 */
-	{ 0x36C2, 0xBDCD }, /* P_GR_P3Q1 */
-	{ 0x36C4, 0xE4B2 }, /* P_GR_P3Q2 */
-	{ 0x36C6, 0xB50F }, /* P_GR_P3Q3 */
-	{ 0x36C8, 0x5B95 }, /* P_GR_P3Q4 */
-	{ 0x3700, 0xFC90 }, /* P_GR_P4Q0 */
-	{ 0x3702, 0x8C51 }, /* P_GR_P4Q1 */
-	{ 0x3704, 0xCED6 }, /* P_GR_P4Q2 */
-	{ 0x3706, 0xB594 }, /* P_GR_P4Q3 */
-	{ 0x3708, 0x0A39 }, /* P_GR_P4Q4 */
-	{ 0x3614, 0x0230 }, /* P_BL_P0Q0 */
-	{ 0x3616, 0x160D }, /* P_BL_P0Q1 */
-	{ 0x3618, 0x08D1 }, /* P_BL_P0Q2 */
-	{ 0x361A, 0x98AB }, /* P_BL_P0Q3 */
-	{ 0x361C, 0xEA50 }, /* P_BL_P0Q4 */
-	{ 0x3654, 0xB4EA }, /* P_BL_P1Q0 */
-	{ 0x3656, 0xEA6C }, /* P_BL_P1Q1 */
-	{ 0x3658, 0xFE08 }, /* P_BL_P1Q2 */
-	{ 0x365A, 0x2C6E }, /* P_BL_P1Q3 */
-	{ 0x365C, 0xEB0E }, /* P_BL_P1Q4 */
-	{ 0x3694, 0x6DF0 }, /* P_BL_P2Q0 */
-	{ 0x3696, 0x3ACF }, /* P_BL_P2Q1 */
-	{ 0x3698, 0x3E0F }, /* P_BL_P2Q2 */
-	{ 0x369A, 0xB2B1 }, /* P_BL_P2Q3 */
-	{ 0x369C, 0xC374 }, /* P_BL_P2Q4 */
-	{ 0x36D4, 0xF2AA }, /* P_BL_P3Q0 */
-	{ 0x36D6, 0x8CCC }, /* P_BL_P3Q1 */
-	{ 0x36D8, 0xDEF2 }, /* P_BL_P3Q2 */
-	{ 0x36DA, 0xFA11 }, /* P_BL_P3Q3 */
-	{ 0x36DC, 0x42F5 }, /* P_BL_P3Q4 */
-	{ 0x3714, 0xF4F1 }, /* P_BL_P4Q0 */
-	{ 0x3716, 0xF6F0 }, /* P_BL_P4Q1 */
-	{ 0x3718, 0x8FD6 }, /* P_BL_P4Q2 */
-	{ 0x371A, 0xEA14 }, /* P_BL_P4Q3 */
-	{ 0x371C, 0x6338 }, /* P_BL_P4Q4 */
-	{ 0x361E, 0x0350 }, /* P_GB_P0Q0 */
-	{ 0x3620, 0x91AE }, /* P_GB_P0Q1 */
-	{ 0x3622, 0x0571 }, /* P_GB_P0Q2 */
-	{ 0x3624, 0x100D }, /* P_GB_P0Q3 */
-	{ 0x3626, 0xCA70 }, /* P_GB_P0Q4 */
-	{ 0x365E, 0xE6CB }, /* P_GB_P1Q0 */
-	{ 0x3660, 0x50ED }, /* P_GB_P1Q1 */
-	{ 0x3662, 0x3DAE }, /* P_GB_P1Q2 */
-	{ 0x3664, 0xAA4F }, /* P_GB_P1Q3 */
-	{ 0x3666, 0xDC50 }, /* P_GB_P1Q4 */
-	{ 0x369E, 0x5470 }, /* P_GB_P2Q0 */
-	{ 0x36A0, 0x1F6E }, /* P_GB_P2Q1 */
-	{ 0x36A2, 0x6671 }, /* P_GB_P2Q2 */
-	{ 0x36A4, 0xC010 }, /* P_GB_P2Q3 */
-	{ 0x36A6, 0x8DF5 }, /* P_GB_P2Q4 */
-	{ 0x36DE, 0x0B0C }, /* P_GB_P3Q0 */
-	{ 0x36E0, 0x84CE }, /* P_GB_P3Q1 */
-	{ 0x36E2, 0x8493 }, /* P_GB_P3Q2 */
-	{ 0x36E4, 0xA610 }, /* P_GB_P3Q3 */
-	{ 0x36E6, 0x50B5 }, /* P_GB_P3Q4 */
-	{ 0x371E, 0x9651 }, /* P_GB_P4Q0 */
-	{ 0x3720, 0x1EAB }, /* P_GB_P4Q1 */
-	{ 0x3722, 0xAF76 }, /* P_GB_P4Q2 */
-	{ 0x3724, 0xE4F4 }, /* P_GB_P4Q3 */
-	{ 0x3726, 0x79F8 }, /* P_GB_P4Q4 */
-	{ 0x3782, 0x0410 }, /* POLY_ORIGIN_C */
-	{ 0x3784, 0x0320 }, /* POLY_ORIGIN_R  */
-	{ 0x3780, 0x8000 } /* POLY_SC_ENABLE */
-};
-
-struct mt9t013_reg mt9t013_regs = {
-	.reg_pat = &mt9t013_reg_pat[0],
-	.reg_pat_size = ARRAY_SIZE(mt9t013_reg_pat),
-	.ttbl = &mt9t013_test_tbl[0],
-	.ttbl_size = ARRAY_SIZE(mt9t013_test_tbl),
-	.lctbl = &mt9t013_lc_tbl[0],
-	.lctbl_size = ARRAY_SIZE(mt9t013_lc_tbl),
-	.rftbl = &mt9t013_lc_tbl[0],	/* &mt9t013_rolloff_tbl[0], */
-	.rftbl_size = ARRAY_SIZE(mt9t013_lc_tbl)
-};
-
-
diff --git a/drivers/media/platform/msm/camera_v1/ov5640.c b/drivers/media/platform/msm/camera_v1/ov5640.c
deleted file mode 100644
index 8441a46..0000000
--- a/drivers/media/platform/msm/camera_v1/ov5640.c
+++ /dev/null
@@ -1,1477 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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/platform/msm/camera_v1/ov5640.h b/drivers/media/platform/msm/camera_v1/ov5640.h
deleted file mode 100644
index a428da6..0000000
--- a/drivers/media/platform/msm/camera_v1/ov5640.h
+++ /dev/null
@@ -1,2993 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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/platform/msm/camera_v1/ov5647.c b/drivers/media/platform/msm/camera_v1/ov5647.c
deleted file mode 100644
index 365faef..0000000
--- a/drivers/media/platform/msm/camera_v1/ov5647.c
+++ /dev/null
@@ -1,1201 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#include <linux/delay.h>
-#include <linux/debugfs.h>
-#include <linux/types.h>
-#include <linux/i2c.h>
-#include <linux/uaccess.h>
-#include <linux/miscdevice.h>
-#include <linux/slab.h>
-#include <linux/gpio.h>
-#include <linux/bitops.h>
-#include <linux/leds.h>
-#include <mach/camera.h>
-#include <media/msm_camera.h>
-#include "ov5647.h"
-
-/* 16bit address - 8 bit context register structure */
-#define Q8	0x00000100
-#define Q10	0x00000400
-
-#define REG_OV5647_GAIN_MSB           0x350A
-#define REG_OV5647_GAIN_LSB           0x350B
-#define REG_OV5647_LINE_HSB           0x3500
-#define REG_OV5647_LINE_MSB           0x3501
-#define REG_OV5647_LINE_LSB           0x3502
-
-/* MCLK */
-#define OV5647_MASTER_CLK_RATE 24000000
-
-/* AF Total steps parameters */
-#define OV5647_TOTAL_STEPS_NEAR_TO_FAR	32
-
-#define OV5647_REG_PREV_FRAME_LEN_1	31
-#define OV5647_REG_PREV_FRAME_LEN_2	32
-#define OV5647_REG_PREV_LINE_LEN_1	33
-#define OV5647_REG_PREV_LINE_LEN_2	34
-
-#define OV5647_REG_SNAP_FRAME_LEN_1	15
-#define OV5647_REG_SNAP_FRAME_LEN_2	16
-#define OV5647_REG_SNAP_LINE_LEN_1	17
-#define OV5647_REG_SNAP_LINE_LEN_2	18
-#define MSB                             1
-#define LSB                             0
-
-/* Debug switch */
-#ifdef CDBG
-#undef CDBG
-#endif
-#ifdef CDBG_HIGH
-#undef CDBG_HIGH
-#endif
-
-/*#define OV5647_VERBOSE_DGB*/
-
-#ifdef OV5647_VERBOSE_DGB
-#define CDBG(fmt, args...) pr_debug(fmt, ##args)
-#define CDBG_HIGH(fmt, args...) pr_debug(fmt, ##args)
-#else
-#define CDBG(fmt, args...) do { } while (0)
-#define CDBG_HIGH(fmt, args...) pr_debug(fmt, ##args)
-#endif
-
-/*for debug*/
-#ifdef CDBG
-#undef CDBG
-#endif
-#define CDBG(fmt, args...) printk(fmt, ##args)
-
-static uint8_t  mode_mask = 0x09;
-struct ov5647_work_t {
-	struct work_struct work;
-};
-
-static struct ov5647_work_t *ov5647_sensorw;
-static struct ov5647_work_t *ov5647_af_sensorw;
-static struct i2c_client *ov5647_af_client;
-static struct i2c_client *ov5647_client;
-
-struct ov5647_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 */
-	uint16_t fps;
-
-	uint16_t curr_lens_pos;
-	uint16_t curr_step_pos;
-	uint16_t my_reg_gain;
-	uint32_t my_reg_line_count;
-	uint16_t total_lines_per_frame;
-
-	enum ov5647_resolution_t prev_res;
-	enum ov5647_resolution_t pict_res;
-	enum ov5647_resolution_t curr_res;
-	enum ov5647_test_mode_t  set_test;
-};
-
-static bool CSI_CONFIG;
-static struct ov5647_ctrl_t *ov5647_ctrl;
-
-static DECLARE_WAIT_QUEUE_HEAD(ov5647_wait_queue);
-static DECLARE_WAIT_QUEUE_HEAD(ov5647_af_wait_queue);
-DEFINE_MUTEX(ov5647_mut);
-
-static uint16_t prev_line_length_pck;
-static uint16_t prev_frame_length_lines;
-static uint16_t snap_line_length_pck;
-static uint16_t snap_frame_length_lines;
-
-static int ov5647_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   = 1,
-			.buf   = rxdata,
-		},
-	};
-	if (i2c_transfer(ov5647_client->adapter, msgs, 2) < 0) {
-		CDBG("ov5647_i2c_rxdata faild 0x%x\n", saddr);
-		return -EIO;
-	}
-	return 0;
-}
-
-static int32_t ov5647_i2c_txdata(unsigned short saddr,
-		unsigned char *txdata, int length)
-{
-	struct i2c_msg msg[] = {
-		{
-			.addr = saddr,
-			.flags = 0,
-			.len = length,
-			.buf = txdata,
-		},
-	};
-	if (i2c_transfer(ov5647_client->adapter, msg, 1) < 0) {
-		CDBG("ov5647_i2c_txdata faild 0x%x\n", saddr);
-		return -EIO;
-	}
-
-	return 0;
-}
-
-static int32_t ov5647_i2c_read(unsigned short raddr,
-		unsigned short *rdata)
-{
-	int32_t rc = 0;
-	unsigned char buf[2];
-
-	if (!rdata)
-		return -EIO;
-	CDBG("%s:saddr:0x%x raddr:0x%x data:0x%x",
-		__func__, ov5647_client->addr, raddr, *rdata);
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (raddr & 0xFF00) >> 8;
-	buf[1] = (raddr & 0x00FF);
-	rc = ov5647_i2c_rxdata(ov5647_client->addr >> 1, buf, 1);
-	if (rc < 0) {
-		CDBG("ov5647_i2c_read 0x%x failed!\n", raddr);
-		return rc;
-	}
-	*rdata = buf[0];
-	CDBG("ov5647_i2c_read 0x%x val = 0x%x!\n", raddr, *rdata);
-
-	return rc;
-}
-
-static int32_t ov5647_i2c_write_b_sensor(unsigned short waddr, uint8_t bdata)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[3];
-
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00) >> 8;
-	buf[1] = (waddr & 0x00FF);
-	buf[2] = bdata;
-	CDBG("i2c_write_b addr = 0x%x, val = 0x%x\n", waddr, bdata);
-	rc = ov5647_i2c_txdata(ov5647_client->addr >> 1, buf, 3);
-	if (rc < 0) {
-		pr_err("i2c_write_b failed, addr = 0x%x, val = 0x%x!\n",
-				waddr, bdata);
-	}
-	return rc;
-}
-
-static int32_t ov5647_i2c_write_b_table(struct ov5647_i2c_reg_conf const
-		*reg_conf_tbl, int num)
-{
-	int i;
-	int32_t rc = -EIO;
-
-	for (i = 0; i < num; i++) {
-		rc = ov5647_i2c_write_b_sensor(reg_conf_tbl->waddr,
-				reg_conf_tbl->wdata);
-		if (rc < 0)
-			break;
-		reg_conf_tbl++;
-	}
-	return rc;
-}
-
-static int32_t ov5647_af_i2c_txdata(unsigned short saddr,
-		unsigned char *txdata, int length)
-{
-	struct i2c_msg msg[] = {
-		{
-			.addr = saddr,
-			.flags = 0,
-			.len = length,
-			.buf = txdata,
-		},
-	};
-	if (i2c_transfer(ov5647_af_client->adapter, msg, 1) < 0) {
-		pr_err("ov5647_af_i2c_txdata faild 0x%x\n", saddr);
-		return -EIO;
-	}
-
-	return 0;
-}
-
-static int32_t ov5647_af_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;
-	CDBG("i2c_write_b addr = 0x%x, val = 0x%x\n", waddr, bdata);
-	rc = ov5647_af_i2c_txdata(ov5647_af_client->addr, buf, 2);
-	if (rc < 0) {
-		pr_err("i2c_write_b failed, addr = 0x%x, val = 0x%x!\n",
-				waddr, bdata);
-	}
-	return rc;
-}
-
-static void ov5647_start_stream(void)
-{
-	CDBG("CAMERA_DBG: 0x4202 0x0, stream on...\r\n");
-	ov5647_i2c_write_b_sensor(0x4202, 0x00);/* streaming on */
-}
-
-static void ov5647_stop_stream(void)
-{
-	CDBG("CAMERA_DBG: 0x4202 0xf, stream off...\r\n");
-	ov5647_i2c_write_b_sensor(0x4202, 0x0f);/* streaming off */
-}
-
-static void ov5647_group_hold_on(void)
-{
-	ov5647_i2c_write_b_sensor(0x0104, 0x01);
-}
-
-static void ov5647_group_hold_off(void)
-{
-	ov5647_i2c_write_b_sensor(0x0104, 0x0);
-}
-
-static void ov5647_get_pict_fps(uint16_t fps, uint16_t *pfps)
-{
-	/* input fps is preview fps in Q8 format */
-	uint32_t divider, d1, d2;
-	uint32_t preview_pclk = 0x37, snapshot_pclk = 0x4f;
-
-	d1 = (prev_frame_length_lines * 0x00000400) / snap_frame_length_lines;
-	d2 = (prev_line_length_pck * 0x00000400) / snap_line_length_pck;
-	divider = (d1 * d2*preview_pclk/snapshot_pclk) / 0x400;
-	CDBG(KERN_ERR "ov5647_get_pict_fps divider = %d", divider);
-	/*Verify PCLK settings and frame sizes.*/
-	*pfps = (uint16_t) (fps * divider / 0x400);
-}
-
-static uint16_t ov5647_get_prev_lines_pf(void)
-{
-	if (ov5647_ctrl->prev_res == QTR_SIZE)
-		return prev_frame_length_lines;
-	else
-		return snap_frame_length_lines;
-}
-
-static uint16_t ov5647_get_prev_pixels_pl(void)
-{
-	if (ov5647_ctrl->prev_res == QTR_SIZE)
-		return prev_line_length_pck;
-	else
-		return snap_line_length_pck;
-}
-
-static uint16_t ov5647_get_pict_lines_pf(void)
-{
-	if (ov5647_ctrl->pict_res == QTR_SIZE)
-		return prev_frame_length_lines;
-	else
-		return snap_frame_length_lines;
-}
-
-static uint16_t ov5647_get_pict_pixels_pl(void)
-{
-	if (ov5647_ctrl->pict_res == QTR_SIZE)
-		return prev_line_length_pck;
-	else
-		return snap_line_length_pck;
-}
-
-static uint32_t ov5647_get_pict_max_exp_lc(void)
-{
-	return snap_frame_length_lines * 24;
-}
-
-static int32_t ov5647_set_fps(struct fps_cfg   *fps)
-{
-	uint16_t total_lines_per_frame;
-	int32_t rc = 0;
-
-	ov5647_ctrl->fps_divider = fps->fps_div;
-	ov5647_ctrl->pict_fps_divider = fps->pict_fps_div;
-
-	if (ov5647_ctrl->sensormode == SENSOR_PREVIEW_MODE) {
-		total_lines_per_frame = (uint16_t)
-		((prev_frame_length_lines * ov5647_ctrl->fps_divider) / 0x400);
-	} else {
-		total_lines_per_frame = (uint16_t)
-		((snap_frame_length_lines * ov5647_ctrl->fps_divider) / 0x400);
-	}
-
-	ov5647_group_hold_on();
-	rc = ov5647_i2c_write_b_sensor(0x0340,
-			((total_lines_per_frame & 0xFF00) >> 8));
-	rc = ov5647_i2c_write_b_sensor(0x0341,
-			(total_lines_per_frame & 0x00FF));
-	ov5647_group_hold_off();
-
-	return rc;
-}
-
-static inline uint8_t ov5647_byte(uint16_t word, uint8_t offset)
-{
-	return word >> (offset * BITS_PER_BYTE);
-}
-
-static int32_t ov5647_write_exp_gain(uint16_t gain, uint32_t line)
-{
-	int rc = 0;
-	uint16_t max_line;
-	u8 intg_time_hsb, intg_time_msb, intg_time_lsb;
-	uint8_t gain_lsb, gain_hsb;
-	ov5647_ctrl->my_reg_gain = gain;
-	ov5647_ctrl->my_reg_line_count = (uint16_t)line;
-
-	CDBG(KERN_ERR "preview exposure setting 0x%x, 0x%x, %d",
-		 gain, line, line);
-
-	gain_lsb = (uint8_t) (ov5647_ctrl->my_reg_gain);
-	gain_hsb = (uint8_t)((ov5647_ctrl->my_reg_gain & 0x300)>>8);
-	/* adjust frame rate */
-	if (line > 980) {
-		rc = ov5647_i2c_write_b_sensor(0x380E,
-			 (uint8_t)((line+4) >> 8)) ;
-		rc = ov5647_i2c_write_b_sensor(0x380F,
-			 (uint8_t)((line+4) & 0x00FF)) ;
-		max_line = line + 4;
-	} else if (max_line > 984) {
-		rc = ov5647_i2c_write_b_sensor(0x380E,
-			 (uint8_t)(984 >> 8)) ;
-		rc = ov5647_i2c_write_b_sensor(0x380F,
-			 (uint8_t)(984 & 0x00FF)) ;
-		max_line = 984;
-	}
-
-	line = line<<4;
-	/* ov5647 need this operation */
-	intg_time_hsb = (u8)(line>>16);
-	intg_time_msb = (u8) ((line & 0xFF00) >> 8);
-	intg_time_lsb = (u8) (line & 0x00FF);
-
-	ov5647_group_hold_on();
-	rc = ov5647_i2c_write_b_sensor(REG_OV5647_LINE_HSB, intg_time_hsb) ;
-	rc = ov5647_i2c_write_b_sensor(REG_OV5647_LINE_MSB, intg_time_msb) ;
-	rc = ov5647_i2c_write_b_sensor(REG_OV5647_LINE_LSB, intg_time_lsb) ;
-
-	rc = ov5647_i2c_write_b_sensor(REG_OV5647_GAIN_MSB, gain_hsb) ;
-	rc = ov5647_i2c_write_b_sensor(REG_OV5647_GAIN_LSB, gain_lsb) ;
-	ov5647_group_hold_off();
-
-	return rc;
-}
-
-
-static int32_t ov5647_set_pict_exp_gain(uint16_t gain, uint32_t line)
-{
-	uint16_t max_line;
-	int rc = 0;
-	uint8_t gain_lsb, gain_hsb;
-	u8 intg_time_hsb, intg_time_msb, intg_time_lsb;
-
-	ov5647_ctrl->my_reg_gain = gain;
-	ov5647_ctrl->my_reg_line_count = (uint16_t)line;
-
-	gain_lsb = (uint8_t) (ov5647_ctrl->my_reg_gain);
-	gain_hsb = (uint8_t)((ov5647_ctrl->my_reg_gain & 0x300)>>8);
-
-	CDBG(KERN_ERR "snapshot exposure seting 0x%x, 0x%x, %d"
-		, gain, line, line);
-
-	if (line > 1964) {
-		rc = ov5647_i2c_write_b_sensor(0x380E,
-			 (uint8_t)((line+4) >> 8)) ;
-		rc = ov5647_i2c_write_b_sensor(0x380F,
-			 (uint8_t)((line+4) & 0x00FF)) ;
-		max_line = line + 4;
-	} else if (max_line > 1968) {
-		rc = ov5647_i2c_write_b_sensor(0x380E,
-			 (uint8_t)(1968 >> 8)) ;
-		rc = ov5647_i2c_write_b_sensor(0x380F,
-			 (uint8_t)(1968 & 0x00FF)) ;
-		max_line = 1968;
-	}
-	line = line<<4;
-	/* ov5647 need this operation */
-	intg_time_hsb = (u8)(line>>16);
-	intg_time_msb = (u8) ((line & 0xFF00) >> 8);
-	intg_time_lsb = (u8) (line & 0x00FF);
-
-	/* FIXME for BLC trigger */
-	ov5647_group_hold_on();
-	rc = ov5647_i2c_write_b_sensor(REG_OV5647_LINE_HSB, intg_time_hsb) ;
-	rc = ov5647_i2c_write_b_sensor(REG_OV5647_LINE_MSB, intg_time_msb) ;
-	rc = ov5647_i2c_write_b_sensor(REG_OV5647_LINE_LSB, intg_time_lsb) ;
-
-	rc = ov5647_i2c_write_b_sensor(REG_OV5647_GAIN_MSB, gain_hsb) ;
-	rc = ov5647_i2c_write_b_sensor(REG_OV5647_GAIN_LSB, gain_lsb - 1) ;
-
-	rc = ov5647_i2c_write_b_sensor(REG_OV5647_LINE_HSB, intg_time_hsb) ;
-	rc = ov5647_i2c_write_b_sensor(REG_OV5647_LINE_MSB, intg_time_msb) ;
-	rc = ov5647_i2c_write_b_sensor(REG_OV5647_LINE_LSB, intg_time_lsb) ;
-
-	rc = ov5647_i2c_write_b_sensor(REG_OV5647_GAIN_MSB, gain_hsb) ;
-	rc = ov5647_i2c_write_b_sensor(REG_OV5647_GAIN_LSB, gain_lsb) ;
-	ov5647_group_hold_off();
-
-	msleep(500);
-	return rc;
-
-}
-
-static int32_t ov5647_move_focus(int direction, int32_t num_steps)
-{
-	uint8_t   code_val_msb = 0;
-	uint8_t   code_val_lsb = 0;
-	int16_t   step_direction, actual_step, next_position;
-	int rc;
-
-	if (num_steps == 0)
-		return 0;
-
-	if (direction == MOVE_NEAR)
-		step_direction = 20;
-	else if (direction == MOVE_FAR)
-		step_direction = -20;
-	else
-		return -EINVAL;
-
-	actual_step = (int16_t)(step_direction * num_steps);
-	next_position = (int16_t)ov5647_ctrl->curr_lens_pos + actual_step;
-	if (next_position < 0) {
-		CDBG(KERN_ERR "%s: OV5647 position(=%d) out of range",
-			__func__, next_position);
-		next_position = 0;
-	}
-	if (next_position > 0x3FF) {
-		CDBG(KERN_ERR "%s: OV5647 position(=%d) out of range",
-			__func__, next_position);
-		next_position = 0x3FF;
-	}
-	ov5647_ctrl->curr_lens_pos = next_position;
-
-	code_val_msb = (uint8_t)((ov5647_ctrl->curr_lens_pos & 0x03FF) >> 4);
-	code_val_lsb = (uint8_t)((ov5647_ctrl->curr_lens_pos & 0x000F) << 4);
-	code_val_lsb |= mode_mask;
-
-	rc = ov5647_af_i2c_write_b_sensor(code_val_msb, code_val_lsb);
-	/* DAC Setting */
-	if (rc != 0) {
-		CDBG(KERN_ERR "%s: WRITE ERROR lsb = 0x%x, msb = 0x%x",
-			__func__, code_val_lsb, code_val_msb);
-	} else {
-		CDBG(KERN_ERR "%s: Successful lsb = 0x%x, msb = 0x%x",
-			__func__, code_val_lsb, code_val_msb);
-		/* delay may set based on the steps moved
-		when I2C write successful */
-		msleep(100);
-	}
-	return 0;
-}
-
-static int32_t ov5647_set_default_focus(uint8_t af_step)
-{
-	uint8_t  code_val_msb = 0;
-	uint8_t  code_val_lsb = 0;
-	int rc = 0;
-
-	ov5647_ctrl->curr_lens_pos = 200;
-
-
-	code_val_msb = (ov5647_ctrl->curr_lens_pos & 0x03FF) >> 4;
-	code_val_lsb = (ov5647_ctrl->curr_lens_pos & 0x000F) << 4;
-	code_val_lsb |= mode_mask;
-
-	CDBG(KERN_ERR "ov5647_set_default_focus:lens pos = %d",
-		 ov5647_ctrl->curr_lens_pos);
-	rc = ov5647_af_i2c_write_b_sensor(code_val_msb, code_val_lsb);
-	/* DAC Setting */
-	if (rc != 0)
-		CDBG(KERN_ERR "%s: WRITE ERROR lsb = 0x%x, msb = 0x%x",
-			__func__, code_val_lsb, code_val_msb);
-	else
-		CDBG(KERN_ERR "%s: WRITE successful lsb = 0x%x, msb = 0x%x",
-			__func__, code_val_lsb, code_val_msb);
-
-	usleep_range(10000, 11000);
-	return 0;
-}
-
-static int32_t ov5647_test(enum ov5647_test_mode_t mo)
-{
-	int32_t rc = 0;
-
-	if (mo != TEST_OFF)
-		rc = ov5647_i2c_write_b_sensor(0x0601, (uint8_t) mo);
-
-	return rc;
-}
-
-static void ov5647_reset_sensor(void)
-{
-	ov5647_i2c_write_b_sensor(0x103, 0x1);
-}
-
-
-static int32_t ov5647_sensor_setting(int update_type, int rt)
-{
-
-	int32_t rc = 0;
-	struct msm_camera_csi_params ov5647_csi_params;
-
-	ov5647_stop_stream();
-
-	/* wait for clk/data really stop */
-	if ((rt == RES_CAPTURE) || (CSI_CONFIG == 0))
-		msleep(66);
-	else
-		msleep(266);
-
-	CDBG("CAMERA_DBG1: 0x4800 regVal:0x25\r\n");
-	ov5647_i2c_write_b_sensor(0x4800, 0x25);/* streaming off */
-
-	usleep_range(10000, 11000);
-
-	if (update_type == REG_INIT) {
-		ov5647_reset_sensor();
-		ov5647_i2c_write_b_table(ov5647_regs.rec_settings,
-			ov5647_regs.rec_size);
-		CSI_CONFIG = 0;
-	} else if (update_type == UPDATE_PERIODIC) {
-			/* turn off flash when preview */
-
-			if (rt == RES_PREVIEW) {
-				ov5647_i2c_write_b_table(ov5647_regs.reg_prev,
-					 ov5647_regs.reg_prev_size);
-				CDBG("CAMERA_DBG:preview settings...\r\n");
-			} else {
-				ov5647_i2c_write_b_table(ov5647_regs.reg_snap,
-					 ov5647_regs.reg_snap_size);
-				CDBG("CAMERA_DBG:snapshot settings...\r\n");
-			}
-
-			msleep(20);
-			if (!CSI_CONFIG) {
-				msm_camio_vfe_clk_rate_set(192000000);
-				ov5647_csi_params.data_format = CSI_8BIT;
-				ov5647_csi_params.lane_cnt = 2;
-				ov5647_csi_params.lane_assign = 0xe4;
-				ov5647_csi_params.dpcm_scheme = 0;
-				ov5647_csi_params.settle_cnt = 10;
-				rc = msm_camio_csi_config(&ov5647_csi_params);
-				msleep(20);
-				CSI_CONFIG = 1;
-			/* exit powerdown state */
-				ov5647_i2c_write_b_sensor(0x0100, 0x01);
-			}
-			CDBG("CAMERA_DBG: 0x4800 regVal:0x04\r\n");
-			/* streaming on */
-			ov5647_i2c_write_b_sensor(0x4800, 0x04);
-			msleep(266);
-			ov5647_start_stream();
-			msleep(30);
-	}
-	return rc;
-}
-
-static int32_t ov5647_video_config(int mode)
-{
-	int32_t rc = 0;
-	int rt;
-	CDBG("video config\n");
-	/* change sensor resolution if needed */
-	if (ov5647_ctrl->prev_res == QTR_SIZE)
-		rt = RES_PREVIEW;
-	else
-		rt = RES_CAPTURE;
-	if (ov5647_sensor_setting(UPDATE_PERIODIC, rt) < 0)
-		return rc;
-	if (ov5647_ctrl->set_test) {
-		if (ov5647_test(ov5647_ctrl->set_test) < 0)
-			return  rc;
-	}
-
-	ov5647_ctrl->curr_res = ov5647_ctrl->prev_res;
-	ov5647_ctrl->sensormode = mode;
-	return rc;
-}
-
-static int32_t ov5647_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-	int rt;
-
-	/*change sensor resolution if needed */
-	if (ov5647_ctrl->curr_res != ov5647_ctrl->pict_res) {
-		if (ov5647_ctrl->pict_res == QTR_SIZE)
-			rt = RES_PREVIEW;
-		else
-			rt = RES_CAPTURE;
-		if (ov5647_sensor_setting(UPDATE_PERIODIC, rt) < 0)
-			return rc;
-	}
-
-	ov5647_ctrl->curr_res = ov5647_ctrl->pict_res;
-	ov5647_ctrl->sensormode = mode;
-	return rc;
-}
-
-static int32_t ov5647_raw_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-	int rt;
-
-	/* change sensor resolution if needed */
-	if (ov5647_ctrl->curr_res != ov5647_ctrl->pict_res) {
-		if (ov5647_ctrl->pict_res == QTR_SIZE)
-			rt = RES_PREVIEW;
-		else
-			rt = RES_CAPTURE;
-		if (ov5647_sensor_setting(UPDATE_PERIODIC, rt) < 0)
-			return rc;
-	}
-
-	ov5647_ctrl->curr_res = ov5647_ctrl->pict_res;
-	ov5647_ctrl->sensormode = mode;
-	return rc;
-}
-
-static int32_t ov5647_set_sensor_mode(int mode,
-		int res)
-{
-	int32_t rc = 0;
-
-	switch (mode) {
-	case SENSOR_PREVIEW_MODE:
-		rc = ov5647_video_config(mode);
-		break;
-	case SENSOR_SNAPSHOT_MODE:
-		rc = ov5647_snapshot_config(mode);
-		break;
-	case SENSOR_RAW_SNAPSHOT_MODE:
-		rc = ov5647_raw_snapshot_config(mode);
-		break;
-	default:
-		rc = -EINVAL;
-		break;
-	}
-	return rc;
-}
-
-static int32_t ov5647_power_down(void)
-{
-	ov5647_stop_stream();
-	return 0;
-}
-
-static int ov5647_probe_init_done(const struct msm_camera_sensor_info *data)
-{
-	CDBG("probe done\n");
-	gpio_direction_output(data->sensor_pwd, 1);
-	return 0;
-}
-
-static int ov5647_probe_init_sensor(const struct msm_camera_sensor_info *data)
-{
-	int32_t rc = 0;
-	uint16_t regaddress1 = 0x300a;
-	uint16_t regaddress2 = 0x300b;
-	uint16_t chipid1 = 0;
-	uint16_t chipid2 = 0;
-
-	CDBG("%s: %d\n", __func__, __LINE__);
-
-	gpio_direction_output(data->sensor_pwd, 0);
-	usleep_range(4000, 4100);
-	gpio_direction_output(data->sensor_reset, 1);
-	usleep_range(2000, 2100);
-
-	ov5647_i2c_read(regaddress1, &chipid1);
-	if (chipid1 != 0x56) {
-		rc = -ENODEV;
-		pr_err("ov5647_probe_init_sensor fail chip id doesnot match\n");
-		goto init_probe_fail;
-	}
-
-	ov5647_i2c_read(regaddress2, &chipid2);
-	if (chipid2 != 0x47) {
-		rc = -ENODEV;
-		pr_err("ov5647_probe_init_sensor fail chip id doesnot match\n");
-		goto init_probe_fail;
-	}
-
-	pr_err("ID1: 0x%x\n", chipid1);
-	pr_err("ID2: 0x%x\n", chipid2);
-	goto init_probe_done;
-
-init_probe_fail:
-	pr_err(" ov5647_probe_init_sensor fails\n");
-	ov5647_probe_init_done(data);
-	return rc;
-init_probe_done:
-	pr_debug(" ov5647_probe_init_sensor finishes\n");
-	gpio_direction_output(data->sensor_pwd, 1);
-	return rc;
-}
-
-
-static int ov5647_sensor_open_init(const struct msm_camera_sensor_info *data)
-{
-	int32_t rc = 0;
-
-	CDBG("%s: %d\n", __func__, __LINE__);
-	CDBG("Calling ov5647_sensor_open_init\n");
-
-	ov5647_ctrl = kzalloc(sizeof(struct ov5647_ctrl_t), GFP_KERNEL);
-	if (!ov5647_ctrl) {
-		CDBG("ov5647_init failed!\n");
-		rc = -ENOMEM;
-		goto init_done;
-	}
-	ov5647_ctrl->fps_divider = 1 * 0x00000400;
-	ov5647_ctrl->pict_fps_divider = 1 * 0x00000400;
-	ov5647_ctrl->set_test = TEST_OFF;
-	ov5647_ctrl->prev_res = QTR_SIZE;
-	ov5647_ctrl->pict_res = FULL_SIZE;
-
-	if (data)
-		ov5647_ctrl->sensordata = data;
-
-	prev_frame_length_lines = 0x3d8;
-
-	prev_line_length_pck = 0x768*2;
-
-	snap_frame_length_lines = 0x7b0;
-
-	snap_line_length_pck = 0xa8c;
-
-	/* enable mclk first */
-	msm_camio_clk_rate_set(OV5647_MASTER_CLK_RATE);
-
-	gpio_direction_output(data->sensor_pwd, 1);
-	gpio_direction_output(data->sensor_reset, 0);
-	usleep_range(10000, 11000);
-	/* power on camera ldo and vreg */
-	if (ov5647_ctrl->sensordata->pmic_gpio_enable)
-		lcd_camera_power_onoff(1);
-	usleep_range(10000, 11000); /*waiting for ldo stable*/
-	gpio_direction_output(data->sensor_pwd, 0);
-	msleep(20);
-	gpio_direction_output(data->sensor_reset, 1);
-	msleep(25);
-
-	CDBG("init settings\n");
-	if (ov5647_ctrl->prev_res == QTR_SIZE)
-		rc = ov5647_sensor_setting(REG_INIT, RES_PREVIEW);
-	else
-		rc = ov5647_sensor_setting(REG_INIT, RES_CAPTURE);
-	ov5647_ctrl->fps = 30 * Q8;
-
-	/* enable AF actuator */
-	if (ov5647_ctrl->sensordata->vcm_enable) {
-		CDBG("enable AF actuator, gpio = %d\n",
-			 ov5647_ctrl->sensordata->vcm_pwd);
-		rc = gpio_request(ov5647_ctrl->sensordata->vcm_pwd,
-						"ov5647_af");
-		if (!rc)
-			gpio_direction_output(
-				ov5647_ctrl->sensordata->vcm_pwd,
-				 1);
-		else {
-			pr_err("ov5647_ctrl gpio request failed!\n");
-			goto init_fail;
-		}
-		msleep(20);
-		rc = ov5647_set_default_focus(0);
-		if (rc < 0) {
-			gpio_direction_output(ov5647_ctrl->sensordata->vcm_pwd,
-								0);
-			gpio_free(ov5647_ctrl->sensordata->vcm_pwd);
-		}
-	}
-	if (rc < 0)
-		goto init_fail;
-	else
-		goto init_done;
-init_fail:
-	CDBG("init_fail\n");
-	ov5647_probe_init_done(data);
-	/* No need to power OFF camera ldo and vreg
-	affects Display while resume */
-init_done:
-	CDBG("init_done\n");
-	return rc;
-}
-
-static int ov5647_i2c_remove(struct i2c_client *client)
-{
-	return 0;
-}
-
-static int ov5647_init_client(struct i2c_client *client)
-{
-	/* Initialize the MSM_CAMI2C Chip */
-	init_waitqueue_head(&ov5647_wait_queue);
-	return 0;
-}
-
-static int ov5647_af_init_client(struct i2c_client *client)
-{
-	/* Initialize the MSM_CAMI2C Chip */
-	init_waitqueue_head(&ov5647_af_wait_queue);
-	return 0;
-}
-
-static const struct i2c_device_id ov5647_af_i2c_id[] = {
-	{"ov5647_af", 0},
-	{ }
-};
-
-static int ov5647_af_i2c_probe(struct i2c_client *client,
-		const struct i2c_device_id *id)
-{
-	int rc = 0;
-	CDBG("ov5647_af_probe called!\n");
-
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		CDBG("i2c_check_functionality failed\n");
-		goto probe_failure;
-	}
-
-	ov5647_af_sensorw = kzalloc(sizeof(struct ov5647_work_t), GFP_KERNEL);
-	if (!ov5647_af_sensorw) {
-		CDBG("kzalloc failed.\n");
-		rc = -ENOMEM;
-		goto probe_failure;
-	}
-
-	i2c_set_clientdata(client, ov5647_af_sensorw);
-	ov5647_af_init_client(client);
-	ov5647_af_client = client;
-
-	msleep(50);
-
-	CDBG("ov5647_af_probe successed! rc = %d\n", rc);
-	return 0;
-
-probe_failure:
-	CDBG("ov5647_af_probe failed! rc = %d\n", rc);
-	return rc;
-}
-
-static const struct i2c_device_id ov5647_i2c_id[] = {
-	{"ov5647", 0}, {}
-};
-
-static int ov5647_i2c_probe(struct i2c_client *client,
-		const struct i2c_device_id *id)
-{
-	int rc = 0;
-	CDBG("ov5647_probe called!\n");
-
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		CDBG("i2c_check_functionality failed\n");
-		goto probe_failure;
-	}
-
-	ov5647_sensorw = kzalloc(sizeof(struct ov5647_work_t), GFP_KERNEL);
-	if (!ov5647_sensorw) {
-		CDBG("kzalloc failed.\n");
-		rc = -ENOMEM;
-		goto probe_failure;
-	}
-
-	i2c_set_clientdata(client, ov5647_sensorw);
-	ov5647_init_client(client);
-	ov5647_client = client;
-
-	msleep(50);
-
-	CDBG("ov5647_probe successed! rc = %d\n", rc);
-	return 0;
-
-probe_failure:
-	CDBG("ov5647_probe failed! rc = %d\n", rc);
-	return rc;
-}
-
-static int __devexit ov5647_remove(struct i2c_client *client)
-{
-	struct ov5647_work_t *sensorw = i2c_get_clientdata(client);
-	free_irq(client->irq, sensorw);
-	ov5647_client = NULL;
-	kfree(sensorw);
-	return 0;
-}
-
-static int __devexit ov5647_af_remove(struct i2c_client *client)
-{
-	struct ov5647_work_t *ov5647_af = i2c_get_clientdata(client);
-	free_irq(client->irq, ov5647_af);
-	ov5647_af_client = NULL;
-	kfree(ov5647_af);
-	return 0;
-}
-
-static struct i2c_driver ov5647_i2c_driver = {
-	.id_table = ov5647_i2c_id,
-	.probe  = ov5647_i2c_probe,
-	.remove = ov5647_i2c_remove,
-	.driver = {
-		.name = "ov5647",
-	},
-};
-
-static struct i2c_driver ov5647_af_i2c_driver = {
-	.id_table = ov5647_af_i2c_id,
-	.probe  = ov5647_af_i2c_probe,
-	.remove = __exit_p(ov5647_af_i2c_remove),
-	.driver = {
-		.name = "ov5647_af",
-	},
-};
-
-int ov5647_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(&ov5647_mut);
-	CDBG("ov5647_sensor_config: cfgtype = %d\n",
-			cdata.cfgtype);
-	switch (cdata.cfgtype) {
-	case CFG_GET_PICT_FPS:
-		ov5647_get_pict_fps(
-			cdata.cfg.gfps.prevfps,
-			&(cdata.cfg.gfps.pictfps));
-
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_GET_PREV_L_PF:
-		cdata.cfg.prevl_pf =
-			ov5647_get_prev_lines_pf();
-
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_GET_PREV_P_PL:
-		cdata.cfg.prevp_pl =
-			ov5647_get_prev_pixels_pl();
-
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_GET_PICT_L_PF:
-		cdata.cfg.pictl_pf =
-			ov5647_get_pict_lines_pf();
-
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_GET_PICT_P_PL:
-		cdata.cfg.pictp_pl =
-			ov5647_get_pict_pixels_pl();
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_GET_PICT_MAX_EXP_LC:
-		cdata.cfg.pict_max_exp_lc =
-			ov5647_get_pict_max_exp_lc();
-
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_SET_FPS:
-	case CFG_SET_PICT_FPS:
-		rc = ov5647_set_fps(&(cdata.cfg.fps));
-		break;
-	case CFG_SET_EXP_GAIN:
-		rc = ov5647_write_exp_gain(cdata.cfg.exp_gain.gain,
-				cdata.cfg.exp_gain.line);
-		break;
-	case CFG_SET_PICT_EXP_GAIN:
-		rc = ov5647_set_pict_exp_gain(cdata.cfg.exp_gain.gain,
-				cdata.cfg.exp_gain.line);
-		break;
-	case CFG_SET_MODE:
-		rc = ov5647_set_sensor_mode(cdata.mode, cdata.rs);
-		break;
-	case CFG_PWR_DOWN:
-		rc = ov5647_power_down();
-		break;
-	case CFG_MOVE_FOCUS:
-		rc = ov5647_move_focus(cdata.cfg.focus.dir,
-				cdata.cfg.focus.steps);
-		break;
-	case CFG_SET_DEFAULT_FOCUS:
-		rc = ov5647_set_default_focus(cdata.cfg.focus.steps);
-		break;
-
-	case CFG_GET_AF_MAX_STEPS:
-		cdata.max_steps = OV5647_TOTAL_STEPS_NEAR_TO_FAR;
-		if (copy_to_user((void *)argp,
-					&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_SET_EFFECT:
-		rc = ov5647_set_default_focus(cdata.cfg.effect);
-		break;
-	default:
-		rc = -EFAULT;
-		break;
-	}
-	mutex_unlock(&ov5647_mut);
-
-	return rc;
-}
-
-static int ov5647_sensor_release(void)
-{
-	int rc = -EBADF;
-	unsigned short rdata;
-
-	mutex_lock(&ov5647_mut);
-	ov5647_power_down();
-	msleep(20);
-	ov5647_i2c_read(0x3018, &rdata);
-	rdata |= 0x18; /*set bit 3 bit 4 to 1*/
-	ov5647_i2c_write_b_sensor(0x3018, rdata);/*write back*/
-	msleep(20);
-
-	gpio_set_value(ov5647_ctrl->sensordata->sensor_pwd, 1);
-	usleep_range(5000, 5100);
-	if (ov5647_ctrl->sensordata->vcm_enable) {
-		gpio_direction_output(ov5647_ctrl->sensordata->vcm_pwd, 0);
-		gpio_free(ov5647_ctrl->sensordata->vcm_pwd);
-	}
-
-	/* No need to power OFF camera ldo and vreg
-	affects Display while resume */
-
-	kfree(ov5647_ctrl);
-	ov5647_ctrl = NULL;
-	CDBG("ov5647_release completed\n");
-	mutex_unlock(&ov5647_mut);
-
-	return rc;
-}
-
-static int ov5647_sensor_probe(const struct msm_camera_sensor_info *info,
-		struct msm_sensor_ctrl *s)
-{
-	int rc = 0;
-
-	CDBG("%s E\n", __func__);
-
-	gpio_direction_output(info->sensor_pwd, 1);
-	gpio_direction_output(info->sensor_reset, 0);
-	usleep_range(1000, 1100);
-	/* turn on ldo and vreg */
-	if (info->pmic_gpio_enable)
-		lcd_camera_power_onoff(1);
-
-	rc = i2c_add_driver(&ov5647_i2c_driver);
-	if (rc < 0 || ov5647_client == NULL) {
-		rc = -ENOTSUPP;
-		CDBG("I2C add driver ov5647 failed");
-		goto probe_fail_2;
-	}
-	if (info->vcm_enable) {
-		rc = i2c_add_driver(&ov5647_af_i2c_driver);
-		if (rc < 0 || ov5647_af_client == NULL) {
-			rc = -ENOTSUPP;
-			CDBG("I2C add driver ov5647 af failed");
-			goto probe_fail_3;
-		}
-	}
-	msm_camio_clk_rate_set(OV5647_MASTER_CLK_RATE);
-
-	rc = ov5647_probe_init_sensor(info);
-	if (rc < 0)
-		goto probe_fail_1;
-
-	s->s_init = ov5647_sensor_open_init;
-	s->s_release = ov5647_sensor_release;
-	s->s_config  = ov5647_sensor_config;
-	s->s_mount_angle = info->sensor_platform_info->mount_angle;
-	gpio_set_value(info->sensor_pwd, 1);
-	ov5647_probe_init_done(info);
-	/* turn off ldo and vreg */
-	if (info->pmic_gpio_enable)
-		lcd_camera_power_onoff(0);
-
-	CDBG("%s X", __func__);
-	return rc;
-
-probe_fail_3:
-	i2c_del_driver(&ov5647_af_i2c_driver);
-probe_fail_2:
-	i2c_del_driver(&ov5647_i2c_driver);
-probe_fail_1:
-	/* turn off ldo and vreg */
-	if (info->pmic_gpio_enable)
-		lcd_camera_power_onoff(0);
-	CDBG("ov5647_sensor_probe: SENSOR PROBE FAILS!\n");
-	CDBG("%s X", __func__);
-	return rc;
-}
-
-static int __devinit ov5647_probe(struct platform_device *pdev)
-{
-	return msm_camera_drv_start(pdev, ov5647_sensor_probe);
-}
-
-static struct platform_driver msm_camera_driver = {
-	.probe = ov5647_probe,
-	.driver = {
-		.name = "msm_camera_ov5647",
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init ov5647_init(void)
-{
-	return platform_driver_register(&msm_camera_driver);
-}
-
-module_init(ov5647_init);
-MODULE_DESCRIPTION("Omnivision 5 MP Bayer sensor driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/ov5647.h b/drivers/media/platform/msm/camera_v1/ov5647.h
deleted file mode 100644
index 0015d63..0000000
--- a/drivers/media/platform/msm/camera_v1/ov5647.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#ifndef OV5647_H
-#define OV5647_H
-#include <linux/types.h>
-#include <mach/board.h>
-
-extern struct ov5647_reg ov5647_regs;
-extern int lcd_camera_power_onoff(int on);
-extern struct rw_semaphore leds_list_lock;
-extern struct list_head leds_list;
-
-struct ov5647_i2c_reg_conf {
-	unsigned short waddr;
-	unsigned short wdata;
-};
-
-enum ov5647_test_mode_t {
-	TEST_OFF,
-	TEST_1,
-	TEST_2,
-	TEST_3
-};
-
-enum ov5647_resolution_t {
-	QTR_SIZE,
-	FULL_SIZE,
-	INVALID_SIZE
-};
-enum ov5647_setting {
-	RES_PREVIEW,
-	RES_CAPTURE
-};
-enum ov5647_reg_update {
-	/* Sensor egisters that need to be updated during initialization */
-	REG_INIT,
-	/* Sensor egisters that needs periodic I2C writes */
-	UPDATE_PERIODIC,
-	/* All the sensor Registers will be updated */
-	UPDATE_ALL,
-	/* Not valid update */
-	UPDATE_INVALID
-};
-
-enum ov5647_reg_pll {
-	E013_VT_PIX_CLK_DIV,
-	E013_VT_SYS_CLK_DIV,
-	E013_PRE_PLL_CLK_DIV,
-	E013_PLL_MULTIPLIER,
-	E013_OP_PIX_CLK_DIV,
-	E013_OP_SYS_CLK_DIV
-};
-
-enum ov5647_reg_mode {
-	E013_X_ADDR_START,
-	E013_X_ADDR_END,
-	E013_Y_ADDR_START,
-	E013_Y_ADDR_END,
-	E013_X_OUTPUT_SIZE,
-	E013_Y_OUTPUT_SIZE,
-	E013_DATAPATH_SELECT,
-	E013_READ_MODE,
-	E013_ANALOG_CONTROL5,
-	E013_DAC_LD_4_5,
-	E013_SCALING_MODE,
-	E013_SCALE_M,
-	E013_LINE_LENGTH_PCK,
-	E013_FRAME_LENGTH_LINES,
-	E013_COARSE_INTEGRATION_TIME,
-	E013_FINE_INTEGRATION_TIME,
-	E013_FINE_CORRECTION
-};
-
-struct ov5647_reg {
-	const struct ov5647_i2c_reg_conf *rec_settings;
-	const unsigned short rec_size;
-	const struct ov5647_i2c_reg_conf *reg_prev;
-	const unsigned short reg_prev_size;
-	const struct ov5647_i2c_reg_conf *reg_snap;
-	const unsigned short reg_snap_size;
-};
-#endif /* OV5647_H */
diff --git a/drivers/media/platform/msm/camera_v1/ov5647_reg.c b/drivers/media/platform/msm/camera_v1/ov5647_reg.c
deleted file mode 100644
index c9709bf..0000000
--- a/drivers/media/platform/msm/camera_v1/ov5647_reg.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-
-#include "ov5647.h"
-struct ov5647_i2c_reg_conf ov5647_prev_settings[] = {
-	/*1280*960 Reference Setting 24M MCLK 2lane 280Mbps/lane 30fps
-	for back to preview*/
-	{0x3035, 0x21},
-	{0x3036, 0x37},
-	{0x3821, 0x07},
-	{0x3820, 0x41},
-	{0x3612, 0x09},
-	{0x3618, 0x00},
-	{0x380c, 0x07},
-	{0x380d, 0x68},
-	{0x380e, 0x03},
-	{0x380f, 0xd8},
-	{0x3814, 0x31},
-	{0x3815, 0x31},
-	{0x3709, 0x52},
-	{0x3808, 0x05},
-	{0x3809, 0x00},
-	{0x380a, 0x03},
-	{0x380b, 0xc0},
-	{0x3800, 0x00},
-	{0x3801, 0x18},
-	{0x3802, 0x00},
-	{0x3803, 0x0e},
-	{0x3804, 0x0a},
-	{0x3805, 0x27},
-	{0x3806, 0x07},
-	{0x3807, 0x95},
-	{0x4004, 0x02},
-};
-
-struct ov5647_i2c_reg_conf ov5647_snap_settings[] = {
-	/*2608*1952 Reference Setting 24M MCLK 2lane 280Mbps/lane 30fps*/
-	{0x3035, 0x21},
-	{0x3036, 0x4f},
-	{0x3821, 0x06},
-	{0x3820, 0x00},
-	{0x3612, 0x0b},
-	{0x3618, 0x04},
-	{0x380c, 0x0a},
-	{0x380d, 0x8c},
-	{0x380e, 0x07},
-	{0x380f, 0xb0},
-	{0x3814, 0x11},
-	{0x3815, 0x11},
-	{0x3709, 0x12},
-	{0x3808, 0x0a},
-	{0x3809, 0x30},
-	{0x380a, 0x07},
-	{0x380b, 0xa0},
-	{0x3800, 0x00},
-	{0x3801, 0x04},
-	{0x3802, 0x00},
-	{0x3803, 0x00},
-	{0x3804, 0x0a},
-	{0x3805, 0x3b},
-	{0x3806, 0x07},
-	{0x3807, 0xa3},
-	{0x4004, 0x04},
-};
-
-struct ov5647_i2c_reg_conf ov5647_recommend_settings[] = {
-	{0x3035, 0x11},
-	{0x303c, 0x11},
-	{0x370c, 0x03},
-	{0x5000, 0x06},
-	{0x5003, 0x08},
-	{0x5a00, 0x08},
-	{0x3000, 0xff},
-	{0x3001, 0xff},
-	{0x3002, 0xff},
-	{0x301d, 0xf0},
-	{0x3a18, 0x00},
-	{0x3a19, 0xf8},
-	{0x3c01, 0x80},
-	{0x3b07, 0x0c},
-	{0x3708, 0x64},
-	{0x3630, 0x2e},
-	{0x3632, 0xe2},
-	{0x3633, 0x23},
-	{0x3634, 0x44},
-	{0x3620, 0x64},
-	{0x3621, 0xe0},
-	{0x3600, 0x37},
-	{0x3704, 0xa0},
-	{0x3703, 0x5a},
-	{0x3715, 0x78},
-	{0x3717, 0x01},
-	{0x3731, 0x02},
-	{0x370b, 0x60},
-	{0x3705, 0x1a},
-	{0x3f05, 0x02},
-	{0x3f06, 0x10},
-	{0x3f01, 0x0a},
-	{0x3a08, 0x01},
-	{0x3a0f, 0x58},
-	{0x3a10, 0x50},
-	{0x3a1b, 0x58},
-	{0x3a1e, 0x50},
-	{0x3a11, 0x60},
-	{0x3a1f, 0x28},
-	{0x4001, 0x02},
-	{0x4000, 0x09},
-	{0x3000, 0x00},
-	{0x3001, 0x00},
-	{0x3002, 0x00},
-	{0x3017, 0xe0},
-	{0x301c, 0xfc},
-	{0x3636, 0x06},
-	{0x3016, 0x08},
-	{0x3827, 0xec},
-	{0x3018, 0x44},
-	{0x3035, 0x21},
-	{0x3106, 0xf5},
-	{0x3034, 0x18},
-	{0x301c, 0xf8},
-	/*lens setting*/
-	{0x5000, 0x86},
-	{0x5800, 0x11},
-	{0x5801, 0x0c},
-	{0x5802, 0x0a},
-	{0x5803, 0x0b},
-	{0x5804, 0x0d},
-	{0x5805, 0x13},
-	{0x5806, 0x09},
-	{0x5807, 0x05},
-	{0x5808, 0x03},
-	{0x5809, 0x03},
-	{0x580a, 0x06},
-	{0x580b, 0x08},
-	{0x580c, 0x05},
-	{0x580d, 0x01},
-	{0x580e, 0x00},
-	{0x580f, 0x00},
-	{0x5810, 0x02},
-	{0x5811, 0x06},
-	{0x5812, 0x05},
-	{0x5813, 0x01},
-	{0x5814, 0x00},
-	{0x5815, 0x00},
-	{0x5816, 0x02},
-	{0x5817, 0x06},
-	{0x5818, 0x09},
-	{0x5819, 0x05},
-	{0x581a, 0x04},
-	{0x581b, 0x04},
-	{0x581c, 0x06},
-	{0x581d, 0x09},
-	{0x581e, 0x11},
-	{0x581f, 0x0c},
-	{0x5820, 0x0b},
-	{0x5821, 0x0b},
-	{0x5822, 0x0d},
-	{0x5823, 0x13},
-	{0x5824, 0x22},
-	{0x5825, 0x26},
-	{0x5826, 0x26},
-	{0x5827, 0x24},
-	{0x5828, 0x24},
-	{0x5829, 0x24},
-	{0x582a, 0x22},
-	{0x582b, 0x20},
-	{0x582c, 0x22},
-	{0x582d, 0x26},
-	{0x582e, 0x22},
-	{0x582f, 0x22},
-	{0x5830, 0x42},
-	{0x5831, 0x22},
-	{0x5832, 0x02},
-	{0x5833, 0x24},
-	{0x5834, 0x22},
-	{0x5835, 0x22},
-	{0x5836, 0x22},
-	{0x5837, 0x26},
-	{0x5838, 0x42},
-	{0x5839, 0x26},
-	{0x583a, 0x06},
-	{0x583b, 0x26},
-	{0x583c, 0x24},
-	{0x583d, 0xce},
-	/* manual AWB,manual AE,close Lenc,open WBC*/
-	{0x3503, 0x03}, /*manual AE*/
-	{0x3501, 0x10},
-	{0x3502, 0x80},
-	{0x350a, 0x00},
-	{0x350b, 0x7f},
-	{0x5001, 0x01}, /*manual AWB*/
-	{0x5180, 0x08},
-	{0x5186, 0x04},
-	{0x5187, 0x00},
-	{0x5188, 0x04},
-	{0x5189, 0x00},
-	{0x518a, 0x04},
-	{0x518b, 0x00},
-	{0x5000, 0x06}, /*No lenc,WBC on*/
-};
-
-struct ov5647_reg ov5647_regs = {
-	.rec_settings = &ov5647_recommend_settings[0],
-	.rec_size = ARRAY_SIZE(ov5647_recommend_settings),
-	.reg_prev = &ov5647_prev_settings[0],
-	.reg_prev_size = ARRAY_SIZE(ov5647_prev_settings),
-	.reg_snap = &ov5647_snap_settings[0],
-	.reg_snap_size = ARRAY_SIZE(ov5647_snap_settings),
-};
diff --git a/drivers/media/platform/msm/camera_v1/ov7692.c b/drivers/media/platform/msm/camera_v1/ov7692.c
deleted file mode 100644
index 252d42c..0000000
--- a/drivers/media/platform/msm/camera_v1/ov7692.c
+++ /dev/null
@@ -1,597 +0,0 @@
-/* Copyright (c) 2010-2011, The Linux Foundation. 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.
- */
-
-#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 "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
-
-/*============================================================================
-							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},
-    {0x80, 0x7f},
-    {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;
-	CDBG("i2c_write_b addr = 0x%x, val = 0x%x\n", waddr, 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;
-	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(10);
-			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;
-
-	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 int32_t ov7692_power_down(void)
-{
-	return 0;
-}
-
-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;
-	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);
-
-	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:
-		rc = ov7692_power_down();
-		break;
-	case CFG_SET_EFFECT:
-		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_power_down();
-	kfree(ov7692_ctrl);
-	ov7692_ctrl = NULL;
-	CDBG("ov7692_release completed\n");
-	mutex_unlock(&ov7692_mut);
-
-	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;
-	}
-	msm_camio_clk_rate_set(24000000);
-	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 = 0;
-	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/media/platform/msm/camera_v1/ov7692.h b/drivers/media/platform/msm/camera_v1/ov7692.h
deleted file mode 100644
index da98284..0000000
--- a/drivers/media/platform/msm/camera_v1/ov7692.h
+++ /dev/null
@@ -1,666 +0,0 @@
-/* Copyright (c) 2010, 2012, The Linux Foundation. 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.
- */
-#ifndef OV7692_H
-#define OV7692_H
-#include <linux/types.h>
-#include <mach/board.h>
-
-#define INVMASK(v)  (0xff-v)
-#define OV7692Core_WritePREG(pTbl)  OV7692_WritePRegs \
-			(pTbl, sizeof(pTbl)/sizeof(pTbl[0]))
-
-extern int lcd_camera_power_onoff(int on);
-struct reg_addr_val_pair_struct {
-	uint8_t	reg_addr;
-	uint8_t	reg_val;
-};
-
-enum ov7692_test_mode_t {
-	TEST_OFF,
-	TEST_1,
-	TEST_2,
-	TEST_3
-};
-
-enum ov7692_resolution_t {
-	QTR_SIZE,
-	FULL_SIZE,
-	INVALID_SIZE
-};
-
-enum ov7692_setting {
-	RES_PREVIEW,
-	RES_CAPTURE
-};
-enum ov7692_reg_update {
-	/* Sensor egisters that need to be updated during initialization */
-	REG_INIT,
-	/* Sensor egisters that needs periodic I2C writes */
-	UPDATE_PERIODIC,
-	/* All the sensor Registers will be updated */
-	UPDATE_ALL,
-	/* Not valid update */
-	UPDATE_INVALID
-};
-
-/*OV SENSOR SCCB*/
-struct OV7692_WREG {
-	uint8_t addr;
-	uint8_t data;
-	uint8_t mask;
-} OV7692_WREG;
-
-#ifdef CONFIG_WEBCAM_OV7692_QRD
-/*  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},
-};
-#endif
-/* Exposure Compensation */
-struct OV7692_WREG ov7692_exposure_compensation_lv0_tbl[] = {
-	/*@@ +1.7EV*/
-	{0x24, 0xc0},
-	{0x25, 0xb8},
-	{0x26, 0xe6},
-};
-
-struct OV7692_WREG ov7692_exposure_compensation_lv1_tbl[] = {
-	/*@@ +1.0EV*/
-	{0x24, 0xa8},
-	{0x25, 0xa0},
-	{0x26, 0xc4},
-};
-
-struct OV7692_WREG ov7692_exposure_compensation_lv2_default_tbl[] = {
-	/*@@ default*/
-	{0x24, 0x86},
-	{0x25, 0x76},
-	{0x26, 0xb3},
-};
-
-struct OV7692_WREG ov7692_exposure_compensation_lv3_tbl[] = {
-	/*@@ -1.0EV*/
-	{0x24, 0x70},
-	{0x25, 0x60},
-	{0x26, 0xa2},
-};
-
-struct OV7692_WREG ov7692_exposure_compensation_lv4_tbl[] = {
-	/*@@ -1.7EV*/
-	{0x24, 0x50},
-	{0x25, 0x40},
-	{0x26, 0xa2},
-};
-
-struct OV7692_WREG ov7692_antibanding_off_tbl[] = {
-	{0x13, 0xE5, INVMASK(0x20)},
-};
-
-struct OV7692_WREG ov7692_antibanding_auto_tbl[] = {
-	{0x13, 0x20, INVMASK(0x20)},
-	{0x14, 0x14, INVMASK(0x17)},
-};
-
-struct OV7692_WREG ov7692_antibanding_50z_tbl[] = {
-	/*Band 50Hz*/
-	{0x13, 0x20, INVMASK(0x20)},
-	{0x14, 0x17, INVMASK(0x17)},
-};
-
-struct OV7692_WREG ov7692_antibanding_60z_tbl[] = {
-	/*Band 60Hz*/
-	{0x13, 0x20, INVMASK(0x20)},
-	{0x14, 0x16, INVMASK(0x17)},
-};
-
-/*Saturation*/
-struct OV7692_WREG ov7692_saturation_lv0_tbl[] = {
-	/*Saturation level 0*/
-	{0x81, 0x33, INVMASK(0x33)},
-	{0xd8, 0x00, INVMASK(0xff)},
-	{0xd9, 0x00, INVMASK(0xff)},
-	{0xd2, 0x02, INVMASK(0xff)},
-};
-
-struct OV7692_WREG ov7692_saturation_lv1_tbl[] = {
-	/*Saturation level 1*/
-	{0x81, 0x33, INVMASK(0x33)},
-	{0xd8, 0x10, INVMASK(0xff)},
-	{0xd9, 0x10, INVMASK(0xff)},
-	{0xd2, 0x02, INVMASK(0xff)},
-};
-
-struct OV7692_WREG ov7692_saturation_lv2_tbl[] = {
-	/*Saturation level 2*/
-	{0x81, 0x33, INVMASK(0x33)},
-	{0xd8, 0x20, INVMASK(0xff)},
-	{0xd9, 0x20, INVMASK(0xff)},
-	{0xd2, 0x02, INVMASK(0xff)},
-
-};
-
-struct OV7692_WREG ov7692_saturation_lv3_tbl[] = {
-	/*Saturation level 3*/
-	{0x81, 0x33, INVMASK(0x33)},
-	{0xd8, 0x30, INVMASK(0xff)},
-	{0xd9, 0x30, INVMASK(0xff)},
-	{0xd2, 0x02, INVMASK(0xff)},
-
-};
-
-struct OV7692_WREG ov7692_saturation_default_lv4_tbl[] = {
-	/*Saturation level 4 (default)*/
-	{0x81, 0x33, INVMASK(0x33)},
-	{0xd8, 0x40, INVMASK(0xff)},
-	{0xd9, 0x40, INVMASK(0xff)},
-	{0xd2, 0x02, INVMASK(0xff)},
-};
-
-struct OV7692_WREG ov7692_saturation_lv5_tbl[] = {
-	/*Saturation level 5*/
-	{0x81, 0x33, INVMASK(0x33)},
-	{0xd8, 0x50, INVMASK(0xff)},
-	{0xd9, 0x50, INVMASK(0xff)},
-	{0xd2, 0x02, INVMASK(0xff)},
-};
-
-struct OV7692_WREG ov7692_saturation_lv6_tbl[] = {
-	/*Saturation level 6*/
-	{0x81, 0x33, INVMASK(0x33)},
-	{0xd8, 0x60, INVMASK(0xff)},
-	{0xd9, 0x60, INVMASK(0xff)},
-	{0xd2, 0x02, INVMASK(0xff)},
-};
-
-struct OV7692_WREG ov7692_saturation_lv7_tbl[] = {
-	/*Saturation level 7*/
-	{0x81, 0x33, INVMASK(0x33)},
-	{0xd8, 0x70, INVMASK(0xff)},
-	{0xd9, 0x70, INVMASK(0xff)},
-	{0xd2, 0x02, INVMASK(0xff)},
-};
-
-struct OV7692_WREG ov7692_saturation_lv8_tbl[] = {
-	/*Saturation level 8*/
-	{0x81, 0x33, INVMASK(0x33)},
-	{0xd8, 0x80, INVMASK(0xff)},
-	{0xd9, 0x80, INVMASK(0xff)},
-	{0xd2, 0x02, INVMASK(0xff)},
-};
-
-/*EFFECT*/
-struct OV7692_WREG ov7692_effect_normal_tbl[] = {
-	{0x81, 0x00, INVMASK(0x20)},
-	{0x28, 0x00, },
-	{0xd2, 0x00, },
-	{0xda, 0x80, },
-	{0xdb, 0x80, },
-};
-
-struct OV7692_WREG ov7692_effect_mono_tbl[] = {
-	{0x81, 0x20, INVMASK(0x20)},
-	{0x28, 0x00, },
-	{0xd2, 0x18, },
-	{0xda, 0x80, },
-	{0xdb, 0x80, },
-};
-
-struct OV7692_WREG ov7692_effect_bw_tbl[] = {
-	{0x81, 0x20, INVMASK(0x20)},
-	{0x28, 0x00, },
-	{0xd2, 0x18, },
-	{0xda, 0x80, },
-	{0xdb, 0x80, },
-};
-
-struct OV7692_WREG ov7692_effect_sepia_tbl[] = {
-	{0x81, 0x20, INVMASK(0x20)},
-	{0x28, 0x00, },
-	{0xd2, 0x18, },
-	{0xda, 0x40, },
-	{0xdb, 0xa0, },
-};
-
-struct OV7692_WREG ov7692_effect_bluish_tbl[] = {
-	{0x81, 0x20, INVMASK(0x20)},
-	{0x28, 0x00, },
-	{0xd2, 0x18, },
-	{0xda, 0xc0, },
-	{0xdb, 0x80, },
-};
-
-struct OV7692_WREG ov7692_effect_reddish_tbl[] = {
-	{0x81, 0x20, INVMASK(0x20)},
-	{0x28, 0x00, },
-	{0xd2, 0x18, },
-	{0xda, 0x80, },
-	{0xdb, 0xc0, },
-};
-
-struct OV7692_WREG ov7692_effect_greenish_tbl[] = {
-	{0x81, 0x20, INVMASK(0x20)},
-	{0x28, 0x00, },
-	{0xd2, 0x18, },
-	{0xda, 0x60, },
-	{0xdb, 0x60, },
-};
-
-struct OV7692_WREG ov7692_effect_negative_tbl[] = {
-	{0x81, 0x20, INVMASK(0x20)},
-	{0x28, 0x80, },
-	{0xd2, 0x40, },
-	{0xda, 0x80, },
-	{0xdb, 0x80, },
-};
-
-/*Contrast*/
-struct OV7692_WREG ov7692_contrast_lv0_tbl[] = {
-	/*Contrast -4*/
-	{0xb2, 0x29},
-	{0xa3, 0x55},
-	{0xa4, 0x5b},
-	{0xa5, 0x67},
-	{0xa6, 0x7e},
-	{0xa7, 0x89},
-	{0xa8, 0x93},
-	{0xa9, 0x9c},
-	{0xaa, 0xa4},
-	{0xab, 0xac},
-	{0xac, 0xb3},
-	{0xad, 0xbe},
-	{0xae, 0xc7},
-	{0xaf, 0xd5},
-	{0xb0, 0xdd},
-	{0xb1, 0xe1},
-};
-
-struct OV7692_WREG ov7692_contrast_lv1_tbl[] = {
-	/*Contrast -3*/
-	{0xb2, 0x20},
-	{0xa3, 0x43},
-	{0xa4, 0x4a},
-	{0xa5, 0x58},
-	{0xa6, 0x73},
-	{0xa7, 0x80},
-	{0xa8, 0x8b},
-	{0xa9, 0x96},
-	{0xaa, 0x9f},
-	{0xab, 0xa8},
-	{0xac, 0xb1},
-	{0xad, 0xbe},
-	{0xae, 0xc9},
-	{0xaf, 0xd8},
-	{0xb0, 0xe2},
-	{0xb1, 0xe8},
-};
-
-struct OV7692_WREG ov7692_contrast_lv2_tbl[] = {
-	/*Contrast -2*/
-	{0xb2, 0x18},
-	{0xa3, 0x31},
-	{0xa4, 0x39},
-	{0xa5, 0x4a},
-	{0xa6, 0x68},
-	{0xa7, 0x77},
-	{0xa8, 0x84},
-	{0xa9, 0x90},
-	{0xaa, 0x9b},
-	{0xab, 0xa5},
-	{0xac, 0xaf},
-	{0xad, 0xbe},
-	{0xae, 0xca},
-	{0xaf, 0xdc},
-	{0xb0, 0xe7},
-	{0xb1, 0xee},
-};
-
-struct OV7692_WREG ov7692_contrast_lv3_tbl[] = {
-	/*Contrast -1*/
-	{0xb2, 0x10},
-	{0xa3, 0x1f},
-	{0xa4, 0x28},
-	{0xa5, 0x3b},
-	{0xa6, 0x5d},
-	{0xa7, 0x6e},
-	{0xa8, 0x7d},
-	{0xa9, 0x8a},
-	{0xaa, 0x96},
-	{0xab, 0xa2},
-	{0xac, 0xad},
-	{0xad, 0xbe},
-	{0xae, 0xcc},
-	{0xaf, 0xe0},
-	{0xb0, 0xed},
-	{0xb1, 0xf4},
-};
-
-struct OV7692_WREG ov7692_contrast_default_lv4_tbl[] = {
-	/*Contrast 0*/
-	{0xb2, 0x6},
-	{0xa3, 0xb},
-	{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},
-};
-
-struct OV7692_WREG ov7692_contrast_lv5_tbl[] = {
-	/*Contrast 1*/
-	{0xb2, 0xc},
-	{0xa3, 0x4},
-	{0xa4, 0xc},
-	{0xa5, 0x1f},
-	{0xa6, 0x45},
-	{0xa7, 0x58},
-	{0xa8, 0x6b},
-	{0xa9, 0x7c},
-	{0xaa, 0x8d},
-	{0xab, 0x9d},
-	{0xac, 0xac},
-	{0xad, 0xc3},
-	{0xae, 0xd2},
-	{0xaf, 0xe8},
-	{0xb0, 0xf2},
-	{0xb1, 0xf7},
-};
-
-struct OV7692_WREG ov7692_contrast_lv6_tbl[] = {
-	/*Contrast 2*/
-	{0xb2, 0x1},
-	{0xa3, 0x2},
-	{0xa4, 0x9},
-	{0xa5, 0x1a},
-	{0xa6, 0x3e},
-	{0xa7, 0x4a},
-	{0xa8, 0x59},
-	{0xa9, 0x6a},
-	{0xaa, 0x79},
-	{0xab, 0x8e},
-	{0xac, 0xa4},
-	{0xad, 0xc1},
-	{0xae, 0xdb},
-	{0xaf, 0xf4},
-	{0xb0, 0xff},
-	{0xb1, 0xff},
-};
-
-struct OV7692_WREG ov7692_contrast_lv7_tbl[] = {
-	/*Contrast 3*/
-	{0xb2, 0xc},
-	{0xa3, 0x4},
-	{0xa4, 0x8},
-	{0xa5, 0x17},
-	{0xa6, 0x27},
-	{0xa7, 0x3d},
-	{0xa8, 0x54},
-	{0xa9, 0x60},
-	{0xaa, 0x77},
-	{0xab, 0x85},
-	{0xac, 0xa4},
-	{0xad, 0xc6},
-	{0xae, 0xd2},
-	{0xaf, 0xe9},
-	{0xb0, 0xf0},
-	{0xb1, 0xf7},
-};
-
-struct OV7692_WREG ov7692_contrast_lv8_tbl[] = {
-	/*Contrast 4*/
-	{0xb2, 0x1},
-	{0xa3, 0x4},
-	{0xa4, 0x4},
-	{0xa5, 0x7},
-	{0xa6, 0xb},
-	{0xa7, 0x17},
-	{0xa8, 0x2a},
-	{0xa9, 0x41},
-	{0xaa, 0x59},
-	{0xab, 0x6b},
-	{0xac, 0x8b},
-	{0xad, 0xb1},
-	{0xae, 0xd2},
-	{0xaf, 0xea},
-	{0xb0, 0xf4},
-	{0xb1, 0xff},
-};
-
-	/*Sharpness*/
-struct OV7692_WREG ov7692_sharpness_lv0_tbl[] = {
-	/*Sharpness 0*/
-	{0xb4, 0x20, INVMASK(0x20)},
-	{0xb6, 0x00, INVMASK(0x1f)},
-};
-struct OV7692_WREG ov7692_sharpness_lv1_tbl[] = {
-	/*Sharpness 1*/
-	{0xb4, 0x20, INVMASK(0x20)},
-	{0xb6, 0x01, INVMASK(0x1f)},
-};
-struct OV7692_WREG ov7692_sharpness_default_lv2_tbl[] = {
-	/*Sharpness Auto (Default)*/
-	{0xb4, 0x00, INVMASK(0x20)},
-	{0xb6, 0x00, INVMASK(0x1f)},
-};
-struct OV7692_WREG ov7692_sharpness_lv3_tbl[] = {
-	/*Sharpness 3*/
-	{0xb4, 0x20, INVMASK(0x20)},
-	{0xb6, 0x66, INVMASK(0x04)},
-};
-struct OV7692_WREG ov7692_sharpness_lv4_tbl[] = {
-	/*Sharpness 4*/
-	{0xb4, 0x20, INVMASK(0x20)},
-	{0xb6, 0x99, INVMASK(0x1f)},
-};
-struct OV7692_WREG ov7692_sharpness_lv5_tbl[] = {
-	/*Sharpness 5*/
-	{0xb4, 0x20, INVMASK(0x20)},
-	{0xb6, 0xcc, INVMASK(0x1f)},
-};
-struct OV7692_WREG ov7692_sharpness_lv6_tbl[] = {
-	/*Sharpness 6*/
-	{0xb4, 0x20, INVMASK(0x20)},
-	{0xb6, 0xff, INVMASK(0x1f)},
-};
-
-	/* ISO TYPE*/
-struct OV7692_WREG ov7692_iso_type_auto[] = {
-	/*@@ISO Auto*/
-	{0x14, 0x20, INVMASK(0x70)},
-};
-
-struct OV7692_WREG ov7692_iso_type_100[] = {
-	/*@@ISO 100*/
-	{0x14, 0x00, INVMASK(0x70)},
-};
-
-struct OV7692_WREG ov7692_iso_type_200[] = {
-	/*@@ISO 200*/
-	{0x14, 0x10, INVMASK(0x70)},
-};
-
-struct OV7692_WREG ov7692_iso_type_400[] = {
-	/*@@ISO 400*/
-	{0x14, 0x20, INVMASK(0x70)},
-};
-
-struct OV7692_WREG ov7692_iso_type_800[] = {
-	/*@@ISO 800*/
-	{0x14, 0x30, INVMASK(0x70)},
-};
-
-struct OV7692_WREG ov7692_iso_type_1600[] = {
-	/*@@ISO 1600*/
-	{0x14, 0x40, INVMASK(0x70)},
-};
-
-	/*Light Mode*/
-struct OV7692_WREG ov7692_wb_def[] = {
-	{0x13, 0xf7},
-	{0x15, 0x00},
-};
-
-struct OV7692_WREG ov7692_wb_custom[] = {
-	{0x13, 0xf5},
-	{0x01, 0x56},
-	{0x02, 0x50},
-	{0x15, 0x00},
-};
-
-struct OV7692_WREG ov7692_wb_inc[] = {
-	{0x13, 0xf5},
-	{0x01, 0x66},
-	{0x02, 0x40},
-	{0x15, 0x00},
-};
-
-struct OV7692_WREG ov7692_wb_daylight[] = {
-	{0x13, 0xf5},
-	{0x01, 0x43},
-	{0x02, 0x5d},
-	{0x15, 0x00},
-};
-
-struct OV7692_WREG ov7692_wb_cloudy[] = {
-	{0x13, 0xf5},
-	{0x01, 0x48},
-	{0x02, 0x63},
-	{0x15, 0x00},
-};
-
-#endif
-
diff --git a/drivers/media/platform/msm/camera_v1/ov7692_qrd.c b/drivers/media/platform/msm/camera_v1/ov7692_qrd.c
deleted file mode 100644
index 05a82ab..0000000
--- a/drivers/media/platform/msm/camera_v1/ov7692_qrd.c
+++ /dev/null
@@ -1,1178 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-
-#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
-============================================================================*/
-
-
-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 effect_value;
-static int16_t ov7692_effect = CAMERA_EFFECT_OFF;
-static unsigned int SAT_U = 0x80;
-static unsigned int SAT_V = 0x80;
-
-/*=============================================================*/
-
-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;
-	CDBG("i2c_write_b addr = 0x%x, val = 0x%x\n", waddr, 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_WritePRegs(struct OV7692_WREG *pTb, int32_t len)
-{
-	int32_t i, ret = 0;
-	uint8_t regv;
-
-	for (i = 0; i < len; i++) {
-		if (pTb[i].mask == 0) {
-			ov7692_i2c_write_b_sensor(pTb[i].addr, pTb[i].data);
-		} else {
-			ov7692_i2c_read(pTb[i].addr, &regv, 1);
-			regv &= pTb[i].mask;
-			regv |= (pTb[i].data & (~pTb[i].mask));
-			ov7692_i2c_write_b_sensor(pTb[i].addr, regv);
-		}
-	}
-	return ret;
-}
-
-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;
-
-			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;
-			}
-			usleep_range(10000, 11000);
-			rc = msm_camio_csi_config(&ov7692_csi_params);
-			usleep_range(10000, 11000);
-			ov7692_i2c_write_b_sensor(0x0e, 0x00);
-			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 int ov7692_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 = OV7692Core_WritePREG(
-			ov7692_exposure_compensation_lv0_tbl);
-		break;
-	case CAMERA_EXPOSURE_COMPENSATION_LV1:
-		CDBG("--CAMERA--CAMERA_EXPOSURE_COMPENSATION_LV1\n");
-		rc = OV7692Core_WritePREG(
-			ov7692_exposure_compensation_lv1_tbl);
-		break;
-	case CAMERA_EXPOSURE_COMPENSATION_LV2:
-		CDBG("--CAMERA--CAMERA_EXPOSURE_COMPENSATION_LV2\n");
-		rc = OV7692Core_WritePREG(
-			ov7692_exposure_compensation_lv2_default_tbl);
-		break;
-	case CAMERA_EXPOSURE_COMPENSATION_LV3:
-		CDBG("--CAMERA--CAMERA_EXPOSURE_COMPENSATION_LV3\n");
-		rc = OV7692Core_WritePREG(
-			ov7692_exposure_compensation_lv3_tbl);
-		break;
-	case CAMERA_EXPOSURE_COMPENSATION_LV4:
-		CDBG("--CAMERA--CAMERA_EXPOSURE_COMPENSATION_LV3\n");
-		rc = OV7692Core_WritePREG(
-			ov7692_exposure_compensation_lv4_tbl);
-		break;
-	default:
-		CDBG("--CAMERA--ERROR CAMERA_EXPOSURE_COMPENSATION\n");
-		break;
-	}
-	CDBG("--CAMERA-- %s ...(End)\n", __func__);
-	return rc;
-}
-
-static long ov7692_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 = OV7692Core_WritePREG(ov7692_antibanding_60z_tbl);
-		break;
-	case CAMERA_ANTIBANDING_50HZ:
-		CDBG("--CAMERA--CAMERA_ANTIBANDING_50HZ\n");
-		rc = OV7692Core_WritePREG(ov7692_antibanding_50z_tbl);
-		break;
-	case CAMERA_ANTIBANDING_AUTO:
-		CDBG("--CAMERA--CAMERA_ANTIBANDING_AUTO\n");
-		rc = OV7692Core_WritePREG(ov7692_antibanding_auto_tbl);
-		break;
-	default:
-		CDBG("--CAMERA--CAMERA_ANTIBANDING_ERROR COMMAND\n");
-		break;
-	}
-	CDBG("--CAMERA-- %s ...(End)\n", __func__);
-	return rc;
-}
-
-static int ov7692_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 = OV7692Core_WritePREG(ov7692_saturation_lv0_tbl);
-			break;
-		case CAMERA_SATURATION_LV1:
-			CDBG("--CAMERA--CAMERA_SATURATION_LV1\n");
-			rc = OV7692Core_WritePREG(ov7692_saturation_lv1_tbl);
-			break;
-		case CAMERA_SATURATION_LV2:
-			CDBG("--CAMERA--CAMERA_SATURATION_LV2\n");
-			rc = OV7692Core_WritePREG(ov7692_saturation_lv2_tbl);
-			break;
-		case CAMERA_SATURATION_LV3:
-			CDBG("--CAMERA--CAMERA_SATURATION_LV3\n");
-			rc = OV7692Core_WritePREG(ov7692_saturation_lv3_tbl);
-			break;
-		case CAMERA_SATURATION_LV4:
-			CDBG("--CAMERA--CAMERA_SATURATION_LV4\n");
-			rc = OV7692Core_WritePREG(
-				ov7692_saturation_default_lv4_tbl);
-			break;
-		case CAMERA_SATURATION_LV5:
-			CDBG("--CAMERA--CAMERA_SATURATION_LV5\n");
-			rc = OV7692Core_WritePREG(ov7692_saturation_lv5_tbl);
-			break;
-		case CAMERA_SATURATION_LV6:
-			CDBG("--CAMERA--CAMERA_SATURATION_LV6\n");
-			rc = OV7692Core_WritePREG(ov7692_saturation_lv6_tbl);
-			break;
-		case CAMERA_SATURATION_LV7:
-			CDBG("--CAMERA--CAMERA_SATURATION_LV7\n");
-			rc = OV7692Core_WritePREG(ov7692_saturation_lv7_tbl);
-			break;
-		case CAMERA_SATURATION_LV8:
-			CDBG("--CAMERA--CAMERA_SATURATION_LV8\n");
-			rc = OV7692Core_WritePREG(ov7692_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");
-		SAT_U = 0x00;
-		SAT_V = 0x00;
-		break;
-	case CAMERA_SATURATION_LV1:
-		CDBG("--CAMERA--CAMERA_SATURATION_LV1\n");
-		SAT_U = 0x10;
-		SAT_V = 0x10;
-		break;
-	case CAMERA_SATURATION_LV2:
-		CDBG("--CAMERA--CAMERA_SATURATION_LV2\n");
-		SAT_U = 0x20;
-		SAT_V = 0x20;
-		break;
-	case CAMERA_SATURATION_LV3:
-		CDBG("--CAMERA--CAMERA_SATURATION_LV3\n");
-		SAT_U = 0x30;
-		SAT_V = 0x30;
-		break;
-	case CAMERA_SATURATION_LV4:
-		CDBG("--CAMERA--CAMERA_SATURATION_LV4\n");
-		SAT_U = 0x40;
-		SAT_V = 0x40;
-		break;
-	case CAMERA_SATURATION_LV5:
-		CDBG("--CAMERA--CAMERA_SATURATION_LV5\n");
-		SAT_U = 0x50;
-		SAT_V = 0x50;
-		break;
-	case CAMERA_SATURATION_LV6:
-		CDBG("--CAMERA--CAMERA_SATURATION_LV6\n");
-		SAT_U = 0x60;
-		SAT_V = 0x60;
-		break;
-	case CAMERA_SATURATION_LV7:
-		CDBG("--CAMERA--CAMERA_SATURATION_LV7\n");
-		SAT_U = 0x70;
-		SAT_V = 0x70;
-		break;
-	case CAMERA_SATURATION_LV8:
-		CDBG("--CAMERA--CAMERA_SATURATION_LV8\n");
-		SAT_U = 0x80;
-		SAT_V = 0x80;
-		break;
-	default:
-		CDBG("--CAMERA--CAMERA_SATURATION_ERROR COMMAND\n");
-		break;
-	}
-	CDBG("--CAMERA-- %s ...(End)\n", __func__);
-	return rc;
-}
-
-static long ov7692_set_effect(int mode, int effect)
-{
-	int rc = 0;
-	CDBG("--CAMERA-- %s ...(Start)\n", __func__);
-
-	switch (mode) {
-	case SENSOR_PREVIEW_MODE:
-		break;
-	case SENSOR_HFR_60FPS_MODE:
-		break;
-	case SENSOR_HFR_90FPS_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 = OV7692Core_WritePREG(ov7692_effect_normal_tbl);
-		/* for recover saturation level
-		 when change special effect*/
-		ov7692_i2c_write_b_sensor(0xda, SAT_U);
-		/* for recover saturation level
-		when change special effect*/
-		ov7692_i2c_write_b_sensor(0xdb, SAT_V);
-		break;
-	}
-	case CAMERA_EFFECT_MONO: {
-		CDBG("--CAMERA-- %s ...CAMERA_EFFECT_MONO\n", __func__);
-		rc = OV7692Core_WritePREG(ov7692_effect_mono_tbl);
-		break;
-	}
-	case CAMERA_EFFECT_BW: {
-		CDBG("--CAMERA-- %s ...CAMERA_EFFECT_BW\n", __func__);
-		rc = OV7692Core_WritePREG(ov7692_effect_bw_tbl);
-		break;
-	}
-	case CAMERA_EFFECT_BLUISH: {
-		CDBG("--CAMERA-- %s ...CAMERA_EFFECT_BLUISH\n", __func__);
-		rc = OV7692Core_WritePREG(ov7692_effect_bluish_tbl);
-		break;
-	}
-	case CAMERA_EFFECT_SOLARIZE: {
-		CDBG("%s ...CAMERA_EFFECT_NEGATIVE(No Support)!\n", __func__);
-		break;
-	}
-	case CAMERA_EFFECT_SEPIA: {
-		CDBG("--CAMERA-- %s ...CAMERA_EFFECT_SEPIA\n", __func__);
-		rc = OV7692Core_WritePREG(ov7692_effect_sepia_tbl);
-		break;
-	}
-	case CAMERA_EFFECT_REDDISH: {
-		CDBG("--CAMERA-- %s ...CAMERA_EFFECT_REDDISH\n", __func__);
-		rc = OV7692Core_WritePREG(ov7692_effect_reddish_tbl);
-		break;
-	}
-	case CAMERA_EFFECT_GREENISH: {
-		CDBG("--CAMERA-- %s ...CAMERA_EFFECT_GREENISH\n", __func__);
-		rc = OV7692Core_WritePREG(ov7692_effect_greenish_tbl);
-		break;
-	}
-	case CAMERA_EFFECT_NEGATIVE: {
-		CDBG("--CAMERA-- %s ...CAMERA_EFFECT_NEGATIVE\n", __func__);
-		rc = OV7692Core_WritePREG(ov7692_effect_negative_tbl);
-		break;
-	}
-	default: {
-		CDBG("--CAMERA-- %s ...Default(Not Support)\n", __func__);
-	}
-	}
-	ov7692_effect = effect;
-	/*Refresh Sequencer */
-	CDBG("--CAMERA-- %s ...(End)\n", __func__);
-	return rc;
-}
-
-static int ov7692_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 = OV7692Core_WritePREG(ov7692_contrast_lv0_tbl);
-			break;
-		case CAMERA_CONTRAST_LV1:
-			CDBG("--CAMERA--CAMERA_CONTRAST_LV1\n");
-			rc = OV7692Core_WritePREG(ov7692_contrast_lv1_tbl);
-			break;
-		case CAMERA_CONTRAST_LV2:
-			CDBG("--CAMERA--CAMERA_CONTRAST_LV2\n");
-			rc = OV7692Core_WritePREG(ov7692_contrast_lv2_tbl);
-			break;
-		case CAMERA_CONTRAST_LV3:
-			CDBG("--CAMERA--CAMERA_CONTRAST_LV3\n");
-			rc = OV7692Core_WritePREG(ov7692_contrast_lv3_tbl);
-			break;
-		case CAMERA_CONTRAST_LV4:
-			CDBG("--CAMERA--CAMERA_CONTRAST_LV4\n");
-			rc = OV7692Core_WritePREG(
-				ov7692_contrast_default_lv4_tbl);
-			break;
-		case CAMERA_CONTRAST_LV5:
-			CDBG("--CAMERA--CAMERA_CONTRAST_LV5\n");
-			rc = OV7692Core_WritePREG(ov7692_contrast_lv5_tbl);
-			break;
-		case CAMERA_CONTRAST_LV6:
-			CDBG("--CAMERA--CAMERA_CONTRAST_LV6\n");
-			rc = OV7692Core_WritePREG(ov7692_contrast_lv6_tbl);
-			break;
-		case CAMERA_CONTRAST_LV7:
-			CDBG("--CAMERA--CAMERA_CONTRAST_LV7\n");
-			rc = OV7692Core_WritePREG(ov7692_contrast_lv7_tbl);
-			break;
-		case CAMERA_CONTRAST_LV8:
-			CDBG("--CAMERA--CAMERA_CONTRAST_LV8\n");
-			rc = OV7692Core_WritePREG(ov7692_contrast_lv8_tbl);
-			break;
-		default:
-			CDBG("--CAMERA--CAMERA_CONTRAST_ERROR COMMAND\n");
-			break;
-		}
-	}
-	CDBG("--CAMERA-- %s ...(End)\n", __func__);
-	return rc;
-}
-
-static int ov7692_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 = OV7692Core_WritePREG(ov7692_sharpness_lv0_tbl);
-			break;
-		case CAMERA_SHARPNESS_LV1:
-			CDBG("--CAMERA--CAMERA_SHARPNESS_LV1\n");
-			rc = OV7692Core_WritePREG(ov7692_sharpness_lv1_tbl);
-			break;
-		case CAMERA_SHARPNESS_LV2:
-			CDBG("--CAMERA--CAMERA_SHARPNESS_LV2\n");
-			rc = OV7692Core_WritePREG(
-				ov7692_sharpness_default_lv2_tbl);
-			break;
-		case CAMERA_SHARPNESS_LV3:
-			CDBG("--CAMERA--CAMERA_SHARPNESS_LV3\n");
-			rc = OV7692Core_WritePREG(ov7692_sharpness_lv3_tbl);
-			break;
-		case CAMERA_SHARPNESS_LV4:
-			CDBG("--CAMERA--CAMERA_SHARPNESS_LV4\n");
-			rc = OV7692Core_WritePREG(ov7692_sharpness_lv4_tbl);
-			break;
-		case CAMERA_SHARPNESS_LV5:
-			CDBG("--CAMERA--CAMERA_SHARPNESS_LV5\n");
-			rc = OV7692Core_WritePREG(ov7692_sharpness_lv5_tbl);
-			break;
-		case CAMERA_SHARPNESS_LV6:
-			CDBG("--CAMERA--CAMERA_SHARPNESS_LV6\n");
-			rc = OV7692Core_WritePREG(ov7692_sharpness_lv6_tbl);
-			break;
-		default:
-			CDBG("--CAMERA--CAMERA_SHARPNESS_ERROR COMMAND\n");
-			break;
-		}
-	}
-	CDBG("--CAMERA-- %s ...(End)\n", __func__);
-	return rc;
-}
-
-static int ov7692_set_iso(int8_t iso_type)
-{
-	long rc = 0;
-
-	CDBG("--CAMERA-- %s ...(Start)\n", __func__);
-	CDBG("--CAMERA-- %s ...iso_type = %d\n", __func__ , iso_type);
-	switch (iso_type) {
-	case CAMERA_ISO_TYPE_AUTO:
-		CDBG("--CAMERA--CAMERA_ISO_TYPE_AUTO\n");
-		rc = OV7692Core_WritePREG(ov7692_iso_type_auto);
-		break;
-	case CAMEAR_ISO_TYPE_HJR:
-		CDBG("--CAMERA--CAMEAR_ISO_TYPE_HJR\n");
-		rc = OV7692Core_WritePREG(ov7692_iso_type_auto);
-		break;
-	case CAMEAR_ISO_TYPE_100:
-		CDBG("--CAMERA--CAMEAR_ISO_TYPE_100\n");
-		rc = OV7692Core_WritePREG(ov7692_iso_type_100);
-		break;
-	case CAMERA_ISO_TYPE_200:
-		CDBG("--CAMERA--CAMERA_ISO_TYPE_200\n");
-		rc = OV7692Core_WritePREG(ov7692_iso_type_200);
-		break;
-	case CAMERA_ISO_TYPE_400:
-		CDBG("--CAMERA--CAMERA_ISO_TYPE_400\n");
-		rc = OV7692Core_WritePREG(ov7692_iso_type_400);
-		break;
-	case CAMEAR_ISO_TYPE_800:
-		CDBG("--CAMERA--CAMEAR_ISO_TYPE_800\n");
-		rc = OV7692Core_WritePREG(ov7692_iso_type_800);
-		break;
-	case CAMERA_ISO_TYPE_1600:
-		CDBG("--CAMERA--CAMERA_ISO_TYPE_1600\n");
-		rc = OV7692Core_WritePREG(ov7692_iso_type_1600);
-		break;
-	default:
-		CDBG("--CAMERA--ERROR ISO TYPE\n");
-		break;
-	}
-	CDBG("--CAMERA-- %s ...(End)\n", __func__);
-	return rc;
-}
-
-static int ov7692_set_wb_oem(uint8_t param)
-{
-	int rc = 0;
-	CDBG("--CAMERA--%s runs\r\n", __func__);
-
-	switch (param) {
-	case CAMERA_WB_AUTO:
-		CDBG("--CAMERA--CAMERA_WB_AUTO\n");
-		rc = OV7692Core_WritePREG(ov7692_wb_def);
-		break;
-	case CAMERA_WB_CUSTOM:
-		CDBG("--CAMERA--CAMERA_WB_CUSTOM\n");
-		rc = OV7692Core_WritePREG(ov7692_wb_custom);
-		break;
-	case CAMERA_WB_INCANDESCENT:
-		CDBG("--CAMERA--CAMERA_WB_INCANDESCENT\n");
-		rc = OV7692Core_WritePREG(ov7692_wb_inc);
-		break;
-	case CAMERA_WB_DAYLIGHT:
-		CDBG("--CAMERA--CAMERA_WB_DAYLIGHT\n");
-		rc = OV7692Core_WritePREG(ov7692_wb_daylight);
-		break;
-	case CAMERA_WB_CLOUDY_DAYLIGHT:
-		CDBG("--CAMERA--CAMERA_WB_CLOUDY_DAYLIGHT\n");
-		rc = OV7692Core_WritePREG(ov7692_wb_cloudy);
-		break;
-	default:
-		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*/
-	usleep_range(5000, 5100);
-	gpio_set_value(ov7692_reset_gpio, 0);
-	usleep_range(5000, 5100);
-	gpio_set_value(ov7692_reset_gpio, 1);
-	usleep_range(1000, 1100);
-	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;
-	/* turn on LDO for PVT */
-	if (data->pmic_gpio_enable)
-		lcd_camera_power_onoff(1);
-
-	/* enable mclk first */
-
-	msm_camio_clk_rate_set(24000000);
-	msleep(20);
-
-	ov7692_power_on();
-	usleep_range(5000, 5100);
-
-	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");
-	if (data->pmic_gpio_enable)
-		lcd_camera_power_onoff(0);
-	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_SET_EFFECT:
-		CDBG("--CAMERA-- CFG_SET_EFFECT mode=%d, effect = %d !!\n",
-			 cdata.mode, cdata.cfg.effect);
-		rc = ov7692_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 !!\n");
-		ov7692_power_down();
-		break;
-	case CFG_WRITE_EXPOSURE_GAIN:
-		CDBG("--CAMERA-- CFG_WRITE_EXPOSURE_GAIN (Not Support) !!\n");
-		/* Not Support */
-		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_REGISTER_TO_REAL_GAIN:
-		CDBG("--CAMERA-- CFG_REGISTER_TO_REAL_GAIN (Not Support) !!\n");
-		/* Not Support */
-		break;
-	case CFG_REAL_TO_REGISTER_GAIN:
-		CDBG("--CAMERA-- CFG_REAL_TO_REGISTER_GAIN (Not Support) !!\n");
-		/* Not Support */
-		break;
-	case CFG_SET_FPS:
-		CDBG("--CAMERA-- CFG_SET_FPS (Not Support) !!\n");
-		/* Not Support */
-		break;
-	case CFG_SET_PICT_FPS:
-		CDBG("--CAMERA-- CFG_SET_PICT_FPS (Not Support) !!\n");
-		/* Not Support */
-		break;
-	case CFG_SET_BRIGHTNESS:
-		CDBG("--CAMERA-- CFG_SET_BRIGHTNESS  !!\n");
-		/* rc = ov7692_set_brightness(cdata.cfg.brightness); */
-		break;
-	case CFG_SET_CONTRAST:
-		CDBG("--CAMERA-- CFG_SET_CONTRAST  !!\n");
-		rc = ov7692_set_contrast(cdata.cfg.contrast);
-		break;
-	case CFG_SET_ZOOM:
-		CDBG("--CAMERA-- CFG_SET_ZOOM (Not Support) !!\n");
-		/* Not Support */
-		break;
-	case CFG_SET_EXPOSURE_MODE:
-		CDBG("--CAMERA-- CFG_SET_EXPOSURE_MODE !!\n");
-		/* rc = ov7692_set_exposure_mode(cdata.cfg.ae_mode); */
-		break;
-	case CFG_SET_WB:
-		CDBG("--CAMERA-- CFG_SET_WB!!\n");
-		ov7692_set_wb_oem(cdata.cfg.wb_val);
-		rc = 0 ;
-		break;
-	case CFG_SET_ANTIBANDING:
-		CDBG("--CAMERA-- CFG_SET_ANTIBANDING antibanding = %d !!\n",
-			 cdata.cfg.antibanding);
-		rc = ov7692_set_antibanding(cdata.cfg.antibanding);
-		break;
-	case CFG_SET_EXP_GAIN:
-		CDBG("--CAMERA-- CFG_SET_EXP_GAIN (Not Support) !!\n");
-		/* Not Support */
-		break;
-	case CFG_SET_PICT_EXP_GAIN:
-		CDBG("--CAMERA-- CFG_SET_PICT_EXP_GAIN (Not Support) !!\n");
-		/* Not Support */
-		break;
-	case CFG_SET_LENS_SHADING:
-		CDBG("--CAMERA-- CFG_SET_LENS_SHADING !!\n");
-		/* rc = ov7692_lens_shading_enable(cdata.cfg.lens_shading); */
-		break;
-	case CFG_GET_PICT_FPS:
-		CDBG("--CAMERA-- CFG_GET_PICT_FPS (Not Support) !!\n");
-		/* Not Support */
-		break;
-	case CFG_GET_PREV_L_PF:
-		CDBG("--CAMERA-- CFG_GET_PREV_L_PF (Not Support) !!\n");
-		/* Not Support */
-		break;
-	case CFG_GET_PREV_P_PL:
-		CDBG("--CAMERA-- CFG_GET_PREV_P_PL (Not Support) !!\n");
-		/* Not Support */
-		break;
-	case CFG_GET_PICT_L_PF:
-		CDBG("--CAMERA-- CFG_GET_PICT_L_PF (Not Support) !!\n");
-		/* Not Support */
-		break;
-	case CFG_GET_PICT_P_PL:
-		CDBG("--CAMERA-- CFG_GET_PICT_P_PL (Not Support) !!\n");
-		/* Not Support */
-		break;
-	case CFG_GET_AF_MAX_STEPS:
-		CDBG("--CAMERA-- CFG_GET_AF_MAX_STEPS (Not Support) !!\n");
-		/* Not Support */
-		break;
-	case CFG_GET_PICT_MAX_EXP_LC:
-		CDBG("--CAMERA-- CFG_GET_PICT_MAX_EXP_LC (Not Support) !!\n");
-		/* Not Support */
-		break;
-	case CFG_SEND_WB_INFO:
-		CDBG("--CAMERA-- CFG_SEND_WB_INFO (Not Support) !!\n");
-		/* Not Support */
-		break;
-	case CFG_SENSOR_INIT:
-		CDBG("--CAMERA-- CFG_SENSOR_INIT (Not Support) !!\n");
-		/* Not Support */
-		break;
-	case CFG_SET_SATURATION:
-		CDBG("--CAMERA-- CFG_SET_SATURATION !!\n");
-		rc = ov7692_set_saturation(cdata.cfg.saturation);
-		break;
-	case CFG_SET_SHARPNESS:
-		CDBG("--CAMERA-- CFG_SET_SHARPNESS !!\n");
-		rc = ov7692_set_sharpness(cdata.cfg.sharpness);
-		break;
-	case CFG_SET_TOUCHAEC:
-		CDBG("--CAMERA-- CFG_SET_TOUCHAEC!!\n");
-		/* ov7692_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 (Not Support) !!\n");
-		/* Not Support */
-		break;
-	case CFG_SET_AUTOFLASH:
-		CDBG("--CAMERA-- CFG_SET_AUTOFLASH (Not Support) !!\n");
-		/* Not Support */
-		break;
-	case CFG_SET_EXPOSURE_COMPENSATION:
-		CDBG("--CAMERA-- CFG_SET_EXPOSURE_COMPENSATION !\n");
-		rc = ov7692_set_exposure_compensation(
-			cdata.cfg.exp_compensation);
-		break;
-	case CFG_SET_ISO:
-		CDBG("--CAMERA-- CFG_SET_ISO !\n");
-		rc = ov7692_set_iso(cdata.cfg.iso_type);
-		break;
-	default:
-		CDBG("--CAMERA-- %s: Command=%d (Not Implement) !!\n",
-			 __func__, cdata.cfgtype);
-		rc = -EINVAL;
-		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;
-	}
-	pr_debug("%s: %d Entered\n", __func__, __LINE__);
-	rc = ov7692_probe_init_gpio(info);
-	if (rc < 0) {
-		CDBG("%s: gpio init failed\n", __func__);
-		goto probe_fail;
-	}
-	/* turn on LDO for PVT */
-	if (info->pmic_gpio_enable)
-		lcd_camera_power_onoff(1);
-
-	ov7692_power_down();
-
-	msm_camio_clk_rate_set(24000000);
-	usleep_range(5000, 5100);
-
-	ov7692_power_on();
-	usleep_range(5000, 5100);
-
-	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_sw_reset(); */
-	ov7692_power_down();
-
-	if (info->pmic_gpio_enable)
-		lcd_camera_power_onoff(0);
-
-	return rc;
-
-probe_fail:
-	CDBG("ov7692_sensor_probe: SENSOR PROBE FAILS!\n");
-	if (info->pmic_gpio_enable)
-		lcd_camera_power_onoff(0);
-	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/media/platform/msm/camera_v1/ov9726.c b/drivers/media/platform/msm/camera_v1/ov9726.c
deleted file mode 100644
index 96a084c..0000000
--- a/drivers/media/platform/msm/camera_v1/ov9726.c
+++ /dev/null
@@ -1,794 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- */
-
-#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/gpio.h>
-#include <mach/camera.h>
-#include "ov9726.h"
-
-/*=============================================================
-	SENSOR REGISTER DEFINES
-==============================================================*/
-#define OV9726_Q8				0x00000100
-#define OV9726_Q8Shift				8
-#define OV9726_Q10				0x00000400
-#define OV9726_Q10Shift				10
-
-/* Omnivision8810 product ID register address */
-#define	OV9726_PIDH_REG				0x0000
-#define	OV9726_PIDL_REG				0x0001
-/* Omnivision8810 product ID */
-#define	OV9726_PID				0x97
-/* Omnivision8810 version */
-#define	OV9726_VER				0x26
-/* Time in milisecs for waiting for the sensor to reset */
-#define	OV9726_RESET_DELAY_MSECS		66
-#define	OV9726_DEFAULT_CLOCK_RATE		24000000
-/* Registers*/
-#define	OV9726_GAIN				0x3000
-#define	OV9726_AEC_MSB				0x3002
-#define	OV9726_AEC_LSB				0x3003
-
-/* Color bar pattern selection */
-#define OV9726_COLOR_BAR_PATTERN_SEL_REG	0x600
-/* Color bar enabling control */
-#define OV9726_COLOR_BAR_ENABLE_REG		0x601
-/* Time in milisecs for waiting for the sensor to reset*/
-#define OV9726_RESET_DELAY_MSECS		66
-/* I2C Address of the Sensor */
-/*============================================================================
-		DATA DECLARATIONS
-============================================================================*/
-#define OV9726_FULL_SIZE_DUMMY_PIXELS		0
-#define OV9726_FULL_SIZE_DUMMY_LINES		0
-#define OV9726_QTR_SIZE_DUMMY_PIXELS		0
-#define OV9726_QTR_SIZE_DUMMY_LINES		0
-
-#define OV9726_FULL_SIZE_WIDTH			1296
-#define OV9726_FULL_SIZE_HEIGHT			808
-
-#define OV9726_QTR_SIZE_WIDTH			1296
-#define OV9726_QTR_SIZE_HEIGHT			808
-
-#define OV9726_HRZ_FULL_BLK_PIXELS		368
-#define OV9726_VER_FULL_BLK_LINES		32
-#define OV9726_HRZ_QTR_BLK_PIXELS		368
-#define OV9726_VER_QTR_BLK_LINES		32
-
-#define OV9726_MSB_MASK			0xFF00
-#define OV9726_LSB_MASK			0x00FF
-
-struct ov9726_work_t {
-	struct work_struct work;
-};
-static struct ov9726_work_t *ov9726_sensorw;
-static struct i2c_client *ov9726_client;
-struct ov9726_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 */
-	uint16_t fps;
-	int16_t curr_lens_pos;
-	uint16_t curr_step_pos;
-	uint16_t my_reg_gain;
-	uint32_t my_reg_line_count;
-	uint16_t total_lines_per_frame;
-	enum ov9726_resolution_t prev_res;
-	enum ov9726_resolution_t pict_res;
-	enum ov9726_resolution_t curr_res;
-	enum ov9726_test_mode_t  set_test;
-	unsigned short imgaddr;
-};
-static struct ov9726_ctrl_t *ov9726_ctrl;
-static int8_t config_not_set = 1;
-static DECLARE_WAIT_QUEUE_HEAD(ov9726_wait_queue);
-DEFINE_MUTEX(ov9726_mut);
-
-/*=============================================================*/
-static int ov9726_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(ov9726_client->adapter, msgs, 2) < 0) {
-		CDBG("ov9726_i2c_rxdata failed!\n");
-		return -EIO;
-	}
-
-	return 0;
-}
-
-static int32_t ov9726_i2c_txdata(unsigned short saddr,
-				unsigned char *txdata, int length)
-{
-	struct i2c_msg msg[] = {
-		{
-		 .addr = saddr ,
-		 .flags = 0,
-		 .len = length,
-		 .buf = txdata,
-		 },
-	};
-
-	if (i2c_transfer(ov9726_client->adapter, msg, 1) < 0) {
-		CDBG("ov9726_i2c_txdata faild 0x%x\n", ov9726_client->addr);
-		return -EIO;
-	}
-
-	return 0;
-}
-
-static int32_t ov9726_i2c_read(unsigned short raddr,
-				unsigned short *rdata, int rlen)
-{
-	int32_t rc = 0;
-	unsigned char buf[2];
-
-	if (!rdata)
-		return -EIO;
-
-	buf[0] = (raddr & OV9726_MSB_MASK) >> 8;
-	buf[1] = (raddr & OV9726_LSB_MASK);
-
-	rc = ov9726_i2c_rxdata(ov9726_client->addr, buf, rlen);
-
-	if (rc < 0) {
-		CDBG("ov9726_i2c_read 0x%x failed!\n", raddr);
-		return rc;
-	}
-
-	*rdata = (rlen == 2 ? buf[0] << 8 | buf[1] : buf[0]);
-	return rc;
-}
-
-static int32_t ov9726_i2c_write_b(unsigned short saddr,
-	unsigned short waddr, uint8_t bdata)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[3];
-
-	buf[0] = (waddr & OV9726_MSB_MASK) >> 8;
-	buf[1] = (waddr & OV9726_LSB_MASK);
-	buf[2] = bdata;
-
-	CDBG("i2c_write_b addr = 0x%x, val = 0x%xd\n", waddr, bdata);
-	rc = ov9726_i2c_txdata(saddr, buf, 3);
-
-	if (rc < 0) {
-		CDBG("i2c_write_b failed, addr = 0x%x, val = 0x%x!\n",
-			 waddr, bdata);
-	}
-
-	return rc;
-}
-
-static void ov9726_get_pict_fps(uint16_t fps, uint16_t *pfps)
-{
-	uint32_t divider;	/*Q10 */
-	uint32_t d1;
-	uint32_t d2;
-	uint16_t snapshot_height, preview_height, preview_width, snapshot_width;
-	if (ov9726_ctrl->prev_res == QTR_SIZE) {
-		preview_width = OV9726_QTR_SIZE_WIDTH +
-			OV9726_HRZ_QTR_BLK_PIXELS ;
-		preview_height = OV9726_QTR_SIZE_HEIGHT +
-			OV9726_VER_QTR_BLK_LINES ;
-	} else {
-		/* full size resolution used for preview. */
-		preview_width = OV9726_FULL_SIZE_WIDTH +
-			OV9726_HRZ_FULL_BLK_PIXELS ;
-		preview_height = OV9726_FULL_SIZE_HEIGHT +
-			OV9726_VER_FULL_BLK_LINES ;
-	}
-	if (ov9726_ctrl->pict_res == QTR_SIZE) {
-		snapshot_width  = OV9726_QTR_SIZE_WIDTH +
-			OV9726_HRZ_QTR_BLK_PIXELS ;
-		snapshot_height = OV9726_QTR_SIZE_HEIGHT +
-			OV9726_VER_QTR_BLK_LINES ;
-	} else {
-		snapshot_width  = OV9726_FULL_SIZE_WIDTH +
-			OV9726_HRZ_FULL_BLK_PIXELS;
-		snapshot_height = OV9726_FULL_SIZE_HEIGHT +
-			OV9726_VER_FULL_BLK_LINES;
-	}
-
-	d1 = (uint32_t)(((uint32_t)preview_height <<
-		OV9726_Q10Shift) /
-		snapshot_height);
-
-	d2 = (uint32_t)(((uint32_t)preview_width <<
-		OV9726_Q10Shift) /
-		 snapshot_width);
-
-	divider = (uint32_t) (d1 * d2) >> OV9726_Q10Shift;
-	*pfps = (uint16_t)((uint32_t)(fps * divider) >> OV9726_Q10Shift);
-}
-
-static uint16_t ov9726_get_prev_lines_pf(void)
-{
-	if (ov9726_ctrl->prev_res == QTR_SIZE)
-		return OV9726_QTR_SIZE_HEIGHT + OV9726_VER_QTR_BLK_LINES;
-	else
-		return OV9726_FULL_SIZE_HEIGHT + OV9726_VER_FULL_BLK_LINES;
-}
-
-static uint16_t ov9726_get_prev_pixels_pl(void)
-{
-	if (ov9726_ctrl->prev_res == QTR_SIZE)
-		return OV9726_QTR_SIZE_WIDTH + OV9726_HRZ_QTR_BLK_PIXELS;
-	else
-		return OV9726_FULL_SIZE_WIDTH + OV9726_HRZ_FULL_BLK_PIXELS;
-}
-
-static uint16_t ov9726_get_pict_lines_pf(void)
-{
-	if (ov9726_ctrl->pict_res == QTR_SIZE)
-		return OV9726_QTR_SIZE_HEIGHT + OV9726_VER_QTR_BLK_LINES;
-	else
-		return OV9726_FULL_SIZE_HEIGHT + OV9726_VER_FULL_BLK_LINES;
-}
-
-static uint16_t ov9726_get_pict_pixels_pl(void)
-{
-	if (ov9726_ctrl->pict_res == QTR_SIZE)
-		return OV9726_QTR_SIZE_WIDTH + OV9726_HRZ_QTR_BLK_PIXELS;
-	else
-		return OV9726_FULL_SIZE_WIDTH + OV9726_HRZ_FULL_BLK_PIXELS;
-}
-
-static uint32_t ov9726_get_pict_max_exp_lc(void)
-{
-	if (ov9726_ctrl->pict_res == QTR_SIZE)
-		return (OV9726_QTR_SIZE_HEIGHT + OV9726_VER_QTR_BLK_LINES)*24;
-	else
-		return (OV9726_FULL_SIZE_HEIGHT + OV9726_VER_FULL_BLK_LINES)*24;
-}
-
-static int32_t ov9726_set_fps(struct fps_cfg	*fps)
-{
-	int32_t rc = 0;
-	CDBG("%s: fps->fps_div = %d\n", __func__, fps->fps_div);
-	/* TODO: Passing of fps_divider from user space has issues. */
-	/* ov9726_ctrl->fps_divider = fps->fps_div; */
-	ov9726_ctrl->fps_divider = 1 * 0x400;
-	CDBG("%s: ov9726_ctrl->fps_divider = %d\n", __func__,
-		ov9726_ctrl->fps_divider);
-	ov9726_ctrl->pict_fps_divider = fps->pict_fps_div;
-	ov9726_ctrl->fps = fps->f_mult;
-	return rc;
-}
-
-static int32_t ov9726_write_exp_gain(uint16_t gain, uint32_t line)
-{
-	static uint16_t max_legal_gain = 0x00FF;
-	uint8_t gain_msb, gain_lsb;
-	uint8_t intg_time_msb, intg_time_lsb;
-	uint8_t ov9726_offset = 6;
-	uint8_t line_length_pck_msb, line_length_pck_lsb;
-	uint16_t line_length_pck, frame_length_lines;
-	uint32_t line_length_ratio = 1 << OV9726_Q8Shift;
-	int32_t rc = -1;
-	CDBG("%s: gain = %d	line = %d", __func__, gain, line);
-
-	if (ov9726_ctrl->sensormode != SENSOR_SNAPSHOT_MODE) {
-		if (ov9726_ctrl->curr_res == QTR_SIZE) {
-			frame_length_lines = OV9726_QTR_SIZE_HEIGHT +
-			 OV9726_VER_QTR_BLK_LINES;
-			line_length_pck = OV9726_QTR_SIZE_WIDTH	+
-			 OV9726_HRZ_QTR_BLK_PIXELS;
-		} else {
-			frame_length_lines = OV9726_FULL_SIZE_HEIGHT +
-				OV9726_VER_FULL_BLK_LINES;
-			line_length_pck = OV9726_FULL_SIZE_WIDTH +
-				OV9726_HRZ_FULL_BLK_PIXELS;
-		}
-		if (line > (frame_length_lines - ov9726_offset))
-			ov9726_ctrl->fps = (uint16_t) (((uint32_t)30 <<
-				OV9726_Q8Shift) *
-				(frame_length_lines - ov9726_offset) / line);
-		else
-			ov9726_ctrl->fps = (uint16_t) ((uint32_t)30 <<
-				OV9726_Q8Shift);
-	} else {
-		frame_length_lines = OV9726_FULL_SIZE_HEIGHT +
-			OV9726_VER_FULL_BLK_LINES;
-		line_length_pck = OV9726_FULL_SIZE_WIDTH +
-			OV9726_HRZ_FULL_BLK_PIXELS;
-	}
-
-	if (ov9726_ctrl->sensormode != SENSOR_SNAPSHOT_MODE) {
-		line = (uint32_t) (line * ov9726_ctrl->fps_divider) >>
-			OV9726_Q10Shift;
-	} else {
-		line = (uint32_t) (line * ov9726_ctrl->pict_fps_divider) >>
-			OV9726_Q10Shift;
-	}
-
-	/* calculate line_length_ratio */
-	if (line > (frame_length_lines - ov9726_offset)) {
-		line_length_ratio = (line << OV9726_Q8Shift) /
-			(frame_length_lines - ov9726_offset);
-		line = frame_length_lines - ov9726_offset;
-	} else
-		line_length_ratio = (uint32_t)1 << OV9726_Q8Shift;
-
-	if (gain > max_legal_gain) {
-		/* range:	0	to 224 */
-		gain = max_legal_gain;
-	}
-	/* update	gain registers */
-	gain_msb = (uint8_t) ((gain & 0xFF00) >> 8);
-	gain_lsb = (uint8_t) (gain & 0x00FF);
-	/* linear	AFR	horizontal stretch */
-	line_length_pck = (uint16_t) ((line_length_pck *
-		line_length_ratio) >> OV9726_Q8Shift);
-	line_length_pck_msb = (uint8_t) ((line_length_pck & 0xFF00) >> 8);
-	line_length_pck_lsb = (uint8_t) (line_length_pck & 0x00FF);
-	/* update	line count registers */
-	intg_time_msb = (uint8_t) ((line & 0xFF00) >> 8);
-	intg_time_lsb = (uint8_t) (line	& 0x00FF);
-
-	rc = ov9726_i2c_write_b(ov9726_client->addr, 0x104, 0x1);
-	if (rc < 0)
-		return rc;
-
-	rc = ov9726_i2c_write_b(ov9726_client->addr, 0x204, gain_msb);
-	if (rc < 0)
-		return rc;
-
-	rc = ov9726_i2c_write_b(ov9726_client->addr, 0x205, gain_lsb);
-	if (rc < 0)
-		return rc;
-
-	rc = ov9726_i2c_write_b(ov9726_client->addr, 0x342,
-		line_length_pck_msb);
-	if (rc < 0)
-		return rc;
-
-	rc = ov9726_i2c_write_b(ov9726_client->addr, 0x343,
-		line_length_pck_lsb);
-	if (rc < 0)
-		return rc;
-
-	rc = ov9726_i2c_write_b(ov9726_client->addr, 0x0202, intg_time_msb);
-	if (rc < 0)
-		return rc;
-
-	rc = ov9726_i2c_write_b(ov9726_client->addr, 0x0203, intg_time_lsb);
-	if (rc < 0)
-		return rc;
-
-	rc = ov9726_i2c_write_b(ov9726_client->addr, 0x104, 0x0);
-	if (rc < 0)
-		return rc;
-
-	return rc;
-}
-
-static int32_t ov9726_set_pict_exp_gain(uint16_t gain, uint32_t line)
-{
-	int32_t rc = 0;
-	rc = ov9726_write_exp_gain(gain, line);
-	return rc;
-}
-
-static int32_t initialize_ov9726_registers(void)
-{
-	int32_t i;
-	int32_t rc = 0;
-	ov9726_ctrl->sensormode = SENSOR_PREVIEW_MODE ;
-	/* Configure sensor for Preview mode and Snapshot mode */
-	CDBG("Initialize_ov9726_registers\n");
-	for (i = 0; i < ov9726_array_length; i++) {
-		rc = ov9726_i2c_write_b(ov9726_client->addr,
-			ov9726_init_settings_array[i].reg_addr,
-			ov9726_init_settings_array[i].reg_val);
-	if (rc < 0)
-		return rc;
-	}
-	return rc;
-}
-
-static int32_t ov9726_video_config(int mode)
-{
-	int32_t rc = 0;
-
-	ov9726_ctrl->sensormode = mode;
-
-	if (config_not_set) {
-		struct msm_camera_csi_params ov9726_csi_params;
-
-		/* sensor in standby */
-		ov9726_i2c_write_b(ov9726_client->addr, 0x100, 0);
-		msleep(5);
-		/* Initialize Sensor registers */
-		ov9726_csi_params.data_format = CSI_10BIT;
-		ov9726_csi_params.lane_cnt = 1;
-		ov9726_csi_params.lane_assign = 0xe4;
-		ov9726_csi_params.dpcm_scheme = 0;
-		ov9726_csi_params.settle_cnt = 7;
-
-		rc = msm_camio_csi_config(&ov9726_csi_params);
-		rc = initialize_ov9726_registers();
-		config_not_set = 0;
-	}
-	return rc;
-}
-
-static int32_t ov9726_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-	ov9726_ctrl->sensormode = mode;
-	return rc;
-}
-
-static int32_t ov9726_raw_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-	ov9726_ctrl->sensormode = mode;
-	return rc;
-}
-
-static int32_t ov9726_set_sensor_mode(int  mode,
-			int  res)
-{
-	int32_t rc = 0;
-	switch (mode) {
-	case SENSOR_PREVIEW_MODE:
-		rc = ov9726_video_config(mode);
-		break;
-	case SENSOR_SNAPSHOT_MODE:
-		rc = ov9726_snapshot_config(mode);
-		break;
-	case SENSOR_RAW_SNAPSHOT_MODE:
-		rc = ov9726_raw_snapshot_config(mode);
-		break;
-	default:
-		rc = -EINVAL;
-		break;
-	}
-	return rc;
-}
-
-static int ov9726_probe_init_sensor(const struct msm_camera_sensor_info *data)
-{
-	int32_t rc = 0;
-	uint16_t  chipidl, chipidh;
-
-	if (data->sensor_reset_enable) {
-		rc = gpio_request(data->sensor_reset, "ov9726");
-		if (!rc) {
-			gpio_direction_output(data->sensor_reset, 0);
-			gpio_set_value_cansleep(data->sensor_reset, 1);
-			msleep(20);
-		} else
-			goto init_probe_done;
-	}
-	/* 3. Read sensor Model ID: */
-	rc = ov9726_i2c_read(OV9726_PIDH_REG, &chipidh, 1);
-	if (rc < 0)
-		goto init_probe_fail;
-	rc = ov9726_i2c_read(OV9726_PIDL_REG, &chipidl, 1);
-	if (rc < 0)
-		goto init_probe_fail;
-	CDBG("kov9726 model_id = 0x%x  0x%x\n", chipidh, chipidl);
-	/* 4. Compare sensor ID to OV9726 ID: */
-	if (chipidh != OV9726_PID) {
-		rc = -ENODEV;
-		printk(KERN_INFO "Probeinit fail\n");
-		goto init_probe_fail;
-	}
-	CDBG("chipidh == OV9726_PID\n");
-	msleep(OV9726_RESET_DELAY_MSECS);
-	CDBG("after delay\n");
-	goto init_probe_done;
-
-init_probe_fail:
-	if (data->sensor_reset_enable) {
-		gpio_direction_output(data->sensor_reset, 0);
-		gpio_free(data->sensor_reset);
-	}
-init_probe_done:
-	printk(KERN_INFO " ov9726_probe_init_sensor finishes\n");
-	return rc;
-}
-
-int ov9726_sensor_open_init(const struct msm_camera_sensor_info *data)
-{
-	int32_t  rc;
-
-	CDBG("Calling ov9726_sensor_open_init\n");
-	ov9726_ctrl = kzalloc(sizeof(struct ov9726_ctrl_t), GFP_KERNEL);
-	if (!ov9726_ctrl) {
-		CDBG("ov9726_init failed!\n");
-		rc = -ENOMEM;
-		goto init_done;
-	}
-	ov9726_ctrl->curr_lens_pos = -1;
-	ov9726_ctrl->fps_divider = 1 << OV9726_Q10Shift;
-	ov9726_ctrl->pict_fps_divider = 1 << OV9726_Q10Shift;
-	ov9726_ctrl->set_test = TEST_OFF;
-	ov9726_ctrl->prev_res = FULL_SIZE;
-	ov9726_ctrl->pict_res = FULL_SIZE;
-	ov9726_ctrl->curr_res = INVALID_SIZE;
-	config_not_set = 1;
-	if (data)
-		ov9726_ctrl->sensordata = data;
-	/* enable mclk first */
-	msm_camio_clk_rate_set(OV9726_DEFAULT_CLOCK_RATE);
-	msleep(20);
-	rc = ov9726_probe_init_sensor(data);
-	if (rc < 0)
-		goto init_fail;
-
-	ov9726_ctrl->fps = (uint16_t)(30 << OV9726_Q8Shift);
-	/* generate test pattern */
-	if (rc < 0)
-		goto init_fail;
-	else
-		goto init_done;
-	/* reset the driver state */
-init_fail:
-	CDBG(" init_fail\n");
-	kfree(ov9726_ctrl);
-init_done:
-	CDBG("init_done\n");
-	return rc;
-}
-
-static int ov9726_init_client(struct i2c_client *client)
-{
-	/* Initialize the MSM_CAMI2C Chip */
-	init_waitqueue_head(&ov9726_wait_queue);
-	return 0;
-}
-
-static const struct i2c_device_id ov9726_i2c_id[] = {
-	{ "ov9726", 0},
-	{ }
-};
-
-static int ov9726_i2c_probe(struct i2c_client *client,
-	const struct i2c_device_id *id)
-{
-	int rc = 0;
-	CDBG("ov9726_probe called!\n");
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		CDBG("i2c_check_functionality failed\n");
-		goto probe_failure;
-	}
-	ov9726_sensorw = kzalloc(sizeof(struct ov9726_work_t), GFP_KERNEL);
-	if (!ov9726_sensorw) {
-		CDBG("kzalloc failed.\n");
-		rc = -ENOMEM;
-		goto probe_failure;
-	}
-	i2c_set_clientdata(client, ov9726_sensorw);
-	ov9726_init_client(client);
-	ov9726_client = client;
-	msleep(50);
-	CDBG("ov9726_probe successed! rc = %d\n", rc);
-	return 0;
-probe_failure:
-	CDBG("ov9726_probe failed! rc = %d\n", rc);
-	return rc;
-}
-
-static int __exit ov9726_remove(struct i2c_client *client)
-{
-	struct ov9726_work_t_t *sensorw = i2c_get_clientdata(client);
-	free_irq(client->irq, sensorw);
-	ov9726_client = NULL;
-	kfree(sensorw);
-	return 0;
-}
-
-static struct i2c_driver ov9726_i2c_driver = {
-	.id_table = ov9726_i2c_id,
-	.probe	= ov9726_i2c_probe,
-	.remove = __exit_p(ov9726_i2c_remove),
-	.driver = {
-		.name = "ov9726",
-	},
-};
-
-int ov9726_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(&ov9726_mut);
-	CDBG("ov9726_sensor_config: cfgtype = %d\n",
-		cdata.cfgtype);
-	switch (cdata.cfgtype) {
-	case CFG_GET_PICT_FPS:
-		ov9726_get_pict_fps(cdata.cfg.gfps.prevfps,
-				&(cdata.cfg.gfps.pictfps));
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-			break;
-	case CFG_GET_PREV_L_PF:
-		cdata.cfg.prevl_pf = ov9726_get_prev_lines_pf();
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_GET_PREV_P_PL:
-		cdata.cfg.prevp_pl = ov9726_get_prev_pixels_pl();
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_GET_PICT_L_PF:
-		cdata.cfg.pictl_pf = ov9726_get_pict_lines_pf();
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_GET_PICT_P_PL:
-		cdata.cfg.pictp_pl =
-				ov9726_get_pict_pixels_pl();
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_GET_PICT_MAX_EXP_LC:
-		cdata.cfg.pict_max_exp_lc = ov9726_get_pict_max_exp_lc();
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_SET_FPS:
-	case CFG_SET_PICT_FPS:
-		rc = ov9726_set_fps(&(cdata.cfg.fps));
-		break;
-	case CFG_SET_EXP_GAIN:
-		rc = ov9726_write_exp_gain(
-					cdata.cfg.exp_gain.gain,
-					cdata.cfg.exp_gain.line);
-		break;
-	case CFG_SET_PICT_EXP_GAIN:
-		rc = ov9726_set_pict_exp_gain(
-					cdata.cfg.exp_gain.gain,
-					cdata.cfg.exp_gain.line);
-		break;
-	case CFG_SET_MODE:
-		rc = ov9726_set_sensor_mode(cdata.mode,
-						cdata.rs);
-		break;
-	case CFG_PWR_DOWN:
-	case CFG_MOVE_FOCUS:
-	case CFG_SET_DEFAULT_FOCUS:
-		rc = 0;
-		break;
-	case CFG_SET_EFFECT:
-	default:
-		rc = -EFAULT;
-		break;
-	}
-	mutex_unlock(&ov9726_mut);
-	return rc;
-}
-
-static int ov9726_probe_init_done(const struct msm_camera_sensor_info *data)
-{
-	if (data->sensor_reset_enable) {
-		gpio_direction_output(data->sensor_reset, 0);
-		gpio_free(data->sensor_reset);
-	}
-	return 0;
-}
-
-static int ov9726_sensor_release(void)
-{
-	int rc = -EBADF;
-	mutex_lock(&ov9726_mut);
-	if (ov9726_ctrl->sensordata->sensor_reset_enable) {
-		gpio_direction_output(
-			ov9726_ctrl->sensordata->sensor_reset, 0);
-		gpio_free(ov9726_ctrl->sensordata->sensor_reset);
-	}
-	kfree(ov9726_ctrl);
-	ov9726_ctrl = NULL;
-	CDBG("ov9726_release completed\n");
-	mutex_unlock(&ov9726_mut);
-	return rc;
-}
-
-static int ov9726_sensor_probe(const struct msm_camera_sensor_info *info,
-		struct msm_sensor_ctrl *s)
-{
-	int rc = 0;
-
-	rc = i2c_add_driver(&ov9726_i2c_driver);
-	if (rc < 0 || ov9726_client == NULL) {
-		rc = -ENOTSUPP;
-		goto probe_fail;
-	}
-	msm_camio_clk_rate_set(24000000);
-	msleep(20);
-	rc = ov9726_probe_init_sensor(info);
-	if (rc < 0)
-		goto probe_fail;
-
-	s->s_init = ov9726_sensor_open_init;
-	s->s_release = ov9726_sensor_release;
-	s->s_config  = ov9726_sensor_config;
-	s->s_camera_type = FRONT_CAMERA_2D;
-	s->s_mount_angle = info->sensor_platform_info->mount_angle;
-	ov9726_probe_init_done(info);
-
-	return rc;
-
-probe_fail:
-	CDBG("SENSOR PROBE FAILS!\n");
-	return rc;
-}
-
-static int __ov9726_probe(struct platform_device *pdev)
-{
-	return msm_camera_drv_start(pdev, ov9726_sensor_probe);
-}
-
-static struct platform_driver msm_camera_driver = {
-	.probe = __ov9726_probe,
-	.driver = {
-		.name = "msm_camera_ov9726",
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init ov9726_init(void)
-{
-	return platform_driver_register(&msm_camera_driver);
-}
-
-module_init(ov9726_init);
-void ov9726_exit(void)
-{
-	i2c_del_driver(&ov9726_i2c_driver);
-}
-
-MODULE_DESCRIPTION("OMNI VGA Bayer sensor driver");
-MODULE_LICENSE("GPL v2");
-
diff --git a/drivers/media/platform/msm/camera_v1/ov9726.h b/drivers/media/platform/msm/camera_v1/ov9726.h
deleted file mode 100644
index 40ba1a8..0000000
--- a/drivers/media/platform/msm/camera_v1/ov9726.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- */
-
-#ifndef OV9726_H
-#define OV9726_H
-#include <linux/types.h>
-#include <mach/board.h>
-
-/* 16bit address - 8 bit context register structure */
-struct reg_struct_type {
-	uint16_t	reg_addr;
-	unsigned char	reg_val;
-};
-
-enum ov9726_test_mode_t {
-	TEST_OFF,
-	TEST_1,
-	TEST_2,
-	TEST_3
-};
-
-enum ov9726_resolution_t {
-	QTR_SIZE,
-	FULL_SIZE,
-	INVALID_SIZE
-};
-extern struct reg_struct_type ov9726_init_settings_array[];
-extern int32_t ov9726_array_length;
-#endif
-
diff --git a/drivers/media/platform/msm/camera_v1/ov9726_reg.c b/drivers/media/platform/msm/camera_v1/ov9726_reg.c
deleted file mode 100644
index 216ecca..0000000
--- a/drivers/media/platform/msm/camera_v1/ov9726_reg.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- *
- */
-
-#include "ov9726.h"
-struct reg_struct_type ov9726_init_settings_array[] = {
-	{0x0103, 0x01}, /* SOFTWARE_RESET */
-	{0x3026, 0x00}, /* OUTPUT_SELECT01 */
-	{0x3027, 0x00}, /* OUTPUT_SELECT02 */
-	{0x3002, 0xe8}, /* IO_CTRL00 */
-	{0x3004, 0x03}, /* IO_CTRL01 */
-	{0x3005, 0xff}, /* IO_CTRL02 */
-	{0x3703, 0x42},
-	{0x3704, 0x10},
-	{0x3705, 0x45},
-	{0x3603, 0xaa},
-	{0x3632, 0x2f},
-	{0x3620, 0x66},
-	{0x3621, 0xc0},
-	{0x0340, 0x03}, /* FRAME_LENGTH_LINES_HI */
-	{0x0341, 0xC1}, /* FRAME_LENGTH_LINES_LO */
-	{0x0342, 0x06}, /* LINE_LENGTH_PCK_HI */
-	{0x0343, 0x80}, /* LINE_LENGTH_PCK_LO */
-	{0x0202, 0x03}, /* COARSE_INTEGRATION_TIME_HI */
-	{0x0203, 0x43}, /* COARSE_INTEGRATION_TIME_LO */
-	{0x3833, 0x04},
-	{0x3835, 0x02},
-	{0x4702, 0x04},
-	{0x4704, 0x00}, /* DVP_CTRL01 */
-	{0x4706, 0x08},
-	{0x5052, 0x01},
-	{0x3819, 0x6e},
-	{0x3817, 0x94},
-	{0x3a18, 0x00}, /* AEC_GAIN_CEILING_HI */
-	{0x3a19, 0x7f}, /* AEC_GAIN_CEILING_LO */
-	{0x404e, 0x7e},
-	{0x3631, 0x52},
-	{0x3633, 0x50},
-	{0x3630, 0xd2},
-	{0x3604, 0x08},
-	{0x3601, 0x40},
-	{0x3602, 0x14},
-	{0x3610, 0xa0},
-	{0x3612, 0x20},
-	{0x034c, 0x05}, /* X_OUTPUT_SIZE_HI */
-	{0x034d, 0x10}, /* X_OUTPUT_SIZE_LO */
-	{0x034e, 0x03}, /* Y_OUTPUT_SIZE_HI */
-	{0x034f, 0x28}, /* Y_OUTPUT_SIZE_LO */
-	{0x0340, 0x03}, /* FRAME_LENGTH_LINES_HI */
-	{0x0341, 0xC1}, /* FRAME_LENGTH_LINES_LO */
-	{0x0342, 0x06}, /* LINE_LENGTH_PCK_HI */
-	{0x0343, 0x80}, /* LINE_LENGTH_PCK_LO */
-	{0x0202, 0x03}, /* COARSE_INTEGRATION_TIME_HI */
-	{0x0203, 0x43}, /* COARSE_INTEGRATION_TIME_LO */
-	{0x0303, 0x01}, /* VT_SYS_CLK_DIV_LO */
-	{0x3002, 0x00}, /* IO_CTRL00 */
-	{0x3004, 0x00}, /* IO_CTRL01 */
-	{0x3005, 0x00}, /* IO_CTRL02 */
-	{0x4801, 0x0f}, /* MIPI_CTRL01 */
-	{0x4803, 0x05}, /* MIPI_CTRL03 */
-	{0x4601, 0x16}, /* VFIFO_READ_CONTROL */
-	{0x3014, 0x05}, /* SC_CMMN_MIPI / SC_CTRL00 */
-	{0x3104, 0x80},
-	{0x0305, 0x04}, /* PRE_PLL_CLK_DIV_LO */
-	{0x0307, 0x64}, /* PLL_MULTIPLIER_LO */
-	{0x300c, 0x02},
-	{0x300d, 0x20},
-	{0x300e, 0x01},
-	{0x3010, 0x01},
-	{0x460e, 0x81}, /* VFIFO_CONTROL00 */
-	{0x0101, 0x01}, /* IMAGE_ORIENTATION */
-	{0x3707, 0x14},
-	{0x3622, 0x9f},
-	{0x5047, 0x3D}, /* ISP_CTRL47 */
-	{0x4002, 0x45}, /* BLC_CTRL02 */
-	{0x5000, 0x06}, /* ISP_CTRL0 */
-	{0x5001, 0x00}, /* ISP_CTRL1 */
-	{0x3406, 0x00}, /* AWB_MANUAL_CTRL */
-	{0x3503, 0x13}, /* AEC_ENABLE */
-	{0x4005, 0x18}, /* BLC_CTRL05 */
-	{0x4837, 0x21},
-	{0x0100, 0x01}, /* MODE_SELECT */
-	{0x3a0f, 0x64}, /* AEC_CTRL0F */
-	{0x3a10, 0x54}, /* AEC_CTRL10 */
-	{0x3a11, 0xc2}, /* AEC_CTRL11 */
-	{0x3a1b, 0x64}, /* AEC_CTRL1B */
-	{0x3a1e, 0x54}, /* AEC_CTRL1E */
-	{0x3a1a, 0x05}, /* AEC_DIFF_MAX */
-};
-int32_t ov9726_array_length = sizeof(ov9726_init_settings_array) /
-	sizeof(ov9726_init_settings_array[0]);
-
diff --git a/drivers/media/platform/msm/camera_v1/qs_s5k4e1.c b/drivers/media/platform/msm/camera_v1/qs_s5k4e1.c
deleted file mode 100644
index 32d094d..0000000
--- a/drivers/media/platform/msm/camera_v1/qs_s5k4e1.c
+++ /dev/null
@@ -1,1822 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- *
- */
-
-#include <linux/delay.h>
-#include <linux/debugfs.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/gpio.h>
-#include <mach/camera.h>
-#include "qs_s5k4e1.h"
-/*=============================================================
-	SENSOR REGISTER DEFINES
-==============================================================*/
-#define REG_GROUPED_PARAMETER_HOLD		0x0104
-#define GROUPED_PARAMETER_HOLD_OFF		0x00
-#define GROUPED_PARAMETER_HOLD			0x01
-/* Integration Time */
-#define REG_COARSE_INTEGRATION_TIME		0x0202
-/* Gain */
-#define REG_GLOBAL_GAIN					0x0204
-#define REG_GR_GAIN					0x020E
-#define REG_R_GAIN					0x0210
-#define REG_B_GAIN					0x0212
-#define REG_GB_GAIN					0x0214
-/* PLL registers */
-#define REG_FRAME_LENGTH_LINES			0x0340
-#define REG_LINE_LENGTH_PCK				0x0342
-/* Test Pattern */
-#define REG_TEST_PATTERN_MODE			0x0601
-#define REG_VCM_NEW_CODE				0x30F2
-#define AF_ADDR							0x18
-#define BRIDGE_ADDR						0x80
-/*============================================================================
-			 TYPE DECLARATIONS
-============================================================================*/
-
-/* 16bit address - 8 bit context register structure */
-#define Q8  0x00000100
-#define Q10 0x00000400
-#define QS_S5K4E1_MASTER_CLK_RATE 24000000
-#define QS_S5K4E1_OFFSET			8
-
-/* AF Total steps parameters */
-#define QS_S5K4E1_TOTAL_STEPS_NEAR_TO_FAR    32
-#define QS_S5K4E1_TOTAL_STEPS_3D    32
-
-uint16_t qs_s5k4e1_step_position_table[QS_S5K4E1_TOTAL_STEPS_NEAR_TO_FAR+1];
-uint16_t qs_s5k4e1_step_position_table_left[QS_S5K4E1_TOTAL_STEPS_3D+1];
-uint16_t qs_s5k4e1_step_position_table_right[QS_S5K4E1_TOTAL_STEPS_3D+1];
-uint16_t qs_s5k4e1_nl_region_boundary1;
-uint16_t qs_s5k4e1_nl_region_code_per_step1 = 190;
-uint16_t qs_s5k4e1_l_region_code_per_step = 8;
-uint16_t qs_s5k4e1_damping_threshold = 10;
-uint16_t qs_s5k4e1_sw_damping_time_wait = 8;
-uint16_t qs_s5k4e1_af_mode = 4;
-int16_t qs_s5k4e1_af_initial_code = 190;
-int16_t qs_s5k4e1_af_right_adjust;
-
-struct qs_s5k4e1_work_t {
-	struct work_struct work;
-};
-
-static struct qs_s5k4e1_work_t *qs_s5k4e1_sensorw;
-static struct i2c_client *qs_s5k4e1_client;
-static char lens_eeprom_data[864];
-static bool cali_data_status;
-struct qs_s5k4e1_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 */
-	uint16_t fps;
-
-	uint16_t curr_lens_pos;
-	uint16_t curr_step_pos;
-	uint16_t my_reg_gain;
-	uint32_t my_reg_line_count;
-	uint16_t total_lines_per_frame;
-
-	enum qs_s5k4e1_resolution_t prev_res;
-	enum qs_s5k4e1_resolution_t pict_res;
-	enum qs_s5k4e1_resolution_t curr_res;
-	enum qs_s5k4e1_test_mode_t  set_test;
-	enum qs_s5k4e1_cam_mode_t cam_mode;
-};
-
-static uint16_t prev_line_length_pck;
-static uint16_t prev_frame_length_lines;
-static uint16_t snap_line_length_pck;
-static uint16_t snap_frame_length_lines;
-
-static bool CSI_CONFIG, LENS_SHADE_CONFIG, default_lens_shade;
-static struct qs_s5k4e1_ctrl_t *qs_s5k4e1_ctrl;
-static DECLARE_WAIT_QUEUE_HEAD(qs_s5k4e1_wait_queue);
-DEFINE_MUTEX(qs_s5k4e1_mut);
-
-static int cam_debug_init(void);
-static struct dentry *debugfs_base;
-/*=============================================================*/
-
-static int qs_s5k4e1_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(qs_s5k4e1_client->adapter, msgs, 2) < 0) {
-		CDBG("qs_s5k4e1_i2c_rxdata faild 0x%x\n", saddr);
-		return -EIO;
-	}
-	return 0;
-}
-
-static int32_t qs_s5k4e1_i2c_txdata(unsigned short saddr,
-				unsigned char *txdata, int length)
-{
-	struct i2c_msg msg[] = {
-		{
-			.addr = saddr,
-			.flags = 0,
-			.len = length,
-			.buf = txdata,
-		 },
-	};
-	if (i2c_transfer(qs_s5k4e1_client->adapter, msg, 1) < 0) {
-		CDBG("qs_s5k4e1_i2c_txdata faild 0x%x\n", saddr);
-		return -EIO;
-	}
-
-	return 0;
-}
-
-static int32_t qs_s5k4e1_i2c_read(unsigned short raddr,
-	unsigned short *rdata, int rlen)
-{
-	int32_t rc = 0;
-	unsigned char buf[2];
-	if (!rdata)
-		return -EIO;
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (raddr & 0xFF00) >> 8;
-	buf[1] = (raddr & 0x00FF);
-	rc = qs_s5k4e1_i2c_rxdata(qs_s5k4e1_client->addr>>1, buf, rlen);
-	if (rc < 0) {
-		CDBG("qs_s5k4e1_i2c_read 0x%x failed!\n", raddr);
-		return rc;
-	}
-	*rdata = (rlen == 2 ? buf[0] << 8 | buf[1] : buf[0]);
-	CDBG("qs_s5k4e1_i2c_read 0x%x val = 0x%x!\n", raddr, *rdata);
-	return rc;
-}
-
-static int32_t qs_s5k4e1_i2c_write_w_sensor(unsigned short waddr,
-	 uint16_t wdata)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[4];
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00) >> 8;
-	buf[1] = (waddr & 0x00FF);
-	buf[2] = (wdata & 0xFF00) >> 8;
-	buf[3] = (wdata & 0x00FF);
-	CDBG("i2c_write_b addr = 0x%x, val = 0x%x\n", waddr, wdata);
-	rc = qs_s5k4e1_i2c_txdata(qs_s5k4e1_client->addr>>1, buf, 4);
-	if (rc < 0) {
-		CDBG("i2c_write_b failed, addr = 0x%x, val = 0x%x!\n",
-			waddr, wdata);
-	}
-	return rc;
-}
-
-static int32_t qs_s5k4e1_i2c_write_b_sensor(unsigned short waddr, uint8_t bdata)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[3];
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00) >> 8;
-	buf[1] = (waddr & 0x00FF);
-	buf[2] = bdata;
-	CDBG("i2c_write_b addr = 0x%x, val = 0x%x\n", waddr, bdata);
-	rc = qs_s5k4e1_i2c_txdata(qs_s5k4e1_client->addr>>1, buf, 3);
-	if (rc < 0) {
-		CDBG("i2c_write_b failed, addr = 0x%x, val = 0x%x!\n",
-			waddr, bdata);
-	}
-	return rc;
-}
-
-static int32_t qs_s5k4e1_i2c_write_b_table(struct qs_s5k4e1_i2c_reg_conf const
-					 *reg_conf_tbl, int num)
-{
-	int i;
-	int32_t rc = -EIO;
-	for (i = 0; i < num; i++) {
-		rc = qs_s5k4e1_i2c_write_b_sensor(reg_conf_tbl->waddr,
-			reg_conf_tbl->wdata);
-		if (rc < 0)
-			break;
-		reg_conf_tbl++;
-	}
-	return rc;
-}
-
-static int32_t qs_s5k4e1_i2c_write_seq_sensor(unsigned short waddr,
-		unsigned char *seq_data, int len)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[len+2];
-	int i = 0;
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00) >> 8;
-	buf[1] = (waddr & 0x00FF);
-	for (i = 0; i < len; i++)
-		buf[i+2] = seq_data[i];
-	rc = qs_s5k4e1_i2c_txdata(qs_s5k4e1_client->addr>>1, buf, len+2);
-	return rc;
-}
-
-static int32_t af_i2c_write_b_sensor(unsigned short baddr, uint8_t bdata)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[2];
-	memset(buf, 0, sizeof(buf));
-	buf[0] = baddr;
-	buf[1] = bdata;
-	CDBG("i2c_write_b addr = 0x%x, val = 0x%x\n", baddr, bdata);
-	rc = qs_s5k4e1_i2c_txdata(AF_ADDR>>1, buf, 2);
-	if (rc < 0) {
-		CDBG("i2c_write_b failed, addr = 0x%x, val = 0x%x!\n",
-			baddr, bdata);
-	}
-	return rc;
-}
-
-static int32_t bridge_i2c_write_w(unsigned short waddr, uint16_t wdata)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[4];
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00) >> 8;
-	buf[1] = (waddr & 0x00FF);
-	buf[2] = (wdata & 0xFF00) >> 8;
-	buf[3] = (wdata & 0x00FF);
-	CDBG("bridge_i2c_write_w addr = 0x%x, val = 0x%x\n", waddr, wdata);
-	rc = qs_s5k4e1_i2c_txdata(BRIDGE_ADDR>>1, buf, 4);
-	if (rc < 0) {
-		CDBG("bridge_i2c_write_w failed, addr = 0x%x, val = 0x%x!\n",
-			waddr, wdata);
-	}
-	return rc;
-}
-
-static int32_t bridge_i2c_read(unsigned short raddr,
-	unsigned short *rdata, int rlen)
-{
-	int32_t rc = 0;
-	unsigned char buf[2];
-	if (!rdata)
-		return -EIO;
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (raddr & 0xFF00) >> 8;
-	buf[1] = (raddr & 0x00FF);
-	rc = qs_s5k4e1_i2c_rxdata(BRIDGE_ADDR>>1, buf, rlen);
-	if (rc < 0) {
-		CDBG("bridge_i2c_read 0x%x failed!\n", raddr);
-		return rc;
-	}
-	*rdata = (rlen == 2 ? buf[0] << 8 | buf[1] : buf[0]);
-	CDBG("bridge_i2c_read 0x%x val = 0x%x!\n", raddr, *rdata);
-	return rc;
-}
-
-static int32_t qs_s5k4e1_eeprom_i2c_read(unsigned short raddr,
-	unsigned char *rdata, int rlen)
-{
-	int32_t rc = 0;
-	unsigned short i2caddr = 0xA0 >> 1;
-	unsigned char buf[rlen];
-	int i = 0;
-	if (!rdata)
-		return -EIO;
-
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (raddr & 0xFF00) >> 8;
-	buf[1] = (raddr & 0x00FF);
-	rc = qs_s5k4e1_i2c_rxdata(i2caddr, buf, rlen);
-	if (rc < 0) {
-		CDBG("qs_s5k4e1_eeprom_i2c_read 0x%x failed!\n", raddr);
-		return rc;
-	}
-	for (i = 0; i < rlen; i++) {
-		rdata[i] = buf[i];
-		CDBG("qs_s5k4e1_eeprom_i2c_read 0x%x index: %d val = 0x%x!\n",
-			raddr, i, buf[i]);
-	}
-	return rc;
-}
-
-static int32_t qs_s5k4e1_eeprom_i2c_read_b(unsigned short raddr,
-	unsigned short *rdata, int rlen)
-{
-	int32_t rc = 0;
-	unsigned char buf[2];
-	rc = qs_s5k4e1_eeprom_i2c_read(raddr, &buf[0], rlen);
-	*rdata = (rlen == 2 ? buf[0] << 8 | buf[1] : buf[0]);
-	CDBG("qs_s5k4e1_eeprom_i2c_read 0x%x val = 0x%x!\n", raddr, *rdata);
-	return rc;
-}
-
-static int32_t qs_s5k4e1_get_calibration_data(
-	struct sensor_3d_cali_data_t *cdata)
-{
-	int32_t rc = 0;
-	cali_data_status = 1;
-	rc = qs_s5k4e1_eeprom_i2c_read(0x0,
-		&(cdata->left_p_matrix[0][0][0]), 96);
-	if (rc < 0)
-		goto fail;
-	rc = qs_s5k4e1_eeprom_i2c_read(0x60,
-		&(cdata->right_p_matrix[0][0][0]), 96);
-	if (rc < 0)
-		goto fail;
-	rc = qs_s5k4e1_eeprom_i2c_read(0xC0, &(cdata->square_len[0]), 8);
-	if (rc < 0)
-		goto fail;
-	rc = qs_s5k4e1_eeprom_i2c_read(0xC8, &(cdata->focal_len[0]), 8);
-	if (rc < 0)
-		goto fail;
-	rc = qs_s5k4e1_eeprom_i2c_read(0xD0, &(cdata->pixel_pitch[0]), 8);
-	if (rc < 0)
-		goto fail;
-	rc = qs_s5k4e1_eeprom_i2c_read_b(0x100, &(cdata->left_r), 1);
-	if (rc < 0)
-		goto fail;
-	rc = qs_s5k4e1_eeprom_i2c_read_b(0x101, &(cdata->right_r), 1);
-	if (rc < 0)
-		goto fail;
-	rc = qs_s5k4e1_eeprom_i2c_read_b(0x102, &(cdata->left_b), 1);
-	if (rc < 0)
-		goto fail;
-	rc = qs_s5k4e1_eeprom_i2c_read_b(0x103, &(cdata->right_b), 1);
-	if (rc < 0)
-		goto fail;
-	rc = qs_s5k4e1_eeprom_i2c_read_b(0x104, &(cdata->left_gb), 1);
-	if (rc < 0)
-		goto fail;
-	rc = qs_s5k4e1_eeprom_i2c_read_b(0x105, &(cdata->right_gb), 1);
-	if (rc < 0)
-		goto fail;
-	rc = qs_s5k4e1_eeprom_i2c_read_b(0x110, &(cdata->left_af_far), 2);
-	if (rc < 0)
-		goto fail;
-	rc = qs_s5k4e1_eeprom_i2c_read_b(0x112, &(cdata->right_af_far), 2);
-	if (rc < 0)
-		goto fail;
-	rc = qs_s5k4e1_eeprom_i2c_read_b(0x114, &(cdata->left_af_mid), 2);
-	if (rc < 0)
-		goto fail;
-	rc = qs_s5k4e1_eeprom_i2c_read_b(0x116, &(cdata->right_af_mid), 2);
-	if (rc < 0)
-		goto fail;
-	rc = qs_s5k4e1_eeprom_i2c_read_b(0x118, &(cdata->left_af_short), 2);
-	if (rc < 0)
-		goto fail;
-	rc = qs_s5k4e1_eeprom_i2c_read_b(0x11A, &(cdata->right_af_short), 2);
-	if (rc < 0)
-		goto fail;
-	rc = qs_s5k4e1_eeprom_i2c_read_b(0x11C, &(cdata->left_af_5um), 2);
-	if (rc < 0)
-		goto fail;
-	rc = qs_s5k4e1_eeprom_i2c_read_b(0x11E, &(cdata->right_af_5um), 2);
-	if (rc < 0)
-		goto fail;
-	rc = qs_s5k4e1_eeprom_i2c_read_b(0x120, &(cdata->left_af_50up), 2);
-	if (rc < 0)
-		goto fail;
-	rc = qs_s5k4e1_eeprom_i2c_read_b(0x122, &(cdata->right_af_50up), 2);
-	if (rc < 0)
-		goto fail;
-	rc = qs_s5k4e1_eeprom_i2c_read_b(0x124, &(cdata->left_af_50down), 2);
-	if (rc < 0)
-		goto fail;
-	rc = qs_s5k4e1_eeprom_i2c_read_b(0x126, &(cdata->right_af_50down), 2);
-	if (rc < 0)
-		goto fail;
-
-	return 0;
-
-fail:
-	cali_data_status = 0;
-	return -EIO;
-
-}
-static int32_t qs_s5k4e1_write_left_lsc(char *left_lsc, int rt)
-{
-	struct qs_s5k4e1_i2c_reg_conf *ptr = (struct qs_s5k4e1_i2c_reg_conf *)
-		(qs_s5k4e1_regs.reg_lens + rt);
-	bridge_i2c_write_w(0x06, 0x02);
-	if (!LENS_SHADE_CONFIG) {
-		qs_s5k4e1_i2c_write_b_sensor(0x3096, 0x40);
-		qs_s5k4e1_i2c_write_b_table(ptr, qs_s5k4e1_regs.reg_lens_size);
-		if (default_lens_shade)
-			qs_s5k4e1_i2c_write_b_table(qs_s5k4e1_regs.
-			reg_default_lens, qs_s5k4e1_regs.reg_default_lens_size);
-		else {
-			qs_s5k4e1_i2c_write_seq_sensor(0x3200,
-				&left_lsc[0], 216);
-			qs_s5k4e1_i2c_write_seq_sensor(0x32D8,
-				&left_lsc[216], 216);
-		}
-		qs_s5k4e1_i2c_write_b_sensor(0x3096, 0x60);
-		qs_s5k4e1_i2c_write_b_sensor(0x3096, 0x40);
-	} else
-		qs_s5k4e1_i2c_write_b_table(ptr, qs_s5k4e1_regs.reg_lens_size);
-	return 0;
-}
-
-static int32_t qs_s5k4e1_write_right_lsc(char *right_lsc, int rt)
-{
-	struct qs_s5k4e1_i2c_reg_conf *ptr = (struct qs_s5k4e1_i2c_reg_conf *)
-		(qs_s5k4e1_regs.reg_lens + rt);
-	bridge_i2c_write_w(0x06, 0x01);
-	if (!LENS_SHADE_CONFIG) {
-		qs_s5k4e1_i2c_write_b_sensor(0x3096, 0x40);
-		qs_s5k4e1_i2c_write_b_table(ptr, qs_s5k4e1_regs.reg_lens_size);
-		if (default_lens_shade)
-			qs_s5k4e1_i2c_write_b_table(qs_s5k4e1_regs.
-			reg_default_lens, qs_s5k4e1_regs.reg_default_lens_size);
-		else {
-			qs_s5k4e1_i2c_write_seq_sensor(0x3200,
-				&right_lsc[0], 216);
-			qs_s5k4e1_i2c_write_seq_sensor(0x32D8,
-				&right_lsc[216], 216);
-		}
-		qs_s5k4e1_i2c_write_b_sensor(0x3096, 0x60);
-		qs_s5k4e1_i2c_write_b_sensor(0x3096, 0x40);
-	} else
-		qs_s5k4e1_i2c_write_b_table(ptr, qs_s5k4e1_regs.reg_lens_size);
-	return 0;
-}
-
-static int32_t qs_s5k4e1_write_lsc(char *lsc, int rt)
-{
-	if (qs_s5k4e1_ctrl->cam_mode == MODE_3D) {
-		qs_s5k4e1_write_left_lsc(&lsc[0], rt);
-		qs_s5k4e1_write_right_lsc(&lsc[432], rt);
-		bridge_i2c_write_w(0x06, 0x03);
-	} else if (qs_s5k4e1_ctrl->cam_mode == MODE_2D_LEFT)
-		qs_s5k4e1_write_left_lsc(&lsc[0], rt);
-	else if (qs_s5k4e1_ctrl->cam_mode == MODE_2D_RIGHT)
-		qs_s5k4e1_write_right_lsc(&lsc[432], rt);
-	return 0;
-}
-
-static int32_t qs_s5k4e1_read_left_lsc(char *left_lsc)
-{
-	qs_s5k4e1_eeprom_i2c_read(0x200, &left_lsc[0], 216);
-	qs_s5k4e1_eeprom_i2c_read(0x2D8, &left_lsc[216], 216);
-	return 0;
-}
-
-static int32_t qs_s5k4e1_read_right_lsc(char *right_lsc)
-{
-	qs_s5k4e1_eeprom_i2c_read(0x3B0, &right_lsc[0], 216);
-	qs_s5k4e1_eeprom_i2c_read(0x488, &right_lsc[216], 216);
-	return 0;
-}
-
-static int32_t qs_s5k4e1_read_lsc(char *lsc)
-{
-	qs_s5k4e1_read_left_lsc(&lsc[0]);
-	qs_s5k4e1_read_right_lsc(&lsc[432]);
-	return 0;
-}
-
-static int32_t qs_s5k4e1_bridge_reset(void){
-	unsigned short RegData = 0, GPIOInState = 0;
-	int32_t rc = 0;
-	rc = bridge_i2c_write_w(0x50, 0x00);
-	if (rc < 0)
-		goto bridge_fail;
-	rc = bridge_i2c_write_w(0x53, 0x00);
-	if (rc < 0)
-		goto bridge_fail;
-	msleep(30);
-	rc = bridge_i2c_write_w(0x53, 0x01);
-	if (rc < 0)
-		goto bridge_fail;
-	msleep(30);
-	rc = bridge_i2c_write_w(0x0E, 0xFFFF);
-	if (rc < 0)
-		goto err;
-	rc = bridge_i2c_read(0x54, &RegData, 2);
-	if (rc < 0)
-		goto err;
-	rc = bridge_i2c_write_w(0x54, (RegData | 0x1));
-	if (rc < 0)
-		goto err;
-	msleep(30);
-	rc = bridge_i2c_read(0x54, &RegData, 2);
-	if (rc < 0)
-		goto err;
-	rc = bridge_i2c_write_w(0x54, (RegData | 0x4));
-	if (rc < 0)
-		goto err;
-	rc = bridge_i2c_read(0x55, &GPIOInState, 2);
-	if (rc < 0)
-		goto err;
-	rc = bridge_i2c_write_w(0x55, (GPIOInState | 0x1));
-	if (rc < 0)
-		goto err;
-	msleep(30);
-	rc = bridge_i2c_read(0x55, &GPIOInState, 2);
-	if (rc < 0)
-		goto err;
-	rc = bridge_i2c_write_w(0x55, (GPIOInState | 0x4));
-	if (rc < 0)
-		goto err;
-	msleep(30);
-	rc = bridge_i2c_read(0x55, &GPIOInState, 2);
-	if (rc < 0)
-		goto err;
-	GPIOInState = ((GPIOInState >> 4) & 0x1);
-
-	rc = bridge_i2c_read(0x08, &GPIOInState, 2);
-	if (rc < 0)
-		goto err;
-	rc = bridge_i2c_write_w(0x08, GPIOInState | 0x4000);
-	if (rc < 0)
-		goto err;
-	return rc;
-
-err:
-	bridge_i2c_write_w(0x53, 0x00);
-	msleep(30);
-
-bridge_fail:
-	return rc;
-
-}
-
-static void qs_s5k4e1_bridge_config(int mode, int rt)
-{
-	unsigned short RegData = 0;
-	if (mode == MODE_3D) {
-		bridge_i2c_read(0x54, &RegData, 2);
-		bridge_i2c_write_w(0x54, (RegData | 0x2));
-		bridge_i2c_write_w(0x54, (RegData | 0xa));
-		bridge_i2c_read(0x55, &RegData, 2);
-		bridge_i2c_write_w(0x55, (RegData | 0x2));
-		bridge_i2c_write_w(0x55, (RegData | 0xa));
-		bridge_i2c_write_w(0x14, 0x0C);
-		msleep(20);
-		bridge_i2c_write_w(0x16, 0x00);
-		bridge_i2c_write_w(0x51, 0x3);
-		bridge_i2c_write_w(0x52, 0x1);
-		bridge_i2c_write_w(0x06, 0x03);
-		bridge_i2c_write_w(0x04, 0x2018);
-		bridge_i2c_write_w(0x50, 0x00);
-	} else if (mode == MODE_2D_RIGHT) {
-		bridge_i2c_read(0x54, &RegData, 2);
-		RegData |= 0x2;
-		bridge_i2c_write_w(0x54, RegData);
-		bridge_i2c_write_w(0x54, (RegData & ~(0x8)));
-		bridge_i2c_read(0x55, &RegData, 2);
-		RegData |= 0x2;
-		bridge_i2c_write_w(0x55, RegData);
-		bridge_i2c_write_w(0x55, (RegData & ~(0x8)));
-		bridge_i2c_write_w(0x14, 0x04);
-		msleep(20);
-		bridge_i2c_write_w(0x51, 0x3);
-		bridge_i2c_write_w(0x06, 0x01);
-		bridge_i2c_write_w(0x04, 0x2018);
-		bridge_i2c_write_w(0x50, 0x01);
-	} else if (mode == MODE_2D_LEFT) {
-		bridge_i2c_read(0x54, &RegData, 2);
-		RegData |= 0x8;
-		bridge_i2c_write_w(0x54, RegData);
-		bridge_i2c_write_w(0x54, (RegData & ~(0x2)));
-		bridge_i2c_read(0x55, &RegData, 2);
-		RegData |= 0x8;
-		bridge_i2c_write_w(0x55, RegData);
-		bridge_i2c_write_w(0x55, (RegData & ~(0x2)));
-		bridge_i2c_write_w(0x14, 0x08);
-		msleep(20);
-		bridge_i2c_write_w(0x51, 0x3);
-		bridge_i2c_write_w(0x06, 0x02);
-		bridge_i2c_write_w(0x04, 0x2018);
-		bridge_i2c_write_w(0x50, 0x02);
-	}
-}
-
-static void qs_s5k4e1_group_hold_on(void)
-{
-	qs_s5k4e1_i2c_write_b_sensor(REG_GROUPED_PARAMETER_HOLD,
-						GROUPED_PARAMETER_HOLD);
-}
-
-static void qs_s5k4e1_group_hold_off(void)
-{
-	qs_s5k4e1_i2c_write_b_sensor(REG_GROUPED_PARAMETER_HOLD,
-						GROUPED_PARAMETER_HOLD_OFF);
-}
-
-static void qs_s5k4e1_start_stream(void)
-{
-	qs_s5k4e1_i2c_write_b_sensor(0x0100, 0x01);
-}
-
-static void qs_s5k4e1_stop_stream(void)
-{
-	qs_s5k4e1_i2c_write_b_sensor(0x0100, 0x00);
-}
-
-static void qs_s5k4e1_get_pict_fps(uint16_t fps, uint16_t *pfps)
-{
-	/* input fps is preview fps in Q8 format */
-	uint32_t divider, d1, d2;
-
-	d1 = prev_frame_length_lines * 0x00000400 / snap_frame_length_lines;
-	d2 = prev_line_length_pck * 0x00000400 / snap_line_length_pck;
-	divider = d1 * d2 / 0x400;
-
-	/*Verify PCLK settings and frame sizes.*/
-	*pfps = (uint16_t) (fps * divider / 0x400);
-	/* 2 is the ratio of no.of snapshot channels
-	to number of preview channels */
-}
-
-static uint16_t qs_s5k4e1_get_prev_lines_pf(void)
-{
-
-	return prev_frame_length_lines;
-
-}
-
-static uint16_t qs_s5k4e1_get_prev_pixels_pl(void)
-{
-	return prev_line_length_pck;
-
-}
-
-static uint16_t qs_s5k4e1_get_pict_lines_pf(void)
-{
-	return snap_frame_length_lines;
-}
-
-static uint16_t qs_s5k4e1_get_pict_pixels_pl(void)
-{
-	return snap_line_length_pck;
-}
-
-
-static uint32_t qs_s5k4e1_get_pict_max_exp_lc(void)
-{
-	return snap_frame_length_lines  * 24;
-}
-
-static int32_t qs_s5k4e1_set_fps(struct fps_cfg   *fps)
-{
-	uint16_t total_lines_per_frame;
-	int32_t rc = 0;
-	qs_s5k4e1_ctrl->fps_divider = fps->fps_div;
-	qs_s5k4e1_ctrl->pict_fps_divider = fps->pict_fps_div;
-	if (qs_s5k4e1_ctrl->sensormode == SENSOR_PREVIEW_MODE) {
-		total_lines_per_frame = (uint16_t)
-		((prev_frame_length_lines) * qs_s5k4e1_ctrl->fps_divider/0x400);
-	} else {
-		total_lines_per_frame = (uint16_t)
-		((snap_frame_length_lines) *
-			qs_s5k4e1_ctrl->pict_fps_divider/0x400);
-	}
-	qs_s5k4e1_group_hold_on();
-	rc = qs_s5k4e1_i2c_write_w_sensor(REG_FRAME_LENGTH_LINES,
-							total_lines_per_frame);
-	qs_s5k4e1_group_hold_off();
-	return rc;
-}
-
-static int32_t qs_s5k4e1_write_exp_gain(struct sensor_3d_exp_cfg exp_cfg)
-{
-	uint16_t max_legal_gain = 0x0200;
-	uint32_t ll_pck, fl_lines;
-	uint16_t gain = exp_cfg.gain;
-	uint32_t line = exp_cfg.line;
-	int32_t rc = 0;
-	if (gain > max_legal_gain) {
-		CDBG("Max legal gain Line:%d\n", __LINE__);
-		gain = max_legal_gain;
-	}
-	CDBG("qs_s5k4e1_write_exp_gain : gain = %d line = %d\n", gain, line);
-
-	if (qs_s5k4e1_ctrl->sensormode == SENSOR_PREVIEW_MODE) {
-		qs_s5k4e1_ctrl->my_reg_gain = gain;
-		qs_s5k4e1_ctrl->my_reg_line_count = (uint16_t) line;
-		fl_lines = prev_frame_length_lines *
-			qs_s5k4e1_ctrl->fps_divider / 0x400;
-		ll_pck = prev_line_length_pck;
-	} else {
-		fl_lines = snap_frame_length_lines *
-			qs_s5k4e1_ctrl->pict_fps_divider / 0x400;
-		ll_pck = snap_line_length_pck;
-	}
-	if (line > (fl_lines - QS_S5K4E1_OFFSET))
-		fl_lines = line + QS_S5K4E1_OFFSET;
-	qs_s5k4e1_group_hold_on();
-	rc = qs_s5k4e1_i2c_write_w_sensor(REG_GLOBAL_GAIN, gain);
-	rc = qs_s5k4e1_i2c_write_w_sensor(REG_FRAME_LENGTH_LINES, fl_lines);
-	rc = qs_s5k4e1_i2c_write_w_sensor(REG_COARSE_INTEGRATION_TIME, line);
-	if ((qs_s5k4e1_ctrl->cam_mode == MODE_3D) && (cali_data_status == 1)) {
-		bridge_i2c_write_w(0x06, 0x01);
-		rc = qs_s5k4e1_i2c_write_w_sensor(REG_GLOBAL_GAIN,
-			 exp_cfg.gain_adjust);
-		rc = qs_s5k4e1_i2c_write_w_sensor(REG_GR_GAIN, exp_cfg.gr_gain);
-		rc = qs_s5k4e1_i2c_write_w_sensor(REG_R_GAIN,
-				exp_cfg.r_gain);
-		rc = qs_s5k4e1_i2c_write_w_sensor(REG_B_GAIN,
-				exp_cfg.b_gain);
-		rc = qs_s5k4e1_i2c_write_w_sensor(REG_GB_GAIN,
-				exp_cfg.gb_gain);
-		bridge_i2c_write_w(0x06, 0x03);
-	}
-	qs_s5k4e1_group_hold_off();
-	return rc;
-}
-
-static int32_t qs_s5k4e1_set_pict_exp_gain(struct sensor_3d_exp_cfg exp_cfg)
-{
-	int32_t rc = 0;
-	rc = qs_s5k4e1_write_exp_gain(exp_cfg);
-	return rc;
-}
-
-static int32_t qs_s5k4e1_write_focus_value(uint16_t code_value)
-{
-	uint8_t code_val_msb, code_val_lsb;
-	if ((qs_s5k4e1_ctrl->cam_mode == MODE_2D_LEFT) ||
-		(qs_s5k4e1_ctrl->cam_mode == MODE_3D)) {
-		/* Left */
-		bridge_i2c_write_w(0x06, 0x02);
-		CDBG("%s: Left Lens Position: %d\n", __func__,
-			code_value);
-		code_val_msb = code_value >> 4;
-		code_val_lsb = (code_value & 0x000F) << 4;
-		code_val_lsb |= qs_s5k4e1_af_mode;
-		if (af_i2c_write_b_sensor(code_val_msb, code_val_lsb) < 0) {
-			CDBG("move_focus failed at line %d ...\n", __LINE__);
-			return -EBUSY;
-		}
-	}
-
-	if ((qs_s5k4e1_ctrl->cam_mode == MODE_2D_RIGHT) ||
-		(qs_s5k4e1_ctrl->cam_mode == MODE_3D)) {
-		/* Right */
-		bridge_i2c_write_w(0x06, 0x01);
-		code_value += qs_s5k4e1_af_right_adjust;
-		CDBG("%s: Right Lens Position: %d\n", __func__,
-			code_value);
-		code_val_msb = code_value >> 4;
-		code_val_lsb = (code_value & 0x000F) << 4;
-		code_val_lsb |= qs_s5k4e1_af_mode;
-		if (af_i2c_write_b_sensor(code_val_msb, code_val_lsb) < 0) {
-			CDBG("move_focus failed at line %d ...\n", __LINE__);
-			return -EBUSY;
-		}
-	}
-
-	if (qs_s5k4e1_ctrl->cam_mode == MODE_3D) {
-		/* 3D Mode */
-		bridge_i2c_write_w(0x06, 0x03);
-	}
-	usleep(qs_s5k4e1_sw_damping_time_wait*50);
-	return 0;
-}
-
-static int32_t qs_s5k4e1_write_1D_focus_value(uint16_t code_value)
-{
-	uint8_t code_val_msb, code_val_lsb;
-	CDBG("%s: Lens Position: %d\n", __func__, code_value);
-	code_val_msb = code_value >> 4;
-	code_val_lsb = (code_value & 0x000F) << 4;
-	code_val_lsb |= qs_s5k4e1_af_mode;
-	if (af_i2c_write_b_sensor(code_val_msb, code_val_lsb) < 0) {
-		CDBG("move_focus failed at line %d ...\n", __LINE__);
-		return -EBUSY;
-	}
-
-	usleep(qs_s5k4e1_sw_damping_time_wait*50);
-	return 0;
-}
-
-static int32_t qs_s5k4e1_move_focus(int direction,
-	int32_t num_steps)
-{
-	int16_t step_direction, actual_step, dest_lens_position,
-		dest_step_position;
-	int16_t max_step_postion = QS_S5K4E1_TOTAL_STEPS_NEAR_TO_FAR;
-	CDBG("Inside %s\n", __func__);
-	if (direction == MOVE_NEAR)
-		step_direction = 1;
-	else
-		step_direction = -1;
-
-	actual_step = (int16_t) (step_direction * (int16_t) num_steps);
-	dest_step_position = (int16_t) (qs_s5k4e1_ctrl->curr_step_pos +
-		actual_step);
-
-	if (qs_s5k4e1_ctrl->cam_mode == MODE_3D)
-		max_step_postion = QS_S5K4E1_TOTAL_STEPS_3D;
-
-	if (dest_step_position > max_step_postion)
-		dest_step_position = max_step_postion;
-	else if (dest_step_position < 0)
-		dest_step_position = 0;
-
-	if (dest_step_position == qs_s5k4e1_ctrl->curr_step_pos) {
-		CDBG("%s cur and dest pos are same\n", __func__);
-		CDBG("%s cur_step_pos:%d\n", __func__,
-			qs_s5k4e1_ctrl->curr_step_pos);
-		return 0;
-	}
-
-	if (step_direction < 0) {
-		if (num_steps >= 20) {
-			/* sweeping towards all the way in infinity direction */
-			qs_s5k4e1_af_mode = 2;
-			qs_s5k4e1_sw_damping_time_wait = 8;
-		} else if (num_steps <= 4) {
-			/* reverse search during macro mode */
-			qs_s5k4e1_af_mode = 4;
-			qs_s5k4e1_sw_damping_time_wait = 16;
-		} else {
-			qs_s5k4e1_af_mode = 3;
-			qs_s5k4e1_sw_damping_time_wait = 12;
-		}
-	} else {
-		/* coarse search towards macro direction */
-		qs_s5k4e1_af_mode = 4;
-		qs_s5k4e1_sw_damping_time_wait = 16;
-	}
-
-	if (qs_s5k4e1_ctrl->cam_mode == MODE_3D) {
-		/* Left */
-		bridge_i2c_write_w(0x06, 0x02);
-		dest_lens_position =
-			qs_s5k4e1_step_position_table_left[dest_step_position];
-		if (qs_s5k4e1_write_1D_focus_value(dest_lens_position) < 0) {
-			CDBG("move_focus failed at line %d ...\n", __LINE__);
-			bridge_i2c_write_w(0x06, 0x03);
-			return -EBUSY;
-		}
-		/* Keep left sensor as reference as AF stats is from left */
-		qs_s5k4e1_ctrl->curr_step_pos = dest_step_position;
-		qs_s5k4e1_ctrl->curr_lens_pos = dest_lens_position;
-
-		/* Right */
-		bridge_i2c_write_w(0x06, 0x01);
-		dest_lens_position =
-			qs_s5k4e1_step_position_table_right[dest_step_position];
-		if (qs_s5k4e1_write_1D_focus_value(dest_lens_position) < 0) {
-			CDBG("move_focus failed at line %d ...\n", __LINE__);
-			bridge_i2c_write_w(0x06, 0x03);
-			return -EBUSY;
-		}
-
-		/* 3D Mode */
-		bridge_i2c_write_w(0x06, 0x03);
-		return 0;
-	}
-
-	dest_lens_position = qs_s5k4e1_step_position_table[dest_step_position];
-	CDBG("%s: Step Position: %d\n", __func__, dest_step_position);
-	if (qs_s5k4e1_ctrl->curr_lens_pos != dest_lens_position) {
-		if (qs_s5k4e1_write_focus_value(dest_lens_position) < 0) {
-			CDBG("move_focus failed at line %d ...\n", __LINE__);
-			return -EBUSY;
-		}
-	}
-
-	qs_s5k4e1_ctrl->curr_step_pos = dest_step_position;
-	qs_s5k4e1_ctrl->curr_lens_pos = dest_lens_position;
-	return 0;
-}
-
-static int32_t qs_s5k4e1_set_default_focus(uint8_t af_step)
-{
-	int32_t rc = 0;
-	if (qs_s5k4e1_ctrl->curr_step_pos) {
-		rc = qs_s5k4e1_move_focus(MOVE_FAR,
-			qs_s5k4e1_ctrl->curr_step_pos);
-		if (rc < 0)
-			return rc;
-	} else {
-		if (qs_s5k4e1_ctrl->cam_mode == MODE_3D) {
-			/* Left */
-			bridge_i2c_write_w(0x06, 0x02);
-			rc = qs_s5k4e1_write_1D_focus_value(
-				qs_s5k4e1_step_position_table_left[0]);
-			if (rc < 0) {
-				bridge_i2c_write_w(0x06, 0x03);
-				return rc;
-			}
-
-			/* Right */
-			bridge_i2c_write_w(0x06, 0x01);
-			rc = qs_s5k4e1_write_1D_focus_value(
-				qs_s5k4e1_step_position_table_right[0]);
-			if (rc < 0) {
-				bridge_i2c_write_w(0x06, 0x03);
-				return rc;
-			}
-
-			/* Left sensor is the reference sensor for AF stats */
-			qs_s5k4e1_ctrl->curr_lens_pos =
-				qs_s5k4e1_step_position_table_left[0];
-
-			/* 3D Mode */
-			bridge_i2c_write_w(0x06, 0x03);
-		} else {
-			rc = qs_s5k4e1_write_focus_value(
-				qs_s5k4e1_step_position_table[0]);
-			if (rc < 0)
-				return rc;
-			qs_s5k4e1_ctrl->curr_lens_pos =
-				qs_s5k4e1_step_position_table[0];
-		}
-	}
-	CDBG("%s\n", __func__);
-	return 0;
-}
-
-static void qs_s5k4e1_3d_table_init(void)
-{
-	int16_t af_data = 0;
-	uint16_t step = 8, step_q2 = 8, anchor_point_q2;
-	int32_t rc = 0, i, j;
-	uint16_t eeprom_read_addr[2][3] = {{0x110, 0x114, 0x118},
-		{0x112, 0x116, 0x11A} };
-	uint16_t *step_position_table;
-
-	step_position_table = qs_s5k4e1_step_position_table_left;
-	for (j = 0; j < 2; j++) {
-		rc = qs_s5k4e1_eeprom_i2c_read_b(eeprom_read_addr[j][0],
-			&af_data, 2);
-		if (rc == 0) {
-			CDBG("%s: Far data - %d\n", __func__, af_data);
-			step_position_table[0] = af_data;
-		} else {
-			CDBG("%s: EEPROM data read error\n", __func__);
-			return;
-		}
-
-		rc = qs_s5k4e1_eeprom_i2c_read_b(eeprom_read_addr[j][1],
-			&af_data, 2);
-		if (rc == 0) {
-			CDBG("%s: Medium data - %d\n", __func__, af_data);
-			step_position_table[2] = af_data;
-		} else {
-			CDBG("%s: EEPROM data read error\n", __func__);
-			return;
-		}
-
-		/*
-		 * Using the 150cm and 100cm calibration values
-		 * as per the Lens characteristics derive intermediate step
-		 */
-		step_position_table[1] = step_position_table[0] +
-			(step_position_table[2] - step_position_table[0])/2;
-		CDBG("%s: Step between 150cm:100cm is %d\n", __func__,
-			step_position_table[1]);
-
-		rc = qs_s5k4e1_eeprom_i2c_read_b(eeprom_read_addr[j][2],
-			&af_data, 2);
-		if (rc == 0) {
-			CDBG("%s: Short data - %d\n", __func__, af_data);
-			step_position_table[6] = af_data;
-		} else {
-			CDBG("%s: EEPROM data read error\n", __func__);
-			return;
-		}
-
-		/*
-		 * Using the 100cm and 50cm calibration values
-		 * as per the Lens characteristics derive
-		 * intermediate steps
-		 */
-		step = (step_position_table[6] - step_position_table[2])/4;
-
-		/*
-		 * Interpolate the intermediate steps between 100cm
-		 * to 50cm based on COC1.5
-		 */
-		step_position_table[3] = step_position_table[2] + step;
-		step_position_table[4] = step_position_table[3] + step;
-		step_position_table[5] = step_position_table[4] + step;
-
-		/*
-		 * Extrapolate the steps within 50cm based on
-		 * OC2 to converge faster. This range is beyond the 3D
-		 * specification of 50cm
-		 */
-		anchor_point_q2 = step_position_table[6] << 1;
-		step_q2 = (step_position_table[6] - step_position_table[2]);
-
-		for (i = 7; i < QS_S5K4E1_TOTAL_STEPS_3D; i++) {
-			anchor_point_q2 += step_q2;
-			step_position_table[i] = anchor_point_q2 >> 1;
-		}
-		step_position_table = qs_s5k4e1_step_position_table_right;
-	}
-}
-
-static void qs_s5k4e1_init_focus(void)
-{
-	uint8_t i;
-	int32_t rc = 0;
-	int16_t af_far_data = 0;
-	qs_s5k4e1_af_initial_code = 190;
-	/* Read the calibration data from left and right sensors if available */
-	rc = qs_s5k4e1_eeprom_i2c_read_b(0x110, &af_far_data, 2);
-	if (rc == 0) {
-		CDBG("%s: Left Far data - %d\n", __func__, af_far_data);
-		qs_s5k4e1_af_initial_code = af_far_data;
-	}
-
-	rc = qs_s5k4e1_eeprom_i2c_read_b(0x112, &af_far_data, 2);
-	if (rc == 0) {
-		CDBG("%s: Right Far data - %d\n", __func__, af_far_data);
-		qs_s5k4e1_af_right_adjust = af_far_data -
-			qs_s5k4e1_af_initial_code;
-	}
-
-	qs_s5k4e1_3d_table_init();
-
-	qs_s5k4e1_step_position_table[0] = qs_s5k4e1_af_initial_code;
-	for (i = 1; i <= QS_S5K4E1_TOTAL_STEPS_NEAR_TO_FAR; i++) {
-		if (i <= qs_s5k4e1_nl_region_boundary1) {
-			qs_s5k4e1_step_position_table[i] =
-				qs_s5k4e1_step_position_table[i-1]
-				+ qs_s5k4e1_nl_region_code_per_step1;
-		} else {
-			qs_s5k4e1_step_position_table[i] =
-				qs_s5k4e1_step_position_table[i-1]
-				+ qs_s5k4e1_l_region_code_per_step;
-		}
-
-		if (qs_s5k4e1_step_position_table[i] > 1023)
-			qs_s5k4e1_step_position_table[i] = 1023;
-	}
-	qs_s5k4e1_ctrl->curr_step_pos = 0;
-}
-
-static int32_t qs_s5k4e1_test(enum qs_s5k4e1_test_mode_t mo)
-{
-	int32_t rc = 0;
-	if (mo == TEST_OFF)
-		return rc;
-	else {
-		/* REG_0x30D8[4] is TESBYPEN: 0: Normal Operation,
-		1: Bypass Signal Processing
-		REG_0x30D8[5] is EBDMASK: 0:
-		Output Embedded data, 1: No output embedded data */
-		if (qs_s5k4e1_i2c_write_b_sensor(REG_TEST_PATTERN_MODE,
-			(uint8_t) mo) < 0) {
-			return rc;
-		}
-	}
-	return rc;
-}
-
-static int32_t qs_s5k4e1_sensor_setting(int update_type, int rt)
-{
-
-	int32_t rc = 0;
-	struct msm_camera_csi_params qs_s5k4e1_csi_params;
-
-	qs_s5k4e1_stop_stream();
-	msleep(80);
-	bridge_i2c_write_w(0x53, 0x00);
-	msleep(80);
-	if (update_type == REG_INIT) {
-		CSI_CONFIG = 0;
-		LENS_SHADE_CONFIG = 0;
-		default_lens_shade = 0;
-		bridge_i2c_write_w(0x53, 0x01);
-		msleep(30);
-		qs_s5k4e1_bridge_config(qs_s5k4e1_ctrl->cam_mode, rt);
-		msleep(30);
-		qs_s5k4e1_i2c_write_b_table(qs_s5k4e1_regs.rec_settings,
-				qs_s5k4e1_regs.rec_size);
-		msleep(30);
-	} else if (update_type == UPDATE_PERIODIC) {
-		qs_s5k4e1_write_lsc(lens_eeprom_data, rt);
-		msleep(100);
-		if (!CSI_CONFIG) {
-			if (qs_s5k4e1_ctrl->cam_mode == MODE_3D) {
-				qs_s5k4e1_csi_params.lane_cnt = 4;
-				qs_s5k4e1_csi_params.data_format = CSI_8BIT;
-			} else {
-				qs_s5k4e1_csi_params.lane_cnt = 1;
-				qs_s5k4e1_csi_params.data_format = CSI_10BIT;
-			}
-			qs_s5k4e1_csi_params.lane_assign = 0xe4;
-			qs_s5k4e1_csi_params.dpcm_scheme = 0;
-			qs_s5k4e1_csi_params.settle_cnt = 28;
-			rc = msm_camio_csi_config(&qs_s5k4e1_csi_params);
-			msleep(10);
-			cam_debug_init();
-			CSI_CONFIG = 1;
-		}
-		bridge_i2c_write_w(0x53, 0x01);
-		msleep(50);
-		qs_s5k4e1_i2c_write_b_table(qs_s5k4e1_regs.conf_array[rt].conf,
-			qs_s5k4e1_regs.conf_array[rt].size);
-		msleep(50);
-		qs_s5k4e1_start_stream();
-		msleep(80);
-	}
-	return rc;
-}
-
-static int32_t qs_s5k4e1_video_config(int mode)
-{
-
-	int32_t rc = 0;
-	/* change sensor resolution if needed */
-	if (qs_s5k4e1_sensor_setting(UPDATE_PERIODIC,
-			qs_s5k4e1_ctrl->prev_res) < 0)
-		return rc;
-	if (qs_s5k4e1_ctrl->set_test) {
-		if (qs_s5k4e1_test(qs_s5k4e1_ctrl->set_test) < 0)
-			return  rc;
-	}
-
-	qs_s5k4e1_ctrl->curr_res = qs_s5k4e1_ctrl->prev_res;
-	qs_s5k4e1_ctrl->sensormode = mode;
-	return rc;
-}
-
-static int32_t qs_s5k4e1_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-	/*change sensor resolution if needed */
-	if (qs_s5k4e1_ctrl->curr_res != qs_s5k4e1_ctrl->pict_res) {
-		if (qs_s5k4e1_sensor_setting(UPDATE_PERIODIC,
-				qs_s5k4e1_ctrl->pict_res) < 0)
-			return rc;
-	}
-
-	qs_s5k4e1_ctrl->curr_res = qs_s5k4e1_ctrl->pict_res;
-	qs_s5k4e1_ctrl->sensormode = mode;
-	return rc;
-} /*end of qs_s5k4e1_snapshot_config*/
-
-static int32_t qs_s5k4e1_raw_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-	/* change sensor resolution if needed */
-	if (qs_s5k4e1_ctrl->curr_res != qs_s5k4e1_ctrl->pict_res) {
-		if (qs_s5k4e1_sensor_setting(UPDATE_PERIODIC,
-				qs_s5k4e1_ctrl->pict_res) < 0)
-			return rc;
-	}
-
-	qs_s5k4e1_ctrl->curr_res = qs_s5k4e1_ctrl->pict_res;
-	qs_s5k4e1_ctrl->sensormode = mode;
-	return rc;
-} /*end of qs_s5k4e1_raw_snapshot_config*/
-
-static int32_t qs_s5k4e1_mode_init(int mode, struct sensor_init_cfg init_info)
-{
-	int32_t rc = 0;
-	if (mode != qs_s5k4e1_ctrl->cam_mode) {
-		qs_s5k4e1_ctrl->prev_res = init_info.prev_res;
-		qs_s5k4e1_ctrl->pict_res = init_info.pict_res;
-		qs_s5k4e1_ctrl->cam_mode = mode;
-
-		prev_frame_length_lines =
-		((qs_s5k4e1_regs.conf_array[qs_s5k4e1_ctrl->prev_res]\
-			.conf[QS_S5K4E1_FRAME_LENGTH_LINES_H].wdata << 8)
-			| qs_s5k4e1_regs.conf_array[qs_s5k4e1_ctrl->prev_res]\
-			.conf[QS_S5K4E1_FRAME_LENGTH_LINES_L].wdata);
-		prev_line_length_pck =
-		(qs_s5k4e1_regs.conf_array[qs_s5k4e1_ctrl->prev_res]\
-			.conf[QS_S5K4E1_LINE_LENGTH_PCK_H].wdata << 8)
-			| qs_s5k4e1_regs.conf_array[qs_s5k4e1_ctrl->prev_res]\
-			.conf[QS_S5K4E1_LINE_LENGTH_PCK_L].wdata;
-		snap_frame_length_lines =
-		(qs_s5k4e1_regs.conf_array[qs_s5k4e1_ctrl->pict_res]\
-			.conf[QS_S5K4E1_FRAME_LENGTH_LINES_H].wdata << 8)
-			| qs_s5k4e1_regs.conf_array[qs_s5k4e1_ctrl->pict_res]\
-			.conf[QS_S5K4E1_FRAME_LENGTH_LINES_L].wdata;
-		snap_line_length_pck =
-		(qs_s5k4e1_regs.conf_array[qs_s5k4e1_ctrl->pict_res]\
-			.conf[QS_S5K4E1_LINE_LENGTH_PCK_H].wdata << 8)
-			| qs_s5k4e1_regs.conf_array[qs_s5k4e1_ctrl->pict_res]\
-			.conf[QS_S5K4E1_LINE_LENGTH_PCK_L].wdata;
-
-	rc = qs_s5k4e1_sensor_setting(REG_INIT,
-		qs_s5k4e1_ctrl->prev_res);
-	}
-	return rc;
-}
-static int32_t qs_s5k4e1_set_sensor_mode(int mode,
-	int res)
-{
-	int32_t rc = 0;
-	switch (mode) {
-	case SENSOR_PREVIEW_MODE:
-		qs_s5k4e1_ctrl->prev_res = res;
-		rc = qs_s5k4e1_video_config(mode);
-		break;
-	case SENSOR_SNAPSHOT_MODE:
-		qs_s5k4e1_ctrl->pict_res = res;
-		rc = qs_s5k4e1_snapshot_config(mode);
-		break;
-	case SENSOR_RAW_SNAPSHOT_MODE:
-		qs_s5k4e1_ctrl->pict_res = res;
-		rc = qs_s5k4e1_raw_snapshot_config(mode);
-		break;
-	default:
-		rc = -EINVAL;
-		break;
-	}
-	return rc;
-}
-
-static int32_t qs_s5k4e1_power_down(void)
-{
-	qs_s5k4e1_stop_stream();
-	msleep(30);
-	qs_s5k4e1_af_mode = 2;
-	qs_s5k4e1_af_right_adjust = 0;
-	qs_s5k4e1_write_focus_value(0);
-	msleep(100);
-	/* Set AF actutator to PowerDown */
-	af_i2c_write_b_sensor(0x80, 00);
-	return 0;
-}
-
-static int qs_s5k4e1_probe_init_done(const struct msm_camera_sensor_info *data)
-{
-	CDBG("probe done\n");
-	gpio_free(data->sensor_reset);
-	return 0;
-}
-
-static int
-	qs_s5k4e1_probe_init_sensor(const struct msm_camera_sensor_info *data)
-{
-	int32_t rc = 0;
-	uint16_t chipid = 0;
-	CDBG("%s: %d\n", __func__, __LINE__);
-	rc = gpio_request(data->sensor_reset, "qs_s5k4e1");
-	CDBG(" qs_s5k4e1_probe_init_sensor\n");
-	if (!rc) {
-		CDBG("sensor_reset = %d\n", rc);
-		gpio_direction_output(data->sensor_reset, 0);
-		msleep(50);
-		gpio_set_value_cansleep(data->sensor_reset, 1);
-		msleep(13);
-	} else {
-		goto init_probe_done;
-	}
-	msleep(70);
-	rc = qs_s5k4e1_bridge_reset();
-	if (rc < 0)
-		goto init_probe_fail;
-	qs_s5k4e1_bridge_config(MODE_3D, RES_PREVIEW);
-	msleep(30);
-
-	CDBG(" qs_s5k4e1_probe_init_sensor is called\n");
-	rc = qs_s5k4e1_i2c_read(0x0000, &chipid, 2);
-	CDBG("ID: %d\n", chipid);
-	/* 4. Compare sensor ID to QS_S5K4E1 ID: */
-	if (chipid != 0x4e10) {
-		rc = -ENODEV;
-		CDBG("qs_s5k4e1_probe_init_sensor fail chip id mismatch\n");
-		goto init_probe_fail;
-	}
-	goto init_probe_done;
-init_probe_fail:
-	CDBG(" qs_s5k4e1_probe_init_sensor fails\n");
-	gpio_set_value_cansleep(data->sensor_reset, 0);
-	qs_s5k4e1_probe_init_done(data);
-init_probe_done:
-	CDBG(" qs_s5k4e1_probe_init_sensor finishes\n");
-	return rc;
-}
-/* camsensor_qs_s5k4e1_reset */
-
-int qs_s5k4e1_sensor_open_init(const struct msm_camera_sensor_info *data)
-{
-	int32_t rc = 0;
-	CDBG("%s: %d\n", __func__, __LINE__);
-	CDBG("Calling qs_s5k4e1_sensor_open_init\n");
-
-	qs_s5k4e1_ctrl = kzalloc(sizeof(struct qs_s5k4e1_ctrl_t), GFP_KERNEL);
-	if (!qs_s5k4e1_ctrl) {
-		CDBG("qs_s5k4e1_init failed!\n");
-		rc = -ENOMEM;
-		goto init_done;
-	}
-	qs_s5k4e1_ctrl->fps_divider = 1 * 0x00000400;
-	qs_s5k4e1_ctrl->pict_fps_divider = 1 * 0x00000400;
-	qs_s5k4e1_ctrl->set_test = TEST_OFF;
-	qs_s5k4e1_ctrl->cam_mode = MODE_INVALID;
-
-	if (data)
-		qs_s5k4e1_ctrl->sensordata = data;
-	if (rc < 0) {
-		CDBG("Calling qs_s5k4e1_sensor_open_init fail1\n");
-		return rc;
-	}
-	CDBG("%s: %d\n", __func__, __LINE__);
-	/* enable mclk first */
-	msm_camio_clk_rate_set(QS_S5K4E1_MASTER_CLK_RATE);
-	rc = qs_s5k4e1_probe_init_sensor(data);
-	if (rc < 0)
-		goto init_fail;
-/*Default mode is 3D*/
-	memcpy(lens_eeprom_data, data->eeprom_data, 864);
-	qs_s5k4e1_ctrl->fps = 30*Q8;
-	qs_s5k4e1_init_focus();
-	if (rc < 0) {
-		gpio_set_value_cansleep(data->sensor_reset, 0);
-		goto init_fail;
-	} else
-		goto init_done;
-init_fail:
-	CDBG("init_fail\n");
-	qs_s5k4e1_probe_init_done(data);
-init_done:
-	CDBG("init_done\n");
-	return rc;
-} /*endof qs_s5k4e1_sensor_open_init*/
-
-static int qs_s5k4e1_init_client(struct i2c_client *client)
-{
-	/* Initialize the MSM_CAMI2C Chip */
-	init_waitqueue_head(&qs_s5k4e1_wait_queue);
-	return 0;
-}
-
-static const struct i2c_device_id qs_s5k4e1_i2c_id[] = {
-	{"qs_s5k4e1", 0},
-	{ }
-};
-
-static int qs_s5k4e1_i2c_probe(struct i2c_client *client,
-	const struct i2c_device_id *id)
-{
-	int rc = 0;
-	CDBG("qs_s5k4e1_probe called!\n");
-
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		CDBG("i2c_check_functionality failed\n");
-		goto probe_failure;
-	}
-
-	qs_s5k4e1_sensorw = kzalloc(sizeof(struct qs_s5k4e1_work_t),
-		 GFP_KERNEL);
-	if (!qs_s5k4e1_sensorw) {
-		CDBG("kzalloc failed.\n");
-		rc = -ENOMEM;
-		goto probe_failure;
-	}
-
-	i2c_set_clientdata(client, qs_s5k4e1_sensorw);
-	qs_s5k4e1_init_client(client);
-	qs_s5k4e1_client = client;
-
-	msleep(50);
-
-	CDBG("qs_s5k4e1_probe successed! rc = %d\n", rc);
-	return 0;
-
-probe_failure:
-	CDBG("qs_s5k4e1_probe failed! rc = %d\n", rc);
-	return rc;
-}
-
-static int qs_s5k4e1_send_wb_info(struct wb_info_cfg *wb)
-{
-	return 0;
-
-} /*end of qs_s5k4e1_snapshot_config*/
-
-static int __exit qs_s5k4e1_remove(struct i2c_client *client)
-{
-	struct qs_s5k4e1_work_t_t *sensorw = i2c_get_clientdata(client);
-	free_irq(client->irq, sensorw);
-	qs_s5k4e1_client = NULL;
-	kfree(sensorw);
-	return 0;
-}
-
-static struct i2c_driver qs_s5k4e1_i2c_driver = {
-	.id_table = qs_s5k4e1_i2c_id,
-	.probe  = qs_s5k4e1_i2c_probe,
-	.remove = __exit_p(qs_s5k4e1_i2c_remove),
-	.driver = {
-		.name = "qs_s5k4e1",
-	},
-};
-
-int qs_s5k4e1_3D_sensor_config(void __user *argp)
-{
-	struct sensor_large_data cdata;
-	long rc;
-	if (copy_from_user(&cdata,
-		(void *)argp,
-		sizeof(struct sensor_large_data)))
-		return -EFAULT;
-	mutex_lock(&qs_s5k4e1_mut);
-	rc = qs_s5k4e1_get_calibration_data
-		(&cdata.data.sensor_3d_cali_data);
-	if (rc < 0)
-		goto fail;
-	if (copy_to_user((void *)argp,
-		&cdata,
-		sizeof(struct sensor_large_data)))
-		rc = -EFAULT;
-fail:
-	mutex_unlock(&qs_s5k4e1_mut);
-	return rc;
-}
-
-int qs_s5k4e1_2D_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(&qs_s5k4e1_mut);
-	CDBG("qs_s5k4e1_sensor_config: cfgtype = %d\n",
-	cdata.cfgtype);
-		switch (cdata.cfgtype) {
-		case CFG_GET_PICT_FPS:
-			qs_s5k4e1_get_pict_fps(
-				cdata.cfg.gfps.prevfps,
-				&(cdata.cfg.gfps.pictfps));
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_GET_PREV_L_PF:
-			cdata.cfg.prevl_pf =
-			qs_s5k4e1_get_prev_lines_pf();
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_GET_PREV_P_PL:
-			cdata.cfg.prevp_pl =
-				qs_s5k4e1_get_prev_pixels_pl();
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_GET_PICT_L_PF:
-			cdata.cfg.pictl_pf =
-				qs_s5k4e1_get_pict_lines_pf();
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_GET_PICT_P_PL:
-			cdata.cfg.pictp_pl =
-				qs_s5k4e1_get_pict_pixels_pl();
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_GET_PICT_MAX_EXP_LC:
-			cdata.cfg.pict_max_exp_lc =
-				qs_s5k4e1_get_pict_max_exp_lc();
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_SET_FPS:
-		case CFG_SET_PICT_FPS:
-			rc = qs_s5k4e1_set_fps(&(cdata.cfg.fps));
-			break;
-
-		case CFG_SET_EXP_GAIN:
-			rc =
-				qs_s5k4e1_write_exp_gain(
-					cdata.cfg.sensor_3d_exp);
-			break;
-
-		case CFG_SET_PICT_EXP_GAIN:
-			rc =
-				qs_s5k4e1_set_pict_exp_gain(
-				cdata.cfg.sensor_3d_exp);
-			break;
-
-		case CFG_SET_MODE:
-			rc = qs_s5k4e1_set_sensor_mode(cdata.mode,
-					cdata.rs);
-			break;
-
-		case CFG_PWR_DOWN:
-			rc = qs_s5k4e1_power_down();
-			break;
-
-		case CFG_MOVE_FOCUS:
-			rc =
-				qs_s5k4e1_move_focus(
-				cdata.cfg.focus.dir,
-				cdata.cfg.focus.steps);
-			break;
-
-		case CFG_SET_DEFAULT_FOCUS:
-			rc =
-				qs_s5k4e1_set_default_focus(
-				cdata.cfg.focus.steps);
-			break;
-
-		case CFG_GET_AF_MAX_STEPS:
-			if (qs_s5k4e1_ctrl->cam_mode == MODE_3D)
-				cdata.max_steps = QS_S5K4E1_TOTAL_STEPS_3D;
-			else
-				cdata.max_steps =
-					QS_S5K4E1_TOTAL_STEPS_NEAR_TO_FAR;
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_SET_EFFECT:
-			rc = qs_s5k4e1_set_default_focus(
-				cdata.cfg.effect);
-			break;
-
-
-		case CFG_SEND_WB_INFO:
-			rc = qs_s5k4e1_send_wb_info(
-				&(cdata.cfg.wb_info));
-			break;
-
-		case CFG_SENSOR_INIT:
-			rc = qs_s5k4e1_mode_init(cdata.mode,
-					cdata.cfg.init_info);
-			break;
-
-		default:
-			rc = -EFAULT;
-			break;
-		}
-
-	mutex_unlock(&qs_s5k4e1_mut);
-
-	return rc;
-}
-
-int qs_s5k4e1_sensor_config(void __user *argp)
-{
-	int cfgtype;
-	long rc;
-	if (copy_from_user(&cfgtype,
-		(void *)argp,
-		sizeof(int)))
-		return -EFAULT;
-	if (cfgtype != CFG_GET_3D_CALI_DATA)
-		rc = qs_s5k4e1_2D_sensor_config(argp);
-	else
-		rc = qs_s5k4e1_3D_sensor_config(argp);
-	return rc;
-}
-
-static int qs_s5k4e1_sensor_release(void)
-{
-	int rc = -EBADF;
-	mutex_lock(&qs_s5k4e1_mut);
-	qs_s5k4e1_power_down();
-	bridge_i2c_write_w(0x53, 0x00);
-	msleep(20);
-	gpio_set_value_cansleep(qs_s5k4e1_ctrl->sensordata->sensor_reset, 0);
-	msleep(5);
-	gpio_free(qs_s5k4e1_ctrl->sensordata->sensor_reset);
-	kfree(qs_s5k4e1_ctrl);
-	qs_s5k4e1_ctrl = NULL;
-	CDBG("qs_s5k4e1_release completed\n");
-	mutex_unlock(&qs_s5k4e1_mut);
-
-	return rc;
-}
-
-static int qs_s5k4e1_sensor_probe(const struct msm_camera_sensor_info *info,
-		struct msm_sensor_ctrl *s)
-{
-	int rc = 0;
-	rc = i2c_add_driver(&qs_s5k4e1_i2c_driver);
-	if (rc < 0 || qs_s5k4e1_client == NULL) {
-		rc = -ENOTSUPP;
-		CDBG("I2C add driver failed");
-		goto probe_fail;
-	}
-	msm_camio_clk_rate_set(QS_S5K4E1_MASTER_CLK_RATE);
-	rc = qs_s5k4e1_probe_init_sensor(info);
-	if (rc < 0)
-		goto probe_fail;
-	qs_s5k4e1_read_lsc(info->eeprom_data); /*Default mode is 3D*/
-	s->s_init = qs_s5k4e1_sensor_open_init;
-	s->s_release = qs_s5k4e1_sensor_release;
-	s->s_config  = qs_s5k4e1_sensor_config;
-	s->s_mount_angle = info->sensor_platform_info->mount_angle;
-	s->s_camera_type = BACK_CAMERA_3D;
-	s->s_video_packing = SIDE_BY_SIDE_HALF;
-	s->s_snap_packing = SIDE_BY_SIDE_FULL;
-	bridge_i2c_write_w(0x53, 0x00);
-	msleep(20);
-	gpio_set_value_cansleep(info->sensor_reset, 0);
-	qs_s5k4e1_probe_init_done(info);
-	return rc;
-
-probe_fail:
-	CDBG("qs_s5k4e1_sensor_probe: SENSOR PROBE FAILS!\n");
-	return rc;
-}
-
-static bool streaming = 1;
-
-static int qs_s5k4e1_focus_test(void *data, u64 *val)
-{
-	int i = 0;
-	qs_s5k4e1_set_default_focus(0);
-
-	for (i = 0; i < QS_S5K4E1_TOTAL_STEPS_NEAR_TO_FAR; i++) {
-		qs_s5k4e1_move_focus(MOVE_NEAR, 1);
-		msleep(2000);
-	}
-	msleep(5000);
-	for ( ; i > 0; i--) {
-		qs_s5k4e1_move_focus(MOVE_FAR, 1);
-		msleep(2000);
-	}
-	return 0;
-}
-
-DEFINE_SIMPLE_ATTRIBUTE(cam_focus, qs_s5k4e1_focus_test,
-			NULL, "%lld\n");
-
-static int qs_s5k4e1_step_test(void *data, u64 *val)
-{
-	int rc = 0;
-	struct sensor_large_data cdata;
-	rc = qs_s5k4e1_get_calibration_data
-		(&cdata.data.sensor_3d_cali_data);
-	if (rc < 0)
-		CDBG("%s: Calibration data read fail.\n", __func__);
-
-	return 0;
-}
-
-static int qs_s5k4e1_set_step(void *data, u64 val)
-{
-	qs_s5k4e1_l_region_code_per_step = val & 0xFF;
-	qs_s5k4e1_af_mode = (val >> 8) & 0xFF;
-	qs_s5k4e1_nl_region_code_per_step1 = (val >> 16) & 0xFFFF;
-
-	return 0;
-}
-
-DEFINE_SIMPLE_ATTRIBUTE(cam_step, qs_s5k4e1_step_test,
-			qs_s5k4e1_set_step, "%lld\n");
-
-static int cam_debug_stream_set(void *data, u64 val)
-{
-	int rc = 0;
-
-	if (val) {
-		qs_s5k4e1_start_stream();
-		streaming = 1;
-	} else {
-		qs_s5k4e1_stop_stream();
-		streaming = 0;
-	}
-
-	return rc;
-}
-
-static int cam_debug_stream_get(void *data, u64 *val)
-{
-	*val = streaming;
-	return 0;
-}
-DEFINE_SIMPLE_ATTRIBUTE(cam_stream, cam_debug_stream_get,
-			cam_debug_stream_set, "%llu\n");
-
-static uint16_t qs_s5k4e1_step_val = QS_S5K4E1_TOTAL_STEPS_NEAR_TO_FAR;
-static uint8_t qs_s5k4e1_step_dir = MOVE_NEAR;
-static int qs_s5k4e1_af_step_config(void *data, u64 val)
-{
-	qs_s5k4e1_step_val = val & 0xFFFF;
-	qs_s5k4e1_step_dir = (val >> 16) & 0x1;
-	CDBG("%s\n", __func__);
-	return 0;
-}
-
-static int qs_s5k4e1_af_step(void *data, u64 *val)
-{
-	int i = 0;
-	int dir = MOVE_NEAR;
-	CDBG("%s\n", __func__);
-	qs_s5k4e1_set_default_focus(0);
-	msleep(5000);
-	if (qs_s5k4e1_step_dir == 1)
-		dir = MOVE_FAR;
-
-	for (i = 0; i < qs_s5k4e1_step_val; i += 4) {
-		qs_s5k4e1_move_focus(dir, 4);
-		msleep(1000);
-	}
-	qs_s5k4e1_set_default_focus(0);
-	return 0;
-}
-
-DEFINE_SIMPLE_ATTRIBUTE(af_step, qs_s5k4e1_af_step,
-			qs_s5k4e1_af_step_config, "%llu\n");
-
-static int cam_debug_init(void)
-{
-	struct dentry *cam_dir;
-	debugfs_base = debugfs_create_dir("sensor", NULL);
-	if (!debugfs_base)
-		return -ENOMEM;
-
-	cam_dir = debugfs_create_dir("qs_s5k4e1", debugfs_base);
-	if (!cam_dir)
-		return -ENOMEM;
-
-	if (!debugfs_create_file("focus", S_IRUGO | S_IWUSR, cam_dir,
-							 NULL, &cam_focus))
-		return -ENOMEM;
-	if (!debugfs_create_file("step", S_IRUGO | S_IWUSR, cam_dir,
-							 NULL, &cam_step))
-		return -ENOMEM;
-	if (!debugfs_create_file("stream", S_IRUGO | S_IWUSR, cam_dir,
-							 NULL, &cam_stream))
-		return -ENOMEM;
-	if (!debugfs_create_file("af_step", S_IRUGO | S_IWUSR, cam_dir,
-							 NULL, &af_step))
-		return -ENOMEM;
-	return 0;
-}
-
-static int __qs_s5k4e1_probe(struct platform_device *pdev)
-{
-	return msm_camera_drv_start(pdev, qs_s5k4e1_sensor_probe);
-}
-
-static struct platform_driver msm_camera_driver = {
-	.probe = __qs_s5k4e1_probe,
-	.driver = {
-		.name = "msm_camera_qs_s5k4e1",
-	.owner = THIS_MODULE,
-	},
-};
-
-static int __init qs_s5k4e1_init(void)
-{
-	return platform_driver_register(&msm_camera_driver);
-}
-
-module_init(qs_s5k4e1_init);
-void qs_s5k4e1_exit(void)
-{
-	i2c_del_driver(&qs_s5k4e1_i2c_driver);
-}
-MODULE_DESCRIPTION("Samsung 5MP Bayer sensor driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/qs_s5k4e1.h b/drivers/media/platform/msm/camera_v1/qs_s5k4e1.h
deleted file mode 100644
index dca3d0a..0000000
--- a/drivers/media/platform/msm/camera_v1/qs_s5k4e1.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- *
- */
-
-#ifndef QS_S5K4E1_H
-#define QS_S5K4E1_H
-#include <linux/types.h>
-#include <mach/board.h>
-extern struct qs_s5k4e1_reg qs_s5k4e1_regs;
-
-#define LENS_SHADE_TABLE 16
-
-struct qs_s5k4e1_i2c_reg_conf {
-	unsigned short waddr;
-	unsigned short wdata;
-};
-
-struct qs_s5k4e1_i2c_conf_array {
-       struct qs_s5k4e1_i2c_reg_conf *conf;
-       unsigned short size;
-};
-
-enum qs_s5k4e1_test_mode_t {
-	TEST_OFF,
-	TEST_1,
-	TEST_2,
-	TEST_3
-};
-
-enum qs_s5k4e1_resolution_t {
-	QTR_2D_SIZE,
-	FULL_2D_SIZE,
-	QTR_3D_SIZE,
-	FULL_3D_SIZE,
-	INVALID_SIZE
-};
-enum qs_s5k4e1_setting {
-	RES_PREVIEW,
-	RES_CAPTURE,
-	RES_3D_PREVIEW,
-	RES_3D_CAPTURE
-};
-enum qs_s5k4e1_cam_mode_t {
-    MODE_2D_RIGHT,
-	MODE_2D_LEFT,
-	MODE_3D,
-	MODE_INVALID
-};
-enum qs_s5k4e1_reg_update {
-	/* Sensor egisters that need to be updated during initialization */
-	REG_INIT,
-	/* Sensor egisters that needs periodic I2C writes */
-	UPDATE_PERIODIC,
-	/* All the sensor Registers will be updated */
-	UPDATE_ALL,
-	/* Not valid update */
-	UPDATE_INVALID
-};
-
-enum qs_s5k4e1_reg_mode {
-	QS_S5K4E1_FRAME_LENGTH_LINES_H = 1,
-	QS_S5K4E1_FRAME_LENGTH_LINES_L,
-	QS_S5K4E1_LINE_LENGTH_PCK_H,
-	QS_S5K4E1_LINE_LENGTH_PCK_L,
-};
-
-struct qs_s5k4e1_reg {
-	const struct qs_s5k4e1_i2c_reg_conf *rec_settings;
-	const unsigned short rec_size;
-	const struct qs_s5k4e1_i2c_reg_conf *reg_prev;
-	const unsigned short reg_prev_size;
-	const struct qs_s5k4e1_i2c_reg_conf *reg_snap;
-	const unsigned short reg_snap_size;
-	const struct qs_s5k4e1_i2c_reg_conf (*reg_lens)[LENS_SHADE_TABLE];
-	const unsigned short reg_lens_size;
-	const struct qs_s5k4e1_i2c_reg_conf *reg_default_lens;
-	const unsigned short reg_default_lens_size;
-	const struct qs_s5k4e1_i2c_conf_array *conf_array;
-};
-#endif /* QS_S5K4E1_H */
diff --git a/drivers/media/platform/msm/camera_v1/qs_s5k4e1_reg.c b/drivers/media/platform/msm/camera_v1/qs_s5k4e1_reg.c
deleted file mode 100644
index b872343..0000000
--- a/drivers/media/platform/msm/camera_v1/qs_s5k4e1_reg.c
+++ /dev/null
@@ -1,804 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- *
- */
-
-
-#include "qs_s5k4e1.h"
-
-struct qs_s5k4e1_i2c_reg_conf qs_s5k4e1_prev_settings_3d[] = {
-	{0x0100, 0x00},
-	/*Frame Length*/
-	{0x0340, 0x04},
-	{0x0341, 0x90},
-	/*Line Length*/
-	{0x0342, 0x0A},
-	{0x0343, 0xB2},
-	{0x3030, 0x06},
-	{0x3017, 0xA4},
-	{0x301B, 0x88},
-	{0x30BC, 0x90},
-	{0x301C, 0x04},
-	{0x0202, 0x04},
-	{0x0203, 0x12},
-	{0x0204, 0x00},
-	{0x0205, 0x80},
-	{0x0306, 0x00},
-	{0x0307, 0x60},
-	{0x30B5, 0x01},
-	{0x30E2, 0x02},/*num lanes[1:0] = 1*/
-	{0x30F1, 0x60},
-/*MIPI Size Setting*/
-	{0x30A9, 0x02},
-	{0x300E, 0xE8},
-	{0x0387, 0x01},
-	{0x0344, 0x01},
-	{0x0345, 0x18},
-	{0x0348, 0x09},
-	{0x0349, 0x17},
-	{0x0346, 0x01},
-	{0x0347, 0x94},
-	{0x034A, 0x06},
-	{0x034B, 0x13},
-	{0x0380, 0x00},
-	{0x0381, 0x01},
-	{0x0382, 0x00},
-	{0x0383, 0x01},
-	{0x0384, 0x00},
-	{0x0385, 0x01},
-	{0x0386, 0x00},
-	{0x0387, 0x01},
-	{0x034C, 0x04},
-	{0x034D, 0x00},
-	{0x034E, 0x04},
-	{0x034F, 0x80},
-	{0x30BF, 0xAA},
-	{0x30C0, 0x40},
-	{0x30C8, 0x04},
-	{0x30C9, 0x00},
-};
-
-struct qs_s5k4e1_i2c_reg_conf qs_s5k4e1_prev_settings_2d[] = {
-	{0x0100, 0x00},
-	{0x0340, 0x03},
-	{0x0341, 0xe0},
-	{0x0342, 0x0A},
-	{0x0343, 0xB2},
-	{0x3030, 0x06},
-	{0x301B, 0x83},
-	{0x30BC, 0x98},
-	{0x301C, 0x04},
-	{0x0202, 0x01},
-	{0x0203, 0xFD},
-	{0x0204, 0x00},
-	{0x0205, 0x80},
-	{0x0306, 0x00},
-	{0x0307, 0x64},
-	{0x30B5, 0x00},
-	{0x30E2, 0x01},/*num lanes[1:0] = 1*/
-	{0x30F1, 0xd0},
-	{0x30A9, 0x02},
-	{0x300E, 0xEB},
-	{0x0387, 0x03},
-	{0x0344, 0x00},
-	{0x0345, 0x00},
-	{0x0348, 0x0A},
-	{0x0349, 0x2F},
-	{0x0346, 0x00},
-	{0x0347, 0x00},
-	{0x034A, 0x07},
-	{0x034B, 0xA7},
-	{0x0380, 0x00},
-	{0x0381, 0x01},
-	{0x0382, 0x00},
-	{0x0383, 0x01},
-	{0x0384, 0x00},
-	{0x0385, 0x01},
-	{0x0386, 0x00},
-	{0x0387, 0x03},
-	{0x034C, 0x05},
-	{0x034D, 0x10},
-	{0x034E, 0x03},
-	{0x034F, 0xd4},
-	{0x30BF, 0xAB},
-	{0x30C0, 0xc0},
-	{0x30C8, 0x06},
-	{0x30C9, 0x54},
-};
-
-struct qs_s5k4e1_i2c_reg_conf qs_s5k4e1_snap_settings_2d[] = {
-	{0x0100, 0x00},
-	{0x0340, 0x07},
-	{0x0341, 0xb4},
-	{0x0342, 0x0A},
-	{0x0343, 0xB2},
-	{0x3030, 0x06}, /*shut streaming off*/
-	{0x300E, 0xE8},
-	{0x301B, 0x75},
-	{0x301C, 0x04},
-	{0x30BC, 0x98},
-	{0x0202, 0x04},
-	{0x0203, 0x12},
-	{0x0204, 0x00},
-	{0x0205, 0x80},
-	{0x0306, 0x00},
-	{0x0307, 0x64},
-	{0x30B5, 0x00},
-	{0x30E2, 0x01},/*num lanes[1:0] = 1*/
-	{0x30F1, 0xd0},
-	{0x30A9, 0x03},/*Horizontal Binning Off*/
-	{0x300E, 0xE8},/*Vertical Binning Off*/
-	{0x0387, 0x01},/*y_odd_inc*/
-	{0x034C, 0x0A},/*x_output size*/
-	{0x034D, 0x30},
-	{0x034E, 0x07},/*y_output size*/
-	{0x034F, 0xA8},
-	{0x30BF, 0xAB},/*outif_enable[7], data_type[5:0](2Bh = bayer 10bit)*/
-	{0x30C0, 0x86},/*video_offset[7:4] 3260%12*/
-	{0x30C8, 0x0C},/*video_data_length 3260 = 2608 * 1.25*/
-	{0x30C9, 0xBC},
-
-};
-
-struct qs_s5k4e1_i2c_reg_conf qs_s5k4e1_snap_settings_3d[] = {
-	{0x0100, 0x00},
-
-/* Frame Length*/
-	{0x0340, 0x09},
-	{0x0341, 0x20},
-/* Line Length*/
-	{0x0342, 0x0A},
-	{0x0343, 0xB2},
-	{0x3030, 0x06},/*shut streaming off*/
-/*Analog Setting*/
-	{0x3017, 0xA4},
-	{0x301B, 0x88},
-	{0x30BC, 0x90},
-	{0x301C, 0x04},
-/*Integration setting ... */
-	{0x0202, 0x04},
-	{0x0203, 0x12},
-	{0x0204, 0x00},
-	{0x0205, 0x80},
-/*PLL setting ...*/
-	{0x0306, 0x00},
-	{0x0307, 0x60},
-	{0x30B5, 0x01},
-	{0x30E2, 0x02},/*num lanes[1:0] = 1*/
-	{0x30F1, 0x60},
-/*MIPI Size Setting*/
-	{0x30A9, 0x01},
-	{0x300E, 0xE8},
-	{0x0387, 0x01},
-	{0x0344, 0x01},/*x_addr_start*/
-	{0x0345, 0x14},
-	{0x0348, 0x09},/*x_addr_end*/
-	{0x0349, 0x17},
-	{0x0346, 0x01},/*y_addr_start*/
-	{0x0347, 0x94},
-	{0x034A, 0x06},/*y_addr_end*/
-	{0x034B, 0x13},
-	{0x0380, 0x00},/*x_even_inc 1*/
-	{0x0381, 0x01},
-	{0x0382, 0x00},/*x_odd_inc 1*/
-	{0x0383, 0x01},
-	{0x0384, 0x00},/*y_even_inc 1*/
-	{0x0385, 0x01},
-	{0x0386, 0x00},/*y_odd_inc 1*/
-	{0x0387, 0x01},
-	{0x034C, 0x08},/*x_output size*/
-	{0x034D, 0x00},
-	{0x034E, 0x04},/*y_output size*/
-	{0x034F, 0x80},
-	{0x30BF, 0xAA},/*outif_enable[7], data_type[5:0](2Bh = bayer 8bit)*/
-	{0x30C0, 0x80},/*video_offset[7:4]*/
-	{0x30C8, 0x08},/*video_data_length*/
-	{0x30C9, 0x00},
-
-};
-
-struct qs_s5k4e1_i2c_reg_conf qs_s5k4e1_recommend_settings[] = {
-	{0x0100, 0x00},
-
-	{0x3030, 0x06},/*shut streaming*/
-/*Analog Setting*/
-	{0x3000, 0x05},
-	{0x3001, 0x03},
-	{0x3002, 0x08},
-	{0x3003, 0x09},
-	{0x3004, 0x2E},
-	{0x3005, 0x06},
-	{0x3006, 0x34},
-	{0x3007, 0x00},
-	{0x3008, 0x3C},
-	{0x3009, 0x3C},
-	{0x300A, 0x28},
-	{0x300B, 0x04},
-	{0x300C, 0x0A},
-	{0x300D, 0x02},
-	{0x300F, 0x82},
-	{0x3010, 0x00},
-	{0x3011, 0x4C},
-	{0x3012, 0x30},
-	{0x3013, 0xC0},
-	{0x3014, 0x00},
-	{0x3015, 0x00},
-	{0x3016, 0x2C},
-	{0x3017, 0x94},
-	{0x3018, 0x78},
-	{0x301D, 0xD4},
-	{0x3021, 0x02},
-	{0x3022, 0x24},
-	{0x3024, 0x40},
-	{0x3027, 0x08},
-	{0x3029, 0xC6},
-	{0x302B, 0x01},
-	{0x30D8, 0x3F},
-/* ADLC setting ...*/
-	{0x3070, 0x5F},
-	{0x3071, 0x00},
-	{0x3080, 0x04},
-	{0x3081, 0x38},
-
-/*MIPI setting*/
-	{0x30BD, 0x00},/*SEL_CCP[0]*/
-	{0x3084, 0x15},/*SYNC Mode*/
-	{0x30BE, 0x1A},/*M_PCLKDIV_AUTO[4], M_DIV_PCLK[3:0]*/
-	{0x30C1, 0x01},/*pack video enable [0]*/
-	{0x30EE, 0x02},/*DPHY enable [1]*/
-	{0x3111, 0x86},/*Embedded data off [5]*/
-/*For MIPI T8 T9*/
-	{0x30E3, 0x38},
-	{0x30E4, 0x40},
-	{0x3113, 0x70},
-	{0x3114, 0x80},
-	{0x3115, 0x7B},
-	{0x3116, 0xC0},
-	{0x30EE, 0x12},
-
-/*PLL setting ...*/
-	{0x0305, 0x06},
-};
-static struct qs_s5k4e1_i2c_reg_conf qs_s5k4e1_default_lenshading_settings[] = {
-
-	{0x3200, 0x00},
-	{0x3201, 0x9a},
-	{0x3202, 0x56},
-	{0x3203, 0xf },
-	{0x3204, 0xd8},
-	{0x3205, 0x94},
-	{0x3206, 0x0 },
-	{0x3207, 0x10},
-	{0x3208, 0x71},
-	{0x3209, 0x0 },
-	{0x320a, 0x9 },
-	{0x320b, 0xc1},
-	{0x320c, 0xf },
-	{0x320d, 0xf1},
-	{0x320e, 0x3d},
-	{0x320f, 0x0 },
-	{0x3210, 0xa },
-	{0x3211, 0x93},
-	{0x3212, 0xf },
-	{0x3213, 0xc9},
-	{0x3214, 0xa1},
-	{0x3215, 0x0 },
-	{0x3216, 0x10},
-	{0x3217, 0x89},
-	{0x3218, 0xf },
-	{0x3219, 0xfb},
-	{0x321a, 0xf3},
-	{0x321b, 0xf },
-	{0x321c, 0xf8},
-	{0x321d, 0xfc},
-	{0x321e, 0x0 },
-	{0x321f, 0x4 },
-	{0x3220, 0xe3},
-	{0x3221, 0xf },
-	{0x3222, 0xfe},
-	{0x3223, 0x94},
-	{0x3224, 0x0 },
-	{0x3225, 0x24},
-	{0x3226, 0x59},
-	{0x3227, 0xf },
-	{0x3228, 0xe9},
-	{0x3229, 0x68},
-	{0x322a, 0xf },
-	{0x322b, 0xfa},
-	{0x322c, 0x7f},
-	{0x322d, 0x0 },
-	{0x322e, 0x13},
-	{0x322f, 0xe1},
-	{0x3230, 0x0 },
-	{0x3231, 0x3 },
-	{0x3232, 0xbc},
-	{0x3233, 0xf },
-	{0x3234, 0xf0},
-	{0x3235, 0xa1},
-	{0x3236, 0xf },
-	{0x3237, 0xf4},
-	{0x3238, 0xc9},
-	{0x3239, 0x0 },
-	{0x323a, 0x11},
-	{0x323b, 0x4b},
-	{0x323c, 0x0 },
-	{0x323d, 0x12},
-	{0x323e, 0xc5},
-	{0x323f, 0xf },
-	{0x3240, 0xe3},
-	{0x3241, 0xb },
-	{0x3242, 0xf },
-	{0x3243, 0xf8},
-	{0x3244, 0x4f},
-	{0x3245, 0x0 },
-	{0x3246, 0x13},
-	{0x3247, 0xac},
-	{0x3248, 0x0 },
-	{0x3249, 0x0 },
-	{0x324a, 0x7c},
-	{0x324b, 0xf },
-	{0x324c, 0xfe},
-	{0x324d, 0xdd},
-	{0x324e, 0xf },
-	{0x324f, 0xf2},
-	{0x3250, 0x96},
-	{0x3251, 0x0 },
-	{0x3252, 0x8 },
-	{0x3253, 0xef},
-	{0x3254, 0x0 },
-	{0x3255, 0x6 },
-	{0x3256, 0xa4},
-	{0x3257, 0x0 },
-	{0x3258, 0x2 },
-	{0x3259, 0x4b},
-	{0x325a, 0x0 },
-	{0x325b, 0x6 },
-	{0x325c, 0x85},
-	{0x325d, 0xf },
-	{0x325e, 0xf8},
-	{0x325f, 0x6a},
-	{0x3260, 0xf },
-	{0x3261, 0xfd},
-	{0x3262, 0x70},
-	{0x3263, 0x0 },
-	{0x3264, 0xd },
-	{0x3265, 0xa9},
-	{0x3266, 0xf },
-	{0x3267, 0xfd},
-	{0x3268, 0xf8},
-	{0x3269, 0xf },
-	{0x326a, 0xec},
-	{0x326b, 0xfc},
-	{0x326c, 0x0 },
-	{0x326d, 0xa7},
-	{0x326e, 0x5 },
-	{0x326f, 0xf },
-	{0x3270, 0xd6},
-	{0x3271, 0x19},
-	{0x3272, 0x0 },
-	{0x3273, 0xa },
-	{0x3274, 0xe8},
-	{0x3275, 0x0 },
-	{0x3276, 0x17},
-	{0x3277, 0x1 },
-	{0x3278, 0xf },
-	{0x3279, 0xe7},
-	{0x327a, 0xa0},
-	{0x327b, 0x0 },
-	{0x327c, 0xb },
-	{0x327d, 0xc3},
-	{0x327e, 0xf },
-	{0x327f, 0xc0},
-	{0x3280, 0xe3},
-	{0x3281, 0x0 },
-	{0x3282, 0x15},
-	{0x3283, 0x5a},
-	{0x3284, 0xf },
-	{0x3285, 0xf9},
-	{0x3286, 0xa0},
-	{0x3287, 0xf },
-	{0x3288, 0xf4},
-	{0x3289, 0xce},
-	{0x328a, 0x0 },
-	{0x328b, 0xb },
-	{0x328c, 0x72},
-	{0x328d, 0xf },
-	{0x328e, 0xfb},
-	{0x328f, 0xb5},
-	{0x3290, 0x0 },
-	{0x3291, 0x2f},
-	{0x3292, 0xb },
-	{0x3293, 0xf },
-	{0x3294, 0xde},
-	{0x3295, 0xc0},
-	{0x3296, 0x0 },
-	{0x3297, 0x0 },
-	{0x3298, 0x58},
-	{0x3299, 0x0 },
-	{0x329a, 0x1b},
-	{0x329b, 0x5 },
-	{0x329c, 0xf },
-	{0x329d, 0xf9},
-	{0x329e, 0x23},
-	{0x329f, 0xf },
-	{0x32a0, 0xf3},
-	{0x32a1, 0x94},
-	{0x32a2, 0xf },
-	{0x32a3, 0xe7},
-	{0x32a4, 0xc2},
-	{0x32a5, 0x0 },
-	{0x32a6, 0x1d},
-	{0x32a7, 0xe5},
-	{0x32a8, 0x0 },
-	{0x32a9, 0x5 },
-	{0x32aa, 0xaf},
-	{0x32ab, 0xf },
-	{0x32ac, 0xe3},
-	{0x32ad, 0xb7},
-	{0x32ae, 0xf },
-	{0x32af, 0xf8},
-	{0x32b0, 0x34},
-	{0x32b1, 0x0 },
-	{0x32b2, 0x1c},
-	{0x32b3, 0x3d},
-	{0x32b4, 0x0 },
-	{0x32b5, 0x10},
-	{0x32b6, 0x4a},
-	{0x32b7, 0xf },
-	{0x32b8, 0xfa},
-	{0x32b9, 0x7 },
-	{0x32ba, 0xf },
-	{0x32bb, 0xff},
-	{0x32bc, 0x16},
-	{0x32bd, 0x0 },
-	{0x32be, 0x5 },
-	{0x32bf, 0x4e},
-	{0x32c0, 0x0 },
-	{0x32c1, 0xc },
-	{0x32c2, 0x1b},
-	{0x32c3, 0xf },
-	{0x32c4, 0xf1},
-	{0x32c5, 0xdb},
-	{0x32c6, 0xf },
-	{0x32c7, 0xfc},
-	{0x32c8, 0xf8},
-	{0x32c9, 0xf },
-	{0x32ca, 0xf4},
-	{0x32cb, 0xad},
-	{0x32cc, 0xf },
-	{0x32cd, 0xfb},
-	{0x32ce, 0x59},
-	{0x32cf, 0x0 },
-	{0x32d0, 0x9 },
-	{0x32d1, 0xf7},
-	{0x32d2, 0x0 },
-	{0x32d3, 0x0 },
-	{0x32d4, 0xc1},
-	{0x32d5, 0xf },
-	{0x32d6, 0xf5},
-	{0x32d7, 0x30},
-	{0x32d8, 0x0 },
-	{0x32d9, 0x83},
-	{0x32da, 0x1d},
-	{0x32db, 0xf },
-	{0x32dc, 0xe3},
-	{0x32dd, 0x3c},
-	{0x32de, 0x0 },
-	{0x32df, 0xa },
-	{0x32e0, 0x10},
-	{0x32e1, 0x0 },
-	{0x32e2, 0x7 },
-	{0x32e3, 0x65},
-	{0x32e4, 0xf },
-	{0x32e5, 0xfe},
-	{0x32e6, 0x79},
-	{0x32e7, 0xf },
-	{0x32e8, 0xfd},
-	{0x32e9, 0x57},
-	{0x32ea, 0xf },
-	{0x32eb, 0xd6},
-	{0x32ec, 0x8f},
-	{0x32ed, 0x0 },
-	{0x32ee, 0x3 },
-	{0x32ef, 0x93},
-	{0x32f0, 0x0 },
-	{0x32f1, 0x6 },
-	{0x32f2, 0xa },
-	{0x32f3, 0xf },
-	{0x32f4, 0xfa},
-	{0x32f5, 0x6c},
-	{0x32f6, 0xf },
-	{0x32f7, 0xf1},
-	{0x32f8, 0x1e},
-	{0x32f9, 0x0 },
-	{0x32fa, 0x14},
-	{0x32fb, 0xe7},
-	{0x32fc, 0x0 },
-	{0x32fd, 0x1f},
-	{0x32fe, 0x2d},
-	{0x32ff, 0x0 },
-	{0x3300, 0x7 },
-	{0x3301, 0x5e},
-	{0x3302, 0xf },
-	{0x3303, 0xe0},
-	{0x3304, 0x55},
-	{0x3305, 0x0 },
-	{0x3306, 0x20},
-	{0x3307, 0x93},
-	{0x3308, 0x0 },
-	{0x3309, 0xf },
-	{0x330a, 0x20},
-	{0x330b, 0xf },
-	{0x330c, 0xd7},
-	{0x330d, 0xf5},
-	{0x330e, 0xf },
-	{0x330f, 0xef},
-	{0x3310, 0xb8},
-	{0x3311, 0xf },
-	{0x3312, 0xf0},
-	{0x3313, 0x29},
-	{0x3314, 0x0 },
-	{0x3315, 0x27},
-	{0x3316, 0x5e},
-	{0x3317, 0xf },
-	{0x3318, 0xda},
-	{0x3319, 0x14},
-	{0x331a, 0xf },
-	{0x331b, 0xef},
-	{0x331c, 0x93},
-	{0x331d, 0x0 },
-	{0x331e, 0x2c},
-	{0x331f, 0xdc},
-	{0x3320, 0x0 },
-	{0x3321, 0xe },
-	{0x3322, 0x2d},
-	{0x3323, 0x0 },
-	{0x3324, 0x6 },
-	{0x3325, 0xcf},
-	{0x3326, 0xf },
-	{0x3327, 0xfb},
-	{0x3328, 0x26},
-	{0x3329, 0x0 },
-	{0x332a, 0x3 },
-	{0x332b, 0x5 },
-	{0x332c, 0x0 },
-	{0x332d, 0x6 },
-	{0x332e, 0xa6},
-	{0x332f, 0xf },
-	{0x3330, 0xf7},
-	{0x3331, 0x7b},
-	{0x3332, 0xf },
-	{0x3333, 0xf9},
-	{0x3334, 0xb },
-	{0x3335, 0x0 },
-	{0x3336, 0x7 },
-	{0x3337, 0x5a},
-	{0x3338, 0xf },
-	{0x3339, 0xe4},
-	{0x333a, 0x7a},
-	{0x333b, 0x0 },
-	{0x333c, 0x1b},
-	{0x333d, 0xb0},
-	{0x333e, 0x0 },
-	{0x333f, 0x2 },
-	{0x3340, 0xa7},
-	{0x3341, 0xf },
-	{0x3342, 0xe9},
-	{0x3343, 0x3a},
-	{0x3344, 0x0 },
-	{0x3345, 0x95},
-	{0x3346, 0x42},
-	{0x3347, 0xf },
-	{0x3348, 0xda},
-	{0x3349, 0x45},
-	{0x334a, 0x0 },
-	{0x334b, 0x16},
-	{0x334c, 0x7a},
-	{0x334d, 0xf },
-	{0x334e, 0xfb},
-	{0x334f, 0x32},
-	{0x3350, 0x0 },
-	{0x3351, 0x6 },
-	{0x3352, 0x35},
-	{0x3353, 0xf },
-	{0x3354, 0xfc},
-	{0x3355, 0x8f},
-	{0x3356, 0xf },
-	{0x3357, 0xca},
-	{0x3358, 0xd5},
-	{0x3359, 0x0 },
-	{0x335a, 0x11},
-	{0x335b, 0x59},
-	{0x335c, 0xf },
-	{0x335d, 0xfa},
-	{0x335e, 0xaa},
-	{0x335f, 0xf },
-	{0x3360, 0xfe},
-	{0x3361, 0x84},
-	{0x3362, 0xf },
-	{0x3363, 0xf6},
-	{0x3364, 0x8f},
-	{0x3365, 0x0 },
-	{0x3366, 0xb },
-	{0x3367, 0x70},
-	{0x3368, 0x0 },
-	{0x3369, 0x25},
-	{0x336a, 0x83},
-	{0x336b, 0xf },
-	{0x336c, 0xe7},
-	{0x336d, 0x27},
-	{0x336e, 0xf },
-	{0x336f, 0xf1},
-	{0x3370, 0x72},
-	{0x3371, 0x0 },
-	{0x3372, 0x21},
-	{0x3373, 0x6d},
-	{0x3374, 0x0 },
-	{0x3375, 0x2 },
-	{0x3376, 0xc3},
-	{0x3377, 0xf },
-	{0x3378, 0xe8},
-	{0x3379, 0x5a},
-	{0x337a, 0xf },
-	{0x337b, 0xf2},
-	{0x337c, 0x73},
-	{0x337d, 0x0 },
-	{0x337e, 0x19},
-	{0x337f, 0xa5},
-	{0x3380, 0x0 },
-	{0x3381, 0x1a},
-	{0x3382, 0x81},
-	{0x3383, 0xf },
-	{0x3384, 0xd0},
-	{0x3385, 0x31},
-	{0x3386, 0xf },
-	{0x3387, 0xfb},
-	{0x3388, 0xff},
-	{0x3389, 0x0 },
-	{0x338a, 0x1e},
-	{0x338b, 0xe1},
-	{0x338c, 0x0 },
-	{0x338d, 0x5 },
-	{0x338e, 0xe1},
-	{0x338f, 0xf },
-	{0x3390, 0xee},
-	{0x3391, 0xe2},
-	{0x3392, 0xf },
-	{0x3393, 0xf6},
-	{0x3394, 0xcf},
-	{0x3395, 0x0 },
-	{0x3396, 0x13},
-	{0x3397, 0x8f},
-	{0x3398, 0x0 },
-	{0x3399, 0x3 },
-	{0x339a, 0x61},
-	{0x339b, 0xf },
-	{0x339c, 0xf8},
-	{0x339d, 0xf7},
-	{0x339e, 0x0 },
-	{0x339f, 0x0 },
-	{0x33a0, 0xb5},
-	{0x33a1, 0x0 },
-	{0x33a2, 0x5 },
-	{0x33a3, 0x78},
-	{0x33a4, 0xf },
-	{0x33a5, 0xf4},
-	{0x33a6, 0x5 },
-	{0x33a7, 0x0 },
-	{0x33a8, 0xc },
-	{0x33a9, 0xe },
-	{0x33aa, 0x0 },
-	{0x33ab, 0x3 },
-	{0x33ac, 0x53},
-	{0x33ad, 0xf },
-	{0x33ae, 0xec},
-	{0x33af, 0xbd},
-};
-
-const struct
-qs_s5k4e1_i2c_reg_conf qs_s5k4e1_lenshading_settings[4][LENS_SHADE_TABLE] = {
-	{/*2D Preview*/
-		{0x3097, 0x52},/*sh4ch_blk_width = 82*/
-		{0x3098, 0x3e},/*sh4ch_blk_height = 62*/
-		{0x3099, 0x03},/*sh4ch_step_x msb (sh4ch_step_x = 799)*/
-		{0x309a, 0x1f},/*sh4ch_step_x lsb*/
-		{0x309b, 0x04},/*sh4ch_step_y msb (sh4ch_step_y = 1057)*/
-		{0x309c, 0x21},/*sh4ch_step_y lsb*/
-		{0x309d, 0x00},/*sh4ch_start_blk_cnt_x = 0*/
-		{0x309e, 0x00},/*sh4ch_start_int_cnt_x = 0*/
-		{0x309f, 0x00},/*sh4ch_start_frac_cnt_x msb (0)*/
-		{0x30a0, 0x00},/*sh4ch_start_frac_cnt_x lsb*/
-		{0x30a1, 0x00},/*sh4ch_start_blk_cnt_y = 0*/
-		{0x30a2, 0x00},/*sh4ch_start_int_cnt_y = 0*/
-		{0x30a3, 0x00},/*sh4ch_start_frac_cnt_y msb (0)*/
-		{0x30a4, 0x00},/*sh4ch_start_frac_cnt_y lsb*/
-		{0x30a5, 0x01},
-		{0x30a6, 0x00},/*gs_pedestal	= 64*/
-	},
-	{/*2D Snapshot*/
-		{0x3097, 0x52},/*sh4ch_blk_width = 82*/
-		{0x3098, 0x7b},/*sh4ch_blk_height = 123*/
-		{0x3099, 0x03},/*sh4ch_step_x msb (sh4ch_step_x = 799)*/
-		{0x309a, 0x1f},/*sh4ch_step_x lsb*/
-		{0x309b, 0x02},/*sh4ch_step_y msb (sh4ch_step_y = 533)*/
-		{0x309c, 0x15},/*sh4ch_step_y lsb*/
-		{0x309d, 0x00},/*sh4ch_start_blk_cnt_x = 0*/
-		{0x309e, 0x00},/*sh4ch_start_int_cnt_x = 0*/
-		{0x309f, 0x00},/*sh4ch_start_frac_cnt_x msb (0)*/
-		{0x30a0, 0x00},/*sh4ch_start_frac_cnt_x lsb*/
-		{0x30a1, 0x00},/*sh4ch_start_blk_cnt_y = 0*/
-		{0x30a2, 0x00},/*sh4ch_start_int_cnt_y = 0*/
-		{0x30a3, 0x00},/*sh4ch_start_frac_cnt_y msb (0)*/
-		{0x30a4, 0x00},/*sh4ch_start_frac_cnt_y lsb*/
-		{0x30a5, 0x01},
-		{0x30a6, 0x00},/*gs_pedestal	= 64*/
-	},
-
-	{/*3D Preview*/
-		{0x3097, 0x52},/*sh4ch_blk_width = 82*/
-		{0x3098, 0x7b},/*sh4ch_blk_height = 123*/
-		{0x3099, 0x03},/*sh4ch_step_x msb (sh4ch_step_x = 799)*/
-		{0x309a, 0x1f},/*sh4ch_step_x lsb*/
-		{0x309b, 0x02},/*sh4ch_step_y msb (sh4ch_step_y = 533)*/
-		{0x309c, 0x15},/*sh4ch_step_y lsb*/
-		{0x309d, 0x3a},/*sh4ch_start_blk_cnt_x = 58*/
-		{0x309e, 0x01},/*sh4ch_start_int_cnt_x = 1*/
-		{0x309f, 0xb5},/*sh4ch_start_frac_cnt_x msb (46342)*/
-		{0x30a0, 0x06},/*sh4ch_start_frac_cnt_x lsb*/
-		{0x30a1, 0x23},/*sh4ch_start_blk_cnt_y = 35*/
-		{0x30a2, 0x03},/*sh4ch_start_int_cnt_y = 3*/
-		{0x30a3, 0x48},/*sh4ch_start_frac_cnt_y msb (46342)*/
-		{0x30a4, 0xdf},/*sh4ch_start_frac_cnt_y lsb*/
-		{0x30a5, 0x01},
-		{0x30a6, 0x00},/*gs_pedestal	= 64*/
-	},
-
-	{/*3D Snapshot*/
-		{0x3097, 0x52},/*sh4ch_blk_width = 82*/
-		{0x3098, 0x7b},/*sh4ch_blk_height = 123*/
-		{0x3099, 0x03},/*sh4ch_step_x msb (sh4ch_step_x = 799)*/
-		{0x309a, 0x1f},/*sh4ch_step_x lsb*/
-		{0x309b, 0x02},/*sh4ch_step_y msb (sh4ch_step_y = 533)*/
-		{0x309c, 0x15},/*sh4ch_step_y lsb*/
-		{0x309d, 0x38},/*sh4ch_start_blk_cnt_x = 56*/
-		{0x309e, 0x01},/*sh4ch_start_int_cnt_x = 1*/
-		{0x309f, 0xae},/*sh4ch_start_frac_cnt_x msb (44744)*/
-		{0x30a0, 0xc8},/*sh4ch_start_frac_cnt_x lsb*/
-		{0x30a1, 0x23},/*sh4ch_start_blk_cnt_y = 35*/
-		{0x30a2, 0x03},/*sh4ch_start_int_cnt_y = 3*/
-		{0x30a3, 0x48},/*sh4ch_start_frac_cnt_y msb (44744)*/
-		{0x30a4, 0xdf},/*sh4ch_start_frac_cnt_y lsb*/
-		{0x30a5, 0x01},
-		{0x30a6, 0x00},/*gs_pedestal	= 64*/
-	},
-
-};
-
-struct qs_s5k4e1_i2c_conf_array qs_s5k4e1_confs[] = {
-	{&qs_s5k4e1_prev_settings_2d[0], \
-		ARRAY_SIZE(qs_s5k4e1_prev_settings_2d)},
-	{&qs_s5k4e1_snap_settings_2d[0], \
-		ARRAY_SIZE(qs_s5k4e1_snap_settings_2d)},
-	{&qs_s5k4e1_prev_settings_3d[0], \
-		ARRAY_SIZE(qs_s5k4e1_prev_settings_3d)},
-	{&qs_s5k4e1_snap_settings_3d[0], \
-		ARRAY_SIZE(qs_s5k4e1_snap_settings_3d)},
-};
-struct qs_s5k4e1_reg qs_s5k4e1_regs = {
-	.rec_settings = &qs_s5k4e1_recommend_settings[0],
-	.rec_size = ARRAY_SIZE(qs_s5k4e1_recommend_settings),
-	.reg_lens = &qs_s5k4e1_lenshading_settings[0],
-	.reg_lens_size = ARRAY_SIZE(qs_s5k4e1_lenshading_settings[0]),
-	.reg_default_lens = &qs_s5k4e1_default_lenshading_settings[0],
-	.reg_default_lens_size =
-		ARRAY_SIZE(qs_s5k4e1_default_lenshading_settings),
-	.conf_array = &qs_s5k4e1_confs[0],
-};
diff --git a/drivers/media/platform/msm/camera_v1/s5k3e2fx.c b/drivers/media/platform/msm/camera_v1/s5k3e2fx.c
deleted file mode 100644
index f7591d9..0000000
--- a/drivers/media/platform/msm/camera_v1/s5k3e2fx.c
+++ /dev/null
@@ -1,1387 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-
-#include <linux/module.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include <linux/types.h>
-#include <linux/i2c.h>
-#include <linux/uaccess.h>
-#include <linux/miscdevice.h>
-#include <media/msm_camera.h>
-#include <mach/gpio.h>
-#include <mach/camera.h>
-#include "s5k3e2fx.h"
-
-#define S5K3E2FX_REG_MODEL_ID   0x0000
-#define S5K3E2FX_MODEL_ID       0x3E2F
-
-/* PLL Registers */
-#define REG_PRE_PLL_CLK_DIV           0x0305
-#define REG_PLL_MULTIPLIER_MSB        0x0306
-#define REG_PLL_MULTIPLIER_LSB        0x0307
-#define REG_VT_PIX_CLK_DIV            0x0301
-#define REG_VT_SYS_CLK_DIV            0x0303
-#define REG_OP_PIX_CLK_DIV            0x0309
-#define REG_OP_SYS_CLK_DIV            0x030B
-
-/* Data Format Registers */
-#define REG_CCP_DATA_FORMAT_MSB       0x0112
-#define REG_CCP_DATA_FORMAT_LSB       0x0113
-
-/* Output Size */
-#define REG_X_OUTPUT_SIZE_MSB         0x034C
-#define REG_X_OUTPUT_SIZE_LSB         0x034D
-#define REG_Y_OUTPUT_SIZE_MSB         0x034E
-#define REG_Y_OUTPUT_SIZE_LSB         0x034F
-
-/* Binning */
-#define REG_X_EVEN_INC                0x0381
-#define REG_X_ODD_INC                 0x0383
-#define REG_Y_EVEN_INC                0x0385
-#define REG_Y_ODD_INC                 0x0387
-/*Reserved register */
-#define REG_BINNING_ENABLE            0x3014
-
-/* Frame Fotmat */
-#define REG_FRAME_LENGTH_LINES_MSB    0x0340
-#define REG_FRAME_LENGTH_LINES_LSB    0x0341
-#define REG_LINE_LENGTH_PCK_MSB       0x0342
-#define REG_LINE_LENGTH_PCK_LSB       0x0343
-
-/* MSR setting */
-/* Reserved registers */
-#define REG_SHADE_CLK_ENABLE          0x30AC
-#define REG_SEL_CCP                   0x30C4
-#define REG_VPIX                      0x3024
-#define REG_CLAMP_ON                  0x3015
-#define REG_OFFSET                    0x307E
-
-/* CDS timing settings */
-/* Reserved registers */
-#define REG_LD_START                  0x3000
-#define REG_LD_END                    0x3001
-#define REG_SL_START                  0x3002
-#define REG_SL_END                    0x3003
-#define REG_RX_START                  0x3004
-#define REG_S1_START                  0x3005
-#define REG_S1_END                    0x3006
-#define REG_S1S_START                 0x3007
-#define REG_S1S_END                   0x3008
-#define REG_S3_START                  0x3009
-#define REG_S3_END                    0x300A
-#define REG_CMP_EN_START              0x300B
-#define REG_CLP_SL_START              0x300C
-#define REG_CLP_SL_END                0x300D
-#define REG_OFF_START                 0x300E
-#define REG_RMP_EN_START              0x300F
-#define REG_TX_START                  0x3010
-#define REG_TX_END                    0x3011
-#define REG_STX_WIDTH                 0x3012
-#define REG_TYPE1_AF_ENABLE           0x3130
-#define DRIVER_ENABLED                0x0001
-#define AUTO_START_ENABLED            0x0010
-#define REG_NEW_POSITION              0x3131
-#define REG_3152_RESERVED             0x3152
-#define REG_315A_RESERVED             0x315A
-#define REG_ANALOGUE_GAIN_CODE_GLOBAL_MSB 0x0204
-#define REG_ANALOGUE_GAIN_CODE_GLOBAL_LSB 0x0205
-#define REG_FINE_INTEGRATION_TIME         0x0200
-#define REG_COARSE_INTEGRATION_TIME       0x0202
-#define REG_COARSE_INTEGRATION_TIME_LSB   0x0203
-
-/* Mode select register */
-#define S5K3E2FX_REG_MODE_SELECT      0x0100
-#define S5K3E2FX_MODE_SELECT_STREAM     0x01   /* start streaming */
-#define S5K3E2FX_MODE_SELECT_SW_STANDBY 0x00   /* software standby */
-#define S5K3E2FX_REG_SOFTWARE_RESET   0x0103
-#define S5K3E2FX_SOFTWARE_RESET         0x01
-#define REG_TEST_PATTERN_MODE         0x0601
-
-struct reg_struct {
-  uint8_t pre_pll_clk_div;               /* 0x0305 */
-  uint8_t pll_multiplier_msb;            /* 0x0306 */
-  uint8_t pll_multiplier_lsb;            /* 0x0307 */
-  uint8_t vt_pix_clk_div;                /* 0x0301 */
-  uint8_t vt_sys_clk_div;                /* 0x0303 */
-  uint8_t op_pix_clk_div;                /* 0x0309 */
-  uint8_t op_sys_clk_div;                /* 0x030B */
-  uint8_t ccp_data_format_msb;           /* 0x0112 */
-  uint8_t ccp_data_format_lsb;           /* 0x0113 */
-  uint8_t x_output_size_msb;             /* 0x034C */
-  uint8_t x_output_size_lsb;             /* 0x034D */
-  uint8_t y_output_size_msb;             /* 0x034E */
-  uint8_t y_output_size_lsb;             /* 0x034F */
-  uint8_t x_even_inc;                    /* 0x0381 */
-  uint8_t x_odd_inc;                     /* 0x0383 */
-  uint8_t y_even_inc;                    /* 0x0385 */
-  uint8_t y_odd_inc;                     /* 0x0387 */
-  uint8_t binning_enable;                /* 0x3014 */
-  uint8_t frame_length_lines_msb;        /* 0x0340 */
-  uint8_t frame_length_lines_lsb;        /* 0x0341 */
-  uint8_t line_length_pck_msb;           /* 0x0342 */
-  uint8_t line_length_pck_lsb;           /* 0x0343 */
-  uint8_t shade_clk_enable ;             /* 0x30AC */
-  uint8_t sel_ccp;                       /* 0x30C4 */
-  uint8_t vpix;                          /* 0x3024 */
-  uint8_t clamp_on;                      /* 0x3015 */
-  uint8_t offset;                        /* 0x307E */
-  uint8_t ld_start;                      /* 0x3000 */
-  uint8_t ld_end;                        /* 0x3001 */
-  uint8_t sl_start;                      /* 0x3002 */
-  uint8_t sl_end;                        /* 0x3003 */
-  uint8_t rx_start;                      /* 0x3004 */
-  uint8_t s1_start;                      /* 0x3005 */
-  uint8_t s1_end;                        /* 0x3006 */
-  uint8_t s1s_start;                     /* 0x3007 */
-  uint8_t s1s_end;                       /* 0x3008 */
-  uint8_t s3_start;                      /* 0x3009 */
-  uint8_t s3_end;                        /* 0x300A */
-  uint8_t cmp_en_start;                  /* 0x300B */
-  uint8_t clp_sl_start;                  /* 0x300C */
-  uint8_t clp_sl_end;                    /* 0x300D */
-  uint8_t off_start;                     /* 0x300E */
-  uint8_t rmp_en_start;                  /* 0x300F */
-  uint8_t tx_start;                      /* 0x3010 */
-  uint8_t tx_end;                        /* 0x3011 */
-  uint8_t stx_width;                     /* 0x3012 */
-  uint8_t reg_3152_reserved;             /* 0x3152 */
-  uint8_t reg_315A_reserved;             /* 0x315A */
-  uint8_t analogue_gain_code_global_msb; /* 0x0204 */
-  uint8_t analogue_gain_code_global_lsb; /* 0x0205 */
-  uint8_t fine_integration_time;         /* 0x0200 */
-  uint8_t coarse_integration_time;       /* 0x0202 */
-  uint32_t  size_h;
-  uint32_t  blk_l;
-  uint32_t  size_w;
-  uint32_t  blk_p;
-};
-
-struct reg_struct s5k3e2fx_reg_pat[2] =  {
-  {	/* Preview */
-    0x06,  /* pre_pll_clk_div       REG=0x0305 */
-    0x00,  /* pll_multiplier_msb    REG=0x0306 */
-    0x88,  /* pll_multiplier_lsb    REG=0x0307 */
-    0x0a,  /* vt_pix_clk_div        REG=0x0301 */
-    0x01,  /* vt_sys_clk_div        REG=0x0303 */
-    0x0a,  /* op_pix_clk_div        REG=0x0309 */
-    0x01,  /* op_sys_clk_div        REG=0x030B */
-    0x0a,  /* ccp_data_format_msb   REG=0x0112 */
-    0x0a,  /* ccp_data_format_lsb   REG=0x0113 */
-    0x05,  /* x_output_size_msb     REG=0x034C */
-    0x10,  /* x_output_size_lsb     REG=0x034D */
-    0x03,  /* y_output_size_msb     REG=0x034E */
-    0xcc,  /* y_output_size_lsb     REG=0x034F */
-
-    /* enable binning for preview */
-    0x01,  /* x_even_inc             REG=0x0381 */
-    0x01,  /* x_odd_inc              REG=0x0383 */
-    0x01,  /* y_even_inc             REG=0x0385 */
-    0x03,  /* y_odd_inc              REG=0x0387 */
-    0x06,  /* binning_enable         REG=0x3014 */
-
-    0x03,  /* frame_length_lines_msb        REG=0x0340 */
-    0xde,  /* frame_length_lines_lsb        REG=0x0341 */
-    0x0a,  /* line_length_pck_msb           REG=0x0342 */
-    0xac,  /* line_length_pck_lsb           REG=0x0343 */
-    0x81,  /* shade_clk_enable              REG=0x30AC */
-    0x01,  /* sel_ccp                       REG=0x30C4 */
-    0x04,  /* vpix                          REG=0x3024 */
-    0x00,  /* clamp_on                      REG=0x3015 */
-    0x02,  /* offset                        REG=0x307E */
-    0x03,  /* ld_start                      REG=0x3000 */
-    0x9c,  /* ld_end                        REG=0x3001 */
-    0x02,  /* sl_start                      REG=0x3002 */
-    0x9e,  /* sl_end                        REG=0x3003 */
-    0x05,  /* rx_start                      REG=0x3004 */
-    0x0f,  /* s1_start                      REG=0x3005 */
-    0x24,  /* s1_end                        REG=0x3006 */
-    0x7c,  /* s1s_start                     REG=0x3007 */
-    0x9a,  /* s1s_end                       REG=0x3008 */
-    0x10,  /* s3_start                      REG=0x3009 */
-    0x14,  /* s3_end                        REG=0x300A */
-    0x10,  /* cmp_en_start                  REG=0x300B */
-    0x04,  /* clp_sl_start                  REG=0x300C */
-    0x26,  /* clp_sl_end                    REG=0x300D */
-    0x02,  /* off_start                     REG=0x300E */
-    0x0e,  /* rmp_en_start                  REG=0x300F */
-    0x30,  /* tx_start                      REG=0x3010 */
-    0x4e,  /* tx_end                        REG=0x3011 */
-    0x1E,  /* stx_width                     REG=0x3012 */
-    0x08,  /* reg_3152_reserved             REG=0x3152 */
-    0x10,  /* reg_315A_reserved             REG=0x315A */
-    0x00,  /* analogue_gain_code_global_msb REG=0x0204 */
-    0x80,  /* analogue_gain_code_global_lsb REG=0x0205 */
-    0x02,  /* fine_integration_time         REG=0x0200 */
-    0x03,  /* coarse_integration_time       REG=0x0202 */
-		972,
-		18,
-		1296,
-		1436
-  },
-  { /* Snapshot */
-    0x06,  /* pre_pll_clk_div               REG=0x0305 */
-    0x00,  /* pll_multiplier_msb            REG=0x0306 */
-    0x88,  /* pll_multiplier_lsb            REG=0x0307 */
-    0x0a,  /* vt_pix_clk_div                REG=0x0301 */
-    0x01,  /* vt_sys_clk_div                REG=0x0303 */
-    0x0a,  /* op_pix_clk_div                REG=0x0309 */
-    0x01,  /* op_sys_clk_div                REG=0x030B */
-    0x0a,  /* ccp_data_format_msb           REG=0x0112 */
-    0x0a,  /* ccp_data_format_lsb           REG=0x0113 */
-    0x0a,  /* x_output_size_msb             REG=0x034C */
-    0x30,  /* x_output_size_lsb             REG=0x034D */
-    0x07,  /* y_output_size_msb             REG=0x034E */
-    0xa8,  /* y_output_size_lsb             REG=0x034F */
-
-    /* disable binning for snapshot */
-    0x01,  /* x_even_inc                    REG=0x0381 */
-    0x01,  /* x_odd_inc                     REG=0x0383 */
-    0x01,  /* y_even_inc                    REG=0x0385 */
-    0x01,  /* y_odd_inc                     REG=0x0387 */
-    0x00,  /* binning_enable                REG=0x3014 */
-
-    0x07,  /* frame_length_lines_msb        REG=0x0340 */
-    0xb6,  /* frame_length_lines_lsb        REG=0x0341 */
-    0x0a,  /* line_length_pck_msb           REG=0x0342 */
-    0xac,  /* line_length_pck_lsb           REG=0x0343 */
-    0x81,  /* shade_clk_enable              REG=0x30AC */
-    0x01,  /* sel_ccp                       REG=0x30C4 */
-    0x04,  /* vpix                          REG=0x3024 */
-    0x00,  /* clamp_on                      REG=0x3015 */
-    0x02,  /* offset                        REG=0x307E */
-    0x03,  /* ld_start                      REG=0x3000 */
-    0x9c,  /* ld_end                        REG=0x3001 */
-    0x02,  /* sl_start                      REG=0x3002 */
-    0x9e,  /* sl_end                        REG=0x3003 */
-    0x05,  /* rx_start                      REG=0x3004 */
-    0x0f,  /* s1_start                      REG=0x3005 */
-    0x24,  /* s1_end                        REG=0x3006 */
-    0x7c,  /* s1s_start                     REG=0x3007 */
-    0x9a,  /* s1s_end                       REG=0x3008 */
-    0x10,  /* s3_start                      REG=0x3009 */
-    0x14,  /* s3_end                        REG=0x300A */
-    0x10,  /* cmp_en_start                  REG=0x300B */
-    0x04,  /* clp_sl_start                  REG=0x300C */
-    0x26,  /* clp_sl_end                    REG=0x300D */
-    0x02,  /* off_start                     REG=0x300E */
-    0x0e,  /* rmp_en_start                  REG=0x300F */
-    0x30,  /* tx_start                      REG=0x3010 */
-    0x4e,  /* tx_end                        REG=0x3011 */
-    0x1E,  /* stx_width                     REG=0x3012 */
-    0x08,  /* reg_3152_reserved             REG=0x3152 */
-    0x10,  /* reg_315A_reserved             REG=0x315A */
-    0x00,  /* analogue_gain_code_global_msb REG=0x0204 */
-    0x80,  /* analogue_gain_code_global_lsb REG=0x0205 */
-    0x02,  /* fine_integration_time         REG=0x0200 */
-    0x03,  /* coarse_integration_time       REG=0x0202 */
-		1960,
-		14,
-		2608,
-		124
-	}
-};
-
-struct s5k3e2fx_work {
-	struct work_struct work;
-};
-static struct s5k3e2fx_work *s5k3e2fx_sensorw;
-static struct i2c_client *s5k3e2fx_client;
-
-struct s5k3e2fx_ctrl {
-	const struct msm_camera_sensor_info *sensordata;
-
-	int sensormode;
-	uint32_t fps_divider; /* init to 1 * 0x00000400 */
-	uint32_t pict_fps_divider; /* init to 1 * 0x00000400 */
-
-	uint16_t curr_lens_pos;
-	uint16_t init_curr_lens_pos;
-	uint16_t my_reg_gain;
-	uint32_t 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;
-};
-
-struct s5k3e2fx_i2c_reg_conf {
-	unsigned short waddr;
-	unsigned char  bdata;
-};
-
-static struct s5k3e2fx_ctrl *s5k3e2fx_ctrl;
-static DECLARE_WAIT_QUEUE_HEAD(s5k3e2fx_wait_queue);
-DEFINE_MUTEX(s5k3e2fx_mutex);
-
-static int s5k3e2fx_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(s5k3e2fx_client->adapter, msgs, 2) < 0) {
-		CDBG("s5k3e2fx_i2c_rxdata failed!\n");
-		return -EIO;
-	}
-
-	return 0;
-}
-
-static int32_t s5k3e2fx_i2c_txdata(unsigned short saddr,
-	unsigned char *txdata, int length)
-{
-	struct i2c_msg msg[] = {
-		{
-		.addr  = saddr,
-		.flags = 0,
-		.len = length,
-		.buf = txdata,
-		},
-	};
-
-	if (i2c_transfer(s5k3e2fx_client->adapter, msg, 1) < 0) {
-		CDBG("s5k3e2fx_i2c_txdata failed\n");
-		return -EIO;
-	}
-
-	return 0;
-}
-
-static int32_t s5k3e2fx_i2c_write_b(unsigned short saddr, unsigned short waddr,
-	unsigned char bdata)
-{
-	int32_t rc = -EIO;
-	unsigned char buf[4];
-
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00)>>8;
-	buf[1] = (waddr & 0x00FF);
-	buf[2] = bdata;
-
-	rc = s5k3e2fx_i2c_txdata(saddr, buf, 3);
-
-	if (rc < 0)
-		CDBG("i2c_write_w failed, addr = 0x%x, val = 0x%x!\n",
-			waddr, bdata);
-
-	return rc;
-}
-
-static int32_t s5k3e2fx_i2c_write_table(
-	struct s5k3e2fx_i2c_reg_conf *reg_cfg_tbl, int num)
-{
-	int i;
-	int32_t rc = -EIO;
-	for (i = 0; i < num; i++) {
-		rc = s5k3e2fx_i2c_write_b(s5k3e2fx_client->addr,
-			reg_cfg_tbl->waddr, reg_cfg_tbl->bdata);
-		if (rc < 0)
-			break;
-		reg_cfg_tbl++;
-	}
-
-	return rc;
-}
-
-static int32_t s5k3e2fx_i2c_read_w(unsigned short saddr, unsigned short raddr,
-	unsigned short *rdata)
-{
-	int32_t rc = 0;
-	unsigned char buf[4];
-
-	if (!rdata)
-		return -EIO;
-
-	memset(buf, 0, sizeof(buf));
-
-	buf[0] = (raddr & 0xFF00)>>8;
-	buf[1] = (raddr & 0x00FF);
-
-	rc = s5k3e2fx_i2c_rxdata(saddr, buf, 2);
-	if (rc < 0)
-		return rc;
-
-	*rdata = buf[0] << 8 | buf[1];
-
-	if (rc < 0)
-		CDBG("s5k3e2fx_i2c_read failed!\n");
-
-	return rc;
-}
-
-static int s5k3e2fx_probe_init_done(const struct msm_camera_sensor_info *data)
-{
-	gpio_direction_output(data->sensor_reset, 0);
-	gpio_free(data->sensor_reset);
-	return 0;
-}
-
-static int s5k3e2fx_probe_init_sensor(const struct msm_camera_sensor_info *data)
-{
-	int32_t  rc;
-	uint16_t chipid = 0;
-
-	rc = gpio_request(data->sensor_reset, "s5k3e2fx");
-	if (!rc)
-		gpio_direction_output(data->sensor_reset, 1);
-	else
-		goto init_probe_done;
-
-	mdelay(20);
-
-	CDBG("s5k3e2fx_sensor_init(): reseting sensor.\n");
-
-	rc = s5k3e2fx_i2c_read_w(s5k3e2fx_client->addr,
-		S5K3E2FX_REG_MODEL_ID, &chipid);
-	if (rc < 0)
-		goto init_probe_fail;
-
-	if (chipid != S5K3E2FX_MODEL_ID) {
-		CDBG("S5K3E2FX wrong model_id = 0x%x\n", chipid);
-		rc = -ENODEV;
-		goto init_probe_fail;
-	}
-
-	goto init_probe_done;
-
-init_probe_fail:
-	s5k3e2fx_probe_init_done(data);
-init_probe_done:
-	return rc;
-}
-
-static int s5k3e2fx_init_client(struct i2c_client *client)
-{
-	/* Initialize the MSM_CAMI2C Chip */
-	init_waitqueue_head(&s5k3e2fx_wait_queue);
-	return 0;
-}
-
-static const struct i2c_device_id s5k3e2fx_i2c_id[] = {
-	{ "s5k3e2fx", 0},
-	{ }
-};
-
-static int s5k3e2fx_i2c_probe(struct i2c_client *client,
-	const struct i2c_device_id *id)
-{
-	int rc = 0;
-	CDBG("s5k3e2fx_probe called!\n");
-
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		CDBG("i2c_check_functionality failed\n");
-		goto probe_failure;
-	}
-
-	s5k3e2fx_sensorw = kzalloc(sizeof(struct s5k3e2fx_work), GFP_KERNEL);
-	if (!s5k3e2fx_sensorw) {
-		CDBG("kzalloc failed.\n");
-		rc = -ENOMEM;
-		goto probe_failure;
-	}
-
-	i2c_set_clientdata(client, s5k3e2fx_sensorw);
-	s5k3e2fx_init_client(client);
-	s5k3e2fx_client = client;
-
-	mdelay(50);
-
-	CDBG("s5k3e2fx_probe successed! rc = %d\n", rc);
-	return 0;
-
-probe_failure:
-	CDBG("s5k3e2fx_probe failed! rc = %d\n", rc);
-	return rc;
-}
-
-static struct i2c_driver s5k3e2fx_i2c_driver = {
-	.id_table = s5k3e2fx_i2c_id,
-	.probe  = s5k3e2fx_i2c_probe,
-	.remove = __exit_p(s5k3e2fx_i2c_remove),
-	.driver = {
-		.name = "s5k3e2fx",
-	},
-};
-
-static int32_t s5k3e2fx_test(enum msm_s_test_mode mo)
-{
-	int32_t rc = 0;
-
-	if (mo == S_TEST_OFF)
-		rc = 0;
-	else
-		rc = s5k3e2fx_i2c_write_b(s5k3e2fx_client->addr,
-			REG_TEST_PATTERN_MODE, (uint16_t)mo);
-
-	return rc;
-}
-
-static int32_t s5k3e2fx_setting(enum msm_s_reg_update rupdate,
-	enum msm_s_setting rt)
-{
-	int32_t rc = 0;
-  uint16_t num_lperf;
-
-	switch (rupdate) {
-	case S_UPDATE_PERIODIC:
-	if (rt == S_RES_PREVIEW || rt == S_RES_CAPTURE) {
-
-		struct s5k3e2fx_i2c_reg_conf tbl_1[] = {
-			{REG_CCP_DATA_FORMAT_MSB,
-				s5k3e2fx_reg_pat[rt].ccp_data_format_msb},
-			{REG_CCP_DATA_FORMAT_LSB,
-				s5k3e2fx_reg_pat[rt].ccp_data_format_lsb},
-			{REG_X_OUTPUT_SIZE_MSB,
-				s5k3e2fx_reg_pat[rt].x_output_size_msb},
-			{REG_X_OUTPUT_SIZE_LSB,
-				s5k3e2fx_reg_pat[rt].x_output_size_lsb},
-			{REG_Y_OUTPUT_SIZE_MSB,
-				s5k3e2fx_reg_pat[rt].y_output_size_msb},
-			{REG_Y_OUTPUT_SIZE_LSB,
-				s5k3e2fx_reg_pat[rt].y_output_size_lsb},
-			{REG_X_EVEN_INC,
-				s5k3e2fx_reg_pat[rt].x_even_inc},
-			{REG_X_ODD_INC,
-				s5k3e2fx_reg_pat[rt].x_odd_inc},
-			{REG_Y_EVEN_INC,
-				s5k3e2fx_reg_pat[rt].y_even_inc},
-			{REG_Y_ODD_INC,
-				s5k3e2fx_reg_pat[rt].y_odd_inc},
-			{REG_BINNING_ENABLE,
-				s5k3e2fx_reg_pat[rt].binning_enable},
-		};
-
-		struct s5k3e2fx_i2c_reg_conf tbl_2[] = {
-			{REG_FRAME_LENGTH_LINES_MSB, 0},
-			{REG_FRAME_LENGTH_LINES_LSB, 0},
-			{REG_LINE_LENGTH_PCK_MSB,
-				s5k3e2fx_reg_pat[rt].line_length_pck_msb},
-			{REG_LINE_LENGTH_PCK_LSB,
-				s5k3e2fx_reg_pat[rt].line_length_pck_lsb},
-			{REG_SHADE_CLK_ENABLE,
-				s5k3e2fx_reg_pat[rt].shade_clk_enable},
-			{REG_SEL_CCP, s5k3e2fx_reg_pat[rt].sel_ccp},
-			{REG_VPIX, s5k3e2fx_reg_pat[rt].vpix},
-			{REG_CLAMP_ON, s5k3e2fx_reg_pat[rt].clamp_on},
-			{REG_OFFSET, s5k3e2fx_reg_pat[rt].offset},
-			{REG_LD_START, s5k3e2fx_reg_pat[rt].ld_start},
-			{REG_LD_END, s5k3e2fx_reg_pat[rt].ld_end},
-			{REG_SL_START, s5k3e2fx_reg_pat[rt].sl_start},
-			{REG_SL_END, s5k3e2fx_reg_pat[rt].sl_end},
-			{REG_RX_START, s5k3e2fx_reg_pat[rt].rx_start},
-			{REG_S1_START, s5k3e2fx_reg_pat[rt].s1_start},
-			{REG_S1_END, s5k3e2fx_reg_pat[rt].s1_end},
-			{REG_S1S_START, s5k3e2fx_reg_pat[rt].s1s_start},
-			{REG_S1S_END, s5k3e2fx_reg_pat[rt].s1s_end},
-			{REG_S3_START, s5k3e2fx_reg_pat[rt].s3_start},
-			{REG_S3_END, s5k3e2fx_reg_pat[rt].s3_end},
-			{REG_CMP_EN_START, s5k3e2fx_reg_pat[rt].cmp_en_start},
-			{REG_CLP_SL_START, s5k3e2fx_reg_pat[rt].clp_sl_start},
-			{REG_CLP_SL_END, s5k3e2fx_reg_pat[rt].clp_sl_end},
-			{REG_OFF_START, s5k3e2fx_reg_pat[rt].off_start},
-			{REG_RMP_EN_START, s5k3e2fx_reg_pat[rt].rmp_en_start},
-			{REG_TX_START, s5k3e2fx_reg_pat[rt].tx_start},
-			{REG_TX_END, s5k3e2fx_reg_pat[rt].tx_end},
-			{REG_STX_WIDTH, s5k3e2fx_reg_pat[rt].stx_width},
-			{REG_3152_RESERVED,
-				s5k3e2fx_reg_pat[rt].reg_3152_reserved},
-			{REG_315A_RESERVED,
-				s5k3e2fx_reg_pat[rt].reg_315A_reserved},
-			{REG_ANALOGUE_GAIN_CODE_GLOBAL_MSB,
-				s5k3e2fx_reg_pat[rt].
-				analogue_gain_code_global_msb},
-			{REG_ANALOGUE_GAIN_CODE_GLOBAL_LSB,
-				s5k3e2fx_reg_pat[rt].
-				analogue_gain_code_global_lsb},
-			{REG_FINE_INTEGRATION_TIME,
-				s5k3e2fx_reg_pat[rt].fine_integration_time},
-			{REG_COARSE_INTEGRATION_TIME,
-				s5k3e2fx_reg_pat[rt].coarse_integration_time},
-			{S5K3E2FX_REG_MODE_SELECT, S5K3E2FX_MODE_SELECT_STREAM},
-		};
-
-		rc = s5k3e2fx_i2c_write_table(&tbl_1[0],
-			ARRAY_SIZE(tbl_1));
-		if (rc < 0)
-			return rc;
-
-		num_lperf = (uint16_t)
-			((s5k3e2fx_reg_pat[rt].frame_length_lines_msb << 8)
-			& 0xFF00)
-			+ s5k3e2fx_reg_pat[rt].frame_length_lines_lsb;
-
-		num_lperf = num_lperf * s5k3e2fx_ctrl->fps_divider / 0x0400;
-
-		tbl_2[0] = (struct s5k3e2fx_i2c_reg_conf)
-			{REG_FRAME_LENGTH_LINES_MSB, (num_lperf & 0xFF00) >> 8};
-		tbl_2[1] = (struct s5k3e2fx_i2c_reg_conf)
-			{REG_FRAME_LENGTH_LINES_LSB, (num_lperf & 0x00FF)};
-
-		rc = s5k3e2fx_i2c_write_table(&tbl_2[0],
-			ARRAY_SIZE(tbl_2));
-		if (rc < 0)
-			return rc;
-
-		mdelay(5);
-
-		rc = s5k3e2fx_test(s5k3e2fx_ctrl->set_test);
-		if (rc < 0)
-			return rc;
-	  }
-    break; /* UPDATE_PERIODIC */
-
-	case S_REG_INIT:
-	if (rt == S_RES_PREVIEW || rt == S_RES_CAPTURE) {
-
-		struct s5k3e2fx_i2c_reg_conf tbl_3[] = {
-			{S5K3E2FX_REG_SOFTWARE_RESET, S5K3E2FX_SOFTWARE_RESET},
-			{S5K3E2FX_REG_MODE_SELECT,
-				S5K3E2FX_MODE_SELECT_SW_STANDBY},
-			/* PLL setting */
-			{REG_PRE_PLL_CLK_DIV,
-				s5k3e2fx_reg_pat[rt].pre_pll_clk_div},
-			{REG_PLL_MULTIPLIER_MSB,
-				s5k3e2fx_reg_pat[rt].pll_multiplier_msb},
-			{REG_PLL_MULTIPLIER_LSB,
-				s5k3e2fx_reg_pat[rt].pll_multiplier_lsb},
-			{REG_VT_PIX_CLK_DIV,
-				s5k3e2fx_reg_pat[rt].vt_pix_clk_div},
-			{REG_VT_SYS_CLK_DIV,
-				s5k3e2fx_reg_pat[rt].vt_sys_clk_div},
-			{REG_OP_PIX_CLK_DIV,
-				s5k3e2fx_reg_pat[rt].op_pix_clk_div},
-			{REG_OP_SYS_CLK_DIV,
-				s5k3e2fx_reg_pat[rt].op_sys_clk_div},
-			/*Data Format */
-			{REG_CCP_DATA_FORMAT_MSB,
-				s5k3e2fx_reg_pat[rt].ccp_data_format_msb},
-			{REG_CCP_DATA_FORMAT_LSB,
-				s5k3e2fx_reg_pat[rt].ccp_data_format_lsb},
-			/*Output Size */
-			{REG_X_OUTPUT_SIZE_MSB,
-				s5k3e2fx_reg_pat[rt].x_output_size_msb},
-			{REG_X_OUTPUT_SIZE_LSB,
-				s5k3e2fx_reg_pat[rt].x_output_size_lsb},
-			{REG_Y_OUTPUT_SIZE_MSB,
-				s5k3e2fx_reg_pat[rt].y_output_size_msb},
-			{REG_Y_OUTPUT_SIZE_LSB,
-				s5k3e2fx_reg_pat[rt].y_output_size_lsb},
-			/* Binning */
-			{REG_X_EVEN_INC, s5k3e2fx_reg_pat[rt].x_even_inc},
-			{REG_X_ODD_INC, s5k3e2fx_reg_pat[rt].x_odd_inc },
-			{REG_Y_EVEN_INC, s5k3e2fx_reg_pat[rt].y_even_inc},
-			{REG_Y_ODD_INC, s5k3e2fx_reg_pat[rt].y_odd_inc},
-			{REG_BINNING_ENABLE,
-				s5k3e2fx_reg_pat[rt].binning_enable},
-			/* Frame format */
-			{REG_FRAME_LENGTH_LINES_MSB,
-				s5k3e2fx_reg_pat[rt].frame_length_lines_msb},
-			{REG_FRAME_LENGTH_LINES_LSB,
-				s5k3e2fx_reg_pat[rt].frame_length_lines_lsb},
-			{REG_LINE_LENGTH_PCK_MSB,
-				s5k3e2fx_reg_pat[rt].line_length_pck_msb},
-			{REG_LINE_LENGTH_PCK_LSB,
-				s5k3e2fx_reg_pat[rt].line_length_pck_lsb},
-			/* MSR setting */
-			{REG_SHADE_CLK_ENABLE,
-				s5k3e2fx_reg_pat[rt].shade_clk_enable},
-			{REG_SEL_CCP, s5k3e2fx_reg_pat[rt].sel_ccp},
-			{REG_VPIX, s5k3e2fx_reg_pat[rt].vpix},
-			{REG_CLAMP_ON, s5k3e2fx_reg_pat[rt].clamp_on},
-			{REG_OFFSET, s5k3e2fx_reg_pat[rt].offset},
-			/* CDS timing setting */
-			{REG_LD_START, s5k3e2fx_reg_pat[rt].ld_start},
-			{REG_LD_END, s5k3e2fx_reg_pat[rt].ld_end},
-			{REG_SL_START, s5k3e2fx_reg_pat[rt].sl_start},
-			{REG_SL_END, s5k3e2fx_reg_pat[rt].sl_end},
-			{REG_RX_START, s5k3e2fx_reg_pat[rt].rx_start},
-			{REG_S1_START, s5k3e2fx_reg_pat[rt].s1_start},
-			{REG_S1_END, s5k3e2fx_reg_pat[rt].s1_end},
-			{REG_S1S_START, s5k3e2fx_reg_pat[rt].s1s_start},
-			{REG_S1S_END, s5k3e2fx_reg_pat[rt].s1s_end},
-			{REG_S3_START, s5k3e2fx_reg_pat[rt].s3_start},
-			{REG_S3_END, s5k3e2fx_reg_pat[rt].s3_end},
-			{REG_CMP_EN_START, s5k3e2fx_reg_pat[rt].cmp_en_start},
-			{REG_CLP_SL_START, s5k3e2fx_reg_pat[rt].clp_sl_start},
-			{REG_CLP_SL_END, s5k3e2fx_reg_pat[rt].clp_sl_end},
-			{REG_OFF_START, s5k3e2fx_reg_pat[rt].off_start},
-			{REG_RMP_EN_START, s5k3e2fx_reg_pat[rt].rmp_en_start},
-			{REG_TX_START, s5k3e2fx_reg_pat[rt].tx_start},
-			{REG_TX_END, s5k3e2fx_reg_pat[rt].tx_end},
-			{REG_STX_WIDTH, s5k3e2fx_reg_pat[rt].stx_width},
-			{REG_3152_RESERVED,
-				s5k3e2fx_reg_pat[rt].reg_3152_reserved},
-			{REG_315A_RESERVED,
-				s5k3e2fx_reg_pat[rt].reg_315A_reserved},
-			{REG_ANALOGUE_GAIN_CODE_GLOBAL_MSB,
-				s5k3e2fx_reg_pat[rt].
-				analogue_gain_code_global_msb},
-			{REG_ANALOGUE_GAIN_CODE_GLOBAL_LSB,
-				s5k3e2fx_reg_pat[rt].
-				analogue_gain_code_global_lsb},
-			{REG_FINE_INTEGRATION_TIME,
-				s5k3e2fx_reg_pat[rt].fine_integration_time},
-			{REG_COARSE_INTEGRATION_TIME,
-				s5k3e2fx_reg_pat[rt].coarse_integration_time},
-			{S5K3E2FX_REG_MODE_SELECT, S5K3E2FX_MODE_SELECT_STREAM},
-		};
-
-		/* reset fps_divider */
-		s5k3e2fx_ctrl->fps_divider = 1 * 0x0400;
-		rc = s5k3e2fx_i2c_write_table(&tbl_3[0],
-			ARRAY_SIZE(tbl_3));
-		if (rc < 0)
-			return rc;
-		}
-		break; /* case REG_INIT: */
-
-	default:
-		rc = -EINVAL;
-		break;
-	} /* switch (rupdate) */
-
-	return rc;
-}
-
-static int s5k3e2fx_sensor_open_init(const struct msm_camera_sensor_info *data)
-{
-	int32_t  rc;
-
-	s5k3e2fx_ctrl = kzalloc(sizeof(struct s5k3e2fx_ctrl), GFP_KERNEL);
-	if (!s5k3e2fx_ctrl) {
-		CDBG("s5k3e2fx_init failed!\n");
-		rc = -ENOMEM;
-		goto init_done;
-	}
-
-	s5k3e2fx_ctrl->fps_divider = 1 * 0x00000400;
-	s5k3e2fx_ctrl->pict_fps_divider = 1 * 0x00000400;
-	s5k3e2fx_ctrl->set_test = S_TEST_OFF;
-	s5k3e2fx_ctrl->prev_res = S_QTR_SIZE;
-	s5k3e2fx_ctrl->pict_res = S_FULL_SIZE;
-
-	if (data)
-		s5k3e2fx_ctrl->sensordata = data;
-
-	/* enable mclk first */
-	msm_camio_clk_rate_set(24000000);
-	mdelay(20);
-
-	msm_camio_camif_pad_reg_reset();
-	mdelay(20);
-
-	rc = s5k3e2fx_probe_init_sensor(data);
-	if (rc < 0)
-		goto init_fail1;
-
-	if (s5k3e2fx_ctrl->prev_res == S_QTR_SIZE)
-		rc = s5k3e2fx_setting(S_REG_INIT, S_RES_PREVIEW);
-	else
-		rc = s5k3e2fx_setting(S_REG_INIT, S_RES_CAPTURE);
-
-	if (rc < 0) {
-		CDBG("s5k3e2fx_setting failed. rc = %d\n", rc);
-		goto init_fail1;
-	}
-
-	/* initialize AF */
-	rc = s5k3e2fx_i2c_write_b(s5k3e2fx_client->addr,
-			0x3146, 0x3A);
-	if (rc < 0)
-		goto init_fail1;
-
-	rc = s5k3e2fx_i2c_write_b(s5k3e2fx_client->addr,
-			0x3130, 0x03);
-	if (rc < 0)
-		goto init_fail1;
-
-	goto init_done;
-
-init_fail1:
-	s5k3e2fx_probe_init_done(data);
-	kfree(s5k3e2fx_ctrl);
-init_done:
-	return rc;
-}
-
-static int32_t s5k3e2fx_power_down(void)
-{
-	int32_t rc = 0;
-	return rc;
-}
-
-static int s5k3e2fx_sensor_release(void)
-{
-	int rc = -EBADF;
-
-	mutex_lock(&s5k3e2fx_mutex);
-
-	s5k3e2fx_power_down();
-
-	gpio_direction_output(s5k3e2fx_ctrl->sensordata->sensor_reset,
-		0);
-	gpio_free(s5k3e2fx_ctrl->sensordata->sensor_reset);
-
-	kfree(s5k3e2fx_ctrl);
-	s5k3e2fx_ctrl = NULL;
-
-	CDBG("s5k3e2fx_release completed\n");
-
-	mutex_unlock(&s5k3e2fx_mutex);
-	return rc;
-}
-
-static void s5k3e2fx_get_pict_fps(uint16_t fps, uint16_t *pfps)
-{
-	/* input fps is preview fps in Q8 format */
-	uint32_t divider;   /* Q10 */
-
-	divider = (uint32_t)
-		((s5k3e2fx_reg_pat[S_RES_PREVIEW].size_h +
-			s5k3e2fx_reg_pat[S_RES_PREVIEW].blk_l) *
-		 (s5k3e2fx_reg_pat[S_RES_PREVIEW].size_w +
-			s5k3e2fx_reg_pat[S_RES_PREVIEW].blk_p)) * 0x00000400 /
-		((s5k3e2fx_reg_pat[S_RES_CAPTURE].size_h +
-			s5k3e2fx_reg_pat[S_RES_CAPTURE].blk_l) *
-		 (s5k3e2fx_reg_pat[S_RES_CAPTURE].size_w +
-			s5k3e2fx_reg_pat[S_RES_CAPTURE].blk_p));
-
-	/* Verify PCLK settings and frame sizes. */
-	*pfps = (uint16_t)(fps * divider / 0x00000400);
-}
-
-static uint16_t s5k3e2fx_get_prev_lines_pf(void)
-{
-	return s5k3e2fx_reg_pat[S_RES_PREVIEW].size_h +
-		s5k3e2fx_reg_pat[S_RES_PREVIEW].blk_l;
-}
-
-static uint16_t s5k3e2fx_get_prev_pixels_pl(void)
-{
-	return s5k3e2fx_reg_pat[S_RES_PREVIEW].size_w +
-		s5k3e2fx_reg_pat[S_RES_PREVIEW].blk_p;
-}
-
-static uint16_t s5k3e2fx_get_pict_lines_pf(void)
-{
-	return s5k3e2fx_reg_pat[S_RES_CAPTURE].size_h +
-		s5k3e2fx_reg_pat[S_RES_CAPTURE].blk_l;
-}
-
-static uint16_t s5k3e2fx_get_pict_pixels_pl(void)
-{
-	return s5k3e2fx_reg_pat[S_RES_CAPTURE].size_w +
-		s5k3e2fx_reg_pat[S_RES_CAPTURE].blk_p;
-}
-
-static uint32_t s5k3e2fx_get_pict_max_exp_lc(void)
-{
-	uint32_t snapshot_lines_per_frame;
-
-	if (s5k3e2fx_ctrl->pict_res == S_QTR_SIZE)
-		snapshot_lines_per_frame =
-		s5k3e2fx_reg_pat[S_RES_PREVIEW].size_h +
-		s5k3e2fx_reg_pat[S_RES_PREVIEW].blk_l;
-	else
-		snapshot_lines_per_frame = 3961 * 3;
-
-	return snapshot_lines_per_frame;
-}
-
-static int32_t s5k3e2fx_set_fps(struct fps_cfg *fps)
-{
-	/* input is new fps in Q10 format */
-	int32_t rc = 0;
-	enum msm_s_setting setting;
-
-	s5k3e2fx_ctrl->fps_divider = fps->fps_div;
-
-	if (s5k3e2fx_ctrl->sensormode == SENSOR_PREVIEW_MODE)
-		setting = S_RES_PREVIEW;
-	else
-		setting = S_RES_CAPTURE;
-
-  rc = s5k3e2fx_i2c_write_b(s5k3e2fx_client->addr,
-		REG_FRAME_LENGTH_LINES_MSB,
-		(((s5k3e2fx_reg_pat[setting].size_h +
-			s5k3e2fx_reg_pat[setting].blk_l) *
-			s5k3e2fx_ctrl->fps_divider / 0x400) & 0xFF00) >> 8);
-	if (rc < 0)
-		goto set_fps_done;
-
-  rc = s5k3e2fx_i2c_write_b(s5k3e2fx_client->addr,
-		REG_FRAME_LENGTH_LINES_LSB,
-		(((s5k3e2fx_reg_pat[setting].size_h +
-			s5k3e2fx_reg_pat[setting].blk_l) *
-			s5k3e2fx_ctrl->fps_divider / 0x400) & 0x00FF));
-
-set_fps_done:
-	return rc;
-}
-
-static int32_t s5k3e2fx_write_exp_gain(uint16_t gain, uint32_t line)
-{
-	int32_t rc = 0;
-
-	uint16_t max_legal_gain = 0x0200;
-	uint32_t ll_ratio; /* Q10 */
-	uint32_t ll_pck, fl_lines;
-	uint16_t offset = 4;
-	uint32_t  gain_msb, gain_lsb;
-	uint32_t  intg_t_msb, intg_t_lsb;
-	uint32_t  ll_pck_msb, ll_pck_lsb;
-
-	struct s5k3e2fx_i2c_reg_conf tbl[2];
-
-	CDBG("Line:%d s5k3e2fx_write_exp_gain \n", __LINE__);
-
-	if (s5k3e2fx_ctrl->sensormode == SENSOR_PREVIEW_MODE) {
-
-		s5k3e2fx_ctrl->my_reg_gain = gain;
-		s5k3e2fx_ctrl->my_reg_line_count = (uint16_t)line;
-
-		fl_lines = s5k3e2fx_reg_pat[S_RES_PREVIEW].size_h +
-			s5k3e2fx_reg_pat[S_RES_PREVIEW].blk_l;
-
-		ll_pck = s5k3e2fx_reg_pat[S_RES_PREVIEW].size_w +
-			s5k3e2fx_reg_pat[S_RES_PREVIEW].blk_p;
-
-	} else {
-
-		fl_lines = s5k3e2fx_reg_pat[S_RES_CAPTURE].size_h +
-			s5k3e2fx_reg_pat[S_RES_CAPTURE].blk_l;
-
-		ll_pck = s5k3e2fx_reg_pat[S_RES_CAPTURE].size_w +
-			s5k3e2fx_reg_pat[S_RES_CAPTURE].blk_p;
-	}
-
-	if (gain > max_legal_gain)
-		gain = max_legal_gain;
-
-	/* in Q10 */
-	line = (line * s5k3e2fx_ctrl->fps_divider);
-
-	if (fl_lines < (line / 0x400))
-		ll_ratio = (line / (fl_lines - offset));
-	else
-		ll_ratio = 0x400;
-
-	/* update gain registers */
-	gain_msb = (gain & 0xFF00) >> 8;
-	gain_lsb = gain & 0x00FF;
-	tbl[0].waddr = REG_ANALOGUE_GAIN_CODE_GLOBAL_MSB;
-	tbl[0].bdata = gain_msb;
-	tbl[1].waddr = REG_ANALOGUE_GAIN_CODE_GLOBAL_LSB;
-	tbl[1].bdata = gain_lsb;
-	rc = s5k3e2fx_i2c_write_table(&tbl[0], ARRAY_SIZE(tbl));
-	if (rc < 0)
-		goto write_gain_done;
-
-	ll_pck = ll_pck * ll_ratio;
-	ll_pck_msb = ((ll_pck / 0x400) & 0xFF00) >> 8;
-	ll_pck_lsb = (ll_pck / 0x400) & 0x00FF;
-	tbl[0].waddr = REG_LINE_LENGTH_PCK_MSB;
-	tbl[0].bdata = ll_pck_msb;
-	tbl[1].waddr = REG_LINE_LENGTH_PCK_LSB;
-	tbl[1].bdata = ll_pck_lsb;
-	rc = s5k3e2fx_i2c_write_table(&tbl[0], ARRAY_SIZE(tbl));
-	if (rc < 0)
-		goto write_gain_done;
-
-	line = line / ll_ratio;
-	intg_t_msb = (line & 0xFF00) >> 8;
-	intg_t_lsb = (line & 0x00FF);
-	tbl[0].waddr = REG_COARSE_INTEGRATION_TIME;
-	tbl[0].bdata = intg_t_msb;
-	tbl[1].waddr = REG_COARSE_INTEGRATION_TIME_LSB;
-	tbl[1].bdata = intg_t_lsb;
-	rc = s5k3e2fx_i2c_write_table(&tbl[0], ARRAY_SIZE(tbl));
-
-write_gain_done:
-	return rc;
-}
-
-static int32_t s5k3e2fx_set_pict_exp_gain(uint16_t gain, uint32_t line)
-{
-	int32_t rc = 0;
-
-	CDBG("Line:%d s5k3e2fx_set_pict_exp_gain \n", __LINE__);
-
-	rc =
-		s5k3e2fx_write_exp_gain(gain, line);
-
-	return rc;
-}
-
-static int32_t s5k3e2fx_video_config(int mode, int res)
-{
-	int32_t rc;
-
-	switch (res) {
-	case S_QTR_SIZE:
-		rc = s5k3e2fx_setting(S_UPDATE_PERIODIC, S_RES_PREVIEW);
-		if (rc < 0)
-			return rc;
-
-		CDBG("s5k3e2fx sensor configuration done!\n");
-		break;
-
-	case S_FULL_SIZE:
-		rc = s5k3e2fx_setting(S_UPDATE_PERIODIC, S_RES_CAPTURE);
-		if (rc < 0)
-			return rc;
-
-		break;
-
-	default:
-		return 0;
-	} /* switch */
-
-	s5k3e2fx_ctrl->prev_res = res;
-	s5k3e2fx_ctrl->curr_res = res;
-	s5k3e2fx_ctrl->sensormode = mode;
-
-	rc =
-		s5k3e2fx_write_exp_gain(s5k3e2fx_ctrl->my_reg_gain,
-			s5k3e2fx_ctrl->my_reg_line_count);
-
-	return rc;
-}
-
-static int32_t s5k3e2fx_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-
-	rc = s5k3e2fx_setting(S_UPDATE_PERIODIC, S_RES_CAPTURE);
-	if (rc < 0)
-		return rc;
-
-	s5k3e2fx_ctrl->curr_res = s5k3e2fx_ctrl->pict_res;
-	s5k3e2fx_ctrl->sensormode = mode;
-
-	return rc;
-}
-
-static int32_t s5k3e2fx_raw_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-
-	rc = s5k3e2fx_setting(S_UPDATE_PERIODIC, S_RES_CAPTURE);
-	if (rc < 0)
-		return rc;
-
-	s5k3e2fx_ctrl->curr_res = s5k3e2fx_ctrl->pict_res;
-	s5k3e2fx_ctrl->sensormode = mode;
-
-	return rc;
-}
-
-static int32_t s5k3e2fx_set_sensor_mode(int mode, int res)
-{
-	int32_t rc = 0;
-
-	switch (mode) {
-	case SENSOR_PREVIEW_MODE:
-		rc = s5k3e2fx_video_config(mode, res);
-		break;
-
-	case SENSOR_SNAPSHOT_MODE:
-		rc = s5k3e2fx_snapshot_config(mode);
-		break;
-
-	case SENSOR_RAW_SNAPSHOT_MODE:
-		rc = s5k3e2fx_raw_snapshot_config(mode);
-		break;
-
-	default:
-		rc = -EINVAL;
-		break;
-	}
-
-	return rc;
-}
-
-static int32_t s5k3e2fx_set_default_focus(void)
-{
-	int32_t rc = 0;
-
-  rc = s5k3e2fx_i2c_write_b(s5k3e2fx_client->addr,
-		0x3131, 0);
-	if (rc < 0)
-		return rc;
-
-  rc = s5k3e2fx_i2c_write_b(s5k3e2fx_client->addr,
-		0x3132, 0);
-	if (rc < 0)
-		return rc;
-
-	s5k3e2fx_ctrl->curr_lens_pos = 0;
-
-	return rc;
-}
-
-static int32_t s5k3e2fx_move_focus(int direction, int32_t num_steps)
-{
-	int32_t rc = 0;
-	int32_t i;
-	int16_t step_direction;
-	int16_t actual_step;
-	int16_t next_pos, pos_offset;
-	int16_t init_code = 50;
-	uint8_t next_pos_msb, next_pos_lsb;
-	int16_t s_move[5];
-	uint32_t gain; /* Q10 format */
-
-	if (direction == MOVE_NEAR)
-		step_direction = 20;
-	else if (direction == MOVE_FAR)
-		step_direction = -20;
-	else {
-		CDBG("s5k3e2fx_move_focus failed at line %d ...\n", __LINE__);
-		return -EINVAL;
-	}
-
-	actual_step = step_direction * (int16_t)num_steps;
-	pos_offset = init_code + s5k3e2fx_ctrl->curr_lens_pos;
-	gain = actual_step * 0x400 / 5;
-
-	for (i = 0; i <= 4; i++) {
-		if (actual_step >= 0)
-			s_move[i] = (((i+1)*gain+0x200)-(i*gain+0x200))/0x400;
-		else
-			s_move[i] = (((i+1)*gain-0x200)-(i*gain-0x200))/0x400;
-	}
-
-	/* Ring Damping Code */
-	for (i = 0; i <= 4; i++) {
-		next_pos = (int16_t)(pos_offset + s_move[i]);
-
-		if (next_pos > (738 + init_code))
-			next_pos = 738 + init_code;
-		else if (next_pos < 0)
-			next_pos = 0;
-
-		CDBG("next_position in damping mode = %d\n", next_pos);
-		/* Writing the Values to the actuator */
-		if (next_pos == init_code)
-			next_pos = 0x00;
-
-		next_pos_msb = next_pos >> 8;
-		next_pos_lsb = next_pos & 0x00FF;
-
-		rc = s5k3e2fx_i2c_write_b(s5k3e2fx_client->addr,
-			0x3131, next_pos_msb);
-		if (rc < 0)
-			break;
-
-		rc = s5k3e2fx_i2c_write_b(s5k3e2fx_client->addr,
-			0x3132, next_pos_lsb);
-		if (rc < 0)
-			break;
-
-		pos_offset = next_pos;
-		s5k3e2fx_ctrl->curr_lens_pos = pos_offset - init_code;
-		if (i < 4)
-			mdelay(3);
-	}
-
-	return rc;
-}
-
-static int s5k3e2fx_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(&s5k3e2fx_mutex);
-
-	CDBG("%s: cfgtype = %d\n", __func__, cdata.cfgtype);
-	switch (cdata.cfgtype) {
-	case CFG_GET_PICT_FPS:
-		s5k3e2fx_get_pict_fps(cdata.cfg.gfps.prevfps,
-			&(cdata.cfg.gfps.pictfps));
-
-		if (copy_to_user((void *)argp, &cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PREV_L_PF:
-		cdata.cfg.prevl_pf = s5k3e2fx_get_prev_lines_pf();
-
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PREV_P_PL:
-		cdata.cfg.prevp_pl = s5k3e2fx_get_prev_pixels_pl();
-
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PICT_L_PF:
-		cdata.cfg.pictl_pf = s5k3e2fx_get_pict_lines_pf();
-
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PICT_P_PL:
-		cdata.cfg.pictp_pl = s5k3e2fx_get_pict_pixels_pl();
-
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PICT_MAX_EXP_LC:
-		cdata.cfg.pict_max_exp_lc =
-			s5k3e2fx_get_pict_max_exp_lc();
-
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_SET_FPS:
-	case CFG_SET_PICT_FPS:
-		rc = s5k3e2fx_set_fps(&(cdata.cfg.fps));
-		break;
-
-	case CFG_SET_EXP_GAIN:
-		rc =
-			s5k3e2fx_write_exp_gain(cdata.cfg.exp_gain.gain,
-				cdata.cfg.exp_gain.line);
-		break;
-
-	case CFG_SET_PICT_EXP_GAIN:
-		CDBG("Line:%d CFG_SET_PICT_EXP_GAIN \n", __LINE__);
-		rc =
-			s5k3e2fx_set_pict_exp_gain(
-				cdata.cfg.exp_gain.gain,
-				cdata.cfg.exp_gain.line);
-		break;
-
-	case CFG_SET_MODE:
-		rc =
-			s5k3e2fx_set_sensor_mode(
-			cdata.mode, cdata.rs);
-		break;
-
-	case CFG_PWR_DOWN:
-		rc = s5k3e2fx_power_down();
-		break;
-
-	case CFG_MOVE_FOCUS:
-		rc =
-			s5k3e2fx_move_focus(
-			cdata.cfg.focus.dir,
-			cdata.cfg.focus.steps);
-		break;
-
-	case CFG_SET_DEFAULT_FOCUS:
-		rc =
-			s5k3e2fx_set_default_focus();
-		break;
-
-	case CFG_GET_AF_MAX_STEPS:
-	case CFG_SET_EFFECT:
-	case CFG_SET_LENS_SHADING:
-	default:
-		rc = -EINVAL;
-		break;
-	}
-
-	mutex_unlock(&s5k3e2fx_mutex);
-	return rc;
-}
-
-static int s5k3e2fx_sensor_probe(const struct msm_camera_sensor_info *info,
-		struct msm_sensor_ctrl *s)
-{
-	int rc = 0;
-
-	rc = i2c_add_driver(&s5k3e2fx_i2c_driver);
-	if (rc < 0 || s5k3e2fx_client == NULL) {
-		rc = -ENOTSUPP;
-		goto probe_fail;
-	}
-
-	msm_camio_clk_rate_set(24000000);
-	mdelay(20);
-
-	rc = s5k3e2fx_probe_init_sensor(info);
-	if (rc < 0)
-		goto probe_fail;
-
-	s->s_init = s5k3e2fx_sensor_open_init;
-	s->s_release = s5k3e2fx_sensor_release;
-	s->s_config  = s5k3e2fx_sensor_config;
-	s->s_mount_angle  = 0;
-	s5k3e2fx_probe_init_done(info);
-
-	return rc;
-
-probe_fail:
-	CDBG("SENSOR PROBE FAILS!\n");
-	return rc;
-}
-
-static int __s5k3e2fx_probe(struct platform_device *pdev)
-{
-	return msm_camera_drv_start(pdev, s5k3e2fx_sensor_probe);
-}
-
-static struct platform_driver msm_camera_driver = {
-	.probe = __s5k3e2fx_probe,
-	.driver = {
-		.name = "msm_camera_s5k3e2fx",
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init s5k3e2fx_init(void)
-{
-	return platform_driver_register(&msm_camera_driver);
-}
-
-module_init(s5k3e2fx_init);
-
diff --git a/drivers/media/platform/msm/camera_v1/s5k3e2fx.h b/drivers/media/platform/msm/camera_v1/s5k3e2fx.h
deleted file mode 100644
index 3cf4f8e..0000000
--- a/drivers/media/platform/msm/camera_v1/s5k3e2fx.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-
-#ifndef CAMSENSOR_S5K3E2FX
-#define CAMSENSOR_S5K3E2FX
-
-#include <mach/board.h>
-#endif /* CAMSENSOR_S5K3E2FX */
diff --git a/drivers/media/platform/msm/camera_v1/s5k4e1.c b/drivers/media/platform/msm/camera_v1/s5k4e1.c
deleted file mode 100644
index c62103e..0000000
--- a/drivers/media/platform/msm/camera_v1/s5k4e1.c
+++ /dev/null
@@ -1,1103 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- */
-
-#include <linux/delay.h>
-#include <linux/debugfs.h>
-#include <linux/types.h>
-#include <linux/i2c.h>
-#include <linux/uaccess.h>
-#include <linux/miscdevice.h>
-#include <linux/slab.h>
-#include <linux/gpio.h>
-#include <linux/bitops.h>
-#include <mach/camera.h>
-#include <media/msm_camera.h>
-#include "s5k4e1.h"
-
-/* 16bit address - 8 bit context register structure */
-#define Q8	0x00000100
-#define Q10	0x00000400
-
-/* MCLK */
-#define S5K4E1_MASTER_CLK_RATE 24000000
-
-/* AF Total steps parameters */
-#define S5K4E1_TOTAL_STEPS_NEAR_TO_FAR	32
-
-#define S5K4E1_REG_PREV_FRAME_LEN_1	31
-#define S5K4E1_REG_PREV_FRAME_LEN_2	32
-#define S5K4E1_REG_PREV_LINE_LEN_1	33
-#define S5K4E1_REG_PREV_LINE_LEN_2	34
-
-#define S5K4E1_REG_SNAP_FRAME_LEN_1	15
-#define S5K4E1_REG_SNAP_FRAME_LEN_2	16
-#define  S5K4E1_REG_SNAP_LINE_LEN_1	17
-#define S5K4E1_REG_SNAP_LINE_LEN_2	18
-#define MSB                             1
-#define LSB                             0
-
-struct s5k4e1_work_t {
-	struct work_struct work;
-};
-
-static struct s5k4e1_work_t *s5k4e1_sensorw;
-static struct s5k4e1_work_t *s5k4e1_af_sensorw;
-static struct i2c_client *s5k4e1_af_client;
-static struct i2c_client *s5k4e1_client;
-
-struct s5k4e1_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 */
-	uint16_t fps;
-
-	uint16_t curr_lens_pos;
-	uint16_t curr_step_pos;
-	uint16_t my_reg_gain;
-	uint32_t my_reg_line_count;
-	uint16_t total_lines_per_frame;
-
-	enum s5k4e1_resolution_t prev_res;
-	enum s5k4e1_resolution_t pict_res;
-	enum s5k4e1_resolution_t curr_res;
-	enum s5k4e1_test_mode_t  set_test;
-};
-
-static bool CSI_CONFIG;
-static struct s5k4e1_ctrl_t *s5k4e1_ctrl;
-
-static DECLARE_WAIT_QUEUE_HEAD(s5k4e1_wait_queue);
-static DECLARE_WAIT_QUEUE_HEAD(s5k4e1_af_wait_queue);
-DEFINE_MUTEX(s5k4e1_mut);
-
-static uint16_t prev_line_length_pck;
-static uint16_t prev_frame_length_lines;
-static uint16_t snap_line_length_pck;
-static uint16_t snap_frame_length_lines;
-
-static int s5k4e1_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(s5k4e1_client->adapter, msgs, 2) < 0) {
-		CDBG("s5k4e1_i2c_rxdata faild 0x%x\n", saddr);
-		return -EIO;
-	}
-	return 0;
-}
-
-static int32_t s5k4e1_i2c_txdata(unsigned short saddr,
-		unsigned char *txdata, int length)
-{
-	struct i2c_msg msg[] = {
-		{
-			.addr = saddr,
-			.flags = 0,
-			.len = length,
-			.buf = txdata,
-		},
-	};
-	if (i2c_transfer(s5k4e1_client->adapter, msg, 1) < 0) {
-		CDBG("s5k4e1_i2c_txdata faild 0x%x\n", saddr);
-		return -EIO;
-	}
-
-	return 0;
-}
-
-static int32_t s5k4e1_i2c_read(unsigned short raddr,
-		unsigned short *rdata, int rlen)
-{
-	int32_t rc = 0;
-	unsigned char buf[2];
-
-	if (!rdata)
-		return -EIO;
-
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (raddr & 0xFF00) >> 8;
-	buf[1] = (raddr & 0x00FF);
-	rc = s5k4e1_i2c_rxdata(s5k4e1_client->addr, buf, rlen);
-	if (rc < 0) {
-		CDBG("s5k4e1_i2c_read 0x%x failed!\n", raddr);
-		return rc;
-	}
-	*rdata = (rlen == 2 ? buf[0] << 8 | buf[1] : buf[0]);
-	CDBG("s5k4e1_i2c_read 0x%x val = 0x%x!\n", raddr, *rdata);
-
-	return rc;
-}
-
-static int32_t s5k4e1_i2c_write_b_sensor(unsigned short waddr, uint8_t bdata)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[3];
-
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00) >> 8;
-	buf[1] = (waddr & 0x00FF);
-	buf[2] = bdata;
-	CDBG("i2c_write_b addr = 0x%x, val = 0x%x\n", waddr, bdata);
-	rc = s5k4e1_i2c_txdata(s5k4e1_client->addr, buf, 3);
-	if (rc < 0) {
-		CDBG("i2c_write_b failed, addr = 0x%x, val = 0x%x!\n",
-				waddr, bdata);
-	}
-	return rc;
-}
-
-static int32_t s5k4e1_i2c_write_b_table(struct s5k4e1_i2c_reg_conf const
-		*reg_conf_tbl, int num)
-{
-	int i;
-	int32_t rc = -EIO;
-
-	for (i = 0; i < num; i++) {
-		rc = s5k4e1_i2c_write_b_sensor(reg_conf_tbl->waddr,
-				reg_conf_tbl->wdata);
-		if (rc < 0)
-			break;
-		reg_conf_tbl++;
-	}
-	return rc;
-}
-
-static int32_t s5k4e1_af_i2c_txdata(unsigned short saddr,
-		unsigned char *txdata, int length)
-{
-	struct i2c_msg msg[] = {
-		{
-			.addr = saddr,
-			.flags = 0,
-			.len = length,
-			.buf = txdata,
-		},
-	};
-	if (i2c_transfer(s5k4e1_af_client->adapter, msg, 1) < 0) {
-		pr_err("s5k4e1_af_i2c_txdata faild 0x%x\n", saddr);
-		return -EIO;
-	}
-
-	return 0;
-}
-
-static int32_t s5k4e1_af_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;
-	CDBG("i2c_write_b addr = 0x%x, val = 0x%x\n", waddr, bdata);
-	rc = s5k4e1_af_i2c_txdata(s5k4e1_af_client->addr << 1, buf, 2);
-	if (rc < 0) {
-		pr_err("i2c_write_b failed, addr = 0x%x, val = 0x%x!\n",
-				waddr, bdata);
-	}
-	return rc;
-}
-
-static void s5k4e1_start_stream(void)
-{
-	s5k4e1_i2c_write_b_sensor(0x0100, 0x01);/* streaming on */
-}
-
-static void s5k4e1_stop_stream(void)
-{
-	s5k4e1_i2c_write_b_sensor(0x0100, 0x00);/* streaming off */
-}
-
-static void s5k4e1_group_hold_on(void)
-{
-	s5k4e1_i2c_write_b_sensor(0x0104, 0x01);
-}
-
-static void s5k4e1_group_hold_off(void)
-{
-	s5k4e1_i2c_write_b_sensor(0x0104, 0x0);
-}
-
-static void s5k4e1_get_pict_fps(uint16_t fps, uint16_t *pfps)
-{
-	/* input fps is preview fps in Q8 format */
-	uint32_t divider, d1, d2;
-
-	d1 = (prev_frame_length_lines * 0x00000400) / snap_frame_length_lines;
-	d2 = (prev_line_length_pck * 0x00000400) / snap_line_length_pck;
-	divider = (d1 * d2) / 0x400;
-
-	/*Verify PCLK settings and frame sizes.*/
-	*pfps = (uint16_t) (fps * divider / 0x400);
-}
-
-static uint16_t s5k4e1_get_prev_lines_pf(void)
-{
-	if (s5k4e1_ctrl->prev_res == QTR_SIZE)
-		return prev_frame_length_lines;
-	else
-		return snap_frame_length_lines;
-}
-
-static uint16_t s5k4e1_get_prev_pixels_pl(void)
-{
-	if (s5k4e1_ctrl->prev_res == QTR_SIZE)
-		return prev_line_length_pck;
-	else
-		return snap_line_length_pck;
-}
-
-static uint16_t s5k4e1_get_pict_lines_pf(void)
-{
-	if (s5k4e1_ctrl->pict_res == QTR_SIZE)
-		return prev_frame_length_lines;
-	else
-		return snap_frame_length_lines;
-}
-
-static uint16_t s5k4e1_get_pict_pixels_pl(void)
-{
-	if (s5k4e1_ctrl->pict_res == QTR_SIZE)
-		return prev_line_length_pck;
-	else
-		return snap_line_length_pck;
-}
-
-static uint32_t s5k4e1_get_pict_max_exp_lc(void)
-{
-	return snap_frame_length_lines * 24;
-}
-
-static int32_t s5k4e1_set_fps(struct fps_cfg   *fps)
-{
-	uint16_t total_lines_per_frame;
-	int32_t rc = 0;
-
-	s5k4e1_ctrl->fps_divider = fps->fps_div;
-	s5k4e1_ctrl->pict_fps_divider = fps->pict_fps_div;
-
-	if (s5k4e1_ctrl->sensormode == SENSOR_PREVIEW_MODE) {
-		total_lines_per_frame = (uint16_t)
-		((prev_frame_length_lines * s5k4e1_ctrl->fps_divider) / 0x400);
-	} else {
-		total_lines_per_frame = (uint16_t)
-		((snap_frame_length_lines * s5k4e1_ctrl->fps_divider) / 0x400);
-	}
-
-	s5k4e1_group_hold_on();
-	rc = s5k4e1_i2c_write_b_sensor(0x0340,
-			((total_lines_per_frame & 0xFF00) >> 8));
-	rc = s5k4e1_i2c_write_b_sensor(0x0341,
-			(total_lines_per_frame & 0x00FF));
-	s5k4e1_group_hold_off();
-
-	return rc;
-}
-
-static inline uint8_t s5k4e1_byte(uint16_t word, uint8_t offset)
-{
-	return word >> (offset * BITS_PER_BYTE);
-}
-
-static int32_t s5k4e1_write_exp_gain(uint16_t gain, uint32_t line)
-{
-	uint16_t max_legal_gain = 0x0200;
-	int32_t rc = 0;
-	static uint32_t fl_lines;
-
-	if (gain > max_legal_gain) {
-		pr_debug("Max legal gain Line:%d\n", __LINE__);
-		gain = max_legal_gain;
-	}
-	/* Analogue Gain */
-	s5k4e1_i2c_write_b_sensor(0x0204, s5k4e1_byte(gain, MSB));
-	s5k4e1_i2c_write_b_sensor(0x0205, s5k4e1_byte(gain, LSB));
-
-	if (line > (prev_frame_length_lines - 4)) {
-		fl_lines = line+4;
-		s5k4e1_group_hold_on();
-		s5k4e1_i2c_write_b_sensor(0x0340, s5k4e1_byte(fl_lines, MSB));
-		s5k4e1_i2c_write_b_sensor(0x0341, s5k4e1_byte(fl_lines, LSB));
-		/* Coarse Integration Time */
-		s5k4e1_i2c_write_b_sensor(0x0202, s5k4e1_byte(line, MSB));
-		s5k4e1_i2c_write_b_sensor(0x0203, s5k4e1_byte(line, LSB));
-		s5k4e1_group_hold_off();
-	} else if (line < (fl_lines - 4)) {
-		fl_lines = line+4;
-		if (fl_lines < prev_frame_length_lines)
-			fl_lines = prev_frame_length_lines;
-
-		s5k4e1_group_hold_on();
-		/* Coarse Integration Time */
-		s5k4e1_i2c_write_b_sensor(0x0202, s5k4e1_byte(line, MSB));
-		s5k4e1_i2c_write_b_sensor(0x0203, s5k4e1_byte(line, LSB));
-		s5k4e1_i2c_write_b_sensor(0x0340, s5k4e1_byte(fl_lines, MSB));
-		s5k4e1_i2c_write_b_sensor(0x0341, s5k4e1_byte(fl_lines, LSB));
-		s5k4e1_group_hold_off();
-	} else {
-		fl_lines = line+4;
-		s5k4e1_group_hold_on();
-		/* Coarse Integration Time */
-		s5k4e1_i2c_write_b_sensor(0x0202, s5k4e1_byte(line, MSB));
-		s5k4e1_i2c_write_b_sensor(0x0203, s5k4e1_byte(line, LSB));
-		s5k4e1_group_hold_off();
-	}
-	return rc;
-}
-
-static int32_t s5k4e1_set_pict_exp_gain(uint16_t gain, uint32_t line)
-{
-	uint16_t max_legal_gain = 0x0200;
-	uint16_t min_ll_pck = 0x0AB2;
-	uint32_t ll_pck, fl_lines;
-	uint32_t ll_ratio;
-	int32_t rc = 0;
-	uint8_t gain_msb, gain_lsb;
-	uint8_t intg_time_msb, intg_time_lsb;
-	uint8_t ll_pck_msb, ll_pck_lsb;
-
-	if (gain > max_legal_gain) {
-		pr_debug("Max legal gain Line:%d\n", __LINE__);
-		gain = max_legal_gain;
-	}
-
-	pr_debug("s5k4e1_write_exp_gain : gain = %d line = %d\n", gain, line);
-	line = (uint32_t) (line * s5k4e1_ctrl->pict_fps_divider);
-	fl_lines = snap_frame_length_lines;
-	ll_pck = snap_line_length_pck;
-
-	if (fl_lines < (line / 0x400))
-		ll_ratio = (line / (fl_lines - 4));
-	else
-		ll_ratio = 0x400;
-
-	ll_pck = ll_pck * ll_ratio / 0x400;
-	line = line / ll_ratio;
-	if (ll_pck < min_ll_pck)
-		ll_pck = min_ll_pck;
-
-	gain_msb = (uint8_t) ((gain & 0xFF00) >> 8);
-	gain_lsb = (uint8_t) (gain & 0x00FF);
-
-	intg_time_msb = (uint8_t) ((line & 0xFF00) >> 8);
-	intg_time_lsb = (uint8_t) (line & 0x00FF);
-
-	ll_pck_msb = (uint8_t) ((ll_pck & 0xFF00) >> 8);
-	ll_pck_lsb = (uint8_t) (ll_pck & 0x00FF);
-
-	s5k4e1_group_hold_on();
-	s5k4e1_i2c_write_b_sensor(0x0204, gain_msb); /* Analogue Gain */
-	s5k4e1_i2c_write_b_sensor(0x0205, gain_lsb);
-
-	s5k4e1_i2c_write_b_sensor(0x0342, ll_pck_msb);
-	s5k4e1_i2c_write_b_sensor(0x0343, ll_pck_lsb);
-
-	/* Coarse Integration Time */
-	s5k4e1_i2c_write_b_sensor(0x0202, intg_time_msb);
-	s5k4e1_i2c_write_b_sensor(0x0203, intg_time_lsb);
-	s5k4e1_group_hold_off();
-
-	return rc;
-}
-
-static int32_t s5k4e1_move_focus(int direction,
-		int32_t num_steps)
-{
-	int16_t step_direction, actual_step, next_position;
-	uint8_t code_val_msb, code_val_lsb;
-
-	if (direction == MOVE_NEAR)
-		step_direction = 16;
-	else
-		step_direction = -16;
-
-	actual_step = (int16_t) (step_direction * num_steps);
-	next_position = (int16_t) (s5k4e1_ctrl->curr_lens_pos + actual_step);
-
-	if (next_position > 1023)
-		next_position = 1023;
-	else if (next_position < 0)
-		next_position = 0;
-
-	code_val_msb = next_position >> 4;
-	code_val_lsb = (next_position & 0x000F) << 4;
-
-	if (s5k4e1_af_i2c_write_b_sensor(code_val_msb, code_val_lsb) < 0) {
-		pr_err("move_focus failed at line %d ...\n", __LINE__);
-		return -EBUSY;
-	}
-
-	s5k4e1_ctrl->curr_lens_pos = next_position;
-	return 0;
-}
-
-static int32_t s5k4e1_set_default_focus(uint8_t af_step)
-{
-	int32_t rc = 0;
-
-	if (s5k4e1_ctrl->curr_step_pos != 0) {
-		rc = s5k4e1_move_focus(MOVE_FAR,
-				s5k4e1_ctrl->curr_step_pos);
-	} else {
-		s5k4e1_af_i2c_write_b_sensor(0x00, 0x00);
-	}
-
-	s5k4e1_ctrl->curr_lens_pos = 0;
-	s5k4e1_ctrl->curr_step_pos = 0;
-
-	return rc;
-}
-
-static int32_t s5k4e1_test(enum s5k4e1_test_mode_t mo)
-{
-	int32_t rc = 0;
-
-	if (mo != TEST_OFF)
-		rc = s5k4e1_i2c_write_b_sensor(0x0601, (uint8_t) mo);
-
-	return rc;
-}
-
-static void s5k4e1_reset_sensor(void)
-{
-	s5k4e1_i2c_write_b_sensor(0x103, 0x1);
-}
-
-static int32_t s5k4e1_sensor_setting(int update_type, int rt)
-{
-
-	int32_t rc = 0;
-	struct msm_camera_csi_params s5k4e1_csi_params;
-
-	s5k4e1_stop_stream();
-	msleep(30);
-
-	if (update_type == REG_INIT) {
-		s5k4e1_reset_sensor();
-		s5k4e1_i2c_write_b_table(s5k4e1_regs.reg_mipi,
-				s5k4e1_regs.reg_mipi_size);
-		s5k4e1_i2c_write_b_table(s5k4e1_regs.rec_settings,
-				s5k4e1_regs.rec_size);
-		s5k4e1_i2c_write_b_table(s5k4e1_regs.reg_pll_p,
-				s5k4e1_regs.reg_pll_p_size);
-		CSI_CONFIG = 0;
-	} else if (update_type == UPDATE_PERIODIC) {
-		if (rt == RES_PREVIEW)
-			s5k4e1_i2c_write_b_table(s5k4e1_regs.reg_prev,
-					s5k4e1_regs.reg_prev_size);
-		else
-			s5k4e1_i2c_write_b_table(s5k4e1_regs.reg_snap,
-					s5k4e1_regs.reg_snap_size);
-		msleep(20);
-		if (!CSI_CONFIG) {
-			msm_camio_vfe_clk_rate_set(192000000);
-			s5k4e1_csi_params.data_format = CSI_10BIT;
-			s5k4e1_csi_params.lane_cnt = 1;
-			s5k4e1_csi_params.lane_assign = 0xe4;
-			s5k4e1_csi_params.dpcm_scheme = 0;
-			s5k4e1_csi_params.settle_cnt = 24;
-			rc = msm_camio_csi_config(&s5k4e1_csi_params);
-			msleep(20);
-			CSI_CONFIG = 1;
-		}
-		s5k4e1_start_stream();
-		msleep(30);
-	}
-	return rc;
-}
-
-static int32_t s5k4e1_video_config(int mode)
-{
-
-	int32_t rc = 0;
-	int rt;
-	CDBG("video config\n");
-	/* change sensor resolution if needed */
-	if (s5k4e1_ctrl->prev_res == QTR_SIZE)
-		rt = RES_PREVIEW;
-	else
-		rt = RES_CAPTURE;
-	if (s5k4e1_sensor_setting(UPDATE_PERIODIC, rt) < 0)
-		return rc;
-	if (s5k4e1_ctrl->set_test) {
-		if (s5k4e1_test(s5k4e1_ctrl->set_test) < 0)
-			return  rc;
-	}
-
-	s5k4e1_ctrl->curr_res = s5k4e1_ctrl->prev_res;
-	s5k4e1_ctrl->sensormode = mode;
-	return rc;
-}
-
-static int32_t s5k4e1_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-	int rt;
-
-	/*change sensor resolution if needed */
-	if (s5k4e1_ctrl->curr_res != s5k4e1_ctrl->pict_res) {
-		if (s5k4e1_ctrl->pict_res == QTR_SIZE)
-			rt = RES_PREVIEW;
-		else
-			rt = RES_CAPTURE;
-		if (s5k4e1_sensor_setting(UPDATE_PERIODIC, rt) < 0)
-			return rc;
-	}
-
-	s5k4e1_ctrl->curr_res = s5k4e1_ctrl->pict_res;
-	s5k4e1_ctrl->sensormode = mode;
-	return rc;
-}
-
-static int32_t s5k4e1_raw_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-	int rt;
-
-	/* change sensor resolution if needed */
-	if (s5k4e1_ctrl->curr_res != s5k4e1_ctrl->pict_res) {
-		if (s5k4e1_ctrl->pict_res == QTR_SIZE)
-			rt = RES_PREVIEW;
-		else
-			rt = RES_CAPTURE;
-		if (s5k4e1_sensor_setting(UPDATE_PERIODIC, rt) < 0)
-			return rc;
-	}
-
-	s5k4e1_ctrl->curr_res = s5k4e1_ctrl->pict_res;
-	s5k4e1_ctrl->sensormode = mode;
-	return rc;
-}
-
-static int32_t s5k4e1_set_sensor_mode(int mode,
-		int res)
-{
-	int32_t rc = 0;
-
-	switch (mode) {
-	case SENSOR_PREVIEW_MODE:
-		rc = s5k4e1_video_config(mode);
-		break;
-	case SENSOR_SNAPSHOT_MODE:
-		rc = s5k4e1_snapshot_config(mode);
-		break;
-	case SENSOR_RAW_SNAPSHOT_MODE:
-		rc = s5k4e1_raw_snapshot_config(mode);
-		break;
-	default:
-		rc = -EINVAL;
-		break;
-	}
-	return rc;
-}
-
-static int32_t s5k4e1_power_down(void)
-{
-	s5k4e1_stop_stream();
-	return 0;
-}
-
-static int s5k4e1_probe_init_done(const struct msm_camera_sensor_info *data)
-{
-	CDBG("probe done\n");
-	gpio_free(data->sensor_reset);
-	return 0;
-}
-
-static int s5k4e1_probe_init_sensor(const struct msm_camera_sensor_info *data)
-{
-	int32_t rc = 0;
-	uint16_t regaddress1 = 0x0000;
-	uint16_t regaddress2 = 0x0001;
-	uint16_t chipid1 = 0;
-	uint16_t chipid2 = 0;
-
-	CDBG("%s: %d\n", __func__, __LINE__);
-	CDBG(" s5k4e1_probe_init_sensor is called\n");
-
-	rc = gpio_request(data->sensor_reset, "s5k4e1");
-	CDBG(" s5k4e1_probe_init_sensor\n");
-	if (!rc) {
-		CDBG("sensor_reset = %d\n", rc);
-		gpio_direction_output(data->sensor_reset, 0);
-		msleep(50);
-		gpio_set_value_cansleep(data->sensor_reset, 1);
-		msleep(20);
-	} else
-		goto gpio_req_fail;
-
-	msleep(20);
-
-	s5k4e1_i2c_read(regaddress1, &chipid1, 1);
-	if (chipid1 != 0x4E) {
-		rc = -ENODEV;
-		CDBG("s5k4e1_probe_init_sensor fail chip id doesnot match\n");
-		goto init_probe_fail;
-	}
-
-	s5k4e1_i2c_read(regaddress2, &chipid2 , 1);
-	if (chipid2 != 0x10) {
-		rc = -ENODEV;
-		CDBG("s5k4e1_probe_init_sensor fail chip id doesnot match\n");
-		goto init_probe_fail;
-	}
-
-	CDBG("ID: %d\n", chipid1);
-	CDBG("ID: %d\n", chipid1);
-
-	return rc;
-
-init_probe_fail:
-	CDBG(" s5k4e1_probe_init_sensor fails\n");
-	gpio_set_value_cansleep(data->sensor_reset, 0);
-	s5k4e1_probe_init_done(data);
-	if (data->vcm_enable) {
-		int ret = gpio_request(data->vcm_pwd, "s5k4e1_af");
-		if (!ret) {
-			gpio_direction_output(data->vcm_pwd, 0);
-			msleep(20);
-			gpio_free(data->vcm_pwd);
-		}
-	}
-gpio_req_fail:
-	return rc;
-}
-
-int s5k4e1_sensor_open_init(const struct msm_camera_sensor_info *data)
-{
-	int32_t rc = 0;
-
-	CDBG("%s: %d\n", __func__, __LINE__);
-	CDBG("Calling s5k4e1_sensor_open_init\n");
-
-	s5k4e1_ctrl = kzalloc(sizeof(struct s5k4e1_ctrl_t), GFP_KERNEL);
-	if (!s5k4e1_ctrl) {
-		CDBG("s5k4e1_init failed!\n");
-		rc = -ENOMEM;
-		goto init_done;
-	}
-	s5k4e1_ctrl->fps_divider = 1 * 0x00000400;
-	s5k4e1_ctrl->pict_fps_divider = 1 * 0x00000400;
-	s5k4e1_ctrl->set_test = TEST_OFF;
-	s5k4e1_ctrl->prev_res = QTR_SIZE;
-	s5k4e1_ctrl->pict_res = FULL_SIZE;
-
-	if (data)
-		s5k4e1_ctrl->sensordata = data;
-
-	prev_frame_length_lines =
-	((s5k4e1_regs.reg_prev[S5K4E1_REG_PREV_FRAME_LEN_1].wdata << 8) |
-		s5k4e1_regs.reg_prev[S5K4E1_REG_PREV_FRAME_LEN_2].wdata);
-
-	prev_line_length_pck =
-	(s5k4e1_regs.reg_prev[S5K4E1_REG_PREV_LINE_LEN_1].wdata << 8) |
-		s5k4e1_regs.reg_prev[S5K4E1_REG_PREV_LINE_LEN_2].wdata;
-
-	snap_frame_length_lines =
-	(s5k4e1_regs.reg_snap[S5K4E1_REG_SNAP_FRAME_LEN_1].wdata << 8) |
-		s5k4e1_regs.reg_snap[S5K4E1_REG_SNAP_FRAME_LEN_2].wdata;
-
-	snap_line_length_pck =
-	(s5k4e1_regs.reg_snap[S5K4E1_REG_SNAP_LINE_LEN_1].wdata << 8) |
-		s5k4e1_regs.reg_snap[S5K4E1_REG_SNAP_LINE_LEN_1].wdata;
-
-	/* enable mclk first */
-	msm_camio_clk_rate_set(S5K4E1_MASTER_CLK_RATE);
-	rc = s5k4e1_probe_init_sensor(data);
-	if (rc < 0)
-		goto init_fail;
-
-	CDBG("init settings\n");
-	if (s5k4e1_ctrl->prev_res == QTR_SIZE)
-		rc = s5k4e1_sensor_setting(REG_INIT, RES_PREVIEW);
-	else
-		rc = s5k4e1_sensor_setting(REG_INIT, RES_CAPTURE);
-	s5k4e1_ctrl->fps = 30 * Q8;
-
-	/* enable AF actuator */
-	if (s5k4e1_ctrl->sensordata->vcm_enable) {
-		CDBG("enable AF actuator, gpio = %d\n",
-			 s5k4e1_ctrl->sensordata->vcm_pwd);
-		rc = gpio_request(s5k4e1_ctrl->sensordata->vcm_pwd,
-						"s5k4e1_af");
-		if (!rc)
-			gpio_direction_output(
-				s5k4e1_ctrl->sensordata->vcm_pwd,
-				 1);
-		else {
-			pr_err("s5k4e1_ctrl gpio request failed!\n");
-			goto init_fail;
-		}
-		msleep(20);
-		rc = s5k4e1_set_default_focus(0);
-		if (rc < 0) {
-			gpio_direction_output(s5k4e1_ctrl->sensordata->vcm_pwd,
-								0);
-			gpio_free(s5k4e1_ctrl->sensordata->vcm_pwd);
-		}
-	}
-	if (rc < 0)
-		goto init_fail;
-	else
-		goto init_done;
-init_fail:
-	CDBG("init_fail\n");
-	s5k4e1_probe_init_done(data);
-init_done:
-	CDBG("init_done\n");
-	return rc;
-}
-
-static int s5k4e1_init_client(struct i2c_client *client)
-{
-	/* Initialize the MSM_CAMI2C Chip */
-	init_waitqueue_head(&s5k4e1_wait_queue);
-	return 0;
-}
-
-static int s5k4e1_af_init_client(struct i2c_client *client)
-{
-	/* Initialize the MSM_CAMI2C Chip */
-	init_waitqueue_head(&s5k4e1_af_wait_queue);
-	return 0;
-}
-
-static const struct i2c_device_id s5k4e1_af_i2c_id[] = {
-	{"s5k4e1_af", 0},
-	{ }
-};
-
-static int s5k4e1_af_i2c_probe(struct i2c_client *client,
-		const struct i2c_device_id *id)
-{
-	int rc = 0;
-	CDBG("s5k4e1_af_probe called!\n");
-
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		CDBG("i2c_check_functionality failed\n");
-		goto probe_failure;
-	}
-
-	s5k4e1_af_sensorw = kzalloc(sizeof(struct s5k4e1_work_t), GFP_KERNEL);
-	if (!s5k4e1_af_sensorw) {
-		CDBG("kzalloc failed.\n");
-		rc = -ENOMEM;
-		goto probe_failure;
-	}
-
-	i2c_set_clientdata(client, s5k4e1_af_sensorw);
-	s5k4e1_af_init_client(client);
-	s5k4e1_af_client = client;
-
-	msleep(50);
-
-	CDBG("s5k4e1_af_probe successed! rc = %d\n", rc);
-	return 0;
-
-probe_failure:
-	CDBG("s5k4e1_af_probe failed! rc = %d\n", rc);
-	return rc;
-}
-
-static const struct i2c_device_id s5k4e1_i2c_id[] = {
-	{"s5k4e1", 0},
-	{ }
-};
-
-static int s5k4e1_i2c_probe(struct i2c_client *client,
-		const struct i2c_device_id *id)
-{
-	int rc = 0;
-	CDBG("s5k4e1_probe called!\n");
-
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		CDBG("i2c_check_functionality failed\n");
-		goto probe_failure;
-	}
-
-	s5k4e1_sensorw = kzalloc(sizeof(struct s5k4e1_work_t), GFP_KERNEL);
-	if (!s5k4e1_sensorw) {
-		CDBG("kzalloc failed.\n");
-		rc = -ENOMEM;
-		goto probe_failure;
-	}
-
-	i2c_set_clientdata(client, s5k4e1_sensorw);
-	s5k4e1_init_client(client);
-	s5k4e1_client = client;
-
-	msleep(50);
-
-	CDBG("s5k4e1_probe successed! rc = %d\n", rc);
-	return 0;
-
-probe_failure:
-	CDBG("s5k4e1_probe failed! rc = %d\n", rc);
-	return rc;
-}
-
-static int __devexit s5k4e1_remove(struct i2c_client *client)
-{
-	struct s5k4e1_work_t *sensorw = i2c_get_clientdata(client);
-	free_irq(client->irq, sensorw);
-	s5k4e1_client = NULL;
-	kfree(sensorw);
-	return 0;
-}
-
-static int __devexit s5k4e1_af_remove(struct i2c_client *client)
-{
-	struct s5k4e1_work_t *s5k4e1_af = i2c_get_clientdata(client);
-	free_irq(client->irq, s5k4e1_af);
-	s5k4e1_af_client = NULL;
-	kfree(s5k4e1_af);
-	return 0;
-}
-
-static struct i2c_driver s5k4e1_i2c_driver = {
-	.id_table = s5k4e1_i2c_id,
-	.probe  = s5k4e1_i2c_probe,
-	.remove = __exit_p(s5k4e1_i2c_remove),
-	.driver = {
-		.name = "s5k4e1",
-	},
-};
-
-static struct i2c_driver s5k4e1_af_i2c_driver = {
-	.id_table = s5k4e1_af_i2c_id,
-	.probe  = s5k4e1_af_i2c_probe,
-	.remove = __exit_p(s5k4e1_af_i2c_remove),
-	.driver = {
-		.name = "s5k4e1_af",
-	},
-};
-
-int s5k4e1_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(&s5k4e1_mut);
-	CDBG("s5k4e1_sensor_config: cfgtype = %d\n",
-			cdata.cfgtype);
-	switch (cdata.cfgtype) {
-	case CFG_GET_PICT_FPS:
-		s5k4e1_get_pict_fps(
-			cdata.cfg.gfps.prevfps,
-			&(cdata.cfg.gfps.pictfps));
-
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_GET_PREV_L_PF:
-		cdata.cfg.prevl_pf =
-			s5k4e1_get_prev_lines_pf();
-
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_GET_PREV_P_PL:
-		cdata.cfg.prevp_pl =
-			s5k4e1_get_prev_pixels_pl();
-
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_GET_PICT_L_PF:
-		cdata.cfg.pictl_pf =
-			s5k4e1_get_pict_lines_pf();
-
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_GET_PICT_P_PL:
-		cdata.cfg.pictp_pl =
-			s5k4e1_get_pict_pixels_pl();
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_GET_PICT_MAX_EXP_LC:
-		cdata.cfg.pict_max_exp_lc =
-			s5k4e1_get_pict_max_exp_lc();
-
-		if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_SET_FPS:
-	case CFG_SET_PICT_FPS:
-		rc = s5k4e1_set_fps(&(cdata.cfg.fps));
-		break;
-	case CFG_SET_EXP_GAIN:
-		rc = s5k4e1_write_exp_gain(cdata.cfg.exp_gain.gain,
-				cdata.cfg.exp_gain.line);
-		break;
-	case CFG_SET_PICT_EXP_GAIN:
-		rc = s5k4e1_set_pict_exp_gain(cdata.cfg.exp_gain.gain,
-				cdata.cfg.exp_gain.line);
-		break;
-	case CFG_SET_MODE:
-		rc = s5k4e1_set_sensor_mode(cdata.mode, cdata.rs);
-		break;
-	case CFG_PWR_DOWN:
-		rc = s5k4e1_power_down();
-		break;
-	case CFG_MOVE_FOCUS:
-		rc = s5k4e1_move_focus(cdata.cfg.focus.dir,
-				cdata.cfg.focus.steps);
-		break;
-	case CFG_SET_DEFAULT_FOCUS:
-		rc = s5k4e1_set_default_focus(cdata.cfg.focus.steps);
-		break;
-	case CFG_GET_AF_MAX_STEPS:
-		cdata.max_steps = S5K4E1_TOTAL_STEPS_NEAR_TO_FAR;
-		if (copy_to_user((void *)argp,
-					&cdata,
-				sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-	case CFG_SET_EFFECT:
-		rc = s5k4e1_set_default_focus(cdata.cfg.effect);
-		break;
-	default:
-		rc = -EFAULT;
-		break;
-	}
-	mutex_unlock(&s5k4e1_mut);
-
-	return rc;
-}
-
-static int s5k4e1_sensor_release(void)
-{
-	int rc = -EBADF;
-
-	mutex_lock(&s5k4e1_mut);
-	s5k4e1_power_down();
-	msleep(20);
-	gpio_set_value_cansleep(s5k4e1_ctrl->sensordata->sensor_reset, 0);
-	usleep_range(5000, 5100);
-	gpio_free(s5k4e1_ctrl->sensordata->sensor_reset);
-	if (s5k4e1_ctrl->sensordata->vcm_enable) {
-		gpio_set_value_cansleep(s5k4e1_ctrl->sensordata->vcm_pwd, 0);
-		gpio_free(s5k4e1_ctrl->sensordata->vcm_pwd);
-	}
-	kfree(s5k4e1_ctrl);
-	s5k4e1_ctrl = NULL;
-	CDBG("s5k4e1_release completed\n");
-	mutex_unlock(&s5k4e1_mut);
-
-	return rc;
-}
-
-static int s5k4e1_sensor_probe(const struct msm_camera_sensor_info *info,
-		struct msm_sensor_ctrl *s)
-{
-	int rc = 0;
-
-	rc = i2c_add_driver(&s5k4e1_i2c_driver);
-	if (rc < 0 || s5k4e1_client == NULL) {
-		rc = -ENOTSUPP;
-		CDBG("I2C add driver failed");
-		goto probe_fail_1;
-	}
-
-	rc = i2c_add_driver(&s5k4e1_af_i2c_driver);
-	if (rc < 0 || s5k4e1_af_client == NULL) {
-		rc = -ENOTSUPP;
-		CDBG("I2C add driver failed");
-		goto probe_fail_2;
-	}
-
-	msm_camio_clk_rate_set(S5K4E1_MASTER_CLK_RATE);
-
-	rc = s5k4e1_probe_init_sensor(info);
-	if (rc < 0)
-		goto probe_fail_3;
-
-	s->s_init = s5k4e1_sensor_open_init;
-	s->s_release = s5k4e1_sensor_release;
-	s->s_config  = s5k4e1_sensor_config;
-	s->s_mount_angle = info->sensor_platform_info->mount_angle;
-	gpio_set_value_cansleep(info->sensor_reset, 0);
-	s5k4e1_probe_init_done(info);
-	/* Keep vcm_pwd to OUT Low */
-	if (info->vcm_enable) {
-		rc = gpio_request(info->vcm_pwd, "s5k4e1_af");
-		if (!rc) {
-			gpio_direction_output(info->vcm_pwd, 0);
-			msleep(20);
-			gpio_free(info->vcm_pwd);
-		} else
-			return rc;
-	}
-	return rc;
-
-probe_fail_3:
-	i2c_del_driver(&s5k4e1_af_i2c_driver);
-probe_fail_2:
-	i2c_del_driver(&s5k4e1_i2c_driver);
-probe_fail_1:
-	CDBG("s5k4e1_sensor_probe: SENSOR PROBE FAILS!\n");
-	return rc;
-}
-
-static int __devinit s5k4e1_probe(struct platform_device *pdev)
-{
-	return msm_camera_drv_start(pdev, s5k4e1_sensor_probe);
-}
-
-static struct platform_driver msm_camera_driver = {
-	.probe = s5k4e1_probe,
-	.driver = {
-		.name = "msm_camera_s5k4e1",
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init s5k4e1_init(void)
-{
-	return platform_driver_register(&msm_camera_driver);
-}
-
-module_init(s5k4e1_init);
-MODULE_DESCRIPTION("Samsung 5 MP Bayer sensor driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/s5k4e1.h b/drivers/media/platform/msm/camera_v1/s5k4e1.h
deleted file mode 100644
index d58b3f0..0000000
--- a/drivers/media/platform/msm/camera_v1/s5k4e1.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- */
-
-#ifndef S5K4E1_H
-#define S5K4E1_H
-#include <linux/types.h>
-#include <mach/board.h>
-extern struct s5k4e1_reg s5k4e1_regs;
-
-struct s5k4e1_i2c_reg_conf {
-	unsigned short waddr;
-	unsigned short wdata;
-};
-
-enum s5k4e1_test_mode_t {
-	TEST_OFF,
-	TEST_1,
-	TEST_2,
-	TEST_3
-};
-
-enum s5k4e1_resolution_t {
-	QTR_SIZE,
-	FULL_SIZE,
-	INVALID_SIZE
-};
-enum s5k4e1_setting {
-	RES_PREVIEW,
-	RES_CAPTURE
-};
-enum s5k4e1_reg_update {
-	/* Sensor egisters that need to be updated during initialization */
-	REG_INIT,
-	/* Sensor egisters that needs periodic I2C writes */
-	UPDATE_PERIODIC,
-	/* All the sensor Registers will be updated */
-	UPDATE_ALL,
-	/* Not valid update */
-	UPDATE_INVALID
-};
-
-enum s5k4e1_reg_pll {
-	E013_VT_PIX_CLK_DIV,
-	E013_VT_SYS_CLK_DIV,
-	E013_PRE_PLL_CLK_DIV,
-	E013_PLL_MULTIPLIER,
-	E013_OP_PIX_CLK_DIV,
-	E013_OP_SYS_CLK_DIV
-};
-
-enum s5k4e1_reg_mode {
-	E013_X_ADDR_START,
-	E013_X_ADDR_END,
-	E013_Y_ADDR_START,
-	E013_Y_ADDR_END,
-	E013_X_OUTPUT_SIZE,
-	E013_Y_OUTPUT_SIZE,
-	E013_DATAPATH_SELECT,
-	E013_READ_MODE,
-	E013_ANALOG_CONTROL5,
-	E013_DAC_LD_4_5,
-	E013_SCALING_MODE,
-	E013_SCALE_M,
-	E013_LINE_LENGTH_PCK,
-	E013_FRAME_LENGTH_LINES,
-	E013_COARSE_INTEGRATION_TIME,
-	E013_FINE_INTEGRATION_TIME,
-	E013_FINE_CORRECTION
-};
-
-struct s5k4e1_reg {
-	const struct s5k4e1_i2c_reg_conf *reg_mipi;
-	const unsigned short reg_mipi_size;
-	const struct s5k4e1_i2c_reg_conf *rec_settings;
-	const unsigned short rec_size;
-	const struct s5k4e1_i2c_reg_conf *reg_pll_p;
-	const unsigned short reg_pll_p_size;
-	const struct s5k4e1_i2c_reg_conf *reg_pll_s;
-	const unsigned short reg_pll_s_size;
-	const struct s5k4e1_i2c_reg_conf *reg_prev;
-	const unsigned short reg_prev_size;
-	const struct s5k4e1_i2c_reg_conf *reg_snap;
-	const unsigned short reg_snap_size;
-};
-#endif /* S5K4E1_H */
diff --git a/drivers/media/platform/msm/camera_v1/s5k4e1_reg.c b/drivers/media/platform/msm/camera_v1/s5k4e1_reg.c
deleted file mode 100644
index 679ef17..0000000
--- a/drivers/media/platform/msm/camera_v1/s5k4e1_reg.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- */
-
-
-#include "s5k4e1.h"
-
-struct s5k4e1_i2c_reg_conf s5k4e1_mipi_settings[] = {
-	{0x30BD, 0x00},/* SEL_CCP[0] */
-	{0x3084, 0x15},/* SYNC Mode */
-	{0x30BE, 0x1A},/* M_PCLKDIV_AUTO[4], M_DIV_PCLK[3:0] */
-	{0x30C1, 0x01},/* pack video enable [0] */
-	{0x30EE, 0x02},/* DPHY enable [ 1] */
-	{0x3111, 0x86},/* Embedded data off [5] */
-};
-
-/* PLL Configuration */
-struct s5k4e1_i2c_reg_conf s5k4e1_pll_preview_settings[] = {
-	{0x0305, 0x04},
-	{0x0306, 0x00},
-	{0x0307, 0x44},
-	{0x30B5, 0x00},
-	{0x30E2, 0x01},/* num lanes[1:0] = 2 */
-	{0x30F1, 0xB0},
-};
-
-struct s5k4e1_i2c_reg_conf s5k4e1_pll_snap_settings[] = {
-	{0x0305, 0x04},
-	{0x0306, 0x00},
-	{0x0307, 0x44},
-	{0x30B5, 0x00},
-	{0x30E2, 0x01},/* num lanes[1:0] = 2 */
-	{0x30F1, 0xB0},
-};
-
-struct s5k4e1_i2c_reg_conf s5k4e1_prev_settings[] = {
-	/* output size (1304 x 980) */
-	{0x30A9, 0x02},/* Horizontal Binning On */
-	{0x300E, 0xEB},/* Vertical Binning On */
-	{0x0387, 0x03},/* y_odd_inc 03(10b AVG) */
-	{0x0344, 0x00},/* x_addr_start 0 */
-	{0x0345, 0x00},
-	{0x0348, 0x0A},/* x_addr_end 2607 */
-	{0x0349, 0x2F},
-	{0x0346, 0x00},/* y_addr_start 0 */
-	{0x0347, 0x00},
-	{0x034A, 0x07},/* y_addr_end 1959 */
-	{0x034B, 0xA7},
-	{0x0380, 0x00},/* x_even_inc 1 */
-	{0x0381, 0x01},
-	{0x0382, 0x00},/* x_odd_inc 1 */
-	{0x0383, 0x01},
-	{0x0384, 0x00},/* y_even_inc 1 */
-	{0x0385, 0x01},
-	{0x0386, 0x00},/* y_odd_inc 3 */
-	{0x0387, 0x03},
-	{0x034C, 0x05},/* x_output_size 1304 */
-	{0x034D, 0x18},
-	{0x034E, 0x03},/* y_output_size 980 */
-	{0x034F, 0xd4},
-	{0x30BF, 0xAB},/* outif_enable[7], data_type[5:0](2Bh = bayer 10bit} */
-	{0x30C0, 0xA0},/* video_offset[7:4] 3260%12 */
-	{0x30C8, 0x06},/* video_data_length 1600 = 1304 * 1.25 */
-	{0x30C9, 0x5E},
-	/* Timing Configuration */
-	{0x0202, 0x03},
-	{0x0203, 0x14},
-	{0x0204, 0x00},
-	{0x0205, 0x80},
-	{0x0340, 0x03},/* Frame Length */
-	{0x0341, 0xE0},
-	{0x0342, 0x0A},/* 2738  Line Length */
-	{0x0343, 0xB2},
-};
-
-struct s5k4e1_i2c_reg_conf s5k4e1_snap_settings[] = {
-	/*Output Size (2608x1960)*/
-	{0x30A9, 0x03},/* Horizontal Binning Off */
-	{0x300E, 0xE8},/* Vertical Binning Off */
-	{0x0387, 0x01},/* y_odd_inc */
-	{0x034C, 0x0A},/* x_output size */
-	{0x034D, 0x30},
-	{0x034E, 0x07},/* y_output size */
-	{0x034F, 0xA8},
-	{0x30BF, 0xAB},/* outif_enable[7], data_type[5:0](2Bh = bayer 10bit} */
-	{0x30C0, 0x80},/* video_offset[7:4] 3260%12 */
-	{0x30C8, 0x0C},/* video_data_length 3260 = 2608 * 1.25 */
-	{0x30C9, 0xBC},
-	/*Timing configuration*/
-	{0x0202, 0x06},
-	{0x0203, 0x28},
-	{0x0204, 0x00},
-	{0x0205, 0x80},
-	{0x0340, 0x07},/* Frame Length */
-	{0x0341, 0xB4},
-	{0x0342, 0x0A},/* 2738 Line Length */
-	{0x0343, 0xB2},
-};
-
-struct s5k4e1_i2c_reg_conf s5k4e1_recommend_settings[] = {
-	/*CDS timing setting ... */
-	{0x3000, 0x05},
-	{0x3001, 0x03},
-	{0x3002, 0x08},
-	{0x3003, 0x0A},
-	{0x3004, 0x50},
-	{0x3005, 0x0E},
-	{0x3006, 0x5E},
-	{0x3007, 0x00},
-	{0x3008, 0x78},
-	{0x3009, 0x78},
-	{0x300A, 0x50},
-	{0x300B, 0x08},
-	{0x300C, 0x14},
-	{0x300D, 0x00},
-	{0x300E, 0xE8},
-	{0x300F, 0x82},
-	{0x301B, 0x77},
-
-	/* CDS option setting ... */
-	{0x3010, 0x00},
-	{0x3011, 0x3A},
-	{0x3029, 0x04},
-	{0x3012, 0x30},
-	{0x3013, 0xA0},
-	{0x3014, 0x00},
-	{0x3015, 0x00},
-	{0x3016, 0x30},
-	{0x3017, 0x94},
-	{0x3018, 0x70},
-	{0x301D, 0xD4},
-	{0x3021, 0x02},
-	{0x3022, 0x24},
-	{0x3024, 0x40},
-	{0x3027, 0x08},
-
-	/* Pixel option setting ...   */
-	{0x301C, 0x04},
-	{0x30D8, 0x3F},
-	{0x302B, 0x01},
-
-	{0x3070, 0x5F},
-	{0x3071, 0x00},
-	{0x3080, 0x04},
-	{0x3081, 0x38},
-};
-
-struct s5k4e1_reg s5k4e1_regs = {
-	.reg_mipi = &s5k4e1_mipi_settings[0],
-	.reg_mipi_size = ARRAY_SIZE(s5k4e1_mipi_settings),
-	.rec_settings = &s5k4e1_recommend_settings[0],
-	.rec_size = ARRAY_SIZE(s5k4e1_recommend_settings),
-	.reg_pll_p = &s5k4e1_pll_preview_settings[0],
-	.reg_pll_p_size = ARRAY_SIZE(s5k4e1_pll_preview_settings),
-	.reg_pll_s = &s5k4e1_pll_snap_settings[0],
-	.reg_pll_s_size = ARRAY_SIZE(s5k4e1_pll_snap_settings),
-	.reg_prev = &s5k4e1_prev_settings[0],
-	.reg_prev_size = ARRAY_SIZE(s5k4e1_prev_settings),
-	.reg_snap = &s5k4e1_snap_settings[0],
-	.reg_snap_size = ARRAY_SIZE(s5k4e1_snap_settings),
-};
diff --git a/drivers/media/platform/msm/camera_v1/sensors/Makefile b/drivers/media/platform/msm/camera_v1/sensors/Makefile
deleted file mode 100644
index 174e9ba..0000000
--- a/drivers/media/platform/msm/camera_v1/sensors/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-GCC_VERSION      := $(shell $(CONFIG_SHELL) $(PWD)/scripts/gcc-version.sh $(CROSS_COMPILE)gcc)
-EXTRA_CFLAGS += -Idrivers/media/platform/msm/camera_v1
-EXTRA_CFLAGS += -Idrivers/media/platform/msm/camera_v1/io
-EXTRA_CFLAGS += -Idrivers/media/platform/msm/camera_v1/eeprom
-EXTRA_CFLAGS += -Idrivers/media/platform/msm/camera_v1/csi
-obj-$(CONFIG_MSM_CAMERA_SENSOR) += msm_sensor_common.o msm_sensor.o msm_sensor_bayer.o msm_sensor_init.o
-obj-$(CONFIG_OV5647) += ov5647_v4l2.o
-obj-$(CONFIG_OV8825) += ov8825_v4l2.o
-obj-$(CONFIG_IMX074) += imx074_v4l2.o
-obj-$(CONFIG_S5K3L1YX) += s5k3l1yx.o
-obj-$(CONFIG_IMX135) += imx135_v4l2.o
-obj-$(CONFIG_OV2720) += ov2720.o
-obj-$(CONFIG_MT9M114) += mt9m114_v4l2.o
-obj-$(CONFIG_S5K4E1) += s5k4e1_v4l2.o
-obj-$(CONFIG_MT9E013) += mt9e013_v4l2.o
-obj-$(CONFIG_WEBCAM_OV9726) += ov9726_v4l2.o
-obj-$(CONFIG_OV7692) += ov7692_v4l2.o
-obj-$(CONFIG_VX6953) += vx6953.o
diff --git a/drivers/media/platform/msm/camera_v1/sensors/imx074_v4l2.c b/drivers/media/platform/msm/camera_v1/sensors/imx074_v4l2.c
deleted file mode 100644
index f0759a8..0000000
--- a/drivers/media/platform/msm/camera_v1/sensors/imx074_v4l2.c
+++ /dev/null
@@ -1,291 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- *
- */
-
-#include "msm_sensor.h"
-#define SENSOR_NAME "imx074"
-#define PLATFORM_DRIVER_NAME "msm_camera_imx074"
-#define imx074_obj imx074_##obj
-
-DEFINE_MUTEX(imx074_mut);
-static struct msm_sensor_ctrl_t imx074_s_ctrl;
-
-static struct msm_camera_i2c_reg_conf imx074_start_settings[] = {
-	{0x0100, 0x01},
-};
-
-static struct msm_camera_i2c_reg_conf imx074_stop_settings[] = {
-	{0x0100, 0x00},
-};
-
-static struct msm_camera_i2c_reg_conf imx074_groupon_settings[] = {
-	{0x104, 0x01},
-};
-
-static struct msm_camera_i2c_reg_conf imx074_groupoff_settings[] = {
-	{0x104, 0x00},
-};
-
-static struct msm_camera_i2c_reg_conf imx074_prev_settings[] = {
-	{0x0307, 0x2D}, /*pll_multiplier*/
-	{0x0340, 0x06}, /*frame_length_lines_hi*/
-	{0x0341, 0x34}, /*frame_length_lines_lo*/
-	{0x0342, 0x11}, /*line_length_pclk_hi*/
-	{0x0343, 0x78}, /*line_length_pclk_lo*/
-	{0x0347, 0x00}, /*y_addr_start*/
-	{0x034b, 0x2F}, /*y_add_end*/
-	{0x034c, 0x08}, /*x_output_size_msb*/
-	{0x034d, 0x38}, /*x_output_size_lsb*/
-	{0x034e, 0x06}, /*y_output_size_msb*/
-	{0x034f, 0x18}, /*y_output_size_lsb*/
-	{0x0381, 0x01}, /*x_even_inc*/
-	{0x0383, 0x03}, /*x_odd_inc*/
-	{0x0385, 0x01}, /*y_even_inc*/
-	{0x0387, 0x03}, /*y_odd_inc*/
-	{0x3001, 0x80}, /*hmodeadd*/
-	{0x3016, 0x16}, /*vmodeadd*/
-	{0x3069, 0x24}, /*vapplinepos_start*/
-	{0x306b, 0x53}, /*vapplinepos_end*/
-	{0x3086, 0x00}, /*shutter*/
-	{0x30e8, 0x80}, /*haddave*/
-	{0x3301, 0x83}, /*lanesel*/
-};
-
-static struct msm_camera_i2c_reg_conf imx074_snap_settings[] = {
-	{0x0307, 0x26}, /*pll_multiplier*/
-	{0x0340, 0x0C}, /*frame_length_lines_hi*/
-	{0x0341, 0x90}, /*frame_length_lines_lo*/
-	{0x0342, 0x11}, /*line_length_pclk_hi*/
-	{0x0343, 0x78}, /*line_length_pclk_lo*/
-	{0x0347, 0x00}, /*y_addr_start*/
-	{0x034b, 0x2F}, /*y_add_end*/
-	{0x034c, 0x10}, /*x_output_size_msb*/
-	{0x034d, 0x70}, /*x_output_size_lsb*/
-	{0x034e, 0x0c}, /*y_output_size_msb*/
-	{0x034f, 0x30}, /*y_output_size_lsb*/
-	{0x0381, 0x01}, /*x_even_inc*/
-	{0x0383, 0x01}, /*x_odd_inc*/
-	{0x0385, 0x01}, /*y_even_inc*/
-	{0x0387, 0x01}, /*y_odd_inc*/
-	{0x3001, 0x00}, /*hmodeadd*/
-	{0x3016, 0x06}, /*vmodeadd*/
-	{0x3069, 0x24}, /*vapplinepos_start*/
-	{0x306b, 0x53}, /*vapplinepos_end*/
-	{0x3086, 0x00}, /*shutter*/
-	{0x30e8, 0x00}, /*haddave*/
-	{0x3301, 0x03}, /*lanesel*/
-};
-
-static struct msm_camera_i2c_reg_conf imx074_recommend_settings[] = {
-	{0x0305, 0x02},
-	{0x302b, 0x4B},
-	{0x3024, 0x03},
-	{0x0101, 0x00},
-	{0x300a, 0x80},
-	{0x3014, 0x08},
-	{0x3015, 0x37},
-	{0x301c, 0x01},
-	{0x302c, 0x05},
-	{0x3031, 0x26},
-	{0x3041, 0x60},
-	{0x3051, 0x24},
-	{0x3053, 0x34},
-	{0x3057, 0xc0},
-	{0x305c, 0x09},
-	{0x305d, 0x07},
-	{0x3060, 0x30},
-	{0x3065, 0x00},
-	{0x30aa, 0x08},
-	{0x30ab, 0x1c},
-	{0x30b0, 0x32},
-	{0x30b2, 0x83},
-	{0x30d3, 0x04},
-	{0x3106, 0x78},
-	{0x310c, 0x82},
-	{0x3304, 0x05},
-	{0x3305, 0x04},
-	{0x3306, 0x11},
-	{0x3307, 0x02},
-	{0x3308, 0x0c},
-	{0x3309, 0x06},
-	{0x330a, 0x08},
-	{0x330b, 0x04},
-	{0x330c, 0x08},
-	{0x330d, 0x06},
-	{0x330f, 0x01},
-	{0x3381, 0x00},
-};
-
-static struct v4l2_subdev_info imx074_subdev_info[] = {
-	{
-	.code   = V4L2_MBUS_FMT_SBGGR10_1X10,
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	.fmt    = 1,
-	.order    = 0,
-	},
-	/* more can be supported, to be added later */
-};
-
-static struct msm_camera_i2c_conf_array imx074_init_conf[] = {
-	{&imx074_recommend_settings[0],
-	ARRAY_SIZE(imx074_recommend_settings), 0, MSM_CAMERA_I2C_BYTE_DATA}
-};
-
-static struct msm_camera_i2c_conf_array imx074_confs[] = {
-	{&imx074_snap_settings[0],
-	ARRAY_SIZE(imx074_snap_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-	{&imx074_prev_settings[0],
-	ARRAY_SIZE(imx074_prev_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-};
-
-static struct msm_sensor_output_info_t imx074_dimensions[] = {
-	{
-		.x_output = 0x1070,
-		.y_output = 0xC30,
-		.line_length_pclk = 0x1178,
-		.frame_length_lines = 0xC90,
-		.vt_pixel_clk = 182400000,
-		.op_pixel_clk = 182400000,
-		.binning_factor = 1,
-	},
-	{
-		.x_output = 0x838,
-		.y_output = 0x618,
-		.line_length_pclk = 0x1178,
-		.frame_length_lines = 0x634,
-		.vt_pixel_clk = 216000000,
-		.op_pixel_clk = 108000000,
-		.binning_factor = 2,
-	},
-};
-
-static struct msm_sensor_output_reg_addr_t imx074_reg_addr = {
-	.x_output = 0x34C,
-	.y_output = 0x34E,
-	.line_length_pclk = 0x342,
-	.frame_length_lines = 0x340,
-};
-
-static struct msm_sensor_id_info_t imx074_id_info = {
-	.sensor_id_reg_addr = 0x0,
-	.sensor_id = 0x0074,
-};
-
-static struct msm_sensor_exp_gain_info_t imx074_exp_gain_info = {
-	.coarse_int_time_addr = 0x202,
-	.global_gain_addr = 0x204,
-	.vert_offset = 3,
-};
-
-static enum msm_camera_vreg_name_t imx074_veg_seq[] = {
-	CAM_VDIG,
-	CAM_VIO,
-	CAM_VANA,
-	CAM_VAF,
-};
-
-static const struct i2c_device_id imx074_i2c_id[] = {
-	{SENSOR_NAME, (kernel_ulong_t)&imx074_s_ctrl},
-	{ }
-};
-
-static struct i2c_driver imx074_i2c_driver = {
-	.id_table = imx074_i2c_id,
-	.probe  = msm_sensor_i2c_probe,
-	.driver = {
-		.name = SENSOR_NAME,
-	},
-};
-
-static struct msm_camera_i2c_client imx074_sensor_i2c_client = {
-	.addr_type = MSM_CAMERA_I2C_WORD_ADDR,
-};
-
-static int __init msm_sensor_init_module(void)
-{
-	return i2c_add_driver(&imx074_i2c_driver);
-}
-
-static struct v4l2_subdev_core_ops imx074_subdev_core_ops = {
-	.ioctl = msm_sensor_subdev_ioctl,
-	.s_power = msm_sensor_power,
-};
-
-static struct v4l2_subdev_video_ops imx074_subdev_video_ops = {
-	.enum_mbus_fmt = msm_sensor_v4l2_enum_fmt,
-};
-
-static struct v4l2_subdev_ops imx074_subdev_ops = {
-	.core = &imx074_subdev_core_ops,
-	.video  = &imx074_subdev_video_ops,
-};
-
-static struct msm_sensor_fn_t imx074_func_tbl = {
-	.sensor_start_stream = msm_sensor_start_stream,
-	.sensor_stop_stream = msm_sensor_stop_stream,
-	.sensor_group_hold_on = msm_sensor_group_hold_on,
-	.sensor_group_hold_off = msm_sensor_group_hold_off,
-	.sensor_set_fps = msm_sensor_set_fps,
-	.sensor_write_exp_gain = msm_sensor_write_exp_gain1,
-	.sensor_write_snapshot_exp_gain = msm_sensor_write_exp_gain1,
-	.sensor_setting = msm_sensor_setting,
-	.sensor_csi_setting = msm_sensor_setting1,
-	.sensor_set_sensor_mode = msm_sensor_set_sensor_mode,
-	.sensor_mode_init = msm_sensor_mode_init,
-	.sensor_get_output_info = msm_sensor_get_output_info,
-	.sensor_config = msm_sensor_config,
-	.sensor_power_up = msm_sensor_power_up,
-	.sensor_power_down = msm_sensor_power_down,
-	.sensor_adjust_frame_lines = msm_sensor_adjust_frame_lines1,
-	.sensor_get_csi_params = msm_sensor_get_csi_params,
-};
-
-static struct msm_sensor_reg_t imx074_regs = {
-	.default_data_type = MSM_CAMERA_I2C_BYTE_DATA,
-	.start_stream_conf = imx074_start_settings,
-	.start_stream_conf_size = ARRAY_SIZE(imx074_start_settings),
-	.stop_stream_conf = imx074_stop_settings,
-	.stop_stream_conf_size = ARRAY_SIZE(imx074_stop_settings),
-	.group_hold_on_conf = imx074_groupon_settings,
-	.group_hold_on_conf_size = ARRAY_SIZE(imx074_groupon_settings),
-	.group_hold_off_conf = imx074_groupoff_settings,
-	.group_hold_off_conf_size =
-		ARRAY_SIZE(imx074_groupoff_settings),
-	.init_settings = &imx074_init_conf[0],
-	.init_size = ARRAY_SIZE(imx074_init_conf),
-	.mode_settings = &imx074_confs[0],
-	.output_settings = &imx074_dimensions[0],
-	.num_conf = ARRAY_SIZE(imx074_confs),
-};
-
-static struct msm_sensor_ctrl_t imx074_s_ctrl = {
-	.msm_sensor_reg = &imx074_regs,
-	.sensor_i2c_client = &imx074_sensor_i2c_client,
-	.sensor_i2c_addr = 0x34,
-	.vreg_seq = imx074_veg_seq,
-	.num_vreg_seq = ARRAY_SIZE(imx074_veg_seq),
-	.sensor_output_reg_addr = &imx074_reg_addr,
-	.sensor_id_info = &imx074_id_info,
-	.sensor_exp_gain_info = &imx074_exp_gain_info,
-	.cam_mode = MSM_SENSOR_MODE_INVALID,
-	.msm_sensor_mutex = &imx074_mut,
-	.sensor_i2c_driver = &imx074_i2c_driver,
-	.sensor_v4l2_subdev_info = imx074_subdev_info,
-	.sensor_v4l2_subdev_info_size = ARRAY_SIZE(imx074_subdev_info),
-	.sensor_v4l2_subdev_ops = &imx074_subdev_ops,
-	.func_tbl = &imx074_func_tbl,
-	.clk_rate = MSM_SENSOR_MCLK_24HZ,
-};
-
-module_init(msm_sensor_init_module);
-MODULE_DESCRIPTION("Sony 13MP Bayer sensor driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/sensors/imx091.h b/drivers/media/platform/msm/camera_v1/sensors/imx091.h
deleted file mode 100644
index a909138..0000000
--- a/drivers/media/platform/msm/camera_v1/sensors/imx091.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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 IMX091_SENSOR_NAME "imx091"
-DEFINE_MSM_MUTEX(imx091_mut);
-
-static struct msm_sensor_ctrl_t imx091_s_ctrl;
-
-static struct v4l2_subdev_info imx091_subdev_info[] = {
-	{
-	.code   = V4L2_MBUS_FMT_SBGGR10_1X10,
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	.fmt    = 1,
-	.order    = 0,
-	},
-	/* more can be supported, to be added later */
-};
-
-static struct msm_sensor_id_info_t imx091_id_info = {
-	.sensor_id_reg_addr = 0x0000,
-	.sensor_id = 0x0091,
-};
-
-static enum msm_camera_vreg_name_t imx091_veg_seq[] = {
-	CAM_VANA,
-	CAM_VAF,
-	CAM_VDIG,
-	CAM_VIO,
-};
-
-static struct msm_camera_power_seq_t imx091_power_seq[] = {
-	{REQUEST_GPIO, 0},
-	{REQUEST_VREG, 0},
-	{ENABLE_VREG, 0},
-	{ENABLE_GPIO, 0},
-	{CONFIG_CLK, 1},
-	{CONFIG_I2C_MUX, 0},
-};
-
-static const struct i2c_device_id imx091_i2c_id[] = {
-	{IMX091_SENSOR_NAME, (kernel_ulong_t)&imx091_s_ctrl},
-	{ }
-};
-
-static struct i2c_driver imx091_i2c_driver = {
-	.id_table = imx091_i2c_id,
-	.probe  = msm_sensor_bayer_i2c_probe,
-	.driver = {
-		.name = IMX091_SENSOR_NAME,
-	},
-};
-
-static struct msm_camera_i2c_client imx091_sensor_i2c_client = {
-	.addr_type = MSM_CAMERA_I2C_WORD_ADDR,
-};
-
-static struct v4l2_subdev_core_ops imx091_subdev_core_ops = {
-	.ioctl = msm_sensor_bayer_subdev_ioctl,
-	.s_power = msm_sensor_bayer_power,
-};
-
-static struct v4l2_subdev_video_ops imx091_subdev_video_ops = {
-	.enum_mbus_fmt = msm_sensor_bayer_v4l2_enum_fmt,
-};
-
-static struct v4l2_subdev_ops imx091_subdev_ops = {
-	.core = &imx091_subdev_core_ops,
-	.video  = &imx091_subdev_video_ops,
-};
-
-static struct msm_sensor_fn_t imx091_func_tbl = {
-	.sensor_config = msm_sensor_bayer_config,
-	.sensor_power_up = msm_sensor_bayer_power_up,
-	.sensor_power_down = msm_sensor_bayer_power_down,
-	.sensor_get_csi_params = msm_sensor_bayer_get_csi_params,
-	.sensor_read_eeprom = msm_sensor_bayer_eeprom_read,
-};
-
-static struct msm_sensor_ctrl_t imx091_s_ctrl = {
-	.sensor_i2c_client = &imx091_sensor_i2c_client,
-	.sensor_i2c_addr = 0x34,
-	.vreg_seq = imx091_veg_seq,
-	.num_vreg_seq = ARRAY_SIZE(imx091_veg_seq),
-	.power_seq = &imx091_power_seq[0],
-	.num_power_seq = ARRAY_SIZE(imx091_power_seq),
-	.sensor_id_info = &imx091_id_info,
-	.msm_sensor_mutex = &imx091_mut,
-	.sensor_v4l2_subdev_info = imx091_subdev_info,
-	.sensor_v4l2_subdev_info_size = ARRAY_SIZE(imx091_subdev_info),
-	.sensor_v4l2_subdev_ops = &imx091_subdev_ops,
-	.func_tbl = &imx091_func_tbl,
-	.clk_rate = MSM_SENSOR_MCLK_24HZ,
-};
diff --git a/drivers/media/platform/msm/camera_v1/sensors/imx135_v4l2.c b/drivers/media/platform/msm/camera_v1/sensors/imx135_v4l2.c
deleted file mode 100644
index 98e2999..0000000
--- a/drivers/media/platform/msm/camera_v1/sensors/imx135_v4l2.c
+++ /dev/null
@@ -1,1289 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- *
- */
-
-#include "msm_sensor.h"
-#define SENSOR_NAME "imx135"
-#define PLATFORM_DRIVER_NAME "msm_camera_imx135"
-#define imx135_obj imx135_##obj
-
-DEFINE_MUTEX(imx135_mut);
-static struct msm_sensor_ctrl_t imx135_s_ctrl;
-
-static struct msm_camera_i2c_reg_conf imx135_start_settings[] = {
-	{0x0100, 0x01},
-};
-
-static struct msm_camera_i2c_reg_conf imx135_stop_settings[] = {
-	{0x0100, 0x00},
-};
-
-static struct msm_camera_i2c_reg_conf imx135_groupon_settings[] = {
-	{0x104, 0x01},
-};
-
-static struct msm_camera_i2c_reg_conf imx135_groupoff_settings[] = {
-	{0x104, 0x00},
-};
-
-static struct msm_camera_i2c_reg_conf imx135_recommend_settings[] = {
-/* Global Settings */
-	{0x0101, 0x00},
-	{0x0105, 0x01},
-	{0x0110, 0x00},
-	{0x0220, 0x01},
-	{0x3302, 0x11},
-	{0x3833, 0x20},
-	{0x3893, 0x00},
-	{0x3906, 0x08},
-	{0x3907, 0x01},
-	{0x391B, 0x01},
-	{0x3C09, 0x01},
-	{0x600A, 0x00},
-	{0x3008, 0xB0},
-	{0x320A, 0x01},
-	{0x320D, 0x10},
-	{0x3216, 0x2E},
-	{0x322C, 0x02},
-	{0x3409, 0x0C},
-	{0x340C, 0x2D},
-	{0x3411, 0x39},
-	{0x3414, 0x1E},
-	{0x3427, 0x04},
-	{0x3480, 0x1E},
-	{0x3484, 0x1E},
-	{0x3488, 0x1E},
-	{0x348C, 0x1E},
-	{0x3490, 0x1E},
-	{0x3494, 0x1E},
-	{0x3511, 0x8F},
-	{0x364F, 0x2D},
-	/*Defect Correction Recommended Setting */
-	{0x380A, 0x00},
-	{0x380B, 0x00},
-	{0x4103, 0x00},
-	/*Color Artifact Recommended Setting */
-	{0x4243, 0x9A},
-	{0x4330, 0x01},
-	{0x4331, 0x90},
-	{0x4332, 0x02},
-	{0x4333, 0x58},
-	{0x4334, 0x03},
-	{0x4335, 0x20},
-	{0x4336, 0x03},
-	{0x4337, 0x84},
-	{0x433C, 0x01},
-	{0x4340, 0x02},
-	{0x4341, 0x58},
-	{0x4342, 0x03},
-	{0x4343, 0x52},
-	/*Moiré reduction Parameter Setting	*/
-	{0x4364, 0x0B},
-	{0x4368, 0x00},
-	{0x4369, 0x0F},
-	{0x436A, 0x03},
-	{0x436B, 0xA8},
-	{0x436C, 0x00},
-	{0x436D, 0x00},
-	{0x436E, 0x00},
-	{0x436F, 0x06},
-	/*CNR parameter setting	*/
-	{0x4281, 0x21},
-	{0x4282, 0x18},
-	{0x4283, 0x04},
-	{0x4284, 0x08},
-	{0x4287, 0x7F},
-	{0x4288, 0x08},
-	{0x428B, 0x7F},
-	{0x428C, 0x08},
-	{0x428F, 0x7F},
-	{0x4297, 0x00},
-	{0x4298, 0x7E},
-	{0x4299, 0x7E},
-	{0x429A, 0x7E},
-	{0x42A4, 0xFB},
-	{0x42A5, 0x7E},
-	{0x42A6, 0xDF},
-	{0x42A7, 0xB7},
-	{0x42AF, 0x03},
-	/*ARNR Parameter Setting*/
-	{0x4207, 0x03},
-	{0x4216, 0x08},
-	{0x4217, 0x08},
-	/*DLC Parameter Setting*/
-	{0x4218, 0x00},
-	{0x421B, 0x20},
-	{0x421F, 0x04},
-	{0x4222, 0x02},
-	{0x4223, 0x22},
-	{0x422E, 0x54},
-	{0x422F, 0xFB},
-	{0x4230, 0xFF},
-	{0x4231, 0xFE},
-	{0x4232, 0xFF},
-	{0x4235, 0x58},
-	{0x4236, 0xF7},
-	{0x4237, 0xFD},
-	{0x4239, 0x4E},
-	{0x423A, 0xFC},
-	{0x423B, 0xFD},
-	/*HDR Setting*/
-	{0x4300, 0x00},
-	{0x4316, 0x12},
-	{0x4317, 0x22},
-	{0x4318, 0x00},
-	{0x4319, 0x00},
-	{0x431A, 0x00},
-	{0x4324, 0x03},
-	{0x4325, 0x20},
-	{0x4326, 0x03},
-	{0x4327, 0x84},
-	{0x4328, 0x03},
-	{0x4329, 0x20},
-	{0x432A, 0x03},
-	{0x432B, 0x20},
-	{0x432C, 0x01},
-	{0x432D, 0x01},
-	{0x4338, 0x02},
-	{0x4339, 0x00},
-	{0x433A, 0x00},
-	{0x433B, 0x02},
-	{0x435A, 0x03},
-	{0x435B, 0x84},
-	{0x435E, 0x01},
-	{0x435F, 0xFF},
-	{0x4360, 0x01},
-	{0x4361, 0xF4},
-	{0x4362, 0x03},
-	{0x4363, 0x84},
-	{0x437B, 0x01},
-	{0x4401, 0x03}, /*0x3F*/
-	{0x4402, 0xFF},
-	{0x4404, 0x13},
-	{0x4405, 0x26},
-	{0x4406, 0x07},
-	{0x4408, 0x20},
-	{0x4409, 0xE5},
-	{0x440A, 0xFB},
-	{0x440C, 0xF6},
-	{0x440D, 0xEA},
-	{0x440E, 0x20},
-	{0x4410, 0x00},
-	{0x4411, 0x00},
-	{0x4412, 0x3F},
-	{0x4413, 0xFF},
-	{0x4414, 0x1F},
-	{0x4415, 0xFF},
-	{0x4416, 0x20},
-	{0x4417, 0x00},
-	{0x4418, 0x1F},
-	{0x4419, 0xFF},
-	{0x441A, 0x20},
-	{0x441B, 0x00},
-	{0x441D, 0x40},
-	{0x441E, 0x1E},
-	{0x441F, 0x38},
-	{0x4420, 0x01},
-	{0x4444, 0x00},
-	{0x4445, 0x00},
-	{0x4446, 0x1D},
-	{0x4447, 0xF9},
-	{0x4452, 0x00},
-	{0x4453, 0xA0},
-	{0x4454, 0x08},
-	{0x4455, 0x00},
-	{0x4456, 0x0F},
-	{0x4457, 0xFF},
-	{0x4458, 0x18},
-	{0x4459, 0x18},
-	{0x445A, 0x3F},
-	{0x445B, 0x3A},
-	{0x445C, 0x00},
-	{0x445D, 0x28},
-	{0x445E, 0x01},
-	{0x445F, 0x90},
-	{0x4460, 0x00},
-	{0x4461, 0x60},
-	{0x4462, 0x00},
-	{0x4463, 0x00},
-	{0x4464, 0x00},
-	{0x4465, 0x00},
-	{0x446C, 0x00},
-	{0x446D, 0x00},
-	{0x446E, 0x00},
-	/*LSC Setting*/
-	{0x452A, 0x02},
-	/*White Balance Setting */
-	{0x0712, 0x01},
-	{0x0713, 0x00},
-	{0x0714, 0x01},
-	{0x0715, 0x00},
-	{0x0716, 0x01},
-	{0x0717, 0x00},
-	{0x0718, 0x01},
-	{0x0719, 0x00},
-	/*Shading setting*/
-	{0x4500, 0x1F},
-};
-
-static struct msm_camera_i2c_reg_conf imx135_prev_settings[] = {
-	/* Clock Setting */
-	{0x011E, 0x18},
-	{0x011F, 0x00},
-	{0x0301, 0x05},
-	{0x0303, 0x01},
-	{0x0305, 0x03},
-	{0x0309, 0x05},
-	{0x030B, 0x02},
-	{0x030C, 0x00},
-	{0x030D, 0x71},
-	{0x030E, 0x01},
-	{0x3A06, 0x12},
-	/* Mode setting */
-	{0x0108, 0x03},
-	{0x0112, 0x0A},
-	{0x0113, 0x0A},
-	{0x0381, 0x01},
-	{0x0383, 0x01},
-	{0x0385, 0x01},
-	{0x0387, 0x01},
-	{0x0390, 0x01},
-	{0x0391, 0x22},
-	{0x0392, 0x00},
-	{0x0401, 0x00},
-	{0x0404, 0x00},
-	{0x0405, 0x10},
-	{0x4082, 0x01},
-	{0x4083, 0x01},
-	{0x7006, 0x04},
-	/* OptionalFunction setting */
-	{0x0700, 0x00},
-	{0x3A63, 0x00},
-	{0x4100, 0xF8},
-	{0x4203, 0xFF},
-	{0x4344, 0x00},
-	{0x441C, 0x01},
-	/* Size setting	*/
-	{0x0340, 0x06},
-	{0x0341, 0x2E},
-	{0x0342, 0x11},
-	{0x0343, 0xDC},
-	{0x0344, 0x00},
-	{0x0345, 0x00},
-	{0x0346, 0x00},
-	{0x0347, 0x00},
-	{0x0348, 0x10},
-	{0x0349, 0x6F},
-	{0x034A, 0x0C},
-	{0x034B, 0x2F},
-	{0x034C, 0x08},
-	{0x034D, 0x38},
-	{0x034E, 0x06},
-	{0x034F, 0x18},
-	{0x0350, 0x00},
-	{0x0351, 0x00},
-	{0x0352, 0x00},
-	{0x0353, 0x00},
-	{0x0354, 0x08},
-	{0x0355, 0x38},
-	{0x0356, 0x06},
-	{0x0357, 0x18},
-	{0x301D, 0x30},
-	{0x3310, 0x08},
-	{0x3311, 0x38},
-	{0x3312, 0x06},
-	{0x3313, 0x18},
-	{0x331C, 0x00},
-	{0x331D, 0x52},
-	{0x4084, 0x00},
-	{0x4085, 0x00},
-	{0x4086, 0x00},
-	{0x4087, 0x00},
-	{0x4400, 0x00},
-	/* Global Timing Setting */
-	{0x0830, 0x67},
-	{0x0831, 0x27},
-	{0x0832, 0x47},
-	{0x0833, 0x27},
-	{0x0834, 0x27},
-	{0x0835, 0x1F},
-	{0x0836, 0x87},
-	{0x0837, 0x2F},
-	{0x0839, 0x1F},
-	{0x083A, 0x17},
-	{0x083B, 0x02},
-	/* Integration Time Setting */
-	{0x0202, 0x06},
-	{0x0203, 0x2A},
-	/* Gain Setting	*/
-	{0x0205, 0x00},
-	{0x020E, 0x01},
-	{0x020F, 0x00},
-	{0x0210, 0x01},
-	{0x0211, 0x00},
-	{0x0212, 0x01},
-	{0x0213, 0x00},
-	{0x0214, 0x01},
-	{0x0215, 0x00},
-	/* HDR Setting */
-	{0x0230, 0x00},
-	{0x0231, 0x00},
-	{0x0233, 0x00},
-	{0x0234, 0x00},
-	{0x0235, 0x40},
-	{0x0238, 0x00},
-	{0x0239, 0x04},
-	{0x023B, 0x00},
-	{0x023C, 0x01},
-	{0x33B0, 0x04},
-	{0x33B1, 0x00},
-	{0x33B3, 0x00},
-	{0x33B4, 0x00},
-	{0x3800, 0x00},
-};
-
-static struct msm_camera_i2c_reg_conf imx135_LSCTable_settings[] = {
-	{0x4800, 0x02},
-	{0x4801, 0x68},
-	{0x4802, 0x02},
-	{0x4803, 0x4f},
-	{0x4804, 0x02},
-	{0x4805, 0x10},
-	{0x4806, 0x01},
-	{0x4807, 0xf3},
-	{0x4808, 0x01},
-	{0x4809, 0xc3},
-	{0x480a, 0x01},
-	{0x480b, 0xb3},
-	{0x480c, 0x01},
-	{0x480d, 0x9a},
-	{0x480e, 0x01},
-	{0x480f, 0x8e},
-	{0x4810, 0x01},
-	{0x4811, 0x84},
-	{0x4812, 0x01},
-	{0x4813, 0x7f},
-	{0x4814, 0x01},
-	{0x4815, 0x94},
-	{0x4816, 0x01},
-	{0x4817, 0x8a},
-	{0x4818, 0x01},
-	{0x4819, 0xb7},
-	{0x481a, 0x01},
-	{0x481b, 0xa6},
-	{0x481c, 0x01},
-	{0x481d, 0xf9},
-	{0x481e, 0x01},
-	{0x481f, 0xe2},
-	{0x4820, 0x02},
-	{0x4821, 0x62},
-	{0x4822, 0x02},
-	{0x4823, 0x37},
-	{0x4824, 0x02},
-	{0x4825, 0x26},
-	{0x4826, 0x02},
-	{0x4827, 0x0c},
-	{0x4828, 0x01},
-	{0x4829, 0xbb},
-	{0x482a, 0x01},
-	{0x482b, 0xaf},
-	{0x482c, 0x01},
-	{0x482d, 0x7c},
-	{0x482e, 0x01},
-	{0x482f, 0x70},
-	{0x4830, 0x01},
-	{0x4831, 0x50},
-	{0x4832, 0x01},
-	{0x4833, 0x4b},
-	{0x4834, 0x01},
-	{0x4835, 0x3e},
-	{0x4836, 0x01},
-	{0x4837, 0x39},
-	{0x4838, 0x01},
-	{0x4839, 0x4c},
-	{0x483a, 0x01},
-	{0x483b, 0x45},
-	{0x483c, 0x01},
-	{0x483d, 0x74},
-	{0x483e, 0x01},
-	{0x483f, 0x63},
-	{0x4840, 0x01},
-	{0x4841, 0xae},
-	{0x4842, 0x01},
-	{0x4843, 0x97},
-	{0x4844, 0x02},
-	{0x4845, 0x07},
-	{0x4846, 0x01},
-	{0x4847, 0xeb},
-	{0x4848, 0x01},
-	{0x4849, 0xf6},
-	{0x484a, 0x01},
-	{0x484b, 0xdf},
-	{0x484c, 0x01},
-	{0x484d, 0x93},
-	{0x484e, 0x01},
-	{0x484f, 0x8d},
-	{0x4850, 0x01},
-	{0x4851, 0x50},
-	{0x4852, 0x01},
-	{0x4853, 0x4b},
-	{0x4854, 0x01},
-	{0x4855, 0x22},
-	{0x4856, 0x01},
-	{0x4857, 0x20},
-	{0x4858, 0x01},
-	{0x4859, 0x10},
-	{0x485a, 0x01},
-	{0x485b, 0x0e},
-	{0x485c, 0x01},
-	{0x485d, 0x1d},
-	{0x485e, 0x01},
-	{0x485f, 0x18},
-	{0x4860, 0x01},
-	{0x4861, 0x48},
-	{0x4862, 0x01},
-	{0x4863, 0x3f},
-	{0x4864, 0x01},
-	{0x4865, 0x85},
-	{0x4866, 0x01},
-	{0x4867, 0x7b},
-	{0x4868, 0x01},
-	{0x4869, 0xd9},
-	{0x486a, 0x01},
-	{0x486b, 0xc5},
-	{0x486c, 0x01},
-	{0x486d, 0xdf},
-	{0x486e, 0x01},
-	{0x486f, 0xcf},
-	{0x4870, 0x01},
-	{0x4871, 0x87},
-	{0x4872, 0x01},
-	{0x4873, 0x7f},
-	{0x4874, 0x01},
-	{0x4875, 0x3d},
-	{0x4876, 0x01},
-	{0x4877, 0x3a},
-	{0x4878, 0x01},
-	{0x4879, 0x10},
-	{0x487a, 0x01},
-	{0x487b, 0x0e},
-	{0x487c, 0x01},
-	{0x487d, 0x00},
-	{0x487e, 0x01},
-	{0x487f, 0x00},
-	{0x4880, 0x01},
-	{0x4881, 0x0a},
-	{0x4882, 0x01},
-	{0x4883, 0x07},
-	{0x4884, 0x01},
-	{0x4885, 0x34},
-	{0x4886, 0x01},
-	{0x4887, 0x2f},
-	{0x4888, 0x01},
-	{0x4889, 0x77},
-	{0x488a, 0x01},
-	{0x488b, 0x69},
-	{0x488c, 0x01},
-	{0x488d, 0xcc},
-	{0x488e, 0x01},
-	{0x488f, 0xb9},
-	{0x4890, 0x01},
-	{0x4891, 0xea},
-	{0x4892, 0x01},
-	{0x4893, 0xdf},
-	{0x4894, 0x01},
-	{0x4895, 0x93},
-	{0x4896, 0x01},
-	{0x4897, 0x86},
-	{0x4898, 0x01},
-	{0x4899, 0x4c},
-	{0x489a, 0x01},
-	{0x489b, 0x48},
-	{0x489c, 0x01},
-	{0x489d, 0x20},
-	{0x489e, 0x01},
-	{0x489f, 0x1c},
-	{0x48a0, 0x01},
-	{0x48a1, 0x0d},
-	{0x48a2, 0x01},
-	{0x48a3, 0x09},
-	{0x48a4, 0x01},
-	{0x48a5, 0x1a},
-	{0x48a6, 0x01},
-	{0x48a7, 0x15},
-	{0x48a8, 0x01},
-	{0x48a9, 0x43},
-	{0x48aa, 0x01},
-	{0x48ab, 0x3d},
-	{0x48ac, 0x01},
-	{0x48ad, 0x84},
-	{0x48ae, 0x01},
-	{0x48af, 0x75},
-	{0x48b0, 0x01},
-	{0x48b1, 0xd3},
-	{0x48b2, 0x01},
-	{0x48b3, 0xbf},
-	{0x48b4, 0x02},
-	{0x48b5, 0x23},
-	{0x48b6, 0x02},
-	{0x48b7, 0x07},
-	{0x48b8, 0x01},
-	{0x48b9, 0xbc},
-	{0x48ba, 0x01},
-	{0x48bb, 0xac},
-	{0x48bc, 0x01},
-	{0x48bd, 0x7a},
-	{0x48be, 0x01},
-	{0x48bf, 0x6f},
-	{0x48c0, 0x01},
-	{0x48c1, 0x4c},
-	{0x48c2, 0x01},
-	{0x48c3, 0x47},
-	{0x48c4, 0x01},
-	{0x48c5, 0x3d},
-	{0x48c6, 0x01},
-	{0x48c7, 0x37},
-	{0x48c8, 0x01},
-	{0x48c9, 0x48},
-	{0x48ca, 0x01},
-	{0x48cb, 0x40},
-	{0x48cc, 0x01},
-	{0x48cd, 0x70},
-	{0x48ce, 0x01},
-	{0x48cf, 0x61},
-	{0x48d0, 0x01},
-	{0x48d1, 0xab},
-	{0x48d2, 0x01},
-	{0x48d3, 0x9a},
-	{0x48d4, 0x02},
-	{0x48d5, 0x03},
-	{0x48d6, 0x01},
-	{0x48d7, 0xe6},
-	{0x48d8, 0x02},
-	{0x48d9, 0x71},
-	{0x48da, 0x02},
-	{0x48db, 0x4a},
-	{0x48dc, 0x02},
-	{0x48dd, 0x07},
-	{0x48de, 0x01},
-	{0x48df, 0xef},
-	{0x48e0, 0x01},
-	{0x48e1, 0xbf},
-	{0x48e2, 0x01},
-	{0x48e3, 0xae},
-	{0x48e4, 0x01},
-	{0x48e5, 0x97},
-	{0x48e6, 0x01},
-	{0x48e7, 0x89},
-	{0x48e8, 0x01},
-	{0x48e9, 0x82},
-	{0x48ea, 0x01},
-	{0x48eb, 0x7a},
-	{0x48ec, 0x01},
-	{0x48ed, 0x91},
-	{0x48ee, 0x01},
-	{0x48ef, 0x83},
-	{0x48f0, 0x01},
-	{0x48f1, 0xb7},
-	{0x48f2, 0x01},
-	{0x48f3, 0xa9},
-	{0x48f4, 0x01},
-	{0x48f5, 0xf0},
-	{0x48f6, 0x01},
-	{0x48f7, 0xd9},
-	{0x48f8, 0x02},
-	{0x48f9, 0x55},
-	{0x48fa, 0x02},
-	{0x48fb, 0x32},
-	{0x48fc, 0x02},
-	{0x48fd, 0x4b},
-	{0x48fe, 0x02},
-	{0x48ff, 0x4c},
-	{0x4900, 0x01},
-	{0x4901, 0xec},
-	{0x4902, 0x01},
-	{0x4903, 0xf2},
-	{0x4904, 0x01},
-	{0x4905, 0xb1},
-	{0x4906, 0x01},
-	{0x4907, 0xb7},
-	{0x4908, 0x01},
-	{0x4909, 0x8a},
-	{0x490a, 0x01},
-	{0x490b, 0x8c},
-	{0x490c, 0x01},
-	{0x490d, 0x7d},
-	{0x490e, 0x01},
-	{0x490f, 0x7d},
-	{0x4910, 0x01},
-	{0x4911, 0x87},
-	{0x4912, 0x01},
-	{0x4913, 0x87},
-	{0x4914, 0x01},
-	{0x4915, 0xa8},
-	{0x4916, 0x01},
-	{0x4917, 0xa8},
-	{0x4918, 0x01},
-	{0x4919, 0xe2},
-	{0x491a, 0x01},
-	{0x491b, 0xda},
-	{0x491c, 0x02},
-	{0x491d, 0x38},
-	{0x491e, 0x02},
-	{0x491f, 0x30},
-	{0x4920, 0x02},
-	{0x4921, 0x0a},
-	{0x4922, 0x02},
-	{0x4923, 0x0e},
-	{0x4924, 0x01},
-	{0x4925, 0xae},
-	{0x4926, 0x01},
-	{0x4927, 0xaf},
-	{0x4928, 0x01},
-	{0x4929, 0x71},
-	{0x492a, 0x01},
-	{0x492b, 0x74},
-	{0x492c, 0x01},
-	{0x492d, 0x4b},
-	{0x492e, 0x01},
-	{0x492f, 0x4a},
-	{0x4930, 0x01},
-	{0x4931, 0x3b},
-	{0x4932, 0x01},
-	{0x4933, 0x3c},
-	{0x4934, 0x01},
-	{0x4935, 0x46},
-	{0x4936, 0x01},
-	{0x4937, 0x47},
-	{0x4938, 0x01},
-	{0x4939, 0x68},
-	{0x493a, 0x01},
-	{0x493b, 0x68},
-	{0x493c, 0x01},
-	{0x493d, 0x9e},
-	{0x493e, 0x01},
-	{0x493f, 0xa0},
-	{0x4940, 0x01},
-	{0x4941, 0xf4},
-	{0x4942, 0x01},
-	{0x4943, 0xec},
-	{0x4944, 0x01},
-	{0x4945, 0xdc},
-	{0x4946, 0x01},
-	{0x4947, 0xe7},
-	{0x4948, 0x01},
-	{0x4949, 0x8a},
-	{0x494a, 0x01},
-	{0x494b, 0x8e},
-	{0x494c, 0x01},
-	{0x494d, 0x4b},
-	{0x494e, 0x01},
-	{0x494f, 0x4b},
-	{0x4950, 0x01},
-	{0x4951, 0x1e},
-	{0x4952, 0x01},
-	{0x4953, 0x1f},
-	{0x4954, 0x01},
-	{0x4955, 0x0c},
-	{0x4956, 0x01},
-	{0x4957, 0x0b},
-	{0x4958, 0x01},
-	{0x4959, 0x18},
-	{0x495a, 0x01},
-	{0x495b, 0x17},
-	{0x495c, 0x01},
-	{0x495d, 0x42},
-	{0x495e, 0x01},
-	{0x495f, 0x3f},
-	{0x4960, 0x01},
-	{0x4961, 0x7b},
-	{0x4962, 0x01},
-	{0x4963, 0x79},
-	{0x4964, 0x01},
-	{0x4965, 0xcb},
-	{0x4966, 0x01},
-	{0x4967, 0xc1},
-	{0x4968, 0x01},
-	{0x4969, 0xd4},
-	{0x496a, 0x01},
-	{0x496b, 0xd4},
-	{0x496c, 0x01},
-	{0x496d, 0x80},
-	{0x496e, 0x01},
-	{0x496f, 0x81},
-	{0x4970, 0x01},
-	{0x4971, 0x3e},
-	{0x4972, 0x01},
-	{0x4973, 0x3a},
-	{0x4974, 0x01},
-	{0x4975, 0x10},
-	{0x4976, 0x01},
-	{0x4977, 0x0d},
-	{0x4978, 0x01},
-	{0x4979, 0x00},
-	{0x497a, 0x01},
-	{0x497b, 0x00},
-	{0x497c, 0x01},
-	{0x497d, 0x07},
-	{0x497e, 0x01},
-	{0x497f, 0x08},
-	{0x4980, 0x01},
-	{0x4981, 0x34},
-	{0x4982, 0x01},
-	{0x4983, 0x32},
-	{0x4984, 0x01},
-	{0x4985, 0x72},
-	{0x4986, 0x01},
-	{0x4987, 0x6d},
-	{0x4988, 0x01},
-	{0x4989, 0xc1},
-	{0x498a, 0x01},
-	{0x498b, 0xb6},
-	{0x498c, 0x01},
-	{0x498d, 0xe1},
-	{0x498e, 0x01},
-	{0x498f, 0xe5},
-	{0x4990, 0x01},
-	{0x4991, 0x8d},
-	{0x4992, 0x01},
-	{0x4993, 0x8f},
-	{0x4994, 0x01},
-	{0x4995, 0x4c},
-	{0x4996, 0x01},
-	{0x4997, 0x4d},
-	{0x4998, 0x01},
-	{0x4999, 0x1d},
-	{0x499a, 0x01},
-	{0x499b, 0x1d},
-	{0x499c, 0x01},
-	{0x499d, 0x0b},
-	{0x499e, 0x01},
-	{0x499f, 0x0b},
-	{0x49a0, 0x01},
-	{0x49a1, 0x18},
-	{0x49a2, 0x01},
-	{0x49a3, 0x16},
-	{0x49a4, 0x01},
-	{0x49a5, 0x40},
-	{0x49a6, 0x01},
-	{0x49a7, 0x3f},
-	{0x49a8, 0x01},
-	{0x49a9, 0x7c},
-	{0x49aa, 0x01},
-	{0x49ab, 0x77},
-	{0x49ac, 0x01},
-	{0x49ad, 0xcb},
-	{0x49ae, 0x01},
-	{0x49af, 0xc8},
-	{0x49b0, 0x02},
-	{0x49b1, 0x0a},
-	{0x49b2, 0x02},
-	{0x49b3, 0x0f},
-	{0x49b4, 0x01},
-	{0x49b5, 0xad},
-	{0x49b6, 0x01},
-	{0x49b7, 0xaf},
-	{0x49b8, 0x01},
-	{0x49b9, 0x74},
-	{0x49ba, 0x01},
-	{0x49bb, 0x73},
-	{0x49bc, 0x01},
-	{0x49bd, 0x49},
-	{0x49be, 0x01},
-	{0x49bf, 0x48},
-	{0x49c0, 0x01},
-	{0x49c1, 0x37},
-	{0x49c2, 0x01},
-	{0x49c3, 0x37},
-	{0x49c4, 0x01},
-	{0x49c5, 0x44},
-	{0x49c6, 0x01},
-	{0x49c7, 0x3f},
-	{0x49c8, 0x01},
-	{0x49c9, 0x68},
-	{0x49ca, 0x01},
-	{0x49cb, 0x65},
-	{0x49cc, 0x01},
-	{0x49cd, 0xa2},
-	{0x49ce, 0x01},
-	{0x49cf, 0x9d},
-	{0x49d0, 0x01},
-	{0x49d1, 0xf0},
-	{0x49d2, 0x01},
-	{0x49d3, 0xe6},
-	{0x49d4, 0x02},
-	{0x49d5, 0x4f},
-	{0x49d6, 0x02},
-	{0x49d7, 0x4c},
-	{0x49d8, 0x01},
-	{0x49d9, 0xf4},
-	{0x49da, 0x01},
-	{0x49db, 0xf8},
-	{0x49dc, 0x01},
-	{0x49dd, 0xb6},
-	{0x49de, 0x01},
-	{0x49df, 0xb4},
-	{0x49e0, 0x01},
-	{0x49e1, 0x90},
-	{0x49e2, 0x01},
-	{0x49e3, 0x91},
-	{0x49e4, 0x01},
-	{0x49e5, 0x7f},
-	{0x49e6, 0x01},
-	{0x49e7, 0x81},
-	{0x49e8, 0x01},
-	{0x49e9, 0x8a},
-	{0x49ea, 0x01},
-	{0x49eb, 0x88},
-	{0x49ec, 0x01},
-	{0x49ed, 0xa8},
-	{0x49ee, 0x01},
-	{0x49ef, 0xa9},
-	{0x49f0, 0x01},
-	{0x49f1, 0xde},
-	{0x49f2, 0x01},
-	{0x49f3, 0xd9},
-	{0x49f4, 0x02},
-	{0x49f5, 0x3b},
-	{0x49f6, 0x02},
-	{0x49f7, 0x30},
-	{0x3A63, 0x01},
-};
-
-static struct msm_camera_i2c_reg_conf imx135_snap_settings[] = {
-	/* Clock Setting	*/
-	{0x011E, 0x18},
-	{0x011F, 0x00},
-	{0x0301, 0x05},
-	{0x0303, 0x01},
-	{0x0305, 0x03},
-	{0x0309, 0x05},
-	{0x030B, 0x01},
-	{0x030C, 0x00},
-	{0x030D, 0x60},/*0x64*/
-	{0x030E, 0x01},
-	{0x3A06, 0x11},
-	/* Mode setting */
-	{0x0108, 0x03},
-	{0x0112, 0x0A},
-	{0x0113, 0x0A},
-	{0x0381, 0x01},
-	{0x0383, 0x01},
-	{0x0385, 0x01},
-	{0x0387, 0x01},
-	{0x0390, 0x00},
-	{0x0391, 0x11},
-	{0x0392, 0x00},
-	{0x0401, 0x00},
-	{0x0404, 0x00},
-	{0x0405, 0x10},
-	{0x4082, 0x01},
-	{0x4083, 0x01},
-	{0x7006, 0x04},
-	/* OptionalFunction setting */
-	{0x0700, 0x00},
-	{0x3A63, 0x00},
-	{0x4100, 0xF8},
-	{0x4203, 0xFF},
-	{0x4344, 0x00},
-	{0x441C, 0x01},
-	/* Size setting	*/
-	{0x0340, 0x0C},
-	{0x0341, 0x46},
-	{0x0342, 0x11},
-	{0x0343, 0xDC},
-	{0x0344, 0x00},
-	{0x0345, 0x00},
-	{0x0346, 0x00},
-	{0x0347, 0x00},
-	{0x0348, 0x10},
-	{0x0349, 0x6F},
-	{0x034A, 0x0C},
-	{0x034B, 0x2F},
-	{0x034C, 0x10},
-	{0x034D, 0x70},
-	{0x034E, 0x0C},
-	{0x034F, 0x30},
-	{0x0350, 0x00},
-	{0x0351, 0x00},
-	{0x0352, 0x00},
-	{0x0353, 0x00},
-	{0x0354, 0x10},
-	{0x0355, 0x70},
-	{0x0356, 0x0C},
-	{0x0357, 0x30},
-	{0x301D, 0x30},
-	{0x3310, 0x10},
-	{0x3311, 0x70},
-	{0x3312, 0x0C},
-	{0x3313, 0x30},
-	{0x331C, 0x01},
-	{0x331D, 0x68},
-	{0x4084, 0x00},
-	{0x4085, 0x00},
-	{0x4086, 0x00},
-	{0x4087, 0x00},
-	{0x4400, 0x00},
-	/* Global Timing Setting */
-	{0x0830, 0x7F},
-	{0x0831, 0x37},
-	{0x0832, 0x5F},
-	{0x0833, 0x37},
-	{0x0834, 0x37},
-	{0x0835, 0x3F},
-	{0x0836, 0xC7},
-	{0x0837, 0x3F},
-	{0x0839, 0x1F},
-	{0x083A, 0x17},
-	{0x083B, 0x02},
-	/* Integration Time Setting */
-	{0x0202, 0x0C},
-	{0x0203, 0x42},
-	/* Gain Setting	*/
-	{0x0205, 0x00},
-	{0x020E, 0x01},
-	{0x020F, 0x00},
-	{0x0210, 0x01},
-	{0x0211, 0x00},
-	{0x0212, 0x01},
-	{0x0213, 0x00},
-	{0x0214, 0x01},
-	{0x0215, 0x00},
-	/* HDR Setting */
-	{0x0230, 0x00},
-	{0x0231, 0x00},
-	{0x0233, 0x00},
-	{0x0234, 0x00},
-	{0x0235, 0x40},
-	{0x0238, 0x00},
-	{0x0239, 0x04},
-	{0x023B, 0x00},
-	{0x023C, 0x01},
-	{0x33B0, 0x04},
-	{0x33B1, 0x00},
-	{0x33B3, 0x00},
-	{0x33B4, 0x00},
-	{0x3800, 0x00},
-};
-
-static struct msm_camera_i2c_reg_conf imx135_hdr_settings[] = {
-	/* Clock Setting */
-	{0x011E, 0x18},
-	{0x011F, 0x00},
-	{0x0301, 0x05},
-	{0x0303, 0x01},
-	{0x0305, 0x03},
-	{0x0309, 0x05},
-	{0x030B, 0x02},
-	{0x030C, 0x00},
-	{0x030D, 0x71},
-	{0x030E, 0x01},
-	{0x3A06, 0x12},
-	/* Mode setting	*/
-	{0x0108, 0x03},
-	{0x0112, 0x0E},
-	{0x0113, 0x0A},
-	{0x0381, 0x01},
-	{0x0383, 0x01},
-	{0x0385, 0x01},
-	{0x0387, 0x01},
-	{0x0390, 0x00},
-	{0x0391, 0x11},
-	{0x0392, 0x00},
-	{0x0401, 0x00},
-	{0x0404, 0x00},
-	{0x0405, 0x10},
-	{0x4082, 0x01},
-	{0x4083, 0x01},
-	{0x7006, 0x04},
-	/* OptionnalFunction setting */
-	{0x0700, 0x01},
-	{0x3A63, 0x00},
-	{0x4100, 0xF8},
-	{0x4203, 0xFF},
-	{0x4344, 0x00},
-	{0x441C, 0x01},
-	/* Size setting	*/
-	{0x0340, 0x0C},
-	{0x0341, 0x48},
-	{0x0342, 0x11},
-	{0x0343, 0xDC},
-	{0x0344, 0x00},
-	{0x0345, 0x08},
-	{0x0346, 0x00},
-	{0x0347, 0x00},
-	{0x0348, 0x10},
-	{0x0349, 0x67},
-	{0x034A, 0x0C},
-	{0x034B, 0x2F},
-	{0x034C, 0x08},
-	{0x034D, 0x30},
-	{0x034E, 0x06},
-	{0x034F, 0x18},
-	{0x0350, 0x00},
-	{0x0351, 0x00},
-	{0x0352, 0x00},
-	{0x0353, 0x00},
-	{0x0354, 0x08},
-	{0x0355, 0x30},
-	{0x0356, 0x06},
-	{0x0357, 0x18},
-	{0x301D, 0x30},
-	{0x3310, 0x08},
-	{0x3311, 0x30},
-	{0x3312, 0x06},
-	{0x3313, 0x18},
-	{0x331C, 0x00},
-	{0x331D, 0x10},
-	{0x4084, 0x00},
-	{0x4085, 0x00},
-	{0x4086, 0x00},
-	{0x4087, 0x00},
-	{0x4400, 0x00},
-	/*Global Timing Setting	*/
-	{0x0830, 0x67},
-	{0x0831, 0x27},
-	{0x0832, 0x47},
-	{0x0833, 0x27},
-	{0x0834, 0x27},
-	{0x0835, 0x1F},
-	{0x0836, 0x87},
-	{0x0837, 0x2F},
-	{0x0839, 0x1F},
-	{0x083A, 0x17},
-	{0x083B, 0x02},
-	/*Integration Time Setting*/
-	{0x0202, 0x0C},
-	{0x0203, 0x44},
-	/*Gain Setting */
-	{0x0205, 0x00},
-	{0x020E, 0x01},
-	{0x020F, 0x00},
-	{0x0210, 0x01},
-	{0x0211, 0x00},
-	{0x0212, 0x01},
-	{0x0213, 0x00},
-	{0x0214, 0x01},
-	{0x0215, 0x00},
-	/* HDR Setting */
-	{0x0230, 0x00},
-	{0x0231, 0x00},
-	{0x0233, 0x00},
-	{0x0234, 0x00},
-	{0x0235, 0x40},
-	{0x0238, 0x01}, /*Direct 1 / Auto 0*/
-	{0x0239, 0x04},
-	{0x023B, 0x03},
-	{0x023C, 0x01},
-	{0x33B0, 0x08},
-	{0x33B1, 0x30},
-	{0x33B3, 0x01},
-	{0x33B4, 0x00},
-	{0x3800, 0x00},
-};
-
-static struct v4l2_subdev_info imx135_subdev_info[] = {
-	{
-	.code		= V4L2_MBUS_FMT_SBGGR10_1X10,
-	.colorspace	= V4L2_COLORSPACE_JPEG,
-	.fmt		= 1,
-	.order		= 0,
-	},
-	/* more can be supported, to be added later */
-};
-
-static struct msm_camera_i2c_conf_array imx135_init_conf[] = {
-	{&imx135_recommend_settings[0],
-	ARRAY_SIZE(imx135_recommend_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-	{&imx135_LSCTable_settings[0],
-	ARRAY_SIZE(imx135_LSCTable_settings), 0, MSM_CAMERA_I2C_BYTE_DATA}
-};
-
-static struct msm_camera_i2c_conf_array imx135_confs[] = {
-	{&imx135_snap_settings[0],
-	ARRAY_SIZE(imx135_snap_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-	{&imx135_prev_settings[0],
-	ARRAY_SIZE(imx135_prev_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-	{&imx135_hdr_settings[0],
-	ARRAY_SIZE(imx135_hdr_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-};
-
-static struct msm_sensor_output_info_t imx135_dimensions[] = {
-	/* RES0 snapshot(FULL SIZE) */
-	{
-		.x_output = 4208,
-		.y_output = 3120,
-		.line_length_pclk = 4572,
-		.frame_length_lines = 3290,
-		.vt_pixel_clk = 360000000,
-		.op_pixel_clk = 319680000,
-		.binning_factor = 1,
-	},
-	/* RES1 4:3 preview(1/2HV QTR SIZE) */
-	{
-		.x_output = 2104,
-		.y_output = 1560,
-		.line_length_pclk = 4572,
-		.frame_length_lines = 1582,
-		.vt_pixel_clk = 360000000,
-		.op_pixel_clk = 180000000,
-		.binning_factor = 1,
-	},
-	/* RES2 4:3 HDR movie mode */
-	{
-		.x_output = 2096,
-		.y_output = 1560,
-		.line_length_pclk = 4572,
-		.frame_length_lines = 3290,
-		.vt_pixel_clk = 360000000,
-		.op_pixel_clk = 180000000,
-		.binning_factor = 1,
-	},
-};
-
-static struct msm_sensor_output_reg_addr_t imx135_reg_addr = {
-	.x_output = 0x34C,
-	.y_output = 0x34E,
-	.line_length_pclk = 0x342,
-	.frame_length_lines = 0x340,
-};
-
-static struct msm_sensor_id_info_t imx135_id_info = {
-	.sensor_id_reg_addr = 0x0000,
-	.sensor_id = 0x1210,
-};
-
-static struct msm_sensor_exp_gain_info_t imx135_exp_gain_info = {
-	.coarse_int_time_addr = 0x202,
-	.global_gain_addr = 0x205,
-	.vert_offset = 4,
-};
-
-static const struct i2c_device_id imx135_i2c_id[] = {
-	{SENSOR_NAME, (kernel_ulong_t)&imx135_s_ctrl},
-	{ }
-};
-
-static struct i2c_driver imx135_i2c_driver = {
-	.id_table = imx135_i2c_id,
-	.probe  = msm_sensor_i2c_probe,
-	.driver = {
-		.name = SENSOR_NAME,
-	},
-};
-
-static struct msm_camera_i2c_client imx135_sensor_i2c_client = {
-	.addr_type = MSM_CAMERA_I2C_WORD_ADDR,
-};
-
-static int __init msm_sensor_init_module(void)
-{
-	return i2c_add_driver(&imx135_i2c_driver);
-}
-
-static struct v4l2_subdev_core_ops imx135_subdev_core_ops = {
-	.ioctl = msm_sensor_subdev_ioctl,
-	.s_power = msm_sensor_power,
-};
-
-static struct v4l2_subdev_video_ops imx135_subdev_video_ops = {
-	.enum_mbus_fmt = msm_sensor_v4l2_enum_fmt,
-};
-
-static struct v4l2_subdev_ops imx135_subdev_ops = {
-	.core = &imx135_subdev_core_ops,
-	.video  = &imx135_subdev_video_ops,
-};
-
-int32_t imx135_write_exp_gain(struct msm_sensor_ctrl_t *s_ctrl,
-		uint16_t gain, uint32_t line)
-{
-	uint32_t fl_lines;
-	uint8_t offset;
-	fl_lines = s_ctrl->curr_frame_length_lines;
-	fl_lines = (fl_lines * s_ctrl->fps_divider) / Q10;
-	offset = s_ctrl->sensor_exp_gain_info->vert_offset;
-	if (line > (fl_lines - offset))
-		fl_lines = line + offset;
-
-	s_ctrl->func_tbl->sensor_group_hold_on(s_ctrl);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_output_reg_addr->frame_length_lines, fl_lines,
-		MSM_CAMERA_I2C_WORD_DATA);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->coarse_int_time_addr, line,
-		MSM_CAMERA_I2C_WORD_DATA);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->global_gain_addr, gain,
-		MSM_CAMERA_I2C_BYTE_DATA);
-	s_ctrl->func_tbl->sensor_group_hold_off(s_ctrl);
-	return 0;
-}
-
-static struct msm_sensor_fn_t imx135_func_tbl = {
-	.sensor_start_stream = msm_sensor_start_stream,
-	.sensor_stop_stream = msm_sensor_stop_stream,
-	.sensor_group_hold_on = msm_sensor_group_hold_on,
-	.sensor_group_hold_off = msm_sensor_group_hold_off,
-	.sensor_set_fps = msm_sensor_set_fps,
-	.sensor_write_exp_gain = imx135_write_exp_gain,
-	.sensor_write_snapshot_exp_gain = imx135_write_exp_gain,
-	.sensor_setting = msm_sensor_setting,
-	.sensor_csi_setting = msm_sensor_setting1,
-	.sensor_set_sensor_mode = msm_sensor_set_sensor_mode,
-	.sensor_mode_init = msm_sensor_mode_init,
-	.sensor_get_output_info = msm_sensor_get_output_info,
-	.sensor_config = msm_sensor_config,
-	.sensor_power_up = msm_sensor_power_up,
-	.sensor_power_down = msm_sensor_power_down,
-	.sensor_adjust_frame_lines = msm_sensor_adjust_frame_lines1,
-	.sensor_get_csi_params = msm_sensor_get_csi_params,
-};
-
-static struct msm_sensor_reg_t imx135_regs = {
-	.default_data_type = MSM_CAMERA_I2C_BYTE_DATA,
-	.start_stream_conf = imx135_start_settings,
-	.start_stream_conf_size = ARRAY_SIZE(imx135_start_settings),
-	.stop_stream_conf = imx135_stop_settings,
-	.stop_stream_conf_size = ARRAY_SIZE(imx135_stop_settings),
-	.group_hold_on_conf = imx135_groupon_settings,
-	.group_hold_on_conf_size = ARRAY_SIZE(imx135_groupon_settings),
-	.group_hold_off_conf = imx135_groupoff_settings,
-	.group_hold_off_conf_size =
-		ARRAY_SIZE(imx135_groupoff_settings),
-	.init_settings = &imx135_init_conf[0],
-	.init_size = ARRAY_SIZE(imx135_init_conf),
-	.mode_settings = &imx135_confs[0],
-	.output_settings = &imx135_dimensions[0],
-	.num_conf = ARRAY_SIZE(imx135_confs),
-};
-
-static struct msm_sensor_ctrl_t imx135_s_ctrl = {
-	.msm_sensor_reg = &imx135_regs,
-	.sensor_i2c_client = &imx135_sensor_i2c_client,
-	.sensor_i2c_addr = 0x20,
-	.sensor_output_reg_addr = &imx135_reg_addr,
-	.sensor_id_info = &imx135_id_info,
-	.sensor_exp_gain_info = &imx135_exp_gain_info,
-	.cam_mode = MSM_SENSOR_MODE_INVALID,
-	.msm_sensor_mutex = &imx135_mut,
-	.sensor_i2c_driver = &imx135_i2c_driver,
-	.sensor_v4l2_subdev_info = imx135_subdev_info,
-	.sensor_v4l2_subdev_info_size = ARRAY_SIZE(imx135_subdev_info),
-	.sensor_v4l2_subdev_ops = &imx135_subdev_ops,
-	.func_tbl = &imx135_func_tbl,
-	.clk_rate = MSM_SENSOR_MCLK_24HZ,
-};
-
-module_init(msm_sensor_init_module);
-MODULE_DESCRIPTION("Sony 13MP Bayer sensor driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/sensors/msm_sensor.c b/drivers/media/platform/msm/camera_v1/sensors/msm_sensor.c
deleted file mode 100644
index 3df963a..0000000
--- a/drivers/media/platform/msm/camera_v1/sensors/msm_sensor.c
+++ /dev/null
@@ -1,1975 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-#include <mach/msm_bus.h>
-#include <mach/msm_bus_board.h>
-#include "msm_sensor.h"
-#include "msm_sensor_common.h"
-#include "msm.h"
-#include "msm_ispif.h"
-#include "msm_camera_i2c_mux.h"
-
-/*=============================================================*/
-void msm_sensor_adjust_frame_lines1(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	uint16_t cur_line = 0;
-	uint16_t exp_fl_lines = 0;
-	if (s_ctrl->sensor_exp_gain_info) {
-		msm_camera_i2c_read(s_ctrl->sensor_i2c_client,
-			s_ctrl->sensor_exp_gain_info->coarse_int_time_addr,
-			&cur_line,
-			MSM_CAMERA_I2C_WORD_DATA);
-		exp_fl_lines = cur_line +
-			s_ctrl->sensor_exp_gain_info->vert_offset;
-		if (exp_fl_lines > s_ctrl->msm_sensor_reg->
-			output_settings[s_ctrl->curr_res].frame_length_lines)
-			msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-				s_ctrl->sensor_output_reg_addr->
-				frame_length_lines,
-				exp_fl_lines,
-				MSM_CAMERA_I2C_WORD_DATA);
-		CDBG("%s cur_fl_lines %d, exp_fl_lines %d\n", __func__,
-			s_ctrl->msm_sensor_reg->
-			output_settings[s_ctrl->curr_res].frame_length_lines,
-			exp_fl_lines);
-	}
-	return;
-}
-
-void msm_sensor_adjust_frame_lines2(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	uint16_t cur_line = 0;
-	uint16_t exp_fl_lines = 0;
-	uint8_t int_time[3];
-	if (s_ctrl->sensor_exp_gain_info) {
-		msm_camera_i2c_read_seq(s_ctrl->sensor_i2c_client,
-			s_ctrl->sensor_exp_gain_info->coarse_int_time_addr-1,
-			&int_time[0], 3);
-		cur_line |= int_time[0] << 12;
-		cur_line |= int_time[1] << 4;
-		cur_line |= int_time[2] >> 4;
-		exp_fl_lines = cur_line +
-			s_ctrl->sensor_exp_gain_info->vert_offset;
-		if (exp_fl_lines > s_ctrl->msm_sensor_reg->
-			output_settings[s_ctrl->curr_res].frame_length_lines)
-			msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-				s_ctrl->sensor_output_reg_addr->
-				frame_length_lines,
-				exp_fl_lines,
-				MSM_CAMERA_I2C_WORD_DATA);
-		CDBG("%s cur_line %x cur_fl_lines %x, exp_fl_lines %x\n",
-			__func__,
-			cur_line,
-			s_ctrl->msm_sensor_reg->
-			output_settings[s_ctrl->curr_res].frame_length_lines,
-			exp_fl_lines);
-	}
-	return;
-}
-
-static void msm_sensor_delay_frames(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	long fps = 0;
-	uint32_t delay = 0;
-
-	if (s_ctrl->curr_res < MSM_SENSOR_INVALID_RES &&
-		s_ctrl->wait_num_frames > 0) {
-		fps = s_ctrl->msm_sensor_reg->
-			output_settings[s_ctrl->curr_res].vt_pixel_clk /
-			s_ctrl->curr_frame_length_lines /
-			s_ctrl->curr_line_length_pclk;
-		if (fps == 0)
-			delay = s_ctrl->min_delay;
-		else
-			delay = (1000 * s_ctrl->wait_num_frames) / fps / Q10;
-	}
-	CDBG("%s fps = %ld, delay = %d, min_delay %d\n", __func__, fps,
-		delay, s_ctrl->min_delay);
-	if (delay > s_ctrl->min_delay)
-		msleep(delay);
-	else if (s_ctrl->min_delay)
-		msleep(s_ctrl->min_delay);
-	return;
-}
-
-int32_t msm_sensor_write_init_settings(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	int32_t rc;
-	rc = msm_sensor_write_all_conf_array(
-		s_ctrl->sensor_i2c_client,
-		s_ctrl->msm_sensor_reg->init_settings,
-		s_ctrl->msm_sensor_reg->init_size);
-	return rc;
-}
-
-int32_t msm_sensor_write_res_settings(struct msm_sensor_ctrl_t *s_ctrl,
-	uint16_t res)
-{
-	int32_t rc;
-	rc = msm_sensor_write_conf_array(
-		s_ctrl->sensor_i2c_client,
-		s_ctrl->msm_sensor_reg->mode_settings, res);
-	if (rc < 0)
-		return rc;
-
-	rc = msm_sensor_write_output_settings(s_ctrl, res);
-	if (rc < 0)
-		return rc;
-
-	return rc;
-}
-
-int32_t msm_sensor_write_output_settings(struct msm_sensor_ctrl_t *s_ctrl,
-	uint16_t res)
-{
-	int32_t rc = -EFAULT;
-	struct msm_camera_i2c_reg_conf dim_settings[] = {
-		{s_ctrl->sensor_output_reg_addr->x_output,
-			s_ctrl->msm_sensor_reg->
-			output_settings[res].x_output},
-		{s_ctrl->sensor_output_reg_addr->y_output,
-			s_ctrl->msm_sensor_reg->
-			output_settings[res].y_output},
-		{s_ctrl->sensor_output_reg_addr->line_length_pclk,
-			s_ctrl->msm_sensor_reg->
-			output_settings[res].line_length_pclk},
-		{s_ctrl->sensor_output_reg_addr->frame_length_lines,
-			s_ctrl->msm_sensor_reg->
-			output_settings[res].frame_length_lines},
-	};
-
-	rc = msm_camera_i2c_write_tbl(s_ctrl->sensor_i2c_client, dim_settings,
-		ARRAY_SIZE(dim_settings), MSM_CAMERA_I2C_WORD_DATA);
-	return rc;
-}
-
-void msm_sensor_start_stream(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	if (s_ctrl->curr_res >= s_ctrl->msm_sensor_reg->num_conf)
-		return;
-
-	if (s_ctrl->func_tbl->sensor_adjust_frame_lines)
-		s_ctrl->func_tbl->sensor_adjust_frame_lines(s_ctrl);
-
-	msm_camera_i2c_write_tbl(
-		s_ctrl->sensor_i2c_client,
-		s_ctrl->msm_sensor_reg->start_stream_conf,
-		s_ctrl->msm_sensor_reg->start_stream_conf_size,
-		s_ctrl->msm_sensor_reg->default_data_type);
-	msleep(20);
-}
-
-void msm_sensor_stop_stream(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	msm_camera_i2c_write_tbl(
-		s_ctrl->sensor_i2c_client,
-		s_ctrl->msm_sensor_reg->stop_stream_conf,
-		s_ctrl->msm_sensor_reg->stop_stream_conf_size,
-		s_ctrl->msm_sensor_reg->default_data_type);
-	msm_sensor_delay_frames(s_ctrl);
-}
-
-void msm_sensor_group_hold_on(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	msm_camera_i2c_write_tbl(
-		s_ctrl->sensor_i2c_client,
-		s_ctrl->msm_sensor_reg->group_hold_on_conf,
-		s_ctrl->msm_sensor_reg->group_hold_on_conf_size,
-		s_ctrl->msm_sensor_reg->default_data_type);
-}
-
-void msm_sensor_group_hold_off(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	msm_camera_i2c_write_tbl(
-		s_ctrl->sensor_i2c_client,
-		s_ctrl->msm_sensor_reg->group_hold_off_conf,
-		s_ctrl->msm_sensor_reg->group_hold_off_conf_size,
-		s_ctrl->msm_sensor_reg->default_data_type);
-}
-
-int32_t msm_sensor_set_fps(struct msm_sensor_ctrl_t *s_ctrl,
-						struct fps_cfg *fps)
-{
-	s_ctrl->fps_divider = fps->fps_div;
-
-	return 0;
-}
-
-int32_t msm_sensor_write_exp_gain1(struct msm_sensor_ctrl_t *s_ctrl,
-		uint16_t gain, uint32_t line)
-{
-	uint32_t fl_lines;
-	uint8_t offset;
-	fl_lines = s_ctrl->curr_frame_length_lines;
-	fl_lines = (fl_lines * s_ctrl->fps_divider) / Q10;
-	offset = s_ctrl->sensor_exp_gain_info->vert_offset;
-	if (line > (fl_lines - offset))
-		fl_lines = line + offset;
-
-	s_ctrl->func_tbl->sensor_group_hold_on(s_ctrl);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_output_reg_addr->frame_length_lines, fl_lines,
-		MSM_CAMERA_I2C_WORD_DATA);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->coarse_int_time_addr, line,
-		MSM_CAMERA_I2C_WORD_DATA);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->global_gain_addr, gain,
-		MSM_CAMERA_I2C_WORD_DATA);
-	s_ctrl->func_tbl->sensor_group_hold_off(s_ctrl);
-	return 0;
-}
-
-int32_t msm_sensor_write_exp_gain2(struct msm_sensor_ctrl_t *s_ctrl,
-		uint16_t gain, uint32_t line)
-{
-	uint32_t fl_lines, ll_pclk, ll_ratio;
-	uint8_t offset;
-	fl_lines = s_ctrl->curr_frame_length_lines * s_ctrl->fps_divider / Q10;
-	ll_pclk = s_ctrl->curr_line_length_pclk;
-	offset = s_ctrl->sensor_exp_gain_info->vert_offset;
-	if (line > (fl_lines - offset)) {
-		ll_ratio = (line * Q10) / (fl_lines - offset);
-		ll_pclk = ll_pclk * ll_ratio / Q10;
-		line = fl_lines - offset;
-	}
-
-	s_ctrl->func_tbl->sensor_group_hold_on(s_ctrl);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_output_reg_addr->line_length_pclk, ll_pclk,
-		MSM_CAMERA_I2C_WORD_DATA);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->coarse_int_time_addr, line,
-		MSM_CAMERA_I2C_WORD_DATA);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->global_gain_addr, gain,
-		MSM_CAMERA_I2C_WORD_DATA);
-	s_ctrl->func_tbl->sensor_group_hold_off(s_ctrl);
-	return 0;
-}
-
-int32_t msm_sensor_setting1(struct msm_sensor_ctrl_t *s_ctrl,
-			int update_type, int res)
-{
-	int32_t rc = 0;
-
-	if (update_type == MSM_SENSOR_REG_INIT) {
-		CDBG("Register INIT\n");
-		msm_sensor_enable_debugfs(s_ctrl);
-		s_ctrl->func_tbl->sensor_stop_stream(s_ctrl);
-		msm_sensor_write_init_settings(s_ctrl);
-	} else if (update_type == MSM_SENSOR_UPDATE_PERIODIC) {
-		CDBG("PERIODIC : %d\n", res);
-		msm_sensor_write_conf_array(
-			s_ctrl->sensor_i2c_client,
-			s_ctrl->msm_sensor_reg->mode_settings, res);
-		msleep(30);
-		v4l2_subdev_notify(&s_ctrl->sensor_v4l2_subdev,
-			NOTIFY_PCLK_CHANGE,
-			&s_ctrl->sensordata->pdata->ioclk.vfe_clk_rate);
-	}
-	return rc;
-}
-
-int32_t msm_sensor_setting(struct msm_sensor_ctrl_t *s_ctrl,
-			int update_type, int res)
-{
-	int32_t rc = 0;
-
-	if (update_type == MSM_SENSOR_REG_INIT) {
-		s_ctrl->func_tbl->sensor_stop_stream(s_ctrl);
-		msm_sensor_write_init_settings(s_ctrl);
-	} else if (update_type == MSM_SENSOR_UPDATE_PERIODIC) {
-		msm_sensor_write_res_settings(s_ctrl, res);
-		v4l2_subdev_notify(&s_ctrl->sensor_v4l2_subdev,
-			NOTIFY_PCLK_CHANGE, &s_ctrl->msm_sensor_reg->
-			output_settings[res].op_pixel_clk);
-	}
-	return rc;
-}
-
-int32_t msm_sensor_set_sensor_mode(struct msm_sensor_ctrl_t *s_ctrl,
-	int mode, int res)
-{
-	int32_t rc = 0;
-	if (s_ctrl->curr_res != res) {
-		s_ctrl->curr_frame_length_lines =
-			s_ctrl->msm_sensor_reg->
-			output_settings[res].frame_length_lines;
-
-		s_ctrl->curr_line_length_pclk =
-			s_ctrl->msm_sensor_reg->
-			output_settings[res].line_length_pclk;
-
-		if (s_ctrl->is_csic ||
-			!s_ctrl->sensordata->csi_if)
-			rc = s_ctrl->func_tbl->sensor_csi_setting(s_ctrl,
-				MSM_SENSOR_UPDATE_PERIODIC, res);
-		else
-			rc = s_ctrl->func_tbl->sensor_setting(s_ctrl,
-				MSM_SENSOR_UPDATE_PERIODIC, res);
-		if (rc < 0)
-			return rc;
-		s_ctrl->curr_res = res;
-	}
-
-	return rc;
-}
-
-int32_t msm_sensor_mode_init(struct msm_sensor_ctrl_t *s_ctrl,
-			int mode, struct sensor_init_cfg *init_info)
-{
-	int32_t rc = 0;
-	s_ctrl->fps_divider = Q10;
-	s_ctrl->cam_mode = MSM_SENSOR_MODE_INVALID;
-
-	CDBG("%s: %d\n", __func__, __LINE__);
-	if (mode != s_ctrl->cam_mode) {
-		s_ctrl->curr_res = MSM_SENSOR_INVALID_RES;
-		s_ctrl->cam_mode = mode;
-
-		if (s_ctrl->is_csic ||
-			!s_ctrl->sensordata->csi_if)
-			rc = s_ctrl->func_tbl->sensor_csi_setting(s_ctrl,
-				MSM_SENSOR_REG_INIT, 0);
-		else
-			rc = s_ctrl->func_tbl->sensor_setting(s_ctrl,
-				MSM_SENSOR_REG_INIT, 0);
-	}
-	return rc;
-}
-
-int32_t msm_sensor_get_output_info(struct msm_sensor_ctrl_t *s_ctrl,
-		struct sensor_output_info_t *sensor_output_info)
-{
-	int rc = 0;
-	sensor_output_info->num_info = s_ctrl->msm_sensor_reg->num_conf;
-	if (copy_to_user((void *)sensor_output_info->output_info,
-		s_ctrl->msm_sensor_reg->output_settings,
-		sizeof(struct msm_sensor_output_info_t) *
-		s_ctrl->msm_sensor_reg->num_conf))
-		rc = -EFAULT;
-
-	return rc;
-}
-
-static int32_t msm_sensor_release(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	CDBG("%s called\n", __func__);
-	s_ctrl->func_tbl->sensor_stop_stream(s_ctrl);
-	return 0;
-}
-
-long msm_sensor_subdev_ioctl(struct v4l2_subdev *sd,
-			unsigned int cmd, void *arg)
-{
-	struct msm_sensor_ctrl_t *s_ctrl = get_sctrl(sd);
-	void __user *argp = (void __user *)arg;
-	if (s_ctrl->sensor_state == MSM_SENSOR_POWER_DOWN)
-		return -EINVAL;
-	switch (cmd) {
-	case VIDIOC_MSM_SENSOR_CFG:
-		return s_ctrl->func_tbl->sensor_config(s_ctrl, argp);
-	case VIDIOC_MSM_SENSOR_RELEASE:
-		return msm_sensor_release(s_ctrl);
-	case VIDIOC_MSM_SENSOR_CSID_INFO: {
-		struct msm_sensor_csi_info *csi_info =
-			(struct msm_sensor_csi_info *)arg;
-		s_ctrl->is_csic = csi_info->is_csic;
-		return 0;
-	}
-	default:
-		return -ENOIOCTLCMD;
-	}
-}
-
-int32_t msm_sensor_get_csi_params(struct msm_sensor_ctrl_t *s_ctrl,
-		struct csi_lane_params_t *sensor_output_info)
-{
-	uint8_t index;
-	struct msm_camera_csi_lane_params *csi_lane_params =
-		s_ctrl->sensordata->sensor_platform_info->csi_lane_params;
-	if (csi_lane_params) {
-		sensor_output_info->csi_lane_assign = csi_lane_params->
-			csi_lane_assign;
-		sensor_output_info->csi_lane_mask = csi_lane_params->
-			csi_lane_mask;
-		sensor_output_info->csi_phy_sel =
-			s_ctrl->sensordata->pdata->csiphy_core;
-	}
-	sensor_output_info->csi_if = s_ctrl->sensordata->csi_if;
-	for (index = 0; index < sensor_output_info->csi_if; index++)
-		sensor_output_info->csid_core[index] = s_ctrl->sensordata->
-			pdata[index].csid_core;
-
-	return 0;
-}
-
-int32_t msm_sensor_config(struct msm_sensor_ctrl_t *s_ctrl, 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(s_ctrl->msm_sensor_mutex);
-	CDBG("%s:%d %s cfgtype = %d\n", __func__, __LINE__,
-		s_ctrl->sensordata->sensor_name, cdata.cfgtype);
-	switch (cdata.cfgtype) {
-		case CFG_SET_FPS:
-		case CFG_SET_PICT_FPS:
-			if (s_ctrl->func_tbl->
-			sensor_set_fps == NULL) {
-				rc = -EFAULT;
-				break;
-			}
-			rc = s_ctrl->func_tbl->
-				sensor_set_fps(
-				s_ctrl,
-				&(cdata.cfg.fps));
-			break;
-
-		case CFG_SET_EXP_GAIN:
-			if (s_ctrl->func_tbl->
-			sensor_write_exp_gain == NULL) {
-				rc = -EFAULT;
-				break;
-			}
-			rc =
-				s_ctrl->func_tbl->
-				sensor_write_exp_gain(
-					s_ctrl,
-					cdata.cfg.exp_gain.gain,
-					cdata.cfg.exp_gain.line);
-			break;
-
-		case CFG_SET_PICT_EXP_GAIN:
-			if (s_ctrl->func_tbl->
-			sensor_write_snapshot_exp_gain == NULL) {
-				rc = -EFAULT;
-				break;
-			}
-			rc =
-				s_ctrl->func_tbl->
-				sensor_write_snapshot_exp_gain(
-					s_ctrl,
-					cdata.cfg.exp_gain.gain,
-					cdata.cfg.exp_gain.line);
-			break;
-
-		case CFG_SET_MODE:
-			if (s_ctrl->func_tbl->
-			sensor_set_sensor_mode == NULL) {
-				rc = -EFAULT;
-				break;
-			}
-			rc = s_ctrl->func_tbl->
-				sensor_set_sensor_mode(
-					s_ctrl,
-					cdata.mode,
-					cdata.rs);
-			break;
-
-		case CFG_SET_EFFECT:
-			break;
-
-		case CFG_SENSOR_INIT:
-			if (s_ctrl->func_tbl->
-			sensor_mode_init == NULL) {
-				rc = -EFAULT;
-				break;
-			}
-			rc = s_ctrl->func_tbl->
-				sensor_mode_init(
-				s_ctrl,
-				cdata.mode,
-				&(cdata.cfg.init_info));
-			break;
-
-		case CFG_GET_OUTPUT_INFO:
-			if (s_ctrl->func_tbl->
-			sensor_get_output_info == NULL) {
-				rc = -EFAULT;
-				break;
-			}
-			rc = s_ctrl->func_tbl->
-				sensor_get_output_info(
-				s_ctrl,
-				&cdata.cfg.output_info);
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_START_STREAM:
-			if (s_ctrl->func_tbl->sensor_start_stream == NULL) {
-				rc = -EFAULT;
-				break;
-			}
-			s_ctrl->func_tbl->sensor_start_stream(s_ctrl);
-			break;
-
-		case CFG_STOP_STREAM:
-			if (s_ctrl->func_tbl->sensor_stop_stream == NULL) {
-				rc = -EFAULT;
-				break;
-			}
-			s_ctrl->func_tbl->sensor_stop_stream(s_ctrl);
-			break;
-
-		case CFG_GET_CSI_PARAMS:
-			if (s_ctrl->func_tbl->sensor_get_csi_params == NULL) {
-				rc = -EFAULT;
-				break;
-			}
-			rc = s_ctrl->func_tbl->sensor_get_csi_params(
-				s_ctrl,
-				&cdata.cfg.csi_lane_params);
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_POWER_UP:
-			pr_err("%s calling power up\n", __func__);
-			if (s_ctrl->func_tbl->sensor_power_up)
-				rc = s_ctrl->func_tbl->sensor_power_up(s_ctrl);
-			else
-				rc = -EFAULT;
-			break;
-
-		case CFG_POWER_DOWN:
-			if (s_ctrl->func_tbl->sensor_power_down)
-				rc = s_ctrl->func_tbl->sensor_power_down(
-					s_ctrl);
-			else
-				rc = -EFAULT;
-			break;
-
-		default:
-			rc = -EFAULT;
-			break;
-		}
-
-	mutex_unlock(s_ctrl->msm_sensor_mutex);
-
-	return rc;
-}
-
-static struct msm_cam_clk_info cam_8960_clk_info[] = {
-	{"cam_clk", MSM_SENSOR_MCLK_24HZ},
-};
-
-static struct msm_cam_clk_info cam_8974_clk_info[] = {
-	{"cam_src_clk", 19200000},
-	{"cam_clk", -1},
-};
-
-int32_t msm_sensor_enable_i2c_mux(struct msm_camera_i2c_conf *i2c_conf)
-{
-	struct v4l2_subdev *i2c_mux_sd =
-		dev_get_drvdata(&i2c_conf->mux_dev->dev);
-	v4l2_subdev_call(i2c_mux_sd, core, ioctl,
-		VIDIOC_MSM_I2C_MUX_INIT, NULL);
-	v4l2_subdev_call(i2c_mux_sd, core, ioctl,
-		VIDIOC_MSM_I2C_MUX_CFG, (void *)&i2c_conf->i2c_mux_mode);
-	return 0;
-}
-
-int32_t msm_sensor_disable_i2c_mux(struct msm_camera_i2c_conf *i2c_conf)
-{
-	struct v4l2_subdev *i2c_mux_sd =
-		dev_get_drvdata(&i2c_conf->mux_dev->dev);
-	v4l2_subdev_call(i2c_mux_sd, core, ioctl,
-				VIDIOC_MSM_I2C_MUX_RELEASE, NULL);
-	return 0;
-}
-
-static int32_t msm_sensor_init_flash_data(struct device_node *of_node,
-	struct  msm_camera_sensor_info *sensordata)
-{
-	int32_t rc = 0;
-	uint32_t val = 0;
-	struct msm_camera_sensor_flash_data *flash_data = NULL;
-	struct device_node *flash_src_node = NULL;
-
-	sensordata->flash_data = kzalloc(sizeof(
-		struct msm_camera_sensor_flash_data), GFP_KERNEL);
-	if (!sensordata->flash_data) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		return -ENOMEM;
-	}
-
-	if (!of_get_property(of_node, "qcom,flash-src-index", &val)) {
-		CDBG("%s flash not available\n", __func__);
-		return rc;
-	}
-	flash_data = sensordata->flash_data;
-
-	flash_src_node = of_parse_phandle(of_node, "qcom,flash-src-index", 0);
-	if (!flash_src_node) {
-		pr_err("%s:%d flash_src_node NULL\n", __func__,
-			__LINE__);
-		goto ERROR1;
-	}
-
-	rc = of_property_read_u32(flash_src_node, "qcom,flash-type", &val);
-	CDBG("%s qcom,flash-type %d, rc %d\n", __func__, val, rc);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR2;
-	}
-	flash_data->flash_type = val;
-
-	rc = of_property_read_u32(flash_src_node, "cell-index", &val);
-	CDBG("%s qcom,flash-src-index %d, rc %d\n", __func__, val, rc);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR2;
-	}
-	flash_data->flash_src_index = val;
-
-	of_node_put(flash_src_node);
-
-	return rc;
-ERROR2:
-	of_node_put(flash_src_node);
-ERROR1:
-	flash_data->flash_type = MSM_CAMERA_FLASH_NONE;
-	return rc;
-}
-
-static int32_t msm_sensor_init_vreg_data(struct device_node *of_node,
-	struct msm_camera_sensor_platform_info *pinfo)
-{
-	int32_t rc = 0, i = 0;
-	uint32_t count = 0;
-	uint32_t *val_array = NULL;
-
-	count = of_property_count_strings(of_node, "qcom,cam-vreg-name");
-	CDBG("%s qcom,cam-vreg-name count %d\n", __func__, count);
-
-	if (!count)
-		return 0;
-
-	pinfo->cam_vreg = kzalloc(sizeof(struct camera_vreg_t) * count,
-		GFP_KERNEL);
-	if (!pinfo->cam_vreg) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		return -ENOMEM;
-	}
-
-	pinfo->num_vreg = count;
-	for (i = 0; i < count; i++) {
-		rc = of_property_read_string_index(of_node,
-			"qcom,cam-vreg-name", i, &pinfo->cam_vreg[i].reg_name);
-		CDBG("%s reg_name[%d] = %s\n", __func__, i,
-			pinfo->cam_vreg[i].reg_name);
-		if (rc < 0) {
-			pr_err("%s failed %d\n", __func__, __LINE__);
-			goto ERROR1;
-		}
-	}
-
-	val_array = kzalloc(sizeof(uint32_t) * count, GFP_KERNEL);
-	if (!val_array) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		rc = -ENOMEM;
-		goto ERROR1;
-	}
-
-	rc = of_property_read_u32_array(of_node, "qcom,cam-vreg-type",
-		val_array, count);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR2;
-	}
-	for (i = 0; i < count; i++) {
-		pinfo->cam_vreg[i].type = val_array[i];
-		CDBG("%s cam_vreg[%d].type = %d\n", __func__, i,
-			pinfo->cam_vreg[i].type);
-	}
-
-	rc = of_property_read_u32_array(of_node, "qcom,cam-vreg-min-voltage",
-		val_array, count);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR2;
-	}
-	for (i = 0; i < count; i++) {
-		pinfo->cam_vreg[i].min_voltage = val_array[i];
-		CDBG("%s cam_vreg[%d].min_voltage = %d\n", __func__,
-			i, pinfo->cam_vreg[i].min_voltage);
-	}
-
-	rc = of_property_read_u32_array(of_node, "qcom,cam-vreg-max-voltage",
-		val_array, count);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR2;
-	}
-	for (i = 0; i < count; i++) {
-		pinfo->cam_vreg[i].max_voltage = val_array[i];
-		CDBG("%s cam_vreg[%d].max_voltage = %d\n", __func__,
-			i, pinfo->cam_vreg[i].max_voltage);
-	}
-
-	rc = of_property_read_u32_array(of_node, "qcom,cam-vreg-op-mode",
-		val_array, count);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR2;
-	}
-	for (i = 0; i < count; i++) {
-		pinfo->cam_vreg[i].op_mode = val_array[i];
-		CDBG("%s cam_vreg[%d].op_mode = %d\n", __func__, i,
-			pinfo->cam_vreg[i].op_mode);
-	}
-
-	kfree(val_array);
-	return rc;
-ERROR2:
-	kfree(val_array);
-ERROR1:
-	kfree(pinfo->cam_vreg);
-	pinfo->num_vreg = 0;
-	return rc;
-}
-
-static int32_t msm_sensor_init_gpio_common_tbl_data(struct device_node *of_node,
-	struct msm_camera_gpio_conf *gconf, uint16_t *gpio_array,
-	uint16_t gpio_array_size)
-{
-	int32_t rc = 0, i = 0;
-	uint32_t count = 0;
-	uint32_t *val_array = NULL;
-
-	if (!of_get_property(of_node, "qcom,gpio-common-tbl-num", &count))
-		return 0;
-
-	count /= sizeof(uint32_t);
-	if (!count) {
-		pr_err("%s qcom,gpio-common-tbl-num 0\n", __func__);
-		return 0;
-	} else if (count > gpio_array_size) {
-		pr_err("%s gpio common tbl size exceeds gpio array\n",
-			__func__);
-		return -EFAULT;
-	}
-
-	val_array = kzalloc(sizeof(uint32_t) * count, GFP_KERNEL);
-	if (!val_array) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		return -ENOMEM;
-	}
-
-	gconf->cam_gpio_common_tbl = kzalloc(sizeof(struct gpio) * count,
-		GFP_KERNEL);
-	if (!gconf->cam_gpio_common_tbl) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		rc = -ENOMEM;
-		goto ERROR1;
-	}
-	gconf->cam_gpio_common_tbl_size = count;
-
-	rc = of_property_read_u32_array(of_node, "qcom,gpio-common-tbl-num",
-		val_array, count);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR2;
-	}
-	for (i = 0; i < count; i++) {
-		if (val_array[i] >= gpio_array_size) {
-			pr_err("%s gpio common tbl index %d invalid\n",
-				__func__, val_array[i]);
-			return -EINVAL;
-		}
-		gconf->cam_gpio_common_tbl[i].gpio = gpio_array[val_array[i]];
-		CDBG("%s cam_gpio_common_tbl[%d].gpio = %d\n", __func__, i,
-			gconf->cam_gpio_common_tbl[i].gpio);
-	}
-
-	rc = of_property_read_u32_array(of_node, "qcom,gpio-common-tbl-flags",
-		val_array, count);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR2;
-	}
-	for (i = 0; i < count; i++) {
-		gconf->cam_gpio_common_tbl[i].flags = val_array[i];
-		CDBG("%s cam_gpio_common_tbl[%d].flags = %ld\n", __func__, i,
-			gconf->cam_gpio_common_tbl[i].flags);
-	}
-
-	for (i = 0; i < count; i++) {
-		rc = of_property_read_string_index(of_node,
-			"qcom,gpio-common-tbl-label", i,
-			&gconf->cam_gpio_common_tbl[i].label);
-		CDBG("%s cam_gpio_common_tbl[%d].label = %s\n", __func__, i,
-			gconf->cam_gpio_common_tbl[i].label);
-		if (rc < 0) {
-			pr_err("%s failed %d\n", __func__, __LINE__);
-			goto ERROR2;
-		}
-	}
-
-	kfree(val_array);
-	return rc;
-
-ERROR2:
-	kfree(gconf->cam_gpio_common_tbl);
-ERROR1:
-	kfree(val_array);
-	gconf->cam_gpio_common_tbl_size = 0;
-	return rc;
-}
-
-static int32_t msm_sensor_init_gpio_req_tbl_data(struct device_node *of_node,
-	struct msm_camera_gpio_conf *gconf, uint16_t *gpio_array,
-	uint16_t gpio_array_size)
-{
-	int32_t rc = 0, i = 0;
-	uint32_t count = 0;
-	uint32_t *val_array = NULL;
-
-	if (!of_get_property(of_node, "qcom,gpio-req-tbl-num", &count))
-		return 0;
-
-	count /= sizeof(uint32_t);
-	if (!count) {
-		pr_err("%s qcom,gpio-req-tbl-num 0\n", __func__);
-		return 0;
-	}
-
-	val_array = kzalloc(sizeof(uint32_t) * count, GFP_KERNEL);
-	if (!val_array) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		return -ENOMEM;
-	}
-
-	gconf->cam_gpio_req_tbl = kzalloc(sizeof(struct gpio) * count,
-		GFP_KERNEL);
-	if (!gconf->cam_gpio_req_tbl) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		rc = -ENOMEM;
-		goto ERROR1;
-	}
-	gconf->cam_gpio_req_tbl_size = count;
-
-	rc = of_property_read_u32_array(of_node, "qcom,gpio-req-tbl-num",
-		val_array, count);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR2;
-	}
-	for (i = 0; i < count; i++) {
-		if (val_array[i] >= gpio_array_size) {
-			pr_err("%s gpio req tbl index %d invalid\n",
-				__func__, val_array[i]);
-			return -EINVAL;
-		}
-		gconf->cam_gpio_req_tbl[i].gpio = gpio_array[val_array[i]];
-		CDBG("%s cam_gpio_req_tbl[%d].gpio = %d\n", __func__, i,
-			gconf->cam_gpio_req_tbl[i].gpio);
-	}
-
-	rc = of_property_read_u32_array(of_node, "qcom,gpio-req-tbl-flags",
-		val_array, count);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR2;
-	}
-	for (i = 0; i < count; i++) {
-		gconf->cam_gpio_req_tbl[i].flags = val_array[i];
-		CDBG("%s cam_gpio_req_tbl[%d].flags = %ld\n", __func__, i,
-			gconf->cam_gpio_req_tbl[i].flags);
-	}
-
-	for (i = 0; i < count; i++) {
-		rc = of_property_read_string_index(of_node,
-			"qcom,gpio-req-tbl-label", i,
-			&gconf->cam_gpio_req_tbl[i].label);
-		CDBG("%s cam_gpio_req_tbl[%d].label = %s\n", __func__, i,
-			gconf->cam_gpio_req_tbl[i].label);
-		if (rc < 0) {
-			pr_err("%s failed %d\n", __func__, __LINE__);
-			goto ERROR2;
-		}
-	}
-
-	kfree(val_array);
-	return rc;
-
-ERROR2:
-	kfree(gconf->cam_gpio_req_tbl);
-ERROR1:
-	kfree(val_array);
-	gconf->cam_gpio_req_tbl_size = 0;
-	return rc;
-}
-
-static int32_t msm_sensor_init_gpio_set_tbl_data(struct device_node *of_node,
-	struct msm_camera_gpio_conf *gconf, uint16_t *gpio_array,
-	uint16_t gpio_array_size)
-{
-	int32_t rc = 0, i = 0;
-	uint32_t count = 0;
-	uint32_t *val_array = NULL;
-
-	if (!of_get_property(of_node, "qcom,gpio-set-tbl-num", &count))
-		return 0;
-
-	count /= sizeof(uint32_t);
-	if (!count) {
-		pr_err("%s qcom,gpio-set-tbl-num 0\n", __func__);
-		return 0;
-	}
-
-	val_array = kzalloc(sizeof(uint32_t) * count, GFP_KERNEL);
-	if (!val_array) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		return -ENOMEM;
-	}
-
-	gconf->cam_gpio_set_tbl = kzalloc(sizeof(struct msm_gpio_set_tbl) *
-		count, GFP_KERNEL);
-	if (!gconf->cam_gpio_set_tbl) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		rc = -ENOMEM;
-		goto ERROR1;
-	}
-	gconf->cam_gpio_set_tbl_size = count;
-
-	rc = of_property_read_u32_array(of_node, "qcom,gpio-set-tbl-num",
-		val_array, count);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR2;
-	}
-	for (i = 0; i < count; i++) {
-		if (val_array[i] >= gpio_array_size) {
-			pr_err("%s gpio set tbl index %d invalid\n",
-				__func__, val_array[i]);
-			return -EINVAL;
-		}
-		gconf->cam_gpio_set_tbl[i].gpio = gpio_array[val_array[i]];
-		CDBG("%s cam_gpio_set_tbl[%d].gpio = %d\n", __func__, i,
-			gconf->cam_gpio_set_tbl[i].gpio);
-	}
-
-	rc = of_property_read_u32_array(of_node, "qcom,gpio-set-tbl-flags",
-		val_array, count);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR2;
-	}
-	for (i = 0; i < count; i++) {
-		gconf->cam_gpio_set_tbl[i].flags = val_array[i];
-		CDBG("%s cam_gpio_set_tbl[%d].flags = %ld\n", __func__, i,
-			gconf->cam_gpio_set_tbl[i].flags);
-	}
-
-	rc = of_property_read_u32_array(of_node, "qcom,gpio-set-tbl-delay",
-		val_array, count);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR2;
-	}
-	for (i = 0; i < count; i++) {
-		gconf->cam_gpio_set_tbl[i].delay = val_array[i];
-		CDBG("%s cam_gpio_set_tbl[%d].delay = %d\n", __func__, i,
-			gconf->cam_gpio_set_tbl[i].delay);
-	}
-
-	kfree(val_array);
-	return rc;
-
-ERROR2:
-	kfree(gconf->cam_gpio_set_tbl);
-ERROR1:
-	kfree(val_array);
-	gconf->cam_gpio_set_tbl_size = 0;
-	return rc;
-}
-
-static int32_t msm_sensor_init_gpio_tlmm_tbl_data(struct device_node *of_node,
-	struct msm_camera_gpio_conf *gconf, uint16_t *gpio_array,
-	uint16_t gpio_array_size)
-{
-	int32_t rc = 0, i = 0;
-	uint32_t count = 0;
-	uint32_t *val_array = NULL;
-	struct gpio_tlmm_cfg *tlmm_cfg = NULL;
-
-	if (!of_get_property(of_node, "gpio_tlmm_table_num", &count))
-		return 0;
-
-	count /= sizeof(uint32_t);
-
-	if (!count)
-		return 0;
-
-	val_array = kzalloc(sizeof(uint32_t) * count, GFP_KERNEL);
-	if (!val_array) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		return -ENOMEM;
-	}
-
-	tlmm_cfg = kzalloc(sizeof(struct gpio_tlmm_cfg) * count, GFP_KERNEL);
-	if (!tlmm_cfg) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		rc = -ENOMEM;
-		goto ERROR1;
-	}
-
-	gconf->camera_off_table = kzalloc(sizeof(uint32_t) * count, GFP_KERNEL);
-	if (!gconf->camera_off_table) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		rc = -ENOMEM;
-		goto ERROR2;
-	}
-	gconf->camera_off_table_size = count;
-
-	gconf->camera_on_table = kzalloc(sizeof(uint32_t) * count, GFP_KERNEL);
-	if (!gconf->camera_on_table) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		rc = -ENOMEM;
-		goto ERROR3;
-	}
-	gconf->camera_on_table_size = count;
-
-	rc = of_property_read_u32_array(of_node, "gpio_tlmm_table_num",
-		val_array, count);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR4;
-	}
-	for (i = 0; i < count; i++) {
-		if (val_array[i] >= gpio_array_size) {
-			pr_err("%s gpio set tbl index %d invalid\n",
-				__func__, val_array[i]);
-			return -EINVAL;
-		}
-		tlmm_cfg[i].gpio = gpio_array[val_array[i]];
-		CDBG("%s tlmm_cfg[%d].gpio = %d\n", __func__, i,
-			tlmm_cfg[i].gpio);
-	}
-
-	rc = of_property_read_u32_array(of_node, "gpio_tlmm_table_dir",
-		val_array, count);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR4;
-	}
-	for (i = 0; i < count; i++) {
-		tlmm_cfg[i].dir = val_array[i];
-		CDBG("%s tlmm_cfg[%d].dir = %d\n", __func__, i,
-			tlmm_cfg[i].dir);
-	}
-
-	rc = of_property_read_u32_array(of_node, "gpio_tlmm_table_pull",
-		val_array, count);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR4;
-	}
-	for (i = 0; i < count; i++) {
-		tlmm_cfg[i].pull = val_array[i];
-		CDBG("%s tlmm_cfg[%d].pull = %d\n", __func__, i,
-			tlmm_cfg[i].pull);
-	}
-
-	rc = of_property_read_u32_array(of_node, "gpio_tlmm_table_drvstr",
-		val_array, count);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR4;
-	}
-	for (i = 0; i < count; i++) {
-		tlmm_cfg[i].drvstr = val_array[i];
-		CDBG("%s tlmm_cfg[%d].drvstr = %d\n", __func__, i,
-			tlmm_cfg[i].drvstr);
-	}
-
-	for (i = 0; i < count; i++) {
-		gconf->camera_off_table[i] = GPIO_CFG(tlmm_cfg[i].gpio,
-			0, tlmm_cfg[i].dir, tlmm_cfg[i].pull,
-			tlmm_cfg[i].drvstr);
-		gconf->camera_on_table[i] = GPIO_CFG(tlmm_cfg[i].gpio,
-			1, tlmm_cfg[i].dir, tlmm_cfg[i].pull,
-			tlmm_cfg[i].drvstr);
-	}
-
-	kfree(tlmm_cfg);
-	kfree(val_array);
-	return rc;
-
-ERROR4:
-	kfree(gconf->camera_on_table);
-ERROR3:
-	kfree(gconf->camera_off_table);
-ERROR2:
-	kfree(tlmm_cfg);
-ERROR1:
-	kfree(val_array);
-	gconf->camera_off_table_size = 0;
-	gconf->camera_on_table_size = 0;
-	return rc;
-}
-
-static int32_t msm_sensor_init_csi_data(struct device_node *of_node,
-	struct  msm_camera_sensor_info *sensordata)
-{
-	int32_t rc = 0, i = 0;
-	uint32_t count = 0, val = 0;
-	uint32_t *val_array = NULL;
-	struct msm_camera_sensor_platform_info *pinfo =
-		sensordata->sensor_platform_info;
-
-	rc = of_property_read_u32(of_node, "qcom,csi-if", &count);
-	CDBG("%s qcom,csi-if %d, rc %d\n", __func__, count, rc);
-	if (rc < 0 || !count)
-		return rc;
-	sensordata->csi_if = count;
-
-	sensordata->pdata = kzalloc(sizeof(
-		struct msm_camera_device_platform_data) * count, GFP_KERNEL);
-	if (!sensordata->pdata) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		return -ENOMEM;
-	}
-
-	val_array = kzalloc(sizeof(uint32_t) * count, GFP_KERNEL);
-	if (!val_array) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		rc = -ENOMEM;
-		goto ERROR1;
-	}
-
-	rc = of_property_read_u32_array(of_node, "qcom,csid-core", val_array,
-		count);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR2;
-	}
-	for (i = 0; i < count; i++) {
-		sensordata->pdata[i].csid_core = val_array[i];
-		CDBG("%s csi_data[%d].csid_core = %d\n", __func__, i,
-			sensordata->pdata[i].csid_core);
-	}
-
-	pinfo->csi_lane_params = kzalloc(
-		sizeof(struct msm_camera_csi_lane_params), GFP_KERNEL);
-	if (!pinfo->csi_lane_params) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		rc = -ENOMEM;
-		goto ERROR2;
-	}
-
-	rc = of_property_read_u32(of_node, "qcom,csi-lane-assign", &val);
-	CDBG("%s qcom,csi-lane-assign %x, rc %d\n", __func__, val, rc);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR3;
-	}
-	pinfo->csi_lane_params->csi_lane_assign = val;
-
-	rc = of_property_read_u32(of_node, "qcom,csi-lane-mask", &val);
-	CDBG("%s qcom,csi-lane-mask %x, rc %d\n", __func__, val, rc);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR3;
-	}
-	pinfo->csi_lane_params->csi_lane_mask = val;
-
-	rc = of_property_read_u32(of_node, "qcom,csi-phy-sel", &val);
-	CDBG("%s qcom,csi-phy-sel %x, rc %d\n", __func__, val, rc);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR3;
-	}
-	sensordata->pdata->csiphy_core = val;
-	kfree(val_array);
-	return rc;
-ERROR3:
-	kfree(pinfo->csi_lane_params);
-ERROR2:
-	kfree(val_array);
-ERROR1:
-	kfree(sensordata->pdata);
-	sensordata->csi_if = 0;
-	return rc;
-}
-static int32_t msm_sensor_init_actuator_data(struct device_node *of_node,
-	struct  msm_camera_sensor_info *sensordata)
-{
-	int32_t rc = 0;
-	uint32_t val = 0;
-
-	rc = of_property_read_u32(of_node, "qcom,actuator-cam-name", &val);
-	CDBG("%s qcom,actuator-cam-name %d, rc %d\n", __func__, val, rc);
-	if (rc < 0)
-		return 0;
-
-	sensordata->actuator_info = kzalloc(sizeof(struct msm_actuator_info),
-		GFP_KERNEL);
-	if (!sensordata->actuator_info) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		rc = -ENOMEM;
-		goto ERROR;
-	}
-
-	sensordata->actuator_info->cam_name = val;
-
-	rc = of_property_read_u32(of_node, "qcom,actuator-vcm-pwd", &val);
-	CDBG("%s qcom,actuator-vcm-pwd %d, rc %d\n", __func__, val, rc);
-	if (!rc)
-		sensordata->actuator_info->vcm_pwd = val;
-
-	rc = of_property_read_u32(of_node, "qcom,actuator-vcm-enable", &val);
-	CDBG("%s qcom,actuator-vcm-enable %d, rc %d\n", __func__, val, rc);
-	if (!rc)
-		sensordata->actuator_info->vcm_enable = val;
-
-	return 0;
-ERROR:
-	return rc;
-}
-
-static int32_t msm_sensor_init_sensor_data(struct platform_device *pdev,
-	struct msm_sensor_ctrl_t *s_ctrl)
-{
-	int32_t rc = 0, i = 0;
-	uint32_t val = 0;
-	struct device_node *of_node = pdev->dev.of_node;
-	struct msm_camera_sensor_platform_info *pinfo = NULL;
-	struct msm_camera_gpio_conf *gconf = NULL;
-	struct msm_camera_sensor_info *sensordata = NULL;
-	uint16_t *gpio_array = NULL;
-	uint16_t gpio_array_size = 0;
-
-	s_ctrl->sensordata = kzalloc(sizeof(struct msm_camera_sensor_info),
-		GFP_KERNEL);
-	if (!s_ctrl->sensordata) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		return -ENOMEM;
-	}
-
-	sensordata = s_ctrl->sensordata;
-
-	rc = of_property_read_string(of_node, "qcom,sensor-name",
-		&sensordata->sensor_name);
-	CDBG("%s qcom,sensor-name %s, rc %d\n", __func__,
-		sensordata->sensor_name, rc);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR1;
-	}
-
-	rc = of_property_read_u32(of_node, "qcom,camera-type", &val);
-	CDBG("%s qcom,camera-type %d, rc %d\n", __func__, val, rc);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR1;
-	}
-	sensordata->camera_type = val;
-
-	rc = of_property_read_u32(of_node, "qcom,sensor-type", &val);
-	CDBG("%s qcom,sensor-type %d, rc %d\n", __func__, val, rc);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR1;
-	}
-	sensordata->sensor_type = val;
-
-	rc = msm_sensor_init_flash_data(of_node, sensordata);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR1;
-	}
-
-	sensordata->sensor_platform_info = kzalloc(sizeof(
-		struct msm_camera_sensor_platform_info), GFP_KERNEL);
-	if (!sensordata->sensor_platform_info) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		rc = -ENOMEM;
-		goto ERROR1;
-	}
-
-	pinfo = sensordata->sensor_platform_info;
-
-	rc = of_property_read_u32(of_node, "qcom,mount-angle",
-		&pinfo->mount_angle);
-	CDBG("%s qcom,mount-angle %d, rc %d\n", __func__, pinfo->mount_angle,
-		rc);
-	if (rc < 0) {
-		/* Set default mount angle */
-		pinfo->mount_angle = 0;
-		rc = 0;
-	}
-
-	rc = msm_sensor_init_csi_data(of_node, sensordata);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR2;
-	}
-
-	rc = msm_sensor_init_vreg_data(of_node, pinfo);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR3;
-	}
-
-	pinfo->gpio_conf = kzalloc(sizeof(struct msm_camera_gpio_conf),
-		GFP_KERNEL);
-	if (!pinfo->gpio_conf) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		rc = -ENOMEM;
-		goto ERROR4;
-	}
-	gconf = pinfo->gpio_conf;
-	rc = of_property_read_u32(of_node, "qcom,gpio-no-mux",
-		&gconf->gpio_no_mux);
-	CDBG("%s gconf->gpio_no_mux %d, rc %d\n", __func__,
-		gconf->gpio_no_mux, rc);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR5;
-	}
-
-	gpio_array_size = of_gpio_count(of_node);
-	CDBG("%s gpio count %d\n", __func__, gpio_array_size);
-
-	if (gpio_array_size) {
-		gpio_array = kzalloc(sizeof(uint16_t) * gpio_array_size,
-			GFP_KERNEL);
-		if (!gpio_array) {
-			pr_err("%s failed %d\n", __func__, __LINE__);
-			goto ERROR5;
-		}
-		for (i = 0; i < gpio_array_size; i++) {
-			gpio_array[i] = of_get_gpio(of_node, i);
-			CDBG("%s gpio_array[%d] = %d\n", __func__, i,
-				gpio_array[i]);
-		}
-
-		rc = msm_sensor_init_gpio_common_tbl_data(of_node, gconf,
-			gpio_array, gpio_array_size);
-		if (rc < 0) {
-			pr_err("%s failed %d\n", __func__, __LINE__);
-			goto ERROR5;
-		}
-
-		rc = msm_sensor_init_gpio_req_tbl_data(of_node, gconf,
-			gpio_array, gpio_array_size);
-		if (rc < 0) {
-			pr_err("%s failed %d\n", __func__, __LINE__);
-			goto ERROR6;
-		}
-
-		rc = msm_sensor_init_gpio_set_tbl_data(of_node, gconf,
-			gpio_array, gpio_array_size);
-		if (rc < 0) {
-			pr_err("%s failed %d\n", __func__, __LINE__);
-			goto ERROR7;
-		}
-
-		rc = msm_sensor_init_gpio_tlmm_tbl_data(of_node, gconf,
-			gpio_array, gpio_array_size);
-		if (rc < 0) {
-			pr_err("%s failed %d\n", __func__, __LINE__);
-			goto ERROR8;
-		}
-	}
-	rc = msm_sensor_init_actuator_data(of_node, sensordata);
-	if (rc < 0) {
-		pr_err("%s failed %d\n", __func__, __LINE__);
-		goto ERROR9;
-	}
-
-	kfree(gpio_array);
-	return rc;
-
-ERROR9:
-	kfree(s_ctrl->sensordata->sensor_platform_info->gpio_conf->
-		camera_on_table);
-	kfree(s_ctrl->sensordata->sensor_platform_info->gpio_conf->
-		camera_off_table);
-ERROR8:
-	kfree(s_ctrl->sensordata->sensor_platform_info->gpio_conf->
-		cam_gpio_set_tbl);
-ERROR7:
-	kfree(s_ctrl->sensordata->sensor_platform_info->gpio_conf->
-		cam_gpio_req_tbl);
-ERROR6:
-	kfree(s_ctrl->sensordata->sensor_platform_info->gpio_conf->
-		cam_gpio_common_tbl);
-ERROR5:
-	kfree(s_ctrl->sensordata->sensor_platform_info->gpio_conf);
-ERROR4:
-	kfree(s_ctrl->sensordata->sensor_platform_info->cam_vreg);
-ERROR3:
-	kfree(s_ctrl->sensordata->sensor_platform_info->csi_lane_params);
-	kfree(s_ctrl->sensordata->pdata);
-ERROR2:
-	kfree(s_ctrl->sensordata->sensor_platform_info);
-	kfree(s_ctrl->sensordata->flash_data);
-ERROR1:
-	kfree(s_ctrl->sensordata);
-	kfree(gpio_array);
-	return rc;
-}
-
-int32_t msm_sensor_free_sensor_data(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	if (!s_ctrl->pdev)
-		return 0;
-	kfree(s_ctrl->sensordata->sensor_platform_info->gpio_conf->
-		camera_on_table);
-	kfree(s_ctrl->sensordata->sensor_platform_info->gpio_conf->
-		camera_off_table);
-	kfree(s_ctrl->sensordata->sensor_platform_info->gpio_conf->
-		cam_gpio_set_tbl);
-	kfree(s_ctrl->sensordata->sensor_platform_info->gpio_conf->
-		cam_gpio_req_tbl);
-	kfree(s_ctrl->sensordata->sensor_platform_info->gpio_conf->
-		cam_gpio_common_tbl);
-	kfree(s_ctrl->sensordata->sensor_platform_info->gpio_conf);
-	kfree(s_ctrl->sensordata->sensor_platform_info->cam_vreg);
-	kfree(s_ctrl->sensordata->sensor_platform_info->csi_lane_params);
-	kfree(s_ctrl->sensordata->pdata);
-	kfree(s_ctrl->sensordata->sensor_platform_info);
-	kfree(s_ctrl->sensordata->flash_data);
-	kfree(s_ctrl->sensordata);
-	return 0;
-}
-
-int32_t msm_sensor_power_up(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	int32_t rc = 0;
-	struct msm_camera_sensor_info *data = s_ctrl->sensordata;
-	struct device *dev = NULL;
-	if (s_ctrl->sensor_device_type == MSM_SENSOR_PLATFORM_DEVICE)
-		dev = &s_ctrl->pdev->dev;
-	else
-		dev = &s_ctrl->sensor_i2c_client->client->dev;
-	s_ctrl->reg_ptr = kzalloc(sizeof(struct regulator *)
-			* data->sensor_platform_info->num_vreg, GFP_KERNEL);
-	if (!s_ctrl->reg_ptr) {
-		pr_err("%s: could not allocate mem for regulators\n",
-			__func__);
-		return -ENOMEM;
-	}
-
-	rc = msm_camera_request_gpio_table(data, 1);
-	if (rc < 0) {
-		pr_err("%s: request gpio failed\n", __func__);
-		goto request_gpio_failed;
-	}
-
-	rc = msm_camera_config_vreg(dev,
-		s_ctrl->sensordata->sensor_platform_info->cam_vreg,
-		s_ctrl->sensordata->sensor_platform_info->num_vreg,
-		s_ctrl->vreg_seq,
-		s_ctrl->num_vreg_seq,
-		s_ctrl->reg_ptr, 1);
-	if (rc < 0) {
-		pr_err("%s: regulator on failed\n", __func__);
-		goto config_vreg_failed;
-	}
-
-	rc = msm_camera_enable_vreg(dev,
-		s_ctrl->sensordata->sensor_platform_info->cam_vreg,
-		s_ctrl->sensordata->sensor_platform_info->num_vreg,
-		s_ctrl->vreg_seq,
-		s_ctrl->num_vreg_seq,
-		s_ctrl->reg_ptr, 1);
-	if (rc < 0) {
-		pr_err("%s: enable regulator failed\n", __func__);
-		goto enable_vreg_failed;
-	}
-
-	rc = msm_camera_config_gpio_table(data, 1);
-	if (rc < 0) {
-		pr_err("%s: config gpio failed\n", __func__);
-		goto config_gpio_failed;
-	}
-
-	if (s_ctrl->sensor_device_type == MSM_SENSOR_I2C_DEVICE) {
-		if (s_ctrl->clk_rate != 0)
-			cam_8960_clk_info->clk_rate = s_ctrl->clk_rate;
-
-		rc = msm_cam_clk_enable(dev, cam_8960_clk_info,
-			s_ctrl->cam_clk, ARRAY_SIZE(cam_8960_clk_info), 1);
-		if (rc < 0) {
-			pr_err("%s: clk enable failed\n", __func__);
-			goto enable_clk_failed;
-		}
-	} else {
-		rc = msm_cam_clk_enable(dev, cam_8974_clk_info,
-			s_ctrl->cam_clk, ARRAY_SIZE(cam_8974_clk_info), 1);
-		if (rc < 0) {
-			pr_err("%s: clk enable failed\n", __func__);
-			goto enable_clk_failed;
-		}
-	}
-
-	if (!s_ctrl->power_seq_delay)
-		usleep_range(1000, 2000);
-	else if (s_ctrl->power_seq_delay < 20)
-		usleep_range((s_ctrl->power_seq_delay * 1000),
-			((s_ctrl->power_seq_delay * 1000) + 1000));
-	else
-		msleep(s_ctrl->power_seq_delay);
-
-	if (data->sensor_platform_info->ext_power_ctrl != NULL)
-		data->sensor_platform_info->ext_power_ctrl(1);
-
-	if (data->sensor_platform_info->i2c_conf &&
-		data->sensor_platform_info->i2c_conf->use_i2c_mux)
-		msm_sensor_enable_i2c_mux(data->sensor_platform_info->i2c_conf);
-
-	if (s_ctrl->sensor_device_type == MSM_SENSOR_PLATFORM_DEVICE) {
-		rc = msm_sensor_cci_util(s_ctrl->sensor_i2c_client,
-			MSM_CCI_INIT);
-		if (rc < 0) {
-			pr_err("%s cci_init failed\n", __func__);
-			goto cci_init_failed;
-		}
-	}
-	s_ctrl->curr_res = MSM_SENSOR_INVALID_RES;
-	return rc;
-
-cci_init_failed:
-	if (data->sensor_platform_info->i2c_conf &&
-		data->sensor_platform_info->i2c_conf->use_i2c_mux)
-		msm_sensor_disable_i2c_mux(
-			data->sensor_platform_info->i2c_conf);
-enable_clk_failed:
-		msm_camera_config_gpio_table(data, 0);
-config_gpio_failed:
-	msm_camera_enable_vreg(dev,
-			s_ctrl->sensordata->sensor_platform_info->cam_vreg,
-			s_ctrl->sensordata->sensor_platform_info->num_vreg,
-			s_ctrl->vreg_seq,
-			s_ctrl->num_vreg_seq,
-			s_ctrl->reg_ptr, 0);
-
-enable_vreg_failed:
-	msm_camera_config_vreg(dev,
-		s_ctrl->sensordata->sensor_platform_info->cam_vreg,
-		s_ctrl->sensordata->sensor_platform_info->num_vreg,
-		s_ctrl->vreg_seq,
-		s_ctrl->num_vreg_seq,
-		s_ctrl->reg_ptr, 0);
-config_vreg_failed:
-	msm_camera_request_gpio_table(data, 0);
-request_gpio_failed:
-	kfree(s_ctrl->reg_ptr);
-	return rc;
-}
-
-int32_t msm_sensor_power_down(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	struct msm_camera_sensor_info *data = s_ctrl->sensordata;
-	struct device *dev = NULL;
-	if (s_ctrl->sensor_device_type == MSM_SENSOR_PLATFORM_DEVICE)
-		dev = &s_ctrl->pdev->dev;
-	else
-		dev = &s_ctrl->sensor_i2c_client->client->dev;
-	if (s_ctrl->sensor_device_type == MSM_SENSOR_PLATFORM_DEVICE) {
-		msm_sensor_cci_util(s_ctrl->sensor_i2c_client,
-			MSM_CCI_RELEASE);
-	}
-
-	if (data->sensor_platform_info->i2c_conf &&
-		data->sensor_platform_info->i2c_conf->use_i2c_mux)
-		msm_sensor_disable_i2c_mux(
-			data->sensor_platform_info->i2c_conf);
-
-	if (data->sensor_platform_info->ext_power_ctrl != NULL)
-		data->sensor_platform_info->ext_power_ctrl(0);
-	if (s_ctrl->sensor_device_type == MSM_SENSOR_I2C_DEVICE)
-		msm_cam_clk_enable(dev, cam_8960_clk_info, s_ctrl->cam_clk,
-			ARRAY_SIZE(cam_8960_clk_info), 0);
-	else
-		msm_cam_clk_enable(dev, cam_8974_clk_info, s_ctrl->cam_clk,
-			ARRAY_SIZE(cam_8974_clk_info), 0);
-	msm_camera_config_gpio_table(data, 0);
-	msm_camera_enable_vreg(dev,
-		s_ctrl->sensordata->sensor_platform_info->cam_vreg,
-		s_ctrl->sensordata->sensor_platform_info->num_vreg,
-		s_ctrl->vreg_seq,
-		s_ctrl->num_vreg_seq,
-		s_ctrl->reg_ptr, 0);
-	msm_camera_config_vreg(dev,
-		s_ctrl->sensordata->sensor_platform_info->cam_vreg,
-		s_ctrl->sensordata->sensor_platform_info->num_vreg,
-		s_ctrl->vreg_seq,
-		s_ctrl->num_vreg_seq,
-		s_ctrl->reg_ptr, 0);
-	msm_camera_request_gpio_table(data, 0);
-	kfree(s_ctrl->reg_ptr);
-	s_ctrl->curr_res = MSM_SENSOR_INVALID_RES;
-	return 0;
-}
-
-int32_t msm_sensor_match_id(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	int32_t rc = 0;
-	uint16_t chipid = 0;
-	rc = msm_camera_i2c_read(
-			s_ctrl->sensor_i2c_client,
-			s_ctrl->sensor_id_info->sensor_id_reg_addr, &chipid,
-			MSM_CAMERA_I2C_WORD_DATA);
-	if (rc < 0) {
-		pr_err("%s: %s: read id failed\n", __func__,
-			s_ctrl->sensordata->sensor_name);
-		return rc;
-	}
-
-	CDBG("%s: read id: %x expected id %x:\n", __func__, chipid,
-		s_ctrl->sensor_id_info->sensor_id);
-	if (chipid != s_ctrl->sensor_id_info->sensor_id) {
-		pr_err("msm_sensor_match_id chip id doesnot match\n");
-		return -ENODEV;
-	}
-	return rc;
-}
-
-int32_t msm_sensor_i2c_probe(struct i2c_client *client,
-	const struct i2c_device_id *id)
-{
-	int rc = 0;
-	struct msm_sensor_ctrl_t *s_ctrl;
-	CDBG("%s %s_i2c_probe called\n", __func__, client->name);
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		pr_err("%s %s i2c_check_functionality failed\n",
-			__func__, client->name);
-		rc = -EFAULT;
-		return rc;
-	}
-
-	s_ctrl = (struct msm_sensor_ctrl_t *)(id->driver_data);
-	s_ctrl->sensor_device_type = MSM_SENSOR_I2C_DEVICE;
-	if (s_ctrl->sensor_i2c_client != NULL) {
-		s_ctrl->sensor_i2c_client->client = client;
-		if (s_ctrl->sensor_i2c_addr != 0)
-			s_ctrl->sensor_i2c_client->client->addr =
-				s_ctrl->sensor_i2c_addr;
-	} else {
-		pr_err("%s %s sensor_i2c_client NULL\n",
-			__func__, client->name);
-		rc = -EFAULT;
-		return rc;
-	}
-
-	s_ctrl->sensordata = client->dev.platform_data;
-	if (s_ctrl->sensordata == NULL) {
-		pr_err("%s %s NULL sensor data\n", __func__, client->name);
-		return -EFAULT;
-	}
-
-	rc = s_ctrl->func_tbl->sensor_power_up(s_ctrl);
-	if (rc < 0) {
-		pr_err("%s %s power up failed\n", __func__, client->name);
-		return rc;
-	}
-
-	if (s_ctrl->func_tbl->sensor_match_id)
-		rc = s_ctrl->func_tbl->sensor_match_id(s_ctrl);
-	else
-		rc = msm_sensor_match_id(s_ctrl);
-	if (rc < 0)
-		goto probe_fail;
-
-	if (!s_ctrl->wait_num_frames)
-		s_ctrl->wait_num_frames = 1 * Q10;
-
-	pr_err("%s %s probe succeeded\n", __func__, client->name);
-	snprintf(s_ctrl->sensor_v4l2_subdev.name,
-		sizeof(s_ctrl->sensor_v4l2_subdev.name), "%s", id->name);
-	v4l2_i2c_subdev_init(&s_ctrl->sensor_v4l2_subdev, client,
-		s_ctrl->sensor_v4l2_subdev_ops);
-	s_ctrl->sensor_v4l2_subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	media_entity_init(&s_ctrl->sensor_v4l2_subdev.entity, 0, NULL, 0);
-	s_ctrl->sensor_v4l2_subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
-	s_ctrl->sensor_v4l2_subdev.entity.group_id = SENSOR_DEV;
-	s_ctrl->sensor_v4l2_subdev.entity.name =
-		s_ctrl->sensor_v4l2_subdev.name;
-	msm_sensor_register(&s_ctrl->sensor_v4l2_subdev);
-	s_ctrl->sensor_v4l2_subdev.entity.revision =
-		s_ctrl->sensor_v4l2_subdev.devnode->num;
-	goto power_down;
-probe_fail:
-	pr_err("%s %s_i2c_probe failed\n", __func__, client->name);
-power_down:
-	if (rc > 0)
-		rc = 0;
-	s_ctrl->func_tbl->sensor_power_down(s_ctrl);
-	s_ctrl->sensor_state = MSM_SENSOR_POWER_DOWN;
-	return rc;
-}
-
-static int msm_sensor_subdev_match_core(struct device *dev, void *data)
-{
-	int core_index = (int)data;
-	struct platform_device *pdev = to_platform_device(dev);
-	CDBG("%s cci pdev %p\n", __func__, pdev);
-	if (pdev->id == core_index)
-		return 1;
-	else
-		return 0;
-}
-
-int32_t msm_sensor_platform_probe(struct platform_device *pdev, void *data)
-{
-	int32_t rc = 0;
-	struct msm_sensor_ctrl_t *s_ctrl = (struct msm_sensor_ctrl_t *)data;
-	struct device_driver *driver;
-	struct device *dev;
-	s_ctrl->pdev = pdev;
-	CDBG("%s called data %p\n", __func__, data);
-	if (pdev->dev.of_node) {
-		rc = msm_sensor_init_sensor_data(pdev, s_ctrl);
-		if (rc < 0) {
-			pr_err("%s failed line %d\n", __func__, __LINE__);
-			return rc;
-		}
-	}
-	s_ctrl->sensor_device_type = MSM_SENSOR_PLATFORM_DEVICE;
-	s_ctrl->sensor_i2c_client->cci_client = kzalloc(sizeof(
-		struct msm_camera_cci_client), GFP_KERNEL);
-	if (!s_ctrl->sensor_i2c_client->cci_client) {
-		pr_err("%s failed line %d\n", __func__, __LINE__);
-		return rc;
-	}
-	driver = driver_find(MSM_CCI_DRV_NAME, &platform_bus_type);
-	if (!driver) {
-		pr_err("%s failed line %d\n", __func__, __LINE__);
-		return rc;
-	}
-
-	dev = driver_find_device(driver, NULL, 0,
-				msm_sensor_subdev_match_core);
-	if (!dev) {
-		pr_err("%s failed line %d\n", __func__, __LINE__);
-		return rc;
-	}
-	s_ctrl->sensor_i2c_client->cci_client->cci_subdev =
-		dev_get_drvdata(dev);
-	CDBG("%s sd %p\n", __func__,
-		s_ctrl->sensor_i2c_client->cci_client->cci_subdev);
-	s_ctrl->sensor_i2c_client->cci_client->cci_i2c_master = MASTER_0;
-	s_ctrl->sensor_i2c_client->cci_client->sid =
-		s_ctrl->sensor_i2c_addr >> 1;
-	s_ctrl->sensor_i2c_client->cci_client->retries = 3;
-	s_ctrl->sensor_i2c_client->cci_client->id_map = 0;
-	if (!s_ctrl->wait_num_frames)
-		s_ctrl->wait_num_frames = 1 * Q10;
-
-	rc = s_ctrl->func_tbl->sensor_power_up(s_ctrl);
-	if (rc < 0) {
-		pr_err("%s %s power up failed\n", __func__,
-			pdev->id_entry->name);
-		return rc;
-	}
-
-	if (s_ctrl->func_tbl->sensor_match_id)
-		rc = s_ctrl->func_tbl->sensor_match_id(s_ctrl);
-	else
-		rc = msm_sensor_match_id(s_ctrl);
-	if (rc < 0)
-		goto probe_fail;
-
-	pr_err("%s %s probe succeeded\n", __func__,
-		s_ctrl->sensordata->sensor_name);
-	v4l2_subdev_init(&s_ctrl->sensor_v4l2_subdev,
-		s_ctrl->sensor_v4l2_subdev_ops);
-	snprintf(s_ctrl->sensor_v4l2_subdev.name,
-		sizeof(s_ctrl->sensor_v4l2_subdev.name), "%s",
-		s_ctrl->sensordata->sensor_name);
-	v4l2_set_subdevdata(&s_ctrl->sensor_v4l2_subdev, pdev);
-	msm_sensor_register(&s_ctrl->sensor_v4l2_subdev);
-
-	goto power_down;
-probe_fail:
-	pr_err("%s %s probe failed\n", __func__, pdev->id_entry->name);
-power_down:
-	s_ctrl->func_tbl->sensor_power_down(s_ctrl);
-	return rc;
-}
-
-int32_t msm_sensor_power(struct v4l2_subdev *sd, int on)
-{
-	int rc = 0;
-	struct msm_sensor_ctrl_t *s_ctrl = get_sctrl(sd);
-	mutex_lock(s_ctrl->msm_sensor_mutex);
-	if (on) {
-		rc = s_ctrl->func_tbl->sensor_power_up(s_ctrl);
-		if (rc < 0) {
-			pr_err("%s: %s power_up failed rc = %d\n", __func__,
-				s_ctrl->sensordata->sensor_name, rc);
-			s_ctrl->sensor_state = MSM_SENSOR_POWER_DOWN;
-		} else {
-			if (s_ctrl->func_tbl->sensor_match_id)
-				rc = s_ctrl->func_tbl->sensor_match_id(s_ctrl);
-			else
-				rc = msm_sensor_match_id(s_ctrl);
-			if (rc < 0) {
-				pr_err("%s: %s match_id failed  rc=%d\n",
-					__func__,
-					s_ctrl->sensordata->sensor_name, rc);
-				if (s_ctrl->func_tbl->sensor_power_down(s_ctrl)
-					< 0)
-					pr_err("%s: %s power_down failed\n",
-					__func__,
-					s_ctrl->sensordata->sensor_name);
-				s_ctrl->sensor_state = MSM_SENSOR_POWER_DOWN;
-			}
-			s_ctrl->sensor_state = MSM_SENSOR_POWER_UP;
-		}
-	} else {
-		rc = s_ctrl->func_tbl->sensor_power_down(s_ctrl);
-		s_ctrl->sensor_state = MSM_SENSOR_POWER_DOWN;
-	}
-	mutex_unlock(s_ctrl->msm_sensor_mutex);
-	return rc;
-}
-
-int32_t msm_sensor_v4l2_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
-			   enum v4l2_mbus_pixelcode *code)
-{
-	struct msm_sensor_ctrl_t *s_ctrl = get_sctrl(sd);
-
-	if ((unsigned int)index >= s_ctrl->sensor_v4l2_subdev_info_size)
-		return -EINVAL;
-
-	*code = s_ctrl->sensor_v4l2_subdev_info[index].code;
-	return 0;
-}
-
-int32_t msm_sensor_v4l2_s_ctrl(struct v4l2_subdev *sd,
-	struct v4l2_control *ctrl)
-{
-	int rc = -1, i = 0;
-	struct msm_sensor_ctrl_t *s_ctrl = get_sctrl(sd);
-	struct msm_sensor_v4l2_ctrl_info_t *v4l2_ctrl =
-		s_ctrl->msm_sensor_v4l2_ctrl_info;
-
-	CDBG("%s\n", __func__);
-	CDBG("%d\n", ctrl->id);
-	if (v4l2_ctrl == NULL)
-		return rc;
-	for (i = 0; i < s_ctrl->num_v4l2_ctrl; i++) {
-		if (v4l2_ctrl[i].ctrl_id == ctrl->id) {
-			if (v4l2_ctrl[i].s_v4l2_ctrl != NULL) {
-				CDBG("\n calling msm_sensor_s_ctrl_by_enum\n");
-				rc = v4l2_ctrl[i].s_v4l2_ctrl(
-					s_ctrl,
-					&s_ctrl->msm_sensor_v4l2_ctrl_info[i],
-					ctrl->value);
-			}
-			break;
-		}
-	}
-
-	return rc;
-}
-
-int32_t msm_sensor_v4l2_query_ctrl(
-	struct v4l2_subdev *sd, struct v4l2_queryctrl *qctrl)
-{
-	int rc = -1, i = 0;
-	struct msm_sensor_ctrl_t *s_ctrl =
-		(struct msm_sensor_ctrl_t *) sd->dev_priv;
-
-	CDBG("%s\n", __func__);
-	CDBG("%s id: %d\n", __func__, qctrl->id);
-
-	if (s_ctrl->msm_sensor_v4l2_ctrl_info == NULL)
-		return rc;
-
-	for (i = 0; i < s_ctrl->num_v4l2_ctrl; i++) {
-		if (s_ctrl->msm_sensor_v4l2_ctrl_info[i].ctrl_id == qctrl->id) {
-			qctrl->minimum =
-				s_ctrl->msm_sensor_v4l2_ctrl_info[i].min;
-			qctrl->maximum =
-				s_ctrl->msm_sensor_v4l2_ctrl_info[i].max;
-			qctrl->flags = 1;
-			rc = 0;
-			break;
-		}
-	}
-
-	return rc;
-}
-
-int msm_sensor_s_ctrl_by_enum(struct msm_sensor_ctrl_t *s_ctrl,
-		struct msm_sensor_v4l2_ctrl_info_t *ctrl_info, int value)
-{
-	int rc = 0;
-	CDBG("%s enter\n", __func__);
-	rc = msm_sensor_write_enum_conf_array(
-		s_ctrl->sensor_i2c_client,
-		ctrl_info->enum_cfg_settings, value);
-	return rc;
-}
-
-static int msm_sensor_debugfs_stream_s(void *data, u64 val)
-{
-	struct msm_sensor_ctrl_t *s_ctrl = (struct msm_sensor_ctrl_t *) data;
-	if (val)
-		s_ctrl->func_tbl->sensor_start_stream(s_ctrl);
-	else
-		s_ctrl->func_tbl->sensor_stop_stream(s_ctrl);
-	return 0;
-}
-
-DEFINE_SIMPLE_ATTRIBUTE(sensor_debugfs_stream, NULL,
-			msm_sensor_debugfs_stream_s, "%llu\n");
-
-static int msm_sensor_debugfs_test_s(void *data, u64 val)
-{
-	CDBG("val: %llu\n", val);
-	return 0;
-}
-
-DEFINE_SIMPLE_ATTRIBUTE(sensor_debugfs_test, NULL,
-			msm_sensor_debugfs_test_s, "%llu\n");
-
-int msm_sensor_enable_debugfs(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	struct dentry *debugfs_base, *sensor_dir;
-	debugfs_base = debugfs_create_dir("msm_sensor", NULL);
-	if (!debugfs_base)
-		return -ENOMEM;
-
-	sensor_dir = debugfs_create_dir
-		(s_ctrl->sensordata->sensor_name, debugfs_base);
-	if (!sensor_dir)
-		return -ENOMEM;
-
-	if (!debugfs_create_file("stream", S_IRUGO | S_IWUSR, sensor_dir,
-			(void *) s_ctrl, &sensor_debugfs_stream))
-		return -ENOMEM;
-
-	if (!debugfs_create_file("test", S_IRUGO | S_IWUSR, sensor_dir,
-			(void *) s_ctrl, &sensor_debugfs_test))
-		return -ENOMEM;
-
-	return 0;
-}
diff --git a/drivers/media/platform/msm/camera_v1/sensors/msm_sensor.h b/drivers/media/platform/msm/camera_v1/sensors/msm_sensor.h
deleted file mode 100644
index e144197..0000000
--- a/drivers/media/platform/msm/camera_v1/sensors/msm_sensor.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-
-#ifndef MSM_SENSOR_H
-#define MSM_SENSOR_H
-
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/i2c.h>
-#include <linux/miscdevice.h>
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <linux/types.h>
-#include <linux/uaccess.h>
-#include <linux/of.h>
-#include <linux/of_device.h>
-#include <linux/of_gpio.h>
-#include <linux/gpio.h>
-#include <mach/camera.h>
-#include <media/msm_camera.h>
-#include <media/v4l2-subdev.h>
-#include "msm_camera_i2c.h"
-#include "msm_camera_eeprom.h"
-#include "msm_sensor_common.h"
-
-void msm_sensor_start_stream(struct msm_sensor_ctrl_t *s_ctrl);
-void msm_sensor_stop_stream(struct msm_sensor_ctrl_t *s_ctrl);
-void msm_sensor_group_hold_on(struct msm_sensor_ctrl_t *s_ctrl);
-void msm_sensor_group_hold_off(struct msm_sensor_ctrl_t *s_ctrl);
-
-int32_t msm_sensor_set_fps(struct msm_sensor_ctrl_t *s_ctrl,
-			struct fps_cfg   *fps);
-int32_t msm_sensor_write_exp_gain1(struct msm_sensor_ctrl_t *s_ctrl,
-		uint16_t gain, uint32_t line);
-int32_t msm_sensor_write_exp_gain2(struct msm_sensor_ctrl_t *s_ctrl,
-		uint16_t gain, uint32_t line);
-int32_t msm_sensor_set_sensor_mode(struct msm_sensor_ctrl_t *s_ctrl,
-	int mode, int res);
-int32_t msm_sensor_mode_init(struct msm_sensor_ctrl_t *s_ctrl,
-			int mode, struct sensor_init_cfg *init_info);
-int32_t msm_sensor_get_output_info(struct msm_sensor_ctrl_t *,
-		struct sensor_output_info_t *);
-int32_t msm_sensor_config(struct msm_sensor_ctrl_t *s_ctrl,
-			void __user *argp);
-int32_t msm_sensor_power_up(struct msm_sensor_ctrl_t *s_ctrl);
-int32_t msm_sensor_power_down(struct msm_sensor_ctrl_t *s_ctrl);
-
-int32_t msm_sensor_match_id(struct msm_sensor_ctrl_t *s_ctrl);
-int msm_sensor_i2c_probe(struct i2c_client *client,
-	const struct i2c_device_id *id);
-
-int32_t msm_sensor_platform_probe(struct platform_device *pdev, void *data);
-
-int32_t msm_sensor_power(struct v4l2_subdev *sd, int on);
-
-int32_t msm_sensor_v4l2_s_ctrl(struct v4l2_subdev *sd,
-	struct v4l2_control *ctrl);
-
-int32_t msm_sensor_v4l2_query_ctrl(
-	struct v4l2_subdev *sd, struct v4l2_queryctrl *qctrl);
-
-int msm_sensor_s_ctrl_by_index(struct msm_sensor_ctrl_t *s_ctrl,
-	struct msm_sensor_v4l2_ctrl_info_t *ctrl_info, int value);
-
-int msm_sensor_s_ctrl_by_enum(struct msm_sensor_ctrl_t *s_ctrl,
-		struct msm_sensor_v4l2_ctrl_info_t *ctrl_info, int value);
-
-int msm_sensor_v4l2_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
-			enum v4l2_mbus_pixelcode *code);
-
-int msm_sensor_write_init_settings(struct msm_sensor_ctrl_t *s_ctrl);
-int msm_sensor_write_res_settings
-	(struct msm_sensor_ctrl_t *s_ctrl, uint16_t res);
-
-int32_t msm_sensor_write_output_settings(struct msm_sensor_ctrl_t *s_ctrl,
-	uint16_t res);
-
-void msm_sensor_adjust_frame_lines1(struct msm_sensor_ctrl_t *s_ctrl);
-
-void msm_sensor_adjust_frame_lines2(struct msm_sensor_ctrl_t *s_ctrl);
-
-int32_t msm_sensor_setting(struct msm_sensor_ctrl_t *s_ctrl,
-			int update_type, int res);
-
-int32_t msm_sensor_setting1(struct msm_sensor_ctrl_t *s_ctrl,
-			int update_type, int res);
-
-int msm_sensor_enable_debugfs(struct msm_sensor_ctrl_t *s_ctrl);
-
-long msm_sensor_subdev_ioctl(struct v4l2_subdev *sd,
-			unsigned int cmd, void *arg);
-
-int32_t msm_sensor_get_csi_params(struct msm_sensor_ctrl_t *s_ctrl,
-		struct csi_lane_params_t *sensor_output_info);
-
-struct msm_sensor_ctrl_t *get_sctrl(struct v4l2_subdev *sd);
-int32_t msm_sensor_free_sensor_data(struct msm_sensor_ctrl_t *s_ctrl);
-
-#define VIDIOC_MSM_SENSOR_CFG \
-	_IOWR('V', BASE_VIDIOC_PRIVATE + 4, void __user *)
-
-#define VIDIOC_MSM_SENSOR_RELEASE \
-	_IO('V', BASE_VIDIOC_PRIVATE + 11)
-
-#define VIDIOC_MSM_SENSOR_CSID_INFO\
-	_IOWR('V', BASE_VIDIOC_PRIVATE + 12, struct msm_sensor_csi_info *)
-
-#endif
diff --git a/drivers/media/platform/msm/camera_v1/sensors/msm_sensor_bayer.c b/drivers/media/platform/msm/camera_v1/sensors/msm_sensor_bayer.c
deleted file mode 100644
index 18e78a8..0000000
--- a/drivers/media/platform/msm/camera_v1/sensors/msm_sensor_bayer.c
+++ /dev/null
@@ -1,909 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-
-#include "msm_sensor_bayer.h"
-#include "msm.h"
-#include "msm_ispif.h"
-#include "msm_camera_i2c_mux.h"
-/*=============================================================*/
-
-long msm_sensor_bayer_subdev_ioctl(struct v4l2_subdev *sd,
-			unsigned int cmd, void *arg)
-{
-	struct msm_sensor_ctrl_t *s_ctrl = get_sctrl(sd);
-	void __user *argp = (void __user *)arg;
-	switch (cmd) {
-	case VIDIOC_MSM_SENSOR_CFG:
-		return s_ctrl->func_tbl->sensor_config(s_ctrl, argp);
-	case VIDIOC_MSM_SENSOR_RELEASE:
-		return 0;
-	case VIDIOC_MSM_SENSOR_CSID_INFO: {
-		struct msm_sensor_csi_info *csi_info =
-			(struct msm_sensor_csi_info *)arg;
-		s_ctrl->is_csic = csi_info->is_csic;
-		return 0;
-	}
-	default:
-		return -ENOIOCTLCMD;
-	}
-}
-
-int32_t msm_sensor_bayer_get_csi_params(struct msm_sensor_ctrl_t *s_ctrl,
-		struct csi_lane_params_t *sensor_output_info)
-{
-	uint8_t index;
-	struct msm_camera_csi_lane_params *csi_lane_params =
-		s_ctrl->sensordata->sensor_platform_info->csi_lane_params;
-	if (csi_lane_params) {
-		sensor_output_info->csi_lane_assign = csi_lane_params->
-			csi_lane_assign;
-		sensor_output_info->csi_lane_mask = csi_lane_params->
-			csi_lane_mask;
-	}
-	sensor_output_info->csi_if = s_ctrl->sensordata->csi_if;
-	for (index = 0; index < sensor_output_info->csi_if; index++)
-		sensor_output_info->csid_core[index] = s_ctrl->sensordata->
-			pdata[index].csid_core;
-
-	return 0;
-}
-
-int32_t msm_sensor_bayer_config(struct msm_sensor_ctrl_t *s_ctrl,
-	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(s_ctrl->msm_sensor_mutex);
-	CDBG("%s:%d %s cfgtype = %d\n", __func__, __LINE__,
-		s_ctrl->sensordata->sensor_name, cdata.cfgtype);
-	switch (cdata.cfgtype) {
-	case CFG_WRITE_I2C_ARRAY: {
-		struct msm_camera_i2c_reg_setting conf_array;
-		struct msm_camera_i2c_reg_array *regs = NULL;
-
-		if (copy_from_user(&conf_array,
-			(void *)cdata.cfg.setting,
-			sizeof(struct msm_camera_i2c_reg_setting))) {
-			pr_err("%s:%d failed\n", __func__, __LINE__);
-			rc = -EFAULT;
-			break;
-		}
-
-		regs = kzalloc(conf_array.size * sizeof(
-			struct msm_camera_i2c_reg_array),
-			GFP_KERNEL);
-		if (!regs) {
-			pr_err("%s:%d failed\n", __func__, __LINE__);
-			rc = -EFAULT;
-			break;
-		}
-
-		if (copy_from_user(regs, (void *)conf_array.reg_setting,
-			conf_array.size * sizeof(
-			struct msm_camera_i2c_reg_array))) {
-			pr_err("%s:%d failed\n", __func__, __LINE__);
-			kfree(regs);
-			rc = -EFAULT;
-			break;
-		}
-
-		conf_array.reg_setting = regs;
-		rc = msm_camera_i2c_write_bayer_table(s_ctrl->sensor_i2c_client,
-			&conf_array);
-		kfree(regs);
-		break;
-	}
-	case CFG_READ_I2C_ARRAY: {
-		struct msm_camera_i2c_reg_setting conf_array;
-		struct msm_camera_i2c_reg_array *regs;
-		int index;
-
-		if (copy_from_user(&conf_array,
-				(void *)cdata.cfg.setting,
-				sizeof(struct msm_camera_i2c_reg_setting))) {
-				pr_err("%s:%d failed\n", __func__, __LINE__);
-				rc = -EFAULT;
-				break;
-		}
-
-		regs = kzalloc(conf_array.size * sizeof(
-				struct msm_camera_i2c_reg_array),
-				GFP_KERNEL);
-		if (!regs) {
-			pr_err("%s:%d failed\n", __func__, __LINE__);
-			rc = -EFAULT;
-			kfree(regs);
-			break;
-		}
-
-		if (copy_from_user(regs, (void *)conf_array.reg_setting,
-				conf_array.size * sizeof(
-				struct msm_camera_i2c_reg_array))) {
-				pr_err("%s:%d failed\n", __func__, __LINE__);
-				kfree(regs);
-				rc = -EFAULT;
-				break;
-			}
-
-		s_ctrl->sensor_i2c_client->addr_type = conf_array.addr_type;
-		for (index = 0; index < conf_array.size; index++) {
-			msm_camera_i2c_read(s_ctrl->sensor_i2c_client,
-					regs[index].reg_addr,
-					&regs[index].reg_data,
-				conf_array.data_type
-				);
-		}
-
-		if (copy_to_user(conf_array.reg_setting,
-			regs,
-			conf_array.size * sizeof(
-			struct msm_camera_i2c_reg_array))) {
-			pr_err("%s:%d failed\n", __func__, __LINE__);
-			kfree(regs);
-			rc = -EFAULT;
-			break;
-		}
-		s_ctrl->sensor_i2c_client->addr_type = conf_array.addr_type;
-		kfree(regs);
-		break;
-	}
-	case CFG_PCLK_CHANGE: {
-		uint32_t pclk = cdata.cfg.pclk;
-		v4l2_subdev_notify(&s_ctrl->sensor_v4l2_subdev,
-			NOTIFY_PCLK_CHANGE, &pclk);
-		break;
-	}
-	case CFG_GPIO_OP: {
-		struct msm_cam_gpio_operation gop;
-		if (copy_from_user(&gop,
-			(void *)cdata.cfg.setting,
-			sizeof(struct msm_cam_gpio_operation))) {
-			pr_err("%s:%d failed\n", __func__, __LINE__);
-		}
-		switch (gop.op_type) {
-		case GPIO_GET_VALUE:
-			gop.value = gpio_get_value(gop.address);
-			if (copy_from_user((void *)cdata.cfg.setting,
-				&gop,
-				sizeof(struct msm_cam_gpio_operation))) {
-				pr_err("%s:%d failed\n", __func__, __LINE__);
-				rc = -EFAULT;
-				break;
-			}
-			break;
-		case GPIO_SET_VALUE:
-			gpio_set_value(gop.address, gop.value);
-			break;
-		case GPIO_SET_DIRECTION_INPUT:
-			gpio_direction_input(gop.address);
-			break;
-		case GPIO_SET_DIRECTION_OUTPUT:
-			gpio_direction_output(gop.address, gop.value);
-			break;
-		case GPIO_REQUEST:
-			gpio_request(gop.address, gop.tag);
-			break;
-		case GPIO_FREE:
-			gpio_free(gop.address);
-			break;
-		default:
-			break;
-		}
-
-		break;
-	}
-	case CFG_GET_CSI_PARAMS:
-		if (s_ctrl->func_tbl->sensor_get_csi_params == NULL) {
-			rc = -EFAULT;
-			break;
-		}
-		rc = s_ctrl->func_tbl->sensor_get_csi_params(
-			s_ctrl,
-			&cdata.cfg.csi_lane_params);
-
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_POWER_UP:
-		if (s_ctrl->func_tbl->sensor_power_up)
-			rc = s_ctrl->func_tbl->sensor_power_up(s_ctrl);
-		else
-			rc = -EFAULT;
-		break;
-
-	case CFG_POWER_DOWN:
-		if (s_ctrl->func_tbl->sensor_power_down)
-			rc = s_ctrl->func_tbl->sensor_power_down(
-				s_ctrl);
-		else
-			rc = -EFAULT;
-		break;
-
-	case CFG_CONFIG_VREG_ARRAY: {
-		struct msm_camera_vreg_setting vreg_setting;
-		struct camera_vreg_t *cam_vreg = NULL;
-
-		if (copy_from_user(&vreg_setting,
-			(void *)cdata.cfg.setting,
-			sizeof(struct msm_camera_vreg_setting))) {
-			pr_err("%s:%d failed\n", __func__, __LINE__);
-			rc = -EFAULT;
-			break;
-		}
-
-		cam_vreg = kzalloc(vreg_setting.num_vreg * sizeof(
-			struct camera_vreg_t),
-			GFP_KERNEL);
-		if (!cam_vreg) {
-			pr_err("%s:%d failed\n", __func__, __LINE__);
-			rc = -EFAULT;
-			break;
-		}
-
-		if (copy_from_user(cam_vreg, (void *)vreg_setting.cam_vreg,
-			vreg_setting.num_vreg * sizeof(
-			struct camera_vreg_t))) {
-			pr_err("%s:%d failed\n", __func__, __LINE__);
-			kfree(cam_vreg);
-			rc = -EFAULT;
-			break;
-		}
-		rc = msm_camera_config_vreg(
-			&s_ctrl->sensor_i2c_client->client->dev,
-			cam_vreg,
-			vreg_setting.num_vreg,
-			NULL,
-			0,
-			s_ctrl->reg_ptr,
-			vreg_setting.enable);
-		if (rc < 0) {
-			kfree(cam_vreg);
-			pr_err("%s: regulator on failed\n", __func__);
-			break;
-		}
-
-		rc = msm_camera_enable_vreg(
-			&s_ctrl->sensor_i2c_client->client->dev,
-			cam_vreg,
-			vreg_setting.num_vreg,
-			NULL,
-			0,
-			s_ctrl->reg_ptr,
-			vreg_setting.enable);
-		if (rc < 0) {
-			kfree(cam_vreg);
-			pr_err("%s: enable regulator failed\n", __func__);
-			break;
-		}
-		kfree(cam_vreg);
-		break;
-	}
-	case CFG_CONFIG_CLK_ARRAY: {
-		struct msm_cam_clk_setting clk_setting;
-		struct msm_cam_clk_info *clk_info = NULL;
-
-		if (copy_from_user(&clk_setting,
-			(void *)cdata.cfg.setting,
-			sizeof(struct msm_camera_vreg_setting))) {
-			pr_err("%s:%d failed\n", __func__, __LINE__);
-			rc = -EFAULT;
-			break;
-		}
-
-		clk_info = kzalloc(clk_setting.num_clk_info * sizeof(
-			struct msm_cam_clk_info),
-			GFP_KERNEL);
-		if (!clk_info) {
-			pr_err("%s:%d failed\n", __func__, __LINE__);
-			rc = -EFAULT;
-			break;
-		}
-
-		if (copy_from_user(clk_info, (void *)clk_setting.clk_info,
-			clk_setting.num_clk_info * sizeof(
-			struct msm_cam_clk_info))) {
-			pr_err("%s:%d failed\n", __func__, __LINE__);
-			kfree(clk_info);
-			rc = -EFAULT;
-			break;
-		}
-		rc = msm_cam_clk_enable(&s_ctrl->sensor_i2c_client->client->dev,
-			clk_info, s_ctrl->cam_clk,
-			clk_setting.num_clk_info,
-			clk_setting.enable);
-		kfree(clk_info);
-		break;
-	}
-	case CFG_GET_EEPROM_DATA: {
-		if (copy_to_user((void *)cdata.cfg.eeprom_data.eeprom_data,
-			&s_ctrl->eeprom_data.data, s_ctrl->eeprom_data.length)){
-			pr_err("%s:%d failed\n", __func__, __LINE__);
-			rc = -EFAULT;
-		}
-		cdata.cfg.eeprom_data.index = s_ctrl->eeprom_data.length;
-		break;
-	}
-	default:
-		rc = -EFAULT;
-		break;
-	}
-
-	mutex_unlock(s_ctrl->msm_sensor_mutex);
-
-	return rc;
-}
-
-static struct msm_cam_clk_info cam_clk_info[] = {
-	{"cam_clk", MSM_SENSOR_MCLK_24HZ},
-};
-
-int32_t msm_sensor_bayer_enable_i2c_mux(struct msm_camera_i2c_conf *i2c_conf)
-{
-	struct v4l2_subdev *i2c_mux_sd =
-		dev_get_drvdata(&i2c_conf->mux_dev->dev);
-	v4l2_subdev_call(i2c_mux_sd, core, ioctl,
-		VIDIOC_MSM_I2C_MUX_INIT, NULL);
-	v4l2_subdev_call(i2c_mux_sd, core, ioctl,
-		VIDIOC_MSM_I2C_MUX_CFG, (void *)&i2c_conf->i2c_mux_mode);
-	return 0;
-}
-
-int32_t msm_sensor_bayer_disable_i2c_mux(struct msm_camera_i2c_conf *i2c_conf)
-{
-	struct v4l2_subdev *i2c_mux_sd =
-		dev_get_drvdata(&i2c_conf->mux_dev->dev);
-	v4l2_subdev_call(i2c_mux_sd, core, ioctl,
-				VIDIOC_MSM_I2C_MUX_RELEASE, NULL);
-	return 0;
-}
-
-static struct msm_camera_power_seq_t sensor_power_seq[] = {
-	{REQUEST_GPIO, 0},
-	{REQUEST_VREG, 0},
-	{ENABLE_VREG, 0},
-	{ENABLE_GPIO, 0},
-	{CONFIG_CLK, 0},
-	{CONFIG_EXT_POWER_CTRL, 0},
-	{CONFIG_I2C_MUX, 0},
-};
-
-int32_t msm_sensor_bayer_power_up(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	int32_t rc = 0, size = 0, index = 0;
-	struct msm_camera_sensor_info *data = s_ctrl->sensordata;
-	struct msm_camera_power_seq_t *power_seq = NULL;
-	CDBG("%s: %d\n", __func__, __LINE__);
-	if (s_ctrl->power_seq) {
-		power_seq = s_ctrl->power_seq;
-		size = s_ctrl->num_power_seq;
-	} else {
-		power_seq = &sensor_power_seq[0];
-		size = ARRAY_SIZE(sensor_power_seq);
-	}
-
-	s_ctrl->reg_ptr = kzalloc(sizeof(struct regulator *)
-			* data->sensor_platform_info->num_vreg, GFP_KERNEL);
-	if (!s_ctrl->reg_ptr) {
-		pr_err("%s: could not allocate mem for regulators\n",
-			__func__);
-		return -ENOMEM;
-	}
-
-	for (index = 0; index < size; index++) {
-		switch (power_seq[index].power_config) {
-		case REQUEST_GPIO:
-			rc = msm_camera_request_gpio_table(data, 1);
-			if (rc < 0) {
-				pr_err("%s: request gpio failed\n", __func__);
-				goto ERROR;
-			}
-			if (power_seq[index].delay)
-				usleep_range(power_seq[index].delay * 1000,
-					(power_seq[index].delay * 1000) + 1000);
-			break;
-		case REQUEST_VREG:
-			rc = msm_camera_config_vreg(
-				&s_ctrl->sensor_i2c_client->client->dev,
-				s_ctrl->sensordata->sensor_platform_info->
-				cam_vreg,
-				s_ctrl->sensordata->sensor_platform_info->
-				num_vreg,
-				s_ctrl->vreg_seq,
-				s_ctrl->num_vreg_seq,
-				s_ctrl->reg_ptr, 1);
-			if (rc < 0) {
-				pr_err("%s: regulator on failed\n", __func__);
-				goto ERROR;
-			}
-			if (power_seq[index].delay)
-				usleep_range(power_seq[index].delay * 1000,
-					(power_seq[index].delay * 1000) + 1000);
-			break;
-		case ENABLE_VREG:
-			rc = msm_camera_enable_vreg(
-				&s_ctrl->sensor_i2c_client->client->dev,
-				s_ctrl->sensordata->sensor_platform_info->
-				cam_vreg,
-				s_ctrl->sensordata->sensor_platform_info->
-				num_vreg,
-				s_ctrl->vreg_seq,
-				s_ctrl->num_vreg_seq,
-				s_ctrl->reg_ptr, 1);
-			if (rc < 0) {
-				pr_err("%s: enable regulator failed\n",
-					__func__);
-				goto ERROR;
-			}
-			if (power_seq[index].delay)
-				usleep_range(power_seq[index].delay * 1000,
-					(power_seq[index].delay * 1000) + 1000);
-			break;
-		case ENABLE_GPIO:
-			rc = msm_camera_config_gpio_table(data, 1);
-			if (rc < 0) {
-				pr_err("%s: config gpio failed\n", __func__);
-				goto ERROR;
-			}
-			if (power_seq[index].delay)
-				usleep_range(power_seq[index].delay * 1000,
-					(power_seq[index].delay * 1000) + 1000);
-			break;
-		case CONFIG_CLK:
-			if (s_ctrl->clk_rate != 0)
-				cam_clk_info->clk_rate = s_ctrl->clk_rate;
-
-			rc = msm_cam_clk_enable(
-				&s_ctrl->sensor_i2c_client->client->dev,
-				cam_clk_info, s_ctrl->cam_clk,
-				ARRAY_SIZE(cam_clk_info), 1);
-			if (rc < 0) {
-				pr_err("%s: clk enable failed\n", __func__);
-				goto ERROR;
-			}
-			if (power_seq[index].delay)
-				usleep_range(power_seq[index].delay * 1000,
-					(power_seq[index].delay * 1000) + 1000);
-			break;
-		case CONFIG_EXT_POWER_CTRL:
-			if (data->sensor_platform_info->ext_power_ctrl != NULL)
-				data->sensor_platform_info->ext_power_ctrl(1);
-			if (power_seq[index].delay)
-				usleep_range(power_seq[index].delay * 1000,
-					(power_seq[index].delay * 1000) + 1000);
-			break;
-		case CONFIG_I2C_MUX:
-			if (data->sensor_platform_info->i2c_conf &&
-				data->sensor_platform_info->i2c_conf->
-				use_i2c_mux)
-				msm_sensor_bayer_enable_i2c_mux(
-					data->sensor_platform_info->i2c_conf);
-			if (power_seq[index].delay)
-				usleep_range(power_seq[index].delay * 1000,
-					(power_seq[index].delay * 1000) + 1000);
-			break;
-		default:
-			pr_err("%s error power config %d\n", __func__,
-				power_seq[index].power_config);
-			rc = -EINVAL;
-			break;
-		}
-	}
-
-	return rc;
-
-ERROR:
-	for (index--; index >= 0; index--) {
-		switch (power_seq[index].power_config) {
-		case CONFIG_I2C_MUX:
-			if (data->sensor_platform_info->i2c_conf &&
-				data->sensor_platform_info->i2c_conf->
-				use_i2c_mux)
-				msm_sensor_bayer_disable_i2c_mux(
-					data->sensor_platform_info->i2c_conf);
-			break;
-		case CONFIG_EXT_POWER_CTRL:
-			if (data->sensor_platform_info->ext_power_ctrl != NULL)
-				data->sensor_platform_info->ext_power_ctrl(0);
-			break;
-		case CONFIG_CLK:
-			msm_cam_clk_enable(&s_ctrl->sensor_i2c_client->client->
-				dev, cam_clk_info, s_ctrl->cam_clk,
-				ARRAY_SIZE(cam_clk_info), 0);
-			break;
-		case ENABLE_GPIO:
-			msm_camera_config_gpio_table(data, 0);
-			break;
-		case ENABLE_VREG:
-			msm_camera_enable_vreg(&s_ctrl->sensor_i2c_client->
-				client->dev,
-				s_ctrl->sensordata->sensor_platform_info->
-				cam_vreg,
-				s_ctrl->sensordata->sensor_platform_info->
-				num_vreg,
-				s_ctrl->vreg_seq,
-				s_ctrl->num_vreg_seq,
-				s_ctrl->reg_ptr, 0);
-			break;
-		case REQUEST_VREG:
-			msm_camera_config_vreg(&s_ctrl->sensor_i2c_client->
-				client->dev,
-				s_ctrl->sensordata->sensor_platform_info->
-				cam_vreg,
-				s_ctrl->sensordata->sensor_platform_info->
-				num_vreg,
-				s_ctrl->vreg_seq,
-				s_ctrl->num_vreg_seq,
-				s_ctrl->reg_ptr, 0);
-			break;
-		case REQUEST_GPIO:
-			msm_camera_request_gpio_table(data, 0);
-			break;
-		default:
-			pr_err("%s error power config %d\n", __func__,
-				power_seq[index].power_config);
-			break;
-		}
-	}
-	kfree(s_ctrl->reg_ptr);
-	return rc;
-}
-
-int32_t msm_sensor_bayer_power_down(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	int32_t size = 0, index = 0;
-	struct msm_camera_sensor_info *data = s_ctrl->sensordata;
-	struct msm_camera_power_seq_t *power_seq = NULL;
-	CDBG("%s\n", __func__);
-
-	if (s_ctrl->power_seq) {
-		power_seq = s_ctrl->power_seq;
-		size = s_ctrl->num_power_seq;
-	} else {
-		power_seq = &sensor_power_seq[0];
-		size = ARRAY_SIZE(sensor_power_seq);
-	}
-
-	for (index = (size - 1); index >= 0; index--) {
-		switch (power_seq[index].power_config) {
-		case CONFIG_I2C_MUX:
-			if (data->sensor_platform_info->i2c_conf &&
-				data->sensor_platform_info->i2c_conf->
-				use_i2c_mux)
-				msm_sensor_bayer_disable_i2c_mux(
-					data->sensor_platform_info->i2c_conf);
-			break;
-		case CONFIG_EXT_POWER_CTRL:
-			if (data->sensor_platform_info->ext_power_ctrl != NULL)
-				data->sensor_platform_info->ext_power_ctrl(0);
-			break;
-		case CONFIG_CLK:
-			msm_cam_clk_enable(&s_ctrl->sensor_i2c_client->client->
-				dev, cam_clk_info, s_ctrl->cam_clk,
-				ARRAY_SIZE(cam_clk_info), 0);
-			break;
-		case ENABLE_GPIO:
-			msm_camera_config_gpio_table(data, 0);
-			break;
-		case ENABLE_VREG:
-			msm_camera_enable_vreg(&s_ctrl->sensor_i2c_client->
-				client->dev,
-				s_ctrl->sensordata->sensor_platform_info->
-				cam_vreg,
-				s_ctrl->sensordata->sensor_platform_info->
-				num_vreg,
-				s_ctrl->vreg_seq,
-				s_ctrl->num_vreg_seq,
-				s_ctrl->reg_ptr, 0);
-			break;
-		case REQUEST_VREG:
-			msm_camera_config_vreg(&s_ctrl->sensor_i2c_client->
-				client->dev,
-				s_ctrl->sensordata->sensor_platform_info->
-				cam_vreg,
-				s_ctrl->sensordata->sensor_platform_info->
-				num_vreg,
-				s_ctrl->vreg_seq,
-				s_ctrl->num_vreg_seq,
-				s_ctrl->reg_ptr, 0);
-			break;
-		case REQUEST_GPIO:
-			msm_camera_request_gpio_table(data, 0);
-			break;
-		default:
-			pr_err("%s error power config %d\n", __func__,
-				power_seq[index].power_config);
-			break;
-		}
-	}
-	kfree(s_ctrl->reg_ptr);
-	return 0;
-}
-
-int32_t msm_sensor_bayer_match_id(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	int32_t rc = 0;
-	uint16_t chipid = 0;
-	rc = msm_camera_i2c_read(
-			s_ctrl->sensor_i2c_client,
-			s_ctrl->sensor_id_info->sensor_id_reg_addr, &chipid,
-			MSM_CAMERA_I2C_WORD_DATA);
-	if (rc < 0) {
-		pr_err("%s: %s: read id failed\n", __func__,
-			s_ctrl->sensordata->sensor_name);
-		return rc;
-	}
-
-	CDBG("%s: read id: %x expected id %x:\n", __func__, chipid,
-		s_ctrl->sensor_id_info->sensor_id);
-	if (chipid != s_ctrl->sensor_id_info->sensor_id) {
-		pr_err("msm_sensor_match_id chip id doesnot match\n");
-		return -ENODEV;
-	}
-	return rc;
-}
-
-int32_t msm_sensor_bayer_eeprom_read(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	uint32_t reg_addr = 0;
-	uint8_t *data = s_ctrl->eeprom_data.data;
-	uint32_t num_byte = 0;
-	int rc = 0;
-	uint32_t i2c_addr;
-	struct msm_camera_sensor_info *sensor_info = s_ctrl->sensordata;
-	i2c_addr = sensor_info->eeprom_info->eeprom_i2c_slave_addr;
-	num_byte = s_ctrl->eeprom_data.length = sensor_info->eeprom_info->
-		eeprom_read_length;
-	reg_addr = sensor_info->eeprom_info->eeprom_reg_addr;
-
-	data = kzalloc(num_byte * sizeof(uint8_t), GFP_KERNEL);
-	if (!data) {
-		pr_err("%s:%d failed\n", __func__, __LINE__);
-		rc = -EFAULT;
-		return rc;
-	}
-
-	s_ctrl->sensor_i2c_client->client->addr = i2c_addr;
-	CDBG("eeprom read: i2c addr is %x num byte %d  reg addr %x\n",
-		i2c_addr, num_byte, reg_addr);
-	rc = msm_camera_i2c_read_seq(s_ctrl->sensor_i2c_client, reg_addr, data,
-		num_byte);
-	s_ctrl->sensor_i2c_client->client->addr = s_ctrl->sensor_i2c_addr;
-	return rc;
-}
-
-int32_t msm_sensor_bayer_i2c_probe(struct i2c_client *client,
-	const struct i2c_device_id *id)
-{
-	int rc = 0;
-	struct msm_sensor_ctrl_t *s_ctrl;
-	CDBG("%s %s_i2c_probe called\n", __func__, client->name);
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		pr_err("%s %s i2c_check_functionality failed\n",
-			__func__, client->name);
-		rc = -EFAULT;
-		return rc;
-	}
-
-	s_ctrl = (struct msm_sensor_ctrl_t *)(id->driver_data);
-	if (s_ctrl->sensor_i2c_client != NULL) {
-		s_ctrl->sensor_i2c_client->client = client;
-		if (s_ctrl->sensor_i2c_addr != 0)
-			s_ctrl->sensor_i2c_client->client->addr =
-				s_ctrl->sensor_i2c_addr;
-	} else {
-		pr_err("%s %s sensor_i2c_client NULL\n",
-			__func__, client->name);
-		rc = -EFAULT;
-		return rc;
-	}
-
-	s_ctrl->sensordata = client->dev.platform_data;
-	if (s_ctrl->sensordata == NULL) {
-		pr_err("%s %s NULL sensor data\n", __func__, client->name);
-		return -EFAULT;
-	}
-
-	rc = s_ctrl->func_tbl->sensor_power_up(s_ctrl);
-	if (rc < 0) {
-		pr_err("%s %s power up failed\n", __func__, client->name);
-		return rc;
-	}
-
-	if (s_ctrl->func_tbl->sensor_match_id)
-		rc = s_ctrl->func_tbl->sensor_match_id(s_ctrl);
-	else
-		rc = msm_sensor_bayer_match_id(s_ctrl);
-	if (rc < 0)
-		goto probe_fail;
-
-	if (!s_ctrl->wait_num_frames)
-		s_ctrl->wait_num_frames = 1;
-
-	pr_err("%s %s probe succeeded\n", __func__, client->name);
-	snprintf(s_ctrl->sensor_v4l2_subdev.name,
-		sizeof(s_ctrl->sensor_v4l2_subdev.name), "%s", id->name);
-	v4l2_i2c_subdev_init(&s_ctrl->sensor_v4l2_subdev, client,
-		s_ctrl->sensor_v4l2_subdev_ops);
-	s_ctrl->sensor_v4l2_subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	media_entity_init(&s_ctrl->sensor_v4l2_subdev.entity, 0, NULL, 0);
-	s_ctrl->sensor_v4l2_subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
-	s_ctrl->sensor_v4l2_subdev.entity.group_id = SENSOR_DEV;
-	s_ctrl->sensor_v4l2_subdev.entity.name =
-		s_ctrl->sensor_v4l2_subdev.name;
-	msm_sensor_register(&s_ctrl->sensor_v4l2_subdev);
-	s_ctrl->sensor_v4l2_subdev.entity.revision =
-		s_ctrl->sensor_v4l2_subdev.devnode->num;
-	if (s_ctrl->func_tbl->sensor_read_eeprom != NULL)
-		s_ctrl->func_tbl->sensor_read_eeprom(s_ctrl);
-	else
-		msm_sensor_bayer_eeprom_read(s_ctrl);
-	goto power_down;
-probe_fail:
-	pr_err("%s %s_i2c_probe failed\n", __func__, client->name);
-power_down:
-	if (rc > 0)
-		rc = 0;
-	s_ctrl->func_tbl->sensor_power_down(s_ctrl);
-	return rc;
-}
-
-int32_t msm_sensor_delay_i2c_probe(struct i2c_client *client,
-	const struct i2c_device_id *id)
-{
-	int rc = 0;
-	struct msm_sensor_ctrl_t *s_ctrl;
-	CDBG("%s %s_delay_i2c_probe called\n", __func__, client->name);
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		pr_err("%s %s i2c_check_functionality failed\n",
-			__func__, client->name);
-		rc = -EFAULT;
-		return rc;
-	}
-
-	s_ctrl = (struct msm_sensor_ctrl_t *)(id->driver_data);
-	if (s_ctrl->sensor_i2c_client != NULL) {
-		s_ctrl->sensor_i2c_client->client = client;
-		if (s_ctrl->sensor_i2c_addr != 0)
-			s_ctrl->sensor_i2c_client->client->addr =
-				s_ctrl->sensor_i2c_addr;
-	} else {
-		pr_err("%s %s sensor_i2c_client NULL\n",
-			__func__, client->name);
-		rc = -EFAULT;
-		return rc;
-	}
-
-	s_ctrl->sensordata = client->dev.platform_data;
-	if (s_ctrl->sensordata == NULL) {
-		pr_err("%s %s NULL sensor data\n", __func__, client->name);
-		return -EFAULT;
-	}
-
-	if (!s_ctrl->wait_num_frames)
-		s_ctrl->wait_num_frames = 1;
-
-	pr_err("%s %s probe succeeded\n", __func__, client->name);
-	snprintf(s_ctrl->sensor_v4l2_subdev.name,
-		sizeof(s_ctrl->sensor_v4l2_subdev.name), "%s", id->name);
-	v4l2_i2c_subdev_init(&s_ctrl->sensor_v4l2_subdev, client,
-		s_ctrl->sensor_v4l2_subdev_ops);
-	s_ctrl->sensor_v4l2_subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	media_entity_init(&s_ctrl->sensor_v4l2_subdev.entity, 0, NULL, 0);
-	s_ctrl->sensor_v4l2_subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
-	s_ctrl->sensor_v4l2_subdev.entity.group_id = SENSOR_DEV;
-	s_ctrl->sensor_v4l2_subdev.entity.name =
-		s_ctrl->sensor_v4l2_subdev.name;
-	msm_sensor_register(&s_ctrl->sensor_v4l2_subdev);
-	s_ctrl->sensor_v4l2_subdev.entity.revision =
-		s_ctrl->sensor_v4l2_subdev.devnode->num;
-	if (rc > 0)
-		rc = 0;
-	return rc;
-}
-
-int32_t msm_sensor_bayer_power(struct v4l2_subdev *sd, int on)
-{
-	int rc = 0;
-	struct msm_sensor_ctrl_t *s_ctrl = get_sctrl(sd);
-	mutex_lock(s_ctrl->msm_sensor_mutex);
-	if (!on)
-		rc = s_ctrl->func_tbl->sensor_power_down(s_ctrl);
-	mutex_unlock(s_ctrl->msm_sensor_mutex);
-	return rc;
-}
-
-int32_t msm_sensor_bayer_v4l2_enum_fmt(struct v4l2_subdev *sd,
-	unsigned int index, enum v4l2_mbus_pixelcode *code)
-{
-	struct msm_sensor_ctrl_t *s_ctrl = get_sctrl(sd);
-
-	if ((unsigned int)index >= s_ctrl->sensor_v4l2_subdev_info_size)
-		return -EINVAL;
-
-	*code = s_ctrl->sensor_v4l2_subdev_info[index].code;
-	return 0;
-}
-
-int32_t msm_sensor_bayer_v4l2_s_ctrl(struct v4l2_subdev *sd,
-	struct v4l2_control *ctrl)
-{
-	int rc = -1, i = 0;
-	struct msm_sensor_ctrl_t *s_ctrl = get_sctrl(sd);
-	struct msm_sensor_v4l2_ctrl_info_t *v4l2_ctrl =
-		s_ctrl->msm_sensor_v4l2_ctrl_info;
-
-	CDBG("%s\n", __func__);
-	CDBG("%d\n", ctrl->id);
-	if (v4l2_ctrl == NULL)
-		return rc;
-	for (i = 0; i < s_ctrl->num_v4l2_ctrl; i++) {
-		if (v4l2_ctrl[i].ctrl_id == ctrl->id) {
-			if (v4l2_ctrl[i].s_v4l2_ctrl != NULL) {
-				CDBG("\n calling msm_sensor_s_ctrl_by_enum\n");
-				rc = v4l2_ctrl[i].s_v4l2_ctrl(
-					s_ctrl,
-					&s_ctrl->msm_sensor_v4l2_ctrl_info[i],
-					ctrl->value);
-			}
-			break;
-		}
-	}
-
-	return rc;
-}
-
-int32_t msm_sensor_bayer_v4l2_query_ctrl(
-	struct v4l2_subdev *sd, struct v4l2_queryctrl *qctrl)
-{
-	int rc = -1, i = 0;
-	struct msm_sensor_ctrl_t *s_ctrl =
-		(struct msm_sensor_ctrl_t *) sd->dev_priv;
-
-	CDBG("%s\n", __func__);
-	CDBG("%s id: %d\n", __func__, qctrl->id);
-
-	if (s_ctrl->msm_sensor_v4l2_ctrl_info == NULL)
-		return rc;
-
-	for (i = 0; i < s_ctrl->num_v4l2_ctrl; i++) {
-		if (s_ctrl->msm_sensor_v4l2_ctrl_info[i].ctrl_id == qctrl->id) {
-			qctrl->minimum =
-				s_ctrl->msm_sensor_v4l2_ctrl_info[i].min;
-			qctrl->maximum =
-				s_ctrl->msm_sensor_v4l2_ctrl_info[i].max;
-			qctrl->flags = 1;
-			rc = 0;
-			break;
-		}
-	}
-
-	return rc;
-}
-
-int msm_sensor_bayer_s_ctrl_by_enum(struct msm_sensor_ctrl_t *s_ctrl,
-		struct msm_sensor_v4l2_ctrl_info_t *ctrl_info, int value)
-{
-	int rc = 0;
-	CDBG("%s enter\n", __func__);
-	rc = msm_sensor_write_enum_conf_array(
-		s_ctrl->sensor_i2c_client,
-		ctrl_info->enum_cfg_settings, value);
-	return rc;
-}
-
diff --git a/drivers/media/platform/msm/camera_v1/sensors/msm_sensor_bayer.h b/drivers/media/platform/msm/camera_v1/sensors/msm_sensor_bayer.h
deleted file mode 100644
index 584b790..0000000
--- a/drivers/media/platform/msm/camera_v1/sensors/msm_sensor_bayer.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-
-#ifndef MSM_SENSOR_BAYER_H
-#define MSM_SENSOR_BAYER_H
-
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/i2c.h>
-#include <linux/miscdevice.h>
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <linux/types.h>
-#include <linux/uaccess.h>
-#include <mach/camera.h>
-#include <mach/gpio.h>
-#include <media/msm_camera.h>
-#include <media/v4l2-subdev.h>
-#include "msm_camera_i2c.h"
-#include "msm_camera_eeprom.h"
-#include "msm_sensor_common.h"
-
-struct sensor_driver_t {
-	struct platform_driver *platform_pdriver;
-	int32_t (*platform_probe)(struct platform_device *pdev);
-};
-
-int32_t msm_sensor_bayer_config(struct msm_sensor_ctrl_t *s_ctrl,
-			void __user *argp);
-int32_t msm_sensor_bayer_power_up(struct msm_sensor_ctrl_t *s_ctrl);
-int32_t msm_sensor_bayer_power_down(struct msm_sensor_ctrl_t *s_ctrl);
-
-int32_t msm_sensor_bayer_match_id(struct msm_sensor_ctrl_t *s_ctrl);
-int msm_sensor_bayer_i2c_probe(struct i2c_client *client,
-	const struct i2c_device_id *id);
-int32_t msm_sensor_delay_i2c_probe(struct i2c_client *client,
-	const struct i2c_device_id *id);
-int32_t msm_sensor_bayer_power(struct v4l2_subdev *sd, int on);
-
-int32_t msm_sensor_bayer_v4l2_s_ctrl(struct v4l2_subdev *sd,
-	struct v4l2_control *ctrl);
-
-int32_t msm_sensor_bayer_v4l2_query_ctrl(
-	struct v4l2_subdev *sd, struct v4l2_queryctrl *qctrl);
-
-int msm_sensor_bayer_s_ctrl_by_enum(struct msm_sensor_ctrl_t *s_ctrl,
-		struct msm_sensor_v4l2_ctrl_info_t *ctrl_info, int value);
-
-int msm_sensor_bayer_v4l2_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
-			enum v4l2_mbus_pixelcode *code);
-
-long msm_sensor_bayer_subdev_ioctl(struct v4l2_subdev *sd,
-			unsigned int cmd, void *arg);
-
-int32_t msm_sensor_bayer_get_csi_params(struct msm_sensor_ctrl_t *s_ctrl,
-		struct csi_lane_params_t *sensor_output_info);
-
-int32_t msm_sensor_bayer_eeprom_read(struct msm_sensor_ctrl_t *s_ctrl);
-
-#define VIDIOC_MSM_SENSOR_CFG \
-	_IOWR('V', BASE_VIDIOC_PRIVATE + 4, void __user *)
-
-#define VIDIOC_MSM_SENSOR_RELEASE \
-	_IO('V', BASE_VIDIOC_PRIVATE + 11)
-
-#define VIDIOC_MSM_SENSOR_CSID_INFO\
-	_IOWR('V', BASE_VIDIOC_PRIVATE + 12, struct msm_sensor_csi_info *)
-#endif
diff --git a/drivers/media/platform/msm/camera_v1/sensors/msm_sensor_common.c b/drivers/media/platform/msm/camera_v1/sensors/msm_sensor_common.c
deleted file mode 100644
index a8d78b0..0000000
--- a/drivers/media/platform/msm/camera_v1/sensors/msm_sensor_common.c
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-
-#include "msm_sensor_common.h"
-
-struct msm_sensor_ctrl_t *get_sctrl(struct v4l2_subdev *sd)
-{
-	return container_of(sd, struct msm_sensor_ctrl_t, sensor_v4l2_subdev);
-}
diff --git a/drivers/media/platform/msm/camera_v1/sensors/msm_sensor_common.h b/drivers/media/platform/msm/camera_v1/sensors/msm_sensor_common.h
deleted file mode 100644
index a1f5b83..0000000
--- a/drivers/media/platform/msm/camera_v1/sensors/msm_sensor_common.h
+++ /dev/null
@@ -1,227 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-
-#ifndef MSM_SENSOR_COMMON_H
-#define MSM_SENSOR_COMMON_H
-
-#include <linux/debugfs.h>
-#include <linux/delay.h>
-#include <linux/i2c.h>
-#include <linux/miscdevice.h>
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/slab.h>
-#include <linux/types.h>
-#include <linux/uaccess.h>
-#include <linux/gpio.h>
-#include <linux/of_gpio.h>
-#include <mach/camera.h>
-#include <media/msm_camera.h>
-#include <media/v4l2-subdev.h>
-#include "msm_camera_i2c.h"
-#include "msm_camera_eeprom.h"
-#define Q8  0x00000100
-#define Q10 0x00000400
-
-#define MSM_SENSOR_MCLK_8HZ 8000000
-#define MSM_SENSOR_MCLK_16HZ 16000000
-#define MSM_SENSOR_MCLK_24HZ 24000000
-
-#define DEFINE_MSM_MUTEX(mutexname) \
-	static struct mutex mutexname = __MUTEX_INITIALIZER(mutexname)
-
-struct gpio_tlmm_cfg {
-	uint32_t gpio;
-	uint32_t dir;
-	uint32_t pull;
-	uint32_t drvstr;
-};
-
-enum msm_sensor_reg_update {
-	/* Sensor egisters that need to be updated during initialization */
-	MSM_SENSOR_REG_INIT,
-	/* Sensor egisters that needs periodic I2C writes */
-	MSM_SENSOR_UPDATE_PERIODIC,
-	/* All the sensor Registers will be updated */
-	MSM_SENSOR_UPDATE_ALL,
-	/* Not valid update */
-	MSM_SENSOR_UPDATE_INVALID
-};
-
-enum msm_sensor_cam_mode_t {
-	MSM_SENSOR_MODE_2D_RIGHT,
-	MSM_SENSOR_MODE_2D_LEFT,
-	MSM_SENSOR_MODE_3D,
-	MSM_SENSOR_MODE_INVALID
-};
-
-enum msm_camera_power_config_t {
-	REQUEST_GPIO,
-	ENABLE_GPIO,
-	REQUEST_VREG,
-	ENABLE_VREG,
-	CONFIG_CLK,
-	CONFIG_EXT_POWER_CTRL,
-	CONFIG_I2C_MUX,
-};
-
-struct msm_camera_power_seq_t {
-	enum msm_camera_power_config_t power_config;
-	uint32_t delay;
-};
-
-struct msm_sensor_id_info_t {
-	uint16_t sensor_id_reg_addr;
-	uint16_t sensor_id;
-};
-
-struct msm_sensor_reg_t {
-	enum msm_camera_i2c_data_type default_data_type;
-	struct msm_camera_i2c_reg_conf *start_stream_conf;
-	uint8_t start_stream_conf_size;
-	struct msm_camera_i2c_reg_conf *stop_stream_conf;
-	uint8_t stop_stream_conf_size;
-	struct msm_camera_i2c_reg_conf *group_hold_on_conf;
-	uint8_t group_hold_on_conf_size;
-	struct msm_camera_i2c_reg_conf *group_hold_off_conf;
-	uint8_t group_hold_off_conf_size;
-	struct msm_camera_i2c_conf_array *init_settings;
-	uint8_t init_size;
-	struct msm_camera_i2c_conf_array *mode_settings;
-	struct msm_camera_i2c_conf_array *no_effect_settings;
-	struct msm_sensor_output_info_t *output_settings;
-	uint8_t num_conf;
-};
-
-enum msm_sensor_device_type_t {
-	MSM_SENSOR_I2C_DEVICE,
-	MSM_SENSOR_PLATFORM_DEVICE,
-};
-
-struct v4l2_subdev_info {
-	enum v4l2_mbus_pixelcode code;
-	enum v4l2_colorspace colorspace;
-	uint16_t fmt;
-	uint16_t order;
-};
-
-struct msm_sensor_ctrl_t;
-
-struct msm_sensor_v4l2_ctrl_info_t {
-	uint32_t ctrl_id;
-	int16_t min;
-	int16_t max;
-	int16_t step;
-	struct msm_camera_i2c_enum_conf_array *enum_cfg_settings;
-	int (*s_v4l2_ctrl) (struct msm_sensor_ctrl_t *,
-		struct msm_sensor_v4l2_ctrl_info_t *, int);
-};
-
-struct msm_sensor_fn_t {
-	void (*sensor_start_stream) (struct msm_sensor_ctrl_t *);
-	void (*sensor_stop_stream) (struct msm_sensor_ctrl_t *);
-	void (*sensor_group_hold_on) (struct msm_sensor_ctrl_t *);
-	void (*sensor_group_hold_off) (struct msm_sensor_ctrl_t *);
-
-	int32_t (*sensor_set_fps) (struct msm_sensor_ctrl_t *,
-			struct fps_cfg *);
-	int32_t (*sensor_write_exp_gain) (struct msm_sensor_ctrl_t *,
-			uint16_t, uint32_t);
-	int32_t (*sensor_write_snapshot_exp_gain) (struct msm_sensor_ctrl_t *,
-			uint16_t, uint32_t);
-	int32_t (*sensor_setting) (struct msm_sensor_ctrl_t *,
-			int update_type, int rt);
-	int32_t (*sensor_csi_setting) (struct msm_sensor_ctrl_t *,
-			int update_type, int rt);
-	int32_t (*sensor_set_sensor_mode)
-			(struct msm_sensor_ctrl_t *, int, int);
-	int32_t (*sensor_mode_init) (struct msm_sensor_ctrl_t *,
-		int, struct sensor_init_cfg *);
-	int32_t (*sensor_get_output_info) (struct msm_sensor_ctrl_t *,
-		struct sensor_output_info_t *);
-	int (*sensor_config) (struct msm_sensor_ctrl_t *, void __user *);
-	int (*sensor_power_down)
-		(struct msm_sensor_ctrl_t *);
-	int (*sensor_power_up) (struct msm_sensor_ctrl_t *);
-	int32_t (*sensor_match_id)(struct msm_sensor_ctrl_t *s_ctrl);
-	void (*sensor_adjust_frame_lines) (struct msm_sensor_ctrl_t *s_ctrl);
-	int32_t (*sensor_get_csi_params)(struct msm_sensor_ctrl_t *,
-		struct csi_lane_params_t *);
-	int32_t (*sensor_read_eeprom)(struct msm_sensor_ctrl_t *);
-};
-
-struct msm_sensor_csi_info {
-	uint8_t is_csic;
-};
-
-enum msm_sensor_state {
-	MSM_SENSOR_POWER_UP,
-	MSM_SENSOR_POWER_DOWN,
-};
-
-struct msm_sensor_eeprom_data {
-	uint8_t *data;
-	uint32_t length;
-};
-
-struct msm_sensor_ctrl_t {
-	struct  msm_camera_sensor_info *sensordata;
-	struct i2c_client *msm_sensor_client;
-	struct i2c_driver *sensor_i2c_driver;
-	struct platform_device *pdev;
-	struct msm_camera_i2c_client *sensor_i2c_client;
-	uint16_t sensor_i2c_addr;
-	enum msm_camera_vreg_name_t *vreg_seq;
-	int num_vreg_seq;
-	struct msm_camera_power_seq_t *power_seq;
-	int num_power_seq;
-	enum msm_sensor_device_type_t sensor_device_type;
-
-	struct msm_sensor_output_reg_addr_t *sensor_output_reg_addr;
-	struct msm_sensor_id_info_t *sensor_id_info;
-	struct msm_sensor_exp_gain_info_t *sensor_exp_gain_info;
-	struct msm_sensor_reg_t *msm_sensor_reg;
-	struct msm_sensor_v4l2_ctrl_info_t *msm_sensor_v4l2_ctrl_info;
-	uint16_t num_v4l2_ctrl;
-	uint8_t is_csic;
-
-	uint16_t curr_line_length_pclk;
-	uint16_t curr_frame_length_lines;
-
-	uint32_t fps_divider;
-	enum msm_sensor_resolution_t curr_res;
-	enum msm_sensor_cam_mode_t cam_mode;
-
-	struct mutex *msm_sensor_mutex;
-
-	struct v4l2_subdev sensor_v4l2_subdev;
-	struct v4l2_subdev_info *sensor_v4l2_subdev_info;
-	uint8_t sensor_v4l2_subdev_info_size;
-	struct v4l2_subdev_ops *sensor_v4l2_subdev_ops;
-	struct msm_sensor_fn_t *func_tbl;
-	struct regulator **reg_ptr;
-	struct clk *cam_clk[2];
-	long clk_rate;
-	enum msm_sensor_state sensor_state;
-	/* Number of frames to delay after start / stop stream in Q10 format.
-	   Initialize to -1 for this value to be ignored */
-	int16_t wait_num_frames;
-	/* minimum delay after stop / stop stream in ms */
-	uint16_t min_delay;
-	/* delay (in ms) after power up sequence */
-	uint16_t power_seq_delay;
-	struct msm_sensor_eeprom_data eeprom_data;
-};
-
-struct msm_sensor_ctrl_t *get_sctrl(struct v4l2_subdev *sd);
-
-#endif
diff --git a/drivers/media/platform/msm/camera_v1/sensors/msm_sensor_init.c b/drivers/media/platform/msm/camera_v1/sensors/msm_sensor_init.c
deleted file mode 100644
index d759cf1..0000000
--- a/drivers/media/platform/msm/camera_v1/sensors/msm_sensor_init.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- *
- */
-
-#include "msm_sensor.h"
-#include "msm.h"
-#include "msm_sensor_bayer.h"
-#include "imx091.h"
-
-static struct i2c_driver *sensor_i2c_driver[] = {
-	/* back camera */
-	&imx091_i2c_driver,
-	/* front camera */
-};
-
-static int __init msm_sensor_init_module(void)
-{
-	int index = 0;
-	for (index = 0; index < ARRAY_SIZE(sensor_i2c_driver); index++)
-		i2c_add_driver(sensor_i2c_driver[index]);
-	return 0;
-}
-
-module_init(msm_sensor_init_module);
-MODULE_DESCRIPTION("Sensor driver probe");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/sensors/mt9e013_v4l2.c b/drivers/media/platform/msm/camera_v1/sensors/mt9e013_v4l2.c
deleted file mode 100644
index 289beba..0000000
--- a/drivers/media/platform/msm/camera_v1/sensors/mt9e013_v4l2.c
+++ /dev/null
@@ -1,496 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- *
- */
-
-#include "msm_sensor.h"
-#define SENSOR_NAME "mt9e013"
-#define PLATFORM_DRIVER_NAME "msm_camera_mt9e013"
-#define mt9e013_obj mt9e013_##obj
-
-DEFINE_MUTEX(mt9e013_mut);
-static struct msm_sensor_ctrl_t mt9e013_s_ctrl;
-
-static struct msm_camera_i2c_reg_conf mt9e013_groupon_settings[] = {
-	{0x0104, 0x01},
-};
-
-static struct msm_camera_i2c_reg_conf mt9e013_groupoff_settings[] = {
-	{0x0104, 0x00},
-};
-
-static struct msm_camera_i2c_reg_conf mt9e013_prev_settings[] = {
-	/*Output Size (1632x1224)*/
-	{0x0344, 0x0008},/*X_ADDR_START*/
-	{0x0348, 0x0CC9},/*X_ADDR_END*/
-	{0x0346, 0x0008},/*Y_ADDR_START*/
-	{0x034A, 0x0999},/*Y_ADDR_END*/
-	{0x034C, 0x0660},/*X_OUTPUT_SIZE*/
-	{0x034E, 0x04C8},/*Y_OUTPUT_SIZE*/
-	{0x306E, 0xFCB0},/*DATAPATH_SELECT*/
-	{0x3040, 0x04C3},/*READ_MODE*/
-	{0x3178, 0x0000},/*ANALOG_CONTROL5*/
-	{0x3ED0, 0x1E24},/*DAC_LD_4_5*/
-	{0x0400, 0x0002},/*SCALING_MODE*/
-	{0x0404, 0x0010},/*SCALE_M*/
-	/*Timing configuration*/
-	{0x0342, 0x1018},/*LINE_LENGTH_PCK*/
-	{0x0340, 0x055B},/*FRAME_LENGTH_LINES*/
-	{0x0202, 0x0557},/*COARSE_INTEGRATION_TIME*/
-	{0x3014, 0x0846},/*FINE_INTEGRATION_TIME_*/
-	{0x3010, 0x0130},/*FINE_CORRECTION*/
-};
-
-static struct msm_camera_i2c_reg_conf mt9e013_snap_settings[] = {
-	/*Output Size (3264x2448)*/
-	{0x0344, 0x0000},/*X_ADDR_START */
-	{0x0348, 0x0CCF},/*X_ADDR_END*/
-	{0x0346, 0x0000},/*Y_ADDR_START */
-	{0x034A, 0x099F},/*Y_ADDR_END*/
-	{0x034C, 0x0CD0},/*X_OUTPUT_SIZE*/
-	{0x034E, 0x09A0},/*Y_OUTPUT_SIZE*/
-	{0x306E, 0xFC80},/*DATAPATH_SELECT*/
-	{0x3040, 0x0041},/*READ_MODE*/
-	{0x3178, 0x0000},/*ANALOG_CONTROL5*/
-	{0x3ED0, 0x1E24},/*DAC_LD_4_5*/
-	{0x0400, 0x0000},/*SCALING_MODE*/
-	{0x0404, 0x0010},/*SCALE_M*/
-	/*Timing configuration*/
-	{0x0342, 0x13F8},/*LINE_LENGTH_PCK*/
-	{0x0340, 0x0A2F},/*FRAME_LENGTH_LINES*/
-	{0x0202, 0x0A1F},/*COARSE_INTEGRATION_TIME*/
-	{0x3014, 0x03F6},/*FINE_INTEGRATION_TIME_ */
-	{0x3010, 0x0078},/*FINE_CORRECTION*/
-};
-
-static struct msm_camera_i2c_reg_conf mt9e013_hfr60_settings[] = {
-	{0x0300, 0x0005},/*VT_PIX_CLK_DIV*/
-	{0x0302, 0x0001},/*VT_SYS_CLK_DIV*/
-	{0x0304, 0x0002},/*PRE_PLL_CLK_DIV*/
-	{0x0306, 0x0029},/*PLL_MULTIPLIER*/
-	{0x0308, 0x000A},/*OP_PIX_CLK_DIV*/
-	{0x030A, 0x0001},/*OP_SYS_CLK_DIV*/
-	{0x0344, 0x0008},/*X_ADDR_START*/
-	{0x0348, 0x0685},/*X_ADDR_END*/
-	{0x0346, 0x013a},/*Y_ADDR_START*/
-	{0x034A, 0x055B},/*Y_ADDR_END*/
-	{0x034C, 0x0340},/*X_OUTPUT_SIZE*/
-	{0x034E, 0x0212},/*Y_OUTPUT_SIZE*/
-	{0x306E, 0xFC80},/*DATAPATH_SELECT*/
-	{0x3040, 0x00C3},/*READ_MODE*/
-	{0x3178, 0x0000},/*ANALOG_CONTROL5*/
-	{0x3ED0, 0x1E24},/*DAC_LD_4_5*/
-	{0x0400, 0x0000},/*SCALING_MODE*/
-	{0x0404, 0x0010},/*SCALE_M*/
-	/*Timing configuration*/
-	{0x0342, 0x0970},/*LINE_LENGTH_PCK*/
-	{0x0340, 0x02A1},/*FRAME_LENGTH_LINES*/
-	{0x0202, 0x02A1},/*COARSE_INTEGRATION_TIME*/
-	{0x3014, 0x03F6},/*FINE_INTEGRATION_TIME_*/
-	{0x3010, 0x0078},/*FINE_CORRECTION*/
-};
-
-static struct msm_camera_i2c_reg_conf mt9e013_hfr90_settings[] = {
-	{0x0300, 0x0005},/*VT_PIX_CLK_DIV*/
-	{0x0302, 0x0001},/*VT_SYS_CLK_DIV*/
-	{0x0304, 0x0002},/*PRE_PLL_CLK_DIV*/
-	{0x0306, 0x003D},/*PLL_MULTIPLIER*/
-	{0x0308, 0x000A},/*OP_PIX_CLK_DIV*/
-	{0x030A, 0x0001},/*OP_SYS_CLK_DIV*/
-	{0x0344, 0x0008},/*X_ADDR_START*/
-	{0x0348, 0x0685},/*X_ADDR_END*/
-	{0x0346, 0x013a},/*Y_ADDR_START*/
-	{0x034A, 0x055B},/*Y_ADDR_END*/
-	{0x034C, 0x0340},/*X_OUTPUT_SIZE*/
-	{0x034E, 0x0212},/*Y_OUTPUT_SIZE*/
-	{0x306E, 0xFC80},/*DATAPATH_SELECT*/
-	{0x3040, 0x00C3},/*READ_MODE*/
-	{0x3178, 0x0000},/*ANALOG_CONTROL5*/
-	{0x3ED0, 0x1E24},/*DAC_LD_4_5*/
-	{0x0400, 0x0000},/*SCALING_MODE*/
-	{0x0404, 0x0010},/*SCALE_M*/
-	/*Timing configuration*/
-	{0x0342, 0x0970},/*LINE_LENGTH_PCK*/
-	{0x0340, 0x02A1},/*FRAME_LENGTH_LINES*/
-	{0x0202, 0x02A1},/*COARSE_INTEGRATION_TIME*/
-	{0x3014, 0x03F6},/*FINE_INTEGRATION_TIME_*/
-	{0x3010, 0x0078},/*FINE_CORRECTION*/
-};
-
-static struct msm_camera_i2c_reg_conf mt9e013_hfr120_settings[] = {
-	{0x0300, 0x0005},/*VT_PIX_CLK_DIV*/
-	{0x0302, 0x0001},/*VT_SYS_CLK_DIV*/
-	{0x0304, 0x0002},/*PRE_PLL_CLK_DIV*/
-	{0x0306, 0x0052},/*PLL_MULTIPLIER*/
-	{0x0308, 0x000A},/*OP_PIX_CLK_DIV*/
-	{0x030A, 0x0001},/*OP_SYS_CLK_DIV*/
-	{0x0344, 0x0008},/*X_ADDR_START*/
-	{0x0348, 0x0685},/*X_ADDR_END*/
-	{0x0346, 0x013a},/*Y_ADDR_START*/
-	{0x034A, 0x055B},/*Y_ADDR_END*/
-	{0x034C, 0x0340},/*X_OUTPUT_SIZE*/
-	{0x034E, 0x0212},/*Y_OUTPUT_SIZE*/
-	{0x306E, 0xFC80},/*DATAPATH_SELECT*/
-	{0x3040, 0x00C3},/*READ_MODE*/
-	{0x3178, 0x0000},/*ANALOG_CONTROL5*/
-	{0x3ED0, 0x1E24},/*DAC_LD_4_5*/
-	{0x0400, 0x0000},/*SCALING_MODE*/
-	{0x0404, 0x0010},/*SCALE_M*/
-	/*Timing configuration*/
-	{0x0342, 0x0970},/*LINE_LENGTH_PCK*/
-	{0x0340, 0x02A1},/*FRAME_LENGTH_LINES*/
-	{0x0202, 0x02A1},/*COARSE_INTEGRATION_TIME*/
-	{0x3014, 0x03F6},/*FINE_INTEGRATION_TIME_*/
-	{0x3010, 0x0078},/*FINE_CORRECTION*/
-};
-
-static struct msm_camera_i2c_reg_conf mt9e013_recommend_settings[] = {
-	/*Disable embedded data*/
-	{0x3064, 0x7800},/*SMIA_TEST*/
-	/*configure 2-lane MIPI*/
-	{0x31AE, 0x0202},/*SERIAL_FORMAT*/
-	{0x31B8, 0x0E3F},/*MIPI_TIMING_2*/
-	/*set data to RAW10 format*/
-	{0x0112, 0x0A0A},/*CCP_DATA_FORMAT*/
-	{0x30F0, 0x800D},/*VCM CONTROL*/
-
-	{0x3044, 0x0590},
-	{0x306E, 0xFC80},
-	{0x30B2, 0xC000},
-	{0x30D6, 0x0800},
-	{0x316C, 0xB42F},
-	{0x316E, 0x869A},
-	{0x3170, 0x210E},
-	{0x317A, 0x010E},
-	{0x31E0, 0x1FB9},
-	{0x31E6, 0x07FC},
-	{0x37C0, 0x0000},
-	{0x37C2, 0x0000},
-	{0x37C4, 0x0000},
-	{0x37C6, 0x0000},
-	{0x3E00, 0x0011},
-	{0x3E02, 0x8801},
-	{0x3E04, 0x2801},
-	{0x3E06, 0x8449},
-	{0x3E08, 0x6841},
-	{0x3E0A, 0x400C},
-	{0x3E0C, 0x1001},
-	{0x3E0E, 0x2603},
-	{0x3E10, 0x4B41},
-	{0x3E12, 0x4B24},
-	{0x3E14, 0xA3CF},
-	{0x3E16, 0x8802},
-	{0x3E18, 0x8401},
-	{0x3E1A, 0x8601},
-	{0x3E1C, 0x8401},
-	{0x3E1E, 0x840A},
-	{0x3E20, 0xFF00},
-	{0x3E22, 0x8401},
-	{0x3E24, 0x00FF},
-	{0x3E26, 0x0088},
-	{0x3E28, 0x2E8A},
-	{0x3E30, 0x0000},
-	{0x3E32, 0x8801},
-	{0x3E34, 0x4029},
-	{0x3E36, 0x00FF},
-	{0x3E38, 0x8469},
-	{0x3E3A, 0x00FF},
-	{0x3E3C, 0x2801},
-	{0x3E3E, 0x3E2A},
-	{0x3E40, 0x1C01},
-	{0x3E42, 0xFF84},
-	{0x3E44, 0x8401},
-	{0x3E46, 0x0C01},
-	{0x3E48, 0x8401},
-	{0x3E4A, 0x00FF},
-	{0x3E4C, 0x8402},
-	{0x3E4E, 0x8984},
-	{0x3E50, 0x6628},
-	{0x3E52, 0x8340},
-	{0x3E54, 0x00FF},
-	{0x3E56, 0x4A42},
-	{0x3E58, 0x2703},
-	{0x3E5A, 0x6752},
-	{0x3E5C, 0x3F2A},
-	{0x3E5E, 0x846A},
-	{0x3E60, 0x4C01},
-	{0x3E62, 0x8401},
-	{0x3E66, 0x3901},
-	{0x3E90, 0x2C01},
-	{0x3E98, 0x2B02},
-	{0x3E92, 0x2A04},
-	{0x3E94, 0x2509},
-	{0x3E96, 0x0000},
-	{0x3E9A, 0x2905},
-	{0x3E9C, 0x00FF},
-	{0x3ECC, 0x00EB},
-	{0x3ED0, 0x1E24},
-	{0x3ED4, 0xAFC4},
-	{0x3ED6, 0x909B},
-	{0x3EE0, 0x2424},
-	{0x3EE2, 0x9797},
-	{0x3EE4, 0xC100},
-	{0x3EE6, 0x0540},
-	{0x3174, 0x8000},
-	/* PLL settings */
-	{0x0300, 0x0004},/*VT_PIX_CLK_DIV*/
-	{0x0302, 0x0001},/*VT_SYS_CLK_DIV*/
-	{0x0304, 0x0002},/*PRE_PLL_CLK_DIV*/
-	{0x0306, 0x003A},/*PLL_MULTIPLIER*/
-	{0x0308, 0x000A},/*OP_PIX_CLK_DIV*/
-	{0x030A, 0x0001},/*OP_SYS_CLK_DIV*/
-};
-
-static struct v4l2_subdev_info mt9e013_subdev_info[] = {
-	{
-	.code   = V4L2_MBUS_FMT_SBGGR10_1X10,
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	.fmt    = 1,
-	.order    = 0,
-	},
-	/* more can be supported, to be added later */
-};
-
-static struct msm_camera_i2c_conf_array mt9e013_init_conf[] = {
-	{&mt9e013_recommend_settings[0],
-	ARRAY_SIZE(mt9e013_recommend_settings), 0, MSM_CAMERA_I2C_WORD_DATA}
-};
-
-static struct msm_camera_i2c_conf_array mt9e013_confs[] = {
-	{&mt9e013_snap_settings[0],
-	ARRAY_SIZE(mt9e013_snap_settings), 0, MSM_CAMERA_I2C_WORD_DATA},
-	{&mt9e013_prev_settings[0],
-	ARRAY_SIZE(mt9e013_prev_settings), 0, MSM_CAMERA_I2C_WORD_DATA},
-	{&mt9e013_hfr60_settings[0],
-	ARRAY_SIZE(mt9e013_hfr60_settings), 0, MSM_CAMERA_I2C_WORD_DATA},
-	{&mt9e013_hfr90_settings[0],
-	ARRAY_SIZE(mt9e013_hfr90_settings), 0, MSM_CAMERA_I2C_WORD_DATA},
-	{&mt9e013_hfr120_settings[0],
-	ARRAY_SIZE(mt9e013_hfr120_settings), 0, MSM_CAMERA_I2C_WORD_DATA},
-};
-
-static struct msm_sensor_output_info_t mt9e013_dimensions[] = {
-	{
-		.x_output = 0xCD0,
-		.y_output = 0x9A0,
-		.line_length_pclk = 0x13F8,
-		.frame_length_lines = 0xA2F,
-		.vt_pixel_clk = 174000000,
-		.op_pixel_clk = 174000000,
-		.binning_factor = 1,
-	},
-	{
-		.x_output = 0x660,
-		.y_output = 0x4C8,
-		.line_length_pclk = 0x1018,
-		.frame_length_lines = 0x55B,
-		.vt_pixel_clk = 174000000,
-		.op_pixel_clk = 174000000,
-		.binning_factor = 1,
-	},
-	{
-		.x_output = 0x340,
-		.y_output = 0x212,
-		.line_length_pclk = 0x970,
-		.frame_length_lines = 0x2A1,
-		.vt_pixel_clk = 98400000,
-		.op_pixel_clk = 98400000,
-		.binning_factor = 1,
-	},
-	{
-		.x_output = 0x340,
-		.y_output = 0x212,
-		.line_length_pclk = 0x970,
-		.frame_length_lines = 0x2A1,
-		.vt_pixel_clk = 146400000,
-		.op_pixel_clk = 146400000,
-		.binning_factor = 1,
-	},
-	{
-		.x_output = 0x340,
-		.y_output = 0x212,
-		.line_length_pclk = 0x970,
-		.frame_length_lines = 0x2A1,
-		.vt_pixel_clk = 196800000,
-		.op_pixel_clk = 196800000,
-		.binning_factor = 1,
-	},
-};
-
-static struct msm_sensor_output_reg_addr_t mt9e013_reg_addr = {
-	.x_output = 0x34C,
-	.y_output = 0x34E,
-	.line_length_pclk = 0x342,
-	.frame_length_lines = 0x340,
-};
-
-static struct msm_sensor_id_info_t mt9e013_id_info = {
-	.sensor_id_reg_addr = 0x0,
-	.sensor_id = 0x4B00,
-};
-
-static struct msm_sensor_exp_gain_info_t mt9e013_exp_gain_info = {
-	.coarse_int_time_addr = 0x202,
-	.global_gain_addr = 0x305E,
-	.vert_offset = 0,
-};
-
-static int32_t mt9e013_write_exp_gain(struct msm_sensor_ctrl_t *s_ctrl,
-		uint16_t gain, uint32_t line)
-{
-	uint32_t fl_lines;
-	fl_lines =
-		(s_ctrl->curr_frame_length_lines * s_ctrl->fps_divider) / Q10;
-
-	s_ctrl->func_tbl->sensor_group_hold_on(s_ctrl);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->global_gain_addr, gain | 0x1000,
-		MSM_CAMERA_I2C_WORD_DATA);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->coarse_int_time_addr, line,
-		MSM_CAMERA_I2C_WORD_DATA);
-	s_ctrl->func_tbl->sensor_group_hold_off(s_ctrl);
-	return 0;
-}
-
-static int32_t mt9e013_write_exp_snapshot_gain(struct msm_sensor_ctrl_t *s_ctrl,
-		uint16_t gain, uint32_t line)
-{
-	uint32_t fl_lines;
-	fl_lines =
-		(s_ctrl->curr_frame_length_lines * s_ctrl->fps_divider) / Q10;
-
-	s_ctrl->func_tbl->sensor_group_hold_on(s_ctrl);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->global_gain_addr, gain | 0x1000,
-		MSM_CAMERA_I2C_WORD_DATA);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->coarse_int_time_addr, line,
-		MSM_CAMERA_I2C_WORD_DATA);
-	s_ctrl->func_tbl->sensor_group_hold_off(s_ctrl);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		0x301A, (0x065C|0x2), MSM_CAMERA_I2C_WORD_DATA);
-
-	return 0;
-}
-static void mt9e013_start_stream(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		0x301A, 0x8250, MSM_CAMERA_I2C_WORD_DATA);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		0x301A, 0x8650, MSM_CAMERA_I2C_WORD_DATA);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		0x301A, 0x8658, MSM_CAMERA_I2C_WORD_DATA);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		0x0104, 0x00, MSM_CAMERA_I2C_BYTE_DATA);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		0x301A, 0x065C, MSM_CAMERA_I2C_WORD_DATA);
-}
-
-static void mt9e013_stop_stream(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		0x301A, 0x0058, MSM_CAMERA_I2C_WORD_DATA);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		0x301A, 0x0050, MSM_CAMERA_I2C_WORD_DATA);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		0x0104, 0x01, MSM_CAMERA_I2C_BYTE_DATA);
-}
-
-static const struct i2c_device_id mt9e013_i2c_id[] = {
-	{SENSOR_NAME, (kernel_ulong_t)&mt9e013_s_ctrl},
-	{ }
-};
-
-static struct i2c_driver mt9e013_i2c_driver = {
-	.id_table = mt9e013_i2c_id,
-	.probe  = msm_sensor_i2c_probe,
-	.driver = {
-		.name = SENSOR_NAME,
-	},
-};
-
-static struct msm_camera_i2c_client mt9e013_sensor_i2c_client = {
-	.addr_type = MSM_CAMERA_I2C_WORD_ADDR,
-};
-
-static int __init msm_sensor_init_module(void)
-{
-	return i2c_add_driver(&mt9e013_i2c_driver);
-}
-
-static struct v4l2_subdev_core_ops mt9e013_subdev_core_ops = {
-	.ioctl = msm_sensor_subdev_ioctl,
-	.s_power = msm_sensor_power,
-};
-
-static struct v4l2_subdev_video_ops mt9e013_subdev_video_ops = {
-	.enum_mbus_fmt = msm_sensor_v4l2_enum_fmt,
-};
-
-static struct v4l2_subdev_ops mt9e013_subdev_ops = {
-	.core = &mt9e013_subdev_core_ops,
-	.video  = &mt9e013_subdev_video_ops,
-};
-
-static struct msm_sensor_fn_t mt9e013_func_tbl = {
-	.sensor_start_stream = mt9e013_start_stream,
-	.sensor_stop_stream = mt9e013_stop_stream,
-	.sensor_group_hold_on = msm_sensor_group_hold_on,
-	.sensor_group_hold_off = msm_sensor_group_hold_off,
-	.sensor_set_fps = msm_sensor_set_fps,
-	.sensor_write_exp_gain = mt9e013_write_exp_gain,
-	.sensor_write_snapshot_exp_gain = mt9e013_write_exp_snapshot_gain,
-	.sensor_csi_setting = msm_sensor_setting1,
-	.sensor_set_sensor_mode = msm_sensor_set_sensor_mode,
-	.sensor_mode_init = msm_sensor_mode_init,
-	.sensor_get_output_info = msm_sensor_get_output_info,
-	.sensor_config = msm_sensor_config,
-	.sensor_power_up = msm_sensor_power_up,
-	.sensor_power_down = msm_sensor_power_down,
-};
-
-static struct msm_sensor_reg_t mt9e013_regs = {
-	.default_data_type = MSM_CAMERA_I2C_BYTE_DATA,
-	.group_hold_on_conf = mt9e013_groupon_settings,
-	.group_hold_on_conf_size = ARRAY_SIZE(mt9e013_groupon_settings),
-	.group_hold_off_conf = mt9e013_groupoff_settings,
-	.group_hold_off_conf_size =
-		ARRAY_SIZE(mt9e013_groupoff_settings),
-	.init_settings = &mt9e013_init_conf[0],
-	.init_size = ARRAY_SIZE(mt9e013_init_conf),
-	.mode_settings = &mt9e013_confs[0],
-	.output_settings = &mt9e013_dimensions[0],
-	.num_conf = ARRAY_SIZE(mt9e013_confs),
-};
-
-static struct msm_sensor_ctrl_t mt9e013_s_ctrl = {
-	.msm_sensor_reg = &mt9e013_regs,
-	.sensor_i2c_client = &mt9e013_sensor_i2c_client,
-	.sensor_i2c_addr = 0x6C,
-	.sensor_output_reg_addr = &mt9e013_reg_addr,
-	.sensor_id_info = &mt9e013_id_info,
-	.sensor_exp_gain_info = &mt9e013_exp_gain_info,
-	.cam_mode = MSM_SENSOR_MODE_INVALID,
-	.msm_sensor_mutex = &mt9e013_mut,
-	.sensor_i2c_driver = &mt9e013_i2c_driver,
-	.sensor_v4l2_subdev_info = mt9e013_subdev_info,
-	.sensor_v4l2_subdev_info_size = ARRAY_SIZE(mt9e013_subdev_info),
-	.sensor_v4l2_subdev_ops = &mt9e013_subdev_ops,
-	.func_tbl = &mt9e013_func_tbl,
-	.clk_rate = MSM_SENSOR_MCLK_24HZ,
-};
-
-module_init(msm_sensor_init_module);
-MODULE_DESCRIPTION("Aptina 8MP Bayer sensor driver");
-MODULE_LICENSE("GPL v2");
-
-
diff --git a/drivers/media/platform/msm/camera_v1/sensors/mt9m114_v4l2.c b/drivers/media/platform/msm/camera_v1/sensors/mt9m114_v4l2.c
deleted file mode 100644
index c952f7b..0000000
--- a/drivers/media/platform/msm/camera_v1/sensors/mt9m114_v4l2.c
+++ /dev/null
@@ -1,1332 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- *
- */
-
-#include "msm_sensor.h"
-#define SENSOR_NAME "mt9m114"
-#define PLATFORM_DRIVER_NAME "msm_camera_mt9m114"
-#define mt9m114_obj mt9m114_##obj
-
-/* Sysctl registers */
-#define MT9M114_COMMAND_REGISTER                0x0080
-#define MT9M114_COMMAND_REGISTER_APPLY_PATCH    (1 << 0)
-#define MT9M114_COMMAND_REGISTER_SET_STATE      (1 << 1)
-#define MT9M114_COMMAND_REGISTER_REFRESH        (1 << 2)
-#define MT9M114_COMMAND_REGISTER_WAIT_FOR_EVENT (1 << 3)
-#define MT9M114_COMMAND_REGISTER_OK             (1 << 15)
-
-DEFINE_MUTEX(mt9m114_mut);
-static struct msm_sensor_ctrl_t mt9m114_s_ctrl;
-
-static struct msm_camera_i2c_reg_conf mt9m114_720p_settings[] = {
-	{0xdc00, 0x50, MSM_CAMERA_I2C_BYTE_DATA, MSM_CAMERA_I2C_CMD_WRITE},
-	{MT9M114_COMMAND_REGISTER, MT9M114_COMMAND_REGISTER_SET_STATE,
-		MSM_CAMERA_I2C_UNSET_WORD_MASK, MSM_CAMERA_I2C_CMD_POLL},
-	{MT9M114_COMMAND_REGISTER, (MT9M114_COMMAND_REGISTER_OK |
-		MT9M114_COMMAND_REGISTER_SET_STATE), MSM_CAMERA_I2C_WORD_DATA,
-		MSM_CAMERA_I2C_CMD_WRITE},
-	{MT9M114_COMMAND_REGISTER, MT9M114_COMMAND_REGISTER_SET_STATE,
-		MSM_CAMERA_I2C_UNSET_WORD_MASK, MSM_CAMERA_I2C_CMD_POLL},
-	{0xDC01, 0x52, MSM_CAMERA_I2C_BYTE_DATA, MSM_CAMERA_I2C_CMD_POLL},
-
-	{0x098E, 0, MSM_CAMERA_I2C_BYTE_DATA},
-	{0xC800, 0x007C,},/*y_addr_start = 124*/
-	{0xC802, 0x0004,},/*x_addr_start = 4*/
-	{0xC804, 0x0353,},/*y_addr_end = 851*/
-	{0xC806, 0x050B,},/*x_addr_end = 1291*/
-	{0xC808, 0x02DC,},/*pixclk = 48000000*/
-	{0xC80A, 0x6C00,},/*pixclk = 48000000*/
-	{0xC80C, 0x0001,},/*row_speed = 1*/
-	{0xC80E, 0x00DB,},/*fine_integ_time_min = 219*/
-	{0xC810, 0x05BD,},/*fine_integ_time_max = 1469*/
-	{0xC812, 0x03E8,},/*frame_length_lines = 1000*/
-	{0xC814, 0x0640,},/*line_length_pck = 1600*/
-	{0xC816, 0x0060,},/*fine_correction = 96*/
-	{0xC818, 0x02D3,},/*cpipe_last_row = 723*/
-	{0xC826, 0x0020,},/*reg_0_data = 32*/
-	{0xC834, 0x0000,},/*sensor_control_read_mode = 0*/
-	{0xC854, 0x0000,},/*crop_window_xoffset = 0*/
-	{0xC856, 0x0000,},/*crop_window_yoffset = 0*/
-	{0xC858, 0x0500,},/*crop_window_width = 1280*/
-	{0xC85A, 0x02D0,},/*crop_window_height = 720*/
-	{0xC85C, 0x03, MSM_CAMERA_I2C_BYTE_DATA},  /*crop_cropmode = 3*/
-	{0xC868, 0x0500,},/*output_width = 1280*/
-	{0xC86A, 0x02D0,},/*output_height = 720*/
-	{0xC878, 0x00, MSM_CAMERA_I2C_BYTE_DATA},  /*aet_aemode = 0*/
-	{0xC88C, 0x1E00,},/*aet_max_frame_rate = 7680*/
-	{0xC88E, 0x1E00,},/*aet_min_frame_rate = 7680*/
-	{0xC914, 0x0000,},/*stat_awb_window_xstart = 0*/
-	{0xC916, 0x0000,},/*stat_awb_window_ystart = 0*/
-	{0xC918, 0x04FF,},/*stat_awb_window_xend = 1279*/
-	{0xC91A, 0x02CF,},/*stat_awb_window_yend = 719*/
-	{0xC91C, 0x0000,},/*stat_ae_window_xstart = 0*/
-	{0xC91E, 0x0000,},/*stat_ae_window_ystart = 0*/
-	{0xC920, 0x00FF,},/*stat_ae_window_xend = 255*/
-	{0xC922, 0x008F,},/*stat_ae_window_yend = 143*/
-};
-
-static struct msm_camera_i2c_reg_conf mt9m114_recommend_settings[] = {
-	{0x301A, 0x0200, MSM_CAMERA_I2C_SET_WORD_MASK},
-	{0x098E, 0, MSM_CAMERA_I2C_BYTE_DATA},
-	/*cam_sysctl_pll_enable = 1*/
-	{0xC97E, 0x01, MSM_CAMERA_I2C_BYTE_DATA},
-	/*cam_sysctl_pll_divider_m_n = 288*/
-	{0xC980, 0x0120,},
-	/*cam_sysctl_pll_divider_p = 1792*/
-	{0xC982, 0x0700,},
-	/*output_control = 32769*/
-	{0xC984, 0x8001,},
-	/*mipi_timing_t_hs_zero = 3840*/
-	{0xC988, 0x0F00,},
-	/*mipi_timing_t_hs_exit_hs_trail = 2823*/
-	{0xC98A, 0x0B07,},
-	/*mipi_timing_t_clk_post_clk_pre = 3329*/
-	{0xC98C, 0x0D01,},
-	/*mipi_timing_t_clk_trail_clk_zero = 1821*/
-	{0xC98E, 0x071D,},
-	/*mipi_timing_t_lpx = 6*/
-	{0xC990, 0x0006,},
-	/*mipi_timing_init_timing = 2572*/
-	{0xC992, 0x0A0C,},
-	{0xC800, 0x007C,},/*y_addr_start = 124*/
-	{0xC802, 0x0004,},/*x_addr_start = 4*/
-	{0xC804, 0x0353,},/*y_addr_end = 851*/
-	{0xC806, 0x050B,},/*x_addr_end = 1291*/
-	{0xC808, 0x02DC,},/*pixclk = 48000000*/
-	{0xC80A, 0x6C00,},/*pixclk = 48000000*/
-	{0xC80C, 0x0001,},/*row_speed = 1*/
-	{0xC80E, 0x00DB,},/*fine_integ_time_min = 219*/
-	{0xC810, 0x05BD,},/*fine_integ_time_max = 1469*/
-	{0xC812, 0x03E8,},/*frame_length_lines = 1000*/
-	{0xC814, 0x0640,},/*line_length_pck = 1600*/
-	{0xC816, 0x0060,},/*fine_correction = 96*/
-	{0xC818, 0x02D3,},/*cpipe_last_row = 723*/
-	{0xC826, 0x0020,},/*reg_0_data = 32*/
-	{0xC834, 0x0000,},/*sensor_control_read_mode = 0*/
-	{0xC854, 0x0000,},/*crop_window_xoffset = 0*/
-	{0xC856, 0x0000,},/*crop_window_yoffset = 0*/
-	{0xC858, 0x0500,},/*crop_window_width = 1280*/
-	{0xC85A, 0x02D0,},/*crop_window_height = 720*/
-	{0xC85C, 0x03, MSM_CAMERA_I2C_BYTE_DATA},  /*crop_cropmode = 3*/
-	{0xC868, 0x0500,},/*output_width = 1280*/
-	{0xC86A, 0x02D0,},/*output_height = 720*/
-	{0xC878, 0x00, MSM_CAMERA_I2C_BYTE_DATA},  /*aet_aemode = 0*/
-	{0xC88C, 0x1E00,},/*aet_max_frame_rate = 7680*/
-	{0xC88E, 0x1E00,},/*aet_min_frame_rate = 7680*/
-	{0xC914, 0x0000,},/*stat_awb_window_xstart = 0*/
-	{0xC916, 0x0000,},/*stat_awb_window_ystart = 0*/
-	{0xC918, 0x04FF,},/*stat_awb_window_xend = 1279*/
-	{0xC91A, 0x02CF,},/*stat_awb_window_yend = 719*/
-	{0xC91C, 0x0000,},/*stat_ae_window_xstart = 0*/
-	{0xC91E, 0x0000,},/*stat_ae_window_ystart = 0*/
-	{0xC920, 0x00FF,},/*stat_ae_window_xend = 255*/
-	{0xC922, 0x008F,},/*stat_ae_window_yend = 143*/
-
-	/*Sensor optimization*/
-	{0x316A, 0x8270,},
-	{0x316C, 0x8270,},
-	{0x3ED0, 0x2305,},
-	{0x3ED2, 0x77CF,},
-	{0x316E, 0x8202,},
-	{0x3180, 0x87FF,},
-	{0x30D4, 0x6080,},
-	{0xA802, 0x0008,},/*AE_TRACK_MODE*/
-	{0x3E14, 0xFF39,},
-	{0x0982, 0x0001,},/*ACCESS_CTL_STAT*/
-	{0x098A, 0x5000,},/*PHYSICAL_ADDRESS_ACCESS*/
-	{0xD000, 0x70CF,},
-	{0xD002, 0xFFFF,},
-	{0xD004, 0xC5D4,},
-	{0xD006, 0x903A,},
-	{0xD008, 0x2144,},
-	{0xD00A, 0x0C00,},
-	{0xD00C, 0x2186,},
-	{0xD00E, 0x0FF3,},
-	{0xD010, 0xB844,},
-	{0xD012, 0xB948,},
-	{0xD014, 0xE082,},
-	{0xD016, 0x20CC,},
-	{0xD018, 0x80E2,},
-	{0xD01A, 0x21CC,},
-	{0xD01C, 0x80A2,},
-	{0xD01E, 0x21CC,},
-	{0xD020, 0x80E2,},
-	{0xD022, 0xF404,},
-	{0xD024, 0xD801,},
-	{0xD026, 0xF003,},
-	{0xD028, 0xD800,},
-	{0xD02A, 0x7EE0,},
-	{0xD02C, 0xC0F1,},
-	{0xD02E, 0x08BA,},
-	{0xD030, 0x0600,},
-	{0xD032, 0xC1A1,},
-	{0xD034, 0x76CF,},
-	{0xD036, 0xFFFF,},
-	{0xD038, 0xC130,},
-	{0xD03A, 0x6E04,},
-	{0xD03C, 0xC040,},
-	{0xD03E, 0x71CF,},
-	{0xD040, 0xFFFF,},
-	{0xD042, 0xC790,},
-	{0xD044, 0x8103,},
-	{0xD046, 0x77CF,},
-	{0xD048, 0xFFFF,},
-	{0xD04A, 0xC7C0,},
-	{0xD04C, 0xE001,},
-	{0xD04E, 0xA103,},
-	{0xD050, 0xD800,},
-	{0xD052, 0x0C6A,},
-	{0xD054, 0x04E0,},
-	{0xD056, 0xB89E,},
-	{0xD058, 0x7508,},
-	{0xD05A, 0x8E1C,},
-	{0xD05C, 0x0809,},
-	{0xD05E, 0x0191,},
-	{0xD060, 0xD801,},
-	{0xD062, 0xAE1D,},
-	{0xD064, 0xE580,},
-	{0xD066, 0x20CA,},
-	{0xD068, 0x0022,},
-	{0xD06A, 0x20CF,},
-	{0xD06C, 0x0522,},
-	{0xD06E, 0x0C5C,},
-	{0xD070, 0x04E2,},
-	{0xD072, 0x21CA,},
-	{0xD074, 0x0062,},
-	{0xD076, 0xE580,},
-	{0xD078, 0xD901,},
-	{0xD07A, 0x79C0,},
-	{0xD07C, 0xD800,},
-	{0xD07E, 0x0BE6,},
-	{0xD080, 0x04E0,},
-	{0xD082, 0xB89E,},
-	{0xD084, 0x70CF,},
-	{0xD086, 0xFFFF,},
-	{0xD088, 0xC8D4,},
-	{0xD08A, 0x9002,},
-	{0xD08C, 0x0857,},
-	{0xD08E, 0x025E,},
-	{0xD090, 0xFFDC,},
-	{0xD092, 0xE080,},
-	{0xD094, 0x25CC,},
-	{0xD096, 0x9022,},
-	{0xD098, 0xF225,},
-	{0xD09A, 0x1700,},
-	{0xD09C, 0x108A,},
-	{0xD09E, 0x73CF,},
-	{0xD0A0, 0xFF00,},
-	{0xD0A2, 0x3174,},
-	{0xD0A4, 0x9307,},
-	{0xD0A6, 0x2A04,},
-	{0xD0A8, 0x103E,},
-	{0xD0AA, 0x9328,},
-	{0xD0AC, 0x2942,},
-	{0xD0AE, 0x7140,},
-	{0xD0B0, 0x2A04,},
-	{0xD0B2, 0x107E,},
-	{0xD0B4, 0x9349,},
-	{0xD0B6, 0x2942,},
-	{0xD0B8, 0x7141,},
-	{0xD0BA, 0x2A04,},
-	{0xD0BC, 0x10BE,},
-	{0xD0BE, 0x934A,},
-	{0xD0C0, 0x2942,},
-	{0xD0C2, 0x714B,},
-	{0xD0C4, 0x2A04,},
-	{0xD0C6, 0x10BE,},
-	{0xD0C8, 0x130C,},
-	{0xD0CA, 0x010A,},
-	{0xD0CC, 0x2942,},
-	{0xD0CE, 0x7142,},
-	{0xD0D0, 0x2250,},
-	{0xD0D2, 0x13CA,},
-	{0xD0D4, 0x1B0C,},
-	{0xD0D6, 0x0284,},
-	{0xD0D8, 0xB307,},
-	{0xD0DA, 0xB328,},
-	{0xD0DC, 0x1B12,},
-	{0xD0DE, 0x02C4,},
-	{0xD0E0, 0xB34A,},
-	{0xD0E2, 0xED88,},
-	{0xD0E4, 0x71CF,},
-	{0xD0E6, 0xFF00,},
-	{0xD0E8, 0x3174,},
-	{0xD0EA, 0x9106,},
-	{0xD0EC, 0xB88F,},
-	{0xD0EE, 0xB106,},
-	{0xD0F0, 0x210A,},
-	{0xD0F2, 0x8340,},
-	{0xD0F4, 0xC000,},
-	{0xD0F6, 0x21CA,},
-	{0xD0F8, 0x0062,},
-	{0xD0FA, 0x20F0,},
-	{0xD0FC, 0x0040,},
-	{0xD0FE, 0x0B02,},
-	{0xD100, 0x0320,},
-	{0xD102, 0xD901,},
-	{0xD104, 0x07F1,},
-	{0xD106, 0x05E0,},
-	{0xD108, 0xC0A1,},
-	{0xD10A, 0x78E0,},
-	{0xD10C, 0xC0F1,},
-	{0xD10E, 0x71CF,},
-	{0xD110, 0xFFFF,},
-	{0xD112, 0xC7C0,},
-	{0xD114, 0xD840,},
-	{0xD116, 0xA900,},
-	{0xD118, 0x71CF,},
-	{0xD11A, 0xFFFF,},
-	{0xD11C, 0xD02C,},
-	{0xD11E, 0xD81E,},
-	{0xD120, 0x0A5A,},
-	{0xD122, 0x04E0,},
-	{0xD124, 0xDA00,},
-	{0xD126, 0xD800,},
-	{0xD128, 0xC0D1,},
-	{0xD12A, 0x7EE0,},
-	{0x098E, 0x0000,},
-
-	{0x0982, 0x0001,},
-	{0x098A, 0x5C10,},
-	{0xDC10, 0xC0F1,},
-	{0xDC12, 0x0CDA,},
-	{0xDC14, 0x0580,},
-	{0xDC16, 0x76CF,},
-	{0xDC18, 0xFF00,},
-	{0xDC1A, 0x2184,},
-	{0xDC1C, 0x9624,},
-	{0xDC1E, 0x218C,},
-	{0xDC20, 0x8FC3,},
-	{0xDC22, 0x75CF,},
-	{0xDC24, 0xFFFF,},
-	{0xDC26, 0xE058,},
-	{0xDC28, 0xF686,},
-	{0xDC2A, 0x1550,},
-	{0xDC2C, 0x1080,},
-	{0xDC2E, 0xE001,},
-	{0xDC30, 0x1D50,},
-	{0xDC32, 0x1002,},
-	{0xDC34, 0x1552,},
-	{0xDC36, 0x1100,},
-	{0xDC38, 0x6038,},
-	{0xDC3A, 0x1D52,},
-	{0xDC3C, 0x1004,},
-	{0xDC3E, 0x1540,},
-	{0xDC40, 0x1080,},
-	{0xDC42, 0x081B,},
-	{0xDC44, 0x00D1,},
-	{0xDC46, 0x8512,},
-	{0xDC48, 0x1000,},
-	{0xDC4A, 0x00C0,},
-	{0xDC4C, 0x7822,},
-	{0xDC4E, 0x2089,},
-	{0xDC50, 0x0FC1,},
-	{0xDC52, 0x2008,},
-	{0xDC54, 0x0F81,},
-	{0xDC56, 0xFFFF,},
-	{0xDC58, 0xFF80,},
-	{0xDC5A, 0x8512,},
-	{0xDC5C, 0x1801,},
-	{0xDC5E, 0x0052,},
-	{0xDC60, 0xA512,},
-	{0xDC62, 0x1544,},
-	{0xDC64, 0x1080,},
-	{0xDC66, 0xB861,},
-	{0xDC68, 0x262F,},
-	{0xDC6A, 0xF007,},
-	{0xDC6C, 0x1D44,},
-	{0xDC6E, 0x1002,},
-	{0xDC70, 0x20CA,},
-	{0xDC72, 0x0021,},
-	{0xDC74, 0x20CF,},
-	{0xDC76, 0x04E1,},
-	{0xDC78, 0x0850,},
-	{0xDC7A, 0x04A1,},
-	{0xDC7C, 0x21CA,},
-	{0xDC7E, 0x0021,},
-	{0xDC80, 0x1542,},
-	{0xDC82, 0x1140,},
-	{0xDC84, 0x8D2C,},
-	{0xDC86, 0x6038,},
-	{0xDC88, 0x1D42,},
-	{0xDC8A, 0x1004,},
-	{0xDC8C, 0x1542,},
-	{0xDC8E, 0x1140,},
-	{0xDC90, 0xB601,},
-	{0xDC92, 0x046D,},
-	{0xDC94, 0x0580,},
-	{0xDC96, 0x78E0,},
-	{0xDC98, 0xD800,},
-	{0xDC9A, 0xB893,},
-	{0xDC9C, 0x002D,},
-	{0xDC9E, 0x04A0,},
-	{0xDCA0, 0xD900,},
-	{0xDCA2, 0x78E0,},
-	{0xDCA4, 0x72CF,},
-	{0xDCA6, 0xFFFF,},
-	{0xDCA8, 0xE058,},
-	{0xDCAA, 0x2240,},
-	{0xDCAC, 0x0340,},
-	{0xDCAE, 0xA212,},
-	{0xDCB0, 0x208A,},
-	{0xDCB2, 0x0FFF,},
-	{0xDCB4, 0x1A42,},
-	{0xDCB6, 0x0004,},
-	{0xDCB8, 0xD830,},
-	{0xDCBA, 0x1A44,},
-	{0xDCBC, 0x0002,},
-	{0xDCBE, 0xD800,},
-	{0xDCC0, 0x1A50,},
-	{0xDCC2, 0x0002,},
-	{0xDCC4, 0x1A52,},
-	{0xDCC6, 0x0004,},
-	{0xDCC8, 0x1242,},
-	{0xDCCA, 0x0140,},
-	{0xDCCC, 0x8A2C,},
-	{0xDCCE, 0x6038,},
-	{0xDCD0, 0x1A42,},
-	{0xDCD2, 0x0004,},
-	{0xDCD4, 0x1242,},
-	{0xDCD6, 0x0141,},
-	{0xDCD8, 0x70CF,},
-	{0xDCDA, 0xFF00,},
-	{0xDCDC, 0x2184,},
-	{0xDCDE, 0xB021,},
-	{0xDCE0, 0xD800,},
-	{0xDCE2, 0xB893,},
-	{0xDCE4, 0x07E5,},
-	{0xDCE6, 0x0460,},
-	{0xDCE8, 0xD901,},
-	{0xDCEA, 0x78E0,},
-	{0xDCEC, 0xC0F1,},
-	{0xDCEE, 0x0BFA,},
-	{0xDCF0, 0x05A0,},
-	{0xDCF2, 0x216F,},
-	{0xDCF4, 0x0043,},
-	{0xDCF6, 0xC1A4,},
-	{0xDCF8, 0x220A,},
-	{0xDCFA, 0x1F80,},
-	{0xDCFC, 0xFFFF,},
-	{0xDCFE, 0xE058,},
-	{0xDD00, 0x2240,},
-	{0xDD02, 0x134F,},
-	{0xDD04, 0x1A48,},
-	{0xDD06, 0x13C0,},
-	{0xDD08, 0x1248,},
-	{0xDD0A, 0x1002,},
-	{0xDD0C, 0x70CF,},
-	{0xDD0E, 0x7FFF,},
-	{0xDD10, 0xFFFF,},
-	{0xDD12, 0xE230,},
-	{0xDD14, 0xC240,},
-	{0xDD16, 0xDA00,},
-	{0xDD18, 0xF00C,},
-	{0xDD1A, 0x1248,},
-	{0xDD1C, 0x1003,},
-	{0xDD1E, 0x1301,},
-	{0xDD20, 0x04CB,},
-	{0xDD22, 0x7261,},
-	{0xDD24, 0x2108,},
-	{0xDD26, 0x0081,},
-	{0xDD28, 0x2009,},
-	{0xDD2A, 0x0080,},
-	{0xDD2C, 0x1A48,},
-	{0xDD2E, 0x10C0,},
-	{0xDD30, 0x1248,},
-	{0xDD32, 0x100B,},
-	{0xDD34, 0xC300,},
-	{0xDD36, 0x0BE7,},
-	{0xDD38, 0x90C4,},
-	{0xDD3A, 0x2102,},
-	{0xDD3C, 0x0003,},
-	{0xDD3E, 0x238C,},
-	{0xDD40, 0x8FC3,},
-	{0xDD42, 0xF6C7,},
-	{0xDD44, 0xDAFF,},
-	{0xDD46, 0x1A05,},
-	{0xDD48, 0x1082,},
-	{0xDD4A, 0xC241,},
-	{0xDD4C, 0xF005,},
-	{0xDD4E, 0x7A6F,},
-	{0xDD50, 0xC241,},
-	{0xDD52, 0x1A05,},
-	{0xDD54, 0x10C2,},
-	{0xDD56, 0x2000,},
-	{0xDD58, 0x8040,},
-	{0xDD5A, 0xDA00,},
-	{0xDD5C, 0x20C0,},
-	{0xDD5E, 0x0064,},
-	{0xDD60, 0x781C,},
-	{0xDD62, 0xC042,},
-	{0xDD64, 0x1C0E,},
-	{0xDD66, 0x3082,},
-	{0xDD68, 0x1A48,},
-	{0xDD6A, 0x13C0,},
-	{0xDD6C, 0x7548,},
-	{0xDD6E, 0x7348,},
-	{0xDD70, 0x7148,},
-	{0xDD72, 0x7648,},
-	{0xDD74, 0xF002,},
-	{0xDD76, 0x7608,},
-	{0xDD78, 0x1248,},
-	{0xDD7A, 0x1000,},
-	{0xDD7C, 0x1400,},
-	{0xDD7E, 0x300B,},
-	{0xDD80, 0x084D,},
-	{0xDD82, 0x02C5,},
-	{0xDD84, 0x1248,},
-	{0xDD86, 0x1000,},
-	{0xDD88, 0xE101,},
-	{0xDD8A, 0x1001,},
-	{0xDD8C, 0x04CB,},
-	{0xDD8E, 0x1A48,},
-	{0xDD90, 0x1000,},
-	{0xDD92, 0x7361,},
-	{0xDD94, 0x1408,},
-	{0xDD96, 0x300B,},
-	{0xDD98, 0x2302,},
-	{0xDD9A, 0x02C0,},
-	{0xDD9C, 0x780D,},
-	{0xDD9E, 0x2607,},
-	{0xDDA0, 0x903E,},
-	{0xDDA2, 0x07D6,},
-	{0xDDA4, 0xFFE3,},
-	{0xDDA6, 0x792F,},
-	{0xDDA8, 0x09CF,},
-	{0xDDAA, 0x8152,},
-	{0xDDAC, 0x1248,},
-	{0xDDAE, 0x100E,},
-	{0xDDB0, 0x2400,},
-	{0xDDB2, 0x334B,},
-	{0xDDB4, 0xE501,},
-	{0xDDB6, 0x7EE2,},
-	{0xDDB8, 0x0DBF,},
-	{0xDDBA, 0x90F2,},
-	{0xDDBC, 0x1B0C,},
-	{0xDDBE, 0x1382,},
-	{0xDDC0, 0xC123,},
-	{0xDDC2, 0x140E,},
-	{0xDDC4, 0x3080,},
-	{0xDDC6, 0x7822,},
-	{0xDDC8, 0x1A07,},
-	{0xDDCA, 0x1002,},
-	{0xDDCC, 0x124C,},
-	{0xDDCE, 0x1000,},
-	{0xDDD0, 0x120B,},
-	{0xDDD2, 0x1081,},
-	{0xDDD4, 0x1207,},
-	{0xDDD6, 0x1083,},
-	{0xDDD8, 0x2142,},
-	{0xDDDA, 0x004B,},
-	{0xDDDC, 0x781B,},
-	{0xDDDE, 0x0B21,},
-	{0xDDE0, 0x02E2,},
-	{0xDDE2, 0x1A4C,},
-	{0xDDE4, 0x1000,},
-	{0xDDE6, 0xE101,},
-	{0xDDE8, 0x0915,},
-	{0xDDEA, 0x00C2,},
-	{0xDDEC, 0xC101,},
-	{0xDDEE, 0x1204,},
-	{0xDDF0, 0x1083,},
-	{0xDDF2, 0x090D,},
-	{0xDDF4, 0x00C2,},
-	{0xDDF6, 0xE001,},
-	{0xDDF8, 0x1A4C,},
-	{0xDDFA, 0x1000,},
-	{0xDDFC, 0x1A06,},
-	{0xDDFE, 0x1002,},
-	{0xDE00, 0x234A,},
-	{0xDE02, 0x1000,},
-	{0xDE04, 0x7169,},
-	{0xDE06, 0xF008,},
-	{0xDE08, 0x2053,},
-	{0xDE0A, 0x0003,},
-	{0xDE0C, 0x6179,},
-	{0xDE0E, 0x781C,},
-	{0xDE10, 0x2340,},
-	{0xDE12, 0x104B,},
-	{0xDE14, 0x1203,},
-	{0xDE16, 0x1083,},
-	{0xDE18, 0x0BF1,},
-	{0xDE1A, 0x90C2,},
-	{0xDE1C, 0x1202,},
-	{0xDE1E, 0x1080,},
-	{0xDE20, 0x091D,},
-	{0xDE22, 0x0004,},
-	{0xDE24, 0x70CF,},
-	{0xDE26, 0xFFFF,},
-	{0xDE28, 0xC644,},
-	{0xDE2A, 0x881B,},
-	{0xDE2C, 0xE0B2,},
-	{0xDE2E, 0xD83C,},
-	{0xDE30, 0x20CA,},
-	{0xDE32, 0x0CA2,},
-	{0xDE34, 0x1A01,},
-	{0xDE36, 0x1002,},
-	{0xDE38, 0x1A4C,},
-	{0xDE3A, 0x1080,},
-	{0xDE3C, 0x02B9,},
-	{0xDE3E, 0x05A0,},
-	{0xDE40, 0xC0A4,},
-	{0xDE42, 0x78E0,},
-	{0xDE44, 0xC0F1,},
-	{0xDE46, 0xFF95,},
-	{0xDE48, 0xD800,},
-	{0xDE4A, 0x71CF,},
-	{0xDE4C, 0xFF00,},
-	{0xDE4E, 0x1FE0,},
-	{0xDE50, 0x19D0,},
-	{0xDE52, 0x001C,},
-	{0xDE54, 0x19D1,},
-	{0xDE56, 0x001C,},
-	{0xDE58, 0x70CF,},
-	{0xDE5A, 0xFFFF,},
-	{0xDE5C, 0xE058,},
-	{0xDE5E, 0x901F,},
-	{0xDE60, 0xB861,},
-	{0xDE62, 0x19D2,},
-	{0xDE64, 0x001C,},
-	{0xDE66, 0xC0D1,},
-	{0xDE68, 0x7EE0,},
-	{0xDE6A, 0x78E0,},
-	{0xDE6C, 0xC0F1,},
-	{0xDE6E, 0x0A7A,},
-	{0xDE70, 0x0580,},
-	{0xDE72, 0x70CF,},
-	{0xDE74, 0xFFFF,},
-	{0xDE76, 0xC5D4,},
-	{0xDE78, 0x9041,},
-	{0xDE7A, 0x9023,},
-	{0xDE7C, 0x75CF,},
-	{0xDE7E, 0xFFFF,},
-	{0xDE80, 0xE058,},
-	{0xDE82, 0x7942,},
-	{0xDE84, 0xB967,},
-	{0xDE86, 0x7F30,},
-	{0xDE88, 0xB53F,},
-	{0xDE8A, 0x71CF,},
-	{0xDE8C, 0xFFFF,},
-	{0xDE8E, 0xC84C,},
-	{0xDE90, 0x91D3,},
-	{0xDE92, 0x108B,},
-	{0xDE94, 0x0081,},
-	{0xDE96, 0x2615,},
-	{0xDE98, 0x1380,},
-	{0xDE9A, 0x090F,},
-	{0xDE9C, 0x0C91,},
-	{0xDE9E, 0x0A8E,},
-	{0xDEA0, 0x05A0,},
-	{0xDEA2, 0xD906,},
-	{0xDEA4, 0x7E10,},
-	{0xDEA6, 0x2615,},
-	{0xDEA8, 0x1380,},
-	{0xDEAA, 0x0A82,},
-	{0xDEAC, 0x05A0,},
-	{0xDEAE, 0xD960,},
-	{0xDEB0, 0x790F,},
-	{0xDEB2, 0x090D,},
-	{0xDEB4, 0x0133,},
-	{0xDEB6, 0xAD0C,},
-	{0xDEB8, 0xD904,},
-	{0xDEBA, 0xAD2C,},
-	{0xDEBC, 0x79EC,},
-	{0xDEBE, 0x2941,},
-	{0xDEC0, 0x7402,},
-	{0xDEC2, 0x71CF,},
-	{0xDEC4, 0xFF00,},
-	{0xDEC6, 0x2184,},
-	{0xDEC8, 0xB142,},
-	{0xDECA, 0x1906,},
-	{0xDECC, 0x0E44,},
-	{0xDECE, 0xFFDE,},
-	{0xDED0, 0x70C9,},
-	{0xDED2, 0x0A5A,},
-	{0xDED4, 0x05A0,},
-	{0xDED6, 0x8D2C,},
-	{0xDED8, 0xAD0B,},
-	{0xDEDA, 0xD800,},
-	{0xDEDC, 0xAD01,},
-	{0xDEDE, 0x0219,},
-	{0xDEE0, 0x05A0,},
-	{0xDEE2, 0xA513,},
-	{0xDEE4, 0xC0F1,},
-	{0xDEE6, 0x71CF,},
-	{0xDEE8, 0xFFFF,},
-	{0xDEEA, 0xC644,},
-	{0xDEEC, 0xA91B,},
-	{0xDEEE, 0xD902,},
-	{0xDEF0, 0x70CF,},
-	{0xDEF2, 0xFFFF,},
-	{0xDEF4, 0xC84C,},
-	{0xDEF6, 0x093E,},
-	{0xDEF8, 0x03A0,},
-	{0xDEFA, 0xA826,},
-	{0xDEFC, 0xFFDC,},
-	{0xDEFE, 0xF1B5,},
-	{0xDF00, 0xC0F1,},
-	{0xDF02, 0x09EA,},
-	{0xDF04, 0x0580,},
-	{0xDF06, 0x75CF,},
-	{0xDF08, 0xFFFF,},
-	{0xDF0A, 0xE058,},
-	{0xDF0C, 0x1540,},
-	{0xDF0E, 0x1080,},
-	{0xDF10, 0x08A7,},
-	{0xDF12, 0x0010,},
-	{0xDF14, 0x8D00,},
-	{0xDF16, 0x0813,},
-	{0xDF18, 0x009E,},
-	{0xDF1A, 0x1540,},
-	{0xDF1C, 0x1081,},
-	{0xDF1E, 0xE181,},
-	{0xDF20, 0x20CA,},
-	{0xDF22, 0x00A1,},
-	{0xDF24, 0xF24B,},
-	{0xDF26, 0x1540,},
-	{0xDF28, 0x1081,},
-	{0xDF2A, 0x090F,},
-	{0xDF2C, 0x0050,},
-	{0xDF2E, 0x1540,},
-	{0xDF30, 0x1081,},
-	{0xDF32, 0x0927,},
-	{0xDF34, 0x0091,},
-	{0xDF36, 0x1550,},
-	{0xDF38, 0x1081,},
-	{0xDF3A, 0xDE00,},
-	{0xDF3C, 0xAD2A,},
-	{0xDF3E, 0x1D50,},
-	{0xDF40, 0x1382,},
-	{0xDF42, 0x1552,},
-	{0xDF44, 0x1101,},
-	{0xDF46, 0x1D52,},
-	{0xDF48, 0x1384,},
-	{0xDF4A, 0xB524,},
-	{0xDF4C, 0x082D,},
-	{0xDF4E, 0x015F,},
-	{0xDF50, 0xFF55,},
-	{0xDF52, 0xD803,},
-	{0xDF54, 0xF033,},
-	{0xDF56, 0x1540,},
-	{0xDF58, 0x1081,},
-	{0xDF5A, 0x0967,},
-	{0xDF5C, 0x00D1,},
-	{0xDF5E, 0x1550,},
-	{0xDF60, 0x1081,},
-	{0xDF62, 0xDE00,},
-	{0xDF64, 0xAD2A,},
-	{0xDF66, 0x1D50,},
-	{0xDF68, 0x1382,},
-	{0xDF6A, 0x1552,},
-	{0xDF6C, 0x1101,},
-	{0xDF6E, 0x1D52,},
-	{0xDF70, 0x1384,},
-	{0xDF72, 0xB524,},
-	{0xDF74, 0x0811,},
-	{0xDF76, 0x019E,},
-	{0xDF78, 0xB8A0,},
-	{0xDF7A, 0xAD00,},
-	{0xDF7C, 0xFF47,},
-	{0xDF7E, 0x1D40,},
-	{0xDF80, 0x1382,},
-	{0xDF82, 0xF01F,},
-	{0xDF84, 0xFF5A,},
-	{0xDF86, 0x8D01,},
-	{0xDF88, 0x8D40,},
-	{0xDF8A, 0xE812,},
-	{0xDF8C, 0x71CF,},
-	{0xDF8E, 0xFFFF,},
-	{0xDF90, 0xC644,},
-	{0xDF92, 0x893B,},
-	{0xDF94, 0x7030,},
-	{0xDF96, 0x22D1,},
-	{0xDF98, 0x8062,},
-	{0xDF9A, 0xF20A,},
-	{0xDF9C, 0x0A0F,},
-	{0xDF9E, 0x009E,},
-	{0xDFA0, 0x71CF,},
-	{0xDFA2, 0xFFFF,},
-	{0xDFA4, 0xC84C,},
-	{0xDFA6, 0x893B,},
-	{0xDFA8, 0xE902,},
-	{0xDFAA, 0xFFCF,},
-	{0xDFAC, 0x8D00,},
-	{0xDFAE, 0xB8E7,},
-	{0xDFB0, 0x26CA,},
-	{0xDFB2, 0x1022,},
-	{0xDFB4, 0xF5E2,},
-	{0xDFB6, 0xFF3C,},
-	{0xDFB8, 0xD801,},
-	{0xDFBA, 0x1D40,},
-	{0xDFBC, 0x1002,},
-	{0xDFBE, 0x0141,},
-	{0xDFC0, 0x0580,},
-	{0xDFC2, 0x78E0,},
-	{0xDFC4, 0xC0F1,},
-	{0xDFC6, 0xC5E1,},
-	{0xDFC8, 0xFF34,},
-	{0xDFCA, 0xDD00,},
-	{0xDFCC, 0x70CF,},
-	{0xDFCE, 0xFFFF,},
-	{0xDFD0, 0xE090,},
-	{0xDFD2, 0xA8A8,},
-	{0xDFD4, 0xD800,},
-	{0xDFD6, 0xB893,},
-	{0xDFD8, 0x0C8A,},
-	{0xDFDA, 0x0460,},
-	{0xDFDC, 0xD901,},
-	{0xDFDE, 0x71CF,},
-	{0xDFE0, 0xFFFF,},
-	{0xDFE2, 0xDC10,},
-	{0xDFE4, 0xD813,},
-	{0xDFE6, 0x0B96,},
-	{0xDFE8, 0x0460,},
-	{0xDFEA, 0x72A9,},
-	{0xDFEC, 0x0119,},
-	{0xDFEE, 0x0580,},
-	{0xDFF0, 0xC0F1,},
-	{0xDFF2, 0x71CF,},
-	{0xDFF4, 0x0000,},
-	{0xDFF6, 0x5BAE,},
-	{0xDFF8, 0x7940,},
-	{0xDFFA, 0xFF9D,},
-	{0xDFFC, 0xF135,},
-	{0xDFFE, 0x78E0,},
-	{0xE000, 0xC0F1,},
-	{0xE002, 0x70CF,},
-	{0xE004, 0x0000,},
-	{0xE006, 0x5CBA,},
-	{0xE008, 0x7840,},
-	{0xE00A, 0x70CF,},
-	{0xE00C, 0xFFFF,},
-	{0xE00E, 0xE058,},
-	{0xE010, 0x8800,},
-	{0xE012, 0x0815,},
-	{0xE014, 0x001E,},
-	{0xE016, 0x70CF,},
-	{0xE018, 0xFFFF,},
-	{0xE01A, 0xC84C,},
-	{0xE01C, 0x881A,},
-	{0xE01E, 0xE080,},
-	{0xE020, 0x0EE0,},
-	{0xE022, 0xFFC1,},
-	{0xE024, 0xF121,},
-	{0xE026, 0x78E0,},
-	{0xE028, 0xC0F1,},
-	{0xE02A, 0xD900,},
-	{0xE02C, 0xF009,},
-	{0xE02E, 0x70CF,},
-	{0xE030, 0xFFFF,},
-	{0xE032, 0xE0AC,},
-	{0xE034, 0x7835,},
-	{0xE036, 0x8041,},
-	{0xE038, 0x8000,},
-	{0xE03A, 0xE102,},
-	{0xE03C, 0xA040,},
-	{0xE03E, 0x09F3,},
-	{0xE040, 0x8114,},
-	{0xE042, 0x71CF,},
-	{0xE044, 0xFFFF,},
-	{0xE046, 0xE058,},
-	{0xE048, 0x70CF,},
-	{0xE04A, 0xFFFF,},
-	{0xE04C, 0xC594,},
-	{0xE04E, 0xB030,},
-	{0xE050, 0xFFDD,},
-	{0xE052, 0xD800,},
-	{0xE054, 0xF109,},
-	{0xE056, 0x0000,},
-	{0xE058, 0x0300,},
-	{0xE05A, 0x0204,},
-	{0xE05C, 0x0700,},
-	{0xE05E, 0x0000,},
-	{0xE060, 0x0000,},
-	{0xE062, 0x0000,},
-	{0xE064, 0x0000,},
-	{0xE066, 0x0000,},
-	{0xE068, 0x0000,},
-	{0xE06A, 0x0000,},
-	{0xE06C, 0x0000,},
-	{0xE06E, 0x0000,},
-	{0xE070, 0x0000,},
-	{0xE072, 0x0000,},
-	{0xE074, 0x0000,},
-	{0xE076, 0x0000,},
-	{0xE078, 0x0000,},
-	{0xE07A, 0x0000,},
-	{0xE07C, 0x0000,},
-	{0xE07E, 0x0000,},
-	{0xE080, 0x0000,},
-	{0xE082, 0x0000,},
-	{0xE084, 0x0000,},
-	{0xE086, 0x0000,},
-	{0xE088, 0x0000,},
-	{0xE08A, 0x0000,},
-	{0xE08C, 0x0000,},
-	{0xE08E, 0x0000,},
-	{0xE090, 0x0000,},
-	{0xE092, 0x0000,},
-	{0xE094, 0x0000,},
-	{0xE096, 0x0000,},
-	{0xE098, 0x0000,},
-	{0xE09A, 0x0000,},
-	{0xE09C, 0x0000,},
-	{0xE09E, 0x0000,},
-	{0xE0A0, 0x0000,},
-	{0xE0A2, 0x0000,},
-	{0xE0A4, 0x0000,},
-	{0xE0A6, 0x0000,},
-	{0xE0A8, 0x0000,},
-	{0xE0AA, 0x0000,},
-	{0xE0AC, 0xFFFF,},
-	{0xE0AE, 0xCB68,},
-	{0xE0B0, 0xFFFF,},
-	{0xE0B2, 0xDFF0,},
-	{0xE0B4, 0xFFFF,},
-	{0xE0B6, 0xCB6C,},
-	{0xE0B8, 0xFFFF,},
-	{0xE0BA, 0xE000,},
-	{0x098E, 0x0000,},
-
-	/*MIPI setting for SOC1040*/
-	{0x3C5A, 0x0009,},
-	{0x3C44, 0x0080,},/*MIPI_CUSTOM_SHORT_PKT*/
-
-	/*[Tuning_settings]*/
-
-	/*[CCM]*/
-	{0xC892, 0x0267,},/*CAM_AWB_CCM_L_0*/
-	{0xC894, 0xFF1A,},/*CAM_AWB_CCM_L_1*/
-	{0xC896, 0xFFB3,},/*CAM_AWB_CCM_L_2*/
-	{0xC898, 0xFF80,},/*CAM_AWB_CCM_L_3*/
-	{0xC89A, 0x0166,},/*CAM_AWB_CCM_L_4*/
-	{0xC89C, 0x0003,},/*CAM_AWB_CCM_L_5*/
-	{0xC89E, 0xFF9A,},/*CAM_AWB_CCM_L_6*/
-	{0xC8A0, 0xFEB4,},/*CAM_AWB_CCM_L_7*/
-	{0xC8A2, 0x024D,},/*CAM_AWB_CCM_L_8*/
-	{0xC8A4, 0x01BF,},/*CAM_AWB_CCM_M_0*/
-	{0xC8A6, 0xFF01,},/*CAM_AWB_CCM_M_1*/
-	{0xC8A8, 0xFFF3,},/*CAM_AWB_CCM_M_2*/
-	{0xC8AA, 0xFF75,},/*CAM_AWB_CCM_M_3*/
-	{0xC8AC, 0x0198,},/*CAM_AWB_CCM_M_4*/
-	{0xC8AE, 0xFFFD,},/*CAM_AWB_CCM_M_5*/
-	{0xC8B0, 0xFF9A,},/*CAM_AWB_CCM_M_6*/
-	{0xC8B2, 0xFEE7,},/*CAM_AWB_CCM_M_7*/
-	{0xC8B4, 0x02A8,},/*CAM_AWB_CCM_M_8*/
-	{0xC8B6, 0x01D9,},/*CAM_AWB_CCM_R_0*/
-	{0xC8B8, 0xFF26,},/*CAM_AWB_CCM_R_1*/
-	{0xC8BA, 0xFFF3,},/*CAM_AWB_CCM_R_2*/
-	{0xC8BC, 0xFFB3,},/*CAM_AWB_CCM_R_3*/
-	{0xC8BE, 0x0132,},/*CAM_AWB_CCM_R_4*/
-	{0xC8C0, 0xFFE8,},/*CAM_AWB_CCM_R_5*/
-	{0xC8C2, 0xFFDA,},/*CAM_AWB_CCM_R_6*/
-	{0xC8C4, 0xFECD,},/*CAM_AWB_CCM_R_7*/
-	{0xC8C6, 0x02C2,},/*CAM_AWB_CCM_R_8*/
-	{0xC8C8, 0x0075,},/*CAM_AWB_CCM_L_RG_GAIN*/
-	{0xC8CA, 0x011C,},/*CAM_AWB_CCM_L_BG_GAIN*/
-	{0xC8CC, 0x009A,},/*CAM_AWB_CCM_M_RG_GAIN*/
-	{0xC8CE, 0x0105,},/*CAM_AWB_CCM_M_BG_GAIN*/
-	{0xC8D0, 0x00A4,},/*CAM_AWB_CCM_R_RG_GAIN*/
-	{0xC8D2, 0x00AC,},/*CAM_AWB_CCM_R_BG_GAIN*/
-	{0xC8D4, 0x0A8C,},/*CAM_AWB_CCM_L_CTEMP*/
-	{0xC8D6, 0x0F0A,},/*CAM_AWB_CCM_M_CTEMP*/
-	{0xC8D8, 0x1964,},/*CAM_AWB_CCM_R_CTEMP*/
-
-	/*[AWB]*/
-	{0xC914, 0x0000,},/*CAM_STAT_AWB_CLIP_WINDOW_XSTART*/
-	{0xC916, 0x0000,},/*CAM_STAT_AWB_CLIP_WINDOW_YSTART*/
-	{0xC918, 0x04FF,},/*CAM_STAT_AWB_CLIP_WINDOW_XEND*/
-	{0xC91A, 0x02CF,},/*CAM_STAT_AWB_CLIP_WINDOW_YEND*/
-	{0xC904, 0x0033,},/*CAM_AWB_AWB_XSHIFT_PRE_ADJ*/
-	{0xC906, 0x0040,},/*CAM_AWB_AWB_YSHIFT_PRE_ADJ*/
-	{0xC8F2, 0x03, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_AWB_AWB_XSCALE*/
-	{0xC8F3, 0x02, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_AWB_AWB_YSCALE*/
-	{0xC906, 0x003C,},/*CAM_AWB_AWB_YSHIFT_PRE_ADJ*/
-	{0xC8F4, 0x0000,},/*CAM_AWB_AWB_WEIGHTS_0*/
-	{0xC8F6, 0x0000,},/*CAM_AWB_AWB_WEIGHTS_1*/
-	{0xC8F8, 0x0000,},/*CAM_AWB_AWB_WEIGHTS_2*/
-	{0xC8FA, 0xE724,},/*CAM_AWB_AWB_WEIGHTS_3*/
-	{0xC8FC, 0x1583,},/*CAM_AWB_AWB_WEIGHTS_4*/
-	{0xC8FE, 0x2045,},/*CAM_AWB_AWB_WEIGHTS_5*/
-	{0xC900, 0x03FF,},/*CAM_AWB_AWB_WEIGHTS_6*/
-	{0xC902, 0x007C,},/*CAM_AWB_AWB_WEIGHTS_7*/
-	{0xC90C, 0x80, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_AWB_K_R_L*/
-	{0xC90D, 0x80, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_AWB_K_G_L*/
-	{0xC90E, 0x80, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_AWB_K_B_L*/
-	{0xC90F, 0x88, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_AWB_K_R_R*/
-	{0xC910, 0x80, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_AWB_K_G_R*/
-	{0xC911, 0x80, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_AWB_K_B_R*/
-
-	/*[Step7-CPIPE_Preference]*/
-	{0xC926, 0x0020,},/*CAM_LL_START_BRIGHTNESS*/
-	{0xC928, 0x009A,},/*CAM_LL_STOP_BRIGHTNESS*/
-	{0xC946, 0x0070,},/*CAM_LL_START_GAIN_METRIC*/
-	{0xC948, 0x00F3,},/*CAM_LL_STOP_GAIN_METRIC*/
-	{0xC952, 0x0020,},/*CAM_LL_START_TARGET_LUMA_BM*/
-	{0xC954, 0x009A,},/*CAM_LL_STOP_TARGET_LUMA_BM*/
-	{0xC92A, 0x80, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_START_SATURATION*/
-	{0xC92B, 0x4B, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_END_SATURATION*/
-	{0xC92C, 0x00, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_START_DESATURATION*/
-	{0xC92D, 0xFF, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_END_DESATURATION*/
-	{0xC92E, 0x3C, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_START_DEMOSAIC*/
-	{0xC92F, 0x02, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_START_AP_GAIN*/
-	{0xC930, 0x06, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_START_AP_THRESH*/
-	{0xC931, 0x64, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_STOP_DEMOSAIC*/
-	{0xC932, 0x01, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_STOP_AP_GAIN*/
-	{0xC933, 0x0C, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_STOP_AP_THRESH*/
-	{0xC934, 0x3C, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_START_NR_RED*/
-	{0xC935, 0x3C, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_START_NR_GREEN*/
-	{0xC936, 0x3C, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_START_NR_BLUE*/
-	{0xC937, 0x0F, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_START_NR_THRESH*/
-	{0xC938, 0x64, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_STOP_NR_RED*/
-	{0xC939, 0x64, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_STOP_NR_GREEN*/
-	{0xC93A, 0x64, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_STOP_NR_BLUE*/
-	{0xC93B, 0x32, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_STOP_NR_THRESH*/
-	{0xC93C, 0x0020,},/*CAM_LL_START_CONTRAST_BM*/
-	{0xC93E, 0x009A,},/*CAM_LL_STOP_CONTRAST_BM*/
-	{0xC940, 0x00DC,},/*CAM_LL_GAMMA*/
-	/*CAM_LL_START_CONTRAST_GRADIENT*/
-	{0xC942, 0x38, MSM_CAMERA_I2C_BYTE_DATA},
-	/*CAM_LL_STOP_CONTRAST_GRADIENT*/
-	{0xC943, 0x30, MSM_CAMERA_I2C_BYTE_DATA},
-	{0xC944, 0x50, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_START_CONTRAST_LUMA*/
-	{0xC945, 0x19, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_STOP_CONTRAST_LUMA*/
-	{0xC94A, 0x0230,},/*CAM_LL_START_FADE_TO_BLACK_LUMA*/
-	{0xC94C, 0x0010,},/*CAM_LL_STOP_FADE_TO_BLACK_LUMA*/
-	{0xC94E, 0x01CD,},/*CAM_LL_CLUSTER_DC_TH_BM*/
-	{0xC950, 0x05, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_CLUSTER_DC_GATE*/
-	{0xC951, 0x40, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_LL_SUMMING_SENSITIVITY*/
-	/*CAM_AET_TARGET_AVERAGE_LUMA_DARK*/
-	{0xC87B, 0x1B, MSM_CAMERA_I2C_BYTE_DATA},
-	{0xC878, 0x0E, MSM_CAMERA_I2C_BYTE_DATA},/*CAM_AET_AEMODE*/
-	{0xC890, 0x0080,},/*CAM_AET_TARGET_GAIN*/
-	{0xC886, 0x0100,},/*CAM_AET_AE_MAX_VIRT_AGAIN*/
-	{0xC87C, 0x005A,},/*CAM_AET_BLACK_CLIPPING_TARGET*/
-	{0xB42A, 0x05, MSM_CAMERA_I2C_BYTE_DATA},/*CCM_DELTA_GAIN*/
-	/*AE_TRACK_AE_TRACKING_DAMPENING*/
-	{0xA80A, 0x20, MSM_CAMERA_I2C_BYTE_DATA},
-	{0x3C44, 0x0080,},
-	{0x3C40, 0x0004, MSM_CAMERA_I2C_UNSET_WORD_MASK},
-	{0xA802, 0x08, MSM_CAMERA_I2C_SET_BYTE_MASK},
-	{0xC908, 0x01, MSM_CAMERA_I2C_BYTE_DATA},
-	{0xC879, 0x01, MSM_CAMERA_I2C_BYTE_DATA},
-	{0xC909, 0x01, MSM_CAMERA_I2C_UNSET_BYTE_MASK},
-	{0xA80A, 0x18, MSM_CAMERA_I2C_BYTE_DATA},
-	{0xA80B, 0x18, MSM_CAMERA_I2C_BYTE_DATA},
-	{0xAC16, 0x18, MSM_CAMERA_I2C_BYTE_DATA},
-	{0xC878, 0x08, MSM_CAMERA_I2C_SET_BYTE_MASK},
-	{0xBC02, 0x08, MSM_CAMERA_I2C_UNSET_BYTE_MASK},
-};
-
-static struct v4l2_subdev_info mt9m114_subdev_info[] = {
-	{
-	.code   = V4L2_MBUS_FMT_YUYV8_2X8,
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	.fmt    = 1,
-	.order    = 0,
-	},
-	/* more can be supported, to be added later */
-};
-
-static struct msm_camera_i2c_reg_conf mt9m114_config_change_settings[] = {
-	{0xdc00, 0x28, MSM_CAMERA_I2C_BYTE_DATA, MSM_CAMERA_I2C_CMD_WRITE},
-	{MT9M114_COMMAND_REGISTER, MT9M114_COMMAND_REGISTER_SET_STATE,
-		MSM_CAMERA_I2C_UNSET_WORD_MASK, MSM_CAMERA_I2C_CMD_POLL},
-	{MT9M114_COMMAND_REGISTER, (MT9M114_COMMAND_REGISTER_OK |
-		MT9M114_COMMAND_REGISTER_SET_STATE), MSM_CAMERA_I2C_WORD_DATA,
-		MSM_CAMERA_I2C_CMD_WRITE},
-	{MT9M114_COMMAND_REGISTER, MT9M114_COMMAND_REGISTER_SET_STATE,
-		MSM_CAMERA_I2C_UNSET_WORD_MASK, MSM_CAMERA_I2C_CMD_POLL},
-	{0xDC01, 0x31, MSM_CAMERA_I2C_BYTE_DATA},
-};
-
-static void mt9m114_stop_stream(struct msm_sensor_ctrl_t *s_ctrl) {}
-
-static struct msm_camera_i2c_conf_array mt9m114_init_conf[] = {
-	{mt9m114_recommend_settings,
-	ARRAY_SIZE(mt9m114_recommend_settings), 0, MSM_CAMERA_I2C_WORD_DATA},
-	{mt9m114_config_change_settings,
-	ARRAY_SIZE(mt9m114_config_change_settings),
-	0, MSM_CAMERA_I2C_WORD_DATA},
-};
-
-static struct msm_camera_i2c_conf_array mt9m114_confs[] = {
-	{mt9m114_720p_settings,
-	ARRAY_SIZE(mt9m114_720p_settings), 0, MSM_CAMERA_I2C_WORD_DATA},
-};
-
-static struct msm_camera_i2c_reg_conf mt9m114_saturation[][1] = {
-	{{0xCC12, 0x00},},
-	{{0xCC12, 0x1A},},
-	{{0xCC12, 0x34},},
-	{{0xCC12, 0x4E},},
-	{{0xCC12, 0x68},},
-	{{0xCC12, 0x80},},
-	{{0xCC12, 0x9A},},
-	{{0xCC12, 0xB4},},
-	{{0xCC12, 0xCE},},
-	{{0xCC12, 0xE8},},
-	{{0xCC12, 0xFF},},
-};
-
-static struct msm_camera_i2c_reg_conf mt9m114_refresh[] = {
-	{MT9M114_COMMAND_REGISTER, MT9M114_COMMAND_REGISTER_REFRESH,
-		MSM_CAMERA_I2C_UNSET_WORD_MASK, MSM_CAMERA_I2C_CMD_POLL},
-	{MT9M114_COMMAND_REGISTER, (MT9M114_COMMAND_REGISTER_OK |
-		MT9M114_COMMAND_REGISTER_REFRESH), MSM_CAMERA_I2C_WORD_DATA,
-		MSM_CAMERA_I2C_CMD_WRITE},
-	{MT9M114_COMMAND_REGISTER, MT9M114_COMMAND_REGISTER_REFRESH,
-		MSM_CAMERA_I2C_UNSET_WORD_MASK, MSM_CAMERA_I2C_CMD_POLL},
-	{MT9M114_COMMAND_REGISTER, MT9M114_COMMAND_REGISTER_OK,
-		MSM_CAMERA_I2C_SET_WORD_MASK, MSM_CAMERA_I2C_CMD_POLL},
-};
-
-static struct msm_camera_i2c_conf_array mt9m114_saturation_confs[][2] = {
-	{{mt9m114_saturation[0],
-		ARRAY_SIZE(mt9m114_saturation[0]), 0, MSM_CAMERA_I2C_WORD_DATA},
-	{mt9m114_refresh,
-		ARRAY_SIZE(mt9m114_refresh), 0, MSM_CAMERA_I2C_WORD_DATA},},
-	{{mt9m114_saturation[1],
-		ARRAY_SIZE(mt9m114_saturation[1]), 0, MSM_CAMERA_I2C_WORD_DATA},
-	{mt9m114_refresh,
-		ARRAY_SIZE(mt9m114_refresh), 0, MSM_CAMERA_I2C_WORD_DATA},},
-	{{mt9m114_saturation[2],
-		ARRAY_SIZE(mt9m114_saturation[2]), 0, MSM_CAMERA_I2C_WORD_DATA},
-	{mt9m114_refresh,
-		ARRAY_SIZE(mt9m114_refresh), 0, MSM_CAMERA_I2C_WORD_DATA},},
-	{{mt9m114_saturation[3],
-		ARRAY_SIZE(mt9m114_saturation[3]), 0, MSM_CAMERA_I2C_WORD_DATA},
-	{mt9m114_refresh,
-		ARRAY_SIZE(mt9m114_refresh), 0, MSM_CAMERA_I2C_WORD_DATA},},
-	{{mt9m114_saturation[4],
-		ARRAY_SIZE(mt9m114_saturation[4]), 0, MSM_CAMERA_I2C_WORD_DATA},
-	{mt9m114_refresh,
-		ARRAY_SIZE(mt9m114_refresh), 0, MSM_CAMERA_I2C_WORD_DATA},},
-	{{mt9m114_saturation[5],
-		ARRAY_SIZE(mt9m114_saturation[5]), 0, MSM_CAMERA_I2C_WORD_DATA},
-	{mt9m114_refresh,
-		ARRAY_SIZE(mt9m114_refresh), 0, MSM_CAMERA_I2C_WORD_DATA},},
-	{{mt9m114_saturation[6],
-		ARRAY_SIZE(mt9m114_saturation[6]), 0, MSM_CAMERA_I2C_WORD_DATA},
-	{mt9m114_refresh,
-		ARRAY_SIZE(mt9m114_refresh), 0, MSM_CAMERA_I2C_WORD_DATA},},
-	{{mt9m114_saturation[7],
-		ARRAY_SIZE(mt9m114_saturation[7]), 0, MSM_CAMERA_I2C_WORD_DATA},
-	{mt9m114_refresh,
-		ARRAY_SIZE(mt9m114_refresh), 0, MSM_CAMERA_I2C_WORD_DATA},},
-	{{mt9m114_saturation[8],
-		ARRAY_SIZE(mt9m114_saturation[8]), 0, MSM_CAMERA_I2C_WORD_DATA},
-	{mt9m114_refresh,
-		ARRAY_SIZE(mt9m114_refresh), 0, MSM_CAMERA_I2C_WORD_DATA},},
-	{{mt9m114_saturation[9],
-		ARRAY_SIZE(mt9m114_saturation[9]), 0, MSM_CAMERA_I2C_WORD_DATA},
-	{mt9m114_refresh,
-		ARRAY_SIZE(mt9m114_refresh), 0, MSM_CAMERA_I2C_WORD_DATA},},
-	{{mt9m114_saturation[10],
-		ARRAY_SIZE(mt9m114_saturation[10]),
-		0, MSM_CAMERA_I2C_WORD_DATA},
-	{mt9m114_refresh,
-		ARRAY_SIZE(mt9m114_refresh), 0, MSM_CAMERA_I2C_WORD_DATA},},
-};
-
-static int mt9m114_saturation_enum_map[] = {
-	MSM_V4L2_SATURATION_L0,
-	MSM_V4L2_SATURATION_L1,
-	MSM_V4L2_SATURATION_L2,
-	MSM_V4L2_SATURATION_L3,
-	MSM_V4L2_SATURATION_L4,
-	MSM_V4L2_SATURATION_L5,
-	MSM_V4L2_SATURATION_L6,
-	MSM_V4L2_SATURATION_L7,
-	MSM_V4L2_SATURATION_L8,
-	MSM_V4L2_SATURATION_L9,
-	MSM_V4L2_SATURATION_L10,
-};
-
-static struct msm_camera_i2c_enum_conf_array mt9m114_saturation_enum_confs = {
-	.conf = &mt9m114_saturation_confs[0][0],
-	.conf_enum = mt9m114_saturation_enum_map,
-	.num_enum = ARRAY_SIZE(mt9m114_saturation_enum_map),
-	.num_index = ARRAY_SIZE(mt9m114_saturation_confs),
-	.num_conf = ARRAY_SIZE(mt9m114_saturation_confs[0]),
-	.data_type = MSM_CAMERA_I2C_WORD_DATA,
-};
-
-struct msm_sensor_v4l2_ctrl_info_t mt9m114_v4l2_ctrl_info[] = {
-	{
-		.ctrl_id = V4L2_CID_SATURATION,
-		.min = MSM_V4L2_SATURATION_L0,
-		.max = MSM_V4L2_SATURATION_L10,
-		.step = 1,
-		.enum_cfg_settings = &mt9m114_saturation_enum_confs,
-		.s_v4l2_ctrl = msm_sensor_s_ctrl_by_enum,
-	},
-};
-
-static struct msm_sensor_output_info_t mt9m114_dimensions[] = {
-	{
-		.x_output = 0x500,
-		.y_output = 0x2D0,
-		.line_length_pclk = 0x500,
-		.frame_length_lines = 0x2D0,
-		.vt_pixel_clk = 48000000,
-		.op_pixel_clk = 128000000,
-		.binning_factor = 1,
-	},
-};
-
-static struct msm_sensor_output_reg_addr_t mt9m114_reg_addr = {
-	.x_output = 0xC868,
-	.y_output = 0xC86A,
-	.line_length_pclk = 0xC868,
-	.frame_length_lines = 0xC86A,
-};
-
-static enum msm_camera_vreg_name_t mt9m114_veg_seq[] = {
-	CAM_VIO,
-	CAM_VDIG,
-	CAM_VANA,
-};
-
-static struct msm_sensor_id_info_t mt9m114_id_info = {
-	.sensor_id_reg_addr = 0x0,
-	.sensor_id = 0x2481,
-};
-
-static const struct i2c_device_id mt9m114_i2c_id[] = {
-	{SENSOR_NAME, (kernel_ulong_t)&mt9m114_s_ctrl},
-	{ }
-};
-
-static struct i2c_driver mt9m114_i2c_driver = {
-	.id_table = mt9m114_i2c_id,
-	.probe  = msm_sensor_i2c_probe,
-	.driver = {
-		.name = SENSOR_NAME,
-	},
-};
-
-static struct msm_camera_i2c_client mt9m114_sensor_i2c_client = {
-	.addr_type = MSM_CAMERA_I2C_WORD_ADDR,
-};
-
-static const struct of_device_id mt9m114_dt_match[] = {
-	{.compatible = "qcom,mt9m114", .data = &mt9m114_s_ctrl},
-	{}
-};
-
-MODULE_DEVICE_TABLE(of, mt9m114_dt_match);
-
-static struct platform_driver mt9m114_platform_driver = {
-	.driver = {
-		.name = "qcom,mt9m114",
-		.owner = THIS_MODULE,
-		.of_match_table = mt9m114_dt_match,
-	},
-};
-
-static int32_t mt9m114_platform_probe(struct platform_device *pdev)
-{
-	int32_t rc = 0;
-	const struct of_device_id *match;
-	match = of_match_device(mt9m114_dt_match, &pdev->dev);
-	rc = msm_sensor_platform_probe(pdev, match->data);
-	return rc;
-}
-
-static int __init msm_sensor_init_module(void)
-{
-	int32_t rc = 0;
-	rc = platform_driver_probe(&mt9m114_platform_driver,
-		mt9m114_platform_probe);
-	if (!rc)
-		return rc;
-	return i2c_add_driver(&mt9m114_i2c_driver);
-}
-
-
-static void __exit msm_sensor_exit_module(void)
-{
-	if (mt9m114_s_ctrl.pdev) {
-		msm_sensor_free_sensor_data(&mt9m114_s_ctrl);
-		platform_driver_unregister(&mt9m114_platform_driver);
-	} else {
-		i2c_del_driver(&mt9m114_i2c_driver);
-	}
-	return;
-}
-
-static struct v4l2_subdev_core_ops mt9m114_subdev_core_ops = {
-	.s_ctrl = msm_sensor_v4l2_s_ctrl,
-	.queryctrl = msm_sensor_v4l2_query_ctrl,
-	.ioctl = msm_sensor_subdev_ioctl,
-	.s_power = msm_sensor_power,
-};
-
-static struct v4l2_subdev_video_ops mt9m114_subdev_video_ops = {
-	.enum_mbus_fmt = msm_sensor_v4l2_enum_fmt,
-};
-
-static struct v4l2_subdev_ops mt9m114_subdev_ops = {
-	.core = &mt9m114_subdev_core_ops,
-	.video  = &mt9m114_subdev_video_ops,
-};
-
-static struct msm_sensor_fn_t mt9m114_func_tbl = {
-	.sensor_start_stream = msm_sensor_start_stream,
-	.sensor_stop_stream = mt9m114_stop_stream,
-	.sensor_setting = msm_sensor_setting,
-	.sensor_set_sensor_mode = msm_sensor_set_sensor_mode,
-	.sensor_mode_init = msm_sensor_mode_init,
-	.sensor_get_output_info = msm_sensor_get_output_info,
-	.sensor_config = msm_sensor_config,
-	.sensor_power_up = msm_sensor_power_up,
-	.sensor_power_down = msm_sensor_power_down,
-	.sensor_get_csi_params = msm_sensor_get_csi_params,
-};
-
-static struct msm_sensor_reg_t mt9m114_regs = {
-	.default_data_type = MSM_CAMERA_I2C_BYTE_DATA,
-	.start_stream_conf = mt9m114_config_change_settings,
-	.start_stream_conf_size = ARRAY_SIZE(mt9m114_config_change_settings),
-	.init_settings = &mt9m114_init_conf[0],
-	.init_size = ARRAY_SIZE(mt9m114_init_conf),
-	.mode_settings = &mt9m114_confs[0],
-	.output_settings = &mt9m114_dimensions[0],
-	.num_conf = ARRAY_SIZE(mt9m114_confs),
-};
-
-static struct msm_sensor_ctrl_t mt9m114_s_ctrl = {
-	.msm_sensor_reg = &mt9m114_regs,
-	.msm_sensor_v4l2_ctrl_info = mt9m114_v4l2_ctrl_info,
-	.num_v4l2_ctrl = ARRAY_SIZE(mt9m114_v4l2_ctrl_info),
-	.sensor_i2c_client = &mt9m114_sensor_i2c_client,
-	.sensor_i2c_addr = 0x90,
-	.vreg_seq = mt9m114_veg_seq,
-	.num_vreg_seq = ARRAY_SIZE(mt9m114_veg_seq),
-	.sensor_output_reg_addr = &mt9m114_reg_addr,
-	.sensor_id_info = &mt9m114_id_info,
-	.cam_mode = MSM_SENSOR_MODE_INVALID,
-	.min_delay = 30,
-	.power_seq_delay = 60,
-	.msm_sensor_mutex = &mt9m114_mut,
-	.sensor_i2c_driver = &mt9m114_i2c_driver,
-	.sensor_v4l2_subdev_info = mt9m114_subdev_info,
-	.sensor_v4l2_subdev_info_size = ARRAY_SIZE(mt9m114_subdev_info),
-	.sensor_v4l2_subdev_ops = &mt9m114_subdev_ops,
-	.func_tbl = &mt9m114_func_tbl,
-};
-
-module_init(msm_sensor_init_module);
-module_exit(msm_sensor_exit_module);
-MODULE_DESCRIPTION("Aptina 1.26MP YUV sensor driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/sensors/ov2720.c b/drivers/media/platform/msm/camera_v1/sensors/ov2720.c
deleted file mode 100644
index fe7bf07..0000000
--- a/drivers/media/platform/msm/camera_v1/sensors/ov2720.c
+++ /dev/null
@@ -1,856 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- *
- */
-
-#include "msm_sensor.h"
-#include "ov2720.h"
-#define SENSOR_NAME "ov2720"
-#define PLATFORM_DRIVER_NAME "msm_camera_ov2720"
-#define ov2720_obj ov2720_##obj
-
-DEFINE_MUTEX(ov2720_mut);
-static struct msm_sensor_ctrl_t ov2720_s_ctrl;
-
-static struct msm_camera_i2c_reg_conf ov2720_start_settings[] = {
-	{0x0100, 0x01},
-};
-
-static struct msm_camera_i2c_reg_conf ov2720_stop_settings[] = {
-	{0x0100, 0x00},
-};
-
-static struct msm_camera_i2c_reg_conf ov2720_groupon_settings[] = {
-	{0x3208, 0x00},
-};
-
-static struct msm_camera_i2c_reg_conf ov2720_groupoff_settings[] = {
-	{0x3208, 0x10},
-	{0x3208, 0xA0},
-};
-
-static struct msm_camera_i2c_reg_conf ov2720_prev_settings[] = {
-	{0x3800, 0x00},
-	{0x3801, 0x02},
-	{0x3802, 0x00},
-	{0x3803, 0x00},
-	{0x3804, 0x07},
-	{0x3805, 0xA1},
-	{0x3806, 0x04},
-	{0x3807, 0x47},
-	{0x3810, 0x00},
-	{0x3811, 0x09},
-	{0x3812, 0x00},
-	{0x3813, 0x02},
-	{0x3820, 0x80},
-	{0x3821, 0x06},
-	{0x3814, 0x11},
-	{0x3815, 0x11},
-	{0x3612, 0x0b},
-	{0x3618, 0x04},
-	{0x3a08, 0x01},
-	{0x3a09, 0x50},
-	{0x3a0a, 0x01},
-	{0x3a0b, 0x18},
-	{0x3a0d, 0x03},
-	{0x3a0e, 0x03},
-	{0x4520, 0x00},
-	{0x4837, 0x1b},
-	{0x3000, 0xff},
-	{0x3001, 0xff},
-	{0x3002, 0xf0},
-	{0x3600, 0x08},
-	{0x3621, 0xc0},
-	{0x3632, 0xd2},
-	{0x3633, 0x23},
-	{0x3634, 0x54},
-	{0x3f01, 0x0c},
-	{0x5001, 0xc1},
-	{0x3614, 0xf0},
-	{0x3630, 0x2d},
-	{0x370b, 0x62},
-	{0x3706, 0x61},
-	{0x4000, 0x02},
-	{0x4002, 0xc5},
-	{0x4005, 0x08},
-	{0x404f, 0x84},
-	{0x4051, 0x00},
-	{0x5000, 0xcf},
-	{0x3a18, 0x00},
-	{0x3a19, 0x80},
-	{0x3503, 0x03},
-	{0x4521, 0x00},
-	{0x5183, 0xb0},
-	{0x5184, 0xb0},
-	{0x5185, 0xb0},
-	{0x370c, 0x0c},
-	{0x3035, 0x10},
-	{0x3036, 0x1e},
-	{0x3037, 0x21},
-	{0x303e, 0x19},
-	{0x3038, 0x06},
-	{0x3018, 0x04},
-	{0x3000, 0x00},
-	{0x3001, 0x00},
-	{0x3002, 0x00},
-	{0x3a0f, 0x40},
-	{0x3a10, 0x38},
-	{0x3a1b, 0x48},
-	{0x3a1e, 0x30},
-	{0x3a11, 0x90},
-	{0x3a1f, 0x10},
-	{0x4800, 0x24},
-};
-
-static struct msm_camera_i2c_reg_conf ov2720_720_settings[] = {
-	{0x3800, 0x01},
-	{0x3801, 0x4a},
-	{0x3802, 0x00},
-	{0x3803, 0xba},
-	{0x3804, 0x06},
-	{0x3805, 0x51+32},
-	{0x3806, 0x03},
-	{0x3807, 0x8d+24},
-	{0x3810, 0x00},
-	{0x3811, 0x05},
-	{0x3812, 0x00},
-	{0x3813, 0x02},
-	{0x3820, 0x80},
-	{0x3821, 0x06},
-	{0x3814, 0x11},
-	{0x3815, 0x11},
-	{0x3612, 0x0b},
-	{0x3618, 0x04},
-	{0x3a08, 0x01},
-	{0x3a09, 0x50},
-	{0x3a0a, 0x01},
-	{0x3a0b, 0x18},
-	{0x3a0d, 0x03},
-	{0x3a0e, 0x03},
-	{0x4520, 0x00},
-	{0x4837, 0x1b},
-	{0x3000, 0xff},
-	{0x3001, 0xff},
-	{0x3002, 0xf0},
-	{0x3600, 0x08},
-	{0x3621, 0xc0},
-	{0x3632, 0xd2},
-	{0x3633, 0x23},
-	{0x3634, 0x54},
-	{0x3f01, 0x0c},
-	{0x5001, 0xc1},
-	{0x3614, 0xf0},
-	{0x3630, 0x2d},
-	{0x370b, 0x62},
-	{0x3706, 0x61},
-	{0x4000, 0x02},
-	{0x4002, 0xc5},
-	{0x4005, 0x08},
-	{0x404f, 0x84},
-	{0x4051, 0x00},
-	{0x5000, 0xff},
-	{0x3a18, 0x00},
-	{0x3a19, 0x80},
-	{0x3503, 0x13},
-	{0x4521, 0x00},
-	{0x5183, 0xb0},
-	{0x5184, 0xb0},
-	{0x5185, 0xb0},
-	{0x370c, 0x0c},
-	{0x3035, 0x10},
-	{0x3036, 0x04},
-	{0x3037, 0x61},
-	{0x303e, 0x19},
-	{0x3038, 0x06},
-	{0x3018, 0x04},
-	{0x3000, 0x00},
-	{0x3001, 0x00},
-	{0x3002, 0x00},
-	{0x3a0f, 0x40},
-	{0x3a10, 0x38},
-	{0x3a1b, 0x48},
-	{0x3a1e, 0x30},
-	{0x3a11, 0x90},
-	{0x3a1f, 0x10},
-	{0x4800, 0x24},
-};
-
-static struct msm_camera_i2c_reg_conf ov2720_vga_settings[] = {
-	{0x3800, 0x00},
-	{0x3801, 0x0c},
-	{0x3802, 0x00},
-	{0x3803, 0x02},
-	{0x3804, 0x07},
-	{0x3805, 0x97+32},
-	{0x3806, 0x04},
-	{0x3807, 0x45+24},
-	{0x3810, 0x00},
-	{0x3811, 0x03},
-	{0x3812, 0x00},
-	{0x3813, 0x03},
-	{0x3820, 0x80},
-	{0x3821, 0x06},
-	{0x3814, 0x11},
-	{0x3815, 0x11},
-	{0x3612, 0x0b},
-	{0x3618, 0x04},
-	{0x3a08, 0x01},
-	{0x3a09, 0x50},
-	{0x3a0a, 0x01},
-	{0x3a0b, 0x18},
-	{0x3a0d, 0x03},
-	{0x3a0e, 0x03},
-	{0x4520, 0x00},
-	{0x4837, 0x1b},
-	{0x3000, 0xff},
-	{0x3001, 0xff},
-	{0x3002, 0xf0},
-	{0x3600, 0x08},
-	{0x3621, 0xc0},
-	{0x3632, 0xd2},
-	{0x3633, 0x23},
-	{0x3634, 0x54},
-	{0x3f01, 0x0c},
-	{0x5001, 0xc1},
-	{0x3614, 0xf0},
-	{0x3630, 0x2d},
-	{0x370b, 0x62},
-	{0x3706, 0x61},
-	{0x4000, 0x02},
-	{0x4002, 0xc5},
-	{0x4005, 0x08},
-	{0x404f, 0x84},
-	{0x4051, 0x00},
-	{0x5000, 0xff},
-	{0x3a18, 0x00},
-	{0x3a19, 0x80},
-	{0x3503, 0x13},
-	{0x4521, 0x00},
-	{0x5183, 0xb0},
-	{0x5184, 0xb0},
-	{0x5185, 0xb0},
-	{0x370c, 0x0c},
-	{0x3035, 0x10},
-	{0x3036, 0x04},
-	{0x3037, 0x61},
-	{0x303e, 0x19},
-	{0x3038, 0x06},
-	{0x3018, 0x04},
-	{0x3000, 0x00},
-	{0x3001, 0x00},
-	{0x3002, 0x00},
-	{0x3a0f, 0x40},
-	{0x3a10, 0x38},
-	{0x3a1b, 0x48},
-	{0x3a1e, 0x30},
-	{0x3a11, 0x90},
-	{0x3a1f, 0x10},
-	{0x4800, 0x24},
-	{0x3500, 0x00},
-	{0x3501, 0x17},
-	{0x3502, 0xf0},
-	{0x3508, 0x00},
-	{0x3509, 0x20},
-};
-
-static struct msm_camera_i2c_reg_conf ov2720_60fps_settings[] = {
-	{0x3718, 0x10},
-	{0x3702, 0x18},
-	{0x373a, 0x3c},
-	{0x3715, 0x01},
-	{0x3703, 0x1d},
-	{0x3705, 0x0b},
-	{0x3730, 0x1f},
-	{0x3704, 0x3f},
-	{0x3f06, 0x1d},
-	{0x371c, 0x00},
-	{0x371d, 0x83},
-	{0x371e, 0x00},
-	{0x371f, 0xb6},
-	{0x3708, 0x63},
-	{0x3709, 0x52},
-	{0x3800, 0x01},
-	{0x3801, 0x42},
-	{0x3802, 0x00},
-	{0x3803, 0x40},
-	{0x3804, 0x06},
-	{0x3805, 0x61},
-	{0x3806, 0x04},
-	{0x3807, 0x08},
-	{0x3808, 0x02},
-	{0x3809, 0x80},
-	{0x380a, 0x01},
-	{0x380b, 0xe0},
-	{0x380c, 0x03},
-	{0x380d, 0x0c},
-	{0x380e, 0x02},
-	{0x380f, 0x00},
-	{0x3810, 0x00},
-	{0x3811, 0x0f},
-	{0x3812, 0x00},
-	{0x3813, 0x02},
-	{0x3820, 0x80},
-	{0x3821, 0x06},
-	{0x3814, 0x31},
-	{0x3815, 0x31},
-	{0x3612, 0x0b},
-	{0x3618, 0x04},
-	{0x3a08, 0x02},
-	{0x3a09, 0x67},
-	{0x3a0a, 0x02},
-	{0x3a0b, 0x00},
-	{0x3a0d, 0x00},
-	{0x3a0e, 0x00},
-	{0x4520, 0x0a},
-	{0x4837, 0x29},
-	{0x3000, 0xff},
-	{0x3001, 0xff},
-	{0x3002, 0xf0},
-	{0x3600, 0x08},
-	{0x3621, 0xc0},
-	{0x3632, 0xd2},
-	{0x3633, 0x23},
-	{0x3634, 0x54},
-	{0x3f01, 0x0c},
-	{0x5001, 0xc1},
-	{0x3614, 0xf0},
-	{0x3630, 0x2d},
-	{0x370b, 0x62},
-	{0x3706, 0x61},
-	{0x4000, 0x02},
-	{0x4002, 0xc5},
-	{0x4005, 0x08},
-	{0x404f, 0x84},
-	{0x4051, 0x00},
-	{0x5000, 0xcf},
-	{0x3a18, 0x00},
-	{0x3a19, 0x80},
-	{0x3503, 0x07},
-	{0x4521, 0x00},
-	{0x5183, 0xb0},
-	{0x5184, 0xb0},
-	{0x5185, 0xb0},
-	{0x370c, 0x0c},
-	{0x3035, 0x30},
-	{0x3036, 0x14},
-	{0x3037, 0x21},
-	{0x303e, 0x19},
-	{0x3038, 0x06},
-	{0x3018, 0x04},
-	{0x3000, 0x00},
-	{0x3001, 0x00},
-	{0x3002, 0x00},
-	{0x3a0f, 0x40},
-	{0x3a10, 0x38},
-	{0x3a1b, 0x48},
-	{0x3a1e, 0x30},
-	{0x3a11, 0x90},
-	{0x3a1f, 0x10},
-	{0x3011, 0x22},
-	{0x3a00, 0x58},
-};
-
-static struct msm_camera_i2c_reg_conf ov2720_90fps_settings[] = {
-	{0x3718, 0x10},
-	{0x3702, 0x18},
-	{0x373a, 0x3c},
-	{0x3715, 0x01},
-	{0x3703, 0x1d},
-	{0x3705, 0x0b},
-	{0x3730, 0x1f},
-	{0x3704, 0x3f},
-	{0x3f06, 0x1d},
-	{0x371c, 0x00},
-	{0x371d, 0x83},
-	{0x371e, 0x00},
-	{0x371f, 0xb6},
-	{0x3708, 0x63},
-	{0x3709, 0x52},
-	{0x3800, 0x01},
-	{0x3801, 0x42},
-	{0x3802, 0x00},
-	{0x3803, 0x40},
-	{0x3804, 0x06},
-	{0x3805, 0x61},
-	{0x3806, 0x04},
-	{0x3807, 0x08},
-	{0x3808, 0x02},
-	{0x3809, 0x80},
-	{0x380a, 0x01},
-	{0x380b, 0xe0},
-	{0x380c, 0x03},
-	{0x380d, 0x0c},
-	{0x380e, 0x02},
-	{0x380f, 0x00},
-	{0x3810, 0x00},
-	{0x3811, 0x0f},
-	{0x3812, 0x00},
-	{0x3813, 0x02},
-	{0x3820, 0x80},
-	{0x3821, 0x06},
-	{0x3814, 0x31},
-	{0x3815, 0x31},
-	{0x3612, 0x0b},
-	{0x3618, 0x04},
-	{0x3a08, 0x02},
-	{0x3a09, 0x67},
-	{0x3a0a, 0x02},
-	{0x3a0b, 0x00},
-	{0x3a0d, 0x00},
-	{0x3a0e, 0x00},
-	{0x4520, 0x0a},
-	{0x4837, 0x29},
-	{0x3000, 0xff},
-	{0x3001, 0xff},
-	{0x3002, 0xf0},
-	{0x3600, 0x08},
-	{0x3621, 0xc0},
-	{0x3632, 0xd2},
-	{0x3633, 0x23},
-	{0x3634, 0x54},
-	{0x3f01, 0x0c},
-	{0x5001, 0xc1},
-	{0x3614, 0xf0},
-	{0x3630, 0x2d},
-	{0x370b, 0x62},
-	{0x3706, 0x61},
-	{0x4000, 0x02},
-	{0x4002, 0xc5},
-	{0x4005, 0x08},
-	{0x404f, 0x84},
-	{0x4051, 0x00},
-	{0x5000, 0xcf},
-	{0x3a18, 0x00},
-	{0x3a19, 0x80},
-	{0x3503, 0x07},
-	{0x4521, 0x00},
-	{0x5183, 0xb0},
-	{0x5184, 0xb0},
-	{0x5185, 0xb0},
-	{0x370c, 0x0c},
-	{0x3035, 0x30},
-	{0x3036, 0x1e},
-	{0x3037, 0x21},
-	{0x303e, 0x19},
-	{0x3038, 0x06},
-	{0x3018, 0x04},
-	{0x3000, 0x00},
-	{0x3001, 0x00},
-	{0x3002, 0x00},
-	{0x3a0f, 0x40},
-	{0x3a10, 0x38},
-	{0x3a1b, 0x48},
-	{0x3a1e, 0x30},
-	{0x3a11, 0x90},
-	{0x3a1f, 0x10},
-	{0x3011, 0x22},
-	{0x3a00, 0x58},
-};
-
-static struct msm_camera_i2c_reg_conf ov2720_120fps_settings[] = {
-	{0x3718, 0x10},
-	{0x3702, 0x18},
-	{0x373a, 0x3c},
-	{0x3715, 0x01},
-	{0x3703, 0x1d},
-	{0x3705, 0x0b},
-	{0x3730, 0x1f},
-	{0x3704, 0x3f},
-	{0x3f06, 0x1d},
-	{0x371c, 0x00},
-	{0x371d, 0x83},
-	{0x371e, 0x00},
-	{0x371f, 0xb6},
-	{0x3708, 0x63},
-	{0x3709, 0x52},
-	{0x3800, 0x01},
-	{0x3801, 0x42},
-	{0x3802, 0x00},
-	{0x3803, 0x40},
-	{0x3804, 0x06},
-	{0x3805, 0x61},
-	{0x3806, 0x04},
-	{0x3807, 0x08},
-	{0x3808, 0x02},
-	{0x3809, 0x80},
-	{0x380a, 0x01},
-	{0x380b, 0xe0},
-	{0x380c, 0x03},
-	{0x380d, 0x0c},
-	{0x380e, 0x02},
-	{0x380f, 0x00},
-	{0x3810, 0x00},
-	{0x3811, 0x0f},
-	{0x3812, 0x00},
-	{0x3813, 0x02},
-	{0x3820, 0x80},
-	{0x3821, 0x06},
-	{0x3814, 0x31},
-	{0x3815, 0x31},
-	{0x3612, 0x0b},
-	{0x3618, 0x04},
-	{0x3a08, 0x02},
-	{0x3a09, 0x67},
-	{0x3a0a, 0x02},
-	{0x3a0b, 0x00},
-	{0x3a0d, 0x00},
-	{0x3a0e, 0x00},
-	{0x4520, 0x0a},
-	{0x4837, 0x29},
-	{0x3000, 0xff},
-	{0x3001, 0xff},
-	{0x3002, 0xf0},
-	{0x3600, 0x08},
-	{0x3621, 0xc0},
-	{0x3632, 0xd2},
-	{0x3633, 0x23},
-	{0x3634, 0x54},
-	{0x3f01, 0x0c},
-	{0x5001, 0xc1},
-	{0x3614, 0xf0},
-	{0x3630, 0x2d},
-	{0x370b, 0x62},
-	{0x3706, 0x61},
-	{0x4000, 0x02},
-	{0x4002, 0xc5},
-	{0x4005, 0x08},
-	{0x404f, 0x84},
-	{0x4051, 0x00},
-	{0x5000, 0xcf},
-	{0x3a18, 0x00},
-	{0x3a19, 0x80},
-	{0x3503, 0x07},
-	{0x4521, 0x00},
-	{0x5183, 0xb0},
-	{0x5184, 0xb0},
-	{0x5185, 0xb0},
-	{0x370c, 0x0c},
-	{0x3035, 0x10},
-	{0x3036, 0x14},
-	{0x3037, 0x21},
-	{0x303e, 0x19},
-	{0x3038, 0x06},
-	{0x3018, 0x04},
-	{0x3000, 0x00},
-	{0x3001, 0x00},
-	{0x3002, 0x00},
-	{0x3a0f, 0x40},
-	{0x3a10, 0x38},
-	{0x3a1b, 0x48},
-	{0x3a1e, 0x30},
-	{0x3a11, 0x90},
-	{0x3a1f, 0x10},
-	{0x3011, 0x22},
-	{0x3a00, 0x58},
-};
-
-static struct msm_camera_i2c_reg_conf ov2720_recommend_settings[] = {
-	{0x0103, 0x01},
-	{0x3718, 0x10},
-	{0x3702, 0x24},
-	{0x373a, 0x60},
-	{0x3715, 0x01},
-	{0x3703, 0x2e},
-	{0x3705, 0x10},
-	{0x3730, 0x30},
-	{0x3704, 0x62},
-	{0x3f06, 0x3a},
-	{0x371c, 0x00},
-	{0x371d, 0xc4},
-	{0x371e, 0x01},
-	{0x371f, 0x0d},
-	{0x3708, 0x61},
-	{0x3709, 0x12},
-};
-
-static struct v4l2_subdev_info ov2720_subdev_info[] = {
-	{
-	.code   = V4L2_MBUS_FMT_SBGGR10_1X10,
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	.fmt    = 1,
-	.order    = 0,
-	},
-	/* more can be supported, to be added later */
-};
-
-static struct msm_camera_i2c_conf_array ov2720_init_conf[] = {
-	{&ov2720_recommend_settings[0],
-	ARRAY_SIZE(ov2720_recommend_settings), 0, MSM_CAMERA_I2C_BYTE_DATA}
-};
-
-static struct msm_camera_i2c_conf_array ov2720_confs[] = {
-	{&ov2720_prev_settings[0],
-	ARRAY_SIZE(ov2720_prev_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-	{&ov2720_vga_settings[0],
-	ARRAY_SIZE(ov2720_vga_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-	{&ov2720_720_settings[0],
-	ARRAY_SIZE(ov2720_720_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-	{&ov2720_60fps_settings[0],
-	ARRAY_SIZE(ov2720_60fps_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-	{&ov2720_90fps_settings[0],
-	ARRAY_SIZE(ov2720_90fps_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-	{&ov2720_120fps_settings[0],
-	ARRAY_SIZE(ov2720_120fps_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-};
-
-static struct msm_sensor_output_info_t ov2720_dimensions[] = {
-	{
-		.x_output = 0x78C,
-		.y_output = 0x444,
-		.line_length_pclk = 0x85c,
-		.frame_length_lines = 0x460,
-		.vt_pixel_clk = 72000000,
-		.op_pixel_clk = 72000000,
-		.binning_factor = 1,
-	},
-	{
-		.x_output = 0x510,
-		.y_output = 0x278,
-		.line_length_pclk = 0x85c,
-		.frame_length_lines = 0x460,
-		.vt_pixel_clk = 72000000,
-		.op_pixel_clk = 72000000,
-		.binning_factor = 1,
-	},
-	{
-		.x_output = 0x298,
-		.y_output = 0x1F2,
-		.line_length_pclk = 0x85c,
-		.frame_length_lines = 0x460,
-		.vt_pixel_clk = 72000000,
-		.op_pixel_clk = 72000000,
-		.binning_factor = 1,
-	},
-	{
-		.x_output = 0x280, /* 640 */
-		.y_output = 0x1E0, /* 480 */
-		.line_length_pclk = 0x30C, /* 780 */
-		.frame_length_lines = 0x200, /* 512 */
-		.vt_pixel_clk = 24000000,
-		.op_pixel_clk = 24000000,
-		.binning_factor = 1,
-	},
-	{
-		.x_output = 0x280, /* 640 */
-		.y_output = 0x1E0, /* 480 */
-		.line_length_pclk = 0x30C, /* 780 */
-		.frame_length_lines = 0x200, /* 512 */
-		.vt_pixel_clk = 36000000,
-		.op_pixel_clk = 36000000,
-		.binning_factor = 1,
-	},
-	{
-		.x_output = 0x280, /* 640 */
-		.y_output = 0x1E0, /* 480 */
-		.line_length_pclk = 0x30C, /* 780 */
-		.frame_length_lines = 0x200, /* 512 */
-		.vt_pixel_clk = 48000000,
-		.op_pixel_clk = 48000000,
-		.binning_factor = 1,
-	},
-};
-
-static struct msm_sensor_output_reg_addr_t ov2720_reg_addr = {
-	.x_output = 0x3808,
-	.y_output = 0x380a,
-	.line_length_pclk = 0x380c,
-	.frame_length_lines = 0x380e,
-};
-
-static struct msm_sensor_id_info_t ov2720_id_info = {
-	.sensor_id_reg_addr = 0x300A,
-	.sensor_id = 0x2720,
-};
-
-static struct msm_sensor_exp_gain_info_t ov2720_exp_gain_info = {
-	.coarse_int_time_addr = 0x3501,
-	.global_gain_addr = 0x3508,
-	.vert_offset = 6,
-};
-
-static enum msm_camera_vreg_name_t ov2720_veg_seq[] = {
-	CAM_VIO,
-	CAM_VANA,
-	CAM_VDIG,
-};
-
-static int32_t ov2720_write_exp_gain(struct msm_sensor_ctrl_t *s_ctrl,
-		uint16_t gain, uint32_t line)
-{
-	uint32_t fl_lines, offset;
-	uint8_t int_time[3];
-	fl_lines =
-		(s_ctrl->curr_frame_length_lines * s_ctrl->fps_divider) / Q10;
-	offset = s_ctrl->sensor_exp_gain_info->vert_offset;
-	if (line > (fl_lines - offset))
-		fl_lines = line + offset;
-
-	s_ctrl->func_tbl->sensor_group_hold_on(s_ctrl);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_output_reg_addr->frame_length_lines, fl_lines,
-		MSM_CAMERA_I2C_WORD_DATA);
-	int_time[0] = line >> 12;
-	int_time[1] = line >> 4;
-	int_time[2] = line << 4;
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->coarse_int_time_addr-1,
-		int_time[0], MSM_CAMERA_I2C_BYTE_DATA);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->coarse_int_time_addr,
-		int_time[1], MSM_CAMERA_I2C_BYTE_DATA);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->coarse_int_time_addr+1,
-		int_time[2], MSM_CAMERA_I2C_BYTE_DATA);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->global_gain_addr, gain,
-		MSM_CAMERA_I2C_WORD_DATA);
-	s_ctrl->func_tbl->sensor_group_hold_off(s_ctrl);
-	return 0;
-}
-
-static const struct i2c_device_id ov2720_i2c_id[] = {
-	{SENSOR_NAME, (kernel_ulong_t)&ov2720_s_ctrl},
-	{ }
-};
-
-static struct i2c_driver ov2720_i2c_driver = {
-	.id_table = ov2720_i2c_id,
-	.probe  = msm_sensor_i2c_probe,
-	.driver = {
-		.name = SENSOR_NAME,
-	},
-};
-
-static struct msm_camera_i2c_client ov2720_sensor_i2c_client = {
-	.addr_type = MSM_CAMERA_I2C_WORD_ADDR,
-};
-
-
-static const struct of_device_id ov2720_dt_match[] = {
-	{.compatible = "qcom,ov2720", .data = &ov2720_s_ctrl},
-	{}
-};
-
-MODULE_DEVICE_TABLE(of, ov2720_dt_match);
-
-static struct platform_driver ov2720_platform_driver = {
-	.driver = {
-		.name = "qcom,ov2720",
-		.owner = THIS_MODULE,
-		.of_match_table = ov2720_dt_match,
-	},
-};
-
-static int32_t ov2720_platform_probe(struct platform_device *pdev)
-{
-	int32_t rc = 0;
-	const struct of_device_id *match;
-	match = of_match_device(ov2720_dt_match, &pdev->dev);
-	rc = msm_sensor_platform_probe(pdev, match->data);
-	return rc;
-}
-
-static int __init msm_sensor_init_module(void)
-{
-	int32_t rc = 0;
-	rc = platform_driver_probe(&ov2720_platform_driver,
-		ov2720_platform_probe);
-	if (!rc)
-		return rc;
-	return i2c_add_driver(&ov2720_i2c_driver);
-}
-
-static void __exit msm_sensor_exit_module(void)
-{
-	if (ov2720_s_ctrl.pdev) {
-		msm_sensor_free_sensor_data(&ov2720_s_ctrl);
-		platform_driver_unregister(&ov2720_platform_driver);
-	} else
-		i2c_del_driver(&ov2720_i2c_driver);
-	return;
-}
-
-static struct v4l2_subdev_core_ops ov2720_subdev_core_ops = {
-	.ioctl = msm_sensor_subdev_ioctl,
-	.s_power = msm_sensor_power,
-};
-
-static struct v4l2_subdev_video_ops ov2720_subdev_video_ops = {
-	.enum_mbus_fmt = msm_sensor_v4l2_enum_fmt,
-};
-
-static struct v4l2_subdev_ops ov2720_subdev_ops = {
-	.core = &ov2720_subdev_core_ops,
-	.video  = &ov2720_subdev_video_ops,
-};
-
-static struct msm_sensor_fn_t ov2720_func_tbl = {
-	.sensor_start_stream = msm_sensor_start_stream,
-	.sensor_stop_stream = msm_sensor_stop_stream,
-	.sensor_group_hold_on = msm_sensor_group_hold_on,
-	.sensor_group_hold_off = msm_sensor_group_hold_off,
-	.sensor_set_fps = msm_sensor_set_fps,
-	.sensor_write_exp_gain = ov2720_write_exp_gain,
-	.sensor_write_snapshot_exp_gain = ov2720_write_exp_gain,
-	.sensor_setting = msm_sensor_setting,
-	.sensor_set_sensor_mode = msm_sensor_set_sensor_mode,
-	.sensor_mode_init = msm_sensor_mode_init,
-	.sensor_get_output_info = msm_sensor_get_output_info,
-	.sensor_config = msm_sensor_config,
-	.sensor_power_up = msm_sensor_power_up,
-	.sensor_power_down = msm_sensor_power_down,
-	.sensor_adjust_frame_lines = msm_sensor_adjust_frame_lines2,
-	.sensor_get_csi_params = msm_sensor_get_csi_params,
-};
-
-static struct msm_sensor_reg_t ov2720_regs = {
-	.default_data_type = MSM_CAMERA_I2C_BYTE_DATA,
-	.start_stream_conf = ov2720_start_settings,
-	.start_stream_conf_size = ARRAY_SIZE(ov2720_start_settings),
-	.stop_stream_conf = ov2720_stop_settings,
-	.stop_stream_conf_size = ARRAY_SIZE(ov2720_stop_settings),
-	.group_hold_on_conf = ov2720_groupon_settings,
-	.group_hold_on_conf_size = ARRAY_SIZE(ov2720_groupon_settings),
-	.group_hold_off_conf = ov2720_groupoff_settings,
-	.group_hold_off_conf_size =
-		ARRAY_SIZE(ov2720_groupoff_settings),
-	.init_settings = &ov2720_init_conf[0],
-	.init_size = ARRAY_SIZE(ov2720_init_conf),
-	.mode_settings = &ov2720_confs[0],
-	.output_settings = &ov2720_dimensions[0],
-	.num_conf = ARRAY_SIZE(ov2720_confs),
-};
-
-static struct msm_sensor_ctrl_t ov2720_s_ctrl = {
-	.msm_sensor_reg = &ov2720_regs,
-	.sensor_i2c_client = &ov2720_sensor_i2c_client,
-	.sensor_i2c_addr = 0x6C,
-	.vreg_seq = ov2720_veg_seq,
-	.num_vreg_seq = ARRAY_SIZE(ov2720_veg_seq),
-	.sensor_output_reg_addr = &ov2720_reg_addr,
-	.sensor_id_info = &ov2720_id_info,
-	.sensor_exp_gain_info = &ov2720_exp_gain_info,
-	.cam_mode = MSM_SENSOR_MODE_INVALID,
-	.msm_sensor_mutex = &ov2720_mut,
-	.sensor_i2c_driver = &ov2720_i2c_driver,
-	.sensor_v4l2_subdev_info = ov2720_subdev_info,
-	.sensor_v4l2_subdev_info_size = ARRAY_SIZE(ov2720_subdev_info),
-	.sensor_v4l2_subdev_ops = &ov2720_subdev_ops,
-	.func_tbl = &ov2720_func_tbl,
-	.clk_rate = MSM_SENSOR_MCLK_24HZ,
-};
-
-module_init(msm_sensor_init_module);
-module_exit(msm_sensor_exit_module);
-MODULE_DESCRIPTION("Omnivision 2MP Bayer sensor driver");
-MODULE_LICENSE("GPL v2");
-
-
diff --git a/drivers/media/platform/msm/camera_v1/sensors/ov2720.h b/drivers/media/platform/msm/camera_v1/sensors/ov2720.h
deleted file mode 100644
index 6b47666..0000000
--- a/drivers/media/platform/msm/camera_v1/sensors/ov2720.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- *
- */
-
-#include <mach/board.h>
-extern struct platform_driver ov2720_driver;
-
diff --git a/drivers/media/platform/msm/camera_v1/sensors/ov5647_v4l2.c b/drivers/media/platform/msm/camera_v1/sensors/ov5647_v4l2.c
deleted file mode 100644
index f27e648..0000000
--- a/drivers/media/platform/msm/camera_v1/sensors/ov5647_v4l2.c
+++ /dev/null
@@ -1,831 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- *
- */
-
-#include "msm_sensor.h"
-#include "msm.h"
-#define SENSOR_NAME "ov5647"
-#define PLATFORM_DRIVER_NAME "msm_camera_ov5647"
-#define ov5647_obj ov5647_##obj
-
-static struct msm_sensor_ctrl_t ov5647_s_ctrl;
-
-DEFINE_MUTEX(ov5647_mut);
-
-static struct msm_camera_i2c_reg_conf ov5647_start_settings[] = {
-	{0x4202, 0x00},  /* streaming on */
-	{0x0100, 0x01},
-	{0x4800, 0x04},
-};
-
-static struct msm_camera_i2c_reg_conf ov5647_stop_settings[] = {
-	{0x4202, 0x0f},  /* streaming off*/
-};
-
-static struct msm_camera_i2c_reg_conf ov5647_groupon_settings[] = {
-	{0x3208, 0x0},
-};
-
-static struct msm_camera_i2c_reg_conf ov5647_groupoff_settings[] = {
-	{0x3208, 0x10},
-	{0x3208, 0xa0},
-};
-
-static struct msm_camera_i2c_reg_conf ov5647_prev_settings[] = {
-	/*1280*960 Reference Setting 24M MCLK 2lane 280Mbps/lane 30fps
-	for back to preview*/
-	{0x3035, 0x21},
-	{0x3036, 0x37},
-	{0x3821, 0x07},
-	{0x3820, 0x41},
-	{0x3612, 0x09},
-	{0x3618, 0x00},
-	{0x380c, 0x07},
-	{0x380d, 0x68},
-	{0x380e, 0x03},
-	{0x380f, 0xd8},
-	{0x3814, 0x31},
-	{0x3815, 0x31},
-	{0x3709, 0x52},
-	{0x3808, 0x05},
-	{0x3809, 0x00},
-	{0x380a, 0x03},
-	{0x380b, 0xc0},
-	{0x3800, 0x00},
-	{0x3801, 0x18},
-	{0x3802, 0x00},
-	{0x3803, 0x0e},
-	{0x3804, 0x0a},
-	{0x3805, 0x27},
-	{0x3806, 0x07},
-	{0x3807, 0x95},
-	{0x4004, 0x02},
-};
-
-static struct msm_camera_i2c_reg_conf ov5647_snap_settings[] = {
-	/*2608*1952 Reference Setting 24M MCLK 2lane 280Mbps/lane 30fps*/
-	{0x3035, 0x21},
-	{0x3036, 0x4f},
-	{0x3821, 0x06},
-	{0x3820, 0x00},
-	{0x3612, 0x0b},
-	{0x3618, 0x04},
-	{0x380c, 0x0a},
-	{0x380d, 0x8c},
-	{0x380e, 0x07},
-	{0x380f, 0xb0},
-	{0x3814, 0x11},
-	{0x3815, 0x11},
-	{0x3709, 0x12},
-	{0x3808, 0x0a},
-	{0x3809, 0x30},
-	{0x380a, 0x07},
-	{0x380b, 0xa0},
-	{0x3800, 0x00},
-	{0x3801, 0x04},
-	{0x3802, 0x00},
-	{0x3803, 0x00},
-	{0x3804, 0x0a},
-	{0x3805, 0x3b},
-	{0x3806, 0x07},
-	{0x3807, 0xa3},
-	{0x4004, 0x04},
-};
-
-static struct msm_camera_i2c_reg_conf ov5647_video_60fps_settings[] = {
-	{0x3035, 0x21},
-	{0x3036, 0x38},
-	{0x3821, 0x07},
-	{0x3820, 0x41},
-	{0x3612, 0x49},
-	{0x3618, 0x00},
-	{0x380c, 0x07},
-	{0x380d, 0x30},
-	{0x380e, 0x01},
-	{0x380f, 0xf8},
-	{0x3814, 0x71},
-	{0x3815, 0x71},
-	{0x3709, 0x52},
-	{0x3808, 0x02},
-	{0x3809, 0x80},
-	{0x380a, 0x01},
-	{0x380b, 0xe0},
-	{0x3800, 0x00},
-	{0x3801, 0x10},
-	{0x3802, 0x00},
-	{0x3803, 0x00},
-	{0x3804, 0x0a},
-	{0x3805, 0x2f},
-	{0x3806, 0x07},
-	{0x3807, 0x9f},
-	{0x4004, 0x02},
-};
-
-static struct msm_camera_i2c_reg_conf ov5647_video_90fps_settings[] = {
-	{0x3035, 0x11},
-	{0x3036, 0x2a},
-	{0x3821, 0x07},
-	{0x3820, 0x41},
-	{0x3612, 0x49},
-	{0x3618, 0x00},
-	{0x380c, 0x07},
-	{0x380d, 0x30},
-	{0x380e, 0x01},
-	{0x380f, 0xf8},
-	{0x3814, 0x71},
-	{0x3815, 0x71},
-	{0x3709, 0x52},
-	{0x3808, 0x02},
-	{0x3809, 0x80},
-	{0x380a, 0x01},
-	{0x380b, 0xe0},
-	{0x3800, 0x00},
-	{0x3801, 0x10},
-	{0x3802, 0x00},
-	{0x3803, 0x00},
-	{0x3804, 0x0a},
-	{0x3805, 0x2f},
-	{0x3806, 0x07},
-	{0x3807, 0x9f},
-	{0x4004, 0x02},
-};
-
-static struct msm_camera_i2c_reg_conf ov5647_zsl_settings[] = {
-	{0x3035, 0x21},
-	{0x3036, 0x4f},
-	{0x3821, 0x06},
-	{0x3820, 0x00},
-	{0x3612, 0x0b},
-	{0x3618, 0x04},
-	{0x380c, 0x0a},
-	{0x380d, 0x8c},
-	{0x380e, 0x07},
-	{0x380f, 0xb0},
-	{0x3814, 0x11},
-	{0x3815, 0x11},
-	{0x3709, 0x12},
-	{0x3808, 0x0a},
-	{0x3809, 0x30},
-	{0x380a, 0x07},
-	{0x380b, 0xa0},
-	{0x3800, 0x00},
-	{0x3801, 0x04},
-	{0x3802, 0x00},
-	{0x3803, 0x00},
-	{0x3804, 0x0a},
-	{0x3805, 0x3b},
-	{0x3806, 0x07},
-	{0x3807, 0xa3},
-	{0x4004, 0x04},
-};
-
-static struct msm_camera_i2c_reg_conf ov5647_recommend_settings[] = {
-	{0x3035, 0x11},
-	{0x303c, 0x11},
-	{0x370c, 0x03},
-	{0x5000, 0x06},
-	{0x5003, 0x08},
-	{0x5a00, 0x08},
-	{0x3000, 0xff},
-	{0x3001, 0xff},
-	{0x3002, 0xff},
-	{0x301d, 0xf0},
-	{0x3a18, 0x00},
-	{0x3a19, 0xf8},
-	{0x3c01, 0x80},
-	{0x3b07, 0x0c},
-	{0x3708, 0x64},
-	{0x3630, 0x2e},
-	{0x3632, 0xe2},
-	{0x3633, 0x23},
-	{0x3634, 0x44},
-	{0x3620, 0x64},
-	{0x3621, 0xe0},
-	{0x3600, 0x37},
-	{0x3704, 0xa0},
-	{0x3703, 0x5a},
-	{0x3715, 0x78},
-	{0x3717, 0x01},
-	{0x3731, 0x02},
-	{0x370b, 0x60},
-	{0x3705, 0x1a},
-	{0x3f05, 0x02},
-	{0x3f06, 0x10},
-	{0x3f01, 0x0a},
-	{0x3a08, 0x01},
-	{0x3a0f, 0x58},
-	{0x3a10, 0x50},
-	{0x3a1b, 0x58},
-	{0x3a1e, 0x50},
-	{0x3a11, 0x60},
-	{0x3a1f, 0x28},
-	{0x4001, 0x02},
-	{0x4000, 0x09},
-	{0x3000, 0x00},
-	{0x3001, 0x00},
-	{0x3002, 0x00},
-	{0x3017, 0xe0},
-	{0x301c, 0xfc},
-	{0x3636, 0x06},
-	{0x3016, 0x08},
-	{0x3827, 0xec},
-	{0x3018, 0x44},
-	{0x3035, 0x21},
-	{0x3106, 0xf5},
-	{0x3034, 0x18},
-	{0x301c, 0xf8},
-	/*lens setting*/
-	{0x5000, 0x86},
-	{0x5800, 0x11},
-	{0x5801, 0x0c},
-	{0x5802, 0x0a},
-	{0x5803, 0x0b},
-	{0x5804, 0x0d},
-	{0x5805, 0x13},
-	{0x5806, 0x09},
-	{0x5807, 0x05},
-	{0x5808, 0x03},
-	{0x5809, 0x03},
-	{0x580a, 0x06},
-	{0x580b, 0x08},
-	{0x580c, 0x05},
-	{0x580d, 0x01},
-	{0x580e, 0x00},
-	{0x580f, 0x00},
-	{0x5810, 0x02},
-	{0x5811, 0x06},
-	{0x5812, 0x05},
-	{0x5813, 0x01},
-	{0x5814, 0x00},
-	{0x5815, 0x00},
-	{0x5816, 0x02},
-	{0x5817, 0x06},
-	{0x5818, 0x09},
-	{0x5819, 0x05},
-	{0x581a, 0x04},
-	{0x581b, 0x04},
-	{0x581c, 0x06},
-	{0x581d, 0x09},
-	{0x581e, 0x11},
-	{0x581f, 0x0c},
-	{0x5820, 0x0b},
-	{0x5821, 0x0b},
-	{0x5822, 0x0d},
-	{0x5823, 0x13},
-	{0x5824, 0x22},
-	{0x5825, 0x26},
-	{0x5826, 0x26},
-	{0x5827, 0x24},
-	{0x5828, 0x24},
-	{0x5829, 0x24},
-	{0x582a, 0x22},
-	{0x582b, 0x20},
-	{0x582c, 0x22},
-	{0x582d, 0x26},
-	{0x582e, 0x22},
-	{0x582f, 0x22},
-	{0x5830, 0x42},
-	{0x5831, 0x22},
-	{0x5832, 0x02},
-	{0x5833, 0x24},
-	{0x5834, 0x22},
-	{0x5835, 0x22},
-	{0x5836, 0x22},
-	{0x5837, 0x26},
-	{0x5838, 0x42},
-	{0x5839, 0x26},
-	{0x583a, 0x06},
-	{0x583b, 0x26},
-	{0x583c, 0x24},
-	{0x583d, 0xce},
-	/* manual AWB,manual AE,close Lenc,open WBC*/
-	{0x3503, 0x03}, /*manual AE*/
-	{0x3501, 0x10},
-	{0x3502, 0x80},
-	{0x350a, 0x00},
-	{0x350b, 0x7f},
-	{0x5001, 0x01}, /*manual AWB*/
-	{0x5180, 0x08},
-	{0x5186, 0x04},
-	{0x5187, 0x00},
-	{0x5188, 0x04},
-	{0x5189, 0x00},
-	{0x518a, 0x04},
-	{0x518b, 0x00},
-	{0x5000, 0x06}, /*No lenc,WBC on*/
-	{0x4005, 0x18},
-	{0x4051, 0x8f},
-};
-
-
-static struct msm_camera_i2c_conf_array ov5647_init_conf[] = {
-	{&ov5647_recommend_settings[0],
-	ARRAY_SIZE(ov5647_recommend_settings), 0, MSM_CAMERA_I2C_BYTE_DATA}
-};
-
-static struct msm_camera_i2c_conf_array ov5647_confs[] = {
-	{&ov5647_snap_settings[0],
-	ARRAY_SIZE(ov5647_snap_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-	{&ov5647_prev_settings[0],
-	ARRAY_SIZE(ov5647_prev_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-	{&ov5647_video_60fps_settings[0],
-	ARRAY_SIZE(ov5647_video_60fps_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-	{&ov5647_video_90fps_settings[0],
-	ARRAY_SIZE(ov5647_video_90fps_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-	{&ov5647_zsl_settings[0],
-	ARRAY_SIZE(ov5647_zsl_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-};
-
-static struct v4l2_subdev_info ov5647_subdev_info[] = {
-	{
-		.code   = V4L2_MBUS_FMT_SBGGR10_1X10,
-		.colorspace = V4L2_COLORSPACE_JPEG,
-		.fmt    = 1,
-		.order    = 0,
-	},
-	/* more can be supported, to be added later */
-};
-
-static struct msm_sensor_output_info_t ov5647_dimensions[] = {
-	{ /* For SNAPSHOT */
-		.x_output = 0xA30,  /*2608*/  /*for 5Mp*/
-		.y_output = 0x7A0,   /*1952*/
-		.line_length_pclk = 0xA8C,
-		.frame_length_lines = 0x7B0,
-		.vt_pixel_clk = 79704000,
-		.op_pixel_clk = 159408000,
-		.binning_factor = 0x0,
-	},
-	{ /* For PREVIEW */
-		.x_output = 0x500, /*1280*/
-		.y_output = 0x3C0, /*960*/
-		.line_length_pclk = 0x768,
-		.frame_length_lines = 0x3D8,
-		.vt_pixel_clk = 55969920,
-		.op_pixel_clk = 159408000,
-		.binning_factor = 0x0,
-	},
-	{ /* For 60fps */
-		.x_output = 0x280,  /*640*/
-		.y_output = 0x1E0,   /*480*/
-		.line_length_pclk = 0x73C,
-		.frame_length_lines = 0x1F8,
-		.vt_pixel_clk = 56004480,
-		.op_pixel_clk = 159408000,
-		.binning_factor = 0x0,
-	},
-	{ /* For 90fps */
-		.x_output = 0x280,  /*640*/
-		.y_output = 0x1E0,   /*480*/
-		.line_length_pclk = 0x73C,
-		.frame_length_lines = 0x1F8,
-		.vt_pixel_clk = 56004480,
-		.op_pixel_clk = 159408000,
-		.binning_factor = 0x0,
-	},
-	{ /* For ZSL */
-		.x_output = 0xA30,  /*2608*/  /*for 5Mp*/
-		.y_output = 0x7A0,   /*1952*/
-		.line_length_pclk = 0xA8C,
-		.frame_length_lines = 0x7B0,
-		.vt_pixel_clk = 79704000,
-		.op_pixel_clk = 159408000,
-		.binning_factor = 0x0,
-	},
-
-};
-
-static struct msm_sensor_output_reg_addr_t ov5647_reg_addr = {
-	.x_output = 0x3808,
-	.y_output = 0x380A,
-	.line_length_pclk = 0x380C,
-	.frame_length_lines = 0x380E,
-};
-
-static struct msm_sensor_id_info_t ov5647_id_info = {
-	.sensor_id_reg_addr = 0x300a,
-	.sensor_id = 0x5647,
-};
-
-static struct msm_sensor_exp_gain_info_t ov5647_exp_gain_info = {
-	.coarse_int_time_addr = 0x3500,
-	.global_gain_addr = 0x350A,
-	.vert_offset = 4,
-};
-
-void ov5647_sensor_reset_stream(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	msm_camera_i2c_write(
-		s_ctrl->sensor_i2c_client,
-		0x103, 0x1,
-		MSM_CAMERA_I2C_BYTE_DATA);
-}
-
-static int32_t ov5647_write_pict_exp_gain(struct msm_sensor_ctrl_t *s_ctrl,
-		uint16_t gain, uint32_t line)
-{
-
-	static uint16_t max_line = 1964;
-	uint8_t gain_lsb, gain_hsb;
-	u8 intg_time_hsb, intg_time_msb, intg_time_lsb;
-
-	gain_lsb = (uint8_t) (gain);
-	gain_hsb = (uint8_t)((gain & 0x300)>>8);
-
-	CDBG(KERN_ERR "snapshot exposure seting 0x%x, 0x%x, %d"
-		, gain, line, line);
-	s_ctrl->func_tbl->sensor_group_hold_on(s_ctrl);
-	if (line > 1964) {
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-			s_ctrl->sensor_output_reg_addr->frame_length_lines,
-			(uint8_t)((line+4) >> 8),
-			MSM_CAMERA_I2C_BYTE_DATA);
-
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-			s_ctrl->sensor_output_reg_addr->frame_length_lines + 1,
-			(uint8_t)((line+4) & 0x00FF),
-			MSM_CAMERA_I2C_BYTE_DATA);
-		max_line = line + 4;
-	} else if (max_line > 1968) {
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-			s_ctrl->sensor_output_reg_addr->frame_length_lines,
-			(uint8_t)(1968 >> 8),
-			MSM_CAMERA_I2C_BYTE_DATA);
-
-		 msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-			s_ctrl->sensor_output_reg_addr->frame_length_lines + 1,
-			(uint8_t)(1968 & 0x00FF),
-			MSM_CAMERA_I2C_BYTE_DATA);
-			max_line = 1968;
-	}
-
-
-	line = line<<4;
-	/* ov5647 need this operation */
-	intg_time_hsb = (u8)(line>>16);
-	intg_time_msb = (u8) ((line & 0xFF00) >> 8);
-	intg_time_lsb = (u8) (line & 0x00FF);
-
-	/* FIXME for BLC trigger */
-	/* Coarse Integration Time */
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->coarse_int_time_addr,
-		intg_time_hsb,
-		MSM_CAMERA_I2C_BYTE_DATA);
-
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->coarse_int_time_addr + 1,
-		intg_time_msb,
-		MSM_CAMERA_I2C_BYTE_DATA);
-
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->coarse_int_time_addr + 2,
-		intg_time_lsb,
-		MSM_CAMERA_I2C_BYTE_DATA);
-
-	/* gain */
-
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->global_gain_addr,
-		gain_hsb,
-		MSM_CAMERA_I2C_BYTE_DATA);
-
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->global_gain_addr + 1,
-		gain_lsb^0x1,
-		MSM_CAMERA_I2C_BYTE_DATA);
-
-	/* Coarse Integration Time */
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->coarse_int_time_addr,
-		intg_time_hsb,
-		MSM_CAMERA_I2C_BYTE_DATA);
-
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->coarse_int_time_addr + 1,
-		intg_time_msb,
-		MSM_CAMERA_I2C_BYTE_DATA);
-
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->coarse_int_time_addr + 2,
-		intg_time_lsb,
-		MSM_CAMERA_I2C_BYTE_DATA);
-
-	/* gain */
-
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->global_gain_addr,
-		gain_hsb,
-		MSM_CAMERA_I2C_BYTE_DATA);
-
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->global_gain_addr + 1,
-		gain_lsb,
-		MSM_CAMERA_I2C_BYTE_DATA);
-
-
-	s_ctrl->func_tbl->sensor_group_hold_off(s_ctrl);
-	return 0;
-
-}
-
-
-static int32_t ov5647_write_prev_exp_gain(struct msm_sensor_ctrl_t *s_ctrl,
-						uint16_t gain, uint32_t line)
-{
-	u8 intg_time_hsb, intg_time_msb, intg_time_lsb;
-	uint8_t gain_lsb, gain_hsb;
-	uint32_t fl_lines = s_ctrl->curr_frame_length_lines;
-	uint8_t offset = s_ctrl->sensor_exp_gain_info->vert_offset;
-
-	CDBG(KERN_ERR "preview exposure setting 0x%x, 0x%x, %d",
-		 gain, line, line);
-
-	gain_lsb = (uint8_t) (gain);
-	gain_hsb = (uint8_t)((gain & 0x300)>>8);
-
-	fl_lines = (fl_lines * s_ctrl->fps_divider) / Q10;
-
-	s_ctrl->func_tbl->sensor_group_hold_on(s_ctrl);
-
-	/* adjust frame rate */
-	if ((s_ctrl->curr_res < MSM_SENSOR_RES_2) &&
-		(line > (fl_lines - offset)))
-		fl_lines = line + offset;
-
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_output_reg_addr->frame_length_lines,
-		(uint8_t)(fl_lines >> 8),
-		MSM_CAMERA_I2C_BYTE_DATA);
-
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_output_reg_addr->frame_length_lines + 1,
-		(uint8_t)(fl_lines & 0x00FF),
-		MSM_CAMERA_I2C_BYTE_DATA);
-
-	line = line<<4;
-	/* ov5647 need this operation */
-	intg_time_hsb = (u8)(line>>16);
-	intg_time_msb = (u8) ((line & 0xFF00) >> 8);
-	intg_time_lsb = (u8) (line & 0x00FF);
-
-
-	/* Coarse Integration Time */
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->coarse_int_time_addr,
-		intg_time_hsb,
-		MSM_CAMERA_I2C_BYTE_DATA);
-
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->coarse_int_time_addr + 1,
-		intg_time_msb,
-		MSM_CAMERA_I2C_BYTE_DATA);
-
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->coarse_int_time_addr + 2,
-		intg_time_lsb,
-		MSM_CAMERA_I2C_BYTE_DATA);
-
-	/* gain */
-
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->global_gain_addr,
-		gain_hsb,
-		MSM_CAMERA_I2C_BYTE_DATA);
-
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->global_gain_addr + 1,
-		gain_lsb,
-		MSM_CAMERA_I2C_BYTE_DATA);
-
-	s_ctrl->func_tbl->sensor_group_hold_off(s_ctrl);
-
-	return 0;
-}
-
-static const struct i2c_device_id ov5647_i2c_id[] = {
-	{SENSOR_NAME, (kernel_ulong_t)&ov5647_s_ctrl},
-	{ }
-};
-int32_t ov5647_sensor_i2c_probe(struct i2c_client *client,
-		const struct i2c_device_id *id)
-{
-	int32_t rc = 0;
-	struct msm_sensor_ctrl_t *s_ctrl;
-
-	rc = msm_sensor_i2c_probe(client, id);
-
-	if (client->dev.platform_data == NULL) {
-		pr_err("%s: NULL sensor data\n", __func__);
-		return -EFAULT;
-	}
-
-	s_ctrl = client->dev.platform_data;
-
-	return rc;
-}
-
-static struct i2c_driver ov5647_i2c_driver = {
-	.id_table = ov5647_i2c_id,
-	.probe  = ov5647_sensor_i2c_probe,
-	.driver = {
-		.name = SENSOR_NAME,
-	},
-};
-
-
-
-static struct msm_camera_i2c_client ov5647_sensor_i2c_client = {
-	.addr_type = MSM_CAMERA_I2C_WORD_ADDR,
-};
-
-static int __init msm_sensor_init_module(void)
-{
-	return i2c_add_driver(&ov5647_i2c_driver);
-}
-
-static struct v4l2_subdev_core_ops ov5647_subdev_core_ops = {
-	.ioctl = msm_sensor_subdev_ioctl,
-	.s_power = msm_sensor_power,
-};
-
-static struct v4l2_subdev_video_ops ov5647_subdev_video_ops = {
-	.enum_mbus_fmt = msm_sensor_v4l2_enum_fmt,
-};
-
-static struct v4l2_subdev_ops ov5647_subdev_ops = {
-	.core = &ov5647_subdev_core_ops,
-	.video  = &ov5647_subdev_video_ops,
-};
-
-int32_t ov5647_sensor_power_down(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	struct msm_camera_sensor_info *info = NULL;
-	unsigned short rdata;
-	int rc;
-
-	info = s_ctrl->sensordata;
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		0x4202, 0xf,
-		MSM_CAMERA_I2C_BYTE_DATA);
-	msleep(20);
-	rc = msm_camera_i2c_read(s_ctrl->sensor_i2c_client, 0x3018,
-			&rdata, MSM_CAMERA_I2C_WORD_DATA);
-	CDBG("ov5647_sensor_power_down: %d\n", rc);
-	rdata |= 0x18;
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		0x3018, rdata,
-		MSM_CAMERA_I2C_WORD_DATA);
-	msleep(20);
-	gpio_direction_output(info->sensor_pwd, 1);
-	usleep_range(5000, 5100);
-	msm_sensor_power_down(s_ctrl);
-	return 0;
-}
-
-int32_t ov5647_sensor_power_up(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	int32_t rc = 0;
-	struct msm_camera_sensor_info *info = NULL;
-
-	info = s_ctrl->sensordata;
-	gpio_direction_output(info->sensor_pwd, 1);
-	gpio_direction_output(info->sensor_reset, 0);
-	usleep_range(10000, 11000);
-	rc = msm_sensor_power_up(s_ctrl);
-	if (rc < 0) {
-		CDBG("%s: msm_sensor_power_up failed\n", __func__);
-		return rc;
-	}
-
-	/* turn on ldo and vreg */
-
-	gpio_direction_output(info->sensor_pwd, 0);
-	msleep(20);
-	gpio_direction_output(info->sensor_reset, 1);
-	msleep(25);
-
-	return rc;
-
-}
-
-static int32_t vfe_clk = 266667000;
-
-static void ov5647_stop_stream(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	msm_camera_i2c_write_tbl(
-		s_ctrl->sensor_i2c_client,
-		s_ctrl->msm_sensor_reg->stop_stream_conf,
-		s_ctrl->msm_sensor_reg->stop_stream_conf_size,
-		s_ctrl->msm_sensor_reg->default_data_type);
-
-	if (s_ctrl->curr_res == MSM_SENSOR_RES_FULL)
-		msleep(66);
-	else
-		msleep(266);
-
-	msm_camera_i2c_write(
-			s_ctrl->sensor_i2c_client,
-			0x4800, 0x25,
-			MSM_CAMERA_I2C_BYTE_DATA);
-}
-
-int32_t ov5647_sensor_setting(struct msm_sensor_ctrl_t *s_ctrl,
-			int update_type, int res)
-{
-	int32_t rc = 0;
-	if (update_type == MSM_SENSOR_REG_INIT) {
-		CDBG("Register INIT\n");
-		s_ctrl->func_tbl->sensor_stop_stream(s_ctrl);
-		msm_camera_i2c_write(
-				s_ctrl->sensor_i2c_client,
-				0x103, 0x1,
-				MSM_CAMERA_I2C_BYTE_DATA);
-		msm_sensor_enable_debugfs(s_ctrl);
-		msm_sensor_write_init_settings(s_ctrl);
-	} else if (update_type == MSM_SENSOR_UPDATE_PERIODIC) {
-		CDBG("PERIODIC : %d\n", res);
-		msm_sensor_write_conf_array(
-			s_ctrl->sensor_i2c_client,
-			s_ctrl->msm_sensor_reg->mode_settings, res);
-		msleep(30);
-		msm_camera_i2c_write(
-			s_ctrl->sensor_i2c_client,
-			0x100, 0x1,
-			MSM_CAMERA_I2C_BYTE_DATA);
-		msm_camera_i2c_write(
-			s_ctrl->sensor_i2c_client,
-			0x4800, 0x4,
-			MSM_CAMERA_I2C_BYTE_DATA);
-		msleep(266);
-		if (res == MSM_SENSOR_RES_4)
-			v4l2_subdev_notify(&s_ctrl->sensor_v4l2_subdev,
-					NOTIFY_PCLK_CHANGE,
-					&vfe_clk);
-	}
-	return rc;
-}
-static struct msm_sensor_fn_t ov5647_func_tbl = {
-	.sensor_start_stream = msm_sensor_start_stream,
-	.sensor_stop_stream = ov5647_stop_stream,
-	.sensor_group_hold_on = msm_sensor_group_hold_on,
-	.sensor_group_hold_off = msm_sensor_group_hold_off,
-	.sensor_set_fps = msm_sensor_set_fps,
-	.sensor_write_exp_gain = ov5647_write_prev_exp_gain,
-	.sensor_write_snapshot_exp_gain = ov5647_write_pict_exp_gain,
-	.sensor_csi_setting = ov5647_sensor_setting,
-	.sensor_set_sensor_mode = msm_sensor_set_sensor_mode,
-	.sensor_mode_init = msm_sensor_mode_init,
-	.sensor_get_output_info = msm_sensor_get_output_info,
-	.sensor_config = msm_sensor_config,
-	.sensor_power_up = ov5647_sensor_power_up,
-	.sensor_power_down = ov5647_sensor_power_down,
-};
-
-static struct msm_sensor_reg_t ov5647_regs = {
-	.default_data_type = MSM_CAMERA_I2C_BYTE_DATA,
-	.start_stream_conf = ov5647_start_settings,
-	.start_stream_conf_size = ARRAY_SIZE(ov5647_start_settings),
-	.stop_stream_conf = ov5647_stop_settings,
-	.stop_stream_conf_size = ARRAY_SIZE(ov5647_stop_settings),
-	.group_hold_on_conf = ov5647_groupon_settings,
-	.group_hold_on_conf_size = ARRAY_SIZE(ov5647_groupon_settings),
-	.group_hold_off_conf = ov5647_groupoff_settings,
-	.group_hold_off_conf_size =
-		ARRAY_SIZE(ov5647_groupoff_settings),
-	.init_settings = &ov5647_init_conf[0],
-	.init_size = ARRAY_SIZE(ov5647_init_conf),
-	.mode_settings = &ov5647_confs[0],
-	.output_settings = &ov5647_dimensions[0],
-	.num_conf = ARRAY_SIZE(ov5647_confs),
-};
-
-static struct msm_sensor_ctrl_t ov5647_s_ctrl = {
-	.msm_sensor_reg = &ov5647_regs,
-	.sensor_i2c_client = &ov5647_sensor_i2c_client,
-	.sensor_i2c_addr =  0x36 << 1 ,
-	.sensor_output_reg_addr = &ov5647_reg_addr,
-	.sensor_id_info = &ov5647_id_info,
-	.sensor_exp_gain_info = &ov5647_exp_gain_info,
-	.cam_mode = MSM_SENSOR_MODE_INVALID,
-	.msm_sensor_mutex = &ov5647_mut,
-	.sensor_i2c_driver = &ov5647_i2c_driver,
-	.sensor_v4l2_subdev_info = ov5647_subdev_info,
-	.sensor_v4l2_subdev_info_size = ARRAY_SIZE(ov5647_subdev_info),
-	.sensor_v4l2_subdev_ops = &ov5647_subdev_ops,
-	.func_tbl = &ov5647_func_tbl,
-	.clk_rate = MSM_SENSOR_MCLK_24HZ,
-};
-
-module_init(msm_sensor_init_module);
-MODULE_DESCRIPTION("Omnivision WXGA Bayer sensor driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/sensors/ov7692_v4l2.c b/drivers/media/platform/msm/camera_v1/sensors/ov7692_v4l2.c
deleted file mode 100644
index efc78f8..0000000
--- a/drivers/media/platform/msm/camera_v1/sensors/ov7692_v4l2.c
+++ /dev/null
@@ -1,926 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- *
- */
-
-#include "msm_sensor.h"
-#define SENSOR_NAME "ov7692"
-
-DEFINE_MUTEX(ov7692_mut);
-static struct msm_sensor_ctrl_t ov7692_s_ctrl;
-
-static int effect_value = CAMERA_EFFECT_OFF;
-static unsigned int SAT_U = 0x80; /* DEFAULT SATURATION VALUES*/
-static unsigned int SAT_V = 0x80; /* DEFAULT SATURATION VALUES*/
-
-static struct msm_camera_i2c_reg_conf ov7692_start_settings[] = {
-	{0x0e, 0x00},
-};
-
-static struct msm_camera_i2c_reg_conf ov7692_stop_settings[] = {
-	{0x0e, 0x08},
-};
-
-static struct msm_camera_i2c_reg_conf ov7692_recommend_settings[] = {
-	{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},
-	{0xd0, 0x48},
-	{0x82, 0x03},
-	{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},
-	{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 struct msm_camera_i2c_reg_conf ov7692_full_settings[] = {
-	{0xcc, 0x02},
-	{0xcd, 0x80},
-	{0xce, 0x01},
-	{0xcf, 0xe0},
-	{0xc8, 0x02},
-	{0xc9, 0x80},
-	{0xca, 0x01},
-	{0xcb, 0xe0},
-};
-
-static struct v4l2_subdev_info ov7692_subdev_info[] = {
-	{
-		.code   = V4L2_MBUS_FMT_YUYV8_2X8,
-		.colorspace = V4L2_COLORSPACE_JPEG,
-		.fmt    = 1,
-		.order    = 0,
-	},
-	/* more can be supported, to be added later */
-};
-
-
-static struct msm_camera_i2c_conf_array ov7692_init_conf[] = {
-	{&ov7692_recommend_settings[0],
-	ARRAY_SIZE(ov7692_recommend_settings), 0, MSM_CAMERA_I2C_BYTE_DATA}
-};
-
-static struct msm_camera_i2c_conf_array ov7692_confs[] = {
-	{&ov7692_full_settings[0],
-	ARRAY_SIZE(ov7692_full_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-};
-
-static struct msm_camera_i2c_reg_conf ov7692_saturation[][4] = {
-	{{0x81, 0x33, 0x00, 0x00, 0xCC}, {0xd8, 0x00, 0x00, 0x00, 0x00},
-		{0xd9, 0x00, 0x00, 0x00, 0x00},
-		{0xd2, 0x02, 0x00, 0x00, 0x00},},/* SATURATION LEVEL0*/
-	{{0x81, 0x33, 0x00, 0x00, 0xCC}, {0xd8, 0x10, 0x00, 0x00, 0x00},
-		{0xd9, 0x10, 0x00, 0x00, 0x00},
-		{0xd2, 0x02, 0x00, 0x00, 0x00},},	/* SATURATION LEVEL1*/
-	{{0x81, 0x33, 0x00, 0x00, 0xCC}, {0xd8, 0x20, 0x00, 0x00, 0x00},
-		{0xd9, 0x20, 0x00, 0x00, 0x00},
-		{0xd2, 0x02, 0x00, 0x00, 0x00},},	/* SATURATION LEVEL2*/
-	{{0x81, 0x33, 0x00, 0x00, 0xCC}, {0xd8, 0x30, 0x00, 0x00, 0x00},
-		{0xd9, 0x30, 0x00, 0x00, 0x00},
-		{0xd2, 0x02, 0x00, 0x00, 0x00},},	/* SATURATION LEVEL3*/
-	{{0x81, 0x33, 0x00, 0x00, 0xCC}, {0xd8, 0x40, 0x00, 0x00, 0x00},
-		{0xd9, 0x40, 0x00, 0x00, 0x00},
-		{0xd2, 0x02, 0x00, 0x00, 0x00},},	/* SATURATION LEVEL4*/
-	{{0x81, 0x33, 0x00, 0x00, 0xCC}, {0xd8, 0x50, 0x00, 0x00, 0x00},
-		{0xd9, 0x50, 0x00, 0x00, 0x00},
-		{0xd2, 0x02, 0x00, 0x00, 0x00},},	/* SATURATION LEVEL5*/
-	{{0x81, 0x33, 0x00, 0x00, 0xCC}, {0xd8, 0x60, 0x00, 0x00, 0x00},
-		{0xd9, 0x60, 0x00, 0x00, 0x00},
-		{0xd2, 0x02, 0x00, 0x00, 0x00},},	/* SATURATION LEVEL6*/
-	{{0x81, 0x33, 0x00, 0x00, 0xCC}, {0xd8, 0x70, 0x00, 0x00, 0x00},
-		{0xd9, 0x70, 0x00, 0x00, 0x00},
-		{0xd2, 0x02, 0x00, 0x00, 0x00},},	/* SATURATION LEVEL7*/
-	{{0x81, 0x33, 0x00, 0x00, 0xCC}, {0xd8, 0x80, 0x00, 0x00, 0x00},
-		{0xd9, 0x80, 0x00, 0x00, 0x00},
-		{0xd2, 0x02, 0x00, 0x00, 0x00},},	/* SATURATION LEVEL8*/
-};
-static struct msm_camera_i2c_conf_array ov7692_saturation_confs[][1] = {
-	{{ov7692_saturation[0], ARRAY_SIZE(ov7692_saturation[0]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_saturation[1], ARRAY_SIZE(ov7692_saturation[1]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_saturation[2], ARRAY_SIZE(ov7692_saturation[2]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_saturation[3], ARRAY_SIZE(ov7692_saturation[3]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_saturation[4], ARRAY_SIZE(ov7692_saturation[4]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_saturation[5], ARRAY_SIZE(ov7692_saturation[5]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_saturation[6], ARRAY_SIZE(ov7692_saturation[6]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_saturation[7], ARRAY_SIZE(ov7692_saturation[7]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_saturation[8], ARRAY_SIZE(ov7692_saturation[8]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-};
-
-static int ov7692_saturation_enum_map[] = {
-	MSM_V4L2_SATURATION_L0,
-	MSM_V4L2_SATURATION_L1,
-	MSM_V4L2_SATURATION_L2,
-	MSM_V4L2_SATURATION_L3,
-	MSM_V4L2_SATURATION_L4,
-	MSM_V4L2_SATURATION_L5,
-	MSM_V4L2_SATURATION_L6,
-	MSM_V4L2_SATURATION_L7,
-	MSM_V4L2_SATURATION_L8,
-};
-static struct msm_sensor_output_info_t ov7692_dimensions[] = {
-	{
-		.x_output = 0x280,
-		.y_output = 0x1E0,
-		.line_length_pclk = 0x290,
-		.frame_length_lines = 0x1EC,
-		.vt_pixel_clk = 9216000,
-		.op_pixel_clk = 9216000,
-		.binning_factor = 1,
-	},
-};
-
-static struct msm_camera_i2c_enum_conf_array ov7692_saturation_enum_confs = {
-	.conf = &ov7692_saturation_confs[0][0],
-	.conf_enum = ov7692_saturation_enum_map,
-	.num_enum = ARRAY_SIZE(ov7692_saturation_enum_map),
-	.num_index = ARRAY_SIZE(ov7692_saturation_confs),
-	.num_conf = ARRAY_SIZE(ov7692_saturation_confs[0]),
-	.data_type = MSM_CAMERA_I2C_BYTE_DATA,
-};
-
-static struct msm_camera_i2c_reg_conf ov7692_contrast[][16] = {
-	{{0xb2, 0x29}, {0xa3, 0x55}, {0xa4, 0x5b}, {0xa5, 0x67}, {0xa6, 0x7e},
-		{0xa7, 0x89}, {0xa8, 0x93}, {0xa9, 0x9c}, {0xaa, 0xa4},
-		{0xab, 0xac}, {0xac, 0xb3}, {0xad, 0xbe}, {0xae, 0xc7},
-		{0xaf, 0xd5}, {0xb0, 0xdd}, {0xb1, 0xe1},},	/* CONTRAST L0*/
-	{{0xb2, 0x20}, {0xa3, 0x43}, {0xa4, 0x4a}, {0xa5, 0x58}, {0xa6, 0x73},
-		{0xa7, 0x80}, {0xa8, 0x8b}, {0xa9, 0x96}, {0xaa, 0x9f},
-		{0xab, 0xa8}, {0xac, 0xb1}, {0xad, 0xbe}, {0xae, 0xc9},
-		{0xaf, 0xd8}, {0xb0, 0xe2}, {0xb1, 0xe8},},	/* CONTRAST L1*/
-	{{0xb2, 0x18}, {0xa3, 0x31}, {0xa4, 0x39}, {0xa5, 0x4a}, {0xa6, 0x68},
-		{0xa7, 0x77}, {0xa8, 0x84}, {0xa9, 0x90}, {0xaa, 0x9b},
-		{0xab, 0xa5}, {0xac, 0xaf}, {0xad, 0xbe}, {0xae, 0xca},
-		{0xaf, 0xdc}, {0xb0, 0xe7}, {0xb1, 0xee},},	/* CONTRAST L2*/
-	{{0xb2, 0x10}, {0xa3, 0x1f}, {0xa4, 0x28}, {0xa5, 0x3b}, {0xa6, 0x5d},
-		{0xa7, 0x6e}, {0xa8, 0x7d}, {0xa9, 0x8a}, {0xaa, 0x96},
-		{0xab, 0xa2}, {0xac, 0xad}, {0xad, 0xbe}, {0xae, 0xcc},
-		{0xaf, 0xe0}, {0xb0, 0xed}, {0xb1, 0xf4},},	/* CONTRAST L3*/
-	 {{0xb2, 0x6}, {0xa3, 0xb}, {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},},	/* CONTRAST L4*/
-	{{0xb2, 0xc}, {0xa3, 0x4}, {0xa4, 0xc}, {0xa5, 0x1f}, {0xa6, 0x45},
-		{0xa7, 0x58}, {0xa8, 0x6b}, {0xa9, 0x7c}, {0xaa, 0x8d},
-		{0xab, 0x9d}, {0xac, 0xac}, {0xad, 0xc3}, {0xae, 0xd2},
-		{0xaf, 0xe8}, {0xb0, 0xf2}, {0xb1, 0xf7},},	/* CONTRAST L5*/
-	{{0xb2, 0x1}, {0xa3, 0x2}, {0xa4, 0x9}, {0xa5, 0x1a}, {0xa6, 0x3e},
-		{0xa7, 0x4a}, {0xa8, 0x59}, {0xa9, 0x6a}, {0xaa, 0x79},
-		{0xab, 0x8e}, {0xac, 0xa4}, {0xad, 0xc1}, {0xae, 0xdb},
-		{0xaf, 0xf4}, {0xb0, 0xff}, {0xb1, 0xff},},	/* CONTRAST L6*/
-	{{0xb2, 0xc}, {0xa3, 0x4}, {0xa4, 0x8}, {0xa5, 0x17}, {0xa6, 0x27},
-		{0xa7, 0x3d}, {0xa8, 0x54}, {0xa9, 0x60}, {0xaa, 0x77},
-		{0xab, 0x85}, {0xac, 0xa4}, {0xad, 0xc6}, {0xae, 0xd2},
-		{0xaf, 0xe9}, {0xb0, 0xf0}, {0xb1, 0xf7},},	/* CONTRAST L7*/
-	{{0xb2, 0x1}, {0xa3, 0x4}, {0xa4, 0x4}, {0xa5, 0x7}, {0xa6, 0xb},
-		{0xa7, 0x17}, {0xa8, 0x2a}, {0xa9, 0x41}, {0xaa, 0x59},
-		{0xab, 0x6b}, {0xac, 0x8b}, {0xad, 0xb1}, {0xae, 0xd2},
-		{0xaf, 0xea}, {0xb0, 0xf4}, {0xb1, 0xff},},	/* CONTRAST L8*/
-};
-
-static struct msm_camera_i2c_conf_array ov7692_contrast_confs[][1] = {
-	{{ov7692_contrast[0], ARRAY_SIZE(ov7692_contrast[0]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_contrast[1], ARRAY_SIZE(ov7692_contrast[1]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_contrast[2], ARRAY_SIZE(ov7692_contrast[2]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_contrast[3], ARRAY_SIZE(ov7692_contrast[3]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_contrast[4], ARRAY_SIZE(ov7692_contrast[4]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_contrast[5], ARRAY_SIZE(ov7692_contrast[5]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_contrast[6], ARRAY_SIZE(ov7692_contrast[6]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_contrast[7], ARRAY_SIZE(ov7692_contrast[7]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_contrast[8], ARRAY_SIZE(ov7692_contrast[8]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-};
-
-
-static int ov7692_contrast_enum_map[] = {
-	MSM_V4L2_CONTRAST_L0,
-	MSM_V4L2_CONTRAST_L1,
-	MSM_V4L2_CONTRAST_L2,
-	MSM_V4L2_CONTRAST_L3,
-	MSM_V4L2_CONTRAST_L4,
-	MSM_V4L2_CONTRAST_L5,
-	MSM_V4L2_CONTRAST_L6,
-	MSM_V4L2_CONTRAST_L7,
-	MSM_V4L2_CONTRAST_L8,
-};
-
-static struct msm_camera_i2c_enum_conf_array ov7692_contrast_enum_confs = {
-	.conf = &ov7692_contrast_confs[0][0],
-	.conf_enum = ov7692_contrast_enum_map,
-	.num_enum = ARRAY_SIZE(ov7692_contrast_enum_map),
-	.num_index = ARRAY_SIZE(ov7692_contrast_confs),
-	.num_conf = ARRAY_SIZE(ov7692_contrast_confs[0]),
-	.data_type = MSM_CAMERA_I2C_BYTE_DATA,
-};
-static struct msm_camera_i2c_reg_conf ov7692_sharpness[][2] = {
-	{{0xb4, 0x20, 0x00, 0x00, 0xDF},
-		{0xb6, 0x00, 0x00, 0x00, 0xE0},},    /* SHARPNESS LEVEL 0*/
-	{{0xb4, 0x20, 0x00, 0x00, 0xDF},
-		{0xb6, 0x01, 0x00, 0x00, 0xE0},},    /* SHARPNESS LEVEL 1*/
-	{{0xb4, 0x00, 0x00, 0x00, 0xDF},
-		{0xb6, 0x00, 0x00, 0x00, 0xE0},},    /* SHARPNESS LEVEL 2*/
-	{{0xb4, 0x20, 0x00, 0x00, 0xDF},
-		{0xb6, 0x66, 0x00, 0x00, 0xE0},},    /* SHARPNESS LEVEL 3*/
-	{{0xb4, 0x20, 0x00, 0x00, 0xDF},
-		{0xb6, 0x99, 0x00, 0x00, 0xE0},},    /* SHARPNESS LEVEL 4*/
-	{{0xb4, 0x20, 0x00, 0x00, 0xDF},
-		{0xb6, 0xcc, 0x00, 0x00, 0xE0},},    /* SHARPNESS LEVEL 5*/
-};
-
-static struct msm_camera_i2c_conf_array ov7692_sharpness_confs[][1] = {
-	{{ov7692_sharpness[0], ARRAY_SIZE(ov7692_sharpness[0]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_sharpness[1], ARRAY_SIZE(ov7692_sharpness[1]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_sharpness[2], ARRAY_SIZE(ov7692_sharpness[2]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_sharpness[3], ARRAY_SIZE(ov7692_sharpness[3]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_sharpness[4], ARRAY_SIZE(ov7692_sharpness[4]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_sharpness[5], ARRAY_SIZE(ov7692_sharpness[5]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-};
-
-static int ov7692_sharpness_enum_map[] = {
-	MSM_V4L2_SHARPNESS_L0,
-	MSM_V4L2_SHARPNESS_L1,
-	MSM_V4L2_SHARPNESS_L2,
-	MSM_V4L2_SHARPNESS_L3,
-	MSM_V4L2_SHARPNESS_L4,
-	MSM_V4L2_SHARPNESS_L5,
-};
-
-static struct msm_camera_i2c_enum_conf_array ov7692_sharpness_enum_confs = {
-	.conf = &ov7692_sharpness_confs[0][0],
-	.conf_enum = ov7692_sharpness_enum_map,
-	.num_enum = ARRAY_SIZE(ov7692_sharpness_enum_map),
-	.num_index = ARRAY_SIZE(ov7692_sharpness_confs),
-	.num_conf = ARRAY_SIZE(ov7692_sharpness_confs[0]),
-	.data_type = MSM_CAMERA_I2C_BYTE_DATA,
-};
-
-static struct msm_camera_i2c_reg_conf ov7692_exposure[][3] = {
-	{{0x24, 0x50}, {0x25, 0x40}, {0x26, 0xa2},}, /*EXPOSURECOMPENSATIONN2*/
-	{{0x24, 0x70}, {0x25, 0x60}, {0x26, 0xa2},}, /*EXPOSURECOMPENSATIONN1*/
-	{{0x24, 0x86}, {0x25, 0x76}, {0x26, 0xb3},}, /*EXPOSURECOMPENSATIOND*/
-	{{0x24, 0xa8}, {0x25, 0xa0}, {0x26, 0xc4},}, /*EXPOSURECOMPENSATIONp1*/
-	{{0x24, 0xc0}, {0x25, 0xb8}, {0x26, 0xe6},}, /*EXPOSURECOMPENSATIONP2*/
-};
-
-static struct msm_camera_i2c_conf_array ov7692_exposure_confs[][1] = {
-	{{ov7692_exposure[0], ARRAY_SIZE(ov7692_exposure[0]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_exposure[1], ARRAY_SIZE(ov7692_exposure[1]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_exposure[2], ARRAY_SIZE(ov7692_exposure[2]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_exposure[3], ARRAY_SIZE(ov7692_exposure[3]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_exposure[4], ARRAY_SIZE(ov7692_exposure[4]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-};
-
-static int ov7692_exposure_enum_map[] = {
-	MSM_V4L2_EXPOSURE_N2,
-	MSM_V4L2_EXPOSURE_N1,
-	MSM_V4L2_EXPOSURE_D,
-	MSM_V4L2_EXPOSURE_P1,
-	MSM_V4L2_EXPOSURE_P2,
-};
-
-static struct msm_camera_i2c_enum_conf_array ov7692_exposure_enum_confs = {
-	.conf = &ov7692_exposure_confs[0][0],
-	.conf_enum = ov7692_exposure_enum_map,
-	.num_enum = ARRAY_SIZE(ov7692_exposure_enum_map),
-	.num_index = ARRAY_SIZE(ov7692_exposure_confs),
-	.num_conf = ARRAY_SIZE(ov7692_exposure_confs[0]),
-	.data_type = MSM_CAMERA_I2C_BYTE_DATA,
-};
-
-static struct msm_camera_i2c_reg_conf ov7692_iso[][1] = {
-	{{0x14, 0x20, 0x00, 0x00, 0x8F},},   /*ISO_AUTO*/
-	{{0x14, 0x20, 0x00, 0x00, 0x8F},},   /*ISO_DEBLUR*/
-	{{0x14, 0x00, 0x00, 0x00, 0x8F},},   /*ISO_100*/
-	{{0x14, 0x10, 0x00, 0x00, 0x8F},},   /*ISO_200*/
-	{{0x14, 0x20, 0x00, 0x00, 0x8F},},   /*ISO_400*/
-	{{0x14, 0x30, 0x00, 0x00, 0x8F},},   /*ISO_800*/
-	{{0x14, 0x40, 0x00, 0x00, 0x8F},},   /*ISO_1600*/
-};
-
-
-static struct msm_camera_i2c_conf_array ov7692_iso_confs[][1] = {
-	{{ov7692_iso[0], ARRAY_SIZE(ov7692_iso[0]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_iso[1], ARRAY_SIZE(ov7692_iso[1]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_iso[2], ARRAY_SIZE(ov7692_iso[2]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_iso[3], ARRAY_SIZE(ov7692_iso[3]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_iso[4], ARRAY_SIZE(ov7692_iso[4]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_iso[5], ARRAY_SIZE(ov7692_iso[5]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-};
-
-static int ov7692_iso_enum_map[] = {
-	MSM_V4L2_ISO_AUTO ,
-	MSM_V4L2_ISO_DEBLUR,
-	MSM_V4L2_ISO_100,
-	MSM_V4L2_ISO_200,
-	MSM_V4L2_ISO_400,
-	MSM_V4L2_ISO_800,
-	MSM_V4L2_ISO_1600,
-};
-
-
-static struct msm_camera_i2c_enum_conf_array ov7692_iso_enum_confs = {
-	.conf = &ov7692_iso_confs[0][0],
-	.conf_enum = ov7692_iso_enum_map,
-	.num_enum = ARRAY_SIZE(ov7692_iso_enum_map),
-	.num_index = ARRAY_SIZE(ov7692_iso_confs),
-	.num_conf = ARRAY_SIZE(ov7692_iso_confs[0]),
-	.data_type = MSM_CAMERA_I2C_BYTE_DATA,
-};
-
-static struct msm_camera_i2c_reg_conf ov7692_no_effect[] = {
-	{0x81, 0x00, 0x00, 0x00, 0xDF},
-	{0x28, 0x00,},
-	{0xd2, 0x00,},
-	{0xda, 0x80,},
-	{0xdb, 0x80,},
-};
-
-static struct msm_camera_i2c_conf_array ov7692_no_effect_confs[] = {
-	{&ov7692_no_effect[0],
-	ARRAY_SIZE(ov7692_no_effect), 0,
-	MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},
-};
-
-static struct msm_camera_i2c_reg_conf ov7692_special_effect[][5] = {
-	{{0x81, 0x20, 0x00, 0x00, 0xDF}, {0x28, 0x00,}, {0xd2, 0x18,},
-		{0xda, 0x80,}, {0xdb, 0x80,},},	/*for special effect OFF*/
-	{{0x81, 0x20, 0x00, 0x00, 0xDF}, {0x28, 0x00,}, {0xd2, 0x18,},
-		{0xda, 0x80,}, {0xdb, 0x80,},},	/*for special effect MONO*/
-	{{0x81, 0x20, 0x00, 0x00, 0xDF}, {0x28, 0x80,}, {0xd2, 0x40,},
-		{0xda, 0x80,}, {0xdb, 0x80,},},	/*for special efefct Negative*/
-	{{-1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1},
-		{-1, -1, -1, -1, -1},
-		{-1, -1, -1, -1, -1},},/*Solarize is not supported by sensor*/
-	{{0x81, 0x20, 0x00, 0x00, 0xDF}, {0x28, 0x00,}, {0xd2, 0x18,},
-		{0xda, 0x40,}, {0xdb, 0xa0,},},	/*for sepia*/
-	{{-1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1},
-		{-1, -1, -1, -1, -1},
-		{-1, -1, -1, -1, -1},},		/* Posteraize not supported */
-	{{-1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1},
-		{-1, -1, -1, -1, -1},
-		{-1, -1, -1, -1, -1},},		/* White board not supported*/
-	{{-1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1},
-		{-1, -1, -1, -1, -1},
-		{-1, -1, -1, -1, -1},},		/*Blackboard not supported*/
-	{{-1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1},
-		{-1, -1, -1, -1, -1},
-		{-1, -1, -1, -1, -1},},		/*Aqua not supported*/
-	{{-1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1},
-		{-1, -1, -1, -1, -1},
-		{-1, -1, -1, -1, -1},},		/*Emboss not supported */
-	{{-1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1},
-		{-1, -1, -1, -1, -1},
-		{-1, -1, -1, -1, -1},},		/*sketch not supported*/
-	{{-1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1},
-		{-1, -1, -1, -1, -1},
-		{-1, -1, -1, -1, -1},},		/*Neon not supported*/
-	{{-1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1},
-		{-1, -1, -1, -1, -1},
-		{-1, -1, -1, -1, -1},},		/*MAX value*/
-};
-
-static struct msm_camera_i2c_conf_array ov7692_special_effect_confs[][1] = {
-	{{ov7692_special_effect[0],  ARRAY_SIZE(ov7692_special_effect[0]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_special_effect[1],  ARRAY_SIZE(ov7692_special_effect[1]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_special_effect[2],  ARRAY_SIZE(ov7692_special_effect[2]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_special_effect[3],  ARRAY_SIZE(ov7692_special_effect[3]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_special_effect[4],  ARRAY_SIZE(ov7692_special_effect[4]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_special_effect[5],  ARRAY_SIZE(ov7692_special_effect[5]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_special_effect[6],  ARRAY_SIZE(ov7692_special_effect[6]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_special_effect[7],  ARRAY_SIZE(ov7692_special_effect[7]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_special_effect[8],  ARRAY_SIZE(ov7692_special_effect[8]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_special_effect[9],  ARRAY_SIZE(ov7692_special_effect[9]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_special_effect[10], ARRAY_SIZE(ov7692_special_effect[10]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_special_effect[11], ARRAY_SIZE(ov7692_special_effect[11]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_special_effect[12], ARRAY_SIZE(ov7692_special_effect[12]), 0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-};
-
-static int ov7692_special_effect_enum_map[] = {
-	MSM_V4L2_EFFECT_OFF,
-	MSM_V4L2_EFFECT_MONO,
-	MSM_V4L2_EFFECT_NEGATIVE,
-	MSM_V4L2_EFFECT_SOLARIZE,
-	MSM_V4L2_EFFECT_SEPIA,
-	MSM_V4L2_EFFECT_POSTERAIZE,
-	MSM_V4L2_EFFECT_WHITEBOARD,
-	MSM_V4L2_EFFECT_BLACKBOARD,
-	MSM_V4L2_EFFECT_AQUA,
-	MSM_V4L2_EFFECT_EMBOSS,
-	MSM_V4L2_EFFECT_SKETCH,
-	MSM_V4L2_EFFECT_NEON,
-	MSM_V4L2_EFFECT_MAX,
-};
-
-static struct msm_camera_i2c_enum_conf_array
-		 ov7692_special_effect_enum_confs = {
-	.conf = &ov7692_special_effect_confs[0][0],
-	.conf_enum = ov7692_special_effect_enum_map,
-	.num_enum = ARRAY_SIZE(ov7692_special_effect_enum_map),
-	.num_index = ARRAY_SIZE(ov7692_special_effect_confs),
-	.num_conf = ARRAY_SIZE(ov7692_special_effect_confs[0]),
-	.data_type = MSM_CAMERA_I2C_BYTE_DATA,
-};
-
-static struct msm_camera_i2c_reg_conf ov7692_antibanding[][2] = {
-	{{0x13, 0x20, 0x00, 0x00, 0xDF},
-		{0x14, 0x16, 0x00, 0x00, 0xE8},},   /*ANTIBANDING 60HZ*/
-	{{0x13, 0x20, 0x00, 0x00, 0xDF},
-		{0x14, 0x17, 0x00, 0x00, 0xE8},},   /*ANTIBANDING 50HZ*/
-	{{0x13, 0x20, 0x00, 0x00, 0xDF},
-		{0x14, 0x14, 0x00, 0x00, 0xE8},},   /* ANTIBANDING AUTO*/
-};
-
-
-static struct msm_camera_i2c_conf_array ov7692_antibanding_confs[][1] = {
-	{{ov7692_antibanding[0], ARRAY_SIZE(ov7692_antibanding[0]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_antibanding[1], ARRAY_SIZE(ov7692_antibanding[1]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_antibanding[2], ARRAY_SIZE(ov7692_antibanding[2]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-};
-
-static int ov7692_antibanding_enum_map[] = {
-	MSM_V4L2_POWER_LINE_60HZ,
-	MSM_V4L2_POWER_LINE_50HZ,
-	MSM_V4L2_POWER_LINE_AUTO,
-};
-
-
-static struct msm_camera_i2c_enum_conf_array ov7692_antibanding_enum_confs = {
-	.conf = &ov7692_antibanding_confs[0][0],
-	.conf_enum = ov7692_antibanding_enum_map,
-	.num_enum = ARRAY_SIZE(ov7692_antibanding_enum_map),
-	.num_index = ARRAY_SIZE(ov7692_antibanding_confs),
-	.num_conf = ARRAY_SIZE(ov7692_antibanding_confs[0]),
-	.data_type = MSM_CAMERA_I2C_BYTE_DATA,
-};
-
-static struct msm_camera_i2c_reg_conf ov7692_wb_oem[][4] = {
-	{{-1, -1, -1, -1 , -1}, {-1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1},
-		{-1, -1, -1, -1, -1},},/*WHITEBALNACE OFF*/
-	{{0x13, 0xf7}, {0x15, 0x00}, {-1, -1, -1, -1, -1},
-		{-1, -1, -1, -1, -1},}, /*WHITEBALNACE AUTO*/
-	{{0x13, 0xf5}, {0x01, 0x56}, {0x02, 0x50},
-		{0x15, 0x00},},	/*WHITEBALNACE CUSTOM*/
-	{{0x13, 0xf5}, {0x01, 0x66}, {0x02, 0x40},
-		{0x15, 0x00},},	/*INCANDISCENT*/
-	{{-1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1},
-		{-1, -1, -1, -1, -1},},	/*FLOURESECT NOT SUPPORTED */
-	{{0x13, 0xf5}, {0x01, 0x43}, {0x02, 0x5d},
-		{0x15, 0x00},},	/*DAYLIGHT*/
-	{{0x13, 0xf5}, {0x01, 0x48}, {0x02, 0x63},
-		{0x15, 0x00},},	/*CLOUDY*/
-};
-
-static struct msm_camera_i2c_conf_array ov7692_wb_oem_confs[][1] = {
-	{{ov7692_wb_oem[0], ARRAY_SIZE(ov7692_wb_oem[0]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_wb_oem[1], ARRAY_SIZE(ov7692_wb_oem[1]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_wb_oem[2], ARRAY_SIZE(ov7692_wb_oem[2]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_wb_oem[3], ARRAY_SIZE(ov7692_wb_oem[3]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_wb_oem[4], ARRAY_SIZE(ov7692_wb_oem[4]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_wb_oem[5], ARRAY_SIZE(ov7692_wb_oem[5]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-	{{ov7692_wb_oem[6], ARRAY_SIZE(ov7692_wb_oem[6]),  0,
-		MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA},},
-};
-
-static int ov7692_wb_oem_enum_map[] = {
-	MSM_V4L2_WB_OFF,
-	MSM_V4L2_WB_AUTO ,
-	MSM_V4L2_WB_CUSTOM,
-	MSM_V4L2_WB_INCANDESCENT,
-	MSM_V4L2_WB_FLUORESCENT,
-	MSM_V4L2_WB_DAYLIGHT,
-	MSM_V4L2_WB_CLOUDY_DAYLIGHT,
-};
-
-static struct msm_camera_i2c_enum_conf_array ov7692_wb_oem_enum_confs = {
-	.conf = &ov7692_wb_oem_confs[0][0],
-	.conf_enum = ov7692_wb_oem_enum_map,
-	.num_enum = ARRAY_SIZE(ov7692_wb_oem_enum_map),
-	.num_index = ARRAY_SIZE(ov7692_wb_oem_confs),
-	.num_conf = ARRAY_SIZE(ov7692_wb_oem_confs[0]),
-	.data_type = MSM_CAMERA_I2C_BYTE_DATA,
-};
-
-
-int ov7692_saturation_msm_sensor_s_ctrl_by_enum(
-		struct msm_sensor_ctrl_t *s_ctrl,
-		struct msm_sensor_v4l2_ctrl_info_t *ctrl_info, int value)
-{
-	int rc = 0;
-	if (effect_value == CAMERA_EFFECT_OFF) {
-		rc = msm_sensor_write_enum_conf_array(
-			s_ctrl->sensor_i2c_client,
-			ctrl_info->enum_cfg_settings, value);
-	}
-	if (value <= MSM_V4L2_SATURATION_L8)
-		SAT_U = SAT_V = value * 0x10;
-	CDBG("--CAMERA-- %s ...(End)\n", __func__);
-	return rc;
-}
-
-
-int ov7692_contrast_msm_sensor_s_ctrl_by_enum(
-		struct msm_sensor_ctrl_t *s_ctrl,
-		struct msm_sensor_v4l2_ctrl_info_t *ctrl_info, int value)
-{
-	int rc = 0;
-	if (effect_value == CAMERA_EFFECT_OFF) {
-		rc = msm_sensor_write_enum_conf_array(
-			s_ctrl->sensor_i2c_client,
-			ctrl_info->enum_cfg_settings, value);
-	}
-	return rc;
-}
-
-int ov7692_sharpness_msm_sensor_s_ctrl_by_enum(
-		struct msm_sensor_ctrl_t *s_ctrl,
-		struct msm_sensor_v4l2_ctrl_info_t *ctrl_info, int value)
-{
-	int rc = 0;
-	if (effect_value == CAMERA_EFFECT_OFF) {
-		rc = msm_sensor_write_enum_conf_array(
-			s_ctrl->sensor_i2c_client,
-			ctrl_info->enum_cfg_settings, value);
-	}
-	return rc;
-}
-
-int ov7692_effect_msm_sensor_s_ctrl_by_enum(struct msm_sensor_ctrl_t *s_ctrl,
-		struct msm_sensor_v4l2_ctrl_info_t *ctrl_info, int value)
-{
-	int rc = 0;
-	effect_value = value;
-	if (effect_value == CAMERA_EFFECT_OFF) {
-		rc = msm_sensor_write_conf_array(
-			s_ctrl->sensor_i2c_client,
-			s_ctrl->msm_sensor_reg->no_effect_settings, 0);
-		if (rc < 0) {
-			CDBG("write faield\n");
-			return rc;
-		}
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client, 0xda, SAT_U,
-			MSM_CAMERA_I2C_BYTE_DATA);
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client, 0xdb, SAT_V,
-			MSM_CAMERA_I2C_BYTE_DATA);
-	} else {
-		rc = msm_sensor_write_enum_conf_array(
-			s_ctrl->sensor_i2c_client,
-			ctrl_info->enum_cfg_settings, value);
-	}
-	return rc;
-}
-
-int ov7692_antibanding_msm_sensor_s_ctrl_by_enum(
-		struct msm_sensor_ctrl_t *s_ctrl,
-		struct msm_sensor_v4l2_ctrl_info_t *ctrl_info, int value)
-{
-	int rc = 0;
-		return rc;
-}
-
-int ov7692_msm_sensor_s_ctrl_by_enum(struct msm_sensor_ctrl_t *s_ctrl,
-		struct msm_sensor_v4l2_ctrl_info_t *ctrl_info, int value)
-{
-	int rc = 0;
-	rc = msm_sensor_write_enum_conf_array(
-		s_ctrl->sensor_i2c_client,
-		ctrl_info->enum_cfg_settings, value);
-	if (rc < 0) {
-		CDBG("write faield\n");
-		return rc;
-	}
-	return rc;
-}
-
-struct msm_sensor_v4l2_ctrl_info_t ov7692_v4l2_ctrl_info[] = {
-	{
-		.ctrl_id = V4L2_CID_SATURATION,
-		.min = MSM_V4L2_SATURATION_L0,
-		.max = MSM_V4L2_SATURATION_L8,
-		.step = 1,
-		.enum_cfg_settings = &ov7692_saturation_enum_confs,
-		.s_v4l2_ctrl = ov7692_saturation_msm_sensor_s_ctrl_by_enum,
-	},
-	{
-		.ctrl_id = V4L2_CID_CONTRAST,
-		.min = MSM_V4L2_CONTRAST_L0,
-		.max = MSM_V4L2_CONTRAST_L8,
-		.step = 1,
-		.enum_cfg_settings = &ov7692_contrast_enum_confs,
-		.s_v4l2_ctrl = ov7692_contrast_msm_sensor_s_ctrl_by_enum,
-	},
-	{
-		.ctrl_id = V4L2_CID_SHARPNESS,
-		.min = MSM_V4L2_SHARPNESS_L0,
-		.max = MSM_V4L2_SHARPNESS_L5,
-		.step = 1,
-		.enum_cfg_settings = &ov7692_sharpness_enum_confs,
-		.s_v4l2_ctrl = ov7692_sharpness_msm_sensor_s_ctrl_by_enum,
-	},
-	{
-		.ctrl_id = V4L2_CID_EXPOSURE,
-		.min = MSM_V4L2_EXPOSURE_N2,
-		.max = MSM_V4L2_EXPOSURE_P2,
-		.step = 1,
-		.enum_cfg_settings = &ov7692_exposure_enum_confs,
-		.s_v4l2_ctrl = ov7692_msm_sensor_s_ctrl_by_enum,
-	},
-	{
-		.ctrl_id = MSM_V4L2_PID_ISO,
-		.min = MSM_V4L2_ISO_AUTO,
-		.max = MSM_V4L2_ISO_1600,
-		.step = 1,
-		.enum_cfg_settings = &ov7692_iso_enum_confs,
-		.s_v4l2_ctrl = ov7692_msm_sensor_s_ctrl_by_enum,
-	},
-	{
-		.ctrl_id = V4L2_CID_SPECIAL_EFFECT,
-		.min = MSM_V4L2_EFFECT_OFF,
-		.max = MSM_V4L2_EFFECT_NEGATIVE,
-		.step = 1,
-		.enum_cfg_settings = &ov7692_special_effect_enum_confs,
-		.s_v4l2_ctrl = ov7692_effect_msm_sensor_s_ctrl_by_enum,
-	},
-	{
-		.ctrl_id = V4L2_CID_POWER_LINE_FREQUENCY,
-		.min = MSM_V4L2_POWER_LINE_60HZ,
-		.max = MSM_V4L2_POWER_LINE_AUTO,
-		.step = 1,
-		.enum_cfg_settings = &ov7692_antibanding_enum_confs,
-		.s_v4l2_ctrl = ov7692_antibanding_msm_sensor_s_ctrl_by_enum,
-	},
-	{
-		.ctrl_id = V4L2_CID_WHITE_BALANCE_TEMPERATURE,
-		.min = MSM_V4L2_WB_OFF,
-		.max = MSM_V4L2_WB_CLOUDY_DAYLIGHT,
-		.step = 1,
-		.enum_cfg_settings = &ov7692_wb_oem_enum_confs,
-		.s_v4l2_ctrl = ov7692_msm_sensor_s_ctrl_by_enum,
-	},
-
-};
-
-static struct msm_sensor_output_reg_addr_t ov7692_reg_addr = {
-	.x_output = 0xCC,
-	.y_output = 0xCE,
-	.line_length_pclk = 0xC8,
-	.frame_length_lines = 0xCA,
-};
-
-static struct msm_sensor_id_info_t ov7692_id_info = {
-	.sensor_id_reg_addr = 0x0A,
-	.sensor_id = 0x7692,
-};
-
-static const struct i2c_device_id ov7692_i2c_id[] = {
-	{SENSOR_NAME, (kernel_ulong_t)&ov7692_s_ctrl},
-	{ }
-};
-
-
-static struct i2c_driver ov7692_i2c_driver = {
-	.id_table = ov7692_i2c_id,
-	.probe  = msm_sensor_i2c_probe,
-	.driver = {
-		.name = SENSOR_NAME,
-	},
-};
-
-static struct msm_camera_i2c_client ov7692_sensor_i2c_client = {
-	.addr_type = MSM_CAMERA_I2C_BYTE_ADDR,
-};
-
-static int __init msm_sensor_init_module(void)
-{
-	int rc = 0;
-	CDBG("OV7692\n");
-
-	rc = i2c_add_driver(&ov7692_i2c_driver);
-
-	return rc;
-}
-
-static struct v4l2_subdev_core_ops ov7692_subdev_core_ops = {
-	.s_ctrl = msm_sensor_v4l2_s_ctrl,
-	.queryctrl = msm_sensor_v4l2_query_ctrl,
-	.ioctl = msm_sensor_subdev_ioctl,
-	.s_power = msm_sensor_power,
-};
-
-static struct v4l2_subdev_video_ops ov7692_subdev_video_ops = {
-	.enum_mbus_fmt = msm_sensor_v4l2_enum_fmt,
-};
-
-static struct v4l2_subdev_ops ov7692_subdev_ops = {
-	.core = &ov7692_subdev_core_ops,
-	.video  = &ov7692_subdev_video_ops,
-};
-
-static struct msm_sensor_fn_t ov7692_func_tbl = {
-	.sensor_start_stream = msm_sensor_start_stream,
-	.sensor_stop_stream = msm_sensor_stop_stream,
-	.sensor_csi_setting = msm_sensor_setting1,
-	.sensor_set_sensor_mode = msm_sensor_set_sensor_mode,
-	.sensor_mode_init = msm_sensor_mode_init,
-	.sensor_get_output_info = msm_sensor_get_output_info,
-	.sensor_config = msm_sensor_config,
-	.sensor_power_up = msm_sensor_power_up,
-	.sensor_power_down = msm_sensor_power_down,
-};
-
-static struct msm_sensor_reg_t ov7692_regs = {
-	.default_data_type = MSM_CAMERA_I2C_BYTE_DATA,
-	.start_stream_conf = ov7692_start_settings,
-	.start_stream_conf_size = ARRAY_SIZE(ov7692_start_settings),
-	.stop_stream_conf = ov7692_stop_settings,
-	.stop_stream_conf_size = ARRAY_SIZE(ov7692_stop_settings),
-	.init_settings = &ov7692_init_conf[0],
-	.init_size = ARRAY_SIZE(ov7692_init_conf),
-	.mode_settings = &ov7692_confs[0],
-	.no_effect_settings = &ov7692_no_effect_confs[0],
-	.output_settings = &ov7692_dimensions[0],
-	.num_conf = ARRAY_SIZE(ov7692_confs),
-};
-
-static struct msm_sensor_ctrl_t ov7692_s_ctrl = {
-	.msm_sensor_reg = &ov7692_regs,
-	.msm_sensor_v4l2_ctrl_info = ov7692_v4l2_ctrl_info,
-	.num_v4l2_ctrl = ARRAY_SIZE(ov7692_v4l2_ctrl_info),
-	.sensor_i2c_client = &ov7692_sensor_i2c_client,
-	.sensor_i2c_addr = 0x78,
-	.sensor_output_reg_addr = &ov7692_reg_addr,
-	.sensor_id_info = &ov7692_id_info,
-	.cam_mode = MSM_SENSOR_MODE_INVALID,
-	.msm_sensor_mutex = &ov7692_mut,
-	.sensor_i2c_driver = &ov7692_i2c_driver,
-	.sensor_v4l2_subdev_info = ov7692_subdev_info,
-	.sensor_v4l2_subdev_info_size = ARRAY_SIZE(ov7692_subdev_info),
-	.sensor_v4l2_subdev_ops = &ov7692_subdev_ops,
-	.func_tbl = &ov7692_func_tbl,
-	.clk_rate = MSM_SENSOR_MCLK_24HZ,
-};
-
-module_init(msm_sensor_init_module);
-MODULE_DESCRIPTION("Omnivision VGA YUV sensor driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/sensors/ov8825_v4l2.c b/drivers/media/platform/msm/camera_v1/sensors/ov8825_v4l2.c
deleted file mode 100644
index ddf4619..0000000
--- a/drivers/media/platform/msm/camera_v1/sensors/ov8825_v4l2.c
+++ /dev/null
@@ -1,937 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- *
- */
-
-#include "msm_sensor.h"
-#include "msm.h"
-#define SENSOR_NAME "ov8825"
-#define PLATFORM_DRIVER_NAME "msm_camera_ov8825"
-#define ov8825_obj ov8825_##obj
-
-/* TO DO - Currently ov5647 typical values are used
- * Need to get the exact values */
-#define OV8825_RG_RATIO_TYPICAL_VALUE 64 /* R/G of typical camera module */
-#define OV8825_BG_RATIO_TYPICAL_VALUE 105 /* B/G of typical camera module */
-
-DEFINE_MUTEX(ov8825_mut);
-static struct msm_sensor_ctrl_t ov8825_s_ctrl;
-
-struct otp_struct {
-	uint8_t customer_id;
-	uint8_t module_integrator_id;
-	uint8_t lens_id;
-	uint8_t rg_ratio;
-	uint8_t bg_ratio;
-	uint8_t user_data[5];
-} st_ov8825_otp;
-
-static struct msm_camera_i2c_reg_conf ov8825_start_settings[] = {
-	{0x0100, 0x01},
-};
-
-static struct msm_camera_i2c_reg_conf ov8825_stop_settings[] = {
-	{0x0100, 0x00},
-};
-
-static struct msm_camera_i2c_reg_conf ov8825_groupon_settings[] = {
-	{0x3208, 0x00},
-};
-
-static struct msm_camera_i2c_reg_conf ov8825_groupoff_settings[] = {
-	{0x3208, 0x10},
-	{0x3208, 0xA0},
-};
-
-static struct msm_camera_i2c_reg_conf ov8825_prev_settings[] = {
-	{0x3003, 0xce}, /*PLL_CTRL0*/
-	{0x3004, 0xd4}, /*PLL_CTRL1*/
-	{0x3005, 0x00}, /*PLL_CTRL2*/
-	{0x3006, 0x10}, /*PLL_CTRL3*/
-	{0x3007, 0x3b}, /*PLL_CTRL4*/
-	{0x3011, 0x01}, /*MIPI_Lane_4_Lane*/
-	{0x3012, 0x80}, /*SC_PLL CTRL_S0*/
-	{0x3013, 0x39}, /*SC_PLL CTRL_S1*/
-	{0x3104, 0x20}, /*SCCB_PLL*/
-	{0x3106, 0x15}, /*SRB_CTRL*/
-	{0x3501, 0x4e}, /*AEC_HIGH*/
-	{0x3502, 0xa0}, /*AEC_LOW*/
-	{0x350b, 0x1f}, /*AGC*/
-	{0x3600, 0x06}, /*ANACTRL0*/
-	{0x3601, 0x34}, /*ANACTRL1*/
-	{0x3700, 0x20}, /*SENCTROL0 Sensor control*/
-	{0x3702, 0x50}, /*SENCTROL2 Sensor control*/
-	{0x3703, 0xcc}, /*SENCTROL3 Sensor control*/
-	{0x3704, 0x19}, /*SENCTROL4 Sensor control*/
-	{0x3705, 0x14}, /*SENCTROL5 Sensor control*/
-	{0x3706, 0x4b}, /*SENCTROL6 Sensor control*/
-	{0x3707, 0x63}, /*SENCTROL7 Sensor control*/
-	{0x3708, 0x84}, /*SENCTROL8 Sensor control*/
-	{0x3709, 0x40}, /*SENCTROL9 Sensor control*/
-	{0x370a, 0x12}, /*SENCTROLA Sensor control*/
-	{0x370e, 0x00}, /*SENCTROLE Sensor control*/
-	{0x3711, 0x0f}, /*SENCTROL11 Sensor control*/
-	{0x3712, 0x9c}, /*SENCTROL12 Sensor control*/
-	{0x3724, 0x01}, /*Reserved*/
-	{0x3725, 0x92}, /*Reserved*/
-	{0x3726, 0x01}, /*Reserved*/
-	{0x3727, 0xa9}, /*Reserved*/
-	{0x3800, 0x00}, /*HS(HREF start High)*/
-	{0x3801, 0x00}, /*HS(HREF start Low)*/
-	{0x3802, 0x00}, /*VS(Vertical start High)*/
-	{0x3803, 0x00}, /*VS(Vertical start Low)*/
-	{0x3804, 0x0c}, /*HW = 3295*/
-	{0x3805, 0xdf}, /*HW*/
-	{0x3806, 0x09}, /*VH = 2459*/
-	{0x3807, 0x9b}, /*VH*/
-	{0x3808, 0x06}, /*ISPHO = 1632*/
-	{0x3809, 0x60}, /*ISPHO*/
-	{0x380a, 0x04}, /*ISPVO = 1224*/
-	{0x380b, 0xc8}, /*ISPVO*/
-	{0x380c, 0x0d}, /*HTS = 3516*/
-	{0x380d, 0xbc}, /*HTS*/
-	{0x380e, 0x04}, /*VTS = 1264*/
-	{0x380f, 0xf0}, /*VTS*/
-	{0x3810, 0x00}, /*HOFF = 8*/
-	{0x3811, 0x08}, /*HOFF*/
-	{0x3812, 0x00}, /*VOFF = 4*/
-	{0x3813, 0x04}, /*VOFF*/
-	{0x3814, 0x31}, /*X INC*/
-	{0x3815, 0x31}, /*Y INC*/
-	{0x3820, 0x81}, /*Timing Reg20:Vflip*/
-	{0x3821, 0x17}, /*Timing Reg21:Hmirror*/
-	{0x3f00, 0x00}, /*PSRAM Ctrl0*/
-	{0x3f01, 0xfc}, /*PSRAM Ctrl1*/
-	{0x3f05, 0x10}, /*PSRAM Ctrl5*/
-	{0x4600, 0x04}, /*VFIFO Ctrl0*/
-	{0x4601, 0x00}, /*VFIFO Read ST High*/
-	{0x4602, 0x30}, /*VFIFO Read ST Low*/
-	{0x4837, 0x28}, /*MIPI PCLK PERIOD*/
-	{0x5068, 0x00}, /*HSCALE_CTRL*/
-	{0x506a, 0x00}, /*VSCALE_CTRL*/
-	{0x5c00, 0x80}, /*PBLC CTRL00*/
-	{0x5c01, 0x00}, /*PBLC CTRL01*/
-	{0x5c02, 0x00}, /*PBLC CTRL02*/
-	{0x5c03, 0x00}, /*PBLC CTRL03*/
-	{0x5c04, 0x00}, /*PBLC CTRL04*/
-	{0x5c08, 0x10}, /*PBLC CTRL08*/
-	{0x6900, 0x61}, /*CADC CTRL00*/
-};
-
-static struct msm_camera_i2c_reg_conf ov8825_snap_settings[] = {
-	{0x3003, 0xce}, /*PLL_CTRL0*/
-	{0x3004, 0xd8}, /*PLL_CTRL1*/
-	{0x3005, 0x00}, /*PLL_CTRL2*/
-	{0x3006, 0x10}, /*PLL_CTRL3*/
-	{0x3007, 0x3b}, /*PLL_CTRL4*/
-	{0x3011, 0x01}, /*MIPI_Lane_4_Lane*/
-	{0x3012, 0x81}, /*SC_PLL CTRL_S0*/
-	{0x3013, 0x39}, /*SC_PLL CTRL_S1*/
-	{0x3104, 0x20}, /*SCCB_PLL*/
-	{0x3106, 0x11}, /*SRB_CTRL*/
-	{0x3501, 0x9a}, /*AEC_HIGH*/
-	{0x3502, 0xa0}, /*AEC_LOW*/
-	{0x350b, 0x1f}, /*AGC*/
-	{0x3600, 0x07}, /*ANACTRL0*/
-	{0x3601, 0x33}, /*ANACTRL1*/
-	{0x3700, 0x10}, /*SENCTROL0 Sensor control*/
-	{0x3702, 0x28}, /*SENCTROL2 Sensor control*/
-	{0x3703, 0x6c}, /*SENCTROL3 Sensor control*/
-	{0x3704, 0x8d}, /*SENCTROL4 Sensor control*/
-	{0x3705, 0x0a}, /*SENCTROL5 Sensor control*/
-	{0x3706, 0x27}, /*SENCTROL6 Sensor control*/
-	{0x3707, 0x63}, /*SENCTROL7 Sensor control*/
-	{0x3708, 0x40}, /*SENCTROL8 Sensor control*/
-	{0x3709, 0x20}, /*SENCTROL9 Sensor control*/
-	{0x370a, 0x12}, /*SENCTROLA Sensor control*/
-	{0x370e, 0x00}, /*SENCTROLE Sensor control*/
-	{0x3711, 0x07}, /*SENCTROL11 Sensor control*/
-	{0x3712, 0x4e}, /*SENCTROL12 Sensor control*/
-	{0x3724, 0x00}, /*Reserved*/
-	{0x3725, 0xd4}, /*Reserved*/
-	{0x3726, 0x00}, /*Reserved*/
-	{0x3727, 0xe1}, /*Reserved*/
-	{0x3800, 0x00}, /*HS(HREF start High)*/
-	{0x3801, 0x00}, /*HS(HREF start Low)*/
-	{0x3802, 0x00}, /*VS(Vertical start Hgh)*/
-	{0x3803, 0x00}, /*VS(Vertical start Low)*/
-	{0x3804, 0x0c}, /*HW = 3295*/
-	{0x3805, 0xdf}, /*HW*/
-	{0x3806, 0x09}, /*VH = 2459*/
-	{0x3807, 0x9b}, /*VH*/
-	{0x3808, 0x0c}, /*ISPHO = 1632*/
-	{0x3809, 0xc0}, /*ISPHO*/
-	{0x380a, 0x09}, /*ISPVO = 1224*/
-	{0x380b, 0x90}, /*ISPVO*/
-	{0x380c, 0x0e}, /*HTS = 3516*/
-	{0x380d, 0x00}, /*HTS*/
-	{0x380e, 0x09}, /*VTS = 1264*/
-	{0x380f, 0xb0}, /*VTS*/
-	{0x3810, 0x00}, /*HOFF = 8*/
-	{0x3811, 0x10}, /*HOFF*/
-	{0x3812, 0x00}, /*VOFF = 4*/
-	{0x3813, 0x06}, /*VOFF*/
-	{0x3814, 0x11}, /*X INC*/
-	{0x3815, 0x11}, /*Y INC*/
-	{0x3820, 0x80}, /*Timing Reg20:Vflip*/
-	{0x3821, 0x16}, /*Timing Reg21:Hmirror*/
-	{0x3f00, 0x02}, /*PSRAM Ctrl0*/
-	{0x3f01, 0xfc}, /*PSRAM Ctrl1*/
-	{0x3f05, 0x10}, /*PSRAM Ctrl5*/
-	{0x4600, 0x04}, /*VFIFO Ctrl0*/
-	{0x4601, 0x00}, /*VFIFO Read ST High*/
-	{0x4602, 0x78}, /*VFIFO Read ST Low*/
-	{0x4837, 0x28}, /*MIPI PCLK PERIOD*/
-	{0x5068, 0x00}, /*HSCALE_CTRL*/
-	{0x506a, 0x00}, /*VSCALE_CTRL*/
-	{0x5c00, 0x80}, /*PBLC CTRL00*/
-	{0x5c01, 0x00}, /*PBLC CTRL01*/
-	{0x5c02, 0x00}, /*PBLC CTRL02*/
-	{0x5c03, 0x00}, /*PBLC CTRL03*/
-	{0x5c04, 0x00}, /*PBLC CTRL04*/
-	{0x5c08, 0x10}, /*PBLC CTRL08*/
-	{0x6900, 0x61}, /*CADC CTRL00*/
-};
-
-
-static struct msm_camera_i2c_reg_conf ov8825_reset_settings[] = {
-	{0x0103, 0x01},
-};
-
-static struct msm_camera_i2c_reg_conf ov8825_recommend_settings[] = {
-	{0x3000, 0x16},
-	{0x3001, 0x00},
-	{0x3002, 0x6c},
-	{0x300d, 0x00},
-	{0x301f, 0x09},
-	{0x3010, 0x00},
-	{0x3018, 0x00},
-	{0x3300, 0x00},
-	{0x3500, 0x00},
-	{0x3503, 0x07},
-	{0x3509, 0x00},
-	{0x3602, 0x42},
-	{0x3603, 0x5c},
-	{0x3604, 0x98},
-	{0x3605, 0xf5},
-	{0x3609, 0xb4},
-	{0x360a, 0x7c},
-	{0x360b, 0xc9},
-	{0x360c, 0x0b},
-	{0x3612, 0x00},
-	{0x3613, 0x02},
-	{0x3614, 0x0f},
-	{0x3615, 0x00},
-	{0x3616, 0x03},
-	{0x3617, 0xa1},
-	{0x3618, 0x00},
-	{0x3619, 0x00},
-	{0x361a, 0xB0},
-	{0x361b, 0x04},
-	{0x361c, 0x07},
-	{0x3701, 0x44},
-	{0x370b, 0x01},
-	{0x370c, 0x50},
-	{0x370d, 0x00},
-	{0x3816, 0x02},
-	{0x3817, 0x40},
-	{0x3818, 0x00},
-	{0x3819, 0x40},
-	{0x3b1f, 0x00},
-	{0x3d00, 0x00},
-	{0x3d01, 0x00},
-	{0x3d02, 0x00},
-	{0x3d03, 0x00},
-	{0x3d04, 0x00},
-	{0x3d05, 0x00},
-	{0x3d06, 0x00},
-	{0x3d07, 0x00},
-	{0x3d08, 0x00},
-	{0x3d09, 0x00},
-	{0x3d0a, 0x00},
-	{0x3d0b, 0x00},
-	{0x3d0c, 0x00},
-	{0x3d0d, 0x00},
-	{0x3d0e, 0x00},
-	{0x3d0f, 0x00},
-	{0x3d10, 0x00},
-	{0x3d11, 0x00},
-	{0x3d12, 0x00},
-	{0x3d13, 0x00},
-	{0x3d14, 0x00},
-	{0x3d15, 0x00},
-	{0x3d16, 0x00},
-	{0x3d17, 0x00},
-	{0x3d18, 0x00},
-	{0x3d19, 0x00},
-	{0x3d1a, 0x00},
-	{0x3d1b, 0x00},
-	{0x3d1c, 0x00},
-	{0x3d1d, 0x00},
-	{0x3d1e, 0x00},
-	{0x3d1f, 0x00},
-	{0x3d80, 0x00},
-	{0x3d81, 0x00},
-	{0x3d84, 0x00},
-	{0x3f06, 0x00},
-	{0x3f07, 0x00},
-	{0x4000, 0x29},
-	{0x4001, 0x02},
-	{0x4002, 0x45},
-	{0x4003, 0x08},
-	{0x4004, 0x04},
-	{0x4005, 0x18},
-	{0x4300, 0xff},
-	{0x4303, 0x00},
-	{0x4304, 0x08},
-	{0x4307, 0x00},
-	{0x4800, 0x04},
-	{0x4801, 0x0f},
-	{0x4843, 0x02},
-	{0x5000, 0x06},
-	{0x5001, 0x00},
-	{0x5002, 0x00},
-	{0x501f, 0x00},
-	{0x5780, 0xfc},
-	{0x5c05, 0x00},
-	{0x5c06, 0x00},
-	{0x5c07, 0x80},
-	{0x6700, 0x05},
-	{0x6701, 0x19},
-	{0x6702, 0xfd},
-	{0x6703, 0xd7},
-	{0x6704, 0xff},
-	{0x6705, 0xff},
-	{0x6800, 0x10},
-	{0x6801, 0x02},
-	{0x6802, 0x90},
-	{0x6803, 0x10},
-	{0x6804, 0x59},
-	{0x6901, 0x04},
-	{0x5800, 0x0f},
-	{0x5801, 0x0d},
-	{0x5802, 0x09},
-	{0x5803, 0x0a},
-	{0x5804, 0x0d},
-	{0x5805, 0x14},
-	{0x5806, 0x0a},
-	{0x5807, 0x04},
-	{0x5808, 0x03},
-	{0x5809, 0x03},
-	{0x580a, 0x05},
-	{0x580b, 0x0a},
-	{0x580c, 0x05},
-	{0x580d, 0x02},
-	{0x580e, 0x00},
-	{0x580f, 0x00},
-	{0x5810, 0x03},
-	{0x5811, 0x05},
-	{0x5812, 0x09},
-	{0x5813, 0x03},
-	{0x5814, 0x01},
-	{0x5815, 0x01},
-	{0x5816, 0x04},
-	{0x5817, 0x09},
-	{0x5818, 0x09},
-	{0x5819, 0x08},
-	{0x581a, 0x06},
-	{0x581b, 0x06},
-	{0x581c, 0x08},
-	{0x581d, 0x06},
-	{0x581e, 0x33},
-	{0x581f, 0x11},
-	{0x5820, 0x0e},
-	{0x5821, 0x0f},
-	{0x5822, 0x11},
-	{0x5823, 0x3f},
-	{0x5824, 0x08},
-	{0x5825, 0x46},
-	{0x5826, 0x46},
-	{0x5827, 0x46},
-	{0x5828, 0x46},
-	{0x5829, 0x46},
-	{0x582a, 0x42},
-	{0x582b, 0x42},
-	{0x582c, 0x44},
-	{0x582d, 0x46},
-	{0x582e, 0x46},
-	{0x582f, 0x60},
-	{0x5830, 0x62},
-	{0x5831, 0x42},
-	{0x5832, 0x46},
-	{0x5833, 0x46},
-	{0x5834, 0x44},
-	{0x5835, 0x44},
-	{0x5836, 0x44},
-	{0x5837, 0x48},
-	{0x5838, 0x28},
-	{0x5839, 0x46},
-	{0x583a, 0x48},
-	{0x583b, 0x68},
-	{0x583c, 0x28},
-	{0x583d, 0xae},
-	{0x5842, 0x00},
-	{0x5843, 0xef},
-	{0x5844, 0x01},
-	{0x5845, 0x3f},
-	{0x5846, 0x01},
-	{0x5847, 0x3f},
-	{0x5848, 0x00},
-	{0x5849, 0xd5},
-	{0x3503, 0x07},
-	{0x3500, 0x00},
-	{0x3501, 0x27},
-	{0x3502, 0x00},
-	{0x350b, 0xff},
-	{0x3400, 0x04},
-	{0x3401, 0x00},
-	{0x3402, 0x04},
-	{0x3403, 0x00},
-	{0x3404, 0x04},
-	{0x3405, 0x00},
-	{0x3406, 0x01},
-	{0x5001, 0x01},
-	{0x5000, 0x86},/* enable lens compensation and dpc */
-	/* LENC setting 70% */
-	{0x5800, 0x21},
-	{0x5801, 0x10},
-	{0x5802, 0x09},
-	{0x5803, 0x0a},
-	{0x5804, 0x0f},
-	{0x5805, 0x23},
-	{0x5806, 0x08},
-	{0x5807, 0x04},
-	{0x5808, 0x04},
-	{0x5809, 0x04},
-	{0x580a, 0x04},
-	{0x580b, 0x0a},
-	{0x580c, 0x04},
-	{0x580d, 0x02},
-	{0x580e, 0x00},
-	{0x580f, 0x00},
-	{0x5810, 0x03},
-	{0x5811, 0x06},
-	{0x5812, 0x05},
-	{0x5813, 0x02},
-	{0x5814, 0x00},
-	{0x5815, 0x00},
-	{0x5816, 0x03},
-	{0x5817, 0x06},
-	{0x5818, 0x09},
-	{0x5819, 0x05},
-	{0x581a, 0x04},
-	{0x581b, 0x04},
-	{0x581c, 0x05},
-	{0x581d, 0x0a},
-	{0x581e, 0x24},
-	{0x581f, 0x11},
-	{0x5820, 0x0a},
-	{0x5821, 0x0a},
-	{0x5822, 0x10},
-	{0x5823, 0x27},
-	{0x5824, 0x2a},
-	{0x5825, 0x58},
-	{0x5826, 0x28},
-	{0x5827, 0x28},
-	{0x5828, 0x28},
-	{0x5829, 0x28},
-	{0x582a, 0x46},
-	{0x582b, 0x44},
-	{0x582c, 0x46},
-	{0x582d, 0x46},
-	{0x582e, 0x28},
-	{0x582f, 0x62},
-	{0x5830, 0x60},
-	{0x5831, 0x42},
-	{0x5832, 0x28},
-	{0x5833, 0x48},
-	{0x5834, 0x46},
-	{0x5835, 0x46},
-	{0x5836, 0x26},
-	{0x5837, 0x46},
-	{0x5838, 0x28},
-	{0x5839, 0x48},
-	{0x583a, 0x28},
-	{0x583b, 0x28},
-	{0x583c, 0x26},
-	{0x583d, 0x9d},
-};
-
-static struct v4l2_subdev_info ov8825_subdev_info[] = {
-	{
-		.code   = V4L2_MBUS_FMT_SBGGR10_1X10,
-		.colorspace = V4L2_COLORSPACE_JPEG,
-		.fmt    = 1,
-		.order    = 0,
-	},
-	/* more can be supported, to be added later */
-};
-
-static struct msm_camera_i2c_conf_array ov8825_init_conf[] = {
-	{&ov8825_reset_settings[0],
-	ARRAY_SIZE(ov8825_reset_settings), 50, MSM_CAMERA_I2C_BYTE_DATA},
-	{&ov8825_recommend_settings[0],
-	ARRAY_SIZE(ov8825_recommend_settings), 0, MSM_CAMERA_I2C_BYTE_DATA}
-};
-
-static struct msm_camera_i2c_conf_array ov8825_confs[] = {
-	{&ov8825_snap_settings[0],
-	ARRAY_SIZE(ov8825_snap_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-	{&ov8825_prev_settings[0],
-	ARRAY_SIZE(ov8825_prev_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-};
-
-static struct msm_sensor_output_info_t ov8825_dimensions[] = {
-	{
-		.x_output = 0xCC0,
-		.y_output = 0x990,
-		.line_length_pclk = 0xE00,
-		.frame_length_lines = 0x9B0,
-		.vt_pixel_clk = 133400000,
-		.op_pixel_clk = 176000000,
-		.binning_factor = 1,
-	},
-	{
-		.x_output = 0x660,
-		.y_output = 0x4C8,
-		.line_length_pclk = 0x6DE,
-		.frame_length_lines = 0x505,
-		.vt_pixel_clk = 66700000,
-		.op_pixel_clk = 88000000,
-		.binning_factor = 2,
-	},
-};
-
-static struct msm_sensor_output_reg_addr_t ov8825_reg_addr = {
-	.x_output = 0x3808,
-	.y_output = 0x380a,
-	.line_length_pclk = 0x380c,
-	.frame_length_lines = 0x380e,
-};
-
-static struct msm_sensor_id_info_t ov8825_id_info = {
-	.sensor_id_reg_addr = 0x300A,
-	.sensor_id = 0x8825,
-};
-
-static struct msm_sensor_exp_gain_info_t ov8825_exp_gain_info = {
-	.coarse_int_time_addr = 0x3501,
-	.global_gain_addr = 0x350A,
-	.vert_offset = 6,
-};
-
-/********************************************
- * index: index of otp group. (0, 1, 2)
- * return value:
- *     0, group index is empty
- *     1, group index has invalid data
- *     2, group index has valid data
- **********************************************/
-uint16_t ov8825_check_otp_wb(struct msm_sensor_ctrl_t *s_ctrl, uint16_t index)
-{
-	uint16_t temp, i;
-	uint16_t address;
-
-	/* clear otp buffer */
-
-	/* select otp bank 0 */
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client, 0x3d84, 0x08,
-			MSM_CAMERA_I2C_BYTE_DATA);
-
-	/* load otp into buffer */
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client, 0x3d81, 0x01,
-			MSM_CAMERA_I2C_BYTE_DATA);
-
-	/* read from group [index] */
-	address = 0x3d05 + index * 9;
-	msm_camera_i2c_read(s_ctrl->sensor_i2c_client, address, &temp,
-			MSM_CAMERA_I2C_BYTE_DATA);
-
-	/* disable otp read */
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client, 0x3d81, 0x00,
-			MSM_CAMERA_I2C_BYTE_DATA);
-
-	/* clear otp buffer */
-	for (i = 0; i < 32; i++) {
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client, (0x3d00+i),
-				0x00, MSM_CAMERA_I2C_BYTE_DATA);
-	}
-
-	if (!temp)
-		return 0;
-	else if ((!(temp & 0x80)) && (temp & 0x7f))
-		return 2;
-	else
-		return 1;
-}
-
-void ov8825_read_otp_wb(struct msm_sensor_ctrl_t *s_ctrl,
-		uint16_t index, struct otp_struct *potp)
-{
-	uint16_t temp, i;
-	uint16_t address;
-
-	/* select otp bank 0 */
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client, 0x3d84, 0x08,
-			MSM_CAMERA_I2C_BYTE_DATA);
-
-	/* load otp data into buffer */
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client, 0x3d81, 0x01,
-			MSM_CAMERA_I2C_BYTE_DATA);
-
-	/* read otp data from 0x3d00 - 0x3d1f*/
-	address = 0x3d05 + index * 9;
-
-	msm_camera_i2c_read(s_ctrl->sensor_i2c_client, address, &temp,
-			MSM_CAMERA_I2C_BYTE_DATA);
-
-	potp->module_integrator_id = temp;
-	potp->customer_id = temp & 0x7f;
-
-	msm_camera_i2c_read(s_ctrl->sensor_i2c_client, (address+1), &temp,
-			MSM_CAMERA_I2C_BYTE_DATA);
-	potp->lens_id = temp;
-
-	msm_camera_i2c_read(s_ctrl->sensor_i2c_client, (address+2), &temp,
-			MSM_CAMERA_I2C_BYTE_DATA);
-	potp->rg_ratio = temp;
-
-	msm_camera_i2c_read(s_ctrl->sensor_i2c_client, (address+3), &temp,
-			MSM_CAMERA_I2C_BYTE_DATA);
-	potp->bg_ratio = temp;
-
-	msm_camera_i2c_read(s_ctrl->sensor_i2c_client, (address+4), &temp,
-			MSM_CAMERA_I2C_BYTE_DATA);
-	potp->user_data[0] = temp;
-
-	msm_camera_i2c_read(s_ctrl->sensor_i2c_client, (address+5), &temp,
-			MSM_CAMERA_I2C_BYTE_DATA);
-	potp->user_data[1] = temp;
-
-	msm_camera_i2c_read(s_ctrl->sensor_i2c_client, (address+6), &temp,
-			MSM_CAMERA_I2C_BYTE_DATA);
-	potp->user_data[2] = temp;
-
-	msm_camera_i2c_read(s_ctrl->sensor_i2c_client, (address+7), &temp,
-			MSM_CAMERA_I2C_BYTE_DATA);
-	potp->user_data[3] = temp;
-
-	msm_camera_i2c_read(s_ctrl->sensor_i2c_client, (address+8), &temp,
-			MSM_CAMERA_I2C_BYTE_DATA);
-	potp->user_data[4] = temp;
-
-	CDBG("%s customer_id  = 0x%02x\r\n", __func__, potp->customer_id);
-	CDBG("%s lens_id      = 0x%02x\r\n", __func__, potp->lens_id);
-	CDBG("%s rg_ratio     = 0x%02x\r\n", __func__, potp->rg_ratio);
-	CDBG("%s bg_ratio     = 0x%02x\r\n", __func__, potp->bg_ratio);
-	CDBG("%s user_data[0] = 0x%02x\r\n", __func__, potp->user_data[0]);
-	CDBG("%s user_data[1] = 0x%02x\r\n", __func__, potp->user_data[1]);
-	CDBG("%s user_data[2] = 0x%02x\r\n", __func__, potp->user_data[2]);
-	CDBG("%s user_data[3] = 0x%02x\r\n", __func__, potp->user_data[3]);
-	CDBG("%s user_data[4] = 0x%02x\r\n", __func__, potp->user_data[4]);
-
-	/* disable otp read */
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client, 0x3d81, 0x00,
-			MSM_CAMERA_I2C_BYTE_DATA);
-
-	/* clear otp buffer */
-	for (i = 0; i < 32; i++)
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client, (0x3d00+i),
-				0x00, MSM_CAMERA_I2C_BYTE_DATA);
-}
-
-/**********************************************
- * r_gain, sensor red gain of AWB, 0x400 =1
- * g_gain, sensor green gain of AWB, 0x400 =1
- * b_gain, sensor blue gain of AWB, 0x400 =1
- ***********************************************/
-void ov8825_update_awb_gain(struct msm_sensor_ctrl_t *s_ctrl,
-		uint16_t r_gain, uint16_t g_gain, uint16_t b_gain)
-{
-	CDBG("%s r_gain = 0x%04x\r\n", __func__, r_gain);
-	CDBG("%s g_gain = 0x%04x\r\n", __func__, g_gain);
-	CDBG("%s b_gain = 0x%04x\r\n", __func__, b_gain);
-	if (r_gain > 0x400) {
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client, 0x5186,
-				(r_gain>>8), MSM_CAMERA_I2C_BYTE_DATA);
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client, 0x5187,
-				(r_gain&0xff), MSM_CAMERA_I2C_BYTE_DATA);
-	}
-	if (g_gain > 0x400) {
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client, 0x5188,
-				(g_gain>>8), MSM_CAMERA_I2C_BYTE_DATA);
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client, 0x5189,
-				(g_gain&0xff), MSM_CAMERA_I2C_BYTE_DATA);
-	}
-	if (b_gain > 0x400) {
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client, 0x518a,
-				(b_gain>>8), MSM_CAMERA_I2C_BYTE_DATA);
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client, 0x518b,
-				(b_gain&0xff), MSM_CAMERA_I2C_BYTE_DATA);
-	}
-}
-
-/**************************************************
- * call this function after OV8825 initialization
- * return value:
- *     0, update success
- *     1, no OTP
- ***************************************************/
-uint16_t ov8825_update_otp(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	uint16_t i;
-	uint16_t otp_index;
-	uint16_t temp;
-	uint16_t r_gain, g_gain, b_gain, g_gain_r, g_gain_b;
-
-	/* R/G and B/G of current camera module is read out from sensor OTP */
-	/* check first OTP with valid data */
-	for (i = 0; i < 3; i++) {
-		temp = ov8825_check_otp_wb(s_ctrl, i);
-		if (temp == 2) {
-			otp_index = i;
-			break;
-		}
-	}
-	if (i == 3) {
-		/* no valid wb OTP data */
-		CDBG("no valid wb OTP data\r\n");
-		return 1;
-	}
-	ov8825_read_otp_wb(s_ctrl, otp_index, &st_ov8825_otp);
-	/* calculate g_gain */
-	/* 0x400 = 1x gain */
-	if (st_ov8825_otp.bg_ratio < OV8825_BG_RATIO_TYPICAL_VALUE) {
-		if (st_ov8825_otp.rg_ratio < OV8825_RG_RATIO_TYPICAL_VALUE) {
-			g_gain = 0x400;
-			b_gain = 0x400 *
-				OV8825_BG_RATIO_TYPICAL_VALUE /
-				st_ov8825_otp.bg_ratio;
-			r_gain = 0x400 *
-				OV8825_RG_RATIO_TYPICAL_VALUE /
-				st_ov8825_otp.rg_ratio;
-		} else {
-			r_gain = 0x400;
-			g_gain = 0x400 *
-				st_ov8825_otp.rg_ratio /
-				OV8825_RG_RATIO_TYPICAL_VALUE;
-			b_gain = g_gain *
-				OV8825_BG_RATIO_TYPICAL_VALUE /
-				st_ov8825_otp.bg_ratio;
-		}
-	} else {
-		if (st_ov8825_otp.rg_ratio < OV8825_RG_RATIO_TYPICAL_VALUE) {
-			b_gain = 0x400;
-			g_gain = 0x400 *
-				st_ov8825_otp.bg_ratio /
-				OV8825_BG_RATIO_TYPICAL_VALUE;
-			r_gain = g_gain *
-				OV8825_RG_RATIO_TYPICAL_VALUE /
-				st_ov8825_otp.rg_ratio;
-		} else {
-			g_gain_b = 0x400 *
-				st_ov8825_otp.bg_ratio /
-				OV8825_BG_RATIO_TYPICAL_VALUE;
-			g_gain_r = 0x400 *
-				st_ov8825_otp.rg_ratio /
-				OV8825_RG_RATIO_TYPICAL_VALUE;
-			if (g_gain_b > g_gain_r) {
-				b_gain = 0x400;
-				g_gain = g_gain_b;
-				r_gain = g_gain *
-					OV8825_RG_RATIO_TYPICAL_VALUE /
-					st_ov8825_otp.rg_ratio;
-			} else {
-				r_gain = 0x400;
-				g_gain = g_gain_r;
-				b_gain = g_gain *
-					OV8825_BG_RATIO_TYPICAL_VALUE /
-					st_ov8825_otp.bg_ratio;
-			}
-		}
-	}
-	ov8825_update_awb_gain(s_ctrl, r_gain, g_gain, b_gain);
-	return 0;
-}
-
-static int32_t ov8825_write_exp_gain(struct msm_sensor_ctrl_t *s_ctrl,
-		uint16_t gain, uint32_t line)
-{
-	uint32_t fl_lines, offset;
-	uint8_t int_time[3];
-
-	fl_lines =
-		(s_ctrl->curr_frame_length_lines * s_ctrl->fps_divider) / Q10;
-	offset = s_ctrl->sensor_exp_gain_info->vert_offset;
-	if (line > (fl_lines - offset))
-		fl_lines = line + offset;
-	CDBG("ov8825_write_exp_gain: %d %d %d\n", fl_lines, gain, line);
-	s_ctrl->func_tbl->sensor_group_hold_on(s_ctrl);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_output_reg_addr->frame_length_lines, fl_lines,
-		MSM_CAMERA_I2C_WORD_DATA);
-	int_time[0] = line >> 12;
-	int_time[1] = line >> 4;
-	int_time[2] = line << 4;
-	msm_camera_i2c_write_seq(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->coarse_int_time_addr-1,
-		&int_time[0], 3);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->global_gain_addr, gain,
-		MSM_CAMERA_I2C_WORD_DATA);
-	s_ctrl->func_tbl->sensor_group_hold_off(s_ctrl);
-	return 0;
-}
-
-static const struct i2c_device_id ov8825_i2c_id[] = {
-	{SENSOR_NAME, (kernel_ulong_t)&ov8825_s_ctrl},
-	{ }
-};
-
-int32_t ov8825_sensor_power_up(struct msm_sensor_ctrl_t *s_ctrl)
-{
-	int32_t rc = 0;
-	struct msm_camera_sensor_info *info = NULL;
-
-	info = s_ctrl->sensordata;
-	gpio_direction_output(info->sensor_pwd, 0);
-	gpio_direction_output(info->sensor_reset, 0);
-	usleep_range(10000, 11000);
-	rc = msm_sensor_power_up(s_ctrl);
-	if (rc < 0) {
-		CDBG("%s: msm_sensor_power_up failed\n", __func__);
-		return rc;
-	}
-	/* turn on ldo and vreg */
-	gpio_direction_output(info->sensor_pwd, 1);
-	msleep(20);
-	gpio_direction_output(info->sensor_reset, 1);
-	msleep(40);
-	return rc;
-}
-
-static struct i2c_driver ov8825_i2c_driver = {
-	.id_table = ov8825_i2c_id,
-	.probe  = msm_sensor_i2c_probe,
-	.driver = {
-		.name = SENSOR_NAME,
-	},
-};
-
-static struct msm_camera_i2c_client ov8825_sensor_i2c_client = {
-	.addr_type = MSM_CAMERA_I2C_WORD_ADDR,
-};
-
-
-
-static int __init msm_sensor_init_module(void)
-{
-	return i2c_add_driver(&ov8825_i2c_driver);
-}
-
-static struct v4l2_subdev_core_ops ov8825_subdev_core_ops = {
-	.ioctl = msm_sensor_subdev_ioctl,
-	.s_power = msm_sensor_power,
-};
-
-static struct v4l2_subdev_video_ops ov8825_subdev_video_ops = {
-	.enum_mbus_fmt = msm_sensor_v4l2_enum_fmt,
-};
-
-static struct v4l2_subdev_ops ov8825_subdev_ops = {
-	.core = &ov8825_subdev_core_ops,
-	.video  = &ov8825_subdev_video_ops,
-};
-
-int32_t ov8825_sensor_setting(struct msm_sensor_ctrl_t *s_ctrl,
-			int update_type, int res)
-{
-	int32_t rc = 0;
-
-	if (update_type == MSM_SENSOR_REG_INIT) {
-		CDBG("Register INIT\n");
-		s_ctrl->func_tbl->sensor_stop_stream(s_ctrl);
-		msm_sensor_enable_debugfs(s_ctrl);
-		msm_sensor_write_init_settings(s_ctrl);
-		CDBG("Update OTP\n");
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client, 0x100, 0x1,
-				MSM_CAMERA_I2C_BYTE_DATA);
-		msleep(66);
-		ov8825_update_otp(s_ctrl);
-		usleep_range(10000, 11000);
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client, 0x100, 0x0,
-		  MSM_CAMERA_I2C_BYTE_DATA);
-	} else if (update_type == MSM_SENSOR_UPDATE_PERIODIC) {
-		CDBG("PERIODIC : %d\n", res);
-		msm_sensor_write_conf_array(
-			s_ctrl->sensor_i2c_client,
-			s_ctrl->msm_sensor_reg->mode_settings, res);
-		msleep(30);
-		v4l2_subdev_notify(&s_ctrl->sensor_v4l2_subdev,
-			NOTIFY_PCLK_CHANGE,
-			&s_ctrl->sensordata->pdata->ioclk.vfe_clk_rate);
-	}
-	return rc;
-}
-
-static struct msm_sensor_fn_t ov8825_func_tbl = {
-	.sensor_start_stream = msm_sensor_start_stream,
-	.sensor_stop_stream = msm_sensor_stop_stream,
-	.sensor_group_hold_on = msm_sensor_group_hold_on,
-	.sensor_group_hold_off = msm_sensor_group_hold_off,
-	.sensor_set_fps = msm_sensor_set_fps,
-	.sensor_write_exp_gain = ov8825_write_exp_gain,
-	.sensor_write_snapshot_exp_gain = ov8825_write_exp_gain,
-	.sensor_csi_setting = ov8825_sensor_setting,
-	.sensor_set_sensor_mode = msm_sensor_set_sensor_mode,
-	.sensor_mode_init = msm_sensor_mode_init,
-	.sensor_get_output_info = msm_sensor_get_output_info,
-	.sensor_config = msm_sensor_config,
-	.sensor_power_up = ov8825_sensor_power_up,
-	.sensor_power_down = msm_sensor_power_down,
-};
-
-static struct msm_sensor_reg_t ov8825_regs = {
-	.default_data_type = MSM_CAMERA_I2C_BYTE_DATA,
-	.start_stream_conf = ov8825_start_settings,
-	.start_stream_conf_size = ARRAY_SIZE(ov8825_start_settings),
-	.stop_stream_conf = ov8825_stop_settings,
-	.stop_stream_conf_size = ARRAY_SIZE(ov8825_stop_settings),
-	.group_hold_on_conf = ov8825_groupon_settings,
-	.group_hold_on_conf_size = ARRAY_SIZE(ov8825_groupon_settings),
-	.group_hold_off_conf = ov8825_groupoff_settings,
-	.group_hold_off_conf_size =	ARRAY_SIZE(ov8825_groupoff_settings),
-	.init_settings = &ov8825_init_conf[0],
-	.init_size = ARRAY_SIZE(ov8825_init_conf),
-	.mode_settings = &ov8825_confs[0],
-	.output_settings = &ov8825_dimensions[0],
-	.num_conf = ARRAY_SIZE(ov8825_confs),
-};
-
-static struct msm_sensor_ctrl_t ov8825_s_ctrl = {
-	.msm_sensor_reg = &ov8825_regs,
-	.sensor_i2c_client = &ov8825_sensor_i2c_client,
-	.sensor_i2c_addr = 0x6C,
-	.sensor_output_reg_addr = &ov8825_reg_addr,
-	.sensor_id_info = &ov8825_id_info,
-	.sensor_exp_gain_info = &ov8825_exp_gain_info,
-	.cam_mode = MSM_SENSOR_MODE_INVALID,
-	.msm_sensor_mutex = &ov8825_mut,
-	.sensor_i2c_driver = &ov8825_i2c_driver,
-	.sensor_v4l2_subdev_info = ov8825_subdev_info,
-	.sensor_v4l2_subdev_info_size = ARRAY_SIZE(ov8825_subdev_info),
-	.sensor_v4l2_subdev_ops = &ov8825_subdev_ops,
-	.func_tbl = &ov8825_func_tbl,
-};
-
-module_init(msm_sensor_init_module);
-MODULE_DESCRIPTION("Omnivison 8MP Bayer sensor driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/sensors/ov9726_v4l2.c b/drivers/media/platform/msm/camera_v1/sensors/ov9726_v4l2.c
deleted file mode 100644
index debd959..0000000
--- a/drivers/media/platform/msm/camera_v1/sensors/ov9726_v4l2.c
+++ /dev/null
@@ -1,268 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- *
- */
-
-#include "msm_sensor.h"
-#define SENSOR_NAME "ov9726"
-#define PLATFORM_DRIVER_NAME "msm_camera_ov9726"
-#define ov9726_obj ov9726_##obj
-
-DEFINE_MUTEX(ov9726_mut);
-static struct msm_sensor_ctrl_t ov9726_s_ctrl;
-
-static struct msm_camera_i2c_reg_conf ov9726_start_settings[] = {
-	{0x0100, 0x01},
-};
-
-static struct msm_camera_i2c_reg_conf ov9726_stop_settings[] = {
-	{0x0100, 0x00},
-};
-
-static struct msm_camera_i2c_reg_conf ov9726_groupon_settings[] = {
-	{0x0104, 0x01},
-};
-
-static struct msm_camera_i2c_reg_conf ov9726_groupoff_settings[] = {
-	{0x0104, 0x00},
-};
-
-static struct msm_camera_i2c_reg_conf ov9726_prev_settings[] = {
-};
-
-static struct msm_camera_i2c_reg_conf ov9726_recommend_settings[] = {
-	{0x0103, 0x01}, /* SOFTWARE_RESET */
-	{0x3026, 0x00}, /* OUTPUT_SELECT01 */
-	{0x3027, 0x00}, /* OUTPUT_SELECT02 */
-	{0x3002, 0xe8}, /* IO_CTRL00 */
-	{0x3004, 0x03}, /* IO_CTRL01 */
-	{0x3005, 0xff}, /* IO_CTRL02 */
-	{0x3703, 0x42},
-	{0x3704, 0x10},
-	{0x3705, 0x45},
-	{0x3603, 0xaa},
-	{0x3632, 0x2f},
-	{0x3620, 0x66},
-	{0x3621, 0xc0},
-	{0x0340, 0x03}, /* FRAME_LENGTH_LINES_HI */
-	{0x0341, 0xC1}, /* FRAME_LENGTH_LINES_LO */
-	{0x0342, 0x06}, /* LINE_LENGTH_PCK_HI */
-	{0x0343, 0x80}, /* LINE_LENGTH_PCK_LO */
-	{0x0202, 0x03}, /* COARSE_INTEGRATION_TIME_HI */
-	{0x0203, 0x43}, /* COARSE_INTEGRATION_TIME_LO */
-	{0x3833, 0x04},
-	{0x3835, 0x02},
-	{0x4702, 0x04},
-	{0x4704, 0x00}, /* DVP_CTRL01 */
-	{0x4706, 0x08},
-	{0x5052, 0x01},
-	{0x3819, 0x6e},
-	{0x3817, 0x94},
-	{0x3a18, 0x00}, /* AEC_GAIN_CEILING_HI */
-	{0x3a19, 0x7f}, /* AEC_GAIN_CEILING_LO */
-	{0x404e, 0x7e},
-	{0x3631, 0x52},
-	{0x3633, 0x50},
-	{0x3630, 0xd2},
-	{0x3604, 0x08},
-	{0x3601, 0x40},
-	{0x3602, 0x14},
-	{0x3610, 0xa0},
-	{0x3612, 0x20},
-	{0x034c, 0x05}, /* X_OUTPUT_SIZE_HI */
-	{0x034d, 0x10}, /* X_OUTPUT_SIZE_LO */
-	{0x034e, 0x03}, /* Y_OUTPUT_SIZE_HI */
-	{0x034f, 0x28}, /* Y_OUTPUT_SIZE_LO */
-	{0x0340, 0x03}, /* FRAME_LENGTH_LINES_HI */
-	{0x0341, 0xC1}, /* FRAME_LENGTH_LINES_LO */
-	{0x0342, 0x06}, /* LINE_LENGTH_PCK_HI */
-	{0x0343, 0x80}, /* LINE_LENGTH_PCK_LO */
-	{0x0202, 0x03}, /* COARSE_INTEGRATION_TIME_HI */
-	{0x0203, 0x43}, /* COARSE_INTEGRATION_TIME_LO */
-	{0x0303, 0x01}, /* VT_SYS_CLK_DIV_LO */
-	{0x3002, 0x00}, /* IO_CTRL00 */
-	{0x3004, 0x00}, /* IO_CTRL01 */
-	{0x3005, 0x00}, /* IO_CTRL02 */
-	{0x4801, 0x0f}, /* MIPI_CTRL01 */
-	{0x4803, 0x05}, /* MIPI_CTRL03 */
-	{0x4601, 0x16}, /* VFIFO_READ_CONTROL */
-	{0x3014, 0x05}, /* SC_CMMN_MIPI / SC_CTRL00 */
-	{0x3104, 0x80},
-	{0x0305, 0x04}, /* PRE_PLL_CLK_DIV_LO */
-	{0x0307, 0x64}, /* PLL_MULTIPLIER_LO */
-	{0x300c, 0x02},
-	{0x300d, 0x20},
-	{0x300e, 0x01},
-	{0x3010, 0x01},
-	{0x460e, 0x81}, /* VFIFO_CONTROL00 */
-	{0x0101, 0x01}, /* IMAGE_ORIENTATION */
-	{0x3707, 0x14},
-	{0x3622, 0x9f},
-	{0x5047, 0x3D}, /* ISP_CTRL47 */
-	{0x4002, 0x45}, /* BLC_CTRL02 */
-	{0x5000, 0x06}, /* ISP_CTRL0 */
-	{0x5001, 0x00}, /* ISP_CTRL1 */
-	{0x3406, 0x00}, /* AWB_MANUAL_CTRL */
-	{0x3503, 0x13}, /* AEC_ENABLE */
-	{0x4005, 0x18}, /* BLC_CTRL05 */
-	{0x4837, 0x21},
-	{0x0100, 0x01}, /* MODE_SELECT */
-	{0x3a0f, 0x64}, /* AEC_CTRL0F */
-	{0x3a10, 0x54}, /* AEC_CTRL10 */
-	{0x3a11, 0xc2}, /* AEC_CTRL11 */
-	{0x3a1b, 0x64}, /* AEC_CTRL1B */
-	{0x3a1e, 0x54}, /* AEC_CTRL1E */
-	{0x3a1a, 0x05}, /* AEC_DIFF_MAX */
-};
-
-static struct v4l2_subdev_info ov9726_subdev_info[] = {
-	{
-	.code   = V4L2_MBUS_FMT_SBGGR10_1X10,
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	.fmt    = 1,
-	.order    = 0,
-	},
-	/* more can be supported, to be added later */
-};
-
-static struct msm_camera_i2c_conf_array ov9726_init_conf[] = {
-	{&ov9726_recommend_settings[0],
-	ARRAY_SIZE(ov9726_recommend_settings), 0, MSM_CAMERA_I2C_BYTE_DATA}
-};
-
-static struct msm_camera_i2c_conf_array ov9726_confs[] = {
-	{&ov9726_prev_settings[0],
-	ARRAY_SIZE(ov9726_prev_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-};
-
-static struct msm_sensor_output_info_t ov9726_dimensions[] = {
-	{
-		.x_output = 0x510, /* 1296 */
-		.y_output = 0x328, /* 808 */
-		.line_length_pclk = 0x680, /* 1664 */
-		.frame_length_lines = 0x3C1, /* 961 */
-		.vt_pixel_clk = 320000000,
-		.op_pixel_clk = 320000000,
-		.binning_factor = 1,
-	},
-};
-
-static struct msm_sensor_output_reg_addr_t ov9726_reg_addr = {
-	.x_output = 0x034c,
-	.y_output = 0x034e,
-	.line_length_pclk = 0x0342,
-	.frame_length_lines = 0x0340,
-};
-
-static struct msm_sensor_id_info_t ov9726_id_info = {
-	.sensor_id_reg_addr = 0x0000,
-	.sensor_id = 0x9726,
-};
-
-static struct msm_sensor_exp_gain_info_t ov9726_exp_gain_info = {
-	.coarse_int_time_addr = 0x0202,
-	.global_gain_addr = 0x0204,
-	.vert_offset = 6,
-};
-
-static const struct i2c_device_id ov9726_i2c_id[] = {
-	{SENSOR_NAME, (kernel_ulong_t)&ov9726_s_ctrl},
-	{ }
-};
-
-static struct i2c_driver ov9726_i2c_driver = {
-	.id_table = ov9726_i2c_id,
-	.probe  = msm_sensor_i2c_probe,
-	.driver = {
-		.name = SENSOR_NAME,
-	},
-};
-
-static struct msm_camera_i2c_client ov9726_sensor_i2c_client = {
-	.addr_type = MSM_CAMERA_I2C_WORD_ADDR,
-};
-
-static int __init msm_sensor_init_module(void)
-{
-	return i2c_add_driver(&ov9726_i2c_driver);
-}
-
-static struct v4l2_subdev_core_ops ov9726_subdev_core_ops = {
-	.ioctl = msm_sensor_subdev_ioctl,
-	.s_power = msm_sensor_power,
-};
-
-static struct v4l2_subdev_video_ops ov9726_subdev_video_ops = {
-	.enum_mbus_fmt = msm_sensor_v4l2_enum_fmt,
-};
-
-static struct v4l2_subdev_ops ov9726_subdev_ops = {
-	.core = &ov9726_subdev_core_ops,
-	.video  = &ov9726_subdev_video_ops,
-};
-
-static struct msm_sensor_fn_t ov9726_func_tbl = {
-	.sensor_start_stream = msm_sensor_start_stream,
-	.sensor_stop_stream = msm_sensor_stop_stream,
-	.sensor_group_hold_on = msm_sensor_group_hold_on,
-	.sensor_group_hold_off = msm_sensor_group_hold_off,
-	.sensor_set_fps = msm_sensor_set_fps,
-	.sensor_write_exp_gain = msm_sensor_write_exp_gain1,
-	.sensor_write_snapshot_exp_gain = msm_sensor_write_exp_gain1,
-	.sensor_csi_setting = msm_sensor_setting1,
-	.sensor_set_sensor_mode = msm_sensor_set_sensor_mode,
-	.sensor_mode_init = msm_sensor_mode_init,
-	.sensor_get_output_info = msm_sensor_get_output_info,
-	.sensor_config = msm_sensor_config,
-	.sensor_power_up = msm_sensor_power_up,
-	.sensor_power_down = msm_sensor_power_down,
-};
-
-static struct msm_sensor_reg_t ov9726_regs = {
-	.default_data_type = MSM_CAMERA_I2C_BYTE_DATA,
-	.start_stream_conf = ov9726_start_settings,
-	.start_stream_conf_size = ARRAY_SIZE(ov9726_start_settings),
-	.stop_stream_conf = ov9726_stop_settings,
-	.stop_stream_conf_size = ARRAY_SIZE(ov9726_stop_settings),
-	.group_hold_on_conf = ov9726_groupon_settings,
-	.group_hold_on_conf_size = ARRAY_SIZE(ov9726_groupon_settings),
-	.group_hold_off_conf = ov9726_groupoff_settings,
-	.group_hold_off_conf_size =
-		ARRAY_SIZE(ov9726_groupoff_settings),
-	.init_settings = &ov9726_init_conf[0],
-	.init_size = ARRAY_SIZE(ov9726_init_conf),
-	.mode_settings = &ov9726_confs[0],
-	.output_settings = &ov9726_dimensions[0],
-	.num_conf = ARRAY_SIZE(ov9726_confs),
-};
-
-static struct msm_sensor_ctrl_t ov9726_s_ctrl = {
-	.msm_sensor_reg = &ov9726_regs,
-	.sensor_i2c_client = &ov9726_sensor_i2c_client,
-	.sensor_i2c_addr = 0x20,
-	.sensor_output_reg_addr = &ov9726_reg_addr,
-	.sensor_id_info = &ov9726_id_info,
-	.sensor_exp_gain_info = &ov9726_exp_gain_info,
-	.cam_mode = MSM_SENSOR_MODE_INVALID,
-	.msm_sensor_mutex = &ov9726_mut,
-	.sensor_i2c_driver = &ov9726_i2c_driver,
-	.sensor_v4l2_subdev_info = ov9726_subdev_info,
-	.sensor_v4l2_subdev_info_size = ARRAY_SIZE(ov9726_subdev_info),
-	.sensor_v4l2_subdev_ops = &ov9726_subdev_ops,
-	.func_tbl = &ov9726_func_tbl,
-	.clk_rate = MSM_SENSOR_MCLK_24HZ,
-};
-
-module_init(msm_sensor_init_module);
-MODULE_DESCRIPTION("Omnivision WXGA Bayer sensor driver");
-MODULE_LICENSE("GPL v2");
-
-
diff --git a/drivers/media/platform/msm/camera_v1/sensors/s5k3l1yx.c b/drivers/media/platform/msm/camera_v1/sensors/s5k3l1yx.c
deleted file mode 100644
index 0bd625c..0000000
--- a/drivers/media/platform/msm/camera_v1/sensors/s5k3l1yx.c
+++ /dev/null
@@ -1,747 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- *
- */
-
-#include "msm_sensor.h"
-#define SENSOR_NAME "s5k3l1yx"
-#define PLATFORM_DRIVER_NAME "msm_camera_s5k3l1yx"
-
-DEFINE_MUTEX(s5k3l1yx_mut);
-static struct msm_sensor_ctrl_t s5k3l1yx_s_ctrl;
-
-static struct msm_camera_i2c_reg_conf s5k3l1yx_start_settings[] = {
-	{0x0100, 0x01},
-};
-
-static struct msm_camera_i2c_reg_conf s5k3l1yx_stop_settings[] = {
-	{0x0100, 0x00},
-};
-
-static struct msm_camera_i2c_reg_conf s5k3l1yx_groupon_settings[] = {
-	{0x104, 0x01},
-};
-
-static struct msm_camera_i2c_reg_conf s5k3l1yx_groupoff_settings[] = {
-	{0x104, 0x00},
-};
-
-static struct msm_camera_i2c_reg_conf s5k3l1yx_snap_settings[] = {
-	{0x0501, 0x00}, /* compression_algorithim_L(1d) */
-	{0x0112, 0x0A}, /* CCP_data_format_H */
-	{0x0113, 0x0A}, /* CCP_data_format_L raw8=0808 ,DCPM10 -->8= 0A08 */
-	{0x0306, 0x00}, /* pll_multiplier */
-	{0x0307, 0xA5}, /* pll_multiplier */
-	{0x0202, 0x09}, /* coarse_integration_time */
-	{0x0203, 0x32}, /* coarse_integration_time */
-	{0x0340, 0x0B}, /* frame_length_lines */
-	{0x0341, 0xEC}, /* frame_length_lines */
-	{0x0342, 0x14}, /* line_length_pck */
-	{0x0343, 0xD8}, /* line_length_pck */
-	{0x0344, 0x00}, /* x_addr_start */
-	{0x0345, 0x08}, /* x_addr_start */
-	{0x0346, 0x00}, /* y_addr_start */
-	{0x0347, 0x00}, /* y_addr_start */
-	{0x0348, 0x0F}, /* x_addr_end */
-	{0x0349, 0xA7}, /* x_addr_end */
-	{0x034A, 0x0B}, /* y_addr_end */
-	{0x034B, 0xC7}, /* y_addr_end */
-	{0x034C, 0x0F}, /* x_output_size */
-	{0x034D, 0xA0}, /* x_output_size */
-	{0x034E, 0x0B}, /* y_output_size */
-	{0x034F, 0xC8}, /* y_output_size */
-	{0x0380, 0x00}, /* x_even_inc */
-	{0x0381, 0x01}, /* x_even_inc */
-	{0x0382, 0x00}, /* x_odd_inc */
-	{0x0383, 0x01}, /* x_odd_inc */
-	{0x0384, 0x00}, /* y_even_inc */
-	{0x0385, 0x01}, /* y_even_inc */
-	{0x0386, 0x00}, /* y_odd_inc */
-	{0x0387, 0x01}, /* y_odd_inc */
-	{0x0900, 0x00}, /* binning_mode */
-	{0x0901, 0x22}, /* binning_type */
-	{0x0902, 0x01}, /* binning_weighting */
-};
-
-static struct msm_camera_i2c_reg_conf s5k3l1yx_prev_settings[] = {
-	{0x0501, 0x00}, /* compression_algorithim_L(1d) */
-	{0x0112, 0x0A}, /* CCP_data_format_H */
-	{0x0113, 0x0A}, /* CCP_data_format_L raw8=0808 ,DCPM10 -->8= 0A08 */
-	{0x0306, 0x00}, /* pll_multiplier */
-	{0x0307, 0xA5}, /* pll_multiplier */
-	{0x0202, 0x06}, /* coarse_integration_time */
-	{0x0203, 0x00}, /* coarse_integration_time */
-	{0x0340, 0x09}, /* frame_length_lines */
-	{0x0341, 0x6C}, /* frame_length_lines */
-	{0x0342, 0x11}, /* line_length_pck */
-	{0x0343, 0x80}, /* line_length_pck */
-	{0x0344, 0x00}, /* x_addr_start */
-	{0x0345, 0x18}, /* x_addr_start */
-	{0x0346, 0x00}, /* y_addr_start */
-	{0x0347, 0x00}, /* y_addr_start */
-	{0x0348, 0x0F}, /* x_addr_end */
-	{0x0349, 0x97}, /* x_addr_end */
-	{0x034A, 0x0B}, /* y_addr_end */
-	{0x034B, 0xC7}, /* y_addr_end */
-	{0x034C, 0x07}, /* x_output_size */
-	{0x034D, 0xC0}, /* x_output_size */
-	{0x034E, 0x05}, /* y_output_size */
-	{0x034F, 0xE4}, /* y_output_size */
-	{0x0380, 0x00}, /* x_even_inc */
-	{0x0381, 0x01}, /* x_even_inc */
-	{0x0382, 0x00}, /* x_odd_inc */
-	{0x0383, 0x03}, /* x_odd_inc */
-	{0x0384, 0x00}, /* y_even_inc */
-	{0x0385, 0x01}, /* y_even_inc */
-	{0x0386, 0x00}, /* y_odd_inc */
-	{0x0387, 0x03}, /* y_odd_inc */
-	{0x0900, 0x01}, /* binning_mode */
-	{0x0901, 0x22}, /* binning_type */
-	{0x0902, 0x01}, /* binning_weighting */
-};
-
-static struct msm_camera_i2c_reg_conf s5k3l1yx_video_60fps_settings[] = {
-	{0x0501, 0x00}, /* compression_algorithim_L(1d) */
-	{0x0112, 0x0A}, /* CCP_data_format_H */
-	{0x0113, 0x0A}, /* CCP_data_format_L raw8=0808 ,DCPM10 -->8= 0A08 */
-	{0x0306, 0x00}, /* pll_multiplier */
-	{0x0307, 0xA5}, /* pll_multiplier */
-	{0x0202, 0x03}, /* coarse_integration_time */
-	{0x0203, 0xD8}, /* coarse_integration_time */
-	{0x0340, 0x03}, /* frame_length_lines */
-	{0x0341, 0xE0}, /* frame_length_lines */
-	{0x0342, 0x14}, /* line_length_pck */
-	{0x0343, 0xD8}, /* line_length_pck */
-	{0x0344, 0x01}, /* x_addr_start */
-	{0x0345, 0x20}, /* x_addr_start */
-	{0x0346, 0x02}, /* y_addr_start */
-	{0x0347, 0x24}, /* y_addr_start */
-	{0x0348, 0x0E}, /* x_addr_end */
-	{0x0349, 0xA0}, /* x_addr_end */
-	{0x034A, 0x09}, /* y_addr_end */
-	{0x034B, 0xA4}, /* y_addr_end */
-	{0x034C, 0x03}, /* x_output_size */
-	{0x034D, 0x60}, /* x_output_size */
-	{0x034E, 0x01}, /* y_output_size */
-	{0x034F, 0xE0}, /* y_output_size */
-	{0x0380, 0x00}, /* x_even_inc */
-	{0x0381, 0x01}, /* x_even_inc */
-	{0x0382, 0x00}, /* x_odd_inc */
-	{0x0383, 0x07}, /* x_odd_inc */
-	{0x0384, 0x00}, /* y_even_inc */
-	{0x0385, 0x01}, /* y_even_inc */
-	{0x0386, 0x00}, /* y_odd_inc */
-	{0x0387, 0x07}, /* y_odd_inc */
-	{0x0900, 0x01}, /* binning_mode */
-	{0x0901, 0x44}, /* binning_type */
-	{0x0902, 0x01}, /* binning_weighting */
-};
-
-static struct msm_camera_i2c_reg_conf s5k3l1yx_video_90fps_settings[] = {
-	{0x0501, 0x00}, /* compression_algorithim_L(1d) */
-	{0x0112, 0x0A}, /* CCP_data_format_H */
-	{0x0113, 0x0A}, /* CCP_data_format_L raw8=0808 ,DCPM10 -->8= 0A08 */
-	{0x0306, 0x00}, /* pll_multiplier */
-	{0x0307, 0xA5}, /* pll_multiplier */
-	{0x0202, 0x02}, /* coarse_integration_time */
-	{0x0203, 0x90}, /* coarse_integration_time */
-	{0x0340, 0x02}, /* frame_length_lines */
-	{0x0341, 0x98}, /* frame_length_lines */
-	{0x0342, 0x14}, /* line_length_pck */
-	{0x0343, 0xD8}, /* line_length_pck */
-	{0x0344, 0x01}, /* x_addr_start */
-	{0x0345, 0x20}, /* x_addr_start */
-	{0x0346, 0x02}, /* y_addr_start */
-	{0x0347, 0x24}, /* y_addr_start */
-	{0x0348, 0x0E}, /* x_addr_end */
-	{0x0349, 0xA0}, /* x_addr_end */
-	{0x034A, 0x09}, /* y_addr_end */
-	{0x034B, 0xA4}, /* y_addr_end */
-	{0x034C, 0x03}, /* x_output_size */
-	{0x034D, 0x60}, /* x_output_size */
-	{0x034E, 0x01}, /* y_output_size */
-	{0x034F, 0xE0}, /* y_output_size */
-	{0x0380, 0x00}, /* x_even_inc */
-	{0x0381, 0x01}, /* x_even_inc */
-	{0x0382, 0x00}, /* x_odd_inc */
-	{0x0383, 0x07}, /* x_odd_inc */
-	{0x0384, 0x00}, /* y_even_inc */
-	{0x0385, 0x01}, /* y_even_inc */
-	{0x0386, 0x00}, /* y_odd_inc */
-	{0x0387, 0x07}, /* y_odd_inc */
-	{0x0900, 0x01}, /* binning_mode */
-	{0x0901, 0x44}, /* binning_type */
-	{0x0902, 0x01}, /* binning_weighting */
-};
-
-static struct msm_camera_i2c_reg_conf s5k3l1yx_video_120fps_settings[] = {
-	{0x0501, 0x00}, /* compression_algorithim_L(1d) */
-	{0x0112, 0x0A}, /* CCP_data_format_H */
-	{0x0113, 0x0A}, /* CCP_data_format_L raw8=0808 ,DCPM10 -->8= 0A08 */
-	{0x0306, 0x00}, /* pll_multiplier */
-	{0x0307, 0xA5}, /* pll_multiplier */
-	{0x0202, 0x01}, /* coarse_integration_time */
-	{0x0203, 0xFA}, /* coarse_integration_time */
-	{0x0340, 0x02}, /* frame_length_lines */
-	{0x0341, 0x02}, /* frame_length_lines */
-	{0x0342, 0x14}, /* line_length_pck */
-	{0x0343, 0xD8}, /* line_length_pck */
-	{0x0344, 0x01}, /* x_addr_start */
-	{0x0345, 0x20}, /* x_addr_start */
-	{0x0346, 0x02}, /* y_addr_start */
-	{0x0347, 0x24}, /* y_addr_start */
-	{0x0348, 0x0E}, /* x_addr_end */
-	{0x0349, 0xA0}, /* x_addr_end */
-	{0x034A, 0x09}, /* y_addr_end */
-	{0x034B, 0xA4}, /* y_addr_end */
-	{0x034C, 0x03}, /* x_output_size */
-	{0x034D, 0x60}, /* x_output_size */
-	{0x034E, 0x01}, /* y_output_size */
-	{0x034F, 0xE0}, /* y_output_size */
-	{0x0380, 0x00}, /* x_even_inc */
-	{0x0381, 0x01}, /* x_even_inc */
-	{0x0382, 0x00}, /* x_odd_inc */
-	{0x0383, 0x07}, /* x_odd_inc */
-	{0x0384, 0x00}, /* y_even_inc */
-	{0x0385, 0x01}, /* y_even_inc */
-	{0x0386, 0x00}, /* y_odd_inc */
-	{0x0387, 0x07}, /* y_odd_inc */
-	{0x0900, 0x01}, /* binning_mode */
-	{0x0901, 0x44}, /* binning_type */
-	{0x0902, 0x01}, /* binning_weighting */
-};
-
-static struct msm_camera_i2c_reg_conf s5k3l1yx_dpcm_settings[] = {
-	{0x0501, 0x01}, /* compression_algorithim_L(1d) */
-	{0x0112, 0x0A}, /* CCP_data_format_H */
-	{0x0113, 0x08}, /* CCP_data_format_L raw8=0808 ,DCPM10 -->8= 0A08 */
-	{0x0306, 0x00}, /* pll_multiplier */
-	{0x0307, 0xA0}, /* pll_multiplier */
-	{0x0202, 0x09}, /* coarse_integration_time */
-	{0x0203, 0x32}, /* coarse_integration_time */
-	{0x0340, 0x0B}, /* frame_length_lines */
-	{0x0341, 0xEC}, /* frame_length_lines */
-	{0x0342, 0x11}, /* line_length_pck */
-	{0x0343, 0x80}, /* line_length_pck */
-	{0x0344, 0x00}, /* x_addr_start */
-	{0x0345, 0x08}, /* x_addr_start */
-	{0x0346, 0x00}, /* y_addr_start */
-	{0x0347, 0x00}, /* y_addr_start */
-	{0x0348, 0x0F}, /* x_addr_end */
-	{0x0349, 0xA7}, /* x_addr_end */
-	{0x034A, 0x0B}, /* y_addr_end */
-	{0x034B, 0xC7}, /* y_addr_end */
-	{0x034C, 0x0F}, /* x_output_size */
-	{0x034D, 0xA0}, /* x_output_size */
-	{0x034E, 0x0B}, /* y_output_size */
-	{0x034F, 0xC8}, /* y_output_size */
-	{0x0380, 0x00}, /* x_even_inc */
-	{0x0381, 0x01}, /* x_even_inc */
-	{0x0382, 0x00}, /* x_odd_inc */
-	{0x0383, 0x01}, /* x_odd_inc */
-	{0x0384, 0x00}, /* y_even_inc */
-	{0x0385, 0x01}, /* y_even_inc */
-	{0x0386, 0x00}, /* y_odd_inc */
-	{0x0387, 0x01}, /* y_odd_inc */
-	{0x0900, 0x00}, /* binning_mode */
-	{0x0901, 0x22}, /* binning_type */
-	{0x0902, 0x01}, /* binning_weighting */
-};
-
-static struct msm_camera_i2c_reg_conf s5k3l1yx_recommend_settings[] = {
-	{0x0100, 0x00},
-	{0x0103, 0x01}, /* software_reset */
-	{0x0104, 0x00}, /* grouped_parameter_hold */
-	{0x0114, 0x03}, /* CSI_lane_mode, 4 lane setting */
-	{0x0120, 0x00}, /* gain_mode, global analogue gain*/
-	{0x0121, 0x00}, /* exposure_mode, global exposure */
-	{0x0136, 0x18}, /* Extclk_frequency_mhz */
-	{0x0137, 0x00}, /* Extclk_frequency_mhz */
-	{0x0200, 0x08}, /* fine_integration_time */
-	{0x0201, 0x88}, /* fine_integration_time */
-	{0x0204, 0x00}, /* analogue_gain_code_global */
-	{0x0205, 0x20}, /* analogue_gain_code_global */
-	{0x020E, 0x01}, /* digital_gain_greenR */
-	{0x020F, 0x00}, /* digital_gain_greenR */
-	{0x0210, 0x01}, /* digital_gain_red */
-	{0x0211, 0x00}, /* digital_gain_red */
-	{0x0212, 0x01}, /* digital_gain_blue */
-	{0x0213, 0x00}, /* digital_gain_blue */
-	{0x0214, 0x01}, /* digital_gain_greenB */
-	{0x0215, 0x00}, /* digital_gain_greenB */
-	{0x0300, 0x00}, /* vt_pix_clk_div */
-	{0x0301, 0x02}, /* vt_pix_clk_div */
-	{0x0302, 0x00}, /* vt_sys_clk_div */
-	{0x0303, 0x01}, /* vt_sys_clk_div */
-	{0x0304, 0x00}, /* pre_pll_clk_div */
-	{0x0305, 0x06}, /* pre_pll_clk_div */
-	{0x0308, 0x00}, /* op_pix_clk_div */
-	{0x0309, 0x02}, /* op_pix_clk_div */
-	{0x030A, 0x00}, /* op_sys_clk_div */
-	{0x030B, 0x01}, /* op_sys_clk_div */
-	{0x0800, 0x00}, /* tclk_post for D-PHY control */
-	{0x0801, 0x00}, /* ths_prepare for D-PHY control */
-	{0x0802, 0x00}, /* ths_zero_min for D-PHY control */
-	{0x0803, 0x00}, /* ths_trail for D-PHY control */
-	{0x0804, 0x00}, /* tclk_trail_min for D-PHY control */
-	{0x0805, 0x00}, /* tclk_prepare for D-PHY control */
-	{0x0806, 0x00}, /* tclk_zero_zero for D-PHY control */
-	{0x0807, 0x00}, /* tlpx for D-PHY control */
-	{0x0820, 0x02}, /* requested_link_bit_rate_mbps */
-	{0x0821, 0x94}, /* requested_link_bit_rate_mbps */
-	{0x0822, 0x00}, /* requested_link_bit_rate_mbps */
-	{0x0823, 0x00}, /* requested_link_bit_rate_mbps */
-	{0x3000, 0x0A},
-	{0x3001, 0xF7},
-	{0x3002, 0x0A},
-	{0x3003, 0xF7},
-	{0x3004, 0x08},
-	{0x3005, 0xF8},
-	{0x3006, 0x5B},
-	{0x3007, 0x73},
-	{0x3008, 0x49},
-	{0x3009, 0x0C},
-	{0x300A, 0xF8},
-	{0x300B, 0x4E},
-	{0x300C, 0x64},
-	{0x300D, 0x5C},
-	{0x300E, 0x71},
-	{0x300F, 0x0C},
-	{0x3010, 0x6A},
-	{0x3011, 0x14},
-	{0x3012, 0x14},
-	{0x3013, 0x0C},
-	{0x3014, 0x24},
-	{0x3015, 0x4F},
-	{0x3016, 0x86},
-	{0x3017, 0x0E},
-	{0x3018, 0x2C},
-	{0x3019, 0x30},
-	{0x301A, 0x31},
-	{0x301B, 0x32},
-	{0x301C, 0xFF},
-	{0x301D, 0x33},
-	{0x301E, 0x5C},
-	{0x301F, 0xFA},
-	{0x3020, 0x36},
-	{0x3021, 0x46},
-	{0x3022, 0x92},
-	{0x3023, 0xF5},
-	{0x3024, 0x6E},
-	{0x3025, 0x19},
-	{0x3026, 0x32},
-	{0x3027, 0x4B},
-	{0x3028, 0x04},
-	{0x3029, 0x50},
-	{0x302A, 0x0C},
-	{0x302B, 0x04},
-	{0x302C, 0xEF},
-	{0x302D, 0xC1},
-	{0x302E, 0x74},
-	{0x302F, 0x40},
-	{0x3030, 0x00},
-	{0x3031, 0x00},
-	{0x3032, 0x00},
-	{0x3033, 0x00},
-	{0x3034, 0x0F},
-	{0x3035, 0x01},
-	{0x3036, 0x00},
-	{0x3037, 0x00},
-	{0x3038, 0x88},
-	{0x3039, 0x98},
-	{0x303A, 0x1F},
-	{0x303B, 0x01},
-	{0x303C, 0x00},
-	{0x303D, 0x03},
-	{0x303E, 0x2F},
-	{0x303F, 0x09},
-	{0x3040, 0xFF},
-	{0x3041, 0x22},
-	{0x3042, 0x03},
-	{0x3043, 0x03},
-	{0x3044, 0x20},
-	{0x3045, 0x10},
-	{0x3046, 0x10},
-	{0x3047, 0x08},
-	{0x3048, 0x10},
-	{0x3049, 0x01},
-	{0x304A, 0x00},
-	{0x304B, 0x80},
-	{0x304C, 0x80},
-	{0x304D, 0x00},
-	{0x304E, 0x00},
-	{0x304F, 0x00},
-	{0x3051, 0x09},
-	{0x3052, 0xC4},
-	{0x305A, 0xE0},
-	{0x323D, 0x04},
-	{0x323E, 0x38},
-	{0x3305, 0xDD},
-	{0x3050, 0x01},
-	{0x3202, 0x01},
-	{0x3203, 0x01},
-	{0x3204, 0x01},
-	{0x3205, 0x01},
-	{0x3206, 0x01},
-	{0x3207, 0x01},
-	{0x320A, 0x05},
-	{0x320B, 0x20},
-	{0x3235, 0xB7},
-	{0x324C, 0x04},
-	{0x324A, 0x07},
-	{0x3902, 0x01},
-	{0x3915, 0x70},
-	{0x3916, 0x80},
-	{0x3A00, 0x01},
-	{0x3A06, 0x03},
-	{0x3B29, 0x01},
-	{0x3C11, 0x08},
-	{0x3C12, 0x7B},
-	{0x3C13, 0xC0},
-	{0x3C14, 0x70},
-	{0x3C15, 0x80},
-	{0x3C20, 0x04},
-	{0x3C23, 0x03},
-	{0x3C24, 0x00},
-	{0x3C50, 0x72},
-	{0x3C51, 0x85},
-	{0x3C53, 0x40},
-	{0x3C55, 0xA0},
-	{0x3D00, 0x00},
-	{0x3D01, 0x00},
-	{0x3D11, 0x01},
-	{0x3486, 0x05},
-	{0x3B35, 0x06},
-	{0x3A05, 0x01},
-	{0x3A07, 0x2B},
-	{0x3A09, 0x01},
-	{0x3940, 0xFF},
-	{0x3300, 0x00},
-	{0x3900, 0xFF},
-	{0x3914, 0x08},
-	{0x3A01, 0x0F},
-	{0x3A02, 0xA0},
-	{0x3A03, 0x0B},
-	{0x3A04, 0xC8},
-	{0x3701, 0x00},
-	{0x3702, 0x00},
-	{0x3703, 0x00},
-	{0x3704, 0x00},
-	{0x0101, 0x00}, /* image_orientation, mirror & flip off*/
-	{0x0105, 0x01}, /* mask_corrupted_frames */
-	{0x0110, 0x00}, /* CSI-2_channel_identifier */
-	{0x3942, 0x01}, /* [0] 1:mipi, 0:pvi */
-	{0x0B00, 0x00},
-};
-
-static struct msm_camera_i2c_reg_conf s5k3l1yx_19mhz_prev_settings[] = {
-	{0x0501, 0x00}, /* compression_algorithim_L(1d) */
-	{0x0112, 0x0A}, /* CCP_data_format_H */
-	{0x0113, 0x0A}, /* CCP_data_format_L raw8=0808 ,DCPM10 -->8= 0A08 */
-	{0x0306, 0x00}, /* pll_multiplier */
-	{0x0307, 0xCE}, /* pll_multiplier */
-	{0x0202, 0x06}, /* coarse_integration_time */
-	{0x0203, 0x00}, /* coarse_integration_time */
-	{0x0340, 0x09}, /* frame_length_lines */
-	{0x0341, 0x6C}, /* frame_length_lines */
-	{0x0342, 0x11}, /* line_length_pck */
-	{0x0343, 0x80}, /* line_length_pck */
-	{0x0344, 0x00}, /* x_addr_start */
-	{0x0345, 0x18}, /* x_addr_start */
-	{0x0346, 0x00}, /* y_addr_start */
-	{0x0347, 0x00}, /* y_addr_start */
-	{0x0348, 0x0F}, /* x_addr_end */
-	{0x0349, 0x97}, /* x_addr_end */
-	{0x034A, 0x0B}, /* y_addr_end */
-	{0x034B, 0xC7}, /* y_addr_end */
-	{0x034C, 0x07}, /* x_output_size */
-	{0x034D, 0xC0}, /* x_output_size */
-	{0x034E, 0x05}, /* y_output_size */
-	{0x034F, 0xE4}, /* y_output_size */
-	{0x0380, 0x00}, /* x_even_inc */
-	{0x0381, 0x01}, /* x_even_inc */
-	{0x0382, 0x00}, /* x_odd_inc */
-	{0x0383, 0x03}, /* x_odd_inc */
-	{0x0384, 0x00}, /* y_even_inc */
-	{0x0385, 0x01}, /* y_even_inc */
-	{0x0386, 0x00}, /* y_odd_inc */
-	{0x0387, 0x03}, /* y_odd_inc */
-	{0x0900, 0x01}, /* binning_mode */
-	{0x0901, 0x22}, /* binning_type */
-	{0x0902, 0x01}, /* binning_weighting */
-};
-
-static struct v4l2_subdev_info s5k3l1yx_subdev_info[] = {
-	{
-	.code   = V4L2_MBUS_FMT_SBGGR10_1X10,
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	.fmt    = 1,
-	.order    = 0,
-	},
-	/* more can be supported, to be added later */
-};
-
-static struct msm_camera_i2c_conf_array s5k3l1yx_init_conf[] = {
-	{&s5k3l1yx_recommend_settings[0],
-	ARRAY_SIZE(s5k3l1yx_recommend_settings), 0, MSM_CAMERA_I2C_BYTE_DATA}
-};
-
-static struct msm_camera_i2c_conf_array s5k3l1yx_confs[] = {
-	{&s5k3l1yx_snap_settings[0],
-	ARRAY_SIZE(s5k3l1yx_snap_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-	{&s5k3l1yx_prev_settings[0],
-	ARRAY_SIZE(s5k3l1yx_prev_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-	{&s5k3l1yx_video_60fps_settings[0],
-	ARRAY_SIZE(s5k3l1yx_video_60fps_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-	{&s5k3l1yx_video_90fps_settings[0],
-	ARRAY_SIZE(s5k3l1yx_video_90fps_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-	{&s5k3l1yx_video_120fps_settings[0],
-	ARRAY_SIZE(s5k3l1yx_video_120fps_settings), 0,
-					MSM_CAMERA_I2C_BYTE_DATA},
-	{&s5k3l1yx_dpcm_settings[0],
-	ARRAY_SIZE(s5k3l1yx_dpcm_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-	{&s5k3l1yx_19mhz_prev_settings[0],
-	ARRAY_SIZE(s5k3l1yx_19mhz_prev_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-};
-
-static struct msm_sensor_output_info_t s5k3l1yx_dimensions[] = {
-	/* 20 fps snapshot */
-	{
-		.x_output = 4000,
-		.y_output = 3016,
-		.line_length_pclk = 5336,
-		.frame_length_lines = 3052,
-		.vt_pixel_clk = 330000000,
-		.op_pixel_clk = 264000000,
-		.binning_factor = 1,
-	},
-	/* 30 fps preview */
-	{
-		.x_output = 1984,
-		.y_output = 1508,
-		.line_length_pclk = 4480,
-		.frame_length_lines = 2412,
-		.vt_pixel_clk = 330000000,
-		.op_pixel_clk = 264000000,
-		.binning_factor = 1,
-	},
-	/* 60 fps video */
-	{
-		.x_output = 864,
-		.y_output = 480,
-		.line_length_pclk = 5336,
-		.frame_length_lines = 992,
-		.vt_pixel_clk = 330000000,
-		.op_pixel_clk = 264000000,
-		.binning_factor = 1,
-	},
-	/* 90 fps video */
-	{
-		.x_output = 864,
-		.y_output = 480,
-		.line_length_pclk = 5336,
-		.frame_length_lines = 664,
-		.vt_pixel_clk = 330000000,
-		.op_pixel_clk = 264000000,
-		.binning_factor = 1,
-	},
-	/* 120 fps video */
-	{
-		.x_output = 864,
-		.y_output = 480,
-		.line_length_pclk = 5336,
-		.frame_length_lines = 514,
-		.vt_pixel_clk = 330000000,
-		.op_pixel_clk = 264000000,
-		.binning_factor = 1,
-	},
-	/* 24 fps snapshot */
-	{
-		.x_output = 4000,
-		.y_output = 3016,
-		.line_length_pclk = 4480,
-		.frame_length_lines = 3052,
-		.vt_pixel_clk = 330000000,
-		.op_pixel_clk = 320000000,
-		.binning_factor = 1,
-	},
-	/* 30 fps preview with 19.2 input clock*/
-	{
-		.x_output = 1984,
-		.y_output = 1508,
-		.line_length_pclk = 4480,
-		.frame_length_lines = 2412,
-		.vt_pixel_clk = 330000000,
-		.op_pixel_clk = 264000000,
-		.binning_factor = 1,
-	},
-};
-
-static struct msm_sensor_output_reg_addr_t s5k3l1yx_reg_addr = {
-	.x_output = 0x34C,
-	.y_output = 0x34E,
-	.line_length_pclk = 0x342,
-	.frame_length_lines = 0x340,
-};
-
-static enum msm_camera_vreg_name_t s5k3l1yx_veg_seq[] = {
-	CAM_VDIG,
-	CAM_VANA,
-	CAM_VIO,
-	CAM_VAF,
-};
-
-static struct msm_sensor_id_info_t s5k3l1yx_id_info = {
-	.sensor_id_reg_addr = 0x0,
-	.sensor_id = 0x3121,
-};
-
-static struct msm_sensor_exp_gain_info_t s5k3l1yx_exp_gain_info = {
-	.coarse_int_time_addr = 0x202,
-	.global_gain_addr = 0x204,
-	.vert_offset = 8,
-};
-
-static const struct i2c_device_id s5k3l1yx_i2c_id[] = {
-	{SENSOR_NAME, (kernel_ulong_t)&s5k3l1yx_s_ctrl},
-	{ }
-};
-
-static struct i2c_driver s5k3l1yx_i2c_driver = {
-	.id_table = s5k3l1yx_i2c_id,
-	.probe  = msm_sensor_i2c_probe,
-	.driver = {
-		.name = SENSOR_NAME,
-	},
-};
-
-static struct msm_camera_i2c_client s5k3l1yx_sensor_i2c_client = {
-	.addr_type = MSM_CAMERA_I2C_WORD_ADDR,
-};
-
-static const struct of_device_id s5k3l1yx_dt_match[] = {
-	{.compatible = "qcom,s5k3l1yx", .data = &s5k3l1yx_s_ctrl},
-	{}
-};
-
-MODULE_DEVICE_TABLE(of, s5k3l1yx_dt_match);
-
-static struct platform_driver s5k3l1yx_platform_driver = {
-	.driver = {
-		.name = "qcom,s5k3l1yx",
-		.owner = THIS_MODULE,
-		.of_match_table = s5k3l1yx_dt_match,
-	},
-};
-
-static int32_t s5k3l1yx_platform_probe(struct platform_device *pdev)
-{
-	int32_t rc = 0;
-	const struct of_device_id *match;
-	match = of_match_device(s5k3l1yx_dt_match, &pdev->dev);
-	rc = msm_sensor_platform_probe(pdev, match->data);
-	return rc;
-}
-
-static int __init msm_sensor_init_module(void)
-{
-	int32_t rc = 0;
-	rc = platform_driver_probe(&s5k3l1yx_platform_driver,
-		s5k3l1yx_platform_probe);
-	if (!rc)
-		return rc;
-	return i2c_add_driver(&s5k3l1yx_i2c_driver);
-}
-
-static void __exit msm_sensor_exit_module(void)
-{
-	if (s5k3l1yx_s_ctrl.pdev) {
-		msm_sensor_free_sensor_data(&s5k3l1yx_s_ctrl);
-		platform_driver_unregister(&s5k3l1yx_platform_driver);
-	} else
-		i2c_del_driver(&s5k3l1yx_i2c_driver);
-	return;
-}
-
-static struct v4l2_subdev_core_ops s5k3l1yx_subdev_core_ops = {
-	.ioctl = msm_sensor_subdev_ioctl,
-	.s_power = msm_sensor_power,
-};
-
-static struct v4l2_subdev_video_ops s5k3l1yx_subdev_video_ops = {
-	.enum_mbus_fmt = msm_sensor_v4l2_enum_fmt,
-};
-
-static struct v4l2_subdev_ops s5k3l1yx_subdev_ops = {
-	.core = &s5k3l1yx_subdev_core_ops,
-	.video  = &s5k3l1yx_subdev_video_ops,
-};
-
-static struct msm_sensor_fn_t s5k3l1yx_func_tbl = {
-	.sensor_start_stream = msm_sensor_start_stream,
-	.sensor_stop_stream = msm_sensor_stop_stream,
-	.sensor_group_hold_on = msm_sensor_group_hold_on,
-	.sensor_group_hold_off = msm_sensor_group_hold_off,
-	.sensor_set_fps = msm_sensor_set_fps,
-	.sensor_write_exp_gain = msm_sensor_write_exp_gain1,
-	.sensor_write_snapshot_exp_gain = msm_sensor_write_exp_gain1,
-	.sensor_setting = msm_sensor_setting,
-	.sensor_set_sensor_mode = msm_sensor_set_sensor_mode,
-	.sensor_mode_init = msm_sensor_mode_init,
-	.sensor_get_output_info = msm_sensor_get_output_info,
-	.sensor_config = msm_sensor_config,
-	.sensor_power_up = msm_sensor_power_up,
-	.sensor_power_down = msm_sensor_power_down,
-	.sensor_adjust_frame_lines = msm_sensor_adjust_frame_lines1,
-	.sensor_get_csi_params = msm_sensor_get_csi_params,
-};
-
-static struct msm_sensor_reg_t s5k3l1yx_regs = {
-	.default_data_type = MSM_CAMERA_I2C_BYTE_DATA,
-	.start_stream_conf = s5k3l1yx_start_settings,
-	.start_stream_conf_size = ARRAY_SIZE(s5k3l1yx_start_settings),
-	.stop_stream_conf = s5k3l1yx_stop_settings,
-	.stop_stream_conf_size = ARRAY_SIZE(s5k3l1yx_stop_settings),
-	.group_hold_on_conf = s5k3l1yx_groupon_settings,
-	.group_hold_on_conf_size = ARRAY_SIZE(s5k3l1yx_groupon_settings),
-	.group_hold_off_conf = s5k3l1yx_groupoff_settings,
-	.group_hold_off_conf_size =
-		ARRAY_SIZE(s5k3l1yx_groupoff_settings),
-	.init_settings = &s5k3l1yx_init_conf[0],
-	.init_size = ARRAY_SIZE(s5k3l1yx_init_conf),
-	.mode_settings = &s5k3l1yx_confs[0],
-	.output_settings = &s5k3l1yx_dimensions[0],
-	.num_conf = ARRAY_SIZE(s5k3l1yx_confs),
-};
-
-static struct msm_sensor_ctrl_t s5k3l1yx_s_ctrl = {
-	.msm_sensor_reg = &s5k3l1yx_regs,
-	.sensor_i2c_client = &s5k3l1yx_sensor_i2c_client,
-	.sensor_i2c_addr = 0x6E,
-	.vreg_seq = s5k3l1yx_veg_seq,
-	.num_vreg_seq = ARRAY_SIZE(s5k3l1yx_veg_seq),
-	.sensor_output_reg_addr = &s5k3l1yx_reg_addr,
-	.sensor_id_info = &s5k3l1yx_id_info,
-	.sensor_exp_gain_info = &s5k3l1yx_exp_gain_info,
-	.cam_mode = MSM_SENSOR_MODE_INVALID,
-	.msm_sensor_mutex = &s5k3l1yx_mut,
-	.sensor_i2c_driver = &s5k3l1yx_i2c_driver,
-	.sensor_v4l2_subdev_info = s5k3l1yx_subdev_info,
-	.sensor_v4l2_subdev_info_size = ARRAY_SIZE(s5k3l1yx_subdev_info),
-	.sensor_v4l2_subdev_ops = &s5k3l1yx_subdev_ops,
-	.func_tbl = &s5k3l1yx_func_tbl,
-	.clk_rate = MSM_SENSOR_MCLK_24HZ,
-};
-
-module_init(msm_sensor_init_module);
-module_exit(msm_sensor_exit_module);
-MODULE_DESCRIPTION("Samsung 12MP Bayer sensor driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/sensors/s5k4e1_v4l2.c b/drivers/media/platform/msm/camera_v1/sensors/s5k4e1_v4l2.c
deleted file mode 100644
index a95bb0a..0000000
--- a/drivers/media/platform/msm/camera_v1/sensors/s5k4e1_v4l2.c
+++ /dev/null
@@ -1,518 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- *
- */
-
-#include "msm_sensor.h"
-#define SENSOR_NAME "s5k4e1"
-#define PLATFORM_DRIVER_NAME "msm_camera_s5k4e1"
-#define s5k4e1_obj s5k4e1_##obj
-#define MSB                             1
-#define LSB                             0
-
-DEFINE_MUTEX(s5k4e1_mut);
-static struct msm_sensor_ctrl_t s5k4e1_s_ctrl;
-
-static struct msm_camera_i2c_reg_conf s5k4e1_start_settings[] = {
-	{0x0100, 0x01},
-};
-
-static struct msm_camera_i2c_reg_conf s5k4e1_stop_settings[] = {
-	{0x0100, 0x00},
-};
-
-static struct msm_camera_i2c_reg_conf s5k4e1_groupon_settings[] = {
-	{0x0104, 0x01},
-};
-
-static struct msm_camera_i2c_reg_conf s5k4e1_groupoff_settings[] = {
-	{0x0104, 0x00},
-};
-
-static struct msm_camera_i2c_reg_conf s5k4e1_prev_settings[] = {
-	/* output size (1304 x 980) */
-	{0x30A9, 0x02},/* Horizontal Binning On */
-	{0x300E, 0xEB},/* Vertical Binning On */
-	{0x0387, 0x03},/* y_odd_inc 03(10b AVG) */
-	{0x0344, 0x00},/* x_addr_start 0 */
-	{0x0345, 0x00},
-	{0x0348, 0x0A},/* x_addr_end 2607 */
-	{0x0349, 0x2F},
-	{0x0346, 0x00},/* y_addr_start 0 */
-	{0x0347, 0x00},
-	{0x034A, 0x07},/* y_addr_end 1959 */
-	{0x034B, 0xA7},
-	{0x0380, 0x00},/* x_even_inc 1 */
-	{0x0381, 0x01},
-	{0x0382, 0x00},/* x_odd_inc 1 */
-	{0x0383, 0x01},
-	{0x0384, 0x00},/* y_even_inc 1 */
-	{0x0385, 0x01},
-	{0x0386, 0x00},/* y_odd_inc 3 */
-	{0x0387, 0x03},
-	{0x034C, 0x05},/* x_output_size 1304 */
-	{0x034D, 0x18},
-	{0x034E, 0x03},/* y_output_size 980 */
-	{0x034F, 0xd4},
-	{0x30BF, 0xAB},/* outif_enable[7], data_type[5:0](2Bh = bayer 10bit} */
-	{0x30C0, 0xA0},/* video_offset[7:4] 3260%12 */
-	{0x30C8, 0x06},/* video_data_length 1600 = 1304 * 1.25 */
-	{0x30C9, 0x5E},
-	/* Timing Configuration */
-	{0x0202, 0x03},
-	{0x0203, 0x14},
-	{0x0204, 0x00},
-	{0x0205, 0x80},
-	{0x0340, 0x03},/* Frame Length */
-	{0x0341, 0xE0},
-	{0x0342, 0x0A},/* 2738  Line Length */
-	{0x0343, 0xB2},
-};
-
-static struct msm_camera_i2c_reg_conf s5k4e1_snap_settings[] = {
-	/*Output Size (2608x1960)*/
-	{0x30A9, 0x03},/* Horizontal Binning Off */
-	{0x300E, 0xE8},/* Vertical Binning Off */
-	{0x0387, 0x01},/* y_odd_inc */
-	{0x034C, 0x0A},/* x_output size */
-	{0x034D, 0x30},
-	{0x034E, 0x07},/* y_output size */
-	{0x034F, 0xA8},
-	{0x30BF, 0xAB},/* outif_enable[7], data_type[5:0](2Bh = bayer 10bit} */
-	{0x30C0, 0x80},/* video_offset[7:4] 3260%12 */
-	{0x30C8, 0x0C},/* video_data_length 3260 = 2608 * 1.25 */
-	{0x30C9, 0xBC},
-	/*Timing configuration*/
-	{0x0202, 0x06},
-	{0x0203, 0x28},
-	{0x0204, 0x00},
-	{0x0205, 0x80},
-	{0x0340, 0x07},/* Frame Length */
-	{0x0341, 0xB4},
-	{0x0342, 0x0A},/* 2738 Line Length */
-	{0x0343, 0xB2},
-};
-
-static struct msm_camera_i2c_reg_conf s5k4e1_recommend_settings[] = {
-	/* Reset setting */
-	{0x0103, 0x01},
-	/* MIPI settings */
-	{0x30BD, 0x00},/* SEL_CCP[0] */
-	{0x3084, 0x15},/* SYNC Mode */
-	{0x30BE, 0x1A},/* M_PCLKDIV_AUTO[4], M_DIV_PCLK[3:0] */
-	{0x30C1, 0x01},/* pack video enable [0] */
-	{0x30EE, 0x02},/* DPHY enable [ 1] */
-	{0x3111, 0x86},/* Embedded data off [5] */
-
-	/* REC Settings */
-	/*CDS timing setting ... */
-	{0x3000, 0x05},
-	{0x3001, 0x03},
-	{0x3002, 0x08},
-	{0x3003, 0x0A},
-	{0x3004, 0x50},
-	{0x3005, 0x0E},
-	{0x3006, 0x5E},
-	{0x3007, 0x00},
-	{0x3008, 0x78},
-	{0x3009, 0x78},
-	{0x300A, 0x50},
-	{0x300B, 0x08},
-	{0x300C, 0x14},
-	{0x300D, 0x00},
-	{0x300E, 0xE8},
-	{0x300F, 0x82},
-	{0x301B, 0x77},
-
-	/* CDS option setting ... */
-	{0x3010, 0x00},
-	{0x3011, 0x3A},
-	{0x3029, 0x04},
-	{0x3012, 0x30},
-	{0x3013, 0xA0},
-	{0x3014, 0x00},
-	{0x3015, 0x00},
-	{0x3016, 0x30},
-	{0x3017, 0x94},
-	{0x3018, 0x70},
-	{0x301D, 0xD4},
-	{0x3021, 0x02},
-	{0x3022, 0x24},
-	{0x3024, 0x40},
-	{0x3027, 0x08},
-
-	/* Pixel option setting ...   */
-	{0x301C, 0x04},
-	{0x30D8, 0x3F},
-	{0x302B, 0x01},
-
-	{0x3070, 0x5F},
-	{0x3071, 0x00},
-	{0x3080, 0x04},
-	{0x3081, 0x38},
-
-	/* PLL settings */
-	{0x0305, 0x04},
-	{0x0306, 0x00},
-	{0x0307, 0x44},
-	{0x30B5, 0x00},
-	{0x30E2, 0x01},/* num lanes[1:0] = 2 */
-	{0x30F1, 0xB0},
-};
-
-static struct v4l2_subdev_info s5k4e1_subdev_info[] = {
-	{
-	.code   = V4L2_MBUS_FMT_SGRBG10_1X10,
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	.fmt    = 1,
-	.order    = 0,
-	},
-	/* more can be supported, to be added later */
-};
-
-static struct msm_camera_i2c_conf_array s5k4e1_init_conf[] = {
-	{&s5k4e1_recommend_settings[0],
-	ARRAY_SIZE(s5k4e1_recommend_settings), 0, MSM_CAMERA_I2C_BYTE_DATA}
-};
-
-static struct msm_camera_i2c_conf_array s5k4e1_confs[] = {
-	{&s5k4e1_snap_settings[0],
-	ARRAY_SIZE(s5k4e1_snap_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-	{&s5k4e1_prev_settings[0],
-	ARRAY_SIZE(s5k4e1_prev_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-};
-
-static struct msm_sensor_output_info_t s5k4e1_dimensions[] = {
-	{
-		.x_output = 0xA30,
-		.y_output = 0x7A8,
-		.line_length_pclk = 0xAB2,
-		.frame_length_lines = 0x7B4,
-		.vt_pixel_clk = 81600000,
-		.op_pixel_clk = 81600000,
-		.binning_factor = 0,
-	},
-	{
-		.x_output = 0x518,
-		.y_output = 0x3D4,
-		.line_length_pclk = 0xAB2,
-		.frame_length_lines = 0x3E0,
-		.vt_pixel_clk = 81600000,
-		.op_pixel_clk = 81600000,
-		.binning_factor = 1,
-	},
-};
-
-static struct msm_sensor_output_reg_addr_t s5k4e1_reg_addr = {
-	.x_output = 0x034C,
-	.y_output = 0x034E,
-	.line_length_pclk = 0x0342,
-	.frame_length_lines = 0x0340,
-};
-
-static struct msm_sensor_id_info_t s5k4e1_id_info = {
-	.sensor_id_reg_addr = 0x0000,
-	.sensor_id = 0x4E10,
-};
-
-static struct msm_sensor_exp_gain_info_t s5k4e1_exp_gain_info = {
-	.coarse_int_time_addr = 0x0202,
-	.global_gain_addr = 0x0204,
-	.vert_offset = 4,
-};
-
-static inline uint8_t s5k4e1_byte(uint16_t word, uint8_t offset)
-{
-	return word >> (offset * BITS_PER_BYTE);
-}
-
-static int32_t s5k4e1_write_prev_exp_gain(struct msm_sensor_ctrl_t *s_ctrl,
-						uint16_t gain, uint32_t line)
-{
-	uint16_t max_legal_gain = 0x0200;
-	int32_t rc = 0;
-	static uint32_t fl_lines, offset;
-
-	pr_info("s5k4e1_write_prev_exp_gain :%d %d\n", gain, line);
-	offset = s_ctrl->sensor_exp_gain_info->vert_offset;
-	if (gain > max_legal_gain) {
-		CDBG("Max legal gain Line:%d\n", __LINE__);
-		gain = max_legal_gain;
-	}
-
-	/* Analogue Gain */
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->global_gain_addr,
-		s5k4e1_byte(gain, MSB),
-		MSM_CAMERA_I2C_BYTE_DATA);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->global_gain_addr + 1,
-		s5k4e1_byte(gain, LSB),
-		MSM_CAMERA_I2C_BYTE_DATA);
-
-	if (line > (s_ctrl->curr_frame_length_lines - offset)) {
-		fl_lines = line + offset;
-		s_ctrl->func_tbl->sensor_group_hold_on(s_ctrl);
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-			s_ctrl->sensor_output_reg_addr->frame_length_lines,
-			s5k4e1_byte(fl_lines, MSB),
-			MSM_CAMERA_I2C_BYTE_DATA);
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-			s_ctrl->sensor_output_reg_addr->frame_length_lines + 1,
-			s5k4e1_byte(fl_lines, LSB),
-			MSM_CAMERA_I2C_BYTE_DATA);
-		/* Coarse Integration Time */
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-			s_ctrl->sensor_exp_gain_info->coarse_int_time_addr,
-			s5k4e1_byte(line, MSB),
-			MSM_CAMERA_I2C_BYTE_DATA);
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-			s_ctrl->sensor_exp_gain_info->coarse_int_time_addr + 1,
-			s5k4e1_byte(line, LSB),
-			MSM_CAMERA_I2C_BYTE_DATA);
-		s_ctrl->func_tbl->sensor_group_hold_off(s_ctrl);
-	} else if (line < (fl_lines - offset)) {
-		fl_lines = line + offset;
-		if (fl_lines < s_ctrl->curr_frame_length_lines)
-			fl_lines = s_ctrl->curr_frame_length_lines;
-
-		s_ctrl->func_tbl->sensor_group_hold_on(s_ctrl);
-		/* Coarse Integration Time */
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-			s_ctrl->sensor_exp_gain_info->coarse_int_time_addr,
-			s5k4e1_byte(line, MSB),
-			MSM_CAMERA_I2C_BYTE_DATA);
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-			s_ctrl->sensor_exp_gain_info->coarse_int_time_addr + 1,
-			s5k4e1_byte(line, LSB),
-			MSM_CAMERA_I2C_BYTE_DATA);
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-			s_ctrl->sensor_output_reg_addr->frame_length_lines,
-			s5k4e1_byte(fl_lines, MSB),
-			MSM_CAMERA_I2C_BYTE_DATA);
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-			s_ctrl->sensor_output_reg_addr->frame_length_lines + 1,
-			s5k4e1_byte(fl_lines, LSB),
-			MSM_CAMERA_I2C_BYTE_DATA);
-		s_ctrl->func_tbl->sensor_group_hold_off(s_ctrl);
-	} else {
-		fl_lines = line+4;
-		s_ctrl->func_tbl->sensor_group_hold_on(s_ctrl);
-		/* Coarse Integration Time */
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-			s_ctrl->sensor_exp_gain_info->coarse_int_time_addr,
-			s5k4e1_byte(line, MSB),
-			MSM_CAMERA_I2C_BYTE_DATA);
-		msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-			s_ctrl->sensor_exp_gain_info->coarse_int_time_addr + 1,
-			s5k4e1_byte(line, LSB),
-			MSM_CAMERA_I2C_BYTE_DATA);
-		s_ctrl->func_tbl->sensor_group_hold_off(s_ctrl);
-	}
-	return rc;
-}
-
-static int32_t s5k4e1_write_pict_exp_gain(struct msm_sensor_ctrl_t *s_ctrl,
-		uint16_t gain, uint32_t line)
-{
-	uint16_t max_legal_gain = 0x0200;
-	uint16_t min_ll_pck = 0x0AB2;
-	uint32_t ll_pck, fl_lines;
-	uint32_t ll_ratio;
-	uint8_t gain_msb, gain_lsb;
-	uint8_t intg_time_msb, intg_time_lsb;
-	uint8_t ll_pck_msb, ll_pck_lsb;
-
-	if (gain > max_legal_gain) {
-		CDBG("Max legal gain Line:%d\n", __LINE__);
-		gain = max_legal_gain;
-	}
-
-	pr_info("s5k4e1_write_exp_gain : gain = %d line = %d\n", gain, line);
-	line = (uint32_t) (line * s_ctrl->fps_divider);
-	fl_lines = s_ctrl->curr_frame_length_lines * s_ctrl->fps_divider / Q10;
-	ll_pck = s_ctrl->curr_line_length_pclk;
-
-	if (fl_lines < (line / Q10))
-		ll_ratio = (line / (fl_lines - 4));
-	else
-		ll_ratio = Q10;
-
-	ll_pck = ll_pck * ll_ratio / Q10;
-	line = line / ll_ratio;
-	if (ll_pck < min_ll_pck)
-		ll_pck = min_ll_pck;
-
-	gain_msb = (uint8_t) ((gain & 0xFF00) >> 8);
-	gain_lsb = (uint8_t) (gain & 0x00FF);
-
-	intg_time_msb = (uint8_t) ((line & 0xFF00) >> 8);
-	intg_time_lsb = (uint8_t) (line & 0x00FF);
-
-	ll_pck_msb = (uint8_t) ((ll_pck & 0xFF00) >> 8);
-	ll_pck_lsb = (uint8_t) (ll_pck & 0x00FF);
-
-	s_ctrl->func_tbl->sensor_group_hold_on(s_ctrl);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->global_gain_addr,
-		gain_msb,
-		MSM_CAMERA_I2C_BYTE_DATA);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->global_gain_addr + 1,
-		gain_lsb,
-		MSM_CAMERA_I2C_BYTE_DATA);
-
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_output_reg_addr->line_length_pclk,
-		ll_pck_msb,
-		MSM_CAMERA_I2C_BYTE_DATA);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_output_reg_addr->line_length_pclk + 1,
-		ll_pck_lsb,
-		MSM_CAMERA_I2C_BYTE_DATA);
-
-	/* Coarse Integration Time */
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->coarse_int_time_addr,
-		intg_time_msb,
-		MSM_CAMERA_I2C_BYTE_DATA);
-	msm_camera_i2c_write(s_ctrl->sensor_i2c_client,
-		s_ctrl->sensor_exp_gain_info->coarse_int_time_addr + 1,
-		intg_time_lsb,
-		MSM_CAMERA_I2C_BYTE_DATA);
-	s_ctrl->func_tbl->sensor_group_hold_off(s_ctrl);
-
-	return 0;
-}
-
-int32_t s5k4e1_sensor_i2c_probe(struct i2c_client *client,
-	const struct i2c_device_id *id)
-{
-	int rc = 0;
-	struct msm_camera_sensor_info *s_info;
-
-	rc = msm_sensor_i2c_probe(client, id);
-
-	s_info = client->dev.platform_data;
-	if (s_info == NULL) {
-		pr_err("%s %s NULL sensor data\n", __func__, client->name);
-		return -EFAULT;
-	}
-
-	if (s_info->actuator_info->vcm_enable) {
-		rc = gpio_request(s_info->actuator_info->vcm_pwd,
-				"msm_actuator");
-		if (rc < 0)
-			pr_err("%s: gpio_request:msm_actuator %d failed\n",
-				__func__, s_info->actuator_info->vcm_pwd);
-		rc = gpio_direction_output(s_info->actuator_info->vcm_pwd, 0);
-		if (rc < 0)
-			pr_err("%s: gpio:msm_actuator %d direction can't be set\n",
-				__func__, s_info->actuator_info->vcm_pwd);
-		gpio_free(s_info->actuator_info->vcm_pwd);
-	}
-
-	return rc;
-}
-
-static const struct i2c_device_id s5k4e1_i2c_id[] = {
-	{SENSOR_NAME, (kernel_ulong_t)&s5k4e1_s_ctrl},
-	{ }
-};
-
-static struct i2c_driver s5k4e1_i2c_driver = {
-	.id_table = s5k4e1_i2c_id,
-	.probe  = s5k4e1_sensor_i2c_probe,
-	.driver = {
-		.name = SENSOR_NAME,
-	},
-};
-
-static struct msm_camera_i2c_client s5k4e1_sensor_i2c_client = {
-	.addr_type = MSM_CAMERA_I2C_WORD_ADDR,
-};
-
-static int __init msm_sensor_init_module(void)
-{
-	return i2c_add_driver(&s5k4e1_i2c_driver);
-}
-
-static struct v4l2_subdev_core_ops s5k4e1_subdev_core_ops = {
-	.ioctl = msm_sensor_subdev_ioctl,
-	.s_power = msm_sensor_power,
-};
-
-static struct v4l2_subdev_video_ops s5k4e1_subdev_video_ops = {
-	.enum_mbus_fmt = msm_sensor_v4l2_enum_fmt,
-};
-
-static struct v4l2_subdev_ops s5k4e1_subdev_ops = {
-	.core = &s5k4e1_subdev_core_ops,
-	.video  = &s5k4e1_subdev_video_ops,
-};
-
-static struct msm_sensor_fn_t s5k4e1_func_tbl = {
-	.sensor_start_stream = msm_sensor_start_stream,
-	.sensor_stop_stream = msm_sensor_stop_stream,
-	.sensor_group_hold_on = msm_sensor_group_hold_on,
-	.sensor_group_hold_off = msm_sensor_group_hold_off,
-	.sensor_set_fps = msm_sensor_set_fps,
-	.sensor_write_exp_gain = s5k4e1_write_prev_exp_gain,
-	.sensor_write_snapshot_exp_gain = s5k4e1_write_pict_exp_gain,
-	.sensor_csi_setting = msm_sensor_setting1,
-	.sensor_set_sensor_mode = msm_sensor_set_sensor_mode,
-	.sensor_mode_init = msm_sensor_mode_init,
-	.sensor_get_output_info = msm_sensor_get_output_info,
-	.sensor_config = msm_sensor_config,
-	.sensor_power_up = msm_sensor_power_up,
-	.sensor_power_down = msm_sensor_power_down,
-};
-
-static struct msm_sensor_reg_t s5k4e1_regs = {
-	.default_data_type = MSM_CAMERA_I2C_BYTE_DATA,
-	.start_stream_conf = s5k4e1_start_settings,
-	.start_stream_conf_size = ARRAY_SIZE(s5k4e1_start_settings),
-	.stop_stream_conf = s5k4e1_stop_settings,
-	.stop_stream_conf_size = ARRAY_SIZE(s5k4e1_stop_settings),
-	.group_hold_on_conf = s5k4e1_groupon_settings,
-	.group_hold_on_conf_size = ARRAY_SIZE(s5k4e1_groupon_settings),
-	.group_hold_off_conf = s5k4e1_groupoff_settings,
-	.group_hold_off_conf_size =
-		ARRAY_SIZE(s5k4e1_groupoff_settings),
-	.init_settings = &s5k4e1_init_conf[0],
-	.init_size = ARRAY_SIZE(s5k4e1_init_conf),
-	.mode_settings = &s5k4e1_confs[0],
-	.output_settings = &s5k4e1_dimensions[0],
-	.num_conf = ARRAY_SIZE(s5k4e1_confs),
-};
-
-static struct msm_sensor_ctrl_t s5k4e1_s_ctrl = {
-	.msm_sensor_reg = &s5k4e1_regs,
-	.sensor_i2c_client = &s5k4e1_sensor_i2c_client,
-	.sensor_i2c_addr = 0x6C,
-	.sensor_output_reg_addr = &s5k4e1_reg_addr,
-	.sensor_id_info = &s5k4e1_id_info,
-	.sensor_exp_gain_info = &s5k4e1_exp_gain_info,
-	.cam_mode = MSM_SENSOR_MODE_INVALID,
-	.msm_sensor_mutex = &s5k4e1_mut,
-	.sensor_i2c_driver = &s5k4e1_i2c_driver,
-	.sensor_v4l2_subdev_info = s5k4e1_subdev_info,
-	.sensor_v4l2_subdev_info_size = ARRAY_SIZE(s5k4e1_subdev_info),
-	.sensor_v4l2_subdev_ops = &s5k4e1_subdev_ops,
-	.func_tbl = &s5k4e1_func_tbl,
-	.clk_rate = MSM_SENSOR_MCLK_24HZ,
-};
-
-module_init(msm_sensor_init_module);
-MODULE_DESCRIPTION("Samsung 5MP Bayer sensor driver");
-MODULE_LICENSE("GPL v2");
-
-
diff --git a/drivers/media/platform/msm/camera_v1/sensors/vx6953.c b/drivers/media/platform/msm/camera_v1/sensors/vx6953.c
deleted file mode 100644
index 9867468..0000000
--- a/drivers/media/platform/msm/camera_v1/sensors/vx6953.c
+++ /dev/null
@@ -1,2037 +0,0 @@
-/* Copyright (c) 2010-2012, The Linux Foundation. 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.
- *
- */
-
-#include "msm_sensor.h"
-#include "msm.h"
-#include "vx6953.h"
-#include "vx6953_reg.h"
-#define SENSOR_NAME "vx6953"
-#define PLATFORM_DRIVER_NAME "msm_camera_vx6953"
-#define vx6953_obj vx6953_##obj
-
-DEFINE_MUTEX(vx6953_mut);
-
-#undef CDBG
-#define CDBG printk
-#define REG_GROUPED_PARAMETER_HOLD			0x0104
-#define GROUPED_PARAMETER_HOLD_OFF			0x00
-#define GROUPED_PARAMETER_HOLD				0x01
-#define REG_MODE_SELECT					0x0100
-#define MODE_SELECT_STANDBY_MODE			0x00
-#define MODE_SELECT_STREAM				0x01
-/* Integration Time */
-#define REG_COARSE_INTEGRATION_TIME_HI			0x0202
-#define REG_COARSE_INTEGRATION_TIME_LO			0x0203
-/* Gain */
-#define REG_ANALOGUE_GAIN_CODE_GLOBAL_HI		0x0204
-#define REG_ANALOGUE_GAIN_CODE_GLOBAL_LO		0x0205
-/* Digital Gain */
-#define REG_DIGITAL_GAIN_GREEN_R_HI			0x020E
-#define REG_DIGITAL_GAIN_GREEN_R_LO			0x020F
-#define REG_DIGITAL_GAIN_RED_HI				0x0210
-#define REG_DIGITAL_GAIN_RED_LO				0x0211
-#define REG_DIGITAL_GAIN_BLUE_HI			0x0212
-#define REG_DIGITAL_GAIN_BLUE_LO			0x0213
-#define REG_DIGITAL_GAIN_GREEN_B_HI			0x0214
-#define REG_DIGITAL_GAIN_GREEN_B_LO			0x0215
-/* output bits setting */
-#define REG_0x0112					0x0112
-#define REG_0x0113					0x0113
-/* PLL registers */
-#define REG_VT_PIX_CLK_DIV				0x0301
-#define REG_PRE_PLL_CLK_DIV				0x0305
-#define REG_PLL_MULTIPLIER				0x0307
-#define REG_OP_PIX_CLK_DIV				0x0309
-#define REG_0x034c					0x034c
-#define REG_0x034d					0x034d
-#define REG_0x034e					0x034e
-#define REG_0x034f					0x034f
-#define REG_0x0387					0x0387
-#define REG_0x0383					0x0383
-#define REG_FRAME_LENGTH_LINES_HI			0x0340
-#define REG_FRAME_LENGTH_LINES_LO			0x0341
-#define REG_LINE_LENGTH_PCK_HI				0x0342
-#define REG_LINE_LENGTH_PCK_LO				0x0343
-#define REG_0x3030					0x3030
-#define REG_0x0111					0x0111
-#define REG_0x0136					0x0136
-#define REG_0x0137					0x0137
-#define REG_0x0b00					0x0b00
-#define REG_0x3001					0x3001
-#define REG_0x3004					0x3004
-#define REG_0x3007					0x3007
-#define REG_0x301a					0x301a
-#define REG_0x3101					0x3101
-#define REG_0x3364					0x3364
-#define REG_0x3365					0x3365
-#define REG_0x0b83					0x0b83
-#define REG_0x0b84					0x0b84
-#define REG_0x0b85					0x0b85
-#define REG_0x0b88					0x0b88
-#define REG_0x0b89					0x0b89
-#define REG_0x0b8a					0x0b8a
-#define REG_0x3005					0x3005
-#define REG_0x3010					0x3010
-#define REG_0x3036					0x3036
-#define REG_0x3041					0x3041
-#define REG_0x0b80					0x0b80
-#define REG_0x0900					0x0900
-#define REG_0x0901					0x0901
-#define REG_0x0902					0x0902
-#define REG_0x3016					0x3016
-#define REG_0x301d					0x301d
-#define REG_0x317e					0x317e
-#define REG_0x317f					0x317f
-#define REG_0x3400					0x3400
-#define REG_0x303a					0x303a
-#define REG_0x1716					0x1716
-#define REG_0x1717					0x1717
-#define REG_0x1718					0x1718
-#define REG_0x1719					0x1719
-#define REG_0x3006					0x3006
-#define REG_0x301b					0x301b
-#define REG_0x3098					0x3098
-#define REG_0x309d					0x309d
-#define REG_0x3011					0x3011
-#define REG_0x3035					0x3035
-#define REG_0x3045					0x3045
-#define REG_0x3210					0x3210
-#define	REG_0x0111					0x0111
-#define REG_0x3410					0x3410
-#define REG_0x0b06					0x0b06
-#define REG_0x0b07					0x0b07
-#define REG_0x0b08					0x0b08
-#define REG_0x0b09					0x0b09
-#define REG_0x3640					0x3640
-/* Test Pattern */
-#define REG_TEST_PATTERN_MODE				0x0601
-/* 16bit address - 8 bit context register structure */
-#define	VX6953_STM5M0EDOF_OFFSET	9
-#define	Q8		0x00000100
-#define	Q10		0x00000400
-#define	VX6953_STM5M0EDOF_MAX_SNAPSHOT_EXPOSURE_LINE_COUNT	2922
-#define	VX6953_STM5M0EDOF_DEFAULT_MASTER_CLK_RATE	24000000
-#define	VX6953_STM5M0EDOF_OP_PIXEL_CLOCK_RATE	79800000
-#define	VX6953_STM5M0EDOF_VT_PIXEL_CLOCK_RATE	88670000
-/* Full	Size */
-#define	VX6953_FULL_SIZE_WIDTH	2608
-#define	VX6953_FULL_SIZE_HEIGHT		1960
-#define	VX6953_FULL_SIZE_DUMMY_PIXELS	1
-#define	VX6953_FULL_SIZE_DUMMY_LINES	0
-/* Quarter Size	*/
-#define	VX6953_QTR_SIZE_WIDTH	1304
-#define	VX6953_QTR_SIZE_HEIGHT		980
-#define	VX6953_QTR_SIZE_DUMMY_PIXELS	1
-#define	VX6953_QTR_SIZE_DUMMY_LINES		0
-/* Blanking	as measured	on the scope */
-/* Full	Size */
-#define	VX6953_HRZ_FULL_BLK_PIXELS	348
-#define	VX6953_VER_FULL_BLK_LINES	40
-/* Quarter Size	*/
-#define	VX6953_HRZ_QTR_BLK_PIXELS	1628
-#define	VX6953_VER_QTR_BLK_LINES	28
-#define	MAX_LINE_LENGTH_PCK		8190
-#define	MAX_FRAME_LENGTH_LINES	16383
-#define	VX6953_REVISION_NUMBER_CUT2	0x10/*revision number	for	Cut2.0*/
-#define	VX6953_REVISION_NUMBER_CUT3	0x20/*revision number	for	Cut3.0*/
-static struct msm_sensor_ctrl_t vx6953_s_ctrl;
-static uint32_t fps_divider;/* init to 1 * 0x00000400 */
-static uint16_t fps;
-static uint8_t vx6953_stm5m0edof_delay_msecs_stdby;
-static struct msm_camera_i2c_reg_conf vx6953_start_settings[] = {
-	{0x0100, 0x01},
-};
-
-static struct msm_camera_i2c_reg_conf vx6953_stop_settings[] = {
-	{0x0100, 0x00},
-};
-
-static struct msm_camera_i2c_reg_conf vx6953_groupon_settings[] = {
-	{0x0104, 0x01},
-};
-
-static struct msm_camera_i2c_reg_conf vx6953_groupoff_settings[] = {
-	{0x0104, 0x00},
-};
-
-static struct msm_camera_i2c_reg_conf vx6953_prev_settings[] = {
-	{0x0202, 0x03},/*REG = 0x0202 coarse integration_time_hi*/
-	{0x0203, 0xD0},/*REG = 0x0203 coarse_integration_time_lo*/
-	{0x0205, 0xC0},/*REG = 0x0205 analogue_gain_code_global*/
-	{0x0340, 0x03},/*REG = 0x0340 frame_length_lines_hi*/
-	{0x0341, 0xf0},/*REG = 0x0341 frame_length_lines_lo*/
-	{0x0342, 0x0b},/*REG = 0x0342  line_length_pck_hi*/
-	{0x0343, 0x74},/*REG = 0x0343  line_length_pck_lo*/
-	{0x3005, 0x03},/*REG = 0x3005*/
-	{0x3010, 0x00},/*REG = 0x3010*/
-	{0x3011, 0x01},/*REG = 0x3011*/
-	{0x301a, 0x6a},/*REG = 0x301a*/
-	{0x3035, 0x03},/*REG = 0x3035*/
-	{0x3036, 0x2c},/*REG = 0x3036*/
-	{0x3041, 0x00},/*REG = 0x3041*/
-	{0x3042, 0x24},/*REG = 0x3042*/
-	{0x3045, 0x81},/*REG = 0x3045*/
-	{0x0b80, 0x02},/*REG = 0x0b80 edof estimate*/
-	{0x0900, 0x01},/*REG = 0x0900*/
-	{0x0901, 0x22},/*REG = 0x0901*/
-	{0x0902, 0x04},/*REG = 0x0902*/
-	{0x0383, 0x03},/*REG = 0x0383*/
-	{0x0387, 0x03},/*REG = 0x0387*/
-	{0x034c, 0x05},/*REG = 0x034c*/
-	{0x034d, 0x18},/*REG = 0x034d*/
-	{0x034e, 0x03},/*REG = 0x034e*/
-	{0x034f, 0xd4},/*REG = 0x034f*/
-	{0x1716, 0x02},/*0x1716*/
-	{0x1717, 0x04},/*0x1717*/
-	{0x1718, 0x08},/*0x1718*/
-	{0x1719, 0x2c},/*0x1719*/
-};
-
-static struct msm_camera_i2c_reg_conf vx6953_snap_settings[] = {
-	{0x0202, 0x07},/*REG = 0x0202 coarse_integration_time_hi*/
-	{0x0203, 0x00},/*REG = 0x0203 coarse_integration_time_lo*/
-	{0x0205, 0xc0},/*REG = 0x0205 analogue_gain_code_global*/
-	{0x0340, 0x07},/*REG = 0x0340 frame_length_lines_hi*/
-	{0x0341, 0xd0},/*REG = 0x0341 frame_length_lines_lo*/
-	{0x0342, 0x0b},/*REG = 0x0342 line_length_pck_hi*/
-	{0x0343, 0x8c},/*REG = 0x0343 line_length_pck_lo*/
-	{0x3005, 0x01},/*REG = 0x3005*/
-	{0x3010, 0x00},/*REG = 0x3010*/
-	{0x3011, 0x00},/*REG = 0x3011*/
-	{0x301a, 0x55},/*REG = 0x301a*/
-	{0x3035, 0x01},/*REG = 0x3035*/
-	{0x3036, 0x23},/*REG = 0x3036*/
-	{0x3041, 0x00},/*REG = 0x3041*/
-	{0x3042, 0x24},/*REG = 0x3042*/
-	{0x3045, 0xb7},/*REG = 0x3045*/
-	{0x0b80, 0x01},/*REG = 0x0b80 edof application*/
-	{0x0900, 0x00},/*REG = 0x0900*/
-	{0x0901, 0x00},/*REG = 0x0901*/
-	{0x0902, 0x00},/*REG = 0x0902*/
-	{0x0383, 0x01},/*REG = 0x0383*/
-	{0x0387, 0x01},/*REG = 0x0387*/
-	{0x034c, 0x0A},/*REG = 0x034c*/
-	{0x034d, 0x30},/*REG = 0x034d*/
-	{0x034e, 0x07},/*REG = 0x034e*/
-	{0x034f, 0xA8},/*REG = 0x034f*/
-	{0x1716, 0x02},/*0x1716*/
-	{0x1717, 0x0d},/*0x1717*/
-	{0x1718, 0x07},/*0x1718*/
-	{0x1719, 0x7d},/*0x1719*/
-};
-
-static struct msm_camera_i2c_reg_conf vx6953_recommend_settings[] = {
-	{0x0103, 0x01}, /* standby */
-	{0x0100, 0x00}, /* stop streaming */
-	/* patch cut 2*/
-	{0xFB94, 0},	/*intialise Data Xfer Status reg*/
-	{0xFB95, 0},	/*gain 1	  (0x00)*/
-	{0xFB96, 0},	/*gain 1.07   (0x10)*/
-	{0xFB97, 0},	/*gain 1.14   (0x20)*/
-	{0xFB98, 0},	/*gain 1.23   (0x30)*/
-	{0xFB99, 0},	/*gain 1.33   (0x40)*/
-	{0xFB9A, 0},	/*gain 1.45   (0x50)*/
-	{0xFB9B, 0},	/*gain 1.6    (0x60)*/
-	{0xFB9C, 0},	/*gain 1.78   (0x70)*/
-	{0xFB9D, 2},	/*gain 2	  (0x80)*/
-	{0xFB9E, 2},	/*gain 2.29   (0x90)*/
-	{0xFB9F, 3},	/*gain 2.67   (0xA0)*/
-	{0xFBA0, 3},	/*gain 3.2    (0xB0)*/
-	{0xFBA1, 4},	/*gain 4	  (0xC0)*/
-	{0xFBA2, 7},	/*gain 5.33   (0xD0)*/
-	{0xFBA3, 10},	/*gain 8	  (0xE0)*/
-	{0xFBA4, 11},	/*gain 9.14   (0xE4)*/
-	{0xFBA5, 13},	/*gain 10.67  (0xE8)*/
-	{0xFBA6, 15},	/*gain 12.8   (0xEC)*/
-	{0xFBA7, 19},	/*gain 16     (0xF0)*/
-	{0xF800, 0x12},
-	{0xF801, 0x06},
-	{0xF802, 0xf7},
-	{0xF803, 0x90},
-	{0xF804, 0x02},
-	{0xF805, 0x05},
-	{0xF806, 0xe0},
-	{0xF807, 0xff},
-	{0xF808, 0x65},
-	{0xF809, 0x7d},
-	{0xF80A, 0x70},
-	{0xF80B, 0x03},
-	{0xF80C, 0x02},
-	{0xF80D, 0xf9},
-	{0xF80E, 0x1c},
-	{0xF80F, 0x8f},
-	{0xF810, 0x7d},
-	{0xF811, 0xe4},
-	{0xF812, 0xf5},
-	{0xF813, 0x7a},
-	{0xF814, 0x75},
-	{0xF815, 0x78},
-	{0xF816, 0x30},
-	{0xF817, 0x75},
-	{0xF818, 0x79},
-	{0xF819, 0x53},
-	{0xF81A, 0x85},
-	{0xF81B, 0x79},
-	{0xF81C, 0x82},
-	{0xF81D, 0x85},
-	{0xF81E, 0x78},
-	{0xF81F, 0x83},
-	{0xF820, 0xe0},
-	{0xF821, 0xc3},
-	{0xF822, 0x95},
-	{0xF823, 0x7b},
-	{0xF824, 0xf0},
-	{0xF825, 0x74},
-	{0xF826, 0x02},
-	{0xF827, 0x25},
-	{0xF828, 0x79},
-	{0xF829, 0xf5},
-	{0xF82A, 0x79},
-	{0xF82B, 0xe4},
-	{0xF82C, 0x35},
-	{0xF82D, 0x78},
-	{0xF82E, 0xf5},
-	{0xF82F, 0x78},
-	{0xF830, 0x05},
-	{0xF831, 0x7a},
-	{0xF832, 0xe5},
-	{0xF833, 0x7a},
-	{0xF834, 0xb4},
-	{0xF835, 0x08},
-	{0xF836, 0xe3},
-	{0xF837, 0xe5},
-	{0xF838, 0x7d},
-	{0xF839, 0x70},
-	{0xF83A, 0x04},
-	{0xF83B, 0xff},
-	{0xF83C, 0x02},
-	{0xF83D, 0xf8},
-	{0xF83E, 0xe4},
-	{0xF83F, 0xe5},
-	{0xF840, 0x7d},
-	{0xF841, 0xb4},
-	{0xF842, 0x10},
-	{0xF843, 0x05},
-	{0xF844, 0x7f},
-	{0xF845, 0x01},
-	{0xF846, 0x02},
-	{0xF847, 0xf8},
-	{0xF848, 0xe4},
-	{0xF849, 0xe5},
-	{0xF84A, 0x7d},
-	{0xF84B, 0xb4},
-	{0xF84C, 0x20},
-	{0xF84D, 0x05},
-	{0xF84E, 0x7f},
-	{0xF84F, 0x02},
-	{0xF850, 0x02},
-	{0xF851, 0xf8},
-	{0xF852, 0xe4},
-	{0xF853, 0xe5},
-	{0xF854, 0x7d},
-	{0xF855, 0xb4},
-	{0xF856, 0x30},
-	{0xF857, 0x05},
-	{0xF858, 0x7f},
-	{0xF859, 0x03},
-	{0xF85A, 0x02},
-	{0xF85B, 0xf8},
-	{0xF85C, 0xe4},
-	{0xF85D, 0xe5},
-	{0xF85E, 0x7d},
-	{0xF85F, 0xb4},
-	{0xF860, 0x40},
-	{0xF861, 0x04},
-	{0xF862, 0x7f},
-	{0xF863, 0x04},
-	{0xF864, 0x80},
-	{0xF865, 0x7e},
-	{0xF866, 0xe5},
-	{0xF867, 0x7d},
-	{0xF868, 0xb4},
-	{0xF869, 0x50},
-	{0xF86A, 0x04},
-	{0xF86B, 0x7f},
-	{0xF86C, 0x05},
-	{0xF86D, 0x80},
-	{0xF86E, 0x75},
-	{0xF86F, 0xe5},
-	{0xF870, 0x7d},
-	{0xF871, 0xb4},
-	{0xF872, 0x60},
-	{0xF873, 0x04},
-	{0xF874, 0x7f},
-	{0xF875, 0x06},
-	{0xF876, 0x80},
-	{0xF877, 0x6c},
-	{0xF878, 0xe5},
-	{0xF879, 0x7d},
-	{0xF87A, 0xb4},
-	{0xF87B, 0x70},
-	{0xF87C, 0x04},
-	{0xF87D, 0x7f},
-	{0xF87E, 0x07},
-	{0xF87F, 0x80},
-	{0xF880, 0x63},
-	{0xF881, 0xe5},
-	{0xF882, 0x7d},
-	{0xF883, 0xb4},
-	{0xF884, 0x80},
-	{0xF885, 0x04},
-	{0xF886, 0x7f},
-	{0xF887, 0x08},
-	{0xF888, 0x80},
-	{0xF889, 0x5a},
-	{0xF88A, 0xe5},
-	{0xF88B, 0x7d},
-	{0xF88C, 0xb4},
-	{0xF88D, 0x90},
-	{0xF88E, 0x04},
-	{0xF88F, 0x7f},
-	{0xF890, 0x09},
-	{0xF891, 0x80},
-	{0xF892, 0x51},
-	{0xF893, 0xe5},
-	{0xF894, 0x7d},
-	{0xF895, 0xb4},
-	{0xF896, 0xa0},
-	{0xF897, 0x04},
-	{0xF898, 0x7f},
-	{0xF899, 0x0a},
-	{0xF89A, 0x80},
-	{0xF89B, 0x48},
-	{0xF89C, 0xe5},
-	{0xF89D, 0x7d},
-	{0xF89E, 0xb4},
-	{0xF89F, 0xb0},
-	{0xF8A0, 0x04},
-	{0xF8A1, 0x7f},
-	{0xF8A2, 0x0b},
-	{0xF8A3, 0x80},
-	{0xF8A4, 0x3f},
-	{0xF8A5, 0xe5},
-	{0xF8A6, 0x7d},
-	{0xF8A7, 0xb4},
-	{0xF8A8, 0xc0},
-	{0xF8A9, 0x04},
-	{0xF8AA, 0x7f},
-	{0xF8AB, 0x0c},
-	{0xF8AC, 0x80},
-	{0xF8AD, 0x36},
-	{0xF8AE, 0xe5},
-	{0xF8AF, 0x7d},
-	{0xF8B0, 0xb4},
-	{0xF8B1, 0xd0},
-	{0xF8B2, 0x04},
-	{0xF8B3, 0x7f},
-	{0xF8B4, 0x0d},
-	{0xF8B5, 0x80},
-	{0xF8B6, 0x2d},
-	{0xF8B7, 0xe5},
-	{0xF8B8, 0x7d},
-	{0xF8B9, 0xb4},
-	{0xF8BA, 0xe0},
-	{0xF8BB, 0x04},
-	{0xF8BC, 0x7f},
-	{0xF8BD, 0x0e},
-	{0xF8BE, 0x80},
-	{0xF8BF, 0x24},
-	{0xF8C0, 0xe5},
-	{0xF8C1, 0x7d},
-	{0xF8C2, 0xb4},
-	{0xF8C3, 0xe4},
-	{0xF8C4, 0x04},
-	{0xF8C5, 0x7f},
-	{0xF8C6, 0x0f},
-	{0xF8C7, 0x80},
-	{0xF8C8, 0x1b},
-	{0xF8C9, 0xe5},
-	{0xF8CA, 0x7d},
-	{0xF8CB, 0xb4},
-	{0xF8CC, 0xe8},
-	{0xF8CD, 0x04},
-	{0xF8CE, 0x7f},
-	{0xF8CF, 0x10},
-	{0xF8D0, 0x80},
-	{0xF8D1, 0x12},
-	{0xF8D2, 0xe5},
-	{0xF8D3, 0x7d},
-	{0xF8D4, 0xb4},
-	{0xF8D5, 0xec},
-	{0xF8D6, 0x04},
-	{0xF8D7, 0x7f},
-	{0xF8D8, 0x11},
-	{0xF8D9, 0x80},
-	{0xF8DA, 0x09},
-	{0xF8DB, 0xe5},
-	{0xF8DC, 0x7d},
-	{0xF8DD, 0x7f},
-	{0xF8DE, 0x00},
-	{0xF8DF, 0xb4},
-	{0xF8E0, 0xf0},
-	{0xF8E1, 0x02},
-	{0xF8E2, 0x7f},
-	{0xF8E3, 0x12},
-	{0xF8E4, 0x8f},
-	{0xF8E5, 0x7c},
-	{0xF8E6, 0xef},
-	{0xF8E7, 0x24},
-	{0xF8E8, 0x95},
-	{0xF8E9, 0xff},
-	{0xF8EA, 0xe4},
-	{0xF8EB, 0x34},
-	{0xF8EC, 0xfb},
-	{0xF8ED, 0x8f},
-	{0xF8EE, 0x82},
-	{0xF8EF, 0xf5},
-	{0xF8F0, 0x83},
-	{0xF8F1, 0xe4},
-	{0xF8F2, 0x93},
-	{0xF8F3, 0xf5},
-	{0xF8F4, 0x7c},
-	{0xF8F5, 0xf5},
-	{0xF8F6, 0x7b},
-	{0xF8F7, 0xe4},
-	{0xF8F8, 0xf5},
-	{0xF8F9, 0x7a},
-	{0xF8FA, 0x75},
-	{0xF8FB, 0x78},
-	{0xF8FC, 0x30},
-	{0xF8FD, 0x75},
-	{0xF8FE, 0x79},
-	{0xF8FF, 0x53},
-	{0xF900, 0x85},
-	{0xF901, 0x79},
-	{0xF902, 0x82},
-	{0xF903, 0x85},
-	{0xF904, 0x78},
-	{0xF905, 0x83},
-	{0xF906, 0xe0},
-	{0xF907, 0x25},
-	{0xF908, 0x7c},
-	{0xF909, 0xf0},
-	{0xF90A, 0x74},
-	{0xF90B, 0x02},
-	{0xF90C, 0x25},
-	{0xF90D, 0x79},
-	{0xF90E, 0xf5},
-	{0xF90F, 0x79},
-	{0xF910, 0xe4},
-	{0xF911, 0x35},
-	{0xF912, 0x78},
-	{0xF913, 0xf5},
-	{0xF914, 0x78},
-	{0xF915, 0x05},
-	{0xF916, 0x7a},
-	{0xF917, 0xe5},
-	{0xF918, 0x7a},
-	{0xF919, 0xb4},
-	{0xF91A, 0x08},
-	{0xF91B, 0xe4},
-	{0xF91C, 0x02},
-	{0xF91D, 0x18},
-	{0xF91E, 0x32},
-	{0xF91F, 0x22},
-	{0xF920, 0xf0},
-	{0xF921, 0x90},
-	{0xF922, 0xa0},
-	{0xF923, 0xf8},
-	{0xF924, 0xe0},
-	{0xF925, 0x70},
-	{0xF926, 0x02},
-	{0xF927, 0xa3},
-	{0xF928, 0xe0},
-	{0xF929, 0x70},
-	{0xF92A, 0x0a},
-	{0xF92B, 0x90},
-	{0xF92C, 0xa1},
-	{0xF92D, 0x10},
-	{0xF92E, 0xe0},
-	{0xF92F, 0xfe},
-	{0xF930, 0xa3},
-	{0xF931, 0xe0},
-	{0xF932, 0xff},
-	{0xF933, 0x80},
-	{0xF934, 0x04},
-	{0xF935, 0x7e},
-	{0xF936, 0x00},
-	{0xF937, 0x7f},
-	{0xF938, 0x00},
-	{0xF939, 0x8e},
-	{0xF93A, 0x7e},
-	{0xF93B, 0x8f},
-	{0xF93C, 0x7f},
-	{0xF93D, 0x90},
-	{0xF93E, 0x36},
-	{0xF93F, 0x0d},
-	{0xF940, 0xe0},
-	{0xF941, 0x44},
-	{0xF942, 0x02},
-	{0xF943, 0xf0},
-	{0xF944, 0x90},
-	{0xF945, 0x36},
-	{0xF946, 0x0e},
-	{0xF947, 0xe5},
-	{0xF948, 0x7e},
-	{0xF949, 0xf0},
-	{0xF94A, 0xa3},
-	{0xF94B, 0xe5},
-	{0xF94C, 0x7f},
-	{0xF94D, 0xf0},
-	{0xF94E, 0xe5},
-	{0xF94F, 0x3a},
-	{0xF950, 0x60},
-	{0xF951, 0x0c},
-	{0xF952, 0x90},
-	{0xF953, 0x36},
-	{0xF954, 0x09},
-	{0xF955, 0xe0},
-	{0xF956, 0x70},
-	{0xF957, 0x06},
-	{0xF958, 0x90},
-	{0xF959, 0x36},
-	{0xF95A, 0x08},
-	{0xF95B, 0xf0},
-	{0xF95C, 0xf5},
-	{0xF95D, 0x3a},
-	{0xF95E, 0x02},
-	{0xF95F, 0x03},
-	{0xF960, 0x94},
-	{0xF961, 0x22},
-	{0xF962, 0x78},
-	{0xF963, 0x07},
-	{0xF964, 0xe6},
-	{0xF965, 0xd3},
-	{0xF966, 0x94},
-	{0xF967, 0x00},
-	{0xF968, 0x40},
-	{0xF969, 0x16},
-	{0xF96A, 0x16},
-	{0xF96B, 0xe6},
-	{0xF96C, 0x90},
-	{0xF96D, 0x30},
-	{0xF96E, 0xa1},
-	{0xF96F, 0xf0},
-	{0xF970, 0x90},
-	{0xF971, 0x43},
-	{0xF972, 0x83},
-	{0xF973, 0xe0},
-	{0xF974, 0xb4},
-	{0xF975, 0x01},
-	{0xF976, 0x0f},
-	{0xF977, 0x90},
-	{0xF978, 0x43},
-	{0xF979, 0x87},
-	{0xF97A, 0xe0},
-	{0xF97B, 0xb4},
-	{0xF97C, 0x01},
-	{0xF97D, 0x08},
-	{0xF97E, 0x80},
-	{0xF97F, 0x00},
-	{0xF980, 0x90},
-	{0xF981, 0x30},
-	{0xF982, 0xa0},
-	{0xF983, 0x74},
-	{0xF984, 0x01},
-	{0xF985, 0xf0},
-	{0xF986, 0x22},
-	{0xF987, 0xf0},
-	{0xF988, 0x90},
-	{0xF989, 0x35},
-	{0xF98A, 0xba},
-	{0xF98B, 0xe0},
-	{0xF98C, 0xb4},
-	{0xF98D, 0x0a},
-	{0xF98E, 0x0d},
-	{0xF98F, 0xa3},
-	{0xF990, 0xe0},
-	{0xF991, 0xb4},
-	{0xF992, 0x01},
-	{0xF993, 0x08},
-	{0xF994, 0x90},
-	{0xF995, 0xfb},
-	{0xF996, 0x94},
-	{0xF997, 0xe0},
-	{0xF998, 0x90},
-	{0xF999, 0x35},
-	{0xF99A, 0xb8},
-	{0xF99B, 0xf0},
-	{0xF99C, 0xd0},
-	{0xF99D, 0xd0},
-	{0xF99E, 0xd0},
-	{0xF99F, 0x82},
-	{0xF9A0, 0xd0},
-	{0xF9A1, 0x83},
-	{0xF9A2, 0xd0},
-	{0xF9A3, 0xe0},
-	{0xF9A4, 0x32},
-	{0xF9A5, 0x22},
-	{0xF9A6, 0xe5},
-	{0xF9A7, 0x7f},
-	{0xF9A8, 0x45},
-	{0xF9A9, 0x7e},
-	{0xF9AA, 0x60},
-	{0xF9AB, 0x15},
-	{0xF9AC, 0x90},
-	{0xF9AD, 0x01},
-	{0xF9AE, 0x00},
-	{0xF9AF, 0xe0},
-	{0xF9B0, 0x70},
-	{0xF9B1, 0x0f},
-	{0xF9B2, 0x90},
-	{0xF9B3, 0xa0},
-	{0xF9B4, 0xf8},
-	{0xF9B5, 0xe5},
-	{0xF9B6, 0x7e},
-	{0xF9B7, 0xf0},
-	{0xF9B8, 0xa3},
-	{0xF9B9, 0xe5},
-	{0xF9BA, 0x7f},
-	{0xF9BB, 0xf0},
-	{0xF9BC, 0xe4},
-	{0xF9BD, 0xf5},
-	{0xF9BE, 0x7e},
-	{0xF9BF, 0xf5},
-	{0xF9C0, 0x7f},
-	{0xF9C1, 0x22},
-	{0xF9C2, 0x02},
-	{0xF9C3, 0x0e},
-	{0xF9C4, 0x79},
-	{0xF9C5, 0x22},
-	/* Offsets:*/
-	{0x35C6, 0x00},/* FIDDLEDARKCAL*/
-	{0x35C7, 0x00},
-	{0x35C8, 0x01},/*STOREDISTANCEATSTOPSTREAMING*/
-	{0x35C9, 0x20},
-	{0x35CA, 0x01},/*BRUCEFIX*/
-	{0x35CB, 0x62},
-	{0x35CC, 0x01},/*FIXDATAXFERSTATUSREG*/
-	{0x35CD, 0x87},
-	{0x35CE, 0x01},/*FOCUSDISTANCEUPDATE*/
-	{0x35CF, 0xA6},
-	{0x35D0, 0x01},/*SKIPEDOFRESET*/
-	{0x35D1, 0xC2},
-	{0x35D2, 0x00},
-	{0x35D3, 0xFB},
-	{0x35D4, 0x00},
-	{0x35D5, 0x94},
-	{0x35D6, 0x00},
-	{0x35D7, 0xFB},
-	{0x35D8, 0x00},
-	{0x35D9, 0x94},
-	{0x35DA, 0x00},
-	{0x35DB, 0xFB},
-	{0x35DC, 0x00},
-	{0x35DD, 0x94},
-	{0x35DE, 0x00},
-	{0x35DF, 0xFB},
-	{0x35E0, 0x00},
-	{0x35E1, 0x94},
-	{0x35E6, 0x18},/* FIDDLEDARKCAL*/
-	{0x35E7, 0x2F},
-	{0x35E8, 0x03},/* STOREDISTANCEATSTOPSTREAMING*/
-	{0x35E9, 0x93},
-	{0x35EA, 0x18},/* BRUCEFIX*/
-	{0x35EB, 0x99},
-	{0x35EC, 0x00},/* FIXDATAXFERSTATUSREG*/
-	{0x35ED, 0xA3},
-	{0x35EE, 0x21},/* FOCUSDISTANCEUPDATE*/
-	{0x35EF, 0x5B},
-	{0x35F0, 0x0E},/* SKIPEDOFRESET*/
-	{0x35F1, 0x74},
-	{0x35F2, 0x04},
-	{0x35F3, 0x64},
-	{0x35F4, 0x04},
-	{0x35F5, 0x65},
-	{0x35F6, 0x04},
-	{0x35F7, 0x7B},
-	{0x35F8, 0x04},
-	{0x35F9, 0x7C},
-	{0x35FA, 0x04},
-	{0x35FB, 0xDD},
-	{0x35FC, 0x04},
-	{0x35FD, 0xDE},
-	{0x35FE, 0x04},
-	{0x35FF, 0xEF},
-	{0x3600, 0x04},
-	{0x3601, 0xF0},
-	/*Jump/Data:*/
-	{0x35C2, 0x3F},/* Jump Reg*/
-	{0x35C3, 0xFF},/* Jump Reg*/
-	{0x35C4, 0x3F},/* Data Reg*/
-	{0x35C5, 0xC0},/* Data Reg*/
-	{0x35C0, 0x01},/* Enable*/
-	/* end of patch cut 2 */
-	/* common settings */
-	{0x0112, 10},/*REG = 0x0112 , 10 bit */
-	{0x0113, 10},/*REG = 0x0113*/
-	{0x0301, 9},/*REG = 0x0301 vt_pix_clk_div*/
-	{0x0305, 4},/*REG = 0x0305 pre_pll_clk_div*/
-	{0x0307, 133},/*REG = 0x0307 pll_multiplier*/
-	{0x0309, 10},/*REG = 0x0309 op_pix_clk_div*/
-	{0x3030, 0x08},/*REG = 0x3030*/
-	{0x0111, 0x02},/*REG = 0x0111*/
-	{0x0b00, 0x01},/*REG = 0x0b00 ,lens shading off */
-	{0x3001, 0x30},/*REG = 0x3001*/
-	{0x3004, 0x33},/*REG = 0x3004*/
-	{0x3007, 0x09},/*REG = 0x3007*/
-	{0x3016, 0x1F},/*REG = 0x3016*/
-	{0x301d, 0x03},/*REG = 0x301d*/
-	{0x317E, 0x11},/*REG = 0x317E*/
-	{0x317F, 0x09},/*REG = 0x317F*/
-	{0x3400, 0x38},/*REG = 0x3400*/
-	{0x0b06, 0x00},/*REG_0x0b06*/
-	{0x0b07, 0x80},/*REG_0x0b07*/
-	{0x0b08, 0x01},/*REG_0x0b08*/
-	{0x0b09, 0x4F},/*REG_0x0b09*/
-	{0x0136, 0x18},/*REG_0x0136*/
-	{0x0137, 0x00},/*/REG_0x0137*/
-	{0x0b83, 0x20},/*REG = 0x0b83*/
-	{0x0b84, 0x90},/*REG = 0x0b84*/
-	{0x0b85, 0x20},/*REG = 0x0b85*/
-	{0x0b88, 0x80},/*REG = 0x0b88*/
-	{0x0b89, 0x00},/*REG = 0x0b89*/
-	{0x0b8a, 0x00},/*REG = 0x0b8a*/
-	/* end of common settings */
-};
-
-static struct v4l2_subdev_info vx6953_subdev_info[] = {
-	{
-	.code   = V4L2_MBUS_FMT_SGRBG10_1X10,
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	.fmt    = 1,
-	.order    = 0,
-	},
-	/* more can be supported, to be added later */
-};
-
-static struct msm_camera_i2c_conf_array vx6953_init_conf[] = {
-	{&vx6953_recommend_settings[0],
-	ARRAY_SIZE(vx6953_recommend_settings), 0, MSM_CAMERA_I2C_BYTE_DATA}
-};
-
-static struct msm_camera_i2c_conf_array vx6953_confs[] = {
-	{&vx6953_snap_settings[0],
-	ARRAY_SIZE(vx6953_snap_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-	{&vx6953_prev_settings[0],
-	ARRAY_SIZE(vx6953_prev_settings), 0, MSM_CAMERA_I2C_BYTE_DATA},
-};
-
-static struct msm_sensor_output_info_t vx6953_dimensions[] = {
-	{
-		.x_output = 0xA30,
-		.y_output = 0x7A8,
-		.line_length_pclk = 0xB8C,
-		.frame_length_lines = 0x7D0,
-		.vt_pixel_clk = 88666666,
-		.op_pixel_clk = 192000000,
-		.binning_factor = 1,
-	},
-	{
-		.x_output = 0x518,
-		.y_output = 0x3D4,
-		.line_length_pclk = 0xB74,
-		.frame_length_lines = 0x3F0,
-		.vt_pixel_clk = 88666666,
-		.op_pixel_clk = 192000000,
-		.binning_factor = 1,
-	},
-};
-
-static struct msm_sensor_output_reg_addr_t vx6953_reg_addr = {
-	.x_output = 0x034C,
-	.y_output = 0x034E,
-	.line_length_pclk = 0x0342,
-	.frame_length_lines = 0x0340,
-};
-
-static struct msm_sensor_id_info_t vx6953_id_info = {
-	.sensor_id_reg_addr = 0x0000,
-	.sensor_id = 0x03B9,
-};
-
-static struct msm_sensor_exp_gain_info_t vx6953_exp_gain_info = {
-	.coarse_int_time_addr = 0x0202,
-	.global_gain_addr = 0x0204,
-	.vert_offset = 9,
-};
-
-static const struct i2c_device_id vx6953_i2c_id[] = {
-	{SENSOR_NAME, (kernel_ulong_t)&vx6953_s_ctrl},
-	{ }
-};
-
-static struct i2c_driver vx6953_i2c_driver = {
-	.id_table = vx6953_i2c_id,
-	.probe  = msm_sensor_i2c_probe,
-	.driver = {
-		.name = SENSOR_NAME,
-	},
-};
-
-static struct msm_camera_i2c_client vx6953_sensor_i2c_client = {
-	.addr_type = MSM_CAMERA_I2C_WORD_ADDR,
-};
-
-static int __init msm_sensor_init_module(void)
-{
-	return i2c_add_driver(&vx6953_i2c_driver);
-}
-
-static int32_t vx6953_set_fps(struct msm_sensor_ctrl_t *s_ctrl,
-	struct fps_cfg *fps) {
-	return 0;
-}
-
-int32_t vx6953_write_exp_gain(struct msm_sensor_ctrl_t *s_ctrl,
-	uint16_t gain, uint32_t line) {
-	return 0;
-}
-
-static struct v4l2_subdev_core_ops vx6953_subdev_core_ops = {
-	.ioctl = msm_sensor_subdev_ioctl,
-	.s_power = msm_sensor_power,
-};
-
-static struct v4l2_subdev_video_ops vx6953_subdev_video_ops = {
-	.enum_mbus_fmt = msm_sensor_v4l2_enum_fmt,
-};
-
-static struct v4l2_subdev_ops vx6953_subdev_ops = {
-	.core = &vx6953_subdev_core_ops,
-	.video  = &vx6953_subdev_video_ops,
-};
-
-static struct msm_camera_i2c_reg_conf vx6953_edof_estimation[] = {
-	{REG_0x0b80, 0x02},
-};
-
-static struct msm_camera_i2c_reg_conf vx6953_edof_application[] = {
-	{REG_0x0b80, 0x01},
-};
-
-static struct msm_camera_i2c_reg_conf vx6953_edof_default[] = {
-	{REG_0x0b80, 0x00},
-};
-
-static int vx6953_enable_edof(enum edof_mode_t edof_mode)
-{
-	int rc = 0;
-	if (edof_mode == VX6953_EDOF_ESTIMATION) {
-		/* EDof Estimation mode for preview */
-		msm_camera_i2c_write_tbl(
-			vx6953_s_ctrl.sensor_i2c_client,
-			vx6953_edof_estimation,
-			ARRAY_SIZE(vx6953_edof_estimation),
-			vx6953_s_ctrl.msm_sensor_reg->default_data_type);
-		CDBG("VX6953_EDOF_ESTIMATION");
-	} else if (edof_mode == VX6953_EDOF_APPLICATION) {
-		/* EDof Application mode for Capture */
-		msm_camera_i2c_write_tbl(
-			vx6953_s_ctrl.sensor_i2c_client,
-			vx6953_edof_application,
-			ARRAY_SIZE(vx6953_edof_application),
-			vx6953_s_ctrl.msm_sensor_reg->default_data_type);
-		CDBG("VX6953_EDOF_APPLICATION");
-	} else {
-		/* EDOF disabled */
-		msm_camera_i2c_write_tbl(
-			vx6953_s_ctrl.sensor_i2c_client,
-			vx6953_edof_default,
-			ARRAY_SIZE(vx6953_edof_default),
-			vx6953_s_ctrl.msm_sensor_reg->default_data_type);
-		CDBG("VX6953_EDOF_DISABLE");
-	}
-	return rc;
-}
-
-static struct msm_camera_i2c_reg_conf vx6953_standby[] = {
-	{0x103, 0x01},
-};
-
-static struct msm_camera_i2c_reg_conf patch_tbl_cut2[] = {
-	{0xFB94, 0},	/*intialise Data Xfer Status reg*/
-	{0xFB95, 0},	/*gain 1	  (0x00)*/
-	{0xFB96, 0},	/*gain 1.07   (0x10)*/
-	{0xFB97, 0},	/*gain 1.14   (0x20)*/
-	{0xFB98, 0},	/*gain 1.23   (0x30)*/
-	{0xFB99, 0},	/*gain 1.33   (0x40)*/
-	{0xFB9A, 0},	/*gain 1.45   (0x50)*/
-	{0xFB9B, 0},	/*gain 1.6    (0x60)*/
-	{0xFB9C, 0},	/*gain 1.78   (0x70)*/
-	{0xFB9D, 2},	/*gain 2	  (0x80)*/
-	{0xFB9E, 2},	/*gain 2.29   (0x90)*/
-	{0xFB9F, 3},	/*gain 2.67   (0xA0)*/
-	{0xFBA0, 3},	/*gain 3.2    (0xB0)*/
-	{0xFBA1, 4},	/*gain 4	  (0xC0)*/
-	{0xFBA2, 7},	/*gain 5.33   (0xD0)*/
-	{0xFBA3, 10},	/*gain 8	  (0xE0)*/
-	{0xFBA4, 11},	/*gain 9.14   (0xE4)*/
-	{0xFBA5, 13},	/*gain 10.67  (0xE8)*/
-	{0xFBA6, 15},	/*gain 12.8   (0xEC)*/
-	{0xFBA7, 19},	/*gain 16     (0xF0)*/
-	{0xF800, 0x12},
-	{0xF801, 0x06},
-	{0xF802, 0xf7},
-	{0xF803, 0x90},
-	{0xF804, 0x02},
-	{0xF805, 0x05},
-	{0xF806, 0xe0},
-	{0xF807, 0xff},
-	{0xF808, 0x65},
-	{0xF809, 0x7d},
-	{0xF80A, 0x70},
-	{0xF80B, 0x03},
-	{0xF80C, 0x02},
-	{0xF80D, 0xf9},
-	{0xF80E, 0x1c},
-	{0xF80F, 0x8f},
-	{0xF810, 0x7d},
-	{0xF811, 0xe4},
-	{0xF812, 0xf5},
-	{0xF813, 0x7a},
-	{0xF814, 0x75},
-	{0xF815, 0x78},
-	{0xF816, 0x30},
-	{0xF817, 0x75},
-	{0xF818, 0x79},
-	{0xF819, 0x53},
-	{0xF81A, 0x85},
-	{0xF81B, 0x79},
-	{0xF81C, 0x82},
-	{0xF81D, 0x85},
-	{0xF81E, 0x78},
-	{0xF81F, 0x83},
-	{0xF820, 0xe0},
-	{0xF821, 0xc3},
-	{0xF822, 0x95},
-	{0xF823, 0x7b},
-	{0xF824, 0xf0},
-	{0xF825, 0x74},
-	{0xF826, 0x02},
-	{0xF827, 0x25},
-	{0xF828, 0x79},
-	{0xF829, 0xf5},
-	{0xF82A, 0x79},
-	{0xF82B, 0xe4},
-	{0xF82C, 0x35},
-	{0xF82D, 0x78},
-	{0xF82E, 0xf5},
-	{0xF82F, 0x78},
-	{0xF830, 0x05},
-	{0xF831, 0x7a},
-	{0xF832, 0xe5},
-	{0xF833, 0x7a},
-	{0xF834, 0xb4},
-	{0xF835, 0x08},
-	{0xF836, 0xe3},
-	{0xF837, 0xe5},
-	{0xF838, 0x7d},
-	{0xF839, 0x70},
-	{0xF83A, 0x04},
-	{0xF83B, 0xff},
-	{0xF83C, 0x02},
-	{0xF83D, 0xf8},
-	{0xF83E, 0xe4},
-	{0xF83F, 0xe5},
-	{0xF840, 0x7d},
-	{0xF841, 0xb4},
-	{0xF842, 0x10},
-	{0xF843, 0x05},
-	{0xF844, 0x7f},
-	{0xF845, 0x01},
-	{0xF846, 0x02},
-	{0xF847, 0xf8},
-	{0xF848, 0xe4},
-	{0xF849, 0xe5},
-	{0xF84A, 0x7d},
-	{0xF84B, 0xb4},
-	{0xF84C, 0x20},
-	{0xF84D, 0x05},
-	{0xF84E, 0x7f},
-	{0xF84F, 0x02},
-	{0xF850, 0x02},
-	{0xF851, 0xf8},
-	{0xF852, 0xe4},
-	{0xF853, 0xe5},
-	{0xF854, 0x7d},
-	{0xF855, 0xb4},
-	{0xF856, 0x30},
-	{0xF857, 0x05},
-	{0xF858, 0x7f},
-	{0xF859, 0x03},
-	{0xF85A, 0x02},
-	{0xF85B, 0xf8},
-	{0xF85C, 0xe4},
-	{0xF85D, 0xe5},
-	{0xF85E, 0x7d},
-	{0xF85F, 0xb4},
-	{0xF860, 0x40},
-	{0xF861, 0x04},
-	{0xF862, 0x7f},
-	{0xF863, 0x04},
-	{0xF864, 0x80},
-	{0xF865, 0x7e},
-	{0xF866, 0xe5},
-	{0xF867, 0x7d},
-	{0xF868, 0xb4},
-	{0xF869, 0x50},
-	{0xF86A, 0x04},
-	{0xF86B, 0x7f},
-	{0xF86C, 0x05},
-	{0xF86D, 0x80},
-	{0xF86E, 0x75},
-	{0xF86F, 0xe5},
-	{0xF870, 0x7d},
-	{0xF871, 0xb4},
-	{0xF872, 0x60},
-	{0xF873, 0x04},
-	{0xF874, 0x7f},
-	{0xF875, 0x06},
-	{0xF876, 0x80},
-	{0xF877, 0x6c},
-	{0xF878, 0xe5},
-	{0xF879, 0x7d},
-	{0xF87A, 0xb4},
-	{0xF87B, 0x70},
-	{0xF87C, 0x04},
-	{0xF87D, 0x7f},
-	{0xF87E, 0x07},
-	{0xF87F, 0x80},
-	{0xF880, 0x63},
-	{0xF881, 0xe5},
-	{0xF882, 0x7d},
-	{0xF883, 0xb4},
-	{0xF884, 0x80},
-	{0xF885, 0x04},
-	{0xF886, 0x7f},
-	{0xF887, 0x08},
-	{0xF888, 0x80},
-	{0xF889, 0x5a},
-	{0xF88A, 0xe5},
-	{0xF88B, 0x7d},
-	{0xF88C, 0xb4},
-	{0xF88D, 0x90},
-	{0xF88E, 0x04},
-	{0xF88F, 0x7f},
-	{0xF890, 0x09},
-	{0xF891, 0x80},
-	{0xF892, 0x51},
-	{0xF893, 0xe5},
-	{0xF894, 0x7d},
-	{0xF895, 0xb4},
-	{0xF896, 0xa0},
-	{0xF897, 0x04},
-	{0xF898, 0x7f},
-	{0xF899, 0x0a},
-	{0xF89A, 0x80},
-	{0xF89B, 0x48},
-	{0xF89C, 0xe5},
-	{0xF89D, 0x7d},
-	{0xF89E, 0xb4},
-	{0xF89F, 0xb0},
-	{0xF8A0, 0x04},
-	{0xF8A1, 0x7f},
-	{0xF8A2, 0x0b},
-	{0xF8A3, 0x80},
-	{0xF8A4, 0x3f},
-	{0xF8A5, 0xe5},
-	{0xF8A6, 0x7d},
-	{0xF8A7, 0xb4},
-	{0xF8A8, 0xc0},
-	{0xF8A9, 0x04},
-	{0xF8AA, 0x7f},
-	{0xF8AB, 0x0c},
-	{0xF8AC, 0x80},
-	{0xF8AD, 0x36},
-	{0xF8AE, 0xe5},
-	{0xF8AF, 0x7d},
-	{0xF8B0, 0xb4},
-	{0xF8B1, 0xd0},
-	{0xF8B2, 0x04},
-	{0xF8B3, 0x7f},
-	{0xF8B4, 0x0d},
-	{0xF8B5, 0x80},
-	{0xF8B6, 0x2d},
-	{0xF8B7, 0xe5},
-	{0xF8B8, 0x7d},
-	{0xF8B9, 0xb4},
-	{0xF8BA, 0xe0},
-	{0xF8BB, 0x04},
-	{0xF8BC, 0x7f},
-	{0xF8BD, 0x0e},
-	{0xF8BE, 0x80},
-	{0xF8BF, 0x24},
-	{0xF8C0, 0xe5},
-	{0xF8C1, 0x7d},
-	{0xF8C2, 0xb4},
-	{0xF8C3, 0xe4},
-	{0xF8C4, 0x04},
-	{0xF8C5, 0x7f},
-	{0xF8C6, 0x0f},
-	{0xF8C7, 0x80},
-	{0xF8C8, 0x1b},
-	{0xF8C9, 0xe5},
-	{0xF8CA, 0x7d},
-	{0xF8CB, 0xb4},
-	{0xF8CC, 0xe8},
-	{0xF8CD, 0x04},
-	{0xF8CE, 0x7f},
-	{0xF8CF, 0x10},
-	{0xF8D0, 0x80},
-	{0xF8D1, 0x12},
-	{0xF8D2, 0xe5},
-	{0xF8D3, 0x7d},
-	{0xF8D4, 0xb4},
-	{0xF8D5, 0xec},
-	{0xF8D6, 0x04},
-	{0xF8D7, 0x7f},
-	{0xF8D8, 0x11},
-	{0xF8D9, 0x80},
-	{0xF8DA, 0x09},
-	{0xF8DB, 0xe5},
-	{0xF8DC, 0x7d},
-	{0xF8DD, 0x7f},
-	{0xF8DE, 0x00},
-	{0xF8DF, 0xb4},
-	{0xF8E0, 0xf0},
-	{0xF8E1, 0x02},
-	{0xF8E2, 0x7f},
-	{0xF8E3, 0x12},
-	{0xF8E4, 0x8f},
-	{0xF8E5, 0x7c},
-	{0xF8E6, 0xef},
-	{0xF8E7, 0x24},
-	{0xF8E8, 0x95},
-	{0xF8E9, 0xff},
-	{0xF8EA, 0xe4},
-	{0xF8EB, 0x34},
-	{0xF8EC, 0xfb},
-	{0xF8ED, 0x8f},
-	{0xF8EE, 0x82},
-	{0xF8EF, 0xf5},
-	{0xF8F0, 0x83},
-	{0xF8F1, 0xe4},
-	{0xF8F2, 0x93},
-	{0xF8F3, 0xf5},
-	{0xF8F4, 0x7c},
-	{0xF8F5, 0xf5},
-	{0xF8F6, 0x7b},
-	{0xF8F7, 0xe4},
-	{0xF8F8, 0xf5},
-	{0xF8F9, 0x7a},
-	{0xF8FA, 0x75},
-	{0xF8FB, 0x78},
-	{0xF8FC, 0x30},
-	{0xF8FD, 0x75},
-	{0xF8FE, 0x79},
-	{0xF8FF, 0x53},
-	{0xF900, 0x85},
-	{0xF901, 0x79},
-	{0xF902, 0x82},
-	{0xF903, 0x85},
-	{0xF904, 0x78},
-	{0xF905, 0x83},
-	{0xF906, 0xe0},
-	{0xF907, 0x25},
-	{0xF908, 0x7c},
-	{0xF909, 0xf0},
-	{0xF90A, 0x74},
-	{0xF90B, 0x02},
-	{0xF90C, 0x25},
-	{0xF90D, 0x79},
-	{0xF90E, 0xf5},
-	{0xF90F, 0x79},
-	{0xF910, 0xe4},
-	{0xF911, 0x35},
-	{0xF912, 0x78},
-	{0xF913, 0xf5},
-	{0xF914, 0x78},
-	{0xF915, 0x05},
-	{0xF916, 0x7a},
-	{0xF917, 0xe5},
-	{0xF918, 0x7a},
-	{0xF919, 0xb4},
-	{0xF91A, 0x08},
-	{0xF91B, 0xe4},
-	{0xF91C, 0x02},
-	{0xF91D, 0x18},
-	{0xF91E, 0x32},
-	{0xF91F, 0x22},
-	{0xF920, 0xf0},
-	{0xF921, 0x90},
-	{0xF922, 0xa0},
-	{0xF923, 0xf8},
-	{0xF924, 0xe0},
-	{0xF925, 0x70},
-	{0xF926, 0x02},
-	{0xF927, 0xa3},
-	{0xF928, 0xe0},
-	{0xF929, 0x70},
-	{0xF92A, 0x0a},
-	{0xF92B, 0x90},
-	{0xF92C, 0xa1},
-	{0xF92D, 0x10},
-	{0xF92E, 0xe0},
-	{0xF92F, 0xfe},
-	{0xF930, 0xa3},
-	{0xF931, 0xe0},
-	{0xF932, 0xff},
-	{0xF933, 0x80},
-	{0xF934, 0x04},
-	{0xF935, 0x7e},
-	{0xF936, 0x00},
-	{0xF937, 0x7f},
-	{0xF938, 0x00},
-	{0xF939, 0x8e},
-	{0xF93A, 0x7e},
-	{0xF93B, 0x8f},
-	{0xF93C, 0x7f},
-	{0xF93D, 0x90},
-	{0xF93E, 0x36},
-	{0xF93F, 0x0d},
-	{0xF940, 0xe0},
-	{0xF941, 0x44},
-	{0xF942, 0x02},
-	{0xF943, 0xf0},
-	{0xF944, 0x90},
-	{0xF945, 0x36},
-	{0xF946, 0x0e},
-	{0xF947, 0xe5},
-	{0xF948, 0x7e},
-	{0xF949, 0xf0},
-	{0xF94A, 0xa3},
-	{0xF94B, 0xe5},
-	{0xF94C, 0x7f},
-	{0xF94D, 0xf0},
-	{0xF94E, 0xe5},
-	{0xF94F, 0x3a},
-	{0xF950, 0x60},
-	{0xF951, 0x0c},
-	{0xF952, 0x90},
-	{0xF953, 0x36},
-	{0xF954, 0x09},
-	{0xF955, 0xe0},
-	{0xF956, 0x70},
-	{0xF957, 0x06},
-	{0xF958, 0x90},
-	{0xF959, 0x36},
-	{0xF95A, 0x08},
-	{0xF95B, 0xf0},
-	{0xF95C, 0xf5},
-	{0xF95D, 0x3a},
-	{0xF95E, 0x02},
-	{0xF95F, 0x03},
-	{0xF960, 0x94},
-	{0xF961, 0x22},
-	{0xF962, 0x78},
-	{0xF963, 0x07},
-	{0xF964, 0xe6},
-	{0xF965, 0xd3},
-	{0xF966, 0x94},
-	{0xF967, 0x00},
-	{0xF968, 0x40},
-	{0xF969, 0x16},
-	{0xF96A, 0x16},
-	{0xF96B, 0xe6},
-	{0xF96C, 0x90},
-	{0xF96D, 0x30},
-	{0xF96E, 0xa1},
-	{0xF96F, 0xf0},
-	{0xF970, 0x90},
-	{0xF971, 0x43},
-	{0xF972, 0x83},
-	{0xF973, 0xe0},
-	{0xF974, 0xb4},
-	{0xF975, 0x01},
-	{0xF976, 0x0f},
-	{0xF977, 0x90},
-	{0xF978, 0x43},
-	{0xF979, 0x87},
-	{0xF97A, 0xe0},
-	{0xF97B, 0xb4},
-	{0xF97C, 0x01},
-	{0xF97D, 0x08},
-	{0xF97E, 0x80},
-	{0xF97F, 0x00},
-	{0xF980, 0x90},
-	{0xF981, 0x30},
-	{0xF982, 0xa0},
-	{0xF983, 0x74},
-	{0xF984, 0x01},
-	{0xF985, 0xf0},
-	{0xF986, 0x22},
-	{0xF987, 0xf0},
-	{0xF988, 0x90},
-	{0xF989, 0x35},
-	{0xF98A, 0xba},
-	{0xF98B, 0xe0},
-	{0xF98C, 0xb4},
-	{0xF98D, 0x0a},
-	{0xF98E, 0x0d},
-	{0xF98F, 0xa3},
-	{0xF990, 0xe0},
-	{0xF991, 0xb4},
-	{0xF992, 0x01},
-	{0xF993, 0x08},
-	{0xF994, 0x90},
-	{0xF995, 0xfb},
-	{0xF996, 0x94},
-	{0xF997, 0xe0},
-	{0xF998, 0x90},
-	{0xF999, 0x35},
-	{0xF99A, 0xb8},
-	{0xF99B, 0xf0},
-	{0xF99C, 0xd0},
-	{0xF99D, 0xd0},
-	{0xF99E, 0xd0},
-	{0xF99F, 0x82},
-	{0xF9A0, 0xd0},
-	{0xF9A1, 0x83},
-	{0xF9A2, 0xd0},
-	{0xF9A3, 0xe0},
-	{0xF9A4, 0x32},
-	{0xF9A5, 0x22},
-	{0xF9A6, 0xe5},
-	{0xF9A7, 0x7f},
-	{0xF9A8, 0x45},
-	{0xF9A9, 0x7e},
-	{0xF9AA, 0x60},
-	{0xF9AB, 0x15},
-	{0xF9AC, 0x90},
-	{0xF9AD, 0x01},
-	{0xF9AE, 0x00},
-	{0xF9AF, 0xe0},
-	{0xF9B0, 0x70},
-	{0xF9B1, 0x0f},
-	{0xF9B2, 0x90},
-	{0xF9B3, 0xa0},
-	{0xF9B4, 0xf8},
-	{0xF9B5, 0xe5},
-	{0xF9B6, 0x7e},
-	{0xF9B7, 0xf0},
-	{0xF9B8, 0xa3},
-	{0xF9B9, 0xe5},
-	{0xF9BA, 0x7f},
-	{0xF9BB, 0xf0},
-	{0xF9BC, 0xe4},
-	{0xF9BD, 0xf5},
-	{0xF9BE, 0x7e},
-	{0xF9BF, 0xf5},
-	{0xF9C0, 0x7f},
-	{0xF9C1, 0x22},
-	{0xF9C2, 0x02},
-	{0xF9C3, 0x0e},
-	{0xF9C4, 0x79},
-	{0xF9C5, 0x22},
-	/* Offsets:*/
-	{0x35C6, 0x00},/* FIDDLEDARKCAL*/
-	{0x35C7, 0x00},
-	{0x35C8, 0x01},/*STOREDISTANCEATSTOPSTREAMING*/
-	{0x35C9, 0x20},
-	{0x35CA, 0x01},/*BRUCEFIX*/
-	{0x35CB, 0x62},
-	{0x35CC, 0x01},/*FIXDATAXFERSTATUSREG*/
-	{0x35CD, 0x87},
-	{0x35CE, 0x01},/*FOCUSDISTANCEUPDATE*/
-	{0x35CF, 0xA6},
-	{0x35D0, 0x01},/*SKIPEDOFRESET*/
-	{0x35D1, 0xC2},
-	{0x35D2, 0x00},
-	{0x35D3, 0xFB},
-	{0x35D4, 0x00},
-	{0x35D5, 0x94},
-	{0x35D6, 0x00},
-	{0x35D7, 0xFB},
-	{0x35D8, 0x00},
-	{0x35D9, 0x94},
-	{0x35DA, 0x00},
-	{0x35DB, 0xFB},
-	{0x35DC, 0x00},
-	{0x35DD, 0x94},
-	{0x35DE, 0x00},
-	{0x35DF, 0xFB},
-	{0x35E0, 0x00},
-	{0x35E1, 0x94},
-	{0x35E6, 0x18},/* FIDDLEDARKCAL*/
-	{0x35E7, 0x2F},
-	{0x35E8, 0x03},/* STOREDISTANCEATSTOPSTREAMING*/
-	{0x35E9, 0x93},
-	{0x35EA, 0x18},/* BRUCEFIX*/
-	{0x35EB, 0x99},
-	{0x35EC, 0x00},/* FIXDATAXFERSTATUSREG*/
-	{0x35ED, 0xA3},
-	{0x35EE, 0x21},/* FOCUSDISTANCEUPDATE*/
-	{0x35EF, 0x5B},
-	{0x35F0, 0x0E},/* SKIPEDOFRESET*/
-	{0x35F1, 0x74},
-	{0x35F2, 0x04},
-	{0x35F3, 0x64},
-	{0x35F4, 0x04},
-	{0x35F5, 0x65},
-	{0x35F6, 0x04},
-	{0x35F7, 0x7B},
-	{0x35F8, 0x04},
-	{0x35F9, 0x7C},
-	{0x35FA, 0x04},
-	{0x35FB, 0xDD},
-	{0x35FC, 0x04},
-	{0x35FD, 0xDE},
-	{0x35FE, 0x04},
-	{0x35FF, 0xEF},
-	{0x3600, 0x04},
-	{0x3601, 0xF0},
-	/*Jump/Data:*/
-	{0x35C2, 0x3F},/* Jump Reg*/
-	{0x35C3, 0xFF},/* Jump Reg*/
-	{0x35C4, 0x3F},/* Data Reg*/
-	{0x35C5, 0xC0},/* Data Reg*/
-	{0x35C0, 0x01},/* Enable*/
-};
-struct msm_camera_i2c_reg_conf init_tbl[] = {
-	{0x0112, 10},
-	{0x0113, 10},
-	{0x0301, 9},
-	{0x0305, 4},
-	{0x0307, 133},
-	{0x0309, 10},
-	{0x0202, 0x03},
-	{0x0203, 0xd0},
-	{0x0205, 0xc0},
-	{0x3030, 0x08},
-	{0x0111, 0x02},
-	{0x0b00, 0x01},
-	{0x3001, 0x30},
-	{0x3004, 0x33},
-	{0x3007, 0x09},
-	{0x3016, 0x1F},
-	{0x301d, 0x03},
-	{0x317e, 0x11},
-	{0x317f, 0x09},
-	{0x3400, 0x38},
-	{0x0b06, 0x00},
-	{0x0b07, 0x80},
-	{0x0b08, 0x01},
-	{0x0b09, 0x4F},
-	{0x0136, 0x18},
-	{0x0137, 0x00},
-	{0x0b83, 0x20},
-	{0x0b84, 0x90},
-	{0x0b85, 0x20},
-	{0x0b88, 0x80},
-	{0x0b89, 0x00},
-	{0x0b8a, 0x00},
-	{0x0340, 0x03},   /*REG = 0x0340 frame_length_lines_hi*/
-	{0x0341, 0xf0},   /*REG = 0x0341 frame_length_lines_lo*/
-	{0x0342, 0x0b},   /*REG = 0x0342  line_length_pck_hi*/
-	{0x0343, 0x74},   /*REG = 0x0343  line_length_pck_lo*/
-	{0x3005, 0x03},   /*REG = 0x3005*/
-	{0x3010, 0x00},   /*REG = 0x3010*/
-	{0x3011, 0x01},   /*REG = 0x3011*/
-	{0x301a, 0x6a},   /*REG = 0x301a*/
-	{0x3035, 0x03},   /*REG = 0x3035*/
-	{0x3036, 0x2c},   /*REG = 0x3036*/
-	{0x3041, 0x00},   /*REG = 0x3041*/
-	{0x3042, 0x24},   /*REG = 0x3042*/
-	{0x3045, 0x81},   /*REG = 0x3045*/
-	{0x0b80, 0x02},   /*REG = 0x0b80 edof estimate*/
-	{0x0900, 0x01},   /*REG = 0x0900*/
-	{0x0901, 0x22},   /*REG = 0x0901*/
-	{0x0902, 0x04},   /*REG = 0x0902*/
-	{0x0383, 0x03},   /*REG = 0x0383*/
-	{0x0387, 0x03},   /*REG = 0x0387*/
-	{0x034c, 0x05},   /*REG = 0x034c*/
-	{0x034d, 0x18},   /*REG = 0x034d*/
-	{0x034e, 0x03},   /*REG = 0x034e*/
-	{0x034f, 0xd4},   /*REG = 0x034f*/
-	{0x1716, 0x02},   /*0x1716*/
-	{0x1717, 0x04},   /*0x1717*/
-	{0x1718, 0x08},   /*0x1718*/
-	{0x1719, 0x2c},   /*0x1719*/
-};
-
-struct msm_camera_i2c_reg_conf mode_tbl1[] = {
-	{REG_0x0112, 10},/*REG = 0x0112 , 10 bit */
-	{REG_0x0113, 10},/*REG = 0x0113*/
-	{REG_VT_PIX_CLK_DIV, 9},/*REG = 0x0301 vt_pix_clk_div*/
-	{REG_PRE_PLL_CLK_DIV, 4},/*REG = 0x0305 pre_pll_clk_div*/
-	{REG_PLL_MULTIPLIER, 133},/*REG = 0x0307 pll_multiplier*/
-	{REG_OP_PIX_CLK_DIV, 10},/*REG = 0x0309 op_pix_clk_div*/
-	{REG_FRAME_LENGTH_LINES_HI, 0x03},/*REG = 0x0340 frame_length_lines_hi*/
-	{REG_FRAME_LENGTH_LINES_LO, 0xf0},/*REG = 0x0341 frame_length_lines_lo*/
-	{REG_LINE_LENGTH_PCK_HI, 0x0b},   /*REG = 0x0342  line_length_pck_hi*/
-	{REG_LINE_LENGTH_PCK_LO, 0x74},   /*REG = 0x0343  line_length_pck_lo*/
-	{REG_0x3005, 0x03},   /*REG = 0x3005*/
-	{0x3010, 0x00},   /*REG = 0x3010*/
-	{REG_0x3011, 0x01},   /*REG = 0x3011*/
-	{REG_0x301a, 0x6a},   /*REG = 0x301a*/
-	{REG_0x3035, 0x03},   /*REG = 0x3035*/
-	{REG_0x3036, 0x2c},   /*REG = 0x3036*/
-	{REG_0x3041, 0x00},   /*REG = 0x3041*/
-	{0x3042, 0x24},   /*REG = 0x3042*/
-	{REG_0x3045, 0x81},   /*REG = 0x3045*/
-	{REG_0x0b80, 0x02},   /*REG = 0x0b80 edof estimate*/
-	{REG_0x0900, 0x01},   /*REG = 0x0900*/
-	{REG_0x0901, 0x22},   /*REG = 0x0901*/
-	{REG_0x0902, 0x04},   /*REG = 0x0902*/
-	{REG_0x0383, 0x03},   /*REG = 0x0383*/
-	{REG_0x0387, 0x03},   /*REG = 0x0387*/
-	{REG_0x034c, 0x05},   /*REG = 0x034c*/
-	{REG_0x034d, 0x18},   /*REG = 0x034d*/
-	{REG_0x034e, 0x03},   /*REG = 0x034e*/
-	{REG_0x034f, 0xd4},   /*REG = 0x034f*/
-	{REG_0x1716, 0x02},   /*0x1716*/
-	{REG_0x1717, 0x04},   /*0x1717*/
-	{REG_0x1718, 0x08},   /*0x1718*/
-	{REG_0x1719, 0x2c},   /*0x1719*/
-};
-
-struct msm_camera_i2c_reg_conf mode_tbl2[] = {
-	{REG_0x0112, 10},/*REG = 0x0112 , 10 bit */
-	{REG_0x0113, 10},/*REG = 0x0113*/
-	{REG_VT_PIX_CLK_DIV, 9},/*REG = 0x0301 vt_pix_clk_div*/
-	{REG_PRE_PLL_CLK_DIV, 4},/*REG = 0x0305 pre_pll_clk_div*/
-	{REG_PLL_MULTIPLIER, 133},/*REG = 0x0307 pll_multiplier*/
-	{REG_OP_PIX_CLK_DIV, 10},/*REG = 0x0309 op_pix_clk_div*/
-	{REG_FRAME_LENGTH_LINES_HI, 0x07},/*REG = 0x0340 frame_length_lines_hi*/
-	{REG_FRAME_LENGTH_LINES_LO, 0xd0},/*REG = 0x0341 frame_length_lines_lo*/
-	{REG_LINE_LENGTH_PCK_HI, 0x0b},/*REG = 0x0342 line_length_pck_hi*/
-	{REG_LINE_LENGTH_PCK_LO, 0x8c},/*REG = 0x0343 line_length_pck_lo*/
-	{REG_0x3005, 0x01},/*REG = 0x3005*/
-	{0x3010, 0x00},/*REG = 0x3010*/
-	{REG_0x3011, 0x00},/*REG = 0x3011*/
-	{REG_0x301a, 0x55},/*REG = 0x301a*/
-	{REG_0x3035, 0x01},/*REG = 0x3035*/
-	{REG_0x3036, 0x23},/*REG = 0x3036*/
-	{REG_0x3041, 0x00},/*REG = 0x3041*/
-	{0x3042, 0x24},/*REG = 0x3042*/
-	{REG_0x3045, 0xb7},/*REG = 0x3045*/
-	{REG_0x0b80, 0x01},/*REG = 0x0b80 edof application*/
-	{REG_0x0900, 0x00},/*REG = 0x0900*/
-	{REG_0x0901, 0x00},/*REG = 0x0901*/
-	{REG_0x0902, 0x00},/*REG = 0x0902*/
-	{REG_0x0383, 0x01},/*REG = 0x0383*/
-	{REG_0x0387, 0x01},/*REG = 0x0387*/
-	{REG_0x034c, 0x0A},/*REG = 0x034c*/
-	{REG_0x034d, 0x30},/*REG = 0x034d*/
-	{REG_0x034e, 0x07},/*REG = 0x034e*/
-	{REG_0x034f, 0xA8},/*REG = 0x034f*/
-	{REG_0x1716, 0x02},/*0x1716*/
-	{REG_0x1717, 0x0d},/*0x1717*/
-	{REG_0x1718, 0x07},/*0x1718*/
-	{REG_0x1719, 0x7d},/*0x1719*/
-};
-
-static int32_t vx6953_sensor_setting(int update_type, int rt)
-{
-
-	int32_t rc = 0;
-	uint16_t frame_cnt = 0;
-		CDBG("%s update type = %d, rt = %d\n",
-			__func__, update_type, rt);
-
-		switch (update_type) {
-		case REG_INIT:
-		if (rt == RES_PREVIEW || rt == RES_CAPTURE) {
-						/* reset fps_divider */
-			fps = 30 * Q8;
-			/* stop streaming */
-
-			/* Reset everything first */
-			msm_camera_i2c_write_tbl(
-				vx6953_s_ctrl.sensor_i2c_client,
-				vx6953_standby,
-				ARRAY_SIZE(vx6953_standby),
-				vx6953_s_ctrl.msm_sensor_reg->
-				default_data_type);
-
-			msleep(20);
-
-			CDBG("Init vx6953_sensor_setting standby\n");
-			msm_camera_i2c_write_tbl(
-				vx6953_s_ctrl.sensor_i2c_client,
-				vx6953_stop_settings,
-				ARRAY_SIZE(vx6953_stop_settings),
-				vx6953_s_ctrl.msm_sensor_reg->
-				default_data_type);
-				/*vx6953_stm5m0edof_delay_msecs_stdby*/
-			msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-			msm_camera_i2c_write_tbl(
-				vx6953_s_ctrl.sensor_i2c_client,
-				patch_tbl_cut2,
-				ARRAY_SIZE(patch_tbl_cut2),
-				vx6953_s_ctrl.msm_sensor_reg->
-				default_data_type);
-			msm_camera_i2c_write_tbl(
-				vx6953_s_ctrl.sensor_i2c_client,
-				init_tbl,
-				ARRAY_SIZE(init_tbl),
-				vx6953_s_ctrl.msm_sensor_reg->
-				default_data_type);
-			msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-		}
-		return rc;
-		case UPDATE_PERIODIC:
-		if (rt == RES_PREVIEW || rt == RES_CAPTURE) {
-			struct msm_camera_i2c_reg_conf init_mode_tbl[] =  {
-			{REG_0x0112,
-				vx6953_regs.reg_pat_init[0].reg_0x0112},
-			{REG_0x0113,
-				vx6953_regs.reg_pat_init[0].reg_0x0113},
-			{REG_VT_PIX_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				vt_pix_clk_div},
-			{REG_PRE_PLL_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				pre_pll_clk_div},
-			{REG_PLL_MULTIPLIER,
-				vx6953_regs.reg_pat_init[0].
-				pll_multiplier},
-			{REG_OP_PIX_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				op_pix_clk_div},
-			{REG_COARSE_INTEGRATION_TIME_HI,
-				vx6953_regs.reg_pat[rt].
-				coarse_integration_time_hi},
-			{REG_COARSE_INTEGRATION_TIME_LO,
-				vx6953_regs.reg_pat[rt].
-				coarse_integration_time_lo},
-			{REG_ANALOGUE_GAIN_CODE_GLOBAL_LO,
-				vx6953_regs.reg_pat[rt].
-				analogue_gain_code_global},
-			{REG_0x3030,
-				vx6953_regs.reg_pat_init[0].reg_0x3030},
-			/* 953 specific registers */
-			{REG_0x0111,
-				vx6953_regs.reg_pat_init[0].reg_0x0111},
-			{REG_0x0b00,
-				vx6953_regs.reg_pat_init[0].reg_0x0b00},
-			{REG_0x3001,
-				vx6953_regs.reg_pat_init[0].reg_0x3001},
-			{REG_0x3004,
-				vx6953_regs.reg_pat_init[0].reg_0x3004},
-			{REG_0x3007,
-				vx6953_regs.reg_pat_init[0].reg_0x3007},
-			{REG_0x3016,
-				vx6953_regs.reg_pat_init[0].reg_0x3016},
-			{REG_0x301d,
-				vx6953_regs.reg_pat_init[0].reg_0x301d},
-			{REG_0x317e,
-				vx6953_regs.reg_pat_init[0].reg_0x317e},
-			{REG_0x317f,
-				vx6953_regs.reg_pat_init[0].reg_0x317f},
-			{REG_0x3400,
-				vx6953_regs.reg_pat_init[0].reg_0x3400},
-			{0x0b06,
-				vx6953_regs.reg_pat_init[0].reg_0x0b06},
-			/*Single_defect_correct_weight = auto*/
-			{0x0b07,
-				vx6953_regs.reg_pat_init[0].reg_0x0b07},
-			/*Dynamic couplet correction ENABLED*/
-			{0x0b08,
-				vx6953_regs.reg_pat_init[0].reg_0x0b08},
-			/*Dynamic couplet correction weight*/
-			{0x0b09,
-				vx6953_regs.reg_pat_init[0].reg_0x0b09},
-			/* Clock Setup */
-			/* Tell sensor ext clk is 24MHz*/
-			{0x0136,
-				vx6953_regs.reg_pat_init[0].reg_0x0136},
-			{0x0137,
-				vx6953_regs.reg_pat_init[0].reg_0x0137},
-			/* The white balance gains must be written
-			to the sensor every frame. */
-			/* Edof */
-			{REG_0x0b83,
-				vx6953_regs.reg_pat_init[0].reg_0x0b83},
-			{REG_0x0b84,
-				vx6953_regs.reg_pat_init[0].reg_0x0b84},
-			{0x0b85,
-				vx6953_regs.reg_pat_init[0].reg_0x0b85},
-			{0x0b88,
-				vx6953_regs.reg_pat_init[0].reg_0x0b88},
-			{0x0b89,
-				vx6953_regs.reg_pat_init[0].reg_0x0b89},
-			{REG_0x0b8a,
-				vx6953_regs.reg_pat_init[0].reg_0x0b8a},
-			/* Mode specific regieters */
-			{REG_FRAME_LENGTH_LINES_HI,
-				vx6953_regs.reg_pat[rt].
-				frame_length_lines_hi},
-			{REG_FRAME_LENGTH_LINES_LO,
-				vx6953_regs.reg_pat[rt].
-				frame_length_lines_lo},
-			{REG_LINE_LENGTH_PCK_HI,
-				vx6953_regs.reg_pat[rt].
-				line_length_pck_hi},
-			{REG_LINE_LENGTH_PCK_LO,
-				vx6953_regs.reg_pat[rt].
-				line_length_pck_lo},
-			{REG_0x3005,
-				vx6953_regs.reg_pat[rt].reg_0x3005},
-			{0x3010,
-				vx6953_regs.reg_pat[rt].reg_0x3010},
-			{REG_0x3011,
-				vx6953_regs.reg_pat[rt].reg_0x3011},
-			{REG_0x301a,
-				vx6953_regs.reg_pat[rt].reg_0x301a},
-			{REG_0x3035,
-				vx6953_regs.reg_pat[rt].reg_0x3035},
-			{REG_0x3036,
-				vx6953_regs.reg_pat[rt].reg_0x3036},
-			{REG_0x3041,
-				vx6953_regs.reg_pat[rt].reg_0x3041},
-			{0x3042,
-				vx6953_regs.reg_pat[rt].reg_0x3042},
-			{REG_0x3045,
-				vx6953_regs.reg_pat[rt].reg_0x3045},
-			/*EDOF: Estimation settings for Preview mode
-			Application settings for capture mode
-			(standard settings - Not tuned) */
-			{REG_0x0b80,
-				vx6953_regs.reg_pat[rt].reg_0x0b80},
-			{REG_0x0900,
-				vx6953_regs.reg_pat[rt].reg_0x0900},
-			{REG_0x0901,
-				vx6953_regs.reg_pat[rt].reg_0x0901},
-			{REG_0x0902,
-				vx6953_regs.reg_pat[rt].reg_0x0902},
-			{REG_0x0383,
-				vx6953_regs.reg_pat[rt].reg_0x0383},
-			{REG_0x0387,
-				vx6953_regs.reg_pat[rt].reg_0x0387},
-			/* Change output size / frame rate */
-			{REG_0x034c,
-				vx6953_regs.reg_pat[rt].reg_0x034c},
-			{REG_0x034d,
-				vx6953_regs.reg_pat[rt].reg_0x034d},
-			{REG_0x034e,
-				vx6953_regs.reg_pat[rt].reg_0x034e},
-			{REG_0x034f,
-				vx6953_regs.reg_pat[rt].reg_0x034f},
-			{REG_0x1716,
-				vx6953_regs.reg_pat[rt].reg_0x1716},
-			{REG_0x1717,
-				vx6953_regs.reg_pat[rt].reg_0x1717},
-			{REG_0x1718,
-				vx6953_regs.reg_pat[rt].reg_0x1718},
-			{REG_0x1719,
-				vx6953_regs.reg_pat[rt].reg_0x1719},
-			};
-			/* stop streaming */
-			msleep(20);
-
-			/* Reset everything first */
-			msm_camera_i2c_write_tbl(
-				vx6953_s_ctrl.sensor_i2c_client,
-				vx6953_standby,
-				ARRAY_SIZE(vx6953_standby),
-				vx6953_s_ctrl.msm_sensor_reg->
-				default_data_type);
-
-
-			msleep(20);
-
-			msm_camera_i2c_write_tbl(
-				vx6953_s_ctrl.sensor_i2c_client,
-				vx6953_stop_settings,
-				ARRAY_SIZE(vx6953_stop_settings),
-				vx6953_s_ctrl.msm_sensor_reg->
-				default_data_type);
-			/*vx6953_stm5m0edof_delay_msecs_stdby*/
-			msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-
-			msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-
-			msm_camera_i2c_write_tbl(
-				vx6953_s_ctrl.sensor_i2c_client,
-				patch_tbl_cut2,
-				ARRAY_SIZE(patch_tbl_cut2),
-				vx6953_s_ctrl.msm_sensor_reg->
-				default_data_type);
-
-			msm_camera_i2c_write_tbl(
-				vx6953_s_ctrl.sensor_i2c_client,
-				init_mode_tbl,
-				ARRAY_SIZE(init_mode_tbl),
-				vx6953_s_ctrl.msm_sensor_reg->
-				default_data_type);
-
-			msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-			if (rt == RES_PREVIEW) {
-				CDBG("%s write mode_tbl for preview\n",
-					__func__);
-				msm_camera_i2c_write_tbl(
-					vx6953_s_ctrl.sensor_i2c_client,
-					mode_tbl1,
-					ARRAY_SIZE(mode_tbl1),
-					vx6953_s_ctrl.msm_sensor_reg->
-					default_data_type);
-			} else if (rt == RES_CAPTURE) {
-				CDBG("%s write mode_tbl for capture\n",
-					__func__);
-				msm_camera_i2c_write_tbl(
-					vx6953_s_ctrl.sensor_i2c_client,
-					mode_tbl2,
-					ARRAY_SIZE(mode_tbl2),
-					vx6953_s_ctrl.msm_sensor_reg->
-					default_data_type);
-			}
-			msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-
-			/* Start sensor streaming */
-			msm_camera_i2c_write_tbl(
-				vx6953_s_ctrl.sensor_i2c_client,
-				vx6953_start_settings,
-				ARRAY_SIZE(vx6953_start_settings),
-				vx6953_s_ctrl.msm_sensor_reg->
-				default_data_type);
-			msleep(20);
-
-			msm_camera_i2c_read(
-				vx6953_s_ctrl.sensor_i2c_client,
-				0x0005,
-				&frame_cnt,
-				MSM_CAMERA_I2C_BYTE_ADDR);
-			while (frame_cnt == 0xFF) {
-				msm_camera_i2c_read(
-					vx6953_s_ctrl.sensor_i2c_client,
-					0x0005,
-					&frame_cnt,
-					MSM_CAMERA_I2C_BYTE_ADDR);
-				CDBG("%s frame_cnt = %d\n",
-					__func__, frame_cnt);
-				usleep_range(5000, 10000);
-			}
-		}
-		return rc;
-		default:
-		return rc;
-	}
-	return rc;
-}
-
-static int32_t vx6953_init_config(void)
-{
-	int32_t rc = 0;
-	int rt;
-	/* change sensor resolution	if needed */
-	CDBG("%s called\n", __func__);
-	rt = RES_PREVIEW;
-	vx6953_stm5m0edof_delay_msecs_stdby =
-		((((2 * 1000 * fps_divider) /
-		   fps) * Q8) / Q10) + 1;
-
-	vx6953_sensor_setting(REG_INIT, rt);
-
-	vx6953_enable_edof(VX6953_EDOF_ESTIMATION);
-	return rc;
-}
-
-static int32_t vx6953_update_config(int rt)
-{
-	int32_t rc = 0;
-	CDBG("%s rt = %d\n", __func__, rt);
-	if (rt == MSM_SENSOR_RES_FULL)
-		rt = RES_CAPTURE;
-	else if (rt == MSM_SENSOR_RES_QTR)
-		rt = RES_PREVIEW;
-
-	vx6953_stm5m0edof_delay_msecs_stdby = 67;
-	vx6953_sensor_setting(UPDATE_PERIODIC, rt);
-
-	if (rt == RES_PREVIEW)
-		vx6953_enable_edof(VX6953_EDOF_ESTIMATION);
-	else if (rt == RES_CAPTURE)
-		vx6953_enable_edof(VX6953_EDOF_APPLICATION);
-
-	return rc;
-} /*end of vx6953_snapshot_config*/
-
-static int32_t vx6953_set_sensor_mode(struct msm_sensor_ctrl_t *s_ctrl,
-	int update_type, int rt)
-{
-	int32_t rc = 0;
-
-	fps_divider = 1 * 0x00000400;
-	fps = 30*Q8;
-
-	switch (update_type) {
-	case MSM_SENSOR_REG_INIT:
-		rc = vx6953_init_config();
-		break;
-	case MSM_SENSOR_UPDATE_PERIODIC:
-		rc = vx6953_update_config(rt);
-		break;
-	default:
-		rc = -EINVAL;
-		break;
-	}
-	return rc;
-}
-static struct msm_sensor_fn_t vx6953_func_tbl = {
-	.sensor_start_stream = msm_sensor_start_stream,
-	.sensor_stop_stream = msm_sensor_stop_stream,
-	.sensor_group_hold_on = msm_sensor_group_hold_on,
-	.sensor_group_hold_off = msm_sensor_group_hold_off,
-	.sensor_set_fps = vx6953_set_fps,
-	.sensor_write_exp_gain = vx6953_write_exp_gain,
-	.sensor_write_snapshot_exp_gain = vx6953_write_exp_gain,
-	.sensor_csi_setting = vx6953_set_sensor_mode,
-	.sensor_set_sensor_mode = msm_sensor_set_sensor_mode,
-	.sensor_mode_init = msm_sensor_mode_init,
-	.sensor_get_output_info = msm_sensor_get_output_info,
-	.sensor_config = msm_sensor_config,
-	.sensor_power_up = msm_sensor_power_up,
-	.sensor_power_down = msm_sensor_power_down,
-};
-
-static struct msm_sensor_reg_t vx6953_data_regs = {
-	.default_data_type = MSM_CAMERA_I2C_BYTE_DATA,
-	.start_stream_conf = vx6953_start_settings,
-	.start_stream_conf_size = ARRAY_SIZE(vx6953_start_settings),
-	.stop_stream_conf = vx6953_stop_settings,
-	.stop_stream_conf_size = ARRAY_SIZE(vx6953_stop_settings),
-	.group_hold_on_conf = vx6953_groupon_settings,
-	.group_hold_on_conf_size = ARRAY_SIZE(vx6953_groupon_settings),
-	.group_hold_off_conf = vx6953_groupoff_settings,
-	.group_hold_off_conf_size =
-		ARRAY_SIZE(vx6953_groupoff_settings),
-	.init_settings = &vx6953_init_conf[0],
-	.init_size = ARRAY_SIZE(vx6953_init_conf),
-	.mode_settings = &vx6953_confs[0],
-	.output_settings = &vx6953_dimensions[0],
-	.num_conf = ARRAY_SIZE(vx6953_confs),
-};
-
-static struct msm_sensor_ctrl_t vx6953_s_ctrl = {
-	.msm_sensor_reg = &vx6953_data_regs,
-	.sensor_i2c_client = &vx6953_sensor_i2c_client,
-	.sensor_i2c_addr = 0x20,
-	.sensor_output_reg_addr = &vx6953_reg_addr,
-	.sensor_id_info = &vx6953_id_info,
-	.sensor_exp_gain_info = &vx6953_exp_gain_info,
-	.cam_mode = MSM_SENSOR_MODE_INVALID,
-	.msm_sensor_mutex = &vx6953_mut,
-	.sensor_i2c_driver = &vx6953_i2c_driver,
-	.sensor_v4l2_subdev_info = vx6953_subdev_info,
-	.sensor_v4l2_subdev_info_size = ARRAY_SIZE(vx6953_subdev_info),
-	.sensor_v4l2_subdev_ops = &vx6953_subdev_ops,
-	.func_tbl = &vx6953_func_tbl,
-	.clk_rate = MSM_SENSOR_MCLK_24HZ,
-};
-
-module_init(msm_sensor_init_module);
-MODULE_DESCRIPTION("Sensor VX6953 (BAYER 5M)");
-MODULE_LICENSE("GPL v2");
-
diff --git a/drivers/media/platform/msm/camera_v1/sensors/vx6953.h b/drivers/media/platform/msm/camera_v1/sensors/vx6953.h
deleted file mode 100644
index 2fc2a19..0000000
--- a/drivers/media/platform/msm/camera_v1/sensors/vx6953.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/* Copyright (c) 2010, The Linux Foundation. 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.
- *
- */
-
-#ifndef VX6953_H
-#define VX6953_H
-#include <linux/types.h>
-#include <mach/board.h>
-struct reg_struct_init {
-	uint8_t reg_0x0112;      /* 0x0112*/
-	uint8_t reg_0x0113;      /* 0x0113*/
-	uint8_t vt_pix_clk_div;  /* 0x0301*/
-	uint8_t pre_pll_clk_div; /* 0x0305*/
-	uint8_t pll_multiplier;  /* 0x0307*/
-	uint8_t op_pix_clk_div;  /* 0x0309*/
-	uint8_t reg_0x3030;      /*0x3030*/
-	uint8_t reg_0x0111;      /*0x0111*/
-	uint8_t reg_0x0b00;      /*0x0b00*/
-	uint8_t reg_0x3001;      /*0x3001*/
-	uint8_t reg_0x3004;      /*0x3004*/
-	uint8_t reg_0x3007;      /*0x3007*/
-	uint8_t reg_0x3016;      /*0x3016*/
-	uint8_t reg_0x301d;      /*0x301d*/
-	uint8_t reg_0x317e;      /*0x317E*/
-	uint8_t reg_0x317f;      /*0x317F*/
-	uint8_t reg_0x3400;      /*0x3400*/
-	uint8_t reg_0x0b06;      /*0x0b06*/
-	uint8_t reg_0x0b07;      /*0x0b07*/
-	uint8_t reg_0x0b08;      /*0x0b08*/
-	uint8_t reg_0x0b09;      /*0x0b09*/
-	uint8_t reg_0x0136;
-	uint8_t reg_0x0137;
-	/* Edof */
-	uint8_t reg_0x0b83;      /*0x0b83*/
-	uint8_t reg_0x0b84;      /*0x0b84*/
-	uint8_t reg_0x0b85;      /*0x0b85*/
-	uint8_t reg_0x0b88;      /*0x0b88*/
-	uint8_t reg_0x0b89;      /*0x0b89*/
-	uint8_t reg_0x0b8a;      /*0x0b8a*/
-	};
-struct reg_struct {
-	uint8_t coarse_integration_time_hi; /*REG_COARSE_INTEGRATION_TIME_HI*/
-	uint8_t coarse_integration_time_lo; /*REG_COARSE_INTEGRATION_TIME_LO*/
-	uint8_t analogue_gain_code_global;
-	uint8_t frame_length_lines_hi; /* 0x0340*/
-	uint8_t frame_length_lines_lo; /* 0x0341*/
-	uint8_t line_length_pck_hi;    /* 0x0342*/
-	uint8_t line_length_pck_lo;    /* 0x0343*/
-	uint8_t reg_0x3005;   /* 0x3005*/
-	uint8_t reg_0x3010;  /* 0x3010*/
-	uint8_t reg_0x3011;  /* 0x3011*/
-	uint8_t reg_0x301a;  /* 0x301a*/
-	uint8_t reg_0x3035;  /* 0x3035*/
-	uint8_t reg_0x3036;   /* 0x3036*/
-	uint8_t reg_0x3041;  /*0x3041*/
-	uint8_t reg_0x3042;  /*0x3042*/
-	uint8_t reg_0x3045;  /*0x3045*/
-	uint8_t reg_0x0b80;   /* 0x0b80*/
-	uint8_t reg_0x0900;   /*0x0900*/
-	uint8_t reg_0x0901;   /* 0x0901*/
-	uint8_t reg_0x0902;   /*0x0902*/
-	uint8_t reg_0x0383;   /*0x0383*/
-	uint8_t reg_0x0387;   /* 0x0387*/
-	uint8_t reg_0x034c;   /* 0x034c*/
-	uint8_t reg_0x034d;   /*0x034d*/
-	uint8_t reg_0x034e;   /* 0x034e*/
-	uint8_t reg_0x034f;   /* 0x034f*/
-	uint8_t reg_0x1716; /*0x1716*/
-	uint8_t reg_0x1717; /*0x1717*/
-	uint8_t reg_0x1718; /*0x1718*/
-	uint8_t reg_0x1719; /*0x1719*/
-	uint8_t reg_0x3210;/*0x3210*/
-	uint8_t reg_0x111; /*0x111*/
-	uint8_t reg_0x3410;  /*0x3410*/
-	uint8_t reg_0x3098;
-	uint8_t reg_0x309D;
-	uint8_t reg_0x0200;
-	uint8_t reg_0x0201;
-	};
-struct vx6953_i2c_reg_conf {
-	unsigned short waddr;
-	unsigned short wdata;
-};
-
-enum vx6953_test_mode_t {
-	TEST_OFF,
-	TEST_1,
-	TEST_2,
-	TEST_3
-};
-
-enum vx6953_resolution_t {
-	QTR_SIZE,
-	FULL_SIZE,
-	INVALID_SIZE
-};
-enum vx6953_setting {
-	RES_PREVIEW,
-	RES_CAPTURE
-};
-enum mt9p012_reg_update {
-	/* Sensor egisters that need to be updated during initialization */
-	REG_INIT,
-	/* Sensor egisters that needs periodic I2C writes */
-	UPDATE_PERIODIC,
-	/* All the sensor Registers will be updated */
-	UPDATE_ALL,
-	/* Not valid update */
-	UPDATE_INVALID
-};
-
-enum sensor_revision_t {
-	VX6953_STM5M0EDOF_CUT_1,
-	VX6953_STM5M0EDOF_CUT_2,
-	VX6953_STM5M0EDOF_CUT_3
-};
-enum edof_mode_t {
-	VX6953_EDOF_DISABLE,       /* 0x00 */
-	VX6953_EDOF_APPLICATION,   /* 0x01 */
-	VX6953_EDOF_ESTIMATION     /* 0x02 */
-};
-struct vx6953_reg {
-	const struct reg_struct_init  *reg_pat_init;
-	const struct reg_struct  *reg_pat;
-};
-#endif /* VX6953_H */
diff --git a/drivers/media/platform/msm/camera_v1/sensors/vx6953_reg.h b/drivers/media/platform/msm/camera_v1/sensors/vx6953_reg.h
deleted file mode 100644
index fe99be5..0000000
--- a/drivers/media/platform/msm/camera_v1/sensors/vx6953_reg.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/* Copyright (c) 2010, The Linux Foundation. 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.
- *
- */
-
-
-struct reg_struct_init vx6953_reg_init[1] = {
-	{
-		10,			/*REG = 0x0112 , 10 bit */
-		10,			/*REG = 0x0113*/
-		9,			/*REG = 0x0301 vt_pix_clk_div*/
-		4,		/*REG = 0x0305 pre_pll_clk_div*/
-		133,		/*REG = 0x0307 pll_multiplier*/
-		10,		/*REG = 0x0309 op_pix_clk_div*/
-		0x08,		/*REG = 0x3030*/
-		0x02,		/*REG = 0x0111*/
-		0x01,		/*REG = 0x0b00 ,lens shading off */
-		0x30,		/*REG = 0x3001*/
-		0x33,		/*REG = 0x3004*/
-		0x09,		/*REG = 0x3007*/
-		0x1F,		/*REG = 0x3016*/
-		0x03,		/*REG = 0x301d*/
-		0x11,		/*REG = 0x317E*/
-		0x09,		/*REG = 0x317F*/
-		0x38,		/*REG = 0x3400*/
-		0x00,		/*REG_0x0b06*/
-		0x80,		/*REG_0x0b07*/
-		0x01,		/*REG_0x0b08*/
-		0x4F,		/*REG_0x0b09*/
-		0x18,		/*REG_0x0136*/
-		0x00,		/*/REG_0x0137*/
-		0x20,		/*REG = 0x0b83*/
-		0x90,		/*REG = 0x0b84*/
-		0x20,		/*REG = 0x0b85*/
-		0x80,		/*REG = 0x0b88*/
-		0x00,		/*REG = 0x0b89*/
-		0x00,		/*REG = 0x0b8a*/
-	}
-};
-struct reg_struct vx6953_reg_pat[2] = {
-	{/* Preview */
-		0x03,	/*REG = 0x0202 coarse integration_time_hi*/
-		0xd0,	/*REG = 0x0203 coarse_integration_time_lo*/
-		0xc0,	/*REG = 0x0205 analogue_gain_code_global*/
-		0x03,	/*REG = 0x0340 frame_length_lines_hi*/
-		0xf0,	/*REG = 0x0341 frame_length_lines_lo*/
-		0x0b,	/*REG = 0x0342  line_length_pck_hi*/
-		0x74,	/*REG = 0x0343  line_length_pck_lo*/
-		0x03,	/*REG = 0x3005*/
-		0x00,	/*REG = 0x3010*/
-		0x01,	/*REG = 0x3011*/
-		0x6a,	/*REG = 0x301a*/
-		0x03,	/*REG = 0x3035*/
-		0x2c,	/*REG = 0x3036*/
-		0x00,	/*REG = 0x3041*/
-		0x24,	/*REG = 0x3042*/
-		0x81,	/*REG = 0x3045*/
-		0x02,	/*REG = 0x0b80 edof estimate*/
-		0x01,	/*REG = 0x0900*/
-		0x22,	/*REG = 0x0901*/
-		0x04,	/*REG = 0x0902*/
-		0x03,	/*REG = 0x0383*/
-		0x03,	/*REG = 0x0387*/
-		0x05,	/*REG = 0x034c*/
-		0x18,	/*REG = 0x034d*/
-		0x03,	/*REG = 0x034e*/
-		0xd4,	/*REG = 0x034f*/
-		0x02,	/*0x1716*/
-		0x04,	/*0x1717*/
-		0x08,	/*0x1718*/
-		0x2c,	/*0x1719*/
-		0x01,   /*0x3210*/
-		0x02,   /*0x111*/
-		0x01,   /*0x3410*/
-		0x01,   /*0x3098*/
-		0x05,   /*0x309D*/
-		0x02,
-		0x04,
-	},
-	{ /* Snapshot */
-		0x07,/*REG = 0x0202 coarse_integration_time_hi*/
-		0x00,/*REG = 0x0203 coarse_integration_time_lo*/
-		0xc0,/*REG = 0x0205 analogue_gain_code_global*/
-		0x07,/*REG = 0x0340 frame_length_lines_hi*/
-		0xd0,/*REG = 0x0341 frame_length_lines_lo*/
-		0x0b,/*REG = 0x0342 line_length_pck_hi*/
-		0x8c,/*REG = 0x0343 line_length_pck_lo*/
-		0x01,/*REG = 0x3005*/
-		0x00,/*REG = 0x3010*/
-		0x00,/*REG = 0x3011*/
-		0x55,/*REG = 0x301a*/
-		0x01,/*REG = 0x3035*/
-		0x23,/*REG = 0x3036*/
-		0x00,/*REG = 0x3041*/
-		0x24,/*REG = 0x3042*/
-		0xb7,/*REG = 0x3045*/
-		0x01,/*REG = 0x0b80 edof application*/
-		0x00,/*REG = 0x0900*/
-		0x00,/*REG = 0x0901*/
-		0x00,/*REG = 0x0902*/
-		0x01,/*REG = 0x0383*/
-		0x01,/*REG = 0x0387*/
-		0x0A,/*REG = 0x034c*/
-		0x30,/*REG = 0x034d*/
-		0x07,/*REG = 0x034e*/
-		0xA8,/*REG = 0x034f*/
-		0x02,/*0x1716*/
-		0x0d,/*0x1717*/
-		0x07,/*0x1718*/
-		0x7d,/*0x1719*/
-		0x01,/*0x3210*/
-		0x02,/*0x111*/
-		0x01,/*0x3410*/
-		0x01,/*0x3098*/
-		0x05, /*0x309D*/
-		0x02,
-		0x00,
-	}
-};
-
-
-
-struct vx6953_reg vx6953_regs = {
-	.reg_pat_init = &vx6953_reg_init[0],
-	.reg_pat = &vx6953_reg_pat[0],
-};
diff --git a/drivers/media/platform/msm/camera_v1/server/Makefile b/drivers/media/platform/msm/camera_v1/server/Makefile
deleted file mode 100644
index a64be59..0000000
--- a/drivers/media/platform/msm/camera_v1/server/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-GCC_VERSION      := $(shell $(CONFIG_SHELL) $(PWD)/scripts/gcc-version.sh $(CROSS_COMPILE)gcc)
-
-ifeq ($(CONFIG_MSM_CAMERA_V4L2),y)
-  EXTRA_CFLAGS += -Idrivers/media/platform/msm/camera_v1
-  EXTRA_CFLAGS += -Idrivers/media/platform/msm/camera_v1/io
-  EXTRA_CFLAGS += -Idrivers/media/platform/msm/camera_v1/csi
-  EXTRA_CFLAGS += -Idrivers/media/platform/msm/camera_v1/eeprom
-  EXTRA_CFLAGS += -Idrivers/media/platform/msm/camera_v1/sensors
-  EXTRA_CFLAGS += -Idrivers/media/platform/msm/camera_v1/actuators
-  obj-$(CONFIG_MSM_CAMERA)   += msm_cam_server.o
-endif
diff --git a/drivers/media/platform/msm/camera_v1/server/msm_cam_server.c b/drivers/media/platform/msm/camera_v1/server/msm_cam_server.c
deleted file mode 100644
index d9fba33..0000000
--- a/drivers/media/platform/msm/camera_v1/server/msm_cam_server.c
+++ /dev/null
@@ -1,3258 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/of.h>
-#include "msm_cam_server.h"
-#include "msm_csid.h"
-#include "msm_csic.h"
-#include "msm_csiphy.h"
-#include "msm_ispif.h"
-#include "msm_sensor.h"
-#include "msm_actuator.h"
-#include "msm_csi_register.h"
-
-#ifdef CONFIG_MSM_CAMERA_DEBUG
-#define D(fmt, args...) pr_debug("msm: " fmt, ##args)
-#else
-#define D(fmt, args...) do {} while (0)
-#endif
-
-static struct msm_cam_server_dev g_server_dev;
-static struct class *msm_class;
-static dev_t msm_devno;
-
-static long msm_server_send_v4l2_evt(void *evt);
-static void msm_cam_server_subdev_notify(struct v4l2_subdev *sd,
-	unsigned int notification, void *arg);
-
-void msm_queue_init(struct msm_device_queue *queue, const char *name)
-{
-	D("%s\n", __func__);
-	spin_lock_init(&queue->lock);
-	queue->len = 0;
-	queue->max = 0;
-	queue->name = name;
-	INIT_LIST_HEAD(&queue->list);
-	init_waitqueue_head(&queue->wait);
-}
-
-void msm_enqueue(struct msm_device_queue *queue,
-			struct list_head *entry)
-{
-	unsigned long flags;
-	spin_lock_irqsave(&queue->lock, flags);
-	queue->len++;
-	if (queue->len > queue->max) {
-		queue->max = queue->len;
-		pr_info("%s: queue %s new max is %d\n", __func__,
-			queue->name, queue->max);
-	}
-	list_add_tail(entry, &queue->list);
-	wake_up(&queue->wait);
-	D("%s: woke up %s\n", __func__, queue->name);
-	spin_unlock_irqrestore(&queue->lock, flags);
-}
-
-void msm_drain_eventq(struct msm_device_queue *queue)
-{
-	unsigned long flags;
-	struct msm_queue_cmd *qcmd;
-	struct msm_isp_event_ctrl *isp_event;
-	spin_lock_irqsave(&queue->lock, flags);
-	while (!list_empty(&queue->list)) {
-		qcmd = list_first_entry(&queue->list,
-			struct msm_queue_cmd, list_eventdata);
-		list_del_init(&qcmd->list_eventdata);
-		isp_event =
-			(struct msm_isp_event_ctrl *)
-			qcmd->command;
-		if (isp_event->isp_data.ctrl.value != NULL)
-			kfree(isp_event->isp_data.ctrl.value);
-		kfree(qcmd->command);
-		free_qcmd(qcmd);
-	}
-	spin_unlock_irqrestore(&queue->lock, flags);
-}
-
-int32_t msm_find_free_queue(void)
-{
-	int i;
-	for (i = 0; i < MAX_NUM_ACTIVE_CAMERA; i++) {
-		struct msm_cam_server_queue *queue;
-		queue = &g_server_dev.server_queue[i];
-		if (!queue->queue_active)
-			return i;
-	}
-	return -EINVAL;
-}
-
-void msm_setup_v4l2_event_queue(struct v4l2_fh *eventHandle,
-	struct video_device *pvdev)
-{
-	v4l2_fh_init(eventHandle, pvdev);
-	v4l2_fh_add(eventHandle);
-}
-
-void msm_destroy_v4l2_event_queue(struct v4l2_fh *eventHandle)
-{
-	v4l2_fh_del(eventHandle);
-	v4l2_fh_exit(eventHandle);
-}
-
-int msm_cam_server_config_interface_map(u32 extendedmode,
-	uint32_t mctl_handle, int vnode_id, int is_bayer_sensor)
-{
-	int i = 0;
-	int rc = 0;
-	int old_handle;
-	int interface;
-
-	if (vnode_id >= MAX_NUM_ACTIVE_CAMERA) {
-		pr_err("%s: invalid msm_dev node id = %d", __func__, vnode_id);
-		return -EINVAL;
-	}
-	D("%s: extendedmode = %d, vnode_id = %d, is_bayer_sensor = %d",
-		__func__, extendedmode, vnode_id, is_bayer_sensor);
-	switch (extendedmode) {
-	case MSM_V4L2_EXT_CAPTURE_MODE_RDI:
-		interface = RDI_0;
-		break;
-	case MSM_V4L2_EXT_CAPTURE_MODE_RDI1:
-		interface = RDI_1;
-		break;
-	case MSM_V4L2_EXT_CAPTURE_MODE_RDI2:
-		interface = RDI_2;
-		break;
-	default:
-		interface = PIX_0;
-		break;
-	}
-
-	for (i = 0; i < INTF_MAX; i++) {
-		if (g_server_dev.interface_map_table[i].interface ==
-							interface) {
-			if (is_bayer_sensor && interface == PIX_0) {
-				if (g_server_dev.
-					interface_map_table[i].mctl_handle &&
-					!g_server_dev.interface_map_table[i].
-						is_bayer_sensor) {
-					/* in simultaneous camera usecase
-					 * SoC does not use PIX interface */
-					g_server_dev.interface_map_table[i].
-						mctl_handle = 0;
-				}
-			}
-
-			if (!is_bayer_sensor && interface == PIX_0) {
-				if (g_server_dev.
-					interface_map_table[i].mctl_handle &&
-					g_server_dev.interface_map_table[i].
-						is_bayer_sensor) {
-					/* In case of simultaneous camera,
-					 * the YUV sensor could use PIX
-					 * interface to only queue the preview
-					 * or video buffers, but does not
-					 * expect any notifications directly.
-					 * (preview/video data is updated from
-					 * postprocessing in such scenario).
-					 * In such case, there is no need to
-					 * update the mctl_handle in the intf
-					 * map table, since the notification
-					 * will not be sent directly. */
-					break;
-				}
-			}
-
-			old_handle =
-				g_server_dev.interface_map_table[i].mctl_handle;
-			if (old_handle == 0) {
-				g_server_dev.interface_map_table[i].mctl_handle
-					= mctl_handle;
-				g_server_dev.interface_map_table[i].
-					is_bayer_sensor = is_bayer_sensor;
-				g_server_dev.interface_map_table[i].vnode_id
-					= vnode_id;
-			} else {
-				if (!g_server_dev.interface_map_table[i].
-					is_bayer_sensor &&
-					(extendedmode ==
-					MSM_V4L2_EXT_CAPTURE_MODE_PREVIEW ||
-					extendedmode ==
-					MSM_V4L2_EXT_CAPTURE_MODE_VIDEO ||
-					extendedmode ==
-					MSM_V4L2_EXT_CAPTURE_MODE_MAIN ||
-					extendedmode ==
-					MSM_V4L2_EXT_CAPTURE_MODE_THUMBNAIL)) {
-					D("%s: SoC sensor, image_mode = %d",
-					__func__, extendedmode);
-					break;
-				}
-				if (old_handle != mctl_handle) {
-					pr_err("%s: iface_map[%d] is set: %d\n",
-						__func__, i, old_handle);
-					rc = -EINVAL;
-				}
-			}
-			break;
-		}
-	}
-
-	if (i == INTF_MAX)
-		rc = -EINVAL;
-	return rc;
-}
-
-void msm_cam_server_clear_interface_map(uint32_t mctl_handle)
-{
-	int i;
-	for (i = 0; i < INTF_MAX; i++)
-		if (g_server_dev.interface_map_table[i].
-			mctl_handle == mctl_handle)
-			g_server_dev.interface_map_table[i].
-				mctl_handle = 0;
-}
-
-struct iommu_domain *msm_cam_server_get_domain()
-{
-	return g_server_dev.domain;
-}
-
-int msm_cam_server_get_domain_num()
-{
-	return g_server_dev.domain_num;
-}
-
-uint32_t msm_cam_server_get_mctl_handle(void)
-{
-	uint32_t i;
-	if ((g_server_dev.mctl_handle_cnt << 8) == 0)
-		g_server_dev.mctl_handle_cnt++;
-	for (i = 0; i < MAX_NUM_ACTIVE_CAMERA; i++) {
-		if (g_server_dev.mctl[i].handle == 0) {
-			g_server_dev.mctl[i].handle =
-				(++g_server_dev.mctl_handle_cnt) << 8 | i;
-			memset(&g_server_dev.mctl[i].mctl,
-				0, sizeof(g_server_dev.mctl[i].mctl));
-			return g_server_dev.mctl[i].handle;
-		}
-	}
-	return 0;
-}
-
-void msm_cam_server_free_mctl(uint32_t handle)
-{
-	uint32_t mctl_index;
-	mctl_index = handle & 0xff;
-	if ((mctl_index < MAX_NUM_ACTIVE_CAMERA) &&
-		(g_server_dev.mctl[mctl_index].handle == handle))
-		g_server_dev.mctl[mctl_index].handle = 0;
-	else
-		pr_err("%s: invalid free handle\n", __func__);
-}
-
-struct msm_cam_media_controller *msm_cam_server_get_mctl(uint32_t handle)
-{
-	uint32_t mctl_index;
-	mctl_index = handle & 0xff;
-	if ((mctl_index < MAX_NUM_ACTIVE_CAMERA) &&
-		(g_server_dev.mctl[mctl_index].handle == handle))
-		return &g_server_dev.mctl[mctl_index].mctl;
-	return NULL;
-}
-
-
-static void msm_cam_server_send_error_evt(
-		struct msm_cam_media_controller *pmctl, int evt_type)
-{
-	struct v4l2_event v4l2_ev;
-	v4l2_ev.id = 0;
-	v4l2_ev.type = evt_type;
-	ktime_get_ts(&v4l2_ev.timestamp);
-	v4l2_event_queue(pmctl->pcam_ptr->pvdev, &v4l2_ev);
-}
-
-static int msm_ctrl_cmd_done(void *arg)
-{
-	void __user *uptr;
-	struct msm_queue_cmd *qcmd;
-	struct msm_camera_v4l2_ioctl_t *ioctl_ptr = arg;
-	struct msm_ctrl_cmd *command;
-	D("%s\n", __func__);
-
-	command = kzalloc(sizeof(struct msm_ctrl_cmd), GFP_KERNEL);
-	if (!command) {
-		pr_err("%s Insufficient memory. return", __func__);
-		goto command_alloc_fail;
-	}
-
-	qcmd = kzalloc(sizeof(struct msm_queue_cmd), GFP_KERNEL);
-	if (!qcmd) {
-		pr_err("%s Insufficient memory. return", __func__);
-		goto qcmd_alloc_fail;
-	}
-
-	mutex_lock(&g_server_dev.server_queue_lock);
-
-	if (copy_from_user(command, (void __user *)ioctl_ptr->ioctl_ptr,
-					   sizeof(struct msm_ctrl_cmd))) {
-		pr_err("%s: copy_from_user failed, size=%d\n",
-			__func__, sizeof(struct msm_ctrl_cmd));
-		goto ctrl_cmd_done_error;
-	}
-
-	if (!g_server_dev.server_queue[command->queue_idx].queue_active) {
-		pr_err("%s: Invalid queue\n", __func__);
-		goto ctrl_cmd_done_error;
-	}
-
-	D("%s qid %d evtid %d %d\n", __func__, command->queue_idx,
-		command->evt_id,
-		g_server_dev.server_queue[command->queue_idx].evt_id);
-
-	if (command->evt_id !=
-		g_server_dev.server_queue[command->queue_idx].evt_id) {
-		pr_err("Invalid event id from userspace\n");
-		goto ctrl_cmd_done_error;
-	}
-
-	atomic_set(&qcmd->on_heap, 1);
-	uptr = command->value;
-	qcmd->command = command;
-
-	if (command->length > 0) {
-		command->value =
-			g_server_dev.server_queue[command->queue_idx].ctrl_data;
-		if (command->length > MAX_SERVER_PAYLOAD_LENGTH) {
-			pr_err("%s: user data %d is too big (max %d)\n",
-				__func__, command->length,
-				max_control_command_size);
-			goto ctrl_cmd_done_error;
-		}
-		if (copy_from_user(command->value, uptr, command->length)) {
-			pr_err("%s: copy_from_user failed, size=%d\n",
-				__func__, sizeof(struct msm_ctrl_cmd));
-			goto ctrl_cmd_done_error;
-		}
-	}
-	msm_enqueue(&g_server_dev.server_queue
-		[command->queue_idx].ctrl_q, &qcmd->list_control);
-	mutex_unlock(&g_server_dev.server_queue_lock);
-	return 0;
-
-ctrl_cmd_done_error:
-	mutex_unlock(&g_server_dev.server_queue_lock);
-	free_qcmd(qcmd);
-qcmd_alloc_fail:
-	kfree(command);
-command_alloc_fail:
-	return -EINVAL;
-}
-
-/* send control command to config and wait for results*/
-static int msm_server_control(struct msm_cam_server_dev *server_dev,
-				uint32_t id, struct msm_ctrl_cmd *out)
-{
-	int rc = 0;
-	uint8_t wait_count;
-	void *value;
-	struct msm_queue_cmd *rcmd;
-	struct msm_queue_cmd *event_qcmd;
-	struct msm_ctrl_cmd *ctrlcmd;
-	struct msm_device_queue *queue =
-		&server_dev->server_queue[out->queue_idx].ctrl_q;
-
-	struct v4l2_event v4l2_evt;
-	struct msm_isp_event_ctrl *isp_event;
-	void *ctrlcmd_data;
-
-	event_qcmd = kzalloc(sizeof(struct msm_queue_cmd), GFP_KERNEL);
-	if (!event_qcmd) {
-		pr_err("%s Insufficient memory. return", __func__);
-		rc = -ENOMEM;
-		goto event_qcmd_alloc_fail;
-	}
-
-	isp_event = kzalloc(sizeof(struct msm_isp_event_ctrl), GFP_KERNEL);
-	if (!isp_event) {
-		pr_err("%s Insufficient memory. return", __func__);
-		rc = -ENOMEM;
-		goto isp_event_alloc_fail;
-	}
-
-	D("%s\n", __func__);
-	mutex_lock(&server_dev->server_queue_lock);
-	if (++server_dev->server_evt_id == 0)
-		server_dev->server_evt_id++;
-
-	D("%s qid %d evtid %d\n", __func__, out->queue_idx,
-		server_dev->server_evt_id);
-	server_dev->server_queue[out->queue_idx].evt_id =
-		server_dev->server_evt_id;
-	v4l2_evt.type = V4L2_EVENT_PRIVATE_START + MSM_CAM_RESP_V4L2;
-	v4l2_evt.id = id;
-	v4l2_evt.u.data[0] = out->queue_idx;
-	/* setup event object to transfer the command; */
-	isp_event->resptype = MSM_CAM_RESP_V4L2;
-	isp_event->isp_data.ctrl = *out;
-	isp_event->isp_data.ctrl.evt_id = server_dev->server_evt_id;
-
-	if (out->value != NULL && out->length != 0) {
-		ctrlcmd_data = kzalloc(out->length, GFP_KERNEL);
-		if (!ctrlcmd_data) {
-			rc = -ENOMEM;
-			goto ctrlcmd_alloc_fail;
-		}
-		memcpy(ctrlcmd_data, out->value, out->length);
-		isp_event->isp_data.ctrl.value = ctrlcmd_data;
-	}
-
-	atomic_set(&event_qcmd->on_heap, 1);
-	event_qcmd->command = isp_event;
-
-	msm_enqueue(&server_dev->server_queue[out->queue_idx].eventData_q,
-				&event_qcmd->list_eventdata);
-
-	/* now send command to config thread in userspace,
-	 * and wait for results */
-	v4l2_event_queue(server_dev->server_command_queue.pvdev,
-					  &v4l2_evt);
-	D("%s v4l2_event_queue: type = 0x%x\n", __func__, v4l2_evt.type);
-	mutex_unlock(&server_dev->server_queue_lock);
-
-	/* wait for config return status */
-	D("Waiting for config status\n");
-	/* wait event may be interrupted by sugnal,
-	 * in this case -ERESTARTSYS is returned and retry is needed.
-	 * Now we only retry once. */
-	wait_count = 2;
-	do {
-		rc = wait_event_interruptible_timeout(queue->wait,
-			!list_empty_careful(&queue->list),
-			msecs_to_jiffies(out->timeout_ms));
-		wait_count--;
-		if (rc != -ERESTARTSYS)
-			break;
-		D("%s: wait_event interrupted by signal, remain_count = %d",
-			__func__, wait_count);
-	} while (wait_count > 0);
-	D("Waiting is over for config status\n");
-	if (list_empty_careful(&queue->list)) {
-		if (!rc)
-			rc = -ETIMEDOUT;
-		if (rc < 0) {
-			if (++server_dev->server_evt_id == 0)
-				server_dev->server_evt_id++;
-			pr_err("%s: wait_event error %d\n", __func__, rc);
-			return rc;
-		}
-	}
-
-	rcmd = msm_dequeue(queue, list_control);
-	BUG_ON(!rcmd);
-	D("%s Finished servicing ioctl\n", __func__);
-
-	ctrlcmd = (struct msm_ctrl_cmd *)(rcmd->command);
-	value = out->value;
-	if (ctrlcmd->length > 0 && value != NULL &&
-		ctrlcmd->length <= out->length)
-		memcpy(value, ctrlcmd->value, ctrlcmd->length);
-
-	memcpy(out, ctrlcmd, sizeof(struct msm_ctrl_cmd));
-	out->value = value;
-
-	kfree(ctrlcmd);
-	free_qcmd(rcmd);
-	D("%s: rc %d\n", __func__, rc);
-	/* rc is the time elapsed.
-	 * This means that the communication with the daemon itself was
-	 * successful(irrespective of the handling of the ctrlcmd).
-	 * So, just reset the rc to 0 to indicate success.
-	 * Its upto the caller to parse the ctrlcmd to check the status. We
-	 * dont need to parse it here. */
-	if (rc >= 0)
-		rc = 0;
-
-	return rc;
-
-ctrlcmd_alloc_fail:
-	kfree(isp_event);
-isp_event_alloc_fail:
-	kfree(event_qcmd);
-event_qcmd_alloc_fail:
-	return rc;
-}
-
-int msm_server_private_general(struct msm_cam_v4l2_device *pcam,
-		struct msm_camera_v4l2_ioctl_t *ioctl_ptr)
-{
-	struct msm_ctrl_cmd ctrlcmd;
-	void *temp_data = NULL;
-	int rc;
-	if (ioctl_ptr->len > 0) {
-		temp_data = kzalloc(ioctl_ptr->len, GFP_KERNEL);
-		if (!temp_data) {
-			pr_err("%s could not allocate memory\n", __func__);
-			rc = -ENOMEM;
-			goto end;
-		}
-		if (copy_from_user((void *)temp_data,
-			(void __user *)ioctl_ptr->ioctl_ptr,
-			ioctl_ptr->len)) {
-			ERR_COPY_FROM_USER();
-			rc = -EFAULT;
-			goto copy_from_user_failed;
-		}
-	}
-
-	mutex_lock(&pcam->vid_lock);
-	ctrlcmd.type = MSM_V4L2_PRIVATE_CMD;
-	ctrlcmd.length = ioctl_ptr->len;
-	ctrlcmd.value = temp_data;
-	ctrlcmd.timeout_ms = 1000;
-	ctrlcmd.status = ioctl_ptr->id;
-	ctrlcmd.vnode_id = pcam->vnode_id;
-	ctrlcmd.queue_idx = pcam->server_queue_idx;
-	ctrlcmd.config_ident = g_server_dev.config_info.config_dev_id[0];
-	/* send command to config thread in usersspace, and get return value */
-	rc = msm_server_control(&g_server_dev, 0, &ctrlcmd);
-	if (rc < 0)
-		pr_err("%s: send event failed\n", __func__);
-	else {
-		if (ioctl_ptr->len > 0) {
-			if (copy_to_user((void __user *)ioctl_ptr->ioctl_ptr,
-				(void *)temp_data,
-				ioctl_ptr->len)) {
-				ERR_COPY_TO_USER();
-				rc = -EFAULT;
-			}
-		}
-	}
-	mutex_unlock(&pcam->vid_lock);
-
-	kfree(temp_data);
-	return rc;
-copy_from_user_failed:
-	kfree(temp_data);
-end:
-return rc;
-}
-
-int msm_server_get_crop(struct msm_cam_v4l2_device *pcam,
-				int idx, struct v4l2_crop *crop)
-{
-	int rc = 0;
-	struct msm_ctrl_cmd ctrlcmd;
-
-	BUG_ON(crop == NULL);
-
-	ctrlcmd.type = MSM_V4L2_GET_CROP;
-	ctrlcmd.length = sizeof(struct v4l2_crop);
-	ctrlcmd.value = (void *)crop;
-	ctrlcmd.timeout_ms = 1000;
-	ctrlcmd.vnode_id = pcam->vnode_id;
-	ctrlcmd.queue_idx = pcam->server_queue_idx;
-	ctrlcmd.stream_type = pcam->dev_inst[idx]->image_mode;
-	ctrlcmd.config_ident = g_server_dev.config_info.config_dev_id[
-						pcam->server_queue_idx];
-
-	/* send command to config thread in userspace, and get return value */
-	rc = msm_server_control(&g_server_dev, 0, &ctrlcmd);
-	D("%s: rc = %d\n", __func__, rc);
-
-	return rc;
-}
-
-/*send open command to server*/
-int msm_send_open_server(struct msm_cam_v4l2_device *pcam)
-{
-	int rc = 0;
-	struct msm_ctrl_cmd ctrlcmd;
-	int idx = pcam->server_queue_idx;
-	D("%s qid %d\n", __func__, pcam->server_queue_idx);
-	ctrlcmd.type	   = MSM_V4L2_OPEN;
-	ctrlcmd.timeout_ms = 10000;
-	ctrlcmd.length = strnlen(
-		g_server_dev.config_info.config_dev_name[idx],
-		MAX_DEV_NAME_LEN)+1;
-	ctrlcmd.value = (char *)g_server_dev.config_info.config_dev_name[idx];
-	ctrlcmd.vnode_id = pcam->vnode_id;
-	ctrlcmd.queue_idx = pcam->server_queue_idx;
-	ctrlcmd.config_ident = g_server_dev.config_info.config_dev_id[idx];
-
-	/* send command to config thread in usersspace, and get return value */
-	rc = msm_server_control(&g_server_dev, 0, &ctrlcmd);
-
-	return rc;
-}
-
-int msm_send_close_server(struct msm_cam_v4l2_device *pcam)
-{
-	int rc = 0;
-	struct msm_ctrl_cmd ctrlcmd;
-	D("%s qid %d\n", __func__, pcam->server_queue_idx);
-	ctrlcmd.type	   = MSM_V4L2_CLOSE;
-	ctrlcmd.timeout_ms = 10000;
-	ctrlcmd.length	 = strnlen(g_server_dev.config_info.config_dev_name[
-				pcam->server_queue_idx], MAX_DEV_NAME_LEN)+1;
-	ctrlcmd.value    = (char *)g_server_dev.config_info.config_dev_name[
-				pcam->server_queue_idx];
-	ctrlcmd.vnode_id = pcam->vnode_id;
-	ctrlcmd.queue_idx = pcam->server_queue_idx;
-	ctrlcmd.config_ident = g_server_dev.config_info.config_dev_id[
-						pcam->server_queue_idx];
-
-	/* send command to config thread in usersspace, and get return value */
-	rc = msm_server_control(&g_server_dev, 0, &ctrlcmd);
-
-	return rc;
-}
-
-int msm_server_set_fmt(struct msm_cam_v4l2_device *pcam, int idx,
-				 struct v4l2_format *pfmt)
-{
-	int rc = 0;
-	int i = 0;
-	struct v4l2_pix_format *pix = &pfmt->fmt.pix;
-	struct msm_ctrl_cmd ctrlcmd;
-	struct img_plane_info plane_info;
-
-	plane_info.width = pix->width;
-	plane_info.height = pix->height;
-	plane_info.pixelformat = pix->pixelformat;
-	plane_info.buffer_type = pfmt->type;
-	plane_info.ext_mode = pcam->dev_inst[idx]->image_mode;
-	plane_info.num_planes = 1;
-	plane_info.inst_handle = pcam->dev_inst[idx]->inst_handle;
-	D("%s: %d, %d, 0x%x\n", __func__,
-		pfmt->fmt.pix.width, pfmt->fmt.pix.height,
-		pfmt->fmt.pix.pixelformat);
-
-	if (pfmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-		D("%s, Attention! Wrong buf-type %d\n", __func__, pfmt->type);
-
-	for (i = 0; i < pcam->num_fmts; i++)
-		if (pcam->usr_fmts[i].fourcc == pix->pixelformat)
-			break;
-	if (i == pcam->num_fmts) {
-		pr_err("%s: User requested pixelformat %x not supported\n",
-						__func__, pix->pixelformat);
-		return -EINVAL;
-	}
-
-	ctrlcmd.type       = MSM_V4L2_VID_CAP_TYPE;
-	ctrlcmd.length     = sizeof(struct img_plane_info);
-	ctrlcmd.value      = (void *)&plane_info;
-	ctrlcmd.timeout_ms = 10000;
-	ctrlcmd.vnode_id   = pcam->vnode_id;
-	ctrlcmd.queue_idx = pcam->server_queue_idx;
-	ctrlcmd.config_ident = g_server_dev.config_info.config_dev_id[0];
-
-	/* send command to config thread in usersspace, and get return value */
-	rc = msm_server_control(&g_server_dev, 0, &ctrlcmd);
-
-	if (rc >= 0) {
-		pcam->dev_inst[idx]->vid_fmt = *pfmt;
-		pcam->dev_inst[idx]->sensor_pxlcode
-					= pcam->usr_fmts[i].pxlcode;
-		D("%s:inst=0x%x,idx=%d,width=%d,heigth=%d\n",
-			 __func__, (u32)pcam->dev_inst[idx], idx,
-			 pcam->dev_inst[idx]->vid_fmt.fmt.pix.width,
-			 pcam->dev_inst[idx]->vid_fmt.fmt.pix.height);
-		pcam->dev_inst[idx]->plane_info = plane_info;
-	}
-
-	return rc;
-}
-
-int msm_server_set_fmt_mplane(struct msm_cam_v4l2_device *pcam, int idx,
-				 struct v4l2_format *pfmt)
-{
-	int rc = 0;
-	int i = 0;
-	struct v4l2_pix_format_mplane *pix_mp = &pfmt->fmt.pix_mp;
-	struct msm_ctrl_cmd ctrlcmd;
-	struct img_plane_info plane_info;
-
-	plane_info.width = pix_mp->width;
-	plane_info.height = pix_mp->height;
-	plane_info.pixelformat = pix_mp->pixelformat;
-	plane_info.buffer_type = pfmt->type;
-	plane_info.ext_mode = pcam->dev_inst[idx]->image_mode;
-	plane_info.num_planes = pix_mp->num_planes;
-	plane_info.inst_handle = pcam->dev_inst[idx]->inst_handle;
-
-	if (plane_info.num_planes <= 0 ||
-		plane_info.num_planes > VIDEO_MAX_PLANES) {
-		pr_err("%s Invalid number of planes set %d", __func__,
-				plane_info.num_planes);
-		return -EINVAL;
-	}
-	D("%s: %d, %d, 0x%x\n", __func__,
-		pfmt->fmt.pix_mp.width, pfmt->fmt.pix_mp.height,
-		pfmt->fmt.pix_mp.pixelformat);
-
-	if (pfmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
-		pr_err("%s, Attention! Wrong buf-type %d\n",
-			__func__, pfmt->type);
-		return -EINVAL;
-	}
-
-	for (i = 0; i < pcam->num_fmts; i++)
-		if (pcam->usr_fmts[i].fourcc == pix_mp->pixelformat)
-			break;
-	if (i == pcam->num_fmts) {
-		pr_err("%s: User requested pixelformat %x not supported\n",
-						__func__, pix_mp->pixelformat);
-		return -EINVAL;
-	}
-
-	ctrlcmd.type       = MSM_V4L2_VID_CAP_TYPE;
-	ctrlcmd.length     = sizeof(struct img_plane_info);
-	ctrlcmd.value      = (void *)&plane_info;
-	ctrlcmd.timeout_ms = 10000;
-	ctrlcmd.vnode_id   = pcam->vnode_id;
-	ctrlcmd.queue_idx = pcam->server_queue_idx;
-
-	/* send command to config thread in usersspace, and get return value */
-	rc = msm_server_control(&g_server_dev, 0, &ctrlcmd);
-	if (rc >= 0) {
-		pcam->dev_inst[idx]->vid_fmt = *pfmt;
-		pcam->dev_inst[idx]->sensor_pxlcode
-					= pcam->usr_fmts[i].pxlcode;
-		D("%s:inst=0x%x,idx=%d,width=%d,heigth=%d\n",
-			 __func__, (u32)pcam->dev_inst[idx], idx,
-			 pcam->dev_inst[idx]->vid_fmt.fmt.pix_mp.width,
-			 pcam->dev_inst[idx]->vid_fmt.fmt.pix_mp.height);
-		pcam->dev_inst[idx]->plane_info = plane_info;
-	}
-
-	return rc;
-}
-
-int msm_server_streamon(struct msm_cam_v4l2_device *pcam, int idx)
-{
-	int rc = 0;
-	struct msm_ctrl_cmd ctrlcmd;
-	D("%s\n", __func__);
-	ctrlcmd.type	   = MSM_V4L2_STREAM_ON;
-	ctrlcmd.timeout_ms = 10000;
-	ctrlcmd.length	 = 0;
-	ctrlcmd.value    = NULL;
-	ctrlcmd.stream_type = pcam->dev_inst[idx]->image_mode;
-	ctrlcmd.vnode_id = pcam->vnode_id;
-	ctrlcmd.queue_idx = pcam->server_queue_idx;
-	ctrlcmd.config_ident = g_server_dev.config_info.config_dev_id[0];
-
-
-	/* send command to config thread in usersspace, and get return value */
-	rc = msm_server_control(&g_server_dev, 0, &ctrlcmd);
-
-	return rc;
-}
-
-int msm_server_streamoff(struct msm_cam_v4l2_device *pcam, int idx)
-{
-	int rc = 0;
-	struct msm_ctrl_cmd ctrlcmd;
-
-	D("%s, pcam = 0x%x\n", __func__, (u32)pcam);
-	ctrlcmd.type        = MSM_V4L2_STREAM_OFF;
-	ctrlcmd.timeout_ms  = 10000;
-	ctrlcmd.length      = 0;
-	ctrlcmd.value       = NULL;
-	ctrlcmd.stream_type = pcam->dev_inst[idx]->image_mode;
-	ctrlcmd.vnode_id = pcam->vnode_id;
-	ctrlcmd.queue_idx = pcam->server_queue_idx;
-	ctrlcmd.config_ident = g_server_dev.config_info.config_dev_id[0];
-
-	/* send command to config thread in usersspace, and get return value */
-	rc = msm_server_control(&g_server_dev, 0, &ctrlcmd);
-
-	return rc;
-}
-
-int msm_server_proc_ctrl_cmd(struct msm_cam_v4l2_device *pcam,
-		struct msm_camera_v4l2_ioctl_t *ioctl_ptr, int is_set_cmd)
-{
-	int rc = 0;
-	struct msm_ctrl_cmd ctrlcmd, tmp_cmd, *cmd_ptr;
-	uint8_t *ctrl_data = NULL;
-	uint32_t cmd_len = sizeof(struct msm_ctrl_cmd);
-	uint32_t value_len;
-
-	if (copy_from_user(&tmp_cmd,
-		(void __user *)ioctl_ptr->ioctl_ptr, cmd_len)) {
-		pr_err("%s: copy_from_user failed.\n", __func__);
-		rc = -EINVAL;
-		goto end;
-	}
-	value_len = tmp_cmd.length;
-	ctrl_data = kzalloc(value_len+cmd_len, GFP_KERNEL);
-	if (!ctrl_data) {
-		pr_err("%s could not allocate memory\n", __func__);
-		rc = -ENOMEM;
-		goto end;
-	}
-
-	cmd_ptr = (struct msm_ctrl_cmd *) ctrl_data;
-	*cmd_ptr = tmp_cmd;
-	if (tmp_cmd.value && tmp_cmd.length > 0) {
-		cmd_ptr->value = (void *)(ctrl_data+cmd_len);
-		if (copy_from_user((void *)cmd_ptr->value,
-				   (void __user *)tmp_cmd.value,
-				   value_len)) {
-			pr_err("%s: copy_from_user failed.\n", __func__);
-			rc = -EINVAL;
-			goto end;
-		}
-	} else {
-		cmd_ptr->value = NULL;
-	}
-
-	D("%s: cmd type = %d, up1=0x%x, ulen1=%d, up2=0x%x, ulen2=%d\n",
-		__func__, tmp_cmd.type, (uint32_t)ioctl_ptr->ioctl_ptr, cmd_len,
-		(uint32_t)tmp_cmd.value, tmp_cmd.length);
-
-	ctrlcmd.type = MSM_V4L2_SET_CTRL_CMD;
-	ctrlcmd.length = cmd_len + value_len;
-	ctrlcmd.value = (void *)ctrl_data;
-	if (tmp_cmd.timeout_ms > 0)
-		ctrlcmd.timeout_ms = tmp_cmd.timeout_ms;
-	else
-		ctrlcmd.timeout_ms = 1000;
-	ctrlcmd.vnode_id = pcam->vnode_id;
-	ctrlcmd.queue_idx = pcam->server_queue_idx;
-	ctrlcmd.config_ident = g_server_dev.config_info.config_dev_id[0];
-	/* send command to config thread in usersspace, and get return value */
-	rc = msm_server_control(&g_server_dev, 0, &ctrlcmd);
-	D("%s: msm_server_control rc=%d\n", __func__, rc);
-	if (rc == 0) {
-		if (tmp_cmd.value && tmp_cmd.length > 0 &&
-			copy_to_user((void __user *)tmp_cmd.value,
-				(void *)(ctrl_data+cmd_len), tmp_cmd.length)) {
-			pr_err("%s: copy_to_user failed, size=%d\n",
-				__func__, tmp_cmd.length);
-			rc = -EINVAL;
-			goto end;
-		}
-		tmp_cmd.status = cmd_ptr->status = ctrlcmd.status;
-		if (copy_to_user((void __user *)ioctl_ptr->ioctl_ptr,
-			(void *)cmd_ptr, cmd_len)) {
-			pr_err("%s: copy_to_user failed in cpy, size=%d\n",
-				__func__, cmd_len);
-			rc = -EINVAL;
-			goto end;
-		}
-	}
-end:
-	D("%s: END, type = %d, vaddr = 0x%x, vlen = %d, status = %d, rc = %d\n",
-		__func__, tmp_cmd.type, (uint32_t)tmp_cmd.value,
-		tmp_cmd.length, tmp_cmd.status, rc);
-	kfree(ctrl_data);
-	ctrl_data = NULL;
-	return rc;
-}
-
-int msm_server_s_ctrl(struct msm_cam_v4l2_device *pcam,
-				 struct v4l2_control *ctrl)
-{
-	int rc = 0;
-	struct msm_ctrl_cmd ctrlcmd;
-	uint8_t ctrl_data[max_control_command_size];
-
-	WARN_ON(ctrl == NULL);
-	if (ctrl == NULL) {
-		pr_err("%s Invalid control\n", __func__);
-		return -EINVAL;
-	}
-
-	memset(ctrl_data, 0, sizeof(ctrl_data));
-
-	ctrlcmd.type = MSM_V4L2_SET_CTRL;
-	ctrlcmd.length = sizeof(struct v4l2_control);
-	ctrlcmd.value = (void *)ctrl_data;
-	memcpy(ctrlcmd.value, ctrl, ctrlcmd.length);
-	ctrlcmd.timeout_ms = 1000;
-	ctrlcmd.vnode_id = pcam->vnode_id;
-	ctrlcmd.queue_idx = pcam->server_queue_idx;
-	ctrlcmd.config_ident = g_server_dev.config_info.config_dev_id[0];
-
-	/* send command to config thread in usersspace, and get return value */
-	rc = msm_server_control(&g_server_dev, 0, &ctrlcmd);
-
-	return rc;
-}
-
-int msm_server_g_ctrl(struct msm_cam_v4l2_device *pcam,
-				 struct v4l2_control *ctrl)
-{
-	int rc = 0;
-	struct msm_ctrl_cmd ctrlcmd;
-	uint8_t ctrl_data[max_control_command_size];
-
-	WARN_ON(ctrl == NULL);
-	if (ctrl == NULL) {
-		pr_err("%s Invalid control\n", __func__);
-		return -EINVAL;
-	}
-
-	memset(ctrl_data, 0, sizeof(ctrl_data));
-
-	ctrlcmd.type = MSM_V4L2_GET_CTRL;
-	ctrlcmd.length = sizeof(struct v4l2_control);
-	ctrlcmd.value = (void *)ctrl_data;
-	memcpy(ctrlcmd.value, ctrl, ctrlcmd.length);
-	ctrlcmd.timeout_ms = 1000;
-	ctrlcmd.vnode_id = pcam->vnode_id;
-	ctrlcmd.queue_idx = pcam->server_queue_idx;
-	ctrlcmd.config_ident = g_server_dev.config_info.config_dev_id[0];
-
-	/* send command to config thread in usersspace, and get return value */
-	rc = msm_server_control(&g_server_dev, 0, &ctrlcmd);
-
-	ctrl->value = ((struct v4l2_control *)ctrlcmd.value)->value;
-
-	return rc;
-}
-
-int msm_server_q_ctrl(struct msm_cam_v4l2_device *pcam,
-			struct v4l2_queryctrl *queryctrl)
-{
-	int rc = 0;
-	struct msm_ctrl_cmd ctrlcmd;
-	uint8_t ctrl_data[max_control_command_size];
-
-	WARN_ON(queryctrl == NULL);
-	memset(ctrl_data, 0, sizeof(ctrl_data));
-
-	ctrlcmd.type = MSM_V4L2_QUERY_CTRL;
-	ctrlcmd.length = sizeof(struct v4l2_queryctrl);
-	ctrlcmd.value = (void *)ctrl_data;
-	memcpy(ctrlcmd.value, queryctrl, ctrlcmd.length);
-	ctrlcmd.timeout_ms = 1000;
-	ctrlcmd.vnode_id = pcam->vnode_id;
-	ctrlcmd.queue_idx = pcam->server_queue_idx;
-	ctrlcmd.config_ident = g_server_dev.config_info.config_dev_id[0];
-
-	/* send command to config thread in userspace, and get return value */
-	rc = msm_server_control(&g_server_dev, 0, &ctrlcmd);
-	D("%s: rc = %d\n", __func__, rc);
-
-	if (rc >= 0)
-		memcpy(queryctrl, ctrlcmd.value, sizeof(struct v4l2_queryctrl));
-
-	return rc;
-}
-
-int msm_server_get_fmt(struct msm_cam_v4l2_device *pcam,
-		 int idx, struct v4l2_format *pfmt)
-{
-	struct v4l2_pix_format *pix = &pfmt->fmt.pix;
-
-	pix->width        = pcam->dev_inst[idx]->vid_fmt.fmt.pix.width;
-	pix->height       = pcam->dev_inst[idx]->vid_fmt.fmt.pix.height;
-	pix->field        = pcam->dev_inst[idx]->vid_fmt.fmt.pix.field;
-	pix->pixelformat  = pcam->dev_inst[idx]->vid_fmt.fmt.pix.pixelformat;
-	pix->bytesperline = pcam->dev_inst[idx]->vid_fmt.fmt.pix.bytesperline;
-	pix->colorspace   = pcam->dev_inst[idx]->vid_fmt.fmt.pix.colorspace;
-	if (pix->bytesperline < 0)
-		return pix->bytesperline;
-
-	pix->sizeimage    = pix->height * pix->bytesperline;
-
-	return 0;
-}
-
-int msm_server_get_fmt_mplane(struct msm_cam_v4l2_device *pcam,
-		 int idx, struct v4l2_format *pfmt)
-{
-	*pfmt = pcam->dev_inst[idx]->vid_fmt;
-	return 0;
-}
-
-int msm_server_try_fmt(struct msm_cam_v4l2_device *pcam,
-				 struct v4l2_format *pfmt)
-{
-	int rc = 0;
-	int i = 0;
-	struct v4l2_pix_format *pix = &pfmt->fmt.pix;
-
-	D("%s: 0x%x\n", __func__, pix->pixelformat);
-	if (pfmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
-		pr_err("%s: pfmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE!\n",
-							__func__);
-		return -EINVAL;
-	}
-
-	/* check if the format is supported by this host-sensor combo */
-	for (i = 0; i < pcam->num_fmts; i++) {
-		D("%s: usr_fmts.fourcc: 0x%x\n", __func__,
-			pcam->usr_fmts[i].fourcc);
-		if (pcam->usr_fmts[i].fourcc == pix->pixelformat)
-			break;
-	}
-
-	if (i == pcam->num_fmts) {
-		pr_err("%s: Format %x not found\n", __func__, pix->pixelformat);
-		return -EINVAL;
-	}
-	return rc;
-}
-
-int msm_server_try_fmt_mplane(struct msm_cam_v4l2_device *pcam,
-				 struct v4l2_format *pfmt)
-{
-	int rc = 0;
-	int i = 0;
-	struct v4l2_pix_format_mplane *pix_mp = &pfmt->fmt.pix_mp;
-
-	D("%s: 0x%x\n", __func__, pix_mp->pixelformat);
-	if (pfmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
-		pr_err("%s: Incorrect format type %d ",
-			__func__, pfmt->type);
-		return -EINVAL;
-	}
-
-	/* check if the format is supported by this host-sensor combo */
-	for (i = 0; i < pcam->num_fmts; i++) {
-		D("%s: usr_fmts.fourcc: 0x%x\n", __func__,
-			pcam->usr_fmts[i].fourcc);
-		if (pcam->usr_fmts[i].fourcc == pix_mp->pixelformat)
-			break;
-	}
-
-	if (i == pcam->num_fmts) {
-		pr_err("%s: Format %x not found\n",
-			__func__, pix_mp->pixelformat);
-		return -EINVAL;
-	}
-	return rc;
-}
-
-int msm_server_v4l2_subscribe_event(struct v4l2_fh *fh,
-			struct v4l2_event_subscription *sub)
-{
-	int rc = 0;
-
-	D("%s: fh = 0x%x, type = 0x%x", __func__, (u32)fh, sub->type);
-	if (sub->type == V4L2_EVENT_ALL) {
-		/*sub->type = MSM_ISP_EVENT_START;*/
-		sub->type = V4L2_EVENT_PRIVATE_START + MSM_CAM_RESP_CTRL;
-		D("sub->type start = 0x%x\n", sub->type);
-		do {
-			rc = v4l2_event_subscribe(fh, sub, 30);

-			if (rc < 0) {
-				D("%s: failed for evtType = 0x%x, rc = %d\n",
-						__func__, sub->type, rc);
-			/* unsubscribe all events here and return */
-			sub->type = V4L2_EVENT_ALL;
-			v4l2_event_unsubscribe(fh, sub);
-			return rc;
-			} else
-				D("%s: subscribed evtType = 0x%x, rc = %d\n",
-						__func__, sub->type, rc);
-			sub->type++;
-			D("sub->type while = 0x%x\n", sub->type);
-		} while (sub->type !=
-			V4L2_EVENT_PRIVATE_START + MSM_SVR_RESP_MAX);
-	} else {
-		D("sub->type not V4L2_EVENT_ALL = 0x%x\n", sub->type);
-		rc = v4l2_event_subscribe(fh, sub, 30);

-		if (rc < 0)
-			D("%s: failed for evtType = 0x%x, rc = %d\n",
-						__func__, sub->type, rc);
-	}
-
-	D("%s: rc = %d\n", __func__, rc);
-	return rc;
-}
-
-int msm_server_v4l2_unsubscribe_event(struct v4l2_fh *fh,
-			struct v4l2_event_subscription *sub)
-{
-	int rc = 0;
-	struct v4l2_event ev;
-
-	D("%s: fh = 0x%x\n", __func__, (u32)fh);
-
-	/* Undequeue all pending events and free associated
-	 * msm_isp_event_ctrl  */
-	while (v4l2_event_pending(fh)) {
-		struct msm_isp_event_ctrl *isp_event;
-		rc = v4l2_event_dequeue(fh, &ev, O_NONBLOCK);
-		if (rc) {
-			pr_err("%s: v4l2_event_dequeue failed %d",
-						__func__, rc);
-			break;
-		}
-		isp_event = (struct msm_isp_event_ctrl *)
-			(*((uint32_t *)ev.u.data));
-		if (isp_event) {
-			if (isp_event->isp_data.isp_msg.len != 0 &&
-				isp_event->isp_data.isp_msg.data != NULL) {
-				kfree(isp_event->isp_data.isp_msg.data);
-				isp_event->isp_data.isp_msg.len = 0;
-				isp_event->isp_data.isp_msg.data = NULL;
-			}
-			kfree(isp_event);
-			*((uint32_t *)ev.u.data) = 0;
-		}
-	}
-
-	rc = v4l2_event_unsubscribe(fh, sub);
-	D("%s: rc = %d\n", __func__, rc);
-	return rc;
-}
-
-/* open an active camera session to manage the streaming logic */
-static int msm_cam_server_open_session(struct msm_cam_server_dev *ps,
-	struct msm_cam_v4l2_device *pcam)
-{
-	int rc = 0;
-
-	D("%s\n", __func__);
-
-	if (!ps || !pcam) {
-		pr_err("%s NULL pointer passed in!\n", __func__);
-		return rc;
-	}
-
-	/*
-	 * The number of camera instance should be controlled by the
-	 * resource manager. Currently supporting two active instances
-	 */
-	if (atomic_read(&ps->number_pcam_active) > 1) {
-		pr_err("%s Cannot have more than two active camera %d\n",
-			__func__, atomic_read(&ps->number_pcam_active));
-		return -EINVAL;
-	}
-	/* book keeping this camera session*/
-	ps->pcam_active[pcam->server_queue_idx] = pcam;
-	ps->opened_pcam[pcam->vnode_id] = pcam;
-	atomic_inc(&ps->number_pcam_active);
-
-	D("config pcam = 0x%p\n", pcam);
-
-	/* initialization the media controller module*/
-	msm_mctl_init(pcam);
-
-	return rc;
-}
-
-/* close an active camera session to server */
-static int msm_cam_server_close_session(struct msm_cam_server_dev *ps,
-	struct msm_cam_v4l2_device *pcam)
-{
-	int i;
-	int rc = 0;
-	D("%s\n", __func__);
-
-	if (!ps || !pcam) {
-		D("%s NULL pointer passed in!\n", __func__);
-		return rc;
-	}
-
-	atomic_dec(&ps->number_pcam_active);
-	ps->pcam_active[pcam->server_queue_idx] = NULL;
-	ps->opened_pcam[pcam->vnode_id] = NULL;
-	for (i = 0; i < INTF_MAX; i++) {
-		if (ps->interface_map_table[i].mctl_handle ==
-			pcam->mctl_handle)
-			ps->interface_map_table[i].mctl_handle = 0;
-	}
-	msm_mctl_free(pcam);
-	return rc;
-}
-
-static int map_imem_addresses(struct msm_cam_media_controller *mctl)
-{
-	int rc = 0;
-	rc = msm_iommu_map_contig_buffer(
-		(unsigned long)IMEM_Y_PING_OFFSET, mctl->domain_num, 0,
-		((IMEM_Y_SIZE + IMEM_CBCR_SIZE + 4095) & (~4095)),
-		SZ_4K, IOMMU_WRITE | IOMMU_READ,
-		(unsigned long *)&mctl->ping_imem_y);
-	mctl->ping_imem_cbcr = mctl->ping_imem_y + IMEM_Y_SIZE;
-	if (rc < 0) {
-		pr_err("%s: ping iommu mapping returned error %d\n",
-			__func__, rc);
-		mctl->ping_imem_y = 0;
-		mctl->ping_imem_cbcr = 0;
-	}
-	msm_iommu_map_contig_buffer(
-		(unsigned long)IMEM_Y_PONG_OFFSET, mctl->domain_num, 0,
-		((IMEM_Y_SIZE + IMEM_CBCR_SIZE + 4095) & (~4095)),
-		SZ_4K, IOMMU_WRITE | IOMMU_READ,
-		(unsigned long *)&mctl->pong_imem_y);
-	mctl->pong_imem_cbcr = mctl->pong_imem_y + IMEM_Y_SIZE;
-	if (rc < 0) {
-		pr_err("%s: pong iommu mapping returned error %d\n",
-			 __func__, rc);
-		mctl->pong_imem_y = 0;
-		mctl->pong_imem_cbcr = 0;
-	}
-	return rc;
-}
-
-static void unmap_imem_addresses(struct msm_cam_media_controller *mctl)
-{
-	msm_iommu_unmap_contig_buffer(mctl->ping_imem_y,
-		mctl->domain_num, 0,
-		((IMEM_Y_SIZE + IMEM_CBCR_SIZE + 4095) & (~4095)));
-	msm_iommu_unmap_contig_buffer(mctl->pong_imem_y,
-		mctl->domain_num, 0,
-		((IMEM_Y_SIZE + IMEM_CBCR_SIZE + 4095) & (~4095)));
-	mctl->ping_imem_y = 0;
-	mctl->ping_imem_cbcr = 0;
-	mctl->pong_imem_y = 0;
-	mctl->pong_imem_cbcr = 0;
-}
-
-static long msm_ioctl_server(struct file *file, void *fh,
-		bool valid_prio, int cmd, void *arg)
-{
-	int rc = -EINVAL;
-	struct msm_camera_v4l2_ioctl_t *ioctl_ptr = arg;
-	struct msm_camera_info temp_cam_info;
-	struct msm_cam_config_dev_info temp_config_info;
-	struct msm_mctl_node_info temp_mctl_info;
-	int i;
-
-	D("%s: cmd %d\n", __func__, _IOC_NR(cmd));
-
-	switch (cmd) {
-	case MSM_CAM_V4L2_IOCTL_GET_CAMERA_INFO:
-		if (copy_from_user(&temp_cam_info,
-				(void __user *)ioctl_ptr->ioctl_ptr,
-				sizeof(struct msm_camera_info))) {
-			pr_err("%s Copy from user failed for cmd %d",
-				__func__, cmd);
-			rc = -EINVAL;
-			return rc;
-		}
-		for (i = 0; i < g_server_dev.camera_info.num_cameras; i++) {
-			if (copy_to_user((void __user *)
-			temp_cam_info.video_dev_name[i],
-			g_server_dev.camera_info.video_dev_name[i],
-			strnlen(g_server_dev.camera_info.video_dev_name[i],
-				MAX_DEV_NAME_LEN))) {
-				pr_err("%s Copy to user failed for cmd %d",
-					__func__, cmd);
-				rc = -EINVAL;
-				return rc;
-			}
-			temp_cam_info.has_3d_support[i] =
-				g_server_dev.camera_info.has_3d_support[i];
-			temp_cam_info.is_internal_cam[i] =
-				g_server_dev.camera_info.is_internal_cam[i];
-			temp_cam_info.s_mount_angle[i] =
-				g_server_dev.camera_info.s_mount_angle[i];
-			temp_cam_info.sensor_type[i] =
-				g_server_dev.camera_info.sensor_type[i];
-
-		}
-		temp_cam_info.num_cameras =
-			g_server_dev.camera_info.num_cameras;
-		if (copy_to_user((void __user *)ioctl_ptr->ioctl_ptr,
-			&temp_cam_info,	sizeof(struct msm_camera_info))) {
-			pr_err("%s Copy to user failed for cmd %d",
-				__func__, cmd);
-			rc = -EINVAL;
-			return rc;
-		}
-		rc = 0;
-		break;
-
-	case MSM_CAM_V4L2_IOCTL_GET_CONFIG_INFO:
-		if (copy_from_user(&temp_config_info,
-			(void __user *)ioctl_ptr->ioctl_ptr,
-			sizeof(struct msm_cam_config_dev_info))) {
-			pr_err("%s Copy from user failed for cmd %d",
-				__func__, cmd);
-			rc = -EINVAL;
-			return rc;
-		}
-		for (i = 0;
-		 i < g_server_dev.config_info.num_config_nodes; i++) {
-			if (copy_to_user(
-			(void __user *)temp_config_info.config_dev_name[i],
-			g_server_dev.config_info.config_dev_name[i],
-			strnlen(g_server_dev.config_info.config_dev_name[i],
-				MAX_DEV_NAME_LEN))) {
-				pr_err("%s Copy to user failed for cmd %d",
-					__func__, cmd);
-				rc = -EINVAL;
-				return rc;
-			}
-		}
-		temp_config_info.num_config_nodes =
-			g_server_dev.config_info.num_config_nodes;
-		if (copy_to_user((void __user *)ioctl_ptr->ioctl_ptr,
-			&temp_config_info,
-			sizeof(struct msm_cam_config_dev_info))) {
-			pr_err("%s Copy to user failed for cmd %d",
-				__func__, cmd);
-			rc = -EINVAL;
-			return rc;
-		}
-		rc = 0;
-		break;
-	case MSM_CAM_V4L2_IOCTL_GET_MCTL_INFO:
-		if (copy_from_user(&temp_mctl_info,
-				(void __user *)ioctl_ptr->ioctl_ptr,
-				sizeof(struct msm_mctl_node_info))) {
-			pr_err("%s Copy from user failed for cmd %d",
-				__func__, cmd);
-			rc = -EINVAL;
-			return rc;
-		}
-		for (i = 0; i < g_server_dev.mctl_node_info.num_mctl_nodes;
-				i++) {
-			if (copy_to_user((void __user *)
-			temp_mctl_info.mctl_node_name[i],
-			g_server_dev.mctl_node_info.mctl_node_name[i], strnlen(
-			g_server_dev.mctl_node_info.mctl_node_name[i],
-			MAX_DEV_NAME_LEN))) {
-				pr_err("%s Copy to user failed for cmd %d",
-					__func__, cmd);
-				rc = -EINVAL;
-				return rc;
-			}
-		}
-		temp_mctl_info.num_mctl_nodes =
-			g_server_dev.mctl_node_info.num_mctl_nodes;
-		if (copy_to_user((void __user *)ioctl_ptr->ioctl_ptr,
-			&temp_mctl_info, sizeof(struct msm_mctl_node_info))) {
-			pr_err("%s Copy to user failed for cmd %d",
-				__func__, cmd);
-			rc = -EINVAL;
-			return rc;
-		}
-		rc = 0;
-	break;
-
-	case MSM_CAM_V4L2_IOCTL_CTRL_CMD_DONE:
-		D("%s: MSM_CAM_IOCTL_CTRL_CMD_DONE\n", __func__);
-		rc = msm_ctrl_cmd_done(arg);
-		break;
-
-	case MSM_CAM_V4L2_IOCTL_GET_EVENT_PAYLOAD: {
-		struct msm_queue_cmd *event_cmd;
-		struct msm_isp_event_ctrl u_isp_event;
-		struct msm_isp_event_ctrl *k_isp_event;
-		struct msm_device_queue *queue;
-		void __user *u_ctrl_value = NULL;
-		if (copy_from_user(&u_isp_event,
-			(void __user *)ioctl_ptr->ioctl_ptr,
-			sizeof(struct msm_isp_event_ctrl))) {
-			pr_err("%s Copy from user failed for cmd %d",
-				__func__, cmd);
-			rc = -EINVAL;
-			return rc;
-		}
-
-		mutex_lock(&g_server_dev.server_queue_lock);
-		if (!g_server_dev.server_queue
-			[u_isp_event.isp_data.ctrl.queue_idx].queue_active) {
-			pr_err("%s: Invalid queue\n", __func__);
-			mutex_unlock(&g_server_dev.server_queue_lock);
-			rc = -EINVAL;
-			return rc;
-		}
-		queue = &g_server_dev.server_queue
-			[u_isp_event.isp_data.ctrl.queue_idx].eventData_q;
-		event_cmd = msm_dequeue(queue, list_eventdata);
-		if (!event_cmd) {
-			pr_err("%s: No event payload\n", __func__);
-			rc = -EINVAL;
-			mutex_unlock(&g_server_dev.server_queue_lock);
-			return rc;
-		}
-		k_isp_event = (struct msm_isp_event_ctrl *)
-				event_cmd->command;
-		free_qcmd(event_cmd);
-
-		/* Save the pointer of the user allocated command buffer*/
-		u_ctrl_value = u_isp_event.isp_data.ctrl.value;
-
-		/* Copy the event structure into user struct*/
-		u_isp_event = *k_isp_event;
-
-		/* Restore the saved pointer of the user
-		 * allocated command buffer. */
-		u_isp_event.isp_data.ctrl.value = u_ctrl_value;
-
-		/* Copy the ctrl cmd, if present*/
-		if (k_isp_event->isp_data.ctrl.length > 0 &&
-			k_isp_event->isp_data.ctrl.value != NULL) {
-			void *k_ctrl_value =
-				k_isp_event->isp_data.ctrl.value;
-			if (copy_to_user(u_ctrl_value, k_ctrl_value,
-				 k_isp_event->isp_data.ctrl.length)) {
-				pr_err("%s Copy to user failed for cmd %d",
-					__func__, cmd);
-				kfree(k_isp_event->isp_data.ctrl.value);
-				kfree(k_isp_event);
-				rc = -EINVAL;
-				mutex_unlock(&g_server_dev.server_queue_lock);
-				break;
-			}
-			kfree(k_isp_event->isp_data.ctrl.value);
-		}
-		if (copy_to_user((void __user *)ioctl_ptr->ioctl_ptr,
-			&u_isp_event, sizeof(struct msm_isp_event_ctrl))) {
-			pr_err("%s Copy to user failed for cmd %d",
-				__func__, cmd);
-			kfree(k_isp_event);
-			mutex_unlock(&g_server_dev.server_queue_lock);
-			rc = -EINVAL;
-			return rc;
-		}
-		kfree(k_isp_event);
-		mutex_unlock(&g_server_dev.server_queue_lock);
-		rc = 0;
-		break;
-	}
-
-	case MSM_CAM_IOCTL_SEND_EVENT:
-		rc = msm_server_send_v4l2_evt(arg);
-		break;
-
-	default:
-		pr_err("%s: Invalid IOCTL = %d", __func__, cmd);
-		break;
-	}
-	return rc;
-}
-
-static int msm_open_server(struct file *fp)
-{
-	int rc = 0;
-	D("%s: open %s\n", __func__, fp->f_path.dentry->d_name.name);
-	mutex_lock(&g_server_dev.server_lock);
-	g_server_dev.use_count++;
-	if (g_server_dev.use_count == 1)
-		fp->private_data =
-			&g_server_dev.server_command_queue.eventHandle;
-	mutex_unlock(&g_server_dev.server_lock);
-	return rc;
-}
-
-static int msm_close_server(struct file *fp)
-{
-	struct v4l2_event_subscription sub;
-	D("%s\n", __func__);
-	mutex_lock(&g_server_dev.server_lock);
-	if (g_server_dev.use_count > 0)
-		g_server_dev.use_count--;
-	mutex_unlock(&g_server_dev.server_lock);
-
-	if (g_server_dev.use_count == 0) {
-		int i;
-		mutex_lock(&g_server_dev.server_lock);
-		for (i = 0; i < MAX_NUM_ACTIVE_CAMERA; i++) {
-			if (g_server_dev.pcam_active[i]) {
-				struct msm_cam_media_controller *pmctl = NULL;
-
-				pmctl = msm_cam_server_get_mctl(
-				g_server_dev.pcam_active[i]->mctl_handle);
-				if (pmctl && pmctl->mctl_release) {
-					pmctl->mctl_release(pmctl);
-					/*so that it isn't closed again*/
-					pmctl->mctl_release = NULL;
-				}
-				if (pmctl)
-					msm_cam_server_send_error_evt(pmctl,
-						V4L2_EVENT_PRIVATE_START +
-						MSM_CAM_APP_NOTIFY_ERROR_EVENT);
-			}
-		}
-		sub.type = V4L2_EVENT_ALL;
-		v4l2_event_unsubscribe(
-			&g_server_dev.server_command_queue.eventHandle, &sub);
-		mutex_unlock(&g_server_dev.server_lock);
-	}
-	return 0;
-}
-
-static unsigned int msm_poll_server(struct file *fp,
-					struct poll_table_struct *wait)
-{
-	int rc = 0;
-
-	D("%s\n", __func__);
-	poll_wait(fp,
-		 &g_server_dev.server_command_queue.eventHandle.wait,

-		 wait);
-	if (v4l2_event_pending(&g_server_dev.server_command_queue.eventHandle))
-		rc |= POLLPRI;
-
-	return rc;
-}
-
-int msm_server_get_usecount(void)
-{
-	return g_server_dev.use_count;
-}
-
-int msm_server_update_sensor_info(struct msm_cam_v4l2_device *pcam,
-	struct msm_camera_sensor_info *sdata)
-{
-	int rc = 0;
-
-	if (!pcam || !sdata) {
-		pr_err("%s Input data is null ", __func__);
-		return -EINVAL;
-	}
-
-	g_server_dev.camera_info.video_dev_name
-	[g_server_dev.camera_info.num_cameras]
-	= video_device_node_name(pcam->pvdev);
-	D("%s Connected video device %s\n", __func__,
-		g_server_dev.camera_info.video_dev_name
-		[g_server_dev.camera_info.num_cameras]);
-
-	g_server_dev.camera_info.s_mount_angle
-	[g_server_dev.camera_info.num_cameras]
-	= sdata->sensor_platform_info->mount_angle;
-
-	g_server_dev.camera_info.is_internal_cam
-	[g_server_dev.camera_info.num_cameras]
-	= sdata->camera_type;
-
-	g_server_dev.mctl_node_info.mctl_node_name
-	[g_server_dev.mctl_node_info.num_mctl_nodes]
-	= video_device_node_name(pcam->mctl_node.pvdev);
-
-	pr_info("%s mctl_node_name[%d] = %s\n", __func__,
-		g_server_dev.mctl_node_info.num_mctl_nodes,
-		g_server_dev.mctl_node_info.mctl_node_name
-		[g_server_dev.mctl_node_info.num_mctl_nodes]);
-
-	/*Temporary solution to store info in media device structure
-	  until we can expand media device structure to support more
-	  device info*/
-	snprintf(pcam->media_dev.serial,
-			sizeof(pcam->media_dev.serial),
-			"%s-%d-%d", QCAMERA_NAME,
-			sdata->sensor_platform_info->mount_angle,
-			sdata->camera_type);
-
-	g_server_dev.camera_info.num_cameras++;
-	g_server_dev.mctl_node_info.num_mctl_nodes++;
-
-	D("%s done, rc = %d\n", __func__, rc);
-	D("%s number of sensors connected is %d\n", __func__,
-		g_server_dev.camera_info.num_cameras);
-
-	return rc;
-}
-
-int msm_server_begin_session(struct msm_cam_v4l2_device *pcam,
-	int server_q_idx)
-{
-	int rc = -EINVAL, ges_evt;
-	struct msm_cam_server_queue *queue;
-	struct msm_cam_media_controller *pmctl;
-
-	if (!pcam) {
-		pr_err("%s pcam passed is null ", __func__);
-		return rc;
-	}
-
-	ges_evt = MSM_V4L2_GES_CAM_OPEN;
-	D("%s send gesture evt\n", __func__);
-	msm_cam_server_subdev_notify(g_server_dev.gesture_device,
-		NOTIFY_GESTURE_CAM_EVT, &ges_evt);
-
-	pcam->server_queue_idx = server_q_idx;
-	queue = &g_server_dev.server_queue[server_q_idx];
-	queue->ctrl_data = kzalloc(sizeof(uint8_t) *
-			MAX_SERVER_PAYLOAD_LENGTH, GFP_KERNEL);
-	if (queue->ctrl_data == NULL) {
-		pr_err("%s: Could not allocate memory\n", __func__);
-		rc = -ENOMEM;
-		goto error;
-	}
-	msm_queue_init(&queue->ctrl_q, "control");
-	msm_queue_init(&queue->eventData_q, "eventdata");
-	queue->queue_active = 1;
-	rc = msm_cam_server_open_session(&g_server_dev, pcam);
-	if (rc < 0) {
-		pr_err("%s: cam_server_open_session failed %d\n",
-			__func__, rc);
-		goto error;
-	}
-
-	pmctl = msm_cam_server_get_mctl(pcam->mctl_handle);
-	if (!pmctl) {
-		pr_err("%s: invalid mctl controller", __func__);
-		goto error;
-	}
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-		pmctl->domain = msm_cam_server_get_domain();
-		pmctl->domain_num = msm_cam_server_get_domain_num();
-#endif
-	rc = map_imem_addresses(pmctl);
-	if (rc < 0) {
-		pr_err("%sFailed to map imem addresses %d\n", __func__, rc);
-		goto error;
-	}
-
-	return rc;
-error:
-	ges_evt = MSM_V4L2_GES_CAM_CLOSE;
-	msm_cam_server_subdev_notify(g_server_dev.gesture_device,
-		NOTIFY_GESTURE_CAM_EVT, &ges_evt);
-
-	queue->queue_active = 0;
-	msm_drain_eventq(&queue->eventData_q);
-	msm_queue_drain(&queue->ctrl_q, list_control);
-	kfree(queue->ctrl_data);
-	queue->ctrl_data = NULL;
-	queue = NULL;
-	return rc;
-}
-
-int msm_server_end_session(struct msm_cam_v4l2_device *pcam)
-{
-	int rc = -EINVAL, ges_evt;
-	struct msm_cam_server_queue *queue;
-	struct msm_cam_media_controller *pmctl;
-
-	mutex_lock(&g_server_dev.server_queue_lock);
-	queue = &g_server_dev.server_queue[pcam->server_queue_idx];
-	queue->queue_active = 0;
-	kfree(queue->ctrl_data);
-	queue->ctrl_data = NULL;
-	msm_queue_drain(&queue->ctrl_q, list_control);
-	msm_drain_eventq(&queue->eventData_q);
-	mutex_unlock(&g_server_dev.server_queue_lock);
-
-	pmctl = msm_cam_server_get_mctl(pcam->mctl_handle);
-	if (!pmctl) {
-		pr_err("%s: invalid mctl controller", __func__);
-		return -EINVAL;
-	}
-	unmap_imem_addresses(pmctl);
-
-	rc = msm_cam_server_close_session(&g_server_dev, pcam);
-	if (rc < 0)
-		pr_err("msm_cam_server_close_session fails %d\n", rc);
-
-	ges_evt = MSM_V4L2_GES_CAM_CLOSE;
-	msm_cam_server_subdev_notify(g_server_dev.gesture_device,
-			NOTIFY_GESTURE_CAM_EVT, &ges_evt);
-
-	return rc;
-}
-
-/* Init a config node for ISP control,
- * which will create a config device (/dev/config0/ and plug in
- * ISP's operation "v4l2_ioctl_ops*"
- */
-static const struct v4l2_file_operations msm_fops_server = {
-	.owner = THIS_MODULE,
-	.open  = msm_open_server,
-	.poll  = msm_poll_server,
-	.unlocked_ioctl = video_ioctl2,
-	.release = msm_close_server,
-};
-
-static const struct v4l2_ioctl_ops msm_ioctl_ops_server = {
-	.vidioc_subscribe_event = msm_server_v4l2_subscribe_event,
-	.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
-	.vidioc_default = msm_ioctl_server,
-};
-
-static uint32_t msm_camera_server_find_mctl(
-		unsigned int notification, void *arg)
-{
-	int i;
-	uint32_t interface;
-	switch (notification) {
-	case NOTIFY_ISP_MSG_EVT:
-		if (((struct isp_msg_event *)arg)->msg_id ==
-			MSG_ID_RDI0_UPDATE_ACK)
-			interface = RDI_0;
-		else if (((struct isp_msg_event *)arg)->msg_id ==
-			MSG_ID_RDI1_UPDATE_ACK)
-			interface = RDI_1;
-		else
-			interface = PIX_0;
-		break;
-	case NOTIFY_VFE_MSG_OUT:
-		if (((struct isp_msg_output *)arg)->output_id ==
-					MSG_ID_OUTPUT_TERTIARY1)
-			interface = RDI_0;
-		else if (((struct isp_msg_output *)arg)->output_id ==
-						MSG_ID_OUTPUT_TERTIARY2)
-			interface = RDI_1;
-		else
-			interface = PIX_0;
-		break;
-	case NOTIFY_VFE_BUF_EVT: {
-		struct msm_vfe_resp *rp;
-		struct msm_frame_info *frame_info;
-		uint8_t vnode_id;
-
-		rp = (struct msm_vfe_resp *)arg;
-		frame_info = rp->evt_msg.data;
-		if (!frame_info) {
-			interface = PIX_0;
-			break;
-		}
-		if (frame_info->inst_handle) {
-			vnode_id = GET_DEVID_MODE(frame_info->inst_handle);
-			if (vnode_id < MAX_NUM_ACTIVE_CAMERA &&
-				g_server_dev.opened_pcam[vnode_id]) {
-				return g_server_dev.
-					opened_pcam[vnode_id]->mctl_handle;
-			} else {
-				pr_err("%s: cannot find mctl handle", __func__);
-				return 0;
-			}
-		} else {
-			if (frame_info->path == VFE_MSG_OUTPUT_TERTIARY1)
-				interface = RDI_0;
-			else if (frame_info->path == VFE_MSG_OUTPUT_TERTIARY2)
-				interface = RDI_1;
-			else
-				interface = PIX_0;
-		}
-		}
-		break;
-	case NOTIFY_AXI_RDI_SOF_COUNT: {
-		struct rdi_count_msg *msg = (struct rdi_count_msg *)arg;
-		interface = msg->rdi_interface;
-		}
-		break;
-	case NOTIFY_VFE_MSG_STATS:
-	case NOTIFY_VFE_MSG_COMP_STATS:
-	case NOTIFY_VFE_CAMIF_ERROR:
-	default:
-		interface = PIX_0;
-		break;
-	}
-	for (i = 0; i < INTF_MAX; i++) {
-		if (interface == g_server_dev.interface_map_table[i].interface)
-			break;
-	}
-	if (i == INTF_MAX) {
-		pr_err("%s: Cannot find valid interface map\n", __func__);
-		return -EINVAL;
-	} else
-		return g_server_dev.interface_map_table[i].mctl_handle;
-}
-
-static void msm_cam_server_subdev_notify(struct v4l2_subdev *sd,
-				unsigned int notification, void *arg)
-{
-	int rc = -EINVAL;
-	uint32_t mctl_handle = 0;
-	struct msm_cam_media_controller *p_mctl = NULL;
-	int is_gesture_evt =
-		(notification == NOTIFY_GESTURE_EVT)
-		|| (notification == NOTIFY_GESTURE_CAM_EVT);
-
-	if (!is_gesture_evt) {
-		mctl_handle = msm_camera_server_find_mctl(notification, arg);
-		if (mctl_handle < 0) {
-			pr_err("%s: Couldn't find mctl instance!\n", __func__);
-			return;
-		}
-	}
-	switch (notification) {
-	case NOTIFY_ISP_MSG_EVT:
-	case NOTIFY_VFE_MSG_OUT:
-	case NOTIFY_VFE_PIX_SOF_COUNT:
-	case NOTIFY_VFE_MSG_STATS:
-	case NOTIFY_VFE_MSG_COMP_STATS:
-	case NOTIFY_VFE_BUF_EVT:
-		p_mctl = msm_cam_server_get_mctl(mctl_handle);
-		if (p_mctl && p_mctl->isp_notify && p_mctl->vfe_sdev)
-			rc = p_mctl->isp_notify(p_mctl,
-				p_mctl->vfe_sdev, notification, arg);
-		break;
-	case NOTIFY_VFE_IRQ:{
-		struct msm_vfe_cfg_cmd cfg_cmd;
-		struct msm_camvfe_params vfe_params;
-		cfg_cmd.cmd_type = CMD_VFE_PROCESS_IRQ;
-		vfe_params.vfe_cfg = &cfg_cmd;
-		vfe_params.data = arg;
-		rc = v4l2_subdev_call(sd,
-			core, ioctl, 0, &vfe_params);
-	}
-		break;
-	case NOTIFY_AXI_IRQ:
-		rc = v4l2_subdev_call(sd, core, ioctl, VIDIOC_MSM_AXI_IRQ, arg);
-		break;
-	case NOTIFY_AXI_RDI_SOF_COUNT:
-		p_mctl = msm_cam_server_get_mctl(mctl_handle);
-		if (p_mctl && p_mctl->axi_sdev)
-			rc = v4l2_subdev_call(p_mctl->axi_sdev, core, ioctl,
-				VIDIOC_MSM_AXI_RDI_COUNT_UPDATE, arg);
-		break;
-	case NOTIFY_PCLK_CHANGE:
-		p_mctl = v4l2_get_subdev_hostdata(sd);
-		if (p_mctl) {
-			if (p_mctl->axi_sdev)
-				rc = v4l2_subdev_call(p_mctl->axi_sdev, video,
-				s_crystal_freq, *(uint32_t *)arg, 0);
-			else
-				rc = v4l2_subdev_call(p_mctl->vfe_sdev, video,
-				s_crystal_freq, *(uint32_t *)arg, 0);
-		}
-		break;
-	case NOTIFY_GESTURE_EVT:
-		rc = v4l2_subdev_call(g_server_dev.gesture_device,
-			core, ioctl, VIDIOC_MSM_GESTURE_EVT, arg);
-		break;
-	case NOTIFY_GESTURE_CAM_EVT:
-		rc = v4l2_subdev_call(g_server_dev.gesture_device,
-			core, ioctl, VIDIOC_MSM_GESTURE_CAM_EVT, arg);
-		break;
-	case NOTIFY_VFE_CAMIF_ERROR: {
-		p_mctl = msm_cam_server_get_mctl(mctl_handle);
-		if (p_mctl)
-			msm_cam_server_send_error_evt(p_mctl,
-				V4L2_EVENT_PRIVATE_START +
-				MSM_CAM_APP_NOTIFY_ERROR_EVENT);
-		break;
-	}
-	default:
-		break;
-	}
-
-	return;
-}
-
-void msm_cam_release_subdev_node(struct video_device *vdev)
-{
-	struct v4l2_subdev *sd = video_get_drvdata(vdev);
-	sd->devnode = NULL;
-	kfree(vdev);
-}
-
-/* Helper function to get the irq_idx corresponding
- * to the irq_num. */
-int get_irq_idx_from_irq_num(int irq_num)
-{
-	int i;
-	for (i = 0; i < CAMERA_SS_IRQ_MAX; i++)
-		if (irq_num == g_server_dev.hw_irqmap[i].irq_num)
-			return g_server_dev.hw_irqmap[i].irq_idx;
-
-	return -EINVAL;
-}
-
-static struct v4l2_subdev  *msm_cam_find_subdev_node(
-	struct v4l2_subdev **sd_list, u32 revision_num)
-{
-	int i = 0;
-	for (i = 0; sd_list[i] != NULL; i++) {
-		if (sd_list[i]->entity.revision == revision_num) {
-			return sd_list[i];
-			break;
-		}
-	}
-	return NULL;
-}
-
-int msm_mctl_find_sensor_subdevs(struct msm_cam_media_controller *p_mctl,
-	uint8_t csiphy_core_index, uint8_t csid_core_index)
-{
-	int rc = -ENODEV;
-
-	v4l2_set_subdev_hostdata(p_mctl->sensor_sdev, p_mctl);
-
-	rc = msm_csi_register_subdevs(p_mctl, csiphy_core_index,
-		csid_core_index, &g_server_dev);
-	if (rc < 0)
-		pr_err("%s: Could not find sensor subdevs\n", __func__);
-
-	return rc;
-}
-
-int msm_mctl_find_flash_subdev(struct msm_cam_media_controller *p_mctl,
-	uint8_t index)
-{
-	if (index < MAX_NUM_FLASH_DEV)
-		p_mctl->flash_sdev = g_server_dev.flash_device[index];
-	return 0;
-}
-
-static irqreturn_t msm_camera_server_parse_irq(int irq_num, void *data)
-{
-	unsigned long flags;
-	int irq_idx, i, rc;
-	u32 status = 0;
-	struct intr_table_entry *ind_irq_tbl;
-	struct intr_table_entry *comp_irq_tbl;
-	bool subdev_handled = 0;
-
-	irq_idx = get_irq_idx_from_irq_num(irq_num);
-	if (irq_idx < 0) {
-		pr_err("server_parse_irq: no clients for irq #%d. returning ",
-			irq_num);
-		return IRQ_HANDLED;
-	}
-
-	spin_lock_irqsave(&g_server_dev.intr_table_lock, flags);
-	ind_irq_tbl = &g_server_dev.irq_lkup_table.ind_intr_tbl[0];
-	comp_irq_tbl = &g_server_dev.irq_lkup_table.comp_intr_tbl[0];
-	if (ind_irq_tbl[irq_idx].is_composite) {
-		for (i = 0; i < comp_irq_tbl[irq_idx].num_hwcore; i++) {
-			if (comp_irq_tbl[irq_idx].subdev_list[i]) {
-				rc = v4l2_subdev_call(
-					comp_irq_tbl[irq_idx].subdev_list[i],
-					core, interrupt_service_routine,
-					status, &subdev_handled);
-				if ((rc < 0) || !subdev_handled) {
-					pr_err("server_parse_irq:Error\n"
-						"handling irq %d rc = %d",
-						irq_num, rc);
-					/* Dispatch the irq to the remaining
-					 * subdevs in the list. */
-					continue;
-				}
-			}
-		}
-	} else {
-		rc = v4l2_subdev_call(ind_irq_tbl[irq_idx].subdev_list[0],
-			core, interrupt_service_routine,
-			status, &subdev_handled);
-		if ((rc < 0) || !subdev_handled) {
-			pr_err("server_parse_irq: Error handling irq %d rc = %d",
-				irq_num, rc);
-			spin_unlock_irqrestore(&g_server_dev.intr_table_lock,
-				flags);
-			return IRQ_HANDLED;
-		}
-	}
-	spin_unlock_irqrestore(&g_server_dev.intr_table_lock, flags);
-	return IRQ_HANDLED;
-}
-
-/* Helper function to get the irq_idx corresponding
- * to the camera hwcore. This function should _only_
- * be invoked when the IRQ Router is configured
- * non-composite mode. */
-int get_irq_idx_from_camhw_idx(int cam_hw_idx)
-{
-	int i;
-	for (i = 0; i < MSM_CAM_HW_MAX; i++)
-		if (cam_hw_idx == g_server_dev.hw_irqmap[i].cam_hw_idx)
-			return g_server_dev.hw_irqmap[i].irq_idx;
-
-	return -EINVAL;
-}
-
-static inline void update_compirq_subdev_info(
-	struct intr_table_entry *irq_entry,
-	uint32_t cam_hw_mask, uint8_t cam_hw_id,
-	int *num_hwcore)
-{
-	if (cam_hw_mask & (0x1 << cam_hw_id)) {
-		/* If the mask has been set for this cam hwcore
-		 * update the subdev ptr......*/
-		irq_entry->subdev_list[cam_hw_id] =
-			g_server_dev.subdev_table[cam_hw_id];
-		(*num_hwcore)++;
-	} else {
-		/*....else, just clear it, so that the irq will
-		 * not be dispatched to this hw. */
-		irq_entry->subdev_list[cam_hw_id] = NULL;
-	}
-}
-
-static int msm_server_update_composite_irq_info(
-	struct intr_table_entry *irq_req)
-{
-	int num_hwcore = 0, rc = 0;
-	struct intr_table_entry *comp_irq_tbl =
-		&g_server_dev.irq_lkup_table.comp_intr_tbl[0];
-
-	comp_irq_tbl[irq_req->irq_idx].is_composite = 1;
-	comp_irq_tbl[irq_req->irq_idx].irq_trigger_type =
-		irq_req->irq_trigger_type;
-	comp_irq_tbl[irq_req->irq_idx].num_hwcore = irq_req->num_hwcore;
-
-	update_compirq_subdev_info(&comp_irq_tbl[irq_req->irq_idx],
-		irq_req->cam_hw_mask, MSM_CAM_HW_MICRO, &num_hwcore);
-
-	update_compirq_subdev_info(&comp_irq_tbl[irq_req->irq_idx],
-		irq_req->cam_hw_mask, MSM_CAM_HW_CCI, &num_hwcore);
-
-	update_compirq_subdev_info(&comp_irq_tbl[irq_req->irq_idx],
-		irq_req->cam_hw_mask, MSM_CAM_HW_CSI0, &num_hwcore);
-
-	update_compirq_subdev_info(&comp_irq_tbl[irq_req->irq_idx],
-		irq_req->cam_hw_mask, MSM_CAM_HW_CSI1, &num_hwcore);
-
-	update_compirq_subdev_info(&comp_irq_tbl[irq_req->irq_idx],
-		irq_req->cam_hw_mask, MSM_CAM_HW_CSI2, &num_hwcore);
-
-	update_compirq_subdev_info(&comp_irq_tbl[irq_req->irq_idx],
-		irq_req->cam_hw_mask, MSM_CAM_HW_CSI3, &num_hwcore);
-
-	update_compirq_subdev_info(&comp_irq_tbl[irq_req->irq_idx],
-		irq_req->cam_hw_mask, MSM_CAM_HW_ISPIF, &num_hwcore);
-
-	update_compirq_subdev_info(&comp_irq_tbl[irq_req->irq_idx],
-		irq_req->cam_hw_mask, MSM_CAM_HW_CPP, &num_hwcore);
-
-	update_compirq_subdev_info(&comp_irq_tbl[irq_req->irq_idx],
-		irq_req->cam_hw_mask, MSM_CAM_HW_VFE0, &num_hwcore);
-
-	update_compirq_subdev_info(&comp_irq_tbl[irq_req->irq_idx],
-		irq_req->cam_hw_mask, MSM_CAM_HW_VFE1, &num_hwcore);
-
-	update_compirq_subdev_info(&comp_irq_tbl[irq_req->irq_idx],
-		irq_req->cam_hw_mask, MSM_CAM_HW_JPEG0, &num_hwcore);
-
-	update_compirq_subdev_info(&comp_irq_tbl[irq_req->irq_idx],
-		irq_req->cam_hw_mask, MSM_CAM_HW_JPEG1, &num_hwcore);
-
-	update_compirq_subdev_info(&comp_irq_tbl[irq_req->irq_idx],
-		irq_req->cam_hw_mask, MSM_CAM_HW_JPEG2, &num_hwcore);
-
-	if (num_hwcore != irq_req->num_hwcore) {
-		pr_warn("%s Mismatch!! requested cam hwcores: %d, Mask set %d",
-			__func__, irq_req->num_hwcore, num_hwcore);
-		rc = -EINVAL;
-	}
-	return rc;
-}
-
-int msm_cam_server_request_irq(void *arg)
-{
-	unsigned long flags;
-	int rc = 0;
-	struct intr_table_entry *irq_req =  (struct intr_table_entry *)arg;
-	struct intr_table_entry *ind_irq_tbl =
-		&g_server_dev.irq_lkup_table.ind_intr_tbl[0];
-	struct intr_table_entry *comp_irq_tbl =
-		&g_server_dev.irq_lkup_table.comp_intr_tbl[0];
-
-	if (!irq_req || !irq_req->irq_num || !irq_req->num_hwcore) {
-		pr_err("%s Invalid input ", __func__);
-		return -EINVAL;
-	}
-
-	if (!g_server_dev.irqr_device) {
-		/* This either means, the current target does not
-		 * have a IRQ Router hw or the IRQ Router device is
-		 * not probed yet. The latter should not happen.
-		 * In any case, just return back without updating
-		 * the interrupt lookup table. */
-		pr_info("%s IRQ Router hw is not present. ", __func__);
-		return -ENXIO;
-	}
-
-	if (irq_req->is_composite) {
-		if (irq_req->irq_idx >= CAMERA_SS_IRQ_0 &&
-				irq_req->irq_idx < CAMERA_SS_IRQ_MAX) {
-			spin_lock_irqsave(&g_server_dev.intr_table_lock, flags);
-			/* Update the composite irq information into
-			 * the composite irq lookup table.... */
-			if (msm_server_update_composite_irq_info(irq_req)) {
-				pr_err("%s Invalid configuration", __func__);
-				spin_unlock_irqrestore(
-					&g_server_dev.intr_table_lock, flags);
-				return -EINVAL;
-			}
-			spin_unlock_irqrestore(&g_server_dev.intr_table_lock,
-				flags);
-			/*...and then update the corresponding entry
-			 * in the individual irq lookup table to indicate
-			 * that this IRQ is a composite irq and needs to be
-			 * sent to multiple subdevs. */
-			ind_irq_tbl[irq_req->irq_idx].is_composite = 1;
-			rc = request_irq(comp_irq_tbl[irq_req->irq_idx].irq_num,
-				msm_camera_server_parse_irq,
-				irq_req->irq_trigger_type,
-				ind_irq_tbl[irq_req->irq_idx].dev_name,
-				ind_irq_tbl[irq_req->irq_idx].data);
-			if (rc < 0) {
-				pr_err("%s: request_irq failed for %s\n",
-					__func__, irq_req->dev_name);
-				return -EBUSY;
-			}
-		} else {
-			pr_err("%s Invalid irq_idx %d ",
-				__func__, irq_req->irq_idx);
-			return -EINVAL;
-		}
-	} else {
-		if (irq_req->cam_hw_idx >= MSM_CAM_HW_MICRO &&
-				irq_req->cam_hw_idx < MSM_CAM_HW_MAX) {
-			/* Update the irq information into
-			 * the individual irq lookup table.... */
-			irq_req->irq_idx =
-				get_irq_idx_from_camhw_idx(irq_req->cam_hw_idx);
-			if (irq_req->irq_idx < 0) {
-				pr_err("%s Invalid hw index %d ", __func__,
-					irq_req->cam_hw_idx);
-				return -EINVAL;
-			}
-			spin_lock_irqsave(&g_server_dev.intr_table_lock, flags);
-			/* Make sure the composite irq is not configured for
-			 * this IRQ already. */
-			BUG_ON(ind_irq_tbl[irq_req->irq_idx].is_composite);
-
-			ind_irq_tbl[irq_req->irq_idx] = *irq_req;
-			/* irq_num is stored inside the server's hw_irqmap
-			 * during the device subdevice registration. */
-			ind_irq_tbl[irq_req->irq_idx].irq_num =
-			g_server_dev.hw_irqmap[irq_req->irq_idx].irq_num;
-
-			/*...and clear the corresponding entry in the
-			 * compsoite irq lookup table to indicate that this
-			 * IRQ will only be dispatched to single subdev. */
-			memset(&comp_irq_tbl[irq_req->irq_idx], 0,
-					sizeof(struct intr_table_entry));
-			D("%s Saving Entry %d %d %d %p",
-			__func__,
-			ind_irq_tbl[irq_req->irq_idx].irq_num,
-			ind_irq_tbl[irq_req->irq_idx].cam_hw_idx,
-			ind_irq_tbl[irq_req->irq_idx].is_composite,
-			ind_irq_tbl[irq_req->irq_idx].subdev_list[0]);
-
-			spin_unlock_irqrestore(&g_server_dev.intr_table_lock,
-				flags);
-
-			rc = request_irq(ind_irq_tbl[irq_req->irq_idx].irq_num,
-				msm_camera_server_parse_irq,
-				irq_req->irq_trigger_type,
-				ind_irq_tbl[irq_req->irq_idx].dev_name,
-				ind_irq_tbl[irq_req->irq_idx].data);
-			if (rc < 0) {
-				pr_err("%s: request_irq failed for %s\n",
-					__func__, irq_req->dev_name);
-				return -EBUSY;
-			}
-		} else {
-			pr_err("%s Invalid hw index %d ", __func__,
-				irq_req->cam_hw_idx);
-			return -EINVAL;
-		}
-	}
-	D("%s Successfully requested for IRQ for device %s ", __func__,
-		irq_req->dev_name);
-	return rc;
-}
-
-int msm_cam_server_update_irqmap(
-	struct msm_cam_server_irqmap_entry *irqmap_entry)
-{
-	if (!irqmap_entry || (irqmap_entry->irq_idx < CAMERA_SS_IRQ_0 ||
-		irqmap_entry->irq_idx >= CAMERA_SS_IRQ_MAX)) {
-		pr_err("%s Invalid irqmap entry ", __func__);
-		return -EINVAL;
-	}
-	g_server_dev.hw_irqmap[irqmap_entry->irq_idx] = *irqmap_entry;
-	return 0;
-}
-
-static int msm_cam_server_register_subdev(struct v4l2_device *v4l2_dev,
-	struct v4l2_subdev *sd)
-{
-	int rc = 0;
-	struct video_device *vdev;
-
-	if (v4l2_dev == NULL || sd == NULL || !sd->name[0]) {
-		pr_err("%s Invalid input ", __func__);
-		return -EINVAL;
-	}
-
-	rc = v4l2_device_register_subdev(v4l2_dev, sd);
-	if (rc < 0) {
-		pr_err("%s v4l2 subdev register failed for %s ret = %d",
-			__func__, sd->name, rc);
-		return rc;
-	}
-
-	/* Register a device node for every subdev marked with the
-	 * V4L2_SUBDEV_FL_HAS_DEVNODE flag.
-	 */
-	if (!(sd->flags & V4L2_SUBDEV_FL_HAS_DEVNODE))
-		return rc;
-
-	vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
-	if (!vdev) {
-		pr_err("%s Not enough memory ", __func__);
-		rc = -ENOMEM;
-		goto clean_up;
-	}
-
-	video_set_drvdata(vdev, sd);
-	strlcpy(vdev->name, sd->name, sizeof(vdev->name));
-	vdev->v4l2_dev = v4l2_dev;
-	vdev->fops = &v4l2_subdev_fops;
-	vdev->release = msm_cam_release_subdev_node;
-	rc = __video_register_device(vdev, VFL_TYPE_SUBDEV, -1, 1,
-						  sd->owner);
-	if (rc < 0) {
-		pr_err("%s Error registering video device %s", __func__,
-			sd->name);
-		kfree(vdev);
-		goto clean_up;
-	}
-#if defined(CONFIG_MEDIA_CONTROLLER)
-	sd->entity.info.v4l.major = VIDEO_MAJOR;
-	sd->entity.info.v4l.minor = vdev->minor;
-#endif
-	sd->devnode = vdev;
-	return 0;
-
-clean_up:
-	if (sd->devnode)
-		video_unregister_device(sd->devnode);
-	return rc;
-}
-
-static int msm_cam_server_fill_sdev_irqnum(int cam_hw_idx,
-	int irq_num)
-{
-	int rc = 0, irq_idx;
-	irq_idx = get_irq_idx_from_camhw_idx(cam_hw_idx);
-	if (irq_idx < 0) {
-		pr_err("%s Invalid cam_hw_idx %d ", __func__, cam_hw_idx);
-		rc = -EINVAL;
-	} else {
-		g_server_dev.hw_irqmap[irq_idx].irq_num = irq_num;
-	}
-	return rc;
-}
-
-int msm_cam_register_subdev_node(struct v4l2_subdev *sd,
-	struct msm_cam_subdev_info *sd_info)
-{
-	int err = 0, cam_hw_idx;
-	uint8_t sdev_type, index;
-
-	sdev_type = sd_info->sdev_type;
-	index     = sd_info->sd_index;
-
-	switch (sdev_type) {
-	case SENSOR_DEV:
-		if (index >= MAX_NUM_SENSOR_DEV) {
-			pr_err("%s Invalid sensor idx %d", __func__, index);
-			err = -EINVAL;
-			break;
-		}
-		g_server_dev.sensor_device[index] = sd;
-		break;
-
-	case CSIPHY_DEV:
-		if (index >= MAX_NUM_CSIPHY_DEV) {
-			pr_err("%s Invalid CSIPHY idx %d", __func__, index);
-			err = -EINVAL;
-			break;
-		}
-		g_server_dev.csiphy_device[index] = sd;
-		break;
-
-	case CSID_DEV:
-		if (index >= MAX_NUM_CSID_DEV) {
-			pr_err("%s Invalid CSID idx %d", __func__, index);
-			err = -EINVAL;
-			break;
-		}
-		cam_hw_idx = MSM_CAM_HW_CSI0 + index;
-		g_server_dev.csid_device[index] = sd;
-		if (g_server_dev.irqr_device) {
-			g_server_dev.subdev_table[cam_hw_idx] = sd;
-			err = msm_cam_server_fill_sdev_irqnum(cam_hw_idx,
-				sd_info->irq_num);
-		}
-		break;
-
-	case CSIC_DEV:
-		if (index >= MAX_NUM_CSIC_DEV) {
-			pr_err("%s Invalid CSIC idx %d", __func__, index);
-			err = -EINVAL;
-			break;
-		}
-		g_server_dev.csic_device[index] = sd;
-		break;
-
-	case ISPIF_DEV:
-		if (index >= MAX_NUM_ISPIF_DEV) {
-			pr_err("%s Invalid ISPIF idx %d", __func__, index);
-			err = -EINVAL;
-			break;
-		}
-		cam_hw_idx = MSM_CAM_HW_ISPIF + index;
-		g_server_dev.ispif_device[index] = sd;
-		if (g_server_dev.irqr_device) {
-			g_server_dev.subdev_table[cam_hw_idx] = sd;
-			err = msm_cam_server_fill_sdev_irqnum(cam_hw_idx,
-				sd_info->irq_num);
-		}
-		break;
-
-	case VFE_DEV:
-		if (index >= MAX_NUM_VFE_DEV) {
-			pr_err("%s Invalid VFE idx %d", __func__, index);
-			err = -EINVAL;
-			break;
-		}
-		cam_hw_idx = MSM_CAM_HW_VFE0 + index;
-		g_server_dev.vfe_device[index] = sd;
-		if (g_server_dev.irqr_device) {
-			g_server_dev.subdev_table[cam_hw_idx] = sd;
-			err = msm_cam_server_fill_sdev_irqnum(cam_hw_idx,
-				sd_info->irq_num);
-		}
-		break;
-
-	case VPE_DEV:
-		if (index >= MAX_NUM_VPE_DEV) {
-			pr_err("%s Invalid VPE idx %d", __func__, index);
-			err = -EINVAL;
-			break;
-		}
-		g_server_dev.vpe_device[index] = sd;
-		break;
-
-	case AXI_DEV:
-		if (index >= MAX_NUM_AXI_DEV) {
-			pr_err("%s Invalid AXI idx %d", __func__, index);
-			err = -EINVAL;
-			break;
-		}
-		g_server_dev.axi_device[index] = sd;
-		break;
-
-	case GESTURE_DEV:
-		g_server_dev.gesture_device = sd;
-		break;
-
-	case IRQ_ROUTER_DEV:
-		g_server_dev.irqr_device = sd;
-
-	case CPP_DEV:
-		if (index >= MAX_NUM_CPP_DEV) {
-			pr_err("%s Invalid CPP idx %d", __func__, index);
-			err = -EINVAL;
-			break;
-		}
-		g_server_dev.cpp_device[index] = sd;
-		break;
-	case CCI_DEV:
-		g_server_dev.cci_device = sd;
-		if (g_server_dev.irqr_device) {
-			if (index >= MAX_NUM_CCI_DEV) {
-				pr_err("%s Invalid CCI idx %d", __func__,
-					index);
-				err = -EINVAL;
-				break;
-			}
-			cam_hw_idx = MSM_CAM_HW_CCI + index;
-			g_server_dev.subdev_table[cam_hw_idx] = sd;
-			err = msm_cam_server_fill_sdev_irqnum(MSM_CAM_HW_CCI,
-				sd_info->irq_num);
-		}
-		break;
-
-	case FLASH_DEV:
-		if (index >= MAX_NUM_FLASH_DEV) {
-			pr_err("%s Invalid flash idx %d", __func__, index);
-			err = -EINVAL;
-			break;
-		}
-		g_server_dev.flash_device[index] = sd;
-		break;
-
-	default:
-		break;
-	}
-
-	if (err < 0)
-		return err;
-
-	err = msm_cam_server_register_subdev(&g_server_dev.v4l2_dev, sd);
-	return err;
-}
-
-#ifdef CONFIG_MSM_IOMMU
-static int camera_register_domain(void)
-{
-	struct msm_iova_partition camera_fw_partition = {
-		.start = SZ_128K,
-		.size = SZ_2G - SZ_128K,
-	};
-	struct msm_iova_layout camera_fw_layout = {
-		.partitions = &camera_fw_partition,
-		.npartitions = 1,
-		.client_name = "camera_isp",
-		.domain_flags = 0,
-	};
-
-	return msm_register_domain(&camera_fw_layout);
-}
-#endif
-
-static int msm_setup_server_dev(struct platform_device *pdev)
-{
-	int rc = -ENODEV, i;
-
-	D("%s\n", __func__);
-	g_server_dev.server_pdev = pdev;
-	g_server_dev.v4l2_dev.dev = &pdev->dev;
-	g_server_dev.v4l2_dev.notify = msm_cam_server_subdev_notify;
-	rc = v4l2_device_register(g_server_dev.v4l2_dev.dev,
-			&g_server_dev.v4l2_dev);
-	if (rc < 0)
-		return -EINVAL;
-
-	g_server_dev.video_dev = video_device_alloc();
-	if (g_server_dev.video_dev == NULL) {
-		pr_err("%s: video_device_alloc failed\n", __func__);
-		return rc;
-	}
-
-	strlcpy(g_server_dev.video_dev->name, pdev->name,
-			sizeof(g_server_dev.video_dev->name));
-
-	g_server_dev.video_dev->v4l2_dev = &g_server_dev.v4l2_dev;
-	g_server_dev.video_dev->fops = &msm_fops_server;
-	g_server_dev.video_dev->ioctl_ops = &msm_ioctl_ops_server;
-	g_server_dev.video_dev->release   = video_device_release;
-	g_server_dev.video_dev->minor = 100;
-	g_server_dev.video_dev->vfl_type = VFL_TYPE_GRABBER;
-
-	video_set_drvdata(g_server_dev.video_dev, &g_server_dev);
-
-	strlcpy(g_server_dev.media_dev.model, QCAMERA_SERVER_NAME,
-		sizeof(g_server_dev.media_dev.model));
-	g_server_dev.media_dev.dev = &pdev->dev;
-	rc = media_device_register(&g_server_dev.media_dev);
-	g_server_dev.v4l2_dev.mdev = &g_server_dev.media_dev;
-	media_entity_init(&g_server_dev.video_dev->entity, 0, NULL, 0);
-	g_server_dev.video_dev->entity.type = MEDIA_ENT_T_DEVNODE_V4L;
-	g_server_dev.video_dev->entity.group_id = QCAMERA_VNODE_GROUP_ID;
-
-	rc = video_register_device(g_server_dev.video_dev,
-		VFL_TYPE_GRABBER, 100);
-
-	g_server_dev.video_dev->entity.name =
-		video_device_node_name(g_server_dev.video_dev);
-
-	mutex_init(&g_server_dev.server_lock);
-	mutex_init(&g_server_dev.server_queue_lock);
-	spin_lock_init(&g_server_dev.intr_table_lock);
-	memset(&g_server_dev.irq_lkup_table, 0,
-			sizeof(struct irqmgr_intr_lkup_table));
-	g_server_dev.camera_info.num_cameras = 0;
-	atomic_set(&g_server_dev.number_pcam_active, 0);
-	g_server_dev.server_evt_id = 0;
-
-	/*initialize fake video device and event queue*/
-
-	g_server_dev.server_command_queue.pvdev = g_server_dev.video_dev;
-	msm_setup_v4l2_event_queue(
-		&g_server_dev.server_command_queue.eventHandle,
-		g_server_dev.server_command_queue.pvdev);
-
-	for (i = 0; i < MAX_NUM_ACTIVE_CAMERA; i++) {
-		struct msm_cam_server_queue *queue;
-		queue = &g_server_dev.server_queue[i];
-		queue->queue_active = 0;
-		msm_queue_init(&queue->ctrl_q, "control");
-		msm_queue_init(&queue->eventData_q, "eventdata");
-		g_server_dev.pcam_active[i] = NULL;
-	}
-
-	for (i = 0; i < INTF_MAX; i++) {
-		g_server_dev.interface_map_table[i].interface = 0x01 << i;
-		g_server_dev.interface_map_table[i].mctl_handle = 0;
-	}
-#ifdef CONFIG_MSM_IOMMU
-	g_server_dev.domain_num = camera_register_domain();
-	if (g_server_dev.domain_num < 0) {
-		pr_err("%s: could not register domain\n", __func__);
-		rc = -ENODEV;
-		return rc;
-	}
-	g_server_dev.domain =
-		msm_get_iommu_domain(g_server_dev.domain_num);
-	if (!g_server_dev.domain) {
-		pr_err("%s: cannot find domain\n", __func__);
-		rc = -ENODEV;
-		return rc;
-	}
-#endif
-	return rc;
-}
-
-static long msm_server_send_v4l2_evt(void *evt)
-{
-	struct v4l2_event *v4l2_ev = (struct v4l2_event *)evt;
-	int rc = 0;
-
-	if (NULL == evt) {
-		pr_err("%s: evt is NULL\n", __func__);
-		return -EINVAL;
-	}
-
-	D("%s: evt type 0x%x\n", __func__, v4l2_ev->type);
-	if ((v4l2_ev->type >= MSM_GES_APP_EVT_MIN) &&
-		(v4l2_ev->type < MSM_GES_APP_EVT_MAX)) {
-		msm_cam_server_subdev_notify(g_server_dev.gesture_device,
-			NOTIFY_GESTURE_EVT, v4l2_ev);
-	} else {
-		pr_err("%s: Invalid evt %d\n", __func__, v4l2_ev->type);
-		rc = -EINVAL;
-	}
-	D("%s: end\n", __func__);
-
-	return rc;
-}
-
-int msm_cam_server_open_mctl_session(struct msm_cam_v4l2_device *pcam,
-	int *p_active)
-{
-	int rc = 0;
-	int i = 0;
-	struct msm_cam_media_controller *pmctl = NULL;
-	*p_active = 0;
-
-	for (i = 0; i < MAX_NUM_ACTIVE_CAMERA; i++) {
-		if (NULL != g_server_dev.pcam_active[i]) {
-			pr_info("%s: Active camera present return", __func__);
-			return 0;
-		}
-	}
-
-	rc = msm_cam_server_open_session(&g_server_dev, pcam);
-	if (rc < 0) {
-		pr_err("%s: cam_server_open_session failed %d\n",
-		__func__, rc);
-		return rc;
-	}
-
-	pmctl = msm_cam_server_get_mctl(pcam->mctl_handle);
-	if (!pmctl || !pmctl->mctl_open) {
-		D("%s: media contoller is not inited\n",
-			 __func__);
-		rc = -ENODEV;
-		return rc;
-	}
-
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-		pmctl->domain = msm_cam_server_get_domain();
-		pmctl->domain_num = msm_cam_server_get_domain_num();
-#endif
-
-	D("%s: call mctl_open\n", __func__);
-	rc = pmctl->mctl_open(pmctl, MSM_APPS_ID_V4L2);
-
-	if (rc < 0) {
-		pr_err("%s: HW open failed rc = 0x%x\n",  __func__, rc);
-		return rc;
-	}
-	pmctl->pcam_ptr = pcam;
-	*p_active = 1;
-	return rc;
-}
-
-int msm_cam_server_close_mctl_session(struct msm_cam_v4l2_device *pcam)
-{
-	int rc = 0;
-	struct msm_cam_media_controller *pmctl = NULL;
-
-	pmctl = msm_cam_server_get_mctl(pcam->mctl_handle);
-	if (!pmctl) {
-		D("%s: invalid handle\n", __func__);
-		return -ENODEV;
-	}
-
-	if (pmctl->mctl_release)
-		pmctl->mctl_release(pmctl);
-
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-	kref_put(&pmctl->refcount, msm_release_ion_client);
-#endif
-
-	rc = msm_cam_server_close_session(&g_server_dev, pcam);
-	if (rc < 0)
-		pr_err("msm_cam_server_close_session fails %d\n", rc);
-
-	return rc;
-}
-
-int msm_server_open_client(int *p_qidx)
-{
-	int rc = 0;
-	int server_q_idx = 0;
-	struct msm_cam_server_queue *queue = NULL;
-
-	mutex_lock(&g_server_dev.server_lock);
-	server_q_idx = msm_find_free_queue();
-	if (server_q_idx < 0) {
-		mutex_unlock(&g_server_dev.server_lock);
-		return server_q_idx;
-	}
-
-	*p_qidx = server_q_idx;
-	queue = &g_server_dev.server_queue[server_q_idx];
-	queue->ctrl_data = kzalloc(sizeof(uint8_t) *
-		MAX_SERVER_PAYLOAD_LENGTH, GFP_KERNEL);
-	if (!queue->ctrl_data) {
-		pr_err("%s: Could not find memory\n", __func__);
-		return -ENOMEM;
-	}
-	msm_queue_init(&queue->ctrl_q, "control");
-	msm_queue_init(&queue->eventData_q, "eventdata");
-	queue->queue_active = 1;
-	mutex_unlock(&g_server_dev.server_lock);
-	return rc;
-}
-
-int msm_server_send_ctrl(struct msm_ctrl_cmd *out,
-	int ctrl_id)
-{
-	int rc = 0;
-	void *value;
-	struct msm_queue_cmd *rcmd;
-	struct msm_queue_cmd *event_qcmd;
-	struct msm_ctrl_cmd *ctrlcmd;
-	struct msm_cam_server_dev *server_dev = &g_server_dev;
-	struct msm_device_queue *queue =
-		&server_dev->server_queue[out->queue_idx].ctrl_q;
-
-	struct v4l2_event v4l2_evt;
-	struct msm_isp_event_ctrl *isp_event;
-	void *ctrlcmd_data;
-
-	event_qcmd = kzalloc(sizeof(struct msm_queue_cmd), GFP_KERNEL);
-	if (!event_qcmd) {
-		pr_err("%s Insufficient memory. return", __func__);
-		rc = -ENOMEM;
-		goto event_qcmd_alloc_fail;
-	}
-
-	isp_event = kzalloc(sizeof(struct msm_isp_event_ctrl), GFP_KERNEL);
-	if (!isp_event) {
-		pr_err("%s Insufficient memory. return", __func__);
-		rc = -ENOMEM;
-		goto isp_event_alloc_fail;
-	}
-
-	D("%s\n", __func__);
-	mutex_lock(&server_dev->server_queue_lock);
-	if (++server_dev->server_evt_id == 0)
-		server_dev->server_evt_id++;
-
-	D("%s qid %d evtid %d\n", __func__, out->queue_idx,
-		server_dev->server_evt_id);
-	server_dev->server_queue[out->queue_idx].evt_id =
-		server_dev->server_evt_id;
-	v4l2_evt.type = V4L2_EVENT_PRIVATE_START + ctrl_id;
-	v4l2_evt.id = 0;
-	v4l2_evt.u.data[0] = out->queue_idx;
-	/* setup event object to transfer the command; */
-	isp_event->resptype = MSM_CAM_RESP_V4L2;
-	isp_event->isp_data.ctrl = *out;
-	isp_event->isp_data.ctrl.evt_id = server_dev->server_evt_id;
-
-	if (out->value != NULL && out->length != 0) {
-		ctrlcmd_data = kzalloc(out->length, GFP_KERNEL);
-		if (!ctrlcmd_data) {
-			rc = -ENOMEM;
-			goto ctrlcmd_alloc_fail;
-		}
-		memcpy(ctrlcmd_data, out->value, out->length);
-		isp_event->isp_data.ctrl.value = ctrlcmd_data;
-	}
-
-	atomic_set(&event_qcmd->on_heap, 1);
-	event_qcmd->command = isp_event;
-
-	msm_enqueue(&server_dev->server_queue[out->queue_idx].eventData_q,
-				&event_qcmd->list_eventdata);
-
-	/* now send command to config thread in userspace,
-	 * and wait for results */
-	v4l2_event_queue(server_dev->server_command_queue.pvdev,
-					  &v4l2_evt);
-	D("%s v4l2_event_queue: type = 0x%x\n", __func__, v4l2_evt.type);
-	mutex_unlock(&server_dev->server_queue_lock);
-
-	/* wait for config return status */
-	D("Waiting for config status\n");
-	rc = wait_event_interruptible_timeout(queue->wait,
-		!list_empty_careful(&queue->list),
-		msecs_to_jiffies(out->timeout_ms));
-	D("Waiting is over for config status\n");
-	if (list_empty_careful(&queue->list)) {
-		if (!rc)
-			rc = -ETIMEDOUT;
-		if (rc < 0) {
-			if (++server_dev->server_evt_id == 0)
-				server_dev->server_evt_id++;
-			pr_err("%s: wait_event error %d\n", __func__, rc);
-			return rc;
-		}
-	}
-
-	rcmd = msm_dequeue(queue, list_control);
-	BUG_ON(!rcmd);
-	D("%s Finished servicing ioctl\n", __func__);
-
-	ctrlcmd = (struct msm_ctrl_cmd *)(rcmd->command);
-	value = out->value;
-	if (ctrlcmd->length > 0 && value != NULL &&
-		ctrlcmd->length <= out->length)
-		memcpy(value, ctrlcmd->value, ctrlcmd->length);
-
-	memcpy(out, ctrlcmd, sizeof(struct msm_ctrl_cmd));
-	out->value = value;
-
-	kfree(ctrlcmd);
-	free_qcmd(rcmd);
-	D("%s: rc %d\n", __func__, rc);
-	/* rc is the time elapsed. */
-	if (rc >= 0) {
-		/* TODO: Refactor msm_ctrl_cmd::status field */
-		if (out->status == 0)
-			rc = -1;
-		else if (out->status == 1 || out->status == 4)
-			rc = 0;
-		else
-			rc = -EINVAL;
-	}
-	return rc;
-
-ctrlcmd_alloc_fail:
-	kfree(isp_event);
-isp_event_alloc_fail:
-	kfree(event_qcmd);
-event_qcmd_alloc_fail:
-	return rc;
-}
-
-int msm_server_close_client(int idx)
-{
-	int rc = 0;
-	struct msm_cam_server_queue *queue = NULL;
-	mutex_lock(&g_server_dev.server_lock);
-	queue = &g_server_dev.server_queue[idx];
-	queue->queue_active = 0;
-	kfree(queue->ctrl_data);
-	queue->ctrl_data = NULL;
-	msm_queue_drain(&queue->ctrl_q, list_control);
-	msm_drain_eventq(&queue->eventData_q);
-	mutex_unlock(&g_server_dev.server_lock);
-	return rc;
-}
-
-static unsigned int msm_poll_config(struct file *fp,
-					struct poll_table_struct *wait)
-{
-	int rc = 0;
-	struct msm_cam_config_dev *config = fp->private_data;
-	if (config == NULL)
-		return -EINVAL;
-
-	D("%s\n", __func__);
-
-	poll_wait(fp,
-	&config->config_stat_event_queue.eventHandle.wait, wait);

-	if (v4l2_event_pending(&config->config_stat_event_queue.eventHandle))
-		rc |= POLLPRI;
-	return rc;
-}
-
-static int msm_open_config(struct inode *inode, struct file *fp)
-{
-	int rc;
-	struct msm_cam_config_dev *config_cam = container_of(inode->i_cdev,
-		struct msm_cam_config_dev, config_cdev);
-
-	D("%s: open %s\n", __func__, fp->f_path.dentry->d_name.name);
-
-	rc = nonseekable_open(inode, fp);
-	if (rc < 0) {
-		pr_err("%s: nonseekable_open error %d\n", __func__, rc);
-		return rc;
-	}
-	config_cam->use_count++;
-
-	/* assume there is only one active camera possible*/
-	config_cam->p_mctl = msm_cam_server_get_mctl(
-		g_server_dev.pcam_active[config_cam->dev_num]->mctl_handle);
-	if (!config_cam->p_mctl) {
-		pr_err("%s: cannot find mctl\n", __func__);
-		return -ENODEV;
-	}
-
-	INIT_HLIST_HEAD(&config_cam->p_mctl->stats_info.pmem_stats_list);
-	spin_lock_init(&config_cam->p_mctl->stats_info.pmem_stats_spinlock);
-
-	config_cam->p_mctl->config_device = config_cam;
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-	kref_get(&config_cam->p_mctl->refcount);
-#endif
-	fp->private_data = config_cam;
-	return rc;
-}
-
-static int msm_set_mctl_subdev(struct msm_cam_media_controller *pmctl,
-	struct msm_mctl_set_sdev_data *set_data)
-{
-	int rc = 0;
-	struct v4l2_subdev *temp_sdev = NULL;
-	switch (set_data->sdev_type) {
-	case CSIPHY_DEV:
-		pmctl->csiphy_sdev = msm_cam_find_subdev_node
-			(&g_server_dev.csiphy_device[0], set_data->revision);
-		temp_sdev = pmctl->csiphy_sdev;
-		break;
-	case CSID_DEV:
-		pmctl->csid_sdev = msm_cam_find_subdev_node
-			(&g_server_dev.csid_device[0], set_data->revision);
-		temp_sdev = pmctl->csid_sdev;
-		break;
-	case CSIC_DEV:
-		pmctl->csic_sdev = msm_cam_find_subdev_node
-			(&g_server_dev.csic_device[0], set_data->revision);
-		temp_sdev = pmctl->csic_sdev;
-		break;
-	case ISPIF_DEV:
-		pmctl->ispif_sdev = msm_cam_find_subdev_node
-			(&g_server_dev.ispif_device[0], set_data->revision);
-		temp_sdev = pmctl->ispif_sdev;
-		break;
-	case VFE_DEV:
-		pmctl->vfe_sdev = msm_cam_find_subdev_node
-			(&g_server_dev.vfe_device[0], set_data->revision);
-		temp_sdev = pmctl->vfe_sdev;
-		break;
-	case AXI_DEV:
-		pmctl->axi_sdev = msm_cam_find_subdev_node
-			(&g_server_dev.axi_device[0], set_data->revision);
-		temp_sdev = pmctl->axi_sdev;
-		break;
-	case VPE_DEV:
-		pmctl->vpe_sdev = msm_cam_find_subdev_node
-			(&g_server_dev.vpe_device[0], set_data->revision);
-		temp_sdev = pmctl->vpe_sdev;
-		break;
-	default:
-		rc = -EINVAL;
-		break;
-	}
-	if (temp_sdev != NULL)
-		v4l2_set_subdev_hostdata(temp_sdev, pmctl);
-	else
-		pr_err("%s: Could not find subdev\n", __func__);
-	return rc;
-}
-
-static int msm_unset_mctl_subdev(struct msm_cam_media_controller *pmctl,
-	struct msm_mctl_set_sdev_data *set_data)
-{
-	int rc = 0;
-	switch (set_data->sdev_type) {
-	case CSIPHY_DEV:
-		pmctl->csiphy_sdev = NULL;
-		break;
-	case CSID_DEV:
-		pmctl->csid_sdev = NULL;
-		break;
-	case CSIC_DEV:
-		pmctl->csic_sdev = NULL;
-		break;
-	case ISPIF_DEV:
-		pmctl->ispif_sdev = NULL;
-		break;
-	case VFE_DEV:
-		pmctl->vfe_sdev = NULL;
-		break;
-	case AXI_DEV:
-		pmctl->axi_sdev = NULL;
-		break;
-	case VPE_DEV:
-		pmctl->vpe_sdev = NULL;
-		break;
-	default:
-		rc = -EINVAL;
-		break;
-	}
-	return rc;
-}
-
-static long msm_ioctl_config(struct file *fp, unsigned int cmd,
-	unsigned long arg)
-{
-
-	int rc = 0;
-	struct v4l2_event ev;
-	struct msm_cam_config_dev *config_cam = fp->private_data;
-	struct v4l2_event_subscription temp_sub;
-
-	D("%s: cmd %d\n", __func__, _IOC_NR(cmd));
-	ev.id = 0;

-
-	switch (cmd) {
-	/* memory management shall be handeld here*/
-	case MSM_CAM_IOCTL_REGISTER_PMEM:
-		return msm_register_pmem(
-			&config_cam->p_mctl->stats_info.pmem_stats_list,
-			(void __user *)arg, config_cam->p_mctl->client,
-			config_cam->p_mctl->domain_num);
-		break;
-
-	case MSM_CAM_IOCTL_UNREGISTER_PMEM:
-		return msm_pmem_table_del(
-			&config_cam->p_mctl->stats_info.pmem_stats_list,
-			(void __user *)arg, config_cam->p_mctl->client,
-			config_cam->p_mctl->domain_num);
-		break;
-
-	case VIDIOC_SUBSCRIBE_EVENT:
-		if (copy_from_user(&temp_sub,
-			(void __user *)arg,
-			sizeof(struct v4l2_event_subscription))) {
-				pr_err("%s copy_from_user failed for cmd %d ",
-					__func__, cmd);
-				rc = -EINVAL;
-				return rc;
-		}
-		rc = msm_server_v4l2_subscribe_event
-			(&config_cam->config_stat_event_queue.eventHandle,
-				 &temp_sub);
-		if (rc < 0) {
-			pr_err("%s: cam_v4l2_subscribe_event failed rc=%d\n",
-				__func__, rc);
-			return rc;
-		}
-		break;
-
-	case VIDIOC_UNSUBSCRIBE_EVENT:
-		if (copy_from_user(&temp_sub, (void __user *)arg,
-			  sizeof(struct v4l2_event_subscription))) {
-			rc = -EINVAL;
-			return rc;
-		}
-		rc = msm_server_v4l2_unsubscribe_event
-			(&config_cam->config_stat_event_queue.eventHandle,
-			 &temp_sub);
-		if (rc < 0) {
-			pr_err("%s: cam_v4l2_unsubscribe_event failed rc=%d\n",
-				__func__, rc);
-			return rc;
-		}
-		break;
-
-	case VIDIOC_DQEVENT: {
-		void __user *u_msg_value = NULL, *user_ptr = NULL;
-		struct msm_isp_event_ctrl u_isp_event;
-		struct msm_isp_event_ctrl *k_isp_event;
-
-		/* First, copy the v4l2 event structure from userspace */
-		D("%s: VIDIOC_DQEVENT\n", __func__);
-		if (copy_from_user(&ev, (void __user *)arg,
-				sizeof(struct v4l2_event)))
-			break;
-		/* Next, get the pointer to event_ctrl structure
-		 * embedded inside the v4l2_event.u.data array. */
-		user_ptr = (void __user *)(*((uint32_t *)ev.u.data));
-
-		/* Next, copy the userspace event ctrl structure */
-		if (copy_from_user((void *)&u_isp_event, user_ptr,
-				   sizeof(struct msm_isp_event_ctrl))) {
-			rc = -EFAULT;
-			break;
-		}
-		/* Save the pointer of the user allocated command buffer*/
-		u_msg_value = u_isp_event.isp_data.isp_msg.data;
-
-		/* Dequeue the event queued into the v4l2 queue*/
-		rc = v4l2_event_dequeue(
-			&config_cam->config_stat_event_queue.eventHandle,
-			&ev, fp->f_flags & O_NONBLOCK);
-		if (rc < 0) {
-			pr_err("no pending events?");
-			rc = -EFAULT;
-			break;
-		}
-		/* Use k_isp_event to point to the event_ctrl structure
-		 * embedded inside v4l2_event.u.data */
-		k_isp_event = (struct msm_isp_event_ctrl *)
-				(*((uint32_t *)ev.u.data));
-		/* Copy the event structure into user struct. */
-		u_isp_event = *k_isp_event;
-		if (ev.type != (V4L2_EVENT_PRIVATE_START +
-				MSM_CAM_RESP_DIV_FRAME_EVT_MSG) &&
-				ev.type != (V4L2_EVENT_PRIVATE_START +
-				MSM_CAM_RESP_MCTL_PP_EVENT)) {
-
-			/* Restore the saved pointer of the
-			 * user allocated command buffer. */
-			u_isp_event.isp_data.isp_msg.data = u_msg_value;
-
-			if (ev.type == (V4L2_EVENT_PRIVATE_START +
-					MSM_CAM_RESP_STAT_EVT_MSG)) {
-				if (k_isp_event->isp_data.isp_msg.len > 0) {
-					void *k_msg_value =
-					k_isp_event->isp_data.isp_msg.data;
-					if (copy_to_user(u_msg_value,
-							k_msg_value,
-					 k_isp_event->isp_data.isp_msg.len)) {
-						rc = -EINVAL;
-						break;
-					}
-					kfree(k_msg_value);
-					k_msg_value = NULL;
-				}
-			}
-		}
-		/* Copy the event ctrl structure back
-		 * into user's structure. */
-		if (copy_to_user(user_ptr,
-				(void *)&u_isp_event, sizeof(
-				struct msm_isp_event_ctrl))) {
-			rc = -EINVAL;
-			break;
-		}
-		kfree(k_isp_event);
-		k_isp_event = NULL;
-
-		/* Copy the v4l2_event structure back to the user*/
-		if (copy_to_user((void __user *)arg, &ev,
-				sizeof(struct v4l2_event))) {
-			rc = -EINVAL;
-			break;
-		}
-		}
-
-		break;
-
-	case MSM_CAM_IOCTL_V4L2_EVT_NOTIFY:
-		rc = msm_v4l2_evt_notify(config_cam->p_mctl, cmd, arg);
-		break;
-
-	case MSM_CAM_IOCTL_SET_MCTL_SDEV:{
-		struct msm_mctl_set_sdev_data set_data;
-		if (copy_from_user(&set_data, (void __user *)arg,
-			sizeof(struct msm_mctl_set_sdev_data))) {
-			ERR_COPY_FROM_USER();
-			rc = -EINVAL;
-			break;
-		}
-		rc = msm_set_mctl_subdev(config_cam->p_mctl, &set_data);
-		break;
-	}
-
-	case MSM_CAM_IOCTL_UNSET_MCTL_SDEV:{
-		struct msm_mctl_set_sdev_data set_data;
-		if (copy_from_user(&set_data, (void __user *)arg,
-			sizeof(struct msm_mctl_set_sdev_data))) {
-			ERR_COPY_FROM_USER();
-			rc = -EINVAL;
-			break;
-		}
-		rc = msm_unset_mctl_subdev(config_cam->p_mctl, &set_data);
-		break;
-	}
-
-	default:{
-		/* For the rest of config command, forward to media controller*/
-		struct msm_cam_media_controller *p_mctl = config_cam->p_mctl;
-		if (p_mctl && p_mctl->mctl_cmd) {
-			rc = config_cam->p_mctl->mctl_cmd(p_mctl, cmd, arg);
-		} else {
-			rc = -EINVAL;
-			pr_err("%s: media controller is null\n", __func__);
-		}
-
-		break;
-	} /* end of default*/
-	} /* end of switch*/
-	return rc;
-}
-
-static int msm_close_config(struct inode *node, struct file *f)
-{
-	struct v4l2_event_subscription sub;
-	struct msm_cam_config_dev *config_cam = f->private_data;
-
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-	D("%s Decrementing ref count of config node ", __func__);
-	kref_put(&config_cam->p_mctl->refcount, msm_release_ion_client);
-#endif
-	sub.type = V4L2_EVENT_ALL;
-	msm_server_v4l2_unsubscribe_event(
-		&config_cam->config_stat_event_queue.eventHandle,
-		&sub);
-	return 0;
-}
-
-static const struct file_operations msm_fops_config = {
-	.owner = THIS_MODULE,
-	.open  = msm_open_config,
-	.poll  = msm_poll_config,
-	.unlocked_ioctl = msm_ioctl_config,
-	.release = msm_close_config,
-};
-
-static int msm_setup_config_dev(int node, char *device_name)
-{
-	int rc = -ENODEV;
-	struct device *device_config;
-	int dev_num = node;
-	dev_t devno;
-	struct msm_cam_config_dev *config_cam;
-
-	config_cam = kzalloc(sizeof(*config_cam), GFP_KERNEL);
-	if (!config_cam) {
-		pr_err("%s: could not allocate memory for config_device\n",
-			__func__);
-		return -ENOMEM;
-	}
-
-	D("%s\n", __func__);
-
-	devno = MKDEV(MAJOR(msm_devno), dev_num+1);
-	device_config = device_create(msm_class, NULL, devno, NULL, "%s%d",
-		device_name, dev_num);
-
-	if (IS_ERR(device_config)) {
-		rc = PTR_ERR(device_config);
-		pr_err("%s: error creating device: %d\n", __func__, rc);
-		goto config_setup_fail;
-	}
-
-	cdev_init(&config_cam->config_cdev, &msm_fops_config);
-	config_cam->config_cdev.owner = THIS_MODULE;
-
-	rc = cdev_add(&config_cam->config_cdev, devno, 1);
-	if (rc < 0) {
-		pr_err("%s: error adding cdev: %d\n", __func__, rc);
-		device_destroy(msm_class, devno);
-		goto config_setup_fail;
-	}
-	g_server_dev.config_info.config_dev_name[dev_num] =
-		dev_name(device_config);
-	D("%s Connected config device %s\n", __func__,
-		g_server_dev.config_info.config_dev_name[dev_num]);
-	g_server_dev.config_info.config_dev_id[dev_num] =
-		dev_num;
-
-	config_cam->config_stat_event_queue.pvdev = video_device_alloc();
-	if (config_cam->config_stat_event_queue.pvdev == NULL) {
-		pr_err("%s: video_device_alloc failed\n", __func__);
-		goto config_setup_fail;
-	}
-
-	/* v4l2_fh support */
-	spin_lock_init(&config_cam->config_stat_event_queue.pvdev->fh_lock);
-	INIT_LIST_HEAD(&config_cam->config_stat_event_queue.pvdev->fh_list);
-	msm_setup_v4l2_event_queue(
-		&config_cam->config_stat_event_queue.eventHandle,
-		config_cam->config_stat_event_queue.pvdev);
-	config_cam->dev_num = dev_num;
-
-	return rc;
-
-config_setup_fail:
-	kfree(config_cam);
-	return rc;
-}
-
-static int __devinit msm_camera_probe(struct platform_device *pdev)
-{
-	int rc = 0, i;
-	memset(&g_server_dev, 0, sizeof(struct msm_cam_server_dev));
-	/*for now just create two config nodes
-	  put logic here later to know how many configs to create*/
-	g_server_dev.config_info.num_config_nodes = 2;
-
-	if (!msm_class) {
-		rc = alloc_chrdev_region(&msm_devno, 0,
-		g_server_dev.config_info.num_config_nodes+1, "msm_camera");
-		if (rc < 0) {
-			pr_err("%s: failed to allocate chrdev: %d\n", __func__,
-			rc);
-			return rc;
-		}
-
-		msm_class = class_create(THIS_MODULE, "msm_camera");
-		if (IS_ERR(msm_class)) {
-			rc = PTR_ERR(msm_class);
-			pr_err("%s: create device class failed: %d\n",
-			__func__, rc);
-			return rc;
-		}
-	}
-
-	D("creating server and config nodes\n");
-	rc = msm_setup_server_dev(pdev);
-	if (rc < 0) {
-		pr_err("%s: failed to create server dev: %d\n", __func__,
-		rc);
-		return rc;
-	}
-
-	for (i = 0; i < g_server_dev.config_info.num_config_nodes; i++) {
-		rc = msm_setup_config_dev(i, "config");
-		if (rc < 0) {
-			pr_err("%s:failed to create config dev: %d\n",
-			 __func__, rc);
-			return rc;
-		}
-	}
-
-	return rc;
-}
-
-static int __exit msm_camera_exit(struct platform_device *pdev)
-{
-	return 0;
-}
-
-static const struct of_device_id msm_cam_server_dt_match[] = {
-	{.compatible = "qcom,cam_server"},
-}
-
-MODULE_DEVICE_TABLE(of, msm_cam_server_dt_match);
-
-static struct platform_driver msm_cam_server_driver = {
-	.probe = msm_camera_probe,
-	.remove = msm_camera_exit,
-	.driver = {
-		.name = "msm_cam_server",
-		.owner = THIS_MODULE,
-		.of_match_table = msm_cam_server_dt_match,
-	},
-};
-
-static int __init msm_cam_server_init(void)
-{
-	return platform_driver_register(&msm_cam_server_driver);
-}
-
-static void __exit msm_cam_server_exit(void)
-{
-	platform_driver_unregister(&msm_cam_server_driver);
-}
-
-module_init(msm_cam_server_init);
-module_exit(msm_cam_server_exit);
-MODULE_DESCRIPTION("msm camera server");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/server/msm_cam_server.h b/drivers/media/platform/msm/camera_v1/server/msm_cam_server.h
deleted file mode 100644
index 810830e..0000000
--- a/drivers/media/platform/msm/camera_v1/server/msm_cam_server.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- *
- */
-
-#ifndef _MSM_CAM_SERVER_H
-#define _MSM_CAM_SERVER_H
-
-#include <linux/proc_fs.h>
-#include <linux/ioctl.h>
-#include <mach/camera.h>
-#include "../msm.h"
-
-uint32_t msm_cam_server_get_mctl_handle(void);
-struct iommu_domain *msm_cam_server_get_domain(void);
-int msm_cam_server_get_domain_num(void);
-struct msm_cam_media_controller *msm_cam_server_get_mctl(uint32_t handle);
-void msm_cam_server_free_mctl(uint32_t handle);
-/* Server session control APIs */
-int msm_server_begin_session(struct msm_cam_v4l2_device *pcam,
-	int server_q_idx);
-int msm_server_end_session(struct msm_cam_v4l2_device *pcam);
-int msm_send_open_server(struct msm_cam_v4l2_device *pcam);
-int msm_send_close_server(struct msm_cam_v4l2_device *pcam);
-int msm_server_update_sensor_info(struct msm_cam_v4l2_device *pcam,
-	struct msm_camera_sensor_info *sdata);
-/* Server camera control APIs */
-int msm_server_streamon(struct msm_cam_v4l2_device *pcam, int idx);
-int msm_server_streamoff(struct msm_cam_v4l2_device *pcam, int idx);
-int msm_server_get_usecount(void);
-int32_t msm_find_free_queue(void);
-int msm_server_proc_ctrl_cmd(struct msm_cam_v4l2_device *pcam,
-	struct msm_camera_v4l2_ioctl_t *ioctl_ptr, int is_set_cmd);
-int msm_server_private_general(struct msm_cam_v4l2_device *pcam,
-	struct msm_camera_v4l2_ioctl_t *ioctl_ptr);
-int msm_server_s_ctrl(struct msm_cam_v4l2_device *pcam,
-	struct v4l2_control *ctrl);
-int msm_server_g_ctrl(struct msm_cam_v4l2_device *pcam,
-	struct v4l2_control *ctrl);
-int msm_server_q_ctrl(struct msm_cam_v4l2_device *pcam,
-	struct v4l2_queryctrl *queryctrl);
-int msm_server_set_fmt(struct msm_cam_v4l2_device *pcam, int idx,
-	struct v4l2_format *pfmt);
-int msm_server_set_fmt_mplane(struct msm_cam_v4l2_device *pcam, int idx,
-	struct v4l2_format *pfmt);
-int msm_server_get_fmt(struct msm_cam_v4l2_device *pcam,
-	int idx, struct v4l2_format *pfmt);
-int msm_server_get_fmt_mplane(struct msm_cam_v4l2_device *pcam,
-	int idx, struct v4l2_format *pfmt);
-int msm_server_try_fmt(struct msm_cam_v4l2_device *pcam,
-	struct v4l2_format *pfmt);
-int msm_server_try_fmt_mplane(struct msm_cam_v4l2_device *pcam,
-	struct v4l2_format *pfmt);
-int msm_server_v4l2_subscribe_event(struct v4l2_fh *fh,
-	struct v4l2_event_subscription *sub);
-int msm_server_v4l2_unsubscribe_event(struct v4l2_fh *fh,
-	struct v4l2_event_subscription *sub);
-int msm_server_get_crop(struct msm_cam_v4l2_device *pcam,
-	int idx, struct v4l2_crop *crop);
-int msm_cam_server_request_irq(void *arg);
-int msm_cam_server_update_irqmap(
-	struct msm_cam_server_irqmap_entry *entry);
-int msm_cam_server_config_interface_map(u32 extendedmode,
-	uint32_t mctl_handle, int vnode_id, int is_bayer_sensor);
-#endif /* _MSM_CAM_SERVER_H */
diff --git a/drivers/media/platform/msm/camera_v1/sn12m0pz.c b/drivers/media/platform/msm/camera_v1/sn12m0pz.c
deleted file mode 100644
index 1fcd732..0000000
--- a/drivers/media/platform/msm/camera_v1/sn12m0pz.c
+++ /dev/null
@@ -1,1851 +0,0 @@
-/* Copyright (c) 2010-2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/delay.h>
-#include <linux/types.h>
-#include <linux/i2c.h>
-#include <linux/uaccess.h>
-#include <linux/miscdevice.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <media/msm_camera.h>
-#include <mach/gpio.h>
-#include <mach/camera.h>
-#include <linux/slab.h>
-#include "sn12m0pz.h"
-
-
-#define	Q8					0x00000100
-#define	REG_GROUPED_PARAMETER_HOLD		0x0104
-#define	GROUPED_PARAMETER_HOLD_OFF		0x00
-#define	GROUPED_PARAMETER_HOLD			0x01
-#define	REG_MODE_SELECT				0x0100
-#define	MODE_SELECT_STANDBY_MODE		0x00
-#define	MODE_SELECT_STREAM			0x01
-
-/* Integration Time */
-#define	REG_COARSE_INTEGRATION_TIME_MSB		0x0202
-#define	REG_COARSE_INTEGRATION_TIME_LSB		0x0203
-
-/* Gain */
-#define	REG_ANALOGUE_GAIN_CODE_GLOBAL_MSB	0x0204
-#define	REG_ANALOGUE_GAIN_CODE_GLOBAL_LSB	0x0205
-
-/* PLL Register Defines */
-#define	REG_PLL_MULTIPLIER			0x0307
-#define	REG_0x302B				0x302B
-
-/* MIPI Enable Settings */
-#define	REG_0x30E5				0x30E5
-#define	REG_0x3300				0x3300
-
-/* Global Setting */
-#define	REG_IMAGE_ORIENTATION			0x0101
-
-#define	REG_0x300A				0x300A
-#define	REG_0x3014				0x3014
-#define	REG_0x3015				0x3015
-#define	REG_0x3017				0x3017
-#define	REG_0x301C				0x301C
-#define	REG_0x3031				0x3031
-#define	REG_0x3040				0x3040
-#define	REG_0x3041				0x3041
-#define	REG_0x3051				0x3051
-#define	REG_0x3053				0x3053
-#define	REG_0x3055				0x3055
-#define	REG_0x3057				0x3057
-#define	REG_0x3060				0x3060
-#define	REG_0x3065				0x3065
-#define	REG_0x30AA				0x30AA
-#define	REG_0x30AB				0x30AB
-#define	REG_0x30B0				0x30B0
-#define	REG_0x30B2				0x30B2
-#define	REG_0x30D3				0x30D3
-
-#define	REG_0x3106				0x3106
-#define	REG_0x3108				0x3108
-#define	REG_0x310A				0x310A
-#define	REG_0x310C				0x310C
-#define	REG_0x310E				0x310E
-#define	REG_0x3126				0x3126
-#define	REG_0x312E				0x312E
-#define	REG_0x313C				0x313C
-#define	REG_0x313E				0x313E
-#define	REG_0x3140				0x3140
-#define	REG_0x3142				0x3142
-#define	REG_0x3144				0x3144
-#define	REG_0x3148				0x3148
-#define	REG_0x314A				0x314A
-#define	REG_0x3166				0x3166
-#define	REG_0x3168				0x3168
-#define	REG_0x316F				0x316F
-#define	REG_0x3171				0x3171
-#define	REG_0x3173				0x3173
-#define	REG_0x3175				0x3175
-#define	REG_0x3177				0x3177
-#define	REG_0x3179				0x3179
-#define	REG_0x317B				0x317B
-#define	REG_0x317D				0x317D
-#define	REG_0x317F			0x317F
-#define	REG_0x3181			0x3181
-#define	REG_0x3184			0x3184
-#define	REG_0x3185			0x3185
-#define	REG_0x3187			0x3187
-
-#define	REG_0x31A4			0x31A4
-#define	REG_0x31A6			0x31A6
-#define	REG_0x31AC			0x31AC
-#define	REG_0x31AE			0x31AE
-#define	REG_0x31B4			0x31B4
-#define	REG_0x31B6			0x31B6
-
-#define	REG_0x3254			0x3254
-#define	REG_0x3256			0x3256
-#define	REG_0x3258			0x3258
-#define	REG_0x325A			0x325A
-#define	REG_0x3260			0x3260
-#define	REG_0x3262			0x3262
-
-
-#define	REG_0x3304			0x3304
-#define	REG_0x3305			0x3305
-#define	REG_0x3306			0x3306
-#define	REG_0x3307			0x3307
-#define	REG_0x3308			0x3308
-#define	REG_0x3309			0x3309
-#define	REG_0x330A			0x330A
-#define	REG_0x330B			0x330B
-#define	REG_0x330C			0x330C
-#define	REG_0x330D			0x330D
-
-/* Mode Setting */
-#define	REG_FRAME_LENGTH_LINES_MSB	0x0340
-#define	REG_FRAME_LENGTH_LINES_LSB	0x0341
-#define	REG_LINE_LENGTH_PCK_MSB		0x0342
-#define	REG_LINE_LENGTH_PCK_LSB		0x0343
-#define	REG_X_OUTPUT_SIZE_MSB		0x034C
-#define	REG_X_OUTPUT_SIZE_LSB		0x034D
-#define	REG_Y_OUTPUT_SIZE_MSB		0x034E
-#define	REG_Y_OUTPUT_SIZE_LSB		0x034F
-#define	REG_X_EVEN_INC_LSB		0x0381
-#define	REG_X_ODD_INC_LSB		0x0383
-#define	REG_Y_EVEN_INC_LSB		0x0385
-#define	REG_Y_ODD_INC_LSB		0x0387
-#define	REG_0x3016			0x3016
-#define	REG_0x30E8			0x30E8
-#define	REG_0x3301			0x3301
-/* for 120fps support */
-#define	REG_0x0344			0x0344
-#define	REG_0x0345			0x0345
-#define	REG_0x0346			0x0346
-#define	REG_0x0347			0x0347
-#define	REG_0x0348			0x0348
-#define	REG_0x0349			0x0349
-#define	REG_0x034A			0x034A
-#define	REG_0x034B			0x034B
-
-/* Test Pattern */
-#define	REG_0x30D8			0x30D8
-#define	REG_TEST_PATTERN_MODE		0x0601
-
-/* Solid Color Test Pattern */
-#define	REG_TEST_DATA_RED_MSB		0x0603
-#define	REG_TEST_DATA_RED_LSB		0x0603
-#define	REG_TEST_DATA_GREENR_MSB	0x0604
-#define	REG_TEST_DATA_GREENR_LSB	0x0605
-#define	REG_TEST_DATA_BLUE_MSB		0x0606
-#define	REG_TEST_DATA_BLUE_LSB		0x0607
-#define	REG_TEST_DATA_GREENB_MSB	0x0608
-#define	REG_TEST_DATA_GREENB_LSB	0x0609
-#define	SN12M0PZ_AF_I2C_SLAVE_ID	0xE4
-#define	SN12M0PZ_STEPS_NEAR_TO_CLOSEST_INF	42
-#define	SN12M0PZ_TOTAL_STEPS_NEAR_TO_FAR	42
-
-
-/* TYPE DECLARATIONS */
-
-
-enum mipi_config_type {
-	IU060F_SN12M0PZ_STMIPID01,
-	IU060F_SN12M0PZ_STMIPID02
-};
-
-enum sn12m0pz_test_mode_t {
-	TEST_OFF,
-	TEST_1,
-	TEST_2,
-	TEST_3
-};
-
-enum sn12m0pz_resolution_t {
-	QTR_SIZE,
-	FULL_SIZE,
-	INVALID_SIZE,
-	QVGA_SIZE,
-};
-
-enum sn12m0pz_setting {
-	RES_PREVIEW,
-	RES_CAPTURE,
-	RES_VIDEO_120FPS,
-};
-
-enum mt9p012_reg_update {
-	/* Sensor egisters that need to be updated during initialization */
-	REG_INIT,
-	/* Sensor egisters that needs periodic I2C writes */
-	UPDATE_PERIODIC,
-	/* All the sensor Registers will be updated */
-	UPDATE_ALL,
-	/* Not valid update */
-	UPDATE_INVALID
-};
-
-/* 816x612, 24MHz MCLK 96MHz PCLK */
-#define	IU060F_SN12M0PZ_OFFSET			3
-/* Time in milisecs for waiting for the sensor to reset.*/
-#define	SN12M0PZ_RESET_DELAY_MSECS		66
-#define	SN12M0PZ_WIDTH				4032
-#define	SN12M0PZ_HEIGHT				3024
-#define	SN12M0PZ_FULL_SIZE_WIDTH		4032
-#define	SN12M0PZ_FULL_SIZE_HEIGHT		3024
-#define	SN12M0PZ_HRZ_FULL_BLK_PIXELS		176
-#define	SN12M0PZ_VER_FULL_BLK_LINES		50
-#define	SN12M0PZ_QTR_SIZE_WIDTH			2016
-#define	SN12M0PZ_QTR_SIZE_HEIGHT		1512
-#define	SN12M0PZ_HRZ_QTR_BLK_PIXELS		2192
-#define	SN12M0PZ_VER_QTR_BLK_LINES		26
-
-/* 120fps mode */
-#define	SN12M0PZ_QVGA_SIZE_WIDTH		4032
-#define	SN12M0PZ_QVGA_SIZE_HEIGHT		249
-#define	SN12M0PZ_HRZ_QVGA_BLK_PIXELS		176
-#define	SN12M0PZ_VER_QVGA_BLK_LINES		9
-#define	SN12M0PZ_DEFAULT_CLOCK_RATE		24000000
-
-static uint32_t IU060F_SN12M0PZ_DELAY_MSECS = 30;
-static enum mipi_config_type mipi_config = IU060F_SN12M0PZ_STMIPID02;
-/* AF Tuning Parameters */
-static int16_t enable_single_D02_lane;
-static int16_t fullsize_cropped_at_8mp;
-
-struct sn12m0pz_work_t {
-	struct work_struct work;
-};
-
-static struct sn12m0pz_work_t *sn12m0pz_sensorw;
-static struct i2c_client *sn12m0pz_client;
-
-struct sn12m0pz_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 */
-	uint16_t fps;
-	int16_t curr_lens_pos;
-	uint16_t curr_step_pos;
-	uint16_t my_reg_gain;
-	uint32_t my_reg_line_count;
-	uint16_t total_lines_per_frame;
-	enum sn12m0pz_resolution_t prev_res;
-	enum sn12m0pz_resolution_t pict_res;
-	enum sn12m0pz_resolution_t curr_res;
-	enum sn12m0pz_test_mode_t  set_test;
-	unsigned short imgaddr;
-};
-
-static struct sn12m0pz_ctrl_t *sn12m0pz_ctrl;
-static DECLARE_WAIT_QUEUE_HEAD(sn12m0pz_wait_queue);
-DEFINE_MUTEX(sn12m0pz_mut);
-
-
-static int sn12m0pz_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   = 2,
-			.buf   = rxdata,
-		},
-	};
-
-	if (i2c_transfer(sn12m0pz_client->adapter, msgs, 2) < 0) {
-		CDBG("sn12m0pz_i2c_rxdata failed!");
-		return -EIO;
-	}
-
-	return 0;
-}
-static int32_t sn12m0pz_i2c_txdata(unsigned short saddr,
-				unsigned char *txdata, int length)
-{
-
-	struct i2c_msg msg[] = {
-		{
-			.addr  = saddr,
-			.flags = 0,
-			.len	 = length,
-			.buf	 = txdata,
-		},
-	};
-
-	if (i2c_transfer(sn12m0pz_client->adapter, msg, 1) < 0) {
-		CDBG("sn12m0pz_i2c_txdata faild 0x%x", sn12m0pz_client->addr);
-		return -EIO;
-	}
-
-	return 0;
-}
-
-static int32_t sn12m0pz_i2c_read(unsigned short raddr,
-				unsigned short *rdata, int rlen)
-{
-	int32_t rc;
-	unsigned char buf[2];
-	if (!rdata)
-		return -EIO;
-
-	memset(buf, 0, sizeof(buf));
-
-	buf[0] = (raddr & 0xFF00) >> 8;
-	buf[1] = (raddr & 0x00FF);
-
-	rc = sn12m0pz_i2c_rxdata(sn12m0pz_client->addr, buf, rlen);
-
-	if (rc < 0) {
-		CDBG("sn12m0pz_i2c_read 0x%x failed!", raddr);
-		return rc;
-	}
-
-	*rdata = (rlen == 2 ? buf[0] << 8 | buf[1] : buf[0]);
-
-	return rc;
-}
-
-static int32_t sn12m0pz_i2c_write_b_sensor(unsigned short waddr, uint8_t bdata)
-{
-	int32_t rc;
-	unsigned char buf[3];
-
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00) >> 8;
-	buf[1] = (waddr & 0x00FF);
-	buf[2] = bdata;
-	udelay(90);
-	CDBG("i2c_write_b addr = %x, val = %x\n", waddr, bdata);
-	rc = sn12m0pz_i2c_txdata(sn12m0pz_client->addr, buf, 3);
-
-	if (rc < 0) {
-		CDBG("i2c_write_b failed, addr = 0x%x, val = 0x%x!",
-			waddr, bdata);
-	}
-
-	return rc;
-}
-
-static int16_t sn12m0pz_i2c_write_b_af(unsigned short saddr,
-				unsigned short baddr, unsigned short bdata)
-{
-	int16_t rc;
-	unsigned char buf[2];
-
-	memset(buf, 0, sizeof(buf));
-	buf[0] = baddr;
-	buf[1] = bdata;
-	rc = sn12m0pz_i2c_txdata(saddr, buf, 2);
-
-	if (rc < 0)
-		CDBG("i2c_write failed, saddr = 0x%x addr = 0x%x, val =0x%x!",
-			saddr, baddr, bdata);
-
-	return rc;
-}
-
-static int32_t sn12m0pz_i2c_write_byte_bridge(unsigned short saddr,
-				unsigned short waddr, uint8_t bdata)
-{
-	int32_t rc;
-	unsigned char buf[3];
-
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00) >> 8;
-	buf[1] = (waddr & 0x00FF);
-	buf[2] = bdata;
-
-	CDBG("i2c_write_b addr = %x, val = %x", waddr, bdata);
-	rc = sn12m0pz_i2c_txdata(saddr, buf, 3);
-
-	if (rc < 0)
-		CDBG("i2c_write_b failed, addr = 0x%x, val = 0x%x!",
-			waddr, bdata);
-
-	return rc;
-}
-
-static int32_t sn12m0pz_stmipid01_config(void)
-{
-	int32_t rc = 0;
-	/* Initiate I2C for D01: */
-	/* MIPI Bridge configuration */
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x0002, 0x19) < 0)
-		return rc; /* enable clock lane*/
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x0003, 0x00) < 0)
-		return rc;
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x0004, 0x3E) < 0)
-		return rc; /* mipi mode clock*/
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x0005, 0x01) < 0)
-		return rc; /* enable data line*/
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x0006, 0x0F) < 0)
-		return rc; /* mipi mode data 0x01*/
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x0009, 0x00) < 0)
-		return rc; /* Data_Lane1_Reg1*/
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x000D, 0x92) < 0)
-		return rc; /* CCPRxRegisters*/
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x000E, 0x28) < 0)
-		return rc; /* 10 bits for pixel width input for CCP rx.*/
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x0014, 0xC0) < 0)
-		return rc; /* no bypass, no decomp, 1Lane System,CSIstreaming*/
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x0015, 0x48) < 0)
-		return rc; /* ModeControlRegisters-- Don't reset error flag*/
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x0017, 0x2B) < 0)
-		return rc; /* Data_ID_Rreg*/
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x0018, 0x2B) < 0)
-		return rc; /* Data_ID_Rreg_emb*/
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x0019, 0x0C) < 0)
-		return rc;
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x001E, 0x0A) < 0)
-		return rc;
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x001F, 0x0A) < 0)
-		return rc;
-
-	return rc;
-}
-static int32_t sn12m0pz_stmipid02_config(void)
-{
-	int32_t rc = 0;
-
-	/* Main Camera Clock Lane 1 (CLHP1, CLKN1)*/
-	/* Enable Clock Lane 1 (CLHP1, CLKN1), 0x15 for 400MHz */
-	if (enable_single_D02_lane) {
-		if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x0002, 0x19) < 0)
-			return rc;
-		/* Main Camera Data Lane 1.1 (DATA2P1, DATA2N1) */
-		if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x0009, 0x00) < 0)
-			return rc;/* Enable Data Lane 1.2 (DATA2P1, DATA2N1) */
-		if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x000A, 0x00) < 0)
-			return rc; /*CSIMode on Data Lane1.2(DATA2P1,DATA2N1)*/
-		/* Mode Control */
-		/* Enable single lane for qtr preview */
-		if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x0014, 0xC0) < 0)
-			return rc; /*set 0xC0 - left justified on upper bits)*/
-		/* bit 1 set to 0 i.e. 1 lane system for qtr size preview */
-	} else {
-		if (sn12m0pz_ctrl->prev_res == QVGA_SIZE) {
-			if (sn12m0pz_i2c_write_byte_bridge(0x28>>1,
-				0x0002, 0x19) < 0)
-				return rc;
-		} else {
-			if (sn12m0pz_i2c_write_byte_bridge(0x28>>1,
-				0x0002, 0x21) < 0)
-				return rc;
-		}
-		/* Main Camera Data Lane 1.1 (DATA2P1, DATA2N1) */
-		if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x0009, 0x01) < 0)
-			return rc; /* Enable Data Lane 1.2 (DATA2P1, DATA2N1) */
-		if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x000A, 0x01) < 0)
-			return rc; /* CSI Mode Data Lane1.2(DATA2P1, DATA2N1)*/
-
-		/* Mode Control */
-		/* Enable two lanes for full size preview/ snapshot */
-		if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x0014, 0xC2) < 0)
-			return rc; /* No decompression, CSI dual lane */
-	}
-
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x0004, 0x1E) < 0)
-		return rc;
-
-	/* Main Camera Data Lane 1.1 (DATA1P1, DATA1N1) */
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x0005, 0x03) < 0)
-		return rc; /* Enable Data Lane 1.1 (DATA1P1, DATA1N1) */
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x0006, 0x0f) < 0)
-		return rc; /* CSI Mode on Data Lane 1.1 (DATA1P1, DATA1N1) */
-
-	/* Tristated Output, continuous clock, */
-	/*polarity of clock is inverted and sync signals not inverted*/
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x0015, 0x08) < 0)
-		return rc;
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x0036, 0x20) < 0)
-		return rc; /* Enable compensation macro, main camera */
-
-	/* Data type: 0x2B Raw 10 */
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x0017, 0x2B) < 0)
-		return rc;
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x0018, 0x2B) < 0)
-		return rc; /* Data type of embedded data: 0x2B Raw 10 */
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x0019, 0x0C) < 0)
-		return rc; /* Data type and pixel width programmed 0x0C*/
-
-	/* Decompression Mode */
-
-	/* Pixel Width and Decompression ON/OFF */
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x001E, 0x0A) < 0)
-		return rc; /* Image data not compressed: 0x0A for 10 bits */
-	if (sn12m0pz_i2c_write_byte_bridge(0x28>>1, 0x001F, 0x0A) < 0)
-		return rc; /* Embedded data not compressed: 0x0A for 10 bits */
-	return rc;
-}
-
-static int16_t sn12m0pz_af_init(void)
-{
-	int16_t rc;
-	/* Initialize waveform */
-	rc = sn12m0pz_i2c_write_b_af(SN12M0PZ_AF_I2C_SLAVE_ID >> 1, 0x01, 0xA9);
-
-	rc = sn12m0pz_i2c_write_b_af(SN12M0PZ_AF_I2C_SLAVE_ID >> 1, 0x02, 0xD2);
-
-	rc = sn12m0pz_i2c_write_b_af(SN12M0PZ_AF_I2C_SLAVE_ID >> 1, 0x03, 0x0C);
-
-	rc = sn12m0pz_i2c_write_b_af(SN12M0PZ_AF_I2C_SLAVE_ID >> 1, 0x04, 0x14);
-
-	rc = sn12m0pz_i2c_write_b_af(SN12M0PZ_AF_I2C_SLAVE_ID >> 1, 0x05, 0xB6);
-
-	rc = sn12m0pz_i2c_write_b_af(SN12M0PZ_AF_I2C_SLAVE_ID >> 1, 0x06, 0x4F);
-
-	rc = sn12m0pz_i2c_write_b_af(SN12M0PZ_AF_I2C_SLAVE_ID >> 1, 0x07, 0x00);
-
-	return rc;
-}
-
-static int32_t sn12m0pz_move_focus(int direction,
-	int32_t num_steps)
-{
-	int8_t step_direction, dest_step_position, bit_mask;
-	int32_t rc = 0;
-	uint16_t sn12m0pz_l_region_code_per_step = 3;
-
-	if (num_steps == 0)
-		return rc;
-
-	if (direction == MOVE_NEAR) {
-		step_direction = 1;
-		bit_mask = 0x80;
-	} else if (direction == MOVE_FAR) {
-		step_direction = -1;
-		bit_mask = 0x00;
-	} else {
-		CDBG("sn12m0pz_move_focus: Illegal focus direction");
-		return -EINVAL;
-	}
-
-	dest_step_position = sn12m0pz_ctrl->curr_step_pos +
-		(step_direction * num_steps);
-
-	if (dest_step_position < 0)
-		dest_step_position = 0;
-	else if (dest_step_position > SN12M0PZ_TOTAL_STEPS_NEAR_TO_FAR)
-		dest_step_position = SN12M0PZ_TOTAL_STEPS_NEAR_TO_FAR;
-
-	rc = sn12m0pz_i2c_write_b_af(SN12M0PZ_AF_I2C_SLAVE_ID >> 1, 0x00,
-		((num_steps * sn12m0pz_l_region_code_per_step) | bit_mask));
-
-	sn12m0pz_ctrl->curr_step_pos = dest_step_position;
-
-	return rc;
-}
-static int32_t sn12m0pz_set_default_focus(uint8_t af_step)
-{
-	int32_t rc;
-
-	/* Initialize to infinity */
-
-	rc = sn12m0pz_i2c_write_b_af(SN12M0PZ_AF_I2C_SLAVE_ID >> 1, 0x00, 0x7F);
-
-	rc = sn12m0pz_i2c_write_b_af(SN12M0PZ_AF_I2C_SLAVE_ID >> 1, 0x00, 0x7F);
-
-	sn12m0pz_ctrl->curr_step_pos = 0;
-
-	return rc;
-}
-static void sn12m0pz_get_pict_fps(uint16_t fps, uint16_t *pfps)
-{
-	/* input fps is preview fps in Q8 format */
-	uint16_t preview_frame_length_lines, snapshot_frame_length_lines;
-	uint16_t preview_line_length_pck, snapshot_line_length_pck;
-	uint32_t divider, pclk_mult, d1, d2;
-
-	/* Total frame_length_lines and line_length_pck for preview */
-	CDBG("sn12m0pz_get_pict_fps prev_res %d", sn12m0pz_ctrl->prev_res);
-	if (sn12m0pz_ctrl->prev_res == QVGA_SIZE) {
-		preview_frame_length_lines = SN12M0PZ_QVGA_SIZE_HEIGHT +
-			SN12M0PZ_VER_QVGA_BLK_LINES;
-		preview_line_length_pck = SN12M0PZ_QVGA_SIZE_WIDTH +
-			SN12M0PZ_HRZ_QVGA_BLK_PIXELS;
-	} else {
-		preview_frame_length_lines = SN12M0PZ_QTR_SIZE_HEIGHT +
-			SN12M0PZ_VER_QTR_BLK_LINES;
-		preview_line_length_pck = SN12M0PZ_QTR_SIZE_WIDTH +
-			SN12M0PZ_HRZ_QTR_BLK_PIXELS;
-	}
-	/* Total frame_length_lines and line_length_pck for snapshot */
-	snapshot_frame_length_lines = SN12M0PZ_FULL_SIZE_HEIGHT
-				+ SN12M0PZ_HRZ_FULL_BLK_PIXELS;
-	snapshot_line_length_pck = SN12M0PZ_FULL_SIZE_WIDTH
-				+ SN12M0PZ_HRZ_FULL_BLK_PIXELS;
-	d1 = preview_frame_length_lines *
-				0x00000400 / snapshot_frame_length_lines;
-	d2 = preview_line_length_pck *
-				0x00000400/snapshot_line_length_pck;
-	divider = d1 * d2 / 0x400;
-	pclk_mult =
-		(uint32_t)
-		(sn12m0pz_regs.reg_pat[RES_CAPTURE].pll_multiplier_lsb *
-		0x400) / (uint32_t)
-		sn12m0pz_regs.reg_pat[RES_PREVIEW].pll_multiplier_lsb;
-	*pfps = (uint16_t) (((fps * divider) / 0x400 * pclk_mult) / 0x400);
-}
-
-static uint16_t sn12m0pz_get_prev_lines_pf(void)
-{
-	if (sn12m0pz_ctrl->prev_res == QTR_SIZE)
-		return SN12M0PZ_QTR_SIZE_HEIGHT +
-			SN12M0PZ_VER_QTR_BLK_LINES;
-	else if (sn12m0pz_ctrl->prev_res == QVGA_SIZE)
-		return SN12M0PZ_QVGA_SIZE_HEIGHT +
-			SN12M0PZ_VER_QVGA_BLK_LINES;
-
-	else
-		return SN12M0PZ_FULL_SIZE_HEIGHT +
-			SN12M0PZ_VER_FULL_BLK_LINES;
-}
-
-static uint16_t sn12m0pz_get_prev_pixels_pl(void)
-{
-	if (sn12m0pz_ctrl->prev_res == QTR_SIZE)
-		return SN12M0PZ_QTR_SIZE_WIDTH +
-			SN12M0PZ_HRZ_QTR_BLK_PIXELS;
-	else
-		return SN12M0PZ_FULL_SIZE_WIDTH +
-			SN12M0PZ_HRZ_FULL_BLK_PIXELS;
-}
-
-static uint16_t sn12m0pz_get_pict_lines_pf(void)
-{
-	if (sn12m0pz_ctrl->pict_res == QTR_SIZE)
-		return SN12M0PZ_QTR_SIZE_HEIGHT +
-			SN12M0PZ_VER_QTR_BLK_LINES;
-	else
-		return SN12M0PZ_FULL_SIZE_HEIGHT +
-			SN12M0PZ_VER_FULL_BLK_LINES;
-}
-
-static uint16_t sn12m0pz_get_pict_pixels_pl(void)
-{
-	if (sn12m0pz_ctrl->pict_res == QTR_SIZE)
-		return SN12M0PZ_QTR_SIZE_WIDTH +
-			SN12M0PZ_HRZ_QTR_BLK_PIXELS;
-	else
-		return SN12M0PZ_FULL_SIZE_WIDTH +
-			SN12M0PZ_HRZ_FULL_BLK_PIXELS;
-}
-
-static uint32_t sn12m0pz_get_pict_max_exp_lc(void)
-{
-	if (sn12m0pz_ctrl->pict_res == QTR_SIZE)
-		return (SN12M0PZ_QTR_SIZE_HEIGHT +
-			SN12M0PZ_VER_QTR_BLK_LINES) * 24;
-	else
-		return (SN12M0PZ_FULL_SIZE_HEIGHT +
-			SN12M0PZ_VER_FULL_BLK_LINES) * 24;
-}
-
-static int32_t sn12m0pz_set_fps(struct fps_cfg	*fps)
-{
-	uint16_t total_lines_per_frame;
-	int32_t rc = 0;
-
-	total_lines_per_frame = (uint16_t)((SN12M0PZ_QTR_SIZE_HEIGHT +
-				SN12M0PZ_VER_QTR_BLK_LINES) *
-				sn12m0pz_ctrl->fps_divider / 0x400);
-
-	if (sn12m0pz_i2c_write_b_sensor(REG_FRAME_LENGTH_LINES_MSB,
-				((total_lines_per_frame & 0xFF00) >> 8)) < 0)
-		return rc;
-
-	if (sn12m0pz_i2c_write_b_sensor(REG_FRAME_LENGTH_LINES_LSB,
-				(total_lines_per_frame & 0x00FF)) < 0)
-		return rc;
-
-	return rc;
-}
-
-static int32_t sn12m0pz_write_exp_gain(uint16_t gain, uint32_t line)
-{
-	static uint16_t max_legal_gain = 0x00E0;
-	uint8_t gain_msb, gain_lsb;
-	uint8_t intg_time_msb, intg_time_lsb;
-	uint8_t line_length_pck_msb, line_length_pck_lsb;
-	uint16_t line_length_pck, frame_length_lines, temp_lines;
-	uint32_t line_length_ratio = 1 * Q8;
-	int32_t rc = 0;
-	CDBG("sn12m0pz_write_exp_gain : gain = %d line = %d", gain, line);
-
-	if (sn12m0pz_ctrl->sensormode != SENSOR_SNAPSHOT_MODE) {
-		if (sn12m0pz_ctrl->prev_res == QVGA_SIZE) {
-			frame_length_lines = SN12M0PZ_QVGA_SIZE_HEIGHT +
-						SN12M0PZ_VER_QVGA_BLK_LINES;
-			line_length_pck = SN12M0PZ_QVGA_SIZE_WIDTH +
-						SN12M0PZ_HRZ_QVGA_BLK_PIXELS;
-			if (line > (frame_length_lines -
-					IU060F_SN12M0PZ_OFFSET))
-				line = frame_length_lines -
-						IU060F_SN12M0PZ_OFFSET;
-			sn12m0pz_ctrl->fps = (uint16_t) (120 * Q8);
-		} else {
-			if (sn12m0pz_ctrl->curr_res  == QTR_SIZE) {
-				frame_length_lines = SN12M0PZ_QTR_SIZE_HEIGHT +
-						SN12M0PZ_VER_QTR_BLK_LINES;
-				line_length_pck = SN12M0PZ_QTR_SIZE_WIDTH +
-						SN12M0PZ_HRZ_QTR_BLK_PIXELS;
-			} else {
-				frame_length_lines = SN12M0PZ_HEIGHT +
-						SN12M0PZ_VER_FULL_BLK_LINES;
-				line_length_pck = SN12M0PZ_WIDTH +
-						SN12M0PZ_HRZ_FULL_BLK_PIXELS;
-			}
-			if (line > (frame_length_lines -
-						IU060F_SN12M0PZ_OFFSET))
-				sn12m0pz_ctrl->fps = (uint16_t) (30 * Q8 *
-			(frame_length_lines - IU060F_SN12M0PZ_OFFSET) / line);
-			else
-				sn12m0pz_ctrl->fps = (uint16_t) (30 * Q8);
-		}
-	} else {
-		if (sn12m0pz_ctrl->curr_res  == QTR_SIZE) {
-			frame_length_lines = SN12M0PZ_QTR_SIZE_HEIGHT +
-						SN12M0PZ_VER_QTR_BLK_LINES;
-			line_length_pck = SN12M0PZ_QTR_SIZE_WIDTH +
-						SN12M0PZ_HRZ_QTR_BLK_PIXELS;
-		} else {
-			frame_length_lines = SN12M0PZ_HEIGHT +
-						SN12M0PZ_VER_FULL_BLK_LINES;
-			line_length_pck = SN12M0PZ_WIDTH +
-						SN12M0PZ_HRZ_FULL_BLK_PIXELS;
-		}
-	}
-	if (gain > max_legal_gain)
-		/* range: 0 to 224 */
-		gain = max_legal_gain;
-	temp_lines = line;
-	/* calculate line_length_ratio */
-	if (line > (frame_length_lines - IU060F_SN12M0PZ_OFFSET)) {
-		line_length_ratio = (line * Q8) / (frame_length_lines -
-					IU060F_SN12M0PZ_OFFSET);
-		temp_lines = frame_length_lines - IU060F_SN12M0PZ_OFFSET;
-		if (line_length_ratio == 0)
-			line_length_ratio = 1 * Q8;
-	} else
-		line_length_ratio = 1 * Q8;
-
-	line = (uint32_t) (line * sn12m0pz_ctrl->fps_divider/0x400);
-
-	/* update gain registers */
-	gain_msb = (uint8_t) ((gain & 0xFF00) >> 8);
-	gain_lsb = (uint8_t) (gain & 0x00FF);
-
-	/* linear AFR horizontal stretch */
-	line_length_pck = (uint16_t) (line_length_pck * line_length_ratio / Q8);
-	line_length_pck_msb = (uint8_t) ((line_length_pck & 0xFF00) >> 8);
-	line_length_pck_lsb = (uint8_t) (line_length_pck & 0x00FF);
-
-	/* update line count registers */
-	intg_time_msb = (uint8_t) ((temp_lines & 0xFF00) >> 8);
-	intg_time_lsb = (uint8_t) (temp_lines & 0x00FF);
-
-
-	if (sn12m0pz_i2c_write_b_sensor(REG_GROUPED_PARAMETER_HOLD,
-			GROUPED_PARAMETER_HOLD) < 0)
-		return rc;
-
-	if (sn12m0pz_i2c_write_b_sensor(REG_ANALOGUE_GAIN_CODE_GLOBAL_MSB,
-			gain_msb) < 0)
-		return rc;
-
-	if (sn12m0pz_i2c_write_b_sensor(REG_ANALOGUE_GAIN_CODE_GLOBAL_LSB,
-			gain_lsb) < 0)
-		return rc;
-
-	if (sn12m0pz_i2c_write_b_sensor(REG_LINE_LENGTH_PCK_MSB,
-			line_length_pck_msb) < 0)
-		return rc;
-
-	if (sn12m0pz_i2c_write_b_sensor(REG_LINE_LENGTH_PCK_LSB,
-			line_length_pck_lsb) < 0)
-		return rc;
-
-	if (sn12m0pz_i2c_write_b_sensor(REG_COARSE_INTEGRATION_TIME_MSB,
-			intg_time_msb) < 0)
-		return rc;
-
-	if (sn12m0pz_i2c_write_b_sensor(REG_COARSE_INTEGRATION_TIME_LSB,
-			intg_time_lsb) < 0)
-		return rc;
-
-	if (sn12m0pz_i2c_write_b_sensor(REG_GROUPED_PARAMETER_HOLD,
-			GROUPED_PARAMETER_HOLD_OFF) < 0)
-		return rc;
-
-	return rc;
-}
-
-
-static int32_t sn12m0pz_set_pict_exp_gain(uint16_t gain, uint32_t line)
-{
-	int32_t rc;
-	rc = sn12m0pz_write_exp_gain(gain, line);
-	return rc;
-}
-
-static int32_t sn12m0pz_test(enum sn12m0pz_test_mode_t mo)
-{
-	uint8_t test_data_val_msb = 0x07;
-	uint8_t test_data_val_lsb = 0xFF;
-	int32_t rc = 0;
-	if (mo == TEST_OFF)
-		return rc;
-	else {
-		/* REG_0x30D8[4] is TESBYPEN: 0: Normal Operation,
-		 1: Bypass Signal Processing. REG_0x30D8[5] is EBDMASK:
-		 0: Output Embedded data, 1: No output embedded data */
-
-		if (sn12m0pz_i2c_write_b_sensor(REG_0x30D8, 0x10) < 0)
-			return rc;
-
-		if (sn12m0pz_i2c_write_b_sensor(REG_TEST_PATTERN_MODE,
-			(uint8_t) mo) < 0)
-			return rc;
-
-		/* Solid Color Test Pattern */
-
-		if (mo == TEST_1) {
-			if (sn12m0pz_i2c_write_b_sensor(REG_TEST_DATA_RED_MSB,
-				test_data_val_msb) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_TEST_DATA_RED_LSB,
-				test_data_val_lsb) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(
-						REG_TEST_DATA_GREENR_MSB,
-						test_data_val_msb) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(
-						REG_TEST_DATA_GREENR_LSB,
-						test_data_val_lsb) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_TEST_DATA_BLUE_MSB,
-				test_data_val_msb) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_TEST_DATA_BLUE_LSB,
-				test_data_val_lsb) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(
-						REG_TEST_DATA_GREENB_MSB,
-						test_data_val_msb) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(
-						REG_TEST_DATA_GREENB_LSB,
-						test_data_val_lsb) < 0)
-				return rc;
-		}
-
-	}
-
-	return rc;
-}
-
-static int32_t sn12m0pz_reset(void)
-{
-	int32_t rc = 0;
-	/* register 0x0002 is Port 2, CAM_XCLRO */
-	gpio_direction_output(sn12m0pz_ctrl->
-		sensordata->sensor_reset,
-		0);
-	msleep(50);
-	gpio_direction_output(sn12m0pz_ctrl->
-		sensordata->sensor_reset,
-		1);
-	msleep(13);
-	return rc;
-}
-
-static int32_t sn12m0pz_sensor_setting(int update_type, int rt)
-{
-	uint16_t total_lines_per_frame;
-	int32_t rc = 0;
-
-	switch (update_type) {
-	case UPDATE_PERIODIC:
-		/* Put Sensor into sofware standby mode	*/
-		if (sn12m0pz_i2c_write_b_sensor(REG_MODE_SELECT,
-				MODE_SELECT_STANDBY_MODE) <  0)
-			return rc;
-		msleep(5);
-		/* Hardware reset D02, lane config between full size/qtr size*/
-		rc = sn12m0pz_reset();
-		if (rc < 0)
-			return rc;
-
-		if (sn12m0pz_stmipid02_config() < 0)
-			return rc;
-	case REG_INIT:
-		if (rt == RES_PREVIEW || rt == RES_CAPTURE
-				|| rt == RES_VIDEO_120FPS) {
-			/* reset fps_divider */
-			sn12m0pz_ctrl->fps_divider = 1 * 0x400;
-
-			/* PLL settings */
-			if (sn12m0pz_i2c_write_b_sensor(REG_PLL_MULTIPLIER,
-			sn12m0pz_regs.reg_pat[rt].pll_multiplier_lsb) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x302B,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x302B) < 0)
-				return rc;
-
-			/* MIPI Enable Settings */
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x30E5,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x30E5) < 0)
-				return rc;
-
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3300,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3300) < 0)
-				return rc;
-
-			/* Global Setting */
-			if (
-				sn12m0pz_i2c_write_b_sensor(
-				REG_IMAGE_ORIENTATION,
-				sn12m0pz_regs.reg_pat_init[0].image_orient) < 0)
-				return rc;
-			if (
-				sn12m0pz_i2c_write_b_sensor(
-				REG_COARSE_INTEGRATION_TIME_MSB,
-				sn12m0pz_regs.reg_pat[rt].coarse_integ_time_msb)
-				< 0)
-				return rc;
-			if (
-				sn12m0pz_i2c_write_b_sensor(
-				REG_COARSE_INTEGRATION_TIME_LSB,
-				sn12m0pz_regs.reg_pat[rt].coarse_integ_time_lsb)
-				 < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x300A,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x300A) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3014,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3014) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3015,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3015) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3017,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3017) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x301C,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x301C) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3031,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3031) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3040,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3040) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3041,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3041) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3051,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3051) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3053,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3053) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3055,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3055) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3057,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3057) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3060,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3060) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3065,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3065) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x30AA,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x30AA) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x30AB,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x30AB) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x30B0,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x30B0) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x30B2,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x30B2) < 0)
-				return rc;
-
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x30D3,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x30D3) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x30D8,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x30D8) < 0)
-				return rc;
-
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3106,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3106) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3108,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3108) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x310A,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x310A) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x310C,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x310C) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x310E,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x310E) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3126,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3126) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x312E,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x312E) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x313C,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x313C) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x313E,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x313E) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3140,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3140) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3142,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3142) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3144,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3144) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3148,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3148) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x314A,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x314A) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3166,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3166) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3168,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3168) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x316F,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x316F) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3171,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3171) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3173,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3173) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3175,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3175) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3177,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3177) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3179,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3179) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x317B,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x317B) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x317D,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x317D) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x317F,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x317F) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3181,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3181) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3184,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3184) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3185,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3185) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3187,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3187) < 0)
-				return rc;
-
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x31A4,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x31A4) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x31A6,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x31A6) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x31AC,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x31AC) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x31AE,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x31AE) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x31B4,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x31B4) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x31B6,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x31B6) < 0)
-				return rc;
-
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3254,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3254) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3256,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3256) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3258,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3258) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x325A,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x325A) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3260,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3260) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3262,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3262) < 0)
-				return rc;
-
-
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3304,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3304) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3305,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3305) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3306,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3306) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3307,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3307) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3308,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3308) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3309,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x3309) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x330A,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x330A) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x330B,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x330B) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x330C,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x330C) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x330D,
-				sn12m0pz_regs.reg_pat_init[0].reg_0x330D) < 0)
-				return rc;
-
-			/* Mode setting */
-			/* Update registers with correct
-				 frame_length_line value for AFR */
-			total_lines_per_frame = (uint16_t)(
-			(sn12m0pz_regs.reg_pat[rt].frame_length_lines_msb << 8)
-			& 0xFF00) +
-			sn12m0pz_regs.reg_pat[rt].frame_length_lines_lsb;
-			total_lines_per_frame = total_lines_per_frame *
-					sn12m0pz_ctrl->fps_divider / 0x400;
-
-			if (sn12m0pz_i2c_write_b_sensor(
-					REG_FRAME_LENGTH_LINES_MSB,
-					(total_lines_per_frame & 0xFF00) >> 8)
-					< 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(
-					REG_FRAME_LENGTH_LINES_LSB,
-					(total_lines_per_frame & 0x00FF)) < 0)
-				return rc;
-
-			if (sn12m0pz_i2c_write_b_sensor(REG_LINE_LENGTH_PCK_MSB,
-				sn12m0pz_regs.reg_pat[rt].line_length_pck_msb) <
-				0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_LINE_LENGTH_PCK_LSB,
-				sn12m0pz_regs.reg_pat[rt].line_length_pck_lsb) <
-				0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_X_OUTPUT_SIZE_MSB,
-				sn12m0pz_regs.reg_pat[rt].x_output_size_msb) <
-				0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_X_OUTPUT_SIZE_LSB,
-				sn12m0pz_regs.reg_pat[rt].x_output_size_lsb) <
-				0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_Y_OUTPUT_SIZE_MSB,
-				sn12m0pz_regs.reg_pat[rt].y_output_size_msb) <
-				0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_Y_OUTPUT_SIZE_LSB,
-				sn12m0pz_regs.reg_pat[rt].y_output_size_lsb) <
-				0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_X_EVEN_INC_LSB,
-				sn12m0pz_regs.reg_pat[rt].x_even_inc_lsb) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_X_ODD_INC_LSB,
-				sn12m0pz_regs.reg_pat[rt].x_odd_inc_lsb) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_Y_EVEN_INC_LSB,
-				sn12m0pz_regs.reg_pat[rt].y_even_inc_lsb) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_Y_ODD_INC_LSB,
-				sn12m0pz_regs.reg_pat[rt].y_odd_inc_lsb) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3016,
-				sn12m0pz_regs.reg_pat[rt].reg_0x3016) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x30E8,
-				sn12m0pz_regs.reg_pat[rt].reg_0x30E8) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x3301,
-				sn12m0pz_regs.reg_pat[rt].reg_0x3301) < 0)
-				return rc;
-
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x0344,
-				sn12m0pz_regs.reg_pat[rt].reg_0x0344) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x0345,
-				sn12m0pz_regs.reg_pat[rt].reg_0x0345) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x0346,
-				sn12m0pz_regs.reg_pat[rt].reg_0x0346) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x0347,
-				sn12m0pz_regs.reg_pat[rt].reg_0x0347) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x0348,
-				sn12m0pz_regs.reg_pat[rt].reg_0x0348) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x0349,
-				sn12m0pz_regs.reg_pat[rt].reg_0x0349) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x034A,
-				sn12m0pz_regs.reg_pat[rt].reg_0x034A) < 0)
-				return rc;
-			if (sn12m0pz_i2c_write_b_sensor(REG_0x034B,
-				sn12m0pz_regs.reg_pat[rt].reg_0x034B) < 0)
-				return rc;
-
-			if ((rt == RES_CAPTURE) && fullsize_cropped_at_8mp) {
-				/* x address end */
-				if (sn12m0pz_i2c_write_b_sensor(0x0348,
-								0x0C) < 0)
-					return rc;
-				if (sn12m0pz_i2c_write_b_sensor(0x0349,
-								0x0CF) < 0)
-					return rc;
-				/* y address end */
-				if (sn12m0pz_i2c_write_b_sensor(0x034A,
-								0x09) < 0)
-					return rc;
-				if (sn12m0pz_i2c_write_b_sensor(0x034B,
-								0x9F) < 0)
-					return rc;
-			}
-
-			if (mipi_config == IU060F_SN12M0PZ_STMIPID01) {
-				if (sn12m0pz_i2c_write_b_sensor(
-						REG_PLL_MULTIPLIER, 0x43) < 0)
-					return rc;
-				if (rt == RES_CAPTURE) {
-					if (sn12m0pz_i2c_write_b_sensor(
-						REG_0x3301, 0x01) < 0)
-						return rc;
-				if (sn12m0pz_i2c_write_b_sensor(
-						REG_0x3017, 0xE0) < 0)
-					return rc;
-				}
-			}
-
-			if (sn12m0pz_i2c_write_b_sensor(REG_MODE_SELECT,
-						MODE_SELECT_STREAM) < 0)
-				return rc;
-
-			msleep(IU060F_SN12M0PZ_DELAY_MSECS);
-
-			if (sn12m0pz_test(sn12m0pz_ctrl->set_test) < 0)
-				return rc;
-
-			if (mipi_config == IU060F_SN12M0PZ_STMIPID02)
-				CDBG("%s,%d", __func__, __LINE__);
-			return rc;
-		}
-	default:
-		return rc;
-		}
-}
-
-
-static int32_t sn12m0pz_video_config(int mode)
-{
-
-	int32_t rc = 0;
-	int rt;
-
-
-	if (mode == SENSOR_HFR_120FPS_MODE)
-		sn12m0pz_ctrl->prev_res = QVGA_SIZE;
-
-	/* change sensor resolution if needed */
-	if (sn12m0pz_ctrl->curr_res != sn12m0pz_ctrl->prev_res) {
-		if (sn12m0pz_ctrl->prev_res == QTR_SIZE) {
-			rt = RES_PREVIEW;
-			IU060F_SN12M0PZ_DELAY_MSECS = 35; /*measured on scope*/
-			enable_single_D02_lane = 1;
-		} else if (sn12m0pz_ctrl->prev_res == QVGA_SIZE) {
-			rt = RES_VIDEO_120FPS;
-			IU060F_SN12M0PZ_DELAY_MSECS = 35; /*measured on scope*/
-			enable_single_D02_lane = 0;
-		} else {
-			rt = RES_CAPTURE;
-			enable_single_D02_lane = 0;
-		}
-
-		if (sn12m0pz_sensor_setting(UPDATE_PERIODIC, rt) < 0)
-			return rc;
-	}
-
-	sn12m0pz_ctrl->curr_res = sn12m0pz_ctrl->prev_res;
-	sn12m0pz_ctrl->sensormode = mode;
-
-	return rc;
-}
-static int32_t sn12m0pz_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-	int rt;
-	/* change sensor resolution if needed */
-	if (sn12m0pz_ctrl->curr_res != sn12m0pz_ctrl->pict_res) {
-		if (sn12m0pz_ctrl->pict_res == QTR_SIZE) {
-			rt = RES_PREVIEW;
-			enable_single_D02_lane = 1;
-		} else {
-			rt = RES_CAPTURE;
-			IU060F_SN12M0PZ_DELAY_MSECS = 100;/*measured on scope*/
-			enable_single_D02_lane = 0;
-		}
-
-		if (sn12m0pz_sensor_setting(UPDATE_PERIODIC, rt) < 0)
-			return rc;
-	}
-
-	sn12m0pz_ctrl->curr_res = sn12m0pz_ctrl->pict_res;
-	sn12m0pz_ctrl->sensormode = mode;
-	return rc;
-}
-
-static int32_t sn12m0pz_raw_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-	int rt;
-	/* change sensor resolution if needed */
-	if (sn12m0pz_ctrl->curr_res != sn12m0pz_ctrl->pict_res) {
-		if (sn12m0pz_ctrl->pict_res == QTR_SIZE) {
-			rt = RES_PREVIEW;
-			enable_single_D02_lane = 1;
-		} else {
-			rt = RES_CAPTURE;
-			IU060F_SN12M0PZ_DELAY_MSECS = 100;/*measured on scope*/
-			enable_single_D02_lane = 0;
-		}
-		if (sn12m0pz_sensor_setting(UPDATE_PERIODIC, rt) < 0)
-			return rc;
-		}
-	sn12m0pz_ctrl->curr_res = sn12m0pz_ctrl->pict_res;
-	sn12m0pz_ctrl->sensormode = mode;
-	return rc;
-}
-static int32_t sn12m0pz_set_sensor_mode(int  mode,
-	int  res)
-{
-	int32_t rc;
-
-	switch (mode) {
-	case SENSOR_PREVIEW_MODE:
-	case SENSOR_HFR_120FPS_MODE:
-		rc = sn12m0pz_video_config(mode);
-		break;
-
-	case SENSOR_SNAPSHOT_MODE:
-		rc = sn12m0pz_snapshot_config(mode);
-		break;
-
-	case SENSOR_RAW_SNAPSHOT_MODE:
-		rc = sn12m0pz_raw_snapshot_config(mode);
-		break;
-
-	default:
-		rc = -EINVAL;
-		break;
-	}
-	return rc;
-}
-
-static int32_t sn12m0pz_power_down(void)
-{
-	return 0;
-}
-
-
-static int sn12m0pz_probe_init_done(const struct msm_camera_sensor_info *data)
-{
-
-	gpio_direction_output(data->sensor_reset, 0);
-	gpio_free(data->sensor_reset);
-	gpio_direction_output(data->vcm_pwd, 0);
-	gpio_free(data->vcm_pwd);
-	return 0;
-}
-
-static int sn12m0pz_probe_init_sensor(const struct msm_camera_sensor_info *data)
-{
-	int32_t rc;
-	unsigned short chipidl, chipidh;
-	CDBG("Requesting gpio");
-	rc = gpio_request(data->sensor_reset, "sn12m0pz");
-	CDBG(" sn12m0pz_probe_init_sensor");
-	if (!rc) {
-		gpio_direction_output(data->sensor_reset, 0);
-		msleep(20);
-		gpio_direction_output(data->sensor_reset, 1);
-		msleep(13);
-	} else {
-		goto init_probe_done;
-	}
-	CDBG("Requestion gpio");
-	rc = gpio_request(data->vcm_pwd, "sn12m0pz");
-	CDBG(" sn12m0pz_probe_init_sensor");
-
-	if (!rc) {
-		gpio_direction_output(data->vcm_pwd, 0);
-		msleep(20);
-		gpio_direction_output(data->vcm_pwd, 1);
-		msleep(13);
-	} else {
-		gpio_direction_output(data->sensor_reset, 0);
-		gpio_free(data->sensor_reset);
-		goto init_probe_done;
-	}
-
-	msleep(20);
-
-	/* 3. Read sensor Model ID: */
-	rc = sn12m0pz_i2c_read(0x0000, &chipidh, 1);
-	if (rc < 0) {
-		CDBG(" sn12m0pz_probe_init_sensor3");
-		goto init_probe_fail;
-	}
-	rc = sn12m0pz_i2c_read(0x0001, &chipidl, 1);
-	if (rc < 0) {
-		CDBG(" sn12m0pz_probe_init_sensor4");
-		goto init_probe_fail;
-	}
-
-	/* 4. Compare sensor ID to SN12M0PZ ID: */
-	if (chipidh != 0x00 || chipidl != 0x60) {
-		rc = -ENODEV;
-		CDBG("sn12m0pz_probe_init_sensor fail chip id doesnot match");
-		goto init_probe_fail;
-	}
-
-	msleep(SN12M0PZ_RESET_DELAY_MSECS);
-
-	goto init_probe_done;
-
-init_probe_fail:
-	CDBG(" sn12m0pz_probe_init_sensor fails");
-	sn12m0pz_probe_init_done(data);
-
-init_probe_done:
-	CDBG(" sn12m0pz_probe_init_sensor finishes");
-	return rc;
-}
-
-int sn12m0pz_sensor_open_init(const struct msm_camera_sensor_info *data)
-{
-	int32_t rc = 0;
-	CDBG("Calling sn12m0pz_sensor_open_init");
-
-	sn12m0pz_ctrl = kzalloc(sizeof(struct sn12m0pz_ctrl_t), GFP_KERNEL);
-	if (!sn12m0pz_ctrl) {
-		CDBG("sn12m0pz_init failed!");
-		rc = -ENOMEM;
-		goto init_done;
-	}
-
-	sn12m0pz_ctrl->fps_divider      = 1 * 0x00000400;
-	sn12m0pz_ctrl->pict_fps_divider = 1 * 0x00000400;
-	sn12m0pz_ctrl->set_test = TEST_OFF;
-	sn12m0pz_ctrl->prev_res = QTR_SIZE;
-	sn12m0pz_ctrl->pict_res = FULL_SIZE;
-	sn12m0pz_ctrl->curr_res = INVALID_SIZE;
-	if (data)
-		sn12m0pz_ctrl->sensordata = data;
-
-	if (rc < 0)
-		return rc;
-
-	/* enable mclk first */
-	msm_camio_clk_rate_set(SN12M0PZ_DEFAULT_CLOCK_RATE);
-	msleep(20);
-	msm_camio_camif_pad_reg_reset();
-	msleep(20);
-	CDBG("Calling sn12m0pz_sensor_open_init");
-	rc = sn12m0pz_probe_init_sensor(data);
-
-	if (rc < 0)
-		goto init_fail;
-	/* send reset signal */
-	if (mipi_config == IU060F_SN12M0PZ_STMIPID01) {
-		if (sn12m0pz_stmipid01_config() < 0) {
-			CDBG("Calling sn12m0pz_sensor_open_init fail");
-			return rc;
-		}
-	} else {
-		if (sn12m0pz_ctrl->prev_res  == QTR_SIZE)
-			enable_single_D02_lane = 1;
-		else /* FULL_SIZE */
-			enable_single_D02_lane = 0;
-
-		if (sn12m0pz_stmipid02_config() < 0) {
-			CDBG("Calling sn12m0pz_sensor_open_init fail");
-			return rc;
-		}
-	}
-
-
-	if (sn12m0pz_ctrl->prev_res == QTR_SIZE) {
-		if (sn12m0pz_sensor_setting(REG_INIT, RES_PREVIEW) < 0)
-			return rc;
-	} else if (sn12m0pz_ctrl->prev_res == QVGA_SIZE) {
-		if (sn12m0pz_sensor_setting(REG_INIT, RES_VIDEO_120FPS) < 0)
-			return rc;
-	} else {
-		if (sn12m0pz_sensor_setting(REG_INIT, RES_CAPTURE) < 0)
-			return rc;
-	}
-
-	if (sn12m0pz_af_init() < 0)
-		return rc;
-	sn12m0pz_ctrl->fps = 30*Q8;
-	if (rc < 0)
-		goto init_fail;
-	else
-		goto init_done;
-init_fail:
-	CDBG(" init_fail");
-	sn12m0pz_probe_init_done(data);
-	kfree(sn12m0pz_ctrl);
-init_done:
-	CDBG("init_done");
-	return rc;
-}
-static int __devinit sn12m0pz_init_client(struct i2c_client *client)
-{
-	/* Initialize the MSM_CAMI2C Chip */
-	init_waitqueue_head(&sn12m0pz_wait_queue);
-	return 0;
-}
-
-static const struct i2c_device_id sn12m0pz_i2c_id[] = {
-	{ "sn12m0pz", 0},
-	{ }
-};
-
-static int __devinit sn12m0pz_i2c_probe(struct i2c_client *client,
-	const struct i2c_device_id *id)
-{
-	int rc = 0;
-	CDBG("sn12m0pz_probe called!");
-
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		CDBG("i2c_check_functionality failed");
-		goto probe_failure;
-	}
-
-	sn12m0pz_sensorw = kzalloc(sizeof(struct sn12m0pz_work_t), GFP_KERNEL);
-	if (!sn12m0pz_sensorw) {
-		CDBG("kzalloc failed");
-		rc = -ENOMEM;
-		goto probe_failure;
-	}
-
-	i2c_set_clientdata(client, sn12m0pz_sensorw);
-	sn12m0pz_init_client(client);
-	sn12m0pz_client = client;
-
-	msleep(50);
-
-	CDBG("sn12m0pz_probe successed! rc = %d", rc);
-	return 0;
-
-probe_failure:
-	CDBG("sn12m0pz_probe failed! rc = %d", rc);
-	return rc;
-}
-
-static int __exit sn12m0pz_remove(struct i2c_client *client)
-{
-	struct sn12m0pz_work_t_t *sensorw = i2c_get_clientdata(client);
-	free_irq(client->irq, sensorw);
-	sn12m0pz_client = NULL;
-	kfree(sensorw);
-	return 0;
-}
-
-static struct i2c_driver sn12m0pz_i2c_driver = {
-	.id_table = sn12m0pz_i2c_id,
-	.probe	= sn12m0pz_i2c_probe,
-	.remove = __exit_p(sn12m0pz_i2c_remove),
-	.driver = {
-		.name = "sn12m0pz",
-	},
-};
-
-int sn12m0pz_sensor_config(void __user *argp)
-{
-	struct sensor_cfg_data cdata;
-	int32_t rc = 0;
-	if (copy_from_user(&cdata,
-				(void *)argp,
-				sizeof(struct sensor_cfg_data)))
-		return -EFAULT;
-
-	mutex_lock(&sn12m0pz_mut);
-
-	CDBG("sn12m0pz_sensor_config: cfgtype = %d",
-		cdata.cfgtype);
-	switch (cdata.cfgtype) {
-	case CFG_GET_PICT_FPS:
-		sn12m0pz_get_pict_fps(cdata.cfg.gfps.prevfps,
-					&(cdata.cfg.gfps.pictfps));
-
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PREV_L_PF:
-		cdata.cfg.prevl_pf =
-			sn12m0pz_get_prev_lines_pf();
-
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PREV_P_PL:
-		cdata.cfg.prevp_pl =
-			sn12m0pz_get_prev_pixels_pl();
-
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PICT_L_PF:
-		cdata.cfg.pictl_pf =
-			sn12m0pz_get_pict_lines_pf();
-
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PICT_P_PL:
-		cdata.cfg.pictp_pl =
-			sn12m0pz_get_pict_pixels_pl();
-
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PICT_MAX_EXP_LC:
-		cdata.cfg.pict_max_exp_lc =
-			sn12m0pz_get_pict_max_exp_lc();
-
-		if (copy_to_user((void *)argp,
-			&cdata,
-			sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_SET_FPS:
-	case CFG_SET_PICT_FPS:
-		rc = sn12m0pz_set_fps(&(cdata.cfg.fps));
-		break;
-
-	case CFG_SET_EXP_GAIN:
-		rc =
-			sn12m0pz_write_exp_gain(
-				cdata.cfg.exp_gain.gain,
-				cdata.cfg.exp_gain.line);
-		break;
-	case CFG_SET_PICT_EXP_GAIN:
-		rc =
-			sn12m0pz_set_pict_exp_gain(
-				cdata.cfg.exp_gain.gain,
-				cdata.cfg.exp_gain.line);
-		break;
-
-	case CFG_SET_MODE:
-		rc = sn12m0pz_set_sensor_mode(cdata.mode,
-					cdata.rs);
-		break;
-
-	case CFG_PWR_DOWN:
-		rc = sn12m0pz_power_down();
-		break;
-
-	case CFG_MOVE_FOCUS:
-		rc = sn12m0pz_move_focus(cdata.cfg.focus.dir,
-					cdata.cfg.focus.steps);
-		break;
-
-	case CFG_SET_DEFAULT_FOCUS:
-		rc = sn12m0pz_set_default_focus(cdata.cfg.focus.steps);
-		break;
-
-	case CFG_SET_EFFECT:
-		rc = 0;
-		break;
-	case CFG_SET_LENS_SHADING:
-		rc = 0;
-		break;
-	default:
-		rc = -EFAULT;
-		break;
-	}
-
-	mutex_unlock(&sn12m0pz_mut);
-
-	return rc;
-}
-
-static int sn12m0pz_sensor_release(void)
-{
-	int rc = -EBADF;
-
-	mutex_lock(&sn12m0pz_mut);
-
-	sn12m0pz_power_down();
-
-	gpio_direction_output(sn12m0pz_ctrl->sensordata->sensor_reset,
-		0);
-	gpio_free(sn12m0pz_ctrl->sensordata->sensor_reset);
-
-	gpio_direction_output(sn12m0pz_ctrl->sensordata->vcm_pwd,
-		0);
-	gpio_free(sn12m0pz_ctrl->sensordata->vcm_pwd);
-
-	kfree(sn12m0pz_ctrl);
-	sn12m0pz_ctrl = NULL;
-
-	CDBG("sn12m0pz_release completed");
-
-
-	mutex_unlock(&sn12m0pz_mut);
-
-	return rc;
-}
-
-static int sn12m0pz_sensor_probe(const struct msm_camera_sensor_info *info,
-		struct msm_sensor_ctrl *s)
-{
-	int rc;
-
-	rc = i2c_add_driver(&sn12m0pz_i2c_driver);
-	if (rc < 0 || sn12m0pz_client == NULL) {
-		rc = -ENOTSUPP;
-		goto probe_fail;
-	}
-
-	msm_camio_clk_rate_set(SN12M0PZ_DEFAULT_CLOCK_RATE);
-	msleep(20);
-
-	rc = sn12m0pz_probe_init_sensor(info);
-	if (rc < 0)
-		goto probe_fail;
-
-	s->s_init = sn12m0pz_sensor_open_init;
-	s->s_release = sn12m0pz_sensor_release;
-	s->s_config  = sn12m0pz_sensor_config;
-	s->s_mount_angle  = 0;
-	sn12m0pz_probe_init_done(info);
-
-	return rc;
-
-probe_fail:
-	CDBG("SENSOR PROBE FAILS!");
-	i2c_del_driver(&sn12m0pz_i2c_driver);
-	return rc;
-}
-
-static int __sn12m0pz_probe(struct platform_device *pdev)
-{
-	return msm_camera_drv_start(pdev, sn12m0pz_sensor_probe);
-}
-
-static struct platform_driver msm_camera_driver = {
-	.probe = __sn12m0pz_probe,
-	.driver = {
-		.name = "msm_camera_sn12m0pz",
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init sn12m0pz_init(void)
-{
-	return platform_driver_register(&msm_camera_driver);
-}
-
-module_init(sn12m0pz_init);
-
-MODULE_DESCRIPTION("Sony 12M MP Bayer sensor driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/sn12m0pz.h b/drivers/media/platform/msm/camera_v1/sn12m0pz.h
deleted file mode 100644
index c3d3346..0000000
--- a/drivers/media/platform/msm/camera_v1/sn12m0pz.h
+++ /dev/null
@@ -1,138 +0,0 @@
-
-/* Copyright (c) 2010, The Linux Foundation. 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.
- *
- */
-#ifndef SN12M0PZ_H
-#define SN12M0PZ_H
-
-#include <linux/types.h>
-extern struct sn12m0pz_reg sn12m0pz_regs; /* from mt9t013_reg.c */
-struct reg_struct{
-	uint8_t pll_multiplier_lsb;            /* 0x0307*/
-	uint8_t coarse_integ_time_msb;   /* 0x0202*/
-	uint8_t coarse_integ_time_lsb;   /* 0x0203*/
-	uint8_t frame_length_lines_msb;        /* 0x0340*/
-	uint8_t frame_length_lines_lsb;        /* 0x0341*/
-	uint8_t line_length_pck_msb;           /* 0x0342*/
-	uint8_t line_length_pck_lsb;           /* 0x0343*/
-	uint8_t x_output_size_msb;             /* 0x034C*/
-	uint8_t x_output_size_lsb;             /* 0x034D*/
-	uint8_t y_output_size_msb;             /* 0x034E*/
-	uint8_t y_output_size_lsb;             /* 0x034F*/
-	uint8_t x_even_inc_lsb;                /* 0x0381*/
-	uint8_t x_odd_inc_lsb;                 /* 0x0383*/
-	uint8_t y_even_inc_lsb;                /* 0x0385*/
-	uint8_t y_odd_inc_lsb;                 /* 0x0387*/
-	uint8_t reg_0x3016;                    /* 0x3016 VMODEADD*/
-	uint8_t reg_0x30E8;                    /* 0x30E8 HADDAVE*/
-	uint8_t reg_0x3301;                    /* 0x3301 RGLANESEL*/
-	/*added for 120fps support */
-	uint8_t reg_0x0344;
-	uint8_t reg_0x0345;
-	uint8_t reg_0x0346;
-	uint8_t reg_0x0347;
-	uint8_t reg_0x0348;
-	uint8_t reg_0x0349;
-	uint8_t reg_0x034A;
-	uint8_t reg_0x034B;
-};
-struct reg_struct_init{
-	uint8_t reg_0x302B;/* 0x302B*/
-
-	uint8_t reg_0x30E5;/* 0x30E5*/
-	uint8_t reg_0x3300;   /* 0x3300*/
-
-	uint8_t image_orient;   /* 0x0101*/
-
-	uint8_t reg_0x300A;   /* 0x300A*/
-	uint8_t reg_0x3014;   /* 0x3014*/
-	uint8_t reg_0x3015;   /* 0x3015*/
-	uint8_t reg_0x3017;   /* 0x3017*/
-	uint8_t reg_0x301C;   /* 0x301C*/
-	uint8_t reg_0x3031;   /* 0x3031*/
-	uint8_t reg_0x3040;   /* 0x3040*/
-	uint8_t reg_0x3041;   /* 0x3041*/
-	uint8_t reg_0x3051;   /* 0x3051*/
-	uint8_t reg_0x3053;   /* 0x3053*/
-	uint8_t reg_0x3055;   /* 0x3055*/
-	uint8_t reg_0x3057;   /* 0x3057*/
-	uint8_t reg_0x3060;   /* 0x3060*/
-	uint8_t reg_0x3065;   /* 0x3065*/
-	uint8_t reg_0x30AA;   /* 0x30AA*/
-	uint8_t reg_0x30AB;   /* 0x30AB*/
-	uint8_t reg_0x30B0;   /* 0x30B0*/
-	uint8_t reg_0x30B2;   /* 0x30B2*/
-
-	uint8_t reg_0x30D3;   /* 0X30D3*/
-	uint8_t reg_0x30D8;   /* 0X30D8*/
-
-	uint8_t reg_0x3106;   /* 0x3106*/
-	uint8_t reg_0x3108;   /* 0x3108*/
-	uint8_t reg_0x310A;   /* 0x310A*/
-	uint8_t reg_0x310C;   /* 0x310C*/
-	uint8_t reg_0x310E;   /* 0x310E*/
-	uint8_t reg_0x3126;   /* 0x3126*/
-	uint8_t reg_0x312E;   /* 0x312E*/
-	uint8_t reg_0x313C;   /* 0x313C*/
-	uint8_t reg_0x313E;   /* 0x313E*/
-	uint8_t reg_0x3140;   /* 0x3140*/
-	uint8_t reg_0x3142;   /* 0x3142*/
-	uint8_t reg_0x3144;   /* 0x3144*/
-	uint8_t reg_0x3148;   /* 0x3148*/
-	uint8_t reg_0x314A;   /* 0x314A*/
-	uint8_t reg_0x3166;   /* 0x3166*/
-	uint8_t reg_0x3168;   /* 0x3168*/
-	uint8_t reg_0x316F;   /* 0x316F*/
-	uint8_t reg_0x3171;   /* 0x3171*/
-	uint8_t reg_0x3173;   /* 0x3173*/
-	uint8_t reg_0x3175;   /* 0x3175*/
-	uint8_t reg_0x3177;   /* 0x3177*/
-	uint8_t reg_0x3179;   /* 0x3179*/
-	uint8_t reg_0x317B;   /* 0x317B*/
-	uint8_t reg_0x317D;   /* 0x317D*/
-	uint8_t reg_0x317F;   /* 0x317F*/
-	uint8_t reg_0x3181;   /* 0x3181*/
-	uint8_t reg_0x3184;   /* 0x3184*/
-	uint8_t reg_0x3185;   /* 0x3185*/
-	uint8_t reg_0x3187;   /* 0x3187*/
-
-	uint8_t reg_0x31A4;   /* 0x31A4*/
-	uint8_t reg_0x31A6;   /* 0x31A6*/
-	uint8_t reg_0x31AC;   /* 0x31AC*/
-	uint8_t reg_0x31AE;   /* 0x31AE*/
-	uint8_t reg_0x31B4;   /* 0x31B4*/
-	uint8_t reg_0x31B6;   /* 0x31B6*/
-
-	uint8_t reg_0x3254;   /* 0x3254*/
-	uint8_t reg_0x3256;   /* 0x3256*/
-	uint8_t reg_0x3258;   /* 0x3258*/
-	uint8_t reg_0x325A;   /* 0x325A*/
-	uint8_t reg_0x3260;   /* 0x3260*/
-	uint8_t reg_0x3262;   /* 0x3262*/
-
-	uint8_t reg_0x3304;   /* 0x3304*/
-	uint8_t reg_0x3305;   /* 0x3305*/
-	uint8_t reg_0x3306;   /* 0x3306*/
-	uint8_t reg_0x3307;   /* 0x3307*/
-	uint8_t reg_0x3308;   /* 0x3308*/
-	uint8_t reg_0x3309;   /* 0x3309*/
-	uint8_t reg_0x330A;   /* 0x330A*/
-	uint8_t reg_0x330B;   /* 0x330B*/
-	uint8_t reg_0x330C;   /* 0x330C*/
-	uint8_t reg_0x330D;   /* 0x330D*/
-
-};
-struct sn12m0pz_reg{
-	const struct reg_struct  *reg_pat;
-	const struct reg_struct_init  *reg_pat_init;
-};
-#endif
diff --git a/drivers/media/platform/msm/camera_v1/sn12m0pz_reg.c b/drivers/media/platform/msm/camera_v1/sn12m0pz_reg.c
deleted file mode 100644
index c406d98..0000000
--- a/drivers/media/platform/msm/camera_v1/sn12m0pz_reg.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/* Copyright (c) 2010, The Linux Foundation. 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.
- *
- */
-
-#include "sn12m0pz.h"
-/* Initialisation settings */
-
-const struct reg_struct_init iu060f_reg_pat_init[1] = {{
-	/* PLL setting */
-	0x4B, /* reg 0x302B*/
-	/* MIPI Enable Setting */
-	0x04, /* reg 0x30E5*/
-	0x00, /* reg 0x3300*/
-	/* Global Setting */
-	0x00, /* image_orientation*/
-	0x80, /* reg 0x300A*/
-	0x08, /* reg 0x3014*/
-	0x37, /* reg 0x3015*/
-	0x60, /* reg 0x3017*/
-	0x01, /* reg 0x301C*/
-	0x28, /* reg 0x3031*/
-	0x00, /* reg 0x3040*/
-	0x60, /* reg 0x3041*/
-	0x24, /* reg 0x3051*/
-	0x34, /* reg 0x3053*/
-	0x3B, /* reg 0x3055*/
-	0xC0, /* reg 0x3057*/
-	0x30, /* reg 0x3060*/
-	0x00, /* reg 0x3065*/
-	0x88, /* reg 0x30AA*/
-	0x1C, /* reg 0x30AB*/
-	0x32, /* reg 0x30B0*/
-	0x83, /* reg 0x30B2*/
-	0x04, /* reg 0x30D3*/
-	0xC0, /* reg 0x30D8*/
-	0x50, /* reg 0x3106*/
-	0xA5, /* reg 0x3108*/
-	0xA9, /* reg 0x310A*/
-	0x0C, /* reg 0x310C*/
-	0x55, /* reg 0x310E*/
-	0xCC, /* reg 0x3126*/
-	0x83, /* reg 0x312E*/
-	0xC7, /* reg 0x313C*/
-	0x07, /* reg 0x313E*/
-	0x32, /* reg 0x3140*/
-	0x35, /* reg 0x3142*/
-	0x35, /* reg 0x3144*/
-	0x73, /* reg 0x3148*/
-	0x80, /* reg 0x314A*/
-	0xBE, /* reg 0x3166*/
-	0xBD, /* reg 0x3168*/
-	0x82, /* reg 0x316F*/
-	0xBC, /* reg 0x3171*/
-	0x82, /* reg 0x3173*/
-	0xBC, /* reg 0x3175*/
-	0x0C, /* reg 0x3177*/
-	0x2C, /* reg 0x3179*/
-	0x83, /* reg 0x317B*/
-	0xAF, /* reg 0x317D*/
-	0x83, /* reg 0x317F*/
-	0xAF, /* reg 0x3181*/
-	0x06, /* reg 0x3184*/
-	0xBA, /* reg 0x3185*/
-	0xBE, /* reg 0x3187*/
-	0xD8, /* reg 0x31A4*/
-	0x17, /* reg 0x31A6*/
-	0xCF, /* reg 0x31AC*/
-	0xF1, /* reg 0x31AE*/
-	0xD8, /* reg 0x31B4*/
-	0x17, /* reg 0x31B6*/
-	0x09, /* reg 0x3254 */
-	0xC5, /* reg 0x3256 */
-	0x84, /* reg 0x3258 */
-	0x6C, /* reg 0x325A */
-	0x0B, /* reg 0x3260 */
-	0x09, /* reg 0x3262 */
-	0x05, /* reg 0x3304*/
-	0x04, /* reg 0x3305*/
-	0x15, /* reg 0x3306*/
-	0x03, /* reg 0x3307*/
-	0x13, /* reg 0x3308*/
-	0x05, /* reg 0x3309*/
-	0x0B, /* reg 0x330A*/
-	0x04, /* reg 0x330B*/
-	0x0B, /* reg 0x330C*/
-	0x06  /* reg 0x330D*/
-}
-};
-
-/* Preview / Snapshot register settings */
-const struct reg_struct iu060f_reg_pat[3] = {
-	{ /* Preview */
-		0x22, /*0x1b*/ /* fps*/
-
-		/* Global Setting */
-		0x01, /* coarse_integration_time_msb*/
-		0xFF, /* coarse_integration_time_lsb*/
-
-		/* Mode Setting */
-		/* V: 1/2 V-addition (1,3),
-		H: 1/2 H-averaging (1,3) */
-
-		0x06, /* frame_length_lines_msb     0x0340*/
-		0x02, /* frame_length_lines_lsb     0x0341*/
-		0x10, /* line_length_pck_msb        0x0342*/
-		0x70, /* line_length_pck_lsb        0x0343*/
-		0x07, /* x_output_size_msb          0x034C*/
-		0xe0, /* x_output_size_lsb          0x034D*/
-		0x05, /* y_output_size_msb          0x034E*/
-		0xe8, /* y_output_size_lsb          0x034F*/
-		0x01, /* x_even_inc_lsb             0x0381*/
-		0x03, /* x_odd_inc_lsb              0x0383*/
-		0x01, /* y_even_inc_lsb             0x0385*/
-		0x03, /* y_odd_inc_lsb              0x0387*/
-		0x46, /* reg 0x3016 VMODEADD        0x3016*/
-		0x86, /* reg 0x30E8 HADDAVE         0x30E8*/
-		0x01, /* reg 0x3301 RGLANESEL       0x3301*/
-
-		0x00,  /* 0x0344 */
-		0x00,  /* 0x0345 */
-		0x00,  /* 0x0346 */
-		0x00,  /* 0x0347 */
-		0x0F,  /* 0x0348 */
-		0xBF,  /* 0x0349 */
-		0x0B,  /* 0x034A */
-		0xCF,  /* 0x034B */
-	},
-	{ /* Snapshot */
-		0x14, /* pll_multiplier_lsb    // 20/10 fps*/
-		/* 0x14 for pclk 96MHz at 7.5 fps */
-
-		/* Global Setting */
-		0x0B, /* coarse_integration_time_msb*/
-		0xFF, /* coarse_integration_time_lsb*/
-
-		/* Mode Setting */
-		/* Full */
-		0x0C,/*frame_length_lines_msb 0x0340*/
-		0x02,/*frame_length_lines_lsb 0x0341*/
-		0x10,/*line_length_pck_msb 0x0342*/
-		0x70,/* line_length_pck_lsb 0x0343*/
-		0x0F,/* x_output_size_msb   0x034C*/
-		0xC0, /* x_output_size_lsb  0x034D*/
-		0x0B, /* y_output_size_msb  0x034E*/
-		0xD0, /* y_output_size_lsb  0x034F*/
-		0x01, /* x_even_inc_lsb     0x0381*/
-		0x01, /* x_odd_inc_lsb      0x0383*/
-		0x01, /* y_even_inc_lsb                     0x0385*/
-		0x01, /* y_odd_inc_lsb                      0x0387*/
-		0x06, /* reg 0x3016 VMODEADD                0x3016*/
-		0x06, /* reg 0x30E8 HADDAVE                 0x30E8*/
-		0x00, /* reg 0x3301 RGLANESEL               0x3301*/
-
-		0x00,  /* 0x0344 */
-		0x00,  /* 0x0345 */
-		0x00,  /* 0x0346 */
-		0x00,  /* 0x0347 */
-		0x0F,  /* 0x0348 */
-		0xBF,  /* 0x0349 */
-		0x0B,  /* 0x034A */
-		0xCF,  /* 0x034B */
-	},
-	/* 120 fps settings */
-	{
-		0x1B, /*0x1B fps*/
-		/* Global Setting */
-		0x00, /* coarse_integration_time_msb*/
-		0xFE, /* coarse_integration_time_lsb*/
-
-		/* Mode Setting */
-		/* V: 1/8 V-addition (9,7),
-		H: Full */
-
-		0x01, /* frame_length_lines_msb     0x0340*/
-		0x01, /* frame_length_lines_lsb     0x0341*/
-		0x10, /* line_length_pck_msb        0x0342*/
-		0x70, /* line_length_pck_lsb        0x0343*/
-		0x0f, /* x_output_size_msb          0x034C*/
-		0xc0, /* x_output_size_lsb          0x034D*/
-		0x00, /* y_output_size_msb          0x034E*/
-		0xF8, /* y_output_size_lsb          0x034F*/
-		0x01, /* x_even_inc_lsb             0x0381*/
-		0x01, /* x_odd_inc_lsb              0x0383*/
-		0x09, /* y_even_inc_lsb             0x0385*/
-		0x07, /* y_odd_inc_lsb              0x0387*/
-		0x46, /* reg 0x3016 VMODEADD        0x3016*/
-		0x86, /* reg 0x30E8 HADDAVE         0x30E8*/
-		0x00, /* reg 0x3301 RGLANESEL       0x3301*/
-		/* add for 120fps support */
-		0x00, /* 0x0344*/
-		0x00, /* 0x0345*/
-		0x02, /* 0x0346*/
-		0x10, /* 0x0347*/
-		0x0F, /* 0x0348*/
-		0xBF, /* 0x0349*/
-		0x09, /* 0x034A*/
-		0xCF, /* 0x034B*/
-	}
-};
-struct sn12m0pz_reg sn12m0pz_regs = {
-	.reg_pat = &iu060f_reg_pat[0],
-	.reg_pat_init = &iu060f_reg_pat_init[0],
-};
-
diff --git a/drivers/media/platform/msm/camera_v1/vb6801.c b/drivers/media/platform/msm/camera_v1/vb6801.c
deleted file mode 100644
index f916a1c..0000000
--- a/drivers/media/platform/msm/camera_v1/vb6801.c
+++ /dev/null
@@ -1,1616 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-
-#include <linux/delay.h>
-#include <linux/types.h>
-#include <linux/i2c.h>
-#include <linux/uaccess.h>
-#include <linux/miscdevice.h>
-#include <media/msm_camera.h>
-#include <mach/gpio.h>
-#include <mach/camera.h>
-#include "vb6801.h"
-
-/*=============================================================
-	SENSOR REGISTER DEFINES
-==============================================================*/
-enum {
-	REG_HOLD = 0x0104,
-	RELEASE_HOLD = 0x0000,
-	HOLD = 0x0001,
-	STANDBY_MODE = 0x0000,
-	REG_COARSE_INTEGRATION_TIME = 0x0202,
-	REG_ANALOGUE_GAIN_CODE_GLOBAL = 0x0204,
-	REG_RAMP_SCALE = 0x3116,
-	REG_POWER_MAN_ENABLE_3 = 0x3142,
-	REG_POWER_MAN_ENABLE_4 = 0x3143,
-	REG_POWER_MAN_ENABLE_5 = 0x3144,
-	REG_CCP2_DATA_FORMAT = 0x0112,
-	REG_PRE_PLL_CLK_DIV = 0x0304,
-	REG_PLL_MULTIPLIER = 0x0306,
-	REG_VT_SYS_CLK_DIV = 0x0302,
-	REG_VT_PIX_CLK_DIV = 0x0300,
-	REG_OP_SYS_CLK_DIV = 0x030A,
-	REG_OP_PIX_CLK_DIV = 0x0308,
-	REG_VT_LINE_LENGTH_PCK = 0x0342,
-	REG_X_OUTPUT_SIZE = 0x034C,
-	REG_Y_OUTPUT_SIZE = 0x034E,
-	REG_X_ODD_INC = 0x0382,
-	REG_Y_ODD_INC = 0x0386,
-	REG_VT_FRAME_LENGTH_LINES = 0x0340,
-	REG_ANALOG_TIMING_MODES_2 = 0x3113,
-	REG_BRUCE_ENABLE = 0x37B0,
-	REG_OP_CODER_SYNC_CLK_SETUP = 0x3400,
-	REG_OP_CODER_ENABLE = 0x3401,
-	REG_OP_CODER_SLOW_PAD_EN = 0x3402,
-	REG_OP_CODER_AUTO_STARTUP = 0x3414,
-	REG_SCYTHE_ENABLE = 0x3204,
-	REG_SCYTHE_WEIGHT = 0x3206,
-	REG_FRAME_COUNT = 0x0005,
-	REG_MODE_SELECT = 0x0100,
-	REG_CCP2_CHANNEL_IDENTIFIER = 0x0110,
-	REG_CCP2_SIGNALLING_MODE = 0x0111,
-	REG_BTL_LEVEL_SETUP = 0x311B,
-	REG_OP_CODER_AUTOMATIC_MODE_ENABLE = 0x3403,
-	REG_PLL_CTRL = 0x3801,
-	REG_VCM_DAC_CODE = 0x3860,
-	REG_VCM_DAC_STROBE = 0x3868,
-	REG_VCM_DAC_ENABLE = 0x386C,
-	REG_NVM_T1_ADDR_00 = 0x3600,
-	REG_NVM_T1_ADDR_01 = 0x3601,
-	REG_NVM_T1_ADDR_02 = 0x3602,
-	REG_NVM_T1_ADDR_03 = 0x3603,
-	REG_NVM_T1_ADDR_04 = 0x3604,
-	REG_NVM_T1_ADDR_05 = 0x3605,
-	REG_NVM_T1_ADDR_06 = 0x3606,
-	REG_NVM_T1_ADDR_07 = 0x3607,
-	REG_NVM_T1_ADDR_08 = 0x3608,
-	REG_NVM_T1_ADDR_09 = 0x3609,
-	REG_NVM_T1_ADDR_0A = 0x360A,
-	REG_NVM_T1_ADDR_0B = 0x360B,
-	REG_NVM_T1_ADDR_0C = 0x360C,
-	REG_NVM_T1_ADDR_0D = 0x360D,
-	REG_NVM_T1_ADDR_0E = 0x360E,
-	REG_NVM_T1_ADDR_0F = 0x360F,
-	REG_NVM_T1_ADDR_10 = 0x3610,
-	REG_NVM_T1_ADDR_11 = 0x3611,
-	REG_NVM_T1_ADDR_12 = 0x3612,
-	REG_NVM_T1_ADDR_13 = 0x3613,
-	REG_NVM_CTRL = 0x3680,
-	REG_NVM_PDN = 0x3681,
-	REG_NVM_PULSE_WIDTH = 0x368B,
-};
-
-#define VB6801_LINES_PER_FRAME_PREVIEW   800
-#define VB6801_LINES_PER_FRAME_SNAPSHOT 1600
-#define VB6801_PIXELS_PER_LINE_PREVIEW  2500
-#define VB6801_PIXELS_PER_LINE_SNAPSHOT 2500
-
-/* AF constant */
-#define VB6801_TOTAL_STEPS_NEAR_TO_FAR    25
-#define VB6801_STEPS_NEAR_TO_CLOSEST_INF  25
-
-/* for 30 fps preview */
-#define VB6801_DEFAULT_CLOCK_RATE    12000000
-
-enum vb6801_test_mode_t {
-	TEST_OFF,
-	TEST_1,
-	TEST_2,
-	TEST_3
-};
-
-enum vb6801_resolution_t {
-	QTR_SIZE,
-	FULL_SIZE,
-	INVALID_SIZE
-};
-
-enum vb6801_setting_t {
-	RES_PREVIEW,
-	RES_CAPTURE
-};
-
-struct vb6801_work_t {
-	struct work_struct work;
-};
-
-struct sensor_dynamic_params_t {
-	uint16_t preview_pixelsPerLine;
-	uint16_t preview_linesPerFrame;
-	uint16_t snapshot_pixelsPerLine;
-	uint16_t snapshot_linesPerFrame;
-	uint8_t snapshot_changed_fps;
-	uint32_t pclk;
-};
-
-struct vb6801_sensor_info {
-	/* Sensor Configuration Input Parameters */
-	uint32_t ext_clk_freq_mhz;
-	uint32_t target_frame_rate_fps;
-	uint32_t target_vt_pix_clk_freq_mhz;
-	uint32_t sub_sampling_factor;
-	uint32_t analog_binning_allowed;
-	uint32_t raw_mode;
-	uint32_t capture_mode;
-
-	/* Image Readout Registers */
-	uint32_t x_odd_inc;	/* x pixel array addressing odd increment */
-	uint32_t y_odd_inc;	/* y pixel array addressing odd increment */
-	uint32_t x_output_size;	/* width of output image  */
-	uint32_t y_output_size;	/* height of output image */
-
-	/* Declare data format */
-	uint32_t ccp2_data_format;
-
-	/* Clock Tree Registers */
-	uint32_t pre_pll_clk_div;
-	uint32_t pll_multiplier;
-	uint32_t vt_sys_clk_div;
-	uint32_t vt_pix_clk_div;
-	uint32_t op_sys_clk_div;
-	uint32_t op_pix_clk_div;
-
-	/* Video Timing Registers */
-	uint32_t vt_line_length_pck;
-	uint32_t vt_frame_length_lines;
-
-	/* Analogue Binning Registers */
-	uint8_t vtiming_major;
-	uint8_t analog_timing_modes_4;
-
-	/* Fine (pixel) Integration Time Registers */
-	uint32_t fine_integration_time;
-
-	/* Coarse (lines) Integration Time Limit Registers */
-	uint32_t coarse_integration_time_max;
-
-	/* Coarse (lines) Integration Timit Register (16-bit) */
-	uint32_t coarse_integration_time;
-
-	/* Analogue Gain Code Global Registers */
-	uint32_t analogue_gain_code_global;
-
-	/* Digital Gain Code Registers */
-	uint32_t digital_gain_code;
-
-	/* Overall gain (analogue & digital) code
-	 * Note that this is not a real register but just
-	 * an abstraction for the combination of analogue
-	 * and digital gain */
-	uint32_t gain_code;
-
-	/* FMT Test Information */
-	uint32_t pass_fail;
-	uint32_t day;
-	uint32_t month;
-	uint32_t year;
-	uint32_t tester;
-	uint32_t part_number;
-
-	/* Autofocus controls */
-	uint32_t vcm_dac_code;
-	int vcm_max_dac_code_step;
-	int vcm_proportional_factor;
-	int vcm_dac_code_spacing_ms;
-
-	/* VCM NVM Characterisation Information */
-	uint32_t vcm_dac_code_infinity_dn;
-	uint32_t vcm_dac_code_macro_up;
-	uint32_t vcm_dac_code_up_dn_delta;
-
-	/* Internal Variables */
-	uint32_t min_vt_frame_length_lines;
-};
-
-struct vb6801_work_t *vb6801_sensorw;
-struct i2c_client *vb6801_client;
-
-struct vb6801_ctrl_t {
-	const struct msm_camera_sensor_info *sensordata;
-
-	int sensormode;
-	uint32_t factor_fps;	/* init to 1 * 0x00000400 */
-	uint16_t curr_fps;
-	uint16_t max_fps;
-	int8_t pict_exp_update;
-	int8_t reducel;
-	uint16_t curr_lens_pos;
-	uint16_t init_curr_lens_pos;
-	enum vb6801_resolution_t prev_res;
-	enum vb6801_resolution_t pict_res;
-	enum vb6801_resolution_t curr_res;
-	enum vb6801_test_mode_t set_test;
-
-	struct vb6801_sensor_info s_info;
-	struct sensor_dynamic_params_t s_dynamic_params;
-};
-
-static struct vb6801_ctrl_t *vb6801_ctrl;
-static DECLARE_WAIT_QUEUE_HEAD(vb6801_wait_queue);
-DEFINE_MUTEX(vb6801_mut);
-
-static int vb6801_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 = 2,
-			.buf = rxdata,
-		},
-	};
-
-	if (i2c_transfer(vb6801_client->adapter, msgs, 2) < 0) {
-		CDBG("vb6801_i2c_rxdata failed!\n");
-		return -EIO;
-	}
-
-	return 0;
-}
-
-static int32_t vb6801_i2c_read(unsigned short raddr,
-			       unsigned short *rdata, int rlen)
-{
-	int32_t rc = 0;
-	unsigned char buf[2];
-
-	if (!rdata)
-		return -EIO;
-
-	memset(buf, 0, sizeof(buf));
-
-	buf[0] = (raddr & 0xFF00) >> 8;
-	buf[1] = (raddr & 0x00FF);
-
-	rc = vb6801_i2c_rxdata(vb6801_client->addr, buf, rlen);
-
-	if (rc < 0) {
-		CDBG("vb6801_i2c_read 0x%x failed!\n", raddr);
-		return rc;
-	}
-
-	*rdata = (rlen == 2 ? buf[0] << 8 | buf[1] : buf[0]);
-
-	return rc;
-}
-
-static int32_t vb6801_i2c_read_table(struct vb6801_i2c_reg_conf_t *regs,
-				     int items)
-{
-	int i;
-	int32_t rc = -EFAULT;
-
-	for (i = 0; i < items; i++) {
-		unsigned short *buf =
-		    regs->dlen == D_LEN_BYTE ?
-		    (unsigned short *)&regs->bdata :
-		    (unsigned short *)&regs->wdata;
-		rc = vb6801_i2c_read(regs->waddr, buf, regs->dlen + 1);
-
-		if (rc < 0) {
-			CDBG("vb6801_i2c_read_table Failed!!!\n");
-			break;
-		}
-
-		regs++;
-	}
-
-	return rc;
-}
-
-static int32_t vb6801_i2c_txdata(unsigned short saddr,
-				 unsigned char *txdata, int length)
-{
-	struct i2c_msg msg[] = {
-		{
-			.addr = saddr,
-			.flags = 0,
-			.len = length,
-			.buf = txdata,
-		},
-	};
-
-	if (i2c_transfer(vb6801_client->adapter, msg, 1) < 0) {
-		CDBG("vb6801_i2c_txdata faild 0x%x\n", vb6801_client->addr);
-		return -EIO;
-	}
-
-	return 0;
-}
-
-static int32_t vb6801_i2c_write_b(unsigned short waddr, uint8_t bdata)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[3];
-
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00) >> 8;
-	buf[1] = (waddr & 0x00FF);
-	buf[2] = bdata;
-
-	CDBG("i2c_write_b addr = %d, val = %d\n", waddr, bdata);
-	rc = vb6801_i2c_txdata(vb6801_client->addr, buf, 3);
-
-	if (rc < 0) {
-		CDBG("i2c_write_b failed, addr = 0x%x, val = 0x%x!\n",
-		     waddr, bdata);
-	}
-
-	return rc;
-}
-
-static int32_t vb6801_i2c_write_w(unsigned short waddr, unsigned short wdata)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[4];
-
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00) >> 8;
-	buf[1] = (waddr & 0x00FF);
-	buf[2] = (wdata & 0xFF00) >> 8;
-	buf[3] = (wdata & 0x00FF);
-
-	CDBG("i2c_write_w addr = %d, val = %d, buf[2] = 0x%x, buf[3] = 0x%x\n",
-	     waddr, wdata, buf[2], buf[3]);
-
-	rc = vb6801_i2c_txdata(vb6801_client->addr, buf, 4);
-	if (rc < 0) {
-		CDBG("i2c_write_w failed, addr = 0x%x, val = 0x%x!\n",
-		     waddr, wdata);
-	}
-
-	return rc;
-}
-
-static int32_t vb6801_i2c_write_table(struct vb6801_i2c_reg_conf_t *regs,
-				      int items)
-{
-	int i;
-	int32_t rc = -EFAULT;
-
-	for (i = 0; i < items; i++) {
-		rc = ((regs->dlen == D_LEN_BYTE) ?
-		      vb6801_i2c_write_b(regs->waddr, regs->bdata) :
-		      vb6801_i2c_write_w(regs->waddr, regs->wdata));
-
-		if (rc < 0) {
-			CDBG("vb6801_i2c_write_table Failed!!!\n");
-			break;
-		}
-
-		regs++;
-	}
-
-	return rc;
-}
-
-static int32_t vb6801_reset(const struct msm_camera_sensor_info *data)
-{
-	int rc;
-
-	rc = gpio_request(data->sensor_reset, "vb6801");
-	if (!rc) {
-		CDBG("sensor_reset SUcceeded\n");
-		gpio_direction_output(data->sensor_reset, 0);
-		mdelay(50);
-		gpio_direction_output(data->sensor_reset, 1);
-		mdelay(13);
-	} else
-		CDBG("sensor_reset FAiled\n");
-
-	return rc;
-}
-
-static int32_t vb6801_set_default_focus(void)
-{
-	int32_t rc = 0;
-
-	/* FIXME: Default focus not supported */
-
-	return rc;
-}
-
-static void vb6801_get_pict_fps(uint16_t fps, uint16_t *pfps)
-{
-	/* input fps is preview fps in Q8 format */
-	uint32_t divider; /*Q10 */
-	uint32_t pclk_mult; /*Q10 */
-	uint32_t d1;
-	uint32_t d2;
-
-	d1 =
-		(uint32_t)(
-		(vb6801_ctrl->s_dynamic_params.preview_linesPerFrame *
-		0x00000400) /
-		vb6801_ctrl->s_dynamic_params.snapshot_linesPerFrame);
-
-	d2 =
-		(uint32_t)(
-		(vb6801_ctrl->s_dynamic_params.preview_pixelsPerLine *
-		0x00000400) /
-		vb6801_ctrl->s_dynamic_params.snapshot_pixelsPerLine);
-
-
-	divider = (uint32_t) (d1 * d2) / 0x00000400;
-
-	pclk_mult = (48 * 0x400) / 60;
-
-	/* Verify PCLK settings and frame sizes. */
-	*pfps = (uint16_t)((((fps * pclk_mult) / 0x00000400) * divider)/
-				0x00000400);
-}
-
-static uint16_t vb6801_get_prev_lines_pf(void)
-{
-	if (vb6801_ctrl->prev_res == QTR_SIZE)
-		return vb6801_ctrl->s_dynamic_params.preview_linesPerFrame;
-	else
-		return vb6801_ctrl->s_dynamic_params.snapshot_linesPerFrame;
-}
-
-static uint16_t vb6801_get_prev_pixels_pl(void)
-{
-	if (vb6801_ctrl->prev_res == QTR_SIZE)
-		return vb6801_ctrl->s_dynamic_params.preview_pixelsPerLine;
-	else
-		return vb6801_ctrl->s_dynamic_params.snapshot_pixelsPerLine;
-}
-
-static uint16_t vb6801_get_pict_lines_pf(void)
-{
-	return vb6801_ctrl->s_dynamic_params.snapshot_linesPerFrame;
-}
-
-static uint16_t vb6801_get_pict_pixels_pl(void)
-{
-	return vb6801_ctrl->s_dynamic_params.snapshot_pixelsPerLine;
-}
-
-static uint32_t vb6801_get_pict_max_exp_lc(void)
-{
-	uint16_t snapshot_lines_per_frame;
-
-	if (vb6801_ctrl->pict_res == QTR_SIZE) {
-		snapshot_lines_per_frame =
-		    vb6801_ctrl->s_dynamic_params.preview_linesPerFrame - 3;
-	} else {
-		snapshot_lines_per_frame =
-		    vb6801_ctrl->s_dynamic_params.snapshot_linesPerFrame - 3;
-	}
-
-	return snapshot_lines_per_frame;
-}
-
-static int32_t vb6801_set_fps(struct fps_cfg *fps)
-{
-	int32_t rc = 0;
-
-	/* input is new fps in Q8 format */
-	switch (fps->fps_div) {
-	case 7680:		/* 30 * Q8 */
-		vb6801_ctrl->factor_fps = 1;
-		break;
-
-	case 3840:		/* 15 * Q8 */
-		vb6801_ctrl->factor_fps = 2;
-		break;
-
-	case 2560:		/* 10 * Q8 */
-		vb6801_ctrl->factor_fps = 3;
-		break;
-
-	case 1920:		/* 7.5 * Q8 */
-		vb6801_ctrl->factor_fps = 4;
-		break;
-
-	default:
-		rc = -ENODEV;
-		break;
-	}
-
-	return rc;
-}
-
-static int32_t vb6801_write_exp_gain(uint16_t gain, uint32_t line)
-{
-	int32_t rc = 0;
-	uint16_t lpf;
-
-	if (vb6801_ctrl->curr_res == SENSOR_FULL_SIZE)
-		lpf = VB6801_LINES_PER_FRAME_SNAPSHOT;
-	else
-		lpf = VB6801_LINES_PER_FRAME_PREVIEW;
-
-	/* hold */
-	rc = vb6801_i2c_write_w(REG_HOLD, HOLD);
-	if (rc < 0)
-		goto exp_gain_done;
-
-	if ((vb6801_ctrl->curr_fps <
-	     vb6801_ctrl->max_fps / vb6801_ctrl->factor_fps) &&
-	    (!vb6801_ctrl->pict_exp_update)) {
-
-		if (vb6801_ctrl->reducel) {
-
-			rc = vb6801_i2c_write_w(REG_VT_FRAME_LENGTH_LINES,
-						lpf * vb6801_ctrl->factor_fps);
-
-			vb6801_ctrl->curr_fps =
-			    vb6801_ctrl->max_fps / vb6801_ctrl->factor_fps;
-
-		} else if (!vb6801_ctrl->reducel) {
-
-			rc = vb6801_i2c_write_w(REG_COARSE_INTEGRATION_TIME,
-						line * vb6801_ctrl->factor_fps);
-
-			vb6801_ctrl->reducel = 1;
-		}
-	} else if ((vb6801_ctrl->curr_fps >
-		    vb6801_ctrl->max_fps / vb6801_ctrl->factor_fps) &&
-		   (!vb6801_ctrl->pict_exp_update)) {
-
-		rc = vb6801_i2c_write_w(REG_VT_FRAME_LENGTH_LINES,
-					lpf * vb6801_ctrl->factor_fps);
-
-		vb6801_ctrl->curr_fps =
-		    vb6801_ctrl->max_fps / vb6801_ctrl->factor_fps;
-
-	} else {
-		/* analogue_gain_code_global */
-		rc = vb6801_i2c_write_w(REG_ANALOGUE_GAIN_CODE_GLOBAL, gain);
-		if (rc < 0)
-			goto exp_gain_done;
-
-		/* coarse_integration_time */
-		rc = vb6801_i2c_write_w(REG_COARSE_INTEGRATION_TIME,
-					line * vb6801_ctrl->factor_fps);
-		if (rc < 0)
-			goto exp_gain_done;
-
-		vb6801_ctrl->pict_exp_update = 1;
-	}
-
-	rc = vb6801_i2c_write_w(REG_HOLD, RELEASE_HOLD);
-
-exp_gain_done:
-	return rc;
-}
-
-static int32_t vb6801_set_pict_exp_gain(uint16_t gain, uint32_t line)
-{
-	vb6801_ctrl->pict_exp_update = 1;
-	return vb6801_write_exp_gain(gain, line);
-}
-
-static int32_t vb6801_power_down(void)
-{
-	int32_t rc = 0;
-	rc = vb6801_i2c_write_b(REG_NVM_PDN, 0);
-
-	mdelay(5);
-	return rc;
-}
-
-static int32_t vb6801_go_to_position(uint32_t target_vcm_dac_code,
-				     struct vb6801_sensor_info *ps)
-{
-	/* Prior to running this function the following values must
-	 * be initialised in the sensor data structure, PS
-	 * ps->vcm_dac_code
-	 * ps->vcm_max_dac_code_step
-	 * ps->vcm_dac_code_spacing_ms */
-
-	int32_t rc = 0;
-
-	ps->vcm_dac_code = target_vcm_dac_code;
-
-	/* Restore Strobe to zero state */
-	rc = vb6801_i2c_write_b(REG_VCM_DAC_STROBE, 0x00);
-	if (rc < 0)
-		return rc;
-
-	/* Write 9-bit VCM DAC Code */
-	rc = vb6801_i2c_write_w(REG_VCM_DAC_CODE, ps->vcm_dac_code);
-	if (rc < 0)
-		return rc;
-
-	/* Generate a rising edge on the dac_strobe to latch
-	 * new DAC value */
-
-	rc = vb6801_i2c_write_w(REG_VCM_DAC_STROBE, 0x01);
-
-	return rc;
-}
-
-static int32_t vb6801_move_focus(int direction, int32_t num_steps)
-{
-	int16_t step_direction;
-	int16_t actual_step;
-	int16_t next_position;
-	uint32_t step_size;
-	int16_t small_move[4];
-	uint16_t i;
-	int32_t rc = 0;
-
-	step_size = (vb6801_ctrl->s_info.vcm_dac_code_macro_up -
-		     vb6801_ctrl->s_info.vcm_dac_code_infinity_dn) /
-	    VB6801_TOTAL_STEPS_NEAR_TO_FAR;
-
-	if (num_steps > VB6801_TOTAL_STEPS_NEAR_TO_FAR)
-		num_steps = VB6801_TOTAL_STEPS_NEAR_TO_FAR;
-	else if (num_steps == 0)
-		return -EINVAL;
-
-	if (direction == MOVE_NEAR)
-		step_direction = 4;
-	else if (direction == MOVE_FAR)
-		step_direction = -4;
-	else
-		return -EINVAL;
-
-	/* need to decide about default position and power supplied
-	 * at start up and reset */
-	if (vb6801_ctrl->curr_lens_pos < vb6801_ctrl->init_curr_lens_pos)
-		vb6801_ctrl->curr_lens_pos = vb6801_ctrl->init_curr_lens_pos;
-
-	actual_step = (step_direction * num_steps);
-
-	next_position = vb6801_ctrl->curr_lens_pos;
-
-	for (i = 0; i < 4; i++) {
-		if (actual_step >= 0)
-			small_move[i] =
-			    (i + 1) * actual_step / 4 - i * actual_step / 4;
-
-		if (actual_step < 0)
-			small_move[i] =
-			    (i + 1) * actual_step / 4 - i * actual_step / 4;
-	}
-
-	if (next_position > 511)
-		next_position = 511;
-	else if (next_position < 0)
-		next_position = 0;
-
-	/* for damping */
-	for (i = 0; i < 4; i++) {
-		next_position =
-		    (int16_t) (vb6801_ctrl->curr_lens_pos + small_move[i]);
-
-		/* Writing the digital code for current to the actuator */
-		CDBG("next_position in damping mode = %d\n", next_position);
-
-		rc = vb6801_go_to_position(next_position, &vb6801_ctrl->s_info);
-		if (rc < 0) {
-			CDBG("go_to_position Failed!!!\n");
-			return rc;
-		}
-
-		vb6801_ctrl->curr_lens_pos = next_position;
-		if (i < 3)
-			mdelay(5);
-	}
-
-	return rc;
-}
-
-static int vb6801_read_nvm_data(struct vb6801_sensor_info *ps)
-{
-	/* +--------+------+------+----------------+---------------+
-	 * | Index | NVM | NVM | Name | Description |
-	 * | | Addr | Byte | | |
-	 * +--------+------+------+----------------+---------------+
-	 * | 0x3600 | 0 | 3 | nvm_t1_addr_00 | {PF[2:0]:Day[4:0]} |
-	 * | 0x3601 | 0 | 2 | nvm_t1_addr_01 | {Month[3:0]:Year[3:0]} |
-	 * | 0x3602 | 0 | 1 | nvm_t1_addr_02 | Tester[7:0] |
-	 * | 0x3603 | 0 | 0 | nvm_t1_addr_03 | Part[15:8] |
-	 * +--------+------+------+----------------+---------------+
-	 * | 0x3604 | 1 | 3 | nvm_t1_addr_04 | Part[7:0] |
-	 * | 0x3605 | 1 | 2 | nvm_t1_addr_05 | StartWPM[7:0] |
-	 * | 0x3606 | 1 | 1 | nvm_t1_addr_06 | Infinity[7:0] |
-	 * | 0x3607 | 1 | 0 | nvm_t1_addr_07 | Macro[7:0] |
-	 * +--------+------+------+----------------+---------------+
-	 * | 0x3608 | 2 | 3 | nvm_t1_addr_08 | Reserved |
-	 * | 0x3609 | 2 | 2 | nvm_t1_addr_09 | Reserved |
-	 * | 0x360A | 2 | 1 | nvm_t1_addr_0A | UpDown[7:0] |
-	 * | 0x360B | 2 | 0 | nvm_t1_addr_0B | Reserved |
-	 * +--------+------+------+----------------+---------------+
-	 * | 0x360C | 3 | 3 | nvm_t1_addr_0C | Reserved |
-	 * | 0x360D | 3 | 2 | nvm_t1_addr_0D | Reserved |
-	 * | 0x360E | 3 | 1 | nvm_t1_addr_0E | Reserved |
-	 * | 0x360F | 3 | 0 | nvm_t1_addr_0F | Reserved |
-	 * +--------+------+------+----------------+---------------+
-	 * | 0x3610 | 4 | 3 | nvm_t1_addr_10 | Reserved |
-	 * | 0x3611 | 4 | 2 | nvm_t1_addr_11 | Reserved |
-	 * | 0x3612 | 4 | 1 | nvm_t1_addr_12 | Reserved |
-	 * | 0x3613 | 4 | 0 | nvm_t1_addr_13 | Reserved |
-	 * +--------+------+------+----------------+---------------+*/
-
-	int32_t rc;
-	struct vb6801_i2c_reg_conf_t rreg[] = {
-		{REG_NVM_T1_ADDR_00, 0, 0, D_LEN_BYTE},
-		{REG_NVM_T1_ADDR_01, 0, 0, D_LEN_BYTE},
-		{REG_NVM_T1_ADDR_02, 0, 0, D_LEN_BYTE},
-		{REG_NVM_T1_ADDR_03, 0, 0, D_LEN_BYTE},
-		{REG_NVM_T1_ADDR_04, 0, 0, D_LEN_BYTE},
-		{REG_NVM_T1_ADDR_05, 0, 0, D_LEN_BYTE},
-		{REG_NVM_T1_ADDR_06, 0, 0, D_LEN_BYTE},
-		{REG_NVM_T1_ADDR_07, 0, 0, D_LEN_BYTE},
-		{REG_NVM_T1_ADDR_08, 0, 0, D_LEN_BYTE},
-		{REG_NVM_T1_ADDR_09, 0, 0, D_LEN_BYTE},
-		{REG_NVM_T1_ADDR_0A, 0, 0, D_LEN_BYTE},
-		{REG_NVM_T1_ADDR_0B, 0, 0, D_LEN_BYTE},
-		{REG_NVM_T1_ADDR_0C, 0, 0, D_LEN_BYTE},
-		{REG_NVM_T1_ADDR_0D, 0, 0, D_LEN_BYTE},
-		{REG_NVM_T1_ADDR_0E, 0, 0, D_LEN_BYTE},
-		{REG_NVM_T1_ADDR_0F, 0, 0, D_LEN_BYTE},
-		{REG_NVM_T1_ADDR_10, 0, 0, D_LEN_BYTE},
-		{REG_NVM_T1_ADDR_11, 0, 0, D_LEN_BYTE},
-		{REG_NVM_T1_ADDR_12, 0, 0, D_LEN_BYTE},
-		{REG_NVM_T1_ADDR_13, 0, 0, D_LEN_BYTE},
-	};
-
-	struct vb6801_i2c_reg_conf_t wreg[] = {
-		/* Enable NVM for Direct Reading */
-		{REG_NVM_CTRL, 0, 2, D_LEN_BYTE},
-
-		/* Power up NVM */
-		{REG_NVM_PDN, 0, 1, D_LEN_BYTE},
-	};
-
-	rc = vb6801_i2c_write_table(wreg, ARRAY_SIZE(wreg));
-	if (rc < 0) {
-		CDBG("I2C Write Table FAILED!!!\n");
-		return rc;
-	}
-
-	/* NVM Read Pulse Width
-	 * ====================
-	 * nvm_pulse_width_us = nvm_pulse_width_ext_clk / ext_clk_freq_mhz
-	 * Valid Range for Read Pulse Width = 400ns -> 3.0us
-	 * Min ext_clk_freq_mhz = 6MHz  => 3.0 *  6  = 18
-	 * Max ext_clk_freq_mhz = 27MHz => 0.4 * 27 = 10.8
-	 * Choose 15 as a common value
-	 *  - 15 /  6.0 = 2.5000us
-	 *  - 15 / 12.0 = 1.2500us
-	 *  - 15 / 27.0 = 0.5555us */
-	rc = vb6801_i2c_write_w(REG_NVM_PULSE_WIDTH, 15);
-	if (rc < 0) {
-		rc = -EBUSY;
-		goto nv_shutdown;
-	}
-
-	rc = vb6801_i2c_read_table(rreg, ARRAY_SIZE(rreg));
-	if (rc < 0) {
-		CDBG("I2C Read Table FAILED!!!\n");
-		rc = -EBUSY;
-		goto nv_shutdown;
-	}
-
-	/* Decode and Save FMT Info */
-	ps->pass_fail = (rreg[0].bdata & 0x00E0) >> 5;
-	ps->day = (rreg[0].bdata & 0x001F);
-	ps->month = (rreg[1].bdata & 0x00F0) >> 4;
-	ps->year = (rreg[1].bdata & 0x000F) + 2000;
-	ps->tester = rreg[2].bdata;
-	ps->part_number = (rreg[3].bdata << 8) + rreg[4].bdata;
-
-	/* Decode and Save VCM Dac Values in data structure */
-	ps->vcm_dac_code_infinity_dn = rreg[6].bdata;
-	ps->vcm_dac_code_macro_up = rreg[7].bdata << 1;
-	ps->vcm_dac_code_up_dn_delta = rreg[10].bdata;
-
-nv_shutdown:
-	/* Power Down NVM to extend life time */
-	rc = vb6801_i2c_write_b(REG_NVM_PDN, 0);
-
-	return rc;
-}
-
-static int vb6801_config_sensor(int32_t ext_clk_freq_mhz,
-				int32_t target_frame_rate_fps,
-				int32_t target_vt_pix_clk_freq_mhz,
-				uint32_t sub_sampling_factor,
-				uint32_t analog_binning_allowed,
-				uint32_t raw_mode, int capture_mode,
-				enum vb6801_resolution_t res)
-{
-	uint32_t rc;
-	/* ext_clk_freq_mhz      = 6.0 -> 27.0 MHz
-	 * target_frame_rate_fps  = 15 fps
-	 * target_vt_pix_clk_freq_mhz = 24.0 -> 64.0MHz
-	 * sub_sampling factor   = 1, 2, 3, or 4
-	 * raw_mode factor       = 10
-	 *
-	 * capture_mode, 0 = CCP1
-	 * capture_mode, 1 = CCP2
-	 * capture_mode, 2 = 10-bit parallel + hsync + vsync */
-
-	/* Declare data format */
-	uint32_t ccp2_data_format = 0x0A0A;
-
-	/*  Declare clock tree variables */
-	int32_t min_pll_ip_freq_mhz = 6;
-	int32_t max_pll_op_freq_mhz = 640;
-	uint32_t pre_pll_clk_div = 1;
-	int32_t pll_ip_freq_mhz = 6;
-	uint32_t pll_multiplier = 100;
-	int32_t pll_op_freq_mhz = 600;
-	uint32_t vt_sys_clk_div = 1;
-	int32_t vt_sys_clk_freq_mhz = 600;
-	uint32_t vt_pix_clk_div = 10;
-	int32_t vt_pix_clk_freq_mhz = 60;
-	uint32_t op_sys_clk_div = 1;
-	int32_t op_sys_clk_freq_mhz = 60;
-	uint32_t op_pix_clk_div = 10;
-	int32_t op_pix_clk_freq_mhz = 60;
-
-	/* Declare pixel array and frame timing variables */
-	uint32_t x_pixel_array = 2064;
-	uint32_t y_pixel_array = 1544;
-	uint32_t x_even_inc = 1;
-	uint32_t x_odd_inc = 1;
-	uint32_t y_even_inc = 1;
-	uint32_t y_odd_inc = 1;
-	uint32_t x_output_size = 2064;
-	uint32_t y_output_size = 1544;
-	uint32_t additional_rows = 2;
-	uint32_t min_vt_frame_blanking_lines = 16;
-	uint32_t vt_line_length_pck = 2500;
-	uint32_t vt_line_length_us = 0;
-	uint32_t min_vt_frame_length_lines = 1562;
-	uint32_t vt_frame_length_lines = 1600;
-	uint32_t target_vt_frame_length_ms;	/* 200 * 0x0001000 / 3; */
-	uint32_t vt_frame_length_ms;	/* 200 * 0x0001000 / 3; */
-	uint32_t frame_rate_fps = 15;
-
-	/* Coarse intergration time */
-	uint32_t coarse_integration_time = 1597;
-	uint32_t coarse_integration_time_max_margin = 3;
-	uint16_t frame_count;
-	int timeout;
-
-	struct vb6801_sensor_info *pinfo = &vb6801_ctrl->s_info;
-
-	struct vb6801_i2c_reg_conf_t rreg[] = {
-		{REG_PRE_PLL_CLK_DIV, 0, 0, D_LEN_WORD},
-		{REG_PLL_MULTIPLIER, 0, 0, D_LEN_WORD},
-		{REG_VT_SYS_CLK_DIV, 0, 0, D_LEN_WORD},
-		{REG_VT_PIX_CLK_DIV, 0, 0, D_LEN_WORD},
-		{REG_OP_SYS_CLK_DIV, 0, 0, D_LEN_WORD},
-		{REG_OP_PIX_CLK_DIV, 0, 0, D_LEN_WORD},
-		{REG_FRAME_COUNT, 0, 0, D_LEN_BYTE},
-	};
-
-	struct vb6801_i2c_reg_conf_t wreg2[] = {
-		{REG_POWER_MAN_ENABLE_3, 0, 95, D_LEN_BYTE},
-		{REG_POWER_MAN_ENABLE_4, 0, 142, D_LEN_BYTE},
-		{REG_POWER_MAN_ENABLE_5, 0, 7, D_LEN_BYTE},
-	};
-
-	/* VIDEO TIMING CALCULATIONS
-	 * ========================= */
-
-	/* Pixel Array Size */
-	x_pixel_array = 2064;
-	y_pixel_array = 1544;
-
-	/* set current resolution */
-	vb6801_ctrl->curr_res = res;
-
-	/* Analogue binning setup */
-	if (pinfo->analog_binning_allowed > 0 &&
-	    pinfo->sub_sampling_factor == 4) {
-
-		pinfo->vtiming_major = 1;
-		pinfo->analog_timing_modes_4 = 32;
-	} else if (pinfo->analog_binning_allowed > 0 &&
-		   pinfo->sub_sampling_factor == 2) {
-
-		pinfo->vtiming_major = 1;
-		pinfo->analog_timing_modes_4 = 0;
-	} else {
-
-		pinfo->vtiming_major = 0;
-		pinfo->analog_timing_modes_4 = 0;
-	}
-
-	/* Sub-Sampling X & Y Odd Increments: valid values 1, 3, 5, 7 */
-	x_even_inc = 1;
-	y_even_inc = 1;
-	x_odd_inc = (sub_sampling_factor << 1) - x_even_inc;
-	y_odd_inc = (sub_sampling_factor << 1) - y_even_inc;
-
-	/* Output image size
-	 * Must always be a multiple of 2 - round down */
-	x_output_size = ((x_pixel_array / sub_sampling_factor) >> 1) << 1;
-	y_output_size = ((y_pixel_array / sub_sampling_factor) >> 1) << 1;
-
-	/* Output data format */
-	ccp2_data_format = (raw_mode << 8) + raw_mode;
-
-	/* Pre PLL clock divider : valid values 1, 2 or 4
-	 * The 1st step is to ensure that PLL input frequency is as close
-	 * as possible to the min allowed PLL input frequency.
-	 * This yields the smallest step size in the PLL output frequency. */
-	pre_pll_clk_div =
-	    ((int)(ext_clk_freq_mhz / min_pll_ip_freq_mhz) >> 1) << 1;
-	if (pre_pll_clk_div < 2)
-		pre_pll_clk_div = 1;
-
-	pll_ip_freq_mhz = ext_clk_freq_mhz / pre_pll_clk_div;
-
-	/* Video Timing System Clock divider: valid values 1, 2, 4
-	 * Now need to work backwards through the clock tree to determine the
-	 * 1st pass estimates for vt_sys_clk_freq_mhz and then the PLL output
-	 * frequency.*/
-	vt_sys_clk_freq_mhz = vt_pix_clk_div * target_vt_pix_clk_freq_mhz;
-	vt_sys_clk_div = max_pll_op_freq_mhz / vt_sys_clk_freq_mhz;
-	if (vt_sys_clk_div < 2)
-		vt_sys_clk_div = 1;
-
-	/* PLL Mulitplier: min , max 106 */
-	pll_op_freq_mhz = vt_sys_clk_div * vt_sys_clk_freq_mhz;
-	pll_multiplier = (pll_op_freq_mhz * 0x0001000) / pll_ip_freq_mhz;
-
-	/* Calculate the acutal pll output frequency
-	 * - the pll_multiplier calculation introduces a quantisation error
-	 *   due the integer nature of the pll multiplier */
-	pll_op_freq_mhz = (pll_ip_freq_mhz * pll_multiplier) / 0x0001000;
-
-	/* Re-calculate video timing clock frequencies based
-	 * on actual PLL freq */
-	vt_sys_clk_freq_mhz = pll_op_freq_mhz / vt_sys_clk_div;
-	vt_pix_clk_freq_mhz = ((vt_sys_clk_freq_mhz * 0x0001000) /
-				vt_pix_clk_div)/0x0001000;
-
-	/* Output System Clock Divider: valid value 1, 2, 4, 6, 8
-	 * op_sys_clk_div = vt_sys_clk_div;*/
-	op_sys_clk_div = (vt_sys_clk_div * sub_sampling_factor);
-	if (op_sys_clk_div < 2)
-		op_sys_clk_div = 1;
-
-	/* Calculate output timing clock frequencies */
-	op_sys_clk_freq_mhz = pll_op_freq_mhz / op_sys_clk_div;
-	op_pix_clk_freq_mhz =
-	    (op_sys_clk_freq_mhz * 0x0001000) / (op_pix_clk_div * 0x0001000);
-
-	/* Line length in pixels and us */
-	vt_line_length_pck = 2500;
-	vt_line_length_us =
-	    vt_line_length_pck * 0x0001000 / vt_pix_clk_freq_mhz;
-
-	/* Target vt_frame_length_ms */
-	target_vt_frame_length_ms = (1000 * 0x0001000 / target_frame_rate_fps);
-
-	/* Frame length in lines */
-	min_vt_frame_length_lines =
-	    additional_rows + y_output_size + min_vt_frame_blanking_lines;
-
-	vt_frame_length_lines =
-	    ((1000 * target_vt_frame_length_ms) / vt_line_length_us);
-
-	if (vt_frame_length_lines <= min_vt_frame_length_lines)
-		vt_frame_length_lines = min_vt_frame_length_lines;
-
-	/* Calcuate the actual frame length in ms */
-	vt_frame_length_ms = (vt_frame_length_lines * vt_line_length_us / 1000);
-
-	/* Frame Rate in fps */
-	frame_rate_fps = (1000 * 0x0001000 / vt_frame_length_ms);
-
-	/* Set coarse integration to max */
-	coarse_integration_time =
-	    vt_frame_length_lines - coarse_integration_time_max_margin;
-
-	CDBG("SENSOR VIDEO TIMING SUMMARY:\n");
-	CDBG(" ============================\n");
-	CDBG("ext_clk_freq_mhz      = %d\n", ext_clk_freq_mhz);
-	CDBG("pre_pll_clk_div       = %d\n", pre_pll_clk_div);
-	CDBG("pll_ip_freq_mhz       = %d\n", pll_ip_freq_mhz);
-	CDBG("pll_multiplier        = %d\n", pll_multiplier);
-	CDBG("pll_op_freq_mhz       = %d\n", pll_op_freq_mhz);
-	CDBG("vt_sys_clk_div        = %d\n", vt_sys_clk_div);
-	CDBG("vt_sys_clk_freq_mhz   = %d\n", vt_sys_clk_freq_mhz);
-	CDBG("vt_pix_clk_div        = %d\n", vt_pix_clk_div);
-	CDBG("vt_pix_clk_freq_mhz   = %d\n", vt_pix_clk_freq_mhz);
-	CDBG("op_sys_clk_div        = %d\n", op_sys_clk_div);
-	CDBG("op_sys_clk_freq_mhz   = %d\n", op_sys_clk_freq_mhz);
-	CDBG("op_pix_clk_div        = %d\n", op_pix_clk_div);
-	CDBG("op_pix_clk_freq_mhz   = %d\n", op_pix_clk_freq_mhz);
-	CDBG("vt_line_length_pck    = %d\n", vt_line_length_pck);
-	CDBG("vt_line_length_us     = %d\n", vt_line_length_us/0x0001000);
-	CDBG("vt_frame_length_lines = %d\n", vt_frame_length_lines);
-	CDBG("vt_frame_length_ms    = %d\n", vt_frame_length_ms/0x0001000);
-	CDBG("frame_rate_fps        = %d\n", frame_rate_fps);
-	CDBG("ccp2_data_format = %d\n", ccp2_data_format);
-	CDBG("x_output_size = %d\n", x_output_size);
-	CDBG("y_output_size = %d\n", y_output_size);
-	CDBG("x_odd_inc = %d\n", x_odd_inc);
-	CDBG("y_odd_inc = %d\n", y_odd_inc);
-	CDBG("(vt_frame_length_lines * frame_rate_factor ) = %d\n",
-	    (vt_frame_length_lines * vb6801_ctrl->factor_fps));
-	CDBG("coarse_integration_time = %d\n", coarse_integration_time);
-	CDBG("pinfo->vcm_dac_code = %d\n", pinfo->vcm_dac_code);
-	CDBG("capture_mode = %d\n", capture_mode);
-
-	/* RE-CONFIGURE SENSOR WITH NEW TIMINGS
-	 * ====================================
-	 * Enter Software Standby Mode */
-	rc = vb6801_i2c_write_b(REG_MODE_SELECT, 0);
-	if (rc < 0) {
-		CDBG("I2C vb6801_i2c_write_b FAILED!!!\n");
-		return rc;
-	}
-
-	/* Wait 100ms */
-	mdelay(100);
-
-	if (capture_mode == 0) {
-
-		rc = vb6801_i2c_write_b(REG_CCP2_CHANNEL_IDENTIFIER, 0);
-		rc = vb6801_i2c_write_b(REG_CCP2_SIGNALLING_MODE, 0);
-	} else if (capture_mode == 1) {
-
-		rc = vb6801_i2c_write_b(REG_CCP2_CHANNEL_IDENTIFIER, 0);
-		rc = vb6801_i2c_write_b(REG_CCP2_SIGNALLING_MODE, 1);
-	}
-
-	{
-		struct vb6801_i2c_reg_conf_t wreg[] = {
-			/* Re-configure Sensor */
-			{REG_CCP2_DATA_FORMAT, ccp2_data_format, 0,
-			 D_LEN_WORD},
-			{REG_ANALOGUE_GAIN_CODE_GLOBAL, 128, 0, D_LEN_WORD},
-			{REG_PRE_PLL_CLK_DIV, pre_pll_clk_div, 0, D_LEN_WORD},
-			{REG_VT_SYS_CLK_DIV, vt_sys_clk_div, 0, D_LEN_WORD},
-			{REG_VT_PIX_CLK_DIV, vt_pix_clk_div, 0, D_LEN_WORD},
-			{REG_OP_SYS_CLK_DIV, vt_sys_clk_div, 0, D_LEN_WORD},
-			{REG_OP_PIX_CLK_DIV, vt_pix_clk_div, 0, D_LEN_WORD},
-			{REG_VT_LINE_LENGTH_PCK, vt_line_length_pck, 0,
-			 D_LEN_WORD},
-			{REG_X_OUTPUT_SIZE, x_output_size, 0, D_LEN_WORD},
-			{REG_Y_OUTPUT_SIZE, y_output_size, 0, D_LEN_WORD},
-			{REG_X_ODD_INC, x_odd_inc, 0, D_LEN_WORD},
-			{REG_Y_ODD_INC, y_odd_inc, 0, D_LEN_WORD},
-			{REG_VT_FRAME_LENGTH_LINES,
-			 vt_frame_length_lines * vb6801_ctrl->factor_fps, 0,
-			 D_LEN_WORD},
-			{REG_COARSE_INTEGRATION_TIME,
-			 coarse_integration_time, 0, D_LEN_WORD},
-			/* Analogue Settings */
-			{REG_ANALOG_TIMING_MODES_2, 0, 132, D_LEN_BYTE},
-			{REG_RAMP_SCALE, 0, 5, D_LEN_BYTE},
-			{REG_BTL_LEVEL_SETUP, 0, 11, D_LEN_BYTE},
-			/* Enable Defect Correction */
-			{REG_SCYTHE_ENABLE, 0, 1, D_LEN_BYTE},
-			{REG_SCYTHE_WEIGHT, 0, 16, D_LEN_BYTE},
-			{REG_BRUCE_ENABLE, 0, 1, D_LEN_BYTE},
-			/* Auto Focus Configuration
-			 * Please note that the DAC Code is a written as a
-			 * 16-bit value 0 = infinity (no DAC current) */
-			{REG_VCM_DAC_CODE, pinfo->vcm_dac_code, 0, D_LEN_WORD},
-			{REG_VCM_DAC_STROBE, 0, 0, D_LEN_BYTE},
-			{REG_VCM_DAC_ENABLE, 0, 1, D_LEN_BYTE},
-		};
-
-		rc = vb6801_i2c_write_table(wreg, ARRAY_SIZE(wreg));
-		if (rc < 0) {
-			CDBG("I2C Write Table FAILED!!!\n");
-			return rc;
-		}
-	}
-	/* Parallel Interface Configuration */
-	if (capture_mode >= 2) {
-		struct vb6801_i2c_reg_conf_t wreg1[] = {
-			{REG_OP_CODER_SYNC_CLK_SETUP, 0, 15, D_LEN_BYTE},
-			{REG_OP_CODER_ENABLE, 0, 3, D_LEN_BYTE},
-			{REG_OP_CODER_SLOW_PAD_EN, 0, 1, D_LEN_BYTE},
-			{REG_OP_CODER_AUTOMATIC_MODE_ENABLE, 0, 3, D_LEN_BYTE},
-			{REG_OP_CODER_AUTO_STARTUP, 0, 2, D_LEN_BYTE},
-		};
-
-		rc = vb6801_i2c_write_table(wreg1, ARRAY_SIZE(wreg1));
-		if (rc < 0) {
-			CDBG("I2C Write Table FAILED!!!\n");
-			return rc;
-		}
-	}
-
-	/* Enter Streaming Mode */
-	rc = vb6801_i2c_write_b(REG_MODE_SELECT, 1);
-	if (rc < 0) {
-		CDBG("I2C Write Table FAILED!!!\n");
-		return rc;
-	}
-
-	/* Wait until the sensor starts streaming
-	 * Poll until the reported frame_count value is != 0xFF */
-	frame_count = 0xFF;
-	timeout = 2000;
-	while (frame_count == 0xFF && timeout > 0) {
-		rc = vb6801_i2c_read(REG_FRAME_COUNT, &frame_count, 1);
-		if (rc < 0)
-			return rc;
-
-		CDBG("REG_FRAME_COUNT  = 0x%x\n", frame_count);
-		timeout--;
-	}
-
-	/* Post Streaming Configuration */
-
-	rc = vb6801_i2c_write_table(wreg2, ARRAY_SIZE(wreg2));
-	if (rc < 0) {
-		CDBG("I2C Write Table FAILED!!!\n");
-		return rc;
-	}
-
-	rc = vb6801_i2c_read_table(rreg, ARRAY_SIZE(rreg));
-	if (rc < 0) {
-		CDBG("I2C Read Table FAILED!!!\n");
-		return rc;
-	}
-
-	CDBG("REG_PRE_PLL_CLK_DIV = 0x%x\n", rreg[0].wdata);
-	CDBG("REG_PLL_MULTIPLIER  = 0x%x\n", rreg[1].wdata);
-	CDBG("REG_VT_SYS_CLK_DIV  = 0x%x\n", rreg[2].wdata);
-	CDBG("REG_VT_PIX_CLK_DIV  = 0x%x\n", rreg[3].wdata);
-	CDBG("REG_OP_SYS_CLK_DIV  = 0x%x\n", rreg[4].wdata);
-	CDBG("REG_OP_PIX_CLK_DIV  = 0x%x\n", rreg[5].wdata);
-	CDBG("REG_FRAME_COUNT  = 0x%x\n", rreg[6].bdata);
-
-	mdelay(50);
-	frame_count = 0;
-	rc = vb6801_i2c_read(REG_FRAME_COUNT, &frame_count, 1);
-	CDBG("REG_FRAME_COUNT1  = 0x%x\n", frame_count);
-
-	mdelay(150);
-	frame_count = 0;
-	rc = vb6801_i2c_read(REG_FRAME_COUNT, &frame_count, 1);
-	CDBG("REG_FRAME_COUNT2  = 0x%x\n", frame_count);
-
-	mdelay(100);
-	frame_count = 0;
-	rc = vb6801_i2c_read(REG_FRAME_COUNT, &frame_count, 1);
-	CDBG("REG_FRAME_COUNT3  = 0x%x\n", frame_count);
-
-	mdelay(250);
-	frame_count = 0;
-	rc = vb6801_i2c_read(REG_FRAME_COUNT, &frame_count, 1);
-	CDBG("REG_FRAME_COUNT4  = 0x%x\n", frame_count);
-
-	return rc;
-}
-
-static int vb6801_sensor_init_done(const struct msm_camera_sensor_info *data)
-{
-	gpio_direction_output(data->sensor_reset, 0);
-	gpio_free(data->sensor_reset);
-	return 0;
-}
-
-static int vb6801_init_client(struct i2c_client *client)
-{
-	/* Initialize the MSM_CAMI2C Chip */
-	init_waitqueue_head(&vb6801_wait_queue);
-	return 0;
-}
-
-static int32_t vb6801_video_config(int mode, int res)
-{
-	int32_t rc = 0;
-
-	vb6801_ctrl->prev_res = res;
-	vb6801_ctrl->curr_res = res;
-	vb6801_ctrl->sensormode = mode;
-
-	rc = vb6801_config_sensor(12, 30, 60, 2, 1, 10, 2, RES_PREVIEW);
-	if (rc < 0)
-		return rc;
-
-	rc = vb6801_i2c_read(REG_VT_LINE_LENGTH_PCK,
-			     &vb6801_ctrl->s_dynamic_params.
-			     preview_pixelsPerLine, 2);
-	if (rc < 0)
-		return rc;
-
-	rc = vb6801_i2c_read(REG_VT_LINE_LENGTH_PCK,
-			     &vb6801_ctrl->s_dynamic_params.
-			     preview_linesPerFrame, 2);
-
-	return rc;
-}
-
-static int32_t vb6801_snapshot_config(int mode, int res)
-{
-	int32_t rc = 0;
-
-	vb6801_ctrl->curr_res = vb6801_ctrl->pict_res;
-	vb6801_ctrl->sensormode = mode;
-
-	rc = vb6801_config_sensor(12, 12, 48, 1, 1, 10, 2, RES_CAPTURE);
-	if (rc < 0)
-		return rc;
-
-	rc = vb6801_i2c_read(REG_VT_LINE_LENGTH_PCK,
-			     &vb6801_ctrl->s_dynamic_params.
-			     snapshot_pixelsPerLine, 2);
-	if (rc < 0)
-		return rc;
-
-	rc = vb6801_i2c_read(REG_VT_LINE_LENGTH_PCK,
-			     &vb6801_ctrl->s_dynamic_params.
-			     snapshot_linesPerFrame, 2);
-
-	return rc;
-}
-
-static int32_t vb6801_set_sensor_mode(int mode, int res)
-{
-	int32_t rc = 0;
-
-	switch (mode) {
-	case SENSOR_PREVIEW_MODE:
-		rc = vb6801_video_config(mode, res);
-		break;
-
-	case SENSOR_SNAPSHOT_MODE:
-	case SENSOR_RAW_SNAPSHOT_MODE:
-		rc = vb6801_snapshot_config(mode, res);
-		break;
-
-	default:
-		rc = -EINVAL;
-		break;
-	}
-
-	return rc;
-}
-
-int vb6801_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(&vb6801_mut);
-
-	CDBG("vb6801_sensor_config, cfgtype = %d\n", cdata.cfgtype);
-
-	switch (cdata.cfgtype) {
-	case CFG_GET_PICT_FPS:
-		vb6801_get_pict_fps(cdata.cfg.gfps.prevfps,
-				    &(cdata.cfg.gfps.pictfps));
-
-		if (copy_to_user((void *)argp,
-				 &cdata, sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PREV_L_PF:
-		cdata.cfg.prevl_pf = vb6801_get_prev_lines_pf();
-
-		if (copy_to_user((void *)argp,
-				 &cdata, sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PREV_P_PL:
-		cdata.cfg.prevp_pl = vb6801_get_prev_pixels_pl();
-
-		if (copy_to_user((void *)argp,
-				 &cdata, sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PICT_L_PF:
-		cdata.cfg.pictl_pf = vb6801_get_pict_lines_pf();
-
-		if (copy_to_user((void *)argp,
-				 &cdata, sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PICT_P_PL:
-		cdata.cfg.pictp_pl = vb6801_get_pict_pixels_pl();
-
-		if (copy_to_user((void *)argp,
-				 &cdata, sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_GET_PICT_MAX_EXP_LC:
-		cdata.cfg.pict_max_exp_lc = vb6801_get_pict_max_exp_lc();
-
-		if (copy_to_user((void *)argp,
-				 &cdata, sizeof(struct sensor_cfg_data)))
-			rc = -EFAULT;
-		break;
-
-	case CFG_SET_FPS:
-	case CFG_SET_PICT_FPS:
-		rc = vb6801_set_fps(&(cdata.cfg.fps));
-		break;
-
-	case CFG_SET_EXP_GAIN:
-		rc = vb6801_write_exp_gain(cdata.cfg.exp_gain.gain,
-					   cdata.cfg.exp_gain.line);
-		break;
-
-	case CFG_SET_PICT_EXP_GAIN:
-		rc = vb6801_set_pict_exp_gain(cdata.cfg.exp_gain.gain,
-					      cdata.cfg.exp_gain.line);
-		break;
-
-	case CFG_SET_MODE:
-		rc = vb6801_set_sensor_mode(cdata.mode, cdata.rs);
-		break;
-
-	case CFG_PWR_DOWN:
-		rc = vb6801_power_down();
-		break;
-
-	case CFG_MOVE_FOCUS:
-		rc = vb6801_move_focus(cdata.cfg.focus.dir,
-				       cdata.cfg.focus.steps);
-		break;
-
-	case CFG_SET_DEFAULT_FOCUS:
-		rc = vb6801_set_default_focus();
-		break;
-
-	default:
-		rc = -EFAULT;
-		break;
-	}
-
-	mutex_unlock(&vb6801_mut);
-
-	return rc;
-}
-
-static int vb6801_sensor_release(void)
-{
-	int rc = -EBADF;
-
-	mutex_lock(&vb6801_mut);
-
-	vb6801_power_down();
-	vb6801_sensor_init_done(vb6801_ctrl->sensordata);
-	kfree(vb6801_ctrl);
-	mutex_unlock(&vb6801_mut);
-
-	return rc;
-}
-
-static int vb6801_i2c_probe(struct i2c_client *client,
-			    const struct i2c_device_id *id)
-{
-	int rc = 0;
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		rc = -ENOTSUPP;
-		goto probe_failure;
-	}
-
-	vb6801_sensorw = kzalloc(sizeof(struct vb6801_work_t), GFP_KERNEL);
-
-	if (!vb6801_sensorw) {
-		rc = -ENOMEM;
-		goto probe_failure;
-	}
-
-	i2c_set_clientdata(client, vb6801_sensorw);
-	vb6801_init_client(client);
-	vb6801_client = client;
-	vb6801_client->addr = vb6801_client->addr >> 1;
-
-	return 0;
-
-probe_failure:
-	if (vb6801_sensorw != NULL) {
-		kfree(vb6801_sensorw);
-		vb6801_sensorw = NULL;
-	}
-	return rc;
-}
-
-static int __exit vb6801_i2c_remove(struct i2c_client *client)
-{
-	struct vb6801_work_t *sensorw = i2c_get_clientdata(client);
-	free_irq(client->irq, sensorw);
-	vb6801_client = NULL;
-	kfree(sensorw);
-	return 0;
-}
-
-static const struct i2c_device_id vb6801_i2c_id[] = {
-	{"vb6801", 0},
-	{}
-};
-
-static struct i2c_driver vb6801_i2c_driver = {
-	.id_table = vb6801_i2c_id,
-	.probe = vb6801_i2c_probe,
-	.remove = __exit_p(vb6801_i2c_remove),
-	.driver = {
-		   .name = "vb6801",
-		   },
-};
-
-static int vb6801_probe_init_sensor(const struct msm_camera_sensor_info *data)
-{
-	int rc;
-
-	struct vb6801_i2c_reg_conf_t rreg[] = {
-		{0x0000, 0, 0, D_LEN_BYTE},
-		{0x0001, 0, 0, D_LEN_BYTE},
-	};
-
-	rc = vb6801_reset(data);
-	if (rc < 0)
-		goto init_probe_done;
-
-	mdelay(20);
-
-	rc = vb6801_i2c_read_table(rreg, ARRAY_SIZE(rreg));
-	if (rc < 0) {
-		CDBG("I2C Read Table FAILED!!!\n");
-		goto init_probe_fail;
-	}
-
-	/* 4. Compare sensor ID to VB6801 ID: */
-	if (rreg[0].bdata != 0x03 || rreg[1].bdata != 0x53) {
-		CDBG("vb6801_sensor_init: sensor ID don't match!\n");
-		goto init_probe_fail;
-	}
-
-	goto init_probe_done;
-
-init_probe_fail:
-	vb6801_sensor_init_done(data);
-init_probe_done:
-	return rc;
-}
-
-int vb6801_sensor_open_init(const struct msm_camera_sensor_info *data)
-{
-	int32_t rc;
-	struct vb6801_i2c_reg_conf_t wreg[] = {
-		{REG_MODE_SELECT, 0, STANDBY_MODE, D_LEN_BYTE},
-		{0x0113, 0, 0x0A, D_LEN_BYTE},
-	};
-
-	vb6801_ctrl = kzalloc(sizeof(struct vb6801_ctrl_t), GFP_KERNEL);
-	if (!vb6801_ctrl) {
-		rc = -ENOMEM;
-		goto open_init_fail1;
-	}
-
-	vb6801_ctrl->factor_fps = 1 /** 0x00000400*/ ;
-	vb6801_ctrl->curr_fps = 7680; /* 30 * Q8 */ ;
-	vb6801_ctrl->max_fps = 7680; /* 30 * Q8 */ ;
-	vb6801_ctrl->pict_exp_update = 0; /* 30 * Q8 */ ;
-	vb6801_ctrl->reducel = 0; /* 30 * Q8 */ ;
-
-	vb6801_ctrl->set_test = TEST_OFF;
-	vb6801_ctrl->prev_res = QTR_SIZE;
-	vb6801_ctrl->pict_res = FULL_SIZE;
-
-	vb6801_ctrl->s_dynamic_params.preview_linesPerFrame =
-	    VB6801_LINES_PER_FRAME_PREVIEW;
-	vb6801_ctrl->s_dynamic_params.preview_pixelsPerLine =
-	    VB6801_PIXELS_PER_LINE_PREVIEW;
-	vb6801_ctrl->s_dynamic_params.snapshot_linesPerFrame =
-	    VB6801_LINES_PER_FRAME_SNAPSHOT;
-	vb6801_ctrl->s_dynamic_params.snapshot_pixelsPerLine =
-	    VB6801_PIXELS_PER_LINE_SNAPSHOT;
-
-	if (data)
-		vb6801_ctrl->sensordata = data;
-
-	/* enable mclk first */
-	msm_camio_clk_rate_set(VB6801_DEFAULT_CLOCK_RATE);
-	mdelay(20);
-
-	rc = vb6801_reset(data);
-	if (rc < 0)
-		goto open_init_fail1;
-
-	rc = vb6801_i2c_write_table(wreg, ARRAY_SIZE(wreg));
-	if (rc < 0) {
-		CDBG("I2C Write Table FAILED!!!\n");
-		goto open_init_fail2;
-	}
-
-	rc = vb6801_read_nvm_data(&vb6801_ctrl->s_info);
-	if (rc < 0) {
-		CDBG("vb6801_read_nvm_data FAILED!!!\n");
-		goto open_init_fail2;
-	}
-	mdelay(66);
-
-	rc = vb6801_config_sensor(12, 30, 60, 2, 1, 10, 2, RES_PREVIEW);
-	if (rc < 0)
-		goto open_init_fail2;
-
-	goto open_init_done;
-
-open_init_fail2:
-	vb6801_sensor_init_done(data);
-open_init_fail1:
-	kfree(vb6801_ctrl);
-open_init_done:
-	return rc;
-}
-
-static int vb6801_sensor_probe(const struct msm_camera_sensor_info *info,
-			       struct msm_sensor_ctrl *s)
-{
-	int rc = i2c_add_driver(&vb6801_i2c_driver);
-	if (rc < 0 || vb6801_client == NULL) {
-		rc = -ENOTSUPP;
-		goto probe_done;
-	}
-
-	/* enable mclk first */
-	msm_camio_clk_rate_set(VB6801_DEFAULT_CLOCK_RATE);
-	mdelay(20);
-
-	rc = vb6801_probe_init_sensor(info);
-	if (rc < 0)
-		goto probe_done;
-
-	s->s_init = vb6801_sensor_open_init;
-	s->s_release = vb6801_sensor_release;
-	s->s_config = vb6801_sensor_config;
-	s->s_mount_angle  = 0;
-	vb6801_sensor_init_done(info);
-
-probe_done:
-	return rc;
-}
-
-static int __vb6801_probe(struct platform_device *pdev)
-{
-	return msm_camera_drv_start(pdev, vb6801_sensor_probe);
-}
-
-static struct platform_driver msm_camera_driver = {
-	.probe = __vb6801_probe,
-	.driver = {
-		   .name = "msm_camera_vb6801",
-		   .owner = THIS_MODULE,
-		   },
-};
-
-static int __init vb6801_init(void)
-{
-	return platform_driver_register(&msm_camera_driver);
-}
-
-module_init(vb6801_init);
-void vb6801_exit(void)
-{
-	i2c_del_driver(&vb6801_i2c_driver);
-}
diff --git a/drivers/media/platform/msm/camera_v1/vb6801.h b/drivers/media/platform/msm/camera_v1/vb6801.h
deleted file mode 100644
index 5a8842c..0000000
--- a/drivers/media/platform/msm/camera_v1/vb6801.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* Copyright (c) 2008-2009, The Linux Foundation. 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.
- *
- */
-
-#ifndef VB6801_H
-#define VB6801_H
-
-#include <mach/board.h>
-
-extern struct vb6801_reg_t vb6801_regs;	/* from vb6801_reg.c */
-
-struct reg_struct {
-	uint16_t vt_pix_clk_div;	/*  0x0300 */
-	uint16_t vt_sys_clk_div;	/*  0x0302 */
-	uint16_t pre_pll_clk_div;	/*  0x0304 */
-	uint16_t pll_multiplier;	/*  0x0306 */
-	uint16_t op_pix_clk_div;	/*  0x0308 */
-	uint16_t op_sys_clk_div;	/*  0x030A */
-	uint16_t scale_m;	/*  0x0404 */
-	uint16_t row_speed;	/*  0x3016 */
-	uint16_t x_addr_start;	/*  0x3004 */
-	uint16_t x_addr_end;	/*  0x3008 */
-	uint16_t y_addr_start;	/*  0x3002 */
-	uint16_t y_addr_end;	/*  0x3006 */
-	uint16_t read_mode;	/*  0x3040 */
-	uint16_t x_output_size;	/*  0x034C */
-	uint16_t y_output_size;	/*  0x034E */
-	uint16_t line_length_pck;	/*  0x300C */
-	uint16_t frame_length_lines;	/*  0x300A */
-	uint16_t coarse_int_time;	/*  0x3012 */
-	uint16_t fine_int_time;	/*  0x3014 */
-};
-
-enum i2c_data_len {
-	D_LEN_BYTE,
-	D_LEN_WORD
-};
-
-struct vb6801_i2c_reg_conf_t {
-	unsigned short waddr;
-	unsigned short wdata;
-	uint8_t bdata;
-	enum i2c_data_len dlen;
-};
-
-struct vb6801_reg_t {
-	struct reg_struct const *reg_pat;
-	uint16_t reg_pat_size;
-	struct vb6801_i2c_reg_conf_t const *ttbl;
-	uint16_t ttbl_size;
-	struct vb6801_i2c_reg_conf_t const *lctbl;
-	uint16_t lctbl_size;
-	struct vb6801_i2c_reg_conf_t const *rftbl;
-	uint16_t rftbl_size;
-};
-
-#endif /* VB6801_H */
diff --git a/drivers/media/platform/msm/camera_v1/vfe/Makefile b/drivers/media/platform/msm/camera_v1/vfe/Makefile
deleted file mode 100644
index ead1075..0000000
--- a/drivers/media/platform/msm/camera_v1/vfe/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-GCC_VERSION      := $(shell $(CONFIG_SHELL) $(PWD)/scripts/gcc-version.sh $(CROSS_COMPILE)gcc)
-ccflags-y += -Idrivers/media/platform/msm/camera_v1
-ccflags-y += -Idrivers/media/platform/msm/camera_v1/server
-ifeq ($(GCC_VERSION),0404)
-CFLAGS_REMOVE_msm_vfe8x.o = -Wframe-larger-than=1024
-endif
-ifeq ($(CONFIG_MSM_CAMERA_V4L2),y)
-  obj-$(CONFIG_ARCH_MSM7X27A) += msm_vfe7x27a_v4l2.o
-  obj-$(CONFIG_ARCH_MSM8X60) += msm_vfe31_v4l2.o
-  obj-$(CONFIG_ARCH_MSM7X30) += msm_vfe31_v4l2.o
-else
-  obj-$(CONFIG_ARCH_MSM7X27A) += msm_vfe7x27a.o
-  obj-$(CONFIG_ARCH_MSM8X60) += msm_vfe31.o
-  obj-$(CONFIG_ARCH_MSM7X30) += msm_vfe31.o
-endif
-obj-$(CONFIG_ARCH_MSM_ARM11) += msm_vfe7x.o
-obj-$(CONFIG_ARCH_QSD8X50) += msm_vfe8x.o msm_vfe8x_proc.o
-obj-$(CONFIG_ARCH_MSM8960) += msm_vfe32.o
-obj-$(CONFIG_ARCH_MSM8974) += msm_vfe40.o
-obj-$(CONFIG_MSM_CAMERA_V4L2) += msm_vfe_stats_buf.o
diff --git a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe31.c b/drivers/media/platform/msm/camera_v1/vfe/msm_vfe31.c
deleted file mode 100644
index ab92085..0000000
--- a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe31.c
+++ /dev/null
@@ -1,4012 +0,0 @@
-/* Copyright (c) 2010-2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/uaccess.h>
-#include <linux/interrupt.h>
-#include <linux/slab.h>
-#include <linux/io.h>
-#include <mach/irqs.h>
-#include <mach/camera.h>
-#include <asm/atomic.h>
-
-#include "msm_vfe31.h"
-#include "msm_vpe1.h"
-atomic_t irq_cnt;
-
-static struct vfe31_ctrl_type *vfe31_ctrl;
-static struct msm_camera_io_clk camio_clk;
-static void *vfe_syncdata;
-static void vfe31_send_msg_no_payload(enum VFE31_MESSAGE_ID id);
-static void vfe31_reset_hist_cfg(void);
-
-struct vfe31_isr_queue_cmd {
-	struct list_head list;
-	uint32_t                           vfeInterruptStatus0;
-	uint32_t                           vfeInterruptStatus1;
-	uint32_t                           vfePingPongStatus;
-	struct vfe_frame_asf_info          vfeAsfFrameInfo;
-	struct vfe_frame_bpc_info          vfeBpcFrameInfo;
-	struct vfe_msg_camif_status        vfeCamifStatusLocal;
-};
-
-static struct vfe31_cmd_type vfe31_cmd[] = {
-/* 0*/	{V31_DUMMY_0},
-		{V31_SET_CLK},
-		{V31_RESET},
-		{V31_START},
-		{V31_TEST_GEN_START},
-/* 5*/	{V31_OPERATION_CFG, V31_OPERATION_CFG_LEN},
-		{V31_AXI_OUT_CFG, V31_AXI_OUT_LEN, V31_AXI_OUT_OFF, 0xFF},
-		{V31_CAMIF_CFG, V31_CAMIF_LEN, V31_CAMIF_OFF, 0xFF},
-		{V31_AXI_INPUT_CFG},
-		{V31_BLACK_LEVEL_CFG, V31_BLACK_LEVEL_LEN, V31_BLACK_LEVEL_OFF,
-		0xFF},
-/*10*/  {V31_ROLL_OFF_CFG, V31_ROLL_OFF_CFG_LEN, V31_ROLL_OFF_CFG_OFF,
-		0xFF},
-		{V31_DEMUX_CFG, V31_DEMUX_LEN, V31_DEMUX_OFF, 0xFF},
-		{V31_DEMOSAIC_0_CFG, V31_DEMOSAIC_0_LEN, V31_DEMOSAIC_0_OFF,
-		0xFF},
-		{V31_DEMOSAIC_1_CFG, V31_DEMOSAIC_1_LEN, V31_DEMOSAIC_1_OFF,
-		0xFF},
-		{V31_DEMOSAIC_2_CFG, V31_DEMOSAIC_2_LEN, V31_DEMOSAIC_2_OFF,
-		0xFF},
-/*15*/	{V31_FOV_CFG, V31_FOV_LEN, V31_FOV_OFF, 0xFF},
-		{V31_MAIN_SCALER_CFG, V31_MAIN_SCALER_LEN, V31_MAIN_SCALER_OFF,
-		0xFF},
-		{V31_WB_CFG, V31_WB_LEN, V31_WB_OFF, 0xFF},
-		{V31_COLOR_COR_CFG, V31_COLOR_COR_LEN, V31_COLOR_COR_OFF, 0xFF},
-		{V31_RGB_G_CFG, V31_RGB_G_LEN, V31_RGB_G_OFF, 0xFF},
-/*20*/	{V31_LA_CFG, V31_LA_LEN, V31_LA_OFF, 0xFF },
-		{V31_CHROMA_EN_CFG, V31_CHROMA_EN_LEN, V31_CHROMA_EN_OFF, 0xFF},
-		{V31_CHROMA_SUP_CFG, V31_CHROMA_SUP_LEN, V31_CHROMA_SUP_OFF,
-		0xFF},
-		{V31_MCE_CFG, V31_MCE_LEN, V31_MCE_OFF, 0xFF},
-		{V31_SK_ENHAN_CFG, V31_SCE_LEN, V31_SCE_OFF, 0xFF},
-/*25*/	{V31_ASF_CFG, V31_ASF_LEN, V31_ASF_OFF, 0xFF},
-		{V31_S2Y_CFG, V31_S2Y_LEN, V31_S2Y_OFF, 0xFF},
-		{V31_S2CbCr_CFG, V31_S2CbCr_LEN, V31_S2CbCr_OFF, 0xFF},
-		{V31_CHROMA_SUBS_CFG, V31_CHROMA_SUBS_LEN, V31_CHROMA_SUBS_OFF,
-		0xFF},
-		{V31_OUT_CLAMP_CFG, V31_OUT_CLAMP_LEN, V31_OUT_CLAMP_OFF,
-		0xFF},
-/*30*/	{V31_FRAME_SKIP_CFG, V31_FRAME_SKIP_LEN, V31_FRAME_SKIP_OFF,
-		0xFF},
-		{V31_DUMMY_1},
-		{V31_DUMMY_2},
-		{V31_DUMMY_3},
-		{V31_UPDATE},
-/*35*/	{V31_BL_LVL_UPDATE, V31_BLACK_LEVEL_LEN, V31_BLACK_LEVEL_OFF,
-		0xFF},
-		{V31_DEMUX_UPDATE, V31_DEMUX_LEN, V31_DEMUX_OFF, 0xFF},
-		{V31_DEMOSAIC_1_UPDATE, V31_DEMOSAIC_1_LEN, V31_DEMOSAIC_1_OFF,
-		0xFF},
-		{V31_DEMOSAIC_2_UPDATE, V31_DEMOSAIC_2_LEN, V31_DEMOSAIC_2_OFF,
-		0xFF},
-		{V31_FOV_UPDATE, V31_FOV_LEN, V31_FOV_OFF, 0xFF},
-/*40*/	{V31_MAIN_SCALER_UPDATE, V31_MAIN_SCALER_LEN, V31_MAIN_SCALER_OFF,
-		0xFF},
-		{V31_WB_UPDATE, V31_WB_LEN, V31_WB_OFF, 0xFF},
-		{V31_COLOR_COR_UPDATE, V31_COLOR_COR_LEN, V31_COLOR_COR_OFF,
-		0xFF},
-		{V31_RGB_G_UPDATE, V31_RGB_G_LEN, V31_CHROMA_EN_OFF, 0xFF},
-		{V31_LA_UPDATE, V31_LA_LEN, V31_LA_OFF, 0xFF },
-/*45*/	{V31_CHROMA_EN_UPDATE, V31_CHROMA_EN_LEN, V31_CHROMA_EN_OFF,
-		0xFF},
-		{V31_CHROMA_SUP_UPDATE, V31_CHROMA_SUP_LEN, V31_CHROMA_SUP_OFF,
-		0xFF},
-		{V31_MCE_UPDATE, V31_MCE_LEN, V31_MCE_OFF, 0xFF},
-		{V31_SK_ENHAN_UPDATE, V31_SCE_LEN, V31_SCE_OFF, 0xFF},
-		{V31_S2CbCr_UPDATE, V31_S2CbCr_LEN, V31_S2CbCr_OFF, 0xFF},
-/*50*/	{V31_S2Y_UPDATE, V31_S2Y_LEN, V31_S2Y_OFF, 0xFF},
-		{V31_ASF_UPDATE, V31_ASF_UPDATE_LEN, V31_ASF_OFF, 0xFF},
-		{V31_FRAME_SKIP_UPDATE},
-		{V31_CAMIF_FRAME_UPDATE},
-		{V31_STATS_AF_UPDATE, V31_STATS_AF_LEN, V31_STATS_AF_OFF},
-/*55*/	{V31_STATS_AE_UPDATE, V31_STATS_AE_LEN, V31_STATS_AE_OFF},
-		{V31_STATS_AWB_UPDATE, V31_STATS_AWB_LEN, V31_STATS_AWB_OFF},
-		{V31_STATS_RS_UPDATE, V31_STATS_RS_LEN, V31_STATS_RS_OFF},
-		{V31_STATS_CS_UPDATE, V31_STATS_CS_LEN, V31_STATS_CS_OFF},
-		{V31_STATS_SKIN_UPDATE},
-/*60*/	{V31_STATS_IHIST_UPDATE, V31_STATS_IHIST_LEN, V31_STATS_IHIST_OFF},
-		{V31_DUMMY_4},
-		{V31_EPOCH1_ACK},
-		{V31_EPOCH2_ACK},
-		{V31_START_RECORDING},
-/*65*/	{V31_STOP_RECORDING},
-		{V31_DUMMY_5},
-		{V31_DUMMY_6},
-		{V31_CAPTURE, V31_CAPTURE_LEN, 0xFF},
-		{V31_DUMMY_7},
-/*70*/	{V31_STOP},
-		{V31_GET_HW_VERSION},
-		{V31_GET_FRAME_SKIP_COUNTS},
-		{V31_OUTPUT1_BUFFER_ENQ},
-		{V31_OUTPUT2_BUFFER_ENQ},
-/*75*/	{V31_OUTPUT3_BUFFER_ENQ},
-		{V31_JPEG_OUT_BUF_ENQ},
-		{V31_RAW_OUT_BUF_ENQ},
-		{V31_RAW_IN_BUF_ENQ},
-		{V31_STATS_AF_ENQ},
-/*80*/	{V31_STATS_AE_ENQ},
-		{V31_STATS_AWB_ENQ},
-		{V31_STATS_RS_ENQ},
-		{V31_STATS_CS_ENQ},
-		{V31_STATS_SKIN_ENQ},
-/*85*/	{V31_STATS_IHIST_ENQ},
-		{V31_DUMMY_8},
-		{V31_JPEG_ENC_CFG},
-		{V31_DUMMY_9},
-		{V31_STATS_AF_START, V31_STATS_AF_LEN, V31_STATS_AF_OFF},
-/*90*/	{V31_STATS_AF_STOP},
-		{V31_STATS_AE_START, V31_STATS_AE_LEN, V31_STATS_AE_OFF},
-		{V31_STATS_AE_STOP},
-		{V31_STATS_AWB_START, V31_STATS_AWB_LEN, V31_STATS_AWB_OFF},
-		{V31_STATS_AWB_STOP},
-/*95*/	{V31_STATS_RS_START, V31_STATS_RS_LEN, V31_STATS_RS_OFF},
-		{V31_STATS_RS_STOP},
-		{V31_STATS_CS_START, V31_STATS_CS_LEN, V31_STATS_CS_OFF},
-		{V31_STATS_CS_STOP},
-		{V31_STATS_SKIN_START},
-/*100*/	{V31_STATS_SKIN_STOP},
-		{V31_STATS_IHIST_START,
-		V31_STATS_IHIST_LEN, V31_STATS_IHIST_OFF},
-		{V31_STATS_IHIST_STOP},
-		{V31_DUMMY_10},
-		{V31_SYNC_TIMER_SETTING, V31_SYNC_TIMER_LEN,
-			V31_SYNC_TIMER_OFF},
-/*105*/	{V31_ASYNC_TIMER_SETTING, V31_ASYNC_TIMER_LEN, V31_ASYNC_TIMER_OFF},
-		{V31_LIVESHOT},
-		{V31_ZSL, V31_CAPTURE_LEN, 0xFF},
-		{V31_STEREOCAM},
-		{V31_LA_SETUP},
-/*110*/	{V31_XBAR_CFG, V31_XBAR_CFG_LEN, V31_XBAR_CFG_OFF},
-/*111*/	{V31_EZTUNE_CFG, V31_EZTUNE_CFG_LEN, V31_EZTUNE_CFG_OFF},
-};
-
-uint32_t vfe31_AXI_WM_CFG[] = {
-	0x0000004C,
-	0x00000064,
-	0x0000007C,
-	0x00000094,
-	0x000000AC,
-	0x000000C4,
-	0x000000DC,
-};
-
-static const char *vfe31_general_cmd[] = {
-	"DUMMY_0",  /* 0 */
-	"SET_CLK",
-	"RESET",
-	"START",
-	"TEST_GEN_START",
-	"OPERATION_CFG",  /* 5 */
-	"AXI_OUT_CFG",
-	"CAMIF_CFG",
-	"AXI_INPUT_CFG",
-	"BLACK_LEVEL_CFG",
-	"ROLL_OFF_CFG",  /* 10 */
-	"DEMUX_CFG",
-	"DEMOSAIC_0_CFG",  /* general */
-	"DEMOSAIC_1_CFG",  /* ABF     */
-	"DEMOSAIC_2_CFG",  /* BPC     */
-	"FOV_CFG",  /* 15  */
-	"MAIN_SCALER_CFG",
-	"WB_CFG",
-	"COLOR_COR_CFG",
-	"RGB_G_CFG",
-	"LA_CFG",  /* 20 */
-	"CHROMA_EN_CFG",
-	"CHROMA_SUP_CFG",
-	"MCE_CFG",
-	"SK_ENHAN_CFG",
-	"ASF_CFG",  /* 25 */
-	"S2Y_CFG",
-	"S2CbCr_CFG",
-	"CHROMA_SUBS_CFG",
-	"OUT_CLAMP_CFG",
-	"FRAME_SKIP_CFG",  /* 30 */
-	"DUMMY_1",
-	"DUMMY_2",
-	"DUMMY_3",
-	"UPDATE",
-	"BL_LVL_UPDATE",  /* 35 */
-	"DEMUX_UPDATE",
-	"DEMOSAIC_1_UPDATE",  /* BPC */
-	"DEMOSAIC_2_UPDATE",  /* ABF */
-	"FOV_UPDATE",
-	"MAIN_SCALER_UPDATE",  /* 40 */
-	"WB_UPDATE",
-	"COLOR_COR_UPDATE",
-	"RGB_G_UPDATE",
-	"LA_UPDATE",
-	"CHROMA_EN_UPDATE",  /* 45 */
-	"CHROMA_SUP_UPDATE",
-	"MCE_UPDATE",
-	"SK_ENHAN_UPDATE",
-	"S2CbCr_UPDATE",
-	"S2Y_UPDATE",  /* 50 */
-	"ASF_UPDATE",
-	"FRAME_SKIP_UPDATE",
-	"CAMIF_FRAME_UPDATE",
-	"STATS_AF_UPDATE",
-	"STATS_AE_UPDATE",  /* 55 */
-	"STATS_AWB_UPDATE",
-	"STATS_RS_UPDATE",
-	"STATS_CS_UPDATE",
-	"STATS_SKIN_UPDATE",
-	"STATS_IHIST_UPDATE",  /* 60 */
-	"DUMMY_4",
-	"EPOCH1_ACK",
-	"EPOCH2_ACK",
-	"START_RECORDING",
-	"STOP_RECORDING",  /* 65 */
-	"DUMMY_5",
-	"DUMMY_6",
-	"CAPTURE",
-	"DUMMY_7",
-	"STOP",  /* 70 */
-	"GET_HW_VERSION",
-	"GET_FRAME_SKIP_COUNTS",
-	"OUTPUT1_BUFFER_ENQ",
-	"OUTPUT2_BUFFER_ENQ",
-	"OUTPUT3_BUFFER_ENQ",  /* 75 */
-	"JPEG_OUT_BUF_ENQ",
-	"RAW_OUT_BUF_ENQ",
-	"RAW_IN_BUF_ENQ",
-	"STATS_AF_ENQ",
-	"STATS_AE_ENQ",  /* 80 */
-	"STATS_AWB_ENQ",
-	"STATS_RS_ENQ",
-	"STATS_CS_ENQ",
-	"STATS_SKIN_ENQ",
-	"STATS_IHIST_ENQ",  /* 85 */
-	"DUMMY_8",
-	"JPEG_ENC_CFG",
-	"DUMMY_9",
-	"STATS_AF_START",
-	"STATS_AF_STOP",  /* 90 */
-	"STATS_AE_START",
-	"STATS_AE_STOP",
-	"STATS_AWB_START",
-	"STATS_AWB_STOP",
-	"STATS_RS_START",  /* 95 */
-	"STATS_RS_STOP",
-	"STATS_CS_START",
-	"STATS_CS_STOP",
-	"STATS_SKIN_START",
-	"STATS_SKIN_STOP",  /* 100 */
-	"STATS_IHIST_START",
-	"STATS_IHIST_STOP",
-	"DUMMY_10",
-	"SYNC_TIMER_SETTING",
-	"ASYNC_TIMER_SETTING",  /* 105 */
-	"V31_LIVESHOT",
-	"V31_ZSL",
-	"V31_STEREOCAM",
-	"V31_LA_SETUP",
-	"V31_XBAR_CFG",
-};
-
-static void vfe_addr_convert(struct msm_vfe_phy_info *pinfo,
-	enum vfe_resp_msg type, void *data, void **ext, int32_t *elen)
-{
-	uint8_t outid;
-	switch (type) {
-	case VFE_MSG_OUTPUT_T:
-	case VFE_MSG_OUTPUT_P:
-	case VFE_MSG_OUTPUT_S:
-	case VFE_MSG_OUTPUT_V:
-	{
-		pinfo->output_id =
-			((struct vfe_message *)data)->_u.msgOut.output_id;
-
-		switch (type) {
-		case VFE_MSG_OUTPUT_P:
-			outid = OUTPUT_TYPE_P;
-			break;
-		case VFE_MSG_OUTPUT_V:
-			outid = OUTPUT_TYPE_V;
-			break;
-		case VFE_MSG_OUTPUT_T:
-			outid = OUTPUT_TYPE_T;
-			break;
-		case VFE_MSG_OUTPUT_S:
-			outid = OUTPUT_TYPE_S;
-			break;
-		default:
-			outid = 0xff;
-			break;
-		}
-		pinfo->output_id = outid;
-		pinfo->p0_phy =
-			((struct vfe_message *)data)->_u.msgOut.p0_addr;
-		pinfo->p1_phy =
-			((struct vfe_message *)data)->_u.msgOut.p1_addr;
-		pinfo->p2_phy =
-			((struct vfe_message *)data)->_u.msgOut.p2_addr;
-
-		pinfo->frame_id =
-		((struct vfe_message *)data)->_u.msgOut.frameCounter;
-
-		((struct vfe_msg_output *)(vfe31_ctrl->extdata))->bpcInfo =
-		((struct vfe_message *)data)->_u.msgOut.bpcInfo;
-		((struct vfe_msg_output *)(vfe31_ctrl->extdata))->asfInfo =
-		((struct vfe_message *)data)->_u.msgOut.asfInfo;
-		((struct vfe_msg_output *)(vfe31_ctrl->extdata))->frameCounter =
-		((struct vfe_message *)data)->_u.msgOut.frameCounter;
-		*ext  = vfe31_ctrl->extdata;
-		*elen = vfe31_ctrl->extlen;
-	}
-		break;
-
-	default:
-		break;
-	} /* switch */
-}
-
-
-static void vfe31_proc_ops(enum VFE31_MESSAGE_ID id, void *msg, size_t len)
-{
-	struct msm_vfe_resp *rp;
-
-	rp = vfe31_ctrl->resp->vfe_alloc(sizeof(struct msm_vfe_resp),
-		vfe31_ctrl->syncdata, GFP_ATOMIC);
-	if (!rp) {
-		CDBG("rp: cannot allocate buffer\n");
-		return;
-	}
-	CDBG("vfe31_proc_ops, msgId = %d\n", id);
-	rp->evt_msg.type   = MSM_CAMERA_MSG;
-	rp->evt_msg.msg_id = id;
-	rp->evt_msg.len    = len;
-	rp->evt_msg.data   = msg;
-
-	switch (rp->evt_msg.msg_id) {
-	case MSG_ID_SNAPSHOT_DONE:
-		rp->type = VFE_MSG_SNAPSHOT;
-		break;
-
-	case MSG_ID_OUTPUT_P:
-		rp->type = VFE_MSG_OUTPUT_P;
-		vfe_addr_convert(&(rp->phy), VFE_MSG_OUTPUT_P,
-			rp->evt_msg.data, &(rp->extdata),
-			&(rp->extlen));
-		break;
-
-	case MSG_ID_OUTPUT_T:
-		rp->type = VFE_MSG_OUTPUT_T;
-		vfe_addr_convert(&(rp->phy), VFE_MSG_OUTPUT_T,
-			rp->evt_msg.data, &(rp->extdata),
-			&(rp->extlen));
-		break;
-
-	case MSG_ID_OUTPUT_S:
-		rp->type = VFE_MSG_OUTPUT_S;
-		vfe_addr_convert(&(rp->phy), VFE_MSG_OUTPUT_S,
-			rp->evt_msg.data, &(rp->extdata),
-			&(rp->extlen));
-		break;
-
-	case MSG_ID_OUTPUT_V:
-		rp->type = VFE_MSG_OUTPUT_V;
-		vfe_addr_convert(&(rp->phy), VFE_MSG_OUTPUT_V,
-			rp->evt_msg.data, &(rp->extdata),
-			&(rp->extlen));
-		break;
-
-	case MSG_ID_COMMON:
-		rp->type = VFE_MSG_COMMON;
-		rp->stats_msg.status_bits = ((struct vfe_message *)
-			rp->evt_msg.data)->_u.msgStats.status_bits;
-		rp->stats_msg.frame_id = ((struct vfe_message *)
-			rp->evt_msg.data)->_u.msgStats.frameCounter;
-
-		rp->stats_msg.aec_buff = ((struct vfe_message *)
-			rp->evt_msg.data)->_u.msgStats.buff.aec;
-		rp->stats_msg.awb_buff = ((struct vfe_message *)
-			rp->evt_msg.data)->_u.msgStats.buff.awb;
-		rp->stats_msg.af_buff = ((struct vfe_message *)
-			rp->evt_msg.data)->_u.msgStats.buff.af;
-		rp->stats_msg.ihist_buff = ((struct vfe_message *)
-			rp->evt_msg.data)->_u.msgStats.buff.ihist;
-		rp->stats_msg.rs_buff = ((struct vfe_message *)
-			rp->evt_msg.data)->_u.msgStats.buff.rs;
-		rp->stats_msg.cs_buff = ((struct vfe_message *)
-			rp->evt_msg.data)->_u.msgStats.buff.cs;
-		rp->stats_msg.awb_ymin = ((struct vfe_message *)
-			rp->evt_msg.data)->_u.msgStats.buff.awb_ymin;
-		break;
-
-	case MSG_ID_SYNC_TIMER0_DONE:
-		rp->type = VFE_MSG_SYNC_TIMER0;
-		break;
-
-	case MSG_ID_SYNC_TIMER1_DONE:
-		rp->type = VFE_MSG_SYNC_TIMER1;
-		break;
-
-	case MSG_ID_SYNC_TIMER2_DONE:
-		rp->type = VFE_MSG_SYNC_TIMER2;
-		break;
-
-	default:
-		rp->type = VFE_MSG_GENERAL;
-		break;
-	}
-
-	/* save the frame id.*/
-	rp->evt_msg.frame_id = rp->phy.frame_id;
-
-	vfe31_ctrl->resp->vfe_resp(rp, MSM_CAM_Q_VFE_MSG, vfe31_ctrl->syncdata,
-		GFP_ATOMIC);
-}
-
-static void vfe_send_outmsg(uint8_t msgid, uint32_t p0_addr,
-	uint32_t p1_addr, uint32_t p2_addr)
-{
-	struct vfe_message msg;
-	uint8_t outid;
-
-	msg._d = msgid;   /* now the output mode is redundnat. */
-	msg._u.msgOut.frameCounter = vfe31_ctrl->vfeFrameId;
-
-	switch (msgid) {
-	case MSG_ID_OUTPUT_P:
-		outid = OUTPUT_TYPE_P;
-		break;
-	case MSG_ID_OUTPUT_V:
-		outid = OUTPUT_TYPE_V;
-		break;
-	case MSG_ID_OUTPUT_T:
-		outid = OUTPUT_TYPE_T;
-		break;
-	case MSG_ID_OUTPUT_S:
-		outid = OUTPUT_TYPE_S;
-		break;
-	default:
-		outid = 0xff;  /* -1 for error condition.*/
-		break;
-	}
-	msg._u.msgOut.output_id   = msgid;
-	msg._u.msgOut.p0_addr     = p0_addr;
-	msg._u.msgOut.p1_addr     = p1_addr;
-	msg._u.msgOut.p2_addr     = p2_addr;
-	CDBG("%s p2_addr = 0x%x\n", __func__, p2_addr);
-	vfe31_proc_ops(msgid, &msg, sizeof(struct vfe_message));
-	return;
-}
-static int vfe31_enable(struct camera_enable_cmd *enable)
-{
-	return 0;
-}
-
-static void vfe31_stop(void)
-{
-	atomic_set(&vfe31_ctrl->vstate, 0);
-	atomic_set(&vfe31_ctrl->stop_ack_pending, 1);
-
-	/* in either continuous or snapshot mode, stop command can be issued
-	 * at any time. stop camif immediately. */
-	msm_camera_io_w_mb(CAMIF_COMMAND_STOP_IMMEDIATELY,
-		vfe31_ctrl->vfebase + VFE_CAMIF_COMMAND);
-
-	/* disable all interrupts.  */
-	msm_camera_io_w(VFE_DISABLE_ALL_IRQS,
-		vfe31_ctrl->vfebase + VFE_IRQ_MASK_0);
-	msm_camera_io_w(VFE_DISABLE_ALL_IRQS,
-		vfe31_ctrl->vfebase + VFE_IRQ_MASK_1);
-
-	/* clear all pending interrupts*/
-	msm_camera_io_w(VFE_CLEAR_ALL_IRQS,
-		vfe31_ctrl->vfebase + VFE_IRQ_CLEAR_0);
-	msm_camera_io_w(VFE_CLEAR_ALL_IRQS,
-		vfe31_ctrl->vfebase + VFE_IRQ_CLEAR_1);
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(1,
-		vfe31_ctrl->vfebase + VFE_IRQ_CMD);
-
-	/* now enable only halt_irq & reset_irq */
-	msm_camera_io_w(0xf0000000,          /* this is for async timer. */
-		vfe31_ctrl->vfebase + VFE_IRQ_MASK_0);
-	msm_camera_io_w(VFE_IMASK_AXI_HALT,
-		vfe31_ctrl->vfebase + VFE_IRQ_MASK_1);
-
-	/* then apply axi halt command. */
-	msm_camera_io_w_mb(AXI_HALT,
-		vfe31_ctrl->vfebase + VFE_AXI_CMD);
-}
-
-static int vfe31_disable(struct camera_enable_cmd *enable,
-	struct platform_device *dev)
-{
-	msm_camio_set_perf_lvl(S_EXIT);
-	msm_camio_disable(dev);
-	return 0;
-}
-
-static int vfe31_add_free_buf2(struct vfe31_output_ch *outch,
-	uint32_t paddr, uint32_t p0_off, uint32_t p1_off, uint32_t p2_off)
-{
-	struct vfe31_free_buf *free_buf = NULL;
-	unsigned long flags = 0;
-	free_buf = kmalloc(sizeof(struct vfe31_free_buf), GFP_KERNEL);
-	if (!free_buf)
-		return -ENOMEM;
-
-	spin_lock_irqsave(&outch->free_buf_lock, flags);
-	free_buf->paddr = paddr;
-	free_buf->planar0_off = p0_off;
-	free_buf->planar1_off = p1_off;
-	free_buf->planar2_off = p2_off;
-	list_add_tail(&free_buf->node, &outch->free_buf_head);
-
-	CDBG("%s: free_buf paddr = 0x%x, y_off = %d, cbcr_off = %d\n",
-		__func__, free_buf->paddr, free_buf->planar0_off,
-		free_buf->planar1_off);
-	spin_unlock_irqrestore(&outch->free_buf_lock, flags);
-	return 0;
-}
-
-#define vfe31_add_free_buf(outch, regptr) \
-	vfe31_add_free_buf2(outch, regptr->paddr, \
-	regptr->info.planar0_off,	\
-	regptr->info.planar1_off,	\
-	regptr->info.planar2_off)
-
-#define vfe31_free_buf_available(outch) \
-	(!list_empty(&outch.free_buf_head))
-
-static inline struct vfe31_free_buf *vfe31_get_free_buf(
-	struct vfe31_output_ch *outch)
-{
-	unsigned long flags = 0;
-	struct vfe31_free_buf *free_buf = NULL;
-	spin_lock_irqsave(&outch->free_buf_lock, flags);
-	if (!list_empty(&outch->free_buf_head)) {
-		free_buf = list_first_entry(&outch->free_buf_head,
-			struct vfe31_free_buf, node);
-		if (free_buf)
-			list_del_init(&free_buf->node);
-	}
-	spin_unlock_irqrestore(&outch->free_buf_lock, flags);
-	return free_buf;
-}
-
-static inline void vfe31_reset_free_buf_queue(
-	struct vfe31_output_ch *outch)
-{
-	unsigned long flags = 0;
-	struct vfe31_free_buf *free_buf = NULL;
-	spin_lock_irqsave(&outch->free_buf_lock, flags);
-	while (!list_empty(&outch->free_buf_head)) {
-		free_buf = list_first_entry(&outch->free_buf_head,
-			struct vfe31_free_buf, node);
-		if (free_buf) {
-			list_del_init(&free_buf->node);
-			kfree(free_buf);
-		}
-	}
-	spin_unlock_irqrestore(&outch->free_buf_lock, flags);
-}
-
-#define vfe31_init_free_buf_queue() do {	\
-	INIT_LIST_HEAD(&vfe31_ctrl->outpath.out0.free_buf_head);	\
-	INIT_LIST_HEAD(&vfe31_ctrl->outpath.out1.free_buf_head);	\
-	INIT_LIST_HEAD(&vfe31_ctrl->outpath.out2.free_buf_head);	\
-	spin_lock_init(&vfe31_ctrl->outpath.out0.free_buf_lock);	\
-	spin_lock_init(&vfe31_ctrl->outpath.out1.free_buf_lock);	\
-	spin_lock_init(&vfe31_ctrl->outpath.out2.free_buf_lock);	\
-} while (0)
-
-#define vfe31_reset_free_buf_queue_all() do {	\
-	vfe31_reset_free_buf_queue(&vfe31_ctrl->outpath.out0);	\
-	vfe31_reset_free_buf_queue(&vfe31_ctrl->outpath.out1);	\
-	vfe31_reset_free_buf_queue(&vfe31_ctrl->outpath.out2);	\
-} while (0)
-
-static int vfe31_config_axi(int mode, struct axidata *ad, uint32_t *ao)
-{
-	int i;
-	uint32_t *p, *p1, *p2, *p3;
-	int32_t *ch_info;
-	struct vfe31_output_ch *outp1, *outp2, *outp3;
-	struct msm_pmem_region *regp1 = NULL;
-	struct msm_pmem_region *regp2 = NULL;
-	struct msm_pmem_region *regp3 = NULL;
-	int ret;
-	struct msm_sync* p_sync = (struct msm_sync *)vfe_syncdata;
-
-	outp1 = NULL;
-	outp2 = NULL;
-	outp3 = NULL;
-
-	p = ao + 2;
-
-	/* Update the corresponding write masters for each output*/
-	ch_info = ao + V31_AXI_CFG_LEN;
-	vfe31_ctrl->outpath.out0.ch0 = 0x0000FFFF & *ch_info;
-	vfe31_ctrl->outpath.out0.ch1 = 0x0000FFFF & (*ch_info++ >> 16);
-	vfe31_ctrl->outpath.out0.ch2 = 0x0000FFFF & *ch_info++;
-	vfe31_ctrl->outpath.out1.ch0 = 0x0000FFFF & *ch_info;
-	vfe31_ctrl->outpath.out1.ch1 = 0x0000FFFF & (*ch_info++ >> 16);
-	vfe31_ctrl->outpath.out1.ch2 = 0x0000FFFF & *ch_info++;
-	vfe31_ctrl->outpath.out2.ch0 = 0x0000FFFF & *ch_info;
-	vfe31_ctrl->outpath.out2.ch1 = 0x0000FFFF & (*ch_info++ >> 16);
-	vfe31_ctrl->outpath.out2.ch2 = 0x0000FFFF & *ch_info++;
-
-	CDBG("vfe31_config_axi: mode = %d, bufnum1 = %d, bufnum2 = %d"
-		"bufnum3 = %d", mode, ad->bufnum1, ad->bufnum2, ad->bufnum3);
-
-	switch (mode) {
-
-	case OUTPUT_2: {
-		if (ad->bufnum2 != 3)
-			return -EINVAL;
-		regp1 = &(ad->region[ad->bufnum1]);
-		outp1 = &(vfe31_ctrl->outpath.out0);
-		vfe31_ctrl->outpath.output_mode |= VFE31_OUTPUT_MODE_PT;
-
-		for (i = 0; i < 2; i++) {
-			p1 = ao + 6 + i;    /* wm0 for y  */
-			*p1 = (regp1->paddr + regp1->info.planar0_off);
-
-			p1 = ao + 12 + i;  /* wm1 for cbcr */
-			*p1 = (regp1->paddr + regp1->info.planar1_off);
-			regp1++;
-		}
-		ret = vfe31_add_free_buf(outp1, regp1);
-		if (ret < 0)
-			return ret;
-	}
-		break;
-
-	case OUTPUT_1_AND_2:
-		/* use wm0& 4 for thumbnail, wm1&5 for main image.*/
-		if ((ad->bufnum1 < 1) || (ad->bufnum2 < 1))
-			return -EINVAL;
-		vfe31_ctrl->outpath.output_mode |=
-			VFE31_OUTPUT_MODE_S;  /* main image.*/
-		vfe31_ctrl->outpath.output_mode |=
-			VFE31_OUTPUT_MODE_PT;  /* thumbnail. */
-
-		/* this is thumbnail buffer. */
-		regp1 = &(ad->region[ad->bufnum1-1]);
-		/* this is main image buffer. */
-		regp2 = &(ad->region[ad->bufnum1+ad->bufnum2-1]);
-
-		outp1 = &(vfe31_ctrl->outpath.out0);
-		outp2 = &(vfe31_ctrl->outpath.out1); /* snapshot */
-
-		/*  Parse the buffers!!! */
-		if (ad->bufnum2 == 1) {	/* assuming bufnum1 = bufnum2 */
-			p1 = ao + 6;   /* wm0 ping */
-			*p1++ = (regp1->paddr + regp1->info.planar0_off);
-
-			/* this is to duplicate ping address to pong.*/
-			*p1 = (regp1->paddr + regp1->info.planar0_off);
-
-			p1 = ao + 30;  /* wm4 ping */
-			*p1++ = (regp1->paddr + regp1->info.planar1_off);
-			CDBG("%s: regp1->info.cbcr_off = 0x%x\n", __func__,
-						 regp1->info.planar1_off);
-
-			/* this is to duplicate ping address to pong.*/
-			*p1 = (regp1->paddr + regp1->info.planar1_off);
-
-			p1 = ao + 12;   /* wm1 ping */
-			*p1++ = (regp2->paddr + regp2->info.planar0_off);
-
-			/* pong = ping,*/
-			*p1 = (regp2->paddr + regp2->info.planar0_off);
-
-			p1 = ao + 36;  /* wm5 */
-			*p1++ = (regp2->paddr + regp2->info.planar1_off);
-			CDBG("%s: regp2->info.cbcr_off = 0x%x\n", __func__,
-						 regp2->info.planar1_off);
-
-			/* pong = ping,*/
-			*p1 = (regp2->paddr + regp2->info.planar1_off);
-		} else { /* more than one snapshot */
-			/* first fill ping & pong */
-			for (i = 0; i < 2; i++) {
-				p1 = ao + 6 + i;    /* wm0 for y  */
-				*p1 = (regp1->paddr + regp1->info.planar0_off);
-				p1 = ao + 30 + i;  /* wm4 for cbcr */
-				*p1 = (regp1->paddr + regp1->info.planar1_off);
-				regp1--;
-			}
-
-			for (i = 0; i < 2; i++) {
-				p2 = ao + 12 + i;    /* wm1 for y  */
-				*p2 = (regp2->paddr + regp2->info.planar0_off);
-				p2 = ao + 36 + i;  /* wm5 for cbcr */
-				*p2 = (regp2->paddr + regp2->info.planar1_off);
-				regp2--;
-			}
-
-			for (i = 2; i < ad->bufnum1; i++) {
-				ret = vfe31_add_free_buf(outp1, regp1);
-				if (ret < 0)
-					return ret;
-				regp1--;
-			}
-
-			for (i = 2; i < ad->bufnum2; i++) {
-				ret = vfe31_add_free_buf(outp2, regp2);
-				if (ret < 0)
-					return ret;
-				regp2--;
-			}
-		}
-		break;
-
-	case OUTPUT_1_2_AND_3:
-		CDBG("%s: OUTPUT_1_2_AND_3", __func__);
-		CDBG("%s: %d %d %d", __func__, ad->bufnum1, ad->bufnum2,
-			ad->bufnum3);
-		/* use wm0& 4 for postview, wm1&5 for preview.*/
-		/* use wm2& 6 for main img */
-		if ((ad->bufnum1 < 1) || (ad->bufnum2 < 1) || (ad->bufnum3 < 1))
-			return -EINVAL;
-		vfe31_ctrl->outpath.output_mode |=
-			VFE31_OUTPUT_MODE_S;  /* main image.*/
-		vfe31_ctrl->outpath.output_mode |=
-			VFE31_OUTPUT_MODE_P;  /* preview. */
-		vfe31_ctrl->outpath.output_mode |=
-			VFE31_OUTPUT_MODE_T;  /* thumbnail. */
-
-		/* this is preview buffer. */
-		regp1 = &(ad->region[0]);
-		/* this is thumbnail buffer. */
-		regp2 = &(ad->region[ad->bufnum1]);
-		/* this is main image buffer. */
-		regp3 = &(ad->region[ad->bufnum1+ad->bufnum2]);
-		outp1 = &(vfe31_ctrl->outpath.out0);
-		outp2 = &(vfe31_ctrl->outpath.out1);
-		outp3 = &(vfe31_ctrl->outpath.out2);
-
-		/*  Parse the buffers!!! */
-		/* first fill ping & pong */
-		for (i = 0; i < 2; i++) {
-			p1 = ao + 6 + i;    /* wm0 for y  */
-			*p1 = (regp1->paddr + regp1->info.planar0_off);
-			p1 = ao + 30 + i;  /* wm4 for cbcr */
-			*p1 = (regp1->paddr + regp1->info.planar1_off);
-			regp1++;
-		}
-
-		for (i = 0; i < 2; i++) {
-			p2 = ao + 12 + i;    /* wm1 for y  */
-			*p2 = (regp2->paddr + regp2->info.planar0_off);
-			p2 = ao + 36 + i;  /* wm5 for cbcr */
-			*p2 = (regp2->paddr + regp2->info.planar1_off);
-			regp2++;
-		}
-
-		for (i = 0; i < 2; i++) {
-			p3 = ao + 18 + i;    /* wm2 for y  */
-			*p3 = (regp3->paddr + regp3->info.planar0_off);
-			p3 = ao + 42 + i;  /* wm6 for cbcr */
-			*p3 = (regp3->paddr + regp3->info.planar1_off);
-			regp3++;
-		}
-
-		for (i = 2; i < ad->bufnum1; i++) {
-			ret = vfe31_add_free_buf(outp1, regp1);
-			if (ret < 0)
-				return ret;
-			regp1++;
-		}
-
-		for (i = 2; i < ad->bufnum2; i++) {
-			ret = vfe31_add_free_buf(outp2, regp2);
-			if (ret < 0)
-				return ret;
-			regp2++;
-		}
-
-		for (i = 2; i < ad->bufnum3; i++) {
-			ret = vfe31_add_free_buf(outp3, regp3);
-			if (ret < 0)
-				return ret;
-			regp3++;
-		}
-		break;
-
-	case OUTPUT_ZSL_ALL_CHNLS:
-		CDBG("%s: OUTPUT_ZSL_ALL_CHNLS", __func__);
-		CDBG("%s: %d %d %d", __func__, ad->bufnum1, ad->bufnum2,
-			ad->bufnum3);
-		/* use wm0& 4 for postview, wm1&5 for preview.*/
-		/* use wm2& 6 for main img */
-		if ((ad->bufnum1 < 1) || (ad->bufnum2 < 1) || (ad->bufnum3 < 1))
-			return -EINVAL;
-		vfe31_ctrl->outpath.output_mode |=
-			VFE31_OUTPUT_MODE_S;  /* main image.*/
-		vfe31_ctrl->outpath.output_mode |=
-			VFE31_OUTPUT_MODE_P_ALL_CHNLS;  /* preview. */
-		vfe31_ctrl->outpath.output_mode |=
-			VFE31_OUTPUT_MODE_T;  /* thumbnail. */
-
-		/* this is preview buffer. */
-		regp1 = &(ad->region[0]);
-		/* this is thumbnail buffer. */
-		regp2 = &(ad->region[ad->bufnum1]);
-		/* this is main image buffer. */
-		regp3 = &(ad->region[ad->bufnum1+ad->bufnum2]);
-		outp1 = &(vfe31_ctrl->outpath.out0);
-		outp2 = &(vfe31_ctrl->outpath.out1);
-		outp3 = &(vfe31_ctrl->outpath.out2);
-
-		/*  Parse the buffers!!! */
-		/* first fill ping & pong */
-		for (i = 0; i < 2; i++) {
-			p1 = ao + 6 + i;    /* wm0 for y  */
-			*p1 = (regp2->paddr + regp2->info.planar0_off);
-			p1 = ao + 12 + i;  /* wm1 for cbcr */
-			*p1 = (regp2->paddr + regp2->info.planar1_off);
-			regp2++;
-		}
-
-		for (i = 0; i < 2; i++) {
-			p2 = ao + 30 + i;    /* wm4 for y  */
-			*p2 = (regp1->paddr + regp1->info.planar0_off);
-			p2 = ao + 36 + i;  /* wm5 for cbcr */
-			*p2 = (regp1->paddr + regp1->info.planar1_off);
-			p2 = ao + 42 + i;  /* wm5 for cbcr */
-			*p2 = (regp1->paddr + regp1->info.planar2_off);
-			regp1++;
-		}
-
-		for (i = 0; i < 2; i++) {
-			p3 = ao + 18 + i;    /* wm2 for y  */
-			*p3 = (regp3->paddr + regp3->info.planar0_off);
-			p3 = ao + 24 + i;  /* wm3 for cbcr */
-			*p3 = (regp3->paddr + regp3->info.planar1_off);
-			regp3++;
-		}
-		for (i = 2; i < ad->bufnum1; i++) {
-			ret = vfe31_add_free_buf(outp1, regp1);
-			if (ret < 0)
-				return ret;
-			regp1++;
-		}
-
-		for (i = 2; i < ad->bufnum2; i++) {
-			ret = vfe31_add_free_buf(outp2, regp2);
-			if (ret < 0)
-				return ret;
-			regp2++;
-		}
-
-		for (i = 2; i < ad->bufnum3; i++) {
-			ret = vfe31_add_free_buf(outp3, regp3);
-			if (ret < 0)
-				return ret;
-			regp3++;
-		}
-		break;
-
-	case OUTPUT_1_AND_3: {
-		/* use wm0&4 for preview, wm1&5 for video.*/
-		if ((ad->bufnum1 < 2) || (ad->bufnum2 < 2))
-			return -EINVAL;
-
-#ifdef CONFIG_MSM_CAMERA_V4L2
-		*p++ = 0x1;    /* xbar cfg0 */
-		*p = 0x1a03;    /* xbar cfg1 */
-#endif
-		vfe31_ctrl->outpath.output_mode |=
-			VFE31_OUTPUT_MODE_V;  /* video*/
-		vfe31_ctrl->outpath.output_mode |=
-			VFE31_OUTPUT_MODE_PT;  /* preview */
-
-		regp1 = &(ad->region[0]); /* this is preview buffer. */
-		regp2 = &(ad->region[ad->bufnum1]);/* this is video buffer. */
-		outp1 = &(vfe31_ctrl->outpath.out0); /* preview */
-		outp2 = &(vfe31_ctrl->outpath.out2); /* video */
-
-
-		for (i = 0; i < 2; i++) {
-			p1 = ao + 6 + i;    /* wm0 for y  */
-			*p1 = (regp1->paddr + regp1->info.planar0_off);
-
-			p1 = ao + 30 + i;  /* wm4 for cbcr */
-			*p1 = (regp1->paddr + regp1->info.planar1_off);
-			regp1++;
-		}
-
-		for (i = 0; i < 2; i++) {
-			p2 = ao + 12 + i;    /* wm1 for y  */
-			*p2 = (regp2->paddr + regp2->info.planar0_off);
-
-			p2 = ao + 36 + i;  /* wm5 for cbcr */
-			*p2 = (regp2->paddr + regp2->info.planar1_off);
-			regp2++;
-		}
-		for (i = 2; i < ad->bufnum1; i++) {
-			ret = vfe31_add_free_buf(outp1, regp1);
-			if (ret < 0)
-				return ret;
-			regp1++;
-		}
-
-		for (i = 2; i < ad->bufnum2; i++) {
-			ret = vfe31_add_free_buf(outp2, regp2);
-			if (ret < 0)
-				return ret;
-			regp2++;
-		}
-	}
-		break;
-
-	case OUTPUT_VIDEO_ALL_CHNLS: {
-		/* use wm0&4 for preview, wm1&5 for video.*/
-		vfe31_ctrl->outpath.output_mode |=
-			VFE31_OUTPUT_MODE_V;  /* video*/
-		vfe31_ctrl->outpath.output_mode |=
-			VFE31_OUTPUT_MODE_P_ALL_CHNLS;
-		regp1 = &(ad->region[0]);
-		regp2 = &(ad->region[ad->bufnum1]);
-		outp1 = &(vfe31_ctrl->outpath.out0);
-		outp2 = &(vfe31_ctrl->outpath.out2);
-
-		for (i = 0; i < 2; i++) {
-			p1 = ao + 6 + i;    /* wm0 for y  */
-			*p1 = (regp1->paddr + regp1->info.planar0_off);
-
-			p1 = ao + 12 + i;  /* wm1 for cbcr */
-			*p1 = (regp1->paddr + regp1->info.planar1_off);
-
-			p1 = ao + 18 + i;  /* wm2 for cbcr */
-			*p1 = (regp1->paddr + regp1->info.planar2_off);
-			regp1++;
-		}
-		for (i = 0; i < 2; i++) {
-			p2 = ao + 30 + i;    /* wm4 for y  */
-			*p2 = (regp2->paddr + regp2->info.planar0_off);
-
-			p2 = ao + 36 + i;  /* wm5 for cbcr */
-			*p2 = (regp2->paddr + regp2->info.planar1_off);
-			regp2++;
-		}
-		for (i = 2; i < ad->bufnum1; i++) {
-			ret = vfe31_add_free_buf(outp1, regp1);
-			if (ret < 0)
-				return ret;
-			regp1++;
-		}
-		for (i = 2; i < ad->bufnum2; i++) {
-			ret = vfe31_add_free_buf(outp2, regp2);
-			if (ret < 0)
-				return ret;
-			regp2++;
-		}
-	}
-		break;
-
-	case CAMIF_TO_AXI_VIA_OUTPUT_2: {  /* use wm0 only */
-		if (ad->bufnum2 < 1)
-			return -EINVAL;
-		CDBG("config axi for raw snapshot.\n");
-		vfe31_ctrl->outpath.out1.ch0 = 0; /* raw */
-		regp1 = &(ad->region[ad->bufnum1]);
-		vfe31_ctrl->outpath.output_mode |= VFE31_OUTPUT_MODE_S;
-		p1 = ao + 6;    /* wm0 for y  */
-		*p1 = (regp1->paddr + regp1->info.planar0_off);
-		if (p_sync->stereocam_enabled)
-			p_sync->stereo_state = STEREO_RAW_SNAP_IDLE;
-	}
-		break;
-	default:
-		break;
-	}
-	msm_camera_io_memcpy(
-		vfe31_ctrl->vfebase + vfe31_cmd[V31_AXI_OUT_CFG].offset,
-		ao, vfe31_cmd[V31_AXI_OUT_CFG].length - V31_AXI_CH_INF_LEN);
-
-	return 0;
-}
-
-static void vfe31_reset_internal_variables(void)
-{
-	unsigned long flags;
-	vfe31_ctrl->vfeImaskCompositePacked = 0;
-	/* state control variables */
-	vfe31_ctrl->start_ack_pending = FALSE;
-	atomic_set(&irq_cnt, 0);
-
-	spin_lock_irqsave(&vfe31_ctrl->xbar_lock, flags);
-	vfe31_ctrl->xbar_update_pending = 0;
-	spin_unlock_irqrestore(&vfe31_ctrl->xbar_lock, flags);
-
-	atomic_set(&vfe31_ctrl->stop_ack_pending, 0);
-	atomic_set(&vfe31_ctrl->vstate, 0);
-
-	vfe31_ctrl->aec_ack_pending = FALSE;
-	vfe31_ctrl->af_ack_pending = FALSE;
-	vfe31_ctrl->awb_ack_pending = FALSE;
-	vfe31_ctrl->ihist_ack_pending = FALSE;
-	vfe31_ctrl->rs_ack_pending = FALSE;
-	vfe31_ctrl->cs_ack_pending = FALSE;
-
-	vfe31_ctrl->reset_ack_pending  = FALSE;
-
-	spin_lock_irqsave(&vfe31_ctrl->update_ack_lock, flags);
-	vfe31_ctrl->update_ack_pending = FALSE;
-	spin_unlock_irqrestore(&vfe31_ctrl->update_ack_lock, flags);
-
-	vfe31_ctrl->recording_state = VFE_REC_STATE_IDLE;
-
-	/* 0 for continuous mode, 1 for snapshot mode */
-	vfe31_ctrl->operation_mode = VFE_MODE_OF_OPERATION_CONTINUOUS;
-	vfe31_ctrl->outpath.output_mode = 0;
-	vfe31_ctrl->vfe_capture_count = 0;
-
-	/* this is unsigned 32 bit integer. */
-	vfe31_ctrl->vfeFrameId = 0;
-
-	vfe31_ctrl->output1Pattern = 0xffffffff;
-	vfe31_ctrl->output1Period  = 31;
-	vfe31_ctrl->output2Pattern = 0xffffffff;
-	vfe31_ctrl->output2Period  = 31;
-	vfe31_ctrl->vfeFrameSkipCount   = 0;
-	vfe31_ctrl->vfeFrameSkipPeriod  = 31;
-
-	/* Stats control variables. */
-	memset(&(vfe31_ctrl->afStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	memset(&(vfe31_ctrl->awbStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	memset(&(vfe31_ctrl->aecStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	memset(&(vfe31_ctrl->ihistStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	memset(&(vfe31_ctrl->rsStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	memset(&(vfe31_ctrl->csStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-}
-
-static void vfe31_reset(void)
-{
-	uint32_t vfe_version;
-	vfe31_reset_free_buf_queue_all();
-	vfe31_reset_internal_variables();
-
-	vfe31_reset_hist_cfg();
-	vfe_version = msm_camera_io_r(vfe31_ctrl->vfebase);
-	CDBG("vfe_version = 0x%x\n", vfe_version);
-	/* disable all interrupts.  vfeImaskLocal is also reset to 0
-	* to begin with. */
-	msm_camera_io_w(VFE_DISABLE_ALL_IRQS,
-		vfe31_ctrl->vfebase + VFE_IRQ_MASK_0);
-
-	msm_camera_io_w(VFE_DISABLE_ALL_IRQS,
-		vfe31_ctrl->vfebase + VFE_IRQ_MASK_1);
-
-	/* clear all pending interrupts*/
-	msm_camera_io_w(VFE_CLEAR_ALL_IRQS,
-		vfe31_ctrl->vfebase + VFE_IRQ_CLEAR_0);
-	msm_camera_io_w(VFE_CLEAR_ALL_IRQS,
-		vfe31_ctrl->vfebase + VFE_IRQ_CLEAR_1);
-
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(1, vfe31_ctrl->vfebase + VFE_IRQ_CMD);
-
-	/* enable reset_ack interrupt.  */
-	msm_camera_io_w(VFE_IMASK_RESET,
-		vfe31_ctrl->vfebase + VFE_IRQ_MASK_1);
-
-	/* Write to VFE_GLOBAL_RESET_CMD to reset the vfe hardware. Once reset
-	 * is done, hardware interrupt will be generated.  VFE ist processes
-	 * the interrupt to complete the function call.  Note that the reset
-	 * function is synchronous. */
-
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(VFE_RESET_UPON_RESET_CMD,
-		vfe31_ctrl->vfebase + VFE_GLOBAL_RESET);
-}
-
-static int vfe31_operation_config(uint32_t *cmd)
-{
-	uint32_t *p = cmd;
-
-	vfe31_ctrl->operation_mode = *p;
-	vpe_ctrl->pad_2k_bool = (vfe31_ctrl->operation_mode & 1) ?
-		FALSE : TRUE;
-
-	vfe31_ctrl->stats_comp = *(++p);
-	vfe31_ctrl->hfr_mode = *(++p);
-
-	msm_camera_io_w(*(++p), vfe31_ctrl->vfebase + VFE_CFG_OFF);
-	msm_camera_io_w(*(++p), vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-	msm_camera_io_w(*(++p), vfe31_ctrl->vfebase + VFE_REALIGN_BUF);
-	msm_camera_io_w(*(++p), vfe31_ctrl->vfebase + VFE_CHROMA_UP);
-	msm_camera_io_w(*(++p), vfe31_ctrl->vfebase + VFE_STATS_CFG);
-	wmb();
-	return 0;
-}
-static uint32_t vfe_stats_awb_buf_init(struct vfe_cmd_stats_buf *in)
-{
-	uint32_t *ptr = in->statsBuf;
-	uint32_t addr;
-
-	addr = ptr[0];
-	msm_camera_io_w(addr,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_AWB_WR_PING_ADDR);
-	addr = ptr[1];
-	msm_camera_io_w(addr,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_AWB_WR_PONG_ADDR);
-	vfe31_ctrl->awbStatsControl.nextFrameAddrBuf = in->statsBuf[2];
-	return 0;
-}
-
-
-static uint32_t vfe_stats_aec_buf_init(struct vfe_cmd_stats_buf *in)
-{
-	uint32_t *ptr = in->statsBuf;
-	uint32_t addr;
-
-	addr = ptr[0];
-	msm_camera_io_w(addr,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_AEC_WR_PING_ADDR);
-	addr = ptr[1];
-	msm_camera_io_w(addr,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_AEC_WR_PONG_ADDR);
-
-	vfe31_ctrl->aecStatsControl.nextFrameAddrBuf = in->statsBuf[2];
-	return 0;
-}
-
-static uint32_t vfe_stats_af_buf_init(struct vfe_cmd_stats_buf *in)
-{
-	uint32_t *ptr = in->statsBuf;
-	uint32_t addr;
-
-	addr = ptr[0];
-	msm_camera_io_w(addr,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_AF_WR_PING_ADDR);
-	addr = ptr[1];
-	msm_camera_io_w(addr,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_AF_WR_PONG_ADDR);
-
-	vfe31_ctrl->afStatsControl.nextFrameAddrBuf = in->statsBuf[2];
-	return 0;
-}
-
-static uint32_t vfe_stats_ihist_buf_init(struct vfe_cmd_stats_buf *in)
-{
-	uint32_t *ptr = in->statsBuf;
-	uint32_t addr;
-
-	addr = ptr[0];
-	msm_camera_io_w(addr,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_HIST_WR_PING_ADDR);
-	addr = ptr[1];
-	msm_camera_io_w(addr,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_HIST_WR_PONG_ADDR);
-
-	vfe31_ctrl->ihistStatsControl.nextFrameAddrBuf = in->statsBuf[2];
-	return 0;
-}
-
-static uint32_t vfe_stats_rs_buf_init(struct vfe_cmd_stats_buf *in)
-{
-	uint32_t *ptr = in->statsBuf;
-	uint32_t addr;
-
-	addr = ptr[0];
-	msm_camera_io_w(addr,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_RS_WR_PING_ADDR);
-	addr = ptr[1];
-	msm_camera_io_w(addr,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_RS_WR_PONG_ADDR);
-
-	vfe31_ctrl->rsStatsControl.nextFrameAddrBuf = in->statsBuf[2];
-	return 0;
-}
-static uint32_t vfe_stats_cs_buf_init(struct vfe_cmd_stats_buf *in)
-{
-	uint32_t *ptr = in->statsBuf;
-	uint32_t addr;
-
-	addr = ptr[0];
-	msm_camera_io_w(addr,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_CS_WR_PING_ADDR);
-	addr = ptr[1];
-	msm_camera_io_w(addr,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_CS_WR_PONG_ADDR);
-
-	vfe31_ctrl->csStatsControl.nextFrameAddrBuf = in->statsBuf[2];
-	return 0;
-}
-
-static void vfe31_start_common(void)
-{
-	uint32_t irq_mask = 0x00E00021;
-	vfe31_ctrl->start_ack_pending = TRUE;
-	CDBG("VFE opertaion mode = 0x%x, output mode = 0x%x\n",
-		vfe31_ctrl->operation_mode, vfe31_ctrl->outpath.output_mode);
-	/* Enable IRQ for comp stats, Image master, SOF & Reg Update*/
-	if (vfe31_ctrl->stats_comp)
-		irq_mask |= 0x01000000;
-	else /* Enable IRQ for Image masters, AF stats, SOF & Reg Update */
-		irq_mask |= 0x00004000;
-
-	/* Enable EOF for video mode */
-	if (VFE_MODE_OF_OPERATION_VIDEO == vfe31_ctrl->operation_mode)
-		irq_mask |= 0x4;
-
-	msm_camera_io_w(irq_mask, vfe31_ctrl->vfebase + VFE_IRQ_MASK_0);
-
-	msm_camera_io_w(VFE_IMASK_RESET,
-		vfe31_ctrl->vfebase + VFE_IRQ_MASK_1);
-	/* enable out of order option */
-	msm_camera_io_w(0x80000000, vfe31_ctrl->vfebase + VFE_AXI_CFG);
-	/* enable performance monitor */
-	msm_camera_io_w(1, vfe31_ctrl->vfebase + VFE_BUS_PM_CFG);
-	msm_camera_io_w(1, vfe31_ctrl->vfebase + VFE_BUS_PM_CMD);
-
-
-	msm_camera_io_dump(vfe31_ctrl->vfebase, 0x600);
-
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(1, vfe31_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-	msm_camera_io_w(1, vfe31_ctrl->vfebase + VFE_CAMIF_COMMAND);
-	wmb();
-
-	atomic_set(&vfe31_ctrl->vstate, 1);
-}
-
-static int vfe31_start_recording(void)
-{
-	msm_camio_set_perf_lvl(S_VIDEO);
-	usleep(1000);
-	vfe31_ctrl->recording_state = VFE_REC_STATE_START_REQUESTED;
-	msm_camera_io_w_mb(1, vfe31_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-	return 0;
-}
-
-static int vfe31_stop_recording(void)
-{
-	vfe31_ctrl->recording_state = VFE_REC_STATE_STOP_REQUESTED;
-	msm_camera_io_w_mb(1, vfe31_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-	msm_camio_set_perf_lvl(S_PREVIEW);
-	return 0;
-}
-
-static void vfe31_liveshot(void)
-{
-	struct msm_sync* p_sync = (struct msm_sync *)vfe_syncdata;
-	if (p_sync)
-		p_sync->liveshot_enabled = true;
-}
-
-static void vfe31_stereocam(uint32_t enable)
-{
-	struct msm_sync* p_sync = (struct msm_sync *)vfe_syncdata;
-	if (p_sync) {
-		CDBG("%s: Enable StereoCam %d!!!\n", __func__, enable);
-		p_sync->stereocam_enabled = enable;
-	}
-}
-
-static int vfe31_zsl(void)
-{
-	uint32_t irq_comp_mask = 0;
-	/* capture command is valid for both idle and active state. */
-	irq_comp_mask	=
-		msm_camera_io_r(vfe31_ctrl->vfebase + VFE_IRQ_COMP_MASK);
-
-	CDBG("%s:op mode %d O/P Mode %d\n", __func__,
-		vfe31_ctrl->operation_mode, vfe31_ctrl->outpath.output_mode);
-	if ((vfe31_ctrl->operation_mode == VFE_MODE_OF_OPERATION_ZSL)) {
-		if (vfe31_ctrl->outpath.output_mode & VFE31_OUTPUT_MODE_P) {
-			irq_comp_mask |=
-				((0x1 << (vfe31_ctrl->outpath.out0.ch0)) |
-				(0x1 << (vfe31_ctrl->outpath.out0.ch1)));
-		} else if (vfe31_ctrl->outpath.output_mode &
-				VFE31_OUTPUT_MODE_P_ALL_CHNLS) {
-			irq_comp_mask |= (0x1 << vfe31_ctrl->outpath.out0.ch0 |
-				0x1 << vfe31_ctrl->outpath.out0.ch1 |
-				0x1 << vfe31_ctrl->outpath.out0.ch2);
-		}
-		if (vfe31_ctrl->outpath.output_mode & VFE31_OUTPUT_MODE_T) {
-			irq_comp_mask |=
-				((0x1 << (vfe31_ctrl->outpath.out1.ch0 + 8)) |
-				(0x1 << (vfe31_ctrl->outpath.out1.ch1 + 8)));
-		}
-		if (vfe31_ctrl->outpath.output_mode & VFE31_OUTPUT_MODE_S) {
-			irq_comp_mask |=
-			((0x1 << (vfe31_ctrl->outpath.out2.ch0 + 8)) |
-			(0x1 << (vfe31_ctrl->outpath.out2.ch1 + 8)));
-		}
-		if (vfe31_ctrl->outpath.output_mode & VFE31_OUTPUT_MODE_P) {
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-				vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch0]);
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-				vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch1]);
-		} else if (vfe31_ctrl->outpath.output_mode &
-				VFE31_OUTPUT_MODE_P_ALL_CHNLS) {
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-				vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch0]);
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-				vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch1]);
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-				vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch2]);
-		}
-		if (vfe31_ctrl->outpath.output_mode & VFE31_OUTPUT_MODE_T) {
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-				vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out1.ch0]);
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-				vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out1.ch1]);
-		}
-		if (vfe31_ctrl->outpath.output_mode & VFE31_OUTPUT_MODE_S) {
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-				vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out2.ch0]);
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-				vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out2.ch1]);
-		}
-	}
-	msm_camera_io_w(irq_comp_mask, vfe31_ctrl->vfebase + VFE_IRQ_COMP_MASK);
-	vfe31_start_common();
-	msm_camio_set_perf_lvl(S_ZSL);
-	usleep(1000);
-	/* for debug */
-	msm_camera_io_w(1, vfe31_ctrl->vfebase + 0x18C);
-	msm_camera_io_w(1, vfe31_ctrl->vfebase + 0x188);
-	return 0;
-}
-
-static int vfe31_capture(uint32_t num_frames_capture)
-{
-	uint32_t irq_comp_mask = 0;
-	struct msm_sync* p_sync = (struct msm_sync *)vfe_syncdata;
-
-	/* capture command is valid for both idle and active state. */
-	vfe31_ctrl->vfe_capture_count = num_frames_capture;
-	if (p_sync) {
-		p_sync->snap_count = num_frames_capture;
-		p_sync->thumb_count = num_frames_capture;
-	}
-
-	irq_comp_mask	=
-		msm_camera_io_r(vfe31_ctrl->vfebase + VFE_IRQ_COMP_MASK);
-
-	if ((vfe31_ctrl->operation_mode ==
-		 VFE_MODE_OF_OPERATION_SNAPSHOT) ||
-		(vfe31_ctrl->operation_mode ==
-		 VFE_MODE_OF_OPERATION_ZSL)){
-		if (vfe31_ctrl->outpath.output_mode & VFE31_OUTPUT_MODE_PT) {
-			irq_comp_mask |=
-				((0x1 << (vfe31_ctrl->outpath.out0.ch0 + 8)) |
-				(0x1 << (vfe31_ctrl->outpath.out0.ch1 + 8)));
-		}
-		if (vfe31_ctrl->outpath.output_mode & VFE31_OUTPUT_MODE_S) {
-			irq_comp_mask |=
-			((0x1 << (vfe31_ctrl->outpath.out1.ch0 + 8)) |
-			(0x1 << (vfe31_ctrl->outpath.out1.ch1 + 8)));
-		}
-		if (vfe31_ctrl->outpath.output_mode & VFE31_OUTPUT_MODE_PT) {
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-				vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch0]);
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-				vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch1]);
-		}
-		if (vfe31_ctrl->outpath.output_mode & VFE31_OUTPUT_MODE_S) {
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-				vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out1.ch0]);
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-				vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out1.ch1]);
-		}
-	} else {  /* this is raw snapshot mode. */
-		CDBG("config the comp imask for raw snapshot mode.\n");
-		if (vfe31_ctrl->outpath.output_mode & VFE31_OUTPUT_MODE_S) {
-			irq_comp_mask |=
-			(0x1 << (vfe31_ctrl->outpath.out1.ch0 + 8));
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-				vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out1.ch0]);
-		}
-	}
-	msm_camera_io_w(irq_comp_mask, vfe31_ctrl->vfebase + VFE_IRQ_COMP_MASK);
-	if (p_sync->stereocam_enabled)
-		msm_camio_set_perf_lvl(S_STEREO_CAPTURE);
-	else
-		msm_camio_set_perf_lvl(S_CAPTURE);
-
-	usleep(1000);
-	vfe31_start_common();
-	return 0;
-}
-
-static int vfe31_start(void)
-{
-	uint32_t irq_comp_mask = 0;
-	struct msm_sync* p_sync = (struct msm_sync *)vfe_syncdata;
-	/* start command now is only good for continuous mode. */
-	if ((vfe31_ctrl->operation_mode != VFE_MODE_OF_OPERATION_CONTINUOUS) &&
-		(vfe31_ctrl->operation_mode != VFE_MODE_OF_OPERATION_VIDEO))
-		return 0;
-	irq_comp_mask =
-		msm_camera_io_r(vfe31_ctrl->vfebase + VFE_IRQ_COMP_MASK);
-
-	if (vfe31_ctrl->outpath.output_mode & VFE31_OUTPUT_MODE_PT) {
-		irq_comp_mask |= (0x1 << vfe31_ctrl->outpath.out0.ch0 |
-			0x1 << vfe31_ctrl->outpath.out0.ch1);
-			if (vfe31_ctrl->outpath.out0.ch2 >= 0)
-				irq_comp_mask |=
-					(0x1 << vfe31_ctrl->outpath.out0.ch0 |
-					0x1 << vfe31_ctrl->outpath.out0.ch1 |
-					0x1 << vfe31_ctrl->outpath.out0.ch2);
-	} else if (vfe31_ctrl->outpath.output_mode &
-		VFE31_OUTPUT_MODE_P_ALL_CHNLS) {
-			irq_comp_mask |= (0x1 << vfe31_ctrl->outpath.out0.ch0 |
-				0x1 << vfe31_ctrl->outpath.out0.ch1 |
-				0x1 << vfe31_ctrl->outpath.out0.ch2);
-	}
-
-	if (vfe31_ctrl->outpath.output_mode & VFE31_OUTPUT_MODE_V) {
-		irq_comp_mask |= (0x1 << (vfe31_ctrl->outpath.out2.ch0 + 16)|
-			0x1 << (vfe31_ctrl->outpath.out2.ch1 + 16));
-	}
-
-	msm_camera_io_w(irq_comp_mask, vfe31_ctrl->vfebase + VFE_IRQ_COMP_MASK);
-
-
-	if (vfe31_ctrl->outpath.output_mode & VFE31_OUTPUT_MODE_PT) {
-		msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch0]);
-		msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch1]);
-		if (vfe31_ctrl->outpath.out0.ch2 >= 0)
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch2]);
-	} else if (vfe31_ctrl->outpath.output_mode &
-		VFE31_OUTPUT_MODE_P_ALL_CHNLS) {
-		msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch0]);
-		msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch1]);
-		msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch2]);
-	}
-
-	if (p_sync->stereocam_enabled)
-		msm_camio_set_perf_lvl(S_STEREO_VIDEO);
-	else
-		msm_camio_set_perf_lvl(S_PREVIEW);
-
-	usleep(1000);
-	vfe31_start_common();
-	return 0;
-}
-
-static void vfe31_update(void)
-{
-	unsigned long flags;
-	CDBG("vfe31_update\n");
-
-	if (vfe31_ctrl->update_gamma) {
-		if (!msm_camera_io_r(vfe31_ctrl->vfebase + V31_GAMMA_CFG_OFF))
-			msm_camera_io_w(7,
-				vfe31_ctrl->vfebase+V31_GAMMA_CFG_OFF);
-		else
-			msm_camera_io_w(0,
-				vfe31_ctrl->vfebase+V31_GAMMA_CFG_OFF);
-		vfe31_ctrl->update_gamma = false;
-	}
-	if (vfe31_ctrl->update_luma) {
-		if (!msm_camera_io_r(vfe31_ctrl->vfebase + V31_LUMA_CFG_OFF))
-			msm_camera_io_w(1,
-				vfe31_ctrl->vfebase + V31_LUMA_CFG_OFF);
-		else
-			msm_camera_io_w(0,
-				vfe31_ctrl->vfebase + V31_LUMA_CFG_OFF);
-		vfe31_ctrl->update_luma = false;
-	}
-	spin_lock_irqsave(&vfe31_ctrl->update_ack_lock, flags);
-	vfe31_ctrl->update_ack_pending = TRUE;
-	spin_unlock_irqrestore(&vfe31_ctrl->update_ack_lock, flags);
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(1, vfe31_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-	return;
-}
-
-static void vfe31_sync_timer_stop(void)
-{
-	uint32_t value = 0;
-	vfe31_ctrl->sync_timer_state = 0;
-	if (vfe31_ctrl->sync_timer_number == 0)
-		value = 0x10000;
-	else if (vfe31_ctrl->sync_timer_number == 1)
-		value = 0x20000;
-	else if (vfe31_ctrl->sync_timer_number == 2)
-		value = 0x40000;
-
-	/* Timer Stop */
-	msm_camera_io_w_mb(value, vfe31_ctrl->vfebase + V31_SYNC_TIMER_OFF);
-}
-
-static void vfe31_sync_timer_start(const uint32_t *tbl)
-{
-	/* set bit 8 for auto increment. */
-	uint32_t value = 1;
-	uint32_t val;
-
-	vfe31_ctrl->sync_timer_state = *tbl++;
-	vfe31_ctrl->sync_timer_repeat_count = *tbl++;
-	vfe31_ctrl->sync_timer_number = *tbl++;
-	CDBG("%s timer_state %d, repeat_cnt %d timer number %d\n",
-		 __func__, vfe31_ctrl->sync_timer_state,
-		 vfe31_ctrl->sync_timer_repeat_count,
-		 vfe31_ctrl->sync_timer_number);
-
-	if (vfe31_ctrl->sync_timer_state) { /* Start Timer */
-		value = value << vfe31_ctrl->sync_timer_number;
-	} else { /* Stop Timer */
-		CDBG("Failed to Start timer\n");
-		 return;
-	}
-
-	/* Timer Start */
-	msm_camera_io_w(value, vfe31_ctrl->vfebase + V31_SYNC_TIMER_OFF);
-	/* Sync Timer Line Start */
-	value = *tbl++;
-	msm_camera_io_w(value, vfe31_ctrl->vfebase + V31_SYNC_TIMER_OFF +
-		4 + ((vfe31_ctrl->sync_timer_number) * 12));
-	/* Sync Timer Pixel Start */
-	value = *tbl++;
-	msm_camera_io_w(value, vfe31_ctrl->vfebase + V31_SYNC_TIMER_OFF +
-			 8 + ((vfe31_ctrl->sync_timer_number) * 12));
-	/* Sync Timer Pixel Duration */
-	value = *tbl++;
-	val = camio_clk.vfe_clk_rate / 10000;
-	val = 10000000 / val;
-	val = value * 10000 / val;
-	CDBG("%s: Pixel Clk Cycles!!! %d\n", __func__, val);
-	msm_camera_io_w(val, vfe31_ctrl->vfebase + V31_SYNC_TIMER_OFF +
-		12 + ((vfe31_ctrl->sync_timer_number) * 12));
-	/* Timer0 Active High/LOW */
-	value = *tbl++;
-	msm_camera_io_w(value,
-		vfe31_ctrl->vfebase + V31_SYNC_TIMER_POLARITY_OFF);
-	/* Selects sync timer 0 output to drive onto timer1 port */
-	value = 0;
-	msm_camera_io_w(value, vfe31_ctrl->vfebase + V31_TIMER_SELECT_OFF);
-	wmb();
-}
-
-static void vfe31_program_dmi_cfg(enum VFE31_DMI_RAM_SEL bankSel)
-{
-	/* set bit 8 for auto increment. */
-	uint32_t value = VFE_DMI_CFG_DEFAULT;
-	value += (uint32_t)bankSel;
-
-	msm_camera_io_w_mb(value, vfe31_ctrl->vfebase + VFE_DMI_CFG);
-	/* by default, always starts with offset 0.*/
-	msm_camera_io_w(0, vfe31_ctrl->vfebase + VFE_DMI_ADDR);
-	wmb();
-}
-static void vfe31_write_gamma_cfg(enum VFE31_DMI_RAM_SEL channel_sel,
-						const uint32_t *tbl)
-{
-	int i;
-	uint32_t value, value1, value2;
-	vfe31_program_dmi_cfg(channel_sel);
-	/* for loop for extracting init table. */
-	for (i = 0 ; i < (VFE31_GAMMA_NUM_ENTRIES/2) ; i++) {
-		value = *tbl++;
-		value1 = value & 0x0000FFFF;
-		value2 = (value & 0xFFFF0000)>>16;
-		msm_camera_io_w((value1),
-			vfe31_ctrl->vfebase + VFE_DMI_DATA_LO);
-		msm_camera_io_w((value2),
-			vfe31_ctrl->vfebase + VFE_DMI_DATA_LO);
-	}
-	vfe31_program_dmi_cfg(NO_MEM_SELECTED);
-}
-
-static void vfe31_reset_hist_cfg()
-{
-	uint32_t i;
-	uint32_t value = 0;
-
-	vfe31_program_dmi_cfg(STATS_HIST_RAM);
-	for (i = 0 ; i < VFE31_HIST_TABLE_LENGTH ; i++)
-		msm_camera_io_w(value, vfe31_ctrl->vfebase + VFE_DMI_DATA_LO);
-	vfe31_program_dmi_cfg(NO_MEM_SELECTED);
-}
-
-static void vfe31_write_la_cfg(enum VFE31_DMI_RAM_SEL channel_sel,
-						const uint32_t *tbl)
-{
-	uint32_t i;
-	uint32_t value, value1, value2;
-
-	vfe31_program_dmi_cfg(channel_sel);
-	/* for loop for extracting init table. */
-	for (i = 0 ; i < (VFE31_LA_TABLE_LENGTH/2) ; i++) {
-		value = *tbl++;
-		value1 = value & 0x0000FFFF;
-		value2 = (value & 0xFFFF0000)>>16;
-		msm_camera_io_w((value1),
-			vfe31_ctrl->vfebase + VFE_DMI_DATA_LO);
-		msm_camera_io_w((value2),
-			vfe31_ctrl->vfebase + VFE_DMI_DATA_LO);
-	}
-	vfe31_program_dmi_cfg(NO_MEM_SELECTED);
-}
-
-static int vfe31_proc_general(struct msm_vfe31_cmd *cmd)
-{
-	int i , rc = 0;
-	uint32_t old_val = 0 , new_val = 0;
-	uint32_t *cmdp = NULL;
-	uint32_t *cmdp_local = NULL;
-	uint32_t snapshot_cnt = 0;
-	uint32_t stereo_cam_enable = 0;
-	struct msm_sync* p_sync = (struct msm_sync *)vfe_syncdata;
-
-	CDBG("vfe31_proc_general: cmdID = %s, length = %d\n",
-		vfe31_general_cmd[cmd->id], cmd->length);
-	switch (cmd->id) {
-	case V31_RESET:
-		pr_info("vfe31_proc_general: cmdID = %s\n",
-			vfe31_general_cmd[cmd->id]);
-		vfe31_reset();
-		break;
-	case V31_START:
-		pr_info("vfe31_proc_general: cmdID = %s\n",
-			vfe31_general_cmd[cmd->id]);
-		rc = vfe31_start();
-		break;
-	case V31_UPDATE:
-		vfe31_update();
-		break;
-	case V31_ZSL:
-		pr_info("vfe31_proc_general: cmdID = %s\n",
-			vfe31_general_cmd[cmd->id]);
-		vfe31_zsl();
-		break;
-	case V31_CAPTURE:
-		pr_info("vfe31_proc_general: cmdID = %s\n",
-			vfe31_general_cmd[cmd->id]);
-		if (copy_from_user(&snapshot_cnt, (void __user *)(cmd->value),
-				sizeof(uint32_t))) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		rc = vfe31_capture(snapshot_cnt);
-		break;
-	case V31_START_RECORDING:
-		pr_info("vfe31_proc_general: cmdID = %s\n",
-			vfe31_general_cmd[cmd->id]);
-		rc = vfe31_start_recording();
-		if (p_sync->stereocam_enabled)
-			p_sync->stereo_state = STEREO_VIDEO_ACTIVE;
-		break;
-	case V31_STOP_RECORDING:
-		pr_info("vfe31_proc_general: cmdID = %s\n",
-			vfe31_general_cmd[cmd->id]);
-		rc = vfe31_stop_recording();
-		if (p_sync->stereocam_enabled)
-			p_sync->stereo_state = STEREO_VIDEO_IDLE;
-		break;
-	case V31_OPERATION_CFG: {
-		if (cmd->length != V31_OPERATION_CFG_LEN) {
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(V31_OPERATION_CFG_LEN, GFP_ATOMIC);
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			V31_OPERATION_CFG_LEN)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		rc = vfe31_operation_config(cmdp);
-		}
-		break;
-
-	case V31_STATS_AE_START: {
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val |= AE_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-		cmdp, (vfe31_cmd[cmd->id].length));
-		}
-		break;
-	case V31_STATS_AF_START: {
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val |= AF_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-		cmdp, (vfe31_cmd[cmd->id].length));
-		}
-		break;
-	case V31_STATS_AWB_START: {
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val |= AWB_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-			cmdp, (vfe31_cmd[cmd->id].length));
-		}
-		break;
-
-	case V31_STATS_IHIST_START: {
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val |= IHIST_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-			cmdp, (vfe31_cmd[cmd->id].length));
-		}
-		break;
-
-	case V31_XBAR_CFG: {
-		unsigned long flags = 0;
-		spin_lock_irqsave(&vfe31_ctrl->xbar_lock, flags);
-		if ((cmd->length != V31_XBAR_CFG_LEN)
-			|| vfe31_ctrl->xbar_update_pending) {
-			rc = -EINVAL;
-			spin_unlock_irqrestore(&vfe31_ctrl->xbar_lock, flags);
-			goto proc_general_done;
-		}
-		spin_unlock_irqrestore(&vfe31_ctrl->xbar_lock, flags);
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		spin_lock_irqsave(&vfe31_ctrl->xbar_lock, flags);
-		vfe31_ctrl->xbar_cfg[0] = *cmdp;
-		vfe31_ctrl->xbar_cfg[1] = *(cmdp+1);
-		vfe31_ctrl->xbar_update_pending = 1;
-		spin_unlock_irqrestore(&vfe31_ctrl->xbar_lock, flags);
-		CDBG("%s: xbar0 0x%x xbar1 0x%x", __func__,
-			vfe31_ctrl->xbar_cfg[0],
-			vfe31_ctrl->xbar_cfg[1]);
-		}
-		break;
-
-	case V31_STATS_RS_START: {
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-			cmdp, (vfe31_cmd[cmd->id].length));
-		}
-		break;
-
-	case V31_STATS_CS_START: {
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-			cmdp, (vfe31_cmd[cmd->id].length));
-		}
-		break;
-
-	case V31_MCE_UPDATE:
-	case V31_MCE_CFG:{
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		/* Incrementing with 4 so as to point to the 2nd Register as
-		the 2nd register has the mce_enable bit */
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase +
-						V31_CHROMA_SUP_OFF + 4);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		new_val = *cmdp_local;
-		old_val &= MCE_EN_MASK;
-		new_val = new_val | old_val;
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + V31_CHROMA_SUP_OFF + 4,
-			&new_val, 4);
-		cmdp_local += 1;
-
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase +
-						V31_CHROMA_SUP_OFF + 8);
-		new_val = *cmdp_local;
-		old_val &= MCE_Q_K_MASK;
-		new_val = new_val | old_val;
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + V31_CHROMA_SUP_OFF + 8,
-			&new_val, 4);
-		cmdp_local += 1;
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-			cmdp_local, (vfe31_cmd[cmd->id].length));
-		}
-		break;
-	case V31_DEMOSAIC_2_UPDATE: /* 38 BPC update   */
-	case V31_DEMOSAIC_2_CFG: {  /* 14 BPC config   */
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		new_val = *cmdp_local;
-
-		old_val = msm_camera_io_r(
-				vfe31_ctrl->vfebase + V31_DEMOSAIC_0_OFF);
-		old_val &= BPC_MASK;
-
-		new_val = new_val | old_val;
-		*cmdp_local = new_val;
-		msm_camera_io_memcpy(vfe31_ctrl->vfebase + V31_DEMOSAIC_0_OFF,
-					cmdp_local, 4);
-		cmdp_local += 1;
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-			cmdp_local, (vfe31_cmd[cmd->id].length));
-		}
-		break;
-	case V31_DEMOSAIC_1_UPDATE:/* 37 ABF update  */
-	case V31_DEMOSAIC_1_CFG: { /* 13 ABF config  */
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		new_val = *cmdp_local;
-
-		old_val = msm_camera_io_r(
-				vfe31_ctrl->vfebase + V31_DEMOSAIC_0_OFF);
-		old_val &= ABF_MASK;
-		new_val = new_val | old_val;
-		*cmdp_local = new_val;
-
-		msm_camera_io_memcpy(vfe31_ctrl->vfebase + V31_DEMOSAIC_0_OFF,
-		    cmdp_local, 4);
-
-		cmdp_local += 1;
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-			cmdp_local, (vfe31_cmd[cmd->id].length));
-		}
-		break;
-	case V31_ROLL_OFF_CFG: {
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value) , cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-		cmdp_local, 16);
-		cmdp_local += 4;
-		vfe31_program_dmi_cfg(ROLLOFF_RAM);
-		/* for loop for extrcting init table. */
-		for (i = 0 ; i < (VFE31_ROLL_OFF_INIT_TABLE_SIZE * 2) ; i++) {
-			msm_camera_io_w(*cmdp_local ,
-			vfe31_ctrl->vfebase + VFE_DMI_DATA_LO);
-			cmdp_local++;
-		}
-		CDBG("done writing init table\n");
-		/* by default, always starts with offset 0. */
-		msm_camera_io_w(LENS_ROLL_OFF_DELTA_TABLE_OFFSET,
-		vfe31_ctrl->vfebase + VFE_DMI_ADDR);
-		/* for loop for extracting delta table. */
-		for (i = 0 ; i < (VFE31_ROLL_OFF_DELTA_TABLE_SIZE * 2) ; i++) {
-			msm_camera_io_w(*cmdp_local,
-			vfe31_ctrl->vfebase + VFE_DMI_DATA_LO);
-			cmdp_local++;
-		}
-		vfe31_program_dmi_cfg(NO_MEM_SELECTED);
-		}
-		break;
-
-	case V31_LA_CFG:{
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		/* Select Bank 0*/
-		*cmdp = 0;
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-			cmdp, (vfe31_cmd[cmd->id].length));
-		cmdp += 1;
-		vfe31_write_la_cfg(LUMA_ADAPT_LUT_RAM_BANK0 , cmdp);
-		cmdp -= 1;
-		}
-		break;
-
-	case V31_LA_UPDATE: {
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		old_val = msm_camera_io_r(
-				vfe31_ctrl->vfebase + V31_LUMA_CFG_OFF);
-		cmdp += 1;
-		if (old_val != 0x0)
-			vfe31_write_la_cfg(LUMA_ADAPT_LUT_RAM_BANK0 , cmdp);
-		else
-			vfe31_write_la_cfg(LUMA_ADAPT_LUT_RAM_BANK1 , cmdp);
-		vfe31_ctrl->update_luma = true;
-		cmdp -= 1;
-		}
-		break;
-
-	case V31_SK_ENHAN_CFG:
-	case V31_SK_ENHAN_UPDATE:{
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(vfe31_ctrl->vfebase + V31_SCE_OFF,
-				cmdp, V31_SCE_LEN);
-		}
-		break;
-
-	case V31_LIVESHOT:
-		vfe31_liveshot();
-		break;
-
-	case V31_STEREOCAM:
-		if (copy_from_user(&stereo_cam_enable,
-			(void __user *)(cmd->value), sizeof(uint32_t))) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		vfe31_stereocam(stereo_cam_enable);
-		break;
-
-	case V31_RGB_G_CFG: {
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		/* Select Bank 0*/
-		*cmdp = 0;
-		msm_camera_io_memcpy(vfe31_ctrl->vfebase + V31_RGB_G_OFF,
-				cmdp, 4);
-		cmdp += 1;
-		vfe31_write_gamma_cfg(RGBLUT_CHX_BANK0, cmdp);
-		cmdp -= 1;
-		}
-		break;
-
-	case V31_RGB_G_UPDATE: {
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp, (void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		old_val = msm_camera_io_r(
-				vfe31_ctrl->vfebase + V31_GAMMA_CFG_OFF);
-		cmdp += 1;
-
-		if (!old_val) {
-			vfe31_write_gamma_cfg(RGBLUT_CHX_BANK1, cmdp);
-		} else {
-			vfe31_write_gamma_cfg(RGBLUT_CHX_BANK0, cmdp);
-			}
-		vfe31_ctrl->update_gamma = true;
-		cmdp -= 1;
-		}
-		break;
-
-	case V31_STATS_AWB_STOP: {
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~AWB_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		}
-		break;
-	case V31_STATS_AE_STOP: {
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~AE_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		}
-		break;
-	case V31_STATS_AF_STOP: {
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~AF_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		}
-		break;
-
-	case V31_STATS_IHIST_STOP: {
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~IHIST_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		}
-		break;
-
-	case V31_STATS_RS_STOP: {
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~RS_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		}
-		break;
-
-	case V31_STATS_CS_STOP: {
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~CS_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		}
-		break;
-	case V31_STOP:
-		pr_info("vfe31_proc_general: cmdID = %s\n",
-			vfe31_general_cmd[cmd->id]);
-		vfe31_stop();
-		break;
-
-	case V31_SYNC_TIMER_SETTING:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp, (void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		vfe31_sync_timer_start(cmdp);
-		break;
-
-	case V31_EZTUNE_CFG: {
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		*cmdp &= ~STATS_ENABLE_MASK;
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= STATS_ENABLE_MASK;
-		*cmdp |= old_val;
-
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-			cmdp, (vfe31_cmd[cmd->id].length));
-		}
-		break;
-
-	default: {
-		if (cmd->length != vfe31_cmd[cmd->id].length)
-			return -EINVAL;
-
-		cmdp = kmalloc(vfe31_cmd[cmd->id].length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-
-		if (copy_from_user(cmdp, (void __user *)cmd->value,
-				cmd->length)) {
-			rc = -EFAULT;
-			pr_err("%s copy from user failed for cmd %d",
-				__func__, cmd->id);
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-			cmdp, (vfe31_cmd[cmd->id].length));
-	}
-	break;
-
-	}
-
-proc_general_done:
-	kfree(cmdp);
-
-	return rc;
-}
-
-static void vfe31_stats_af_ack(struct vfe_cmd_stats_ack *pAck)
-{
-	vfe31_ctrl->afStatsControl.nextFrameAddrBuf = pAck->nextStatsBuf;
-	vfe31_ctrl->af_ack_pending = FALSE;
-}
-
-static void vfe31_stats_awb_ack(struct vfe_cmd_stats_ack *pAck)
-{
-	vfe31_ctrl->awbStatsControl.nextFrameAddrBuf = pAck->nextStatsBuf;
-	vfe31_ctrl->awb_ack_pending = FALSE;
-}
-
-static void vfe31_stats_aec_ack(struct vfe_cmd_stats_ack *pAck)
-{
-	vfe31_ctrl->aecStatsControl.nextFrameAddrBuf = pAck->nextStatsBuf;
-	vfe31_ctrl->aec_ack_pending = FALSE;
-}
-
-static void vfe31_stats_ihist_ack(struct vfe_cmd_stats_ack *pAck)
-{
-	vfe31_ctrl->ihistStatsControl.nextFrameAddrBuf = pAck->nextStatsBuf;
-	vfe31_ctrl->ihist_ack_pending = FALSE;
-}
-
-static void vfe31_stats_rs_ack(struct vfe_cmd_stats_ack *pAck)
-{
-	vfe31_ctrl->rsStatsControl.nextFrameAddrBuf = pAck->nextStatsBuf;
-	vfe31_ctrl->rs_ack_pending = FALSE;
-}
-
-static void vfe31_stats_cs_ack(struct vfe_cmd_stats_ack *pAck)
-{
-	vfe31_ctrl->csStatsControl.nextFrameAddrBuf = pAck->nextStatsBuf;
-	vfe31_ctrl->cs_ack_pending = FALSE;
-}
-
-static int vfe31_config(struct msm_vfe_cfg_cmd *cmd, void *data)
-{
-	struct msm_vfe31_cmd vfecmd;
-
-	long rc = 0;
-	uint32_t i = 0;
-	struct vfe_cmd_stats_buf *scfg = NULL;
-	struct msm_pmem_region   *regptr = NULL;
-	struct vfe_cmd_stats_ack *sack = NULL;
-
-	if (cmd->cmd_type != CMD_FRAME_BUF_RELEASE &&
-		cmd->cmd_type != CMD_SNAP_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_AEC_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_AWB_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_IHIST_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_RS_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_CS_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_AF_BUF_RELEASE) {
-		if (copy_from_user(&vfecmd,
-				(void __user *)(cmd->value),
-				sizeof(vfecmd))) {
-			pr_err("%s %d: copy_from_user failed\n", __func__,
-				__LINE__);
-			return -EFAULT;
-		}
-	} else {
-	/* here eith stats release or frame release. */
-		if (cmd->cmd_type != CMD_FRAME_BUF_RELEASE &&
-			cmd->cmd_type != CMD_SNAP_BUF_RELEASE) {
-			/* then must be stats release. */
-			if (!data)
-				return -EFAULT;
-				sack = kmalloc(sizeof(struct vfe_cmd_stats_ack),
-				GFP_ATOMIC);
-				if (!sack)
-					return -ENOMEM;
-
-				sack->nextStatsBuf = *(uint32_t *)data;
-			}
-	}
-
-	CDBG("%s: cmdType = %d\n", __func__, cmd->cmd_type);
-
-	if ((cmd->cmd_type == CMD_STATS_AF_ENABLE) ||
-		(cmd->cmd_type == CMD_STATS_AWB_ENABLE) ||
-		(cmd->cmd_type == CMD_STATS_IHIST_ENABLE) ||
-		(cmd->cmd_type == CMD_STATS_RS_ENABLE) ||
-		(cmd->cmd_type == CMD_STATS_CS_ENABLE) ||
-		(cmd->cmd_type == CMD_STATS_AEC_ENABLE)) {
-		struct axidata *axid;
-		axid = data;
-		if (!axid) {
-			rc = -EFAULT;
-			goto vfe31_config_done;
-		}
-
-		scfg =
-			kmalloc(sizeof(struct vfe_cmd_stats_buf),
-				GFP_ATOMIC);
-		if (!scfg) {
-			rc = -ENOMEM;
-			goto vfe31_config_done;
-		}
-		regptr = axid->region;
-		if (axid->bufnum1 > 0) {
-			for (i = 0; i < axid->bufnum1; i++) {
-				scfg->statsBuf[i] =
-					(uint32_t)(regptr->paddr);
-				regptr++;
-			}
-		}
-		/* individual */
-		switch (cmd->cmd_type) {
-		case CMD_STATS_AEC_ENABLE:
-			rc = vfe_stats_aec_buf_init(scfg);
-			break;
-		case CMD_STATS_AF_ENABLE:
-			rc = vfe_stats_af_buf_init(scfg);
-			break;
-		case CMD_STATS_AWB_ENABLE:
-			rc = vfe_stats_awb_buf_init(scfg);
-			break;
-		case CMD_STATS_IHIST_ENABLE:
-			rc = vfe_stats_ihist_buf_init(scfg);
-			break;
-		case CMD_STATS_RS_ENABLE:
-			rc = vfe_stats_rs_buf_init(scfg);
-			break;
-		case CMD_STATS_CS_ENABLE:
-			rc = vfe_stats_cs_buf_init(scfg);
-			break;
-		}
-	}
-
-	switch (cmd->cmd_type) {
-	case CMD_GENERAL:
-		rc = vfe31_proc_general(&vfecmd);
-		break;
-
-	case CMD_FRAME_BUF_RELEASE: {
-		struct msm_frame *b;
-		unsigned long p;
-		int ret;
-		struct vfe31_output_ch *outch = NULL;
-		if (!data) {
-			rc = -EFAULT;
-			break;
-		}
-
-		b = (struct msm_frame *)(cmd->value);
-		p = *(unsigned long *)data;
-
-		CDBG("CMD_FRAME_BUF_RELEASE b->path = %d\n", b->path);
-
-		if (b->path & OUTPUT_TYPE_P) {
-			CDBG("CMD_FRAME_BUF_RELEASE got free buffer\n");
-			outch = &vfe31_ctrl->outpath.out0;
-		} else if (b->path & OUTPUT_TYPE_S) {
-			outch = &vfe31_ctrl->outpath.out1;
-		} else if (b->path & OUTPUT_TYPE_V) {
-			outch = &vfe31_ctrl->outpath.out2;
-		} else {
-			rc = -EFAULT;
-			break;
-		}
-
-		ret = vfe31_add_free_buf2(outch, p, b->planar0_off,
-			b->planar1_off, b->planar2_off);
-		if (ret < 0)
-			return ret;
-		break;
-	}
-
-	case CMD_SNAP_BUF_RELEASE: {
-		struct msm_frame *b;
-		unsigned long p;
-		int ret;
-		struct vfe31_output_ch *outch = NULL;
-		if (!data)
-			return -EFAULT;
-
-		b = (struct msm_frame *)(cmd->value);
-		p = *(unsigned long *)data;
-
-		CDBG("CMD_PIC_BUF_RELEASE b->path = %d\n", b->path);
-
-		if (b->path & OUTPUT_TYPE_T) {
-			CDBG("CMD_FRAME_BUF_RELEASE got free buffer\n");
-			outch = &vfe31_ctrl->outpath.out1;
-		} else if (b->path & OUTPUT_TYPE_S) {
-			outch = &vfe31_ctrl->outpath.out2;
-		} else
-			return -EFAULT;
-
-		ret = vfe31_add_free_buf2(outch, p, b->planar0_off,
-			b->planar1_off,	b->planar2_off);
-		if (ret < 0)
-			return ret;
-		break;
-	}
-
-	case CMD_STATS_AEC_BUF_RELEASE:
-		vfe31_stats_aec_ack(sack);
-		break;
-
-	case CMD_STATS_AF_BUF_RELEASE:
-		vfe31_stats_af_ack(sack);
-		break;
-
-	case CMD_STATS_AWB_BUF_RELEASE:
-		vfe31_stats_awb_ack(sack);
-		break;
-
-	case CMD_STATS_IHIST_BUF_RELEASE:
-		vfe31_stats_ihist_ack(sack);
-		break;
-
-	case CMD_STATS_RS_BUF_RELEASE:
-		vfe31_stats_rs_ack(sack);
-		break;
-
-	case CMD_STATS_CS_BUF_RELEASE:
-		vfe31_stats_cs_ack(sack);
-		break;
-
-	case CMD_AXI_CFG_PREVIEW: {
-		struct axidata *axid;
-		uint32_t *axio = NULL;
-		axid = data;
-		if (!axid) {
-			rc = -EFAULT;
-			break;
-		}
-		axio =
-			kmalloc(vfe31_cmd[V31_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			break;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe31_cmd[V31_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			rc = -EFAULT;
-			break;
-		}
-		vfe31_config_axi(OUTPUT_2, axid, axio);
-		kfree(axio);
-		break;
-	}
-
-	case CMD_RAW_PICT_AXI_CFG: {
-		struct axidata *axid;
-		uint32_t *axio = NULL;
-		axid = data;
-		if (!axid) {
-			rc = -EFAULT;
-			break;
-		}
-		axio =
-			kmalloc(vfe31_cmd[V31_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			break;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe31_cmd[V31_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			rc = -EFAULT;
-			break;
-		}
-		vfe31_config_axi(CAMIF_TO_AXI_VIA_OUTPUT_2, axid, axio);
-		kfree(axio);
-		break;
-	}
-
-	case CMD_AXI_CFG_SNAP: {
-		struct axidata *axid;
-		uint32_t *axio = NULL;
-		CDBG("%s, CMD_AXI_CFG_SNAP\n", __func__);
-		axid = data;
-		if (!axid)
-			return -EFAULT;
-		axio =
-			kmalloc(vfe31_cmd[V31_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			break;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe31_cmd[V31_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			rc = -EFAULT;
-			break;
-		}
-		vfe31_config_axi(OUTPUT_1_AND_2, axid, axio);
-		kfree(axio);
-		break;
-	}
-
-	case CMD_AXI_CFG_ZSL: {
-		struct axidata *axid;
-		uint32_t *axio = NULL;
-		CDBG("%s, CMD_AXI_CFG_ZSL\n", __func__);
-		axid = data;
-		if (!axid)
-			return -EFAULT;
-		axio =
-			kmalloc(vfe31_cmd[V31_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			break;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe31_cmd[V31_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			rc = -EFAULT;
-			break;
-		}
-		vfe31_config_axi(OUTPUT_1_2_AND_3, axid, axio);
-		kfree(axio);
-	}
-		break;
-
-	case CMD_AXI_CFG_ZSL_ALL_CHNLS: {
-		struct axidata *axid;
-		uint32_t *axio;
-		CDBG("%s, CMD_AXI_CFG_ZSL\n", __func__);
-		axid = data;
-		if (!axid)
-			return -EFAULT;
-		axio =
-			kmalloc(vfe31_cmd[V31_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			break;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe31_cmd[V31_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			rc = -EFAULT;
-			break;
-		}
-		vfe31_config_axi(OUTPUT_ZSL_ALL_CHNLS, axid, axio);
-		kfree(axio);
-	}
-		break;
-
-	case CMD_AXI_CFG_VIDEO: {
-		struct axidata *axid;
-		uint32_t *axio = NULL;
-		axid = data;
-		if (!axid) {
-			rc = -EFAULT;
-			break;
-		}
-
-		axio =
-			kmalloc(vfe31_cmd[V31_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			break;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe31_cmd[V31_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			rc = -EFAULT;
-			break;
-		}
-		vfe31_config_axi(OUTPUT_1_AND_3, axid, axio);
-		kfree(axio);
-		break;
-	}
-
-	case CMD_AXI_CFG_VIDEO_ALL_CHNLS: {
-		struct axidata *axid;
-		uint32_t *axio = NULL;
-		axid = data;
-		if (!axid) {
-			rc = -EFAULT;
-			break;
-		}
-
-		axio =
-			kmalloc(vfe31_cmd[V31_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			break;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe31_cmd[V31_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			rc = -EFAULT;
-			break;
-		}
-		vfe31_config_axi(OUTPUT_VIDEO_ALL_CHNLS, axid, axio);
-		kfree(axio);
-		break;
-	}
-
-	default:
-		break;
-	}
-vfe31_config_done:
-	kfree(scfg);
-	kfree(sack);
-	CDBG("%s done: rc = %d\n", __func__, (int) rc);
-	return rc;
-}
-
-static void vfe31_send_msg_no_payload(enum VFE31_MESSAGE_ID id)
-{
-	struct vfe_message msg;
-
-	CDBG("vfe31_send_msg_no_payload\n");
-	msg._d = id;
-	vfe31_proc_ops(id, &msg, 0);
-}
-
-static void vfe31_process_reg_update_irq(void)
-{
-	uint32_t  temp, old_val;
-	unsigned long flags;
-	if (vfe31_ctrl->recording_state == VFE_REC_STATE_START_REQUESTED) {
-		if (vfe31_ctrl->outpath.output_mode & VFE31_OUTPUT_MODE_V) {
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-				vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out2.ch0]);
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-				vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out2.ch1]);
-		}
-		vfe31_ctrl->recording_state = VFE_REC_STATE_STARTED;
-		if (vpe_ctrl->dis_en) {
-			old_val = msm_camera_io_r(
-				vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-			old_val |= RS_CS_ENABLE_MASK;
-			msm_camera_io_w(old_val,
-				vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		}
-		msm_camera_io_w_mb(1, vfe31_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-		CDBG("start video triggered .\n");
-	} else if (vfe31_ctrl->recording_state
-			== VFE_REC_STATE_STOP_REQUESTED) {
-		if (vfe31_ctrl->outpath.output_mode & VFE31_OUTPUT_MODE_V) {
-			msm_camera_io_w(0, vfe31_ctrl->vfebase +
-				vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out2.ch0]);
-			msm_camera_io_w(0, vfe31_ctrl->vfebase +
-				vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out2.ch1]);
-		}
-
-		/*disable rs& cs when stop recording. */
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= (~RS_CS_ENABLE_MASK);
-		msm_camera_io_w(old_val,
-				vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		CDBG("stop video triggered\n");
-	}
-	if (vfe31_ctrl->start_ack_pending == TRUE) {
-		vfe31_send_msg_no_payload(MSG_ID_START_ACK);
-		vfe31_ctrl->start_ack_pending = FALSE;
-	} else {
-		if (vfe31_ctrl->recording_state ==
-			VFE_REC_STATE_STOP_REQUESTED) {
-			vfe31_ctrl->recording_state = VFE_REC_STATE_STOPPED;
-			msm_camera_io_w_mb(1, vfe31_ctrl->vfebase +
-						VFE_REG_UPDATE_CMD);
-		} else if (vfe31_ctrl->recording_state ==
-			VFE_REC_STATE_STOPPED) {
-			CDBG("sent stop video rec ACK");
-			vfe31_send_msg_no_payload(MSG_ID_STOP_REC_ACK);
-			vfe31_ctrl->recording_state = VFE_REC_STATE_IDLE;
-		}
-		spin_lock_irqsave(&vfe31_ctrl->update_ack_lock, flags);
-		if (vfe31_ctrl->update_ack_pending == TRUE) {
-			vfe31_ctrl->update_ack_pending = FALSE;
-			spin_unlock_irqrestore(
-				&vfe31_ctrl->update_ack_lock, flags);
-			vfe31_send_msg_no_payload(MSG_ID_UPDATE_ACK);
-		} else {
-			spin_unlock_irqrestore(
-				&vfe31_ctrl->update_ack_lock, flags);
-		}
-	}
-	/* in snapshot mode */
-	if (vfe31_ctrl->operation_mode ==
-		VFE_MODE_OF_OPERATION_SNAPSHOT) {
-		/* later we need to add check for live snapshot mode. */
-
-		if (vfe31_ctrl->vfe_capture_count)
-			vfe31_ctrl->vfe_capture_count--;
-		/* if last frame to be captured: */
-		if (vfe31_ctrl->vfe_capture_count == 0) {
-			/* stop the bus output:  write master enable = 0*/
-			if (vfe31_ctrl->outpath.output_mode &
-					VFE31_OUTPUT_MODE_PT) {
-				msm_camera_io_w(0, vfe31_ctrl->vfebase +
-					vfe31_AXI_WM_CFG[
-						vfe31_ctrl->outpath.out0.ch0]);
-				msm_camera_io_w(0, vfe31_ctrl->vfebase +
-					vfe31_AXI_WM_CFG[vfe31_ctrl->
-						outpath.out0.ch1]);
-			}
-			if (vfe31_ctrl->outpath.output_mode &
-					VFE31_OUTPUT_MODE_S) {
-				msm_camera_io_w(0, vfe31_ctrl->vfebase +
-					vfe31_AXI_WM_CFG[vfe31_ctrl->
-						outpath.out1.ch0]);
-				msm_camera_io_w(0, vfe31_ctrl->vfebase +
-					vfe31_AXI_WM_CFG[vfe31_ctrl->
-						outpath.out1.ch1]);
-			}
-
-			/* Ensure the write order while writing
-			to the command register using the barrier */
-			msm_camera_io_w_mb(CAMIF_COMMAND_STOP_AT_FRAME_BOUNDARY,
-				vfe31_ctrl->vfebase + VFE_CAMIF_COMMAND);
-
-			/* Ensure the read order while reading
-			to the command register using the barrier */
-			temp = msm_camera_io_r_mb(vfe31_ctrl->vfebase +
-				VFE_CAMIF_COMMAND);
-		}
-		/* then do reg_update. */
-		msm_camera_io_w_mb(1, vfe31_ctrl->vfebase +
-			VFE_REG_UPDATE_CMD);
-	} /* if snapshot mode. */
-}
-
-static void vfe31_set_default_reg_values(void)
-{
-	msm_camera_io_w(0x800080, vfe31_ctrl->vfebase + VFE_DEMUX_GAIN_0);
-	msm_camera_io_w(0x800080, vfe31_ctrl->vfebase + VFE_DEMUX_GAIN_1);
-	msm_camera_io_w(0xFFFFF, vfe31_ctrl->vfebase + VFE_CGC_OVERRIDE);
-
-	/* default frame drop period and pattern */
-	msm_camera_io_w(0x1f, vfe31_ctrl->vfebase + VFE_FRAMEDROP_ENC_Y_CFG);
-	msm_camera_io_w(0x1f, vfe31_ctrl->vfebase + VFE_FRAMEDROP_ENC_CBCR_CFG);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe31_ctrl->vfebase + VFE_FRAMEDROP_ENC_Y_PATTERN);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe31_ctrl->vfebase + VFE_FRAMEDROP_ENC_CBCR_PATTERN);
-	msm_camera_io_w(0x1f, vfe31_ctrl->vfebase + VFE_FRAMEDROP_VIEW_Y);
-	msm_camera_io_w(0x1f, vfe31_ctrl->vfebase + VFE_FRAMEDROP_VIEW_CBCR);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe31_ctrl->vfebase + VFE_FRAMEDROP_VIEW_Y_PATTERN);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe31_ctrl->vfebase + VFE_FRAMEDROP_VIEW_CBCR_PATTERN);
-	msm_camera_io_w(0, vfe31_ctrl->vfebase + VFE_CLAMP_MIN);
-	msm_camera_io_w(0xFFFFFF, vfe31_ctrl->vfebase + VFE_CLAMP_MAX);
-
-	/* stats UB config */
-	msm_camera_io_w(0x3980007,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_AEC_UB_CFG);
-	msm_camera_io_w(0x3A00007,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_AF_UB_CFG);
-	msm_camera_io_w(0x3A8000F,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_AWB_UB_CFG);
-	msm_camera_io_w(0x3B80007,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_RS_UB_CFG);
-	msm_camera_io_w(0x3C0001F,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_CS_UB_CFG);
-	msm_camera_io_w(0x3E0001F,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_HIST_UB_CFG);
-}
-
-static void vfe31_process_reset_irq(void)
-{
-	atomic_set(&vfe31_ctrl->vstate, 0);
-	vfe31_ctrl->while_stopping_mask = VFE_IMASK_WHILE_STOPPING_1;
-	if (atomic_read(&vfe31_ctrl->stop_ack_pending)) {
-		/* this is from the stop command. */
-		atomic_set(&vfe31_ctrl->stop_ack_pending, 0);
-		vfe31_send_msg_no_payload(MSG_ID_STOP_ACK);
-	} else {
-		/* this is from reset command. */
-		vfe31_set_default_reg_values();
-
-		/* reload all write masters. (frame & line)*/
-		msm_camera_io_w_mb(0x7FFF, vfe31_ctrl->vfebase + VFE_BUS_CMD);
-		vfe31_send_msg_no_payload(MSG_ID_RESET_ACK);
-	}
-}
-
-
-static void vfe31_process_axi_halt_irq(void)
-{
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(AXI_HALT_CLEAR,
-		vfe31_ctrl->vfebase + VFE_AXI_CMD);
-	vfe31_ctrl->while_stopping_mask = VFE_IMASK_RESET;
-
-	/* disable all interrupts.  */
-	msm_camera_io_w(VFE_DISABLE_ALL_IRQS,
-		vfe31_ctrl->vfebase + VFE_IRQ_MASK_0);
-	msm_camera_io_w(VFE_DISABLE_ALL_IRQS,
-		vfe31_ctrl->vfebase + VFE_IRQ_MASK_1);
-
-	/* clear all pending interrupts*/
-	msm_camera_io_w(VFE_CLEAR_ALL_IRQS,
-		vfe31_ctrl->vfebase + VFE_IRQ_CLEAR_0);
-	msm_camera_io_w(VFE_CLEAR_ALL_IRQS,
-		vfe31_ctrl->vfebase + VFE_IRQ_CLEAR_1);
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(1,
-		vfe31_ctrl->vfebase + VFE_IRQ_CMD);
-
-	/* now enable only halt_irq & reset_irq */
-	msm_camera_io_w(0xf0000000,          /* this is for async timer. */
-		vfe31_ctrl->vfebase + VFE_IRQ_MASK_0);
-	msm_camera_io_w(VFE_IMASK_RESET,
-		vfe31_ctrl->vfebase + VFE_IRQ_MASK_1);
-
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	CDBG("%s: about to reset vfe...\n", __func__);
-	msm_camera_io_w_mb(VFE_RESET_UPON_STOP_CMD,
-		vfe31_ctrl->vfebase + VFE_GLOBAL_RESET);
-
-}
-
-static void vfe31_process_camif_sof_irq(void)
-{
-	uint32_t  temp;
-
-	/* in raw snapshot mode */
-	if (vfe31_ctrl->operation_mode ==
-		VFE_MODE_OF_OPERATION_RAW_SNAPSHOT) {
-		if (vfe31_ctrl->start_ack_pending) {
-			vfe31_send_msg_no_payload(MSG_ID_START_ACK);
-			vfe31_ctrl->start_ack_pending = FALSE;
-		}
-		if (vfe31_ctrl->vfe_capture_count)
-			vfe31_ctrl->vfe_capture_count--;
-		/* if last frame to be captured: */
-		if (vfe31_ctrl->vfe_capture_count == 0) {
-			/* Ensure the write order while writing
-			to the command register using the barrier */
-			msm_camera_io_w_mb(CAMIF_COMMAND_STOP_AT_FRAME_BOUNDARY,
-				vfe31_ctrl->vfebase + VFE_CAMIF_COMMAND);
-			temp = msm_camera_io_r_mb(vfe31_ctrl->vfebase +
-				VFE_CAMIF_COMMAND);
-		}
-	} /* if raw snapshot mode. */
-
-	if ((vfe31_ctrl->hfr_mode != HFR_MODE_OFF) &&
-		(vfe31_ctrl->operation_mode == VFE_MODE_OF_OPERATION_VIDEO) &&
-		(vfe31_ctrl->vfeFrameId % vfe31_ctrl->hfr_mode != 0)) {
-		vfe31_ctrl->vfeFrameId++;
-		CDBG("Skip the SOF notification when HFR enabled\n");
-		return;
-	}
-	vfe31_send_msg_no_payload(MSG_ID_SOF_ACK);
-	vfe31_ctrl->vfeFrameId++;
-	CDBG("camif_sof_irq, frameId = %d\n", vfe31_ctrl->vfeFrameId);
-
-	if (vfe31_ctrl->sync_timer_state) {
-		if (vfe31_ctrl->sync_timer_repeat_count == 0)
-			vfe31_sync_timer_stop();
-		else
-		vfe31_ctrl->sync_timer_repeat_count--;
-	}
-}
-
-static void vfe31_process_error_irq(uint32_t errStatus)
-{
-	uint32_t camifStatus, read_val;
-	uint32_t *temp;
-
-	if (errStatus & VFE31_IMASK_CAMIF_ERROR) {
-		pr_err("vfe31_irq: camif errors\n");
-		temp = (uint32_t *)(vfe31_ctrl->vfebase + VFE_CAMIF_STATUS);
-		camifStatus = msm_camera_io_r(temp);
-		pr_err("camifStatus  = 0x%x\n", camifStatus);
-		vfe31_send_msg_no_payload(MSG_ID_CAMIF_ERROR);
-	}
-
-	if (errStatus & VFE31_IMASK_STATS_CS_OVWR)
-		pr_err("vfe31_irq: stats cs overwrite\n");
-
-	if (errStatus & VFE31_IMASK_STATS_IHIST_OVWR)
-		pr_err("vfe31_irq: stats ihist overwrite\n");
-
-	if (errStatus & VFE31_IMASK_REALIGN_BUF_Y_OVFL)
-		pr_err("vfe31_irq: realign bug Y overflow\n");
-
-	if (errStatus & VFE31_IMASK_REALIGN_BUF_CB_OVFL)
-		pr_err("vfe31_irq: realign bug CB overflow\n");
-
-	if (errStatus & VFE31_IMASK_REALIGN_BUF_CR_OVFL)
-		pr_err("vfe31_irq: realign bug CR overflow\n");
-
-	if (errStatus & VFE31_IMASK_VIOLATION)
-		pr_err("vfe31_irq: violation interrupt\n");
-
-	if (errStatus & VFE31_IMASK_IMG_MAST_0_BUS_OVFL)
-		pr_err("vfe31_irq: image master 0 bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_IMG_MAST_1_BUS_OVFL)
-		pr_err("vfe31_irq: image master 1 bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_IMG_MAST_2_BUS_OVFL)
-		pr_err("vfe31_irq: image master 2 bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_IMG_MAST_3_BUS_OVFL)
-		pr_err("vfe31_irq: image master 3 bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_IMG_MAST_4_BUS_OVFL)
-		pr_err("vfe31_irq: image master 4 bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_IMG_MAST_5_BUS_OVFL)
-		pr_err("vfe31_irq: image master 5 bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_IMG_MAST_6_BUS_OVFL)
-		pr_err("vfe31_irq: image master 6 bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_STATS_AE_BUS_OVFL)
-		pr_err("vfe31_irq: ae stats bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_STATS_AF_BUS_OVFL)
-		pr_err("vfe31_irq: af stats bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_STATS_AWB_BUS_OVFL)
-		pr_err("vfe31_irq: awb stats bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_STATS_RS_BUS_OVFL)
-		pr_err("vfe31_irq: rs stats bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_STATS_CS_BUS_OVFL)
-		pr_err("vfe31_irq: cs stats bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_STATS_IHIST_BUS_OVFL)
-		pr_err("vfe31_irq: ihist stats bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_STATS_SKIN_BUS_OVFL)
-		pr_err("vfe31_irq: skin stats bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_AXI_ERROR) {
-		pr_err("vfe31_irq: axi error\n");
-		/* read status too when overflow happens.*/
-		read_val = msm_camera_io_r(vfe31_ctrl->vfebase +
-			VFE_BUS_PING_PONG_STATUS);
-		pr_debug("VFE_BUS_PING_PONG_STATUS = 0x%x\n", read_val);
-		read_val = msm_camera_io_r(vfe31_ctrl->vfebase +
-			VFE_BUS_OPERATION_STATUS);
-		pr_debug("VFE_BUS_OPERATION_STATUS = 0x%x\n", read_val);
-		read_val = msm_camera_io_r(vfe31_ctrl->vfebase +
-			VFE_BUS_IMAGE_MASTER_0_WR_PM_STATS_0);
-		pr_debug("VFE_BUS_IMAGE_MASTER_0_WR_PM_STATS_0 = 0x%x\n",
-			read_val);
-		read_val = msm_camera_io_r(vfe31_ctrl->vfebase +
-			VFE_BUS_IMAGE_MASTER_0_WR_PM_STATS_1);
-		pr_debug("VFE_BUS_IMAGE_MASTER_0_WR_PM_STATS_1 = 0x%x\n",
-			read_val);
-		read_val = msm_camera_io_r(vfe31_ctrl->vfebase +
-			VFE_AXI_STATUS);
-		pr_debug("VFE_AXI_STATUS = 0x%x\n", read_val);
-	}
-}
-
-#define VFE31_AXI_OFFSET 0x0050
-#define vfe31_get_ch_ping_addr(chn) \
-	(msm_camera_io_r(vfe31_ctrl->vfebase + 0x0050 + 0x18 * (chn)))
-#define vfe31_get_ch_pong_addr(chn) \
-	(msm_camera_io_r(vfe31_ctrl->vfebase + 0x0050 + 0x18 * (chn) + 4))
-#define vfe31_get_ch_addr(ping_pong, chn) \
-	(((ping_pong) & (1 << (chn))) == 0 ? \
-	vfe31_get_ch_pong_addr(chn) : vfe31_get_ch_ping_addr(chn))
-
-#define vfe31_put_ch_ping_addr(chn, addr) \
-	(msm_camera_io_w((addr), vfe31_ctrl->vfebase + 0x0050 + 0x18 * (chn)))
-#define vfe31_put_ch_pong_addr(chn, addr) \
-	(msm_camera_io_w((addr), \
-	vfe31_ctrl->vfebase + 0x0050 + 0x18 * (chn) + 4))
-#define vfe31_put_ch_addr(ping_pong, chn, addr) \
-	(((ping_pong) & (1 << (chn))) == 0 ?   \
-	vfe31_put_ch_pong_addr((chn), (addr)) : \
-	vfe31_put_ch_ping_addr((chn), (addr)))
-
-static void vfe31_process_output_path_irq_0(uint32_t ping_pong)
-{
-	uint32_t p0_addr, p1_addr, p2_addr;
-#ifdef CONFIG_MSM_CAMERA_V4L2
-	uint32_t pyaddr_ping, pcbcraddr_ping, pyaddr_pong, pcbcraddr_pong;
-#endif
-	struct vfe31_free_buf *free_buf = NULL;
-	/* we render frames in the following conditions:
-	1. Continuous mode and the free buffer is avaialable.
-	*/
-	if (vfe31_ctrl->outpath.output_mode &
-		VFE31_OUTPUT_MODE_P_ALL_CHNLS) {
-		if (!(((ping_pong & PINGPONG_LOWER) == PINGPONG_LOWER) ||
-			((ping_pong & PINGPONG_LOWER) == 0x0))) {
-			pr_err(" Irq_2 - skip the frame pp_status is not proper"
-				"PP_status = 0x%x\n", ping_pong);
-			return;
-		}
-	}
-	free_buf = vfe31_get_free_buf(&vfe31_ctrl->outpath.out0);
-
-	if (free_buf) {
-		/* Y channel */
-		p0_addr = vfe31_get_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out0.ch0);
-		/* Chroma channel */
-		p1_addr = vfe31_get_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out0.ch1);
-		if (vfe31_ctrl->outpath.output_mode &
-			VFE31_OUTPUT_MODE_P_ALL_CHNLS) {
-			p2_addr = vfe31_get_ch_addr(ping_pong,
-				vfe31_ctrl->outpath.out0.ch2);
-		} else {
-			p2_addr = p0_addr;
-		}
-		CDBG("Output path 0, p0_addr = 0x%x, p1_addr = 0x%x,"
-			 "p2_addr = 0x%x\n", p0_addr, p1_addr, p2_addr);
-		/* Y channel */
-		vfe31_put_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out0.ch0,
-			free_buf->paddr + free_buf->planar0_off);
-		/* Chroma channel */
-		vfe31_put_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out0.ch1,
-			free_buf->paddr + free_buf->planar1_off);
-		if (vfe31_ctrl->outpath.output_mode &
-			VFE31_OUTPUT_MODE_P_ALL_CHNLS)
-			vfe31_put_ch_addr(ping_pong,
-				vfe31_ctrl->outpath.out0.ch2,
-			free_buf->paddr + free_buf->planar2_off);
-			kfree(free_buf);
-			/* if continuous mode, for display. (preview) */
-			vfe_send_outmsg(MSG_ID_OUTPUT_P,  p0_addr, p1_addr,
-				p2_addr);
-	} else {
-		vfe31_ctrl->outpath.out0.frame_drop_cnt++;
-		pr_warning("path_irq_0 - no free buffer!\n");
-#ifdef CONFIG_MSM_CAMERA_V4L2
-		pr_info("Swapping ping and pong\n");
-
-		/*get addresses*/
-		/* Y channel */
-		pyaddr_ping = vfe31_get_ch_ping_addr(
-			vfe31_ctrl->outpath.out0.ch0);
-		/* Chroma channel */
-		pcbcraddr_ping = vfe31_get_ch_ping_addr(
-			vfe31_ctrl->outpath.out0.ch1);
-		/* Y channel */
-		pyaddr_pong = vfe31_get_ch_pong_addr(
-			vfe31_ctrl->outpath.out0.ch0);
-		/* Chroma channel */
-		pcbcraddr_pong = vfe31_get_ch_pong_addr(
-			vfe31_ctrl->outpath.out0.ch1);
-
-		CDBG("ping = 0x%p, pong = 0x%p\n", (void *)pyaddr_ping,
-			(void *)pyaddr_pong);
-		CDBG("ping_cbcr = 0x%p, pong_cbcr = 0x%p\n",
-			(void *)pcbcraddr_ping, (void *)pcbcraddr_pong);
-
-		/*put addresses*/
-		/* SWAP y channel*/
-		vfe31_put_ch_ping_addr(vfe31_ctrl->outpath.out0.ch0,
-			pyaddr_pong);
-		vfe31_put_ch_pong_addr(vfe31_ctrl->outpath.out0.ch0,
-			pyaddr_ping);
-		/* SWAP chroma channel*/
-		vfe31_put_ch_ping_addr(vfe31_ctrl->outpath.out0.ch1,
-			pcbcraddr_pong);
-		vfe31_put_ch_pong_addr(vfe31_ctrl->outpath.out0.ch1,
-			pcbcraddr_ping);
-		CDBG("after swap: ping = 0x%p, pong = 0x%p\n",
-			(void *)pyaddr_pong, (void *)pyaddr_ping);
-#endif
-	}
-}
-
-static void vfe31_process_snapshot_frame(uint32_t ping_pong)
-{
-	uint32_t p0_addr, p1_addr;
-	struct vfe31_free_buf *free_buf = NULL;
-	/* Y channel- Main Image */
-	p0_addr = vfe31_get_ch_addr(ping_pong,
-		vfe31_ctrl->outpath.out1.ch0);
-	/* Chroma channel - TN Image */
-	p1_addr = vfe31_get_ch_addr(ping_pong,
-		vfe31_ctrl->outpath.out1.ch1);
-
-	free_buf = vfe31_get_free_buf(&vfe31_ctrl->outpath.out1);
-	CDBG("%s: snapshot main, p0_addr = 0x%x, p1_addr = 0x%x\n",
-		__func__, p0_addr, p1_addr);
-	if (free_buf) {
-		/* Y channel */
-		vfe31_put_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out1.ch0,
-			free_buf->paddr + free_buf->planar0_off);
-		/* Chroma channel */
-		vfe31_put_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out1.ch1,
-			free_buf->paddr + free_buf->planar1_off);
-		kfree(free_buf);
-	}
-	vfe_send_outmsg(MSG_ID_OUTPUT_S, p0_addr, p1_addr, p0_addr);
-
-	/* Y channel- TN Image */
-	p0_addr = vfe31_get_ch_addr(ping_pong,
-		vfe31_ctrl->outpath.out0.ch0);
-	/* Chroma channel - TN Image */
-	p1_addr = vfe31_get_ch_addr(ping_pong,
-		vfe31_ctrl->outpath.out0.ch1);
-
-	free_buf = vfe31_get_free_buf(&vfe31_ctrl->outpath.out0);
-	CDBG("%s: snapshot TN, p0_addr = 0x%x, p1_addr = 0x%x\n",
-		__func__, p0_addr, p1_addr);
-	if (free_buf) {
-		/* Y channel */
-		vfe31_put_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out0.ch0,
-			free_buf->paddr + free_buf->planar0_off);
-		/* Chroma channel */
-		vfe31_put_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out0.ch1,
-			free_buf->paddr + free_buf->planar1_off);
-		kfree(free_buf);
-	}
-
-	vfe_send_outmsg(MSG_ID_OUTPUT_T, p0_addr, p1_addr, p0_addr);
-
-	/* in snapshot mode if done then send
-		snapshot done message */
-	if (vfe31_ctrl->vfe_capture_count == 0) {
-		vfe31_send_msg_no_payload(MSG_ID_SNAPSHOT_DONE);
-		/* Ensure the write order while writing
-			to the cmd register using barrier */
-		msm_camera_io_w_mb(CAMIF_COMMAND_STOP_IMMEDIATELY,
-			vfe31_ctrl->vfebase +
-			VFE_CAMIF_COMMAND);
-	}
-}
-
-static void vfe31_process_raw_snapshot_frame(uint32_t ping_pong)
-{
-	uint32_t pyaddr, pcbcraddr;
-	struct vfe31_free_buf *free_buf = NULL;
-	struct msm_sync* p_sync = (struct msm_sync *)vfe_syncdata;
-
-	if (p_sync->stereocam_enabled)
-		p_sync->stereo_state = STEREO_RAW_SNAP_STARTED;
-
-	/* Y channel- Main Image */
-	pyaddr = vfe31_get_ch_addr(ping_pong,
-		vfe31_ctrl->outpath.out1.ch0);
-	/* Chroma channel - Main Image */
-	pcbcraddr = vfe31_get_ch_addr(ping_pong,
-		vfe31_ctrl->outpath.out1.ch1);
-
-	free_buf = vfe31_get_free_buf(&vfe31_ctrl->outpath.out1);
-	CDBG("%s: snapshot raw, pyaddr = 0x%x, pcbcraddr = 0x%x\n",
-		__func__, pyaddr, pcbcraddr);
-	if (free_buf) {
-		/* Y channel */
-		vfe31_put_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out1.ch0,
-			free_buf->paddr + free_buf->planar0_off);
-		/* Chroma channel */
-		vfe31_put_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out1.ch1,
-			free_buf->paddr + free_buf->planar1_off);
-		kfree(free_buf);
-	}
-	 vfe_send_outmsg(MSG_ID_OUTPUT_S, pyaddr, pcbcraddr, 0);
-
-	/* in snapshot mode if done then send
-		snapshot done message */
-	if (vfe31_ctrl->vfe_capture_count == 0) {
-		vfe31_send_msg_no_payload(MSG_ID_SNAPSHOT_DONE);
-		/* Ensure the write order while writing
-		to the cmd register using barrier */
-		msm_camera_io_w_mb(CAMIF_COMMAND_STOP_IMMEDIATELY,
-			vfe31_ctrl->vfebase +
-			VFE_CAMIF_COMMAND);
-	}
-}
-static void vfe31_process_zsl_frame(uint32_t ping_pong)
-{
-	uint32_t p0_addr, p1_addr;
-	struct vfe31_free_buf *free_buf = NULL;
-	/* Y channel- Main Image */
-	p0_addr = vfe31_get_ch_addr(ping_pong,
-		vfe31_ctrl->outpath.out2.ch0);
-	/* Chroma channel - Main Image */
-	p1_addr = vfe31_get_ch_addr(ping_pong,
-		vfe31_ctrl->outpath.out2.ch1);
-
-	free_buf = vfe31_get_free_buf(&vfe31_ctrl->outpath.out2);
-	CDBG("%s: snapshot main, pyaddr = 0x%x, pcbcraddr = 0x%x\n",
-		__func__, p0_addr, p1_addr);
-	if (free_buf) {
-		/* Y channel */
-		vfe31_put_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out2.ch0,
-			free_buf->paddr + free_buf->planar0_off);
-		/* Chroma channel */
-		vfe31_put_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out2.ch1,
-			free_buf->paddr + free_buf->planar1_off);
-		kfree(free_buf);
-	}
-	 vfe_send_outmsg(MSG_ID_OUTPUT_S, p0_addr, p1_addr, p0_addr);
-
-	/* Y channel- TN Image */
-	p0_addr = vfe31_get_ch_addr(ping_pong,
-		vfe31_ctrl->outpath.out1.ch0);
-	/* Chroma channel - TN Image */
-	p1_addr = vfe31_get_ch_addr(ping_pong,
-		vfe31_ctrl->outpath.out1.ch1);
-
-	free_buf = vfe31_get_free_buf(&vfe31_ctrl->outpath.out1);
-	CDBG("%s: snapshot TN, pyaddr = 0x%x, pcbcraddr = 0x%x\n",
-		__func__, p0_addr, p1_addr);
-	if (free_buf) {
-		/* Y channel */
-		vfe31_put_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out1.ch0,
-			free_buf->paddr + free_buf->planar0_off);
-		/* Chroma channel */
-		vfe31_put_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out1.ch1,
-			free_buf->paddr + free_buf->planar1_off);
-		kfree(free_buf);
-	}
-
-	vfe_send_outmsg(MSG_ID_OUTPUT_T, p0_addr, p1_addr, p0_addr);
-}
-
-static void vfe31_process_output_path_irq_1(uint32_t ping_pong)
-{
-
-#ifdef CONFIG_MSM_CAMERA_V4L2
-	uint32_t pyaddr_ping, pcbcraddr_ping, pyaddr_pong, pcbcraddr_pong;
-#endif
-	CDBG("%s, operation_mode = %d, cap_cnt = %d\n", __func__,
-		vfe31_ctrl->operation_mode, vfe31_ctrl->vfe_capture_count);
-
-	/* In Snapshot mode */
-	if ((VFE_MODE_OF_OPERATION_SNAPSHOT == vfe31_ctrl->operation_mode)
-		&& ((vfe31_ctrl->vfe_capture_count <= 1)
-		|| (vfe31_free_buf_available(vfe31_ctrl->outpath.out0) &&
-		vfe31_free_buf_available(vfe31_ctrl->outpath.out1)))) {
-		vfe31_process_snapshot_frame(ping_pong);
-	} else if ((VFE_MODE_OF_OPERATION_RAW_SNAPSHOT ==
-		vfe31_ctrl->operation_mode) &&
-		((vfe31_ctrl->vfe_capture_count <= 1) ||
-		vfe31_free_buf_available(vfe31_ctrl->outpath.out1))) {
-		vfe31_process_raw_snapshot_frame(ping_pong);
-	} else if ((VFE_MODE_OF_OPERATION_ZSL == vfe31_ctrl->operation_mode)
-		&& (vfe31_free_buf_available(vfe31_ctrl->outpath.out1)
-		&& vfe31_free_buf_available(vfe31_ctrl->outpath.out2))) {
-		vfe31_process_zsl_frame(ping_pong);
-	} else {
-		vfe31_ctrl->outpath.out1.frame_drop_cnt++;
-		pr_info("path_irq_1 - no free buffer!\n");
-#ifdef CONFIG_MSM_CAMERA_V4L2
-		pr_info("Swapping ping and pong\n");
-
-		/*get addresses*/
-		/* Y channel */
-		pyaddr_ping = vfe31_get_ch_ping_addr(
-			vfe31_ctrl->outpath.out1.ch0);
-		/* Chroma channel */
-		pcbcraddr_ping = vfe31_get_ch_ping_addr(
-			vfe31_ctrl->outpath.out1.ch1);
-		/* Y channel */
-		pyaddr_pong = vfe31_get_ch_pong_addr(
-			vfe31_ctrl->outpath.out1.ch0);
-		/* Chroma channel */
-		pcbcraddr_pong = vfe31_get_ch_pong_addr(
-			vfe31_ctrl->outpath.out1.ch1);
-
-		CDBG("ping = 0x%p, pong = 0x%p\n", (void *)pyaddr_ping,
-			(void *)pyaddr_pong);
-		CDBG("ping_cbcr = 0x%p, pong_cbcr = 0x%p\n",
-			(void *)pcbcraddr_ping, (void *)pcbcraddr_pong);
-
-		/*put addresses*/
-		/* SWAP y channel*/
-		vfe31_put_ch_ping_addr(vfe31_ctrl->outpath.out1.ch0,
-			pyaddr_pong);
-		vfe31_put_ch_pong_addr(vfe31_ctrl->outpath.out1.ch0,
-			pyaddr_ping);
-		/* SWAP chroma channel*/
-		vfe31_put_ch_ping_addr(vfe31_ctrl->outpath.out1.ch1,
-			pcbcraddr_pong);
-		vfe31_put_ch_pong_addr(vfe31_ctrl->outpath.out1.ch1,
-			pcbcraddr_ping);
-		CDBG("after swap: ping = 0x%p, pong = 0x%p\n",
-			(void *)pyaddr_pong, (void *)pyaddr_ping);
-#endif
-	}
-
-}
-
-static void vfe31_process_output_path_irq_2(uint32_t ping_pong)
-{
-	uint32_t p0_addr, p1_addr, p2_addr;
-	struct vfe31_free_buf *free_buf = NULL;
-
-#ifdef CONFIG_MSM_CAMERA_V4L2
-	uint32_t pyaddr_ping, pcbcraddr_ping, pyaddr_pong, pcbcraddr_pong;
-#endif
-	/* we render frames in the following conditions:
-	1. Continuous mode and the free buffer is avaialable.
-	*/
-	CDBG("%s, operation_mode = %d, state %d\n", __func__,
-		vfe31_ctrl->operation_mode,
-		vfe31_ctrl->recording_state);
-	/* Ensure that both wm1 and wm5 ping and pong buffers are active*/
-	if (!(((ping_pong & 0x22) == 0x22) ||
-		((ping_pong & 0x22) == 0x0))) {
-		pr_err(" Irq_2 - skip the frame pp_status is not proper"
-			"PP_status = 0x%x\n", ping_pong);
-		return;
-	}
-	if ((vfe31_ctrl->recording_state == VFE_REC_STATE_STOP_REQUESTED)
-		|| (vfe31_ctrl->recording_state == VFE_REC_STATE_STOPPED)) {
-		vfe31_ctrl->outpath.out2.frame_drop_cnt++;
-		pr_warning("path_irq_2 - recording stopped\n");
-		return;
-	}
-
-	free_buf = vfe31_get_free_buf(&vfe31_ctrl->outpath.out2);
-
-	if (free_buf) {
-		/* Y channel */
-		p0_addr = vfe31_get_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out2.ch0);
-		/* Chroma channel */
-		p1_addr = vfe31_get_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out2.ch1);
-		p2_addr = p0_addr;
-		CDBG("video output, pyaddr = 0x%x, pcbcraddr = 0x%x\n",
-			p0_addr, p1_addr);
-
-		/* Y channel */
-		vfe31_put_ch_addr(ping_pong,
-		vfe31_ctrl->outpath.out2.ch0,
-		free_buf->paddr + free_buf->planar0_off);
-		/* Chroma channel */
-		vfe31_put_ch_addr(ping_pong,
-		vfe31_ctrl->outpath.out2.ch1,
-		free_buf->paddr + free_buf->planar1_off);
-		kfree(free_buf);
-		vfe_send_outmsg(MSG_ID_OUTPUT_V, p0_addr, p1_addr, p2_addr);
-	} else {
-		vfe31_ctrl->outpath.out2.frame_drop_cnt++;
-		pr_warning("path_irq_2 - no free buffer!\n");
-
-#ifdef CONFIG_MSM_CAMERA_V4L2
-		pr_info("Swapping ping and pong\n");
-
-		/*get addresses*/
-		/* Y channel */
-		pyaddr_ping = vfe31_get_ch_ping_addr(
-			vfe31_ctrl->outpath.out2.ch0);
-		/* Chroma channel */
-		pcbcraddr_ping = vfe31_get_ch_ping_addr(
-			vfe31_ctrl->outpath.out2.ch1);
-		/* Y channel */
-		pyaddr_pong = vfe31_get_ch_pong_addr(
-			vfe31_ctrl->outpath.out2.ch0);
-		/* Chroma channel */
-		pcbcraddr_pong = vfe31_get_ch_pong_addr(
-			vfe31_ctrl->outpath.out2.ch1);
-
-		CDBG("ping = 0x%p, pong = 0x%p\n", (void *)pyaddr_ping,
-			(void *)pyaddr_pong);
-		CDBG("ping_cbcr = 0x%p, pong_cbcr = 0x%p\n",
-			(void *)pcbcraddr_ping, (void *)pcbcraddr_pong);
-
-		/*put addresses*/
-		/* SWAP y channel*/
-		vfe31_put_ch_ping_addr(vfe31_ctrl->outpath.out2.ch0,
-			pyaddr_pong);
-		vfe31_put_ch_pong_addr(vfe31_ctrl->outpath.out2.ch0,
-			pyaddr_ping);
-		/* SWAP chroma channel*/
-		vfe31_put_ch_ping_addr(vfe31_ctrl->outpath.out2.ch1,
-			pcbcraddr_pong);
-		vfe31_put_ch_pong_addr(vfe31_ctrl->outpath.out2.ch1,
-			pcbcraddr_ping);
-		CDBG("after swap: ping = 0x%p, pong = 0x%p\n",
-			(void *)pyaddr_pong, (void *)pyaddr_ping);
-#endif
-	}
-}
-
-
-static uint32_t  vfe31_process_stats_irq_common(uint32_t statsNum,
-						uint32_t newAddr) {
-
-	uint32_t pingpongStatus;
-	uint32_t returnAddr;
-	uint32_t pingpongAddr;
-
-	/* must be 0=ping, 1=pong */
-	pingpongStatus =
-		((msm_camera_io_r(vfe31_ctrl->vfebase +
-		VFE_BUS_PING_PONG_STATUS))
-	& ((uint32_t)(1<<(statsNum + 7)))) >> (statsNum + 7);
-	/* stats bits starts at 7 */
-	CDBG("statsNum %d, pingpongStatus %d\n", statsNum, pingpongStatus);
-	pingpongAddr =
-		((uint32_t)(vfe31_ctrl->vfebase +
-				VFE_BUS_STATS_PING_PONG_BASE)) +
-				(3*statsNum)*4 + (1-pingpongStatus)*4;
-	returnAddr = msm_camera_io_r((uint32_t *)pingpongAddr);
-	msm_camera_io_w(newAddr, (uint32_t *)pingpongAddr);
-	return returnAddr;
-}
-
-static void vfe_send_stats_msg(void)
-{
-	struct  vfe_message msg;
-	uint32_t temp;
-
-	/* fill message with right content. */
-	msg._u.msgStats.frameCounter = vfe31_ctrl->vfeFrameId;
-	msg._u.msgStats.status_bits = vfe31_ctrl->status_bits;
-	msg._d = MSG_ID_COMMON;
-
-	msg._u.msgStats.buff.aec = vfe31_ctrl->aecStatsControl.bufToRender;
-	msg._u.msgStats.buff.awb = vfe31_ctrl->awbStatsControl.bufToRender;
-	msg._u.msgStats.buff.af = vfe31_ctrl->afStatsControl.bufToRender;
-
-	msg._u.msgStats.buff.ihist = vfe31_ctrl->ihistStatsControl.bufToRender;
-	msg._u.msgStats.buff.rs = vfe31_ctrl->rsStatsControl.bufToRender;
-	msg._u.msgStats.buff.cs = vfe31_ctrl->csStatsControl.bufToRender;
-
-	temp = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_STATS_AWB_SGW_CFG);
-	msg._u.msgStats.buff.awb_ymin = (0xFF00 & temp) >> 8;
-
-	vfe31_proc_ops(msg._d,
-		&msg, sizeof(struct vfe_message));
-	return;
-}
-
-static void vfe31_process_stats(void)
-{
-	int32_t process_stats = false;
-
-	CDBG("%s, stats = 0x%x\n", __func__, vfe31_ctrl->status_bits);
-
-	if (vfe31_ctrl->status_bits & VFE_IRQ_STATUS0_STATS_AEC) {
-		if (!vfe31_ctrl->aec_ack_pending) {
-			vfe31_ctrl->aec_ack_pending = TRUE;
-			vfe31_ctrl->aecStatsControl.bufToRender =
-				vfe31_process_stats_irq_common(statsAeNum,
-				vfe31_ctrl->aecStatsControl.nextFrameAddrBuf);
-			process_stats = true;
-		} else{
-			vfe31_ctrl->aecStatsControl.bufToRender = 0;
-			vfe31_ctrl->aecStatsControl.droppedStatsFrameCount++;
-		}
-	} else {
-		vfe31_ctrl->aecStatsControl.bufToRender = 0;
-	}
-
-	if (vfe31_ctrl->status_bits & VFE_IRQ_STATUS0_STATS_AWB) {
-		if (!vfe31_ctrl->awb_ack_pending) {
-			vfe31_ctrl->awb_ack_pending = TRUE;
-			vfe31_ctrl->awbStatsControl.bufToRender =
-				vfe31_process_stats_irq_common(statsAwbNum,
-				vfe31_ctrl->awbStatsControl.nextFrameAddrBuf);
-			process_stats = true;
-		} else{
-			vfe31_ctrl->awbStatsControl.droppedStatsFrameCount++;
-			vfe31_ctrl->awbStatsControl.bufToRender = 0;
-		}
-	} else {
-		vfe31_ctrl->awbStatsControl.bufToRender = 0;
-	}
-
-
-	if (vfe31_ctrl->status_bits & VFE_IRQ_STATUS0_STATS_AF) {
-		if (!vfe31_ctrl->af_ack_pending) {
-			vfe31_ctrl->af_ack_pending = TRUE;
-			vfe31_ctrl->afStatsControl.bufToRender =
-				vfe31_process_stats_irq_common(statsAfNum,
-				vfe31_ctrl->afStatsControl.nextFrameAddrBuf);
-			process_stats = true;
-		} else {
-			vfe31_ctrl->afStatsControl.bufToRender = 0;
-			vfe31_ctrl->afStatsControl.droppedStatsFrameCount++;
-		}
-	} else {
-		vfe31_ctrl->afStatsControl.bufToRender = 0;
-	}
-
-	if (vfe31_ctrl->status_bits & VFE_IRQ_STATUS0_STATS_IHIST) {
-		if (!vfe31_ctrl->ihist_ack_pending) {
-			vfe31_ctrl->ihist_ack_pending = TRUE;
-			vfe31_ctrl->ihistStatsControl.bufToRender =
-				vfe31_process_stats_irq_common(statsIhistNum,
-				vfe31_ctrl->ihistStatsControl.nextFrameAddrBuf);
-			process_stats = true;
-		} else {
-			vfe31_ctrl->ihistStatsControl.droppedStatsFrameCount++;
-			vfe31_ctrl->ihistStatsControl.bufToRender = 0;
-		}
-	} else {
-		vfe31_ctrl->ihistStatsControl.bufToRender = 0;
-	}
-
-	if (vfe31_ctrl->status_bits & VFE_IRQ_STATUS0_STATS_RS) {
-		if (!vfe31_ctrl->rs_ack_pending) {
-			vfe31_ctrl->rs_ack_pending = TRUE;
-			vfe31_ctrl->rsStatsControl.bufToRender =
-				vfe31_process_stats_irq_common(statsRsNum,
-				vfe31_ctrl->rsStatsControl.nextFrameAddrBuf);
-			process_stats = true;
-		} else {
-			vfe31_ctrl->rsStatsControl.droppedStatsFrameCount++;
-			vfe31_ctrl->rsStatsControl.bufToRender = 0;
-		}
-	} else {
-		vfe31_ctrl->rsStatsControl.bufToRender = 0;
-	}
-
-
-	if (vfe31_ctrl->status_bits & VFE_IRQ_STATUS0_STATS_CS) {
-		if (!vfe31_ctrl->cs_ack_pending) {
-			vfe31_ctrl->cs_ack_pending = TRUE;
-			vfe31_ctrl->csStatsControl.bufToRender =
-				vfe31_process_stats_irq_common(statsCsNum,
-				vfe31_ctrl->csStatsControl.nextFrameAddrBuf);
-			process_stats = true;
-		} else {
-			vfe31_ctrl->csStatsControl.droppedStatsFrameCount++;
-			vfe31_ctrl->csStatsControl.bufToRender = 0;
-		}
-	} else {
-		vfe31_ctrl->csStatsControl.bufToRender = 0;
-	}
-
-	if (process_stats)
-		vfe_send_stats_msg();
-
-	return;
-}
-
-static void vfe31_process_stats_irq(uint32_t *irqstatus)
-{
-	/* Subsample the stats according to the hfr speed*/
-	if ((vfe31_ctrl->hfr_mode != HFR_MODE_OFF) &&
-		(vfe31_ctrl->vfeFrameId % vfe31_ctrl->hfr_mode != 0)) {
-		CDBG("Skip the stats when HFR enabled\n");
-		return;
-	}
-
-	vfe31_ctrl->status_bits = VFE_COM_STATUS & *irqstatus;
-	vfe31_process_stats();
-	return;
-}
-
-static void vfe31_do_tasklet(unsigned long data)
-{
-	unsigned long flags;
-
-	struct vfe31_isr_queue_cmd *qcmd = NULL;
-
-	CDBG("=== vfe31_do_tasklet start === \n");
-
-	while (atomic_read(&irq_cnt)) {
-		spin_lock_irqsave(&vfe31_ctrl->tasklet_lock, flags);
-		qcmd = list_first_entry(&vfe31_ctrl->tasklet_q,
-			struct vfe31_isr_queue_cmd, list);
-		atomic_sub(1, &irq_cnt);
-
-		if (!qcmd) {
-			spin_unlock_irqrestore(&vfe31_ctrl->tasklet_lock,
-				flags);
-			return;
-		}
-
-		list_del(&qcmd->list);
-		spin_unlock_irqrestore(&vfe31_ctrl->tasklet_lock,
-			flags);
-
-		/* interrupt to be processed,  *qcmd has the payload.  */
-		if (qcmd->vfeInterruptStatus0 &
-			VFE_IRQ_STATUS0_REG_UPDATE_MASK) {
-			CDBG("irq regUpdateIrq\n");
-			vfe31_process_reg_update_irq();
-		}
-
-		if (qcmd->vfeInterruptStatus1 &
-			VFE_IMASK_RESET) {
-			CDBG("irq resetAckIrq\n");
-			vfe31_process_reset_irq();
-		}
-
-
-		if (qcmd->vfeInterruptStatus1 &
-			VFE_IMASK_AXI_HALT) {
-			CDBG("irq axi halt irq\n");
-			vfe31_process_axi_halt_irq();
-		}
-
-		if (atomic_read(&vfe31_ctrl->vstate)) {
-			if (qcmd->vfeInterruptStatus1 &
-					VFE31_IMASK_ERROR_ONLY_1) {
-				pr_err("irq	errorIrq\n");
-				vfe31_process_error_irq(
-					qcmd->vfeInterruptStatus1 &
-					VFE31_IMASK_ERROR_ONLY_1);
-			}
-
-			/* irqs below are only valid when in active state. */
-			/* next, check output path related interrupts. */
-			if (qcmd->vfeInterruptStatus0 &
-				VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE0_MASK) {
-				CDBG("Image composite done 0 irq occured.\n");
-				vfe31_process_output_path_irq_0(
-					qcmd->vfePingPongStatus);
-			}
-
-			if (qcmd->vfeInterruptStatus0 &
-				VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE1_MASK) {
-				CDBG("Image composite done 1 irq occured.\n");
-				vfe31_process_output_path_irq_1(
-					qcmd->vfePingPongStatus);
-			}
-
-			if (qcmd->vfeInterruptStatus0 &
-				VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE2_MASK) {
-				CDBG("Image composite done 2 irq occured.\n");
-				vfe31_process_output_path_irq_2(
-					qcmd->vfePingPongStatus);
-			}
-
-			/* then process stats irq. */
-			if (vfe31_ctrl->stats_comp) {
-				/* process stats comb interrupt. */
-				if (qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_COMPOSIT_MASK) {
-					CDBG("Stats composite irq occured.\n");
-					vfe31_process_stats_irq(
-						&qcmd->vfeInterruptStatus0);
-				}
-			} else {
-				/* process individual stats interrupt. */
-				if (qcmd->vfeInterruptStatus0 &
-						VFE_COM_STATUS) {
-					CDBG("VFE stats occured.\n");
-					vfe31_process_stats_irq(
-						&qcmd->vfeInterruptStatus0);
-				}
-				if (qcmd->vfeInterruptStatus0 &
-						VFE_IRQ_STATUS0_SYNC_TIMER0) {
-					CDBG("SYNC_TIMER 0 irq occured.\n");
-					vfe31_send_msg_no_payload(
-						MSG_ID_SYNC_TIMER0_DONE);
-				}
-				if (qcmd->vfeInterruptStatus0 &
-						VFE_IRQ_STATUS0_SYNC_TIMER1) {
-					CDBG("SYNC_TIMER 1 irq occured.\n");
-					vfe31_send_msg_no_payload(
-						MSG_ID_SYNC_TIMER1_DONE);
-				}
-				if (qcmd->vfeInterruptStatus0 &
-						VFE_IRQ_STATUS0_SYNC_TIMER2) {
-					CDBG("SYNC_TIMER 2 irq occured.\n");
-					vfe31_send_msg_no_payload(
-						MSG_ID_SYNC_TIMER2_DONE);
-				}
-			}
-		}
-		if (qcmd->vfeInterruptStatus0 &
-				VFE_IRQ_STATUS0_CAMIF_SOF_MASK) {
-			CDBG("irq	camifSofIrq\n");
-			vfe31_process_camif_sof_irq();
-		}
-		kfree(qcmd);
-	}
-	CDBG("=== vfe31_do_tasklet end === \n");
-}
-
-DECLARE_TASKLET(vfe31_tasklet, vfe31_do_tasklet, 0);
-
-static irqreturn_t vfe31_parse_irq(int irq_num, void *data)
-{
-	unsigned long flags;
-	struct vfe31_irq_status irq;
-	struct vfe31_isr_queue_cmd *qcmd;
-	uint32_t *val;
-	CDBG("vfe_parse_irq\n");
-	memset(&irq, 0, sizeof(struct vfe31_irq_status));
-
-	val = (uint32_t *)(vfe31_ctrl->vfebase + VFE_IRQ_STATUS_0);
-	irq.vfeIrqStatus0 = msm_camera_io_r(val);
-
-	val = (uint32_t *)(vfe31_ctrl->vfebase + VFE_IRQ_STATUS_1);
-	irq.vfeIrqStatus1 = msm_camera_io_r(val);
-
-	if (irq.vfeIrqStatus1 & VFE_IMASK_AXI_HALT) {
-		msm_camera_io_w(VFE_IMASK_RESET,
-			vfe31_ctrl->vfebase + VFE_IRQ_MASK_1);
-		msm_camera_io_w_mb(AXI_HALT_CLEAR,
-			vfe31_ctrl->vfebase + VFE_AXI_CMD);
-	}
-
-	val = (uint32_t *)(vfe31_ctrl->vfebase + VFE_CAMIF_STATUS);
-	irq.camifStatus = msm_camera_io_r(val);
-	CDBG("camifStatus  = 0x%x\n", irq.camifStatus);
-
-	val = (uint32_t *)(vfe31_ctrl->vfebase + VFE_BUS_PING_PONG_STATUS);
-	irq.vfePingPongStatus = msm_camera_io_r(val);
-
-	/* clear the pending interrupt of the same kind.*/
-	msm_camera_io_w(irq.vfeIrqStatus0,
-		vfe31_ctrl->vfebase + VFE_IRQ_CLEAR_0);
-	msm_camera_io_w(irq.vfeIrqStatus1,
-		vfe31_ctrl->vfebase + VFE_IRQ_CLEAR_1);
-
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(1, vfe31_ctrl->vfebase + VFE_IRQ_CMD);
-
-	if ((irq.vfeIrqStatus0 == 0) && (irq.vfeIrqStatus1 == 0)) {
-		CDBG("vfe_parse_irq: vfeIrqStatus0 & 1 are both 0!\n");
-		return IRQ_HANDLED;
-	}
-
-	qcmd = kzalloc(sizeof(struct vfe31_isr_queue_cmd),
-		GFP_ATOMIC);
-	if (!qcmd) {
-		pr_err("vfe_parse_irq: qcmd malloc failed!\n");
-		return IRQ_HANDLED;
-	}
-
-	if (atomic_read(&vfe31_ctrl->stop_ack_pending)) {
-		irq.vfeIrqStatus0 &= VFE_IMASK_WHILE_STOPPING_0;
-		irq.vfeIrqStatus1 &= vfe31_ctrl->while_stopping_mask;
-	}
-
-	spin_lock_irqsave(&vfe31_ctrl->xbar_lock, flags);
-	if ((irq.vfeIrqStatus0 &
-		VFE_IRQ_STATUS0_CAMIF_EOF_MASK) &&
-		vfe31_ctrl->xbar_update_pending) {
-		CDBG("irq camifEofIrq\n");
-		msm_camera_io_memcpy(vfe31_ctrl->vfebase + V31_XBAR_CFG_OFF,
-			(void *)vfe31_ctrl->xbar_cfg, V31_XBAR_CFG_LEN);
-		vfe31_ctrl->xbar_update_pending = 0;
-	}
-	spin_unlock_irqrestore(&vfe31_ctrl->xbar_lock, flags);
-	CDBG("vfe_parse_irq: Irq_status0 = 0x%x, Irq_status1 = 0x%x.\n",
-		irq.vfeIrqStatus0, irq.vfeIrqStatus1);
-
-	qcmd->vfeInterruptStatus0 = irq.vfeIrqStatus0;
-	qcmd->vfeInterruptStatus1 = irq.vfeIrqStatus1;
-	qcmd->vfePingPongStatus = irq.vfePingPongStatus;
-
-	spin_lock_irqsave(&vfe31_ctrl->tasklet_lock, flags);
-	list_add_tail(&qcmd->list, &vfe31_ctrl->tasklet_q);
-
-	atomic_add(1, &irq_cnt);
-	spin_unlock_irqrestore(&vfe31_ctrl->tasklet_lock, flags);
-	tasklet_schedule(&vfe31_tasklet);
-	return IRQ_HANDLED;
-}
-
-static void vfe31_release(struct platform_device *pdev)
-{
-	struct resource	*vfemem, *vfeio;
-
-	vfe31_reset_free_buf_queue_all();
-	CDBG("%s, free_irq\n", __func__);
-	free_irq(vfe31_ctrl->vfeirq, 0);
-	tasklet_kill(&vfe31_tasklet);
-
-	if (atomic_read(&irq_cnt))
-		pr_warning("%s, Warning IRQ Count not ZERO\n", __func__);
-
-	vfemem = vfe31_ctrl->vfemem;
-	vfeio  = vfe31_ctrl->vfeio;
-
-	msm_vpe_release();
-
-	kfree(vfe31_ctrl->extdata);
-	iounmap(vfe31_ctrl->vfebase);
-	kfree(vfe31_ctrl);
-	vfe31_ctrl = NULL;
-	release_mem_region(vfemem->start, (vfemem->end - vfemem->start) + 1);
-	CDBG("%s, msm_camio_disable\n", __func__);
-	msm_camio_disable(pdev);
-	msm_camio_set_perf_lvl(S_EXIT);
-
-	vfe_syncdata = NULL;
-}
-
-static int vfe31_resource_init(struct msm_vfe_callback *presp,
-	struct platform_device *pdev, void *sdata)
-{
-	struct resource	*vfemem, *vfeirq, *vfeio;
-	int rc;
-	struct msm_camera_sensor_info *s_info;
-	s_info = pdev->dev.platform_data;
-
-	pdev->resource = s_info->resource;
-	pdev->num_resources = s_info->num_resources;
-
-	vfemem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!vfemem) {
-		pr_err("%s: no mem resource?\n", __func__);
-		return -ENODEV;
-	}
-
-	vfeirq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	if (!vfeirq) {
-		pr_err("%s: no irq resource?\n", __func__);
-		return -ENODEV;
-	}
-
-	vfeio = request_mem_region(vfemem->start,
-		resource_size(vfemem), pdev->name);
-	if (!vfeio) {
-		pr_err("%s: VFE region already claimed\n", __func__);
-		return -EBUSY;
-	}
-
-	vfe31_ctrl = kzalloc(sizeof(struct vfe31_ctrl_type), GFP_KERNEL);
-	if (!vfe31_ctrl) {
-		rc = -ENOMEM;
-		goto cmd_init_failed1;
-	}
-
-	vfe31_ctrl->vfeirq = vfeirq->start;
-
-	vfe31_ctrl->vfebase =
-		ioremap(vfemem->start, (vfemem->end - vfemem->start) + 1);
-	if (!vfe31_ctrl->vfebase) {
-		rc = -ENOMEM;
-		pr_err("%s: vfe ioremap failed\n", __func__);
-		goto cmd_init_failed2;
-	}
-
-	if (presp && presp->vfe_resp)
-		vfe31_ctrl->resp = presp;
-	else {
-		rc = -EINVAL;
-		goto cmd_init_failed3;
-	}
-
-	vfe31_ctrl->extdata =
-		kmalloc(sizeof(struct vfe31_frame_extra), GFP_KERNEL);
-	if (!vfe31_ctrl->extdata) {
-		rc = -ENOMEM;
-		goto cmd_init_failed3;
-	}
-
-	vfe31_ctrl->extlen = sizeof(struct vfe31_frame_extra);
-
-	spin_lock_init(&vfe31_ctrl->io_lock);
-	spin_lock_init(&vfe31_ctrl->update_ack_lock);
-	spin_lock_init(&vfe31_ctrl->tasklet_lock);
-	spin_lock_init(&vfe31_ctrl->xbar_lock);
-
-	INIT_LIST_HEAD(&vfe31_ctrl->tasklet_q);
-	vfe31_init_free_buf_queue();
-
-	vfe31_ctrl->syncdata = sdata;
-	vfe31_ctrl->vfemem = vfemem;
-	vfe31_ctrl->vfeio  = vfeio;
-	vfe31_ctrl->update_gamma = false;
-	vfe31_ctrl->update_luma = false;
-	vfe31_ctrl->s_info = s_info;
-	vfe31_ctrl->stats_comp = 0;
-	vfe31_ctrl->hfr_mode = HFR_MODE_OFF;
-	return 0;
-
-cmd_init_failed3:
-	free_irq(vfe31_ctrl->vfeirq, 0);
-	iounmap(vfe31_ctrl->vfebase);
-cmd_init_failed2:
-	kfree(vfe31_ctrl);
-cmd_init_failed1:
-	release_mem_region(vfemem->start, (vfemem->end - vfemem->start) + 1);
-	return rc;
-}
-
-static int vfe31_init(struct msm_vfe_callback *presp,
-	struct platform_device *pdev)
-{
-	int rc = 0;
-	struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data;
-	struct msm_camera_device_platform_data *camdev = sinfo->pdata;
-
-	camio_clk = camdev->ioclk;
-
-	rc = vfe31_resource_init(presp, pdev, vfe_syncdata);
-	if (rc < 0)
-		return rc;
-	/* Bring up all the required GPIOs and Clocks */
-	rc = msm_camio_enable(pdev);
-	msm_camio_set_perf_lvl(S_INIT);
-	if (msm_vpe_open() < 0)
-		CDBG("%s: vpe_open failed\n", __func__);
-
-	/* TO DO: Need to release the VFE resources */
-	rc = request_irq(vfe31_ctrl->vfeirq, vfe31_parse_irq,
-			IRQF_TRIGGER_RISING, "vfe", 0);
-
-	return rc;
-}
-
-void msm_camvfe_fn_init(struct msm_camvfe_fn *fptr, void *data)
-{
-	fptr->vfe_init    = vfe31_init;
-	fptr->vfe_enable  = vfe31_enable;
-	fptr->vfe_config  = vfe31_config;
-	fptr->vfe_disable = vfe31_disable;
-	fptr->vfe_release = vfe31_release;
-	fptr->vfe_stop = vfe31_stop;
-	vfe_syncdata = data;
-}
-
-void msm_camvpe_fn_init(struct msm_camvpe_fn *fptr, void *data)
-{
-	fptr->vpe_reg		= msm_vpe_reg;
-	fptr->send_frame_to_vpe	= msm_send_frame_to_vpe;
-	fptr->vpe_config	= msm_vpe_config;
-	fptr->vpe_cfg_update	= msm_vpe_cfg_update;
-	fptr->dis		= &(vpe_ctrl->dis_en);
-	fptr->vpe_cfg_offset = msm_vpe_offset_update;
-	vpe_ctrl->syncdata = data;
-}
diff --git a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe31.h b/drivers/media/platform/msm/camera_v1/vfe/msm_vfe31.h
deleted file mode 100644
index 4e1a8d4..0000000
--- a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe31.h
+++ /dev/null
@@ -1,1119 +0,0 @@
-/* Copyright (c) 2010-2012, The Linux Foundation. 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.
- *
- */
-
-#ifndef __MSM_VFE31_H__
-#define __MSM_VFE31_H__
-
-#define TRUE  1
-#define FALSE 0
-
-/* at start of camif,  bit 1:0 = 0x01:enable
- * image data capture at frame boundary. */
-#define CAMIF_COMMAND_START  0x00000005
-
-/* bit 2= 0x1:clear the CAMIF_STATUS register
- * value. */
-#define CAMIF_COMMAND_CLEAR  0x00000004
-
-/* at stop of vfe pipeline, for now it is assumed
- * that camif will stop at any time. Bit 1:0 = 0x10:
- * disable image data capture immediately. */
-#define CAMIF_COMMAND_STOP_IMMEDIATELY  0x00000002
-
-/* at stop of vfe pipeline, for now it is assumed
- * that camif will stop at any time. Bit 1:0 = 0x00:
- * disable image data capture at frame boundary */
-#define CAMIF_COMMAND_STOP_AT_FRAME_BOUNDARY  0x00000000
-
-/* to halt axi bridge */
-#define AXI_HALT  0x00000001
-
-/* clear the halt bit. */
-#define AXI_HALT_CLEAR  0x00000000
-
-/* clear axi_halt_irq */
-#define MASK_AXI_HALT_IRQ	0xFF7FFFFF
-
-/* reset the pipeline when stop command is issued.
- * (without reset the register.) bit 26-31 = 0,
- * domain reset, bit 0-9 = 1 for module reset, except
- * register module. */
-#define VFE_RESET_UPON_STOP_CMD  0x000003ef
-
-/* reset the pipeline when reset command.
- * bit 26-31 = 0, domain reset, bit 0-9 = 1 for module reset. */
-#define VFE_RESET_UPON_RESET_CMD  0x000003ff
-
-/* bit 5 is for axi status idle or busy.
- * 1 =  halted,  0 = busy */
-#define AXI_STATUS_BUSY_MASK 0x00000020
-
-/* bit 0 & bit 1 = 1, both y and cbcr irqs need to be present
- * for frame done interrupt */
-#define VFE_COMP_IRQ_BOTH_Y_CBCR 3
-
-/* bit 1 = 1, only cbcr irq triggers frame done interrupt */
-#define VFE_COMP_IRQ_CBCR_ONLY 2
-
-/* bit 0 = 1, only y irq triggers frame done interrupt */
-#define VFE_COMP_IRQ_Y_ONLY 1
-
-/* bit 0 = 1, PM go;   bit1 = 1, PM stop */
-#define VFE_PERFORMANCE_MONITOR_GO   0x00000001
-#define VFE_PERFORMANCE_MONITOR_STOP 0x00000002
-
-/* bit 0 = 1, test gen go;   bit1 = 1, test gen stop */
-#define VFE_TEST_GEN_GO   0x00000001
-#define VFE_TEST_GEN_STOP 0x00000002
-
-/* the chroma is assumed to be interpolated between
- * the luma samples.  JPEG 4:2:2 */
-#define VFE_CHROMA_UPSAMPLE_INTERPOLATED 0
-
-/* constants for irq registers */
-#define VFE_DISABLE_ALL_IRQS 0
-/* bit =1 is to clear the corresponding bit in VFE_IRQ_STATUS.  */
-#define VFE_CLEAR_ALL_IRQS   0xffffffff
-
-#define VFE_IRQ_STATUS0_CAMIF_SOF_MASK            0x00000001
-#define VFE_IRQ_STATUS0_CAMIF_EOF_MASK            0x00000004
-#define VFE_IRQ_STATUS0_REG_UPDATE_MASK           0x00000020
-#define VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE0_MASK 0x00200000
-#define VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE1_MASK 0x00400000
-#define VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE2_MASK 0x00800000
-#define VFE_IRQ_STATUS1_RESET_AXI_HALT_ACK_MASK   0x00800000
-#define VFE_IRQ_STATUS0_STATS_COMPOSIT_MASK       0x01000000
-
-#define VFE_IRQ_STATUS0_STATS_AEC     0x2000  /* bit 13 */
-#define VFE_IRQ_STATUS0_STATS_AF      0x4000  /* bit 14 */
-#define VFE_IRQ_STATUS0_STATS_AWB     0x8000  /* bit 15 */
-#define VFE_IRQ_STATUS0_STATS_RS      0x10000  /* bit 16 */
-#define VFE_IRQ_STATUS0_STATS_CS      0x20000  /* bit 17 */
-#define VFE_IRQ_STATUS0_STATS_IHIST   0x40000  /* bit 18 */
-
-#define VFE_IRQ_STATUS0_SYNC_TIMER0   0x2000000  /* bit 25 */
-#define VFE_IRQ_STATUS0_SYNC_TIMER1   0x4000000  /* bit 26 */
-#define VFE_IRQ_STATUS0_SYNC_TIMER2   0x8000000  /* bit 27 */
-#define VFE_IRQ_STATUS0_ASYNC_TIMER0  0x10000000  /* bit 28 */
-#define VFE_IRQ_STATUS0_ASYNC_TIMER1  0x20000000  /* bit 29 */
-#define VFE_IRQ_STATUS0_ASYNC_TIMER2  0x40000000  /* bit 30 */
-#define VFE_IRQ_STATUS0_ASYNC_TIMER3  0x80000000  /* bit 31 */
-
-/* imask for while waiting for stop ack,  driver has already
- * requested stop, waiting for reset irq, and async timer irq.
- * For irq_status_0, bit 28-31 are for async timer. For
- * irq_status_1, bit 22 for reset irq, bit 23 for axi_halt_ack
-   irq */
-#define VFE_IMASK_WHILE_STOPPING_0  0xF0000000
-#define VFE_IMASK_WHILE_STOPPING_1  0x00C00000
-#define VFE_IMASK_RESET             0x00400000
-#define VFE_IMASK_AXI_HALT          0x00800000
-
-
-/* no error irq in mask 0 */
-#define VFE_IMASK_ERROR_ONLY_0  0x0
-/* when normal case, don't want to block error status. */
-/* bit 0-21 are error irq bits */
-#define VFE_IMASK_ERROR_ONLY_1  0x003fffff
-
-/* For BPC bit 0,bit 12-17 and bit 26 -20 are set to zero and other's 1 */
-#define BPC_MASK 0xF80C0FFE
-
-/* For BPC bit 1 and 2 are set to zero and other's 1 */
-#define ABF_MASK 0xFFFFFFF9
-
-/* For MCE enable bit 28 set to zero and other's 1 */
-#define MCE_EN_MASK 0xEFFFFFFF
-
-/* For MCE Q_K bit 28 to 31 set to zero and other's 1 */
-#define MCE_Q_K_MASK 0x0FFFFFFF
-
-#define AWB_ENABLE_MASK 0x00000080     /* bit 7 */
-#define AF_ENABLE_MASK 0x00000040      /* bit 6 */
-#define AE_ENABLE_MASK 0x00000020      /* bit 5 */
-#define IHIST_ENABLE_MASK 0x00008000   /* bit 15 */
-#define RS_ENABLE_MASK 0x00000100      /* bit 8  */
-#define CS_ENABLE_MASK 0x00000200      /* bit 9  */
-#define RS_CS_ENABLE_MASK 0x00000300   /* bit 8,9  */
-#define STATS_ENABLE_MASK 0x000483E0   /* bit 18,15,9,8,7,6,5*/
-
-#define VFE_REG_UPDATE_TRIGGER           1
-#define VFE_PM_BUF_MAX_CNT_MASK          0xFF
-#define VFE_DMI_CFG_DEFAULT              0x00000100
-#define LENS_ROLL_OFF_DELTA_TABLE_OFFSET 32
-#define VFE_AE_PINGPONG_STATUS_BIT       0x80
-#define VFE_AF_PINGPONG_STATUS_BIT       0x100
-#define VFE_AWB_PINGPONG_STATUS_BIT      0x200
-#define PINGPONG_LOWER                   0x7
-
-#define HFR_MODE_OFF 1
-
-enum VFE31_DMI_RAM_SEL {
-	 NO_MEM_SELECTED          = 0,
-	 ROLLOFF_RAM              = 0x1,
-	 RGBLUT_RAM_CH0_BANK0     = 0x2,
-	 RGBLUT_RAM_CH0_BANK1     = 0x3,
-	 RGBLUT_RAM_CH1_BANK0     = 0x4,
-	 RGBLUT_RAM_CH1_BANK1     = 0x5,
-	 RGBLUT_RAM_CH2_BANK0     = 0x6,
-	 RGBLUT_RAM_CH2_BANK1     = 0x7,
-	 STATS_HIST_RAM           = 0x8,
-	 RGBLUT_CHX_BANK0         = 0x9,
-	 RGBLUT_CHX_BANK1         = 0xa,
-	 LUMA_ADAPT_LUT_RAM_BANK0 = 0xb,
-	 LUMA_ADAPT_LUT_RAM_BANK1 = 0xc
-};
-
-enum  VFE_STATE {
-	VFE_STATE_IDLE,
-	VFE_STATE_ACTIVE
-};
-
-enum  vfe_recording_state {
-	VFE_REC_STATE_IDLE,
-	VFE_REC_STATE_START_REQUESTED,
-	VFE_REC_STATE_STARTED,
-	VFE_REC_STATE_STOP_REQUESTED,
-	VFE_REC_STATE_STOPPED,
-};
-
-#define V31_DUMMY_0               0
-#define V31_SET_CLK               1
-#define V31_RESET                 2
-#define V31_START                 3
-#define V31_TEST_GEN_START        4
-#define V31_OPERATION_CFG         5
-#define V31_AXI_OUT_CFG           6
-#define V31_CAMIF_CFG             7
-#define V31_AXI_INPUT_CFG         8
-#define V31_BLACK_LEVEL_CFG       9
-#define V31_ROLL_OFF_CFG          10
-#define V31_DEMUX_CFG             11
-#define V31_DEMOSAIC_0_CFG        12 /* general */
-#define V31_DEMOSAIC_1_CFG        13 /* ABF     */
-#define V31_DEMOSAIC_2_CFG        14 /* BPC     */
-#define V31_FOV_CFG               15
-#define V31_MAIN_SCALER_CFG       16
-#define V31_WB_CFG                17
-#define V31_COLOR_COR_CFG         18
-#define V31_RGB_G_CFG             19
-#define V31_LA_CFG                20
-#define V31_CHROMA_EN_CFG         21
-#define V31_CHROMA_SUP_CFG        22
-#define V31_MCE_CFG               23
-#define V31_SK_ENHAN_CFG          24
-#define V31_ASF_CFG               25
-#define V31_S2Y_CFG               26
-#define V31_S2CbCr_CFG            27
-#define V31_CHROMA_SUBS_CFG       28
-#define V31_OUT_CLAMP_CFG         29
-#define V31_FRAME_SKIP_CFG        30
-#define V31_DUMMY_1               31
-#define V31_DUMMY_2               32
-#define V31_DUMMY_3               33
-#define V31_UPDATE                34
-#define V31_BL_LVL_UPDATE         35
-#define V31_DEMUX_UPDATE          36
-#define V31_DEMOSAIC_1_UPDATE     37 /* BPC */
-#define V31_DEMOSAIC_2_UPDATE     38 /* ABF */
-#define V31_FOV_UPDATE            39
-#define V31_MAIN_SCALER_UPDATE    40
-#define V31_WB_UPDATE             41
-#define V31_COLOR_COR_UPDATE      42
-#define V31_RGB_G_UPDATE          43
-#define V31_LA_UPDATE             44
-#define V31_CHROMA_EN_UPDATE      45
-#define V31_CHROMA_SUP_UPDATE     46
-#define V31_MCE_UPDATE            47
-#define V31_SK_ENHAN_UPDATE       48
-#define V31_S2CbCr_UPDATE         49
-#define V31_S2Y_UPDATE            50
-#define V31_ASF_UPDATE            51
-#define V31_FRAME_SKIP_UPDATE     52
-#define V31_CAMIF_FRAME_UPDATE    53
-#define V31_STATS_AF_UPDATE       54
-#define V31_STATS_AE_UPDATE       55
-#define V31_STATS_AWB_UPDATE      56
-#define V31_STATS_RS_UPDATE       57
-#define V31_STATS_CS_UPDATE       58
-#define V31_STATS_SKIN_UPDATE     59
-#define V31_STATS_IHIST_UPDATE    60
-#define V31_DUMMY_4               61
-#define V31_EPOCH1_ACK            62
-#define V31_EPOCH2_ACK            63
-#define V31_START_RECORDING       64
-#define V31_STOP_RECORDING        65
-#define V31_DUMMY_5               66
-#define V31_DUMMY_6               67
-#define V31_CAPTURE               68
-#define V31_DUMMY_7               69
-#define V31_STOP                  70
-#define V31_GET_HW_VERSION        71
-#define V31_GET_FRAME_SKIP_COUNTS 72
-#define V31_OUTPUT1_BUFFER_ENQ    73
-#define V31_OUTPUT2_BUFFER_ENQ    74
-#define V31_OUTPUT3_BUFFER_ENQ    75
-#define V31_JPEG_OUT_BUF_ENQ      76
-#define V31_RAW_OUT_BUF_ENQ       77
-#define V31_RAW_IN_BUF_ENQ        78
-#define V31_STATS_AF_ENQ          79
-#define V31_STATS_AE_ENQ          80
-#define V31_STATS_AWB_ENQ         81
-#define V31_STATS_RS_ENQ          82
-#define V31_STATS_CS_ENQ          83
-#define V31_STATS_SKIN_ENQ        84
-#define V31_STATS_IHIST_ENQ       85
-#define V31_DUMMY_8               86
-#define V31_JPEG_ENC_CFG          87
-#define V31_DUMMY_9               88
-#define V31_STATS_AF_START        89
-#define V31_STATS_AF_STOP         90
-#define V31_STATS_AE_START        91
-#define V31_STATS_AE_STOP         92
-#define V31_STATS_AWB_START       93
-#define V31_STATS_AWB_STOP        94
-#define V31_STATS_RS_START        95
-#define V31_STATS_RS_STOP         96
-#define V31_STATS_CS_START        97
-#define V31_STATS_CS_STOP         98
-#define V31_STATS_SKIN_START      99
-#define V31_STATS_SKIN_STOP       100
-#define V31_STATS_IHIST_START     101
-#define V31_STATS_IHIST_STOP      102
-#define V31_DUMMY_10              103
-#define V31_SYNC_TIMER_SETTING    104
-#define V31_ASYNC_TIMER_SETTING   105
-#define V31_LIVESHOT              106
-#define V31_ZSL                   107
-#define V31_STEREOCAM             108
-#define V31_LA_SETUP              109
-#define V31_XBAR_CFG              110
-#define V31_EZTUNE_CFG            111
-
-#define V31_CAMIF_OFF             0x000001E4
-#define V31_CAMIF_LEN             32
-
-#define V31_DEMUX_OFF             0x00000284
-#define V31_DEMUX_LEN             20
-
-#define V31_DEMOSAIC_0_OFF        0x00000298
-#define V31_DEMOSAIC_0_LEN        4
-/* ABF     */
-#define V31_DEMOSAIC_1_OFF        0x000002A4
-#define V31_DEMOSAIC_1_LEN        180
-/* BPC     */
-#define V31_DEMOSAIC_2_OFF        0x0000029C
-#define V31_DEMOSAIC_2_LEN        8
-
-/* gamma VFE_LUT_BANK_SEL*/
-#define V31_GAMMA_CFG_OFF         0x000003BC
-#define V31_LUMA_CFG_OFF          0x000003C0
-
-#define V31_OUT_CLAMP_OFF         0x00000524
-#define V31_OUT_CLAMP_LEN         8
-
-#define V31_OPERATION_CFG_LEN     32
-
-#define V31_AXI_OUT_OFF           0x00000038
-#define V31_AXI_OUT_LEN           220
-#define V31_AXI_CH_INF_LEN        32
-#define V31_AXI_CFG_LEN           47
-
-#define V31_FRAME_SKIP_OFF        0x00000504
-#define V31_FRAME_SKIP_LEN        32
-
-#define V31_CHROMA_SUBS_OFF       0x000004F8
-#define V31_CHROMA_SUBS_LEN       12
-
-#define V31_FOV_OFF           0x00000360
-#define V31_FOV_LEN           8
-
-#define V31_MAIN_SCALER_OFF 0x00000368
-#define V31_MAIN_SCALER_LEN 28
-
-#define V31_S2Y_OFF 0x000004D0
-#define V31_S2Y_LEN 20
-
-#define V31_S2CbCr_OFF 0x000004E4
-#define V31_S2CbCr_LEN 20
-
-#define V31_CHROMA_EN_OFF 0x000003C4
-#define V31_CHROMA_EN_LEN 36
-
-#define V31_SYNC_TIMER_OFF      0x0000020C
-#define V31_SYNC_TIMER_POLARITY_OFF 0x00000234
-#define V31_TIMER_SELECT_OFF        0x0000025C
-#define V31_SYNC_TIMER_LEN 28
-
-#define V31_ASYNC_TIMER_OFF 0x00000238
-#define V31_ASYNC_TIMER_LEN 28
-
-#define V31_BLACK_LEVEL_OFF 0x00000264
-#define V31_BLACK_LEVEL_LEN 16
-
-#define V31_ROLL_OFF_CFG_OFF 0x00000274
-#define V31_ROLL_OFF_CFG_LEN 16
-
-#define V31_COLOR_COR_OFF 0x00000388
-#define V31_COLOR_COR_LEN 52
-
-#define V31_WB_OFF 0x00000384
-#define V31_WB_LEN 4
-
-#define V31_RGB_G_OFF 0x000003BC
-#define V31_RGB_G_LEN 4
-
-#define V31_LA_OFF 0x000003C0
-#define V31_LA_LEN 4
-
-#define V31_SCE_OFF 0x00000418
-#define V31_SCE_LEN 136
-
-#define V31_CHROMA_SUP_OFF 0x000003E8
-#define V31_CHROMA_SUP_LEN 12
-
-#define V31_MCE_OFF 0x000003F4
-#define V31_MCE_LEN 36
-#define V31_STATS_AF_OFF 0x0000053c
-#define V31_STATS_AF_LEN 16
-
-#define V31_STATS_AE_OFF 0x00000534
-#define V31_STATS_AE_LEN 8
-
-#define V31_STATS_AWB_OFF 0x0000054c
-#define V31_STATS_AWB_LEN 32
-
-#define V31_STATS_IHIST_OFF 0x0000057c
-#define V31_STATS_IHIST_LEN 8
-
-#define V31_STATS_RS_OFF 0x0000056c
-#define V31_STATS_RS_LEN 8
-
-#define V31_STATS_CS_OFF 0x00000574
-#define V31_STATS_CS_LEN 8
-
-#define V31_XBAR_CFG_OFF 0x00000040
-#define V31_XBAR_CFG_LEN 8
-
-#define V31_EZTUNE_CFG_OFF 0x00000010
-#define V31_EZTUNE_CFG_LEN 4
-
-#define V31_ASF_OFF 0x000004A0
-#define V31_ASF_LEN 48
-#define V31_ASF_UPDATE_LEN 36
-
-#define V31_CAPTURE_LEN 4
-
-struct vfe_cmd_hw_version {
-	uint32_t minorVersion;
-	uint32_t majorVersion;
-	uint32_t coreVersion;
-};
-
-enum VFE_AXI_OUTPUT_MODE {
-	VFE_AXI_OUTPUT_MODE_Output1,
-	VFE_AXI_OUTPUT_MODE_Output2,
-	VFE_AXI_OUTPUT_MODE_Output1AndOutput2,
-	VFE_AXI_OUTPUT_MODE_CAMIFToAXIViaOutput2,
-	VFE_AXI_OUTPUT_MODE_Output2AndCAMIFToAXIViaOutput1,
-	VFE_AXI_OUTPUT_MODE_Output1AndCAMIFToAXIViaOutput2,
-	VFE_AXI_LAST_OUTPUT_MODE_ENUM
-};
-
-enum VFE_RAW_WR_PATH_SEL {
-	VFE_RAW_OUTPUT_DISABLED,
-	VFE_RAW_OUTPUT_ENC_CBCR_PATH,
-	VFE_RAW_OUTPUT_VIEW_CBCR_PATH,
-	VFE_RAW_OUTPUT_PATH_INVALID
-};
-
-
-#define VFE_AXI_OUTPUT_BURST_LENGTH     4
-#define VFE_MAX_NUM_FRAGMENTS_PER_FRAME 4
-#define VFE_AXI_OUTPUT_CFG_FRAME_COUNT  3
-
-struct vfe_cmds_per_write_master {
-	uint16_t imageWidth;
-	uint16_t imageHeight;
-	uint16_t outRowCount;
-	uint16_t outRowIncrement;
-	uint32_t outFragments[VFE_AXI_OUTPUT_CFG_FRAME_COUNT]
-		[VFE_MAX_NUM_FRAGMENTS_PER_FRAME];
-};
-
-struct vfe_cmds_axi_per_output_path {
-	uint8_t fragmentCount;
-	struct vfe_cmds_per_write_master firstWM;
-	struct vfe_cmds_per_write_master secondWM;
-};
-
-enum VFE_AXI_BURST_LENGTH {
-	VFE_AXI_BURST_LENGTH_IS_2  = 2,
-	VFE_AXI_BURST_LENGTH_IS_4  = 4,
-	VFE_AXI_BURST_LENGTH_IS_8  = 8,
-	VFE_AXI_BURST_LENGTH_IS_16 = 16
-};
-
-
-struct vfe_cmd_fov_crop_config {
-	uint8_t enable;
-	uint16_t firstPixel;
-	uint16_t lastPixel;
-	uint16_t firstLine;
-	uint16_t lastLine;
-};
-
-struct vfe_cmds_main_scaler_stripe_init {
-	uint16_t MNCounterInit;
-	uint16_t phaseInit;
-};
-
-struct vfe_cmds_scaler_one_dimension {
-	uint8_t  enable;
-	uint16_t inputSize;
-	uint16_t outputSize;
-	uint32_t phaseMultiplicationFactor;
-	uint8_t  interpolationResolution;
-};
-
-struct vfe_cmd_main_scaler_config {
-	uint8_t enable;
-	struct vfe_cmds_scaler_one_dimension    hconfig;
-	struct vfe_cmds_scaler_one_dimension    vconfig;
-	struct vfe_cmds_main_scaler_stripe_init MNInitH;
-	struct vfe_cmds_main_scaler_stripe_init MNInitV;
-};
-
-struct vfe_cmd_scaler2_config {
-	uint8_t enable;
-	struct vfe_cmds_scaler_one_dimension hconfig;
-	struct vfe_cmds_scaler_one_dimension vconfig;
-};
-
-
-struct vfe_cmd_frame_skip_update {
-	uint32_t output1Pattern;
-	uint32_t output2Pattern;
-};
-
-struct vfe_cmd_output_clamp_config {
-	uint8_t minCh0;
-	uint8_t minCh1;
-	uint8_t minCh2;
-	uint8_t maxCh0;
-	uint8_t maxCh1;
-	uint8_t maxCh2;
-};
-
-struct vfe_cmd_chroma_subsample_config {
-	uint8_t enable;
-	uint8_t cropEnable;
-	uint8_t vsubSampleEnable;
-	uint8_t hsubSampleEnable;
-	uint8_t vCosited;
-	uint8_t hCosited;
-	uint8_t vCositedPhase;
-	uint8_t hCositedPhase;
-	uint16_t cropWidthFirstPixel;
-	uint16_t cropWidthLastPixel;
-	uint16_t cropHeightFirstLine;
-	uint16_t cropHeightLastLine;
-};
-
-enum VFE_START_INPUT_SOURCE {
-	VFE_START_INPUT_SOURCE_CAMIF,
-	VFE_START_INPUT_SOURCE_TESTGEN,
-	VFE_START_INPUT_SOURCE_AXI,
-	VFE_START_INPUT_SOURCE_INVALID
-};
-
-enum VFE_START_PIXEL_PATTERN {
-	VFE_BAYER_RGRGRG,
-	VFE_BAYER_GRGRGR,
-	VFE_BAYER_BGBGBG,
-	VFE_BAYER_GBGBGB,
-	VFE_YUV_YCbYCr,
-	VFE_YUV_YCrYCb,
-	VFE_YUV_CbYCrY,
-	VFE_YUV_CrYCbY
-};
-
-enum VFE_BUS_RD_INPUT_PIXEL_PATTERN {
-	VFE_BAYER_RAW,
-	VFE_YUV_INTERLEAVED,
-	VFE_YUV_PSEUDO_PLANAR_Y,
-	VFE_YUV_PSEUDO_PLANAR_CBCR
-};
-
-enum VFE_YUV_INPUT_COSITING_MODE {
-	VFE_YUV_COSITED,
-	VFE_YUV_INTERPOLATED
-};
-
-
-/* 13*1  */
-#define VFE31_ROLL_OFF_INIT_TABLE_SIZE  13
-/* 13*16 */
-#define VFE31_ROLL_OFF_DELTA_TABLE_SIZE 208
-
-#define VFE31_GAMMA_NUM_ENTRIES  64
-
-#define VFE31_LA_TABLE_LENGTH    64
-
-#define VFE31_HIST_TABLE_LENGTH  256
-
-struct vfe_cmds_demosaic_abf {
-	uint8_t   enable;
-	uint8_t   forceOn;
-	uint8_t   shift;
-	uint16_t  lpThreshold;
-	uint16_t  max;
-	uint16_t  min;
-	uint8_t   ratio;
-};
-
-struct vfe_cmds_demosaic_bpc {
-	uint8_t   enable;
-	uint16_t  fmaxThreshold;
-	uint16_t  fminThreshold;
-	uint16_t  redDiffThreshold;
-	uint16_t  blueDiffThreshold;
-	uint16_t  greenDiffThreshold;
-};
-
-struct vfe_cmd_demosaic_config {
-	uint8_t   enable;
-	uint8_t   slopeShift;
-	struct vfe_cmds_demosaic_abf abfConfig;
-	struct vfe_cmds_demosaic_bpc bpcConfig;
-};
-
-struct vfe_cmd_demosaic_bpc_update {
-	struct vfe_cmds_demosaic_bpc bpcUpdate;
-};
-
-struct vfe_cmd_demosaic_abf_update {
-	struct vfe_cmds_demosaic_abf abfUpdate;
-};
-
-struct vfe_cmd_white_balance_config {
-	uint8_t  enable;
-	uint16_t ch2Gain;
-	uint16_t ch1Gain;
-	uint16_t ch0Gain;
-};
-
-enum VFE_COLOR_CORRECTION_COEF_QFACTOR {
-	COEF_IS_Q7_SIGNED,
-	COEF_IS_Q8_SIGNED,
-	COEF_IS_Q9_SIGNED,
-	COEF_IS_Q10_SIGNED
-};
-
-struct vfe_cmd_color_correction_config {
-	uint8_t     enable;
-	enum VFE_COLOR_CORRECTION_COEF_QFACTOR coefQFactor;
-	int16_t  C0;
-	int16_t  C1;
-	int16_t  C2;
-	int16_t  C3;
-	int16_t  C4;
-	int16_t  C5;
-	int16_t  C6;
-	int16_t  C7;
-	int16_t  C8;
-	int16_t  K0;
-	int16_t  K1;
-	int16_t  K2;
-};
-
-#define VFE_LA_TABLE_LENGTH 64
-
-struct vfe_cmd_la_config {
-	uint8_t enable;
-	int16_t table[VFE_LA_TABLE_LENGTH];
-};
-
-#define VFE_GAMMA_TABLE_LENGTH 256
-enum VFE_RGB_GAMMA_TABLE_SELECT {
-	RGB_GAMMA_CH0_SELECTED,
-	RGB_GAMMA_CH1_SELECTED,
-	RGB_GAMMA_CH2_SELECTED,
-	RGB_GAMMA_CH0_CH1_SELECTED,
-	RGB_GAMMA_CH0_CH2_SELECTED,
-	RGB_GAMMA_CH1_CH2_SELECTED,
-	RGB_GAMMA_CH0_CH1_CH2_SELECTED
-};
-
-struct vfe_cmd_rgb_gamma_config {
-	uint8_t enable;
-	enum VFE_RGB_GAMMA_TABLE_SELECT channelSelect;
-	int16_t table[VFE_GAMMA_TABLE_LENGTH];
-};
-
-struct vfe_cmd_chroma_enhan_config {
-	uint8_t  enable;
-	int16_t am;
-	int16_t ap;
-	int16_t bm;
-	int16_t bp;
-	int16_t cm;
-	int16_t cp;
-	int16_t dm;
-	int16_t dp;
-	int16_t kcr;
-	int16_t kcb;
-	int16_t RGBtoYConversionV0;
-	int16_t RGBtoYConversionV1;
-	int16_t RGBtoYConversionV2;
-	uint8_t RGBtoYConversionOffset;
-};
-
-struct vfe_cmd_chroma_suppression_config {
-	uint8_t enable;
-	uint8_t m1;
-	uint8_t m3;
-	uint8_t n1;
-	uint8_t n3;
-	uint8_t nn1;
-	uint8_t mm1;
-};
-
-struct vfe_cmd_asf_config {
-	uint8_t enable;
-	uint8_t smoothFilterEnabled;
-	uint8_t sharpMode;
-	uint8_t smoothCoefCenter;
-	uint8_t smoothCoefSurr;
-	uint8_t normalizeFactor;
-	uint8_t sharpK1;
-	uint8_t sharpK2;
-	uint8_t sharpThreshE1;
-	int8_t sharpThreshE2;
-	int8_t sharpThreshE3;
-	int8_t sharpThreshE4;
-	int8_t sharpThreshE5;
-	int8_t filter1Coefficients[9];
-	int8_t filter2Coefficients[9];
-	uint8_t  cropEnable;
-	uint16_t cropFirstPixel;
-	uint16_t cropLastPixel;
-	uint16_t cropFirstLine;
-	uint16_t cropLastLine;
-};
-
-struct vfe_cmd_asf_update {
-	uint8_t enable;
-	uint8_t smoothFilterEnabled;
-	uint8_t sharpMode;
-	uint8_t smoothCoefCenter;
-	uint8_t smoothCoefSurr;
-	uint8_t normalizeFactor;
-	uint8_t sharpK1;
-	uint8_t sharpK2;
-	uint8_t sharpThreshE1;
-	int8_t  sharpThreshE2;
-	int8_t  sharpThreshE3;
-	int8_t  sharpThreshE4;
-	int8_t  sharpThreshE5;
-	int8_t  filter1Coefficients[9];
-	int8_t  filter2Coefficients[9];
-	uint8_t cropEnable;
-};
-
-enum VFE_TEST_GEN_SYNC_EDGE {
-	VFE_TEST_GEN_SYNC_EDGE_ActiveHigh,
-	VFE_TEST_GEN_SYNC_EDGE_ActiveLow
-};
-
-
-struct vfe_cmd_bus_pm_start {
-	uint8_t output2YWrPmEnable;
-	uint8_t output2CbcrWrPmEnable;
-	uint8_t output1YWrPmEnable;
-	uint8_t output1CbcrWrPmEnable;
-};
-
-struct  vfe_frame_skip_counts {
-	uint32_t  totalFrameCount;
-	uint32_t  output1Count;
-	uint32_t  output2Count;
-};
-
-enum VFE_AXI_RD_UNPACK_HBI_SEL {
-	VFE_AXI_RD_HBI_32_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_64_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_128_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_256_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_512_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_1024_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_2048_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_4096_CLOCK_CYCLES
-};
-
-enum VFE31_MESSAGE_ID {
-	MSG_ID_RESET_ACK, /* 0 */
-	MSG_ID_START_ACK,
-	MSG_ID_STOP_ACK,
-	MSG_ID_UPDATE_ACK,
-	MSG_ID_OUTPUT_P,
-	MSG_ID_OUTPUT_T,
-	MSG_ID_OUTPUT_S,
-	MSG_ID_OUTPUT_V,
-	MSG_ID_SNAPSHOT_DONE,
-	MSG_ID_COMMON,
-	MSG_ID_EPOCH1, /* 10 */
-	MSG_ID_EPOCH2,
-	MSG_ID_SYNC_TIMER0_DONE,
-	MSG_ID_SYNC_TIMER1_DONE,
-	MSG_ID_SYNC_TIMER2_DONE,
-	MSG_ID_ASYNC_TIMER0_DONE,
-	MSG_ID_ASYNC_TIMER1_DONE,
-	MSG_ID_ASYNC_TIMER2_DONE,
-	MSG_ID_ASYNC_TIMER3_DONE,
-	MSG_ID_AE_OVERFLOW,
-	MSG_ID_AF_OVERFLOW, /* 20 */
-	MSG_ID_AWB_OVERFLOW,
-	MSG_ID_RS_OVERFLOW,
-	MSG_ID_CS_OVERFLOW,
-	MSG_ID_IHIST_OVERFLOW,
-	MSG_ID_SKIN_OVERFLOW,
-	MSG_ID_AXI_ERROR,
-	MSG_ID_CAMIF_OVERFLOW,
-	MSG_ID_VIOLATION,
-	MSG_ID_CAMIF_ERROR,
-	MSG_ID_BUS_OVERFLOW, /* 30 */
-	MSG_ID_SOF_ACK,
-	MSG_ID_STOP_REC_ACK,
-};
-
-struct stats_buffer {
-	uint8_t awb_ymin;
-	uint32_t aec;
-	uint32_t awb;
-	uint32_t af;
-	uint32_t ihist;
-	uint32_t rs;
-	uint32_t cs;
-	uint32_t skin;
-};
-
-struct vfe_msg_stats {
-	struct stats_buffer buff;
-	uint32_t    frameCounter;
-	uint32_t    status_bits;
-};
-
-
-struct vfe_frame_bpc_info {
-	uint32_t greenDefectPixelCount;
-	uint32_t redBlueDefectPixelCount;
-};
-
-struct vfe_frame_asf_info {
-	uint32_t  asfMaxEdge;
-	uint32_t  asfHbiCount;
-};
-
-struct vfe_msg_camif_status {
-	uint8_t  camifState;
-	uint32_t pixelCount;
-	uint32_t lineCount;
-};
-
-
-struct vfe31_irq_status {
-	uint32_t vfeIrqStatus0;
-	uint32_t vfeIrqStatus1;
-	uint32_t camifStatus;
-	uint32_t demosaicStatus;
-	uint32_t asfMaxEdge;
-	uint32_t vfePingPongStatus;
-};
-
-struct vfe_msg_output {
-	uint8_t   output_id;
-	uint32_t  p0_addr;
-	uint32_t  p1_addr;
-	uint32_t  p2_addr;
-	struct vfe_frame_bpc_info bpcInfo;
-	struct vfe_frame_asf_info asfInfo;
-	uint32_t  frameCounter;
-};
-
-struct vfe_message {
-	enum VFE31_MESSAGE_ID _d;
-	union {
-		struct vfe_msg_output              msgOut;
-		struct vfe_msg_stats               msgStats;
-		struct vfe_msg_camif_status        msgCamifError;
-   } _u;
-};
-
-/* New one for 7x30 */
-struct msm_vfe31_cmd {
-	int32_t  id;
-	uint16_t length;
-	void     *value;
-};
-
-#define V31_PREVIEW_AXI_FLAG  0x00000001
-#define V31_SNAPSHOT_AXI_FLAG (0x00000001<<1)
-
-struct vfe31_cmd_type {
-	uint16_t id;
-	uint32_t length;
-	uint32_t offset;
-	uint32_t flag;
-};
-
-struct vfe31_free_buf {
-	struct list_head node;
-	uint32_t paddr;
-	uint32_t planar0_off;
-	uint32_t planar1_off;
-	uint32_t planar2_off;
-	uint32_t cbcr_off;
-};
-
-struct vfe31_output_ch {
-	struct list_head free_buf_head;
-	spinlock_t free_buf_lock;
-	uint16_t output_fmt;
-	int8_t ch0;
-	int8_t ch1;
-	int8_t ch2;
-	uint32_t  frame_drop_cnt;
-};
-
-/* no error irq in mask 0 */
-#define VFE31_IMASK_ERROR_ONLY_0  0x0
-/* when normal case, don't want to block error status. */
-/* bit 0-21 are error irq bits */
-#define VFE31_IMASK_ERROR_ONLY_1               0x003FFFFF
-#define VFE31_IMASK_CAMIF_ERROR               (0x00000001<<0)
-#define VFE31_IMASK_STATS_CS_OVWR             (0x00000001<<1)
-#define VFE31_IMASK_STATS_IHIST_OVWR          (0x00000001<<2)
-#define VFE31_IMASK_REALIGN_BUF_Y_OVFL        (0x00000001<<3)
-#define VFE31_IMASK_REALIGN_BUF_CB_OVFL       (0x00000001<<4)
-#define VFE31_IMASK_REALIGN_BUF_CR_OVFL       (0x00000001<<5)
-#define VFE31_IMASK_VIOLATION                 (0x00000001<<6)
-#define VFE31_IMASK_IMG_MAST_0_BUS_OVFL       (0x00000001<<7)
-#define VFE31_IMASK_IMG_MAST_1_BUS_OVFL       (0x00000001<<8)
-#define VFE31_IMASK_IMG_MAST_2_BUS_OVFL       (0x00000001<<9)
-#define VFE31_IMASK_IMG_MAST_3_BUS_OVFL       (0x00000001<<10)
-#define VFE31_IMASK_IMG_MAST_4_BUS_OVFL       (0x00000001<<11)
-#define VFE31_IMASK_IMG_MAST_5_BUS_OVFL       (0x00000001<<12)
-#define VFE31_IMASK_IMG_MAST_6_BUS_OVFL       (0x00000001<<13)
-#define VFE31_IMASK_STATS_AE_BUS_OVFL         (0x00000001<<14)
-#define VFE31_IMASK_STATS_AF_BUS_OVFL         (0x00000001<<15)
-#define VFE31_IMASK_STATS_AWB_BUS_OVFL        (0x00000001<<16)
-#define VFE31_IMASK_STATS_RS_BUS_OVFL         (0x00000001<<17)
-#define VFE31_IMASK_STATS_CS_BUS_OVFL         (0x00000001<<18)
-#define VFE31_IMASK_STATS_IHIST_BUS_OVFL      (0x00000001<<19)
-#define VFE31_IMASK_STATS_SKIN_BUS_OVFL       (0x00000001<<20)
-#define VFE31_IMASK_AXI_ERROR                 (0x00000001<<21)
-
-#define VFE_COM_STATUS 0x000FE000
-
-struct vfe31_output_path {
-	uint16_t output_mode;     /* bitmask  */
-
-	struct vfe31_output_ch out0; /* preview and thumbnail */
-	struct vfe31_output_ch out1; /* snapshot */
-	struct vfe31_output_ch out2; /* video    */
-};
-
-struct vfe31_frame_extra {
-	uint32_t greenDefectPixelCount;
-	uint32_t redBlueDefectPixelCount;
-
-	uint32_t  asfMaxEdge;
-	uint32_t  asfHbiCount;
-
-	uint32_t yWrPmStats0;
-	uint32_t yWrPmStats1;
-	uint32_t cbcrWrPmStats0;
-	uint32_t cbcrWrPmStats1;
-
-	uint32_t  frameCounter;
-};
-
-#define VFE_DISABLE_ALL_IRQS             0
-#define VFE_CLEAR_ALL_IRQS               0xffffffff
-
-#define VFE_GLOBAL_RESET                 0x00000004
-#define VFE_CGC_OVERRIDE                 0x0000000C
-#define VFE_MODULE_CFG                   0x00000010
-#define VFE_CFG_OFF                      0x00000014
-#define VFE_IRQ_CMD                      0x00000018
-#define VFE_IRQ_MASK_0                   0x0000001C
-#define VFE_IRQ_MASK_1                   0x00000020
-#define VFE_IRQ_CLEAR_0                  0x00000024
-#define VFE_IRQ_CLEAR_1                  0x00000028
-#define VFE_IRQ_STATUS_0                 0x0000002C
-#define VFE_IRQ_STATUS_1                 0x00000030
-#define VFE_IRQ_COMP_MASK                0x00000034
-#define VFE_BUS_CMD                      0x00000038
-#define VFE_BUS_PING_PONG_STATUS         0x00000180
-#define VFE_BUS_OPERATION_STATUS         0x00000184
-
-#define VFE_BUS_IMAGE_MASTER_0_WR_PM_STATS_0        0x00000190
-#define VFE_BUS_IMAGE_MASTER_0_WR_PM_STATS_1        0x00000194
-
-#define VFE_AXI_CMD                      0x000001D8
-#define VFE_AXI_STATUS                   0x000001DC
-#define VFE_BUS_STATS_PING_PONG_BASE     0x000000F4
-
-#define VFE_BUS_STATS_AEC_WR_PING_ADDR   0x000000F4
-#define VFE_BUS_STATS_AEC_WR_PONG_ADDR   0x000000F8
-#define VFE_BUS_STATS_AEC_UB_CFG         0x000000FC
-#define VFE_BUS_STATS_AF_WR_PING_ADDR    0x00000100
-#define VFE_BUS_STATS_AF_WR_PONG_ADDR    0x00000104
-#define VFE_BUS_STATS_AF_UB_CFG          0x00000108
-#define VFE_BUS_STATS_AWB_WR_PING_ADDR   0x0000010C
-#define VFE_BUS_STATS_AWB_WR_PONG_ADDR   0x00000110
-#define VFE_BUS_STATS_AWB_UB_CFG         0x00000114
-#define VFE_BUS_STATS_RS_WR_PING_ADDR    0x00000118
-#define VFE_BUS_STATS_RS_WR_PONG_ADDR    0x0000011C
-#define VFE_BUS_STATS_RS_UB_CFG          0x00000120
-
-#define VFE_BUS_STATS_CS_WR_PING_ADDR    0x00000124
-#define VFE_BUS_STATS_CS_WR_PONG_ADDR    0x00000128
-#define VFE_BUS_STATS_CS_UB_CFG          0x0000012C
-#define VFE_BUS_STATS_HIST_WR_PING_ADDR  0x00000130
-#define VFE_BUS_STATS_HIST_WR_PONG_ADDR  0x00000134
-#define VFE_BUS_STATS_HIST_UB_CFG        0x00000138
-#define VFE_BUS_STATS_SKIN_WR_PING_ADDR  0x0000013C
-#define VFE_BUS_STATS_SKIN_WR_PONG_ADDR  0x00000140
-#define VFE_BUS_STATS_SKIN_UB_CFG        0x00000144
-#define VFE_BUS_PM_CMD                   0x00000188
-#define VFE_BUS_PM_CFG                   0x0000018C
-#define VFE_CAMIF_COMMAND                0x000001E0
-#define VFE_CAMIF_STATUS                 0x00000204
-#define VFE_REG_UPDATE_CMD               0x00000260
-#define VFE_DEMUX_GAIN_0                 0x00000288
-#define VFE_DEMUX_GAIN_1                 0x0000028C
-#define VFE_CHROMA_UP                    0x0000035C
-#define VFE_FRAMEDROP_ENC_Y_CFG          0x00000504
-#define VFE_FRAMEDROP_ENC_CBCR_CFG       0x00000508
-#define VFE_FRAMEDROP_ENC_Y_PATTERN      0x0000050C
-#define VFE_FRAMEDROP_ENC_CBCR_PATTERN   0x00000510
-#define VFE_FRAMEDROP_VIEW_Y             0x00000514
-#define VFE_FRAMEDROP_VIEW_CBCR          0x00000518
-#define VFE_FRAMEDROP_VIEW_Y_PATTERN     0x0000051C
-#define VFE_FRAMEDROP_VIEW_CBCR_PATTERN  0x00000520
-#define VFE_CLAMP_MAX                    0x00000524
-#define VFE_CLAMP_MIN                    0x00000528
-#define VFE_REALIGN_BUF                  0x0000052C
-#define VFE_STATS_CFG                    0x00000530
-#define VFE_STATS_AWB_SGW_CFG            0x00000554
-#define VFE_DMI_CFG                      0x00000598
-#define VFE_DMI_ADDR                     0x0000059C
-#define VFE_DMI_DATA_LO                  0x000005A4
-#define VFE_AXI_CFG                      0x00000600
-
-struct vfe_stats_control {
-	uint8_t  ackPending;
-	uint32_t nextFrameAddrBuf;
-	uint32_t droppedStatsFrameCount;
-	uint32_t bufToRender;
-};
-
-struct vfe31_ctrl_type {
-	uint16_t operation_mode;     /* streaming or snapshot */
-	struct vfe31_output_path outpath;
-
-	uint32_t vfeImaskCompositePacked;
-
-	spinlock_t  update_ack_lock;
-	spinlock_t  io_lock;
-
-	int8_t aec_ack_pending;
-	int8_t awb_ack_pending;
-	int8_t af_ack_pending;
-	int8_t ihist_ack_pending;
-	int8_t rs_ack_pending;
-	int8_t cs_ack_pending;
-
-	struct msm_vfe_callback *resp;
-	uint32_t extlen;
-	void *extdata;
-
-	int8_t start_ack_pending;
-	atomic_t stop_ack_pending;
-	int8_t reset_ack_pending;
-	int8_t update_ack_pending;
-	enum vfe_recording_state recording_state;
-	int8_t output0_available;
-	int8_t output1_available;
-	int8_t update_gamma;
-	int8_t update_luma;
-	spinlock_t  tasklet_lock;
-	struct list_head tasklet_q;
-	int vfeirq;
-	void __iomem *vfebase;
-	void *syncdata;
-
-	struct resource	*vfemem;
-	struct resource *vfeio;
-
-	uint32_t stats_comp;
-	uint32_t hfr_mode;
-	atomic_t vstate;
-	uint32_t vfe_capture_count;
-	uint32_t sync_timer_repeat_count;
-	uint32_t sync_timer_state;
-	uint32_t sync_timer_number;
-
-	uint32_t vfeFrameId;
-	uint32_t output1Pattern;
-	uint32_t output1Period;
-	uint32_t output2Pattern;
-	uint32_t output2Period;
-	uint32_t vfeFrameSkipCount;
-	uint32_t vfeFrameSkipPeriod;
-	uint32_t status_bits;
-	struct vfe_stats_control afStatsControl;
-	struct vfe_stats_control awbStatsControl;
-	struct vfe_stats_control aecStatsControl;
-	struct vfe_stats_control ihistStatsControl;
-	struct vfe_stats_control rsStatsControl;
-	struct vfe_stats_control csStatsControl;
-	struct msm_camera_sensor_info *s_info;
-	struct vfe_message vMsgHold_Snap;
-	struct vfe_message vMsgHold_Thumb;
-	int8_t xbar_update_pending;
-	uint32_t xbar_cfg[2];
-	spinlock_t xbar_lock;
-	uint32_t while_stopping_mask;
-};
-
-#define statsAeNum      0
-#define statsAfNum      1
-#define statsAwbNum     2
-#define statsRsNum      3
-#define statsCsNum      4
-#define statsIhistNum   5
-#define statsSkinNum    6
-
-struct vfe_cmd_stats_ack{
-  uint32_t  nextStatsBuf;
-};
-
-#define VFE_STATS_BUFFER_COUNT            3
-
-struct vfe_cmd_stats_buf{
-   uint32_t statsBuf[VFE_STATS_BUFFER_COUNT];
-};
-#endif /* __MSM_VFE31_H__ */
diff --git a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe31_v4l2.c b/drivers/media/platform/msm/camera_v1/vfe/msm_vfe31_v4l2.c
deleted file mode 100644
index 10ddd4b..0000000
--- a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe31_v4l2.c
+++ /dev/null
@@ -1,4241 +0,0 @@
-/* Copyright (c) 2012 The Linux Foundation. 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.
- */
-
-#include <linux/uaccess.h>
-#include <linux/interrupt.h>
-#include <linux/slab.h>
-#include <linux/io.h>
-#include <linux/atomic.h>
-#include <linux/regulator/consumer.h>
-#include <linux/clk.h>
-#include <linux/module.h>
-#include <mach/clk.h>
-#include <mach/irqs.h>
-#include <mach/camera.h>
-#include <media/v4l2-device.h>
-#include <media/v4l2-subdev.h>
-#include <media/msm_isp.h>
-
-#include "msm.h"
-#include "msm_vfe31_v4l2.h"
-
-atomic_t irq_cnt;
-
-#define BUFF_SIZE_128 128
-
-#define VFE31_AXI_OFFSET 0x0050
-#define vfe31_get_ch_ping_addr(chn) \
-	(msm_camera_io_r(vfe31_ctrl->vfebase + 0x0050 + 0x18 * (chn)))
-#define vfe31_get_ch_pong_addr(chn) \
-	(msm_camera_io_r(vfe31_ctrl->vfebase + 0x0050 + 0x18 * (chn) + 4))
-#define vfe31_get_ch_addr(ping_pong, chn) \
-	(((ping_pong) & (1 << (chn))) == 0 ? \
-	vfe31_get_ch_pong_addr(chn) : vfe31_get_ch_ping_addr(chn))
-
-#define vfe31_put_ch_ping_addr(chn, addr) \
-	(msm_camera_io_w((addr), vfe31_ctrl->vfebase + 0x0050 + 0x18 * (chn)))
-#define vfe31_put_ch_pong_addr(chn, addr) \
-	(msm_camera_io_w((addr), \
-	vfe31_ctrl->vfebase + 0x0050 + 0x18 * (chn) + 4))
-#define vfe31_put_ch_addr(ping_pong, chn, addr) \
-	(((ping_pong) & (1 << (chn))) == 0 ?   \
-	vfe31_put_ch_pong_addr((chn), (addr)) : \
-	vfe31_put_ch_ping_addr((chn), (addr)))
-
-#define VFE_CLK_RATE	153600000
-#define CAMIF_CFG_RMSK             0x1fffff
-
-static struct vfe31_ctrl_type *vfe31_ctrl;
-static uint32_t vfe_clk_rate;
-
-struct vfe31_isr_queue_cmd {
-	struct list_head	list;
-	uint32_t		vfeInterruptStatus0;
-	uint32_t		vfeInterruptStatus1;
-};
-
-static struct vfe31_cmd_type vfe31_cmd[] = {
-/* 0*/	{VFE_CMD_DUMMY_0},
-		{VFE_CMD_SET_CLK},
-		{VFE_CMD_RESET},
-		{VFE_CMD_START},
-		{VFE_CMD_TEST_GEN_START},
-/* 5*/	{VFE_CMD_OPERATION_CFG, V31_OPERATION_CFG_LEN},
-		{VFE_CMD_AXI_OUT_CFG, V31_AXI_OUT_LEN, V31_AXI_OUT_OFF, 0xFF},
-		{VFE_CMD_CAMIF_CFG, V31_CAMIF_LEN, V31_CAMIF_OFF, 0xFF},
-		{VFE_CMD_AXI_INPUT_CFG},
-		{VFE_CMD_BLACK_LEVEL_CFG, V31_BLACK_LEVEL_LEN,
-		V31_BLACK_LEVEL_OFF,
-		0xFF},
-/*10*/  {VFE_CMD_MESH_ROLL_OFF_CFG, V31_MESH_ROLL_OFF_CFG_LEN,
-		V31_MESH_ROLL_OFF_CFG_OFF, 0xFF},
-		{VFE_CMD_DEMUX_CFG, V31_DEMUX_LEN, V31_DEMUX_OFF, 0xFF},
-		{VFE_CMD_FOV_CFG, V31_FOV_LEN, V31_FOV_OFF, 0xFF},
-		{VFE_CMD_MAIN_SCALER_CFG, V31_MAIN_SCALER_LEN,
-		V31_MAIN_SCALER_OFF, 0xFF},
-		{VFE_CMD_WB_CFG, V31_WB_LEN, V31_WB_OFF, 0xFF},
-/*15*/	{VFE_CMD_COLOR_COR_CFG, V31_COLOR_COR_LEN, V31_COLOR_COR_OFF, 0xFF},
-		{VFE_CMD_RGB_G_CFG, V31_RGB_G_LEN, V31_RGB_G_OFF, 0xFF},
-		{VFE_CMD_LA_CFG, V31_LA_LEN, V31_LA_OFF, 0xFF },
-		{VFE_CMD_CHROMA_EN_CFG, V31_CHROMA_EN_LEN, V31_CHROMA_EN_OFF,
-		0xFF},
-		{VFE_CMD_CHROMA_SUP_CFG, V31_CHROMA_SUP_LEN, V31_CHROMA_SUP_OFF,
-		0xFF},
-/*20*/	{VFE_CMD_MCE_CFG, V31_MCE_LEN, V31_MCE_OFF, 0xFF},
-		{VFE_CMD_SK_ENHAN_CFG, V31_SCE_LEN, V31_SCE_OFF, 0xFF},
-		{VFE_CMD_ASF_CFG, V31_ASF_LEN, V31_ASF_OFF, 0xFF},
-		{VFE_CMD_S2Y_CFG, V31_S2Y_LEN, V31_S2Y_OFF, 0xFF},
-		{VFE_CMD_S2CbCr_CFG, V31_S2CbCr_LEN, V31_S2CbCr_OFF, 0xFF},
-/*25*/	{VFE_CMD_CHROMA_SUBS_CFG, V31_CHROMA_SUBS_LEN, V31_CHROMA_SUBS_OFF,
-		0xFF},
-		{VFE_CMD_OUT_CLAMP_CFG, V31_OUT_CLAMP_LEN, V31_OUT_CLAMP_OFF,
-		0xFF},
-		{VFE_CMD_FRAME_SKIP_CFG, V31_FRAME_SKIP_LEN, V31_FRAME_SKIP_OFF,
-		0xFF},
-		{VFE_CMD_DUMMY_1},
-		{VFE_CMD_DUMMY_2},
-/*30*/	{VFE_CMD_DUMMY_3},
-		{VFE_CMD_UPDATE},
-		{VFE_CMD_BL_LVL_UPDATE, V31_BLACK_LEVEL_LEN,
-		V31_BLACK_LEVEL_OFF, 0xFF},
-		{VFE_CMD_DEMUX_UPDATE, V31_DEMUX_LEN, V31_DEMUX_OFF, 0xFF},
-		{VFE_CMD_FOV_UPDATE, V31_FOV_LEN, V31_FOV_OFF, 0xFF},
-/*35*/	{VFE_CMD_MAIN_SCALER_UPDATE, V31_MAIN_SCALER_LEN, V31_MAIN_SCALER_OFF,
-		0xFF},
-		{VFE_CMD_WB_UPDATE, V31_WB_LEN, V31_WB_OFF, 0xFF},
-		{VFE_CMD_COLOR_COR_UPDATE, V31_COLOR_COR_LEN, V31_COLOR_COR_OFF,
-		0xFF},
-		{VFE_CMD_RGB_G_UPDATE, V31_RGB_G_LEN, V31_CHROMA_EN_OFF, 0xFF},
-		{VFE_CMD_LA_UPDATE, V31_LA_LEN, V31_LA_OFF, 0xFF },
-/*40*/	{VFE_CMD_CHROMA_EN_UPDATE, V31_CHROMA_EN_LEN, V31_CHROMA_EN_OFF,
-		0xFF},
-		{VFE_CMD_CHROMA_SUP_UPDATE, V31_CHROMA_SUP_LEN,
-		V31_CHROMA_SUP_OFF, 0xFF},
-		{VFE_CMD_MCE_UPDATE, V31_MCE_LEN, V31_MCE_OFF, 0xFF},
-		{VFE_CMD_SK_ENHAN_UPDATE, V31_SCE_LEN, V31_SCE_OFF, 0xFF},
-		{VFE_CMD_S2CbCr_UPDATE, V31_S2CbCr_LEN, V31_S2CbCr_OFF, 0xFF},
-/*45*/	{VFE_CMD_S2Y_UPDATE, V31_S2Y_LEN, V31_S2Y_OFF, 0xFF},
-		{VFE_CMD_ASF_UPDATE, V31_ASF_UPDATE_LEN, V31_ASF_OFF, 0xFF},
-		{VFE_CMD_FRAME_SKIP_UPDATE},
-		{VFE_CMD_CAMIF_FRAME_UPDATE},
-		{VFE_CMD_STATS_AF_UPDATE, V31_STATS_AF_LEN, V31_STATS_AF_OFF},
-/*50*/	{VFE_CMD_STATS_AE_UPDATE, V31_STATS_AE_LEN, V31_STATS_AE_OFF},
-		{VFE_CMD_STATS_AWB_UPDATE, V31_STATS_AWB_LEN,
-		V31_STATS_AWB_OFF},
-		{VFE_CMD_STATS_RS_UPDATE, V31_STATS_RS_LEN, V31_STATS_RS_OFF},
-		{VFE_CMD_STATS_CS_UPDATE, V31_STATS_CS_LEN, V31_STATS_CS_OFF},
-		{VFE_CMD_STATS_SKIN_UPDATE},
-/*55*/	{VFE_CMD_STATS_IHIST_UPDATE, V31_STATS_IHIST_LEN, V31_STATS_IHIST_OFF},
-		{VFE_CMD_DUMMY_4},
-		{VFE_CMD_EPOCH1_ACK},
-		{VFE_CMD_EPOCH2_ACK},
-		{VFE_CMD_START_RECORDING},
-/*60*/	{VFE_CMD_STOP_RECORDING},
-		{VFE_CMD_DUMMY_5},
-		{VFE_CMD_DUMMY_6},
-		{VFE_CMD_CAPTURE, V31_CAPTURE_LEN, 0xFF},
-		{VFE_CMD_DUMMY_7},
-/*65*/	{VFE_CMD_STOP},
-		{VFE_CMD_GET_HW_VERSION, V31_GET_HW_VERSION_LEN,
-		V31_GET_HW_VERSION_OFF},
-		{VFE_CMD_GET_FRAME_SKIP_COUNTS},
-		{VFE_CMD_OUTPUT1_BUFFER_ENQ},
-		{VFE_CMD_OUTPUT2_BUFFER_ENQ},
-/*70*/	{VFE_CMD_OUTPUT3_BUFFER_ENQ},
-		{VFE_CMD_JPEG_OUT_BUF_ENQ},
-		{VFE_CMD_RAW_OUT_BUF_ENQ},
-		{VFE_CMD_RAW_IN_BUF_ENQ},
-		{VFE_CMD_STATS_AF_ENQ},
-/*75*/	{VFE_CMD_STATS_AE_ENQ},
-		{VFE_CMD_STATS_AWB_ENQ},
-		{VFE_CMD_STATS_RS_ENQ},
-		{VFE_CMD_STATS_CS_ENQ},
-		{VFE_CMD_STATS_SKIN_ENQ},
-/*80*/	{VFE_CMD_STATS_IHIST_ENQ},
-		{VFE_CMD_DUMMY_8},
-		{VFE_CMD_JPEG_ENC_CFG},
-		{VFE_CMD_DUMMY_9},
-		{VFE_CMD_STATS_AF_START, V31_STATS_AF_LEN, V31_STATS_AF_OFF},
-/*85*/	{VFE_CMD_STATS_AF_STOP},
-		{VFE_CMD_STATS_AE_START, V31_STATS_AE_LEN, V31_STATS_AE_OFF},
-		{VFE_CMD_STATS_AE_STOP},
-		{VFE_CMD_STATS_AWB_START, V31_STATS_AWB_LEN, V31_STATS_AWB_OFF},
-		{VFE_CMD_STATS_AWB_STOP},
-/*90*/	{VFE_CMD_STATS_RS_START, V31_STATS_RS_LEN, V31_STATS_RS_OFF},
-		{VFE_CMD_STATS_RS_STOP},
-		{VFE_CMD_STATS_CS_START, V31_STATS_CS_LEN, V31_STATS_CS_OFF},
-		{VFE_CMD_STATS_CS_STOP},
-		{VFE_CMD_STATS_SKIN_START},
-/*95*/	{VFE_CMD_STATS_SKIN_STOP},
-		{VFE_CMD_STATS_IHIST_START,
-		V31_STATS_IHIST_LEN, V31_STATS_IHIST_OFF},
-		{VFE_CMD_STATS_IHIST_STOP},
-		{VFE_CMD_DUMMY_10},
-		{VFE_CMD_SYNC_TIMER_SETTING, V31_SYNC_TIMER_LEN,
-			V31_SYNC_TIMER_OFF},
-/*100*/	{VFE_CMD_ASYNC_TIMER_SETTING, V31_ASYNC_TIMER_LEN, V31_ASYNC_TIMER_OFF},
-		{VFE_CMD_LIVESHOT},
-		{VFE_CMD_LA_SETUP},
-		{VFE_CMD_LINEARIZATION_CFG},
-		{VFE_CMD_DEMOSAICV3},
-/*105*/	{VFE_CMD_DEMOSAICV3_ABCC_CFG},
-	{VFE_CMD_DEMOSAICV3_DBCC_CFG},
-		{VFE_CMD_DEMOSAICV3_DBPC_CFG, V31_DEMOSAICV3_DBPC_LEN,
-			V31_DEMOSAICV3_DBPC_CFG_OFF},
-		{VFE_CMD_DEMOSAICV3_ABF_CFG, V31_DEMOSAICV3_ABF_LEN,
-			V31_DEMOSAICV3_ABF_OFF},
-		{VFE_CMD_DEMOSAICV3_ABCC_UPDATE},
-/*110*/	{VFE_CMD_DEMOSAICV3_DBCC_UPDATE},
-		{VFE_CMD_DEMOSAICV3_DBPC_UPDATE, V31_DEMOSAICV3_DBPC_LEN,
-			V31_DEMOSAICV3_DBPC_CFG_OFF},
-		{VFE_CMD_XBAR_CFG},
-		{VFE_CMD_MODULE_CFG, V31_MODULE_CFG_LEN, V31_MODULE_CFG_OFF},
-		{VFE_CMD_ZSL},
-/*115*/	{VFE_CMD_LINEARIZATION_UPDATE},
-		{VFE_CMD_DEMOSAICV3_ABF_UPDATE, V31_DEMOSAICV3_ABF_LEN,
-			V31_DEMOSAICV3_ABF_OFF},
-		{VFE_CMD_CLF_CFG},
-		{VFE_CMD_CLF_LUMA_UPDATE},
-		{VFE_CMD_CLF_CHROMA_UPDATE},
-/*120*/ {VFE_CMD_PCA_ROLL_OFF_CFG},
-		{VFE_CMD_PCA_ROLL_OFF_UPDATE},
-		{VFE_CMD_GET_REG_DUMP},
-		{VFE_CMD_GET_LINEARIZATON_TABLE},
-		{VFE_CMD_GET_MESH_ROLLOFF_TABLE},
-/*125*/ {VFE_CMD_GET_PCA_ROLLOFF_TABLE},
-		{VFE_CMD_GET_RGB_G_TABLE},
-		{VFE_CMD_GET_LA_TABLE},
-		{VFE_CMD_DEMOSAICV3_UPDATE},
-};
-
-uint32_t vfe31_AXI_WM_CFG[] = {
-	0x0000004C,
-	0x00000064,
-	0x0000007C,
-	0x00000094,
-	0x000000AC,
-	0x000000C4,
-	0x000000DC,
-};
-
-static const char * const vfe31_general_cmd[] = {
-	"DUMMY_0",  /* 0 */
-	"SET_CLK",
-	"RESET",
-	"START",
-	"TEST_GEN_START",
-	"OPERATION_CFG",  /* 5 */
-	"AXI_OUT_CFG",
-	"CAMIF_CFG",
-	"AXI_INPUT_CFG",
-	"BLACK_LEVEL_CFG",
-	"ROLL_OFF_CFG",  /* 10 */
-	"DEMUX_CFG",
-	"FOV_CFG",
-	"MAIN_SCALER_CFG",
-	"WB_CFG",
-	"COLOR_COR_CFG", /* 15 */
-	"RGB_G_CFG",
-	"LA_CFG",
-	"CHROMA_EN_CFG",
-	"CHROMA_SUP_CFG",
-	"MCE_CFG", /* 20 */
-	"SK_ENHAN_CFG",
-	"ASF_CFG",
-	"S2Y_CFG",
-	"S2CbCr_CFG",
-	"CHROMA_SUBS_CFG",  /* 25 */
-	"OUT_CLAMP_CFG",
-	"FRAME_SKIP_CFG",
-	"DUMMY_1",
-	"DUMMY_2",
-	"DUMMY_3",  /* 30 */
-	"UPDATE",
-	"BL_LVL_UPDATE",
-	"DEMUX_UPDATE",
-	"FOV_UPDATE",
-	"MAIN_SCALER_UPDATE",  /* 35 */
-	"WB_UPDATE",
-	"COLOR_COR_UPDATE",
-	"RGB_G_UPDATE",
-	"LA_UPDATE",
-	"CHROMA_EN_UPDATE",  /* 40 */
-	"CHROMA_SUP_UPDATE",
-	"MCE_UPDATE",
-	"SK_ENHAN_UPDATE",
-	"S2CbCr_UPDATE",
-	"S2Y_UPDATE",  /* 45 */
-	"ASF_UPDATE",
-	"FRAME_SKIP_UPDATE",
-	"CAMIF_FRAME_UPDATE",
-	"STATS_AF_UPDATE",
-	"STATS_AE_UPDATE",  /* 50 */
-	"STATS_AWB_UPDATE",
-	"STATS_RS_UPDATE",
-	"STATS_CS_UPDATE",
-	"STATS_SKIN_UPDATE",
-	"STATS_IHIST_UPDATE",  /* 55 */
-	"DUMMY_4",
-	"EPOCH1_ACK",
-	"EPOCH2_ACK",
-	"START_RECORDING",
-	"STOP_RECORDING",  /* 60 */
-	"DUMMY_5",
-	"DUMMY_6",
-	"CAPTURE",
-	"DUMMY_7",
-	"STOP",  /* 65 */
-	"GET_HW_VERSION",
-	"GET_FRAME_SKIP_COUNTS",
-	"OUTPUT1_BUFFER_ENQ",
-	"OUTPUT2_BUFFER_ENQ",
-	"OUTPUT3_BUFFER_ENQ",  /* 70 */
-	"JPEG_OUT_BUF_ENQ",
-	"RAW_OUT_BUF_ENQ",
-	"RAW_IN_BUF_ENQ",
-	"STATS_AF_ENQ",
-	"STATS_AE_ENQ",  /* 75 */
-	"STATS_AWB_ENQ",
-	"STATS_RS_ENQ",
-	"STATS_CS_ENQ",
-	"STATS_SKIN_ENQ",
-	"STATS_IHIST_ENQ",  /* 80 */
-	"DUMMY_8",
-	"JPEG_ENC_CFG",
-	"DUMMY_9",
-	"STATS_AF_START",
-	"STATS_AF_STOP",  /* 85 */
-	"STATS_AE_START",
-	"STATS_AE_STOP",
-	"STATS_AWB_START",
-	"STATS_AWB_STOP",
-	"STATS_RS_START",  /* 90 */
-	"STATS_RS_STOP",
-	"STATS_CS_START",
-	"STATS_CS_STOP",
-	"STATS_SKIN_START",
-	"STATS_SKIN_STOP",  /* 95 */
-	"STATS_IHIST_START",
-	"STATS_IHIST_STOP",
-	"DUMMY_10",
-	"SYNC_TIMER_SETTING",
-	"ASYNC_TIMER_SETTING",  /* 100 */
-	"LIVESHOT",
-	"LA_SETUP",
-	"LINEARIZATION_CFG",
-	"DEMOSAICV3",
-	"DEMOSAICV3_ABCC_CFG", /* 105 */
-	"DEMOSAICV3_DBCC_CFG",
-	"DEMOSAICV3_DBPC_CFG",
-	"DEMOSAICV3_ABF_CFG",
-	"DEMOSAICV3_ABCC_UPDATE",
-	"DEMOSAICV3_DBCC_UPDATE", /* 110 */
-	"DEMOSAICV3_DBPC_UPDATE",
-	"XBAR_CFG",
-	"EZTUNE_CFG",
-	"V31_ZSL",
-	"LINEARIZATION_UPDATE", /*115*/
-	"DEMOSAICV3_ABF_UPDATE",
-	"CLF_CFG",
-	"CLF_LUMA_UPDATE",
-	"CLF_CHROMA_UPDATE",
-	"PCA_ROLL_OFF_CFG", /*120*/
-	"PCA_ROLL_OFF_UPDATE",
-	"GET_REG_DUMP",
-	"GET_LINEARIZATON_TABLE",
-	"GET_MESH_ROLLOFF_TABLE",
-	"GET_PCA_ROLLOFF_TABLE", /*125*/
-	"GET_RGB_G_TABLE",
-	"GET_LA_TABLE",
-	"DEMOSAICV3_UPDATE",
-};
-
-
-static unsigned long vfe31_stats_dqbuf(enum msm_stats_enum_type stats_type)
-{
-	struct msm_stats_meta_buf *buf = NULL;
-	int rc = 0;
-	rc = vfe31_ctrl->stats_ops.dqbuf(vfe31_ctrl->stats_ops.stats_ctrl,
-			stats_type, &buf);
-	if (rc < 0) {
-		CDBG("%s: dq stats buf (type = %d) err = %d",
-			__func__, stats_type, rc);
-		return 0L;
-	}
-	return buf->paddr;
-}
-
-static unsigned long vfe31_stats_flush_enqueue(
-	enum msm_stats_enum_type stats_type)
-{
-	struct msm_stats_bufq *bufq = NULL;
-	struct msm_stats_meta_buf *stats_buf = NULL;
-	int rc = 0;
-	int i;
-	/*
-	 * Passing NULL for ion client as the buffers are already
-	 * mapped at this stage, client is not required, flush all
-	 * the buffers, and buffers move to PREPARE state
-	 */
-
-	rc = vfe31_ctrl->stats_ops.bufq_flush(
-			vfe31_ctrl->stats_ops.stats_ctrl, stats_type, NULL);
-	if (rc < 0) {
-		pr_err("%s: dq stats buf (type = %d) err = %d",
-			__func__, stats_type, rc);
-		return 0L;
-	}
-
-	/* Queue all the buffers back to QUEUED state */
-	bufq = vfe31_ctrl->stats_ctrl.bufq[stats_type];
-	for (i = 0; i < bufq->num_bufs; i++) {
-		stats_buf = &bufq->bufs[i];
-		rc = vfe31_ctrl->stats_ops.enqueue_buf(
-				vfe31_ctrl->stats_ops.stats_ctrl,
-				&(stats_buf->info), NULL, -1);
-		if (rc < 0) {
-			pr_err("%s: dq stats buf (type = %d) err = %d",
-				__func__, stats_type, rc);
-			return rc;
-		}
-	}
-	return 0L;
-}
-
-static unsigned long vfe31_stats_unregbuf(
-	struct msm_stats_reqbuf *req_buf, int domain_num)
-{
-	int i = 0, rc = 0;
-
-	for (i = 0; i < req_buf->num_buf; i++) {
-		rc = vfe31_ctrl->stats_ops.buf_unprepare(
-			vfe31_ctrl->stats_ops.stats_ctrl,
-			req_buf->stats_type, i,
-			vfe31_ctrl->stats_ops.client, domain_num);
-		if (rc < 0) {
-			pr_err("%s: unreg stats buf (type = %d) err = %d",
-				__func__, req_buf->stats_type, rc);
-		return rc;
-		}
-	}
-	return 0L;
-}
-
-static int vfe_stats_awb_buf_init(
-	struct vfe_cmd_stats_buf *in)
-{
-	uint32_t addr;
-	unsigned long flags;
-
-	spin_lock_irqsave(&vfe31_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe31_stats_dqbuf(MSM_STATS_TYPE_AWB);
-	spin_unlock_irqrestore(&vfe31_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq awb ping buf from free buf queue", __func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_AWB_WR_PING_ADDR);
-	spin_lock_irqsave(&vfe31_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe31_stats_dqbuf(MSM_STATS_TYPE_AWB);
-	spin_unlock_irqrestore(&vfe31_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq awb ping buf from free buf queue", __func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_AWB_WR_PONG_ADDR);
-	return 0;
-}
-
-static int vfe_stats_aec_buf_init(
-	struct vfe_cmd_stats_buf *in)
-{
-	uint32_t addr;
-	unsigned long flags;
-
-	spin_lock_irqsave(&vfe31_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe31_stats_dqbuf(MSM_STATS_TYPE_AEC);
-	spin_unlock_irqrestore(&vfe31_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq aec ping buf from free buf queue",
-			__func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe31_ctrl->vfebase +
-		VFE_BUS_STATS_AEC_WR_PING_ADDR);
-	spin_lock_irqsave(&vfe31_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe31_stats_dqbuf(MSM_STATS_TYPE_AEC);
-	spin_unlock_irqrestore(&vfe31_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq aec pong buf from free buf queue",
-			__func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe31_ctrl->vfebase +
-		VFE_BUS_STATS_AEC_WR_PONG_ADDR);
-	return 0;
-}
-
-static int vfe_stats_af_buf_init(
-	struct vfe_cmd_stats_buf *in)
-{
-	uint32_t addr;
-	unsigned long flags;
-	int rc = 0;
-
-	spin_lock_irqsave(&vfe31_ctrl->stats_bufq_lock, flags);
-	rc = vfe31_stats_flush_enqueue(MSM_STATS_TYPE_AF);
-	if (rc < 0) {
-		pr_err("%s: dq stats buf err = %d",
-			__func__, rc);
-		spin_unlock_irqrestore(&vfe31_ctrl->stats_bufq_lock, flags);
-		return -EINVAL;
-	}
-	addr = (uint32_t)vfe31_stats_dqbuf(MSM_STATS_TYPE_AF);
-	spin_unlock_irqrestore(&vfe31_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq af ping buf from free buf queue", __func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_AF_WR_PING_ADDR);
-	spin_lock_irqsave(&vfe31_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe31_stats_dqbuf(MSM_STATS_TYPE_AF);
-	spin_unlock_irqrestore(&vfe31_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq af pong buf from free buf queue", __func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_AF_WR_PONG_ADDR);
-	return 0;
-}
-
-static int vfe_stats_ihist_buf_init(
-	struct vfe_cmd_stats_buf *in)
-{
-	uint32_t addr;
-	unsigned long flags;
-	spin_lock_irqsave(&vfe31_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe31_stats_dqbuf(MSM_STATS_TYPE_IHIST);
-	spin_unlock_irqrestore(&vfe31_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq ihist ping buf from free buf queue",
-			__func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_HIST_WR_PING_ADDR);
-	spin_lock_irqsave(&vfe31_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe31_stats_dqbuf(MSM_STATS_TYPE_IHIST);
-	spin_unlock_irqrestore(&vfe31_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq ihist pong buf from free buf queue", __func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_HIST_WR_PONG_ADDR);
-	return 0;
-}
-
-static int vfe_stats_rs_buf_init(struct vfe_cmd_stats_buf *in)
-{
-	uint32_t addr;
-	unsigned long flags;
-	spin_lock_irqsave(&vfe31_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe31_stats_dqbuf(MSM_STATS_TYPE_RS);
-	spin_unlock_irqrestore(&vfe31_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq rs ping buf from free buf queue", __func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_RS_WR_PING_ADDR);
-	spin_lock_irqsave(&vfe31_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe31_stats_dqbuf(MSM_STATS_TYPE_RS);
-	spin_unlock_irqrestore(&vfe31_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq rs pong buf from free buf queue", __func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_RS_WR_PONG_ADDR);
-	return 0;
-}
-
-static int vfe_stats_cs_buf_init(struct vfe_cmd_stats_buf *in)
-{
-	uint32_t addr;
-	unsigned long flags;
-
-	spin_lock_irqsave(&vfe31_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe31_stats_dqbuf(MSM_STATS_TYPE_CS);
-	spin_unlock_irqrestore(&vfe31_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq cs ping buf from free buf queue", __func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_CS_WR_PING_ADDR);
-	spin_lock_irqsave(&vfe31_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe31_stats_dqbuf(MSM_STATS_TYPE_CS);
-	spin_unlock_irqrestore(&vfe31_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq cs pong buf from free buf queue", __func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_CS_WR_PONG_ADDR);
-	return 0;
-}
-
-static void vfe31_stop(void)
-{
-	uint8_t  axiBusyFlag = true;
-	unsigned long flags;
-
-	atomic_set(&vfe31_ctrl->vstate, 0);
-
-	/* for reset hw modules, and send msg when reset_irq comes.*/
-	spin_lock_irqsave(&vfe31_ctrl->stop_flag_lock, flags);
-	vfe31_ctrl->stop_ack_pending = TRUE;
-	spin_unlock_irqrestore(&vfe31_ctrl->stop_flag_lock, flags);
-
-	/* disable all interrupts.  */
-	msm_camera_io_w(VFE_DISABLE_ALL_IRQS,
-		vfe31_ctrl->vfebase + VFE_IRQ_MASK_0);
-	msm_camera_io_w(VFE_DISABLE_ALL_IRQS,
-		vfe31_ctrl->vfebase + VFE_IRQ_MASK_1);
-
-	/* clear all pending interrupts*/
-	msm_camera_io_w(VFE_CLEAR_ALL_IRQS,
-		vfe31_ctrl->vfebase + VFE_IRQ_CLEAR_0);
-	msm_camera_io_w(VFE_CLEAR_ALL_IRQS,
-		vfe31_ctrl->vfebase + VFE_IRQ_CLEAR_1);
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(1,
-		vfe31_ctrl->vfebase + VFE_IRQ_CMD);
-
-	/* in either continuous or snapshot mode, stop command can be issued
-	 * at any time. stop camif immediately. */
-	msm_camera_io_w_mb(CAMIF_COMMAND_STOP_IMMEDIATELY,
-		vfe31_ctrl->vfebase + VFE_CAMIF_COMMAND);
-	/* axi halt command. */
-	msm_camera_io_w(AXI_HALT,
-		vfe31_ctrl->vfebase + VFE_AXI_CMD);
-	wmb();
-	while (axiBusyFlag) {
-		if (msm_camera_io_r(vfe31_ctrl->vfebase + VFE_AXI_STATUS) & 0x1)
-			axiBusyFlag = false;
-	}
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(AXI_HALT_CLEAR,
-		vfe31_ctrl->vfebase + VFE_AXI_CMD);
-
-	/* now enable only halt_irq & reset_irq */
-	msm_camera_io_w(0xf0000000,          /* this is for async timer. */
-		vfe31_ctrl->vfebase + VFE_IRQ_MASK_0);
-	msm_camera_io_w(VFE_IMASK_WHILE_STOPPING_1,
-		vfe31_ctrl->vfebase + VFE_IRQ_MASK_1);
-
-	msm_camera_io_w_mb(VFE_RESET_UPON_STOP_CMD,
-		vfe31_ctrl->vfebase + VFE_GLOBAL_RESET);
-}
-
-static void vfe31_subdev_notify(int id, int path, uint32_t inst_handle)
-{
-	struct msm_vfe_resp rp;
-	struct msm_frame_info frame_info;
-	unsigned long flags;
-	spin_lock_irqsave(&vfe31_ctrl->sd_notify_lock, flags);
-	memset(&rp, 0, sizeof(struct msm_vfe_resp));
-	CDBG("vfe31_subdev_notify : msgId = %d\n", id);
-	rp.evt_msg.type   = MSM_CAMERA_MSG;
-	frame_info.inst_handle = inst_handle;
-	frame_info.path = path;
-	rp.evt_msg.data = &frame_info;
-	rp.type	   = id;
-	v4l2_subdev_notify(&vfe31_ctrl->subdev, NOTIFY_VFE_BUF_EVT, &rp);
-	spin_unlock_irqrestore(&vfe31_ctrl->sd_notify_lock, flags);
-}
-
-static int vfe31_config_axi(int mode, uint32_t *ao)
-{
-	uint32_t *ch_info;
-	uint32_t *axi_cfg = ao + V31_AXI_RESERVED;
-	uint32_t bus_cmd = *axi_cfg;
-	int i;
-
-	/* Update the corresponding write masters for each output*/
-	ch_info = axi_cfg + V31_AXI_CFG_LEN;
-	vfe31_ctrl->outpath.out0.ch0 = 0x0000FFFF & *ch_info;
-	vfe31_ctrl->outpath.out0.ch1 = 0x0000FFFF & (*ch_info++ >> 16);
-	vfe31_ctrl->outpath.out0.ch2 = 0x0000FFFF & *ch_info++;
-	vfe31_ctrl->outpath.out0.inst_handle = *ch_info++;
-	vfe31_ctrl->outpath.out1.ch0 = 0x0000FFFF & *ch_info;
-	vfe31_ctrl->outpath.out1.ch1 = 0x0000FFFF & (*ch_info++ >> 16);
-	vfe31_ctrl->outpath.out1.ch2 = 0x0000FFFF & *ch_info++;
-	vfe31_ctrl->outpath.out1.inst_handle = *ch_info++;
-	vfe31_ctrl->outpath.out2.ch0 = 0x0000FFFF & *ch_info;
-	vfe31_ctrl->outpath.out2.ch1 = 0x0000FFFF & (*ch_info++ >> 16);
-	vfe31_ctrl->outpath.out2.ch2 = 0x0000FFFF & *ch_info++;
-	vfe31_ctrl->outpath.out2.inst_handle = *ch_info++;
-
-	switch (mode) {
-	case OUTPUT_PRIM:
-		vfe31_ctrl->outpath.output_mode =
-			VFE31_OUTPUT_MODE_PRIMARY;
-		break;
-	case OUTPUT_PRIM_ALL_CHNLS:
-		vfe31_ctrl->outpath.output_mode =
-			VFE31_OUTPUT_MODE_PRIMARY_ALL_CHNLS;
-		break;
-	case OUTPUT_PRIM|OUTPUT_SEC:
-		vfe31_ctrl->outpath.output_mode =
-			VFE31_OUTPUT_MODE_PRIMARY;
-		vfe31_ctrl->outpath.output_mode |=
-			VFE31_OUTPUT_MODE_SECONDARY;
-		break;
-	case OUTPUT_PRIM|OUTPUT_SEC_ALL_CHNLS:
-		vfe31_ctrl->outpath.output_mode =
-			VFE31_OUTPUT_MODE_PRIMARY;
-		vfe31_ctrl->outpath.output_mode |=
-			VFE31_OUTPUT_MODE_SECONDARY_ALL_CHNLS;
-		break;
-	case OUTPUT_PRIM_ALL_CHNLS|OUTPUT_SEC:
-		vfe31_ctrl->outpath.output_mode =
-			VFE31_OUTPUT_MODE_PRIMARY_ALL_CHNLS;
-		vfe31_ctrl->outpath.output_mode |=
-			VFE31_OUTPUT_MODE_SECONDARY;
-		break;
-	default:
-		pr_err("%s Invalid AXI mode %d ", __func__, mode);
-		return -EINVAL;
-	}
-
-	axi_cfg++;
-	msm_camera_io_memcpy(vfe31_ctrl->vfebase +
-		vfe31_cmd[VFE_CMD_AXI_OUT_CFG].offset, axi_cfg,
-		V31_AXI_BUS_CFG_LEN);
-	axi_cfg += V31_AXI_BUS_CFG_LEN/4;
-	for (i = 0; i < ARRAY_SIZE(vfe31_AXI_WM_CFG); i++) {
-		msm_camera_io_w(*axi_cfg,
-		vfe31_ctrl->vfebase+vfe31_AXI_WM_CFG[i]);
-		axi_cfg += 3;
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase+vfe31_AXI_WM_CFG[i]+12,
-							axi_cfg, 12);
-		axi_cfg += 3;
-	}
-	msm_camera_io_w(bus_cmd, vfe31_ctrl->vfebase +
-					V31_AXI_BUS_CMD_OFF);
-
-	return 0;
-}
-
-static void vfe31_reset_internal_variables(void)
-{
-	unsigned long flags;
-	vfe31_ctrl->vfeImaskCompositePacked = 0;
-	/* state control variables */
-	vfe31_ctrl->start_ack_pending = FALSE;
-	atomic_set(&irq_cnt, 0);
-
-	spin_lock_irqsave(&vfe31_ctrl->stop_flag_lock, flags);
-	vfe31_ctrl->stop_ack_pending  = FALSE;
-	spin_unlock_irqrestore(&vfe31_ctrl->stop_flag_lock, flags);
-
-	vfe31_ctrl->reset_ack_pending  = FALSE;
-
-	spin_lock_irqsave(&vfe31_ctrl->update_ack_lock, flags);
-	vfe31_ctrl->update_ack_pending = FALSE;
-	spin_unlock_irqrestore(&vfe31_ctrl->update_ack_lock, flags);
-
-	vfe31_ctrl->recording_state = VFE_STATE_IDLE;
-	vfe31_ctrl->liveshot_state = VFE_STATE_IDLE;
-
-	atomic_set(&vfe31_ctrl->vstate, 0);
-
-	/* 0 for continuous mode, 1 for snapshot mode */
-	vfe31_ctrl->operation_mode = 0;
-	vfe31_ctrl->outpath.output_mode = 0;
-	vfe31_ctrl->vfe_capture_count = 0;
-
-	/* this is unsigned 32 bit integer. */
-	vfe31_ctrl->vfeFrameId = 0;
-	/* Stats control variables. */
-	memset(&(vfe31_ctrl->afStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	memset(&(vfe31_ctrl->awbStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	memset(&(vfe31_ctrl->aecStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	memset(&(vfe31_ctrl->ihistStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	memset(&(vfe31_ctrl->rsStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	memset(&(vfe31_ctrl->csStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	vfe31_ctrl->frame_skip_cnt = 31;
-	vfe31_ctrl->frame_skip_pattern = 0xffffffff;
-	vfe31_ctrl->snapshot_frame_cnt = 0;
-}
-
-static void vfe31_reset(void)
-{
-	vfe31_reset_internal_variables();
-	/* disable all interrupts.  vfeImaskLocal is also reset to 0
-	* to begin with. */
-	msm_camera_io_w(VFE_DISABLE_ALL_IRQS,
-		vfe31_ctrl->vfebase + VFE_IRQ_MASK_0);
-
-	msm_camera_io_w(VFE_DISABLE_ALL_IRQS,
-		vfe31_ctrl->vfebase + VFE_IRQ_MASK_1);
-
-	/* clear all pending interrupts*/
-	msm_camera_io_w(VFE_CLEAR_ALL_IRQS,
-		vfe31_ctrl->vfebase + VFE_IRQ_CLEAR_0);
-	msm_camera_io_w(VFE_CLEAR_ALL_IRQS,
-		vfe31_ctrl->vfebase + VFE_IRQ_CLEAR_1);
-
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(1, vfe31_ctrl->vfebase + VFE_IRQ_CMD);
-
-	/* enable reset_ack interrupt.  */
-	msm_camera_io_w(VFE_IMASK_WHILE_STOPPING_1,
-	vfe31_ctrl->vfebase + VFE_IRQ_MASK_1);
-
-	/* Write to VFE_GLOBAL_RESET_CMD to reset the vfe hardware. Once reset
-	 * is done, hardware interrupt will be generated.  VFE ist processes
-	 * the interrupt to complete the function call.  Note that the reset
-	 * function is synchronous. */
-
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(VFE_RESET_UPON_RESET_CMD,
-		vfe31_ctrl->vfebase + VFE_GLOBAL_RESET);
-}
-
-static int vfe31_operation_config(uint32_t *cmd)
-{
-	uint32_t *p = cmd;
-
-	vfe31_ctrl->operation_mode = *p;
-	vfe31_ctrl->stats_comp = *(++p);
-	vfe31_ctrl->hfr_mode = *(++p);
-
-	msm_camera_io_w(*(++p), vfe31_ctrl->vfebase + VFE_CFG);
-	msm_camera_io_w(*(++p), vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-	msm_camera_io_w(*(++p), vfe31_ctrl->vfebase + VFE_REALIGN_BUF);
-	msm_camera_io_w(*(++p), vfe31_ctrl->vfebase + VFE_CHROMA_UP);
-	msm_camera_io_w(*(++p), vfe31_ctrl->vfebase + VFE_STATS_CFG);
-	return 0;
-}
-
-static void msm_camera_io_dump2(void __iomem *addr, int size)
-{
-	char line_str[BUFF_SIZE_128], *p_str;
-	int i;
-	u32 *p = (u32 *) addr;
-	u32 data;
-	CDBG("%s: %p %d\n", __func__, addr, size);
-	line_str[0] = '\0';
-	p_str = line_str;
-	for (i = 0; i < size/4; i++) {
-		if (i % 4 == 0) {
-			snprintf(p_str, 12, "%08x: ", (u32) p);
-			p_str += 10;
-		}
-		data = readl_relaxed(p++);
-		snprintf(p_str, 12, "%08x ", data);
-		p_str += 9;
-		if ((i + 1) % 4 == 0) {
-			CDBG("%s\n", line_str);
-			line_str[0] = '\0';
-			p_str = line_str;
-		}
-	}
-	if (line_str[0] != '\0')
-		CDBG("%s\n", line_str);
-}
-
-static void vfe31_start_common(void)
-{
-	uint32_t irq_mask = 0x00E00021;
-	vfe31_ctrl->start_ack_pending = TRUE;
-	CDBG("VFE opertaion mode = 0x%x, output mode = 0x%x\n",
-		vfe31_ctrl->operation_mode, vfe31_ctrl->outpath.output_mode);
-	if (vfe31_ctrl->stats_comp)
-		irq_mask |= VFE_IRQ_STATUS0_STATS_COMPOSIT_MASK;
-	else
-		irq_mask |= 0x000FE000;
-
-	msm_camera_io_w(irq_mask, vfe31_ctrl->vfebase + VFE_IRQ_MASK_0);
-	msm_camera_io_w(VFE_IMASK_WHILE_STOPPING_1,
-		vfe31_ctrl->vfebase + VFE_IRQ_MASK_1);
-
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(1, vfe31_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-	msm_camera_io_w_mb(1, vfe31_ctrl->vfebase + VFE_CAMIF_COMMAND);
-
-	msm_camera_io_dump2(vfe31_ctrl->vfebase, vfe31_ctrl->register_total*4);
-	atomic_set(&vfe31_ctrl->vstate, 1);
-}
-
-static int vfe31_start_recording(struct msm_cam_media_controller *pmctl)
-{
-	msm_camio_bus_scale_cfg(
-		pmctl->sdata->pdata->cam_bus_scale_table, S_VIDEO);
-	vfe31_ctrl->recording_state = VFE_STATE_START_REQUESTED;
-	msm_camera_io_w_mb(1, vfe31_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-	return 0;
-}
-
-static int vfe31_stop_recording(struct msm_cam_media_controller *pmctl)
-{
-	vfe31_ctrl->recording_state = VFE_STATE_STOP_REQUESTED;
-	msm_camera_io_w_mb(1, vfe31_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-	msm_camio_bus_scale_cfg(
-		pmctl->sdata->pdata->cam_bus_scale_table, S_PREVIEW);
-	return 0;
-}
-
-static void vfe31_start_liveshot(struct msm_cam_media_controller *pmctl)
-{
-	/* Hardcode 1 live snapshot for now. */
-	vfe31_ctrl->outpath.out0.capture_cnt = 1;
-	vfe31_ctrl->vfe_capture_count = vfe31_ctrl->outpath.out0.capture_cnt;
-
-	vfe31_ctrl->liveshot_state = VFE_STATE_START_REQUESTED;
-	msm_camera_io_w_mb(1, vfe31_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-}
-
-static int vfe31_zsl(struct msm_cam_media_controller *pmctl)
-{
-	uint32_t irq_comp_mask = 0;
-	/* capture command is valid for both idle and active state. */
-	irq_comp_mask	=
-		msm_camera_io_r(vfe31_ctrl->vfebase + VFE_IRQ_COMP_MASK);
-
-	CDBG("%s:op mode %d O/P Mode %d\n", __func__,
-		vfe31_ctrl->operation_mode, vfe31_ctrl->outpath.output_mode);
-
-	if (vfe31_ctrl->outpath.output_mode & VFE31_OUTPUT_MODE_PRIMARY) {
-		irq_comp_mask |= ((0x1 << (vfe31_ctrl->outpath.out0.ch0)) |
-			(0x1 << (vfe31_ctrl->outpath.out0.ch1)));
-	} else if (vfe31_ctrl->outpath.output_mode &
-		VFE31_OUTPUT_MODE_PRIMARY_ALL_CHNLS) {
-		irq_comp_mask |= ((0x1 << (vfe31_ctrl->outpath.out0.ch0)) |
-			(0x1 << (vfe31_ctrl->outpath.out0.ch1)) |
-			(0x1 << (vfe31_ctrl->outpath.out0.ch2)));
-	}
-
-	if (vfe31_ctrl->outpath.output_mode & VFE31_OUTPUT_MODE_SECONDARY) {
-		irq_comp_mask |= ((0x1 << (vfe31_ctrl->outpath.out1.ch0 + 8)) |
-			(0x1 << (vfe31_ctrl->outpath.out1.ch1 + 8)));
-	} else if (vfe31_ctrl->outpath.output_mode &
-		VFE31_OUTPUT_MODE_SECONDARY_ALL_CHNLS) {
-		irq_comp_mask |= ((0x1 << (vfe31_ctrl->outpath.out1.ch0 + 8)) |
-			(0x1 << (vfe31_ctrl->outpath.out1.ch1 + 8)) |
-			(0x1 << (vfe31_ctrl->outpath.out1.ch2 + 8)));
-	}
-
-	if (vfe31_ctrl->outpath.output_mode & VFE31_OUTPUT_MODE_PRIMARY) {
-		msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch0]);
-		msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch1]);
-	} else if (vfe31_ctrl->outpath.output_mode &
-		VFE31_OUTPUT_MODE_PRIMARY_ALL_CHNLS) {
-		msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch0]);
-		msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch1]);
-		msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch2]);
-	}
-
-	if (vfe31_ctrl->outpath.output_mode & VFE31_OUTPUT_MODE_SECONDARY) {
-		msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out1.ch0]);
-		msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out1.ch1]);
-	} else if (vfe31_ctrl->outpath.output_mode &
-		VFE31_OUTPUT_MODE_SECONDARY_ALL_CHNLS) {
-		msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out1.ch0]);
-		msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out1.ch1]);
-		msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out1.ch2]);
-	}
-
-	msm_camera_io_w(irq_comp_mask, vfe31_ctrl->vfebase + VFE_IRQ_COMP_MASK);
-	vfe31_start_common();
-	msm_camio_bus_scale_cfg(
-		pmctl->sdata->pdata->cam_bus_scale_table, S_ZSL);
-
-	msm_camera_io_w(1, vfe31_ctrl->vfebase + 0x18C);
-	msm_camera_io_w(1, vfe31_ctrl->vfebase + 0x188);
-	return 0;
-}
-static int vfe31_capture_raw(
-	struct msm_cam_media_controller *pmctl,
-	uint32_t num_frames_capture)
-{
-	uint32_t irq_comp_mask = 0;
-
-	vfe31_ctrl->outpath.out0.capture_cnt = num_frames_capture;
-	vfe31_ctrl->vfe_capture_count = num_frames_capture;
-
-	irq_comp_mask =
-		msm_camera_io_r(vfe31_ctrl->vfebase + VFE_IRQ_COMP_MASK);
-
-	if (vfe31_ctrl->outpath.output_mode & VFE31_OUTPUT_MODE_PRIMARY) {
-		irq_comp_mask |= (0x1 << (vfe31_ctrl->outpath.out0.ch0));
-		msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch0]);
-	}
-
-	msm_camera_io_w(irq_comp_mask, vfe31_ctrl->vfebase + VFE_IRQ_COMP_MASK);
-	msm_camio_bus_scale_cfg(
-		pmctl->sdata->pdata->cam_bus_scale_table, S_CAPTURE);
-	vfe31_start_common();
-	return 0;
-}
-
-static int vfe31_capture(
-	struct msm_cam_media_controller *pmctl,
-	uint32_t num_frames_capture)
-{
-	uint32_t irq_comp_mask = 0;
-	/* capture command is valid for both idle and active state. */
-	vfe31_ctrl->outpath.out1.capture_cnt = num_frames_capture;
-	if (vfe31_ctrl->operation_mode == VFE_OUTPUTS_MAIN_AND_THUMB ||
-		vfe31_ctrl->operation_mode == VFE_OUTPUTS_THUMB_AND_MAIN ||
-		vfe31_ctrl->operation_mode == VFE_OUTPUTS_JPEG_AND_THUMB ||
-		vfe31_ctrl->operation_mode == VFE_OUTPUTS_THUMB_AND_JPEG) {
-		vfe31_ctrl->outpath.out0.capture_cnt =
-			num_frames_capture;
-	}
-
-	vfe31_ctrl->vfe_capture_count = num_frames_capture;
-	irq_comp_mask = msm_camera_io_r(
-				vfe31_ctrl->vfebase + VFE_IRQ_COMP_MASK);
-
-	if (vfe31_ctrl->operation_mode == VFE_OUTPUTS_MAIN_AND_THUMB ||
-		vfe31_ctrl->operation_mode == VFE_OUTPUTS_JPEG_AND_THUMB ||
-		vfe31_ctrl->operation_mode == VFE_OUTPUTS_THUMB_AND_MAIN) {
-		if (vfe31_ctrl->outpath.output_mode &
-			VFE31_OUTPUT_MODE_PRIMARY) {
-			irq_comp_mask |= (0x1 << vfe31_ctrl->outpath.out0.ch0 |
-				0x1 << vfe31_ctrl->outpath.out0.ch1);
-		}
-		if (vfe31_ctrl->outpath.output_mode &
-			VFE31_OUTPUT_MODE_SECONDARY) {
-			irq_comp_mask |=
-				(0x1 << (vfe31_ctrl->outpath.out1.ch0 + 8) |
-				0x1 << (vfe31_ctrl->outpath.out1.ch1 + 8));
-		}
-		if (vfe31_ctrl->outpath.output_mode &
-			VFE31_OUTPUT_MODE_PRIMARY) {
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-				vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch0]);
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-				vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch1]);
-		}
-		if (vfe31_ctrl->outpath.output_mode &
-			VFE31_OUTPUT_MODE_SECONDARY) {
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-				vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out1.ch0]);
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-				vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out1.ch1]);
-		}
-	}
-
-	vfe31_ctrl->vfe_capture_count = num_frames_capture;
-
-	msm_camera_io_w(irq_comp_mask, vfe31_ctrl->vfebase + VFE_IRQ_COMP_MASK);
-	msm_camera_io_r(vfe31_ctrl->vfebase + VFE_IRQ_COMP_MASK);
-	msm_camio_bus_scale_cfg(
-		pmctl->sdata->pdata->cam_bus_scale_table, S_CAPTURE);
-
-	vfe31_start_common();
-	/* for debug */
-	msm_camera_io_w(1, vfe31_ctrl->vfebase + 0x18C);
-	msm_camera_io_w(1, vfe31_ctrl->vfebase + 0x188);
-	return 0;
-}
-
-static int vfe31_start(struct msm_cam_media_controller *pmctl)
-{
-	uint32_t irq_comp_mask = 0;
-
-	irq_comp_mask	=
-		msm_camera_io_r(vfe31_ctrl->vfebase + VFE_IRQ_COMP_MASK);
-
-	if (vfe31_ctrl->outpath.output_mode & VFE31_OUTPUT_MODE_PRIMARY) {
-		irq_comp_mask |= (0x1 << vfe31_ctrl->outpath.out0.ch0 |
-			0x1 << vfe31_ctrl->outpath.out0.ch1);
-	} else if (vfe31_ctrl->outpath.output_mode &
-		VFE31_OUTPUT_MODE_PRIMARY_ALL_CHNLS) {
-		irq_comp_mask |= (0x1 << vfe31_ctrl->outpath.out0.ch0 |
-			0x1 << vfe31_ctrl->outpath.out0.ch1 |
-			0x1 << vfe31_ctrl->outpath.out0.ch2);
-	}
-	if (vfe31_ctrl->outpath.output_mode & VFE31_OUTPUT_MODE_SECONDARY) {
-		irq_comp_mask |= (0x1 << (vfe31_ctrl->outpath.out1.ch0 + 8) |
-			0x1 << (vfe31_ctrl->outpath.out1.ch1 + 8));
-	} else if (vfe31_ctrl->outpath.output_mode &
-		VFE31_OUTPUT_MODE_SECONDARY_ALL_CHNLS) {
-		irq_comp_mask |= (0x1 << (vfe31_ctrl->outpath.out1.ch0 + 8) |
-			0x1 << (vfe31_ctrl->outpath.out1.ch1 + 8) |
-			0x1 << (vfe31_ctrl->outpath.out1.ch2 + 8));
-	}
-	msm_camera_io_w(irq_comp_mask, vfe31_ctrl->vfebase + VFE_IRQ_COMP_MASK);
-
-	switch (vfe31_ctrl->operation_mode) {
-	case VFE_OUTPUTS_PREVIEW:
-	case VFE_OUTPUTS_PREVIEW_AND_VIDEO:
-		if (vfe31_ctrl->outpath.output_mode &
-			VFE31_OUTPUT_MODE_PRIMARY) {
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch0]);
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch1]);
-		} else if (vfe31_ctrl->outpath.output_mode &
-			VFE31_OUTPUT_MODE_PRIMARY_ALL_CHNLS) {
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch0]);
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch1]);
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch2]);
-		}
-		break;
-	default:
-		if (vfe31_ctrl->outpath.output_mode &
-			VFE31_OUTPUT_MODE_SECONDARY) {
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out1.ch0]);
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out1.ch1]);
-		} else if (vfe31_ctrl->outpath.output_mode &
-			VFE31_OUTPUT_MODE_SECONDARY_ALL_CHNLS) {
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out1.ch0]);
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out1.ch1]);
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out1.ch2]);
-		}
-		break;
-	}
-	msm_camio_bus_scale_cfg(
-		pmctl->sdata->pdata->cam_bus_scale_table, S_PREVIEW);
-	vfe31_start_common();
-	return 0;
-}
-
-static void vfe31_update(void)
-{
-	unsigned long flags;
-
-	if (vfe31_ctrl->update_la) {
-		if (!msm_camera_io_r(vfe31_ctrl->vfebase + V31_LA_OFF))
-			msm_camera_io_w(1, vfe31_ctrl->vfebase + V31_LA_OFF);
-		else
-			msm_camera_io_w(0, vfe31_ctrl->vfebase + V31_LA_OFF);
-		vfe31_ctrl->update_la = false;
-	}
-
-	if (vfe31_ctrl->update_gamma) {
-		if (!msm_camera_io_r(vfe31_ctrl->vfebase + V31_RGB_G_OFF))
-			msm_camera_io_w(7, vfe31_ctrl->vfebase+V31_RGB_G_OFF);
-		else
-			msm_camera_io_w(0, vfe31_ctrl->vfebase+V31_RGB_G_OFF);
-		vfe31_ctrl->update_gamma = false;
-	}
-
-	spin_lock_irqsave(&vfe31_ctrl->update_ack_lock, flags);
-	vfe31_ctrl->update_ack_pending = TRUE;
-	spin_unlock_irqrestore(&vfe31_ctrl->update_ack_lock, flags);
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(1, vfe31_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-	return;
-}
-
-static void vfe31_sync_timer_stop(void)
-{
-	uint32_t value = 0;
-	vfe31_ctrl->sync_timer_state = 0;
-	if (vfe31_ctrl->sync_timer_number == 0)
-		value = 0x10000;
-	else if (vfe31_ctrl->sync_timer_number == 1)
-		value = 0x20000;
-	else if (vfe31_ctrl->sync_timer_number == 2)
-		value = 0x40000;
-
-	/* Timer Stop */
-	msm_camera_io_w(value, vfe31_ctrl->vfebase + V31_SYNC_TIMER_OFF);
-}
-
-static void vfe31_sync_timer_start(const uint32_t *tbl)
-{
-	/* set bit 8 for auto increment. */
-	uint32_t value = 1;
-	uint32_t val;
-
-	vfe31_ctrl->sync_timer_state = *tbl++;
-	vfe31_ctrl->sync_timer_repeat_count = *tbl++;
-	vfe31_ctrl->sync_timer_number = *tbl++;
-	CDBG("%s timer_state %d, repeat_cnt %d timer number %d\n",
-		 __func__, vfe31_ctrl->sync_timer_state,
-		 vfe31_ctrl->sync_timer_repeat_count,
-		 vfe31_ctrl->sync_timer_number);
-
-	if (vfe31_ctrl->sync_timer_state) { /* Start Timer */
-		value = value << vfe31_ctrl->sync_timer_number;
-	} else { /* Stop Timer */
-		CDBG("Failed to Start timer\n");
-		return;
-	}
-
-	/* Timer Start */
-	msm_camera_io_w(value, vfe31_ctrl->vfebase + V31_SYNC_TIMER_OFF);
-	/* Sync Timer Line Start */
-	value = *tbl++;
-	msm_camera_io_w(value, vfe31_ctrl->vfebase + V31_SYNC_TIMER_OFF +
-		4 + ((vfe31_ctrl->sync_timer_number) * 12));
-	/* Sync Timer Pixel Start */
-	value = *tbl++;
-	msm_camera_io_w(value, vfe31_ctrl->vfebase + V31_SYNC_TIMER_OFF +
-		 8 + ((vfe31_ctrl->sync_timer_number) * 12));
-	/* Sync Timer Pixel Duration */
-	value = *tbl++;
-	val = vfe_clk_rate / 10000;
-	val = 10000000 / val;
-	val = value * 10000 / val;
-	CDBG("%s: Pixel Clk Cycles!!! %d\n", __func__, val);
-	msm_camera_io_w(val, vfe31_ctrl->vfebase + V31_SYNC_TIMER_OFF +
-		12 + ((vfe31_ctrl->sync_timer_number) * 12));
-	/* Timer0 Active High/LOW */
-	value = *tbl++;
-	msm_camera_io_w(value,
-		vfe31_ctrl->vfebase + V31_SYNC_TIMER_POLARITY_OFF);
-	/* Selects sync timer 0 output to drive onto timer1 port */
-	value = 0;
-	msm_camera_io_w(value, vfe31_ctrl->vfebase + V31_TIMER_SELECT_OFF);
-}
-
-static void vfe31_program_dmi_cfg(enum VFE31_DMI_RAM_SEL bankSel)
-{
-	/* set bit 8 for auto increment. */
-	uint32_t value = VFE_DMI_CFG_DEFAULT;
-	value += (uint32_t)bankSel;
-	CDBG("%s: banksel = %d\n", __func__, bankSel);
-
-	msm_camera_io_w(value, vfe31_ctrl->vfebase + VFE_DMI_CFG);
-	/* by default, always starts with offset 0.*/
-	msm_camera_io_w(0, vfe31_ctrl->vfebase + VFE_DMI_ADDR);
-}
-static void vfe31_write_gamma_cfg(enum VFE31_DMI_RAM_SEL channel_sel,
-						const uint32_t *tbl)
-{
-	int i;
-	uint32_t value, value1, value2;
-	vfe31_program_dmi_cfg(channel_sel);
-	for (i = 0 ; i < (VFE31_GAMMA_NUM_ENTRIES/2) ; i++) {
-		value = *tbl++;
-		value1 = value & 0x0000FFFF;
-		value2 = (value & 0xFFFF0000)>>16;
-		msm_camera_io_w((value1),
-			vfe31_ctrl->vfebase + VFE_DMI_DATA_LO);
-		msm_camera_io_w((value2),
-			vfe31_ctrl->vfebase + VFE_DMI_DATA_LO);
-	}
-	vfe31_program_dmi_cfg(NO_MEM_SELECTED);
-}
-
-static void vfe31_read_gamma_cfg(enum VFE31_DMI_RAM_SEL channel_sel,
-	uint32_t *tbl)
-{
-	int i;
-	vfe31_program_dmi_cfg(channel_sel);
-	CDBG("%s: Gamma table channel: %d\n", __func__, channel_sel);
-	for (i = 0 ; i < VFE31_GAMMA_NUM_ENTRIES ; i++) {
-		*tbl = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_DMI_DATA_LO);
-		CDBG("%s: %08x\n", __func__, *tbl);
-		tbl++;
-	}
-	vfe31_program_dmi_cfg(NO_MEM_SELECTED);
-}
-
-static void vfe31_write_la_cfg(enum VFE31_DMI_RAM_SEL channel_sel,
-						const uint32_t *tbl)
-{
-	uint32_t i;
-	uint32_t value, value1, value2;
-
-	vfe31_program_dmi_cfg(channel_sel);
-	for (i = 0 ; i < (VFE31_LA_TABLE_LENGTH/2) ; i++) {
-		value = *tbl++;
-		value1 = value & 0x0000FFFF;
-		value2 = (value & 0xFFFF0000)>>16;
-		msm_camera_io_w((value1),
-			vfe31_ctrl->vfebase + VFE_DMI_DATA_LO);
-		msm_camera_io_w((value2),
-			vfe31_ctrl->vfebase + VFE_DMI_DATA_LO);
-	}
-	vfe31_program_dmi_cfg(NO_MEM_SELECTED);
-}
-
-static struct vfe31_output_ch *vfe31_get_ch(int path)
-{
-	struct vfe31_output_ch *ch = NULL;
-
-	if (path == VFE_MSG_OUTPUT_PRIMARY)
-		ch = &vfe31_ctrl->outpath.out0;
-	else if (path == VFE_MSG_OUTPUT_SECONDARY)
-		ch = &vfe31_ctrl->outpath.out1;
-	else
-		pr_err("%s: Invalid path %d\n", __func__, path);
-
-	BUG_ON(ch == NULL);
-	return ch;
-}
-static struct msm_free_buf *vfe31_check_free_buffer(int id, int path)
-{
-	struct vfe31_output_ch *outch = NULL;
-	struct msm_free_buf *b = NULL;
-	uint32_t inst_handle = 0;
-
-	if (path == VFE_MSG_OUTPUT_PRIMARY)
-		inst_handle = vfe31_ctrl->outpath.out0.inst_handle;
-	else
-		inst_handle = vfe31_ctrl->outpath.out1.inst_handle;
-
-	vfe31_subdev_notify(id, path, inst_handle);
-	outch = vfe31_get_ch(path);
-	if (outch->free_buf.ch_paddr[0])
-		b = &outch->free_buf;
-	return b;
-}
-static int vfe31_configure_pingpong_buffers(int id, int path)
-{
-	struct vfe31_output_ch *outch = NULL;
-	int rc = 0;
-	uint32_t inst_handle = 0;
-
-	if (path == VFE_MSG_OUTPUT_PRIMARY)
-		inst_handle = vfe31_ctrl->outpath.out0.inst_handle;
-	else
-		inst_handle = vfe31_ctrl->outpath.out1.inst_handle;
-
-	vfe31_subdev_notify(id, path, inst_handle);
-	outch = vfe31_get_ch(path);
-	if (outch->ping.ch_paddr[0] && outch->pong.ch_paddr[0]) {
-		/* Configure Preview Ping Pong */
-		CDBG("%s Configure ping/pong address for %d",
-			__func__, path);
-		vfe31_put_ch_ping_addr(outch->ch0,
-			outch->ping.ch_paddr[0]);
-		vfe31_put_ch_pong_addr(outch->ch0,
-			outch->pong.ch_paddr[0]);
-
-		if (vfe31_ctrl->operation_mode !=
-			VFE_OUTPUTS_RAW) {
-			vfe31_put_ch_ping_addr(outch->ch1,
-				outch->ping.ch_paddr[1]);
-			vfe31_put_ch_pong_addr(outch->ch1,
-				outch->pong.ch_paddr[1]);
-		}
-
-		if (outch->ping.num_planes > 2)
-			vfe31_put_ch_ping_addr(outch->ch2,
-				outch->ping.ch_paddr[2]);
-		if (outch->pong.num_planes > 2)
-			vfe31_put_ch_pong_addr(outch->ch2,
-				outch->pong.ch_paddr[2]);
-
-		/* avoid stale info */
-		memset(&outch->ping, 0, sizeof(struct msm_free_buf));
-		memset(&outch->pong, 0, sizeof(struct msm_free_buf));
-	} else {
-		pr_err("%s ping/pong addr is null!!", __func__);
-		rc = -EINVAL;
-	}
-	return rc;
-}
-
-static void vfe31_send_isp_msg(struct vfe31_ctrl_type *vctrl,
-	uint32_t isp_msg_id)
-{
-	struct isp_msg_event isp_msg_evt;
-
-	isp_msg_evt.msg_id = isp_msg_id;
-	isp_msg_evt.sof_count = vfe31_ctrl->vfeFrameId;
-	v4l2_subdev_notify(&vctrl->subdev,
-		NOTIFY_ISP_MSG_EVT, (void *)&isp_msg_evt);
-}
-
-static int vfe31_proc_general(
-	struct msm_cam_media_controller *pmctl,
-	struct msm_isp_cmd *cmd)
-{
-	int i , rc = 0;
-	uint32_t old_val = 0 , new_val = 0;
-	uint32_t *cmdp = NULL;
-	uint32_t *cmdp_local = NULL;
-	uint32_t snapshot_cnt = 0;
-	uint32_t temp1 = 0, temp2 = 0;
-
-	CDBG("vfe31_proc_general: cmdID = %s, length = %d\n",
-		vfe31_general_cmd[cmd->id], cmd->length);
-	switch (cmd->id) {
-	case VFE_CMD_RESET:
-		pr_info("vfe31_proc_general: cmdID = %s\n",
-			vfe31_general_cmd[cmd->id]);
-		vfe31_reset();
-		break;
-	case VFE_CMD_START:
-		pr_info("vfe31_proc_general: cmdID = %s\n",
-			vfe31_general_cmd[cmd->id]);
-		if ((vfe31_ctrl->operation_mode ==
-				VFE_OUTPUTS_PREVIEW_AND_VIDEO) ||
-			(vfe31_ctrl->operation_mode ==
-				VFE_OUTPUTS_PREVIEW))
-			/* Configure primary channel */
-			rc = vfe31_configure_pingpong_buffers(
-				VFE_MSG_START, VFE_MSG_OUTPUT_PRIMARY);
-		else
-			/* Configure secondary channel */
-			rc = vfe31_configure_pingpong_buffers(
-				VFE_MSG_START, VFE_MSG_OUTPUT_SECONDARY);
-		if (rc < 0) {
-			pr_err("%s error configuring pingpong buffers"
-				" for preview", __func__);
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		rc = vfe31_start(pmctl);
-		break;
-	case VFE_CMD_UPDATE:
-		vfe31_update();
-		break;
-	case VFE_CMD_CAPTURE_RAW:
-		pr_info("%s: cmdID = VFE_CMD_CAPTURE_RAW\n", __func__);
-		if (copy_from_user(&snapshot_cnt, (void __user *)(cmd->value),
-			sizeof(uint32_t))) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		rc = vfe31_configure_pingpong_buffers(VFE_MSG_CAPTURE,
-			VFE_MSG_OUTPUT_PRIMARY);
-		if (rc < 0) {
-			pr_err("%s error configuring pingpong buffers"
-				" for snapshot", __func__);
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		rc = vfe31_capture_raw(pmctl, snapshot_cnt);
-		break;
-	case VFE_CMD_CAPTURE:
-		if (copy_from_user(&snapshot_cnt, (void __user *)(cmd->value),
-			sizeof(uint32_t))) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-
-		if (vfe31_ctrl->operation_mode == VFE_OUTPUTS_JPEG_AND_THUMB ||
-		vfe31_ctrl->operation_mode == VFE_OUTPUTS_THUMB_AND_JPEG) {
-			if (snapshot_cnt != 1) {
-				pr_err("only support 1 inline snapshot\n");
-				rc = -EINVAL;
-				goto proc_general_done;
-			}
-			/* Configure primary channel for JPEG */
-			rc = vfe31_configure_pingpong_buffers(
-				VFE_MSG_JPEG_CAPTURE,
-				VFE_MSG_OUTPUT_PRIMARY);
-		} else {
-			/* Configure primary channel */
-			rc = vfe31_configure_pingpong_buffers(
-				VFE_MSG_CAPTURE,
-				VFE_MSG_OUTPUT_PRIMARY);
-		}
-		if (rc < 0) {
-			pr_err("%s error configuring pingpong buffers"
-				" for primary output", __func__);
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		/* Configure secondary channel */
-		rc = vfe31_configure_pingpong_buffers(VFE_MSG_CAPTURE,
-			VFE_MSG_OUTPUT_SECONDARY);
-		if (rc < 0) {
-			pr_err("%s error configuring pingpong buffers"
-				" for secondary output", __func__);
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		rc = vfe31_capture(pmctl, snapshot_cnt);
-		break;
-	case VFE_CMD_START_RECORDING:
-		pr_info("vfe31_proc_general: cmdID = %s\n",
-			vfe31_general_cmd[cmd->id]);
-		if (copy_from_user(&temp1, (void __user *)(cmd->value),
-				sizeof(uint32_t))) {
-			pr_err("%s Error copying inst_handle for recording\n",
-				__func__);
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		if (vfe31_ctrl->operation_mode ==
-			VFE_OUTPUTS_PREVIEW_AND_VIDEO) {
-			vfe31_ctrl->outpath.out1.inst_handle = temp1;
-			rc = vfe31_configure_pingpong_buffers(
-				VFE_MSG_START_RECORDING,
-				VFE_MSG_OUTPUT_SECONDARY);
-		} else if (vfe31_ctrl->operation_mode ==
-			VFE_OUTPUTS_VIDEO_AND_PREVIEW) {
-			vfe31_ctrl->outpath.out0.inst_handle = temp1;
-			rc = vfe31_configure_pingpong_buffers(
-				VFE_MSG_START_RECORDING,
-				VFE_MSG_OUTPUT_PRIMARY);
-		}
-		if (rc < 0) {
-			pr_err("%s error configuring pingpong buffers"
-				" for video", __func__);
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		rc = vfe31_start_recording(pmctl);
-		break;
-	case VFE_CMD_STOP_RECORDING:
-		pr_info("vfe31_proc_general: cmdID = %s\n",
-			vfe31_general_cmd[cmd->id]);
-		rc = vfe31_stop_recording(pmctl);
-		break;
-	case VFE_CMD_OPERATION_CFG:
-		if (cmd->length != V31_OPERATION_CFG_LEN) {
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(V31_OPERATION_CFG_LEN, GFP_ATOMIC);
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			V31_OPERATION_CFG_LEN)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		rc = vfe31_operation_config(cmdp);
-		break;
-
-	case VFE_CMD_STATS_AE_START:
-		rc = vfe_stats_aec_buf_init(NULL);
-		if (rc < 0) {
-			pr_err("%s: cannot config ping/pong address of AEC",
-				__func__);
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val |= AE_BG_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-		cmdp, (vfe31_cmd[cmd->id].length));
-		break;
-	case VFE_CMD_STATS_AF_START:
-		rc = vfe_stats_af_buf_init(NULL);
-		if (rc < 0) {
-			pr_err("%s: cannot config ping/pong address of AF",
-				__func__);
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val |= AF_BF_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-		cmdp, (vfe31_cmd[cmd->id].length));
-		break;
-	case VFE_CMD_STATS_AWB_START:
-		rc = vfe_stats_awb_buf_init(NULL);
-		if (rc < 0) {
-			pr_err("%s: cannot config ping/pong address of AWB",
-				__func__);
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val |= AWB_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-			cmdp, (vfe31_cmd[cmd->id].length));
-		break;
-
-	case VFE_CMD_STATS_IHIST_START:
-		rc = vfe_stats_ihist_buf_init(NULL);
-		if (rc < 0) {
-			pr_err("%s: cannot config ping/pong address of IHIST",
-			__func__);
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val |= IHIST_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-			cmdp, (vfe31_cmd[cmd->id].length));
-		break;
-
-	case VFE_CMD_STATS_RS_START:
-		rc = vfe_stats_rs_buf_init(NULL);
-		if (rc < 0) {
-			pr_err("%s: cannot config ping/pong address of RS",
-				__func__);
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-			cmdp, (vfe31_cmd[cmd->id].length));
-		break;
-
-	case VFE_CMD_STATS_CS_START:
-		rc = vfe_stats_cs_buf_init(NULL);
-		if (rc < 0) {
-			pr_err("%s: cannot config ping/pong address of CS",
-				__func__);
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-			cmdp, (vfe31_cmd[cmd->id].length));
-		break;
-
-	case VFE_CMD_MCE_UPDATE:
-	case VFE_CMD_MCE_CFG:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		/* Incrementing with 4 so as to point to the 2nd Register as
-		the 2nd register has the mce_enable bit */
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase +
-			V31_CHROMA_SUP_OFF + 4);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		new_val = *cmdp_local;
-		old_val &= MCE_EN_MASK;
-		new_val = new_val | old_val;
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + V31_CHROMA_SUP_OFF + 4,
-			&new_val, 4);
-		cmdp_local += 1;
-
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase +
-			V31_CHROMA_SUP_OFF + 8);
-		new_val = *cmdp_local;
-		old_val &= MCE_Q_K_MASK;
-		new_val = new_val | old_val;
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + V31_CHROMA_SUP_OFF + 8,
-			&new_val, 4);
-		cmdp_local += 1;
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-			cmdp_local, (vfe31_cmd[cmd->id].length));
-		break;
-	case VFE_CMD_CHROMA_SUP_UPDATE:
-	case VFE_CMD_CHROMA_SUP_CFG:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		msm_camera_io_memcpy(vfe31_ctrl->vfebase + V31_CHROMA_SUP_OFF,
-			cmdp_local, 4);
-
-		cmdp_local += 1;
-		new_val = *cmdp_local;
-		/* Incrementing with 4 so as to point to the 2nd Register as
-		 * the 2nd register has the mce_enable bit
-		 */
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase +
-			V31_CHROMA_SUP_OFF + 4);
-		old_val &= ~MCE_EN_MASK;
-		new_val = new_val | old_val;
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + V31_CHROMA_SUP_OFF + 4,
-			&new_val, 4);
-		cmdp_local += 1;
-
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase +
-			V31_CHROMA_SUP_OFF + 8);
-		new_val = *cmdp_local;
-		old_val &= ~MCE_Q_K_MASK;
-		new_val = new_val | old_val;
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + V31_CHROMA_SUP_OFF + 8,
-			&new_val, 4);
-		break;
-
-	case VFE_CMD_MESH_ROLL_OFF_CFG:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value) , cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-			cmdp_local, 16);
-		cmdp_local += 4;
-		vfe31_program_dmi_cfg(ROLLOFF_RAM);
-		/* for loop for extrcting init table. */
-		for (i = 0; i < (V31_MESH_ROLL_OFF_INIT_TABLE_SIZE * 2); i++) {
-			msm_camera_io_w(*cmdp_local ,
-			vfe31_ctrl->vfebase + VFE_DMI_DATA_LO);
-			cmdp_local++;
-		}
-		CDBG("done writing init table\n");
-		/* by default, always starts with offset 0. */
-		msm_camera_io_w(V31_MESH_ROLL_OFF_DELTA_TABLE_OFFSET,
-		vfe31_ctrl->vfebase + VFE_DMI_ADDR);
-		/* for loop for extracting delta table. */
-		for (i = 0; i < (V31_MESH_ROLL_OFF_DELTA_TABLE_SIZE * 2); i++) {
-			msm_camera_io_w(*cmdp_local,
-			vfe31_ctrl->vfebase + VFE_DMI_DATA_LO);
-			cmdp_local++;
-		}
-		vfe31_program_dmi_cfg(NO_MEM_SELECTED);
-		break;
-
-	case VFE_CMD_GET_MESH_ROLLOFF_TABLE:
-		temp1 = sizeof(uint32_t) * ((V31_MESH_ROLL_OFF_INIT_TABLE_SIZE *
-			2) + (V31_MESH_ROLL_OFF_DELTA_TABLE_SIZE * 2));
-		if (cmd->length != temp1) {
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		cmdp = kzalloc(temp1, GFP_KERNEL);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		vfe31_program_dmi_cfg(ROLLOFF_RAM);
-		CDBG("%s: Mesh Rolloff init Table\n", __func__);
-		for (i = 0; i < (V31_MESH_ROLL_OFF_INIT_TABLE_SIZE * 2); i++) {
-			*cmdp_local = msm_camera_io_r(
-					vfe31_ctrl->vfebase + VFE_DMI_DATA_LO);
-			CDBG("%s: %08x\n", __func__, *cmdp_local);
-			cmdp_local++;
-		}
-		msm_camera_io_w(V31_MESH_ROLL_OFF_DELTA_TABLE_OFFSET,
-			vfe31_ctrl->vfebase + VFE_DMI_ADDR);
-		CDBG("%s: Mesh Rolloff Delta Table\n", __func__);
-		for (i = 0; i < (V31_MESH_ROLL_OFF_DELTA_TABLE_SIZE * 2); i++) {
-			*cmdp_local = msm_camera_io_r(
-					vfe31_ctrl->vfebase + VFE_DMI_DATA_LO);
-			CDBG("%s: %08x\n", __func__, *cmdp_local);
-			cmdp_local++;
-		}
-		CDBG("done reading delta table\n");
-		vfe31_program_dmi_cfg(NO_MEM_SELECTED);
-		if (copy_to_user((void __user *)(cmd->value), cmdp,
-			temp1)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		break;
-	case VFE_CMD_LA_CFG:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-			cmdp_local, (vfe31_cmd[cmd->id].length));
-
-		cmdp_local += 1;
-		vfe31_write_la_cfg(LUMA_ADAPT_LUT_RAM_BANK0, cmdp_local);
-		break;
-
-	case VFE_CMD_LA_UPDATE:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-
-		cmdp_local = cmdp + 1;
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + V31_LA_OFF);
-		if (old_val != 0x0)
-			vfe31_write_la_cfg(LUMA_ADAPT_LUT_RAM_BANK0,
-				cmdp_local);
-		else
-			vfe31_write_la_cfg(LUMA_ADAPT_LUT_RAM_BANK1,
-				cmdp_local);
-		vfe31_ctrl->update_la = true;
-		break;
-
-	case VFE_CMD_GET_LA_TABLE:
-		temp1 = sizeof(uint32_t) * VFE31_LA_TABLE_LENGTH / 2;
-		if (cmd->length != temp1) {
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		cmdp = kzalloc(temp1, GFP_KERNEL);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		if (msm_camera_io_r(vfe31_ctrl->vfebase + V31_LA_OFF))
-			vfe31_program_dmi_cfg(LUMA_ADAPT_LUT_RAM_BANK1);
-		else
-			vfe31_program_dmi_cfg(LUMA_ADAPT_LUT_RAM_BANK0);
-		for (i = 0 ; i < (VFE31_LA_TABLE_LENGTH / 2) ; i++) {
-			*cmdp_local = msm_camera_io_r(
-					vfe31_ctrl->vfebase + VFE_DMI_DATA_LO);
-			*cmdp_local |= (msm_camera_io_r(vfe31_ctrl->vfebase +
-				VFE_DMI_DATA_LO)) << 16;
-			cmdp_local++;
-		}
-		vfe31_program_dmi_cfg(NO_MEM_SELECTED);
-		if (copy_to_user((void __user *)(cmd->value), cmdp,
-			temp1)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		break;
-	case VFE_CMD_SK_ENHAN_CFG:
-	case VFE_CMD_SK_ENHAN_UPDATE:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(vfe31_ctrl->vfebase + V31_SCE_OFF,
-			cmdp, V31_SCE_LEN);
-		break;
-
-	case VFE_CMD_LIVESHOT:
-		if (copy_from_user(&temp1, (void __user *)(cmd->value),
-				sizeof(uint32_t))) {
-			pr_err("%s Error copying inst_handle for liveshot ",
-				__func__);
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		vfe31_ctrl->outpath.out0.inst_handle = temp1;
-		/* Configure primary channel */
-		rc = vfe31_configure_pingpong_buffers(VFE_MSG_CAPTURE,
-			VFE_MSG_OUTPUT_PRIMARY);
-		if (rc < 0) {
-			pr_err("%s error configuring pingpong buffers"
-				" for primary output", __func__);
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		vfe31_start_liveshot(pmctl);
-		break;
-
-	case VFE_CMD_DEMOSAICV3:
-		if (cmd->length != V31_DEMOSAICV3_LEN) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		new_val = *cmdp_local;
-
-		old_val = msm_camera_io_r(
-				vfe31_ctrl->vfebase + V31_DEMOSAICV3_OFF);
-		old_val &= DEMOSAIC_MASK;
-		new_val = new_val | old_val;
-		*cmdp_local = new_val;
-
-		msm_camera_io_memcpy(vfe31_ctrl->vfebase + V31_DEMOSAICV3_OFF,
-			cmdp_local, V31_DEMOSAICV3_LEN);
-		break;
-
-	case VFE_CMD_DEMOSAICV3_UPDATE:
-		if (cmd->length !=
-			V31_DEMOSAICV3_LEN * V31_DEMOSAICV3_UP_REG_CNT) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		new_val = *cmdp_local;
-
-		old_val = msm_camera_io_r(
-				vfe31_ctrl->vfebase + V31_DEMOSAICV3_OFF);
-		old_val &= DEMOSAIC_MASK;
-		new_val = new_val | old_val;
-		*cmdp_local = new_val;
-
-		msm_camera_io_memcpy(vfe31_ctrl->vfebase + V31_DEMOSAICV3_OFF,
-			cmdp_local, V31_DEMOSAICV3_LEN);
-
-		break;
-
-	case VFE_CMD_DEMOSAICV3_ABCC_CFG:
-		rc = -EFAULT;
-		break;
-
-	case VFE_CMD_DEMOSAICV3_ABF_UPDATE:/* 116 ABF update  */
-	case VFE_CMD_DEMOSAICV3_ABF_CFG: /* 108 ABF config  */
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		new_val = *cmdp_local;
-
-		old_val = msm_camera_io_r(
-				vfe31_ctrl->vfebase + V31_DEMOSAICV3_OFF);
-		old_val &= ABF_MASK;
-		new_val = new_val | old_val;
-		*cmdp_local = new_val;
-
-		msm_camera_io_memcpy(vfe31_ctrl->vfebase + V31_DEMOSAICV3_OFF,
-		    cmdp_local, 4);
-
-		cmdp_local += 1;
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-			cmdp_local, (vfe31_cmd[cmd->id].length));
-		break;
-
-	case VFE_CMD_DEMOSAICV3_DBCC_CFG:
-	case VFE_CMD_DEMOSAICV3_DBCC_UPDATE:
-		return -EINVAL;
-
-	case VFE_CMD_DEMOSAICV3_DBPC_CFG:
-	case VFE_CMD_DEMOSAICV3_DBPC_UPDATE:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		new_val = *cmdp_local;
-
-		old_val = msm_camera_io_r(
-				vfe31_ctrl->vfebase + V31_DEMOSAICV3_OFF);
-		old_val &= BPC_MASK;
-
-		new_val = new_val | old_val;
-		*cmdp_local = new_val;
-		msm_camera_io_memcpy(vfe31_ctrl->vfebase + V31_DEMOSAICV3_OFF,
-					cmdp_local, V31_DEMOSAICV3_LEN);
-		cmdp_local += 1;
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + V31_DEMOSAICV3_DBPC_CFG_OFF,
-			cmdp_local, V31_DEMOSAICV3_DBPC_LEN);
-		break;
-
-	case VFE_CMD_RGB_G_CFG:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(vfe31_ctrl->vfebase + V31_RGB_G_OFF,
-			cmdp, 4);
-		cmdp += 1;
-
-		vfe31_write_gamma_cfg(RGBLUT_RAM_CH0_BANK0, cmdp);
-		vfe31_write_gamma_cfg(RGBLUT_RAM_CH1_BANK0, cmdp);
-		vfe31_write_gamma_cfg(RGBLUT_RAM_CH2_BANK0, cmdp);
-		cmdp -= 1;
-		break;
-
-	case VFE_CMD_RGB_G_UPDATE:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp, (void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + V31_RGB_G_OFF);
-		cmdp += 1;
-		if (old_val != 0x0) {
-			vfe31_write_gamma_cfg(RGBLUT_RAM_CH0_BANK0, cmdp);
-			vfe31_write_gamma_cfg(RGBLUT_RAM_CH1_BANK0, cmdp);
-			vfe31_write_gamma_cfg(RGBLUT_RAM_CH2_BANK0, cmdp);
-		} else {
-			vfe31_write_gamma_cfg(RGBLUT_RAM_CH0_BANK1, cmdp);
-			vfe31_write_gamma_cfg(RGBLUT_RAM_CH1_BANK1, cmdp);
-			vfe31_write_gamma_cfg(RGBLUT_RAM_CH2_BANK1, cmdp);
-		}
-		vfe31_ctrl->update_gamma = TRUE;
-		cmdp -= 1;
-		break;
-
-	case VFE_CMD_GET_RGB_G_TABLE:
-		temp1 = sizeof(uint32_t) * VFE31_GAMMA_NUM_ENTRIES * 3;
-		if (cmd->length != temp1) {
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		cmdp = kzalloc(temp1, GFP_KERNEL);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + V31_RGB_G_OFF);
-		temp2 = old_val ? RGBLUT_RAM_CH0_BANK1 :
-			RGBLUT_RAM_CH0_BANK0;
-		for (i = 0; i < 3; i++) {
-			vfe31_read_gamma_cfg(temp2,
-				cmdp_local + (VFE31_GAMMA_NUM_ENTRIES * i));
-			temp2 += 2;
-		}
-		if (copy_to_user((void __user *)(cmd->value), cmdp,
-			temp1)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		break;
-
-	case VFE_CMD_STATS_AWB_STOP:
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~AWB_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		break;
-	case VFE_CMD_STATS_AE_STOP:
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~AE_BG_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		break;
-	case VFE_CMD_STATS_AF_STOP:
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~AF_BF_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		rc = vfe31_stats_flush_enqueue(MSM_STATS_TYPE_AF);
-		if (rc < 0) {
-			pr_err("%s: dq stats buf err = %d",
-				   __func__, rc);
-			return -EINVAL;
-		}
-		break;
-
-	case VFE_CMD_STATS_IHIST_STOP:
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~IHIST_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		break;
-
-	case VFE_CMD_STATS_RS_STOP:
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~RS_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		break;
-
-	case VFE_CMD_STATS_CS_STOP:
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~CS_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		break;
-
-	case VFE_CMD_STOP:
-		pr_info("vfe31_proc_general: cmdID = %s\n",
-			vfe31_general_cmd[cmd->id]);
-		vfe31_stop();
-		break;
-
-	case VFE_CMD_SYNC_TIMER_SETTING:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp, (void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		vfe31_sync_timer_start(cmdp);
-		break;
-
-	case VFE_CMD_MODULE_CFG:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		*cmdp &= ~STATS_ENABLE_MASK;
-		old_val = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= STATS_ENABLE_MASK;
-		*cmdp |= old_val;
-
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-			cmdp, (vfe31_cmd[cmd->id].length));
-		break;
-
-	case VFE_CMD_ZSL:
-		rc = vfe31_configure_pingpong_buffers(VFE_MSG_START,
-			VFE_MSG_OUTPUT_PRIMARY);
-		if (rc < 0)
-			goto proc_general_done;
-		rc = vfe31_configure_pingpong_buffers(VFE_MSG_START,
-			VFE_MSG_OUTPUT_SECONDARY);
-		if (rc < 0)
-			goto proc_general_done;
-
-		rc = vfe31_zsl(pmctl);
-		break;
-
-	case VFE_CMD_ASF_CFG:
-	case VFE_CMD_ASF_UPDATE:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp, (void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-			cmdp, (vfe31_cmd[cmd->id].length));
-		cmdp_local = cmdp + V31_ASF_LEN/4;
-		break;
-
-	case VFE_CMD_GET_HW_VERSION:
-		if (cmd->length != V31_GET_HW_VERSION_LEN) {
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(V31_GET_HW_VERSION_LEN, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		*cmdp = msm_camera_io_r(
-				vfe31_ctrl->vfebase+V31_GET_HW_VERSION_OFF);
-		if (copy_to_user((void __user *)(cmd->value), cmdp,
-			V31_GET_HW_VERSION_LEN)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		break;
-	case VFE_CMD_GET_REG_DUMP:
-		temp1 = sizeof(uint32_t) * vfe31_ctrl->register_total;
-		if (cmd->length != temp1) {
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(temp1, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		msm_camera_io_dump(
-			vfe31_ctrl->vfebase, vfe31_ctrl->register_total*4);
-		CDBG("%s: %p %p %d\n", __func__, (void *)cmdp,
-			vfe31_ctrl->vfebase, temp1);
-		memcpy_fromio((void *)cmdp, vfe31_ctrl->vfebase, temp1);
-		if (copy_to_user((void __user *)(cmd->value), cmdp, temp1)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		break;
-	case VFE_CMD_FRAME_SKIP_CFG:
-		if (cmd->length != vfe31_cmd[cmd->id].length)
-			return -EINVAL;
-
-		cmdp = kmalloc(vfe31_cmd[cmd->id].length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-
-		if (copy_from_user(cmdp, (void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-			cmdp, (vfe31_cmd[cmd->id].length));
-		vfe31_ctrl->frame_skip_cnt = ((uint32_t)
-			*cmdp & VFE_FRAME_SKIP_PERIOD_MASK) + 1;
-		vfe31_ctrl->frame_skip_pattern = (uint32_t)(*(cmdp + 2));
-		break;
-	default:
-		if (cmd->length != vfe31_cmd[cmd->id].length)
-			return -EINVAL;
-
-		cmdp = kmalloc(vfe31_cmd[cmd->id].length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-
-		if (copy_from_user(cmdp, (void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(
-			vfe31_ctrl->vfebase + vfe31_cmd[cmd->id].offset,
-			cmdp, (vfe31_cmd[cmd->id].length));
-		break;
-
-	}
-
-proc_general_done:
-	kfree(cmdp);
-
-	return rc;
-}
-
-static inline void vfe31_read_irq_status(struct vfe31_irq_status *out)
-{
-	uint32_t *temp;
-	memset(out, 0, sizeof(struct vfe31_irq_status));
-	temp = (uint32_t *)(vfe31_ctrl->vfebase + VFE_IRQ_STATUS_0);
-	out->vfeIrqStatus0 = msm_camera_io_r(temp);
-
-	temp = (uint32_t *)(vfe31_ctrl->vfebase + VFE_IRQ_STATUS_1);
-	out->vfeIrqStatus1 = msm_camera_io_r(temp);
-
-	temp = (uint32_t *)(vfe31_ctrl->vfebase + VFE_CAMIF_STATUS);
-	out->camifStatus = msm_camera_io_r(temp);
-	CDBG("camifStatus  = 0x%x\n", out->camifStatus);
-
-	/* clear the pending interrupt of the same kind.*/
-	msm_camera_io_w(out->vfeIrqStatus0,
-		vfe31_ctrl->vfebase + VFE_IRQ_CLEAR_0);
-	msm_camera_io_w(out->vfeIrqStatus1,
-		vfe31_ctrl->vfebase + VFE_IRQ_CLEAR_1);
-
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(1, vfe31_ctrl->vfebase + VFE_IRQ_CMD);
-
-}
-
-static void vfe31_process_reg_update_irq(void)
-{
-	unsigned long flags;
-
-	if (vfe31_ctrl->recording_state == VFE_STATE_START_REQUESTED) {
-		if (vfe31_ctrl->operation_mode ==
-			VFE_OUTPUTS_VIDEO_AND_PREVIEW) {
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch0]);
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch1]);
-		} else if (vfe31_ctrl->operation_mode ==
-			VFE_OUTPUTS_PREVIEW_AND_VIDEO) {
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out1.ch0]);
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out1.ch1]);
-		}
-		vfe31_ctrl->recording_state = VFE_STATE_STARTED;
-		msm_camera_io_w_mb(1, vfe31_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-		CDBG("start video triggered .\n");
-	} else if (vfe31_ctrl->recording_state ==
-		VFE_STATE_STOP_REQUESTED) {
-		if (vfe31_ctrl->operation_mode ==
-			VFE_OUTPUTS_VIDEO_AND_PREVIEW) {
-			msm_camera_io_w(0, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch0]);
-			msm_camera_io_w(0, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch1]);
-		} else if (vfe31_ctrl->operation_mode ==
-			VFE_OUTPUTS_PREVIEW_AND_VIDEO) {
-			msm_camera_io_w(0, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out1.ch0]);
-			msm_camera_io_w(0, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out1.ch1]);
-		}
-		CDBG("stop video triggered .\n");
-	}
-
-	if (vfe31_ctrl->start_ack_pending == TRUE) {
-		vfe31_send_isp_msg(vfe31_ctrl, MSG_ID_START_ACK);
-		vfe31_ctrl->start_ack_pending = FALSE;
-	} else {
-		if (vfe31_ctrl->recording_state ==
-			VFE_STATE_STOP_REQUESTED) {
-			vfe31_ctrl->recording_state = VFE_STATE_STOPPED;
-			/* request a reg update and send STOP_REC_ACK
-			 * when we process the next reg update irq.
-			 */
-			msm_camera_io_w_mb(1,
-			vfe31_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-		} else if (vfe31_ctrl->recording_state ==
-			VFE_STATE_STOPPED) {
-			vfe31_send_isp_msg(vfe31_ctrl, MSG_ID_STOP_REC_ACK);
-			vfe31_ctrl->recording_state = VFE_STATE_IDLE;
-		}
-		spin_lock_irqsave(&vfe31_ctrl->update_ack_lock, flags);
-		if (vfe31_ctrl->update_ack_pending == TRUE) {
-			vfe31_ctrl->update_ack_pending = FALSE;
-			spin_unlock_irqrestore(
-				&vfe31_ctrl->update_ack_lock, flags);
-			vfe31_send_isp_msg(vfe31_ctrl, MSG_ID_UPDATE_ACK);
-		} else {
-			spin_unlock_irqrestore(
-				&vfe31_ctrl->update_ack_lock, flags);
-		}
-	}
-
-	if (vfe31_ctrl->liveshot_state == VFE_STATE_START_REQUESTED) {
-		pr_info("%s enabling liveshot output\n", __func__);
-		if (vfe31_ctrl->outpath.output_mode &
-			VFE31_OUTPUT_MODE_PRIMARY) {
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch0]);
-			msm_camera_io_w(1, vfe31_ctrl->vfebase +
-			vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch1]);
-			vfe31_ctrl->liveshot_state = VFE_STATE_STARTED;
-		}
-	}
-
-	if (vfe31_ctrl->liveshot_state == VFE_STATE_STARTED) {
-		vfe31_ctrl->vfe_capture_count--;
-		if (!vfe31_ctrl->vfe_capture_count)
-			vfe31_ctrl->liveshot_state = VFE_STATE_STOP_REQUESTED;
-		msm_camera_io_w_mb(1, vfe31_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-	} else if (vfe31_ctrl->liveshot_state == VFE_STATE_STOP_REQUESTED) {
-		CDBG("%s: disabling liveshot output\n", __func__);
-		if (vfe31_ctrl->outpath.output_mode &
-			VFE31_OUTPUT_MODE_PRIMARY) {
-			msm_camera_io_w(0, vfe31_ctrl->vfebase +
-				vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch0]);
-			msm_camera_io_w(0, vfe31_ctrl->vfebase +
-				vfe31_AXI_WM_CFG[vfe31_ctrl->outpath.out0.ch1]);
-			vfe31_ctrl->liveshot_state = VFE_STATE_STOPPED;
-			msm_camera_io_w_mb(1, vfe31_ctrl->vfebase +
-				VFE_REG_UPDATE_CMD);
-		}
-	} else if (vfe31_ctrl->liveshot_state == VFE_STATE_STOPPED) {
-		vfe31_ctrl->liveshot_state = VFE_STATE_IDLE;
-	}
-
-	if ((vfe31_ctrl->operation_mode == VFE_OUTPUTS_THUMB_AND_MAIN) ||
-		(vfe31_ctrl->operation_mode == VFE_OUTPUTS_MAIN_AND_THUMB) ||
-		(vfe31_ctrl->operation_mode == VFE_OUTPUTS_THUMB_AND_JPEG) ||
-		(vfe31_ctrl->operation_mode == VFE_OUTPUTS_JPEG_AND_THUMB)) {
-		/* in snapshot mode */
-		/* later we need to add check for live snapshot mode. */
-		if (vfe31_ctrl->frame_skip_pattern & (0x1 <<
-			(vfe31_ctrl->snapshot_frame_cnt %
-				vfe31_ctrl->frame_skip_cnt))) {
-			/* if last frame to be captured: */
-			if (vfe31_ctrl->vfe_capture_count == 0) {
-				/* stop the bus output:write master enable = 0*/
-				if (vfe31_ctrl->outpath.output_mode &
-					VFE31_OUTPUT_MODE_PRIMARY) {
-					msm_camera_io_w(0, vfe31_ctrl->vfebase +
-						vfe31_AXI_WM_CFG[vfe31_ctrl->
-						outpath.out0.ch0]);
-					msm_camera_io_w(0, vfe31_ctrl->vfebase +
-						vfe31_AXI_WM_CFG[vfe31_ctrl->
-						outpath.out0.ch1]);
-				}
-				if (vfe31_ctrl->outpath.output_mode &
-					VFE31_OUTPUT_MODE_SECONDARY) {
-					msm_camera_io_w(0, vfe31_ctrl->vfebase +
-						vfe31_AXI_WM_CFG[vfe31_ctrl->
-						outpath.out1.ch0]);
-					msm_camera_io_w(0, vfe31_ctrl->vfebase +
-						vfe31_AXI_WM_CFG[vfe31_ctrl->
-						outpath.out1.ch1]);
-				}
-				msm_camera_io_w_mb
-				(CAMIF_COMMAND_STOP_AT_FRAME_BOUNDARY,
-				vfe31_ctrl->vfebase + VFE_CAMIF_COMMAND);
-				vfe31_ctrl->snapshot_frame_cnt = -1;
-				vfe31_ctrl->frame_skip_cnt = 31;
-				vfe31_ctrl->frame_skip_pattern = 0xffffffff;
-			} /*if snapshot count is 0*/
-		} /*if frame is not being dropped*/
-		/* then do reg_update. */
-		msm_camera_io_w(1, vfe31_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-	} /* if snapshot mode. */
-}
-
-static void vfe31_set_default_reg_values(void)
-{
-	msm_camera_io_w(0x800080, vfe31_ctrl->vfebase + VFE_DEMUX_GAIN_0);
-	msm_camera_io_w(0x800080, vfe31_ctrl->vfebase + VFE_DEMUX_GAIN_1);
-	/* What value should we program CGC_OVERRIDE to? */
-	msm_camera_io_w(0xFFFFF, vfe31_ctrl->vfebase + VFE_CGC_OVERRIDE);
-
-	/* default frame drop period and pattern */
-	msm_camera_io_w(0x1f, vfe31_ctrl->vfebase + VFE_FRAMEDROP_ENC_Y_CFG);
-	msm_camera_io_w(0x1f, vfe31_ctrl->vfebase + VFE_FRAMEDROP_ENC_CBCR_CFG);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe31_ctrl->vfebase + VFE_FRAMEDROP_ENC_Y_PATTERN);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe31_ctrl->vfebase + VFE_FRAMEDROP_ENC_CBCR_PATTERN);
-	msm_camera_io_w(0x1f, vfe31_ctrl->vfebase + VFE_FRAMEDROP_VIEW_Y);
-	msm_camera_io_w(0x1f, vfe31_ctrl->vfebase + VFE_FRAMEDROP_VIEW_CBCR);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe31_ctrl->vfebase + VFE_FRAMEDROP_VIEW_Y_PATTERN);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe31_ctrl->vfebase + VFE_FRAMEDROP_VIEW_CBCR_PATTERN);
-	msm_camera_io_w(0, vfe31_ctrl->vfebase + VFE_CLAMP_MIN);
-	msm_camera_io_w(0xFFFFFF, vfe31_ctrl->vfebase + VFE_CLAMP_MAX);
-
-	/* stats UB config */
-	msm_camera_io_w(0x3980007,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_AEC_UB_CFG);
-	msm_camera_io_w(0x3A00007,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_AF_UB_CFG);
-	msm_camera_io_w(0x3A8000F,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_AWB_UB_CFG);
-	msm_camera_io_w(0x3B80007,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_RS_UB_CFG);
-	msm_camera_io_w(0x3C0001F,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_CS_UB_CFG);
-	msm_camera_io_w(0x3E0001F,
-		vfe31_ctrl->vfebase + VFE_BUS_STATS_HIST_UB_CFG);
-}
-
-static void vfe31_process_reset_irq(void)
-{
-	unsigned long flags;
-
-	atomic_set(&vfe31_ctrl->vstate, 0);
-
-	spin_lock_irqsave(&vfe31_ctrl->stop_flag_lock, flags);
-	if (vfe31_ctrl->stop_ack_pending) {
-		vfe31_ctrl->stop_ack_pending = FALSE;
-		spin_unlock_irqrestore(&vfe31_ctrl->stop_flag_lock, flags);
-		vfe31_send_isp_msg(vfe31_ctrl, MSG_ID_STOP_ACK);
-	} else {
-		spin_unlock_irqrestore(&vfe31_ctrl->stop_flag_lock, flags);
-		/* this is from reset command. */
-		vfe31_set_default_reg_values();
-
-		/* reload all write masters. (frame & line)*/
-		msm_camera_io_w(0x7FFF, vfe31_ctrl->vfebase + VFE_BUS_CMD);
-		vfe31_send_isp_msg(vfe31_ctrl, MSG_ID_RESET_ACK);
-	}
-}
-
-static void vfe31_process_camif_sof_irq(void)
-{
-	if (vfe31_ctrl->operation_mode ==
-		VFE_OUTPUTS_RAW) {
-		if (vfe31_ctrl->start_ack_pending) {
-			vfe31_send_isp_msg(vfe31_ctrl, MSG_ID_START_ACK);
-			vfe31_ctrl->start_ack_pending = FALSE;
-		}
-		vfe31_ctrl->vfe_capture_count--;
-		/* if last frame to be captured: */
-		if (vfe31_ctrl->vfe_capture_count == 0) {
-			/* Ensure the write order while writing
-			 to the command register using the barrier */
-			msm_camera_io_w_mb(CAMIF_COMMAND_STOP_AT_FRAME_BOUNDARY,
-				vfe31_ctrl->vfebase + VFE_CAMIF_COMMAND);
-		}
-	} /* if raw snapshot mode. */
-	if ((vfe31_ctrl->hfr_mode != HFR_MODE_OFF) &&
-		(vfe31_ctrl->operation_mode == VFE_MODE_OF_OPERATION_VIDEO) &&
-		(vfe31_ctrl->vfeFrameId % vfe31_ctrl->hfr_mode != 0)) {
-		vfe31_ctrl->vfeFrameId++;
-		CDBG("Skip the SOF notification when HFR enabled\n");
-		return;
-	}
-	vfe31_ctrl->vfeFrameId++;
-	vfe31_send_isp_msg(vfe31_ctrl, MSG_ID_SOF_ACK);
-	CDBG("camif_sof_irq, frameId = %d\n", vfe31_ctrl->vfeFrameId);
-
-	if (vfe31_ctrl->sync_timer_state) {
-		if (vfe31_ctrl->sync_timer_repeat_count == 0)
-			vfe31_sync_timer_stop();
-		else
-			vfe31_ctrl->sync_timer_repeat_count--;
-	}
-	if ((vfe31_ctrl->operation_mode == VFE_OUTPUTS_THUMB_AND_MAIN) ||
-		(vfe31_ctrl->operation_mode == VFE_OUTPUTS_MAIN_AND_THUMB) ||
-		(vfe31_ctrl->operation_mode == VFE_OUTPUTS_THUMB_AND_JPEG) ||
-		(vfe31_ctrl->operation_mode == VFE_OUTPUTS_JPEG_AND_THUMB)) {
-		if (vfe31_ctrl->frame_skip_pattern & (0x1 <<
-			(vfe31_ctrl->snapshot_frame_cnt %
-				vfe31_ctrl->frame_skip_cnt))) {
-			vfe31_ctrl->vfe_capture_count--;
-		}
-		vfe31_ctrl->snapshot_frame_cnt++;
-	}
-}
-
-static void vfe31_process_error_irq(uint32_t errStatus)
-{
-	uint32_t reg_value, read_val;
-
-	if (errStatus & VFE31_IMASK_CAMIF_ERROR) {
-		pr_err("vfe31_irq: camif errors\n");
-		reg_value = msm_camera_io_r(
-				vfe31_ctrl->vfebase + VFE_CAMIF_STATUS);
-		pr_err("camifStatus  = 0x%x\n", reg_value);
-		vfe31_send_isp_msg(vfe31_ctrl, MSG_ID_CAMIF_ERROR);
-	}
-
-	if (errStatus & VFE31_IMASK_STATS_CS_OVWR)
-		pr_err("vfe31_irq: stats cs overwrite\n");
-
-	if (errStatus & VFE31_IMASK_STATS_IHIST_OVWR)
-		pr_err("vfe31_irq: stats ihist overwrite\n");
-
-	if (errStatus & VFE31_IMASK_REALIGN_BUF_Y_OVFL)
-		pr_err("vfe31_irq: realign bug Y overflow\n");
-
-	if (errStatus & VFE31_IMASK_REALIGN_BUF_CB_OVFL)
-		pr_err("vfe31_irq: realign bug CB overflow\n");
-
-	if (errStatus & VFE31_IMASK_REALIGN_BUF_CR_OVFL)
-		pr_err("vfe31_irq: realign bug CR overflow\n");
-
-	if (errStatus & VFE31_IMASK_VIOLATION)
-		pr_err("vfe31_irq: violation interrupt\n");
-
-	if (errStatus & VFE31_IMASK_IMG_MAST_0_BUS_OVFL)
-		pr_err("vfe31_irq: image master 0 bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_IMG_MAST_1_BUS_OVFL)
-		pr_err("vfe31_irq: image master 1 bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_IMG_MAST_2_BUS_OVFL)
-		pr_err("vfe31_irq: image master 2 bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_IMG_MAST_3_BUS_OVFL)
-		pr_err("vfe31_irq: image master 3 bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_IMG_MAST_4_BUS_OVFL)
-		pr_err("vfe31_irq: image master 4 bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_IMG_MAST_5_BUS_OVFL)
-		pr_err("vfe31_irq: image master 5 bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_IMG_MAST_6_BUS_OVFL)
-		pr_err("vfe31_irq: image master 6 bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_STATS_AE_BG_BUS_OVFL)
-		pr_err("vfe31_irq: ae/bg stats bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_STATS_AF_BF_BUS_OVFL)
-		pr_err("vfe31_irq: af/bf stats bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_STATS_AWB_BUS_OVFL)
-		pr_err("vfe31_irq: awb stats bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_STATS_RS_BUS_OVFL)
-		pr_err("vfe31_irq: rs stats bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_STATS_CS_BUS_OVFL)
-		pr_err("vfe31_irq: cs stats bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_STATS_IHIST_BUS_OVFL)
-		pr_err("vfe31_irq: ihist stats bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_STATS_SKIN_BHIST_BUS_OVFL)
-		pr_err("vfe31_irq: skin/bhist stats bus overflow\n");
-
-	if (errStatus & VFE31_IMASK_AXI_ERROR) {
-		pr_err("vfe31_irq: axi error\n");
-		/* read status too when overflow happens.*/
-		read_val = msm_camera_io_r(vfe31_ctrl->vfebase +
-			VFE_BUS_PING_PONG_STATUS);
-		pr_debug("VFE_BUS_PING_PONG_STATUS = 0x%x\n", read_val);
-		read_val = msm_camera_io_r(vfe31_ctrl->vfebase +
-			VFE_BUS_OPERATION_STATUS);
-		pr_debug("VFE_BUS_OPERATION_STATUS = 0x%x\n", read_val);
-		read_val = msm_camera_io_r(vfe31_ctrl->vfebase +
-			VFE_BUS_IMAGE_MASTER_0_WR_PM_STATS_0);
-		pr_debug("VFE_BUS_IMAGE_MASTER_0_WR_PM_STATS_0 = 0x%x\n",
-			read_val);
-		read_val = msm_camera_io_r(vfe31_ctrl->vfebase +
-			VFE_BUS_IMAGE_MASTER_0_WR_PM_STATS_1);
-		pr_debug("VFE_BUS_IMAGE_MASTER_0_WR_PM_STATS_1 = 0x%x\n",
-			read_val);
-		read_val = msm_camera_io_r(vfe31_ctrl->vfebase +
-			VFE_AXI_STATUS);
-		pr_debug("VFE_AXI_STATUS = 0x%x\n", read_val);
-	}
-}
-static void vfe_send_outmsg(struct v4l2_subdev *sd, uint8_t msgid,
-	uint32_t ch0_paddr, uint32_t ch1_paddr,
-	uint32_t ch2_paddr, uint32_t inst_handle)
-{
-	struct isp_msg_output msg;
-
-	msg.output_id		= msgid;
-	msg.buf.inst_handle	= inst_handle;
-	msg.buf.ch_paddr[0]	= ch0_paddr;
-	msg.buf.ch_paddr[1]	= ch1_paddr;
-	msg.buf.ch_paddr[2]	= ch2_paddr;
-	msg.frameCounter	= vfe31_ctrl->vfeFrameId;
-
-	v4l2_subdev_notify(&vfe31_ctrl->subdev,
-		NOTIFY_VFE_MSG_OUT, &msg);
-	return;
-}
-
-static void vfe31_process_output_path_irq_0(void)
-{
-	uint32_t ping_pong;
-	uint32_t ch0_paddr, ch1_paddr, ch2_paddr;
-	uint8_t out_bool = 0;
-	struct msm_free_buf *free_buf = NULL;
-
-	free_buf = vfe31_check_free_buffer(VFE_MSG_OUTPUT_IRQ,
-		VFE_MSG_OUTPUT_PRIMARY);
-
-	/* we render frames in the following conditions:
-	 * 1. Continuous mode and the free buffer is avaialable.
-	 * 2. In snapshot shot mode, free buffer is not always available.
-	 * when pending snapshot count is <=1,  then no need to use
-	 * free buffer.
-	 */
-	out_bool = ((vfe31_ctrl->operation_mode == VFE_OUTPUTS_THUMB_AND_MAIN ||
-		vfe31_ctrl->operation_mode == VFE_OUTPUTS_MAIN_AND_THUMB ||
-		vfe31_ctrl->operation_mode == VFE_OUTPUTS_THUMB_AND_JPEG ||
-		vfe31_ctrl->operation_mode == VFE_OUTPUTS_JPEG_AND_THUMB ||
-		vfe31_ctrl->operation_mode == VFE_OUTPUTS_RAW ||
-		vfe31_ctrl->liveshot_state == VFE_STATE_STARTED ||
-		vfe31_ctrl->liveshot_state == VFE_STATE_STOP_REQUESTED ||
-		vfe31_ctrl->liveshot_state == VFE_STATE_STOPPED) &&
-		(vfe31_ctrl->vfe_capture_count <= 1)) || free_buf;
-
-	if (out_bool) {
-		ping_pong = msm_camera_io_r(vfe31_ctrl->vfebase +
-			VFE_BUS_PING_PONG_STATUS);
-
-		/* Channel 0*/
-		ch0_paddr = vfe31_get_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out0.ch0);
-		/* Channel 1*/
-		ch1_paddr = vfe31_get_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out0.ch1);
-		/* Channel 2*/
-		ch2_paddr = vfe31_get_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out0.ch2);
-
-		CDBG("output path 0, ch0 = 0x%x, ch1 = 0x%x, ch2 = 0x%x\n",
-			ch0_paddr, ch1_paddr, ch2_paddr);
-		if (free_buf) {
-			/* Y channel */
-			vfe31_put_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out0.ch0,
-			free_buf->ch_paddr[0]);
-			/* Chroma channel */
-			vfe31_put_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out0.ch1,
-			free_buf->ch_paddr[1]);
-			if (free_buf->num_planes > 2)
-				vfe31_put_ch_addr(ping_pong,
-					vfe31_ctrl->outpath.out0.ch2,
-					free_buf->ch_paddr[2]);
-		}
-		if (vfe31_ctrl->operation_mode ==
-				VFE_OUTPUTS_THUMB_AND_MAIN ||
-			vfe31_ctrl->operation_mode ==
-				VFE_OUTPUTS_MAIN_AND_THUMB ||
-			vfe31_ctrl->operation_mode ==
-				VFE_OUTPUTS_THUMB_AND_JPEG ||
-			vfe31_ctrl->operation_mode ==
-				VFE_OUTPUTS_JPEG_AND_THUMB ||
-			vfe31_ctrl->operation_mode ==
-				VFE_OUTPUTS_RAW ||
-			vfe31_ctrl->liveshot_state == VFE_STATE_STOPPED)
-			vfe31_ctrl->outpath.out0.capture_cnt--;
-
-		vfe_send_outmsg(&vfe31_ctrl->subdev,
-			MSG_ID_OUTPUT_PRIMARY, ch0_paddr,
-			ch1_paddr, ch2_paddr,
-			vfe31_ctrl->outpath.out0.inst_handle);
-
-		if (vfe31_ctrl->liveshot_state == VFE_STATE_STOPPED)
-			vfe31_ctrl->liveshot_state = VFE_STATE_IDLE;
-
-	} else {
-		vfe31_ctrl->outpath.out0.frame_drop_cnt++;
-		CDBG("path_irq_0 - no free buffer!\n");
-	}
-}
-
-static void vfe31_process_output_path_irq_1(void)
-{
-	uint32_t ping_pong;
-	uint32_t ch0_paddr, ch1_paddr, ch2_paddr;
-	/* this must be snapshot main image output. */
-	uint8_t out_bool = 0;
-	struct msm_free_buf *free_buf = NULL;
-
-	free_buf = vfe31_check_free_buffer(VFE_MSG_OUTPUT_IRQ,
-		VFE_MSG_OUTPUT_SECONDARY);
-	out_bool = ((vfe31_ctrl->operation_mode ==
-				VFE_OUTPUTS_THUMB_AND_MAIN ||
-			vfe31_ctrl->operation_mode ==
-				VFE_OUTPUTS_MAIN_AND_THUMB ||
-			vfe31_ctrl->operation_mode ==
-				VFE_OUTPUTS_RAW ||
-			vfe31_ctrl->operation_mode ==
-				VFE_OUTPUTS_JPEG_AND_THUMB) &&
-			(vfe31_ctrl->vfe_capture_count <= 1)) || free_buf;
-
-	if (out_bool) {
-		ping_pong = msm_camera_io_r(vfe31_ctrl->vfebase +
-			VFE_BUS_PING_PONG_STATUS);
-
-		/* Y channel */
-		ch0_paddr = vfe31_get_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out1.ch0);
-		/* Chroma channel */
-		ch1_paddr = vfe31_get_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out1.ch1);
-		ch2_paddr = vfe31_get_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out1.ch2);
-
-		pr_debug("%s ch0 = 0x%x, ch1 = 0x%x, ch2 = 0x%x\n",
-			__func__, ch0_paddr, ch1_paddr, ch2_paddr);
-		if (free_buf) {
-			/* Y channel */
-			vfe31_put_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out1.ch0,
-			free_buf->ch_paddr[0]);
-			/* Chroma channel */
-			vfe31_put_ch_addr(ping_pong,
-			vfe31_ctrl->outpath.out1.ch1,
-			free_buf->ch_paddr[1]);
-			if (free_buf->num_planes > 2)
-				vfe31_put_ch_addr(ping_pong,
-					vfe31_ctrl->outpath.out1.ch2,
-					free_buf->ch_paddr[2]);
-		}
-		if (vfe31_ctrl->operation_mode ==
-				VFE_OUTPUTS_THUMB_AND_MAIN ||
-			vfe31_ctrl->operation_mode ==
-				VFE_OUTPUTS_MAIN_AND_THUMB ||
-			vfe31_ctrl->operation_mode ==
-				VFE_OUTPUTS_RAW ||
-			vfe31_ctrl->operation_mode ==
-				VFE_OUTPUTS_JPEG_AND_THUMB)
-			vfe31_ctrl->outpath.out1.capture_cnt--;
-
-		vfe_send_outmsg(&vfe31_ctrl->subdev,
-			MSG_ID_OUTPUT_SECONDARY, ch0_paddr,
-			ch1_paddr, ch2_paddr,
-			vfe31_ctrl->outpath.out1.inst_handle);
-	} else {
-		vfe31_ctrl->outpath.out1.frame_drop_cnt++;
-		CDBG("path_irq_1 - no free buffer!\n");
-	}
-}
-
-static uint32_t  vfe31_process_stats_irq_common(uint32_t statsNum,
-	uint32_t newAddr)
-{
-
-	uint32_t pingpongStatus;
-	uint32_t returnAddr;
-	uint32_t pingpongAddr;
-
-	/* must be 0=ping, 1=pong */
-	pingpongStatus =
-		((msm_camera_io_r(vfe31_ctrl->vfebase +
-		VFE_BUS_PING_PONG_STATUS))
-		& ((uint32_t)(1<<(statsNum + 7)))) >> (statsNum + 7);
-	/* stats bits starts at 7 */
-	CDBG("statsNum %d, pingpongStatus %d\n", statsNum, pingpongStatus);
-	pingpongAddr =
-		((uint32_t)(vfe31_ctrl->vfebase +
-		VFE_BUS_STATS_PING_PONG_BASE)) +
-		(3*statsNum)*4 + (1-pingpongStatus)*4;
-	returnAddr = msm_camera_io_r((uint32_t *)pingpongAddr);
-	msm_camera_io_w(newAddr, (uint32_t *)pingpongAddr);
-	return returnAddr;
-}
-
-static void
-vfe_send_stats_msg(uint32_t bufAddress, uint32_t statsNum)
-{
-	int rc = 0;
-	void *vaddr = NULL;
-	/* fill message with right content. */
-	/* @todo This is causing issues, need further investigate */
-	/* spin_lock_irqsave(&ctrl->state_lock, flags); */
-	struct isp_msg_stats msgStats;
-	msgStats.frameCounter = vfe31_ctrl->vfeFrameId;
-	msgStats.buffer = bufAddress;
-
-	switch (statsNum) {
-	case STATS_AE_NUM:{
-		msgStats.id = MSG_ID_STATS_AEC;
-		rc = vfe31_ctrl->stats_ops.dispatch(
-				vfe31_ctrl->stats_ops.stats_ctrl,
-				MSM_STATS_TYPE_AEC,	bufAddress,
-				&msgStats.buf_idx, &vaddr, &msgStats.fd,
-				vfe31_ctrl->stats_ops.client);
-		}
-		break;
-	case STATS_AF_NUM:{
-		msgStats.id = MSG_ID_STATS_AF;
-		rc = vfe31_ctrl->stats_ops.dispatch(
-				vfe31_ctrl->stats_ops.stats_ctrl,
-				MSM_STATS_TYPE_AF, bufAddress,
-				&msgStats.buf_idx, &vaddr, &msgStats.fd,
-				vfe31_ctrl->stats_ops.client);
-		}
-		break;
-	case STATS_AWB_NUM: {
-		msgStats.id = MSG_ID_STATS_AWB;
-		rc = vfe31_ctrl->stats_ops.dispatch(
-				vfe31_ctrl->stats_ops.stats_ctrl,
-				MSM_STATS_TYPE_AWB, bufAddress,
-				&msgStats.buf_idx, &vaddr, &msgStats.fd,
-				vfe31_ctrl->stats_ops.client);
-		}
-		break;
-
-	case STATS_IHIST_NUM: {
-		msgStats.id = MSG_ID_STATS_IHIST;
-		rc = vfe31_ctrl->stats_ops.dispatch(
-				vfe31_ctrl->stats_ops.stats_ctrl,
-				MSM_STATS_TYPE_IHIST, bufAddress,
-				&msgStats.buf_idx, &vaddr, &msgStats.fd,
-				vfe31_ctrl->stats_ops.client);
-		}
-		break;
-	case STATS_RS_NUM: {
-		msgStats.id = MSG_ID_STATS_RS;
-		rc = vfe31_ctrl->stats_ops.dispatch(
-				vfe31_ctrl->stats_ops.stats_ctrl,
-				MSM_STATS_TYPE_RS, bufAddress,
-				&msgStats.buf_idx, &vaddr, &msgStats.fd,
-				vfe31_ctrl->stats_ops.client);
-		}
-		break;
-	case STATS_CS_NUM: {
-		msgStats.id = MSG_ID_STATS_CS;
-		rc = vfe31_ctrl->stats_ops.dispatch(
-				vfe31_ctrl->stats_ops.stats_ctrl,
-				MSM_STATS_TYPE_CS, bufAddress,
-				&msgStats.buf_idx, &vaddr, &msgStats.fd,
-				vfe31_ctrl->stats_ops.client);
-		}
-		break;
-
-	default:
-		goto stats_done;
-	}
-	if (rc == 0) {
-		msgStats.buffer = (uint32_t)vaddr;
-		v4l2_subdev_notify(&vfe31_ctrl->subdev,
-			NOTIFY_VFE_MSG_STATS, &msgStats);
-	} else {
-		pr_err("%s: paddr to idx mapping error, stats_id = %d,\n"
-			"paddr = 0x%d\n", __func__,
-			 msgStats.id, msgStats.buffer);
-	}
-stats_done:
-	/* spin_unlock_irqrestore(&ctrl->state_lock, flags); */
-	return;
-}
-
-static void vfe_send_comp_stats_msg(uint32_t status_bits)
-{
-	struct msm_stats_buf msgStats;
-	uint32_t temp;
-
-	msgStats.frame_id = vfe31_ctrl->vfeFrameId;
-	msgStats.status_bits = status_bits;
-
-	msgStats.aec.buff = vfe31_ctrl->aecStatsControl.bufToRender;
-	msgStats.awb.buff = vfe31_ctrl->awbStatsControl.bufToRender;
-	msgStats.af.buff = vfe31_ctrl->afStatsControl.bufToRender;
-
-	msgStats.ihist.buff = vfe31_ctrl->ihistStatsControl.bufToRender;
-	msgStats.rs.buff = vfe31_ctrl->rsStatsControl.bufToRender;
-	msgStats.cs.buff = vfe31_ctrl->csStatsControl.bufToRender;
-
-	temp = msm_camera_io_r(vfe31_ctrl->vfebase + VFE_STATS_AWB_SGW_CFG);
-	msgStats.awb_ymin = (0xFF00 & temp) >> 8;
-
-	v4l2_subdev_notify(&vfe31_ctrl->subdev,
-		NOTIFY_VFE_MSG_COMP_STATS, &msgStats);
-}
-
-static void vfe31_process_stats_ae_irq(void)
-{
-	unsigned long flags;
-	uint32_t addr;
-	spin_lock_irqsave(&vfe31_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe31_stats_dqbuf(MSM_STATS_TYPE_AEC);
-	spin_unlock_irqrestore(&vfe31_ctrl->stats_bufq_lock, flags);
-	if (addr) {
-		vfe31_ctrl->aecStatsControl.bufToRender =
-			vfe31_process_stats_irq_common(STATS_AE_NUM,
-			addr);
-
-		vfe_send_stats_msg(vfe31_ctrl->aecStatsControl.bufToRender,
-			STATS_AE_NUM);
-	} else{
-		vfe31_ctrl->aecStatsControl.droppedStatsFrameCount++;
-		CDBG("%s: droppedStatsFrameCount = %d", __func__,
-			vfe31_ctrl->aecStatsControl.droppedStatsFrameCount);
-	}
-}
-
-static void vfe31_process_stats_awb_irq(void)
-{
-	unsigned long flags;
-	uint32_t addr;
-	spin_lock_irqsave(&vfe31_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe31_stats_dqbuf(MSM_STATS_TYPE_AWB);
-	spin_unlock_irqrestore(&vfe31_ctrl->stats_bufq_lock, flags);
-	if (addr) {
-		vfe31_ctrl->awbStatsControl.bufToRender =
-			vfe31_process_stats_irq_common(STATS_AWB_NUM,
-			addr);
-
-		vfe_send_stats_msg(vfe31_ctrl->awbStatsControl.bufToRender,
-			STATS_AWB_NUM);
-	} else{
-		vfe31_ctrl->awbStatsControl.droppedStatsFrameCount++;
-		CDBG("%s: droppedStatsFrameCount = %d", __func__,
-			vfe31_ctrl->awbStatsControl.droppedStatsFrameCount);
-	}
-}
-
-static void vfe31_process_stats_af_irq(void)
-{
-	unsigned long flags;
-	uint32_t addr;
-	spin_lock_irqsave(&vfe31_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe31_stats_dqbuf(MSM_STATS_TYPE_AF);
-	spin_unlock_irqrestore(&vfe31_ctrl->stats_bufq_lock, flags);
-	if (addr) {
-		vfe31_ctrl->afStatsControl.bufToRender =
-			vfe31_process_stats_irq_common(STATS_AF_NUM,
-			addr);
-
-		vfe_send_stats_msg(vfe31_ctrl->afStatsControl.bufToRender,
-			STATS_AF_NUM);
-	} else{
-		vfe31_ctrl->afStatsControl.droppedStatsFrameCount++;
-		CDBG("%s: droppedStatsFrameCount = %d", __func__,
-			vfe31_ctrl->afStatsControl.droppedStatsFrameCount);
-	}
-}
-
-static void vfe31_process_stats_ihist_irq(void)
-{
-	unsigned long flags;
-	uint32_t addr;
-	spin_lock_irqsave(&vfe31_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe31_stats_dqbuf(MSM_STATS_TYPE_IHIST);
-	spin_unlock_irqrestore(&vfe31_ctrl->stats_bufq_lock, flags);
-	if (addr) {
-		vfe31_ctrl->ihistStatsControl.bufToRender =
-			  vfe31_process_stats_irq_common(STATS_IHIST_NUM,
-				addr);
-		vfe_send_stats_msg(vfe31_ctrl->ihistStatsControl.bufToRender,
-			  STATS_IHIST_NUM);
-	} else {
-		vfe31_ctrl->ihistStatsControl.droppedStatsFrameCount++;
-		CDBG("%s: droppedStatsFrameCount = %d", __func__,
-			 vfe31_ctrl->ihistStatsControl.droppedStatsFrameCount);
-	}
-}
-
-static void vfe31_process_stats_rs_irq(void)
-{
-	unsigned long flags;
-	uint32_t addr;
-	spin_lock_irqsave(&vfe31_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe31_stats_dqbuf(MSM_STATS_TYPE_RS);
-	spin_unlock_irqrestore(&vfe31_ctrl->stats_bufq_lock, flags);
-	if (addr) {
-		vfe31_ctrl->rsStatsControl.bufToRender =
-			vfe31_process_stats_irq_common(STATS_RS_NUM,
-			addr);
-		vfe_send_stats_msg(vfe31_ctrl->rsStatsControl.bufToRender,
-			STATS_RS_NUM);
-	} else {
-		vfe31_ctrl->rsStatsControl.droppedStatsFrameCount++;
-		CDBG("%s: droppedStatsFrameCount = %d", __func__,
-			vfe31_ctrl->rsStatsControl.droppedStatsFrameCount);
-	}
-}
-
-static void vfe31_process_stats_cs_irq(void)
-{
-	unsigned long flags;
-	uint32_t addr;
-	spin_lock_irqsave(&vfe31_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe31_stats_dqbuf(MSM_STATS_TYPE_CS);
-	spin_unlock_irqrestore(&vfe31_ctrl->stats_bufq_lock, flags);
-	if (addr) {
-		vfe31_ctrl->csStatsControl.bufToRender =
-			vfe31_process_stats_irq_common(STATS_CS_NUM,
-				addr);
-			vfe_send_stats_msg(
-				vfe31_ctrl->csStatsControl.bufToRender,
-				STATS_CS_NUM);
-	} else {
-		vfe31_ctrl->csStatsControl.droppedStatsFrameCount++;
-		CDBG("%s: droppedStatsFrameCount = %d", __func__,
-			vfe31_ctrl->csStatsControl.droppedStatsFrameCount);
-	}
-}
-
-static void vfe31_process_stats(uint32_t status_bits)
-{
-	unsigned long flags;
-	int32_t process_stats = false;
-	uint32_t addr;
-	CDBG("%s, stats = 0x%x\n", __func__, status_bits);
-
-	spin_lock_irqsave(&vfe31_ctrl->stats_bufq_lock, flags);
-	if (status_bits & VFE_IRQ_STATUS0_STATS_AEC) {
-		addr = (uint32_t)vfe31_stats_dqbuf(MSM_STATS_TYPE_AEC);
-		if (addr) {
-			vfe31_ctrl->aecStatsControl.bufToRender =
-				vfe31_process_stats_irq_common(STATS_AE_NUM,
-				addr);
-			process_stats = true;
-		} else{
-			vfe31_ctrl->aecStatsControl.bufToRender = 0;
-			vfe31_ctrl->aecStatsControl.droppedStatsFrameCount++;
-		}
-	} else {
-		vfe31_ctrl->aecStatsControl.bufToRender = 0;
-	}
-
-	if (status_bits & VFE_IRQ_STATUS0_STATS_AWB) {
-		addr = (uint32_t)vfe31_stats_dqbuf(MSM_STATS_TYPE_AWB);
-		if (addr) {
-			vfe31_ctrl->awbStatsControl.bufToRender =
-				vfe31_process_stats_irq_common(STATS_AWB_NUM,
-				addr);
-			process_stats = true;
-		} else{
-			vfe31_ctrl->awbStatsControl.droppedStatsFrameCount++;
-			vfe31_ctrl->awbStatsControl.bufToRender = 0;
-		}
-	} else {
-		vfe31_ctrl->awbStatsControl.bufToRender = 0;
-	}
-
-
-	if (status_bits & VFE_IRQ_STATUS0_STATS_AF) {
-		addr = (uint32_t)vfe31_stats_dqbuf(MSM_STATS_TYPE_AF);
-		if (addr) {
-			vfe31_ctrl->afStatsControl.bufToRender =
-				vfe31_process_stats_irq_common(STATS_AF_NUM,
-				addr);
-			process_stats = true;
-		} else {
-			vfe31_ctrl->afStatsControl.bufToRender = 0;
-			vfe31_ctrl->afStatsControl.droppedStatsFrameCount++;
-		}
-	} else {
-		vfe31_ctrl->afStatsControl.bufToRender = 0;
-	}
-
-	if (status_bits & VFE_IRQ_STATUS0_STATS_IHIST) {
-		addr = (uint32_t)vfe31_stats_dqbuf(MSM_STATS_TYPE_IHIST);
-		if (addr) {
-			vfe31_ctrl->ihistStatsControl.bufToRender =
-				vfe31_process_stats_irq_common(STATS_IHIST_NUM,
-				addr);
-			process_stats = true;
-		} else {
-			vfe31_ctrl->ihistStatsControl.droppedStatsFrameCount++;
-			vfe31_ctrl->ihistStatsControl.bufToRender = 0;
-		}
-	} else {
-		vfe31_ctrl->ihistStatsControl.bufToRender = 0;
-	}
-
-	if (status_bits & VFE_IRQ_STATUS0_STATS_RS) {
-		addr = (uint32_t)vfe31_stats_dqbuf(MSM_STATS_TYPE_RS);
-		if (!addr) {
-			vfe31_ctrl->rsStatsControl.bufToRender =
-				vfe31_process_stats_irq_common(STATS_RS_NUM,
-				addr);
-			process_stats = true;
-		} else {
-			vfe31_ctrl->rsStatsControl.droppedStatsFrameCount++;
-			vfe31_ctrl->rsStatsControl.bufToRender = 0;
-		}
-	} else {
-		vfe31_ctrl->rsStatsControl.bufToRender = 0;
-	}
-
-
-	if (status_bits & VFE_IRQ_STATUS0_STATS_CS) {
-		addr = (uint32_t)vfe31_stats_dqbuf(MSM_STATS_TYPE_CS);
-		if (addr) {
-			vfe31_ctrl->csStatsControl.bufToRender =
-				vfe31_process_stats_irq_common(STATS_CS_NUM,
-				addr);
-			process_stats = true;
-		} else {
-			vfe31_ctrl->csStatsControl.droppedStatsFrameCount++;
-			vfe31_ctrl->csStatsControl.bufToRender = 0;
-		}
-	} else {
-		vfe31_ctrl->csStatsControl.bufToRender = 0;
-	}
-
-	spin_unlock_irqrestore(&vfe31_ctrl->stats_bufq_lock, flags);
-	if (process_stats)
-		vfe_send_comp_stats_msg(status_bits);
-
-	return;
-}
-
-static long vfe_stats_bufq_sub_ioctl(struct msm_vfe_cfg_cmd *cmd,
-	void *ion_client, int domain_num)
-{
-	long rc = 0;
-	switch (cmd->cmd_type) {
-	case VFE_CMD_STATS_REQBUF:
-		if (!vfe31_ctrl->stats_ops.stats_ctrl) {
-			/* stats_ctrl has not been init yet */
-			rc = msm_stats_buf_ops_init(&vfe31_ctrl->stats_ctrl,
-					(struct ion_client *)ion_client,
-					&vfe31_ctrl->stats_ops);
-		if (rc < 0) {
-			pr_err("%s: cannot init stats ops", __func__);
-			goto end;
-		}
-		rc = vfe31_ctrl->stats_ops.stats_ctrl_init(
-				&vfe31_ctrl->stats_ctrl);
-		if (rc < 0) {
-			pr_err("%s: cannot init stats_ctrl ops", __func__);
-			memset(&vfe31_ctrl->stats_ops, 0,
-				sizeof(vfe31_ctrl->stats_ops));
-			goto end;
-		}
-		if (sizeof(struct msm_stats_reqbuf) != cmd->length) {
-			/* error. the length not match */
-			pr_err("%s: stats reqbuf input size = %d,\n"
-				"struct size = %d, mis match\n",
-				 __func__, cmd->length,
-				 sizeof(struct msm_stats_reqbuf));
-			rc = -EINVAL;
-			goto end;
-		}
-	}
-	rc = vfe31_ctrl->stats_ops.reqbuf(&vfe31_ctrl->stats_ctrl,
-			(struct msm_stats_reqbuf *)cmd->value,
-			vfe31_ctrl->stats_ops.client);
-	break;
-	case VFE_CMD_STATS_ENQUEUEBUF:
-		if (sizeof(struct msm_stats_buf_info) != cmd->length) {
-			/* error. the length not match */
-			pr_err("%s: stats enqueuebuf input size = %d,\n"
-				"struct size = %d, mis match\n",
-				__func__, cmd->length,
-				sizeof(struct msm_stats_buf_info));
-			rc = -EINVAL ;
-			goto end;
-		}
-		rc = vfe31_ctrl->stats_ops.enqueue_buf(&vfe31_ctrl->stats_ctrl,
-				(struct msm_stats_buf_info *)cmd->value,
-				vfe31_ctrl->stats_ops.client, domain_num);
-	break;
-	case VFE_CMD_STATS_FLUSH_BUFQ: {
-		struct msm_stats_flush_bufq *flush_req = NULL;
-		flush_req = (struct msm_stats_flush_bufq *)cmd->value;
-		if (sizeof(struct msm_stats_flush_bufq) != cmd->length) {
-			/* error. the length not match */
-			pr_err("%s: stats flush queue input size = %d,\n"
-				"struct size = %d, mitch match\n",
-				__func__, cmd->length,
-				sizeof(struct msm_stats_flush_bufq));
-			rc = -EINVAL ;
-			goto end;
-		}
-		rc = vfe31_ctrl->stats_ops.bufq_flush(&vfe31_ctrl->stats_ctrl,
-				(enum msm_stats_enum_type)flush_req->stats_type,
-				vfe31_ctrl->stats_ops.client);
-	}
-	break;
-	case VFE_CMD_STATS_UNREGBUF:
-	{
-		struct msm_stats_reqbuf *req_buf = NULL;
-		req_buf = (struct msm_stats_reqbuf *)cmd->value;
-		if (sizeof(struct msm_stats_reqbuf) != cmd->length) {
-			/* error. the length not match */
-			pr_err("%s: stats reqbuf input size = %d,\n"
-				"struct size = %d, mitch match\n",
-				 __func__, cmd->length,
-				sizeof(struct msm_stats_reqbuf));
-			rc = -EINVAL ;
-			goto end;
-		}
-		rc = vfe31_stats_unregbuf(req_buf, domain_num);
-	}
-	break;
-	default:
-		rc = -1;
-		pr_err("%s: cmd_type %d not supported", __func__,
-			cmd->cmd_type);
-	break;
-	}
-end:
-	return rc;
-}
-
-static void vfe31_process_stats_irq(uint32_t *irqstatus)
-{
-	uint32_t status_bits = VFE_COM_STATUS & *irqstatus;
-
-	if ((vfe31_ctrl->hfr_mode != HFR_MODE_OFF) &&
-		(vfe31_ctrl->vfeFrameId % vfe31_ctrl->hfr_mode != 0)) {
-		CDBG("Skip the stats when HFR enabled\n");
-		return;
-	}
-
-	vfe31_process_stats(status_bits);
-	return;
-}
-
-static void vfe31_do_tasklet(unsigned long data)
-{
-	unsigned long flags;
-
-	struct vfe31_isr_queue_cmd *qcmd = NULL;
-
-	CDBG("=== vfe31_do_tasklet start ===\n");
-
-	while (atomic_read(&irq_cnt)) {
-		spin_lock_irqsave(&vfe31_ctrl->tasklet_lock, flags);
-		qcmd = list_first_entry(&vfe31_ctrl->tasklet_q,
-			struct vfe31_isr_queue_cmd, list);
-		atomic_sub(1, &irq_cnt);
-
-		if (!qcmd) {
-			spin_unlock_irqrestore(&vfe31_ctrl->tasklet_lock,
-				flags);
-			return;
-		}
-
-		list_del(&qcmd->list);
-		spin_unlock_irqrestore(&vfe31_ctrl->tasklet_lock,
-			flags);
-
-		if (qcmd->vfeInterruptStatus0 &
-			VFE_IRQ_STATUS0_CAMIF_SOF_MASK) {
-			CDBG("irq	camifSofIrq\n");
-			vfe31_process_camif_sof_irq();
-		}
-		/* interrupt to be processed,  *qcmd has the payload.  */
-		if (qcmd->vfeInterruptStatus0 &
-			VFE_IRQ_STATUS0_REG_UPDATE_MASK) {
-			CDBG("irq	regUpdateIrq\n");
-			vfe31_process_reg_update_irq();
-		}
-
-		if (qcmd->vfeInterruptStatus1 &
-			VFE_IMASK_WHILE_STOPPING_1) {
-			CDBG("irq	resetAckIrq\n");
-			vfe31_process_reset_irq();
-		}
-
-		if (atomic_read(&vfe31_ctrl->vstate)) {
-			if (qcmd->vfeInterruptStatus1 &
-				VFE31_IMASK_ERROR_ONLY_1) {
-				pr_err("irq	errorIrq\n");
-				vfe31_process_error_irq(
-					qcmd->vfeInterruptStatus1 &
-					VFE31_IMASK_ERROR_ONLY_1);
-			}
-			/* next, check output path related interrupts. */
-			if (qcmd->vfeInterruptStatus0 &
-				VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE0_MASK) {
-				CDBG("Image composite done 0 irq occured.\n");
-				vfe31_process_output_path_irq_0();
-			}
-			if (qcmd->vfeInterruptStatus0 &
-				VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE1_MASK) {
-				CDBG("Image composite done 1 irq occured.\n");
-				vfe31_process_output_path_irq_1();
-			}
-			/* in snapshot mode if done then send
-			snapshot done message */
-			if (vfe31_ctrl->operation_mode ==
-					VFE_OUTPUTS_THUMB_AND_MAIN ||
-				vfe31_ctrl->operation_mode ==
-					VFE_OUTPUTS_MAIN_AND_THUMB ||
-				vfe31_ctrl->operation_mode ==
-					VFE_OUTPUTS_THUMB_AND_JPEG ||
-				vfe31_ctrl->operation_mode ==
-					VFE_OUTPUTS_JPEG_AND_THUMB ||
-				vfe31_ctrl->operation_mode ==
-					VFE_OUTPUTS_RAW) {
-				if ((vfe31_ctrl->outpath.out0.capture_cnt == 0)
-					&& (vfe31_ctrl->outpath.out1.
-					capture_cnt == 0)) {
-					msm_camera_io_w_mb(
-						CAMIF_COMMAND_STOP_IMMEDIATELY,
-						vfe31_ctrl->vfebase +
-						VFE_CAMIF_COMMAND);
-					vfe31_send_isp_msg(vfe31_ctrl,
-						MSG_ID_SNAPSHOT_DONE);
-				}
-			}
-			/* then process stats irq. */
-			if (vfe31_ctrl->stats_comp) {
-				/* process stats comb interrupt. */
-				if (qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_COMPOSIT_MASK) {
-					CDBG("Stats composite irq occured.\n");
-					vfe31_process_stats_irq(
-						&qcmd->vfeInterruptStatus0);
-				}
-			} else {
-				/* process individual stats interrupt. */
-				if (qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_AEC) {
-					CDBG("Stats AEC irq occured.\n");
-					vfe31_process_stats_ae_irq();
-				}
-				if (qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_AWB) {
-					CDBG("Stats AWB irq occured.\n");
-					vfe31_process_stats_awb_irq();
-				}
-				if (qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_AF) {
-					CDBG("Stats AF irq occured.\n");
-					vfe31_process_stats_af_irq();
-				}
-				if (qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_IHIST) {
-					CDBG("Stats IHIST irq occured.\n");
-					vfe31_process_stats_ihist_irq();
-				}
-				if (qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_RS) {
-					CDBG("Stats RS irq occured.\n");
-					vfe31_process_stats_rs_irq();
-				}
-				if (qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_CS) {
-					CDBG("Stats CS irq occured.\n");
-					vfe31_process_stats_cs_irq();
-				}
-				if (qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_SYNC_TIMER0) {
-					CDBG("SYNC_TIMER 0 irq occured.\n");
-					vfe31_send_isp_msg(vfe31_ctrl,
-						MSG_ID_SYNC_TIMER0_DONE);
-				}
-				if (qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_SYNC_TIMER1) {
-					CDBG("SYNC_TIMER 1 irq occured.\n");
-					vfe31_send_isp_msg(vfe31_ctrl,
-						MSG_ID_SYNC_TIMER1_DONE);
-				}
-				if (qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_SYNC_TIMER2) {
-					CDBG("SYNC_TIMER 2 irq occured.\n");
-					vfe31_send_isp_msg(vfe31_ctrl,
-						MSG_ID_SYNC_TIMER2_DONE);
-				}
-			}
-		}
-		kfree(qcmd);
-	}
-	CDBG("=== vfe31_do_tasklet end ===\n");
-}
-
-DECLARE_TASKLET(vfe31_tasklet, vfe31_do_tasklet, 0);
-
-static irqreturn_t vfe31_parse_irq(int irq_num, void *data)
-{
-	unsigned long flags;
-	struct vfe31_irq_status irq;
-	struct vfe31_isr_queue_cmd *qcmd;
-
-	CDBG("vfe_parse_irq\n");
-
-	vfe31_read_irq_status(&irq);
-
-	if ((irq.vfeIrqStatus0 == 0) && (irq.vfeIrqStatus1 == 0)) {
-		CDBG("vfe_parse_irq: vfeIrqStatus0 & 1 are both 0!\n");
-		return IRQ_HANDLED;
-	}
-
-	qcmd = kzalloc(sizeof(struct vfe31_isr_queue_cmd),
-		GFP_ATOMIC);
-	if (!qcmd) {
-		pr_err("vfe_parse_irq: qcmd malloc failed!\n");
-		return IRQ_HANDLED;
-	}
-
-	spin_lock_irqsave(&vfe31_ctrl->stop_flag_lock, flags);
-	if (vfe31_ctrl->stop_ack_pending) {
-		irq.vfeIrqStatus0 &= VFE_IMASK_WHILE_STOPPING_0;
-		irq.vfeIrqStatus1 &= VFE_IMASK_WHILE_STOPPING_1;
-	}
-	spin_unlock_irqrestore(&vfe31_ctrl->stop_flag_lock, flags);
-
-	CDBG("vfe_parse_irq: Irq_status0 = 0x%x, Irq_status1 = 0x%x.\n",
-		irq.vfeIrqStatus0, irq.vfeIrqStatus1);
-
-	qcmd->vfeInterruptStatus0 = irq.vfeIrqStatus0;
-	qcmd->vfeInterruptStatus1 = irq.vfeIrqStatus1;
-
-	spin_lock_irqsave(&vfe31_ctrl->tasklet_lock, flags);
-	list_add_tail(&qcmd->list, &vfe31_ctrl->tasklet_q);
-
-	atomic_add(1, &irq_cnt);
-	spin_unlock_irqrestore(&vfe31_ctrl->tasklet_lock, flags);
-	tasklet_schedule(&vfe31_tasklet);
-	return IRQ_HANDLED;
-}
-
-static long msm_vfe_subdev_ioctl(struct v4l2_subdev *sd,
-			unsigned int subdev_cmd, void *arg)
-{
-	struct msm_cam_media_controller *pmctl =
-		(struct msm_cam_media_controller *)v4l2_get_subdev_hostdata(sd);
-	struct msm_isp_cmd vfecmd;
-	struct msm_camvfe_params *vfe_params;
-	struct msm_vfe_cfg_cmd *cmd;
-	void *data;
-
-	long rc = 0;
-	struct vfe_cmd_stats_buf *scfg = NULL;
-	struct vfe_cmd_stats_ack *sack = NULL;
-
-	if (subdev_cmd == VIDIOC_MSM_VFE_INIT) {
-		CDBG("%s init\n", __func__);
-		return msm_vfe_subdev_init(sd);
-	} else if (subdev_cmd == VIDIOC_MSM_VFE_RELEASE) {
-		msm_vfe_subdev_release(sd);
-		return 0;
-	}
-	vfe_params = (struct msm_camvfe_params *)arg;
-	cmd = vfe_params->vfe_cfg;
-	data = vfe_params->data;
-
-	switch (cmd->cmd_type) {
-	case VFE_CMD_STATS_REQBUF:
-	case VFE_CMD_STATS_ENQUEUEBUF:
-	case VFE_CMD_STATS_FLUSH_BUFQ:
-	case VFE_CMD_STATS_UNREGBUF:
-		/* for easy porting put in one envelope */
-		rc = vfe_stats_bufq_sub_ioctl(cmd, vfe_params->data,
-			pmctl->domain_num);
-		return rc;
-	default:
-		if (cmd->cmd_type != CMD_CONFIG_PING_ADDR &&
-			cmd->cmd_type != CMD_CONFIG_PONG_ADDR &&
-			cmd->cmd_type != CMD_CONFIG_FREE_BUF_ADDR &&
-			cmd->cmd_type != CMD_STATS_AEC_BUF_RELEASE &&
-			cmd->cmd_type != CMD_STATS_AWB_BUF_RELEASE &&
-			cmd->cmd_type != CMD_STATS_IHIST_BUF_RELEASE &&
-			cmd->cmd_type != CMD_STATS_RS_BUF_RELEASE &&
-			cmd->cmd_type != CMD_STATS_CS_BUF_RELEASE &&
-			cmd->cmd_type != CMD_STATS_AF_BUF_RELEASE) {
-				if (copy_from_user(&vfecmd,
-					(void __user *)(cmd->value),
-					sizeof(vfecmd))) {
-						pr_err("%s %d: copy_from_user failed\n",
-						__func__, __LINE__);
-					return -EFAULT;
-				}
-		} else {
-			/* here eith stats release or frame release. */
-			if (cmd->cmd_type != CMD_CONFIG_PING_ADDR &&
-				cmd->cmd_type != CMD_CONFIG_PONG_ADDR &&
-				cmd->cmd_type != CMD_CONFIG_FREE_BUF_ADDR) {
-				/* then must be stats release. */
-				if (!data) {
-					pr_err("%s: data = NULL," \
-						"cmd->cmd_type = %d\n",
-						__func__, cmd->cmd_type);
-					return -EFAULT;
-				}
-				sack = kmalloc(sizeof(struct vfe_cmd_stats_ack),
-							GFP_ATOMIC);
-				if (!sack) {
-					pr_err("%s: no mem for" \
-						"cmd->cmd_type = %d\n",
-						__func__, cmd->cmd_type);
-					return -ENOMEM;
-				}
-
-				sack->nextStatsBuf = *(uint32_t *)data;
-			}
-		}
-
-		CDBG("%s: cmdType = %d\n", __func__, cmd->cmd_type);
-
-		if ((cmd->cmd_type == CMD_STATS_AF_ENABLE)    ||
-			(cmd->cmd_type == CMD_STATS_AWB_ENABLE)   ||
-			(cmd->cmd_type == CMD_STATS_IHIST_ENABLE) ||
-			(cmd->cmd_type == CMD_STATS_RS_ENABLE)    ||
-			(cmd->cmd_type == CMD_STATS_CS_ENABLE)    ||
-			(cmd->cmd_type == CMD_STATS_AEC_ENABLE)) {
-			scfg = NULL;
-			goto vfe31_config_done;
-		}
-		switch (cmd->cmd_type) {
-		case CMD_GENERAL: {
-			rc = vfe31_proc_general(pmctl, &vfecmd);
-			}
-			break;
-		case CMD_CONFIG_PING_ADDR: {
-			int path = *((int *)cmd->value);
-			struct vfe31_output_ch *outch = vfe31_get_ch(path);
-			outch->ping = *((struct msm_free_buf *)data);
-			}
-			break;
-
-		case CMD_CONFIG_PONG_ADDR: {
-			int path = *((int *)cmd->value);
-			struct vfe31_output_ch *outch = vfe31_get_ch(path);
-			outch->pong = *((struct msm_free_buf *)data);
-			}
-			break;
-
-		case CMD_CONFIG_FREE_BUF_ADDR: {
-			int path = *((int *)cmd->value);
-			struct vfe31_output_ch *outch = vfe31_get_ch(path);
-			outch->free_buf = *((struct msm_free_buf *)data);
-			}
-			break;
-
-		case CMD_SNAP_BUF_RELEASE:
-			break;
-
-		case CMD_AXI_CFG_PRIM: {
-			uint32_t *axio = NULL;
-			axio = kmalloc(vfe31_cmd[VFE_CMD_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-			if (!axio) {
-				rc = -ENOMEM;
-				break;
-			}
-
-			if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe31_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-				kfree(axio);
-				rc = -EFAULT;
-				break;
-			}
-			vfe31_config_axi(OUTPUT_PRIM, axio);
-			kfree(axio);
-			}
-			break;
-
-		case CMD_AXI_CFG_PRIM_ALL_CHNLS: {
-			uint32_t *axio = NULL;
-			axio = kmalloc(vfe31_cmd[VFE_CMD_AXI_OUT_CFG].length,
-					GFP_ATOMIC);
-			if (!axio) {
-				rc = -ENOMEM;
-				break;
-			}
-
-			if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe31_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-				kfree(axio);
-				rc = -EFAULT;
-				break;
-			}
-			vfe31_config_axi(OUTPUT_PRIM_ALL_CHNLS, axio);
-			kfree(axio);
-		}
-			break;
-
-		case CMD_AXI_CFG_PRIM|CMD_AXI_CFG_SEC: {
-			uint32_t *axio = NULL;
-			axio = kmalloc(vfe31_cmd[VFE_CMD_AXI_OUT_CFG].length,
-					GFP_ATOMIC);
-			if (!axio) {
-				rc = -ENOMEM;
-				break;
-			}
-
-			if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe31_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-				kfree(axio);
-				rc = -EFAULT;
-				break;
-			}
-			vfe31_config_axi(OUTPUT_PRIM|OUTPUT_SEC, axio);
-			kfree(axio);
-			}
-			break;
-
-		case CMD_AXI_CFG_PRIM|CMD_AXI_CFG_SEC_ALL_CHNLS: {
-			uint32_t *axio = NULL;
-			axio = kmalloc(vfe31_cmd[VFE_CMD_AXI_OUT_CFG].length,
-					GFP_ATOMIC);
-			if (!axio) {
-				rc = -ENOMEM;
-				break;
-			}
-
-			if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe31_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-				kfree(axio);
-				rc = -EFAULT;
-				break;
-			}
-			vfe31_config_axi
-				(OUTPUT_PRIM|OUTPUT_SEC_ALL_CHNLS, axio);
-			kfree(axio);
-			}
-			break;
-
-		case CMD_AXI_CFG_PRIM_ALL_CHNLS|CMD_AXI_CFG_SEC: {
-			uint32_t *axio = NULL;
-			axio = kmalloc(vfe31_cmd[VFE_CMD_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-			if (!axio) {
-				rc = -ENOMEM;
-				break;
-			}
-
-			if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe31_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-				kfree(axio);
-				rc = -EFAULT;
-				break;
-			}
-			vfe31_config_axi
-				(OUTPUT_PRIM_ALL_CHNLS|OUTPUT_SEC, axio);
-			kfree(axio);
-			}
-			break;
-
-		case CMD_AXI_CFG_PRIM_ALL_CHNLS|CMD_AXI_CFG_SEC_ALL_CHNLS: {
-			pr_err("%s Invalid/Unsupported AXI configuration %x",
-				__func__, cmd->cmd_type);
-			}
-			break;
-
-		case CMD_AXI_START:
-			/* No need to decouple AXI/VFE for VFE3.1*/
-			break;
-
-		case CMD_AXI_STOP:
-			/* No need to decouple AXI/VFE for VFE3.1*/
-			break;
-
-		case CMD_AXI_RESET:
-			/* No need to decouple AXI/VFE for VFE3.1*/
-			break;
-
-		default:
-			pr_err("%s Unsupported AXI configuration %x ", __func__,
-				cmd->cmd_type);
-			break;
-		}
-	}
-vfe31_config_done:
-	kfree(scfg);
-	kfree(sack);
-	CDBG("%s done: rc = %d\n", __func__, (int) rc);
-	return rc;
-}
-
-static int msm_vfe_subdev_s_crystal_freq(struct v4l2_subdev *sd,
-	u32 freq, u32 flags)
-{
-	int rc = 0;
-	int round_rate;
-
-	round_rate = clk_round_rate(vfe31_ctrl->vfe_clk[0], freq);
-	if (rc < 0) {
-		pr_err("%s: clk_round_rate failed %d\n",
-			__func__, rc);
-		return rc;
-	}
-
-	vfe_clk_rate = round_rate;
-	rc = clk_set_rate(vfe31_ctrl->vfe_clk[0], round_rate);
-	if (rc < 0)
-		pr_err("%s: clk_set_rate failed %d\n",
-			__func__, rc);
-
-	return rc;
-}
-
-static const struct v4l2_subdev_video_ops msm_vfe_subdev_video_ops = {
-	.s_crystal_freq = msm_vfe_subdev_s_crystal_freq,
-};
-
-static const struct v4l2_subdev_core_ops msm_vfe_subdev_core_ops = {
-	.ioctl = msm_vfe_subdev_ioctl,
-};
-
-static const struct v4l2_subdev_ops msm_vfe_subdev_ops = {
-	.core = &msm_vfe_subdev_core_ops,
-	.video = &msm_vfe_subdev_video_ops,
-};
-
-static struct msm_cam_clk_info vfe_clk_info[] = {
-	{"vfe_clk", VFE_CLK_RATE},
-	{"vfe_pclk", -1},
-};
-
-static struct msm_cam_clk_info vfe_camif_clk_info[] = {
-	{"camif_pad_pclk", -1},
-	{"vfe_camif_clk", -1},
-};
-
-static void msm_vfe_camio_clk_sel(enum msm_camio_clk_src_type srctype)
-{
-	struct clk *clk = NULL;
-
-	clk = vfe31_ctrl->vfe_clk[0];
-
-	if (clk != NULL) {
-		switch (srctype) {
-		case MSM_CAMIO_CLK_SRC_INTERNAL:
-			clk_set_flags(clk, 0x00000100 << 1);
-			break;
-
-		case MSM_CAMIO_CLK_SRC_EXTERNAL:
-			clk_set_flags(clk, 0x00000100);
-			break;
-
-		default:
-			break;
-		}
-	}
-}
-
-static void msm_vfe_camif_pad_reg_reset(void)
-{
-	uint32_t reg;
-
-	msm_vfe_camio_clk_sel(MSM_CAMIO_CLK_SRC_INTERNAL);
-	usleep_range(10000, 15000);
-
-	reg = (msm_camera_io_r(vfe31_ctrl->camifbase)) & CAMIF_CFG_RMSK;
-	reg |= 0x3;
-	msm_camera_io_w(reg, vfe31_ctrl->camifbase);
-	usleep_range(10000, 15000);
-
-	reg = (msm_camera_io_r(vfe31_ctrl->camifbase)) & CAMIF_CFG_RMSK;
-	reg |= 0x10;
-	msm_camera_io_w(reg, vfe31_ctrl->camifbase);
-	usleep_range(10000, 15000);
-
-	reg = (msm_camera_io_r(vfe31_ctrl->camifbase)) & CAMIF_CFG_RMSK;
-	/* Need to be uninverted*/
-	reg &= 0x03;
-	msm_camera_io_w(reg, vfe31_ctrl->camifbase);
-	usleep_range(10000, 15000);
-}
-
-int msm_vfe_subdev_init(struct v4l2_subdev *sd)
-{
-	int rc = 0;
-	struct msm_cam_media_controller *mctl;
-	mctl = v4l2_get_subdev_hostdata(sd);
-	if (mctl == NULL) {
-		rc = -EINVAL;
-		goto mctl_failed;
-	}
-
-	spin_lock_init(&vfe31_ctrl->stop_flag_lock);
-	spin_lock_init(&vfe31_ctrl->state_lock);
-	spin_lock_init(&vfe31_ctrl->stats_bufq_lock);
-	spin_lock_init(&vfe31_ctrl->io_lock);
-	spin_lock_init(&vfe31_ctrl->update_ack_lock);
-	spin_lock_init(&vfe31_ctrl->tasklet_lock);
-	spin_lock_init(&vfe31_ctrl->sd_notify_lock);
-	INIT_LIST_HEAD(&vfe31_ctrl->tasklet_q);
-
-	memset(&vfe31_ctrl->stats_ctrl, 0, sizeof(struct msm_stats_bufq_ctrl));
-	memset(&vfe31_ctrl->stats_ops, 0, sizeof(struct msm_stats_ops));
-
-	vfe31_ctrl->update_linear = false;
-	vfe31_ctrl->update_rolloff = false;
-	vfe31_ctrl->update_la = false;
-	vfe31_ctrl->update_gamma = false;
-	vfe31_ctrl->hfr_mode = HFR_MODE_OFF;
-
-	vfe31_ctrl->vfebase = ioremap(vfe31_ctrl->vfemem->start,
-		resource_size(vfe31_ctrl->vfemem));
-	if (!vfe31_ctrl->vfebase) {
-		rc = -ENOMEM;
-		pr_err("%s: vfe ioremap failed\n", __func__);
-		goto vfe_remap_failed;
-	}
-	if (!mctl->sdata->csi_if) {
-		vfe31_ctrl->camifbase = ioremap(vfe31_ctrl->camifmem->start,
-			resource_size(vfe31_ctrl->camifmem));
-		if (!vfe31_ctrl->camifbase) {
-			rc = -ENOMEM;
-			pr_err("%s: camif ioremap failed\n", __func__);
-			goto camif_remap_failed;
-		}
-	}
-
-	if (vfe31_ctrl->fs_vfe) {
-		rc = regulator_enable(vfe31_ctrl->fs_vfe);
-		if (rc) {
-			pr_err("%s: Regulator FS_VFE enable failed\n",
-							__func__);
-			goto vfe_fs_failed;
-		}
-	}
-
-	rc = msm_cam_clk_enable(&vfe31_ctrl->pdev->dev, vfe_clk_info,
-		vfe31_ctrl->vfe_clk, ARRAY_SIZE(vfe_clk_info), 1);
-	if (rc < 0)
-		goto vfe_clk_enable_failed;
-
-	if (!mctl->sdata->csi_if) {
-		rc = msm_cam_clk_enable(&vfe31_ctrl->pdev->dev,
-			vfe_camif_clk_info,
-			vfe31_ctrl->vfe_camif_clk,
-			ARRAY_SIZE(vfe_camif_clk_info), 1);
-		if (rc < 0)
-			goto vfe_camif_clk_enable_failed;
-		msm_vfe_camif_pad_reg_reset();
-	}
-
-#ifdef CONFIG_MSM_IOMMU
-	rc = iommu_attach_device(mctl->domain, vfe31_ctrl->iommu_ctx_imgwr);
-	if (rc < 0) {
-		rc = -ENODEV;
-		pr_err("%s: Device attach failed\n", __func__);
-		goto device_imgwr_attach_failed;
-	}
-	rc = iommu_attach_device(mctl->domain, vfe31_ctrl->iommu_ctx_misc);
-	if (rc < 0) {
-		rc = -ENODEV;
-		pr_err("%s: Device attach failed\n", __func__);
-		goto device_misc_attach_failed;
-	}
-#endif
-
-	msm_camio_bus_scale_cfg(
-		mctl->sdata->pdata->cam_bus_scale_table, S_INIT);
-	msm_camio_bus_scale_cfg(
-		mctl->sdata->pdata->cam_bus_scale_table, S_PREVIEW);
-	vfe31_ctrl->register_total = VFE31_REGISTER_TOTAL;
-
-	enable_irq(vfe31_ctrl->vfeirq->start);
-
-	return rc;
-
-#ifdef CONFIG_MSM_IOMMU
-device_misc_attach_failed:
-	iommu_detach_device(mctl->domain, vfe31_ctrl->iommu_ctx_imgwr);
-device_imgwr_attach_failed:
-#endif
-	if (!mctl->sdata->csi_if)
-		msm_cam_clk_enable(&vfe31_ctrl->pdev->dev,
-			vfe_camif_clk_info,
-			vfe31_ctrl->vfe_camif_clk,
-			ARRAY_SIZE(vfe_camif_clk_info), 0);
-vfe_camif_clk_enable_failed:
-	msm_cam_clk_enable(&vfe31_ctrl->pdev->dev, vfe_clk_info,
-		vfe31_ctrl->vfe_clk, ARRAY_SIZE(vfe_clk_info), 0);
-vfe_clk_enable_failed:
-	regulator_disable(vfe31_ctrl->fs_vfe);
-vfe_fs_failed:
-	if (!mctl->sdata->csi_if)
-		iounmap(vfe31_ctrl->camifbase);
-camif_remap_failed:
-	iounmap(vfe31_ctrl->vfebase);
-vfe_remap_failed:
-mctl_failed:
-	return rc;
-}
-
-void msm_vfe_subdev_release(struct v4l2_subdev *sd)
-{
-	struct msm_cam_media_controller *pmctl =
-		(struct msm_cam_media_controller *)v4l2_get_subdev_hostdata(sd);
-	disable_irq(vfe31_ctrl->vfeirq->start);
-	tasklet_kill(&vfe31_tasklet);
-
-#ifdef CONFIG_MSM_IOMMU
-	iommu_detach_device(pmctl->domain, vfe31_ctrl->iommu_ctx_misc);
-	iommu_detach_device(pmctl->domain, vfe31_ctrl->iommu_ctx_imgwr);
-#endif
-
-	if (!pmctl->sdata->csi_if)
-		msm_cam_clk_enable(&vfe31_ctrl->pdev->dev,
-			vfe_camif_clk_info,
-			vfe31_ctrl->vfe_camif_clk,
-			ARRAY_SIZE(vfe_camif_clk_info), 0);
-
-	msm_cam_clk_enable(&vfe31_ctrl->pdev->dev, vfe_clk_info,
-		vfe31_ctrl->vfe_clk, ARRAY_SIZE(vfe_clk_info), 0);
-
-	if (vfe31_ctrl->fs_vfe)
-		regulator_disable(vfe31_ctrl->fs_vfe);
-
-	CDBG("%s Releasing resources\n", __func__);
-	if (!pmctl->sdata->csi_if)
-		iounmap(vfe31_ctrl->camifbase);
-	iounmap(vfe31_ctrl->vfebase);
-
-	if (atomic_read(&irq_cnt))
-		pr_warning("%s, Warning IRQ Count not ZERO\n", __func__);
-
-	msm_camio_bus_scale_cfg(
-		pmctl->sdata->pdata->cam_bus_scale_table, S_EXIT);
-}
-
-static const struct v4l2_subdev_internal_ops msm_vfe_internal_ops;
-
-static int __devinit vfe31_probe(struct platform_device *pdev)
-{
-	int rc = 0;
-	struct msm_cam_subdev_info sd_info;
-
-	CDBG("%s: device id = %d\n", __func__, pdev->id);
-
-	vfe31_ctrl = kzalloc(sizeof(struct vfe31_ctrl_type), GFP_KERNEL);
-	if (!vfe31_ctrl) {
-		pr_err("%s: no enough memory\n", __func__);
-		return -ENOMEM;
-	}
-
-	v4l2_subdev_init(&vfe31_ctrl->subdev, &msm_vfe_subdev_ops);
-	vfe31_ctrl->subdev.internal_ops = &msm_vfe_internal_ops;
-	vfe31_ctrl->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	snprintf(vfe31_ctrl->subdev.name,
-			 sizeof(vfe31_ctrl->subdev.name), "vfe3.1");
-	v4l2_set_subdevdata(&vfe31_ctrl->subdev, vfe31_ctrl);
-	platform_set_drvdata(pdev, &vfe31_ctrl->subdev);
-
-	vfe31_ctrl->vfemem = platform_get_resource_byname(pdev,
-		IORESOURCE_MEM, "msm_vfe");
-	if (!vfe31_ctrl->vfemem) {
-		pr_err("%s: no mem resource?\n", __func__);
-		rc = -ENODEV;
-		goto vfe31_no_resource;
-	}
-	vfe31_ctrl->vfeirq = platform_get_resource_byname(pdev,
-		IORESOURCE_IRQ, "msm_vfe");
-	if (!vfe31_ctrl->vfeirq) {
-		pr_err("%s: no irq resource?\n", __func__);
-		rc = -ENODEV;
-		goto vfe31_no_resource;
-	}
-	vfe31_ctrl->camifmem = platform_get_resource_byname(pdev,
-		IORESOURCE_MEM, "msm_camif");
-	if (!vfe31_ctrl->camifmem)
-		pr_err("%s: camif not supported\n", __func__);
-
-	vfe31_ctrl->vfeio = request_mem_region(vfe31_ctrl->vfemem->start,
-		resource_size(vfe31_ctrl->vfemem), pdev->name);
-	if (!vfe31_ctrl->vfeio) {
-		pr_err("%s: no valid mem region\n", __func__);
-		rc = -EBUSY;
-		goto vfe31_no_resource;
-	}
-
-	if (vfe31_ctrl->camifmem) {
-		vfe31_ctrl->camifio = request_mem_region(
-			vfe31_ctrl->camifmem->start,
-			resource_size(vfe31_ctrl->camifmem), pdev->name);
-		if (!vfe31_ctrl->camifio) {
-			release_mem_region(vfe31_ctrl->vfemem->start,
-				resource_size(vfe31_ctrl->vfemem));
-			pr_err("%s: no valid mem region\n", __func__);
-			rc = -EBUSY;
-			goto vfe31_no_resource;
-		}
-	}
-
-	rc = request_irq(vfe31_ctrl->vfeirq->start, vfe31_parse_irq,
-		IRQF_TRIGGER_RISING, "vfe", 0);
-	if (rc < 0) {
-		if (vfe31_ctrl->camifmem) {
-			release_mem_region(vfe31_ctrl->camifmem->start,
-				resource_size(vfe31_ctrl->camifmem));
-		}
-		release_mem_region(vfe31_ctrl->vfemem->start,
-			resource_size(vfe31_ctrl->vfemem));
-		pr_err("%s: irq request fail\n", __func__);
-		rc = -EBUSY;
-		goto vfe31_no_resource;
-	}
-
-	disable_irq(vfe31_ctrl->vfeirq->start);
-
-#ifdef CONFIG_MSM_IOMMU
-	/*get device context for IOMMU*/
-	vfe31_ctrl->iommu_ctx_imgwr =
-		msm_iommu_get_ctx("vfe_imgwr"); /*re-confirm*/
-	vfe31_ctrl->iommu_ctx_misc =
-		msm_iommu_get_ctx("vfe_misc"); /*re-confirm*/
-	if (!vfe31_ctrl->iommu_ctx_imgwr || !vfe31_ctrl->iommu_ctx_misc) {
-		if (vfe31_ctrl->camifmem) {
-			release_mem_region(vfe31_ctrl->camifmem->start,
-				resource_size(vfe31_ctrl->camifmem));
-		}
-		release_mem_region(vfe31_ctrl->vfemem->start,
-			resource_size(vfe31_ctrl->vfemem));
-		pr_err("%s: No iommu fw context found\n", __func__);
-		rc = -ENODEV;
-		goto vfe31_no_resource;
-	}
-#endif
-
-	vfe31_ctrl->pdev = pdev;
-	vfe31_ctrl->fs_vfe = regulator_get(&vfe31_ctrl->pdev->dev, "vdd");
-	if (IS_ERR(vfe31_ctrl->fs_vfe)) {
-		pr_err("%s: Regulator get failed %ld\n", __func__,
-			PTR_ERR(vfe31_ctrl->fs_vfe));
-		vfe31_ctrl->fs_vfe = NULL;
-	}
-
-	sd_info.sdev_type = VFE_DEV;
-	sd_info.sd_index = 0;
-	sd_info.irq_num = vfe31_ctrl->vfeirq->start;
-	msm_cam_register_subdev_node(&vfe31_ctrl->subdev, &sd_info);
-
-	media_entity_init(&vfe31_ctrl->subdev.entity, 0, NULL, 0);
-	vfe31_ctrl->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
-	vfe31_ctrl->subdev.entity.group_id = VFE_DEV;
-	vfe31_ctrl->subdev.entity.name = pdev->name;
-	vfe31_ctrl->subdev.entity.revision = vfe31_ctrl->subdev.devnode->num;
-	return 0;
-
-vfe31_no_resource:
-	kfree(vfe31_ctrl);
-	return 0;
-}
-
-static struct platform_driver vfe31_driver = {
-	.probe = vfe31_probe,
-	.driver = {
-	.name = MSM_VFE_DRV_NAME,
-	.owner = THIS_MODULE,
-	},
-};
-
-static int __init msm_vfe31_init_module(void)
-{
-	return platform_driver_register(&vfe31_driver);
-}
-
-static void __exit msm_vfe31_exit_module(void)
-{
-	platform_driver_unregister(&vfe31_driver);
-}
-
-module_init(msm_vfe31_init_module);
-module_exit(msm_vfe31_exit_module);
-MODULE_DESCRIPTION("VFE 3.1 driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe31_v4l2.h b/drivers/media/platform/msm/camera_v1/vfe/msm_vfe31_v4l2.h
deleted file mode 100644
index eea8078..0000000
--- a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe31_v4l2.h
+++ /dev/null
@@ -1,955 +0,0 @@
-/* Copyright (c) 2012 The Linux Foundation. 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.
- *
- */
-
-#ifndef __MSM_VFE31_V4L2_H__
-#define __MSM_VFE31_V4L2_H__
-
-#include <linux/bitops.h>
-#include "msm_vfe_stats_buf.h"
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-/* This defines total number registers in VFE.
- * Each register is 4 bytes so to get the range,
- * multiply this number with 4. */
-#define VFE31_REGISTER_TOTAL 0x0000017F
-
-/* at start of camif,  bit 1:0 = 0x01:enable
- * image data capture at frame boundary. */
-#define CAMIF_COMMAND_START  0x00000005
-
-/* bit 2= 0x1:clear the CAMIF_STATUS register
- * value. */
-#define CAMIF_COMMAND_CLEAR  0x00000004
-
-/* at stop of vfe pipeline, for now it is assumed
- * that camif will stop at any time. Bit 1:0 = 0x10:
- * disable image data capture immediately. */
-#define CAMIF_COMMAND_STOP_IMMEDIATELY  0x00000002
-
-/* at stop of vfe pipeline, for now it is assumed
- * that camif will stop at any time. Bit 1:0 = 0x00:
- * disable image data capture at frame boundary */
-#define CAMIF_COMMAND_STOP_AT_FRAME_BOUNDARY  0x00000000
-
-/* to halt axi bridge */
-#define AXI_HALT  0x00000001
-
-/* clear the halt bit. */
-#define AXI_HALT_CLEAR  0x00000000
-
-/* clear axi_halt_irq */
-#define MASK_AXI_HALT_IRQ	0xFF7FFFFF
-
-/* reset the pipeline when stop command is issued.
- * (without reset the register.) bit 26-31 = 0,
- * domain reset, bit 0-9 = 1 for module reset, except
- * register module. */
-#define VFE_RESET_UPON_STOP_CMD  0x000003ef
-
-/* reset the pipeline when reset command.
- * bit 26-31 = 0, domain reset, bit 0-9 = 1 for module reset. */
-#define VFE_RESET_UPON_RESET_CMD  0x000003ff
-
-/* bit 5 is for axi status idle or busy.
- * 1 =  halted,  0 = busy */
-#define AXI_STATUS_BUSY_MASK 0x00000020
-
-/* bit 0 & bit 1 = 1, both y and cbcr irqs need to be present
- * for frame done interrupt */
-#define VFE_COMP_IRQ_BOTH_Y_CBCR 3
-
-/* bit 1 = 1, only cbcr irq triggers frame done interrupt */
-#define VFE_COMP_IRQ_CBCR_ONLY 2
-
-/* bit 0 = 1, only y irq triggers frame done interrupt */
-#define VFE_COMP_IRQ_Y_ONLY 1
-
-/* bit 0 = 1, PM go;   bit1 = 1, PM stop */
-#define VFE_PERFORMANCE_MONITOR_GO   0x00000001
-#define VFE_PERFORMANCE_MONITOR_STOP 0x00000002
-
-/* bit 0 = 1, test gen go;   bit1 = 1, test gen stop */
-#define VFE_TEST_GEN_GO   0x00000001
-#define VFE_TEST_GEN_STOP 0x00000002
-
-/* the chroma is assumed to be interpolated between
- * the luma samples.  JPEG 4:2:2 */
-#define VFE_CHROMA_UPSAMPLE_INTERPOLATED 0
-
-/* constants for irq registers */
-#define VFE_DISABLE_ALL_IRQS 0
-/* bit =1 is to clear the corresponding bit in VFE_IRQ_STATUS.  */
-#define VFE_CLEAR_ALL_IRQS   0xffffffff
-
-#define VFE_IRQ_STATUS0_CAMIF_SOF_MASK            0x00000001
-#define VFE_IRQ_STATUS0_CAMIF_EOF_MASK            0x00000004
-#define VFE_IRQ_STATUS0_REG_UPDATE_MASK           0x00000020
-#define VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE0_MASK 0x00200000
-#define VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE1_MASK 0x00400000
-#define VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE2_MASK 0x00800000
-#define VFE_IRQ_STATUS1_RESET_AXI_HALT_ACK_MASK   0x00800000
-#define VFE_IRQ_STATUS0_STATS_COMPOSIT_MASK       0x01000000
-
-#define VFE_IRQ_STATUS0_STATS_AEC     0x2000  /* bit 13 */
-#define VFE_IRQ_STATUS0_STATS_AF      0x4000  /* bit 14 */
-#define VFE_IRQ_STATUS0_STATS_AWB     0x8000  /* bit 15 */
-#define VFE_IRQ_STATUS0_STATS_RS      0x10000  /* bit 16 */
-#define VFE_IRQ_STATUS0_STATS_CS      0x20000  /* bit 17 */
-#define VFE_IRQ_STATUS0_STATS_IHIST   0x40000  /* bit 18 */
-
-#define VFE_IRQ_STATUS0_SYNC_TIMER0   0x2000000  /* bit 25 */
-#define VFE_IRQ_STATUS0_SYNC_TIMER1   0x4000000  /* bit 26 */
-#define VFE_IRQ_STATUS0_SYNC_TIMER2   0x8000000  /* bit 27 */
-#define VFE_IRQ_STATUS0_ASYNC_TIMER0  0x10000000  /* bit 28 */
-#define VFE_IRQ_STATUS0_ASYNC_TIMER1  0x20000000  /* bit 29 */
-#define VFE_IRQ_STATUS0_ASYNC_TIMER2  0x40000000  /* bit 30 */
-#define VFE_IRQ_STATUS0_ASYNC_TIMER3  0x80000000  /* bit 31 */
-
-/* imask for while waiting for stop ack,  driver has already
- * requested stop, waiting for reset irq, and async timer irq.
- * For irq_status_0, bit 28-31 are for async timer. For
- * irq_status_1, bit 22 for reset irq, bit 23 for axi_halt_ack
-   irq */
-#define VFE_IMASK_WHILE_STOPPING_0  0xF0000000
-#define VFE_IMASK_WHILE_STOPPING_1  0x00C00000
-#define VFE_IMASK_RESET             0x00400000
-#define VFE_IMASK_AXI_HALT          0x00800000
-
-
-/* no error irq in mask 0 */
-#define VFE_IMASK_ERROR_ONLY_0  0x0
-/* when normal case, don't want to block error status. */
-/* bit 0-21 are error irq bits */
-#define VFE_IMASK_ERROR_ONLY_1  0x003fffff
-
-/* For BPC bit 0,bit 12-17 and bit 26 -20 are set to zero and other's 1 */
-#define BPC_MASK 0xF80C0FFE
-
-/* For BPC bit 1 and 2 are set to zero and other's 1 */
-#define ABF_MASK 0xFFFFFFF9
-
-/* For DBPC bit 0 is set to zero and other's 1 */
-#define DBPC_MASK 0xFFFFFFFE
-
-/* For DBCC bit 1 is set to zero and other's 1 */
-#define DBCC_MASK 0xFFFFFFFD
-
-/* For DBPC/ABF/DBCC/ABCC bits are set to 1 all others 0 */
-#define DEMOSAIC_MASK 0x8FFFFFFF
-/* For MCE enable bit 28 set to zero and other's 1 */
-#define MCE_EN_MASK 0xEFFFFFFF
-
-/* For MCE Q_K bit 28 to 31 set to zero and other's 1 */
-#define MCE_Q_K_MASK 0x0FFFFFFF
-
-#define AE_BG_ENABLE_MASK 0x00000020      /* bit 5 */
-#define AF_BF_ENABLE_MASK 0x00000040      /* bit 6 */
-#define AWB_ENABLE_MASK 0x00000080     /* bit 7 */
-
-#define RS_ENABLE_MASK 0x00000100      /* bit 8  */
-#define CS_ENABLE_MASK 0x00000200      /* bit 9  */
-#define RS_CS_ENABLE_MASK 0x00000300   /* bit 8,9  */
-#define IHIST_ENABLE_MASK 0x00008000   /* bit 15 */
-#define STATS_ENABLE_MASK 0x000483E0   /* bit 18,15,9,8,7,6,5*/
-
-#define VFE_REG_UPDATE_TRIGGER           1
-#define VFE_PM_BUF_MAX_CNT_MASK          0xFF
-#define VFE_DMI_CFG_DEFAULT              0x00000100
-#define VFE_AE_PINGPONG_STATUS_BIT       0x80
-#define VFE_AF_PINGPONG_STATUS_BIT       0x100
-#define VFE_AWB_PINGPONG_STATUS_BIT      0x200
-
-#define HFR_MODE_OFF 1
-#define VFE_FRAME_SKIP_PERIOD_MASK 0x0000001F /*bits 0 -4*/
-
-enum VFE31_DMI_RAM_SEL {
-	 NO_MEM_SELECTED          = 0,
-	 ROLLOFF_RAM              = 0x1,
-	 RGBLUT_RAM_CH0_BANK0     = 0x2,
-	 RGBLUT_RAM_CH0_BANK1     = 0x3,
-	 RGBLUT_RAM_CH1_BANK0     = 0x4,
-	 RGBLUT_RAM_CH1_BANK1     = 0x5,
-	 RGBLUT_RAM_CH2_BANK0     = 0x6,
-	 RGBLUT_RAM_CH2_BANK1     = 0x7,
-	 STATS_HIST_RAM           = 0x8,
-	 RGBLUT_CHX_BANK0         = 0x9,
-	 RGBLUT_CHX_BANK1         = 0xa,
-	 LUMA_ADAPT_LUT_RAM_BANK0 = 0xb,
-	 LUMA_ADAPT_LUT_RAM_BANK1 = 0xc
-};
-
-enum vfe_output_state {
-	VFE_STATE_IDLE,
-	VFE_STATE_START_REQUESTED,
-	VFE_STATE_STARTED,
-	VFE_STATE_STOP_REQUESTED,
-	VFE_STATE_STOPPED,
-};
-
-#define V31_CAMIF_OFF             0x000001E4
-#define V31_CAMIF_LEN             32
-
-#define V31_DEMUX_OFF             0x00000284
-#define V31_DEMUX_LEN             20
-
-#define V31_DEMOSAICV3_UP_REG_CNT 5
-
-#define V31_OUT_CLAMP_OFF         0x00000524
-#define V31_OUT_CLAMP_LEN         8
-
-#define V31_OPERATION_CFG_LEN     32
-
-#define V31_AXI_BUS_CMD_OFF       0x00000038
-#define V31_AXI_OUT_OFF           0x0000003C
-#define V31_AXI_OUT_LEN           240
-#define V31_AXI_CFG_LEN           47
-#define V31_AXI_RESERVED            1
-#define V31_AXI_RESERVED_LEN        4
-#define V31_AXI_BUS_CFG_LEN       16
-
-#define V31_FRAME_SKIP_OFF        0x00000504
-#define V31_FRAME_SKIP_LEN        32
-
-#define V31_CHROMA_SUBS_OFF       0x000004F8
-#define V31_CHROMA_SUBS_LEN       12
-
-#define V31_FOV_OFF           0x00000360
-#define V31_FOV_LEN           8
-
-#define V31_MAIN_SCALER_OFF 0x00000368
-#define V31_MAIN_SCALER_LEN 28
-
-#define V31_S2Y_OFF 0x000004D0
-#define V31_S2Y_LEN 20
-
-#define V31_S2CbCr_OFF 0x000004E4
-#define V31_S2CbCr_LEN 20
-
-#define V31_CHROMA_EN_OFF 0x000003C4
-#define V31_CHROMA_EN_LEN 36
-
-#define V31_SYNC_TIMER_OFF      0x0000020C
-#define V31_SYNC_TIMER_POLARITY_OFF 0x00000234
-#define V31_TIMER_SELECT_OFF        0x0000025C
-#define V31_SYNC_TIMER_LEN 28
-
-#define V31_ASYNC_TIMER_OFF 0x00000238
-#define V31_ASYNC_TIMER_LEN 28
-
-#define V31_BLACK_LEVEL_OFF 0x00000264
-#define V31_BLACK_LEVEL_LEN 16
-
-#define V31_MESH_ROLL_OFF_CFG_OFF             0x00000274
-#define V31_MESH_ROLL_OFF_CFG_LEN             16
-#define V31_MESH_ROLL_OFF_INIT_TABLE_SIZE     13
-#define V31_MESH_ROLL_OFF_DELTA_TABLE_SIZE    208
-#define V31_MESH_ROLL_OFF_DELTA_TABLE_OFFSET  32
-
-#define V31_COLOR_COR_OFF 0x00000388
-#define V31_COLOR_COR_LEN 52
-
-#define V31_WB_OFF 0x00000384
-#define V31_WB_LEN 4
-
-#define V31_RGB_G_OFF 0x000003BC
-#define V31_RGB_G_LEN 4
-
-#define V31_LA_OFF 0x000003C0
-#define V31_LA_LEN 4
-
-#define V31_SCE_OFF 0x00000418
-#define V31_SCE_LEN 136
-
-#define V31_CHROMA_SUP_OFF 0x000003E8
-#define V31_CHROMA_SUP_LEN 12
-
-#define V31_MCE_OFF 0x000003F4
-#define V31_MCE_LEN 36
-#define V31_STATS_AF_OFF 0x0000053c
-#define V31_STATS_AF_LEN 16
-
-#define V31_STATS_AE_OFF 0x00000534
-#define V31_STATS_AE_LEN 8
-
-#define V31_STATS_AWB_OFF 0x0000054c
-#define V31_STATS_AWB_LEN 32
-
-#define V31_STATS_IHIST_OFF 0x0000057c
-#define V31_STATS_IHIST_LEN 8
-
-#define V31_STATS_RS_OFF 0x0000056c
-#define V31_STATS_RS_LEN 8
-
-#define V31_STATS_CS_OFF 0x00000574
-#define V31_STATS_CS_LEN 8
-
-#define V31_ASF_OFF 0x000004A0
-#define V31_ASF_LEN 48
-#define V31_ASF_UPDATE_LEN 36
-#define V31_CAPTURE_LEN 4
-#define V31_GET_HW_VERSION_OFF 0
-#define V31_GET_HW_VERSION_LEN 4
-#define V31_DEMOSAICV3_OFF 0x00000298
-#define V31_DEMOSAICV3_LEN 4
-/* BPC     */
-#define V31_DEMOSAICV3_DBPC_CFG_OFF  0x0000029C
-#define V31_DEMOSAICV3_DBPC_LEN 8
-#define V31_XBAR_CFG_OFF 0x00000040
-/* ABF     */
-#define V31_DEMOSAICV3_ABF_OFF 0x000002A4
-#define V31_DEMOSAICV3_ABF_LEN 180
-#define V31_XBAR_CFG_LEN 8
-
-#define V31_MODULE_CFG_OFF 0x00000010
-#define V31_MODULE_CFG_LEN 4
-#define V31_EZTUNE_CFG_OFF 0x00000010
-#define V31_EZTUNE_CFG_LEN 4
-
-struct vfe_cmd_hw_version {
-	uint32_t minorVersion;
-	uint32_t majorVersion;
-	uint32_t coreVersion;
-};
-
-enum VFE_AXI_OUTPUT_MODE {
-	VFE_AXI_OUTPUT_MODE_Output1,
-	VFE_AXI_OUTPUT_MODE_Output2,
-	VFE_AXI_OUTPUT_MODE_Output1AndOutput2,
-	VFE_AXI_OUTPUT_MODE_CAMIFToAXIViaOutput2,
-	VFE_AXI_OUTPUT_MODE_Output2AndCAMIFToAXIViaOutput1,
-	VFE_AXI_OUTPUT_MODE_Output1AndCAMIFToAXIViaOutput2,
-	VFE_AXI_LAST_OUTPUT_MODE_ENUM
-};
-
-enum VFE_RAW_WR_PATH_SEL {
-	VFE_RAW_OUTPUT_DISABLED,
-	VFE_RAW_OUTPUT_ENC_CBCR_PATH,
-	VFE_RAW_OUTPUT_VIEW_CBCR_PATH,
-	VFE_RAW_OUTPUT_PATH_INVALID
-};
-
-#define VFE_AXI_OUTPUT_BURST_LENGTH     4
-#define VFE_MAX_NUM_FRAGMENTS_PER_FRAME 4
-#define VFE_AXI_OUTPUT_CFG_FRAME_COUNT  3
-
-struct vfe_cmds_per_write_master {
-	uint16_t imageWidth;
-	uint16_t imageHeight;
-	uint16_t outRowCount;
-	uint16_t outRowIncrement;
-	uint32_t outFragments[VFE_AXI_OUTPUT_CFG_FRAME_COUNT]
-		[VFE_MAX_NUM_FRAGMENTS_PER_FRAME];
-};
-
-struct vfe_cmds_axi_per_output_path {
-	uint8_t fragmentCount;
-	struct vfe_cmds_per_write_master firstWM;
-	struct vfe_cmds_per_write_master secondWM;
-};
-
-enum VFE_AXI_BURST_LENGTH {
-	VFE_AXI_BURST_LENGTH_IS_2  = 2,
-	VFE_AXI_BURST_LENGTH_IS_4  = 4,
-	VFE_AXI_BURST_LENGTH_IS_8  = 8,
-	VFE_AXI_BURST_LENGTH_IS_16 = 16
-};
-
-struct vfe_cmd_fov_crop_config {
-	uint8_t enable;
-	uint16_t firstPixel;
-	uint16_t lastPixel;
-	uint16_t firstLine;
-	uint16_t lastLine;
-};
-
-struct vfe_cmds_main_scaler_stripe_init {
-	uint16_t MNCounterInit;
-	uint16_t phaseInit;
-};
-
-struct vfe_cmds_scaler_one_dimension {
-	uint8_t  enable;
-	uint16_t inputSize;
-	uint16_t outputSize;
-	uint32_t phaseMultiplicationFactor;
-	uint8_t  interpolationResolution;
-};
-
-struct vfe_cmd_main_scaler_config {
-	uint8_t enable;
-	struct vfe_cmds_scaler_one_dimension    hconfig;
-	struct vfe_cmds_scaler_one_dimension    vconfig;
-	struct vfe_cmds_main_scaler_stripe_init MNInitH;
-	struct vfe_cmds_main_scaler_stripe_init MNInitV;
-};
-
-struct vfe_cmd_scaler2_config {
-	uint8_t enable;
-	struct vfe_cmds_scaler_one_dimension hconfig;
-	struct vfe_cmds_scaler_one_dimension vconfig;
-};
-
-
-struct vfe_cmd_frame_skip_update {
-	uint32_t output1Pattern;
-	uint32_t output2Pattern;
-};
-
-struct vfe_cmd_output_clamp_config {
-	uint8_t minCh0;
-	uint8_t minCh1;
-	uint8_t minCh2;
-	uint8_t maxCh0;
-	uint8_t maxCh1;
-	uint8_t maxCh2;
-};
-
-struct vfe_cmd_chroma_subsample_config {
-	uint8_t enable;
-	uint8_t cropEnable;
-	uint8_t vsubSampleEnable;
-	uint8_t hsubSampleEnable;
-	uint8_t vCosited;
-	uint8_t hCosited;
-	uint8_t vCositedPhase;
-	uint8_t hCositedPhase;
-	uint16_t cropWidthFirstPixel;
-	uint16_t cropWidthLastPixel;
-	uint16_t cropHeightFirstLine;
-	uint16_t cropHeightLastLine;
-};
-
-enum VFE_START_PIXEL_PATTERN {
-	VFE_BAYER_RGRGRG,
-	VFE_BAYER_GRGRGR,
-	VFE_BAYER_BGBGBG,
-	VFE_BAYER_GBGBGB,
-	VFE_YUV_YCbYCr,
-	VFE_YUV_YCrYCb,
-	VFE_YUV_CbYCrY,
-	VFE_YUV_CrYCbY
-};
-
-enum VFE_BUS_RD_INPUT_PIXEL_PATTERN {
-	VFE_BAYER_RAW,
-	VFE_YUV_INTERLEAVED,
-	VFE_YUV_PSEUDO_PLANAR_Y,
-	VFE_YUV_PSEUDO_PLANAR_CBCR
-};
-
-enum VFE_YUV_INPUT_COSITING_MODE {
-	VFE_YUV_COSITED,
-	VFE_YUV_INTERPOLATED
-};
-
-#define VFE31_GAMMA_NUM_ENTRIES  64
-
-#define VFE31_LA_TABLE_LENGTH    64
-
-#define VFE31_HIST_TABLE_LENGTH  256
-
-struct vfe_cmds_demosaic_abf {
-	uint8_t   enable;
-	uint8_t   forceOn;
-	uint8_t   shift;
-	uint16_t  lpThreshold;
-	uint16_t  max;
-	uint16_t  min;
-	uint8_t   ratio;
-};
-
-struct vfe_cmds_demosaic_bpc {
-	uint8_t   enable;
-	uint16_t  fmaxThreshold;
-	uint16_t  fminThreshold;
-	uint16_t  redDiffThreshold;
-	uint16_t  blueDiffThreshold;
-	uint16_t  greenDiffThreshold;
-};
-
-struct vfe_cmd_demosaic_config {
-	uint8_t   enable;
-	uint8_t   slopeShift;
-	struct vfe_cmds_demosaic_abf abfConfig;
-	struct vfe_cmds_demosaic_bpc bpcConfig;
-};
-
-struct vfe_cmd_demosaic_bpc_update {
-	struct vfe_cmds_demosaic_bpc bpcUpdate;
-};
-
-struct vfe_cmd_demosaic_abf_update {
-	struct vfe_cmds_demosaic_abf abfUpdate;
-};
-
-struct vfe_cmd_white_balance_config {
-	uint8_t  enable;
-	uint16_t ch2Gain;
-	uint16_t ch1Gain;
-	uint16_t ch0Gain;
-};
-
-enum VFE_COLOR_CORRECTION_COEF_QFACTOR {
-	COEF_IS_Q7_SIGNED,
-	COEF_IS_Q8_SIGNED,
-	COEF_IS_Q9_SIGNED,
-	COEF_IS_Q10_SIGNED
-};
-
-struct vfe_cmd_color_correction_config {
-	uint8_t     enable;
-	enum VFE_COLOR_CORRECTION_COEF_QFACTOR coefQFactor;
-	int16_t  C0;
-	int16_t  C1;
-	int16_t  C2;
-	int16_t  C3;
-	int16_t  C4;
-	int16_t  C5;
-	int16_t  C6;
-	int16_t  C7;
-	int16_t  C8;
-	int16_t  K0;
-	int16_t  K1;
-	int16_t  K2;
-};
-
-#define VFE_LA_TABLE_LENGTH 64
-
-struct vfe_cmd_la_config {
-	uint8_t enable;
-	int16_t table[VFE_LA_TABLE_LENGTH];
-};
-
-#define VFE_GAMMA_TABLE_LENGTH 256
-enum VFE_RGB_GAMMA_TABLE_SELECT {
-	RGB_GAMMA_CH0_SELECTED,
-	RGB_GAMMA_CH1_SELECTED,
-	RGB_GAMMA_CH2_SELECTED,
-	RGB_GAMMA_CH0_CH1_SELECTED,
-	RGB_GAMMA_CH0_CH2_SELECTED,
-	RGB_GAMMA_CH1_CH2_SELECTED,
-	RGB_GAMMA_CH0_CH1_CH2_SELECTED
-};
-
-struct vfe_cmd_rgb_gamma_config {
-	uint8_t enable;
-	enum VFE_RGB_GAMMA_TABLE_SELECT channelSelect;
-	int16_t table[VFE_GAMMA_TABLE_LENGTH];
-};
-
-struct vfe_cmd_chroma_enhan_config {
-	uint8_t  enable;
-	int16_t am;
-	int16_t ap;
-	int16_t bm;
-	int16_t bp;
-	int16_t cm;
-	int16_t cp;
-	int16_t dm;
-	int16_t dp;
-	int16_t kcr;
-	int16_t kcb;
-	int16_t RGBtoYConversionV0;
-	int16_t RGBtoYConversionV1;
-	int16_t RGBtoYConversionV2;
-	uint8_t RGBtoYConversionOffset;
-};
-
-struct vfe_cmd_chroma_suppression_config {
-	uint8_t enable;
-	uint8_t m1;
-	uint8_t m3;
-	uint8_t n1;
-	uint8_t n3;
-	uint8_t nn1;
-	uint8_t mm1;
-};
-
-struct vfe_cmd_asf_config {
-	uint8_t enable;
-	uint8_t smoothFilterEnabled;
-	uint8_t sharpMode;
-	uint8_t smoothCoefCenter;
-	uint8_t smoothCoefSurr;
-	uint8_t normalizeFactor;
-	uint8_t sharpK1;
-	uint8_t sharpK2;
-	uint8_t sharpThreshE1;
-	int8_t sharpThreshE2;
-	int8_t sharpThreshE3;
-	int8_t sharpThreshE4;
-	int8_t sharpThreshE5;
-	int8_t filter1Coefficients[9];
-	int8_t filter2Coefficients[9];
-	uint8_t  cropEnable;
-	uint16_t cropFirstPixel;
-	uint16_t cropLastPixel;
-	uint16_t cropFirstLine;
-	uint16_t cropLastLine;
-};
-
-struct vfe_cmd_asf_update {
-	uint8_t enable;
-	uint8_t smoothFilterEnabled;
-	uint8_t sharpMode;
-	uint8_t smoothCoefCenter;
-	uint8_t smoothCoefSurr;
-	uint8_t normalizeFactor;
-	uint8_t sharpK1;
-	uint8_t sharpK2;
-	uint8_t sharpThreshE1;
-	int8_t  sharpThreshE2;
-	int8_t  sharpThreshE3;
-	int8_t  sharpThreshE4;
-	int8_t  sharpThreshE5;
-	int8_t  filter1Coefficients[9];
-	int8_t  filter2Coefficients[9];
-	uint8_t cropEnable;
-};
-
-enum VFE_TEST_GEN_SYNC_EDGE {
-	VFE_TEST_GEN_SYNC_EDGE_ActiveHigh,
-	VFE_TEST_GEN_SYNC_EDGE_ActiveLow
-};
-
-
-struct vfe_cmd_bus_pm_start {
-	uint8_t output2YWrPmEnable;
-	uint8_t output2CbcrWrPmEnable;
-	uint8_t output1YWrPmEnable;
-	uint8_t output1CbcrWrPmEnable;
-};
-
-struct  vfe_frame_skip_counts {
-	uint32_t  totalFrameCount;
-	uint32_t  output1Count;
-	uint32_t  output2Count;
-};
-
-enum VFE_AXI_RD_UNPACK_HBI_SEL {
-	VFE_AXI_RD_HBI_32_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_64_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_128_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_256_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_512_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_1024_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_2048_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_4096_CLOCK_CYCLES
-};
-
-struct vfe_frame_bpc_info {
-	uint32_t greenDefectPixelCount;
-	uint32_t redBlueDefectPixelCount;
-};
-
-struct vfe_frame_asf_info {
-	uint32_t  asfMaxEdge;
-	uint32_t  asfHbiCount;
-};
-
-struct vfe_msg_camif_status {
-	uint8_t  camifState;
-	uint32_t pixelCount;
-	uint32_t lineCount;
-};
-
-struct vfe31_irq_status {
-	uint32_t vfeIrqStatus0;
-	uint32_t vfeIrqStatus1;
-	uint32_t camifStatus;
-	uint32_t demosaicStatus;
-	uint32_t asfMaxEdge;
-};
-
-#define V31_PREVIEW_AXI_FLAG  0x00000001
-#define V31_SNAPSHOT_AXI_FLAG (0x00000001<<1)
-
-struct vfe31_cmd_type {
-	uint16_t id;
-	uint32_t length;
-	uint32_t offset;
-	uint32_t flag;
-};
-
-struct vfe31_free_buf {
-	struct list_head node;
-	uint32_t paddr;
-	uint32_t y_off;
-	uint32_t cbcr_off;
-};
-
-struct vfe31_output_ch {
-	struct list_head free_buf_queue;
-	spinlock_t free_buf_lock;
-	uint32_t inst_handle;
-	int8_t ch0;
-	int8_t ch1;
-	int8_t ch2;
-	uint32_t  capture_cnt;
-	uint32_t  frame_drop_cnt;
-	struct msm_free_buf ping;
-	struct msm_free_buf pong;
-	struct msm_free_buf free_buf;
-};
-
-/* no error irq in mask 0 */
-#define VFE31_IMASK_ERROR_ONLY_0  0x0
-/* when normal case, don't want to block error status. */
-/* bit 0-21 are error irq bits */
-#define VFE31_IMASK_ERROR_ONLY_1               0x003FFFFF
-#define VFE31_IMASK_CAMIF_ERROR               (0x00000001<<0)
-#define VFE31_IMASK_STATS_CS_OVWR             (0x00000001<<1)
-#define VFE31_IMASK_STATS_IHIST_OVWR          (0x00000001<<2)
-#define VFE31_IMASK_REALIGN_BUF_Y_OVFL        (0x00000001<<3)
-#define VFE31_IMASK_REALIGN_BUF_CB_OVFL       (0x00000001<<4)
-#define VFE31_IMASK_REALIGN_BUF_CR_OVFL       (0x00000001<<5)
-#define VFE31_IMASK_VIOLATION                 (0x00000001<<6)
-#define VFE31_IMASK_IMG_MAST_0_BUS_OVFL       (0x00000001<<7)
-#define VFE31_IMASK_IMG_MAST_1_BUS_OVFL       (0x00000001<<8)
-#define VFE31_IMASK_IMG_MAST_2_BUS_OVFL       (0x00000001<<9)
-#define VFE31_IMASK_IMG_MAST_3_BUS_OVFL       (0x00000001<<10)
-#define VFE31_IMASK_IMG_MAST_4_BUS_OVFL       (0x00000001<<11)
-#define VFE31_IMASK_IMG_MAST_5_BUS_OVFL       (0x00000001<<12)
-#define VFE31_IMASK_IMG_MAST_6_BUS_OVFL       (0x00000001<<13)
-#define VFE31_IMASK_STATS_AE_BG_BUS_OVFL         (0x00000001<<14)
-#define VFE31_IMASK_STATS_AF_BF_BUS_OVFL         (0x00000001<<15)
-#define VFE31_IMASK_STATS_AWB_BUS_OVFL        (0x00000001<<16)
-#define VFE31_IMASK_STATS_RS_BUS_OVFL         (0x00000001<<17)
-#define VFE31_IMASK_STATS_CS_BUS_OVFL         (0x00000001<<18)
-#define VFE31_IMASK_STATS_IHIST_BUS_OVFL      (0x00000001<<19)
-#define VFE31_IMASK_STATS_SKIN_BHIST_BUS_OVFL       (0x00000001<<20)
-#define VFE31_IMASK_AXI_ERROR                 (0x00000001<<21)
-
-#define VFE_COM_STATUS 0x000FE000
-
-struct vfe31_output_path {
-	uint16_t output_mode;     /* bitmask  */
-
-	struct vfe31_output_ch out0; /* preview and thumbnail */
-	struct vfe31_output_ch out1; /* snapshot */
-	struct vfe31_output_ch out2; /* video    */
-};
-
-struct vfe31_frame_extra {
-	uint32_t greenDefectPixelCount;
-	uint32_t redBlueDefectPixelCount;
-
-	uint32_t  asfMaxEdge;
-	uint32_t  asfHbiCount;
-
-	uint32_t yWrPmStats0;
-	uint32_t yWrPmStats1;
-	uint32_t cbcrWrPmStats0;
-	uint32_t cbcrWrPmStats1;
-
-	uint32_t  frameCounter;
-};
-
-#define VFE_DISABLE_ALL_IRQS             0
-#define VFE_CLEAR_ALL_IRQS               0xffffffff
-
-#define VFE_HW_VERSION					 0x00000000
-#define VFE_GLOBAL_RESET                 0x00000004
-#define VFE_MODULE_RESET				 0x00000008
-#define VFE_CGC_OVERRIDE                 0x0000000C
-#define VFE_MODULE_CFG                   0x00000010
-#define VFE_CFG				 0x00000014
-#define VFE_IRQ_CMD                      0x00000018
-#define VFE_IRQ_MASK_0                   0x0000001C
-#define VFE_IRQ_MASK_1                   0x00000020
-#define VFE_IRQ_CLEAR_0                  0x00000024
-#define VFE_IRQ_CLEAR_1                  0x00000028
-#define VFE_IRQ_STATUS_0                 0x0000002C
-#define VFE_IRQ_STATUS_1                 0x00000030
-#define VFE_IRQ_COMP_MASK                0x00000034
-#define VFE_BUS_CMD                      0x00000038
-#define VFE_BUS_PING_PONG_STATUS         0x00000180
-#define VFE_BUS_OPERATION_STATUS         0x00000184
-
-#define VFE_BUS_IMAGE_MASTER_0_WR_PM_STATS_0        0x00000190
-#define VFE_BUS_IMAGE_MASTER_0_WR_PM_STATS_1        0x00000194
-
-#define VFE_AXI_CMD                      0x000001D8
-#define VFE_AXI_STATUS                   0x000001DC
-#define VFE_BUS_STATS_PING_PONG_BASE     0x000000F4
-
-#define VFE_BUS_STATS_AEC_WR_PING_ADDR   0x000000F4
-#define VFE_BUS_STATS_AEC_WR_PONG_ADDR   0x000000F8
-#define VFE_BUS_STATS_AEC_UB_CFG         0x000000FC
-#define VFE_BUS_STATS_AF_WR_PING_ADDR    0x00000100
-#define VFE_BUS_STATS_AF_WR_PONG_ADDR    0x00000104
-#define VFE_BUS_STATS_AF_UB_CFG          0x00000108
-#define VFE_BUS_STATS_AWB_WR_PING_ADDR   0x0000010C
-#define VFE_BUS_STATS_AWB_WR_PONG_ADDR   0x00000110
-#define VFE_BUS_STATS_AWB_UB_CFG         0x00000114
-#define VFE_BUS_STATS_RS_WR_PING_ADDR    0x00000118
-#define VFE_BUS_STATS_RS_WR_PONG_ADDR    0x0000011C
-#define VFE_BUS_STATS_RS_UB_CFG          0x00000120
-
-#define VFE_BUS_STATS_CS_WR_PING_ADDR    0x00000124
-#define VFE_BUS_STATS_CS_WR_PONG_ADDR    0x00000128
-#define VFE_BUS_STATS_CS_UB_CFG          0x0000012C
-#define VFE_BUS_STATS_HIST_WR_PING_ADDR  0x00000130
-#define VFE_BUS_STATS_HIST_WR_PONG_ADDR  0x00000134
-#define VFE_BUS_STATS_HIST_UB_CFG        0x00000138
-#define VFE_BUS_STATS_SKIN_WR_PING_ADDR  0x0000013C
-#define VFE_BUS_STATS_SKIN_WR_PONG_ADDR  0x00000140
-#define VFE_BUS_STATS_SKIN_UB_CFG        0x00000144
-#define VFE_BUS_PM_CMD                   0x00000188
-#define VFE_BUS_PM_CFG                   0x0000018C
-#define VFE_CAMIF_COMMAND                0x000001E0
-#define VFE_CAMIF_STATUS                 0x00000204
-#define VFE_REG_UPDATE_CMD               0x00000260
-#define VFE_DEMUX_GAIN_0                 0x00000288
-#define VFE_DEMUX_GAIN_1                 0x0000028C
-#define VFE_CHROMA_UP                    0x0000035C
-#define VFE_FRAMEDROP_ENC_Y_CFG          0x00000504
-#define VFE_FRAMEDROP_ENC_CBCR_CFG       0x00000508
-#define VFE_FRAMEDROP_ENC_Y_PATTERN      0x0000050C
-#define VFE_FRAMEDROP_ENC_CBCR_PATTERN   0x00000510
-#define VFE_FRAMEDROP_VIEW_Y             0x00000514
-#define VFE_FRAMEDROP_VIEW_CBCR          0x00000518
-#define VFE_FRAMEDROP_VIEW_Y_PATTERN     0x0000051C
-#define VFE_FRAMEDROP_VIEW_CBCR_PATTERN  0x00000520
-#define VFE_CLAMP_MAX                    0x00000524
-#define VFE_CLAMP_MIN                    0x00000528
-#define VFE_REALIGN_BUF                  0x0000052C
-#define VFE_STATS_CFG                    0x00000530
-#define VFE_STATS_AWB_SGW_CFG            0x00000554
-#define VFE_DMI_CFG                      0x00000598
-#define VFE_DMI_ADDR                     0x0000059C
-#define VFE_DMI_DATA_LO                  0x000005A4
-#define VFE_AXI_CFG                      0x00000600
-
-#define VFE31_OUTPUT_MODE_PT		BIT(0)
-#define VFE31_OUTPUT_MODE_S			BIT(1)
-#define VFE31_OUTPUT_MODE_V			BIT(2)
-#define VFE31_OUTPUT_MODE_P			BIT(3)
-#define VFE31_OUTPUT_MODE_T			BIT(4)
-#define VFE31_OUTPUT_MODE_P_ALL_CHNLS		BIT(5)
-#define VFE31_OUTPUT_MODE_PRIMARY		BIT(6)
-#define VFE31_OUTPUT_MODE_PRIMARY_ALL_CHNLS	BIT(7)
-#define VFE31_OUTPUT_MODE_SECONDARY		BIT(8)
-#define VFE31_OUTPUT_MODE_SECONDARY_ALL_CHNLS	BIT(9)
-struct vfe_stats_control {
-	uint8_t  ackPending;
-	uint32_t nextFrameAddrBuf;
-	uint32_t droppedStatsFrameCount;
-	uint32_t bufToRender;
-};
-
-struct vfe31_ctrl_type {
-	uint16_t operation_mode;     /* streaming or snapshot */
-	struct vfe31_output_path outpath;
-
-	uint32_t vfeImaskCompositePacked;
-
-	spinlock_t  stop_flag_lock;
-	spinlock_t  update_ack_lock;
-	spinlock_t  state_lock;
-	spinlock_t  io_lock;
-	spinlock_t  stats_bufq_lock;
-
-	uint32_t extlen;
-	void *extdata;
-
-	int8_t start_ack_pending;
-	int8_t stop_ack_pending;
-	int8_t reset_ack_pending;
-	int8_t update_ack_pending;
-	enum vfe_output_state recording_state;
-	int8_t update_linear;
-	int8_t update_rolloff;
-	int8_t update_la;
-	int8_t update_gamma;
-	enum vfe_output_state liveshot_state;
-
-	spinlock_t  tasklet_lock;
-	struct list_head tasklet_q;
-	void __iomem *vfebase;
-	void __iomem *camifbase;
-	void *syncdata;
-	uint32_t register_total;
-
-	struct resource	*vfemem;
-	struct resource	*camifmem;
-	struct resource *vfeio;
-	struct resource *camifio;
-	struct resource *vfeirq;
-	struct regulator *fs_vfe;
-
-	uint32_t stats_comp;
-	atomic_t vstate;
-	uint32_t vfe_capture_count;
-	uint32_t sync_timer_repeat_count;
-	uint32_t sync_timer_state;
-	uint32_t sync_timer_number;
-
-	uint32_t vfeFrameId;
-	uint32_t output1Pattern;
-	uint32_t output1Period;
-	uint32_t output2Pattern;
-	uint32_t output2Period;
-	uint32_t vfeFrameSkipCount;
-	uint32_t vfeFrameSkipPeriod;
-	struct vfe_stats_control afStatsControl;
-	struct vfe_stats_control awbStatsControl;
-	struct vfe_stats_control aecStatsControl;
-	struct vfe_stats_control ihistStatsControl;
-	struct vfe_stats_control rsStatsControl;
-	struct vfe_stats_control csStatsControl;
-
-	/* v4l2 subdev */
-	struct v4l2_subdev subdev;
-	struct platform_device *pdev;
-	struct clk *vfe_clk[5];
-	struct clk *vfe_camif_clk[2];
-	spinlock_t  sd_notify_lock;
-	uint32_t hfr_mode;
-	uint32_t frame_skip_cnt;
-	uint32_t frame_skip_pattern;
-	uint32_t snapshot_frame_cnt;
-	struct msm_stats_bufq_ctrl stats_ctrl;
-	struct msm_stats_ops stats_ops;
-	struct device *iommu_ctx_imgwr;
-	struct device *iommu_ctx_misc;
-};
-
-enum VFE31_STATS_NUM {
-	STATS_AE_NUM,
-	STATS_AF_NUM,
-	STATS_AWB_NUM,
-	STATS_RS_NUM,
-	STATS_CS_NUM,
-	STATS_IHIST_NUM,
-	STATS_SKIN_NUM,
-	STATS_MAX_NUM,
-};
-
-struct vfe_cmd_stats_ack {
-	uint32_t  nextStatsBuf;
-};
-
-#define VFE_STATS_BUFFER_COUNT            3
-
-struct vfe_cmd_stats_buf {
-	uint32_t statsBuf[VFE_STATS_BUFFER_COUNT];
-};
-#endif /* __MSM_VFE31_H__ */
diff --git a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe32.c b/drivers/media/platform/msm/camera_v1/vfe/msm_vfe32.c
deleted file mode 100644
index 3570170..0000000
--- a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe32.c
+++ /dev/null
@@ -1,6782 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-
-#include <linux/module.h>
-#include <linux/uaccess.h>
-#include <linux/interrupt.h>
-#include <linux/slab.h>
-#include <linux/io.h>
-#include <linux/atomic.h>
-#include <linux/regulator/consumer.h>
-#include <linux/clk.h>
-#include <mach/irqs.h>
-#include <mach/camera.h>
-#include <media/v4l2-device.h>
-#include <media/v4l2-subdev.h>
-#include <media/msm_isp.h>
-
-#include "msm.h"
-#include "msm_cam_server.h"
-#include "msm_vfe32.h"
-
-atomic_t irq_cnt;
-
-#define VFE32_AXI_OFFSET 0x0050
-#define vfe32_get_ch_ping_addr(base, chn) \
-	(msm_camera_io_r((base) + 0x0050 + 0x18 * (chn)))
-#define vfe32_get_ch_pong_addr(base, chn) \
-	(msm_camera_io_r((base) + 0x0050 + 0x18 * (chn) + 4))
-#define vfe32_get_ch_addr(ping_pong, base, chn) \
-	((((ping_pong) & (1 << (chn))) == 0) ? \
-	(vfe32_get_ch_pong_addr((base), chn)) : \
-	(vfe32_get_ch_ping_addr((base), chn)))
-
-#define vfe32_put_ch_ping_addr(base, chn, addr) \
-	(msm_camera_io_w((addr), (base) + 0x0050 + 0x18 * (chn)))
-#define vfe32_put_ch_pong_addr(base, chn, addr) \
-	(msm_camera_io_w((addr), (base) + 0x0050 + 0x18 * (chn) + 4))
-#define vfe32_put_ch_addr(ping_pong, base, chn, addr) \
-	(((ping_pong) & (1 << (chn))) == 0 ?   \
-	vfe32_put_ch_pong_addr((base), (chn), (addr)) : \
-	vfe32_put_ch_ping_addr((base), (chn), (addr)))
-
-static uint32_t vfe_clk_rate;
-static void vfe32_send_isp_msg(struct v4l2_subdev *sd,
-	uint32_t vfeFrameId, uint32_t isp_msg_id);
-
-
-struct vfe32_isr_queue_cmd {
-	struct list_head list;
-	uint32_t                           vfeInterruptStatus0;
-	uint32_t                           vfeInterruptStatus1;
-};
-
-static struct vfe32_cmd_type vfe32_cmd[] = {
-/* 0*/	{VFE_CMD_DUMMY_0},
-		{VFE_CMD_SET_CLK},
-		{VFE_CMD_RESET},
-		{VFE_CMD_START},
-		{VFE_CMD_TEST_GEN_START},
-/* 5*/	{VFE_CMD_OPERATION_CFG, V32_OPERATION_CFG_LEN},
-		{VFE_CMD_AXI_OUT_CFG, V32_AXI_OUT_LEN, V32_AXI_OUT_OFF, 0xFF},
-		{VFE_CMD_CAMIF_CFG, V32_CAMIF_LEN, V32_CAMIF_OFF, 0xFF},
-		{VFE_CMD_AXI_INPUT_CFG},
-		{VFE_CMD_BLACK_LEVEL_CFG, V32_BLACK_LEVEL_LEN,
-		V32_BLACK_LEVEL_OFF,
-		0xFF},
-/*10*/  {VFE_CMD_MESH_ROLL_OFF_CFG, V32_MESH_ROLL_OFF_CFG_LEN,
-		V32_MESH_ROLL_OFF_CFG_OFF, 0xFF},
-		{VFE_CMD_DEMUX_CFG, V32_DEMUX_LEN, V32_DEMUX_OFF, 0xFF},
-		{VFE_CMD_FOV_CFG, V32_FOV_LEN, V32_FOV_OFF, 0xFF},
-		{VFE_CMD_MAIN_SCALER_CFG, V32_MAIN_SCALER_LEN,
-		V32_MAIN_SCALER_OFF, 0xFF},
-		{VFE_CMD_WB_CFG, V32_WB_LEN, V32_WB_OFF, 0xFF},
-/*15*/	{VFE_CMD_COLOR_COR_CFG, V32_COLOR_COR_LEN, V32_COLOR_COR_OFF, 0xFF},
-		{VFE_CMD_RGB_G_CFG, V32_RGB_G_LEN, V32_RGB_G_OFF, 0xFF},
-		{VFE_CMD_LA_CFG, V32_LA_LEN, V32_LA_OFF, 0xFF },
-		{VFE_CMD_CHROMA_EN_CFG, V32_CHROMA_EN_LEN, V32_CHROMA_EN_OFF,
-		0xFF},
-		{VFE_CMD_CHROMA_SUP_CFG, V32_CHROMA_SUP_LEN, V32_CHROMA_SUP_OFF,
-		0xFF},
-/*20*/	{VFE_CMD_MCE_CFG, V32_MCE_LEN, V32_MCE_OFF, 0xFF},
-		{VFE_CMD_SK_ENHAN_CFG, V32_SCE_LEN, V32_SCE_OFF, 0xFF},
-		{VFE_CMD_ASF_CFG, V32_ASF_LEN, V32_ASF_OFF, 0xFF},
-		{VFE_CMD_S2Y_CFG, V32_S2Y_LEN, V32_S2Y_OFF, 0xFF},
-		{VFE_CMD_S2CbCr_CFG, V32_S2CbCr_LEN, V32_S2CbCr_OFF, 0xFF},
-/*25*/	{VFE_CMD_CHROMA_SUBS_CFG, V32_CHROMA_SUBS_LEN, V32_CHROMA_SUBS_OFF,
-		0xFF},
-		{VFE_CMD_OUT_CLAMP_CFG, V32_OUT_CLAMP_LEN, V32_OUT_CLAMP_OFF,
-		0xFF},
-		{VFE_CMD_FRAME_SKIP_CFG, V32_FRAME_SKIP_LEN, V32_FRAME_SKIP_OFF,
-		0xFF},
-		{VFE_CMD_DUMMY_1},
-		{VFE_CMD_DUMMY_2},
-/*30*/	{VFE_CMD_DUMMY_3},
-		{VFE_CMD_UPDATE},
-		{VFE_CMD_BL_LVL_UPDATE, V32_BLACK_LEVEL_LEN,
-		V32_BLACK_LEVEL_OFF, 0xFF},
-		{VFE_CMD_DEMUX_UPDATE, V32_DEMUX_LEN, V32_DEMUX_OFF, 0xFF},
-		{VFE_CMD_FOV_UPDATE, V32_FOV_LEN, V32_FOV_OFF, 0xFF},
-/*35*/	{VFE_CMD_MAIN_SCALER_UPDATE, V32_MAIN_SCALER_LEN, V32_MAIN_SCALER_OFF,
-		0xFF},
-		{VFE_CMD_WB_UPDATE, V32_WB_LEN, V32_WB_OFF, 0xFF},
-		{VFE_CMD_COLOR_COR_UPDATE, V32_COLOR_COR_LEN, V32_COLOR_COR_OFF,
-		0xFF},
-		{VFE_CMD_RGB_G_UPDATE, V32_RGB_G_LEN, V32_CHROMA_EN_OFF, 0xFF},
-		{VFE_CMD_LA_UPDATE, V32_LA_LEN, V32_LA_OFF, 0xFF },
-/*40*/	{VFE_CMD_CHROMA_EN_UPDATE, V32_CHROMA_EN_LEN, V32_CHROMA_EN_OFF,
-		0xFF},
-		{VFE_CMD_CHROMA_SUP_UPDATE, V32_CHROMA_SUP_LEN,
-		V32_CHROMA_SUP_OFF, 0xFF},
-		{VFE_CMD_MCE_UPDATE, V32_MCE_LEN, V32_MCE_OFF, 0xFF},
-		{VFE_CMD_SK_ENHAN_UPDATE, V32_SCE_LEN, V32_SCE_OFF, 0xFF},
-		{VFE_CMD_S2CbCr_UPDATE, V32_S2CbCr_LEN, V32_S2CbCr_OFF, 0xFF},
-/*45*/	{VFE_CMD_S2Y_UPDATE, V32_S2Y_LEN, V32_S2Y_OFF, 0xFF},
-		{VFE_CMD_ASF_UPDATE, V32_ASF_UPDATE_LEN, V32_ASF_OFF, 0xFF},
-		{VFE_CMD_FRAME_SKIP_UPDATE},
-		{VFE_CMD_CAMIF_FRAME_UPDATE},
-		{VFE_CMD_STATS_AF_UPDATE, V32_STATS_AF_LEN, V32_STATS_AF_OFF},
-/*50*/	{VFE_CMD_STATS_AE_UPDATE, V32_STATS_AE_LEN, V32_STATS_AE_OFF},
-		{VFE_CMD_STATS_AWB_UPDATE, V32_STATS_AWB_LEN,
-		V32_STATS_AWB_OFF},
-		{VFE_CMD_STATS_RS_UPDATE, V32_STATS_RS_LEN, V32_STATS_RS_OFF},
-		{VFE_CMD_STATS_CS_UPDATE, V32_STATS_CS_LEN, V32_STATS_CS_OFF},
-		{VFE_CMD_STATS_SKIN_UPDATE},
-/*55*/	{VFE_CMD_STATS_IHIST_UPDATE, V32_STATS_IHIST_LEN, V32_STATS_IHIST_OFF},
-		{VFE_CMD_DUMMY_4},
-		{VFE_CMD_EPOCH1_ACK},
-		{VFE_CMD_EPOCH2_ACK},
-		{VFE_CMD_START_RECORDING},
-/*60*/	{VFE_CMD_STOP_RECORDING},
-		{VFE_CMD_DUMMY_5},
-		{VFE_CMD_DUMMY_6},
-		{VFE_CMD_CAPTURE, V32_CAPTURE_LEN, 0xFF},
-		{VFE_CMD_DUMMY_7},
-/*65*/	{VFE_CMD_STOP},
-		{VFE_CMD_GET_HW_VERSION, V32_GET_HW_VERSION_LEN,
-		V32_GET_HW_VERSION_OFF},
-		{VFE_CMD_GET_FRAME_SKIP_COUNTS},
-		{VFE_CMD_OUTPUT1_BUFFER_ENQ},
-		{VFE_CMD_OUTPUT2_BUFFER_ENQ},
-/*70*/	{VFE_CMD_OUTPUT3_BUFFER_ENQ},
-		{VFE_CMD_JPEG_OUT_BUF_ENQ},
-		{VFE_CMD_RAW_OUT_BUF_ENQ},
-		{VFE_CMD_RAW_IN_BUF_ENQ},
-		{VFE_CMD_STATS_AF_ENQ},
-/*75*/	{VFE_CMD_STATS_AE_ENQ},
-		{VFE_CMD_STATS_AWB_ENQ},
-		{VFE_CMD_STATS_RS_ENQ},
-		{VFE_CMD_STATS_CS_ENQ},
-		{VFE_CMD_STATS_SKIN_ENQ},
-/*80*/	{VFE_CMD_STATS_IHIST_ENQ},
-		{VFE_CMD_DUMMY_8},
-		{VFE_CMD_JPEG_ENC_CFG},
-		{VFE_CMD_DUMMY_9},
-		{VFE_CMD_STATS_AF_START, V32_STATS_AF_LEN, V32_STATS_AF_OFF},
-/*85*/	{VFE_CMD_STATS_AF_STOP},
-		{VFE_CMD_STATS_AE_START, V32_STATS_AE_LEN, V32_STATS_AE_OFF},
-		{VFE_CMD_STATS_AE_STOP},
-		{VFE_CMD_STATS_AWB_START, V32_STATS_AWB_LEN, V32_STATS_AWB_OFF},
-		{VFE_CMD_STATS_AWB_STOP},
-/*90*/	{VFE_CMD_STATS_RS_START, V32_STATS_RS_LEN, V32_STATS_RS_OFF},
-		{VFE_CMD_STATS_RS_STOP},
-		{VFE_CMD_STATS_CS_START, V32_STATS_CS_LEN, V32_STATS_CS_OFF},
-		{VFE_CMD_STATS_CS_STOP},
-		{VFE_CMD_STATS_SKIN_START},
-/*95*/	{VFE_CMD_STATS_SKIN_STOP},
-		{VFE_CMD_STATS_IHIST_START,
-		V32_STATS_IHIST_LEN, V32_STATS_IHIST_OFF},
-		{VFE_CMD_STATS_IHIST_STOP},
-		{VFE_CMD_DUMMY_10},
-		{VFE_CMD_SYNC_TIMER_SETTING, V32_SYNC_TIMER_LEN,
-			V32_SYNC_TIMER_OFF},
-/*100*/	{VFE_CMD_ASYNC_TIMER_SETTING, V32_ASYNC_TIMER_LEN, V32_ASYNC_TIMER_OFF},
-		{VFE_CMD_LIVESHOT},
-		{VFE_CMD_LA_SETUP},
-		{VFE_CMD_LINEARIZATION_CFG, V32_LINEARIZATION_LEN1,
-			V32_LINEARIZATION_OFF1},
-		{VFE_CMD_DEMOSAICV3},
-/*105*/	{VFE_CMD_DEMOSAICV3_ABCC_CFG},
-		{VFE_CMD_DEMOSAICV3_DBCC_CFG, V32_DEMOSAICV3_DBCC_LEN,
-			V32_DEMOSAICV3_DBCC_OFF},
-		{VFE_CMD_DEMOSAICV3_DBPC_CFG},
-		{VFE_CMD_DEMOSAICV3_ABF_CFG, V32_DEMOSAICV3_ABF_LEN,
-			V32_DEMOSAICV3_ABF_OFF},
-		{VFE_CMD_DEMOSAICV3_ABCC_UPDATE},
-/*110*/	{VFE_CMD_DEMOSAICV3_DBCC_UPDATE, V32_DEMOSAICV3_DBCC_LEN,
-			V32_DEMOSAICV3_DBCC_OFF},
-		{VFE_CMD_DEMOSAICV3_DBPC_UPDATE},
-		{VFE_CMD_XBAR_CFG},
-		{VFE_CMD_MODULE_CFG, V32_MODULE_CFG_LEN, V32_MODULE_CFG_OFF},
-		{VFE_CMD_ZSL},
-/*115*/	{VFE_CMD_LINEARIZATION_UPDATE, V32_LINEARIZATION_LEN1,
-			V32_LINEARIZATION_OFF1},
-		{VFE_CMD_DEMOSAICV3_ABF_UPDATE, V32_DEMOSAICV3_ABF_LEN,
-			V32_DEMOSAICV3_ABF_OFF},
-		{VFE_CMD_CLF_CFG, V32_CLF_CFG_LEN, V32_CLF_CFG_OFF},
-		{VFE_CMD_CLF_LUMA_UPDATE, V32_CLF_LUMA_UPDATE_LEN,
-			V32_CLF_LUMA_UPDATE_OFF},
-		{VFE_CMD_CLF_CHROMA_UPDATE, V32_CLF_CHROMA_UPDATE_LEN,
-			V32_CLF_CHROMA_UPDATE_OFF},
-/*120*/ {VFE_CMD_PCA_ROLL_OFF_CFG},
-		{VFE_CMD_PCA_ROLL_OFF_UPDATE},
-		{VFE_CMD_GET_REG_DUMP},
-		{VFE_CMD_GET_LINEARIZATON_TABLE},
-		{VFE_CMD_GET_MESH_ROLLOFF_TABLE},
-/*125*/ {VFE_CMD_GET_PCA_ROLLOFF_TABLE},
-		{VFE_CMD_GET_RGB_G_TABLE},
-		{VFE_CMD_GET_LA_TABLE},
-		{VFE_CMD_DEMOSAICV3_UPDATE},
-		{VFE_CMD_ACTIVE_REGION_CFG},
-/*130*/ {VFE_CMD_COLOR_PROCESSING_CONFIG},
-		{VFE_CMD_STATS_WB_AEC_CONFIG},
-		{VFE_CMD_STATS_WB_AEC_UPDATE},
-		{VFE_CMD_Y_GAMMA_CONFIG},
-		{VFE_CMD_SCALE_OUTPUT1_CONFIG},
-/*135*/ {VFE_CMD_SCALE_OUTPUT2_CONFIG},
-		{VFE_CMD_CAPTURE_RAW},
-		{VFE_CMD_STOP_LIVESHOT},
-		{VFE_CMD_RECONFIG_VFE},
-		{VFE_CMD_STATS_REQBUF},
-/*140*/	{VFE_CMD_STATS_ENQUEUEBUF},
-		{VFE_CMD_STATS_FLUSH_BUFQ},
-		{VFE_CMD_STATS_UNREGBUF},
-		{VFE_CMD_STATS_BG_START, V32_STATS_BG_LEN, V32_STATS_BG_OFF},
-		{VFE_CMD_STATS_BG_STOP},
-		{VFE_CMD_STATS_BF_START, V32_STATS_BF_LEN, V32_STATS_BF_OFF},
-/*145*/ {VFE_CMD_STATS_BF_STOP},
-		{VFE_CMD_STATS_BHIST_START, V32_STATS_BHIST_LEN,
-			V32_STATS_BHIST_OFF},
-/*147*/	{VFE_CMD_STATS_BHIST_STOP},
-};
-
-uint32_t vfe32_AXI_WM_CFG[] = {
-	0x0000004C,
-	0x00000064,
-	0x0000007C,
-	0x00000094,
-	0x000000AC,
-	0x000000C4,
-	0x000000DC,
-};
-
-static const char * const vfe32_general_cmd[] = {
-	"DUMMY_0",  /* 0 */
-	"SET_CLK",
-	"RESET",
-	"START",
-	"TEST_GEN_START",
-	"OPERATION_CFG",  /* 5 */
-	"AXI_OUT_CFG",
-	"CAMIF_CFG",
-	"AXI_INPUT_CFG",
-	"BLACK_LEVEL_CFG",
-	"ROLL_OFF_CFG",  /* 10 */
-	"DEMUX_CFG",
-	"FOV_CFG",
-	"MAIN_SCALER_CFG",
-	"WB_CFG",
-	"COLOR_COR_CFG", /* 15 */
-	"RGB_G_CFG",
-	"LA_CFG",
-	"CHROMA_EN_CFG",
-	"CHROMA_SUP_CFG",
-	"MCE_CFG", /* 20 */
-	"SK_ENHAN_CFG",
-	"ASF_CFG",
-	"S2Y_CFG",
-	"S2CbCr_CFG",
-	"CHROMA_SUBS_CFG",  /* 25 */
-	"OUT_CLAMP_CFG",
-	"FRAME_SKIP_CFG",
-	"DUMMY_1",
-	"DUMMY_2",
-	"DUMMY_3",  /* 30 */
-	"UPDATE",
-	"BL_LVL_UPDATE",
-	"DEMUX_UPDATE",
-	"FOV_UPDATE",
-	"MAIN_SCALER_UPDATE",  /* 35 */
-	"WB_UPDATE",
-	"COLOR_COR_UPDATE",
-	"RGB_G_UPDATE",
-	"LA_UPDATE",
-	"CHROMA_EN_UPDATE",  /* 40 */
-	"CHROMA_SUP_UPDATE",
-	"MCE_UPDATE",
-	"SK_ENHAN_UPDATE",
-	"S2CbCr_UPDATE",
-	"S2Y_UPDATE",  /* 45 */
-	"ASF_UPDATE",
-	"FRAME_SKIP_UPDATE",
-	"CAMIF_FRAME_UPDATE",
-	"STATS_AF_UPDATE",
-	"STATS_AE_UPDATE",  /* 50 */
-	"STATS_AWB_UPDATE",
-	"STATS_RS_UPDATE",
-	"STATS_CS_UPDATE",
-	"STATS_SKIN_UPDATE",
-	"STATS_IHIST_UPDATE",  /* 55 */
-	"DUMMY_4",
-	"EPOCH1_ACK",
-	"EPOCH2_ACK",
-	"START_RECORDING",
-	"STOP_RECORDING",  /* 60 */
-	"DUMMY_5",
-	"DUMMY_6",
-	"CAPTURE",
-	"DUMMY_7",
-	"STOP",  /* 65 */
-	"GET_HW_VERSION",
-	"GET_FRAME_SKIP_COUNTS",
-	"OUTPUT1_BUFFER_ENQ",
-	"OUTPUT2_BUFFER_ENQ",
-	"OUTPUT3_BUFFER_ENQ",  /* 70 */
-	"JPEG_OUT_BUF_ENQ",
-	"RAW_OUT_BUF_ENQ",
-	"RAW_IN_BUF_ENQ",
-	"STATS_AF_ENQ",
-	"STATS_AE_ENQ",  /* 75 */
-	"STATS_AWB_ENQ",
-	"STATS_RS_ENQ",
-	"STATS_CS_ENQ",
-	"STATS_SKIN_ENQ",
-	"STATS_IHIST_ENQ",  /* 80 */
-	"DUMMY_8",
-	"JPEG_ENC_CFG",
-	"DUMMY_9",
-	"STATS_AF_START",
-	"STATS_AF_STOP",  /* 85 */
-	"STATS_AE_START",
-	"STATS_AE_STOP",
-	"STATS_AWB_START",
-	"STATS_AWB_STOP",
-	"STATS_RS_START",  /* 90 */
-	"STATS_RS_STOP",
-	"STATS_CS_START",
-	"STATS_CS_STOP",
-	"STATS_SKIN_START",
-	"STATS_SKIN_STOP",  /* 95 */
-	"STATS_IHIST_START",
-	"STATS_IHIST_STOP",
-	"DUMMY_10",
-	"SYNC_TIMER_SETTING",
-	"ASYNC_TIMER_SETTING",  /* 100 */
-	"LIVESHOT",
-	"LA_SETUP",
-	"LINEARIZATION_CFG",
-	"DEMOSAICV3",
-	"DEMOSAICV3_ABCC_CFG", /* 105 */
-	"DEMOSAICV3_DBCC_CFG",
-	"DEMOSAICV3_DBPC_CFG",
-	"DEMOSAICV3_ABF_CFG",
-	"DEMOSAICV3_ABCC_UPDATE",
-	"DEMOSAICV3_DBCC_UPDATE", /* 110 */
-	"DEMOSAICV3_DBPC_UPDATE",
-	"XBAR_CFG",
-	"EZTUNE_CFG",
-	"V32_ZSL",
-	"LINEARIZATION_UPDATE", /*115*/
-	"DEMOSAICV3_ABF_UPDATE",
-	"CLF_CFG",
-	"CLF_LUMA_UPDATE",
-	"CLF_CHROMA_UPDATE",
-	"PCA_ROLL_OFF_CFG", /*120*/
-	"PCA_ROLL_OFF_UPDATE",
-	"GET_REG_DUMP",
-	"GET_LINEARIZATON_TABLE",
-	"GET_MESH_ROLLOFF_TABLE",
-	"GET_PCA_ROLLOFF_TABLE", /*125*/
-	"GET_RGB_G_TABLE",
-	"GET_LA_TABLE",
-	"DEMOSAICV3_UPDATE",
-	"DUMMY_11",
-	"DUMMY_12", /*130*/
-	"DUMMY_13",
-	"DUMMY_14",
-	"DUMMY_15",
-	"DUMMY_16",
-	"DUMMY_17", /*135*/
-	"DUMMY_18",
-	"DUMMY_19",
-	"DUMMY_20",
-	"STATS_REQBUF",
-	"STATS_ENQUEUEBUF", /*140*/
-	"STATS_FLUSH_BUFQ",
-	"STATS_UNREGBUF",
-	"STATS_BG_START",
-	"STATS_BG_STOP",
-	"STATS_BF_START", /*145*/
-	"STATS_BF_STOP",
-	"STATS_BHIST_START",
-	"STATS_BHIST_STOP",
-	"RESET_2",
-};
-
-uint8_t vfe32_use_bayer_stats(struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	if (vfe32_ctrl->ver_num.main >= 4) {
-		/* VFE 4 or above uses bayer stats */
-		return TRUE;
-	} else {
-		return FALSE;
-	}
-}
-
-static void axi_enable_wm_irq(struct vfe_share_ctrl_t *share_ctrl)
-{
-	uint32_t irq_mask, irq_comp_mask = 0;
-	uint16_t vfe_output_mode =
-		share_ctrl->outpath.output_mode &
-			~(VFE32_OUTPUT_MODE_TERTIARY1|
-			VFE32_OUTPUT_MODE_TERTIARY2);
-
-	if (vfe_output_mode)
-		irq_comp_mask =
-		msm_camera_io_r(share_ctrl->vfebase +
-			VFE_IRQ_COMP_MASK);
-	irq_mask = msm_camera_io_r(share_ctrl->vfebase +
-				VFE_IRQ_MASK_0);
-
-	if (share_ctrl->outpath.output_mode &
-			VFE32_OUTPUT_MODE_PRIMARY) {
-		if (share_ctrl->current_mode == VFE_OUTPUTS_RAW)
-			irq_comp_mask |= (
-				0x1 << share_ctrl->outpath.out0.ch0);
-		else
-			irq_comp_mask |= (
-				0x1 << share_ctrl->outpath.out0.ch0 |
-				0x1 << share_ctrl->outpath.out0.ch1);
-		irq_mask |= VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE0_MASK;
-	} else if (share_ctrl->outpath.output_mode &
-			   VFE32_OUTPUT_MODE_PRIMARY_ALL_CHNLS) {
-		irq_comp_mask |= (
-			0x1 << share_ctrl->outpath.out0.ch0 |
-			0x1 << share_ctrl->outpath.out0.ch1 |
-			0x1 << share_ctrl->outpath.out0.ch2);
-		irq_mask |= VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE0_MASK;
-	}
-	if (share_ctrl->outpath.output_mode &
-			VFE32_OUTPUT_MODE_SECONDARY) {
-		irq_comp_mask |= (
-			0x1 << (share_ctrl->outpath.out1.ch0 + 8) |
-			0x1 << (share_ctrl->outpath.out1.ch1 + 8));
-		irq_mask |= VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE1_MASK;
-	} else if (share_ctrl->outpath.output_mode &
-			VFE32_OUTPUT_MODE_SECONDARY_ALL_CHNLS) {
-		irq_comp_mask |= (
-			0x1 << (share_ctrl->outpath.out1.ch0 + 8) |
-			0x1 << (share_ctrl->outpath.out1.ch1 + 8) |
-			0x1 << (share_ctrl->outpath.out1.ch2 + 8));
-		irq_mask |= VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE1_MASK;
-	}
-
-	if (share_ctrl->outpath.output_mode &
-		VFE32_OUTPUT_MODE_TERTIARY1) {
-		irq_mask |= (0x1 << (share_ctrl->outpath.out2.ch0 +
-			VFE_WM_OFFSET));
-	}
-
-	if (share_ctrl->outpath.output_mode &
-		VFE32_OUTPUT_MODE_TERTIARY2) {
-		irq_mask |= (0x1 << (share_ctrl->outpath.out3.ch0 +
-			VFE_WM_OFFSET));
-	}
-
-	msm_camera_io_w(irq_mask, share_ctrl->vfebase +
-			VFE_IRQ_MASK_0);
-	if (vfe_output_mode)
-		msm_camera_io_w(irq_comp_mask,
-			share_ctrl->vfebase + VFE_IRQ_COMP_MASK);
-}
-
-static void axi_disable_wm_irq(struct vfe_share_ctrl_t *share_ctrl,
-	uint16_t output_mode)
-{
-	uint32_t irq_mask, irq_comp_mask = 0;
-	uint16_t vfe_output_mode =
-		output_mode &
-			~(VFE32_OUTPUT_MODE_TERTIARY1|
-			VFE32_OUTPUT_MODE_TERTIARY2);
-	if (vfe_output_mode)
-		irq_comp_mask =
-		msm_camera_io_r(share_ctrl->vfebase +
-			VFE_IRQ_COMP_MASK);
-	irq_mask = msm_camera_io_r(share_ctrl->vfebase +
-				VFE_IRQ_MASK_0);
-
-	if (output_mode &
-			VFE32_OUTPUT_MODE_PRIMARY) {
-		irq_comp_mask &= ~(
-			0x1 << share_ctrl->outpath.out0.ch0 |
-			0x1 << share_ctrl->outpath.out0.ch1);
-		irq_mask &= ~VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE0_MASK;
-	} else if (output_mode &
-			   VFE32_OUTPUT_MODE_PRIMARY_ALL_CHNLS) {
-		irq_comp_mask &= ~(
-			0x1 << share_ctrl->outpath.out0.ch0 |
-			0x1 << share_ctrl->outpath.out0.ch1 |
-			0x1 << share_ctrl->outpath.out0.ch2);
-		irq_mask &= ~VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE0_MASK;
-	}
-	if (output_mode &
-			VFE32_OUTPUT_MODE_SECONDARY) {
-		irq_comp_mask &= ~(
-			0x1 << (share_ctrl->outpath.out1.ch0 + 8) |
-			0x1 << (share_ctrl->outpath.out1.ch1 + 8));
-		irq_mask &= ~VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE1_MASK;
-	} else if (output_mode &
-			VFE32_OUTPUT_MODE_SECONDARY_ALL_CHNLS) {
-		irq_comp_mask &= ~(
-			0x1 << (share_ctrl->outpath.out1.ch0 + 8) |
-			0x1 << (share_ctrl->outpath.out1.ch1 + 8) |
-			0x1 << (share_ctrl->outpath.out1.ch2 + 8));
-		irq_mask &= ~VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE1_MASK;
-	}
-	if (output_mode &
-			VFE32_OUTPUT_MODE_TERTIARY1) {
-			irq_mask &= ~(0x1 << (share_ctrl->outpath.out2.ch0 +
-				VFE_WM_OFFSET));
-	}
-	if (output_mode &
-		VFE32_OUTPUT_MODE_TERTIARY2) {
-		irq_mask &= ~(0x1 << (share_ctrl->outpath.out3.ch0 +
-			VFE_WM_OFFSET));
-	}
-	msm_camera_io_w(irq_mask, share_ctrl->vfebase +
-				VFE_IRQ_MASK_0);
-	if (vfe_output_mode)
-		msm_camera_io_w(irq_comp_mask,
-			share_ctrl->vfebase + VFE_IRQ_COMP_MASK);
-}
-
-static void axi_enable_irq(struct vfe_share_ctrl_t *share_ctrl)
-{
-	uint32_t irq_mask, irq_mask1;
-	uint32_t vfe_mode =
-		share_ctrl->current_mode & ~(VFE_OUTPUTS_RDI0|
-			VFE_OUTPUTS_RDI1);
-
-	if (share_ctrl->axi_ref_cnt == 1) {
-		irq_mask1 =
-			msm_camera_io_r(share_ctrl->vfebase +
-				VFE_IRQ_MASK_1);
-
-		irq_mask1 |= VFE_IMASK_WHILE_STOPPING_1;
-			msm_camera_io_w(irq_mask1, share_ctrl->vfebase +
-				VFE_IRQ_MASK_1);
-	}
-
-	if (share_ctrl->current_mode & (VFE_OUTPUTS_RDI0|VFE_OUTPUTS_RDI1)) {
-		irq_mask1 =
-			msm_camera_io_r(share_ctrl->vfebase +
-				VFE_IRQ_MASK_1);
-
-		if (share_ctrl->current_mode & VFE_OUTPUTS_RDI0)
-			irq_mask1 |= VFE_IRQ_STATUS1_RDI0_REG_UPDATE_MASK;
-
-		if (share_ctrl->current_mode & VFE_OUTPUTS_RDI1)
-			irq_mask1 |= VFE_IRQ_STATUS1_RDI1_REG_UPDATE_MASK;
-
-		msm_camera_io_w(irq_mask1, share_ctrl->vfebase +
-			VFE_IRQ_MASK_1);
-	}
-
-	if (vfe_mode) {
-		irq_mask =
-		msm_camera_io_r(share_ctrl->vfebase +
-			VFE_IRQ_MASK_0);
-		irq_mask |= 0x00000021;
-		if (share_ctrl->stats_comp)
-			irq_mask |= VFE_IRQ_STATUS0_STATS_COMPOSIT_MASK;
-		else
-			irq_mask |= 0x000FE000;
-		msm_camera_io_w(irq_mask, share_ctrl->vfebase +
-			VFE_IRQ_MASK_0);
-		atomic_set(&share_ctrl->vstate, 1);
-	}
-	atomic_set(&share_ctrl->handle_common_irq, 1);
-}
-
-static void axi_clear_all_interrupts(struct vfe_share_ctrl_t *share_ctrl)
-{
-	atomic_set(&share_ctrl->handle_common_irq, 0);
-	msm_camera_io_w(VFE_DISABLE_ALL_IRQS,
-		share_ctrl->vfebase + VFE_IRQ_MASK_0);
-	msm_camera_io_w(VFE_DISABLE_ALL_IRQS,
-		share_ctrl->vfebase + VFE_IRQ_MASK_1);
-
-	/* clear all pending interrupts*/
-	msm_camera_io_w(VFE_CLEAR_ALL_IRQS,
-		share_ctrl->vfebase + VFE_IRQ_CLEAR_0);
-	msm_camera_io_w(VFE_CLEAR_ALL_IRQS,
-		share_ctrl->vfebase + VFE_IRQ_CLEAR_1);
-	/* Ensure the write order while writing
-	*to the command register using the barrier */
-	msm_camera_io_w_mb(1,
-		share_ctrl->vfebase + VFE_IRQ_CMD);
-}
-
-static void axi_disable_irq(struct vfe_share_ctrl_t *share_ctrl,
-	uint32_t mode)
-{
-
-	/* disable all interrupts.  */
-
-	uint32_t irq_mask = 0, irq_mask1 = 0, clear_mask1 = 0;
-	uint32_t vfe_mode =
-		(mode & ~(VFE_OUTPUTS_RDI0|
-			VFE_OUTPUTS_RDI1));
-
-	if (mode & (VFE_OUTPUTS_RDI0|VFE_OUTPUTS_RDI1)) {
-		irq_mask1 =
-			msm_camera_io_r(share_ctrl->vfebase +
-				VFE_IRQ_MASK_1);
-
-		if (mode & VFE_OUTPUTS_RDI0) {
-			irq_mask1 &= ~(VFE_IRQ_STATUS1_RDI0_REG_UPDATE_MASK);
-			clear_mask1 |= VFE_IRQ_STATUS1_RDI0_REG_UPDATE_MASK;
-		}
-
-		if (mode & VFE_OUTPUTS_RDI1) {
-			irq_mask1 &= ~(VFE_IRQ_STATUS1_RDI1_REG_UPDATE_MASK);
-			clear_mask1 |= VFE_IRQ_STATUS1_RDI1_REG_UPDATE_MASK;
-		}
-
-		msm_camera_io_w(irq_mask1, share_ctrl->vfebase +
-			VFE_IRQ_MASK_1);
-		msm_camera_io_w(clear_mask1,
-			share_ctrl->vfebase + VFE_IRQ_CLEAR_1);
-	}
-
-	if (vfe_mode) {
-		atomic_set(&share_ctrl->vstate, 0);
-		irq_mask =
-		msm_camera_io_r(share_ctrl->vfebase +
-			VFE_IRQ_MASK_0);
-		irq_mask &= ~(0x00000021);
-		if (share_ctrl->stats_comp)
-			irq_mask &= ~(VFE_IRQ_STATUS0_STATS_COMPOSIT_MASK);
-		else
-			irq_mask &= ~0x000FE000;
-		msm_camera_io_w(irq_mask, share_ctrl->vfebase +
-			VFE_IRQ_MASK_0);
-	}
-}
-
-static void vfe32_stop(struct vfe32_ctrl_type *vfe32_ctrl)
-{
-
-	/* in either continuous or snapshot mode, stop command can be issued
-	 * at any time. stop camif immediately. */
-	if (!vfe32_ctrl->share_ctrl->dual_enabled)
-		msm_camera_io_w_mb(CAMIF_COMMAND_STOP_IMMEDIATELY,
-			vfe32_ctrl->share_ctrl->vfebase + VFE_CAMIF_COMMAND);
-	else
-		msm_camera_io_w(CAMIF_COMMAND_STOP_AT_FRAME_BOUNDARY,
-			vfe32_ctrl->share_ctrl->vfebase + VFE_CAMIF_COMMAND);
-	vfe32_ctrl->share_ctrl->operation_mode &=
-		(VFE_OUTPUTS_RDI0|VFE_OUTPUTS_RDI1);
-}
-
-static void vfe32_subdev_notify(int id, int path, uint32_t inst_handle,
-	struct v4l2_subdev *sd, struct vfe_share_ctrl_t *share_ctrl)
-{
-	struct msm_vfe_resp rp;
-	struct msm_frame_info frame_info;
-	unsigned long flags = 0;
-	spin_lock_irqsave(&share_ctrl->sd_notify_lock, flags);
-	CDBG("vfe32_subdev_notify : msgId = %d\n", id);
-	memset(&rp, 0, sizeof(struct msm_vfe_resp));
-	rp.evt_msg.type   = MSM_CAMERA_MSG;
-	frame_info.inst_handle = inst_handle;
-	frame_info.path = path;
-	rp.evt_msg.data = &frame_info;
-	rp.type	   = id;
-	v4l2_subdev_notify(sd, NOTIFY_VFE_BUF_EVT, &rp);
-	spin_unlock_irqrestore(&share_ctrl->sd_notify_lock, flags);
-}
-
-static int vfe32_config_axi(
-	struct axi_ctrl_t *axi_ctrl, int mode, uint32_t *ao)
-{
-	uint32_t *ch_info;
-	uint32_t *axi_cfg = ao+V32_AXI_BUS_FMT_OFF;
-	int vfe_mode = (mode & ~(OUTPUT_TERT1|OUTPUT_TERT2));
-	uint32_t bus_cmd = *axi_cfg;
-	int i;
-
-	/* Update the corresponding write masters for each output*/
-	ch_info = axi_cfg + V32_AXI_CFG_LEN;
-	axi_ctrl->share_ctrl->outpath.out0.ch0 = 0x0000FFFF & *ch_info;
-	axi_ctrl->share_ctrl->outpath.out0.ch1 =
-		0x0000FFFF & (*ch_info++ >> 16);
-	axi_ctrl->share_ctrl->outpath.out0.ch2 = 0x0000FFFF & *ch_info++;
-	axi_ctrl->share_ctrl->outpath.out0.inst_handle = *ch_info++;
-
-	axi_ctrl->share_ctrl->outpath.out1.ch0 = 0x0000FFFF & *ch_info;
-	axi_ctrl->share_ctrl->outpath.out1.ch1 =
-		0x0000FFFF & (*ch_info++ >> 16);
-	axi_ctrl->share_ctrl->outpath.out1.ch2 = 0x0000FFFF & *ch_info++;
-	axi_ctrl->share_ctrl->outpath.out1.inst_handle = *ch_info++;
-
-	axi_ctrl->share_ctrl->outpath.out2.ch0 = 0x0000FFFF & *ch_info;
-	axi_ctrl->share_ctrl->outpath.out2.ch1 =
-		0x0000FFFF & (*ch_info++ >> 16);
-	axi_ctrl->share_ctrl->outpath.out2.ch2 = 0x0000FFFF & *ch_info++;
-	axi_ctrl->share_ctrl->outpath.out2.inst_handle = *ch_info++;
-
-	axi_ctrl->share_ctrl->outpath.out3.ch0 = 0x0000FFFF & *ch_info;
-	axi_ctrl->share_ctrl->outpath.out3.ch1 =
-		0x0000FFFF & (*ch_info++ >> 16);
-	axi_ctrl->share_ctrl->outpath.out3.ch2 = 0x0000FFFF & *ch_info++;
-	axi_ctrl->share_ctrl->outpath.out3.inst_handle = *ch_info++;
-
-	axi_ctrl->share_ctrl->outpath.output_mode = 0;
-
-	if (mode & OUTPUT_TERT1)
-		axi_ctrl->share_ctrl->outpath.output_mode |=
-			VFE32_OUTPUT_MODE_TERTIARY1;
-	if (mode & OUTPUT_TERT2)
-		axi_ctrl->share_ctrl->outpath.output_mode |=
-			VFE32_OUTPUT_MODE_TERTIARY2;
-	if (mode == OUTPUT_TERT1 || mode == OUTPUT_TERT1
-		|| mode == (OUTPUT_TERT1|OUTPUT_TERT2))
-			goto bus_cfg;
-
-	switch (vfe_mode) {
-	case OUTPUT_PRIM:
-		axi_ctrl->share_ctrl->outpath.output_mode |=
-			VFE32_OUTPUT_MODE_PRIMARY;
-		break;
-	case OUTPUT_PRIM_ALL_CHNLS:
-		axi_ctrl->share_ctrl->outpath.output_mode |=
-			VFE32_OUTPUT_MODE_PRIMARY_ALL_CHNLS;
-		break;
-	case OUTPUT_PRIM|OUTPUT_SEC:
-		axi_ctrl->share_ctrl->outpath.output_mode |=
-			VFE32_OUTPUT_MODE_PRIMARY;
-		axi_ctrl->share_ctrl->outpath.output_mode |=
-			VFE32_OUTPUT_MODE_SECONDARY;
-		break;
-	case OUTPUT_PRIM|OUTPUT_SEC_ALL_CHNLS:
-		axi_ctrl->share_ctrl->outpath.output_mode |=
-			VFE32_OUTPUT_MODE_PRIMARY;
-		axi_ctrl->share_ctrl->outpath.output_mode |=
-			VFE32_OUTPUT_MODE_SECONDARY_ALL_CHNLS;
-		break;
-	case OUTPUT_PRIM_ALL_CHNLS|OUTPUT_SEC:
-		axi_ctrl->share_ctrl->outpath.output_mode |=
-			VFE32_OUTPUT_MODE_PRIMARY_ALL_CHNLS;
-		axi_ctrl->share_ctrl->outpath.output_mode |=
-			VFE32_OUTPUT_MODE_SECONDARY;
-		break;
-	default:
-		pr_err("%s Invalid AXI mode %d ", __func__, mode);
-		return -EINVAL;
-	}
-
-bus_cfg:
-	msm_camera_io_w(*ao, axi_ctrl->share_ctrl->vfebase +
-		VFE_BUS_IO_FORMAT_CFG);
-	axi_cfg++;
-	msm_camera_io_memcpy(axi_ctrl->share_ctrl->vfebase +
-		vfe32_cmd[VFE_CMD_AXI_OUT_CFG].offset, axi_cfg,
-		V32_AXI_BUS_CFG_LEN);
-	axi_cfg += V32_AXI_BUS_CFG_LEN/4;
-	for (i = 0; i < ARRAY_SIZE(vfe32_AXI_WM_CFG); i++) {
-		axi_cfg += 3;
-		msm_camera_io_memcpy(
-			axi_ctrl->share_ctrl->vfebase+vfe32_AXI_WM_CFG[i]+12,
-								axi_cfg, 12);
-		axi_cfg += 3;
-	}
-	msm_camera_io_w(bus_cmd, axi_ctrl->share_ctrl->vfebase +
-					V32_AXI_BUS_CMD_OFF);
-	msm_camera_io_w(*ch_info++,
-		axi_ctrl->share_ctrl->vfebase + VFE_PIXEL_IF_CFG);
-	if (msm_camera_io_r(axi_ctrl->share_ctrl->vfebase +
-		V32_GET_HW_VERSION_OFF) ==
-		VFE33_HW_NUMBER) {
-		msm_camera_io_w(*ch_info++,
-			axi_ctrl->share_ctrl->vfebase + VFE_RDI0_CFG);
-		msm_camera_io_w(*ch_info++,
-			axi_ctrl->share_ctrl->vfebase + VFE_RDI1_CFG);
-	}
-	return 0;
-}
-
-static void axi_reset_internal_variables(
-	struct axi_ctrl_t *axi_ctrl,
-	struct msm_camera_vfe_params_t vfe_params)
-{
-	if (vfe_params.operation_mode & VFE_OUTPUTS_RDI0) {
-		atomic_set(&axi_ctrl->share_ctrl->rdi0_update_ack_pending, 0);
-		axi_ctrl->share_ctrl->rdi0_capture_count = -1;
-		axi_ctrl->share_ctrl->outpath.out2.capture_cnt = -1;
-		axi_ctrl->share_ctrl->rdi0FrameId = 0;
-		axi_ctrl->share_ctrl->comp_output_mode &=
-			~VFE32_OUTPUT_MODE_TERTIARY1;
-		axi_ctrl->share_ctrl->operation_mode &=
-			~(VFE_OUTPUTS_RDI0);
-	}
-
-	if (vfe_params.operation_mode & VFE_OUTPUTS_RDI1) {
-		atomic_set(&axi_ctrl->share_ctrl->rdi1_update_ack_pending, 0);
-		axi_ctrl->share_ctrl->rdi1_capture_count = -1;
-		axi_ctrl->share_ctrl->outpath.out3.capture_cnt = -1;
-		axi_ctrl->share_ctrl->rdi1FrameId = 0;
-		axi_ctrl->share_ctrl->comp_output_mode &=
-			~VFE32_OUTPUT_MODE_TERTIARY2;
-		axi_ctrl->share_ctrl->operation_mode &=
-			~(VFE_OUTPUTS_RDI1);
-	}
-}
-
-static void axi_global_reset_internal_variables(
-	struct axi_ctrl_t *axi_ctrl)
-{
-	unsigned long flags;
-	/* state control variables */
-	axi_ctrl->share_ctrl->start_ack_pending = FALSE;
-	atomic_set(&irq_cnt, 0);
-
-	spin_lock_irqsave(&axi_ctrl->share_ctrl->stop_flag_lock, flags);
-	axi_ctrl->share_ctrl->stop_ack_pending  = FALSE;
-	spin_unlock_irqrestore(&axi_ctrl->share_ctrl->stop_flag_lock, flags);
-
-	init_completion(&axi_ctrl->share_ctrl->reset_complete);
-
-	spin_lock_irqsave(&axi_ctrl->share_ctrl->update_ack_lock, flags);
-	axi_ctrl->share_ctrl->update_ack_pending = FALSE;
-	spin_unlock_irqrestore(&axi_ctrl->share_ctrl->update_ack_lock, flags);
-
-	axi_ctrl->share_ctrl->recording_state = VFE_STATE_IDLE;
-	axi_ctrl->share_ctrl->liveshot_state = VFE_STATE_IDLE;
-
-	atomic_set(&axi_ctrl->share_ctrl->vstate, 0);
-	atomic_set(&axi_ctrl->share_ctrl->handle_common_irq, 0);
-	atomic_set(&axi_ctrl->share_ctrl->pix0_update_ack_pending, 0);
-	atomic_set(&axi_ctrl->share_ctrl->rdi0_update_ack_pending, 0);
-	atomic_set(&axi_ctrl->share_ctrl->rdi1_update_ack_pending, 0);
-	atomic_set(&axi_ctrl->share_ctrl->rdi2_update_ack_pending, 0);
-
-	/* 0 for continuous mode, 1 for snapshot mode */
-	axi_ctrl->share_ctrl->operation_mode = 0;
-	axi_ctrl->share_ctrl->current_mode = 0;
-	axi_ctrl->share_ctrl->outpath.output_mode = 0;
-	axi_ctrl->share_ctrl->comp_output_mode = 0;
-	axi_ctrl->share_ctrl->vfe_capture_count = 0;
-	axi_ctrl->share_ctrl->rdi0_capture_count = -1;
-	axi_ctrl->share_ctrl->rdi1_capture_count = -1;
-	axi_ctrl->share_ctrl->outpath.out0.capture_cnt = -1;
-	axi_ctrl->share_ctrl->outpath.out1.capture_cnt = -1;
-	axi_ctrl->share_ctrl->outpath.out2.capture_cnt = -1;
-	axi_ctrl->share_ctrl->outpath.out3.capture_cnt = -1;
-
-	/* this is unsigned 32 bit integer. */
-	axi_ctrl->share_ctrl->vfeFrameId = 0;
-	axi_ctrl->share_ctrl->rdi0FrameId = 0;
-	axi_ctrl->share_ctrl->rdi1FrameId = 0;
-	axi_ctrl->share_ctrl->rdi2FrameId = 0;
-}
-
-
-static void vfe32_program_dmi_cfg(
-	enum VFE32_DMI_RAM_SEL bankSel,
-	struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	/* set bit 8 for auto increment. */
-	uint32_t value = VFE_DMI_CFG_DEFAULT;
-	value += (uint32_t)bankSel;
-	CDBG("%s: banksel = %d\n", __func__, bankSel);
-
-	msm_camera_io_w(value, vfe32_ctrl->share_ctrl->vfebase +
-		VFE_DMI_CFG);
-	/* by default, always starts with offset 0.*/
-	msm_camera_io_w(0, vfe32_ctrl->share_ctrl->vfebase +
-		VFE_DMI_ADDR);
-}
-
-static void vfe32_reset_dmi_tables(
-	struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	int i = 0;
-
-	/* Reset Histogram LUTs */
-	CDBG("Reset Bayer histogram LUT : 0\n");
-	vfe32_program_dmi_cfg(STATS_BHIST_RAM0, vfe32_ctrl);
-	/* Loop for configuring LUT */
-	for (i = 0; i < 256; i++) {
-		msm_camera_io_w(0, vfe32_ctrl->share_ctrl->vfebase +
-			VFE_DMI_DATA_HI);
-		msm_camera_io_w(0, vfe32_ctrl->share_ctrl->vfebase +
-			VFE_DMI_DATA_LO);
-	}
-	vfe32_program_dmi_cfg(NO_MEM_SELECTED, vfe32_ctrl);
-
-	CDBG("Reset Bayer Histogram LUT: 1\n");
-	vfe32_program_dmi_cfg(STATS_BHIST_RAM1, vfe32_ctrl);
-	/* Loop for configuring LUT */
-	for (i = 0; i < 256; i++) {
-		msm_camera_io_w(0, vfe32_ctrl->share_ctrl->vfebase +
-			VFE_DMI_DATA_HI);
-		msm_camera_io_w(0, vfe32_ctrl->share_ctrl->vfebase +
-			VFE_DMI_DATA_LO);
-	}
-	vfe32_program_dmi_cfg(NO_MEM_SELECTED, vfe32_ctrl);
-
-	CDBG("Reset IHistogram LUT\n");
-	vfe32_program_dmi_cfg(STATS_IHIST_RAM, vfe32_ctrl);
-	/* Loop for configuring LUT */
-	for (i = 0; i < 256; i++) {
-		msm_camera_io_w(0, vfe32_ctrl->share_ctrl->vfebase +
-			VFE_DMI_DATA_HI);
-		msm_camera_io_w(0, vfe32_ctrl->share_ctrl->vfebase +
-			VFE_DMI_DATA_LO);
-	}
-	vfe32_program_dmi_cfg(NO_MEM_SELECTED, vfe32_ctrl);
-}
-
-static void vfe32_set_default_reg_values(
-	struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	msm_camera_io_w(0x800080,
-		vfe32_ctrl->share_ctrl->vfebase + VFE_DEMUX_GAIN_0);
-	msm_camera_io_w(0x800080,
-		vfe32_ctrl->share_ctrl->vfebase + VFE_DEMUX_GAIN_1);
-	/* What value should we program CGC_OVERRIDE to? */
-	msm_camera_io_w(0xFFFFF,
-		vfe32_ctrl->share_ctrl->vfebase + VFE_CGC_OVERRIDE);
-
-	/* default frame drop period and pattern */
-	msm_camera_io_w(0x1f,
-		vfe32_ctrl->share_ctrl->vfebase + VFE_FRAMEDROP_ENC_Y_CFG);
-	msm_camera_io_w(0x1f,
-		vfe32_ctrl->share_ctrl->vfebase + VFE_FRAMEDROP_ENC_CBCR_CFG);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe32_ctrl->share_ctrl->vfebase + VFE_FRAMEDROP_ENC_Y_PATTERN);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe32_ctrl->share_ctrl->vfebase +
-		VFE_FRAMEDROP_ENC_CBCR_PATTERN);
-	msm_camera_io_w(0x1f,
-		vfe32_ctrl->share_ctrl->vfebase + VFE_FRAMEDROP_VIEW_Y);
-	msm_camera_io_w(0x1f,
-		vfe32_ctrl->share_ctrl->vfebase + VFE_FRAMEDROP_VIEW_CBCR);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe32_ctrl->share_ctrl->vfebase + VFE_FRAMEDROP_VIEW_Y_PATTERN);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe32_ctrl->share_ctrl->vfebase +
-		VFE_FRAMEDROP_VIEW_CBCR_PATTERN);
-	msm_camera_io_w(0, vfe32_ctrl->share_ctrl->vfebase + VFE_CLAMP_MIN);
-	msm_camera_io_w(0xFFFFFF,
-		vfe32_ctrl->share_ctrl->vfebase + VFE_CLAMP_MAX);
-
-	/* stats UB config */
-	CDBG("%s: Use bayer stats = %d\n", __func__,
-		 vfe32_use_bayer_stats(vfe32_ctrl));
-	if (!vfe32_use_bayer_stats(vfe32_ctrl)) {
-		msm_camera_io_w(0x3980007,
-			vfe32_ctrl->share_ctrl->vfebase +
-				VFE_BUS_STATS_AEC_BG_UB_CFG);
-		msm_camera_io_w(0x3A00007,
-			vfe32_ctrl->share_ctrl->vfebase +
-				VFE_BUS_STATS_AF_BF_UB_CFG);
-		msm_camera_io_w(0x3A8000F,
-			vfe32_ctrl->share_ctrl->vfebase +
-				VFE_BUS_STATS_AWB_UB_CFG);
-		msm_camera_io_w(0x3B80007,
-			vfe32_ctrl->share_ctrl->vfebase +
-				VFE_BUS_STATS_RS_UB_CFG);
-		msm_camera_io_w(0x3C0001F,
-			vfe32_ctrl->share_ctrl->vfebase +
-				VFE_BUS_STATS_CS_UB_CFG);
-		msm_camera_io_w(0x3E0001F,
-			vfe32_ctrl->share_ctrl->vfebase +
-				VFE_BUS_STATS_HIST_UB_CFG);
-	} else {
-		msm_camera_io_w(0x350001F,
-			vfe32_ctrl->share_ctrl->vfebase +
-				VFE_BUS_STATS_HIST_UB_CFG);
-		msm_camera_io_w(0x370002F,
-			vfe32_ctrl->share_ctrl->vfebase +
-				VFE_BUS_STATS_AEC_BG_UB_CFG);
-		msm_camera_io_w(0x3A0002F,
-			vfe32_ctrl->share_ctrl->vfebase +
-				VFE_BUS_STATS_AF_BF_UB_CFG);
-		msm_camera_io_w(0x3D00007,
-			vfe32_ctrl->share_ctrl->vfebase +
-				VFE_BUS_STATS_RS_UB_CFG);
-		msm_camera_io_w(0x3D8001F,
-			vfe32_ctrl->share_ctrl->vfebase +
-				VFE_BUS_STATS_CS_UB_CFG);
-		msm_camera_io_w(0x3F80007,
-			vfe32_ctrl->share_ctrl->vfebase +
-				VFE_BUS_STATS_SKIN_BHIST_UB_CFG);
-	}
-	vfe32_reset_dmi_tables(vfe32_ctrl);
-}
-
-static void vfe32_reset_internal_variables(
-	struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	unsigned long flags;
-	spin_lock_irqsave(&vfe32_ctrl->share_ctrl->update_ack_lock,
-		flags);
-	vfe32_ctrl->share_ctrl->update_ack_pending = FALSE;
-	spin_unlock_irqrestore(&vfe32_ctrl->share_ctrl->update_ack_lock,
-		flags);
-	vfe32_ctrl->share_ctrl->vfe_capture_count = 0;
-	/* this is unsigned 32 bit integer. */
-	vfe32_ctrl->share_ctrl->vfeFrameId = 0;
-	vfe32_ctrl->share_ctrl->update_counter = 0;
-
-	/* Stats control variables. */
-	memset(&(vfe32_ctrl->afbfStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	memset(&(vfe32_ctrl->awbStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	memset(&(vfe32_ctrl->aecbgStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	memset(&(vfe32_ctrl->bhistStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	memset(&(vfe32_ctrl->ihistStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	memset(&(vfe32_ctrl->rsStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	memset(&(vfe32_ctrl->csStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-	vfe32_ctrl->share_ctrl->outpath.out0.capture_cnt = -1;
-	vfe32_ctrl->share_ctrl->outpath.out1.capture_cnt = -1;
-	vfe32_ctrl->share_ctrl->recording_state = VFE_STATE_IDLE;
-	vfe32_ctrl->share_ctrl->liveshot_state = VFE_STATE_IDLE;
-
-	atomic_set(&vfe32_ctrl->share_ctrl->vstate, 0);
-	atomic_set(&vfe32_ctrl->share_ctrl->pix0_update_ack_pending, 0);
-
-	vfe32_ctrl->frame_skip_cnt = 31;
-	vfe32_ctrl->frame_skip_pattern = 0xffffffff;
-	vfe32_ctrl->snapshot_frame_cnt = 0;
-	vfe32_set_default_reg_values(vfe32_ctrl);
-}
-
-
-static int vfe32_reset(struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	uint32_t irq_mask1, irq_mask;
-	atomic_set(&vfe32_ctrl->share_ctrl->vstate, 0);
-	msm_camera_io_w(VFE_MODULE_RESET_CMD,
-		vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_RESET);
-	msm_camera_io_w(0,
-		vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_RESET);
-
-	irq_mask =
-		msm_camera_io_r(vfe32_ctrl->share_ctrl->vfebase +
-			VFE_IRQ_MASK_0);
-	irq_mask &= ~(0x000FE021|VFE_IRQ_STATUS0_STATS_COMPOSIT_MASK);
-
-	msm_camera_io_w(irq_mask, vfe32_ctrl->share_ctrl->vfebase +
-		VFE_IRQ_MASK_0);
-	vfe32_ctrl->share_ctrl->operation_mode &=
-		(VFE_OUTPUTS_RDI0|VFE_OUTPUTS_RDI1);
-	vfe32_ctrl->share_ctrl->comp_output_mode &=
-			(VFE32_OUTPUT_MODE_TERTIARY1|
-			VFE32_OUTPUT_MODE_TERTIARY2);
-
-	/* enable reset_ack interrupt.  */
-	irq_mask1 = msm_camera_io_r(
-		vfe32_ctrl->share_ctrl->vfebase + VFE_IRQ_MASK_1);
-	irq_mask1 |= VFE_IMASK_WHILE_STOPPING_1;
-	msm_camera_io_w(irq_mask1,
-		vfe32_ctrl->share_ctrl->vfebase + VFE_IRQ_MASK_1);
-	msm_camera_io_w_mb(VFE_ONLY_RESET_CMD,
-		vfe32_ctrl->share_ctrl->vfebase + VFE_GLOBAL_RESET);
-
-	return wait_for_completion_interruptible(
-			&vfe32_ctrl->share_ctrl->reset_complete);
-}
-
-static int axi_reset(struct axi_ctrl_t *axi_ctrl,
-	struct msm_camera_vfe_params_t vfe_params)
-{
-	int rc = 0;
-	if (vfe_params.skip_reset) {
-		axi_reset_internal_variables(axi_ctrl, vfe_params);
-		return rc;
-	}
-	axi_global_reset_internal_variables(axi_ctrl);
-	/* disable all interrupts.  vfeImaskLocal is also reset to 0
-	* to begin with. */
-	msm_camera_io_w(VFE_DISABLE_ALL_IRQS,
-		axi_ctrl->share_ctrl->vfebase + VFE_IRQ_MASK_0);
-
-	msm_camera_io_w(VFE_DISABLE_ALL_IRQS,
-		axi_ctrl->share_ctrl->vfebase + VFE_IRQ_MASK_1);
-
-	/* clear all pending interrupts*/
-	msm_camera_io_w(VFE_CLEAR_ALL_IRQS,
-		axi_ctrl->share_ctrl->vfebase + VFE_IRQ_CLEAR_0);
-	msm_camera_io_w(VFE_CLEAR_ALL_IRQS,
-		axi_ctrl->share_ctrl->vfebase + VFE_IRQ_CLEAR_1);
-
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(1, axi_ctrl->share_ctrl->vfebase + VFE_IRQ_CMD);
-
-	/* enable reset_ack interrupt.  */
-	msm_camera_io_w(VFE_IMASK_WHILE_STOPPING_1,
-		axi_ctrl->share_ctrl->vfebase + VFE_IRQ_MASK_1);
-
-	/* Write to VFE_GLOBAL_RESET_CMD to reset the vfe hardware. Once reset
-	 * is done, hardware interrupt will be generated.  VFE ist processes
-	 * the interrupt to complete the function call.  Note that the reset
-	 * function is synchronous. */
-
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(VFE_RESET_UPON_RESET_CMD,
-		axi_ctrl->share_ctrl->vfebase + VFE_GLOBAL_RESET);
-
-	return wait_for_completion_interruptible(
-			&axi_ctrl->share_ctrl->reset_complete);
-}
-
-static int vfe32_operation_config(uint32_t *cmd,
-			struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	uint32_t *p = cmd;
-
-	vfe32_ctrl->share_ctrl->stats_comp = *(++p);
-	vfe32_ctrl->hfr_mode = *(++p);
-
-	msm_camera_io_w(*(++p),
-		vfe32_ctrl->share_ctrl->vfebase + VFE_CFG);
-	msm_camera_io_w(*(++p),
-		vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-	msm_camera_io_w(*(++p),
-		vfe32_ctrl->share_ctrl->vfebase + VFE_REALIGN_BUF);
-	msm_camera_io_w(*(++p),
-		vfe32_ctrl->share_ctrl->vfebase + VFE_CHROMA_UP);
-	msm_camera_io_w(*(++p),
-		vfe32_ctrl->share_ctrl->vfebase + VFE_STATS_CFG);
-	return 0;
-}
-
-static unsigned long vfe32_stats_dqbuf(struct vfe32_ctrl_type *vfe32_ctrl,
-	enum msm_stats_enum_type stats_type)
-{
-	struct msm_stats_meta_buf *buf = NULL;
-	int rc = 0;
-	rc = vfe32_ctrl->stats_ops.dqbuf(
-			vfe32_ctrl->stats_ops.stats_ctrl, stats_type, &buf);
-	if (rc < 0) {
-		CDBG("%s: dq stats buf (type = %d) err = %d",
-			__func__, stats_type, rc);
-		return 0L;
-	}
-	return buf->paddr;
-}
-
-static unsigned long vfe32_stats_flush_enqueue(
-	struct vfe32_ctrl_type *vfe32_ctrl,
-	enum msm_stats_enum_type stats_type)
-{
-	struct msm_stats_bufq *bufq = NULL;
-	struct msm_stats_meta_buf *stats_buf = NULL;
-	int rc = 0;
-	int i;
-
-	/*
-	 * Passing NULL for ion client as the buffers are already
-	 * mapped at this stage, client is not required, flush all
-	 * the buffers, and buffers move to PREPARE state
-	 */
-
-	rc = vfe32_ctrl->stats_ops.bufq_flush(
-			vfe32_ctrl->stats_ops.stats_ctrl, stats_type, NULL);
-	if (rc < 0) {
-		pr_err("%s: dq stats buf (type = %d) err = %d",
-			__func__, stats_type, rc);
-		return 0L;
-	}
-	/* Queue all the buffers back to QUEUED state */
-	bufq = vfe32_ctrl->stats_ctrl.bufq[stats_type];
-	for (i = 0; i < bufq->num_bufs; i++) {
-		stats_buf = &bufq->bufs[i];
-		rc = vfe32_ctrl->stats_ops.enqueue_buf(
-				vfe32_ctrl->stats_ops.stats_ctrl,
-				&(stats_buf->info), NULL, -1);
-		if (rc < 0) {
-			pr_err("%s: dq stats buf (type = %d) err = %d",
-				 __func__, stats_type, rc);
-			return rc;
-		}
-	}
-	return 0L;
-}
-
-
-static unsigned long vfe32_stats_unregbuf(
-	struct vfe32_ctrl_type *vfe32_ctrl,
-	struct msm_stats_reqbuf *req_buf, int domain_num)
-{
-	int i = 0, rc = 0;
-
-	for (i = 0; i < req_buf->num_buf; i++) {
-		rc = vfe32_ctrl->stats_ops.buf_unprepare(
-			vfe32_ctrl->stats_ops.stats_ctrl,
-			req_buf->stats_type, i,
-			vfe32_ctrl->stats_ops.client, domain_num);
-		if (rc < 0) {
-			pr_err("%s: unreg stats buf (type = %d) err = %d",
-				__func__, req_buf->stats_type, rc);
-		return rc;
-		}
-	}
-	return 0L;
-}
-static int vfe_stats_awb_buf_init(
-	struct vfe32_ctrl_type *vfe32_ctrl,
-	struct vfe_cmd_stats_buf *in)
-{
-	uint32_t addr;
-	unsigned long flags;
-
-	spin_lock_irqsave(&vfe32_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl, MSM_STATS_TYPE_AWB);
-	spin_unlock_irqrestore(&vfe32_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq awb ping buf from free buf queue", __func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe32_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_AWB_WR_PING_ADDR);
-	spin_lock_irqsave(&vfe32_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl, MSM_STATS_TYPE_AWB);
-	spin_unlock_irqrestore(&vfe32_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq awb ping buf from free buf queue",
-			__func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe32_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_AWB_WR_PONG_ADDR);
-	return 0;
-}
-
-static uint32_t vfe_stats_aec_bg_buf_init(
-	struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	uint32_t addr;
-	unsigned long flags;
-	uint32_t stats_type;
-
-	stats_type =
-		(!vfe32_use_bayer_stats(vfe32_ctrl)) ? MSM_STATS_TYPE_AEC
-			: MSM_STATS_TYPE_BG;
-	spin_lock_irqsave(&vfe32_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl, stats_type);
-	spin_unlock_irqrestore(&vfe32_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq aec ping buf from free buf queue",
-			__func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe32_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_AEC_BG_WR_PING_ADDR);
-	spin_lock_irqsave(&vfe32_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl, stats_type);
-	spin_unlock_irqrestore(&vfe32_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq aec pong buf from free buf queue",
-			__func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe32_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_AEC_BG_WR_PONG_ADDR);
-	return 0;
-}
-
-static int vfe_stats_af_bf_buf_init(
-	struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	uint32_t addr;
-	unsigned long flags;
-	int rc = 0;
-
-	uint32_t stats_type;
-	stats_type =
-		(!vfe32_use_bayer_stats(vfe32_ctrl)) ? MSM_STATS_TYPE_AF
-			: MSM_STATS_TYPE_BF;
-
-	spin_lock_irqsave(&vfe32_ctrl->stats_bufq_lock, flags);
-	rc = vfe32_stats_flush_enqueue(vfe32_ctrl, stats_type);
-	if (rc < 0) {
-		pr_err("%s: dq stats buf err = %d",
-			   __func__, rc);
-		spin_unlock_irqrestore(&vfe32_ctrl->stats_bufq_lock, flags);
-		return -EINVAL;
-	}
-	addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl, stats_type);
-	spin_unlock_irqrestore(&vfe32_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq af ping buf from free buf queue", __func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe32_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_AF_BF_WR_PING_ADDR);
-	spin_lock_irqsave(&vfe32_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl, stats_type);
-	spin_unlock_irqrestore(&vfe32_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq af pong buf from free buf queue", __func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe32_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_AF_BF_WR_PONG_ADDR);
-	return 0;
-}
-
-static uint32_t vfe_stats_bhist_buf_init(
-	struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	uint32_t addr;
-	unsigned long flags;
-
-	spin_lock_irqsave(&vfe32_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl, MSM_STATS_TYPE_BHIST);
-	spin_unlock_irqrestore(&vfe32_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq ihist ping buf from free buf queue",
-			__func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe32_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_SKIN_BHIST_WR_PING_ADDR);
-	spin_lock_irqsave(&vfe32_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl, MSM_STATS_TYPE_BHIST);
-	spin_unlock_irqrestore(&vfe32_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq ihist pong buf from free buf queue",
-			__func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe32_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_SKIN_BHIST_WR_PONG_ADDR);
-
-	return 0;
-}
-
-static int vfe_stats_ihist_buf_init(
-	struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	uint32_t addr;
-	unsigned long flags;
-
-	spin_lock_irqsave(&vfe32_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl, MSM_STATS_TYPE_IHIST);
-	spin_unlock_irqrestore(&vfe32_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq ihist ping buf from free buf queue",
-			__func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe32_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_HIST_WR_PING_ADDR);
-	spin_lock_irqsave(&vfe32_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl, MSM_STATS_TYPE_IHIST);
-	spin_unlock_irqrestore(&vfe32_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq ihist pong buf from free buf queue",
-			__func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe32_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_HIST_WR_PONG_ADDR);
-
-	return 0;
-}
-
-static int vfe_stats_rs_buf_init(
-	struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	uint32_t addr;
-	unsigned long flags;
-
-	spin_lock_irqsave(&vfe32_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl, MSM_STATS_TYPE_RS);
-	spin_unlock_irqrestore(&vfe32_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq rs ping buf from free buf queue", __func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe32_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_RS_WR_PING_ADDR);
-	spin_lock_irqsave(&vfe32_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl, MSM_STATS_TYPE_RS);
-	spin_unlock_irqrestore(&vfe32_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq rs pong buf from free buf queue", __func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe32_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_RS_WR_PONG_ADDR);
-	return 0;
-}
-
-static int vfe_stats_cs_buf_init(
-	struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	uint32_t addr;
-	unsigned long flags;
-	spin_lock_irqsave(&vfe32_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl, MSM_STATS_TYPE_CS);
-	spin_unlock_irqrestore(&vfe32_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq cs ping buf from free buf queue", __func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe32_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_CS_WR_PING_ADDR);
-	spin_lock_irqsave(&vfe32_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl, MSM_STATS_TYPE_CS);
-	spin_unlock_irqrestore(&vfe32_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq cs pong buf from free buf queue", __func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe32_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_CS_WR_PONG_ADDR);
-	return 0;
-}
-
-static void vfe32_start_common(struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	CDBG("VFE opertaion mode = 0x%x, output mode = 0x%x\n",
-		vfe32_ctrl->share_ctrl->operation_mode,
-		vfe32_ctrl->share_ctrl->outpath.output_mode);
-	msm_camera_io_w_mb(1, vfe32_ctrl->share_ctrl->vfebase +
-		VFE_CAMIF_COMMAND);
-	msm_camera_io_w_mb(VFE_AXI_CFG_MASK,
-		vfe32_ctrl->share_ctrl->vfebase + VFE_AXI_CFG);
-}
-
-static int vfe32_start_recording(
-	struct msm_cam_media_controller *pmctl,
-	struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	vfe32_ctrl->share_ctrl->recording_state = VFE_STATE_START_REQUESTED;
-	msm_camera_io_w_mb(1,
-		vfe32_ctrl->share_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-	return 0;
-}
-
-static int vfe32_stop_recording(
-	struct msm_cam_media_controller *pmctl,
-	struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	vfe32_ctrl->share_ctrl->recording_state = VFE_STATE_STOP_REQUESTED;
-	msm_camera_io_w_mb(1,
-		vfe32_ctrl->share_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-	return 0;
-}
-
-static void vfe32_start_liveshot(
-	struct msm_cam_media_controller *pmctl,
-	struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	/* Hardcode 1 live snapshot for now. */
-	vfe32_ctrl->share_ctrl->outpath.out0.capture_cnt = 1;
-	vfe32_ctrl->share_ctrl->vfe_capture_count =
-		vfe32_ctrl->share_ctrl->outpath.out0.capture_cnt;
-
-	vfe32_ctrl->share_ctrl->liveshot_state = VFE_STATE_START_REQUESTED;
-	msm_camera_io_w_mb(1, vfe32_ctrl->
-		share_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-}
-
-static void vfe32_stop_liveshot(
-	struct msm_cam_media_controller *pmctl,
-	struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	vfe32_ctrl->share_ctrl->liveshot_state = VFE_STATE_STOP_REQUESTED;
-	msm_camera_io_w_mb(1,
-		vfe32_ctrl->share_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-}
-
-static int vfe32_zsl(
-	struct msm_cam_media_controller *pmctl,
-	struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	vfe32_ctrl->share_ctrl->start_ack_pending = TRUE;
-	vfe32_start_common(vfe32_ctrl);
-
-	msm_camera_io_w(1, vfe32_ctrl->share_ctrl->vfebase + 0x18C);
-	msm_camera_io_w(1, vfe32_ctrl->share_ctrl->vfebase + 0x188);
-	return 0;
-}
-static int vfe32_capture_raw(
-	struct msm_cam_media_controller *pmctl,
-	struct vfe32_ctrl_type *vfe32_ctrl,
-	uint32_t num_frames_capture)
-{
-	vfe32_ctrl->share_ctrl->outpath.out0.capture_cnt = num_frames_capture;
-	vfe32_ctrl->share_ctrl->vfe_capture_count = num_frames_capture;
-	vfe32_start_common(vfe32_ctrl);
-	return 0;
-}
-
-static int vfe32_capture(
-	struct msm_cam_media_controller *pmctl,
-	uint32_t num_frames_capture,
-	struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	/* capture command is valid for both idle and active state. */
-	vfe32_ctrl->share_ctrl->outpath.out1.capture_cnt = num_frames_capture;
-	if (vfe32_ctrl->share_ctrl->current_mode ==
-			VFE_OUTPUTS_MAIN_AND_THUMB ||
-		vfe32_ctrl->share_ctrl->current_mode ==
-			VFE_OUTPUTS_THUMB_AND_MAIN ||
-		vfe32_ctrl->share_ctrl->current_mode ==
-			VFE_OUTPUTS_JPEG_AND_THUMB ||
-		vfe32_ctrl->share_ctrl->current_mode ==
-			VFE_OUTPUTS_THUMB_AND_JPEG) {
-		vfe32_ctrl->share_ctrl->outpath.out0.capture_cnt =
-			num_frames_capture;
-	}
-
-	vfe32_ctrl->share_ctrl->vfe_capture_count = num_frames_capture;
-
-	vfe32_ctrl->share_ctrl->vfe_capture_count = num_frames_capture;
-
-	vfe32_start_common(vfe32_ctrl);
-	/* for debug */
-	msm_camera_io_w(1, vfe32_ctrl->share_ctrl->vfebase + 0x18C);
-	msm_camera_io_w(1, vfe32_ctrl->share_ctrl->vfebase + 0x188);
-	return 0;
-}
-
-static int vfe32_start(
-	struct msm_cam_media_controller *pmctl,
-	struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	vfe32_start_common(vfe32_ctrl);
-	return 0;
-}
-
-static void vfe32_update(struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	unsigned long flags;
-	uint32_t value = 0;
-	if (vfe32_ctrl->update_linear) {
-		if (!msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase +
-			V32_LINEARIZATION_OFF1))
-			msm_camera_io_w(1,
-				vfe32_ctrl->share_ctrl->vfebase +
-				V32_LINEARIZATION_OFF1);
-		else
-			msm_camera_io_w(0,
-				vfe32_ctrl->share_ctrl->vfebase +
-				V32_LINEARIZATION_OFF1);
-		vfe32_ctrl->update_linear = false;
-	}
-
-	if (vfe32_ctrl->update_rolloff) {
-		value = msm_camera_io_r(vfe32_ctrl->share_ctrl->vfebase +
-			V33_PCA_ROLL_OFF_CFG_OFF1);
-		value ^= V33_PCA_ROLL_OFF_LUT_BANK_SEL_MASK;
-		msm_camera_io_w(value, vfe32_ctrl->share_ctrl->vfebase +
-			V33_PCA_ROLL_OFF_CFG_OFF1);
-		vfe32_ctrl->update_rolloff = false;
-	}
-
-	if (vfe32_ctrl->update_la) {
-		if (!msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase + V32_LA_OFF))
-			msm_camera_io_w(1,
-				vfe32_ctrl->share_ctrl->vfebase + V32_LA_OFF);
-		else
-			msm_camera_io_w(0,
-				vfe32_ctrl->share_ctrl->vfebase + V32_LA_OFF);
-		vfe32_ctrl->update_la = false;
-	}
-
-	if (vfe32_ctrl->update_gamma) {
-		value = msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase + V32_RGB_G_OFF);
-		value ^= V32_GAMMA_LUT_BANK_SEL_MASK;
-		msm_camera_io_w(value,
-			vfe32_ctrl->share_ctrl->vfebase + V32_RGB_G_OFF);
-		vfe32_ctrl->update_gamma = false;
-	}
-
-	spin_lock_irqsave(&vfe32_ctrl->share_ctrl->update_ack_lock, flags);
-	vfe32_ctrl->share_ctrl->update_ack_pending = TRUE;
-	spin_unlock_irqrestore(&vfe32_ctrl->share_ctrl->update_ack_lock, flags);
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(1,
-		vfe32_ctrl->share_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-	return;
-}
-
-static void vfe32_sync_timer_stop(struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	uint32_t value = 0;
-	vfe32_ctrl->sync_timer_state = 0;
-	if (vfe32_ctrl->sync_timer_number == 0)
-		value = 0x10000;
-	else if (vfe32_ctrl->sync_timer_number == 1)
-		value = 0x20000;
-	else if (vfe32_ctrl->sync_timer_number == 2)
-		value = 0x40000;
-
-	/* Timer Stop */
-	msm_camera_io_w(value,
-		vfe32_ctrl->share_ctrl->vfebase + V32_SYNC_TIMER_OFF);
-}
-
-static void vfe32_sync_timer_start(
-	const uint32_t *tbl,
-	struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	/* set bit 8 for auto increment. */
-	uint32_t value = 1;
-	uint32_t val;
-
-	vfe32_ctrl->sync_timer_state = *tbl++;
-	vfe32_ctrl->sync_timer_repeat_count = *tbl++;
-	vfe32_ctrl->sync_timer_number = *tbl++;
-	CDBG("%s timer_state %d, repeat_cnt %d timer number %d\n",
-		 __func__, vfe32_ctrl->sync_timer_state,
-		 vfe32_ctrl->sync_timer_repeat_count,
-		 vfe32_ctrl->sync_timer_number);
-
-	if (vfe32_ctrl->sync_timer_state) { /* Start Timer */
-		value = value << vfe32_ctrl->sync_timer_number;
-	} else { /* Stop Timer */
-		CDBG("Failed to Start timer\n");
-		return;
-	}
-
-	/* Timer Start */
-	msm_camera_io_w(value,
-		vfe32_ctrl->share_ctrl->vfebase + V32_SYNC_TIMER_OFF);
-	/* Sync Timer Line Start */
-	value = *tbl++;
-	msm_camera_io_w(value,
-		vfe32_ctrl->share_ctrl->vfebase + V32_SYNC_TIMER_OFF +
-		4 + ((vfe32_ctrl->sync_timer_number) * 12));
-	/* Sync Timer Pixel Start */
-	value = *tbl++;
-	msm_camera_io_w(value,
-			vfe32_ctrl->share_ctrl->vfebase + V32_SYNC_TIMER_OFF +
-			 8 + ((vfe32_ctrl->sync_timer_number) * 12));
-	/* Sync Timer Pixel Duration */
-	value = *tbl++;
-	val = vfe_clk_rate / 10000;
-	val = 10000000 / val;
-	val = value * 10000 / val;
-	CDBG("%s: Pixel Clk Cycles!!! %d\n", __func__, val);
-	msm_camera_io_w(val,
-		vfe32_ctrl->share_ctrl->vfebase + V32_SYNC_TIMER_OFF +
-		12 + ((vfe32_ctrl->sync_timer_number) * 12));
-	/* Timer0 Active High/LOW */
-	value = *tbl++;
-	msm_camera_io_w(value,
-		vfe32_ctrl->share_ctrl->vfebase + V32_SYNC_TIMER_POLARITY_OFF);
-	/* Selects sync timer 0 output to drive onto timer1 port */
-	value = 0;
-	msm_camera_io_w(value,
-		vfe32_ctrl->share_ctrl->vfebase + V32_TIMER_SELECT_OFF);
-}
-
-
-static void vfe32_write_gamma_cfg(
-	enum VFE32_DMI_RAM_SEL channel_sel,
-	const uint32_t *tbl,
-	struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	int i;
-	uint32_t value, value1, value2;
-	vfe32_program_dmi_cfg(channel_sel, vfe32_ctrl);
-	for (i = 0 ; i < (VFE32_GAMMA_NUM_ENTRIES/2) ; i++) {
-		value = *tbl++;
-		value1 = value & 0x0000FFFF;
-		value2 = (value & 0xFFFF0000)>>16;
-		msm_camera_io_w((value1),
-			vfe32_ctrl->share_ctrl->vfebase + VFE_DMI_DATA_LO);
-		msm_camera_io_w((value2),
-			vfe32_ctrl->share_ctrl->vfebase + VFE_DMI_DATA_LO);
-	}
-	vfe32_program_dmi_cfg(NO_MEM_SELECTED, vfe32_ctrl);
-}
-
-static void vfe32_read_gamma_cfg(
-	enum VFE32_DMI_RAM_SEL channel_sel,
-	uint32_t *tbl,
-	struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	int i;
-	vfe32_program_dmi_cfg(channel_sel, vfe32_ctrl);
-	CDBG("%s: Gamma table channel: %d\n", __func__, channel_sel);
-	for (i = 0 ; i < VFE32_GAMMA_NUM_ENTRIES ; i++) {
-		*tbl = msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase + VFE_DMI_DATA_LO);
-		CDBG("%s: %08x\n", __func__, *tbl);
-		tbl++;
-	}
-	vfe32_program_dmi_cfg(NO_MEM_SELECTED, vfe32_ctrl);
-}
-
-static void vfe32_write_la_cfg(
-	enum VFE32_DMI_RAM_SEL channel_sel,
-	const uint32_t *tbl,
-	struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	uint32_t i;
-	uint32_t value, value1, value2;
-
-	vfe32_program_dmi_cfg(channel_sel, vfe32_ctrl);
-	for (i = 0 ; i < (VFE32_LA_TABLE_LENGTH/2) ; i++) {
-		value = *tbl++;
-		value1 = value & 0x0000FFFF;
-		value2 = (value & 0xFFFF0000)>>16;
-		msm_camera_io_w((value1),
-			vfe32_ctrl->share_ctrl->vfebase + VFE_DMI_DATA_LO);
-		msm_camera_io_w((value2),
-			vfe32_ctrl->share_ctrl->vfebase + VFE_DMI_DATA_LO);
-	}
-	vfe32_program_dmi_cfg(NO_MEM_SELECTED, vfe32_ctrl);
-}
-
-static struct vfe32_output_ch *vfe32_get_ch(
-	int path, struct vfe_share_ctrl_t *share_ctrl)
-{
-	struct vfe32_output_ch *ch = NULL;
-
-	if (path == VFE_MSG_OUTPUT_PRIMARY)
-		ch = &share_ctrl->outpath.out0;
-	else if (path == VFE_MSG_OUTPUT_SECONDARY)
-		ch = &share_ctrl->outpath.out1;
-	else if (path == VFE_MSG_OUTPUT_TERTIARY1)
-		ch = &share_ctrl->outpath.out2;
-	else if (path == VFE_MSG_OUTPUT_TERTIARY2)
-		ch = &share_ctrl->outpath.out3;
-	else
-		pr_err("%s: Invalid path %d\n", __func__,
-			path);
-
-	BUG_ON(ch == NULL);
-	return ch;
-}
-static struct msm_free_buf *vfe32_check_free_buffer(
-	int id, int path, struct axi_ctrl_t *axi_ctrl)
-{
-	struct vfe32_output_ch *outch = NULL;
-	struct msm_free_buf *b = NULL;
-	uint32_t inst_handle = 0;
-
-	if (path == VFE_MSG_OUTPUT_PRIMARY)
-		inst_handle = axi_ctrl->share_ctrl->outpath.out0.inst_handle;
-	else if (path == VFE_MSG_OUTPUT_SECONDARY)
-		inst_handle = axi_ctrl->share_ctrl->outpath.out1.inst_handle;
-	else if (path == VFE_MSG_OUTPUT_TERTIARY1)
-		inst_handle = axi_ctrl->share_ctrl->outpath.out2.inst_handle;
-	else if (path == VFE_MSG_OUTPUT_TERTIARY2)
-		inst_handle = axi_ctrl->share_ctrl->outpath.out3.inst_handle;
-
-	vfe32_subdev_notify(id, path, inst_handle,
-		&axi_ctrl->subdev, axi_ctrl->share_ctrl);
-	outch = vfe32_get_ch(path, axi_ctrl->share_ctrl);
-	if (outch->free_buf.ch_paddr[0])
-		b = &outch->free_buf;
-	return b;
-}
-static int configure_pingpong_buffers(
-	int id, int path, struct axi_ctrl_t *axi_ctrl)
-{
-	struct vfe32_output_ch *outch = NULL;
-	int rc = 0;
-	uint32_t inst_handle = 0;
-	if (path == VFE_MSG_OUTPUT_PRIMARY)
-		inst_handle = axi_ctrl->share_ctrl->outpath.out0.inst_handle;
-	else if (path == VFE_MSG_OUTPUT_SECONDARY)
-		inst_handle = axi_ctrl->share_ctrl->outpath.out1.inst_handle;
-	else if (path == VFE_MSG_OUTPUT_TERTIARY1)
-		inst_handle = axi_ctrl->share_ctrl->outpath.out2.inst_handle;
-	else if (path == VFE_MSG_OUTPUT_TERTIARY2)
-		inst_handle = axi_ctrl->share_ctrl->outpath.out3.inst_handle;
-
-	vfe32_subdev_notify(id, path, inst_handle,
-		&axi_ctrl->subdev, axi_ctrl->share_ctrl);
-	outch = vfe32_get_ch(path, axi_ctrl->share_ctrl);
-	if (outch->ping.ch_paddr[0] && outch->pong.ch_paddr[0]) {
-		/* Configure Preview Ping Pong */
-		pr_info("%s Configure ping/pong address for %d",
-						__func__, path);
-		vfe32_put_ch_ping_addr(
-			axi_ctrl->share_ctrl->vfebase, outch->ch0,
-			outch->ping.ch_paddr[0]);
-		vfe32_put_ch_pong_addr(
-			axi_ctrl->share_ctrl->vfebase, outch->ch0,
-			outch->pong.ch_paddr[0]);
-
-		if ((axi_ctrl->share_ctrl->current_mode !=
-			VFE_OUTPUTS_RAW) && (path != VFE_MSG_OUTPUT_TERTIARY1)
-			&& (path != VFE_MSG_OUTPUT_TERTIARY2)) {
-			vfe32_put_ch_ping_addr(
-				axi_ctrl->share_ctrl->vfebase, outch->ch1,
-				outch->ping.ch_paddr[1]);
-			vfe32_put_ch_pong_addr(
-				axi_ctrl->share_ctrl->vfebase, outch->ch1,
-				outch->pong.ch_paddr[1]);
-		}
-
-		if (outch->ping.num_planes > 2)
-			vfe32_put_ch_ping_addr(
-				axi_ctrl->share_ctrl->vfebase, outch->ch2,
-				outch->ping.ch_paddr[2]);
-		if (outch->pong.num_planes > 2)
-			vfe32_put_ch_pong_addr(
-				axi_ctrl->share_ctrl->vfebase, outch->ch2,
-				outch->pong.ch_paddr[2]);
-
-		/* avoid stale info */
-		memset(&outch->ping, 0, sizeof(struct msm_free_buf));
-		memset(&outch->pong, 0, sizeof(struct msm_free_buf));
-	} else {
-		pr_err("%s ping/pong addr is null!!", __func__);
-		rc = -EINVAL;
-	}
-	return rc;
-}
-
-static void vfe32_write_linear_cfg(
-	enum VFE32_DMI_RAM_SEL channel_sel,
-	const uint32_t *tbl, struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	uint32_t i;
-
-	vfe32_program_dmi_cfg(channel_sel, vfe32_ctrl);
-	/* for loop for configuring LUT. */
-	for (i = 0 ; i < VFE32_LINEARIZATON_TABLE_LENGTH ; i++) {
-		msm_camera_io_w(*tbl,
-			vfe32_ctrl->share_ctrl->vfebase + VFE_DMI_DATA_LO);
-		tbl++;
-	}
-	CDBG("done writing to linearization table\n");
-	vfe32_program_dmi_cfg(NO_MEM_SELECTED, vfe32_ctrl);
-}
-
-static void vfe32_send_isp_msg(
-	struct v4l2_subdev *sd,
-	uint32_t vfeFrameId,
-	uint32_t isp_msg_id)
-{
-	struct isp_msg_event isp_msg_evt;
-
-	isp_msg_evt.msg_id = isp_msg_id;
-	isp_msg_evt.sof_count = vfeFrameId;
-	v4l2_subdev_notify(sd,
-			NOTIFY_ISP_MSG_EVT,
-			(void *)&isp_msg_evt);
-}
-
-static int vfe32_proc_general(
-	struct msm_cam_media_controller *pmctl,
-	struct msm_isp_cmd *cmd,
-	struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	int i , rc = 0;
-	uint32_t old_val = 0 , new_val = 0, module_val = 0;
-	uint32_t *cmdp = NULL;
-	uint32_t *cmdp_local = NULL;
-	uint32_t snapshot_cnt = 0;
-	uint32_t temp1 = 0, temp2 = 0;
-	struct msm_camera_vfe_params_t vfe_params;
-
-	CDBG("vfe32_proc_general: cmdID = %s, length = %d\n",
-		vfe32_general_cmd[cmd->id], cmd->length);
-	switch (cmd->id) {
-	case VFE_CMD_RESET:
-		pr_info("vfe32_proc_general: cmdID = %s\n",
-			vfe32_general_cmd[cmd->id]);
-		vfe32_ctrl->share_ctrl->vfe_reset_flag = true;
-		vfe32_reset(vfe32_ctrl);
-		break;
-	case VFE_CMD_START:
-		pr_info("vfe32_proc_general: cmdID = %s\n",
-			vfe32_general_cmd[cmd->id]);
-		if (copy_from_user(&vfe_params,
-				(void __user *)(cmd->value),
-				sizeof(struct msm_camera_vfe_params_t))) {
-				rc = -EFAULT;
-				goto proc_general_done;
-		}
-
-		vfe32_ctrl->share_ctrl->current_mode =
-			vfe_params.operation_mode;
-
-		rc = vfe32_start(pmctl, vfe32_ctrl);
-		break;
-	case VFE_CMD_UPDATE:
-		vfe32_update(vfe32_ctrl);
-		break;
-	case VFE_CMD_CAPTURE_RAW:
-		pr_info("%s: cmdID = VFE_CMD_CAPTURE_RAW\n", __func__);
-		if (copy_from_user(&vfe_params,
-				(void __user *)(cmd->value),
-				sizeof(struct msm_camera_vfe_params_t))) {
-				rc = -EFAULT;
-				goto proc_general_done;
-		}
-
-		snapshot_cnt = vfe_params.capture_count;
-		vfe32_ctrl->share_ctrl->current_mode =
-			vfe_params.operation_mode;
-		rc = vfe32_capture_raw(pmctl, vfe32_ctrl, snapshot_cnt);
-		break;
-	case VFE_CMD_CAPTURE:
-		if (copy_from_user(&vfe_params,
-				(void __user *)(cmd->value),
-				sizeof(struct msm_camera_vfe_params_t))) {
-				rc = -EFAULT;
-				goto proc_general_done;
-		}
-
-		snapshot_cnt = vfe_params.capture_count;
-		vfe32_ctrl->share_ctrl->current_mode =
-			vfe_params.operation_mode;
-
-		rc = vfe32_capture(pmctl, snapshot_cnt, vfe32_ctrl);
-		break;
-	case VFE_CMD_START_RECORDING:
-		pr_info("vfe32_proc_general: cmdID = %s\n",
-			vfe32_general_cmd[cmd->id]);
-		rc = vfe32_start_recording(pmctl, vfe32_ctrl);
-		break;
-	case VFE_CMD_STOP_RECORDING:
-		pr_info("vfe32_proc_general: cmdID = %s\n",
-			vfe32_general_cmd[cmd->id]);
-		rc = vfe32_stop_recording(pmctl, vfe32_ctrl);
-		break;
-	case VFE_CMD_OPERATION_CFG: {
-		if (cmd->length != V32_OPERATION_CFG_LEN) {
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(V32_OPERATION_CFG_LEN, GFP_ATOMIC);
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			V32_OPERATION_CFG_LEN)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		rc = vfe32_operation_config(cmdp, vfe32_ctrl);
-		}
-		break;
-
-	case VFE_CMD_STATS_AE_START: {
-		if (vfe32_use_bayer_stats(vfe32_ctrl)) {
-			/* Error */
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		rc = vfe_stats_aec_bg_buf_init(vfe32_ctrl);
-		if (rc < 0) {
-			pr_err("%s: cannot config ping/pong address of AEC",
-				 __func__);
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		old_val = msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val |= AE_BG_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			vfe32_cmd[cmd->id].offset,
-			cmdp, (vfe32_cmd[cmd->id].length));
-		}
-		break;
-	case VFE_CMD_STATS_AF_START: {
-		if (vfe32_use_bayer_stats(vfe32_ctrl)) {
-			/* Error */
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		rc = vfe_stats_af_bf_buf_init(vfe32_ctrl);
-		if (rc < 0) {
-			pr_err("%s: cannot config ping/pong address of AF",
-				__func__);
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		old_val = msm_camera_io_r(vfe32_ctrl->share_ctrl->vfebase +
-			VFE_MODULE_CFG);
-		old_val |= AF_BF_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			vfe32_cmd[cmd->id].offset,
-			cmdp, (vfe32_cmd[cmd->id].length));
-		}
-		break;
-	case VFE_CMD_STATS_AWB_START: {
-		if (vfe32_use_bayer_stats(vfe32_ctrl)) {
-			/* Error */
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		rc = vfe_stats_awb_buf_init(vfe32_ctrl, NULL);
-		if (rc < 0) {
-			pr_err("%s: cannot config ping/pong address of AWB",
-				 __func__);
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		old_val = msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val |= AWB_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			vfe32_cmd[cmd->id].offset,
-			cmdp, (vfe32_cmd[cmd->id].length));
-		}
-		break;
-
-	case VFE_CMD_STATS_IHIST_START: {
-		rc = vfe_stats_ihist_buf_init(vfe32_ctrl);
-		if (rc < 0) {
-			pr_err("%s: cannot config ping/pong address of IHIST",
-				 __func__);
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		old_val = msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val |= IHIST_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			vfe32_cmd[cmd->id].offset,
-			cmdp, (vfe32_cmd[cmd->id].length));
-		}
-		break;
-
-
-	case VFE_CMD_STATS_RS_START: {
-		rc = vfe_stats_rs_buf_init(vfe32_ctrl);
-		if (rc < 0) {
-			pr_err("%s: cannot config ping/pong address of RS",
-				__func__);
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			vfe32_cmd[cmd->id].offset,
-			cmdp, (vfe32_cmd[cmd->id].length));
-		}
-		break;
-
-	case VFE_CMD_STATS_CS_START: {
-		rc = vfe_stats_cs_buf_init(vfe32_ctrl);
-		if (rc < 0) {
-			pr_err("%s: cannot config ping/pong address of CS",
-				__func__);
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			vfe32_cmd[cmd->id].offset,
-			cmdp, (vfe32_cmd[cmd->id].length));
-		}
-		break;
-
-	case VFE_CMD_STATS_BG_START:
-	case VFE_CMD_STATS_BF_START:
-	case VFE_CMD_STATS_BHIST_START: {
-		if (!vfe32_use_bayer_stats(vfe32_ctrl)) {
-			/* Error */
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		old_val = msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase + VFE_STATS_CFG);
-		module_val = msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		if (VFE_CMD_STATS_BG_START == cmd->id) {
-			module_val |= AE_BG_ENABLE_MASK;
-			old_val |= STATS_BG_ENABLE_MASK;
-			rc = vfe_stats_aec_bg_buf_init(vfe32_ctrl);
-			if (rc < 0) {
-				pr_err("%s: cannot config ping/pong address of CS",
-					__func__);
-				goto proc_general_done;
-			}
-		} else if (VFE_CMD_STATS_BF_START == cmd->id) {
-			module_val |= AF_BF_ENABLE_MASK;
-			old_val |= STATS_BF_ENABLE_MASK;
-			rc = vfe_stats_af_bf_buf_init(vfe32_ctrl);
-			if (rc < 0) {
-				pr_err("%s: cannot config ping/pong address of CS",
-					__func__);
-				goto proc_general_done;
-			}
-		} else {
-			module_val |= SKIN_BHIST_ENABLE_MASK;
-			old_val |= STATS_BHIST_ENABLE_MASK;
-			rc = vfe_stats_bhist_buf_init(vfe32_ctrl);
-			if (rc < 0) {
-				pr_err("%s: cannot config ping/pong address of CS",
-					__func__);
-				goto proc_general_done;
-			}
-		}
-		msm_camera_io_w(old_val, vfe32_ctrl->share_ctrl->vfebase +
-			VFE_STATS_CFG);
-		msm_camera_io_w(module_val,
-			vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-				(void __user *)(cmd->value),
-				cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			vfe32_cmd[cmd->id].offset,
-			cmdp, (vfe32_cmd[cmd->id].length));
-		}
-		break;
-	case VFE_CMD_MCE_UPDATE:
-	case VFE_CMD_MCE_CFG:{
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		/* Incrementing with 4 so as to point to the 2nd Register as
-		the 2nd register has the mce_enable bit */
-		old_val = msm_camera_io_r(vfe32_ctrl->share_ctrl->vfebase +
-			V32_CHROMA_SUP_OFF + 4);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		new_val = *cmdp_local;
-		old_val &= MCE_EN_MASK;
-		new_val = new_val | old_val;
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			V32_CHROMA_SUP_OFF + 4, &new_val, 4);
-		cmdp_local += 1;
-
-		old_val = msm_camera_io_r(vfe32_ctrl->share_ctrl->vfebase +
-			V32_CHROMA_SUP_OFF + 8);
-		new_val = *cmdp_local;
-		old_val &= MCE_Q_K_MASK;
-		new_val = new_val | old_val;
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			V32_CHROMA_SUP_OFF + 8, &new_val, 4);
-		cmdp_local += 1;
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			vfe32_cmd[cmd->id].offset,
-			cmdp_local, (vfe32_cmd[cmd->id].length));
-		}
-		break;
-	case VFE_CMD_CHROMA_SUP_UPDATE:
-	case VFE_CMD_CHROMA_SUP_CFG:{
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		msm_camera_io_memcpy(vfe32_ctrl->share_ctrl->vfebase +
-			V32_CHROMA_SUP_OFF, cmdp_local, 4);
-
-		cmdp_local += 1;
-		new_val = *cmdp_local;
-		/* Incrementing with 4 so as to point to the 2nd Register as
-		 * the 2nd register has the mce_enable bit
-		 */
-		old_val = msm_camera_io_r(vfe32_ctrl->share_ctrl->vfebase +
-			V32_CHROMA_SUP_OFF + 4);
-		old_val &= ~MCE_EN_MASK;
-		new_val = new_val | old_val;
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			V32_CHROMA_SUP_OFF + 4, &new_val, 4);
-		cmdp_local += 1;
-
-		old_val = msm_camera_io_r(vfe32_ctrl->share_ctrl->vfebase +
-			V32_CHROMA_SUP_OFF + 8);
-		new_val = *cmdp_local;
-		old_val &= ~MCE_Q_K_MASK;
-		new_val = new_val | old_val;
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			V32_CHROMA_SUP_OFF + 8, &new_val, 4);
-		}
-		break;
-	case VFE_CMD_BLACK_LEVEL_CFG:
-		rc = -EFAULT;
-		goto proc_general_done;
-
-	case VFE_CMD_MESH_ROLL_OFF_CFG: {
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value) , cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			vfe32_cmd[cmd->id].offset,
-			cmdp_local, 16);
-		cmdp_local += 4;
-		vfe32_program_dmi_cfg(ROLLOFF_RAM0_BANK0, vfe32_ctrl);
-		/* for loop for extrcting init table. */
-		for (i = 0; i < (V32_MESH_ROLL_OFF_INIT_TABLE_SIZE * 2); i++) {
-			msm_camera_io_w(*cmdp_local ,
-			vfe32_ctrl->share_ctrl->vfebase + VFE_DMI_DATA_LO);
-			cmdp_local++;
-		}
-		CDBG("done writing init table\n");
-		/* by default, always starts with offset 0. */
-		msm_camera_io_w(V32_MESH_ROLL_OFF_DELTA_TABLE_OFFSET,
-		vfe32_ctrl->share_ctrl->vfebase + VFE_DMI_ADDR);
-		/* for loop for extracting delta table. */
-		for (i = 0; i < (V32_MESH_ROLL_OFF_DELTA_TABLE_SIZE * 2); i++) {
-			msm_camera_io_w(*cmdp_local,
-			vfe32_ctrl->share_ctrl->vfebase + VFE_DMI_DATA_LO);
-			cmdp_local++;
-		}
-		vfe32_program_dmi_cfg(NO_MEM_SELECTED, vfe32_ctrl);
-		}
-		break;
-
-	case VFE_CMD_GET_MESH_ROLLOFF_TABLE:
-		temp1 = sizeof(uint32_t) * ((V32_MESH_ROLL_OFF_INIT_TABLE_SIZE *
-			2) + (V32_MESH_ROLL_OFF_DELTA_TABLE_SIZE * 2));
-		if (cmd->length != temp1) {
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		cmdp = kzalloc(temp1, GFP_KERNEL);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		vfe32_program_dmi_cfg(ROLLOFF_RAM0_BANK0, vfe32_ctrl);
-		CDBG("%s: Mesh Rolloff init Table\n", __func__);
-		for (i = 0; i < (V32_MESH_ROLL_OFF_INIT_TABLE_SIZE * 2); i++) {
-			*cmdp_local =
-				msm_camera_io_r(
-					vfe32_ctrl->share_ctrl->vfebase +
-					VFE_DMI_DATA_LO);
-			CDBG("%s: %08x\n", __func__, *cmdp_local);
-			cmdp_local++;
-		}
-		msm_camera_io_w(V32_MESH_ROLL_OFF_DELTA_TABLE_OFFSET,
-			vfe32_ctrl->share_ctrl->vfebase + VFE_DMI_ADDR);
-		CDBG("%s: Mesh Rolloff Delta Table\n", __func__);
-		for (i = 0; i < (V32_MESH_ROLL_OFF_DELTA_TABLE_SIZE * 2); i++) {
-			*cmdp_local =
-				msm_camera_io_r(
-					vfe32_ctrl->share_ctrl->vfebase +
-					VFE_DMI_DATA_LO);
-			CDBG("%s: %08x\n", __func__, *cmdp_local);
-			cmdp_local++;
-		}
-		CDBG("done reading delta table\n");
-		vfe32_program_dmi_cfg(NO_MEM_SELECTED, vfe32_ctrl);
-		if (copy_to_user((void __user *)(cmd->value), cmdp,
-			temp1)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		break;
-	case VFE_CMD_LA_CFG:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			vfe32_cmd[cmd->id].offset,
-			cmdp_local, (vfe32_cmd[cmd->id].length));
-
-		cmdp_local += 1;
-		vfe32_write_la_cfg(LUMA_ADAPT_LUT_RAM_BANK0,
-						   cmdp_local, vfe32_ctrl);
-		break;
-
-	case VFE_CMD_LA_UPDATE: {
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-
-		cmdp_local = cmdp + 1;
-		old_val = msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase + V32_LA_OFF);
-		if (old_val != 0x0)
-			vfe32_write_la_cfg(LUMA_ADAPT_LUT_RAM_BANK0,
-				cmdp_local, vfe32_ctrl);
-		else
-			vfe32_write_la_cfg(LUMA_ADAPT_LUT_RAM_BANK1,
-				cmdp_local, vfe32_ctrl);
-		}
-		vfe32_ctrl->update_la = true;
-		break;
-
-	case VFE_CMD_GET_LA_TABLE:
-		temp1 = sizeof(uint32_t) * VFE32_LA_TABLE_LENGTH / 2;
-		if (cmd->length != temp1) {
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		cmdp = kzalloc(temp1, GFP_KERNEL);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		if (msm_camera_io_r(vfe32_ctrl->
-				share_ctrl->vfebase + V32_LA_OFF))
-			vfe32_program_dmi_cfg(LUMA_ADAPT_LUT_RAM_BANK1,
-						vfe32_ctrl);
-		else
-			vfe32_program_dmi_cfg(LUMA_ADAPT_LUT_RAM_BANK0,
-						vfe32_ctrl);
-		for (i = 0 ; i < (VFE32_LA_TABLE_LENGTH / 2) ; i++) {
-			*cmdp_local =
-				msm_camera_io_r(
-					vfe32_ctrl->share_ctrl->vfebase +
-					VFE_DMI_DATA_LO);
-			*cmdp_local |= (msm_camera_io_r(
-				vfe32_ctrl->share_ctrl->vfebase +
-				VFE_DMI_DATA_LO)) << 16;
-			cmdp_local++;
-		}
-		vfe32_program_dmi_cfg(NO_MEM_SELECTED, vfe32_ctrl);
-		if (copy_to_user((void __user *)(cmd->value), cmdp,
-			temp1)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		break;
-	case VFE_CMD_SK_ENHAN_CFG:
-	case VFE_CMD_SK_ENHAN_UPDATE:{
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase + V32_SCE_OFF,
-			cmdp, V32_SCE_LEN);
-		}
-		break;
-
-	case VFE_CMD_LIVESHOT:
-		/* Configure primary channel */
-		vfe32_start_liveshot(pmctl, vfe32_ctrl);
-		break;
-
-	case VFE_CMD_LINEARIZATION_CFG:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp, (void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			V32_LINEARIZATION_OFF1,
-			cmdp_local, V32_LINEARIZATION_LEN1);
-		cmdp_local += 4;
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			V32_LINEARIZATION_OFF2,
-			cmdp_local, V32_LINEARIZATION_LEN2);
-
-		cmdp_local = cmdp + 17;
-		vfe32_write_linear_cfg(BLACK_LUT_RAM_BANK0,
-					cmdp_local, vfe32_ctrl);
-		break;
-
-	case VFE_CMD_LINEARIZATION_UPDATE:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp, (void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		cmdp_local++;
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			V32_LINEARIZATION_OFF1 + 4,
-			cmdp_local, (V32_LINEARIZATION_LEN1 - 4));
-		cmdp_local += 3;
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			V32_LINEARIZATION_OFF2,
-			cmdp_local, V32_LINEARIZATION_LEN2);
-		cmdp_local = cmdp + 17;
-		/*extracting the bank select*/
-		old_val = msm_camera_io_r(
-				vfe32_ctrl->share_ctrl->vfebase +
-				V32_LINEARIZATION_OFF1);
-
-		if (old_val != 0x0)
-			vfe32_write_linear_cfg(BLACK_LUT_RAM_BANK0,
-						cmdp_local, vfe32_ctrl);
-		else
-			vfe32_write_linear_cfg(BLACK_LUT_RAM_BANK1,
-						cmdp_local, vfe32_ctrl);
-		vfe32_ctrl->update_linear = true;
-		break;
-
-	case VFE_CMD_GET_LINEARIZATON_TABLE:
-		temp1 = sizeof(uint32_t) * VFE32_LINEARIZATON_TABLE_LENGTH;
-		if (cmd->length != temp1) {
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		cmdp = kzalloc(temp1, GFP_KERNEL);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		if (msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase +
-			V32_LINEARIZATION_OFF1))
-			vfe32_program_dmi_cfg(BLACK_LUT_RAM_BANK1, vfe32_ctrl);
-		else
-			vfe32_program_dmi_cfg(BLACK_LUT_RAM_BANK0, vfe32_ctrl);
-		CDBG("%s: Linearization Table\n", __func__);
-		for (i = 0 ; i < VFE32_LINEARIZATON_TABLE_LENGTH ; i++) {
-			*cmdp_local = msm_camera_io_r(
-				vfe32_ctrl->share_ctrl->vfebase +
-				VFE_DMI_DATA_LO);
-			CDBG("%s: %08x\n", __func__, *cmdp_local);
-			cmdp_local++;
-		}
-		vfe32_program_dmi_cfg(NO_MEM_SELECTED, vfe32_ctrl);
-		if (copy_to_user((void __user *)(cmd->value), cmdp,
-			temp1)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		break;
-	case VFE_CMD_DEMOSAICV3:
-		if (cmd->length !=
-			V32_DEMOSAICV3_0_LEN+V32_DEMOSAICV3_1_LEN) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		new_val = *cmdp_local;
-
-		old_val = msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase + V32_DEMOSAICV3_0_OFF);
-		old_val &= DEMOSAIC_MASK;
-		new_val = new_val | old_val;
-		*cmdp_local = new_val;
-
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase + V32_DEMOSAICV3_0_OFF,
-			cmdp_local, V32_DEMOSAICV3_0_LEN);
-		cmdp_local += 1;
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase + V32_DEMOSAICV3_1_OFF,
-			cmdp_local, V32_DEMOSAICV3_1_LEN);
-		break;
-
-	case VFE_CMD_DEMOSAICV3_UPDATE:
-		if (cmd->length !=
-			V32_DEMOSAICV3_0_LEN * V32_DEMOSAICV3_UP_REG_CNT) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		new_val = *cmdp_local;
-
-		old_val = msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase + V32_DEMOSAICV3_0_OFF);
-		old_val &= DEMOSAIC_MASK;
-		new_val = new_val | old_val;
-		*cmdp_local = new_val;
-
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase + V32_DEMOSAICV3_0_OFF,
-			cmdp_local, V32_DEMOSAICV3_0_LEN);
-		/* As the address space is not contiguous increment by 2
-		 * before copying to next address space */
-		cmdp_local += 1;
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase + V32_DEMOSAICV3_1_OFF,
-			cmdp_local, 2 * V32_DEMOSAICV3_0_LEN);
-		/* As the address space is not contiguous increment by 2
-		 * before copying to next address space */
-		cmdp_local += 2;
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase + V32_DEMOSAICV3_2_OFF,
-			cmdp_local, 2 * V32_DEMOSAICV3_0_LEN);
-		break;
-
-	case VFE_CMD_DEMOSAICV3_ABCC_CFG:
-		rc = -EFAULT;
-		break;
-
-	case VFE_CMD_DEMOSAICV3_ABF_UPDATE:/* 116 ABF update  */
-	case VFE_CMD_DEMOSAICV3_ABF_CFG: { /* 108 ABF config  */
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		new_val = *cmdp_local;
-
-		old_val = msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase + V32_DEMOSAICV3_0_OFF);
-		old_val &= ABF_MASK;
-		new_val = new_val | old_val;
-		*cmdp_local = new_val;
-
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase + V32_DEMOSAICV3_0_OFF,
-			cmdp_local, 4);
-
-		cmdp_local += 1;
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			vfe32_cmd[cmd->id].offset,
-			cmdp_local, (vfe32_cmd[cmd->id].length));
-		}
-		break;
-
-	case VFE_CMD_DEMOSAICV3_DBCC_CFG:
-	case VFE_CMD_DEMOSAICV3_DBCC_UPDATE:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		new_val = *cmdp_local;
-
-		old_val = msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase + V32_DEMOSAICV3_0_OFF);
-		old_val &= DBCC_MASK;
-
-		new_val = new_val | old_val;
-		*cmdp_local = new_val;
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase + V32_DEMOSAICV3_0_OFF,
-			cmdp_local, 4);
-		cmdp_local += 1;
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			vfe32_cmd[cmd->id].offset,
-			cmdp_local, (vfe32_cmd[cmd->id].length));
-		break;
-
-	case VFE_CMD_DEMOSAICV3_DBPC_CFG:
-	case VFE_CMD_DEMOSAICV3_DBPC_UPDATE:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		new_val = *cmdp_local;
-
-		old_val = msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase + V32_DEMOSAICV3_0_OFF);
-		old_val &= DBPC_MASK;
-
-		new_val = new_val | old_val;
-		*cmdp_local = new_val;
-		msm_camera_io_memcpy(vfe32_ctrl->share_ctrl->vfebase +
-			V32_DEMOSAICV3_0_OFF,
-			cmdp_local, V32_DEMOSAICV3_LEN);
-		cmdp_local += 1;
-		msm_camera_io_memcpy(vfe32_ctrl->share_ctrl->vfebase +
-			V32_DEMOSAICV3_DBPC_CFG_OFF,
-			cmdp_local, V32_DEMOSAICV3_DBPC_LEN);
-		cmdp_local += 1;
-		msm_camera_io_memcpy(vfe32_ctrl->share_ctrl->vfebase +
-			V32_DEMOSAICV3_DBPC_CFG_OFF0,
-			cmdp_local, V32_DEMOSAICV3_DBPC_LEN);
-		cmdp_local += 1;
-		msm_camera_io_memcpy(vfe32_ctrl->share_ctrl->vfebase +
-			V32_DEMOSAICV3_DBPC_CFG_OFF1,
-			cmdp_local, V32_DEMOSAICV3_DBPC_LEN);
-		cmdp_local += 1;
-		msm_camera_io_memcpy(vfe32_ctrl->share_ctrl->vfebase +
-			V32_DEMOSAICV3_DBPC_CFG_OFF2,
-			cmdp_local, V32_DEMOSAICV3_DBPC_LEN);
-		break;
-
-	case VFE_CMD_RGB_G_CFG: {
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase + V32_RGB_G_OFF,
-			cmdp, 4);
-		cmdp += 1;
-
-		vfe32_write_gamma_cfg(RGBLUT_RAM_CH0_BANK0, cmdp, vfe32_ctrl);
-		vfe32_write_gamma_cfg(RGBLUT_RAM_CH1_BANK0, cmdp, vfe32_ctrl);
-		vfe32_write_gamma_cfg(RGBLUT_RAM_CH2_BANK0, cmdp, vfe32_ctrl);
-		}
-	    cmdp -= 1;
-		break;
-
-	case VFE_CMD_RGB_G_UPDATE: {
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp, (void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-
-		old_val = msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase + V32_RGB_G_OFF);
-		cmdp += 1;
-		if (old_val != 0x0) {
-			vfe32_write_gamma_cfg(
-				RGBLUT_RAM_CH0_BANK0, cmdp, vfe32_ctrl);
-			vfe32_write_gamma_cfg(
-				RGBLUT_RAM_CH1_BANK0, cmdp, vfe32_ctrl);
-			vfe32_write_gamma_cfg(
-				RGBLUT_RAM_CH2_BANK0, cmdp, vfe32_ctrl);
-		} else {
-			vfe32_write_gamma_cfg(
-				RGBLUT_RAM_CH0_BANK1, cmdp, vfe32_ctrl);
-			vfe32_write_gamma_cfg(
-				RGBLUT_RAM_CH1_BANK1, cmdp, vfe32_ctrl);
-			vfe32_write_gamma_cfg(
-				RGBLUT_RAM_CH2_BANK1, cmdp, vfe32_ctrl);
-		}
-		}
-		vfe32_ctrl->update_gamma = TRUE;
-		cmdp -= 1;
-		break;
-
-	case VFE_CMD_GET_RGB_G_TABLE:
-		temp1 = sizeof(uint32_t) * VFE32_GAMMA_NUM_ENTRIES * 3;
-		if (cmd->length != temp1) {
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		cmdp = kzalloc(temp1, GFP_KERNEL);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-
-		old_val = msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase + V32_RGB_G_OFF);
-		temp2 = old_val ? RGBLUT_RAM_CH0_BANK1 :
-			RGBLUT_RAM_CH0_BANK0;
-		for (i = 0; i < 3; i++) {
-			vfe32_read_gamma_cfg(temp2,
-				cmdp_local + (VFE32_GAMMA_NUM_ENTRIES * i),
-				vfe32_ctrl);
-			temp2 += 2;
-		}
-		if (copy_to_user((void __user *)(cmd->value), cmdp,
-			temp1)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		break;
-
-	case VFE_CMD_STATS_AWB_STOP: {
-		if (vfe32_use_bayer_stats(vfe32_ctrl)) {
-			/* Error */
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		old_val = msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~AWB_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		}
-		break;
-	case VFE_CMD_STATS_AE_STOP: {
-		if (vfe32_use_bayer_stats(vfe32_ctrl)) {
-			/* Error */
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		old_val = msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~AE_BG_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		}
-		break;
-	case VFE_CMD_STATS_AF_STOP: {
-		if (vfe32_use_bayer_stats(vfe32_ctrl)) {
-			/* Error */
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		old_val = msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~AF_BF_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		}
-		break;
-
-	case VFE_CMD_STATS_IHIST_STOP: {
-		old_val = msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~IHIST_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		}
-		break;
-
-	case VFE_CMD_STATS_RS_STOP: {
-		old_val = msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~RS_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		}
-		break;
-
-	case VFE_CMD_STATS_CS_STOP: {
-		old_val = msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~CS_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		}
-		break;
-
-	case VFE_CMD_STATS_BG_STOP:
-	case VFE_CMD_STATS_BF_STOP:
-	case VFE_CMD_STATS_BHIST_STOP: {
-		if (!vfe32_use_bayer_stats(vfe32_ctrl)) {
-			/* Error */
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		old_val = msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase + VFE_STATS_CFG);
-		if (VFE_CMD_STATS_BG_STOP == cmd->id)
-			old_val &= ~STATS_BG_ENABLE_MASK;
-		else if (VFE_CMD_STATS_BF_STOP == cmd->id)
-			old_val &= ~STATS_BF_ENABLE_MASK;
-		else
-			old_val &= ~STATS_BHIST_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe32_ctrl->share_ctrl->vfebase + VFE_STATS_CFG);
-		if (VFE_CMD_STATS_BF_STOP == cmd->id) {
-			rc = vfe32_stats_flush_enqueue(vfe32_ctrl,
-					MSM_STATS_TYPE_BF);
-			if (rc < 0) {
-				pr_err("%s: dq stats buf err = %d",
-					   __func__, rc);
-				return -EINVAL;
-			}
-		}
-		}
-		break;
-
-	case VFE_CMD_STOP:
-		pr_info("vfe32_proc_general: cmdID = %s\n",
-			vfe32_general_cmd[cmd->id]);
-		if (copy_from_user(&vfe_params,
-				(void __user *)(cmd->value),
-				sizeof(struct msm_camera_vfe_params_t))) {
-				rc = -EFAULT;
-				goto proc_general_done;
-		}
-
-		vfe32_stop(vfe32_ctrl);
-		break;
-
-	case VFE_CMD_SYNC_TIMER_SETTING:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp, (void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		vfe32_sync_timer_start(cmdp, vfe32_ctrl);
-		break;
-
-	case VFE_CMD_MODULE_CFG: {
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		*cmdp &= ~STATS_ENABLE_MASK;
-		old_val = msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= STATS_ENABLE_MASK;
-		*cmdp |= old_val;
-
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			vfe32_cmd[cmd->id].offset,
-			cmdp, (vfe32_cmd[cmd->id].length));
-		}
-		break;
-
-	case VFE_CMD_ZSL:
-		if (copy_from_user(&vfe_params,
-				(void __user *)(cmd->value),
-				sizeof(struct msm_camera_vfe_params_t))) {
-				rc = -EFAULT;
-				goto proc_general_done;
-		}
-
-		vfe32_ctrl->share_ctrl->current_mode =
-			vfe_params.operation_mode;
-
-		rc = vfe32_zsl(pmctl, vfe32_ctrl);
-		break;
-
-	case VFE_CMD_ASF_CFG:
-	case VFE_CMD_ASF_UPDATE:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp, (void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			vfe32_cmd[cmd->id].offset,
-			cmdp, (vfe32_cmd[cmd->id].length));
-		cmdp_local = cmdp + V32_ASF_LEN/4;
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			V32_ASF_SPECIAL_EFX_CFG_OFF,
-			cmdp_local, V32_ASF_SPECIAL_EFX_CFG_LEN);
-		break;
-
-	case VFE_CMD_PCA_ROLL_OFF_CFG:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value) , cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-
-		cmdp_local = cmdp;
-
-		temp1 = *cmdp_local;
-		cmdp_local++;
-
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			V33_PCA_ROLL_OFF_CFG_OFF1,
-			cmdp_local, V33_PCA_ROLL_OFF_CFG_LEN1);
-		cmdp_local += 4;
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			V33_PCA_ROLL_OFF_CFG_OFF2,
-			cmdp_local, V33_PCA_ROLL_OFF_CFG_LEN2);
-
-		cmdp_local += 3;
-		CDBG("%s: start writing RollOff Ram0 table\n", __func__);
-		vfe32_program_dmi_cfg(ROLLOFF_RAM0_BANK0, vfe32_ctrl);
-		msm_camera_io_w(temp1,
-			vfe32_ctrl->share_ctrl->vfebase + VFE_DMI_ADDR);
-		for (i = 0 ; i < V33_PCA_ROLL_OFF_TABLE_SIZE ; i++) {
-			msm_camera_io_w(*(cmdp_local + 1),
-				vfe32_ctrl->share_ctrl->vfebase +
-				VFE33_DMI_DATA_HI);
-			msm_camera_io_w(*cmdp_local,
-				vfe32_ctrl->share_ctrl->vfebase +
-				VFE33_DMI_DATA_LO);
-			cmdp_local += 2;
-		}
-		CDBG("%s: end writing RollOff Ram0 table\n", __func__);
-
-		CDBG("%s: start writing RollOff Ram1 table\n", __func__);
-		vfe32_program_dmi_cfg(ROLLOFF_RAM1_BANK0, vfe32_ctrl);
-		msm_camera_io_w(temp1,
-			vfe32_ctrl->share_ctrl->vfebase + VFE_DMI_ADDR);
-		for (i = 0 ; i < V33_PCA_ROLL_OFF_TABLE_SIZE ; i++) {
-			msm_camera_io_w(*cmdp_local,
-				vfe32_ctrl->share_ctrl->vfebase +
-				VFE33_DMI_DATA_LO);
-			cmdp_local += 2;
-		}
-		CDBG("%s: end writing RollOff Ram1 table\n", __func__);
-
-		vfe32_program_dmi_cfg(NO_MEM_SELECTED, vfe32_ctrl);
-		break;
-
-	case VFE_CMD_PCA_ROLL_OFF_UPDATE:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value), cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-
-		cmdp_local = cmdp;
-
-		temp1 = *cmdp_local;
-		cmdp_local += 8;
-
-		temp2 = msm_camera_io_r(vfe32_ctrl->share_ctrl->vfebase +
-			V33_PCA_ROLL_OFF_CFG_OFF1)
-			& V33_PCA_ROLL_OFF_LUT_BANK_SEL_MASK;
-
-		CDBG("%s: start writing RollOff Ram0 table\n", __func__);
-		if (temp2)
-			vfe32_program_dmi_cfg(ROLLOFF_RAM0_BANK0, vfe32_ctrl);
-		else
-			vfe32_program_dmi_cfg(ROLLOFF_RAM0_BANK1, vfe32_ctrl);
-
-		msm_camera_io_w(temp1,
-			vfe32_ctrl->share_ctrl->vfebase + VFE_DMI_ADDR);
-		for (i = 0 ; i < V33_PCA_ROLL_OFF_TABLE_SIZE ; i++) {
-			msm_camera_io_w(*(cmdp_local + 1),
-				vfe32_ctrl->share_ctrl->vfebase +
-				VFE33_DMI_DATA_HI);
-			msm_camera_io_w(*cmdp_local,
-				vfe32_ctrl->share_ctrl->vfebase +
-				VFE33_DMI_DATA_LO);
-			cmdp_local += 2;
-		}
-		CDBG("%s: end writing RollOff Ram0 table\n", __func__);
-
-		CDBG("%s: start writing RollOff Ram1 table\n", __func__);
-		if (temp2)
-			vfe32_program_dmi_cfg(ROLLOFF_RAM1_BANK0, vfe32_ctrl);
-		else
-			vfe32_program_dmi_cfg(ROLLOFF_RAM1_BANK1, vfe32_ctrl);
-
-		msm_camera_io_w(temp1,
-			vfe32_ctrl->share_ctrl->vfebase + VFE_DMI_ADDR);
-		for (i = 0 ; i < V33_PCA_ROLL_OFF_TABLE_SIZE ; i++) {
-			msm_camera_io_w(*cmdp_local,
-				vfe32_ctrl->share_ctrl->vfebase +
-				VFE33_DMI_DATA_LO);
-			cmdp_local += 2;
-		}
-		CDBG("%s: end writing RollOff Ram1 table\n", __func__);
-
-		vfe32_program_dmi_cfg(NO_MEM_SELECTED, vfe32_ctrl);
-		vfe32_ctrl->update_rolloff = true;
-		break;
-	case VFE_CMD_GET_PCA_ROLLOFF_TABLE:
-		temp1 = sizeof(uint64_t) * V33_PCA_ROLL_OFF_TABLE_SIZE * 2;
-		if (cmd->length != temp1) {
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		cmdp = kzalloc(temp1, GFP_KERNEL);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		old_val = msm_camera_io_r(vfe32_ctrl->share_ctrl->vfebase +
-			V33_PCA_ROLL_OFF_CFG_OFF1) &
-			V33_PCA_ROLL_OFF_LUT_BANK_SEL_MASK;
-
-		if (old_val)
-			vfe32_program_dmi_cfg(ROLLOFF_RAM0_BANK1, vfe32_ctrl);
-		else
-			vfe32_program_dmi_cfg(ROLLOFF_RAM0_BANK0, vfe32_ctrl);
-
-		CDBG("%s: PCA Rolloff Ram0\n", __func__);
-		for (i = 0 ; i < V33_PCA_ROLL_OFF_TABLE_SIZE * 2; i++) {
-			temp2 = (i == (V33_PCA_ROLL_OFF_TABLE_SIZE));
-			if (old_val && temp2)
-				vfe32_program_dmi_cfg(ROLLOFF_RAM1_BANK1,
-				vfe32_ctrl);
-			else if (!old_val && temp2)
-				vfe32_program_dmi_cfg(ROLLOFF_RAM1_BANK0,
-				vfe32_ctrl);
-
-			*cmdp_local = msm_camera_io_r(
-				vfe32_ctrl->share_ctrl->vfebase +
-				VFE33_DMI_DATA_LO);
-			*(cmdp_local + 1) =
-				msm_camera_io_r(
-				vfe32_ctrl->share_ctrl->vfebase +
-				VFE33_DMI_DATA_HI);
-			CDBG("%s: %08x%08x\n", __func__,
-				*(cmdp_local + 1), *cmdp_local);
-			cmdp_local += 2;
-		}
-		vfe32_program_dmi_cfg(NO_MEM_SELECTED, vfe32_ctrl);
-		if (copy_to_user((void __user *)(cmd->value), cmdp,
-			temp1)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		break;
-	case VFE_CMD_GET_HW_VERSION:
-		if (cmd->length != V32_GET_HW_VERSION_LEN) {
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(V32_GET_HW_VERSION_LEN, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		*cmdp = msm_camera_io_r(
-			vfe32_ctrl->share_ctrl->vfebase+V32_GET_HW_VERSION_OFF);
-		if (copy_to_user((void __user *)(cmd->value), cmdp,
-			V32_GET_HW_VERSION_LEN)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		break;
-	case VFE_CMD_GET_REG_DUMP:
-		temp1 = sizeof(uint32_t) *
-			vfe32_ctrl->share_ctrl->register_total;
-		if (cmd->length != temp1) {
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(temp1, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		msm_camera_io_dump(vfe32_ctrl->share_ctrl->vfebase,
-			vfe32_ctrl->share_ctrl->register_total*4);
-		CDBG("%s: %p %p %d\n", __func__, (void *)cmdp,
-			vfe32_ctrl->share_ctrl->vfebase, temp1);
-		memcpy_fromio((void *)cmdp,
-			vfe32_ctrl->share_ctrl->vfebase, temp1);
-		if (copy_to_user((void __user *)(cmd->value), cmdp, temp1)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		break;
-	case VFE_CMD_FRAME_SKIP_CFG:
-		if (cmd->length != vfe32_cmd[cmd->id].length)
-			return -EINVAL;
-
-		cmdp = kmalloc(vfe32_cmd[cmd->id].length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-
-		if (copy_from_user((cmdp), (void __user *)cmd->value,
-				cmd->length)) {
-			rc = -EFAULT;
-			pr_err("%s copy from user failed for cmd %d",
-				__func__, cmd->id);
-			break;
-		}
-
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			vfe32_cmd[cmd->id].offset,
-			cmdp, (vfe32_cmd[cmd->id].length));
-		vfe32_ctrl->frame_skip_cnt = ((uint32_t)
-			*cmdp & VFE_FRAME_SKIP_PERIOD_MASK) + 1;
-		vfe32_ctrl->frame_skip_pattern = (uint32_t)(*(cmdp + 2));
-		break;
-	case VFE_CMD_STOP_LIVESHOT:
-		CDBG("%s Stopping liveshot ", __func__);
-		vfe32_stop_liveshot(pmctl, vfe32_ctrl);
-		break;
-	default:
-		if (cmd->length != vfe32_cmd[cmd->id].length)
-			return -EINVAL;
-
-		cmdp = kmalloc(vfe32_cmd[cmd->id].length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-
-		if (copy_from_user((cmdp), (void __user *)cmd->value,
-				cmd->length)) {
-			rc = -EFAULT;
-			pr_err("%s copy from user failed for cmd %d",
-				__func__, cmd->id);
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(
-			vfe32_ctrl->share_ctrl->vfebase +
-			vfe32_cmd[cmd->id].offset,
-			cmdp, (vfe32_cmd[cmd->id].length));
-		break;
-
-	}
-
-proc_general_done:
-	kfree(cmdp);
-
-	return rc;
-}
-
-static inline void vfe32_read_irq_status(
-	struct axi_ctrl_t *axi_ctrl, struct vfe32_irq_status *out)
-{
-	uint32_t *temp;
-	memset(out, 0, sizeof(struct vfe32_irq_status));
-	temp = (uint32_t *)(axi_ctrl->share_ctrl->vfebase + VFE_IRQ_STATUS_0);
-	out->vfeIrqStatus0 = msm_camera_io_r(temp);
-
-	temp = (uint32_t *)(axi_ctrl->share_ctrl->vfebase + VFE_IRQ_STATUS_1);
-	out->vfeIrqStatus1 = msm_camera_io_r(temp);
-
-	temp = (uint32_t *)(axi_ctrl->share_ctrl->vfebase + VFE_CAMIF_STATUS);
-	out->camifStatus = msm_camera_io_r(temp);
-	CDBG("camifStatus  = 0x%x\n", out->camifStatus);
-
-	/* clear the pending interrupt of the same kind.*/
-	msm_camera_io_w(out->vfeIrqStatus0,
-		axi_ctrl->share_ctrl->vfebase + VFE_IRQ_CLEAR_0);
-	msm_camera_io_w(out->vfeIrqStatus1,
-		axi_ctrl->share_ctrl->vfebase + VFE_IRQ_CLEAR_1);
-
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(1, axi_ctrl->share_ctrl->vfebase + VFE_IRQ_CMD);
-
-}
-
-void axi_stop_pix(struct vfe_share_ctrl_t *share_ctrl,
-	uint32_t vfe_mode, uint8_t cmd_type)
-{
-	uint32_t reg_update = 0x1;
-	switch (cmd_type) {
-	case AXI_CMD_RAW_CAPTURE:
-		msm_camera_io_w(0, share_ctrl->vfebase
-			+ vfe32_AXI_WM_CFG[share_ctrl->outpath.out0.ch0]);
-		break;
-	case AXI_CMD_PREVIEW: {
-		switch (vfe_mode) {
-		case VFE_OUTPUTS_PREVIEW:
-		case VFE_OUTPUTS_PREVIEW_AND_VIDEO:
-			if (share_ctrl->comp_output_mode &
-				VFE32_OUTPUT_MODE_PRIMARY) {
-				msm_camera_io_w(0, share_ctrl->vfebase
-					+ vfe32_AXI_WM_CFG[share_ctrl->
-					outpath.out0.ch0]);
-				msm_camera_io_w(0, share_ctrl->vfebase
-					+ vfe32_AXI_WM_CFG[share_ctrl->
-					outpath.out0.ch1]);
-			} else if (share_ctrl->comp_output_mode &
-					VFE32_OUTPUT_MODE_PRIMARY_ALL_CHNLS) {
-				msm_camera_io_w(0, share_ctrl->vfebase
-					+ vfe32_AXI_WM_CFG[share_ctrl->
-					outpath.out0.ch0]);
-				msm_camera_io_w(0, share_ctrl->vfebase
-					+ vfe32_AXI_WM_CFG[share_ctrl->
-					outpath.out0.ch1]);
-				msm_camera_io_w(0, share_ctrl->vfebase
-					+ vfe32_AXI_WM_CFG[share_ctrl->
-					outpath.out0.ch2]);
-			}
-			break;
-		default:
-			if (share_ctrl->comp_output_mode &
-				VFE32_OUTPUT_MODE_SECONDARY) {
-				msm_camera_io_w(0, share_ctrl->vfebase
-					+ vfe32_AXI_WM_CFG[share_ctrl->
-					outpath.out1.ch0]);
-				msm_camera_io_w(0, share_ctrl->vfebase
-					+ vfe32_AXI_WM_CFG[share_ctrl->
-					outpath.out1.ch1]);
-			} else if (share_ctrl->comp_output_mode &
-				VFE32_OUTPUT_MODE_SECONDARY_ALL_CHNLS) {
-				msm_camera_io_w(0, share_ctrl->vfebase
-					+ vfe32_AXI_WM_CFG[share_ctrl->
-					outpath.out1.ch0]);
-				msm_camera_io_w(0, share_ctrl->vfebase
-					+ vfe32_AXI_WM_CFG[share_ctrl->
-					outpath.out1.ch1]);
-				msm_camera_io_w(0, share_ctrl->vfebase
-					+ vfe32_AXI_WM_CFG[share_ctrl->
-					outpath.out1.ch2]);
-			}
-			break;
-			}
-		}
-		break;
-	default:
-		if (share_ctrl->comp_output_mode &
-			VFE32_OUTPUT_MODE_PRIMARY) {
-			msm_camera_io_w(0, share_ctrl->vfebase +
-				vfe32_AXI_WM_CFG[share_ctrl->
-				outpath.out0.ch0]);
-			msm_camera_io_w(0, share_ctrl->vfebase +
-				vfe32_AXI_WM_CFG[share_ctrl->
-				outpath.out0.ch1]);
-		} else if (share_ctrl->comp_output_mode &
-				VFE32_OUTPUT_MODE_PRIMARY_ALL_CHNLS) {
-			msm_camera_io_w(0, share_ctrl->vfebase +
-				vfe32_AXI_WM_CFG[share_ctrl->
-				outpath.out0.ch0]);
-			msm_camera_io_w(0, share_ctrl->vfebase +
-				vfe32_AXI_WM_CFG[share_ctrl->
-				outpath.out0.ch1]);
-			msm_camera_io_w(0, share_ctrl->vfebase +
-				vfe32_AXI_WM_CFG[share_ctrl->
-				outpath.out0.ch2]);
-		}
-
-		if (share_ctrl->comp_output_mode &
-			VFE32_OUTPUT_MODE_SECONDARY) {
-			msm_camera_io_w(0, share_ctrl->vfebase +
-				vfe32_AXI_WM_CFG[share_ctrl->
-				outpath.out1.ch0]);
-			msm_camera_io_w(0, share_ctrl->vfebase +
-				vfe32_AXI_WM_CFG[share_ctrl->outpath.out1.ch1]);
-		} else if (share_ctrl->comp_output_mode &
-			VFE32_OUTPUT_MODE_SECONDARY_ALL_CHNLS) {
-			msm_camera_io_w(0, share_ctrl->vfebase +
-				vfe32_AXI_WM_CFG[share_ctrl->outpath.out1.ch0]);
-			msm_camera_io_w(0, share_ctrl->vfebase +
-				vfe32_AXI_WM_CFG[share_ctrl->outpath.out1.ch1]);
-			msm_camera_io_w(0, share_ctrl->vfebase +
-				vfe32_AXI_WM_CFG[share_ctrl->outpath.out1.ch2]);
-		}
-		break;
-	}
-
-	msm_camera_io_w_mb(reg_update,
-		share_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-}
-
-void axi_stop_rdi0(struct vfe_share_ctrl_t *share_ctrl)
-{
-	uint32_t reg_update = 0x2;
-	msm_camera_io_w(0, share_ctrl->vfebase +
-		vfe32_AXI_WM_CFG[share_ctrl->outpath.out2.ch0]);
-	msm_camera_io_w_mb(reg_update,
-		share_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-}
-
-void axi_stop_rdi1(struct vfe_share_ctrl_t *share_ctrl)
-{
-	uint32_t reg_update = 0x4;
-	msm_camera_io_w(0, share_ctrl->vfebase +
-		vfe32_AXI_WM_CFG[share_ctrl->outpath.out3.ch0]);
-	msm_camera_io_w_mb(reg_update,
-		share_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-}
-
-void axi_stop_process(struct vfe_share_ctrl_t *share_ctrl)
-{
-	uint32_t vfe_mode =
-	share_ctrl->current_mode & ~(VFE_OUTPUTS_RDI0|
-		VFE_OUTPUTS_RDI1);
-
-	if (share_ctrl->current_mode & VFE_OUTPUTS_RDI0) {
-		axi_stop_rdi0(share_ctrl);
-		axi_disable_wm_irq(share_ctrl,
-			VFE32_OUTPUT_MODE_TERTIARY1);
-		share_ctrl->comp_output_mode &= ~VFE32_OUTPUT_MODE_TERTIARY1;
-		share_ctrl->operation_mode &=
-			~(VFE_OUTPUTS_RDI0);
-	}
-	if (share_ctrl->current_mode & VFE_OUTPUTS_RDI1) {
-		axi_stop_rdi1(share_ctrl);
-		axi_disable_wm_irq(share_ctrl,
-			VFE32_OUTPUT_MODE_TERTIARY2);
-		share_ctrl->comp_output_mode &= ~VFE32_OUTPUT_MODE_TERTIARY2;
-		share_ctrl->operation_mode &=
-			~(VFE_OUTPUTS_RDI1);
-	}
-	if (vfe_mode) {
-		uint16_t mode = share_ctrl->comp_output_mode &
-			~(VFE32_OUTPUT_MODE_TERTIARY1|
-			VFE32_OUTPUT_MODE_TERTIARY2);
-		axi_stop_pix(share_ctrl, vfe_mode, share_ctrl->cmd_type);
-		axi_disable_wm_irq(share_ctrl, mode);
-		share_ctrl->comp_output_mode &=
-				(VFE32_OUTPUT_MODE_TERTIARY1|
-				VFE32_OUTPUT_MODE_TERTIARY2);
-	}
-}
-
-static void vfe32_process_reg_update_irq(
-		struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	unsigned long flags;
-	struct vfe_share_ctrl_t *share_ctrl = vfe32_ctrl->share_ctrl;
-	if (atomic_read(
-		&share_ctrl->pix0_update_ack_pending) == 2) {
-		uint32_t vfe_mode =
-				share_ctrl->operation_mode & ~(VFE_OUTPUTS_RDI0|
-					VFE_OUTPUTS_RDI1);
-
-		if (share_ctrl->dual_enabled && !share_ctrl->update_counter) {
-			axi_stop_pix(share_ctrl, vfe_mode,
-				share_ctrl->cmd_type);
-			share_ctrl->update_counter++;
-		} else {
-			uint16_t output_mode =
-				share_ctrl->comp_output_mode &
-				~(VFE32_OUTPUT_MODE_TERTIARY1|
-				VFE32_OUTPUT_MODE_TERTIARY2);
-			share_ctrl->update_counter = 0;
-			if (!share_ctrl->dual_enabled)
-				axi_stop_pix(share_ctrl, vfe_mode,
-					share_ctrl->cmd_type);
-			axi_disable_wm_irq(share_ctrl, output_mode);
-			axi_disable_irq(share_ctrl, vfe_mode);
-			atomic_set(&share_ctrl->pix0_update_ack_pending, 0);
-			msm_camera_io_w_mb(
-					CAMIF_COMMAND_STOP_AT_FRAME_BOUNDARY,
-					share_ctrl->vfebase +
-					VFE_CAMIF_COMMAND);
-			vfe32_send_isp_msg(&vfe32_ctrl->subdev,
-				share_ctrl->vfeFrameId,
-				MSG_ID_PIX0_UPDATE_ACK);
-			share_ctrl->comp_output_mode &=
-				(VFE32_OUTPUT_MODE_TERTIARY1|
-				VFE32_OUTPUT_MODE_TERTIARY2);
-		}
-	}  else {
-		if (share_ctrl->recording_state == VFE_STATE_START_REQUESTED) {
-			if (share_ctrl->operation_mode &
-					VFE_OUTPUTS_VIDEO_AND_PREVIEW) {
-				msm_camera_io_w((
-					0x1 << share_ctrl->outpath.out0.ch0 |
-					0x1 << share_ctrl->outpath.out0.ch1),
-					share_ctrl->vfebase + VFE_BUS_CMD);
-				msm_camera_io_w(1,
-					share_ctrl->vfebase + vfe32_AXI_WM_CFG[
-					share_ctrl->outpath.out0.ch0]);
-				msm_camera_io_w(1,
-					share_ctrl->vfebase + vfe32_AXI_WM_CFG[
-					share_ctrl->outpath.out0.ch1]);
-			} else if (share_ctrl->operation_mode &
-					VFE_OUTPUTS_PREVIEW_AND_VIDEO) {
-				msm_camera_io_w((
-					0x1 << share_ctrl->outpath.out1.ch0 |
-					0x1 << share_ctrl->outpath.out1.ch1),
-					share_ctrl->vfebase + VFE_BUS_CMD);
-				msm_camera_io_w(1,
-					share_ctrl->vfebase + vfe32_AXI_WM_CFG[
-					share_ctrl->outpath.out1.ch0]);
-				msm_camera_io_w(1,
-					share_ctrl->vfebase + vfe32_AXI_WM_CFG[
-					share_ctrl->outpath.out1.ch1]);
-			}
-			share_ctrl->recording_state = VFE_STATE_STARTED;
-			msm_camera_io_w_mb(1,
-				share_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-			CDBG("start video triggered .\n");
-		} else if (share_ctrl->recording_state ==
-					VFE_STATE_STOP_REQUESTED) {
-			if (share_ctrl->operation_mode &
-					VFE_OUTPUTS_VIDEO_AND_PREVIEW) {
-				msm_camera_io_w(0,
-					share_ctrl->vfebase + vfe32_AXI_WM_CFG[
-					share_ctrl->outpath.out0.ch0]);
-				msm_camera_io_w(0,
-					share_ctrl->vfebase + vfe32_AXI_WM_CFG[
-					share_ctrl->outpath.out0.ch1]);
-			} else if (share_ctrl->operation_mode &
-					VFE_OUTPUTS_PREVIEW_AND_VIDEO) {
-				msm_camera_io_w(0,
-					share_ctrl->vfebase + vfe32_AXI_WM_CFG[
-					share_ctrl->outpath.out1.ch0]);
-				msm_camera_io_w(0,
-					share_ctrl->vfebase + vfe32_AXI_WM_CFG[
-					share_ctrl->outpath.out1.ch1]);
-			}
-			CDBG("stop video triggered .\n");
-		}
-
-		if (atomic_cmpxchg(
-		&share_ctrl->pix0_update_ack_pending, 1, 0) == 1) {
-			share_ctrl->comp_output_mode |=
-				(share_ctrl->outpath.output_mode
-				& ~(VFE32_OUTPUT_MODE_TERTIARY1|
-					VFE32_OUTPUT_MODE_TERTIARY2));
-			vfe32_send_isp_msg(&vfe32_ctrl->subdev,
-				share_ctrl->vfeFrameId, MSG_ID_PIX0_UPDATE_ACK);
-		} else {
-			if (share_ctrl->recording_state ==
-						VFE_STATE_STOP_REQUESTED) {
-				share_ctrl->recording_state = VFE_STATE_STOPPED;
-				/* request a reg update and send STOP_REC_ACK
-				 * when we process the next reg update irq.
-				 */
-				msm_camera_io_w_mb(1, share_ctrl->vfebase +
-							VFE_REG_UPDATE_CMD);
-			} else if (share_ctrl->recording_state ==
-						VFE_STATE_STOPPED) {
-				vfe32_send_isp_msg(&vfe32_ctrl->subdev,
-					share_ctrl->vfeFrameId,
-					MSG_ID_STOP_REC_ACK);
-				share_ctrl->recording_state = VFE_STATE_IDLE;
-			}
-			spin_lock_irqsave(
-				&share_ctrl->update_ack_lock,
-				flags);
-			if (share_ctrl->update_ack_pending == TRUE) {
-				share_ctrl->update_ack_pending = FALSE;
-				spin_unlock_irqrestore(
-					&share_ctrl->update_ack_lock, flags);
-				vfe32_send_isp_msg(&vfe32_ctrl->subdev,
-					share_ctrl->vfeFrameId,
-					MSG_ID_UPDATE_ACK);
-			} else {
-				spin_unlock_irqrestore(
-					&share_ctrl->update_ack_lock, flags);
-			}
-		}
-
-		switch (share_ctrl->liveshot_state) {
-		case VFE_STATE_START_REQUESTED:
-			CDBG("%s enabling liveshot output\n", __func__);
-			if (share_ctrl->comp_output_mode &
-						VFE32_OUTPUT_MODE_PRIMARY) {
-				msm_camera_io_w((
-					0x1 << share_ctrl->outpath.out0.ch0 |
-					0x1 << share_ctrl->outpath.out0.ch1),
-					share_ctrl->vfebase + VFE_BUS_CMD);
-				msm_camera_io_w(1, share_ctrl->vfebase +
-					vfe32_AXI_WM_CFG[
-					share_ctrl->outpath.out0.ch0]);
-				msm_camera_io_w(1, share_ctrl->vfebase +
-					vfe32_AXI_WM_CFG[
-					share_ctrl->outpath.out0.ch1]);
-
-				share_ctrl->liveshot_state =
-					VFE_STATE_STARTED;
-			}
-			break;
-		case VFE_STATE_STARTED:
-			share_ctrl->vfe_capture_count--;
-			if (!share_ctrl->vfe_capture_count &&
-				(share_ctrl->comp_output_mode &
-					VFE32_OUTPUT_MODE_PRIMARY)) {
-				msm_camera_io_w(0, share_ctrl->vfebase +
-					vfe32_AXI_WM_CFG[
-					share_ctrl->outpath.out0.ch0]);
-				msm_camera_io_w(0, share_ctrl->vfebase +
-					vfe32_AXI_WM_CFG[
-					share_ctrl->outpath.out0.ch1]);
-			}
-			break;
-		case VFE_STATE_STOP_REQUESTED:
-			if (share_ctrl->comp_output_mode &
-					VFE32_OUTPUT_MODE_PRIMARY) {
-				/* Stop requested, stop write masters, and
-				 * trigger REG_UPDATE. Send STOP_LS_ACK in
-				 * next reg update. */
-				msm_camera_io_w(0, share_ctrl->vfebase +
-					vfe32_AXI_WM_CFG[
-					share_ctrl->outpath.out0.ch0]);
-				msm_camera_io_w(0, share_ctrl->vfebase +
-					vfe32_AXI_WM_CFG[
-					share_ctrl->outpath.out0.ch1]);
-
-				share_ctrl->liveshot_state = VFE_STATE_STOPPED;
-				msm_camera_io_w_mb(1, share_ctrl->vfebase +
-					VFE_REG_UPDATE_CMD);
-			}
-			break;
-		case VFE_STATE_STOPPED:
-			CDBG("%s Sending STOP_LS ACK\n", __func__);
-			vfe32_send_isp_msg(&vfe32_ctrl->subdev,
-				share_ctrl->vfeFrameId, MSG_ID_STOP_LS_ACK);
-			share_ctrl->liveshot_state = VFE_STATE_IDLE;
-			break;
-		default:
-			break;
-		}
-
-		if ((share_ctrl->operation_mode & VFE_OUTPUTS_THUMB_AND_MAIN) ||
-			(share_ctrl->operation_mode &
-				VFE_OUTPUTS_MAIN_AND_THUMB) ||
-			(share_ctrl->operation_mode &
-				VFE_OUTPUTS_THUMB_AND_JPEG) ||
-			(share_ctrl->operation_mode &
-				VFE_OUTPUTS_JPEG_AND_THUMB)) {
-			/* in snapshot mode */
-			/* later we need to add check for live snapshot mode. */
-			if (vfe32_ctrl->frame_skip_pattern & (0x1 <<
-				(vfe32_ctrl->snapshot_frame_cnt %
-					vfe32_ctrl->frame_skip_cnt))) {
-				share_ctrl->vfe_capture_count--;
-				/* if last frame to be captured: */
-				if (share_ctrl->vfe_capture_count == 0) {
-					/* stop the bus output: */
-					uint32_t vfe_mode =
-						share_ctrl->operation_mode &
-							~(VFE_OUTPUTS_RDI0|
-							VFE_OUTPUTS_RDI1);
-					axi_stop_pix(share_ctrl, vfe_mode,
-						AXI_CMD_CAPTURE);
-					msm_camera_io_w_mb
-					(CAMIF_COMMAND_STOP_AT_FRAME_BOUNDARY,
-					share_ctrl->vfebase +
-					VFE_CAMIF_COMMAND);
-					vfe32_ctrl->snapshot_frame_cnt = -1;
-					vfe32_ctrl->frame_skip_cnt = 31;
-					vfe32_ctrl->frame_skip_pattern =
-								0xffffffff;
-				} /*if snapshot count is 0*/
-			} /*if frame is not being dropped*/
-			vfe32_ctrl->snapshot_frame_cnt++;
-			/* then do reg_update. */
-			msm_camera_io_w(1,
-				share_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-		} /* if snapshot mode. */
-	}
-}
-
-static void vfe32_process_rdi0_reg_update_irq(
-	struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	if (atomic_cmpxchg(
-		&vfe32_ctrl->share_ctrl->rdi0_update_ack_pending, 1, 0) == 1) {
-		vfe32_ctrl->share_ctrl->comp_output_mode |=
-			VFE32_OUTPUT_MODE_TERTIARY1;
-		vfe32_send_isp_msg(&vfe32_ctrl->subdev,
-			vfe32_ctrl->share_ctrl->rdi0FrameId,
-			MSG_ID_RDI0_UPDATE_ACK);
-	}
-
-	if ((atomic_read(
-		&vfe32_ctrl->share_ctrl->rdi0_update_ack_pending) == 2)
-		|| (vfe32_ctrl->share_ctrl->rdi0_capture_count == 0)) {
-		axi_disable_wm_irq(vfe32_ctrl->share_ctrl,
-			VFE32_OUTPUT_MODE_TERTIARY1);
-		axi_disable_irq(vfe32_ctrl->share_ctrl, VFE_OUTPUTS_RDI0);
-		atomic_set(&vfe32_ctrl->share_ctrl->rdi0_update_ack_pending, 0);
-		vfe32_send_isp_msg(&vfe32_ctrl->subdev,
-			vfe32_ctrl->share_ctrl->rdi0FrameId,
-			MSG_ID_RDI0_UPDATE_ACK);
-
-		if (vfe32_ctrl->share_ctrl->rdi0_capture_count == 0)
-			vfe32_ctrl->share_ctrl->rdi0_capture_count = -1;
-		if (vfe32_ctrl->share_ctrl->outpath.out2.capture_cnt
-			== 0)
-			vfe32_ctrl->share_ctrl->outpath.out2.capture_cnt = -1;
-		vfe32_ctrl->share_ctrl->comp_output_mode &=
-			~VFE32_OUTPUT_MODE_TERTIARY1;
-		vfe32_ctrl->share_ctrl->operation_mode &=
-			~(VFE_OUTPUTS_RDI0);
-	}
-
-	if (vfe32_ctrl->share_ctrl->rdi0_capture_count > 0) {
-		vfe32_ctrl->share_ctrl->rdi0_capture_count--;
-		if (!vfe32_ctrl->share_ctrl->rdi0_capture_count)
-			axi_stop_rdi0(vfe32_ctrl->share_ctrl);
-	}
-}
-
-static void vfe32_process_rdi1_reg_update_irq(
-	struct vfe32_ctrl_type *vfe32_ctrl)
-{
-
-	if (atomic_cmpxchg(
-		&vfe32_ctrl->share_ctrl->rdi1_update_ack_pending, 1, 0)
-				== 1) {
-		vfe32_ctrl->share_ctrl->comp_output_mode |=
-			VFE32_OUTPUT_MODE_TERTIARY2;
-		vfe32_send_isp_msg(&vfe32_ctrl->subdev,
-			vfe32_ctrl->share_ctrl->rdi1FrameId,
-			MSG_ID_RDI1_UPDATE_ACK);
-	}
-
-	if ((atomic_read(
-		&vfe32_ctrl->share_ctrl->rdi1_update_ack_pending) == 2)
-		|| (vfe32_ctrl->share_ctrl->rdi1_capture_count == 0)) {
-		axi_disable_wm_irq(vfe32_ctrl->share_ctrl,
-			VFE32_OUTPUT_MODE_TERTIARY2);
-		axi_disable_irq(vfe32_ctrl->share_ctrl, VFE_OUTPUTS_RDI1);
-		atomic_set(&vfe32_ctrl->share_ctrl->rdi1_update_ack_pending, 0);
-		vfe32_send_isp_msg(&vfe32_ctrl->subdev,
-			vfe32_ctrl->share_ctrl->rdi1FrameId,
-			MSG_ID_RDI1_UPDATE_ACK);
-
-		if (vfe32_ctrl->share_ctrl->rdi1_capture_count == 0)
-			vfe32_ctrl->share_ctrl->rdi1_capture_count = -1;
-		if (vfe32_ctrl->share_ctrl->outpath.out3.capture_cnt
-			== 0)
-			vfe32_ctrl->share_ctrl->outpath.out3.capture_cnt = -1;
-		vfe32_ctrl->share_ctrl->comp_output_mode &=
-			~VFE32_OUTPUT_MODE_TERTIARY2;
-		vfe32_ctrl->share_ctrl->operation_mode &=
-			~(VFE_OUTPUTS_RDI1);
-	}
-
-	if (vfe32_ctrl->share_ctrl->rdi1_capture_count > 0) {
-		vfe32_ctrl->share_ctrl->rdi1_capture_count--;
-		if (!vfe32_ctrl->share_ctrl->rdi1_capture_count)
-			axi_stop_rdi1(vfe32_ctrl->share_ctrl);
-	}
-}
-
-static void vfe32_process_reset_irq(
-		struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	unsigned long flags;
-
-	atomic_set(&vfe32_ctrl->share_ctrl->vstate, 0);
-	atomic_set(&vfe32_ctrl->share_ctrl->handle_common_irq, 0);
-
-	spin_lock_irqsave(&vfe32_ctrl->share_ctrl->stop_flag_lock, flags);
-	if (vfe32_ctrl->share_ctrl->stop_ack_pending) {
-		vfe32_ctrl->share_ctrl->stop_ack_pending = FALSE;
-		spin_unlock_irqrestore(
-			&vfe32_ctrl->share_ctrl->stop_flag_lock, flags);
-		if (vfe32_ctrl->share_ctrl->sync_abort)
-			complete(&vfe32_ctrl->share_ctrl->reset_complete);
-		else
-			vfe32_send_isp_msg(&vfe32_ctrl->subdev,
-				vfe32_ctrl->share_ctrl->vfeFrameId,
-				MSG_ID_STOP_ACK);
-	} else {
-		spin_unlock_irqrestore(
-			&vfe32_ctrl->share_ctrl->stop_flag_lock, flags);
-		/* this is from reset command. */
-		vfe32_reset_internal_variables(vfe32_ctrl);
-		if (vfe32_ctrl->share_ctrl->vfe_reset_flag) {
-			vfe32_ctrl->share_ctrl->vfe_reset_flag = false;
-			msm_camera_io_w(0x7F80,
-				vfe32_ctrl->share_ctrl->vfebase + VFE_BUS_CMD);
-		} else {
-			/* reload all write masters. (frame & line)*/
-			msm_camera_io_w(0x7FFF,
-				vfe32_ctrl->share_ctrl->vfebase + VFE_BUS_CMD);
-		}
-		complete(&vfe32_ctrl->share_ctrl->reset_complete);
-	}
-}
-
-static void vfe32_process_camif_sof_irq(
-		struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	if (vfe32_ctrl->share_ctrl->operation_mode ==
-		VFE_OUTPUTS_RAW) {
-		if (atomic_cmpxchg(
-			&vfe32_ctrl->share_ctrl->pix0_update_ack_pending,
-					1, 0) == 1) {
-			vfe32_ctrl->share_ctrl->comp_output_mode |=
-				(vfe32_ctrl->share_ctrl->outpath.output_mode
-				& ~(VFE32_OUTPUT_MODE_TERTIARY1|
-				VFE32_OUTPUT_MODE_TERTIARY2));
-			vfe32_send_isp_msg(&vfe32_ctrl->subdev,
-				vfe32_ctrl->share_ctrl->vfeFrameId,
-				MSG_ID_PIX0_UPDATE_ACK);
-		}
-
-		vfe32_ctrl->share_ctrl->vfe_capture_count--;
-		/* if last frame to be captured: */
-		if (vfe32_ctrl->share_ctrl->vfe_capture_count == 0) {
-			/* Ensure the write order while writing
-			 to the command register using the barrier */
-			msm_camera_io_w_mb(CAMIF_COMMAND_STOP_AT_FRAME_BOUNDARY,
-			vfe32_ctrl->share_ctrl->vfebase + VFE_CAMIF_COMMAND);
-		}
-	} /* if raw snapshot mode. */
-	if ((vfe32_ctrl->hfr_mode != HFR_MODE_OFF) &&
-		(vfe32_ctrl->share_ctrl->operation_mode ==
-			VFE_MODE_OF_OPERATION_VIDEO) &&
-		(vfe32_ctrl->share_ctrl->vfeFrameId %
-			vfe32_ctrl->hfr_mode != 0)) {
-		if (vfe32_ctrl->vfe_sof_count_enable)
-			vfe32_ctrl->share_ctrl->vfeFrameId++;
-		CDBG("Skip the SOF notification when HFR enabled\n");
-		return;
-	}
-	if (vfe32_ctrl->vfe_sof_count_enable)
-		vfe32_ctrl->share_ctrl->vfeFrameId++;
-
-	vfe32_send_isp_msg(&vfe32_ctrl->subdev,
-		vfe32_ctrl->share_ctrl->vfeFrameId, MSG_ID_SOF_ACK);
-	CDBG("camif_sof_irq, frameId = %d\n",
-		vfe32_ctrl->share_ctrl->vfeFrameId);
-
-	if (vfe32_ctrl->sync_timer_state) {
-		if (vfe32_ctrl->sync_timer_repeat_count == 0)
-			vfe32_sync_timer_stop(vfe32_ctrl);
-		else
-			vfe32_ctrl->sync_timer_repeat_count--;
-	}
-}
-
-static void vfe32_process_error_irq(
-	struct axi_ctrl_t *axi_ctrl, uint32_t errStatus)
-{
-	uint32_t reg_value;
-	if (errStatus & VFE32_IMASK_VIOLATION) {
-		pr_err("vfe32_irq: violation interrupt\n");
-		reg_value = msm_camera_io_r(
-			axi_ctrl->share_ctrl->vfebase + VFE_VIOLATION_STATUS);
-		pr_err("%s: violationStatus  = 0x%x\n", __func__, reg_value);
-	}
-
-	if (errStatus & VFE32_IMASK_CAMIF_ERROR) {
-		pr_err("vfe32_irq: camif errors\n");
-		reg_value = msm_camera_io_r(
-			axi_ctrl->share_ctrl->vfebase + VFE_CAMIF_STATUS);
-		v4l2_subdev_notify(&axi_ctrl->subdev,
-			NOTIFY_VFE_CAMIF_ERROR, (void *)NULL);
-		pr_err("camifStatus  = 0x%x\n", reg_value);
-		vfe32_send_isp_msg(&axi_ctrl->subdev,
-			axi_ctrl->share_ctrl->vfeFrameId, MSG_ID_CAMIF_ERROR);
-	}
-
-	if (errStatus & VFE32_IMASK_BHIST_OVWR)
-		pr_err("vfe32_irq: stats bhist overwrite\n");
-
-	if (errStatus & VFE32_IMASK_STATS_CS_OVWR)
-		pr_err("vfe32_irq: stats cs overwrite\n");
-
-	if (errStatus & VFE32_IMASK_STATS_IHIST_OVWR)
-		pr_err("vfe32_irq: stats ihist overwrite\n");
-
-	if (errStatus & VFE32_IMASK_REALIGN_BUF_Y_OVFL)
-		pr_err("vfe32_irq: realign bug Y overflow\n");
-
-	if (errStatus & VFE32_IMASK_REALIGN_BUF_CB_OVFL)
-		pr_err("vfe32_irq: realign bug CB overflow\n");
-
-	if (errStatus & VFE32_IMASK_REALIGN_BUF_CR_OVFL)
-		pr_err("vfe32_irq: realign bug CR overflow\n");
-
-	if (errStatus & VFE32_IMASK_STATS_AE_BG_BUS_OVFL)
-		pr_err("vfe32_irq: ae/bg stats bus overflow\n");
-
-	if (errStatus & VFE32_IMASK_STATS_AF_BF_BUS_OVFL)
-		pr_err("vfe32_irq: af/bf stats bus overflow\n");
-
-	if (errStatus & VFE32_IMASK_STATS_AWB_BUS_OVFL)
-		pr_err("vfe32_irq: awb stats bus overflow\n");
-
-	if (errStatus & VFE32_IMASK_STATS_RS_BUS_OVFL)
-		pr_err("vfe32_irq: rs stats bus overflow\n");
-
-	if (errStatus & VFE32_IMASK_STATS_CS_BUS_OVFL)
-		pr_err("vfe32_irq: cs stats bus overflow\n");
-
-	if (errStatus & VFE32_IMASK_STATS_IHIST_BUS_OVFL)
-		pr_err("vfe32_irq: ihist stats bus overflow\n");
-
-	if (errStatus & VFE32_IMASK_STATS_SKIN_BHIST_BUS_OVFL)
-		pr_err("vfe32_irq: skin/bhist stats bus overflow\n");
-}
-
-static void vfe32_process_common_error_irq(
-	struct axi_ctrl_t *axi_ctrl, uint32_t errStatus)
-{
-
-	if (errStatus & VFE32_IMASK_IMG_MAST_0_BUS_OVFL)
-		pr_err("vfe32_irq: image master 0 bus overflow\n");
-
-	if (errStatus & VFE32_IMASK_IMG_MAST_1_BUS_OVFL)
-		pr_err("vfe32_irq: image master 1 bus overflow\n");
-
-	if (errStatus & VFE32_IMASK_IMG_MAST_2_BUS_OVFL)
-		pr_err("vfe32_irq: image master 2 bus overflow\n");
-
-	if (errStatus & VFE32_IMASK_IMG_MAST_3_BUS_OVFL)
-		pr_err("vfe32_irq: image master 3 bus overflow\n");
-
-	if (errStatus & VFE32_IMASK_IMG_MAST_4_BUS_OVFL)
-		pr_err("vfe32_irq: image master 4 bus overflow\n");
-
-	if (errStatus & VFE32_IMASK_IMG_MAST_5_BUS_OVFL)
-		pr_err("vfe32_irq: image master 5 bus overflow\n");
-
-	if (errStatus & VFE32_IMASK_IMG_MAST_6_BUS_OVFL)
-		pr_err("vfe32_irq: image master 6 bus overflow\n");
-
-	if (errStatus & VFE32_IMASK_AXI_ERROR)
-		pr_err("vfe32_irq: axi error\n");
-}
-
-
-static void vfe_send_outmsg(
-	struct axi_ctrl_t *axi_ctrl, uint8_t msgid,
-	uint32_t ch0_paddr, uint32_t ch1_paddr,
-	uint32_t ch2_paddr, uint32_t inst_handle)
-{
-	struct isp_msg_output msg;
-
-	msg.output_id = msgid;
-	msg.buf.inst_handle = inst_handle;
-	msg.buf.ch_paddr[0]	= ch0_paddr;
-	msg.buf.ch_paddr[1]	= ch1_paddr;
-	msg.buf.ch_paddr[2]	= ch2_paddr;
-	switch (msgid) {
-	case MSG_ID_OUTPUT_TERTIARY1:
-		msg.frameCounter = axi_ctrl->share_ctrl->rdi0FrameId;
-		break;
-	case MSG_ID_OUTPUT_TERTIARY2:
-		msg.frameCounter = axi_ctrl->share_ctrl->rdi1FrameId;
-		break;
-	default:
-		msg.frameCounter = axi_ctrl->share_ctrl->vfeFrameId;
-		break;
-	}
-
-	v4l2_subdev_notify(&axi_ctrl->subdev,
-			NOTIFY_VFE_MSG_OUT,
-			&msg);
-	return;
-}
-
-static void vfe32_process_output_path_irq_0(
-	struct axi_ctrl_t *axi_ctrl)
-{
-	uint32_t ping_pong;
-	uint32_t ch0_paddr, ch1_paddr, ch2_paddr;
-	uint8_t out_bool = 0;
-	struct msm_free_buf *free_buf = NULL;
-	free_buf = vfe32_check_free_buffer(VFE_MSG_OUTPUT_IRQ,
-		VFE_MSG_OUTPUT_PRIMARY, axi_ctrl);
-
-	/* we render frames in the following conditions:
-	1. Continuous mode and the free buffer is avaialable.
-	2. In snapshot shot mode, free buffer is not always available.
-	when pending snapshot count is <=1,  then no need to use
-	free buffer.
-	*/
-	out_bool = (
-		(axi_ctrl->share_ctrl->operation_mode &
-			VFE_OUTPUTS_THUMB_AND_MAIN ||
-		axi_ctrl->share_ctrl->operation_mode &
-			VFE_OUTPUTS_MAIN_AND_THUMB ||
-		axi_ctrl->share_ctrl->operation_mode &
-			VFE_OUTPUTS_THUMB_AND_JPEG ||
-		axi_ctrl->share_ctrl->operation_mode &
-			VFE_OUTPUTS_JPEG_AND_THUMB ||
-		axi_ctrl->share_ctrl->operation_mode &
-			VFE_OUTPUTS_RAW ||
-		axi_ctrl->share_ctrl->liveshot_state ==
-			VFE_STATE_STARTED ||
-		axi_ctrl->share_ctrl->liveshot_state ==
-			VFE_STATE_STOP_REQUESTED ||
-		axi_ctrl->share_ctrl->liveshot_state ==
-			VFE_STATE_STOPPED) &&
-		(axi_ctrl->share_ctrl->vfe_capture_count <= 1)) ||
-			free_buf;
-
-	if (out_bool) {
-		ping_pong = msm_camera_io_r(axi_ctrl->share_ctrl->vfebase +
-			VFE_BUS_PING_PONG_STATUS);
-
-		/* Channel 0*/
-		ch0_paddr = vfe32_get_ch_addr(
-			ping_pong, axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out0.ch0);
-		/* Channel 1*/
-		ch1_paddr = vfe32_get_ch_addr(
-			ping_pong, axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out0.ch1);
-		/* Channel 2*/
-		ch2_paddr = vfe32_get_ch_addr(
-			ping_pong, axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out0.ch2);
-
-		CDBG("output path 0, ch0 = 0x%x, ch1 = 0x%x, ch2 = 0x%x\n",
-			ch0_paddr, ch1_paddr, ch2_paddr);
-		if (free_buf) {
-			/* Y channel */
-			vfe32_put_ch_addr(ping_pong,
-			axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out0.ch0,
-			free_buf->ch_paddr[0]);
-			/* Chroma channel */
-			vfe32_put_ch_addr(ping_pong,
-			axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out0.ch1,
-			free_buf->ch_paddr[1]);
-			if (free_buf->num_planes > 2)
-				vfe32_put_ch_addr(ping_pong,
-					axi_ctrl->share_ctrl->vfebase,
-					axi_ctrl->share_ctrl->outpath.out0.ch2,
-					free_buf->ch_paddr[2]);
-		}
-		if (axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_THUMB_AND_MAIN ||
-			axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_MAIN_AND_THUMB ||
-			axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_THUMB_AND_JPEG ||
-			axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_JPEG_AND_THUMB ||
-			axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_RAW ||
-			axi_ctrl->share_ctrl->liveshot_state ==
-				VFE_STATE_STOPPED)
-			axi_ctrl->share_ctrl->outpath.out0.capture_cnt--;
-
-		vfe_send_outmsg(axi_ctrl,
-			MSG_ID_OUTPUT_PRIMARY, ch0_paddr,
-			ch1_paddr, ch2_paddr,
-			axi_ctrl->share_ctrl->outpath.out0.inst_handle);
-
-	} else {
-		axi_ctrl->share_ctrl->outpath.out0.frame_drop_cnt++;
-		CDBG("path_irq_0 - no free buffer!\n");
-	}
-}
-
-static void vfe32_process_output_path_irq_1(
-	struct axi_ctrl_t *axi_ctrl)
-{
-	uint32_t ping_pong;
-	uint32_t ch0_paddr, ch1_paddr, ch2_paddr;
-	/* this must be snapshot main image output. */
-	uint8_t out_bool = 0;
-	struct msm_free_buf *free_buf = NULL;
-
-	free_buf = vfe32_check_free_buffer(VFE_MSG_OUTPUT_IRQ,
-		VFE_MSG_OUTPUT_SECONDARY, axi_ctrl);
-	out_bool = ((axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_THUMB_AND_MAIN ||
-			axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_MAIN_AND_THUMB ||
-			axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_RAW ||
-			axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_JPEG_AND_THUMB) &&
-			(axi_ctrl->share_ctrl->vfe_capture_count <= 1)) ||
-				free_buf;
-
-	if (out_bool) {
-		ping_pong = msm_camera_io_r(axi_ctrl->share_ctrl->vfebase +
-			VFE_BUS_PING_PONG_STATUS);
-
-		/* Y channel */
-		ch0_paddr = vfe32_get_ch_addr(ping_pong,
-			axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out1.ch0);
-		/* Chroma channel */
-		ch1_paddr = vfe32_get_ch_addr(ping_pong,
-			axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out1.ch1);
-		ch2_paddr = vfe32_get_ch_addr(ping_pong,
-			axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out1.ch2);
-
-		CDBG("%s ch0 = 0x%x, ch1 = 0x%x, ch2 = 0x%x\n",
-			__func__, ch0_paddr, ch1_paddr, ch2_paddr);
-		if (free_buf) {
-			/* Y channel */
-			vfe32_put_ch_addr(ping_pong,
-			axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out1.ch0,
-			free_buf->ch_paddr[0]);
-			/* Chroma channel */
-			vfe32_put_ch_addr(ping_pong,
-			axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out1.ch1,
-			free_buf->ch_paddr[1]);
-			if (free_buf->num_planes > 2)
-				vfe32_put_ch_addr(ping_pong,
-					axi_ctrl->share_ctrl->vfebase,
-					axi_ctrl->share_ctrl->outpath.out1.ch2,
-					free_buf->ch_paddr[2]);
-		}
-		if (axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_THUMB_AND_MAIN ||
-			axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_MAIN_AND_THUMB ||
-			axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_RAW ||
-			axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_JPEG_AND_THUMB)
-			axi_ctrl->share_ctrl->outpath.out1.capture_cnt--;
-
-		vfe_send_outmsg(axi_ctrl,
-			MSG_ID_OUTPUT_SECONDARY, ch0_paddr,
-			ch1_paddr, ch2_paddr,
-			axi_ctrl->share_ctrl->outpath.out1.inst_handle);
-
-	} else {
-		axi_ctrl->share_ctrl->outpath.out1.frame_drop_cnt++;
-		CDBG("path_irq_1 - no free buffer!\n");
-	}
-}
-
-static void vfe32_process_output_path_irq_rdi0(
-			struct axi_ctrl_t *axi_ctrl)
-{
-	uint32_t ping_pong;
-	uint32_t ch0_paddr = 0;
-	/* this must be rdi image output. */
-	struct msm_free_buf *free_buf = NULL;
-	/*RDI0*/
-	CDBG("rdi0 out irq\n");
-	if (axi_ctrl->share_ctrl->operation_mode & VFE_OUTPUTS_RDI0) {
-		free_buf = vfe32_check_free_buffer(VFE_MSG_OUTPUT_IRQ,
-			VFE_MSG_OUTPUT_TERTIARY1, axi_ctrl);
-		if (axi_ctrl->share_ctrl->outpath.out2.capture_cnt > 0 ||
-							free_buf) {
-			ping_pong = msm_camera_io_r(axi_ctrl->
-				share_ctrl->vfebase +
-				VFE_BUS_PING_PONG_STATUS);
-
-			/* Y only channel */
-			ch0_paddr = vfe32_get_ch_addr(ping_pong,
-				axi_ctrl->share_ctrl->vfebase,
-				axi_ctrl->share_ctrl->outpath.out2.ch0);
-
-			pr_debug("%s ch0 = 0x%x\n",
-				__func__, ch0_paddr);
-
-			if (free_buf)
-				vfe32_put_ch_addr(ping_pong,
-					axi_ctrl->share_ctrl->vfebase,
-					axi_ctrl->share_ctrl->outpath.out2.ch0,
-					free_buf->ch_paddr[0]);
-			if (axi_ctrl->share_ctrl->outpath.out2.capture_cnt == 1)
-				axi_ctrl->share_ctrl->
-					outpath.out2.capture_cnt = 0;
-
-			vfe_send_outmsg(axi_ctrl,
-				MSG_ID_OUTPUT_TERTIARY1, ch0_paddr,
-				0, 0,
-				axi_ctrl->share_ctrl->outpath.out2.inst_handle);
-
-		} else {
-			axi_ctrl->share_ctrl->outpath.out2.frame_drop_cnt++;
-			pr_err("path_irq_2 irq - no free buffer for rdi0!\n");
-		}
-	}
-}
-
-static void vfe32_process_output_path_irq_rdi1(
-	struct axi_ctrl_t *axi_ctrl)
-{
-	uint32_t ping_pong;
-	uint32_t ch0_paddr = 0;
-	/* this must be rdi image output. */
-	struct msm_free_buf *free_buf = NULL;
-	/*RDI1*/
-	if (axi_ctrl->share_ctrl->operation_mode & VFE_OUTPUTS_RDI1) {
-		free_buf = vfe32_check_free_buffer(VFE_MSG_OUTPUT_IRQ,
-			VFE_MSG_OUTPUT_TERTIARY2, axi_ctrl);
-		if (axi_ctrl->share_ctrl->outpath.out3.capture_cnt > 0 ||
-							free_buf) {
-			ping_pong = msm_camera_io_r(axi_ctrl->
-				share_ctrl->vfebase +
-				VFE_BUS_PING_PONG_STATUS);
-
-			/* Y channel */
-			ch0_paddr = vfe32_get_ch_addr(ping_pong,
-				axi_ctrl->share_ctrl->vfebase,
-				axi_ctrl->share_ctrl->outpath.out3.ch0);
-			pr_debug("%s ch0 = 0x%x\n",
-				__func__, ch0_paddr);
-
-			if (free_buf)
-				vfe32_put_ch_addr(ping_pong,
-					axi_ctrl->share_ctrl->vfebase,
-					axi_ctrl->share_ctrl->outpath.out3.ch0,
-					free_buf->ch_paddr[0]);
-			if (axi_ctrl->share_ctrl->
-					outpath.out3.capture_cnt == 1)
-				axi_ctrl->share_ctrl->
-				outpath.out3.capture_cnt = 0;
-
-			vfe_send_outmsg(axi_ctrl,
-				MSG_ID_OUTPUT_TERTIARY2, ch0_paddr,
-				0, 0,
-				axi_ctrl->share_ctrl->outpath.out3.inst_handle);
-		} else {
-			axi_ctrl->share_ctrl->outpath.out3.frame_drop_cnt++;
-			pr_err("path_irq irq - no free buffer for rdi1!\n");
-		}
-	}
-}
-
-static uint32_t  vfe32_process_stats_irq_common(
-	struct vfe32_ctrl_type *vfe32_ctrl,
-	uint32_t statsNum, uint32_t newAddr)
-{
-	uint32_t pingpongStatus;
-	uint32_t returnAddr;
-	uint32_t pingpongAddr;
-
-	/* must be 0=ping, 1=pong */
-	pingpongStatus =
-		((msm_camera_io_r(vfe32_ctrl->share_ctrl->vfebase +
-		VFE_BUS_PING_PONG_STATUS))
-	& ((uint32_t)(1<<(statsNum + 7)))) >> (statsNum + 7);
-	/* stats bits starts at 7 */
-	CDBG("statsNum %d, pingpongStatus %d\n", statsNum, pingpongStatus);
-	pingpongAddr =
-		((uint32_t)(vfe32_ctrl->share_ctrl->vfebase +
-				VFE_BUS_STATS_PING_PONG_BASE)) +
-				(3*statsNum)*4 + (1-pingpongStatus)*4;
-	returnAddr = msm_camera_io_r((uint32_t *)pingpongAddr);
-	msm_camera_io_w(newAddr, (uint32_t *)pingpongAddr);
-	return returnAddr;
-}
-
-static void vfe_send_stats_msg(
-	struct vfe32_ctrl_type *vfe32_ctrl,
-	uint32_t bufAddress, uint32_t statsNum)
-{
-	int rc = 0;
-	void *vaddr = NULL;
-	/* fill message with right content. */
-	/* @todo This is causing issues, need further investigate */
-	/* spin_lock_irqsave(&ctrl->state_lock, flags); */
-	struct isp_msg_stats msgStats;
-	uint32_t stats_type;
-	msgStats.frameCounter = vfe32_ctrl->share_ctrl->vfeFrameId;
-	if (vfe32_ctrl->simultaneous_sof_stat)
-		msgStats.frameCounter--;
-	msgStats.buffer = bufAddress;
-	switch (statsNum) {
-	case statsAeNum:{
-		msgStats.id =
-			(!vfe32_use_bayer_stats(vfe32_ctrl)) ? MSG_ID_STATS_AEC
-				: MSG_ID_STATS_BG;
-		stats_type =
-			(!vfe32_use_bayer_stats(vfe32_ctrl)) ?
-				MSM_STATS_TYPE_AEC : MSM_STATS_TYPE_BG;
-		rc = vfe32_ctrl->stats_ops.dispatch(
-				vfe32_ctrl->stats_ops.stats_ctrl,
-				stats_type, bufAddress,
-				&msgStats.buf_idx, &vaddr, &msgStats.fd,
-				vfe32_ctrl->stats_ops.client);
-		}
-		break;
-	case statsAfNum:{
-		msgStats.id =
-			(!vfe32_use_bayer_stats(vfe32_ctrl)) ? MSG_ID_STATS_AF
-				: MSG_ID_STATS_BF;
-		stats_type =
-			(!vfe32_use_bayer_stats(vfe32_ctrl)) ? MSM_STATS_TYPE_AF
-				: MSM_STATS_TYPE_BF;
-		rc = vfe32_ctrl->stats_ops.dispatch(
-				vfe32_ctrl->stats_ops.stats_ctrl,
-				stats_type, bufAddress,
-				&msgStats.buf_idx, &vaddr, &msgStats.fd,
-				vfe32_ctrl->stats_ops.client);
-		}
-		break;
-	case statsAwbNum: {
-		msgStats.id = MSG_ID_STATS_AWB;
-		rc = vfe32_ctrl->stats_ops.dispatch(
-				vfe32_ctrl->stats_ops.stats_ctrl,
-				MSM_STATS_TYPE_AWB, bufAddress,
-				&msgStats.buf_idx, &vaddr, &msgStats.fd,
-				vfe32_ctrl->stats_ops.client);
-		}
-		break;
-
-	case statsIhistNum: {
-		msgStats.id = MSG_ID_STATS_IHIST;
-		rc = vfe32_ctrl->stats_ops.dispatch(
-				vfe32_ctrl->stats_ops.stats_ctrl,
-				MSM_STATS_TYPE_IHIST, bufAddress,
-				&msgStats.buf_idx, &vaddr, &msgStats.fd,
-				vfe32_ctrl->stats_ops.client);
-		}
-		break;
-	case statsRsNum: {
-		msgStats.id = MSG_ID_STATS_RS;
-		rc = vfe32_ctrl->stats_ops.dispatch(
-				vfe32_ctrl->stats_ops.stats_ctrl,
-				MSM_STATS_TYPE_RS, bufAddress,
-				&msgStats.buf_idx, &vaddr, &msgStats.fd,
-				vfe32_ctrl->stats_ops.client);
-		}
-		break;
-	case statsCsNum: {
-		msgStats.id = MSG_ID_STATS_CS;
-		rc = vfe32_ctrl->stats_ops.dispatch(
-				vfe32_ctrl->stats_ops.stats_ctrl,
-				MSM_STATS_TYPE_CS, bufAddress,
-				&msgStats.buf_idx, &vaddr, &msgStats.fd,
-				vfe32_ctrl->stats_ops.client);
-		}
-		break;
-	case statsSkinNum: {
-		msgStats.id = MSG_ID_STATS_BHIST;
-		rc = vfe32_ctrl->stats_ops.dispatch(
-				vfe32_ctrl->stats_ops.stats_ctrl,
-				MSM_STATS_TYPE_BHIST, bufAddress,
-				&msgStats.buf_idx, &vaddr, &msgStats.fd,
-				vfe32_ctrl->stats_ops.client);
-		}
-		break;
-
-	default:
-		goto stats_done;
-	}
-	if (rc == 0) {
-		msgStats.buffer = (uint32_t)vaddr;
-		v4l2_subdev_notify(&vfe32_ctrl->subdev,
-			NOTIFY_VFE_MSG_STATS,
-			&msgStats);
-	} else {
-		pr_err("%s: paddr to idx mapping error, stats_id = %d, paddr = 0x%d",
-			 __func__, msgStats.id, msgStats.buffer);
-	}
-stats_done:
-	/* spin_unlock_irqrestore(&ctrl->state_lock, flags); */
-	return;
-}
-
-static void vfe_send_comp_stats_msg(
-	struct vfe32_ctrl_type *vfe32_ctrl, uint32_t status_bits)
-{
-	struct msm_stats_buf msgStats;
-	uint32_t temp;
-
-	msgStats.frame_id = vfe32_ctrl->share_ctrl->vfeFrameId;
-	if (vfe32_ctrl->simultaneous_sof_stat)
-		msgStats.frame_id--;
-
-	msgStats.status_bits = status_bits;
-
-	msgStats.aec.buff = vfe32_ctrl->aecbgStatsControl.bufToRender;
-	msgStats.awb.buff = vfe32_ctrl->awbStatsControl.bufToRender;
-	msgStats.af.buff = vfe32_ctrl->afbfStatsControl.bufToRender;
-
-	msgStats.ihist.buff = vfe32_ctrl->ihistStatsControl.bufToRender;
-	msgStats.rs.buff = vfe32_ctrl->rsStatsControl.bufToRender;
-	msgStats.cs.buff = vfe32_ctrl->csStatsControl.bufToRender;
-
-	temp = msm_camera_io_r(
-		vfe32_ctrl->share_ctrl->vfebase + VFE_STATS_AWB_SGW_CFG);
-	msgStats.awb_ymin = (0xFF00 & temp) >> 8;
-
-	v4l2_subdev_notify(&vfe32_ctrl->subdev,
-				NOTIFY_VFE_MSG_COMP_STATS,
-				&msgStats);
-}
-
-static void vfe32_process_stats_ae_bg_irq(struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	unsigned long flags;
-	uint32_t addr;
-	uint32_t stats_type;
-	stats_type =
-		(!vfe32_use_bayer_stats(vfe32_ctrl)) ? MSM_STATS_TYPE_AEC
-			: MSM_STATS_TYPE_BG;
-	spin_lock_irqsave(&vfe32_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl, stats_type);
-	spin_unlock_irqrestore(&vfe32_ctrl->stats_bufq_lock, flags);
-	if (addr) {
-		vfe32_ctrl->aecbgStatsControl.bufToRender =
-			vfe32_process_stats_irq_common(vfe32_ctrl, statsAeNum,
-			addr);
-
-		vfe_send_stats_msg(vfe32_ctrl,
-			vfe32_ctrl->aecbgStatsControl.bufToRender, statsAeNum);
-	} else{
-		vfe32_ctrl->aecbgStatsControl.droppedStatsFrameCount++;
-		CDBG("%s: droppedStatsFrameCount = %d", __func__,
-			vfe32_ctrl->aecbgStatsControl.droppedStatsFrameCount);
-	}
-}
-
-static void vfe32_process_stats_awb_irq(struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	unsigned long flags;
-	uint32_t addr;
-	spin_lock_irqsave(&vfe32_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl, MSM_STATS_TYPE_AWB);
-	spin_unlock_irqrestore(&vfe32_ctrl->stats_bufq_lock, flags);
-	if (addr) {
-		vfe32_ctrl->awbStatsControl.bufToRender =
-			vfe32_process_stats_irq_common(vfe32_ctrl, statsAwbNum,
-			addr);
-
-		vfe_send_stats_msg(vfe32_ctrl,
-			vfe32_ctrl->awbStatsControl.bufToRender, statsAwbNum);
-	} else{
-		vfe32_ctrl->awbStatsControl.droppedStatsFrameCount++;
-		CDBG("%s: droppedStatsFrameCount = %d", __func__,
-			vfe32_ctrl->awbStatsControl.droppedStatsFrameCount);
-	}
-}
-
-static void vfe32_process_stats_af_bf_irq(struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	unsigned long flags;
-	uint32_t addr;
-	uint32_t stats_type;
-	stats_type =
-		(!vfe32_use_bayer_stats(vfe32_ctrl)) ? MSM_STATS_TYPE_AF
-			: MSM_STATS_TYPE_BF;
-	spin_lock_irqsave(&vfe32_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl, stats_type);
-	spin_unlock_irqrestore(&vfe32_ctrl->stats_bufq_lock, flags);
-	if (addr) {
-		vfe32_ctrl->afbfStatsControl.bufToRender =
-			vfe32_process_stats_irq_common(vfe32_ctrl, statsAfNum,
-			addr);
-
-		vfe_send_stats_msg(vfe32_ctrl,
-			vfe32_ctrl->afbfStatsControl.bufToRender, statsAfNum);
-	} else{
-		vfe32_ctrl->afbfStatsControl.droppedStatsFrameCount++;
-		CDBG("%s: droppedStatsFrameCount = %d", __func__,
-			vfe32_ctrl->afbfStatsControl.droppedStatsFrameCount);
-	}
-}
-
-static void vfe32_process_stats_bhist_irq(struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	unsigned long flags;
-	uint32_t addr;
-	spin_lock_irqsave(&vfe32_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl, MSM_STATS_TYPE_BHIST);
-	spin_unlock_irqrestore(&vfe32_ctrl->stats_bufq_lock, flags);
-	if (addr) {
-		vfe32_ctrl->bhistStatsControl.bufToRender =
-			vfe32_process_stats_irq_common(vfe32_ctrl,
-				statsSkinNum, addr);
-
-		vfe_send_stats_msg(vfe32_ctrl,
-			vfe32_ctrl->bhistStatsControl.bufToRender,
-			statsSkinNum);
-	} else{
-		vfe32_ctrl->bhistStatsControl.droppedStatsFrameCount++;
-		CDBG("%s: droppedStatsFrameCount = %d", __func__,
-			vfe32_ctrl->bhistStatsControl.droppedStatsFrameCount);
-	}
-}
-
-static void vfe32_process_stats_ihist_irq(struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	unsigned long flags;
-	uint32_t addr;
-	spin_lock_irqsave(&vfe32_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl, MSM_STATS_TYPE_IHIST);
-	spin_unlock_irqrestore(&vfe32_ctrl->stats_bufq_lock, flags);
-	if (addr) {
-		vfe32_ctrl->ihistStatsControl.bufToRender =
-			vfe32_process_stats_irq_common(
-			vfe32_ctrl, statsIhistNum, addr);
-
-		vfe_send_stats_msg(vfe32_ctrl,
-			vfe32_ctrl->ihistStatsControl.bufToRender,
-			statsIhistNum);
-	} else {
-		vfe32_ctrl->ihistStatsControl.droppedStatsFrameCount++;
-		CDBG("%s: droppedStatsFrameCount = %d", __func__,
-			vfe32_ctrl->ihistStatsControl.droppedStatsFrameCount);
-	}
-}
-
-static void vfe32_process_stats_rs_irq(struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	unsigned long flags;
-	uint32_t addr;
-	spin_lock_irqsave(&vfe32_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl, MSM_STATS_TYPE_RS);
-	spin_unlock_irqrestore(&vfe32_ctrl->stats_bufq_lock, flags);
-	if (addr) {
-		vfe32_ctrl->rsStatsControl.bufToRender =
-			vfe32_process_stats_irq_common(vfe32_ctrl, statsRsNum,
-			addr);
-
-		vfe_send_stats_msg(vfe32_ctrl,
-			vfe32_ctrl->rsStatsControl.bufToRender, statsRsNum);
-	} else {
-		vfe32_ctrl->rsStatsControl.droppedStatsFrameCount++;
-		CDBG("%s: droppedStatsFrameCount = %d", __func__,
-			vfe32_ctrl->rsStatsControl.droppedStatsFrameCount);
-	}
-}
-
-static void vfe32_process_stats_cs_irq(struct vfe32_ctrl_type *vfe32_ctrl)
-{
-	unsigned long flags;
-	uint32_t addr;
-	spin_lock_irqsave(&vfe32_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl, MSM_STATS_TYPE_CS);
-	spin_unlock_irqrestore(&vfe32_ctrl->stats_bufq_lock, flags);
-	if (addr) {
-		vfe32_ctrl->csStatsControl.bufToRender =
-			vfe32_process_stats_irq_common(vfe32_ctrl, statsCsNum,
-			addr);
-
-			vfe_send_stats_msg(vfe32_ctrl,
-				vfe32_ctrl->csStatsControl.bufToRender,
-				statsCsNum);
-	} else {
-		vfe32_ctrl->csStatsControl.droppedStatsFrameCount++;
-		CDBG("%s: droppedStatsFrameCount = %d", __func__,
-			vfe32_ctrl->csStatsControl.droppedStatsFrameCount);
-	}
-}
-
-static void vfe32_process_stats(struct vfe32_ctrl_type *vfe32_ctrl,
-	uint32_t status_bits)
-{
-	unsigned long flags;
-	int32_t process_stats = false;
-	uint32_t addr;
-	uint32_t stats_type;
-
-	CDBG("%s, stats = 0x%x\n", __func__, status_bits);
-	spin_lock_irqsave(&vfe32_ctrl->stats_bufq_lock, flags);
-	stats_type =
-		(!vfe32_use_bayer_stats(vfe32_ctrl)) ? MSM_STATS_TYPE_AEC
-			: MSM_STATS_TYPE_BG;
-
-	if (status_bits & VFE_IRQ_STATUS0_STATS_AEC_BG) {
-		addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl,
-				stats_type);
-		if (addr) {
-			vfe32_ctrl->aecbgStatsControl.bufToRender =
-				vfe32_process_stats_irq_common(
-				vfe32_ctrl, statsAeNum,	addr);
-			process_stats = true;
-		} else{
-			vfe32_ctrl->aecbgStatsControl.bufToRender = 0;
-			vfe32_ctrl->aecbgStatsControl.droppedStatsFrameCount++;
-		}
-	} else {
-		vfe32_ctrl->aecbgStatsControl.bufToRender = 0;
-	}
-
-	if (status_bits & VFE_IRQ_STATUS0_STATS_AWB) {
-		addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl,
-			MSM_STATS_TYPE_AWB);
-		if (addr) {
-			vfe32_ctrl->awbStatsControl.bufToRender =
-				vfe32_process_stats_irq_common(
-				vfe32_ctrl, statsAwbNum,
-				addr);
-			process_stats = true;
-		} else{
-			vfe32_ctrl->awbStatsControl.droppedStatsFrameCount++;
-			vfe32_ctrl->awbStatsControl.bufToRender = 0;
-		}
-	} else {
-		vfe32_ctrl->awbStatsControl.bufToRender = 0;
-	}
-
-	stats_type =
-		(!vfe32_use_bayer_stats(vfe32_ctrl)) ? MSM_STATS_TYPE_AF
-			: MSM_STATS_TYPE_BF;
-	if (status_bits & VFE_IRQ_STATUS0_STATS_AF_BF) {
-		addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl,
-					stats_type);
-		if (addr) {
-			vfe32_ctrl->afbfStatsControl.bufToRender =
-				vfe32_process_stats_irq_common(
-				vfe32_ctrl, statsAfNum,
-				addr);
-			process_stats = true;
-		} else {
-			vfe32_ctrl->afbfStatsControl.bufToRender = 0;
-			vfe32_ctrl->afbfStatsControl.droppedStatsFrameCount++;
-		}
-	} else {
-		vfe32_ctrl->afbfStatsControl.bufToRender = 0;
-	}
-
-	if (status_bits & VFE_IRQ_STATUS0_STATS_IHIST) {
-		addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl,
-					MSM_STATS_TYPE_IHIST);
-		if (addr) {
-			vfe32_ctrl->ihistStatsControl.bufToRender =
-				vfe32_process_stats_irq_common(
-				vfe32_ctrl, statsIhistNum,
-				addr);
-			process_stats = true;
-		} else {
-			vfe32_ctrl->ihistStatsControl.droppedStatsFrameCount++;
-			vfe32_ctrl->ihistStatsControl.bufToRender = 0;
-		}
-	} else {
-		vfe32_ctrl->ihistStatsControl.bufToRender = 0;
-	}
-
-	if (status_bits & VFE_IRQ_STATUS0_STATS_RS) {
-		addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl,
-					MSM_STATS_TYPE_RS);
-		if (addr) {
-			vfe32_ctrl->rsStatsControl.bufToRender =
-				vfe32_process_stats_irq_common(
-				vfe32_ctrl, statsRsNum,
-				addr);
-			process_stats = true;
-		} else {
-			vfe32_ctrl->rsStatsControl.droppedStatsFrameCount++;
-			vfe32_ctrl->rsStatsControl.bufToRender = 0;
-		}
-	} else {
-		vfe32_ctrl->rsStatsControl.bufToRender = 0;
-	}
-
-	if (status_bits & VFE_IRQ_STATUS0_STATS_CS) {
-		addr = (uint32_t)vfe32_stats_dqbuf(vfe32_ctrl,
-					MSM_STATS_TYPE_CS);
-		if (addr) {
-			vfe32_ctrl->csStatsControl.bufToRender =
-				vfe32_process_stats_irq_common(
-				vfe32_ctrl, statsCsNum,
-				addr);
-			process_stats = true;
-		} else {
-			vfe32_ctrl->csStatsControl.droppedStatsFrameCount++;
-			vfe32_ctrl->csStatsControl.bufToRender = 0;
-		}
-	} else {
-		vfe32_ctrl->csStatsControl.bufToRender = 0;
-	}
-	spin_unlock_irqrestore(&vfe32_ctrl->stats_bufq_lock, flags);
-	if (process_stats)
-		vfe_send_comp_stats_msg(vfe32_ctrl, status_bits);
-
-	return;
-}
-
-static void vfe32_process_stats_irq(
-	struct vfe32_ctrl_type *vfe32_ctrl, uint32_t irqstatus)
-{
-	uint32_t status_bits = VFE_COM_STATUS & irqstatus;
-	if ((vfe32_ctrl->hfr_mode != HFR_MODE_OFF) &&
-		(vfe32_ctrl->share_ctrl->vfeFrameId %
-		 vfe32_ctrl->hfr_mode != 0)) {
-		CDBG("Skip the stats when HFR enabled\n");
-		return;
-	}
-
-	vfe32_process_stats(vfe32_ctrl, status_bits);
-	return;
-}
-
-static void vfe32_process_irq(
-	struct vfe32_ctrl_type *vfe32_ctrl, uint32_t irqstatus)
-{
-	if (irqstatus &
-		VFE_IRQ_STATUS0_STATS_COMPOSIT_MASK) {
-		vfe32_process_stats_irq(vfe32_ctrl, irqstatus);
-		return;
-	}
-
-	switch (irqstatus) {
-	case VFE_IRQ_STATUS0_CAMIF_SOF_MASK:
-		CDBG("irq	camifSofIrq\n");
-		vfe32_process_camif_sof_irq(vfe32_ctrl);
-		break;
-	case VFE_IRQ_STATUS0_REG_UPDATE_MASK:
-		CDBG("irq	regUpdateIrq\n");
-		vfe32_process_reg_update_irq(vfe32_ctrl);
-		break;
-	case VFE_IRQ_STATUS1_RDI0_REG_UPDATE:
-		CDBG("irq	rdi0 regUpdateIrq\n");
-		vfe32_process_rdi0_reg_update_irq(vfe32_ctrl);
-		break;
-	case VFE_IRQ_STATUS1_RDI1_REG_UPDATE:
-		CDBG("irq	rdi1 regUpdateIrq\n");
-		vfe32_process_rdi1_reg_update_irq(vfe32_ctrl);
-		break;
-	case VFE_IMASK_WHILE_STOPPING_1:
-		CDBG("irq	resetAckIrq\n");
-		vfe32_process_reset_irq(vfe32_ctrl);
-		break;
-	case VFE_IRQ_STATUS0_STATS_AEC_BG:
-		CDBG("Stats AEC irq occured.\n");
-		vfe32_process_stats_ae_bg_irq(vfe32_ctrl);
-		break;
-	case VFE_IRQ_STATUS0_STATS_AWB:
-		CDBG("Stats AWB irq occured.\n");
-		vfe32_process_stats_awb_irq(vfe32_ctrl);
-		break;
-	case VFE_IRQ_STATUS0_STATS_AF_BF:
-		CDBG("Stats AF irq occured.\n");
-		vfe32_process_stats_af_bf_irq(vfe32_ctrl);
-		break;
-	case VFE_IRQ_STATUS0_STATS_SK_BHIST:
-		CDBG("Stats BHIST irq occured.\n");
-		vfe32_process_stats_bhist_irq(vfe32_ctrl);
-		break;
-	case VFE_IRQ_STATUS0_STATS_IHIST:
-		CDBG("Stats IHIST irq occured.\n");
-		vfe32_process_stats_ihist_irq(vfe32_ctrl);
-		break;
-	case VFE_IRQ_STATUS0_STATS_RS:
-		CDBG("Stats RS irq occured.\n");
-		vfe32_process_stats_rs_irq(vfe32_ctrl);
-		break;
-	case VFE_IRQ_STATUS0_STATS_CS:
-		CDBG("Stats CS irq occured.\n");
-		vfe32_process_stats_cs_irq(vfe32_ctrl);
-		break;
-	case VFE_IRQ_STATUS0_SYNC_TIMER0:
-		CDBG("SYNC_TIMER 0 irq occured.\n");
-		vfe32_send_isp_msg(&vfe32_ctrl->subdev,
-			vfe32_ctrl->share_ctrl->vfeFrameId,
-			MSG_ID_SYNC_TIMER0_DONE);
-		break;
-	case VFE_IRQ_STATUS0_SYNC_TIMER1:
-		CDBG("SYNC_TIMER 1 irq occured.\n");
-		vfe32_send_isp_msg(&vfe32_ctrl->subdev,
-			vfe32_ctrl->share_ctrl->vfeFrameId,
-			MSG_ID_SYNC_TIMER1_DONE);
-		break;
-	case VFE_IRQ_STATUS0_SYNC_TIMER2:
-		CDBG("SYNC_TIMER 2 irq occured.\n");
-		vfe32_send_isp_msg(&vfe32_ctrl->subdev,
-			vfe32_ctrl->share_ctrl->vfeFrameId,
-			MSG_ID_SYNC_TIMER2_DONE);
-		break;
-	default:
-		pr_err("Invalid IRQ status\n");
-	}
-}
-
-static void axi32_do_tasklet(unsigned long data)
-{
-	unsigned long flags;
-	struct axi_ctrl_t *axi_ctrl = (struct axi_ctrl_t *)data;
-	struct vfe32_ctrl_type *vfe32_ctrl = axi_ctrl->share_ctrl->vfe32_ctrl;
-	struct vfe32_isr_queue_cmd *qcmd = NULL;
-	int stat_interrupt;
-
-	CDBG("=== axi32_do_tasklet start ===\n");
-
-	while (atomic_read(&irq_cnt)) {
-		spin_lock_irqsave(&axi_ctrl->tasklet_lock, flags);
-		qcmd = list_first_entry(&axi_ctrl->tasklet_q,
-			struct vfe32_isr_queue_cmd, list);
-		atomic_sub(1, &irq_cnt);
-
-		if (!qcmd) {
-			spin_unlock_irqrestore(&axi_ctrl->tasklet_lock,
-				flags);
-			return;
-		}
-
-		list_del(&qcmd->list);
-		spin_unlock_irqrestore(&axi_ctrl->tasklet_lock,
-			flags);
-
-		if (axi_ctrl->share_ctrl->stats_comp) {
-			stat_interrupt = (qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_COMPOSIT_MASK);
-		} else {
-			stat_interrupt =
-				(qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_AEC_BG) |
-				(qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_AWB) |
-				(qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_AF_BF) |
-				(qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_IHIST) |
-				(qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_RS) |
-				(qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_CS);
-		}
-		if (qcmd->vfeInterruptStatus0 &
-				VFE_IRQ_STATUS0_CAMIF_SOF_MASK) {
-			if (stat_interrupt)
-				vfe32_ctrl->simultaneous_sof_stat = 1;
-			v4l2_subdev_notify(&vfe32_ctrl->subdev,
-				NOTIFY_VFE_IRQ,
-				(void *)VFE_IRQ_STATUS0_CAMIF_SOF_MASK);
-		}
-
-		/* interrupt to be processed,  *qcmd has the payload.  */
-		if (qcmd->vfeInterruptStatus0 &
-				VFE_IRQ_STATUS0_REG_UPDATE_MASK)
-			v4l2_subdev_notify(&vfe32_ctrl->subdev,
-				NOTIFY_VFE_IRQ,
-				(void *)VFE_IRQ_STATUS0_REG_UPDATE_MASK);
-
-		if (qcmd->vfeInterruptStatus1 &
-				VFE_IRQ_STATUS1_RDI0_REG_UPDATE_MASK)
-			v4l2_subdev_notify(&vfe32_ctrl->subdev,
-				NOTIFY_VFE_IRQ,
-				(void *)VFE_IRQ_STATUS1_RDI0_REG_UPDATE);
-
-		if (qcmd->vfeInterruptStatus1 &
-				VFE_IRQ_STATUS1_RDI1_REG_UPDATE_MASK)
-			v4l2_subdev_notify(&vfe32_ctrl->subdev,
-				NOTIFY_VFE_IRQ,
-				(void *)VFE_IRQ_STATUS1_RDI1_REG_UPDATE);
-
-		if (qcmd->vfeInterruptStatus1 &
-				VFE_IMASK_WHILE_STOPPING_1)
-			v4l2_subdev_notify(&vfe32_ctrl->subdev,
-				NOTIFY_VFE_IRQ,
-				(void *)VFE_IMASK_WHILE_STOPPING_1);
-
-		if (atomic_read(&axi_ctrl->share_ctrl->handle_common_irq)) {
-			if (qcmd->vfeInterruptStatus1 &
-					VFE32_IMASK_COMMON_ERROR_ONLY_1) {
-				pr_err("irq	errorIrq\n");
-				vfe32_process_common_error_irq(
-					axi_ctrl,
-					qcmd->vfeInterruptStatus1 &
-					VFE32_IMASK_COMMON_ERROR_ONLY_1);
-			}
-
-			v4l2_subdev_notify(&axi_ctrl->subdev,
-				NOTIFY_AXI_IRQ,
-				(void *)qcmd->vfeInterruptStatus0);
-		}
-
-		if (atomic_read(&axi_ctrl->share_ctrl->vstate)) {
-			if (qcmd->vfeInterruptStatus1 &
-					VFE32_IMASK_VFE_ERROR_ONLY_1) {
-				pr_err("irq	errorIrq\n");
-				vfe32_process_error_irq(
-					axi_ctrl,
-					qcmd->vfeInterruptStatus1 &
-					VFE32_IMASK_VFE_ERROR_ONLY_1);
-			}
-
-			/* then process stats irq. */
-			if (axi_ctrl->share_ctrl->stats_comp) {
-				/* process stats comb interrupt. */
-				if (qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_COMPOSIT_MASK) {
-					CDBG("Stats composite irq occured.\n");
-					v4l2_subdev_notify(&vfe32_ctrl->subdev,
-					NOTIFY_VFE_IRQ,
-					(void *)qcmd->vfeInterruptStatus0);
-				}
-			} else {
-				/* process individual stats interrupt. */
-				if (qcmd->vfeInterruptStatus0 &
-						VFE_IRQ_STATUS0_STATS_AEC_BG)
-					v4l2_subdev_notify(&vfe32_ctrl->subdev,
-					NOTIFY_VFE_IRQ,
-					(void *)VFE_IRQ_STATUS0_STATS_AEC_BG);
-
-				if (qcmd->vfeInterruptStatus0 &
-						VFE_IRQ_STATUS0_STATS_AWB)
-					v4l2_subdev_notify(&vfe32_ctrl->subdev,
-					NOTIFY_VFE_IRQ,
-					(void *)VFE_IRQ_STATUS0_STATS_AWB);
-
-				if (qcmd->vfeInterruptStatus0 &
-						VFE_IRQ_STATUS0_STATS_AF_BF)
-					v4l2_subdev_notify(&vfe32_ctrl->subdev,
-					NOTIFY_VFE_IRQ,
-					(void *)VFE_IRQ_STATUS0_STATS_AF_BF);
-				if (qcmd->vfeInterruptStatus0 &
-						VFE_IRQ_STATUS0_STATS_SK_BHIST)
-					v4l2_subdev_notify(&vfe32_ctrl->subdev,
-					NOTIFY_VFE_IRQ,
-					(void *)VFE_IRQ_STATUS0_STATS_SK_BHIST);
-
-				if (qcmd->vfeInterruptStatus0 &
-						VFE_IRQ_STATUS0_STATS_IHIST)
-					v4l2_subdev_notify(&vfe32_ctrl->subdev,
-					NOTIFY_VFE_IRQ,
-					(void *)VFE_IRQ_STATUS0_STATS_IHIST);
-
-				if (qcmd->vfeInterruptStatus0 &
-						VFE_IRQ_STATUS0_STATS_RS)
-					v4l2_subdev_notify(&vfe32_ctrl->subdev,
-					NOTIFY_VFE_IRQ,
-					(void *)VFE_IRQ_STATUS0_STATS_RS);
-
-				if (qcmd->vfeInterruptStatus0 &
-						VFE_IRQ_STATUS0_STATS_CS)
-					v4l2_subdev_notify(&vfe32_ctrl->subdev,
-					NOTIFY_VFE_IRQ,
-					(void *)VFE_IRQ_STATUS0_STATS_CS);
-
-				if (qcmd->vfeInterruptStatus0 &
-						VFE_IRQ_STATUS0_SYNC_TIMER0)
-					v4l2_subdev_notify(&vfe32_ctrl->subdev,
-					NOTIFY_VFE_IRQ,
-					(void *)VFE_IRQ_STATUS0_SYNC_TIMER0);
-
-				if (qcmd->vfeInterruptStatus0 &
-						VFE_IRQ_STATUS0_SYNC_TIMER1)
-					v4l2_subdev_notify(&vfe32_ctrl->subdev,
-					NOTIFY_VFE_IRQ,
-					(void *)VFE_IRQ_STATUS0_SYNC_TIMER1);
-
-				if (qcmd->vfeInterruptStatus0 &
-						VFE_IRQ_STATUS0_SYNC_TIMER2)
-					v4l2_subdev_notify(&vfe32_ctrl->subdev,
-					NOTIFY_VFE_IRQ,
-					(void *)VFE_IRQ_STATUS0_SYNC_TIMER2);
-			}
-		}
-		vfe32_ctrl->simultaneous_sof_stat = 0;
-		kfree(qcmd);
-	}
-	CDBG("=== axi32_do_tasklet end ===\n");
-}
-
-static irqreturn_t vfe32_parse_irq(int irq_num, void *data)
-{
-	unsigned long flags;
-	struct vfe32_irq_status irq;
-	struct vfe32_isr_queue_cmd *qcmd;
-	struct axi_ctrl_t *axi_ctrl = data;
-
-	CDBG("vfe_parse_irq\n");
-
-	vfe32_read_irq_status(axi_ctrl, &irq);
-
-	if ((irq.vfeIrqStatus0 == 0) && (irq.vfeIrqStatus1 == 0)) {
-		CDBG("vfe_parse_irq: vfeIrqStatus0 & 1 are both 0!\n");
-		return IRQ_HANDLED;
-	}
-
-	qcmd = kzalloc(sizeof(struct vfe32_isr_queue_cmd),
-		GFP_ATOMIC);
-	if (!qcmd) {
-		pr_err("vfe_parse_irq: qcmd malloc failed!\n");
-		return IRQ_HANDLED;
-	}
-
-	spin_lock_irqsave(&axi_ctrl->share_ctrl->stop_flag_lock, flags);
-	if (axi_ctrl->share_ctrl->stop_ack_pending) {
-		irq.vfeIrqStatus0 &= VFE_IMASK_WHILE_STOPPING_0;
-		irq.vfeIrqStatus1 &= VFE_IMASK_WHILE_STOPPING_1;
-	}
-	spin_unlock_irqrestore(&axi_ctrl->share_ctrl->stop_flag_lock, flags);
-
-	CDBG("vfe_parse_irq: Irq_status0 = 0x%x, Irq_status1 = 0x%x.\n",
-		irq.vfeIrqStatus0, irq.vfeIrqStatus1);
-
-	qcmd->vfeInterruptStatus0 = irq.vfeIrqStatus0;
-	qcmd->vfeInterruptStatus1 = irq.vfeIrqStatus1;
-
-	spin_lock_irqsave(&axi_ctrl->tasklet_lock, flags);
-	list_add_tail(&qcmd->list, &axi_ctrl->tasklet_q);
-
-	atomic_add(1, &irq_cnt);
-	spin_unlock_irqrestore(&axi_ctrl->tasklet_lock, flags);
-	tasklet_schedule(&axi_ctrl->vfe32_tasklet);
-	return IRQ_HANDLED;
-}
-
-int msm_axi_subdev_isr_routine(struct v4l2_subdev *sd,
-	u32 status, bool *handled)
-{
-	struct axi_ctrl_t *axi_ctrl = v4l2_get_subdevdata(sd);
-	irqreturn_t ret;
-	pr_info("%s E ", __func__);
-	ret = vfe32_parse_irq(axi_ctrl->vfeirq->start, axi_ctrl);
-	*handled = TRUE;
-	return 0;
-}
-
-static long vfe_stats_bufq_sub_ioctl(
-	struct vfe32_ctrl_type *vfe_ctrl,
-	struct msm_vfe_cfg_cmd *cmd, void *ion_client, int domain_num)
-{
-	long rc = 0;
-	switch (cmd->cmd_type) {
-	case VFE_CMD_STATS_REQBUF:
-	if (!vfe_ctrl->stats_ops.stats_ctrl) {
-		/* stats_ctrl has not been init yet */
-		rc = msm_stats_buf_ops_init(&vfe_ctrl->stats_ctrl,
-				(struct ion_client *)ion_client,
-				&vfe_ctrl->stats_ops);
-		if (rc < 0) {
-			pr_err("%s: cannot init stats ops", __func__);
-			goto end;
-		}
-		rc = vfe_ctrl->stats_ops.stats_ctrl_init(&vfe_ctrl->stats_ctrl);
-		if (rc < 0) {
-			pr_err("%s: cannot init stats_ctrl ops", __func__);
-			memset(&vfe_ctrl->stats_ops, 0,
-				sizeof(vfe_ctrl->stats_ops));
-			goto end;
-		}
-		if (sizeof(struct msm_stats_reqbuf) != cmd->length) {
-			/* error. the length not match */
-			pr_err("%s: stats reqbuf input size = %d,\n"
-				"struct size = %d, mitch match\n",
-				 __func__, cmd->length,
-				sizeof(struct msm_stats_reqbuf));
-			rc = -EINVAL ;
-			goto end;
-		}
-	}
-	rc = vfe_ctrl->stats_ops.reqbuf(
-			&vfe_ctrl->stats_ctrl,
-			(struct msm_stats_reqbuf *)cmd->value,
-			vfe_ctrl->stats_ops.client);
-	break;
-	case VFE_CMD_STATS_ENQUEUEBUF:
-	if (sizeof(struct msm_stats_buf_info) != cmd->length) {
-		/* error. the length not match */
-		pr_err("%s: stats enqueuebuf input size = %d,\n"
-			"struct size = %d, mitch match\n",
-			 __func__, cmd->length,
-			sizeof(struct msm_stats_buf_info));
-			rc = -EINVAL;
-			goto end;
-	}
-	rc = vfe_ctrl->stats_ops.enqueue_buf(
-			&vfe_ctrl->stats_ctrl,
-			(struct msm_stats_buf_info *)cmd->value,
-			vfe_ctrl->stats_ops.client, domain_num);
-	break;
-	case VFE_CMD_STATS_FLUSH_BUFQ:
-	{
-		struct msm_stats_flush_bufq *flush_req = NULL;
-		flush_req = (struct msm_stats_flush_bufq *)cmd->value;
-		if (sizeof(struct msm_stats_flush_bufq) != cmd->length) {
-			/* error. the length not match */
-			pr_err("%s: stats flush queue input size = %d,\n"
-				"struct size = %d, mitch match\n",
-				__func__, cmd->length,
-				sizeof(struct msm_stats_flush_bufq));
-			rc = -EINVAL;
-			goto end;
-	}
-	rc = vfe_ctrl->stats_ops.bufq_flush(
-			&vfe_ctrl->stats_ctrl,
-			(enum msm_stats_enum_type)flush_req->stats_type,
-			vfe_ctrl->stats_ops.client);
-	}
-	break;
-	case VFE_CMD_STATS_UNREGBUF:
-	{
-		struct msm_stats_reqbuf *req_buf = NULL;
-		req_buf = (struct msm_stats_reqbuf *)cmd->value;
-		if (sizeof(struct msm_stats_reqbuf) != cmd->length) {
-			/* error. the length not match */
-			pr_err("%s: stats reqbuf input size = %d,\n"
-				"struct size = %d, mitch match\n",
-				 __func__, cmd->length,
-				sizeof(struct msm_stats_reqbuf));
-			rc = -EINVAL ;
-			goto end;
-		}
-		rc = vfe32_stats_unregbuf(vfe_ctrl, req_buf, domain_num);
-	}
-	break;
-	default:
-		rc = -1;
-		pr_err("%s: cmd_type %d not supported", __func__,
-			cmd->cmd_type);
-	break;
-	}
-end:
-	return rc;
-}
-
-static long msm_vfe_subdev_ioctl(struct v4l2_subdev *sd,
-			unsigned int subdev_cmd, void *arg)
-{
-	struct msm_cam_media_controller *pmctl =
-		(struct msm_cam_media_controller *)v4l2_get_subdev_hostdata(sd);
-	struct vfe32_ctrl_type *vfe32_ctrl =
-		(struct vfe32_ctrl_type *)v4l2_get_subdevdata(sd);
-	struct msm_isp_cmd vfecmd;
-	struct msm_camvfe_params *vfe_params;
-	struct msm_vfe_cfg_cmd *cmd;
-	void *data;
-
-	long rc = 0;
-	struct vfe_cmd_stats_buf *scfg = NULL;
-	struct vfe_cmd_stats_ack *sack = NULL;
-
-	if (!vfe32_ctrl->share_ctrl->vfebase) {
-		pr_err("%s: base address unmapped\n", __func__);
-		return -EFAULT;
-	}
-
-	CDBG("%s\n", __func__);
-	if (subdev_cmd == VIDIOC_MSM_VFE_INIT) {
-		CDBG("%s init\n", __func__);
-		return msm_vfe_subdev_init(sd);
-	} else if (subdev_cmd == VIDIOC_MSM_VFE_RELEASE) {
-		msm_vfe_subdev_release(sd);
-		return 0;
-	}
-	vfe_params = (struct msm_camvfe_params *)arg;
-	cmd = vfe_params->vfe_cfg;
-	data = vfe_params->data;
-	switch (cmd->cmd_type) {
-	case CMD_VFE_PROCESS_IRQ:
-		vfe32_process_irq(vfe32_ctrl, (uint32_t) data);
-		return rc;
-	case VFE_CMD_STATS_REQBUF:
-	case VFE_CMD_STATS_ENQUEUEBUF:
-	case VFE_CMD_STATS_FLUSH_BUFQ:
-	case VFE_CMD_STATS_UNREGBUF:
-		/* for easy porting put in one envelope */
-		rc = vfe_stats_bufq_sub_ioctl(vfe32_ctrl,
-				cmd, vfe_params->data, pmctl->domain_num);
-		return rc;
-	default:
-		if (cmd->cmd_type != CMD_CONFIG_PING_ADDR &&
-		cmd->cmd_type != CMD_CONFIG_PONG_ADDR &&
-		cmd->cmd_type != CMD_CONFIG_FREE_BUF_ADDR &&
-		cmd->cmd_type != CMD_STATS_AEC_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_AWB_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_IHIST_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_RS_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_CS_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_AF_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_BG_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_BF_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_BHIST_BUF_RELEASE &&
-		cmd->cmd_type != CMD_VFE_PIX_SOF_COUNT_UPDATE &&
-		cmd->cmd_type != CMD_VFE_COUNT_PIX_SOF_ENABLE) {
-			if (copy_from_user(&vfecmd,
-					(void __user *)(cmd->value),
-					sizeof(vfecmd))) {
-				pr_err("%s %d: copy_from_user failed\n",
-					__func__, __LINE__);
-				return -EFAULT;
-			}
-		} else {
-			/* here eith stats release or frame release. */
-			if (cmd->cmd_type != CMD_CONFIG_PING_ADDR &&
-				cmd->cmd_type != CMD_CONFIG_PONG_ADDR &&
-				cmd->cmd_type != CMD_CONFIG_FREE_BUF_ADDR) {
-				/* then must be stats release. */
-				if (!data) {
-					pr_err("%s: data = NULL, cmd->cmd_type = %d",
-						__func__, cmd->cmd_type);
-					return -EFAULT;
-				}
-				sack = kmalloc(sizeof(struct vfe_cmd_stats_ack),
-							GFP_ATOMIC);
-				if (!sack) {
-					pr_err("%s: no mem for cmd->cmd_type = %d",
-					 __func__, cmd->cmd_type);
-					return -ENOMEM;
-				}
-				sack->nextStatsBuf = *(uint32_t *)data;
-			}
-		}
-	}
-
-	CDBG("%s: cmdType = %d\n", __func__, cmd->cmd_type);
-
-	if ((cmd->cmd_type == CMD_STATS_AF_ENABLE)    ||
-		(cmd->cmd_type == CMD_STATS_AWB_ENABLE)   ||
-		(cmd->cmd_type == CMD_STATS_IHIST_ENABLE) ||
-		(cmd->cmd_type == CMD_STATS_RS_ENABLE)    ||
-		(cmd->cmd_type == CMD_STATS_CS_ENABLE)    ||
-		(cmd->cmd_type == CMD_STATS_AEC_ENABLE)   ||
-		(cmd->cmd_type == CMD_STATS_BG_ENABLE)    ||
-		(cmd->cmd_type == CMD_STATS_BF_ENABLE)    ||
-		(cmd->cmd_type == CMD_STATS_BHIST_ENABLE)) {
-		struct axidata *axid;
-		axid = data;
-		if (!axid) {
-			rc = -EFAULT;
-			goto vfe32_config_done;
-		}
-		CDBG("%s: cmdType = %d\n", __func__, cmd->cmd_type);
-
-		if ((cmd->cmd_type == CMD_STATS_AF_ENABLE)    ||
-			(cmd->cmd_type == CMD_STATS_AWB_ENABLE)   ||
-			(cmd->cmd_type == CMD_STATS_IHIST_ENABLE) ||
-			(cmd->cmd_type == CMD_STATS_RS_ENABLE)    ||
-			(cmd->cmd_type == CMD_STATS_CS_ENABLE)    ||
-			(cmd->cmd_type == CMD_STATS_AEC_ENABLE)) {
-				scfg = NULL;
-				/* individual */
-				goto vfe32_config_done;
-		}
-		switch (cmd->cmd_type) {
-		case CMD_STATS_AEC_ENABLE:
-		case CMD_STATS_BG_ENABLE:
-		case CMD_STATS_BF_ENABLE:
-		case CMD_STATS_BHIST_ENABLE:
-		case CMD_STATS_AWB_ENABLE:
-		case CMD_STATS_IHIST_ENABLE:
-		case CMD_STATS_RS_ENABLE:
-		case CMD_STATS_CS_ENABLE:
-		default:
-			pr_err("%s Unsupported cmd type %d",
-				__func__, cmd->cmd_type);
-			break;
-		}
-		goto vfe32_config_done;
-	}
-	switch (cmd->cmd_type) {
-	case CMD_GENERAL:
-		rc = vfe32_proc_general(pmctl, &vfecmd, vfe32_ctrl);
-	break;
-	case CMD_VFE_COUNT_PIX_SOF_ENABLE: {
-		int enable = *((int *)cmd->value);
-		if (enable)
-			vfe32_ctrl->vfe_sof_count_enable = TRUE;
-		else
-			vfe32_ctrl->vfe_sof_count_enable = false;
-	}
-	break;
-	case CMD_VFE_PIX_SOF_COUNT_UPDATE:
-		if (!vfe32_ctrl->vfe_sof_count_enable)
-			vfe32_ctrl->share_ctrl->vfeFrameId =
-			*((uint32_t *)vfe_params->data);
-	break;
-	case CMD_CONFIG_PING_ADDR: {
-		int path = *((int *)cmd->value);
-		struct vfe32_output_ch *outch =
-			vfe32_get_ch(path, vfe32_ctrl->share_ctrl);
-		outch->ping = *((struct msm_free_buf *)data);
-	}
-	break;
-
-	case CMD_CONFIG_PONG_ADDR: {
-		int path = *((int *)cmd->value);
-		struct vfe32_output_ch *outch =
-			vfe32_get_ch(path, vfe32_ctrl->share_ctrl);
-		outch->pong = *((struct msm_free_buf *)data);
-	}
-	break;
-
-	case CMD_CONFIG_FREE_BUF_ADDR: {
-		int path = *((int *)cmd->value);
-		struct vfe32_output_ch *outch =
-			vfe32_get_ch(path, vfe32_ctrl->share_ctrl);
-		outch->free_buf = *((struct msm_free_buf *)data);
-	}
-	break;
-
-	case CMD_SNAP_BUF_RELEASE:
-		break;
-
-	default:
-		pr_err("%s Unsupported AXI configuration %x ", __func__,
-			cmd->cmd_type);
-	break;
-	}
-vfe32_config_done:
-	kfree(scfg);
-	kfree(sack);
-	CDBG("%s done: rc = %d\n", __func__, (int) rc);
-	return rc;
-}
-
-static struct msm_cam_clk_info vfe32_clk_info[] = {
-	{"vfe_clk", 228570000},
-	{"vfe_pclk", -1},
-	{"csi_vfe_clk", -1},
-};
-
-static int msm_axi_subdev_s_crystal_freq(struct v4l2_subdev *sd,
-						u32 freq, u32 flags)
-{
-	int rc = 0;
-	int round_rate;
-	struct axi_ctrl_t *axi_ctrl = v4l2_get_subdevdata(sd);
-
-	if (axi_ctrl->share_ctrl->dual_enabled)
-		return rc;
-
-	round_rate = clk_round_rate(axi_ctrl->vfe_clk[0], freq);
-	if (rc < 0) {
-		pr_err("%s: clk_round_rate failed %d\n",
-					__func__, rc);
-		return rc;
-	}
-
-	vfe_clk_rate = round_rate;
-	rc = clk_set_rate(axi_ctrl->vfe_clk[0], round_rate);
-	if (rc < 0)
-		pr_err("%s: clk_set_rate failed %d\n",
-					__func__, rc);
-
-	return rc;
-}
-
-static const struct v4l2_subdev_core_ops msm_vfe_subdev_core_ops = {
-	.ioctl = msm_vfe_subdev_ioctl,
-};
-
-static const struct v4l2_subdev_ops msm_vfe_subdev_ops = {
-	.core = &msm_vfe_subdev_core_ops,
-};
-
-int msm_axi_subdev_init(struct v4l2_subdev *sd,
-	uint8_t dual_enabled)
-{
-	int rc = 0;
-	struct axi_ctrl_t *axi_ctrl = v4l2_get_subdevdata(sd);
-	struct msm_cam_media_controller *mctl =
-		v4l2_get_subdev_hostdata(sd);
-	if (mctl == NULL) {
-		rc = -EINVAL;
-		goto mctl_failed;
-	}
-
-	axi_ctrl->share_ctrl->axi_ref_cnt++;
-	if (axi_ctrl->share_ctrl->axi_ref_cnt > 1)
-		return rc;
-	axi_ctrl->share_ctrl->dual_enabled = dual_enabled;
-	spin_lock_init(&axi_ctrl->tasklet_lock);
-	INIT_LIST_HEAD(&axi_ctrl->tasklet_q);
-	spin_lock_init(&axi_ctrl->share_ctrl->sd_notify_lock);
-
-	axi_ctrl->share_ctrl->vfebase = ioremap(axi_ctrl->vfemem->start,
-		resource_size(axi_ctrl->vfemem));
-	if (!axi_ctrl->share_ctrl->vfebase) {
-		rc = -ENOMEM;
-		pr_err("%s: vfe ioremap failed\n", __func__);
-		goto remap_failed;
-	}
-
-	if (axi_ctrl->fs_vfe) {
-		rc = regulator_enable(axi_ctrl->fs_vfe);
-		if (rc) {
-			pr_err("%s: Regulator enable failed\n",	__func__);
-			goto fs_failed;
-		}
-	}
-
-	rc = msm_cam_clk_enable(&axi_ctrl->pdev->dev, vfe32_clk_info,
-			axi_ctrl->vfe_clk, ARRAY_SIZE(vfe32_clk_info), 1);
-	if (rc < 0)
-		goto clk_enable_failed;
-
-#ifdef CONFIG_MSM_IOMMU
-	rc = iommu_attach_device(mctl->domain, axi_ctrl->iommu_ctx_imgwr);
-	if (rc < 0) {
-		pr_err("%s: imgwr attach failed rc = %d\n", __func__, rc);
-		rc = -ENODEV;
-		goto device_imgwr_attach_failed;
-	}
-	rc = iommu_attach_device(mctl->domain, axi_ctrl->iommu_ctx_misc);
-	if (rc < 0) {
-		pr_err("%s: misc attach failed rc = %d\n", __func__, rc);
-		rc = -ENODEV;
-		goto device_misc_attach_failed;
-	}
-#endif
-
-	msm_camio_bus_scale_cfg(
-		mctl->sdata->pdata->cam_bus_scale_table, S_INIT);
-
-	if (axi_ctrl->share_ctrl->dual_enabled)
-		msm_camio_bus_scale_cfg(
-			mctl->sdata->pdata->cam_bus_scale_table, S_DUAL);
-	else
-		msm_camio_bus_scale_cfg(
-			mctl->sdata->pdata->cam_bus_scale_table, S_PREVIEW);
-
-	if (msm_camera_io_r(
-		axi_ctrl->share_ctrl->vfebase + V32_GET_HW_VERSION_OFF) ==
-		VFE32_HW_NUMBER)
-		axi_ctrl->share_ctrl->register_total = VFE32_REGISTER_TOTAL;
-	else
-		axi_ctrl->share_ctrl->register_total = VFE33_REGISTER_TOTAL;
-
-	spin_lock_init(&axi_ctrl->share_ctrl->stop_flag_lock);
-	spin_lock_init(&axi_ctrl->share_ctrl->update_ack_lock);
-	spin_lock_init(&axi_ctrl->share_ctrl->start_ack_lock);
-
-	enable_irq(axi_ctrl->vfeirq->start);
-
-	return rc;
-
-#ifdef CONFIG_MSM_IOMMU
-device_misc_attach_failed:
-	iommu_detach_device(mctl->domain, axi_ctrl->iommu_ctx_imgwr);
-device_imgwr_attach_failed:
-#endif
-	msm_cam_clk_enable(&axi_ctrl->pdev->dev, vfe32_clk_info,
-			axi_ctrl->vfe_clk, ARRAY_SIZE(vfe32_clk_info), 0);
-clk_enable_failed:
-	if (axi_ctrl->fs_vfe)
-		regulator_disable(axi_ctrl->fs_vfe);
-fs_failed:
-	iounmap(axi_ctrl->share_ctrl->vfebase);
-	axi_ctrl->share_ctrl->vfebase = NULL;
-remap_failed:
-mctl_failed:
-	return rc;
-}
-
-int msm_vfe_subdev_init(struct v4l2_subdev *sd)
-{
-	int rc = 0;
-	struct vfe32_ctrl_type *vfe32_ctrl =
-		(struct vfe32_ctrl_type *)v4l2_get_subdevdata(sd);
-
-	spin_lock_init(&vfe32_ctrl->state_lock);
-	spin_lock_init(&vfe32_ctrl->stats_bufq_lock);
-
-	vfe32_ctrl->update_linear = false;
-	vfe32_ctrl->update_rolloff = false;
-	vfe32_ctrl->update_la = false;
-	vfe32_ctrl->update_gamma = false;
-	vfe32_ctrl->vfe_sof_count_enable = false;
-	vfe32_ctrl->hfr_mode = HFR_MODE_OFF;
-
-	memset(&vfe32_ctrl->stats_ctrl, 0,
-		sizeof(struct msm_stats_bufq_ctrl));
-	memset(&vfe32_ctrl->stats_ops, 0, sizeof(struct msm_stats_ops));
-
-	return rc;
-}
-
-void msm_axi_subdev_release(struct v4l2_subdev *sd)
-{
-	struct axi_ctrl_t *axi_ctrl = v4l2_get_subdevdata(sd);
-	struct msm_cam_media_controller *pmctl =
-		v4l2_get_subdev_hostdata(sd);
-
-	if (!axi_ctrl->share_ctrl->vfebase) {
-		pr_err("%s: base address unmapped\n", __func__);
-		return;
-	}
-
-	axi_ctrl->share_ctrl->axi_ref_cnt--;
-	if (axi_ctrl->share_ctrl->axi_ref_cnt > 0)
-		return;
-
-	axi_clear_all_interrupts(axi_ctrl->share_ctrl);
-	axi_ctrl->share_ctrl->dual_enabled = 0;
-	disable_irq(axi_ctrl->vfeirq->start);
-	tasklet_kill(&axi_ctrl->vfe32_tasklet);
-#ifdef CONFIG_MSM_IOMMU
-	iommu_detach_device(pmctl->domain, axi_ctrl->iommu_ctx_misc);
-	iommu_detach_device(pmctl->domain, axi_ctrl->iommu_ctx_imgwr);
-#endif
-	msm_cam_clk_enable(&axi_ctrl->pdev->dev, vfe32_clk_info,
-			axi_ctrl->vfe_clk, ARRAY_SIZE(vfe32_clk_info), 0);
-	if (axi_ctrl->fs_vfe)
-		regulator_disable(axi_ctrl->fs_vfe);
-
-	iounmap(axi_ctrl->share_ctrl->vfebase);
-	axi_ctrl->share_ctrl->vfebase = NULL;
-
-	if (atomic_read(&irq_cnt))
-		pr_warning("%s, Warning IRQ Count not ZERO\n", __func__);
-
-	msm_camio_bus_scale_cfg(
-		pmctl->sdata->pdata->cam_bus_scale_table, S_EXIT);
-
-}
-
-void msm_vfe_subdev_release(struct v4l2_subdev *sd)
-{
-	struct vfe32_ctrl_type *vfe32_ctrl =
-		(struct vfe32_ctrl_type *)v4l2_get_subdevdata(sd);
-	CDBG("vfe subdev release %p\n",
-		vfe32_ctrl->share_ctrl->vfebase);
-}
-
-void axi_abort(struct axi_ctrl_t *axi_ctrl)
-{
-	uint8_t  axi_busy_flag = true;
-	unsigned long flags;
-	/* axi halt command. */
-
-	spin_lock_irqsave(&axi_ctrl->share_ctrl->stop_flag_lock, flags);
-	axi_ctrl->share_ctrl->stop_ack_pending  = TRUE;
-	spin_unlock_irqrestore(&axi_ctrl->share_ctrl->stop_flag_lock, flags);
-	msm_camera_io_w(AXI_HALT,
-		axi_ctrl->share_ctrl->vfebase + VFE_AXI_CMD);
-	wmb();
-	while (axi_busy_flag) {
-		if (msm_camera_io_r(
-			axi_ctrl->share_ctrl->vfebase + VFE_AXI_STATUS) & 0x1)
-			axi_busy_flag = false;
-	}
-	/* Ensure the write order while writing
-	* to the command register using the barrier */
-	msm_camera_io_w_mb(AXI_HALT_CLEAR,
-		axi_ctrl->share_ctrl->vfebase + VFE_AXI_CMD);
-
-	/* after axi halt, then ok to apply global reset.
-	* enable reset_ack and async timer interrupt only while
-	* stopping the pipeline.*/
-	msm_camera_io_w(0xf0000000,
-		axi_ctrl->share_ctrl->vfebase + VFE_IRQ_MASK_0);
-	msm_camera_io_w(VFE_IMASK_WHILE_STOPPING_1,
-		axi_ctrl->share_ctrl->vfebase + VFE_IRQ_MASK_1);
-
-	/* Ensure the write order while writing
-	* to the command register using the barrier */
-	msm_camera_io_w_mb(VFE_RESET_UPON_STOP_CMD,
-		axi_ctrl->share_ctrl->vfebase + VFE_GLOBAL_RESET);
-	if (axi_ctrl->share_ctrl->sync_abort)
-		wait_for_completion_interruptible(
-			&axi_ctrl->share_ctrl->reset_complete);
-}
-
-int axi_config_buffers(struct axi_ctrl_t *axi_ctrl,
-	struct msm_camera_vfe_params_t vfe_params)
-{
-	uint16_t vfe_mode = axi_ctrl->share_ctrl->current_mode
-			& ~(VFE_OUTPUTS_RDI0|VFE_OUTPUTS_RDI1);
-	int rc = 0;
-	switch (vfe_params.cmd_type) {
-	case AXI_CMD_PREVIEW:
-		if (vfe_mode) {
-			if ((axi_ctrl->share_ctrl->current_mode &
-				VFE_OUTPUTS_PREVIEW_AND_VIDEO) ||
-				(axi_ctrl->share_ctrl->current_mode &
-				VFE_OUTPUTS_PREVIEW))
-				/* Configure primary channel */
-				rc = configure_pingpong_buffers(
-					VFE_MSG_START,
-					VFE_MSG_OUTPUT_PRIMARY,
-					axi_ctrl);
-			else
-			/* Configure secondary channel */
-				rc = configure_pingpong_buffers(
-					VFE_MSG_START,
-					VFE_MSG_OUTPUT_SECONDARY,
-					axi_ctrl);
-		}
-		if (axi_ctrl->share_ctrl->current_mode &
-				VFE_OUTPUTS_RDI0)
-			rc = configure_pingpong_buffers(
-				VFE_MSG_START, VFE_MSG_OUTPUT_TERTIARY1,
-				axi_ctrl);
-		if (axi_ctrl->share_ctrl->current_mode &
-				VFE_OUTPUTS_RDI1)
-			rc = configure_pingpong_buffers(
-				VFE_MSG_START, VFE_MSG_OUTPUT_TERTIARY2,
-				axi_ctrl);
-
-		if (rc < 0) {
-			pr_err("%s error configuring pingpong buffers for preview",
-				__func__);
-			rc = -EINVAL;
-			goto config_done;
-		}
-		break;
-	case AXI_CMD_RAW_CAPTURE:
-		rc = configure_pingpong_buffers(
-			VFE_MSG_CAPTURE, VFE_MSG_OUTPUT_PRIMARY,
-			axi_ctrl);
-		if (rc < 0) {
-			pr_err("%s error configuring pingpong buffers for snapshot",
-				__func__);
-			rc = -EINVAL;
-			goto config_done;
-		}
-		break;
-	case AXI_CMD_ZSL:
-		rc = configure_pingpong_buffers(VFE_MSG_START,
-			VFE_MSG_OUTPUT_PRIMARY, axi_ctrl);
-		if (rc < 0)
-			goto config_done;
-		rc = configure_pingpong_buffers(VFE_MSG_START,
-			VFE_MSG_OUTPUT_SECONDARY, axi_ctrl);
-		if (rc < 0)
-			goto config_done;
-		break;
-	case AXI_CMD_RECORD:
-		if (axi_ctrl->share_ctrl->current_mode &
-			VFE_OUTPUTS_PREVIEW_AND_VIDEO) {
-			axi_ctrl->share_ctrl->outpath.out1.inst_handle =
-				vfe_params.inst_handle;
-			rc = configure_pingpong_buffers(
-				VFE_MSG_START_RECORDING,
-				VFE_MSG_OUTPUT_SECONDARY,
-				axi_ctrl);
-		} else if (axi_ctrl->share_ctrl->current_mode &
-			VFE_OUTPUTS_VIDEO_AND_PREVIEW) {
-			axi_ctrl->share_ctrl->outpath.out0.inst_handle =
-				vfe_params.inst_handle;
-			rc = configure_pingpong_buffers(
-				VFE_MSG_START_RECORDING,
-				VFE_MSG_OUTPUT_PRIMARY,
-				axi_ctrl);
-		}
-		if (rc < 0) {
-			pr_err("%s error configuring pingpong buffers for video",
-				__func__);
-			rc = -EINVAL;
-			goto config_done;
-		}
-		break;
-	case AXI_CMD_LIVESHOT:
-		axi_ctrl->share_ctrl->outpath.out0.inst_handle =
-			vfe_params.inst_handle;
-		rc = configure_pingpong_buffers(VFE_MSG_CAPTURE,
-					VFE_MSG_OUTPUT_PRIMARY, axi_ctrl);
-		if (rc < 0) {
-			pr_err("%s error configuring pingpong buffers for primary output",
-				__func__);
-			rc = -EINVAL;
-			goto config_done;
-		}
-		break;
-	case AXI_CMD_CAPTURE:
-		if (vfe_mode) {
-			if (axi_ctrl->share_ctrl->current_mode ==
-				VFE_OUTPUTS_JPEG_AND_THUMB ||
-			axi_ctrl->share_ctrl->current_mode ==
-				VFE_OUTPUTS_THUMB_AND_JPEG) {
-
-				/* Configure primary channel for JPEG */
-				rc = configure_pingpong_buffers(
-					VFE_MSG_JPEG_CAPTURE,
-					VFE_MSG_OUTPUT_PRIMARY,
-					axi_ctrl);
-			} else {
-				/* Configure primary channel */
-				rc = configure_pingpong_buffers(
-					VFE_MSG_CAPTURE,
-					VFE_MSG_OUTPUT_PRIMARY,
-					axi_ctrl);
-			}
-			if (rc < 0) {
-				pr_err("%s error configuring pingpong buffers for primary output",
-					__func__);
-				rc = -EINVAL;
-				goto config_done;
-			}
-			/* Configure secondary channel */
-			rc = configure_pingpong_buffers(
-					VFE_MSG_CAPTURE,
-					VFE_MSG_OUTPUT_SECONDARY,
-					axi_ctrl);
-			if (rc < 0) {
-				pr_err("%s error configuring pingpong buffers for secondary output",
-					__func__);
-				rc = -EINVAL;
-				goto config_done;
-			}
-		}
-
-		if (axi_ctrl->share_ctrl->current_mode &
-				VFE_OUTPUTS_RDI0)
-			rc = configure_pingpong_buffers(
-				VFE_MSG_CAPTURE, VFE_MSG_OUTPUT_TERTIARY1,
-				axi_ctrl);
-		if (axi_ctrl->share_ctrl->current_mode &
-				VFE_OUTPUTS_RDI1)
-			rc = configure_pingpong_buffers(
-				VFE_MSG_CAPTURE, VFE_MSG_OUTPUT_TERTIARY2,
-				axi_ctrl);
-		break;
-	default:
-		rc = -EINVAL;
-		break;
-
-	}
-config_done:
-	return rc;
-}
-
-void axi_start(struct msm_cam_media_controller *pmctl,
-	struct axi_ctrl_t *axi_ctrl, struct msm_camera_vfe_params_t vfe_params)
-{
-	int rc = 0, bus_vector_idx = 0;
-	uint32_t reg_update = 0;
-	uint32_t vfe_mode =
-		(axi_ctrl->share_ctrl->current_mode &
-		~(VFE_OUTPUTS_RDI0|VFE_OUTPUTS_RDI1));
-	rc = axi_config_buffers(axi_ctrl, vfe_params);
-	if (rc < 0)
-		return;
-
-	switch (vfe_params.cmd_type) {
-	case AXI_CMD_PREVIEW:
-		if (!axi_ctrl->share_ctrl->dual_enabled)
-			msm_camio_bus_scale_cfg(
-			pmctl->sdata->pdata->cam_bus_scale_table, S_PREVIEW);
-		break;
-	case AXI_CMD_CAPTURE:
-	case AXI_CMD_RAW_CAPTURE:
-		if (!axi_ctrl->share_ctrl->dual_enabled)
-			msm_camio_bus_scale_cfg(
-			pmctl->sdata->pdata->cam_bus_scale_table, S_CAPTURE);
-		break;
-	case AXI_CMD_RECORD:
-		if (cpu_is_msm8930() || cpu_is_msm8930aa() ||
-			cpu_is_msm8930ab()) {
-			if (axi_ctrl->share_ctrl->current_mode &
-				VFE_OUTPUTS_PREVIEW_AND_VIDEO
-			|| axi_ctrl->share_ctrl->current_mode &
-				VFE_OUTPUTS_VIDEO_AND_PREVIEW)
-				bus_vector_idx = S_VIDEO;
-			else
-				bus_vector_idx = S_ADV_VIDEO;
-		} else {
-			bus_vector_idx = S_VIDEO;
-		}
-		if (!axi_ctrl->share_ctrl->dual_enabled)
-			msm_camio_bus_scale_cfg(
-			pmctl->sdata->pdata->cam_bus_scale_table,
-			bus_vector_idx);
-		return;
-	case AXI_CMD_ZSL:
-		if (!axi_ctrl->share_ctrl->dual_enabled)
-			msm_camio_bus_scale_cfg(
-			pmctl->sdata->pdata->cam_bus_scale_table, S_ZSL);
-		break;
-	case AXI_CMD_LIVESHOT:
-		if (!axi_ctrl->share_ctrl->dual_enabled)
-			msm_camio_bus_scale_cfg(
-			pmctl->sdata->pdata->cam_bus_scale_table, S_LIVESHOT);
-		return;
-	default:
-		return;
-	}
-	axi_enable_wm_irq(axi_ctrl->share_ctrl);
-
-	switch (vfe_params.cmd_type) {
-	case AXI_CMD_RAW_CAPTURE:
-		msm_camera_io_w((
-			0x1 << axi_ctrl->share_ctrl->outpath.out0.ch0),
-			axi_ctrl->share_ctrl->vfebase + VFE_BUS_CMD);
-		msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase
-			+ vfe32_AXI_WM_CFG[axi_ctrl->
-			share_ctrl->outpath.out0.ch0]);
-		break;
-	case AXI_CMD_PREVIEW: {
-		switch (vfe_mode) {
-		case VFE_OUTPUTS_PREVIEW:
-		case VFE_OUTPUTS_PREVIEW_AND_VIDEO:
-			if (axi_ctrl->share_ctrl->outpath.output_mode &
-				VFE32_OUTPUT_MODE_PRIMARY) {
-				msm_camera_io_w((
-					0x1 << axi_ctrl->share_ctrl->
-							outpath.out0.ch0 |
-					0x1 << axi_ctrl->share_ctrl->
-							outpath.out0.ch1),
-					axi_ctrl->share_ctrl->vfebase +
-							VFE_BUS_CMD);
-				msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase
-					+ vfe32_AXI_WM_CFG[axi_ctrl->
-					share_ctrl->outpath.out0.ch0]);
-				msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase
-					+ vfe32_AXI_WM_CFG[axi_ctrl->
-					share_ctrl->outpath.out0.ch1]);
-
-
-			} else if (axi_ctrl->share_ctrl->outpath.output_mode &
-					VFE32_OUTPUT_MODE_PRIMARY_ALL_CHNLS) {
-				msm_camera_io_w((
-					0x1 << axi_ctrl->share_ctrl->
-							outpath.out0.ch0 |
-					0x1 << axi_ctrl->share_ctrl->
-							outpath.out0.ch1 |
-					0x1 << axi_ctrl->share_ctrl->
-							outpath.out0.ch2),
-					axi_ctrl->share_ctrl->vfebase +
-							VFE_BUS_CMD);
-				msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase
-					+ vfe32_AXI_WM_CFG[axi_ctrl->
-					share_ctrl->outpath.out0.ch0]);
-				msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase
-					+ vfe32_AXI_WM_CFG[axi_ctrl->
-					share_ctrl->outpath.out0.ch1]);
-				msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase
-					+ vfe32_AXI_WM_CFG[axi_ctrl->
-					share_ctrl->outpath.out0.ch2]);
-			}
-			break;
-		default:
-			if (axi_ctrl->share_ctrl->outpath.output_mode &
-				VFE32_OUTPUT_MODE_SECONDARY) {
-				msm_camera_io_w((
-					0x1 << axi_ctrl->share_ctrl->
-						outpath.out1.ch0 |
-					0x1 << axi_ctrl->share_ctrl->
-						outpath.out1.ch1),
-					axi_ctrl->share_ctrl->vfebase +
-						VFE_BUS_CMD);
-				msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase
-					+ vfe32_AXI_WM_CFG[axi_ctrl->
-					share_ctrl->outpath.out1.ch0]);
-				msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase
-					+ vfe32_AXI_WM_CFG[axi_ctrl->
-					share_ctrl->outpath.out1.ch1]);
-			} else if (axi_ctrl->share_ctrl->outpath.output_mode &
-				VFE32_OUTPUT_MODE_SECONDARY_ALL_CHNLS) {
-				msm_camera_io_w((
-					0x1 << axi_ctrl->share_ctrl->
-							outpath.out1.ch0 |
-					0x1 << axi_ctrl->share_ctrl->
-							outpath.out1.ch1 |
-					0x1 << axi_ctrl->share_ctrl->
-							outpath.out1.ch2),
-					axi_ctrl->share_ctrl->vfebase +
-							VFE_BUS_CMD);
-				msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase
-					+ vfe32_AXI_WM_CFG[axi_ctrl->
-					share_ctrl->outpath.out1.ch0]);
-				msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase
-					+ vfe32_AXI_WM_CFG[axi_ctrl->
-					share_ctrl->outpath.out1.ch1]);
-				msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase
-					+ vfe32_AXI_WM_CFG[axi_ctrl->
-					share_ctrl->outpath.out1.ch2]);
-			}
-			break;
-			}
-		}
-		break;
-	default:
-		if (axi_ctrl->share_ctrl->outpath.output_mode &
-			VFE32_OUTPUT_MODE_PRIMARY) {
-			msm_camera_io_w((
-				0x1 << axi_ctrl->share_ctrl->outpath.out0.ch0 |
-				0x1 << axi_ctrl->share_ctrl->outpath.out0.ch1),
-				axi_ctrl->share_ctrl->vfebase + VFE_BUS_CMD);
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe32_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out0.ch0]);
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe32_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out0.ch1]);
-		} else if (axi_ctrl->share_ctrl->outpath.output_mode &
-				VFE32_OUTPUT_MODE_PRIMARY_ALL_CHNLS) {
-			msm_camera_io_w((
-				0x1 << axi_ctrl->share_ctrl->outpath.out0.ch0 |
-				0x1 << axi_ctrl->share_ctrl->outpath.out0.ch1 |
-				0x1 << axi_ctrl->share_ctrl->outpath.out0.ch2),
-				axi_ctrl->share_ctrl->vfebase + VFE_BUS_CMD);
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe32_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out0.ch0]);
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe32_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out0.ch1]);
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe32_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out0.ch2]);
-		}
-
-		if (axi_ctrl->share_ctrl->outpath.output_mode &
-			VFE32_OUTPUT_MODE_SECONDARY) {
-			msm_camera_io_w((
-				0x1 << axi_ctrl->share_ctrl->outpath.out1.ch0 |
-				0x1 << axi_ctrl->share_ctrl->outpath.out1.ch1),
-				axi_ctrl->share_ctrl->vfebase + VFE_BUS_CMD);
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe32_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out1.ch0]);
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe32_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out1.ch1]);
-		} else if (axi_ctrl->share_ctrl->outpath.output_mode &
-			VFE32_OUTPUT_MODE_SECONDARY_ALL_CHNLS) {
-			msm_camera_io_w((
-				0x1 << axi_ctrl->share_ctrl->outpath.out1.ch0 |
-				0x1 << axi_ctrl->share_ctrl->outpath.out1.ch1 |
-				0x1 << axi_ctrl->share_ctrl->outpath.out1.ch2),
-				axi_ctrl->share_ctrl->vfebase + VFE_BUS_CMD);
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe32_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out1.ch0]);
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe32_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out1.ch1]);
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe32_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out1.ch2]);
-		}
-		break;
-	}
-	if (axi_ctrl->share_ctrl->current_mode & VFE_OUTPUTS_RDI0) {
-		axi_ctrl->share_ctrl->outpath.out2.capture_cnt =
-						vfe_params.capture_count;
-		axi_ctrl->share_ctrl->rdi0_capture_count =
-						vfe_params.capture_count;
-		msm_camera_io_w((
-				0x1 << axi_ctrl->share_ctrl->outpath.out2.ch0),
-				axi_ctrl->share_ctrl->vfebase + VFE_BUS_CMD);
-		msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-			vfe32_AXI_WM_CFG[axi_ctrl->share_ctrl->
-			outpath.out2.ch0]);
-	}
-	if (axi_ctrl->share_ctrl->current_mode & VFE_OUTPUTS_RDI1) {
-		axi_ctrl->share_ctrl->outpath.out3.capture_cnt =
-						vfe_params.capture_count;
-		axi_ctrl->share_ctrl->rdi1_capture_count =
-						vfe_params.capture_count;
-		msm_camera_io_w((
-				0x1 << axi_ctrl->share_ctrl->outpath.out3.ch0),
-				axi_ctrl->share_ctrl->vfebase + VFE_BUS_CMD);
-		msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-			vfe32_AXI_WM_CFG[axi_ctrl->share_ctrl->
-			outpath.out3.ch0]);
-	}
-
-	axi_enable_irq(axi_ctrl->share_ctrl);
-
-	if (axi_ctrl->share_ctrl->current_mode & VFE_OUTPUTS_RDI0) {
-		if (!atomic_cmpxchg(
-			&axi_ctrl->share_ctrl->rdi0_update_ack_pending,
-				0, 1))
-			reg_update |= 0x2;
-	}
-	if (axi_ctrl->share_ctrl->current_mode & VFE_OUTPUTS_RDI1) {
-		if (!atomic_cmpxchg(
-			&axi_ctrl->share_ctrl->rdi1_update_ack_pending,
-				0, 1))
-			reg_update |= 0x4;
-	}
-
-	if (vfe_mode) {
-		if (!atomic_cmpxchg(
-			&axi_ctrl->share_ctrl->pix0_update_ack_pending,
-				0, 1))
-			reg_update |= 0x1;
-	}
-
-	msm_camera_io_w_mb(reg_update,
-			axi_ctrl->share_ctrl->vfebase +
-			VFE_REG_UPDATE_CMD);
-	axi_ctrl->share_ctrl->operation_mode |=
-		axi_ctrl->share_ctrl->current_mode;
-}
-
-void axi_stop(struct msm_cam_media_controller *pmctl,
-	struct axi_ctrl_t *axi_ctrl, struct msm_camera_vfe_params_t vfe_params)
-{
-	uint32_t reg_update = 0;
-	uint32_t vfe_mode =
-	axi_ctrl->share_ctrl->current_mode & ~(VFE_OUTPUTS_RDI0|
-		VFE_OUTPUTS_RDI1);
-	int bus_vector_idx = 0;
-
-	switch (vfe_params.cmd_type) {
-	case AXI_CMD_PREVIEW:
-	case AXI_CMD_CAPTURE:
-	case AXI_CMD_RAW_CAPTURE:
-	case AXI_CMD_ZSL:
-		axi_ctrl->share_ctrl->cmd_type = vfe_params.cmd_type;
-		break;
-	case AXI_CMD_RECORD:
-		if (!axi_ctrl->share_ctrl->dual_enabled)
-			msm_camio_bus_scale_cfg(
-			pmctl->sdata->pdata->cam_bus_scale_table, S_PREVIEW);
-		return;
-	case AXI_CMD_LIVESHOT:
-		if (!axi_ctrl->share_ctrl->dual_enabled) {
-			bus_vector_idx = S_VIDEO;
-
-			if (cpu_is_msm8930() || cpu_is_msm8930aa() ||
-				cpu_is_msm8930ab())
-				bus_vector_idx = S_ADV_VIDEO;
-
-			msm_camio_bus_scale_cfg(
-			pmctl->sdata->pdata->cam_bus_scale_table,
-			bus_vector_idx);
-		}
-		return;
-	default:
-		return;
-	}
-
-	if (axi_ctrl->share_ctrl->stop_immediately) {
-		axi_disable_irq(axi_ctrl->share_ctrl,
-			axi_ctrl->share_ctrl->current_mode);
-		axi_stop_process(axi_ctrl->share_ctrl);
-		return;
-	}
-
-	if (axi_ctrl->share_ctrl->current_mode & VFE_OUTPUTS_RDI0) {
-		msm_camera_io_w(0, axi_ctrl->share_ctrl->vfebase +
-			vfe32_AXI_WM_CFG[axi_ctrl->share_ctrl->
-				outpath.out2.ch0]);
-		if (!atomic_cmpxchg(
-			&axi_ctrl->share_ctrl->rdi0_update_ack_pending,
-				0, 2))
-			reg_update |= 0x2;
-	}
-	if (axi_ctrl->share_ctrl->current_mode & VFE_OUTPUTS_RDI1) {
-		msm_camera_io_w(0, axi_ctrl->share_ctrl->vfebase +
-			vfe32_AXI_WM_CFG[axi_ctrl->share_ctrl->
-				outpath.out3.ch0]);
-		if (!atomic_cmpxchg(
-			&axi_ctrl->share_ctrl->rdi1_update_ack_pending,
-				0, 2))
-			reg_update |= 0x4;
-	}
-	if (vfe_mode) {
-		if (!atomic_cmpxchg(
-			&axi_ctrl->share_ctrl->pix0_update_ack_pending,
-				0, 2))
-			reg_update |= 0x1;
-	}
-	msm_camera_io_w_mb(reg_update,
-		axi_ctrl->share_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-}
-
-static int msm_axi_config(struct v4l2_subdev *sd, void __user *arg)
-{
-	struct msm_vfe_cfg_cmd cfgcmd;
-	struct msm_isp_cmd vfecmd;
-	struct axi_ctrl_t *axi_ctrl = v4l2_get_subdevdata(sd);
-	struct msm_cam_media_controller *pmctl =
-		(struct msm_cam_media_controller *)v4l2_get_subdev_hostdata(sd);
-	int rc = 0, vfe_cmd_type = 0, rdi_mode = 0;
-
-	if (!axi_ctrl->share_ctrl->vfebase) {
-		pr_err("%s: base address unmapped\n", __func__);
-		return -EFAULT;
-	}
-	memset(&cfgcmd, 0, sizeof(struct msm_vfe_cfg_cmd));
-	if (NULL != arg) {
-		if (copy_from_user(&cfgcmd, arg, sizeof(cfgcmd))) {
-			ERR_COPY_FROM_USER();
-			return -EFAULT;
-		}
-	}
-	memset(&vfecmd, 0, sizeof(struct msm_isp_cmd));
-	if (NULL != cfgcmd.value) {
-		if (copy_from_user(&vfecmd,
-				(void __user *)(cfgcmd.value),
-				sizeof(vfecmd))) {
-			pr_err("%s %d: copy_from_user failed\n", __func__,
-				__LINE__);
-			return -EFAULT;
-		}
-	}
-
-	vfe_cmd_type = (cfgcmd.cmd_type & ~(CMD_AXI_CFG_TERT1|
-		CMD_AXI_CFG_TERT2));
-	switch (cfgcmd.cmd_type) {
-	case CMD_AXI_CFG_TERT1:{
-		uint32_t *axio = NULL;
-		axio = kmalloc(vfe32_cmd[VFE_CMD_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio) {
-			return -ENOMEM;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe32_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			return -EFAULT;
-		}
-		vfe32_config_axi(axi_ctrl, OUTPUT_TERT1, axio);
-		kfree(axio);
-		return rc;
-		}
-	case CMD_AXI_CFG_TERT2:{
-		uint32_t *axio = NULL;
-		axio = kmalloc(vfe32_cmd[VFE_CMD_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio)
-			return -ENOMEM;
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe32_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			return -EFAULT;
-		}
-		vfe32_config_axi(axi_ctrl, OUTPUT_TERT2, axio);
-		kfree(axio);
-		return rc;
-		}
-	case CMD_AXI_CFG_TERT1|CMD_AXI_CFG_TERT2:{
-		uint32_t *axio = NULL;
-		axio = kmalloc(vfe32_cmd[VFE_CMD_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio)
-			return -ENOMEM;
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe32_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			return -EFAULT;
-		}
-		vfe32_config_axi(axi_ctrl, OUTPUT_TERT1|OUTPUT_TERT2, axio);
-		kfree(axio);
-		return rc;
-		}
-	default:
-		if (cfgcmd.cmd_type & CMD_AXI_CFG_TERT1)
-			rdi_mode |= OUTPUT_TERT1;
-		if (cfgcmd.cmd_type & CMD_AXI_CFG_TERT2)
-			rdi_mode |= OUTPUT_TERT2;
-	}
-	switch (vfe_cmd_type) {
-	case CMD_AXI_CFG_PRIM: {
-		uint32_t *axio = NULL;
-		axio = kmalloc(vfe32_cmd[VFE_CMD_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			break;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe32_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			rc = -EFAULT;
-			break;
-		}
-		vfe32_config_axi(axi_ctrl, rdi_mode|OUTPUT_PRIM, axio);
-		kfree(axio);
-		break;
-		}
-	case CMD_AXI_CFG_PRIM_ALL_CHNLS: {
-		uint32_t *axio = NULL;
-		axio = kmalloc(vfe32_cmd[VFE_CMD_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			break;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe32_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			rc = -EFAULT;
-			break;
-		}
-		vfe32_config_axi(axi_ctrl, rdi_mode|OUTPUT_PRIM_ALL_CHNLS,
-			axio);
-		kfree(axio);
-		break;
-		}
-	case CMD_AXI_CFG_PRIM|CMD_AXI_CFG_SEC: {
-		uint32_t *axio = NULL;
-		axio = kmalloc(vfe32_cmd[VFE_CMD_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			break;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe32_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			rc = -EFAULT;
-			break;
-		}
-		vfe32_config_axi(axi_ctrl,
-			rdi_mode|OUTPUT_PRIM|OUTPUT_SEC, axio);
-		kfree(axio);
-		break;
-		}
-	case CMD_AXI_CFG_PRIM|CMD_AXI_CFG_SEC_ALL_CHNLS: {
-		uint32_t *axio = NULL;
-		axio = kmalloc(vfe32_cmd[VFE_CMD_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			break;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe32_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			rc = -EFAULT;
-			break;
-		}
-		vfe32_config_axi(axi_ctrl,
-			rdi_mode|OUTPUT_PRIM|OUTPUT_SEC_ALL_CHNLS, axio);
-		kfree(axio);
-		break;
-		}
-	case CMD_AXI_CFG_PRIM_ALL_CHNLS|CMD_AXI_CFG_SEC: {
-		uint32_t *axio = NULL;
-		axio = kmalloc(vfe32_cmd[VFE_CMD_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			break;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe32_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			rc = -EFAULT;
-			break;
-		}
-		vfe32_config_axi(axi_ctrl,
-			rdi_mode|OUTPUT_PRIM_ALL_CHNLS|OUTPUT_SEC, axio);
-		kfree(axio);
-		break;
-		}
-
-	case CMD_AXI_CFG_PRIM_ALL_CHNLS|CMD_AXI_CFG_SEC_ALL_CHNLS:
-		pr_err("%s Invalid/Unsupported AXI configuration %x",
-			__func__, cfgcmd.cmd_type);
-		break;
-	case CMD_AXI_START: {
-		struct msm_camera_vfe_params_t vfe_params;
-		if (copy_from_user(&vfe_params,
-				(void __user *)(vfecmd.value),
-				sizeof(struct msm_camera_vfe_params_t))) {
-				return -EFAULT;
-		}
-		axi_ctrl->share_ctrl->current_mode =
-			vfe_params.operation_mode;
-		axi_start(pmctl, axi_ctrl, vfe_params);
-		}
-		break;
-	case CMD_AXI_STOP: {
-		struct msm_camera_vfe_params_t vfe_params;
-		if (copy_from_user(&vfe_params,
-				(void __user *)(vfecmd.value),
-				sizeof(struct msm_camera_vfe_params_t))) {
-				return -EFAULT;
-		}
-		axi_ctrl->share_ctrl->current_mode =
-			vfe_params.operation_mode;
-		axi_ctrl->share_ctrl->stop_immediately =
-			vfe_params.stop_immediately;
-		axi_stop(pmctl, axi_ctrl, vfe_params);
-		}
-		break;
-	case CMD_AXI_RESET: {
-		struct msm_camera_vfe_params_t vfe_params;
-		if (copy_from_user(&vfe_params,
-				(void __user *)(vfecmd.value),
-				sizeof(struct msm_camera_vfe_params_t))) {
-				return -EFAULT;
-		}
-		axi_reset(axi_ctrl, vfe_params);
-		}
-		break;
-	case CMD_AXI_ABORT:
-		if (copy_from_user(&axi_ctrl->share_ctrl->sync_abort,
-				(void __user *)(vfecmd.value),
-				sizeof(uint8_t))) {
-				return -EFAULT;
-		}
-		axi_abort(axi_ctrl);
-		break;
-	default:
-		pr_err("%s Unsupported AXI configuration %x ", __func__,
-			cfgcmd.cmd_type);
-		break;
-	}
-	return rc;
-}
-
-static void msm_axi_process_irq(struct v4l2_subdev *sd, void *arg)
-{
-	struct axi_ctrl_t *axi_ctrl = v4l2_get_subdevdata(sd);
-	uint32_t irqstatus = (uint32_t) arg;
-
-	if (!axi_ctrl->share_ctrl->vfebase) {
-		pr_err("%s: base address unmapped\n", __func__);
-		return;
-	}
-
-	/* next, check output path related interrupts. */
-	if (irqstatus &
-		VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE0_MASK) {
-		CDBG("Image composite done 0 irq occured.\n");
-		vfe32_process_output_path_irq_0(axi_ctrl);
-	}
-	if (irqstatus &
-		VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE1_MASK) {
-		CDBG("Image composite done 1 irq occured.\n");
-		vfe32_process_output_path_irq_1(axi_ctrl);
-	}
-
-	if (axi_ctrl->share_ctrl->comp_output_mode &
-		VFE32_OUTPUT_MODE_TERTIARY1)
-		if (irqstatus & (0x1 << (axi_ctrl->share_ctrl->outpath.out2.ch0
-			+ VFE_WM_OFFSET)))
-			vfe32_process_output_path_irq_rdi0(axi_ctrl);
-	if (axi_ctrl->share_ctrl->comp_output_mode &
-		VFE32_OUTPUT_MODE_TERTIARY2)
-		if (irqstatus & (0x1 << (axi_ctrl->share_ctrl->outpath.out3.ch0
-			+ VFE_WM_OFFSET)))
-			vfe32_process_output_path_irq_rdi1(axi_ctrl);
-
-	/* in snapshot mode if done then send
-	snapshot done message */
-	if (
-		axi_ctrl->share_ctrl->operation_mode &
-			VFE_OUTPUTS_THUMB_AND_MAIN ||
-		axi_ctrl->share_ctrl->operation_mode &
-			VFE_OUTPUTS_MAIN_AND_THUMB ||
-		axi_ctrl->share_ctrl->operation_mode &
-			VFE_OUTPUTS_THUMB_AND_JPEG ||
-		axi_ctrl->share_ctrl->operation_mode &
-			VFE_OUTPUTS_JPEG_AND_THUMB ||
-		axi_ctrl->share_ctrl->operation_mode &
-			VFE_OUTPUTS_RAW) {
-		if ((axi_ctrl->share_ctrl->outpath.out0.capture_cnt == 0)
-				&& (axi_ctrl->share_ctrl->outpath.out1.
-				capture_cnt == 0)) {
-			uint32_t mode =
-				(axi_ctrl->share_ctrl->operation_mode &
-				~(VFE_OUTPUTS_RDI0|VFE_OUTPUTS_RDI1));
-			uint16_t output_mode =
-			axi_ctrl->share_ctrl->comp_output_mode &
-				~(VFE32_OUTPUT_MODE_TERTIARY1|
-				VFE32_OUTPUT_MODE_TERTIARY2);
-			if (!axi_ctrl->share_ctrl->dual_enabled)
-				msm_camera_io_w_mb(
-					CAMIF_COMMAND_STOP_IMMEDIATELY,
-					axi_ctrl->share_ctrl->vfebase +
-					VFE_CAMIF_COMMAND);
-			axi_disable_wm_irq(axi_ctrl->share_ctrl, output_mode);
-			axi_disable_irq(axi_ctrl->share_ctrl, mode);
-			vfe32_send_isp_msg(&axi_ctrl->subdev,
-				axi_ctrl->share_ctrl->vfeFrameId,
-				MSG_ID_PIX0_UPDATE_ACK);
-			axi_ctrl->share_ctrl->outpath.out0.
-				capture_cnt = -1;
-			axi_ctrl->share_ctrl->outpath.out1.
-				capture_cnt = -1;
-			axi_ctrl->share_ctrl->comp_output_mode &=
-				(VFE32_OUTPUT_MODE_TERTIARY1|
-				VFE32_OUTPUT_MODE_TERTIARY2);
-		}
-	}
-
-	if (axi_ctrl->share_ctrl->outpath.out2.capture_cnt == 0) {
-		axi_ctrl->share_ctrl->comp_output_mode &=
-				~VFE32_OUTPUT_MODE_TERTIARY1;
-		axi_ctrl->share_ctrl->outpath.out2.capture_cnt = -1;
-	}
-
-	if (axi_ctrl->share_ctrl->outpath.out3.capture_cnt == 0) {
-		axi_ctrl->share_ctrl->comp_output_mode &=
-				~VFE32_OUTPUT_MODE_TERTIARY2;
-		axi_ctrl->share_ctrl->outpath.out3.capture_cnt = -1;
-	}
-}
-
-static int msm_axi_buf_cfg(struct v4l2_subdev *sd, void __user *arg)
-{
-	struct msm_camvfe_params *vfe_params =
-		(struct msm_camvfe_params *)arg;
-	struct msm_vfe_cfg_cmd *cmd = vfe_params->vfe_cfg;
-	struct axi_ctrl_t *axi_ctrl = v4l2_get_subdevdata(sd);
-	void *data = vfe_params->data;
-	int rc = 0;
-
-	if (!axi_ctrl->share_ctrl->vfebase) {
-		pr_err("%s: base address unmapped\n", __func__);
-		return -EFAULT;
-	}
-
-	switch (cmd->cmd_type) {
-	case CMD_CONFIG_PING_ADDR: {
-		int path = *((int *)cmd->value);
-		struct vfe32_output_ch *outch =
-			vfe32_get_ch(path, axi_ctrl->share_ctrl);
-		outch->ping = *((struct msm_free_buf *)data);
-	}
-		break;
-
-	case CMD_CONFIG_PONG_ADDR: {
-		int path = *((int *)cmd->value);
-		struct vfe32_output_ch *outch =
-			vfe32_get_ch(path, axi_ctrl->share_ctrl);
-		outch->pong = *((struct msm_free_buf *)data);
-	}
-		break;
-
-	case CMD_CONFIG_FREE_BUF_ADDR: {
-		int path = *((int *)cmd->value);
-		struct vfe32_output_ch *outch =
-			vfe32_get_ch(path, axi_ctrl->share_ctrl);
-		outch->free_buf = *((struct msm_free_buf *)data);
-	}
-		break;
-	default:
-		pr_err("%s Unsupported AXI Buf config %x ", __func__,
-			cmd->cmd_type);
-	}
-	return rc;
-};
-
-static const struct v4l2_subdev_internal_ops msm_vfe_internal_ops;
-
-static long msm_axi_subdev_ioctl(struct v4l2_subdev *sd,
-			unsigned int cmd, void *arg)
-{
-	int rc = -ENOIOCTLCMD;
-	switch (cmd) {
-	case VIDIOC_MSM_AXI_INIT: {
-		uint8_t dual_enabled;
-		if (copy_from_user(&dual_enabled,
-				(void __user *)(arg),
-				sizeof(uint8_t))) {
-				rc = -EFAULT;
-				break;
-		}
-		rc = msm_axi_subdev_init(sd, dual_enabled);
-		}
-		break;
-	case VIDIOC_MSM_AXI_CFG:
-		rc = msm_axi_config(sd, arg);
-		break;
-	case VIDIOC_MSM_AXI_IRQ:
-		msm_axi_process_irq(sd, arg);
-		rc = 0;
-		break;
-	case VIDIOC_MSM_AXI_BUF_CFG:
-		msm_axi_buf_cfg(sd, arg);
-		rc = 0;
-		break;
-	case VIDIOC_MSM_AXI_RELEASE:
-		msm_axi_subdev_release(sd);
-		rc = 0;
-		break;
-	case VIDIOC_MSM_AXI_RDI_COUNT_UPDATE: {
-		struct rdi_count_msg *msg = (struct rdi_count_msg *)arg;
-		struct axi_ctrl_t *axi_ctrl = v4l2_get_subdevdata(sd);
-		switch (msg->rdi_interface) {
-		case RDI_0:
-			axi_ctrl->share_ctrl->rdi0FrameId = msg->count;
-			rc = 0;
-			break;
-		case RDI_1:
-			axi_ctrl->share_ctrl->rdi1FrameId = msg->count;
-			rc = 0;
-			break;
-		case RDI_2:
-			axi_ctrl->share_ctrl->rdi2FrameId = msg->count;
-			rc = 0;
-			break;
-		default:
-			pr_err("%s: Incorrect interface sent\n", __func__);
-			rc = -EINVAL;
-			break;
-		}
-		break;
-	}
-	default:
-		pr_err("%s: command %d not found\n", __func__,
-						_IOC_NR(cmd));
-		break;
-	}
-	return rc;
-}
-
-static const struct v4l2_subdev_core_ops msm_axi_subdev_core_ops = {
-	.ioctl = msm_axi_subdev_ioctl,
-	.interrupt_service_routine = msm_axi_subdev_isr_routine,
-};
-
-static const struct v4l2_subdev_video_ops msm_axi_subdev_video_ops = {
-	.s_crystal_freq = msm_axi_subdev_s_crystal_freq,
-};
-
-static const struct v4l2_subdev_ops msm_axi_subdev_ops = {
-	.core = &msm_axi_subdev_core_ops,
-	.video = &msm_axi_subdev_video_ops,
-};
-
-static const struct v4l2_subdev_internal_ops msm_axi_internal_ops;
-
-static int __devinit vfe32_probe(struct platform_device *pdev)
-{
-	int rc = 0;
-	struct axi_ctrl_t *axi_ctrl;
-	struct vfe32_ctrl_type *vfe32_ctrl;
-	struct vfe_share_ctrl_t *share_ctrl;
-	struct intr_table_entry irq_req;
-	struct msm_cam_subdev_info sd_info;
-
-	CDBG("%s: device id = %d\n", __func__, pdev->id);
-
-	share_ctrl = kzalloc(sizeof(struct vfe_share_ctrl_t), GFP_KERNEL);
-	if (!share_ctrl) {
-		pr_err("%s: no enough memory\n", __func__);
-		return -ENOMEM;
-	}
-
-	axi_ctrl = kzalloc(sizeof(struct axi_ctrl_t), GFP_KERNEL);
-	if (!axi_ctrl) {
-		pr_err("%s: no enough memory\n", __func__);
-		kfree(share_ctrl);
-		return -ENOMEM;
-	}
-
-	vfe32_ctrl = kzalloc(sizeof(struct vfe32_ctrl_type), GFP_KERNEL);
-	if (!vfe32_ctrl) {
-		pr_err("%s: no enough memory\n", __func__);
-		kfree(share_ctrl);
-		kfree(axi_ctrl);
-		return -ENOMEM;
-	}
-
-	share_ctrl->axi_ctrl = axi_ctrl;
-	share_ctrl->vfe32_ctrl = vfe32_ctrl;
-	axi_ctrl->share_ctrl = share_ctrl;
-	vfe32_ctrl->share_ctrl = share_ctrl;
-	axi_ctrl->share_ctrl->axi_ref_cnt = 0;
-	v4l2_subdev_init(&axi_ctrl->subdev, &msm_axi_subdev_ops);
-	axi_ctrl->subdev.internal_ops = &msm_axi_internal_ops;
-	axi_ctrl->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	snprintf(axi_ctrl->subdev.name,
-			 sizeof(axi_ctrl->subdev.name), "axi");
-	v4l2_set_subdevdata(&axi_ctrl->subdev, axi_ctrl);
-	axi_ctrl->pdev = pdev;
-
-	sd_info.sdev_type = AXI_DEV;
-	sd_info.sd_index = 0;
-	sd_info.irq_num = 0;
-	msm_cam_register_subdev_node(&axi_ctrl->subdev, &sd_info);
-
-	media_entity_init(&axi_ctrl->subdev.entity, 0, NULL, 0);
-	axi_ctrl->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
-	axi_ctrl->subdev.entity.group_id = AXI_DEV;
-	axi_ctrl->subdev.entity.name = pdev->name;
-	axi_ctrl->subdev.entity.revision = axi_ctrl->subdev.devnode->num;
-
-	v4l2_subdev_init(&vfe32_ctrl->subdev, &msm_vfe_subdev_ops);
-	vfe32_ctrl->subdev.internal_ops = &msm_vfe_internal_ops;
-	vfe32_ctrl->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	snprintf(vfe32_ctrl->subdev.name,
-			 sizeof(vfe32_ctrl->subdev.name), "vfe3.2");
-	v4l2_set_subdevdata(&vfe32_ctrl->subdev, vfe32_ctrl);
-	platform_set_drvdata(pdev, &vfe32_ctrl->subdev);
-
-	axi_ctrl->vfemem = platform_get_resource_byname(pdev,
-					IORESOURCE_MEM, "vfe32");
-	if (!axi_ctrl->vfemem) {
-		pr_err("%s: no mem resource?\n", __func__);
-		rc = -ENODEV;
-		goto vfe32_no_resource;
-	}
-	axi_ctrl->vfeirq = platform_get_resource_byname(pdev,
-					IORESOURCE_IRQ, "vfe32");
-	if (!axi_ctrl->vfeirq) {
-		pr_err("%s: no irq resource?\n", __func__);
-		rc = -ENODEV;
-		goto vfe32_no_resource;
-	}
-
-	axi_ctrl->vfeio = request_mem_region(axi_ctrl->vfemem->start,
-		resource_size(axi_ctrl->vfemem), pdev->name);
-	if (!axi_ctrl->vfeio) {
-		pr_err("%s: no valid mem region\n", __func__);
-		rc = -EBUSY;
-		goto vfe32_no_resource;
-	}
-
-	axi_ctrl->fs_vfe = regulator_get(&pdev->dev, "vdd");
-	if (IS_ERR(axi_ctrl->fs_vfe)) {
-		pr_err("%s: Regulator get failed %ld\n", __func__,
-			PTR_ERR(axi_ctrl->fs_vfe));
-		axi_ctrl->fs_vfe = NULL;
-	}
-
-	/* Register subdev node before requesting irq since
-	 * irq_num is needed by msm_cam_server */
-	sd_info.sdev_type = VFE_DEV;
-	sd_info.sd_index = 0;
-	sd_info.irq_num = axi_ctrl->vfeirq->start;
-	msm_cam_register_subdev_node(&vfe32_ctrl->subdev, &sd_info);
-
-	media_entity_init(&vfe32_ctrl->subdev.entity, 0, NULL, 0);
-	vfe32_ctrl->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
-	vfe32_ctrl->subdev.entity.group_id = VFE_DEV;
-	vfe32_ctrl->subdev.entity.name = pdev->name;
-	vfe32_ctrl->subdev.entity.revision = vfe32_ctrl->subdev.devnode->num;
-
-	/* Request for this device irq from the camera server. If the
-	 * IRQ Router is present on this target, the interrupt will be
-	 * handled by the camera server and the interrupt service
-	 * routine called. If the request_irq call returns ENXIO, then
-	 * the IRQ Router hardware is not present on this target. We
-	 * have to request for the irq ourselves and register the
-	 * appropriate interrupt handler. */
-	irq_req.cam_hw_idx       = MSM_CAM_HW_VFE0;
-	irq_req.dev_name         = "vfe";
-	irq_req.irq_idx          = CAMERA_SS_IRQ_8;
-	irq_req.irq_num          = axi_ctrl->vfeirq->start;
-	irq_req.is_composite     = 0;
-	irq_req.irq_trigger_type = IRQF_TRIGGER_RISING;
-	irq_req.num_hwcore       = 1;
-	irq_req.subdev_list[0]   = &axi_ctrl->subdev;
-	irq_req.data             = (void *)axi_ctrl;
-	rc = msm_cam_server_request_irq(&irq_req);
-	if (rc == -ENXIO) {
-		/* IRQ Router hardware is not present on this hardware.
-		 * Request for the IRQ and register the interrupt handler. */
-		rc = request_irq(axi_ctrl->vfeirq->start, vfe32_parse_irq,
-			IRQF_TRIGGER_RISING, "vfe", axi_ctrl);
-		if (rc < 0) {
-			release_mem_region(axi_ctrl->vfemem->start,
-				resource_size(axi_ctrl->vfemem));
-			pr_err("%s: irq request fail\n", __func__);
-			rc = -EBUSY;
-			goto vfe32_no_resource;
-		}
-		disable_irq(axi_ctrl->vfeirq->start);
-	} else if (rc < 0) {
-		pr_err("%s Error registering irq ", __func__);
-		goto vfe32_no_resource;
-	}
-
-#ifdef CONFIG_MSM_IOMMU
-	/*get device context for IOMMU*/
-	axi_ctrl->iommu_ctx_imgwr =
-		msm_iommu_get_ctx("vfe_imgwr"); /*re-confirm*/
-	axi_ctrl->iommu_ctx_misc =
-		msm_iommu_get_ctx("vfe_misc"); /*re-confirm*/
-	if (!axi_ctrl->iommu_ctx_imgwr || !axi_ctrl->iommu_ctx_misc) {
-		release_mem_region(axi_ctrl->vfemem->start,
-			resource_size(axi_ctrl->vfemem));
-		pr_err("%s: No iommu fw context found\n", __func__);
-		rc = -ENODEV;
-		goto vfe32_no_resource;
-	}
-#endif
-
-	tasklet_init(&axi_ctrl->vfe32_tasklet,
-		axi32_do_tasklet, (unsigned long)axi_ctrl);
-
-	vfe32_ctrl->pdev = pdev;
-	/*disable bayer stats by default*/
-	vfe32_ctrl->ver_num.main = 0;
-	return 0;
-
-vfe32_no_resource:
-	kfree(vfe32_ctrl);
-	kfree(axi_ctrl);
-	return 0;
-}
-
-static struct platform_driver vfe32_driver = {
-	.probe = vfe32_probe,
-	.driver = {
-		.name = MSM_VFE_DRV_NAME,
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init msm_vfe32_init_module(void)
-{
-	return platform_driver_register(&vfe32_driver);
-}
-
-static void __exit msm_vfe32_exit_module(void)
-{
-	platform_driver_unregister(&vfe32_driver);
-}
-
-module_init(msm_vfe32_init_module);
-module_exit(msm_vfe32_exit_module);
-MODULE_DESCRIPTION("VFE 3.2 driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe32.h b/drivers/media/platform/msm/camera_v1/vfe/msm_vfe32.h
deleted file mode 100644
index fa4e0bd..0000000
--- a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe32.h
+++ /dev/null
@@ -1,1078 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-
-#ifndef __MSM_VFE32_H__
-#define __MSM_VFE32_H__
-
-#include <linux/bitops.h>
-#include "msm_vfe_stats_buf.h"
-
-#define TRUE  1
-#define FALSE 0
-
-#define VFE32_HW_NUMBER 0x3030B
-#define VFE33_HW_NUMBER 0x30408
-
-/* This defines total number registers in VFE.
- * Each register is 4 bytes so to get the range,
- * multiply this number with 4. */
-#define VFE32_REGISTER_TOTAL 0x000001CD
-#define VFE33_REGISTER_TOTAL 0x000001EE
-
-/* at start of camif,  bit 1:0 = 0x01:enable
- * image data capture at frame boundary. */
-#define CAMIF_COMMAND_START  0x00000005
-
-/* bit 2= 0x1:clear the CAMIF_STATUS register
- * value. */
-#define CAMIF_COMMAND_CLEAR  0x00000004
-
-/* at stop of vfe pipeline, for now it is assumed
- * that camif will stop at any time. Bit 1:0 = 0x10:
- * disable image data capture immediately. */
-#define CAMIF_COMMAND_STOP_IMMEDIATELY  0x00000002
-
-/* at stop of vfe pipeline, for now it is assumed
- * that camif will stop at any time. Bit 1:0 = 0x00:
- * disable image data capture at frame boundary */
-#define CAMIF_COMMAND_STOP_AT_FRAME_BOUNDARY  0x00000000
-
-/* to halt axi bridge */
-#define AXI_HALT  0x00000001
-
-/* clear the halt bit. */
-#define AXI_HALT_CLEAR  0x00000000
-
-/* reset the pipeline when stop command is issued.
- * (without reset the register.) bit 26-32 = 0,
- * domain reset, bit 0-9 = 1 for module reset, except
- * register module. */
-#define VFE_RESET_UPON_STOP_CMD  0x000003ef
-
-/* reset the pipeline when reset command.
- * bit 26-32 = 0, domain reset, bit 0-9 = 1 for module reset. */
-#define VFE_RESET_UPON_RESET_CMD  0x000003ff
-
-/* reset the vfe only when reset command*/
-#define VFE_ONLY_RESET_CMD  0x00000002
-
-/*Vfe module reset command*/
-#define VFE_MODULE_RESET_CMD 0x07ffffff
-
-/* bit 5 is for axi status idle or busy.
- * 1 =  halted,  0 = busy */
-#define AXI_STATUS_BUSY_MASK 0x00000020
-
-/* bit 0 & bit 1 = 1, both y and cbcr irqs need to be present
- * for frame done interrupt */
-#define VFE_COMP_IRQ_BOTH_Y_CBCR 3
-
-/* bit 1 = 1, only cbcr irq triggers frame done interrupt */
-#define VFE_COMP_IRQ_CBCR_ONLY 2
-
-/* bit 0 = 1, only y irq triggers frame done interrupt */
-#define VFE_COMP_IRQ_Y_ONLY 1
-
-/* bit 0 = 1, PM go;   bit1 = 1, PM stop */
-#define VFE_PERFORMANCE_MONITOR_GO   0x00000001
-#define VFE_PERFORMANCE_MONITOR_STOP 0x00000002
-
-/* bit 0 = 1, test gen go;   bit1 = 1, test gen stop */
-#define VFE_TEST_GEN_GO   0x00000001
-#define VFE_TEST_GEN_STOP 0x00000002
-
-/* the chroma is assumed to be interpolated between
- * the luma samples.  JPEG 4:2:2 */
-#define VFE_CHROMA_UPSAMPLE_INTERPOLATED 0
-
-/* wm bit offset for IRQ MASK and IRQ STATUS register */
-#define VFE_WM_OFFSET 6
-
-/* constants for irq registers */
-#define VFE_DISABLE_ALL_IRQS 0
-/* bit =1 is to clear the corresponding bit in VFE_IRQ_STATUS.  */
-#define VFE_CLEAR_ALL_IRQS   0xffffffff
-
-#define VFE_IRQ_STATUS0_CAMIF_SOF_MASK            0x00000001
-#define VFE_IRQ_STATUS0_REG_UPDATE_MASK           0x00000020
-#define VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE0_MASK 0x00200000
-#define VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE1_MASK 0x00400000
-#define VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE2_MASK 0x00800000
-#define VFE_IRQ_STATUS1_RESET_AXI_HALT_ACK_MASK   0x00800000
-#define VFE_IRQ_STATUS0_STATS_COMPOSIT_MASK       0x01000000
-
-#define VFE_IRQ_STATUS0_STATS_AEC_BG    0x2000  /* bit 13 */
-#define VFE_IRQ_STATUS0_STATS_AF_BF     0x4000  /* bit 14 */
-#define VFE_IRQ_STATUS0_STATS_AWB       0x8000  /* bit 15 */
-#define VFE_IRQ_STATUS0_STATS_RS        0x10000  /* bit 16 */
-#define VFE_IRQ_STATUS0_STATS_CS        0x20000  /* bit 17 */
-#define VFE_IRQ_STATUS0_STATS_IHIST     0x40000  /* bit 18 */
-#define VFE_IRQ_STATUS0_STATS_SK_BHIST  0x80000 /* bit 19 */
-
-#define VFE_IRQ_STATUS0_SYNC_TIMER0   0x2000000  /* bit 25 */
-#define VFE_IRQ_STATUS0_SYNC_TIMER1   0x4000000  /* bit 26 */
-#define VFE_IRQ_STATUS0_SYNC_TIMER2   0x8000000  /* bit 27 */
-#define VFE_IRQ_STATUS0_ASYNC_TIMER0  0x10000000  /* bit 28 */
-#define VFE_IRQ_STATUS0_ASYNC_TIMER1  0x20000000  /* bit 29 */
-#define VFE_IRQ_STATUS0_ASYNC_TIMER2  0x40000000  /* bit 30 */
-#define VFE_IRQ_STATUS0_ASYNC_TIMER3  0x80000000  /* bit 32 */
-
-#define VFE_IRQ_STATUS1_RDI0_REG_UPDATE_MASK  0x4000000 /*bit 26*/
-#define VFE_IRQ_STATUS1_RDI1_REG_UPDATE_MASK  0x8000000 /*bit 27*/
-
-/*TODOs the irq status passed from axi to vfe irq handler does not account
-* for 2 irq status registers. So below macro is added to differentiate between
-* same bit set on both irq status registers. This wil be fixed later by passing
-*entire payload to vfe irq handler and parsing there instead of passing just the
-*status bit*/
-#define VFE_IRQ_STATUS1_RDI0_REG_UPDATE  0x84000000 /*bit 26*/
-#define VFE_IRQ_STATUS1_RDI1_REG_UPDATE  0x88000000 /*bit 27*/
-
-/* imask for while waiting for stop ack,  driver has already
- * requested stop, waiting for reset irq, and async timer irq.
- * For irq_status_0, bit 28-32 are for async timer. For
- * irq_status_1, bit 22 for reset irq, bit 23 for axi_halt_ack
-   irq */
-#define VFE_IMASK_WHILE_STOPPING_0  0xF0000000
-#define VFE_IMASK_WHILE_STOPPING_1  0x00800000
-
-/* no error irq in mask 0 */
-#define VFE_IMASK_ERROR_ONLY_0  0x0
-/* when normal case, don't want to block error status. */
-/* bit 0-21 are error irq bits */
-#define VFE_IMASK_ERROR_ONLY_1  0x003fffff
-
-/* For BPC bit 0,bit 12-17 and bit 26 -20 are set to zero and other's 1 */
-#define BPC_MASK 0xF80C0FFE
-
-/* For ABF bit 4 is set to zero and other's 1 */
-#define ABF_MASK 0xFFFFFFF7
-
-
-/* For DBPC bit 0 is set to zero and other's 1 */
-#define DBPC_MASK 0xFFFFFFFE
-
-/* For DBPC bit 1 is set to zero and other's 1 */
-#define DBCC_MASK 0xFFFFFFFD
-
-/* For DBPC/ABF/DBCC/ABCC bits are set to 1 all others 0 */
-#define DEMOSAIC_MASK 0xF
-
-/* For MCE enable bit 28 set to zero and other's 1 */
-#define MCE_EN_MASK 0xEFFFFFFF
-
-/* For MCE Q_K bit 28 to 32 set to zero and other's 1 */
-#define MCE_Q_K_MASK 0x0FFFFFFF
-
-#define AE_BG_ENABLE_MASK 0x00000020      /* bit 5 */
-#define AF_BF_ENABLE_MASK 0x00000040      /* bit 6 */
-#define AWB_ENABLE_MASK 0x00000080     /* bit 7 */
-#define RS_ENABLE_MASK 0x00000100      /* bit 8  */
-#define CS_ENABLE_MASK 0x00000200      /* bit 9  */
-#define RS_CS_ENABLE_MASK 0x00000300   /* bit 8,9  */
-#define CLF_ENABLE_MASK 0x00002000     /* bit 13 */
-#define IHIST_ENABLE_MASK 0x00010000   /* bit 16 */
-#define SKIN_BHIST_ENABLE_MASK 0x00080000 /* bit 19 */
-#define STATS_ENABLE_MASK 0x000903E0   /* bit 19,16,9,8,7,6,5*/
-
-#define STATS_BG_ENABLE_MASK     0x00000002 /* bit 1 */
-#define STATS_BF_ENABLE_MASK     0x00000004 /* bit 2 */
-#define STATS_BHIST_ENABLE_MASK  0x00000008 /* bit 3 */
-
-#define VFE_REG_UPDATE_TRIGGER           1
-#define VFE_PM_BUF_MAX_CNT_MASK          0xFF
-#define VFE_DMI_CFG_DEFAULT              0x00000100
-#define VFE_AE_PINGPONG_STATUS_BIT       0x80
-#define VFE_AF_PINGPONG_STATUS_BIT       0x100
-#define VFE_AWB_PINGPONG_STATUS_BIT      0x200
-
-#define HFR_MODE_OFF 1
-#define VFE_FRAME_SKIP_PERIOD_MASK 0x0000001F /*bits 0 -4*/
-
-enum VFE32_DMI_RAM_SEL {
-	NO_MEM_SELECTED          = 0,
-	BLACK_LUT_RAM_BANK0      = 0x1,
-	BLACK_LUT_RAM_BANK1      = 0x2,
-	ROLLOFF_RAM0_BANK0       = 0x3,
-	DEMOSAIC_LUT_RAM_BANK0   = 0x4,
-	DEMOSAIC_LUT_RAM_BANK1   = 0x5,
-	STATS_BHIST_RAM0         = 0x6,
-	STATS_BHIST_RAM1         = 0x7,
-	RGBLUT_RAM_CH0_BANK0     = 0x8,
-	RGBLUT_RAM_CH0_BANK1     = 0x9,
-	RGBLUT_RAM_CH1_BANK0     = 0xa,
-	RGBLUT_RAM_CH1_BANK1     = 0xb,
-	RGBLUT_RAM_CH2_BANK0     = 0xc,
-	RGBLUT_RAM_CH2_BANK1     = 0xd,
-	RGBLUT_CHX_BANK0         = 0xe,
-	RGBLUT_CHX_BANK1         = 0xf,
-	STATS_IHIST_RAM          = 0x10,
-	LUMA_ADAPT_LUT_RAM_BANK0 = 0x11,
-	LUMA_ADAPT_LUT_RAM_BANK1 = 0x12,
-	ROLLOFF_RAM1_BANK0       = 0x13,
-	ROLLOFF_RAM0_BANK1       = 0x14,
-	ROLLOFF_RAM1_BANK1       = 0x15,
-};
-
-enum vfe_output_state {
-	VFE_STATE_IDLE,
-	VFE_STATE_START_REQUESTED,
-	VFE_STATE_STARTED,
-	VFE_STATE_STOP_REQUESTED,
-	VFE_STATE_STOPPED,
-};
-
-#define V32_CAMIF_OFF             0x000001E4
-#define V32_CAMIF_LEN             32
-
-#define V32_DEMUX_OFF             0x00000284
-#define V32_DEMUX_LEN             20
-
-#define V32_DEMOSAICV3_0_OFF      0x00000298
-#define V32_DEMOSAICV3_0_LEN      4
-#define V32_DEMOSAICV3_1_OFF      0x0000061C
-#define V32_DEMOSAICV3_1_LEN      88
-#define V32_DEMOSAICV3_2_OFF      0x0000066C
-#define V32_DEMOSAICV3_UP_REG_CNT 5
-/* BPC     */
-#define V32_DEMOSAIC_2_OFF        0x0000029C
-#define V32_DEMOSAIC_2_LEN        8
-
-#define V32_OUT_CLAMP_OFF         0x00000524
-#define V32_OUT_CLAMP_LEN         8
-
-#define V32_OPERATION_CFG_LEN     32
-
-#define V32_AXI_BUS_CMD_OFF       0x00000038
-#define V32_AXI_OUT_OFF           0x0000003C
-#define V32_AXI_OUT_LEN           252
-#define V32_AXI_CFG_LEN           47
-#define V32_AXI_BUS_FMT_OFF       1
-#define V32_AXI_BUS_FMT_LEN       4
-#define V32_AXI_BUS_CFG_LEN       16
-
-#define V32_FRAME_SKIP_OFF        0x00000504
-#define V32_FRAME_SKIP_LEN        32
-
-#define V32_CHROMA_SUBS_OFF       0x000004F8
-#define V32_CHROMA_SUBS_LEN       12
-
-#define V32_FOV_OFF           0x00000360
-#define V32_FOV_LEN           8
-
-#define V32_MAIN_SCALER_OFF 0x00000368
-#define V32_MAIN_SCALER_LEN 28
-
-#define V32_S2Y_OFF 0x000004D0
-#define V32_S2Y_LEN 20
-
-#define V32_S2CbCr_OFF 0x000004E4
-#define V32_S2CbCr_LEN 20
-
-#define V32_CHROMA_EN_OFF 0x000003C4
-#define V32_CHROMA_EN_LEN 36
-
-#define V32_SYNC_TIMER_OFF      0x0000020C
-#define V32_SYNC_TIMER_POLARITY_OFF 0x00000234
-#define V32_TIMER_SELECT_OFF        0x0000025C
-#define V32_SYNC_TIMER_LEN 28
-
-#define V32_ASYNC_TIMER_OFF 0x00000238
-#define V32_ASYNC_TIMER_LEN 28
-
-#define V32_BLACK_LEVEL_OFF 0x00000264
-#define V32_BLACK_LEVEL_LEN 16
-
-#define V32_MESH_ROLL_OFF_CFG_OFF             0x00000274
-#define V32_MESH_ROLL_OFF_CFG_LEN             16
-#define V32_MESH_ROLL_OFF_INIT_TABLE_SIZE     13
-#define V32_MESH_ROLL_OFF_DELTA_TABLE_SIZE    208
-#define V32_MESH_ROLL_OFF_DELTA_TABLE_OFFSET  32
-#define V32_GAMMA_LUT_BANK_SEL_MASK           0x00000007
-
-#define V33_PCA_ROLL_OFF_CFG_LEN1             16
-#define V33_PCA_ROLL_OFF_CFG_OFF1             0x00000274
-#define V33_PCA_ROLL_OFF_CFG_LEN2             12
-#define V33_PCA_ROLL_OFF_CFG_OFF2             0x000007A8
-#define V33_PCA_ROLL_OFF_TABLE_SIZE           (17 + (13*4))
-#define V33_PCA_ROLL_OFF_LUT_BANK_SEL_MASK    0x00010000
-
-#define V32_COLOR_COR_OFF 0x00000388
-#define V32_COLOR_COR_LEN 52
-
-#define V32_WB_OFF 0x00000384
-#define V32_WB_LEN 4
-
-#define V32_RGB_G_OFF 0x000003BC
-#define V32_RGB_G_LEN 4
-
-#define V32_LA_OFF 0x000003C0
-#define V32_LA_LEN 4
-
-#define V32_SCE_OFF 0x00000418
-#define V32_SCE_LEN 136
-
-#define V32_CHROMA_SUP_OFF 0x000003E8
-#define V32_CHROMA_SUP_LEN 12
-
-#define V32_MCE_OFF 0x000003F4
-#define V32_MCE_LEN 36
-#define V32_STATS_AF_OFF 0x0000053c
-#define V32_STATS_AF_LEN 16
-
-#define V32_STATS_AE_OFF 0x00000534
-#define V32_STATS_AE_LEN 8
-
-#define V32_STATS_AWB_OFF 0x0000054c
-#define V32_STATS_AWB_LEN 32
-
-#define V32_STATS_IHIST_OFF 0x0000057c
-#define V32_STATS_IHIST_LEN 8
-
-#define V32_STATS_RS_OFF 0x0000056c
-#define V32_STATS_RS_LEN 8
-
-#define V32_STATS_CS_OFF 0x00000574
-#define V32_STATS_CS_LEN 8
-
-
-#define V32_ASF_OFF 0x000004A0
-#define V32_ASF_LEN 48
-#define V32_ASF_UPDATE_LEN 36
-
-#define V32_CAPTURE_LEN 4
-
-#define V32_GET_HW_VERSION_OFF 0
-#define V32_GET_HW_VERSION_LEN 4
-
-#define V32_LINEARIZATION_OFF1 0x00000264
-#define V32_LINEARIZATION_LEN1 16
-
-#define V32_LINEARIZATION_OFF2 0x0000067C
-#define V32_LINEARIZATION_LEN2 52
-
-#define V32_DEMOSAICV3_OFF 0x00000298
-#define V32_DEMOSAICV3_LEN 4
-
-#define V32_DEMOSAICV3_DBPC_CFG_OFF  0x0000029C
-#define V32_DEMOSAICV3_DBPC_LEN 4
-
-#define V32_DEMOSAICV3_DBPC_CFG_OFF0 0x000002a0
-#define V32_DEMOSAICV3_DBPC_CFG_OFF1 0x00000604
-#define V32_DEMOSAICV3_DBPC_CFG_OFF2 0x00000608
-
-#define V32_DEMOSAICV3_DBCC_OFF 0x0000060C
-#define V32_DEMOSAICV3_DBCC_LEN 16
-
-#define V32_DEMOSAICV3_ABF_OFF 0x000002A4
-#define V32_DEMOSAICV3_ABF_LEN 180
-
-#define V32_MODULE_CFG_OFF 0x00000010
-#define V32_MODULE_CFG_LEN 4
-
-#define V32_ASF_SPECIAL_EFX_CFG_OFF 0x000005FC
-#define V32_ASF_SPECIAL_EFX_CFG_LEN 4
-
-#define V32_CLF_CFG_OFF 0x000006B0
-#define V32_CLF_CFG_LEN 72
-
-#define V32_CLF_LUMA_UPDATE_OFF 0x000006B4
-#define V32_CLF_LUMA_UPDATE_LEN 60
-
-#define V32_CLF_CHROMA_UPDATE_OFF 0x000006F0
-#define V32_CLF_CHROMA_UPDATE_LEN 8
-
-#define V32_STATS_BG_OFF 0x00000700
-#define V32_STATS_BG_LEN 12
-
-#define V32_STATS_BF_OFF 0x0000070c
-#define V32_STATS_BF_LEN 24
-
-#define V32_STATS_BHIST_OFF 0x00000724
-#define V32_STATS_BHIST_LEN 8
-
-struct vfe_cmd_hw_version {
-	uint32_t minorVersion;
-	uint32_t majorVersion;
-	uint32_t coreVersion;
-};
-
-enum VFE_AXI_OUTPUT_MODE {
-	VFE_AXI_OUTPUT_MODE_Output1,
-	VFE_AXI_OUTPUT_MODE_Output2,
-	VFE_AXI_OUTPUT_MODE_Output1AndOutput2,
-	VFE_AXI_OUTPUT_MODE_CAMIFToAXIViaOutput2,
-	VFE_AXI_OUTPUT_MODE_Output2AndCAMIFToAXIViaOutput1,
-	VFE_AXI_OUTPUT_MODE_Output1AndCAMIFToAXIViaOutput2,
-	VFE_AXI_LAST_OUTPUT_MODE_ENUM
-};
-
-enum VFE_RAW_WR_PATH_SEL {
-	VFE_RAW_OUTPUT_DISABLED,
-	VFE_RAW_OUTPUT_ENC_CBCR_PATH,
-	VFE_RAW_OUTPUT_VIEW_CBCR_PATH,
-	VFE_RAW_OUTPUT_PATH_INVALID
-};
-
-
-#define VFE_AXI_OUTPUT_BURST_LENGTH     4
-#define VFE_MAX_NUM_FRAGMENTS_PER_FRAME 4
-#define VFE_AXI_OUTPUT_CFG_FRAME_COUNT  3
-
-struct vfe_cmds_per_write_master {
-	uint16_t imageWidth;
-	uint16_t imageHeight;
-	uint16_t outRowCount;
-	uint16_t outRowIncrement;
-	uint32_t outFragments[VFE_AXI_OUTPUT_CFG_FRAME_COUNT]
-		[VFE_MAX_NUM_FRAGMENTS_PER_FRAME];
-};
-
-struct vfe_cmds_axi_per_output_path {
-	uint8_t fragmentCount;
-	struct vfe_cmds_per_write_master firstWM;
-	struct vfe_cmds_per_write_master secondWM;
-};
-
-enum VFE_AXI_BURST_LENGTH {
-	VFE_AXI_BURST_LENGTH_IS_2  = 2,
-	VFE_AXI_BURST_LENGTH_IS_4  = 4,
-	VFE_AXI_BURST_LENGTH_IS_8  = 8,
-	VFE_AXI_BURST_LENGTH_IS_16 = 16
-};
-
-
-struct vfe_cmd_fov_crop_config {
-	uint8_t enable;
-	uint16_t firstPixel;
-	uint16_t lastPixel;
-	uint16_t firstLine;
-	uint16_t lastLine;
-};
-
-struct vfe_cmds_main_scaler_stripe_init {
-	uint16_t MNCounterInit;
-	uint16_t phaseInit;
-};
-
-struct vfe_cmds_scaler_one_dimension {
-	uint8_t  enable;
-	uint16_t inputSize;
-	uint16_t outputSize;
-	uint32_t phaseMultiplicationFactor;
-	uint8_t  interpolationResolution;
-};
-
-struct vfe_cmd_main_scaler_config {
-	uint8_t enable;
-	struct vfe_cmds_scaler_one_dimension    hconfig;
-	struct vfe_cmds_scaler_one_dimension    vconfig;
-	struct vfe_cmds_main_scaler_stripe_init MNInitH;
-	struct vfe_cmds_main_scaler_stripe_init MNInitV;
-};
-
-struct vfe_cmd_scaler2_config {
-	uint8_t enable;
-	struct vfe_cmds_scaler_one_dimension hconfig;
-	struct vfe_cmds_scaler_one_dimension vconfig;
-};
-
-
-struct vfe_cmd_frame_skip_update {
-	uint32_t output1Pattern;
-	uint32_t output2Pattern;
-};
-
-struct vfe_cmd_output_clamp_config {
-	uint8_t minCh0;
-	uint8_t minCh1;
-	uint8_t minCh2;
-	uint8_t maxCh0;
-	uint8_t maxCh1;
-	uint8_t maxCh2;
-};
-
-struct vfe_cmd_chroma_subsample_config {
-	uint8_t enable;
-	uint8_t cropEnable;
-	uint8_t vsubSampleEnable;
-	uint8_t hsubSampleEnable;
-	uint8_t vCosited;
-	uint8_t hCosited;
-	uint8_t vCositedPhase;
-	uint8_t hCositedPhase;
-	uint16_t cropWidthFirstPixel;
-	uint16_t cropWidthLastPixel;
-	uint16_t cropHeightFirstLine;
-	uint16_t cropHeightLastLine;
-};
-
-enum VFE_START_PIXEL_PATTERN {
-	VFE_BAYER_RGRGRG,
-	VFE_BAYER_GRGRGR,
-	VFE_BAYER_BGBGBG,
-	VFE_BAYER_GBGBGB,
-	VFE_YUV_YCbYCr,
-	VFE_YUV_YCrYCb,
-	VFE_YUV_CbYCrY,
-	VFE_YUV_CrYCbY
-};
-
-enum VFE_BUS_RD_INPUT_PIXEL_PATTERN {
-	VFE_BAYER_RAW,
-	VFE_YUV_INTERLEAVED,
-	VFE_YUV_PSEUDO_PLANAR_Y,
-	VFE_YUV_PSEUDO_PLANAR_CBCR
-};
-
-enum VFE_YUV_INPUT_COSITING_MODE {
-	VFE_YUV_COSITED,
-	VFE_YUV_INTERPOLATED
-};
-
-#define VFE32_GAMMA_NUM_ENTRIES  64
-
-#define VFE32_LA_TABLE_LENGTH    64
-
-#define VFE32_LINEARIZATON_TABLE_LENGTH    36
-
-struct vfe_cmds_demosaic_abf {
-	uint8_t   enable;
-	uint8_t   forceOn;
-	uint8_t   shift;
-	uint16_t  lpThreshold;
-	uint16_t  max;
-	uint16_t  min;
-	uint8_t   ratio;
-};
-
-struct vfe_cmds_demosaic_bpc {
-	uint8_t   enable;
-	uint16_t  fmaxThreshold;
-	uint16_t  fminThreshold;
-	uint16_t  redDiffThreshold;
-	uint16_t  blueDiffThreshold;
-	uint16_t  greenDiffThreshold;
-};
-
-struct vfe_cmd_demosaic_config {
-	uint8_t   enable;
-	uint8_t   slopeShift;
-	struct vfe_cmds_demosaic_abf abfConfig;
-	struct vfe_cmds_demosaic_bpc bpcConfig;
-};
-
-struct vfe_cmd_demosaic_bpc_update {
-	struct vfe_cmds_demosaic_bpc bpcUpdate;
-};
-
-struct vfe_cmd_demosaic_abf_update {
-	struct vfe_cmds_demosaic_abf abfUpdate;
-};
-
-struct vfe_cmd_white_balance_config {
-	uint8_t  enable;
-	uint16_t ch2Gain;
-	uint16_t ch1Gain;
-	uint16_t ch0Gain;
-};
-
-enum VFE_COLOR_CORRECTION_COEF_QFACTOR {
-	COEF_IS_Q7_SIGNED,
-	COEF_IS_Q8_SIGNED,
-	COEF_IS_Q9_SIGNED,
-	COEF_IS_Q10_SIGNED
-};
-
-struct vfe_cmd_color_correction_config {
-	uint8_t     enable;
-	enum VFE_COLOR_CORRECTION_COEF_QFACTOR coefQFactor;
-	int16_t  C0;
-	int16_t  C1;
-	int16_t  C2;
-	int16_t  C3;
-	int16_t  C4;
-	int16_t  C5;
-	int16_t  C6;
-	int16_t  C7;
-	int16_t  C8;
-	int16_t  K0;
-	int16_t  K1;
-	int16_t  K2;
-};
-
-#define VFE_LA_TABLE_LENGTH 64
-
-struct vfe_cmd_la_config {
-	uint8_t enable;
-	int16_t table[VFE_LA_TABLE_LENGTH];
-};
-
-#define VFE_GAMMA_TABLE_LENGTH 256
-enum VFE_RGB_GAMMA_TABLE_SELECT {
-	RGB_GAMMA_CH0_SELECTED,
-	RGB_GAMMA_CH1_SELECTED,
-	RGB_GAMMA_CH2_SELECTED,
-	RGB_GAMMA_CH0_CH1_SELECTED,
-	RGB_GAMMA_CH0_CH2_SELECTED,
-	RGB_GAMMA_CH1_CH2_SELECTED,
-	RGB_GAMMA_CH0_CH1_CH2_SELECTED
-};
-
-struct vfe_cmd_rgb_gamma_config {
-	uint8_t enable;
-	enum VFE_RGB_GAMMA_TABLE_SELECT channelSelect;
-	int16_t table[VFE_GAMMA_TABLE_LENGTH];
-};
-
-struct vfe_cmd_chroma_enhan_config {
-	uint8_t  enable;
-	int16_t am;
-	int16_t ap;
-	int16_t bm;
-	int16_t bp;
-	int16_t cm;
-	int16_t cp;
-	int16_t dm;
-	int16_t dp;
-	int16_t kcr;
-	int16_t kcb;
-	int16_t RGBtoYConversionV0;
-	int16_t RGBtoYConversionV1;
-	int16_t RGBtoYConversionV2;
-	uint8_t RGBtoYConversionOffset;
-};
-
-struct vfe_cmd_chroma_suppression_config {
-	uint8_t enable;
-	uint8_t m1;
-	uint8_t m3;
-	uint8_t n1;
-	uint8_t n3;
-	uint8_t nn1;
-	uint8_t mm1;
-};
-
-struct vfe_cmd_asf_config {
-	uint8_t enable;
-	uint8_t smoothFilterEnabled;
-	uint8_t sharpMode;
-	uint8_t smoothCoefCenter;
-	uint8_t smoothCoefSurr;
-	uint8_t normalizeFactor;
-	uint8_t sharpK1;
-	uint8_t sharpK2;
-	uint8_t sharpThreshE1;
-	int8_t sharpThreshE2;
-	int8_t sharpThreshE3;
-	int8_t sharpThreshE4;
-	int8_t sharpThreshE5;
-	int8_t filter1Coefficients[9];
-	int8_t filter2Coefficients[9];
-	uint8_t  cropEnable;
-	uint16_t cropFirstPixel;
-	uint16_t cropLastPixel;
-	uint16_t cropFirstLine;
-	uint16_t cropLastLine;
-};
-
-struct vfe_cmd_asf_update {
-	uint8_t enable;
-	uint8_t smoothFilterEnabled;
-	uint8_t sharpMode;
-	uint8_t smoothCoefCenter;
-	uint8_t smoothCoefSurr;
-	uint8_t normalizeFactor;
-	uint8_t sharpK1;
-	uint8_t sharpK2;
-	uint8_t sharpThreshE1;
-	int8_t  sharpThreshE2;
-	int8_t  sharpThreshE3;
-	int8_t  sharpThreshE4;
-	int8_t  sharpThreshE5;
-	int8_t  filter1Coefficients[9];
-	int8_t  filter2Coefficients[9];
-	uint8_t cropEnable;
-};
-
-enum VFE_TEST_GEN_SYNC_EDGE {
-	VFE_TEST_GEN_SYNC_EDGE_ActiveHigh,
-	VFE_TEST_GEN_SYNC_EDGE_ActiveLow
-};
-
-
-struct vfe_cmd_bus_pm_start {
-	uint8_t output2YWrPmEnable;
-	uint8_t output2CbcrWrPmEnable;
-	uint8_t output1YWrPmEnable;
-	uint8_t output1CbcrWrPmEnable;
-};
-
-struct  vfe_frame_skip_counts {
-	uint32_t  totalFrameCount;
-	uint32_t  output1Count;
-	uint32_t  output2Count;
-};
-
-enum VFE_AXI_RD_UNPACK_HBI_SEL {
-	VFE_AXI_RD_HBI_32_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_64_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_128_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_256_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_512_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_1024_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_2048_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_4096_CLOCK_CYCLES
-};
-
-struct vfe_frame_bpc_info {
-	uint32_t greenDefectPixelCount;
-	uint32_t redBlueDefectPixelCount;
-};
-
-struct vfe_frame_asf_info {
-	uint32_t  asfMaxEdge;
-	uint32_t  asfHbiCount;
-};
-
-struct vfe_msg_camif_status {
-	uint8_t  camifState;
-	uint32_t pixelCount;
-	uint32_t lineCount;
-};
-
-struct vfe32_irq_status {
-	uint32_t vfeIrqStatus0;
-	uint32_t vfeIrqStatus1;
-	uint32_t camifStatus;
-	uint32_t demosaicStatus;
-	uint32_t asfMaxEdge;
-};
-
-#define V32_PREVIEW_AXI_FLAG  0x00000001
-#define V32_SNAPSHOT_AXI_FLAG (0x00000001<<1)
-
-struct vfe32_cmd_type {
-	uint16_t id;
-	uint32_t length;
-	uint32_t offset;
-	uint32_t flag;
-};
-
-struct vfe32_free_buf {
-	struct list_head node;
-	uint32_t paddr;
-	uint32_t y_off;
-	uint32_t cbcr_off;
-};
-
-struct vfe32_output_ch {
-	struct list_head free_buf_queue;
-	spinlock_t free_buf_lock;
-	uint32_t inst_handle;
-	int8_t ch0;
-	int8_t ch1;
-	int8_t ch2;
-	int32_t  capture_cnt;
-	uint32_t  frame_drop_cnt;
-	struct msm_free_buf ping;
-	struct msm_free_buf pong;
-	struct msm_free_buf free_buf;
-};
-
-/* no error irq in mask 0 */
-#define VFE32_IMASK_ERROR_ONLY_0  0x0
-/* when normal case, don't want to block error status. */
-/* bit 0-21 are error irq bits */
-#define VFE32_IMASK_COMMON_ERROR_ONLY_1       0x00407F00
-#define VFE32_IMASK_VFE_ERROR_ONLY_1          0x001F80FF
-#define VFE32_IMASK_CAMIF_ERROR               (0x00000001<<0)
-#define VFE32_IMASK_BHIST_OVWR                (0x00000001<<1)
-#define VFE32_IMASK_STATS_CS_OVWR             (0x00000001<<2)
-#define VFE32_IMASK_STATS_IHIST_OVWR          (0x00000001<<3)
-#define VFE32_IMASK_REALIGN_BUF_Y_OVFL        (0x00000001<<4)
-#define VFE32_IMASK_REALIGN_BUF_CB_OVFL       (0x00000001<<5)
-#define VFE32_IMASK_REALIGN_BUF_CR_OVFL       (0x00000001<<6)
-#define VFE32_IMASK_VIOLATION                 (0x00000001<<7)
-#define VFE32_IMASK_IMG_MAST_0_BUS_OVFL       (0x00000001<<8)
-#define VFE32_IMASK_IMG_MAST_1_BUS_OVFL       (0x00000001<<9)
-#define VFE32_IMASK_IMG_MAST_2_BUS_OVFL       (0x00000001<<10)
-#define VFE32_IMASK_IMG_MAST_3_BUS_OVFL       (0x00000001<<11)
-#define VFE32_IMASK_IMG_MAST_4_BUS_OVFL       (0x00000001<<12)
-#define VFE32_IMASK_IMG_MAST_5_BUS_OVFL       (0x00000001<<13)
-#define VFE32_IMASK_IMG_MAST_6_BUS_OVFL       (0x00000001<<14)
-#define VFE32_IMASK_STATS_AE_BG_BUS_OVFL      (0x00000001<<15)
-#define VFE32_IMASK_STATS_AF_BF_BUS_OVFL      (0x00000001<<16)
-#define VFE32_IMASK_STATS_AWB_BUS_OVFL        (0x00000001<<17)
-#define VFE32_IMASK_STATS_RS_BUS_OVFL         (0x00000001<<18)
-#define VFE32_IMASK_STATS_CS_BUS_OVFL         (0x00000001<<19)
-#define VFE32_IMASK_STATS_IHIST_BUS_OVFL      (0x00000001<<20)
-#define VFE32_IMASK_STATS_SKIN_BHIST_BUS_OVFL (0x00000001<<21)
-#define VFE32_IMASK_AXI_ERROR                 (0x00000001<<22)
-
-#define VFE_COM_STATUS 0x000FE000
-
-struct vfe32_output_path {
-	uint16_t output_mode;     /* bitmask  */
-
-	struct vfe32_output_ch out0; /* preview and thumbnail */
-	struct vfe32_output_ch out1; /* snapshot */
-	struct vfe32_output_ch out2; /* rdi0    */
-	struct vfe32_output_ch out3; /* rdi01   */
-};
-
-struct vfe32_frame_extra {
-	uint32_t greenDefectPixelCount;
-	uint32_t redBlueDefectPixelCount;
-
-	uint32_t  asfMaxEdge;
-	uint32_t  asfHbiCount;
-
-	uint32_t yWrPmStats0;
-	uint32_t yWrPmStats1;
-	uint32_t cbcrWrPmStats0;
-	uint32_t cbcrWrPmStats1;
-
-	uint32_t  frameCounter;
-};
-
-#define VFE_DISABLE_ALL_IRQS            0
-#define VFE_CLEAR_ALL_IRQS              0xffffffff
-
-#define VFE_HW_VERSION			0x00000000
-#define VFE_GLOBAL_RESET                0x00000004
-#define VFE_MODULE_RESET		0x00000008
-#define VFE_CGC_OVERRIDE                0x0000000C
-#define VFE_MODULE_CFG                  0x00000010
-#define VFE_CFG				0x00000014
-#define VFE_IRQ_CMD                     0x00000018
-#define VFE_IRQ_MASK_0                  0x0000001C
-#define VFE_IRQ_MASK_1                  0x00000020
-#define VFE_IRQ_CLEAR_0                 0x00000024
-#define VFE_IRQ_CLEAR_1                 0x00000028
-#define VFE_IRQ_STATUS_0                0x0000002C
-#define VFE_IRQ_STATUS_1                0x00000030
-#define VFE_IRQ_COMP_MASK               0x00000034
-#define VFE_BUS_CMD                     0x00000038
-#define VFE_BUS_PING_PONG_STATUS        0x00000180
-#define VFE_AXI_CMD                     0x000001D8
-#define VFE_AXI_STATUS        0x000001DC
-#define VFE_BUS_STATS_PING_PONG_BASE    0x000000F4
-
-#define VFE_BUS_STATS_AEC_BG_WR_PING_ADDR    0x000000F4
-#define VFE_BUS_STATS_AEC_BG_WR_PONG_ADDR    0x000000F8
-#define VFE_BUS_STATS_AEC_BG_UB_CFG          0x000000FC
-#define VFE_BUS_STATS_AF_BF_WR_PING_ADDR     0x00000100
-#define VFE_BUS_STATS_AF_BF_WR_PONG_ADDR     0x00000104
-#define VFE_BUS_STATS_AF_BF_UB_CFG           0x00000108
-#define VFE_BUS_STATS_AWB_WR_PING_ADDR    0x0000010C
-#define VFE_BUS_STATS_AWB_WR_PONG_ADDR    0x00000110
-#define VFE_BUS_STATS_AWB_UB_CFG          0x00000114
-#define VFE_BUS_STATS_RS_WR_PING_ADDR    0x00000118
-#define VFE_BUS_STATS_RS_WR_PONG_ADDR    0x0000011C
-#define VFE_BUS_STATS_RS_UB_CFG          0x00000120
-
-#define VFE_BUS_STATS_CS_WR_PING_ADDR    0x00000124
-#define VFE_BUS_STATS_CS_WR_PONG_ADDR    0x00000128
-#define VFE_BUS_STATS_CS_UB_CFG          0x0000012C
-#define VFE_BUS_STATS_HIST_WR_PING_ADDR   0x00000130
-#define VFE_BUS_STATS_HIST_WR_PONG_ADDR   0x00000134
-#define VFE_BUS_STATS_HIST_UB_CFG          0x00000138
-#define VFE_BUS_STATS_SKIN_BHIST_WR_PING_ADDR    0x0000013C
-#define VFE_BUS_STATS_SKIN_BHIST_WR_PONG_ADDR    0x00000140
-#define VFE_BUS_STATS_SKIN_BHIST_UB_CFG          0x00000144
-#define VFE_CAMIF_COMMAND               0x000001E0
-#define VFE_CAMIF_STATUS                0x00000204
-#define VFE_REG_UPDATE_CMD              0x00000260
-#define VFE_DEMUX_GAIN_0                0x00000288
-#define VFE_DEMUX_GAIN_1                0x0000028C
-#define VFE_CHROMA_UP                   0x0000035C
-#define VFE_FRAMEDROP_ENC_Y_CFG         0x00000504
-#define VFE_FRAMEDROP_ENC_CBCR_CFG      0x00000508
-#define VFE_FRAMEDROP_ENC_Y_PATTERN     0x0000050C
-#define VFE_FRAMEDROP_ENC_CBCR_PATTERN  0x00000510
-#define VFE_FRAMEDROP_VIEW_Y            0x00000514
-#define VFE_FRAMEDROP_VIEW_CBCR         0x00000518
-#define VFE_FRAMEDROP_VIEW_Y_PATTERN    0x0000051C
-#define VFE_FRAMEDROP_VIEW_CBCR_PATTERN 0x00000520
-#define VFE_CLAMP_MAX                   0x00000524
-#define VFE_CLAMP_MIN                   0x00000528
-#define VFE_REALIGN_BUF                 0x0000052C
-#define VFE_STATS_CFG                   0x00000530
-#define VFE_STATS_AWB_SGW_CFG           0x00000554
-#define VFE_DMI_CFG                     0x00000598
-#define VFE_DMI_ADDR                    0x0000059C
-#define VFE_DMI_DATA_HI                 0x000005A0
-#define VFE_DMI_DATA_LO                 0x000005A4
-#define VFE_AXI_CFG                     0x00000600
-#define VFE_BUS_IO_FORMAT_CFG           0x000006F8
-#define VFE_PIXEL_IF_CFG                0x000006FC
-#define VFE_RDI0_CFG                    0x00000734
-#define VFE_RDI1_CFG                    0x000007A4
-
-#define VFE_VIOLATION_STATUS            0x000007B4
-
-#define VFE33_DMI_DATA_HI               0x000005A0
-#define VFE33_DMI_DATA_LO               0x000005A4
-
-#define VFE_AXI_CFG_MASK                0xFFFFFFFF
-
-#define VFE32_OUTPUT_MODE_PT			BIT(0)
-#define VFE32_OUTPUT_MODE_S			BIT(1)
-#define VFE32_OUTPUT_MODE_V			BIT(2)
-#define VFE32_OUTPUT_MODE_P			BIT(3)
-#define VFE32_OUTPUT_MODE_T			BIT(4)
-#define VFE32_OUTPUT_MODE_P_ALL_CHNLS		BIT(5)
-#define VFE32_OUTPUT_MODE_PRIMARY		BIT(6)
-#define VFE32_OUTPUT_MODE_PRIMARY_ALL_CHNLS	BIT(7)
-#define VFE32_OUTPUT_MODE_SECONDARY		BIT(8)
-#define VFE32_OUTPUT_MODE_SECONDARY_ALL_CHNLS	BIT(9)
-#define VFE32_OUTPUT_MODE_TERTIARY1		BIT(10)
-#define VFE32_OUTPUT_MODE_TERTIARY2		BIT(11)
-
-struct vfe_stats_control {
-	uint32_t droppedStatsFrameCount;
-	uint32_t bufToRender;
-};
-struct axi_ctrl_t;
-struct vfe32_ctrl_type;
-
-struct vfe_share_ctrl_t {
-	void __iomem *vfebase;
-	uint32_t register_total;
-
-	atomic_t vstate;
-	atomic_t handle_common_irq;
-	uint32_t vfeFrameId;
-	uint32_t rdi0FrameId;
-	uint32_t rdi1FrameId;
-	uint32_t rdi2FrameId;
-	uint32_t stats_comp;
-	spinlock_t  sd_notify_lock;
-	spinlock_t  stop_flag_lock;
-	int8_t stop_ack_pending;
-	enum vfe_output_state liveshot_state;
-	uint32_t vfe_capture_count;
-	int32_t rdi0_capture_count;
-	int32_t rdi1_capture_count;
-	uint8_t update_counter;
-
-	uint32_t operation_mode;     /* streaming or snapshot */
-	uint32_t current_mode;
-	struct vfe32_output_path outpath;
-
-	uint16_t port_info;
-	uint8_t stop_immediately;
-	uint8_t sync_abort;
-	uint16_t cmd_type;
-	uint8_t vfe_reset_flag;
-	uint8_t dual_enabled;
-
-	uint8_t axi_ref_cnt;
-	uint16_t comp_output_mode;
-
-	struct completion reset_complete;
-
-	spinlock_t  update_ack_lock;
-	spinlock_t  start_ack_lock;
-
-	struct axi_ctrl_t *axi_ctrl;
-	struct vfe32_ctrl_type *vfe32_ctrl;
-	int8_t start_ack_pending;
-	int8_t update_ack_pending;
-	enum vfe_output_state recording_state;
-
-	atomic_t pix0_update_ack_pending;
-	atomic_t rdi0_update_ack_pending;
-	atomic_t rdi1_update_ack_pending;
-	atomic_t rdi2_update_ack_pending;
-
-};
-
-struct axi_ctrl_t {
-	struct v4l2_subdev subdev;
-	struct platform_device *pdev;
-	struct resource *vfeirq;
-	spinlock_t  tasklet_lock;
-	struct list_head tasklet_q;
-
-	void *syncdata;
-
-	struct resource	*vfemem;
-	struct resource *vfeio;
-	struct regulator *fs_vfe;
-	struct clk *vfe_clk[3];
-	struct tasklet_struct vfe32_tasklet;
-	struct vfe_share_ctrl_t *share_ctrl;
-	struct device *iommu_ctx_imgwr;
-	struct device *iommu_ctx_misc;
-};
-
-struct vfe32_ctrl_type {
-	spinlock_t  state_lock;
-	spinlock_t  stats_bufq_lock;
-	uint32_t extlen;
-	void *extdata;
-
-	int8_t vfe_sof_count_enable;
-	int8_t update_linear;
-	int8_t update_rolloff;
-	int8_t update_la;
-	int8_t update_gamma;
-
-	struct vfe_share_ctrl_t *share_ctrl;
-
-	uint32_t sync_timer_repeat_count;
-	uint32_t sync_timer_state;
-	uint32_t sync_timer_number;
-
-	struct msm_ver_num_info ver_num;
-	struct vfe_stats_control afbfStatsControl;
-	struct vfe_stats_control awbStatsControl;
-	struct vfe_stats_control aecbgStatsControl;
-	struct vfe_stats_control ihistStatsControl;
-	struct vfe_stats_control rsStatsControl;
-	struct vfe_stats_control csStatsControl;
-	struct vfe_stats_control bhistStatsControl;
-
-	/* v4l2 subdev */
-	struct v4l2_subdev subdev;
-	struct platform_device *pdev;
-	uint32_t hfr_mode;
-	uint32_t frame_skip_cnt;
-	uint32_t frame_skip_pattern;
-	uint32_t snapshot_frame_cnt;
-	struct msm_stats_bufq_ctrl stats_ctrl;
-	struct msm_stats_ops stats_ops;
-
-	uint32_t simultaneous_sof_stat;
-};
-
-#define statsAeNum      0
-#define statsAfNum      1
-#define statsAwbNum     2
-#define statsRsNum      3
-#define statsCsNum      4
-#define statsIhistNum   5
-#define statsSkinNum    6
-
-struct vfe_cmd_stats_ack {
-	uint32_t  nextStatsBuf;
-};
-
-#define VFE_STATS_BUFFER_COUNT            3
-
-struct vfe_cmd_stats_buf {
-	uint32_t statsBuf[VFE_STATS_BUFFER_COUNT];
-};
-
-#endif /* __MSM_VFE32_H__ */
diff --git a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe40.c b/drivers/media/platform/msm/camera_v1/vfe/msm_vfe40.c
deleted file mode 100644
index 5a96a79..0000000
--- a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe40.c
+++ /dev/null
@@ -1,6478 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#include <linux/module.h>
-#include <linux/uaccess.h>
-#include <linux/interrupt.h>
-#include <linux/slab.h>
-#include <linux/io.h>
-#include <linux/of.h>
-#include <linux/atomic.h>
-#include <linux/regulator/consumer.h>
-#include <linux/clk.h>
-#include <mach/irqs.h>
-#include <mach/camera.h>
-#include <media/v4l2-device.h>
-#include <media/v4l2-subdev.h>
-#include <media/msm_isp.h>
-#include <mach/msm_bus.h>
-#include <mach/msm_bus_board.h>
-
-#include "msm.h"
-#include "msm_cam_server.h"
-#include "msm_vfe40.h"
-
-atomic_t irq_cnt;
-
-#define VFE_WM_CFG_BASE 0x0070
-#define VFE_WM_CFG_LEN 0x0024
-
-#define vfe40_get_ch_ping_addr(base, chn) \
-	(msm_camera_io_r((base) + VFE_WM_CFG_BASE + VFE_WM_CFG_LEN * (chn)))
-#define vfe40_get_ch_pong_addr(base, chn) \
-	(msm_camera_io_r((base) + VFE_WM_CFG_BASE + VFE_WM_CFG_LEN * (chn) + 4))
-#define vfe40_get_ch_addr(ping_pong, base, chn) \
-	((((ping_pong) & (1 << (chn))) == 0) ? \
-	(vfe40_get_ch_pong_addr((base), chn)) : \
-	(vfe40_get_ch_ping_addr((base), chn)))
-
-#define vfe40_put_ch_ping_addr(base, chn, addr) \
-	(msm_camera_io_w((addr), \
-	(base) + VFE_WM_CFG_BASE + VFE_WM_CFG_LEN * (chn)))
-#define vfe40_put_ch_pong_addr(base, chn, addr) \
-	(msm_camera_io_w((addr), \
-	(base) + VFE_WM_CFG_BASE + VFE_WM_CFG_LEN * (chn) + 4))
-#define vfe40_put_ch_addr(ping_pong, base, chn, addr) \
-	(((ping_pong) & (1 << (chn))) == 0 ?   \
-	vfe40_put_ch_pong_addr((base), (chn), (addr)) : \
-	vfe40_put_ch_ping_addr((base), (chn), (addr)))
-
-static uint32_t vfe_clk_rate;
-static void vfe40_send_isp_msg(struct v4l2_subdev *sd,
-	uint32_t vfeFrameId, uint32_t isp_msg_id);
-
-
-struct vfe40_isr_queue_cmd {
-	struct list_head list;
-	uint32_t                           vfeInterruptStatus0;
-	uint32_t                           vfeInterruptStatus1;
-};
-
-static struct vfe40_cmd_type vfe40_cmd[] = {
-	[1] = {VFE_CMD_SET_CLK},
-	[2] = {VFE_CMD_RESET},
-	[3] = {VFE_CMD_START},
-	[4] = {VFE_CMD_TEST_GEN_START},
-	[5] = {VFE_CMD_OPERATION_CFG, V40_OPERATION_CFG_LEN},
-	[6] = {VFE_CMD_AXI_OUT_CFG, V40_AXI_OUT_LEN, V40_AXI_BUS_CMD_OFF, 0xFF},
-	[7] = {VFE_CMD_CAMIF_CFG, V40_CAMIF_LEN, V40_CAMIF_OFF, 0xFF},
-	[8] = {VFE_CMD_AXI_INPUT_CFG},
-	[9] = {VFE_CMD_BLACK_LEVEL_CFG},
-	[10] = {VFE_CMD_MESH_ROLL_OFF_CFG, V40_MESH_ROLL_OFF_CFG_LEN,
-		V40_MESH_ROLL_OFF_CFG_OFF, 0xFF},
-	[11] = {VFE_CMD_DEMUX_CFG, V40_DEMUX_LEN, V40_DEMUX_OFF, 0xFF},
-	[12] = {VFE_CMD_FOV_CFG},
-	[13] = {VFE_CMD_MAIN_SCALER_CFG},
-	[14] = {VFE_CMD_WB_CFG, V40_WB_LEN, V40_WB_OFF, 0xFF},
-	[15] = {VFE_CMD_COLOR_COR_CFG, V40_COLOR_COR_LEN,
-		V40_COLOR_COR_OFF, 0xFF},
-	[16] = {VFE_CMD_RGB_G_CFG, V40_RGB_G_LEN, V40_RGB_G_OFF, 0xFF},
-	[17] = {VFE_CMD_LA_CFG, V40_LA_LEN, V40_LA_OFF, 0xFF },
-	[18] = {VFE_CMD_CHROMA_EN_CFG, V40_CHROMA_EN_LEN, V40_CHROMA_EN_OFF,
-		0xFF},
-	[19] = {VFE_CMD_CHROMA_SUP_CFG, V40_CHROMA_SUP_LEN,
-		V40_CHROMA_SUP_OFF, 0xFF},
-	[20] = {VFE_CMD_MCE_CFG, V40_MCE_LEN, V40_MCE_OFF, 0xFF},
-	[21] = {VFE_CMD_SK_ENHAN_CFG, V40_SCE_LEN, V40_SCE_OFF, 0xFF},
-	[22] = {VFE_CMD_ASF_CFG, V40_ASF_LEN, V40_ASF_OFF, 0xFF},
-	[23] = {VFE_CMD_S2Y_CFG},
-	[24] = {VFE_CMD_S2CbCr_CFG},
-	[25] = {VFE_CMD_CHROMA_SUBS_CFG},
-	[26] = {VFE_CMD_OUT_CLAMP_CFG, V40_OUT_CLAMP_LEN, V40_OUT_CLAMP_OFF,
-		0xFF},
-	[27] = {VFE_CMD_FRAME_SKIP_CFG},
-	[31] = {VFE_CMD_UPDATE},
-	[32] = {VFE_CMD_BL_LVL_UPDATE},
-	[33] = {VFE_CMD_DEMUX_UPDATE, V40_DEMUX_LEN, V40_DEMUX_OFF, 0xFF},
-	[34] = {VFE_CMD_FOV_UPDATE},
-	[35] = {VFE_CMD_MAIN_SCALER_UPDATE},
-	[36] = {VFE_CMD_WB_UPDATE, V40_WB_LEN, V40_WB_OFF, 0xFF},
-	[37] = {VFE_CMD_COLOR_COR_UPDATE, V40_COLOR_COR_LEN,
-		V40_COLOR_COR_OFF, 0xFF},
-	[38] = {VFE_CMD_RGB_G_UPDATE, V40_RGB_G_LEN, V40_CHROMA_EN_OFF, 0xFF},
-	[39] = {VFE_CMD_LA_UPDATE, V40_LA_LEN, V40_LA_OFF, 0xFF },
-	[40] = {VFE_CMD_CHROMA_EN_UPDATE, V40_CHROMA_EN_LEN,
-		V40_CHROMA_EN_OFF, 0xFF},
-	[41] = {VFE_CMD_CHROMA_SUP_UPDATE, V40_CHROMA_SUP_LEN,
-		V40_CHROMA_SUP_OFF, 0xFF},
-	[42] = {VFE_CMD_MCE_UPDATE, V40_MCE_LEN, V40_MCE_OFF, 0xFF},
-	[43] = {VFE_CMD_SK_ENHAN_UPDATE, V40_SCE_LEN, V40_SCE_OFF, 0xFF},
-	[44] = {VFE_CMD_S2CbCr_UPDATE},
-	[45] = {VFE_CMD_S2Y_UPDATE},
-	[46] = {VFE_CMD_ASF_UPDATE, V40_ASF_UPDATE_LEN, V40_ASF_OFF, 0xFF},
-	[47] = {VFE_CMD_FRAME_SKIP_UPDATE},
-	[48] = {VFE_CMD_CAMIF_FRAME_UPDATE},
-	[49] = {VFE_CMD_STATS_AF_UPDATE},
-	[50] = {VFE_CMD_STATS_AE_UPDATE},
-	[51] = {VFE_CMD_STATS_AWB_UPDATE, V40_STATS_AWB_LEN,
-		V40_STATS_AWB_OFF},
-	[52] = {VFE_CMD_STATS_RS_UPDATE, V40_STATS_RS_LEN, V40_STATS_RS_OFF},
-	[53] = {VFE_CMD_STATS_CS_UPDATE, V40_STATS_CS_LEN, V40_STATS_CS_OFF},
-	[54] = {VFE_CMD_STATS_SKIN_UPDATE},
-	[55] = {VFE_CMD_STATS_IHIST_UPDATE, V40_STATS_IHIST_LEN,
-		V40_STATS_IHIST_OFF},
-	[57] = {VFE_CMD_EPOCH1_ACK},
-	[58] = {VFE_CMD_EPOCH2_ACK},
-	[59] = {VFE_CMD_START_RECORDING},
-	[60] = {VFE_CMD_STOP_RECORDING},
-	[63] = {VFE_CMD_CAPTURE, V40_CAPTURE_LEN, 0xFF},
-	[65] = {VFE_CMD_STOP},
-	[66] = {VFE_CMD_GET_HW_VERSION, V40_GET_HW_VERSION_LEN,
-		V40_GET_HW_VERSION_OFF},
-	[67] = {VFE_CMD_GET_FRAME_SKIP_COUNTS},
-	[68] = {VFE_CMD_OUTPUT1_BUFFER_ENQ},
-	[69] = {VFE_CMD_OUTPUT2_BUFFER_ENQ},
-	[70] = {VFE_CMD_OUTPUT3_BUFFER_ENQ},
-	[71] = {VFE_CMD_JPEG_OUT_BUF_ENQ},
-	[72] = {VFE_CMD_RAW_OUT_BUF_ENQ},
-	[73] = {VFE_CMD_RAW_IN_BUF_ENQ},
-	[74] = {VFE_CMD_STATS_AF_ENQ},
-	[75] = {VFE_CMD_STATS_AE_ENQ},
-	[76] = {VFE_CMD_STATS_AWB_ENQ},
-	[77] = {VFE_CMD_STATS_RS_ENQ},
-	[78] = {VFE_CMD_STATS_CS_ENQ},
-	[79] = {VFE_CMD_STATS_SKIN_ENQ},
-	[80] = {VFE_CMD_STATS_IHIST_ENQ},
-	[82] = {VFE_CMD_JPEG_ENC_CFG},
-	[84] = {VFE_CMD_STATS_AF_START},
-	[85] = {VFE_CMD_STATS_AF_STOP},
-	[86] = {VFE_CMD_STATS_AE_START},
-	[87] = {VFE_CMD_STATS_AE_STOP},
-	[88] = {VFE_CMD_STATS_AWB_START, V40_STATS_AWB_LEN, V40_STATS_AWB_OFF},
-	[89] = {VFE_CMD_STATS_AWB_STOP},
-	[90] = {VFE_CMD_STATS_RS_START, V40_STATS_RS_LEN, V40_STATS_RS_OFF},
-	[91] = {VFE_CMD_STATS_RS_STOP},
-	[92] = {VFE_CMD_STATS_CS_START, V40_STATS_CS_LEN, V40_STATS_CS_OFF},
-	[93] = {VFE_CMD_STATS_CS_STOP},
-	[94] = {VFE_CMD_STATS_SKIN_START},
-	[95] = {VFE_CMD_STATS_SKIN_STOP},
-	[96] = {VFE_CMD_STATS_IHIST_START,
-		V40_STATS_IHIST_LEN, V40_STATS_IHIST_OFF},
-	[97] = {VFE_CMD_STATS_IHIST_STOP},
-	[99] = {VFE_CMD_SYNC_TIMER_SETTING, V40_SYNC_TIMER_LEN,
-			V40_SYNC_TIMER_OFF},
-	[100] = {VFE_CMD_ASYNC_TIMER_SETTING, V40_ASYNC_TIMER_LEN,
-		V40_ASYNC_TIMER_OFF},
-	[101] = {VFE_CMD_LIVESHOT},
-	[102] = {VFE_CMD_LA_SETUP},
-	[103] = {VFE_CMD_LINEARIZATION_CFG, V40_LINEARIZATION_LEN1,
-			V40_LINEARIZATION_OFF1},
-	[104] = {VFE_CMD_DEMOSAICV3},
-	[105] = {VFE_CMD_DEMOSAICV3_ABCC_CFG},
-	[106] = {VFE_CMD_DEMOSAICV3_DBCC_CFG, V40_DEMOSAICV3_DBCC_LEN,
-			V40_DEMOSAICV3_DBCC_OFF},
-	[107] = {VFE_CMD_DEMOSAICV3_DBPC_CFG},
-	[108] = {VFE_CMD_DEMOSAICV3_ABF_CFG, V40_DEMOSAICV3_ABF_LEN,
-			V40_DEMOSAICV3_ABF_OFF},
-	[109] = {VFE_CMD_DEMOSAICV3_ABCC_UPDATE},
-	[110] = {VFE_CMD_DEMOSAICV3_DBCC_UPDATE, V40_DEMOSAICV3_DBCC_LEN,
-			V40_DEMOSAICV3_DBCC_OFF},
-	[111] = {VFE_CMD_DEMOSAICV3_DBPC_UPDATE},
-	[112] = {VFE_CMD_XBAR_CFG},
-	[113] = {VFE_CMD_MODULE_CFG, V40_MODULE_CFG_LEN, V40_MODULE_CFG_OFF},
-	[114] = {VFE_CMD_ZSL},
-	[115] = {VFE_CMD_LINEARIZATION_UPDATE, V40_LINEARIZATION_LEN1,
-			V40_LINEARIZATION_OFF1},
-	[116] = {VFE_CMD_DEMOSAICV3_ABF_UPDATE, V40_DEMOSAICV3_ABF_LEN,
-			V40_DEMOSAICV3_ABF_OFF},
-	[117] = {VFE_CMD_CLF_CFG, V40_CLF_CFG_LEN, V40_CLF_CFG_OFF},
-	[118] = {VFE_CMD_CLF_LUMA_UPDATE, V40_CLF_LUMA_UPDATE_LEN,
-			V40_CLF_LUMA_UPDATE_OFF},
-	[119] = {VFE_CMD_CLF_CHROMA_UPDATE, V40_CLF_CHROMA_UPDATE_LEN,
-			V40_CLF_CHROMA_UPDATE_OFF},
-	[120] = {VFE_CMD_PCA_ROLL_OFF_CFG},
-	[121] = {VFE_CMD_PCA_ROLL_OFF_UPDATE},
-	[122] = {VFE_CMD_GET_REG_DUMP},
-	[123] = {VFE_CMD_GET_LINEARIZATON_TABLE},
-	[124] = {VFE_CMD_GET_MESH_ROLLOFF_TABLE},
-	[125] = {VFE_CMD_GET_PCA_ROLLOFF_TABLE},
-	[126] = {VFE_CMD_GET_RGB_G_TABLE},
-	[127] = {VFE_CMD_GET_LA_TABLE},
-	[128] = {VFE_CMD_DEMOSAICV3_UPDATE},
-	[129] = {VFE_CMD_ACTIVE_REGION_CFG},
-	[130] = {VFE_CMD_COLOR_PROCESSING_CONFIG},
-	[131] = {VFE_CMD_STATS_WB_AEC_CONFIG},
-	[132] = {VFE_CMD_STATS_WB_AEC_UPDATE},
-	[133] = {VFE_CMD_Y_GAMMA_CONFIG},
-	[134] = {VFE_CMD_SCALE_OUTPUT1_CONFIG},
-	[135] = {VFE_CMD_SCALE_OUTPUT2_CONFIG},
-	[136] = {VFE_CMD_CAPTURE_RAW},
-	[137] = {VFE_CMD_STOP_LIVESHOT},
-	[138] = {VFE_CMD_RECONFIG_VFE},
-	[139] = {VFE_CMD_STATS_REQBUF},
-	[140] = {VFE_CMD_STATS_ENQUEUEBUF},
-	[141] = {VFE_CMD_STATS_FLUSH_BUFQ},
-	[142] = {VFE_CMD_STATS_UNREGBUF},
-	[143] = {VFE_CMD_STATS_BG_START, V40_STATS_BG_LEN, V40_STATS_BG_OFF},
-	[144] = {VFE_CMD_STATS_BG_STOP},
-	[145] = {VFE_CMD_STATS_BF_START, V40_STATS_BF_LEN, V40_STATS_BF_OFF},
-	[146] = {VFE_CMD_STATS_BF_STOP},
-	[147] = {VFE_CMD_STATS_BHIST_START, V40_STATS_BHIST_LEN,
-			V40_STATS_BHIST_OFF},
-	[148] = {VFE_CMD_STATS_BHIST_STOP},
-	[149] = {VFE_CMD_RESET_2},
-	[150] = {VFE_CMD_FOV_ENC_CFG, V40_FOV_ENC_LEN,
-		V40_FOV_ENC_OFF, 0xFF},
-	[151] = {VFE_CMD_FOV_VIEW_CFG, V40_FOV_VIEW_LEN,
-		V40_FOV_VIEW_OFF, 0xFF},
-	[152] = {VFE_CMD_FOV_ENC_UPDATE, V40_FOV_ENC_LEN,
-		V40_FOV_ENC_OFF, 0xFF},
-	[153] = {VFE_CMD_FOV_VIEW_UPDATE, V40_FOV_VIEW_LEN,
-		V40_FOV_VIEW_OFF, 0xFF},
-	[154] = {VFE_CMD_SCALER_ENC_CFG, V40_SCALER_ENC_LEN,
-		V40_SCALER_ENC_OFF, 0xFF},
-	[155] = {VFE_CMD_SCALER_VIEW_CFG, V40_SCALER_VIEW_LEN,
-		V40_SCALER_VIEW_OFF, 0xFF},
-	[156] = {VFE_CMD_SCALER_ENC_UPDATE, V40_SCALER_ENC_LEN,
-		V40_SCALER_ENC_OFF, 0xFF},
-	[157] = {VFE_CMD_SCALER_VIEW_UPDATE, V40_SCALER_VIEW_LEN,
-		V40_SCALER_VIEW_OFF, 0xFF},
-	[158] = {VFE_CMD_COLORXFORM_ENC_CFG, V40_COLORXFORM_ENC_CFG_LEN,
-		V40_COLORXFORM_ENC_CFG_OFF, 0xFF},
-	[159] = {VFE_CMD_COLORXFORM_VIEW_CFG, V40_COLORXFORM_VIEW_CFG_LEN,
-		V40_COLORXFORM_VIEW_CFG_OFF},
-	[160] = {VFE_CMD_COLORXFORM_ENC_UPDATE, V40_COLORXFORM_ENC_CFG_LEN,
-		V40_COLORXFORM_ENC_CFG_OFF, 0xFF},
-	[161] = {VFE_CMD_COLORXFORM_VIEW_UPDATE, V40_COLORXFORM_VIEW_CFG_LEN,
-		V40_COLORXFORM_VIEW_CFG_OFF, 0xFF},
-	[163] = {VFE_CMD_STATS_BE_START, V40_STATS_BE_LEN, V40_STATS_BE_OFF},
-	[164] = {VFE_CMD_STATS_BE_STOP},
-};
-
-static const uint32_t vfe40_AXI_WM_CFG[] = {
-	0x0000006C,
-	0x00000090,
-	0x000000B4,
-	0x000000D8,
-	0x000000FC,
-	0x00000120,
-	0x00000144,
-};
-
-static const char * const vfe40_general_cmd[] = {
-	[1] = "SET_CLK",
-	[2] = "RESET",
-	[3] = "START",
-	[4] = "TEST_GEN_START",
-	[5] = "OPERATION_CFG",  /* 5 */
-	[6] = "AXI_OUT_CFG",
-	[7] = "CAMIF_CFG",
-	[8] = "AXI_INPUT_CFG",
-	[9] = "BLACK_LEVEL_CFG",
-	[10] = "ROLL_OFF_CFG",  /* 10 */
-	[11] = "DEMUX_CFG",
-	[12] = "FOV_CFG",
-	[13] = "MAIN_SCALER_CFG",
-	[14] = "WB_CFG",
-	[15] = "COLOR_COR_CFG", /* 15 */
-	[16] = "RGB_G_CFG",
-	[17] = "LA_CFG",
-	[18] = "CHROMA_EN_CFG",
-	[19] = "CHROMA_SUP_CFG",
-	[20] = "MCE_CFG", /* 20 */
-	[21] = "SK_ENHAN_CFG",
-	[22] = "ASF_CFG",
-	[23] = "S2Y_CFG",
-	[24] = "S2CbCr_CFG",
-	[25] = "CHROMA_SUBS_CFG",  /* 25 */
-	[26] = "OUT_CLAMP_CFG",
-	[27] = "FRAME_SKIP_CFG",
-	[31] = "UPDATE",
-	[32] = "BL_LVL_UPDATE",
-	[33] = "DEMUX_UPDATE",
-	[34] = "FOV_UPDATE",
-	[35] = "MAIN_SCALER_UPDATE",  /* 35 */
-	[36] = "WB_UPDATE",
-	[37] = "COLOR_COR_UPDATE",
-	[38] = "RGB_G_UPDATE",
-	[39] = "LA_UPDATE",
-	[40] = "CHROMA_EN_UPDATE",  /* 40 */
-	[41] = "CHROMA_SUP_UPDATE",
-	[42] = "MCE_UPDATE",
-	[43] = "SK_ENHAN_UPDATE",
-	[44] = "S2CbCr_UPDATE",
-	[45] = "S2Y_UPDATE",  /* 45 */
-	[46] = "ASF_UPDATE",
-	[47] = "FRAME_SKIP_UPDATE",
-	[48] = "CAMIF_FRAME_UPDATE",
-	[49] = "STATS_AF_UPDATE",
-	[50] = "STATS_AE_UPDATE",  /* 50 */
-	[51] = "STATS_AWB_UPDATE",
-	[52] = "STATS_RS_UPDATE",
-	[53] = "STATS_CS_UPDATE",
-	[54] = "STATS_SKIN_UPDATE",
-	[55] = "STATS_IHIST_UPDATE",  /* 55 */
-	[57] = "EPOCH1_ACK",
-	[58] = "EPOCH2_ACK",
-	[59] = "START_RECORDING",
-	[60] = "STOP_RECORDING",  /* 60 */
-	[63] = "CAPTURE",
-	[65] = "STOP",  /* 65 */
-	[66] = "GET_HW_VERSION",
-	[67] = "GET_FRAME_SKIP_COUNTS",
-	[68] = "OUTPUT1_BUFFER_ENQ",
-	[69] = "OUTPUT2_BUFFER_ENQ",
-	[70] = "OUTPUT3_BUFFER_ENQ",  /* 70 */
-	[71] = "JPEG_OUT_BUF_ENQ",
-	[72] = "RAW_OUT_BUF_ENQ",
-	[73] = "RAW_IN_BUF_ENQ",
-	[74] = "STATS_AF_ENQ",
-	[75] = "STATS_AE_ENQ",  /* 75 */
-	[76] = "STATS_AWB_ENQ",
-	[77] = "STATS_RS_ENQ",
-	[78] = "STATS_CS_ENQ",
-	[79] = "STATS_SKIN_ENQ",
-	[80] = "STATS_IHIST_ENQ",  /* 80 */
-	[82] = "JPEG_ENC_CFG",
-	[84] = "STATS_AF_START",
-	[85] = "STATS_AF_STOP",  /* 85 */
-	[86] = "STATS_AE_START",
-	[87] = "STATS_AE_STOP",
-	[88] = "STATS_AWB_START",
-	[89] = "STATS_AWB_STOP",
-	[90] = "STATS_RS_START",  /* 90 */
-	[91] = "STATS_RS_STOP",
-	[92] = "STATS_CS_START",
-	[93] = "STATS_CS_STOP",
-	[94] = "STATS_SKIN_START",
-	[95] = "STATS_SKIN_STOP",  /* 95 */
-	[96] = "STATS_IHIST_START",
-	[97] = "STATS_IHIST_STOP",
-	[99] = "SYNC_TIMER_SETTING",
-	[100] = "ASYNC_TIMER_SETTING",  /* 100 */
-	[101] = "LIVESHOT",
-	[102] = "LA_SETUP",
-	[103] = "LINEARIZATION_CFG",
-	[104] = "DEMOSAICV3",
-	[105] = "DEMOSAICV3_ABCC_CFG", /* 105 */
-	[106] = "DEMOSAICV3_DBCC_CFG",
-	[107] = "DEMOSAICV3_DBPC_CFG",
-	[108] = "DEMOSAICV3_ABF_CFG",
-	[109] = "DEMOSAICV3_ABCC_UPDATE",
-	[110] = "DEMOSAICV3_DBCC_UPDATE", /* 110 */
-	[111] = "DEMOSAICV3_DBPC_UPDATE",
-	[112] = "XBAR_CFG",
-	[113] = "EZTUNE_CFG",
-	[114] = "V40_ZSL",
-	[115] = "LINEARIZATION_UPDATE", /*115*/
-	[116] = "DEMOSAICV3_ABF_UPDATE",
-	[117] = "CLF_CFG",
-	[118] = "CLF_LUMA_UPDATE",
-	[119] = "CLF_CHROMA_UPDATE",
-	[120] = "PCA_ROLL_OFF_CFG", /*120*/
-	[121] = "PCA_ROLL_OFF_UPDATE",
-	[122] = "GET_REG_DUMP",
-	[123] = "GET_LINEARIZATON_TABLE",
-	[124] = "GET_MESH_ROLLOFF_TABLE",
-	[125] = "GET_PCA_ROLLOFF_TABLE", /*125*/
-	[126] = "GET_RGB_G_TABLE",
-	[127] = "GET_LA_TABLE",
-	[128] = "DEMOSAICV3_UPDATE",
-	[139] = "STATS_REQBUF",
-	[140] = "STATS_ENQUEUEBUF", /*140*/
-	[141] = "STATS_FLUSH_BUFQ",
-	[142] = "STATS_UNREGBUF",
-	[143] = "STATS_BG_START",
-	[144] = "STATS_BG_STOP",
-	[145] = "STATS_BF_START", /*145*/
-	[146] = "STATS_BF_STOP",
-	[147] = "STATS_BHIST_START",
-	[148] = "STATS_BHIST_STOP",
-	[149] = "RESET_2",
-};
-
-/*Temporary use fixed bus vectors in VFE */
-static struct msm_bus_vectors vfe_init_vectors[] = {
-	{
-		.src = MSM_BUS_MASTER_VFE,
-		.dst = MSM_BUS_SLAVE_EBI_CH0,
-		.ab  = 0,
-		.ib  = 0,
-	},
-};
-
-static struct msm_bus_vectors vfe_preview_vectors[] = {
-	{
-		.src = MSM_BUS_MASTER_VFE,
-		.dst = MSM_BUS_SLAVE_EBI_CH0,
-		.ab  = 27648000,
-		.ib  = 110592000,
-	},
-};
-
-static struct msm_bus_vectors vfe_video_vectors[] = {
-	{
-		.src = MSM_BUS_MASTER_VFE,
-		.dst = MSM_BUS_SLAVE_EBI_CH0,
-		.ab  = 274406400,
-		.ib  = 617103360,
-	},
-};
-
-static struct msm_bus_vectors vfe_liveshot_vectors[] = {
-	{
-		.src = MSM_BUS_MASTER_VFE,
-		.dst = MSM_BUS_SLAVE_EBI_CH0,
-		.ab  = 348192000,
-		.ib  = 617103360,
-	},
-};
-
-static struct msm_bus_vectors vfe_snapshot_vectors[] = {
-	{
-		.src = MSM_BUS_MASTER_VFE,
-		.dst = MSM_BUS_SLAVE_EBI_CH0,
-		.ab  = 274423680,
-		.ib  = 1097694720,
-	},
-};
-
-static struct msm_bus_vectors vfe_zsl_vectors[] = {
-	{
-		.src = MSM_BUS_MASTER_VFE,
-		.dst = MSM_BUS_SLAVE_EBI_CH0,
-		.ab  = 302071680,
-		.ib  = 1208286720,
-	},
-};
-
-static struct msm_bus_paths vfe_bus_client_config[] = {
-	{
-		ARRAY_SIZE(vfe_init_vectors),
-		vfe_init_vectors,
-	},
-	{
-		ARRAY_SIZE(vfe_preview_vectors),
-		vfe_preview_vectors,
-	},
-	{
-		ARRAY_SIZE(vfe_video_vectors),
-		vfe_video_vectors,
-	},
-	{
-		ARRAY_SIZE(vfe_snapshot_vectors),
-		vfe_snapshot_vectors,
-	},
-	{
-		ARRAY_SIZE(vfe_zsl_vectors),
-		vfe_zsl_vectors,
-	},
-	{
-		ARRAY_SIZE(vfe_liveshot_vectors),
-		vfe_liveshot_vectors,
-	},
-};
-
-static struct msm_bus_scale_pdata vfe_bus_client_pdata = {
-		vfe_bus_client_config,
-		ARRAY_SIZE(vfe_bus_client_config),
-		.name = "msm_camera_vfe",
-};
-
-uint8_t vfe40_use_bayer_stats(struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	if (vfe40_ctrl->ver_num.main >= 4) {
-		/* VFE 4 or above uses bayer stats */
-		return TRUE;
-	} else {
-		return FALSE;
-	}
-}
-
-static void axi_enable_irq(struct vfe_share_ctrl_t *share_ctrl)
-{
-	uint32_t irq_mask;
-	uint16_t vfe_operation_mode =
-		share_ctrl->current_mode & ~(VFE_OUTPUTS_RDI0|
-			VFE_OUTPUTS_RDI1);
-	irq_mask =
-		msm_camera_io_r(share_ctrl->vfebase +
-			VFE_IRQ_MASK_0);
-
-	irq_mask |= VFE_IMASK_WHILE_STOPPING_0;
-
-	if (share_ctrl->current_mode & VFE_OUTPUTS_RDI0)
-		irq_mask |= VFE_IRQ_STATUS0_RDI0_REG_UPDATE_MASK;
-
-	if (share_ctrl->current_mode & VFE_OUTPUTS_RDI1)
-		irq_mask |= VFE_IRQ_STATUS0_RDI1_REG_UPDATE_MASK;
-
-	msm_camera_io_w(irq_mask, share_ctrl->vfebase +
-		VFE_IRQ_MASK_0);
-
-	if (vfe_operation_mode) {
-		irq_mask =
-		msm_camera_io_r(share_ctrl->vfebase +
-			VFE_IRQ_MASK_0);
-		irq_mask |= 0x00000021;
-		if (share_ctrl->stats_comp)
-			irq_mask |= VFE_IRQ_STATUS0_STATS_COMPOSIT_MASK_0;
-		else
-			irq_mask |= 0x00FF0000;
-		msm_camera_io_w(irq_mask, share_ctrl->vfebase +
-			VFE_IRQ_MASK_0);
-		atomic_set(&share_ctrl->vstate, 1);
-	}
-	atomic_set(&share_ctrl->handle_common_irq, 1);
-}
-
-static void axi_disable_irq(struct vfe_share_ctrl_t *share_ctrl)
-{
-
-	/* disable all interrupts.  */
-
-	uint32_t irq_mask = 0;
-	uint16_t vfe_operation_mode =
-		share_ctrl->current_mode & ~(VFE_OUTPUTS_RDI0|
-			VFE_OUTPUTS_RDI1);
-
-	if (share_ctrl->current_mode & VFE_OUTPUTS_RDI0) {
-		irq_mask =
-		msm_camera_io_r(share_ctrl->vfebase +
-			VFE_IRQ_MASK_0);
-		irq_mask &= ~(VFE_IRQ_STATUS0_RDI0_REG_UPDATE_MASK);
-		msm_camera_io_w(irq_mask, share_ctrl->vfebase +
-			VFE_IRQ_MASK_0);
-		msm_camera_io_w(VFE_IRQ_STATUS0_RDI0_REG_UPDATE_MASK,
-			share_ctrl->vfebase + VFE_IRQ_CLEAR_0);
-	}
-	if (share_ctrl->current_mode & VFE_OUTPUTS_RDI1) {
-		irq_mask =
-		msm_camera_io_r(share_ctrl->vfebase +
-			VFE_IRQ_MASK_0);
-		irq_mask &= ~(VFE_IRQ_STATUS0_RDI1_REG_UPDATE_MASK);
-		msm_camera_io_w(irq_mask, share_ctrl->vfebase +
-			VFE_IRQ_MASK_0);
-		msm_camera_io_w(VFE_IRQ_STATUS0_RDI1_REG_UPDATE_MASK,
-			share_ctrl->vfebase + VFE_IRQ_CLEAR_0);
-	}
-	if (vfe_operation_mode) {
-		atomic_set(&share_ctrl->vstate, 0);
-		irq_mask =
-		msm_camera_io_r(share_ctrl->vfebase +
-			VFE_IRQ_MASK_0);
-		irq_mask &= ~(0x00000011);
-		if (share_ctrl->stats_comp)
-			irq_mask &= ~(VFE_IRQ_STATUS0_STATS_COMPOSIT_MASK_0);
-		else
-			irq_mask &= ~0x00FF0000;
-		msm_camera_io_w(irq_mask, share_ctrl->vfebase +
-			VFE_IRQ_MASK_0);
-	}
-
-}
-
-static void vfe40_stop(struct vfe40_ctrl_type *vfe40_ctrl)
-{
-
-	/* in either continuous or snapshot mode, stop command can be issued
-	 * at any time. stop camif immediately. */
-	msm_camera_io_w(CAMIF_COMMAND_STOP_IMMEDIATELY,
-		vfe40_ctrl->share_ctrl->vfebase + VFE_CAMIF_COMMAND);
-	vfe40_ctrl->share_ctrl->operation_mode &=
-		~(vfe40_ctrl->share_ctrl->current_mode);
-	vfe40_ctrl->share_ctrl->current_mode = 0;
-}
-
-static void vfe40_subdev_notify(int id, int path, uint32_t inst_handle,
-	struct v4l2_subdev *sd, struct vfe_share_ctrl_t *share_ctrl)
-{
-	struct msm_vfe_resp rp;
-	struct msm_frame_info frame_info;
-	unsigned long flags = 0;
-	spin_lock_irqsave(&share_ctrl->sd_notify_lock, flags);
-	CDBG("vfe40_subdev_notify : msgId = %d\n", id);
-	memset(&rp, 0, sizeof(struct msm_vfe_resp));
-	rp.evt_msg.type   = MSM_CAMERA_MSG;
-	frame_info.inst_handle = inst_handle;
-	frame_info.path = path;
-	rp.evt_msg.data = &frame_info;
-	rp.type	   = id;
-	v4l2_subdev_notify(sd, NOTIFY_VFE_BUF_EVT, &rp);
-	spin_unlock_irqrestore(&share_ctrl->sd_notify_lock, flags);
-}
-
-static int vfe40_config_axi(
-	struct axi_ctrl_t *axi_ctrl, int mode, uint32_t *ao)
-{
-	uint32_t *ch_info;
-	uint32_t *axi_cfg = ao;
-	int vfe_mode = (mode & ~(OUTPUT_TERT1|OUTPUT_TERT2));
-
-	/* Update the corresponding write masters for each output*/
-	ch_info = axi_cfg + V40_AXI_CFG_LEN;
-	axi_ctrl->share_ctrl->outpath.out0.ch0 = 0x0000FFFF & *ch_info;
-	axi_ctrl->share_ctrl->outpath.out0.ch1 =
-		0x0000FFFF & (*ch_info++ >> 16);
-	axi_ctrl->share_ctrl->outpath.out0.ch2 = 0x0000FFFF & *ch_info++;
-	axi_ctrl->share_ctrl->outpath.out0.inst_handle = *ch_info++;
-
-	axi_ctrl->share_ctrl->outpath.out1.ch0 = 0x0000FFFF & *ch_info;
-	axi_ctrl->share_ctrl->outpath.out1.ch1 =
-		0x0000FFFF & (*ch_info++ >> 16);
-	axi_ctrl->share_ctrl->outpath.out1.ch2 = 0x0000FFFF & *ch_info++;
-	axi_ctrl->share_ctrl->outpath.out1.inst_handle = *ch_info++;
-
-	axi_ctrl->share_ctrl->outpath.out2.ch0 = 0x0000FFFF & *ch_info;
-	axi_ctrl->share_ctrl->outpath.out2.ch1 =
-		0x0000FFFF & (*ch_info++ >> 16);
-	axi_ctrl->share_ctrl->outpath.out2.ch2 = 0x0000FFFF & *ch_info++;
-	axi_ctrl->share_ctrl->outpath.out2.inst_handle = *ch_info++;
-
-	axi_ctrl->share_ctrl->outpath.out3.ch0 = 0x0000FFFF & *ch_info;
-	axi_ctrl->share_ctrl->outpath.out3.ch1 =
-		0x0000FFFF & (*ch_info++ >> 16);
-	axi_ctrl->share_ctrl->outpath.out3.ch2 = 0x0000FFFF & *ch_info++;
-	axi_ctrl->share_ctrl->outpath.out3.inst_handle = *ch_info++;
-
-	axi_ctrl->share_ctrl->outpath.output_mode = 0;
-
-	if (mode & OUTPUT_TERT1)
-		axi_ctrl->share_ctrl->outpath.output_mode |=
-			VFE40_OUTPUT_MODE_TERTIARY1;
-	if (mode & OUTPUT_TERT2)
-		axi_ctrl->share_ctrl->outpath.output_mode |=
-			VFE40_OUTPUT_MODE_TERTIARY2;
-	if (mode == OUTPUT_TERT1 || mode == OUTPUT_TERT1
-		|| mode == (OUTPUT_TERT1|OUTPUT_TERT2))
-			goto bus_cfg;
-
-	switch (vfe_mode) {
-	case OUTPUT_PRIM:
-		axi_ctrl->share_ctrl->outpath.output_mode |=
-			VFE40_OUTPUT_MODE_PRIMARY;
-		break;
-	case OUTPUT_PRIM_ALL_CHNLS:
-		axi_ctrl->share_ctrl->outpath.output_mode |=
-			VFE40_OUTPUT_MODE_PRIMARY_ALL_CHNLS;
-		break;
-	case OUTPUT_PRIM|OUTPUT_SEC:
-		axi_ctrl->share_ctrl->outpath.output_mode |=
-			VFE40_OUTPUT_MODE_PRIMARY;
-		axi_ctrl->share_ctrl->outpath.output_mode |=
-			VFE40_OUTPUT_MODE_SECONDARY;
-		break;
-	case OUTPUT_PRIM|OUTPUT_SEC_ALL_CHNLS:
-		axi_ctrl->share_ctrl->outpath.output_mode |=
-			VFE40_OUTPUT_MODE_PRIMARY;
-		axi_ctrl->share_ctrl->outpath.output_mode |=
-			VFE40_OUTPUT_MODE_SECONDARY_ALL_CHNLS;
-		break;
-	case OUTPUT_PRIM_ALL_CHNLS|OUTPUT_SEC:
-		axi_ctrl->share_ctrl->outpath.output_mode |=
-			VFE40_OUTPUT_MODE_PRIMARY_ALL_CHNLS;
-		axi_ctrl->share_ctrl->outpath.output_mode |=
-			VFE40_OUTPUT_MODE_SECONDARY;
-		break;
-	default:
-		pr_err("%s Invalid AXI mode %d ", __func__, mode);
-		return -EINVAL;
-	}
-
-bus_cfg:
-	msm_camera_io_memcpy(axi_ctrl->share_ctrl->vfebase +
-		vfe40_cmd[VFE_CMD_AXI_OUT_CFG].offset, axi_cfg,
-		V40_AXI_BUS_CFG_LEN);
-	msm_camera_io_w(*ch_info++,
-		axi_ctrl->share_ctrl->vfebase + VFE_RDI0_CFG);
-	msm_camera_io_w(*ch_info++,
-		axi_ctrl->share_ctrl->vfebase + VFE_RDI1_CFG);
-	msm_camera_io_w(*ch_info++,
-		axi_ctrl->share_ctrl->vfebase + VFE_RDI2_CFG);
-	return 0;
-}
-
-static void axi_reset_internal_variables(
-	struct axi_ctrl_t *axi_ctrl)
-{
-	unsigned long flags;
-	/* state control variables */
-	axi_ctrl->share_ctrl->start_ack_pending = FALSE;
-	atomic_set(&irq_cnt, 0);
-
-	spin_lock_irqsave(&axi_ctrl->share_ctrl->stop_flag_lock, flags);
-	axi_ctrl->share_ctrl->stop_ack_pending  = FALSE;
-	spin_unlock_irqrestore(&axi_ctrl->share_ctrl->stop_flag_lock, flags);
-
-	spin_lock_irqsave(&axi_ctrl->share_ctrl->update_ack_lock, flags);
-	axi_ctrl->share_ctrl->update_ack_pending = FALSE;
-	spin_unlock_irqrestore(&axi_ctrl->share_ctrl->update_ack_lock, flags);
-
-	axi_ctrl->share_ctrl->recording_state = VFE_STATE_IDLE;
-	axi_ctrl->share_ctrl->liveshot_state = VFE_STATE_IDLE;
-
-	atomic_set(&axi_ctrl->share_ctrl->vstate, 0);
-	atomic_set(&axi_ctrl->share_ctrl->handle_common_irq, 0);
-	atomic_set(&axi_ctrl->share_ctrl->pix0_update_ack_pending, 0);
-	atomic_set(&axi_ctrl->share_ctrl->rdi0_update_ack_pending, 0);
-	atomic_set(&axi_ctrl->share_ctrl->rdi1_update_ack_pending, 0);
-	atomic_set(&axi_ctrl->share_ctrl->rdi2_update_ack_pending, 0);
-
-	/* 0 for continuous mode, 1 for snapshot mode */
-	axi_ctrl->share_ctrl->operation_mode = 0;
-	axi_ctrl->share_ctrl->current_mode = 0;
-	axi_ctrl->share_ctrl->outpath.output_mode = 0;
-	axi_ctrl->share_ctrl->comp_output_mode = 0;
-	axi_ctrl->share_ctrl->vfe_capture_count = 0;
-
-	/* this is unsigned 32 bit integer. */
-	axi_ctrl->share_ctrl->vfeFrameId = 0;
-	axi_ctrl->share_ctrl->rdi0FrameId = 0;
-	axi_ctrl->share_ctrl->rdi1FrameId = 0;
-	axi_ctrl->share_ctrl->rdi2FrameId = 0;
-}
-
-static void vfe40_program_dmi_cfg(
-	enum VFE40_DMI_RAM_SEL bankSel,
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	/* set bit 8 for auto increment. */
-	uint32_t value = VFE_DMI_CFG_DEFAULT;
-	value += (uint32_t)bankSel;
-	CDBG("%s: banksel = %d\n", __func__, bankSel);
-
-	msm_camera_io_w(value, vfe40_ctrl->share_ctrl->vfebase +
-		VFE_DMI_CFG);
-	/* by default, always starts with offset 0.*/
-	msm_camera_io_w(0, vfe40_ctrl->share_ctrl->vfebase +
-		VFE_DMI_ADDR);
-}
-
-static void vfe40_reset_dmi_tables(
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	int i = 0;
-
-	/* Reset Histogram LUTs */
-	CDBG("Reset Bayer histogram LUT : 0\n");
-	vfe40_program_dmi_cfg(STATS_BHIST_RAM0, vfe40_ctrl);
-	/* Loop for configuring LUT */
-	for (i = 0; i < 256; i++) {
-		msm_camera_io_w(0, vfe40_ctrl->share_ctrl->vfebase +
-			VFE_DMI_DATA_HI);
-		msm_camera_io_w(0, vfe40_ctrl->share_ctrl->vfebase +
-			VFE_DMI_DATA_LO);
-	}
-	vfe40_program_dmi_cfg(NO_MEM_SELECTED, vfe40_ctrl);
-
-	CDBG("Reset Bayer Histogram LUT: 1\n");
-	vfe40_program_dmi_cfg(STATS_BHIST_RAM1, vfe40_ctrl);
-	/* Loop for configuring LUT */
-	for (i = 0; i < 256; i++) {
-		msm_camera_io_w(0, vfe40_ctrl->share_ctrl->vfebase +
-			VFE_DMI_DATA_HI);
-		msm_camera_io_w(0, vfe40_ctrl->share_ctrl->vfebase +
-			VFE_DMI_DATA_LO);
-	}
-	vfe40_program_dmi_cfg(NO_MEM_SELECTED, vfe40_ctrl);
-
-	CDBG("Reset IHistogram LUT\n");
-	vfe40_program_dmi_cfg(STATS_IHIST_RAM, vfe40_ctrl);
-	/* Loop for configuring LUT */
-	for (i = 0; i < 256; i++) {
-		msm_camera_io_w(0, vfe40_ctrl->share_ctrl->vfebase +
-			VFE_DMI_DATA_HI);
-		msm_camera_io_w(0, vfe40_ctrl->share_ctrl->vfebase +
-			VFE_DMI_DATA_LO);
-	}
-	vfe40_program_dmi_cfg(NO_MEM_SELECTED, vfe40_ctrl);
-}
-
-static void vfe40_set_default_reg_values(
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	msm_camera_io_w(0x800080,
-		vfe40_ctrl->share_ctrl->vfebase + VFE_DEMUX_GAIN_0);
-	msm_camera_io_w(0x800080,
-		vfe40_ctrl->share_ctrl->vfebase + VFE_DEMUX_GAIN_1);
-	msm_camera_io_w(0x198FFFFF,
-		vfe40_ctrl->share_ctrl->vfebase + VFE_CGC_OVERRIDE);
-
-	msm_camera_io_w(0,
-		vfe40_ctrl->share_ctrl->vfebase + VFE_CLAMP_ENC_MIN);
-	msm_camera_io_w(0xFFFFFF,
-		vfe40_ctrl->share_ctrl->vfebase + VFE_CLAMP_ENC_MAX);
-	msm_camera_io_w(0,
-		vfe40_ctrl->share_ctrl->vfebase + VFE_CLAMP_VIEW_MIN);
-	msm_camera_io_w(0xFFFFFF,
-		vfe40_ctrl->share_ctrl->vfebase + VFE_CLAMP_VIEW_MAX);
-
-	/* stats UB config */
-	CDBG("%s: Use bayer stats = %d\n", __func__,
-		 vfe40_use_bayer_stats(vfe40_ctrl));
-
-	msm_camera_io_w(0x82F80007,
-		vfe40_ctrl->share_ctrl->vfebase +
-			VFE_BUS_STATS_RS_WR_UB_CFG);
-	msm_camera_io_w(0x8300000F,
-		vfe40_ctrl->share_ctrl->vfebase +
-			VFE_BUS_STATS_CS_WR_UB_CFG);
-
-	msm_camera_io_w(0x8310003F,
-		vfe40_ctrl->share_ctrl->vfebase +
-			VFE_BUS_STATS_BG_WR_UB_CFG);
-	msm_camera_io_w(0x8350003F,
-		vfe40_ctrl->share_ctrl->vfebase +
-			VFE_BUS_STATS_BE_WR_UB_CFG);
-	msm_camera_io_w(0x8390003F,
-		vfe40_ctrl->share_ctrl->vfebase +
-			VFE_BUS_STATS_BF_WR_UB_CFG);
-
-	msm_camera_io_w(0x83D0000F,
-	vfe40_ctrl->share_ctrl->vfebase +
-			VFE_BUS_STATS_HIST_WR_UB_CFG);
-	msm_camera_io_w(0x83E0000F,
-		vfe40_ctrl->share_ctrl->vfebase +
-			VFE_BUS_STATS_SKIN_WR_UB_CFG);
-
-	msm_camera_io_w(0x83F0000F,
-		vfe40_ctrl->share_ctrl->vfebase +
-			VFE_BUS_STATS_AWB_WR_UB_CFG);
-
-	/* stats frame subsample config*/
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe40_ctrl->share_ctrl->vfebase +
-			VFE_BUS_STATS_HIST_WR_FRAMEDROP_PATTERN);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe40_ctrl->share_ctrl->vfebase +
-			VFE_BUS_STATS_BG_WR_FRAMEDROP_PATTERN);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe40_ctrl->share_ctrl->vfebase +
-			VFE_BUS_STATS_BE_WR_FRAMEDROP_PATTERN);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe40_ctrl->share_ctrl->vfebase +
-			VFE_BUS_STATS_BF_WR_FRAMEDROP_PATTERN);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe40_ctrl->share_ctrl->vfebase +
-			VFE_BUS_STATS_RS_WR_FRAMEDROP_PATTERN);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe40_ctrl->share_ctrl->vfebase +
-			VFE_BUS_STATS_CS_WR_FRAMEDROP_PATTERN);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe40_ctrl->share_ctrl->vfebase +
-			VFE_BUS_STATS_SKIN_WR_FRAMEDROP_PATTERN);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe40_ctrl->share_ctrl->vfebase +
-			VFE_BUS_STATS_AWB_WR_FRAMEDROP_PATTERN);
-
-	/* stats irq subsample config*/
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe40_ctrl->share_ctrl->vfebase +
-			VFE_BUS_STATS_HIST_WR_IRQ_SUBSAMPLE_PATTERN);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe40_ctrl->share_ctrl->vfebase +
-			VFE_BUS_STATS_BG_WR_IRQ_SUBSAMPLE_PATTERN);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe40_ctrl->share_ctrl->vfebase +
-			VFE_BUS_STATS_BE_WR_IRQ_SUBSAMPLE_PATTERN);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe40_ctrl->share_ctrl->vfebase +
-			VFE_BUS_STATS_BF_WR_IRQ_SUBSAMPLE_PATTERN);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe40_ctrl->share_ctrl->vfebase +
-			VFE_BUS_STATS_RS_WR_IRQ_SUBSAMPLE_PATTERN);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe40_ctrl->share_ctrl->vfebase +
-			VFE_BUS_STATS_CS_WR_IRQ_SUBSAMPLE_PATTERN);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe40_ctrl->share_ctrl->vfebase +
-			VFE_BUS_STATS_SKIN_WR_IRQ_SUBSAMPLE_PATTERN);
-	msm_camera_io_w(0xFFFFFFFF,
-		vfe40_ctrl->share_ctrl->vfebase +
-			VFE_BUS_STATS_AWB_WR_IRQ_SUBSAMPLE_PATTERN);
-
-	vfe40_reset_dmi_tables(vfe40_ctrl);
-}
-
-static void vfe40_reset_internal_variables(
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	/* Stats control variables. */
-	memset(&(vfe40_ctrl->bfStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	memset(&(vfe40_ctrl->awbStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	memset(&(vfe40_ctrl->bgStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	memset(&(vfe40_ctrl->beStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	memset(&(vfe40_ctrl->bhistStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	memset(&(vfe40_ctrl->ihistStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	memset(&(vfe40_ctrl->rsStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	memset(&(vfe40_ctrl->csStatsControl), 0,
-		sizeof(struct vfe_stats_control));
-
-	vfe40_ctrl->frame_skip_cnt = 31;
-	vfe40_ctrl->frame_skip_pattern = 0xffffffff;
-	vfe40_ctrl->snapshot_frame_cnt = 0;
-	vfe40_set_default_reg_values(vfe40_ctrl);
-}
-
-static int vfe40_reset(struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	uint32_t irq_mask;
-	atomic_set(&vfe40_ctrl->share_ctrl->vstate, 0);
-	msm_camera_io_w(VFE_MODULE_RESET_CMD,
-		vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_RESET);
-	msm_camera_io_w(0,
-		vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_RESET);
-
-	irq_mask =
-		msm_camera_io_r(vfe40_ctrl->share_ctrl->vfebase +
-			VFE_IRQ_MASK_0);
-	irq_mask &= ~(0x00FF0011|VFE_IRQ_STATUS0_STATS_COMPOSIT_MASK_0);
-
-	/* enable reset_ack interrupt.  */
-	irq_mask |= VFE_IMASK_WHILE_STOPPING_0;
-	msm_camera_io_w(irq_mask, vfe40_ctrl->share_ctrl->vfebase +
-		VFE_IRQ_MASK_0);
-
-	msm_camera_io_w_mb(VFE_ONLY_RESET_CMD,
-		vfe40_ctrl->share_ctrl->vfebase + VFE_GLOBAL_RESET);
-
-	return wait_for_completion_interruptible(
-			&vfe40_ctrl->share_ctrl->reset_complete);
-}
-
-static int axi_reset(struct axi_ctrl_t *axi_ctrl)
-{
-	axi_reset_internal_variables(axi_ctrl);
-	/* disable all interrupts.  vfeImaskLocal is also reset to 0
-	* to begin with. */
-	msm_camera_io_w(VFE_DISABLE_ALL_IRQS,
-		axi_ctrl->share_ctrl->vfebase + VFE_IRQ_MASK_0);
-
-	msm_camera_io_w(VFE_DISABLE_ALL_IRQS,
-		axi_ctrl->share_ctrl->vfebase + VFE_IRQ_MASK_1);
-
-	/* clear all pending interrupts*/
-	msm_camera_io_w(VFE_CLEAR_ALL_IRQ0,
-		axi_ctrl->share_ctrl->vfebase + VFE_IRQ_CLEAR_0);
-	msm_camera_io_w(VFE_CLEAR_ALL_IRQ1,
-		axi_ctrl->share_ctrl->vfebase + VFE_IRQ_CLEAR_1);
-
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(1, axi_ctrl->share_ctrl->vfebase + VFE_IRQ_CMD);
-
-	/* enable reset_ack interrupt.  */
-	msm_camera_io_w(VFE_IMASK_WHILE_STOPPING_0,
-		axi_ctrl->share_ctrl->vfebase + VFE_IRQ_MASK_0);
-
-	/* Write to VFE_GLOBAL_RESET_CMD to reset the vfe hardware. Once reset
-	 * is done, hardware interrupt will be generated.  VFE ist processes
-	 * the interrupt to complete the function call.  Note that the reset
-	 * function is synchronous. */
-
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(VFE_RESET_UPON_RESET_CMD,
-		axi_ctrl->share_ctrl->vfebase + VFE_GLOBAL_RESET);
-
-	return wait_for_completion_interruptible(
-			&axi_ctrl->share_ctrl->reset_complete);
-}
-
-static int vfe40_operation_config(uint32_t *cmd,
-			struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	uint32_t *p = cmd;
-
-	vfe40_ctrl->share_ctrl->stats_comp = *(++p);
-	vfe40_ctrl->hfr_mode = *(++p);
-
-	msm_camera_io_w(*(++p),
-		vfe40_ctrl->share_ctrl->vfebase + VFE_CFG);
-	msm_camera_io_w(*(++p),
-		vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-	msm_camera_io_w(*(++p),
-		vfe40_ctrl->share_ctrl->vfebase + VFE_REALIGN_BUF);
-	msm_camera_io_w(*(++p),
-		vfe40_ctrl->share_ctrl->vfebase + VFE_CHROMA_UP);
-	msm_camera_io_w(*(++p),
-		vfe40_ctrl->share_ctrl->vfebase + VFE_STATS_CFG);
-	return 0;
-}
-
-static unsigned long vfe40_stats_dqbuf(struct vfe40_ctrl_type *vfe40_ctrl,
-	enum msm_stats_enum_type stats_type)
-{
-	struct msm_stats_meta_buf *buf = NULL;
-	int rc = 0;
-	rc = vfe40_ctrl->stats_ops.dqbuf(
-			vfe40_ctrl->stats_ops.stats_ctrl, stats_type, &buf);
-	if (rc < 0) {
-		pr_err("%s: dq stats buf (type = %d) err = %d\n",
-			__func__, stats_type, rc);
-		return 0L;
-	}
-	return buf->paddr;
-}
-
-static unsigned long vfe40_stats_flush_enqueue(
-	struct vfe40_ctrl_type *vfe40_ctrl,
-	enum msm_stats_enum_type stats_type)
-{
-	struct msm_stats_bufq *bufq = NULL;
-	struct msm_stats_meta_buf *stats_buf = NULL;
-	int rc = 0;
-	int i;
-
-	/*
-	 * Passing NULL for ion client as the buffers are already
-	 * mapped at this stage, client is not required, flush all
-	 * the buffers, and buffers move to PREPARE state
-	 */
-
-	rc = vfe40_ctrl->stats_ops.bufq_flush(
-			vfe40_ctrl->stats_ops.stats_ctrl, stats_type, NULL);
-	if (rc < 0) {
-		pr_err("%s: dq stats buf (type = %d) err = %d",
-			__func__, stats_type, rc);
-		return 0L;
-	}
-	/* Queue all the buffers back to QUEUED state */
-	bufq = vfe40_ctrl->stats_ctrl.bufq[stats_type];
-	for (i = 0; i < bufq->num_bufs; i++) {
-		stats_buf = &bufq->bufs[i];
-		rc = vfe40_ctrl->stats_ops.enqueue_buf(
-				vfe40_ctrl->stats_ops.stats_ctrl,
-				&(stats_buf->info), NULL, -1);
-		if (rc < 0) {
-			pr_err("%s: dq stats buf (type = %d) err = %d",
-				 __func__, stats_type, rc);
-			return rc;
-		}
-	}
-	return 0L;
-}
-
-
-static unsigned long vfe40_stats_unregbuf(
-	struct vfe40_ctrl_type *vfe40_ctrl,
-	struct msm_stats_reqbuf *req_buf, int domain_num)
-{
-	int i = 0, rc = 0;
-
-	for (i = 0; i < req_buf->num_buf; i++) {
-		rc = vfe40_ctrl->stats_ops.buf_unprepare(
-			vfe40_ctrl->stats_ops.stats_ctrl,
-			req_buf->stats_type, i,
-			vfe40_ctrl->stats_ops.client, domain_num);
-		if (rc < 0) {
-			pr_err("%s: unreg stats buf (type = %d) err = %d",
-				__func__, req_buf->stats_type, rc);
-		return rc;
-		}
-	}
-	return 0L;
-}
-static int vfe_stats_awb_buf_init(
-	struct vfe40_ctrl_type *vfe40_ctrl,
-	struct vfe_cmd_stats_buf *in)
-{
-	uint32_t addr;
-	unsigned long flags;
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl, MSM_STATS_TYPE_AWB);
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq awb ping buf from free buf queue\n", __func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe40_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_AWB_WR_PING_ADDR);
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl, MSM_STATS_TYPE_AWB);
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq awb ping buf from free buf queue\n",
-			__func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe40_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_AWB_WR_PONG_ADDR);
-	return 0;
-}
-
-static uint32_t vfe_stats_be_buf_init(
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	uint32_t addr;
-	unsigned long flags;
-	uint32_t stats_type;
-
-	stats_type = MSM_STATS_TYPE_BE;
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl, stats_type);
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq BE ping buf from free buf queue\n",
-			__func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe40_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_BE_WR_PING_ADDR);
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl, stats_type);
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq BE pong buf from free buf queue\n",
-			__func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe40_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_BE_WR_PONG_ADDR);
-	return 0;
-}
-
-static uint32_t vfe_stats_bg_buf_init(
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	uint32_t addr;
-	unsigned long flags;
-	uint32_t stats_type;
-
-	stats_type = MSM_STATS_TYPE_BG;
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl, stats_type);
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq aec/Bg ping buf from free buf queue\n",
-			__func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe40_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_BG_WR_PING_ADDR);
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl, stats_type);
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq aec/Bg pong buf from free buf queue\n",
-			__func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe40_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_BG_WR_PONG_ADDR);
-	return 0;
-}
-
-static int vfe_stats_bf_buf_init(
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	uint32_t addr;
-	unsigned long flags;
-	int rc = 0;
-
-	uint32_t stats_type;
-	stats_type = MSM_STATS_TYPE_BF;
-
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-	rc = vfe40_stats_flush_enqueue(vfe40_ctrl, stats_type);
-	if (rc < 0) {
-		pr_err("%s: dq stats buf err = %d",
-			   __func__, rc);
-		spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-		return -EINVAL;
-	}
-	addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl, stats_type);
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq af ping buf from free buf queue", __func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe40_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_BF_WR_PING_ADDR);
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl, stats_type);
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq af pong buf from free buf queue", __func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe40_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_BF_WR_PONG_ADDR);
-	return 0;
-}
-
-static uint32_t vfe_stats_bhist_buf_init(
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	uint32_t addr;
-	unsigned long flags;
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl, MSM_STATS_TYPE_BHIST);
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq ihist ping buf from free buf queue",
-			__func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe40_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_SKIN_WR_PING_ADDR);
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl, MSM_STATS_TYPE_BHIST);
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq ihist pong buf from free buf queue",
-			__func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe40_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_SKIN_WR_PONG_ADDR);
-
-	return 0;
-}
-
-static int vfe_stats_ihist_buf_init(
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	uint32_t addr;
-	unsigned long flags;
-
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl, MSM_STATS_TYPE_IHIST);
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq ihist ping buf from free buf queue",
-			__func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe40_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_HIST_WR_PING_ADDR);
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl, MSM_STATS_TYPE_IHIST);
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq Ihist pong buf from free buf queue",
-			__func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe40_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_HIST_WR_PONG_ADDR);
-
-	return 0;
-}
-
-static int vfe_stats_rs_buf_init(
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	uint32_t addr;
-	unsigned long flags;
-
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl, MSM_STATS_TYPE_RS);
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq rs ping buf from free buf queue", __func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe40_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_RS_WR_PING_ADDR);
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl, MSM_STATS_TYPE_RS);
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq rs pong buf from free buf queue", __func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe40_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_RS_WR_PONG_ADDR);
-	return 0;
-}
-
-static int vfe_stats_cs_buf_init(
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	uint32_t addr;
-	unsigned long flags;
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl, MSM_STATS_TYPE_CS);
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq cs ping buf from free buf queue", __func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe40_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_CS_WR_PING_ADDR);
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl, MSM_STATS_TYPE_CS);
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (!addr) {
-		pr_err("%s: dq cs pong buf from free buf queue", __func__);
-		return -ENOMEM;
-	}
-	msm_camera_io_w(addr,
-		vfe40_ctrl->share_ctrl->vfebase +
-		VFE_BUS_STATS_CS_WR_PONG_ADDR);
-	return 0;
-}
-
-static void vfe40_cfg_qos_parms(struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	void __iomem *vfebase = vfe40_ctrl->share_ctrl->vfebase;
-	msm_camera_io_w(0xAAAAAAAA, vfebase + VFE_0_BUS_BDG_QOS_CFG_0);
-	msm_camera_io_w(0xAAAAAAAA, vfebase + VFE_0_BUS_BDG_QOS_CFG_1);
-	msm_camera_io_w(0xAAAAAAAA, vfebase + VFE_0_BUS_BDG_QOS_CFG_2);
-	msm_camera_io_w(0xAAAAAAAA, vfebase + VFE_0_BUS_BDG_QOS_CFG_3);
-	msm_camera_io_w(0xAAAAAAAA, vfebase + VFE_0_BUS_BDG_QOS_CFG_4);
-	msm_camera_io_w(0xAAAAAAAA, vfebase + VFE_0_BUS_BDG_QOS_CFG_5);
-	msm_camera_io_w(0xAAAAAAAA, vfebase + VFE_0_BUS_BDG_QOS_CFG_6);
-	msm_camera_io_w(0x0002AAAA, vfebase + VFE_0_BUS_BDG_QOS_CFG_7);
-}
-
-static void vfe40_start_common(struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	uint16_t vfe_operation_mode =
-		vfe40_ctrl->share_ctrl->current_mode & ~(VFE_OUTPUTS_RDI0|
-			VFE_OUTPUTS_RDI1);
-	CDBG("VFE opertaion mode = 0x%x, output mode = 0x%x\n",
-		vfe40_ctrl->share_ctrl->current_mode,
-		vfe40_ctrl->share_ctrl->outpath.output_mode);
-
-	vfe40_cfg_qos_parms(vfe40_ctrl);
-
-	msm_camera_io_w_mb(0x1,
-			vfe40_ctrl->share_ctrl->vfebase +
-			VFE_REG_UPDATE_CMD);
-
-	msm_camera_io_w_mb(0x00003fff,
-			vfe40_ctrl->share_ctrl->vfebase +
-			V40_AXI_BUS_CMD_OFF);
-	msm_camera_io_w_mb(1,
-			vfe40_ctrl->share_ctrl->vfebase +
-			V40_BUS_PM_CMD);
-	if (vfe_operation_mode) {
-		msm_camera_io_w_mb(1, vfe40_ctrl->share_ctrl->vfebase +
-			VFE_CAMIF_COMMAND);
-	}
-
-}
-
-static int vfe40_start_recording(
-	struct msm_cam_media_controller *pmctl,
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	vfe40_ctrl->share_ctrl->recording_state = VFE_STATE_START_REQUESTED;
-	msm_camera_io_w_mb(1,
-		vfe40_ctrl->share_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-	return 0;
-}
-
-static int vfe40_stop_recording(
-	struct msm_cam_media_controller *pmctl,
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	vfe40_ctrl->share_ctrl->recording_state = VFE_STATE_STOP_REQUESTED;
-	msm_camera_io_w_mb(1,
-		vfe40_ctrl->share_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-	return 0;
-}
-
-static void vfe40_start_liveshot(
-	struct msm_cam_media_controller *pmctl,
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	/* Hardcode 1 live snapshot for now. */
-	vfe40_ctrl->share_ctrl->outpath.out0.capture_cnt = 1;
-	vfe40_ctrl->share_ctrl->vfe_capture_count =
-		vfe40_ctrl->share_ctrl->outpath.out0.capture_cnt;
-
-	vfe40_ctrl->share_ctrl->liveshot_state = VFE_STATE_START_REQUESTED;
-	msm_camera_io_w_mb(1, vfe40_ctrl->
-		share_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-}
-
-static void vfe40_stop_liveshot(
-	struct msm_cam_media_controller *pmctl,
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	vfe40_ctrl->share_ctrl->liveshot_state = VFE_STATE_STOP_REQUESTED;
-	msm_camera_io_w_mb(1,
-		vfe40_ctrl->share_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-}
-
-static int vfe40_zsl(
-	struct msm_cam_media_controller *pmctl,
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	vfe40_ctrl->share_ctrl->start_ack_pending = TRUE;
-	vfe40_start_common(vfe40_ctrl);
-
-	return 0;
-}
-static int vfe40_capture_raw(
-	struct msm_cam_media_controller *pmctl,
-	struct vfe40_ctrl_type *vfe40_ctrl,
-	uint32_t num_frames_capture)
-{
-	vfe40_ctrl->share_ctrl->outpath.out0.capture_cnt = num_frames_capture;
-	vfe40_ctrl->share_ctrl->vfe_capture_count = num_frames_capture;
-	vfe40_start_common(vfe40_ctrl);
-	return 0;
-}
-
-static int vfe40_capture(
-	struct msm_cam_media_controller *pmctl,
-	uint32_t num_frames_capture,
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	/* capture command is valid for both idle and active state. */
-	vfe40_ctrl->share_ctrl->outpath.out1.capture_cnt = num_frames_capture;
-	if (vfe40_ctrl->share_ctrl->current_mode ==
-			VFE_OUTPUTS_MAIN_AND_THUMB ||
-		vfe40_ctrl->share_ctrl->current_mode ==
-			VFE_OUTPUTS_THUMB_AND_MAIN ||
-		vfe40_ctrl->share_ctrl->current_mode ==
-			VFE_OUTPUTS_JPEG_AND_THUMB ||
-		vfe40_ctrl->share_ctrl->current_mode ==
-			VFE_OUTPUTS_THUMB_AND_JPEG) {
-		vfe40_ctrl->share_ctrl->outpath.out0.capture_cnt =
-			num_frames_capture;
-	}
-
-	vfe40_ctrl->share_ctrl->vfe_capture_count = num_frames_capture;
-
-
-	vfe40_start_common(vfe40_ctrl);
-	/* for debug */
-	return 0;
-}
-
-static int vfe40_start(
-	struct msm_cam_media_controller *pmctl,
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	vfe40_start_common(vfe40_ctrl);
-	return 0;
-}
-
-static void vfe40_update(struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	unsigned long flags;
-	uint32_t value = 0;
-	if (vfe40_ctrl->update_linear) {
-		if (!msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase +
-			V40_LINEARIZATION_OFF1))
-			msm_camera_io_w(1,
-				vfe40_ctrl->share_ctrl->vfebase +
-				V40_LINEARIZATION_OFF1);
-		else
-			msm_camera_io_w(0,
-				vfe40_ctrl->share_ctrl->vfebase +
-				V40_LINEARIZATION_OFF1);
-		vfe40_ctrl->update_linear = false;
-	}
-
-	if (vfe40_ctrl->update_la) {
-		if (!msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + V40_LA_OFF))
-			msm_camera_io_w(1,
-				vfe40_ctrl->share_ctrl->vfebase + V40_LA_OFF);
-		else
-			msm_camera_io_w(0,
-				vfe40_ctrl->share_ctrl->vfebase + V40_LA_OFF);
-		vfe40_ctrl->update_la = false;
-	}
-
-	if (vfe40_ctrl->update_gamma) {
-		value = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + V40_RGB_G_OFF);
-		value ^= V40_GAMMA_LUT_BANK_SEL_MASK;
-		msm_camera_io_w(value,
-			vfe40_ctrl->share_ctrl->vfebase + V40_RGB_G_OFF);
-		vfe40_ctrl->update_gamma = false;
-	}
-
-	spin_lock_irqsave(&vfe40_ctrl->share_ctrl->update_ack_lock, flags);
-	vfe40_ctrl->share_ctrl->update_ack_pending = TRUE;
-	spin_unlock_irqrestore(&vfe40_ctrl->share_ctrl->update_ack_lock, flags);
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(1,
-		vfe40_ctrl->share_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-	return;
-}
-
-static void vfe40_sync_timer_stop(struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	uint32_t value = 0;
-	vfe40_ctrl->sync_timer_state = 0;
-	if (vfe40_ctrl->sync_timer_number == 0)
-		value = 0x10000;
-	else if (vfe40_ctrl->sync_timer_number == 1)
-		value = 0x20000;
-	else if (vfe40_ctrl->sync_timer_number == 2)
-		value = 0x40000;
-
-	/* Timer Stop */
-	msm_camera_io_w(value,
-		vfe40_ctrl->share_ctrl->vfebase + V40_SYNC_TIMER_OFF);
-}
-
-static void vfe40_sync_timer_start(
-	const uint32_t *tbl,
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	/* set bit 8 for auto increment. */
-	uint32_t value = 1;
-	uint32_t val;
-
-	vfe40_ctrl->sync_timer_state = *tbl++;
-	vfe40_ctrl->sync_timer_repeat_count = *tbl++;
-	vfe40_ctrl->sync_timer_number = *tbl++;
-	CDBG("%s timer_state %d, repeat_cnt %d timer number %d\n",
-		 __func__, vfe40_ctrl->sync_timer_state,
-		 vfe40_ctrl->sync_timer_repeat_count,
-		 vfe40_ctrl->sync_timer_number);
-
-	if (vfe40_ctrl->sync_timer_state) { /* Start Timer */
-		value = value << vfe40_ctrl->sync_timer_number;
-	} else { /* Stop Timer */
-		CDBG("Failed to Start timer\n");
-		return;
-	}
-
-	/* Timer Start */
-	msm_camera_io_w(value,
-		vfe40_ctrl->share_ctrl->vfebase + V40_SYNC_TIMER_OFF);
-	/* Sync Timer Line Start */
-	value = *tbl++;
-	msm_camera_io_w(value,
-		vfe40_ctrl->share_ctrl->vfebase + V40_SYNC_TIMER_OFF +
-		4 + ((vfe40_ctrl->sync_timer_number) * 12));
-	/* Sync Timer Pixel Start */
-	value = *tbl++;
-	msm_camera_io_w(value,
-			vfe40_ctrl->share_ctrl->vfebase + V40_SYNC_TIMER_OFF +
-			 8 + ((vfe40_ctrl->sync_timer_number) * 12));
-	/* Sync Timer Pixel Duration */
-	value = *tbl++;
-	val = vfe_clk_rate / 10000;
-	val = 10000000 / val;
-	val = value * 10000 / val;
-	CDBG("%s: Pixel Clk Cycles!!! %d\n", __func__, val);
-	msm_camera_io_w(val,
-		vfe40_ctrl->share_ctrl->vfebase + V40_SYNC_TIMER_OFF +
-		12 + ((vfe40_ctrl->sync_timer_number) * 12));
-	/* Timer0 Active High/LOW */
-	value = *tbl++;
-	msm_camera_io_w(value,
-		vfe40_ctrl->share_ctrl->vfebase + V40_SYNC_TIMER_POLARITY_OFF);
-	/* Selects sync timer 0 output to drive onto timer1 port */
-	value = 0;
-	msm_camera_io_w(value,
-		vfe40_ctrl->share_ctrl->vfebase + V40_TIMER_SELECT_OFF);
-}
-
-
-static void vfe40_write_gamma_cfg(
-	enum VFE40_DMI_RAM_SEL channel_sel,
-	const uint32_t *tbl,
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	int i;
-	uint32_t value, value1, value2;
-	vfe40_program_dmi_cfg(channel_sel, vfe40_ctrl);
-	for (i = 0 ; i < (VFE40_GAMMA_NUM_ENTRIES/2) ; i++) {
-		value = *tbl++;
-		value1 = value & 0x0000FFFF;
-		value2 = (value & 0xFFFF0000)>>16;
-		msm_camera_io_w((value1),
-			vfe40_ctrl->share_ctrl->vfebase + VFE_DMI_DATA_LO);
-		msm_camera_io_w((value2),
-			vfe40_ctrl->share_ctrl->vfebase + VFE_DMI_DATA_LO);
-	}
-	vfe40_program_dmi_cfg(NO_MEM_SELECTED, vfe40_ctrl);
-}
-
-static void vfe40_read_gamma_cfg(
-	enum VFE40_DMI_RAM_SEL channel_sel,
-	uint32_t *tbl,
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	int i;
-	vfe40_program_dmi_cfg(channel_sel, vfe40_ctrl);
-	CDBG("%s: Gamma table channel: %d\n", __func__, channel_sel);
-	for (i = 0 ; i < VFE40_GAMMA_NUM_ENTRIES ; i++) {
-		*tbl = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + VFE_DMI_DATA_LO);
-		CDBG("%s: %08x\n", __func__, *tbl);
-		tbl++;
-	}
-	vfe40_program_dmi_cfg(NO_MEM_SELECTED, vfe40_ctrl);
-}
-
-static void vfe40_write_la_cfg(
-	enum VFE40_DMI_RAM_SEL channel_sel,
-	const uint32_t *tbl,
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	uint32_t i;
-	uint32_t value, value1, value2;
-
-	vfe40_program_dmi_cfg(channel_sel, vfe40_ctrl);
-	for (i = 0 ; i < (VFE40_LA_TABLE_LENGTH/2) ; i++) {
-		value = *tbl++;
-		value1 = value & 0x0000FFFF;
-		value2 = (value & 0xFFFF0000)>>16;
-		msm_camera_io_w((value1),
-			vfe40_ctrl->share_ctrl->vfebase + VFE_DMI_DATA_LO);
-		msm_camera_io_w((value2),
-			vfe40_ctrl->share_ctrl->vfebase + VFE_DMI_DATA_LO);
-	}
-	vfe40_program_dmi_cfg(NO_MEM_SELECTED, vfe40_ctrl);
-}
-
-static struct vfe40_output_ch *vfe40_get_ch(
-	int path, struct vfe_share_ctrl_t *share_ctrl)
-{
-	struct vfe40_output_ch *ch = NULL;
-
-	if (path == VFE_MSG_OUTPUT_PRIMARY)
-		ch = &share_ctrl->outpath.out0;
-	else if (path == VFE_MSG_OUTPUT_SECONDARY)
-		ch = &share_ctrl->outpath.out1;
-	else if (path == VFE_MSG_OUTPUT_TERTIARY1)
-		ch = &share_ctrl->outpath.out2;
-	else if (path == VFE_MSG_OUTPUT_TERTIARY2)
-		ch = &share_ctrl->outpath.out3;
-	else
-		pr_err("%s: Invalid path %d\n", __func__,
-			path);
-
-	BUG_ON(ch == NULL);
-	return ch;
-}
-static struct msm_free_buf *vfe40_check_free_buffer(
-	int id, int path, struct axi_ctrl_t *axi_ctrl)
-{
-	struct vfe40_output_ch *outch = NULL;
-	struct msm_free_buf *b = NULL;
-	uint32_t inst_handle = 0;
-
-	if (path == VFE_MSG_OUTPUT_PRIMARY)
-		inst_handle = axi_ctrl->share_ctrl->outpath.out0.inst_handle;
-	else if (path == VFE_MSG_OUTPUT_SECONDARY)
-		inst_handle = axi_ctrl->share_ctrl->outpath.out1.inst_handle;
-	else if (path == VFE_MSG_OUTPUT_TERTIARY1)
-		inst_handle = axi_ctrl->share_ctrl->outpath.out2.inst_handle;
-	else if (path == VFE_MSG_OUTPUT_TERTIARY2)
-		inst_handle = axi_ctrl->share_ctrl->outpath.out3.inst_handle;
-
-	vfe40_subdev_notify(id, path, inst_handle,
-		&axi_ctrl->subdev, axi_ctrl->share_ctrl);
-	outch = vfe40_get_ch(path, axi_ctrl->share_ctrl);
-	if (outch->free_buf.ch_paddr[0])
-		b = &outch->free_buf;
-	return b;
-}
-static int configure_pingpong_buffers(
-	int id, int path, struct axi_ctrl_t *axi_ctrl)
-{
-	struct vfe40_output_ch *outch = NULL;
-	int rc = 0;
-	uint32_t inst_handle = 0;
-	if (path == VFE_MSG_OUTPUT_PRIMARY)
-		inst_handle = axi_ctrl->share_ctrl->outpath.out0.inst_handle;
-	else if (path == VFE_MSG_OUTPUT_SECONDARY)
-		inst_handle = axi_ctrl->share_ctrl->outpath.out1.inst_handle;
-	else if (path == VFE_MSG_OUTPUT_TERTIARY1)
-		inst_handle = axi_ctrl->share_ctrl->outpath.out2.inst_handle;
-	else if (path == VFE_MSG_OUTPUT_TERTIARY2)
-		inst_handle = axi_ctrl->share_ctrl->outpath.out3.inst_handle;
-
-	vfe40_subdev_notify(id, path, inst_handle,
-		&axi_ctrl->subdev, axi_ctrl->share_ctrl);
-	outch = vfe40_get_ch(path, axi_ctrl->share_ctrl);
-	if (outch->ping.ch_paddr[0] && outch->pong.ch_paddr[0]) {
-		/* Configure Preview Ping Pong */
-		pr_info("%s Configure ping/pong address for %d\n",
-						__func__, path);
-		vfe40_put_ch_ping_addr(
-			axi_ctrl->share_ctrl->vfebase, outch->ch0,
-			outch->ping.ch_paddr[0]);
-		vfe40_put_ch_pong_addr(
-			axi_ctrl->share_ctrl->vfebase, outch->ch0,
-			outch->pong.ch_paddr[0]);
-
-		if ((axi_ctrl->share_ctrl->current_mode !=
-			VFE_OUTPUTS_RAW) && (path != VFE_MSG_OUTPUT_TERTIARY1)
-			&& (path != VFE_MSG_OUTPUT_TERTIARY2)) {
-			vfe40_put_ch_ping_addr(
-				axi_ctrl->share_ctrl->vfebase, outch->ch1,
-				outch->ping.ch_paddr[1]);
-			vfe40_put_ch_pong_addr(
-				axi_ctrl->share_ctrl->vfebase, outch->ch1,
-				outch->pong.ch_paddr[1]);
-		}
-
-		if (outch->ping.num_planes > 2)
-			vfe40_put_ch_ping_addr(
-				axi_ctrl->share_ctrl->vfebase, outch->ch2,
-				outch->ping.ch_paddr[2]);
-		if (outch->pong.num_planes > 2)
-			vfe40_put_ch_pong_addr(
-				axi_ctrl->share_ctrl->vfebase, outch->ch2,
-				outch->pong.ch_paddr[2]);
-
-		/* avoid stale info */
-		memset(&outch->ping, 0, sizeof(struct msm_free_buf));
-		memset(&outch->pong, 0, sizeof(struct msm_free_buf));
-	} else {
-		pr_err("%s ping/pong addr is null!!", __func__);
-		rc = -EINVAL;
-	}
-	return rc;
-}
-
-static void vfe40_write_linear_cfg(
-	enum VFE40_DMI_RAM_SEL channel_sel,
-	const uint32_t *tbl, struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	uint32_t i;
-
-	vfe40_program_dmi_cfg(channel_sel, vfe40_ctrl);
-	/* for loop for configuring LUT. */
-	for (i = 0 ; i < VFE40_LINEARIZATON_TABLE_LENGTH ; i++) {
-		msm_camera_io_w(*tbl,
-			vfe40_ctrl->share_ctrl->vfebase + VFE_DMI_DATA_LO);
-		tbl++;
-	}
-	CDBG("done writing to linearization table\n");
-	vfe40_program_dmi_cfg(NO_MEM_SELECTED, vfe40_ctrl);
-}
-
-static void vfe40_send_isp_msg(
-	struct v4l2_subdev *sd,
-	uint32_t vfeFrameId,
-	uint32_t isp_msg_id)
-{
-	struct isp_msg_event isp_msg_evt;
-
-	isp_msg_evt.msg_id = isp_msg_id;
-	isp_msg_evt.sof_count = vfeFrameId;
-	v4l2_subdev_notify(sd,
-			NOTIFY_ISP_MSG_EVT,
-			(void *)&isp_msg_evt);
-}
-
-static int vfe40_proc_general(
-	struct msm_cam_media_controller *pmctl,
-	struct msm_isp_cmd *cmd,
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	int i , rc = 0;
-	uint32_t old_val = 0 , new_val = 0, module_val = 0;
-	uint32_t *cmdp = NULL;
-	uint32_t *cmdp_local = NULL;
-	uint32_t snapshot_cnt = 0;
-	uint32_t temp1 = 0, temp2 = 0;
-	struct msm_camera_vfe_params_t vfe_params;
-
-	CDBG("vfe40_proc_general: cmdID = %s, length = %d\n",
-		vfe40_general_cmd[cmd->id], cmd->length);
-	switch (cmd->id) {
-	case VFE_CMD_RESET:
-		pr_info("vfe40_proc_general: cmdID = %s\n",
-			vfe40_general_cmd[cmd->id]);
-		vfe40_ctrl->share_ctrl->vfe_reset_flag = true;
-		vfe40_reset(vfe40_ctrl);
-		break;
-	case VFE_CMD_START:
-		pr_info("vfe40_proc_general: cmdID = %s\n",
-			vfe40_general_cmd[cmd->id]);
-		if (copy_from_user(&vfe_params,
-				(void __user *)(cmd->value),
-				sizeof(struct msm_camera_vfe_params_t))) {
-				rc = -EFAULT;
-				goto proc_general_done;
-		}
-
-		vfe40_ctrl->share_ctrl->current_mode =
-			vfe_params.operation_mode;
-
-		rc = vfe40_start(pmctl, vfe40_ctrl);
-		break;
-	case VFE_CMD_UPDATE:
-		vfe40_update(vfe40_ctrl);
-		break;
-	case VFE_CMD_CAPTURE_RAW:
-		pr_info("%s: cmdID = VFE_CMD_CAPTURE_RAW\n", __func__);
-		if (copy_from_user(&vfe_params,
-				(void __user *)(cmd->value),
-				sizeof(struct msm_camera_vfe_params_t))) {
-				rc = -EFAULT;
-				goto proc_general_done;
-		}
-
-		snapshot_cnt = vfe_params.capture_count;
-		vfe40_ctrl->share_ctrl->current_mode =
-			vfe_params.operation_mode;
-		rc = vfe40_capture_raw(pmctl, vfe40_ctrl, snapshot_cnt);
-		break;
-	case VFE_CMD_CAPTURE:
-		pr_info("%s: cmdID = VFE_CMD_CAPTURE\n", __func__);
-		if (copy_from_user(&vfe_params,
-				(void __user *)(cmd->value),
-				sizeof(struct msm_camera_vfe_params_t))) {
-				rc = -EFAULT;
-				goto proc_general_done;
-		}
-
-		snapshot_cnt = vfe_params.capture_count;
-		vfe40_ctrl->share_ctrl->current_mode =
-			vfe_params.operation_mode;
-
-		rc = vfe40_capture(pmctl, snapshot_cnt, vfe40_ctrl);
-		break;
-	case VFE_CMD_START_RECORDING:
-		pr_info("vfe40_proc_general: cmdID = %s\n",
-			vfe40_general_cmd[cmd->id]);
-		rc = vfe40_start_recording(pmctl, vfe40_ctrl);
-		break;
-	case VFE_CMD_STOP_RECORDING:
-		pr_info("vfe40_proc_general: cmdID = %s\n",
-			vfe40_general_cmd[cmd->id]);
-		rc = vfe40_stop_recording(pmctl, vfe40_ctrl);
-		break;
-	case VFE_CMD_OPERATION_CFG: {
-		if (cmd->length != V40_OPERATION_CFG_LEN) {
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(V40_OPERATION_CFG_LEN, GFP_ATOMIC);
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			V40_OPERATION_CFG_LEN)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		rc = vfe40_operation_config(cmdp, vfe40_ctrl);
-		}
-		break;
-
-	case VFE_CMD_STATS_AE_START: {
-		if (vfe40_use_bayer_stats(vfe40_ctrl)) {
-			/* Error */
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		rc = vfe_stats_bg_buf_init(vfe40_ctrl);
-		if (rc < 0) {
-			pr_err("%s: cannot config ping/pong address of AEC",
-				 __func__);
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		old_val = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val |= BG_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase +
-			vfe40_cmd[cmd->id].offset,
-			cmdp, (vfe40_cmd[cmd->id].length));
-		}
-		break;
-	case VFE_CMD_STATS_AF_START: {
-		if (vfe40_use_bayer_stats(vfe40_ctrl)) {
-			/* Error */
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		rc = vfe_stats_bf_buf_init(vfe40_ctrl);
-		if (rc < 0) {
-			pr_err("%s: cannot config ping/pong address of AF",
-				__func__);
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		old_val = msm_camera_io_r(vfe40_ctrl->share_ctrl->vfebase +
-			VFE_MODULE_CFG);
-		old_val |= BF_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase +
-			vfe40_cmd[cmd->id].offset,
-			cmdp, (vfe40_cmd[cmd->id].length));
-		}
-		break;
-	case VFE_CMD_STATS_AWB_START: {
-		rc = vfe_stats_awb_buf_init(vfe40_ctrl, NULL);
-		if (rc < 0) {
-			pr_err("%s: cannot config ping/pong address of AWB",
-				 __func__);
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		old_val = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val |= AWB_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase +
-			vfe40_cmd[cmd->id].offset,
-			cmdp, (vfe40_cmd[cmd->id].length));
-		}
-		break;
-
-	case VFE_CMD_STATS_IHIST_START: {
-		rc = vfe_stats_ihist_buf_init(vfe40_ctrl);
-		if (rc < 0) {
-			pr_err("%s: cannot config ping/pong address of IHIST",
-				 __func__);
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		old_val = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val |= IHIST_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase +
-			vfe40_cmd[cmd->id].offset,
-			cmdp, (vfe40_cmd[cmd->id].length));
-		}
-		break;
-
-
-	case VFE_CMD_STATS_RS_START: {
-		rc = vfe_stats_rs_buf_init(vfe40_ctrl);
-		if (rc < 0) {
-			pr_err("%s: cannot config ping/pong address of RS",
-				__func__);
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase +
-			vfe40_cmd[cmd->id].offset,
-			cmdp, (vfe40_cmd[cmd->id].length));
-		}
-		break;
-
-	case VFE_CMD_STATS_CS_START: {
-		rc = vfe_stats_cs_buf_init(vfe40_ctrl);
-		if (rc < 0) {
-			pr_err("%s: cannot config ping/pong address of CS",
-				__func__);
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase +
-			vfe40_cmd[cmd->id].offset,
-			cmdp, (vfe40_cmd[cmd->id].length));
-		}
-		break;
-
-	case VFE_CMD_STATS_BG_START:
-	case VFE_CMD_STATS_BE_START:
-	case VFE_CMD_STATS_BF_START:
-	case VFE_CMD_STATS_BHIST_START: {
-		old_val = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + VFE_STATS_CFG);
-		module_val = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-
-		if (VFE_CMD_STATS_BE_START == cmd->id) {
-			module_val |= BE_ENABLE_MASK;
-			rc = vfe_stats_be_buf_init(vfe40_ctrl);
-			if (rc < 0) {
-				pr_err("%s: cannot config ping/pong address of BG",
-					__func__);
-				goto proc_general_done;
-			}
-		} else if (VFE_CMD_STATS_BG_START == cmd->id) {
-			module_val |= BG_ENABLE_MASK;
-			rc = vfe_stats_bg_buf_init(vfe40_ctrl);
-			if (rc < 0) {
-				pr_err("%s: cannot config ping/pong address of BG",
-					__func__);
-				goto proc_general_done;
-			}
-		} else if (VFE_CMD_STATS_BF_START == cmd->id) {
-			module_val |= BF_ENABLE_MASK;
-			rc = vfe_stats_bf_buf_init(vfe40_ctrl);
-			if (rc < 0) {
-				pr_err("%s: cannot config ping/pong address of BF",
-					__func__);
-				goto proc_general_done;
-			}
-		} else {
-			module_val |= BHIST_ENABLE_MASK;
-			old_val |= STATS_BHIST_ENABLE_MASK;
-			rc = vfe_stats_bhist_buf_init(vfe40_ctrl);
-			if (rc < 0) {
-				pr_err("%s: cannot config ping/pong address of BHist",
-					__func__);
-				goto proc_general_done;
-			}
-		}
-		msm_camera_io_w(old_val, vfe40_ctrl->share_ctrl->vfebase +
-			VFE_STATS_CFG);
-		msm_camera_io_w(module_val,
-			vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-				(void __user *)(cmd->value),
-				cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase +
-			vfe40_cmd[cmd->id].offset,
-			cmdp, (vfe40_cmd[cmd->id].length));
-		}
-		break;
-	case VFE_CMD_MCE_UPDATE:
-	case VFE_CMD_MCE_CFG:{
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		/* Incrementing with 4 so as to point to the 2nd Register as
-		the 2nd register has the mce_enable bit */
-		old_val = msm_camera_io_r(vfe40_ctrl->share_ctrl->vfebase +
-			V40_CHROMA_SUP_OFF + 4);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		new_val = *cmdp_local;
-		old_val &= MCE_EN_MASK;
-		new_val = new_val | old_val;
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase +
-			V40_CHROMA_SUP_OFF + 4, &new_val, 4);
-		cmdp_local += 1;
-
-		old_val = msm_camera_io_r(vfe40_ctrl->share_ctrl->vfebase +
-			V40_CHROMA_SUP_OFF + 8);
-		new_val = *cmdp_local;
-		old_val &= MCE_Q_K_MASK;
-		new_val = new_val | old_val;
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase +
-			V40_CHROMA_SUP_OFF + 8, &new_val, 4);
-		cmdp_local += 1;
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase +
-			vfe40_cmd[cmd->id].offset,
-			cmdp_local, (vfe40_cmd[cmd->id].length));
-		}
-		break;
-	case VFE_CMD_CHROMA_SUP_UPDATE:
-	case VFE_CMD_CHROMA_SUP_CFG:{
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		msm_camera_io_memcpy(vfe40_ctrl->share_ctrl->vfebase +
-			V40_CHROMA_SUP_OFF, cmdp_local, 4);
-
-		cmdp_local += 1;
-		new_val = *cmdp_local;
-		/* Incrementing with 4 so as to point to the 2nd Register as
-		 * the 2nd register has the mce_enable bit
-		 */
-		old_val = msm_camera_io_r(vfe40_ctrl->share_ctrl->vfebase +
-			V40_CHROMA_SUP_OFF + 4);
-		old_val &= ~MCE_EN_MASK;
-		new_val = new_val | old_val;
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase +
-			V40_CHROMA_SUP_OFF + 4, &new_val, 4);
-		cmdp_local += 1;
-
-		old_val = msm_camera_io_r(vfe40_ctrl->share_ctrl->vfebase +
-			V40_CHROMA_SUP_OFF + 8);
-		new_val = *cmdp_local;
-		old_val &= ~MCE_Q_K_MASK;
-		new_val = new_val | old_val;
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase +
-			V40_CHROMA_SUP_OFF + 8, &new_val, 4);
-		}
-		break;
-	case VFE_CMD_BLACK_LEVEL_CFG:
-		rc = -EFAULT;
-		goto proc_general_done;
-
-	case VFE_CMD_MESH_ROLL_OFF_CFG: {
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value) , cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase +
-			vfe40_cmd[cmd->id].offset,
-			cmdp_local, V40_MESH_ROLL_OFF_CFG_LEN);
-		cmdp_local += 9;
-		vfe40_program_dmi_cfg(ROLLOFF_RAM0_BANK0, vfe40_ctrl);
-		/* for loop for extrcting table. */
-		for (i = 0; i < (V40_MESH_ROLL_OFF_TABLE_SIZE * 2); i++) {
-			msm_camera_io_w(*cmdp_local,
-				vfe40_ctrl->share_ctrl->vfebase +
-				VFE_DMI_DATA_LO);
-			cmdp_local++;
-		}
-		CDBG("done writing mesh table\n");
-		vfe40_program_dmi_cfg(NO_MEM_SELECTED, vfe40_ctrl);
-	}
-	break;
-	case VFE_CMD_GET_MESH_ROLLOFF_TABLE:
-		break;
-
-	case VFE_CMD_LA_CFG:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase +
-			vfe40_cmd[cmd->id].offset,
-			cmdp_local, (vfe40_cmd[cmd->id].length));
-
-		cmdp_local += 1;
-		vfe40_write_la_cfg(LUMA_ADAPT_LUT_RAM_BANK0,
-						   cmdp_local, vfe40_ctrl);
-		break;
-
-	case VFE_CMD_LA_UPDATE: {
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-
-		cmdp_local = cmdp + 1;
-		old_val = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + V40_LA_OFF);
-		if (old_val != 0x0)
-			vfe40_write_la_cfg(LUMA_ADAPT_LUT_RAM_BANK0,
-				cmdp_local, vfe40_ctrl);
-		else
-			vfe40_write_la_cfg(LUMA_ADAPT_LUT_RAM_BANK1,
-				cmdp_local, vfe40_ctrl);
-		}
-		vfe40_ctrl->update_la = true;
-		break;
-
-	case VFE_CMD_GET_LA_TABLE:
-		temp1 = sizeof(uint32_t) * VFE40_LA_TABLE_LENGTH / 2;
-		if (cmd->length != temp1) {
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		cmdp = kzalloc(temp1, GFP_KERNEL);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		if (msm_camera_io_r(vfe40_ctrl->
-				share_ctrl->vfebase + V40_LA_OFF))
-			vfe40_program_dmi_cfg(LUMA_ADAPT_LUT_RAM_BANK1,
-						vfe40_ctrl);
-		else
-			vfe40_program_dmi_cfg(LUMA_ADAPT_LUT_RAM_BANK0,
-						vfe40_ctrl);
-		for (i = 0 ; i < (VFE40_LA_TABLE_LENGTH / 2) ; i++) {
-			*cmdp_local =
-				msm_camera_io_r(
-					vfe40_ctrl->share_ctrl->vfebase +
-					VFE_DMI_DATA_LO);
-			*cmdp_local |= (msm_camera_io_r(
-				vfe40_ctrl->share_ctrl->vfebase +
-				VFE_DMI_DATA_LO)) << 16;
-			cmdp_local++;
-		}
-		vfe40_program_dmi_cfg(NO_MEM_SELECTED, vfe40_ctrl);
-		if (copy_to_user((void __user *)(cmd->value), cmdp,
-			temp1)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		break;
-	case VFE_CMD_SK_ENHAN_CFG:
-	case VFE_CMD_SK_ENHAN_UPDATE:{
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase + V40_SCE_OFF,
-			cmdp, V40_SCE_LEN);
-		}
-		break;
-
-	case VFE_CMD_LIVESHOT:
-		/* Configure primary channel */
-		vfe40_start_liveshot(pmctl, vfe40_ctrl);
-		break;
-
-	case VFE_CMD_LINEARIZATION_CFG:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp, (void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase +
-			V40_LINEARIZATION_OFF1,
-			cmdp_local, V40_LINEARIZATION_LEN1);
-		cmdp_local = cmdp + 17;
-		vfe40_write_linear_cfg(BLACK_LUT_RAM_BANK0,
-					cmdp_local, vfe40_ctrl);
-		break;
-
-	case VFE_CMD_LINEARIZATION_UPDATE:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp, (void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		cmdp_local++;
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase +
-			V40_LINEARIZATION_OFF1 + 4,
-			cmdp_local, (V40_LINEARIZATION_LEN1 - 4));
-		cmdp_local = cmdp + 17;
-		/*extracting the bank select*/
-		old_val = msm_camera_io_r(
-				vfe40_ctrl->share_ctrl->vfebase +
-				V40_LINEARIZATION_OFF1);
-
-		if (old_val != 0x0)
-			vfe40_write_linear_cfg(BLACK_LUT_RAM_BANK0,
-						cmdp_local, vfe40_ctrl);
-		else
-			vfe40_write_linear_cfg(BLACK_LUT_RAM_BANK1,
-						cmdp_local, vfe40_ctrl);
-		vfe40_ctrl->update_linear = true;
-		break;
-
-	case VFE_CMD_GET_LINEARIZATON_TABLE:
-		temp1 = sizeof(uint32_t) * VFE40_LINEARIZATON_TABLE_LENGTH;
-		if (cmd->length != temp1) {
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		cmdp = kzalloc(temp1, GFP_KERNEL);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		if (msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase +
-			V40_LINEARIZATION_OFF1))
-			vfe40_program_dmi_cfg(BLACK_LUT_RAM_BANK1, vfe40_ctrl);
-		else
-			vfe40_program_dmi_cfg(BLACK_LUT_RAM_BANK0, vfe40_ctrl);
-		CDBG("%s: Linearization Table\n", __func__);
-		for (i = 0 ; i < VFE40_LINEARIZATON_TABLE_LENGTH ; i++) {
-			*cmdp_local = msm_camera_io_r(
-				vfe40_ctrl->share_ctrl->vfebase +
-				VFE_DMI_DATA_LO);
-			CDBG("%s: %08x\n", __func__, *cmdp_local);
-			cmdp_local++;
-		}
-		vfe40_program_dmi_cfg(NO_MEM_SELECTED, vfe40_ctrl);
-		if (copy_to_user((void __user *)(cmd->value), cmdp,
-			temp1)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		break;
-	case VFE_CMD_DEMOSAICV3:
-		if (cmd->length !=
-			V40_DEMOSAICV3_0_LEN+V40_DEMOSAICV3_1_LEN) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		new_val = *cmdp_local;
-
-		old_val = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + V40_DEMOSAICV3_0_OFF);
-		old_val &= DEMOSAIC_MASK;
-		new_val = new_val | old_val;
-		*cmdp_local = new_val;
-
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase + V40_DEMOSAICV3_0_OFF,
-			cmdp_local, V40_DEMOSAICV3_0_LEN);
-		cmdp_local += 1;
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase + V40_DEMOSAICV3_1_OFF,
-			cmdp_local, V40_DEMOSAICV3_1_LEN);
-		break;
-
-	case VFE_CMD_DEMOSAICV3_UPDATE:
-		if (cmd->length !=
-			V40_DEMOSAICV3_0_LEN * V40_DEMOSAICV3_UP_REG_CNT) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		new_val = *cmdp_local;
-
-		old_val = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + V40_DEMOSAICV3_0_OFF);
-		old_val &= DEMOSAIC_MASK;
-		new_val = new_val | old_val;
-		*cmdp_local = new_val;
-
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase + V40_DEMOSAICV3_0_OFF,
-			cmdp_local, V40_DEMOSAICV3_0_LEN);
-		/* As the address space is not contiguous increment by 2
-		 * before copying to next address space */
-		cmdp_local += 1;
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase + V40_DEMOSAICV3_1_OFF,
-			cmdp_local, 2 * V40_DEMOSAICV3_0_LEN);
-		/* As the address space is not contiguous increment by 2
-		 * before copying to next address space */
-		cmdp_local += 2;
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase + V40_DEMOSAICV3_2_OFF,
-			cmdp_local, 2 * V40_DEMOSAICV3_0_LEN);
-		break;
-
-	case VFE_CMD_DEMOSAICV3_ABCC_CFG:
-		rc = -EFAULT;
-		break;
-
-	case VFE_CMD_DEMOSAICV3_ABF_UPDATE:/* 116 ABF update  */
-	case VFE_CMD_DEMOSAICV3_ABF_CFG: { /* 108 ABF config  */
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		new_val = *cmdp_local;
-
-		old_val = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + V40_DEMOSAICV3_0_OFF);
-		old_val &= ABF_MASK;
-		new_val = new_val | old_val;
-		*cmdp_local = new_val;
-
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase + V40_DEMOSAICV3_0_OFF,
-			cmdp_local, 4);
-
-		cmdp_local += 1;
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase +
-			vfe40_cmd[cmd->id].offset,
-			cmdp_local, (vfe40_cmd[cmd->id].length));
-		}
-		break;
-
-	case VFE_CMD_DEMOSAICV3_DBCC_CFG:
-	case VFE_CMD_DEMOSAICV3_DBCC_UPDATE:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		new_val = *cmdp_local;
-
-		old_val = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + V40_DEMOSAICV3_0_OFF);
-		old_val &= DBCC_MASK;
-
-		new_val = new_val | old_val;
-		*cmdp_local = new_val;
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase + V40_DEMOSAICV3_0_OFF,
-			cmdp_local, 4);
-		cmdp_local += 1;
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase +
-			vfe40_cmd[cmd->id].offset,
-			cmdp_local, (vfe40_cmd[cmd->id].length));
-		break;
-
-	case VFE_CMD_DEMOSAICV3_DBPC_CFG:
-	case VFE_CMD_DEMOSAICV3_DBPC_UPDATE:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-		new_val = *cmdp_local;
-
-		old_val = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + V40_DEMOSAICV3_0_OFF);
-		old_val &= DBPC_MASK;
-
-		new_val = new_val | old_val;
-		*cmdp_local = new_val;
-		msm_camera_io_memcpy(vfe40_ctrl->share_ctrl->vfebase +
-			V40_DEMOSAICV3_0_OFF,
-			cmdp_local, V40_DEMOSAICV3_0_LEN);
-		cmdp_local += 1;
-		msm_camera_io_memcpy(vfe40_ctrl->share_ctrl->vfebase +
-			V40_DEMOSAICV3_DBPC_CFG_OFF,
-			cmdp_local, V40_DEMOSAICV3_DBPC_LEN);
-		cmdp_local += 1;
-		msm_camera_io_memcpy(vfe40_ctrl->share_ctrl->vfebase +
-			V40_DEMOSAICV3_DBPC_CFG_OFF0,
-			cmdp_local, V40_DEMOSAICV3_DBPC_LEN);
-		cmdp_local += 1;
-		msm_camera_io_memcpy(vfe40_ctrl->share_ctrl->vfebase +
-			V40_DEMOSAICV3_DBPC_CFG_OFF1,
-			cmdp_local, V40_DEMOSAICV3_DBPC_LEN);
-		cmdp_local += 1;
-		msm_camera_io_memcpy(vfe40_ctrl->share_ctrl->vfebase +
-			V40_DEMOSAICV3_DBPC_CFG_OFF2,
-			cmdp_local, V40_DEMOSAICV3_DBPC_LEN);
-		break;
-
-	case VFE_CMD_RGB_G_CFG: {
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase + V40_RGB_G_OFF,
-			cmdp, 4);
-		cmdp += 1;
-
-		vfe40_write_gamma_cfg(RGBLUT_RAM_CH0_BANK0, cmdp, vfe40_ctrl);
-		vfe40_write_gamma_cfg(RGBLUT_RAM_CH1_BANK0, cmdp, vfe40_ctrl);
-		vfe40_write_gamma_cfg(RGBLUT_RAM_CH2_BANK0, cmdp, vfe40_ctrl);
-		}
-	    cmdp -= 1;
-		break;
-
-	case VFE_CMD_RGB_G_UPDATE: {
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp, (void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-
-		old_val = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + V40_RGB_G_OFF);
-		cmdp += 1;
-		if (old_val != 0x0) {
-			vfe40_write_gamma_cfg(
-				RGBLUT_RAM_CH0_BANK0, cmdp, vfe40_ctrl);
-			vfe40_write_gamma_cfg(
-				RGBLUT_RAM_CH1_BANK0, cmdp, vfe40_ctrl);
-			vfe40_write_gamma_cfg(
-				RGBLUT_RAM_CH2_BANK0, cmdp, vfe40_ctrl);
-		} else {
-			vfe40_write_gamma_cfg(
-				RGBLUT_RAM_CH0_BANK1, cmdp, vfe40_ctrl);
-			vfe40_write_gamma_cfg(
-				RGBLUT_RAM_CH1_BANK1, cmdp, vfe40_ctrl);
-			vfe40_write_gamma_cfg(
-				RGBLUT_RAM_CH2_BANK1, cmdp, vfe40_ctrl);
-		}
-		}
-		vfe40_ctrl->update_gamma = TRUE;
-		cmdp -= 1;
-		break;
-
-	case VFE_CMD_GET_RGB_G_TABLE:
-		temp1 = sizeof(uint32_t) * VFE40_GAMMA_NUM_ENTRIES * 3;
-		if (cmd->length != temp1) {
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		cmdp = kzalloc(temp1, GFP_KERNEL);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		cmdp_local = cmdp;
-
-		old_val = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + V40_RGB_G_OFF);
-		temp2 = old_val ? RGBLUT_RAM_CH0_BANK1 :
-			RGBLUT_RAM_CH0_BANK0;
-		for (i = 0; i < 3; i++) {
-			vfe40_read_gamma_cfg(temp2,
-				cmdp_local + (VFE40_GAMMA_NUM_ENTRIES * i),
-				vfe40_ctrl);
-			temp2 += 2;
-		}
-		if (copy_to_user((void __user *)(cmd->value), cmdp,
-			temp1)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		break;
-
-	case VFE_CMD_STATS_AWB_STOP: {
-		old_val = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~AWB_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		}
-		break;
-	case VFE_CMD_STATS_BG_STOP: {
-		old_val = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~BG_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		}
-		break;
-	case VFE_CMD_STATS_BF_STOP: {
-		old_val = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~BF_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-		vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-
-		rc = vfe40_stats_flush_enqueue(vfe40_ctrl,
-				MSM_STATS_TYPE_BF);
-		if (rc < 0) {
-			pr_err("%s: dq stats buf err = %d",
-				   __func__, rc);
-			return -EINVAL;
-			}
-		}
-		break;
-
-	case VFE_CMD_STATS_BE_STOP: {
-		old_val = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~BE_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		}
-		break;
-
-	case VFE_CMD_STATS_IHIST_STOP: {
-		old_val = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~IHIST_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		}
-		break;
-
-	case VFE_CMD_STATS_RS_STOP: {
-		old_val = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~RS_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		}
-		break;
-
-	case VFE_CMD_STATS_CS_STOP: {
-		old_val = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= ~CS_ENABLE_MASK;
-		msm_camera_io_w(old_val,
-			vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		}
-		break;
-
-	case VFE_CMD_STATS_BHIST_STOP: {
-		if (!vfe40_use_bayer_stats(vfe40_ctrl)) {
-			/* Error */
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		old_val = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + VFE_STATS_CFG);
-
-		if (VFE_CMD_STATS_BHIST_STOP == cmd->id)
-			old_val &= ~STATS_BHIST_ENABLE_MASK;
-
-		msm_camera_io_w(old_val,
-			vfe40_ctrl->share_ctrl->vfebase + VFE_STATS_CFG);
-		}
-		break;
-
-	case VFE_CMD_STOP:
-		pr_info("vfe40_proc_general: cmdID = %s\n",
-			vfe40_general_cmd[cmd->id]);
-		if (copy_from_user(&vfe_params,
-				(void __user *)(cmd->value),
-				sizeof(struct msm_camera_vfe_params_t))) {
-				rc = -EFAULT;
-				goto proc_general_done;
-		}
-
-		vfe40_ctrl->share_ctrl->current_mode =
-			vfe_params.operation_mode;
-		vfe40_stop(vfe40_ctrl);
-		break;
-
-	case VFE_CMD_SYNC_TIMER_SETTING:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp, (void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		vfe40_sync_timer_start(cmdp, vfe40_ctrl);
-		break;
-
-	case VFE_CMD_MODULE_CFG: {
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp,
-			(void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		*cmdp &= ~STATS_ENABLE_MASK;
-		old_val = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase + VFE_MODULE_CFG);
-		old_val &= STATS_ENABLE_MASK;
-		*cmdp |= old_val;
-
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase +
-			vfe40_cmd[cmd->id].offset,
-			cmdp, (vfe40_cmd[cmd->id].length));
-		}
-		break;
-
-	case VFE_CMD_ZSL:
-		if (copy_from_user(&vfe_params,
-				(void __user *)(cmd->value),
-				sizeof(struct msm_camera_vfe_params_t))) {
-				rc = -EFAULT;
-				goto proc_general_done;
-		}
-
-		vfe40_ctrl->share_ctrl->current_mode =
-			vfe_params.operation_mode;
-
-		rc = vfe40_zsl(pmctl, vfe40_ctrl);
-		break;
-
-	case VFE_CMD_ASF_CFG:
-	case VFE_CMD_ASF_UPDATE:
-		cmdp = kmalloc(cmd->length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		if (copy_from_user(cmdp, (void __user *)(cmd->value),
-			cmd->length)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase +
-			vfe40_cmd[cmd->id].offset,
-			cmdp, (vfe40_cmd[cmd->id].length));
-		cmdp_local = cmdp + V40_ASF_LEN/4;
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase +
-			V40_ASF_SPECIAL_EFX_CFG_OFF,
-			cmdp_local, V40_ASF_SPECIAL_EFX_CFG_LEN);
-		break;
-
-	case VFE_CMD_GET_HW_VERSION:
-		if (cmd->length != V40_GET_HW_VERSION_LEN) {
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(V40_GET_HW_VERSION_LEN, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		*cmdp = msm_camera_io_r(
-			vfe40_ctrl->share_ctrl->vfebase+V40_GET_HW_VERSION_OFF);
-		if (copy_to_user((void __user *)(cmd->value), cmdp,
-			V40_GET_HW_VERSION_LEN)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		break;
-	case VFE_CMD_GET_REG_DUMP:
-		temp1 = sizeof(uint32_t) *
-			vfe40_ctrl->share_ctrl->register_total;
-		if (cmd->length != temp1) {
-			rc = -EINVAL;
-			goto proc_general_done;
-		}
-		cmdp = kmalloc(temp1, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-		msm_camera_io_dump(vfe40_ctrl->share_ctrl->vfebase,
-			vfe40_ctrl->share_ctrl->register_total*4);
-		CDBG("%s: %p %p %d\n", __func__, (void *)cmdp,
-			vfe40_ctrl->share_ctrl->vfebase, temp1);
-		memcpy_fromio((void *)cmdp,
-			vfe40_ctrl->share_ctrl->vfebase, temp1);
-		if (copy_to_user((void __user *)(cmd->value), cmdp, temp1)) {
-			rc = -EFAULT;
-			goto proc_general_done;
-		}
-		break;
-	case VFE_CMD_FRAME_SKIP_CFG:
-		if (cmd->length != vfe40_cmd[cmd->id].length)
-			return -EINVAL;
-
-		cmdp = kmalloc(vfe40_cmd[cmd->id].length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-
-		if (copy_from_user((cmdp), (void __user *)cmd->value,
-				cmd->length)) {
-			rc = -EFAULT;
-			pr_err("%s copy from user failed for cmd %d",
-				__func__, cmd->id);
-			break;
-		}
-
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase +
-			vfe40_cmd[cmd->id].offset,
-			cmdp, (vfe40_cmd[cmd->id].length));
-		vfe40_ctrl->frame_skip_cnt = ((uint32_t)
-			*cmdp & VFE_FRAME_SKIP_PERIOD_MASK) + 1;
-		vfe40_ctrl->frame_skip_pattern = (uint32_t)(*(cmdp + 2));
-		break;
-	case VFE_CMD_STOP_LIVESHOT:
-		CDBG("%s Stopping liveshot ", __func__);
-		vfe40_stop_liveshot(pmctl, vfe40_ctrl);
-		break;
-	default:
-		if (cmd->length != vfe40_cmd[cmd->id].length)
-			return -EINVAL;
-
-		cmdp = kmalloc(vfe40_cmd[cmd->id].length, GFP_ATOMIC);
-		if (!cmdp) {
-			rc = -ENOMEM;
-			goto proc_general_done;
-		}
-
-		if (copy_from_user((cmdp), (void __user *)cmd->value,
-				cmd->length)) {
-			rc = -EFAULT;
-			pr_err("%s copy from user failed for cmd %d",
-				__func__, cmd->id);
-			goto proc_general_done;
-		}
-		msm_camera_io_memcpy(
-			vfe40_ctrl->share_ctrl->vfebase +
-			vfe40_cmd[cmd->id].offset,
-			cmdp, (vfe40_cmd[cmd->id].length));
-		break;
-
-	}
-
-proc_general_done:
-	kfree(cmdp);
-
-	return rc;
-}
-
-static inline void vfe40_read_irq_status(
-	struct axi_ctrl_t *axi_ctrl, struct vfe40_irq_status *out)
-{
-	uint32_t *temp;
-	memset(out, 0, sizeof(struct vfe40_irq_status));
-	temp = (uint32_t *)(axi_ctrl->share_ctrl->vfebase + VFE_IRQ_STATUS_0);
-	out->vfeIrqStatus0 = msm_camera_io_r(temp);
-
-	temp = (uint32_t *)(axi_ctrl->share_ctrl->vfebase + VFE_IRQ_STATUS_1);
-	out->vfeIrqStatus1 = msm_camera_io_r(temp);
-
-	temp = (uint32_t *)(axi_ctrl->share_ctrl->vfebase + VFE_CAMIF_STATUS);
-	out->camifStatus = msm_camera_io_r(temp);
-	CDBG("camifStatus  = 0x%x\n", out->camifStatus);
-
-	/* clear the pending interrupt of the same kind.*/
-	msm_camera_io_w(out->vfeIrqStatus0,
-		axi_ctrl->share_ctrl->vfebase + VFE_IRQ_CLEAR_0);
-	msm_camera_io_w(out->vfeIrqStatus1,
-		axi_ctrl->share_ctrl->vfebase + VFE_IRQ_CLEAR_1);
-
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(1, axi_ctrl->share_ctrl->vfebase + VFE_IRQ_CMD);
-
-}
-
-void axi_stop_pix(struct vfe_share_ctrl_t *share_ctrl)
-{
-	uint32_t operation_mode =
-	share_ctrl->current_mode & ~(VFE_OUTPUTS_RDI0|
-		VFE_OUTPUTS_RDI1);
-	uint32_t irq_comp_mask, irq_mask;
-	uint32_t reg_update = 0x1;
-
-	irq_comp_mask =
-		msm_camera_io_r(share_ctrl->vfebase +
-			VFE_IRQ_COMP_MASK);
-	irq_mask = msm_camera_io_r(share_ctrl->vfebase +
-			VFE_IRQ_MASK_0);
-
-	switch (share_ctrl->cmd_type) {
-	case AXI_CMD_PREVIEW: {
-		switch (operation_mode) {
-		case VFE_OUTPUTS_PREVIEW:
-		case VFE_OUTPUTS_PREVIEW_AND_VIDEO:
-			if (share_ctrl->comp_output_mode &
-				VFE40_OUTPUT_MODE_PRIMARY) {
-				msm_camera_io_w(0, share_ctrl->vfebase
-					+ vfe40_AXI_WM_CFG[share_ctrl->
-					outpath.out0.ch0]);
-				msm_camera_io_w(0, share_ctrl->vfebase
-					+ vfe40_AXI_WM_CFG[share_ctrl->
-					outpath.out0.ch1]);
-				irq_comp_mask &= ~(
-					0x1 << share_ctrl->outpath.out0.ch0 |
-					0x1 << share_ctrl->outpath.out0.ch1);
-				share_ctrl->outpath.output_mode |=
-					VFE40_OUTPUT_MODE_PRIMARY;
-			} else if (share_ctrl->comp_output_mode &
-					VFE40_OUTPUT_MODE_PRIMARY_ALL_CHNLS) {
-				msm_camera_io_w(0, share_ctrl->vfebase
-					+ vfe40_AXI_WM_CFG[share_ctrl->
-					outpath.out0.ch0]);
-				msm_camera_io_w(0, share_ctrl->vfebase
-					+ vfe40_AXI_WM_CFG[share_ctrl->
-					outpath.out0.ch1]);
-				msm_camera_io_w(0, share_ctrl->vfebase
-					+ vfe40_AXI_WM_CFG[share_ctrl->
-					outpath.out0.ch2]);
-				irq_comp_mask &= ~(
-					0x1 << share_ctrl->outpath.out0.ch0 |
-					0x1 << share_ctrl->outpath.out0.ch1 |
-					0x1 << share_ctrl->outpath.out0.ch2);
-				share_ctrl->outpath.output_mode |=
-					VFE40_OUTPUT_MODE_PRIMARY_ALL_CHNLS;
-			}
-			irq_mask &= ~VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE0_MASK;
-			break;
-		default:
-			if (share_ctrl->comp_output_mode &
-				VFE40_OUTPUT_MODE_SECONDARY) {
-				msm_camera_io_w(0, share_ctrl->vfebase
-					+ vfe40_AXI_WM_CFG[share_ctrl->
-					outpath.out1.ch0]);
-				msm_camera_io_w(0, share_ctrl->vfebase
-					+ vfe40_AXI_WM_CFG[share_ctrl->
-					outpath.out1.ch1]);
-				irq_comp_mask &= ~(
-					0x1 << share_ctrl->outpath.out1.ch0 |
-					0x1 << share_ctrl->outpath.out1.ch1);
-				share_ctrl->outpath.output_mode |=
-					VFE40_OUTPUT_MODE_SECONDARY;
-			} else if (share_ctrl->comp_output_mode &
-				VFE40_OUTPUT_MODE_SECONDARY_ALL_CHNLS) {
-				msm_camera_io_w(0, share_ctrl->vfebase
-					+ vfe40_AXI_WM_CFG[share_ctrl->
-					outpath.out1.ch0]);
-				msm_camera_io_w(0, share_ctrl->vfebase
-					+ vfe40_AXI_WM_CFG[share_ctrl->
-					outpath.out1.ch1]);
-				msm_camera_io_w(0, share_ctrl->vfebase
-					+ vfe40_AXI_WM_CFG[share_ctrl->
-					outpath.out1.ch2]);
-				irq_comp_mask &= ~(
-					0x1 << share_ctrl->outpath.out1.ch0 |
-					0x1 << share_ctrl->outpath.out1.ch1 |
-					0x1 << share_ctrl->outpath.out1.ch2);
-				share_ctrl->outpath.output_mode |=
-					VFE40_OUTPUT_MODE_SECONDARY_ALL_CHNLS;
-			}
-			irq_mask &= ~VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE1_MASK;
-			break;
-			}
-		}
-		break;
-	default:
-		if (share_ctrl->comp_output_mode &
-			VFE40_OUTPUT_MODE_PRIMARY) {
-			msm_camera_io_w(0, share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[share_ctrl->
-				outpath.out0.ch0]);
-			msm_camera_io_w(0, share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[share_ctrl->
-				outpath.out0.ch1]);
-			irq_comp_mask &= ~(
-				0x1 << share_ctrl->outpath.out0.ch0 |
-				0x1 << share_ctrl->outpath.out0.ch1);
-			irq_mask &= ~VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE0_MASK;
-			share_ctrl->outpath.output_mode |=
-					VFE40_OUTPUT_MODE_PRIMARY;
-		} else if (share_ctrl->comp_output_mode &
-				VFE40_OUTPUT_MODE_PRIMARY_ALL_CHNLS) {
-			msm_camera_io_w(0, share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[share_ctrl->
-				outpath.out0.ch0]);
-			msm_camera_io_w(0, share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[share_ctrl->
-				outpath.out0.ch1]);
-			msm_camera_io_w(0, share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[share_ctrl->
-				outpath.out0.ch2]);
-			irq_comp_mask &= ~(
-				0x1 << share_ctrl->outpath.out0.ch0 |
-				0x1 << share_ctrl->outpath.out0.ch1 |
-				0x1 << share_ctrl->outpath.out0.ch2);
-			irq_mask &= ~VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE0_MASK;
-			share_ctrl->outpath.output_mode |=
-					VFE40_OUTPUT_MODE_PRIMARY_ALL_CHNLS;
-		}
-
-		if (share_ctrl->comp_output_mode &
-			VFE40_OUTPUT_MODE_SECONDARY) {
-			msm_camera_io_w(0, share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[share_ctrl->
-				outpath.out1.ch0]);
-			msm_camera_io_w(0, share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[share_ctrl->outpath.out1.ch1]);
-			irq_comp_mask &= ~(
-				0x1 << share_ctrl->outpath.out1.ch0 |
-				0x1 << share_ctrl->outpath.out1.ch1);
-			irq_mask &= ~VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE1_MASK;
-			share_ctrl->outpath.output_mode |=
-					VFE40_OUTPUT_MODE_SECONDARY;
-		} else if (share_ctrl->comp_output_mode &
-			VFE40_OUTPUT_MODE_SECONDARY_ALL_CHNLS) {
-			msm_camera_io_w(0, share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[share_ctrl->outpath.out1.ch0]);
-			msm_camera_io_w(0, share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[share_ctrl->outpath.out1.ch1]);
-			msm_camera_io_w(0, share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[share_ctrl->outpath.out1.ch2]);
-			irq_comp_mask &= ~(
-				0x1 << share_ctrl->outpath.out1.ch0 |
-				0x1 << share_ctrl->outpath.out1.ch1 |
-				0x1 << share_ctrl->outpath.out1.ch2);
-			irq_mask &= ~VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE1_MASK;
-			share_ctrl->outpath.output_mode |=
-					VFE40_OUTPUT_MODE_SECONDARY_ALL_CHNLS;
-		}
-		break;
-	}
-
-	msm_camera_io_w_mb(reg_update,
-		share_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-	msm_camera_io_w(irq_comp_mask,
-		share_ctrl->vfebase + VFE_IRQ_COMP_MASK);
-	msm_camera_io_w(irq_mask, share_ctrl->vfebase +
-			VFE_IRQ_MASK_0);
-}
-
-void axi_stop_rdi0(struct vfe_share_ctrl_t *share_ctrl)
-{
-	uint32_t reg_update = 0x2;
-	uint32_t irq_mask;
-	irq_mask = msm_camera_io_r(share_ctrl->vfebase +
-			VFE_IRQ_MASK_0);
-
-	if (share_ctrl->current_mode & VFE_OUTPUTS_RDI0) {
-		msm_camera_io_w(0, share_ctrl->vfebase +
-			vfe40_AXI_WM_CFG[share_ctrl->outpath.out2.ch0]);
-		irq_mask &= ~(0x1 << (share_ctrl->outpath.out2.ch0 +
-				VFE_WM_OFFSET));
-	}
-	msm_camera_io_w_mb(reg_update,
-		share_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-	msm_camera_io_w(irq_mask, share_ctrl->vfebase +
-			VFE_IRQ_MASK_0);
-}
-
-void axi_stop_rdi1(struct vfe_share_ctrl_t *share_ctrl)
-{
-	uint32_t reg_update = 0x4;
-	uint32_t irq_mask;
-	irq_mask = msm_camera_io_r(share_ctrl->vfebase +
-			VFE_IRQ_MASK_0);
-
-	if (share_ctrl->current_mode & VFE_OUTPUTS_RDI1) {
-		msm_camera_io_w(1, share_ctrl->vfebase +
-			vfe40_AXI_WM_CFG[share_ctrl->outpath.out3.ch0]);
-		irq_mask &= ~(0x1 << (share_ctrl->outpath.out3.ch0 +
-			VFE_WM_OFFSET));
-	}
-	msm_camera_io_w_mb(reg_update,
-		share_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-	msm_camera_io_w(irq_mask, share_ctrl->vfebase +
-			VFE_IRQ_MASK_0);
-}
-
-void axi_stop_process(struct vfe_share_ctrl_t *share_ctrl)
-{
-	uint32_t operation_mode =
-	share_ctrl->current_mode & ~(VFE_OUTPUTS_RDI0|
-		VFE_OUTPUTS_RDI1);
-
-	if (share_ctrl->current_mode & VFE_OUTPUTS_RDI0) {
-		axi_stop_rdi0(share_ctrl);
-		share_ctrl->comp_output_mode &= ~VFE40_OUTPUT_MODE_TERTIARY1;
-	}
-	if (share_ctrl->current_mode & VFE_OUTPUTS_RDI1) {
-		axi_stop_rdi1(share_ctrl);
-		share_ctrl->comp_output_mode &= ~VFE40_OUTPUT_MODE_TERTIARY2;
-	}
-	if (operation_mode) {
-		axi_stop_pix(share_ctrl);
-		share_ctrl->comp_output_mode &=
-				~(share_ctrl->outpath.output_mode);
-	}
-}
-
-static void vfe40_process_reg_update_irq(
-		struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	unsigned long flags;
-	struct vfe_share_ctrl_t *share_ctrl = vfe40_ctrl->share_ctrl;
-
-	if (atomic_cmpxchg(
-		&share_ctrl->pix0_update_ack_pending, 2, 0) == 2) {
-		axi_stop_pix(share_ctrl);
-		msm_camera_io_w_mb(
-				CAMIF_COMMAND_STOP_AT_FRAME_BOUNDARY,
-				share_ctrl->vfebase + VFE_CAMIF_COMMAND);
-		axi_disable_irq(share_ctrl);
-		vfe40_send_isp_msg(&vfe40_ctrl->subdev,
-			share_ctrl->vfeFrameId,
-			MSG_ID_PIX0_UPDATE_ACK);
-		share_ctrl->comp_output_mode &=
-				~(share_ctrl->outpath.output_mode);
-		share_ctrl->current_mode &=
-			(VFE_OUTPUTS_RDI0|VFE_OUTPUTS_RDI0);
-	}  else {
-		if (share_ctrl->recording_state == VFE_STATE_START_REQUESTED) {
-			if (share_ctrl->operation_mode &
-				VFE_OUTPUTS_VIDEO_AND_PREVIEW) {
-				msm_camera_io_w(1,
-					share_ctrl->vfebase + vfe40_AXI_WM_CFG[
-				share_ctrl->outpath.out0.ch0]);
-				msm_camera_io_w(1,
-					share_ctrl->vfebase + vfe40_AXI_WM_CFG[
-				share_ctrl->outpath.out0.ch1]);
-			} else if (share_ctrl->operation_mode &
-				VFE_OUTPUTS_PREVIEW_AND_VIDEO) {
-				msm_camera_io_w(1,
-					share_ctrl->vfebase + vfe40_AXI_WM_CFG[
-				share_ctrl->outpath.out1.ch0]);
-				msm_camera_io_w(1,
-					share_ctrl->vfebase + vfe40_AXI_WM_CFG[
-				share_ctrl->outpath.out1.ch1]);
-		}
-			share_ctrl->recording_state = VFE_STATE_STARTED;
-		msm_camera_io_w_mb(1,
-				share_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-		CDBG("start video triggered .\n");
-		} else if (share_ctrl->recording_state ==
-			VFE_STATE_STOP_REQUESTED) {
-			if (share_ctrl->operation_mode &
-				VFE_OUTPUTS_VIDEO_AND_PREVIEW) {
-				msm_camera_io_w(0,
-					share_ctrl->vfebase + vfe40_AXI_WM_CFG[
-				share_ctrl->outpath.out0.ch0]);
-				msm_camera_io_w(0,
-					share_ctrl->vfebase + vfe40_AXI_WM_CFG[
-				share_ctrl->outpath.out0.ch1]);
-			} else if (share_ctrl->operation_mode &
-				VFE_OUTPUTS_PREVIEW_AND_VIDEO) {
-				msm_camera_io_w(0,
-					share_ctrl->vfebase + vfe40_AXI_WM_CFG[
-				share_ctrl->outpath.out1.ch0]);
-				msm_camera_io_w(0,
-					share_ctrl->vfebase + vfe40_AXI_WM_CFG[
-				share_ctrl->outpath.out1.ch1]);
-		}
-		CDBG("stop video triggered .\n");
-	}
-
-		if (atomic_cmpxchg(
-			&share_ctrl->pix0_update_ack_pending, 1, 0) == 1) {
-			share_ctrl->comp_output_mode |=
-				(share_ctrl->outpath.output_mode
-				& ~(VFE40_OUTPUT_MODE_TERTIARY1|
-					VFE40_OUTPUT_MODE_TERTIARY2));
-		vfe40_send_isp_msg(&vfe40_ctrl->subdev,
-				share_ctrl->vfeFrameId, MSG_ID_PIX0_UPDATE_ACK);
-			share_ctrl->current_mode &=
-				(VFE_OUTPUTS_RDI0|VFE_OUTPUTS_RDI0);
-	} else {
-		if (share_ctrl->recording_state ==
-			VFE_STATE_STOP_REQUESTED) {
-				share_ctrl->recording_state = VFE_STATE_STOPPED;
-			/* request a reg update and send STOP_REC_ACK
-			 * when we process the next reg update irq.
-			 */
-			msm_camera_io_w_mb(1, share_ctrl->vfebase +
-						VFE_REG_UPDATE_CMD);
-		} else if (share_ctrl->recording_state ==
-					VFE_STATE_STOPPED) {
-			vfe40_send_isp_msg(&vfe40_ctrl->subdev,
-					share_ctrl->vfeFrameId,
-				MSG_ID_STOP_REC_ACK);
-				share_ctrl->recording_state = VFE_STATE_IDLE;
-		}
-		spin_lock_irqsave(&share_ctrl->update_ack_lock, flags);
-		if (share_ctrl->update_ack_pending == TRUE) {
-			share_ctrl->update_ack_pending = FALSE;
-			spin_unlock_irqrestore(
-				&share_ctrl->update_ack_lock, flags);
-			vfe40_send_isp_msg(&vfe40_ctrl->subdev,
-				share_ctrl->vfeFrameId, MSG_ID_UPDATE_ACK);
-		} else {
-			spin_unlock_irqrestore(
-					&share_ctrl->update_ack_lock, flags);
-		}
-	}
-
-	switch (share_ctrl->liveshot_state) {
-	case VFE_STATE_START_REQUESTED:
-		CDBG("%s enabling liveshot output\n", __func__);
-			if (share_ctrl->comp_output_mode &
-			VFE40_OUTPUT_MODE_PRIMARY) {
-				msm_camera_io_w(1, share_ctrl->vfebase +
-					vfe40_AXI_WM_CFG[
-				share_ctrl->outpath.out0.ch0]);
-				msm_camera_io_w(1, share_ctrl->vfebase +
-					vfe40_AXI_WM_CFG[
-				share_ctrl->outpath.out0.ch1]);
-
-				share_ctrl->liveshot_state =
-				VFE_STATE_STARTED;
-				msm_camera_io_w_mb(1, share_ctrl->vfebase +
-				VFE_REG_UPDATE_CMD);
-		}
-		break;
-	case VFE_STATE_STARTED:
-		CDBG("%s disabling liveshot output\n", __func__);
-		if (share_ctrl->vfe_capture_count >= 1) {
-			if (share_ctrl->vfe_capture_count == 1 &&
-				(share_ctrl->comp_output_mode &
-				VFE40_OUTPUT_MODE_PRIMARY)) {
-				msm_camera_io_w(0, share_ctrl->vfebase +
-					vfe40_AXI_WM_CFG[
-					share_ctrl->outpath.out0.ch0]);
-				msm_camera_io_w(0, share_ctrl->vfebase +
-					vfe40_AXI_WM_CFG[
-					share_ctrl->outpath.out0.ch1]);
-				msm_camera_io_w_mb(1, share_ctrl->vfebase +
-					VFE_REG_UPDATE_CMD);
-			}
-			share_ctrl->vfe_capture_count--;
-		}
-		break;
-	case VFE_STATE_STOP_REQUESTED:
-		CDBG("%s disabling liveshot output from stream off\n",
-			__func__);
-		if (share_ctrl->comp_output_mode &
-			VFE40_OUTPUT_MODE_PRIMARY) {
-			/* Stop requested, stop write masters, and
-			 * trigger REG_UPDATE. Send STOP_LS_ACK in
-			 * next reg update. */
-			msm_camera_io_w(0, share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[
-			share_ctrl->outpath.out0.ch0]);
-			msm_camera_io_w(0, share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[
-			share_ctrl->outpath.out0.ch1]);
-			share_ctrl->liveshot_state = VFE_STATE_STOPPED;
-			msm_camera_io_w_mb(1, share_ctrl->vfebase +
-				VFE_REG_UPDATE_CMD);
-		}
-		break;
-	case VFE_STATE_STOPPED:
-		CDBG("%s Sending STOP_LS ACK\n", __func__);
-		vfe40_send_isp_msg(&vfe40_ctrl->subdev,
-			share_ctrl->vfeFrameId, MSG_ID_STOP_LS_ACK);
-			share_ctrl->liveshot_state = VFE_STATE_IDLE;
-		break;
-	default:
-		break;
-	}
-
-	if ((share_ctrl->operation_mode & VFE_OUTPUTS_THUMB_AND_MAIN) ||
-		(share_ctrl->operation_mode &
-		VFE_OUTPUTS_MAIN_AND_THUMB) ||
-		(share_ctrl->operation_mode &
-		VFE_OUTPUTS_THUMB_AND_JPEG) ||
-		(share_ctrl->operation_mode &
-		VFE_OUTPUTS_JPEG_AND_THUMB)) {
-		/* in snapshot mode */
-		/* later we need to add check for live snapshot mode. */
-		if (vfe40_ctrl->frame_skip_pattern & (0x1 <<
-			(vfe40_ctrl->snapshot_frame_cnt %
-				vfe40_ctrl->frame_skip_cnt))) {
-				share_ctrl->vfe_capture_count--;
-			/* if last frame to be captured: */
-				if (share_ctrl->vfe_capture_count == 0) {
-					/* stop the bus output: */
-					if (share_ctrl->comp_output_mode
-					& VFE40_OUTPUT_MODE_PRIMARY) {
-						msm_camera_io_w(0,
-							share_ctrl->vfebase+
-							vfe40_AXI_WM_CFG[
-							share_ctrl->
-							outpath.out0.ch0]);
-						msm_camera_io_w(0,
-							share_ctrl->vfebase+
-							vfe40_AXI_WM_CFG[
-							share_ctrl->
-							outpath.out0.ch1]);
-					}
-					if (share_ctrl->comp_output_mode &
-						VFE40_OUTPUT_MODE_SECONDARY) {
-						msm_camera_io_w(0,
-							share_ctrl->vfebase+
-							vfe40_AXI_WM_CFG[
-							share_ctrl->
-							outpath.out1.ch0]);
-						msm_camera_io_w(0,
-							share_ctrl->vfebase+
-							vfe40_AXI_WM_CFG[
-							share_ctrl->
-							outpath.out1.ch1]);
-				}
-				msm_camera_io_w_mb
-				(CAMIF_COMMAND_STOP_AT_FRAME_BOUNDARY,
-					share_ctrl->vfebase +
-					VFE_CAMIF_COMMAND);
-				vfe40_ctrl->snapshot_frame_cnt = -1;
-				vfe40_ctrl->frame_skip_cnt = 31;
-				vfe40_ctrl->frame_skip_pattern = 0xffffffff;
-			} /*if snapshot count is 0*/
-		} /*if frame is not being dropped*/
-		vfe40_ctrl->snapshot_frame_cnt++;
-		/* then do reg_update. */
-		msm_camera_io_w(1,
-				share_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-	} /* if snapshot mode. */
-}
-}
-
-static void vfe40_process_rdi0_reg_update_irq(
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	if (atomic_cmpxchg(
-		&vfe40_ctrl->share_ctrl->rdi0_update_ack_pending, 2, 0) == 2) {
-		axi_stop_rdi0(vfe40_ctrl->share_ctrl);
-		axi_disable_irq(vfe40_ctrl->share_ctrl);
-		vfe40_send_isp_msg(&vfe40_ctrl->subdev,
-			vfe40_ctrl->share_ctrl->vfeFrameId,
-			MSG_ID_RDI0_UPDATE_ACK);
-		vfe40_ctrl->share_ctrl->comp_output_mode &=
-			~VFE40_OUTPUT_MODE_TERTIARY1;
-		vfe40_ctrl->share_ctrl->current_mode &=
-			~(VFE_OUTPUTS_RDI0);
-	}
-
-	if (atomic_cmpxchg(
-		&vfe40_ctrl->share_ctrl->rdi0_update_ack_pending, 1, 0) == 1) {
-		vfe40_ctrl->share_ctrl->comp_output_mode |=
-			VFE40_OUTPUT_MODE_TERTIARY1;
-		vfe40_send_isp_msg(&vfe40_ctrl->subdev,
-			vfe40_ctrl->share_ctrl->vfeFrameId,
-			MSG_ID_RDI0_UPDATE_ACK);
-		vfe40_ctrl->share_ctrl->current_mode &=
-			~(VFE_OUTPUTS_RDI0);
-	}
-}
-
-static void vfe40_process_rdi1_reg_update_irq(
-	struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	if (atomic_cmpxchg(
-		&vfe40_ctrl->share_ctrl->rdi1_update_ack_pending, 2, 0) == 2) {
-		axi_stop_rdi1(vfe40_ctrl->share_ctrl);
-		axi_disable_irq(vfe40_ctrl->share_ctrl);
-		vfe40_send_isp_msg(&vfe40_ctrl->subdev,
-			vfe40_ctrl->share_ctrl->vfeFrameId,
-			MSG_ID_RDI1_UPDATE_ACK);
-			vfe40_ctrl->share_ctrl->comp_output_mode &=
-				~VFE40_OUTPUT_MODE_TERTIARY2;
-		vfe40_ctrl->share_ctrl->current_mode &=
-			~(VFE_OUTPUTS_RDI1);
-	}
-
-	if (atomic_cmpxchg(
-		&vfe40_ctrl->share_ctrl->rdi1_update_ack_pending, 1, 0) == 1) {
-		vfe40_ctrl->share_ctrl->comp_output_mode |=
-			VFE40_OUTPUT_MODE_TERTIARY2;
-		vfe40_send_isp_msg(&vfe40_ctrl->subdev,
-			vfe40_ctrl->share_ctrl->vfeFrameId,
-			MSG_ID_RDI1_UPDATE_ACK);
-		vfe40_ctrl->share_ctrl->current_mode &=
-			~(VFE_OUTPUTS_RDI1);
-	}
-}
-
-static void vfe40_process_reset_irq(
-		struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	unsigned long flags;
-
-	atomic_set(&vfe40_ctrl->share_ctrl->vstate, 0);
-	atomic_set(&vfe40_ctrl->share_ctrl->handle_common_irq, 0);
-
-	spin_lock_irqsave(&vfe40_ctrl->share_ctrl->stop_flag_lock, flags);
-	if (vfe40_ctrl->share_ctrl->stop_ack_pending) {
-		vfe40_ctrl->share_ctrl->stop_ack_pending = FALSE;
-		spin_unlock_irqrestore(
-			&vfe40_ctrl->share_ctrl->stop_flag_lock, flags);
-		if (vfe40_ctrl->share_ctrl->sync_abort)
-			complete(&vfe40_ctrl->share_ctrl->reset_complete);
-		else
-		vfe40_send_isp_msg(&vfe40_ctrl->subdev,
-				vfe40_ctrl->share_ctrl->vfeFrameId,
-				MSG_ID_STOP_ACK);
-	} else {
-		spin_unlock_irqrestore(
-			&vfe40_ctrl->share_ctrl->stop_flag_lock, flags);
-		/* this is from reset command. */
-		vfe40_reset_internal_variables(vfe40_ctrl);
-		if (vfe40_ctrl->share_ctrl->vfe_reset_flag) {
-			vfe40_ctrl->share_ctrl->vfe_reset_flag = false;
-			msm_camera_io_w(0xFF00,
-				vfe40_ctrl->share_ctrl->vfebase + VFE_BUS_CMD);
-		} else {
-		/* reload all write masters. (frame & line)*/
-		msm_camera_io_w(0xFF7F,
-			vfe40_ctrl->share_ctrl->vfebase + VFE_BUS_CMD);
-		}
-		complete(&vfe40_ctrl->share_ctrl->reset_complete);
-	}
-}
-
-static void vfe40_process_camif_sof_irq(
-		struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	if (vfe40_ctrl->share_ctrl->operation_mode &
-		VFE_OUTPUTS_RAW) {
-		if (vfe40_ctrl->share_ctrl->start_ack_pending)
-			vfe40_ctrl->share_ctrl->start_ack_pending = FALSE;
-
-		vfe40_ctrl->share_ctrl->vfe_capture_count--;
-		/* if last frame to be captured: */
-		if (vfe40_ctrl->share_ctrl->vfe_capture_count == 0) {
-			/* Ensure the write order while writing
-			 to the command register using the barrier */
-			msm_camera_io_w_mb(CAMIF_COMMAND_STOP_AT_FRAME_BOUNDARY,
-			vfe40_ctrl->share_ctrl->vfebase + VFE_CAMIF_COMMAND);
-		}
-	} /* if raw snapshot mode. */
-	if ((vfe40_ctrl->hfr_mode != HFR_MODE_OFF) &&
-		(vfe40_ctrl->share_ctrl->operation_mode ==
-			VFE_MODE_OF_OPERATION_VIDEO) &&
-		(vfe40_ctrl->share_ctrl->vfeFrameId %
-			vfe40_ctrl->hfr_mode != 0)) {
-		if (vfe40_ctrl->vfe_sof_count_enable)
-			vfe40_ctrl->share_ctrl->vfeFrameId++;
-		CDBG("Skip the SOF notification when HFR enabled\n");
-		return;
-	}
-
-	if (vfe40_ctrl->vfe_sof_count_enable)
-		vfe40_ctrl->share_ctrl->vfeFrameId++;
-
-	vfe40_send_isp_msg(&vfe40_ctrl->subdev,
-		vfe40_ctrl->share_ctrl->vfeFrameId, MSG_ID_SOF_ACK);
-	CDBG("camif_sof_irq, frameId = %d\n",
-		vfe40_ctrl->share_ctrl->vfeFrameId);
-
-	if (vfe40_ctrl->sync_timer_state) {
-		if (vfe40_ctrl->sync_timer_repeat_count == 0)
-			vfe40_sync_timer_stop(vfe40_ctrl);
-		else
-			vfe40_ctrl->sync_timer_repeat_count--;
-	}
-}
-
-static void vfe40_process_error_irq(
-	struct axi_ctrl_t *axi_ctrl, uint32_t errStatus)
-{
-	uint32_t reg_value;
-	if (errStatus & VFE40_IMASK_VIOLATION) {
-		pr_err("vfe40_irq: violation interrupt\n");
-		reg_value = msm_camera_io_r(
-			axi_ctrl->share_ctrl->vfebase + VFE_VIOLATION_STATUS);
-		pr_err("%s: violationStatus  = 0x%x\n", __func__, reg_value);
-	}
-
-	if (errStatus & VFE40_IMASK_CAMIF_ERROR) {
-		pr_err("vfe40_irq: camif errors\n");
-		reg_value = msm_camera_io_r(
-			axi_ctrl->share_ctrl->vfebase + VFE_CAMIF_STATUS);
-		v4l2_subdev_notify(&axi_ctrl->subdev,
-			NOTIFY_VFE_CAMIF_ERROR, (void *)NULL);
-		pr_err("camifStatus  = 0x%x\n", reg_value);
-		vfe40_send_isp_msg(&axi_ctrl->subdev,
-			axi_ctrl->share_ctrl->vfeFrameId, MSG_ID_CAMIF_ERROR);
-	}
-
-	if (errStatus & VFE40_IMASK_BHIST_OVWR)
-		pr_err("vfe40_irq: stats bhist overwrite\n");
-
-	if (errStatus & VFE40_IMASK_STATS_CS_OVWR)
-		pr_err("vfe40_irq: stats cs overwrite\n");
-
-	if (errStatus & VFE40_IMASK_STATS_IHIST_OVWR)
-		pr_err("vfe40_irq: stats ihist overwrite\n");
-
-	if (errStatus & VFE40_IMASK_REALIGN_BUF_Y_OVFL)
-		pr_err("vfe40_irq: realign bug Y overflow\n");
-
-	if (errStatus & VFE40_IMASK_REALIGN_BUF_CB_OVFL)
-		pr_err("vfe40_irq: realign bug CB overflow\n");
-
-	if (errStatus & VFE40_IMASK_REALIGN_BUF_CR_OVFL)
-		pr_err("vfe40_irq: realign bug CR overflow\n");
-
-	if (errStatus & VFE40_IMASK_STATS_BE_BUS_OVFL)
-		pr_err("vfe40_irq: be stats bus overflow\n");
-
-	if (errStatus & VFE40_IMASK_STATS_BG_BUS_OVFL)
-		pr_err("vfe40_irq: bg stats bus overflow\n");
-
-	if (errStatus & VFE40_IMASK_STATS_BF_BUS_OVFL)
-		pr_err("vfe40_irq: bf stats bus overflow\n");
-
-	if (errStatus & VFE40_IMASK_STATS_AWB_BUS_OVFL)
-		pr_err("vfe40_irq: awb stats bus overflow\n");
-
-	if (errStatus & VFE40_IMASK_STATS_RS_BUS_OVFL)
-		pr_err("vfe40_irq: rs stats bus overflow\n");
-
-	if (errStatus & VFE40_IMASK_STATS_CS_BUS_OVFL)
-		pr_err("vfe40_irq: cs stats bus overflow\n");
-
-	if (errStatus & VFE40_IMASK_STATS_IHIST_BUS_OVFL)
-		pr_err("vfe40_irq: ihist stats bus overflow\n");
-
-	if (errStatus & VFE40_IMASK_STATS_SKIN_BHIST_BUS_OVFL)
-		pr_err("vfe40_irq: skin/bhist stats bus overflow\n");
-}
-
-static void vfe40_process_common_error_irq(
-	struct axi_ctrl_t *axi_ctrl, uint32_t errStatus)
-{
-	if (errStatus & VFE40_IMASK_BUS_BDG_HALT_ACK)
-		pr_err("vfe40_irq: BUS BDG HALT ACK\n");
-
-	if (errStatus & VFE40_IMASK_IMG_MAST_0_BUS_OVFL)
-		pr_err("vfe40_irq: image master 0 bus overflow\n");
-
-	if (errStatus & VFE40_IMASK_IMG_MAST_1_BUS_OVFL)
-		pr_err("vfe40_irq: image master 1 bus overflow\n");
-
-	if (errStatus & VFE40_IMASK_IMG_MAST_2_BUS_OVFL)
-		pr_err("vfe40_irq: image master 2 bus overflow\n");
-
-	if (errStatus & VFE40_IMASK_IMG_MAST_3_BUS_OVFL)
-		pr_err("vfe40_irq: image master 3 bus overflow\n");
-
-	if (errStatus & VFE40_IMASK_IMG_MAST_4_BUS_OVFL)
-		pr_err("vfe40_irq: image master 4 bus overflow\n");
-
-	if (errStatus & VFE40_IMASK_IMG_MAST_5_BUS_OVFL)
-		pr_err("vfe40_irq: image master 5 bus overflow\n");
-
-	if (errStatus & VFE40_IMASK_IMG_MAST_6_BUS_OVFL)
-		pr_err("vfe40_irq: image master 6 bus overflow\n");
-
-}
-
-static void vfe_send_outmsg(
-	struct axi_ctrl_t *axi_ctrl, uint8_t msgid,
-	uint32_t ch0_paddr, uint32_t ch1_paddr,
-	uint32_t ch2_paddr, uint32_t inst_handle)
-{
-	struct isp_msg_output msg;
-
-	msg.output_id = msgid;
-	msg.buf.inst_handle = inst_handle;
-	msg.buf.ch_paddr[0]	= ch0_paddr;
-	msg.buf.ch_paddr[1]	= ch1_paddr;
-	msg.buf.ch_paddr[2]	= ch2_paddr;
-	switch (msgid) {
-	case MSG_ID_OUTPUT_TERTIARY1:
-		msg.frameCounter = axi_ctrl->share_ctrl->rdi0FrameId;
-		break;
-	case MSG_ID_OUTPUT_TERTIARY2:
-		msg.frameCounter = axi_ctrl->share_ctrl->rdi1FrameId;
-		break;
-	default:
-		msg.frameCounter = axi_ctrl->share_ctrl->vfeFrameId;
-		break;
-	}
-
-	v4l2_subdev_notify(&axi_ctrl->subdev,
-			NOTIFY_VFE_MSG_OUT,
-			&msg);
-	return;
-}
-
-static void vfe40_process_output_path_irq_0(
-	struct axi_ctrl_t *axi_ctrl)
-{
-	uint32_t ping_pong;
-	uint32_t ch0_paddr, ch1_paddr, ch2_paddr;
-	uint8_t out_bool = 0;
-	struct msm_free_buf *free_buf = NULL;
-
-	free_buf = vfe40_check_free_buffer(VFE_MSG_OUTPUT_IRQ,
-		VFE_MSG_OUTPUT_PRIMARY, axi_ctrl);
-
-	/* we render frames in the following conditions:
-	1. Continuous mode and the free buffer is avaialable.
-	2. In snapshot shot mode, free buffer is not always available.
-	when pending snapshot count is <=1,  then no need to use
-	free buffer.
-	*/
-	out_bool = (
-		(axi_ctrl->share_ctrl->operation_mode &
-			VFE_OUTPUTS_THUMB_AND_MAIN ||
-		axi_ctrl->share_ctrl->operation_mode &
-			VFE_OUTPUTS_MAIN_AND_THUMB ||
-		axi_ctrl->share_ctrl->operation_mode &
-			VFE_OUTPUTS_THUMB_AND_JPEG ||
-		axi_ctrl->share_ctrl->operation_mode &
-			VFE_OUTPUTS_JPEG_AND_THUMB ||
-		axi_ctrl->share_ctrl->operation_mode &
-			VFE_OUTPUTS_RAW ||
-		axi_ctrl->share_ctrl->liveshot_state ==
-			VFE_STATE_STARTED ||
-		axi_ctrl->share_ctrl->liveshot_state ==
-			VFE_STATE_STOP_REQUESTED ||
-		axi_ctrl->share_ctrl->liveshot_state ==
-			VFE_STATE_STOPPED) &&
-		(axi_ctrl->share_ctrl->vfe_capture_count <= 1)) ||
-			free_buf;
-
-	if (out_bool) {
-		ping_pong = msm_camera_io_r(axi_ctrl->share_ctrl->vfebase +
-			VFE_BUS_PING_PONG_STATUS);
-
-		/* Channel 0*/
-		ch0_paddr = vfe40_get_ch_addr(
-			ping_pong, axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out0.ch0);
-		/* Channel 1*/
-		ch1_paddr = vfe40_get_ch_addr(
-			ping_pong, axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out0.ch1);
-		/* Channel 2*/
-		ch2_paddr = vfe40_get_ch_addr(
-			ping_pong, axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out0.ch2);
-
-		CDBG("output path 0, ch0 = 0x%x, ch1 = 0x%x, ch2 = 0x%x\n",
-			ch0_paddr, ch1_paddr, ch2_paddr);
-		if (free_buf) {
-			/* Y channel */
-			vfe40_put_ch_addr(ping_pong,
-			axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out0.ch0,
-			free_buf->ch_paddr[0]);
-			/* Chroma channel */
-			vfe40_put_ch_addr(ping_pong,
-			axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out0.ch1,
-			free_buf->ch_paddr[1]);
-			if (free_buf->num_planes > 2)
-				vfe40_put_ch_addr(ping_pong,
-					axi_ctrl->share_ctrl->vfebase,
-					axi_ctrl->share_ctrl->outpath.out0.ch2,
-					free_buf->ch_paddr[2]);
-		}
-		if (axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_THUMB_AND_MAIN ||
-			axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_MAIN_AND_THUMB ||
-			axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_THUMB_AND_JPEG ||
-			axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_JPEG_AND_THUMB ||
-			axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_RAW ||
-			axi_ctrl->share_ctrl->liveshot_state ==
-				VFE_STATE_STOPPED)
-			axi_ctrl->share_ctrl->outpath.out0.capture_cnt--;
-
-		vfe_send_outmsg(axi_ctrl,
-			MSG_ID_OUTPUT_PRIMARY, ch0_paddr,
-			ch1_paddr, ch2_paddr,
-			axi_ctrl->share_ctrl->outpath.out0.inst_handle);
-
-	} else {
-		axi_ctrl->share_ctrl->outpath.out0.frame_drop_cnt++;
-		CDBG("path_irq_0 - no free buffer!\n");
-	}
-}
-
-static void vfe40_process_output_path_irq_1(
-	struct axi_ctrl_t *axi_ctrl)
-{
-	uint32_t ping_pong;
-	uint32_t ch0_paddr, ch1_paddr, ch2_paddr;
-	/* this must be snapshot main image output. */
-	uint8_t out_bool = 0;
-	struct msm_free_buf *free_buf = NULL;
-
-	free_buf = vfe40_check_free_buffer(VFE_MSG_OUTPUT_IRQ,
-		VFE_MSG_OUTPUT_SECONDARY, axi_ctrl);
-	out_bool = ((axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_THUMB_AND_MAIN ||
-			axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_MAIN_AND_THUMB ||
-			axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_RAW ||
-			axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_JPEG_AND_THUMB) &&
-			(axi_ctrl->share_ctrl->vfe_capture_count <= 1)) ||
-				free_buf;
-
-	if (out_bool) {
-		ping_pong = msm_camera_io_r(axi_ctrl->share_ctrl->vfebase +
-			VFE_BUS_PING_PONG_STATUS);
-
-		/* Y channel */
-		ch0_paddr = vfe40_get_ch_addr(ping_pong,
-			axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out1.ch0);
-		/* Chroma channel */
-		ch1_paddr = vfe40_get_ch_addr(ping_pong,
-			axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out1.ch1);
-		ch2_paddr = vfe40_get_ch_addr(ping_pong,
-			axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out1.ch2);
-
-		CDBG("%s ch0 = 0x%x, ch1 = 0x%x, ch2 = 0x%x\n",
-			__func__, ch0_paddr, ch1_paddr, ch2_paddr);
-		if (free_buf) {
-			/* Y channel */
-			vfe40_put_ch_addr(ping_pong,
-			axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out1.ch0,
-			free_buf->ch_paddr[0]);
-			/* Chroma channel */
-			vfe40_put_ch_addr(ping_pong,
-			axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out1.ch1,
-			free_buf->ch_paddr[1]);
-			if (free_buf->num_planes > 2)
-				vfe40_put_ch_addr(ping_pong,
-					axi_ctrl->share_ctrl->vfebase,
-					axi_ctrl->share_ctrl->outpath.out1.ch2,
-					free_buf->ch_paddr[2]);
-		}
-		if (axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_THUMB_AND_MAIN ||
-			axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_MAIN_AND_THUMB ||
-			axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_RAW ||
-			axi_ctrl->share_ctrl->operation_mode &
-				VFE_OUTPUTS_JPEG_AND_THUMB)
-			axi_ctrl->share_ctrl->outpath.out1.capture_cnt--;
-
-		vfe_send_outmsg(axi_ctrl,
-			MSG_ID_OUTPUT_SECONDARY, ch0_paddr,
-			ch1_paddr, ch2_paddr,
-			axi_ctrl->share_ctrl->outpath.out1.inst_handle);
-
-	} else {
-		axi_ctrl->share_ctrl->outpath.out1.frame_drop_cnt++;
-		CDBG("path_irq_1 - no free buffer!\n");
-	}
-}
-
-static void vfe40_process_output_path_irq_rdi0(
-			struct axi_ctrl_t *axi_ctrl)
-{
-	uint32_t ping_pong;
-	uint32_t ch0_paddr = 0;
-	/* this must be rdi image output. */
-	struct msm_free_buf *free_buf = NULL;
-	/*RDI0*/
-	if (axi_ctrl->share_ctrl->operation_mode & VFE_OUTPUTS_RDI0) {
-		free_buf = vfe40_check_free_buffer(VFE_MSG_OUTPUT_IRQ,
-			VFE_MSG_OUTPUT_TERTIARY1, axi_ctrl);
-		if (free_buf) {
-			ping_pong = msm_camera_io_r(axi_ctrl->
-				share_ctrl->vfebase +
-				VFE_BUS_PING_PONG_STATUS);
-
-			/* Y only channel */
-			ch0_paddr = vfe40_get_ch_addr(ping_pong,
-				axi_ctrl->share_ctrl->vfebase,
-				axi_ctrl->share_ctrl->outpath.out2.ch0);
-
-			pr_debug("%s ch0 = 0x%x\n",
-				__func__, ch0_paddr);
-
-			/* Y channel */
-			vfe40_put_ch_addr(ping_pong,
-				axi_ctrl->share_ctrl->vfebase,
-				axi_ctrl->share_ctrl->outpath.out2.ch0,
-				free_buf->ch_paddr[0]);
-
-			vfe_send_outmsg(axi_ctrl,
-				MSG_ID_OUTPUT_TERTIARY1, ch0_paddr,
-				0, 0,
-				axi_ctrl->share_ctrl->outpath.out2.inst_handle);
-
-		} else {
-			axi_ctrl->share_ctrl->outpath.out2.frame_drop_cnt++;
-			pr_err("path_irq_2 irq - no free buffer for rdi0!\n");
-		}
-	}
-}
-
-static void vfe40_process_output_path_irq_rdi1(
-	struct axi_ctrl_t *axi_ctrl)
-{
-	uint32_t ping_pong;
-	uint32_t ch0_paddr = 0;
-	/* this must be rdi image output. */
-	struct msm_free_buf *free_buf = NULL;
-	/*RDI1*/
-	if (axi_ctrl->share_ctrl->operation_mode & VFE_OUTPUTS_RDI1) {
-		free_buf = vfe40_check_free_buffer(VFE_MSG_OUTPUT_IRQ,
-			VFE_MSG_OUTPUT_TERTIARY2, axi_ctrl);
-		if (free_buf) {
-			ping_pong = msm_camera_io_r(axi_ctrl->
-				share_ctrl->vfebase +
-				VFE_BUS_PING_PONG_STATUS);
-
-			/* Y channel */
-			ch0_paddr = vfe40_get_ch_addr(ping_pong,
-				axi_ctrl->share_ctrl->vfebase,
-				axi_ctrl->share_ctrl->outpath.out3.ch0);
-			pr_debug("%s ch0 = 0x%x\n",
-				__func__, ch0_paddr);
-
-			/* Y channel */
-			vfe40_put_ch_addr(ping_pong,
-				axi_ctrl->share_ctrl->vfebase,
-				axi_ctrl->share_ctrl->outpath.out3.ch0,
-				free_buf->ch_paddr[0]);
-
-			vfe_send_outmsg(axi_ctrl,
-				MSG_ID_OUTPUT_TERTIARY2, ch0_paddr,
-				0, 0,
-				axi_ctrl->share_ctrl->outpath.out3.inst_handle);
-		} else {
-			axi_ctrl->share_ctrl->outpath.out3.frame_drop_cnt++;
-			pr_err("path_irq irq - no free buffer for rdi1!\n");
-		}
-	}
-}
-
-static uint32_t  vfe40_process_stats_irq_common(
-	struct vfe40_ctrl_type *vfe40_ctrl,
-	uint32_t statsNum, uint32_t newAddr)
-{
-	uint32_t pingpongStatus;
-	uint32_t returnAddr;
-	uint32_t pingpongAddr;
-
-	/* must be 0=ping, 1=pong */
-	pingpongStatus =
-		((msm_camera_io_r(vfe40_ctrl->share_ctrl->vfebase +
-		VFE_BUS_PING_PONG_STATUS))
-	& ((uint32_t)(1<<(statsNum + 7)))) >> (statsNum + 7);
-	/* stats bits starts at 7 */
-	CDBG("%s:statsNum %d, pingpongStatus %d\n", __func__,
-		 statsNum, pingpongStatus);
-	pingpongAddr =
-		((uint32_t)(vfe40_ctrl->share_ctrl->vfebase +
-				VFE_BUS_STATS_PING_PONG_BASE)) +
-				(VFE_STATS_BUS_REG_NUM*statsNum)*4 +
-				(1-pingpongStatus)*4;
-	returnAddr = msm_camera_io_r((uint32_t *)pingpongAddr);
-	msm_camera_io_w(newAddr, (uint32_t *)pingpongAddr);
-	return returnAddr;
-}
-
-static void vfe_send_stats_msg(
-	struct vfe40_ctrl_type *vfe40_ctrl,
-	uint32_t bufAddress, uint32_t statsNum)
-{
-	int rc = 0;
-	void *vaddr = NULL;
-	/* fill message with right content. */
-	/* @todo This is causing issues, need further investigate */
-	/* spin_lock_irqsave(&ctrl->state_lock, flags); */
-	struct isp_msg_stats msgStats;
-	uint32_t stats_type;
-	msgStats.frameCounter = vfe40_ctrl->share_ctrl->vfeFrameId;
-	if (vfe40_ctrl->simultaneous_sof_stat)
-		msgStats.frameCounter--;
-	msgStats.buffer = bufAddress;
-	switch (statsNum) {
-	case statsBgNum:{
-		msgStats.id = MSG_ID_STATS_BG;
-		stats_type = MSM_STATS_TYPE_BG;
-		rc = vfe40_ctrl->stats_ops.dispatch(
-				vfe40_ctrl->stats_ops.stats_ctrl,
-				stats_type, bufAddress,
-				&msgStats.buf_idx, &vaddr, &msgStats.fd,
-				vfe40_ctrl->stats_ops.client);
-		}
-		break;
-	case statsBeNum:{
-		msgStats.id = MSG_ID_STATS_BE;
-		stats_type = MSM_STATS_TYPE_BE;
-		rc = vfe40_ctrl->stats_ops.dispatch(
-				vfe40_ctrl->stats_ops.stats_ctrl,
-				stats_type, bufAddress,
-				&msgStats.buf_idx, &vaddr, &msgStats.fd,
-				vfe40_ctrl->stats_ops.client);
-		}
-		break;
-	case statsBfNum:{
-		msgStats.id = MSG_ID_STATS_BF;
-		stats_type =  MSM_STATS_TYPE_BF;
-		rc = vfe40_ctrl->stats_ops.dispatch(
-				vfe40_ctrl->stats_ops.stats_ctrl,
-				stats_type, bufAddress,
-				&msgStats.buf_idx, &vaddr, &msgStats.fd,
-				vfe40_ctrl->stats_ops.client);
-		}
-		break;
-	case statsAwbNum: {
-		msgStats.id = MSG_ID_STATS_AWB;
-		rc = vfe40_ctrl->stats_ops.dispatch(
-				vfe40_ctrl->stats_ops.stats_ctrl,
-				MSM_STATS_TYPE_AWB, bufAddress,
-				&msgStats.buf_idx, &vaddr, &msgStats.fd,
-				vfe40_ctrl->stats_ops.client);
-		}
-		break;
-
-	case statsIhistNum: {
-		msgStats.id = MSG_ID_STATS_IHIST;
-		rc = vfe40_ctrl->stats_ops.dispatch(
-				vfe40_ctrl->stats_ops.stats_ctrl,
-				MSM_STATS_TYPE_IHIST, bufAddress,
-				&msgStats.buf_idx, &vaddr, &msgStats.fd,
-				vfe40_ctrl->stats_ops.client);
-		}
-		break;
-	case statsRsNum: {
-		msgStats.id = MSG_ID_STATS_RS;
-		rc = vfe40_ctrl->stats_ops.dispatch(
-				vfe40_ctrl->stats_ops.stats_ctrl,
-				MSM_STATS_TYPE_RS, bufAddress,
-				&msgStats.buf_idx, &vaddr, &msgStats.fd,
-				vfe40_ctrl->stats_ops.client);
-		}
-		break;
-	case statsCsNum: {
-		msgStats.id = MSG_ID_STATS_CS;
-		rc = vfe40_ctrl->stats_ops.dispatch(
-				vfe40_ctrl->stats_ops.stats_ctrl,
-				MSM_STATS_TYPE_CS, bufAddress,
-				&msgStats.buf_idx, &vaddr, &msgStats.fd,
-				vfe40_ctrl->stats_ops.client);
-		}
-		break;
-	case statsSkinNum: {
-		msgStats.id = MSG_ID_STATS_BHIST;
-		rc = vfe40_ctrl->stats_ops.dispatch(
-				vfe40_ctrl->stats_ops.stats_ctrl,
-				MSM_STATS_TYPE_BHIST, bufAddress,
-				&msgStats.buf_idx, &vaddr, &msgStats.fd,
-				vfe40_ctrl->stats_ops.client);
-		}
-		break;
-
-	default:
-		goto stats_done;
-	}
-	if (rc == 0) {
-		msgStats.buffer = (uint32_t)vaddr;
-		v4l2_subdev_notify(&vfe40_ctrl->subdev,
-			NOTIFY_VFE_MSG_STATS,
-			&msgStats);
-	} else {
-		pr_err("%s: paddr to idx mapping error, stats_id = %d, paddr = 0x%d",
-			 __func__, msgStats.id, msgStats.buffer);
-	}
-stats_done:
-	/* spin_unlock_irqrestore(&ctrl->state_lock, flags); */
-	return;
-}
-
-static void vfe_send_comp_stats_msg(
-	struct vfe40_ctrl_type *vfe40_ctrl, uint32_t status_bits)
-{
-	struct msm_stats_buf msgStats;
-	uint32_t temp;
-
-	msgStats.frame_id = vfe40_ctrl->share_ctrl->vfeFrameId;
-	if (vfe40_ctrl->simultaneous_sof_stat)
-		msgStats.frame_id--;
-
-	msgStats.status_bits = status_bits;
-
-	msgStats.aec.buff = vfe40_ctrl->bgStatsControl.bufToRender;
-	msgStats.awb.buff = vfe40_ctrl->awbStatsControl.bufToRender;
-	msgStats.af.buff = vfe40_ctrl->bfStatsControl.bufToRender;
-
-	msgStats.ihist.buff = vfe40_ctrl->ihistStatsControl.bufToRender;
-	msgStats.rs.buff = vfe40_ctrl->rsStatsControl.bufToRender;
-	msgStats.cs.buff = vfe40_ctrl->csStatsControl.bufToRender;
-
-	temp = msm_camera_io_r(
-		vfe40_ctrl->share_ctrl->vfebase + VFE_STATS_AWB_SGW_CFG);
-	msgStats.awb_ymin = (0xFF00 & temp) >> 8;
-
-	v4l2_subdev_notify(&vfe40_ctrl->subdev,
-				NOTIFY_VFE_MSG_COMP_STATS,
-				&msgStats);
-}
-
-static void vfe40_process_stats_be_irq(struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	unsigned long flags;
-	uint32_t addr;
-	uint32_t stats_type;
-	stats_type = MSM_STATS_TYPE_BE;
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl, stats_type);
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (addr) {
-		vfe40_ctrl->beStatsControl.bufToRender =
-			vfe40_process_stats_irq_common(vfe40_ctrl, statsBeNum,
-			addr);
-
-		vfe_send_stats_msg(vfe40_ctrl,
-			vfe40_ctrl->beStatsControl.bufToRender, statsBeNum);
-	} else{
-		vfe40_ctrl->beStatsControl.droppedStatsFrameCount++;
-		CDBG("%s: droppedStatsFrameCount = %d", __func__,
-			vfe40_ctrl->beStatsControl.droppedStatsFrameCount);
-	}
-}
-
-static void vfe40_process_stats_bg_irq(struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	unsigned long flags;
-	uint32_t addr;
-	uint32_t stats_type;
-	stats_type = MSM_STATS_TYPE_BG;
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl, stats_type);
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (addr) {
-		vfe40_ctrl->bgStatsControl.bufToRender =
-			vfe40_process_stats_irq_common(vfe40_ctrl, statsBgNum,
-			addr);
-
-		vfe_send_stats_msg(vfe40_ctrl,
-			vfe40_ctrl->bgStatsControl.bufToRender, statsBgNum);
-	} else{
-		vfe40_ctrl->bgStatsControl.droppedStatsFrameCount++;
-		CDBG("%s: droppedStatsFrameCount = %d", __func__,
-			vfe40_ctrl->bgStatsControl.droppedStatsFrameCount);
-	}
-}
-
-static void vfe40_process_stats_awb_irq(struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	unsigned long flags;
-	uint32_t addr;
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl, MSM_STATS_TYPE_AWB);
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (addr) {
-		vfe40_ctrl->awbStatsControl.bufToRender =
-			vfe40_process_stats_irq_common(vfe40_ctrl, statsAwbNum,
-			addr);
-
-		vfe_send_stats_msg(vfe40_ctrl,
-			vfe40_ctrl->awbStatsControl.bufToRender, statsAwbNum);
-	} else{
-		vfe40_ctrl->awbStatsControl.droppedStatsFrameCount++;
-		CDBG("%s: droppedStatsFrameCount = %d", __func__,
-			vfe40_ctrl->awbStatsControl.droppedStatsFrameCount);
-	}
-}
-
-static void vfe40_process_stats_bf_irq(struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	unsigned long flags;
-	uint32_t addr;
-	uint32_t stats_type;
-	stats_type = MSM_STATS_TYPE_BF;
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl, stats_type);
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (addr) {
-		vfe40_ctrl->bfStatsControl.bufToRender =
-			vfe40_process_stats_irq_common(vfe40_ctrl, statsBfNum,
-			addr);
-
-		vfe_send_stats_msg(vfe40_ctrl,
-			vfe40_ctrl->bfStatsControl.bufToRender, statsBfNum);
-	} else{
-		vfe40_ctrl->bfStatsControl.droppedStatsFrameCount++;
-		CDBG("%s: droppedStatsFrameCount = %d", __func__,
-			vfe40_ctrl->bfStatsControl.droppedStatsFrameCount);
-	}
-}
-
-static void vfe40_process_stats_bhist_irq(struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	unsigned long flags;
-	uint32_t addr;
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl, MSM_STATS_TYPE_BHIST);
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (addr) {
-		vfe40_ctrl->bhistStatsControl.bufToRender =
-			vfe40_process_stats_irq_common(vfe40_ctrl,
-				statsSkinNum, addr);
-
-		vfe_send_stats_msg(vfe40_ctrl,
-			vfe40_ctrl->bhistStatsControl.bufToRender,
-			statsSkinNum);
-	} else{
-		vfe40_ctrl->bhistStatsControl.droppedStatsFrameCount++;
-		CDBG("%s: droppedStatsFrameCount = %d", __func__,
-			vfe40_ctrl->bhistStatsControl.droppedStatsFrameCount);
-	}
-}
-
-static void vfe40_process_stats_ihist_irq(struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	unsigned long flags;
-	uint32_t addr;
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl, MSM_STATS_TYPE_IHIST);
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (addr) {
-		vfe40_ctrl->ihistStatsControl.bufToRender =
-			vfe40_process_stats_irq_common(
-			vfe40_ctrl, statsIhistNum, addr);
-
-		vfe_send_stats_msg(vfe40_ctrl,
-			vfe40_ctrl->ihistStatsControl.bufToRender,
-			statsIhistNum);
-	} else {
-		vfe40_ctrl->ihistStatsControl.droppedStatsFrameCount++;
-		CDBG("%s: droppedStatsFrameCount = %d", __func__,
-			vfe40_ctrl->ihistStatsControl.droppedStatsFrameCount);
-	}
-}
-
-static void vfe40_process_stats_rs_irq(struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	unsigned long flags;
-	uint32_t addr;
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl, MSM_STATS_TYPE_RS);
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (addr) {
-		vfe40_ctrl->rsStatsControl.bufToRender =
-			vfe40_process_stats_irq_common(vfe40_ctrl, statsRsNum,
-			addr);
-
-		vfe_send_stats_msg(vfe40_ctrl,
-			vfe40_ctrl->rsStatsControl.bufToRender, statsRsNum);
-	} else {
-		vfe40_ctrl->rsStatsControl.droppedStatsFrameCount++;
-		CDBG("%s: droppedStatsFrameCount = %d", __func__,
-			vfe40_ctrl->rsStatsControl.droppedStatsFrameCount);
-	}
-}
-
-static void vfe40_process_stats_cs_irq(struct vfe40_ctrl_type *vfe40_ctrl)
-{
-	unsigned long flags;
-	uint32_t addr;
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-	addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl, MSM_STATS_TYPE_CS);
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (addr) {
-		vfe40_ctrl->csStatsControl.bufToRender =
-			vfe40_process_stats_irq_common(vfe40_ctrl, statsCsNum,
-			addr);
-
-			vfe_send_stats_msg(vfe40_ctrl,
-				vfe40_ctrl->csStatsControl.bufToRender,
-				statsCsNum);
-	} else {
-		vfe40_ctrl->csStatsControl.droppedStatsFrameCount++;
-		CDBG("%s: droppedStatsFrameCount = %d", __func__,
-			vfe40_ctrl->csStatsControl.droppedStatsFrameCount);
-	}
-}
-
-static void vfe40_process_stats(struct vfe40_ctrl_type *vfe40_ctrl,
-	uint32_t status_bits)
-{
-	unsigned long flags;
-	int32_t process_stats = false;
-	uint32_t addr;
-	uint32_t stats_type;
-
-	CDBG("%s, stats = 0x%x\n", __func__, status_bits);
-	spin_lock_irqsave(&vfe40_ctrl->stats_bufq_lock, flags);
-
-	stats_type = MSM_STATS_TYPE_BE;
-	if (status_bits & VFE_IRQ_STATUS0_STATS_BE) {
-		addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl,
-				stats_type);
-		if (addr) {
-			vfe40_ctrl->beStatsControl.bufToRender =
-				vfe40_process_stats_irq_common(
-				vfe40_ctrl, statsBeNum, addr);
-			process_stats = true;
-		} else{
-			vfe40_ctrl->beStatsControl.bufToRender = 0;
-			vfe40_ctrl->beStatsControl.droppedStatsFrameCount++;
-		}
-	} else {
-		vfe40_ctrl->beStatsControl.bufToRender = 0;
-	}
-
-	stats_type = MSM_STATS_TYPE_BG;
-	if (status_bits & VFE_IRQ_STATUS0_STATS_BG) {
-		addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl,
-				stats_type);
-		if (addr) {
-			vfe40_ctrl->bgStatsControl.bufToRender =
-				vfe40_process_stats_irq_common(
-				vfe40_ctrl, statsBgNum, addr);
-			process_stats = true;
-		} else{
-			vfe40_ctrl->bgStatsControl.bufToRender = 0;
-			vfe40_ctrl->bgStatsControl.droppedStatsFrameCount++;
-		}
-	} else {
-		vfe40_ctrl->bgStatsControl.bufToRender = 0;
-	}
-
-	if (status_bits & VFE_IRQ_STATUS0_STATS_AWB) {
-		addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl,
-			MSM_STATS_TYPE_AWB);
-		if (addr) {
-			vfe40_ctrl->awbStatsControl.bufToRender =
-				vfe40_process_stats_irq_common(
-				vfe40_ctrl, statsAwbNum,
-				addr);
-			process_stats = true;
-		} else{
-			vfe40_ctrl->awbStatsControl.droppedStatsFrameCount++;
-			vfe40_ctrl->awbStatsControl.bufToRender = 0;
-		}
-	} else {
-		vfe40_ctrl->awbStatsControl.bufToRender = 0;
-	}
-
-	stats_type = MSM_STATS_TYPE_BF;
-	if (status_bits & VFE_IRQ_STATUS0_STATS_BF) {
-		addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl,
-					stats_type);
-		if (addr) {
-			vfe40_ctrl->bfStatsControl.bufToRender =
-				vfe40_process_stats_irq_common(
-				vfe40_ctrl, statsBfNum,
-				addr);
-			process_stats = true;
-		} else {
-			vfe40_ctrl->bfStatsControl.bufToRender = 0;
-			vfe40_ctrl->bfStatsControl.droppedStatsFrameCount++;
-		}
-	} else {
-		vfe40_ctrl->bfStatsControl.bufToRender = 0;
-	}
-
-	if (status_bits & VFE_IRQ_STATUS0_STATS_IHIST) {
-		addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl,
-					MSM_STATS_TYPE_IHIST);
-		if (addr) {
-			vfe40_ctrl->ihistStatsControl.bufToRender =
-				vfe40_process_stats_irq_common(
-				vfe40_ctrl, statsIhistNum,
-				addr);
-			process_stats = true;
-		} else {
-			vfe40_ctrl->ihistStatsControl.droppedStatsFrameCount++;
-			vfe40_ctrl->ihistStatsControl.bufToRender = 0;
-		}
-	} else {
-		vfe40_ctrl->ihistStatsControl.bufToRender = 0;
-	}
-
-	if (status_bits & VFE_IRQ_STATUS0_STATS_RS) {
-		addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl,
-					MSM_STATS_TYPE_RS);
-		if (addr) {
-			vfe40_ctrl->rsStatsControl.bufToRender =
-				vfe40_process_stats_irq_common(
-				vfe40_ctrl, statsRsNum,
-				addr);
-			process_stats = true;
-		} else {
-			vfe40_ctrl->rsStatsControl.droppedStatsFrameCount++;
-			vfe40_ctrl->rsStatsControl.bufToRender = 0;
-		}
-	} else {
-		vfe40_ctrl->rsStatsControl.bufToRender = 0;
-	}
-
-	if (status_bits & VFE_IRQ_STATUS0_STATS_CS) {
-		addr = (uint32_t)vfe40_stats_dqbuf(vfe40_ctrl,
-					MSM_STATS_TYPE_CS);
-		if (addr) {
-			vfe40_ctrl->csStatsControl.bufToRender =
-				vfe40_process_stats_irq_common(
-				vfe40_ctrl, statsCsNum,
-				addr);
-			process_stats = true;
-		} else {
-			vfe40_ctrl->csStatsControl.droppedStatsFrameCount++;
-			vfe40_ctrl->csStatsControl.bufToRender = 0;
-		}
-	} else {
-		vfe40_ctrl->csStatsControl.bufToRender = 0;
-	}
-	spin_unlock_irqrestore(&vfe40_ctrl->stats_bufq_lock, flags);
-	if (process_stats)
-		vfe_send_comp_stats_msg(vfe40_ctrl, status_bits);
-
-	return;
-}
-
-static void vfe40_process_stats_irq(
-	struct vfe40_ctrl_type *vfe40_ctrl, uint32_t irqstatus)
-{
-	uint32_t status_bits = VFE_COM_STATUS & irqstatus;
-	if ((vfe40_ctrl->hfr_mode != HFR_MODE_OFF) &&
-		(vfe40_ctrl->share_ctrl->vfeFrameId %
-		 vfe40_ctrl->hfr_mode != 0)) {
-		CDBG("Skip the stats when HFR enabled\n");
-		return;
-	}
-
-	vfe40_process_stats(vfe40_ctrl, status_bits);
-	return;
-}
-
-static void vfe40_process_irq(
-	struct vfe40_ctrl_type *vfe40_ctrl, uint32_t irqstatus)
-{
-	if (irqstatus &
-		VFE_IRQ_STATUS0_STATS_COMPOSIT_MASK_0) {
-		vfe40_process_stats_irq(vfe40_ctrl, irqstatus);
-		return;
-	}
-
-	switch (irqstatus) {
-	case VFE_IRQ_STATUS0_CAMIF_SOF_MASK:
-		CDBG("irq	camifSofIrq\n");
-		vfe40_process_camif_sof_irq(vfe40_ctrl);
-		break;
-	case VFE_IRQ_STATUS0_REG_UPDATE_MASK:
-		CDBG("irq	regUpdateIrq\n");
-		vfe40_process_reg_update_irq(vfe40_ctrl);
-		break;
-	case VFE_IRQ_STATUS0_RDI0_REG_UPDATE:
-		CDBG("irq	rdi0 regUpdateIrq\n");
-		vfe40_process_rdi0_reg_update_irq(vfe40_ctrl);
-		break;
-	case VFE_IRQ_STATUS0_RDI1_REG_UPDATE:
-		CDBG("irq	rdi1 regUpdateIrq\n");
-		vfe40_process_rdi1_reg_update_irq(vfe40_ctrl);
-		break;
-	case VFE_IMASK_WHILE_STOPPING_0:
-		CDBG("irq	resetAckIrq\n");
-		vfe40_process_reset_irq(vfe40_ctrl);
-		break;
-	case VFE_IRQ_STATUS0_STATS_BG:
-		CDBG("Stats BG irq occured.\n");
-		vfe40_process_stats_bg_irq(vfe40_ctrl);
-		break;
-	case VFE_IRQ_STATUS0_STATS_BE:
-		CDBG("Stats BE irq occured.\n");
-		vfe40_process_stats_be_irq(vfe40_ctrl);
-		break;
-	case VFE_IRQ_STATUS0_STATS_BF:
-		CDBG("Stats BF irq occured.\n");
-		vfe40_process_stats_bf_irq(vfe40_ctrl);
-		break;
-	case VFE_IRQ_STATUS0_STATS_AWB:
-		CDBG("Stats AWB irq occured.\n");
-		vfe40_process_stats_awb_irq(vfe40_ctrl);
-		break;
-	case VFE_IRQ_STATUS0_STATS_SKIN_BHIST:
-		CDBG("Stats BHIST irq occured.\n");
-		vfe40_process_stats_bhist_irq(vfe40_ctrl);
-		break;
-	case VFE_IRQ_STATUS0_STATS_IHIST:
-		CDBG("Stats IHIST irq occured.\n");
-		vfe40_process_stats_ihist_irq(vfe40_ctrl);
-		break;
-	case VFE_IRQ_STATUS0_STATS_RS:
-		CDBG("Stats RS irq occured.\n");
-		vfe40_process_stats_rs_irq(vfe40_ctrl);
-		break;
-	case VFE_IRQ_STATUS0_STATS_CS:
-		CDBG("Stats CS irq occured.\n");
-		vfe40_process_stats_cs_irq(vfe40_ctrl);
-		break;
-	case VFE_IRQ_STATUS1_SYNC_TIMER0:
-		CDBG("SYNC_TIMER 0 irq occured.\n");
-		vfe40_send_isp_msg(&vfe40_ctrl->subdev,
-			vfe40_ctrl->share_ctrl->vfeFrameId,
-			MSG_ID_SYNC_TIMER0_DONE);
-		break;
-	case VFE_IRQ_STATUS1_SYNC_TIMER1:
-		CDBG("SYNC_TIMER 1 irq occured.\n");
-		vfe40_send_isp_msg(&vfe40_ctrl->subdev,
-			vfe40_ctrl->share_ctrl->vfeFrameId,
-			MSG_ID_SYNC_TIMER1_DONE);
-		break;
-	case VFE_IRQ_STATUS1_SYNC_TIMER2:
-		CDBG("SYNC_TIMER 2 irq occured.\n");
-		vfe40_send_isp_msg(&vfe40_ctrl->subdev,
-			vfe40_ctrl->share_ctrl->vfeFrameId,
-			MSG_ID_SYNC_TIMER2_DONE);
-		break;
-	default:
-		pr_err("Invalid IRQ status\n");
-	}
-}
-
-static void axi40_do_tasklet(unsigned long data)
-{
-	unsigned long flags;
-	struct axi_ctrl_t *axi_ctrl = (struct axi_ctrl_t *)data;
-	struct vfe40_ctrl_type *vfe40_ctrl = axi_ctrl->share_ctrl->vfe40_ctrl;
-	struct vfe40_isr_queue_cmd *qcmd = NULL;
-	int stat_interrupt;
-
-	CDBG("=== axi40_do_tasklet start ===\n");
-
-	while (atomic_read(&irq_cnt)) {
-		spin_lock_irqsave(&axi_ctrl->tasklet_lock, flags);
-		qcmd = list_first_entry(&axi_ctrl->tasklet_q,
-			struct vfe40_isr_queue_cmd, list);
-		atomic_sub(1, &irq_cnt);
-
-		if (!qcmd) {
-			spin_unlock_irqrestore(&axi_ctrl->tasklet_lock,
-				flags);
-			return;
-		}
-
-		list_del(&qcmd->list);
-		spin_unlock_irqrestore(&axi_ctrl->tasklet_lock,
-			flags);
-
-		if (axi_ctrl->share_ctrl->stats_comp) {
-			stat_interrupt = (qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_COMPOSIT_MASK_0);
-		} else {
-			stat_interrupt =
-				(qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_BG) |
-				(qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_BE) |
-				(qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_AWB) |
-				(qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_BF) |
-				(qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_IHIST) |
-				(qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_RS) |
-				(qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_CS);
-		}
-		if (qcmd->vfeInterruptStatus0 &
-				VFE_IRQ_STATUS0_CAMIF_SOF_MASK) {
-			if (stat_interrupt)
-				vfe40_ctrl->simultaneous_sof_stat = 1;
-			v4l2_subdev_notify(&vfe40_ctrl->subdev,
-				NOTIFY_VFE_IRQ,
-				(void *)VFE_IRQ_STATUS0_CAMIF_SOF_MASK);
-		}
-
-		/* interrupt to be processed,  *qcmd has the payload.  */
-		if (qcmd->vfeInterruptStatus0 &
-				VFE_IRQ_STATUS0_REG_UPDATE_MASK)
-			v4l2_subdev_notify(&vfe40_ctrl->subdev,
-				NOTIFY_VFE_IRQ,
-				(void *)VFE_IRQ_STATUS0_REG_UPDATE_MASK);
-
-		if (qcmd->vfeInterruptStatus1 &
-				VFE_IRQ_STATUS0_RDI0_REG_UPDATE_MASK)
-			v4l2_subdev_notify(&vfe40_ctrl->subdev,
-				NOTIFY_VFE_IRQ,
-				(void *)VFE_IRQ_STATUS0_RDI0_REG_UPDATE);
-
-		if (qcmd->vfeInterruptStatus1 &
-				VFE_IRQ_STATUS0_RDI1_REG_UPDATE_MASK)
-			v4l2_subdev_notify(&vfe40_ctrl->subdev,
-				NOTIFY_VFE_IRQ,
-				(void *)VFE_IRQ_STATUS0_RDI1_REG_UPDATE);
-
-		if (qcmd->vfeInterruptStatus0 &
-				VFE_IMASK_WHILE_STOPPING_0)
-			v4l2_subdev_notify(&vfe40_ctrl->subdev,
-				NOTIFY_VFE_IRQ,
-				(void *)VFE_IMASK_WHILE_STOPPING_0);
-
-		if (atomic_read(&axi_ctrl->share_ctrl->handle_common_irq)) {
-			if (qcmd->vfeInterruptStatus1 &
-					VFE40_IMASK_COMMON_ERROR_ONLY_1) {
-				pr_err("irq	errorIrq\n");
-				vfe40_process_common_error_irq(
-					axi_ctrl,
-					qcmd->vfeInterruptStatus1 &
-					VFE40_IMASK_COMMON_ERROR_ONLY_1);
-			}
-
-			v4l2_subdev_notify(&axi_ctrl->subdev,
-				NOTIFY_AXI_IRQ,
-				(void *)qcmd->vfeInterruptStatus0);
-		}
-
-		if (atomic_read(&axi_ctrl->share_ctrl->vstate)) {
-			if (qcmd->vfeInterruptStatus1 &
-					VFE40_IMASK_VFE_ERROR_ONLY_1) {
-				pr_err("irq	errorIrq\n");
-				vfe40_process_error_irq(
-					axi_ctrl,
-					qcmd->vfeInterruptStatus1 &
-					VFE40_IMASK_VFE_ERROR_ONLY_1);
-			}
-
-			/* then process stats irq. */
-			if (axi_ctrl->share_ctrl->stats_comp) {
-				/* process stats comb interrupt. */
-				if (qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_COMPOSIT_MASK_0) {
-					CDBG("Stats composite irq occured.\n");
-					v4l2_subdev_notify(&vfe40_ctrl->subdev,
-					NOTIFY_VFE_IRQ,
-					(void *)qcmd->vfeInterruptStatus0);
-				}
-			} else {
-				/* process individual stats interrupt. */
-				if (qcmd->vfeInterruptStatus0 &
-						VFE_IRQ_STATUS0_STATS_BG)
-					v4l2_subdev_notify(&vfe40_ctrl->subdev,
-					NOTIFY_VFE_IRQ,
-					(void *)VFE_IRQ_STATUS0_STATS_BG);
-
-				if (qcmd->vfeInterruptStatus0 &
-						VFE_IRQ_STATUS0_STATS_BE)
-					v4l2_subdev_notify(&vfe40_ctrl->subdev,
-					NOTIFY_VFE_IRQ,
-					(void *)VFE_IRQ_STATUS0_STATS_BE);
-
-				if (qcmd->vfeInterruptStatus0 &
-						VFE_IRQ_STATUS0_STATS_AWB)
-					v4l2_subdev_notify(&vfe40_ctrl->subdev,
-					NOTIFY_VFE_IRQ,
-					(void *)VFE_IRQ_STATUS0_STATS_AWB);
-
-				if (qcmd->vfeInterruptStatus0 &
-						VFE_IRQ_STATUS0_STATS_BF)
-					v4l2_subdev_notify(&vfe40_ctrl->subdev,
-					NOTIFY_VFE_IRQ,
-					(void *)VFE_IRQ_STATUS0_STATS_BF);
-				if (qcmd->vfeInterruptStatus0 &
-					VFE_IRQ_STATUS0_STATS_SKIN_BHIST)
-					v4l2_subdev_notify(&vfe40_ctrl->subdev,
-					NOTIFY_VFE_IRQ,
-					(void *)
-					VFE_IRQ_STATUS0_STATS_SKIN_BHIST);
-
-				if (qcmd->vfeInterruptStatus0 &
-						VFE_IRQ_STATUS0_STATS_IHIST)
-					v4l2_subdev_notify(&vfe40_ctrl->subdev,
-					NOTIFY_VFE_IRQ,
-					(void *)VFE_IRQ_STATUS0_STATS_IHIST);
-
-				if (qcmd->vfeInterruptStatus0 &
-						VFE_IRQ_STATUS0_STATS_RS)
-					v4l2_subdev_notify(&vfe40_ctrl->subdev,
-					NOTIFY_VFE_IRQ,
-					(void *)VFE_IRQ_STATUS0_STATS_RS);
-
-				if (qcmd->vfeInterruptStatus0 &
-						VFE_IRQ_STATUS0_STATS_CS)
-					v4l2_subdev_notify(&vfe40_ctrl->subdev,
-					NOTIFY_VFE_IRQ,
-					(void *)VFE_IRQ_STATUS0_STATS_CS);
-
-				if (qcmd->vfeInterruptStatus1 &
-						VFE_IRQ_STATUS1_SYNC_TIMER0)
-					v4l2_subdev_notify(&vfe40_ctrl->subdev,
-					NOTIFY_VFE_IRQ,
-					(void *)VFE_IRQ_STATUS1_SYNC_TIMER0);
-
-				if (qcmd->vfeInterruptStatus1 &
-						VFE_IRQ_STATUS1_SYNC_TIMER1)
-					v4l2_subdev_notify(&vfe40_ctrl->subdev,
-					NOTIFY_VFE_IRQ,
-					(void *)VFE_IRQ_STATUS1_SYNC_TIMER1);
-
-				if (qcmd->vfeInterruptStatus1 &
-						VFE_IRQ_STATUS1_SYNC_TIMER2)
-					v4l2_subdev_notify(&vfe40_ctrl->subdev,
-					NOTIFY_VFE_IRQ,
-					(void *)VFE_IRQ_STATUS1_SYNC_TIMER2);
-			}
-		}
-		vfe40_ctrl->simultaneous_sof_stat = 0;
-		kfree(qcmd);
-	}
-	CDBG("=== axi40_do_tasklet end ===\n");
-}
-
-static irqreturn_t vfe40_parse_irq(int irq_num, void *data)
-{
-	unsigned long flags;
-	struct vfe40_irq_status irq;
-	struct vfe40_isr_queue_cmd *qcmd;
-	struct axi_ctrl_t *axi_ctrl = data;
-
-	CDBG("vfe_parse_irq\n");
-
-	vfe40_read_irq_status(axi_ctrl, &irq);
-
-	if ((irq.vfeIrqStatus0 == 0) && (irq.vfeIrqStatus1 == 0)) {
-		CDBG("vfe_parse_irq: vfeIrqStatus0 & 1 are both 0!\n");
-		return IRQ_HANDLED;
-	}
-
-	qcmd = kzalloc(sizeof(struct vfe40_isr_queue_cmd),
-		GFP_ATOMIC);
-	if (!qcmd) {
-		pr_err("vfe_parse_irq: qcmd malloc failed!\n");
-		return IRQ_HANDLED;
-	}
-
-	spin_lock_irqsave(&axi_ctrl->share_ctrl->stop_flag_lock, flags);
-	if (axi_ctrl->share_ctrl->stop_ack_pending) {
-		irq.vfeIrqStatus0 &= VFE_IMASK_WHILE_STOPPING_0;
-		irq.vfeIrqStatus1 &= VFE_IMASK_WHILE_STOPPING_1;
-	}
-	spin_unlock_irqrestore(&axi_ctrl->share_ctrl->stop_flag_lock, flags);
-
-	CDBG("vfe_parse_irq: Irq_status0 = 0x%x, Irq_status1 = 0x%x.\n",
-		irq.vfeIrqStatus0, irq.vfeIrqStatus1);
-
-	qcmd->vfeInterruptStatus0 = irq.vfeIrqStatus0;
-	qcmd->vfeInterruptStatus1 = irq.vfeIrqStatus1;
-
-	spin_lock_irqsave(&axi_ctrl->tasklet_lock, flags);
-	list_add_tail(&qcmd->list, &axi_ctrl->tasklet_q);
-
-	atomic_add(1, &irq_cnt);
-	spin_unlock_irqrestore(&axi_ctrl->tasklet_lock, flags);
-	tasklet_schedule(&axi_ctrl->vfe40_tasklet);
-	return IRQ_HANDLED;
-}
-
-int msm_axi_subdev_isr_routine(struct v4l2_subdev *sd,
-	u32 status, bool *handled)
-{
-	struct axi_ctrl_t *axi_ctrl = v4l2_get_subdevdata(sd);
-	irqreturn_t ret;
-	CDBG("%s E ", __func__);
-	ret = vfe40_parse_irq(axi_ctrl->vfeirq->start, axi_ctrl);
-	*handled = TRUE;
-	return 0;
-}
-
-static long vfe_stats_bufq_sub_ioctl(
-	struct vfe40_ctrl_type *vfe_ctrl,
-	struct msm_vfe_cfg_cmd *cmd, void *ion_client, int domain_num)
-{
-	long rc = 0;
-	switch (cmd->cmd_type) {
-	case VFE_CMD_STATS_REQBUF:
-	if (!vfe_ctrl->stats_ops.stats_ctrl) {
-		/* stats_ctrl has not been init yet */
-		rc = msm_stats_buf_ops_init(&vfe_ctrl->stats_ctrl,
-				(struct ion_client *)ion_client,
-				&vfe_ctrl->stats_ops);
-		if (rc < 0) {
-			pr_err("%s: cannot init stats ops", __func__);
-			goto end;
-		}
-		rc = vfe_ctrl->stats_ops.stats_ctrl_init(&vfe_ctrl->stats_ctrl);
-		if (rc < 0) {
-			pr_err("%s: cannot init stats_ctrl ops", __func__);
-			memset(&vfe_ctrl->stats_ops, 0,
-				sizeof(vfe_ctrl->stats_ops));
-			goto end;
-		}
-		if (sizeof(struct msm_stats_reqbuf) != cmd->length) {
-			/* error. the length not match */
-			pr_err("%s: stats reqbuf input size = %d,\n"
-				"struct size = %d, mitch match\n",
-				 __func__, cmd->length,
-				sizeof(struct msm_stats_reqbuf));
-			rc = -EINVAL ;
-			goto end;
-		}
-	}
-	rc = vfe_ctrl->stats_ops.reqbuf(
-			&vfe_ctrl->stats_ctrl,
-			(struct msm_stats_reqbuf *)cmd->value,
-			vfe_ctrl->stats_ops.client);
-	break;
-	case VFE_CMD_STATS_ENQUEUEBUF:
-	if (sizeof(struct msm_stats_buf_info) != cmd->length) {
-		/* error. the length not match */
-		pr_err("%s: stats enqueuebuf input size = %d,\n"
-			"struct size = %d, mitch match\n",
-			 __func__, cmd->length,
-			sizeof(struct msm_stats_buf_info));
-			rc = -EINVAL;
-			goto end;
-	}
-	rc = vfe_ctrl->stats_ops.enqueue_buf(
-			&vfe_ctrl->stats_ctrl,
-			(struct msm_stats_buf_info *)cmd->value,
-			vfe_ctrl->stats_ops.client, domain_num);
-	break;
-	case VFE_CMD_STATS_FLUSH_BUFQ:
-	{
-		struct msm_stats_flush_bufq *flush_req = NULL;
-		flush_req = (struct msm_stats_flush_bufq *)cmd->value;
-		if (sizeof(struct msm_stats_flush_bufq) != cmd->length) {
-			/* error. the length not match */
-			pr_err("%s: stats flush queue input size = %d,\n"
-				"struct size = %d, mitch match\n",
-				__func__, cmd->length,
-				sizeof(struct msm_stats_flush_bufq));
-			rc = -EINVAL;
-			goto end;
-	}
-	rc = vfe_ctrl->stats_ops.bufq_flush(
-			&vfe_ctrl->stats_ctrl,
-			(enum msm_stats_enum_type)flush_req->stats_type,
-			vfe_ctrl->stats_ops.client);
-	}
-	break;
-	case VFE_CMD_STATS_UNREGBUF:
-	{
-		struct msm_stats_reqbuf *req_buf = NULL;
-		req_buf = (struct msm_stats_reqbuf *)cmd->value;
-		if (sizeof(struct msm_stats_reqbuf) != cmd->length) {
-			/* error. the length not match */
-			pr_err("%s: stats reqbuf input size = %d,\n"
-				"struct size = %d, mitch match\n",
-				 __func__, cmd->length,
-				sizeof(struct msm_stats_reqbuf));
-			rc = -EINVAL ;
-			goto end;
-		}
-		rc = vfe40_stats_unregbuf(vfe_ctrl, req_buf, domain_num);
-	}
-	break;
-	default:
-		rc = -1;
-		pr_err("%s: cmd_type %d not supported", __func__,
-			cmd->cmd_type);
-	break;
-	}
-end:
-	return rc;
-}
-
-static long msm_vfe_subdev_ioctl(struct v4l2_subdev *sd,
-			unsigned int subdev_cmd, void *arg)
-{
-	struct msm_cam_media_controller *pmctl =
-		(struct msm_cam_media_controller *)v4l2_get_subdev_hostdata(sd);
-	struct vfe40_ctrl_type *vfe40_ctrl =
-		(struct vfe40_ctrl_type *)v4l2_get_subdevdata(sd);
-	struct msm_isp_cmd vfecmd;
-	struct msm_camvfe_params *vfe_params;
-	struct msm_vfe_cfg_cmd *cmd;
-	void *data;
-
-	long rc = 0;
-	struct vfe_cmd_stats_buf *scfg = NULL;
-	struct vfe_cmd_stats_ack *sack = NULL;
-
-	if (!vfe40_ctrl->share_ctrl->vfebase) {
-		pr_err("%s: base address unmapped\n", __func__);
-		return -EFAULT;
-	}
-
-	CDBG("%s\n", __func__);
-	if (subdev_cmd == VIDIOC_MSM_VFE_INIT) {
-		CDBG("%s init\n", __func__);
-		return msm_vfe_subdev_init(sd);
-	} else if (subdev_cmd == VIDIOC_MSM_VFE_RELEASE) {
-		msm_vfe_subdev_release(sd);
-		return 0;
-	}
-	vfe_params = (struct msm_camvfe_params *)arg;
-	cmd = vfe_params->vfe_cfg;
-	data = vfe_params->data;
-	switch (cmd->cmd_type) {
-	case CMD_VFE_PROCESS_IRQ:
-		vfe40_process_irq(vfe40_ctrl, (uint32_t) data);
-		return rc;
-	case VFE_CMD_STATS_REQBUF:
-	case VFE_CMD_STATS_ENQUEUEBUF:
-	case VFE_CMD_STATS_FLUSH_BUFQ:
-	case VFE_CMD_STATS_UNREGBUF:
-		/* for easy porting put in one envelope */
-		rc = vfe_stats_bufq_sub_ioctl(vfe40_ctrl,
-				cmd, vfe_params->data, pmctl->domain_num);
-		return rc;
-	default:
-		if (cmd->cmd_type != CMD_CONFIG_PING_ADDR &&
-		cmd->cmd_type != CMD_CONFIG_PONG_ADDR &&
-		cmd->cmd_type != CMD_CONFIG_FREE_BUF_ADDR &&
-		cmd->cmd_type != CMD_STATS_AEC_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_AWB_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_IHIST_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_RS_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_CS_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_AF_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_BG_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_BE_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_BF_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_BHIST_BUF_RELEASE &&
-		cmd->cmd_type != CMD_VFE_PIX_SOF_COUNT_UPDATE &&
-		cmd->cmd_type != CMD_VFE_COUNT_PIX_SOF_ENABLE) {
-			if (copy_from_user(&vfecmd,
-					(void __user *)(cmd->value),
-					sizeof(vfecmd))) {
-				pr_err("%s %d: copy_from_user failed\n",
-					__func__, __LINE__);
-				return -EFAULT;
-			}
-		} else {
-			/* here eith stats release or frame release. */
-			if (cmd->cmd_type != CMD_CONFIG_PING_ADDR &&
-				cmd->cmd_type != CMD_CONFIG_PONG_ADDR &&
-				cmd->cmd_type != CMD_CONFIG_FREE_BUF_ADDR) {
-				/* then must be stats release. */
-				if (!data) {
-					pr_err("%s: data = NULL, cmd->cmd_type = %d",
-						__func__, cmd->cmd_type);
-					return -EFAULT;
-				}
-				sack = kmalloc(sizeof(struct vfe_cmd_stats_ack),
-							GFP_ATOMIC);
-				if (!sack) {
-					pr_err("%s: no mem for cmd->cmd_type = %d",
-					 __func__, cmd->cmd_type);
-					return -ENOMEM;
-				}
-				sack->nextStatsBuf = *(uint32_t *)data;
-			}
-		}
-	}
-
-	CDBG("%s: cmdType = %d\n", __func__, cmd->cmd_type);
-
-	if ((cmd->cmd_type == CMD_STATS_AF_ENABLE)    ||
-		(cmd->cmd_type == CMD_STATS_AWB_ENABLE)   ||
-		(cmd->cmd_type == CMD_STATS_IHIST_ENABLE) ||
-		(cmd->cmd_type == CMD_STATS_RS_ENABLE)    ||
-		(cmd->cmd_type == CMD_STATS_CS_ENABLE)    ||
-		(cmd->cmd_type == CMD_STATS_AEC_ENABLE)   ||
-		(cmd->cmd_type == CMD_STATS_BG_ENABLE)    ||
-		(cmd->cmd_type == CMD_STATS_BE_ENABLE)    ||
-		(cmd->cmd_type == CMD_STATS_BF_ENABLE)    ||
-		(cmd->cmd_type == CMD_STATS_BHIST_ENABLE)) {
-		struct axidata *axid;
-		axid = data;
-		if (!axid) {
-			rc = -EFAULT;
-			goto vfe40_config_done;
-		}
-		CDBG("%s: cmdType = %d\n", __func__, cmd->cmd_type);
-
-		if ((cmd->cmd_type == CMD_STATS_AF_ENABLE)    ||
-			(cmd->cmd_type == CMD_STATS_AWB_ENABLE)   ||
-			(cmd->cmd_type == CMD_STATS_IHIST_ENABLE) ||
-			(cmd->cmd_type == CMD_STATS_RS_ENABLE)    ||
-			(cmd->cmd_type == CMD_STATS_CS_ENABLE)    ||
-			(cmd->cmd_type == CMD_STATS_AEC_ENABLE)) {
-				scfg = NULL;
-				/* individual */
-				goto vfe40_config_done;
-		}
-		switch (cmd->cmd_type) {
-		case CMD_STATS_AEC_ENABLE:
-		case CMD_STATS_BG_ENABLE:
-		case CMD_STATS_BE_ENABLE:
-		case CMD_STATS_BF_ENABLE:
-		case CMD_STATS_BHIST_ENABLE:
-		case CMD_STATS_AWB_ENABLE:
-		case CMD_STATS_IHIST_ENABLE:
-		case CMD_STATS_RS_ENABLE:
-		case CMD_STATS_CS_ENABLE:
-		default:
-			pr_err("%s Unsupported cmd type %d",
-				__func__, cmd->cmd_type);
-			break;
-		}
-		goto vfe40_config_done;
-	}
-	switch (cmd->cmd_type) {
-	case CMD_GENERAL:
-		rc = vfe40_proc_general(pmctl, &vfecmd, vfe40_ctrl);
-	break;
-	case CMD_VFE_COUNT_PIX_SOF_ENABLE: {
-		int enable = *((int *)cmd->value);
-		if (enable)
-			vfe40_ctrl->vfe_sof_count_enable = TRUE;
-		else
-			vfe40_ctrl->vfe_sof_count_enable = false;
-	}
-	break;
-	case CMD_VFE_PIX_SOF_COUNT_UPDATE:
-		if (!vfe40_ctrl->vfe_sof_count_enable)
-			vfe40_ctrl->share_ctrl->vfeFrameId =
-			*((uint32_t *)vfe_params->data);
-	break;
-	case CMD_CONFIG_PING_ADDR: {
-		int path = *((int *)cmd->value);
-		struct vfe40_output_ch *outch =
-			vfe40_get_ch(path, vfe40_ctrl->share_ctrl);
-		outch->ping = *((struct msm_free_buf *)data);
-	}
-	break;
-
-	case CMD_CONFIG_PONG_ADDR: {
-		int path = *((int *)cmd->value);
-		struct vfe40_output_ch *outch =
-			vfe40_get_ch(path, vfe40_ctrl->share_ctrl);
-		outch->pong = *((struct msm_free_buf *)data);
-	}
-	break;
-
-	case CMD_CONFIG_FREE_BUF_ADDR: {
-		int path = *((int *)cmd->value);
-		struct vfe40_output_ch *outch =
-			vfe40_get_ch(path, vfe40_ctrl->share_ctrl);
-		outch->free_buf = *((struct msm_free_buf *)data);
-	}
-	break;
-
-	case CMD_SNAP_BUF_RELEASE:
-		break;
-
-	default:
-		pr_err("%s Unsupported AXI configuration %x ", __func__,
-			cmd->cmd_type);
-	break;
-	}
-vfe40_config_done:
-	kfree(scfg);
-	kfree(sack);
-	CDBG("%s done: rc = %d\n", __func__, (int) rc);
-	return rc;
-}
-
-static struct msm_cam_clk_info vfe40_clk_info[] = {
-	{"camss_top_ahb_clk", -1},
-	{"vfe_clk_src", 266670000},
-	{"camss_vfe_vfe_clk", -1},
-	{"camss_csi_vfe_clk", -1},
-	{"iface_clk", -1},
-	{"bus_clk", -1},
-	{"alt_bus_clk", -1},
-};
-
-static int msm_axi_subdev_s_crystal_freq(struct v4l2_subdev *sd,
-						u32 freq, u32 flags)
-{
-	int rc = 0;
-	int round_rate;
-	struct axi_ctrl_t *axi_ctrl = v4l2_get_subdevdata(sd);
-
-	round_rate = clk_round_rate(axi_ctrl->vfe_clk[1], freq);
-	if (rc < 0) {
-		pr_err("%s: clk_round_rate failed %d\n",
-					__func__, rc);
-		return rc;
-	}
-
-	vfe_clk_rate = round_rate;
-	rc = clk_set_rate(axi_ctrl->vfe_clk[1], round_rate);
-	if (rc < 0)
-		pr_err("%s: clk_set_rate failed %d\n",
-					__func__, rc);
-
-	return rc;
-}
-
-static const struct v4l2_subdev_core_ops msm_vfe_subdev_core_ops = {
-	.ioctl = msm_vfe_subdev_ioctl,
-};
-
-static const struct v4l2_subdev_ops msm_vfe_subdev_ops = {
-	.core = &msm_vfe_subdev_core_ops,
-};
-
-static void msm_vfe40_init_vbif_parms(void __iomem *vfe_vbif_base)
-{
-	msm_camera_io_w(0x1,
-		vfe_vbif_base + VFE40_VBIF_CLKON);
-	msm_camera_io_w(0x01010101,
-		vfe_vbif_base + VFE40_VBIF_IN_RD_LIM_CONF0);
-	msm_camera_io_w(0x01010101,
-		vfe_vbif_base + VFE40_VBIF_IN_RD_LIM_CONF1);
-	msm_camera_io_w(0x10010110,
-		vfe_vbif_base + VFE40_VBIF_IN_RD_LIM_CONF2);
-	msm_camera_io_w(0x10101010,
-		vfe_vbif_base + VFE40_VBIF_IN_WR_LIM_CONF0);
-	msm_camera_io_w(0x10101010,
-		vfe_vbif_base + VFE40_VBIF_IN_WR_LIM_CONF1);
-	msm_camera_io_w(0x10101010,
-		vfe_vbif_base + VFE40_VBIF_IN_WR_LIM_CONF2);
-	msm_camera_io_w(0x00001010,
-		vfe_vbif_base + VFE40_VBIF_OUT_RD_LIM_CONF0);
-	msm_camera_io_w(0x00001010,
-		vfe_vbif_base + VFE40_VBIF_OUT_WR_LIM_CONF0);
-	msm_camera_io_w(0x00000707,
-		vfe_vbif_base + VFE40_VBIF_DDR_OUT_MAX_BURST);
-	msm_camera_io_w(0x00000707,
-		vfe_vbif_base + VFE40_VBIF_OCMEM_OUT_MAX_BURST);
-	msm_camera_io_w(0x00000030,
-		vfe_vbif_base + VFE40_VBIF_ARB_CTL);
-	msm_camera_io_w(0x04210842,
-		vfe_vbif_base + VFE40_VBIF_DDR_ARB_CONF0);
-	msm_camera_io_w(0x04210842,
-		vfe_vbif_base + VFE40_VBIF_DDR_ARB_CONF1);
-	msm_camera_io_w(0x00000001,
-		vfe_vbif_base + VFE40_VBIF_ROUND_ROBIN_QOS_ARB);
-	msm_camera_io_w(0x22222222,
-		vfe_vbif_base + VFE40_VBIF_OUT_AXI_AMEMTYPE_CONF0);
-	msm_camera_io_w(0x00002222,
-		vfe_vbif_base + VFE40_VBIF_OUT_AXI_AMEMTYPE_CONF1);
-	msm_camera_io_w(0x00000FFF,
-		vfe_vbif_base + VFE40_VBIF_OUT_AXI_AOOO_EN);
-	msm_camera_io_w(0x0FFF0FFF,
-		vfe_vbif_base + VFE40_VBIF_OUT_AXI_AOOO);
-}
-
-int msm_axi_subdev_init(struct v4l2_subdev *sd)
-{
-	int rc = 0;
-	struct axi_ctrl_t *axi_ctrl = v4l2_get_subdevdata(sd);
-	struct msm_cam_media_controller *mctl;
-	mctl = v4l2_get_subdev_hostdata(sd);
-	if (mctl == NULL) {
-		pr_err("%s: mctl is NULL\n", __func__);
-		rc = -EINVAL;
-		goto mctl_failed;
-	}
-	axi_ctrl->share_ctrl->axi_ref_cnt++;
-	if (axi_ctrl->share_ctrl->axi_ref_cnt > 1)
-		return rc;
-
-	spin_lock_init(&axi_ctrl->tasklet_lock);
-	INIT_LIST_HEAD(&axi_ctrl->tasklet_q);
-	spin_lock_init(&axi_ctrl->share_ctrl->sd_notify_lock);
-
-	axi_ctrl->share_ctrl->vfebase = ioremap(axi_ctrl->vfemem->start,
-		resource_size(axi_ctrl->vfemem));
-	if (!axi_ctrl->share_ctrl->vfebase) {
-		rc = -ENOMEM;
-		pr_err("%s: vfe ioremap failed\n", __func__);
-		goto remap_failed;
-	}
-
-	axi_ctrl->share_ctrl->vfe_vbif_base =
-		ioremap(axi_ctrl->vfe_vbif_mem->start,
-			resource_size(axi_ctrl->vfe_vbif_mem));
-	if (!axi_ctrl->share_ctrl->vfe_vbif_base) {
-		rc = -ENOMEM;
-		pr_err("%s: vfe ioremap failed\n", __func__);
-		goto remap_failed;
-	}
-
-	if (axi_ctrl->fs_vfe) {
-		rc = regulator_enable(axi_ctrl->fs_vfe);
-		if (rc) {
-			pr_err("%s: Regulator enable failed\n",	__func__);
-			goto fs_failed;
-		}
-	}
-
-	rc = msm_cam_clk_enable(&axi_ctrl->pdev->dev, vfe40_clk_info,
-			axi_ctrl->vfe_clk, ARRAY_SIZE(vfe40_clk_info), 1);
-	if (rc < 0)
-		goto clk_enable_failed;
-
-	axi_ctrl->bus_perf_client =
-		msm_bus_scale_register_client(&vfe_bus_client_pdata);
-	if (!axi_ctrl->bus_perf_client) {
-		pr_err("%s: Registration Failed!\n", __func__);
-		axi_ctrl->bus_perf_client = 0;
-		goto bus_scale_register_failed;
-	}
-
-	msm_camera_bus_scale_cfg(axi_ctrl->bus_perf_client, S_PREVIEW);
-
-	rc = iommu_attach_device(mctl->domain, axi_ctrl->iommu_ctx);
-	if (rc < 0) {
-		pr_err("%s: imgwr attach failed rc = %d\n", __func__, rc);
-		rc = -ENODEV;
-		goto device_imgwr_attach_failed;
-	}
-
-	msm_vfe40_init_vbif_parms(axi_ctrl->share_ctrl->vfe_vbif_base);
-
-	axi_ctrl->share_ctrl->register_total = VFE40_REGISTER_TOTAL;
-
-	spin_lock_init(&axi_ctrl->share_ctrl->stop_flag_lock);
-	spin_lock_init(&axi_ctrl->share_ctrl->update_ack_lock);
-	spin_lock_init(&axi_ctrl->share_ctrl->start_ack_lock);
-	init_completion(&axi_ctrl->share_ctrl->reset_complete);
-
-	if (!axi_ctrl->use_irq_router)
-		enable_irq(axi_ctrl->vfeirq->start);
-
-	return rc;
-
-bus_scale_register_failed:
-	msm_cam_clk_enable(&axi_ctrl->pdev->dev, vfe40_clk_info,
-		axi_ctrl->vfe_clk, ARRAY_SIZE(vfe40_clk_info), 0);
-clk_enable_failed:
-	if (axi_ctrl->fs_vfe)
-		regulator_disable(axi_ctrl->fs_vfe);
-fs_failed:
-	iounmap(axi_ctrl->share_ctrl->vfebase);
-	axi_ctrl->share_ctrl->vfebase = NULL;
-remap_failed:
-	iommu_detach_device(mctl->domain, axi_ctrl->iommu_ctx);
-device_imgwr_attach_failed:
-	if (!axi_ctrl->use_irq_router)
-		disable_irq(axi_ctrl->vfeirq->start);
-mctl_failed:
-	return rc;
-}
-
-int msm_vfe_subdev_init(struct v4l2_subdev *sd)
-{
-	int rc = 0;
-	struct vfe40_ctrl_type *vfe40_ctrl =
-		(struct vfe40_ctrl_type *)v4l2_get_subdevdata(sd);
-
-	spin_lock_init(&vfe40_ctrl->state_lock);
-	spin_lock_init(&vfe40_ctrl->stats_bufq_lock);
-
-	vfe40_ctrl->update_linear = false;
-	vfe40_ctrl->update_rolloff = false;
-	vfe40_ctrl->update_la = false;
-	vfe40_ctrl->update_gamma = false;
-	vfe40_ctrl->vfe_sof_count_enable = true;
-	vfe40_ctrl->hfr_mode = HFR_MODE_OFF;
-
-	memset(&vfe40_ctrl->stats_ctrl, 0,
-		   sizeof(struct msm_stats_bufq_ctrl));
-	memset(&vfe40_ctrl->stats_ops, 0, sizeof(struct msm_stats_ops));
-
-	return rc;
-}
-
-void msm_axi_subdev_release(struct v4l2_subdev *sd)
-{
-	struct msm_cam_media_controller *pmctl =
-		(struct msm_cam_media_controller *)v4l2_get_subdev_hostdata(sd);
-	struct axi_ctrl_t *axi_ctrl = v4l2_get_subdevdata(sd);
-	if (!axi_ctrl->share_ctrl->vfebase) {
-		pr_err("%s: base address unmapped\n", __func__);
-		return;
-	}
-
-	CDBG("%s, free_irq\n", __func__);
-	axi_ctrl->share_ctrl->axi_ref_cnt--;
-	if (axi_ctrl->share_ctrl->axi_ref_cnt > 0)
-		return;
-	if (!axi_ctrl->use_irq_router)
-		disable_irq(axi_ctrl->vfeirq->start);
-	tasklet_kill(&axi_ctrl->vfe40_tasklet);
-
-	iommu_detach_device(pmctl->domain, axi_ctrl->iommu_ctx);
-
-	msm_cam_clk_enable(&axi_ctrl->pdev->dev, vfe40_clk_info,
-			axi_ctrl->vfe_clk, ARRAY_SIZE(vfe40_clk_info), 0);
-	if (axi_ctrl->fs_vfe)
-		regulator_disable(axi_ctrl->fs_vfe);
-
-	iounmap(axi_ctrl->share_ctrl->vfebase);
-	iounmap(axi_ctrl->share_ctrl->vfe_vbif_base);
-	axi_ctrl->share_ctrl->vfebase = NULL;
-
-	if (atomic_read(&irq_cnt))
-		pr_warning("%s, Warning IRQ Count not ZERO\n", __func__);
-
-	msm_camera_bus_scale_cfg(axi_ctrl->bus_perf_client, S_EXIT);
-	axi_ctrl->bus_perf_client = 0;
-
-	msm_vfe_subdev_release(&axi_ctrl->share_ctrl->vfe40_ctrl->subdev);
-}
-
-void msm_vfe_subdev_release(struct v4l2_subdev *sd)
-{
-	struct vfe40_ctrl_type *vfe40_ctrl =
-		(struct vfe40_ctrl_type *)v4l2_get_subdevdata(sd);
-	CDBG("vfe subdev release %p\n",
-		vfe40_ctrl->share_ctrl->vfebase);
-}
-
-void axi_abort(struct axi_ctrl_t *axi_ctrl)
-{
-	uint8_t  axi_busy_flag = true;
-	unsigned long flags;
-	/* axi halt command. */
-
-	spin_lock_irqsave(&axi_ctrl->share_ctrl->stop_flag_lock, flags);
-	axi_ctrl->share_ctrl->stop_ack_pending  = TRUE;
-	spin_unlock_irqrestore(&axi_ctrl->share_ctrl->stop_flag_lock, flags);
-	msm_camera_io_w(AXI_HALT,
-		axi_ctrl->share_ctrl->vfebase + VFE_AXI_CMD);
-	wmb();
-	while (axi_busy_flag) {
-		if (msm_camera_io_r(
-			axi_ctrl->share_ctrl->vfebase + VFE_AXI_STATUS) & 0x1)
-			axi_busy_flag = false;
-	}
-	/* Ensure the write order while writing
-	* to the command register using the barrier */
-	msm_camera_io_w_mb(AXI_HALT_CLEAR,
-		axi_ctrl->share_ctrl->vfebase + VFE_AXI_CMD);
-
-	/* after axi halt, then ok to apply global reset.
-	* enable reset_ack and async timer interrupt only while
-	* stopping the pipeline.*/
-	msm_camera_io_w(0x80000000,
-		axi_ctrl->share_ctrl->vfebase + VFE_IRQ_MASK_0);
-	msm_camera_io_w(0xF0000000,
-		axi_ctrl->share_ctrl->vfebase + VFE_IRQ_MASK_1);
-
-	/* Ensure the write order while writing
-	* to the command register using the barrier */
-	msm_camera_io_w_mb(VFE_RESET_UPON_STOP_CMD,
-		axi_ctrl->share_ctrl->vfebase + VFE_GLOBAL_RESET);
-	if (axi_ctrl->share_ctrl->sync_abort)
-		wait_for_completion_interruptible(
-			&axi_ctrl->share_ctrl->reset_complete);
-}
-
-int axi_config_buffers(struct axi_ctrl_t *axi_ctrl,
-	struct msm_camera_vfe_params_t vfe_params)
-{
-	uint16_t vfe_mode = axi_ctrl->share_ctrl->current_mode
-			& ~(VFE_OUTPUTS_RDI0|VFE_OUTPUTS_RDI1);
-	int rc = 0;
-	switch (vfe_params.cmd_type) {
-	case AXI_CMD_PREVIEW:
-		if (vfe_mode) {
-			if ((axi_ctrl->share_ctrl->current_mode &
-				VFE_OUTPUTS_PREVIEW_AND_VIDEO) ||
-				(axi_ctrl->share_ctrl->current_mode &
-				VFE_OUTPUTS_PREVIEW))
-				/* Configure primary channel */
-				rc = configure_pingpong_buffers(
-					VFE_MSG_START,
-					VFE_MSG_OUTPUT_PRIMARY,
-					axi_ctrl);
-			else
-			/* Configure secondary channel */
-				rc = configure_pingpong_buffers(
-					VFE_MSG_START,
-					VFE_MSG_OUTPUT_SECONDARY,
-					axi_ctrl);
-		}
-		if (axi_ctrl->share_ctrl->current_mode &
-				VFE_OUTPUTS_RDI0)
-			rc = configure_pingpong_buffers(
-				VFE_MSG_START, VFE_MSG_OUTPUT_TERTIARY1,
-				axi_ctrl);
-		if (axi_ctrl->share_ctrl->current_mode &
-				VFE_OUTPUTS_RDI1)
-			rc = configure_pingpong_buffers(
-				VFE_MSG_START, VFE_MSG_OUTPUT_TERTIARY2,
-				axi_ctrl);
-
-		if (rc < 0) {
-			pr_err("%s error configuring pingpong buffers for preview",
-				__func__);
-			rc = -EINVAL;
-			goto config_done;
-		}
-		break;
-	case AXI_CMD_RAW_CAPTURE:
-		rc = configure_pingpong_buffers(
-			VFE_MSG_CAPTURE, VFE_MSG_OUTPUT_PRIMARY,
-			axi_ctrl);
-		if (rc < 0) {
-			pr_err("%s error configuring pingpong buffers for snapshot",
-				__func__);
-			rc = -EINVAL;
-			goto config_done;
-		}
-		break;
-	case AXI_CMD_ZSL:
-		rc = configure_pingpong_buffers(VFE_MSG_START,
-			VFE_MSG_OUTPUT_PRIMARY, axi_ctrl);
-		if (rc < 0)
-			goto config_done;
-		rc = configure_pingpong_buffers(VFE_MSG_START,
-			VFE_MSG_OUTPUT_SECONDARY, axi_ctrl);
-		if (rc < 0)
-			goto config_done;
-		break;
-	case AXI_CMD_RECORD:
-		if (axi_ctrl->share_ctrl->current_mode &
-			VFE_OUTPUTS_PREVIEW_AND_VIDEO) {
-			axi_ctrl->share_ctrl->outpath.out1.inst_handle =
-				vfe_params.inst_handle;
-			rc = configure_pingpong_buffers(
-				VFE_MSG_START_RECORDING,
-				VFE_MSG_OUTPUT_SECONDARY,
-				axi_ctrl);
-		} else if (axi_ctrl->share_ctrl->current_mode &
-			VFE_OUTPUTS_VIDEO_AND_PREVIEW) {
-			axi_ctrl->share_ctrl->outpath.out0.inst_handle =
-				vfe_params.inst_handle;
-			rc = configure_pingpong_buffers(
-				VFE_MSG_START_RECORDING,
-				VFE_MSG_OUTPUT_PRIMARY,
-				axi_ctrl);
-		}
-		if (rc < 0) {
-			pr_err("%s error configuring pingpong buffers for video",
-				__func__);
-			rc = -EINVAL;
-			goto config_done;
-		}
-		break;
-	case AXI_CMD_LIVESHOT:
-		axi_ctrl->share_ctrl->outpath.out0.inst_handle =
-			vfe_params.inst_handle;
-		rc = configure_pingpong_buffers(VFE_MSG_CAPTURE,
-					VFE_MSG_OUTPUT_PRIMARY, axi_ctrl);
-		if (rc < 0) {
-			pr_err("%s error configuring pingpong buffers for primary output",
-				__func__);
-			rc = -EINVAL;
-			goto config_done;
-		}
-		break;
-	case AXI_CMD_CAPTURE:
-		if (axi_ctrl->share_ctrl->current_mode ==
-			VFE_OUTPUTS_JPEG_AND_THUMB ||
-		axi_ctrl->share_ctrl->current_mode ==
-			VFE_OUTPUTS_THUMB_AND_JPEG) {
-
-			/* Configure primary channel for JPEG */
-			rc = configure_pingpong_buffers(
-				VFE_MSG_JPEG_CAPTURE,
-				VFE_MSG_OUTPUT_PRIMARY,
-				axi_ctrl);
-		} else {
-			/* Configure primary channel */
-			rc = configure_pingpong_buffers(
-				VFE_MSG_CAPTURE,
-				VFE_MSG_OUTPUT_PRIMARY,
-				axi_ctrl);
-		}
-		if (rc < 0) {
-			pr_err("%s error configuring pingpong buffers for primary output",
-				__func__);
-			rc = -EINVAL;
-			goto config_done;
-		}
-		/* Configure secondary channel */
-		rc = configure_pingpong_buffers(
-				VFE_MSG_CAPTURE, VFE_MSG_OUTPUT_SECONDARY,
-				axi_ctrl);
-		if (rc < 0) {
-			pr_err("%s error configuring pingpong buffers for secondary output",
-				__func__);
-			rc = -EINVAL;
-			goto config_done;
-		}
-		break;
-	default:
-		rc = -EINVAL;
-		break;
-
-	}
-config_done:
-	return rc;
-}
-
-void axi_start(struct msm_cam_media_controller *pmctl,
-	struct axi_ctrl_t *axi_ctrl, struct msm_camera_vfe_params_t vfe_params)
-{
-	uint32_t irq_comp_mask = 0, irq_mask = 0;
-	int rc = 0;
-	uint32_t reg_update = 0;
-	uint16_t operation_mode =
-		(axi_ctrl->share_ctrl->current_mode &
-		~(VFE_OUTPUTS_RDI0|VFE_OUTPUTS_RDI1));
-	rc = axi_config_buffers(axi_ctrl, vfe_params);
-	if (rc < 0)
-		return;
-
-	switch (vfe_params.cmd_type) {
-	case AXI_CMD_PREVIEW:
-		msm_camera_bus_scale_cfg(axi_ctrl->bus_perf_client, S_PREVIEW);
-		break;
-	case AXI_CMD_CAPTURE:
-	case AXI_CMD_RAW_CAPTURE:
-		msm_camera_bus_scale_cfg(axi_ctrl->bus_perf_client, S_CAPTURE);
-		break;
-	case AXI_CMD_RECORD:
-		msm_camera_bus_scale_cfg(axi_ctrl->bus_perf_client, S_VIDEO);
-		return;
-	case AXI_CMD_ZSL:
-		msm_camera_bus_scale_cfg(axi_ctrl->bus_perf_client, S_ZSL);
-		break;
-	case AXI_CMD_LIVESHOT:
-		msm_camera_bus_scale_cfg(axi_ctrl->bus_perf_client, S_LIVESHOT);
-		return;
-	default:
-		return;
-	}
-
-	irq_comp_mask =
-		msm_camera_io_r(axi_ctrl->share_ctrl->vfebase +
-			VFE_IRQ_COMP_MASK);
-	irq_mask = msm_camera_io_r(axi_ctrl->share_ctrl->vfebase +
-			VFE_IRQ_MASK_0);
-
-	if (axi_ctrl->share_ctrl->outpath.output_mode &
-			VFE40_OUTPUT_MODE_PRIMARY) {
-		if (vfe_params.cmd_type == AXI_CMD_RAW_CAPTURE) {
-			irq_comp_mask |=
-				0x1 << axi_ctrl->share_ctrl->outpath.out0.ch0;
-		} else {
-			irq_comp_mask |= (
-				0x1 << axi_ctrl->share_ctrl->outpath.out0.ch0 |
-				0x1 << axi_ctrl->share_ctrl->outpath.out0.ch1);
-		}
-		irq_mask |= VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE0_MASK;
-	} else if (axi_ctrl->share_ctrl->outpath.output_mode &
-			   VFE40_OUTPUT_MODE_PRIMARY_ALL_CHNLS) {
-		irq_comp_mask |= (
-			0x1 << axi_ctrl->share_ctrl->outpath.out0.ch0 |
-			0x1 << axi_ctrl->share_ctrl->outpath.out0.ch1 |
-			0x1 << axi_ctrl->share_ctrl->outpath.out0.ch2);
-		irq_mask |= VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE0_MASK;
-	}
-	if (axi_ctrl->share_ctrl->outpath.output_mode &
-			VFE40_OUTPUT_MODE_SECONDARY) {
-		irq_comp_mask |= (
-			0x1 << (axi_ctrl->share_ctrl->outpath.out1.ch0 + 8) |
-			0x1 << (axi_ctrl->share_ctrl->outpath.out1.ch1 + 8));
-		irq_mask |= VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE1_MASK;
-	} else if (axi_ctrl->share_ctrl->outpath.output_mode &
-			VFE40_OUTPUT_MODE_SECONDARY_ALL_CHNLS) {
-		irq_comp_mask |= (
-			0x1 << (axi_ctrl->share_ctrl->outpath.out1.ch0 + 8) |
-			0x1 << (axi_ctrl->share_ctrl->outpath.out1.ch1 + 8) |
-			0x1 << (axi_ctrl->share_ctrl->outpath.out1.ch2 + 8));
-		irq_mask |= VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE1_MASK;
-	}
-	if (axi_ctrl->share_ctrl->outpath.output_mode &
-		VFE40_OUTPUT_MODE_TERTIARY1) {
-		irq_mask |= (0x1 << (axi_ctrl->share_ctrl->outpath.out2.ch0 +
-			VFE_WM_OFFSET));
-	}
-	if (axi_ctrl->share_ctrl->outpath.output_mode &
-		VFE40_OUTPUT_MODE_TERTIARY2) {
-		irq_mask |= (0x1 << (axi_ctrl->share_ctrl->outpath.out3.ch0 +
-			VFE_WM_OFFSET));
-	}
-
-	msm_camera_io_w(irq_comp_mask,
-		axi_ctrl->share_ctrl->vfebase + VFE_IRQ_COMP_MASK);
-	msm_camera_io_w(irq_mask, axi_ctrl->share_ctrl->vfebase +
-			VFE_IRQ_MASK_0);
-
-	switch (vfe_params.cmd_type) {
-	case AXI_CMD_PREVIEW: {
-		switch (operation_mode) {
-		case VFE_OUTPUTS_PREVIEW:
-		case VFE_OUTPUTS_PREVIEW_AND_VIDEO:
-			if (axi_ctrl->share_ctrl->outpath.output_mode &
-				VFE40_OUTPUT_MODE_PRIMARY) {
-				msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase
-					+ vfe40_AXI_WM_CFG[axi_ctrl->
-					share_ctrl->outpath.out0.ch0]);
-				msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase
-					+ vfe40_AXI_WM_CFG[axi_ctrl->
-					share_ctrl->outpath.out0.ch1]);
-			} else if (axi_ctrl->share_ctrl->outpath.output_mode &
-					VFE40_OUTPUT_MODE_PRIMARY_ALL_CHNLS) {
-				msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase
-					+ vfe40_AXI_WM_CFG[axi_ctrl->
-					share_ctrl->outpath.out0.ch0]);
-				msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase
-					+ vfe40_AXI_WM_CFG[axi_ctrl->
-					share_ctrl->outpath.out0.ch1]);
-				msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase
-					+ vfe40_AXI_WM_CFG[axi_ctrl->
-					share_ctrl->outpath.out0.ch2]);
-			}
-			break;
-		default:
-			if (axi_ctrl->share_ctrl->outpath.output_mode &
-				VFE40_OUTPUT_MODE_SECONDARY) {
-				msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase
-					+ vfe40_AXI_WM_CFG[axi_ctrl->
-					share_ctrl->outpath.out1.ch0]);
-				msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase
-					+ vfe40_AXI_WM_CFG[axi_ctrl->
-					share_ctrl->outpath.out1.ch1]);
-			} else if (axi_ctrl->share_ctrl->outpath.output_mode &
-				VFE40_OUTPUT_MODE_SECONDARY_ALL_CHNLS) {
-				msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase
-					+ vfe40_AXI_WM_CFG[axi_ctrl->
-					share_ctrl->outpath.out1.ch0]);
-				msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase
-					+ vfe40_AXI_WM_CFG[axi_ctrl->
-					share_ctrl->outpath.out1.ch1]);
-				msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase
-					+ vfe40_AXI_WM_CFG[axi_ctrl->
-					share_ctrl->outpath.out1.ch2]);
-			}
-			break;
-			}
-		}
-		break;
-	default:
-		if (axi_ctrl->share_ctrl->outpath.output_mode &
-			VFE40_OUTPUT_MODE_PRIMARY) {
-			if (vfe_params.cmd_type == AXI_CMD_RAW_CAPTURE) {
-				msm_camera_io_w(1,
-					axi_ctrl->share_ctrl->vfebase +
-					vfe40_AXI_WM_CFG[axi_ctrl->
-					share_ctrl->outpath.out0.ch0]);
-			} else {
-				msm_camera_io_w(1,
-					axi_ctrl->share_ctrl->vfebase +
-					vfe40_AXI_WM_CFG[axi_ctrl
-					->share_ctrl->outpath.out0.ch0]);
-				msm_camera_io_w(1,
-					axi_ctrl->share_ctrl->vfebase +
-					vfe40_AXI_WM_CFG[axi_ctrl->
-					share_ctrl->outpath.out0.ch1]);
-			}
-		} else if (axi_ctrl->share_ctrl->outpath.output_mode &
-				VFE40_OUTPUT_MODE_PRIMARY_ALL_CHNLS) {
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out0.ch0]);
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out0.ch1]);
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out0.ch2]);
-		}
-
-		if (axi_ctrl->share_ctrl->outpath.output_mode &
-			VFE40_OUTPUT_MODE_SECONDARY) {
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out1.ch0]);
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out1.ch1]);
-		} else if (axi_ctrl->share_ctrl->outpath.output_mode &
-			VFE40_OUTPUT_MODE_SECONDARY_ALL_CHNLS) {
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out1.ch0]);
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out1.ch1]);
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out1.ch2]);
-		}
-		break;
-	}
-
-	if (axi_ctrl->share_ctrl->current_mode & VFE_OUTPUTS_RDI0)
-		msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-			vfe40_AXI_WM_CFG[axi_ctrl->share_ctrl->
-			outpath.out2.ch0]);
-	if (axi_ctrl->share_ctrl->current_mode & VFE_OUTPUTS_RDI1)
-		msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-			vfe40_AXI_WM_CFG[axi_ctrl->share_ctrl->
-			outpath.out3.ch0]);
-
-	if (axi_ctrl->share_ctrl->current_mode & VFE_OUTPUTS_RDI0) {
-		irq_mask |= VFE_IRQ_STATUS0_RDI0_REG_UPDATE_MASK;
-		if (!atomic_cmpxchg(
-			&axi_ctrl->share_ctrl->rdi0_update_ack_pending,
-				0, 1))
-			reg_update |= 0x2;
-	}
-	if (axi_ctrl->share_ctrl->current_mode & VFE_OUTPUTS_RDI1) {
-		irq_mask |= VFE_IRQ_STATUS0_RDI1_REG_UPDATE_MASK;
-		if (!atomic_cmpxchg(
-			&axi_ctrl->share_ctrl->rdi1_update_ack_pending,
-				0, 1))
-			reg_update |= 0x4;
-	}
-	msm_camera_io_w(irq_mask, axi_ctrl->share_ctrl->vfebase +
-		VFE_IRQ_MASK_0);
-	if (operation_mode) {
-		if (!atomic_cmpxchg(
-			&axi_ctrl->share_ctrl->pix0_update_ack_pending,
-				0, 1))
-			reg_update |= 0x1;
-	}
-
-	msm_camera_io_w_mb(reg_update,
-			axi_ctrl->share_ctrl->vfebase +
-			VFE_REG_UPDATE_CMD);
-	axi_ctrl->share_ctrl->operation_mode |=
-		axi_ctrl->share_ctrl->current_mode;
-	axi_enable_irq(axi_ctrl->share_ctrl);
-}
-
-void axi_stop(struct msm_cam_media_controller *pmctl,
-	struct axi_ctrl_t *axi_ctrl, struct msm_camera_vfe_params_t vfe_params)
-{
-	uint32_t reg_update = 0;
-	uint32_t operation_mode =
-	axi_ctrl->share_ctrl->current_mode & ~(VFE_OUTPUTS_RDI0|
-		VFE_OUTPUTS_RDI1);
-
-	switch (vfe_params.cmd_type) {
-	case AXI_CMD_PREVIEW:
-	case AXI_CMD_CAPTURE:
-	case AXI_CMD_RAW_CAPTURE:
-	case AXI_CMD_ZSL:
-		break;
-	case AXI_CMD_RECORD:
-		msm_camera_bus_scale_cfg(axi_ctrl->bus_perf_client, S_PREVIEW);
-		return;
-	case AXI_CMD_LIVESHOT:
-		msm_camera_bus_scale_cfg(axi_ctrl->bus_perf_client, S_VIDEO);
-		return;
-	default:
-		return;
-	}
-
-	if (axi_ctrl->share_ctrl->stop_immediately) {
-		axi_disable_irq(axi_ctrl->share_ctrl);
-		axi_stop_process(axi_ctrl->share_ctrl);
-		return;
-	}
-
-	if (axi_ctrl->share_ctrl->current_mode & VFE_OUTPUTS_RDI0) {
-		if (!atomic_cmpxchg(
-			&axi_ctrl->share_ctrl->rdi0_update_ack_pending, 0, 2))
-			reg_update |= 0x2;
-	}
-	if (axi_ctrl->share_ctrl->current_mode & VFE_OUTPUTS_RDI1) {
-		if (!atomic_cmpxchg(
-			&axi_ctrl->share_ctrl->rdi1_update_ack_pending, 0, 2))
-			reg_update |= 0x4;
-	}
-	if (operation_mode) {
-		if (!atomic_cmpxchg(
-			&axi_ctrl->share_ctrl->pix0_update_ack_pending, 0, 2))
-			reg_update |= 0x1;
-	}
-	msm_camera_io_w_mb(reg_update,
-		axi_ctrl->share_ctrl->vfebase + VFE_REG_UPDATE_CMD);
-}
-
-static int msm_axi_config(struct v4l2_subdev *sd, void __user *arg)
-{
-	struct msm_vfe_cfg_cmd cfgcmd;
-	struct msm_isp_cmd vfecmd;
-	struct axi_ctrl_t *axi_ctrl = v4l2_get_subdevdata(sd);
-	struct msm_cam_media_controller *pmctl =
-		(struct msm_cam_media_controller *)v4l2_get_subdev_hostdata(sd);
-	int rc = 0, vfe_cmd_type = 0, rdi_mode = 0;
-
-	if (!axi_ctrl->share_ctrl->vfebase) {
-		pr_err("%s: base address unmapped\n", __func__);
-		return -EFAULT;
-	}
-	memset(&cfgcmd, 0, sizeof(struct msm_vfe_cfg_cmd));
-	if (NULL != arg) {
-		if (copy_from_user(&cfgcmd, arg, sizeof(cfgcmd))) {
-			ERR_COPY_FROM_USER();
-			return -EFAULT;
-		}
-	}
-	memset(&vfecmd, 0, sizeof(struct msm_isp_cmd));
-	if (NULL != cfgcmd.value) {
-		if (copy_from_user(&vfecmd,
-				(void __user *)(cfgcmd.value),
-				sizeof(vfecmd))) {
-			pr_err("%s %d: copy_from_user failed\n", __func__,
-				__LINE__);
-			return -EFAULT;
-		}
-	}
-
-	vfe_cmd_type = (cfgcmd.cmd_type & ~(CMD_AXI_CFG_TERT1|
-		CMD_AXI_CFG_TERT2));
-	switch (cfgcmd.cmd_type) {
-	case CMD_AXI_CFG_TERT1:{
-		uint32_t *axio = NULL;
-		axio = kmalloc(vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio)
-			return -ENOMEM;
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			return -EFAULT;
-		}
-		vfe40_config_axi(axi_ctrl, OUTPUT_TERT1, axio);
-		kfree(axio);
-		return rc;
-		}
-	case CMD_AXI_CFG_TERT2:{
-		uint32_t *axio = NULL;
-		axio = kmalloc(vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio)
-			return -ENOMEM;
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			return -EFAULT;
-		}
-		vfe40_config_axi(axi_ctrl, OUTPUT_TERT2, axio);
-		kfree(axio);
-		return rc;
-		}
-	case CMD_AXI_CFG_TERT1|CMD_AXI_CFG_TERT2:{
-		uint32_t *axio = NULL;
-		axio = kmalloc(vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio)
-			return -ENOMEM;
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			return -EFAULT;
-		}
-		vfe40_config_axi(axi_ctrl, OUTPUT_TERT1|OUTPUT_TERT2, axio);
-		kfree(axio);
-		return rc;
-		}
-	default:
-		if (cfgcmd.cmd_type & CMD_AXI_CFG_TERT1)
-			rdi_mode |= OUTPUT_TERT1;
-		if (cfgcmd.cmd_type & CMD_AXI_CFG_TERT2)
-			rdi_mode |= OUTPUT_TERT2;
-	}
-	switch (vfe_cmd_type) {
-	case CMD_AXI_CFG_PRIM: {
-		uint32_t *axio = NULL;
-		axio = kmalloc(vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			break;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			rc = -EFAULT;
-			break;
-		}
-		vfe40_config_axi(axi_ctrl, rdi_mode|OUTPUT_PRIM, axio);
-		kfree(axio);
-		break;
-		}
-	case CMD_AXI_CFG_PRIM_ALL_CHNLS: {
-		uint32_t *axio = NULL;
-		axio = kmalloc(vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			break;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			rc = -EFAULT;
-			break;
-		}
-		vfe40_config_axi(axi_ctrl, rdi_mode|OUTPUT_PRIM_ALL_CHNLS,
-			axio);
-		kfree(axio);
-		break;
-		}
-	case CMD_AXI_CFG_PRIM|CMD_AXI_CFG_SEC: {
-		uint32_t *axio = NULL;
-		axio = kmalloc(vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			break;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			rc = -EFAULT;
-			break;
-		}
-		vfe40_config_axi(axi_ctrl,
-			rdi_mode|OUTPUT_PRIM|OUTPUT_SEC, axio);
-		kfree(axio);
-		break;
-		}
-	case CMD_AXI_CFG_PRIM|CMD_AXI_CFG_SEC_ALL_CHNLS: {
-		uint32_t *axio = NULL;
-		axio = kmalloc(vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			break;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			rc = -EFAULT;
-			break;
-		}
-		vfe40_config_axi(axi_ctrl,
-			rdi_mode|OUTPUT_PRIM|OUTPUT_SEC_ALL_CHNLS, axio);
-		kfree(axio);
-		break;
-		}
-	case CMD_AXI_CFG_PRIM_ALL_CHNLS|CMD_AXI_CFG_SEC: {
-		uint32_t *axio = NULL;
-		axio = kmalloc(vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			break;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			rc = -EFAULT;
-			break;
-		}
-		vfe40_config_axi(axi_ctrl,
-			rdi_mode|OUTPUT_PRIM_ALL_CHNLS|OUTPUT_SEC, axio);
-		kfree(axio);
-		break;
-		}
-
-	case CMD_AXI_CFG_PRIM_ALL_CHNLS|CMD_AXI_CFG_SEC_ALL_CHNLS:
-		pr_err("%s Invalid/Unsupported AXI configuration %x",
-			__func__, cfgcmd.cmd_type);
-		break;
-	case CMD_AXI_START: {
-		struct msm_camera_vfe_params_t vfe_params;
-		if (copy_from_user(&vfe_params,
-				(void __user *)(vfecmd.value),
-				sizeof(struct msm_camera_vfe_params_t))) {
-				return -EFAULT;
-		}
-		axi_ctrl->share_ctrl->current_mode =
-			vfe_params.operation_mode;
-		axi_start(pmctl, axi_ctrl, vfe_params);
-		}
-		break;
-	case CMD_AXI_STOP: {
-		struct msm_camera_vfe_params_t vfe_params;
-		if (copy_from_user(&vfe_params,
-				(void __user *)(vfecmd.value),
-				sizeof(struct msm_camera_vfe_params_t))) {
-				return -EFAULT;
-		}
-		axi_ctrl->share_ctrl->current_mode =
-			vfe_params.operation_mode;
-		axi_ctrl->share_ctrl->stop_immediately =
-			vfe_params.stop_immediately;
-		axi_stop(pmctl, axi_ctrl, vfe_params);
-		}
-		break;
-	case CMD_AXI_RESET:
-		axi_reset(axi_ctrl);
-		break;
-	case CMD_AXI_ABORT:
-		if (copy_from_user(&axi_ctrl->share_ctrl->sync_abort,
-				(void __user *)(vfecmd.value),
-				sizeof(uint8_t))) {
-				return -EFAULT;
-		}
-		axi_abort(axi_ctrl);
-		break;
-	default:
-		pr_err("%s Unsupported AXI configuration %x ", __func__,
-			cfgcmd.cmd_type);
-		break;
-	}
-	return rc;
-}
-
-static void msm_axi_process_irq(struct v4l2_subdev *sd, void *arg)
-{
-	struct axi_ctrl_t *axi_ctrl = v4l2_get_subdevdata(sd);
-	uint32_t irqstatus = (uint32_t) arg;
-
-	if (!axi_ctrl->share_ctrl->vfebase) {
-		pr_err("%s: base address unmapped\n", __func__);
-		return;
-	}
-
-	/* next, check output path related interrupts. */
-	if (irqstatus &
-		VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE0_MASK) {
-		CDBG("Image composite done 0 irq occured.\n");
-		vfe40_process_output_path_irq_0(axi_ctrl);
-	}
-	if (irqstatus &
-		VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE1_MASK) {
-		CDBG("Image composite done 1 irq occured.\n");
-		vfe40_process_output_path_irq_1(axi_ctrl);
-	}
-
-	if (axi_ctrl->share_ctrl->comp_output_mode &
-		VFE40_OUTPUT_MODE_TERTIARY1)
-		if (irqstatus & (0x1 << (axi_ctrl->share_ctrl->outpath.out2.ch0
-			+ VFE_WM_OFFSET)))
-			vfe40_process_output_path_irq_rdi0(axi_ctrl);
-	if (axi_ctrl->share_ctrl->comp_output_mode &
-		VFE40_OUTPUT_MODE_TERTIARY2)
-		if (irqstatus & (0x1 << (axi_ctrl->share_ctrl->outpath.out3.ch0
-			+ VFE_WM_OFFSET)))
-			vfe40_process_output_path_irq_rdi1(axi_ctrl);
-
-	/* in snapshot mode if done then send
-	snapshot done message */
-	if (
-		axi_ctrl->share_ctrl->operation_mode &
-			VFE_OUTPUTS_THUMB_AND_MAIN ||
-		axi_ctrl->share_ctrl->operation_mode &
-			VFE_OUTPUTS_MAIN_AND_THUMB ||
-		axi_ctrl->share_ctrl->operation_mode &
-			VFE_OUTPUTS_THUMB_AND_JPEG ||
-		axi_ctrl->share_ctrl->operation_mode &
-			VFE_OUTPUTS_JPEG_AND_THUMB ||
-		axi_ctrl->share_ctrl->operation_mode &
-			VFE_OUTPUTS_RAW) {
-		if ((axi_ctrl->share_ctrl->outpath.out0.capture_cnt == 0)
-				&& (axi_ctrl->share_ctrl->outpath.out1.
-				capture_cnt == 0)) {
-			msm_camera_io_w_mb(
-				CAMIF_COMMAND_STOP_IMMEDIATELY,
-				axi_ctrl->share_ctrl->vfebase +
-				VFE_CAMIF_COMMAND);
-			axi_disable_irq(axi_ctrl->share_ctrl);
-			vfe40_send_isp_msg(&axi_ctrl->subdev,
-				axi_ctrl->share_ctrl->vfeFrameId,
-				MSG_ID_PIX0_UPDATE_ACK);
-			vfe40_send_isp_msg(&axi_ctrl->subdev,
-				axi_ctrl->share_ctrl->vfeFrameId,
-				MSG_ID_SNAPSHOT_DONE);
-		}
-	}
-}
-
-static int msm_axi_buf_cfg(struct v4l2_subdev *sd, void __user *arg)
-{
-	struct msm_camvfe_params *vfe_params =
-		(struct msm_camvfe_params *)arg;
-	struct msm_vfe_cfg_cmd *cmd = vfe_params->vfe_cfg;
-	struct axi_ctrl_t *axi_ctrl = v4l2_get_subdevdata(sd);
-	void *data = vfe_params->data;
-	int rc = 0;
-
-	if (!axi_ctrl->share_ctrl->vfebase) {
-		pr_err("%s: base address unmapped\n", __func__);
-		return -EFAULT;
-	}
-
-	switch (cmd->cmd_type) {
-	case CMD_CONFIG_PING_ADDR: {
-		int path = *((int *)cmd->value);
-		struct vfe40_output_ch *outch =
-			vfe40_get_ch(path, axi_ctrl->share_ctrl);
-		outch->ping = *((struct msm_free_buf *)data);
-	}
-		break;
-
-	case CMD_CONFIG_PONG_ADDR: {
-		int path = *((int *)cmd->value);
-		struct vfe40_output_ch *outch =
-			vfe40_get_ch(path, axi_ctrl->share_ctrl);
-		outch->pong = *((struct msm_free_buf *)data);
-	}
-		break;
-
-	case CMD_CONFIG_FREE_BUF_ADDR: {
-		int path = *((int *)cmd->value);
-		struct vfe40_output_ch *outch =
-			vfe40_get_ch(path, axi_ctrl->share_ctrl);
-		outch->free_buf = *((struct msm_free_buf *)data);
-	}
-		break;
-	default:
-		pr_err("%s Unsupported AXI Buf config %x ", __func__,
-			cmd->cmd_type);
-	}
-	return rc;
-};
-
-static const struct v4l2_subdev_internal_ops msm_vfe_internal_ops;
-
-static long msm_axi_subdev_ioctl(struct v4l2_subdev *sd,
-			unsigned int cmd, void *arg)
-{
-	int rc = -ENOIOCTLCMD;
-	switch (cmd) {
-	case VIDIOC_MSM_AXI_INIT:
-		rc = msm_axi_subdev_init(sd);
-		break;
-	case VIDIOC_MSM_AXI_CFG:
-		rc = msm_axi_config(sd, arg);
-		break;
-	case VIDIOC_MSM_AXI_IRQ:
-		msm_axi_process_irq(sd, arg);
-		rc = 0;
-		break;
-	case VIDIOC_MSM_AXI_BUF_CFG:
-		msm_axi_buf_cfg(sd, arg);
-		rc = 0;
-		break;
-	case VIDIOC_MSM_AXI_RELEASE:
-		msm_axi_subdev_release(sd);
-		rc = 0;
-		break;
-	case VIDIOC_MSM_AXI_RDI_COUNT_UPDATE: {
-		struct rdi_count_msg *msg = (struct rdi_count_msg *)arg;
-		struct axi_ctrl_t *axi_ctrl = v4l2_get_subdevdata(sd);
-		switch (msg->rdi_interface) {
-		case RDI_0:
-			axi_ctrl->share_ctrl->rdi0FrameId = msg->count;
-			rc = 0;
-			break;
-		case RDI_1:
-			axi_ctrl->share_ctrl->rdi1FrameId = msg->count;
-			rc = 0;
-			break;
-		case RDI_2:
-			axi_ctrl->share_ctrl->rdi2FrameId = msg->count;
-			rc = 0;
-			break;
-		default:
-			pr_err("%s: Incorrect interface sent\n", __func__);
-			rc = -EINVAL;
-			break;
-		}
-		break;
-	}
-	default:
-		pr_err("%s: command %d not found\n", __func__,
-						_IOC_NR(cmd));
-		break;
-	}
-	return rc;
-}
-
-static const struct v4l2_subdev_core_ops msm_axi_subdev_core_ops = {
-	.ioctl = msm_axi_subdev_ioctl,
-	.interrupt_service_routine = msm_axi_subdev_isr_routine,
-};
-
-static const struct v4l2_subdev_video_ops msm_axi_subdev_video_ops = {
-	.s_crystal_freq = msm_axi_subdev_s_crystal_freq,
-};
-
-static const struct v4l2_subdev_ops msm_axi_subdev_ops = {
-	.core = &msm_axi_subdev_core_ops,
-	.video = &msm_axi_subdev_video_ops,
-};
-
-static const struct v4l2_subdev_internal_ops msm_axi_internal_ops;
-
-static int __devinit vfe40_probe(struct platform_device *pdev)
-{
-	int rc = 0;
-	struct axi_ctrl_t *axi_ctrl;
-	struct vfe40_ctrl_type *vfe40_ctrl;
-	struct vfe_share_ctrl_t *share_ctrl;
-	struct intr_table_entry irq_req;
-	struct msm_cam_subdev_info sd_info;
-	CDBG("%s: device id = %d\n", __func__, pdev->id);
-
-	share_ctrl = kzalloc(sizeof(struct vfe_share_ctrl_t), GFP_KERNEL);
-	if (!share_ctrl) {
-		pr_err("%s: no enough memory\n", __func__);
-		return -ENOMEM;
-	}
-
-	axi_ctrl = kzalloc(sizeof(struct axi_ctrl_t), GFP_KERNEL);
-	if (!axi_ctrl) {
-		pr_err("%s: no enough memory\n", __func__);
-		kfree(share_ctrl);
-		return -ENOMEM;
-	}
-
-	vfe40_ctrl = kzalloc(sizeof(struct vfe40_ctrl_type), GFP_KERNEL);
-	if (!vfe40_ctrl) {
-		pr_err("%s: no enough memory\n", __func__);
-		kfree(share_ctrl);
-		kfree(axi_ctrl);
-		return -ENOMEM;
-	}
-
-	if (pdev->dev.of_node)
-		of_property_read_u32((&pdev->dev)->of_node,
-			"cell-index", &pdev->id);
-
-	share_ctrl->axi_ctrl = axi_ctrl;
-	share_ctrl->vfe40_ctrl = vfe40_ctrl;
-	axi_ctrl->share_ctrl = share_ctrl;
-	vfe40_ctrl->share_ctrl = share_ctrl;
-	axi_ctrl->share_ctrl->axi_ref_cnt = 0;
-	v4l2_subdev_init(&axi_ctrl->subdev, &msm_axi_subdev_ops);
-	axi_ctrl->subdev.internal_ops = &msm_axi_internal_ops;
-	axi_ctrl->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	snprintf(axi_ctrl->subdev.name,
-			 sizeof(axi_ctrl->subdev.name), "axi");
-	v4l2_set_subdevdata(&axi_ctrl->subdev, axi_ctrl);
-	axi_ctrl->pdev = pdev;
-
-	sd_info.sdev_type = AXI_DEV;
-	sd_info.sd_index = pdev->id;
-	sd_info.irq_num = 0;
-	msm_cam_register_subdev_node(&axi_ctrl->subdev, &sd_info);
-
-	media_entity_init(&axi_ctrl->subdev.entity, 0, NULL, 0);
-	axi_ctrl->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
-	axi_ctrl->subdev.entity.group_id = AXI_DEV;
-	axi_ctrl->subdev.entity.name = pdev->name;
-	axi_ctrl->subdev.entity.revision = axi_ctrl->subdev.devnode->num;
-
-	v4l2_subdev_init(&vfe40_ctrl->subdev, &msm_vfe_subdev_ops);
-	vfe40_ctrl->subdev.internal_ops = &msm_vfe_internal_ops;
-	vfe40_ctrl->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	snprintf(vfe40_ctrl->subdev.name,
-			 sizeof(vfe40_ctrl->subdev.name), "vfe4.0");
-	v4l2_set_subdevdata(&vfe40_ctrl->subdev, vfe40_ctrl);
-	platform_set_drvdata(pdev, &vfe40_ctrl->subdev);
-
-	axi_ctrl->vfemem = platform_get_resource_byname(pdev,
-					IORESOURCE_MEM, "vfe");
-	if (!axi_ctrl->vfemem) {
-		pr_err("%s: no mem resource?\n", __func__);
-		rc = -ENODEV;
-		goto vfe40_no_resource;
-	}
-
-	axi_ctrl->vfe_vbif_mem = platform_get_resource_byname(pdev,
-					IORESOURCE_MEM, "vfe_vbif");
-	if (!axi_ctrl->vfe_vbif_mem) {
-		pr_err("%s: no mem resource?\n", __func__);
-		rc = -ENODEV;
-		goto vfe40_no_resource;
-	}
-
-	axi_ctrl->vfeirq = platform_get_resource_byname(pdev,
-					IORESOURCE_IRQ, "vfe");
-	if (!axi_ctrl->vfeirq) {
-		pr_err("%s: no irq resource?\n", __func__);
-		rc = -ENODEV;
-		goto vfe40_no_resource;
-	}
-
-	axi_ctrl->vfeio = request_mem_region(axi_ctrl->vfemem->start,
-		resource_size(axi_ctrl->vfemem), pdev->name);
-	if (!axi_ctrl->vfeio) {
-		pr_err("%s: no valid mem region\n", __func__);
-		rc = -EBUSY;
-		goto vfe40_no_resource;
-	}
-
-	axi_ctrl->fs_vfe = regulator_get(&pdev->dev, "vdd");
-	if (IS_ERR(axi_ctrl->fs_vfe)) {
-		pr_err("%s: Regulator get failed %ld\n", __func__,
-			PTR_ERR(axi_ctrl->fs_vfe));
-		axi_ctrl->fs_vfe = NULL;
-	}
-
-	/* Register subdev node before requesting irq since
-	 * irq_num is needed by msm_cam_server */
-	sd_info.sdev_type = VFE_DEV;
-	sd_info.sd_index = pdev->id;
-	sd_info.irq_num = axi_ctrl->vfeirq->start;
-	msm_cam_register_subdev_node(&vfe40_ctrl->subdev, &sd_info);
-
-	media_entity_init(&vfe40_ctrl->subdev.entity, 0, NULL, 0);
-	vfe40_ctrl->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
-	vfe40_ctrl->subdev.entity.group_id = VFE_DEV;
-	vfe40_ctrl->subdev.entity.name = pdev->name;
-	vfe40_ctrl->subdev.entity.revision = vfe40_ctrl->subdev.devnode->num;
-
-	/* Request for this device irq from the camera server. If the
-	 * IRQ Router is present on this target, the interrupt will be
-	 * handled by the camera server and the interrupt service
-	 * routine called. If the request_irq call returns ENXIO, then
-	 * the IRQ Router hardware is not present on this target. We
-	 * have to request for the irq ourselves and register the
-	 * appropriate interrupt handler. */
-	axi_ctrl->use_irq_router = true;
-	irq_req.cam_hw_idx       = MSM_CAM_HW_VFE0 + pdev->id;
-	irq_req.dev_name         = "vfe";
-	irq_req.irq_idx          = CAMERA_SS_IRQ_8;
-	irq_req.irq_num          = axi_ctrl->vfeirq->start;
-	irq_req.is_composite     = 0;
-	irq_req.irq_trigger_type = IRQF_TRIGGER_RISING;
-	irq_req.num_hwcore       = 1;
-	irq_req.subdev_list[0]   = &axi_ctrl->subdev;
-	irq_req.data             = (void *)axi_ctrl;
-	rc = msm_cam_server_request_irq(&irq_req);
-	if (rc == -ENXIO) {
-		/* IRQ Router hardware is not present on this hardware.
-		 * Request for the IRQ and register the interrupt handler. */
-		axi_ctrl->use_irq_router = false;
-		rc = request_irq(axi_ctrl->vfeirq->start, vfe40_parse_irq,
-			IRQF_TRIGGER_RISING, "vfe", axi_ctrl);
-		if (rc < 0) {
-			release_mem_region(axi_ctrl->vfemem->start,
-				resource_size(axi_ctrl->vfemem));
-			pr_err("%s: irq request fail\n", __func__);
-			rc = -EBUSY;
-			goto vfe40_no_resource;
-		}
-		disable_irq(axi_ctrl->vfeirq->start);
-	} else if (rc < 0) {
-		pr_err("%s Error registering irq ", __func__);
-		goto vfe40_no_resource;
-	}
-
-	/*get device context for IOMMU*/
-	if (pdev->id == 0)
-		axi_ctrl->iommu_ctx = msm_iommu_get_ctx("vfe0");
-	else if (pdev->id == 1)
-		axi_ctrl->iommu_ctx = msm_iommu_get_ctx("vfe1");
-	if (!axi_ctrl->iommu_ctx) {
-		release_mem_region(axi_ctrl->vfemem->start,
-			resource_size(axi_ctrl->vfemem));
-		pr_err("%s: No iommu fw context found\n", __func__);
-		rc = -ENODEV;
-		goto vfe40_no_resource;
-	}
-
-	tasklet_init(&axi_ctrl->vfe40_tasklet,
-		axi40_do_tasklet, (unsigned long)axi_ctrl);
-
-	vfe40_ctrl->pdev = pdev;
-	/*enable bayer stats by default*/
-	vfe40_ctrl->ver_num.main = 4;
-
-	return 0;
-
-vfe40_no_resource:
-	kfree(vfe40_ctrl);
-	kfree(axi_ctrl);
-	return 0;
-}
-
-static const struct of_device_id msm_vfe_dt_match[] = {
-	{.compatible = "qcom,vfe40"},
-};
-
-MODULE_DEVICE_TABLE(of, msm_vfe_dt_match);
-
-static struct platform_driver vfe40_driver = {
-	.probe = vfe40_probe,
-	.driver = {
-		.name = MSM_VFE_DRV_NAME,
-		.owner = THIS_MODULE,
-		.of_match_table = msm_vfe_dt_match,
-	},
-};
-
-static int __init msm_vfe40_init_module(void)
-{
-	return platform_driver_register(&vfe40_driver);
-}
-
-static void __exit msm_vfe40_exit_module(void)
-{
-	platform_driver_unregister(&vfe40_driver);
-}
-
-module_init(msm_vfe40_init_module);
-module_exit(msm_vfe40_exit_module);
-MODULE_DESCRIPTION("VFE 4.0 driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe40.h b/drivers/media/platform/msm/camera_v1/vfe/msm_vfe40.h
deleted file mode 100644
index 2b32203..0000000
--- a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe40.h
+++ /dev/null
@@ -1,1063 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#ifndef __MSM_VFE40_H__
-#define __MSM_VFE40_H__
-
-#include <linux/bitops.h>
-#include "msm_vfe_stats_buf.h"
-
-#define TRUE  1
-#define FALSE 0
-
-#define VFE40_HW_NUMBER 0x10000015
-
-/* This defines total number registers in VFE.
- * Each register is 4 bytes so to get the range,
- * multiply this number with 4. */
-#define VFE40_REGISTER_TOTAL 0x00000320
-
-/* at stop of vfe pipeline, for now it is assumed
- * that camif will stop at any time. Bit 1:0 = 0x10:
- * disable image data capture immediately. */
-#define CAMIF_COMMAND_STOP_IMMEDIATELY  0x00000002
-
-/* at stop of vfe pipeline, for now it is assumed
- * that camif will stop at any time. Bit 1:0 = 0x00:
- * disable image data capture at frame boundary */
-#define CAMIF_COMMAND_STOP_AT_FRAME_BOUNDARY  0x00000000
-
-/* to halt axi bridge */
-#define AXI_HALT  0x00000001
-
-/* clear the halt bit. */
-#define AXI_HALT_CLEAR  0x00000000
-
-/* reset the pipeline when stop command is issued.
- * (without reset the register.) bit 26-32 = 0,
- * domain reset, bit 0-9 = 1 for module reset, except
- * register module. */
-#define VFE_RESET_UPON_STOP_CMD  0x000003ef
-
-/* reset the pipeline when reset command.
- * bit 26-32 = 0, domain reset, bit 0-9 = 1 for module reset. */
-#define VFE_RESET_UPON_RESET_CMD  0x000003ff
-
-/* reset the vfe only when reset command*/
-#define VFE_ONLY_RESET_CMD  0x00000002
-
-/*Vfe module reset command*/
-#define VFE_MODULE_RESET_CMD 0x07ffffff
-
-/* wm bit offset for IRQ MASK and IRQ STATUS register */
-#define VFE_WM_OFFSET 6
-
-/* constants for irq registers */
-#define VFE_DISABLE_ALL_IRQS 0
-/* bit =1 is to clear the corresponding bit in VFE_IRQ_STATUS.  */
-#define VFE_CLEAR_ALL_IRQ0   0xffff7fff
-#define VFE_CLEAR_ALL_IRQ1   0xffffffff
-
-#define VFE_IRQ_STATUS0_CAMIF_SOF_MASK            (0x00000001<<0)
-#define VFE_IRQ_STATUS0_REG_UPDATE_MASK           (0x00000001<<4)
-#define VFE_IRQ_STATUS0_RDI0_REG_UPDATE_MASK      (0x00000001<<5)
-#define VFE_IRQ_STATUS0_RDI1_REG_UPDATE_MASK      (0x00000001<<6)
-#define VFE_IRQ_STATUS0_RDI2_REG_UPDATE_MASK      (0x00000001<<7)
-#define VFE_IRQ_STATUS0_STATS_BE                  (0x00000001<<16)
-#define VFE_IRQ_STATUS0_STATS_BG                  (0x00000001<<17)
-#define VFE_IRQ_STATUS0_STATS_BF                  (0x00000001<<18)
-#define VFE_IRQ_STATUS0_STATS_AWB                 (0x00000001<<19)
-#define VFE_IRQ_STATUS0_STATS_RS                  (0x00000001<<20)
-#define VFE_IRQ_STATUS0_STATS_CS                  (0x00000001<<21)
-#define VFE_IRQ_STATUS0_STATS_IHIST               (0x00000001<<22)
-#define VFE_IRQ_STATUS0_STATS_SKIN_BHIST          (0x00000001<<23)
-#define VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE0_MASK (0x00000001<<25)
-#define VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE1_MASK (0x00000001<<26)
-#define VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE2_MASK (0x00000001<<27)
-#define VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE3_MASK (0x00000001<<28)
-#define VFE_IRQ_STATUS0_STATS_COMPOSIT_MASK_0     (0x00000001<<29)
-#define VFE_IRQ_STATUS0_STATS_COMPOSIT_MASK_1     (0x00000001<<30)
-#define VFE_IRQ_STATUS0_RESET_AXI_HALT_ACK_MASK   (0x00000001<<31)
-
-#define VFE_IRQ_STATUS1_SYNC_TIMER0               (0x00000001<<25)
-#define VFE_IRQ_STATUS1_SYNC_TIMER1               (0x00000001<<26)
-#define VFE_IRQ_STATUS1_SYNC_TIMER2               (0x00000001<<27)
-#define VFE_IRQ_STATUS1_ASYNC_TIMER0              (0x00000001<<28)
-#define VFE_IRQ_STATUS1_ASYNC_TIMER1              (0x00000001<<29)
-#define VFE_IRQ_STATUS1_ASYNC_TIMER2              (0x00000001<<30)
-#define VFE_IRQ_STATUS1_ASYNC_TIMER3              (0x00000001<<31)
-
-/*TODOs the irq status passed from axi to vfe irq handler does not account
-* for 2 irq status registers. So below macro is added to differentiate between
-* same bit set on both irq status registers. This wil be fixed later by passing
-*entire payload to vfe irq handler and parsing there instead of passing just the
-*status bit*/
-
-#define VFE_IRQ_STATUS0_RDI0_REG_UPDATE  VFE_IRQ_STATUS0_RDI0_REG_UPDATE_MASK
-#define VFE_IRQ_STATUS0_RDI1_REG_UPDATE  VFE_IRQ_STATUS0_RDI1_REG_UPDATE_MASK
-
-/* imask for while waiting for stop ack,  driver has already
- * requested stop, waiting for reset irq, and async timer irq.
- * For irq_status_1, bit 28-32 are for async timer. For
- * irq_status_0, bit 31 for reset irq, bit 23 for axi_halt_ack
-   irq */
-#define VFE_IMASK_WHILE_STOPPING_0  0x80000000
-#define VFE_IMASK_WHILE_STOPPING_1  0xF0000000
-
-/* For ABF bit 4 is set to zero and other's 1 */
-#define ABF_MASK 0xFFFFFFF7
-
-/* For DBPC bit 0 is set to zero and other's 1 */
-#define DBPC_MASK 0xFFFFFFFE
-
-/* For DBPC bit 1 is set to zero and other's 1 */
-#define DBCC_MASK 0xFFFFFFFD
-
-/* For DBPC/ABF/DBCC/ABCC bits are set to 1 all others 0 */
-#define DEMOSAIC_MASK 0xF
-
-/* For MCE enable bit 28 set to zero and other's 1 */
-#define MCE_EN_MASK 0xEFFFFFFF
-
-/* For MCE Q_K bit 28 to 32 set to zero and other's 1 */
-#define MCE_Q_K_MASK 0x0FFFFFFF
-
-#define BE_ENABLE_MASK    (0x00000001<<5)
-#define BG_ENABLE_MASK    (0x00000001<<6)
-#define BF_ENABLE_MASK    (0x00000001<<7)
-#define AWB_ENABLE_MASK   (0x00000001<<8)
-#define RS_ENABLE_MASK    (0x00000001<<9)
-#define CS_ENABLE_MASK    (0x00000001<<10)
-#define CLF_ENABLE_MASK   (0x00000001<<12)
-#define IHIST_ENABLE_MASK (0x00000001<<15)
-#define BHIST_ENABLE_MASK (0x00000001<<18)
-#define RS_CS_ENABLE_MASK (RS_ENABLE_MASK|CS_ENABLE_MASK)
-#define STATS_ENABLE_MASK 0x000487E0   /* bit 18,15,10,9,8,7,6,5*/
-
-#define STATS_BHIST_ENABLE_MASK (0x00000001<<1)
-
-#define VFE_DMI_CFG_DEFAULT              0x00000100
-
-#define HFR_MODE_OFF 1
-#define VFE_FRAME_SKIP_PERIOD_MASK 0x0000001F /*bits 0 -4*/
-
-enum VFE40_DMI_RAM_SEL {
-	NO_MEM_SELECTED          = 0,
-	BLACK_LUT_RAM_BANK0      = 0x1,
-	BLACK_LUT_RAM_BANK1      = 0x2,
-	ROLLOFF_RAM0_BANK0       = 0x3,
-	ROLLOFF_RAM0_BANK1       = 0x4,
-	DEMOSAIC_LUT_RAM_BANK0   = 0x5,
-	DEMOSAIC_LUT_RAM_BANK1   = 0x6,
-	STATS_BHIST_RAM0         = 0x7,
-	STATS_BHIST_RAM1         = 0x8,
-	RGBLUT_RAM_CH0_BANK0     = 0x9,
-	RGBLUT_RAM_CH0_BANK1     = 0xa,
-	RGBLUT_RAM_CH1_BANK0     = 0xb,
-	RGBLUT_RAM_CH1_BANK1     = 0xc,
-	RGBLUT_RAM_CH2_BANK0     = 0xd,
-	RGBLUT_RAM_CH2_BANK1     = 0xe,
-	RGBLUT_CHX_BANK0         = 0xf,
-	RGBLUT_CHX_BANK1         = 0x10,
-	STATS_IHIST_RAM          = 0x11,
-	LUMA_ADAPT_LUT_RAM_BANK0 = 0x12,
-	LUMA_ADAPT_LUT_RAM_BANK1 = 0x13,
-};
-
-enum vfe_output_state {
-	VFE_STATE_IDLE,
-	VFE_STATE_START_REQUESTED,
-	VFE_STATE_STARTED,
-	VFE_STATE_STOP_REQUESTED,
-	VFE_STATE_STOPPED,
-};
-
-#define V40_CAMIF_OFF             0x000002F8
-#define V40_CAMIF_LEN             36
-
-#define V40_DEMUX_OFF             0x00000424
-#define V40_DEMUX_LEN             28
-
-#define V40_DEMOSAICV3_0_OFF      0x00000440
-#define V40_DEMOSAICV3_0_LEN      4
-#define V40_DEMOSAICV3_1_OFF      0x00000518
-#define V40_DEMOSAICV3_1_LEN      88
-#define V40_DEMOSAICV3_2_OFF      0x00000568
-#define V40_DEMOSAICV3_UP_REG_CNT 5
-
-#define V40_OUT_CLAMP_OFF         0x00000874
-#define V40_OUT_CLAMP_LEN         16
-
-#define V40_OPERATION_CFG_LEN     32
-
-#define V40_AXI_BUS_CMD_OFF       0x0000004C
-#define V40_AXI_BUS_CFG_LEN       284
-#define V40_AXI_OUT_LEN           344
-#define V40_AXI_CFG_LEN           71
-
-#define V40_BUS_PM_CMD            0x00000270
-#define V40_FOV_ENC_OFF           0x00000854
-#define V40_FOV_ENC_LEN           16
-#define V40_FOV_VIEW_OFF          0x00000864
-#define V40_FOV_VIEW_LEN          16
-
-#define V40_SCALER_ENC_OFF 0x0000075C
-#define V40_SCALER_ENC_LEN 72
-
-#define V40_SCALER_VIEW_OFF 0x000007A4
-#define V40_SCALER_VIEW_LEN 72
-
-#define V40_COLORXFORM_ENC_CFG_OFF 0x0000071C
-#define V40_COLORXFORM_ENC_CFG_LEN 32
-
-#define V40_COLORXFORM_VIEW_CFG_OFF 0x0000073C
-#define V40_COLORXFORM_VIEW_CFG_LEN 32
-
-#define V40_CHROMA_EN_OFF 0x00000640
-#define V40_CHROMA_EN_LEN 36
-
-#define V40_SYNC_TIMER_OFF      0x00000324
-#define V40_SYNC_TIMER_POLARITY_OFF 0x0000034C
-#define V40_TIMER_SELECT_OFF        0x00000374
-#define V40_SYNC_TIMER_LEN 28
-
-#define V40_ASYNC_TIMER_OFF 0x00000350
-#define V40_ASYNC_TIMER_LEN 28
-
-/* use 10x13 mesh table in vfe40*/
-#define V40_MESH_ROLL_OFF_CFG_OFF             0x00000400
-#define V40_MESH_ROLL_OFF_CFG_LEN             36
-#define V40_MESH_ROLL_OFF_TABLE_SIZE          130
-
-#define V40_COLOR_COR_OFF 0x000005D0
-#define V40_COLOR_COR_LEN 52
-
-#define V40_WB_OFF 0x00000580
-#define V40_WB_LEN 4
-
-#define V40_RGB_G_OFF 0x00000638
-#define V40_RGB_G_LEN 4
-#define V40_GAMMA_LUT_BANK_SEL_MASK           0x00000007
-
-#define V40_LA_OFF 0x0000063C
-#define V40_LA_LEN 4
-
-#define V40_SCE_OFF 0x00000694
-#define V40_SCE_LEN 136
-
-#define V40_CHROMA_SUP_OFF 0x00000664
-#define V40_CHROMA_SUP_LEN 12
-
-#define V40_MCE_OFF 0x00000670
-#define V40_MCE_LEN 36
-
-#define V40_STATS_BE_OFF 0x0000088C
-#define V40_STATS_BE_LEN 12
-
-#define V40_STATS_BG_OFF 0x00000898
-#define V40_STATS_BG_LEN 12
-
-#define V40_STATS_BF_OFF 0x000008A4
-#define V40_STATS_BF_LEN 24
-
-#define V40_STATS_BHIST_OFF 0x000008BC
-#define V40_STATS_BHIST_LEN 8
-
-#define V40_STATS_AWB_OFF 0x000008C4
-#define V40_STATS_AWB_LEN 32
-
-#define V40_STATS_RS_OFF 0x000008E4
-#define V40_STATS_RS_LEN 8
-
-#define V40_STATS_CS_OFF 0x000008EC
-#define V40_STATS_CS_LEN 8
-
-#define V40_STATS_IHIST_OFF 0x000008F4
-#define V40_STATS_IHIST_LEN 8
-
-#define V40_STATS_SKIN_OFF 0x000008FC
-#define V40_STATS_SKIN_LEN 20
-
-#define V40_ASF_OFF 0x000007EC
-#define V40_ASF_LEN 48
-#define V40_ASF_UPDATE_LEN 36
-
-#define V40_CAPTURE_LEN 4
-
-#define V40_GET_HW_VERSION_OFF 0
-#define V40_GET_HW_VERSION_LEN 4
-
-#define V40_LINEARIZATION_OFF1 0x0000037C
-#define V40_LINEARIZATION_LEN1 68
-
-#define V40_DEMOSAICV3_DBPC_CFG_OFF  0x00000444
-#define V40_DEMOSAICV3_DBPC_LEN 4
-
-#define V40_DEMOSAICV3_DBPC_CFG_OFF0 0x00000448
-#define V40_DEMOSAICV3_DBPC_CFG_OFF1 0x0000044C
-#define V40_DEMOSAICV3_DBPC_CFG_OFF2 0x00000450
-
-#define V40_DEMOSAICV3_DBCC_OFF 0x00000454
-#define V40_DEMOSAICV3_DBCC_LEN 16
-
-#define V40_DEMOSAICV3_ABF_OFF 0x00000464
-#define V40_DEMOSAICV3_ABF_LEN 180
-
-#define V40_MODULE_CFG_OFF 0x00000018
-#define V40_MODULE_CFG_LEN 4
-
-#define V40_ASF_SPECIAL_EFX_CFG_OFF 0x0000081C
-#define V40_ASF_SPECIAL_EFX_CFG_LEN 4
-
-#define V40_CLF_CFG_OFF 0x00000588
-#define V40_CLF_CFG_LEN 72
-
-#define V40_CLF_LUMA_UPDATE_OFF 0x0000058C
-#define V40_CLF_LUMA_UPDATE_LEN 60
-
-#define V40_CLF_CHROMA_UPDATE_OFF 0x000005C8
-#define V40_CLF_CHROMA_UPDATE_LEN 8
-
-#define VFE40_GAMMA_NUM_ENTRIES  64
-
-#define VFE40_LA_TABLE_LENGTH    64
-
-#define VFE40_LINEARIZATON_TABLE_LENGTH    36
-
-struct vfe_cmd_hw_version {
-	uint32_t minorVersion;
-	uint32_t majorVersion;
-	uint32_t coreVersion;
-};
-
-enum VFE_AXI_OUTPUT_MODE {
-	VFE_AXI_OUTPUT_MODE_Output1,
-	VFE_AXI_OUTPUT_MODE_Output2,
-	VFE_AXI_OUTPUT_MODE_Output1AndOutput2,
-	VFE_AXI_OUTPUT_MODE_CAMIFToAXIViaOutput2,
-	VFE_AXI_OUTPUT_MODE_Output2AndCAMIFToAXIViaOutput1,
-	VFE_AXI_OUTPUT_MODE_Output1AndCAMIFToAXIViaOutput2,
-	VFE_AXI_LAST_OUTPUT_MODE_ENUM
-};
-
-enum VFE_RAW_WR_PATH_SEL {
-	VFE_RAW_OUTPUT_DISABLED,
-	VFE_RAW_OUTPUT_ENC_CBCR_PATH,
-	VFE_RAW_OUTPUT_VIEW_CBCR_PATH,
-	VFE_RAW_OUTPUT_PATH_INVALID
-};
-
-
-#define VFE_AXI_OUTPUT_BURST_LENGTH     4
-#define VFE_MAX_NUM_FRAGMENTS_PER_FRAME 4
-#define VFE_AXI_OUTPUT_CFG_FRAME_COUNT  3
-
-struct vfe_cmds_per_write_master {
-	uint16_t imageWidth;
-	uint16_t imageHeight;
-	uint16_t outRowCount;
-	uint16_t outRowIncrement;
-	uint32_t outFragments[VFE_AXI_OUTPUT_CFG_FRAME_COUNT]
-		[VFE_MAX_NUM_FRAGMENTS_PER_FRAME];
-};
-
-struct vfe_cmds_axi_per_output_path {
-	uint8_t fragmentCount;
-	struct vfe_cmds_per_write_master firstWM;
-	struct vfe_cmds_per_write_master secondWM;
-};
-
-enum VFE_AXI_BURST_LENGTH {
-	VFE_AXI_BURST_LENGTH_IS_2  = 2,
-	VFE_AXI_BURST_LENGTH_IS_4  = 4,
-	VFE_AXI_BURST_LENGTH_IS_8  = 8,
-	VFE_AXI_BURST_LENGTH_IS_16 = 16
-};
-
-
-struct vfe_cmd_fov_crop_config {
-	uint8_t enable;
-	uint16_t firstPixel;
-	uint16_t lastPixel;
-	uint16_t firstLine;
-	uint16_t lastLine;
-};
-
-struct vfe_cmds_main_scaler_stripe_init {
-	uint16_t MNCounterInit;
-	uint16_t phaseInit;
-};
-
-struct vfe_cmds_scaler_one_dimension {
-	uint8_t  enable;
-	uint16_t inputSize;
-	uint16_t outputSize;
-	uint32_t phaseMultiplicationFactor;
-	uint8_t  interpolationResolution;
-};
-
-struct vfe_cmd_main_scaler_config {
-	uint8_t enable;
-	struct vfe_cmds_scaler_one_dimension    hconfig;
-	struct vfe_cmds_scaler_one_dimension    vconfig;
-	struct vfe_cmds_main_scaler_stripe_init MNInitH;
-	struct vfe_cmds_main_scaler_stripe_init MNInitV;
-};
-
-struct vfe_cmd_scaler2_config {
-	uint8_t enable;
-	struct vfe_cmds_scaler_one_dimension hconfig;
-	struct vfe_cmds_scaler_one_dimension vconfig;
-};
-
-
-struct vfe_cmd_frame_skip_update {
-	uint32_t output1Pattern;
-	uint32_t output2Pattern;
-};
-
-struct vfe_cmd_output_clamp_config {
-	uint8_t minCh0;
-	uint8_t minCh1;
-	uint8_t minCh2;
-	uint8_t maxCh0;
-	uint8_t maxCh1;
-	uint8_t maxCh2;
-};
-
-struct vfe_cmd_chroma_subsample_config {
-	uint8_t enable;
-	uint8_t cropEnable;
-	uint8_t vsubSampleEnable;
-	uint8_t hsubSampleEnable;
-	uint8_t vCosited;
-	uint8_t hCosited;
-	uint8_t vCositedPhase;
-	uint8_t hCositedPhase;
-	uint16_t cropWidthFirstPixel;
-	uint16_t cropWidthLastPixel;
-	uint16_t cropHeightFirstLine;
-	uint16_t cropHeightLastLine;
-};
-
-enum VFE_START_PIXEL_PATTERN {
-	VFE_BAYER_RGRGRG,
-	VFE_BAYER_GRGRGR,
-	VFE_BAYER_BGBGBG,
-	VFE_BAYER_GBGBGB,
-	VFE_YUV_YCbYCr,
-	VFE_YUV_YCrYCb,
-	VFE_YUV_CbYCrY,
-	VFE_YUV_CrYCbY
-};
-
-enum VFE_BUS_RD_INPUT_PIXEL_PATTERN {
-	VFE_BAYER_RAW,
-	VFE_YUV_INTERLEAVED,
-	VFE_YUV_PSEUDO_PLANAR_Y,
-	VFE_YUV_PSEUDO_PLANAR_CBCR
-};
-
-enum VFE_YUV_INPUT_COSITING_MODE {
-	VFE_YUV_COSITED,
-	VFE_YUV_INTERPOLATED
-};
-
-struct vfe_cmds_demosaic_abf {
-	uint8_t   enable;
-	uint8_t   forceOn;
-	uint8_t   shift;
-	uint16_t  lpThreshold;
-	uint16_t  max;
-	uint16_t  min;
-	uint8_t   ratio;
-};
-
-struct vfe_cmds_demosaic_bpc {
-	uint8_t   enable;
-	uint16_t  fmaxThreshold;
-	uint16_t  fminThreshold;
-	uint16_t  redDiffThreshold;
-	uint16_t  blueDiffThreshold;
-	uint16_t  greenDiffThreshold;
-};
-
-struct vfe_cmd_demosaic_config {
-	uint8_t   enable;
-	uint8_t   slopeShift;
-	struct vfe_cmds_demosaic_abf abfConfig;
-	struct vfe_cmds_demosaic_bpc bpcConfig;
-};
-
-struct vfe_cmd_demosaic_bpc_update {
-	struct vfe_cmds_demosaic_bpc bpcUpdate;
-};
-
-struct vfe_cmd_demosaic_abf_update {
-	struct vfe_cmds_demosaic_abf abfUpdate;
-};
-
-struct vfe_cmd_white_balance_config {
-	uint8_t  enable;
-	uint16_t ch2Gain;
-	uint16_t ch1Gain;
-	uint16_t ch0Gain;
-};
-
-enum VFE_COLOR_CORRECTION_COEF_QFACTOR {
-	COEF_IS_Q7_SIGNED,
-	COEF_IS_Q8_SIGNED,
-	COEF_IS_Q9_SIGNED,
-	COEF_IS_Q10_SIGNED
-};
-
-struct vfe_cmd_color_correction_config {
-	uint8_t     enable;
-	enum VFE_COLOR_CORRECTION_COEF_QFACTOR coefQFactor;
-	int16_t  C0;
-	int16_t  C1;
-	int16_t  C2;
-	int16_t  C3;
-	int16_t  C4;
-	int16_t  C5;
-	int16_t  C6;
-	int16_t  C7;
-	int16_t  C8;
-	int16_t  K0;
-	int16_t  K1;
-	int16_t  K2;
-};
-
-#define VFE_LA_TABLE_LENGTH 64
-
-struct vfe_cmd_la_config {
-	uint8_t enable;
-	int16_t table[VFE_LA_TABLE_LENGTH];
-};
-
-#define VFE_GAMMA_TABLE_LENGTH 256
-enum VFE_RGB_GAMMA_TABLE_SELECT {
-	RGB_GAMMA_CH0_SELECTED,
-	RGB_GAMMA_CH1_SELECTED,
-	RGB_GAMMA_CH2_SELECTED,
-	RGB_GAMMA_CH0_CH1_SELECTED,
-	RGB_GAMMA_CH0_CH2_SELECTED,
-	RGB_GAMMA_CH1_CH2_SELECTED,
-	RGB_GAMMA_CH0_CH1_CH2_SELECTED
-};
-
-struct vfe_cmd_rgb_gamma_config {
-	uint8_t enable;
-	enum VFE_RGB_GAMMA_TABLE_SELECT channelSelect;
-	int16_t table[VFE_GAMMA_TABLE_LENGTH];
-};
-
-struct vfe_cmd_chroma_enhan_config {
-	uint8_t  enable;
-	int16_t am;
-	int16_t ap;
-	int16_t bm;
-	int16_t bp;
-	int16_t cm;
-	int16_t cp;
-	int16_t dm;
-	int16_t dp;
-	int16_t kcr;
-	int16_t kcb;
-	int16_t RGBtoYConversionV0;
-	int16_t RGBtoYConversionV1;
-	int16_t RGBtoYConversionV2;
-	uint8_t RGBtoYConversionOffset;
-};
-
-struct vfe_cmd_chroma_suppression_config {
-	uint8_t enable;
-	uint8_t m1;
-	uint8_t m3;
-	uint8_t n1;
-	uint8_t n3;
-	uint8_t nn1;
-	uint8_t mm1;
-};
-
-struct vfe_cmd_asf_config {
-	uint8_t enable;
-	uint8_t smoothFilterEnabled;
-	uint8_t sharpMode;
-	uint8_t smoothCoefCenter;
-	uint8_t smoothCoefSurr;
-	uint8_t normalizeFactor;
-	uint8_t sharpK1;
-	uint8_t sharpK2;
-	uint8_t sharpThreshE1;
-	int8_t sharpThreshE2;
-	int8_t sharpThreshE3;
-	int8_t sharpThreshE4;
-	int8_t sharpThreshE5;
-	int8_t filter1Coefficients[9];
-	int8_t filter2Coefficients[9];
-	uint8_t  cropEnable;
-	uint16_t cropFirstPixel;
-	uint16_t cropLastPixel;
-	uint16_t cropFirstLine;
-	uint16_t cropLastLine;
-};
-
-struct vfe_cmd_asf_update {
-	uint8_t enable;
-	uint8_t smoothFilterEnabled;
-	uint8_t sharpMode;
-	uint8_t smoothCoefCenter;
-	uint8_t smoothCoefSurr;
-	uint8_t normalizeFactor;
-	uint8_t sharpK1;
-	uint8_t sharpK2;
-	uint8_t sharpThreshE1;
-	int8_t  sharpThreshE2;
-	int8_t  sharpThreshE3;
-	int8_t  sharpThreshE4;
-	int8_t  sharpThreshE5;
-	int8_t  filter1Coefficients[9];
-	int8_t  filter2Coefficients[9];
-	uint8_t cropEnable;
-};
-
-enum VFE_TEST_GEN_SYNC_EDGE {
-	VFE_TEST_GEN_SYNC_EDGE_ActiveHigh,
-	VFE_TEST_GEN_SYNC_EDGE_ActiveLow
-};
-
-
-struct vfe_cmd_bus_pm_start {
-	uint8_t output2YWrPmEnable;
-	uint8_t output2CbcrWrPmEnable;
-	uint8_t output1YWrPmEnable;
-	uint8_t output1CbcrWrPmEnable;
-};
-
-struct  vfe_frame_skip_counts {
-	uint32_t  totalFrameCount;
-	uint32_t  output1Count;
-	uint32_t  output2Count;
-};
-
-enum VFE_AXI_RD_UNPACK_HBI_SEL {
-	VFE_AXI_RD_HBI_32_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_64_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_128_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_256_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_512_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_1024_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_2048_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_4096_CLOCK_CYCLES
-};
-
-struct vfe_frame_bpc_info {
-	uint32_t greenDefectPixelCount;
-	uint32_t redBlueDefectPixelCount;
-};
-
-struct vfe_frame_asf_info {
-	uint32_t  asfMaxEdge;
-	uint32_t  asfHbiCount;
-};
-
-struct vfe_msg_camif_status {
-	uint8_t  camifState;
-	uint32_t pixelCount;
-	uint32_t lineCount;
-};
-
-struct vfe40_irq_status {
-	uint32_t vfeIrqStatus0;
-	uint32_t vfeIrqStatus1;
-	uint32_t camifStatus;
-	uint32_t demosaicStatus;
-	uint32_t asfMaxEdge;
-};
-
-#define V40_PREVIEW_AXI_FLAG  0x00000001
-#define V40_SNAPSHOT_AXI_FLAG (0x00000001<<1)
-
-struct vfe40_cmd_type {
-	uint16_t id;
-	uint32_t length;
-	uint32_t offset;
-	uint32_t flag;
-};
-
-struct vfe40_free_buf {
-	struct list_head node;
-	uint32_t paddr;
-	uint32_t y_off;
-	uint32_t cbcr_off;
-};
-
-struct vfe40_output_ch {
-	struct list_head free_buf_queue;
-	spinlock_t free_buf_lock;
-	uint32_t inst_handle;
-	int8_t ch0;
-	int8_t ch1;
-	int8_t ch2;
-	uint32_t  capture_cnt;
-	uint32_t  frame_drop_cnt;
-	struct msm_free_buf ping;
-	struct msm_free_buf pong;
-	struct msm_free_buf free_buf;
-};
-
-/* no error irq in mask 0 */
-#define VFE40_IMASK_ERROR_ONLY_0  0x0
-/* when normal case, don't want to block error status. */
-/* bit 0-21 are error irq bits */
-#define VFE40_IMASK_COMMON_ERROR_ONLY_1       0x0000FF00
-#define VFE40_IMASK_VFE_ERROR_ONLY_1          0x00FF01FF
-#define VFE40_IMASK_CAMIF_ERROR               (0x00000001<<0)
-#define VFE40_IMASK_BHIST_OVWR                (0x00000001<<1)
-#define VFE40_IMASK_STATS_CS_OVWR             (0x00000001<<2)
-#define VFE40_IMASK_STATS_IHIST_OVWR          (0x00000001<<3)
-#define VFE40_IMASK_REALIGN_BUF_Y_OVFL        (0x00000001<<4)
-#define VFE40_IMASK_REALIGN_BUF_CB_OVFL       (0x00000001<<5)
-#define VFE40_IMASK_REALIGN_BUF_CR_OVFL       (0x00000001<<6)
-#define VFE40_IMASK_VIOLATION                 (0x00000001<<7)
-#define VFE40_IMASK_BUS_BDG_HALT_ACK          (0x00000001<<8)
-#define VFE40_IMASK_IMG_MAST_0_BUS_OVFL       (0x00000001<<9)
-#define VFE40_IMASK_IMG_MAST_1_BUS_OVFL       (0x00000001<<10)
-#define VFE40_IMASK_IMG_MAST_2_BUS_OVFL       (0x00000001<<11)
-#define VFE40_IMASK_IMG_MAST_3_BUS_OVFL       (0x00000001<<12)
-#define VFE40_IMASK_IMG_MAST_4_BUS_OVFL       (0x00000001<<13)
-#define VFE40_IMASK_IMG_MAST_5_BUS_OVFL       (0x00000001<<14)
-#define VFE40_IMASK_IMG_MAST_6_BUS_OVFL       (0x00000001<<15)
-#define VFE40_IMASK_STATS_BE_BUS_OVFL         (0x00000001<<16)
-#define VFE40_IMASK_STATS_BG_BUS_OVFL         (0x00000001<<17)
-#define VFE40_IMASK_STATS_BF_BUS_OVFL         (0x00000001<<18)
-#define VFE40_IMASK_STATS_AWB_BUS_OVFL        (0x00000001<<19)
-#define VFE40_IMASK_STATS_RS_BUS_OVFL         (0x00000001<<10)
-#define VFE40_IMASK_STATS_CS_BUS_OVFL         (0x00000001<<21)
-#define VFE40_IMASK_STATS_IHIST_BUS_OVFL      (0x00000001<<22)
-#define VFE40_IMASK_STATS_SKIN_BHIST_BUS_OVFL (0x00000001<<23)
-
-#define VFE_COM_STATUS 0x000FE000
-
-struct vfe40_output_path {
-	uint16_t output_mode;     /* bitmask  */
-
-	struct vfe40_output_ch out0; /* preview and thumbnail */
-	struct vfe40_output_ch out1; /* snapshot */
-	struct vfe40_output_ch out2; /* rdi0    */
-	struct vfe40_output_ch out3; /* rdi01   */
-};
-
-struct vfe40_frame_extra {
-	uint32_t greenDefectPixelCount;
-	uint32_t redBlueDefectPixelCount;
-
-	uint32_t  asfMaxEdge;
-	uint32_t  asfHbiCount;
-
-	uint32_t yWrPmStats0;
-	uint32_t yWrPmStats1;
-	uint32_t cbcrWrPmStats0;
-	uint32_t cbcrWrPmStats1;
-
-	uint32_t  frameCounter;
-};
-
-#define VFE_HW_VERSION			0x00000000
-#define VFE_GLOBAL_RESET                0x0000000C
-#define VFE_MODULE_RESET                0x00000010
-#define VFE_CGC_OVERRIDE                0x00000014
-#define VFE_MODULE_CFG                  0x00000018
-#define VFE_CFG				            0x0000001C
-#define VFE_IRQ_CMD                     0x00000024
-#define VFE_IRQ_MASK_0                  0x00000028
-#define VFE_IRQ_MASK_1                  0x0000002C
-#define VFE_IRQ_CLEAR_0                 0x00000030
-#define VFE_IRQ_CLEAR_1                 0x00000034
-#define VFE_IRQ_STATUS_0                0x00000038
-#define VFE_IRQ_STATUS_1                0x0000003C
-#define VFE_IRQ_COMP_MASK               0x00000040
-#define VFE_BUS_CMD                     0x0000004C
-#define VFE_BUS_PING_PONG_STATUS        0x00000268
-#define VFE_AXI_CMD                     0x000002C0
-#define VFE_AXI_STATUS                  0x000002E4
-#define VFE_BUS_STATS_PING_PONG_BASE    0x00000168
-
-#define VFE_BUS_STATS_BE_WR_PING_ADDR    0x00000168
-#define VFE_BUS_STATS_BE_WR_PONG_ADDR    0x0000016C
-#define VFE_BUS_STATS_BE_WR_ADDR_CFG    0x00000170
-#define VFE_BUS_STATS_BE_WR_UB_CFG          0x00000174
-#define VFE_BUS_STATS_BE_WR_FRAMEDROP_PATTERN  0x00000178
-#define VFE_BUS_STATS_BE_WR_IRQ_SUBSAMPLE_PATTERN 0x0000017C
-
-#define VFE_BUS_STATS_BG_WR_PING_ADDR     0x00000180
-#define VFE_BUS_STATS_BG_WR_PONG_ADDR     0x00000184
-#define VFE_BUS_STATS_BG_WR_ADDR_CFG      0x00000188
-#define VFE_BUS_STATS_BG_WR_UB_CFG        0x0000018C
-#define VFE_BUS_STATS_BG_WR_FRAMEDROP_PATTERN 0x00000190
-#define VFE_BUS_STATS_BG_WR_IRQ_SUBSAMPLE_PATTERN 0x00000194
-
-#define VFE_BUS_STATS_BF_WR_PING_ADDR     0x00000198
-#define VFE_BUS_STATS_BF_WR_PONG_ADDR     0x0000019C
-#define VFE_BUS_STATS_BF_WR_ADDR_CFG      0x000001A0
-#define VFE_BUS_STATS_BF_WR_UB_CFG        0x000001A4
-#define VFE_BUS_STATS_BF_WR_FRAMEDROP_PATTERN  0x000001A8
-#define VFE_BUS_STATS_BF_WR_IRQ_SUBSAMPLE_PATTERN  0x000001AC
-
-#define VFE_BUS_STATS_AWB_WR_PING_ADDR    0x000001B0
-#define VFE_BUS_STATS_AWB_WR_PONG_ADDR    0x000001B4
-#define VFE_BUS_STATS_AWB_WR_ADDR_CFG     0x000001B8
-#define VFE_BUS_STATS_AWB_WR_UB_CFG       0x000001BC
-#define VFE_BUS_STATS_AWB_WR_FRAMEDROP_PATTERN  0x000001C0
-#define VFE_BUS_STATS_AWB_WR_IRQ_SUBSAMPLE_PATTERN  0x000001C4
-
-#define VFE_BUS_STATS_RS_WR_PING_ADDR     0x000001C8
-#define VFE_BUS_STATS_RS_WR_PONG_ADDR     0x000001CC
-#define VFE_BUS_STATS_RS_WR_ADDR_CFG      0x000001D0
-#define VFE_BUS_STATS_RS_WR_UB_CFG    0x000001D4
-#define VFE_BUS_STATS_RS_WR_FRAMEDROP_PATTERN      0x000001D8
-#define VFE_BUS_STATS_RS_WR_IRQ_SUBSAMPLE_PATTERN  0x000001DC
-
-#define VFE_BUS_STATS_CS_WR_PING_ADDR     0x000001E0
-#define VFE_BUS_STATS_CS_WR_PONG_ADDR     0x000001E4
-#define VFE_BUS_STATS_CS_WR_ADDR_CFG      0x000001E8
-#define VFE_BUS_STATS_CS_WR_UB_CFG        0x000001EC
-#define VFE_BUS_STATS_CS_WR_FRAMEDROP_PATTERN     0x000001F0
-#define VFE_BUS_STATS_CS_WR_IRQ_SUBSAMPLE_PATTERN 0x000001F4
-
-#define VFE_BUS_STATS_HIST_WR_PING_ADDR   0x000001F8
-#define VFE_BUS_STATS_HIST_WR_PONG_ADDR   0x000001FC
-#define VFE_BUS_STATS_HIST_WR_ADDR_CFG    0x00000200
-#define VFE_BUS_STATS_HIST_WR_UB_CFG      0x00000204
-#define VFE_BUS_STATS_HIST_WR_FRAMEDROP_PATTERN      0x00000208
-#define VFE_BUS_STATS_HIST_WR_IRQ_SUBSAMPLE_PATTERN  0x0000020C
-
-
-#define VFE_BUS_STATS_SKIN_WR_PING_ADDR   0x00000210
-#define VFE_BUS_STATS_SKIN_WR_PONG_ADDR   0x00000214
-#define VFE_BUS_STATS_SKIN_WR_ADDR_CFG    0x00000218
-#define VFE_BUS_STATS_SKIN_WR_UB_CFG      0x0000021C
-#define VFE_BUS_STATS_SKIN_WR_FRAMEDROP_PATTERN       0x00000220
-#define VFE_BUS_STATS_SKIN_WR_IRQ_SUBSAMPLE_PATTERN   0x00000224
-
-#define VFE_0_BUS_BDG_QOS_CFG_0     0x000002C4
-#define VFE_0_BUS_BDG_QOS_CFG_1     0x000002C8
-#define VFE_0_BUS_BDG_QOS_CFG_2     0x000002CC
-#define VFE_0_BUS_BDG_QOS_CFG_3     0x000002D0
-#define VFE_0_BUS_BDG_QOS_CFG_4     0x000002D4
-#define VFE_0_BUS_BDG_QOS_CFG_5     0x000002D8
-#define VFE_0_BUS_BDG_QOS_CFG_6     0x000002DC
-#define VFE_0_BUS_BDG_QOS_CFG_7     0x000002E0
-
-#define VFE_CAMIF_COMMAND               0x000002F4
-#define VFE_CAMIF_STATUS                0x0000031C
-#define VFE_REG_UPDATE_CMD              0x00000378
-#define VFE_DEMUX_GAIN_0                0x00000428
-#define VFE_DEMUX_GAIN_1                0x0000042C
-#define VFE_CHROMA_UP                   0x0000057C
-
-#define VFE_CLAMP_ENC_MAX               0x00000874
-#define VFE_CLAMP_ENC_MIN               0x00000878
-#define VFE_CLAMP_VIEW_MAX              0x0000087C
-#define VFE_CLAMP_VIEW_MIN              0x00000880
-
-#define VFE_REALIGN_BUF                 0x00000884
-#define VFE_STATS_CFG                   0x00000888
-#define VFE_STATS_AWB_SGW_CFG           0x000008CC
-#define VFE_DMI_CFG                     0x00000910
-#define VFE_DMI_ADDR                    0x00000914
-#define VFE_DMI_DATA_HI                 0x00000918
-#define VFE_DMI_DATA_LO                 0x0000091C
-#define VFE_BUS_IO_FORMAT_CFG           0x00000054
-#define VFE_RDI0_CFG                    0x000002E8
-#define VFE_RDI1_CFG                    0x000002EC
-#define VFE_RDI2_CFG                    0x000002F0
-
-#define VFE_VIOLATION_STATUS            0x00000048
-
-#define VFE40_DMI_DATA_HI               0x00000918
-#define VFE40_DMI_DATA_LO               0x0000091C
-
-#define VFE40_OUTPUT_MODE_PT			BIT(0)
-#define VFE40_OUTPUT_MODE_S			BIT(1)
-#define VFE40_OUTPUT_MODE_V			BIT(2)
-#define VFE40_OUTPUT_MODE_P			BIT(3)
-#define VFE40_OUTPUT_MODE_T			BIT(4)
-#define VFE40_OUTPUT_MODE_P_ALL_CHNLS		BIT(5)
-#define VFE40_OUTPUT_MODE_PRIMARY		BIT(6)
-#define VFE40_OUTPUT_MODE_PRIMARY_ALL_CHNLS	BIT(7)
-#define VFE40_OUTPUT_MODE_SECONDARY		BIT(8)
-#define VFE40_OUTPUT_MODE_SECONDARY_ALL_CHNLS	BIT(9)
-#define VFE40_OUTPUT_MODE_TERTIARY1		BIT(10)
-#define VFE40_OUTPUT_MODE_TERTIARY2		BIT(11)
-
-#define VFE40_VBIF_CLKON					0x4
-#define VFE40_VBIF_IN_RD_LIM_CONF0			0xB0
-#define VFE40_VBIF_IN_RD_LIM_CONF1			0xB4
-#define VFE40_VBIF_IN_RD_LIM_CONF2			0xB8
-#define VFE40_VBIF_IN_WR_LIM_CONF0			0xC0
-#define VFE40_VBIF_IN_WR_LIM_CONF1			0xC4
-#define VFE40_VBIF_IN_WR_LIM_CONF2			0xC8
-#define VFE40_VBIF_OUT_RD_LIM_CONF0			0xD0
-#define VFE40_VBIF_OUT_WR_LIM_CONF0			0xD4
-#define VFE40_VBIF_DDR_OUT_MAX_BURST		0xD8
-#define VFE40_VBIF_OCMEM_OUT_MAX_BURST		0xDC
-#define VFE40_VBIF_ARB_CTL					0xF0
-#define VFE40_VBIF_DDR_ARB_CONF0			0xF4
-#define VFE40_VBIF_DDR_ARB_CONF1			0xF8
-#define VFE40_VBIF_ROUND_ROBIN_QOS_ARB		0x124
-#define VFE40_VBIF_OUT_AXI_AMEMTYPE_CONF0	0x160
-#define VFE40_VBIF_OUT_AXI_AMEMTYPE_CONF1	0x164
-#define VFE40_VBIF_OUT_AXI_AOOO_EN			0x178
-#define VFE40_VBIF_OUT_AXI_AOOO				0x17C
-
-struct vfe_stats_control {
-	uint32_t droppedStatsFrameCount;
-	uint32_t bufToRender;
-};
-struct axi_ctrl_t;
-struct vfe40_ctrl_type;
-
-struct vfe_share_ctrl_t {
-	void __iomem *vfebase;
-	void __iomem *vfe_vbif_base;
-	uint32_t register_total;
-
-	atomic_t vstate;
-	atomic_t handle_common_irq;
-	uint32_t vfeFrameId;
-	uint32_t rdi0FrameId;
-	uint32_t rdi1FrameId;
-	uint32_t rdi2FrameId;
-	uint32_t stats_comp;
-	spinlock_t  sd_notify_lock;
-	spinlock_t  stop_flag_lock;
-	int8_t stop_ack_pending;
-	enum vfe_output_state liveshot_state;
-	uint32_t vfe_capture_count;
-
-	uint32_t operation_mode;     /* streaming or snapshot */
-	uint32_t current_mode;
-	struct vfe40_output_path outpath;
-
-	uint16_t port_info;
-	uint8_t stop_immediately;
-	uint8_t sync_abort;
-	uint16_t cmd_type;
-	uint8_t vfe_reset_flag;
-
-	uint8_t axi_ref_cnt;
-	uint16_t comp_output_mode;
-
-	struct completion reset_complete;
-
-	spinlock_t  update_ack_lock;
-	spinlock_t  start_ack_lock;
-
-	struct axi_ctrl_t *axi_ctrl;
-	struct vfe40_ctrl_type *vfe40_ctrl;
-	int8_t start_ack_pending;
-	int8_t update_ack_pending;
-	enum vfe_output_state recording_state;
-
-	atomic_t pix0_update_ack_pending;
-	atomic_t rdi0_update_ack_pending;
-	atomic_t rdi1_update_ack_pending;
-	atomic_t rdi2_update_ack_pending;
-};
-
-struct axi_ctrl_t {
-	struct v4l2_subdev subdev;
-	struct platform_device *pdev;
-	struct resource *vfeirq;
-	spinlock_t  tasklet_lock;
-	struct list_head tasklet_q;
-
-	void *syncdata;
-
-	struct resource	*vfemem;
-	struct resource	*vfe_vbif_mem;
-	struct resource *vfeio;
-	struct resource *vfe_vbif_io;
-	struct regulator *fs_vfe;
-	struct clk *vfe_clk[7];
-	struct tasklet_struct vfe40_tasklet;
-	struct vfe_share_ctrl_t *share_ctrl;
-	struct device *iommu_ctx;
-	uint32_t bus_perf_client;
-	uint32_t use_irq_router;
-};
-
-struct vfe40_ctrl_type {
-	spinlock_t  state_lock;
-	spinlock_t  stats_bufq_lock;
-	uint32_t extlen;
-	void *extdata;
-
-	int8_t vfe_sof_count_enable;
-	int8_t update_linear;
-	int8_t update_rolloff;
-	int8_t update_la;
-	int8_t update_gamma;
-
-	struct vfe_share_ctrl_t *share_ctrl;
-
-	uint32_t sync_timer_repeat_count;
-	uint32_t sync_timer_state;
-	uint32_t sync_timer_number;
-
-	struct msm_ver_num_info ver_num;
-	struct vfe_stats_control beStatsControl;
-	struct vfe_stats_control bfStatsControl;
-	struct vfe_stats_control awbStatsControl;
-	struct vfe_stats_control bgStatsControl;
-	struct vfe_stats_control ihistStatsControl;
-	struct vfe_stats_control rsStatsControl;
-	struct vfe_stats_control csStatsControl;
-	struct vfe_stats_control bhistStatsControl;
-
-	/* v4l2 subdev */
-	struct v4l2_subdev subdev;
-	struct platform_device *pdev;
-	uint32_t hfr_mode;
-	uint32_t frame_skip_cnt;
-	uint32_t frame_skip_pattern;
-	uint32_t snapshot_frame_cnt;
-	struct msm_stats_bufq_ctrl stats_ctrl;
-	struct msm_stats_ops stats_ops;
-
-	uint32_t simultaneous_sof_stat;
-};
-
-#define statsBeNum      0
-#define statsBgNum      1
-#define statsBfNum      2
-#define statsAwbNum     3
-#define statsRsNum      4
-#define statsCsNum      5
-#define statsIhistNum   6
-#define statsSkinNum    7
-
-#define VFE_STATS_BUS_REG_NUM  6
-
-struct vfe_cmd_stats_ack {
-	uint32_t  nextStatsBuf;
-};
-
-#define VFE_STATS_BUFFER_COUNT            3
-
-struct vfe_cmd_stats_buf {
-	uint32_t statsBuf[VFE_STATS_BUFFER_COUNT];
-};
-
-#endif /* __MSM_VFE40_H__ */
diff --git a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe40_axi.c b/drivers/media/platform/msm/camera_v1/vfe/msm_vfe40_axi.c
deleted file mode 100644
index 88a219c..0000000
--- a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe40_axi.c
+++ /dev/null
@@ -1,824 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#include <linux/module.h>
-#include <linux/uaccess.h>
-#include <linux/interrupt.h>
-#include <linux/slab.h>
-#include <linux/io.h>
-#include <linux/atomic.h>
-#include <linux/regulator/consumer.h>
-#include <linux/clk.h>
-#include <mach/irqs.h>
-#include <mach/camera.h>
-#include <media/v4l2-device.h>
-#include <media/v4l2-subdev.h>
-#include <media/msm_isp.h>
-
-#include "msm.h"
-#include "msm_vfe40.h"
-
-static int msm_axi_subdev_s_crystal_freq(struct v4l2_subdev *sd,
-						u32 freq, u32 flags)
-{
-	int rc = 0;
-	int round_rate;
-	struct axi_ctrl_t *axi_ctrl = v4l2_get_subdevdata(sd);
-
-	round_rate = clk_round_rate(axi_ctrl->vfe_clk[0], freq);
-	if (rc < 0) {
-		pr_err("%s: clk_round_rate failed %d\n",
-					__func__, rc);
-		return rc;
-	}
-
-	axi_ctrl->share_ctrl->vfe_clk_rate = round_rate;
-	rc = clk_set_rate(axi_ctrl->vfe_clk[0], round_rate);
-	if (rc < 0)
-		pr_err("%s: clk_set_rate failed %d\n",
-					__func__, rc);
-
-	return rc;
-}
-
-void axi_start(struct axi_ctrl_t *axi_ctrl)
-{
-	switch (axi_ctrl->share_ctrl->operation_mode) {
-	case VFE_OUTPUTS_PREVIEW:
-	case VFE_OUTPUTS_PREVIEW_AND_VIDEO:
-		if (axi_ctrl->share_ctrl->outpath.output_mode &
-			VFE40_OUTPUT_MODE_PRIMARY) {
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out0.ch0]);
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out0.ch1]);
-		} else if (axi_ctrl->share_ctrl->outpath.output_mode &
-				VFE40_OUTPUT_MODE_PRIMARY_ALL_CHNLS) {
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out0.ch0]);
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out0.ch1]);
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out0.ch2]);
-		}
-		break;
-	default:
-		if (axi_ctrl->share_ctrl->outpath.output_mode &
-			VFE40_OUTPUT_MODE_SECONDARY) {
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out1.ch0]);
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out1.ch1]);
-		} else if (axi_ctrl->share_ctrl->outpath.output_mode &
-			VFE40_OUTPUT_MODE_SECONDARY_ALL_CHNLS) {
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out1.ch0]);
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out1.ch1]);
-			msm_camera_io_w(1, axi_ctrl->share_ctrl->vfebase +
-				vfe40_AXI_WM_CFG[axi_ctrl->
-				share_ctrl->outpath.out1.ch2]);
-		}
-		break;
-	}
-}
-
-void axi_stop(struct axi_ctrl_t *axi_ctrl)
-{
-	uint8_t  axiBusyFlag = true;
-	/* axi halt command. */
-	msm_camera_io_w(AXI_HALT,
-		axi_ctrl->share_ctrl->vfebase + VFE_AXI_CMD);
-	wmb();
-	while (axiBusyFlag) {
-		if (msm_camera_io_r(
-			axi_ctrl->share_ctrl->vfebase + VFE_AXI_STATUS) & 0x1)
-			axiBusyFlag = false;
-	}
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(AXI_HALT_CLEAR,
-		axi_ctrl->share_ctrl->vfebase + VFE_AXI_CMD);
-
-	/* after axi halt, then ok to apply global reset. */
-	/* enable reset_ack and async timer interrupt only while
-	stopping the pipeline.*/
-	msm_camera_io_w(0xf0000000,
-		axi_ctrl->share_ctrl->vfebase + VFE_IRQ_MASK_0);
-	msm_camera_io_w(VFE_IMASK_WHILE_STOPPING_1,
-		axi_ctrl->share_ctrl->vfebase + VFE_IRQ_MASK_1);
-
-	/* Ensure the write order while writing
-	to the command register using the barrier */
-	msm_camera_io_w_mb(VFE_RESET_UPON_STOP_CMD,
-		axi_ctrl->share_ctrl->vfebase + VFE_GLOBAL_RESET);
-}
-
-static int vfe40_config_axi(
-	struct axi_ctrl_t *axi_ctrl, int mode, uint32_t *ao)
-{
-	uint32_t *ch_info;
-	uint32_t *axi_cfg = ao;
-
-	/* Update the corresponding write masters for each output*/
-	ch_info = axi_cfg + V40_AXI_CFG_LEN;
-	axi_ctrl->share_ctrl->outpath.out0.ch0 = 0x0000FFFF & *ch_info;
-	axi_ctrl->share_ctrl->outpath.out0.ch1 =
-		0x0000FFFF & (*ch_info++ >> 16);
-	axi_ctrl->share_ctrl->outpath.out0.ch2 = 0x0000FFFF & *ch_info;
-	axi_ctrl->share_ctrl->outpath.out0.image_mode =
-		0x0000FFFF & (*ch_info++ >> 16);
-	axi_ctrl->share_ctrl->outpath.out1.ch0 = 0x0000FFFF & *ch_info;
-	axi_ctrl->share_ctrl->outpath.out1.ch1 =
-		0x0000FFFF & (*ch_info++ >> 16);
-	axi_ctrl->share_ctrl->outpath.out1.ch2 = 0x0000FFFF & *ch_info;
-	axi_ctrl->share_ctrl->outpath.out1.image_mode =
-		0x0000FFFF & (*ch_info++ >> 16);
-	axi_ctrl->share_ctrl->outpath.out2.ch0 = 0x0000FFFF & *ch_info;
-	axi_ctrl->share_ctrl->outpath.out2.ch1 =
-		0x0000FFFF & (*ch_info++ >> 16);
-	axi_ctrl->share_ctrl->outpath.out2.ch2 = 0x0000FFFF & *ch_info++;
-
-	switch (mode) {
-	case OUTPUT_PRIM:
-		axi_ctrl->share_ctrl->outpath.output_mode =
-			VFE40_OUTPUT_MODE_PRIMARY;
-		break;
-	case OUTPUT_PRIM_ALL_CHNLS:
-		axi_ctrl->share_ctrl->outpath.output_mode =
-			VFE40_OUTPUT_MODE_PRIMARY_ALL_CHNLS;
-		break;
-	case OUTPUT_PRIM|OUTPUT_SEC:
-		axi_ctrl->share_ctrl->outpath.output_mode =
-			VFE40_OUTPUT_MODE_PRIMARY;
-		axi_ctrl->share_ctrl->outpath.output_mode |=
-			VFE40_OUTPUT_MODE_SECONDARY;
-		break;
-	case OUTPUT_PRIM|OUTPUT_SEC_ALL_CHNLS:
-		axi_ctrl->share_ctrl->outpath.output_mode =
-			VFE40_OUTPUT_MODE_PRIMARY;
-		axi_ctrl->share_ctrl->outpath.output_mode |=
-			VFE40_OUTPUT_MODE_SECONDARY_ALL_CHNLS;
-		break;
-	case OUTPUT_PRIM_ALL_CHNLS|OUTPUT_SEC:
-		axi_ctrl->share_ctrl->outpath.output_mode =
-			VFE40_OUTPUT_MODE_PRIMARY_ALL_CHNLS;
-		axi_ctrl->share_ctrl->outpath.output_mode |=
-			VFE40_OUTPUT_MODE_SECONDARY;
-		break;
-	default:
-		pr_err("%s Invalid AXI mode %d ", __func__, mode);
-		return -EINVAL;
-	}
-	msm_camera_io_w(*ao, axi_ctrl->share_ctrl->vfebase +
-		VFE_BUS_IO_FORMAT_CFG);
-	msm_camera_io_memcpy(axi_ctrl->share_ctrl->vfebase +
-		vfe40_cmd[VFE_CMD_AXI_OUT_CFG].offset, axi_cfg,
-		vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length - V40_AXI_CH_INF_LEN);
-	msm_camera_io_w(*ch_info++,
-		axi_ctrl->share_ctrl->vfebase + VFE_RDI0_CFG);
-	if (msm_camera_io_r(axi_ctrl->share_ctrl->vfebase +
-		V40_GET_HW_VERSION_OFF) ==
-		VFE40_HW_NUMBER) {
-		msm_camera_io_w(*ch_info++,
-			axi_ctrl->share_ctrl->vfebase + VFE_RDI1_CFG);
-		msm_camera_io_w(*ch_info++,
-			axi_ctrl->share_ctrl->vfebase + VFE_RDI2_CFG);
-	}
-	return 0;
-}
-
-static int msm_axi_config(struct v4l2_subdev *sd, void __user *arg)
-{
-	struct msm_vfe_cfg_cmd cfgcmd;
-	struct msm_isp_cmd vfecmd;
-	int rc = 0;
-	struct axi_ctrl_t *axi_ctrl = v4l2_get_subdevdata(sd);
-
-	if (!axi_ctrl->share_ctrl->vfebase) {
-		pr_err("%s: base address unmapped\n", __func__);
-		return -EFAULT;
-	}
-	if (NULL != arg) {
-		if (copy_from_user(&cfgcmd, arg, sizeof(cfgcmd))) {
-			ERR_COPY_FROM_USER();
-			return -EFAULT;
-		}
-	}
-	if (NULL != cfgcmd.value) {
-		if (copy_from_user(&vfecmd,
-				(void __user *)(cfgcmd.value),
-				sizeof(vfecmd))) {
-			pr_err("%s %d: copy_from_user failed\n", __func__,
-				__LINE__);
-			return -EFAULT;
-		}
-	}
-
-	switch (cfgcmd.cmd_type) {
-	case CMD_AXI_CFG_PRIM: {
-		uint32_t *axio = NULL;
-		axio = kmalloc(vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			break;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			rc = -EFAULT;
-			break;
-		}
-		vfe40_config_axi(axi_ctrl, OUTPUT_PRIM, axio);
-		kfree(axio);
-	}
-		break;
-	case CMD_AXI_CFG_PRIM_ALL_CHNLS: {
-		uint32_t *axio = NULL;
-		axio = kmalloc(vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			break;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			rc = -EFAULT;
-			break;
-		}
-		vfe40_config_axi(axi_ctrl, OUTPUT_PRIM_ALL_CHNLS, axio);
-		kfree(axio);
-	}
-		break;
-	case CMD_AXI_CFG_PRIM|CMD_AXI_CFG_SEC: {
-		uint32_t *axio = NULL;
-		axio = kmalloc(vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			break;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			rc = -EFAULT;
-			break;
-		}
-		vfe40_config_axi(axi_ctrl, OUTPUT_PRIM|OUTPUT_SEC, axio);
-		kfree(axio);
-	}
-		break;
-	case CMD_AXI_CFG_PRIM|CMD_AXI_CFG_SEC_ALL_CHNLS: {
-		uint32_t *axio = NULL;
-		axio = kmalloc(vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			break;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			rc = -EFAULT;
-			break;
-		}
-		vfe40_config_axi(axi_ctrl,
-			OUTPUT_PRIM|OUTPUT_SEC_ALL_CHNLS, axio);
-		kfree(axio);
-	}
-		break;
-	case CMD_AXI_CFG_PRIM_ALL_CHNLS|CMD_AXI_CFG_SEC: {
-		uint32_t *axio = NULL;
-		axio = kmalloc(vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length,
-				GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			break;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd.value),
-				vfe40_cmd[VFE_CMD_AXI_OUT_CFG].length)) {
-			kfree(axio);
-			rc = -EFAULT;
-			break;
-		}
-		vfe40_config_axi(axi_ctrl,
-			OUTPUT_PRIM_ALL_CHNLS|OUTPUT_SEC, axio);
-		kfree(axio);
-	}
-		break;
-	case CMD_AXI_CFG_PRIM_ALL_CHNLS|CMD_AXI_CFG_SEC_ALL_CHNLS:
-		pr_err("%s Invalid/Unsupported AXI configuration %x",
-			__func__, cfgcmd.cmd_type);
-		break;
-	case CMD_AXI_START:
-		axi_start(axi_ctrl);
-		break;
-	case CMD_AXI_STOP:
-		axi_stop(axi_ctrl);
-		break;
-	case CMD_AXI_RESET:
-		break;
-	default:
-		pr_err("%s Unsupported AXI configuration %x ", __func__,
-			cfgcmd.cmd_type);
-		break;
-	}
-	return rc;
-}
-
-static struct msm_free_buf *vfe40_check_free_buffer(
-	int id, int path, struct axi_ctrl_t *axi_ctrl)
-{
-	struct vfe40_output_ch *outch = NULL;
-	struct msm_free_buf *b = NULL;
-	uint32_t image_mode = 0;
-
-	if (path == VFE_MSG_OUTPUT_PRIMARY)
-		image_mode = axi_ctrl->share_ctrl->outpath.out0.image_mode;
-	else
-		image_mode = axi_ctrl->share_ctrl->outpath.out1.image_mode;
-
-	vfe40_subdev_notify(id, path, image_mode,
-		&axi_ctrl->subdev, axi_ctrl->share_ctrl);
-	outch = vfe40_get_ch(path, axi_ctrl->share_ctrl);
-	if (outch->free_buf.ch_paddr[0])
-		b = &outch->free_buf;
-	return b;
-}
-
-static void vfe_send_outmsg(
-	struct axi_ctrl_t *axi_ctrl, uint8_t msgid,
-	uint32_t ch0_paddr, uint32_t ch1_paddr,
-	uint32_t ch2_paddr, uint32_t image_mode)
-{
-	struct isp_msg_output msg;
-
-	msg.output_id = msgid;
-	msg.buf.image_mode = image_mode;
-	msg.buf.ch_paddr[0]	= ch0_paddr;
-	msg.buf.ch_paddr[1]	= ch1_paddr;
-	msg.buf.ch_paddr[2]	= ch2_paddr;
-	msg.frameCounter = axi_ctrl->share_ctrl->vfeFrameId;
-
-	v4l2_subdev_notify(&axi_ctrl->subdev,
-			NOTIFY_VFE_MSG_OUT,
-			&msg);
-	return;
-}
-
-static void vfe40_process_output_path_irq_0(
-	struct axi_ctrl_t *axi_ctrl)
-{
-	uint32_t ping_pong;
-	uint32_t ch0_paddr, ch1_paddr, ch2_paddr;
-	uint8_t out_bool = 0;
-	struct msm_free_buf *free_buf = NULL;
-
-	free_buf = vfe40_check_free_buffer(VFE_MSG_OUTPUT_IRQ,
-		VFE_MSG_OUTPUT_PRIMARY, axi_ctrl);
-
-	/* we render frames in the following conditions:
-	1. Continuous mode and the free buffer is avaialable.
-	2. In snapshot shot mode, free buffer is not always available.
-	when pending snapshot count is <=1,  then no need to use
-	free buffer.
-	*/
-	out_bool = (
-		(axi_ctrl->share_ctrl->operation_mode ==
-			VFE_OUTPUTS_THUMB_AND_MAIN ||
-		axi_ctrl->share_ctrl->operation_mode ==
-			VFE_OUTPUTS_MAIN_AND_THUMB ||
-		axi_ctrl->share_ctrl->operation_mode ==
-			VFE_OUTPUTS_THUMB_AND_JPEG ||
-		axi_ctrl->share_ctrl->operation_mode ==
-			VFE_OUTPUTS_JPEG_AND_THUMB ||
-		axi_ctrl->share_ctrl->operation_mode ==
-			VFE_OUTPUTS_RAW ||
-		axi_ctrl->share_ctrl->liveshot_state ==
-			VFE_STATE_STARTED ||
-		axi_ctrl->share_ctrl->liveshot_state ==
-			VFE_STATE_STOP_REQUESTED ||
-		axi_ctrl->share_ctrl->liveshot_state ==
-			VFE_STATE_STOPPED) &&
-		(axi_ctrl->share_ctrl->vfe_capture_count <= 1)) ||
-			free_buf;
-
-	if (out_bool) {
-		ping_pong = msm_camera_io_r(axi_ctrl->share_ctrl->vfebase +
-			VFE_BUS_PING_PONG_STATUS);
-
-		/* Channel 0*/
-		ch0_paddr = vfe40_get_ch_addr(
-			ping_pong, axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out0.ch0);
-		/* Channel 1*/
-		ch1_paddr = vfe40_get_ch_addr(
-			ping_pong, axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out0.ch1);
-		/* Channel 2*/
-		ch2_paddr = vfe40_get_ch_addr(
-			ping_pong, axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out0.ch2);
-
-		CDBG("output path 0, ch0 = 0x%x, ch1 = 0x%x, ch2 = 0x%x\n",
-			ch0_paddr, ch1_paddr, ch2_paddr);
-		if (free_buf) {
-			/* Y channel */
-			vfe40_put_ch_addr(ping_pong,
-			axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out0.ch0,
-			free_buf->ch_paddr[0]);
-			/* Chroma channel */
-			vfe40_put_ch_addr(ping_pong,
-			axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out0.ch1,
-			free_buf->ch_paddr[1]);
-			if (free_buf->num_planes > 2)
-				vfe40_put_ch_addr(ping_pong,
-					axi_ctrl->share_ctrl->vfebase,
-					axi_ctrl->share_ctrl->outpath.out0.ch2,
-					free_buf->ch_paddr[2]);
-		}
-		if (axi_ctrl->share_ctrl->operation_mode ==
-				VFE_OUTPUTS_THUMB_AND_MAIN ||
-			axi_ctrl->share_ctrl->operation_mode ==
-				VFE_OUTPUTS_MAIN_AND_THUMB ||
-			axi_ctrl->share_ctrl->operation_mode ==
-				VFE_OUTPUTS_THUMB_AND_JPEG ||
-			axi_ctrl->share_ctrl->operation_mode ==
-				VFE_OUTPUTS_JPEG_AND_THUMB ||
-			axi_ctrl->share_ctrl->operation_mode ==
-				VFE_OUTPUTS_RAW ||
-			axi_ctrl->share_ctrl->liveshot_state ==
-				VFE_STATE_STOPPED)
-			axi_ctrl->share_ctrl->outpath.out0.capture_cnt--;
-
-		vfe_send_outmsg(axi_ctrl,
-			MSG_ID_OUTPUT_PRIMARY, ch0_paddr,
-			ch1_paddr, ch2_paddr,
-			axi_ctrl->share_ctrl->outpath.out0.image_mode);
-
-		if (axi_ctrl->share_ctrl->liveshot_state == VFE_STATE_STOPPED)
-			axi_ctrl->share_ctrl->liveshot_state = VFE_STATE_IDLE;
-
-	} else {
-		axi_ctrl->share_ctrl->outpath.out0.frame_drop_cnt++;
-		CDBG("path_irq_0 - no free buffer!\n");
-	}
-}
-
-static void vfe40_process_output_path_irq_1(
-	struct axi_ctrl_t *axi_ctrl)
-{
-	uint32_t ping_pong;
-	uint32_t ch0_paddr, ch1_paddr, ch2_paddr;
-	/* this must be snapshot main image output. */
-	uint8_t out_bool = 0;
-	struct msm_free_buf *free_buf = NULL;
-
-	free_buf = vfe40_check_free_buffer(VFE_MSG_OUTPUT_IRQ,
-		VFE_MSG_OUTPUT_SECONDARY, axi_ctrl);
-	out_bool = ((axi_ctrl->share_ctrl->operation_mode ==
-				VFE_OUTPUTS_THUMB_AND_MAIN ||
-			axi_ctrl->share_ctrl->operation_mode ==
-				VFE_OUTPUTS_MAIN_AND_THUMB ||
-			axi_ctrl->share_ctrl->operation_mode ==
-				VFE_OUTPUTS_RAW ||
-			axi_ctrl->share_ctrl->operation_mode ==
-				VFE_OUTPUTS_JPEG_AND_THUMB) &&
-			(axi_ctrl->share_ctrl->vfe_capture_count <= 1)) ||
-				free_buf;
-
-	if (out_bool) {
-		ping_pong = msm_camera_io_r(axi_ctrl->share_ctrl->vfebase +
-			VFE_BUS_PING_PONG_STATUS);
-
-		/* Y channel */
-		ch0_paddr = vfe40_get_ch_addr(ping_pong,
-			axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out1.ch0);
-		/* Chroma channel */
-		ch1_paddr = vfe40_get_ch_addr(ping_pong,
-			axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out1.ch1);
-		ch2_paddr = vfe40_get_ch_addr(ping_pong,
-			axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out1.ch2);
-
-		CDBG("%s ch0 = 0x%x, ch1 = 0x%x, ch2 = 0x%x\n",
-			__func__, ch0_paddr, ch1_paddr, ch2_paddr);
-		if (free_buf) {
-			/* Y channel */
-			vfe40_put_ch_addr(ping_pong,
-			axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out1.ch0,
-			free_buf->ch_paddr[0]);
-			/* Chroma channel */
-			vfe40_put_ch_addr(ping_pong,
-			axi_ctrl->share_ctrl->vfebase,
-			axi_ctrl->share_ctrl->outpath.out1.ch1,
-			free_buf->ch_paddr[1]);
-			if (free_buf->num_planes > 2)
-				vfe40_put_ch_addr(ping_pong,
-					axi_ctrl->share_ctrl->vfebase,
-					axi_ctrl->share_ctrl->outpath.out1.ch2,
-					free_buf->ch_paddr[2]);
-		}
-		if (axi_ctrl->share_ctrl->operation_mode ==
-				VFE_OUTPUTS_THUMB_AND_MAIN ||
-			axi_ctrl->share_ctrl->operation_mode ==
-				VFE_OUTPUTS_MAIN_AND_THUMB ||
-			axi_ctrl->share_ctrl->operation_mode ==
-				VFE_OUTPUTS_RAW ||
-			axi_ctrl->share_ctrl->operation_mode ==
-				VFE_OUTPUTS_JPEG_AND_THUMB)
-			axi_ctrl->share_ctrl->outpath.out1.capture_cnt--;
-
-		vfe_send_outmsg(axi_ctrl,
-			MSG_ID_OUTPUT_SECONDARY, ch0_paddr,
-			ch1_paddr, ch2_paddr,
-			axi_ctrl->share_ctrl->outpath.out1.image_mode);
-
-	} else {
-		axi_ctrl->share_ctrl->outpath.out1.frame_drop_cnt++;
-		CDBG("path_irq_1 - no free buffer!\n");
-	}
-}
-
-static void msm_axi_process_irq(struct v4l2_subdev *sd, void *arg)
-{
-	struct axi_ctrl_t *axi_ctrl = v4l2_get_subdevdata(sd);
-	uint32_t irqstatus = (uint32_t) arg;
-
-	if (!axi_ctrl->share_ctrl->vfebase) {
-		pr_err("%s: base address unmapped\n", __func__);
-		return;
-	}
-	/* next, check output path related interrupts. */
-	if (irqstatus &
-		VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE0_MASK) {
-		CDBG("Image composite done 0 irq occured.\n");
-		vfe40_process_output_path_irq_0(axi_ctrl);
-	}
-	if (irqstatus &
-		VFE_IRQ_STATUS0_IMAGE_COMPOSIT_DONE1_MASK) {
-		CDBG("Image composite done 1 irq occured.\n");
-		vfe40_process_output_path_irq_1(axi_ctrl);
-	}
-	/* in snapshot mode if done then send
-	snapshot done message */
-	if (axi_ctrl->share_ctrl->operation_mode ==
-			VFE_OUTPUTS_THUMB_AND_MAIN ||
-		axi_ctrl->share_ctrl->operation_mode ==
-			VFE_OUTPUTS_MAIN_AND_THUMB ||
-		axi_ctrl->share_ctrl->operation_mode ==
-			VFE_OUTPUTS_THUMB_AND_JPEG ||
-		axi_ctrl->share_ctrl->operation_mode ==
-			VFE_OUTPUTS_JPEG_AND_THUMB ||
-		axi_ctrl->share_ctrl->operation_mode ==
-			VFE_OUTPUTS_RAW) {
-		if ((axi_ctrl->share_ctrl->outpath.out0.capture_cnt == 0)
-				&& (axi_ctrl->share_ctrl->outpath.out1.
-				capture_cnt == 0)) {
-			msm_camera_io_w_mb(
-				CAMIF_COMMAND_STOP_IMMEDIATELY,
-				axi_ctrl->share_ctrl->vfebase +
-				VFE_CAMIF_COMMAND);
-			vfe40_send_isp_msg(&axi_ctrl->subdev,
-				axi_ctrl->share_ctrl->vfeFrameId,
-				MSG_ID_SNAPSHOT_DONE);
-		}
-	}
-}
-
-static int msm_axi_buf_cfg(struct v4l2_subdev *sd, void __user *arg)
-{
-	struct msm_camvfe_params *vfe_params =
-		(struct msm_camvfe_params *)arg;
-	struct msm_vfe_cfg_cmd *cmd = vfe_params->vfe_cfg;
-	struct axi_ctrl_t *axi_ctrl = v4l2_get_subdevdata(sd);
-	void *data = vfe_params->data;
-	int rc = 0;
-
-	if (!axi_ctrl->share_ctrl->vfebase) {
-		pr_err("%s: base address unmapped\n", __func__);
-		return -EFAULT;
-	}
-
-	switch (cmd->cmd_type) {
-	case CMD_CONFIG_PING_ADDR: {
-		int path = *((int *)cmd->value);
-		struct vfe40_output_ch *outch =
-			vfe40_get_ch(path, axi_ctrl->share_ctrl);
-		outch->ping = *((struct msm_free_buf *)data);
-	}
-		break;
-
-	case CMD_CONFIG_PONG_ADDR: {
-		int path = *((int *)cmd->value);
-		struct vfe40_output_ch *outch =
-			vfe40_get_ch(path, axi_ctrl->share_ctrl);
-		outch->pong = *((struct msm_free_buf *)data);
-	}
-		break;
-
-	case CMD_CONFIG_FREE_BUF_ADDR: {
-		int path = *((int *)cmd->value);
-		struct vfe40_output_ch *outch =
-			vfe40_get_ch(path, axi_ctrl->share_ctrl);
-		outch->free_buf = *((struct msm_free_buf *)data);
-	}
-		break;
-	default:
-		pr_err("%s Unsupported AXI Buf config %x ", __func__,
-			cmd->cmd_type);
-	}
-	return rc;
-};
-
-static struct msm_cam_clk_info vfe40_clk_info[] = {
-	{"vfe_clk_src", 266670000},
-	{"camss_vfe_vfe_clk", -1},
-	{"camss_csi_vfe_clk", -1},
-	{"top_clk", -1},
-	{"iface_clk", -1},
-	{"bus_clk", -1},
-};
-
-int msm_axi_subdev_init(struct v4l2_subdev *sd,
-			struct msm_cam_media_controller *mctl)
-{
-	int rc = 0;
-	struct axi_ctrl_t *axi_ctrl = v4l2_get_subdevdata(sd);
-	v4l2_set_subdev_hostdata(sd, mctl);
-	spin_lock_init(&axi_ctrl->tasklet_lock);
-	INIT_LIST_HEAD(&axi_ctrl->tasklet_q);
-	spin_lock_init(&axi_ctrl->share_ctrl->sd_notify_lock);
-
-	axi_ctrl->share_ctrl->vfebase = ioremap(axi_ctrl->vfemem->start,
-		resource_size(axi_ctrl->vfemem));
-	if (!axi_ctrl->share_ctrl->vfebase) {
-		rc = -ENOMEM;
-		pr_err("%s: vfe ioremap failed\n", __func__);
-		goto remap_failed;
-	}
-
-	if (axi_ctrl->fs_vfe == NULL) {
-		axi_ctrl->fs_vfe =
-			regulator_get(&axi_ctrl->pdev->dev, "vdd");
-		if (IS_ERR(axi_ctrl->fs_vfe)) {
-			pr_err("%s: Regulator FS_VFE get failed %ld\n",
-				__func__, PTR_ERR(axi_ctrl->fs_vfe));
-			axi_ctrl->fs_vfe = NULL;
-			goto fs_failed;
-		} else if (regulator_enable(axi_ctrl->fs_vfe)) {
-			pr_err("%s: Regulator FS_VFE enable failed\n",
-							__func__);
-			regulator_put(axi_ctrl->fs_vfe);
-			axi_ctrl->fs_vfe = NULL;
-			goto fs_failed;
-		}
-	}
-	rc = msm_cam_clk_enable(&axi_ctrl->pdev->dev, vfe40_clk_info,
-			axi_ctrl->vfe_clk, ARRAY_SIZE(vfe40_clk_info), 1);
-	if (rc < 0)
-			goto clk_enable_failed;
-
-	msm_camio_bus_scale_cfg(
-		mctl->sdata->pdata->cam_bus_scale_table, S_INIT);
-	msm_camio_bus_scale_cfg(
-		mctl->sdata->pdata->cam_bus_scale_table, S_PREVIEW);
-
-	axi_ctrl->share_ctrl->register_total = VFE40_REGISTER_TOTAL;
-
-	enable_irq(axi_ctrl->vfeirq->start);
-
-	return rc;
-clk_enable_failed:
-	regulator_disable(axi_ctrl->fs_vfe);
-	regulator_put(axi_ctrl->fs_vfe);
-	axi_ctrl->fs_vfe = NULL;
-fs_failed:
-	iounmap(axi_ctrl->share_ctrl->vfebase);
-	axi_ctrl->share_ctrl->vfebase = NULL;
-remap_failed:
-	disable_irq(axi_ctrl->vfeirq->start);
-	return rc;
-}
-
-void msm_axi_subdev_release(struct v4l2_subdev *sd)
-{
-	struct msm_cam_media_controller *pmctl =
-		(struct msm_cam_media_controller *)v4l2_get_subdev_hostdata(sd);
-	struct axi_ctrl_t *axi_ctrl = v4l2_get_subdevdata(sd);
-	if (!axi_ctrl->share_ctrl->vfebase) {
-		pr_err("%s: base address unmapped\n", __func__);
-		return;
-	}
-
-	CDBG("%s, free_irq\n", __func__);
-	disable_irq(axi_ctrl->vfeirq->start);
-	tasklet_kill(&axi_ctrl->vfe40_tasklet);
-	msm_cam_clk_enable(&axi_ctrl->pdev->dev, vfe40_clk_info,
-		axi_ctrl->vfe_clk, ARRAY_SIZE(vfe40_clk_info), 0);
-
-	if (axi_ctrl->fs_vfe) {
-		regulator_disable(axi_ctrl->fs_vfe);
-		regulator_put(axi_ctrl->fs_vfe);
-		axi_ctrl->fs_vfe = NULL;
-	}
-	iounmap(axi_ctrl->share_ctrl->vfebase);
-	axi_ctrl->share_ctrl->vfebase = NULL;
-
-	if (atomic_read(&axi_ctrl->share_ctrl->irq_cnt))
-		pr_warning("%s, Warning IRQ Count not ZERO\n", __func__);
-
-	msm_camio_bus_scale_cfg(
-		pmctl->sdata->pdata->cam_bus_scale_table, S_EXIT);
-}
-
-static long msm_axi_subdev_ioctl(struct v4l2_subdev *sd,
-			unsigned int cmd, void *arg)
-{
-	int rc = -ENOIOCTLCMD;
-	switch (cmd) {
-	case VIDIOC_MSM_AXI_INIT:
-		rc = msm_axi_subdev_init(sd,
-			(struct msm_cam_media_controller *)arg);
-		break;
-	case VIDIOC_MSM_AXI_CFG:
-		rc = msm_axi_config(sd, arg);
-		break;
-	case VIDIOC_MSM_AXI_IRQ:
-		msm_axi_process_irq(sd, arg);
-		rc = 0;
-		break;
-	case VIDIOC_MSM_AXI_BUF_CFG:
-		msm_axi_buf_cfg(sd, arg);
-		rc = 0;
-		break;
-	case VIDIOC_MSM_AXI_RELEASE:
-		msm_axi_subdev_release(sd);
-		rc = 0;
-		break;
-	default:
-		pr_err("%s: command not found\n", __func__);
-	}
-	return rc;
-}
-
-static const struct v4l2_subdev_core_ops msm_axi_subdev_core_ops = {
-	.ioctl = msm_axi_subdev_ioctl,
-};
-
-static const struct v4l2_subdev_video_ops msm_axi_subdev_video_ops = {
-	.s_crystal_freq = msm_axi_subdev_s_crystal_freq,
-};
-
-static const struct v4l2_subdev_ops msm_axi_subdev_ops = {
-	.core = &msm_axi_subdev_core_ops,
-	.video = &msm_axi_subdev_video_ops,
-};
-
-static const struct v4l2_subdev_internal_ops msm_axi_internal_ops;
-
-void vfe40_axi_probe(struct axi_ctrl_t *axi_ctrl)
-{
-	struct msm_cam_subdev_info sd_info;
-	v4l2_subdev_init(&axi_ctrl->subdev, &msm_axi_subdev_ops);
-	axi_ctrl->subdev.internal_ops = &msm_axi_internal_ops;
-	axi_ctrl->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	snprintf(axi_ctrl->subdev.name,
-			 sizeof(axi_ctrl->subdev.name), "axi");
-	v4l2_set_subdevdata(&axi_ctrl->subdev, axi_ctrl);
-
-	sd_info.sdev_type = AXI_DEV;
-	sd_info.sd_index = axi_ctrl->pdev->id;
-	sd_info.irq_num = 0;
-	msm_cam_register_subdev_node(&axi_ctrl->subdev, &sd_info);
-}
diff --git a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe7x.c b/drivers/media/platform/msm/camera_v1/vfe/msm_vfe7x.c
deleted file mode 100644
index d7ec547..0000000
--- a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe7x.c
+++ /dev/null
@@ -1,786 +0,0 @@
-/* Copyright (c) 2009-2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/msm_adsp.h>
-#include <linux/uaccess.h>
-#include <linux/fs.h>
-
-#include <linux/slab.h>
-#include <mach/msm_adsp.h>
-#include <mach/clk.h>
-#include <linux/delay.h>
-#include <linux/wait.h>
-#include "msm_vfe7x.h"
-#include <linux/pm_qos.h>
-
-#define QDSP_CMDQUEUE 25
-
-#define VFE_RESET_CMD 0
-#define VFE_START_CMD 1
-#define VFE_STOP_CMD  2
-#define VFE_FRAME_ACK 20
-#define STATS_AF_ACK  21
-#define STATS_WE_ACK  22
-
-#define MSG_STOP_ACK  1
-#define MSG_SNAPSHOT  2
-#define MSG_OUTPUT1   6
-#define MSG_OUTPUT2   7
-#define MSG_STATS_AF  8
-#define MSG_STATS_WE  9
-#define MSG_OUTPUT_S  10
-#define MSG_OUTPUT_T  11
-
-#define VFE_ADSP_EVENT 0xFFFF
-#define SNAPSHOT_MASK_MODE 0x00000002
-#define MSM_AXI_QOS_PREVIEW	192000
-#define MSM_AXI_QOS_SNAPSHOT	192000
-
-
-static struct msm_adsp_module *qcam_mod;
-static struct msm_adsp_module *vfe_mod;
-static struct msm_vfe_callback *resp;
-static void *extdata;
-static uint32_t extlen;
-
-struct mutex vfe_lock;
-static void     *vfe_syncdata;
-static uint8_t vfestopped;
-static uint32_t vfetask_state;
-static int cnt;
-
-static struct stop_event stopevent;
-
-unsigned long paddr_s_y;
-unsigned long paddr_s_cbcr;
-unsigned long paddr_t_y;
-unsigned long paddr_t_cbcr;
-
-static void vfe_7x_convert(struct msm_vfe_phy_info *pinfo,
-		enum vfe_resp_msg type,
-		void *data, void **ext, int32_t *elen)
-{
-	switch (type) {
-	case VFE_MSG_OUTPUT_P: {
-		pinfo->p0_phy = ((struct vfe_endframe *)data)->y_address;
-		pinfo->p1_phy =
-			((struct vfe_endframe *)data)->cbcr_address;
-		pinfo->p2_phy = pinfo->p0_phy;
-		pinfo->output_id = OUTPUT_TYPE_P;
-
-		CDBG("vfe_7x_convert, y_phy = 0x%x, cbcr_phy = 0x%x\n",
-				 pinfo->p0_phy, pinfo->p1_phy);
-
-		((struct vfe_frame_extra *)extdata)->bl_evencol =
-		((struct vfe_endframe *)data)->blacklevelevencolumn;
-
-		((struct vfe_frame_extra *)extdata)->bl_oddcol =
-		((struct vfe_endframe *)data)->blackleveloddcolumn;
-
-		((struct vfe_frame_extra *)extdata)->g_def_p_cnt =
-		((struct vfe_endframe *)data)->greendefectpixelcount;
-
-		((struct vfe_frame_extra *)extdata)->r_b_def_p_cnt =
-		((struct vfe_endframe *)data)->redbluedefectpixelcount;
-
-		*ext  = extdata;
-		*elen = extlen;
-	}
-		break;
-
-	case VFE_MSG_OUTPUT_S: {
-		pinfo->p0_phy = paddr_s_y;
-		pinfo->p1_phy = paddr_s_cbcr;
-		pinfo->p2_phy = pinfo->p0_phy;
-		pinfo->output_id = OUTPUT_TYPE_S;
-		CDBG("vfe_7x_convert: y_phy = 0x%x cbcr_phy = 0x%x\n",
-					pinfo->p0_phy, pinfo->p1_phy);
-	}
-		break;
-
-	case VFE_MSG_OUTPUT_T: {
-		pinfo->p0_phy = paddr_t_y;
-		pinfo->p1_phy = paddr_t_cbcr;
-		pinfo->p2_phy = pinfo->p0_phy;
-		pinfo->output_id = OUTPUT_TYPE_T;
-		CDBG("vfe_7x_convert: y_phy = 0x%x cbcr_phy = 0x%x\n",
-					pinfo->p0_phy, pinfo->p1_phy);
-	}
-		break;
-
-	case VFE_MSG_STATS_AF:
-	case VFE_MSG_STATS_WE:
-		pinfo->sbuf_phy = *(uint32_t *)data;
-		break;
-
-	default:
-		break;
-	} /* switch */
-}
-
-static void vfe_7x_ops(void *driver_data, unsigned id, size_t len,
-		void (*getevent)(void *ptr, size_t len))
-{
-	uint32_t evt_buf[3];
-	struct msm_vfe_resp *rp;
-	void *data;
-	CDBG("%s:id=%d\n", __func__, id);
-
-	len = (id == VFE_ADSP_EVENT) ? 0 : len;
-	data = resp->vfe_alloc(sizeof(struct msm_vfe_resp) + len,
-		vfe_syncdata,  GFP_ATOMIC);
-
-	if (!data) {
-		pr_err("%s: rp: cannot allocate buffer\n", __func__);
-		return;
-	}
-	rp = (struct msm_vfe_resp *)data;
-	rp->evt_msg.len = len;
-
-	if (id == VFE_ADSP_EVENT) {
-		/* event */
-		rp->type           = VFE_EVENT;
-		rp->evt_msg.type   = MSM_CAMERA_EVT;
-		getevent(evt_buf, sizeof(evt_buf));
-		rp->evt_msg.msg_id = evt_buf[0];
-	CDBG("%s:event:msg_id=%d\n", __func__, rp->evt_msg.msg_id);
-		resp->vfe_resp(rp, MSM_CAM_Q_VFE_EVT, vfe_syncdata,
-		GFP_ATOMIC);
-	} else {
-		/* messages */
-		rp->evt_msg.type   = MSM_CAMERA_MSG;
-		rp->evt_msg.msg_id = id;
-		rp->evt_msg.data = rp + 1;
-		getevent(rp->evt_msg.data, len);
-	CDBG("%s:messages:msg_id=%d\n", __func__, rp->evt_msg.msg_id);
-
-		switch (rp->evt_msg.msg_id) {
-		case MSG_SNAPSHOT:
-			update_axi_qos(MSM_AXI_QOS_PREVIEW);
-			vfe_7x_ops(driver_data, MSG_OUTPUT_S, len, getevent);
-			vfe_7x_ops(driver_data, MSG_OUTPUT_T, len, getevent);
-			rp->type = VFE_MSG_SNAPSHOT;
-			break;
-
-		case MSG_OUTPUT_S:
-			rp->type = VFE_MSG_OUTPUT_S;
-			vfe_7x_convert(&(rp->phy), VFE_MSG_OUTPUT_S,
-				rp->evt_msg.data, &(rp->extdata),
-				&(rp->extlen));
-			break;
-
-		case MSG_OUTPUT_T:
-			rp->type = VFE_MSG_OUTPUT_T;
-			vfe_7x_convert(&(rp->phy), VFE_MSG_OUTPUT_T,
-				rp->evt_msg.data, &(rp->extdata),
-				&(rp->extlen));
-			break;
-
-		case MSG_OUTPUT1:
-		case MSG_OUTPUT2:
-			rp->type = VFE_MSG_OUTPUT_P;
-			vfe_7x_convert(&(rp->phy), VFE_MSG_OUTPUT_P,
-				rp->evt_msg.data, &(rp->extdata),
-				&(rp->extlen));
-			break;
-
-		case MSG_STATS_AF:
-			rp->type = VFE_MSG_STATS_AF;
-			vfe_7x_convert(&(rp->phy), VFE_MSG_STATS_AF,
-					rp->evt_msg.data, NULL, NULL);
-			break;
-
-		case MSG_STATS_WE:
-			rp->type = VFE_MSG_STATS_WE;
-			vfe_7x_convert(&(rp->phy), VFE_MSG_STATS_WE,
-					rp->evt_msg.data, NULL, NULL);
-
-			CDBG("MSG_STATS_WE: phy = 0x%x\n", rp->phy.sbuf_phy);
-			break;
-
-		case MSG_STOP_ACK:
-			rp->type = VFE_MSG_GENERAL;
-			stopevent.state = 1;
-			wake_up(&stopevent.wait);
-			break;
-
-
-		default:
-			rp->type = VFE_MSG_GENERAL;
-			break;
-		}
-		resp->vfe_resp(rp, MSM_CAM_Q_VFE_MSG, vfe_syncdata, GFP_ATOMIC);
-	}
-}
-
-static struct msm_adsp_ops vfe_7x_sync = {
-	.event = vfe_7x_ops,
-};
-
-static int vfe_7x_enable(struct camera_enable_cmd *enable)
-{
-	int rc = -EFAULT;
-
-	if (!strcmp(enable->name, "QCAMTASK"))
-		rc = msm_adsp_enable(qcam_mod);
-	else if (!strcmp(enable->name, "VFETASK")) {
-		rc = msm_adsp_enable(vfe_mod);
-		vfetask_state = 1;
-	}
-
-	if (!cnt) {
-		add_axi_qos();
-		cnt++;
-	}
-	return rc;
-}
-
-static int vfe_7x_disable(struct camera_enable_cmd *enable,
-		struct platform_device *dev __attribute__((unused)))
-{
-	int rc = -EFAULT;
-
-	if (!strcmp(enable->name, "QCAMTASK"))
-		rc = msm_adsp_disable(qcam_mod);
-	else if (!strcmp(enable->name, "VFETASK")) {
-		rc = msm_adsp_disable(vfe_mod);
-		vfetask_state = 0;
-	}
-
-	return rc;
-}
-
-static int vfe_7x_stop(void)
-{
-	int rc = 0;
-	uint32_t stopcmd = VFE_STOP_CMD;
-	rc = msm_adsp_write(vfe_mod, QDSP_CMDQUEUE,
-				&stopcmd, sizeof(uint32_t));
-	if (rc < 0) {
-		CDBG("%s:%d: failed rc = %d \n", __func__, __LINE__, rc);
-		return rc;
-	}
-
-	stopevent.state = 0;
-	rc = wait_event_timeout(stopevent.wait,
-		stopevent.state != 0,
-		msecs_to_jiffies(stopevent.timeout));
-
-	return rc;
-}
-
-static void vfe_7x_release(struct platform_device *pdev)
-{
-	mutex_lock(&vfe_lock);
-	vfe_syncdata = NULL;
-	mutex_unlock(&vfe_lock);
-
-	if (!vfestopped) {
-		CDBG("%s:%d:Calling vfe_7x_stop()\n", __func__, __LINE__);
-		vfe_7x_stop();
-	} else
-		vfestopped = 0;
-
-	msm_adsp_disable(qcam_mod);
-	msm_adsp_disable(vfe_mod);
-	vfetask_state = 0;
-
-	msm_adsp_put(qcam_mod);
-	msm_adsp_put(vfe_mod);
-
-	msm_camio_disable(pdev);
-
-	kfree(extdata);
-	extlen = 0;
-
-	/* Release AXI */
-	release_axi_qos();
-	cnt = 0;
-}
-
-static int vfe_7x_init(struct msm_vfe_callback *presp,
-	struct platform_device *dev)
-{
-	int rc = 0;
-
-	init_waitqueue_head(&stopevent.wait);
-	stopevent.timeout = 200;
-	stopevent.state = 0;
-
-	if (presp && presp->vfe_resp)
-		resp = presp;
-	else
-		return -EFAULT;
-
-	/* Bring up all the required GPIOs and Clocks */
-	rc = msm_camio_enable(dev);
-	if (rc < 0)
-		return rc;
-	msm_camio_camif_pad_reg_reset();
-
-	extlen = sizeof(struct vfe_frame_extra);
-
-	extdata =
-		kmalloc(extlen, GFP_ATOMIC);
-	if (!extdata) {
-		rc = -ENOMEM;
-		goto init_fail;
-	}
-
-	rc = msm_adsp_get("QCAMTASK", &qcam_mod, &vfe_7x_sync, NULL);
-	if (rc) {
-		rc = -EBUSY;
-		goto get_qcam_fail;
-	}
-
-	rc = msm_adsp_get("VFETASK", &vfe_mod, &vfe_7x_sync, NULL);
-	if (rc) {
-		rc = -EBUSY;
-		goto get_vfe_fail;
-	}
-
-	return 0;
-
-get_vfe_fail:
-	msm_adsp_put(qcam_mod);
-get_qcam_fail:
-	kfree(extdata);
-init_fail:
-	extlen = 0;
-	return rc;
-}
-
-static int vfe_7x_config_axi(int mode,
-	struct axidata *ad, struct axiout *ao)
-{
-	struct msm_pmem_region *regptr;
-	unsigned long *bptr;
-	int    cnt;
-
-	int rc = 0;
-
-	if (mode == OUTPUT_1 || mode == OUTPUT_1_AND_2) {
-		regptr = ad->region;
-
-		CDBG("bufnum1 = %d\n", ad->bufnum1);
-		if (mode == OUTPUT_1_AND_2) {
-			paddr_t_y = regptr->paddr + regptr->info.planar0_off;
-			paddr_t_cbcr = regptr->paddr + regptr->info.planar1_off;
-		}
-
-		CDBG("config_axi1: O1, phy = 0x%lx, y_off = %d, cbcr_off =%d\n",
-			regptr->paddr, regptr->info.planar0_off,
-			regptr->info.planar1_off);
-
-		bptr = &ao->output1buffer1_y_phy;
-		for (cnt = 0; cnt < ad->bufnum1; cnt++) {
-			*bptr = regptr->paddr + regptr->info.planar0_off;
-			bptr++;
-			*bptr = regptr->paddr + regptr->info.planar1_off;
-
-			bptr++;
-			regptr++;
-		}
-
-		regptr--;
-		for (cnt = 0; cnt < (8 - ad->bufnum1); cnt++) {
-			*bptr = regptr->paddr + regptr->info.planar0_off;
-			bptr++;
-			*bptr = regptr->paddr + regptr->info.planar1_off;
-			bptr++;
-		}
-	} /* if OUTPUT1 or Both */
-
-	if (mode == OUTPUT_2 || mode == OUTPUT_1_AND_2) {
-		regptr = &(ad->region[ad->bufnum1]);
-
-		CDBG("bufnum2 = %d\n", ad->bufnum2);
-		paddr_s_y = regptr->paddr +  regptr->info.planar0_off;
-		paddr_s_cbcr = regptr->paddr +  regptr->info.planar1_off;
-		CDBG("config_axi2: O2, phy = 0x%lx, y_off = %d, cbcr_off =%d\n",
-			regptr->paddr, regptr->info.planar0_off,
-			regptr->info.planar1_off);
-
-		bptr = &ao->output2buffer1_y_phy;
-		for (cnt = 0; cnt < ad->bufnum2; cnt++) {
-			*bptr = regptr->paddr + regptr->info.planar0_off;
-			bptr++;
-			*bptr = regptr->paddr + regptr->info.planar1_off;
-
-			bptr++;
-			regptr++;
-		}
-
-		regptr--;
-		for (cnt = 0; cnt < (8 - ad->bufnum2); cnt++) {
-			*bptr = regptr->paddr + regptr->info.planar0_off;
-			bptr++;
-			*bptr = regptr->paddr + regptr->info.planar1_off;
-			bptr++;
-		}
-	}
-
-	return rc;
-}
-
-static int vfe_7x_config(struct msm_vfe_cfg_cmd *cmd, void *data)
-{
-	struct msm_pmem_region *regptr;
-	unsigned char buf[256];
-
-	struct vfe_stats_ack sack;
-	struct axidata *axid;
-	uint32_t i, op_mode;
-	uint32_t *_mode;
-
-	struct vfe_stats_we_cfg *scfg = NULL;
-	struct vfe_stats_af_cfg *sfcfg = NULL;
-
-	struct axiout *axio = NULL;
-	void   *cmd_data = NULL;
-	void   *cmd_data_alloc = NULL;
-	long rc = 0;
-	struct msm_vfe_command_7k *vfecmd;
-
-	vfecmd =
-			kmalloc(sizeof(struct msm_vfe_command_7k),
-				GFP_ATOMIC);
-	if (!vfecmd) {
-		pr_err("vfecmd alloc failed!\n");
-		return -ENOMEM;
-	}
-
-	if (cmd->cmd_type != CMD_FRAME_BUF_RELEASE &&
-	    cmd->cmd_type != CMD_STATS_BUF_RELEASE &&
-	    cmd->cmd_type != CMD_STATS_AF_BUF_RELEASE) {
-		if (copy_from_user(vfecmd,
-				(void __user *)(cmd->value),
-				sizeof(struct msm_vfe_command_7k))) {
-			rc = -EFAULT;
-			goto config_failure;
-		}
-	}
-
-	switch (cmd->cmd_type) {
-	case CMD_STATS_AEC_AWB_ENABLE:
-	case CMD_STATS_AXI_CFG: {
-		axid = data;
-		if (!axid) {
-			rc = -EFAULT;
-			goto config_failure;
-		}
-
-		scfg =
-			kmalloc(sizeof(struct vfe_stats_we_cfg),
-				GFP_ATOMIC);
-		if (!scfg) {
-			rc = -ENOMEM;
-			goto config_failure;
-		}
-
-		if (copy_from_user(scfg,
-					(void __user *)(vfecmd->value),
-					vfecmd->length)) {
-
-			rc = -EFAULT;
-			goto config_done;
-		}
-
-		CDBG("STATS_ENABLE: bufnum = %d, enabling = %d\n",
-			axid->bufnum1, scfg->wb_expstatsenable);
-
-		if (axid->bufnum1 > 0) {
-			regptr = axid->region;
-
-			for (i = 0; i < axid->bufnum1; i++) {
-
-				CDBG("STATS_ENABLE, phy = 0x%lx\n",
-					regptr->paddr);
-
-				scfg->wb_expstatoutputbuffer[i] =
-					(void *)regptr->paddr;
-				regptr++;
-			}
-
-			cmd_data = scfg;
-
-		} else {
-			rc = -EINVAL;
-			goto config_done;
-		}
-	}
-		break;
-
-	case CMD_STATS_AF_ENABLE:
-	case CMD_STATS_AF_AXI_CFG: {
-		axid = data;
-		if (!axid) {
-			rc = -EFAULT;
-			goto config_failure;
-		}
-
-		sfcfg =
-			kmalloc(sizeof(struct vfe_stats_af_cfg),
-				GFP_ATOMIC);
-
-		if (!sfcfg) {
-			rc = -ENOMEM;
-			goto config_failure;
-		}
-
-		if (copy_from_user(sfcfg,
-					(void __user *)(vfecmd->value),
-					vfecmd->length)) {
-
-			rc = -EFAULT;
-			goto config_done;
-		}
-
-		CDBG("AF_ENABLE: bufnum = %d, enabling = %d\n",
-			axid->bufnum1, sfcfg->af_enable);
-
-		if (axid->bufnum1 > 0) {
-			regptr = &axid->region[0];
-
-			for (i = 0; i < axid->bufnum1; i++) {
-
-				CDBG("STATS_ENABLE, phy = 0x%lx\n",
-					regptr->paddr);
-
-				sfcfg->af_outbuf[i] =
-					(void *)regptr->paddr;
-
-				regptr++;
-			}
-
-			cmd_data = sfcfg;
-
-		} else {
-			rc = -EINVAL;
-			goto config_done;
-		}
-	}
-		break;
-
-	case CMD_FRAME_BUF_RELEASE: {
-		struct msm_frame *b;
-		unsigned long p;
-		struct vfe_outputack fack;
-		if (!data)  {
-			rc = -EFAULT;
-			goto config_failure;
-		}
-
-		b = (struct msm_frame *)(cmd->value);
-		p = *(unsigned long *)data;
-
-		fack.header = VFE_FRAME_ACK;
-
-		fack.output2newybufferaddress =
-			(void *)(p + b->planar0_off);
-
-		fack.output2newcbcrbufferaddress =
-			(void *)(p + b->planar1_off);
-
-		vfecmd->queue = QDSP_CMDQUEUE;
-		vfecmd->length = sizeof(struct vfe_outputack);
-		cmd_data = &fack;
-	}
-		break;
-
-	case CMD_SNAP_BUF_RELEASE:
-		break;
-
-	case CMD_STATS_BUF_RELEASE: {
-		CDBG("vfe_7x_config: CMD_STATS_BUF_RELEASE\n");
-		if (!data) {
-			rc = -EFAULT;
-			goto config_failure;
-		}
-
-		sack.header = STATS_WE_ACK;
-		sack.bufaddr = (void *)*(uint32_t *)data;
-
-		vfecmd->queue  = QDSP_CMDQUEUE;
-		vfecmd->length = sizeof(struct vfe_stats_ack);
-		cmd_data = &sack;
-	}
-		break;
-
-	case CMD_STATS_AF_BUF_RELEASE: {
-		CDBG("vfe_7x_config: CMD_STATS_AF_BUF_RELEASE\n");
-		if (!data) {
-			rc = -EFAULT;
-			goto config_failure;
-		}
-
-		sack.header = STATS_AF_ACK;
-		sack.bufaddr = (void *)*(uint32_t *)data;
-
-		vfecmd->queue  = QDSP_CMDQUEUE;
-		vfecmd->length = sizeof(struct vfe_stats_ack);
-		cmd_data = &sack;
-	}
-		break;
-
-	case CMD_GENERAL:
-	case CMD_STATS_DISABLE: {
-		if (vfecmd->length > 256) {
-			cmd_data_alloc =
-			cmd_data = kmalloc(vfecmd->length, GFP_ATOMIC);
-			if (!cmd_data) {
-				rc = -ENOMEM;
-				goto config_failure;
-			}
-		} else
-			cmd_data = buf;
-
-		if (copy_from_user(cmd_data,
-					(void __user *)(vfecmd->value),
-					vfecmd->length)) {
-
-			rc = -EFAULT;
-			goto config_done;
-		}
-
-		if (vfecmd->queue == QDSP_CMDQUEUE) {
-			switch (*(uint32_t *)cmd_data) {
-			case VFE_RESET_CMD:
-				msm_camio_vfe_blk_reset();
-				vfestopped = 0;
-				break;
-
-			case VFE_START_CMD:
-				_mode = (uint32_t *)cmd_data;
-				op_mode = *(++_mode);
-				if (op_mode & SNAPSHOT_MASK_MODE) {
-					/* request AXI bus for snapshot */
-					if (update_axi_qos(MSM_AXI_QOS_SNAPSHOT)
-						< 0) {
-						rc = -EFAULT;
-						goto config_failure;
-					}
-				} else {
-					/* request AXI bus for snapshot */
-					if (update_axi_qos(MSM_AXI_QOS_PREVIEW)
-						< 0) {
-						rc = -EFAULT;
-						goto config_failure;
-					}
-				}
-				msm_camio_camif_pad_reg_reset_2();
-				vfestopped = 0;
-				break;
-
-			case VFE_STOP_CMD:
-				vfestopped = 1;
-				goto config_send;
-
-			default:
-				break;
-			}
-		} /* QDSP_CMDQUEUE */
-	}
-		break;
-	case CMD_AXI_CFG_PREVIEW:
-	case CMD_RAW_PICT_AXI_CFG: {
-		axid = data;
-		if (!axid) {
-			rc = -EFAULT;
-			goto config_failure;
-		}
-
-		axio = kmalloc(sizeof(struct axiout), GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			goto config_failure;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd->value),
-					sizeof(struct axiout))) {
-			rc = -EFAULT;
-			goto config_done;
-		}
-
-		vfe_7x_config_axi(OUTPUT_2, axid, axio);
-		cmd_data = axio;
-	}
-		break;
-
-	case CMD_AXI_CFG_SNAP: {
-		axid = data;
-		if (!axid) {
-			rc = -EFAULT;
-			goto config_failure;
-		}
-
-		axio = kmalloc(sizeof(struct axiout), GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			goto config_failure;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd->value),
-					sizeof(struct axiout))) {
-			rc = -EFAULT;
-			goto config_done;
-		}
-
-		vfe_7x_config_axi(OUTPUT_1_AND_2, axid, axio);
-
-		cmd_data = axio;
-	}
-		break;
-
-	default:
-		break;
-	} /* switch */
-
-	if (vfestopped)
-		goto config_done;
-
-config_send:
-	CDBG("send adsp command = %d\n", *(uint32_t *)cmd_data);
-	if (vfetask_state)
-		rc = msm_adsp_write(vfe_mod, vfecmd->queue,
-					cmd_data, vfecmd->length);
-config_done:
-	if (cmd_data_alloc != NULL)
-		kfree(cmd_data_alloc);
-
-config_failure:
-	kfree(scfg);
-	kfree(axio);
-	kfree(vfecmd);
-	return rc;
-}
-
-void msm_camvfe_fn_init(struct msm_camvfe_fn *fptr, void *data)
-{
-	mutex_init(&vfe_lock);
-	fptr->vfe_init    = vfe_7x_init;
-	fptr->vfe_enable  = vfe_7x_enable;
-	fptr->vfe_config  = vfe_7x_config;
-	fptr->vfe_disable = vfe_7x_disable;
-	fptr->vfe_release = vfe_7x_release;
-	vfe_syncdata = data;
-}
-
-void msm_camvpe_fn_init(struct msm_camvpe_fn *fptr, void *data)
-{
-	fptr->vpe_reg		= NULL;
-	fptr->send_frame_to_vpe	= NULL;
-	fptr->vpe_config	= NULL;
-	fptr->vpe_cfg_update	= NULL;
-	fptr->dis		= NULL;
-}
diff --git a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe7x.h b/drivers/media/platform/msm/camera_v1/vfe/msm_vfe7x.h
deleted file mode 100644
index 944bfea..0000000
--- a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe7x.h
+++ /dev/null
@@ -1,265 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-
-#ifndef __MSM_VFE7X_H__
-#define __MSM_VFE7X_H__
-#include <media/msm_camera.h>
-#include <mach/camera.h>
-
-struct vfe_frame_extra {
-	uint32_t  bl_evencol;
-	uint32_t  bl_oddcol;
-	uint16_t  g_def_p_cnt;
-	uint16_t  r_b_def_p_cnt;
-};
-
-struct vfe_endframe {
-	uint32_t      y_address;
-	uint32_t      cbcr_address;
-
-	unsigned int  blacklevelevencolumn:23;
-	uint16_t      reserved1:9;
-	unsigned int  blackleveloddcolumn:23;
-	uint16_t      reserved2:9;
-
-	uint16_t      greendefectpixelcount:8;
-	uint16_t      reserved3:8;
-	uint16_t      redbluedefectpixelcount:8;
-	uint16_t      reserved4:8;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_outputack {
-	uint32_t  header;
-	void      *output2newybufferaddress;
-	void      *output2newcbcrbufferaddress;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_stats_ack {
-	uint32_t header;
-	/* MUST BE 64 bit ALIGNED */
-	void     *bufaddr;
-} __attribute__((packed, aligned(4)));
-
-/* AXI Output Config Command sent to DSP */
-struct axiout {
-	uint32_t            cmdheader:32;
-	int 		    outputmode:3;
-	uint8_t             format:2;
-	uint32_t            /* reserved */ : 27;
-
-	/* AXI Output 1 Y Configuration, Part 1 */
-	uint32_t            out1yimageheight:12;
-	uint32_t            /* reserved */ : 4;
-	uint32_t            out1yimagewidthin64bitwords:10;
-	uint32_t            /* reserved */ : 6;
-
-	/* AXI Output 1 Y Configuration, Part 2 */
-	uint8_t             out1yburstlen:2;
-	uint32_t            out1ynumrows:12;
-	uint32_t            out1yrowincin64bitincs:12;
-	uint32_t            /* reserved */ : 6;
-
-	/* AXI Output 1 CbCr Configuration, Part 1 */
-	uint32_t            out1cbcrimageheight:12;
-	uint32_t            /* reserved */ : 4;
-	uint32_t            out1cbcrimagewidthin64bitwords:10;
-	uint32_t            /* reserved */ : 6;
-
-	/* AXI Output 1 CbCr Configuration, Part 2 */
-	uint8_t             out1cbcrburstlen:2;
-	uint32_t            out1cbcrnumrows:12;
-	uint32_t            out1cbcrrowincin64bitincs:12;
-	uint32_t            /* reserved */ : 6;
-
-	/* AXI Output 2 Y Configuration, Part 1 */
-	uint32_t            out2yimageheight:12;
-	uint32_t            /* reserved */ : 4;
-	uint32_t            out2yimagewidthin64bitwords:10;
-	uint32_t            /* reserved */ : 6;
-
-	/* AXI Output 2 Y Configuration, Part 2 */
-	uint8_t             out2yburstlen:2;
-	uint32_t            out2ynumrows:12;
-	uint32_t            out2yrowincin64bitincs:12;
-	uint32_t            /* reserved */ : 6;
-
-	/* AXI Output 2 CbCr Configuration, Part 1 */
-	uint32_t            out2cbcrimageheight:12;
-	uint32_t            /* reserved */ : 4;
-	uint32_t            out2cbcrimagewidtein64bitwords:10;
-	uint32_t            /* reserved */ : 6;
-
-	/* AXI Output 2 CbCr Configuration, Part 2 */
-	uint8_t             out2cbcrburstlen:2;
-	uint32_t            out2cbcrnumrows:12;
-	uint32_t            out2cbcrrowincin64bitincs:12;
-	uint32_t            /* reserved */ : 6;
-
-	/* Address configuration:
-	 * output1 phisycal address */
-	unsigned long   output1buffer1_y_phy;
-	unsigned long   output1buffer1_cbcr_phy;
-	unsigned long   output1buffer2_y_phy;
-	unsigned long   output1buffer2_cbcr_phy;
-	unsigned long   output1buffer3_y_phy;
-	unsigned long   output1buffer3_cbcr_phy;
-	unsigned long   output1buffer4_y_phy;
-	unsigned long   output1buffer4_cbcr_phy;
-	unsigned long   output1buffer5_y_phy;
-	unsigned long   output1buffer5_cbcr_phy;
-	unsigned long   output1buffer6_y_phy;
-	unsigned long   output1buffer6_cbcr_phy;
-	unsigned long   output1buffer7_y_phy;
-	unsigned long   output1buffer7_cbcr_phy;
-	unsigned long   output1buffer8_y_phy;
-	unsigned long   output1buffer8_cbcr_phy;
-
-	/* output2 phisycal address */
-	unsigned long   output2buffer1_y_phy;
-	unsigned long   output2buffer1_cbcr_phy;
-	unsigned long   output2buffer2_y_phy;
-	unsigned long   output2buffer2_cbcr_phy;
-	unsigned long   output2buffer3_y_phy;
-	unsigned long   output2buffer3_cbcr_phy;
-	unsigned long   output2buffer4_y_phy;
-	unsigned long   output2buffer4_cbcr_phy;
-	unsigned long   output2buffer5_y_phy;
-	unsigned long   output2buffer5_cbcr_phy;
-	unsigned long   output2buffer6_y_phy;
-	unsigned long   output2buffer6_cbcr_phy;
-	unsigned long   output2buffer7_y_phy;
-	unsigned long   output2buffer7_cbcr_phy;
-	unsigned long   output2buffer8_y_phy;
-	unsigned long   output2buffer8_cbcr_phy;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_stats_we_cfg {
-	uint32_t       header;
-
-	/* White Balance/Exposure Statistic Selection */
-	uint8_t        wb_expstatsenable:1;
-	uint8_t        wb_expstatbuspriorityselection:1;
-	unsigned int   wb_expstatbuspriorityvalue:4;
-	unsigned int   /* reserved */ : 26;
-
-	/* White Balance/Exposure Statistic Configuration, Part 1 */
-	uint8_t        exposurestatregions:1;
-	uint8_t        exposurestatsubregions:1;
-	unsigned int   /* reserved */ : 14;
-
-	unsigned int   whitebalanceminimumy:8;
-	unsigned int   whitebalancemaximumy:8;
-
-	/* White Balance/Exposure Statistic Configuration, Part 2 */
-	uint8_t wb_expstatslopeofneutralregionline[
-		NUM_WB_EXP_NEUTRAL_REGION_LINES];
-
-	/* White Balance/Exposure Statistic Configuration, Part 3 */
-	unsigned int   wb_expstatcrinterceptofneutralregionline2:12;
-	unsigned int   /* reserved */ : 4;
-	unsigned int   wb_expstatcbinterceptofneutralreginnline1:12;
-	unsigned int    /* reserved */ : 4;
-
-	/* White Balance/Exposure Statistic Configuration, Part 4 */
-	unsigned int   wb_expstatcrinterceptofneutralregionline4:12;
-	unsigned int   /* reserved */ : 4;
-	unsigned int   wb_expstatcbinterceptofneutralregionline3:12;
-	unsigned int   /* reserved */ : 4;
-
-	/* White Balance/Exposure Statistic Output Buffer Header */
-	unsigned int   wb_expmetricheaderpattern:8;
-	unsigned int   /* reserved */ : 24;
-
-	/* White Balance/Exposure Statistic Output Buffers-MUST
-	* BE 64 bit ALIGNED */
-	void  *wb_expstatoutputbuffer[NUM_WB_EXP_STAT_OUTPUT_BUFFERS];
-} __attribute__((packed, aligned(4)));
-
-struct vfe_stats_af_cfg {
-	uint32_t header;
-
-	/* Autofocus Statistic Selection */
-	uint8_t       af_enable:1;
-	uint8_t       af_busprioritysel:1;
-	unsigned int  af_buspriorityval:4;
-	unsigned int  /* reserved */ : 26;
-
-	/* Autofocus Statistic Configuration, Part 1 */
-	unsigned int  af_singlewinvoffset:12;
-	unsigned int  /* reserved */ : 4;
-	unsigned int  af_singlewinhoffset:12;
-	unsigned int  /* reserved */ : 3;
-	uint8_t       af_winmode:1;
-
-	/* Autofocus Statistic Configuration, Part 2 */
-	unsigned int  af_singglewinvh:11;
-	unsigned int  /* reserved */ : 5;
-	unsigned int  af_singlewinhw:11;
-	unsigned int  /* reserved */ : 5;
-
-	/* Autofocus Statistic Configuration, Parts 3-6 */
-	uint8_t       af_multiwingrid[NUM_AUTOFOCUS_MULTI_WINDOW_GRIDS];
-
-	/* Autofocus Statistic Configuration, Part 7 */
-	signed int    af_metrichpfcoefa00:5;
-	signed int    af_metrichpfcoefa04:5;
-	unsigned int  af_metricmaxval:11;
-	uint8_t       af_metricsel:1;
-	unsigned int  /* reserved */ : 10;
-
-	/* Autofocus Statistic Configuration, Part 8 */
-	signed int    af_metrichpfcoefa20:5;
-	signed int    af_metrichpfcoefa21:5;
-	signed int    af_metrichpfcoefa22:5;
-	signed int    af_metrichpfcoefa23:5;
-	signed int    af_metrichpfcoefa24:5;
-	unsigned int  /* reserved */ : 7;
-
-	/* Autofocus Statistic Output Buffer Header */
-	unsigned int  af_metrichp:8;
-	unsigned int  /* reserved */ : 24;
-
-	/* Autofocus Statistic Output Buffers - MUST BE 64 bit ALIGNED!!! */
-	void *af_outbuf[NUM_AF_STAT_OUTPUT_BUFFERS];
-} __attribute__((packed, aligned(4))); /* VFE_StatsAutofocusConfigCmdType */
-
-struct msm_camera_frame_msg {
-	unsigned long   output_y_address;
-	unsigned long   output_cbcr_address;
-
-	unsigned int    blacklevelevenColumn:23;
-	uint16_t        reserved1:9;
-	unsigned int    blackleveloddColumn:23;
-	uint16_t        reserved2:9;
-
-	uint16_t        greendefectpixelcount:8;
-	uint16_t        reserved3:8;
-	uint16_t        redbluedefectpixelcount:8;
-	uint16_t        reserved4:8;
-} __attribute__((packed, aligned(4)));
-
-/* New one for 7k */
-struct msm_vfe_command_7k {
-	uint16_t queue;
-	uint16_t length;
-	void     *value;
-};
-
-struct stop_event {
-  wait_queue_head_t wait;
-	int state;
-  int timeout;
-};
-
-
-#endif /* __MSM_VFE7X_H__ */
diff --git a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe7x27a.c b/drivers/media/platform/msm/camera_v1/vfe/msm_vfe7x27a.c
deleted file mode 100644
index 6b41b03..0000000
--- a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe7x27a.c
+++ /dev/null
@@ -1,745 +0,0 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. 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.
- */
-
-#include <linux/msm_adsp.h>
-#include <linux/uaccess.h>
-#include <linux/fs.h>
-
-#include <linux/slab.h>
-#include <linux/pm_qos.h>
-#include <linux/delay.h>
-#include <linux/wait.h>
-#include <mach/msm_adsp.h>
-#include <mach/clk.h>
-#include <mach/camera.h>
-#include "msm_vfe7x27a.h"
-
-#define QDSP_CMDQUEUE 25
-
-#define VFE_RESET_CMD 0
-#define VFE_START_CMD 1
-#define VFE_STOP_CMD  2
-#define VFE_FRAME_ACK 20
-#define STATS_AF_ACK  21
-#define STATS_WE_ACK  22
-
-#define MSG_STOP_ACK  1
-#define MSG_SNAPSHOT  2
-#define MSG_OUTPUT1   6
-#define MSG_OUTPUT2   7
-#define MSG_STATS_AF  8
-#define MSG_STATS_WE  9
-#define MSG_OUTPUT_S  23
-#define MSG_OUTPUT_T  22
-#define MSG_SOF       15
-
-#define VFE_ADSP_EVENT 0xFFFF
-#define SNAPSHOT_MASK_MODE 0x00000002
-#define MSM_AXI_QOS_PREVIEW	122000
-#define MSM_AXI_QOS_SNAPSHOT	192000
-
-
-static struct msm_adsp_module *qcam_mod;
-static struct msm_adsp_module *vfe_mod;
-static struct msm_vfe_callback *resp;
-static void *extdata;
-static uint32_t extlen;
-
-struct mutex vfe_lock;
-static void     *vfe_syncdata;
-static uint8_t vfestopped;
-
-static struct stop_event stopevent;
-
-unsigned long paddr_s_y;
-unsigned long paddr_s_cbcr;
-unsigned long paddr_t_y;
-unsigned long paddr_t_cbcr;
-static uint32_t op_mode;
-
-static void vfe_7x_convert(struct msm_vfe_phy_info *pinfo,
-		enum vfe_resp_msg type,
-		void *data, void **ext, int32_t *elen)
-{
-	switch (type) {
-	case VFE_MSG_OUTPUT_P: {
-		pinfo->p0_phy = ((struct vfe_endframe *)data)->y_address;
-		pinfo->p1_phy =
-			((struct vfe_endframe *)data)->cbcr_address;
-		pinfo->p2_phy = pinfo->p0_phy;
-		pinfo->output_id = OUTPUT_TYPE_P;
-
-		CDBG("vfe_7x_convert, y_phy = 0x%x, cbcr_phy = 0x%x\n",
-				 pinfo->p0_phy, pinfo->p1_phy);
-
-		memcpy(((struct vfe_frame_extra *)extdata),
-			&((struct vfe_endframe *)data)->extra,
-			sizeof(struct vfe_frame_extra));
-
-		*ext  = extdata;
-		*elen = extlen;
-		pinfo->frame_id =
-				((struct vfe_frame_extra *)extdata)->frame_id;
-	}
-		break;
-	case VFE_MSG_OUTPUT_S: {
-		pinfo->p0_phy = paddr_s_y;
-		pinfo->p1_phy = paddr_s_cbcr;
-		pinfo->p2_phy = pinfo->p0_phy;
-		pinfo->output_id = OUTPUT_TYPE_S;
-		CDBG("vfe_7x_convert: y_phy = 0x%x cbcr_phy = 0x%x\n",
-					pinfo->p0_phy, pinfo->p1_phy);
-	}
-		break;
-	case VFE_MSG_OUTPUT_T: {
-		pinfo->p0_phy = paddr_t_y;
-		pinfo->p1_phy = paddr_t_cbcr;
-		pinfo->p2_phy = pinfo->p0_phy;
-		pinfo->output_id = OUTPUT_TYPE_T;
-		CDBG("vfe_7x_convert: y_phy = 0x%x cbcr_phy = 0x%x\n",
-					pinfo->p0_phy, pinfo->p1_phy);
-	}
-		break;
-	case VFE_MSG_STATS_AF:
-	case VFE_MSG_STATS_WE:
-		pinfo->sbuf_phy = *(uint32_t *)data;
-		pinfo->frame_id = *(((uint32_t *)data) + 1);
-		CDBG("frame id = %d\n", pinfo->frame_id);
-		break;
-	default:
-		break;
-	}
-}
-
-static void vfe_7x_ops(void *driver_data, unsigned id, size_t len,
-		void (*getevent)(void *ptr, size_t len))
-{
-	uint32_t evt_buf[3];
-	struct msm_vfe_resp *rp;
-	void *data;
-	CDBG("%s:id=%d\n", __func__, id);
-
-	len = (id == VFE_ADSP_EVENT) ? 0 : len;
-	data = resp->vfe_alloc(sizeof(struct msm_vfe_resp) + len,
-		vfe_syncdata,  GFP_ATOMIC);
-
-	if (!data) {
-		pr_err("%s: rp: cannot allocate buffer\n", __func__);
-		return;
-	}
-	rp = data;
-	rp->evt_msg.len = len;
-
-	if (id == VFE_ADSP_EVENT) {
-		/* event */
-		rp->type           = VFE_EVENT;
-		rp->evt_msg.type   = MSM_CAMERA_EVT;
-		getevent(evt_buf, sizeof(evt_buf));
-		rp->evt_msg.msg_id = evt_buf[0];
-		CDBG("%s:event:msg_id=%d\n", __func__, rp->evt_msg.msg_id);
-		resp->vfe_resp(rp, MSM_CAM_Q_VFE_EVT, vfe_syncdata,
-		GFP_ATOMIC);
-	} else {
-		/* messages */
-		rp->evt_msg.type   = MSM_CAMERA_MSG;
-		rp->evt_msg.msg_id = id;
-		rp->evt_msg.data = rp + 1;
-		getevent(rp->evt_msg.data, len);
-		CDBG("%s:messages:msg_id=%d\n", __func__, rp->evt_msg.msg_id);
-
-		switch (rp->evt_msg.msg_id) {
-		case MSG_SNAPSHOT:
-			msm_camio_set_perf_lvl(S_PREVIEW);
-			vfe_7x_ops(driver_data, MSG_OUTPUT_S, len, getevent);
-			vfe_7x_ops(driver_data, MSG_OUTPUT_T, len, getevent);
-			rp->type = VFE_MSG_SNAPSHOT;
-			break;
-		case MSG_OUTPUT_S:
-			rp->type = VFE_MSG_OUTPUT_S;
-			vfe_7x_convert(&(rp->phy), VFE_MSG_OUTPUT_S,
-					rp->evt_msg.data, &(rp->extdata),
-					&(rp->extlen));
-			break;
-		case MSG_OUTPUT_T:
-			rp->type = VFE_MSG_OUTPUT_T;
-			vfe_7x_convert(&(rp->phy), VFE_MSG_OUTPUT_T,
-					rp->evt_msg.data, &(rp->extdata),
-					&(rp->extlen));
-			break;
-		case MSG_OUTPUT1:
-		case MSG_OUTPUT2:
-			if (op_mode & SNAPSHOT_MASK_MODE) {
-				resp->vfe_free(data);
-				return;
-			}
-			rp->type = VFE_MSG_OUTPUT_P;
-			vfe_7x_convert(&(rp->phy), VFE_MSG_OUTPUT_P,
-				rp->evt_msg.data, &(rp->extdata),
-				&(rp->extlen));
-			break;
-		case MSG_STATS_AF:
-			rp->type = VFE_MSG_STATS_AF;
-			vfe_7x_convert(&(rp->phy), VFE_MSG_STATS_AF,
-					rp->evt_msg.data, NULL, NULL);
-			break;
-		case MSG_STATS_WE:
-			rp->type = VFE_MSG_STATS_WE;
-			vfe_7x_convert(&(rp->phy), VFE_MSG_STATS_WE,
-					rp->evt_msg.data, NULL, NULL);
-
-			CDBG("MSG_STATS_WE: phy = 0x%x\n", rp->phy.sbuf_phy);
-			break;
-		case MSG_STOP_ACK:
-			rp->type = VFE_MSG_GENERAL;
-			stopevent.state = 1;
-			wake_up(&stopevent.wait);
-			break;
-		default:
-			rp->type = VFE_MSG_GENERAL;
-			break;
-		}
-		if (id != MSG_SOF)
-			resp->vfe_resp(rp, MSM_CAM_Q_VFE_MSG,
-					vfe_syncdata, GFP_ATOMIC);
-	}
-}
-
-static struct msm_adsp_ops vfe_7x_sync = {
-	.event = vfe_7x_ops,
-};
-
-static int vfe_7x_enable(struct camera_enable_cmd *enable)
-{
-	int rc = -EFAULT;
-	static int cnt;
-
-	if (!strcmp(enable->name, "QCAMTASK"))
-		rc = msm_adsp_enable(qcam_mod);
-	else if (!strcmp(enable->name, "VFETASK"))
-		rc = msm_adsp_enable(vfe_mod);
-
-	if (!cnt) {
-		msm_camio_set_perf_lvl(S_INIT);
-		cnt++;
-	}
-	return rc;
-}
-
-static int vfe_7x_disable(struct camera_enable_cmd *enable,
-		struct platform_device *dev __attribute__((unused)))
-{
-	int rc = -EFAULT;
-
-	if (!strcmp(enable->name, "QCAMTASK"))
-		rc = msm_adsp_disable(qcam_mod);
-	else if (!strcmp(enable->name, "VFETASK"))
-		rc = msm_adsp_disable(vfe_mod);
-
-	return rc;
-}
-
-static int vfe_7x_stop(void)
-{
-	int rc = 0;
-	uint32_t stopcmd = VFE_STOP_CMD;
-	rc = msm_adsp_write(vfe_mod, QDSP_CMDQUEUE,
-				&stopcmd, sizeof(uint32_t));
-	if (rc < 0) {
-		CDBG("%s:%d: failed rc = %d\n", __func__, __LINE__, rc);
-		return rc;
-	}
-
-	stopevent.state = 0;
-	rc = wait_event_timeout(stopevent.wait,
-		stopevent.state != 0,
-		msecs_to_jiffies(stopevent.timeout));
-
-	return rc;
-}
-
-static void vfe_7x_release(struct platform_device *pdev)
-{
-	mutex_lock(&vfe_lock);
-	vfe_syncdata = NULL;
-	mutex_unlock(&vfe_lock);
-
-	if (!vfestopped) {
-		CDBG("%s:%d:Calling vfe_7x_stop()\n", __func__, __LINE__);
-		vfe_7x_stop();
-	} else
-		vfestopped = 0;
-
-	msm_adsp_disable(qcam_mod);
-	msm_adsp_disable(vfe_mod);
-
-	msm_adsp_put(qcam_mod);
-	msm_adsp_put(vfe_mod);
-
-	msm_camio_disable(pdev);
-
-	kfree(extdata);
-	extlen = 0;
-
-	msm_camio_set_perf_lvl(S_EXIT);
-}
-
-static int vfe_7x_init(struct msm_vfe_callback *presp,
-	struct platform_device *dev)
-{
-	int rc = 0;
-
-	init_waitqueue_head(&stopevent.wait);
-	stopevent.timeout = 200;
-	stopevent.state = 0;
-
-	if (presp && presp->vfe_resp)
-		resp = presp;
-	else
-		return -EFAULT;
-
-	/* Bring up all the required GPIOs and Clocks */
-	rc = msm_camio_enable(dev);
-	if (rc < 0)
-		return rc;
-
-	extlen = sizeof(struct vfe_frame_extra);
-
-	extdata = kmalloc(extlen, GFP_ATOMIC);
-	if (!extdata) {
-		rc = -ENOMEM;
-		goto init_fail;
-	}
-
-	rc = msm_adsp_get("QCAMTASK", &qcam_mod, &vfe_7x_sync, NULL);
-	if (rc) {
-		rc = -EBUSY;
-		goto get_qcam_fail;
-	}
-
-	rc = msm_adsp_get("VFETASK", &vfe_mod, &vfe_7x_sync, NULL);
-	if (rc) {
-		rc = -EBUSY;
-		goto get_vfe_fail;
-	}
-
-	return 0;
-
-get_vfe_fail:
-	msm_adsp_put(qcam_mod);
-get_qcam_fail:
-	kfree(extdata);
-init_fail:
-	extlen = 0;
-	return rc;
-}
-
-static int vfe_7x_config_axi(int mode,
-	struct axidata *ad, struct axiout *ao)
-{
-	struct msm_pmem_region *regptr;
-	unsigned long *bptr;
-	int    cnt;
-
-	int rc = 0;
-
-	if (mode == OUTPUT_1 || mode == OUTPUT_1_AND_2) {
-		regptr = ad->region;
-
-		CDBG("bufnum1 = %d\n", ad->bufnum1);
-		if (mode == OUTPUT_1_AND_2) {
-			paddr_t_y = regptr->paddr + regptr->info.planar0_off;
-			paddr_t_cbcr = regptr->paddr +
-			regptr->info.planar1_off;
-		}
-
-		CDBG("config_axi1: O1, phy = 0x%lx, y_off = %d, cbcr_off =%d\n",
-			regptr->paddr, regptr->info.planar0_off,
-			regptr->info.planar1_off);
-
-		bptr = &ao->output1buffer1_y_phy;
-		for (cnt = 0; cnt < ad->bufnum1; cnt++) {
-			*bptr = regptr->paddr + regptr->info.planar0_off;
-			bptr++;
-			*bptr = regptr->paddr + regptr->info.planar1_off;
-
-			bptr++;
-			regptr++;
-		}
-
-		regptr--;
-		for (cnt = 0; cnt < (8 - ad->bufnum1); cnt++) {
-			*bptr = regptr->paddr + regptr->info.planar0_off;
-			bptr++;
-			*bptr = regptr->paddr + regptr->info.planar1_off;
-			bptr++;
-		}
-	}
-
-	if (mode == OUTPUT_2 || mode == OUTPUT_1_AND_2) {
-		regptr = &(ad->region[ad->bufnum1]);
-
-		CDBG("bufnum2 = %d\n", ad->bufnum2);
-		paddr_s_y = regptr->paddr +  regptr->info.planar0_off;
-		paddr_s_cbcr = regptr->paddr +  regptr->info.planar1_off;
-
-		CDBG("config_axi2: O2, phy = 0x%lx, y_off = %d, cbcr_off =%d\n",
-			regptr->paddr, regptr->info.planar0_off,
-			regptr->info.planar1_off);
-
-		bptr = &ao->output2buffer1_y_phy;
-		for (cnt = 0; cnt < ad->bufnum2; cnt++) {
-			*bptr = regptr->paddr + regptr->info.planar0_off;
-			bptr++;
-			*bptr = regptr->paddr + regptr->info.planar1_off;
-
-			bptr++;
-			regptr++;
-		}
-
-		regptr--;
-		for (cnt = 0; cnt < (8 - ad->bufnum2); cnt++) {
-			*bptr = regptr->paddr + regptr->info.planar0_off;
-			bptr++;
-			*bptr = regptr->paddr + regptr->info.planar1_off;
-			bptr++;
-		}
-	}
-
-	return rc;
-}
-
-static int vfe_7x_config(struct msm_vfe_cfg_cmd *cmd, void *data)
-{
-	struct msm_pmem_region *regptr;
-	unsigned char buf[256];
-
-	struct vfe_stats_ack sack;
-	struct axidata *axid;
-	uint32_t i;
-	uint32_t *_mode;
-
-	struct vfe_stats_we_cfg *scfg = NULL;
-	struct vfe_stats_af_cfg *sfcfg = NULL;
-
-	struct axiout *axio = NULL;
-	void   *cmd_data = NULL;
-	void   *cmd_data_alloc = NULL;
-	long rc = 0;
-	struct msm_vfe_command_7k *vfecmd;
-
-	vfecmd = kmalloc(sizeof(struct msm_vfe_command_7k), GFP_ATOMIC);
-	if (!vfecmd) {
-		pr_err("vfecmd alloc failed!\n");
-		return -ENOMEM;
-	}
-
-	if (cmd->cmd_type != CMD_FRAME_BUF_RELEASE &&
-	    cmd->cmd_type != CMD_STATS_BUF_RELEASE &&
-	    cmd->cmd_type != CMD_STATS_AF_BUF_RELEASE) {
-		if (copy_from_user(vfecmd,
-				(void __user *)(cmd->value),
-				sizeof(struct msm_vfe_command_7k))) {
-			rc = -EFAULT;
-			goto config_failure;
-		}
-	}
-
-	switch (cmd->cmd_type) {
-	case CMD_STATS_AEC_AWB_ENABLE:
-	case CMD_STATS_AXI_CFG: {
-		axid = data;
-		if (!axid) {
-			rc = -EFAULT;
-			goto config_failure;
-		}
-
-		scfg =
-			kmalloc(sizeof(struct vfe_stats_we_cfg),
-				GFP_ATOMIC);
-		if (!scfg) {
-			rc = -ENOMEM;
-			goto config_failure;
-		}
-
-		if (copy_from_user(scfg,
-					(void __user *)(vfecmd->value),
-					vfecmd->length)) {
-
-			rc = -EFAULT;
-			goto config_done;
-		}
-
-		CDBG("STATS_ENABLE: bufnum = %d, enabling = %d\n",
-			axid->bufnum1, scfg->wb_expstatsenable);
-
-		if (axid->bufnum1 > 0) {
-			regptr = axid->region;
-
-			for (i = 0; i < axid->bufnum1; i++) {
-
-				CDBG("STATS_ENABLE, phy = 0x%lx\n",
-					regptr->paddr);
-
-				scfg->wb_expstatoutputbuffer[i] =
-					(void *)regptr->paddr;
-				regptr++;
-			}
-
-			cmd_data = scfg;
-
-		} else {
-			rc = -EINVAL;
-			goto config_done;
-		}
-	}
-		break;
-	case CMD_STATS_AF_ENABLE:
-	case CMD_STATS_AF_AXI_CFG: {
-		axid = data;
-		if (!axid) {
-			rc = -EFAULT;
-			goto config_failure;
-		}
-
-		sfcfg =
-			kmalloc(sizeof(struct vfe_stats_af_cfg),
-				GFP_ATOMIC);
-
-		if (!sfcfg) {
-			rc = -ENOMEM;
-			goto config_failure;
-		}
-
-		if (copy_from_user(sfcfg,
-					(void __user *)(vfecmd->value),
-					vfecmd->length)) {
-
-			rc = -EFAULT;
-			goto config_done;
-		}
-
-		CDBG("AF_ENABLE: bufnum = %d, enabling = %d\n",
-			axid->bufnum1, sfcfg->af_enable);
-
-		if (axid->bufnum1 > 0) {
-			regptr = &axid->region[0];
-
-			for (i = 0; i < axid->bufnum1; i++) {
-
-				CDBG("STATS_ENABLE, phy = 0x%lx\n",
-					regptr->paddr);
-
-				sfcfg->af_outbuf[i] =
-					(void *)regptr->paddr;
-
-				regptr++;
-			}
-
-			cmd_data = sfcfg;
-
-		} else {
-			rc = -EINVAL;
-			goto config_done;
-		}
-	}
-		break;
-	case CMD_FRAME_BUF_RELEASE: {
-		struct msm_frame *b;
-		unsigned long p;
-		struct vfe_outputack fack;
-		if (!data)  {
-			rc = -EFAULT;
-			goto config_failure;
-		}
-
-		b = (struct msm_frame *)(cmd->value);
-		p = *(unsigned long *)data;
-
-		fack.header = VFE_FRAME_ACK;
-
-		fack.output2newybufferaddress =
-			(void *)(p + b->planar0_off);
-
-		fack.output2newcbcrbufferaddress =
-			(void *)(p + b->planar1_off);
-
-		vfecmd->queue = QDSP_CMDQUEUE;
-		vfecmd->length = sizeof(struct vfe_outputack);
-		cmd_data = &fack;
-	}
-		break;
-	case CMD_SNAP_BUF_RELEASE:
-		break;
-	case CMD_STATS_BUF_RELEASE: {
-		CDBG("vfe_7x_config: CMD_STATS_BUF_RELEASE\n");
-		if (!data) {
-			rc = -EFAULT;
-			goto config_failure;
-		}
-
-		sack.header = STATS_WE_ACK;
-		sack.bufaddr = (void *)*(uint32_t *)data;
-
-		vfecmd->queue  = QDSP_CMDQUEUE;
-		vfecmd->length = sizeof(struct vfe_stats_ack);
-		cmd_data = &sack;
-	}
-		break;
-	case CMD_STATS_AF_BUF_RELEASE: {
-		CDBG("vfe_7x_config: CMD_STATS_AF_BUF_RELEASE\n");
-		if (!data) {
-			rc = -EFAULT;
-			goto config_failure;
-		}
-
-		sack.header = STATS_AF_ACK;
-		sack.bufaddr = (void *)*(uint32_t *)data;
-
-		vfecmd->queue  = QDSP_CMDQUEUE;
-		vfecmd->length = sizeof(struct vfe_stats_ack);
-		cmd_data = &sack;
-	}
-		break;
-	case CMD_GENERAL:
-	case CMD_STATS_DISABLE: {
-		if (vfecmd->length > 256) {
-			cmd_data_alloc =
-			cmd_data = kmalloc(vfecmd->length, GFP_ATOMIC);
-			if (!cmd_data) {
-				rc = -ENOMEM;
-				goto config_failure;
-			}
-		} else
-			cmd_data = buf;
-
-		if (copy_from_user(cmd_data,
-					(void __user *)(vfecmd->value),
-					vfecmd->length)) {
-
-			rc = -EFAULT;
-			goto config_done;
-		}
-
-		if (vfecmd->queue == QDSP_CMDQUEUE) {
-			switch (*(uint32_t *)cmd_data) {
-			case VFE_RESET_CMD:
-				msm_camio_vfe_blk_reset();
-				vfestopped = 0;
-				break;
-			case VFE_START_CMD:
-				_mode = (uint32_t *)cmd_data;
-				op_mode = *(++_mode);
-				if (op_mode & SNAPSHOT_MASK_MODE)
-					msm_camio_set_perf_lvl(S_CAPTURE);
-				else
-					msm_camio_set_perf_lvl(S_PREVIEW);
-				vfestopped = 0;
-				break;
-			case VFE_STOP_CMD:
-				vfestopped = 1;
-				goto config_send;
-
-			default:
-				break;
-			}
-		} /* QDSP_CMDQUEUE */
-	}
-		break;
-	case CMD_AXI_CFG_PREVIEW:
-	case CMD_RAW_PICT_AXI_CFG: {
-		axid = data;
-		if (!axid) {
-			rc = -EFAULT;
-			goto config_failure;
-		}
-
-		axio = kmalloc(sizeof(struct axiout), GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			goto config_failure;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd->value),
-					sizeof(struct axiout))) {
-			rc = -EFAULT;
-			goto config_done;
-		}
-
-		vfe_7x_config_axi(OUTPUT_2, axid, axio);
-		cmd_data = axio;
-	}
-		break;
-	case CMD_AXI_CFG_SNAP: {
-		axid = data;
-		if (!axid) {
-			rc = -EFAULT;
-			goto config_failure;
-		}
-
-		axio = kmalloc(sizeof(struct axiout), GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			goto config_failure;
-		}
-
-		if (copy_from_user(axio, (void __user *)(vfecmd->value),
-					sizeof(struct axiout))) {
-			rc = -EFAULT;
-			goto config_done;
-		}
-
-		vfe_7x_config_axi(OUTPUT_1_AND_2, axid, axio);
-
-		cmd_data = axio;
-	}
-		break;
-	default:
-		break;
-	}
-
-	if (vfestopped)
-		goto config_done;
-
-config_send:
-	CDBG("send adsp command = %d\n", *(uint32_t *)cmd_data);
-	rc = msm_adsp_write(vfe_mod, vfecmd->queue,
-				cmd_data, vfecmd->length);
-
-config_done:
-	kfree(cmd_data_alloc);
-
-config_failure:
-	kfree(scfg);
-	kfree(axio);
-	kfree(vfecmd);
-	return rc;
-}
-
-void msm_camvfe_fn_init(struct msm_camvfe_fn *fptr, void *data)
-{
-	mutex_init(&vfe_lock);
-	fptr->vfe_init    = vfe_7x_init;
-	fptr->vfe_enable  = vfe_7x_enable;
-	fptr->vfe_config  = vfe_7x_config;
-	fptr->vfe_disable = vfe_7x_disable;
-	fptr->vfe_release = vfe_7x_release;
-	vfe_syncdata = data;
-}
-
-void msm_camvpe_fn_init(struct msm_camvpe_fn *fptr, void *data)
-{
-	fptr->vpe_reg		= NULL;
-	fptr->send_frame_to_vpe	= NULL;
-	fptr->vpe_config	= NULL;
-	fptr->vpe_cfg_update	= NULL;
-	fptr->dis		= NULL;
-}
diff --git a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe7x27a.h b/drivers/media/platform/msm/camera_v1/vfe/msm_vfe7x27a.h
deleted file mode 100644
index fbebb60..0000000
--- a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe7x27a.h
+++ /dev/null
@@ -1,300 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- */
-
-#ifndef __MSM_VFE7X_H__
-#define __MSM_VFE7X_H__
-#include <media/msm_camera.h>
-#include <mach/camera.h>
-
-struct vfe_frame_extra {
-	uint32_t	bl_evencol:23;
-	uint32_t	rvd1:9;
-	uint32_t	bl_oddcol:23;
-	uint32_t	rvd2:9;
-
-	uint32_t	d_dbpc_stats_hot:16;
-	uint32_t	d_dbpc_stats_cold:16;
-
-	uint32_t	d_dbpc_stats_0_hot:10;
-	uint32_t	rvd3:6;
-	uint32_t	d_dbpc_stats_0_cold:10;
-	uint32_t	rvd4:6;
-	uint32_t	d_dbpc_stats_1_hot:10;
-	uint32_t	rvd5:6;
-	uint32_t	d_dbpc_stats_1_cold:10;
-	uint32_t	rvd6:6;
-
-	uint32_t	asf_max_edge;
-
-	uint32_t	e_y_wm_pm_stats_0:21;
-	uint32_t	rvd7:11;
-	uint32_t	e_y_wm_pm_stats_1_bl:8;
-	uint32_t	rvd8:8;
-	uint32_t	e_y_wm_pm_stats_1_nl:12;
-	uint32_t	rvd9:4;
-
-	uint32_t	e_cbcr_wm_pm_stats_0:21;
-	uint32_t	rvd10:11;
-	uint32_t	e_cbcr_wm_pm_stats_1_bl:8;
-	uint32_t	rvd11:8;
-	uint32_t	e_cbcr_wm_pm_stats_1_nl:12;
-	uint32_t	rvd12:4;
-
-	uint32_t	v_y_wm_pm_stats_0:21;
-	uint32_t	rvd13:11;
-	uint32_t	v_y_wm_pm_stats_1_bl:8;
-	uint32_t	rvd14:8;
-	uint32_t	v_y_wm_pm_stats_1_nl:12;
-	uint32_t	rvd15:4;
-
-	uint32_t	v_cbcr_wm_pm_stats_0:21;
-	uint32_t	rvd16:11;
-	uint32_t	v_cbcr_wm_pm_stats_1_bl:8;
-	uint32_t	rvd17:8;
-	uint32_t	v_cbcr_wm_pm_stats_1_nl:12;
-	uint32_t	rvd18:4;
-
-	uint32_t      frame_id;
-};
-
-struct vfe_endframe {
-	uint32_t      y_address;
-	uint32_t      cbcr_address;
-
-	struct vfe_frame_extra extra;
-} __packed;
-
-struct vfe_outputack {
-	uint32_t  header;
-	void      *output2newybufferaddress;
-	void      *output2newcbcrbufferaddress;
-} __packed;
-
-struct vfe_stats_ack {
-	uint32_t header;
-	/* MUST BE 64 bit ALIGNED */
-	void     *bufaddr;
-} __packed;
-
-/* AXI Output Config Command sent to DSP */
-struct axiout {
-	uint32_t            cmdheader:32;
-	int                 outputmode:3;
-	uint8_t             format:2;
-	uint32_t            /* reserved */ : 27;
-
-	/* AXI Output 1 Y Configuration, Part 1 */
-	uint32_t            out1yimageheight:12;
-	uint32_t            /* reserved */ : 4;
-	uint32_t            out1yimagewidthin64bitwords:10;
-	uint32_t            /* reserved */ : 6;
-
-	/* AXI Output 1 Y Configuration, Part 2 */
-	uint8_t             out1yburstlen:2;
-	uint32_t            out1ynumrows:12;
-	uint32_t            out1yrowincin64bitincs:12;
-	uint32_t            /* reserved */ : 6;
-
-	/* AXI Output 1 CbCr Configuration, Part 1 */
-	uint32_t            out1cbcrimageheight:12;
-	uint32_t            /* reserved */ : 4;
-	uint32_t            out1cbcrimagewidthin64bitwords:10;
-	uint32_t            /* reserved */ : 6;
-
-	/* AXI Output 1 CbCr Configuration, Part 2 */
-	uint8_t             out1cbcrburstlen:2;
-	uint32_t            out1cbcrnumrows:12;
-	uint32_t            out1cbcrrowincin64bitincs:12;
-	uint32_t            /* reserved */ : 6;
-
-	/* AXI Output 2 Y Configuration, Part 1 */
-	uint32_t            out2yimageheight:12;
-	uint32_t            /* reserved */ : 4;
-	uint32_t            out2yimagewidthin64bitwords:10;
-	uint32_t            /* reserved */ : 6;
-
-	/* AXI Output 2 Y Configuration, Part 2 */
-	uint8_t             out2yburstlen:2;
-	uint32_t            out2ynumrows:12;
-	uint32_t            out2yrowincin64bitincs:12;
-	uint32_t            /* reserved */ : 6;
-
-	/* AXI Output 2 CbCr Configuration, Part 1 */
-	uint32_t            out2cbcrimageheight:12;
-	uint32_t            /* reserved */ : 4;
-	uint32_t            out2cbcrimagewidtein64bitwords:10;
-	uint32_t            /* reserved */ : 6;
-
-	/* AXI Output 2 CbCr Configuration, Part 2 */
-	uint8_t             out2cbcrburstlen:2;
-	uint32_t            out2cbcrnumrows:12;
-	uint32_t            out2cbcrrowincin64bitincs:12;
-	uint32_t            /* reserved */ : 6;
-
-	/* Address configuration:
-	 * output1 phisycal address */
-	unsigned long   output1buffer1_y_phy;
-	unsigned long   output1buffer1_cbcr_phy;
-	unsigned long   output1buffer2_y_phy;
-	unsigned long   output1buffer2_cbcr_phy;
-	unsigned long   output1buffer3_y_phy;
-	unsigned long   output1buffer3_cbcr_phy;
-	unsigned long   output1buffer4_y_phy;
-	unsigned long   output1buffer4_cbcr_phy;
-	unsigned long   output1buffer5_y_phy;
-	unsigned long   output1buffer5_cbcr_phy;
-	unsigned long   output1buffer6_y_phy;
-	unsigned long   output1buffer6_cbcr_phy;
-	unsigned long   output1buffer7_y_phy;
-	unsigned long   output1buffer7_cbcr_phy;
-	unsigned long   output1buffer8_y_phy;
-	unsigned long   output1buffer8_cbcr_phy;
-
-	/* output2 phisycal address */
-	unsigned long   output2buffer1_y_phy;
-	unsigned long   output2buffer1_cbcr_phy;
-	unsigned long   output2buffer2_y_phy;
-	unsigned long   output2buffer2_cbcr_phy;
-	unsigned long   output2buffer3_y_phy;
-	unsigned long   output2buffer3_cbcr_phy;
-	unsigned long   output2buffer4_y_phy;
-	unsigned long   output2buffer4_cbcr_phy;
-	unsigned long   output2buffer5_y_phy;
-	unsigned long   output2buffer5_cbcr_phy;
-	unsigned long   output2buffer6_y_phy;
-	unsigned long   output2buffer6_cbcr_phy;
-	unsigned long   output2buffer7_y_phy;
-	unsigned long   output2buffer7_cbcr_phy;
-	unsigned long   output2buffer8_y_phy;
-	unsigned long   output2buffer8_cbcr_phy;
-} __packed;
-
-struct vfe_stats_we_cfg {
-	uint32_t       header;
-
-	/* White Balance/Exposure Statistic Selection */
-	uint8_t        wb_expstatsenable:1;
-	uint8_t        wb_expstatbuspriorityselection:1;
-	unsigned int   wb_expstatbuspriorityvalue:4;
-	unsigned int   /* reserved */ : 26;
-
-	/* White Balance/Exposure Statistic Configuration, Part 1 */
-	uint8_t        exposurestatregions:1;
-	uint8_t        exposurestatsubregions:1;
-	unsigned int   /* reserved */ : 14;
-
-	unsigned int   whitebalanceminimumy:8;
-	unsigned int   whitebalancemaximumy:8;
-
-	/* White Balance/Exposure Statistic Configuration, Part 2 */
-	uint8_t wb_expstatslopeofneutralregionline[
-		NUM_WB_EXP_NEUTRAL_REGION_LINES];
-
-	/* White Balance/Exposure Statistic Configuration, Part 3 */
-	unsigned int   wb_expstatcrinterceptofneutralregionline2:12;
-	unsigned int   /* reserved */ : 4;
-	unsigned int   wb_expstatcbinterceptofneutralreginnline1:12;
-	unsigned int    /* reserved */ : 4;
-
-	/* White Balance/Exposure Statistic Configuration, Part 4 */
-	unsigned int   wb_expstatcrinterceptofneutralregionline4:12;
-	unsigned int   /* reserved */ : 4;
-	unsigned int   wb_expstatcbinterceptofneutralregionline3:12;
-	unsigned int   /* reserved */ : 4;
-
-	/* White Balance/Exposure Statistic Output Buffer Header */
-	unsigned int   wb_expmetricheaderpattern:8;
-	unsigned int   /* reserved */ : 24;
-
-	/* White Balance/Exposure Statistic Output Buffers-MUST
-	* BE 64 bit ALIGNED */
-	void  *wb_expstatoutputbuffer[NUM_WB_EXP_STAT_OUTPUT_BUFFERS];
-} __packed;
-
-struct vfe_stats_af_cfg {
-	uint32_t header;
-
-	/* Autofocus Statistic Selection */
-	uint8_t       af_enable:1;
-	uint8_t       af_busprioritysel:1;
-	unsigned int  af_buspriorityval:4;
-	unsigned int  /* reserved */ : 26;
-
-	/* Autofocus Statistic Configuration, Part 1 */
-	unsigned int  af_singlewinvoffset:12;
-	unsigned int  /* reserved */ : 4;
-	unsigned int  af_singlewinhoffset:12;
-	unsigned int  /* reserved */ : 3;
-	uint8_t       af_winmode:1;
-
-	/* Autofocus Statistic Configuration, Part 2 */
-	unsigned int  af_singglewinvh:11;
-	unsigned int  /* reserved */ : 5;
-	unsigned int  af_singlewinhw:11;
-	unsigned int  /* reserved */ : 5;
-
-	/* Autofocus Statistic Configuration, Parts 3-6 */
-	uint8_t       af_multiwingrid[NUM_AUTOFOCUS_MULTI_WINDOW_GRIDS];
-
-	/* Autofocus Statistic Configuration, Part 7 */
-	signed int    af_metrichpfcoefa00:5;
-	signed int    af_metrichpfcoefa04:5;
-	unsigned int  af_metricmaxval:11;
-	uint8_t       af_metricsel:1;
-	unsigned int  /* reserved */ : 10;
-
-	/* Autofocus Statistic Configuration, Part 8 */
-	signed int    af_metrichpfcoefa20:5;
-	signed int    af_metrichpfcoefa21:5;
-	signed int    af_metrichpfcoefa22:5;
-	signed int    af_metrichpfcoefa23:5;
-	signed int    af_metrichpfcoefa24:5;
-	unsigned int  /* reserved */ : 7;
-
-	/* Autofocus Statistic Output Buffer Header */
-	unsigned int  af_metrichp:8;
-	unsigned int  /* reserved */ : 24;
-
-	/* Autofocus Statistic Output Buffers - MUST BE 64 bit ALIGNED!!! */
-	void *af_outbuf[NUM_AF_STAT_OUTPUT_BUFFERS];
-} __packed; /* VFE_StatsAutofocusConfigCmdType */
-
-struct msm_camera_frame_msg {
-	unsigned long   output_y_address;
-	unsigned long   output_cbcr_address;
-
-	unsigned int    blacklevelevenColumn:23;
-	uint16_t        reserved1:9;
-	unsigned int    blackleveloddColumn:23;
-	uint16_t        reserved2:9;
-
-	uint16_t        greendefectpixelcount:8;
-	uint16_t        reserved3:8;
-	uint16_t        redbluedefectpixelcount:8;
-	uint16_t        reserved4:8;
-} __packed;
-
-/* New one for 7k */
-struct msm_vfe_command_7k {
-	uint16_t queue;
-	uint16_t length;
-	void     *value;
-};
-
-struct stop_event {
-	wait_queue_head_t wait;
-	int state;
-	int timeout;
-};
-
-
-#endif /* __MSM_VFE7X_H__ */
diff --git a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe7x27a_v4l2.c b/drivers/media/platform/msm/camera_v1/vfe/msm_vfe7x27a_v4l2.c
deleted file mode 100644
index 3a8f1b2..0000000
--- a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe7x27a_v4l2.c
+++ /dev/null
@@ -1,2479 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#include <linux/msm_adsp.h>
-#include <linux/uaccess.h>
-#include <linux/fs.h>
-
-#include <linux/slab.h>
-#include <linux/pm_qos.h>
-#include <linux/delay.h>
-#include <linux/wait.h>
-#include <linux/module.h>
-#include <media/v4l2-device.h>
-#include <media/v4l2-subdev.h>
-#include <media/msm_isp.h>
-#include <mach/msm_adsp.h>
-#include <linux/clk.h>
-#include <mach/clk.h>
-#include <mach/camera.h>
-#include "msm_vfe7x27a_v4l2.h"
-#include "msm.h"
-
-/* ADSP Messages */
-#define MSG_RESET_ACK  0
-#define MSG_STOP_ACK  1
-#define MSG_SNAPSHOT  2
-#define MSG_ILLEGAL_COMMAND  3
-#define MSG_START_ACK  4
-#define MSG_UPDATE_ACK  5
-#define MSG_OUTPUT1  6
-#define MSG_OUTPUT2  7
-#define MSG_STATS_AF  8
-#define MSG_STATS_WE  9
-#define MSG_STATS_HISTOGRAM  10
-#define MSG_EPOCH1  11
-#define MSG_EPOCH2  12
-#define MSG_VFE_ERROR 13
-#define MSG_SYNC_TIMER1_DONE  14
-#define MSG_SYNC_TIMER2_DONE  15
-#define MSG_ASYNC_TIMER1_DONE  16
-#define MSG_ASYNC_TIMER2_DONE  17
-#define MSG_CAPTURE_COMPLETE  18
-#define MSG_TABLE_CMD_ACK  19
-#define MSG_EXP_TIMEOUT_ACK  20
-#define MSG_SOF  21
-#define MSG_OUTPUT_T  22
-#define MSG_OUTPUT_S  23
-
-#define VFE_ADSP_EVENT 0xFFFF
-#define SNAPSHOT_MASK_MODE 0x00000001
-#define MSM_AXI_QOS_PREVIEW	122000
-#define MSM_AXI_QOS_SNAPSHOT	192000
-
-
-#define QDSP_CMDQUEUE 25
-#define QDSP_SCALEQUEUE 26
-#define QDSP_TABLEQUEUE 27
-
-/* ADSP Scler queue Cmd IDs */
-#define VFE_SCALE_OUTPUT1_CONFIG  0
-#define VFE_SCALE_OUTPUT2_CONFIG  1
-#define VFE_SCALE_MAX  0xFFFFFFFF
-
-/* ADSP table queue Cmd IDs */
-#define VFE_AXI_INPUT_CONFIG  0
-#define VFE_AXI_OUTPUT_CONFIG  1
-#define VFE_RGB_GAMMA_CONFIG  2
-#define VFE_Y_GAMMA_CONFIG  3
-#define VFE_ROLL_OFF_CONFIG  4
-#define VFE_DEMOSAICv3_BPC_CFG  6
-#define VFE_DEMOSAICv3_ABF_CFG  7
-#define VFE_DEMOSAICv3_CFG  8
-#define VFE_MAX  0xFFFFFFFF
-
-/* ADSP cfg queue cmd IDs */
-#define VFE_RESET  0
-#define VFE_START  1
-#define VFE_STOP  2
-#define VFE_UPDATE  3
-#define VFE_CAMIF_CONFIG  4
-#define VFE_ACTIVE_REGION_CONFIG  5
-#define VFE_DEMOSAIC_CONFIG  6
-#define VFE_INPUT_FORMAT_CONFIG  7
-#define VFE_OUTPUT_CLAMP_CONFIG  8
-#define VFE_CHROMA_SUBSAMPLE_CONFIG  9
-#define VFE_BLACK_LEVEL_CONFIG  10
-#define VFE_WHITE_BALANCE_CONFIG  11
-#define VFE_COLOR_PROCESSING_CONFIG  12
-#define VFE_ADAPTIVE_FILTER_CONFIG  13
-#define VFE_FRAME_SKIP_CONFIG  14
-#define VFE_FOV_CROP  15
-#define VFE_STATS_AUTOFOCUS_CONFIG  16
-#define VFE_STATS_WB_EXP_CONFIG  17
-#define VFE_STATS_HISTOGRAM_CONFIG  18
-#define VFE_OUTPUT1_ACK  19
-#define VFE_OUTPUT2_ACK  20
-#define VFE_STATS_AUTOFOCUS_ACK  21
-#define VFE_STATS_WB_EXP_ACK  22
-#define VFE_EPOCH1_ACK  23
-#define VFE_EPOCH2_ACK  24
-#define VFE_UPDATE_CAMIF_FRAME_CONFIG  25
-#define VFE_SYNC_TIMER1_CONFIG  26
-#define VFE_SYNC_TIMER2_CONFIG  27
-#define VFE_ASYNC_TIMER1_START  28
-#define VFE_ASYNC_TIMER2_START  29
-#define VFE_STATS_AUTOFOCUS_UPDATE  30
-#define VFE_STATS_WB_EXP_UPDATE  31
-#define VFE_ROLL_OFF_UPDATE  33
-#define VFE_DEMOSAICv3_BPC_UPDATE  34
-#define VFE_TESTGEN_START  35
-#define VFE_STATS_MA  0xFFFFFFFF
-
-struct msg_id_map msgs_map[] = {
-	{MSG_RESET_ACK, MSG_ID_RESET_ACK},
-	{MSG_STOP_ACK, MSG_ID_STOP_ACK},
-	{MSG_SNAPSHOT, MSG_ID_SNAPSHOT_DONE},
-	{MSG_ILLEGAL_COMMAND, VFE_MAX},
-	{MSG_START_ACK, MSG_ID_START_ACK},
-	{MSG_UPDATE_ACK, MSG_ID_UPDATE_ACK},
-	{MSG_OUTPUT1, VFE_MAX},
-	{MSG_OUTPUT2, VFE_MAX},
-	{MSG_STATS_AF, MSG_ID_STATS_AF},
-	{MSG_STATS_WE, MSG_ID_STATS_AWB_AEC},
-	{MSG_STATS_HISTOGRAM, MSG_ID_STATS_IHIST},
-	{MSG_EPOCH1, MSG_ID_EPOCH1},
-	{MSG_EPOCH2, MSG_ID_EPOCH2},
-	{MSG_VFE_ERROR, MSG_ID_CAMIF_ERROR},
-	{MSG_SYNC_TIMER1_DONE, MSG_ID_SYNC_TIMER1_DONE},
-	{MSG_SYNC_TIMER2_DONE, MSG_ID_SYNC_TIMER2_DONE},
-	{MSG_ASYNC_TIMER1_DONE, MSG_ID_ASYNC_TIMER1_DONE},
-	{MSG_ASYNC_TIMER2_DONE, MSG_ID_ASYNC_TIMER2_DONE},
-	{MSG_CAPTURE_COMPLETE, MSG_CAPTURE_COMPLETE},
-	{MSG_TABLE_CMD_ACK, MSG_TABLE_CMD_ACK},
-	{MSG_EXP_TIMEOUT_ACK, MSG_EXP_TIMEOUT_ACK},
-	{MSG_SOF, MSG_ID_SOF_ACK},
-	{MSG_OUTPUT_T, MSG_ID_OUTPUT_T},
-	{MSG_OUTPUT_S, MSG_ID_OUTPUT_S},
-};
-
-struct cmd_id_map cmds_map[] = {
-	{VFE_CMD_DUMMY_0, VFE_MAX, VFE_MAX},
-	{VFE_CMD_SET_CLK, VFE_MAX, VFE_MAX},
-	{VFE_CMD_RESET, VFE_RESET, QDSP_CMDQUEUE,
-			"VFE_CMD_RESET", "VFE_RESET"},
-	{VFE_CMD_START, VFE_START, QDSP_CMDQUEUE,
-			"VFE_CMD_START", "VFE_START"},
-	{VFE_CMD_TEST_GEN_START, VFE_TESTGEN_START, QDSP_CMDQUEUE,
-		"VFE_CMD_TEST_GEN_START", "VFE_TESTGEN_START"},
-	{VFE_CMD_OPERATION_CFG, VFE_MAX , VFE_MAX},
-	{VFE_CMD_AXI_OUT_CFG, VFE_AXI_OUTPUT_CONFIG, QDSP_TABLEQUEUE,
-		"VFE_CMD_AXI_OUT_CFG", "VFE_AXI_OUTPUT_CONFIG"},
-	{VFE_CMD_CAMIF_CFG, VFE_CAMIF_CONFIG, QDSP_CMDQUEUE,
-			"VFE_CMD_CAMIF_CFG", "VFE_CAMIF_CONFIG"},
-	{VFE_CMD_AXI_INPUT_CFG, VFE_AXI_INPUT_CONFIG, QDSP_TABLEQUEUE,
-		"VFE_CMD_AXI_INPUT_CFG", "VFE_AXI_INPUT_CONFIG"},
-	{VFE_CMD_BLACK_LEVEL_CFG, VFE_BLACK_LEVEL_CONFIG, QDSP_CMDQUEUE,
-		"VFE_CMD_BLACK_LEVEL_CFG", "VFE_BLACK_LEVEL_CONFIG"},
-	{VFE_CMD_MESH_ROLL_OFF_CFG, VFE_ROLL_OFF_CONFIG, QDSP_TABLEQUEUE,
-		"VFE_CMD_MESH_ROLL_OFF_CFG", "VFE_ROLL_OFF_CONFIG"},
-	{VFE_CMD_DEMUX_CFG, VFE_INPUT_FORMAT_CONFIG, QDSP_CMDQUEUE,
-		"VFE_CMD_DEMUX_CFG", "VFE_INPUT_FORMAT_CONFIG"},
-	{VFE_CMD_FOV_CFG, VFE_FOV_CROP, QDSP_CMDQUEUE,
-		"VFE_CMD_FOV_CFG", "VFE_FOV_CROP"},
-	{VFE_CMD_MAIN_SCALER_CFG, VFE_MAX, VFE_MAX},
-	{VFE_CMD_WB_CFG, VFE_WHITE_BALANCE_CONFIG, QDSP_CMDQUEUE,
-		"VFE_CMD_WB_CFG", "VFE_WHITE_BALANCE_CONFIG"},
-	{VFE_CMD_COLOR_COR_CFG, VFE_MAX, VFE_MAX},
-	{VFE_CMD_RGB_G_CFG, VFE_RGB_GAMMA_CONFIG, QDSP_TABLEQUEUE,
-		"VFE_CMD_RGB_G_CFG", "VFE_RGB_GAMMA_CONFIG"},
-	{VFE_CMD_LA_CFG, VFE_MAX, VFE_MAX},
-	{VFE_CMD_CHROMA_EN_CFG, VFE_MAX, VFE_MAX},
-	{VFE_CMD_CHROMA_SUP_CFG, VFE_MAX, VFE_MAX},
-	{VFE_CMD_MCE_CFG, VFE_MAX, VFE_MAX},
-	{VFE_CMD_SK_ENHAN_CFG, VFE_MAX, VFE_MAX},
-	{VFE_CMD_ASF_CFG, VFE_ADAPTIVE_FILTER_CONFIG, QDSP_CMDQUEUE,
-		"VFE_CMD_ASF_CFG", "VFE_ADAPTIVE_FILTER_CONFIG"},
-	{VFE_CMD_S2Y_CFG, VFE_MAX, VFE_MAX},
-	{VFE_CMD_S2CbCr_CFG, VFE_MAX, VFE_MAX},
-	{VFE_CMD_CHROMA_SUBS_CFG, VFE_CHROMA_SUBSAMPLE_CONFIG, QDSP_CMDQUEUE,
-		"VFE_CMD_CHROMA_SUBS_CFG", "VFE_CHROMA_SUBSAMPLE_CONFIG"},
-	{VFE_CMD_OUT_CLAMP_CFG, VFE_OUTPUT_CLAMP_CONFIG, QDSP_CMDQUEUE,
-		"VFE_CMD_OUT_CLAMP_CFG", "VFE_OUTPUT_CLAMP_CONFIG"},
-	{VFE_CMD_FRAME_SKIP_CFG, VFE_FRAME_SKIP_CONFIG, QDSP_CMDQUEUE,
-		"VFE_CMD_FRAME_SKIP_CFG", "VFE_FRAME_SKIP_CONFIG"},
-	{VFE_CMD_DUMMY_1, VFE_MAX, VFE_MAX},
-	{VFE_CMD_DUMMY_2, VFE_MAX, VFE_MAX},
-	{VFE_CMD_DUMMY_3, VFE_MAX, VFE_MAX},
-	{VFE_CMD_UPDATE, VFE_UPDATE, QDSP_CMDQUEUE,
-		"VFE_CMD_UPDATE", "VFE_UPDATE"},
-	{VFE_CMD_BL_LVL_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_DEMUX_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_FOV_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_MAIN_SCALER_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_WB_UPDATE, VFE_WHITE_BALANCE_CONFIG, QDSP_CMDQUEUE,
-		"VFE_CMD_WB_UPDATE", "VFE_WHITE_BALANCE_CONFIG"},
-	{VFE_CMD_COLOR_COR_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_RGB_G_UPDATE, VFE_RGB_GAMMA_CONFIG, QDSP_TABLEQUEUE,
-		"VFE_CMD_RGB_G_UPDATE", "VFE_RGB_GAMMA_CONFIG"},
-	{VFE_CMD_LA_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_CHROMA_EN_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_CHROMA_SUP_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_MCE_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_SK_ENHAN_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_S2CbCr_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_S2Y_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_ASF_UPDATE, VFE_ADAPTIVE_FILTER_CONFIG, QDSP_CMDQUEUE,
-		"VFE_CMD_ASF_UPDATE", "VFE_ADAPTIVE_FILTER_CONFIG"},
-	{VFE_CMD_FRAME_SKIP_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_CAMIF_FRAME_UPDATE, VFE_UPDATE_CAMIF_FRAME_CONFIG,
-		QDSP_CMDQUEUE, "VFE_CMD_CAMIF_FRAME_UPDATE",
-		"VFE_UPDATE_CAMIF_FRAME_CONFIG"},
-	{VFE_CMD_STATS_AF_UPDATE, VFE_STATS_AUTOFOCUS_UPDATE, QDSP_CMDQUEUE,
-		"VFE_CMD_STATS_AF_UPDATE", "VFE_STATS_AUTOFOCUS_UPDATE"},
-	{VFE_CMD_STATS_AE_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STATS_AWB_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STATS_RS_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STATS_CS_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STATS_SKIN_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STATS_IHIST_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_DUMMY_4, VFE_MAX, VFE_MAX},
-	{VFE_CMD_EPOCH1_ACK, VFE_EPOCH1_ACK, QDSP_CMDQUEUE,
-			"VFE_CMD_EPOCH1_ACK", "VFE_EPOCH1_ACK"},
-	{VFE_CMD_EPOCH2_ACK, VFE_EPOCH2_ACK, QDSP_CMDQUEUE,
-			"VFE_CMD_EPOCH2_ACK", "VFE_EPOCH2_ACK"},
-	{VFE_CMD_START_RECORDING, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STOP_RECORDING, VFE_MAX , VFE_MAX},
-	{VFE_CMD_DUMMY_5, VFE_MAX, VFE_MAX},
-	{VFE_CMD_DUMMY_6, VFE_MAX, VFE_MAX},
-	{VFE_CMD_CAPTURE, VFE_START, QDSP_CMDQUEUE,
-			"VFE_CMD_CAPTURE", "VFE_START"},
-	{VFE_CMD_DUMMY_7, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STOP, VFE_STOP, QDSP_CMDQUEUE, "VFE_CMD_STOP", "VFE_STOP"},
-	{VFE_CMD_GET_HW_VERSION, VFE_MAX, VFE_MAX},
-	{VFE_CMD_GET_FRAME_SKIP_COUNTS, VFE_MAX, VFE_MAX},
-	{VFE_CMD_OUTPUT1_BUFFER_ENQ, VFE_MAX, VFE_MAX},
-	{VFE_CMD_OUTPUT2_BUFFER_ENQ, VFE_MAX, VFE_MAX},
-	{VFE_CMD_OUTPUT3_BUFFER_ENQ, VFE_MAX, VFE_MAX},
-	{VFE_CMD_JPEG_OUT_BUF_ENQ, VFE_MAX, VFE_MAX},
-	{VFE_CMD_RAW_OUT_BUF_ENQ, VFE_MAX, VFE_MAX},
-	{VFE_CMD_RAW_IN_BUF_ENQ, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STATS_AF_ENQ, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STATS_AE_ENQ, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STATS_AWB_ENQ, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STATS_RS_ENQ, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STATS_CS_ENQ, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STATS_SKIN_ENQ, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STATS_IHIST_ENQ, VFE_MAX, VFE_MAX},
-	{VFE_CMD_DUMMY_8, VFE_MAX, VFE_MAX},
-	{VFE_CMD_JPEG_ENC_CFG, VFE_MAX, VFE_MAX},
-	{VFE_CMD_DUMMY_9, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STATS_AF_START, VFE_STATS_AUTOFOCUS_CONFIG, QDSP_CMDQUEUE,
-		"VFE_CMD_STATS_AF_START", "VFE_STATS_AUTOFOCUS_CONFIG"},
-	{VFE_CMD_STATS_AF_STOP, VFE_STATS_AUTOFOCUS_CONFIG, QDSP_CMDQUEUE,
-		"VFE_CMD_STATS_AF_STOP", "VFE_STATS_AUTOFOCUS_CONFIG"},
-	{VFE_CMD_STATS_AE_START, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STATS_AE_STOP, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STATS_AWB_START, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STATS_AWB_STOP, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STATS_RS_START, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STATS_RS_STOP, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STATS_CS_START, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STATS_CS_STOP, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STATS_SKIN_START, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STATS_SKIN_STOP, VFE_MAX, VFE_MAX},
-	{VFE_CMD_STATS_IHIST_START, VFE_STATS_HISTOGRAM_CONFIG, QDSP_CMDQUEUE,
-		"VFE_CMD_STATS_IHIST_START", "VFE_STATS_HISTOGRAM_CONFIG"},
-	{VFE_CMD_STATS_IHIST_STOP, VFE_MAX, VFE_MAX},
-	{VFE_CMD_DUMMY_10, VFE_MAX, VFE_MAX},
-	{VFE_CMD_SYNC_TIMER_SETTING, VFE_MAX, VFE_MAX},
-	{VFE_CMD_ASYNC_TIMER_SETTING, VFE_MAX, VFE_MAX},
-	{VFE_CMD_LIVESHOT, VFE_MAX, VFE_MAX},
-	{VFE_CMD_LA_SETUP, VFE_MAX, VFE_MAX},
-	{VFE_CMD_LINEARIZATION_CFG, VFE_MAX, VFE_MAX},
-	{VFE_CMD_DEMOSAICV3, VFE_DEMOSAICv3_CFG, QDSP_TABLEQUEUE,
-		"VFE_CMD_DEMOSAICV3", "VFE_DEMOSAICv3_CFG"},
-	{VFE_CMD_DEMOSAICV3_ABCC_CFG, VFE_MAX, VFE_MAX},
-	{VFE_CMD_DEMOSAICV3_DBCC_CFG, VFE_MAX, VFE_MAX},
-	{VFE_CMD_DEMOSAICV3_DBPC_CFG, VFE_DEMOSAICv3_BPC_CFG, QDSP_TABLEQUEUE,
-		"VFE_CMD_DEMOSAICV3_DBPC_CFG", "VFE_DEMOSAICv3_BPC_CFG"},
-	{VFE_CMD_DEMOSAICV3_ABF_CFG, VFE_DEMOSAICv3_ABF_CFG, QDSP_TABLEQUEUE,
-		"VFE_CMD_DEMOSAICV3_ABF_CFG", "VFE_DEMOSAICv3_ABF_CFG"},
-	{VFE_CMD_DEMOSAICV3_ABCC_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_DEMOSAICV3_DBCC_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_DEMOSAICV3_DBPC_UPDATE, VFE_DEMOSAICv3_BPC_UPDATE,
-		QDSP_CMDQUEUE, "VFE_CMD_DEMOSAICV3_DBPC_UPDATE",
-		"VFE_DEMOSAICv3_BPC_UPDATE"},
-	{VFE_CMD_XBAR_CFG, VFE_MAX, VFE_MAX},
-	{VFE_CMD_MODULE_CFG, VFE_MAX, VFE_MAX},
-	{VFE_CMD_ZSL, VFE_START, QDSP_CMDQUEUE,
-			"VFE_CMD_ZSL", "VFE_START"},
-	{VFE_CMD_LINEARIZATION_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_DEMOSAICV3_ABF_UPDATE, VFE_DEMOSAICv3_ABF_CFG,
-		QDSP_TABLEQUEUE, "VFE_CMD_DEMOSAICV3_ABF_UPDATE",
-		"VFE_DEMOSAICv3_ABF_CFG"},
-	{VFE_CMD_CLF_CFG, VFE_MAX, VFE_MAX},
-	{VFE_CMD_CLF_LUMA_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_CLF_CHROMA_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_PCA_ROLL_OFF_CFG, VFE_MAX, VFE_MAX},
-	{VFE_CMD_PCA_ROLL_OFF_UPDATE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_GET_REG_DUMP, VFE_MAX, VFE_MAX},
-	{VFE_CMD_GET_LINEARIZATON_TABLE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_GET_MESH_ROLLOFF_TABLE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_GET_PCA_ROLLOFF_TABLE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_GET_RGB_G_TABLE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_GET_LA_TABLE, VFE_MAX, VFE_MAX},
-	{VFE_CMD_DEMOSAICV3_UPDATE, VFE_DEMOSAICv3_CFG, QDSP_TABLEQUEUE,
-		"VFE_CMD_DEMOSAICV3_UPDATE", "VFE_DEMOSAICv3_CFG"},
-	{VFE_CMD_ACTIVE_REGION_CFG, VFE_ACTIVE_REGION_CONFIG, QDSP_CMDQUEUE,
-		"VFE_CMD_ACTIVE_REGION_CFG", "VFE_ACTIVE_REGION_CONFIG"},
-	{VFE_CMD_COLOR_PROCESSING_CONFIG, VFE_COLOR_PROCESSING_CONFIG,
-		QDSP_CMDQUEUE, "VFE_CMD_COLOR_PROCESSING_CONFIG",
-		"VFE_COLOR_PROCESSING_CONFIG"},
-	{VFE_CMD_STATS_WB_AEC_CONFIG, VFE_STATS_WB_EXP_CONFIG, QDSP_CMDQUEUE,
-		"VFE_CMD_STATS_WB_AEC_CONFIG", "VFE_STATS_WB_EXP_CONFIG"},
-	{VFE_CMD_STATS_WB_AEC_UPDATE, VFE_STATS_WB_EXP_UPDATE, QDSP_CMDQUEUE,
-		"VFE_CMD_STATS_WB_AEC_UPDATE", "VFE_STATS_WB_EXP_UPDATE"},
-	{VFE_CMD_Y_GAMMA_CONFIG, VFE_Y_GAMMA_CONFIG, QDSP_TABLEQUEUE,
-		"VFE_CMD_Y_GAMMA_CONFIG", "VFE_Y_GAMMA_CONFIG"},
-	{VFE_CMD_SCALE_OUTPUT1_CONFIG, VFE_SCALE_OUTPUT1_CONFIG,
-		QDSP_SCALEQUEUE, "VFE_CMD_SCALE_OUTPUT1_CONFIG",
-		"VFE_SCALE_OUTPUT1_CONFIG"},
-	{VFE_CMD_SCALE_OUTPUT2_CONFIG, VFE_SCALE_OUTPUT2_CONFIG,
-		QDSP_SCALEQUEUE, "VFE_CMD_SCALE_OUTPUT2_CONFIG",
-		"VFE_SCALE_OUTPUT2_CONFIG"},
-	{VFE_CMD_CAPTURE_RAW, VFE_START, QDSP_CMDQUEUE,
-			"VFE_CMD_CAPTURE_RAW", "VFE_START"},
-	{VFE_CMD_STOP_LIVESHOT, VFE_MAX, VFE_MAX},
-	{VFE_CMD_RECONFIG_VFE, VFE_MAX, VFE_MAX},
-};
-
-
-static struct msm_adsp_module *qcam_mod;
-static struct msm_adsp_module *vfe_mod;
-static void *extdata;
-static uint32_t extlen;
-
-struct mutex vfe_lock;
-static uint8_t vfestopped;
-
-static struct stop_event stopevent;
-
-static uint32_t op_mode;
-static uint32_t raw_mode;
-static struct vfe2x_ctrl_type *vfe2x_ctrl;
-
-static unsigned long vfe2x_stats_dqbuf(enum msm_stats_enum_type stats_type)
-{
-	struct msm_stats_meta_buf *buf = NULL;
-	int rc = 0;
-
-	rc = vfe2x_ctrl->stats_ops.dqbuf(vfe2x_ctrl->stats_ops.stats_ctrl,
-							  stats_type, &buf);
-	if (rc < 0) {
-		CDBG("%s: dq stats buf (type = %d) err = %d",
-			   __func__, stats_type, rc);
-		return 0;
-	}
-	return buf->paddr;
-}
-
-static unsigned long vfe2x_stats_flush_enqueue(
-	enum msm_stats_enum_type stats_type)
-{
-	struct msm_stats_bufq *bufq = NULL;
-	struct msm_stats_meta_buf *stats_buf = NULL;
-	int rc = 0;
-	int i;
-
-	/*
-	 * Passing NULL for ion client as the buffers are already
-	 * mapped at this stage, client is not required, flush all
-	 * the buffers, and buffers move to PREPARE state
-	 */
-	rc = vfe2x_ctrl->stats_ops.bufq_flush(
-			vfe2x_ctrl->stats_ops.stats_ctrl,
-			stats_type, NULL);
-	if (rc < 0) {
-		pr_err("%s: dq stats buf (type = %d) err = %d",
-			 __func__, stats_type, rc);
-		return 0L;
-	}
-
-	/* Queue all the buffers back to QUEUED state */
-	bufq = vfe2x_ctrl->stats_ctrl.bufq[stats_type];
-	for (i = 0; i < bufq->num_bufs; i++) {
-		stats_buf = &bufq->bufs[i];
-		rc = vfe2x_ctrl->stats_ops.enqueue_buf(
-				vfe2x_ctrl->stats_ops.stats_ctrl,
-				&(stats_buf->info), NULL, -1);
-			if (rc < 0) {
-				pr_err("%s: dq stats buf (type = %d) err = %d",
-					 __func__, stats_type, rc);
-				return rc;
-			}
-	}
-	return 0L;
-}
-
-static unsigned long vfe2x_stats_unregbuf(
-	struct msm_stats_reqbuf *req_buf)
-{
-	int i = 0, rc = 0;
-
-	for (i = 0; i < req_buf->num_buf; i++) {
-		rc = vfe2x_ctrl->stats_ops.buf_unprepare(
-			vfe2x_ctrl->stats_ops.stats_ctrl,
-			req_buf->stats_type, i,
-			vfe2x_ctrl->stats_ops.client, -1);
-		if (rc < 0) {
-			pr_err("%s: unreg stats buf (type = %d) err = %d",
-				__func__, req_buf->stats_type, rc);
-		return rc;
-		}
-	}
-	return 0L;
-}
-
-static int vfe2x_stats_buf_init(enum msm_stats_enum_type type)
-{
-	unsigned long flags;
-	int i = 0, rc = 0;
-	if (type == MSM_STATS_TYPE_AF) {
-		spin_lock_irqsave(&vfe2x_ctrl->stats_bufq_lock, flags);
-		rc = vfe2x_stats_flush_enqueue(MSM_STATS_TYPE_AF);
-		if (rc < 0) {
-			pr_err("%s: dq stats buf err = %d",
-				 __func__, rc);
-			spin_unlock_irqrestore(&vfe2x_ctrl->stats_bufq_lock,
-				flags);
-			return -EINVAL;
-		}
-		spin_unlock_irqrestore(&vfe2x_ctrl->stats_bufq_lock, flags);
-	}
-	for (i = 0; i < 3; i++) {
-		spin_lock_irqsave(&vfe2x_ctrl->stats_bufq_lock, flags);
-		if (type == MSM_STATS_TYPE_AE_AW)
-			vfe2x_ctrl->stats_we_buf_ptr[i] =
-				vfe2x_stats_dqbuf(type);
-		else
-			vfe2x_ctrl->stats_af_buf_ptr[i] =
-				vfe2x_stats_dqbuf(type);
-		spin_unlock_irqrestore(&vfe2x_ctrl->stats_bufq_lock, flags);
-		if (!vfe2x_ctrl->stats_we_buf_ptr[i]) {
-			pr_err("%s: dq error type %d ", __func__, type);
-			return -ENOMEM;
-		}
-	}
-	return rc;
-}
-
-static unsigned long vfe2x_stats_enqueuebuf(
-	struct msm_stats_buf_info *info, struct vfe_stats_ack *sack)
-{
-	struct msm_stats_bufq *bufq = NULL;
-	struct msm_stats_meta_buf *stats_buf = NULL;
-	struct msm_stats_meta_buf *buf = NULL;
-	int rc = 0;
-
-	bufq = vfe2x_ctrl->stats_ctrl.bufq[info->type];
-	stats_buf = &bufq->bufs[info->buf_idx];
-
-	CDBG("vfe2x_stats_enqueuebuf: %d\n", stats_buf->state);
-	if (stats_buf->state == MSM_STATS_BUFFER_STATE_INITIALIZED ||
-		stats_buf->state == MSM_STATS_BUFFER_STATE_PREPARED) {
-		rc = vfe2x_ctrl->stats_ops.enqueue_buf(
-				&vfe2x_ctrl->stats_ctrl,
-				info, vfe2x_ctrl->stats_ops.client, -1);
-		if (rc < 0) {
-			pr_err("%s: enqueue_buf (type = %d), index : %d, err = %d",
-				 __func__, info->type, info->buf_idx, rc);
-			return rc;
-		}
-
-	} else {
-		rc = vfe2x_ctrl->stats_ops.querybuf(
-				vfe2x_ctrl->stats_ops.stats_ctrl, info, &buf);
-		if (rc < 0) {
-			pr_err("%s: querybuf (type = %d), index : %d, err = %d",
-				__func__, info->type, info->buf_idx, rc);
-			return rc;
-	}
-		stats_buf->state = MSM_STATS_BUFFER_STATE_DEQUEUED;
-	if (info->type == MSM_STATS_TYPE_AE_AW) {
-		sack->header = VFE_STATS_WB_EXP_ACK;
-		sack->bufaddr = (void *)(uint32_t *)buf->paddr;
-	} else if (info->type == MSM_STATS_TYPE_AF) {
-		sack->header = VFE_STATS_AUTOFOCUS_ACK;
-		sack->bufaddr = (void *)(uint32_t *)buf->paddr;
-	} else
-		pr_err("%s: Invalid stats: should never come here\n", __func__);
-	}
-	return 0L;
-}
-
-static long vfe2x_stats_bufq_sub_ioctl(struct msm_vfe_cfg_cmd *cmd,
-	void *ion_client)
-{
-	long rc = 0;
-
-	switch (cmd->cmd_type) {
-	case VFE_CMD_STATS_REQBUF:
-		if (!vfe2x_ctrl->stats_ops.stats_ctrl) {
-			/* stats_ctrl has not been init yet */
-			rc = msm_stats_buf_ops_init(
-					&vfe2x_ctrl->stats_ctrl,
-					(struct ion_client *)ion_client,
-					&vfe2x_ctrl->stats_ops);
-			if (rc < 0) {
-				pr_err("%s: cannot init stats ops", __func__);
-				goto end;
-			}
-			rc = vfe2x_ctrl->stats_ops.stats_ctrl_init(
-					&vfe2x_ctrl->stats_ctrl);
-			if (rc < 0) {
-				pr_err("%s: cannot init stats_ctrl ops",
-					 __func__);
-				memset(&vfe2x_ctrl->stats_ops, 0,
-				sizeof(vfe2x_ctrl->stats_ops));
-				goto end;
-			}
-			if (sizeof(struct msm_stats_reqbuf) != cmd->length) {
-				/* error. the length not match */
-				pr_err("%s: stats reqbuf input size = %d,\n"
-					"struct size = %d, mismatch\n",
-					__func__, cmd->length,
-					sizeof(struct msm_stats_reqbuf));
-				rc = -EINVAL;
-				goto end;
-			}
-		}
-		rc = vfe2x_ctrl->stats_ops.reqbuf(
-				&vfe2x_ctrl->stats_ctrl,
-				(struct msm_stats_reqbuf *)cmd->value,
-				vfe2x_ctrl->stats_ops.client);
-		break;
-		case VFE_CMD_STATS_ENQUEUEBUF: {
-			if (sizeof(struct msm_stats_buf_info) != cmd->length) {
-				/* error. the length not match */
-				pr_err("%s: stats enqueuebuf input size = %d,\n"
-					"struct size = %d, mismatch\n",
-					 __func__, cmd->length,
-					sizeof(struct msm_stats_buf_info));
-				rc = -EINVAL;
-				goto end;
-		}
-		rc = vfe2x_ctrl->stats_ops.enqueue_buf(
-				&vfe2x_ctrl->stats_ctrl,
-				(struct msm_stats_buf_info *)cmd->value,
-				vfe2x_ctrl->stats_ops.client, -1);
-	}
-	break;
-	case VFE_CMD_STATS_FLUSH_BUFQ: {
-		struct msm_stats_flush_bufq *flush_req = NULL;
-		flush_req = (struct msm_stats_flush_bufq *)cmd->value;
-		if (sizeof(struct msm_stats_flush_bufq) != cmd->length) {
-			/* error. the length not match */
-			pr_err("%s: stats flush queue input size = %d,\n"
-				"struct size = %d, mismatch\n",
-				__func__, cmd->length,
-				sizeof(struct msm_stats_flush_bufq));
-				rc = -EINVAL;
-				goto end;
-		}
-		rc = vfe2x_ctrl->stats_ops.bufq_flush(
-				&vfe2x_ctrl->stats_ctrl,
-				(enum msm_stats_enum_type)flush_req->stats_type,
-				vfe2x_ctrl->stats_ops.client);
-	}
-	break;
-	case VFE_CMD_STATS_UNREGBUF:
-	{
-		struct msm_stats_reqbuf *req_buf = NULL;
-		req_buf = (struct msm_stats_reqbuf *)cmd->value;
-		if (sizeof(struct msm_stats_reqbuf) != cmd->length) {
-			/* error. the length not match */
-			pr_err("%s: stats reqbuf input size = %d,\n"
-				"struct size = %d, mitch match\n",
-				 __func__, cmd->length,
-				sizeof(struct msm_stats_reqbuf));
-			rc = -EINVAL ;
-			goto end;
-		}
-		rc = vfe2x_stats_unregbuf(req_buf);
-	}
-	break;
-	default:
-		rc = -1;
-		pr_err("%s: cmd_type %d not supported",
-			 __func__, cmd->cmd_type);
-	break;
-	}
-end:
-	return rc;
-}
-
-static void vfe2x_send_isp_msg(
-	struct vfe2x_ctrl_type *vctrl,
-	uint32_t isp_msg_id)
-{
-	struct isp_msg_event isp_msg_evt;
-
-	isp_msg_evt.msg_id = isp_msg_id;
-	isp_msg_evt.sof_count = vfe2x_ctrl->vfeFrameId;
-	v4l2_subdev_notify(&vctrl->subdev,
-			NOTIFY_ISP_MSG_EVT,
-			(void *)&isp_msg_evt);
-}
-
-static void vfe_send_outmsg(struct v4l2_subdev *sd, uint8_t msgid,
-		uint32_t ch0_paddr, uint32_t ch1_paddr)
-{
-	struct isp_msg_output msg;
-
-	msg.output_id = msgid;
-	msg.buf.inst_handle = 0;
-	msg.buf.ch_paddr[0]     = ch0_paddr;
-	msg.buf.ch_paddr[1]     = ch1_paddr;
-	msg.frameCounter = vfe2x_ctrl->vfeFrameId;
-
-	v4l2_subdev_notify(&vfe2x_ctrl->subdev,
-			NOTIFY_VFE_MSG_OUT,
-			&msg);
-	return;
-}
-
-static void vfe_send_stats_msg(uint32_t buf_addr, uint32_t msg_id)
-{
-	struct isp_msg_stats msg_stats;
-	void *vaddr = NULL;
-	int rc;
-
-	msg_stats.frameCounter = vfe2x_ctrl->vfeFrameId;
-	msg_stats.buffer       = buf_addr;
-	msg_stats.id           = msg_id;
-
-	if (MSG_ID_STATS_AWB_AEC == msg_id)
-		rc = vfe2x_ctrl->stats_ops.dispatch(
-			vfe2x_ctrl->stats_ops.stats_ctrl,
-			MSM_STATS_TYPE_AE_AW, buf_addr,
-			&msg_stats.buf_idx, &vaddr, &msg_stats.fd,
-			vfe2x_ctrl->stats_ops.client);
-	else if (MSG_ID_STATS_AF == msg_id)
-		rc = vfe2x_ctrl->stats_ops.dispatch(
-			vfe2x_ctrl->stats_ops.stats_ctrl,
-			MSM_STATS_TYPE_AF, buf_addr,
-			&msg_stats.buf_idx, &vaddr, &msg_stats.fd,
-			vfe2x_ctrl->stats_ops.client);
-
-	v4l2_subdev_notify(&vfe2x_ctrl->subdev,
-				NOTIFY_VFE_MSG_STATS,
-				&msg_stats);
-}
-
-static void vfe_7x_ops(void *driver_data, unsigned id, size_t len,
-		void (*getevent)(void *ptr, size_t len))
-{
-	uint32_t evt_buf[3];
-	void *data = NULL;
-	struct buf_info *outch = NULL;
-	uint32_t y_phy, cbcr_phy;
-	static uint32_t liveshot_y_phy;
-	static struct vfe_endframe liveshot_swap;
-	struct table_cmd *table_pending = NULL;
-	unsigned long flags;
-	void   *cmd_data = NULL;
-	unsigned char buf[256];
-	struct msm_free_buf *free_buf = NULL;
-	struct vfe_outputack fack;
-	int i;
-
-	CDBG("%s:id=%d\n", __func__, id);
-	if (id != VFE_ADSP_EVENT) {
-		data = kzalloc(len, GFP_ATOMIC);
-		if (!data) {
-			pr_err("%s: rp: cannot allocate buffer\n", __func__);
-			return;
-		}
-	}
-	if (id == VFE_ADSP_EVENT) {
-		/* event */
-		getevent(evt_buf, sizeof(evt_buf));
-		CDBG("%s:event:msg_id=%d\n", __func__, id);
-	} else {
-		/* messages */
-		getevent(data, len);
-		CDBG("%s:messages:msg_id=%d\n", __func__, id);
-
-		switch (id) {
-		case MSG_SNAPSHOT:
-			while (vfe2x_ctrl->snap.frame_cnt <
-				vfe2x_ctrl->num_snap) {
-				vfe_7x_ops(driver_data, MSG_OUTPUT_S, len,
-					getevent);
-				if (!raw_mode)
-					vfe_7x_ops(driver_data, MSG_OUTPUT_T,
-						len, getevent);
-			}
-			vfe2x_send_isp_msg(vfe2x_ctrl, MSG_ID_SNAPSHOT_DONE);
-			kfree(data);
-			return;
-		case MSG_OUTPUT_S:
-			outch = &vfe2x_ctrl->snap;
-			if (outch->frame_cnt == 0) {
-				y_phy = outch->ping.ch_paddr[0];
-				cbcr_phy = outch->ping.ch_paddr[1];
-			} else if (outch->frame_cnt == 1) {
-				y_phy = outch->pong.ch_paddr[0];
-				cbcr_phy = outch->pong.ch_paddr[1];
-			} else if (outch->frame_cnt == 2) {
-				y_phy = outch->free_buf.ch_paddr[0];
-				cbcr_phy = outch->free_buf.ch_paddr[1];
-			} else {
-				y_phy = outch->free_buf_arr[outch->frame_cnt
-					- 3].ch_paddr[0];
-				cbcr_phy = outch->free_buf_arr[outch->frame_cnt
-					- 3].ch_paddr[1];
-			}
-			outch->frame_cnt++;
-			CDBG("MSG_OUTPUT_S: %x %x %d\n",
-				(unsigned int)y_phy, (unsigned int)cbcr_phy,
-					outch->frame_cnt);
-			vfe_send_outmsg(&vfe2x_ctrl->subdev,
-					MSG_ID_OUTPUT_PRIMARY,
-						y_phy, cbcr_phy);
-			break;
-		case MSG_OUTPUT_T:
-			outch = &vfe2x_ctrl->thumb;
-			if (outch->frame_cnt == 0) {
-				y_phy = outch->ping.ch_paddr[0];
-				cbcr_phy = outch->ping.ch_paddr[1];
-			} else if (outch->frame_cnt == 1) {
-				y_phy = outch->pong.ch_paddr[0];
-				cbcr_phy = outch->pong.ch_paddr[1];
-			} else if (outch->frame_cnt == 2) {
-				y_phy = outch->free_buf.ch_paddr[0];
-				cbcr_phy = outch->free_buf.ch_paddr[1];
-			} else {
-				y_phy = outch->free_buf_arr[outch->frame_cnt
-					- 3].ch_paddr[0];
-				cbcr_phy = outch->free_buf_arr[outch->frame_cnt
-					- 3].ch_paddr[1];
-			}
-			outch->frame_cnt++;
-			CDBG("MSG_OUTPUT_T: %x %x %d\n",
-				(unsigned int)y_phy, (unsigned int)cbcr_phy,
-				outch->frame_cnt);
-			vfe_send_outmsg(&vfe2x_ctrl->subdev,
-						MSG_ID_OUTPUT_SECONDARY,
-							y_phy, cbcr_phy);
-			break;
-		case MSG_OUTPUT1:
-			if (op_mode & SNAPSHOT_MASK_MODE) {
-				kfree(data);
-				return;
-			} else {
-				free_buf = vfe2x_check_free_buffer(
-							VFE_MSG_OUTPUT_IRQ,
-							VFE_MSG_OUTPUT_SECONDARY
-							);
-				CDBG("free_buf = %x\n",
-						(unsigned int) free_buf);
-				if (free_buf) {
-					fack.header = VFE_OUTPUT1_ACK;
-
-					fack.output2newybufferaddress =
-						(void *)(free_buf->ch_paddr[0]);
-
-					fack.output2newcbcrbufferaddress =
-						(void *)(free_buf->ch_paddr[1]);
-
-					cmd_data = &fack;
-					len = sizeof(fack);
-					msm_adsp_write(vfe_mod, QDSP_CMDQUEUE,
-							cmd_data, len);
-			      } else {
-					fack.header = VFE_OUTPUT1_ACK;
-					fack.output2newybufferaddress =
-					(void *)
-				((struct vfe_endframe *)data)->y_address;
-					fack.output2newcbcrbufferaddress =
-					(void *)
-				((struct vfe_endframe *)data)->cbcr_address;
-					cmd_data = &fack;
-					len = sizeof(fack);
-					msm_adsp_write(vfe_mod, QDSP_CMDQUEUE,
-						cmd_data, len);
-					if (!vfe2x_ctrl->zsl_mode) {
-						kfree(data);
-						return;
-					}
-				}
-			}
-			y_phy = ((struct vfe_endframe *)data)->y_address;
-			cbcr_phy = ((struct vfe_endframe *)data)->cbcr_address;
-
-
-			CDBG("vfe_7x_convert, y_phy = 0x%x, cbcr_phy = 0x%x\n",
-				 y_phy, cbcr_phy);
-			if (free_buf) {
-				for (i = 0; i < 3; i++) {
-					if (vfe2x_ctrl->free_buf.buf[i].
-							ch_paddr[0] == y_phy) {
-						vfe2x_ctrl->free_buf.
-							buf[i].ch_paddr[0] =
-							free_buf->ch_paddr[0];
-						vfe2x_ctrl->free_buf.
-							buf[i].ch_paddr[1] =
-							free_buf->ch_paddr[1];
-						break;
-					}
-				}
-				if (i == 3)
-					CDBG("Address doesnt match\n");
-			}
-			memcpy(((struct vfe_frame_extra *)extdata),
-				&((struct vfe_endframe *)data)->extra,
-				sizeof(struct vfe_frame_extra));
-
-			vfe2x_ctrl->vfeFrameId =
-				((struct vfe_frame_extra *)extdata)->frame_id;
-			vfe_send_outmsg(&vfe2x_ctrl->subdev,
-						MSG_ID_OUTPUT_SECONDARY,
-						y_phy, cbcr_phy);
-			break;
-		case MSG_OUTPUT2:
-			if (op_mode & SNAPSHOT_MASK_MODE) {
-				kfree(data);
-				return;
-			}
-			if (vfe2x_ctrl->liveshot_enabled)
-				free_buf = vfe2x_check_free_buffer(
-					VFE_MSG_OUTPUT_IRQ,
-					VFE_MSG_V2X_LIVESHOT_PRIMARY);
-			else
-				free_buf = vfe2x_check_free_buffer(
-					VFE_MSG_OUTPUT_IRQ,
-					VFE_MSG_OUTPUT_PRIMARY);
-			CDBG("free_buf = %x\n",
-					(unsigned int) free_buf);
-			spin_lock_irqsave(
-					&vfe2x_ctrl->liveshot_enabled_lock,
-					flags);
-			if (!vfe2x_ctrl->liveshot_enabled) {
-				spin_unlock_irqrestore(
-						&vfe2x_ctrl->
-						liveshot_enabled_lock,
-						flags);
-				if (free_buf) {
-					fack.header = VFE_OUTPUT2_ACK;
-
-					fack.output2newybufferaddress =
-						(void *)
-						(free_buf->ch_paddr[0]);
-
-					fack.output2newcbcrbufferaddress =
-						(void *)
-						(free_buf->ch_paddr[1]);
-
-					cmd_data = &fack;
-					len = sizeof(fack);
-					msm_adsp_write(vfe_mod,
-							QDSP_CMDQUEUE,
-							cmd_data, len);
-				} else {
-					fack.header = VFE_OUTPUT2_ACK;
-					fack.output2newybufferaddress =
-						(void *)
-						((struct vfe_endframe *)
-						 data)->y_address;
-					fack.output2newcbcrbufferaddress =
-						(void *)
-						((struct vfe_endframe *)
-						 data)->cbcr_address;
-					cmd_data = &fack;
-					len = sizeof(fack);
-					msm_adsp_write(vfe_mod,
-							QDSP_CMDQUEUE,
-							cmd_data, len);
-					if (!vfe2x_ctrl->zsl_mode) {
-						kfree(data);
-						return;
-					}
-				}
-			} else { /* Live snapshot */
-				spin_unlock_irqrestore(
-						&vfe2x_ctrl->
-						liveshot_enabled_lock,
-						flags);
-				if (free_buf) {
-					/* liveshot_swap to enqueue
-					   when liveshot snapshot buffer
-					   is obtainedi from adsp */
-					liveshot_swap.y_address =
-						((struct vfe_endframe *)
-						 data)->y_address;
-					liveshot_swap.cbcr_address =
-						((struct vfe_endframe *)
-						 data)->cbcr_address;
-
-					fack.header = VFE_OUTPUT2_ACK;
-
-					fack.output2newybufferaddress =
-						(void *)
-						(free_buf->ch_paddr[0]);
-
-					fack.output2newcbcrbufferaddress =
-						(void *)
-						(free_buf->ch_paddr[1]);
-
-					liveshot_y_phy =
-						(uint32_t)
-						fack.output2newybufferaddress;
-
-					cmd_data = &fack;
-					len = sizeof(fack);
-					msm_adsp_write(vfe_mod,
-							QDSP_CMDQUEUE,
-							cmd_data, len);
-				} else if (liveshot_y_phy !=
-						((struct vfe_endframe *)
-						 data)->y_address) {
-
-					fack.header = VFE_OUTPUT2_ACK;
-					fack.output2newybufferaddress =
-						(void *)
-						((struct vfe_endframe *)
-						 data)->y_address;
-
-					fack.output2newcbcrbufferaddress =
-						(void *)
-						((struct vfe_endframe *)
-						 data)->cbcr_address;
-
-					cmd_data = &fack;
-					len = sizeof(fack);
-					msm_adsp_write(vfe_mod,
-							QDSP_CMDQUEUE,
-							cmd_data, len);
-					kfree(data);
-					return;
-				} else {
-					/* Enque data got
-					 * during freebuf */
-					fack.header = VFE_OUTPUT2_ACK;
-					fack.output2newybufferaddress =
-						(void *)
-						(liveshot_swap.y_address);
-
-					fack.output2newcbcrbufferaddress =
-						(void *)
-						(liveshot_swap.cbcr_address);
-					cmd_data = &fack;
-					len = sizeof(fack);
-					msm_adsp_write(vfe_mod,
-							QDSP_CMDQUEUE,
-							cmd_data, len);
-				}
-			}
-			y_phy = ((struct vfe_endframe *)data)->
-				y_address;
-			cbcr_phy = ((struct vfe_endframe *)data)->
-				cbcr_address;
-
-
-			CDBG("MSG_OUT2:y_phy= 0x%x, cbcr_phy= 0x%x\n",
-					y_phy, cbcr_phy);
-			if (free_buf) {
-				for (i = 0; i < 3; i++) {
-					if (vfe2x_ctrl->free_buf.buf[i].
-							ch_paddr[0] == y_phy) {
-						vfe2x_ctrl->free_buf.
-							buf[i].ch_paddr[0] =
-							free_buf->ch_paddr[0];
-						vfe2x_ctrl->free_buf.
-							buf[i].ch_paddr[1] =
-							free_buf->ch_paddr[1];
-						break;
-					}
-				}
-				if (i == 3)
-					CDBG("Address doesnt match\n");
-			}
-			memcpy(((struct vfe_frame_extra *)extdata),
-					&((struct vfe_endframe *)data)->extra,
-					sizeof(struct vfe_frame_extra));
-
-			vfe2x_ctrl->vfeFrameId =
-				((struct vfe_frame_extra *)extdata)->
-				frame_id;
-
-			if (!vfe2x_ctrl->liveshot_enabled) {
-				/* Liveshot not enalbed */
-				vfe_send_outmsg(&vfe2x_ctrl->subdev,
-						MSG_ID_OUTPUT_PRIMARY,
-						y_phy, cbcr_phy);
-			} else if (liveshot_y_phy == y_phy) {
-				vfe_send_outmsg(&vfe2x_ctrl->subdev,
-						MSG_ID_OUTPUT_PRIMARY,
-						y_phy, cbcr_phy);
-			}
-			break;
-		case MSG_RESET_ACK:
-		case MSG_START_ACK:
-		case MSG_UPDATE_ACK:
-		case MSG_VFE_ERROR:
-		case MSG_SYNC_TIMER1_DONE:
-		case MSG_SYNC_TIMER2_DONE:
-			vfe2x_send_isp_msg(vfe2x_ctrl, msgs_map[id].isp_id);
-			if (id == MSG_START_ACK)
-				vfe2x_ctrl->vfe_started = 1;
-			if (id == MSG_VFE_ERROR) {
-				uint16_t *ptr;
-				struct vfe_error_msg *VFE_ErrorMessageBuffer
-					= data;
-				ptr = data;
-				CDBG("Error: %x %x\n", ptr[0], ptr[1]);
-				CDBG("CAMIF_Error              = %d\n",
-					VFE_ErrorMessageBuffer->camif_error);
-				CDBG("output1YBusOverflow      = %d\n",
-					VFE_ErrorMessageBuffer->
-					output1ybusoverflow);
-				CDBG("output1CbCrBusOverflow   = %d\n",
-					VFE_ErrorMessageBuffer->
-					output1cbcrbusoverflow);
-				CDBG("output2YBusOverflow      = %d\n",
-					VFE_ErrorMessageBuffer->
-					output2ybusoverflow);
-				CDBG("output2CbCrBusOverflow   = %d\n",
-						VFE_ErrorMessageBuffer->
-						output2cbcrbusoverflow);
-				CDBG("autofocusStatBusOverflow = %d\n",
-						VFE_ErrorMessageBuffer->
-						autofocusstatbusoverflow);
-				CDBG("WB_EXPStatBusOverflow    = %d\n",
-						VFE_ErrorMessageBuffer->
-						wb_expstatbusoverflow);
-				CDBG("AXIError                 = %d\n",
-						VFE_ErrorMessageBuffer->
-						axierror);
-				CDBG("CAMIF_Staus              = %d\n",
-						VFE_ErrorMessageBuffer->
-						camif_staus);
-				CDBG("pixel_count              = %d\n",
-						VFE_ErrorMessageBuffer->
-						pixel_count);
-				CDBG("line_count               = %d\n",
-						VFE_ErrorMessageBuffer->
-						line_count);
-			}
-			break;
-		case MSG_SOF:
-			vfe2x_ctrl->vfeFrameId++;
-			if (vfe2x_ctrl->vfeFrameId == 0)
-				vfe2x_ctrl->vfeFrameId = 1; /* wrapped back */
-			if ((op_mode & SNAPSHOT_MASK_MODE) && !raw_mode
-				&& (vfe2x_ctrl->num_snap <= 1)) {
-				CDBG("Ignore SOF for snapshot\n");
-				kfree(data);
-				return;
-			}
-			vfe2x_send_isp_msg(vfe2x_ctrl, MSG_ID_SOF_ACK);
-			if (raw_mode)
-				vfe2x_send_isp_msg(vfe2x_ctrl,
-						MSG_ID_START_ACK);
-			break;
-		case MSG_STOP_ACK:
-			stopevent.state = 1;
-			vfe2x_ctrl->vfe_started = 0;
-			wake_up(&stopevent.wait);
-			vfe2x_send_isp_msg(vfe2x_ctrl, MSG_ID_STOP_ACK);
-			break;
-		case MSG_STATS_AF:
-		case MSG_STATS_WE:
-			vfe_send_stats_msg(*(uint32_t *)data,
-						msgs_map[id].isp_id);
-			break;
-		default:
-			if (MSG_TABLE_CMD_ACK != id)
-				vfe2x_send_isp_msg(vfe2x_ctrl,
-						msgs_map[id].isp_id);
-			break;
-		}
-	}
-	if (MSG_TABLE_CMD_ACK == id) {
-		spin_lock_irqsave(&vfe2x_ctrl->table_lock, flags);
-		vfe2x_ctrl->tableack_pending = 0;
-		if (list_empty(&vfe2x_ctrl->table_q)) {
-			if (vfe2x_ctrl->start_pending) {
-				CDBG("Send START\n");
-				cmd_data = buf;
-				*(uint32_t *)cmd_data = VFE_START;
-				memcpy(((char *)cmd_data) + 4,
-					&vfe2x_ctrl->start_cmd,
-					sizeof(vfe2x_ctrl->start_cmd));
-				/* Send Start cmd here */
-				len  = sizeof(vfe2x_ctrl->start_cmd) + 4;
-				msm_adsp_write(vfe_mod, QDSP_CMDQUEUE,
-						cmd_data, len);
-				vfe2x_ctrl->start_pending = 0;
-			} else if (vfe2x_ctrl->stop_pending) {
-				CDBG("Send STOP\n");
-				cmd_data = buf;
-				*(uint32_t *)cmd_data = VFE_STOP;
-				/* Send Stop cmd here */
-				len  = 4;
-				msm_adsp_write(vfe_mod, QDSP_CMDQUEUE,
-						cmd_data, len);
-				vfe2x_ctrl->stop_pending = 0;
-			} else if (vfe2x_ctrl->update_pending) {
-				CDBG("Send Update\n");
-				cmd_data = buf;
-				*(uint32_t *)cmd_data = VFE_UPDATE;
-				/* Send Update cmd here */
-				len  = 4;
-				msm_adsp_write(vfe_mod, QDSP_CMDQUEUE,
-						cmd_data, len);
-				vfe2x_ctrl->update_pending = 0;
-			}
-			spin_unlock_irqrestore(&vfe2x_ctrl->table_lock, flags);
-			kfree(data);
-			return;
-		}
-		table_pending = list_first_entry(&vfe2x_ctrl->table_q,
-					struct table_cmd, list);
-		if (!table_pending) {
-			spin_unlock_irqrestore(&vfe2x_ctrl->table_lock, flags);
-			kfree(data);
-			return;
-		}
-		msm_adsp_write(vfe_mod, table_pending->queue,
-				table_pending->cmd, table_pending->size);
-		list_del(&table_pending->list);
-		kfree(table_pending->cmd);
-		kfree(table_pending);
-		vfe2x_ctrl->tableack_pending = 1;
-		spin_unlock_irqrestore(&vfe2x_ctrl->table_lock, flags);
-	} else if (!vfe2x_ctrl->tableack_pending) {
-		if (!list_empty(&vfe2x_ctrl->table_q)) {
-			kfree(data);
-			return;
-		}
-	}
-	kfree(data);
-}
-
-static struct msm_adsp_ops vfe_7x_sync = {
-	.event = vfe_7x_ops,
-};
-
-static int vfe_7x_config_axi(int mode,
-	struct buf_info *ad, struct axiout *ao)
-{
-	unsigned long *bptr;
-	int    cnt;
-	int rc = 0;
-	int o_mode = 0;
-	unsigned long flags;
-
-	if (op_mode & SNAPSHOT_MASK_MODE)
-		o_mode = SNAPSHOT_MASK_MODE;
-
-	if ((o_mode == SNAPSHOT_MASK_MODE) && (vfe2x_ctrl->num_snap > 1)) {
-		CDBG("%s: BURST mode freebuf cnt %d", __func__,
-			ad->free_buf_cnt);
-		/* Burst */
-		if (mode == OUTPUT_SEC) {
-			ao->output1buffer1_y_phy = ad->ping.ch_paddr[0];
-			ao->output1buffer1_cbcr_phy = ad->ping.ch_paddr[1];
-			ao->output1buffer2_y_phy = ad->pong.ch_paddr[0];
-			ao->output1buffer2_cbcr_phy = ad->pong.ch_paddr[1];
-			ao->output1buffer3_y_phy = ad->free_buf.ch_paddr[0];
-			ao->output1buffer3_cbcr_phy = ad->free_buf.ch_paddr[1];
-			bptr = &ao->output1buffer4_y_phy;
-			for (cnt = 0; cnt < 5; cnt++) {
-				*bptr = (cnt < ad->free_buf_cnt-3) ?
-					ad->free_buf_arr[cnt].ch_paddr[0] :
-						ad->pong.ch_paddr[0];
-				bptr++;
-				*bptr = (cnt < ad->free_buf_cnt-3) ?
-					ad->free_buf_arr[cnt].ch_paddr[1] :
-						ad->pong.ch_paddr[1];
-				bptr++;
-			}
-			CDBG("%x %x\n", (unsigned int)ao->output1buffer1_y_phy,
-				(unsigned int)ao->output1buffer1_cbcr_phy);
-			CDBG("%x %x\n", (unsigned int)ao->output1buffer2_y_phy,
-				(unsigned int)ao->output1buffer2_cbcr_phy);
-			CDBG("%x %x\n", (unsigned int)ao->output1buffer3_y_phy,
-				(unsigned int)ao->output1buffer3_cbcr_phy);
-			CDBG("%x %x\n", (unsigned int)ao->output1buffer4_y_phy,
-				(unsigned int)ao->output1buffer4_cbcr_phy);
-			CDBG("%x %x\n", (unsigned int)ao->output1buffer5_y_phy,
-				(unsigned int)ao->output1buffer5_cbcr_phy);
-			CDBG("%x %x\n", (unsigned int)ao->output1buffer6_y_phy,
-				(unsigned int)ao->output1buffer6_cbcr_phy);
-			CDBG("%x %x\n", (unsigned int)ao->output1buffer7_y_phy,
-				(unsigned int)ao->output1buffer7_cbcr_phy);
-		} else { /*Primary*/
-			ao->output2buffer1_y_phy = ad->ping.ch_paddr[0];
-			ao->output2buffer1_cbcr_phy = ad->ping.ch_paddr[1];
-			ao->output2buffer2_y_phy = ad->pong.ch_paddr[0];
-			ao->output2buffer2_cbcr_phy = ad->pong.ch_paddr[1];
-			ao->output2buffer3_y_phy = ad->free_buf.ch_paddr[0];
-			ao->output2buffer3_cbcr_phy = ad->free_buf.ch_paddr[1];
-			bptr = &ao->output2buffer4_y_phy;
-			for (cnt = 0; cnt < 5; cnt++) {
-				*bptr = (cnt < ad->free_buf_cnt-3) ?
-					ad->free_buf_arr[cnt].ch_paddr[0] :
-						ad->pong.ch_paddr[0];
-				bptr++;
-				*bptr = (cnt < ad->free_buf_cnt-3) ?
-					ad->free_buf_arr[cnt].ch_paddr[1] :
-						ad->pong.ch_paddr[1];
-				bptr++;
-			}
-			CDBG("%x %x\n", (unsigned int)ao->output2buffer1_y_phy,
-				(unsigned int)ao->output2buffer1_cbcr_phy);
-			CDBG("%x %x\n", (unsigned int)ao->output2buffer2_y_phy,
-				(unsigned int)ao->output2buffer2_cbcr_phy);
-			CDBG("%x %x\n", (unsigned int)ao->output2buffer3_y_phy,
-				(unsigned int)ao->output2buffer3_cbcr_phy);
-			CDBG("%x %x\n", (unsigned int)ao->output2buffer4_y_phy,
-				(unsigned int)ao->output2buffer4_cbcr_phy);
-			CDBG("%x %x\n", (unsigned int)ao->output2buffer5_y_phy,
-				(unsigned int)ao->output2buffer5_cbcr_phy);
-			CDBG("%x %x\n", (unsigned int)ao->output2buffer6_y_phy,
-				(unsigned int)ao->output2buffer6_cbcr_phy);
-			CDBG("%x %x\n", (unsigned int)ao->output2buffer7_y_phy,
-				(unsigned int)ao->output2buffer7_cbcr_phy);
-		}
-	} else if (mode == OUTPUT_SEC) {
-		/* Thumbnail */
-		if (vfe2x_ctrl->zsl_mode) {
-			ao->output1buffer1_y_phy = ad->ping.ch_paddr[0];
-			ao->output1buffer1_cbcr_phy = ad->ping.ch_paddr[1];
-			ao->output1buffer2_y_phy = ad->pong.ch_paddr[0];
-			ao->output1buffer2_cbcr_phy = ad->pong.ch_paddr[1];
-			ao->output1buffer3_y_phy = ad->free_buf.ch_paddr[0];
-			ao->output1buffer3_cbcr_phy = ad->free_buf.ch_paddr[1];
-			bptr = &ao->output1buffer4_y_phy;
-			for (cnt = 0; cnt < 5; cnt++) {
-				*bptr = ad->pong.ch_paddr[0];
-				bptr++;
-				*bptr = ad->pong.ch_paddr[1];
-				bptr++;
-			}
-		} else {
-			ao->output1buffer1_y_phy = ad->ping.ch_paddr[0];
-			ao->output1buffer1_cbcr_phy = ad->ping.ch_paddr[1];
-			ao->output1buffer2_y_phy = ad->pong.ch_paddr[0];
-			ao->output1buffer2_cbcr_phy = ad->pong.ch_paddr[1];
-			bptr = &ao->output1buffer3_y_phy;
-			for (cnt = 0; cnt < 6; cnt++) {
-				*bptr = ad->pong.ch_paddr[0];
-				bptr++;
-				*bptr = ad->pong.ch_paddr[1];
-				bptr++;
-			}
-		}
-	} else if (mode == OUTPUT_PRIM && o_mode != SNAPSHOT_MASK_MODE) {
-		/* Preview */
-		ao->output2buffer1_y_phy = ad->ping.ch_paddr[0];
-		ao->output2buffer1_cbcr_phy = ad->ping.ch_paddr[1];
-		ao->output2buffer2_y_phy = ad->pong.ch_paddr[0];
-		ao->output2buffer2_cbcr_phy = ad->pong.ch_paddr[1];
-		spin_lock_irqsave(&vfe2x_ctrl->liveshot_enabled_lock,
-				flags);
-		if (vfe2x_ctrl->liveshot_enabled) { /* Live shot */
-			ao->output2buffer3_y_phy = ad->pong.ch_paddr[0];
-			ao->output2buffer3_cbcr_phy = ad->pong.ch_paddr[1];
-		} else {
-			ao->output2buffer3_y_phy = ad->free_buf.ch_paddr[0];
-			ao->output2buffer3_cbcr_phy = ad->free_buf.ch_paddr[1];
-		}
-		spin_unlock_irqrestore(&vfe2x_ctrl->liveshot_enabled_lock,
-				flags);
-		bptr = &ao->output2buffer4_y_phy;
-		for (cnt = 0; cnt < 5; cnt++) {
-			*bptr = ad->pong.ch_paddr[0];
-			bptr++;
-			*bptr = ad->pong.ch_paddr[1];
-			bptr++;
-		}
-		CDBG("%x %x\n", (unsigned int)ao->output2buffer1_y_phy,
-			(unsigned int)ao->output2buffer1_cbcr_phy);
-		CDBG("%x %x\n", (unsigned int)ao->output2buffer2_y_phy,
-			(unsigned int)ao->output2buffer2_cbcr_phy);
-		CDBG("%x %x\n", (unsigned int)ao->output2buffer3_y_phy,
-			(unsigned int)ao->output2buffer3_cbcr_phy);
-		CDBG("%x %x\n", (unsigned int)ao->output2buffer4_y_phy,
-			(unsigned int)ao->output2buffer4_cbcr_phy);
-		CDBG("%x %x\n", (unsigned int)ao->output2buffer5_y_phy,
-			(unsigned int)ao->output2buffer5_cbcr_phy);
-		CDBG("%x %x\n", (unsigned int)ao->output2buffer6_y_phy,
-			(unsigned int)ao->output2buffer6_cbcr_phy);
-		CDBG("%x %x\n", (unsigned int)ao->output2buffer7_y_phy,
-			(unsigned int)ao->output2buffer7_cbcr_phy);
-		vfe2x_ctrl->free_buf.buf[0].ch_paddr[0] = ad->ping.ch_paddr[0];
-		vfe2x_ctrl->free_buf.buf[0].ch_paddr[1] = ad->ping.ch_paddr[1];
-		vfe2x_ctrl->free_buf.buf[1].ch_paddr[0] = ad->pong.ch_paddr[0];
-		vfe2x_ctrl->free_buf.buf[1].ch_paddr[1] = ad->pong.ch_paddr[1];
-		vfe2x_ctrl->free_buf.buf[2].ch_paddr[0] =
-			ad->free_buf.ch_paddr[0];
-		vfe2x_ctrl->free_buf.buf[2].ch_paddr[1] =
-			ad->free_buf.ch_paddr[1];
-	} else if (mode == OUTPUT_PRIM && o_mode == SNAPSHOT_MASK_MODE) {
-		vfe2x_ctrl->reconfig_vfe = 0;
-		if (raw_mode) {
-			ao->output2buffer1_y_phy = ad->ping.ch_paddr[0];
-			ao->output2buffer1_cbcr_phy = ad->ping.ch_paddr[0];
-			ao->output2buffer2_y_phy = ad->pong.ch_paddr[0];
-			ao->output2buffer2_cbcr_phy = ad->pong.ch_paddr[0];
-		} else {
-			ao->output2buffer1_y_phy = ad->ping.ch_paddr[0];
-			ao->output2buffer1_cbcr_phy = ad->ping.ch_paddr[1];
-			ao->output2buffer2_y_phy = ad->pong.ch_paddr[0];
-			ao->output2buffer2_cbcr_phy = ad->pong.ch_paddr[1];
-	}
-		bptr = &ao->output2buffer3_y_phy;
-		for (cnt = 0; cnt < 6; cnt++) {
-			*bptr = ad->pong.ch_paddr[0];
-			bptr++;
-			*bptr = ad->pong.ch_paddr[1];
-			bptr++;
-		}
-	}
-
-	return rc;
-}
-
-static void vfe2x_subdev_notify(int id, int path)
-{
-	struct msm_vfe_resp rp;
-	unsigned long flags = 0;
-	spin_lock_irqsave(&vfe2x_ctrl->sd_notify_lock, flags);
-	memset(&rp, 0, sizeof(struct msm_vfe_resp));
-	CDBG("vfe2x_subdev_notify : msgId = %d\n", id);
-	rp.evt_msg.type   = MSM_CAMERA_MSG;
-	rp.evt_msg.msg_id = path;
-	rp.evt_msg.data = NULL;
-	rp.type	   = id;
-	v4l2_subdev_notify(&vfe2x_ctrl->subdev, NOTIFY_VFE_BUF_EVT, &rp);
-	spin_unlock_irqrestore(&vfe2x_ctrl->sd_notify_lock, flags);
-}
-
-static struct msm_free_buf *vfe2x_check_free_buffer(int id, int path)
-{
-	struct buf_info *outch = NULL;
-
-	vfe2x_subdev_notify(id, path);
-	if (op_mode & SNAPSHOT_MASK_MODE) {
-		if (path == VFE_MSG_OUTPUT_PRIMARY ||
-				path == VFE_MSG_V2X_LIVESHOT_PRIMARY)
-			outch = &vfe2x_ctrl->snap;
-		else if (path == VFE_MSG_OUTPUT_SECONDARY)
-			outch = &vfe2x_ctrl->thumb;
-	} else {
-		if (path == VFE_MSG_OUTPUT_PRIMARY ||
-				path == VFE_MSG_V2X_LIVESHOT_PRIMARY) {
-			if (vfe2x_ctrl->zsl_mode)
-				outch = &vfe2x_ctrl->zsl_prim;
-			else
-				outch = &vfe2x_ctrl->prev;
-		} else if (path == VFE_MSG_OUTPUT_SECONDARY)
-				outch = &vfe2x_ctrl->zsl_sec;
-	}
-	if (outch->free_buf.ch_paddr[0])
-		return &outch->free_buf;
-
-	return NULL;
-}
-
-static int vfe2x_configure_pingpong_buffers(int id, int path)
-{
-	struct buf_info *outch = NULL;
-	int rc = 0;
-
-	vfe2x_subdev_notify(id, path);
-	CDBG("Opmode = %d\n", op_mode);
-	if (op_mode & SNAPSHOT_MASK_MODE) {
-		if (path == VFE_MSG_OUTPUT_PRIMARY ||
-				path == VFE_MSG_V2X_LIVESHOT_PRIMARY)
-			outch = &vfe2x_ctrl->snap;
-		else if (path == VFE_MSG_OUTPUT_SECONDARY)
-			outch = &vfe2x_ctrl->thumb;
-	} else {
-		if (path == VFE_MSG_OUTPUT_PRIMARY ||
-				path == VFE_MSG_V2X_LIVESHOT_PRIMARY) {
-			if (vfe2x_ctrl->zsl_mode)
-				outch = &vfe2x_ctrl->zsl_prim;
-			else
-				outch = &vfe2x_ctrl->prev;
-		} else if (path == VFE_MSG_OUTPUT_SECONDARY)
-			outch = &vfe2x_ctrl->zsl_sec;
-	}
-	if (outch->ping.ch_paddr[0] && outch->pong.ch_paddr[0]) {
-		/* Configure Preview Ping Pong */
-		CDBG("%s Configure ping/pong address for %d",
-						__func__, path);
-	} else {
-		pr_err("%s ping/pong addr is null!!", __func__);
-		rc = -EINVAL;
-	}
-	return rc;
-}
-
-static struct buf_info *vfe2x_get_ch(int path)
-{
-	struct buf_info *ch = NULL;
-
-	CDBG("path = %d op_mode = %d\n", path, op_mode);
-	/* TODO: Remove Mode specific stuff */
-	if (op_mode & SNAPSHOT_MASK_MODE) {
-		if (path == VFE_MSG_OUTPUT_SECONDARY)
-			ch = &vfe2x_ctrl->thumb;
-		else if (path == VFE_MSG_OUTPUT_PRIMARY ||
-					path == VFE_MSG_V2X_LIVESHOT_PRIMARY)
-			ch = &vfe2x_ctrl->snap;
-	} else {
-		if (path == VFE_MSG_OUTPUT_PRIMARY ||
-					path == VFE_MSG_V2X_LIVESHOT_PRIMARY) {
-			if (vfe2x_ctrl->zsl_mode)
-				ch = &vfe2x_ctrl->zsl_prim;
-			else
-				ch = &vfe2x_ctrl->prev;
-		} else if (path == VFE_MSG_OUTPUT_SECONDARY)
-			ch = &vfe2x_ctrl->zsl_sec;
-	}
-
-	BUG_ON(ch == NULL);
-	return ch;
-}
-
-static long msm_vfe_subdev_ioctl(struct v4l2_subdev *sd,
-			unsigned int subdev_cmd, void *arg)
-{
-	struct msm_isp_cmd vfecmd;
-	struct msm_camvfe_params *vfe_params;
-	struct msm_vfe_cfg_cmd *cmd;
-	struct table_cmd *table_pending;
-	long rc = 0;
-	void *data;
-
-	struct msm_pmem_region *regptr;
-	unsigned char buf[256];
-
-	struct vfe_stats_ack sack;
-	struct axidata *axid;
-	uint32_t i;
-	uint32_t header = 0;
-	uint32_t queue = 0;
-	struct vfe_stats_we_cfg *scfg = NULL;
-	struct vfe_stats_af_cfg *sfcfg = NULL;
-
-	struct axiout *axio = NULL;
-	void   *cmd_data = NULL;
-	void   *cmd_data_alloc = NULL;
-	unsigned long flags;
-	struct msm_free_buf *free_buf = NULL;
-	struct vfe_outputack fack;
-
-	CDBG("msm_vfe_subdev_ioctl is called\n");
-	if (subdev_cmd == VIDIOC_MSM_VFE_INIT) {
-		CDBG("%s init\n", __func__);
-		return msm_vfe_subdev_init(sd);
-	} else if (subdev_cmd == VIDIOC_MSM_VFE_RELEASE) {
-		msm_vfe_subdev_release(sd);
-		return 0;
-	}
-
-	vfe_params = (struct msm_camvfe_params *)arg;
-	cmd = vfe_params->vfe_cfg;
-	data = vfe_params->data;
-
-	if (cmd->cmd_type != CMD_FRAME_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_AF_BUF_RELEASE &&
-		cmd->cmd_type != CMD_CONFIG_PING_ADDR &&
-		cmd->cmd_type != CMD_CONFIG_PONG_ADDR &&
-		cmd->cmd_type != CMD_CONFIG_FREE_BUF_ADDR &&
-		cmd->cmd_type != CMD_VFE_BUFFER_RELEASE &&
-		cmd->cmd_type != VFE_CMD_STATS_REQBUF &&
-		cmd->cmd_type != VFE_CMD_STATS_FLUSH_BUFQ &&
-		cmd->cmd_type != VFE_CMD_STATS_UNREGBUF &&
-		cmd->cmd_type != VFE_CMD_STATS_ENQUEUEBUF) {
-		if (copy_from_user(&vfecmd,
-			   (void __user *)(cmd->value),
-			   sizeof(vfecmd))) {
-			pr_err("copy_from_user in msm_vfe_subdev_ioctl fail\n");
-			return -EFAULT;
-		}
-	}
-	switch (cmd->cmd_type) {
-	case VFE_CMD_STATS_REQBUF:
-	case VFE_CMD_STATS_FLUSH_BUFQ:
-	case VFE_CMD_STATS_UNREGBUF:
-		/* for easy porting put in one envelope */
-		rc = vfe2x_stats_bufq_sub_ioctl(cmd, vfe_params->data);
-		return rc;
-	case VFE_CMD_STATS_ENQUEUEBUF:
-		if (sizeof(struct msm_stats_buf_info) != cmd->length) {
-			/* error. the length not match */
-			pr_err("%s: stats enqueuebuf input size = %d,\n"
-				"struct size = %d, mitch match\n",\
-				__func__, cmd->length,
-				sizeof(struct msm_stats_buf_info));
-			rc = -EINVAL;
-			return rc;
-		}
-		sack.header = 0;
-		sack.bufaddr = NULL;
-		rc = vfe2x_stats_enqueuebuf(cmd->value, &sack);
-		if (rc < 0) {
-			pr_err("%s: error", __func__);
-			rc = -EINVAL;
-			return rc;
-		}
-		if (sack.header != 0 && sack.bufaddr != NULL) {
-			queue  = QDSP_CMDQUEUE;
-			vfecmd.length = sizeof(struct vfe_stats_ack) - 4;
-			cmd_data = &sack;
-		} else {
-			return 0;
-		}
-	break;
-	case CMD_VFE_BUFFER_RELEASE: {
-		if (!(vfe2x_ctrl->vfe_started) || op_mode == 1)
-			return 0;
-		if (op_mode & SNAPSHOT_MASK_MODE) {
-			free_buf = vfe2x_check_free_buffer(
-					VFE_MSG_OUTPUT_IRQ,
-					VFE_MSG_OUTPUT_SECONDARY);
-		} else {
-			free_buf = vfe2x_check_free_buffer(
-					VFE_MSG_OUTPUT_IRQ,
-					VFE_MSG_OUTPUT_PRIMARY);
-			if (free_buf) {
-				fack.header = VFE_OUTPUT2_ACK;
-
-				fack.output2newybufferaddress =
-						(void *)(free_buf->ch_paddr[0]);
-
-				fack.output2newcbcrbufferaddress =
-						(void *)(free_buf->ch_paddr[1]);
-
-				cmd_data = &fack;
-				vfecmd.length = sizeof(fack) - 4;
-				queue = QDSP_CMDQUEUE;
-			}
-		}
-	}
-	break;
-	case CMD_CONFIG_PING_ADDR: {
-		int path = *((int *)cmd->value);
-		struct buf_info *outch = vfe2x_get_ch(path);
-		outch->ping = *((struct msm_free_buf *)data);
-	}
-		return 0;
-	case CMD_CONFIG_PONG_ADDR: {
-		int path = *((int *)cmd->value);
-		struct buf_info *outch = vfe2x_get_ch(path);
-		outch->pong = *((struct msm_free_buf *)data);
-	}
-		return 0;
-
-	case CMD_AXI_START:
-	case CMD_AXI_STOP:
-	case CMD_AXI_RESET:
-		return 0;
-
-	case CMD_CONFIG_FREE_BUF_ADDR: {
-		int path = *((int *)cmd->value);
-		struct buf_info *outch = vfe2x_get_ch(path);
-		if ((op_mode & SNAPSHOT_MASK_MODE) &&
-			(vfe2x_ctrl->num_snap > 1)) {
-			CDBG("%s: CMD_CONFIG_FREE_BUF_ADDR Burst mode %d",
-					__func__, outch->free_buf_cnt);
-			if (outch->free_buf_cnt <= 0)
-				outch->free_buf =
-					*((struct msm_free_buf *)data);
-			else
-				outch->free_buf_arr[outch->free_buf_cnt-1] =
-					*((struct msm_free_buf *)data);
-			++outch->free_buf_cnt;
-		} else {
-			outch->free_buf = *((struct msm_free_buf *)data);
-		}
-	}
-		return 0;
-
-	case CMD_STATS_AXI_CFG: {
-		axid = data;
-		if (!axid) {
-			rc = -EFAULT;
-			goto config_failure;
-		}
-
-		scfg =
-			kmalloc(sizeof(struct vfe_stats_we_cfg),
-				GFP_ATOMIC);
-		if (!scfg) {
-			rc = -ENOMEM;
-			goto config_failure;
-		}
-
-		if (copy_from_user((char *)scfg + 4,
-					(void __user *)(vfecmd.value),
-					vfecmd.length)) {
-
-			rc = -EFAULT;
-			goto config_done;
-		}
-
-		CDBG("STATS_ENABLE: bufnum = %d, enabling = %d\n",
-			axid->bufnum1, scfg->wb_expstatsenable);
-
-		header = cmds_map[vfecmd.id].vfe_id;
-		queue = cmds_map[vfecmd.id].queue;
-		if (header == -1 && queue == -1) {
-			rc = -EFAULT;
-			goto config_failure;
-		}
-		*(uint32_t *)scfg = header;
-		if (axid->bufnum1 > 0) {
-			regptr = axid->region;
-
-			for (i = 0; i < axid->bufnum1; i++) {
-
-				CDBG("STATS_ENABLE, phy = 0x%lx\n",
-					regptr->paddr);
-
-				scfg->wb_expstatoutputbuffer[i] =
-					(void *)regptr->paddr;
-				regptr++;
-			}
-
-			cmd_data = scfg;
-
-		} else {
-			rc = -EINVAL;
-			goto config_done;
-		}
-	}
-		break;
-	case CMD_STATS_AEC_AWB_ENABLE: {
-		pr_err("CMD_STATS_AEC_AWB_ENABLE\n");
-		scfg =
-			kmalloc(sizeof(struct vfe_stats_we_cfg),
-				GFP_ATOMIC);
-		if (!scfg) {
-			rc = -ENOMEM;
-			goto config_failure;
-		}
-
-		if (copy_from_user((char *)scfg + 4,
-					(void __user *)(vfecmd.value),
-					vfecmd.length)) {
-
-			rc = -EFAULT;
-			goto config_done;
-		}
-
-		header = cmds_map[vfecmd.id].vfe_id;
-		queue = cmds_map[vfecmd.id].queue;
-		if (header == -1 && queue == -1) {
-			rc = -EFAULT;
-			goto config_failure;
-		}
-		*(uint32_t *)scfg = header;
-		rc = vfe2x_stats_buf_init(MSM_STATS_TYPE_AE_AW);
-		if (rc < 0) {
-			pr_err("%s: cannot config ping/pong address of AWB",
-				 __func__);
-			goto config_failure;
-		}
-		scfg->wb_expstatoutputbuffer[0] =
-			(void *)vfe2x_ctrl->stats_we_buf_ptr[0];
-		scfg->wb_expstatoutputbuffer[1] =
-			(void *)vfe2x_ctrl->stats_we_buf_ptr[1];
-		scfg->wb_expstatoutputbuffer[2] =
-			(void *)vfe2x_ctrl->stats_we_buf_ptr[2];
-		cmd_data = scfg;
-	}
-	break;
-	case CMD_STATS_AF_ENABLE:
-	case CMD_STATS_AF_AXI_CFG: {
-		CDBG("CMD_STATS_AF_ENABLE CMD_STATS_AF_AXI_CFG\n");
-		sfcfg =
-			kmalloc(sizeof(struct vfe_stats_af_cfg),
-				GFP_ATOMIC);
-
-		if (!sfcfg) {
-			rc = -ENOMEM;
-			goto config_failure;
-		}
-
-		if (copy_from_user((char *)sfcfg + 4,
-					(void __user *)(vfecmd.value),
-					vfecmd.length)) {
-
-			rc = -EFAULT;
-			goto config_done;
-		}
-
-		header = cmds_map[vfecmd.id].vfe_id;
-		queue = cmds_map[vfecmd.id].queue;
-		if (header == -1 && queue == -1) {
-			rc = -EFAULT;
-			goto config_failure;
-		}
-		*(uint32_t *)sfcfg = header;
-		rc = vfe2x_stats_buf_init(MSM_STATS_TYPE_AF);
-		sfcfg->af_outbuf[0] = (void *)vfe2x_ctrl->stats_af_buf_ptr[0];
-		sfcfg->af_outbuf[1] = (void *)vfe2x_ctrl->stats_af_buf_ptr[1];
-		sfcfg->af_outbuf[2] = (void *)vfe2x_ctrl->stats_af_buf_ptr[2];
-		if (rc < 0) {
-			pr_err("%s: cannot config ping/pong address of AWB",
-				__func__);
-			goto config_failure;
-		}
-		cmd_data = sfcfg;
-	}
-		break;
-	case CMD_SNAP_BUF_RELEASE:
-		break;
-	case CMD_STATS_BUF_RELEASE: {
-		CDBG("vfe_7x_config: CMD_STATS_BUF_RELEASE\n");
-		if (!data) {
-			rc = -EFAULT;
-			goto config_failure;
-		}
-
-		sack.header = VFE_STATS_WB_EXP_ACK;
-		sack.bufaddr = (void *)*(uint32_t *)data;
-
-		queue  = QDSP_CMDQUEUE;
-		vfecmd.length = sizeof(struct vfe_stats_ack) - 4;
-		cmd_data = &sack;
-	}
-		break;
-	case CMD_STATS_AF_BUF_RELEASE: {
-		CDBG("vfe_7x_config: CMD_STATS_AF_BUF_RELEASE\n");
-		if (!data) {
-			rc = -EFAULT;
-			goto config_failure;
-		}
-
-		sack.header = VFE_STATS_AUTOFOCUS_ACK;
-		sack.bufaddr = (void *)*(uint32_t *)data;
-
-		queue  = QDSP_CMDQUEUE;
-		vfecmd.length = sizeof(struct vfe_stats_ack) - 4;
-		cmd_data = &sack;
-	}
-		break;
-	case CMD_GENERAL:
-	case CMD_STATS_DISABLE: {
-		CDBG("CMD_GENERAL:%d %d\n", vfecmd.id, vfecmd.length);
-		if (vfecmd.id == VFE_CMD_OPERATION_CFG) {
-			if (copy_from_user(&vfe2x_ctrl->start_cmd,
-						(void __user *)(vfecmd.value),
-							vfecmd.length))
-				rc = -EFAULT;
-			op_mode = vfe2x_ctrl->start_cmd.mode_of_operation;
-			vfe2x_ctrl->snap.free_buf_cnt = 0;
-			vfe2x_ctrl->thumb.free_buf_cnt = 0;
-			vfe2x_ctrl->snap.frame_cnt = 0;
-			vfe2x_ctrl->thumb.frame_cnt = 0;
-			vfe2x_ctrl->num_snap =
-				vfe2x_ctrl->start_cmd.snap_number;
-			return rc;
-		}
-		if (vfecmd.id == VFE_CMD_RECONFIG_VFE) {
-			CDBG("VFE is RECONFIGURED\n");
-			vfe2x_ctrl->reconfig_vfe = 1;
-			return 0;
-		}
-		if (vfecmd.id == VFE_CMD_LIVESHOT) {
-			CDBG("live shot enabled\n");
-			spin_lock_irqsave(&vfe2x_ctrl->liveshot_enabled_lock,
-					flags);
-			vfe2x_ctrl->liveshot_enabled = 1;
-			spin_unlock_irqrestore(&vfe2x_ctrl->
-					liveshot_enabled_lock,
-					flags);
-			return 0;
-		}
-		if (vfecmd.id == VFE_CMD_STOP_LIVESHOT) {
-			CDBG("live shot disabled\n");
-			spin_lock_irqsave(&vfe2x_ctrl->liveshot_enabled_lock,
-					flags);
-			vfe2x_ctrl->liveshot_enabled = 0;
-			spin_unlock_irqrestore(
-					&vfe2x_ctrl->liveshot_enabled_lock,
-					flags);
-			return 0;
-		}
-		if (vfecmd.length > 256 - 4) {
-			cmd_data_alloc =
-			cmd_data = kmalloc(vfecmd.length + 4, GFP_ATOMIC);
-			if (!cmd_data) {
-				rc = -ENOMEM;
-				goto config_failure;
-			}
-		} else
-			cmd_data = buf;
-
-		if (copy_from_user(((char *)cmd_data) + 4,
-					(void __user *)(vfecmd.value),
-					vfecmd.length)) {
-
-			rc = -EFAULT;
-			goto config_done;
-		}
-		header = cmds_map[vfecmd.id].vfe_id;
-		queue = cmds_map[vfecmd.id].queue;
-		if (header == -1 && queue == -1) {
-			rc = -EFAULT;
-			goto config_done;
-		}
-		CDBG("%s %s\n", cmds_map[vfecmd.id].isp_id_name,
-			cmds_map[vfecmd.id].vfe_id_name);
-		*(uint32_t *)cmd_data = header;
-		if (queue == QDSP_CMDQUEUE) {
-			switch (vfecmd.id) {
-			case VFE_CMD_RESET:
-				msm_camio_vfe_blk_reset_2();
-				vfestopped = 0;
-				break;
-			case VFE_CMD_START:
-			case VFE_CMD_CAPTURE:
-			case VFE_CMD_CAPTURE_RAW:
-			case VFE_CMD_ZSL:
-				spin_lock_irqsave(&vfe2x_ctrl->table_lock,
-									flags);
-				if ((!list_empty(&vfe2x_ctrl->table_q)) ||
-						vfe2x_ctrl->tableack_pending) {
-					CDBG("start pending\n");
-					vfe2x_ctrl->start_pending = 1;
-					spin_unlock_irqrestore(
-						&vfe2x_ctrl->table_lock,
-								flags);
-					return 0;
-				}
-				spin_unlock_irqrestore(&vfe2x_ctrl->table_lock,
-									flags);
-				vfecmd.length = sizeof(vfe2x_ctrl->start_cmd);
-				memcpy(((char *)cmd_data) + 4,
-					&vfe2x_ctrl->start_cmd,
-					sizeof(vfe2x_ctrl->start_cmd));
-				if (op_mode & SNAPSHOT_MASK_MODE)
-					msm_camio_set_perf_lvl(S_CAPTURE);
-				else
-					msm_camio_set_perf_lvl(S_PREVIEW);
-				vfestopped = 0;
-				break;
-			case VFE_CMD_STOP:
-				vfestopped = 1;
-				spin_lock_irqsave(&vfe2x_ctrl->table_lock,
-						flags);
-				if (op_mode & SNAPSHOT_MASK_MODE) {
-					vfe2x_ctrl->stop_pending = 0;
-					spin_unlock_irqrestore(
-							&vfe2x_ctrl->table_lock,
-							flags);
-					return 0;
-				}
-				if ((!list_empty(&vfe2x_ctrl->table_q)) ||
-						vfe2x_ctrl->tableack_pending) {
-					CDBG("stop pending\n");
-					vfe2x_ctrl->stop_pending = 1;
-					spin_unlock_irqrestore(
-							&vfe2x_ctrl->table_lock,
-							flags);
-					return 0;
-				}
-				spin_unlock_irqrestore(&vfe2x_ctrl->table_lock,
-						flags);
-				vfe2x_ctrl->vfe_started = 0;
-				goto config_send;
-			case VFE_CMD_UPDATE:
-				spin_lock_irqsave(&vfe2x_ctrl->table_lock,
-						flags);
-				if ((!list_empty(&vfe2x_ctrl->table_q)) ||
-						vfe2x_ctrl->tableack_pending) {
-					CDBG("update pending\n");
-					vfe2x_ctrl->update_pending = 0;
-					vfe2x_send_isp_msg(vfe2x_ctrl,
-						msgs_map[MSG_UPDATE_ACK].
-						isp_id);
-					spin_unlock_irqrestore(
-							&vfe2x_ctrl->table_lock,
-							flags);
-					return 0;
-				}
-				spin_unlock_irqrestore(&vfe2x_ctrl->table_lock,
-						flags);
-				goto config_send;
-			default:
-				break;
-			}
-		} /* QDSP_CMDQUEUE */
-	}
-		break;
-	case CMD_AXI_CFG_SEC: {
-		CDBG("CMD_AXI_CFG_SEC\n");
-		raw_mode = 0;
-		vfe2x_ctrl->zsl_mode = 0;
-		axio = kmalloc(sizeof(struct axiout), GFP_ATOMIC);
-		if (!axio) {
-			pr_err("NULL axio\n");
-			rc = -ENOMEM;
-			goto config_failure;
-		}
-
-		if (copy_from_user((char *)axio + 4,
-					(void __user *)(vfecmd.value),
-					sizeof(struct axiout))) {
-			CDBG("copy_from_user failed\n");
-			rc = -EFAULT;
-			goto config_done;
-		}
-		if (op_mode & SNAPSHOT_MASK_MODE)
-			rc = vfe2x_configure_pingpong_buffers(
-						VFE_MSG_CAPTURE,
-						VFE_MSG_OUTPUT_SECONDARY);
-		else
-			rc = vfe2x_configure_pingpong_buffers(
-						VFE_MSG_PREVIEW,
-						VFE_MSG_OUTPUT_SECONDARY);
-		if (rc < 0) {
-			pr_err("%s error configuring pingpong buffers"
-				" for preview", __func__);
-			rc = -EINVAL;
-			goto config_done;
-		}
-
-		if (!(op_mode & SNAPSHOT_MASK_MODE))
-			free_buf = vfe2x_check_free_buffer(
-					VFE_MSG_OUTPUT_IRQ,
-					VFE_MSG_OUTPUT_SECONDARY);
-		header = cmds_map[vfecmd.id].vfe_id;
-		queue = cmds_map[vfecmd.id].queue;
-		if (header == -1 && queue == -1) {
-			rc = -EFAULT;
-			goto config_done;
-		}
-		*(uint32_t *)axio = header;
-		if (op_mode & SNAPSHOT_MASK_MODE)
-			vfe_7x_config_axi(OUTPUT_SEC,
-					&vfe2x_ctrl->thumb, axio);
-		else
-			vfe_7x_config_axi(OUTPUT_SEC,
-					&vfe2x_ctrl->video, axio);
-		cmd_data = axio;
-	}
-		break;
-	case CMD_AXI_CFG_PRIM: {
-		CDBG("CMD_AXI_CFG_PRIM : %d\n", op_mode);
-		raw_mode = 0;
-		vfe2x_ctrl->zsl_mode = 0;
-		axio = kmalloc(sizeof(struct axiout), GFP_ATOMIC);
-		if (!axio) {
-			pr_err("NULL axio\n");
-			rc = -ENOMEM;
-			goto config_failure;
-		}
-
-		if (copy_from_user((char *)axio + 4,
-					(void __user *)(vfecmd.value),
-					sizeof(struct axiout))) {
-			pr_err("copy_from_user failed\n");
-			rc = -EFAULT;
-			goto config_done;
-		}
-		if (!vfe2x_ctrl->reconfig_vfe) {
-			if (op_mode & SNAPSHOT_MASK_MODE)
-				rc = vfe2x_configure_pingpong_buffers(
-						VFE_MSG_CAPTURE,
-						VFE_MSG_OUTPUT_PRIMARY);
-			else
-				rc = vfe2x_configure_pingpong_buffers(
-						VFE_MSG_PREVIEW,
-						VFE_MSG_OUTPUT_PRIMARY);
-			if (rc < 0) {
-				pr_err("%s error configuring pingpong buffers"
-					" for preview", __func__);
-				rc = -EINVAL;
-				goto config_done;
-			}
-			if (!(op_mode & SNAPSHOT_MASK_MODE))
-				free_buf = vfe2x_check_free_buffer(
-					VFE_MSG_OUTPUT_IRQ,
-					VFE_MSG_OUTPUT_PRIMARY);
-		} else {
-			vfe2x_ctrl->prev.ping.ch_paddr[0] =
-				vfe2x_ctrl->free_buf.buf[0].ch_paddr[0];
-			vfe2x_ctrl->prev.ping.ch_paddr[1] =
-				vfe2x_ctrl->free_buf.buf[0].ch_paddr[1];
-			vfe2x_ctrl->prev.pong.ch_paddr[0] =
-				vfe2x_ctrl->free_buf.buf[1].ch_paddr[0];
-			vfe2x_ctrl->prev.pong.ch_paddr[1] =
-				vfe2x_ctrl->free_buf.buf[1].ch_paddr[1];
-			vfe2x_ctrl->prev.free_buf.ch_paddr[0] =
-				vfe2x_ctrl->free_buf.buf[2].ch_paddr[0];
-			vfe2x_ctrl->prev.free_buf.ch_paddr[1] =
-				vfe2x_ctrl->free_buf.buf[2].ch_paddr[1];
-			vfe2x_ctrl->reconfig_vfe = 0;
-		}
-		header = cmds_map[vfecmd.id].vfe_id;
-		queue = cmds_map[vfecmd.id].queue;
-		if (header == -1 && queue == -1) {
-			rc = -EFAULT;
-			goto config_done;
-		}
-		*(uint32_t *)axio = header;
-		if (op_mode & SNAPSHOT_MASK_MODE)
-			vfe_7x_config_axi(OUTPUT_PRIM, &vfe2x_ctrl->snap, axio);
-		else
-			vfe_7x_config_axi(OUTPUT_PRIM, &vfe2x_ctrl->prev, axio);
-		cmd_data = axio;
-	}
-		break;
-	case CMD_AXI_CFG_ZSL: {
-		CDBG("CMD_AXI_CFG_ZSL: %d\n", op_mode);
-		raw_mode = 0;
-		vfe2x_ctrl->zsl_mode = 1;
-		axio = kmalloc(sizeof(struct axiout), GFP_ATOMIC);
-		if (!axio) {
-			pr_err("NULL axio\n");
-			rc = -ENOMEM;
-			goto config_failure;
-		}
-
-		if (copy_from_user((char *)axio + 4,
-					(void __user *)(vfecmd.value),
-					sizeof(struct axiout))) {
-			pr_err("copy_from_user failed\n");
-			rc = -EFAULT;
-			goto config_done;
-		}
-		if (!vfe2x_ctrl->reconfig_vfe) {
-				rc = vfe2x_configure_pingpong_buffers(
-						VFE_MSG_PREVIEW,
-						VFE_MSG_OUTPUT_PRIMARY);
-				rc = vfe2x_configure_pingpong_buffers(
-						VFE_MSG_PREVIEW,
-						VFE_MSG_OUTPUT_SECONDARY);
-			if (rc < 0) {
-				pr_err("%s error configuring pingpong buffers"
-					" for preview", __func__);
-				rc = -EINVAL;
-				goto config_done;
-			}
-				free_buf = vfe2x_check_free_buffer(
-					VFE_MSG_OUTPUT_IRQ,
-					VFE_MSG_OUTPUT_PRIMARY);
-				free_buf = vfe2x_check_free_buffer(
-					VFE_MSG_OUTPUT_IRQ,
-					VFE_MSG_OUTPUT_SECONDARY);
-		} else {
-			vfe2x_ctrl->prev.ping.ch_paddr[0] =
-				vfe2x_ctrl->free_buf.buf[0].ch_paddr[0];
-			vfe2x_ctrl->prev.ping.ch_paddr[1] =
-				vfe2x_ctrl->free_buf.buf[0].ch_paddr[1];
-			vfe2x_ctrl->prev.pong.ch_paddr[0] =
-				vfe2x_ctrl->free_buf.buf[1].ch_paddr[0];
-			vfe2x_ctrl->prev.pong.ch_paddr[1] =
-				vfe2x_ctrl->free_buf.buf[1].ch_paddr[1];
-			vfe2x_ctrl->prev.free_buf.ch_paddr[0] =
-				vfe2x_ctrl->free_buf.buf[2].ch_paddr[0];
-			vfe2x_ctrl->prev.free_buf.ch_paddr[1] =
-				vfe2x_ctrl->free_buf.buf[2].ch_paddr[1];
-			vfe2x_ctrl->reconfig_vfe = 0;
-		}
-		header = cmds_map[vfecmd.id].vfe_id;
-		queue = cmds_map[vfecmd.id].queue;
-		if (header == -1 && queue == -1) {
-			rc = -EFAULT;
-			goto config_done;
-		}
-		*(uint32_t *)axio = header;
-		vfe_7x_config_axi(OUTPUT_PRIM, &vfe2x_ctrl->zsl_prim, axio);
-		vfe_7x_config_axi(OUTPUT_SEC, &vfe2x_ctrl->zsl_sec, axio);
-		cmd_data = axio;
-	}
-		break;
-	case CMD_AXI_CFG_SEC|CMD_AXI_CFG_PRIM: {
-		CDBG("CMD_AXI_CFG_SEC|PRIM\n");
-		raw_mode = 0;
-		vfe2x_ctrl->zsl_mode = 0;
-		axio = kmalloc(sizeof(struct axiout), GFP_ATOMIC);
-		if (!axio) {
-			pr_err("NULL axio\n");
-			rc = -ENOMEM;
-			goto config_failure;
-		}
-
-		if (copy_from_user((char *)axio + 4,
-					(void __user *)(vfecmd.value),
-					sizeof(struct axiout))) {
-			pr_err("copy_from_user failed\n");
-			rc = -EFAULT;
-			goto config_done;
-		}
-		if (op_mode & SNAPSHOT_MASK_MODE)
-			rc = vfe2x_configure_pingpong_buffers(
-						VFE_MSG_CAPTURE,
-						VFE_MSG_OUTPUT_SECONDARY);
-		else
-			rc = vfe2x_configure_pingpong_buffers(
-						VFE_MSG_PREVIEW,
-						VFE_MSG_OUTPUT_SECONDARY);
-		if (rc < 0) {
-			pr_err("%s error configuring pingpong buffers"
-				" for preview", __func__);
-			rc = -EINVAL;
-			goto config_done;
-		}
-
-		if (!(op_mode & SNAPSHOT_MASK_MODE)) {
-			free_buf = vfe2x_check_free_buffer(
-					VFE_MSG_OUTPUT_IRQ,
-					VFE_MSG_OUTPUT_SECONDARY);
-		} else if ((op_mode & SNAPSHOT_MASK_MODE) &&
-				(vfe2x_ctrl->num_snap > 1)) {
-			int i = 0;
-			CDBG("Burst mode AXI config SEC snap cnt %d\n",
-				vfe2x_ctrl->num_snap);
-			for (i = 0; i < vfe2x_ctrl->num_snap - 2; i++) {
-				free_buf = vfe2x_check_free_buffer(
-					VFE_MSG_OUTPUT_IRQ,
-					VFE_MSG_OUTPUT_SECONDARY);
-			}
-		}
-		header = cmds_map[vfecmd.id].vfe_id;
-		queue = cmds_map[vfecmd.id].queue;
-		if (header == -1 && queue == -1) {
-			rc = -EFAULT;
-			goto config_done;
-		}
-		*(uint32_t *)axio = header;
-		if (op_mode & SNAPSHOT_MASK_MODE)
-			vfe_7x_config_axi(OUTPUT_SEC, &vfe2x_ctrl->thumb, axio);
-		else
-			vfe_7x_config_axi(OUTPUT_SEC, &vfe2x_ctrl->prev, axio);
-
-		if (op_mode & SNAPSHOT_MASK_MODE)
-			rc = vfe2x_configure_pingpong_buffers(
-						VFE_MSG_CAPTURE,
-						VFE_MSG_OUTPUT_PRIMARY);
-		else
-			rc = vfe2x_configure_pingpong_buffers(
-						VFE_MSG_PREVIEW,
-						VFE_MSG_OUTPUT_PRIMARY);
-		if (rc < 0) {
-			pr_err("%s error configuring pingpong buffers"
-				" for preview", __func__);
-			rc = -EINVAL;
-			goto config_done;
-		}
-
-		if (!(op_mode & SNAPSHOT_MASK_MODE)) {
-			free_buf = vfe2x_check_free_buffer(
-					VFE_MSG_OUTPUT_IRQ,
-					VFE_MSG_OUTPUT_PRIMARY);
-		} else if ((op_mode & SNAPSHOT_MASK_MODE) &&
-				(vfe2x_ctrl->num_snap > 1)) {
-			int i = 0;
-			CDBG("Burst mode AXI config PRIM snap cnt %d\n",
-				vfe2x_ctrl->num_snap);
-			for (i = 0; i < vfe2x_ctrl->num_snap - 2; i++) {
-				free_buf = vfe2x_check_free_buffer(
-					VFE_MSG_OUTPUT_IRQ,
-					VFE_MSG_OUTPUT_PRIMARY);
-			}
-		}
-
-		if (op_mode & SNAPSHOT_MASK_MODE)
-			vfe_7x_config_axi(OUTPUT_PRIM,
-					&vfe2x_ctrl->snap, axio);
-		else
-			vfe_7x_config_axi(OUTPUT_PRIM,
-					&vfe2x_ctrl->prev, axio);
-		cmd_data = axio;
-	}
-		break;
-	case CMD_RAW_PICT_AXI_CFG: {
-		CDBG("CMD_RAW_PICT_AXI_CFG:%d\n", op_mode);
-		raw_mode = 1;
-		axio = kmalloc(sizeof(struct axiout), GFP_ATOMIC);
-		if (!axio) {
-			rc = -ENOMEM;
-			goto config_failure;
-		}
-
-		if (copy_from_user((char *)axio + 4,
-					(void __user *)(vfecmd.value),
-					sizeof(struct axiout))) {
-			rc = -EFAULT;
-			goto config_done;
-		}
-		header = cmds_map[vfecmd.id].vfe_id;
-		queue = cmds_map[vfecmd.id].queue;
-		rc = vfe2x_configure_pingpong_buffers(VFE_MSG_CAPTURE,
-						VFE_MSG_OUTPUT_PRIMARY);
-		if (rc < 0) {
-			pr_err("%s error configuring pingpong buffers"
-				" for preview", __func__);
-			rc = -EINVAL;
-			goto config_done;
-		}
-		if (header == -1 && queue == -1) {
-			rc = -EFAULT;
-			goto config_done;
-		}
-		*(uint32_t *)axio = header;
-		vfe_7x_config_axi(OUTPUT_PRIM, &vfe2x_ctrl->snap, axio);
-		cmd_data = axio;
-	}
-		break;
-	default:
-		break;
-	}
-
-	if (vfestopped)
-		goto config_done;
-
-config_send:
-	CDBG("send adsp command = %d\n", *(uint32_t *)cmd_data);
-	spin_lock_irqsave(&vfe2x_ctrl->table_lock, flags);
-	if (queue == QDSP_TABLEQUEUE &&
-			vfe2x_ctrl->tableack_pending) {
-		CDBG("store table cmd\n");
-		table_pending = kzalloc(sizeof(struct table_cmd), GFP_ATOMIC);
-		if (!table_pending) {
-			rc = -ENOMEM;
-			spin_unlock_irqrestore(&vfe2x_ctrl->table_lock, flags);
-			goto config_done;
-		}
-		table_pending->cmd = kzalloc(vfecmd.length + 4, GFP_ATOMIC);
-		if (!table_pending->cmd) {
-			kfree(table_pending);
-			rc = -ENOMEM;
-			spin_unlock_irqrestore(&vfe2x_ctrl->table_lock, flags);
-			goto config_done;
-		}
-		memcpy(table_pending->cmd, cmd_data, vfecmd.length + 4);
-		table_pending->queue = queue;
-		table_pending->size = vfecmd.length + 4;
-		list_add_tail(&table_pending->list, &vfe2x_ctrl->table_q);
-		spin_unlock_irqrestore(&vfe2x_ctrl->table_lock, flags);
-	} else {
-		if (queue == QDSP_TABLEQUEUE) {
-			CDBG("sending table cmd\n");
-			vfe2x_ctrl->tableack_pending = 1;
-			rc = msm_adsp_write(vfe_mod, queue,
-				cmd_data, vfecmd.length + 4);
-			spin_unlock_irqrestore(&vfe2x_ctrl->table_lock, flags);
-		} else {
-			if (*(uint32_t *)cmd_data == VFE_OUTPUT2_ACK) {
-				uint32_t *ptr = cmd_data;
-				CDBG("%x %x %x\n", ptr[0], ptr[1], ptr[2]);
-			}
-			CDBG("send n-table cmd\n");
-			rc = msm_adsp_write(vfe_mod, queue,
-				cmd_data, vfecmd.length + 4);
-			spin_unlock_irqrestore(&vfe2x_ctrl->table_lock, flags);
-			CDBG("%x\n", vfecmd.length + 4);
-		}
-	}
-
-config_done:
-	kfree(cmd_data_alloc);
-
-config_failure:
-	kfree(scfg);
-	kfree(axio);
-	kfree(sfcfg);
-	return rc;
-}
-
-static struct msm_cam_clk_info vfe2x_clk_info[] = {
-	{"vfe_clk", 192000000},
-};
-
-int msm_vfe_subdev_init(struct v4l2_subdev *sd)
-{
-	int rc = 0;
-	struct msm_cam_media_controller *mctl;
-	mctl = v4l2_get_subdev_hostdata(sd);
-	if (mctl == NULL) {
-		pr_err("%s: mctl is NULL\n", __func__);
-		rc = -EINVAL;
-		goto mctl_failed;
-	}
-
-	spin_lock_init(&vfe2x_ctrl->sd_notify_lock);
-	spin_lock_init(&vfe2x_ctrl->table_lock);
-	spin_lock_init(&vfe2x_ctrl->vfe_msg_lock);
-	spin_lock_init(&vfe2x_ctrl->liveshot_enabled_lock);
-	init_waitqueue_head(&stopevent.wait);
-	INIT_LIST_HEAD(&vfe2x_ctrl->table_q);
-	INIT_LIST_HEAD(&vfe2x_ctrl->vfe_msg_q);
-	stopevent.timeout = 200;
-	stopevent.state = 0;
-	vfe2x_ctrl->vfe_started = 0;
-
-	memset(&vfe2x_ctrl->stats_ctrl, 0, sizeof(struct msm_stats_bufq_ctrl));
-	memset(&vfe2x_ctrl->stats_ops, 0, sizeof(struct msm_stats_ops));
-
-	CDBG("msm_cam_clk_enable: enable vfe_clk\n");
-	rc = msm_cam_clk_enable(&vfe2x_ctrl->pdev->dev, vfe2x_clk_info,
-			vfe2x_ctrl->vfe_clk, ARRAY_SIZE(vfe2x_clk_info), 1);
-	if (rc < 0)
-		return rc;
-
-	msm_camio_set_perf_lvl(S_INIT);
-
-	/* TODO : check is it required */
-	extlen = sizeof(struct vfe_frame_extra);
-
-	extdata = kmalloc(extlen, GFP_ATOMIC);
-	if (!extdata) {
-		rc = -ENOMEM;
-		goto init_fail;
-	}
-
-	rc = msm_adsp_get("QCAMTASK", &qcam_mod, &vfe_7x_sync, NULL);
-	if (rc) {
-		rc = -EBUSY;
-		goto get_qcam_fail;
-	}
-
-	rc = msm_adsp_get("VFETASK", &vfe_mod, &vfe_7x_sync, NULL);
-	if (rc) {
-		rc = -EBUSY;
-		goto get_vfe_fail;
-	}
-	msm_adsp_enable(qcam_mod);
-	msm_adsp_enable(vfe_mod);
-	return 0;
-
-get_vfe_fail:
-	msm_adsp_put(qcam_mod);
-get_qcam_fail:
-	kfree(extdata);
-init_fail:
-	extlen = 0;
-mctl_failed:
-	return rc;
-}
-
-int msm_vpe_subdev_init(struct v4l2_subdev *sd)
-{
-	return 0;
-}
-
-void msm_vpe_subdev_release(struct v4l2_subdev *sd)
-{
-	return;
-}
-
-void msm_vfe_subdev_release(struct v4l2_subdev *sd)
-{
-	CDBG("msm_cam_clk_enable: disable vfe_clk\n");
-	msm_cam_clk_enable(&vfe2x_ctrl->pdev->dev, vfe2x_clk_info,
-			vfe2x_ctrl->vfe_clk, ARRAY_SIZE(vfe2x_clk_info), 0);
-	msm_adsp_disable(qcam_mod);
-	msm_adsp_disable(vfe_mod);
-
-	msm_adsp_put(qcam_mod);
-	msm_adsp_put(vfe_mod);
-
-	kfree(extdata);
-	msm_camio_set_perf_lvl(S_EXIT);
-	return;
-}
-
-static int msm_vfe_subdev_s_crystal_freq(struct v4l2_subdev *sd,
-	u32 freq, u32 flags)
-{
-	int rc = 0;
-	int round_rate;
-
-	round_rate = clk_round_rate(vfe2x_ctrl->vfe_clk[0], freq);
-	if (rc < 0) {
-		pr_err("%s: clk_round_rate failed %d\n",
-			__func__, rc);
-		return rc;
-	}
-
-	rc = clk_set_rate(vfe2x_ctrl->vfe_clk[0], round_rate);
-	if (rc < 0)
-		pr_err("%s: clk_set_rate failed %d\n",
-			__func__, rc);
-
-	return rc;
-}
-
-static const struct v4l2_subdev_video_ops msm_vfe_subdev_video_ops = {
-	.s_crystal_freq = msm_vfe_subdev_s_crystal_freq,
-};
-
-static const struct v4l2_subdev_core_ops msm_vfe_subdev_core_ops = {
-	.ioctl = msm_vfe_subdev_ioctl,
-};
-
-static const struct v4l2_subdev_ops msm_vfe_subdev_ops = {
-	.core = &msm_vfe_subdev_core_ops,
-	.video = &msm_vfe_subdev_video_ops,
-};
-
-static const struct v4l2_subdev_internal_ops msm_vfe_internal_ops;
-
-static int __devinit vfe2x_probe(struct platform_device *pdev)
-{
-	struct msm_cam_subdev_info sd_info;
-
-	CDBG("%s: device id = %d\n", __func__, pdev->id);
-	vfe2x_ctrl = kzalloc(sizeof(struct vfe2x_ctrl_type), GFP_KERNEL);
-	if (!vfe2x_ctrl) {
-		pr_err("%s: no enough memory\n", __func__);
-		return -ENOMEM;
-	}
-
-	v4l2_subdev_init(&vfe2x_ctrl->subdev, &msm_vfe_subdev_ops);
-	vfe2x_ctrl->subdev.internal_ops = &msm_vfe_internal_ops;
-	vfe2x_ctrl->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
-	snprintf(vfe2x_ctrl->subdev.name,
-			 sizeof(vfe2x_ctrl->subdev.name), "vfe2.x");
-	v4l2_set_subdevdata(&vfe2x_ctrl->subdev, vfe2x_ctrl);
-	platform_set_drvdata(pdev, &vfe2x_ctrl->subdev);
-
-	vfe2x_ctrl->pdev = pdev;
-	sd_info.sdev_type = VFE_DEV;
-	sd_info.sd_index = 0;
-	sd_info.irq_num = 0;
-	msm_cam_register_subdev_node(&vfe2x_ctrl->subdev, &sd_info);
-
-	media_entity_init(&vfe2x_ctrl->subdev.entity, 0, NULL, 0);
-	vfe2x_ctrl->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
-	vfe2x_ctrl->subdev.entity.group_id = VFE_DEV;
-	vfe2x_ctrl->subdev.entity.name = pdev->name;
-	vfe2x_ctrl->subdev.entity.revision = vfe2x_ctrl->subdev.devnode->num;
-	return 0;
-}
-
-static struct platform_driver vfe2x_driver = {
-	.probe = vfe2x_probe,
-	.driver = {
-		.name = MSM_VFE_DRV_NAME,
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init msm_vfe2x_init_module(void)
-{
-	return platform_driver_register(&vfe2x_driver);
-}
-
-static void __exit msm_vfe2x_exit_module(void)
-{
-	platform_driver_unregister(&vfe2x_driver);
-}
-
-module_init(msm_vfe2x_init_module);
-module_exit(msm_vfe2x_exit_module);
-MODULE_DESCRIPTION("VFE 2.x driver");
-MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe7x27a_v4l2.h b/drivers/media/platform/msm/camera_v1/vfe/msm_vfe7x27a_v4l2.h
deleted file mode 100644
index 78b1929..0000000
--- a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe7x27a_v4l2.h
+++ /dev/null
@@ -1,431 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- */
-
-#ifndef __MSM_VFE7X_H__
-#define __MSM_VFE7X_H__
-#include <media/msm_camera.h>
-#include <mach/camera.h>
-#include <linux/list.h>
-#include "msm.h"
-#include "msm_vfe_stats_buf.h"
-
-/*8 DSP buffers, 3 - ping, pong, free*/
-#define FREE_BUF_ARR_SIZE 5
-
-struct cmd_id_map {
-	uint32_t isp_id;
-	uint32_t vfe_id;
-	uint32_t queue;
-	char isp_id_name[64];
-	char vfe_id_name[64];
-} __packed;
-
-struct msg_id_map {
-	uint32_t vfe_id;
-	uint32_t isp_id;
-} __packed;
-
-struct table_cmd {
-	struct list_head list;
-	void *cmd;
-	int size;
-	int queue;
-} __packed;
-
-struct vfe_msg {
-	struct list_head list;
-	void *cmd;
-	int len;
-	int id;
-} __packed;
-
-struct buf_info {
-	/* Buffer */
-	struct msm_free_buf ping;
-	struct msm_free_buf pong;
-	struct msm_free_buf free_buf;
-	/*Array for holding the free buffer if more than one*/
-	struct msm_free_buf free_buf_arr[FREE_BUF_ARR_SIZE];
-	int free_buf_cnt;
-	int frame_cnt;
-} __packed;
-
-struct prev_free_buf_info {
-	struct msm_free_buf buf[3];
-};
-
-struct vfe_cmd_start {
-	uint32_t input_source:1;
-	uint32_t mode_of_operation:1;
-	uint32_t snap_number:4;
-	uint32_t /* reserved */ : 26;
-
-	/* Image Pipeline Modules */
-	uint32_t blacklevel_correction_enable:1;
-	uint32_t lens_rolloff_correction_enable:1;
-	uint32_t white_balance_enable:1;
-	uint32_t rgb_gamma_enable:1;
-	uint32_t luma_noise_reductionpath_enable:1;
-	uint32_t adaptive_spatialfilter_enable:1;
-	uint32_t chroma_subsample_enable:1;
-	uint32_t /* reserved */ : 25;
-
-	/* The dimension fed to the statistics module */
-	uint32_t last_pixel:12;
-	uint32_t /* reserved */ : 4;
-	uint32_t last_line:12;
-	uint32_t /* reserved */ : 4;
-} __packed;
-
-struct vfe2x_ctrl_type {
-	struct buf_info prev;
-	struct buf_info video;
-	struct buf_info snap;
-	struct buf_info raw;
-	struct buf_info thumb;
-	struct prev_free_buf_info free_buf;
-	struct buf_info zsl_prim;
-	struct buf_info zsl_sec;
-	struct prev_free_buf_info zsl_free_buf[2];
-
-
-	spinlock_t  table_lock;
-	struct list_head table_q;
-	uint32_t tableack_pending;
-	uint32_t vfeFrameId;
-
-	spinlock_t vfe_msg_lock;
-	struct list_head vfe_msg_q;
-
-	struct vfe_cmd_start start_cmd;
-	uint32_t start_pending;
-	uint32_t vfe_started;
-	uint32_t stop_pending;
-	uint32_t update_pending;
-
-	spinlock_t liveshot_enabled_lock;
-	uint32_t liveshot_enabled;
-
-	/* v4l2 subdev */
-	struct v4l2_subdev subdev;
-	struct platform_device *pdev;
-	struct clk *vfe_clk[3];
-	spinlock_t  sd_notify_lock;
-	uint32_t    reconfig_vfe;
-	uint32_t    zsl_mode;
-	spinlock_t  stats_bufq_lock;
-	struct msm_stats_bufq_ctrl stats_ctrl;
-	struct msm_stats_ops stats_ops;
-	unsigned long stats_we_buf_ptr[3];
-	unsigned long stats_af_buf_ptr[3];
-	int num_snap;
-} __packed;
-
-struct vfe_frame_extra {
-	uint32_t	bl_evencol:23;
-	uint32_t	rvd1:9;
-	uint32_t	bl_oddcol:23;
-	uint32_t	rvd2:9;
-
-	uint32_t	d_dbpc_stats_hot:16;
-	uint32_t	d_dbpc_stats_cold:16;
-
-	uint32_t	d_dbpc_stats_0_hot:10;
-	uint32_t	rvd3:6;
-	uint32_t	d_dbpc_stats_0_cold:10;
-	uint32_t	rvd4:6;
-	uint32_t	d_dbpc_stats_1_hot:10;
-	uint32_t	rvd5:6;
-	uint32_t	d_dbpc_stats_1_cold:10;
-	uint32_t	rvd6:6;
-
-	uint32_t	asf_max_edge;
-
-	uint32_t	e_y_wm_pm_stats_0:21;
-	uint32_t	rvd7:11;
-	uint32_t	e_y_wm_pm_stats_1_bl:8;
-	uint32_t	rvd8:8;
-	uint32_t	e_y_wm_pm_stats_1_nl:12;
-	uint32_t	rvd9:4;
-
-	uint32_t	e_cbcr_wm_pm_stats_0:21;
-	uint32_t	rvd10:11;
-	uint32_t	e_cbcr_wm_pm_stats_1_bl:8;
-	uint32_t	rvd11:8;
-	uint32_t	e_cbcr_wm_pm_stats_1_nl:12;
-	uint32_t	rvd12:4;
-
-	uint32_t	v_y_wm_pm_stats_0:21;
-	uint32_t	rvd13:11;
-	uint32_t	v_y_wm_pm_stats_1_bl:8;
-	uint32_t	rvd14:8;
-	uint32_t	v_y_wm_pm_stats_1_nl:12;
-	uint32_t	rvd15:4;
-
-	uint32_t	v_cbcr_wm_pm_stats_0:21;
-	uint32_t	rvd16:11;
-	uint32_t	v_cbcr_wm_pm_stats_1_bl:8;
-	uint32_t	rvd17:8;
-	uint32_t	v_cbcr_wm_pm_stats_1_nl:12;
-	uint32_t	rvd18:4;
-
-	uint32_t      frame_id;
-} __packed;
-
-struct vfe_endframe {
-	uint32_t      y_address;
-	uint32_t      cbcr_address;
-
-	struct vfe_frame_extra extra;
-} __packed;
-
-struct vfe_outputack {
-	uint32_t  header;
-	void      *output2newybufferaddress;
-	void      *output2newcbcrbufferaddress;
-} __packed;
-
-struct vfe_stats_ack {
-	uint32_t header;
-	/* MUST BE 64 bit ALIGNED */
-	void     *bufaddr;
-} __packed;
-
-/* AXI Output Config Command sent to DSP */
-struct axiout {
-	uint32_t            cmdheader:32;
-	int                 outputmode:3;
-	uint8_t             format:2;
-	uint32_t            /* reserved */ : 27;
-
-	/* AXI Output 1 Y Configuration, Part 1 */
-	uint32_t            out1yimageheight:12;
-	uint32_t            /* reserved */ : 4;
-	uint32_t            out1yimagewidthin64bitwords:10;
-	uint32_t            /* reserved */ : 6;
-
-	/* AXI Output 1 Y Configuration, Part 2 */
-	uint8_t             out1yburstlen:2;
-	uint32_t            out1ynumrows:12;
-	uint32_t            out1yrowincin64bitincs:12;
-	uint32_t            /* reserved */ : 6;
-
-	/* AXI Output 1 CbCr Configuration, Part 1 */
-	uint32_t            out1cbcrimageheight:12;
-	uint32_t            /* reserved */ : 4;
-	uint32_t            out1cbcrimagewidthin64bitwords:10;
-	uint32_t            /* reserved */ : 6;
-
-	/* AXI Output 1 CbCr Configuration, Part 2 */
-	uint8_t             out1cbcrburstlen:2;
-	uint32_t            out1cbcrnumrows:12;
-	uint32_t            out1cbcrrowincin64bitincs:12;
-	uint32_t            /* reserved */ : 6;
-
-	/* AXI Output 2 Y Configuration, Part 1 */
-	uint32_t            out2yimageheight:12;
-	uint32_t            /* reserved */ : 4;
-	uint32_t            out2yimagewidthin64bitwords:10;
-	uint32_t            /* reserved */ : 6;
-
-	/* AXI Output 2 Y Configuration, Part 2 */
-	uint8_t             out2yburstlen:2;
-	uint32_t            out2ynumrows:12;
-	uint32_t            out2yrowincin64bitincs:12;
-	uint32_t            /* reserved */ : 6;
-
-	/* AXI Output 2 CbCr Configuration, Part 1 */
-	uint32_t            out2cbcrimageheight:12;
-	uint32_t            /* reserved */ : 4;
-	uint32_t            out2cbcrimagewidtein64bitwords:10;
-	uint32_t            /* reserved */ : 6;
-
-	/* AXI Output 2 CbCr Configuration, Part 2 */
-	uint8_t             out2cbcrburstlen:2;
-	uint32_t            out2cbcrnumrows:12;
-	uint32_t            out2cbcrrowincin64bitincs:12;
-	uint32_t            /* reserved */ : 6;
-
-	/* Address configuration:
-	 * output1 phisycal address */
-	unsigned long   output1buffer1_y_phy;
-	unsigned long   output1buffer1_cbcr_phy;
-	unsigned long   output1buffer2_y_phy;
-	unsigned long   output1buffer2_cbcr_phy;
-	unsigned long   output1buffer3_y_phy;
-	unsigned long   output1buffer3_cbcr_phy;
-	unsigned long   output1buffer4_y_phy;
-	unsigned long   output1buffer4_cbcr_phy;
-	unsigned long   output1buffer5_y_phy;
-	unsigned long   output1buffer5_cbcr_phy;
-	unsigned long   output1buffer6_y_phy;
-	unsigned long   output1buffer6_cbcr_phy;
-	unsigned long   output1buffer7_y_phy;
-	unsigned long   output1buffer7_cbcr_phy;
-	unsigned long   output1buffer8_y_phy;
-	unsigned long   output1buffer8_cbcr_phy;
-
-	/* output2 phisycal address */
-	unsigned long   output2buffer1_y_phy;
-	unsigned long   output2buffer1_cbcr_phy;
-	unsigned long   output2buffer2_y_phy;
-	unsigned long   output2buffer2_cbcr_phy;
-	unsigned long   output2buffer3_y_phy;
-	unsigned long   output2buffer3_cbcr_phy;
-	unsigned long   output2buffer4_y_phy;
-	unsigned long   output2buffer4_cbcr_phy;
-	unsigned long   output2buffer5_y_phy;
-	unsigned long   output2buffer5_cbcr_phy;
-	unsigned long   output2buffer6_y_phy;
-	unsigned long   output2buffer6_cbcr_phy;
-	unsigned long   output2buffer7_y_phy;
-	unsigned long   output2buffer7_cbcr_phy;
-	unsigned long   output2buffer8_y_phy;
-	unsigned long   output2buffer8_cbcr_phy;
-} __packed;
-
-struct vfe_stats_we_cfg {
-	uint32_t       header;
-
-	/* White Balance/Exposure Statistic Selection */
-	uint8_t        wb_expstatsenable:1;
-	uint8_t        wb_expstatbuspriorityselection:1;
-	unsigned int   wb_expstatbuspriorityvalue:4;
-	unsigned int   /* reserved */ : 26;
-
-	/* White Balance/Exposure Statistic Configuration, Part 1 */
-	uint8_t        exposurestatregions:1;
-	uint8_t        exposurestatsubregions:1;
-	unsigned int   /* reserved */ : 14;
-
-	unsigned int   whitebalanceminimumy:8;
-	unsigned int   whitebalancemaximumy:8;
-
-	/* White Balance/Exposure Statistic Configuration, Part 2 */
-	uint8_t wb_expstatslopeofneutralregionline[
-		NUM_WB_EXP_NEUTRAL_REGION_LINES];
-
-	/* White Balance/Exposure Statistic Configuration, Part 3 */
-	unsigned int   wb_expstatcrinterceptofneutralregionline2:12;
-	unsigned int   /* reserved */ : 4;
-	unsigned int   wb_expstatcbinterceptofneutralreginnline1:12;
-	unsigned int    /* reserved */ : 4;
-
-	/* White Balance/Exposure Statistic Configuration, Part 4 */
-	unsigned int   wb_expstatcrinterceptofneutralregionline4:12;
-	unsigned int   /* reserved */ : 4;
-	unsigned int   wb_expstatcbinterceptofneutralregionline3:12;
-	unsigned int   /* reserved */ : 4;
-
-	/* White Balance/Exposure Statistic Output Buffer Header */
-	unsigned int   wb_expmetricheaderpattern:8;
-	unsigned int   /* reserved */ : 24;
-
-	/* White Balance/Exposure Statistic Output Buffers-MUST
-	* BE 64 bit ALIGNED */
-	void  *wb_expstatoutputbuffer[NUM_WB_EXP_STAT_OUTPUT_BUFFERS];
-} __packed;
-
-struct vfe_stats_af_cfg {
-	uint32_t header;
-
-	/* Autofocus Statistic Selection */
-	uint8_t       af_enable:1;
-	uint8_t       af_busprioritysel:1;
-	unsigned int  af_buspriorityval:4;
-	unsigned int  /* reserved */ : 26;
-
-	/* Autofocus Statistic Configuration, Part 1 */
-	unsigned int  af_singlewinvoffset:12;
-	unsigned int  /* reserved */ : 4;
-	unsigned int  af_singlewinhoffset:12;
-	unsigned int  /* reserved */ : 3;
-	uint8_t       af_winmode:1;
-
-	/* Autofocus Statistic Configuration, Part 2 */
-	unsigned int  af_singglewinvh:11;
-	unsigned int  /* reserved */ : 5;
-	unsigned int  af_singlewinhw:11;
-	unsigned int  /* reserved */ : 5;
-
-	/* Autofocus Statistic Configuration, Parts 3-6 */
-	uint8_t       af_multiwingrid[NUM_AUTOFOCUS_MULTI_WINDOW_GRIDS];
-
-	/* Autofocus Statistic Configuration, Part 7 */
-	signed int    af_metrichpfcoefa00:5;
-	signed int    af_metrichpfcoefa04:5;
-	unsigned int  af_metricmaxval:11;
-	uint8_t       af_metricsel:1;
-	unsigned int  /* reserved */ : 10;
-
-	/* Autofocus Statistic Configuration, Part 8 */
-	signed int    af_metrichpfcoefa20:5;
-	signed int    af_metrichpfcoefa21:5;
-	signed int    af_metrichpfcoefa22:5;
-	signed int    af_metrichpfcoefa23:5;
-	signed int    af_metrichpfcoefa24:5;
-	unsigned int  /* reserved */ : 7;
-
-	/* Autofocus Statistic Output Buffer Header */
-	unsigned int  af_metrichp:8;
-	unsigned int  /* reserved */ : 24;
-
-	/* Autofocus Statistic Output Buffers - MUST BE 64 bit ALIGNED!!! */
-	void *af_outbuf[NUM_AF_STAT_OUTPUT_BUFFERS];
-} __packed; /* VFE_StatsAutofocusConfigCmdType */
-
-struct msm_camera_frame_msg {
-	unsigned long   output_y_address;
-	unsigned long   output_cbcr_address;
-
-	unsigned int    blacklevelevenColumn:23;
-	uint16_t        reserved1:9;
-	unsigned int    blackleveloddColumn:23;
-	uint16_t        reserved2:9;
-
-	uint16_t        greendefectpixelcount:8;
-	uint16_t        reserved3:8;
-	uint16_t        redbluedefectpixelcount:8;
-	uint16_t        reserved4:8;
-} __packed;
-
-/* New one for 7k */
-struct msm_vfe_command_7k {
-	uint16_t queue;
-	uint16_t length;
-	void     *value;
-};
-
-struct stop_event {
-	wait_queue_head_t wait;
-	int state;
-	int timeout;
-};
-struct vfe_error_msg {
-	unsigned int camif_error:1;
-	unsigned int output1ybusoverflow:1;
-	unsigned int output1cbcrbusoverflow:1;
-	unsigned int output2ybusoverflow:1;
-	unsigned int output2cbcrbusoverflow:1;
-	unsigned int autofocusstatbusoverflow:1;
-	unsigned int wb_expstatbusoverflow:1;
-	unsigned int axierror:1;
-	unsigned int /* reserved */ : 24;
-	unsigned int camif_staus:1;
-	unsigned int pixel_count:14;
-	unsigned int line_count:14;
-	unsigned int /*reserved */ : 3;
-} __packed;
-
-static struct msm_free_buf *vfe2x_check_free_buffer(int id, int path);
-
-#endif /* __MSM_VFE7X_H__ */
diff --git a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe8x.c b/drivers/media/platform/msm/camera_v1/vfe/msm_vfe8x.c
deleted file mode 100644
index 953d634..0000000
--- a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe8x.c
+++ /dev/null
@@ -1,843 +0,0 @@
-/* Copyright (c) 2009, 2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/slab.h>
-#include <linux/uaccess.h>
-#include <linux/interrupt.h>
-#include <mach/irqs.h>
-#include "msm_vfe8x_proc.h"
-#include <linux/pm_qos.h>
-
-#define ON  1
-#define OFF 0
-
-static const char *vfe_general_cmd[] = {
-	"START",  /* 0 */
-	"RESET",
-	"AXI_INPUT_CONFIG",
-	"CAMIF_CONFIG",
-	"AXI_OUTPUT_CONFIG",
-	"BLACK_LEVEL_CONFIG",  /* 5 */
-	"ROLL_OFF_CONFIG",
-	"DEMUX_CHANNEL_GAIN_CONFIG",
-	"DEMOSAIC_CONFIG",
-	"FOV_CROP_CONFIG",
-	"MAIN_SCALER_CONFIG",  /* 10 */
-	"WHITE_BALANCE_CONFIG",
-	"COLOR_CORRECTION_CONFIG",
-	"LA_CONFIG",
-	"RGB_GAMMA_CONFIG",
-	"CHROMA_ENHAN_CONFIG",  /* 15 */
-	"CHROMA_SUPPRESSION_CONFIG",
-	"ASF_CONFIG",
-	"SCALER2Y_CONFIG",
-	"SCALER2CbCr_CONFIG",
-	"CHROMA_SUBSAMPLE_CONFIG",  /* 20 */
-	"FRAME_SKIP_CONFIG",
-	"OUTPUT_CLAMP_CONFIG",
-	"TEST_GEN_START",
-	"UPDATE",
-	"OUTPUT1_ACK",  /* 25 */
-	"OUTPUT2_ACK",
-	"EPOCH1_ACK",
-	"EPOCH2_ACK",
-	"STATS_AUTOFOCUS_ACK",
-	"STATS_WB_EXP_ACK",  /* 30 */
-	"BLACK_LEVEL_UPDATE",
-	"DEMUX_CHANNEL_GAIN_UPDATE",
-	"DEMOSAIC_BPC_UPDATE",
-	"DEMOSAIC_ABF_UPDATE",
-	"FOV_CROP_UPDATE",  /* 35 */
-	"WHITE_BALANCE_UPDATE",
-	"COLOR_CORRECTION_UPDATE",
-	"LA_UPDATE",
-	"RGB_GAMMA_UPDATE",
-	"CHROMA_ENHAN_UPDATE",  /* 40 */
-	"CHROMA_SUPPRESSION_UPDATE",
-	"MAIN_SCALER_UPDATE",
-	"SCALER2CbCr_UPDATE",
-	"SCALER2Y_UPDATE",
-	"ASF_UPDATE",  /* 45 */
-	"FRAME_SKIP_UPDATE",
-	"CAMIF_FRAME_UPDATE",
-	"STATS_AUTOFOCUS_UPDATE",
-	"STATS_WB_EXP_UPDATE",
-	"STOP",  /* 50 */
-	"GET_HW_VERSION",
-	"STATS_SETTING",
-	"STATS_AUTOFOCUS_START",
-	"STATS_AUTOFOCUS_STOP",
-	"STATS_WB_EXP_START",  /* 55 */
-	"STATS_WB_EXP_STOP",
-	"ASYNC_TIMER_SETTING",
-};
-
-static void     *vfe_syncdata;
-
-static int vfe_enable(struct camera_enable_cmd *enable)
-{
-	return 0;
-}
-
-static int vfe_disable(struct camera_enable_cmd *enable,
-	struct platform_device *dev)
-{
-	vfe_stop();
-	msm_camio_disable(dev);
-	return 0;
-}
-
-static void vfe_release(struct platform_device *dev)
-{
-	msm_camio_disable(dev);
-	vfe_cmd_release(dev);
-	update_axi_qos(PM_QOS_DEFAULT_VALUE);
-	vfe_syncdata = NULL;
-}
-
-static void vfe_config_axi(int mode,
-			   struct axidata *ad,
-			   struct vfe_cmd_axi_output_config *ao)
-{
-	struct msm_pmem_region *regptr, *regptr1;
-	int i, j;
-	uint32_t *p1, *p2;
-
-	if (mode == OUTPUT_1 || mode == OUTPUT_1_AND_2) {
-		regptr = ad->region;
-		for (i = 0; i < ad->bufnum1; i++) {
-
-			p1 = &(ao->output1.outputY.outFragments[i][0]);
-			p2 = &(ao->output1.outputCbcr.outFragments[i][0]);
-
-			for (j = 0; j < ao->output1.fragmentCount; j++) {
-
-				*p1 = regptr->paddr + regptr->info.planar0_off;
-				p1++;
-
-				*p2 = regptr->paddr + regptr->info.planar1_off;
-				p2++;
-			}
-			regptr++;
-		}
-	} /* if OUTPUT1 or Both */
-
-	if (mode == OUTPUT_2 || mode == OUTPUT_1_AND_2) {
-
-		regptr = &(ad->region[ad->bufnum1]);
-		CDBG("bufnum2 = %d\n", ad->bufnum2);
-
-		for (i = 0; i < ad->bufnum2; i++) {
-
-			p1 = &(ao->output2.outputY.outFragments[i][0]);
-			p2 = &(ao->output2.outputCbcr.outFragments[i][0]);
-
-			CDBG("config_axi: O2, phy = 0x%lx, y_off = %d, "\
-			     "cbcr_off = %d\n", regptr->paddr,
-				regptr->info.planar0_off,
-				regptr->info.planar1_off);
-
-			for (j = 0; j < ao->output2.fragmentCount; j++) {
-
-				*p1 = regptr->paddr + regptr->info.planar0_off;
-				CDBG("vfe_config_axi: p1 = 0x%x\n", *p1);
-				p1++;
-
-				*p2 = regptr->paddr + regptr->info.planar1_off;
-				CDBG("vfe_config_axi: p2 = 0x%x\n", *p2);
-				p2++;
-			}
-			regptr++;
-		}
-	}
-	/* For video configuration */
-	if (mode == OUTPUT_1_AND_3) {
-		/* this is preview buffer. */
-		regptr =  &(ad->region[0]);
-		/* this is video buffer. */
-		regptr1 = &(ad->region[ad->bufnum1]);
-		CDBG("bufnum1 = %d\n", ad->bufnum1);
-		CDBG("bufnum2 = %d\n", ad->bufnum2);
-
-	for (i = 0; i < ad->bufnum1; i++) {
-		p1 = &(ao->output1.outputY.outFragments[i][0]);
-		p2 = &(ao->output1.outputCbcr.outFragments[i][0]);
-
-		CDBG("config_axi: O1, phy = 0x%lx, y_off = %d, "\
-			 "cbcr_off = %d\n", regptr->paddr,
-			 regptr->info.planar0_off, regptr->info.planar1_off);
-
-			for (j = 0; j < ao->output1.fragmentCount; j++) {
-
-				*p1 = regptr->paddr + regptr->info.planar0_off;
-				CDBG("vfe_config_axi: p1 = 0x%x\n", *p1);
-				p1++;
-
-				*p2 = regptr->paddr + regptr->info.planar1_off;
-				CDBG("vfe_config_axi: p2 = 0x%x\n", *p2);
-				p2++;
-			}
-			regptr++;
-		}
-	for (i = 0; i < ad->bufnum2; i++) {
-		p1 = &(ao->output2.outputY.outFragments[i][0]);
-		p2 = &(ao->output2.outputCbcr.outFragments[i][0]);
-
-		CDBG("config_axi: O2, phy = 0x%lx, y_off = %d, "\
-			 "cbcr_off = %d\n", regptr1->paddr,
-			 regptr1->info.planar0_off, regptr1->info.planar1_off);
-
-			for (j = 0; j < ao->output2.fragmentCount; j++) {
-				*p1 = regptr1->paddr +
-					regptr1->info.planar0_off;
-				CDBG("vfe_config_axi: p1 = 0x%x\n", *p1);
-				p1++;
-				*p2 = regptr1->paddr +
-					r1->info.planar1_off;
-				CDBG("vfe_config_axi: p2 = 0x%x\n", *p2);
-				p2++;
-			}
-			regptr1++;
-		}
-	}
-
-}
-
-#define CHECKED_COPY_FROM_USER(in) {					\
-	if (cmd->length != sizeof(*(in))) {				\
-		pr_err("msm_camera: %s:%d cmd %d: user data size %d "	\
-			"!= kernel data size %d\n",			\
-			__func__, __LINE__,				\
-			cmd->id, cmd->length, sizeof(*(in)));		\
-		rc = -EIO;						\
-		break;							\
-	}								\
-	if (copy_from_user((in), (void __user *)cmd->value,		\
-			sizeof(*(in)))) {				\
-		rc = -EFAULT;						\
-		break;							\
-	}								\
-}
-
-static int vfe_proc_general(struct msm_vfe_command_8k *cmd)
-{
-	int rc = 0;
-
-	CDBG("%s: cmdID = %s\n", __func__, vfe_general_cmd[cmd->id]);
-
-	switch (cmd->id) {
-	case VFE_CMD_ID_RESET:
-		msm_camio_vfe_blk_reset();
-		msm_camio_camif_pad_reg_reset_2();
-		vfe_reset();
-		break;
-
-	case VFE_CMD_ID_START: {
-		struct vfe_cmd_start start;
-			CHECKED_COPY_FROM_USER(&start);
-
-		/* msm_camio_camif_pad_reg_reset_2(); */
-		msm_camio_camif_pad_reg_reset();
-		vfe_start(&start);
-	}
-		break;
-
-	case VFE_CMD_ID_CAMIF_CONFIG: {
-		struct vfe_cmd_camif_config camif;
-			CHECKED_COPY_FROM_USER(&camif);
-
-		vfe_camif_config(&camif);
-	}
-		break;
-
-	case VFE_CMD_ID_BLACK_LEVEL_CONFIG: {
-		struct vfe_cmd_black_level_config bl;
-			CHECKED_COPY_FROM_USER(&bl);
-
-		vfe_black_level_config(&bl);
-	}
-		break;
-
-	case VFE_CMD_ID_ROLL_OFF_CONFIG:{
-			/* rolloff is too big to be on the stack */
-			struct vfe_cmd_roll_off_config *rolloff =
-			    kmalloc(sizeof(struct vfe_cmd_roll_off_config),
-				    GFP_KERNEL);
-			if (!rolloff) {
-				pr_err("%s: out of memory\n", __func__);
-				rc = -ENOMEM;
-				break;
-			}
-			/* Wrap CHECKED_COPY_FROM_USER() in a do-while(0) loop
-			 * to make sure we free rolloff when copy_from_user()
-			 * fails.
-			 */
-			do {
-				CHECKED_COPY_FROM_USER(rolloff);
-				vfe_roll_off_config(rolloff);
-			} while (0);
-			kfree(rolloff);
-	}
-		break;
-
-	case VFE_CMD_ID_DEMUX_CHANNEL_GAIN_CONFIG: {
-		struct vfe_cmd_demux_channel_gain_config demuxc;
-			CHECKED_COPY_FROM_USER(&demuxc);
-
-		/* demux is always enabled.  */
-		vfe_demux_channel_gain_config(&demuxc);
-	}
-		break;
-
-	case VFE_CMD_ID_DEMOSAIC_CONFIG: {
-		struct vfe_cmd_demosaic_config demosaic;
-			CHECKED_COPY_FROM_USER(&demosaic);
-
-		vfe_demosaic_config(&demosaic);
-	}
-		break;
-
-	case VFE_CMD_ID_FOV_CROP_CONFIG:
-	case VFE_CMD_ID_FOV_CROP_UPDATE: {
-		struct vfe_cmd_fov_crop_config fov;
-			CHECKED_COPY_FROM_USER(&fov);
-
-		vfe_fov_crop_config(&fov);
-	}
-		break;
-
-	case VFE_CMD_ID_MAIN_SCALER_CONFIG:
-	case VFE_CMD_ID_MAIN_SCALER_UPDATE: {
-		struct vfe_cmd_main_scaler_config mainds;
-			CHECKED_COPY_FROM_USER(&mainds);
-
-		vfe_main_scaler_config(&mainds);
-	}
-		break;
-
-	case VFE_CMD_ID_WHITE_BALANCE_CONFIG:
-	case VFE_CMD_ID_WHITE_BALANCE_UPDATE: {
-		struct vfe_cmd_white_balance_config wb;
-			CHECKED_COPY_FROM_USER(&wb);
-
-		vfe_white_balance_config(&wb);
-	}
-		break;
-
-	case VFE_CMD_ID_COLOR_CORRECTION_CONFIG:
-	case VFE_CMD_ID_COLOR_CORRECTION_UPDATE: {
-		struct vfe_cmd_color_correction_config cc;
-			CHECKED_COPY_FROM_USER(&cc);
-
-		vfe_color_correction_config(&cc);
-	}
-		break;
-
-	case VFE_CMD_ID_LA_CONFIG: {
-		struct vfe_cmd_la_config la;
-			CHECKED_COPY_FROM_USER(&la);
-
-		vfe_la_config(&la);
-	}
-		break;
-
-	case VFE_CMD_ID_RGB_GAMMA_CONFIG: {
-		struct vfe_cmd_rgb_gamma_config rgb;
-			CHECKED_COPY_FROM_USER(&rgb);
-
-		rc = vfe_rgb_gamma_config(&rgb);
-	}
-		break;
-
-	case VFE_CMD_ID_CHROMA_ENHAN_CONFIG:
-	case VFE_CMD_ID_CHROMA_ENHAN_UPDATE: {
-		struct vfe_cmd_chroma_enhan_config chrom;
-			CHECKED_COPY_FROM_USER(&chrom);
-
-		vfe_chroma_enhan_config(&chrom);
-	}
-		break;
-
-	case VFE_CMD_ID_CHROMA_SUPPRESSION_CONFIG:
-	case VFE_CMD_ID_CHROMA_SUPPRESSION_UPDATE: {
-		struct vfe_cmd_chroma_suppression_config chromsup;
-			CHECKED_COPY_FROM_USER(&chromsup);
-
-		vfe_chroma_sup_config(&chromsup);
-	}
-		break;
-
-	case VFE_CMD_ID_ASF_CONFIG: {
-		struct vfe_cmd_asf_config asf;
-			CHECKED_COPY_FROM_USER(&asf);
-
-		vfe_asf_config(&asf);
-	}
-		break;
-
-	case VFE_CMD_ID_SCALER2Y_CONFIG:
-	case VFE_CMD_ID_SCALER2Y_UPDATE: {
-		struct vfe_cmd_scaler2_config ds2y;
-			CHECKED_COPY_FROM_USER(&ds2y);
-
-		vfe_scaler2y_config(&ds2y);
-	}
-		break;
-
-	case VFE_CMD_ID_SCALER2CbCr_CONFIG:
-	case VFE_CMD_ID_SCALER2CbCr_UPDATE: {
-		struct vfe_cmd_scaler2_config ds2cbcr;
-			CHECKED_COPY_FROM_USER(&ds2cbcr);
-
-		vfe_scaler2cbcr_config(&ds2cbcr);
-	}
-		break;
-
-	case VFE_CMD_ID_CHROMA_SUBSAMPLE_CONFIG: {
-		struct vfe_cmd_chroma_subsample_config sub;
-			CHECKED_COPY_FROM_USER(&sub);
-
-		vfe_chroma_subsample_config(&sub);
-	}
-		break;
-
-	case VFE_CMD_ID_FRAME_SKIP_CONFIG: {
-		struct vfe_cmd_frame_skip_config fskip;
-			CHECKED_COPY_FROM_USER(&fskip);
-
-		vfe_frame_skip_config(&fskip);
-	}
-		break;
-
-	case VFE_CMD_ID_OUTPUT_CLAMP_CONFIG: {
-		struct vfe_cmd_output_clamp_config clamp;
-			CHECKED_COPY_FROM_USER(&clamp);
-
-		vfe_output_clamp_config(&clamp);
-	}
-		break;
-
-	/* module update commands */
-	case VFE_CMD_ID_BLACK_LEVEL_UPDATE: {
-		struct vfe_cmd_black_level_config blk;
-			CHECKED_COPY_FROM_USER(&blk);
-
-		vfe_black_level_update(&blk);
-	}
-		break;
-
-	case VFE_CMD_ID_DEMUX_CHANNEL_GAIN_UPDATE: {
-		struct vfe_cmd_demux_channel_gain_config dmu;
-			CHECKED_COPY_FROM_USER(&dmu);
-
-		vfe_demux_channel_gain_update(&dmu);
-	}
-		break;
-
-	case VFE_CMD_ID_DEMOSAIC_BPC_UPDATE: {
-		struct vfe_cmd_demosaic_bpc_update demo_bpc;
-			CHECKED_COPY_FROM_USER(&demo_bpc);
-
-		vfe_demosaic_bpc_update(&demo_bpc);
-	}
-		break;
-
-	case VFE_CMD_ID_DEMOSAIC_ABF_UPDATE: {
-		struct vfe_cmd_demosaic_abf_update demo_abf;
-			CHECKED_COPY_FROM_USER(&demo_abf);
-
-		vfe_demosaic_abf_update(&demo_abf);
-	}
-		break;
-
-	case VFE_CMD_ID_LA_UPDATE: {
-		struct vfe_cmd_la_config la;
-			CHECKED_COPY_FROM_USER(&la);
-
-		vfe_la_update(&la);
-	}
-		break;
-
-	case VFE_CMD_ID_RGB_GAMMA_UPDATE: {
-		struct vfe_cmd_rgb_gamma_config rgb;
-			CHECKED_COPY_FROM_USER(&rgb);
-
-		rc = vfe_rgb_gamma_update(&rgb);
-	}
-		break;
-
-	case VFE_CMD_ID_ASF_UPDATE: {
-		struct vfe_cmd_asf_update asf;
-			CHECKED_COPY_FROM_USER(&asf);
-
-		vfe_asf_update(&asf);
-	}
-		break;
-
-	case VFE_CMD_ID_FRAME_SKIP_UPDATE: {
-		struct vfe_cmd_frame_skip_update fskip;
-			CHECKED_COPY_FROM_USER(&fskip);
-			/* Start recording */
-			if (fskip.output2Pattern == 0xffffffff)
-				update_axi_qos(MSM_AXI_QOS_RECORDING);
-			 else if (fskip.output2Pattern == 0)
-				update_axi_qos(MSM_AXI_QOS_PREVIEW);
-
-		vfe_frame_skip_update(&fskip);
-	}
-		break;
-
-	case VFE_CMD_ID_CAMIF_FRAME_UPDATE: {
-		struct vfe_cmds_camif_frame fup;
-			CHECKED_COPY_FROM_USER(&fup);
-
-		vfe_camif_frame_update(&fup);
-	}
-		break;
-
-	/* stats update commands */
-	case VFE_CMD_ID_STATS_AUTOFOCUS_UPDATE: {
-		struct vfe_cmd_stats_af_update afup;
-			CHECKED_COPY_FROM_USER(&afup);
-
-		vfe_stats_update_af(&afup);
-	}
-		break;
-
-	case VFE_CMD_ID_STATS_WB_EXP_UPDATE: {
-		struct vfe_cmd_stats_wb_exp_update wbexp;
-			CHECKED_COPY_FROM_USER(&wbexp);
-
-		vfe_stats_update_wb_exp(&wbexp);
-	}
-		break;
-
-	/* control of start, stop, update, etc... */
-	case VFE_CMD_ID_STOP:
-		vfe_stop();
-		break;
-
-	case VFE_CMD_ID_GET_HW_VERSION:
-		break;
-
-	/* stats */
-	case VFE_CMD_ID_STATS_SETTING: {
-		struct vfe_cmd_stats_setting stats;
-			CHECKED_COPY_FROM_USER(&stats);
-
-		vfe_stats_setting(&stats);
-	}
-		break;
-
-	case VFE_CMD_ID_STATS_AUTOFOCUS_START: {
-		struct vfe_cmd_stats_af_start af;
-			CHECKED_COPY_FROM_USER(&af);
-
-		vfe_stats_start_af(&af);
-	}
-		break;
-
-	case VFE_CMD_ID_STATS_AUTOFOCUS_STOP:
-		vfe_stats_af_stop();
-		break;
-
-	case VFE_CMD_ID_STATS_WB_EXP_START: {
-		struct vfe_cmd_stats_wb_exp_start awexp;
-			CHECKED_COPY_FROM_USER(&awexp);
-
-		vfe_stats_start_wb_exp(&awexp);
-	}
-		break;
-
-	case VFE_CMD_ID_STATS_WB_EXP_STOP:
-		vfe_stats_wb_exp_stop();
-		break;
-
-	case VFE_CMD_ID_ASYNC_TIMER_SETTING:
-		break;
-
-	case VFE_CMD_ID_UPDATE:
-		vfe_update();
-		break;
-
-	/* test gen */
-	case VFE_CMD_ID_TEST_GEN_START:
-		break;
-
-/*
-  acknowledge from upper layer
-	these are not in general command.
-
-	case VFE_CMD_ID_OUTPUT1_ACK:
-		break;
-	case VFE_CMD_ID_OUTPUT2_ACK:
-		break;
-	case VFE_CMD_ID_EPOCH1_ACK:
-		break;
-	case VFE_CMD_ID_EPOCH2_ACK:
-		break;
-	case VFE_CMD_ID_STATS_AUTOFOCUS_ACK:
-		break;
-	case VFE_CMD_ID_STATS_WB_EXP_ACK:
-		break;
-*/
-
-	default:
-		pr_err("%s: invalid cmd id %d\n", __func__, cmd->id);
-		rc = -EINVAL;
-		break;
-	} /* switch */
-
-	return rc;
-}
-
-static int vfe_config(struct msm_vfe_cfg_cmd *cmd, void *data)
-{
-	struct msm_pmem_region *regptr;
-	struct msm_vfe_command_8k vfecmd;
-	struct vfe_cmd_axi_output_config axio;
-	struct axidata *axid = data;
-
-	int rc = 0;
-
-
-	if (cmd->cmd_type != CMD_FRAME_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_BUF_RELEASE &&
-		cmd->cmd_type != CMD_STATS_AF_BUF_RELEASE) {
-
-		if (copy_from_user(&vfecmd,
-			(void __user *)(cmd->value), sizeof(vfecmd))) {
-			pr_err("%s %d: copy_from_user failed\n",
-				__func__, __LINE__);
-			return -EFAULT;
-		}
-	}
-
-	CDBG("%s: cmdType = %d\n", __func__, cmd->cmd_type);
-
-	switch (cmd->cmd_type) {
-	case CMD_GENERAL:
-		rc = vfe_proc_general(&vfecmd);
-		break;
-
-	case CMD_STATS_ENABLE:
-	case CMD_STATS_AXI_CFG: {
-			int i;
-			struct vfe_cmd_stats_setting scfg;
-
-			BUG_ON(!axid);
-
-			if (vfecmd.length != sizeof(scfg)) {
-				pr_err
-				("msm_camera: %s: cmd %d: user-space "\
-				"data size %d != kernel data size %d\n",
-				__func__,
-				cmd->cmd_type, vfecmd.length,
-				sizeof(scfg));
-				return -EIO;
-			}
-
-			if (copy_from_user(&scfg,
-				(void __user *)(vfecmd.value),
-				sizeof(scfg))) {
-				pr_err("%s %d: copy_from_user failed\n",
-				__func__, __LINE__);
-			return -EFAULT;
-		}
-
-		regptr = axid->region;
-		if (axid->bufnum1 > 0) {
-			for (i = 0; i < axid->bufnum1; i++) {
-					scfg.awbBuffer[i] =
-					(uint32_t)(regptr->paddr);
-				regptr++;
-			}
-		}
-
-		if (axid->bufnum2 > 0) {
-			for (i = 0; i < axid->bufnum2; i++) {
-					scfg.afBuffer[i] =
-					(uint32_t)(regptr->paddr);
-				regptr++;
-			}
-		}
-
-			vfe_stats_setting(&scfg);
-	}
-		break;
-
-	case CMD_STATS_AF_AXI_CFG:
-		break;
-
-	case CMD_FRAME_BUF_RELEASE: {
-		/* preview buffer release */
-		struct msm_frame *b;
-		unsigned long p;
-		struct vfe_cmd_output_ack fack;
-
-			BUG_ON(!data);
-
-		b = (struct msm_frame *)(cmd->value);
-		p = *(unsigned long *)data;
-
-			fack.ybufaddr[0] = (uint32_t) (p + b->planar0_off);
-
-			fack.chromabufaddr[0] = (uint32_t) (p + b->planar1_off);
-
-		if (b->path == OUTPUT_TYPE_P)
-			vfe_output_p_ack(&fack);
-
-		if ((b->path == OUTPUT_TYPE_V)
-			 || (b->path == OUTPUT_TYPE_S))
-			vfe_output_v_ack(&fack);
-	}
-		break;
-
-	case CMD_SNAP_BUF_RELEASE:
-		break;
-
-	case CMD_STATS_BUF_RELEASE: {
-		struct vfe_cmd_stats_wb_exp_ack sack;
-
-			BUG_ON(!data);
-
-		sack.nextWbExpOutputBufferAddr = *(uint32_t *)data;
-		vfe_stats_wb_exp_ack(&sack);
-	}
-		break;
-
-	case CMD_STATS_AF_BUF_RELEASE: {
-		struct vfe_cmd_stats_af_ack ack;
-
-			BUG_ON(!data);
-
-		ack.nextAFOutputBufferAddr = *(uint32_t *)data;
-		vfe_stats_af_ack(&ack);
-	}
-		break;
-
-	case CMD_AXI_CFG_PREVIEW:
-	case CMD_RAW_PICT_AXI_CFG: {
-
-			BUG_ON(!axid);
-
-			if (copy_from_user(&axio, (void __user *)(vfecmd.value),
-				sizeof(axio))) {
-				pr_err("%s %d: copy_from_user failed\n",
-					__func__, __LINE__);
-			return -EFAULT;
-		}
-			/* Validate the data from user space */
-			if (axio.output2.fragmentCount <
-				VFE_MIN_NUM_FRAGMENTS_PER_FRAME ||
-				axio.output2.fragmentCount >
-				VFE_MAX_NUM_FRAGMENTS_PER_FRAME)
-				return -EINVAL;
-
-			vfe_config_axi(OUTPUT_2, axid, &axio);
-			axio.outputDataSize = 0;
-			vfe_axi_output_config(&axio);
-	}
-		break;
-
-	case CMD_AXI_CFG_SNAP: {
-
-			BUG_ON(!axid);
-
-			if (copy_from_user(&axio, (void __user *)(vfecmd.value),
-				sizeof(axio))) {
-				pr_err("%s %d: copy_from_user failed\n",
-					__func__, __LINE__);
-			return -EFAULT;
-		}
-			/* Validate the data from user space */
-			if (axio.output1.fragmentCount <
-				VFE_MIN_NUM_FRAGMENTS_PER_FRAME ||
-				axio.output1.fragmentCount >
-				VFE_MAX_NUM_FRAGMENTS_PER_FRAME ||
-				axio.output2.fragmentCount <
-				VFE_MIN_NUM_FRAGMENTS_PER_FRAME ||
-				axio.output2.fragmentCount >
-				VFE_MAX_NUM_FRAGMENTS_PER_FRAME)
-				return -EINVAL;
-
-			vfe_config_axi(OUTPUT_1_AND_2, axid, &axio);
-			vfe_axi_output_config(&axio);
-	}
-		break;
-
-	case CMD_AXI_CFG_VIDEO: {
-			BUG_ON(!axid);
-
-			if (copy_from_user(&axio, (void __user *)(vfecmd.value),
-				sizeof(axio))) {
-				pr_err("%s %d: copy_from_user failed\n",
-					__func__, __LINE__);
-			return -EFAULT;
-		}
-			/* Validate the data from user space */
-			if (axio.output1.fragmentCount <
-				VFE_MIN_NUM_FRAGMENTS_PER_FRAME ||
-				axio.output1.fragmentCount >
-				VFE_MAX_NUM_FRAGMENTS_PER_FRAME ||
-				axio.output2.fragmentCount <
-				VFE_MIN_NUM_FRAGMENTS_PER_FRAME ||
-				axio.output2.fragmentCount >
-				VFE_MAX_NUM_FRAGMENTS_PER_FRAME)
-				return -EINVAL;
-
-			vfe_config_axi(OUTPUT_1_AND_3, axid, &axio);
-			axio.outputDataSize = 0;
-			vfe_axi_output_config(&axio);
-	}
-		break;
-
-	default:
-		break;
-	} /* switch */
-
-	return rc;
-}
-
-static int vfe_init(struct msm_vfe_callback *presp, struct platform_device *dev)
-{
-	int rc = 0;
-
-	rc = vfe_cmd_init(presp, dev, vfe_syncdata);
-	if (rc < 0)
-		return rc;
-
-	/* Bring up all the required GPIOs and Clocks */
-	rc = msm_camio_enable(dev);
-
-	return rc;
-}
-
-void msm_camvfe_fn_init(struct msm_camvfe_fn *fptr, void *data)
-{
-	fptr->vfe_init    = vfe_init;
-	fptr->vfe_enable  = vfe_enable;
-	fptr->vfe_config  = vfe_config;
-	fptr->vfe_disable = vfe_disable;
-	fptr->vfe_release = vfe_release;
-	vfe_syncdata = data;
-}
-
-void msm_camvpe_fn_init(struct msm_camvpe_fn *fptr, void *data)
-{
-	fptr->vpe_reg		= NULL;
-	fptr->send_frame_to_vpe	= NULL;
-	fptr->vpe_config	= NULL;
-	fptr->vpe_cfg_update	= NULL;
-	fptr->dis		= NULL;
-}
diff --git a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe8x.h b/drivers/media/platform/msm/camera_v1/vfe/msm_vfe8x.h
deleted file mode 100644
index 54e9c95..0000000
--- a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe8x.h
+++ /dev/null
@@ -1,909 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-
-#ifndef __MSM_VFE8X_H__
-#define __MSM_VFE8X_H__
-
-#define TRUE  1
-#define FALSE 0
-#define boolean uint8_t
-
-enum  VFE_STATE {
-	VFE_STATE_IDLE,
-	VFE_STATE_ACTIVE
-};
-
-enum vfe_cmd_id {
-	/*
-	*Important! Command_ID are arranged in order.
-	*Don't change!*/
-	VFE_CMD_ID_START,
-	VFE_CMD_ID_RESET,
-
-	/* bus and camif config */
-	VFE_CMD_ID_AXI_INPUT_CONFIG,
-	VFE_CMD_ID_CAMIF_CONFIG,
-	VFE_CMD_ID_AXI_OUTPUT_CONFIG,
-
-	/* module config  */
-	VFE_CMD_ID_BLACK_LEVEL_CONFIG,
-	VFE_CMD_ID_ROLL_OFF_CONFIG,
-	VFE_CMD_ID_DEMUX_CHANNEL_GAIN_CONFIG,
-	VFE_CMD_ID_DEMOSAIC_CONFIG,
-	VFE_CMD_ID_FOV_CROP_CONFIG,
-	VFE_CMD_ID_MAIN_SCALER_CONFIG,
-	VFE_CMD_ID_WHITE_BALANCE_CONFIG,
-	VFE_CMD_ID_COLOR_CORRECTION_CONFIG,
-	VFE_CMD_ID_LA_CONFIG,
-	VFE_CMD_ID_RGB_GAMMA_CONFIG,
-	VFE_CMD_ID_CHROMA_ENHAN_CONFIG,
-	VFE_CMD_ID_CHROMA_SUPPRESSION_CONFIG,
-	VFE_CMD_ID_ASF_CONFIG,
-	VFE_CMD_ID_SCALER2Y_CONFIG,
-	VFE_CMD_ID_SCALER2CbCr_CONFIG,
-	VFE_CMD_ID_CHROMA_SUBSAMPLE_CONFIG,
-	VFE_CMD_ID_FRAME_SKIP_CONFIG,
-	VFE_CMD_ID_OUTPUT_CLAMP_CONFIG,
-
-	/* test gen */
-	VFE_CMD_ID_TEST_GEN_START,
-
-	VFE_CMD_ID_UPDATE,
-
-	/* ackownledge from upper layer */
-	VFE_CMD_ID_OUTPUT1_ACK,
-	VFE_CMD_ID_OUTPUT2_ACK,
-	VFE_CMD_ID_EPOCH1_ACK,
-	VFE_CMD_ID_EPOCH2_ACK,
-	VFE_CMD_ID_STATS_AUTOFOCUS_ACK,
-	VFE_CMD_ID_STATS_WB_EXP_ACK,
-
-	/* module update commands */
-	VFE_CMD_ID_BLACK_LEVEL_UPDATE,
-	VFE_CMD_ID_DEMUX_CHANNEL_GAIN_UPDATE,
-	VFE_CMD_ID_DEMOSAIC_BPC_UPDATE,
-	VFE_CMD_ID_DEMOSAIC_ABF_UPDATE,
-	VFE_CMD_ID_FOV_CROP_UPDATE,
-	VFE_CMD_ID_WHITE_BALANCE_UPDATE,
-	VFE_CMD_ID_COLOR_CORRECTION_UPDATE,
-	VFE_CMD_ID_LA_UPDATE,
-	VFE_CMD_ID_RGB_GAMMA_UPDATE,
-	VFE_CMD_ID_CHROMA_ENHAN_UPDATE,
-	VFE_CMD_ID_CHROMA_SUPPRESSION_UPDATE,
-	VFE_CMD_ID_MAIN_SCALER_UPDATE,
-	VFE_CMD_ID_SCALER2CbCr_UPDATE,
-	VFE_CMD_ID_SCALER2Y_UPDATE,
-	VFE_CMD_ID_ASF_UPDATE,
-	VFE_CMD_ID_FRAME_SKIP_UPDATE,
-	VFE_CMD_ID_CAMIF_FRAME_UPDATE,
-
-	/* stats update commands */
-	VFE_CMD_ID_STATS_AUTOFOCUS_UPDATE,
-	VFE_CMD_ID_STATS_WB_EXP_UPDATE,
-
-	/* control of start, stop, update, etc... */
-  VFE_CMD_ID_STOP,
-	VFE_CMD_ID_GET_HW_VERSION,
-
-	/* stats */
-	VFE_CMD_ID_STATS_SETTING,
-	VFE_CMD_ID_STATS_AUTOFOCUS_START,
-	VFE_CMD_ID_STATS_AUTOFOCUS_STOP,
-	VFE_CMD_ID_STATS_WB_EXP_START,
-	VFE_CMD_ID_STATS_WB_EXP_STOP,
-
-	VFE_CMD_ID_ASYNC_TIMER_SETTING,
-
-	/* max id  */
-	VFE_CMD_ID_MAX
-};
-
-struct vfe_cmd_hw_version {
-	uint32_t minorVersion;
-	uint32_t majorVersion;
-	uint32_t coreVersion;
-};
-
-enum VFE_CAMIF_SYNC_EDGE {
-	VFE_CAMIF_SYNC_EDGE_ActiveHigh,
-	VFE_CAMIF_SYNC_EDGE_ActiveLow
-};
-
-enum VFE_CAMIF_SYNC_MODE {
-	VFE_CAMIF_SYNC_MODE_APS,
-	VFE_CAMIF_SYNC_MODE_EFS,
-	VFE_CAMIF_SYNC_MODE_ELS,
-	VFE_CAMIF_SYNC_MODE_ILLEGAL
-};
-
-struct vfe_cmds_camif_efs {
-	uint8_t efsendofline;
-	uint8_t efsstartofline;
-	uint8_t efsendofframe;
-	uint8_t efsstartofframe;
-};
-
-struct vfe_cmds_camif_frame {
-	uint16_t pixelsPerLine;
-	uint16_t linesPerFrame;
-};
-
-struct vfe_cmds_camif_window {
-	uint16_t firstpixel;
-	uint16_t lastpixel;
-	uint16_t firstline;
-	uint16_t lastline;
-};
-
-enum CAMIF_SUBSAMPLE_FRAME_SKIP {
-	CAMIF_SUBSAMPLE_FRAME_SKIP_0,
-	CAMIF_SUBSAMPLE_FRAME_SKIP_AllFrames,
-	CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_2Frame,
-	CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_3Frame,
-	CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_4Frame,
-	CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_5Frame,
-	CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_6Frame,
-	CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_7Frame,
-	CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_8Frame,
-	CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_9Frame,
-	CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_10Frame,
-	CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_11Frame,
-	CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_12Frame,
-	CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_13Frame,
-	CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_14Frame,
-	CAMIF_SUBSAMPLE_FRAME_SKIP_ONE_OUT_OF_EVERY_15Frame
-};
-
-struct vfe_cmds_camif_subsample {
-	uint16_t pixelskipmask;
-	uint16_t lineskipmask;
-	enum CAMIF_SUBSAMPLE_FRAME_SKIP frameskip;
-	uint8_t frameskipmode;
-	uint8_t pixelskipwrap;
-};
-
-struct vfe_cmds_camif_epoch {
-	uint8_t  enable;
-	uint16_t lineindex;
-};
-
-struct vfe_cmds_camif_cfg {
-	enum VFE_CAMIF_SYNC_EDGE  vSyncEdge;
-	enum VFE_CAMIF_SYNC_EDGE  hSyncEdge;
-	enum VFE_CAMIF_SYNC_MODE  syncMode;
-	uint8_t vfeSubSampleEnable;
-	uint8_t busSubSampleEnable;
-	uint8_t irqSubSampleEnable;
-	uint8_t binningEnable;
-	uint8_t misrEnable;
-};
-
-struct vfe_cmd_camif_config {
-	struct vfe_cmds_camif_cfg camifConfig;
-	struct vfe_cmds_camif_efs EFS;
-	struct vfe_cmds_camif_frame     frame;
-	struct vfe_cmds_camif_window    window;
-	struct vfe_cmds_camif_subsample subsample;
-	struct vfe_cmds_camif_epoch     epoch1;
-	struct vfe_cmds_camif_epoch     epoch2;
-};
-
-enum VFE_AXI_OUTPUT_MODE {
-	VFE_AXI_OUTPUT_MODE_Output1,
-	VFE_AXI_OUTPUT_MODE_Output2,
-	VFE_AXI_OUTPUT_MODE_Output1AndOutput2,
-	VFE_AXI_OUTPUT_MODE_CAMIFToAXIViaOutput2,
-	VFE_AXI_OUTPUT_MODE_Output2AndCAMIFToAXIViaOutput1,
-	VFE_AXI_OUTPUT_MODE_Output1AndCAMIFToAXIViaOutput2,
-	VFE_AXI_LAST_OUTPUT_MODE_ENUM
-};
-
-enum VFE_RAW_WR_PATH_SEL {
-	VFE_RAW_OUTPUT_DISABLED,
-	VFE_RAW_OUTPUT_ENC_CBCR_PATH,
-	VFE_RAW_OUTPUT_VIEW_CBCR_PATH,
-	VFE_RAW_OUTPUT_PATH_INVALID
-};
-
-enum VFE_RAW_PIXEL_DATA_SIZE {
-	VFE_RAW_PIXEL_DATA_SIZE_8BIT,
-	VFE_RAW_PIXEL_DATA_SIZE_10BIT,
-	VFE_RAW_PIXEL_DATA_SIZE_12BIT,
-};
-
-#define VFE_AXI_OUTPUT_BURST_LENGTH     4
-#define VFE_MAX_NUM_FRAGMENTS_PER_FRAME 4
-#define VFE_MIN_NUM_FRAGMENTS_PER_FRAME 1
-#define VFE_AXI_OUTPUT_CFG_FRAME_COUNT  3
-
-struct vfe_cmds_axi_out_per_component {
-	uint16_t imageWidth;
-	uint16_t imageHeight;
-	uint16_t outRowCount;
-	uint16_t outRowIncrement;
-	uint32_t outFragments[VFE_AXI_OUTPUT_CFG_FRAME_COUNT]
-		[VFE_MAX_NUM_FRAGMENTS_PER_FRAME];
-};
-
-struct vfe_cmds_axi_per_output_path {
-	uint8_t fragmentCount;
-	struct vfe_cmds_axi_out_per_component outputY;
-	struct vfe_cmds_axi_out_per_component outputCbcr;
-};
-
-enum VFE_AXI_BURST_LENGTH {
-	VFE_AXI_BURST_LENGTH_IS_2  = 2,
-	VFE_AXI_BURST_LENGTH_IS_4  = 4,
-	VFE_AXI_BURST_LENGTH_IS_8  = 8,
-	VFE_AXI_BURST_LENGTH_IS_16 = 16
-};
-
-struct vfe_cmd_axi_output_config {
-	enum VFE_AXI_BURST_LENGTH burstLength;
-	enum VFE_AXI_OUTPUT_MODE outputMode;
-	enum VFE_RAW_PIXEL_DATA_SIZE outputDataSize;
-	struct vfe_cmds_axi_per_output_path output1;
-	struct vfe_cmds_axi_per_output_path output2;
-};
-
-struct vfe_cmd_fov_crop_config {
-	uint8_t enable;
-	uint16_t firstPixel;
-	uint16_t lastPixel;
-	uint16_t firstLine;
-	uint16_t lastLine;
-};
-
-struct vfe_cmds_main_scaler_stripe_init {
-	uint16_t MNCounterInit;
-	uint16_t phaseInit;
-};
-
-struct vfe_cmds_scaler_one_dimension {
-	uint8_t  enable;
-	uint16_t inputSize;
-	uint16_t outputSize;
-	uint32_t phaseMultiplicationFactor;
-	uint8_t  interpolationResolution;
-};
-
-struct vfe_cmd_main_scaler_config {
-	uint8_t enable;
-	struct vfe_cmds_scaler_one_dimension    hconfig;
-	struct vfe_cmds_scaler_one_dimension    vconfig;
-	struct vfe_cmds_main_scaler_stripe_init MNInitH;
-	struct vfe_cmds_main_scaler_stripe_init MNInitV;
-};
-
-struct vfe_cmd_scaler2_config {
-	uint8_t enable;
-	struct vfe_cmds_scaler_one_dimension hconfig;
-	struct vfe_cmds_scaler_one_dimension vconfig;
-};
-
-struct vfe_cmd_frame_skip_config {
-	uint8_t output1Period;
-	uint32_t output1Pattern;
-	uint8_t output2Period;
-	uint32_t output2Pattern;
-};
-
-struct vfe_cmd_frame_skip_update {
-	uint32_t output1Pattern;
-	uint32_t output2Pattern;
-};
-
-struct vfe_cmd_output_clamp_config {
-	uint8_t minCh0;
-	uint8_t minCh1;
-	uint8_t minCh2;
-	uint8_t maxCh0;
-	uint8_t maxCh1;
-	uint8_t maxCh2;
-};
-
-struct vfe_cmd_chroma_subsample_config {
-	uint8_t enable;
-	uint8_t cropEnable;
-	uint8_t vsubSampleEnable;
-	uint8_t hsubSampleEnable;
-	uint8_t vCosited;
-	uint8_t hCosited;
-	uint8_t vCositedPhase;
-	uint8_t hCositedPhase;
-	uint16_t cropWidthFirstPixel;
-	uint16_t cropWidthLastPixel;
-	uint16_t cropHeightFirstLine;
-	uint16_t cropHeightLastLine;
-};
-
-enum VFE_START_INPUT_SOURCE {
-	VFE_START_INPUT_SOURCE_CAMIF,
-	VFE_START_INPUT_SOURCE_TESTGEN,
-	VFE_START_INPUT_SOURCE_AXI,
-	VFE_START_INPUT_SOURCE_INVALID
-};
-
-enum VFE_START_OPERATION_MODE {
-	VFE_START_OPERATION_MODE_CONTINUOUS,
-	VFE_START_OPERATION_MODE_SNAPSHOT
-};
-
-enum VFE_START_PIXEL_PATTERN {
-	VFE_BAYER_RGRGRG,
-	VFE_BAYER_GRGRGR,
-	VFE_BAYER_BGBGBG,
-	VFE_BAYER_GBGBGB,
-	VFE_YUV_YCbYCr,
-	VFE_YUV_YCrYCb,
-	VFE_YUV_CbYCrY,
-	VFE_YUV_CrYCbY
-};
-
-enum VFE_BUS_RD_INPUT_PIXEL_PATTERN {
-	VFE_BAYER_RAW,
-	VFE_YUV_INTERLEAVED,
-	VFE_YUV_PSEUDO_PLANAR_Y,
-	VFE_YUV_PSEUDO_PLANAR_CBCR
-};
-
-enum VFE_YUV_INPUT_COSITING_MODE {
-	VFE_YUV_COSITED,
-	VFE_YUV_INTERPOLATED
-};
-
-struct vfe_cmd_start {
-	enum VFE_START_INPUT_SOURCE inputSource;
-	enum VFE_START_OPERATION_MODE operationMode;
-	uint8_t     snapshotCount;
-	enum VFE_START_PIXEL_PATTERN pixel;
-	enum VFE_YUV_INPUT_COSITING_MODE yuvInputCositingMode;
-};
-
-struct vfe_cmd_output_ack {
-	uint32_t ybufaddr[VFE_MAX_NUM_FRAGMENTS_PER_FRAME];
-	uint32_t chromabufaddr[VFE_MAX_NUM_FRAGMENTS_PER_FRAME];
-};
-
-#define VFE_STATS_BUFFER_COUNT 3
-
-struct vfe_cmd_stats_setting {
-	uint16_t frameHDimension;
-	uint16_t frameVDimension;
-	uint8_t  afBusPrioritySelection;
-	uint8_t  afBusPriority;
-	uint8_t  awbBusPrioritySelection;
-	uint8_t  awbBusPriority;
-	uint8_t  histBusPrioritySelection;
-	uint8_t  histBusPriority;
-	uint32_t afBuffer[VFE_STATS_BUFFER_COUNT];
-	uint32_t awbBuffer[VFE_STATS_BUFFER_COUNT];
-	uint32_t histBuffer[VFE_STATS_BUFFER_COUNT];
-};
-
-struct vfe_cmd_stats_af_start {
-	uint8_t  enable;
-	uint8_t  windowMode;
-	uint16_t windowHOffset;
-	uint16_t windowVOffset;
-	uint16_t windowWidth;
-	uint16_t windowHeight;
-	uint8_t  gridForMultiWindows[16];
-	uint8_t     metricSelection;
-	int16_t  metricMax;
-	int8_t   highPassCoef[7];
-	int8_t   bufferHeader;
-};
-
-struct vfe_cmd_stats_af_update {
-	uint8_t  windowMode;
-	uint16_t windowHOffset;
-	uint16_t windowVOffset;
-	uint16_t windowWidth;
-	uint16_t windowHeight;
-};
-
-struct vfe_cmd_stats_wb_exp_start {
-	uint8_t   enable;
-	uint8_t   wbExpRegions;
-	uint8_t   wbExpSubRegion;
-	uint8_t   awbYMin;
-	uint8_t   awbYMax;
-	int8_t    awbMCFG[4];
-	int16_t   awbCCFG[4];
-	int8_t    axwHeader;
-};
-
-struct vfe_cmd_stats_wb_exp_update {
-	uint8_t wbExpRegions;
-	uint8_t wbExpSubRegion;
-	int8_t  awbYMin;
-	int8_t  awbYMax;
-	int8_t  awbMCFG[4];
-	int16_t awbCCFG[4];
-};
-
-struct vfe_cmd_stats_af_ack {
-	uint32_t nextAFOutputBufferAddr;
-};
-
-struct vfe_cmd_stats_wb_exp_ack {
-	uint32_t  nextWbExpOutputBufferAddr;
-};
-
-struct vfe_cmd_black_level_config {
-	uint8_t  enable;
-	uint16_t evenEvenAdjustment;
-	uint16_t evenOddAdjustment;
-	uint16_t oddEvenAdjustment;
-	uint16_t oddOddAdjustment;
-};
-
-/* 13*1  */
-#define  VFE_ROLL_OFF_INIT_TABLE_SIZE  13
-/* 13*16 */
-#define  VFE_ROLL_OFF_DELTA_TABLE_SIZE 208
-
-struct vfe_cmd_roll_off_config {
-	uint8_t  enable;
-	uint16_t gridWidth;
-	uint16_t gridHeight;
-	uint16_t  yDelta;
-	uint8_t  gridXIndex;
-	uint8_t  gridYIndex;
-	uint16_t gridPixelXIndex;
-	uint16_t gridPixelYIndex;
-	uint16_t yDeltaAccum;
-	uint16_t initTableR[VFE_ROLL_OFF_INIT_TABLE_SIZE];
-	uint16_t initTableGr[VFE_ROLL_OFF_INIT_TABLE_SIZE];
-	uint16_t initTableB[VFE_ROLL_OFF_INIT_TABLE_SIZE];
-	uint16_t initTableGb[VFE_ROLL_OFF_INIT_TABLE_SIZE];
-	int16_t  deltaTableR[VFE_ROLL_OFF_DELTA_TABLE_SIZE];
-	int16_t  deltaTableGr[VFE_ROLL_OFF_DELTA_TABLE_SIZE];
-	int16_t  deltaTableB[VFE_ROLL_OFF_DELTA_TABLE_SIZE];
-	int16_t  deltaTableGb[VFE_ROLL_OFF_DELTA_TABLE_SIZE];
-};
-
-struct vfe_cmd_demux_channel_gain_config {
-	uint16_t ch0EvenGain;
-	uint16_t ch0OddGain;
-	uint16_t ch1Gain;
-	uint16_t ch2Gain;
-};
-
-struct vfe_cmds_demosaic_abf {
-	uint8_t   enable;
-	uint8_t   forceOn;
-	uint8_t   shift;
-	uint16_t  lpThreshold;
-	uint16_t  max;
-	uint16_t  min;
-	uint8_t   ratio;
-};
-
-struct vfe_cmds_demosaic_bpc {
-	uint8_t   enable;
-	uint16_t  fmaxThreshold;
-	uint16_t  fminThreshold;
-	uint16_t  redDiffThreshold;
-	uint16_t  blueDiffThreshold;
-	uint16_t  greenDiffThreshold;
-};
-
-struct vfe_cmd_demosaic_config {
-	uint8_t   enable;
-	uint8_t   slopeShift;
-	struct vfe_cmds_demosaic_abf abfConfig;
-	struct vfe_cmds_demosaic_bpc bpcConfig;
-};
-
-struct vfe_cmd_demosaic_bpc_update {
-	struct vfe_cmds_demosaic_bpc bpcUpdate;
-};
-
-struct vfe_cmd_demosaic_abf_update {
-	struct vfe_cmds_demosaic_abf abfUpdate;
-};
-
-struct vfe_cmd_white_balance_config {
-	uint8_t  enable;
-	uint16_t ch2Gain;
-	uint16_t ch1Gain;
-	uint16_t ch0Gain;
-};
-
-enum VFE_COLOR_CORRECTION_COEF_QFACTOR {
-	COEF_IS_Q7_SIGNED,
-	COEF_IS_Q8_SIGNED,
-	COEF_IS_Q9_SIGNED,
-	COEF_IS_Q10_SIGNED
-};
-
-struct vfe_cmd_color_correction_config {
-	uint8_t     enable;
-	enum VFE_COLOR_CORRECTION_COEF_QFACTOR coefQFactor;
-	int16_t  C0;
-	int16_t  C1;
-	int16_t  C2;
-	int16_t  C3;
-	int16_t  C4;
-	int16_t  C5;
-	int16_t  C6;
-	int16_t  C7;
-	int16_t  C8;
-	int16_t  K0;
-	int16_t  K1;
-	int16_t  K2;
-};
-
-#define VFE_LA_TABLE_LENGTH 256
-struct vfe_cmd_la_config {
-	uint8_t enable;
-	int16_t table[VFE_LA_TABLE_LENGTH];
-};
-
-#define VFE_GAMMA_TABLE_LENGTH 256
-enum VFE_RGB_GAMMA_TABLE_SELECT {
-	RGB_GAMMA_CH0_SELECTED,
-	RGB_GAMMA_CH1_SELECTED,
-	RGB_GAMMA_CH2_SELECTED,
-	RGB_GAMMA_CH0_CH1_SELECTED,
-	RGB_GAMMA_CH0_CH2_SELECTED,
-	RGB_GAMMA_CH1_CH2_SELECTED,
-	RGB_GAMMA_CH0_CH1_CH2_SELECTED
-};
-
-struct vfe_cmd_rgb_gamma_config {
-	uint8_t enable;
-	enum VFE_RGB_GAMMA_TABLE_SELECT channelSelect;
-	int16_t table[VFE_GAMMA_TABLE_LENGTH];
-};
-
-struct vfe_cmd_chroma_enhan_config {
-	uint8_t  enable;
-	int16_t am;
-	int16_t ap;
-	int16_t bm;
-	int16_t bp;
-	int16_t cm;
-	int16_t cp;
-	int16_t dm;
-	int16_t dp;
-	int16_t kcr;
-	int16_t kcb;
-	int16_t RGBtoYConversionV0;
-	int16_t RGBtoYConversionV1;
-	int16_t RGBtoYConversionV2;
-	uint8_t RGBtoYConversionOffset;
-};
-
-struct vfe_cmd_chroma_suppression_config {
-	uint8_t enable;
-	uint8_t m1;
-	uint8_t m3;
-	uint8_t n1;
-	uint8_t n3;
-	uint8_t nn1;
-	uint8_t mm1;
-};
-
-struct vfe_cmd_asf_config {
-	uint8_t enable;
-	uint8_t smoothFilterEnabled;
-	uint8_t sharpMode;
-	uint8_t smoothCoefCenter;
-	uint8_t smoothCoefSurr;
-	uint8_t normalizeFactor;
-	uint8_t sharpK1;
-	uint8_t sharpK2;
-	uint8_t sharpThreshE1;
-	int8_t sharpThreshE2;
-	int8_t sharpThreshE3;
-	int8_t sharpThreshE4;
-	int8_t sharpThreshE5;
-	int8_t filter1Coefficients[9];
-	int8_t filter2Coefficients[9];
-	uint8_t  cropEnable;
-	uint16_t cropFirstPixel;
-	uint16_t cropLastPixel;
-	uint16_t cropFirstLine;
-	uint16_t cropLastLine;
-};
-
-struct vfe_cmd_asf_update {
-	uint8_t enable;
-	uint8_t smoothFilterEnabled;
-	uint8_t sharpMode;
-	uint8_t smoothCoefCenter;
-	uint8_t smoothCoefSurr;
-	uint8_t normalizeFactor;
-	uint8_t sharpK1;
-	uint8_t sharpK2;
-	uint8_t sharpThreshE1;
-	int8_t  sharpThreshE2;
-	int8_t  sharpThreshE3;
-	int8_t  sharpThreshE4;
-	int8_t  sharpThreshE5;
-	int8_t  filter1Coefficients[9];
-	int8_t  filter2Coefficients[9];
-	uint8_t cropEnable;
-};
-
-enum VFE_TEST_GEN_SYNC_EDGE {
-	VFE_TEST_GEN_SYNC_EDGE_ActiveHigh,
-	VFE_TEST_GEN_SYNC_EDGE_ActiveLow
-};
-
-struct vfe_cmd_test_gen_start {
-	uint8_t pixelDataSelect;
-	uint8_t systematicDataSelect;
-	enum VFE_TEST_GEN_SYNC_EDGE  hsyncEdge;
-	enum VFE_TEST_GEN_SYNC_EDGE  vsyncEdge;
-	uint16_t numFrame;
-	enum VFE_RAW_PIXEL_DATA_SIZE pixelDataSize;
-	uint16_t imageWidth;
-	uint16_t imageHeight;
-	uint32_t startOfFrameOffset;
-	uint32_t endOfFrameNOffset;
-	uint16_t startOfLineOffset;
-	uint16_t endOfLineNOffset;
-	uint16_t hbi;
-	uint8_t  vblEnable;
-	uint16_t vbl;
-	uint8_t  startOfFrameDummyLine;
-	uint8_t  endOfFrameDummyLine;
-	uint8_t  unicolorBarEnable;
-	uint8_t  colorBarsSplitEnable;
-	uint8_t  unicolorBarSelect;
-	enum VFE_START_PIXEL_PATTERN  colorBarsPixelPattern;
-	uint8_t  colorBarsRotatePeriod;
-	uint16_t testGenRandomSeed;
-};
-
-struct vfe_cmd_bus_pm_start {
-	uint8_t output2YWrPmEnable;
-	uint8_t output2CbcrWrPmEnable;
-	uint8_t output1YWrPmEnable;
-	uint8_t output1CbcrWrPmEnable;
-};
-
-struct vfe_cmd_camif_frame_update {
-	struct vfe_cmds_camif_frame camifFrame;
-};
-
-struct vfe_cmd_sync_timer_setting {
-	uint8_t  whichSyncTimer;
-	uint8_t  operation;
-	uint8_t  polarity;
-	uint16_t repeatCount;
-	uint16_t hsyncCount;
-	uint32_t pclkCount;
-	uint32_t outputDuration;
-};
-
-struct vfe_cmd_async_timer_setting {
-	uint8_t  whichAsyncTimer;
-	uint8_t  operation;
-	uint8_t  polarity;
-	uint16_t repeatCount;
-	uint16_t inactiveCount;
-	uint32_t activeCount;
-};
-
-struct  vfe_frame_skip_counts {
-	uint32_t  totalFrameCount;
-	uint32_t  output1Count;
-	uint32_t  output2Count;
-};
-
-enum VFE_AXI_RD_UNPACK_HBI_SEL {
-	VFE_AXI_RD_HBI_32_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_64_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_128_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_256_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_512_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_1024_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_2048_CLOCK_CYCLES,
-	VFE_AXI_RD_HBI_4096_CLOCK_CYCLES
-};
-
-struct vfe_cmd_axi_input_config {
-	uint32_t  fragAddr[4];
-	uint8_t   totalFragmentCount;
-	uint16_t  ySize;
-	uint16_t  xOffset;
-	uint16_t  xSize;
-	uint16_t  rowIncrement;
-	uint16_t  numOfRows;
-	enum VFE_AXI_BURST_LENGTH burstLength;
-	uint8_t   unpackPhase;
-	enum VFE_AXI_RD_UNPACK_HBI_SEL unpackHbi;
-	enum VFE_RAW_PIXEL_DATA_SIZE   pixelSize;
-	uint8_t   padRepeatCountLeft;
-	uint8_t   padRepeatCountRight;
-	uint8_t   padRepeatCountTop;
-	uint8_t   padRepeatCountBottom;
-	uint8_t   padLeftComponentSelectCycle0;
-	uint8_t   padLeftComponentSelectCycle1;
-	uint8_t   padLeftComponentSelectCycle2;
-	uint8_t   padLeftComponentSelectCycle3;
-	uint8_t   padLeftStopCycle0;
-	uint8_t   padLeftStopCycle1;
-	uint8_t   padLeftStopCycle2;
-	uint8_t   padLeftStopCycle3;
-	uint8_t   padRightComponentSelectCycle0;
-	uint8_t   padRightComponentSelectCycle1;
-	uint8_t   padRightComponentSelectCycle2;
-	uint8_t   padRightComponentSelectCycle3;
-	uint8_t   padRightStopCycle0;
-	uint8_t   padRightStopCycle1;
-	uint8_t   padRightStopCycle2;
-	uint8_t   padRightStopCycle3;
-	uint8_t   padTopLineCount;
-	uint8_t   padBottomLineCount;
-};
-
-struct vfe_interrupt_status {
-	uint8_t camifErrorIrq;
-	uint8_t camifSofIrq;
-	uint8_t camifEolIrq;
-	uint8_t camifEofIrq;
-	uint8_t camifEpoch1Irq;
-	uint8_t camifEpoch2Irq;
-	uint8_t camifOverflowIrq;
-	uint8_t ceIrq;
-	uint8_t regUpdateIrq;
-	uint8_t resetAckIrq;
-	uint8_t encYPingpongIrq;
-	uint8_t encCbcrPingpongIrq;
-	uint8_t viewYPingpongIrq;
-	uint8_t viewCbcrPingpongIrq;
-	uint8_t rdPingpongIrq;
-	uint8_t afPingpongIrq;
-	uint8_t awbPingpongIrq;
-	uint8_t histPingpongIrq;
-	uint8_t encIrq;
-	uint8_t viewIrq;
-	uint8_t busOverflowIrq;
-	uint8_t afOverflowIrq;
-	uint8_t awbOverflowIrq;
-	uint8_t syncTimer0Irq;
-	uint8_t syncTimer1Irq;
-	uint8_t syncTimer2Irq;
-	uint8_t asyncTimer0Irq;
-	uint8_t asyncTimer1Irq;
-	uint8_t asyncTimer2Irq;
-	uint8_t asyncTimer3Irq;
-	uint8_t axiErrorIrq;
-	uint8_t violationIrq;
-	uint8_t anyErrorIrqs;
-	uint8_t anyOutput1PathIrqs;
-	uint8_t anyOutput2PathIrqs;
-	uint8_t anyOutputPathIrqs;
-	uint8_t anyAsyncTimerIrqs;
-	uint8_t anySyncTimerIrqs;
-	uint8_t anyIrqForActiveStatesOnly;
-};
-
-enum VFE_MESSAGE_ID {
-	VFE_MSG_ID_RESET_ACK,
-	VFE_MSG_ID_START_ACK,
-	VFE_MSG_ID_STOP_ACK,
-	VFE_MSG_ID_UPDATE_ACK,
-	VFE_MSG_ID_OUTPUT_P,
-	VFE_MSG_ID_OUTPUT_V,
-	VFE_MSG_ID_OUTPUT_S,
-	VFE_MSG_ID_OUTPUT_T,
-	VFE_MSG_ID_SNAPSHOT_DONE,
-	VFE_MSG_ID_STATS_AUTOFOCUS,
-	VFE_MSG_ID_STATS_WB_EXP,
-	VFE_MSG_ID_EPOCH1,
-	VFE_MSG_ID_EPOCH2,
-	VFE_MSG_ID_SYNC_TIMER0_DONE,
-	VFE_MSG_ID_SYNC_TIMER1_DONE,
-	VFE_MSG_ID_SYNC_TIMER2_DONE,
-	VFE_MSG_ID_ASYNC_TIMER0_DONE,
-	VFE_MSG_ID_ASYNC_TIMER1_DONE,
-	VFE_MSG_ID_ASYNC_TIMER2_DONE,
-	VFE_MSG_ID_ASYNC_TIMER3_DONE,
-	VFE_MSG_ID_AF_OVERFLOW,
-	VFE_MSG_ID_AWB_OVERFLOW,
-	VFE_MSG_ID_AXI_ERROR,
-	VFE_MSG_ID_CAMIF_OVERFLOW,
-	VFE_MSG_ID_VIOLATION,
-	VFE_MSG_ID_CAMIF_ERROR,
-	VFE_MSG_ID_BUS_OVERFLOW,
-	VFE_MSG_ID_SOF_ACK,
-};
-
-struct vfe_msg_stats_autofocus {
-	uint32_t    afBuffer;
-	uint32_t    frameCounter;
-};
-
-struct vfe_msg_stats_wb_exp {
-	uint32_t awbBuffer;
-	uint32_t frameCounter;
-};
-
-struct vfe_frame_bpc_info {
-	uint32_t greenDefectPixelCount;
-	uint32_t redBlueDefectPixelCount;
-};
-
-struct vfe_frame_asf_info {
-	uint32_t  asfMaxEdge;
-	uint32_t  asfHbiCount;
-};
-
-struct vfe_msg_camif_status {
-	uint8_t  camifState;
-	uint32_t pixelCount;
-	uint32_t lineCount;
-};
-
-struct vfe_bus_pm_per_path {
-	uint32_t yWrPmStats0;
-	uint32_t yWrPmStats1;
-	uint32_t cbcrWrPmStats0;
-	uint32_t cbcrWrPmStats1;
-};
-
-struct vfe_bus_performance_monitor {
-	struct vfe_bus_pm_per_path encPathPmInfo;
-	struct vfe_bus_pm_per_path viewPathPmInfo;
-};
-
-struct vfe_irq_thread_msg {
-	uint32_t  vfeIrqStatus;
-	uint32_t  camifStatus;
-	uint32_t  demosaicStatus;
-	uint32_t  asfMaxEdge;
-	struct vfe_bus_performance_monitor pmInfo;
-};
-
-struct vfe_msg_output {
-	uint32_t  yBuffer;
-	uint32_t  cbcrBuffer;
-	struct vfe_frame_bpc_info bpcInfo;
-	struct vfe_frame_asf_info asfInfo;
-	uint32_t  frameCounter;
-	struct vfe_bus_pm_per_path pmData;
-};
-
-struct vfe_message {
-	enum VFE_MESSAGE_ID _d;
-	union {
-		struct vfe_msg_output              msgOutput1;
-		struct vfe_msg_output              msgOutput2;
-		struct vfe_msg_stats_autofocus     msgStatsAf;
-		struct vfe_msg_stats_wb_exp        msgStatsWbExp;
-		struct vfe_msg_camif_status        msgCamifError;
-		struct vfe_bus_performance_monitor msgBusOverflow;
-   } _u;
-};
-
-/* New one for 8k */
-struct msm_vfe_command_8k {
-	int id;
-	uint16_t length;
-	void     *value;
-};
-
-struct vfe_frame_extra {
-	struct vfe_frame_bpc_info bpcInfo;
-	struct vfe_frame_asf_info asfInfo;
-	uint32_t  frameCounter;
-	struct vfe_bus_pm_per_path pmData;
-};
-#endif /* __MSM_VFE8X_H__ */
diff --git a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe8x_proc.c b/drivers/media/platform/msm/camera_v1/vfe/msm_vfe8x_proc.c
deleted file mode 100644
index 4ebb30d..0000000
--- a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe8x_proc.c
+++ /dev/null
@@ -1,3889 +0,0 @@
-/* Copyright (c) 2009-2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/slab.h>
-#include <linux/interrupt.h>
-#include <linux/spinlock.h>
-#include <linux/io.h>
-#include <linux/list.h>
-#include <linux/delay.h>
-#include <linux/platform_device.h>
-#include "msm_vfe8x_proc.h"
-#include <media/msm_camera.h>
-#include <mach/board.h>
-
-struct isr_queue_cmd {
-	struct list_head list;
-	struct vfe_interrupt_status vfeInterruptStatus;
-	struct vfe_frame_asf_info vfeAsfFrameInfo;
-	struct vfe_frame_bpc_info vfeBpcFrameInfo;
-	struct vfe_msg_camif_status vfeCamifStatusLocal;
-	struct vfe_bus_performance_monitor vfePmData;
-};
-
-struct msm_vfe8x_ctrl {
-	/* bit 1:0 ENC_IRQ_MASK = 0x11:
-	 * generate IRQ when both y and cbcr frame is ready. */
-
-	/* bit 1:0 VIEW_IRQ_MASK= 0x11:
-	 * generate IRQ when both y and cbcr frame is ready. */
-	struct vfe_irq_composite_mask_config vfeIrqCompositeMaskLocal;
-	struct vfe_module_enable vfeModuleEnableLocal;
-	struct vfe_camif_cfg_data   vfeCamifConfigLocal;
-	struct vfe_interrupt_mask   vfeImaskLocal;
-	struct vfe_stats_cmd_data   vfeStatsCmdLocal;
-	struct vfe_bus_cfg_data     vfeBusConfigLocal;
-	struct vfe_cmd_bus_pm_start vfeBusPmConfigLocal;
-	struct vfe_bus_cmd_data     vfeBusCmdLocal;
-	enum vfe_interrupt_name     vfeInterruptNameLocal;
-	uint32_t vfeLaBankSel;
-	struct vfe_gamma_lut_sel  vfeGammaLutSel;
-
-	boolean vfeStartAckPendingFlag;
-	boolean vfeStopAckPending;
-	boolean vfeResetAckPending;
-	boolean vfeUpdateAckPending;
-
-	enum VFE_AXI_OUTPUT_MODE        axiOutputMode;
-	enum VFE_START_OPERATION_MODE   vfeOperationMode;
-
-	atomic_t vfe_serv_interrupt;
-
-	uint32_t            vfeSnapShotCount;
-	uint32_t            vfeRequestedSnapShotCount;
-	boolean             vfeStatsPingPongReloadFlag;
-	uint32_t            vfeFrameId;
-
-	struct vfe_cmd_frame_skip_config vfeFrameSkip;
-	uint32_t vfeFrameSkipPattern;
-	uint8_t  vfeFrameSkipCount;
-	uint8_t  vfeFrameSkipPeriod;
-
-	boolean  vfeTestGenStartFlag;
-	uint32_t vfeImaskPacked;
-	uint32_t vfeImaskCompositePacked;
-	enum VFE_RAW_PIXEL_DATA_SIZE       axiInputDataSize;
-	struct vfe_irq_thread_msg          vfeIrqThreadMsgLocal;
-
-	struct vfe_output_path_combo  viewPath;
-	struct vfe_output_path_combo  encPath;
-	struct vfe_frame_skip_counts vfeDroppedFrameCounts;
-	struct vfe_stats_control afStatsControl;
-	struct vfe_stats_control awbStatsControl;
-
-	enum VFE_STATE  vstate;
-
-	struct msm_vfe_callback *resp;
-	struct vfe_frame_extra extdata;
-
-	struct isr_queue_cmd irqs[10];
-	spinlock_t irqs_lock;
-	int irq_get;
-	int irq_put;
-
-	int vfeirq;
-	void __iomem *vfebase;
-
-	void *syncdata;
-};
-
-static struct msm_vfe8x_ctrl *ctrl;
-static spinlock_t msm_vfe_ctrl_lock;
-
-static void vfe_prog_hw(uint8_t *hwreg, uint32_t *inptr, uint32_t regcnt)
-{
-	/* unsigned long flags; */
-	uint32_t i;
-	uint32_t *p;
-
-	/* @todo This is causing issues, need further investigate */
-	/* spin_lock_irqsave(&ctrl->io_lock, flags); */
-
-	p = (uint32_t *)(hwreg);
-	for (i = 0; i < (regcnt >> 2); i++)
-		writel(*inptr++, p++);
-		/* *p++ = *inptr++; */
-
-	/* spin_unlock_irqrestore(&ctrl->io_lock, flags); */
-}
-
-static void
-vfe_set_bus_pipo_addr(struct vfe_output_path_combo *vpath,
-	struct vfe_output_path_combo *epath)
-{
-	vpath->yPath.hwRegPingAddress = (uint8_t *)
-		(ctrl->vfebase + VFE_BUS_VIEW_Y_WR_PING_ADDR);
-	vpath->yPath.hwRegPongAddress = (uint8_t *)
-		(ctrl->vfebase + VFE_BUS_VIEW_Y_WR_PONG_ADDR);
-	vpath->cbcrPath.hwRegPingAddress = (uint8_t *)
-		(ctrl->vfebase + VFE_BUS_VIEW_CBCR_WR_PING_ADDR);
-	vpath->cbcrPath.hwRegPongAddress = (uint8_t *)
-		(ctrl->vfebase + VFE_BUS_VIEW_CBCR_WR_PONG_ADDR);
-
-	epath->yPath.hwRegPingAddress = (uint8_t *)
-		(ctrl->vfebase + VFE_BUS_ENC_Y_WR_PING_ADDR);
-	epath->yPath.hwRegPongAddress = (uint8_t *)
-		(ctrl->vfebase + VFE_BUS_ENC_Y_WR_PONG_ADDR);
-	epath->cbcrPath.hwRegPingAddress = (uint8_t *)
-		(ctrl->vfebase + VFE_BUS_ENC_CBCR_WR_PING_ADDR);
-	epath->cbcrPath.hwRegPongAddress = (uint8_t *)
-		(ctrl->vfebase + VFE_BUS_ENC_CBCR_WR_PONG_ADDR);
-}
-
-static void vfe_axi_output(struct vfe_cmd_axi_output_config *in,
-	struct vfe_output_path_combo *out1,
-	struct vfe_output_path_combo *out2, uint16_t out)
-{
-	struct vfe_axi_out_cfg cmd;
-
-	uint16_t temp;
-	uint32_t burstLength;
-
-	memset(&cmd, 0, sizeof(cmd));
-	/* force it to burst length 4, hardware does not support it. */
-	burstLength = 1;
-
-	/* AXI Output 2 Y Configuration*/
-	/* VFE_BUS_ENC_Y_WR_PING_ADDR  */
-	cmd.out2YPingAddr = out2->yPath.addressBuffer[0];
-
-	/* VFE_BUS_ENC_Y_WR_PONG_ADDR  */
-	cmd.out2YPongAddr = out2->yPath.addressBuffer[1];
-
-	/* VFE_BUS_ENC_Y_WR_IMAGE_SIZE */
-	cmd.out2YImageHeight = in->output2.outputY.imageHeight;
-	/* convert the image width and row increment to be in
-	 * unit of 64bit (8 bytes) */
-	temp = (in->output2.outputY.imageWidth + (out - 1)) / out;
-	cmd.out2YImageWidthin64bit = temp;
-
-	/* VFE_BUS_ENC_Y_WR_BUFFER_CFG */
-	cmd.out2YBurstLength = burstLength;
-	cmd.out2YNumRows = in->output2.outputY.outRowCount;
-	temp = (in->output2.outputY.outRowIncrement + (out - 1)) / out;
-	cmd.out2YRowIncrementIn64bit = temp;
-
-	/* AXI Output 2 Cbcr Configuration*/
-	/* VFE_BUS_ENC_Cbcr_WR_PING_ADDR  */
-	cmd.out2CbcrPingAddr = out2->cbcrPath.addressBuffer[0];
-
-	/* VFE_BUS_ENC_Cbcr_WR_PONG_ADDR  */
-	cmd.out2CbcrPongAddr = out2->cbcrPath.addressBuffer[1];
-
-	/* VFE_BUS_ENC_Cbcr_WR_IMAGE_SIZE */
-	cmd.out2CbcrImageHeight = in->output2.outputCbcr.imageHeight;
-	temp = (in->output2.outputCbcr.imageWidth + (out - 1)) / out;
-	cmd.out2CbcrImageWidthIn64bit = temp;
-
-	/* VFE_BUS_ENC_Cbcr_WR_BUFFER_CFG */
-	cmd.out2CbcrBurstLength = burstLength;
-	cmd.out2CbcrNumRows = in->output2.outputCbcr.outRowCount;
-	temp = (in->output2.outputCbcr.outRowIncrement + (out - 1)) / out;
-	cmd.out2CbcrRowIncrementIn64bit = temp;
-
-	/* AXI Output 1 Y Configuration */
-	/* VFE_BUS_VIEW_Y_WR_PING_ADDR  */
-	cmd.out1YPingAddr = out1->yPath.addressBuffer[0];
-
-	/* VFE_BUS_VIEW_Y_WR_PONG_ADDR */
-	cmd.out1YPongAddr = out1->yPath.addressBuffer[1];
-
-	/* VFE_BUS_VIEW_Y_WR_IMAGE_SIZE */
-	cmd.out1YImageHeight = in->output1.outputY.imageHeight;
-	temp = (in->output1.outputY.imageWidth + (out - 1)) / out;
-	cmd.out1YImageWidthin64bit = temp;
-
-	/* VFE_BUS_VIEW_Y_WR_BUFFER_CFG     */
-	cmd.out1YBurstLength = burstLength;
-	cmd.out1YNumRows = in->output1.outputY.outRowCount;
-
-	temp = (in->output1.outputY.outRowIncrement + (out - 1)) / out;
-	cmd.out1YRowIncrementIn64bit = temp;
-
-	/* AXI Output 1 Cbcr Configuration*/
-	cmd.out1CbcrPingAddr = out1->cbcrPath.addressBuffer[0];
-
-	/* VFE_BUS_VIEW_Cbcr_WR_PONG_ADDR  */
-	cmd.out1CbcrPongAddr = out1->cbcrPath.addressBuffer[1];
-
-	/* VFE_BUS_VIEW_Cbcr_WR_IMAGE_SIZE */
-	cmd.out1CbcrImageHeight = in->output1.outputCbcr.imageHeight;
-	temp = (in->output1.outputCbcr.imageWidth + (out - 1)) / out;
-	cmd.out1CbcrImageWidthIn64bit = temp;
-
-	cmd.out1CbcrBurstLength = burstLength;
-	cmd.out1CbcrNumRows = in->output1.outputCbcr.outRowCount;
-	temp = (in->output1.outputCbcr.outRowIncrement + (out - 1)) / out;
-
-	cmd.out1CbcrRowIncrementIn64bit = temp;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_BUS_ENC_Y_WR_PING_ADDR,
-		(uint32_t *)&cmd, sizeof(cmd));
-}
-
-static void vfe_reg_bus_cfg(struct vfe_bus_cfg_data *in)
-{
-	struct vfe_axi_bus_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	cmd.stripeRdPathEn      = in->stripeRdPathEn;
-	cmd.encYWrPathEn        = in->encYWrPathEn;
-	cmd.encCbcrWrPathEn     = in->encCbcrWrPathEn;
-	cmd.viewYWrPathEn       = in->viewYWrPathEn;
-	cmd.viewCbcrWrPathEn    = in->viewCbcrWrPathEn;
-	cmd.rawPixelDataSize    = (uint32_t)in->rawPixelDataSize;
-	cmd.rawWritePathSelect  = (uint32_t)in->rawWritePathSelect;
-
-	/*  program vfe_bus_cfg */
-	writel(*((uint32_t *)&cmd), ctrl->vfebase + VFE_BUS_CFG);
-}
-
-static void vfe_reg_camif_config(struct vfe_camif_cfg_data *in)
-{
-	struct VFE_CAMIFConfigType cfg;
-
-	memset(&cfg, 0, sizeof(cfg));
-
-	cfg.VSyncEdge = in->camifCfgFromCmd.vSyncEdge;
-
-	cfg.HSyncEdge = in->camifCfgFromCmd.hSyncEdge;
-
-	cfg.syncMode = in->camifCfgFromCmd.syncMode;
-
-	cfg.vfeSubsampleEnable = in->camifCfgFromCmd.vfeSubSampleEnable;
-
-	cfg.busSubsampleEnable = in->camifCfgFromCmd.busSubSampleEnable;
-
-	cfg.camif2vfeEnable = in->camif2OutputEnable;
-
-	cfg.camif2busEnable = in->camif2BusEnable;
-
-	cfg.irqSubsampleEnable = in->camifCfgFromCmd.irqSubSampleEnable;
-
-	cfg.binningEnable = in->camifCfgFromCmd.binningEnable;
-
-	cfg.misrEnable = in->camifCfgFromCmd.misrEnable;
-
-	/*  program camif_config */
-	writel(*((uint32_t *)&cfg), ctrl->vfebase + CAMIF_CONFIG);
-}
-
-static void vfe_reg_bus_cmd(struct vfe_bus_cmd_data *in)
-{
-	struct vfe_buscmd cmd;
-	memset(&cmd, 0, sizeof(cmd));
-
-	cmd.stripeReload        = in->stripeReload;
-	cmd.busPingpongReload   = in->busPingpongReload;
-	cmd.statsPingpongReload = in->statsPingpongReload;
-
-	writel(*((uint32_t *)&cmd), ctrl->vfebase + VFE_BUS_CMD);
-
-	CDBG("bus command = 0x%x\n", (*((uint32_t *)&cmd)));
-
-	/* this is needed, as the control bits are pulse based.
-	 * Don't want to reload bus pingpong again. */
-	in->busPingpongReload = 0;
-	in->statsPingpongReload = 0;
-	in->stripeReload = 0;
-}
-
-static void vfe_reg_module_cfg(struct vfe_module_enable *in)
-{
-	struct vfe_mod_enable ena;
-
-	memset(&ena, 0, sizeof(ena));
-
-	ena.blackLevelCorrectionEnable = in->blackLevelCorrectionEnable;
-	ena.lensRollOffEnable          = in->lensRollOffEnable;
-	ena.demuxEnable                = in->demuxEnable;
-	ena.chromaUpsampleEnable       = in->chromaUpsampleEnable;
-	ena.demosaicEnable             = in->demosaicEnable;
-	ena.statsEnable                = in->statsEnable;
-	ena.cropEnable                 = in->cropEnable;
-	ena.mainScalerEnable           = in->mainScalerEnable;
-	ena.whiteBalanceEnable         = in->whiteBalanceEnable;
-	ena.colorCorrectionEnable      = in->colorCorrectionEnable;
-	ena.yHistEnable                = in->yHistEnable;
-	ena.skinToneEnable             = in->skinToneEnable;
-	ena.lumaAdaptationEnable       = in->lumaAdaptationEnable;
-	ena.rgbLUTEnable               = in->rgbLUTEnable;
-	ena.chromaEnhanEnable          = in->chromaEnhanEnable;
-	ena.asfEnable                  = in->asfEnable;
-	ena.chromaSuppressionEnable    = in->chromaSuppressionEnable;
-	ena.chromaSubsampleEnable      = in->chromaSubsampleEnable;
-	ena.scaler2YEnable             = in->scaler2YEnable;
-	ena.scaler2CbcrEnable          = in->scaler2CbcrEnable;
-
-	writel(*((uint32_t *)&ena), ctrl->vfebase + VFE_MODULE_CFG);
-}
-
-static void vfe_program_dmi_cfg(enum VFE_DMI_RAM_SEL bankSel)
-{
-	/* set bit 8 for auto increment. */
-	uint32_t value = (uint32_t) ctrl->vfebase + VFE_DMI_CFG_DEFAULT;
-
-	value += (uint32_t)bankSel;
-	/* CDBG("dmi cfg input bank is  0x%x\n", bankSel); */
-
-	writel(value, ctrl->vfebase + VFE_DMI_CFG);
-	writel(0, ctrl->vfebase + VFE_DMI_ADDR);
-}
-
-static void vfe_write_lens_roll_off_table(struct vfe_cmd_roll_off_config *in)
-{
-	uint16_t i;
-	uint32_t data;
-
-	uint16_t *initGr = in->initTableGr;
-	uint16_t *initGb = in->initTableGb;
-	uint16_t *initB =  in->initTableB;
-	uint16_t *initR =  in->initTableR;
-
-	int16_t *pDeltaGr = in->deltaTableGr;
-	int16_t *pDeltaGb = in->deltaTableGb;
-	int16_t *pDeltaB =  in->deltaTableB;
-	int16_t *pDeltaR =  in->deltaTableR;
-
-	vfe_program_dmi_cfg(ROLLOFF_RAM);
-
-	/* first pack and write init table */
-	for (i = 0; i < VFE_ROLL_OFF_INIT_TABLE_SIZE; i++) {
-		data = (((uint32_t)(*initR)) & 0x0000FFFF) |
-			(((uint32_t)(*initGr)) << 16);
-		initR++;
-		initGr++;
-
-		writel(data, ctrl->vfebase + VFE_DMI_DATA_LO);
-
-		data = (((uint32_t)(*initB)) & 0x0000FFFF) |
-			(((uint32_t)(*initGb))<<16);
-		initB++;
-		initGb++;
-
-		writel(data, ctrl->vfebase + VFE_DMI_DATA_LO);
-	}
-
-	/* there are gaps between the init table and delta table,
-	 * set the offset for delta table. */
-	writel(LENS_ROLL_OFF_DELTA_TABLE_OFFSET, ctrl->vfebase + VFE_DMI_ADDR);
-
-	/* pack and write delta table */
-	for (i = 0; i < VFE_ROLL_OFF_DELTA_TABLE_SIZE; i++) {
-		data = (((int)(*pDeltaR)) & 0x0000FFFF) |
-			(((int)(*pDeltaGr))<<16);
-		pDeltaR++;
-		pDeltaGr++;
-
-		writel(data, ctrl->vfebase + VFE_DMI_DATA_LO);
-
-		data = (((int)(*pDeltaB)) & 0x0000FFFF) |
-			(((int)(*pDeltaGb))<<16);
-		pDeltaB++;
-		pDeltaGb++;
-
-		writel(data, ctrl->vfebase + VFE_DMI_DATA_LO);
-	}
-
-	/* After DMI transfer, to make it safe, need to set the
-	 * DMI_CFG to unselect any SRAM
-	 */
-	/* unselect the SRAM Bank. */
-	writel(VFE_DMI_CFG_DEFAULT, ctrl->vfebase + VFE_DMI_CFG);
-}
-
-static void vfe_set_default_reg_values(void)
-{
-	writel(0x800080, ctrl->vfebase + VFE_DEMUX_GAIN_0);
-	writel(0x800080, ctrl->vfebase + VFE_DEMUX_GAIN_1);
-	writel(0xFFFFF, ctrl->vfebase + VFE_CGC_OVERRIDE);
-
-	/* default frame drop period and pattern */
-	writel(0x1f, ctrl->vfebase + VFE_FRAMEDROP_ENC_Y_CFG);
-	writel(0x1f, ctrl->vfebase + VFE_FRAMEDROP_ENC_CBCR_CFG);
-	writel(0xFFFFFFFF, ctrl->vfebase + VFE_FRAMEDROP_ENC_Y_PATTERN);
-	writel(0xFFFFFFFF, ctrl->vfebase + VFE_FRAMEDROP_ENC_CBCR_PATTERN);
-	writel(0x1f, ctrl->vfebase + VFE_FRAMEDROP_VIEW_Y_CFG);
-	writel(0x1f, ctrl->vfebase + VFE_FRAMEDROP_VIEW_CBCR_CFG);
-	writel(0xFFFFFFFF, ctrl->vfebase + VFE_FRAMEDROP_VIEW_Y_PATTERN);
-	writel(0xFFFFFFFF, ctrl->vfebase + VFE_FRAMEDROP_VIEW_CBCR_PATTERN);
-	writel(0, ctrl->vfebase + VFE_CLAMP_MIN_CFG);
-	writel(0xFFFFFF, ctrl->vfebase + VFE_CLAMP_MAX_CFG);
-}
-
-static void vfe_config_demux(uint32_t period, uint32_t even, uint32_t odd)
-{
-	writel(period, ctrl->vfebase + VFE_DEMUX_CFG);
-	writel(even, ctrl->vfebase + VFE_DEMUX_EVEN_CFG);
-	writel(odd, ctrl->vfebase + VFE_DEMUX_ODD_CFG);
-}
-
-static void vfe_pm_stop(void)
-{
-	writel(VFE_PERFORMANCE_MONITOR_STOP, ctrl->vfebase + VFE_BUS_PM_CMD);
-}
-
-static void vfe_camif_stop_immediately(void)
-{
-	writel(CAMIF_COMMAND_STOP_IMMEDIATELY, ctrl->vfebase + CAMIF_COMMAND);
-	writel(0, ctrl->vfebase + VFE_CGC_OVERRIDE);
-}
-
-static void vfe_program_reg_update_cmd(uint32_t value)
-{
-	writel(value, ctrl->vfebase + VFE_REG_UPDATE_CMD);
-}
-
-static void vfe_program_global_reset_cmd(uint32_t value)
-{
-	writel(value, ctrl->vfebase + VFE_GLOBAL_RESET_CMD);
-}
-
-static void vfe_program_axi_cmd(uint32_t value)
-{
-	writel(value, ctrl->vfebase + VFE_AXI_CMD);
-}
-
-static void vfe_program_irq_composite_mask(uint32_t value)
-{
-	writel(value, ctrl->vfebase + VFE_IRQ_COMPOSITE_MASK);
-}
-
-static inline void vfe_program_irq_mask(uint32_t value)
-{
-	writel(value, ctrl->vfebase + VFE_IRQ_MASK);
-}
-
-static uint32_t vfe_read_axi_status(void)
-{
-	return readl(ctrl->vfebase + VFE_AXI_STATUS);
-}
-
-static void
-vfe_set_stats_pingpong_address(struct vfe_stats_control *afControl,
-	struct vfe_stats_control *awbControl)
-{
-	afControl->hwRegPingAddress = (uint8_t *)
-		(ctrl->vfebase + VFE_BUS_STATS_AF_WR_PING_ADDR);
-	afControl->hwRegPongAddress = (uint8_t *)
-		(ctrl->vfebase + VFE_BUS_STATS_AF_WR_PONG_ADDR);
-
-	awbControl->hwRegPingAddress = (uint8_t *)
-		(ctrl->vfebase + VFE_BUS_STATS_AWB_WR_PING_ADDR);
-	awbControl->hwRegPongAddress = (uint8_t *)
-		(ctrl->vfebase + VFE_BUS_STATS_AWB_WR_PONG_ADDR);
-}
-
-static void vfe_program_lut_bank_sel(struct vfe_gamma_lut_sel *in)
-{
-	struct VFE_GammaLutSelect_ConfigCmdType cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-
-	cmd.ch0BankSelect = in->ch0BankSelect;
-	cmd.ch1BankSelect = in->ch1BankSelect;
-	cmd.ch2BankSelect = in->ch2BankSelect;
-	CDBG("VFE gamma lut bank selection is 0x%x\n", *((uint32_t *)&cmd));
-	vfe_prog_hw(ctrl->vfebase + VFE_LUT_BANK_SEL,
-		(uint32_t *)&cmd, sizeof(cmd));
-}
-
-static void vfe_program_stats_cmd(struct vfe_stats_cmd_data *in)
-{
-	struct VFE_StatsCmdType stats;
-	memset(&stats, 0, sizeof(stats));
-
-	stats.autoFocusEnable        = in->autoFocusEnable;
-	stats.axwEnable              = in->axwEnable;
-	stats.histEnable             = in->histEnable;
-	stats.clearHistEnable        = in->clearHistEnable;
-	stats.histAutoClearEnable    = in->histAutoClearEnable;
-	stats.colorConversionEnable  = in->colorConversionEnable;
-
-	writel(*((uint32_t *)&stats), ctrl->vfebase + VFE_STATS_CMD);
-}
-
-static void vfe_pm_start(struct vfe_cmd_bus_pm_start *in)
-{
-	struct VFE_Bus_Pm_ConfigCmdType cmd;
-	memset(&cmd, 0, sizeof(struct VFE_Bus_Pm_ConfigCmdType));
-
-	cmd.output2YWrPmEnable     = in->output2YWrPmEnable;
-	cmd.output2CbcrWrPmEnable  = in->output2CbcrWrPmEnable;
-	cmd.output1YWrPmEnable     = in->output1YWrPmEnable;
-	cmd.output1CbcrWrPmEnable  = in->output1CbcrWrPmEnable;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_BUS_PM_CFG,
-		(uint32_t *)&cmd, sizeof(cmd));
-}
-
-static void vfe_8k_pm_start(struct vfe_cmd_bus_pm_start *in)
-{
-	in->output1CbcrWrPmEnable = ctrl->vfeBusConfigLocal.viewCbcrWrPathEn;
-	in->output1YWrPmEnable    = ctrl->vfeBusConfigLocal.viewYWrPathEn;
-	in->output2CbcrWrPmEnable = ctrl->vfeBusConfigLocal.encCbcrWrPathEn;
-	in->output2YWrPmEnable    = ctrl->vfeBusConfigLocal.encYWrPathEn;
-
-	if (in->output1CbcrWrPmEnable || in->output1YWrPmEnable)
-		ctrl->viewPath.pmEnabled = TRUE;
-
-	if (in->output2CbcrWrPmEnable || in->output2YWrPmEnable)
-		ctrl->encPath.pmEnabled = TRUE;
-
-	vfe_pm_start(in);
-
-	writel(VFE_PERFORMANCE_MONITOR_GO, ctrl->vfebase + VFE_BUS_PM_CMD);
-}
-
-static uint32_t vfe_irq_pack(struct vfe_interrupt_mask data)
-{
-	struct vfe_irqenable packedData;
-
-	memset(&packedData, 0, sizeof(packedData));
-
-	packedData.camifErrorIrq          = data.camifErrorIrq;
-	packedData.camifSofIrq            = data.camifSofIrq;
-	packedData.camifEolIrq            = data.camifEolIrq;
-	packedData.camifEofIrq            = data.camifEofIrq;
-	packedData.camifEpoch1Irq         = data.camifEpoch1Irq;
-	packedData.camifEpoch2Irq         = data.camifEpoch2Irq;
-	packedData.camifOverflowIrq       = data.camifOverflowIrq;
-	packedData.ceIrq                  = data.ceIrq;
-	packedData.regUpdateIrq           = data.regUpdateIrq;
-	packedData.resetAckIrq            = data.resetAckIrq;
-	packedData.encYPingpongIrq        = data.encYPingpongIrq;
-	packedData.encCbcrPingpongIrq     = data.encCbcrPingpongIrq;
-	packedData.viewYPingpongIrq       = data.viewYPingpongIrq;
-	packedData.viewCbcrPingpongIrq    = data.viewCbcrPingpongIrq;
-	packedData.rdPingpongIrq          = data.rdPingpongIrq;
-	packedData.afPingpongIrq          = data.afPingpongIrq;
-	packedData.awbPingpongIrq         = data.awbPingpongIrq;
-	packedData.histPingpongIrq        = data.histPingpongIrq;
-	packedData.encIrq                 = data.encIrq;
-	packedData.viewIrq                = data.viewIrq;
-	packedData.busOverflowIrq         = data.busOverflowIrq;
-	packedData.afOverflowIrq          = data.afOverflowIrq;
-	packedData.awbOverflowIrq         = data.awbOverflowIrq;
-	packedData.syncTimer0Irq          = data.syncTimer0Irq;
-	packedData.syncTimer1Irq          = data.syncTimer1Irq;
-	packedData.syncTimer2Irq          = data.syncTimer2Irq;
-	packedData.asyncTimer0Irq         = data.asyncTimer0Irq;
-	packedData.asyncTimer1Irq         = data.asyncTimer1Irq;
-	packedData.asyncTimer2Irq         = data.asyncTimer2Irq;
-	packedData.asyncTimer3Irq         = data.asyncTimer3Irq;
-	packedData.axiErrorIrq            = data.axiErrorIrq;
-	packedData.violationIrq           = data.violationIrq;
-
-	return *((uint32_t *)&packedData);
-}
-
-static uint32_t
-vfe_irq_composite_pack(struct vfe_irq_composite_mask_config data)
-{
-	struct VFE_Irq_Composite_MaskType packedData;
-
-	memset(&packedData, 0, sizeof(packedData));
-
-	packedData.encIrqComMaskBits   = data.encIrqComMask;
-	packedData.viewIrqComMaskBits  = data.viewIrqComMask;
-	packedData.ceDoneSelBits       = data.ceDoneSel;
-
-	return *((uint32_t *)&packedData);
-}
-
-static void vfe_addr_convert(struct msm_vfe_phy_info *pinfo,
-				enum vfe_resp_msg type, void *data, void **ext,
-				int *elen)
-{
-	switch (type) {
-	case VFE_MSG_OUTPUT_P:
-	case VFE_MSG_OUTPUT_V:{
-		pinfo->planar0_off =
-			((struct vfe_message *)data)->_u.msgOutput2.yBuffer;
-		pinfo->planar1_off =
-			((struct vfe_message *)data)->_u.msgOutput2.
-			cbcrBuffer;
-		pinfo->planar2_off = pinfo->planar0_off;
-		ctrl->extdata.bpcInfo =
-			((struct vfe_message *)data)->_u.msgOutput2.bpcInfo;
-		ctrl->extdata.asfInfo =
-			((struct vfe_message *)data)->_u.msgOutput2.asfInfo;
-		ctrl->extdata.frameCounter =
-			((struct vfe_message *)data)->_u.msgOutput2.
-			frameCounter;
-		ctrl->extdata.pmData =
-		((struct vfe_message *)data)->_u.msgOutput2.pmData;
-		*ext = &ctrl->extdata;
-		*elen = sizeof(ctrl->extdata);
-	}
-		break;
-
-	case VFE_MSG_STATS_AF:
-		pinfo->sbuf_phy =
-		((struct vfe_message *)data)->_u.msgStatsAf.afBuffer;
-		break;
-
-	case VFE_MSG_STATS_WE:
-		pinfo->sbuf_phy =
-		((struct vfe_message *)data)->_u.msgStatsWbExp.awbBuffer;
-		break;
-
-	default:
-		break;
-	} /* switch */
-}
-
-static boolean vfe_send_preview_msg(struct msm_vfe_resp *rp,
-			struct vfe_message *msg, void *data);
-static boolean vfe_send_video_msg(struct msm_vfe_resp *rp,
-			struct vfe_message *msg, void *data);
-static boolean vfe_send_mainimage_msg(struct msm_vfe_resp *rp,
-			struct vfe_message *msg, void *data);
-static boolean vfe_send_thumbnail_msg(struct msm_vfe_resp *rp,
-			struct vfe_message *msg, void *data);
-static boolean vfe_send_af_stats_msg(struct msm_vfe_resp *rp,
-			struct vfe_message *msg, void *data);
-static boolean vfe_send_awb_stats_msg(struct msm_vfe_resp *rp,
-			struct vfe_message *msg, void *data);
-static boolean vfe_send_camif_error_msg(struct msm_vfe_resp *rp,
-			struct vfe_message *msg, void *data);
-static boolean vfe_send_bus_overflow_msg(struct msm_vfe_resp *rp,
-			struct vfe_message *msg, void *data);
-static boolean vfe_send_sof_msg(struct msm_vfe_resp *rp,
-			struct vfe_message *msg, void *data);
-
-static boolean invalid(struct msm_vfe_resp *rp,
-		struct vfe_message *_m, void *_d)
-{
-	BUG_ON(1); /* this function should not be called. */
-	return FALSE;
-}
-
-static struct {
-	boolean (*fn)(struct msm_vfe_resp *rp, struct vfe_message *msg,
-		void *data);
-	enum vfe_resp_msg rt; /* reponse type */
-} vfe_funcs[] = {
-	[VFE_MSG_ID_RESET_ACK] = { NULL, VFE_MSG_GENERAL },
-	[VFE_MSG_ID_START_ACK] = { NULL, VFE_MSG_GENERAL },
-	[VFE_MSG_ID_STOP_ACK] = { NULL, VFE_MSG_GENERAL },
-	[VFE_MSG_ID_UPDATE_ACK] = { NULL, VFE_MSG_GENERAL },
-	[VFE_MSG_ID_OUTPUT_P] = { vfe_send_preview_msg, VFE_MSG_OUTPUT_P },
-	[VFE_MSG_ID_OUTPUT_V] = { vfe_send_video_msg, VFE_MSG_OUTPUT_V },
-	[VFE_MSG_ID_OUTPUT_S] = { vfe_send_mainimage_msg, VFE_MSG_OUTPUT_S },
-	[VFE_MSG_ID_OUTPUT_T] = { vfe_send_thumbnail_msg, VFE_MSG_OUTPUT_T },
-	[VFE_MSG_ID_SNAPSHOT_DONE] = { NULL, VFE_MSG_SNAPSHOT },
-	[VFE_MSG_ID_STATS_AUTOFOCUS] = { vfe_send_af_stats_msg,
-		VFE_MSG_STATS_AF },
-	[VFE_MSG_ID_STATS_WB_EXP] = { vfe_send_awb_stats_msg,
-		VFE_MSG_STATS_WE },
-	[VFE_MSG_ID_EPOCH1] = { NULL, VFE_MSG_GENERAL },
-	[VFE_MSG_ID_EPOCH2] = { NULL, VFE_MSG_GENERAL },
-	[VFE_MSG_ID_SYNC_TIMER0_DONE] = { invalid },
-	[VFE_MSG_ID_SYNC_TIMER1_DONE] = { invalid },
-	[VFE_MSG_ID_SYNC_TIMER2_DONE] = { invalid },
-	[VFE_MSG_ID_ASYNC_TIMER0_DONE] = { invalid },
-	[VFE_MSG_ID_ASYNC_TIMER1_DONE] = { invalid },
-	[VFE_MSG_ID_ASYNC_TIMER2_DONE] = { invalid },
-	[VFE_MSG_ID_ASYNC_TIMER3_DONE] = { invalid },
-	[VFE_MSG_ID_AF_OVERFLOW] = { NULL, VFE_MSG_GENERAL },
-	[VFE_MSG_ID_AWB_OVERFLOW] = { NULL, VFE_MSG_GENERAL },
-	[VFE_MSG_ID_AXI_ERROR] = { NULL, VFE_MSG_GENERAL },
-	[VFE_MSG_ID_CAMIF_OVERFLOW] = { NULL, VFE_MSG_GENERAL },
-	[VFE_MSG_ID_VIOLATION] = { invalid },
-	[VFE_MSG_ID_CAMIF_ERROR] = { vfe_send_camif_error_msg,
-		VFE_MSG_GENERAL },
-	[VFE_MSG_ID_BUS_OVERFLOW] = { vfe_send_bus_overflow_msg,
-		VFE_MSG_GENERAL },
-	[VFE_MSG_ID_SOF_ACK] = { vfe_send_sof_msg,
-		VFE_MSG_GENERAL },
-};
-
-static void vfe_proc_ops(enum VFE_MESSAGE_ID id, void *data)
-{
-	struct msm_vfe_resp *rp;
-	struct vfe_message *msg;
-
-	if (id >= ARRAY_SIZE(vfe_funcs) || vfe_funcs[id].fn == invalid) {
-		pr_err("%s: invalid VFE message id %d\n", __func__, id);
-		return;
-	}
-
-	/* In 8k, OUTPUT1 & OUTPUT2 messages arrive before SNAPSHOT_DONE.
-	 * We don't send such messages to the user.  Note that we can do
-	 * this in the vfe_func[] callback, but that would cause us to
-	 * allocate and then immediately free the msm_vfe_resp structure,
-	 * which is wasteful.
-	 */
-	if ((ctrl->vfeOperationMode == VFE_START_OPERATION_MODE_SNAPSHOT) &&
-			(id == VFE_MSG_ID_OUTPUT_T ||
-			 id == VFE_MSG_ID_OUTPUT_S))
-		return;
-
-	rp = ctrl->resp->vfe_alloc(sizeof(*rp) +
-					(vfe_funcs[id].fn ? sizeof(*msg) : 0),
-					ctrl->syncdata,
-					GFP_ATOMIC);
-	if (!rp) {
-		pr_err("%s: out of memory\n", __func__);
-		return;
-	}
-
-	rp->type = vfe_funcs[id].rt;
-	rp->evt_msg.type = MSM_CAMERA_MSG;
-	rp->evt_msg.msg_id = id;
-
-	if (!vfe_funcs[id].fn) {
-		rp->evt_msg.len = 0;
-		rp->evt_msg.data = 0;
-	} else {
-		/* populate the message accordingly */
-		if (vfe_funcs[id].fn)
-			rp->evt_msg.data = msg =
-				(struct vfe_message *)(rp + 1);
-		else
-			rp->evt_msg.data = msg = 0;
-		rp->evt_msg.len = sizeof(*msg);
-		msg->_d = id;
-		if (vfe_funcs[id].fn(rp, msg, data) == FALSE) {
-			pr_warning("%s: freeing memory: handler for %d "
-				"returned false\n", __func__, id);
-			ctrl->resp->vfe_free(rp);
-			return;
-		}
-}
-
-	ctrl->resp->vfe_resp(rp, MSM_CAM_Q_VFE_MSG, ctrl->syncdata, GFP_KERNEL);
-}
-
-static boolean vfe_send_bus_overflow_msg(struct msm_vfe_resp *rp,
-			struct vfe_message *msg,
-			void *data)
-{
-#if 0
-	memcpy(&(msg->_u.msgBusOverflow),
-		&ctrl->vfePmData, sizeof(ctrl->vfePmData));
-#endif
-	return TRUE;
-}
-
-static boolean vfe_send_sof_msg(struct msm_vfe_resp *rp,
-			struct vfe_message *msg,
-			void *data)
-{
-	return TRUE;
-}
-static boolean vfe_send_camif_error_msg(struct msm_vfe_resp *rp,
-			struct vfe_message *msg,
-			void *data)
-{
-#if 0
-	memcpy(&(msg->_u.msgCamifError),
-	       &ctrl->vfeCamifStatusLocal, sizeof(ctrl->vfeCamifStatusLocal));
-#endif
-	return TRUE;
-}
-
-static void vfe_process_error_irq(struct vfe_interrupt_status *irqstatus)
-{
-	/* all possible error irq.  Note error irqs are not enabled, it is
-	 * checked only when other interrupts are present. */
-	if (irqstatus->afOverflowIrq)
-		vfe_proc_ops(VFE_MSG_ID_AF_OVERFLOW, NULL);
-
-	if (irqstatus->awbOverflowIrq)
-		vfe_proc_ops(VFE_MSG_ID_AWB_OVERFLOW, NULL);
-
-	if (irqstatus->axiErrorIrq)
-		vfe_proc_ops(VFE_MSG_ID_AXI_ERROR, NULL);
-
-	if (irqstatus->busOverflowIrq)
-		vfe_proc_ops(VFE_MSG_ID_BUS_OVERFLOW, NULL);
-
-	if (irqstatus->camifErrorIrq) {
-		CDBG("vfe_irq: camif errors\n");
-		vfe_proc_ops(VFE_MSG_ID_CAMIF_ERROR, NULL);
-	}
-
-	if (irqstatus->camifOverflowIrq)
-		vfe_proc_ops(VFE_MSG_ID_CAMIF_OVERFLOW, NULL);
-
-	if (irqstatus->violationIrq)
-		pr_err("%s: violation irq\n", __func__);
-}
-
-static void vfe_process_camif_sof_irq(void)
-{
-	/* increment the frame id number. */
-	ctrl->vfeFrameId++;
-
-	CDBG("camif_sof_irq, frameId = %d\n", ctrl->vfeFrameId);
-
-	/* In snapshot mode, if frame skip is programmed,
-	* need to check it accordingly to stop camif at
-	* correct frame boundary. For the dropped frames,
-	* there won't be any output path irqs, but there is
-	* still SOF irq, which can help us determine when
-	* to stop the camif.
-	*/
-	if (ctrl->vfeOperationMode) {
-		if ((1 << ctrl->vfeFrameSkipCount)&ctrl->vfeFrameSkipPattern) {
-
-			ctrl->vfeSnapShotCount--;
-			if (ctrl->vfeSnapShotCount == 0)
-				/* terminate vfe pipeline at frame boundary. */
-				writel(CAMIF_COMMAND_STOP_AT_FRAME_BOUNDARY,
-					ctrl->vfebase + CAMIF_COMMAND);
-		}
-
-		/* update frame skip counter for bit checking. */
-		ctrl->vfeFrameSkipCount++;
-		if (ctrl->vfeFrameSkipCount == (ctrl->vfeFrameSkipPeriod + 1))
-			ctrl->vfeFrameSkipCount = 0;
-	}
-	vfe_proc_ops(VFE_MSG_ID_SOF_ACK, NULL);
-}
-
-static boolean vfe_get_af_pingpong_status(void)
-{
-	uint32_t busPingPongStatus =
-		readl(ctrl->vfebase + VFE_BUS_PINGPONG_STATUS);
-	return !!(busPingPongStatus & VFE_AF_PINGPONG_STATUS_BIT);
-}
-
-static uint32_t vfe_read_af_buf_addr(boolean pipo)
-{
-	if (pipo == FALSE)
-		return readl(ctrl->vfebase + VFE_BUS_STATS_AF_WR_PING_ADDR);
-	else
-		return readl(ctrl->vfebase + VFE_BUS_STATS_AF_WR_PONG_ADDR);
-}
-
-static void vfe_update_af_buf_addr(boolean pipo, uint32_t addr)
-{
-	if (pipo == FALSE)
-		writel(addr, ctrl->vfebase + VFE_BUS_STATS_AF_WR_PING_ADDR);
-	else
-		writel(addr, ctrl->vfebase + VFE_BUS_STATS_AF_WR_PONG_ADDR);
-}
-
-static boolean vfe_send_af_stats_msg(struct msm_vfe_resp *rp,
-		struct vfe_message *msg, void *data)
-{
-	uint32_t afBufAddress = (uint32_t)data;
-
-	/* fill message with right content. */
-	/* @todo This is causing issues, need further investigate */
-	/* spin_lock_irqsave(&ctrl->state_lock, flags); */
-	if (ctrl->vstate != VFE_STATE_ACTIVE)
-		return FALSE;
-
-	msg->_u.msgStatsAf.afBuffer = afBufAddress;
-	msg->_u.msgStatsAf.frameCounter = ctrl->vfeFrameId;
-
-	ctrl->afStatsControl.ackPending = TRUE;
-
-	vfe_addr_convert(&(rp->phy), rp->type, msg, NULL, NULL);
-	/* spin_unlock_irqrestore(&ctrl->state_lock, flags); */
-	return TRUE;
-}
-
-static void vfe_process_stats_af_irq(void)
-{
-	boolean bufferAvailable;
-
-	if (!(ctrl->afStatsControl.ackPending)) {
-
-		/* read hardware status. */
-		ctrl->afStatsControl.pingPongStatus =
-			vfe_get_af_pingpong_status();
-
-		bufferAvailable = (ctrl->afStatsControl.pingPongStatus) ^ 1;
-
-		ctrl->afStatsControl.bufToRender =
-			vfe_read_af_buf_addr(bufferAvailable);
-
-		/* update the same buffer address (ping or pong) */
-		vfe_update_af_buf_addr(bufferAvailable,
-			ctrl->afStatsControl.nextFrameAddrBuf);
-
-		vfe_proc_ops(VFE_MSG_ID_STATS_AUTOFOCUS,
-			(void *)ctrl->afStatsControl.bufToRender);
-	} else
-		ctrl->afStatsControl.droppedStatsFrameCount++;
-}
-
-static boolean vfe_get_awb_pingpong_status(void)
-{
-	uint32_t busPingPongStatus =
-
-		readl(ctrl->vfebase + VFE_BUS_PINGPONG_STATUS);
-
-	return !!(busPingPongStatus & VFE_AWB_PINGPONG_STATUS_BIT);
-
-}
-
-static uint32_t vfe_read_awb_buf_addr(boolean pingpong)
-{
-	if (pingpong == FALSE)
-		return readl(ctrl->vfebase + VFE_BUS_STATS_AWB_WR_PING_ADDR);
-	else
-		return readl(ctrl->vfebase + VFE_BUS_STATS_AWB_WR_PONG_ADDR);
-}
-
-static void vfe_update_awb_buf_addr(boolean pingpong, uint32_t addr)
-{
-	if (pingpong == FALSE)
-		writel(addr, ctrl->vfebase + VFE_BUS_STATS_AWB_WR_PING_ADDR);
-	else
-		writel(addr, ctrl->vfebase + VFE_BUS_STATS_AWB_WR_PONG_ADDR);
-}
-
-static boolean vfe_send_awb_stats_msg(struct msm_vfe_resp *rp,
-		struct vfe_message *msg, void *data)
-{
-	uint32_t awbBufAddress = (uint32_t)data;
-
-	/* fill message with right content. */
-	/* @todo This is causing issues, need further investigate */
-	/* spin_lock_irqsave(&ctrl->state_lock, flags); */
-	if (ctrl->vstate != VFE_STATE_ACTIVE)
-		return FALSE;
-
-	msg->_u.msgStatsWbExp.awbBuffer = awbBufAddress;
-	msg->_u.msgStatsWbExp.frameCounter = ctrl->vfeFrameId;
-
-
-	ctrl->awbStatsControl.ackPending = TRUE;
-
-	vfe_addr_convert(&(rp->phy),
-			rp->type, msg,
-			NULL, NULL);
-
-	return TRUE;
-}
-
-static void vfe_process_stats_awb_irq(void)
-{
-	boolean bufferAvailable;
-
-	if (!(ctrl->awbStatsControl.ackPending)) {
-
-		ctrl->awbStatsControl.pingPongStatus =
-			vfe_get_awb_pingpong_status();
-
-		bufferAvailable = (ctrl->awbStatsControl.pingPongStatus) ^ 1;
-
-		ctrl->awbStatsControl.bufToRender =
-			vfe_read_awb_buf_addr(bufferAvailable);
-
-		vfe_update_awb_buf_addr(bufferAvailable,
-			ctrl->awbStatsControl.nextFrameAddrBuf);
-
-		vfe_proc_ops(VFE_MSG_ID_STATS_WB_EXP,
-			(void *)ctrl->awbStatsControl.bufToRender);
-
-	} else
-		ctrl->awbStatsControl.droppedStatsFrameCount++;
-}
-
-static void vfe_write_gamma_table(uint8_t channel,
-	boolean bank, int16_t *pTable)
-{
-	uint16_t i;
-
-	enum VFE_DMI_RAM_SEL dmiRamSel = NO_MEM_SELECTED;
-
-	switch (channel) {
-	case 0:
-		if (bank == 0)
-			dmiRamSel = RGBLUT_RAM_CH0_BANK0;
-		else
-			dmiRamSel = RGBLUT_RAM_CH0_BANK1;
-		break;
-
-	case 1:
-		if (bank == 0)
-			dmiRamSel = RGBLUT_RAM_CH1_BANK0;
-		else
-			dmiRamSel = RGBLUT_RAM_CH1_BANK1;
-		break;
-
-	case 2:
-		if (bank == 0)
-			dmiRamSel = RGBLUT_RAM_CH2_BANK0;
-		else
-			dmiRamSel = RGBLUT_RAM_CH2_BANK1;
-		break;
-
-	default:
-		break;
-	}
-
-	vfe_program_dmi_cfg(dmiRamSel);
-
-	for (i = 0; i < VFE_GAMMA_TABLE_LENGTH; i++) {
-		writel((uint32_t)(*pTable), ctrl->vfebase + VFE_DMI_DATA_LO);
-		pTable++;
-	}
-
-	/* After DMI transfer, need to set the DMI_CFG to unselect any SRAM
-	unselect the SRAM Bank. */
-	writel(VFE_DMI_CFG_DEFAULT, ctrl->vfebase + VFE_DMI_CFG);
-}
-
-static void vfe_prog_hw_testgen_cmd(uint32_t value)
-{
-	writel(value, ctrl->vfebase + VFE_HW_TESTGEN_CMD);
-}
-
-static inline void vfe_read_irq_status(struct vfe_irq_thread_msg *out)
-{
-	uint32_t *temp;
-
-	memset(out, 0, sizeof(struct vfe_irq_thread_msg));
-
-	temp = (uint32_t *)(ctrl->vfebase + VFE_IRQ_STATUS);
-	out->vfeIrqStatus = readl(temp);
-
-	temp = (uint32_t *)(ctrl->vfebase + CAMIF_STATUS);
-	out->camifStatus = readl(temp);
-
-/*	this for YUV performance tuning
-	writel(0x7, ctrl->vfebase + CAMIF_COMMAND);
-	writel(0x3, ctrl->vfebase + CAMIF_COMMAND);
-	CDBG("camifStatus  = 0x%x\n", out->camifStatus);
-*/
-/*
-	temp = (uint32_t *)(ctrl->vfebase + VFE_DEMOSAIC_STATUS);
-	out->demosaicStatus = readl(temp);
-
-	temp = (uint32_t *)(ctrl->vfebase + VFE_ASF_MAX_EDGE);
-	out->asfMaxEdge = readl(temp);
-
-	temp = (uint32_t *)(ctrl->vfebase + VFE_BUS_ENC_Y_WR_PM_STATS_0);
-*/
-
-#if 0
-	out->pmInfo.encPathPmInfo.yWrPmStats0      = readl(temp++);
-	out->pmInfo.encPathPmInfo.yWrPmStats1      = readl(temp++);
-	out->pmInfo.encPathPmInfo.cbcrWrPmStats0   = readl(temp++);
-	out->pmInfo.encPathPmInfo.cbcrWrPmStats1   = readl(temp++);
-	out->pmInfo.viewPathPmInfo.yWrPmStats0     = readl(temp++);
-	out->pmInfo.viewPathPmInfo.yWrPmStats1     = readl(temp++);
-	out->pmInfo.viewPathPmInfo.cbcrWrPmStats0  = readl(temp++);
-	out->pmInfo.viewPathPmInfo.cbcrWrPmStats1  = readl(temp);
-#endif /* if 0 Jeff */
-}
-
-static void
-vfe_parse_interrupt_status(struct vfe_interrupt_status *ret,
-uint32_t irqStatusIn)
-{
-	struct vfe_irqenable hwstat;
-	boolean temp;
-
-	memset(&hwstat, 0, sizeof(hwstat));
-	memset(ret, 0, sizeof(*ret));
-
-	hwstat = *((struct vfe_irqenable *)(&irqStatusIn));
-
-	ret->camifErrorIrq = hwstat.camifErrorIrq;
-	ret->camifSofIrq = hwstat.camifSofIrq;
-	ret->camifEolIrq = hwstat.camifEolIrq;
-	ret->camifEofIrq = hwstat.camifEofIrq;
-	ret->camifEpoch1Irq = hwstat.camifEpoch1Irq;
-	ret->camifEpoch2Irq = hwstat.camifEpoch2Irq;
-	ret->camifOverflowIrq = hwstat.camifOverflowIrq;
-	ret->ceIrq = hwstat.ceIrq;
-	ret->regUpdateIrq = hwstat.regUpdateIrq;
-	ret->resetAckIrq = hwstat.resetAckIrq;
-	ret->encYPingpongIrq = hwstat.encYPingpongIrq;
-	ret->encCbcrPingpongIrq = hwstat.encCbcrPingpongIrq;
-	ret->viewYPingpongIrq = hwstat.viewYPingpongIrq;
-	ret->viewCbcrPingpongIrq = hwstat.viewCbcrPingpongIrq;
-	ret->rdPingpongIrq = hwstat.rdPingpongIrq;
-	ret->afPingpongIrq = hwstat.afPingpongIrq;
-	ret->awbPingpongIrq = hwstat.awbPingpongIrq;
-	ret->histPingpongIrq = hwstat.histPingpongIrq;
-	ret->encIrq = hwstat.encIrq;
-	ret->viewIrq = hwstat.viewIrq;
-	ret->busOverflowIrq = hwstat.busOverflowIrq;
-	ret->afOverflowIrq = hwstat.afOverflowIrq;
-	ret->awbOverflowIrq = hwstat.awbOverflowIrq;
-	ret->syncTimer0Irq = hwstat.syncTimer0Irq;
-	ret->syncTimer1Irq = hwstat.syncTimer1Irq;
-	ret->syncTimer2Irq = hwstat.syncTimer2Irq;
-	ret->asyncTimer0Irq = hwstat.asyncTimer0Irq;
-	ret->asyncTimer1Irq = hwstat.asyncTimer1Irq;
-	ret->asyncTimer2Irq = hwstat.asyncTimer2Irq;
-	ret->asyncTimer3Irq = hwstat.asyncTimer3Irq;
-	ret->axiErrorIrq = hwstat.axiErrorIrq;
-	ret->violationIrq = hwstat.violationIrq;
-
-	/* logic OR of any error bits
-	 * although each irq corresponds to a bit, the data type here is a
-	 * boolean already. hence use logic operation.
-	 */
-	temp =
-	    ret->camifErrorIrq ||
-	    ret->camifOverflowIrq ||
-	    ret->afOverflowIrq ||
-	    ret->awbOverflowIrq ||
-	    ret->awbPingpongIrq ||
-	    ret->afPingpongIrq ||
-	    ret->busOverflowIrq || ret->axiErrorIrq || ret->violationIrq;
-
-	ret->anyErrorIrqs = temp;
-
-	/* logic OR of any output path bits*/
-	temp = ret->encYPingpongIrq || ret->encCbcrPingpongIrq || ret->encIrq;
-
-	ret->anyOutput2PathIrqs = temp;
-
-	temp = ret->viewYPingpongIrq || ret->viewCbcrPingpongIrq ||
-		ret->viewIrq;
-
-	ret->anyOutput1PathIrqs = temp;
-
-	ret->anyOutputPathIrqs =
-	    ret->anyOutput1PathIrqs || ret->anyOutput2PathIrqs;
-
-	/* logic OR of any sync timer bits*/
-	temp = ret->syncTimer0Irq || ret->syncTimer1Irq || ret->syncTimer2Irq;
-
-	ret->anySyncTimerIrqs = temp;
-
-	/* logic OR of any async timer bits*/
-	temp =
-	    ret->asyncTimer0Irq ||
-	    ret->asyncTimer1Irq || ret->asyncTimer2Irq || ret->asyncTimer3Irq;
-
-	ret->anyAsyncTimerIrqs = temp;
-
-	/* bool for all interrupts that are not allowed in idle state */
-	temp =
-	    ret->anyErrorIrqs ||
-	    ret->anyOutputPathIrqs ||
-	    ret->anySyncTimerIrqs ||
-	    ret->regUpdateIrq ||
-	    ret->awbPingpongIrq ||
-	    ret->afPingpongIrq ||
-	    ret->camifSofIrq || ret->camifEpoch2Irq || ret->camifEpoch1Irq;
-
-	ret->anyIrqForActiveStatesOnly = temp;
-}
-
-static void
-vfe_get_asf_frame_info(struct vfe_frame_asf_info *rc,
-struct vfe_irq_thread_msg *in)
-{
-	struct vfe_asf_info     asfInfoTemp;
-
-	memset(rc, 0, sizeof(*rc));
-	memset(&asfInfoTemp, 0, sizeof(asfInfoTemp));
-
-	asfInfoTemp = *((struct vfe_asf_info *)(&(in->asfMaxEdge)));
-
-	rc->asfHbiCount = asfInfoTemp.HBICount;
-	rc->asfMaxEdge = asfInfoTemp.maxEdge;
-}
-
-static void
-vfe_get_demosaic_frame_info(struct vfe_frame_bpc_info *rc,
-struct vfe_irq_thread_msg *in)
-{
-	struct vfe_bps_info     bpcInfoTemp;
-
-	memset(rc, 0, sizeof(*rc));
-	memset(&bpcInfoTemp, 0, sizeof(bpcInfoTemp));
-
-	bpcInfoTemp = *((struct vfe_bps_info *)(&(in->demosaicStatus)));
-
-	rc->greenDefectPixelCount = bpcInfoTemp.greenBadPixelCount;
-
-	rc->redBlueDefectPixelCount = bpcInfoTemp.RedBlueBadPixelCount;
-}
-
-static void
-vfe_get_camif_status(struct vfe_msg_camif_status *rc,
-struct vfe_irq_thread_msg *in)
-{
-	struct vfe_camif_stats camifStatusTemp;
-
-	memset(rc, 0, sizeof(*rc));
-	memset(&camifStatusTemp, 0, sizeof(camifStatusTemp));
-
-	camifStatusTemp = *((struct vfe_camif_stats *)(&(in->camifStatus)));
-
-	rc->camifState = (boolean) camifStatusTemp.camifHalt;
-	rc->lineCount = camifStatusTemp.lineCount;
-	rc->pixelCount = camifStatusTemp.pixelCount;
-}
-
-static void
-vfe_get_performance_monitor_data(struct vfe_bus_performance_monitor *rc,
-		struct vfe_irq_thread_msg *in)
-{
-	memset(rc, 0, sizeof(*rc));
-
-	rc->encPathPmInfo.yWrPmStats0 = in->pmInfo.encPathPmInfo.yWrPmStats0;
-	rc->encPathPmInfo.yWrPmStats1 = in->pmInfo.encPathPmInfo.yWrPmStats1;
-	rc->encPathPmInfo.cbcrWrPmStats0 =
-		in->pmInfo.encPathPmInfo.cbcrWrPmStats0;
-	rc->encPathPmInfo.cbcrWrPmStats1 =
-		in->pmInfo.encPathPmInfo.cbcrWrPmStats1;
-	rc->viewPathPmInfo.yWrPmStats0 = in->pmInfo.viewPathPmInfo.yWrPmStats0;
-	rc->viewPathPmInfo.yWrPmStats1 = in->pmInfo.viewPathPmInfo.yWrPmStats1;
-	rc->viewPathPmInfo.cbcrWrPmStats0 =
-		in->pmInfo.viewPathPmInfo.cbcrWrPmStats0;
-	rc->viewPathPmInfo.cbcrWrPmStats1 =
-	    in->pmInfo.viewPathPmInfo.cbcrWrPmStats1;
-}
-
-static void vfe_process_reg_update_irq(void)
-{
-	CDBG("vfe_process_reg_update_irq: ackPendingFlag is %d\n",
-	ctrl->vfeStartAckPendingFlag);
-	if (ctrl->vfeStartAckPendingFlag == TRUE) {
-		vfe_proc_ops(VFE_MSG_ID_START_ACK, NULL);
-		ctrl->vfeStartAckPendingFlag = FALSE;
-	} else
-		vfe_proc_ops(VFE_MSG_ID_UPDATE_ACK, NULL);
-}
-
-static void vfe_process_reset_irq(void)
-{
-	/* unsigned long flags; */
-
-	/* @todo This is causing issues, need further investigate */
-	/* spin_lock_irqsave(&ctrl->state_lock, flags); */
-	ctrl->vstate = VFE_STATE_IDLE;
-	/* spin_unlock_irqrestore(&ctrl->state_lock, flags); */
-
-	if (ctrl->vfeStopAckPending == TRUE) {
-		ctrl->vfeStopAckPending = FALSE;
-		vfe_proc_ops(VFE_MSG_ID_STOP_ACK, NULL);
-	} else {
-		vfe_set_default_reg_values();
-		vfe_proc_ops(VFE_MSG_ID_RESET_ACK, NULL);
-	}
-}
-
-static void vfe_process_pingpong_irq(struct vfe_output_path *in,
-	uint8_t fragmentCount)
-{
-	uint16_t circularIndex;
-	uint32_t nextFragmentAddr;
-
-	/* get next fragment address from circular buffer */
-	circularIndex    = (in->fragIndex) % (2 * fragmentCount);
-	nextFragmentAddr = in->addressBuffer[circularIndex];
-
-	in->fragIndex = circularIndex + 1;
-
-	/* use next fragment to program hardware ping/pong address. */
-	if (in->hwCurrentFlag == ping) {
-		writel(nextFragmentAddr, in->hwRegPingAddress);
-		in->hwCurrentFlag = pong;
-
-	} else {
-		writel(nextFragmentAddr, in->hwRegPongAddress);
-		in->hwCurrentFlag = ping;
-	}
-}
-
-static boolean vfe_send_video_msg(struct msm_vfe_resp *rp,
-		struct vfe_message *msg, void *data)
-{
-	struct vfe_msg_output *pPayload = data;
-
-	if (ctrl->vstate != VFE_STATE_ACTIVE)
-		return FALSE;
-	memcpy(&(msg->_u),
-		(void *)pPayload, sizeof(struct vfe_msg_output));
-
-	rp->phy.output_id = OUTPUT_TYPE_V;
-	CDBG("vfe_send_video_msg rp->type= %d\n", rp->type);
-
-	vfe_addr_convert(&(rp->phy),
-			rp->type, msg,
-			&(rp->extdata), &(rp->extlen));
-	return TRUE;
-}
-
-static boolean vfe_send_preview_msg(struct msm_vfe_resp *rp,
-		struct vfe_message *msg, void *data)
-{
-	struct vfe_msg_output *pPayload = data;
-
-	if (ctrl->vstate != VFE_STATE_ACTIVE)
-		return FALSE;
-
-	memcpy(&(msg->_u), (void *)pPayload, sizeof(struct vfe_msg_output));
-
-	rp->phy.output_id = OUTPUT_TYPE_P;
-	CDBG("vfe_send_preview_msg rp->type= %d\n", rp->type);
-
-	vfe_addr_convert(&(rp->phy),
-			rp->type, msg,
-			&(rp->extdata), &(rp->extlen));
-
-	return TRUE;
-}
-
-
-static boolean vfe_send_thumbnail_msg(struct msm_vfe_resp *rp,
-		struct vfe_message *msg, void *data)
-{
-	struct vfe_msg_output *pPayload = data;
-
-	if (ctrl->vstate != VFE_STATE_ACTIVE)
-		return FALSE;
-
-	memcpy(&(msg->_u), (void *)pPayload, sizeof(struct vfe_msg_output));
-
-	rp->phy.output_id = OUTPUT_TYPE_T;
-	CDBG("vfe_send_thumbnail_msg rp->type= %d\n", rp->type);
-
-	if (ctrl->viewPath.snapshotPendingCount <= 1)
-		ctrl->viewPath.ackPending = FALSE;
-
-	vfe_addr_convert(&(rp->phy),
-			rp->type, msg,
-			&(rp->extdata), &(rp->extlen));
-	return TRUE;
-}
-
-static boolean vfe_send_mainimage_msg(struct msm_vfe_resp *rp,
-		struct vfe_message *msg, void *data)
-{
-	struct vfe_msg_output *pPayload = data;
-
-	if (ctrl->vstate != VFE_STATE_ACTIVE)
-		return FALSE;
-
-	memcpy(&(msg->_u), (void *)pPayload, sizeof(struct vfe_msg_output));
-
-	rp->phy.output_id = OUTPUT_TYPE_S;
-	CDBG("vfe_send_mainimage_msg rp->type= %d\n", rp->type);
-
-	if (ctrl->encPath.snapshotPendingCount <= 1) {
-		ctrl->encPath.ackPending = FALSE;
-	}
-
-	vfe_addr_convert(&(rp->phy),
-			rp->type, msg,
-			&(rp->extdata), &(rp->extlen));
-
-	return TRUE;
-}
-
-static void vfe_send_output_msg(boolean whichOutputPath,
-	uint32_t yPathAddr, uint32_t cbcrPathAddr)
-{
-	struct vfe_msg_output msgPayload;
-
-	msgPayload.yBuffer = yPathAddr;
-	msgPayload.cbcrBuffer = cbcrPathAddr;
-
-	/* asf info is common for both output1 and output2 */
-#if 0
-	msgPayload.asfInfo.asfHbiCount = ctrl->vfeAsfFrameInfo.asfHbiCount;
-	msgPayload.asfInfo.asfMaxEdge = ctrl->vfeAsfFrameInfo.asfMaxEdge;
-
-	/* demosaic info is common for both output1 and output2 */
-	msgPayload.bpcInfo.greenDefectPixelCount =
-		ctrl->vfeBpcFrameInfo.greenDefectPixelCount;
-	msgPayload.bpcInfo.redBlueDefectPixelCount =
-		ctrl->vfeBpcFrameInfo.redBlueDefectPixelCount;
-#endif /* if 0 */
-
-	/* frame ID is common for both paths. */
-	msgPayload.frameCounter = ctrl->vfeFrameId;
-
-	if (whichOutputPath) {
-		/* msgPayload.pmData = ctrl->vfePmData.encPathPmInfo; */
-		ctrl->encPath.ackPending = TRUE;
-
-		if (ctrl->vfeOperationMode == 0) {
-			if (ctrl->axiOutputMode ==
-				VFE_AXI_OUTPUT_MODE_Output1AndOutput2) {
-				/* video mode */
-				vfe_proc_ops(VFE_MSG_ID_OUTPUT_V, &msgPayload);
-			} else{
-				/* preview mode */
-				vfe_proc_ops(VFE_MSG_ID_OUTPUT_P, &msgPayload);
-			}
-		} else {
-			vfe_proc_ops(VFE_MSG_ID_OUTPUT_S, &msgPayload);
-		}
-
-	} else {
-		/* physical output1 path from vfe */
-		ctrl->viewPath.ackPending = TRUE;
-
-		if (ctrl->vfeOperationMode == 0) {
-			vfe_proc_ops(VFE_MSG_ID_OUTPUT_P, &msgPayload);
-			CDBG(" video mode display output.\n");
-
-		} else{
-			vfe_proc_ops(VFE_MSG_ID_OUTPUT_T, &msgPayload);
-			CDBG(" snapshot mode thumbnail output.\n");
-		}
-	}
-}
-
-static void vfe_process_frame_done_irq_multi_frag(struct vfe_output_path_combo
-						  *in)
-{
-	uint32_t yAddress, cbcrAddress;
-	uint16_t idx;
-	uint32_t *ptrY;
-	uint32_t *ptrCbcr;
-	const uint32_t *ptrSrc;
-	uint8_t i;
-
-	if (!in->ackPending) {
-
-		idx = (in->currentFrame) * (in->fragCount);
-
-		/* Send output message. */
-		yAddress = in->yPath.addressBuffer[idx];
-		cbcrAddress = in->cbcrPath.addressBuffer[idx];
-
-		/* copy next frame to current frame. */
-		ptrSrc  = in->nextFrameAddrBuf;
-		ptrY = (uint32_t *)&in->yPath.addressBuffer[idx];
-		ptrCbcr = (uint32_t *)&in->cbcrPath.addressBuffer[idx];
-
-		/* Copy Y address */
-		for (i = 0; i < in->fragCount; i++)
-			*ptrY++ = *ptrSrc++;
-
-		/* Copy Cbcr address */
-		for (i = 0; i < in->fragCount; i++)
-			*ptrCbcr++ = *ptrSrc++;
-
-		vfe_send_output_msg(in->whichOutputPath, yAddress, cbcrAddress);
-
-	} else {
-		if (in->whichOutputPath == 0)
-			ctrl->vfeDroppedFrameCounts.output1Count++;
-
-		if (in->whichOutputPath == 1)
-			ctrl->vfeDroppedFrameCounts.output2Count++;
-	}
-
-	/* toggle current frame. */
-	in->currentFrame = in->currentFrame^1;
-
-	if (ctrl->vfeOperationMode)
-		in->snapshotPendingCount--;
-}
-
-static void vfe_process_frame_done_irq_no_frag_io(
-		struct vfe_output_path_combo *in,
-		uint32_t *pNextAddr,
-	uint32_t *pdestRenderAddr)
-{
-	uint32_t busPingPongStatus;
-	uint32_t tempAddress;
-
-	/* 1. read hw status register. */
-	busPingPongStatus = readl(ctrl->vfebase + VFE_BUS_PINGPONG_STATUS);
-
-	CDBG("hardware status is 0x%x\n", busPingPongStatus);
-
-	/* 2. determine ping or pong */
-	/* use cbcr status */
-	busPingPongStatus = busPingPongStatus & (1<<(in->cbcrStatusBit));
-
-	/* 3. read out address and update address */
-	if (busPingPongStatus == 0) {
-		/* hw is working on ping, render pong buffer */
-		/* a. read out pong address */
-		/* read out y address. */
-		tempAddress = readl(in->yPath.hwRegPongAddress);
-
-		CDBG("pong 1 addr = 0x%x\n", tempAddress);
-		*pdestRenderAddr++ = tempAddress;
-		/* read out cbcr address. */
-		tempAddress = readl(in->cbcrPath.hwRegPongAddress);
-
-		CDBG("pong 2 addr = 0x%x\n", tempAddress);
-		*pdestRenderAddr = tempAddress;
-
-		/* b. update pong address */
-		writel(*pNextAddr++, in->yPath.hwRegPongAddress);
-		writel(*pNextAddr, in->cbcrPath.hwRegPongAddress);
-	} else {
-		/* hw is working on pong, render ping buffer */
-
-		/* a. read out ping address */
-		tempAddress = readl(in->yPath.hwRegPingAddress);
-		CDBG("ping 1 addr = 0x%x\n", tempAddress);
-		*pdestRenderAddr++ = tempAddress;
-		tempAddress = readl(in->cbcrPath.hwRegPingAddress);
-
-		CDBG("ping 2 addr = 0x%x\n", tempAddress);
-		*pdestRenderAddr = tempAddress;
-
-		/* b. update ping address */
-		writel(*pNextAddr++, in->yPath.hwRegPingAddress);
-		CDBG("NextAddress = 0x%x\n", *pNextAddr);
-		writel(*pNextAddr, in->cbcrPath.hwRegPingAddress);
-	}
-}
-
-static void vfe_process_frame_done_irq_no_frag(struct vfe_output_path_combo *in)
-{
-	uint32_t addressToRender[2];
-
-	if (!in->ackPending) {
-		vfe_process_frame_done_irq_no_frag_io(in,
-						      in->nextFrameAddrBuf,
-						      addressToRender);
-
-		/* use addressToRender to send out message. */
-		vfe_send_output_msg(in->whichOutputPath,
-				addressToRender[0], addressToRender[1]);
-
-	} else {
-		/* ackPending is still there, accumulate dropped frame count.
-		 * These count can be read through ioctrl command. */
-		CDBG("waiting frame ACK\n");
-
-		if (in->whichOutputPath == 0)
-			ctrl->vfeDroppedFrameCounts.output1Count++;
-
-		if (in->whichOutputPath == 1)
-			ctrl->vfeDroppedFrameCounts.output2Count++;
-	}
-
-	/* in case of multishot when upper layer did not ack, there will still
-	 * be a snapshot done msg sent out, even though the number of frames
-	 * sent out may be less than the desired number of frames.  snapshot
-	 * done msg would be helpful to indicate that vfe pipeline has stop,
-	 * and in good known state.
-	 */
-	if (ctrl->vfeOperationMode)
-		in->snapshotPendingCount--;
-}
-
-static void vfe_process_output_path_irq(struct vfe_interrupt_status *irqstatus)
-{
-	/* unsigned long flags; */
-
-	/* process the view path interrupts */
-	if (irqstatus->anyOutput1PathIrqs) {
-		if (ctrl->viewPath.multiFrag) {
-
-			if (irqstatus->viewCbcrPingpongIrq)
-				vfe_process_pingpong_irq(&
-							 (ctrl->viewPath.
-							  cbcrPath),
-							 ctrl->viewPath.
-							 fragCount);
-
-			if (irqstatus->viewYPingpongIrq)
-				vfe_process_pingpong_irq(&
-							 (ctrl->viewPath.yPath),
-							 ctrl->viewPath.
-							 fragCount);
-
-			if (irqstatus->viewIrq)
-				vfe_process_frame_done_irq_multi_frag(&ctrl->
-								      viewPath);
-
-		} else {
-			/* typical case for no fragment,
-			 only frame done irq is enabled. */
-			if (irqstatus->viewIrq)
-				vfe_process_frame_done_irq_no_frag(&ctrl->
-								   viewPath);
-		}
-	}
-
-	/* process the encoder path interrupts */
-	if (irqstatus->anyOutput2PathIrqs) {
-		if (ctrl->encPath.multiFrag) {
-			if (irqstatus->encCbcrPingpongIrq)
-				vfe_process_pingpong_irq(&
-							 (ctrl->encPath.
-							  cbcrPath),
-							 ctrl->encPath.
-							 fragCount);
-
-			if (irqstatus->encYPingpongIrq)
-				vfe_process_pingpong_irq(&(ctrl->encPath.yPath),
-							 ctrl->encPath.
-							 fragCount);
-
-			if (irqstatus->encIrq)
-				vfe_process_frame_done_irq_multi_frag(&ctrl->
-								      encPath);
-
-		} else {
-			if (irqstatus->encIrq)
-				vfe_process_frame_done_irq_no_frag(&ctrl->
-								   encPath);
-		}
-	}
-
-	if (ctrl->vfeOperationMode) {
-		if ((ctrl->encPath.snapshotPendingCount == 0) &&
-				(ctrl->viewPath.snapshotPendingCount == 0)) {
-
-			/* @todo This is causing issues, further investigate */
-			/* spin_lock_irqsave(&ctrl->state_lock, flags); */
-			ctrl->vstate = VFE_STATE_IDLE;
-			/* spin_unlock_irqrestore(&ctrl->state_lock, flags); */
-
-			vfe_proc_ops(VFE_MSG_ID_SNAPSHOT_DONE, NULL);
-			vfe_camif_stop_immediately();
-			vfe_prog_hw_testgen_cmd(VFE_TEST_GEN_STOP);
-			vfe_pm_stop();
-		}
-	}
-}
-
-static void __vfe_do_tasklet(struct isr_queue_cmd *qcmd)
-{
-	if (qcmd->vfeInterruptStatus.regUpdateIrq) {
-		CDBG("irq regUpdateIrq\n");
-		vfe_process_reg_update_irq();
-	}
-
-	if (qcmd->vfeInterruptStatus.resetAckIrq) {
-		CDBG("%s: process resetAckIrq\n", __func__);
-		vfe_process_reset_irq();
-	}
-
-	if (ctrl->vstate != VFE_STATE_ACTIVE)
-		return;
-
-#if 0
-	if (qcmd->vfeInterruptStatus.camifEpoch1Irq)
-		vfe_proc_ops(VFE_MSG_ID_EPOCH1);
-
-	if (qcmd->vfeInterruptStatus.camifEpoch2Irq)
-		vfe_proc_ops(VFE_MSG_ID_EPOCH2);
-#endif /* Jeff */
-
-	/* next, check output path related interrupts. */
-	if (qcmd->vfeInterruptStatus.anyOutputPathIrqs) {
-		CDBG("irq: anyOutputPathIrqs\n");
-		vfe_process_output_path_irq(&qcmd->vfeInterruptStatus);
-	}
-
-	if (qcmd->vfeInterruptStatus.afPingpongIrq)
-		vfe_process_stats_af_irq();
-
-	if (qcmd->vfeInterruptStatus.awbPingpongIrq)
-		vfe_process_stats_awb_irq();
-
-	/* any error irqs*/
-	if (qcmd->vfeInterruptStatus.anyErrorIrqs)
-		vfe_process_error_irq(&qcmd->vfeInterruptStatus);
-
-#if 0
-	if (qcmd->vfeInterruptStatus.anySyncTimerIrqs)
-		vfe_process_sync_timer_irq();
-
-	if (qcmd->vfeInterruptStatus.anyAsyncTimerIrqs)
-		vfe_process_async_timer_irq();
-#endif /* Jeff */
-
-	if (qcmd->vfeInterruptStatus.camifSofIrq) {
-		CDBG("irq: camifSofIrq\n");
-		vfe_process_camif_sof_irq();
-	}
-}
-
-static struct isr_queue_cmd *get_irq_cmd_nosync(void)
-{
-	int old_get = ctrl->irq_get++;
-	ctrl->irq_get = ctrl->irq_get % ARRAY_SIZE(ctrl->irqs);
-	if (ctrl->irq_get == ctrl->irq_put) {
-		pr_err("%s: out of irq command packets\n", __func__);
-		ctrl->irq_get = old_get;
-		return NULL;
-	}
-
-	return ctrl->irqs + old_get;
-}
-
-static struct isr_queue_cmd *next_irq_cmd(void)
-{
-	unsigned long flags;
-	struct isr_queue_cmd *cmd;
-	spin_lock_irqsave(&ctrl->irqs_lock, flags);
-	if (ctrl->irq_get == ctrl->irq_put) {
-		spin_unlock_irqrestore(&ctrl->irqs_lock, flags);
-		return NULL; /* already empty */
-	}
-	cmd = ctrl->irqs + ctrl->irq_put;
-	spin_unlock_irqrestore(&ctrl->irqs_lock, flags);
-	return cmd;
-}
-
-static void put_irq_cmd(void)
-{
-	unsigned long flags;
-	spin_lock_irqsave(&ctrl->irqs_lock, flags);
-	if (ctrl->irq_get == ctrl->irq_put) {
-		spin_unlock_irqrestore(&ctrl->irqs_lock, flags);
-		return; /* already empty */
-	}
-	ctrl->irq_put++;
-	ctrl->irq_put %= ARRAY_SIZE(ctrl->irqs);
-	spin_unlock_irqrestore(&ctrl->irqs_lock, flags);
-}
-
-static void vfe_do_tasklet(unsigned long data)
-{
-	int cnt = 0;
-	unsigned long flags;
-	struct isr_queue_cmd *qcmd = NULL;
-
-	spin_lock_irqsave(&msm_vfe_ctrl_lock, flags);
-	if (!ctrl) {
-		spin_unlock_irqrestore(&msm_vfe_ctrl_lock, flags);
-		return;
-	}
-
-	CDBG("%s\n", __func__);
-
-	while ((qcmd = next_irq_cmd())) {
-		__vfe_do_tasklet(qcmd);
-		put_irq_cmd();
-		cnt++;
-	}
-
-	if (cnt > ARRAY_SIZE(ctrl->irqs)/2)
-		CDBG("%s: serviced %d vfe interrupts\n", __func__, cnt);
-
-	spin_unlock_irqrestore(&msm_vfe_ctrl_lock, flags);
-}
-
-DECLARE_TASKLET(vfe_tasklet, vfe_do_tasklet, 0);
-
-static irqreturn_t vfe_parse_irq(int irq_num, void *data)
-{
-	unsigned long flags;
-	uint32_t irqStatusLocal;
-	struct vfe_irq_thread_msg irq;
-	struct isr_queue_cmd *qcmd;
-
-	CDBG("vfe_parse_irq\n");
-
-	if (!atomic_read(&ctrl->vfe_serv_interrupt))
-		return IRQ_HANDLED;
-
-	vfe_read_irq_status(&irq);
-
-	if (irq.vfeIrqStatus == 0) {
-		CDBG("vfe_parse_irq: irq.vfeIrqStatus is 0\n");
-		return IRQ_HANDLED;
-	}
-
-	if (ctrl->vfeStopAckPending)
-		irqStatusLocal = (VFE_IMASK_WHILE_STOPPING & irq.vfeIrqStatus);
-	else
-		irqStatusLocal =
-			((ctrl->vfeImaskPacked | VFE_IMASK_ERROR_ONLY) &
-				irq.vfeIrqStatus);
-
-	spin_lock_irqsave(&ctrl->irqs_lock, flags);
-	qcmd = get_irq_cmd_nosync();
-	if (!qcmd) {
-		spin_unlock_irqrestore(&ctrl->irqs_lock, flags);
-		goto done;
-	}
-	/* first parse the interrupt status to local data structures. */
-	vfe_parse_interrupt_status(&qcmd->vfeInterruptStatus, irqStatusLocal);
-	vfe_get_asf_frame_info(&qcmd->vfeAsfFrameInfo, &irq);
-	vfe_get_demosaic_frame_info(&qcmd->vfeBpcFrameInfo, &irq);
-	vfe_get_camif_status(&qcmd->vfeCamifStatusLocal, &irq);
-	vfe_get_performance_monitor_data(&qcmd->vfePmData, &irq);
-	spin_unlock_irqrestore(&ctrl->irqs_lock, flags);
-	tasklet_schedule(&vfe_tasklet);
-
-done:
-	/* clear the pending interrupt of the same kind.*/
-	writel(irq.vfeIrqStatus, ctrl->vfebase + VFE_IRQ_CLEAR);
-
-	return IRQ_HANDLED;
-}
-
-int vfe_cmd_init(struct msm_vfe_callback *presp,
-	struct platform_device *pdev, void *sdata)
-{
-	struct resource	*vfemem, *vfeirq, *vfeio;
-	int rc;
-	struct msm_camera_sensor_info *s_info;
-	s_info = pdev->dev.platform_data;
-
-	pdev->resource = s_info->resource;
-	pdev->num_resources = s_info->num_resources;
-
-	vfemem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!vfemem) {
-		pr_err("%s: no mem resource\n", __func__);
-		return -ENODEV;
-	}
-
-	vfeirq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	if (!vfeirq) {
-		pr_err("%s: no irq resource\n", __func__);
-		return -ENODEV;
-	}
-
-	vfeio = request_mem_region(vfemem->start,
-		resource_size(vfemem), pdev->name);
-	if (!vfeio) {
-		pr_err("%s: VFE region already claimed\n", __func__);
-		return -EBUSY;
-	}
-
-	ctrl = kzalloc(sizeof(struct msm_vfe8x_ctrl), GFP_KERNEL);
-	if (!ctrl) {
-		pr_err("%s: out of memory\n", __func__);
-		rc = -ENOMEM;
-		goto cmd_init_failed1;
-	}
-	atomic_set(&ctrl->vfe_serv_interrupt, 0);
-	ctrl->vfeirq  = vfeirq->start;
-
-	ctrl->vfebase =
-		ioremap(vfemem->start, (vfemem->end - vfemem->start) + 1);
-	if (!ctrl->vfebase) {
-		pr_err("%s: ioremap failed\n", __func__);
-		rc = -ENOMEM;
-		goto cmd_init_failed2;
-	}
-
-	rc = request_irq(ctrl->vfeirq, vfe_parse_irq,
-		IRQF_TRIGGER_RISING, "vfe", 0);
-	if (rc < 0) {
-		pr_err("%s: request_irq(%d) failed\n", __func__, ctrl->vfeirq);
-		goto cmd_init_failed2;
-	}
-
-	if (presp && presp->vfe_resp)
-		ctrl->resp = presp;
-	else {
-		pr_err("%s: no vfe_resp function\n", __func__);
-
-		rc = -EIO;
-		goto cmd_init_failed3;
-	}
-
-	ctrl->syncdata = sdata;
-	return 0;
-
-cmd_init_failed3:
-	disable_irq(ctrl->vfeirq);
-	free_irq(ctrl->vfeirq, 0);
-	iounmap(ctrl->vfebase);
-cmd_init_failed2:
-	kfree(ctrl);
-cmd_init_failed1:
-	release_mem_region(vfemem->start, (vfemem->end - vfemem->start) + 1);
-	return rc;
-}
-
-void vfe_cmd_release(struct platform_device *dev)
-{
-	struct resource	*mem;
-	unsigned long flags;
-	atomic_set(&ctrl->vfe_serv_interrupt, 0);
-	disable_irq(ctrl->vfeirq);
-	free_irq(ctrl->vfeirq, 0);
-
-	iounmap(ctrl->vfebase);
-	mem = platform_get_resource(dev, IORESOURCE_MEM, 0);
-	release_mem_region(mem->start, (mem->end - mem->start) + 1);
-
-	spin_lock_irqsave(&msm_vfe_ctrl_lock, flags);
-	kfree(ctrl);
-	ctrl = 0;
-	spin_unlock_irqrestore(&msm_vfe_ctrl_lock, flags);
-}
-
-void vfe_stats_af_stop(void)
-{
-	ctrl->vfeStatsCmdLocal.autoFocusEnable = FALSE;
-	ctrl->vfeImaskLocal.afPingpongIrq = FALSE;
-}
-
-void vfe_stop(void)
-{
-	int spin_cnt = 0;
-	uint32_t vfeAxiStauts;
-
-	/* for reset hw modules, and send msg when reset_irq comes.*/
-	ctrl->vfeStopAckPending = TRUE;
-
-	ctrl->vfeStatsPingPongReloadFlag = FALSE;
-	vfe_pm_stop();
-
-	/* disable all interrupts.  */
-	vfe_program_irq_mask(VFE_DISABLE_ALL_IRQS);
-
-	/* in either continuous or snapshot mode, stop command can be issued
-	 * at any time.
-	 */
-	vfe_camif_stop_immediately();
-	vfe_program_axi_cmd(AXI_HALT);
-	vfe_prog_hw_testgen_cmd(VFE_TEST_GEN_STOP);
-
-	do {
-		vfeAxiStauts = vfe_read_axi_status();
-		spin_cnt++;
-	} while (!(vfeAxiStauts & AXI_STATUS_BUSY_MASK));
-	if (spin_cnt > 1)
-		pr_warning("%s: spin_cnt %d\n", __func__, spin_cnt);
-
-	vfe_program_axi_cmd(AXI_HALT_CLEAR);
-
-	/* clear all pending interrupts */
-	writel(VFE_CLEAR_ALL_IRQS, ctrl->vfebase + VFE_IRQ_CLEAR);
-
-	/* enable reset_ack and async timer interrupt only while stopping
-	 * the pipeline.
-	 */
-	vfe_program_irq_mask(VFE_IMASK_WHILE_STOPPING);
-
-	vfe_program_global_reset_cmd(VFE_RESET_UPON_STOP_CMD);
-}
-
-void vfe_update(void)
-{
-	ctrl->vfeModuleEnableLocal.statsEnable =
-		ctrl->vfeStatsCmdLocal.autoFocusEnable |
-		ctrl->vfeStatsCmdLocal.axwEnable;
-
-	vfe_reg_module_cfg(&ctrl->vfeModuleEnableLocal);
-
-	vfe_program_stats_cmd(&ctrl->vfeStatsCmdLocal);
-
-	ctrl->vfeImaskPacked = vfe_irq_pack(ctrl->vfeImaskLocal);
-	vfe_program_irq_mask(ctrl->vfeImaskPacked);
-
-	if ((ctrl->vfeModuleEnableLocal.statsEnable == TRUE) &&
-			(ctrl->vfeStatsPingPongReloadFlag == FALSE)) {
-		ctrl->vfeStatsPingPongReloadFlag = TRUE;
-
-		ctrl->vfeBusCmdLocal.statsPingpongReload = TRUE;
-		vfe_reg_bus_cmd(&ctrl->vfeBusCmdLocal);
-	}
-
-	vfe_program_reg_update_cmd(VFE_REG_UPDATE_TRIGGER);
-}
-
-int vfe_rgb_gamma_update(struct vfe_cmd_rgb_gamma_config *in)
-{
-	int rc = 0;
-
-	ctrl->vfeModuleEnableLocal.rgbLUTEnable = in->enable;
-
-	switch (in->channelSelect) {
-	case RGB_GAMMA_CH0_SELECTED:
-		ctrl->vfeGammaLutSel.ch0BankSelect ^= 1;
-		vfe_write_gamma_table(0,
-				      ctrl->vfeGammaLutSel.ch0BankSelect,
-				      in->table);
-		break;
-
-	case RGB_GAMMA_CH1_SELECTED:
-		ctrl->vfeGammaLutSel.ch1BankSelect ^= 1;
-		vfe_write_gamma_table(1,
-				      ctrl->vfeGammaLutSel.ch1BankSelect,
-				      in->table);
-		break;
-
-	case RGB_GAMMA_CH2_SELECTED:
-		ctrl->vfeGammaLutSel.ch2BankSelect ^= 1;
-		vfe_write_gamma_table(2,
-				      ctrl->vfeGammaLutSel.ch2BankSelect,
-				      in->table);
-		break;
-
-	case RGB_GAMMA_CH0_CH1_SELECTED:
-		ctrl->vfeGammaLutSel.ch0BankSelect ^= 1;
-		ctrl->vfeGammaLutSel.ch1BankSelect ^= 1;
-		vfe_write_gamma_table(0, ctrl->vfeGammaLutSel.ch0BankSelect,
-			in->table);
-		vfe_write_gamma_table(1, ctrl->vfeGammaLutSel.ch1BankSelect,
-			in->table);
-		break;
-
-	case RGB_GAMMA_CH0_CH2_SELECTED:
-		ctrl->vfeGammaLutSel.ch0BankSelect ^= 1;
-		ctrl->vfeGammaLutSel.ch2BankSelect ^= 1;
-		vfe_write_gamma_table(0, ctrl->vfeGammaLutSel.ch0BankSelect,
-			in->table);
-		vfe_write_gamma_table(2, ctrl->vfeGammaLutSel.ch2BankSelect,
-			in->table);
-		break;
-
-	case RGB_GAMMA_CH1_CH2_SELECTED:
-		ctrl->vfeGammaLutSel.ch1BankSelect ^= 1;
-		ctrl->vfeGammaLutSel.ch2BankSelect ^= 1;
-		vfe_write_gamma_table(1, ctrl->vfeGammaLutSel.ch1BankSelect,
-			in->table);
-		vfe_write_gamma_table(2, ctrl->vfeGammaLutSel.ch2BankSelect,
-			in->table);
-		break;
-
-	case RGB_GAMMA_CH0_CH1_CH2_SELECTED:
-		ctrl->vfeGammaLutSel.ch0BankSelect ^= 1;
-		ctrl->vfeGammaLutSel.ch1BankSelect ^= 1;
-		ctrl->vfeGammaLutSel.ch2BankSelect ^= 1;
-		vfe_write_gamma_table(0, ctrl->vfeGammaLutSel.ch0BankSelect,
-			in->table);
-		vfe_write_gamma_table(1, ctrl->vfeGammaLutSel.ch1BankSelect,
-			in->table);
-		vfe_write_gamma_table(2, ctrl->vfeGammaLutSel.ch2BankSelect,
-			in->table);
-		break;
-
-	default:
-		pr_err("%s: invalid gamma channel %d\n", __func__,
-			in->channelSelect);
-		return -EINVAL;
-	} /* switch */
-
-	/* update the gammaLutSel register. */
-	vfe_program_lut_bank_sel(&ctrl->vfeGammaLutSel);
-
-	return rc;
-}
-
-int vfe_rgb_gamma_config(struct vfe_cmd_rgb_gamma_config *in)
-{
-	int rc = 0;
-
-	ctrl->vfeModuleEnableLocal.rgbLUTEnable = in->enable;
-
-	switch (in->channelSelect) {
-	case RGB_GAMMA_CH0_SELECTED:
-vfe_write_gamma_table(0, 0, in->table);
-break;
-
-	case RGB_GAMMA_CH1_SELECTED:
-		vfe_write_gamma_table(1, 0, in->table);
-		break;
-
-	case RGB_GAMMA_CH2_SELECTED:
-		vfe_write_gamma_table(2, 0, in->table);
-		break;
-
-	case RGB_GAMMA_CH0_CH1_SELECTED:
-		vfe_write_gamma_table(0, 0, in->table);
-		vfe_write_gamma_table(1, 0, in->table);
-		break;
-
-	case RGB_GAMMA_CH0_CH2_SELECTED:
-		vfe_write_gamma_table(0, 0, in->table);
-		vfe_write_gamma_table(2, 0, in->table);
-		break;
-
-	case RGB_GAMMA_CH1_CH2_SELECTED:
-		vfe_write_gamma_table(1, 0, in->table);
-		vfe_write_gamma_table(2, 0, in->table);
-		break;
-
-	case RGB_GAMMA_CH0_CH1_CH2_SELECTED:
-		vfe_write_gamma_table(0, 0, in->table);
-		vfe_write_gamma_table(1, 0, in->table);
-		vfe_write_gamma_table(2, 0, in->table);
-		break;
-
-	default:
-		pr_err("%s: invalid gamma channel %d\n", __func__,
-			in->channelSelect);
-		rc = -EINVAL;
-		break;
-	} /* switch */
-
-	return rc;
-}
-
-void vfe_stats_af_ack(struct vfe_cmd_stats_af_ack *in)
-{
-	ctrl->afStatsControl.nextFrameAddrBuf = in->nextAFOutputBufferAddr;
-	ctrl->afStatsControl.ackPending = FALSE;
-}
-
-void vfe_stats_wb_exp_ack(struct vfe_cmd_stats_wb_exp_ack *in)
-{
-	ctrl->awbStatsControl.nextFrameAddrBuf = in->nextWbExpOutputBufferAddr;
-	ctrl->awbStatsControl.ackPending = FALSE;
-}
-
-
-void vfe_output_v_ack(struct vfe_cmd_output_ack *in)
-{
-	const uint32_t *psrc;
-	uint32_t *pdest;
-	uint8_t i;
-
-	pdest = ctrl->encPath.nextFrameAddrBuf;
-
-	CDBG("video_frame_ack: ack addr = 0x%x\n", in->ybufaddr[0]);
-
-	psrc = in->ybufaddr;
-	for (i = 0; i < ctrl->encPath.fragCount; i++)
-		*pdest++ = *psrc++;
-
-	psrc = in->chromabufaddr;
-	for (i = 0; i < ctrl->encPath.fragCount; i++)
-		*pdest++ = *psrc++;
-
-	ctrl->encPath.ackPending = FALSE;
-}
-
-void vfe_output_p_ack(struct vfe_cmd_output_ack *in)
-{
-	const uint32_t *psrc;
-	uint32_t *pdest;
-	uint8_t i;
-
-	if (ctrl->axiOutputMode == VFE_AXI_OUTPUT_MODE_Output1AndOutput2) {
-		/* video mode, preview comes from output1 path */
-
-	pdest = ctrl->viewPath.nextFrameAddrBuf;
-
-	psrc = in->ybufaddr;
-	for (i = 0; i < ctrl->viewPath.fragCount; i++)
-		*pdest++ = *psrc++;
-
-	psrc = in->chromabufaddr;
-	for (i = 0; i < ctrl->viewPath.fragCount; i++)
-		*pdest++ = *psrc++;
-
-	ctrl->viewPath.ackPending = FALSE;
-
-	} else { /* preview mode, preview comes from output2 path. */
-		pdest = ctrl->encPath.nextFrameAddrBuf;
-
-		psrc = in->ybufaddr;
-		for (i = 0; i < ctrl->encPath.fragCount; i++)
-			*pdest++ = *psrc++;
-
-		psrc = in->chromabufaddr;
-		for (i = 0; i < ctrl->encPath.fragCount; i++)
-			*pdest++ = *psrc++;
-
-		ctrl->encPath.ackPending = FALSE;
-
-	}
-}
-
-void vfe_start(struct vfe_cmd_start *in)
-{
-	uint32_t  pmstatus = 0;
-	boolean rawmode;
-	uint32_t  demperiod = 0;
-	uint32_t  demeven = 0;
-	uint32_t  demodd = 0;
-
-	/* derived from other commands.  (camif config, axi output config,
-	 * etc)
-	*/
-	struct vfe_cfg hwcfg;
-	struct vfe_upsample_cfg chromupcfg;
-
-	CDBG("vfe_start operationMode = %d\n", in->operationMode);
-
-	memset(&hwcfg, 0, sizeof(hwcfg));
-	memset(&chromupcfg, 0, sizeof(chromupcfg));
-
-	switch (in->pixel) {
-	case VFE_BAYER_RGRGRG:
-		demperiod = 1;
-		demeven = 0xC9;
-		demodd = 0xAC;
-		break;
-
-	case VFE_BAYER_GRGRGR:
-		demperiod = 1;
-		demeven = 0x9C;
-		demodd = 0xCA;
-		break;
-
-	case VFE_BAYER_BGBGBG:
-		demperiod = 1;
-		demeven = 0xCA;
-		demodd = 0x9C;
-		break;
-
-	case VFE_BAYER_GBGBGB:
-		demperiod = 1;
-		demeven = 0xAC;
-		demodd = 0xC9;
-		break;
-
-	case VFE_YUV_YCbYCr:
-		demperiod = 3;
-		demeven = 0x9CAC;
-		demodd = 0x9CAC;
-		break;
-
-	case VFE_YUV_YCrYCb:
-		demperiod = 3;
-		demeven = 0xAC9C;
-		demodd = 0xAC9C;
-		break;
-
-	case VFE_YUV_CbYCrY:
-		demperiod = 3;
-		demeven = 0xC9CA;
-		demodd = 0xC9CA;
-		break;
-
-	case VFE_YUV_CrYCbY:
-		demperiod = 3;
-		demeven = 0xCAC9;
-		demodd = 0xCAC9;
-		break;
-
-	default:
-		return;
-	}
-
-	vfe_config_demux(demperiod, demeven, demodd);
-
-	vfe_program_lut_bank_sel(&ctrl->vfeGammaLutSel);
-
-	/* save variables to local. */
-	ctrl->vfeOperationMode = in->operationMode;
-	if (ctrl->vfeOperationMode == VFE_START_OPERATION_MODE_SNAPSHOT) {
-
-		update_axi_qos(MSM_AXI_QOS_SNAPSHOT);
-		/* in snapshot mode, initialize snapshot count*/
-		ctrl->vfeSnapShotCount = in->snapshotCount;
-
-		/* save the requested count, this is temporarily done, to
-		help with HJR / multishot. */
-		ctrl->vfeRequestedSnapShotCount = ctrl->vfeSnapShotCount;
-
-		CDBG("requested snapshot count = %d\n", ctrl->vfeSnapShotCount);
-
-		/* Assumption is to have the same pattern and period for both
-		paths, if both paths are used. */
-		if (ctrl->viewPath.pathEnabled) {
-			ctrl->viewPath.snapshotPendingCount = in->snapshotCount;
-
-			ctrl->vfeFrameSkipPattern =
-				ctrl->vfeFrameSkip.output1Pattern;
-			ctrl->vfeFrameSkipPeriod =
-				ctrl->vfeFrameSkip.output1Period;
-		}
-
-		if (ctrl->encPath.pathEnabled) {
-			ctrl->encPath.snapshotPendingCount = in->snapshotCount;
-
-			ctrl->vfeFrameSkipPattern =
-				ctrl->vfeFrameSkip.output2Pattern;
-			ctrl->vfeFrameSkipPeriod =
-				ctrl->vfeFrameSkip.output2Period;
-		}
-	} else
-		update_axi_qos(MSM_AXI_QOS_PREVIEW);
-
-	/* enable color conversion for bayer sensor
-	if stats enabled, need to do color conversion. */
-	if (in->pixel <= VFE_BAYER_GBGBGB)
-		ctrl->vfeStatsCmdLocal.colorConversionEnable = TRUE;
-
-	vfe_program_stats_cmd(&ctrl->vfeStatsCmdLocal);
-
-	if (in->pixel >= VFE_YUV_YCbYCr)
-		ctrl->vfeModuleEnableLocal.chromaUpsampleEnable = TRUE;
-
-	ctrl->vfeModuleEnableLocal.demuxEnable = TRUE;
-
-	/* if any stats module is enabled, the main bit is enabled. */
-	ctrl->vfeModuleEnableLocal.statsEnable =
-		ctrl->vfeStatsCmdLocal.autoFocusEnable |
-		ctrl->vfeStatsCmdLocal.axwEnable;
-
-	vfe_reg_module_cfg(&ctrl->vfeModuleEnableLocal);
-
-	/* in case of offline processing, do not need to config camif. Having
-	 * bus output enabled in camif_config register might confuse the
-	 * hardware?
-	 */
-	if (in->inputSource != VFE_START_INPUT_SOURCE_AXI) {
-		vfe_reg_camif_config(&ctrl->vfeCamifConfigLocal);
-	} else {
-		/* offline processing, enable axi read */
-		ctrl->vfeBusConfigLocal.stripeRdPathEn = TRUE;
-		ctrl->vfeBusCmdLocal.stripeReload = TRUE;
-		ctrl->vfeBusConfigLocal.rawPixelDataSize =
-			ctrl->axiInputDataSize;
-	}
-
-	vfe_reg_bus_cfg(&ctrl->vfeBusConfigLocal);
-
-	/* directly from start command */
-	hwcfg.pixelPattern = in->pixel;
-	hwcfg.inputSource = in->inputSource;
-	writel(*(uint32_t *)&hwcfg, ctrl->vfebase + VFE_CFG);
-
-	/* regardless module enabled or not, it does not hurt
-	 * to program the cositing mode. */
-	chromupcfg.chromaCositingForYCbCrInputs = in->yuvInputCositingMode;
-
-	writel(*(uint32_t *)&chromupcfg,
-		ctrl->vfebase + VFE_CHROMA_UPSAMPLE_CFG);
-
-	/* MISR to monitor the axi read. */
-	writel(0xd8, ctrl->vfebase + VFE_BUS_MISR_MAST_CFG_0);
-
-	/* clear all pending interrupts. */
-	writel(VFE_CLEAR_ALL_IRQS, ctrl->vfebase + VFE_IRQ_CLEAR);
-
-	/*  define how composite interrupt work.  */
-	ctrl->vfeImaskCompositePacked =
-		vfe_irq_composite_pack(ctrl->vfeIrqCompositeMaskLocal);
-
-	vfe_program_irq_composite_mask(ctrl->vfeImaskCompositePacked);
-
-	/*  enable all necessary interrupts.      */
-	ctrl->vfeImaskLocal.camifSofIrq  = TRUE;
-	ctrl->vfeImaskLocal.regUpdateIrq = TRUE;
-	ctrl->vfeImaskLocal.resetAckIrq  = TRUE;
-
-	ctrl->vfeImaskPacked = vfe_irq_pack(ctrl->vfeImaskLocal);
-	vfe_program_irq_mask(ctrl->vfeImaskPacked);
-
-	/* enable bus performance monitor */
-	vfe_8k_pm_start(&ctrl->vfeBusPmConfigLocal);
-
-	/* trigger vfe reg update */
-	ctrl->vfeStartAckPendingFlag = TRUE;
-
-	/* write bus command to trigger reload of ping pong buffer. */
-	ctrl->vfeBusCmdLocal.busPingpongReload = TRUE;
-
-	if (ctrl->vfeModuleEnableLocal.statsEnable == TRUE) {
-		ctrl->vfeBusCmdLocal.statsPingpongReload = TRUE;
-		ctrl->vfeStatsPingPongReloadFlag = TRUE;
-	}
-
-	writel(VFE_REG_UPDATE_TRIGGER, ctrl->vfebase + VFE_REG_UPDATE_CMD);
-
-	/* program later than the reg update. */
-	vfe_reg_bus_cmd(&ctrl->vfeBusCmdLocal);
-
-	if ((in->inputSource ==
-			 VFE_START_INPUT_SOURCE_CAMIF) ||
-	    (in->inputSource == VFE_START_INPUT_SOURCE_TESTGEN))
-		writel(CAMIF_COMMAND_START, ctrl->vfebase + CAMIF_COMMAND);
-
-	/* start test gen if it is enabled */
-	if (ctrl->vfeTestGenStartFlag == TRUE) {
-		ctrl->vfeTestGenStartFlag = FALSE;
-		vfe_prog_hw_testgen_cmd(VFE_TEST_GEN_GO);
-	}
-
-	CDBG("ctrl->axiOutputMode = %d\n", ctrl->axiOutputMode);
-	if (ctrl->axiOutputMode == VFE_AXI_OUTPUT_MODE_CAMIFToAXIViaOutput2) {
-		/* raw dump mode */
-		rawmode = TRUE;
-
-		while (rawmode) {
-			pmstatus =
-				readl(ctrl->vfebase +
-					VFE_BUS_ENC_CBCR_WR_PM_STATS_1);
-
-			if ((pmstatus & VFE_PM_BUF_MAX_CNT_MASK) != 0)
-				rawmode = FALSE;
-		}
-
-		vfe_proc_ops(VFE_MSG_ID_START_ACK, NULL);
-		ctrl->vfeStartAckPendingFlag = FALSE;
-	}
-
-	ctrl->vstate = VFE_STATE_ACTIVE;
-}
-
-void vfe_la_update(struct vfe_cmd_la_config *in)
-{
-	int16_t *pTable;
-	enum VFE_DMI_RAM_SEL dmiRamSel;
-	int i;
-
-	pTable = in->table;
-	ctrl->vfeModuleEnableLocal.lumaAdaptationEnable = in->enable;
-
-	/* toggle the bank to be used. */
-	ctrl->vfeLaBankSel ^= 1;
-
-	if (ctrl->vfeLaBankSel == 0)
-		dmiRamSel = LUMA_ADAPT_LUT_RAM_BANK0;
-	else
-		dmiRamSel = LUMA_ADAPT_LUT_RAM_BANK1;
-
-	/* configure the DMI_CFG to select right sram */
-	vfe_program_dmi_cfg(dmiRamSel);
-
-	for (i = 0; i < VFE_LA_TABLE_LENGTH; i++) {
-		writel((uint32_t)(*pTable), ctrl->vfebase + VFE_DMI_DATA_LO);
-		pTable++;
-	}
-
-	/* After DMI transfer, to make it safe, need to set
-	 * the DMI_CFG to unselect any SRAM */
-	writel(VFE_DMI_CFG_DEFAULT, ctrl->vfebase + VFE_DMI_CFG);
-	writel(ctrl->vfeLaBankSel, ctrl->vfebase + VFE_LA_CFG);
-}
-
-void vfe_la_config(struct vfe_cmd_la_config *in)
-{
-	uint16_t i;
-	int16_t  *pTable;
-	enum VFE_DMI_RAM_SEL dmiRamSel;
-
-	pTable = in->table;
-	ctrl->vfeModuleEnableLocal.lumaAdaptationEnable = in->enable;
-
-	if (ctrl->vfeLaBankSel == 0)
-		dmiRamSel = LUMA_ADAPT_LUT_RAM_BANK0;
-	else
-		dmiRamSel = LUMA_ADAPT_LUT_RAM_BANK1;
-
-	/* configure the DMI_CFG to select right sram */
-	vfe_program_dmi_cfg(dmiRamSel);
-
-	for (i = 0; i < VFE_LA_TABLE_LENGTH; i++) {
-		writel((uint32_t)(*pTable), ctrl->vfebase + VFE_DMI_DATA_LO);
-		pTable++;
-	}
-
-	/* After DMI transfer, to make it safe, need to set the
-	 * DMI_CFG to unselect any SRAM */
-	writel(VFE_DMI_CFG_DEFAULT, ctrl->vfebase + VFE_DMI_CFG);
-
-	/* can only be bank 0 or bank 1 for now. */
-	writel(ctrl->vfeLaBankSel, ctrl->vfebase + VFE_LA_CFG);
-	CDBG("VFE Luma adaptation bank selection is 0x%x\n",
-			 *(uint32_t *)&ctrl->vfeLaBankSel);
-}
-
-void vfe_test_gen_start(struct vfe_cmd_test_gen_start *in)
-{
-	struct VFE_TestGen_ConfigCmdType cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-
-	cmd.numFrame              = in->numFrame;
-	cmd.pixelDataSelect       = in->pixelDataSelect;
-	cmd.systematicDataSelect  = in->systematicDataSelect;
-	cmd.pixelDataSize         = (uint32_t)in->pixelDataSize;
-	cmd.hsyncEdge             = (uint32_t)in->hsyncEdge;
-	cmd.vsyncEdge             = (uint32_t)in->vsyncEdge;
-	cmd.imageWidth            = in->imageWidth;
-	cmd.imageHeight           = in->imageHeight;
-	cmd.sofOffset             = in->startOfFrameOffset;
-	cmd.eofNOffset            = in->endOfFrameNOffset;
-	cmd.solOffset             = in->startOfLineOffset;
-	cmd.eolNOffset            = in->endOfLineNOffset;
-	cmd.hBlankInterval        = in->hbi;
-	cmd.vBlankInterval        = in->vbl;
-	cmd.vBlankIntervalEnable  = in->vblEnable;
-	cmd.sofDummy              = in->startOfFrameDummyLine;
-	cmd.eofDummy              = in->endOfFrameDummyLine;
-	cmd.unicolorBarSelect     = in->unicolorBarSelect;
-	cmd.unicolorBarEnable     = in->unicolorBarEnable;
-	cmd.splitEnable           = in->colorBarsSplitEnable;
-	cmd.pixelPattern          = (uint32_t)in->colorBarsPixelPattern;
-	cmd.rotatePeriod          = in->colorBarsRotatePeriod;
-	cmd.randomSeed            = in->testGenRandomSeed;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_HW_TESTGEN_CFG,
-		(uint32_t *) &cmd, sizeof(cmd));
-}
-
-void vfe_frame_skip_update(struct vfe_cmd_frame_skip_update *in)
-{
-	struct VFE_FRAME_SKIP_UpdateCmdType cmd;
-
-	cmd.yPattern    = in->output1Pattern;
-	cmd.cbcrPattern = in->output1Pattern;
-	vfe_prog_hw(ctrl->vfebase + VFE_FRAMEDROP_VIEW_Y_PATTERN,
-		(uint32_t *)&cmd, sizeof(cmd));
-
-	cmd.yPattern    = in->output2Pattern;
-	cmd.cbcrPattern = in->output2Pattern;
-	vfe_prog_hw(ctrl->vfebase + VFE_FRAMEDROP_ENC_Y_PATTERN,
-		(uint32_t *)&cmd, sizeof(cmd));
-}
-
-void vfe_frame_skip_config(struct vfe_cmd_frame_skip_config *in)
-{
-	struct vfe_frame_skip_cfg cmd;
-	memset(&cmd, 0, sizeof(cmd));
-
-	ctrl->vfeFrameSkip = *in;
-
-	cmd.output2YPeriod     = in->output2Period;
-	cmd.output2CbCrPeriod  = in->output2Period;
-	cmd.output2YPattern    = in->output2Pattern;
-	cmd.output2CbCrPattern = in->output2Pattern;
-	cmd.output1YPeriod     = in->output1Period;
-	cmd.output1CbCrPeriod  = in->output1Period;
-	cmd.output1YPattern    = in->output1Pattern;
-	cmd.output1CbCrPattern = in->output1Pattern;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_FRAMEDROP_ENC_Y_CFG,
-		(uint32_t *)&cmd, sizeof(cmd));
-}
-
-void vfe_output_clamp_config(struct vfe_cmd_output_clamp_config *in)
-{
-	struct vfe_output_clamp_cfg cmd;
-	memset(&cmd, 0, sizeof(cmd));
-
-	cmd.yChanMax  = in->maxCh0;
-	cmd.cbChanMax = in->maxCh1;
-	cmd.crChanMax = in->maxCh2;
-
-	cmd.yChanMin  = in->minCh0;
-	cmd.cbChanMin = in->minCh1;
-	cmd.crChanMin = in->minCh2;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_CLAMP_MAX_CFG, (uint32_t *)&cmd,
-		sizeof(cmd));
-}
-
-void vfe_camif_frame_update(struct vfe_cmds_camif_frame *in)
-{
-	struct vfe_camifframe_update cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-
-	cmd.pixelsPerLine = in->pixelsPerLine;
-	cmd.linesPerFrame = in->linesPerFrame;
-
-	vfe_prog_hw(ctrl->vfebase + CAMIF_FRAME_CONFIG, (uint32_t *)&cmd,
-		sizeof(cmd));
-}
-
-void vfe_color_correction_config(struct vfe_cmd_color_correction_config *in)
-{
-	struct vfe_color_correction_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	ctrl->vfeModuleEnableLocal.colorCorrectionEnable = in->enable;
-
-	cmd.c0 = in->C0;
-	cmd.c1 = in->C1;
-	cmd.c2 = in->C2;
-	cmd.c3 = in->C3;
-	cmd.c4 = in->C4;
-	cmd.c5 = in->C5;
-	cmd.c6 = in->C6;
-	cmd.c7 = in->C7;
-	cmd.c8 = in->C8;
-
-	cmd.k0 = in->K0;
-	cmd.k1 = in->K1;
-	cmd.k2 = in->K2;
-
-	cmd.coefQFactor = in->coefQFactor;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_COLOR_CORRECT_COEFF_0,
-		(uint32_t *)&cmd, sizeof(cmd));
-}
-
-void vfe_demosaic_abf_update(struct vfe_cmd_demosaic_abf_update *in)
-{
-struct vfe_demosaic_cfg cmd;
-	struct vfe_demosaic_abf_cfg cmdabf;
-	uint32_t temp;
-
-	memset(&cmd, 0, sizeof(cmd));
-	temp = readl(ctrl->vfebase + VFE_DEMOSAIC_CFG);
-
-	cmd = *((struct vfe_demosaic_cfg *)(&temp));
-	cmd.abfEnable       = in->abfUpdate.enable;
-	cmd.forceAbfOn      = in->abfUpdate.forceOn;
-	cmd.abfShift        = in->abfUpdate.shift;
-	vfe_prog_hw(ctrl->vfebase + VFE_DEMOSAIC_CFG,
-		(uint32_t *)&cmd, sizeof(cmd));
-
-	cmdabf.lpThreshold  = in->abfUpdate.lpThreshold;
-	cmdabf.ratio        = in->abfUpdate.ratio;
-	cmdabf.minValue     = in->abfUpdate.min;
-	cmdabf.maxValue     = in->abfUpdate.max;
-	vfe_prog_hw(ctrl->vfebase + VFE_DEMOSAIC_ABF_CFG_0,
-		(uint32_t *)&cmdabf, sizeof(cmdabf));
-}
-
-void vfe_demosaic_bpc_update(struct vfe_cmd_demosaic_bpc_update *in)
-{
-	struct vfe_demosaic_cfg cmd;
-	struct vfe_demosaic_bpc_cfg cmdbpc;
-	uint32_t temp;
-
-	memset(&cmd, 0, sizeof(cmd));
-
-	temp = readl(ctrl->vfebase + VFE_DEMOSAIC_CFG);
-
-	cmd = *((struct vfe_demosaic_cfg *)(&temp));
-	cmd.badPixelCorrEnable = in->bpcUpdate.enable;
-	cmd.fminThreshold      = in->bpcUpdate.fminThreshold;
-	cmd.fmaxThreshold      = in->bpcUpdate.fmaxThreshold;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_DEMOSAIC_CFG,
-		(uint32_t *)&cmd, sizeof(cmd));
-
-	cmdbpc.blueDiffThreshold  = in->bpcUpdate.blueDiffThreshold;
-	cmdbpc.redDiffThreshold   = in->bpcUpdate.redDiffThreshold;
-	cmdbpc.greenDiffThreshold = in->bpcUpdate.greenDiffThreshold;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_DEMOSAIC_BPC_CFG_0,
-		(uint32_t *)&cmdbpc, sizeof(cmdbpc));
-}
-
-void vfe_demosaic_config(struct vfe_cmd_demosaic_config *in)
-{
-	struct vfe_demosaic_cfg cmd;
-	struct vfe_demosaic_bpc_cfg cmd_bpc;
-	struct vfe_demosaic_abf_cfg cmd_abf;
-
-	memset(&cmd, 0, sizeof(cmd));
-	memset(&cmd_bpc, 0, sizeof(cmd_bpc));
-	memset(&cmd_abf, 0, sizeof(cmd_abf));
-
-	ctrl->vfeModuleEnableLocal.demosaicEnable = in->enable;
-
-	cmd.abfEnable          = in->abfConfig.enable;
-	cmd.badPixelCorrEnable = in->bpcConfig.enable;
-	cmd.forceAbfOn         = in->abfConfig.forceOn;
-	cmd.abfShift           = in->abfConfig.shift;
-	cmd.fminThreshold      = in->bpcConfig.fminThreshold;
-	cmd.fmaxThreshold      = in->bpcConfig.fmaxThreshold;
-	cmd.slopeShift         = in->slopeShift;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_DEMOSAIC_CFG,
-		(uint32_t *)&cmd, sizeof(cmd));
-
-	cmd_abf.lpThreshold = in->abfConfig.lpThreshold;
-	cmd_abf.ratio       = in->abfConfig.ratio;
-	cmd_abf.minValue    = in->abfConfig.min;
-	cmd_abf.maxValue    = in->abfConfig.max;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_DEMOSAIC_ABF_CFG_0,
-		(uint32_t *)&cmd_abf, sizeof(cmd_abf));
-
-	cmd_bpc.blueDiffThreshold   = in->bpcConfig.blueDiffThreshold;
-	cmd_bpc.redDiffThreshold    = in->bpcConfig.redDiffThreshold;
-	cmd_bpc.greenDiffThreshold  = in->bpcConfig.greenDiffThreshold;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_DEMOSAIC_BPC_CFG_0,
-		(uint32_t *)&cmd_bpc, sizeof(cmd_bpc));
-}
-
-void vfe_demux_channel_gain_update(struct vfe_cmd_demux_channel_gain_config *in)
-{
-	struct vfe_demux_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-
-	cmd.ch0EvenGain  = in->ch0EvenGain;
-	cmd.ch0OddGain   = in->ch0OddGain;
-	cmd.ch1Gain      = in->ch1Gain;
-	cmd.ch2Gain      = in->ch2Gain;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_DEMUX_GAIN_0,
-		(uint32_t *)&cmd, sizeof(cmd));
-}
-
-void vfe_demux_channel_gain_config(struct vfe_cmd_demux_channel_gain_config *in)
-{
-	struct vfe_demux_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-
-	cmd.ch0EvenGain = in->ch0EvenGain;
-	cmd.ch0OddGain  = in->ch0OddGain;
-	cmd.ch1Gain     = in->ch1Gain;
-	cmd.ch2Gain     = in->ch2Gain;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_DEMUX_GAIN_0,
-		(uint32_t *)&cmd, sizeof(cmd));
-}
-
-void vfe_black_level_update(struct vfe_cmd_black_level_config *in)
-{
-	struct vfe_blacklevel_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-	ctrl->vfeModuleEnableLocal.blackLevelCorrectionEnable = in->enable;
-
-	cmd.evenEvenAdjustment = in->evenEvenAdjustment;
-	cmd.evenOddAdjustment  = in->evenOddAdjustment;
-	cmd.oddEvenAdjustment  = in->oddEvenAdjustment;
-	cmd.oddOddAdjustment   = in->oddOddAdjustment;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_BLACK_EVEN_EVEN_VALUE,
-		(uint32_t *)&cmd, sizeof(cmd));
-}
-
-void vfe_black_level_config(struct vfe_cmd_black_level_config *in)
-{
-	struct vfe_blacklevel_cfg cmd;
-	memset(&cmd, 0, sizeof(cmd));
-
-	ctrl->vfeModuleEnableLocal.blackLevelCorrectionEnable = in->enable;
-
-	cmd.evenEvenAdjustment = in->evenEvenAdjustment;
-	cmd.evenOddAdjustment  = in->evenOddAdjustment;
-	cmd.oddEvenAdjustment  = in->oddEvenAdjustment;
-	cmd.oddOddAdjustment   = in->oddOddAdjustment;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_BLACK_EVEN_EVEN_VALUE,
-		(uint32_t *)&cmd, sizeof(cmd));
-}
-
-void vfe_asf_update(struct vfe_cmd_asf_update *in)
-{
-	struct vfe_asf_update cmd;
-	memset(&cmd, 0, sizeof(cmd));
-
-	ctrl->vfeModuleEnableLocal.asfEnable = in->enable;
-
-	cmd.smoothEnable     = in->smoothFilterEnabled;
-	cmd.sharpMode        = in->sharpMode;
-	cmd.smoothCoeff0     = in->smoothCoefCenter;
-	cmd.smoothCoeff1     = in->smoothCoefSurr;
-	cmd.cropEnable       = in->cropEnable;
-	cmd.sharpThresholdE1 = in->sharpThreshE1;
-	cmd.sharpDegreeK1    = in->sharpK1;
-	cmd.sharpDegreeK2    = in->sharpK2;
-	cmd.normalizeFactor  = in->normalizeFactor;
-	cmd.sharpThresholdE2 = in->sharpThreshE2;
-	cmd.sharpThresholdE3 = in->sharpThreshE3;
-	cmd.sharpThresholdE4 = in->sharpThreshE4;
-	cmd.sharpThresholdE5 = in->sharpThreshE5;
-	cmd.F1Coeff0         = in->filter1Coefficients[0];
-	cmd.F1Coeff1         = in->filter1Coefficients[1];
-	cmd.F1Coeff2         = in->filter1Coefficients[2];
-	cmd.F1Coeff3         = in->filter1Coefficients[3];
-	cmd.F1Coeff4         = in->filter1Coefficients[4];
-	cmd.F1Coeff5         = in->filter1Coefficients[5];
-	cmd.F1Coeff6         = in->filter1Coefficients[6];
-	cmd.F1Coeff7         = in->filter1Coefficients[7];
-	cmd.F1Coeff8         = in->filter1Coefficients[8];
-	cmd.F2Coeff0         = in->filter2Coefficients[0];
-	cmd.F2Coeff1         = in->filter2Coefficients[1];
-	cmd.F2Coeff2         = in->filter2Coefficients[2];
-	cmd.F2Coeff3         = in->filter2Coefficients[3];
-	cmd.F2Coeff4         = in->filter2Coefficients[4];
-	cmd.F2Coeff5         = in->filter2Coefficients[5];
-	cmd.F2Coeff6         = in->filter2Coefficients[6];
-	cmd.F2Coeff7         = in->filter2Coefficients[7];
-	cmd.F2Coeff8         = in->filter2Coefficients[8];
-
-	vfe_prog_hw(ctrl->vfebase + VFE_ASF_CFG,
-		(uint32_t *)&cmd, sizeof(cmd));
-}
-
-void vfe_asf_config(struct vfe_cmd_asf_config *in)
-{
-	struct vfe_asf_update     cmd;
-	struct vfe_asfcrop_cfg cmd2;
-
-	memset(&cmd, 0, sizeof(cmd));
-	memset(&cmd2, 0, sizeof(cmd2));
-
-	ctrl->vfeModuleEnableLocal.asfEnable = in->enable;
-
-	cmd.smoothEnable       = in->smoothFilterEnabled;
-	cmd.sharpMode          = in->sharpMode;
-	cmd.smoothCoeff0       = in->smoothCoefCenter;
-	cmd.smoothCoeff1       = in->smoothCoefSurr;
-	cmd.cropEnable         = in->cropEnable;
-	cmd.sharpThresholdE1   = in->sharpThreshE1;
-	cmd.sharpDegreeK1      = in->sharpK1;
-	cmd.sharpDegreeK2      = in->sharpK2;
-	cmd.normalizeFactor    = in->normalizeFactor;
-	cmd.sharpThresholdE2   = in->sharpThreshE2;
-	cmd.sharpThresholdE3   = in->sharpThreshE3;
-	cmd.sharpThresholdE4   = in->sharpThreshE4;
-	cmd.sharpThresholdE5   = in->sharpThreshE5;
-	cmd.F1Coeff0           = in->filter1Coefficients[0];
-	cmd.F1Coeff1           = in->filter1Coefficients[1];
-	cmd.F1Coeff2           = in->filter1Coefficients[2];
-	cmd.F1Coeff3           = in->filter1Coefficients[3];
-	cmd.F1Coeff4           = in->filter1Coefficients[4];
-	cmd.F1Coeff5           = in->filter1Coefficients[5];
-	cmd.F1Coeff6           = in->filter1Coefficients[6];
-	cmd.F1Coeff7           = in->filter1Coefficients[7];
-	cmd.F1Coeff8           = in->filter1Coefficients[8];
-	cmd.F2Coeff0           = in->filter2Coefficients[0];
-	cmd.F2Coeff1           = in->filter2Coefficients[1];
-	cmd.F2Coeff2           = in->filter2Coefficients[2];
-	cmd.F2Coeff3           = in->filter2Coefficients[3];
-	cmd.F2Coeff4           = in->filter2Coefficients[4];
-	cmd.F2Coeff5           = in->filter2Coefficients[5];
-	cmd.F2Coeff6           = in->filter2Coefficients[6];
-	cmd.F2Coeff7           = in->filter2Coefficients[7];
-	cmd.F2Coeff8           = in->filter2Coefficients[8];
-
-	vfe_prog_hw(ctrl->vfebase + VFE_ASF_CFG,
-		(uint32_t *)&cmd, sizeof(cmd));
-
-	cmd2.firstLine  = in->cropFirstLine;
-	cmd2.lastLine   = in->cropLastLine;
-	cmd2.firstPixel = in->cropFirstPixel;
-	cmd2.lastPixel  = in->cropLastPixel;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_ASF_CROP_WIDTH_CFG,
-		(uint32_t *)&cmd2, sizeof(cmd2));
-}
-
-void vfe_white_balance_config(struct vfe_cmd_white_balance_config *in)
-{
-	struct vfe_wb_cfg cmd;
-	memset(&cmd, 0, sizeof(cmd));
-
-	ctrl->vfeModuleEnableLocal.whiteBalanceEnable = in->enable;
-
-	cmd.ch0Gain = in->ch0Gain;
-	cmd.ch1Gain = in->ch1Gain;
-	cmd.ch2Gain = in->ch2Gain;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_WB_CFG,
-		(uint32_t *)&cmd, sizeof(cmd));
-}
-
-void vfe_chroma_sup_config(struct vfe_cmd_chroma_suppression_config *in)
-{
-	struct vfe_chroma_suppress_cfg cmd;
-	memset(&cmd, 0, sizeof(cmd));
-
-	ctrl->vfeModuleEnableLocal.chromaSuppressionEnable = in->enable;
-
-	cmd.m1  = in->m1;
-	cmd.m3  = in->m3;
-	cmd.n1  = in->n1;
-	cmd.n3  = in->n3;
-	cmd.mm1 = in->mm1;
-	cmd.nn1 = in->nn1;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_CHROMA_SUPPRESS_CFG_0,
-		(uint32_t *)&cmd, sizeof(cmd));
-}
-
-void vfe_roll_off_config(struct vfe_cmd_roll_off_config *in)
-{
-	struct vfe_rolloff_cfg cmd;
-	memset(&cmd, 0, sizeof(cmd));
-
-	ctrl->vfeModuleEnableLocal.lensRollOffEnable = in->enable;
-
-	cmd.gridWidth   = in->gridWidth;
-	cmd.gridHeight  = in->gridHeight;
-	cmd.yDelta      = in->yDelta;
-	cmd.gridX       = in->gridXIndex;
-	cmd.gridY       = in->gridYIndex;
-	cmd.pixelX      = in->gridPixelXIndex;
-	cmd.pixelY      = in->gridPixelYIndex;
-	cmd.yDeltaAccum = in->yDeltaAccum;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_ROLLOFF_CFG_0,
-		(uint32_t *)&cmd, sizeof(cmd));
-
-	vfe_write_lens_roll_off_table(in);
-}
-
-void vfe_chroma_subsample_config(struct vfe_cmd_chroma_subsample_config *in)
-{
-	struct vfe_chromasubsample_cfg cmd;
-	memset(&cmd, 0, sizeof(cmd));
-
-	ctrl->vfeModuleEnableLocal.chromaSubsampleEnable = in->enable;
-
-	cmd.hCositedPhase       = in->hCositedPhase;
-	cmd.vCositedPhase       = in->vCositedPhase;
-	cmd.hCosited            = in->hCosited;
-	cmd.vCosited            = in->vCosited;
-	cmd.hsubSampleEnable    = in->hsubSampleEnable;
-	cmd.vsubSampleEnable    = in->vsubSampleEnable;
-	cmd.cropEnable          = in->cropEnable;
-	cmd.cropWidthLastPixel  = in->cropWidthLastPixel;
-	cmd.cropWidthFirstPixel = in->cropWidthFirstPixel;
-	cmd.cropHeightLastLine  = in->cropHeightLastLine;
-	cmd.cropHeightFirstLine = in->cropHeightFirstLine;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_CHROMA_SUBSAMPLE_CFG,
-		(uint32_t *)&cmd, sizeof(cmd));
-}
-
-void vfe_chroma_enhan_config(struct vfe_cmd_chroma_enhan_config *in)
-{
-	struct vfe_chroma_enhance_cfg cmd;
-	struct vfe_color_convert_cfg cmd2;
-
-	memset(&cmd, 0, sizeof(cmd));
-	memset(&cmd2, 0, sizeof(cmd2));
-
-	ctrl->vfeModuleEnableLocal.chromaEnhanEnable = in->enable;
-
-	cmd.ap             = in->ap;
-	cmd.am             = in->am;
-	cmd.bp             = in->bp;
-	cmd.bm             = in->bm;
-	cmd.cp             = in->cp;
-	cmd.cm             = in->cm;
-	cmd.dp             = in->dp;
-	cmd.dm             = in->dm;
-	cmd.kcb            = in->kcb;
-	cmd.kcr            = in->kcr;
-
-	cmd2.v0            = in->RGBtoYConversionV0;
-	cmd2.v1            = in->RGBtoYConversionV1;
-	cmd2.v2            = in->RGBtoYConversionV2;
-	cmd2.ConvertOffset = in->RGBtoYConversionOffset;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_CHROMA_ENHAN_A,
-		(uint32_t *)&cmd, sizeof(cmd));
-
-	vfe_prog_hw(ctrl->vfebase + VFE_COLOR_CONVERT_COEFF_0,
-		(uint32_t *)&cmd2, sizeof(cmd2));
-}
-
-void vfe_scaler2cbcr_config(struct vfe_cmd_scaler2_config *in)
-{
-	struct vfe_scaler2_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-
-	ctrl->vfeModuleEnableLocal.scaler2CbcrEnable = in->enable;
-
-	cmd.hEnable              = in->hconfig.enable;
-	cmd.vEnable              = in->vconfig.enable;
-	cmd.inWidth              = in->hconfig.inputSize;
-	cmd.outWidth             = in->hconfig.outputSize;
-	cmd.horizPhaseMult       = in->hconfig.phaseMultiplicationFactor;
-	cmd.horizInterResolution = in->hconfig.interpolationResolution;
-	cmd.inHeight             = in->vconfig.inputSize;
-	cmd.outHeight            = in->vconfig.outputSize;
-	cmd.vertPhaseMult        = in->vconfig.phaseMultiplicationFactor;
-	cmd.vertInterResolution  = in->vconfig.interpolationResolution;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_SCALE_CBCR_CFG,
-		(uint32_t *)&cmd, sizeof(cmd));
-}
-
-void vfe_scaler2y_config(struct vfe_cmd_scaler2_config *in)
-{
-	struct vfe_scaler2_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-
-	ctrl->vfeModuleEnableLocal.scaler2YEnable = in->enable;
-
-	cmd.hEnable               = in->hconfig.enable;
-	cmd.vEnable               = in->vconfig.enable;
-	cmd.inWidth               = in->hconfig.inputSize;
-	cmd.outWidth              = in->hconfig.outputSize;
-	cmd.horizPhaseMult        = in->hconfig.phaseMultiplicationFactor;
-	cmd.horizInterResolution  = in->hconfig.interpolationResolution;
-	cmd.inHeight              = in->vconfig.inputSize;
-	cmd.outHeight             = in->vconfig.outputSize;
-	cmd.vertPhaseMult         = in->vconfig.phaseMultiplicationFactor;
-	cmd.vertInterResolution   = in->vconfig.interpolationResolution;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_SCALE_Y_CFG,
-		(uint32_t *)&cmd, sizeof(cmd));
-}
-
-void vfe_main_scaler_config(struct vfe_cmd_main_scaler_config *in)
-{
-	struct vfe_main_scaler_cfg cmd;
-
-	memset(&cmd, 0, sizeof(cmd));
-
-	ctrl->vfeModuleEnableLocal.mainScalerEnable = in->enable;
-
-	cmd.hEnable              = in->hconfig.enable;
-	cmd.vEnable              = in->vconfig.enable;
-	cmd.inWidth              = in->hconfig.inputSize;
-	cmd.outWidth             = in->hconfig.outputSize;
-	cmd.horizPhaseMult       = in->hconfig.phaseMultiplicationFactor;
-	cmd.horizInterResolution = in->hconfig.interpolationResolution;
-	cmd.horizMNInit          = in->MNInitH.MNCounterInit;
-	cmd.horizPhaseInit       = in->MNInitH.phaseInit;
-	cmd.inHeight             = in->vconfig.inputSize;
-	cmd.outHeight            = in->vconfig.outputSize;
-	cmd.vertPhaseMult        = in->vconfig.phaseMultiplicationFactor;
-	cmd.vertInterResolution  = in->vconfig.interpolationResolution;
-	cmd.vertMNInit           = in->MNInitV.MNCounterInit;
-	cmd.vertPhaseInit        = in->MNInitV.phaseInit;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_SCALE_CFG,
-		(uint32_t *)&cmd, sizeof(cmd));
-}
-
-void vfe_stats_wb_exp_stop(void)
-{
-	ctrl->vfeStatsCmdLocal.axwEnable = FALSE;
-	ctrl->vfeImaskLocal.awbPingpongIrq = FALSE;
-}
-
-void vfe_stats_update_wb_exp(struct vfe_cmd_stats_wb_exp_update *in)
-{
-	struct vfe_statsawb_update   cmd;
-	struct vfe_statsawbae_update cmd2;
-
-	memset(&cmd, 0, sizeof(cmd));
-	memset(&cmd2, 0, sizeof(cmd2));
-
-	cmd.m1  = in->awbMCFG[0];
-	cmd.m2  = in->awbMCFG[1];
-	cmd.m3  = in->awbMCFG[2];
-	cmd.m4  = in->awbMCFG[3];
-	cmd.c1  = in->awbCCFG[0];
-	cmd.c2  = in->awbCCFG[1];
-	cmd.c3  = in->awbCCFG[2];
-	cmd.c4  = in->awbCCFG[3];
-	vfe_prog_hw(ctrl->vfebase + VFE_STATS_AWB_MCFG,
-		(uint32_t *)&cmd, sizeof(cmd));
-
-	cmd2.aeRegionCfg    = in->wbExpRegions;
-	cmd2.aeSubregionCfg = in->wbExpSubRegion;
-	cmd2.awbYMin        = in->awbYMin;
-	cmd2.awbYMax        = in->awbYMax;
-	vfe_prog_hw(ctrl->vfebase + VFE_STATS_AWBAE_CFG,
-		(uint32_t *)&cmd2, sizeof(cmd2));
-}
-
-void vfe_stats_update_af(struct vfe_cmd_stats_af_update *in)
-{
-	struct vfe_statsaf_update cmd;
-	memset(&cmd, 0, sizeof(cmd));
-
-	cmd.windowVOffset = in->windowVOffset;
-	cmd.windowHOffset = in->windowHOffset;
-	cmd.windowMode    = in->windowMode;
-	cmd.windowHeight  = in->windowHeight;
-	cmd.windowWidth   = in->windowWidth;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_STATS_AF_CFG,
-		(uint32_t *)&cmd, sizeof(cmd));
-}
-
-void vfe_stats_start_wb_exp(struct vfe_cmd_stats_wb_exp_start *in)
-{
-	struct vfe_statsawb_update   cmd;
-	struct vfe_statsawbae_update cmd2;
-	struct vfe_statsaxw_hdr_cfg  cmd3;
-
-	ctrl->vfeStatsCmdLocal.axwEnable   =  in->enable;
-	ctrl->vfeImaskLocal.awbPingpongIrq = TRUE;
-
-	memset(&cmd, 0, sizeof(cmd));
-	memset(&cmd2, 0, sizeof(cmd2));
-	memset(&cmd3, 0, sizeof(cmd3));
-
-	cmd.m1  = in->awbMCFG[0];
-	cmd.m2  = in->awbMCFG[1];
-	cmd.m3  = in->awbMCFG[2];
-	cmd.m4  = in->awbMCFG[3];
-	cmd.c1  = in->awbCCFG[0];
-	cmd.c2  = in->awbCCFG[1];
-	cmd.c3  = in->awbCCFG[2];
-	cmd.c4  = in->awbCCFG[3];
-	vfe_prog_hw(ctrl->vfebase + VFE_STATS_AWB_MCFG,
-		(uint32_t *)&cmd, sizeof(cmd));
-
-	cmd2.aeRegionCfg     = in->wbExpRegions;
-	cmd2.aeSubregionCfg  = in->wbExpSubRegion;
-	cmd2.awbYMin         = in->awbYMin;
-	cmd2.awbYMax         = in->awbYMax;
-	vfe_prog_hw(ctrl->vfebase + VFE_STATS_AWBAE_CFG,
-		(uint32_t *)&cmd2, sizeof(cmd2));
-
-	cmd3.axwHeader       = in->axwHeader;
-	vfe_prog_hw(ctrl->vfebase + VFE_STATS_AXW_HEADER,
-		(uint32_t *)&cmd3, sizeof(cmd3));
-}
-
-void vfe_stats_start_af(struct vfe_cmd_stats_af_start *in)
-{
-	struct vfe_statsaf_update cmd;
-	struct vfe_statsaf_cfg    cmd2;
-
-	memset(&cmd, 0, sizeof(cmd));
-	memset(&cmd2, 0, sizeof(cmd2));
-
-	ctrl->vfeStatsCmdLocal.autoFocusEnable = in->enable;
-	ctrl->vfeImaskLocal.afPingpongIrq = TRUE;
-
-	cmd.windowVOffset = in->windowVOffset;
-	cmd.windowHOffset = in->windowHOffset;
-	cmd.windowMode    = in->windowMode;
-	cmd.windowHeight  = in->windowHeight;
-	cmd.windowWidth   = in->windowWidth;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_STATS_AF_CFG,
-		(uint32_t *)&cmd, sizeof(cmd));
-
-	cmd2.a00       = in->highPassCoef[0];
-	cmd2.a04       = in->highPassCoef[1];
-	cmd2.a20       = in->highPassCoef[2];
-	cmd2.a21       = in->highPassCoef[3];
-	cmd2.a22       = in->highPassCoef[4];
-	cmd2.a23       = in->highPassCoef[5];
-	cmd2.a24       = in->highPassCoef[6];
-	cmd2.fvMax     = in->metricMax;
-	cmd2.fvMetric  = in->metricSelection;
-	cmd2.afHeader  = in->bufferHeader;
-	cmd2.entry00   = in->gridForMultiWindows[0];
-	cmd2.entry01   = in->gridForMultiWindows[1];
-	cmd2.entry02   = in->gridForMultiWindows[2];
-	cmd2.entry03   = in->gridForMultiWindows[3];
-	cmd2.entry10   = in->gridForMultiWindows[4];
-	cmd2.entry11   = in->gridForMultiWindows[5];
-	cmd2.entry12   = in->gridForMultiWindows[6];
-	cmd2.entry13   = in->gridForMultiWindows[7];
-	cmd2.entry20   = in->gridForMultiWindows[8];
-	cmd2.entry21   = in->gridForMultiWindows[9];
-	cmd2.entry22   = in->gridForMultiWindows[10];
-	cmd2.entry23   = in->gridForMultiWindows[11];
-	cmd2.entry30   = in->gridForMultiWindows[12];
-	cmd2.entry31   = in->gridForMultiWindows[13];
-	cmd2.entry32   = in->gridForMultiWindows[14];
-	cmd2.entry33   = in->gridForMultiWindows[15];
-
-	vfe_prog_hw(ctrl->vfebase + VFE_STATS_AF_GRID_0,
-		(uint32_t *)&cmd2, sizeof(cmd2));
-}
-
-void vfe_stats_setting(struct vfe_cmd_stats_setting *in)
-{
-	struct vfe_statsframe cmd1;
-	struct vfe_busstats_wrprio cmd2;
-
-	memset(&cmd1, 0, sizeof(cmd1));
-	memset(&cmd2, 0, sizeof(cmd2));
-
-	ctrl->afStatsControl.addressBuffer[0] = in->afBuffer[0];
-	ctrl->afStatsControl.addressBuffer[1] = in->afBuffer[1];
-	ctrl->afStatsControl.nextFrameAddrBuf = in->afBuffer[2];
-
-	ctrl->awbStatsControl.addressBuffer[0] = in->awbBuffer[0];
-	ctrl->awbStatsControl.addressBuffer[1] = in->awbBuffer[1];
-	ctrl->awbStatsControl.nextFrameAddrBuf = in->awbBuffer[2];
-
-	cmd1.lastPixel = in->frameHDimension;
-	cmd1.lastLine  = in->frameVDimension;
-	vfe_prog_hw(ctrl->vfebase + VFE_STATS_FRAME_SIZE,
-		(uint32_t *)&cmd1, sizeof(cmd1));
-
-	cmd2.afBusPriority    = in->afBusPriority;
-	cmd2.awbBusPriority   = in->awbBusPriority;
-	cmd2.histBusPriority  = in->histBusPriority;
-	cmd2.afBusPriorityEn  = in->afBusPrioritySelection;
-	cmd2.awbBusPriorityEn = in->awbBusPrioritySelection;
-	cmd2.histBusPriorityEn = in->histBusPrioritySelection;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_BUS_STATS_WR_PRIORITY,
-		(uint32_t *)&cmd2, sizeof(cmd2));
-
-	/* Program the bus ping pong address for statistics modules. */
-	writel(in->afBuffer[0], ctrl->vfebase + VFE_BUS_STATS_AF_WR_PING_ADDR);
-	writel(in->afBuffer[1], ctrl->vfebase + VFE_BUS_STATS_AF_WR_PONG_ADDR);
-	writel(in->awbBuffer[0],
-		ctrl->vfebase + VFE_BUS_STATS_AWB_WR_PING_ADDR);
-	writel(in->awbBuffer[1],
-		ctrl->vfebase + VFE_BUS_STATS_AWB_WR_PONG_ADDR);
-	writel(in->histBuffer[0],
-		ctrl->vfebase + VFE_BUS_STATS_HIST_WR_PING_ADDR);
-	writel(in->histBuffer[1],
-		ctrl->vfebase + VFE_BUS_STATS_HIST_WR_PONG_ADDR);
-}
-
-void vfe_axi_input_config(struct vfe_cmd_axi_input_config *in)
-{
-	struct VFE_AxiInputCmdType cmd;
-	uint32_t xSizeWord, axiRdUnpackPattern;
-	uint8_t  axiInputPpw;
-	uint32_t busPingpongRdIrqEnable;
-
-	ctrl->vfeImaskLocal.rdPingpongIrq = TRUE;
-
-	switch (in->pixelSize) {
-	case VFE_RAW_PIXEL_DATA_SIZE_10BIT:
-		ctrl->axiInputDataSize = VFE_RAW_PIXEL_DATA_SIZE_10BIT;
-		break;
-
-	case VFE_RAW_PIXEL_DATA_SIZE_12BIT:
-		ctrl->axiInputDataSize = VFE_RAW_PIXEL_DATA_SIZE_12BIT;
-		break;
-
-	case VFE_RAW_PIXEL_DATA_SIZE_8BIT:
-	default:
-		ctrl->axiInputDataSize = VFE_RAW_PIXEL_DATA_SIZE_8BIT;
-		break;
-	}
-
-	memset(&cmd, 0, sizeof(cmd));
-
-	switch (in->pixelSize) {
-	case VFE_RAW_PIXEL_DATA_SIZE_10BIT:
-		axiInputPpw = 6;
-		axiRdUnpackPattern = 0xD43210;
-		break;
-
-	case VFE_RAW_PIXEL_DATA_SIZE_12BIT:
-		axiInputPpw = 5;
-		axiRdUnpackPattern = 0xC3210;
-		break;
-
-	case VFE_RAW_PIXEL_DATA_SIZE_8BIT:
-	default:
-		axiInputPpw = 8;
-		axiRdUnpackPattern = 0xF6543210;
-		break;
-	}
-
-	xSizeWord =
-		((((in->xOffset % axiInputPpw) + in->xSize) +
-			(axiInputPpw-1)) / axiInputPpw) - 1;
-
-	cmd.stripeStartAddr0  = in->fragAddr[0];
-	cmd.stripeStartAddr1  = in->fragAddr[1];
-	cmd.stripeStartAddr2  = in->fragAddr[2];
-	cmd.stripeStartAddr3  = in->fragAddr[3];
-	cmd.ySize             = in->ySize;
-	cmd.yOffsetDelta      = 0;
-	cmd.xSizeWord         = xSizeWord;
-	cmd.burstLength       = 1;
-	cmd.NumOfRows         = in->numOfRows;
-	cmd.RowIncrement = (in->rowIncrement + (axiInputPpw - 1)) / axiInputPpw;
-	cmd.mainUnpackHeight  = in->ySize;
-	cmd.mainUnpackWidth   = in->xSize - 1;
-	cmd.mainUnpackHbiSel  = (uint32_t)in->unpackHbi;
-	cmd.mainUnpackPhase   = in->unpackPhase;
-	cmd.unpackPattern     = axiRdUnpackPattern;
-	cmd.padLeft           = in->padRepeatCountLeft;
-	cmd.padRight          = in->padRepeatCountRight;
-	cmd.padTop            = in->padRepeatCountTop;
-	cmd.padBottom         = in->padRepeatCountBottom;
-	cmd.leftUnpackPattern0   = in->padLeftComponentSelectCycle0;
-	cmd.leftUnpackPattern1   = in->padLeftComponentSelectCycle1;
-	cmd.leftUnpackPattern2   = in->padLeftComponentSelectCycle2;
-	cmd.leftUnpackPattern3   = in->padLeftComponentSelectCycle3;
-	cmd.leftUnpackStop0      = in->padLeftStopCycle0;
-	cmd.leftUnpackStop1      = in->padLeftStopCycle1;
-	cmd.leftUnpackStop2      = in->padLeftStopCycle2;
-	cmd.leftUnpackStop3      = in->padLeftStopCycle3;
-	cmd.rightUnpackPattern0  = in->padRightComponentSelectCycle0;
-	cmd.rightUnpackPattern1  = in->padRightComponentSelectCycle1;
-	cmd.rightUnpackPattern2  = in->padRightComponentSelectCycle2;
-	cmd.rightUnpackPattern3  = in->padRightComponentSelectCycle3;
-	cmd.rightUnpackStop0     = in->padRightStopCycle0;
-	cmd.rightUnpackStop1     = in->padRightStopCycle1;
-	cmd.rightUnpackStop2     = in->padRightStopCycle2;
-	cmd.rightUnpackStop3     = in->padRightStopCycle3;
-	cmd.topUnapckPattern     = in->padTopLineCount;
-	cmd.bottomUnapckPattern  = in->padBottomLineCount;
-
-	/*  program vfe_bus_cfg */
-	vfe_prog_hw(ctrl->vfebase + VFE_BUS_STRIPE_RD_ADDR_0,
-		(uint32_t *)&cmd, sizeof(cmd));
-
-	/* hacking code, put it to default value */
-	busPingpongRdIrqEnable = 0xf;
-
-	writel(busPingpongRdIrqEnable, ctrl->vfebase + VFE_BUS_PINGPONG_IRQ_EN);
-}
-
-void vfe_axi_output_config(struct vfe_cmd_axi_output_config *in)
-{
-	/* local variable  */
-	uint32_t *pcircle;
-	uint32_t *pdest;
-	uint32_t *psrc;
-	uint8_t  i;
-	uint8_t  fcnt;
-	uint16_t axioutpw = 8;
-
-	/* parameters check, condition and usage mode check */
-	ctrl->encPath.fragCount = in->output2.fragmentCount;
-	if (ctrl->encPath.fragCount > 1)
-		ctrl->encPath.multiFrag = TRUE;
-
-	ctrl->viewPath.fragCount = in->output1.fragmentCount;
-	if (ctrl->viewPath.fragCount > 1)
-		ctrl->viewPath.multiFrag = TRUE;
-
-	/* VFE_BUS_CFG.  raw data size */
-	ctrl->vfeBusConfigLocal.rawPixelDataSize = in->outputDataSize;
-
-	switch (in->outputDataSize) {
-	case VFE_RAW_PIXEL_DATA_SIZE_8BIT:
-		axioutpw = 8;
-		break;
-
-	case VFE_RAW_PIXEL_DATA_SIZE_10BIT:
-		axioutpw = 6;
-		break;
-
-	case VFE_RAW_PIXEL_DATA_SIZE_12BIT:
-		axioutpw = 5;
-		break;
-	}
-
-	ctrl->axiOutputMode = in->outputMode;
-
-	CDBG("axiOutputMode = %d\n", ctrl->axiOutputMode);
-
-	switch (ctrl->axiOutputMode) {
-	case VFE_AXI_OUTPUT_MODE_Output1: {
-		ctrl->vfeCamifConfigLocal.camif2BusEnable   = FALSE;
-		ctrl->vfeCamifConfigLocal.camif2OutputEnable = TRUE;
-		ctrl->vfeBusConfigLocal.rawWritePathSelect  =
-			VFE_RAW_OUTPUT_DISABLED;
-
-		ctrl->encPath.pathEnabled                   = FALSE;
-		ctrl->vfeImaskLocal.encIrq                  = FALSE;
-		ctrl->vfeIrqCompositeMaskLocal.encIrqComMask =
-			VFE_COMP_IRQ_BOTH_Y_CBCR;
-
-		ctrl->vfeBusConfigLocal.encYWrPathEn          = FALSE;
-		ctrl->vfeBusConfigLocal.encCbcrWrPathEn       = FALSE;
-		ctrl->viewPath.pathEnabled                    = TRUE;
-		ctrl->vfeImaskLocal.viewIrq                   = TRUE;
-		ctrl->vfeIrqCompositeMaskLocal.viewIrqComMask =
-			VFE_COMP_IRQ_BOTH_Y_CBCR;
-
-		ctrl->vfeBusConfigLocal.viewYWrPathEn    = TRUE;
-		ctrl->vfeBusConfigLocal.viewCbcrWrPathEn = TRUE;
-
-		if (ctrl->vfeBusConfigLocal.encYWrPathEn &&
-				ctrl->encPath.multiFrag)
-			ctrl->vfeImaskLocal.encYPingpongIrq    = TRUE;
-
-		if (ctrl->vfeBusConfigLocal.encCbcrWrPathEn &&
-				ctrl->encPath.multiFrag)
-			ctrl->vfeImaskLocal.encCbcrPingpongIrq = TRUE;
-
-		if (ctrl->vfeBusConfigLocal.viewYWrPathEn &&
-				ctrl->viewPath.multiFrag)
-			ctrl->vfeImaskLocal.viewYPingpongIrq   = TRUE;
-
-		if (ctrl->vfeBusConfigLocal.viewCbcrWrPathEn &&
-				ctrl->viewPath.multiFrag)
-			ctrl->vfeImaskLocal.viewCbcrPingpongIrq = TRUE;
-	} /* VFE_AXI_OUTPUT_MODE_Output1 */
-		break;
-
-	case VFE_AXI_OUTPUT_MODE_Output2: {
-		ctrl->vfeCamifConfigLocal.camif2BusEnable   = FALSE;
-		ctrl->vfeCamifConfigLocal.camif2OutputEnable = TRUE;
-		ctrl->vfeBusConfigLocal.rawWritePathSelect  =
-			VFE_RAW_OUTPUT_DISABLED;
-
-		ctrl->encPath.pathEnabled                   = TRUE;
-		ctrl->vfeImaskLocal.encIrq                  = TRUE;
-		ctrl->vfeIrqCompositeMaskLocal.encIrqComMask =
-			VFE_COMP_IRQ_BOTH_Y_CBCR;
-
-		ctrl->vfeBusConfigLocal.encYWrPathEn        = TRUE;
-		ctrl->vfeBusConfigLocal.encCbcrWrPathEn     = TRUE;
-
-		ctrl->viewPath.pathEnabled                   = FALSE;
-		ctrl->vfeImaskLocal.viewIrq                  = FALSE;
-		ctrl->vfeIrqCompositeMaskLocal.viewIrqComMask =
-			VFE_COMP_IRQ_BOTH_Y_CBCR;
-
-		ctrl->vfeBusConfigLocal.viewYWrPathEn        = FALSE;
-		ctrl->vfeBusConfigLocal.viewCbcrWrPathEn     = FALSE;
-
-		if (ctrl->vfeBusConfigLocal.encYWrPathEn &&
-				ctrl->encPath.multiFrag)
-			ctrl->vfeImaskLocal.encYPingpongIrq    = TRUE;
-
-		if (ctrl->vfeBusConfigLocal.encCbcrWrPathEn &&
-				ctrl->encPath.multiFrag)
-			ctrl->vfeImaskLocal.encCbcrPingpongIrq = TRUE;
-
-		if (ctrl->vfeBusConfigLocal.viewYWrPathEn &&
-				ctrl->viewPath.multiFrag)
-			ctrl->vfeImaskLocal.viewYPingpongIrq   = TRUE;
-
-		if (ctrl->vfeBusConfigLocal.viewCbcrWrPathEn &&
-				ctrl->viewPath.multiFrag)
-			ctrl->vfeImaskLocal.viewCbcrPingpongIrq = TRUE;
-	} /* VFE_AXI_OUTPUT_MODE_Output2 */
-			break;
-
-	case VFE_AXI_OUTPUT_MODE_Output1AndOutput2: {
-		ctrl->vfeCamifConfigLocal.camif2BusEnable    = FALSE;
-		ctrl->vfeCamifConfigLocal.camif2OutputEnable = TRUE;
-		ctrl->vfeBusConfigLocal.rawWritePathSelect   =
-			VFE_RAW_OUTPUT_DISABLED;
-
-		ctrl->encPath.pathEnabled                    = TRUE;
-		ctrl->vfeImaskLocal.encIrq                   = TRUE;
-		ctrl->vfeIrqCompositeMaskLocal.encIrqComMask =
-			VFE_COMP_IRQ_BOTH_Y_CBCR;
-
-		ctrl->vfeBusConfigLocal.encYWrPathEn         = TRUE;
-		ctrl->vfeBusConfigLocal.encCbcrWrPathEn      = TRUE;
-		ctrl->viewPath.pathEnabled                   = TRUE;
-		ctrl->vfeImaskLocal.viewIrq                  = TRUE;
-		ctrl->vfeIrqCompositeMaskLocal.viewIrqComMask =
-			VFE_COMP_IRQ_BOTH_Y_CBCR;
-
-		ctrl->vfeBusConfigLocal.viewYWrPathEn        = TRUE;
-		ctrl->vfeBusConfigLocal.viewCbcrWrPathEn     = TRUE;
-
-		if (ctrl->vfeBusConfigLocal.encYWrPathEn &&
-				ctrl->encPath.multiFrag)
-			ctrl->vfeImaskLocal.encYPingpongIrq    = TRUE;
-
-		if (ctrl->vfeBusConfigLocal.encCbcrWrPathEn &&
-				ctrl->encPath.multiFrag)
-			ctrl->vfeImaskLocal.encCbcrPingpongIrq = TRUE;
-
-		if (ctrl->vfeBusConfigLocal.viewYWrPathEn &&
-				ctrl->viewPath.multiFrag)
-			ctrl->vfeImaskLocal.viewYPingpongIrq   = TRUE;
-
-		if (ctrl->vfeBusConfigLocal.viewCbcrWrPathEn &&
-				ctrl->viewPath.multiFrag)
-			ctrl->vfeImaskLocal.viewCbcrPingpongIrq = TRUE;
-	} /* VFE_AXI_OUTPUT_MODE_Output1AndOutput2 */
-		break;
-
-	case VFE_AXI_OUTPUT_MODE_CAMIFToAXIViaOutput2: {
-		/* For raw snapshot, we need both ping and pong buffer
-		 * initialized to the same address. Otherwise, if we
-		 * leave the pong buffer to NULL, there will be axi_error.
-		 * Note that ideally we should deal with this at upper layer,
-		 * which is in msm_vfe8x.c */
-		if (!in->output2.outputCbcr.outFragments[1][0]) {
-			in->output2.outputCbcr.outFragments[1][0] =
-				in->output2.outputCbcr.outFragments[0][0];
-		}
-
-		ctrl->vfeCamifConfigLocal.camif2BusEnable   = TRUE;
-		ctrl->vfeCamifConfigLocal.camif2OutputEnable = FALSE;
-		ctrl->vfeBusConfigLocal.rawWritePathSelect  =
-			VFE_RAW_OUTPUT_ENC_CBCR_PATH;
-
-		ctrl->encPath.pathEnabled                   = TRUE;
-		ctrl->vfeImaskLocal.encIrq                  = TRUE;
-		ctrl->vfeIrqCompositeMaskLocal.encIrqComMask =
-			VFE_COMP_IRQ_CBCR_ONLY;
-
-		ctrl->vfeBusConfigLocal.encYWrPathEn        = FALSE;
-		ctrl->vfeBusConfigLocal.encCbcrWrPathEn     = TRUE;
-
-		ctrl->viewPath.pathEnabled                   = FALSE;
-		ctrl->vfeImaskLocal.viewIrq                  = FALSE;
-		ctrl->vfeIrqCompositeMaskLocal.viewIrqComMask =
-			VFE_COMP_IRQ_BOTH_Y_CBCR;
-
-		ctrl->vfeBusConfigLocal.viewYWrPathEn        = FALSE;
-		ctrl->vfeBusConfigLocal.viewCbcrWrPathEn     = FALSE;
-
-		if (ctrl->vfeBusConfigLocal.encYWrPathEn &&
-				ctrl->encPath.multiFrag)
-			ctrl->vfeImaskLocal.encYPingpongIrq    = TRUE;
-
-		if (ctrl->vfeBusConfigLocal.encCbcrWrPathEn &&
-				ctrl->encPath.multiFrag)
-			ctrl->vfeImaskLocal.encCbcrPingpongIrq = TRUE;
-
-		if (ctrl->vfeBusConfigLocal.viewYWrPathEn &&
-				ctrl->viewPath.multiFrag)
-			ctrl->vfeImaskLocal.viewYPingpongIrq   = TRUE;
-
-		if (ctrl->vfeBusConfigLocal.viewCbcrWrPathEn &&
-				ctrl->viewPath.multiFrag)
-			ctrl->vfeImaskLocal.viewCbcrPingpongIrq = TRUE;
-	} /* VFE_AXI_OUTPUT_MODE_CAMIFToAXIViaOutput2 */
-		break;
-
-	case VFE_AXI_OUTPUT_MODE_Output2AndCAMIFToAXIViaOutput1: {
-		ctrl->vfeCamifConfigLocal.camif2BusEnable   = TRUE;
-		ctrl->vfeCamifConfigLocal.camif2OutputEnable = TRUE;
-		ctrl->vfeBusConfigLocal.rawWritePathSelect  =
-			VFE_RAW_OUTPUT_VIEW_CBCR_PATH;
-
-		ctrl->encPath.pathEnabled                   = TRUE;
-		ctrl->vfeImaskLocal.encIrq                  = TRUE;
-		ctrl->vfeIrqCompositeMaskLocal.encIrqComMask =
-			VFE_COMP_IRQ_BOTH_Y_CBCR;
-
-		ctrl->vfeBusConfigLocal.encYWrPathEn        = TRUE;
-		ctrl->vfeBusConfigLocal.encCbcrWrPathEn     = TRUE;
-
-		ctrl->viewPath.pathEnabled                   = TRUE;
-		ctrl->vfeImaskLocal.viewIrq                  = TRUE;
-		ctrl->vfeIrqCompositeMaskLocal.viewIrqComMask =
-			VFE_COMP_IRQ_CBCR_ONLY;
-
-		ctrl->vfeBusConfigLocal.viewYWrPathEn        = FALSE;
-		ctrl->vfeBusConfigLocal.viewCbcrWrPathEn     = TRUE;
-
-		if (ctrl->vfeBusConfigLocal.encYWrPathEn &&
-				ctrl->encPath.multiFrag)
-			ctrl->vfeImaskLocal.encYPingpongIrq    = TRUE;
-
-		if (ctrl->vfeBusConfigLocal.encCbcrWrPathEn &&
-				ctrl->encPath.multiFrag)
-			ctrl->vfeImaskLocal.encCbcrPingpongIrq = TRUE;
-
-		if (ctrl->vfeBusConfigLocal.viewYWrPathEn &&
-				ctrl->viewPath.multiFrag)
-			ctrl->vfeImaskLocal.viewYPingpongIrq   = TRUE;
-
-		if (ctrl->vfeBusConfigLocal.viewCbcrWrPathEn &&
-				ctrl->viewPath.multiFrag)
-			ctrl->vfeImaskLocal.viewCbcrPingpongIrq = TRUE;
-	} /* VFE_AXI_OUTPUT_MODE_Output2AndCAMIFToAXIViaOutput1 */
-		break;
-
-	case VFE_AXI_OUTPUT_MODE_Output1AndCAMIFToAXIViaOutput2: {
-		ctrl->vfeCamifConfigLocal.camif2BusEnable   = TRUE;
-		ctrl->vfeCamifConfigLocal.camif2OutputEnable = TRUE;
-		ctrl->vfeBusConfigLocal.rawWritePathSelect  =
-			VFE_RAW_OUTPUT_ENC_CBCR_PATH;
-
-		ctrl->encPath.pathEnabled                     = TRUE;
-		ctrl->vfeImaskLocal.encIrq                    = TRUE;
-		ctrl->vfeIrqCompositeMaskLocal.encIrqComMask  =
-			VFE_COMP_IRQ_CBCR_ONLY;
-
-		ctrl->vfeBusConfigLocal.encYWrPathEn          = FALSE;
-		ctrl->vfeBusConfigLocal.encCbcrWrPathEn       = TRUE;
-
-		ctrl->viewPath.pathEnabled                    = TRUE;
-		ctrl->vfeImaskLocal.viewIrq                   = TRUE;
-
-		ctrl->vfeIrqCompositeMaskLocal.viewIrqComMask =
-			VFE_COMP_IRQ_BOTH_Y_CBCR;
-
-		ctrl->vfeBusConfigLocal.viewYWrPathEn         = TRUE;
-		ctrl->vfeBusConfigLocal.viewCbcrWrPathEn      = TRUE;
-
-		if (ctrl->vfeBusConfigLocal.encYWrPathEn &&
-				ctrl->encPath.multiFrag)
-			ctrl->vfeImaskLocal.encYPingpongIrq       = TRUE;
-
-		if (ctrl->vfeBusConfigLocal.encCbcrWrPathEn &&
-				ctrl->encPath.multiFrag)
-			ctrl->vfeImaskLocal.encCbcrPingpongIrq    = TRUE;
-
-		if (ctrl->vfeBusConfigLocal.viewYWrPathEn &&
-				ctrl->viewPath.multiFrag)
-			ctrl->vfeImaskLocal.viewYPingpongIrq      = TRUE;
-
-		if (ctrl->vfeBusConfigLocal.viewCbcrWrPathEn &&
-				ctrl->viewPath.multiFrag)
-			ctrl->vfeImaskLocal.viewCbcrPingpongIrq   = TRUE;
-	} /* VFE_AXI_OUTPUT_MODE_Output1AndCAMIFToAXIViaOutput2 */
-		break;
-
-	case VFE_AXI_LAST_OUTPUT_MODE_ENUM:
-		break;
-	} /* switch */
-
-	/* Save the addresses for each path. */
-	/* output2 path */
-	fcnt = ctrl->encPath.fragCount;
-
-	pcircle = ctrl->encPath.yPath.addressBuffer;
-	pdest = ctrl->encPath.nextFrameAddrBuf;
-
-	psrc = &(in->output2.outputY.outFragments[0][0]);
-	for (i = 0; i < fcnt; i++)
-		*pcircle++ = *psrc++;
-
-	psrc = &(in->output2.outputY.outFragments[1][0]);
-	for (i = 0; i < fcnt; i++)
-		*pcircle++ = *psrc++;
-
-	psrc = &(in->output2.outputY.outFragments[2][0]);
-	for (i = 0; i < fcnt; i++)
-		*pdest++ = *psrc++;
-
-	pcircle = ctrl->encPath.cbcrPath.addressBuffer;
-
-	psrc = &(in->output2.outputCbcr.outFragments[0][0]);
-	for (i = 0; i < fcnt; i++)
-		*pcircle++ = *psrc++;
-
-	psrc = &(in->output2.outputCbcr.outFragments[1][0]);
-	for (i = 0; i < fcnt; i++)
-		*pcircle++ = *psrc++;
-
-	psrc = &(in->output2.outputCbcr.outFragments[2][0]);
-	for (i = 0; i < fcnt; i++)
-		*pdest++ = *psrc++;
-
-	vfe_set_bus_pipo_addr(&ctrl->viewPath, &ctrl->encPath);
-
-	ctrl->encPath.ackPending = FALSE;
-	ctrl->encPath.currentFrame = ping;
-	ctrl->encPath.whichOutputPath = 1;
-	ctrl->encPath.yPath.fragIndex = 2;
-	ctrl->encPath.cbcrPath.fragIndex = 2;
-	ctrl->encPath.yPath.hwCurrentFlag = ping;
-	ctrl->encPath.cbcrPath.hwCurrentFlag = ping;
-
-	/* output1 path */
-	pcircle = ctrl->viewPath.yPath.addressBuffer;
-	pdest = ctrl->viewPath.nextFrameAddrBuf;
-	fcnt = ctrl->viewPath.fragCount;
-
-	psrc = &(in->output1.outputY.outFragments[0][0]);
-	for (i = 0; i < fcnt; i++)
-		*pcircle++ = *psrc++;
-
-	psrc = &(in->output1.outputY.outFragments[1][0]);
-	for (i = 0; i < fcnt; i++)
-		*pcircle++ = *psrc++;
-
-	psrc = &(in->output1.outputY.outFragments[2][0]);
-	for (i = 0; i < fcnt; i++)
-		*pdest++ = *psrc++;
-
-	pcircle = ctrl->viewPath.cbcrPath.addressBuffer;
-
-	psrc = &(in->output1.outputCbcr.outFragments[0][0]);
-	for (i = 0; i < fcnt; i++)
-		*pcircle++ = *psrc++;
-
-	psrc = &(in->output1.outputCbcr.outFragments[1][0]);
-	for (i = 0; i < fcnt; i++)
-		*pcircle++ = *psrc++;
-
-	psrc = &(in->output1.outputCbcr.outFragments[2][0]);
-	for (i = 0; i < fcnt; i++)
-		*pdest++ = *psrc++;
-
-	ctrl->viewPath.ackPending = FALSE;
-	ctrl->viewPath.currentFrame = ping;
-	ctrl->viewPath.whichOutputPath = 0;
-	ctrl->viewPath.yPath.fragIndex = 2;
-	ctrl->viewPath.cbcrPath.fragIndex = 2;
-	ctrl->viewPath.yPath.hwCurrentFlag = ping;
-	ctrl->viewPath.cbcrPath.hwCurrentFlag = ping;
-
-	/* call to program the registers. */
-	vfe_axi_output(in, &ctrl->viewPath, &ctrl->encPath, axioutpw);
-}
-
-void vfe_camif_config(struct vfe_cmd_camif_config *in)
-{
-	struct vfe_camifcfg cmd;
-	memset(&cmd, 0, sizeof(cmd));
-
-	CDBG("camif.frame pixelsPerLine = %d\n", in->frame.pixelsPerLine);
-	CDBG("camif.frame linesPerFrame = %d\n", in->frame.linesPerFrame);
-	CDBG("camif.window firstpixel = %d\n", in->window.firstpixel);
-	CDBG("camif.window lastpixel = %d\n",  in->window.lastpixel);
-	CDBG("camif.window firstline = %d\n",  in->window.firstline);
-	CDBG("camif.window lastline = %d\n",   in->window.lastline);
-
-	/* determine if epoch interrupt needs to be enabled.  */
-	if ((in->epoch1.enable == TRUE) &&
-	    (in->epoch1.lineindex <= in->frame.linesPerFrame))
-		ctrl->vfeImaskLocal.camifEpoch1Irq = 1;
-
-	if ((in->epoch2.enable == TRUE) &&
-	    (in->epoch2.lineindex <= in->frame.linesPerFrame)) {
-		ctrl->vfeImaskLocal.camifEpoch2Irq = 1;
-	}
-
-	/*  save the content to program CAMIF_CONFIG seperately. */
-	ctrl->vfeCamifConfigLocal.camifCfgFromCmd = in->camifConfig;
-
-	/* EFS_Config */
-	cmd.efsEndOfLine     = in->EFS.efsendofline;
-	cmd.efsStartOfLine   = in->EFS.efsstartofline;
-	cmd.efsEndOfFrame    = in->EFS.efsendofframe;
-	cmd.efsStartOfFrame  = in->EFS.efsstartofframe;
-
-	/* Frame Config */
-	cmd.frameConfigPixelsPerLine = in->frame.pixelsPerLine;
-	cmd.frameConfigLinesPerFrame = in->frame.linesPerFrame;
-
-	/* Window Width Config */
-	cmd.windowWidthCfgLastPixel  = in->window.lastpixel;
-	cmd.windowWidthCfgFirstPixel = in->window.firstpixel;
-
-	/* Window Height Config */
-	cmd.windowHeightCfglastLine   = in->window.lastline;
-	cmd.windowHeightCfgfirstLine  = in->window.firstline;
-
-	/* Subsample 1 Config */
-	cmd.subsample1CfgPixelSkip = in->subsample.pixelskipmask;
-	cmd.subsample1CfgLineSkip  = in->subsample.lineskipmask;
-
-	/* Subsample 2 Config */
-	cmd.subsample2CfgFrameSkip      = in->subsample.frameskip;
-	cmd.subsample2CfgFrameSkipMode  = in->subsample.frameskipmode;
-	cmd.subsample2CfgPixelSkipWrap  = in->subsample.pixelskipwrap;
-
-	/* Epoch Interrupt */
-	cmd.epoch1Line = in->epoch1.lineindex;
-	cmd.epoch2Line = in->epoch2.lineindex;
-
-	vfe_prog_hw(ctrl->vfebase + CAMIF_EFS_CONFIG,
-		(uint32_t *)&cmd, sizeof(cmd));
-}
-
-void vfe_fov_crop_config(struct vfe_cmd_fov_crop_config *in)
-{
-	struct vfe_fov_crop_cfg cmd;
-	memset(&cmd, 0, sizeof(cmd));
-
-	ctrl->vfeModuleEnableLocal.cropEnable = in->enable;
-
-	/* FOV Corp, Part 1 */
-	cmd.lastPixel  = in->lastPixel;
-	cmd.firstPixel = in->firstPixel;
-
-	/* FOV Corp, Part 2 */
-	cmd.lastLine   = in->lastLine;
-	cmd.firstLine  = in->firstLine;
-
-	vfe_prog_hw(ctrl->vfebase + VFE_CROP_WIDTH_CFG,
-		(uint32_t *)&cmd, sizeof(cmd));
-}
-
-void vfe_get_hw_version(struct vfe_cmd_hw_version *out)
-{
-	uint32_t vfeHwVersionPacked;
-	struct vfe_hw_ver ver;
-
-	vfeHwVersionPacked = readl(ctrl->vfebase + VFE_HW_VERSION);
-
-	ver = *((struct vfe_hw_ver *)&vfeHwVersionPacked);
-
-	out->coreVersion  = ver.coreVersion;
-	out->minorVersion = ver.minorVersion;
-	out->majorVersion = ver.majorVersion;
-}
-
-static void vfe_reset_internal_variables(void)
-{
-	/* local variables to program the hardware. */
-	ctrl->vfeImaskPacked = 0;
-	ctrl->vfeImaskCompositePacked = 0;
-
-	/* FALSE = disable,  1 = enable. */
-	memset(&ctrl->vfeModuleEnableLocal, 0,
-		sizeof(ctrl->vfeModuleEnableLocal));
-
-	/* 0 = disable, 1 = enable */
-	memset(&ctrl->vfeCamifConfigLocal, 0,
-		sizeof(ctrl->vfeCamifConfigLocal));
-	/* 0 = disable, 1 = enable */
-	memset(&ctrl->vfeImaskLocal, 0, sizeof(ctrl->vfeImaskLocal));
-	memset(&ctrl->vfeStatsCmdLocal, 0, sizeof(ctrl->vfeStatsCmdLocal));
-	memset(&ctrl->vfeBusConfigLocal, 0, sizeof(ctrl->vfeBusConfigLocal));
-	memset(&ctrl->vfeBusPmConfigLocal, 0,
-		sizeof(ctrl->vfeBusPmConfigLocal));
-	memset(&ctrl->vfeBusCmdLocal, 0, sizeof(ctrl->vfeBusCmdLocal));
-	memset(&ctrl->vfeInterruptNameLocal, 0,
-		sizeof(ctrl->vfeInterruptNameLocal));
-	memset(&ctrl->vfeDroppedFrameCounts, 0,
-		sizeof(ctrl->vfeDroppedFrameCounts));
-	memset(&ctrl->vfeIrqThreadMsgLocal, 0,
-		sizeof(ctrl->vfeIrqThreadMsgLocal));
-
-	/* state control variables */
-	ctrl->vfeStartAckPendingFlag = FALSE;
-	ctrl->vfeStopAckPending = FALSE;
-	ctrl->vfeIrqCompositeMaskLocal.ceDoneSel = 0;
-	ctrl->vfeIrqCompositeMaskLocal.encIrqComMask = VFE_COMP_IRQ_BOTH_Y_CBCR;
-	ctrl->vfeIrqCompositeMaskLocal.viewIrqComMask =
-		VFE_COMP_IRQ_BOTH_Y_CBCR;
-
-	ctrl->vstate = VFE_STATE_IDLE;
-
-	ctrl->axiOutputMode = VFE_AXI_LAST_OUTPUT_MODE_ENUM;
-	/* 0 for continuous mode, 1 for snapshot mode */
-	ctrl->vfeOperationMode = VFE_START_OPERATION_MODE_CONTINUOUS;
-	ctrl->vfeSnapShotCount = 0;
-	ctrl->vfeStatsPingPongReloadFlag = FALSE;
-	/* this is unsigned 32 bit integer. */
-	ctrl->vfeFrameId = 0;
-	ctrl->vfeFrameSkip.output1Pattern = 0xffffffff;
-	ctrl->vfeFrameSkip.output1Period  = 31;
-	ctrl->vfeFrameSkip.output2Pattern = 0xffffffff;
-	ctrl->vfeFrameSkip.output2Period  = 31;
-	ctrl->vfeFrameSkipPattern = 0xffffffff;
-	ctrl->vfeFrameSkipCount   = 0;
-	ctrl->vfeFrameSkipPeriod  = 31;
-
-	memset((void *)&ctrl->encPath, 0, sizeof(ctrl->encPath));
-	memset((void *)&ctrl->viewPath, 0, sizeof(ctrl->viewPath));
-
-	ctrl->encPath.whichOutputPath  = 1;
-	ctrl->encPath.cbcrStatusBit    = 5;
-	ctrl->viewPath.whichOutputPath = 0;
-	ctrl->viewPath.cbcrStatusBit   = 7;
-
-	ctrl->vfeTestGenStartFlag = FALSE;
-
-	/* default to bank 0. */
-	ctrl->vfeLaBankSel = 0;
-
-	/* default to bank 0 for all channels. */
-	memset(&ctrl->vfeGammaLutSel, 0, sizeof(ctrl->vfeGammaLutSel));
-
-	/* Stats control variables. */
-	memset(&ctrl->afStatsControl, 0, sizeof(ctrl->afStatsControl));
-	memset(&ctrl->awbStatsControl, 0, sizeof(ctrl->awbStatsControl));
-	vfe_set_stats_pingpong_address(&ctrl->afStatsControl,
-		&ctrl->awbStatsControl);
-}
-
-void vfe_reset(void)
-{
-	spin_lock_init(&msm_vfe_ctrl_lock);
-	vfe_reset_internal_variables();
-
-	atomic_set(&ctrl->vfe_serv_interrupt, 1);
-	ctrl->vfeImaskLocal.resetAckIrq = TRUE;
-	ctrl->vfeImaskPacked = vfe_irq_pack(ctrl->vfeImaskLocal);
-
-	/* disable all interrupts. */
-	writel(VFE_DISABLE_ALL_IRQS, ctrl->vfebase + VFE_IRQ_COMPOSITE_MASK);
-
-	/* clear all pending interrupts*/
-	writel(VFE_CLEAR_ALL_IRQS, ctrl->vfebase + VFE_IRQ_CLEAR);
-
-	/* enable reset_ack interrupt.  */
-	writel(ctrl->vfeImaskPacked, ctrl->vfebase + VFE_IRQ_MASK);
-
-	writel(VFE_RESET_UPON_RESET_CMD, ctrl->vfebase + VFE_GLOBAL_RESET_CMD);
-}
diff --git a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe8x_proc.h b/drivers/media/platform/msm/camera_v1/vfe/msm_vfe8x_proc.h
deleted file mode 100644
index 4e18c7c..0000000
--- a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe8x_proc.h
+++ /dev/null
@@ -1,1563 +0,0 @@
-/* Copyright (c) 2009, The Linux Foundation. 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.
- *
- */
-
-#ifndef __MSM_VFE8X_REG_H__
-#define __MSM_VFE8X_REG_H__
-
-#include <mach/msm_iomap.h>
-#include <mach/camera.h>
-#include "msm_vfe8x.h"
-
-
-#define MSM_AXI_QOS_PREVIEW		128000
-#define MSM_AXI_QOS_SNAPSHOT	128000
-#define MSM_AXI_QOS_RECORDING	128000
-
-
-/* at start of camif,  bit 1:0 = 0x01:enable
- * image data capture at frame boundary. */
-#define CAMIF_COMMAND_START  0x00000005
-
-/* bit 2= 0x1:clear the CAMIF_STATUS register
- * value. */
-#define CAMIF_COMMAND_CLEAR  0x00000004
-
-/* at stop of vfe pipeline, for now it is assumed
- * that camif will stop at any time. Bit 1:0 = 0x10:
- * disable image data capture immediately. */
-#define CAMIF_COMMAND_STOP_IMMEDIATELY  0x00000002
-
-/* at stop of vfe pipeline, for now it is assumed
- * that camif will stop at any time. Bit 1:0 = 0x00:
- * disable image data capture at frame boundary */
-#define CAMIF_COMMAND_STOP_AT_FRAME_BOUNDARY  0x00000000
-
-/* to halt axi bridge */
-#define AXI_HALT  0x00000001
-
-/* clear the halt bit. */
-#define AXI_HALT_CLEAR  0x00000000
-
-/* reset the pipeline when stop command is issued.
- * (without reset the register.) bit 26-31 = 0,
- * domain reset, bit 0-9 = 1 for module reset, except
- * register module. */
-#define VFE_RESET_UPON_STOP_CMD  0x000003ef
-
-/* reset the pipeline when reset command.
- * bit 26-31 = 0, domain reset, bit 0-9 = 1 for module reset. */
-#define VFE_RESET_UPON_RESET_CMD  0x000003ff
-
-/* bit 5 is for axi status idle or busy.
- * 1 =  halted,  0 = busy */
-#define AXI_STATUS_BUSY_MASK 0x00000020
-
-/* bit 0 & bit 1 = 1, both y and cbcr irqs need to be present
- * for frame done interrupt */
-#define VFE_COMP_IRQ_BOTH_Y_CBCR 3
-
-/* bit 1 = 1, only cbcr irq triggers frame done interrupt */
-#define VFE_COMP_IRQ_CBCR_ONLY 2
-
-/* bit 0 = 1, only y irq triggers frame done interrupt */
-#define VFE_COMP_IRQ_Y_ONLY 1
-
-/* bit 0 = 1, PM go;   bit1 = 1, PM stop */
-#define VFE_PERFORMANCE_MONITOR_GO   0x00000001
-#define VFE_PERFORMANCE_MONITOR_STOP 0x00000002
-
-/* bit 0 = 1, test gen go;   bit1 = 1, test gen stop */
-#define VFE_TEST_GEN_GO   0x00000001
-#define VFE_TEST_GEN_STOP 0x00000002
-
-/* the chroma is assumed to be interpolated between
- * the luma samples.  JPEG 4:2:2 */
-#define VFE_CHROMA_UPSAMPLE_INTERPOLATED 0
-
-/* constants for irq registers */
-#define VFE_DISABLE_ALL_IRQS 0
-/* bit =1 is to clear the corresponding bit in VFE_IRQ_STATUS.  */
-#define VFE_CLEAR_ALL_IRQS   0xffffffff
-/* imask for while waiting for stop ack,  driver has already
- * requested stop, waiting for reset irq,
- * bit 29,28,27,26 for async timer, bit 9 for reset */
-#define VFE_IMASK_WHILE_STOPPING  0x3c000200
-
-/* when normal case, don't want to block error status.
- * bit 0,6,20,21,22,30,31 */
-#define VFE_IMASK_ERROR_ONLY             0xC0700041
-#define VFE_REG_UPDATE_TRIGGER           1
-#define VFE_PM_BUF_MAX_CNT_MASK          0xFF
-#define VFE_DMI_CFG_DEFAULT              0x00000100
-#define LENS_ROLL_OFF_DELTA_TABLE_OFFSET 32
-#define VFE_AF_PINGPONG_STATUS_BIT       0x100
-#define VFE_AWB_PINGPONG_STATUS_BIT      0x200
-
-/* VFE I/O registers */
-enum {
-	VFE_HW_VERSION                    = 0x00000000,
-	VFE_GLOBAL_RESET_CMD              = 0x00000004,
-	VFE_MODULE_RESET                  = 0x00000008,
-	VFE_CGC_OVERRIDE                  = 0x0000000C,
-	VFE_MODULE_CFG                    = 0x00000010,
-	VFE_CFG                           = 0x00000014,
-	VFE_IRQ_MASK                      = 0x00000018,
-	VFE_IRQ_CLEAR                     = 0x0000001C,
-VFE_IRQ_STATUS                    = 0x00000020,
-VFE_IRQ_COMPOSITE_MASK            = 0x00000024,
-VFE_BUS_CMD                       = 0x00000028,
-VFE_BUS_CFG                       = 0x0000002C,
-VFE_BUS_ENC_Y_WR_PING_ADDR        = 0x00000030,
-VFE_BUS_ENC_Y_WR_PONG_ADDR        = 0x00000034,
-VFE_BUS_ENC_Y_WR_IMAGE_SIZE       = 0x00000038,
-VFE_BUS_ENC_Y_WR_BUFFER_CFG       = 0x0000003C,
-VFE_BUS_ENC_CBCR_WR_PING_ADDR     = 0x00000040,
-VFE_BUS_ENC_CBCR_WR_PONG_ADDR     = 0x00000044,
-VFE_BUS_ENC_CBCR_WR_IMAGE_SIZE    = 0x00000048,
-VFE_BUS_ENC_CBCR_WR_BUFFER_CFG    = 0x0000004C,
-VFE_BUS_VIEW_Y_WR_PING_ADDR       = 0x00000050,
-VFE_BUS_VIEW_Y_WR_PONG_ADDR       = 0x00000054,
-VFE_BUS_VIEW_Y_WR_IMAGE_SIZE      = 0x00000058,
-VFE_BUS_VIEW_Y_WR_BUFFER_CFG      = 0x0000005C,
-VFE_BUS_VIEW_CBCR_WR_PING_ADDR    = 0x00000060,
-VFE_BUS_VIEW_CBCR_WR_PONG_ADDR    = 0x00000064,
-VFE_BUS_VIEW_CBCR_WR_IMAGE_SIZE   = 0x00000068,
-VFE_BUS_VIEW_CBCR_WR_BUFFER_CFG   = 0x0000006C,
-VFE_BUS_STATS_AF_WR_PING_ADDR     = 0x00000070,
-VFE_BUS_STATS_AF_WR_PONG_ADDR     = 0x00000074,
-VFE_BUS_STATS_AWB_WR_PING_ADDR    = 0x00000078,
-VFE_BUS_STATS_AWB_WR_PONG_ADDR    = 0x0000007C,
-VFE_BUS_STATS_HIST_WR_PING_ADDR   = 0x00000080,
-VFE_BUS_STATS_HIST_WR_PONG_ADDR   = 0x00000084,
-VFE_BUS_STATS_WR_PRIORITY         = 0x00000088,
-VFE_BUS_STRIPE_RD_ADDR_0          = 0x0000008C,
-VFE_BUS_STRIPE_RD_ADDR_1          = 0x00000090,
-VFE_BUS_STRIPE_RD_ADDR_2          = 0x00000094,
-VFE_BUS_STRIPE_RD_ADDR_3          = 0x00000098,
-VFE_BUS_STRIPE_RD_VSIZE           = 0x0000009C,
-VFE_BUS_STRIPE_RD_HSIZE           = 0x000000A0,
-VFE_BUS_STRIPE_RD_BUFFER_CFG      = 0x000000A4,
-VFE_BUS_STRIPE_RD_UNPACK_CFG      = 0x000000A8,
-VFE_BUS_STRIPE_RD_UNPACK          = 0x000000AC,
-VFE_BUS_STRIPE_RD_PAD_SIZE        = 0x000000B0,
-VFE_BUS_STRIPE_RD_PAD_L_UNPACK    = 0x000000B4,
-VFE_BUS_STRIPE_RD_PAD_R_UNPACK    = 0x000000B8,
-VFE_BUS_STRIPE_RD_PAD_TB_UNPACK   = 0x000000BC,
-VFE_BUS_PINGPONG_IRQ_EN           = 0x000000C0,
-VFE_BUS_PINGPONG_STATUS           = 0x000000C4,
-VFE_BUS_PM_CMD                    = 0x000000C8,
-VFE_BUS_PM_CFG                    = 0x000000CC,
-VFE_BUS_ENC_Y_WR_PM_STATS_0       = 0x000000D0,
-VFE_BUS_ENC_Y_WR_PM_STATS_1       = 0x000000D4,
-VFE_BUS_ENC_CBCR_WR_PM_STATS_0    = 0x000000D8,
-VFE_BUS_ENC_CBCR_WR_PM_STATS_1    = 0x000000DC,
-VFE_BUS_VIEW_Y_WR_PM_STATS_0      = 0x000000E0,
-VFE_BUS_VIEW_Y_WR_PM_STATS_1      = 0x000000E4,
-VFE_BUS_VIEW_CBCR_WR_PM_STATS_0   = 0x000000E8,
-VFE_BUS_VIEW_CBCR_WR_PM_STATS_1   = 0x000000EC,
-VFE_BUS_MISR_CFG                  = 0x000000F4,
-VFE_BUS_MISR_MAST_CFG_0           = 0x000000F8,
-VFE_BUS_MISR_MAST_CFG_1           = 0x000000FC,
-VFE_BUS_MISR_RD_VAL               = 0x00000100,
-VFE_AXI_CMD                       = 0x00000104,
-VFE_AXI_CFG                       = 0x00000108,
-VFE_AXI_STATUS                    = 0x0000010C,
-CAMIF_COMMAND                     = 0x00000110,
-CAMIF_CONFIG                      = 0x00000114,
-CAMIF_EFS_CONFIG                  = 0x00000118,
-CAMIF_FRAME_CONFIG                = 0x0000011C,
-CAMIF_WINDOW_WIDTH_CONFIG         = 0x00000120,
-CAMIF_WINDOW_HEIGHT_CONFIG        = 0x00000124,
-CAMIF_SUBSAMPLE1_CONFIG           = 0x00000128,
-CAMIF_SUBSAMPLE2_CONFIG           = 0x0000012C,
-CAMIF_EPOCH_IRQ                   = 0x00000130,
-CAMIF_STATUS                      = 0x00000134,
-CAMIF_MISR                        = 0x00000138,
-VFE_SYNC_TIMER_CMD                = 0x0000013C,
-VFE_SYNC_TIMER0_LINE_START        = 0x00000140,
-VFE_SYNC_TIMER0_PIXEL_START       = 0x00000144,
-VFE_SYNC_TIMER0_PIXEL_DURATION    = 0x00000148,
-VFE_SYNC_TIMER1_LINE_START        = 0x0000014C,
-VFE_SYNC_TIMER1_PIXEL_START       = 0x00000150,
-VFE_SYNC_TIMER1_PIXEL_DURATION    = 0x00000154,
-VFE_SYNC_TIMER2_LINE_START        = 0x00000158,
-VFE_SYNC_TIMER2_PIXEL_START       = 0x0000015C,
-VFE_SYNC_TIMER2_PIXEL_DURATION    = 0x00000160,
-VFE_SYNC_TIMER_POLARITY           = 0x00000164,
-VFE_ASYNC_TIMER_CMD               = 0x00000168,
-VFE_ASYNC_TIMER0_CFG_0            = 0x0000016C,
-VFE_ASYNC_TIMER0_CFG_1            = 0x00000170,
-VFE_ASYNC_TIMER1_CFG_0            = 0x00000174,
-VFE_ASYNC_TIMER1_CFG_1            = 0x00000178,
-VFE_ASYNC_TIMER2_CFG_0            = 0x0000017C,
-VFE_ASYNC_TIMER2_CFG_1            = 0x00000180,
-VFE_ASYNC_TIMER3_CFG_0            = 0x00000184,
-VFE_ASYNC_TIMER3_CFG_1            = 0x00000188,
-VFE_TIMER_SEL                     = 0x0000018C,
-VFE_REG_UPDATE_CMD                = 0x00000190,
-VFE_BLACK_EVEN_EVEN_VALUE         = 0x00000194,
-VFE_BLACK_EVEN_ODD_VALUE          = 0x00000198,
-VFE_BLACK_ODD_EVEN_VALUE          = 0x0000019C,
-VFE_BLACK_ODD_ODD_VALUE           = 0x000001A0,
-VFE_ROLLOFF_CFG_0                 = 0x000001A4,
-VFE_ROLLOFF_CFG_1                 = 0x000001A8,
-VFE_ROLLOFF_CFG_2                 = 0x000001AC,
-VFE_DEMUX_CFG                     = 0x000001B0,
-VFE_DEMUX_GAIN_0                  = 0x000001B4,
-VFE_DEMUX_GAIN_1                  = 0x000001B8,
-VFE_DEMUX_EVEN_CFG                = 0x000001BC,
-VFE_DEMUX_ODD_CFG                 = 0x000001C0,
-VFE_DEMOSAIC_CFG                  = 0x000001C4,
-VFE_DEMOSAIC_ABF_CFG_0            = 0x000001C8,
-VFE_DEMOSAIC_ABF_CFG_1            = 0x000001CC,
-VFE_DEMOSAIC_BPC_CFG_0            = 0x000001D0,
-VFE_DEMOSAIC_BPC_CFG_1            = 0x000001D4,
-VFE_DEMOSAIC_STATUS               = 0x000001D8,
-VFE_CHROMA_UPSAMPLE_CFG           = 0x000001DC,
-VFE_CROP_WIDTH_CFG                = 0x000001E0,
-VFE_CROP_HEIGHT_CFG               = 0x000001E4,
-VFE_COLOR_CORRECT_COEFF_0         = 0x000001E8,
-VFE_COLOR_CORRECT_COEFF_1         = 0x000001EC,
-VFE_COLOR_CORRECT_COEFF_2         = 0x000001F0,
-VFE_COLOR_CORRECT_COEFF_3         = 0x000001F4,
-VFE_COLOR_CORRECT_COEFF_4         = 0x000001F8,
-VFE_COLOR_CORRECT_COEFF_5         = 0x000001FC,
-VFE_COLOR_CORRECT_COEFF_6         = 0x00000200,
-VFE_COLOR_CORRECT_COEFF_7         = 0x00000204,
-VFE_COLOR_CORRECT_COEFF_8         = 0x00000208,
-VFE_COLOR_CORRECT_OFFSET_0        = 0x0000020C,
-VFE_COLOR_CORRECT_OFFSET_1        = 0x00000210,
-VFE_COLOR_CORRECT_OFFSET_2        = 0x00000214,
-VFE_COLOR_CORRECT_COEFF_Q         = 0x00000218,
-VFE_LA_CFG                        = 0x0000021C,
-VFE_LUT_BANK_SEL                  = 0x00000220,
-VFE_CHROMA_ENHAN_A                = 0x00000224,
-VFE_CHROMA_ENHAN_B                = 0x00000228,
-VFE_CHROMA_ENHAN_C                = 0x0000022C,
-VFE_CHROMA_ENHAN_D                = 0x00000230,
-VFE_CHROMA_ENHAN_K                = 0x00000234,
-VFE_COLOR_CONVERT_COEFF_0         = 0x00000238,
-VFE_COLOR_CONVERT_COEFF_1         = 0x0000023C,
-VFE_COLOR_CONVERT_COEFF_2         = 0x00000240,
-VFE_COLOR_CONVERT_OFFSET          = 0x00000244,
-VFE_ASF_CFG                       = 0x00000248,
-VFE_ASF_SHARP_CFG_0               = 0x0000024C,
-VFE_ASF_SHARP_CFG_1               = 0x00000250,
-VFE_ASF_SHARP_COEFF_0             = 0x00000254,
-VFE_ASF_SHARP_COEFF_1             = 0x00000258,
-VFE_ASF_SHARP_COEFF_2             = 0x0000025C,
-VFE_ASF_SHARP_COEFF_3             = 0x00000260,
-VFE_ASF_MAX_EDGE                  = 0x00000264,
-VFE_ASF_CROP_WIDTH_CFG            = 0x00000268,
-VFE_ASF_CROP_HEIGHT_CFG           = 0x0000026C,
-VFE_SCALE_CFG                     = 0x00000270,
-VFE_SCALE_H_IMAGE_SIZE_CFG        = 0x00000274,
-VFE_SCALE_H_PHASE_CFG             = 0x00000278,
-VFE_SCALE_H_STRIPE_CFG            = 0x0000027C,
-VFE_SCALE_V_IMAGE_SIZE_CFG        = 0x00000280,
-VFE_SCALE_V_PHASE_CFG             = 0x00000284,
-VFE_SCALE_V_STRIPE_CFG            = 0x00000288,
-VFE_SCALE_Y_CFG                   = 0x0000028C,
-VFE_SCALE_Y_H_IMAGE_SIZE_CFG      = 0x00000290,
-VFE_SCALE_Y_H_PHASE_CFG           = 0x00000294,
-VFE_SCALE_Y_V_IMAGE_SIZE_CFG      = 0x00000298,
-VFE_SCALE_Y_V_PHASE_CFG           = 0x0000029C,
-VFE_SCALE_CBCR_CFG                = 0x000002A0,
-VFE_SCALE_CBCR_H_IMAGE_SIZE_CFG   = 0x000002A4,
-VFE_SCALE_CBCR_H_PHASE_CFG        = 0x000002A8,
-VFE_SCALE_CBCR_V_IMAGE_SIZE_CFG   = 0x000002AC,
-VFE_SCALE_CBCR_V_PHASE_CFG        = 0x000002B0,
-VFE_WB_CFG                        = 0x000002B4,
-VFE_CHROMA_SUPPRESS_CFG_0         = 0x000002B8,
-VFE_CHROMA_SUPPRESS_CFG_1         = 0x000002BC,
-VFE_CHROMA_SUBSAMPLE_CFG          = 0x000002C0,
-VFE_CHROMA_SUB_CROP_WIDTH_CFG     = 0x000002C4,
-VFE_CHROMA_SUB_CROP_HEIGHT_CFG    = 0x000002C8,
-VFE_FRAMEDROP_ENC_Y_CFG           = 0x000002CC,
-VFE_FRAMEDROP_ENC_CBCR_CFG        = 0x000002D0,
-VFE_FRAMEDROP_ENC_Y_PATTERN       = 0x000002D4,
-VFE_FRAMEDROP_ENC_CBCR_PATTERN    = 0x000002D8,
-VFE_FRAMEDROP_VIEW_Y_CFG          = 0x000002DC,
-VFE_FRAMEDROP_VIEW_CBCR_CFG       = 0x000002E0,
-VFE_FRAMEDROP_VIEW_Y_PATTERN      = 0x000002E4,
-VFE_FRAMEDROP_VIEW_CBCR_PATTERN   = 0x000002E8,
-VFE_CLAMP_MAX_CFG                 = 0x000002EC,
-VFE_CLAMP_MIN_CFG                 = 0x000002F0,
-VFE_STATS_CMD                     = 0x000002F4,
-VFE_STATS_AF_CFG                  = 0x000002F8,
-VFE_STATS_AF_DIM                  = 0x000002FC,
-VFE_STATS_AF_GRID_0               = 0x00000300,
-VFE_STATS_AF_GRID_1               = 0x00000304,
-VFE_STATS_AF_GRID_2               = 0x00000308,
-VFE_STATS_AF_GRID_3               = 0x0000030C,
-VFE_STATS_AF_HEADER               = 0x00000310,
-VFE_STATS_AF_COEF0                = 0x00000314,
-VFE_STATS_AF_COEF1                = 0x00000318,
-VFE_STATS_AWBAE_CFG               = 0x0000031C,
-VFE_STATS_AXW_HEADER              = 0x00000320,
-VFE_STATS_AWB_MCFG                = 0x00000324,
-VFE_STATS_AWB_CCFG1               = 0x00000328,
-VFE_STATS_AWB_CCFG2               = 0x0000032C,
-VFE_STATS_HIST_HEADER             = 0x00000330,
-VFE_STATS_HIST_INNER_OFFSET       = 0x00000334,
-VFE_STATS_HIST_INNER_DIM          = 0x00000338,
-VFE_STATS_FRAME_SIZE              = 0x0000033C,
-VFE_DMI_CFG                       = 0x00000340,
-VFE_DMI_ADDR                      = 0x00000344,
-VFE_DMI_DATA_HI                   = 0x00000348,
-VFE_DMI_DATA_LO                   = 0x0000034C,
-VFE_DMI_RAM_AUTO_LOAD_CMD         = 0x00000350,
-VFE_DMI_RAM_AUTO_LOAD_STATUS      = 0x00000354,
-VFE_DMI_RAM_AUTO_LOAD_CFG         = 0x00000358,
-VFE_DMI_RAM_AUTO_LOAD_SEED        = 0x0000035C,
-VFE_TESTBUS_SEL                   = 0x00000360,
-VFE_TESTGEN_CFG                   = 0x00000364,
-VFE_SW_TESTGEN_CMD                = 0x00000368,
-VFE_HW_TESTGEN_CMD                = 0x0000036C,
-VFE_HW_TESTGEN_CFG                = 0x00000370,
-VFE_HW_TESTGEN_IMAGE_CFG          = 0x00000374,
-VFE_HW_TESTGEN_SOF_OFFSET_CFG     = 0x00000378,
-VFE_HW_TESTGEN_EOF_NOFFSET_CFG    = 0x0000037C,
-VFE_HW_TESTGEN_SOL_OFFSET_CFG     = 0x00000380,
-VFE_HW_TESTGEN_EOL_NOFFSET_CFG    = 0x00000384,
-VFE_HW_TESTGEN_HBI_CFG            = 0x00000388,
-VFE_HW_TESTGEN_VBL_CFG            = 0x0000038C,
-VFE_HW_TESTGEN_SOF_DUMMY_LINE_CFG2 = 0x00000390,
-VFE_HW_TESTGEN_EOF_DUMMY_LINE_CFG2 = 0x00000394,
-VFE_HW_TESTGEN_COLOR_BARS_CFG     = 0x00000398,
-VFE_HW_TESTGEN_RANDOM_CFG         = 0x0000039C,
-VFE_SPARE                         = 0x000003A0,
-};
-
-#define ping 0x0
-#define pong 0x1
-
-struct vfe_bus_cfg_data {
-	boolean                  stripeRdPathEn;
-	boolean                  encYWrPathEn;
-	boolean                  encCbcrWrPathEn;
-	boolean                  viewYWrPathEn;
-	boolean                  viewCbcrWrPathEn;
-	enum VFE_RAW_PIXEL_DATA_SIZE rawPixelDataSize;
-	enum VFE_RAW_WR_PATH_SEL     rawWritePathSelect;
-};
-
-struct vfe_camif_cfg_data {
-	boolean camif2OutputEnable;
-	boolean camif2BusEnable;
-	struct vfe_cmds_camif_cfg camifCfgFromCmd;
-};
-
-struct vfe_irq_composite_mask_config {
-	uint8_t encIrqComMask;
-	uint8_t viewIrqComMask;
-	uint8_t ceDoneSel;
-};
-
-/* define a structure for each output path.*/
-struct vfe_output_path {
-	uint32_t addressBuffer[8];
-	uint16_t fragIndex;
-	boolean  hwCurrentFlag;
-	uint8_t  *hwRegPingAddress;
-	uint8_t  *hwRegPongAddress;
-};
-
-struct vfe_output_path_combo {
-	boolean           whichOutputPath;
-	boolean           pathEnabled;
-	boolean           multiFrag;
-	uint8_t           fragCount;
-	boolean           ackPending;
-	uint8_t           currentFrame;
-	uint32_t          nextFrameAddrBuf[8];
-	struct vfe_output_path   yPath;
-	struct vfe_output_path   cbcrPath;
-	uint8_t           snapshotPendingCount;
-	boolean           pmEnabled;
-	uint8_t           cbcrStatusBit;
-};
-
-struct vfe_stats_control {
-	boolean  ackPending;
-	uint32_t addressBuffer[2];
-	uint32_t nextFrameAddrBuf;
-	boolean  pingPongStatus;
-	uint8_t  *hwRegPingAddress;
-	uint8_t  *hwRegPongAddress;
-	uint32_t droppedStatsFrameCount;
-	uint32_t bufToRender;
-};
-
-struct vfe_gamma_lut_sel {
-	boolean  ch0BankSelect;
-	boolean  ch1BankSelect;
-	boolean  ch2BankSelect;
-};
-
-struct vfe_interrupt_mask {
-	boolean  camifErrorIrq;
-	boolean  camifSofIrq;
-	boolean  camifEolIrq;
-	boolean  camifEofIrq;
-	boolean  camifEpoch1Irq;
-	boolean  camifEpoch2Irq;
-	boolean  camifOverflowIrq;
-	boolean  ceIrq;
-	boolean  regUpdateIrq;
-	boolean  resetAckIrq;
-	boolean  encYPingpongIrq;
-	boolean  encCbcrPingpongIrq;
-	boolean  viewYPingpongIrq;
-	boolean  viewCbcrPingpongIrq;
-	boolean  rdPingpongIrq;
-	boolean  afPingpongIrq;
-	boolean  awbPingpongIrq;
-	boolean  histPingpongIrq;
-	boolean  encIrq;
-	boolean  viewIrq;
-	boolean  busOverflowIrq;
-	boolean  afOverflowIrq;
-	boolean  awbOverflowIrq;
-	boolean  syncTimer0Irq;
-	boolean  syncTimer1Irq;
-	boolean  syncTimer2Irq;
-	boolean  asyncTimer0Irq;
-	boolean  asyncTimer1Irq;
-	boolean  asyncTimer2Irq;
-	boolean  asyncTimer3Irq;
-	boolean  axiErrorIrq;
-	boolean  violationIrq;
-};
-
-enum vfe_interrupt_name {
-	CAMIF_ERROR_IRQ,
-	CAMIF_SOF_IRQ,
-	CAMIF_EOL_IRQ,
-	CAMIF_EOF_IRQ,
-	CAMIF_EPOCH1_IRQ,
-	CAMIF_EPOCH2_IRQ,
-	CAMIF_OVERFLOW_IRQ,
-	CE_IRQ,
-	REG_UPDATE_IRQ,
-	RESET_ACK_IRQ,
-	ENC_Y_PINGPONG_IRQ,
-	ENC_CBCR_PINGPONG_IRQ,
-	VIEW_Y_PINGPONG_IRQ,
-	VIEW_CBCR_PINGPONG_IRQ,
-	RD_PINGPONG_IRQ,
-	AF_PINGPONG_IRQ,
-	AWB_PINGPONG_IRQ,
-	HIST_PINGPONG_IRQ,
-	ENC_IRQ,
-	VIEW_IRQ,
-	BUS_OVERFLOW_IRQ,
-	AF_OVERFLOW_IRQ,
-	AWB_OVERFLOW_IRQ,
-	SYNC_TIMER0_IRQ,
-	SYNC_TIMER1_IRQ,
-	SYNC_TIMER2_IRQ,
-	ASYNC_TIMER0_IRQ,
-	ASYNC_TIMER1_IRQ,
-	ASYNC_TIMER2_IRQ,
-	ASYNC_TIMER3_IRQ,
-	AXI_ERROR_IRQ,
-	VIOLATION_IRQ
-};
-
-enum VFE_DMI_RAM_SEL {
-	NO_MEM_SELECTED          = 0,
-	ROLLOFF_RAM              = 0x1,
-	RGBLUT_RAM_CH0_BANK0     = 0x2,
-	RGBLUT_RAM_CH0_BANK1     = 0x3,
-	RGBLUT_RAM_CH1_BANK0     = 0x4,
-	RGBLUT_RAM_CH1_BANK1     = 0x5,
-	RGBLUT_RAM_CH2_BANK0     = 0x6,
-	RGBLUT_RAM_CH2_BANK1     = 0x7,
-	STATS_HIST_CB_EVEN_RAM   = 0x8,
-	STATS_HIST_CB_ODD_RAM    = 0x9,
-	STATS_HIST_CR_EVEN_RAM   = 0xa,
-	STATS_HIST_CR_ODD_RAM    = 0xb,
-	RGBLUT_CHX_BANK0         = 0xc,
-	RGBLUT_CHX_BANK1         = 0xd,
-	LUMA_ADAPT_LUT_RAM_BANK0 = 0xe,
-	LUMA_ADAPT_LUT_RAM_BANK1 = 0xf
-};
-
-struct vfe_module_enable {
-	boolean  blackLevelCorrectionEnable;
-	boolean  lensRollOffEnable;
-	boolean  demuxEnable;
-	boolean  chromaUpsampleEnable;
-	boolean  demosaicEnable;
-	boolean  statsEnable;
-	boolean  cropEnable;
-	boolean  mainScalerEnable;
-	boolean  whiteBalanceEnable;
-	boolean  colorCorrectionEnable;
-	boolean  yHistEnable;
-	boolean  skinToneEnable;
-	boolean  lumaAdaptationEnable;
-	boolean  rgbLUTEnable;
-	boolean  chromaEnhanEnable;
-	boolean  asfEnable;
-	boolean  chromaSuppressionEnable;
-	boolean  chromaSubsampleEnable;
-	boolean  scaler2YEnable;
-	boolean  scaler2CbcrEnable;
-};
-
-struct vfe_bus_cmd_data {
-	boolean  stripeReload;
-	boolean  busPingpongReload;
-	boolean  statsPingpongReload;
-};
-
-struct vfe_stats_cmd_data {
-	boolean  autoFocusEnable;
-	boolean  axwEnable;
-	boolean  histEnable;
-	boolean  clearHistEnable;
-	boolean  histAutoClearEnable;
-	boolean  colorConversionEnable;
-};
-
-struct vfe_hw_ver {
-	uint32_t minorVersion:8;
-	uint32_t majorVersion:8;
-	uint32_t coreVersion:4;
-	uint32_t /* reserved */ : 12;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_cfg {
-	uint32_t pixelPattern:3;
-	uint32_t /* reserved */ : 13;
-	uint32_t inputSource:2;
-	uint32_t /* reserved */ : 14;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_buscmd {
-	uint32_t  stripeReload:1;
-	uint32_t  /* reserved */ : 3;
-	uint32_t  busPingpongReload:1;
-	uint32_t  statsPingpongReload:1;
-	uint32_t  /* reserved */ : 26;
-} __attribute__((packed, aligned(4)));
-
-struct VFE_Irq_Composite_MaskType {
-	uint32_t  encIrqComMaskBits:2;
-	uint32_t  viewIrqComMaskBits:2;
-	uint32_t  ceDoneSelBits:5;
-	uint32_t  /* reserved */ : 23;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_mod_enable {
-	uint32_t blackLevelCorrectionEnable:1;
-	uint32_t lensRollOffEnable:1;
-	uint32_t demuxEnable:1;
-	uint32_t chromaUpsampleEnable:1;
-	uint32_t demosaicEnable:1;
-	uint32_t statsEnable:1;
-	uint32_t cropEnable:1;
-	uint32_t mainScalerEnable:1;
-	uint32_t whiteBalanceEnable:1;
-	uint32_t colorCorrectionEnable:1;
-	uint32_t yHistEnable:1;
-	uint32_t skinToneEnable:1;
-	uint32_t lumaAdaptationEnable:1;
-	uint32_t rgbLUTEnable:1;
-	uint32_t chromaEnhanEnable:1;
-	uint32_t asfEnable:1;
-	uint32_t chromaSuppressionEnable:1;
-	uint32_t chromaSubsampleEnable:1;
-	uint32_t scaler2YEnable:1;
-	uint32_t scaler2CbcrEnable:1;
-	uint32_t /* reserved */ : 14;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_irqenable {
-	uint32_t camifErrorIrq:1;
-	uint32_t camifSofIrq:1;
-	uint32_t camifEolIrq:1;
-	uint32_t camifEofIrq:1;
-	uint32_t camifEpoch1Irq:1;
-	uint32_t camifEpoch2Irq:1;
-	uint32_t camifOverflowIrq:1;
-	uint32_t ceIrq:1;
-	uint32_t regUpdateIrq:1;
-	uint32_t resetAckIrq:1;
-	uint32_t encYPingpongIrq:1;
-	uint32_t encCbcrPingpongIrq:1;
-	uint32_t viewYPingpongIrq:1;
-	uint32_t viewCbcrPingpongIrq:1;
-	uint32_t rdPingpongIrq:1;
-	uint32_t afPingpongIrq:1;
-	uint32_t awbPingpongIrq:1;
-	uint32_t histPingpongIrq:1;
-	uint32_t encIrq:1;
-	uint32_t viewIrq:1;
-	uint32_t busOverflowIrq:1;
-	uint32_t afOverflowIrq:1;
-	uint32_t awbOverflowIrq:1;
-	uint32_t syncTimer0Irq:1;
-	uint32_t syncTimer1Irq:1;
-	uint32_t syncTimer2Irq:1;
-	uint32_t asyncTimer0Irq:1;
-	uint32_t asyncTimer1Irq:1;
-	uint32_t asyncTimer2Irq:1;
-	uint32_t asyncTimer3Irq:1;
-	uint32_t axiErrorIrq:1;
-	uint32_t violationIrq:1;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_upsample_cfg {
-	uint32_t chromaCositingForYCbCrInputs:1;
-	uint32_t /* reserved */ : 31;
-} __attribute__((packed, aligned(4)));
-
-struct VFE_CAMIFConfigType {
-	/* CAMIF Config */
-	uint32_t  /* reserved */ : 1;
-	uint32_t  VSyncEdge:1;
-	uint32_t  HSyncEdge:1;
-	uint32_t  syncMode:2;
-	uint32_t  vfeSubsampleEnable:1;
-	uint32_t  /* reserved */ : 1;
-	uint32_t  busSubsampleEnable:1;
-	uint32_t  camif2vfeEnable:1;
-	uint32_t  /* reserved */ : 1;
-	uint32_t  camif2busEnable:1;
-	uint32_t  irqSubsampleEnable:1;
-	uint32_t  binningEnable:1;
-	uint32_t  /* reserved */ : 18;
-	uint32_t  misrEnable:1;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_camifcfg {
-	/* EFS_Config */
-	uint32_t efsEndOfLine:8;
-	uint32_t efsStartOfLine:8;
-	uint32_t efsEndOfFrame:8;
-	uint32_t efsStartOfFrame:8;
-	/* Frame Config */
-	uint32_t frameConfigPixelsPerLine:14;
-	uint32_t /* reserved */ : 2;
-	uint32_t frameConfigLinesPerFrame:14;
-	uint32_t /* reserved */ : 2;
-	/* Window Width Config */
-	uint32_t windowWidthCfgLastPixel:14;
-	uint32_t /* reserved */ : 2;
-	uint32_t windowWidthCfgFirstPixel:14;
-	uint32_t /* reserved */ : 2;
-	/* Window Height Config */
-	uint32_t windowHeightCfglastLine:14;
-	uint32_t /* reserved */ : 2;
-	uint32_t windowHeightCfgfirstLine:14;
-	uint32_t /* reserved */ : 2;
-	/* Subsample 1 Config */
-	uint32_t subsample1CfgPixelSkip:16;
-	uint32_t subsample1CfgLineSkip:16;
-	/* Subsample 2 Config */
-	uint32_t subsample2CfgFrameSkip:4;
-	uint32_t subsample2CfgFrameSkipMode:1;
-	uint32_t subsample2CfgPixelSkipWrap:1;
-	uint32_t /* reserved */ : 26;
-	/* Epoch Interrupt */
-	uint32_t epoch1Line:14;
-	uint32_t /* reserved */ : 2;
-	uint32_t epoch2Line:14;
-	uint32_t /* reserved */ : 2;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_camifframe_update {
-	uint32_t pixelsPerLine:14;
-	uint32_t /* reserved */ : 2;
-	uint32_t linesPerFrame:14;
-	uint32_t /* reserved */ : 2;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_axi_bus_cfg {
-	uint32_t  stripeRdPathEn:1;
-	uint32_t  /* reserved */ : 3;
-	uint32_t  encYWrPathEn:1;
-	uint32_t  encCbcrWrPathEn:1;
-	uint32_t  viewYWrPathEn:1;
-	uint32_t  viewCbcrWrPathEn:1;
-	uint32_t  rawPixelDataSize:2;
-	uint32_t  rawWritePathSelect:2;
-	uint32_t  /* reserved */ : 20;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_axi_out_cfg {
-	uint32_t  out2YPingAddr:32;
-	uint32_t  out2YPongAddr:32;
-	uint32_t  out2YImageHeight:12;
-	uint32_t  /* reserved */ : 4;
-	uint32_t  out2YImageWidthin64bit:10;
-	uint32_t  /* reserved */ : 6;
-	uint32_t  out2YBurstLength:2;
-	uint32_t  /* reserved */ : 2;
-	uint32_t  out2YNumRows:12;
-	uint32_t  out2YRowIncrementIn64bit:12;
-	uint32_t  /* reserved */ : 4;
-	uint32_t  out2CbcrPingAddr:32;
-	uint32_t  out2CbcrPongAddr:32;
-	uint32_t  out2CbcrImageHeight:12;
-	uint32_t  /* reserved */ : 4;
-	uint32_t  out2CbcrImageWidthIn64bit:10;
-	uint32_t  /* reserved */ : 6;
-	uint32_t  out2CbcrBurstLength:2;
-	uint32_t  /* reserved */ : 2;
-	uint32_t  out2CbcrNumRows:12;
-	uint32_t  out2CbcrRowIncrementIn64bit:12;
-	uint32_t  /* reserved */ : 4;
-	uint32_t  out1YPingAddr:32;
-	uint32_t  out1YPongAddr:32;
-	uint32_t  out1YImageHeight:12;
-	uint32_t  /* reserved */ : 4;
-	uint32_t  out1YImageWidthin64bit:10;
-	uint32_t  /* reserved */ : 6;
-	uint32_t  out1YBurstLength:2;
-	uint32_t  /* reserved */ : 2;
-	uint32_t  out1YNumRows:12;
-	uint32_t  out1YRowIncrementIn64bit:12;
-	uint32_t  /* reserved */ : 4;
-	uint32_t  out1CbcrPingAddr:32;
-	uint32_t  out1CbcrPongAddr:32;
-	uint32_t  out1CbcrImageHeight:12;
-	uint32_t  /* reserved */ : 4;
-	uint32_t  out1CbcrImageWidthIn64bit:10;
-	uint32_t  /* reserved */ : 6;
-	uint32_t  out1CbcrBurstLength:2;
-	uint32_t  /* reserved */ : 2;
-	uint32_t  out1CbcrNumRows:12;
-	uint32_t  out1CbcrRowIncrementIn64bit:12;
-	uint32_t  /* reserved */ : 4;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_output_clamp_cfg {
-	/* Output Clamp Maximums */
-	uint32_t yChanMax:8;
-	uint32_t cbChanMax:8;
-	uint32_t crChanMax:8;
-	uint32_t /* reserved */ : 8;
-	/* Output Clamp Minimums */
-	uint32_t yChanMin:8;
-	uint32_t cbChanMin:8;
-	uint32_t crChanMin:8;
-	uint32_t /* reserved */ : 8;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_fov_crop_cfg {
-	uint32_t lastPixel:12;
-	uint32_t /* reserved */ : 4;
-	uint32_t firstPixel:12;
-	uint32_t /* reserved */ : 4;
-
-	/* FOV Corp, Part 2 */
-	uint32_t lastLine:12;
-	uint32_t /* reserved */ : 4;
-	uint32_t firstLine:12;
-	uint32_t /* reserved */ : 4;
-} __attribute__((packed, aligned(4)));
-
-struct VFE_FRAME_SKIP_UpdateCmdType {
-	uint32_t  yPattern:32;
-	uint32_t  cbcrPattern:32;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_frame_skip_cfg {
-	/* Frame Drop Enc (output2) */
-	uint32_t output2YPeriod:5;
-	uint32_t /* reserved */	: 27;
-	uint32_t output2CbCrPeriod:5;
-	uint32_t /* reserved */ : 27;
-	uint32_t output2YPattern:32;
-	uint32_t output2CbCrPattern:32;
-	/* Frame Drop View (output1) */
-	uint32_t output1YPeriod:5;
-	uint32_t /* reserved */ : 27;
-	uint32_t output1CbCrPeriod:5;
-	uint32_t /* reserved */ : 27;
-	uint32_t output1YPattern:32;
-	uint32_t output1CbCrPattern:32;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_main_scaler_cfg {
-	/* Scaler Enable Config */
-	uint32_t hEnable:1;
-	uint32_t vEnable:1;
-	uint32_t /* reserved */ : 30;
-	/* Scale H Image Size Config */
-	uint32_t inWidth:12;
-	uint32_t /* reserved */ : 4;
-	uint32_t outWidth:12;
-	uint32_t /* reserved */ : 4;
-	/* Scale H Phase Config */
-	uint32_t horizPhaseMult:18;
-	uint32_t /* reserved */ : 2;
-	uint32_t horizInterResolution:2;
-	uint32_t /* reserved */ : 10;
-	/* Scale H Stripe Config */
-	uint32_t horizMNInit:12;
-	uint32_t /* reserved */ : 4;
-	uint32_t horizPhaseInit:15;
-	uint32_t /* reserved */ : 1;
-	/* Scale V Image Size Config */
-	uint32_t inHeight:12;
-	uint32_t /* reserved */ : 4;
-	uint32_t outHeight:12;
-	uint32_t /* reserved */ : 4;
-	/* Scale V Phase Config */
-	uint32_t vertPhaseMult:18;
-	uint32_t /* reserved */ : 2;
-	uint32_t vertInterResolution:2;
-	uint32_t /* reserved */ : 10;
-	/* Scale V Stripe Config */
-	uint32_t vertMNInit:12;
-	uint32_t /* reserved */ : 4;
-	uint32_t vertPhaseInit:15;
-	uint32_t /* reserved */ : 1;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_scaler2_cfg {
-	/* Scaler   Enable Config */
-	uint32_t  hEnable:1;
-	uint32_t  vEnable:1;
-	uint32_t  /* reserved */ : 30;
-	/* Scaler   H Image Size Config */
-	uint32_t  inWidth:12;
-	uint32_t  /* reserved */ : 4;
-	uint32_t  outWidth:12;
-	uint32_t  /* reserved */ : 4;
-	/* Scaler   H Phase Config */
-	uint32_t  horizPhaseMult:18;
-	uint32_t  /* reserved */ : 2;
-	uint32_t  horizInterResolution:2;
-	uint32_t  /* reserved */ : 10;
-	/* Scaler   V Image Size Config */
-	uint32_t  inHeight:12;
-	uint32_t  /* reserved */ : 4;
-	uint32_t  outHeight:12;
-	uint32_t  /* reserved */ : 4;
-	/* Scaler   V Phase Config */
-	uint32_t  vertPhaseMult:18;
-	uint32_t  /* reserved */ : 2;
-	uint32_t  vertInterResolution:2;
-	uint32_t  /* reserved */ : 10;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_rolloff_cfg {
-	/* Rolloff 0 Config */
-	uint32_t  gridWidth:9;
-	uint32_t  gridHeight:9;
-	uint32_t  yDelta:9;
-	uint32_t  /* reserved */ : 5;
-	/* Rolloff 1 Config*/
-	uint32_t  gridX:4;
-	uint32_t  gridY:4;
-	uint32_t  pixelX:9;
-	uint32_t  /* reserved */ : 3;
-	uint32_t  pixelY:9;
-	uint32_t  /* reserved */ : 3;
-	/* Rolloff 2 Config */
-	uint32_t  yDeltaAccum:12;
-	uint32_t  /* reserved */ : 20;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_asf_update {
-	/* ASF Config Command */
-	uint32_t smoothEnable:1;
-	uint32_t sharpMode:2;
-	uint32_t /* reserved */ : 1;
-	uint32_t smoothCoeff1:4;
-	uint32_t smoothCoeff0:8;
-	uint32_t pipeFlushCount:12;
-	uint32_t pipeFlushOvd:1;
-	uint32_t flushHaltOvd:1;
-	uint32_t cropEnable:1;
-	uint32_t /* reserved */ : 1;
-	/* Sharpening Config 0 */
-	uint32_t sharpThresholdE1:7;
-	uint32_t /* reserved */ : 1;
-	uint32_t sharpDegreeK1:5;
-	uint32_t /* reserved */ : 3;
-	uint32_t sharpDegreeK2:5;
-	uint32_t /* reserved */ : 3;
-	uint32_t normalizeFactor:7;
-	uint32_t /* reserved */ : 1;
-	/* Sharpening Config 1 */
-	uint32_t sharpThresholdE2:8;
-	uint32_t sharpThresholdE3:8;
-	uint32_t sharpThresholdE4:8;
-	uint32_t sharpThresholdE5:8;
-	/* Sharpening Coefficients 0 */
-	uint32_t F1Coeff0:6;
-	uint32_t F1Coeff1:6;
-	uint32_t F1Coeff2:6;
-	uint32_t F1Coeff3:6;
-	uint32_t F1Coeff4:6;
-	uint32_t /* reserved */ : 2;
-	/* Sharpening Coefficients 1 */
-	uint32_t F1Coeff5:6;
-	uint32_t F1Coeff6:6;
-	uint32_t F1Coeff7:6;
-	uint32_t F1Coeff8:7;
-	uint32_t /* reserved */ : 7;
-	/* Sharpening Coefficients 2 */
-	uint32_t F2Coeff0:6;
-	uint32_t F2Coeff1:6;
-	uint32_t F2Coeff2:6;
-	uint32_t F2Coeff3:6;
-	uint32_t F2Coeff4:6;
-	uint32_t /* reserved */ : 2;
-	/* Sharpening Coefficients 3 */
-	uint32_t F2Coeff5:6;
-	uint32_t F2Coeff6:6;
-	uint32_t F2Coeff7:6;
-	uint32_t F2Coeff8:7;
-	uint32_t /* reserved */ : 7;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_asfcrop_cfg {
-	/* ASF Crop Width Config */
-	uint32_t lastPixel:12;
-	uint32_t /* reserved */ : 4;
-	uint32_t firstPixel:12;
-	uint32_t /* reserved */ : 4;
-	/* ASP Crop Height Config */
-	uint32_t lastLine:12;
-	uint32_t /* reserved */ : 4;
-	uint32_t firstLine:12;
-	uint32_t /* reserved */ : 4;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_chroma_suppress_cfg {
-	/* Chroma Suppress 0 Config */
-	uint32_t m1:8;
-	uint32_t m3:8;
-	uint32_t n1:3;
-	uint32_t /* reserved */ : 1;
-	uint32_t n3:3;
-	uint32_t /* reserved */ : 9;
-	/* Chroma Suppress 1 Config */
-	uint32_t mm1:8;
-	uint32_t nn1:3;
-	uint32_t /* reserved */ : 21;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_chromasubsample_cfg {
-	/* Chroma Subsample Selection */
-	uint32_t  hCositedPhase:1;
-	uint32_t  vCositedPhase:1;
-	uint32_t  hCosited:1;
-	uint32_t  vCosited:1;
-	uint32_t  hsubSampleEnable:1;
-	uint32_t  vsubSampleEnable:1;
-	uint32_t  cropEnable:1;
-	uint32_t  /* reserved */ : 25;
-	uint32_t  cropWidthLastPixel:12;
-	uint32_t  /* reserved */ : 4;
-	uint32_t  cropWidthFirstPixel:12;
-	uint32_t  /* reserved */ : 4;
-	uint32_t  cropHeightLastLine:12;
-	uint32_t  /* reserved */ : 4;
-	uint32_t  cropHeightFirstLine:12;
-	uint32_t  /* reserved */ : 4;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_blacklevel_cfg {
-	/* Black Even-Even Value Config */
-	uint32_t    evenEvenAdjustment:9;
-	uint32_t   /* reserved */ : 23;
-	/* Black Even-Odd Value Config */
-	uint32_t    evenOddAdjustment:9;
-	uint32_t   /* reserved */ : 23;
-	/* Black Odd-Even Value Config */
-	uint32_t    oddEvenAdjustment:9;
-	uint32_t   /* reserved */ : 23;
-	/* Black Odd-Odd Value Config */
-	uint32_t    oddOddAdjustment:9;
-	uint32_t   /* reserved */ : 23;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_demux_cfg {
-	/* Demux Gain 0 Config */
-	uint32_t  ch0EvenGain:10;
-	uint32_t  /* reserved */ : 6;
-	uint32_t  ch0OddGain:10;
-	uint32_t  /* reserved */ : 6;
-	/* Demux Gain 1 Config */
-	uint32_t  ch1Gain:10;
-	uint32_t  /* reserved */ : 6;
-	uint32_t  ch2Gain:10;
-	uint32_t  /* reserved */ : 6;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_bps_info {
-  uint32_t greenBadPixelCount:8;
-  uint32_t /* reserved */ : 8;
-  uint32_t RedBlueBadPixelCount:8;
-  uint32_t /* reserved */ : 8;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_demosaic_cfg {
-	/* Demosaic Config */
-	uint32_t abfEnable:1;
-	uint32_t badPixelCorrEnable:1;
-	uint32_t forceAbfOn:1;
-	uint32_t /* reserved */ : 1;
-	uint32_t abfShift:4;
-	uint32_t fminThreshold:7;
-	uint32_t /* reserved */ : 1;
-	uint32_t fmaxThreshold:7;
-	uint32_t /* reserved */ : 5;
-	uint32_t slopeShift:3;
-	uint32_t /* reserved */ : 1;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_demosaic_bpc_cfg {
-	/* Demosaic BPC Config 0 */
-	uint32_t blueDiffThreshold:12;
-	uint32_t redDiffThreshold:12;
-	uint32_t /* reserved */ : 8;
-	/* Demosaic BPC Config 1 */
-	uint32_t greenDiffThreshold:12;
-	uint32_t /* reserved */ : 20;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_demosaic_abf_cfg {
-	/* Demosaic ABF Config 0 */
-	uint32_t lpThreshold:10;
-	uint32_t /* reserved */ : 22;
-	/* Demosaic ABF Config 1 */
-	uint32_t ratio:4;
-	uint32_t minValue:10;
-	uint32_t /* reserved */ : 2;
-	uint32_t maxValue:10;
-	uint32_t /* reserved */ : 6;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_color_correction_cfg {
-	/* Color Corr. Coefficient 0 Config */
-	uint32_t   c0:12;
-	uint32_t   /* reserved */ : 20;
-	/* Color Corr. Coefficient 1 Config */
-	uint32_t   c1:12;
-	uint32_t   /* reserved */ : 20;
-	/* Color Corr. Coefficient 2 Config */
-	uint32_t   c2:12;
-	uint32_t   /* reserved */ : 20;
-	/* Color Corr. Coefficient 3 Config */
-	uint32_t   c3:12;
-	uint32_t   /* reserved */ : 20;
-	/* Color Corr. Coefficient 4 Config */
-	uint32_t   c4:12;
-	uint32_t   /* reserved */ : 20;
-	/* Color Corr. Coefficient 5 Config */
-	uint32_t   c5:12;
-	uint32_t   /* reserved */ : 20;
-	/* Color Corr. Coefficient 6 Config */
-	uint32_t   c6:12;
-	uint32_t   /* reserved */ : 20;
-	/* Color Corr. Coefficient 7 Config */
-	uint32_t   c7:12;
-	uint32_t   /* reserved */ : 20;
-	/* Color Corr. Coefficient 8 Config */
-	uint32_t   c8:12;
-	uint32_t   /* reserved */ : 20;
-	/* Color Corr. Offset 0 Config */
-	uint32_t   k0:11;
-	uint32_t   /* reserved */ : 21;
-	/* Color Corr. Offset 1 Config */
-	uint32_t   k1:11;
-	uint32_t   /* reserved */ : 21;
-	/* Color Corr. Offset 2 Config */
-	uint32_t   k2:11;
-	uint32_t   /* reserved */ : 21;
-	/* Color Corr. Coefficient Q Config */
-	uint32_t   coefQFactor:2;
-	uint32_t   /* reserved */ : 30;
-} __attribute__((packed, aligned(4)));
-
-struct VFE_LumaAdaptation_ConfigCmdType {
-	/* LA Config */
-	uint32_t   lutBankSelect:1;
-	uint32_t   /* reserved */ : 31;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_wb_cfg {
-	/* WB Config */
-	uint32_t ch0Gain:9;
-	uint32_t ch1Gain:9;
-	uint32_t ch2Gain:9;
-	uint32_t /* reserved */ : 5;
-} __attribute__((packed, aligned(4)));
-
-struct VFE_GammaLutSelect_ConfigCmdType {
-	/* LUT Bank Select Config */
-	uint32_t   ch0BankSelect:1;
-	uint32_t   ch1BankSelect:1;
-	uint32_t   ch2BankSelect:1;
-	uint32_t   /* reserved */ : 29;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_chroma_enhance_cfg {
-	/* Chroma Enhance A Config */
-	uint32_t ap:11;
-	uint32_t /* reserved */ : 5;
-	uint32_t am:11;
-	uint32_t /* reserved */ : 5;
-	/* Chroma Enhance B Config */
-	uint32_t bp:11;
-	uint32_t /* reserved */ : 5;
-	uint32_t bm:11;
-	uint32_t /* reserved */ : 5;
-	/* Chroma Enhance C Config */
-	uint32_t cp:11;
-	uint32_t /* reserved */ : 5;
-	uint32_t cm:11;
-	uint32_t /* reserved */ : 5;
-	/* Chroma Enhance D Config */
-	uint32_t dp:11;
-	uint32_t /* reserved */ : 5;
-	uint32_t dm:11;
-	uint32_t /* reserved */ : 5;
-	/* Chroma Enhance K Config */
-	uint32_t kcb:11;
-	uint32_t /* reserved */ : 5;
-	uint32_t kcr:11;
-	uint32_t /* reserved */ : 5;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_color_convert_cfg {
-	/* Conversion Coefficient 0 */
-	uint32_t v0:12;
-	uint32_t /* reserved */ : 20;
-	/* Conversion Coefficient 1 */
-	uint32_t v1:12;
-	uint32_t /* reserved */ : 20;
-	/* Conversion Coefficient 2 */
-	uint32_t v2:12;
-	uint32_t /* reserved */ : 20;
-	/* Conversion Offset */
-	uint32_t ConvertOffset:8;
-	uint32_t /* reserved */ : 24;
-} __attribute__((packed, aligned(4)));
-
-struct VFE_SyncTimer_ConfigCmdType {
-	/* Timer Line Start Config */
-	uint32_t       timerLineStart:12;
-	uint32_t       /* reserved */ : 20;
-	/* Timer Pixel Start Config */
-	uint32_t       timerPixelStart:18;
-	uint32_t       /* reserved */ : 14;
-	/* Timer Pixel Duration Config */
-	uint32_t       timerPixelDuration:28;
-	uint32_t       /* reserved */ : 4;
-	/* Sync Timer Polarity Config */
-	uint32_t       timer0Polarity:1;
-	uint32_t       timer1Polarity:1;
-	uint32_t       timer2Polarity:1;
-	uint32_t       /* reserved */ : 29;
-} __attribute__((packed, aligned(4)));
-
-struct VFE_AsyncTimer_ConfigCmdType {
-	/* Async Timer Config 0 */
-	uint32_t     inactiveLength:20;
-	uint32_t     numRepetition:10;
-	uint32_t     /* reserved */ : 1;
-	uint32_t     polarity:1;
-	/* Async Timer Config 1 */
-	uint32_t     activeLength:20;
-	uint32_t     /* reserved */ : 12;
-} __attribute__((packed, aligned(4)));
-
-struct VFE_AWBAEStatistics_ConfigCmdType {
-	/* AWB autoexposure Config */
-	uint32_t    aeRegionConfig:1;
-	uint32_t    aeSubregionConfig:1;
-	uint32_t    /* reserved */ : 14;
-	uint32_t    awbYMin:8;
-	uint32_t    awbYMax:8;
-	/* AXW Header */
-	uint32_t    axwHeader:8;
-	uint32_t    /* reserved */ : 24;
-	/* AWB Mconfig */
-	uint32_t    m4:8;
-	uint32_t    m3:8;
-	uint32_t    m2:8;
-	uint32_t    m1:8;
-	/* AWB Cconfig */
-	uint32_t    c2:12;
-	uint32_t    /* reserved */ : 4;
-	uint32_t    c1:12;
-	uint32_t    /* reserved */ : 4;
-	/* AWB Cconfig 2 */
-	uint32_t    c4:12;
-	uint32_t    /* reserved */ : 4;
-	uint32_t    c3:12;
-	uint32_t    /* reserved */ : 4;
-} __attribute__((packed, aligned(4)));
-
-struct VFE_TestGen_ConfigCmdType {
-	/* HW Test Gen Config */
-	uint32_t   numFrame:10;
-	uint32_t   /* reserved */ : 2;
-	uint32_t   pixelDataSelect:1;
-	uint32_t   systematicDataSelect:1;
-	uint32_t   /* reserved */ : 2;
-	uint32_t   pixelDataSize:2;
-	uint32_t   hsyncEdge:1;
-	uint32_t   vsyncEdge:1;
-	uint32_t   /* reserved */ : 12;
-	/* HW Test Gen Image Config */
-	uint32_t   imageWidth:14;
-	uint32_t   /* reserved */ : 2;
-	uint32_t   imageHeight:14;
-	uint32_t   /* reserved */ : 2;
-	/* SOF Offset Config */
-	uint32_t   sofOffset:24;
-	uint32_t   /* reserved */ : 8;
-	/* EOF NOffset Config */
-	uint32_t   eofNOffset:24;
-	uint32_t   /* reserved */ : 8;
-	/* SOL Offset Config */
-	uint32_t   solOffset:9;
-	uint32_t   /* reserved */ : 23;
-	/* EOL NOffset Config */
-	uint32_t   eolNOffset:9;
-	uint32_t   /* reserved */ : 23;
-	/* HBI Config */
-	uint32_t   hBlankInterval:14;
-	uint32_t   /* reserved */ : 18;
-	/* VBL Config */
-	uint32_t   vBlankInterval:14;
-	uint32_t   /* reserved */ : 2;
-	uint32_t   vBlankIntervalEnable:1;
-	uint32_t   /* reserved */ : 15;
-	/* SOF Dummy Line Config */
-	uint32_t   sofDummy:8;
-	uint32_t   /* reserved */ : 24;
-	/* EOF Dummy Line Config */
-	uint32_t   eofDummy:8;
-	uint32_t   /* reserved */ : 24;
-	/* Color Bars Config */
-	uint32_t   unicolorBarSelect:3;
-	uint32_t   /* reserved */ : 1;
-	uint32_t   unicolorBarEnable:1;
-	uint32_t   splitEnable:1;
-	uint32_t   pixelPattern:2;
-	uint32_t   rotatePeriod:6;
-	uint32_t   /* reserved */ : 18;
-	/* Random Config */
-	uint32_t   randomSeed:16;
-	uint32_t   /* reserved */ : 16;
-} __attribute__((packed, aligned(4)));
-
-struct VFE_Bus_Pm_ConfigCmdType {
-	/* VFE Bus Performance Monitor Config */
-	uint32_t  output2YWrPmEnable:1;
-	uint32_t  output2CbcrWrPmEnable:1;
-	uint32_t  output1YWrPmEnable:1;
-	uint32_t  output1CbcrWrPmEnable:1;
-	uint32_t  /* reserved */ : 28;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_asf_info {
-	/* asf max edge  */
-	uint32_t maxEdge:13;
-	uint32_t /* reserved */ : 3;
-	/* HBi count  */
-	uint32_t HBICount:12;
-	uint32_t /* reserved */ : 4;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_camif_stats {
-  uint32_t  pixelCount:14;
-  uint32_t  /* reserved */ : 2;
-  uint32_t  lineCount:14;
-  uint32_t  /* reserved */ : 1;
-  uint32_t  camifHalt:1;
-} __attribute__((packed, aligned(4)));
-
-struct VFE_StatsCmdType {
-	uint32_t  autoFocusEnable:1;
-	uint32_t  axwEnable:1;
-	uint32_t  histEnable:1;
-	uint32_t  clearHistEnable:1;
-	uint32_t  histAutoClearEnable:1;
-	uint32_t  colorConversionEnable:1;
-	uint32_t  /* reserved */ : 26;
-} __attribute__((packed, aligned(4)));
-
-
-struct vfe_statsframe {
-	uint32_t lastPixel:12;
-	uint32_t /* reserved */ : 4;
-	uint32_t lastLine:12;
-	uint32_t /* reserved */ : 4;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_busstats_wrprio {
-	uint32_t afBusPriority:4;
-	uint32_t awbBusPriority:4;
-	uint32_t histBusPriority:4;
-	uint32_t afBusPriorityEn:1;
-	uint32_t awbBusPriorityEn:1;
-	uint32_t histBusPriorityEn:1;
-	uint32_t /* reserved */ : 17;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_statsaf_update {
-	/* VFE_STATS_AF_CFG */
-	uint32_t windowVOffset:12;
-	uint32_t /* reserved */ : 4;
-	uint32_t windowHOffset:12;
-	uint32_t /* reserved */ : 3;
-	uint32_t windowMode:1;
-
-	/* VFE_STATS_AF_DIM */
-	uint32_t windowHeight:12;
-	uint32_t /* reserved */ : 4;
-	uint32_t windowWidth:12;
-	uint32_t /* reserved */ : 4;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_statsaf_cfg {
-	/* VFE_STATS_AF_GRID_0 */
-	uint32_t  entry00:8;
-	uint32_t  entry01:8;
-	uint32_t  entry02:8;
-	uint32_t  entry03:8;
-
-	/* VFE_STATS_AF_GRID_1 */
-	uint32_t  entry10:8;
-	uint32_t  entry11:8;
-	uint32_t  entry12:8;
-	uint32_t  entry13:8;
-
-	/* VFE_STATS_AF_GRID_2 */
-	uint32_t  entry20:8;
-	uint32_t  entry21:8;
-	uint32_t  entry22:8;
-	uint32_t  entry23:8;
-
-	/* VFE_STATS_AF_GRID_3 */
-	uint32_t  entry30:8;
-	uint32_t  entry31:8;
-	uint32_t  entry32:8;
-	uint32_t  entry33:8;
-
-	/* VFE_STATS_AF_HEADER */
-	uint32_t  afHeader:8;
-	uint32_t  /* reserved */ : 24;
-	/*  VFE_STATS_AF_COEF0 */
-	uint32_t  a00:5;
-	uint32_t  a04:5;
-	uint32_t  fvMax:11;
-	uint32_t  fvMetric:1;
-	uint32_t  /* reserved */ : 10;
-
-	/* VFE_STATS_AF_COEF1 */
-	uint32_t  a20:5;
-	uint32_t  a21:5;
-	uint32_t  a22:5;
-	uint32_t  a23:5;
-	uint32_t  a24:5;
-	uint32_t  /* reserved */ : 7;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_statsawbae_update {
-	uint32_t  aeRegionCfg:1;
-	uint32_t  aeSubregionCfg:1;
-	uint32_t  /* reserved */ : 14;
-	uint32_t  awbYMin:8;
-	uint32_t  awbYMax:8;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_statsaxw_hdr_cfg {
-	/* Stats AXW Header Config */
-	uint32_t axwHeader:8;
-	uint32_t /* reserved */ : 24;
-} __attribute__((packed, aligned(4)));
-
-struct vfe_statsawb_update {
-	/* AWB MConfig */
-	uint32_t  m4:8;
-	uint32_t  m3:8;
-	uint32_t  m2:8;
-	uint32_t  m1:8;
-
-	/* AWB CConfig1 */
-	uint32_t  c2:12;
-	uint32_t  /* reserved */ : 4;
-	uint32_t  c1:12;
-	uint32_t  /* reserved */ : 4;
-
-	/* AWB CConfig2 */
-	uint32_t  c4:12;
-	uint32_t  /* reserved */ : 4;
-	uint32_t  c3:12;
-	uint32_t  /* reserved */ : 4;
-} __attribute__((packed, aligned(4)));
-
-struct VFE_SyncTimerCmdType {
-	uint32_t  hsyncCount:12;
-	uint32_t  /* reserved */ : 20;
-	uint32_t  pclkCount:18;
-	uint32_t  /* reserved */ : 14;
-	uint32_t  outputDuration:28;
-	uint32_t  /* reserved */ : 4;
-} __attribute__((packed, aligned(4)));
-
-struct VFE_AsyncTimerCmdType {
-	/*  config 0 */
-	uint32_t    inactiveCount:20;
-	uint32_t    repeatCount:10;
-	uint32_t    /* reserved */ : 1;
-	uint32_t    polarity:1;
-	/*  config 1 */
-	uint32_t    activeCount:20;
-	uint32_t    /* reserved */ : 12;
-} __attribute__((packed, aligned(4)));
-
-struct VFE_AxiInputCmdType {
-	uint32_t   stripeStartAddr0:32;
-	uint32_t   stripeStartAddr1:32;
-	uint32_t   stripeStartAddr2:32;
-	uint32_t   stripeStartAddr3:32;
-
-	uint32_t   ySize:12;
-	uint32_t   yOffsetDelta:12;
-	uint32_t   /* reserved */ : 8;
-
-	/* bus_stripe_rd_hSize */
-	uint32_t   /* reserved */ : 16;
-	uint32_t   xSizeWord:10;
-	uint32_t   /* reserved */ : 6;
-
-	/* bus_stripe_rd_buffer_cfg */
-	uint32_t   burstLength:2;
-	uint32_t   /* reserved */ : 2;
-	uint32_t   NumOfRows:12;
-	uint32_t   RowIncrement:12;
-	uint32_t   /* reserved */ : 4;
-
-	/* bus_stripe_rd_unpack_cfg */
-	uint32_t   mainUnpackHeight:12;
-	uint32_t   mainUnpackWidth:13;
-	uint32_t   mainUnpackHbiSel:3;
-	uint32_t   mainUnpackPhase:3;
-	uint32_t   /* reserved */ : 1;
-
-	/* bus_stripe_rd_unpack */
-	uint32_t   unpackPattern:32;
-
-	/* bus_stripe_rd_pad_size */
-	uint32_t   padLeft:7;
-	uint32_t   /* reserved */ : 1;
-	uint32_t   padRight:7;
-	uint32_t   /* reserved */ : 1;
-	uint32_t   padTop:7;
-	uint32_t   /* reserved */ : 1;
-	uint32_t   padBottom:7;
-	uint32_t   /* reserved */ : 1;
-
-	/* bus_stripe_rd_pad_L_unpack */
-	uint32_t   leftUnpackPattern0:4;
-	uint32_t   leftUnpackPattern1:4;
-	uint32_t   leftUnpackPattern2:4;
-	uint32_t   leftUnpackPattern3:4;
-	uint32_t   leftUnpackStop0:1;
-	uint32_t   leftUnpackStop1:1;
-	uint32_t   leftUnpackStop2:1;
-	uint32_t   leftUnpackStop3:1;
-	uint32_t   /* reserved */ : 12;
-
-	/* bus_stripe_rd_pad_R_unpack */
-	uint32_t   rightUnpackPattern0:4;
-	uint32_t   rightUnpackPattern1:4;
-	uint32_t   rightUnpackPattern2:4;
-	uint32_t   rightUnpackPattern3:4;
-	uint32_t   rightUnpackStop0:1;
-	uint32_t   rightUnpackStop1:1;
-	uint32_t   rightUnpackStop2:1;
-	uint32_t   rightUnpackStop3:1;
-	uint32_t   /* reserved */ : 12;
-
-	/* bus_stripe_rd_pad_tb_unpack */
-	uint32_t   topUnapckPattern:4;
-	uint32_t   /* reserved */ : 12;
-	uint32_t   bottomUnapckPattern:4;
-	uint32_t   /* reserved */ : 12;
-} __attribute__((packed, aligned(4)));
-
-struct VFE_AxiRdFragIrqEnable {
-	uint32_t stripeRdFragirq0Enable:1;
-	uint32_t stripeRdFragirq1Enable:1;
-	uint32_t stripeRdFragirq2Enable:1;
-	uint32_t stripeRdFragirq3Enable:1;
-	uint32_t   /* reserved */ : 28;
-} __attribute__((packed, aligned(4)));
-
-int vfe_cmd_init(struct msm_vfe_callback *, struct platform_device *, void *);
-void vfe_stats_af_stop(void);
-void vfe_stop(void);
-void vfe_update(void);
-int vfe_rgb_gamma_update(struct vfe_cmd_rgb_gamma_config *);
-int vfe_rgb_gamma_config(struct vfe_cmd_rgb_gamma_config *);
-void vfe_stats_wb_exp_ack(struct vfe_cmd_stats_wb_exp_ack *);
-void vfe_stats_af_ack(struct vfe_cmd_stats_af_ack *);
-void vfe_start(struct vfe_cmd_start *);
-void vfe_la_update(struct vfe_cmd_la_config *);
-void vfe_la_config(struct vfe_cmd_la_config *);
-void vfe_test_gen_start(struct vfe_cmd_test_gen_start *);
-void vfe_frame_skip_update(struct vfe_cmd_frame_skip_update *);
-void vfe_frame_skip_config(struct vfe_cmd_frame_skip_config *);
-void vfe_output_clamp_config(struct vfe_cmd_output_clamp_config *);
-void vfe_camif_frame_update(struct vfe_cmds_camif_frame *);
-void vfe_color_correction_config(struct vfe_cmd_color_correction_config *);
-void vfe_demosaic_abf_update(struct vfe_cmd_demosaic_abf_update *);
-void vfe_demosaic_bpc_update(struct vfe_cmd_demosaic_bpc_update *);
-void vfe_demosaic_config(struct vfe_cmd_demosaic_config *);
-void vfe_demux_channel_gain_update(struct vfe_cmd_demux_channel_gain_config *);
-void vfe_demux_channel_gain_config(struct vfe_cmd_demux_channel_gain_config *);
-void vfe_black_level_update(struct vfe_cmd_black_level_config *);
-void vfe_black_level_config(struct vfe_cmd_black_level_config *);
-void vfe_asf_update(struct vfe_cmd_asf_update *);
-void vfe_asf_config(struct vfe_cmd_asf_config *);
-void vfe_white_balance_config(struct vfe_cmd_white_balance_config *);
-void vfe_chroma_sup_config(struct vfe_cmd_chroma_suppression_config *);
-void vfe_roll_off_config(struct vfe_cmd_roll_off_config *);
-void vfe_chroma_subsample_config(struct vfe_cmd_chroma_subsample_config *);
-void vfe_chroma_enhan_config(struct vfe_cmd_chroma_enhan_config *);
-void vfe_scaler2cbcr_config(struct vfe_cmd_scaler2_config *);
-void vfe_scaler2y_config(struct vfe_cmd_scaler2_config *);
-void vfe_main_scaler_config(struct vfe_cmd_main_scaler_config *);
-void vfe_stats_wb_exp_stop(void);
-void vfe_stats_update_wb_exp(struct vfe_cmd_stats_wb_exp_update *);
-void vfe_stats_update_af(struct vfe_cmd_stats_af_update *);
-void vfe_stats_start_wb_exp(struct vfe_cmd_stats_wb_exp_start *);
-void vfe_stats_start_af(struct vfe_cmd_stats_af_start *);
-void vfe_stats_setting(struct vfe_cmd_stats_setting *);
-void vfe_axi_input_config(struct vfe_cmd_axi_input_config *);
-void vfe_axi_output_config(struct vfe_cmd_axi_output_config *);
-void vfe_camif_config(struct vfe_cmd_camif_config *);
-void vfe_fov_crop_config(struct vfe_cmd_fov_crop_config *);
-void vfe_get_hw_version(struct vfe_cmd_hw_version *);
-void vfe_reset(void);
-void vfe_cmd_release(struct platform_device *);
-void vfe_output_p_ack(struct vfe_cmd_output_ack *);
-void vfe_output_v_ack(struct vfe_cmd_output_ack *);
-#endif /* __MSM_VFE8X_REG_H__ */
diff --git a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe_stats_buf.c b/drivers/media/platform/msm/camera_v1/vfe/msm_vfe_stats_buf.c
deleted file mode 100644
index a550d78..0000000
--- a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe_stats_buf.c
+++ /dev/null
@@ -1,476 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/workqueue.h>
-#include <linux/delay.h>
-#include <linux/types.h>
-#include <linux/list.h>
-#include <linux/ioctl.h>
-#include <linux/spinlock.h>
-#include <linux/videodev2.h>
-#include <linux/proc_fs.h>
-#include <linux/vmalloc.h>
-
-#include <media/v4l2-dev.h>
-#include <media/v4l2-ioctl.h>
-#include <media/v4l2-device.h>
-
-
-#include <media/msm_camera.h>
-#include <media/msm_isp.h>
-#include "msm.h"
-#include "msm_vfe_stats_buf.h"
-
-#ifdef CONFIG_MSM_CAMERA_DEBUG
-	#define D(fmt, args...) pr_debug("msm_stats: " fmt, ##args)
-#else
-	#define D(fmt, args...) do {} while (0)
-#endif
-
-static int msm_stats_init(struct msm_stats_bufq_ctrl *stats_ctrl)
-{
-	int rc = 0;
-	/* cannot get spinlock here */
-	if (stats_ctrl->init_done > 0) {
-		pr_err("%s: already initialized stats ctrl. no op", __func__);
-		return 0;
-	}
-	memset(stats_ctrl,  0,  sizeof(struct msm_stats_bufq_ctrl));
-	spin_lock_init(&stats_ctrl->lock);
-	stats_ctrl->init_done = 1;
-	return rc;
-}
-
-static int msm_stats_reqbuf(struct msm_stats_bufq_ctrl *stats_ctrl,
-	struct msm_stats_reqbuf *reqbuf,
-	struct ion_client *client)
-{
-	int rc = 0;
-	struct msm_stats_bufq *bufq;
-	struct msm_stats_meta_buf *bufs;
-	int idx = reqbuf->stats_type;
-	int i;
-
-	D("%s: type : %d, buf num : %d\n", __func__,
-		reqbuf->stats_type, reqbuf->num_buf);
-	if (reqbuf->num_buf > 0) {
-		if (stats_ctrl->bufq[idx]) {
-			/* already in use. Error */
-			pr_err("%s: stats type %d aleady requested",
-				 __func__, reqbuf->stats_type);
-			rc = -EEXIST;
-			goto end;
-		} else {
-			/* good case */
-			bufq = (struct msm_stats_bufq *)
-				kzalloc(
-					sizeof(struct msm_stats_bufq),
-					GFP_KERNEL);
-			if (!bufq) {
-				/* no memory */
-				rc = -ENOMEM;
-				pr_err("%s: no mem for stats type %d",
-					__func__, reqbuf->stats_type);
-				goto end;
-			}
-			bufs = (struct msm_stats_meta_buf *)
-				kzalloc((reqbuf->num_buf *
-					sizeof(struct msm_stats_meta_buf)),
-					GFP_KERNEL);
-			if (!bufs) {
-				/* no memory */
-				rc = -ENOMEM;
-				pr_err("%s: no mem for stats buf, stats type = %d",
-					__func__, reqbuf->stats_type);
-				kfree(bufq);
-				goto end;
-			}
-			/* init bufq list head */
-			INIT_LIST_HEAD(&bufq->head);
-			/* set the meta buf state to initialized */
-			bufq->num_bufs = reqbuf->num_buf;
-			for (i = 0; i < reqbuf->num_buf; i++)
-				bufs[i].state =
-					MSM_STATS_BUFFER_STATE_INITIALIZED;
-			bufq->bufs = bufs;
-			bufq->num_bufs = reqbuf->num_buf;
-			bufq->type = reqbuf->stats_type;
-			stats_ctrl->bufq[idx] = bufq;
-			/* done reqbuf (larger than zero case) */
-			goto end;
-		}
-	} else if (reqbuf->num_buf == 0) {
-		if (stats_ctrl->bufq[idx] == NULL) {
-			/* double free case? */
-			pr_err("%s: stats type %d aleady freed",
-				 __func__, reqbuf->stats_type);
-			rc = -ENXIO;
-			goto end;
-		} else {
-			/* good case. need to de-reqbuf */
-			kfree(stats_ctrl->bufq[idx]->bufs);
-			kfree(stats_ctrl->bufq[idx]);
-			stats_ctrl->bufq[idx] = NULL;
-			goto end;
-		}
-	} else {
-		/* error case */
-		pr_err("%s: stats type = %d, req_num_buf = %d, error",
-			   __func__, reqbuf->stats_type, reqbuf->num_buf);
-		rc = -EPERM;
-		goto end;
-	}
-end:
-	return rc;
-}
-static int msm_stats_deinit(struct msm_stats_bufq_ctrl *stats_ctrl)
-{
-	int rc = 0;
-	int i;
-
-	if (stats_ctrl->init_done == 0) {
-		pr_err("%s: not inited yet. no op", __func__);
-		return 0;
-	}
-	/* safe guard in case deallocate memory not done yet. */
-	for (i = 0; i < MSM_STATS_TYPE_MAX; i++) {
-		if (stats_ctrl->bufq[i]) {
-			if (stats_ctrl->bufq[i]->bufs) {
-				rc = -1;
-				pr_err("%s: stats type = %d, buf not freed yet",
-					 __func__, i);
-				BUG_ON(stats_ctrl->bufq[i]->bufs);
-			} else {
-				rc = -1;
-				pr_err("%s: stats type = %d, bufq not freed yet",
-					__func__, i);
-				BUG_ON(stats_ctrl->bufq[i]);
-			}
-		}
-	}
-	memset(stats_ctrl,  0,  sizeof(struct msm_stats_bufq_ctrl));
-	return rc;
-}
-
-static int msm_stats_buf_prepare(struct msm_stats_bufq_ctrl *stats_ctrl,
-	struct msm_stats_buf_info *info, struct ion_client *client,
-	int domain_num)
-{
-	unsigned long paddr;
-#ifndef CONFIG_MSM_MULTIMEDIA_USE_ION
-	unsigned long kvstart;
-	struct file *file;
-#endif
-	int rc = 0;
-	unsigned long len;
-	struct msm_stats_bufq *bufq = NULL;
-	struct msm_stats_meta_buf *stats_buf = NULL;
-
-	D("%s: type : %d, buf num : %d\n", __func__,
-		info->type, info->buf_idx);
-
-	bufq = stats_ctrl->bufq[info->type];
-	stats_buf = &bufq->bufs[info->buf_idx];
-	if (stats_buf->state == MSM_STATS_BUFFER_STATE_UNUSED) {
-		pr_err("%s: need reqbuf first, stats type = %d",
-			__func__, info->type);
-		rc = -1;
-		goto out1;
-	}
-	if (stats_buf->state != MSM_STATS_BUFFER_STATE_INITIALIZED) {
-		D("%s: stats already mapped, no op, stats type = %d",
-			__func__, info->type);
-		goto out1;
-	}
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-	stats_buf->handle = ion_import_dma_buf(client, info->fd);
-	if (IS_ERR_OR_NULL(stats_buf->handle)) {
-		rc = -EINVAL;
-		pr_err("%s: stats_buf has null/error ION handle %p",
-			   __func__, stats_buf->handle);
-		goto out1;
-	}
-	if (ion_map_iommu(client, stats_buf->handle,
-			domain_num, 0, SZ_4K,
-			0, &paddr, &len, 0, 0) < 0) {
-		rc = -EINVAL;
-		pr_err("%s: cannot map address", __func__);
-		goto out2;
-	}
-#else
-	paddr = 0;
-	file = NULL;
-	kvstart = 0;
-#endif
-	if (!info->len)
-		info->len = len;
-	paddr += info->offset;
-	len = info->len;
-	stats_buf->paddr = paddr;
-	stats_buf->len = len;
-	memcpy(&stats_buf->info, info, sizeof(stats_buf->info));
-	D("%s Adding buf to list with type %d\n", __func__,
-	  stats_buf->info.type);
-	D("%s pmem_stats address is 0x%ld\n", __func__, paddr);
-	stats_buf->state = MSM_STATS_BUFFER_STATE_PREPARED;
-	return 0;
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-	ion_unmap_iommu(client, stats_buf->handle, domain_num, 0);
-#endif
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-out2:
-	ion_free(client, stats_buf->handle);
-#endif
-out1:
-	return rc;
-}
-static int msm_stats_buf_unprepare(struct msm_stats_bufq_ctrl *stats_ctrl,
-	enum msm_stats_enum_type stats_type, int buf_idx,
-	struct ion_client *client, int domain_num)
-{
-	int rc = 0;
-	struct msm_stats_bufq *bufq = NULL;
-	struct msm_stats_meta_buf *stats_buf = NULL;
-
-	D("%s: type : %d, idx : %d\n", __func__, stats_type, buf_idx);
-	bufq = stats_ctrl->bufq[stats_type];
-	stats_buf = &bufq->bufs[buf_idx];
-	if (stats_buf->state == MSM_STATS_BUFFER_STATE_UNUSED) {
-		pr_err("%s: need reqbuf first, stats type = %d",
-			__func__, stats_type);
-		rc = -1;
-		goto end;
-	}
-	if (stats_buf->state == MSM_STATS_BUFFER_STATE_INITIALIZED) {
-		D("%s: stats already mapped, no op, stats type = %d",
-			__func__, stats_type);
-		goto end;
-	}
-#ifdef CONFIG_MSM_MULTIMEDIA_USE_ION
-	ion_unmap_iommu(client, stats_buf->handle,
-					domain_num, 0);
-	ion_free(client, stats_buf->handle);
-#endif
-	if (stats_buf->state == MSM_STATS_BUFFER_STATE_QUEUED) {
-		/* buf queued need delete from list */
-		D("%s: delete stats buf, type = %d, idx = %d",
-		  __func__,  stats_type,  buf_idx);
-		list_del_init(&stats_buf->list);
-	}
-end:
-	return rc;
-}
-
-static int msm_stats_bufq_flush(struct msm_stats_bufq_ctrl *stats_ctrl,
-	enum msm_stats_enum_type stats_type, struct ion_client *client)
-{
-	int rc = 0;
-	int i;
-	struct msm_stats_bufq *bufq = NULL;
-	struct msm_stats_meta_buf *stats_buf = NULL;
-
-	D("%s: type : %d\n", __func__, stats_type);
-	bufq = stats_ctrl->bufq[stats_type];
-
-	for (i = 0; i < bufq->num_bufs; i++) {
-		stats_buf = &bufq->bufs[i];
-		switch (stats_buf->state) {
-		case MSM_STATS_BUFFER_STATE_QUEUED:
-			/* buf queued in stats free queue */
-			stats_buf->state = MSM_STATS_BUFFER_STATE_PREPARED;
-			list_del_init(&stats_buf->list);
-			break;
-		case MSM_STATS_BUFFER_STATE_DEQUEUED:
-			/* if stats buf in VFE reset the state */
-			stats_buf->state = MSM_STATS_BUFFER_STATE_PREPARED;
-			break;
-		case MSM_STATS_BUFFER_STATE_DISPATCHED:
-			/* if stats buf in userspace reset the state */
-			stats_buf->state = MSM_STATS_BUFFER_STATE_PREPARED;
-			break;
-		default:
-			break;
-		}
-	}
-	return rc;
-}
-
-static int msm_stats_dqbuf(struct msm_stats_bufq_ctrl *stats_ctrl,
-	enum msm_stats_enum_type stats_type,
-	struct msm_stats_meta_buf **pp_stats_buf)
-{
-	int rc = 0;
-	struct msm_stats_bufq *bufq = NULL;
-	struct msm_stats_meta_buf *stats_buf = NULL;
-
-	D("%s: type : %d\n", __func__, stats_type);
-	*pp_stats_buf = NULL;
-	bufq = stats_ctrl->bufq[stats_type];
-
-	list_for_each_entry(stats_buf, &bufq->head, list) {
-		if (stats_buf->state == MSM_STATS_BUFFER_STATE_QUEUED) {
-			/* found one buf */
-			list_del_init(&stats_buf->list);
-			*pp_stats_buf = stats_buf;
-			break;
-		}
-	}
-	if (!(*pp_stats_buf)) {
-		D("%s: no free stats buf, type = %d",
-			__func__, stats_type);
-		rc = -1;
-		return rc;
-	}
-	stats_buf->state = MSM_STATS_BUFFER_STATE_DEQUEUED;
-	return rc;
-}
-
-
-static int msm_stats_querybuf(struct msm_stats_bufq_ctrl *stats_ctrl,
-	struct msm_stats_buf_info *info,
-	struct msm_stats_meta_buf **pp_stats_buf)
-{
-	int rc = 0;
-	struct msm_stats_bufq *bufq = NULL;
-
-	*pp_stats_buf = NULL;
-	D("%s: stats type : %d, buf_idx : %d", __func__, info->type,
-		   info->buf_idx);
-	bufq = stats_ctrl->bufq[info->type];
-	*pp_stats_buf = &bufq->bufs[info->buf_idx];
-
-	return rc;
-}
-
-static int msm_stats_qbuf(struct msm_stats_bufq_ctrl *stats_ctrl,
-	enum msm_stats_enum_type stats_type,
-	int buf_idx)
-{
-	int rc = 0;
-	struct msm_stats_bufq *bufq = NULL;
-	struct msm_stats_meta_buf *stats_buf = NULL;
-	D("%s: stats type : %d, buf_idx : %d", __func__, stats_type,
-		   buf_idx);
-
-	bufq = stats_ctrl->bufq[stats_type];
-	if (!bufq) {
-		pr_err("%s: null bufq, stats type = %d", __func__, stats_type);
-		rc = -1;
-		goto end;
-	}
-	if (buf_idx >= bufq->num_bufs) {
-		pr_err("%s: stats type = %d, its idx %d larger than buf count %d",
-			   __func__, stats_type, buf_idx, bufq->num_bufs);
-		rc = -1;
-		goto end;
-	}
-	stats_buf = &bufq->bufs[buf_idx];
-	switch (stats_buf->state) {
-	case MSM_STATS_BUFFER_STATE_PREPARED:
-	case MSM_STATS_BUFFER_STATE_DEQUEUED:
-	case MSM_STATS_BUFFER_STATE_DISPATCHED:
-		stats_buf->state = MSM_STATS_BUFFER_STATE_QUEUED;
-		list_add_tail(&stats_buf->list, &bufq->head);
-		break;
-	default:
-		pr_err("%s: incorrect state = %d, stats type = %d, cannot qbuf",
-			   __func__, stats_buf->state, stats_type);
-		rc = -1;
-		break;
-	}
-end:
-	return rc;
-}
-
-static int msm_stats_buf_dispatch(struct msm_stats_bufq_ctrl *stats_ctrl,
-	enum msm_stats_enum_type stats_type,
-	unsigned long phy_addr, int *buf_idx,
-	void **vaddr, int *fd,
-	struct ion_client *client)
-{
-	int rc = 0;
-	int i;
-	struct msm_stats_bufq *bufq = NULL;
-	struct msm_stats_meta_buf *stats_buf = NULL;
-	D("%s: stats type : %d\n", __func__, stats_type);
-
-	*buf_idx = -1;
-	*vaddr = NULL;
-	*fd = 0;
-	bufq = stats_ctrl->bufq[stats_type];
-	for (i = 0; i < bufq->num_bufs; i++) {
-		if (bufq->bufs[i].paddr == phy_addr) {
-			stats_buf = &bufq->bufs[i];
-			*buf_idx = i;
-			*vaddr = stats_buf->info.vaddr;
-			*fd = stats_buf->info.fd;
-			break;
-		}
-	}
-	if (!stats_buf) {
-		pr_err("%s: no match, phy_addr = 0x%ld, stats_type = %d",
-			   __func__, phy_addr, stats_type);
-		return -EFAULT;
-	}
-	switch (stats_buf->state) {
-	case MSM_STATS_BUFFER_STATE_DEQUEUED:
-		stats_buf->state = MSM_STATS_BUFFER_STATE_DISPATCHED;
-		break;
-	default:
-		pr_err("%s: type = %d, idx = %d, cur_state = %d,\n"
-			   "cannot set state to DISPATCHED\n",
-			   __func__, stats_type, *buf_idx, stats_buf->state);
-		rc = -EFAULT;
-		break;
-	}
-	return rc;
-}
-static int msm_stats_enqueue_buf(struct msm_stats_bufq_ctrl *stats_ctrl,
-	struct msm_stats_buf_info *info, struct ion_client *client,
-	int domain_num)
-{
-	int rc = 0;
-	D("%s: stats type : %d, idx : %d\n", __func__,
-		info->type, info->buf_idx);
-	rc = msm_stats_buf_prepare(stats_ctrl, info, client, domain_num);
-	if (rc < 0) {
-		pr_err("%s: buf_prepare failed, rc = %d", __func__, rc);
-		return -EINVAL;
-	}
-	rc = msm_stats_qbuf(stats_ctrl,   info->type, info->buf_idx);
-	if (rc < 0) {
-		pr_err("%s: msm_stats_qbuf failed, rc = %d", __func__, rc);
-		return -EINVAL;
-	}
-	return rc;
-}
-
-int msm_stats_buf_ops_init(struct msm_stats_bufq_ctrl *stats_ctrl,
-	struct ion_client *client, struct msm_stats_ops *ops)
-{
-	ops->stats_ctrl = stats_ctrl;
-	ops->client = client;
-	ops->enqueue_buf = msm_stats_enqueue_buf;
-	ops->qbuf = msm_stats_qbuf;
-	ops->dqbuf = msm_stats_dqbuf;
-	ops->bufq_flush = msm_stats_bufq_flush;
-	ops->buf_unprepare = msm_stats_buf_unprepare;
-	ops->buf_prepare = msm_stats_buf_prepare;
-	ops->reqbuf = msm_stats_reqbuf;
-	ops->querybuf = msm_stats_querybuf;
-	ops->dispatch = msm_stats_buf_dispatch;
-	ops->stats_ctrl_init = msm_stats_init;
-	ops->stats_ctrl_deinit = msm_stats_deinit;
-	return 0;
-}
-
diff --git a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe_stats_buf.h b/drivers/media/platform/msm/camera_v1/vfe/msm_vfe_stats_buf.h
deleted file mode 100644
index 6a1c79d..0000000
--- a/drivers/media/platform/msm/camera_v1/vfe/msm_vfe_stats_buf.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* Copyright (c) 2012, The Linux Foundation. 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.
- *
- */
-
-#ifndef _MSM_STATS_BUF_H_
-#define _MSM_STATS_BUF_H_
-
-enum msm_stats_buffer_state {
-	MSM_STATS_BUFFER_STATE_UNUSED,	  /* not used */
-	MSM_STATS_BUFFER_STATE_INITIALIZED,	   /* REQBUF done */
-	MSM_STATS_BUFFER_STATE_PREPARED,	/* BUF mapped */
-	MSM_STATS_BUFFER_STATE_QUEUED,	  /* buf queued */
-	MSM_STATS_BUFFER_STATE_DEQUEUED,	/* in use in VFE */
-	MSM_STATS_BUFFER_STATE_DISPATCHED,	  /* sent to userspace */
-};
-
-struct msm_stats_meta_buf {
-	struct list_head list;
-	enum msm_stats_buffer_state state;
-	int type;
-	int fd;
-	uint32_t offset;
-	unsigned long paddr;
-	unsigned long len;
-	struct file *file;
-	struct msm_stats_buf_info info;
-	struct ion_handle *handle;
-};
-
-struct msm_stats_bufq {
-	struct list_head head;
-	int num_bufs;
-	int type;
-	struct msm_stats_meta_buf *bufs;
-};
-
-
-struct msm_stats_bufq_ctrl {
-	/* not use spin lock for now. Assume vfe holds spin lock */
-	spinlock_t lock;
-	int init_done;
-	struct msm_stats_bufq *bufq[MSM_STATS_TYPE_MAX];
-};
-
-struct msm_stats_ops {
-	struct msm_stats_bufq_ctrl *stats_ctrl;
-	struct ion_client *client;
-	int (*enqueue_buf) (struct msm_stats_bufq_ctrl *stats_ctrl,
-				struct msm_stats_buf_info *info,
-				struct ion_client *client, int domain_num);
-	int (*qbuf) (struct msm_stats_bufq_ctrl *stats_ctrl,
-				 enum msm_stats_enum_type stats_type,
-				 int buf_idx);
-	int (*dqbuf) (struct msm_stats_bufq_ctrl *stats_ctrl,
-				  enum msm_stats_enum_type stats_type,
-				  struct msm_stats_meta_buf **pp_stats_buf);
-	int (*bufq_flush) (struct msm_stats_bufq_ctrl *stats_ctrl,
-					   enum msm_stats_enum_type stats_type,
-					   struct ion_client *client);
-	int (*buf_unprepare) (struct msm_stats_bufq_ctrl *stats_ctrl,
-		enum msm_stats_enum_type stats_type,
-		int buf_idx,
-		struct ion_client *client, int domain_num);
-	int (*buf_prepare) (struct msm_stats_bufq_ctrl *stats_ctrl,
-				struct msm_stats_buf_info *info,
-				struct ion_client *client, int domain_num);
-	int (*reqbuf) (struct msm_stats_bufq_ctrl *stats_ctrl,
-				   struct msm_stats_reqbuf *reqbuf,
-				   struct ion_client *client);
-	int (*dispatch) (struct msm_stats_bufq_ctrl *stats_ctrl,
-		enum msm_stats_enum_type stats_type,
-		unsigned long phy_addr, int *buf_idx, void **vaddr, int *fd,
-		struct ion_client *client);
-	int (*querybuf) (struct msm_stats_bufq_ctrl *stats_ctrl,
-		struct msm_stats_buf_info *info,
-		struct msm_stats_meta_buf **pp_stats_buf);
-	int (*stats_ctrl_init) (struct msm_stats_bufq_ctrl *stats_ctrl);
-	int (*stats_ctrl_deinit) (struct msm_stats_bufq_ctrl *stats_ctrl);
-};
-
-int msm_stats_buf_ops_init(struct msm_stats_bufq_ctrl *stats_ctrl,
-	struct ion_client *client, struct msm_stats_ops *ops);
-
-#endif /* _MSM_STATS_BUF_H_ */
diff --git a/drivers/media/platform/msm/camera_v1/vx6953.c b/drivers/media/platform/msm/camera_v1/vx6953.c
deleted file mode 100644
index cc09a0d..0000000
--- a/drivers/media/platform/msm/camera_v1/vx6953.c
+++ /dev/null
@@ -1,3667 +0,0 @@
-/* Copyright (c) 2010-2012, The Linux Foundation. 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.
- *
- */
-
-#include <linux/delay.h>
-#include <linux/types.h>
-#include <linux/i2c.h>
-#include <linux/uaccess.h>
-#include <linux/miscdevice.h>
-#include <linux/module.h>
-#include <media/msm_camera.h>
-#include <mach/gpio.h>
-#include <mach/camera.h>
-#include <linux/slab.h>
-#include "vx6953.h"
-
-/*=============================================================
-	SENSOR REGISTER DEFINES
-==============================================================*/
-
-#define REG_GROUPED_PARAMETER_HOLD			0x0104
-#define GROUPED_PARAMETER_HOLD_OFF			0x00
-#define GROUPED_PARAMETER_HOLD				0x01
-#define REG_MODE_SELECT					0x0100
-#define MODE_SELECT_STANDBY_MODE			0x00
-#define MODE_SELECT_STREAM				0x01
-/* Integration Time */
-#define REG_COARSE_INTEGRATION_TIME_HI			0x0202
-#define REG_COARSE_INTEGRATION_TIME_LO			0x0203
-/* Gain */
-#define REG_ANALOGUE_GAIN_CODE_GLOBAL_HI		0x0204
-#define REG_ANALOGUE_GAIN_CODE_GLOBAL_LO		0x0205
-/* Digital Gain */
-#define REG_DIGITAL_GAIN_GREEN_R_HI			0x020E
-#define REG_DIGITAL_GAIN_GREEN_R_LO			0x020F
-#define REG_DIGITAL_GAIN_RED_HI				0x0210
-#define REG_DIGITAL_GAIN_RED_LO				0x0211
-#define REG_DIGITAL_GAIN_BLUE_HI			0x0212
-#define REG_DIGITAL_GAIN_BLUE_LO			0x0213
-#define REG_DIGITAL_GAIN_GREEN_B_HI			0x0214
-#define REG_DIGITAL_GAIN_GREEN_B_LO			0x0215
-/* output bits setting */
-#define REG_0x0112					0x0112
-#define REG_0x0113					0x0113
-/* PLL registers */
-#define REG_VT_PIX_CLK_DIV				0x0301
-#define REG_PRE_PLL_CLK_DIV				0x0305
-#define REG_PLL_MULTIPLIER				0x0307
-#define REG_OP_PIX_CLK_DIV				0x0309
-#define REG_0x034c					0x034c
-#define REG_0x034d					0x034d
-#define REG_0x034e					0x034e
-#define REG_0x034f					0x034f
-#define REG_0x0387					0x0387
-#define REG_0x0383					0x0383
-#define REG_FRAME_LENGTH_LINES_HI			0x0340
-#define REG_FRAME_LENGTH_LINES_LO			0x0341
-#define REG_LINE_LENGTH_PCK_HI				0x0342
-#define REG_LINE_LENGTH_PCK_LO				0x0343
-#define REG_0x3030					0x3030
-#define REG_0x0111					0x0111
-#define REG_0x0136					0x0136
-#define REG_0x0137					0x0137
-#define REG_0x0b00					0x0b00
-#define REG_0x3001					0x3001
-#define REG_0x3004					0x3004
-#define REG_0x3007					0x3007
-#define REG_0x301a					0x301a
-#define REG_0x3101					0x3101
-#define REG_0x3364					0x3364
-#define REG_0x3365					0x3365
-#define REG_0x0b83					0x0b83
-#define REG_0x0b84					0x0b84
-#define REG_0x0b85					0x0b85
-#define REG_0x0b88					0x0b88
-#define REG_0x0b89					0x0b89
-#define REG_0x0b8a					0x0b8a
-#define REG_0x3005					0x3005
-#define REG_0x3010					0x3010
-#define REG_0x3036					0x3036
-#define REG_0x3041					0x3041
-#define REG_0x0b80					0x0b80
-#define REG_0x0900					0x0900
-#define REG_0x0901					0x0901
-#define REG_0x0902					0x0902
-#define REG_0x3016					0x3016
-#define REG_0x301d					0x301d
-#define REG_0x317e					0x317e
-#define REG_0x317f					0x317f
-#define REG_0x3400					0x3400
-#define REG_0x303a					0x303a
-#define REG_0x1716					0x1716
-#define REG_0x1717					0x1717
-#define REG_0x1718					0x1718
-#define REG_0x1719					0x1719
-#define REG_0x3006					0x3006
-#define REG_0x301b					0x301b
-#define REG_0x3098					0x3098
-#define REG_0x309d					0x309d
-#define REG_0x3011					0x3011
-#define REG_0x3035					0x3035
-#define REG_0x3045					0x3045
-#define REG_0x3210					0x3210
-#define	REG_0x0111					0x0111
-#define REG_0x3410					0x3410
-#define REG_0x0b06					0x0b06
-#define REG_0x0b07					0x0b07
-#define REG_0x0b08					0x0b08
-#define REG_0x0b09					0x0b09
-#define REG_0x3640					0x3640
-/* Test Pattern */
-#define REG_TEST_PATTERN_MODE				0x0601
-
-/*============================================================================
-							 TYPE DECLARATIONS
-============================================================================*/
-
-/* 16bit address - 8 bit context register structure */
-#define	VX6953_STM5M0EDOF_OFFSET	9
-#define	Q8		0x00000100
-#define	Q10		0x00000400
-#define	VX6953_STM5M0EDOF_MAX_SNAPSHOT_EXPOSURE_LINE_COUNT	2922
-#define	VX6953_STM5M0EDOF_DEFAULT_MASTER_CLK_RATE	24000000
-#define	VX6953_STM5M0EDOF_OP_PIXEL_CLOCK_RATE	79800000
-#define	VX6953_STM5M0EDOF_VT_PIXEL_CLOCK_RATE	88670000
-/* Full	Size */
-#define	VX6953_FULL_SIZE_WIDTH	2608
-#define	VX6953_FULL_SIZE_HEIGHT		1960
-#define	VX6953_FULL_SIZE_DUMMY_PIXELS	1
-#define	VX6953_FULL_SIZE_DUMMY_LINES	0
-/* Quarter Size	*/
-#define	VX6953_QTR_SIZE_WIDTH	1304
-#define	VX6953_QTR_SIZE_HEIGHT		980
-#define	VX6953_QTR_SIZE_DUMMY_PIXELS	1
-#define	VX6953_QTR_SIZE_DUMMY_LINES		0
-/* Blanking	as measured	on the scope */
-/* Full	Size */
-#define	VX6953_HRZ_FULL_BLK_PIXELS	348
-#define	VX6953_VER_FULL_BLK_LINES	40
-/* Quarter Size	*/
-#define	VX6953_HRZ_QTR_BLK_PIXELS	1628
-#define	VX6953_VER_QTR_BLK_LINES	28
-#define	MAX_LINE_LENGTH_PCK		8190
-#define	MAX_FRAME_LENGTH_LINES	16383
-#define	VX6953_REVISION_NUMBER_CUT2	0x10/*revision number	for	Cut2.0*/
-#define	VX6953_REVISION_NUMBER_CUT3	0x20/*revision number	for	Cut3.0*/
-/* FIXME: Changes from here */
-struct vx6953_work_t {
-	struct work_struct work;
-};
-
-static struct vx6953_work_t *vx6953_sensorw;
-static struct i2c_client *vx6953_client;
-
-struct vx6953_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 */
-	uint16_t fps;
-
-	int16_t curr_lens_pos;
-	uint16_t curr_step_pos;
-	uint16_t my_reg_gain;
-	uint32_t my_reg_line_count;
-	uint16_t total_lines_per_frame;
-
-	enum vx6953_resolution_t prev_res;
-	enum vx6953_resolution_t pict_res;
-	enum vx6953_resolution_t curr_res;
-	enum vx6953_test_mode_t  set_test;
-	enum sensor_revision_t sensor_type;
-
-	enum edof_mode_t edof_mode;
-
-	unsigned short imgaddr;
-};
-
-
-static uint8_t vx6953_stm5m0edof_delay_msecs_stdby;
-static uint16_t vx6953_stm5m0edof_delay_msecs_stream = 20;
-static uint8_t count;
-static struct vx6953_ctrl_t *vx6953_ctrl;
-static DECLARE_WAIT_QUEUE_HEAD(vx6953_wait_queue);
-DEFINE_MUTEX(vx6953_mut);
-static struct vx6953_i2c_reg_conf patch_tbl_cut2[] = {
-	{0xFB94, 0},	/*intialise Data Xfer Status reg*/
-	{0xFB95, 0},	/*gain 1	  (0x00)*/
-	{0xFB96, 0},	/*gain 1.07   (0x10)*/
-	{0xFB97, 0},	/*gain 1.14   (0x20)*/
-	{0xFB98, 0},	/*gain 1.23   (0x30)*/
-	{0xFB99, 0},	/*gain 1.33   (0x40)*/
-	{0xFB9A, 0},	/*gain 1.45   (0x50)*/
-	{0xFB9B, 0},	/*gain 1.6    (0x60)*/
-	{0xFB9C, 0},	/*gain 1.78   (0x70)*/
-	{0xFB9D, 2},	/*gain 2	  (0x80)*/
-	{0xFB9E, 2},	/*gain 2.29   (0x90)*/
-	{0xFB9F, 3},	/*gain 2.67   (0xA0)*/
-	{0xFBA0, 3},	/*gain 3.2    (0xB0)*/
-	{0xFBA1, 4},	/*gain 4	  (0xC0)*/
-	{0xFBA2, 7},	/*gain 5.33   (0xD0)*/
-	{0xFBA3, 10},	/*gain 8	  (0xE0)*/
-	{0xFBA4, 11},	/*gain 9.14   (0xE4)*/
-	{0xFBA5, 13},	/*gain 10.67  (0xE8)*/
-	{0xFBA6, 15},	/*gain 12.8   (0xEC)*/
-	{0xFBA7, 19},	/*gain 16     (0xF0)*/
-	{0xF800, 0x12},
-	{0xF801, 0x06},
-	{0xF802, 0xf7},
-	{0xF803, 0x90},
-	{0xF804, 0x02},
-	{0xF805, 0x05},
-	{0xF806, 0xe0},
-	{0xF807, 0xff},
-	{0xF808, 0x65},
-	{0xF809, 0x7d},
-	{0xF80A, 0x70},
-	{0xF80B, 0x03},
-	{0xF80C, 0x02},
-	{0xF80D, 0xf9},
-	{0xF80E, 0x1c},
-	{0xF80F, 0x8f},
-	{0xF810, 0x7d},
-	{0xF811, 0xe4},
-	{0xF812, 0xf5},
-	{0xF813, 0x7a},
-	{0xF814, 0x75},
-	{0xF815, 0x78},
-	{0xF816, 0x30},
-	{0xF817, 0x75},
-	{0xF818, 0x79},
-	{0xF819, 0x53},
-	{0xF81A, 0x85},
-	{0xF81B, 0x79},
-	{0xF81C, 0x82},
-	{0xF81D, 0x85},
-	{0xF81E, 0x78},
-	{0xF81F, 0x83},
-	{0xF820, 0xe0},
-	{0xF821, 0xc3},
-	{0xF822, 0x95},
-	{0xF823, 0x7b},
-	{0xF824, 0xf0},
-	{0xF825, 0x74},
-	{0xF826, 0x02},
-	{0xF827, 0x25},
-	{0xF828, 0x79},
-	{0xF829, 0xf5},
-	{0xF82A, 0x79},
-	{0xF82B, 0xe4},
-	{0xF82C, 0x35},
-	{0xF82D, 0x78},
-	{0xF82E, 0xf5},
-	{0xF82F, 0x78},
-	{0xF830, 0x05},
-	{0xF831, 0x7a},
-	{0xF832, 0xe5},
-	{0xF833, 0x7a},
-	{0xF834, 0xb4},
-	{0xF835, 0x08},
-	{0xF836, 0xe3},
-	{0xF837, 0xe5},
-	{0xF838, 0x7d},
-	{0xF839, 0x70},
-	{0xF83A, 0x04},
-	{0xF83B, 0xff},
-	{0xF83C, 0x02},
-	{0xF83D, 0xf8},
-	{0xF83E, 0xe4},
-	{0xF83F, 0xe5},
-	{0xF840, 0x7d},
-	{0xF841, 0xb4},
-	{0xF842, 0x10},
-	{0xF843, 0x05},
-	{0xF844, 0x7f},
-	{0xF845, 0x01},
-	{0xF846, 0x02},
-	{0xF847, 0xf8},
-	{0xF848, 0xe4},
-	{0xF849, 0xe5},
-	{0xF84A, 0x7d},
-	{0xF84B, 0xb4},
-	{0xF84C, 0x20},
-	{0xF84D, 0x05},
-	{0xF84E, 0x7f},
-	{0xF84F, 0x02},
-	{0xF850, 0x02},
-	{0xF851, 0xf8},
-	{0xF852, 0xe4},
-	{0xF853, 0xe5},
-	{0xF854, 0x7d},
-	{0xF855, 0xb4},
-	{0xF856, 0x30},
-	{0xF857, 0x05},
-	{0xF858, 0x7f},
-	{0xF859, 0x03},
-	{0xF85A, 0x02},
-	{0xF85B, 0xf8},
-	{0xF85C, 0xe4},
-	{0xF85D, 0xe5},
-	{0xF85E, 0x7d},
-	{0xF85F, 0xb4},
-	{0xF860, 0x40},
-	{0xF861, 0x04},
-	{0xF862, 0x7f},
-	{0xF863, 0x04},
-	{0xF864, 0x80},
-	{0xF865, 0x7e},
-	{0xF866, 0xe5},
-	{0xF867, 0x7d},
-	{0xF868, 0xb4},
-	{0xF869, 0x50},
-	{0xF86A, 0x04},
-	{0xF86B, 0x7f},
-	{0xF86C, 0x05},
-	{0xF86D, 0x80},
-	{0xF86E, 0x75},
-	{0xF86F, 0xe5},
-	{0xF870, 0x7d},
-	{0xF871, 0xb4},
-	{0xF872, 0x60},
-	{0xF873, 0x04},
-	{0xF874, 0x7f},
-	{0xF875, 0x06},
-	{0xF876, 0x80},
-	{0xF877, 0x6c},
-	{0xF878, 0xe5},
-	{0xF879, 0x7d},
-	{0xF87A, 0xb4},
-	{0xF87B, 0x70},
-	{0xF87C, 0x04},
-	{0xF87D, 0x7f},
-	{0xF87E, 0x07},
-	{0xF87F, 0x80},
-	{0xF880, 0x63},
-	{0xF881, 0xe5},
-	{0xF882, 0x7d},
-	{0xF883, 0xb4},
-	{0xF884, 0x80},
-	{0xF885, 0x04},
-	{0xF886, 0x7f},
-	{0xF887, 0x08},
-	{0xF888, 0x80},
-	{0xF889, 0x5a},
-	{0xF88A, 0xe5},
-	{0xF88B, 0x7d},
-	{0xF88C, 0xb4},
-	{0xF88D, 0x90},
-	{0xF88E, 0x04},
-	{0xF88F, 0x7f},
-	{0xF890, 0x09},
-	{0xF891, 0x80},
-	{0xF892, 0x51},
-	{0xF893, 0xe5},
-	{0xF894, 0x7d},
-	{0xF895, 0xb4},
-	{0xF896, 0xa0},
-	{0xF897, 0x04},
-	{0xF898, 0x7f},
-	{0xF899, 0x0a},
-	{0xF89A, 0x80},
-	{0xF89B, 0x48},
-	{0xF89C, 0xe5},
-	{0xF89D, 0x7d},
-	{0xF89E, 0xb4},
-	{0xF89F, 0xb0},
-	{0xF8A0, 0x04},
-	{0xF8A1, 0x7f},
-	{0xF8A2, 0x0b},
-	{0xF8A3, 0x80},
-	{0xF8A4, 0x3f},
-	{0xF8A5, 0xe5},
-	{0xF8A6, 0x7d},
-	{0xF8A7, 0xb4},
-	{0xF8A8, 0xc0},
-	{0xF8A9, 0x04},
-	{0xF8AA, 0x7f},
-	{0xF8AB, 0x0c},
-	{0xF8AC, 0x80},
-	{0xF8AD, 0x36},
-	{0xF8AE, 0xe5},
-	{0xF8AF, 0x7d},
-	{0xF8B0, 0xb4},
-	{0xF8B1, 0xd0},
-	{0xF8B2, 0x04},
-	{0xF8B3, 0x7f},
-	{0xF8B4, 0x0d},
-	{0xF8B5, 0x80},
-	{0xF8B6, 0x2d},
-	{0xF8B7, 0xe5},
-	{0xF8B8, 0x7d},
-	{0xF8B9, 0xb4},
-	{0xF8BA, 0xe0},
-	{0xF8BB, 0x04},
-	{0xF8BC, 0x7f},
-	{0xF8BD, 0x0e},
-	{0xF8BE, 0x80},
-	{0xF8BF, 0x24},
-	{0xF8C0, 0xe5},
-	{0xF8C1, 0x7d},
-	{0xF8C2, 0xb4},
-	{0xF8C3, 0xe4},
-	{0xF8C4, 0x04},
-	{0xF8C5, 0x7f},
-	{0xF8C6, 0x0f},
-	{0xF8C7, 0x80},
-	{0xF8C8, 0x1b},
-	{0xF8C9, 0xe5},
-	{0xF8CA, 0x7d},
-	{0xF8CB, 0xb4},
-	{0xF8CC, 0xe8},
-	{0xF8CD, 0x04},
-	{0xF8CE, 0x7f},
-	{0xF8CF, 0x10},
-	{0xF8D0, 0x80},
-	{0xF8D1, 0x12},
-	{0xF8D2, 0xe5},
-	{0xF8D3, 0x7d},
-	{0xF8D4, 0xb4},
-	{0xF8D5, 0xec},
-	{0xF8D6, 0x04},
-	{0xF8D7, 0x7f},
-	{0xF8D8, 0x11},
-	{0xF8D9, 0x80},
-	{0xF8DA, 0x09},
-	{0xF8DB, 0xe5},
-	{0xF8DC, 0x7d},
-	{0xF8DD, 0x7f},
-	{0xF8DE, 0x00},
-	{0xF8DF, 0xb4},
-	{0xF8E0, 0xf0},
-	{0xF8E1, 0x02},
-	{0xF8E2, 0x7f},
-	{0xF8E3, 0x12},
-	{0xF8E4, 0x8f},
-	{0xF8E5, 0x7c},
-	{0xF8E6, 0xef},
-	{0xF8E7, 0x24},
-	{0xF8E8, 0x95},
-	{0xF8E9, 0xff},
-	{0xF8EA, 0xe4},
-	{0xF8EB, 0x34},
-	{0xF8EC, 0xfb},
-	{0xF8ED, 0x8f},
-	{0xF8EE, 0x82},
-	{0xF8EF, 0xf5},
-	{0xF8F0, 0x83},
-	{0xF8F1, 0xe4},
-	{0xF8F2, 0x93},
-	{0xF8F3, 0xf5},
-	{0xF8F4, 0x7c},
-	{0xF8F5, 0xf5},
-	{0xF8F6, 0x7b},
-	{0xF8F7, 0xe4},
-	{0xF8F8, 0xf5},
-	{0xF8F9, 0x7a},
-	{0xF8FA, 0x75},
-	{0xF8FB, 0x78},
-	{0xF8FC, 0x30},
-	{0xF8FD, 0x75},
-	{0xF8FE, 0x79},
-	{0xF8FF, 0x53},
-	{0xF900, 0x85},
-	{0xF901, 0x79},
-	{0xF902, 0x82},
-	{0xF903, 0x85},
-	{0xF904, 0x78},
-	{0xF905, 0x83},
-	{0xF906, 0xe0},
-	{0xF907, 0x25},
-	{0xF908, 0x7c},
-	{0xF909, 0xf0},
-	{0xF90A, 0x74},
-	{0xF90B, 0x02},
-	{0xF90C, 0x25},
-	{0xF90D, 0x79},
-	{0xF90E, 0xf5},
-	{0xF90F, 0x79},
-	{0xF910, 0xe4},
-	{0xF911, 0x35},
-	{0xF912, 0x78},
-	{0xF913, 0xf5},
-	{0xF914, 0x78},
-	{0xF915, 0x05},
-	{0xF916, 0x7a},
-	{0xF917, 0xe5},
-	{0xF918, 0x7a},
-	{0xF919, 0xb4},
-	{0xF91A, 0x08},
-	{0xF91B, 0xe4},
-	{0xF91C, 0x02},
-	{0xF91D, 0x18},
-	{0xF91E, 0x32},
-	{0xF91F, 0x22},
-	{0xF920, 0xf0},
-	{0xF921, 0x90},
-	{0xF922, 0xa0},
-	{0xF923, 0xf8},
-	{0xF924, 0xe0},
-	{0xF925, 0x70},
-	{0xF926, 0x02},
-	{0xF927, 0xa3},
-	{0xF928, 0xe0},
-	{0xF929, 0x70},
-	{0xF92A, 0x0a},
-	{0xF92B, 0x90},
-	{0xF92C, 0xa1},
-	{0xF92D, 0x10},
-	{0xF92E, 0xe0},
-	{0xF92F, 0xfe},
-	{0xF930, 0xa3},
-	{0xF931, 0xe0},
-	{0xF932, 0xff},
-	{0xF933, 0x80},
-	{0xF934, 0x04},
-	{0xF935, 0x7e},
-	{0xF936, 0x00},
-	{0xF937, 0x7f},
-	{0xF938, 0x00},
-	{0xF939, 0x8e},
-	{0xF93A, 0x7e},
-	{0xF93B, 0x8f},
-	{0xF93C, 0x7f},
-	{0xF93D, 0x90},
-	{0xF93E, 0x36},
-	{0xF93F, 0x0d},
-	{0xF940, 0xe0},
-	{0xF941, 0x44},
-	{0xF942, 0x02},
-	{0xF943, 0xf0},
-	{0xF944, 0x90},
-	{0xF945, 0x36},
-	{0xF946, 0x0e},
-	{0xF947, 0xe5},
-	{0xF948, 0x7e},
-	{0xF949, 0xf0},
-	{0xF94A, 0xa3},
-	{0xF94B, 0xe5},
-	{0xF94C, 0x7f},
-	{0xF94D, 0xf0},
-	{0xF94E, 0xe5},
-	{0xF94F, 0x3a},
-	{0xF950, 0x60},
-	{0xF951, 0x0c},
-	{0xF952, 0x90},
-	{0xF953, 0x36},
-	{0xF954, 0x09},
-	{0xF955, 0xe0},
-	{0xF956, 0x70},
-	{0xF957, 0x06},
-	{0xF958, 0x90},
-	{0xF959, 0x36},
-	{0xF95A, 0x08},
-	{0xF95B, 0xf0},
-	{0xF95C, 0xf5},
-	{0xF95D, 0x3a},
-	{0xF95E, 0x02},
-	{0xF95F, 0x03},
-	{0xF960, 0x94},
-	{0xF961, 0x22},
-	{0xF962, 0x78},
-	{0xF963, 0x07},
-	{0xF964, 0xe6},
-	{0xF965, 0xd3},
-	{0xF966, 0x94},
-	{0xF967, 0x00},
-	{0xF968, 0x40},
-	{0xF969, 0x16},
-	{0xF96A, 0x16},
-	{0xF96B, 0xe6},
-	{0xF96C, 0x90},
-	{0xF96D, 0x30},
-	{0xF96E, 0xa1},
-	{0xF96F, 0xf0},
-	{0xF970, 0x90},
-	{0xF971, 0x43},
-	{0xF972, 0x83},
-	{0xF973, 0xe0},
-	{0xF974, 0xb4},
-	{0xF975, 0x01},
-	{0xF976, 0x0f},
-	{0xF977, 0x90},
-	{0xF978, 0x43},
-	{0xF979, 0x87},
-	{0xF97A, 0xe0},
-	{0xF97B, 0xb4},
-	{0xF97C, 0x01},
-	{0xF97D, 0x08},
-	{0xF97E, 0x80},
-	{0xF97F, 0x00},
-	{0xF980, 0x90},
-	{0xF981, 0x30},
-	{0xF982, 0xa0},
-	{0xF983, 0x74},
-	{0xF984, 0x01},
-	{0xF985, 0xf0},
-	{0xF986, 0x22},
-	{0xF987, 0xf0},
-	{0xF988, 0x90},
-	{0xF989, 0x35},
-	{0xF98A, 0xba},
-	{0xF98B, 0xe0},
-	{0xF98C, 0xb4},
-	{0xF98D, 0x0a},
-	{0xF98E, 0x0d},
-	{0xF98F, 0xa3},
-	{0xF990, 0xe0},
-	{0xF991, 0xb4},
-	{0xF992, 0x01},
-	{0xF993, 0x08},
-	{0xF994, 0x90},
-	{0xF995, 0xfb},
-	{0xF996, 0x94},
-	{0xF997, 0xe0},
-	{0xF998, 0x90},
-	{0xF999, 0x35},
-	{0xF99A, 0xb8},
-	{0xF99B, 0xf0},
-	{0xF99C, 0xd0},
-	{0xF99D, 0xd0},
-	{0xF99E, 0xd0},
-	{0xF99F, 0x82},
-	{0xF9A0, 0xd0},
-	{0xF9A1, 0x83},
-	{0xF9A2, 0xd0},
-	{0xF9A3, 0xe0},
-	{0xF9A4, 0x32},
-	{0xF9A5, 0x22},
-	{0xF9A6, 0xe5},
-	{0xF9A7, 0x7f},
-	{0xF9A8, 0x45},
-	{0xF9A9, 0x7e},
-	{0xF9AA, 0x60},
-	{0xF9AB, 0x15},
-	{0xF9AC, 0x90},
-	{0xF9AD, 0x01},
-	{0xF9AE, 0x00},
-	{0xF9AF, 0xe0},
-	{0xF9B0, 0x70},
-	{0xF9B1, 0x0f},
-	{0xF9B2, 0x90},
-	{0xF9B3, 0xa0},
-	{0xF9B4, 0xf8},
-	{0xF9B5, 0xe5},
-	{0xF9B6, 0x7e},
-	{0xF9B7, 0xf0},
-	{0xF9B8, 0xa3},
-	{0xF9B9, 0xe5},
-	{0xF9BA, 0x7f},
-	{0xF9BB, 0xf0},
-	{0xF9BC, 0xe4},
-	{0xF9BD, 0xf5},
-	{0xF9BE, 0x7e},
-	{0xF9BF, 0xf5},
-	{0xF9C0, 0x7f},
-	{0xF9C1, 0x22},
-	{0xF9C2, 0x02},
-	{0xF9C3, 0x0e},
-	{0xF9C4, 0x79},
-	{0xF9C5, 0x22},
-	/* Offsets:*/
-	{0x35C6, 0x00},/* FIDDLEDARKCAL*/
-	{0x35C7, 0x00},
-	{0x35C8, 0x01},/*STOREDISTANCEATSTOPSTREAMING*/
-	{0x35C9, 0x20},
-	{0x35CA, 0x01},/*BRUCEFIX*/
-	{0x35CB, 0x62},
-	{0x35CC, 0x01},/*FIXDATAXFERSTATUSREG*/
-	{0x35CD, 0x87},
-	{0x35CE, 0x01},/*FOCUSDISTANCEUPDATE*/
-	{0x35CF, 0xA6},
-	{0x35D0, 0x01},/*SKIPEDOFRESET*/
-	{0x35D1, 0xC2},
-	{0x35D2, 0x00},
-	{0x35D3, 0xFB},
-	{0x35D4, 0x00},
-	{0x35D5, 0x94},
-	{0x35D6, 0x00},
-	{0x35D7, 0xFB},
-	{0x35D8, 0x00},
-	{0x35D9, 0x94},
-	{0x35DA, 0x00},
-	{0x35DB, 0xFB},
-	{0x35DC, 0x00},
-	{0x35DD, 0x94},
-	{0x35DE, 0x00},
-	{0x35DF, 0xFB},
-	{0x35E0, 0x00},
-	{0x35E1, 0x94},
-	{0x35E6, 0x18},/* FIDDLEDARKCAL*/
-	{0x35E7, 0x2F},
-	{0x35E8, 0x03},/* STOREDISTANCEATSTOPSTREAMING*/
-	{0x35E9, 0x93},
-	{0x35EA, 0x18},/* BRUCEFIX*/
-	{0x35EB, 0x99},
-	{0x35EC, 0x00},/* FIXDATAXFERSTATUSREG*/
-	{0x35ED, 0xA3},
-	{0x35EE, 0x21},/* FOCUSDISTANCEUPDATE*/
-	{0x35EF, 0x5B},
-	{0x35F0, 0x0E},/* SKIPEDOFRESET*/
-	{0x35F1, 0x74},
-	{0x35F2, 0x04},
-	{0x35F3, 0x64},
-	{0x35F4, 0x04},
-	{0x35F5, 0x65},
-	{0x35F6, 0x04},
-	{0x35F7, 0x7B},
-	{0x35F8, 0x04},
-	{0x35F9, 0x7C},
-	{0x35FA, 0x04},
-	{0x35FB, 0xDD},
-	{0x35FC, 0x04},
-	{0x35FD, 0xDE},
-	{0x35FE, 0x04},
-	{0x35FF, 0xEF},
-	{0x3600, 0x04},
-	{0x3601, 0xF0},
-	/*Jump/Data:*/
-	{0x35C2, 0x3F},/* Jump Reg*/
-	{0x35C3, 0xFF},/* Jump Reg*/
-	{0x35C4, 0x3F},/* Data Reg*/
-	{0x35C5, 0xC0},/* Data Reg*/
-	{0x35C0, 0x01},/* Enable*/
-
-};
-
-static struct vx6953_i2c_reg_conf cut3_cali_data[] = {
-		{0x360A, 0x07 },
-		{0x3530, 0x07 },
-		{0x35B5, 0x00 },
-		{0x35BC, 0x00 },
-		{0xAFF8, 0x00 },
-		{0xAFF9, 0x01 },
-		{0xF800, 0x90 },
-		{0xF801, 0x30 },
-		{0xF802, 0x31 },
-		{0xF803, 0xe0 },
-		{0xF804, 0xf5 },
-		{0xF805, 0x7d },
-		{0xF806, 0xb4 },
-		{0xF807, 0x01 },
-		{0xF808, 0x06 },
-		{0xF809, 0x75 },
-		{0xF80A, 0x7d },
-		{0xF80B, 0x03 },
-		{0xF80C, 0x74 },
-		{0xF80D, 0x03 },
-		{0xF80E, 0xf0 },
-		{0xF80F, 0x90 },
-		{0xF810, 0x30 },
-		{0xF811, 0x04 },
-		{0xF812, 0x74 },
-		{0xF813, 0x33 },
-		{0xF814, 0xf0 },
-		{0xF815, 0x90 },
-		{0xF816, 0x30 },
-		{0xF817, 0x06 },
-		{0xF818, 0xe4 },
-		{0xF819, 0xf0 },
-		{0xF81A, 0xa3 },
-		{0xF81B, 0x74 },
-		{0xF81C, 0x08 },
-		{0xF81D, 0xf0 },
-		{0xF81E, 0x90 },
-		{0xF81F, 0x30 },
-		{0xF820, 0x10 },
-		{0xF821, 0xe4 },
-		{0xF822, 0xf0 },
-		{0xF823, 0xa3 },
-		{0xF824, 0xf0 },
-		{0xF825, 0x90 },
-		{0xF826, 0x30 },
-		{0xF827, 0x16 },
-		{0xF828, 0x74 },
-		{0xF829, 0x1e },
-		{0xF82A, 0xf0 },
-		{0xF82B, 0x90 },
-		{0xF82C, 0x30 },
-		{0xF82D, 0x1a },
-		{0xF82E, 0x74 },
-		{0xF82F, 0x6a },
-		{0xF830, 0xf0 },
-		{0xF831, 0x90 },
-		{0xF832, 0x30 },
-		{0xF833, 0x30 },
-		{0xF834, 0x74 },
-		{0xF835, 0x08 },
-		{0xF836, 0xf0 },
-		{0xF837, 0x90 },
-		{0xF838, 0x30 },
-		{0xF839, 0x36 },
-		{0xF83A, 0x74 },
-		{0xF83B, 0x2c },
-		{0xF83C, 0xf0 },
-		{0xF83D, 0x90 },
-		{0xF83E, 0x30 },
-		{0xF83F, 0x41 },
-		{0xF840, 0xe4 },
-		{0xF841, 0xf0 },
-		{0xF842, 0xa3 },
-		{0xF843, 0x74 },
-		{0xF844, 0x24 },
-		{0xF845, 0xf0 },
-		{0xF846, 0x90 },
-		{0xF847, 0x30 },
-		{0xF848, 0x45 },
-		{0xF849, 0x74 },
-		{0xF84A, 0x81 },
-		{0xF84B, 0xf0 },
-		{0xF84C, 0x90 },
-		{0xF84D, 0x30 },
-		{0xF84E, 0x98 },
-		{0xF84F, 0x74 },
-		{0xF850, 0x01 },
-		{0xF851, 0xf0 },
-		{0xF852, 0x90 },
-		{0xF853, 0x30 },
-		{0xF854, 0x9d },
-		{0xF855, 0x74 },
-		{0xF856, 0x05 },
-		{0xF857, 0xf0 },
-		{0xF858, 0xe5 },
-		{0xF859, 0x7d },
-		{0xF85A, 0x70 },
-		{0xF85B, 0x22 },
-		{0xF85C, 0x90 },
-		{0xF85D, 0x02 },
-		{0xF85E, 0x00 },
-		{0xF85F, 0x74 },
-		{0xF860, 0x02 },
-		{0xF861, 0xf0 },
-		{0xF862, 0xa3 },
-		{0xF863, 0x74 },
-		{0xF864, 0x54 },
-		{0xF865, 0xf0 },
-		{0xF866, 0x90 },
-		{0xF867, 0x30 },
-		{0xF868, 0x05 },
-		{0xF869, 0x74 },
-		{0xF86A, 0x01 },
-		{0xF86B, 0xf0 },
-		{0xF86C, 0x90 },
-		{0xF86D, 0x30 },
-		{0xF86E, 0x1b },
-		{0xF86F, 0x74 },
-		{0xF870, 0x29 },
-		{0xF871, 0xf0 },
-		{0xF872, 0x90 },
-		{0xF873, 0x30 },
-		{0xF874, 0x30 },
-		{0xF875, 0xe4 },
-		{0xF876, 0xf0 },
-		{0xF877, 0x90 },
-		{0xF878, 0x30 },
-		{0xF879, 0x35 },
-		{0xF87A, 0x04 },
-		{0xF87B, 0xf0 },
-		{0xF87C, 0x80 },
-		{0xF87D, 0x69 },
-		{0xF87E, 0xe5 },
-		{0xF87F, 0x7d },
-		{0xF880, 0x64 },
-		{0xF881, 0x02 },
-		{0xF882, 0x70 },
-		{0xF883, 0x3c },
-		{0xF884, 0x90 },
-		{0xF885, 0x02 },
-		{0xF886, 0x00 },
-		{0xF887, 0x74 },
-		{0xF888, 0x04 },
-		{0xF889, 0xf0 },
-		{0xF88A, 0xa3 },
-		{0xF88B, 0x74 },
-		{0xF88C, 0x10 },
-		{0xF88D, 0xf0 },
-		{0xF88E, 0x90 },
-		{0xF88F, 0x30 },
-		{0xF890, 0x04 },
-		{0xF891, 0x74 },
-		{0xF892, 0x34 },
-		{0xF893, 0xf0 },
-		{0xF894, 0xa3 },
-		{0xF895, 0x74 },
-		{0xF896, 0x07 },
-		{0xF897, 0xf0 },
-		{0xF898, 0x90 },
-		{0xF899, 0x30 },
-		{0xF89A, 0x10 },
-		{0xF89B, 0x74 },
-		{0xF89C, 0x10 },
-		{0xF89D, 0xf0 },
-		{0xF89E, 0x90 },
-		{0xF89F, 0x30 },
-		{0xF8A0, 0x16 },
-		{0xF8A1, 0x74 },
-		{0xF8A2, 0x1f },
-		{0xF8A3, 0xf0 },
-		{0xF8A4, 0x90 },
-		{0xF8A5, 0x30 },
-		{0xF8A6, 0x1a },
-		{0xF8A7, 0x74 },
-		{0xF8A8, 0x62 },
-		{0xF8A9, 0xf0 },
-		{0xF8AA, 0xa3 },
-		{0xF8AB, 0x74 },
-		{0xF8AC, 0x2a },
-		{0xF8AD, 0xf0 },
-		{0xF8AE, 0x90 },
-		{0xF8AF, 0x30 },
-		{0xF8B0, 0x35 },
-		{0xF8B1, 0x74 },
-		{0xF8B2, 0x04 },
-		{0xF8B3, 0xf0 },
-		{0xF8B4, 0x90 },
-		{0xF8B5, 0x30 },
-		{0xF8B6, 0x41 },
-		{0xF8B7, 0x74 },
-		{0xF8B8, 0x60 },
-		{0xF8B9, 0xf0 },
-		{0xF8BA, 0xa3 },
-		{0xF8BB, 0x74 },
-		{0xF8BC, 0x64 },
-		{0xF8BD, 0xf0 },
-		{0xF8BE, 0x80 },
-		{0xF8BF, 0x27 },
-		{0xF8C0, 0xe5 },
-		{0xF8C1, 0x7d },
-		{0xF8C2, 0xb4 },
-		{0xF8C3, 0x03 },
-		{0xF8C4, 0x22 },
-		{0xF8C5, 0x90 },
-		{0xF8C6, 0x02 },
-		{0xF8C7, 0x00 },
-		{0xF8C8, 0x74 },
-		{0xF8C9, 0x02 },
-		{0xF8CA, 0xf0 },
-		{0xF8CB, 0xa3 },
-		{0xF8CC, 0x74 },
-		{0xF8CD, 0x26 },
-		{0xF8CE, 0xf0 },
-		{0xF8CF, 0x90 },
-		{0xF8D0, 0x30 },
-		{0xF8D1, 0x05 },
-		{0xF8D2, 0x74 },
-		{0xF8D3, 0x03 },
-		{0xF8D4, 0xf0 },
-		{0xF8D5, 0x90 },
-		{0xF8D6, 0x30 },
-		{0xF8D7, 0x11 },
-		{0xF8D8, 0x74 },
-		{0xF8D9, 0x01 },
-		{0xF8DA, 0xf0 },
-		{0xF8DB, 0x90 },
-		{0xF8DC, 0x30 },
-		{0xF8DD, 0x1b },
-		{0xF8DE, 0x74 },
-		{0xF8DF, 0x2a },
-		{0xF8E0, 0xf0 },
-		{0xF8E1, 0x90 },
-		{0xF8E2, 0x30 },
-		{0xF8E3, 0x35 },
-		{0xF8E4, 0x74 },
-		{0xF8E5, 0x03 },
-		{0xF8E6, 0xf0 },
-		{0xF8E7, 0x90 },
-		{0xF8E8, 0x41 },
-		{0xF8E9, 0x01 },
-		{0xF8EA, 0xe0 },
-		{0xF8EB, 0xf5 },
-		{0xF8EC, 0x79 },
-		{0xF8ED, 0x90 },
-		{0xF8EE, 0x43 },
-		{0xF8EF, 0x87 },
-		{0xF8F0, 0xe0 },
-		{0xF8F1, 0xf5 },
-		{0xF8F2, 0x7a },
-		{0xF8F3, 0x90 },
-		{0xF8F4, 0x42 },
-		{0xF8F5, 0x05 },
-		{0xF8F6, 0xe0 },
-		{0xF8F7, 0xf5 },
-		{0xF8F8, 0x7b },
-		{0xF8F9, 0x22 },
-		{0xF8FA, 0x78 },
-		{0xF8FB, 0x07 },
-		{0xF8FC, 0xe6 },
-		{0xF8FD, 0xf5 },
-		{0xF8FE, 0x7c },
-		{0xF8FF, 0xe5 },
-		{0xF900, 0x7c },
-		{0xF901, 0x60 },
-		{0xF902, 0x1e },
-		{0xF903, 0x90 },
-		{0xF904, 0x43 },
-		{0xF905, 0x83 },
-		{0xF906, 0xe0 },
-		{0xF907, 0xb4 },
-		{0xF908, 0x01 },
-		{0xF909, 0x17 },
-		{0xF90A, 0x90 },
-		{0xF90B, 0x43 },
-		{0xF90C, 0x87 },
-		{0xF90D, 0xe0 },
-		{0xF90E, 0xb4 },
-		{0xF90F, 0x01 },
-		{0xF910, 0x10 },
-		{0xF911, 0x15 },
-		{0xF912, 0x7c },
-		{0xF913, 0x90 },
-		{0xF914, 0x30 },
-		{0xF915, 0xa1 },
-		{0xF916, 0xe5 },
-		{0xF917, 0x7c },
-		{0xF918, 0xf0 },
-		{0xF919, 0x90 },
-		{0xF91A, 0x30 },
-		{0xF91B, 0xa0 },
-		{0xF91C, 0x74 },
-		{0xF91D, 0x01 },
-		{0xF91E, 0xf0 },
-		{0xF91F, 0x80 },
-		{0xF920, 0x05 },
-		{0xF921, 0xe4 },
-		{0xF922, 0x90 },
-		{0xF923, 0x30 },
-		{0xF924, 0xa0 },
-		{0xF925, 0xf0 },
-		{0xF926, 0x90 },
-		{0xF927, 0x41 },
-		{0xF928, 0x01 },
-		{0xF929, 0xe0 },
-		{0xF92A, 0xfc },
-		{0xF92B, 0x54 },
-		{0xF92C, 0x02 },
-		{0xF92D, 0xfe },
-		{0xF92E, 0xe5 },
-		{0xF92F, 0x79 },
-		{0xF930, 0x54 },
-		{0xF931, 0x02 },
-		{0xF932, 0xb5 },
-		{0xF933, 0x06 },
-		{0xF934, 0x0f },
-		{0xF935, 0x90 },
-		{0xF936, 0x43 },
-		{0xF937, 0x87 },
-		{0xF938, 0xe0 },
-		{0xF939, 0xb5 },
-		{0xF93A, 0x7a },
-		{0xF93B, 0x08 },
-		{0xF93C, 0x90 },
-		{0xF93D, 0x42 },
-		{0xF93E, 0x05 },
-		{0xF93F, 0xe0 },
-		{0xF940, 0x65 },
-		{0xF941, 0x7b },
-		{0xF942, 0x60 },
-		{0xF943, 0x0b },
-		{0xF944, 0x90 },
-		{0xF945, 0x30 },
-		{0xF946, 0x50 },
-		{0xF947, 0xe0 },
-		{0xF948, 0x54 },
-		{0xF949, 0xf9 },
-		{0xF94A, 0x44 },
-		{0xF94B, 0x02 },
-		{0xF94C, 0xf0 },
-		{0xF94D, 0x80 },
-		{0xF94E, 0x09 },
-		{0xF94F, 0x90 },
-		{0xF950, 0x30 },
-		{0xF951, 0x50 },
-		{0xF952, 0xe0 },
-		{0xF953, 0x54 },
-		{0xF954, 0xf9 },
-		{0xF955, 0x44 },
-		{0xF956, 0x04 },
-		{0xF957, 0xf0 },
-		{0xF958, 0x8c },
-		{0xF959, 0x79 },
-		{0xF95A, 0x90 },
-		{0xF95B, 0x43 },
-		{0xF95C, 0x87 },
-		{0xF95D, 0xe0 },
-		{0xF95E, 0xf5 },
-		{0xF95F, 0x7a },
-		{0xF960, 0x90 },
-		{0xF961, 0x42 },
-		{0xF962, 0x05 },
-		{0xF963, 0xe0 },
-		{0xF964, 0xf5 },
-		{0xF965, 0x7b },
-		{0xF966, 0x22 },
-		{0xF967, 0xc3 },
-		{0xF968, 0x90 },
-		{0xF969, 0x0b },
-		{0xF96A, 0x89 },
-		{0xF96B, 0xe0 },
-		{0xF96C, 0x94 },
-		{0xF96D, 0x1e },
-		{0xF96E, 0x90 },
-		{0xF96F, 0x0b },
-		{0xF970, 0x88 },
-		{0xF971, 0xe0 },
-		{0xF972, 0x94 },
-		{0xF973, 0x00 },
-		{0xF974, 0x50 },
-		{0xF975, 0x06 },
-		{0xF976, 0x7e },
-		{0xF977, 0x00 },
-		{0xF978, 0x7f },
-		{0xF979, 0x01 },
-		{0xF97A, 0x80 },
-		{0xF97B, 0x3d },
-		{0xF97C, 0xc3 },
-		{0xF97D, 0x90 },
-		{0xF97E, 0x0b },
-		{0xF97F, 0x89 },
-		{0xF980, 0xe0 },
-		{0xF981, 0x94 },
-		{0xF982, 0x3c },
-		{0xF983, 0x90 },
-		{0xF984, 0x0b },
-		{0xF985, 0x88 },
-		{0xF986, 0xe0 },
-		{0xF987, 0x94 },
-		{0xF988, 0x00 },
-		{0xF989, 0x50 },
-		{0xF98A, 0x06 },
-		{0xF98B, 0x7e },
-		{0xF98C, 0x00 },
-		{0xF98D, 0x7f },
-		{0xF98E, 0x02 },
-		{0xF98F, 0x80 },
-		{0xF990, 0x28 },
-		{0xF991, 0xc3 },
-		{0xF992, 0x90 },
-		{0xF993, 0x0b },
-		{0xF994, 0x89 },
-		{0xF995, 0xe0 },
-		{0xF996, 0x94 },
-		{0xF997, 0xfa },
-		{0xF998, 0x90 },
-		{0xF999, 0x0b },
-		{0xF99A, 0x88 },
-		{0xF99B, 0xe0 },
-		{0xF99C, 0x94 },
-		{0xF99D, 0x00 },
-		{0xF99E, 0x50 },
-		{0xF99F, 0x06 },
-		{0xF9A0, 0x7e },
-		{0xF9A1, 0x00 },
-		{0xF9A2, 0x7f },
-		{0xF9A3, 0x03 },
-		{0xF9A4, 0x80 },
-		{0xF9A5, 0x13 },
-		{0xF9A6, 0xc3 },
-		{0xF9A7, 0x90 },
-		{0xF9A8, 0x0b },
-		{0xF9A9, 0x88 },
-		{0xF9AA, 0xe0 },
-		{0xF9AB, 0x94 },
-		{0xF9AC, 0x80 },
-		{0xF9AD, 0x50 },
-		{0xF9AE, 0x06 },
-		{0xF9AF, 0x7e },
-		{0xF9B0, 0x00 },
-		{0xF9B1, 0x7f },
-		{0xF9B2, 0x04 },
-		{0xF9B3, 0x80 },
-		{0xF9B4, 0x04 },
-		{0xF9B5, 0xae },
-		{0xF9B6, 0x7e },
-		{0xF9B7, 0xaf },
-		{0xF9B8, 0x7f },
-		{0xF9B9, 0x90 },
-		{0xF9BA, 0xa0 },
-		{0xF9BB, 0xf8 },
-		{0xF9BC, 0xee },
-		{0xF9BD, 0xf0 },
-		{0xF9BE, 0xa3 },
-		{0xF9BF, 0xef },
-		{0xF9C0, 0xf0 },
-		{0xF9C1, 0x22 },
-		{0xF9C2, 0x90 },
-		{0xF9C3, 0x33 },
-		{0xF9C4, 0x82 },
-		{0xF9C5, 0xe0 },
-		{0xF9C6, 0xff },
-		{0xF9C7, 0x64 },
-		{0xF9C8, 0x01 },
-		{0xF9C9, 0x70 },
-		{0xF9CA, 0x30 },
-		{0xF9CB, 0xe5 },
-		{0xF9CC, 0x7f },
-		{0xF9CD, 0x64 },
-		{0xF9CE, 0x02 },
-		{0xF9CF, 0x45 },
-		{0xF9D0, 0x7e },
-		{0xF9D1, 0x70 },
-		{0xF9D2, 0x04 },
-		{0xF9D3, 0x7d },
-		{0xF9D4, 0x1e },
-		{0xF9D5, 0x80 },
-		{0xF9D6, 0x1d },
-		{0xF9D7, 0xe5 },
-		{0xF9D8, 0x7f },
-		{0xF9D9, 0x64 },
-		{0xF9DA, 0x03 },
-		{0xF9DB, 0x45 },
-		{0xF9DC, 0x7e },
-		{0xF9DD, 0x70 },
-		{0xF9DE, 0x04 },
-		{0xF9DF, 0x7d },
-		{0xF9E0, 0x3c },
-		{0xF9E1, 0x80 },
-		{0xF9E2, 0x11 },
-		{0xF9E3, 0xe5 },
-		{0xF9E4, 0x7f },
-		{0xF9E5, 0x64 },
-		{0xF9E6, 0x04 },
-		{0xF9E7, 0x45 },
-		{0xF9E8, 0x7e },
-		{0xF9E9, 0x70 },
-		{0xF9EA, 0x04 },
-		{0xF9EB, 0x7d },
-		{0xF9EC, 0xfa },
-		{0xF9ED, 0x80 },
-		{0xF9EE, 0x05 },
-		{0xF9EF, 0x90 },
-		{0xF9F0, 0x33 },
-		{0xF9F1, 0x81 },
-		{0xF9F2, 0xe0 },
-		{0xF9F3, 0xfd },
-		{0xF9F4, 0xae },
-		{0xF9F5, 0x05 },
-		{0xF9F6, 0x90 },
-		{0xF9F7, 0x33 },
-		{0xF9F8, 0x81 },
-		{0xF9F9, 0xed },
-		{0xF9FA, 0xf0 },
-		{0xF9FB, 0xef },
-		{0xF9FC, 0xb4 },
-		{0xF9FD, 0x01 },
-		{0xF9FE, 0x10 },
-		{0xF9FF, 0x90 },
-		{0xFA00, 0x01 },
-		{0xFA01, 0x00 },
-		{0xFA02, 0xe0 },
-		{0xFA03, 0x60 },
-		{0xFA04, 0x0a },
-		{0xFA05, 0x90 },
-		{0xFA06, 0xa1 },
-		{0xFA07, 0x10 },
-		{0xFA08, 0xe0 },
-		{0xFA09, 0xf5 },
-		{0xFA0A, 0x7e },
-		{0xFA0B, 0xa3 },
-		{0xFA0C, 0xe0 },
-		{0xFA0D, 0xf5 },
-		{0xFA0E, 0x7f },
-		{0xFA0F, 0x22 },
-		{0xFA10, 0x12 },
-		{0xFA11, 0x2f },
-		{0xFA12, 0x4d },
-		{0xFA13, 0x90 },
-		{0xFA14, 0x35 },
-		{0xFA15, 0x38 },
-		{0xFA16, 0xe0 },
-		{0xFA17, 0x70 },
-		{0xFA18, 0x05 },
-		{0xFA19, 0x12 },
-		{0xFA1A, 0x00 },
-		{0xFA1B, 0x0e },
-		{0xFA1C, 0x80 },
-		{0xFA1D, 0x03 },
-		{0xFA1E, 0x12 },
-		{0xFA1F, 0x07 },
-		{0xFA20, 0xc9 },
-		{0xFA21, 0x90 },
-		{0xFA22, 0x40 },
-		{0xFA23, 0x06 },
-		{0xFA24, 0xe0 },
-		{0xFA25, 0xf4 },
-		{0xFA26, 0x54 },
-		{0xFA27, 0x02 },
-		{0xFA28, 0xff },
-		{0xFA29, 0xe0 },
-		{0xFA2A, 0x54 },
-		{0xFA2B, 0x01 },
-		{0xFA2C, 0x4f },
-		{0xFA2D, 0x90 },
-		{0xFA2E, 0x31 },
-		{0xFA2F, 0x32 },
-		{0xFA30, 0xf0 },
-		{0xFA31, 0x90 },
-		{0xFA32, 0xfa },
-		{0xFA33, 0x9d },
-		{0xFA34, 0xe0 },
-		{0xFA35, 0x70 },
-		{0xFA36, 0x03 },
-		{0xFA37, 0x12 },
-		{0xFA38, 0x27 },
-		{0xFA39, 0x27 },
-		{0xFA3A, 0x02 },
-		{0xFA3B, 0x05 },
-		{0xFA3C, 0xac },
-		{0xFA3D, 0x22 },
-		{0xFA3E, 0xf0 },
-		{0xFA3F, 0xe5 },
-		{0xFA40, 0x3a },
-		{0xFA41, 0xb4 },
-		{0xFA42, 0x06 },
-		{0xFA43, 0x06 },
-		{0xFA44, 0x63 },
-		{0xFA45, 0x3e },
-		{0xFA46, 0x02 },
-		{0xFA47, 0x12 },
-		{0xFA48, 0x03 },
-		{0xFA49, 0xea },
-		{0xFA4A, 0x02 },
-		{0xFA4B, 0x17 },
-		{0xFA4C, 0x4a },
-		{0xFA4D, 0x22 },
-		{0x35C9, 0xFA },
-		{0x35CA, 0x01 },
-		{0x35CB, 0x67 },
-		{0x35CC, 0x01 },
-		{0x35CD, 0xC2 },
-		{0x35CE, 0x02 },
-		{0x35CF, 0x10 },
-		{0x35D0, 0x02 },
-		{0x35D1, 0x3E },
-		{0x35D3, 0xF6 },
-		{0x35D5, 0x07 },
-		{0x35D7, 0xA3 },
-		{0x35DB, 0x02 },
-		{0x35DD, 0x06 },
-		{0x35DF, 0x27 },
-		{0x35E6, 0x28 },
-		{0x35E7, 0x76 },
-		{0x35E8, 0x2A },
-		{0x35E9, 0x15 },
-		{0x35EA, 0x2D },
-		{0x35EB, 0x07 },
-		{0x35EC, 0x04 },
-		{0x35ED, 0x43 },
-		{0x35EE, 0x05 },
-		{0x35EF, 0xA9 },
-		{0x35F0, 0x17 },
-		{0x35F1, 0x41 },
-		{0x35F2, 0x24 },
-		{0x35F3, 0x88 },
-		{0x35F4, 0x01 },
-		{0x35F5, 0x54 },
-		{0x35F6, 0x01 },
-		{0x35F7, 0x55 },
-		{0x35F8, 0x2E },
-		{0x35F9, 0xF2 },
-		{0x35FA, 0x06 },
-		{0x35FB, 0x02 },
-		{0x35FC, 0x06 },
-		{0x35FD, 0x03 },
-		{0x35FE, 0x06 },
-		{0x35FF, 0x04 },
-		{0x3600, 0x0F },
-		{0x3601, 0x48 },
-		{0x3602, 0x0F },
-		{0x3603, 0x49 },
-		{0x3604, 0x0F },
-		{0x3605, 0x4A },
-		{0x35C2, 0xFF },
-		{0x35C3, 0xFF },
-		{0x35C4, 0xFF },
-		{0x35C5, 0xC0 },
-		{0x35C0, 0x01 },
-
-
-		{0xa098, 0x02 },
-		{0xa099, 0x87 },
-		{0xa09c, 0x00 },
-		{0xa09d, 0xc5 },
-		{0xa4ec, 0x05 },
-		{0xa4ed, 0x05 },
-		{0xa4f0, 0x04 },
-		{0xa4f1, 0x04 },
-		{0xa4f4, 0x04 },
-		{0xa4f5, 0x05 },
-		{0xa4f8, 0x05 },
-		{0xa4f9, 0x07 },
-		{0xa4fc, 0x07 },
-		{0xa4fd, 0x07 },
-		{0xa500, 0x07 },
-		{0xa501, 0x07 },
-		{0xa504, 0x08 },
-		{0xa505, 0x08 },
-		{0xa518, 0x01 },
-		{0xa519, 0x02 },
-		{0xa51c, 0x01 },
-		{0xa51d, 0x00 },
-		{0xa534, 0x00 },
-		{0xa535, 0x04 },
-		{0xa538, 0x04 },
-		{0xa539, 0x03 },
-		{0xa53c, 0x05 },
-		{0xa53d, 0x07 },
-		{0xa540, 0x07 },
-		{0xa541, 0x06 },
-		{0xa544, 0x07 },
-		{0xa545, 0x06 },
-		{0xa548, 0x05 },
-		{0xa549, 0x06 },
-		{0xa54c, 0x06 },
-		{0xa54d, 0x07 },
-		{0xa550, 0x07 },
-		{0xa551, 0x04 },
-		{0xa554, 0x04 },
-		{0xa555, 0x04 },
-		{0xa558, 0x05 },
-		{0xa559, 0x06 },
-		{0xa55c, 0x07 },
-		{0xa55d, 0x07 },
-		{0xa56c, 0x00 },
-		{0xa56d, 0x0a },
-		{0xa570, 0x08 },
-		{0xa571, 0x05 },
-		{0xa574, 0x04 },
-		{0xa575, 0x03 },
-		{0xa578, 0x04 },
-		{0xa579, 0x04 },
-		{0xa58c, 0x1f },
-		{0xa58d, 0x1b },
-		{0xa590, 0x17 },
-		{0xa591, 0x13 },
-		{0xa594, 0x10 },
-		{0xa595, 0x0d },
-		{0xa598, 0x0f },
-		{0xa599, 0x11 },
-		{0xa59c, 0x03 },
-		{0xa59d, 0x03 },
-		{0xa5a0, 0x03 },
-		{0xa5a1, 0x03 },
-		{0xa5a4, 0x03 },
-		{0xa5a5, 0x04 },
-		{0xa5a8, 0x05 },
-		{0xa5a9, 0x00 },
-		{0xa5ac, 0x00 },
-		{0xa5ad, 0x00 },
-		{0xa5b0, 0x00 },
-		{0xa5b1, 0x00 },
-		{0xa5b4, 0x00 },
-		{0xa5b5, 0x00 },
-		{0xa5c4, 0x1f },
-		{0xa5c5, 0x13 },
-		{0xa5c8, 0x14 },
-		{0xa5c9, 0x14 },
-		{0xa5cc, 0x14 },
-		{0xa5cd, 0x13 },
-		{0xa5d0, 0x17 },
-		{0xa5d1, 0x1a },
-		{0xa5f4, 0x05 },
-		{0xa5f5, 0x05 },
-		{0xa5f8, 0x05 },
-		{0xa5f9, 0x06 },
-		{0xa5fc, 0x06 },
-		{0xa5fd, 0x06 },
-		{0xa600, 0x06 },
-		{0xa601, 0x06 },
-		{0xa608, 0x07 },
-		{0xa609, 0x08 },
-		{0xa60c, 0x08 },
-		{0xa60d, 0x07 },
-		{0xa63c, 0x00 },
-		{0xa63d, 0x02 },
-		{0xa640, 0x02 },
-		{0xa641, 0x02 },
-		{0xa644, 0x02 },
-		{0xa645, 0x02 },
-		{0xa648, 0x03 },
-		{0xa649, 0x04 },
-		{0xa64c, 0x0a },
-		{0xa64d, 0x09 },
-		{0xa650, 0x08 },
-		{0xa651, 0x09 },
-		{0xa654, 0x09 },
-		{0xa655, 0x0a },
-		{0xa658, 0x0a },
-		{0xa659, 0x0a },
-		{0xa65c, 0x0a },
-		{0xa65d, 0x09 },
-		{0xa660, 0x09 },
-		{0xa661, 0x09 },
-		{0xa664, 0x09 },
-		{0xa665, 0x08 },
-		{0xa680, 0x01 },
-		{0xa681, 0x02 },
-		{0xa694, 0x1f },
-		{0xa695, 0x10 },
-		{0xa698, 0x0e },
-		{0xa699, 0x0c },
-		{0xa69c, 0x0d },
-		{0xa69d, 0x0d },
-		{0xa6a0, 0x0f },
-		{0xa6a1, 0x11 },
-		{0xa6a4, 0x00 },
-		{0xa6a5, 0x00 },
-		{0xa6a8, 0x00 },
-		{0xa6a9, 0x00 },
-		{0xa6ac, 0x00 },
-		{0xa6ad, 0x00 },
-		{0xa6b0, 0x00 },
-		{0xa6b1, 0x04 },
-		{0xa6b4, 0x04 },
-		{0xa6b5, 0x04 },
-		{0xa6b8, 0x04 },
-		{0xa6b9, 0x04 },
-		{0xa6bc, 0x05 },
-		{0xa6bd, 0x05 },
-		{0xa6c0, 0x1f },
-		{0xa6c1, 0x1f },
-		{0xa6c4, 0x1f },
-		{0xa6c5, 0x1f },
-		{0xa6c8, 0x1f },
-		{0xa6c9, 0x1f },
-		{0xa6cc, 0x1f },
-		{0xa6cd, 0x0b },
-		{0xa6d0, 0x0c },
-		{0xa6d1, 0x0d },
-		{0xa6d4, 0x0d },
-		{0xa6d5, 0x0d },
-		{0xa6d8, 0x11 },
-		{0xa6d9, 0x14 },
-		{0xa6fc, 0x02 },
-		{0xa6fd, 0x03 },
-		{0xa700, 0x03 },
-		{0xa701, 0x03 },
-		{0xa704, 0x03 },
-		{0xa705, 0x04 },
-		{0xa708, 0x05 },
-		{0xa709, 0x02 },
-		{0xa70c, 0x02 },
-		{0xa70d, 0x02 },
-		{0xa710, 0x03 },
-		{0xa711, 0x04 },
-		{0xa714, 0x04 },
-		{0xa715, 0x04 },
-		{0xa744, 0x00 },
-		{0xa745, 0x03 },
-		{0xa748, 0x04 },
-		{0xa749, 0x04 },
-		{0xa74c, 0x05 },
-		{0xa74d, 0x06 },
-		{0xa750, 0x07 },
-		{0xa751, 0x07 },
-		{0xa754, 0x05 },
-		{0xa755, 0x05 },
-		{0xa758, 0x05 },
-		{0xa759, 0x05 },
-		{0xa75c, 0x05 },
-		{0xa75d, 0x06 },
-		{0xa760, 0x07 },
-		{0xa761, 0x07 },
-		{0xa764, 0x06 },
-		{0xa765, 0x05 },
-		{0xa768, 0x05 },
-		{0xa769, 0x05 },
-		{0xa76c, 0x06 },
-		{0xa76d, 0x07 },
-		{0xa77c, 0x00 },
-		{0xa77d, 0x05 },
-		{0xa780, 0x05 },
-		{0xa781, 0x05 },
-		{0xa784, 0x05 },
-		{0xa785, 0x04 },
-		{0xa788, 0x05 },
-		{0xa789, 0x06 },
-		{0xa79c, 0x1f },
-		{0xa79d, 0x15 },
-		{0xa7a0, 0x13 },
-		{0xa7a1, 0x10 },
-		{0xa7a4, 0x0f },
-		{0xa7a5, 0x0d },
-		{0xa7a8, 0x11 },
-		{0xa7a9, 0x14 },
-		{0xa7ac, 0x02 },
-		{0xa7ad, 0x02 },
-		{0xa7b0, 0x02 },
-		{0xa7b1, 0x02 },
-		{0xa7b4, 0x02 },
-		{0xa7b5, 0x03 },
-		{0xa7b8, 0x03 },
-		{0xa7b9, 0x00 },
-		{0xa7bc, 0x00 },
-		{0xa7bd, 0x00 },
-		{0xa7c0, 0x00 },
-		{0xa7c1, 0x00 },
-		{0xa7c4, 0x00 },
-		{0xa7c5, 0x00 },
-		{0xa7d4, 0x1f },
-		{0xa7d5, 0x0d },
-		{0xa7d8, 0x0f },
-		{0xa7d9, 0x10 },
-		{0xa7dc, 0x10 },
-		{0xa7dd, 0x10 },
-		{0xa7e0, 0x13 },
-		{0xa7e1, 0x16 },
-		{0xa7f4, 0x00 },
-		{0xa7f5, 0x03 },
-		{0xa7f8, 0x04 },
-		{0xa7f9, 0x04 },
-		{0xa7fc, 0x04 },
-		{0xa7fd, 0x03 },
-		{0xa800, 0x03 },
-		{0xa801, 0x03 },
-		{0xa804, 0x03 },
-		{0xa805, 0x03 },
-		{0xa808, 0x03 },
-		{0xa809, 0x03 },
-		{0xa80c, 0x03 },
-		{0xa80d, 0x04 },
-		{0xa810, 0x04 },
-		{0xa811, 0x0a },
-		{0xa814, 0x0a },
-		{0xa815, 0x0a },
-		{0xa818, 0x0f },
-		{0xa819, 0x14 },
-		{0xa81c, 0x14 },
-		{0xa81d, 0x14 },
-		{0xa82c, 0x00 },
-		{0xa82d, 0x04 },
-		{0xa830, 0x02 },
-		{0xa831, 0x00 },
-		{0xa834, 0x00 },
-		{0xa835, 0x00 },
-		{0xa838, 0x00 },
-		{0xa839, 0x00 },
-		{0xa840, 0x1f },
-		{0xa841, 0x1f },
-		{0xa848, 0x1f },
-		{0xa849, 0x1f },
-		{0xa84c, 0x1f },
-		{0xa84d, 0x0c },
-		{0xa850, 0x0c },
-		{0xa851, 0x0c },
-		{0xa854, 0x0c },
-		{0xa855, 0x0c },
-		{0xa858, 0x0c },
-		{0xa859, 0x0c },
-		{0xa85c, 0x0c },
-		{0xa85d, 0x0c },
-		{0xa860, 0x0c },
-		{0xa861, 0x0c },
-		{0xa864, 0x0c },
-		{0xa865, 0x0c },
-		{0xa868, 0x0c },
-		{0xa869, 0x0c },
-		{0xa86c, 0x0c },
-		{0xa86d, 0x0c },
-		{0xa870, 0x0c },
-		{0xa871, 0x0c },
-		{0xa874, 0x0c },
-		{0xa875, 0x0c },
-		{0xa878, 0x1f },
-		{0xa879, 0x1f },
-		{0xa87c, 0x1f },
-		{0xa87d, 0x1f },
-		{0xa880, 0x1f },
-		{0xa881, 0x1f },
-		{0xa884, 0x1f },
-		{0xa885, 0x0c },
-		{0xa888, 0x0c },
-		{0xa889, 0x0c },
-		{0xa88c, 0x0c },
-		{0xa88d, 0x0c },
-		{0xa890, 0x0c },
-		{0xa891, 0x0c },
-		{0xa898, 0x1f },
-		{0xa899, 0x1f },
-		{0xa8a0, 0x1f },
-		{0xa8a1, 0x1f },
-		{0xa8a4, 0x1f },
-		{0xa8a5, 0x0c },
-		{0xa8a8, 0x0c },
-		{0xa8a9, 0x0c },
-		{0xa8ac, 0x0c },
-		{0xa8ad, 0x0c },
-		{0xa8b0, 0x0c },
-		{0xa8b1, 0x0c },
-		{0xa8b4, 0x0c },
-		{0xa8b5, 0x0c },
-		{0xa8b8, 0x0c },
-		{0xa8b9, 0x0c },
-		{0xa8bc, 0x0c },
-		{0xa8bd, 0x0c },
-		{0xa8c0, 0x0c },
-		{0xa8c1, 0x0c },
-		{0xa8c4, 0x0c },
-		{0xa8c5, 0x0c },
-		{0xa8c8, 0x0c },
-		{0xa8c9, 0x0c },
-		{0xa8cc, 0x0c },
-		{0xa8cd, 0x0c },
-		{0xa8d0, 0x1f },
-		{0xa8d1, 0x1f },
-		{0xa8d4, 0x1f },
-		{0xa8d5, 0x1f },
-		{0xa8d8, 0x1f },
-		{0xa8d9, 0x1f },
-		{0xa8dc, 0x1f },
-		{0xa8dd, 0x0c },
-		{0xa8e0, 0x0c },
-		{0xa8e1, 0x0c },
-		{0xa8e4, 0x0c },
-		{0xa8e5, 0x0c },
-		{0xa8e8, 0x0c },
-		{0xa8e9, 0x0c },
-		{0xa8f0, 0x1f },
-		{0xa8f1, 0x1f },
-		{0xa8f8, 0x1f },
-		{0xa8f9, 0x1f },
-		{0xa8fc, 0x1f },
-		{0xa8fd, 0x0c },
-		{0xa900, 0x0c },
-		{0xa901, 0x0c },
-		{0xa904, 0x0c },
-		{0xa905, 0x0c },
-		{0xa908, 0x0c },
-		{0xa909, 0x0c },
-		{0xa90c, 0x0c },
-		{0xa90d, 0x0c },
-		{0xa910, 0x0c },
-		{0xa911, 0x0c },
-		{0xa914, 0x0c },
-		{0xa915, 0x0c },
-		{0xa918, 0x0c },
-		{0xa919, 0x0c },
-		{0xa91c, 0x0c },
-		{0xa91d, 0x0c },
-		{0xa920, 0x0c },
-		{0xa921, 0x0c },
-		{0xa924, 0x0c },
-		{0xa925, 0x0c },
-		{0xa928, 0x1f },
-		{0xa929, 0x1f },
-		{0xa92c, 0x1f },
-		{0xa92d, 0x1f },
-		{0xa930, 0x1f },
-		{0xa931, 0x1f },
-		{0xa934, 0x1f },
-		{0xa935, 0x0c },
-		{0xa938, 0x0c },
-		{0xa939, 0x0c },
-		{0xa93c, 0x0c },
-		{0xa93d, 0x0c },
-		{0xa940, 0x0c },
-		{0xa941, 0x0c },
-		{0xa96c, 0x0d },
-		{0xa96d, 0x16 },
-		{0xa970, 0x19 },
-		{0xa971, 0x0e },
-		{0xa974, 0x16 },
-		{0xa975, 0x1a },
-		{0xa978, 0x0d },
-		{0xa979, 0x15 },
-		{0xa97c, 0x19 },
-		{0xa97d, 0x0d },
-		{0xa980, 0x15 },
-		{0xa981, 0x1a },
-		{0xa984, 0x0d },
-		{0xa985, 0x15 },
-		{0xa988, 0x1a },
-		{0xa989, 0x0d },
-		{0xa98c, 0x15 },
-		{0xa98d, 0x1a },
-		{0xa990, 0x0b },
-		{0xa991, 0x11 },
-		{0xa994, 0x02 },
-		{0xa995, 0x0e },
-		{0xa998, 0x16 },
-		{0xa999, 0x02 },
-		{0xa99c, 0x0c },
-		{0xa99d, 0x13 },
-		{0xa9a0, 0x02 },
-		{0xa9a1, 0x0c },
-		{0xa9a4, 0x12 },
-		{0xa9a5, 0x02 },
-		{0xa9a8, 0x0c },
-		{0xa9a9, 0x12 },
-		{0xa9ac, 0x02 },
-		{0xa9ad, 0x0c },
-		{0xa9b0, 0x12 },
-		{0xa9b1, 0x02 },
-		{0xa9b4, 0x10 },
-		{0xa9b5, 0x1e },
-		{0xa9b8, 0x0f },
-		{0xa9b9, 0x13 },
-		{0xa9bc, 0x20 },
-		{0xa9bd, 0x10 },
-		{0xa9c0, 0x11 },
-		{0xa9c1, 0x1e },
-		{0xa9c4, 0x10 },
-		{0xa9c5, 0x11 },
-		{0xa9c8, 0x1e },
-		{0xa9c9, 0x10 },
-		{0xa9cc, 0x11 },
-		{0xa9cd, 0x20 },
-		{0xa9d0, 0x10 },
-		{0xa9d1, 0x13 },
-		{0xa9d4, 0x24 },
-		{0xa9d5, 0x10 },
-		{0xa9f0, 0x02 },
-		{0xa9f1, 0x01 },
-		{0xa9f8, 0x19 },
-		{0xa9f9, 0x0b },
-		{0xa9fc, 0x0a },
-		{0xa9fd, 0x07 },
-		{0xaa00, 0x0c },
-		{0xaa01, 0x0e },
-		{0xaa08, 0x0c },
-		{0xaa09, 0x06 },
-		{0xaa0c, 0x0c },
-		{0xaa0d, 0x0a },
-		{0xaa24, 0x10 },
-		{0xaa25, 0x12 },
-		{0xaa28, 0x0b },
-		{0xaa29, 0x07 },
-		{0xaa2c, 0x10 },
-		{0xaa2d, 0x14 },
-		{0xaa34, 0x0e },
-		{0xaa35, 0x0e },
-		{0xaa38, 0x07 },
-		{0xaa39, 0x07 },
-		{0xaa3c, 0x0e },
-		{0xaa3d, 0x0c },
-		{0xaa48, 0x09 },
-		{0xaa49, 0x0c },
-		{0xaa4c, 0x0c },
-		{0xaa4d, 0x07 },
-		{0xaa54, 0x08 },
-		{0xaa55, 0x06 },
-		{0xaa58, 0x04 },
-		{0xaa59, 0x05 },
-		{0xaa5c, 0x06 },
-		{0xaa5d, 0x06 },
-		{0xaa68, 0x05 },
-		{0xaa69, 0x05 },
-		{0xaa6c, 0x04 },
-		{0xaa6d, 0x05 },
-		{0xaa74, 0x06 },
-		{0xaa75, 0x04 },
-		{0xaa78, 0x05 },
-		{0xaa79, 0x05 },
-		{0xaa7c, 0x04 },
-		{0xaa7d, 0x06 },
-		{0xac18, 0x14 },
-		{0xac19, 0x00 },
-		{0xac1c, 0x14 },
-		{0xac1d, 0x00 },
-		{0xac20, 0x14 },
-		{0xac21, 0x00 },
-		{0xac24, 0x14 },
-		{0xac25, 0x00 },
-		{0xac28, 0x14 },
-		{0xac29, 0x00 },
-		{0xac2c, 0x14 },
-		{0xac2d, 0x00 },
-		{0xac34, 0x16 },
-		{0xac35, 0x00 },
-		{0xac38, 0x16 },
-		{0xac39, 0x00 },
-		{0xac3c, 0x16 },
-		{0xac3d, 0x00 },
-		{0xac40, 0x16 },
-		{0xac41, 0x00 },
-		{0xac44, 0x16 },
-		{0xac45, 0x00 },
-		{0xac48, 0x16 },
-		{0xac49, 0x00 },
-		{0xac50, 0x1b },
-		{0xac51, 0x00 },
-		{0xac54, 0x1b },
-		{0xac55, 0x00 },
-		{0xac58, 0x1b },
-		{0xac59, 0x00 },
-		{0xac5c, 0x1b },
-		{0xac5d, 0x00 },
-		{0xac60, 0x1b },
-		{0xac61, 0x00 },
-		{0xac64, 0x1b },
-		{0xac65, 0x00 },
-		{0xac74, 0x09 },
-		{0xac75, 0x0c },
-		{0xac78, 0x0f },
-		{0xac79, 0x11 },
-		{0xac7c, 0x12 },
-		{0xac7d, 0x14 },
-		{0xac80, 0x09 },
-		{0xac81, 0x0c },
-		{0xac84, 0x0f },
-		{0xac85, 0x11 },
-		{0xac88, 0x12 },
-		{0xac89, 0x14 },
-		{0xac8c, 0x09 },
-		{0xac8d, 0x0c },
-		{0xac90, 0x0f },
-		{0xac91, 0x11 },
-		{0xac94, 0x12 },
-		{0xac95, 0x14 },
-		{0xac98, 0x09 },
-		{0xac99, 0x0c },
-		{0xac9c, 0x0f },
-		{0xac9d, 0x11 },
-		{0xaca0, 0x12 },
-		{0xaca1, 0x14 },
-		{0xaca4, 0x09 },
-		{0xaca5, 0x0c },
-		{0xaca8, 0x0f },
-		{0xaca9, 0x11 },
-		{0xacac, 0x12 },
-		{0xacad, 0x14 },
-		{0xacb0, 0x07 },
-		{0xacb1, 0x09 },
-		{0xacb4, 0x0c },
-		{0xacb5, 0x0d },
-		{0xacb8, 0x0d },
-		{0xacb9, 0x0e },
-		{0xacbc, 0x05 },
-		{0xacbd, 0x07 },
-		{0xacc0, 0x0a },
-		{0xacc1, 0x0b },
-		{0xacc4, 0x0b },
-		{0xacc5, 0x0c },
-		{0xacc8, 0x03 },
-		{0xacc9, 0x04 },
-		{0xaccc, 0x07 },
-		{0xaccd, 0x08 },
-		{0xacd0, 0x09 },
-		{0xacd1, 0x09 },
-		{0x35B5, 0x01 },
-		{0x35BC, 0x01 },
-		{0x360A, 0x02 },
-		{0xFA9B, 0x01 },
-};
-
-#define NUM_LSC_CAST_REGS      33
-
-enum LSC_Cast_t{
-	cast_H = 0,
-	cast_U30,
-	cast_CW,
-	cast_D,
-	cast_MAX
-};
-
-static short int LSC_CorrectionForCast[cast_MAX][NUM_LSC_CAST_REGS] = {
-	{-30, -20,  8, 11, -16, -26, -35, -53, -9, -10, 44, 57, -39,
-		-14, 50, -173, -38, -32, -1, 9, 39, 51, -33, -49, -28,
-		-22, 7, 11, -21, 17, -62, -56, 0},
-	{-29, -18,  6,  1,  17, -35, -77, 0, 5, -17, -6, -22, -41, -1,
-		-37, 83, -38, -32, 1, -2, 15, 25, -67, 19, -28, -22, 5,
-		2, -18, 21, -86, 0, 0},
-	{-10, -15, -4, -6,  -8,  -3, -63, 8, 25, -9, -39, -51, -9,
-		0, -21, 112, -10, -23, -7, -9, 10, 18, -11, 23, -10,
-		-15, -4, -6, -10, -3, -52, 7, 0},
-	{  5,   3, -4, -5,  -1,   3,   4, 8, 12, 3, -22, -21, 7, 17,
-		2, 35, 8, 2, -3, -2, -9, -5, 10, 4, 9, 2, -4, -5,
-		-2, 0, -6, 9, 0}
-};
-
-static unsigned short LSC_CastRegs[] = {
-	0xFB7E,			/* H   */
-	0xFB3C,			/* U30 */
-	0xFAFA,			/* CW  */
-	0xFAB8			/* D65 */
-};
-
-/*=============================================================*/
-
-static int vx6953_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   = 2,
-			.buf   = rxdata,
-		},
-	};
-	if (i2c_transfer(vx6953_client->adapter, msgs, 2) < 0) {
-		CDBG("vx6953_i2c_rxdata failed!\n");
-		return -EIO;
-	}
-	return 0;
-}
-static int32_t vx6953_i2c_txdata(unsigned short saddr,
-				unsigned char *txdata, int length)
-{
-	struct i2c_msg msg[] = {
-		{
-			.addr = saddr,
-			.flags = 0,
-			.len = length,
-			.buf = txdata,
-		 },
-	};
-	if (i2c_transfer(vx6953_client->adapter, msg, 1) < 0) {
-		CDBG("vx6953_i2c_txdata faild 0x%x\n", vx6953_client->addr);
-		return -EIO;
-	}
-
-	return 0;
-}
-
-
-static int32_t vx6953_i2c_read(unsigned short raddr,
-	unsigned short *rdata, int rlen)
-{
-	int32_t rc = 0;
-	unsigned char buf[2];
-	if (!rdata)
-		return -EIO;
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (raddr & 0xFF00) >> 8;
-	buf[1] = (raddr & 0x00FF);
-	rc = vx6953_i2c_rxdata(vx6953_client->addr>>1, buf, rlen);
-	if (rc < 0) {
-		CDBG("vx6953_i2c_read 0x%x failed!\n", raddr);
-		return rc;
-	}
-	*rdata = (rlen == 2 ? buf[0] << 8 | buf[1] : buf[0]);
-	return rc;
-}
-static int32_t vx6953_i2c_write_b_sensor(unsigned short waddr, uint8_t bdata)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[3];
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00) >> 8;
-	buf[1] = (waddr & 0x00FF);
-	buf[2] = bdata;
-	CDBG("i2c_write_b addr = 0x%x, val = 0x%x\n", waddr, bdata);
-	rc = vx6953_i2c_txdata(vx6953_client->addr>>1, buf, 3);
-	if (rc < 0) {
-		CDBG("i2c_write_b failed, addr = 0x%x, val = 0x%x!\n",
-			waddr, bdata);
-	}
-	return rc;
-}
-static int32_t vx6953_i2c_write_w_sensor(unsigned short waddr, uint16_t wdata)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[4];
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00) >> 8;
-	buf[1] = (waddr & 0x00FF);
-	buf[2] = (wdata & 0xFF00) >> 8;
-	buf[3] = (wdata & 0x00FF);
-	CDBG("i2c_write_b addr = 0x%x, val = 0x%x\n", waddr, wdata);
-	rc = vx6953_i2c_txdata(vx6953_client->addr>>1, buf, 4);
-	if (rc < 0) {
-		CDBG("i2c_write_b failed, addr = 0x%x, val = 0x%x!\n",
-			waddr, wdata);
-	}
-	return rc;
-}
-static int32_t vx6953_i2c_write_seq_sensor(unsigned short waddr,
-	uint8_t *bdata, uint16_t len)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[len+2];
-	int i;
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00) >> 8;
-	buf[1] = (waddr & 0x00FF);
-	for (i = 2; i < len+2; i++)
-		buf[i] = *bdata++;
-	rc = vx6953_i2c_txdata(vx6953_client->addr>>1, buf, len+2);
-	if (rc < 0) {
-		CDBG("i2c_write_b failed, addr = 0x%x, val = 0x%x!\n",
-			 waddr, bdata[0]);
-	}
-	return rc;
-}
-
-static int32_t vx6953_i2c_write_w_table(struct vx6953_i2c_reg_conf const
-					 *reg_conf_tbl, int num)
-{
-	int i;
-	int32_t rc = -EIO;
-	for (i = 0; i < num; i++) {
-		rc = vx6953_i2c_write_b_sensor(reg_conf_tbl->waddr,
-			reg_conf_tbl->wdata);
-		if (rc < 0)
-			break;
-		reg_conf_tbl++;
-	}
-	return rc;
-}
-
-static void vx6953_get_pict_fps(uint16_t fps, uint16_t *pfps)
-{
-	/* input fps is preview fps in Q8 format */
-	uint16_t preview_frame_length_lines, snapshot_frame_length_lines;
-	uint16_t preview_line_length_pck, snapshot_line_length_pck;
-	uint32_t divider, d1, d2;
-	/* Total frame_length_lines and line_length_pck for preview */
-	preview_frame_length_lines = VX6953_QTR_SIZE_HEIGHT +
-		VX6953_VER_QTR_BLK_LINES;
-	preview_line_length_pck = VX6953_QTR_SIZE_WIDTH +
-		VX6953_HRZ_QTR_BLK_PIXELS;
-	/* Total frame_length_lines and line_length_pck for snapshot */
-	snapshot_frame_length_lines = VX6953_FULL_SIZE_HEIGHT +
-		VX6953_VER_FULL_BLK_LINES;
-	snapshot_line_length_pck = VX6953_FULL_SIZE_WIDTH +
-		VX6953_HRZ_FULL_BLK_PIXELS;
-	d1 = preview_frame_length_lines * 0x00000400/
-		snapshot_frame_length_lines;
-	d2 = preview_line_length_pck * 0x00000400/
-		snapshot_line_length_pck;
-	divider = d1 * d2 / 0x400;
-	/*Verify PCLK settings and frame sizes.*/
-	*pfps = (uint16_t) (fps * divider / 0x400);
-	/* 2 is the ratio of no.of snapshot channels
-	to number of preview channels */
-
-}
-
-static uint16_t vx6953_get_prev_lines_pf(void)
-{
-	if (vx6953_ctrl->prev_res == QTR_SIZE)
-		return VX6953_QTR_SIZE_HEIGHT + VX6953_VER_QTR_BLK_LINES;
-	else
-		return VX6953_FULL_SIZE_HEIGHT + VX6953_VER_FULL_BLK_LINES;
-
-}
-
-static uint16_t vx6953_get_prev_pixels_pl(void)
-{
-	if (vx6953_ctrl->prev_res == QTR_SIZE)
-		return VX6953_QTR_SIZE_WIDTH + VX6953_HRZ_QTR_BLK_PIXELS;
-	else
-		return VX6953_FULL_SIZE_WIDTH + VX6953_HRZ_FULL_BLK_PIXELS;
-}
-
-static uint16_t vx6953_get_pict_lines_pf(void)
-{
-		if (vx6953_ctrl->pict_res == QTR_SIZE)
-			return VX6953_QTR_SIZE_HEIGHT +
-				VX6953_VER_QTR_BLK_LINES;
-		else
-			return VX6953_FULL_SIZE_HEIGHT +
-				VX6953_VER_FULL_BLK_LINES;
-}
-
-static uint16_t vx6953_get_pict_pixels_pl(void)
-{
-	if (vx6953_ctrl->pict_res == QTR_SIZE)
-		return VX6953_QTR_SIZE_WIDTH +
-			VX6953_HRZ_QTR_BLK_PIXELS;
-	else
-		return VX6953_FULL_SIZE_WIDTH +
-			VX6953_HRZ_FULL_BLK_PIXELS;
-}
-
-static uint32_t vx6953_get_pict_max_exp_lc(void)
-{
-	if (vx6953_ctrl->pict_res == QTR_SIZE)
-		return (VX6953_QTR_SIZE_HEIGHT +
-			VX6953_VER_QTR_BLK_LINES)*24;
-	else
-		return (VX6953_FULL_SIZE_HEIGHT +
-			VX6953_VER_FULL_BLK_LINES)*24;
-}
-
-static int32_t vx6953_set_fps(struct fps_cfg	*fps)
-{
-	uint16_t total_lines_per_frame;
-	int32_t rc = 0;
-	total_lines_per_frame = (uint16_t)((VX6953_QTR_SIZE_HEIGHT +
-		VX6953_VER_QTR_BLK_LINES) * vx6953_ctrl->fps_divider/0x400);
-
-	vx6953_i2c_write_b_sensor(REG_GROUPED_PARAMETER_HOLD,
-		GROUPED_PARAMETER_HOLD);
-	if (vx6953_i2c_write_b_sensor(REG_FRAME_LENGTH_LINES_HI,
-		((total_lines_per_frame & 0xFF00) >> 8)) < 0)
-		return rc;
-	if (vx6953_i2c_write_b_sensor(REG_FRAME_LENGTH_LINES_LO,
-		(total_lines_per_frame & 0x00FF)) < 0)
-		return rc;
-	vx6953_i2c_write_b_sensor(REG_GROUPED_PARAMETER_HOLD,
-		GROUPED_PARAMETER_HOLD_OFF);
-	return rc;
-}
-
-static int32_t vx6953_write_exp_gain(uint16_t gain, uint32_t line)
-{
-	uint16_t line_length_pck, frame_length_lines;
-	uint8_t gain_hi, gain_lo;
-	uint8_t intg_time_hi, intg_time_lo;
-	uint8_t frame_length_lines_hi = 0, frame_length_lines_lo = 0;
-	int32_t rc = 0;
-	if (vx6953_ctrl->sensormode != SENSOR_SNAPSHOT_MODE) {
-		frame_length_lines = VX6953_QTR_SIZE_HEIGHT +
-		VX6953_VER_QTR_BLK_LINES;
-		line_length_pck = VX6953_QTR_SIZE_WIDTH +
-			VX6953_HRZ_QTR_BLK_PIXELS;
-		if (line > (frame_length_lines -
-			VX6953_STM5M0EDOF_OFFSET)) {
-			vx6953_ctrl->fps = (uint16_t) (30 * Q8 *
-			(frame_length_lines - VX6953_STM5M0EDOF_OFFSET)/
-			line);
-		} else {
-			vx6953_ctrl->fps = (uint16_t) (30 * Q8);
-		}
-	} else {
-		frame_length_lines = VX6953_FULL_SIZE_HEIGHT +
-				VX6953_VER_FULL_BLK_LINES;
-		line_length_pck = VX6953_FULL_SIZE_WIDTH +
-				VX6953_HRZ_FULL_BLK_PIXELS;
-	}
-
-	vx6953_i2c_write_b_sensor(REG_GROUPED_PARAMETER_HOLD,
-		GROUPED_PARAMETER_HOLD);
-	if ((line + VX6953_STM5M0EDOF_OFFSET) > MAX_FRAME_LENGTH_LINES) {
-		frame_length_lines = MAX_FRAME_LENGTH_LINES;
-		line = MAX_FRAME_LENGTH_LINES - VX6953_STM5M0EDOF_OFFSET;
-	} else if ((line + VX6953_STM5M0EDOF_OFFSET) > frame_length_lines) {
-		frame_length_lines = line + VX6953_STM5M0EDOF_OFFSET;
-		line = frame_length_lines;
-	}
-
-	frame_length_lines_hi = (uint8_t) ((frame_length_lines &
-		0xFF00) >> 8);
-	frame_length_lines_lo = (uint8_t) (frame_length_lines &
-		0x00FF);
-	vx6953_i2c_write_b_sensor(REG_FRAME_LENGTH_LINES_HI,
-		frame_length_lines_hi);
-	vx6953_i2c_write_b_sensor(REG_FRAME_LENGTH_LINES_LO,
-		frame_length_lines_lo);
-
-	/* update analogue gain registers */
-	gain_hi = (uint8_t) ((gain & 0xFF00) >> 8);
-	gain_lo = (uint8_t) (gain & 0x00FF);
-	vx6953_i2c_write_b_sensor(REG_ANALOGUE_GAIN_CODE_GLOBAL_LO,
-		gain_lo);
-	vx6953_i2c_write_b_sensor(REG_DIGITAL_GAIN_GREEN_R_LO, gain_hi);
-	vx6953_i2c_write_b_sensor(REG_DIGITAL_GAIN_RED_LO, gain_hi);
-	vx6953_i2c_write_b_sensor(REG_DIGITAL_GAIN_BLUE_LO, gain_hi);
-	vx6953_i2c_write_b_sensor(REG_DIGITAL_GAIN_GREEN_B_LO, gain_hi);
-	CDBG("%s, gain_hi 0x%x, gain_lo 0x%x\n", __func__,
-		gain_hi, gain_lo);
-	/* update line count registers */
-	intg_time_hi = (uint8_t) (((uint16_t)line & 0xFF00) >> 8);
-	intg_time_lo = (uint8_t) ((uint16_t)line & 0x00FF);
-	vx6953_i2c_write_b_sensor(REG_COARSE_INTEGRATION_TIME_HI,
-		intg_time_hi);
-	vx6953_i2c_write_b_sensor(REG_COARSE_INTEGRATION_TIME_LO,
-		intg_time_lo);
-	vx6953_i2c_write_b_sensor(REG_GROUPED_PARAMETER_HOLD,
-		GROUPED_PARAMETER_HOLD_OFF);
-
-	return rc;
-}
-
-static int32_t vx6953_set_pict_exp_gain(uint16_t gain, uint32_t line)
-{
-	int32_t rc = 0;
-	rc = vx6953_write_exp_gain(gain, line);
-	return rc;
-} /* endof vx6953_set_pict_exp_gain*/
-
-static int32_t vx6953_move_focus(int direction,
-	int32_t num_steps)
-{
-	return 0;
-}
-
-
-static int32_t vx6953_set_default_focus(uint8_t af_step)
-{
-	return 0;
-}
-
-static int32_t vx6953_test(enum vx6953_test_mode_t mo)
-{
-	int32_t rc = 0;
-	if (mo == TEST_OFF)
-		return rc;
-	else {
-		/* REG_0x30D8[4] is TESBYPEN: 0: Normal Operation,
-		1: Bypass Signal Processing
-		REG_0x30D8[5] is EBDMASK: 0:
-		Output Embedded data, 1: No output embedded data */
-		if (vx6953_i2c_write_b_sensor(REG_TEST_PATTERN_MODE,
-			(uint8_t) mo) < 0) {
-			return rc;
-		}
-	}
-	return rc;
-}
-
-static int vx6953_enable_edof(enum edof_mode_t edof_mode)
-{
-	int rc = 0;
-	if (edof_mode == VX6953_EDOF_ESTIMATION) {
-		/* EDof Estimation mode for preview */
-		if (vx6953_i2c_write_b_sensor(REG_0x0b80, 0x02) < 0)
-			return rc;
-		CDBG("VX6953_EDOF_ESTIMATION");
-	} else if (edof_mode == VX6953_EDOF_APPLICATION) {
-		/* EDof Application mode for Capture */
-		if (vx6953_i2c_write_b_sensor(REG_0x0b80, 0x01) < 0)
-			return rc;
-		CDBG("VX6953_EDOF_APPLICATION");
-	} else {
-		/* EDOF disabled */
-		if (vx6953_i2c_write_b_sensor(REG_0x0b80, 0x00) < 0)
-			return rc;
-		CDBG("VX6953_EDOF_DISABLE");
-	}
-	return rc;
-}
-
-static int32_t vx6953_patch_for_cut2(void)
-{
-	int32_t rc = 0;
-	rc = vx6953_i2c_write_w_table(patch_tbl_cut2,
-		ARRAY_SIZE(patch_tbl_cut2));
-	if (rc < 0)
-		return rc;
-
-	return rc;
-}
-
-static int32_t vx6953_lsc_patch(void)
-{
-	int32_t rc = 0;
-	int i, j;
-	short int  v;
-	unsigned short version = 0;
-	unsigned short LSC_Raw[NUM_LSC_CAST_REGS];
-	unsigned short LSC_Fixed[NUM_LSC_CAST_REGS];
-
-	vx6953_i2c_read(0x10, &version, 1);
-	CDBG("Cut 3 Version %d\n", version);
-	if (version != 1)
-		return 0;
-
-	vx6953_i2c_write_b_sensor(0x3640, 0x00);
-	for (j = cast_H; j < cast_MAX; j++) {
-		for (i = 0; i < NUM_LSC_CAST_REGS; i++) {
-			rc = vx6953_i2c_read(LSC_CastRegs[cast_D]+(2*i),
-								&LSC_Raw[i], 2);
-			if (rc < 0)
-				return rc;
-			v = LSC_Raw[i];
-			v +=  LSC_CorrectionForCast[j][i];
-			LSC_Fixed[i] = (unsigned short) v;
-		}
-		for (i = 0; i < NUM_LSC_CAST_REGS; i++) {
-			rc = vx6953_i2c_write_w_sensor(LSC_CastRegs[j]+(2*i),
-								LSC_Fixed[i]);
-			if (rc < 0)
-				return rc;
-		}
-	}
-	CDBG("vx6953_lsc_patch done\n");
-	return rc;
-}
-
-static int32_t vx6953_sensor_setting(int update_type, int rt)
-{
-
-	int32_t rc = 0;
-	unsigned short frame_cnt;
-	struct msm_camera_csi_params vx6953_csi_params;
-	if (vx6953_ctrl->sensor_type != VX6953_STM5M0EDOF_CUT_2) {
-		switch (update_type) {
-		case REG_INIT:
-		if (rt == RES_PREVIEW || rt == RES_CAPTURE) {
-			struct vx6953_i2c_reg_conf init_tbl[] = {
-				{REG_0x0112,
-					vx6953_regs.reg_pat_init[0].
-					reg_0x0112},
-				{REG_0x0113,
-					vx6953_regs.reg_pat_init[0].
-					reg_0x0113},
-				{REG_VT_PIX_CLK_DIV,
-					vx6953_regs.reg_pat_init[0].
-					vt_pix_clk_div},
-				{0x303, 0x01},
-				{0x30b, 0x01},
-				{REG_PRE_PLL_CLK_DIV,
-					vx6953_regs.reg_pat_init[0].
-					pre_pll_clk_div},
-				{REG_PLL_MULTIPLIER,
-					vx6953_regs.reg_pat_init[0].
-					pll_multiplier},
-				{REG_OP_PIX_CLK_DIV,
-					vx6953_regs.reg_pat_init[0].
-					op_pix_clk_div},
-				{REG_0x3210, 0x01},
-				{REG_0x0111,
-					vx6953_regs.reg_pat_init[0].
-					reg_0x0111},
-				{REG_0x0b00,
-					vx6953_regs.reg_pat_init[0].
-					reg_0x0b00},
-				{REG_0x0136,
-					vx6953_regs.reg_pat_init[0].
-					reg_0x0136},
-				{REG_0x0137,
-					vx6953_regs.reg_pat_init[0].
-					reg_0x0137},
-				{REG_0x0b06,
-					vx6953_regs.reg_pat_init[0].
-					reg_0x0b06},
-				{REG_0x0b07,
-					vx6953_regs.reg_pat_init[0].
-					reg_0x0b07},
-				{REG_0x0b08,
-					vx6953_regs.reg_pat_init[0].
-					reg_0x0b08},
-				{REG_0x0b09,
-					vx6953_regs.reg_pat_init[0].
-					reg_0x0b09},
-				{REG_0x0b83,
-					vx6953_regs.reg_pat_init[0].
-					reg_0x0b83},
-				{REG_0x0b84,
-					vx6953_regs.reg_pat_init[0].
-					reg_0x0b84},
-				{REG_0x0b85,
-					vx6953_regs.reg_pat_init[0].
-					reg_0x0b85},
-				{REG_0x0b88,
-					vx6953_regs.reg_pat_init[0].
-					reg_0x0b88},
-				{REG_0x0b89,
-					vx6953_regs.reg_pat_init[0].
-					reg_0x0b89},
-				{REG_0x0b8a,
-					vx6953_regs.reg_pat_init[0].
-					reg_0x0b8a},
-				{0x3393, 0x06},
-				{0x3394, 0x07},
-				{0x338d, 0x08},
-				{0x338e, 0x08},
-				{0x338f, 0x00},
-			};
-			/* reset fps_divider */
-			vx6953_ctrl->fps = 30 * Q8;
-			/* stop streaming */
-
-			count = 0;
-			CDBG("Init vx6953_sensor_setting standby\n");
-			if (vx6953_i2c_write_b_sensor(REG_MODE_SELECT,
-				MODE_SELECT_STANDBY_MODE) < 0)
-				return rc;
-			msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-			vx6953_i2c_write_b_sensor(REG_GROUPED_PARAMETER_HOLD,
-			GROUPED_PARAMETER_HOLD);
-
-			rc = vx6953_i2c_write_w_table(cut3_cali_data,
-				ARRAY_SIZE(cut3_cali_data));
-
-			vx6953_lsc_patch();
-
-			vx6953_i2c_write_w_sensor(0x100A, 0x07A3);
-			vx6953_i2c_write_w_sensor(0x114A, 0x002A);
-			vx6953_i2c_write_w_sensor(0x1716, 0x0204);
-			vx6953_i2c_write_w_sensor(0x1718, 0x0880);
-
-			rc = vx6953_i2c_write_w_table(&init_tbl[0],
-				ARRAY_SIZE(init_tbl));
-			if (rc < 0)
-				return rc;
-
-			msleep(10);
-
-		}
-		return rc;
-		case UPDATE_PERIODIC:
-		if (rt == RES_PREVIEW || rt == RES_CAPTURE) {
-			struct vx6953_i2c_reg_conf preview_mode_tbl[] = {
-				{0x200, 0x02},
-				{0x201, 0x26},
-				{REG_COARSE_INTEGRATION_TIME_HI,
-					vx6953_regs.reg_pat[rt].
-					coarse_integration_time_hi},
-				{REG_COARSE_INTEGRATION_TIME_LO,
-					vx6953_regs.reg_pat[rt].
-					coarse_integration_time_lo},
-				{REG_ANALOGUE_GAIN_CODE_GLOBAL_LO,
-					vx6953_regs.reg_pat[rt].
-					analogue_gain_code_global},
-				{REG_FRAME_LENGTH_LINES_HI,
-					vx6953_regs.reg_pat[rt].
-					frame_length_lines_hi},
-				{REG_FRAME_LENGTH_LINES_LO,
-					vx6953_regs.reg_pat[rt].
-					frame_length_lines_lo},
-				{REG_LINE_LENGTH_PCK_HI,
-					vx6953_regs.reg_pat[rt].
-					line_length_pck_hi},
-				{REG_LINE_LENGTH_PCK_LO,
-					vx6953_regs.reg_pat[rt].
-					line_length_pck_lo},
-				{REG_0x0b80,
-					vx6953_regs.reg_pat[rt].
-					reg_0x0b80},
-				{REG_0x0900,
-					vx6953_regs.reg_pat[rt].
-					reg_0x0900},
-				{REG_0x0901,
-					vx6953_regs.reg_pat[rt].
-					reg_0x0901},
-				{REG_0x0902,
-					vx6953_regs.reg_pat[rt].
-					reg_0x0902},
-				{REG_0x0383,
-					vx6953_regs.reg_pat[rt].
-					reg_0x0383},
-				{REG_0x0387,
-					vx6953_regs.reg_pat[rt].
-					reg_0x0387},
-				{REG_0x034c,
-					vx6953_regs.reg_pat[rt].
-					reg_0x034c},
-				{REG_0x034d,
-					vx6953_regs.reg_pat[rt].
-					reg_0x034d},
-				{REG_0x034e,
-					vx6953_regs.reg_pat[rt].
-					reg_0x034e},
-				{REG_0x034f,
-					vx6953_regs.reg_pat[rt].
-					reg_0x034f},
-				{REG_0x3640, 0x00},
-			};
-
-			struct vx6953_i2c_reg_conf snapshot_mode_tbl[] = {
-				{0x0200, 0x02},
-				{0x0201, 0x54},
-				{REG_COARSE_INTEGRATION_TIME_HI,
-					vx6953_regs.reg_pat[rt].
-					coarse_integration_time_hi},
-				{REG_COARSE_INTEGRATION_TIME_LO,
-					vx6953_regs.reg_pat[rt].
-					coarse_integration_time_lo},
-				{REG_ANALOGUE_GAIN_CODE_GLOBAL_LO,
-					vx6953_regs.reg_pat[rt].
-					analogue_gain_code_global},
-				{REG_FRAME_LENGTH_LINES_HI,
-					vx6953_regs.reg_pat[rt].
-					frame_length_lines_hi},
-				{REG_FRAME_LENGTH_LINES_LO,
-					vx6953_regs.reg_pat[rt].
-					frame_length_lines_lo},
-				{REG_LINE_LENGTH_PCK_HI,
-					vx6953_regs.reg_pat[rt].
-					line_length_pck_hi},
-				{REG_LINE_LENGTH_PCK_LO,
-					vx6953_regs.reg_pat[rt].
-					line_length_pck_lo},
-				{REG_0x0b80,
-					vx6953_regs.reg_pat[rt].
-					reg_0x0b80},
-				{REG_0x0900,
-					vx6953_regs.reg_pat[rt].
-					reg_0x0900},
-				{REG_0x0901,
-					vx6953_regs.reg_pat[rt].
-					reg_0x0901},
-				{REG_0x0902,
-					vx6953_regs.reg_pat[rt].
-					reg_0x0902},
-				{REG_0x0383,
-					vx6953_regs.reg_pat[rt].
-					reg_0x0383},
-				{REG_0x0387,
-					vx6953_regs.reg_pat[rt].
-					reg_0x0387},
-				{REG_0x034c,
-					vx6953_regs.reg_pat[rt].
-					reg_0x034c},
-				{REG_0x034d,
-					vx6953_regs.reg_pat[rt].
-					reg_0x034d},
-				{REG_0x034e,
-					vx6953_regs.reg_pat[rt].
-					reg_0x034e},
-				{REG_0x034f,
-					vx6953_regs.reg_pat[rt].
-					reg_0x034f},
-				{0x3140, 0x01},
-				{REG_0x3640, 0x00},
-			};
-			/* stop streaming */
-
-			if (vx6953_i2c_write_b_sensor(REG_MODE_SELECT,
-				MODE_SELECT_STANDBY_MODE) < 0)
-				return rc;
-			msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-
-			if (count == 0) {
-				vx6953_csi_params.data_format = CSI_8BIT;
-				vx6953_csi_params.lane_cnt = 1;
-				vx6953_csi_params.lane_assign = 0xe4;
-				vx6953_csi_params.dpcm_scheme = 0;
-				vx6953_csi_params.settle_cnt = 7;
-				rc = msm_camio_csi_config(&vx6953_csi_params);
-				if (rc < 0)
-					CDBG("config csi controller failed\n");
-
-				msleep(20);
-				count = 1;
-			}
-
-			vx6953_i2c_write_b_sensor(REG_GROUPED_PARAMETER_HOLD,
-			GROUPED_PARAMETER_HOLD);
-
-			if (rt == RES_PREVIEW) {
-				rc = vx6953_i2c_write_w_table(
-					&preview_mode_tbl[0],
-					ARRAY_SIZE(preview_mode_tbl));
-				if (rc < 0)
-					return rc;
-			}
-			if (rt == RES_CAPTURE) {
-				rc = vx6953_i2c_write_w_table(
-					&snapshot_mode_tbl[0],
-					ARRAY_SIZE(snapshot_mode_tbl));
-				if (rc < 0)
-					return rc;
-			}
-
-			vx6953_i2c_write_b_sensor(REG_GROUPED_PARAMETER_HOLD,
-			GROUPED_PARAMETER_HOLD_OFF);
-
-			/* Start sensor streaming */
-			if (vx6953_i2c_write_b_sensor(REG_MODE_SELECT,
-				MODE_SELECT_STREAM) < 0)
-				return rc;
-			msleep(10);
-
-			if (vx6953_i2c_read(0x0005, &frame_cnt, 1) < 0)
-				return rc;
-
-			while (frame_cnt == 0xFF) {
-				if (vx6953_i2c_read(0x0005, &frame_cnt, 1) < 0)
-					return rc;
-				CDBG("frame_cnt=%d\n", frame_cnt);
-				msleep(2);
-			}
-		}
-		return rc;
-		default:
-			return rc;
-		}
-	} else {
-		switch (update_type) {
-		case REG_INIT:
-		if (rt == RES_PREVIEW || rt == RES_CAPTURE) {
-			struct vx6953_i2c_reg_conf init_tbl[] = {
-			{REG_0x0112,
-				vx6953_regs.reg_pat_init[0].reg_0x0112},
-			{REG_0x0113,
-				vx6953_regs.reg_pat_init[0].reg_0x0113},
-			{REG_VT_PIX_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				vt_pix_clk_div},
-			{REG_PRE_PLL_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				pre_pll_clk_div},
-			{REG_PLL_MULTIPLIER,
-				vx6953_regs.reg_pat_init[0].
-				pll_multiplier},
-			{REG_OP_PIX_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				op_pix_clk_div},
-			{REG_COARSE_INTEGRATION_TIME_HI,
-				vx6953_regs.reg_pat[rt].
-				coarse_integration_time_hi},
-			{REG_COARSE_INTEGRATION_TIME_LO,
-				vx6953_regs.reg_pat[rt].
-				coarse_integration_time_lo},
-			{REG_ANALOGUE_GAIN_CODE_GLOBAL_LO,
-				vx6953_regs.reg_pat[rt].
-				analogue_gain_code_global},
-			{REG_0x3030,
-				vx6953_regs.reg_pat_init[0].reg_0x3030},
-			/* 953 specific registers */
-			{REG_0x0111,
-				vx6953_regs.reg_pat_init[0].reg_0x0111},
-			{REG_0x0b00,
-				vx6953_regs.reg_pat_init[0].reg_0x0b00},
-			{REG_0x3001,
-				vx6953_regs.reg_pat_init[0].reg_0x3001},
-			{REG_0x3004,
-				vx6953_regs.reg_pat_init[0].reg_0x3004},
-			{REG_0x3007,
-				vx6953_regs.reg_pat_init[0].reg_0x3007},
-			{REG_0x3016,
-				vx6953_regs.reg_pat_init[0].reg_0x3016},
-			{REG_0x301d,
-				vx6953_regs.reg_pat_init[0].reg_0x301d},
-			{REG_0x317e,
-				vx6953_regs.reg_pat_init[0].reg_0x317e},
-			{REG_0x317f,
-				vx6953_regs.reg_pat_init[0].reg_0x317f},
-			{REG_0x3400,
-				vx6953_regs.reg_pat_init[0].reg_0x3400},
-			/* DEFCOR settings */
-			/*Single Defect Correction Weight DISABLE*/
-			{0x0b06,
-				vx6953_regs.reg_pat_init[0].reg_0x0b06},
-			/*Single_defect_correct_weight = auto*/
-			{0x0b07,
-				vx6953_regs.reg_pat_init[0].reg_0x0b07},
-			/*Dynamic couplet correction ENABLED*/
-			{0x0b08,
-				vx6953_regs.reg_pat_init[0].reg_0x0b08},
-			/*Dynamic couplet correction weight*/
-			{0x0b09,
-				vx6953_regs.reg_pat_init[0].reg_0x0b09},
-			/* Clock Setup */
-			/* Tell sensor ext clk is 24MHz*/
-			{0x0136,
-				vx6953_regs.reg_pat_init[0].reg_0x0136},
-			{0x0137,
-				vx6953_regs.reg_pat_init[0].reg_0x0137},
-			/* The white balance gains must be written
-			to the sensor every frame. */
-			/* Edof */
-			{REG_0x0b83,
-				vx6953_regs.reg_pat_init[0].reg_0x0b83},
-			{REG_0x0b84,
-				vx6953_regs.reg_pat_init[0].reg_0x0b84},
-			{0x0b85,
-				vx6953_regs.reg_pat_init[0].reg_0x0b85},
-			{0x0b88,
-				vx6953_regs.reg_pat_init[0].reg_0x0b88},
-			{0x0b89,
-				vx6953_regs.reg_pat_init[0].reg_0x0b89},
-			{REG_0x0b8a,
-				vx6953_regs.reg_pat_init[0].reg_0x0b8a},
-			/* Mode specific regieters */
-			{REG_FRAME_LENGTH_LINES_HI,
-				vx6953_regs.reg_pat[rt].
-				frame_length_lines_hi},
-			{REG_FRAME_LENGTH_LINES_LO,
-				vx6953_regs.reg_pat[rt].
-				frame_length_lines_lo},
-			{REG_LINE_LENGTH_PCK_HI,
-				vx6953_regs.reg_pat[rt].
-				line_length_pck_hi},
-			{REG_LINE_LENGTH_PCK_LO,
-				vx6953_regs.reg_pat[rt].
-				line_length_pck_lo},
-			{REG_0x3005,
-				vx6953_regs.reg_pat[rt].reg_0x3005},
-			{0x3010,
-				vx6953_regs.reg_pat[rt].reg_0x3010},
-			{REG_0x3011,
-				vx6953_regs.reg_pat[rt].reg_0x3011},
-			{REG_0x301a,
-				vx6953_regs.reg_pat[rt].reg_0x301a},
-			{REG_0x3035,
-				vx6953_regs.reg_pat[rt].reg_0x3035},
-			{REG_0x3036,
-				vx6953_regs.reg_pat[rt].reg_0x3036},
-			{REG_0x3041,
-				vx6953_regs.reg_pat[rt].reg_0x3041},
-			{0x3042,
-				vx6953_regs.reg_pat[rt].reg_0x3042},
-			{REG_0x3045,
-				vx6953_regs.reg_pat[rt].reg_0x3045},
-			/*EDOF: Estimation settings for Preview mode
-			Application settings for capture mode
-			(standard settings - Not tuned) */
-			{REG_0x0b80,
-				vx6953_regs.reg_pat[rt].reg_0x0b80},
-			{REG_0x0900,
-				vx6953_regs.reg_pat[rt].reg_0x0900},
-			{REG_0x0901,
-				vx6953_regs.reg_pat[rt].reg_0x0901},
-			{REG_0x0902,
-				vx6953_regs.reg_pat[rt].reg_0x0902},
-			{REG_0x0383,
-				vx6953_regs.reg_pat[rt].reg_0x0383},
-			{REG_0x0387,
-				vx6953_regs.reg_pat[rt].reg_0x0387},
-			/* Change output size / frame rate */
-			{REG_0x034c,
-				vx6953_regs.reg_pat[rt].reg_0x034c},
-			{REG_0x034d,
-				vx6953_regs.reg_pat[rt].reg_0x034d},
-			{REG_0x034e,
-				vx6953_regs.reg_pat[rt].reg_0x034e},
-			{REG_0x034f,
-				vx6953_regs.reg_pat[rt].reg_0x034f},
-			{REG_0x1716,
-				vx6953_regs.reg_pat[rt].reg_0x1716},
-			{REG_0x1717,
-				vx6953_regs.reg_pat[rt].reg_0x1717},
-			{REG_0x1718,
-				vx6953_regs.reg_pat[rt].reg_0x1718},
-			{REG_0x1719,
-				vx6953_regs.reg_pat[rt].reg_0x1719},
-			};
-						/* reset fps_divider */
-			vx6953_ctrl->fps = 30 * Q8;
-			/* stop streaming */
-
-			/* Reset everything first */
-			if (vx6953_i2c_write_b_sensor(0x103, 0x01) < 0) {
-				CDBG("S/W reset failed\n");
-				return rc;
-			} else
-				CDBG("S/W reset successful\n");
-
-			msleep(10);
-
-			CDBG("Init vx6953_sensor_setting standby\n");
-			if (vx6953_i2c_write_b_sensor(REG_MODE_SELECT,
-				MODE_SELECT_STANDBY_MODE) < 0)
-				return rc;
-				/*vx6953_stm5m0edof_delay_msecs_stdby*/
-			msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-			vx6953_patch_for_cut2();
-			rc = vx6953_i2c_write_w_table(&init_tbl[0],
-				ARRAY_SIZE(init_tbl));
-			if (rc < 0)
-				return rc;
-				msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-		}
-	return rc;
-	case UPDATE_PERIODIC:
-		if (rt == RES_PREVIEW || rt == RES_CAPTURE) {
-			struct vx6953_i2c_reg_conf init_mode_tbl[] =  {
-			{REG_0x0112,
-				vx6953_regs.reg_pat_init[0].reg_0x0112},
-			{REG_0x0113,
-				vx6953_regs.reg_pat_init[0].reg_0x0113},
-			{REG_VT_PIX_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				vt_pix_clk_div},
-			{REG_PRE_PLL_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				pre_pll_clk_div},
-			{REG_PLL_MULTIPLIER,
-				vx6953_regs.reg_pat_init[0].
-				pll_multiplier},
-			{REG_OP_PIX_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				op_pix_clk_div},
-			{REG_COARSE_INTEGRATION_TIME_HI,
-				vx6953_regs.reg_pat[rt].
-				coarse_integration_time_hi},
-			{REG_COARSE_INTEGRATION_TIME_LO,
-				vx6953_regs.reg_pat[rt].
-				coarse_integration_time_lo},
-			{REG_ANALOGUE_GAIN_CODE_GLOBAL_LO,
-				vx6953_regs.reg_pat[rt].
-				analogue_gain_code_global},
-			{REG_0x3030,
-				vx6953_regs.reg_pat_init[0].reg_0x3030},
-			/* 953 specific registers */
-			{REG_0x0111,
-				vx6953_regs.reg_pat_init[0].reg_0x0111},
-			{REG_0x0b00,
-				vx6953_regs.reg_pat_init[0].reg_0x0b00},
-			{REG_0x3001,
-				vx6953_regs.reg_pat_init[0].reg_0x3001},
-			{REG_0x3004,
-				vx6953_regs.reg_pat_init[0].reg_0x3004},
-			{REG_0x3007,
-				vx6953_regs.reg_pat_init[0].reg_0x3007},
-			{REG_0x3016,
-				vx6953_regs.reg_pat_init[0].reg_0x3016},
-			{REG_0x301d,
-				vx6953_regs.reg_pat_init[0].reg_0x301d},
-			{REG_0x317e,
-				vx6953_regs.reg_pat_init[0].reg_0x317e},
-			{REG_0x317f,
-				vx6953_regs.reg_pat_init[0].reg_0x317f},
-			{REG_0x3400,
-				vx6953_regs.reg_pat_init[0].reg_0x3400},
-			{0x0b06,
-				vx6953_regs.reg_pat_init[0].reg_0x0b06},
-			/*Single_defect_correct_weight = auto*/
-			{0x0b07,
-				vx6953_regs.reg_pat_init[0].reg_0x0b07},
-			/*Dynamic couplet correction ENABLED*/
-			{0x0b08,
-				vx6953_regs.reg_pat_init[0].reg_0x0b08},
-			/*Dynamic couplet correction weight*/
-			{0x0b09,
-				vx6953_regs.reg_pat_init[0].reg_0x0b09},
-			/* Clock Setup */
-			/* Tell sensor ext clk is 24MHz*/
-			{0x0136,
-				vx6953_regs.reg_pat_init[0].reg_0x0136},
-			{0x0137,
-				vx6953_regs.reg_pat_init[0].reg_0x0137},
-			/* The white balance gains must be written
-			to the sensor every frame. */
-			/* Edof */
-			{REG_0x0b83,
-				vx6953_regs.reg_pat_init[0].reg_0x0b83},
-			{REG_0x0b84,
-				vx6953_regs.reg_pat_init[0].reg_0x0b84},
-			{0x0b85,
-				vx6953_regs.reg_pat_init[0].reg_0x0b85},
-			{0x0b88,
-				vx6953_regs.reg_pat_init[0].reg_0x0b88},
-			{0x0b89,
-				vx6953_regs.reg_pat_init[0].reg_0x0b89},
-			{REG_0x0b8a,
-				vx6953_regs.reg_pat_init[0].reg_0x0b8a},
-			/* Mode specific regieters */
-			{REG_FRAME_LENGTH_LINES_HI,
-				vx6953_regs.reg_pat[rt].
-				frame_length_lines_hi},
-			{REG_FRAME_LENGTH_LINES_LO,
-				vx6953_regs.reg_pat[rt].
-				frame_length_lines_lo},
-			{REG_LINE_LENGTH_PCK_HI,
-				vx6953_regs.reg_pat[rt].
-				line_length_pck_hi},
-			{REG_LINE_LENGTH_PCK_LO,
-				vx6953_regs.reg_pat[rt].
-				line_length_pck_lo},
-			{REG_0x3005,
-				vx6953_regs.reg_pat[rt].reg_0x3005},
-			{0x3010,
-				vx6953_regs.reg_pat[rt].reg_0x3010},
-			{REG_0x3011,
-				vx6953_regs.reg_pat[rt].reg_0x3011},
-			{REG_0x301a,
-				vx6953_regs.reg_pat[rt].reg_0x301a},
-			{REG_0x3035,
-				vx6953_regs.reg_pat[rt].reg_0x3035},
-			{REG_0x3036,
-				vx6953_regs.reg_pat[rt].reg_0x3036},
-			{REG_0x3041,
-				vx6953_regs.reg_pat[rt].reg_0x3041},
-			{0x3042,
-				vx6953_regs.reg_pat[rt].reg_0x3042},
-			{REG_0x3045,
-				vx6953_regs.reg_pat[rt].reg_0x3045},
-			/*EDOF: Estimation settings for Preview mode
-			Application settings for capture mode
-			(standard settings - Not tuned) */
-			{REG_0x0b80,
-				vx6953_regs.reg_pat[rt].reg_0x0b80},
-			{REG_0x0900,
-				vx6953_regs.reg_pat[rt].reg_0x0900},
-			{REG_0x0901,
-				vx6953_regs.reg_pat[rt].reg_0x0901},
-			{REG_0x0902,
-				vx6953_regs.reg_pat[rt].reg_0x0902},
-			{REG_0x0383,
-				vx6953_regs.reg_pat[rt].reg_0x0383},
-			{REG_0x0387,
-				vx6953_regs.reg_pat[rt].reg_0x0387},
-			/* Change output size / frame rate */
-			{REG_0x034c,
-				vx6953_regs.reg_pat[rt].reg_0x034c},
-			{REG_0x034d,
-				vx6953_regs.reg_pat[rt].reg_0x034d},
-			{REG_0x034e,
-				vx6953_regs.reg_pat[rt].reg_0x034e},
-			{REG_0x034f,
-				vx6953_regs.reg_pat[rt].reg_0x034f},
-			{REG_0x1716,
-				vx6953_regs.reg_pat[rt].reg_0x1716},
-			{REG_0x1717,
-				vx6953_regs.reg_pat[rt].reg_0x1717},
-			{REG_0x1718,
-				vx6953_regs.reg_pat[rt].reg_0x1718},
-			{REG_0x1719,
-				vx6953_regs.reg_pat[rt].reg_0x1719},
-			};
-			struct vx6953_i2c_reg_conf mode_tbl[] = {
-			{REG_0x0112,
-				vx6953_regs.reg_pat_init[0].reg_0x0112},
-			{REG_0x0113,
-				vx6953_regs.reg_pat_init[0].reg_0x0113},
-			{REG_VT_PIX_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				vt_pix_clk_div},
-			{REG_PRE_PLL_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				pre_pll_clk_div},
-			{REG_PLL_MULTIPLIER,
-				vx6953_regs.reg_pat_init[0].
-				pll_multiplier},
-			{REG_OP_PIX_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				op_pix_clk_div},
-		/* Mode specific regieters */
-			{REG_FRAME_LENGTH_LINES_HI,
-				vx6953_regs.reg_pat[rt].frame_length_lines_hi},
-			{REG_FRAME_LENGTH_LINES_LO,
-				vx6953_regs.reg_pat[rt].frame_length_lines_lo},
-			{REG_LINE_LENGTH_PCK_HI,
-				vx6953_regs.reg_pat[rt].line_length_pck_hi},
-			{REG_LINE_LENGTH_PCK_LO,
-				vx6953_regs.reg_pat[rt].line_length_pck_lo},
-			{REG_0x3005, vx6953_regs.reg_pat[rt].reg_0x3005},
-			{0x3010, vx6953_regs.reg_pat[rt].reg_0x3010},
-			{REG_0x3011, vx6953_regs.reg_pat[rt].reg_0x3011},
-			{REG_0x301a, vx6953_regs.reg_pat[rt].reg_0x301a},
-			{REG_0x3035, vx6953_regs.reg_pat[rt].reg_0x3035},
-			{REG_0x3036, vx6953_regs.reg_pat[rt].reg_0x3036},
-			{REG_0x3041, vx6953_regs.reg_pat[rt].reg_0x3041},
-			{0x3042, vx6953_regs.reg_pat[rt].reg_0x3042},
-			{REG_0x3045, vx6953_regs.reg_pat[rt].reg_0x3045},
-			/*EDOF: Estimation settings for Preview mode
-			Application settings for capture
-			mode(standard settings - Not tuned) */
-			{REG_0x0b80, vx6953_regs.reg_pat[rt].reg_0x0b80},
-			{REG_0x0900, vx6953_regs.reg_pat[rt].reg_0x0900},
-			{REG_0x0901, vx6953_regs.reg_pat[rt].reg_0x0901},
-			{REG_0x0902, vx6953_regs.reg_pat[rt].reg_0x0902},
-			{REG_0x0383, vx6953_regs.reg_pat[rt].reg_0x0383},
-			{REG_0x0387, vx6953_regs.reg_pat[rt].reg_0x0387},
-			/* Change output size / frame rate */
-			{REG_0x034c, vx6953_regs.reg_pat[rt].reg_0x034c},
-			{REG_0x034d, vx6953_regs.reg_pat[rt].reg_0x034d},
-			{REG_0x034e, vx6953_regs.reg_pat[rt].reg_0x034e},
-			{REG_0x034f, vx6953_regs.reg_pat[rt].reg_0x034f},
-			/*{0x200, vx6953_regs.reg_pat[rt].reg_0x0200},
-			{0x201, vx6953_regs.reg_pat[rt].reg_0x0201},*/
-			{REG_0x1716, vx6953_regs.reg_pat[rt].reg_0x1716},
-			{REG_0x1717, vx6953_regs.reg_pat[rt].reg_0x1717},
-			{REG_0x1718, vx6953_regs.reg_pat[rt].reg_0x1718},
-			{REG_0x1719, vx6953_regs.reg_pat[rt].reg_0x1719},
-			};
-			/* stop streaming */
-			msleep(5);
-
-			/* Reset everything first */
-			if (vx6953_i2c_write_b_sensor(0x103, 0x01) < 0) {
-				CDBG("S/W reset failed\n");
-				return rc;
-			} else
-				CDBG("S/W reset successful\n");
-
-			msleep(10);
-
-			if (vx6953_i2c_write_b_sensor(REG_MODE_SELECT,
-				MODE_SELECT_STANDBY_MODE) < 0)
-				return rc;
-			/*vx6953_stm5m0edof_delay_msecs_stdby*/
-			msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-
-
-			vx6953_csi_params.data_format = CSI_8BIT;
-			vx6953_csi_params.lane_cnt = 1;
-			vx6953_csi_params.lane_assign = 0xe4;
-			vx6953_csi_params.dpcm_scheme = 0;
-			vx6953_csi_params.settle_cnt = 7;
-			rc = msm_camio_csi_config(&vx6953_csi_params);
-			if (rc < 0)
-				return rc;
-
-			msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-
-			vx6953_patch_for_cut2();
-			rc = vx6953_i2c_write_w_table(&init_mode_tbl[0],
-				ARRAY_SIZE(init_mode_tbl));
-			if (rc < 0)
-				return rc;
-
-			msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-
-			rc = vx6953_i2c_write_w_table(&mode_tbl[0],
-				ARRAY_SIZE(mode_tbl));
-			if (rc < 0)
-				return rc;
-
-			msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-
-			/* Start sensor streaming */
-			if (vx6953_i2c_write_b_sensor(REG_MODE_SELECT,
-				MODE_SELECT_STREAM) < 0)
-				return rc;
-			msleep(vx6953_stm5m0edof_delay_msecs_stream);
-
-			if (vx6953_i2c_read(0x0005, &frame_cnt, 1) < 0)
-				return rc;
-
-			while (frame_cnt == 0xFF) {
-				if (vx6953_i2c_read(0x0005, &frame_cnt, 1) < 0)
-					return rc;
-				CDBG("frame_cnt=%d", frame_cnt);
-				msleep(10);
-			}
-		}
-		return rc;
-	default:
-		return rc;
-	}
-	}
-	return rc;
-}
-
-
-static int32_t vx6953_video_config(int mode)
-{
-
-	int32_t	rc = 0;
-	int	rt;
-	/* change sensor resolution	if needed */
-	if (vx6953_ctrl->curr_res != vx6953_ctrl->prev_res) {
-		if (vx6953_ctrl->prev_res == QTR_SIZE) {
-			rt = RES_PREVIEW;
-			vx6953_stm5m0edof_delay_msecs_stdby	=
-				((((2 * 1000 * vx6953_ctrl->fps_divider) /
-				   vx6953_ctrl->fps) * Q8) / Q10) + 1;
-		} else {
-			rt = RES_CAPTURE;
-			vx6953_stm5m0edof_delay_msecs_stdby	=
-				((((1000 * vx6953_ctrl->fps_divider) /
-				   vx6953_ctrl->fps) * Q8) / Q10) + 1;
-		}
-		if (vx6953_sensor_setting(UPDATE_PERIODIC, rt) < 0)
-			return rc;
-	}
-	if (vx6953_ctrl->set_test) {
-		if (vx6953_test(vx6953_ctrl->set_test) < 0)
-			return	rc;
-	}
-	vx6953_ctrl->edof_mode = VX6953_EDOF_ESTIMATION;
-	rc = vx6953_enable_edof(vx6953_ctrl->edof_mode);
-	if (rc < 0)
-		return rc;
-	vx6953_ctrl->curr_res = vx6953_ctrl->prev_res;
-	vx6953_ctrl->sensormode = mode;
-	return rc;
-}
-
-static int32_t vx6953_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-	int rt;
-	/*change sensor resolution if needed */
-	if (vx6953_ctrl->curr_res != vx6953_ctrl->pict_res) {
-		if (vx6953_ctrl->pict_res == QTR_SIZE) {
-			rt = RES_PREVIEW;
-			vx6953_stm5m0edof_delay_msecs_stdby =
-				((((2 * 1000 * vx6953_ctrl->fps_divider) /
-				vx6953_ctrl->fps) * Q8) / Q10) + 1;
-		} else {
-			rt = RES_CAPTURE;
-			vx6953_stm5m0edof_delay_msecs_stdby =
-				((((1000 * vx6953_ctrl->fps_divider) /
-				vx6953_ctrl->fps) * Q8) / Q10) + 1;
-		}
-	if (vx6953_sensor_setting(UPDATE_PERIODIC, rt) < 0)
-		return rc;
-	}
-
-	vx6953_ctrl->edof_mode = VX6953_EDOF_APPLICATION;
-	if (vx6953_enable_edof(vx6953_ctrl->edof_mode) < 0)
-		return rc;
-	vx6953_ctrl->curr_res = vx6953_ctrl->pict_res;
-	vx6953_ctrl->sensormode = mode;
-	return rc;
-} /*end of vx6953_snapshot_config*/
-
-static int32_t vx6953_raw_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-	int rt;
-	/* change sensor resolution if needed */
-	if (vx6953_ctrl->curr_res != vx6953_ctrl->pict_res) {
-		if (vx6953_ctrl->pict_res == QTR_SIZE) {
-			rt = RES_PREVIEW;
-			vx6953_stm5m0edof_delay_msecs_stdby =
-				((((2 * 1000 * vx6953_ctrl->fps_divider)/
-				vx6953_ctrl->fps) * Q8) / Q10) + 1;
-		} else {
-			rt = RES_CAPTURE;
-			vx6953_stm5m0edof_delay_msecs_stdby =
-				((((1000 * vx6953_ctrl->fps_divider)/
-				vx6953_ctrl->fps) * Q8) / Q10) + 1;
-		}
-		if (vx6953_sensor_setting(UPDATE_PERIODIC, rt) < 0)
-			return rc;
-	}
-	vx6953_ctrl->edof_mode = VX6953_EDOF_APPLICATION;
-	if (vx6953_enable_edof(vx6953_ctrl->edof_mode) < 0)
-		return rc;
-	vx6953_ctrl->curr_res = vx6953_ctrl->pict_res;
-	vx6953_ctrl->sensormode = mode;
-	return rc;
-} /*end of vx6953_raw_snapshot_config*/
-static int32_t vx6953_set_sensor_mode(int mode,
-	int res)
-{
-	int32_t rc = 0;
-	switch (mode) {
-	case SENSOR_PREVIEW_MODE:
-		rc = vx6953_video_config(mode);
-		break;
-	case SENSOR_SNAPSHOT_MODE:
-		rc = vx6953_snapshot_config(mode);
-		break;
-	case SENSOR_RAW_SNAPSHOT_MODE:
-		rc = vx6953_raw_snapshot_config(mode);
-		break;
-	default:
-		rc = -EINVAL;
-		break;
-	}
-	return rc;
-}
-static int32_t vx6953_power_down(void)
-{
-	return 0;
-}
-
-
-static int vx6953_probe_init_done(const struct msm_camera_sensor_info *data)
-{
-	gpio_set_value_cansleep(data->sensor_reset, 0);
-	gpio_free(data->sensor_reset);
-	return 0;
-}
-static int vx6953_probe_init_sensor(const struct msm_camera_sensor_info *data)
-{
-	int32_t rc = 0;
-	unsigned short chipidl, chipidh;
-	CDBG("%s: %d\n", __func__, __LINE__);
-	rc = gpio_request(data->sensor_reset, "vx6953");
-	CDBG(" vx6953_probe_init_sensor \n");
-	if (!rc) {
-		CDBG("sensor_reset = %d\n", rc);
-		CDBG(" vx6953_probe_init_sensor 1\n");
-		gpio_direction_output(data->sensor_reset, 0);
-		msleep(10);
-		CDBG(" vx6953_probe_init_sensor 1\n");
-		gpio_set_value_cansleep(data->sensor_reset, 1);
-	} else {
-		CDBG(" vx6953_probe_init_sensor 2\n");
-		goto init_probe_done;
-	}
-	msleep(20);
-	CDBG(" vx6953_probe_init_sensor is called\n");
-	/* 3. Read sensor Model ID: */
-	rc = vx6953_i2c_read(0x0000, &chipidh, 1);
-	if (rc < 0) {
-		CDBG(" vx6953_probe_init_sensor 3\n");
-		goto init_probe_fail;
-	}
-	rc = vx6953_i2c_read(0x0001, &chipidl, 1);
-	if (rc < 0) {
-		CDBG(" vx6953_probe_init_sensor4\n");
-		goto init_probe_fail;
-	}
-	CDBG("vx6953 model_id = 0x%x  0x%x\n", chipidh, chipidl);
-	/* 4. Compare sensor ID to VX6953 ID: */
-	if (chipidh != 0x03 || chipidl != 0xB9) {
-		rc = -ENODEV;
-		CDBG("vx6953_probe_init_sensor fail chip id doesnot match\n");
-		goto init_probe_fail;
-	}
-	goto init_probe_done;
-init_probe_fail:
-	CDBG(" vx6953_probe_init_sensor fails\n");
-	vx6953_probe_init_done(data);
-init_probe_done:
-	CDBG(" vx6953_probe_init_sensor finishes\n");
-	return rc;
-	}
-/* camsensor_iu060f_vx6953_reset */
-int vx6953_sensor_open_init(const struct msm_camera_sensor_info *data)
-{
-	unsigned short revision_number;
-	int32_t rc = 0;
-
-	CDBG("%s: %d\n", __func__, __LINE__);
-	CDBG("Calling vx6953_sensor_open_init\n");
-	vx6953_ctrl = kzalloc(sizeof(struct vx6953_ctrl_t), GFP_KERNEL);
-	if (!vx6953_ctrl) {
-		CDBG("vx6953_init failed!\n");
-		rc = -ENOMEM;
-		goto init_done;
-	}
-	vx6953_ctrl->fps_divider = 1 * 0x00000400;
-	vx6953_ctrl->pict_fps_divider = 1 * 0x00000400;
-	vx6953_ctrl->set_test = TEST_OFF;
-	vx6953_ctrl->prev_res = QTR_SIZE;
-	vx6953_ctrl->pict_res = FULL_SIZE;
-	vx6953_ctrl->curr_res = INVALID_SIZE;
-	vx6953_ctrl->sensor_type = VX6953_STM5M0EDOF_CUT_2;
-	vx6953_ctrl->edof_mode = VX6953_EDOF_ESTIMATION;
-	if (data)
-		vx6953_ctrl->sensordata = data;
-	if (rc < 0) {
-		CDBG("Calling vx6953_sensor_open_init fail1\n");
-		return rc;
-	}
-	CDBG("%s: %d\n", __func__, __LINE__);
-	/* enable mclk first */
-	msm_camio_clk_rate_set(VX6953_STM5M0EDOF_DEFAULT_MASTER_CLK_RATE);
-	CDBG("%s: %d\n", __func__, __LINE__);
-	rc = vx6953_probe_init_sensor(data);
-	if (rc < 0) {
-		CDBG("Calling vx6953_sensor_open_init fail3\n");
-		goto init_fail;
-	}
-	if (vx6953_i2c_read(0x0002, &revision_number, 1) < 0)
-		return rc;
-		CDBG("sensor revision number major = 0x%x\n", revision_number);
-	if (vx6953_i2c_read(0x0018, &revision_number, 1) < 0)
-		return rc;
-		CDBG("sensor revision number = 0x%x\n", revision_number);
-	if (revision_number == VX6953_REVISION_NUMBER_CUT3) {
-		vx6953_ctrl->sensor_type = VX6953_STM5M0EDOF_CUT_3;
-		CDBG("VX6953 EDof Cut 3.0 sensor\n ");
-	} else if (revision_number == VX6953_REVISION_NUMBER_CUT2) {
-		vx6953_ctrl->sensor_type = VX6953_STM5M0EDOF_CUT_2;
-		CDBG("VX6953 EDof Cut 2.0 sensor\n ");
-	} else {/* Cut1.0 reads 0x00 for register 0x0018*/
-		vx6953_ctrl->sensor_type = VX6953_STM5M0EDOF_CUT_1;
-		CDBG("VX6953 EDof Cut 1.0 sensor\n ");
-	}
-	if (vx6953_ctrl->prev_res == QTR_SIZE) {
-		if (vx6953_sensor_setting(REG_INIT, RES_PREVIEW) < 0)
-			return rc;
-	} else {
-		if (vx6953_sensor_setting(REG_INIT, RES_CAPTURE) < 0)
-			return rc;
-	}
-	vx6953_ctrl->fps = 30*Q8;
-	if (rc < 0)
-		goto init_fail;
-	else
-		goto init_done;
-init_fail:
-	CDBG("init_fail\n");
-	vx6953_probe_init_done(data);
-	kfree(vx6953_ctrl);
-init_done:
-	CDBG("init_done\n");
-	return rc;
-} /*endof vx6953_sensor_open_init*/
-
-static int vx6953_init_client(struct i2c_client *client)
-{
-	/* Initialize the MSM_CAMI2C Chip */
-	init_waitqueue_head(&vx6953_wait_queue);
-	return 0;
-}
-
-static const struct i2c_device_id vx6953_i2c_id[] = {
-	{"vx6953", 0},
-	{ }
-};
-
-static int vx6953_i2c_probe(struct i2c_client *client,
-	const struct i2c_device_id *id)
-{
-	int rc = 0;
-	CDBG("vx6953_probe called!\n");
-
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		CDBG("i2c_check_functionality failed\n");
-		goto probe_failure;
-	}
-
-	vx6953_sensorw = kzalloc(sizeof(struct vx6953_work_t), GFP_KERNEL);
-	if (!vx6953_sensorw) {
-		CDBG("kzalloc failed.\n");
-		rc = -ENOMEM;
-		goto probe_failure;
-	}
-
-	i2c_set_clientdata(client, vx6953_sensorw);
-	vx6953_init_client(client);
-	vx6953_client = client;
-
-	msleep(50);
-
-	CDBG("vx6953_probe successed! rc = %d\n", rc);
-	return 0;
-
-probe_failure:
-	CDBG("vx6953_probe failed! rc = %d\n", rc);
-	return rc;
-}
-
-static int vx6953_send_wb_info(struct wb_info_cfg *wb)
-{
-	unsigned short read_data;
-	uint8_t temp[8];
-	int rc = 0;
-	int i = 0;
-
-	/* red_gain */
-	temp[2] = wb->red_gain >> 8;
-	temp[3] = wb->red_gain & 0xFF;
-
-	/* green_gain */
-	temp[0] = wb->green_gain >> 8;
-	temp[1] = wb->green_gain & 0xFF;
-	temp[6] = temp[0];
-	temp[7] = temp[1];
-
-	/* blue_gain */
-	temp[4] = wb->blue_gain >> 8;
-	temp[5] = wb->blue_gain & 0xFF;
-	rc = vx6953_i2c_write_seq_sensor(0x0B8E, &temp[0], 8);
-
-	for (i = 0; i < 6; i++) {
-		rc = vx6953_i2c_read(0x0B8E + i, &read_data, 1);
-		CDBG("%s addr 0x%x val %d \n", __func__, 0x0B8E + i, read_data);
-	}
-	rc = vx6953_i2c_read(0x0B82, &read_data, 1);
-	CDBG("%s addr 0x%x val %d \n", __func__, 0x0B82, read_data);
-	if (rc < 0)
-		return rc;
-	return rc;
-} /*end of vx6953_snapshot_config*/
-
-static int __exit vx6953_remove(struct i2c_client *client)
-{
-	struct vx6953_work_t_t *sensorw = i2c_get_clientdata(client);
-	free_irq(client->irq, sensorw);
-	vx6953_client = NULL;
-	kfree(sensorw);
-	return 0;
-}
-
-static struct i2c_driver vx6953_i2c_driver = {
-	.id_table = vx6953_i2c_id,
-	.probe  = vx6953_i2c_probe,
-	.remove = __exit_p(vx6953_i2c_remove),
-	.driver = {
-		.name = "vx6953",
-	},
-};
-
-int vx6953_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(&vx6953_mut);
-	CDBG("vx6953_sensor_config: cfgtype = %d\n",
-	cdata.cfgtype);
-		switch (cdata.cfgtype) {
-		case CFG_GET_PICT_FPS:
-			vx6953_get_pict_fps(
-				cdata.cfg.gfps.prevfps,
-				&(cdata.cfg.gfps.pictfps));
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_GET_PREV_L_PF:
-			cdata.cfg.prevl_pf =
-			vx6953_get_prev_lines_pf();
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_GET_PREV_P_PL:
-			cdata.cfg.prevp_pl =
-				vx6953_get_prev_pixels_pl();
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_GET_PICT_L_PF:
-			cdata.cfg.pictl_pf =
-				vx6953_get_pict_lines_pf();
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_GET_PICT_P_PL:
-			cdata.cfg.pictp_pl =
-				vx6953_get_pict_pixels_pl();
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_GET_PICT_MAX_EXP_LC:
-			cdata.cfg.pict_max_exp_lc =
-				vx6953_get_pict_max_exp_lc();
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_SET_FPS:
-		case CFG_SET_PICT_FPS:
-			rc = vx6953_set_fps(&(cdata.cfg.fps));
-			break;
-
-		case CFG_SET_EXP_GAIN:
-			rc =
-				vx6953_write_exp_gain(
-					cdata.cfg.exp_gain.gain,
-					cdata.cfg.exp_gain.line);
-			break;
-
-		case CFG_SET_PICT_EXP_GAIN:
-			rc =
-				vx6953_set_pict_exp_gain(
-				cdata.cfg.exp_gain.gain,
-				cdata.cfg.exp_gain.line);
-			break;
-
-		case CFG_SET_MODE:
-			rc = vx6953_set_sensor_mode(cdata.mode,
-					cdata.rs);
-			break;
-
-		case CFG_PWR_DOWN:
-			rc = vx6953_power_down();
-			break;
-
-		case CFG_MOVE_FOCUS:
-			rc =
-				vx6953_move_focus(
-				cdata.cfg.focus.dir,
-				cdata.cfg.focus.steps);
-			break;
-
-		case CFG_SET_DEFAULT_FOCUS:
-			rc =
-				vx6953_set_default_focus(
-				cdata.cfg.focus.steps);
-			break;
-
-		case CFG_SET_EFFECT:
-			rc = vx6953_set_default_focus(
-				cdata.cfg.effect);
-			break;
-
-
-		case CFG_SEND_WB_INFO:
-			rc = vx6953_send_wb_info(
-				&(cdata.cfg.wb_info));
-			break;
-
-		default:
-			rc = -EFAULT;
-			break;
-		}
-
-	mutex_unlock(&vx6953_mut);
-
-	return rc;
-}
-
-
-
-
-static int vx6953_sensor_release(void)
-{
-	int rc = -EBADF;
-	mutex_lock(&vx6953_mut);
-	vx6953_power_down();
-	gpio_direction_output(vx6953_ctrl->sensordata->sensor_reset, 0);
-	gpio_free(vx6953_ctrl->sensordata->sensor_reset);
-	kfree(vx6953_ctrl);
-	vx6953_ctrl = NULL;
-	CDBG("vx6953_release completed\n");
-	mutex_unlock(&vx6953_mut);
-
-	return rc;
-}
-
-static int vx6953_sensor_probe(const struct msm_camera_sensor_info *info,
-		struct msm_sensor_ctrl *s)
-{
-	int rc = 0;
-	rc = i2c_add_driver(&vx6953_i2c_driver);
-	if (rc < 0 || vx6953_client == NULL) {
-		rc = -ENOTSUPP;
-		goto probe_fail;
-	}
-	msm_camio_clk_rate_set(24000000);
-	rc = vx6953_probe_init_sensor(info);
-	if (rc < 0)
-		goto probe_fail;
-	s->s_init = vx6953_sensor_open_init;
-	s->s_release = vx6953_sensor_release;
-	s->s_config  = vx6953_sensor_config;
-	s->s_mount_angle  = info->sensor_platform_info->mount_angle;
-	vx6953_probe_init_done(info);
-	return rc;
-
-probe_fail:
-	CDBG("vx6953_sensor_probe: SENSOR PROBE FAILS!\n");
-	return rc;
-}
-
-static int __vx6953_probe(struct platform_device *pdev)
-{
-	return msm_camera_drv_start(pdev, vx6953_sensor_probe);
-}
-
-static struct platform_driver msm_camera_driver = {
-	.probe = __vx6953_probe,
-	.driver = {
-		.name = "msm_camera_vx6953",
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init vx6953_init(void)
-{
-	return platform_driver_register(&msm_camera_driver);
-}
-
-module_init(vx6953_init);
-void vx6953_exit(void)
-{
-	i2c_del_driver(&vx6953_i2c_driver);
-}
-
-
diff --git a/drivers/media/platform/msm/camera_v1/vx6953.h b/drivers/media/platform/msm/camera_v1/vx6953.h
deleted file mode 100644
index 175facc..0000000
--- a/drivers/media/platform/msm/camera_v1/vx6953.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/* Copyright (c) 2010, The Linux Foundation. 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.
- *
- */
-
-#ifndef VX6953_H
-#define VX6953_H
-#include <linux/types.h>
-#include <mach/board.h>
-extern struct vx6953_reg vx6953_regs;
-struct reg_struct_init {
-	uint8_t reg_0x0112;      /* 0x0112*/
-	uint8_t reg_0x0113;      /* 0x0113*/
-	uint8_t vt_pix_clk_div;  /* 0x0301*/
-	uint8_t pre_pll_clk_div; /* 0x0305*/
-	uint8_t pll_multiplier;  /* 0x0307*/
-	uint8_t op_pix_clk_div;  /* 0x0309*/
-	uint8_t reg_0x3030;      /*0x3030*/
-	uint8_t reg_0x0111;      /*0x0111*/
-	uint8_t reg_0x0b00;      /*0x0b00*/
-	uint8_t reg_0x3001;      /*0x3001*/
-	uint8_t reg_0x3004;      /*0x3004*/
-	uint8_t reg_0x3007;      /*0x3007*/
-	uint8_t reg_0x3016;      /*0x3016*/
-	uint8_t reg_0x301d;      /*0x301d*/
-	uint8_t reg_0x317e;      /*0x317E*/
-	uint8_t reg_0x317f;      /*0x317F*/
-	uint8_t reg_0x3400;      /*0x3400*/
-	uint8_t reg_0x0b06;      /*0x0b06*/
-	uint8_t reg_0x0b07;      /*0x0b07*/
-	uint8_t reg_0x0b08;      /*0x0b08*/
-	uint8_t reg_0x0b09;      /*0x0b09*/
-	uint8_t reg_0x0136;
-	uint8_t reg_0x0137;
-	/* Edof */
-	uint8_t reg_0x0b83;      /*0x0b83*/
-	uint8_t reg_0x0b84;      /*0x0b84*/
-	uint8_t reg_0x0b85;      /*0x0b85*/
-	uint8_t reg_0x0b88;      /*0x0b88*/
-	uint8_t reg_0x0b89;      /*0x0b89*/
-	uint8_t reg_0x0b8a;      /*0x0b8a*/
-	};
-struct reg_struct {
-	uint8_t coarse_integration_time_hi; /*REG_COARSE_INTEGRATION_TIME_HI*/
-	uint8_t coarse_integration_time_lo; /*REG_COARSE_INTEGRATION_TIME_LO*/
-	uint8_t analogue_gain_code_global;
-	uint8_t frame_length_lines_hi; /* 0x0340*/
-	uint8_t frame_length_lines_lo; /* 0x0341*/
-	uint8_t line_length_pck_hi;    /* 0x0342*/
-	uint8_t line_length_pck_lo;    /* 0x0343*/
-	uint8_t reg_0x3005;   /* 0x3005*/
-	uint8_t reg_0x3010;  /* 0x3010*/
-	uint8_t reg_0x3011;  /* 0x3011*/
-	uint8_t reg_0x301a;  /* 0x301a*/
-	uint8_t reg_0x3035;  /* 0x3035*/
-	uint8_t reg_0x3036;   /* 0x3036*/
-	uint8_t reg_0x3041;  /*0x3041*/
-	uint8_t reg_0x3042;  /*0x3042*/
-	uint8_t reg_0x3045;  /*0x3045*/
-	uint8_t reg_0x0b80;   /* 0x0b80*/
-	uint8_t reg_0x0900;   /*0x0900*/
-	uint8_t reg_0x0901;   /* 0x0901*/
-	uint8_t reg_0x0902;   /*0x0902*/
-	uint8_t reg_0x0383;   /*0x0383*/
-	uint8_t reg_0x0387;   /* 0x0387*/
-	uint8_t reg_0x034c;   /* 0x034c*/
-	uint8_t reg_0x034d;   /*0x034d*/
-	uint8_t reg_0x034e;   /* 0x034e*/
-	uint8_t reg_0x034f;   /* 0x034f*/
-	uint8_t reg_0x1716; /*0x1716*/
-	uint8_t reg_0x1717; /*0x1717*/
-	uint8_t reg_0x1718; /*0x1718*/
-	uint8_t reg_0x1719; /*0x1719*/
-	uint8_t reg_0x3210;/*0x3210*/
-	uint8_t reg_0x111; /*0x111*/
-	uint8_t reg_0x3410;  /*0x3410*/
-	uint8_t reg_0x3098;
-	uint8_t reg_0x309D;
-	uint8_t reg_0x0200;
-	uint8_t reg_0x0201;
-	};
-struct vx6953_i2c_reg_conf {
-	unsigned short waddr;
-	unsigned short wdata;
-};
-
-enum vx6953_test_mode_t {
-	TEST_OFF,
-	TEST_1,
-	TEST_2,
-	TEST_3
-};
-
-enum vx6953_resolution_t {
-	QTR_SIZE,
-	FULL_SIZE,
-	INVALID_SIZE
-};
-enum vx6953_setting {
-	RES_PREVIEW,
-	RES_CAPTURE
-};
-enum mt9p012_reg_update {
-	/* Sensor egisters that need to be updated during initialization */
-	REG_INIT,
-	/* Sensor egisters that needs periodic I2C writes */
-	UPDATE_PERIODIC,
-	/* All the sensor Registers will be updated */
-	UPDATE_ALL,
-	/* Not valid update */
-	UPDATE_INVALID
-};
-
-enum sensor_revision_t {
-	VX6953_STM5M0EDOF_CUT_1,
-	VX6953_STM5M0EDOF_CUT_2,
-	VX6953_STM5M0EDOF_CUT_3
-};
-enum edof_mode_t {
-	VX6953_EDOF_DISABLE,       /* 0x00 */
-	VX6953_EDOF_APPLICATION,   /* 0x01 */
-	VX6953_EDOF_ESTIMATION     /* 0x02 */
-};
-struct vx6953_reg {
-	const struct reg_struct_init  *reg_pat_init;
-	const struct reg_struct  *reg_pat;
-};
-#endif /* VX6953_H */
diff --git a/drivers/media/platform/msm/camera_v1/vx6953_reg.c b/drivers/media/platform/msm/camera_v1/vx6953_reg.c
deleted file mode 100644
index eee6904..0000000
--- a/drivers/media/platform/msm/camera_v1/vx6953_reg.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/* Copyright (c) 2010, The Linux Foundation. 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.
- *
- */
-
-
-#include "vx6953.h"
-const struct reg_struct_init vx6953_reg_init[1] = {
-	{
-		10,			/*REG = 0x0112 , 10 bit */
-		10,			/*REG = 0x0113*/
-		9,			/*REG = 0x0301 vt_pix_clk_div*/
-		4,		/*REG = 0x0305 pre_pll_clk_div*/
-		133,		/*REG = 0x0307 pll_multiplier*/
-		10,		/*REG = 0x0309 op_pix_clk_div*/
-		0x08,		/*REG = 0x3030*/
-		0x02,		/*REG = 0x0111*/
-		0x01,		/*REG = 0x0b00 ,lens shading off */
-		0x30,		/*REG = 0x3001*/
-		0x33,		/*REG = 0x3004*/
-		0x09,		/*REG = 0x3007*/
-		0x1F,		/*REG = 0x3016*/
-		0x03,		/*REG = 0x301d*/
-		0x11,		/*REG = 0x317E*/
-		0x09,		/*REG = 0x317F*/
-		0x38,		/*REG = 0x3400*/
-		0x00,		/*REG_0x0b06*/
-		0x80,		/*REG_0x0b07*/
-		0x01,		/*REG_0x0b08*/
-		0x4F,		/*REG_0x0b09*/
-		0x18,		/*REG_0x0136*/
-		0x00,		/*/REG_0x0137*/
-		0x20,		/*REG = 0x0b83*/
-		0x90,		/*REG = 0x0b84*/
-		0x20,		/*REG = 0x0b85*/
-		0x80,		/*REG = 0x0b88*/
-		0x00,		/*REG = 0x0b89*/
-		0x00,		/*REG = 0x0b8a*/
-	}
-};
-const struct reg_struct vx6953_reg_pat[2] = {
-	{/* Preview */
-		0x03,	/*REG = 0x0202 coarse integration_time_hi*/
-		0xd0,	/*REG = 0x0203 coarse_integration_time_lo*/
-		0xc0,	/*REG = 0x0205 analogue_gain_code_global*/
-		0x03,	/*REG = 0x0340 frame_length_lines_hi*/
-		0xf0,	/*REG = 0x0341 frame_length_lines_lo*/
-		0x0b,	/*REG = 0x0342  line_length_pck_hi*/
-		0x74,	/*REG = 0x0343  line_length_pck_lo*/
-		0x03,	/*REG = 0x3005*/
-		0x00,	/*REG = 0x3010*/
-		0x01,	/*REG = 0x3011*/
-		0x6a,	/*REG = 0x301a*/
-		0x03,	/*REG = 0x3035*/
-		0x2c,	/*REG = 0x3036*/
-		0x00,	/*REG = 0x3041*/
-		0x24,	/*REG = 0x3042*/
-		0x81,	/*REG = 0x3045*/
-		0x02,	/*REG = 0x0b80 edof estimate*/
-		0x01,	/*REG = 0x0900*/
-		0x22,	/*REG = 0x0901*/
-		0x04,	/*REG = 0x0902*/
-		0x03,	/*REG = 0x0383*/
-		0x03,	/*REG = 0x0387*/
-		0x05,	/*REG = 0x034c*/
-		0x18,	/*REG = 0x034d*/
-		0x03,	/*REG = 0x034e*/
-		0xd4,	/*REG = 0x034f*/
-		0x02,	/*0x1716*/
-		0x04,	/*0x1717*/
-		0x08,	/*0x1718*/
-		0x2c,	/*0x1719*/
-		0x01,   /*0x3210*/
-		0x02,   /*0x111*/
-		0x01,   /*0x3410*/
-		0x01,   /*0x3098*/
-		0x05,   /*0x309D*/
-		0x02,
-		0x04,
-	},
-	{ /* Snapshot */
-		0x07,/*REG = 0x0202 coarse_integration_time_hi*/
-		0x00,/*REG = 0x0203 coarse_integration_time_lo*/
-		0xc0,/*REG = 0x0205 analogue_gain_code_global*/
-		0x07,/*REG = 0x0340 frame_length_lines_hi*/
-		0xd0,/*REG = 0x0341 frame_length_lines_lo*/
-		0x0b,/*REG = 0x0342 line_length_pck_hi*/
-		0x8c,/*REG = 0x0343 line_length_pck_lo*/
-		0x01,/*REG = 0x3005*/
-		0x00,/*REG = 0x3010*/
-		0x00,/*REG = 0x3011*/
-		0x55,/*REG = 0x301a*/
-		0x01,/*REG = 0x3035*/
-		0x23,/*REG = 0x3036*/
-		0x00,/*REG = 0x3041*/
-		0x24,/*REG = 0x3042*/
-		0xb7,/*REG = 0x3045*/
-		0x01,/*REG = 0x0b80 edof application*/
-		0x00,/*REG = 0x0900*/
-		0x00,/*REG = 0x0901*/
-		0x00,/*REG = 0x0902*/
-		0x01,/*REG = 0x0383*/
-		0x01,/*REG = 0x0387*/
-		0x0A,/*REG = 0x034c*/
-		0x30,/*REG = 0x034d*/
-		0x07,/*REG = 0x034e*/
-		0xA8,/*REG = 0x034f*/
-		0x02,/*0x1716*/
-		0x0d,/*0x1717*/
-		0x07,/*0x1718*/
-		0x7d,/*0x1719*/
-		0x01,/*0x3210*/
-		0x02,/*0x111*/
-		0x01,/*0x3410*/
-		0x01,/*0x3098*/
-		0x05, /*0x309D*/
-		0x02,
-		0x00,
-	}
-};
-
-
-
-struct vx6953_reg vx6953_regs = {
-	.reg_pat_init = &vx6953_reg_init[0],
-	.reg_pat = &vx6953_reg_pat[0],
-};
diff --git a/drivers/media/platform/msm/camera_v1/vx6953_reg_v4l2.c b/drivers/media/platform/msm/camera_v1/vx6953_reg_v4l2.c
deleted file mode 100644
index 8b1c1be..0000000
--- a/drivers/media/platform/msm/camera_v1/vx6953_reg_v4l2.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- *
- */
-
-
-#include "vx6953_v4l2.h"
-const struct reg_struct_init vx6953_reg_init[1] = {
-	{
-		10,			/*REG = 0x0112 , 10 bit */
-		10,			/*REG = 0x0113*/
-		9,			/*REG = 0x0301 vt_pix_clk_div*/
-		4,		/*REG = 0x0305 pre_pll_clk_div*/
-		133,		/*REG = 0x0307 pll_multiplier*/
-		10,		/*REG = 0x0309 op_pix_clk_div*/
-		0x08,		/*REG = 0x3030*/
-		0x02,		/*REG = 0x0111*/
-		0x01,		/*REG = 0x0b00 ,lens shading off */
-		0x30,		/*REG = 0x3001*/
-		0x33,		/*REG = 0x3004*/
-		0x09,		/*REG = 0x3007*/
-		0x1F,		/*REG = 0x3016*/
-		0x03,		/*REG = 0x301d*/
-		0x11,		/*REG = 0x317E*/
-		0x09,		/*REG = 0x317F*/
-		0x38,		/*REG = 0x3400*/
-		0x00,		/*REG_0x0b06*/
-		0x80,		/*REG_0x0b07*/
-		0x01,		/*REG_0x0b08*/
-		0x4F,		/*REG_0x0b09*/
-		0x18,		/*REG_0x0136*/
-		0x00,		/*/REG_0x0137*/
-		0x20,		/*REG = 0x0b83*/
-		0x90,		/*REG = 0x0b84*/
-		0x20,		/*REG = 0x0b85*/
-		0x80,		/*REG = 0x0b88*/
-		0x00,		/*REG = 0x0b89*/
-		0x00,		/*REG = 0x0b8a*/
-	}
-};
-const struct reg_struct vx6953_reg_pat[2] = {
-	{/* Preview */
-		0x03,	/*REG = 0x0202 coarse integration_time_hi*/
-		0xd0,	/*REG = 0x0203 coarse_integration_time_lo*/
-		0xc0,	/*REG = 0x0205 analogue_gain_code_global*/
-		0x03,	/*REG = 0x0340 frame_length_lines_hi*/
-		0xf0,	/*REG = 0x0341 frame_length_lines_lo*/
-		0x0b,	/*REG = 0x0342  line_length_pck_hi*/
-		0xa5,	/*REG = 0x0343  line_length_pck_lo*/
-		0x03,	/*REG = 0x3005*/
-		0x00,	/*REG = 0x3010*/
-		0x01,	/*REG = 0x3011*/
-		0x6a,	/*REG = 0x301a*/
-		0x03,	/*REG = 0x3035*/
-		0x2c,	/*REG = 0x3036*/
-		0x00,	/*REG = 0x3041*/
-		0x24,	/*REG = 0x3042*/
-		0x81,	/*REG = 0x3045*/
-		0x02,	/*REG = 0x0b80 edof estimate*/
-		0x01,	/*REG = 0x0900*/
-		0x22,	/*REG = 0x0901*/
-		0x04,	/*REG = 0x0902*/
-		0x03,	/*REG = 0x0383*/
-		0x03,	/*REG = 0x0387*/
-		0x05,	/*REG = 0x034c*/
-		0x18,	/*REG = 0x034d*/
-		0x03,	/*REG = 0x034e*/
-		0xd4,	/*REG = 0x034f*/
-		0x02,	/*0x1716*/
-		0x04,	/*0x1717*/
-		0x08,	/*0x1718*/
-		0x80,	/*0x1719*/
-		0x01,   /*0x3210*/
-		0x02,   /*0x111*/
-		0x01,   /*0x3410*/
-		0x01,   /*0x3098*/
-		0x05,   /*0x309D*/
-		0x02,
-		0x04,
-	},
-	{ /* Snapshot */
-		0x07,/*REG = 0x0202 coarse_integration_time_hi*/
-		0x00,/*REG = 0x0203 coarse_integration_time_lo*/
-		0xc0,/*REG = 0x0205 analogue_gain_code_global*/
-		0x07,/*REG = 0x0340 frame_length_lines_hi*/
-		0xd0,/*REG = 0x0341 frame_length_lines_lo*/
-		0x0b,/*REG = 0x0342 line_length_pck_hi*/
-		0x8c,/*REG = 0x0343 line_length_pck_lo*/
-		0x01,/*REG = 0x3005*/
-		0x00,/*REG = 0x3010*/
-		0x00,/*REG = 0x3011*/
-		0x55,/*REG = 0x301a*/
-		0x01,/*REG = 0x3035*/
-		0x23,/*REG = 0x3036*/
-		0x00,/*REG = 0x3041*/
-		0x24,/*REG = 0x3042*/
-		0xb7,/*REG = 0x3045*/
-		0x01,/*REG = 0x0b80 edof application*/
-		0x00,/*REG = 0x0900*/
-		0x00,/*REG = 0x0901*/
-		0x00,/*REG = 0x0902*/
-		0x01,/*REG = 0x0383*/
-		0x01,/*REG = 0x0387*/
-		0x0A,/*REG = 0x034c*/
-		0x30,/*REG = 0x034d*/
-		0x07,/*REG = 0x034e*/
-		0xA8,/*REG = 0x034f*/
-		0x02,/*0x1716*/
-		0x0d,/*0x1717*/
-		0x07,/*0x1718*/
-		0x7d,/*0x1719*/
-		0x01,/*0x3210*/
-		0x02,/*0x111*/
-		0x01,/*0x3410*/
-		0x01,/*0x3098*/
-		0x05, /*0x309D*/
-		0x02,
-		0x00,
-	}
-};
-
-
-
-struct vx6953_reg vx6953_regs = {
-	.reg_pat_init = &vx6953_reg_init[0],
-	.reg_pat = &vx6953_reg_pat[0],
-};
diff --git a/drivers/media/platform/msm/camera_v1/vx6953_v4l2.c b/drivers/media/platform/msm/camera_v1/vx6953_v4l2.c
deleted file mode 100644
index 7913752..0000000
--- a/drivers/media/platform/msm/camera_v1/vx6953_v4l2.c
+++ /dev/null
@@ -1,4149 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- *
- */
-
-#include <linux/delay.h>
-#include <linux/types.h>
-#include <linux/i2c.h>
-#include <linux/uaccess.h>
-#include <linux/miscdevice.h>
-#include <media/v4l2-subdev.h>
-#include <media/msm_camera.h>
-#include <mach/gpio.h>
-#include <mach/camera.h>
-#include <linux/slab.h>
-#include "vx6953_v4l2.h"
-#include "msm.h"
-
-#define V4L2_IDENT_VX6953  50000
-
-/*=============================================================
-	SENSOR REGISTER DEFINES
-==============================================================*/
-
-#define REG_GROUPED_PARAMETER_HOLD			0x0104
-#define GROUPED_PARAMETER_HOLD_OFF			0x00
-#define GROUPED_PARAMETER_HOLD				0x01
-#define REG_MODE_SELECT					0x0100
-#define MODE_SELECT_STANDBY_MODE			0x00
-#define MODE_SELECT_STREAM				0x01
-/* Integration Time */
-#define REG_COARSE_INTEGRATION_TIME_HI			0x0202
-#define REG_COARSE_INTEGRATION_TIME_LO			0x0203
-/* Gain */
-#define REG_ANALOGUE_GAIN_CODE_GLOBAL_HI		0x0204
-#define REG_ANALOGUE_GAIN_CODE_GLOBAL_LO		0x0205
-/* Digital Gain */
-#define REG_DIGITAL_GAIN_GREEN_R_HI			0x020E
-#define REG_DIGITAL_GAIN_GREEN_R_LO			0x020F
-#define REG_DIGITAL_GAIN_RED_HI				0x0210
-#define REG_DIGITAL_GAIN_RED_LO				0x0211
-#define REG_DIGITAL_GAIN_BLUE_HI			0x0212
-#define REG_DIGITAL_GAIN_BLUE_LO			0x0213
-#define REG_DIGITAL_GAIN_GREEN_B_HI			0x0214
-#define REG_DIGITAL_GAIN_GREEN_B_LO			0x0215
-/* output bits setting */
-#define REG_0x0112					0x0112
-#define REG_0x0113					0x0113
-/* PLL registers */
-#define REG_VT_PIX_CLK_DIV				0x0301
-#define REG_PRE_PLL_CLK_DIV				0x0305
-#define REG_PLL_MULTIPLIER				0x0307
-#define REG_OP_PIX_CLK_DIV				0x0309
-#define REG_0x034c					0x034c
-#define REG_0x034d					0x034d
-#define REG_0x034e					0x034e
-#define REG_0x034f					0x034f
-#define REG_0x0387					0x0387
-#define REG_0x0383					0x0383
-#define REG_FRAME_LENGTH_LINES_HI			0x0340
-#define REG_FRAME_LENGTH_LINES_LO			0x0341
-#define REG_LINE_LENGTH_PCK_HI				0x0342
-#define REG_LINE_LENGTH_PCK_LO				0x0343
-#define REG_0x3030					0x3030
-#define REG_0x0111					0x0111
-#define REG_0x0136					0x0136
-#define REG_0x0137					0x0137
-#define REG_0x0b00					0x0b00
-#define REG_0x3001					0x3001
-#define REG_0x3004					0x3004
-#define REG_0x3007					0x3007
-#define REG_0x301a					0x301a
-#define REG_0x3101					0x3101
-#define REG_0x3364					0x3364
-#define REG_0x3365					0x3365
-#define REG_0x0b83					0x0b83
-#define REG_0x0b84					0x0b84
-#define REG_0x0b85					0x0b85
-#define REG_0x0b88					0x0b88
-#define REG_0x0b89					0x0b89
-#define REG_0x0b8a					0x0b8a
-#define REG_0x3005					0x3005
-#define REG_0x3010					0x3010
-#define REG_0x3036					0x3036
-#define REG_0x3041					0x3041
-#define REG_0x0b80					0x0b80
-#define REG_0x0900					0x0900
-#define REG_0x0901					0x0901
-#define REG_0x0902					0x0902
-#define REG_0x3016					0x3016
-#define REG_0x301d					0x301d
-#define REG_0x317e					0x317e
-#define REG_0x317f					0x317f
-#define REG_0x3400					0x3400
-#define REG_0x303a					0x303a
-#define REG_0x1716					0x1716
-#define REG_0x1717					0x1717
-#define REG_0x1718					0x1718
-#define REG_0x1719					0x1719
-#define REG_0x3006					0x3006
-#define REG_0x301b					0x301b
-#define REG_0x3098					0x3098
-#define REG_0x309d					0x309d
-#define REG_0x3011					0x3011
-#define REG_0x3035					0x3035
-#define REG_0x3045					0x3045
-#define REG_0x3210					0x3210
-#define	REG_0x0111					0x0111
-#define REG_0x3410					0x3410
-/* Test Pattern */
-#define REG_TEST_PATTERN_MODE				0x0601
-
-/*============================================================================
-							 TYPE DECLARATIONS
-============================================================================*/
-
-/* 16bit address - 8 bit context register structure */
-#define	VX6953_STM5M0EDOF_OFFSET	9
-#define	Q8		0x00000100
-#define	Q10		0x00000400
-#define	VX6953_STM5M0EDOF_MAX_SNAPSHOT_EXPOSURE_LINE_COUNT	2922
-#define	VX6953_STM5M0EDOF_DEFAULT_MASTER_CLK_RATE	24000000
-#define	VX6953_STM5M0EDOF_OP_PIXEL_CLOCK_RATE	79800000
-#define	VX6953_STM5M0EDOF_VT_PIXEL_CLOCK_RATE	88670000
-/* Full	Size */
-#define	VX6953_FULL_SIZE_WIDTH	2608
-#define	VX6953_FULL_SIZE_HEIGHT		1960
-#define	VX6953_FULL_SIZE_DUMMY_PIXELS	1
-#define	VX6953_FULL_SIZE_DUMMY_LINES	0
-/* Quarter Size	*/
-#define	VX6953_QTR_SIZE_WIDTH	1304
-#define	VX6953_QTR_SIZE_HEIGHT		980
-#define	VX6953_QTR_SIZE_DUMMY_PIXELS	1
-#define	VX6953_QTR_SIZE_DUMMY_LINES		0
-/* Blanking	as measured	on the scope */
-/* Full	Size */
-#define	VX6953_HRZ_FULL_BLK_PIXELS	348
-#define	VX6953_VER_FULL_BLK_LINES	40
-/* Quarter Size	*/
-#define	VX6953_HRZ_QTR_BLK_PIXELS	1628
-#define	VX6953_VER_QTR_BLK_LINES	28
-#define	MAX_LINE_LENGTH_PCK		8190
-#define	VX6953_REVISION_NUMBER_CUT2	0x10/*revision number	for	Cut2.0*/
-#define	VX6953_REVISION_NUMBER_CUT3	0x20/*revision number	for	Cut3.0*/
-/* FIXME: Changes from here */
-struct vx6953_work_t {
-	struct work_struct work;
-};
-
-static struct vx6953_work_t *vx6953_sensorw;
-static struct i2c_client *vx6953_client;
-
-struct vx6953_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 */
-	uint16_t fps;
-
-	int16_t curr_lens_pos;
-	uint16_t curr_step_pos;
-	uint16_t my_reg_gain;
-	uint32_t my_reg_line_count;
-	uint16_t total_lines_per_frame;
-
-	enum vx6953_resolution_t prev_res;
-	enum vx6953_resolution_t pict_res;
-	enum vx6953_resolution_t curr_res;
-	enum vx6953_test_mode_t  set_test;
-	enum sensor_revision_t sensor_type;
-
-	enum edof_mode_t edof_mode;
-
-	unsigned short imgaddr;
-
-	struct v4l2_subdev *sensor_dev;
-	struct vx6953_format *fmt;
-};
-
-
-static uint8_t vx6953_stm5m0edof_delay_msecs_stdby;
-static uint16_t vx6953_stm5m0edof_delay_msecs_stream = 20;
-
-static struct vx6953_ctrl_t *vx6953_ctrl;
-static DECLARE_WAIT_QUEUE_HEAD(vx6953_wait_queue);
-DEFINE_MUTEX(vx6953_mut);
-static struct vx6953_i2c_reg_conf patch_tbl_cut2[] = {
-	{0xFB94, 0},	/*intialise Data Xfer Status reg*/
-	{0xFB95, 0},	/*gain 1	  (0x00)*/
-	{0xFB96, 0},	/*gain 1.07   (0x10)*/
-	{0xFB97, 0},	/*gain 1.14   (0x20)*/
-	{0xFB98, 0},	/*gain 1.23   (0x30)*/
-	{0xFB99, 0},	/*gain 1.33   (0x40)*/
-	{0xFB9A, 0},	/*gain 1.45   (0x50)*/
-	{0xFB9B, 0},	/*gain 1.6    (0x60)*/
-	{0xFB9C, 0},	/*gain 1.78   (0x70)*/
-	{0xFB9D, 2},	/*gain 2	  (0x80)*/
-	{0xFB9E, 2},	/*gain 2.29   (0x90)*/
-	{0xFB9F, 3},	/*gain 2.67   (0xA0)*/
-	{0xFBA0, 3},	/*gain 3.2    (0xB0)*/
-	{0xFBA1, 4},	/*gain 4	  (0xC0)*/
-	{0xFBA2, 7},	/*gain 5.33   (0xD0)*/
-	{0xFBA3, 10},	/*gain 8	  (0xE0)*/
-	{0xFBA4, 11},	/*gain 9.14   (0xE4)*/
-	{0xFBA5, 13},	/*gain 10.67  (0xE8)*/
-	{0xFBA6, 15},	/*gain 12.8   (0xEC)*/
-	{0xFBA7, 19},	/*gain 16     (0xF0)*/
-	{0xF800, 0x12},
-	{0xF801, 0x06},
-	{0xF802, 0xf7},
-	{0xF803, 0x90},
-	{0xF804, 0x02},
-	{0xF805, 0x05},
-	{0xF806, 0xe0},
-	{0xF807, 0xff},
-	{0xF808, 0x65},
-	{0xF809, 0x7d},
-	{0xF80A, 0x70},
-	{0xF80B, 0x03},
-	{0xF80C, 0x02},
-	{0xF80D, 0xf9},
-	{0xF80E, 0x1c},
-	{0xF80F, 0x8f},
-	{0xF810, 0x7d},
-	{0xF811, 0xe4},
-	{0xF812, 0xf5},
-	{0xF813, 0x7a},
-	{0xF814, 0x75},
-	{0xF815, 0x78},
-	{0xF816, 0x30},
-	{0xF817, 0x75},
-	{0xF818, 0x79},
-	{0xF819, 0x53},
-	{0xF81A, 0x85},
-	{0xF81B, 0x79},
-	{0xF81C, 0x82},
-	{0xF81D, 0x85},
-	{0xF81E, 0x78},
-	{0xF81F, 0x83},
-	{0xF820, 0xe0},
-	{0xF821, 0xc3},
-	{0xF822, 0x95},
-	{0xF823, 0x7b},
-	{0xF824, 0xf0},
-	{0xF825, 0x74},
-	{0xF826, 0x02},
-	{0xF827, 0x25},
-	{0xF828, 0x79},
-	{0xF829, 0xf5},
-	{0xF82A, 0x79},
-	{0xF82B, 0xe4},
-	{0xF82C, 0x35},
-	{0xF82D, 0x78},
-	{0xF82E, 0xf5},
-	{0xF82F, 0x78},
-	{0xF830, 0x05},
-	{0xF831, 0x7a},
-	{0xF832, 0xe5},
-	{0xF833, 0x7a},
-	{0xF834, 0xb4},
-	{0xF835, 0x08},
-	{0xF836, 0xe3},
-	{0xF837, 0xe5},
-	{0xF838, 0x7d},
-	{0xF839, 0x70},
-	{0xF83A, 0x04},
-	{0xF83B, 0xff},
-	{0xF83C, 0x02},
-	{0xF83D, 0xf8},
-	{0xF83E, 0xe4},
-	{0xF83F, 0xe5},
-	{0xF840, 0x7d},
-	{0xF841, 0xb4},
-	{0xF842, 0x10},
-	{0xF843, 0x05},
-	{0xF844, 0x7f},
-	{0xF845, 0x01},
-	{0xF846, 0x02},
-	{0xF847, 0xf8},
-	{0xF848, 0xe4},
-	{0xF849, 0xe5},
-	{0xF84A, 0x7d},
-	{0xF84B, 0xb4},
-	{0xF84C, 0x20},
-	{0xF84D, 0x05},
-	{0xF84E, 0x7f},
-	{0xF84F, 0x02},
-	{0xF850, 0x02},
-	{0xF851, 0xf8},
-	{0xF852, 0xe4},
-	{0xF853, 0xe5},
-	{0xF854, 0x7d},
-	{0xF855, 0xb4},
-	{0xF856, 0x30},
-	{0xF857, 0x05},
-	{0xF858, 0x7f},
-	{0xF859, 0x03},
-	{0xF85A, 0x02},
-	{0xF85B, 0xf8},
-	{0xF85C, 0xe4},
-	{0xF85D, 0xe5},
-	{0xF85E, 0x7d},
-	{0xF85F, 0xb4},
-	{0xF860, 0x40},
-	{0xF861, 0x04},
-	{0xF862, 0x7f},
-	{0xF863, 0x04},
-	{0xF864, 0x80},
-	{0xF865, 0x7e},
-	{0xF866, 0xe5},
-	{0xF867, 0x7d},
-	{0xF868, 0xb4},
-	{0xF869, 0x50},
-	{0xF86A, 0x04},
-	{0xF86B, 0x7f},
-	{0xF86C, 0x05},
-	{0xF86D, 0x80},
-	{0xF86E, 0x75},
-	{0xF86F, 0xe5},
-	{0xF870, 0x7d},
-	{0xF871, 0xb4},
-	{0xF872, 0x60},
-	{0xF873, 0x04},
-	{0xF874, 0x7f},
-	{0xF875, 0x06},
-	{0xF876, 0x80},
-	{0xF877, 0x6c},
-	{0xF878, 0xe5},
-	{0xF879, 0x7d},
-	{0xF87A, 0xb4},
-	{0xF87B, 0x70},
-	{0xF87C, 0x04},
-	{0xF87D, 0x7f},
-	{0xF87E, 0x07},
-	{0xF87F, 0x80},
-	{0xF880, 0x63},
-	{0xF881, 0xe5},
-	{0xF882, 0x7d},
-	{0xF883, 0xb4},
-	{0xF884, 0x80},
-	{0xF885, 0x04},
-	{0xF886, 0x7f},
-	{0xF887, 0x08},
-	{0xF888, 0x80},
-	{0xF889, 0x5a},
-	{0xF88A, 0xe5},
-	{0xF88B, 0x7d},
-	{0xF88C, 0xb4},
-	{0xF88D, 0x90},
-	{0xF88E, 0x04},
-	{0xF88F, 0x7f},
-	{0xF890, 0x09},
-	{0xF891, 0x80},
-	{0xF892, 0x51},
-	{0xF893, 0xe5},
-	{0xF894, 0x7d},
-	{0xF895, 0xb4},
-	{0xF896, 0xa0},
-	{0xF897, 0x04},
-	{0xF898, 0x7f},
-	{0xF899, 0x0a},
-	{0xF89A, 0x80},
-	{0xF89B, 0x48},
-	{0xF89C, 0xe5},
-	{0xF89D, 0x7d},
-	{0xF89E, 0xb4},
-	{0xF89F, 0xb0},
-	{0xF8A0, 0x04},
-	{0xF8A1, 0x7f},
-	{0xF8A2, 0x0b},
-	{0xF8A3, 0x80},
-	{0xF8A4, 0x3f},
-	{0xF8A5, 0xe5},
-	{0xF8A6, 0x7d},
-	{0xF8A7, 0xb4},
-	{0xF8A8, 0xc0},
-	{0xF8A9, 0x04},
-	{0xF8AA, 0x7f},
-	{0xF8AB, 0x0c},
-	{0xF8AC, 0x80},
-	{0xF8AD, 0x36},
-	{0xF8AE, 0xe5},
-	{0xF8AF, 0x7d},
-	{0xF8B0, 0xb4},
-	{0xF8B1, 0xd0},
-	{0xF8B2, 0x04},
-	{0xF8B3, 0x7f},
-	{0xF8B4, 0x0d},
-	{0xF8B5, 0x80},
-	{0xF8B6, 0x2d},
-	{0xF8B7, 0xe5},
-	{0xF8B8, 0x7d},
-	{0xF8B9, 0xb4},
-	{0xF8BA, 0xe0},
-	{0xF8BB, 0x04},
-	{0xF8BC, 0x7f},
-	{0xF8BD, 0x0e},
-	{0xF8BE, 0x80},
-	{0xF8BF, 0x24},
-	{0xF8C0, 0xe5},
-	{0xF8C1, 0x7d},
-	{0xF8C2, 0xb4},
-	{0xF8C3, 0xe4},
-	{0xF8C4, 0x04},
-	{0xF8C5, 0x7f},
-	{0xF8C6, 0x0f},
-	{0xF8C7, 0x80},
-	{0xF8C8, 0x1b},
-	{0xF8C9, 0xe5},
-	{0xF8CA, 0x7d},
-	{0xF8CB, 0xb4},
-	{0xF8CC, 0xe8},
-	{0xF8CD, 0x04},
-	{0xF8CE, 0x7f},
-	{0xF8CF, 0x10},
-	{0xF8D0, 0x80},
-	{0xF8D1, 0x12},
-	{0xF8D2, 0xe5},
-	{0xF8D3, 0x7d},
-	{0xF8D4, 0xb4},
-	{0xF8D5, 0xec},
-	{0xF8D6, 0x04},
-	{0xF8D7, 0x7f},
-	{0xF8D8, 0x11},
-	{0xF8D9, 0x80},
-	{0xF8DA, 0x09},
-	{0xF8DB, 0xe5},
-	{0xF8DC, 0x7d},
-	{0xF8DD, 0x7f},
-	{0xF8DE, 0x00},
-	{0xF8DF, 0xb4},
-	{0xF8E0, 0xf0},
-	{0xF8E1, 0x02},
-	{0xF8E2, 0x7f},
-	{0xF8E3, 0x12},
-	{0xF8E4, 0x8f},
-	{0xF8E5, 0x7c},
-	{0xF8E6, 0xef},
-	{0xF8E7, 0x24},
-	{0xF8E8, 0x95},
-	{0xF8E9, 0xff},
-	{0xF8EA, 0xe4},
-	{0xF8EB, 0x34},
-	{0xF8EC, 0xfb},
-	{0xF8ED, 0x8f},
-	{0xF8EE, 0x82},
-	{0xF8EF, 0xf5},
-	{0xF8F0, 0x83},
-	{0xF8F1, 0xe4},
-	{0xF8F2, 0x93},
-	{0xF8F3, 0xf5},
-	{0xF8F4, 0x7c},
-	{0xF8F5, 0xf5},
-	{0xF8F6, 0x7b},
-	{0xF8F7, 0xe4},
-	{0xF8F8, 0xf5},
-	{0xF8F9, 0x7a},
-	{0xF8FA, 0x75},
-	{0xF8FB, 0x78},
-	{0xF8FC, 0x30},
-	{0xF8FD, 0x75},
-	{0xF8FE, 0x79},
-	{0xF8FF, 0x53},
-	{0xF900, 0x85},
-	{0xF901, 0x79},
-	{0xF902, 0x82},
-	{0xF903, 0x85},
-	{0xF904, 0x78},
-	{0xF905, 0x83},
-	{0xF906, 0xe0},
-	{0xF907, 0x25},
-	{0xF908, 0x7c},
-	{0xF909, 0xf0},
-	{0xF90A, 0x74},
-	{0xF90B, 0x02},
-	{0xF90C, 0x25},
-	{0xF90D, 0x79},
-	{0xF90E, 0xf5},
-	{0xF90F, 0x79},
-	{0xF910, 0xe4},
-	{0xF911, 0x35},
-	{0xF912, 0x78},
-	{0xF913, 0xf5},
-	{0xF914, 0x78},
-	{0xF915, 0x05},
-	{0xF916, 0x7a},
-	{0xF917, 0xe5},
-	{0xF918, 0x7a},
-	{0xF919, 0xb4},
-	{0xF91A, 0x08},
-	{0xF91B, 0xe4},
-	{0xF91C, 0x02},
-	{0xF91D, 0x18},
-	{0xF91E, 0x32},
-	{0xF91F, 0x22},
-	{0xF920, 0xf0},
-	{0xF921, 0x90},
-	{0xF922, 0xa0},
-	{0xF923, 0xf8},
-	{0xF924, 0xe0},
-	{0xF925, 0x70},
-	{0xF926, 0x02},
-	{0xF927, 0xa3},
-	{0xF928, 0xe0},
-	{0xF929, 0x70},
-	{0xF92A, 0x0a},
-	{0xF92B, 0x90},
-	{0xF92C, 0xa1},
-	{0xF92D, 0x10},
-	{0xF92E, 0xe0},
-	{0xF92F, 0xfe},
-	{0xF930, 0xa3},
-	{0xF931, 0xe0},
-	{0xF932, 0xff},
-	{0xF933, 0x80},
-	{0xF934, 0x04},
-	{0xF935, 0x7e},
-	{0xF936, 0x00},
-	{0xF937, 0x7f},
-	{0xF938, 0x00},
-	{0xF939, 0x8e},
-	{0xF93A, 0x7e},
-	{0xF93B, 0x8f},
-	{0xF93C, 0x7f},
-	{0xF93D, 0x90},
-	{0xF93E, 0x36},
-	{0xF93F, 0x0d},
-	{0xF940, 0xe0},
-	{0xF941, 0x44},
-	{0xF942, 0x02},
-	{0xF943, 0xf0},
-	{0xF944, 0x90},
-	{0xF945, 0x36},
-	{0xF946, 0x0e},
-	{0xF947, 0xe5},
-	{0xF948, 0x7e},
-	{0xF949, 0xf0},
-	{0xF94A, 0xa3},
-	{0xF94B, 0xe5},
-	{0xF94C, 0x7f},
-	{0xF94D, 0xf0},
-	{0xF94E, 0xe5},
-	{0xF94F, 0x3a},
-	{0xF950, 0x60},
-	{0xF951, 0x0c},
-	{0xF952, 0x90},
-	{0xF953, 0x36},
-	{0xF954, 0x09},
-	{0xF955, 0xe0},
-	{0xF956, 0x70},
-	{0xF957, 0x06},
-	{0xF958, 0x90},
-	{0xF959, 0x36},
-	{0xF95A, 0x08},
-	{0xF95B, 0xf0},
-	{0xF95C, 0xf5},
-	{0xF95D, 0x3a},
-	{0xF95E, 0x02},
-	{0xF95F, 0x03},
-	{0xF960, 0x94},
-	{0xF961, 0x22},
-	{0xF962, 0x78},
-	{0xF963, 0x07},
-	{0xF964, 0xe6},
-	{0xF965, 0xd3},
-	{0xF966, 0x94},
-	{0xF967, 0x00},
-	{0xF968, 0x40},
-	{0xF969, 0x16},
-	{0xF96A, 0x16},
-	{0xF96B, 0xe6},
-	{0xF96C, 0x90},
-	{0xF96D, 0x30},
-	{0xF96E, 0xa1},
-	{0xF96F, 0xf0},
-	{0xF970, 0x90},
-	{0xF971, 0x43},
-	{0xF972, 0x83},
-	{0xF973, 0xe0},
-	{0xF974, 0xb4},
-	{0xF975, 0x01},
-	{0xF976, 0x0f},
-	{0xF977, 0x90},
-	{0xF978, 0x43},
-	{0xF979, 0x87},
-	{0xF97A, 0xe0},
-	{0xF97B, 0xb4},
-	{0xF97C, 0x01},
-	{0xF97D, 0x08},
-	{0xF97E, 0x80},
-	{0xF97F, 0x00},
-	{0xF980, 0x90},
-	{0xF981, 0x30},
-	{0xF982, 0xa0},
-	{0xF983, 0x74},
-	{0xF984, 0x01},
-	{0xF985, 0xf0},
-	{0xF986, 0x22},
-	{0xF987, 0xf0},
-	{0xF988, 0x90},
-	{0xF989, 0x35},
-	{0xF98A, 0xba},
-	{0xF98B, 0xe0},
-	{0xF98C, 0xb4},
-	{0xF98D, 0x0a},
-	{0xF98E, 0x0d},
-	{0xF98F, 0xa3},
-	{0xF990, 0xe0},
-	{0xF991, 0xb4},
-	{0xF992, 0x01},
-	{0xF993, 0x08},
-	{0xF994, 0x90},
-	{0xF995, 0xfb},
-	{0xF996, 0x94},
-	{0xF997, 0xe0},
-	{0xF998, 0x90},
-	{0xF999, 0x35},
-	{0xF99A, 0xb8},
-	{0xF99B, 0xf0},
-	{0xF99C, 0xd0},
-	{0xF99D, 0xd0},
-	{0xF99E, 0xd0},
-	{0xF99F, 0x82},
-	{0xF9A0, 0xd0},
-	{0xF9A1, 0x83},
-	{0xF9A2, 0xd0},
-	{0xF9A3, 0xe0},
-	{0xF9A4, 0x32},
-	{0xF9A5, 0x22},
-	{0xF9A6, 0xe5},
-	{0xF9A7, 0x7f},
-	{0xF9A8, 0x45},
-	{0xF9A9, 0x7e},
-	{0xF9AA, 0x60},
-	{0xF9AB, 0x15},
-	{0xF9AC, 0x90},
-	{0xF9AD, 0x01},
-	{0xF9AE, 0x00},
-	{0xF9AF, 0xe0},
-	{0xF9B0, 0x70},
-	{0xF9B1, 0x0f},
-	{0xF9B2, 0x90},
-	{0xF9B3, 0xa0},
-	{0xF9B4, 0xf8},
-	{0xF9B5, 0xe5},
-	{0xF9B6, 0x7e},
-	{0xF9B7, 0xf0},
-	{0xF9B8, 0xa3},
-	{0xF9B9, 0xe5},
-	{0xF9BA, 0x7f},
-	{0xF9BB, 0xf0},
-	{0xF9BC, 0xe4},
-	{0xF9BD, 0xf5},
-	{0xF9BE, 0x7e},
-	{0xF9BF, 0xf5},
-	{0xF9C0, 0x7f},
-	{0xF9C1, 0x22},
-	{0xF9C2, 0x02},
-	{0xF9C3, 0x0e},
-	{0xF9C4, 0x79},
-	{0xF9C5, 0x22},
-	/* Offsets:*/
-	{0x35C6, 0x00},/* FIDDLEDARKCAL*/
-	{0x35C7, 0x00},
-	{0x35C8, 0x01},/*STOREDISTANCEATSTOPSTREAMING*/
-	{0x35C9, 0x20},
-	{0x35CA, 0x01},/*BRUCEFIX*/
-	{0x35CB, 0x62},
-	{0x35CC, 0x01},/*FIXDATAXFERSTATUSREG*/
-	{0x35CD, 0x87},
-	{0x35CE, 0x01},/*FOCUSDISTANCEUPDATE*/
-	{0x35CF, 0xA6},
-	{0x35D0, 0x01},/*SKIPEDOFRESET*/
-	{0x35D1, 0xC2},
-	{0x35D2, 0x00},
-	{0x35D3, 0xFB},
-	{0x35D4, 0x00},
-	{0x35D5, 0x94},
-	{0x35D6, 0x00},
-	{0x35D7, 0xFB},
-	{0x35D8, 0x00},
-	{0x35D9, 0x94},
-	{0x35DA, 0x00},
-	{0x35DB, 0xFB},
-	{0x35DC, 0x00},
-	{0x35DD, 0x94},
-	{0x35DE, 0x00},
-	{0x35DF, 0xFB},
-	{0x35E0, 0x00},
-	{0x35E1, 0x94},
-	{0x35E6, 0x18},/* FIDDLEDARKCAL*/
-	{0x35E7, 0x2F},
-	{0x35E8, 0x03},/* STOREDISTANCEATSTOPSTREAMING*/
-	{0x35E9, 0x93},
-	{0x35EA, 0x18},/* BRUCEFIX*/
-	{0x35EB, 0x99},
-	{0x35EC, 0x00},/* FIXDATAXFERSTATUSREG*/
-	{0x35ED, 0xA3},
-	{0x35EE, 0x21},/* FOCUSDISTANCEUPDATE*/
-	{0x35EF, 0x5B},
-	{0x35F0, 0x0E},/* SKIPEDOFRESET*/
-	{0x35F1, 0x74},
-	{0x35F2, 0x04},
-	{0x35F3, 0x64},
-	{0x35F4, 0x04},
-	{0x35F5, 0x65},
-	{0x35F6, 0x04},
-	{0x35F7, 0x7B},
-	{0x35F8, 0x04},
-	{0x35F9, 0x7C},
-	{0x35FA, 0x04},
-	{0x35FB, 0xDD},
-	{0x35FC, 0x04},
-	{0x35FD, 0xDE},
-	{0x35FE, 0x04},
-	{0x35FF, 0xEF},
-	{0x3600, 0x04},
-	{0x3601, 0xF0},
-	/*Jump/Data:*/
-	{0x35C2, 0x3F},/* Jump Reg*/
-	{0x35C3, 0xFF},/* Jump Reg*/
-	{0x35C4, 0x3F},/* Data Reg*/
-	{0x35C5, 0xC0},/* Data Reg*/
-	{0x35C0, 0x01},/* Enable*/
-
-};
-
-static struct vx6953_i2c_reg_conf edof_tbl[] = {
-	{0xa098, 0x02},
-	{0xa099, 0x87},
-	{0xa09c, 0x00},
-	{0xa09d, 0xc5},
-	{0xa4ec, 0x05},
-	{0xa4ed, 0x05},
-	{0xa4f0, 0x04},
-	{0xa4f1, 0x04},
-	{0xa4f4, 0x04},
-	{0xa4f5, 0x05},
-	{0xa4f8, 0x05},
-	{0xa4f9, 0x07},
-	{0xa4fc, 0x07},
-	{0xa4fd, 0x07},
-	{0xa500, 0x07},
-	{0xa501, 0x07},
-	{0xa504, 0x08},
-	{0xa505, 0x08},
-	{0xa518, 0x01},
-	{0xa519, 0x02},
-	{0xa51c, 0x01},
-	{0xa51d, 0x00},
-	{0xa534, 0x00},
-	{0xa535, 0x04},
-	{0xa538, 0x04},
-	{0xa539, 0x03},
-	{0xa53c, 0x05},
-	{0xa53d, 0x07},
-	{0xa540, 0x07},
-	{0xa541, 0x06},
-	{0xa544, 0x07},
-	{0xa545, 0x06},
-	{0xa548, 0x05},
-	{0xa549, 0x06},
-	{0xa54c, 0x06},
-	{0xa54d, 0x07},
-	{0xa550, 0x07},
-	{0xa551, 0x04},
-	{0xa554, 0x04},
-	{0xa555, 0x04},
-	{0xa558, 0x05},
-	{0xa559, 0x06},
-	{0xa55c, 0x07},
-	{0xa55d, 0x07},
-	{0xa56c, 0x00},
-	{0xa56d, 0x0a},
-	{0xa570, 0x08},
-	{0xa571, 0x05},
-	{0xa574, 0x04},
-	{0xa575, 0x03},
-	{0xa578, 0x04},
-	{0xa579, 0x04},
-	{0xa58c, 0x1f},
-	{0xa58d, 0x1b},
-	{0xa590, 0x17},
-	{0xa591, 0x13},
-	{0xa594, 0x10},
-	{0xa595, 0x0d},
-	{0xa598, 0x0f},
-	{0xa599, 0x11},
-	{0xa59c, 0x03},
-	{0xa59d, 0x03},
-	{0xa5a0, 0x03},
-	{0xa5a1, 0x03},
-	{0xa5a4, 0x03},
-	{0xa5a5, 0x04},
-	{0xa5a8, 0x05},
-	{0xa5a9, 0x00},
-	{0xa5ac, 0x00},
-	{0xa5ad, 0x00},
-	{0xa5b0, 0x00},
-	{0xa5b1, 0x00},
-	{0xa5b4, 0x00},
-	{0xa5b5, 0x00},
-	{0xa5c4, 0x1f},
-	{0xa5c5, 0x13},
-	{0xa5c8, 0x14},
-	{0xa5c9, 0x14},
-	{0xa5cc, 0x14},
-	{0xa5cd, 0x13},
-	{0xa5d0, 0x17},
-	{0xa5d1, 0x1a},
-	{0xa5f4, 0x05},
-	{0xa5f5, 0x05},
-	{0xa5f8, 0x05},
-	{0xa5f9, 0x06},
-	{0xa5fc, 0x06},
-	{0xa5fd, 0x06},
-	{0xa600, 0x06},
-	{0xa601, 0x06},
-	{0xa608, 0x07},
-	{0xa609, 0x08},
-	{0xa60c, 0x08},
-	{0xa60d, 0x07},
-	{0xa63c, 0x00},
-	{0xa63d, 0x02},
-	{0xa640, 0x02},
-	{0xa641, 0x02},
-	{0xa644, 0x02},
-	{0xa645, 0x02},
-	{0xa648, 0x03},
-	{0xa649, 0x04},
-	{0xa64c, 0x0a},
-	{0xa64d, 0x09},
-	{0xa650, 0x08},
-	{0xa651, 0x09},
-	{0xa654, 0x09},
-	{0xa655, 0x0a},
-	{0xa658, 0x0a},
-	{0xa659, 0x0a},
-	{0xa65c, 0x0a},
-	{0xa65d, 0x09},
-	{0xa660, 0x09},
-	{0xa661, 0x09},
-	{0xa664, 0x09},
-	{0xa665, 0x08},
-	{0xa680, 0x01},
-	{0xa681, 0x02},
-	{0xa694, 0x1f},
-	{0xa695, 0x10},
-	{0xa698, 0x0e},
-	{0xa699, 0x0c},
-	{0xa69c, 0x0d},
-	{0xa69d, 0x0d},
-	{0xa6a0, 0x0f},
-	{0xa6a1, 0x11},
-	{0xa6a4, 0x00},
-	{0xa6a5, 0x00},
-	{0xa6a8, 0x00},
-	{0xa6a9, 0x00},
-	{0xa6ac, 0x00},
-	{0xa6ad, 0x00},
-	{0xa6b0, 0x00},
-	{0xa6b1, 0x04},
-	{0xa6b4, 0x04},
-	{0xa6b5, 0x04},
-	{0xa6b8, 0x04},
-	{0xa6b9, 0x04},
-	{0xa6bc, 0x05},
-	{0xa6bd, 0x05},
-	{0xa6c0, 0x1f},
-	{0xa6c1, 0x1f},
-	{0xa6c4, 0x1f},
-	{0xa6c5, 0x1f},
-	{0xa6c8, 0x1f},
-	{0xa6c9, 0x1f},
-	{0xa6cc, 0x1f},
-	{0xa6cd, 0x0b},
-	{0xa6d0, 0x0c},
-	{0xa6d1, 0x0d},
-	{0xa6d4, 0x0d},
-	{0xa6d5, 0x0d},
-	{0xa6d8, 0x11},
-	{0xa6d9, 0x14},
-	{0xa6fc, 0x02},
-	{0xa6fd, 0x03},
-	{0xa700, 0x03},
-	{0xa701, 0x03},
-	{0xa704, 0x03},
-	{0xa705, 0x04},
-	{0xa708, 0x05},
-	{0xa709, 0x02},
-	{0xa70c, 0x02},
-	{0xa70d, 0x02},
-	{0xa710, 0x03},
-	{0xa711, 0x04},
-	{0xa714, 0x04},
-	{0xa715, 0x04},
-	{0xa744, 0x00},
-	{0xa745, 0x03},
-	{0xa748, 0x04},
-	{0xa749, 0x04},
-	{0xa74c, 0x05},
-	{0xa74d, 0x06},
-	{0xa750, 0x07},
-	{0xa751, 0x07},
-	{0xa754, 0x05},
-	{0xa755, 0x05},
-	{0xa758, 0x05},
-	{0xa759, 0x05},
-	{0xa75c, 0x05},
-	{0xa75d, 0x06},
-	{0xa760, 0x07},
-	{0xa761, 0x07},
-	{0xa764, 0x06},
-	{0xa765, 0x05},
-	{0xa768, 0x05},
-	{0xa769, 0x05},
-	{0xa76c, 0x06},
-	{0xa76d, 0x07},
-	{0xa77c, 0x00},
-	{0xa77d, 0x05},
-	{0xa780, 0x05},
-	{0xa781, 0x05},
-	{0xa784, 0x05},
-	{0xa785, 0x04},
-	{0xa788, 0x05},
-	{0xa789, 0x06},
-	{0xa79c, 0x1f},
-	{0xa79d, 0x15},
-	{0xa7a0, 0x13},
-	{0xa7a1, 0x10},
-	{0xa7a4, 0x0f},
-	{0xa7a5, 0x0d},
-	{0xa7a8, 0x11},
-	{0xa7a9, 0x14},
-	{0xa7ac, 0x02},
-	{0xa7ad, 0x02},
-	{0xa7b0, 0x02},
-	{0xa7b1, 0x02},
-	{0xa7b4, 0x02},
-	{0xa7b5, 0x03},
-	{0xa7b8, 0x03},
-	{0xa7b9, 0x00},
-	{0xa7bc, 0x00},
-	{0xa7bd, 0x00},
-	{0xa7c0, 0x00},
-	{0xa7c1, 0x00},
-	{0xa7c4, 0x00},
-	{0xa7c5, 0x00},
-	{0xa7d4, 0x1f},
-	{0xa7d5, 0x0d},
-	{0xa7d8, 0x0f},
-	{0xa7d9, 0x10},
-	{0xa7dc, 0x10},
-	{0xa7dd, 0x10},
-	{0xa7e0, 0x13},
-	{0xa7e1, 0x16},
-	{0xa7f4, 0x00},
-	{0xa7f5, 0x03},
-	{0xa7f8, 0x04},
-	{0xa7f9, 0x04},
-	{0xa7fc, 0x04},
-	{0xa7fd, 0x03},
-	{0xa800, 0x03},
-	{0xa801, 0x03},
-	{0xa804, 0x03},
-	{0xa805, 0x03},
-	{0xa808, 0x03},
-	{0xa809, 0x03},
-	{0xa80c, 0x03},
-	{0xa80d, 0x04},
-	{0xa810, 0x04},
-	{0xa811, 0x0a},
-	{0xa814, 0x0a},
-	{0xa815, 0x0a},
-	{0xa818, 0x0f},
-	{0xa819, 0x14},
-	{0xa81c, 0x14},
-	{0xa81d, 0x14},
-	{0xa82c, 0x00},
-	{0xa82d, 0x04},
-	{0xa830, 0x02},
-	{0xa831, 0x00},
-	{0xa834, 0x00},
-	{0xa835, 0x00},
-	{0xa838, 0x00},
-	{0xa839, 0x00},
-	{0xa840, 0x1f},
-	{0xa841, 0x1f},
-	{0xa848, 0x1f},
-	{0xa849, 0x1f},
-	{0xa84c, 0x1f},
-	{0xa84d, 0x0c},
-	{0xa850, 0x0c},
-	{0xa851, 0x0c},
-	{0xa854, 0x0c},
-	{0xa855, 0x0c},
-	{0xa858, 0x0c},
-	{0xa859, 0x0c},
-	{0xa85c, 0x0c},
-	{0xa85d, 0x0c},
-	{0xa860, 0x0c},
-	{0xa861, 0x0c},
-	{0xa864, 0x0c},
-	{0xa865, 0x0c},
-	{0xa868, 0x0c},
-	{0xa869, 0x0c},
-	{0xa86c, 0x0c},
-	{0xa86d, 0x0c},
-	{0xa870, 0x0c},
-	{0xa871, 0x0c},
-	{0xa874, 0x0c},
-	{0xa875, 0x0c},
-	{0xa878, 0x1f},
-	{0xa879, 0x1f},
-	{0xa87c, 0x1f},
-	{0xa87d, 0x1f},
-	{0xa880, 0x1f},
-	{0xa881, 0x1f},
-	{0xa884, 0x1f},
-	{0xa885, 0x0c},
-	{0xa888, 0x0c},
-	{0xa889, 0x0c},
-	{0xa88c, 0x0c},
-	{0xa88d, 0x0c},
-	{0xa890, 0x0c},
-	{0xa891, 0x0c},
-	{0xa898, 0x1f},
-	{0xa899, 0x1f},
-	{0xa8a0, 0x1f},
-	{0xa8a1, 0x1f},
-	{0xa8a4, 0x1f},
-	{0xa8a5, 0x0c},
-	{0xa8a8, 0x0c},
-	{0xa8a9, 0x0c},
-	{0xa8ac, 0x0c},
-	{0xa8ad, 0x0c},
-	{0xa8b0, 0x0c},
-	{0xa8b1, 0x0c},
-	{0xa8b4, 0x0c},
-	{0xa8b5, 0x0c},
-	{0xa8b8, 0x0c},
-	{0xa8b9, 0x0c},
-	{0xa8bc, 0x0c},
-	{0xa8bd, 0x0c},
-	{0xa8c0, 0x0c},
-	{0xa8c1, 0x0c},
-	{0xa8c4, 0x0c},
-	{0xa8c5, 0x0c},
-	{0xa8c8, 0x0c},
-	{0xa8c9, 0x0c},
-	{0xa8cc, 0x0c},
-	{0xa8cd, 0x0c},
-	{0xa8d0, 0x1f},
-	{0xa8d1, 0x1f},
-	{0xa8d4, 0x1f},
-	{0xa8d5, 0x1f},
-	{0xa8d8, 0x1f},
-	{0xa8d9, 0x1f},
-	{0xa8dc, 0x1f},
-	{0xa8dd, 0x0c},
-	{0xa8e0, 0x0c},
-	{0xa8e1, 0x0c},
-	{0xa8e4, 0x0c},
-	{0xa8e5, 0x0c},
-	{0xa8e8, 0x0c},
-	{0xa8e9, 0x0c},
-	{0xa8f0, 0x1f},
-	{0xa8f1, 0x1f},
-	{0xa8f8, 0x1f},
-	{0xa8f9, 0x1f},
-	{0xa8fc, 0x1f},
-	{0xa8fd, 0x0c},
-	{0xa900, 0x0c},
-	{0xa901, 0x0c},
-	{0xa904, 0x0c},
-	{0xa905, 0x0c},
-	{0xa908, 0x0c},
-	{0xa909, 0x0c},
-	{0xa90c, 0x0c},
-	{0xa90d, 0x0c},
-	{0xa910, 0x0c},
-	{0xa911, 0x0c},
-	{0xa914, 0x0c},
-	{0xa915, 0x0c},
-	{0xa918, 0x0c},
-	{0xa919, 0x0c},
-	{0xa91c, 0x0c},
-	{0xa91d, 0x0c},
-	{0xa920, 0x0c},
-	{0xa921, 0x0c},
-	{0xa924, 0x0c},
-	{0xa925, 0x0c},
-	{0xa928, 0x1f},
-	{0xa929, 0x1f},
-	{0xa92c, 0x1f},
-	{0xa92d, 0x1f},
-	{0xa930, 0x1f},
-	{0xa931, 0x1f},
-	{0xa934, 0x1f},
-	{0xa935, 0x0c},
-	{0xa938, 0x0c},
-	{0xa939, 0x0c},
-	{0xa93c, 0x0c},
-	{0xa93d, 0x0c},
-	{0xa940, 0x0c},
-	{0xa941, 0x0c},
-	{0xa96c, 0x0d},
-	{0xa96d, 0x16},
-	{0xa970, 0x19},
-	{0xa971, 0x0e},
-	{0xa974, 0x16},
-	{0xa975, 0x1a},
-	{0xa978, 0x0d},
-	{0xa979, 0x15},
-	{0xa97c, 0x19},
-	{0xa97d, 0x0d},
-	{0xa980, 0x15},
-	{0xa981, 0x1a},
-	{0xa984, 0x0d},
-	{0xa985, 0x15},
-	{0xa988, 0x1a},
-	{0xa989, 0x0d},
-	{0xa98c, 0x15},
-	{0xa98d, 0x1a},
-	{0xa990, 0x0b},
-	{0xa991, 0x11},
-	{0xa994, 0x02},
-	{0xa995, 0x0e},
-	{0xa998, 0x16},
-	{0xa999, 0x02},
-	{0xa99c, 0x0c},
-	{0xa99d, 0x13},
-	{0xa9a0, 0x02},
-	{0xa9a1, 0x0c},
-	{0xa9a4, 0x12},
-	{0xa9a5, 0x02},
-	{0xa9a8, 0x0c},
-	{0xa9a9, 0x12},
-	{0xa9ac, 0x02},
-	{0xa9ad, 0x0c},
-	{0xa9b0, 0x12},
-	{0xa9b1, 0x02},
-	{0xa9b4, 0x10},
-	{0xa9b5, 0x1e},
-	{0xa9b8, 0x0f},
-	{0xa9b9, 0x13},
-	{0xa9bc, 0x20},
-	{0xa9bd, 0x10},
-	{0xa9c0, 0x11},
-	{0xa9c1, 0x1e},
-	{0xa9c4, 0x10},
-	{0xa9c5, 0x11},
-	{0xa9c8, 0x1e},
-	{0xa9c9, 0x10},
-	{0xa9cc, 0x11},
-	{0xa9cd, 0x20},
-	{0xa9d0, 0x10},
-	{0xa9d1, 0x13},
-	{0xa9d4, 0x24},
-	{0xa9d5, 0x10},
-	{0xa9f0, 0x02},
-	{0xa9f1, 0x01},
-	{0xa9f8, 0x19},
-	{0xa9f9, 0x0b},
-	{0xa9fc, 0x0a},
-	{0xa9fd, 0x07},
-	{0xaa00, 0x0c},
-	{0xaa01, 0x0e},
-	{0xaa08, 0x0c},
-	{0xaa09, 0x06},
-	{0xaa0c, 0x0c},
-	{0xaa0d, 0x0a},
-	{0xaa24, 0x10},
-	{0xaa25, 0x12},
-	{0xaa28, 0x0b},
-	{0xaa29, 0x07},
-	{0xaa2c, 0x10},
-	{0xaa2d, 0x14},
-	{0xaa34, 0x0e},
-	{0xaa35, 0x0e},
-	{0xaa38, 0x07},
-	{0xaa39, 0x07},
-	{0xaa3c, 0x0e},
-	{0xaa3d, 0x0c},
-	{0xaa48, 0x09},
-	{0xaa49, 0x0c},
-	{0xaa4c, 0x0c},
-	{0xaa4d, 0x07},
-	{0xaa54, 0x08},
-	{0xaa55, 0x06},
-	{0xaa58, 0x04},
-	{0xaa59, 0x05},
-	{0xaa5c, 0x06},
-	{0xaa5d, 0x06},
-	{0xaa68, 0x05},
-	{0xaa69, 0x05},
-	{0xaa6c, 0x04},
-	{0xaa6d, 0x05},
-	{0xaa74, 0x06},
-	{0xaa75, 0x04},
-	{0xaa78, 0x05},
-	{0xaa79, 0x05},
-	{0xaa7c, 0x04},
-	{0xaa7d, 0x06},
-	{0xac18, 0x14},
-	{0xac19, 0x00},
-	{0xac1c, 0x14},
-	{0xac1d, 0x00},
-	{0xac20, 0x14},
-	{0xac21, 0x00},
-	{0xac24, 0x14},
-	{0xac25, 0x00},
-	{0xac28, 0x14},
-	{0xac29, 0x00},
-	{0xac2c, 0x14},
-	{0xac2d, 0x00},
-	{0xac34, 0x16},
-	{0xac35, 0x00},
-	{0xac38, 0x16},
-	{0xac39, 0x00},
-	{0xac3c, 0x16},
-	{0xac3d, 0x00},
-	{0xac40, 0x16},
-	{0xac41, 0x00},
-	{0xac44, 0x16},
-	{0xac45, 0x00},
-	{0xac48, 0x16},
-	{0xac49, 0x00},
-	{0xac50, 0x1b},
-	{0xac51, 0x00},
-	{0xac54, 0x1b},
-	{0xac55, 0x00},
-	{0xac58, 0x1b},
-	{0xac59, 0x00},
-	{0xac5c, 0x1b},
-	{0xac5d, 0x00},
-	{0xac60, 0x1b},
-	{0xac61, 0x00},
-	{0xac64, 0x1b},
-	{0xac65, 0x00},
-	{0xac74, 0x09},
-	{0xac75, 0x0c},
-	{0xac78, 0x0f},
-	{0xac79, 0x11},
-	{0xac7c, 0x12},
-	{0xac7d, 0x14},
-	{0xac80, 0x09},
-	{0xac81, 0x0c},
-	{0xac84, 0x0f},
-	{0xac85, 0x11},
-	{0xac88, 0x12},
-	{0xac89, 0x14},
-	{0xac8c, 0x09},
-	{0xac8d, 0x0c},
-	{0xac90, 0x0f},
-	{0xac91, 0x11},
-	{0xac94, 0x12},
-	{0xac95, 0x14},
-	{0xac98, 0x09},
-	{0xac99, 0x0c},
-	{0xac9c, 0x0f},
-	{0xac9d, 0x11},
-	{0xaca0, 0x12},
-	{0xaca1, 0x14},
-	{0xaca4, 0x09},
-	{0xaca5, 0x0c},
-	{0xaca8, 0x0f},
-	{0xaca9, 0x11},
-	{0xacac, 0x12},
-	{0xacad, 0x14},
-	{0xacb0, 0x07},
-	{0xacb1, 0x09},
-	{0xacb4, 0x0c},
-	{0xacb5, 0x0d},
-	{0xacb8, 0x0d},
-	{0xacb9, 0x0e},
-	{0xacbc, 0x05},
-	{0xacbd, 0x07},
-	{0xacc0, 0x0a},
-	{0xacc1, 0x0b},
-	{0xacc4, 0x0b},
-	{0xacc5, 0x0c},
-	{0xacc8, 0x03},
-	{0xacc9, 0x04},
-	{0xaccc, 0x07},
-	{0xaccd, 0x08},
-	{0xacd0, 0x09},
-	{0xacd1, 0x09}
-};
-
-static struct vx6953_i2c_reg_conf patch_tbl_cut3[] = {
-	{0xF800, 0x90},
-	{0xF801, 0x30},
-	{0xF802, 0x31},
-	{0xF803, 0xe0},
-	{0xF804, 0xf5},
-	{0xF805, 0x7d},
-	{0xF806, 0xb4},
-	{0xF807, 0x01},
-	{0xF808, 0x06},
-	{0xF809, 0x75},
-	{0xF80A, 0x7d},
-	{0xF80B, 0x03},
-	{0xF80C, 0x74},
-	{0xF80D, 0x03},
-	{0xF80E, 0xf0},
-	{0xF80F, 0x90},
-	{0xF810, 0x30},
-	{0xF811, 0x04},
-	{0xF812, 0x74},
-	{0xF813, 0x33},
-	{0xF814, 0xf0},
-	{0xF815, 0x90},
-	{0xF816, 0x30},
-	{0xF817, 0x06},
-	{0xF818, 0xe4},
-	{0xF819, 0xf0},
-	{0xF81A, 0xa3},
-	{0xF81B, 0x74},
-	{0xF81C, 0x09},
-	{0xF81D, 0xf0},
-	{0xF81E, 0x90},
-	{0xF81F, 0x30},
-	{0xF820, 0x10},
-	{0xF821, 0xe4},
-	{0xF822, 0xf0},
-	{0xF823, 0xa3},
-	{0xF824, 0xf0},
-	{0xF825, 0x90},
-	{0xF826, 0x30},
-	{0xF827, 0x16},
-	{0xF828, 0x74},
-	{0xF829, 0x1e},
-	{0xF82A, 0xf0},
-	{0xF82B, 0x90},
-	{0xF82C, 0x30},
-	{0xF82D, 0x1a},
-	{0xF82E, 0x74},
-	{0xF82F, 0x6a},
-	{0xF830, 0xf0},
-	{0xF831, 0xa3},
-	{0xF832, 0x74},
-	{0xF833, 0x29},
-	{0xF834, 0xf0},
-	{0xF835, 0x90},
-	{0xF836, 0x30},
-	{0xF837, 0x30},
-	{0xF838, 0x74},
-	{0xF839, 0x08},
-	{0xF83A, 0xf0},
-	{0xF83B, 0x90},
-	{0xF83C, 0x30},
-	{0xF83D, 0x36},
-	{0xF83E, 0x74},
-	{0xF83F, 0x2c},
-	{0xF840, 0xf0},
-	{0xF841, 0x90},
-	{0xF842, 0x30},
-	{0xF843, 0x41},
-	{0xF844, 0xe4},
-	{0xF845, 0xf0},
-	{0xF846, 0xa3},
-	{0xF847, 0x74},
-	{0xF848, 0x24},
-	{0xF849, 0xf0},
-	{0xF84A, 0x90},
-	{0xF84B, 0x30},
-	{0xF84C, 0x45},
-	{0xF84D, 0x74},
-	{0xF84E, 0x81},
-	{0xF84F, 0xf0},
-	{0xF850, 0x90},
-	{0xF851, 0x30},
-	{0xF852, 0x98},
-	{0xF853, 0x74},
-	{0xF854, 0x01},
-	{0xF855, 0xf0},
-	{0xF856, 0x90},
-	{0xF857, 0x30},
-	{0xF858, 0x9d},
-	{0xF859, 0x74},
-	{0xF85A, 0x05},
-	{0xF85B, 0xf0},
-	{0xF85C, 0xe5},
-	{0xF85D, 0x7d},
-	{0xF85E, 0x70},
-	{0xF85F, 0x10},
-	{0xF860, 0x90},
-	{0xF861, 0x30},
-	{0xF862, 0x05},
-	{0xF863, 0x04},
-	{0xF864, 0xf0},
-	{0xF865, 0x90},
-	{0xF866, 0x30},
-	{0xF867, 0x30},
-	{0xF868, 0xe4},
-	{0xF869, 0xf0},
-	{0xF86A, 0x90},
-	{0xF86B, 0x30},
-	{0xF86C, 0x35},
-	{0xF86D, 0x04},
-	{0xF86E, 0xf0},
-	{0xF86F, 0x22},
-	{0xF870, 0xe5},
-	{0xF871, 0x7d},
-	{0xF872, 0x64},
-	{0xF873, 0x02},
-	{0xF874, 0x70},
-	{0xF875, 0x2d},
-	{0xF876, 0x90},
-	{0xF877, 0x30},
-	{0xF878, 0x04},
-	{0xF879, 0x74},
-	{0xF87A, 0x34},
-	{0xF87B, 0xf0},
-	{0xF87C, 0xa3},
-	{0xF87D, 0x74},
-	{0xF87E, 0x07},
-	{0xF87F, 0xf0},
-	{0xF880, 0x90},
-	{0xF881, 0x30},
-	{0xF882, 0x10},
-	{0xF883, 0x74},
-	{0xF884, 0x10},
-	{0xF885, 0xf0},
-	{0xF886, 0x90},
-	{0xF887, 0x30},
-	{0xF888, 0x16},
-	{0xF889, 0x74},
-	{0xF88A, 0x1f},
-	{0xF88B, 0xf0},
-	{0xF88C, 0x90},
-	{0xF88D, 0x30},
-	{0xF88E, 0x1a},
-	{0xF88F, 0x74},
-	{0xF890, 0x62},
-	{0xF891, 0xf0},
-	{0xF892, 0x90},
-	{0xF893, 0x30},
-	{0xF894, 0x35},
-	{0xF895, 0x74},
-	{0xF896, 0x04},
-	{0xF897, 0xf0},
-	{0xF898, 0x90},
-	{0xF899, 0x30},
-	{0xF89A, 0x41},
-	{0xF89B, 0x74},
-	{0xF89C, 0x60},
-	{0xF89D, 0xf0},
-	{0xF89E, 0xa3},
-	{0xF89F, 0x74},
-	{0xF8A0, 0x64},
-	{0xF8A1, 0xf0},
-	{0xF8A2, 0x22},
-	{0xF8A3, 0xe5},
-	{0xF8A4, 0x7d},
-	{0xF8A5, 0xb4},
-	{0xF8A6, 0x03},
-	{0xF8A7, 0x12},
-	{0xF8A8, 0x90},
-	{0xF8A9, 0x30},
-	{0xF8AA, 0x05},
-	{0xF8AB, 0x74},
-	{0xF8AC, 0x03},
-	{0xF8AD, 0xf0},
-	{0xF8AE, 0x90},
-	{0xF8AF, 0x30},
-	{0xF8B0, 0x11},
-	{0xF8B1, 0x74},
-	{0xF8B2, 0x01},
-	{0xF8B3, 0xf0},
-	{0xF8B4, 0x90},
-	{0xF8B5, 0x30},
-	{0xF8B6, 0x35},
-	{0xF8B7, 0x74},
-	{0xF8B8, 0x03},
-	{0xF8B9, 0xf0},
-	{0xF8BA, 0x22},
-	{0xF8BB, 0xc3},
-	{0xF8BC, 0x90},
-	{0xF8BD, 0x0b},
-	{0xF8BE, 0x89},
-	{0xF8BF, 0xe0},
-	{0xF8C0, 0x94},
-	{0xF8C1, 0x1e},
-	{0xF8C2, 0x90},
-	{0xF8C3, 0x0b},
-	{0xF8C4, 0x88},
-	{0xF8C5, 0xe0},
-	{0xF8C6, 0x94},
-	{0xF8C7, 0x00},
-	{0xF8C8, 0x50},
-	{0xF8C9, 0x06},
-	{0xF8CA, 0x7e},
-	{0xF8CB, 0x00},
-	{0xF8CC, 0x7f},
-	{0xF8CD, 0x01},
-	{0xF8CE, 0x80},
-	{0xF8CF, 0x3d},
-	{0xF8D0, 0xc3},
-	{0xF8D1, 0x90},
-	{0xF8D2, 0x0b},
-	{0xF8D3, 0x89},
-	{0xF8D4, 0xe0},
-	{0xF8D5, 0x94},
-	{0xF8D6, 0x3c},
-	{0xF8D7, 0x90},
-	{0xF8D8, 0x0b},
-	{0xF8D9, 0x88},
-	{0xF8DA, 0xe0},
-	{0xF8DB, 0x94},
-	{0xF8DC, 0x00},
-	{0xF8DD, 0x50},
-	{0xF8DE, 0x06},
-	{0xF8DF, 0x7e},
-	{0xF8E0, 0x00},
-	{0xF8E1, 0x7f},
-	{0xF8E2, 0x02},
-	{0xF8E3, 0x80},
-	{0xF8E4, 0x28},
-	{0xF8E5, 0xc3},
-	{0xF8E6, 0x90},
-	{0xF8E7, 0x0b},
-	{0xF8E8, 0x89},
-	{0xF8E9, 0xe0},
-	{0xF8EA, 0x94},
-	{0xF8EB, 0xfa},
-	{0xF8EC, 0x90},
-	{0xF8ED, 0x0b},
-	{0xF8EE, 0x88},
-	{0xF8EF, 0xe0},
-	{0xF8F0, 0x94},
-	{0xF8F1, 0x00},
-	{0xF8F2, 0x50},
-	{0xF8F3, 0x06},
-	{0xF8F4, 0x7e},
-	{0xF8F5, 0x00},
-	{0xF8F6, 0x7f},
-	{0xF8F7, 0x03},
-	{0xF8F8, 0x80},
-	{0xF8F9, 0x13},
-	{0xF8FA, 0xc3},
-	{0xF8FB, 0x90},
-	{0xF8FC, 0x0b},
-	{0xF8FD, 0x88},
-	{0xF8FE, 0xe0},
-	{0xF8FF, 0x94},
-	{0xF900, 0x80},
-	{0xF901, 0x50},
-	{0xF902, 0x06},
-	{0xF903, 0x7e},
-	{0xF904, 0x00},
-	{0xF905, 0x7f},
-	{0xF906, 0x04},
-	{0xF907, 0x80},
-	{0xF908, 0x04},
-	{0xF909, 0xae},
-	{0xF90A, 0x7e},
-	{0xF90B, 0xaf},
-	{0xF90C, 0x7f},
-	{0xF90D, 0x90},
-	{0xF90E, 0xa0},
-	{0xF90F, 0xf8},
-	{0xF910, 0xee},
-	{0xF911, 0xf0},
-	{0xF912, 0xa3},
-	{0xF913, 0xef},
-	{0xF914, 0xf0},
-	{0xF915, 0x22},
-	{0xF916, 0x90},
-	{0xF917, 0x33},
-	{0xF918, 0x82},
-	{0xF919, 0xe0},
-	{0xF91A, 0xff},
-	{0xF91B, 0x64},
-	{0xF91C, 0x01},
-	{0xF91D, 0x70},
-	{0xF91E, 0x30},
-	{0xF91F, 0xe5},
-	{0xF920, 0x7f},
-	{0xF921, 0x64},
-	{0xF922, 0x02},
-	{0xF923, 0x45},
-	{0xF924, 0x7e},
-	{0xF925, 0x70},
-	{0xF926, 0x04},
-	{0xF927, 0x7d},
-	{0xF928, 0x1e},
-	{0xF929, 0x80},
-	{0xF92A, 0x1d},
-	{0xF92B, 0xe5},
-	{0xF92C, 0x7f},
-	{0xF92D, 0x64},
-	{0xF92E, 0x03},
-	{0xF92F, 0x45},
-	{0xF930, 0x7e},
-	{0xF931, 0x70},
-	{0xF932, 0x04},
-	{0xF933, 0x7d},
-	{0xF934, 0x3c},
-	{0xF935, 0x80},
-	{0xF936, 0x11},
-	{0xF937, 0xe5},
-	{0xF938, 0x7f},
-	{0xF939, 0x64},
-	{0xF93A, 0x04},
-	{0xF93B, 0x45},
-	{0xF93C, 0x7e},
-	{0xF93D, 0x70},
-	{0xF93E, 0x04},
-	{0xF93F, 0x7d},
-	{0xF940, 0xfa},
-	{0xF941, 0x80},
-	{0xF942, 0x05},
-	{0xF943, 0x90},
-	{0xF944, 0x33},
-	{0xF945, 0x81},
-	{0xF946, 0xe0},
-	{0xF947, 0xfd},
-	{0xF948, 0xae},
-	{0xF949, 0x05},
-	{0xF94A, 0x90},
-	{0xF94B, 0x33},
-	{0xF94C, 0x81},
-	{0xF94D, 0xed},
-	{0xF94E, 0xf0},
-	{0xF94F, 0xef},
-	{0xF950, 0xb4},
-	{0xF951, 0x01},
-	{0xF952, 0x10},
-	{0xF953, 0x90},
-	{0xF954, 0x01},
-	{0xF955, 0x00},
-	{0xF956, 0xe0},
-	{0xF957, 0x60},
-	{0xF958, 0x0a},
-	{0xF959, 0x90},
-	{0xF95A, 0xa1},
-	{0xF95B, 0x10},
-	{0xF95C, 0xe0},
-	{0xF95D, 0xf5},
-	{0xF95E, 0x7e},
-	{0xF95F, 0xa3},
-	{0xF960, 0xe0},
-	{0xF961, 0xf5},
-	{0xF962, 0x7f},
-	{0xF963, 0x22},
-	{0xF964, 0x12},
-	{0xF965, 0x2f},
-	{0xF966, 0x4d},
-	{0xF967, 0x90},
-	{0xF968, 0x35},
-	{0xF969, 0x38},
-	{0xF96A, 0xe0},
-	{0xF96B, 0x70},
-	{0xF96C, 0x05},
-	{0xF96D, 0x12},
-	{0xF96E, 0x00},
-	{0xF96F, 0x0e},
-	{0xF970, 0x80},
-	{0xF971, 0x03},
-	{0xF972, 0x12},
-	{0xF973, 0x07},
-	{0xF974, 0xc9},
-	{0xF975, 0x90},
-	{0xF976, 0x40},
-	{0xF977, 0x06},
-	{0xF978, 0xe0},
-	{0xF979, 0xf4},
-	{0xF97A, 0x54},
-	{0xF97B, 0x02},
-	{0xF97C, 0xff},
-	{0xF97D, 0xe0},
-	{0xF97E, 0x54},
-	{0xF97F, 0x01},
-	{0xF980, 0x4f},
-	{0xF981, 0x90},
-	{0xF982, 0x31},
-	{0xF983, 0x32},
-	{0xF984, 0xf0},
-	{0xF985, 0x90},
-	{0xF986, 0xfa},
-	{0xF987, 0x9d},
-	{0xF988, 0xe0},
-	{0xF989, 0x70},
-	{0xF98A, 0x03},
-	{0xF98B, 0x12},
-	{0xF98C, 0x27},
-	{0xF98D, 0x27},
-	{0xF98E, 0x02},
-	{0xF98F, 0x05},
-	{0xF990, 0xac},
-	{0xF991, 0x22},
-	{0xF992, 0x78},
-	{0xF993, 0x07},
-	{0xF994, 0xe6},
-	{0xF995, 0xf5},
-	{0xF996, 0x7c},
-	{0xF997, 0xe5},
-	{0xF998, 0x7c},
-	{0xF999, 0x60},
-	{0xF99A, 0x1d},
-	{0xF99B, 0x90},
-	{0xF99C, 0x43},
-	{0xF99D, 0x83},
-	{0xF99E, 0xe0},
-	{0xF99F, 0xb4},
-	{0xF9A0, 0x01},
-	{0xF9A1, 0x16},
-	{0xF9A2, 0x90},
-	{0xF9A3, 0x43},
-	{0xF9A4, 0x87},
-	{0xF9A5, 0xe0},
-	{0xF9A6, 0xb4},
-	{0xF9A7, 0x01},
-	{0xF9A8, 0x0f},
-	{0xF9A9, 0x15},
-	{0xF9AA, 0x7c},
-	{0xF9AB, 0x90},
-	{0xF9AC, 0x30},
-	{0xF9AD, 0xa1},
-	{0xF9AE, 0xe5},
-	{0xF9AF, 0x7c},
-	{0xF9B0, 0xf0},
-	{0xF9B1, 0x90},
-	{0xF9B2, 0x30},
-	{0xF9B3, 0xa0},
-	{0xF9B4, 0x74},
-	{0xF9B5, 0x01},
-	{0xF9B6, 0xf0},
-	{0xF9B7, 0x22},
-	{0xF9B8, 0xe4},
-	{0xF9B9, 0x90},
-	{0xF9BA, 0x30},
-	{0xF9BB, 0xa0},
-	{0xF9BC, 0xf0},
-	{0xF9BD, 0x22},
-	{0xF9BE, 0xf0},
-	{0xF9BF, 0xe5},
-	{0xF9C0, 0x3a},
-	{0xF9C1, 0xb4},
-	{0xF9C2, 0x06},
-	{0xF9C3, 0x06},
-	{0xF9C4, 0x63},
-	{0xF9C5, 0x3e},
-	{0xF9C6, 0x02},
-	{0xF9C7, 0x12},
-	{0xF9C8, 0x03},
-	{0xF9C9, 0xea},
-	{0xF9CA, 0x02},
-	{0xF9CB, 0x17},
-	{0xF9CC, 0x4a},
-	{0xF9CD, 0x22},
-	{0x35C9, 0xBB},
-	{0x35CA, 0x01},
-	{0x35CB, 0x16},
-	{0x35CC, 0x01},
-	{0x35CD, 0x64},
-	{0x35CE, 0x01},
-	{0x35CF, 0x92},
-	{0x35D0, 0x01},
-	{0x35D1, 0xBE},
-	{0x35D3, 0xF6},
-	{0x35D5, 0x07},
-	{0x35D7, 0xA3},
-	{0x35DB, 0x02},
-	{0x35DD, 0x06},
-	{0x35DF, 0x1B},
-	{0x35E6, 0x28},
-	{0x35E7, 0x76},
-	{0x35E8, 0x2D},
-	{0x35E9, 0x07},
-	{0x35EA, 0x04},
-	{0x35EB, 0x43},
-	{0x35EC, 0x05},
-	{0x35ED, 0xA9},
-	{0x35EE, 0x2A},
-	{0x35EF, 0x15},
-	{0x35F0, 0x17},
-	{0x35F1, 0x41},
-	{0x35F2, 0x24},
-	{0x35F3, 0x88},
-	{0x35F4, 0x01},
-	{0x35F5, 0x54},
-	{0x35F6, 0x01},
-	{0x35F7, 0x55},
-	{0x35F8, 0x2E},
-	{0x35F9, 0xF2},
-	{0x35FA, 0x06},
-	{0x35FB, 0x02},
-	{0x35FC, 0x06},
-	{0x35FD, 0x03},
-	{0x35FE, 0x06},
-	{0x35FF, 0x04},
-	{0x35C2, 0x1F},
-	{0x35C3, 0xFF},
-	{0x35C4, 0x1F},
-	{0x35C5, 0xC0},
-	{0x35C0, 0x01},
-};
-
-struct vx6953_format {
-	enum v4l2_mbus_pixelcode code;
-	enum v4l2_colorspace colorspace;
-	u16 fmt;
-	u16 order;
-};
-
-static const struct vx6953_format vx6953_cfmts[] = {
-	{
-	.code   = V4L2_MBUS_FMT_YUYV8_2X8,
-	.colorspace = V4L2_COLORSPACE_JPEG,
-	.fmt    = 1,
-	.order    = 0,
-	}
-	/* more can be supported, to be added later */
-};
-
-
-/*=============================================================*/
-
-static int vx6953_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   = 2,
-			.buf   = rxdata,
-		},
-	};
-	if (i2c_transfer(vx6953_client->adapter, msgs, 2) < 0) {
-		CDBG("vx6953_i2c_rxdata failed!\n");
-		return -EIO;
-	}
-	return 0;
-}
-static int32_t vx6953_i2c_txdata(unsigned short saddr,
-				unsigned char *txdata, int length)
-{
-	struct i2c_msg msg[] = {
-		{
-			.addr = saddr,
-			.flags = 0,
-			.len = length,
-			.buf = txdata,
-		 },
-	};
-	if (i2c_transfer(vx6953_client->adapter, msg, 1) < 0) {
-		CDBG("vx6953_i2c_txdata faild 0x%x\n", vx6953_client->addr);
-		return -EIO;
-	}
-
-	return 0;
-}
-
-
-static int32_t vx6953_i2c_read(unsigned short raddr,
-	unsigned short *rdata, int rlen)
-{
-	int32_t rc = 0;
-	unsigned char buf[2];
-	if (!rdata)
-		return -EIO;
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (raddr & 0xFF00) >> 8;
-	buf[1] = (raddr & 0x00FF);
-	rc = vx6953_i2c_rxdata(vx6953_client->addr>>1, buf, rlen);
-	if (rc < 0) {
-		CDBG("vx6953_i2c_read 0x%x failed!\n", raddr);
-		return rc;
-	}
-	*rdata = (rlen == 2 ? buf[0] << 8 | buf[1] : buf[0]);
-	return rc;
-}
-static int32_t vx6953_i2c_write_b_sensor(unsigned short waddr, uint8_t bdata)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[3];
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00) >> 8;
-	buf[1] = (waddr & 0x00FF);
-	buf[2] = bdata;
-	CDBG("i2c_write_b addr = 0x%x, val = 0x%x\n", waddr, bdata);
-	rc = vx6953_i2c_txdata(vx6953_client->addr>>1, buf, 3);
-	if (rc < 0) {
-		CDBG("i2c_write_b failed, addr = 0x%x, val = 0x%x!\n",
-			waddr, bdata);
-	}
-	return rc;
-}
-static int32_t vx6953_i2c_write_seq_sensor(unsigned short waddr,
-	uint8_t *bdata, uint16_t len)
-{
-	int32_t rc = -EFAULT;
-	unsigned char buf[len+2];
-	int i;
-	memset(buf, 0, sizeof(buf));
-	buf[0] = (waddr & 0xFF00) >> 8;
-	buf[1] = (waddr & 0x00FF);
-	for (i = 2; i < len+2; i++)
-		buf[i] = *bdata++;
-	rc = vx6953_i2c_txdata(vx6953_client->addr>>1, buf, len+2);
-	if (rc < 0) {
-		CDBG("i2c_write_b failed, addr = 0x%x, val = 0x%x!\n",
-			 waddr, bdata[0]);
-	}
-	return rc;
-}
-
-static int32_t vx6953_i2c_write_w_table(struct vx6953_i2c_reg_conf const
-					 *reg_conf_tbl, int num)
-{
-	int i;
-	int32_t rc = -EIO;
-	for (i = 0; i < num; i++) {
-		rc = vx6953_i2c_write_b_sensor(reg_conf_tbl->waddr,
-			reg_conf_tbl->wdata);
-		if (rc < 0)
-			break;
-		reg_conf_tbl++;
-	}
-	return rc;
-}
-
-static void vx6953_get_pict_fps(uint16_t fps, uint16_t *pfps)
-{
-	/* input fps is preview fps in Q8 format */
-	uint16_t preview_frame_length_lines, snapshot_frame_length_lines;
-	uint16_t preview_line_length_pck, snapshot_line_length_pck;
-	uint32_t divider, d1, d2;
-	/* Total frame_length_lines and line_length_pck for preview */
-	preview_frame_length_lines = VX6953_QTR_SIZE_HEIGHT +
-		VX6953_VER_QTR_BLK_LINES;
-	preview_line_length_pck = VX6953_QTR_SIZE_WIDTH +
-		VX6953_HRZ_QTR_BLK_PIXELS;
-	/* Total frame_length_lines and line_length_pck for snapshot */
-	snapshot_frame_length_lines = VX6953_FULL_SIZE_HEIGHT +
-		VX6953_VER_FULL_BLK_LINES;
-	snapshot_line_length_pck = VX6953_FULL_SIZE_WIDTH +
-		VX6953_HRZ_FULL_BLK_PIXELS;
-	d1 = preview_frame_length_lines * 0x00000400/
-		snapshot_frame_length_lines;
-	d2 = preview_line_length_pck * 0x00000400/
-		snapshot_line_length_pck;
-	divider = d1 * d2 / 0x400;
-	/*Verify PCLK settings and frame sizes.*/
-	*pfps = (uint16_t) (fps * divider / 0x400);
-	/* 2 is the ratio of no.of snapshot channels
-	to number of preview channels */
-
-}
-
-static uint16_t vx6953_get_prev_lines_pf(void)
-{
-	if (vx6953_ctrl->prev_res == QTR_SIZE)
-		return VX6953_QTR_SIZE_HEIGHT + VX6953_VER_QTR_BLK_LINES;
-	else
-		return VX6953_FULL_SIZE_HEIGHT + VX6953_VER_FULL_BLK_LINES;
-
-}
-
-static uint16_t vx6953_get_prev_pixels_pl(void)
-{
-	if (vx6953_ctrl->prev_res == QTR_SIZE)
-		return VX6953_QTR_SIZE_WIDTH + VX6953_HRZ_QTR_BLK_PIXELS;
-	else
-		return VX6953_FULL_SIZE_WIDTH + VX6953_HRZ_FULL_BLK_PIXELS;
-}
-
-static uint16_t vx6953_get_pict_lines_pf(void)
-{
-		if (vx6953_ctrl->pict_res == QTR_SIZE)
-			return VX6953_QTR_SIZE_HEIGHT +
-				VX6953_VER_QTR_BLK_LINES;
-		else
-			return VX6953_FULL_SIZE_HEIGHT +
-				VX6953_VER_FULL_BLK_LINES;
-}
-
-static uint16_t vx6953_get_pict_pixels_pl(void)
-{
-	if (vx6953_ctrl->pict_res == QTR_SIZE)
-		return VX6953_QTR_SIZE_WIDTH +
-			VX6953_HRZ_QTR_BLK_PIXELS;
-	else
-		return VX6953_FULL_SIZE_WIDTH +
-			VX6953_HRZ_FULL_BLK_PIXELS;
-}
-
-static uint32_t vx6953_get_pict_max_exp_lc(void)
-{
-	if (vx6953_ctrl->pict_res == QTR_SIZE)
-		return (VX6953_QTR_SIZE_HEIGHT +
-			VX6953_VER_QTR_BLK_LINES)*24;
-	else
-		return (VX6953_FULL_SIZE_HEIGHT +
-			VX6953_VER_FULL_BLK_LINES)*24;
-}
-
-static int32_t vx6953_set_fps(struct fps_cfg	*fps)
-{
-	uint16_t total_lines_per_frame;
-	int32_t rc = 0;
-	total_lines_per_frame = (uint16_t)((VX6953_QTR_SIZE_HEIGHT +
-		VX6953_VER_QTR_BLK_LINES) * vx6953_ctrl->fps_divider/0x400);
-	if (vx6953_i2c_write_b_sensor(REG_FRAME_LENGTH_LINES_HI,
-		((total_lines_per_frame & 0xFF00) >> 8)) < 0)
-		return rc;
-	if (vx6953_i2c_write_b_sensor(REG_FRAME_LENGTH_LINES_LO,
-		(total_lines_per_frame & 0x00FF)) < 0)
-		return rc;
-	return rc;
-}
-
-static int32_t vx6953_write_exp_gain(uint16_t gain, uint32_t line)
-{
-	uint16_t line_length_pck, frame_length_lines;
-	uint8_t gain_hi, gain_lo;
-	uint8_t intg_time_hi, intg_time_lo;
-	uint8_t line_length_pck_hi = 0, line_length_pck_lo = 0;
-	uint16_t line_length_ratio = 1 * Q8;
-	int32_t rc = 0;
-	if (vx6953_ctrl->sensormode != SENSOR_SNAPSHOT_MODE) {
-		frame_length_lines = VX6953_QTR_SIZE_HEIGHT +
-		VX6953_VER_QTR_BLK_LINES;
-		line_length_pck = VX6953_QTR_SIZE_WIDTH +
-			VX6953_HRZ_QTR_BLK_PIXELS;
-		if (line > (frame_length_lines -
-			VX6953_STM5M0EDOF_OFFSET)) {
-			vx6953_ctrl->fps = (uint16_t) (30 * Q8 *
-			(frame_length_lines - VX6953_STM5M0EDOF_OFFSET)/
-			line);
-		} else {
-			vx6953_ctrl->fps = (uint16_t) (30 * Q8);
-		}
-	} else {
-		frame_length_lines = VX6953_FULL_SIZE_HEIGHT +
-				VX6953_VER_FULL_BLK_LINES;
-		line_length_pck = VX6953_FULL_SIZE_WIDTH +
-				VX6953_HRZ_FULL_BLK_PIXELS;
-	}
-	/* calculate line_length_ratio */
-	if ((frame_length_lines - VX6953_STM5M0EDOF_OFFSET) < line) {
-		line_length_ratio = (line*Q8) /
-			(frame_length_lines - VX6953_STM5M0EDOF_OFFSET);
-		line = frame_length_lines - VX6953_STM5M0EDOF_OFFSET;
-	} else {
-		line_length_ratio = 1*Q8;
-	}
-	vx6953_i2c_write_b_sensor(REG_GROUPED_PARAMETER_HOLD,
-		GROUPED_PARAMETER_HOLD);
-	line_length_pck = (line_length_pck >
-		MAX_LINE_LENGTH_PCK) ?
-		MAX_LINE_LENGTH_PCK : line_length_pck;
-	line_length_pck = (uint16_t) (line_length_pck *
-		line_length_ratio/Q8);
-	line_length_pck_hi = (uint8_t) ((line_length_pck &
-		0xFF00) >> 8);
-	line_length_pck_lo = (uint8_t) (line_length_pck &
-		0x00FF);
-	vx6953_i2c_write_b_sensor(REG_LINE_LENGTH_PCK_HI,
-		line_length_pck_hi);
-	vx6953_i2c_write_b_sensor(REG_LINE_LENGTH_PCK_LO,
-		line_length_pck_lo);
-	/* update analogue gain registers */
-	gain_hi = (uint8_t) ((gain & 0xFF00) >> 8);
-	gain_lo = (uint8_t) (gain & 0x00FF);
-	vx6953_i2c_write_b_sensor(REG_ANALOGUE_GAIN_CODE_GLOBAL_LO,
-		gain_lo);
-	vx6953_i2c_write_b_sensor(REG_DIGITAL_GAIN_GREEN_R_LO, gain_hi);
-	vx6953_i2c_write_b_sensor(REG_DIGITAL_GAIN_RED_LO, gain_hi);
-	vx6953_i2c_write_b_sensor(REG_DIGITAL_GAIN_BLUE_LO, gain_hi);
-	vx6953_i2c_write_b_sensor(REG_DIGITAL_GAIN_GREEN_B_LO, gain_hi);
-	CDBG("%s, gain_hi 0x%x, gain_lo 0x%x\n", __func__,
-		gain_hi, gain_lo);
-	/* update line count registers */
-	intg_time_hi = (uint8_t) (((uint16_t)line & 0xFF00) >> 8);
-	intg_time_lo = (uint8_t) ((uint16_t)line & 0x00FF);
-	vx6953_i2c_write_b_sensor(REG_COARSE_INTEGRATION_TIME_HI,
-		intg_time_hi);
-	vx6953_i2c_write_b_sensor(REG_COARSE_INTEGRATION_TIME_LO,
-		intg_time_lo);
-	vx6953_i2c_write_b_sensor(REG_GROUPED_PARAMETER_HOLD,
-		GROUPED_PARAMETER_HOLD_OFF);
-
-	return rc;
-}
-
-static int32_t vx6953_set_pict_exp_gain(uint16_t gain, uint32_t line)
-{
-	int32_t rc = 0;
-	rc = vx6953_write_exp_gain(gain, line);
-	return rc;
-} /* endof vx6953_set_pict_exp_gain*/
-
-static int32_t vx6953_move_focus(int direction,
-	int32_t num_steps)
-{
-	return 0;
-}
-
-
-static int32_t vx6953_set_default_focus(uint8_t af_step)
-{
-	return 0;
-}
-
-static int32_t vx6953_test(enum vx6953_test_mode_t mo)
-{
-	int32_t rc = 0;
-	if (mo == TEST_OFF)
-		return rc;
-	else {
-		/* REG_0x30D8[4] is TESBYPEN: 0: Normal Operation,
-		1: Bypass Signal Processing
-		REG_0x30D8[5] is EBDMASK: 0:
-		Output Embedded data, 1: No output embedded data */
-		if (vx6953_i2c_write_b_sensor(REG_TEST_PATTERN_MODE,
-			(uint8_t) mo) < 0) {
-			return rc;
-		}
-	}
-	return rc;
-}
-
-static int vx6953_enable_edof(enum edof_mode_t edof_mode)
-{
-	int rc = 0;
-	if (edof_mode == VX6953_EDOF_ESTIMATION) {
-		/* EDof Estimation mode for preview */
-		if (vx6953_i2c_write_b_sensor(REG_0x0b80, 0x02) < 0)
-			return rc;
-		CDBG("VX6953_EDOF_ESTIMATION");
-	} else if (edof_mode == VX6953_EDOF_APPLICATION) {
-		/* EDof Application mode for Capture */
-		if (vx6953_i2c_write_b_sensor(REG_0x0b80, 0x01) < 0)
-			return rc;
-		CDBG("VX6953_EDOF_APPLICATION");
-	} else {
-		/* EDOF disabled */
-		if (vx6953_i2c_write_b_sensor(REG_0x0b80, 0x00) < 0)
-			return rc;
-		CDBG("VX6953_EDOF_DISABLE");
-	}
-	return rc;
-}
-
-static int32_t vx6953_patch_for_cut2(void)
-{
-	int32_t rc = 0;
-	rc = vx6953_i2c_write_w_table(patch_tbl_cut2,
-		ARRAY_SIZE(patch_tbl_cut2));
-	if (rc < 0)
-		return rc;
-
-	return rc;
-}
-static int32_t vx6953_patch_for_cut3(void)
-{
-	int32_t rc = 0;
-	rc = vx6953_i2c_write_w_table(patch_tbl_cut3,
-		ARRAY_SIZE(patch_tbl_cut3));
-	if (rc < 0)
-		return rc;
-
-	return rc;
-}
-static int32_t vx6953_sensor_setting(int update_type, int rt)
-{
-
-	int32_t rc = 0;
-	unsigned short frame_cnt;
-	struct msm_camera_csi_params vx6953_csi_params;
-	if (vx6953_ctrl->sensor_type != VX6953_STM5M0EDOF_CUT_2) {
-		switch (update_type) {
-		case REG_INIT:
-		if (rt == RES_PREVIEW || rt == RES_CAPTURE) {
-			struct vx6953_i2c_reg_conf init_tbl[] = {
-			{REG_0x0112,
-				vx6953_regs.reg_pat_init[0].reg_0x0112},
-			{0x6003, 0x01},
-			{REG_0x0113,
-				vx6953_regs.reg_pat_init[0].reg_0x0113},
-			{REG_VT_PIX_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				vt_pix_clk_div},
-			{REG_PRE_PLL_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				pre_pll_clk_div},
-			{REG_PLL_MULTIPLIER,
-				vx6953_regs.reg_pat_init[0].
-				pll_multiplier},
-			{REG_OP_PIX_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				op_pix_clk_div},
-			{REG_COARSE_INTEGRATION_TIME_HI,
-				vx6953_regs.reg_pat[rt].
-				coarse_integration_time_hi},
-			{REG_COARSE_INTEGRATION_TIME_LO,
-				vx6953_regs.reg_pat[rt].
-				coarse_integration_time_lo},
-			{REG_ANALOGUE_GAIN_CODE_GLOBAL_LO,
-				vx6953_regs.reg_pat[rt].
-				analogue_gain_code_global},
-			{REG_0x3030,
-				vx6953_regs.reg_pat_init[0].reg_0x3030},
-			/* 953 specific registers */
-			{REG_0x0111,
-				vx6953_regs.reg_pat_init[0].reg_0x0111},
-			{REG_0x0b00,
-				vx6953_regs.reg_pat_init[0].reg_0x0b00},
-			{REG_0x3001,
-				vx6953_regs.reg_pat_init[0].reg_0x3001},
-			{REG_0x3004,
-				vx6953_regs.reg_pat_init[0].reg_0x3004},
-			{0x3006, 0x00},
-			{REG_0x3007,
-				vx6953_regs.reg_pat_init[0].reg_0x3007},
-			{0x301b, 0x29},
-			/* DEFCOR settings */
-			/*Single Defect Correction Weight DISABLE*/
-			{0x0b06,
-				vx6953_regs.reg_pat_init[0].reg_0x0b06},
-			/*Single_defect_correct_weight = auto*/
-			{0x0b07,
-				vx6953_regs.reg_pat_init[0].reg_0x0b07},
-			/*Dynamic couplet correction ENABLED*/
-			{0x0b08,
-				vx6953_regs.reg_pat_init[0].reg_0x0b08},
-			/*Dynamic couplet correction weight*/
-			{0x0b09,
-				vx6953_regs.reg_pat_init[0].reg_0x0b09},
-			/* Clock Setup */
-			/* Tell sensor ext clk is 24MHz*/
-			{REG_0x0136,
-				vx6953_regs.reg_pat_init[0].reg_0x0136},
-			{REG_0x0137,
-				vx6953_regs.reg_pat_init[0].reg_0x0137},
-			/* The white balance gains must be written
-			to the sensor every frame. */
-			/* Edof */
-			{REG_0x0b83,
-				vx6953_regs.reg_pat_init[0].reg_0x0b83},
-			{REG_0x0b84,
-				vx6953_regs.reg_pat_init[0].reg_0x0b84},
-			{REG_0x0b85,
-				vx6953_regs.reg_pat_init[0].reg_0x0b85},
-			{REG_0x0b88,
-				vx6953_regs.reg_pat_init[0].reg_0x0b88},
-			{REG_0x0b89,
-				vx6953_regs.reg_pat_init[0].reg_0x0b89},
-			{REG_0x0b8a,
-				vx6953_regs.reg_pat_init[0].reg_0x0b8a},
-			/* Mode specific regieters */
-			{REG_FRAME_LENGTH_LINES_HI,
-				vx6953_regs.reg_pat[rt].
-				frame_length_lines_hi},
-			{REG_FRAME_LENGTH_LINES_LO,
-				vx6953_regs.reg_pat[rt].
-				frame_length_lines_lo},
-			{REG_LINE_LENGTH_PCK_HI,
-				vx6953_regs.reg_pat[rt].
-				line_length_pck_hi},
-			{REG_LINE_LENGTH_PCK_LO,
-				vx6953_regs.reg_pat[rt].
-				line_length_pck_lo},
-			{REG_0x3005,
-				vx6953_regs.reg_pat[rt].reg_0x3005},
-			{0x3010,
-				vx6953_regs.reg_pat[rt].reg_0x3010},
-			{REG_0x3011,
-				vx6953_regs.reg_pat[rt].reg_0x3011},
-			{REG_0x301a,
-				vx6953_regs.reg_pat[rt].reg_0x301a},
-			{REG_0x3035,
-				vx6953_regs.reg_pat[rt].reg_0x3035},
-			{REG_0x3036,
-				vx6953_regs.reg_pat[rt].reg_0x3036},
-			{REG_0x3041,
-				vx6953_regs.reg_pat[rt].reg_0x3041},
-			{0x3042,
-				vx6953_regs.reg_pat[rt].reg_0x3042},
-			{REG_0x3045,
-				vx6953_regs.reg_pat[rt].reg_0x3045},
-			/*EDOF: Estimation settings for Preview mode
-			Application settings for capture mode
-			(standard settings - Not tuned) */
-			{REG_0x0b80,
-				vx6953_regs.reg_pat[rt].reg_0x0b80},
-			{REG_0x0900,
-				vx6953_regs.reg_pat[rt].reg_0x0900},
-			{REG_0x0901,
-				vx6953_regs.reg_pat[rt].reg_0x0901},
-			{REG_0x0902,
-				vx6953_regs.reg_pat[rt].reg_0x0902},
-			{REG_0x0383,
-				vx6953_regs.reg_pat[rt].reg_0x0383},
-			{REG_0x0387,
-				vx6953_regs.reg_pat[rt].reg_0x0387},
-			/* Change output size / frame rate */
-			{REG_0x034c,
-				vx6953_regs.reg_pat[rt].reg_0x034c},
-			{REG_0x034d,
-				vx6953_regs.reg_pat[rt].reg_0x034d},
-			{REG_0x034e,
-				vx6953_regs.reg_pat[rt].reg_0x034e},
-			{REG_0x034f,
-				vx6953_regs.reg_pat[rt].reg_0x034f},
-			};
-			/* reset fps_divider */
-			vx6953_ctrl->fps = 30 * Q8;
-			/* stop streaming */
-
-			/* Reset everything first */
-			if (vx6953_i2c_write_b_sensor(0x103, 0x01) < 0) {
-				CDBG("S/W reset failed\n");
-				return rc;
-			} else
-				CDBG("S/W reset successful\n");
-
-			msleep(10);
-
-			CDBG("Init vx6953_sensor_setting standby\n");
-			if (vx6953_i2c_write_b_sensor(REG_MODE_SELECT,
-				MODE_SELECT_STANDBY_MODE) < 0)
-				return rc;
-			/*vx6953_stm5m0edof_delay_msecs_stdby*/
-			msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-
-
-
-			vx6953_patch_for_cut3();
-			rc = vx6953_i2c_write_w_table(&init_tbl[0],
-				ARRAY_SIZE(init_tbl));
-			if (rc < 0)
-				return rc;
-
-			msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-
-			vx6953_i2c_write_b_sensor(0x0b80, 0x00);
-			vx6953_i2c_write_b_sensor(0x3388, 0x03);
-			vx6953_i2c_write_b_sensor(0x3640, 0x00);
-
-			rc = vx6953_i2c_write_w_table(&edof_tbl[0],
-				ARRAY_SIZE(edof_tbl));
-			vx6953_i2c_write_b_sensor(0x3388, 0x00);
-
-		}
-		return rc;
-		case UPDATE_PERIODIC:
-		if (rt == RES_PREVIEW || rt == RES_CAPTURE) {
-			struct vx6953_i2c_reg_conf preview_mode_tbl[] = {
-			{REG_0x0112,
-				vx6953_regs.reg_pat_init[0].reg_0x0112},
-			{0x6003, 0x01},
-			{REG_0x0113,
-				vx6953_regs.reg_pat_init[0].reg_0x0113},
-			{REG_VT_PIX_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				vt_pix_clk_div},
-			{REG_PRE_PLL_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				pre_pll_clk_div},
-			{REG_PLL_MULTIPLIER,
-				vx6953_regs.reg_pat_init[0].
-				pll_multiplier},
-			{REG_OP_PIX_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				op_pix_clk_div},
-
-			{REG_COARSE_INTEGRATION_TIME_HI,
-				vx6953_regs.reg_pat[rt].
-				coarse_integration_time_hi},
-			{REG_COARSE_INTEGRATION_TIME_LO,
-				vx6953_regs.reg_pat[rt].
-				coarse_integration_time_lo},
-			{REG_ANALOGUE_GAIN_CODE_GLOBAL_LO,
-				vx6953_regs.reg_pat[rt].
-				analogue_gain_code_global},
-
-			{REG_0x3210, vx6953_regs.reg_pat[rt].reg_0x3210},
-			{REG_0x0111, vx6953_regs.reg_pat[rt].reg_0x111},
-			{REG_0x3410, vx6953_regs.reg_pat[rt].reg_0x3410},
-
-			{REG_0x3004,
-				vx6953_regs.reg_pat_init[0].reg_0x3004},
-			{REG_0x3006, 0x00},
-			{REG_0x3007,
-				vx6953_regs.reg_pat_init[0].reg_0x3007},
-			{REG_0x301b, 0x29},
-			{REG_0x3036,
-				vx6953_regs.reg_pat[rt].reg_0x3036},
-			{REG_0x3045, vx6953_regs.reg_pat[rt].reg_0x3045},
-			{REG_0x3098, vx6953_regs.reg_pat[rt].reg_0x3098},
-			{REG_0x309d, vx6953_regs.reg_pat[rt].reg_0x309D},
-
-			{REG_0x0900, vx6953_regs.reg_pat[rt].reg_0x0900},
-			{REG_0x0901, vx6953_regs.reg_pat[rt].reg_0x0901},
-			{REG_0x0902, vx6953_regs.reg_pat[rt].reg_0x0902},
-			{REG_0x0383, vx6953_regs.reg_pat[rt].reg_0x0383},
-			{REG_0x0387, vx6953_regs.reg_pat[rt].reg_0x0387},
-
-			{REG_FRAME_LENGTH_LINES_HI,
-				vx6953_regs.reg_pat[rt].
-				frame_length_lines_hi},
-			{REG_FRAME_LENGTH_LINES_LO,
-				vx6953_regs.reg_pat[rt].
-				frame_length_lines_lo},
-			{REG_LINE_LENGTH_PCK_HI,
-				vx6953_regs.reg_pat[rt].
-				line_length_pck_hi},
-			{REG_LINE_LENGTH_PCK_LO,
-				vx6953_regs.reg_pat[rt].
-				line_length_pck_lo},
-			{REG_0x034c,
-				vx6953_regs.reg_pat[rt].reg_0x034c},
-			{REG_0x034d,
-				vx6953_regs.reg_pat[rt].reg_0x034d},
-			{REG_0x034e,
-				vx6953_regs.reg_pat[rt].reg_0x034e},
-			{REG_0x034f,
-				vx6953_regs.reg_pat[rt].reg_0x034f},
-
-			{REG_0x3005, vx6953_regs.reg_pat[rt].reg_0x3005},
-			{REG_0x3010, vx6953_regs.reg_pat[rt].reg_0x3010},
-			{REG_0x3011, vx6953_regs.reg_pat[rt].reg_0x3011},
-			{REG_0x301a, vx6953_regs.reg_pat[rt].reg_0x301a},
-			{REG_0x3030, 0x08},
-			{REG_0x3035, vx6953_regs.reg_pat[rt].reg_0x3035},
-			{REG_0x3041, vx6953_regs.reg_pat[rt].reg_0x3041},
-			{0x3042, vx6953_regs.reg_pat[rt].reg_0x3042},
-
-			{0x200, vx6953_regs.reg_pat[rt].reg_0x0200},
-			{0x201, vx6953_regs.reg_pat[rt].reg_0x0201},
-
-			{0x0b06,
-				vx6953_regs.reg_pat_init[0].reg_0x0b06},
-			/*Single_defect_correct_weight = auto*/
-			{0x0b07,
-				vx6953_regs.reg_pat_init[0].reg_0x0b07},
-			/*Dynamic couplet correction ENABLED*/
-			{0x0b08,
-				vx6953_regs.reg_pat_init[0].reg_0x0b08},
-			/*Dynamic couplet correction weight*/
-			{0x0b09,
-				vx6953_regs.reg_pat_init[0].reg_0x0b09},
-
-			{REG_0x0136,
-				vx6953_regs.reg_pat_init[0].reg_0x0136},
-			{REG_0x0137,
-				vx6953_regs.reg_pat_init[0].reg_0x0137},
-
-			/*EDOF: Estimation settings for Preview mode
-			Application settings for capture
-			mode(standard settings - Not tuned) */
-			{REG_0x0b80, vx6953_regs.reg_pat[rt].reg_0x0b80},
-			{REG_0x0b83,
-				vx6953_regs.reg_pat_init[0].reg_0x0b83},
-			{REG_0x0b84,
-				vx6953_regs.reg_pat_init[0].reg_0x0b84},
-			{REG_0x0b85,
-				vx6953_regs.reg_pat_init[0].reg_0x0b85},
-			{REG_0x0b88,
-				vx6953_regs.reg_pat_init[0].reg_0x0b88},
-			{REG_0x0b89,
-				vx6953_regs.reg_pat_init[0].reg_0x0b89},
-			{REG_0x0b8a,
-				vx6953_regs.reg_pat_init[0].reg_0x0b8a},
-			{0x3393, 0x06}, /* man_spec_edof_ctrl_edof*/
-			{0x3394, 0x07}, /* man_spec_edof_ctrl_edof*/
-			};
-
-			struct vx6953_i2c_reg_conf snapshot_mode_tbl[] = {
-			{REG_MODE_SELECT,	MODE_SELECT_STANDBY_MODE},
-			{REG_0x0112,
-				vx6953_regs.reg_pat_init[0].reg_0x0112},
-			{0x6003, 0x01},
-			{REG_0x0113,
-				vx6953_regs.reg_pat_init[0].reg_0x0113},
-			{REG_VT_PIX_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				vt_pix_clk_div},
-			{0x303,	1}, /* VT_SYS_CLK_DIV */
-			{REG_PRE_PLL_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				pre_pll_clk_div},
-			{REG_PLL_MULTIPLIER,
-				vx6953_regs.reg_pat_init[0].
-				pll_multiplier},
-			{REG_OP_PIX_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				op_pix_clk_div},
-			{0x30b,	1},
-			{REG_COARSE_INTEGRATION_TIME_HI,
-				vx6953_regs.reg_pat[rt].
-				coarse_integration_time_hi},
-			{REG_COARSE_INTEGRATION_TIME_LO,
-				vx6953_regs.reg_pat[rt].
-				coarse_integration_time_lo},
-			{REG_ANALOGUE_GAIN_CODE_GLOBAL_LO,
-				vx6953_regs.reg_pat[rt].
-				analogue_gain_code_global},
-			{REG_LINE_LENGTH_PCK_HI,
-				vx6953_regs.reg_pat[rt].
-				line_length_pck_hi},
-			{REG_LINE_LENGTH_PCK_LO,
-				vx6953_regs.reg_pat[rt].
-				line_length_pck_lo},
-			{REG_FRAME_LENGTH_LINES_HI,
-				vx6953_regs.reg_pat[rt].
-				frame_length_lines_hi},
-			{REG_FRAME_LENGTH_LINES_LO,
-				vx6953_regs.reg_pat[rt].
-				frame_length_lines_lo},
-			{REG_0x3210, vx6953_regs.reg_pat[rt].reg_0x3210},
-			{REG_0x0111, vx6953_regs.reg_pat[rt].reg_0x111},
-
-			{REG_0x0b00,
-				vx6953_regs.reg_pat_init[0].reg_0x0b00},
-			{0x3140, 0x01},  /* AV2X2 block enabled */
-			{REG_0x3410, vx6953_regs.reg_pat[rt].reg_0x3410},
-			{0x0b06,
-				vx6953_regs.reg_pat_init[0].reg_0x0b06},
-			/*Single_defect_correct_weight = auto*/
-			{0x0b07,
-				vx6953_regs.reg_pat_init[0].reg_0x0b07},
-			/*Dynamic couplet correction ENABLED*/
-			{0x0b08,
-				vx6953_regs.reg_pat_init[0].reg_0x0b08},
-			/*Dynamic couplet correction weight*/
-			{0x0b09,
-				vx6953_regs.reg_pat_init[0].reg_0x0b09},
-
-
-			{REG_0x3004,
-				vx6953_regs.reg_pat_init[0].reg_0x3004},
-			{REG_0x3006, 0x00},
-			{REG_0x3007,
-				vx6953_regs.reg_pat_init[0].reg_0x3007},
-			{0x301A, 0x6A},
-			{REG_0x301b, 0x29},
-			{REG_0x3036,
-				vx6953_regs.reg_pat[rt].reg_0x3036},
-			{REG_0x3045, vx6953_regs.reg_pat[rt].reg_0x3045},
-			{REG_0x3098, vx6953_regs.reg_pat[rt].reg_0x3098},
-			{REG_0x309d, vx6953_regs.reg_pat[rt].reg_0x309D},
-
-			{REG_0x0136,
-				vx6953_regs.reg_pat_init[0].reg_0x0136},
-			{REG_0x0137,
-				vx6953_regs.reg_pat_init[0].reg_0x0137},
-
-			{REG_0x0b80, vx6953_regs.reg_pat[rt].reg_0x0b80},
-			{REG_0x0b83,
-				vx6953_regs.reg_pat_init[0].reg_0x0b83},
-			{REG_0x0b84,
-				vx6953_regs.reg_pat_init[0].reg_0x0b84},
-			{REG_0x0b85,
-				vx6953_regs.reg_pat_init[0].reg_0x0b85},
-			{REG_0x0b88,
-				vx6953_regs.reg_pat_init[0].reg_0x0b88},
-			{REG_0x0b89,
-				vx6953_regs.reg_pat_init[0].reg_0x0b89},
-			{REG_0x0b8a,
-				vx6953_regs.reg_pat_init[0].reg_0x0b8a},
-			{0x3393, 0x06}, /* man_spec_edof_ctrl*/
-			{0x3394, 0x07}, /* man_spec_edof_ctrl*/
-			};
-			/* stop streaming */
-			msleep(5);
-
-			/* Reset everything first */
-
-			if (vx6953_i2c_write_b_sensor(0x103, 0x01) < 0) {
-				CDBG("S/W reset failed\n");
-				return rc;
-			} else
-				CDBG("S/W reset successful\n");
-
-			msleep(10);
-
-			if (vx6953_i2c_write_b_sensor(REG_MODE_SELECT,
-				MODE_SELECT_STANDBY_MODE) < 0)
-				return rc;
-			/*vx6953_stm5m0edof_delay_msecs_stdby*/
-			msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-
-			vx6953_csi_params.data_format = CSI_8BIT;
-			vx6953_csi_params.lane_cnt = 1;
-			vx6953_csi_params.lane_assign = 0xe4;
-			vx6953_csi_params.dpcm_scheme = 0;
-			vx6953_csi_params.settle_cnt = 7;
-			rc = msm_camio_csi_config(&vx6953_csi_params);
-			if (rc < 0)
-				CDBG(" config csi controller failed\n");
-
-			msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-
-			vx6953_patch_for_cut3();
-
-			msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-
-			if (rt == RES_PREVIEW) {
-				rc = vx6953_i2c_write_w_table(
-					&preview_mode_tbl[0],
-					ARRAY_SIZE(preview_mode_tbl));
-				if (rc < 0)
-					return rc;
-			}
-			if (rt == RES_CAPTURE) {
-				rc = vx6953_i2c_write_w_table(
-					&snapshot_mode_tbl[0],
-					ARRAY_SIZE(snapshot_mode_tbl));
-				if (rc < 0)
-					return rc;
-			}
-			msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-
-			/* Start sensor streaming */
-			if (vx6953_i2c_write_b_sensor(REG_MODE_SELECT,
-				MODE_SELECT_STREAM) < 0)
-				return rc;
-			msleep(vx6953_stm5m0edof_delay_msecs_stream);
-			/* man_spec_edof_ctrl_tune_smooth_lowlight*/
-			vx6953_i2c_write_b_sensor(0x338d, 0x08);
-			/* man_spec_edof_ctrl_tune_smooth_indoor*/
-			vx6953_i2c_write_b_sensor(0x338e, 0x08);
-			/* man_spec_edof_ctrl_tune_smooth_outdoor*/
-			vx6953_i2c_write_b_sensor(0x338f, 0x00);
-			/*Apply Capture FPGA state machine reset*/
-			vx6953_i2c_write_b_sensor(0x16, 0x00);
-			msleep(100);
-			vx6953_i2c_write_b_sensor(0x16, 0x01);
-
-			if (vx6953_i2c_read(0x0005, &frame_cnt, 1) < 0)
-				return rc;
-
-			while (frame_cnt == 0xFF) {
-				if (vx6953_i2c_read(0x0005, &frame_cnt, 1) < 0)
-					return rc;
-				CDBG("frame_cnt=%d", frame_cnt);
-				msleep(10);
-			}
-		}
-		return rc;
-		default:
-			return rc;
-		}
-	} else {
-		switch (update_type) {
-		case REG_INIT:
-		if (rt == RES_PREVIEW || rt == RES_CAPTURE) {
-			struct vx6953_i2c_reg_conf init_tbl[] = {
-			{REG_0x0112,
-				vx6953_regs.reg_pat_init[0].reg_0x0112},
-			{REG_0x0113,
-				vx6953_regs.reg_pat_init[0].reg_0x0113},
-			{REG_VT_PIX_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				vt_pix_clk_div},
-			{REG_PRE_PLL_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				pre_pll_clk_div},
-			{REG_PLL_MULTIPLIER,
-				vx6953_regs.reg_pat_init[0].
-				pll_multiplier},
-			{REG_OP_PIX_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				op_pix_clk_div},
-			{REG_COARSE_INTEGRATION_TIME_HI,
-				vx6953_regs.reg_pat[rt].
-				coarse_integration_time_hi},
-			{REG_COARSE_INTEGRATION_TIME_LO,
-				vx6953_regs.reg_pat[rt].
-				coarse_integration_time_lo},
-			{REG_ANALOGUE_GAIN_CODE_GLOBAL_LO,
-				vx6953_regs.reg_pat[rt].
-				analogue_gain_code_global},
-			{REG_0x3030,
-				vx6953_regs.reg_pat_init[0].reg_0x3030},
-			/* 953 specific registers */
-			{REG_0x0111,
-				vx6953_regs.reg_pat_init[0].reg_0x0111},
-			{REG_0x0b00,
-				vx6953_regs.reg_pat_init[0].reg_0x0b00},
-			{REG_0x3001,
-				vx6953_regs.reg_pat_init[0].reg_0x3001},
-			{REG_0x3004,
-				vx6953_regs.reg_pat_init[0].reg_0x3004},
-			{REG_0x3007,
-				vx6953_regs.reg_pat_init[0].reg_0x3007},
-			{REG_0x3016,
-				vx6953_regs.reg_pat_init[0].reg_0x3016},
-			{REG_0x301d,
-				vx6953_regs.reg_pat_init[0].reg_0x301d},
-			{REG_0x317e,
-				vx6953_regs.reg_pat_init[0].reg_0x317e},
-			{REG_0x317f,
-				vx6953_regs.reg_pat_init[0].reg_0x317f},
-			{REG_0x3400,
-				vx6953_regs.reg_pat_init[0].reg_0x3400},
-			/* DEFCOR settings */
-			/*Single Defect Correction Weight DISABLE*/
-			{0x0b06,
-				vx6953_regs.reg_pat_init[0].reg_0x0b06},
-			/*Single_defect_correct_weight = auto*/
-			{0x0b07,
-				vx6953_regs.reg_pat_init[0].reg_0x0b07},
-			/*Dynamic couplet correction ENABLED*/
-			{0x0b08,
-				vx6953_regs.reg_pat_init[0].reg_0x0b08},
-			/*Dynamic couplet correction weight*/
-			{0x0b09,
-				vx6953_regs.reg_pat_init[0].reg_0x0b09},
-			/* Clock Setup */
-			/* Tell sensor ext clk is 24MHz*/
-			{0x0136,
-				vx6953_regs.reg_pat_init[0].reg_0x0136},
-			{0x0137,
-				vx6953_regs.reg_pat_init[0].reg_0x0137},
-			/* The white balance gains must be written
-			to the sensor every frame. */
-			/* Edof */
-			{REG_0x0b83,
-				vx6953_regs.reg_pat_init[0].reg_0x0b83},
-			{REG_0x0b84,
-				vx6953_regs.reg_pat_init[0].reg_0x0b84},
-			{0x0b85,
-				vx6953_regs.reg_pat_init[0].reg_0x0b85},
-			{0x0b88,
-				vx6953_regs.reg_pat_init[0].reg_0x0b88},
-			{0x0b89,
-				vx6953_regs.reg_pat_init[0].reg_0x0b89},
-			{REG_0x0b8a,
-				vx6953_regs.reg_pat_init[0].reg_0x0b8a},
-			/* Mode specific regieters */
-			{REG_FRAME_LENGTH_LINES_HI,
-				vx6953_regs.reg_pat[rt].
-				frame_length_lines_hi},
-			{REG_FRAME_LENGTH_LINES_LO,
-				vx6953_regs.reg_pat[rt].
-				frame_length_lines_lo},
-			{REG_LINE_LENGTH_PCK_HI,
-				vx6953_regs.reg_pat[rt].
-				line_length_pck_hi},
-			{REG_LINE_LENGTH_PCK_LO,
-				vx6953_regs.reg_pat[rt].
-				line_length_pck_lo},
-			{REG_0x3005,
-				vx6953_regs.reg_pat[rt].reg_0x3005},
-			{0x3010,
-				vx6953_regs.reg_pat[rt].reg_0x3010},
-			{REG_0x3011,
-				vx6953_regs.reg_pat[rt].reg_0x3011},
-			{REG_0x301a,
-				vx6953_regs.reg_pat[rt].reg_0x301a},
-			{REG_0x3035,
-				vx6953_regs.reg_pat[rt].reg_0x3035},
-			{REG_0x3036,
-				vx6953_regs.reg_pat[rt].reg_0x3036},
-			{REG_0x3041,
-				vx6953_regs.reg_pat[rt].reg_0x3041},
-			{0x3042,
-				vx6953_regs.reg_pat[rt].reg_0x3042},
-			{REG_0x3045,
-				vx6953_regs.reg_pat[rt].reg_0x3045},
-			/*EDOF: Estimation settings for Preview mode
-			Application settings for capture mode
-			(standard settings - Not tuned) */
-			{REG_0x0b80,
-				vx6953_regs.reg_pat[rt].reg_0x0b80},
-			{REG_0x0900,
-				vx6953_regs.reg_pat[rt].reg_0x0900},
-			{REG_0x0901,
-				vx6953_regs.reg_pat[rt].reg_0x0901},
-			{REG_0x0902,
-				vx6953_regs.reg_pat[rt].reg_0x0902},
-			{REG_0x0383,
-				vx6953_regs.reg_pat[rt].reg_0x0383},
-			{REG_0x0387,
-				vx6953_regs.reg_pat[rt].reg_0x0387},
-			/* Change output size / frame rate */
-			{REG_0x034c,
-				vx6953_regs.reg_pat[rt].reg_0x034c},
-			{REG_0x034d,
-				vx6953_regs.reg_pat[rt].reg_0x034d},
-			{REG_0x034e,
-				vx6953_regs.reg_pat[rt].reg_0x034e},
-			{REG_0x034f,
-				vx6953_regs.reg_pat[rt].reg_0x034f},
-			{REG_0x1716,
-				vx6953_regs.reg_pat[rt].reg_0x1716},
-			{REG_0x1717,
-				vx6953_regs.reg_pat[rt].reg_0x1717},
-			{REG_0x1718,
-				vx6953_regs.reg_pat[rt].reg_0x1718},
-			{REG_0x1719,
-				vx6953_regs.reg_pat[rt].reg_0x1719},
-			};
-			/* reset fps_divider */
-			vx6953_ctrl->fps = 30 * Q8;
-			/* stop streaming */
-
-			/* Reset everything first */
-			if (vx6953_i2c_write_b_sensor(0x103, 0x01) < 0) {
-				CDBG("S/W reset failed\n");
-				return rc;
-			} else
-				CDBG("S/W reset successful\n");
-
-			msleep(10);
-
-			CDBG("Init vx6953_sensor_setting standby\n");
-			if (vx6953_i2c_write_b_sensor(REG_MODE_SELECT,
-				MODE_SELECT_STANDBY_MODE) < 0)
-				return rc;
-				/*vx6953_stm5m0edof_delay_msecs_stdby*/
-			msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-			vx6953_patch_for_cut2();
-			rc = vx6953_i2c_write_w_table(&init_tbl[0],
-				ARRAY_SIZE(init_tbl));
-			if (rc < 0)
-				return rc;
-				msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-		}
-		return rc;
-		case UPDATE_PERIODIC:
-		if (rt == RES_PREVIEW || rt == RES_CAPTURE) {
-			struct vx6953_i2c_reg_conf init_mode_tbl[] =  {
-			{REG_0x0112,
-				vx6953_regs.reg_pat_init[0].reg_0x0112},
-			{REG_0x0113,
-				vx6953_regs.reg_pat_init[0].reg_0x0113},
-			{REG_VT_PIX_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				vt_pix_clk_div},
-			{REG_PRE_PLL_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				pre_pll_clk_div},
-			{REG_PLL_MULTIPLIER,
-				vx6953_regs.reg_pat_init[0].
-				pll_multiplier},
-			{REG_OP_PIX_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				op_pix_clk_div},
-			{REG_COARSE_INTEGRATION_TIME_HI,
-				vx6953_regs.reg_pat[rt].
-				coarse_integration_time_hi},
-			{REG_COARSE_INTEGRATION_TIME_LO,
-				vx6953_regs.reg_pat[rt].
-				coarse_integration_time_lo},
-			{REG_ANALOGUE_GAIN_CODE_GLOBAL_LO,
-				vx6953_regs.reg_pat[rt].
-				analogue_gain_code_global},
-			{REG_0x3030,
-				vx6953_regs.reg_pat_init[0].reg_0x3030},
-			/* 953 specific registers */
-			{REG_0x0111,
-				vx6953_regs.reg_pat_init[0].reg_0x0111},
-			{REG_0x0b00,
-				vx6953_regs.reg_pat_init[0].reg_0x0b00},
-			{REG_0x3001,
-				vx6953_regs.reg_pat_init[0].reg_0x3001},
-			{REG_0x3004,
-				vx6953_regs.reg_pat_init[0].reg_0x3004},
-			{REG_0x3007,
-				vx6953_regs.reg_pat_init[0].reg_0x3007},
-			{REG_0x3016,
-				vx6953_regs.reg_pat_init[0].reg_0x3016},
-			{REG_0x301d,
-				vx6953_regs.reg_pat_init[0].reg_0x301d},
-			{REG_0x317e,
-				vx6953_regs.reg_pat_init[0].reg_0x317e},
-			{REG_0x317f,
-				vx6953_regs.reg_pat_init[0].reg_0x317f},
-			{REG_0x3400,
-				vx6953_regs.reg_pat_init[0].reg_0x3400},
-			{0x0b06,
-				vx6953_regs.reg_pat_init[0].reg_0x0b06},
-			/*Single_defect_correct_weight = auto*/
-			{0x0b07,
-				vx6953_regs.reg_pat_init[0].reg_0x0b07},
-			/*Dynamic couplet correction ENABLED*/
-			{0x0b08,
-				vx6953_regs.reg_pat_init[0].reg_0x0b08},
-			/*Dynamic couplet correction weight*/
-			{0x0b09,
-				vx6953_regs.reg_pat_init[0].reg_0x0b09},
-			/* Clock Setup */
-			/* Tell sensor ext clk is 24MHz*/
-			{0x0136,
-				vx6953_regs.reg_pat_init[0].reg_0x0136},
-			{0x0137,
-				vx6953_regs.reg_pat_init[0].reg_0x0137},
-			/* The white balance gains must be written
-			to the sensor every frame. */
-			/* Edof */
-			{REG_0x0b83,
-				vx6953_regs.reg_pat_init[0].reg_0x0b83},
-			{REG_0x0b84,
-				vx6953_regs.reg_pat_init[0].reg_0x0b84},
-			{0x0b85,
-				vx6953_regs.reg_pat_init[0].reg_0x0b85},
-			{0x0b88,
-				vx6953_regs.reg_pat_init[0].reg_0x0b88},
-			{0x0b89,
-				vx6953_regs.reg_pat_init[0].reg_0x0b89},
-			{REG_0x0b8a,
-				vx6953_regs.reg_pat_init[0].reg_0x0b8a},
-			/* Mode specific regieters */
-			{REG_FRAME_LENGTH_LINES_HI,
-				vx6953_regs.reg_pat[rt].
-				frame_length_lines_hi},
-			{REG_FRAME_LENGTH_LINES_LO,
-				vx6953_regs.reg_pat[rt].
-				frame_length_lines_lo},
-			{REG_LINE_LENGTH_PCK_HI,
-				vx6953_regs.reg_pat[rt].
-				line_length_pck_hi},
-			{REG_LINE_LENGTH_PCK_LO,
-				vx6953_regs.reg_pat[rt].
-				line_length_pck_lo},
-			{REG_0x3005,
-				vx6953_regs.reg_pat[rt].reg_0x3005},
-			{0x3010,
-				vx6953_regs.reg_pat[rt].reg_0x3010},
-			{REG_0x3011,
-				vx6953_regs.reg_pat[rt].reg_0x3011},
-			{REG_0x301a,
-				vx6953_regs.reg_pat[rt].reg_0x301a},
-			{REG_0x3035,
-				vx6953_regs.reg_pat[rt].reg_0x3035},
-			{REG_0x3036,
-				vx6953_regs.reg_pat[rt].reg_0x3036},
-			{REG_0x3041,
-				vx6953_regs.reg_pat[rt].reg_0x3041},
-			{0x3042,
-				vx6953_regs.reg_pat[rt].reg_0x3042},
-			{REG_0x3045,
-				vx6953_regs.reg_pat[rt].reg_0x3045},
-			/*EDOF: Estimation settings for Preview mode
-			Application settings for capture mode
-			(standard settings - Not tuned) */
-			{REG_0x0b80,
-				vx6953_regs.reg_pat[rt].reg_0x0b80},
-			{REG_0x0900,
-				vx6953_regs.reg_pat[rt].reg_0x0900},
-			{REG_0x0901,
-				vx6953_regs.reg_pat[rt].reg_0x0901},
-			{REG_0x0902,
-				vx6953_regs.reg_pat[rt].reg_0x0902},
-			{REG_0x0383,
-				vx6953_regs.reg_pat[rt].reg_0x0383},
-			{REG_0x0387,
-				vx6953_regs.reg_pat[rt].reg_0x0387},
-			/* Change output size / frame rate */
-			{REG_0x034c,
-				vx6953_regs.reg_pat[rt].reg_0x034c},
-			{REG_0x034d,
-				vx6953_regs.reg_pat[rt].reg_0x034d},
-			{REG_0x034e,
-				vx6953_regs.reg_pat[rt].reg_0x034e},
-			{REG_0x034f,
-				vx6953_regs.reg_pat[rt].reg_0x034f},
-			{REG_0x1716,
-				vx6953_regs.reg_pat[rt].reg_0x1716},
-			{REG_0x1717,
-				vx6953_regs.reg_pat[rt].reg_0x1717},
-			{REG_0x1718,
-				vx6953_regs.reg_pat[rt].reg_0x1718},
-			{REG_0x1719,
-				vx6953_regs.reg_pat[rt].reg_0x1719},
-			};
-			struct vx6953_i2c_reg_conf mode_tbl[] = {
-			{REG_0x0112,
-				vx6953_regs.reg_pat_init[0].reg_0x0112},
-			{REG_0x0113,
-				vx6953_regs.reg_pat_init[0].reg_0x0113},
-			{REG_VT_PIX_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				vt_pix_clk_div},
-			{REG_PRE_PLL_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				pre_pll_clk_div},
-			{REG_PLL_MULTIPLIER,
-				vx6953_regs.reg_pat_init[0].
-				pll_multiplier},
-			{REG_OP_PIX_CLK_DIV,
-				vx6953_regs.reg_pat_init[0].
-				op_pix_clk_div},
-		/* Mode specific regieters */
-			{REG_FRAME_LENGTH_LINES_HI,
-				vx6953_regs.reg_pat[rt].frame_length_lines_hi},
-			{REG_FRAME_LENGTH_LINES_LO,
-				vx6953_regs.reg_pat[rt].frame_length_lines_lo},
-			{REG_LINE_LENGTH_PCK_HI,
-				vx6953_regs.reg_pat[rt].line_length_pck_hi},
-			{REG_LINE_LENGTH_PCK_LO,
-				vx6953_regs.reg_pat[rt].line_length_pck_lo},
-			{REG_0x3005, vx6953_regs.reg_pat[rt].reg_0x3005},
-			{0x3010, vx6953_regs.reg_pat[rt].reg_0x3010},
-			{REG_0x3011, vx6953_regs.reg_pat[rt].reg_0x3011},
-			{REG_0x301a, vx6953_regs.reg_pat[rt].reg_0x301a},
-			{REG_0x3035, vx6953_regs.reg_pat[rt].reg_0x3035},
-			{REG_0x3036, vx6953_regs.reg_pat[rt].reg_0x3036},
-			{REG_0x3041, vx6953_regs.reg_pat[rt].reg_0x3041},
-			{0x3042, vx6953_regs.reg_pat[rt].reg_0x3042},
-			{REG_0x3045, vx6953_regs.reg_pat[rt].reg_0x3045},
-			/*EDOF: Estimation settings for Preview mode
-			Application settings for capture
-			mode(standard settings - Not tuned) */
-			{REG_0x0b80, vx6953_regs.reg_pat[rt].reg_0x0b80},
-			{REG_0x0900, vx6953_regs.reg_pat[rt].reg_0x0900},
-			{REG_0x0901, vx6953_regs.reg_pat[rt].reg_0x0901},
-			{REG_0x0902, vx6953_regs.reg_pat[rt].reg_0x0902},
-			{REG_0x0383, vx6953_regs.reg_pat[rt].reg_0x0383},
-			{REG_0x0387, vx6953_regs.reg_pat[rt].reg_0x0387},
-			/* Change output size / frame rate */
-			{REG_0x034c, vx6953_regs.reg_pat[rt].reg_0x034c},
-			{REG_0x034d, vx6953_regs.reg_pat[rt].reg_0x034d},
-			{REG_0x034e, vx6953_regs.reg_pat[rt].reg_0x034e},
-			{REG_0x034f, vx6953_regs.reg_pat[rt].reg_0x034f},
-			/*{0x200, vx6953_regs.reg_pat[rt].reg_0x0200},
-			{0x201, vx6953_regs.reg_pat[rt].reg_0x0201},*/
-			{REG_0x1716, vx6953_regs.reg_pat[rt].reg_0x1716},
-			{REG_0x1717, vx6953_regs.reg_pat[rt].reg_0x1717},
-			{REG_0x1718, vx6953_regs.reg_pat[rt].reg_0x1718},
-			{REG_0x1719, vx6953_regs.reg_pat[rt].reg_0x1719},
-			};
-			/* stop streaming */
-			msleep(5);
-
-			/* Reset everything first */
-			if (vx6953_i2c_write_b_sensor(0x103, 0x01) < 0) {
-				CDBG("S/W reset failed\n");
-				return rc;
-			} else
-				CDBG("S/W reset successful\n");
-
-			msleep(10);
-
-			if (vx6953_i2c_write_b_sensor(REG_MODE_SELECT,
-				MODE_SELECT_STANDBY_MODE) < 0)
-				return rc;
-			/*vx6953_stm5m0edof_delay_msecs_stdby*/
-			msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-
-			vx6953_csi_params.data_format = CSI_8BIT;
-			vx6953_csi_params.lane_cnt = 1;
-			vx6953_csi_params.lane_assign = 0xe4;
-			vx6953_csi_params.dpcm_scheme = 0;
-			vx6953_csi_params.settle_cnt = 7;
-			rc = msm_camio_csi_config(&vx6953_csi_params);
-			if (rc < 0)
-				CDBG(" config csi controller failed\n");
-
-			msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-
-			vx6953_patch_for_cut2();
-			rc = vx6953_i2c_write_w_table(&init_mode_tbl[0],
-				ARRAY_SIZE(init_mode_tbl));
-			if (rc < 0)
-				return rc;
-
-			msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-
-			rc = vx6953_i2c_write_w_table(&mode_tbl[0],
-				ARRAY_SIZE(mode_tbl));
-			if (rc < 0)
-				return rc;
-
-			msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-
-			/* Start sensor streaming */
-			if (vx6953_i2c_write_b_sensor(REG_MODE_SELECT,
-				MODE_SELECT_STREAM) < 0)
-				return rc;
-			msleep(vx6953_stm5m0edof_delay_msecs_stream);
-
-			if (vx6953_i2c_read(0x0005, &frame_cnt, 1) < 0)
-				return rc;
-
-			while (frame_cnt == 0xFF) {
-				if (vx6953_i2c_read(0x0005, &frame_cnt, 1) < 0)
-					return rc;
-				CDBG("frame_cnt=%d", frame_cnt);
-				msleep(10);
-			}
-		}
-		return rc;
-		default:
-		return rc;
-	}
-	}
-	return rc;
-}
-
-
-static int32_t vx6953_video_config(int mode)
-{
-
-	int32_t	rc = 0;
-	int	rt;
-	/* change sensor resolution	if needed */
-	if (vx6953_ctrl->prev_res == QTR_SIZE) {
-		rt = RES_PREVIEW;
-		vx6953_stm5m0edof_delay_msecs_stdby	=
-			((((2 * 1000 * vx6953_ctrl->fps_divider) /
-			vx6953_ctrl->fps) * Q8) / Q10) + 1;
-	} else {
-		rt = RES_CAPTURE;
-		vx6953_stm5m0edof_delay_msecs_stdby	=
-			((((1000 * vx6953_ctrl->fps_divider) /
-			vx6953_ctrl->fps) * Q8) / Q10) + 1;
-	}
-	if (vx6953_sensor_setting(UPDATE_PERIODIC, rt) < 0)
-		return rc;
-	if (vx6953_ctrl->set_test) {
-		if (vx6953_test(vx6953_ctrl->set_test) < 0)
-			return	rc;
-	}
-	vx6953_ctrl->edof_mode = VX6953_EDOF_ESTIMATION;
-	rc = vx6953_enable_edof(vx6953_ctrl->edof_mode);
-	if (rc < 0)
-		return rc;
-	vx6953_ctrl->curr_res = vx6953_ctrl->prev_res;
-	vx6953_ctrl->sensormode = mode;
-	return rc;
-}
-
-static int32_t vx6953_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-	int rt;
-	/*change sensor resolution if needed */
-	if (vx6953_ctrl->curr_res != vx6953_ctrl->pict_res) {
-		if (vx6953_ctrl->pict_res == QTR_SIZE) {
-			rt = RES_PREVIEW;
-			vx6953_stm5m0edof_delay_msecs_stdby =
-				((((2 * 1000 * vx6953_ctrl->fps_divider) /
-				vx6953_ctrl->fps) * Q8) / Q10) + 1;
-		} else {
-			rt = RES_CAPTURE;
-			vx6953_stm5m0edof_delay_msecs_stdby =
-				((((1000 * vx6953_ctrl->fps_divider) /
-				vx6953_ctrl->fps) * Q8) / Q10) + 1;
-		}
-	if (vx6953_sensor_setting(UPDATE_PERIODIC, rt) < 0)
-		return rc;
-	}
-
-	vx6953_ctrl->edof_mode = VX6953_EDOF_APPLICATION;
-	if (vx6953_enable_edof(vx6953_ctrl->edof_mode) < 0)
-		return rc;
-	vx6953_ctrl->curr_res = vx6953_ctrl->pict_res;
-	vx6953_ctrl->sensormode = mode;
-	return rc;
-} /*end of vx6953_snapshot_config*/
-
-static int32_t vx6953_raw_snapshot_config(int mode)
-{
-	int32_t rc = 0;
-	int rt;
-	/* change sensor resolution if needed */
-	if (vx6953_ctrl->curr_res != vx6953_ctrl->pict_res) {
-		if (vx6953_ctrl->pict_res == QTR_SIZE) {
-			rt = RES_PREVIEW;
-			vx6953_stm5m0edof_delay_msecs_stdby =
-				((((2 * 1000 * vx6953_ctrl->fps_divider)/
-				vx6953_ctrl->fps) * Q8) / Q10) + 1;
-		} else {
-			rt = RES_CAPTURE;
-			vx6953_stm5m0edof_delay_msecs_stdby =
-				((((1000 * vx6953_ctrl->fps_divider)/
-				vx6953_ctrl->fps) * Q8) / Q10) + 1;
-		}
-		if (vx6953_sensor_setting(UPDATE_PERIODIC, rt) < 0)
-			return rc;
-	}
-	vx6953_ctrl->edof_mode = VX6953_EDOF_APPLICATION;
-	if (vx6953_enable_edof(vx6953_ctrl->edof_mode) < 0)
-		return rc;
-	vx6953_ctrl->curr_res = vx6953_ctrl->pict_res;
-	vx6953_ctrl->sensormode = mode;
-	return rc;
-} /*end of vx6953_raw_snapshot_config*/
-static int32_t vx6953_set_sensor_mode(int mode,
-	int res)
-{
-	int32_t rc = 0;
-	switch (mode) {
-	case SENSOR_PREVIEW_MODE:
-		rc = vx6953_video_config(mode);
-		break;
-	case SENSOR_SNAPSHOT_MODE:
-		rc = vx6953_snapshot_config(mode);
-		break;
-	case SENSOR_RAW_SNAPSHOT_MODE:
-		rc = vx6953_raw_snapshot_config(mode);
-		break;
-	default:
-		rc = -EINVAL;
-		break;
-	}
-	return rc;
-}
-static int32_t vx6953_power_down(void)
-{
-	vx6953_i2c_write_b_sensor(REG_MODE_SELECT,
-	MODE_SELECT_STANDBY_MODE);
-	return 0;
-}
-
-
-static int vx6953_probe_init_done(const struct msm_camera_sensor_info *data)
-{
-	gpio_free(data->sensor_reset);
-	kfree(vx6953_ctrl);
-	vx6953_ctrl = NULL;
-	return 0;
-}
-static int vx6953_probe_init_sensor(const struct msm_camera_sensor_info *data)
-{
-	unsigned short revision_number;
-	int32_t rc = 0;
-	unsigned short chipidl, chipidh;
-	CDBG("%s: %d\n", __func__, __LINE__);
-	rc = gpio_request(data->sensor_reset, "vx6953");
-	CDBG(" vx6953_probe_init_sensor\n");
-	if (!rc) {
-		CDBG("sensor_reset = %d\n", rc);
-		CDBG(" vx6953_probe_init_sensor 1\n");
-		gpio_direction_output(data->sensor_reset, 0);
-		msleep(50);
-		CDBG(" vx6953_probe_init_sensor 1\n");
-		gpio_direction_output(data->sensor_reset, 1);
-		msleep(13);
-	} else {
-		CDBG(" vx6953_probe_init_sensor 2\n");
-		goto init_probe_done;
-	}
-	msleep(20);
-	CDBG(" vx6953_probe_init_sensor is called\n");
-	/* 3. Read sensor Model ID: */
-	rc = vx6953_i2c_read(0x0000, &chipidh, 1);
-	if (rc < 0) {
-		CDBG(" vx6953_probe_init_sensor 3\n");
-		goto init_probe_fail;
-	}
-	rc = vx6953_i2c_read(0x0001, &chipidl, 1);
-	if (rc < 0) {
-		CDBG(" vx6953_probe_init_sensor4\n");
-		goto init_probe_fail;
-	}
-	CDBG("vx6953 model_id = 0x%x  0x%x\n", chipidh, chipidl);
-	/* 4. Compare sensor ID to VX6953 ID: */
-	if (chipidh != 0x03 || chipidl != 0xB9) {
-		rc = -ENODEV;
-		CDBG("vx6953_probe_init_sensor fail chip id doesnot match\n");
-		goto init_probe_fail;
-	}
-
-	vx6953_ctrl = kzalloc(sizeof(struct vx6953_ctrl_t), GFP_KERNEL);
-	if (!vx6953_ctrl) {
-		CDBG("vx6953_init failed!\n");
-		rc = -ENOMEM;
-	}
-	vx6953_ctrl->fps_divider = 1 * 0x00000400;
-	vx6953_ctrl->pict_fps_divider = 1 * 0x00000400;
-	vx6953_ctrl->set_test = TEST_OFF;
-	vx6953_ctrl->prev_res = QTR_SIZE;
-	vx6953_ctrl->pict_res = FULL_SIZE;
-	vx6953_ctrl->curr_res = INVALID_SIZE;
-	vx6953_ctrl->sensor_type = VX6953_STM5M0EDOF_CUT_2;
-	vx6953_ctrl->edof_mode = VX6953_EDOF_ESTIMATION;
-
-	if (data)
-		vx6953_ctrl->sensordata = data;
-
-	if (vx6953_i2c_read(0x0002, &revision_number, 1) < 0)
-		return rc;
-		CDBG("sensor revision number major = 0x%x\n", revision_number);
-	if (vx6953_i2c_read(0x0018, &revision_number, 1) < 0)
-		return rc;
-		CDBG("sensor revision number = 0x%x\n", revision_number);
-	if (revision_number == VX6953_REVISION_NUMBER_CUT3) {
-		vx6953_ctrl->sensor_type = VX6953_STM5M0EDOF_CUT_3;
-		CDBG("VX6953 EDof Cut 3.0 sensor\n ");
-	} else if (revision_number == VX6953_REVISION_NUMBER_CUT2) {
-		vx6953_ctrl->sensor_type = VX6953_STM5M0EDOF_CUT_2;
-		CDBG("VX6953 EDof Cut 2.0 sensor\n ");
-	} else {/* Cut1.0 reads 0x00 for register 0x0018*/
-		vx6953_ctrl->sensor_type = VX6953_STM5M0EDOF_CUT_1;
-		CDBG("VX6953 EDof Cut 1.0 sensor\n ");
-	}
-
-	if (vx6953_ctrl->prev_res == QTR_SIZE) {
-		if (vx6953_sensor_setting(REG_INIT, RES_PREVIEW) < 0)
-			goto init_probe_fail;
-	} else {
-		if (vx6953_sensor_setting(REG_INIT, RES_CAPTURE) < 0)
-			goto init_probe_fail;
-	}
-
-	goto init_probe_done;
-init_probe_fail:
-	CDBG(" vx6953_probe_init_sensor fails\n");
-	gpio_direction_output(data->sensor_reset, 0);
-	vx6953_probe_init_done(data);
-init_probe_done:
-	CDBG(" vx6953_probe_init_sensor finishes\n");
-	return rc;
-	}
-/* camsensor_iu060f_vx6953_reset */
-int vx6953_sensor_open_init(const struct msm_camera_sensor_info *data)
-{
-	unsigned short revision_number;
-	int32_t rc = 0;
-
-	CDBG("%s: %d\n", __func__, __LINE__);
-	CDBG("Calling vx6953_sensor_open_init\n");
-	rc = gpio_request(data->sensor_reset, "vx6953");
-	if (!rc)
-		CDBG("vx6953 gpio_request fail\n");
-
-	vx6953_ctrl = kzalloc(sizeof(struct vx6953_ctrl_t), GFP_KERNEL);
-	if (!vx6953_ctrl) {
-		CDBG("vx6953_init failed!\n");
-		rc = -ENOMEM;
-		goto init_done;
-	}
-	vx6953_ctrl->fps_divider = 1 * 0x00000400;
-	vx6953_ctrl->pict_fps_divider = 1 * 0x00000400;
-	vx6953_ctrl->set_test = TEST_OFF;
-	vx6953_ctrl->prev_res = QTR_SIZE;
-	vx6953_ctrl->pict_res = FULL_SIZE;
-	vx6953_ctrl->curr_res = INVALID_SIZE;
-	vx6953_ctrl->sensor_type = VX6953_STM5M0EDOF_CUT_2;
-	vx6953_ctrl->edof_mode = VX6953_EDOF_ESTIMATION;
-	if (data)
-		vx6953_ctrl->sensordata = data;
-	if (rc < 0) {
-		CDBG("Calling vx6953_sensor_open_init fail1\n");
-		return rc;
-	}
-	CDBG("%s: %d\n", __func__, __LINE__);
-	/* enable mclk first */
-	msm_camio_clk_rate_set(VX6953_STM5M0EDOF_DEFAULT_MASTER_CLK_RATE);
-	CDBG("%s: %d\n", __func__, __LINE__);
-	if (vx6953_i2c_read(0x0002, &revision_number, 1) < 0)
-		return rc;
-		CDBG("sensor revision number major = 0x%x\n", revision_number);
-	if (vx6953_i2c_read(0x0018, &revision_number, 1) < 0)
-		return rc;
-		CDBG("sensor revision number = 0x%x\n", revision_number);
-	if (revision_number == VX6953_REVISION_NUMBER_CUT3) {
-		vx6953_ctrl->sensor_type = VX6953_STM5M0EDOF_CUT_3;
-		CDBG("VX6953 EDof Cut 3.0 sensor\n ");
-	} else if (revision_number == VX6953_REVISION_NUMBER_CUT2) {
-		vx6953_ctrl->sensor_type = VX6953_STM5M0EDOF_CUT_2;
-		CDBG("VX6953 EDof Cut 2.0 sensor\n ");
-	} else {/* Cut1.0 reads 0x00 for register 0x0018*/
-		vx6953_ctrl->sensor_type = VX6953_STM5M0EDOF_CUT_1;
-		CDBG("VX6953 EDof Cut 1.0 sensor\n ");
-	}
-
-	vx6953_ctrl->fps = 30*Q8;
-	if (rc < 0)
-		goto init_fail;
-	else
-		goto init_done;
-init_fail:
-	CDBG("init_fail\n");
-	gpio_direction_output(data->sensor_reset, 0);
-	vx6953_probe_init_done(data);
-init_done:
-	CDBG("init_done\n");
-	return rc;
-} /*endof vx6953_sensor_open_init*/
-
-static int vx6953_init_client(struct i2c_client *client)
-{
-	/* Initialize the MSM_CAMI2C Chip */
-	init_waitqueue_head(&vx6953_wait_queue);
-	return 0;
-}
-
-static const struct i2c_device_id vx6953_i2c_id[] = {
-	{"vx6953", 0},
-	{ }
-};
-
-static int vx6953_i2c_probe(struct i2c_client *client,
-	const struct i2c_device_id *id)
-{
-	int rc = 0;
-	CDBG("vx6953_probe called!\n");
-
-	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-		CDBG("i2c_check_functionality failed\n");
-		goto probe_failure;
-	}
-
-	vx6953_sensorw = kzalloc(sizeof(struct vx6953_work_t), GFP_KERNEL);
-	if (!vx6953_sensorw) {
-		CDBG("kzalloc failed.\n");
-		rc = -ENOMEM;
-		goto probe_failure;
-	}
-
-	i2c_set_clientdata(client, vx6953_sensorw);
-	vx6953_init_client(client);
-	vx6953_client = client;
-
-	msleep(50);
-
-	CDBG("vx6953_probe successed! rc = %d\n", rc);
-	return 0;
-
-probe_failure:
-	CDBG("vx6953_probe failed! rc = %d\n", rc);
-	return rc;
-}
-
-static int vx6953_send_wb_info(struct wb_info_cfg *wb)
-{
-	unsigned short read_data;
-	uint8_t temp[8];
-	int rc = 0;
-	int i = 0;
-
-	/* red_gain */
-	temp[2] = wb->red_gain >> 8;
-	temp[3] = wb->red_gain & 0xFF;
-
-	/* green_gain */
-	temp[0] = wb->green_gain >> 8;
-	temp[1] = wb->green_gain & 0xFF;
-	temp[6] = temp[0];
-	temp[7] = temp[1];
-
-	/* blue_gain */
-	temp[4] = wb->blue_gain >> 8;
-	temp[5] = wb->blue_gain & 0xFF;
-	rc = vx6953_i2c_write_seq_sensor(0x0B8E, &temp[0], 8);
-
-	for (i = 0; i < 6; i++) {
-		rc = vx6953_i2c_read(0x0B8E + i, &read_data, 1);
-		CDBG("%s addr 0x%x val %d\n", __func__, 0x0B8E + i, read_data);
-	}
-	rc = vx6953_i2c_read(0x0B82, &read_data, 1);
-	CDBG("%s addr 0x%x val %d\n", __func__, 0x0B82, read_data);
-	if (rc < 0)
-		return rc;
-	return rc;
-} /*end of vx6953_snapshot_config*/
-
-static int __exit vx6953_remove(struct i2c_client *client)
-{
-	struct vx6953_work_t_t *sensorw = i2c_get_clientdata(client);
-	free_irq(client->irq, sensorw);
-	vx6953_client = NULL;
-	kfree(sensorw);
-	return 0;
-}
-
-static struct i2c_driver vx6953_i2c_driver = {
-	.id_table = vx6953_i2c_id,
-	.probe  = vx6953_i2c_probe,
-	.remove = __exit_p(vx6953_i2c_remove),
-	.driver = {
-		.name = "vx6953",
-	},
-};
-
-static int vx6953_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(&vx6953_mut);
-	CDBG("vx6953_sensor_config: cfgtype = %d\n",
-	cdata.cfgtype);
-		switch (cdata.cfgtype) {
-		case CFG_GET_PICT_FPS:
-			vx6953_get_pict_fps(
-				cdata.cfg.gfps.prevfps,
-				&(cdata.cfg.gfps.pictfps));
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_GET_PREV_L_PF:
-			cdata.cfg.prevl_pf =
-			vx6953_get_prev_lines_pf();
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_GET_PREV_P_PL:
-			cdata.cfg.prevp_pl =
-				vx6953_get_prev_pixels_pl();
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_GET_PICT_L_PF:
-			cdata.cfg.pictl_pf =
-				vx6953_get_pict_lines_pf();
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_GET_PICT_P_PL:
-			cdata.cfg.pictp_pl =
-				vx6953_get_pict_pixels_pl();
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_GET_PICT_MAX_EXP_LC:
-			cdata.cfg.pict_max_exp_lc =
-				vx6953_get_pict_max_exp_lc();
-
-			if (copy_to_user((void *)argp,
-				&cdata,
-				sizeof(struct sensor_cfg_data)))
-				rc = -EFAULT;
-			break;
-
-		case CFG_SET_FPS:
-		case CFG_SET_PICT_FPS:
-			rc = vx6953_set_fps(&(cdata.cfg.fps));
-			break;
-
-		case CFG_SET_EXP_GAIN:
-			rc =
-				vx6953_write_exp_gain(
-					cdata.cfg.exp_gain.gain,
-					cdata.cfg.exp_gain.line);
-			break;
-
-		case CFG_SET_PICT_EXP_GAIN:
-			rc =
-				vx6953_set_pict_exp_gain(
-				cdata.cfg.exp_gain.gain,
-				cdata.cfg.exp_gain.line);
-			break;
-
-		case CFG_SET_MODE:
-			rc = vx6953_set_sensor_mode(cdata.mode,
-					cdata.rs);
-			break;
-
-		case CFG_PWR_DOWN:
-			rc = vx6953_power_down();
-			break;
-
-		case CFG_MOVE_FOCUS:
-			rc =
-				vx6953_move_focus(
-				cdata.cfg.focus.dir,
-				cdata.cfg.focus.steps);
-			break;
-
-		case CFG_SET_DEFAULT_FOCUS:
-			rc =
-				vx6953_set_default_focus(
-				cdata.cfg.focus.steps);
-			break;
-
-		case CFG_SET_EFFECT:
-			rc = vx6953_set_default_focus(
-				cdata.cfg.effect);
-			break;
-
-
-		case CFG_SEND_WB_INFO:
-			rc = vx6953_send_wb_info(
-				&(cdata.cfg.wb_info));
-			break;
-
-		default:
-			rc = -EFAULT;
-			break;
-		}
-
-	mutex_unlock(&vx6953_mut);
-
-	return rc;
-}
-
-
-
-
-static int vx6953_sensor_release(void)
-{
-	int rc = -EBADF;
-	mutex_lock(&vx6953_mut);
-	vx6953_power_down();
-	gpio_free(vx6953_ctrl->sensordata->sensor_reset);
-	kfree(vx6953_ctrl);
-	vx6953_ctrl = NULL;
-	CDBG("vx6953_release completed\n");
-	mutex_unlock(&vx6953_mut);
-
-	return rc;
-}
-
-static int vx6953_g_chip_ident(struct v4l2_subdev *sd,
-			struct v4l2_dbg_chip_ident *id)
-{
-	/* TODO: Need to add this ID in v4l2-chip-ident.h */
-	id->ident    = V4L2_IDENT_VX6953;
-	id->revision = 0;
-
-	return 0;
-}
-
-static int vx6953_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *param)
-{
-	int ret = 0;
-	/* return current mode value */
-	param->parm.capture.capturemode = vx6953_ctrl->sensormode;
-	return ret;
-}
-
-static int vx6953_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *param)
-{
-	/* set the desired mode */
-	/* right now, the only purpose is to set the desired mode -
-	 preview or snapshot */
-	vx6953_ctrl->sensormode = param->parm.capture.capturemode;
-	return 0;
-}
-
-static int vx6953_s_stream(struct v4l2_subdev *sd, int enable)
-{
-	long rc = 0;
-	int mode = vx6953_ctrl->sensormode;
-	int rt = RES_PREVIEW;
-	unsigned short frame_cnt;
-	struct msm_camera_csi_params vx6953_csi_params;
-
-	CDBG("mode = %d, enable = %d\n", mode, enable);
-
-	if (!enable) {
-		/* turn off streaming */
-		/* TODO: Make call to I2C write to turn streaming off */
-		/* rc = vx6953_i2c_write_b_sensor(); */
-
-		struct vx6953_i2c_reg_conf init_tbl[] = {
-			{REG_0x0112,
-			vx6953_regs.reg_pat_init[0].reg_0x0112},
-			{0x6003, 0x01},
-			{REG_0x0113,
-			vx6953_regs.reg_pat_init[0].reg_0x0113},
-			{REG_VT_PIX_CLK_DIV,
-			vx6953_regs.reg_pat_init[0].
-			vt_pix_clk_div},
-			{REG_PRE_PLL_CLK_DIV,
-			vx6953_regs.reg_pat_init[0].
-			pre_pll_clk_div},
-			{REG_PLL_MULTIPLIER,
-			vx6953_regs.reg_pat_init[0].
-			pll_multiplier},
-			{REG_OP_PIX_CLK_DIV,
-			vx6953_regs.reg_pat_init[0].
-			op_pix_clk_div},
-			{REG_COARSE_INTEGRATION_TIME_HI,
-			vx6953_regs.reg_pat[rt].
-			coarse_integration_time_hi},
-			{REG_COARSE_INTEGRATION_TIME_LO,
-			vx6953_regs.reg_pat[rt].
-			coarse_integration_time_lo},
-			{REG_ANALOGUE_GAIN_CODE_GLOBAL_LO,
-			vx6953_regs.reg_pat[rt].
-			analogue_gain_code_global},
-			{REG_0x3030,
-			vx6953_regs.reg_pat_init[0].reg_0x3030},
-			/* 953 specific registers */
-			{REG_0x0111,
-			vx6953_regs.reg_pat_init[0].reg_0x0111},
-			{REG_0x0b00,
-			vx6953_regs.reg_pat_init[0].reg_0x0b00},
-			{REG_0x3001,
-			vx6953_regs.reg_pat_init[0].reg_0x3001},
-			{REG_0x3004,
-			vx6953_regs.reg_pat_init[0].reg_0x3004},
-			{0x3006, 0x00},
-			{REG_0x3007,
-			vx6953_regs.reg_pat_init[0].reg_0x3007},
-			{0x301b, 0x29},
-			/* DEFCOR settings */
-			/*Single Defect Correction Weight DISABLE*/
-			{0x0b06,
-			vx6953_regs.reg_pat_init[0].reg_0x0b06},
-			/*Single_defect_correct_weight = auto*/
-			{0x0b07,
-			vx6953_regs.reg_pat_init[0].reg_0x0b07},
-			/*Dynamic couplet correction ENABLED*/
-			{0x0b08,
-			vx6953_regs.reg_pat_init[0].reg_0x0b08},
-			/*Dynamic couplet correction weight*/
-			{0x0b09,
-			vx6953_regs.reg_pat_init[0].reg_0x0b09},
-			/* Clock Setup */
-			/* Tell sensor ext clk is 24MHz*/
-			{REG_0x0136,
-			vx6953_regs.reg_pat_init[0].reg_0x0136},
-			{REG_0x0137,
-			vx6953_regs.reg_pat_init[0].reg_0x0137},
-			/* The white balance gains must be written
-			 to the sensor every frame. */
-			/* Edof */
-			{REG_0x0b83,
-			vx6953_regs.reg_pat_init[0].reg_0x0b83},
-			{REG_0x0b84,
-			vx6953_regs.reg_pat_init[0].reg_0x0b84},
-			{REG_0x0b85,
-			vx6953_regs.reg_pat_init[0].reg_0x0b85},
-			{REG_0x0b88,
-			vx6953_regs.reg_pat_init[0].reg_0x0b88},
-			{REG_0x0b89,
-			vx6953_regs.reg_pat_init[0].reg_0x0b89},
-			{REG_0x0b8a,
-			vx6953_regs.reg_pat_init[0].reg_0x0b8a},
-			/* Mode specific regieters */
-			{REG_FRAME_LENGTH_LINES_HI,
-			vx6953_regs.reg_pat[rt].
-			frame_length_lines_hi},
-			{REG_FRAME_LENGTH_LINES_LO,
-			vx6953_regs.reg_pat[rt].
-			frame_length_lines_lo},
-			{REG_LINE_LENGTH_PCK_HI,
-			vx6953_regs.reg_pat[rt].
-			line_length_pck_hi},
-			{REG_LINE_LENGTH_PCK_LO,
-			vx6953_regs.reg_pat[rt].
-			line_length_pck_lo},
-			{REG_0x3005,
-			vx6953_regs.reg_pat[rt].reg_0x3005},
-			{0x3010,
-			vx6953_regs.reg_pat[rt].reg_0x3010},
-			{REG_0x3011,
-			vx6953_regs.reg_pat[rt].reg_0x3011},
-			{REG_0x301a,
-			vx6953_regs.reg_pat[rt].reg_0x301a},
-			{REG_0x3035,
-			vx6953_regs.reg_pat[rt].reg_0x3035},
-			{REG_0x3036,
-			vx6953_regs.reg_pat[rt].reg_0x3036},
-			{REG_0x3041,
-			vx6953_regs.reg_pat[rt].reg_0x3041},
-			{0x3042,
-			vx6953_regs.reg_pat[rt].reg_0x3042},
-			{REG_0x3045,
-			vx6953_regs.reg_pat[rt].reg_0x3045},
-			/*EDOF: Estimation settings for Preview mode
-			  Application settings for capture mode
-			  (standard settings - Not tuned) */
-			{REG_0x0b80,
-			vx6953_regs.reg_pat[rt].reg_0x0b80},
-			{REG_0x0900,
-			vx6953_regs.reg_pat[rt].reg_0x0900},
-			{REG_0x0901,
-			vx6953_regs.reg_pat[rt].reg_0x0901},
-			{REG_0x0902,
-			vx6953_regs.reg_pat[rt].reg_0x0902},
-			{REG_0x0383,
-			vx6953_regs.reg_pat[rt].reg_0x0383},
-			{REG_0x0387,
-			vx6953_regs.reg_pat[rt].reg_0x0387},
-			/* Change output size / frame rate */
-			{REG_0x034c,
-			vx6953_regs.reg_pat[rt].reg_0x034c},
-			{REG_0x034d,
-			vx6953_regs.reg_pat[rt].reg_0x034d},
-			{REG_0x034e,
-			vx6953_regs.reg_pat[rt].reg_0x034e},
-			{REG_0x034f,
-			vx6953_regs.reg_pat[rt].reg_0x034f},
-		};
-		/* reset fps_divider */
-		vx6953_ctrl->fps = 30 * Q8;
-		/* stop streaming */
-
-		/* Reset everything first */
-		if (vx6953_i2c_write_b_sensor(0x103, 0x01) < 0) {
-			CDBG("S/W reset failed\n");
-			return rc;
-		} else
-			CDBG("S/W reset successful\n");
-
-		msleep(10);
-
-		CDBG("Init vx6953_sensor_setting standby\n");
-		if (vx6953_i2c_write_b_sensor(REG_MODE_SELECT,
-				    MODE_SELECT_STANDBY_MODE) < 0)
-			return rc;
-
-		/*vx6953_stm5m0edof_delay_msecs_stdby*/
-		msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-
-		vx6953_csi_params.data_format = CSI_8BIT;
-		vx6953_csi_params.lane_cnt = 1;
-		vx6953_csi_params.lane_assign = 0xe4;
-		vx6953_csi_params.dpcm_scheme = 0;
-		vx6953_csi_params.settle_cnt = 7;
-		rc = msm_camio_csi_config(&vx6953_csi_params);
-		if (rc < 0)
-			CDBG(" config csi controller failed\n");
-		msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-
-		vx6953_patch_for_cut3();
-		rc = vx6953_i2c_write_w_table(&init_tbl[0],
-					    ARRAY_SIZE(init_tbl));
-		if (rc < 0)
-			return rc;
-
-		msleep(vx6953_stm5m0edof_delay_msecs_stdby);
-
-		vx6953_i2c_write_b_sensor(0x0b80, 0x00);
-		vx6953_i2c_write_b_sensor(0x3388, 0x03);
-		vx6953_i2c_write_b_sensor(0x3640, 0x00);
-		return rc;
-	} else {
-		/* Start sensor streaming */
-		if (vx6953_i2c_write_b_sensor(REG_MODE_SELECT,
-					    MODE_SELECT_STREAM) < 0)
-			return rc;
-		CDBG("Init vx6953_sensor_setting stream\n");
-		msleep(vx6953_stm5m0edof_delay_msecs_stream);
-		if (vx6953_i2c_read(0x0005, &frame_cnt, 1) < 0)
-			return rc;
-
-		rc = vx6953_i2c_write_w_table(&edof_tbl[0],
-					    ARRAY_SIZE(edof_tbl));
-		vx6953_i2c_write_b_sensor(0x3388, 0x00);
-
-		while (frame_cnt == 0xFF) {
-			if (vx6953_i2c_read(0x0005, &frame_cnt, 1) < 0)
-				return rc;
-			CDBG("frame_cnt=%d", frame_cnt);
-			msleep(10);
-		}
-
-		/* set desired mode */
-		switch (mode) {
-		case SENSOR_PREVIEW_MODE:
-			CDBG("SENSOR_PREVIEW_MODE\n");
-			rc = vx6953_video_config(mode);
-			break;
-		case SENSOR_SNAPSHOT_MODE:
-			CDBG("SENSOR_SNAPSHOT_MODE\n");
-			rc = vx6953_snapshot_config(mode);
-			break;
-		case SENSOR_RAW_SNAPSHOT_MODE:
-			CDBG("SENSOR_RAW_SNAPSHOT_MODE\n");
-			rc = vx6953_raw_snapshot_config(mode);
-			break;
-		default:
-			CDBG("default\n");
-			return -EINVAL;
-		}
-	}
-
-	return 0;
-}
-
-static void vx6953_frame_check(u32 *width, u32 *height)
-{
-	/* get mode first */
-	int mode = vx6953_ctrl->sensormode;
-
-	switch (mode) {
-	case SENSOR_PREVIEW_MODE:
-		if (*width > VX6953_QTR_SIZE_WIDTH)
-			*width = VX6953_QTR_SIZE_WIDTH;
-
-		if (*height > VX6953_QTR_SIZE_HEIGHT)
-			*height = VX6953_QTR_SIZE_HEIGHT;
-		break;
-	case SENSOR_SNAPSHOT_MODE:
-	case SENSOR_RAW_SNAPSHOT_MODE:
-		if (*width > VX6953_HRZ_FULL_BLK_PIXELS)
-			*width = VX6953_HRZ_FULL_BLK_PIXELS;
-
-		if (*height > VX6953_VER_FULL_BLK_LINES)
-			*height = VX6953_VER_FULL_BLK_LINES;
-		break;
-	default:
-		break;
-	}
-}
-
-
-static int vx6953_set_params(struct i2c_client *client, u32 width, u32 height,
-			     enum v4l2_mbus_pixelcode code)
-{
-	int i;
-	vx6953_ctrl->fmt = NULL;
-
-	/*
-	 * frame size check
-	 */
-	vx6953_frame_check(&width, &height);
-
-	/*
-	 * get color format
-	 */
-	for (i = 0; i < ARRAY_SIZE(vx6953_cfmts); i++)
-		if (vx6953_cfmts[i].code == code)
-			break;
-	if (i == ARRAY_SIZE(vx6953_cfmts))
-		return -EINVAL;
-
-	/* sensor supports one fixed size depending upon the mode */
-	switch (vx6953_ctrl->sensormode) {
-	case SENSOR_PREVIEW_MODE:
-		vx6953_video_config(vx6953_ctrl->sensormode);
-		break;
-	case SENSOR_SNAPSHOT_MODE:
-		vx6953_snapshot_config(vx6953_ctrl->sensormode);
-		break;
-	case SENSOR_RAW_SNAPSHOT_MODE:
-		vx6953_raw_snapshot_config(vx6953_ctrl->sensormode);
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	/* why need this ? vx6953_ctrl->fmt = &(vx6953_cfmts[i]); */
-
-	return 0;
-}
-
-static int vx6953_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
-{
-	/* right now we are not supporting, probably vfe can take care */
-	return -EINVAL;
-}
-
-static int vx6953_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
-{
-	return -EINVAL;
-}
-
-static int vx6953_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
-{
-	return -EINVAL;
-}
-
-static int vx6953_g_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
-{
-	/* by this time vx6953_client should already be set */
-	struct i2c_client *client = vx6953_client;
-
-	/* currently sensor supports fixed dimensions only
-	 * depending upon the mode*/
-	if (!vx6953_ctrl->fmt) {
-		int ret = vx6953_set_params(client, VX6953_QTR_SIZE_WIDTH,
-						VX6953_QTR_SIZE_HEIGHT,
-						V4L2_MBUS_FMT_YUYV8_2X8);
-		if (ret < 0)
-			return ret;
-	}
-
-	mf->width = vx6953_get_pict_pixels_pl();
-	mf->height  = vx6953_get_pict_lines_pf();
-	/* TODO: set colorspace */
-	mf->code  = vx6953_ctrl->fmt->code;
-	mf->field = V4L2_FIELD_NONE;
-
-	return 0;
-}
-
-static int vx6953_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
-{
-	/* by this time vx6953_client should already be set */
-	struct i2c_client *client = vx6953_client;
-
-	/* TODO: We need to define this function */
-	/* TODO: set colorspace */
-	return vx6953_set_params(client, mf->width, mf->height, mf->code);
-}
-
-static int vx6953_try_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf)
-{
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(vx6953_cfmts); i++)
-		if (mf->code == vx6953_cfmts[i].code)
-			break;
-
-	if (i == ARRAY_SIZE(vx6953_cfmts))
-		return -EINVAL;
-
-	/* check that frame is within max sensor supported frame size */
-	vx6953_frame_check(&mf->width, &mf->height);
-
-	/* TODO: set colorspace */
-	mf->field = V4L2_FIELD_NONE;
-
-	return 0;
-}
-
-static int vx6953_enum_fmt(struct v4l2_subdev *sd, unsigned int index,
-			   enum v4l2_mbus_pixelcode *code)
-{
-	printk(KERN_DEBUG "Index is %d\n", index);
-	if ((unsigned int)index >= ARRAY_SIZE(vx6953_cfmts))
-		return -EINVAL;
-
-	*code = vx6953_cfmts[index].code;
-	return 0;
-}
-
-static struct v4l2_subdev_core_ops vx6953_subdev_core_ops = {
-	.g_chip_ident = vx6953_g_chip_ident,
-};
-
-static struct v4l2_subdev_video_ops vx6953_subdev_video_ops = {
-	.g_parm			   = vx6953_g_parm,
-	.s_parm			   = vx6953_s_parm,
-	.s_stream = vx6953_s_stream,
-	.g_mbus_fmt = vx6953_g_fmt,
-	.s_mbus_fmt = vx6953_s_fmt,
-	.try_mbus_fmt = vx6953_try_fmt,
-	.cropcap  = vx6953_cropcap,
-	.g_crop   = vx6953_g_crop,
-	.s_crop   = vx6953_s_crop,
-	.enum_mbus_fmt  = vx6953_enum_fmt,
-};
-
-static struct v4l2_subdev_ops vx6953_subdev_ops = {
-	.core = &vx6953_subdev_core_ops,
-	.video  = &vx6953_subdev_video_ops,
-};
-
-static int vx6953_sensor_probe(const struct msm_camera_sensor_info *info,
-		struct msm_sensor_ctrl *s)
-{
-	int rc = 0;
-	rc = i2c_add_driver(&vx6953_i2c_driver);
-	if (rc < 0 || vx6953_client == NULL) {
-		rc = -ENOTSUPP;
-		goto probe_fail;
-	}
-	msm_camio_clk_rate_set(24000000);
-	rc = vx6953_probe_init_sensor(info);
-	if (rc < 0)
-		goto probe_fail;
-	s->s_init = vx6953_sensor_open_init;
-	s->s_release = vx6953_sensor_release;
-	s->s_config  = vx6953_sensor_config;
-	vx6953_probe_init_done(info);
-	return rc;
-
-probe_fail:
-	CDBG("vx6953_sensor_probe: SENSOR PROBE FAILS!\n");
-	return rc;
-}
-
-
-static int vx6953_sensor_probe_cb(const struct msm_camera_sensor_info *info,
-	struct v4l2_subdev *sdev, struct msm_sensor_ctrl *s)
-{
-	int rc = 0;
-	rc = vx6953_sensor_probe(info, s);
-	if (rc < 0)
-		return rc;
-
-	vx6953_ctrl = kzalloc(sizeof(struct vx6953_ctrl_t), GFP_KERNEL);
-	if (!vx6953_ctrl) {
-		CDBG("vx6953_sensor_probe failed!\n");
-		return -ENOMEM;
-	}
-
-	/* probe is successful, init a v4l2 subdevice */
-	printk(KERN_DEBUG "going into v4l2_i2c_subdev_init\n");
-	if (sdev) {
-		v4l2_i2c_subdev_init(sdev, vx6953_client,
-						&vx6953_subdev_ops);
-		vx6953_ctrl->sensor_dev = sdev;
-	}
-	return rc;
-}
-
-static int __vx6953_probe(struct platform_device *pdev)
-{
-	return msm_sensor_register(pdev, vx6953_sensor_probe_cb);
-}
-
-static struct platform_driver msm_camera_driver = {
-	.probe = __vx6953_probe,
-	.driver = {
-		.name = "msm_camera_vx6953",
-		.owner = THIS_MODULE,
-	},
-};
-
-static int __init vx6953_init(void)
-{
-	return platform_driver_register(&msm_camera_driver);
-}
-
-module_init(vx6953_init);
-void vx6953_exit(void)
-{
-	i2c_del_driver(&vx6953_i2c_driver);
-}
-
-
diff --git a/drivers/media/platform/msm/camera_v1/vx6953_v4l2.h b/drivers/media/platform/msm/camera_v1/vx6953_v4l2.h
deleted file mode 100644
index 4c7e90f..0000000
--- a/drivers/media/platform/msm/camera_v1/vx6953_v4l2.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/* Copyright (c) 2011, The Linux Foundation. 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.
- *
- */
-
-#ifndef VX6953_V4L2_H
-#define VX6953_V4L2_H
-#include <linux/types.h>
-#include <mach/board.h>
-extern struct vx6953_reg vx6953_regs;
-struct reg_struct_init {
-	uint8_t reg_0x0112;      /* 0x0112*/
-	uint8_t reg_0x0113;      /* 0x0113*/
-	uint8_t vt_pix_clk_div;  /* 0x0301*/
-	uint8_t pre_pll_clk_div; /* 0x0305*/
-	uint8_t pll_multiplier;  /* 0x0307*/
-	uint8_t op_pix_clk_div;  /* 0x0309*/
-	uint8_t reg_0x3030;      /*0x3030*/
-	uint8_t reg_0x0111;      /*0x0111*/
-	uint8_t reg_0x0b00;      /*0x0b00*/
-	uint8_t reg_0x3001;      /*0x3001*/
-	uint8_t reg_0x3004;      /*0x3004*/
-	uint8_t reg_0x3007;      /*0x3007*/
-	uint8_t reg_0x3016;      /*0x3016*/
-	uint8_t reg_0x301d;      /*0x301d*/
-	uint8_t reg_0x317e;      /*0x317E*/
-	uint8_t reg_0x317f;      /*0x317F*/
-	uint8_t reg_0x3400;      /*0x3400*/
-	uint8_t reg_0x0b06;      /*0x0b06*/
-	uint8_t reg_0x0b07;      /*0x0b07*/
-	uint8_t reg_0x0b08;      /*0x0b08*/
-	uint8_t reg_0x0b09;      /*0x0b09*/
-	uint8_t reg_0x0136;
-	uint8_t reg_0x0137;
-	/* Edof */
-	uint8_t reg_0x0b83;      /*0x0b83*/
-	uint8_t reg_0x0b84;      /*0x0b84*/
-	uint8_t reg_0x0b85;      /*0x0b85*/
-	uint8_t reg_0x0b88;      /*0x0b88*/
-	uint8_t reg_0x0b89;      /*0x0b89*/
-	uint8_t reg_0x0b8a;      /*0x0b8a*/
-	};
-struct reg_struct {
-	uint8_t coarse_integration_time_hi; /*REG_COARSE_INTEGRATION_TIME_HI*/
-	uint8_t coarse_integration_time_lo; /*REG_COARSE_INTEGRATION_TIME_LO*/
-	uint8_t analogue_gain_code_global;
-	uint8_t frame_length_lines_hi; /* 0x0340*/
-	uint8_t frame_length_lines_lo; /* 0x0341*/
-	uint8_t line_length_pck_hi;    /* 0x0342*/
-	uint8_t line_length_pck_lo;    /* 0x0343*/
-	uint8_t reg_0x3005;   /* 0x3005*/
-	uint8_t reg_0x3010;  /* 0x3010*/
-	uint8_t reg_0x3011;  /* 0x3011*/
-	uint8_t reg_0x301a;  /* 0x301a*/
-	uint8_t reg_0x3035;  /* 0x3035*/
-	uint8_t reg_0x3036;   /* 0x3036*/
-	uint8_t reg_0x3041;  /*0x3041*/
-	uint8_t reg_0x3042;  /*0x3042*/
-	uint8_t reg_0x3045;  /*0x3045*/
-	uint8_t reg_0x0b80;   /* 0x0b80*/
-	uint8_t reg_0x0900;   /*0x0900*/
-	uint8_t reg_0x0901;   /* 0x0901*/
-	uint8_t reg_0x0902;   /*0x0902*/
-	uint8_t reg_0x0383;   /*0x0383*/
-	uint8_t reg_0x0387;   /* 0x0387*/
-	uint8_t reg_0x034c;   /* 0x034c*/
-	uint8_t reg_0x034d;   /*0x034d*/
-	uint8_t reg_0x034e;   /* 0x034e*/
-	uint8_t reg_0x034f;   /* 0x034f*/
-	uint8_t reg_0x1716; /*0x1716*/
-	uint8_t reg_0x1717; /*0x1717*/
-	uint8_t reg_0x1718; /*0x1718*/
-	uint8_t reg_0x1719; /*0x1719*/
-	uint8_t reg_0x3210;/*0x3210*/
-	uint8_t reg_0x111; /*0x111*/
-	uint8_t reg_0x3410;  /*0x3410*/
-	uint8_t reg_0x3098;
-	uint8_t reg_0x309D;
-	uint8_t reg_0x0200;
-	uint8_t reg_0x0201;
-	};
-struct vx6953_i2c_reg_conf {
-	unsigned short waddr;
-	unsigned short wdata;
-};
-
-enum vx6953_test_mode_t {
-	TEST_OFF,
-	TEST_1,
-	TEST_2,
-	TEST_3
-};
-
-enum vx6953_resolution_t {
-	QTR_SIZE,
-	FULL_SIZE,
-	INVALID_SIZE
-};
-enum vx6953_setting {
-	RES_PREVIEW,
-	RES_CAPTURE
-};
-enum mt9p012_reg_update {
-	/* Sensor egisters that need to be updated during initialization */
-	REG_INIT,
-	/* Sensor egisters that needs periodic I2C writes */
-	UPDATE_PERIODIC,
-	/* All the sensor Registers will be updated */
-	UPDATE_ALL,
-	/* Not valid update */
-	UPDATE_INVALID
-};
-
-enum sensor_revision_t {
-	VX6953_STM5M0EDOF_CUT_1,
-	VX6953_STM5M0EDOF_CUT_2,
-	VX6953_STM5M0EDOF_CUT_3
-};
-enum edof_mode_t {
-	VX6953_EDOF_DISABLE,       /* 0x00 */
-	VX6953_EDOF_APPLICATION,   /* 0x01 */
-	VX6953_EDOF_ESTIMATION     /* 0x02 */
-};
-struct vx6953_reg {
-	const struct reg_struct_init  *reg_pat_init;
-	const struct reg_struct  *reg_pat;
-};
-#endif /* VX6953_H */
diff --git a/drivers/media/platform/msm/camera_v2/camera/camera.c b/drivers/media/platform/msm/camera_v2/camera/camera.c
index 0313161..eda6150 100644
--- a/drivers/media/platform/msm/camera_v2/camera/camera.c
+++ b/drivers/media/platform/msm/camera_v2/camera/camera.c
@@ -539,6 +539,7 @@
 		goto vb2_q_fail;
 
 	if (!atomic_read(&pvdev->opened)) {
+		pm_stay_awake(&pvdev->vdev->dev);
 
 		/* create a new session when first opened */
 		rc = msm_create_session(pvdev->vdev->num, pvdev->vdev);
@@ -572,6 +573,7 @@
 command_ack_q_fail:
 	msm_destroy_session(pvdev->vdev->num);
 session_fail:
+	pm_relax(&pvdev->vdev->dev);
 	camera_v4l2_vb2_q_release(filep);
 vb2_q_fail:
 	camera_v4l2_fh_release(filep);
@@ -621,6 +623,7 @@
 		/* This should take care of both normal close
 		 * and application crashes */
 		msm_destroy_session(pvdev->vdev->num);
+		pm_relax(&pvdev->vdev->dev);
 		atomic_set(&pvdev->stream_cnt, 0);
 
 	} else {
@@ -723,6 +726,7 @@
 	atomic_set(&pvdev->opened, 0);
 	atomic_set(&pvdev->stream_cnt, 0);
 	video_set_drvdata(pvdev->vdev, pvdev);
+	device_init_wakeup(&pvdev->vdev->dev, 1);
 	goto init_end;
 
 video_register_fail:
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c b/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c
index 4f3094a..9c92a7b 100644
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c
@@ -1153,8 +1153,14 @@
 			 * since for burst case, write masters already skip
 			 * all frames.
 			 */
+			if (stream_info->stream_src == RDI_INTF_0 ||
+				stream_info->stream_src == RDI_INTF_1 ||
+				stream_info->stream_src == RDI_INTF_2)
+				wait_for_complete = 1;
+			else {
 			msm_isp_axi_stream_enable_cfg(vfe_dev, stream_info);
 			stream_info->state = INACTIVE;
+			}
 		} else {
 			wait_for_complete = 1;
 		}
diff --git a/drivers/media/platform/msm/camera_v2/isp/msm_isp_util.c b/drivers/media/platform/msm/camera_v2/isp/msm_isp_util.c
index 5f36a4a..ea0195d 100644
--- a/drivers/media/platform/msm/camera_v2/isp/msm_isp_util.c
+++ b/drivers/media/platform/msm/camera_v2/isp/msm_isp_util.c
@@ -513,7 +513,9 @@
 		}
 		lo_tbl_ptr = cfg_data +
 			reg_cfg_cmd->u.dmi_info.lo_tbl_offset/4;
-
+		if (reg_cfg_cmd->cmd_type == VFE_WRITE_DMI_64BIT)
+			reg_cfg_cmd->u.dmi_info.len =
+				reg_cfg_cmd->u.dmi_info.len / 2;
 		for (i = 0; i < reg_cfg_cmd->u.dmi_info.len/4; i++) {
 			lo_val = *lo_tbl_ptr++;
 			if (reg_cfg_cmd->cmd_type == VFE_WRITE_DMI_16BIT) {
@@ -621,6 +623,12 @@
 		goto reg_cfg_failed;
 	}
 
+	if (!proc_cmd->cmd_len) {
+		pr_err("%s: Passed cmd_len as 0\n", __func__);
+		rc = -EINVAL;
+		goto cfg_data_failed;
+	}
+
 	cfg_data = kzalloc(proc_cmd->cmd_len, GFP_KERNEL);
 	if (!cfg_data) {
 		pr_err("%s: cfg_data alloc failed\n", __func__);
diff --git a/drivers/media/platform/msm/camera_v2/ispif/msm_ispif.c b/drivers/media/platform/msm/camera_v2/ispif/msm_ispif.c
old mode 100644
new mode 100755
index 89016ec..de098c9
--- a/drivers/media/platform/msm/camera_v2/ispif/msm_ispif.c
+++ b/drivers/media/platform/msm/camera_v2/ispif/msm_ispif.c
@@ -200,17 +200,17 @@
 			ispif->base + ISPIF_VFE_m_INTF_CMD_0(i));
 		msm_camera_io_w(ISPIF_STOP_INTF_IMMEDIATELY,
 			ispif->base + ISPIF_VFE_m_INTF_CMD_1(i));
-
+		pr_debug("%s: base %x", __func__, (unsigned int)ispif->base);
 		msm_camera_io_w(0, ispif->base +
 			ISPIF_VFE_m_PIX_INTF_n_CID_MASK(i, 0));
 		msm_camera_io_w(0, ispif->base +
 			ISPIF_VFE_m_PIX_INTF_n_CID_MASK(i, 1));
 		msm_camera_io_w(0, ispif->base +
-			ISPIF_VFE_m_PIX_INTF_n_CID_MASK(i, 0));
+			ISPIF_VFE_m_RDI_INTF_n_CID_MASK(i, 0));
 		msm_camera_io_w(0, ispif->base +
-			ISPIF_VFE_m_PIX_INTF_n_CID_MASK(i, 1));
+			ISPIF_VFE_m_RDI_INTF_n_CID_MASK(i, 1));
 		msm_camera_io_w(0, ispif->base +
-			ISPIF_VFE_m_PIX_INTF_n_CID_MASK(i, 2));
+			ISPIF_VFE_m_RDI_INTF_n_CID_MASK(i, 2));
 
 		msm_camera_io_w(0, ispif->base +
 			ISPIF_VFE_m_PIX_INTF_n_CROP(i, 0));
diff --git a/drivers/media/platform/msm/camera_v2/jpeg_10/msm_jpeg_core.c b/drivers/media/platform/msm/camera_v2/jpeg_10/msm_jpeg_core.c
index 769e2a8..5201134 100644
--- a/drivers/media/platform/msm/camera_v2/jpeg_10/msm_jpeg_core.c
+++ b/drivers/media/platform/msm/camera_v2/jpeg_10/msm_jpeg_core.c
@@ -232,6 +232,7 @@
 			msm_jpeg_irq_handler(
 				MSM_JPEG_HW_MASK_COMP_FRAMEDONE,
 				context, data);
+		pgmn_dev->state = MSM_JPEG_INIT;
 	}
 	if (msm_jpeg_hw_irq_is_reset_ack(jpeg_irq_status)) {
 		data = msm_jpeg_core_reset_ack_irq(jpeg_irq_status,
diff --git a/drivers/media/platform/msm/camera_v2/jpeg_10/msm_jpeg_hw.c b/drivers/media/platform/msm/camera_v2/jpeg_10/msm_jpeg_hw.c
index 0a0fa04..5d34265 100644
--- a/drivers/media/platform/msm/camera_v2/jpeg_10/msm_jpeg_hw.c
+++ b/drivers/media/platform/msm/camera_v2/jpeg_10/msm_jpeg_hw.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2013, The Linux Foundation. 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
@@ -337,6 +337,11 @@
 				__LINE__, hw_cmd_p->offset, max_size);
 			return -EFAULT;
 		}
+		if (hw_cmd_p->offset & 0x3) {
+			JPEG_PR_ERR("%s:%d] %d Invalid alignment\n", __func__,
+					__LINE__, hw_cmd_p->offset);
+			return -EFAULT;
+		}
 
 		switch (hw_cmd_p->type) {
 		case MSM_JPEG_HW_CMD_TYPE_READ:
diff --git a/drivers/media/platform/msm/camera_v2/jpeg_10/msm_jpeg_hw_reg.h b/drivers/media/platform/msm/camera_v2/jpeg_10/msm_jpeg_hw_reg.h
index f970c79..4fbab4b 100644
--- a/drivers/media/platform/msm/camera_v2/jpeg_10/msm_jpeg_hw_reg.h
+++ b/drivers/media/platform/msm/camera_v2/jpeg_10/msm_jpeg_hw_reg.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2013 The Linux Foundation. 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
@@ -55,7 +55,7 @@
 
 #define JPEG_OFFLINE_CMD_START 0x00000001
 
-#define JPEG_RESET_DEFAULT 0x00020000
+#define JPEG_RESET_DEFAULT 0x00032013
 
 #define JPEG_IRQ_DISABLE_ALL 0x00000000
 #define JPEG_IRQ_CLEAR_ALL 0xFFFFFFFF
diff --git a/drivers/media/platform/msm/camera_v2/jpeg_10/msm_jpeg_sync.c b/drivers/media/platform/msm/camera_v2/jpeg_10/msm_jpeg_sync.c
index 80ff9e5..dffdab3 100644
--- a/drivers/media/platform/msm/camera_v2/jpeg_10/msm_jpeg_sync.c
+++ b/drivers/media/platform/msm/camera_v2/jpeg_10/msm_jpeg_sync.c
@@ -669,6 +669,8 @@
 			JPEG_PR_ERR("%s:%d] failed\n", __func__, __LINE__);
 			return -EFAULT;
 		}
+	} else {
+		return is_copy_to_user;
 	}
 
 	return 0;
diff --git a/drivers/media/platform/msm/camera_v2/msm.c b/drivers/media/platform/msm/camera_v2/msm.c
index 1fd1065..c79b3a3 100644
--- a/drivers/media/platform/msm/camera_v2/msm.c
+++ b/drivers/media/platform/msm/camera_v2/msm.c
@@ -438,7 +438,7 @@
 static inline int __msm_destroy_session_streams(void *d1, void *d2)
 {
 	struct msm_stream *stream = d1;
-
+	pr_err("%s: Destroyed here due to list is not empty\n", __func__);
 	INIT_LIST_HEAD(&stream->queued_list);
 	return 0;
 }
@@ -680,9 +680,14 @@
 	}
 
 	/* should wait on session based condition */
-	rc = wait_event_interruptible_timeout(cmd_ack->wait,
-		!list_empty_careful(&cmd_ack->command_q.list),
-		msecs_to_jiffies(timeout));
+	do {
+		rc = wait_event_interruptible_timeout(cmd_ack->wait,
+			!list_empty_careful(&cmd_ack->command_q.list),
+			msecs_to_jiffies(timeout));
+		if (rc != -ERESTARTSYS)
+			break;
+	} while (1);
+
 	if (list_empty_careful(&cmd_ack->command_q.list)) {
 		if (!rc) {
 			pr_err("%s: Timed out\n", __func__);
diff --git a/drivers/media/platform/msm/camera_v2/msm.h b/drivers/media/platform/msm/camera_v2/msm.h
index 46c7d67..32b7222 100644
--- a/drivers/media/platform/msm/camera_v2/msm.h
+++ b/drivers/media/platform/msm/camera_v2/msm.h
@@ -17,7 +17,6 @@
 #include <linux/i2c.h>
 #include <linux/videodev2.h>
 #include <linux/pm_qos.h>
-#include <linux/wakelock.h>
 #include <linux/msm_ion.h>
 #include <linux/iommu.h>
 #include <media/v4l2-dev.h>
diff --git a/drivers/media/platform/msm/camera_v2/msm_buf_mgr/msm_generic_buf_mgr.c b/drivers/media/platform/msm/camera_v2/msm_buf_mgr/msm_generic_buf_mgr.c
index 154ee87..7520ce5 100644
--- a/drivers/media/platform/msm/camera_v2/msm_buf_mgr/msm_generic_buf_mgr.c
+++ b/drivers/media/platform/msm/camera_v2/msm_buf_mgr/msm_generic_buf_mgr.c
@@ -100,6 +100,24 @@
 	return ret;
 }
 
+static void msm_buf_mngr_sd_shutdown(struct msm_buf_mngr_device *buf_mngr_dev)
+{
+	unsigned long flags;
+	struct msm_get_bufs *bufs, *save;
+
+	spin_lock_irqsave(&buf_mngr_dev->buf_q_spinlock, flags);
+	if (!list_empty(&buf_mngr_dev->buf_qhead)) {
+		list_for_each_entry_safe(bufs,
+			save, &buf_mngr_dev->buf_qhead, entry) {
+			pr_err("%s: Delete invalid bufs =%x\n", __func__,
+				(unsigned int)bufs);
+			list_del_init(&bufs->entry);
+			kfree(bufs);
+		}
+	}
+	spin_unlock_irqrestore(&buf_mngr_dev->buf_q_spinlock, flags);
+}
+
 static long msm_buf_mngr_subdev_ioctl(struct v4l2_subdev *sd,
 	unsigned int cmd, void *arg)
 {
@@ -123,6 +141,9 @@
 	case VIDIOC_MSM_BUF_MNGR_PUT_BUF:
 		rc = msm_buf_mngr_put_buf(buf_mngr_dev, argp);
 		break;
+	case MSM_SD_SHUTDOWN:
+		msm_buf_mngr_sd_shutdown(buf_mngr_dev);
+		break;
 	default:
 		return -ENOIOCTLCMD;
 	}
diff --git a/drivers/media/platform/msm/camera_v2/msm_vb2/msm_vb2.c b/drivers/media/platform/msm/camera_v2/msm_vb2/msm_vb2.c
index 8fa8f8d..0fbaeca 100644
--- a/drivers/media/platform/msm/camera_v2/msm_vb2/msm_vb2.c
+++ b/drivers/media/platform/msm/camera_v2/msm_vb2/msm_vb2.c
@@ -251,6 +251,7 @@
 	unsigned long flags;
 	struct msm_vb2_buffer *msm_vb2;
 	struct msm_stream *stream;
+	struct vb2_buffer *vb2_buf = NULL;
 	int rc = 0;
 
 	stream = msm_get_stream(session_id, stream_id);
@@ -258,6 +259,18 @@
 		return 0;
 	spin_lock_irqsave(&stream->stream_lock, flags);
 	if (vb) {
+		list_for_each_entry(msm_vb2, &(stream->queued_list), list) {
+			vb2_buf = &(msm_vb2->vb2_buf);
+			if (vb2_buf == vb)
+				break;
+		}
+		if (vb2_buf != vb) {
+			pr_err("%s:%d VB buffer is INVALID vb=%x, ses_id=%d, str_id=%d\n",
+				__func__, __LINE__, (unsigned int)vb,
+				session_id, stream_id);
+			rc = -EINVAL;
+			goto out;
+		}
 		msm_vb2 =
 			container_of(vb, struct msm_vb2_buffer, vb2_buf);
 		/* put buf before buf done */
@@ -268,10 +281,11 @@
 		} else
 			rc = -EINVAL;
 	} else {
-		pr_err("%s: VB buffer is null\n", __func__);
+		pr_err("%s:%d VB buffer is NULL for ses_id=%d, str_id=%d\n",
+			__func__, __LINE__, session_id, stream_id);
 		rc = -EINVAL;
 	}
-
+out:
 	spin_unlock_irqrestore(&stream->stream_lock, flags);
 	return rc;
 }
diff --git a/drivers/media/platform/msm/camera_v2/pproc/cpp/msm_cpp.c b/drivers/media/platform/msm/camera_v2/pproc/cpp/msm_cpp.c
index 8b8d23b..69f0a3d 100644
--- a/drivers/media/platform/msm/camera_v2/pproc/cpp/msm_cpp.c
+++ b/drivers/media/platform/msm/camera_v2/pproc/cpp/msm_cpp.c
@@ -57,14 +57,12 @@
 };
 
 struct msm_cpp_timer_t {
-	uint8_t used;
+	atomic_t used;
 	struct msm_cpp_timer_data_t data;
 	struct timer_list cpp_timer;
 };
 
-struct msm_cpp_timer_t cpp_timers[2];
-static int del_timer_idx;
-static int set_timer_idx;
+struct msm_cpp_timer_t cpp_timer;
 
 /* dump the frame command before writing to the hardware */
 #define  MSM_CPP_DUMP_FRM_CMD 0
@@ -596,24 +594,20 @@
 				if (msg_id == MSM_CPP_MSG_ID_FRAME_ACK) {
 					CPP_DBG("Frame done!!\n");
 					/* delete CPP timer */
-					CPP_DBG("delete timer %d.\n",
-						del_timer_idx);
-					timer = &cpp_timers[del_timer_idx];
+					CPP_DBG("delete timer.\n");
+					timer = &cpp_timer;
+					atomic_set(&timer->used, 0);
 					del_timer(&timer->cpp_timer);
-					timer->used = 0;
 					timer->data.processed_frame = NULL;
-					del_timer_idx = 1 - del_timer_idx;
 					msm_cpp_notify_frame_done(cpp_dev);
 				} else if (msg_id ==
 					MSM_CPP_MSG_ID_FRAME_NACK) {
 					pr_err("NACK error from hw!!\n");
-					CPP_DBG("delete timer %d.\n",
-						del_timer_idx);
-					timer = &cpp_timers[del_timer_idx];
+					CPP_DBG("delete timer.\n");
+					timer = &cpp_timer;
+					atomic_set(&timer->used, 0);
 					del_timer(&timer->cpp_timer);
-					timer->used = 0;
 					timer->data.processed_frame = NULL;
-					del_timer_idx = 1 - del_timer_idx;
 					msm_cpp_notify_frame_done(cpp_dev);
 				}
 				i += cmd_len + 2;
@@ -926,35 +920,35 @@
 
 	cpp_dev->cpp_open_cnt--;
 	if (cpp_dev->cpp_open_cnt == 0) {
-		pr_err("%s: irq_status: 0x%x\n", __func__,
+		pr_debug("irq_status: 0x%x\n",
 			msm_camera_io_r(cpp_dev->cpp_hw_base + 0x4));
-		pr_err("%s: DEBUG_SP: 0x%x\n", __func__,
+		pr_debug("DEBUG_SP: 0x%x\n",
 			msm_camera_io_r(cpp_dev->cpp_hw_base + 0x40));
-		pr_err("%s: DEBUG_T: 0x%x\n", __func__,
+		pr_debug("DEBUG_T: 0x%x\n",
 			msm_camera_io_r(cpp_dev->cpp_hw_base + 0x44));
-		pr_err("%s: DEBUG_N: 0x%x\n", __func__,
+		pr_debug("DEBUG_N: 0x%x\n",
 			msm_camera_io_r(cpp_dev->cpp_hw_base + 0x48));
-		pr_err("%s: DEBUG_R: 0x%x\n", __func__,
+		pr_debug("DEBUG_R: 0x%x\n",
 			msm_camera_io_r(cpp_dev->cpp_hw_base + 0x4C));
-		pr_err("%s: DEBUG_OPPC: 0x%x\n", __func__,
+		pr_debug("DEBUG_OPPC: 0x%x\n",
 			msm_camera_io_r(cpp_dev->cpp_hw_base + 0x50));
-		pr_err("%s: DEBUG_MO: 0x%x\n", __func__,
+		pr_debug("DEBUG_MO: 0x%x\n",
 			msm_camera_io_r(cpp_dev->cpp_hw_base + 0x54));
-		pr_err("%s: DEBUG_TIMER0: 0x%x\n", __func__,
+		pr_debug("DEBUG_TIMER0: 0x%x\n",
 			msm_camera_io_r(cpp_dev->cpp_hw_base + 0x60));
-		pr_err("%s: DEBUG_TIMER1: 0x%x\n", __func__,
+		pr_debug("DEBUG_TIMER1: 0x%x\n",
 			msm_camera_io_r(cpp_dev->cpp_hw_base + 0x64));
-		pr_err("%s: DEBUG_GPI: 0x%x\n", __func__,
+		pr_debug("DEBUG_GPI: 0x%x\n",
 			msm_camera_io_r(cpp_dev->cpp_hw_base + 0x70));
-		pr_err("%s: DEBUG_GPO: 0x%x\n", __func__,
+		pr_debug("DEBUG_GPO: 0x%x\n",
 			msm_camera_io_r(cpp_dev->cpp_hw_base + 0x74));
-		pr_err("%s: DEBUG_T0: 0x%x\n", __func__,
+		pr_debug("DEBUG_T0: 0x%x\n",
 			msm_camera_io_r(cpp_dev->cpp_hw_base + 0x80));
-		pr_err("%s: DEBUG_R0: 0x%x\n", __func__,
+		pr_debug("DEBUG_R0: 0x%x\n",
 			msm_camera_io_r(cpp_dev->cpp_hw_base + 0x84));
-		pr_err("%s: DEBUG_T1: 0x%x\n", __func__,
+		pr_debug("DEBUG_T1: 0x%x\n",
 			msm_camera_io_r(cpp_dev->cpp_hw_base + 0x88));
-		pr_err("%s: DEBUG_R1: 0x%x\n", __func__,
+		pr_debug("DEBUG_R1: 0x%x\n",
 			msm_camera_io_r(cpp_dev->cpp_hw_base + 0x8C));
 		msm_camera_io_w(0x0, cpp_dev->base + MSM_CPP_MICRO_CLKEN_CTL);
 		cpp_deinit_mem(cpp_dev);
@@ -1077,97 +1071,62 @@
 {
 	int ret;
 	uint32_t i = 0;
-	struct msm_cpp_frame_info_t *this_frame =
-		cpp_timers[del_timer_idx].data.processed_frame;
-	struct msm_cpp_frame_info_t *second_frame = NULL;
+	struct msm_cpp_frame_info_t *this_frame = NULL;
 
-	pr_err("cpp_timer_callback called idx:%d. (jiffies=%lu)\n",
-		del_timer_idx, jiffies);
-	if (!work || !this_frame) {
-		pr_err("Invalid work:%p, this_frame:%p, del_idx:%d\n",
-			work, this_frame, del_timer_idx);
+	pr_err("cpp_timer_callback called. (jiffies=%lu)\n",
+		jiffies);
+	if (!work) {
+		pr_err("Invalid work:%p\n", work);
 		return;
 	}
-	pr_err("fatal: cpp_timer expired for identity=0x%x, frame_id=%03d",
-		this_frame->identity, this_frame->frame_id);
-	cpp_timers[del_timer_idx].used = 0;
-	cpp_timers[del_timer_idx].data.processed_frame = NULL;
-	del_timer_idx = 1 - del_timer_idx;
-
-	if (cpp_timers[del_timer_idx].used == 1) {
-		pr_err("deleting cpp_timer %d.\n", del_timer_idx);
-		del_timer(&cpp_timers[del_timer_idx].cpp_timer);
-		cpp_timers[del_timer_idx].used = 0;
-		second_frame = cpp_timers[del_timer_idx].data.processed_frame;
-		cpp_timers[del_timer_idx].data.processed_frame = NULL;
-		del_timer_idx = 1 - del_timer_idx;
+	if (!atomic_read(&cpp_timer.used)) {
+		pr_err("Delayed trigger, IRQ serviced\n");
+		return;
 	}
 
-	disable_irq(cpp_timers[del_timer_idx].data.cpp_dev->irq->start);
+	disable_irq(cpp_timer.data.cpp_dev->irq->start);
 	pr_err("Reloading firmware\n");
-	cpp_load_fw(cpp_timers[del_timer_idx].data.cpp_dev, NULL);
+	cpp_load_fw(cpp_timer.data.cpp_dev, NULL);
 	pr_err("Firmware loading done\n");
-	enable_irq(cpp_timers[del_timer_idx].data.cpp_dev->irq->start);
-	msm_camera_io_w_mb(0x8, cpp_timers[del_timer_idx].data.cpp_dev->base +
+	enable_irq(cpp_timer.data.cpp_dev->irq->start);
+	msm_camera_io_w_mb(0x8, cpp_timer.data.cpp_dev->base +
 		MSM_CPP_MICRO_IRQGEN_MASK);
 	msm_camera_io_w_mb(0xFFFF,
-		cpp_timers[del_timer_idx].data.cpp_dev->base +
+		cpp_timer.data.cpp_dev->base +
 		MSM_CPP_MICRO_IRQGEN_CLR);
 
-	cpp_timers[set_timer_idx].data.processed_frame = this_frame;
-	cpp_timers[set_timer_idx].used = 1;
-	pr_err("ReInstalling cpp_timer %d\n", set_timer_idx);
-	setup_timer(&cpp_timers[set_timer_idx].cpp_timer, cpp_timer_callback,
-		(unsigned long)&cpp_timers[0]);
+	if (!atomic_read(&cpp_timer.used)) {
+		pr_err("Delayed trigger, IRQ serviced\n");
+		return;
+	}
+
+	this_frame = cpp_timer.data.processed_frame;
+	pr_err("ReInstalling cpp_timer\n");
+	setup_timer(&cpp_timer.cpp_timer, cpp_timer_callback,
+		(unsigned long)&cpp_timer);
 	pr_err("Starting timer to fire in %d ms. (jiffies=%lu)\n",
 		CPP_CMD_TIMEOUT_MS, jiffies);
-	ret = mod_timer(&cpp_timers[set_timer_idx].cpp_timer,
+	ret = mod_timer(&cpp_timer.cpp_timer,
 		jiffies + msecs_to_jiffies(CPP_CMD_TIMEOUT_MS));
 	if (ret)
 		pr_err("error in mod_timer\n");
 
-	set_timer_idx = 1 - set_timer_idx;
-	pr_err("Rescheduling for identity=0x%x, frame_id=%03d",
+	pr_err("Rescheduling for identity=0x%x, frame_id=%03d\n",
 		this_frame->identity, this_frame->frame_id);
-	msm_cpp_write(0x6, cpp_timers[set_timer_idx].data.cpp_dev->base);
+	msm_cpp_write(0x6, cpp_timer.data.cpp_dev->base);
 	msm_cpp_dump_frame_cmd(this_frame->cpp_cmd_msg,
 		this_frame->msg_len);
 	for (i = 0; i < this_frame->msg_len; i++)
 		msm_cpp_write(this_frame->cpp_cmd_msg[i],
-			cpp_timers[set_timer_idx].data.cpp_dev->base);
-
-
-	if (second_frame != NULL) {
-		cpp_timers[set_timer_idx].data.processed_frame = second_frame;
-		cpp_timers[set_timer_idx].used = 1;
-		pr_err("ReInstalling cpp_timer %d\n", set_timer_idx);
-		setup_timer(&cpp_timers[set_timer_idx].cpp_timer,
-			cpp_timer_callback, (unsigned long)&cpp_timers[0]);
-		pr_err("Starting timer to fire in %d ms. (jiffies=%lu)\n",
-			CPP_CMD_TIMEOUT_MS, jiffies);
-		ret = mod_timer(&cpp_timers[set_timer_idx].cpp_timer,
-			jiffies + msecs_to_jiffies(CPP_CMD_TIMEOUT_MS));
-		if (ret)
-			pr_err("error in mod_timer\n");
-
-		set_timer_idx = 1 - set_timer_idx;
-		pr_err("Rescheduling for identity=0x%x, frame_id=%03d",
-			second_frame->identity, second_frame->frame_id);
-		msm_cpp_write(0x6,
-			cpp_timers[set_timer_idx].data.cpp_dev->base);
-		msm_cpp_dump_frame_cmd(second_frame->cpp_cmd_msg,
-			second_frame->msg_len);
-		for (i = 0; i < second_frame->msg_len; i++)
-			msm_cpp_write(second_frame->cpp_cmd_msg[i],
-				cpp_timers[set_timer_idx].data.cpp_dev->base);
-	}
+			cpp_timer.data.cpp_dev->base);
+	return;
 }
 
 void cpp_timer_callback(unsigned long data)
 {
 	struct msm_cpp_work_t *work =
-		cpp_timers[set_timer_idx].data.cpp_dev->work;
-	queue_work(cpp_timers[set_timer_idx].data.cpp_dev->timer_wq,
+		cpp_timer.data.cpp_dev->work;
+	queue_work(cpp_timer.data.cpp_dev->timer_wq,
 		(struct work_struct *)work);
 }
 
@@ -1184,21 +1143,19 @@
 		msm_enqueue(&cpp_dev->processing_q,
 					&frame_qcmd->list_frame);
 
-		cpp_timers[set_timer_idx].data.processed_frame = process_frame;
-		cpp_timers[set_timer_idx].used = 1;
+		cpp_timer.data.processed_frame = process_frame;
+		atomic_set(&cpp_timer.used, 1);
 		/* install timer for cpp timeout */
-		CPP_DBG("Installing cpp_timer %d\n", set_timer_idx);
-		setup_timer(&cpp_timers[set_timer_idx].cpp_timer,
-			cpp_timer_callback, (unsigned long)&cpp_timers[0]);
+		CPP_DBG("Installing cpp_timer\n");
+		setup_timer(&cpp_timer.cpp_timer,
+			cpp_timer_callback, (unsigned long)&cpp_timer);
 		CPP_DBG("Starting timer to fire in %d ms. (jiffies=%lu)\n",
 			CPP_CMD_TIMEOUT_MS, jiffies);
-		ret = mod_timer(&cpp_timers[set_timer_idx].cpp_timer,
+		ret = mod_timer(&cpp_timer.cpp_timer,
 			jiffies + msecs_to_jiffies(CPP_CMD_TIMEOUT_MS));
 		if (ret)
 			pr_err("error in mod_timer\n");
 
-		set_timer_idx = 1 - set_timer_idx;
-
 		msm_cpp_write(0x6, cpp_dev->base);
 		msm_cpp_dump_frame_cmd(process_frame->cpp_cmd_msg,
 				process_frame->msg_len);
@@ -1285,8 +1242,8 @@
 
 	in_phyaddr = msm_cpp_fetch_buffer_info(cpp_dev,
 		&new_frame->input_buffer_info,
-		((new_frame->identity >> 16) & 0xFFFF),
-		(new_frame->identity & 0xFFFF), &in_fd);
+		((new_frame->input_buffer_info.identity >> 16) & 0xFFFF),
+		(new_frame->input_buffer_info.identity & 0xFFFF), &in_fd);
 	if (!in_phyaddr) {
 		pr_err("error gettting input physical address\n");
 		rc = -EINVAL;
@@ -1712,6 +1669,7 @@
 		struct cpp_device *cpp_dev = v4l2_get_subdevdata(sd);
 		struct msm_camera_v4l2_ioctl_t *ioctl_ptr = arg;
 		struct msm_cpp_frame_info_t inst_info;
+		memset(&inst_info, 0, sizeof(struct msm_cpp_frame_info_t));
 		for (i = 0; i < MAX_ACTIVE_CPP_INSTANCE; i++) {
 			if (cpp_dev->cpp_subscribe_list[i].vfh == vfh) {
 				inst_info.inst_id = i;
@@ -1890,10 +1848,8 @@
 	INIT_WORK((struct work_struct *)cpp_dev->work, msm_cpp_do_timeout_work);
 	cpp_dev->cpp_open_cnt = 0;
 	cpp_dev->is_firmware_loaded = 0;
-	cpp_timers[0].data.cpp_dev = cpp_dev;
-	cpp_timers[1].data.cpp_dev = cpp_dev;
-	cpp_timers[0].used = 0;
-	cpp_timers[1].used = 0;
+	cpp_timer.data.cpp_dev = cpp_dev;
+	atomic_set(&cpp_timer.used, 0);
 	cpp_dev->fw_name_bin = NULL;
 	return rc;
 ERROR3:
diff --git a/drivers/media/platform/msm/camera_v2/pproc/vpe/msm_vpe.c b/drivers/media/platform/msm/camera_v2/pproc/vpe/msm_vpe.c
index 3aaff78..dc29199 100644
--- a/drivers/media/platform/msm/camera_v2/pproc/vpe/msm_vpe.c
+++ b/drivers/media/platform/msm/camera_v2/pproc/vpe/msm_vpe.c
@@ -1282,6 +1282,15 @@
 			return -EINVAL;
 		}
 
+		if ((u_stream_buff_info->num_buffs == 0) ||
+			(u_stream_buff_info->num_buffs >
+				MSM_CAMERA_MAX_STREAM_BUF)) {
+			pr_err("%s:%d: Invalid number of buffers\n", __func__,
+				__LINE__);
+			kfree(u_stream_buff_info);
+			mutex_unlock(&vpe_dev->mutex);
+			return -EINVAL;
+		}
 		k_stream_buff_info.num_buffs = u_stream_buff_info->num_buffs;
 		k_stream_buff_info.identity = u_stream_buff_info->identity;
 		k_stream_buff_info.buffer_info =
@@ -1425,6 +1434,7 @@
 		struct vpe_device *vpe_dev = v4l2_get_subdevdata(sd);
 		struct msm_camera_v4l2_ioctl_t *ioctl_ptr = arg;
 		struct msm_vpe_frame_info_t inst_info;
+		memset(&inst_info, 0, sizeof(struct msm_vpe_frame_info_t));
 		for (i = 0; i < MAX_ACTIVE_VPE_INSTANCE; i++) {
 			if (vpe_dev->vpe_subscribe_list[i].vfh == vfh) {
 				inst_info.inst_id = i;
diff --git a/drivers/media/platform/msm/camera_v2/sensor/actuator/msm_actuator.c b/drivers/media/platform/msm/camera_v2/sensor/actuator/msm_actuator.c
index 16a1616..bb2b074 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/actuator/msm_actuator.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/actuator/msm_actuator.c
@@ -79,6 +79,11 @@
 	struct msm_camera_i2c_reg_array *i2c_tbl = a_ctrl->i2c_reg_tbl;
 	CDBG("Enter\n");
 	for (i = 0; i < size; i++) {
+		/* check that the index into i2c_tbl cannot grow larger that
+		the allocated size of i2c_tbl */
+		if ((a_ctrl->total_steps + 1) < (a_ctrl->i2c_tbl_index)) {
+			break;
+		}
 		if (write_arr[i].reg_write_type == MSM_ACTUATOR_WRITE_DAC) {
 			value = (next_lens_position <<
 				write_arr[i].data_shift) |
@@ -196,11 +201,19 @@
 	struct msm_actuator_move_params_t *move_params)
 {
 	int32_t dest_step_position = move_params->dest_step_pos;
+	struct damping_params_t ringing_params_kernel;
 	int32_t rc = 0;
 	int32_t num_steps = move_params->num_steps;
 	struct msm_camera_i2c_reg_setting reg_setting;
 	CDBG("Enter\n");
 
+	if (copy_from_user(&ringing_params_kernel,
+		&(move_params->ringing_params[0]),
+		sizeof(struct damping_params_t))) {
+		pr_err("copy_from_user failed\n");
+		return -EFAULT;
+	}
+
 	if (num_steps == 0)
 		return rc;
 
@@ -208,7 +221,7 @@
 	a_ctrl->func_tbl->actuator_parse_i2c_params(a_ctrl,
 		(num_steps *
 		a_ctrl->region_params[0].code_per_step),
-		move_params->ringing_params[0].hw_params, 0);
+		ringing_params_kernel.hw_params, 0);
 
 	reg_setting.reg_setting = a_ctrl->i2c_reg_tbl;
 	reg_setting.data_type = a_ctrl->i2c_data_type;
@@ -230,6 +243,7 @@
 	struct msm_actuator_move_params_t *move_params)
 {
 	int32_t rc = 0;
+	struct damping_params_t ringing_params_kernel;
 	int8_t sign_dir = move_params->sign_dir;
 	uint16_t step_boundary = 0;
 	uint16_t target_step_pos = 0;
@@ -240,6 +254,14 @@
 	int32_t num_steps = move_params->num_steps;
 	struct msm_camera_i2c_reg_setting reg_setting;
 
+	if (copy_from_user(&ringing_params_kernel,
+		&(move_params->ringing_params[a_ctrl->curr_region_index]),
+		sizeof(struct damping_params_t))) {
+		pr_err("copy_from_user failed\n");
+		return -EFAULT;
+	}
+
+
 	CDBG("called, dir %d, num_steps %d\n", dir, num_steps);
 
 	if (dest_step_pos == a_ctrl->curr_step_pos)
@@ -262,9 +284,7 @@
 				a_ctrl->step_position_table[target_step_pos];
 			a_ctrl->func_tbl->actuator_write_focus(a_ctrl,
 					curr_lens_pos,
-					&(move_params->
-						ringing_params[a_ctrl->
-						curr_region_index]),
+					&ringing_params_kernel,
 					sign_dir,
 					target_lens_pos);
 			curr_lens_pos = target_lens_pos;
@@ -275,8 +295,7 @@
 				a_ctrl->step_position_table[target_step_pos];
 			a_ctrl->func_tbl->actuator_write_focus(a_ctrl,
 					curr_lens_pos,
-					&(move_params->ringing_params[a_ctrl->
-						curr_region_index]),
+					&ringing_params_kernel,
 					sign_dir,
 					target_lens_pos);
 			curr_lens_pos = target_lens_pos;
@@ -437,8 +456,11 @@
 
 	a_ctrl->i2c_data_type = set_info->actuator_params.i2c_data_type;
 	a_ctrl->i2c_client.addr_type = set_info->actuator_params.i2c_addr_type;
-	a_ctrl->reg_tbl_size = set_info->actuator_params.reg_tbl_size;
-	if (a_ctrl->reg_tbl_size > MAX_ACTUATOR_REG_TBL_SIZE) {
+	if (set_info->actuator_params.reg_tbl_size <=
+		MAX_ACTUATOR_REG_TBL_SIZE) {
+		a_ctrl->reg_tbl_size = set_info->actuator_params.reg_tbl_size;
+	} else {
+		a_ctrl->reg_tbl_size = 0;
 		pr_err("MAX_ACTUATOR_REG_TBL_SIZE is exceeded.\n");
 		return -EFAULT;
 	}
diff --git a/drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.c b/drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.c
index 968dcd7..4e1f73e 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.c
@@ -95,7 +95,7 @@
 static void msm_cci_flush_queue(struct cci_device *cci_dev,
 	enum cci_i2c_master_t master)
 {
-	uint32_t rc = 0;
+	int32_t rc = 0;
 
 	msm_camera_io_w(1 << master, cci_dev->base + CCI_HALT_REQ_ADDR);
 	rc = wait_for_completion_interruptible_timeout(
@@ -479,7 +479,8 @@
 		return -EINVAL;
 	}
 
-	if (c_ctrl->cci_info->cci_i2c_master > MASTER_MAX) {
+	if (c_ctrl->cci_info->cci_i2c_master > MASTER_MAX
+			|| c_ctrl->cci_info->cci_i2c_master < 0) {
 		pr_err("%s:%d Invalid I2C master addr\n", __func__, __LINE__);
 		return -EINVAL;
 	}
@@ -524,7 +525,8 @@
 	enum cci_i2c_master_t master;
 	enum cci_i2c_queue_t queue = QUEUE_0;
 	cci_dev = v4l2_get_subdevdata(sd);
-	if (c_ctrl->cci_info->cci_i2c_master > MASTER_MAX) {
+	if (c_ctrl->cci_info->cci_i2c_master > MASTER_MAX
+			|| c_ctrl->cci_info->cci_i2c_master < 0) {
 		pr_err("%s:%d Invalid I2C master addr\n", __func__, __LINE__);
 		return -EINVAL;
 	}
@@ -645,7 +647,7 @@
 static int32_t msm_cci_init(struct v4l2_subdev *sd,
 	struct msm_camera_cci_ctrl *c_ctrl)
 {
-	int rc = 0;
+	int32_t rc = 0;
 	struct cci_device *cci_dev;
 	enum cci_i2c_master_t master;
 	cci_dev = v4l2_get_subdevdata(sd);
@@ -661,7 +663,7 @@
 		CDBG("%s ref_count %d\n", __func__, cci_dev->ref_count);
 		master = c_ctrl->cci_info->cci_i2c_master;
 		CDBG("%s:%d master %d\n", __func__, __LINE__, master);
-		if (master < MASTER_MAX) {
+		if (master < MASTER_MAX && master >= 0) {
 			mutex_lock(&cci_dev->cci_master_info[master].mutex);
 			/* Set reset pending flag to TRUE */
 			cci_dev->cci_master_info[master].reset_pending = TRUE;
diff --git a/drivers/media/platform/msm/camera_v2/sensor/csiphy/msm_csiphy.c b/drivers/media/platform/msm/camera_v2/sensor/csiphy/msm_csiphy.c
old mode 100644
new mode 100755
index 9384a5b..d8608ae
--- a/drivers/media/platform/msm/camera_v2/sensor/csiphy/msm_csiphy.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/csiphy/msm_csiphy.c
@@ -177,6 +177,7 @@
 static struct msm_cam_clk_info csiphy_8610_clk_info[] = {
 	{"csiphy_timer_src_clk", 200000000},
 	{"csiphy_timer_clk", -1},
+	{"csi_ahb_clk", -1},
 };
 
 static struct msm_cam_clk_info csiphy_8974_clk_info[] = {
diff --git a/drivers/media/platform/msm/camera_v2/sensor/eeprom/msm_eeprom.c b/drivers/media/platform/msm/camera_v2/sensor/eeprom/msm_eeprom.c
index 7f13568..45db19c 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/eeprom/msm_eeprom.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/eeprom/msm_eeprom.c
@@ -48,10 +48,12 @@
 			e_ctrl->num_bytes;
 		break;
 	case CFG_EEPROM_READ_CAL_DATA:
-		CDBG("%s E CFG_EEPROM_READ_CAL_DATA\n", __func__);
-		rc = copy_to_user(cdata->cfg.read_data.dbuffer,
+		if (cdata->cfg.read_data.num_bytes <= e_ctrl->num_bytes) {
+			CDBG("%s E CFG_EEPROM_READ_CAL_DATA\n", __func__);
+			rc = copy_to_user(cdata->cfg.read_data.dbuffer,
 			e_ctrl->memory_data,
 			cdata->cfg.read_data.num_bytes);
+		}
 		break;
 	default:
 		break;
diff --git a/drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_flash.h b/drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_flash.h
index 9f3a81c..a4d7f15 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_flash.h
+++ b/drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_flash.h
@@ -53,9 +53,11 @@
 	const char *flash_trigger_name[MAX_LED_TRIGGERS];
 	struct led_trigger *flash_trigger[MAX_LED_TRIGGERS];
 	uint32_t flash_op_current[MAX_LED_TRIGGERS];
+	uint32_t flash_max_current[MAX_LED_TRIGGERS];
 	const char *torch_trigger_name;
 	struct led_trigger *torch_trigger;
 	uint32_t torch_op_current;
+	uint32_t torch_max_current;
 	void *data;
 	uint32_t num_sources;
 	enum msm_camera_device_type_t flash_device_type;
diff --git a/drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_trigger.c b/drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_trigger.c
index 20905c9..699142a 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_trigger.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/flash/msm_led_trigger.c
@@ -29,6 +29,7 @@
 extern int32_t msm_led_torch_create_classdev(
 				struct platform_device *pdev, void *data);
 
+static enum flash_type flashtype;
 static struct msm_led_flash_ctrl_t fctrl;
 
 static int32_t msm_led_trigger_get_subdev_id(struct msm_led_flash_ctrl_t *fctrl,
@@ -50,6 +51,7 @@
 	int rc = 0;
 	struct msm_camera_led_cfg_t *cfg = (struct msm_camera_led_cfg_t *)data;
 	uint32_t i;
+	uint32_t curr_l, max_curr_l;
 	CDBG("called led_state %d\n", cfg->cfgtype);
 
 	if (!fctrl) {
@@ -67,18 +69,38 @@
 		break;
 
 	case MSM_CAMERA_LED_LOW:
-		if (fctrl->torch_trigger)
+		if (fctrl->torch_trigger) {
+			max_curr_l = fctrl->torch_max_current;
+			if (cfg->led_current > 0 &&
+					cfg->led_current < max_curr_l) {
+				curr_l = cfg->led_current;
+			} else {
+				curr_l = fctrl->torch_op_current;
+				pr_err("LED current clamped to %d\n",
+					curr_l);
+			}
 			led_trigger_event(fctrl->torch_trigger,
-				fctrl->torch_op_current);
+				curr_l);
+		}
 		break;
 
 	case MSM_CAMERA_LED_HIGH:
 		if (fctrl->torch_trigger)
 			led_trigger_event(fctrl->torch_trigger, 0);
 		for (i = 0; i < fctrl->num_sources; i++)
-			if (fctrl->flash_trigger[i])
+			if (fctrl->flash_trigger[i]) {
+				max_curr_l = fctrl->flash_max_current[i];
+				if (cfg->led_current > 0 &&
+						cfg->led_current < max_curr_l) {
+					curr_l = cfg->led_current;
+				} else {
+					curr_l = fctrl->flash_op_current[i];
+					pr_err("LED current clamped to %d\n",
+						curr_l);
+				}
 				led_trigger_event(fctrl->flash_trigger[i],
-					fctrl->flash_op_current[i]);
+					curr_l);
+			}
 		break;
 
 	case MSM_CAMERA_LED_INIT:
@@ -115,10 +137,11 @@
 
 static int32_t msm_led_trigger_probe(struct platform_device *pdev)
 {
-	int32_t rc = 0, i = 0;
+	int32_t rc = 0, rc_1 = 0, i = 0;
 	struct device_node *of_node = pdev->dev.of_node;
 	struct device_node *flash_src_node = NULL;
 	uint32_t count = 0;
+	struct led_trigger *temp = NULL;
 
 	CDBG("called\n");
 
@@ -137,11 +160,18 @@
 	}
 	CDBG("pdev id %d\n", pdev->id);
 
+	rc = of_property_read_u32(of_node,
+			"qcom,flash-type", &flashtype);
+	if (rc < 0) {
+		pr_err("flash-type: read failed\n");
+		return -EINVAL;
+	}
+
 	if (of_get_property(of_node, "qcom,flash-source", &count)) {
 		count /= sizeof(uint32_t);
 		CDBG("count %d\n", count);
 		if (count > MAX_LED_TRIGGERS) {
-			pr_err("failed\n");
+			pr_err("invalid count\n");
 			return -EINVAL;
 		}
 		fctrl.num_sources = count;
@@ -157,7 +187,7 @@
 				"linux,default-trigger",
 				&fctrl.flash_trigger_name[i]);
 			if (rc < 0) {
-				pr_err("failed\n");
+				pr_err("default-trigger: read failed\n");
 				of_node_put(flash_src_node);
 				continue;
 			}
@@ -165,12 +195,21 @@
 			CDBG("default trigger %s\n",
 				fctrl.flash_trigger_name[i]);
 
-			rc = of_property_read_u32(flash_src_node,
-				"qcom,current", &fctrl.flash_op_current[i]);
-			if (rc < 0) {
-				pr_err("failed rc %d\n", rc);
-				of_node_put(flash_src_node);
-				continue;
+			if (flashtype == GPIO_FLASH) {
+				/* use fake current */
+				fctrl.flash_op_current[i] = LED_FULL;
+			} else {
+				rc = of_property_read_u32(flash_src_node,
+					"qcom,current",
+					&fctrl.flash_op_current[i]);
+				rc_1 = of_property_read_u32(flash_src_node,
+					"qcom,max-current",
+					&fctrl.flash_max_current[i]);
+				if ((rc < 0) || (rc_1 < 0)) {
+					pr_err("current: read failed\n");
+					of_node_put(flash_src_node);
+					continue;
+				}
 			}
 
 			of_node_put(flash_src_node);
@@ -180,6 +219,10 @@
 
 			led_trigger_register_simple(fctrl.flash_trigger_name[i],
 				&fctrl.flash_trigger[i]);
+
+			if (flashtype == GPIO_FLASH)
+				if (fctrl.flash_trigger[i])
+					temp = fctrl.flash_trigger[i];
 		}
 
 		/* Torch source */
@@ -190,25 +233,43 @@
 				"linux,default-trigger",
 				&fctrl.torch_trigger_name);
 			if (rc < 0) {
-				pr_err("failed\n");
-			} else {
-				CDBG("default trigger %s\n",
-					fctrl.torch_trigger_name);
+				pr_err("default-trigger: read failed\n");
+				goto torch_failed;
+			}
 
-				rc = of_property_read_u32(flash_src_node,
-					"qcom,current",
-					&fctrl.torch_op_current);
-				if (rc < 0) {
-					pr_err("failed rc %d\n", rc);
-				} else {
-					CDBG("torch max_current %d\n",
-						fctrl.torch_op_current);
+			CDBG("default trigger %s\n",
+				fctrl.torch_trigger_name);
 
+			if (flashtype == GPIO_FLASH) {
+				/* use fake current */
+				fctrl.torch_op_current = LED_FULL;
+				if (temp)
+					fctrl.torch_trigger = temp;
+				else
 					led_trigger_register_simple(
 						fctrl.torch_trigger_name,
 						&fctrl.torch_trigger);
+			} else {
+				rc = of_property_read_u32(flash_src_node,
+					"qcom,current",
+					&fctrl.torch_op_current);
+				rc_1 = of_property_read_u32(flash_src_node,
+					"qcom,max-current",
+					&fctrl.torch_max_current);
+
+				if ((rc < 0) || (rc_1 < 0)) {
+					pr_err("current: read failed\n");
+					goto torch_failed;
 				}
+
+				CDBG("torch max_current %d\n",
+					fctrl.torch_op_current);
+
+				led_trigger_register_simple(
+					fctrl.torch_trigger_name,
+					&fctrl.torch_trigger);
 			}
+torch_failed:
 			of_node_put(flash_src_node);
 		}
 	}
diff --git a/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_dt_util.c b/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_dt_util.c
index 484dd69..336c922 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_dt_util.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/io/msm_camera_dt_util.c
@@ -669,7 +669,9 @@
 			}
 			gpio_set_value_cansleep(
 				ctrl->gpio_conf->gpio_num_info->gpio_num
-				[power_setting->seq_val], GPIOF_OUT_INIT_LOW);
+				[power_setting->seq_val],
+				ctrl->gpio_conf->gpio_num_info->gpio_num
+				[power_setting->config_val]);
 			break;
 		case SENSOR_VREG:
 			if (power_setting->seq_val >= CAM_VREG_MAX) {
diff --git a/drivers/media/platform/msm/camera_v2/sensor/msm_sensor.c b/drivers/media/platform/msm/camera_v2/sensor/msm_sensor.c
index 0083378..03145c8 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/msm_sensor.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/msm_sensor.c
@@ -1797,6 +1797,8 @@
 		(struct msm_sensor_ctrl_t *)data;
 	struct msm_camera_cci_client *cci_client = NULL;
 	uint32_t session_id;
+	unsigned long mount_pos;
+
 	s_ctrl->pdev = pdev;
 	s_ctrl->dev = &pdev->dev;
 	CDBG("%s called data %p\n", __func__, data);
@@ -1862,6 +1864,11 @@
 	s_ctrl->msm_sd.sd.entity.group_id = MSM_CAMERA_SUBDEV_SENSOR;
 	s_ctrl->msm_sd.sd.entity.name =
 		s_ctrl->msm_sd.sd.name;
+	mount_pos = s_ctrl->sensordata->sensor_init_params->position;
+	mount_pos = mount_pos << 8;
+	mount_pos = mount_pos |
+	(s_ctrl->sensordata->sensor_init_params->sensor_mount_angle / 90);
+	s_ctrl->msm_sd.sd.entity.flags = mount_pos;
 
 	rc = camera_init_v4l2(&s_ctrl->pdev->dev, &session_id);
 	CDBG("%s rc %d session_id %d\n", __func__, rc, session_id);
@@ -1880,6 +1887,8 @@
 {
 	int rc = 0;
 	uint32_t session_id;
+	unsigned long mount_pos;
+
 	CDBG("%s %s_i2c_probe called\n", __func__, client->name);
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
 		pr_err("%s %s i2c_check_functionality failed\n",
@@ -1976,6 +1985,12 @@
 	s_ctrl->msm_sd.sd.entity.name =
 		s_ctrl->msm_sd.sd.name;
 
+	mount_pos = s_ctrl->sensordata->sensor_init_params->position;
+	mount_pos = mount_pos << 8;
+	mount_pos = mount_pos |
+	(s_ctrl->sensordata->sensor_init_params->sensor_mount_angle / 90);
+	s_ctrl->msm_sd.sd.entity.flags = mount_pos;
+
 	rc = camera_init_v4l2(&s_ctrl->sensor_i2c_client->client->dev,
 		&session_id);
 	CDBG("%s rc %d session_id %d\n", __func__, rc, session_id);
diff --git a/drivers/media/platform/msm/camera_v2/sensor/sp1628.c b/drivers/media/platform/msm/camera_v2/sensor/sp1628.c
old mode 100644
new mode 100755
index 82e4b7c..9a422c0
--- a/drivers/media/platform/msm/camera_v2/sensor/sp1628.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/sp1628.c
@@ -866,6 +866,42 @@
 		}
 		break;
 	}
+	case CFG_SET_SATURATION: {
+
+		break;
+	}
+	case CFG_SET_CONTRAST: {
+
+		break;
+	}
+	case CFG_SET_SHARPNESS: {
+
+		break;
+	}
+	case CFG_SET_ISO: {
+
+		break;
+	}
+	case CFG_SET_EXPOSURE_COMPENSATION: {
+
+		break;
+	}
+	case CFG_SET_EFFECT: {
+
+		break;
+	}
+	case CFG_SET_ANTIBANDING: {
+
+		break;
+	}
+	case CFG_SET_BESTSHOT_MODE: {
+
+		break;
+	}
+	case CFG_SET_WHITE_BALANCE: {
+
+		break;
+	}
 	default:
 		rc = -EFAULT;
 		break;
diff --git a/drivers/media/platform/msm/dvb/demux/mpq_dmx_plugin_common.c b/drivers/media/platform/msm/dvb/demux/mpq_dmx_plugin_common.c
index 2bc460b..d3b9c0a 100644
--- a/drivers/media/platform/msm/dvb/demux/mpq_dmx_plugin_common.c
+++ b/drivers/media/platform/msm/dvb/demux/mpq_dmx_plugin_common.c
@@ -2096,7 +2096,7 @@
 {
 	int left_size, copy_len;
 
-	/* Remainning header bytes that need to be processed? */
+	/* Remaining header bytes that need to be processed? */
 	if (!feed_data->pes_header_left_bytes)
 		return 0;
 
@@ -4036,6 +4036,13 @@
 				__func__);
 			return ret;
 		}
+
+		if (mpq_feed->sdmx_filter_handle ==
+			SDMX_INVALID_FILTER_HANDLE) {
+			MPQ_DVB_DBG_PRINT("%s: filter was stopped\n",
+				__func__);
+			return -ENODEV;
+		}
 	}
 
 	if (mpq_feed->sdmx_buf.pread + header->payload_length <
@@ -4089,6 +4096,13 @@
 
 		mutex_lock(&mpq_demux->mutex);
 
+		if (mpq_feed->sdmx_filter_handle ==
+			SDMX_INVALID_FILTER_HANDLE) {
+			MPQ_DVB_DBG_PRINT("%s: filter was stopped\n",
+					__func__);
+			return -ENODEV;
+		}
+
 		return ret;
 	}
 
@@ -4107,7 +4121,8 @@
 	struct dmx_data_ready pes_event;
 	struct dvb_demux_feed *feed = mpq_feed->dvb_demux_feed;
 	struct dvb_ringbuffer *buf = (struct dvb_ringbuffer *)
-				feed->feed.ts.buffer.ringbuff;
+		feed->feed.ts.buffer.ringbuff;
+	ssize_t bytes_avail;
 
 	if ((!sts->metadata_fill_count) && (!sts->data_fill_count))
 		goto pes_filter_check_overflow;
@@ -4139,13 +4154,18 @@
 	}
 
 	while (sts->metadata_fill_count) {
-		if (dvb_ringbuffer_avail(&mpq_feed->metadata_buf) <
-			(sizeof(header) + sizeof(counters))) {
+		bytes_avail = dvb_ringbuffer_avail(&mpq_feed->metadata_buf);
+		if (bytes_avail < (sizeof(header) + sizeof(counters))) {
 			MPQ_DVB_ERR_PRINT(
-				"%s: metadata_fill_count is %d but actual buffer has less than %d bytes\n",
+				"%s: metadata_fill_count is %d less than required %d bytes\n",
 				__func__,
 				sts->metadata_fill_count,
 				sizeof(header) + sizeof(counters));
+
+			/* clean-up remaining bytes to try to recover */
+			DVB_RINGBUFFER_SKIP(&mpq_feed->metadata_buf,
+				bytes_avail);
+			sts->metadata_fill_count = 0;
 			break;
 		}
 
@@ -4230,6 +4250,7 @@
 	struct dvb_demux_feed *feed = mpq_feed->dvb_demux_feed;
 	struct dvb_demux_filter *f;
 	struct dmx_section_feed *sec = &feed->feed.sec;
+	ssize_t bytes_avail;
 
 	/* Parse error indicators */
 	if (sts->error_indicators & SDMX_FILTER_ERR_SEC_VERIF_CRC32_FAIL) {
@@ -4250,6 +4271,21 @@
 	mpq_feed->sdmx_buf.pwrite = sts->data_write_offset;
 
 	while (sts->metadata_fill_count) {
+		bytes_avail = dvb_ringbuffer_avail(&mpq_feed->metadata_buf);
+		if (bytes_avail < sizeof(header)) {
+			MPQ_DVB_ERR_PRINT(
+				"%s: metadata_fill_count is %d less than required %d bytes\n",
+				__func__,
+				sts->metadata_fill_count,
+				sizeof(header));
+
+			/* clean-up remaining bytes to try to recover */
+			DVB_RINGBUFFER_SKIP(&mpq_feed->metadata_buf,
+				bytes_avail);
+			sts->metadata_fill_count = 0;
+			break;
+		}
+
 		dvb_ringbuffer_read(&mpq_feed->metadata_buf, (u8 *) &header,
 			sizeof(header));
 		sts->metadata_fill_count -= sizeof(header);
@@ -4288,10 +4324,10 @@
 	u8 metadata_buf[MAX_SDMX_METADATA_LENGTH];
 	struct mpq_streambuffer *sbuf;
 	int ret;
-	int pes_cnt = 0;
 	struct dmx_data_ready data_event;
 	struct dmx_data_ready data;
 	struct dvb_demux_feed *feed = mpq_feed->dvb_demux_feed;
+	ssize_t bytes_avail;
 
 	if ((!sts->metadata_fill_count) && (!sts->data_fill_count))
 		goto decoder_filter_check_flags;
@@ -4318,7 +4354,21 @@
 		struct mpq_streambuffer_packet_header packet;
 		struct mpq_adapter_video_meta_data meta_data;
 
-		pes_cnt++;
+		bytes_avail = dvb_ringbuffer_avail(&mpq_feed->metadata_buf);
+		if (bytes_avail < (sizeof(header) + sizeof(counters))) {
+			MPQ_DVB_ERR_PRINT(
+				"%s: metadata_fill_count is %d less than required %d bytes\n",
+				__func__,
+				sts->metadata_fill_count,
+				sizeof(header) + sizeof(counters));
+
+			/* clean-up remaining bytes to try to recover */
+			DVB_RINGBUFFER_SKIP(&mpq_feed->metadata_buf,
+				bytes_avail);
+			sts->metadata_fill_count = 0;
+			break;
+		}
+
 		/* Read metadata header */
 		dvb_ringbuffer_read(&mpq_feed->metadata_buf, (u8 *)&header,
 			sizeof(header));
@@ -4334,15 +4384,28 @@
 		sts->metadata_fill_count -= sizeof(counters);
 
 		/* Read metadata - TS & PES headers */
-		if (header.metadata_length < MAX_SDMX_METADATA_LENGTH)
+		bytes_avail = dvb_ringbuffer_avail(&mpq_feed->metadata_buf);
+		if ((header.metadata_length < MAX_SDMX_METADATA_LENGTH) &&
+			(header.metadata_length >= sizeof(counters)) &&
+			(bytes_avail >=
+			 (header.metadata_length - sizeof(counters)))) {
 			dvb_ringbuffer_read(&mpq_feed->metadata_buf,
 				metadata_buf,
 				header.metadata_length - sizeof(counters));
-		else
+		} else {
 			MPQ_DVB_ERR_PRINT(
-				"%s: meta-data size=%d is too big for meta-data buffer=%d\n",
+				"%s: meta-data size %d larger than available meta-data %d or max allowed %d\n",
 				__func__, header.metadata_length,
+				bytes_avail,
 				MAX_SDMX_METADATA_LENGTH);
+
+			/* clean-up remaining bytes to try to recover */
+			DVB_RINGBUFFER_SKIP(&mpq_feed->metadata_buf,
+				bytes_avail);
+			sts->metadata_fill_count = 0;
+			break;
+		}
+
 		sts->metadata_fill_count -=
 			(header.metadata_length - sizeof(counters));
 
@@ -4407,6 +4470,14 @@
 			return;
 		}
 
+		if (!header.payload_length) {
+			MPQ_DVB_DBG_PRINT(
+				"%s: warnning - video frame with 0 length, dropping\n",
+				__func__);
+			spin_unlock(&mpq_feed->video_info.video_buffer_lock);
+			continue;
+		}
+
 		packet.raw_data_len = header.payload_length;
 		packet.user_data_len = sizeof(meta_data);
 		mpq_streambuffer_get_buffer_handle(sbuf, 0,
@@ -4475,6 +4546,7 @@
 	u8 buf[TS_PACKET_HEADER_LENGTH + MAX_TSP_ADAPTATION_LENGTH +
 	       TIMESTAMP_LEN];
 	size_t stc_len = 0;
+	ssize_t bytes_avail;
 
 	if (sts->error_indicators & SDMX_FILTER_ERR_D_BUF_FULL)
 		MPQ_DVB_ERR_PRINT("%s: internal PCR buffer overflowed!\n",
@@ -4490,6 +4562,21 @@
 	rbuff->pwrite = sts->data_write_offset;
 
 	while (sts->metadata_fill_count) {
+		bytes_avail = dvb_ringbuffer_avail(&mpq_feed->metadata_buf);
+		if (bytes_avail < sizeof(header)) {
+			MPQ_DVB_ERR_PRINT(
+				"%s: metadata_fill_count is %d less than required %d bytes\n",
+				__func__,
+				sts->metadata_fill_count,
+				sizeof(header));
+
+			/* clean-up remaining bytes to try to recover */
+			DVB_RINGBUFFER_SKIP(&mpq_feed->metadata_buf,
+				bytes_avail);
+			sts->metadata_fill_count = 0;
+			break;
+		}
+
 		dvb_ringbuffer_read(&mpq_feed->metadata_buf, (u8 *) &header,
 			sizeof(header));
 		MPQ_DVB_DBG_PRINT(
@@ -4775,6 +4862,14 @@
 		todo = fill_count > limit ? limit : fill_count;
 		ret = mpq_sdmx_process_buffer(mpq_demux, input, todo,
 			read_offset);
+
+		if (mpq_demux->demux.sw_filter_abort) {
+			MPQ_DVB_ERR_PRINT(
+				"%s: Demuxing from DVR was aborted\n",
+				__func__);
+			return -ENODEV;
+		}
+
 		if (ret > 0) {
 			total_bytes_read += ret;
 			fill_count -= ret;
diff --git a/drivers/media/platform/msm/vcap/Kconfig b/drivers/media/platform/msm/vcap/Kconfig
index 2bdcfbd..db3bc47 100644
--- a/drivers/media/platform/msm/vcap/Kconfig
+++ b/drivers/media/platform/msm/vcap/Kconfig
@@ -1,7 +1,6 @@
 config MSM_VCAP
 	tristate "Qualcomm MSM VCAP"
 	depends on VIDEO_DEV && VIDEO_V4L2
-	default y
 	---help---
 		Enables VCAP driver. This device allows for video capture and
 		video processing using the v4l2 api
diff --git a/drivers/media/platform/msm/vidc/hfi_packetization.c b/drivers/media/platform/msm/vidc/hfi_packetization.c
index 30ada3e..ae94287 100644
--- a/drivers/media/platform/msm/vidc/hfi_packetization.c
+++ b/drivers/media/platform/msm/vidc/hfi_packetization.c
@@ -803,7 +803,8 @@
 		pkt->rg_property_data[0] =
 			HFI_PROPERTY_PARAM_VDEC_PICTURE_TYPE_DECODE;
 		hfi = (struct hfi_enable_picture *) &pkt->rg_property_data[1];
-		hfi->picture_type = (u32) pdata;
+		hfi->picture_type =
+			((struct hfi_enable_picture *)pdata)->picture_type;
 		pkt->size += sizeof(u32) * 2;
 		break;
 	}
diff --git a/drivers/media/platform/msm/vidc/hfi_response_handler.c b/drivers/media/platform/msm/vidc/hfi_response_handler.c
index abdb039..3fd5d3a 100644
--- a/drivers/media/platform/msm/vidc/hfi_response_handler.c
+++ b/drivers/media/platform/msm/vidc/hfi_response_handler.c
@@ -1183,42 +1183,78 @@
 	callback(SESSION_GET_SEQ_HDR_DONE, &data_done);
 }
 
-void hfi_process_sys_property_info(
-		struct hfi_property_sys_image_version_info_type *pkt)
+static void hfi_process_sys_get_prop_image_version(
+		struct hfi_msg_sys_property_info_packet *pkt)
 {
 	int i = 0;
 	u32 smem_block_size = 0;
 	u8 *smem_table_ptr;
 	char version[256];
+	const u32 version_string_size = 128;
 	const u32 smem_image_index_venus = 14 * 128;
+	u8 *str_image_version;
+	int req_bytes;
 
-	if (!pkt || !pkt->string_size) {
+	req_bytes = pkt->size - sizeof(*pkt);
+	if (req_bytes < version_string_size ||
+			!pkt->rg_property_data[1] ||
+			pkt->num_properties > 1) {
+		dprintk(VIDC_ERR,
+				"hfi_process_sys_get_prop_image_version:bad_pkt: %d",
+				req_bytes);
+		return;
+	}
+	str_image_version = (u8 *)&pkt->rg_property_data[1];
+	/*
+	 * The version string returned by firmware includes null
+	 * characters at the start and in between. Replace the null
+	 * characters with space, to print the version info.
+	 */
+	for (i = 0; i < version_string_size; i++) {
+		if (str_image_version[i] != '\0')
+			version[i] = str_image_version[i];
+		else
+			version[i] = ' ';
+	}
+	version[i] = '\0';
+	dprintk(VIDC_DBG, "F/W version: %s\n", version);
+
+	smem_table_ptr = smem_get_entry(SMEM_IMAGE_VERSION_TABLE,
+			&smem_block_size);
+	if (smem_table_ptr &&
+			((smem_image_index_venus +
+				version_string_size) <= smem_block_size))
+		memcpy(smem_table_ptr + smem_image_index_venus,
+				str_image_version, version_string_size);
+}
+
+static void hfi_process_sys_property_info(
+		struct hfi_msg_sys_property_info_packet *pkt)
+{
+	if (!pkt) {
 		dprintk(VIDC_ERR, "%s: invalid param\n", __func__);
 		return;
 	}
-
-	if (pkt->string_size < sizeof(version)) {
-		/*
-		 * The version string returned by firmware includes null
-		 * characters at the start and in between. Replace the null
-		 * characters with space, to print the version info.
-		 */
-		for (i = 0; i < pkt->string_size; i++) {
-			if (pkt->str_image_version[i] != '\0')
-				version[i] = pkt->str_image_version[i];
-			else
-				version[i] = ' ';
-		}
-		version[i] = '\0';
-		dprintk(VIDC_DBG, "F/W version: %s\n", version);
+	if (pkt->size < sizeof(*pkt)) {
+		dprintk(VIDC_ERR,
+				"hfi_process_sys_property_info: bad_pkt_size\n");
+		return;
+	}
+	if (pkt->num_properties == 0) {
+		dprintk(VIDC_ERR,
+				"hfi_process_sys_property_info: no_properties\n");
+		return;
 	}
 
-	smem_table_ptr = smem_get_entry(SMEM_IMAGE_VERSION_TABLE,
-						&smem_block_size);
-	if (smem_table_ptr &&
-		((smem_image_index_venus + 128) <= smem_block_size))
-		memcpy(smem_table_ptr + smem_image_index_venus,
-			   (u8 *)pkt->str_image_version, 128);
+	switch (pkt->rg_property_data[0]) {
+	case HFI_PROPERTY_SYS_IMAGE_VERSION:
+		hfi_process_sys_get_prop_image_version(pkt);
+		break;
+	default:
+		dprintk(VIDC_ERR,
+				"hfi_process_sys_property_info:unknown_prop_id: %d\n",
+				pkt->rg_property_data[0]);
+	}
 }
 
 u32 hfi_process_msg_packet(
@@ -1263,7 +1299,7 @@
 		break;
 	case HFI_MSG_SYS_PROPERTY_INFO:
 		hfi_process_sys_property_info(
-		   (struct hfi_property_sys_image_version_info_type *)
+		   (struct hfi_msg_sys_property_info_packet *)
 			msg_hdr);
 		break;
 	case HFI_MSG_SYS_SESSION_END_DONE:
diff --git a/drivers/media/platform/msm/vidc/msm_smem.h b/drivers/media/platform/msm/vidc/msm_smem.h
index dc384bc..ca92e73 100644
--- a/drivers/media/platform/msm/vidc/msm_smem.h
+++ b/drivers/media/platform/msm/vidc/msm_smem.h
@@ -28,37 +28,6 @@
 	SMEM_SECURE = ION_FLAG_SECURE,
 };
 
-enum hal_buffer {
-	HAL_BUFFER_INPUT = 0x1,
-	HAL_BUFFER_OUTPUT = 0x2,
-	HAL_BUFFER_OUTPUT2 = 0x4,
-	HAL_BUFFER_EXTRADATA_INPUT = 0x8,
-	HAL_BUFFER_EXTRADATA_OUTPUT = 0x10,
-	HAL_BUFFER_EXTRADATA_OUTPUT2 = 0x20,
-	HAL_BUFFER_INTERNAL_SCRATCH = 0x40,
-	HAL_BUFFER_INTERNAL_SCRATCH_1 = 0x80,
-	HAL_BUFFER_INTERNAL_SCRATCH_2 = 0x100,
-	HAL_BUFFER_INTERNAL_PERSIST = 0x200,
-	HAL_BUFFER_INTERNAL_PERSIST_1 = 0x400,
-	HAL_BUFFER_INTERNAL_CMD_QUEUE = 0x800,
-};
-
-struct msm_smem {
-	int mem_type;
-	size_t size;
-	void *kvaddr;
-	unsigned long device_addr;
-	u32 flags;
-	void *smem_priv;
-	enum hal_buffer buffer_type;
-};
-
-enum smem_cache_ops {
-	SMEM_CACHE_CLEAN,
-	SMEM_CACHE_INVALIDATE,
-	SMEM_CACHE_CLEAN_INVALIDATE,
-};
-
 void *msm_smem_new_client(enum smem_type mtype,
 				struct msm_vidc_platform_resources *res);
 struct msm_smem *msm_smem_alloc(void *clt, size_t size, u32 align, u32 flags,
@@ -69,7 +38,6 @@
 		enum smem_cache_ops);
 struct msm_smem *msm_smem_user_to_kernel(void *clt, int fd, u32 offset,
 				enum hal_buffer buffer_type);
-int msm_smem_clean_invalidate(void *clt, struct msm_smem *mem);
 int msm_smem_get_domain_partition(void *clt, u32 flags, enum hal_buffer
 		buffer_type, int *domain_num, int *partition_num);
 #endif
diff --git a/drivers/media/platform/msm/vidc/msm_vdec.c b/drivers/media/platform/msm/vidc/msm_vdec.c
index f4fdfe7..9dd4e93 100644
--- a/drivers/media/platform/msm/vidc/msm_vdec.c
+++ b/drivers/media/platform/msm/vidc/msm_vdec.c
@@ -686,6 +686,7 @@
 int msm_vdec_g_fmt(struct msm_vidc_inst *inst, struct v4l2_format *f)
 {
 	const struct msm_vidc_format *fmt = NULL;
+	unsigned int *plane_sizes = NULL;
 	struct hfi_device *hdev;
 	int stride, scanlines;
 	int extra_idx = 0;
@@ -741,9 +742,19 @@
 			goto exit;
 		}
 		if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
+			plane_sizes =
+			&inst->bufq[OUTPUT_PORT].vb2_bufq.plane_sizes[0];
 			for (i = 0; i < fmt->num_planes; ++i) {
-				f->fmt.pix_mp.plane_fmt[i].sizeimage =
-				inst->bufq[OUTPUT_PORT].vb2_bufq.plane_sizes[i];
+				if (plane_sizes[i] == 0) {
+					f->fmt.pix_mp.plane_fmt[i].sizeimage =
+						fmt->get_frame_size(i,
+						inst->capability.height.max,
+						inst->capability.width.max);
+					plane_sizes[i] =
+					f->fmt.pix_mp.plane_fmt[i].sizeimage;
+				} else
+					f->fmt.pix_mp.plane_fmt[i].sizeimage =
+						plane_sizes[i];
 			}
 		} else {
 			switch (fmt->fourcc) {
@@ -960,6 +971,14 @@
 			rc = -EINVAL;
 			goto err_invalid_fmt;
 		}
+		if (!(get_hal_codec_type(fmt->fourcc) &
+			inst->core->dec_codec_supported)) {
+			dprintk(VIDC_ERR,
+				"Codec(0x%x) not supported\n",
+				get_hal_codec_type(fmt->fourcc));
+			rc = -EINVAL;
+			goto err_invalid_fmt;
+		}
 		inst->fmts[fmt->type] = fmt;
 		rc = msm_comm_try_state(inst, MSM_VIDC_OPEN_DONE);
 		if (rc) {
@@ -979,8 +998,10 @@
 					inst->capability.height.max,
 					inst->capability.width.max);
 
-		if (f->fmt.pix_mp.plane_fmt[0].sizeimage > max_input_size)
+		if (f->fmt.pix_mp.plane_fmt[0].sizeimage > max_input_size ||
+			f->fmt.pix_mp.plane_fmt[0].sizeimage == 0) {
 			f->fmt.pix_mp.plane_fmt[0].sizeimage = max_input_size;
+		}
 
 		f->fmt.pix_mp.num_planes = fmt->num_planes;
 		for (i = 0; i < fmt->num_planes; ++i) {
@@ -1807,7 +1828,7 @@
 int msm_vdec_ctrl_init(struct msm_vidc_inst *inst)
 {
 	int idx = 0;
-	struct v4l2_ctrl_config ctrl_cfg;
+	struct v4l2_ctrl_config ctrl_cfg = {0};
 	int ret_val = 0;
 
 	ret_val = v4l2_ctrl_handler_init(&inst->ctrl_handler, NUM_CTRLS);
diff --git a/drivers/media/platform/msm/vidc/msm_venc.c b/drivers/media/platform/msm/vidc/msm_venc.c
index f9b5519..c0bf32c 100644
--- a/drivers/media/platform/msm/vidc/msm_venc.c
+++ b/drivers/media/platform/msm/vidc/msm_venc.c
@@ -2662,7 +2662,7 @@
 {
 
 	int idx = 0;
-	struct v4l2_ctrl_config ctrl_cfg;
+	struct v4l2_ctrl_config ctrl_cfg = {0};
 	int ret_val = 0;
 	ret_val = v4l2_ctrl_handler_init(&inst->ctrl_handler, NUM_CTRLS);
 	if (ret_val) {
diff --git a/drivers/media/platform/msm/vidc/msm_vidc.c b/drivers/media/platform/msm/vidc/msm_vidc.c
index 6ed94e4..25917c1 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc.c
+++ b/drivers/media/platform/msm/vidc/msm_vidc.c
@@ -356,7 +356,7 @@
 		struct v4l2_plane *p, enum hal_buffer buffer_type)
 {
 	struct msm_smem *handle = NULL;
-	handle = msm_smem_user_to_kernel(inst->mem_client,
+	handle = msm_comm_smem_user_to_kernel(inst,
 				p->reserved[0],
 				p->reserved[1],
 				buffer_type);
@@ -365,7 +365,7 @@
 			"%s: Failed to get device buffer address\n", __func__);
 		return NULL;
 	}
-	if (msm_smem_cache_operations(inst->mem_client, handle,
+	if (msm_comm_smem_cache_operations(inst, handle,
 			SMEM_CACHE_CLEAN))
 		dprintk(VIDC_WARN,
 			"CACHE Clean failed: %d, %d, %d\n",
@@ -584,7 +584,7 @@
 			dprintk(VIDC_DBG,
 				"[UNMAP] - handle[%d] = %p fd[%d] = %d",
 				i, temp->handle[i], i, temp->fd[i]);
-			msm_smem_free(inst->mem_client,
+			msm_comm_smem_free(inst,
 				temp->handle[i]);
 		}
 
@@ -660,7 +660,7 @@
 
 	for (i = 0; i < binfo->num_planes; i++) {
 		if (binfo->handle[i]) {
-			rc = msm_smem_cache_operations(inst->mem_client,
+			rc = msm_comm_smem_cache_operations(inst,
 				binfo->handle[i], SMEM_CACHE_INVALIDATE);
 			if (rc) {
 				dprintk(VIDC_ERR,
@@ -745,7 +745,7 @@
 			list_del(&bi->list);
 			for (i = 0; i < bi->num_planes; i++) {
 				if (bi->handle[i])
-					msm_smem_free(inst->mem_client,
+					msm_comm_smem_free(inst,
 							bi->handle[i]);
 			}
 			kfree(bi);
@@ -824,7 +824,7 @@
 		if ((inst->fmts[OUTPUT_PORT]->fourcc ==
 			V4L2_PIX_FMT_HEVC_HYBRID) &&  binfo->handle[i] &&
 			(b->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)) {
-			rc = msm_smem_cache_operations(inst->mem_client,
+			rc = msm_comm_smem_cache_operations(inst,
 				binfo->handle[i], SMEM_CACHE_INVALIDATE);
 			if (rc) {
 				dprintk(VIDC_ERR,
@@ -835,7 +835,7 @@
 
 		if (binfo->handle[i] &&
 			(b->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)) {
-			rc = msm_smem_cache_operations(inst->mem_client,
+			rc = msm_comm_smem_cache_operations(inst,
 					binfo->handle[i], SMEM_CACHE_CLEAN);
 			if (rc) {
 				dprintk(VIDC_ERR,
@@ -970,6 +970,57 @@
 	fsize->stepwise.step_height = capability->height.step_size;
 	return 0;
 }
+
+struct msm_smem *msm_vidc_smem_alloc(void *instance,
+			size_t size, u32 align, u32 flags,
+			enum hal_buffer buffer_type, int map_kernel)
+{
+	return msm_comm_smem_alloc((struct msm_vidc_inst *)instance,
+			size, align, flags, buffer_type, map_kernel);
+
+}
+
+void msm_vidc_smem_free(void *instance, struct msm_smem *mem)
+{
+	msm_comm_smem_free((struct msm_vidc_inst *)instance, mem);
+}
+
+int msm_vidc_smem_cache_operations(void *instance, struct msm_smem *mem,
+		enum smem_cache_ops cache_ops)
+{
+	return msm_comm_smem_cache_operations(
+		(struct msm_vidc_inst *)instance, mem, cache_ops);
+}
+
+struct msm_smem *msm_vidc_smem_user_to_kernel(void *instance, int fd,
+			u32 offset, enum hal_buffer buffer_type)
+{
+	return msm_comm_smem_user_to_kernel(
+			(struct msm_vidc_inst *)instance,
+			fd, offset, buffer_type);
+}
+
+int msm_vidc_smem_get_domain_partition(void *instance, u32 flags,
+		enum hal_buffer buffer_type, int *domain_num,
+		int *partition_num)
+{
+	return msm_comm_smem_get_domain_partition(
+		(struct msm_vidc_inst *)instance,
+		flags, buffer_type, domain_num, partition_num);
+}
+
+void *msm_vidc_smem_get_client(void *instance)
+{
+	struct msm_vidc_inst *inst = instance;
+
+	if (!inst || !inst->mem_client) {
+		dprintk(VIDC_ERR, "%s: invalid instance or client = %p %p\n",
+				__func__, inst, inst->mem_client);
+		return NULL;
+	}
+
+	return inst->mem_client;
+}
 static void *vidc_get_userptr(void *alloc_ctx, unsigned long vaddr,
 				unsigned long size, int write)
 {
@@ -1189,7 +1240,7 @@
 						list);
 				list_del(&buf->list);
 				mutex_unlock(&inst->lock);
-				msm_smem_free(inst->mem_client, buf->handle);
+				msm_comm_smem_free(inst, buf->handle);
 				kfree(buf);
 				mutex_lock(&inst->lock);
 			}
@@ -1200,7 +1251,7 @@
 						list);
 				list_del(&buf->list);
 				mutex_unlock(&inst->lock);
-				msm_smem_free(inst->mem_client, buf->handle);
+				msm_comm_smem_free(inst, buf->handle);
 				kfree(buf);
 				mutex_lock(&inst->lock);
 			}
@@ -1211,14 +1262,14 @@
 						list);
 				list_del(&buf->list);
 				mutex_unlock(&inst->lock);
-				msm_smem_free(inst->mem_client, buf->handle);
+				msm_comm_smem_free(inst, buf->handle);
 				kfree(buf);
 				mutex_lock(&inst->lock);
 			}
 		}
 		if (inst->extradata_handle) {
 			mutex_unlock(&inst->lock);
-			msm_smem_free(inst->mem_client, inst->extradata_handle);
+			msm_comm_smem_free(inst, inst->extradata_handle);
 			mutex_lock(&inst->lock);
 		}
 		mutex_unlock(&inst->lock);
@@ -1247,8 +1298,7 @@
 			for (i = 0; (i < bi->num_planes)
 				&& (i < VIDEO_MAX_PLANES); i++) {
 				if (bi->handle[i])
-					msm_smem_free(inst->mem_client,
-							bi->handle[i]);
+					msm_comm_smem_free(inst, bi->handle[i]);
 			}
 			kfree(bi);
 		}
diff --git a/drivers/media/platform/msm/vidc/msm_vidc_common.c b/drivers/media/platform/msm/vidc/msm_vidc_common.c
index 42460fa..f456246 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc_common.c
+++ b/drivers/media/platform/msm/vidc/msm_vidc_common.c
@@ -277,14 +277,17 @@
 		dprintk(VIDC_ERR, "Wrong device_id received\n");
 		return;
 	}
-	dprintk(VIDC_DBG, "index = %d\n", index);
-	dprintk(VIDC_DBG, "ptr = %p\n", &(core->completions[index]));
-	complete(&(core->completions[index]));
 	sys_init_msg = response->data;
 	if (!sys_init_msg) {
 		dprintk(VIDC_ERR, "sys_init_done message not proper\n");
 		return;
 	}
+	core->enc_codec_supported = sys_init_msg->enc_codec_supported;
+	core->dec_codec_supported = sys_init_msg->dec_codec_supported;
+	dprintk(VIDC_DBG, "supported_codecs: enc = 0x%x, dec = 0x%x\n",
+		core->enc_codec_supported, core->dec_codec_supported);
+	dprintk(VIDC_DBG, "ptr[%d] = %p\n", index, &(core->completions[index]));
+	complete(&(core->completions[index]));
 }
 
 static void handle_session_release_buf_done(enum command_response cmd,
@@ -765,6 +768,7 @@
 			mutex_lock(&core->lock);
 			core->state = VIDC_CORE_INVALID;
 			mutex_unlock(&core->lock);
+			mutex_lock(&core->sync_lock);
 			list_for_each_entry(inst, &core->instances,
 					list) {
 				mutex_lock(&inst->lock);
@@ -786,6 +790,7 @@
 				msm_vidc_queue_v4l2_event(inst,
 						V4L2_EVENT_MSM_VIDC_SYS_ERROR);
 			}
+			mutex_unlock(&core->sync_lock);
 		} else {
 			dprintk(VIDC_ERR,
 				"Got SYS_ERR but unable to identify core");
@@ -813,6 +818,7 @@
 	mutex_lock(&core->lock);
 	core->state = VIDC_CORE_INVALID;
 	mutex_unlock(&core->lock);
+	mutex_lock(&core->sync_lock);
 	list_for_each_entry(inst, &core->instances, list) {
 		if (inst) {
 			msm_vidc_queue_v4l2_event(inst,
@@ -834,6 +840,7 @@
 			mutex_unlock(&inst->lock);
 		}
 	}
+	mutex_unlock(&core->sync_lock);
 }
 
 static void handle_session_close(enum command_response cmd, void *data)
@@ -1594,7 +1601,7 @@
 	return domain;
 }
 
-static enum hal_video_codec get_hal_codec_type(int fourcc)
+enum hal_video_codec get_hal_codec_type(int fourcc)
 {
 	enum hal_video_codec codec;
 	dprintk(VIDC_DBG, "codec is 0x%x", fourcc);
@@ -1994,7 +2001,7 @@
 	if (output_buf->buffer_size) {
 		for (i = 0; i < output_buf->buffer_count_actual;
 				i++) {
-			handle = msm_smem_alloc(inst->mem_client,
+			handle = msm_comm_smem_alloc(inst,
 					buffer_size, 1, smem_flags,
 					buffer_type, 0);
 			if (!handle) {
@@ -2003,7 +2010,7 @@
 				rc = -ENOMEM;
 				goto err_no_mem;
 			}
-			rc = msm_smem_cache_operations(inst->mem_client,
+			rc = msm_comm_smem_cache_operations(inst,
 					handle, SMEM_CACHE_CLEAN);
 			if (rc) {
 				dprintk(VIDC_WARN,
@@ -2048,7 +2055,7 @@
 fail_set_buffers:
 	kfree(binfo);
 fail_kzalloc:
-	msm_smem_free(inst->mem_client, handle);
+	msm_comm_smem_free(inst, handle);
 err_no_mem:
 	return rc;
 }
@@ -2085,7 +2092,7 @@
 	if (scratch_buf->buffer_size) {
 		for (i = 0; i < scratch_buf->buffer_count_actual;
 				i++) {
-			handle = msm_smem_alloc(inst->mem_client,
+			handle = msm_comm_smem_alloc(inst,
 				scratch_buf->buffer_size, 1, smem_flags,
 				buffer_type, 0);
 			if (!handle) {
@@ -2094,7 +2101,7 @@
 				rc = -ENOMEM;
 				goto err_no_mem;
 			}
-			rc = msm_smem_cache_operations(inst->mem_client,
+			rc = msm_comm_smem_cache_operations(inst,
 					handle, SMEM_CACHE_CLEAN);
 			if (rc) {
 				dprintk(VIDC_WARN,
@@ -2130,7 +2137,7 @@
 fail_set_buffers:
 	kfree(binfo);
 fail_kzalloc:
-	msm_smem_free(inst->mem_client, handle);
+	msm_comm_smem_free(inst, handle);
 err_no_mem:
 	return rc;
 }
@@ -2172,7 +2179,7 @@
 
 	if (persist_buf->buffer_size) {
 		for (i = 0; i < persist_buf->buffer_count_actual; i++) {
-			handle = msm_smem_alloc(inst->mem_client,
+			handle = msm_comm_smem_alloc(inst,
 				persist_buf->buffer_size, 1, smem_flags,
 				buffer_type, 0);
 			if (!handle) {
@@ -2181,7 +2188,7 @@
 				rc = -ENOMEM;
 				goto err_no_mem;
 			}
-			rc = msm_smem_cache_operations(inst->mem_client,
+			rc = msm_comm_smem_cache_operations(inst,
 					handle, SMEM_CACHE_CLEAN);
 			if (rc) {
 				dprintk(VIDC_WARN,
@@ -2217,7 +2224,7 @@
 fail_set_buffers:
 	kfree(binfo);
 fail_kzalloc:
-	msm_smem_free(inst->mem_client, handle);
+	msm_comm_smem_free(inst, handle);
 err_no_mem:
 	return rc;
 }
@@ -2586,7 +2593,7 @@
 			}
 			list_del(&buf->list);
 			mutex_unlock(&inst->lock);
-			msm_smem_free(inst->mem_client, buf->handle);
+			msm_comm_smem_free(inst, buf->handle);
 			kfree(buf);
 			mutex_lock(&inst->lock);
 		}
@@ -2657,7 +2664,7 @@
 			}
 			list_del(&buf->list);
 			mutex_unlock(&inst->lock);
-			msm_smem_free(inst->mem_client, buf->handle);
+			msm_comm_smem_free(inst, buf->handle);
 			kfree(buf);
 			mutex_lock(&inst->lock);
 		}
@@ -2728,7 +2735,7 @@
 			}
 			list_del(&buf->list);
 			mutex_unlock(&inst->lock);
-			msm_smem_free(inst->mem_client, buf->handle);
+			msm_comm_smem_free(inst, buf->handle);
 			kfree(buf);
 			mutex_lock(&inst->lock);
 		}
@@ -3158,10 +3165,12 @@
 	int num_mbs_per_sec = 0;
 
 	if (inst->state == MSM_VIDC_OPEN_DONE) {
+		mutex_lock(&inst->core->sync_lock);
 		num_mbs_per_sec = msm_comm_get_load(inst->core,
 			MSM_VIDC_DECODER);
 		num_mbs_per_sec += msm_comm_get_load(inst->core,
 			MSM_VIDC_ENCODER);
+		mutex_unlock(&inst->core->sync_lock);
 		if (num_mbs_per_sec > inst->core->resources.max_load) {
 			dprintk(VIDC_ERR,
 				"H/w is overloaded. needed: %d max: %d\n",
@@ -3334,3 +3343,85 @@
 		change_inst_state(inst, MSM_VIDC_CLOSE_DONE);
 	return rc;
 }
+
+static inline int power_on_for_smem(struct msm_vidc_inst *inst)
+{
+	struct hfi_device *hdev = NULL;
+	int rc = 0;
+
+	if (!inst || !inst->core || !inst->core->device) {
+		dprintk(VIDC_ERR, "%s: invalid inst handle\n", __func__);
+		return -EINVAL;
+	}
+	hdev = inst->core->device;
+	rc = call_hfi_op(hdev, power_enable, hdev->hfi_device_data);
+	if (rc)
+		dprintk(VIDC_ERR, "%s: failed to power on fw\n", __func__);
+	return rc;
+}
+
+struct msm_smem *msm_comm_smem_alloc(struct msm_vidc_inst *inst,
+			size_t size, u32 align, u32 flags,
+			enum hal_buffer buffer_type, int map_kernel)
+{
+	if (!inst) {
+		dprintk(VIDC_ERR, "%s: invalid inst: %p\n", __func__, inst);
+		return NULL;
+	}
+	if (power_on_for_smem(inst))
+		return NULL;
+
+	return msm_smem_alloc(inst->mem_client, size, align,
+				flags, buffer_type, map_kernel);
+}
+
+void msm_comm_smem_free(struct msm_vidc_inst *inst, struct msm_smem *mem)
+{
+	if (!inst || !mem) {
+		dprintk(VIDC_ERR,
+			"%s: invalid params: %p %p\n", __func__, inst, mem);
+		return;
+	}
+	if (power_on_for_smem(inst))
+		return;
+
+	return msm_smem_free(inst->mem_client, mem);
+}
+
+int msm_comm_smem_cache_operations(struct msm_vidc_inst *inst,
+		struct msm_smem *mem, enum smem_cache_ops cache_ops)
+{
+	if (!inst || !mem) {
+		dprintk(VIDC_ERR,
+			"%s: invalid params: %p %p\n", __func__, inst, mem);
+		return -EINVAL;
+	}
+	return msm_smem_cache_operations(inst->mem_client, mem, cache_ops);
+}
+
+struct msm_smem *msm_comm_smem_user_to_kernel(struct msm_vidc_inst *inst,
+			int fd, u32 offset, enum hal_buffer buffer_type)
+{
+	if (!inst) {
+		dprintk(VIDC_ERR, "%s: invalid inst: %p\n", __func__, inst);
+		return NULL;
+	}
+	if (power_on_for_smem(inst))
+		return NULL;
+
+	return msm_smem_user_to_kernel(inst->mem_client,
+			fd, offset, buffer_type);
+}
+
+int msm_comm_smem_get_domain_partition(struct msm_vidc_inst *inst,
+			u32 flags, enum hal_buffer buffer_type,
+			int *domain_num, int *partition_num)
+{
+	if (!inst || !domain_num || !partition_num) {
+		dprintk(VIDC_ERR, "%s: invalid params: %p %p %p\n",
+			__func__, inst, domain_num, partition_num);
+		return -EINVAL;
+	}
+	return msm_smem_get_domain_partition(inst->mem_client, flags,
+			buffer_type, domain_num, partition_num);
+}
diff --git a/drivers/media/platform/msm/vidc/msm_vidc_common.h b/drivers/media/platform/msm/vidc/msm_vidc_common.h
index 195fa7e..e2f7b61 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc_common.h
+++ b/drivers/media/platform/msm/vidc/msm_vidc_common.h
@@ -52,5 +52,16 @@
 int msm_comm_recover_from_session_error(struct msm_vidc_inst *inst);
 enum multi_stream msm_comm_get_stream_output_mode(struct msm_vidc_inst *inst);
 enum hal_buffer msm_comm_get_hal_output_buffer(struct msm_vidc_inst *inst);
-
+struct msm_smem *msm_comm_smem_alloc(struct msm_vidc_inst *inst,
+			size_t size, u32 align, u32 flags,
+			enum hal_buffer buffer_type, int map_kernel);
+void msm_comm_smem_free(struct msm_vidc_inst *inst, struct msm_smem *mem);
+int msm_comm_smem_cache_operations(struct msm_vidc_inst *inst,
+		struct msm_smem *mem, enum smem_cache_ops cache_ops);
+struct msm_smem *msm_comm_smem_user_to_kernel(struct msm_vidc_inst *inst,
+			int fd, u32 offset, enum hal_buffer buffer_type);
+int msm_comm_smem_get_domain_partition(struct msm_vidc_inst *inst,
+			u32 flags, enum hal_buffer buffer_type,
+			int *domain_num, int *partition_num);
+enum hal_video_codec get_hal_codec_type(int fourcc);
 #endif
diff --git a/drivers/media/platform/msm/vidc/msm_vidc_internal.h b/drivers/media/platform/msm/vidc/msm_vidc_internal.h
index 2b1471c..e4f920f 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc_internal.h
+++ b/drivers/media/platform/msm/vidc/msm_vidc_internal.h
@@ -207,6 +207,8 @@
 	struct completion completions[SYS_MSG_END - SYS_MSG_START + 1];
 	enum msm_vidc_hfi_type hfi_type;
 	struct msm_vidc_platform_resources resources;
+	u32 enc_codec_supported;
+	u32 dec_codec_supported;
 };
 
 struct msm_vidc_inst {
diff --git a/drivers/media/platform/msm/vidc/q6_hfi.c b/drivers/media/platform/msm/vidc/q6_hfi.c
index 7c99ec3..8e91f34 100644
--- a/drivers/media/platform/msm/vidc/q6_hfi.c
+++ b/drivers/media/platform/msm/vidc/q6_hfi.c
@@ -560,17 +560,28 @@
 		dprintk(VIDC_ERR, "session_init: failed to create packet");
 		goto err_session_init;
 	}
+	/*
+	 * Add session id to the list entry and then send the apr pkt.
+	 * This will avoid scenarios where apr_send_pkt is taking more
+	 * time and Q6 is returning an ack even before the session id
+	 * gets added to the session list.
+	 */
+	mutex_lock(&dev->session_lock);
+	list_add_tail(&new_session->list, &dev->sess_head);
+	mutex_unlock(&dev->session_lock);
 
 	rc = apr_send_pkt(dev->apr, (uint32_t *)&apr);
 	if (rc != apr.hdr.pkt_size) {
 		dprintk(VIDC_ERR, "%s: apr_send_pkt failed rc: %d",
 				__func__, rc);
+		/* Delete the session id as the send pkt is not successful */
+		mutex_lock(&dev->session_lock);
+		list_del(&new_session->list);
+		mutex_unlock(&dev->session_lock);
 		rc = -EBADE;
 		goto err_session_init;
 	}
-	mutex_lock(&dev->session_lock);
-	list_add_tail(&new_session->list, &dev->sess_head);
-	mutex_unlock(&dev->session_lock);
+
 	return new_session;
 
 err_session_init:
diff --git a/drivers/media/platform/msm/vidc/venus_hfi.c b/drivers/media/platform/msm/vidc/venus_hfi.c
index 916df1d..a8178f7 100644
--- a/drivers/media/platform/msm/vidc/venus_hfi.c
+++ b/drivers/media/platform/msm/vidc/venus_hfi.c
@@ -29,6 +29,7 @@
 #include "venus_hfi.h"
 #include "vidc_hfi_io.h"
 #include "msm_vidc_debug.h"
+#include <linux/iopoll.h>
 
 #define FIRMWARE_SIZE			0X00A00000
 #define REG_ADDR_OFFSET_BITMASK	0x000FFFFF
@@ -75,6 +76,10 @@
 	u32 spare; /*reserved for future, should be zero*/
 };
 
+static int venus_hfi_power_enable(void *dev);
+
+static inline int venus_hfi_clk_gating_off(struct venus_hfi_device *device);
+
 static void venus_hfi_dump_packet(u8 *packet)
 {
 	u32 c = 0, packet_size = *(u32 *)packet;
@@ -402,21 +407,24 @@
 	return rc;
 }
 
-static int venus_hfi_alloc(void *mem, void *clnt, u32 size, u32 align,
-		u32 flags, u32 usage)
+static int venus_hfi_alloc(struct venus_hfi_device *dev, void *mem,
+			u32 size, u32 align, u32 flags, u32 usage)
 {
-	struct vidc_mem_addr *vmem;
-	struct msm_smem *alloc;
+	struct vidc_mem_addr *vmem = NULL;
+	struct msm_smem *alloc = NULL;
 	int rc = 0;
 
-	if (!mem || !clnt || !size) {
+	if (!dev || !dev->hal_client || !mem || !size) {
 		dprintk(VIDC_ERR, "Invalid Params");
 		return -EINVAL;
 	}
+
 	vmem = (struct vidc_mem_addr *)mem;
 	dprintk(VIDC_INFO, "start to alloc: size:%d, Flags: %d", size, flags);
 
-	alloc = msm_smem_alloc(clnt, size, align, flags, usage, 1);
+	venus_hfi_power_enable(dev);
+
+	alloc = msm_smem_alloc(dev->hal_client, size, align, flags, usage, 1);
 	dprintk(VIDC_DBG, "Alloc done");
 	if (!alloc) {
 		dprintk(VIDC_ERR, "Alloc failed\n");
@@ -425,7 +433,7 @@
 	}
 	dprintk(VIDC_DBG, "venus_hfi_alloc:ptr=%p,size=%d",
 			alloc->kvaddr, size);
-	rc = msm_smem_cache_operations(clnt, alloc,
+	rc = msm_smem_cache_operations(dev->hal_client, alloc,
 		SMEM_CACHE_CLEAN);
 	if (rc) {
 		dprintk(VIDC_WARN, "Failed to clean cache\n");
@@ -440,9 +448,14 @@
 	return rc;
 }
 
-static void venus_hfi_free(struct smem_client *clnt, struct msm_smem *mem)
+static void venus_hfi_free(struct venus_hfi_device *dev, struct msm_smem *mem)
 {
-	msm_smem_free(clnt, mem);
+	if (!dev || !mem) {
+		dprintk(VIDC_ERR, "invalid param %p %p\n", dev, mem);
+		return;
+	}
+	venus_hfi_power_enable(dev);
+	msm_smem_free(dev->hal_client, mem);
 }
 
 static void venus_hfi_write_register(struct venus_hfi_device *device, u32 reg,
@@ -865,6 +878,34 @@
 
 static DECLARE_COMPLETION(pc_prep_done);
 
+static int venus_hfi_halt_axi(struct venus_hfi_device *device)
+{
+	u32 reg;
+	int rc = 0;
+	if (!device) {
+		dprintk(VIDC_ERR, "Invalid input: %p\n", device);
+		return -EINVAL;
+	}
+	if (venus_hfi_clk_gating_off(device)) {
+		dprintk(VIDC_ERR, "Failed to turn off clk gating\n");
+		return -EIO;
+	}
+	/* Halt AXI and AXI OCMEM VBIF Access */
+	reg = venus_hfi_read_register(device, VENUS_VBIF_AXI_HALT_CTRL0);
+	reg |= VENUS_VBIF_AXI_HALT_CTRL0_HALT_REQ;
+	venus_hfi_write_register(device, VENUS_VBIF_AXI_HALT_CTRL0, reg, 0);
+
+	/* Request for AXI bus port halt */
+	rc = readl_poll_timeout((u32)device->hal_data->register_base_addr
+			+ VENUS_VBIF_AXI_HALT_CTRL1,
+			reg, reg & VENUS_VBIF_AXI_HALT_CTRL1_HALT_ACK,
+			POLL_INTERVAL_US,
+			VENUS_VBIF_AXI_HALT_ACK_TIMEOUT_US);
+	if (rc)
+		dprintk(VIDC_WARN, "AXI bus port halt timeout\n");
+	return rc;
+}
+
 static inline int venus_hfi_power_off(struct venus_hfi_device *device)
 {
 	int rc = 0;
@@ -972,6 +1013,22 @@
 	return rc;
 }
 
+static int venus_hfi_power_enable(void *dev)
+{
+	int rc = 0;
+	struct venus_hfi_device *device = dev;
+	if (!device) {
+		dprintk(VIDC_ERR, "Invalid params: %p\n", device);
+		return -EINVAL;
+	}
+	mutex_lock(&device->clk_pwr_lock);
+	if (!device->power_enabled)
+		rc = venus_hfi_power_on(device);
+	mutex_unlock(&device->clk_pwr_lock);
+
+	return rc;
+}
+
 static void venus_hfi_pm_hndlr(struct work_struct *work);
 static DECLARE_DELAYED_WORK(venus_hfi_pm_work, venus_hfi_pm_hndlr);
 
@@ -1057,30 +1114,32 @@
 		dprintk(VIDC_ERR, "cannot write to shared Q's");
 		goto err_q_null;
 	}
-	mutex_lock(&device->clk_pwr_lock);
-	result = venus_hfi_clk_gating_off(device);
-	if (result) {
-		dprintk(VIDC_ERR, "%s : Clock enable failed\n",
-			__func__);
-		goto err_q_write;
-	}
-	result = venus_hfi_scale_clocks(device, device->clk_load);
-	if (result) {
-		dprintk(VIDC_ERR, "Clock scaling failed\n");
-		goto err_q_write;
-	}
 	if (!venus_hfi_write_queue(q_info, (u8 *)pkt, &rx_req_is_set)) {
+		mutex_lock(&device->clk_pwr_lock);
+		result = venus_hfi_clk_gating_off(device);
+		if (result) {
+			dprintk(VIDC_ERR, "%s : Clock enable failed\n",
+					__func__);
+			mutex_unlock(&device->clk_pwr_lock);
+			goto err_q_write;
+		}
+		result = venus_hfi_scale_clocks(device, device->clk_load);
+		if (result) {
+			dprintk(VIDC_ERR, "Clock scaling failed\n");
+			mutex_unlock(&device->clk_pwr_lock);
+			goto err_q_write;
+		}
 		if (rx_req_is_set)
 			venus_hfi_write_register(
 				device,
 				VIDC_CPU_IC_SOFTINT,
 				1 << VIDC_CPU_IC_SOFTINT_H2A_SHFT, 0);
 		result = 0;
+		mutex_unlock(&device->clk_pwr_lock);
 	} else {
 		dprintk(VIDC_ERR, "venus_hfi_iface_cmdq_write:queue_full");
 	}
 err_q_write:
-	mutex_unlock(&device->clk_pwr_lock);
 err_q_null:
 	mutex_unlock(&device->write_lock);
 	return result;
@@ -1104,26 +1163,27 @@
 		goto read_error_null;
 	}
 	q_info = &device->iface_queues[VIDC_IFACEQ_MSGQ_IDX];
-	mutex_lock(&device->clk_pwr_lock);
-	rc = venus_hfi_clk_gating_off(device);
-	if (rc) {
-		dprintk(VIDC_ERR,
-			"%s : Clock enable failed\n", __func__);
-		goto read_error;
-	}
 	if (!venus_hfi_read_queue(q_info, (u8 *)pkt, &tx_req_is_set)) {
+		mutex_lock(&device->clk_pwr_lock);
+		rc = venus_hfi_clk_gating_off(device);
+		if (rc) {
+			dprintk(VIDC_ERR,
+					"%s : Clock enable failed\n", __func__);
+			mutex_unlock(&device->clk_pwr_lock);
+			goto read_error;
+		}
 		if (tx_req_is_set)
 			venus_hfi_write_register(
 				device,
 				VIDC_CPU_IC_SOFTINT,
 				1 << VIDC_CPU_IC_SOFTINT_H2A_SHFT, 0);
 		rc = 0;
+		mutex_unlock(&device->clk_pwr_lock);
 	} else {
 		dprintk(VIDC_INFO, "venus_hfi_iface_msgq_read:queue_empty");
 		rc = -ENODATA;
 	}
 read_error:
-	mutex_unlock(&device->clk_pwr_lock);
 read_error_null:
 	mutex_unlock(&device->read_lock);
 	return rc;
@@ -1146,27 +1206,28 @@
 		rc = -ENODATA;
 		goto dbg_error_null;
 	}
-	mutex_lock(&device->clk_pwr_lock);
-	rc = venus_hfi_clk_gating_off(device);
-	if (rc) {
-		dprintk(VIDC_ERR,
-			"%s : Clock enable failed\n", __func__);
-		goto dbg_error;
-	}
 	q_info = &device->iface_queues[VIDC_IFACEQ_DBGQ_IDX];
 	if (!venus_hfi_read_queue(q_info, (u8 *)pkt, &tx_req_is_set)) {
+		mutex_lock(&device->clk_pwr_lock);
+		rc = venus_hfi_clk_gating_off(device);
+		if (rc) {
+			dprintk(VIDC_ERR,
+				"%s : Clock enable failed\n", __func__);
+			mutex_unlock(&device->clk_pwr_lock);
+			goto dbg_error;
+		}
 		if (tx_req_is_set)
 			venus_hfi_write_register(
 				device,
 				VIDC_CPU_IC_SOFTINT,
 				1 << VIDC_CPU_IC_SOFTINT_H2A_SHFT, 0);
 		rc = 0;
+		mutex_unlock(&device->clk_pwr_lock);
 	} else {
 		dprintk(VIDC_INFO, "venus_hfi_iface_dbgq_read:queue_empty");
 		rc = -ENODATA;
 	}
 dbg_error:
-	mutex_unlock(&device->clk_pwr_lock);
 dbg_error_null:
 	mutex_unlock(&device->read_lock);
 	return rc;
@@ -1213,10 +1274,10 @@
 				(unsigned long)(mem_map[i].virtual_addr),
 				domain, partition, SZ_4K);
 		}
-		venus_hfi_free(device->hal_client, device->qdss.mem_data);
+		venus_hfi_free(device, device->qdss.mem_data);
 	}
-	venus_hfi_free(device->hal_client, device->iface_q_table.mem_data);
-	venus_hfi_free(device->hal_client, device->sfr.mem_data);
+	venus_hfi_free(device, device->iface_q_table.mem_data);
+	venus_hfi_free(device, device->sfr.mem_data);
 
 	for (i = 0; i < VIDC_IFACEQ_NUMQ; i++) {
 		device->iface_queues[i].q_hdr = NULL;
@@ -1251,7 +1312,7 @@
 
 	for (i = 0; i < num_entries; i++) {
 		rc = msm_iommu_map_contig_buffer(venus_qdss_entries[i][0],
-			domain, 1 , venus_qdss_entries[i][1],
+			domain, partition, venus_qdss_entries[i][1],
 			SZ_4K, 0, &iova);
 		if (rc) {
 			dprintk(VIDC_ERR,
@@ -1292,8 +1353,8 @@
 	int num_entries = sizeof(venus_qdss_entries)/(2 * sizeof(u32));
 	int domain, partition;
 	mem_addr = &dev->mem_addr;
-	rc = venus_hfi_alloc((void *) mem_addr,
-			dev->hal_client, QUEUE_SIZE, 1, 0,
+	rc = venus_hfi_alloc(dev, (void *) mem_addr,
+			QUEUE_SIZE, 1, 0,
 			HAL_BUFFER_INTERNAL_CMD_QUEUE);
 	if (rc) {
 		dprintk(VIDC_ERR, "iface_q_table_alloc_fail");
@@ -1319,8 +1380,8 @@
 		venus_hfi_set_queue_hdr_defaults(iface_q->q_hdr);
 	}
 
-	rc = venus_hfi_alloc((void *) mem_addr,
-			dev->hal_client, QDSS_SIZE, 1, 0,
+	rc = venus_hfi_alloc(dev, (void *) mem_addr,
+			QDSS_SIZE, 1, 0,
 			HAL_BUFFER_INTERNAL_CMD_QUEUE);
 	if (rc) {
 		dprintk(VIDC_WARN,
@@ -1332,8 +1393,8 @@
 		dev->qdss.mem_size = QDSS_SIZE;
 		dev->qdss.mem_data = mem_addr->mem_data;
 	}
-	rc = venus_hfi_alloc((void *) mem_addr,
-			dev->hal_client, SFR_SIZE, 1, 0,
+	rc = venus_hfi_alloc(dev, (void *) mem_addr,
+			SFR_SIZE, 1, 0,
 			HAL_BUFFER_INTERNAL_CMD_QUEUE);
 	if (rc) {
 		dprintk(VIDC_WARN, "sfr_alloc_fail: SFR not will work");
@@ -1398,7 +1459,7 @@
 	if (rc) {
 		dprintk(VIDC_ERR,
 			"IOMMU mapping failed, Freeing qdss memdata");
-		venus_hfi_free(dev->hal_client, dev->qdss.mem_data);
+		venus_hfi_free(dev, dev->qdss.mem_data);
 		dev->qdss.mem_data = NULL;
 	}
 	if (!IS_ERR_OR_NULL(dev->qdss.align_device_addr))
@@ -1567,20 +1628,59 @@
 	return 0;
 }
 
+static int venus_hfi_is_cmd_pending(struct venus_hfi_device *dev)
+{
+	struct hfi_queue_header *queue;
+	struct vidc_iface_q_info *q_info;
+	u32 write_ptr, read_ptr;
+	u32 rc = 0;
+	q_info = &dev->iface_queues[VIDC_IFACEQ_CMDQ_IDX];
+	if (!q_info)
+		dprintk(VIDC_ERR, "cannot read shared Q's");
+	queue = (struct hfi_queue_header *) q_info->q_hdr;
+	if (!queue) {
+		dprintk(VIDC_ERR, "queue not present");
+		return -ENOENT;
+	}
+	write_ptr = (u32)queue->qhdr_write_idx;
+	read_ptr = (u32)queue->qhdr_read_idx;
+	rc = read_ptr - write_ptr;
+	return rc;
+}
+
+static inline void venus_hfi_clk_gating_on(struct venus_hfi_device *device)
+{
+	if (!device) {
+		dprintk(VIDC_ERR, "Invalid params: %p\n", device);
+		return;
+	}
+	if (!device->clocks_enabled) {
+		dprintk(VIDC_DBG, "Clocks are already disabled");
+		goto already_disabled;
+	}
+	venus_hfi_clk_disable(device);
+	if (!queue_delayed_work(device->venus_pm_workq, &venus_hfi_pm_work,
+			msecs_to_jiffies(msm_vidc_pwr_collapse_delay)))
+		dprintk(VIDC_DBG, "PM work already scheduled\n");
+already_disabled:
+	device->clocks_enabled = 0;
+}
+
 static void venus_hfi_core_clear_interrupt(struct venus_hfi_device *device)
 {
 	u32 intr_status = 0;
-	int rc = 0;
+	int rc = 0, ctrl_status;
 
 	if (!device->callback)
 		return;
+
+	mutex_lock(&device->write_lock);
 	mutex_lock(&device->clk_pwr_lock);
 	rc = venus_hfi_clk_gating_off(device);
 	if (rc) {
 		dprintk(VIDC_ERR,
 			"%s : Clock enable failed\n", __func__);
-		mutex_unlock(&device->clk_pwr_lock);
-		return;
+		goto err_clk_gating_off;
 	}
 	intr_status = venus_hfi_read_register(
 			device,
@@ -1603,8 +1703,23 @@
 			VIDC_CPU_CS_A2HSOFTINTCLR, 1, 0);
 	venus_hfi_write_register(device,
 			VIDC_WRAPPER_INTR_CLEAR, intr_status, 0);
-	mutex_unlock(&device->clk_pwr_lock);
+	rc = venus_hfi_is_cmd_pending(device);
+	ctrl_status = venus_hfi_read_register(
+			device,
+			VIDC_CPU_CS_SCIACMDARG0);
+	dprintk(VIDC_INFO,
+			"CLEAR INTERRUPT - cmd_pending %d, ctrl_status 0x%x\n",
+			rc, ctrl_status);
+	if ((ctrl_status & VIDC_CPU_CS_SCIACMDARG0_HFI_CTRL_INIT_IDLE_MSG_BMSK)
+			&& !rc) {
+		dprintk(VIDC_DBG, "SYS_IDLE interrupt, disable clocks\n");
+		venus_hfi_clk_gating_on(device);
+	}
+
 	dprintk(VIDC_DBG, "Cleared WRAPPER/A2H interrupt");
+err_clk_gating_off:
+	mutex_unlock(&device->clk_pwr_lock);
+	mutex_unlock(&device->write_lock);
 }
 
 static int venus_hfi_core_set_resource(void *device,
@@ -2321,26 +2436,6 @@
 	device->callback(SYS_WATCHDOG_TIMEOUT, &cmd_done);
 }
 
-static int venus_hfi_is_cmd_pending(struct venus_hfi_device *dev)
-{
-	struct hfi_queue_header *queue;
-	struct vidc_iface_q_info *q_info;
-	u32 write_ptr, read_ptr;
-	u32 rc = 0;
-	q_info = &dev->iface_queues[VIDC_IFACEQ_CMDQ_IDX];
-	if (!q_info)
-		dprintk(VIDC_ERR, "cannot read shared Q's");
-	queue = (struct hfi_queue_header *) q_info->q_hdr;
-	if (!queue) {
-		dprintk(VIDC_ERR, "queue not present");
-		return -ENOENT;
-	}
-	write_ptr = (u32)queue->qhdr_write_idx;
-	read_ptr = (u32)queue->qhdr_read_idx;
-	rc = read_ptr - write_ptr;
-	return rc;
-}
-
 static int venus_hfi_core_pc_prep(void *device)
 {
 	struct hfi_cmd_sys_pc_prep_packet pkt;
@@ -2408,24 +2503,6 @@
 	mutex_unlock(&device->clk_pwr_lock);
 }
 
-static inline void venus_hfi_clk_gating_on(struct venus_hfi_device *device)
-{
-	if (!device) {
-		dprintk(VIDC_ERR, "Invalid params: %p\n", device);
-		return;
-	}
-	if (!device->clocks_enabled) {
-		dprintk(VIDC_DBG, "Clocks are already disabled");
-		goto already_disabled;
-	}
-	venus_hfi_clk_disable(device);
-	if (!queue_delayed_work(device->venus_pm_workq, &venus_hfi_pm_work,
-			msecs_to_jiffies(msm_vidc_pwr_collapse_delay)))
-		dprintk(VIDC_DBG, "PM work already scheduled\n");
-already_disabled:
-	device->clocks_enabled = 0;
-}
-
 static int venus_hfi_try_clk_gating(struct venus_hfi_device *device)
 {
 	int rc = 0;
@@ -2506,10 +2583,12 @@
 				(struct hfi_msg_sys_debug_packet *) packet;
 			dprintk(VIDC_FW, "FW-SAYS: %s", pkt->rg_msg_data);
 		}
-		if (rc == HFI_MSG_SYS_IDLE)
+		if (rc == HFI_MSG_SYS_IDLE) {
+			dprintk(VIDC_DBG, "Received HFI_MSG_SYS_IDLE\n");
 			rc = venus_hfi_try_clk_gating(device);
-		else if (rc == HFI_MSG_SYS_PC_PREP_DONE) {
-			dprintk(VIDC_DBG, "Received HFI_MSG_SYS_PC_PREP_DONE");
+		} else if (rc == HFI_MSG_SYS_PC_PREP_DONE) {
+			dprintk(VIDC_DBG,
+					"Received HFI_MSG_SYS_PC_PREP_DONE\n");
 			rc = venus_hfi_try_clk_gating(device);
 			if (rc)
 				dprintk(VIDC_ERR,
@@ -3258,15 +3337,21 @@
 	if (device->resources.fw.cookie) {
 		flush_workqueue(device->vidc_workq);
 		flush_workqueue(device->venus_pm_workq);
+		subsystem_put(device->resources.fw.cookie);
+		venus_hfi_interface_queues_release(dev);
+		/* IOMMU operations need to be done before AXI halt.*/
+		venus_hfi_iommu_detach(device);
+		/* Halt the AXI to make sure there are no pending transactions.
+		 * Clocks should be unprepared after making sure axi is halted.
+		 */
+		if(venus_hfi_halt_axi(device))
+			dprintk(VIDC_WARN, "Failed to halt AXI\n");
 		venus_hfi_disable_clks(device);
 		mutex_lock(&device->clk_pwr_lock);
-		subsystem_put(device->resources.fw.cookie);
 		regulator_disable(device->gdsc);
 		device->power_enabled = 0;
 		--device->pwr_cnt;
 		mutex_unlock(&device->clk_pwr_lock);
-		venus_hfi_interface_queues_release(dev);
-		venus_hfi_iommu_detach(device);
 		device->resources.fw.cookie = NULL;
 	}
 }
@@ -3559,6 +3644,7 @@
 	hdev->get_stride_scanline = venus_hfi_get_stride_scanline;
 	hdev->capability_check = venus_hfi_capability_check;
 	hdev->get_core_capabilities = venus_hfi_get_core_capabilities;
+	hdev->power_enable = venus_hfi_power_enable;
 }
 
 int venus_hfi_initialize(struct hfi_device *hdev, u32 device_id,
diff --git a/drivers/media/platform/msm/vidc/vidc_hfi_api.h b/drivers/media/platform/msm/vidc/vidc_hfi_api.h
index cc07806..be9eae0 100644
--- a/drivers/media/platform/msm/vidc/vidc_hfi_api.h
+++ b/drivers/media/platform/msm/vidc/vidc_hfi_api.h
@@ -1129,6 +1129,7 @@
 		u32 *max_width, u32 *max_height);
 	int (*session_clean)(void *sess);
 	int (*get_core_capabilities)(void);
+	int (*power_enable)(void *dev);
 };
 
 typedef void (*hfi_cmd_response_callback) (enum command_response cmd,
diff --git a/drivers/media/platform/msm/vidc/vidc_hfi_io.h b/drivers/media/platform/msm/vidc/vidc_hfi_io.h
index 6377fbf..176db4a 100644
--- a/drivers/media/platform/msm/vidc/vidc_hfi_io.h
+++ b/drivers/media/platform/msm/vidc/vidc_hfi_io.h
@@ -131,6 +131,15 @@
 #define VIDC_VBIF_AT_OLD_HIGH           (VIDC_VBIF_BASE_OFFS + 0xC08)
 #define VIDC_VBIF_AT_NEW_BASE           (VIDC_VBIF_BASE_OFFS + 0xC10)
 #define VIDC_VBIF_AT_NEW_HIGH           (VIDC_VBIF_BASE_OFFS + 0xC18)
+#define VENUS_VBIF_AXI_HALT_CTRL0   (VIDC_VBIF_BASE_OFFS + 0x208)
+#define VENUS_VBIF_AXI_HALT_CTRL1   (VIDC_VBIF_BASE_OFFS + 0x20C)
+
+#define VENUS_VBIF_AXI_HALT_CTRL0_HALT_REQ		BIT(0)
+#define VENUS_VBIF_AXI_HALT_CTRL1_HALT_ACK		BIT(0)
+#define VENUS_VBIF_AXI_HALT_ACK_TIMEOUT_US		500000
+/* Poll interval in uS */
+#define POLL_INTERVAL_US                                50
+
 
 #define VIDC_VENUS0_WRAPPER_VBIF_REQ_PRIORITY \
 	(VIDC_WRAPPER_BASE_OFFS + 0x20)
diff --git a/drivers/media/platform/msm/wfd/vsg-subdev.c b/drivers/media/platform/msm/wfd/vsg-subdev.c
index 0f2fbbb..c20250e 100644
--- a/drivers/media/platform/msm/wfd/vsg-subdev.c
+++ b/drivers/media/platform/msm/wfd/vsg-subdev.c
@@ -24,6 +24,12 @@
 #define DEFAULT_MODE ((enum vsg_modes)VSG_MODE_CFR)
 #define MAX_BUFS_BUSY_WITH_ENC 5
 
+static void vsg_reset_timer(struct hrtimer *timer, ktime_t time)
+{
+	hrtimer_forward_now(timer, time);
+	hrtimer_restart(timer);
+}
+
 static int vsg_release_input_buffer(struct vsg_context *context,
 		struct vsg_buf_info *buf)
 {
@@ -114,7 +120,7 @@
 	INIT_LIST_HEAD(&buf_info->node);
 
 	ktime_get_ts(&buf_info->time);
-	hrtimer_forward_now(&context->threshold_timer, ns_to_ktime(
+	vsg_reset_timer(&context->threshold_timer, ns_to_ktime(
 				context->max_frame_interval));
 
 	temp = NULL;
@@ -438,7 +444,7 @@
 			 * otherwise, diff between two consecutive frames might
 			 * be less than max_frame_interval (for just one sample)
 			 */
-			hrtimer_forward_now(&context->threshold_timer,
+			vsg_reset_timer(&context->threshold_timer,
 				ns_to_ktime(context->max_frame_interval));
 		}
 	}
diff --git a/drivers/media/radio/radio-iris.c b/drivers/media/radio/radio-iris.c
index 5e056be..a554749 100644
--- a/drivers/media/radio/radio-iris.c
+++ b/drivers/media/radio/radio-iris.c
@@ -49,11 +49,15 @@
 static char utf_8_flag;
 static char rt_ert_flag;
 static char formatting_dir;
+static unsigned char sig_blend = CTRL_ON;
 static DEFINE_MUTEX(iris_fm);
 
 module_param(rds_buf, uint, 0);
 MODULE_PARM_DESC(rds_buf, "RDS buffer entries: *100*");
 
+module_param(sig_blend, byte, S_IWUSR | S_IRUGO);
+MODULE_PARM_DESC(sig_blend, "signal blending switch: 0:OFF 1:ON");
+
 static void radio_hci_cmd_task(unsigned long arg);
 static void radio_hci_rx_task(unsigned long arg);
 static struct video_device *video_get_dev(void);
@@ -492,8 +496,15 @@
 static void iris_q_event(struct iris_device *radio,
 				enum iris_evt_t event)
 {
-	struct kfifo *data_b = &radio->data_buf[IRIS_BUF_EVENTS];
+	struct kfifo *data_b;
 	unsigned char evt = event;
+
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return;
+	}
+
+	data_b = &radio->data_buf[IRIS_BUF_EVENTS];
 	if (kfifo_in_locked(data_b, &evt, 1, &radio->buf_lock[IRIS_BUF_EVENTS]))
 		wake_up_interruptible(&radio->event_queue);
 }
@@ -578,8 +589,6 @@
 	skb_queue_head_init(&hdev->cmd_q);
 	skb_queue_head_init(&hdev->raw_q);
 
-	if (!radio)
-		FMDERR(":radio is null");
 
 	radio->fm_hdev = hdev;
 
@@ -670,6 +679,10 @@
 	struct iris_device *radio = video_get_drvdata(video_get_dev());
 	__u16 opcode = 0;
 
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return -EINVAL;
+	}
 	opcode = hci_opcode_pack(HCI_OGF_FM_DIAGNOSTIC_CMD_REQ,
 		HCI_FM_SET_INTERNAL_TONE_GENRATOR);
 	return radio_hci_send_cmd(hdev, opcode,
@@ -1140,7 +1153,7 @@
 	return radio_hci_send_cmd(hdev, opcode, 0, NULL);
 }
 
-static int radio_hci_err(__u16 code)
+static int radio_hci_err(__u32 code)
 {
 	switch (code) {
 	case 0:
@@ -1638,6 +1651,11 @@
 	__u8 status = *((__u8 *) skb->data);
 	struct iris_device *radio = video_get_drvdata(video_get_dev());
 
+	if (radio == NULL) {
+                FMDERR(":radio is null");
+                return;
+        }
+
 	if ((radio->mode == FM_TURNING_OFF) && (status == 0)) {
 		iris_q_event(radio, IRIS_EVT_RADIO_DISABLED);
 		radio_hci_req_complete(hdev, status);
@@ -1655,6 +1673,10 @@
 	struct hci_fm_conf_rsp  *rsp = (void *)skb->data;
 	struct iris_device *radio = video_get_drvdata(video_get_dev());
 
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return;
+	}
 	if (rsp->status)
 		return;
 
@@ -1668,6 +1690,11 @@
 	struct hci_fm_get_trans_conf_rsp  *rsp = (void *)skb->data;
 	struct iris_device *radio = video_get_drvdata(video_get_dev());
 
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return;
+	}
+
 	if (rsp->status)
 		return;
 	memcpy((void *)&radio->trans_conf,  (void*)&rsp->trans_conf_rsp,
@@ -1681,6 +1708,11 @@
 	struct hci_fm_conf_rsp  *rsp = (void *)skb->data;
 	struct iris_device *radio = video_get_drvdata(video_get_dev());
 
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return;
+	}
+
 	if (rsp->status) {
 		radio_hci_req_complete(hdev, rsp->status);
 		return;
@@ -1703,6 +1735,11 @@
 	struct hci_fm_conf_rsp  *rsp = (void *)skb->data;
 	struct iris_device *radio = video_get_drvdata(video_get_dev());
 
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return;
+	}
+
 	if (rsp->status)
 		return;
 
@@ -1718,6 +1755,11 @@
 	struct hci_fm_sig_threshold_rsp  *rsp = (void *)skb->data;
 	struct iris_device *radio = video_get_drvdata(video_get_dev());
 
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return;
+	}
+
 	if (rsp->status)
 		return;
 
@@ -1729,6 +1771,12 @@
 {
 	struct iris_device *radio = video_get_drvdata(video_get_dev());
 	struct hci_fm_station_rsp *rsp = (void *)skb->data;
+
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return;
+	}
+
 	radio->fm_st_rsp = *(rsp);
 
 	/* Tune is always succesful */
@@ -1768,9 +1816,16 @@
 static void hci_cc_feature_list_rsp(struct radio_hci_dev *hdev,
 	struct sk_buff *skb)
 {
+	struct v4l2_capability *v4l_cap;
 	struct hci_fm_feature_list_rsp  *rsp = (void *)skb->data;
 	struct iris_device *radio = video_get_drvdata(video_get_dev());
-	struct v4l2_capability *v4l_cap = radio->g_cap;
+
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return;
+	}
+
+	v4l_cap = radio->g_cap;
 
 	if (rsp->status)
 		return;
@@ -1785,8 +1840,13 @@
 {
 	struct iris_device *radio = video_get_drvdata(video_get_dev());
 	struct hci_fm_dbg_param_rsp *rsp = (void *)skb->data;
-	radio->st_dbg_param = *(rsp);
 
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return;
+	}
+
+	radio->st_dbg_param = *(rsp);
 	if (radio->st_dbg_param.status)
 		return;
 
@@ -1796,7 +1856,13 @@
 static void iris_q_evt_data(struct iris_device *radio,
 				char *data, int len, int event)
 {
-	struct kfifo *data_b = &radio->data_buf[event];
+	struct kfifo *data_b;
+
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return;
+	}
+	data_b = &radio->data_buf[event];
 	if (kfifo_in_locked(data_b, data, len, &radio->buf_lock[event]))
 		wake_up_interruptible(&radio->event_queue);
 }
@@ -1833,6 +1899,11 @@
 	__u8 status = *((__u8 *) skb->data);
 	__u8 len;
 
+        if (radio == NULL) {
+                FMDERR(":radio is null");
+                return;
+        }
+
 	if (status)
 		return;
 	len = skb->data[1];
@@ -1913,6 +1984,11 @@
 {
 	struct iris_device *radio = video_get_drvdata(video_get_dev());
 	u8  status = skb->data[0];
+
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return;
+	}
 	if (status) {
 		FMDERR("status = %d", status);
 		return;
@@ -2046,6 +2122,10 @@
 	int i;
 	struct iris_device *radio = video_get_drvdata(video_get_dev());
 
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return;
+	}
 	memcpy(&radio->fm_st_rsp.station_rsp, &skb->data[0],
 				sizeof(struct hci_ev_tune_status));
 	iris_q_event(radio, IRIS_EVT_TUNE_SUCC);
@@ -2088,6 +2168,10 @@
 	int abs_freq;
 	int len;
 
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return;
+	}
 	ev = kmalloc(sizeof(*ev), GFP_ATOMIC);
 	if (!ev) {
 		FMDERR("Memory allocation failed");
@@ -2146,6 +2230,10 @@
 	radio = video_get_drvdata(video_get_dev());
 	index = RDSGRP_DATA_OFFSET;
 
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return;
+	}
 	for (blocknum = 0; blocknum < RDS_BLOCKS_NUM; blocknum++) {
 		temp.rdsBlk[blocknum].rdsLsb =
 			(skb->data[index]);
@@ -2552,9 +2640,15 @@
 static int iris_search(struct iris_device *radio, int on, int dir)
 {
 	int retval = 0;
-	enum search_t srch = radio->g_search_mode & SRCH_MODE;
-	radio->search_on = on;
+	enum search_t srch;
 
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return -EINVAL;
+	}
+
+	srch = radio->g_search_mode & SRCH_MODE;
+	radio->search_on = on;
 	if (on) {
 		switch (srch) {
 		case SCAN_FOR_STRONG:
@@ -2596,6 +2690,12 @@
 
 	int rds_grps_proc = 0x00;
 	int retval = 0;
+
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return -EINVAL;
+	}
+
 	if (radio->power_mode != power_mode) {
 
 		if (power_mode) {
@@ -2634,6 +2734,12 @@
 static int iris_recv_set_region(struct iris_device *radio, int req_region)
 {
 	int retval;
+
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return -EINVAL;
+	}
+
 	radio->region = req_region;
 
 	retval = hci_set_fm_recv_conf(
@@ -2647,6 +2753,11 @@
 static int iris_trans_set_region(struct iris_device *radio, int req_region)
 {
 	int retval;
+
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return -EINVAL;
+	}
 	radio->region = req_region;
 
 	retval = hci_set_fm_trans_conf(
@@ -2660,6 +2771,11 @@
 {
 
 	int retval;
+
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return -EINVAL;
+	}
 	retval = hci_fm_tune_station(&freq, radio->fm_hdev);
 	if (retval < 0)
 		FMDERR("Error while setting the frequency : %d\n", retval);
@@ -2689,6 +2805,11 @@
 	char cal_mode = 0x00;
 	int retval = 0x00;
 
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return -EINVAL;
+	}
+
 	cal_mode = PROCS_CALIB_MODE;
 	radio->mode = FM_CALIB;
 	retval = hci_cmd(HCI_FM_ENABLE_RECV_CMD,
@@ -2723,6 +2844,11 @@
 	struct hci_fm_def_data_rd_req rd;
 	int lsb, msb;
 
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return -EINVAL;
+	}
+
 	switch (ctrl->id) {
 	case V4L2_CID_AUDIO_VOLUME:
 		break;
@@ -3008,6 +3134,11 @@
 	struct iris_device *radio = video_get_drvdata(video_devdata(file));
 	struct hci_fm_def_data_rd_req default_data_rd;
 
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return -EINVAL;
+	}
+
 	switch ((ctrl->controls[0]).id) {
 	case V4L2_CID_PRIVATE_IRIS_READ_DEFAULT:
 		data = (ctrl->controls[0]).string;
@@ -3037,6 +3168,10 @@
 	struct iris_device *radio = video_get_drvdata(video_devdata(file));
 	char *data = NULL;
 
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return -EINVAL;
+	}
 	switch ((ctrl->controls[0]).id) {
 	case V4L2_CID_RDS_TX_PS_NAME:
 		FMDBG("In V4L2_CID_RDS_TX_PS_NAME\n");
@@ -3160,6 +3295,11 @@
 	char sinr_th, sinr;
 	__u8 intf_det_low_th, intf_det_high_th, intf_det_out;
 
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return -EINVAL;
+	}
+
 	switch (ctrl->id) {
 	case V4L2_CID_PRIVATE_IRIS_TX_TONE:
 		radio->tone_freq = ctrl->value;
@@ -3472,13 +3612,26 @@
 		radio->riva_data_req.cmd_params.start_addr = ctrl->value;
 		break;
 	case V4L2_CID_PRIVATE_IRIS_RIVA_ACCS_LEN:
-		radio->riva_data_req.cmd_params.length = ctrl->value;
+		if ((ctrl->value > 0) &&
+			(ctrl->value <= MAX_RIVA_PEEK_RSP_SIZE)) {
+			radio->riva_data_req.cmd_params.length = ctrl->value;
+		} else {
+			FMDERR("Length %d is more than the buffer size %d\n",
+			ctrl->value, MAX_RIVA_PEEK_RSP_SIZE);
+			retval = -EINVAL;
+		}
 		break;
 	case V4L2_CID_PRIVATE_IRIS_RIVA_POKE:
-		memcpy(radio->riva_data_req.data, (void *)ctrl->value,
-					radio->riva_data_req.cmd_params.length);
-		radio->riva_data_req.cmd_params.subopcode = RIVA_POKE_OPCODE;
-		retval = hci_poke_data(&radio->riva_data_req , radio->fm_hdev);
+		if (radio->riva_data_req.cmd_params.length <= MAX_RIVA_PEEK_RSP_SIZE) {
+			memcpy(radio->riva_data_req.data, (void *)ctrl->value,
+						radio->riva_data_req.cmd_params.length);
+			radio->riva_data_req.cmd_params.subopcode = RIVA_POKE_OPCODE;
+			retval = hci_poke_data(&radio->riva_data_req , radio->fm_hdev);
+		} else {
+			FMDERR("Can not copy into driver's buffer. Length %d is more than"
+			 "the buffer size %d\n", ctrl->value, MAX_RIVA_PEEK_RSP_SIZE);
+			retval = -EINVAL;
+		}
 		break;
 	case V4L2_CID_PRIVATE_IRIS_SSBI_ACCS_ADDR:
 		radio->ssbi_data_accs.start_addr = ctrl->value;
@@ -3829,6 +3982,10 @@
 	/* Pass the mode of SPUR_CLK */
 	default_data.mode = CKK_SPUR;
 
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return -EINVAL;
+	}
 	temp = radio->spur_table_size;
 	for (cnt = 0; cnt < (temp / 5); cnt++) {
 		offset = 0;
@@ -3899,6 +4056,10 @@
 	int retval;
 	struct iris_device *radio = video_get_drvdata(video_devdata(file));
 
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return -EINVAL;
+	}
 	if (tuner->index > 0) {
 		FMDERR("Invalid Tuner Index");
 		return -EINVAL;
@@ -3942,6 +4103,12 @@
 {
 	struct iris_device *radio = video_get_drvdata(video_devdata(file));
 	int retval = 0;
+
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return -EINVAL;
+	}
+
 	if (tuner->index > 0)
 		return -EINVAL;
 
@@ -3993,6 +4160,10 @@
 	int retval = -1;
 	freq->frequency = freq->frequency / TUNE_PARAM;
 
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return -EINVAL;
+	}
 	if (freq->type != V4L2_TUNER_RADIO)
 		return -EINVAL;
 
@@ -4120,6 +4291,11 @@
 {
 	struct iris_device *radio;
 	radio = video_get_drvdata(video_devdata(file));
+
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return -EINVAL;
+	}
 	strlcpy(capability->driver, DRIVER_NAME, sizeof(capability->driver));
 	strlcpy(capability->card, DRIVER_CARD, sizeof(capability->card));
 	capability->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
@@ -4131,6 +4307,11 @@
 {
 	int retval;
 
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return -EINVAL;
+	}
+
 	radio->mute_mode.soft_mute = CTRL_ON;
 	retval = hci_set_fm_mute_mode(&radio->mute_mode,
 					radio->fm_hdev);
@@ -4141,7 +4322,7 @@
 	}
 
 	radio->stereo_mode.stereo_mode = CTRL_OFF;
-	radio->stereo_mode.sig_blend = CTRL_ON;
+	radio->stereo_mode.sig_blend = sig_blend;
 	radio->stereo_mode.intf_blend = CTRL_ON;
 	radio->stereo_mode.most_switch = CTRL_ON;
 	retval = hci_set_fm_stereo_mode(&radio->stereo_mode,
@@ -4168,7 +4349,14 @@
 static int initialise_trans(struct iris_device *radio)
 {
 
-	int retval = hci_cmd(HCI_FM_GET_TX_CONFIG, radio->fm_hdev);
+	int retval;
+
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return -EINVAL;
+	}
+
+	retval = hci_cmd(HCI_FM_GET_TX_CONFIG, radio->fm_hdev);
 	if (retval < 0)
 		FMDERR("get frequency failed %d\n", retval);
 
@@ -4179,6 +4367,11 @@
 {
 	int retval = 1;
 
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return -EINVAL;
+	}
+
 	if (radio->mode == FM_OFF || radio->mode == FM_RECV)
 		retval = 0;
 
@@ -4321,6 +4514,10 @@
 	int i;
 	struct iris_device *radio = platform_get_drvdata(pdev);
 
+	if (radio == NULL) {
+		FMDERR(":radio is null");
+		return -EINVAL;
+	}
 	video_unregister_device(radio->videodev);
 
 	for (i = 0; i < IRIS_BUF_MAX; i++)
diff --git a/drivers/media/radio/radio-tavarua.c b/drivers/media/radio/radio-tavarua.c
index e0a99e2..6b9f2b3 100644
--- a/drivers/media/radio/radio-tavarua.c
+++ b/drivers/media/radio/radio-tavarua.c
@@ -3051,7 +3051,7 @@
 	int retval = 0;
 	int bytes_to_copy;
 	int bytes_copied = 0;
-	int bytes_left = 0;
+	__u32 bytes_left = 0;
 	int chunk_index = 0;
 	char tx_data[XFR_REG_NUM];
 	struct tavarua_device *radio = video_get_drvdata(video_devdata(file));
@@ -3066,15 +3066,15 @@
 
 		chunk_index = 0;
 		bytes_copied = 0;
-		bytes_left = min((int)(ctrl->controls[0]).size,
-			MAX_PS_LENGTH);
+		bytes_left = min((ctrl->controls[0]).size,
+			(__u32)MAX_PS_LENGTH);
 		data = (ctrl->controls[0]).string;
 
 		/* send payload to FM hardware */
 		while (bytes_left) {
 			chunk_index++;
 			FMDBG("chunk is %d", chunk_index);
-			bytes_to_copy = min(bytes_left, XFR_REG_NUM);
+			bytes_to_copy = min(bytes_left, (__u32)XFR_REG_NUM);
 			/*Clear the tx_data */
 			memset(tx_data, 0, XFR_REG_NUM);
 			if (copy_from_user(tx_data,
@@ -3116,12 +3116,12 @@
 		FMDBG("Passed RT String : %s\n",
 			(ctrl->controls[0]).string);
 		bytes_left =
-		    min((int)(ctrl->controls[0]).size, MAX_RT_LENGTH);
+		    min((ctrl->controls[0]).size, (__u32)MAX_RT_LENGTH);
 		data = (ctrl->controls[0]).string;
 		/* send payload to FM hardware */
 		while (bytes_left) {
 			chunk_index++;
-			bytes_to_copy = min(bytes_left, XFR_REG_NUM);
+			bytes_to_copy = min(bytes_left, (__u32)XFR_REG_NUM);
 			memset(tx_data, 0, XFR_REG_NUM);
 			if (copy_from_user(tx_data,
 				    data + bytes_copied, bytes_to_copy))
@@ -4466,8 +4466,8 @@
 
 	struct marimba_fm_platform_data *tavarua_pdata;
 	struct tavarua_device *radio;
-	int retval;
-	int i;
+	int retval = 0;
+	int i = 0, j = 0;
 	FMDBG("%s: probe called\n", __func__);
 	/* private data allocation */
 	radio = kzalloc(sizeof(struct tavarua_device), GFP_KERNEL);
@@ -4480,6 +4480,7 @@
 	tavarua_pdata = pdev->dev.platform_data;
 	radio->pdata = tavarua_pdata;
 	radio->dev = &pdev->dev;
+	radio->wqueue = NULL;
 	platform_set_drvdata(pdev, radio);
 
 	/* video device allocation */
@@ -4509,15 +4510,16 @@
 		if (kfifo_alloc_rc!=0) {
 			printk(KERN_ERR "%s: failed allocating buffers %d\n",
 				__func__, kfifo_alloc_rc);
-			goto err_bufs;
+		        retval = -ENOMEM;
+		        goto err_all;
 		}
 	}
 	/* initializing the device count  */
 	atomic_set(&radio->users, 1);
 	radio->xfr_in_progress = 0;
 	radio->xfr_bytes_left = 0;
-	for (i = 0; i < TAVARUA_XFR_MAX; i++)
-		radio->pending_xfrs[i] = 0;
+	for (j = 0; j < TAVARUA_XFR_MAX; j++)
+		radio->pending_xfrs[j] = 0;
 
 	/* init transmit data */
 	radio->tx_mode = TAVARUA_TX_RT;
@@ -4548,11 +4550,14 @@
     /*Start the worker thread for event handling and register read_int_stat
 	as worker function*/
 	radio->wqueue  = create_singlethread_workqueue("kfmradio");
-	if (!radio->wqueue)
-		return -ENOMEM;
+	if (!radio->wqueue) {
+	        retval = -ENOMEM;
+		goto err_all;
+        }
 
 	/* register video device */
-	if (video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr)) {
+	retval = video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr);
+	if (retval != 0) {
 		printk(KERN_WARNING DRIVER_NAME
 				": Could not register video device\n");
 		goto err_all;
@@ -4562,9 +4567,11 @@
 
 err_all:
 	video_device_release(radio->videodev);
-err_bufs:
-	for (; i > -1; i--)
+	if (radio->wqueue)
+		destroy_workqueue(radio->wqueue);
+	for (i--; i >= 0; i--) {
 		kfifo_free(&radio->data_buf[i]);
+        }
 err_radio:
 	kfree(radio);
 err_initial:
diff --git a/drivers/media/video/v4l2-ctrls.c b/drivers/media/video/v4l2-ctrls.c
index 7e4ceb3..9dd06ee 100644
--- a/drivers/media/video/v4l2-ctrls.c
+++ b/drivers/media/video/v4l2-ctrls.c
@@ -284,6 +284,7 @@
 		"4.2",
 		"5",
 		"5.1",
+		"5.2",
 		NULL,
 	};
 	static const char * const h264_loop_filter[] = {
diff --git a/drivers/mfd/wcd9xxx-irq.c b/drivers/mfd/wcd9xxx-irq.c
index dc32efd..9209f0b 100644
--- a/drivers/mfd/wcd9xxx-irq.c
+++ b/drivers/mfd/wcd9xxx-irq.c
@@ -150,13 +150,15 @@
 				      msm_cpuidle_get_deep_idle_latency());
 	}
 	mutex_unlock(&wcd9xxx_res->pm_lock);
-	os = wcd9xxx_pm_cmpxchg(wcd9xxx_res,
-					WCD9XXX_PM_SLEEPABLE,
-					WCD9XXX_PM_AWAKE);
+
 	if (!wait_event_timeout(wcd9xxx_res->pm_wq,
-			(os  == WCD9XXX_PM_SLEEPABLE ||
-			 os == WCD9XXX_PM_AWAKE),
-			msecs_to_jiffies(WCD9XXX_SYSTEM_RESUME_TIMEOUT_MS))) {
+				((os =  wcd9xxx_pm_cmpxchg(wcd9xxx_res,
+						  WCD9XXX_PM_SLEEPABLE,
+						  WCD9XXX_PM_AWAKE)) ==
+							WCD9XXX_PM_SLEEPABLE ||
+					(os == WCD9XXX_PM_AWAKE)),
+				msecs_to_jiffies(
+					WCD9XXX_SYSTEM_RESUME_TIMEOUT_MS))) {
 		pr_warn("%s: system didn't resume within %dms, s %d, w %d\n",
 			__func__,
 			WCD9XXX_SYSTEM_RESUME_TIMEOUT_MS, wcd9xxx_res->pm_state,
diff --git a/drivers/misc/qseecom.c b/drivers/misc/qseecom.c
index a30607c..2162294 100644
--- a/drivers/misc/qseecom.c
+++ b/drivers/misc/qseecom.c
@@ -91,7 +91,6 @@
 
 static struct class *driver_class;
 static dev_t qseecom_device_no;
-static struct cdev qseecom_cdev;
 
 static DEFINE_MUTEX(qsee_bw_mutex);
 static DEFINE_MUTEX(app_access_lock);
@@ -162,6 +161,7 @@
 	uint32_t qsee_perf_client;
 	struct qseecom_clk qsee;
 	struct qseecom_clk ce_drv;
+	struct cdev cdev;
 };
 
 struct qseecom_client_handle {
@@ -251,6 +251,12 @@
 			break;
 	}
 	spin_unlock_irqrestore(&qseecom.registered_listener_list_lock, flags);
+
+	if ((entry != NULL) && (entry->svc.listener_id != listener_id)) {
+		pr_err("Service id: %u is not found\n", listener_id);
+		return NULL;
+	}
+
 	return entry;
 }
 
@@ -449,6 +455,11 @@
 	}
 	/* Get the physical address of the ION BUF */
 	ret = ion_phys(qseecom.ion_clnt, data->client.ihandle, &pa, &len);
+	if (len < req.sb_len) {
+		pr_err("Requested length (0x%x) is > allocated (0x%x)\n",
+			req.sb_len, len);
+		return -EINVAL;
+	}
 	/* Populate the structure for sending scm call to load image */
 	data->client.sb_virt = (char *) ion_map_kernel(qseecom.ion_clnt,
 							data->client.ihandle);
@@ -494,6 +505,11 @@
 		}
 		spin_unlock_irqrestore(&qseecom.registered_listener_list_lock,
 				flags);
+
+		if (ptr_svc == NULL) {
+			pr_err("Listener Svc %d does not exist\n", lstnr);
+			return -EINVAL;
+		}
 		if (ptr_svc->svc.listener_id != lstnr) {
 			pr_warning("Service requested for does on exist\n");
 			return -ERESTARTSYS;
@@ -860,6 +876,10 @@
 			req_ptr, send_svc_ireq_ptr);
 		return -EINVAL;
 	}
+	if ((!req_ptr->cmd_req_buf) || (!req_ptr->resp_buf)) {
+		pr_err("Invalid req/resp buffer, exiting\n");
+		return -EINVAL;
+	}
 	send_svc_ireq_ptr->qsee_cmd_id = req_ptr->cmd_id;
 	send_svc_ireq_ptr->key_type =
 	((struct qseecom_rpmb_provision_key *)req_ptr->cmd_req_buf)->key_type;
@@ -1063,8 +1083,6 @@
 	if (ret)
 		return ret;
 
-	pr_debug("sending cmd_req->rsp size: %u, ptr: 0x%p\n",
-			req.resp_len, req.resp_buf);
 	return ret;
 }
 
@@ -1254,8 +1272,7 @@
 	ret = __qseecom_update_cmd_buf(&req, true, data, false);
 	if (ret)
 		return ret;
-	pr_debug("sending cmd_req->rsp size: %u, ptr: 0x%p\n",
-			req.resp_len, req.resp_buf);
+
 	return ret;
 }
 
@@ -1273,6 +1290,11 @@
 	struct qseecom_registered_listener_list *this_lstnr;
 
 	this_lstnr = __qseecom_find_svc(data->listener.id);
+	if (!this_lstnr) {
+		pr_err("Invalid listener ID\n");
+		return -ENODATA;
+	}
+
 	while (1) {
 		if (wait_event_freezable(this_lstnr->rcv_req_wq,
 				__qseecom_listener_has_rcvd_req(data,
@@ -3330,7 +3352,7 @@
 	if (IS_ERR(driver_class)) {
 		rc = -ENOMEM;
 		pr_err("class_create failed %d\n", rc);
-		goto unregister_chrdev_region;
+		goto exit_unreg_chrdev_region;
 	}
 
 	class_dev = device_create(driver_class, NULL, qseecom_device_no, NULL,
@@ -3338,16 +3360,16 @@
 	if (!class_dev) {
 		pr_err("class_device_create failed %d\n", rc);
 		rc = -ENOMEM;
-		goto class_destroy;
+		goto exit_destroy_class;
 	}
 
-	cdev_init(&qseecom_cdev, &qseecom_fops);
-	qseecom_cdev.owner = THIS_MODULE;
+	cdev_init(&qseecom.cdev, &qseecom_fops);
+	qseecom.cdev.owner = THIS_MODULE;
 
-	rc = cdev_add(&qseecom_cdev, MKDEV(MAJOR(qseecom_device_no), 0), 1);
+	rc = cdev_add(&qseecom.cdev, MKDEV(MAJOR(qseecom_device_no), 0), 1);
 	if (rc < 0) {
 		pr_err("cdev_add failed %d\n", rc);
-		goto err;
+		goto exit_destroy_device;
 	}
 
 	INIT_LIST_HEAD(&qseecom.registered_listener_list_head);
@@ -3363,7 +3385,7 @@
 				&qsee_not_legacy, sizeof(qsee_not_legacy));
 	if (rc) {
 		pr_err("Failed to retrieve QSEOS version information %d\n", rc);
-		goto err;
+		goto exit_del_cdev;
 	}
 	if (qsee_not_legacy) {
 		uint32_t feature = 10;
@@ -3373,14 +3395,14 @@
 			&qseecom.qsee_version, sizeof(qseecom.qsee_version));
 		if (rc) {
 			pr_err("Failed to get QSEE version info %d\n", rc);
-			goto err;
+			goto exit_del_cdev;
 		}
 		qseecom.qseos_version = QSEOS_VERSION_14;
 	} else {
 		pr_err("QSEE legacy version is not supported:");
 		pr_err("Support for TZ1.3 and earlier is deprecated\n");
 		rc = -EINVAL;
-		goto err;
+		goto exit_del_cdev;
 	}
 	qseecom.commonlib_loaded = false;
 	qseecom.pdev = class_dev;
@@ -3389,7 +3411,7 @@
 	if (qseecom.ion_clnt == NULL) {
 		pr_err("Ion client cannot be created\n");
 		rc = -ENOMEM;
-		goto err;
+		goto exit_del_cdev;
 	}
 
 	/* register client for bus scaling */
@@ -3401,7 +3423,7 @@
 			pr_err("Fail to get disk-encrypt pipe pair information.\n");
 			qseecom.ce_info.disk_encrypt_pipe = 0xff;
 			rc = -EINVAL;
-			goto err;
+			goto exit_destroy_ion_client;
 		} else {
 			pr_warn("bam_pipe_pair=0x%x",
 			qseecom.ce_info.disk_encrypt_pipe);
@@ -3413,7 +3435,7 @@
 			pr_err("Fail to get qsee ce hw instance information.\n");
 			qseecom.ce_info.qsee_ce_hw_instance = 0xff;
 			rc = -EINVAL;
-			goto err;
+			goto exit_destroy_ion_client;
 		} else {
 			pr_warn("qsee-ce-hw-instance=0x%x",
 			qseecom.ce_info.qsee_ce_hw_instance);
@@ -3425,7 +3447,7 @@
 			pr_err("Fail to get hlos ce hw instance information.\n");
 			qseecom.ce_info.hlos_ce_hw_instance = 0xff;
 			rc = -EINVAL;
-			goto err;
+			goto exit_destroy_ion_client;
 		} else {
 			pr_warn("hlos-ce-hw-instance=0x%x",
 			qseecom.ce_info.hlos_ce_hw_instance);
@@ -3436,13 +3458,13 @@
 
 		ret = __qseecom_init_clk(CLK_QSEE);
 		if (ret)
-			goto err;
+			goto exit_destroy_ion_client;
 
 		if (qseecom.qsee.instance != qseecom.ce_drv.instance) {
 			ret = __qseecom_init_clk(CLK_CE_DRV);
 			if (ret) {
 				__qseecom_deinit_clk(CLK_QSEE);
-				goto err;
+				goto exit_destroy_ion_client;
 			}
 		} else {
 			struct qseecom_clk *qclk;
@@ -3472,7 +3494,7 @@
 			} else {
 				pr_err("Fail to get secure app region info\n");
 				rc = -EINVAL;
-				goto err;
+				goto exit_destroy_ion_client;
 			}
 			rc = scm_call(SCM_SVC_TZSCHEDULER, 1, &req, sizeof(req),
 							&resp, sizeof(resp));
@@ -3480,7 +3502,7 @@
 				pr_err("send secapp reg fail %d resp.res %d\n",
 							rc, resp.result);
 				rc = -EINVAL;
-				goto err;
+				goto exit_destroy_ion_client;
 			}
 		}
 	} else {
@@ -3494,11 +3516,16 @@
 	if (!qseecom.qsee_perf_client)
 		pr_err("Unable to register bus client\n");
 	return 0;
-err:
+
+exit_destroy_ion_client:
+	ion_client_destroy(qseecom.ion_clnt);
+exit_del_cdev:
+	cdev_del(&qseecom.cdev);
+exit_destroy_device:
 	device_destroy(driver_class, qseecom_device_no);
-class_destroy:
+exit_destroy_class:
 	class_destroy(driver_class);
-unregister_chrdev_region:
+exit_unreg_chrdev_region:
 	unregister_chrdev_region(qseecom_device_no, 1);
 	return rc;
 }
@@ -3509,69 +3536,64 @@
 	unsigned long flags = 0;
 	int ret = 0;
 
-	if (pdev->dev.platform_data != NULL)
-		msm_bus_scale_unregister_client(qseecom.qsee_perf_client);
-
 	spin_lock_irqsave(&qseecom.registered_kclient_list_lock, flags);
-	kclient = list_entry((&qseecom.registered_kclient_list_head)->next,
-		struct qseecom_registered_kclient_list, list);
-	if (list_empty(&kclient->list)) {
-		spin_unlock_irqrestore(&qseecom.registered_kclient_list_lock,
-			flags);
-		return 0;
-	}
+
 	list_for_each_entry(kclient, &qseecom.registered_kclient_list_head,
-				list) {
-			if (kclient)
-				list_del(&kclient->list);
-			break;
-	}
-	spin_unlock_irqrestore(&qseecom.registered_kclient_list_lock, flags);
+								list) {
+		if (!kclient)
+			goto exit_irqrestore;
 
+		/* Break the loop if client handle is NULL */
+		if (!kclient->handle)
+			goto exit_free_kclient;
 
-	while (kclient->handle != NULL) {
+		if (list_empty(&kclient->list))
+			goto exit_free_kc_handle;
+
+		list_del(&kclient->list);
 		ret = qseecom_unload_app(kclient->handle->dev);
-		if (ret == 0) {
+		if (!ret) {
 			kzfree(kclient->handle->dev);
 			kzfree(kclient->handle);
 			kzfree(kclient);
 		}
-		spin_lock_irqsave(&qseecom.registered_kclient_list_lock, flags);
-		kclient = list_entry(
-				(&qseecom.registered_kclient_list_head)->next,
-				struct qseecom_registered_kclient_list, list);
-		if (list_empty(&kclient->list)) {
-			spin_unlock_irqrestore(
-				&qseecom.registered_kclient_list_lock, flags);
-			return 0;
-		}
-		list_for_each_entry(kclient,
-				&qseecom.registered_kclient_list_head, list) {
-			if (kclient)
-				list_del(&kclient->list);
-			break;
-		}
-		spin_unlock_irqrestore(&qseecom.registered_kclient_list_lock,
-				flags);
-		if (!kclient) {
-			ret = 0;
-			break;
-		}
 	}
-	if (qseecom.qseos_version  > QSEEE_VERSION_00)
+
+exit_free_kc_handle:
+	kzfree(kclient->handle);
+exit_free_kclient:
+	kzfree(kclient);
+exit_irqrestore:
+	spin_unlock_irqrestore(&qseecom.registered_kclient_list_lock, flags);
+
+	if (qseecom.qseos_version > QSEEE_VERSION_00)
 		qseecom_unload_commonlib_image();
 
 	if (qseecom.qsee_perf_client)
 		msm_bus_scale_client_update_request(qseecom.qsee_perf_client,
 									0);
+	if (pdev->dev.platform_data != NULL)
+		msm_bus_scale_unregister_client(qseecom.qsee_perf_client);
+
 	/* register client for bus scaling */
 	if (pdev->dev.of_node) {
 		__qseecom_deinit_clk(CLK_QSEE);
 		if (qseecom.qsee.instance != qseecom.ce_drv.instance)
 			__qseecom_deinit_clk(CLK_CE_DRV);
 	}
+
+	ion_client_destroy(qseecom.ion_clnt);
+
+	cdev_del(&qseecom.cdev);
+
+	device_destroy(driver_class, qseecom_device_no);
+
+	class_destroy(driver_class);
+
+	unregister_chrdev_region(qseecom_device_no, 1);
+
 	return ret;
-};
+}
 
 static struct of_device_id qseecom_match[] = {
 	{
@@ -3597,10 +3619,7 @@
 
 static void __devexit qseecom_exit(void)
 {
-	device_destroy(driver_class, qseecom_device_no);
-	class_destroy(driver_class);
-	unregister_chrdev_region(qseecom_device_no, 1);
-	ion_client_destroy(qseecom.ion_clnt);
+	platform_driver_unregister(&qseecom_plat_driver);
 }
 
 MODULE_LICENSE("GPL v2");
diff --git a/drivers/misc/smsc_hub.c b/drivers/misc/smsc_hub.c
index 0147e66..6f98dc7 100644
--- a/drivers/misc/smsc_hub.c
+++ b/drivers/misc/smsc_hub.c
@@ -385,26 +385,27 @@
 static int __devinit smsc_hub_probe(struct platform_device *pdev)
 {
 	int ret = 0;
-	const struct smsc_hub_platform_data *pdata;
+	struct smsc_hub_platform_data *pdata;
 	struct device_node *node = pdev->dev.of_node;
 	struct i2c_adapter *i2c_adap;
 	struct i2c_board_info i2c_info;
+	struct of_dev_auxdata *hsic_host_auxdata;
 
 	if (pdev->dev.of_node) {
 		dev_dbg(&pdev->dev, "device tree enabled\n");
-		pdev->dev.platform_data = msm_hub_dt_to_pdata(pdev);
-		if (IS_ERR(pdev->dev.platform_data))
-			return PTR_ERR(pdev->dev.platform_data);
-
-		dev_set_name(&pdev->dev, smsc_hub_driver.driver.name);
+		hsic_host_auxdata = dev_get_platdata(&pdev->dev);
+		pdata = msm_hub_dt_to_pdata(pdev);
+		if (IS_ERR(pdata))
+			return PTR_ERR(pdata);
+	} else {
+		pdata = pdev->dev.platform_data;
 	}
 
-	if (!pdev->dev.platform_data) {
+	if (!pdata) {
 		dev_err(&pdev->dev, "No platform data\n");
 		return -ENODEV;
 	}
 
-	pdata = pdev->dev.platform_data;
 	if (!pdata->hub_reset)
 		return -EINVAL;
 
@@ -413,7 +414,7 @@
 		return -ENOMEM;
 
 	smsc_hub->dev = &pdev->dev;
-	smsc_hub->pdata = pdev->dev.platform_data;
+	smsc_hub->pdata = pdata;
 
 	smsc_hub->hub_vbus_reg = devm_regulator_get(&pdev->dev, "hub_vbus");
 	ret = PTR_ERR(smsc_hub->hub_vbus_reg);
@@ -494,7 +495,7 @@
 	i2c_put_adapter(i2c_adap);
 
 i2c_add_fail:
-	ret = of_platform_populate(node, NULL, NULL, &pdev->dev);
+	ret = of_platform_populate(node, NULL, hsic_host_auxdata, &pdev->dev);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to add child node, ret=%d\n", ret);
 		goto uninit_gpio;
@@ -523,7 +524,7 @@
 {
 	const struct smsc_hub_platform_data *pdata;
 
-	pdata = pdev->dev.platform_data;
+	pdata = smsc_hub->pdata;
 	if (smsc_hub->client) {
 		i2c_unregister_device(smsc_hub->client);
 		smsc_hub->client = NULL;
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index e5315bd..743668b 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -2800,8 +2800,11 @@
  err_putdisk:
 	put_disk(md->disk);
  err_kfree:
+	if (!subname)
+		__clear_bit(md->name_idx, name_use);
 	kfree(md);
  out:
+	__clear_bit(devidx, dev_use);
 	return ERR_PTR(ret);
 }
 
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index eb5d365..421774f 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -414,14 +414,12 @@
 #endif
 	mmc_init_context_info(card->host);
 
-	if (mmc_use_core_runtime_pm(card->host)) {
-		ret = pm_runtime_set_active(&card->dev);
-		if (ret)
-			pr_err("%s: %s: failed setting runtime active: ret: %d\n",
-			       mmc_hostname(card->host), __func__, ret);
-		else if (!mmc_card_sdio(card))
-			pm_runtime_enable(&card->dev);
-	}
+	ret = pm_runtime_set_active(&card->dev);
+	if (ret)
+		pr_err("%s: %s: failed setting runtime active: ret: %d\n",
+		       mmc_hostname(card->host), __func__, ret);
+	else if (!mmc_card_sdio(card) && mmc_use_core_runtime_pm(card->host))
+		pm_runtime_enable(&card->dev);
 
 	ret = device_add(&card->dev);
 	if (ret)
diff --git a/drivers/mmc/core/cd-gpio.c b/drivers/mmc/core/cd-gpio.c
index 14dd313..45ec5c2 100644
--- a/drivers/mmc/core/cd-gpio.c
+++ b/drivers/mmc/core/cd-gpio.c
@@ -111,8 +111,12 @@
 {
 	struct mmc_cd_gpio *cd = host->hotplug.handler_priv;
 
+	if (!cd || !gpio_is_valid(cd->gpio))
+		return;
+
 	free_irq(host->hotplug.irq, host);
 	gpio_free(cd->gpio);
+	cd->gpio = -EINVAL;
 	kfree(cd);
 }
 EXPORT_SYMBOL(mmc_cd_gpio_free);
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 293033b..a296e48 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -61,6 +61,7 @@
 
 /* Flushing a large amount of cached data may take a long time. */
 #define MMC_FLUSH_REQ_TIMEOUT_MS 90000 /* msec */
+#define MMC_CACHE_DISBALE_TIMEOUT_MS 180000 /* msec */
 
 static struct workqueue_struct *workqueue;
 
@@ -744,7 +745,11 @@
 				 */
 				mmc_update_clk_scaling(host);
 				err = mmc_stop_request(host);
-				if (err && !context_info->is_done_rcv) {
+				if (err == MMC_BLK_NO_REQ_TO_STOP) {
+					pending_is_urgent = true;
+					/* wait for done/new/urgent event */
+					continue;
+				} else if (err && !context_info->is_done_rcv) {
 					err = MMC_BLK_ABORT;
 					break;
 				}
@@ -3389,14 +3394,14 @@
 
 		if (card->ext_csd.cache_ctrl ^ enable) {
 			if (!enable)
-				timeout = MMC_FLUSH_REQ_TIMEOUT_MS;
+				timeout = MMC_CACHE_DISBALE_TIMEOUT_MS;
 
 			err = mmc_switch_ignore_timeout(card,
 					EXT_CSD_CMD_SET_NORMAL,
 					EXT_CSD_CACHE_CTRL, enable, timeout);
 
 			if (err == -ETIMEDOUT && !enable) {
-				pr_debug("%s:cache disable operation timeout\n",
+				pr_err("%s:cache disable operation timeout\n",
 						mmc_hostname(card->host));
 				rc = mmc_interrupt_hpi(card);
 				if (rc)
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index edd6a5d..c7fa876 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -78,7 +78,7 @@
 	struct mmc_host *host = cls_dev_to_mmc_host(dev);
 	int ret = 0;
 
-	if (!mmc_use_core_runtime_pm(host))
+	if (!mmc_use_core_pm(host))
 		return 0;
 
 	if (!pm_runtime_suspended(dev)) {
@@ -95,7 +95,7 @@
 	struct mmc_host *host = cls_dev_to_mmc_host(dev);
 	int ret = 0;
 
-	if (!mmc_use_core_runtime_pm(host))
+	if (!mmc_use_core_pm(host))
 		return 0;
 
 	if (!pm_runtime_suspended(dev)) {
@@ -686,14 +686,13 @@
 	WARN_ON((host->caps & MMC_CAP_SDIO_IRQ) &&
 		!host->ops->enable_sdio_irq);
 
-	if (mmc_use_core_runtime_pm(host)) {
-		err = pm_runtime_set_active(&host->class_dev);
-		if (err)
-			pr_err("%s: %s: failed setting runtime active: err: %d\n",
-			       mmc_hostname(host), __func__, err);
-		else
-			pm_runtime_enable(&host->class_dev);
-	}
+	err = pm_runtime_set_active(&host->class_dev);
+	if (err)
+		pr_err("%s: %s: failed setting runtime active: err: %d\n",
+		       mmc_hostname(host), __func__, err);
+	else if (mmc_use_core_runtime_pm(host))
+		pm_runtime_enable(&host->class_dev);
+
 	err = device_add(&host->class_dev);
 	if (err)
 		return err;
diff --git a/drivers/mmc/host/msm_sdcc.c b/drivers/mmc/host/msm_sdcc.c
index 89e3472..95f0a04 100644
--- a/drivers/mmc/host/msm_sdcc.c
+++ b/drivers/mmc/host/msm_sdcc.c
@@ -516,8 +516,6 @@
 
 	if (mrq->data)
 		mrq->data->bytes_xfered = host->curr.data_xfered;
-	if (mrq->cmd->error == -ETIMEDOUT)
-		mdelay(5);
 
 	msmsdcc_reset_dpsm(host);
 
@@ -6475,7 +6473,7 @@
 	host->debugfs_host_dir = NULL;
 }
 #else
-static void msmsdcc_remove_debugfs(msmsdcc_host *host) {}
+static void msmsdcc_remove_debugfs(struct msmsdcc_host *host) {}
 #endif
 
 static int msmsdcc_remove(struct platform_device *pdev)
@@ -6682,7 +6680,7 @@
 }
 #endif
 
-#if CONFIG_DEBUG_FS
+#ifdef CONFIG_DEBUG_FS
 static void msmsdcc_print_pm_stats(struct msmsdcc_host *host, ktime_t start,
 				   const char *func, int err)
 {
diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c
index 2c8598b..e391a06 100644
--- a/drivers/mmc/host/sdhci-msm.c
+++ b/drivers/mmc/host/sdhci-msm.c
@@ -317,6 +317,7 @@
 	bool tuning_done;
 	bool calibration_done;
 	u8 saved_tuning_phase;
+	atomic_t controller_clock;
 };
 
 enum vdd_io_level {
@@ -2213,6 +2214,50 @@
 	return sel_clk;
 }
 
+static int sdhci_msm_enable_controller_clock(struct sdhci_host *host)
+{
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_msm_host *msm_host = pltfm_host->priv;
+	int rc = 0;
+
+	if (atomic_read(&msm_host->controller_clock))
+		return 0;
+
+	sdhci_msm_bus_voting(host, 1);
+
+	if (!IS_ERR(msm_host->pclk)) {
+		rc = clk_prepare_enable(msm_host->pclk);
+		if (rc) {
+			pr_err("%s: %s: failed to enable the pclk with error %d\n",
+			       mmc_hostname(host->mmc), __func__, rc);
+			goto remove_vote;
+		}
+	}
+
+	rc = clk_prepare_enable(msm_host->clk);
+	if (rc) {
+		pr_err("%s: %s: failed to enable the host-clk with error %d\n",
+		       mmc_hostname(host->mmc), __func__, rc);
+		goto disable_pclk;
+	}
+
+	atomic_set(&msm_host->controller_clock, 1);
+	pr_debug("%s: %s: enabled controller clock\n",
+			mmc_hostname(host->mmc), __func__);
+	goto out;
+
+disable_pclk:
+	if (!IS_ERR(msm_host->pclk))
+		clk_disable_unprepare(msm_host->pclk);
+remove_vote:
+	if (msm_host->msm_bus_vote.client_handle)
+		sdhci_msm_bus_cancel_work_and_set_vote(host, 0);
+out:
+	return rc;
+}
+
+
+
 static int sdhci_msm_prepare_clocks(struct sdhci_host *host, bool enable)
 {
 	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
@@ -2223,36 +2268,32 @@
 		pr_debug("%s: request to enable clocks\n",
 				mmc_hostname(host->mmc));
 
-		sdhci_msm_bus_voting(host, 1);
+		/*
+		 * The bus-width or the clock rate might have changed
+		 * after controller clocks are enbaled, update bus vote
+		 * in such case.
+		 */
+		if (atomic_read(&msm_host->controller_clock))
+			sdhci_msm_bus_voting(host, 1);
+
+		rc = sdhci_msm_enable_controller_clock(host);
+		if (rc)
+			goto remove_vote;
 
 		if (!IS_ERR_OR_NULL(msm_host->bus_clk)) {
 			rc = clk_prepare_enable(msm_host->bus_clk);
 			if (rc) {
 				pr_err("%s: %s: failed to enable the bus-clock with error %d\n",
 					mmc_hostname(host->mmc), __func__, rc);
-				goto remove_vote;
+				goto disable_controller_clk;
 			}
 		}
-		if (!IS_ERR(msm_host->pclk)) {
-			rc = clk_prepare_enable(msm_host->pclk);
-			if (rc) {
-				pr_err("%s: %s: failed to enable the pclk with error %d\n",
-					mmc_hostname(host->mmc), __func__, rc);
-				goto disable_bus_clk;
-			}
-		}
-		rc = clk_prepare_enable(msm_host->clk);
-		if (rc) {
-			pr_err("%s: %s: failed to enable the host-clk with error %d\n",
-				mmc_hostname(host->mmc), __func__, rc);
-			goto disable_pclk;
-		}
 		if (!IS_ERR(msm_host->ff_clk)) {
 			rc = clk_prepare_enable(msm_host->ff_clk);
 			if (rc) {
 				pr_err("%s: %s: failed to enable the ff_clk with error %d\n",
 					mmc_hostname(host->mmc), __func__, rc);
-				goto disable_clk;
+				goto disable_bus_clk;
 			}
 		}
 		if (!IS_ERR(msm_host->sleep_clk)) {
@@ -2280,6 +2321,7 @@
 		if (!IS_ERR_OR_NULL(msm_host->bus_clk))
 			clk_disable_unprepare(msm_host->bus_clk);
 
+		atomic_set(&msm_host->controller_clock, 0);
 		sdhci_msm_bus_voting(host, 0);
 	}
 	atomic_set(&msm_host->clks_on, enable);
@@ -2287,15 +2329,15 @@
 disable_ff_clk:
 	if (!IS_ERR_OR_NULL(msm_host->ff_clk))
 		clk_disable_unprepare(msm_host->ff_clk);
-disable_clk:
-	if (!IS_ERR_OR_NULL(msm_host->clk))
-		clk_disable_unprepare(msm_host->clk);
-disable_pclk:
-	if (!IS_ERR_OR_NULL(msm_host->pclk))
-		clk_disable_unprepare(msm_host->pclk);
 disable_bus_clk:
 	if (!IS_ERR_OR_NULL(msm_host->bus_clk))
 		clk_disable_unprepare(msm_host->bus_clk);
+disable_controller_clk:
+	if (!IS_ERR_OR_NULL(msm_host->clk))
+		clk_disable_unprepare(msm_host->clk);
+	if (!IS_ERR_OR_NULL(msm_host->pclk))
+		clk_disable_unprepare(msm_host->pclk);
+	atomic_set(&msm_host->controller_clock, 0);
 remove_vote:
 	if (msm_host->msm_bus_vote.client_handle)
 		sdhci_msm_bus_cancel_work_and_set_vote(host, 0);
@@ -2310,6 +2352,7 @@
 	struct sdhci_msm_host *msm_host = pltfm_host->priv;
 	struct mmc_ios	curr_ios = host->mmc->ios;
 	u32 sup_clock, ddr_clock;
+	bool curr_pwrsave;
 
 	if (!clock) {
 		sdhci_msm_prepare_clocks(host, false);
@@ -2321,6 +2364,22 @@
 	if (rc)
 		return;
 
+	curr_pwrsave = !!(readl_relaxed(host->ioaddr + CORE_VENDOR_SPEC) &
+			  CORE_CLK_PWRSAVE);
+	if ((clock > 400000) &&
+	    !curr_pwrsave && mmc_host_may_gate_card(host->mmc->card))
+		writel_relaxed(readl_relaxed(host->ioaddr + CORE_VENDOR_SPEC)
+				| CORE_CLK_PWRSAVE,
+				host->ioaddr + CORE_VENDOR_SPEC);
+	/*
+	 * Disable pwrsave for a newly added card if doesn't allow clock
+	 * gating.
+	 */
+	else if (curr_pwrsave && !mmc_host_may_gate_card(host->mmc->card))
+		writel_relaxed(readl_relaxed(host->ioaddr + CORE_VENDOR_SPEC)
+				& ~CORE_CLK_PWRSAVE,
+				host->ioaddr + CORE_VENDOR_SPEC);
+
 	sup_clock = sdhci_msm_get_sup_clk_rate(host, clock);
 	if ((curr_ios.timing == MMC_TIMING_UHS_DDR50) ||
 		(curr_ios.timing == MMC_TIMING_MMC_HS400)) {
@@ -2541,6 +2600,7 @@
 	.get_min_clock = sdhci_msm_get_min_clock,
 	.get_max_clock = sdhci_msm_get_max_clock,
 	.disable_data_xfer = sdhci_msm_disable_data_xfer,
+	.enable_controller_clock = sdhci_msm_enable_controller_clock,
 };
 
 static int __devinit sdhci_msm_probe(struct platform_device *pdev)
@@ -2620,6 +2680,7 @@
 		if (ret)
 			goto bus_clk_disable;
 	}
+	atomic_set(&msm_host->controller_clock, 1);
 
 	/* Setup SDC MMC clock */
 	msm_host->clk = devm_clk_get(&pdev->dev, "core_clk");
@@ -2823,6 +2884,7 @@
 	msm_host->mmc->caps2 |= MMC_CAP2_CLK_SCALE;
 	msm_host->mmc->caps2 |= MMC_CAP2_STOP_REQUEST;
 	msm_host->mmc->caps2 |= MMC_CAP2_ASYNC_SDIO_IRQ_4BIT_MODE;
+	msm_host->mmc->caps2 |= MMC_CAP2_CORE_PM;
 	msm_host->mmc->pm_caps |= MMC_PM_KEEP_POWER;
 
 	if (msm_host->pdata->nonremovable)
@@ -2879,7 +2941,7 @@
 	if (ret)
 		pr_err("%s: %s: pm_runtime_set_active failed: err: %d\n",
 		       mmc_hostname(host->mmc), __func__, ret);
-	else
+	else if (mmc_use_core_runtime_pm(host->mmc))
 		pm_runtime_enable(&pdev->dev);
 
 	/* Successful initialization */
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 0cb0491..830223d 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -27,6 +27,7 @@
 
 #include <linux/mmc/mmc.h>
 #include <linux/mmc/host.h>
+#include <linux/mmc/card.h>
 
 #include "sdhci.h"
 
@@ -110,7 +111,7 @@
 		sdhci_readl(host, SDHCI_INT_ENABLE),
 		sdhci_readl(host, SDHCI_SIGNAL_ENABLE));
 	pr_info(DRIVER_NAME ": AC12 err: 0x%08x | Slot int: 0x%08x\n",
-		sdhci_readw(host, SDHCI_AUTO_CMD_ERR),
+		host->auto_cmd_err_sts,
 		sdhci_readw(host, SDHCI_SLOT_INT_STATUS));
 	pr_info(DRIVER_NAME ": Caps:     0x%08x | Caps_1:   0x%08x\n",
 		sdhci_readl(host, SDHCI_CAPABILITIES),
@@ -745,6 +746,12 @@
 	if (host->quirks & SDHCI_QUIRK_BROKEN_TIMEOUT_VAL)
 		return 0xE;
 
+	/* During initialization, don't use max timeout as the clock is slow */
+	if ((host->quirks2 & SDHCI_QUIRK2_USE_RESERVED_MAX_TIMEOUT) &&
+		(host->clock > 400000)) {
+		return 0xF;
+	}
+
 	/* Unspecified timeout, assume max */
 	if (!data && !cmd->cmd_timeout_ms)
 		return 0xE;
@@ -1570,6 +1577,7 @@
 	unsigned long flags;
 	int vdd_bit = -1;
 	u8 ctrl;
+	int ret;
 
 	mutex_lock(&host->ios_mutex);
 	if (host->flags & SDHCI_DEVICE_DEAD) {
@@ -1582,6 +1590,29 @@
 	if (ios->clock)
 		sdhci_set_clock(host, ios->clock);
 
+	/*
+	 * The controller clocks may be off during power-up and we may end up
+	 * enabling card clock before giving power to the card. Hence, during
+	 * MMC_POWER_UP enable the controller clock and turn-on the regulators.
+	 * The mmc_power_up would provide the necessary delay before turning on
+	 * the clocks to the card.
+	 */
+	if (ios->power_mode & MMC_POWER_UP) {
+		if (host->ops->enable_controller_clock) {
+			ret = host->ops->enable_controller_clock(host);
+			if (ret) {
+				pr_err("%s: enabling controller clock: failed: %d\n",
+				       mmc_hostname(host->mmc), ret);
+			} else {
+				vdd_bit = sdhci_set_power(host, ios->vdd);
+
+				if (host->vmmc && vdd_bit != -1)
+					mmc_regulator_set_ocr(host->mmc,
+							      host->vmmc,
+							      vdd_bit);
+			}
+		}
+	}
 	spin_lock_irqsave(&host->lock, flags);
 	if (!host->clock) {
 		spin_unlock_irqrestore(&host->lock, flags);
@@ -1590,14 +1621,16 @@
 	}
 	spin_unlock_irqrestore(&host->lock, flags);
 
-	if (ios->power_mode & (MMC_POWER_UP | MMC_POWER_ON))
+	if (!host->ops->enable_controller_clock && (ios->power_mode &
+						    (MMC_POWER_UP |
+						     MMC_POWER_ON))) {
 		vdd_bit = sdhci_set_power(host, ios->vdd);
 
-	if (host->vmmc && vdd_bit != -1)
-		mmc_regulator_set_ocr(host->mmc, host->vmmc, vdd_bit);
+		if (host->vmmc && vdd_bit != -1)
+			mmc_regulator_set_ocr(host->mmc, host->vmmc, vdd_bit);
+	}
 
 	spin_lock_irqsave(&host->lock, flags);
-
 	if (host->ops->platform_send_init_74_clocks)
 		host->ops->platform_send_init_74_clocks(host, ios->power_mode);
 
@@ -2223,10 +2256,13 @@
 	struct sdhci_host *host = mmc_priv(mmc);
 	unsigned long flags;
 	struct mmc_data *data;
+	int ret = 0;
 
 	spin_lock_irqsave(&host->lock, flags);
-	if (!host->mrq || !host->data)
+	if (!host->mrq || !host->data) {
+		ret = MMC_BLK_NO_REQ_TO_STOP;
 		goto out;
+	}
 
 	data = host->data;
 
@@ -2252,7 +2288,7 @@
 	host->data = NULL;
 out:
 	spin_unlock_irqrestore(&host->lock, flags);
-	return 0;
+	return ret;
 }
 
 static unsigned int sdhci_get_xfer_remain(struct mmc_host *mmc)
@@ -2375,6 +2411,7 @@
 	host->mrq = NULL;
 	host->cmd = NULL;
 	host->data = NULL;
+	host->auto_cmd_err_sts = 0;
 
 #ifndef SDHCI_USE_LEDS_CLASS
 	sdhci_deactivate_led(host);
@@ -2465,7 +2502,9 @@
 		host->cmd->error = -EILSEQ;
 
 	if (intmask & SDHCI_INT_AUTO_CMD_ERR) {
-		auto_cmd_status = sdhci_readw(host, SDHCI_AUTO_CMD_ERR);
+		auto_cmd_status = host->auto_cmd_err_sts;
+		pr_err("%s: %s: AUTO CMD err sts 0x%08x\n",
+			mmc_hostname(host->mmc), __func__, auto_cmd_status);
 		if (auto_cmd_status & (SDHCI_AUTO_CMD12_NOT_EXEC |
 				       SDHCI_AUTO_CMD_INDEX_ERR |
 				       SDHCI_AUTO_CMD_ENDBIT_ERR))
@@ -2728,6 +2767,9 @@
 	}
 
 	if (intmask & SDHCI_INT_CMD_MASK) {
+		if (intmask & SDHCI_INT_AUTO_CMD_ERR)
+			host->auto_cmd_err_sts = sdhci_readw(host,
+					SDHCI_AUTO_CMD_ERR);
 		sdhci_writel(host, intmask & SDHCI_INT_CMD_MASK,
 			SDHCI_INT_STATUS);
 		if ((host->quirks2 & SDHCI_QUIRK2_SLOW_INT_CLR) &&
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 3db99c4..db4806d 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -295,6 +295,7 @@
 	unsigned int	(*get_max_segments)(void);
 	void	(*platform_bus_voting)(struct sdhci_host *host, u32 enable);
 	void    (*disable_data_xfer)(struct sdhci_host *host);
+	int	(*enable_controller_clock)(struct sdhci_host *host);
 };
 
 #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
diff --git a/drivers/net/wireless/ath/regd.c b/drivers/net/wireless/ath/regd.c
index 10dea37..bd4ecf3 100644
--- a/drivers/net/wireless/ath/regd.c
+++ b/drivers/net/wireless/ath/regd.c
@@ -520,6 +520,7 @@
 		 */
 		regd = ath_world_regdomain(reg);
 		wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY;
+		wiphy->country_ie_pref = NL80211_COUNTRY_IE_FOLLOW_POWER;
 	} else {
 		/*
 		 * This gets applied in the case of the absence of CRDA,
diff --git a/drivers/net/wireless/wcnss/wcnss_wlan.c b/drivers/net/wireless/wcnss/wcnss_wlan.c
index 0036971..0eab568 100644
--- a/drivers/net/wireless/wcnss/wcnss_wlan.c
+++ b/drivers/net/wireless/wcnss/wcnss_wlan.c
@@ -100,6 +100,14 @@
 
 #define PRONTO_PMU_COM_CPU_CBCR_OFFSET     0x0030
 #define PRONTO_PMU_COM_AHB_CBCR_OFFSET     0x0034
+
+#define PRONTO_PMU_WLAN_AHB_CBCR_OFFSET    0x0074
+#define PRONTO_PMU_WLAN_AHB_CBCR_CLK_EN    BIT(0)
+#define PRONTO_PMU_WLAN_AHB_CBCR_CLK_OFF   BIT(31)
+
+#define PRONTO_PMU_CPU_AHB_CMD_RCGR_OFFSET  0x0120
+#define PRONTO_PMU_CPU_AHB_CMD_RCGR_ROOT_EN BIT(1)
+
 #define PRONTO_PMU_CFG_OFFSET              0x1004
 #define PRONTO_PMU_COM_CSR_OFFSET          0x1040
 #define PRONTO_PMU_SOFT_RESET_OFFSET       0x104C
@@ -134,6 +142,7 @@
 #define MSM_PRONTO_PLL_BASE				0xfb21b1c0
 #define PRONTO_PLL_STATUS_OFFSET		0x1c
 
+#define MSM_PRONTO_TXP_STATUS           0xfb08040c
 #define MSM_PRONTO_TXP_PHY_ABORT        0xfb080488
 #define MSM_PRONTO_BRDG_ERR_SRC         0xfb080fb0
 
@@ -146,6 +155,7 @@
 #define WCNSS_CTRL_CHANNEL			"WCNSS_CTRL"
 #define WCNSS_MAX_FRAME_SIZE		(4*1024)
 #define WCNSS_VERSION_LEN			30
+#define WCNSS_MAX_BUILD_VER_LEN		256
 
 /* message types */
 #define WCNSS_CTRL_MSG_START	0x01000000
@@ -158,6 +168,8 @@
 #define	WCNSS_CALDATA_DNLD_REQ        (WCNSS_CTRL_MSG_START + 6)
 #define	WCNSS_CALDATA_DNLD_RSP        (WCNSS_CTRL_MSG_START + 7)
 #define	WCNSS_VBATT_LEVEL_IND         (WCNSS_CTRL_MSG_START + 8)
+#define	WCNSS_BUILD_VER_REQ           (WCNSS_CTRL_MSG_START + 9)
+#define	WCNSS_BUILD_VER_RSP           (WCNSS_CTRL_MSG_START + 10)
 
 
 #define VALID_VERSION(version) \
@@ -331,6 +343,7 @@
 	void __iomem *pronto_ccpu_base;
 	void __iomem *pronto_saw2_base;
 	void __iomem *pronto_pll_base;
+	void __iomem *wlan_tx_status;
 	void __iomem *wlan_tx_phy_aborts;
 	void __iomem *wlan_brdg_err_source;
 	void __iomem *fiq_reg;
@@ -475,7 +488,7 @@
 void wcnss_pronto_log_debug_regs(void)
 {
 	void __iomem *reg_addr, *tst_addr, *tst_ctrl_addr;
-	u32 reg = 0, reg2 = 0;
+	u32 reg = 0, reg2 = 0, reg3 = 0, reg4 = 0;
 
 
 	reg_addr = penv->msm_wcnss_base + PRONTO_PMU_SPARE_OFFSET;
@@ -506,6 +519,10 @@
 	pr_info_ratelimited("%s:  PRONTO_PMU_SOFT_RESET %08x\n",
 						__func__, reg);
 
+	reg_addr = penv->pronto_saw2_base + PRONTO_SAW2_SPM_STS_OFFSET;
+	reg = readl_relaxed(reg_addr);
+	pr_info_ratelimited("%s: PRONTO_SAW2_SPM_STS %08x\n", __func__, reg);
+
 	reg_addr = penv->msm_wcnss_base + PRONTO_PMU_COM_GDSCR_OFFSET;
 	reg = readl_relaxed(reg_addr);
 	pr_info_ratelimited("%s:  PRONTO_PMU_COM_GDSCR %08x\n",
@@ -554,10 +571,6 @@
 	reg = readl_relaxed(reg_addr);
 	pr_info_ratelimited("%s: CCU_CCPU_LAST_ADDR2 %08x\n", __func__, reg);
 
-	reg_addr = penv->pronto_saw2_base + PRONTO_SAW2_SPM_STS_OFFSET;
-	reg = readl_relaxed(reg_addr);
-	pr_info_ratelimited("%s: PRONTO_SAW2_SPM_STS %08x\n", __func__, reg);
-
 	reg_addr = penv->pronto_pll_base + PRONTO_PLL_STATUS_OFFSET;
 	reg = readl_relaxed(reg_addr);
 	pr_info_ratelimited("%s: PRONTO_PLL_STATUS %08x\n", __func__, reg);
@@ -631,8 +644,19 @@
 	reg_addr = penv->msm_wcnss_base + PRONTO_PMU_WLAN_GDSCR_OFFSET;
 	reg2 = readl_relaxed(reg_addr);
 
+	reg_addr = penv->msm_wcnss_base + PRONTO_PMU_WLAN_AHB_CBCR_OFFSET;
+	reg3 = readl_relaxed(reg_addr);
+	pr_info_ratelimited("%s:  PMU_WLAN_AHB_CBCR %08x\n", __func__, reg3);
+
+	reg_addr = penv->msm_wcnss_base + PRONTO_PMU_CPU_AHB_CMD_RCGR_OFFSET;
+	reg4 = readl_relaxed(reg_addr);
+	pr_info_ratelimited("%s:  PMU_CPU_CMD_RCGR %08x\n", __func__, reg4);
+
 	if ((reg & PRONTO_PMU_WLAN_BCR_BLK_ARES) ||
-			(reg2 & PRONTO_PMU_WLAN_GDSCR_SW_COLLAPSE)) {
+		(reg2 & PRONTO_PMU_WLAN_GDSCR_SW_COLLAPSE) ||
+		(!(reg4 & PRONTO_PMU_CPU_AHB_CMD_RCGR_ROOT_EN)) ||
+		(reg3 & PRONTO_PMU_WLAN_AHB_CBCR_CLK_OFF) ||
+		(!(reg3 & PRONTO_PMU_WLAN_AHB_CBCR_CLK_EN))) {
 		pr_info_ratelimited("%s:  Cannot log, wlan domain is power collapsed\n",
 				__func__);
 		return;
@@ -644,6 +668,8 @@
 	reg = readl_relaxed(penv->wlan_brdg_err_source);
 	pr_info_ratelimited("%s: WLAN_BRDG_ERR_SOURCE %08x\n", __func__, reg);
 
+	reg = readl_relaxed(penv->wlan_tx_status);
+	pr_info_ratelimited("%s: WLAN_TX_STATUS %08x\n", __func__, reg);
 }
 EXPORT_SYMBOL(wcnss_pronto_log_debug_regs);
 
@@ -1400,7 +1426,9 @@
 	int len = 0;
 	int rc = 0;
 	unsigned char buf[sizeof(struct wcnss_version)];
+	unsigned char build[WCNSS_MAX_BUILD_VER_LEN+1];
 	struct smd_msg_hdr *phdr;
+	struct smd_msg_hdr smd_msg;
 	struct wcnss_version *pversion;
 	int hw_type;
 	unsigned char fw_status = 0;
@@ -1457,6 +1485,12 @@
 			break;
 
 		case WCNSS_PRONTO_HW:
+			smd_msg.msg_type = WCNSS_BUILD_VER_REQ;
+			smd_msg.msg_len = sizeof(smd_msg);
+			rc = wcnss_smd_tx(&smd_msg, smd_msg.msg_len);
+			if (rc < 0)
+				pr_err("wcnss: smd tx failed: %s\n", __func__);
+
 			/* supported only if pronto major >= 1 and minor >= 4 */
 			if ((pversion->major >= 1) && (pversion->minor >= 4)) {
 				pr_info("wcnss: schedule dnld work for pronto\n");
@@ -1471,6 +1505,21 @@
 		}
 		break;
 
+	case WCNSS_BUILD_VER_RSP:
+		if (len > WCNSS_MAX_BUILD_VER_LEN) {
+			pr_err("wcnss: invalid build version data from wcnss %d\n",
+					len);
+			return;
+		}
+		rc = smd_read(penv->smd_ch, build, len);
+		if (rc < len) {
+			pr_err("wcnss: incomplete data read from smd\n");
+			return;
+		}
+		build[len] = 0;
+		pr_info("wcnss: build version %s\n", build);
+		break;
+
 	case WCNSS_NVBIN_DNLD_RSP:
 		penv->nv_downloaded = true;
 		fw_status = wcnss_fw_status();
@@ -1944,7 +1993,12 @@
 			pr_err("%s: ioremap wlan BRDG ERR failed\n", __func__);
 			goto fail_ioremap8;
 		}
-
+		penv->wlan_tx_status = ioremap(MSM_PRONTO_TXP_STATUS, SZ_8);
+		if (!penv->wlan_tx_status) {
+			ret = -ENOMEM;
+			pr_err("%s: ioremap wlan TX STATUS failed\n", __func__);
+			goto fail_ioremap9;
+		}
 	}
 	penv->adc_tm_dev = qpnp_get_adc_tm(&penv->pdev->dev, "wcnss");
 	if (IS_ERR(penv->adc_tm_dev)) {
@@ -1970,6 +2024,9 @@
 fail_pil:
 	if (penv->riva_ccu_base)
 		iounmap(penv->riva_ccu_base);
+	if (penv->wlan_tx_status)
+		iounmap(penv->wlan_tx_status);
+fail_ioremap9:
 	if (penv->wlan_brdg_err_source)
 		iounmap(penv->wlan_brdg_err_source);
 fail_ioremap8:
diff --git a/drivers/nfc/nfc-nci.c b/drivers/nfc/nfc-nci.c
index 67b057c..043f9bc 100644
--- a/drivers/nfc/nfc-nci.c
+++ b/drivers/nfc/nfc-nci.c
@@ -923,6 +923,19 @@
 		goto err_misc_register;
 	}
 
+	regulators.regulator = regulator_get(&client->dev, regulators.name);
+	if (IS_ERR(regulators.regulator)) {
+		r = PTR_ERR(regulators.regulator);
+		pr_err("regulator get of %s failed (%d)\n", regulators.name, r);
+	} else {
+		/* Enable the regulator */
+		r = regulator_enable(regulators.regulator);
+		if (r) {
+			pr_err("vreg %s enable failed (%d)\n",
+				regulators.name, r);
+		}
+	}
+
 	logging_level = 0;
 	/* request irq.  The irq is set whenever the chip has data available
 	* for reading.  It is cleared when all data has been read.
diff --git a/drivers/nfc/nfc-nci.h b/drivers/nfc/nfc-nci.h
index 81f2521..9bfb77d 100644
--- a/drivers/nfc/nfc-nci.h
+++ b/drivers/nfc/nfc-nci.h
@@ -223,3 +223,9 @@
 	unsigned int	reg;
 };
 #endif
+/* enable LDO */
+struct vregs_info {
+	const char * const name;
+	struct regulator *regulator;
+};
+struct vregs_info regulators = {"vlogic", NULL};
diff --git a/drivers/of/of_batterydata.c b/drivers/of/of_batterydata.c
index 2061408..b0d40f1 100644
--- a/drivers/of/of_batterydata.c
+++ b/drivers/of/of_batterydata.c
@@ -244,9 +244,17 @@
 {
 	int64_t resistor_value_kohm, denom;
 
+	if (batt_id_uv == 0) {
+		/* vadc not correct or batt id line grounded, report 0 kohms */
+		return 0;
+	}
 	/* calculate the battery id resistance reported via ADC */
 	denom = div64_s64(vadc_vdd * 1000000LL, batt_id_uv) - 1000000LL;
 
+	if (denom == 0) {
+		/* batt id connector might be open, return 0 kohms */
+		return 0;
+	}
 	resistor_value_kohm = div64_s64(rpull_up * 1000000LL + denom/2, denom);
 
 	pr_debug("batt id voltage = %d, resistor value = %lld\n",
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 5f0ba94..9ccb993 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -327,10 +327,9 @@
 	for(; lookup->compatible != NULL; lookup++) {
 		if (!of_device_is_compatible(np, lookup->compatible))
 			continue;
-		if (of_address_to_resource(np, 0, &res))
-			continue;
-		if (res.start != lookup->phys_addr)
-			continue;
+		if (!of_address_to_resource(np, 0, &res))
+			if (res.start != lookup->phys_addr)
+				continue;
 		pr_debug("%s: devname=%s\n", np->full_name, lookup->name);
 		return lookup;
 	}
diff --git a/drivers/platform/msm/ipa/ipa.c b/drivers/platform/msm/ipa/ipa.c
index 6a16cf3..1ef1f1b 100644
--- a/drivers/platform/msm/ipa/ipa.c
+++ b/drivers/platform/msm/ipa/ipa.c
@@ -963,7 +963,7 @@
 	enum ipa_pipe_mem_type mem_type;
 
 	if (!pipe_connection || !node)
-		goto err;
+		return -EINVAL;
 
 	key = "qcom,src-bam-physical-address";
 	rc = of_property_read_u32(node, key, &val);
diff --git a/drivers/platform/msm/ipa/ipa_flt.c b/drivers/platform/msm/ipa/ipa_flt.c
index 2d75141..c3db716 100644
--- a/drivers/platform/msm/ipa/ipa_flt.c
+++ b/drivers/platform/msm/ipa/ipa_flt.c
@@ -802,8 +802,11 @@
 	IPADBG("reset flt ip=%d\n", ip);
 	list_for_each_entry_safe(entry, next, &tbl->head_flt_rule_list, link) {
 		node = ipa_search(&ipa_ctx->flt_rule_hdl_tree, (u32)entry);
-		if (node == NULL)
+		if (node == NULL) {
 			WARN_ON(1);
+			mutex_unlock(&ipa_ctx->lock);
+			return -EFAULT;
+		}
 
 		if ((ip == IPA_IP_v4 &&
 		     entry->rule.attrib.attrib_mask == IPA_FLT_PROTOCOL &&
@@ -833,8 +836,11 @@
 				link) {
 			node = ipa_search(&ipa_ctx->flt_rule_hdl_tree,
 					(u32)entry);
-			if (node == NULL)
+			if (node == NULL) {
 				WARN_ON(1);
+				mutex_unlock(&ipa_ctx->lock);
+				return -EFAULT;
+			}
 			list_del(&entry->link);
 			entry->tbl->rule_cnt--;
 			if (entry->rt_tbl)
diff --git a/drivers/platform/msm/ipa/ipa_hdr.c b/drivers/platform/msm/ipa/ipa_hdr.c
index 9618da2..54cbf5f 100644
--- a/drivers/platform/msm/ipa/ipa_hdr.c
+++ b/drivers/platform/msm/ipa/ipa_hdr.c
@@ -450,8 +450,11 @@
 			continue;
 
 		node = ipa_search(&ipa_ctx->hdr_hdl_tree, (u32) entry);
-		if (node == NULL)
+		if (node == NULL) {
 			WARN_ON(1);
+			mutex_unlock(&ipa_ctx->lock);
+			return -EFAULT;
+		}
 		list_del(&entry->link);
 		entry->cookie = 0;
 		kmem_cache_free(ipa_ctx->hdr_cache, entry);
diff --git a/drivers/platform/msm/ipa/ipa_rt.c b/drivers/platform/msm/ipa/ipa_rt.c
index 8d6d5e6..f453010 100644
--- a/drivers/platform/msm/ipa/ipa_rt.c
+++ b/drivers/platform/msm/ipa/ipa_rt.c
@@ -843,8 +843,11 @@
 					 &tbl->head_rt_rule_list, link) {
 			node = ipa_search(&ipa_ctx->rt_rule_hdl_tree,
 					  (u32)rule);
-			if (node == NULL)
+			if (node == NULL) {
 				WARN_ON(1);
+				mutex_unlock(&ipa_ctx->lock);
+				return -EFAULT;
+			}
 
 			/*
 			 * for the "default" routing tbl, remove all but the
@@ -866,8 +869,11 @@
 		}
 
 		node = ipa_search(&ipa_ctx->rt_tbl_hdl_tree, (u32)tbl);
-		if (node  == NULL)
+		if (node  == NULL) {
 			WARN_ON(1);
+			mutex_unlock(&ipa_ctx->lock);
+			return -EFAULT;
+		}
 
 		/* do not remove the "default" routing tbl which has index 0 */
 		if (tbl->idx != 0) {
diff --git a/drivers/power/max17042_battery.c b/drivers/power/max17042_battery.c
index 04620c2..915767d 100644
--- a/drivers/power/max17042_battery.c
+++ b/drivers/power/max17042_battery.c
@@ -105,6 +105,7 @@
 	POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
 	POWER_SUPPLY_PROP_VOLTAGE_NOW,
 	POWER_SUPPLY_PROP_VOLTAGE_AVG,
+	POWER_SUPPLY_PROP_VOLTAGE_OCV,
 	POWER_SUPPLY_PROP_CAPACITY,
 	POWER_SUPPLY_PROP_CHARGE_FULL,
 	POWER_SUPPLY_PROP_TEMP,
@@ -171,6 +172,13 @@
 
 		val->intval = ret * 625 / 8;
 		break;
+	case POWER_SUPPLY_PROP_VOLTAGE_OCV:
+		ret = max17042_read_reg(chip->client, MAX17042_OCVInternal);
+		if (ret < 0)
+			return ret;
+
+		val->intval = ret * 625 / 8;
+		break;
 	case POWER_SUPPLY_PROP_CAPACITY:
 		ret = max17042_read_reg(chip->client, MAX17042_RepSOC);
 		if (ret < 0)
diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
index 319a24d..4688514 100644
--- a/drivers/power/power_supply_sysfs.c
+++ b/drivers/power/power_supply_sysfs.c
@@ -148,9 +148,11 @@
 	POWER_SUPPLY_ATTR(voltage_now),
 	POWER_SUPPLY_ATTR(voltage_avg),
 	POWER_SUPPLY_ATTR(input_voltage_regulation),
+	POWER_SUPPLY_ATTR(voltage_ocv),
 	POWER_SUPPLY_ATTR(current_max),
 	POWER_SUPPLY_ATTR(input_current_max),
 	POWER_SUPPLY_ATTR(input_current_trim),
+	POWER_SUPPLY_ATTR(input_current_settled),
 	POWER_SUPPLY_ATTR(current_now),
 	POWER_SUPPLY_ATTR(current_avg),
 	POWER_SUPPLY_ATTR(power_now),
diff --git a/drivers/power/qpnp-bms.c b/drivers/power/qpnp-bms.c
index ad39e88..3fe1ca8 100644
--- a/drivers/power/qpnp-bms.c
+++ b/drivers/power/qpnp-bms.c
@@ -203,12 +203,14 @@
 	int				low_voltage_threshold;
 	int				low_soc_calc_threshold;
 	int				low_soc_calculate_soc_ms;
+	int				low_voltage_calculate_soc_ms;
 	int				calculate_soc_ms;
 	struct bms_wakeup_source	soc_wake_source;
 	struct wake_lock		cv_wake_lock;
 
 	uint16_t			ocv_reading_at_100;
 	uint16_t			prev_last_good_ocv_raw;
+	int				insertion_ocv_uv;
 	int				last_ocv_uv;
 	int				charging_adjusted_ocv;
 	int				last_ocv_temp;
@@ -239,6 +241,7 @@
 	unsigned int			vadc_v0625;
 	unsigned int			vadc_v1250;
 
+	int				system_load_count;
 	int				prev_uuc_iavg_ma;
 	int				prev_pc_unusable;
 	int				ibat_at_cv_ua;
@@ -762,14 +765,26 @@
 	return get_battery_status(chip) == POWER_SUPPLY_STATUS_FULL;
 }
 
+#define BAT_PRES_BIT		BIT(7)
 static bool is_battery_present(struct qpnp_bms_chip *chip)
 {
 	union power_supply_propval ret = {0,};
+	int rc;
+	u8 batt_pres;
 
+	/* first try to use the batt_pres register if given */
+	if (chip->batt_pres_addr) {
+		rc = qpnp_read_wrapper(chip, &batt_pres,
+				chip->batt_pres_addr, 1);
+		if (!rc && (batt_pres & BAT_PRES_BIT))
+			return true;
+		else
+			return false;
+	}
 	if (chip->batt_psy == NULL)
 		chip->batt_psy = power_supply_get_by_name("battery");
 	if (chip->batt_psy) {
-		/* if battery has been registered, use the status property */
+		/* if battery has been registered, use the present property */
 		chip->batt_psy->get_property(chip->batt_psy,
 					POWER_SUPPLY_PROP_PRESENT, &ret);
 		return ret.intval;
@@ -780,6 +795,35 @@
 	return false;
 }
 
+static int get_battery_insertion_ocv_uv(struct qpnp_bms_chip *chip)
+{
+	union power_supply_propval ret = {0,};
+	int rc, vbat;
+
+	if (chip->batt_psy == NULL)
+		chip->batt_psy = power_supply_get_by_name("battery");
+	if (chip->batt_psy) {
+		/* if battery has been registered, use the ocv property */
+		rc = chip->batt_psy->get_property(chip->batt_psy,
+				POWER_SUPPLY_PROP_VOLTAGE_OCV, &ret);
+		if (rc) {
+			/*
+			 * Default to vbatt if the battery OCV is not
+			 * registered.
+			 */
+			pr_debug("Battery psy does not have voltage ocv\n");
+			rc = get_battery_voltage(chip, &vbat);
+			if (rc)
+				return -EINVAL;
+			return vbat;
+		}
+		return ret.intval;
+	}
+
+	pr_debug("battery power supply is not registered\n");
+	return -EINVAL;
+}
+
 static bool is_batfet_closed(struct qpnp_bms_chip *chip)
 {
 	union power_supply_propval ret = {0,};
@@ -859,7 +903,7 @@
 
 static void reset_for_new_battery(struct qpnp_bms_chip *chip, int batt_temp)
 {
-	chip->last_ocv_uv = estimate_ocv(chip);
+	chip->last_ocv_uv = chip->insertion_ocv_uv;
 	mutex_lock(&chip->last_soc_mutex);
 	chip->last_soc = -EINVAL;
 	chip->last_soc_invalid = true;
@@ -890,14 +934,67 @@
 	}
 }
 
+#define SIGN(x) ((x) < 0 ? -1 : 1)
+#define UV_PER_SPIN 50000
+static int find_ocv_for_pc(struct qpnp_bms_chip *chip, int batt_temp, int pc)
+{
+	int new_pc;
+	int batt_temp_degc = batt_temp / 10;
+	int ocv_mv;
+	int delta_mv = 5;
+	int max_spin_count;
+	int count = 0;
+	int sign, new_sign;
+
+	ocv_mv = interpolate_ocv(chip->pc_temp_ocv_lut, batt_temp_degc, pc);
+
+	new_pc = interpolate_pc(chip->pc_temp_ocv_lut, batt_temp_degc, ocv_mv);
+	pr_debug("test revlookup pc = %d for ocv = %d\n", new_pc, ocv_mv);
+	max_spin_count = 1 + (chip->max_voltage_uv - chip->v_cutoff_uv)
+						/ UV_PER_SPIN;
+	sign = SIGN(pc - new_pc);
+
+	while (abs(new_pc - pc) != 0 && count < max_spin_count) {
+		/*
+		 * If the newly interpolated pc is larger than the lookup pc,
+		 * the ocv should be reduced and vice versa
+		 */
+		new_sign = SIGN(pc - new_pc);
+		/*
+		 * If the sign has changed, then we have passed the lookup pc.
+		 * reduce the ocv step size to get finer results.
+		 *
+		 * If we have already reduced the ocv step size and still
+		 * passed the lookup pc, just stop and use the current ocv.
+		 * This can only happen if the batterydata profile is
+		 * non-monotonic anyways.
+		 */
+		if (new_sign != sign) {
+			if (delta_mv > 1)
+				delta_mv = 1;
+			else
+				break;
+		}
+		sign = new_sign;
+
+		ocv_mv = ocv_mv + delta_mv * sign;
+		new_pc = interpolate_pc(chip->pc_temp_ocv_lut,
+				batt_temp_degc, ocv_mv);
+		pr_debug("test revlookup pc = %d for ocv = %d\n",
+			new_pc, ocv_mv);
+		count++;
+	}
+
+	return ocv_mv * 1000;
+}
+
 #define OCV_RAW_UNINITIALIZED	0xFFFF
 #define MIN_OCV_UV		2000000
 static int read_soc_params_raw(struct qpnp_bms_chip *chip,
 				struct raw_soc_params *raw,
 				int batt_temp)
 {
-	bool warm_reset = false;
-	int rc;
+	int warm_reset, rc;
 
 	mutex_lock(&chip->bms_output_lock);
 
@@ -945,8 +1042,8 @@
 		chip->done_charging = false;
 		/* if we just finished charging, reset CC and fake 100% */
 		chip->ocv_reading_at_100 = raw->last_good_ocv_raw;
-		chip->last_ocv_uv = chip->max_voltage_uv;
-		raw->last_good_ocv_uv = chip->max_voltage_uv;
+		chip->last_ocv_uv = find_ocv_for_pc(chip, batt_temp, 100);
+		raw->last_good_ocv_uv = chip->last_ocv_uv;
 		raw->cc = 0;
 		raw->shdw_cc = 0;
 		reset_cc(chip, CLEAR_CC | CLEAR_SHDW_CC);
@@ -1302,48 +1399,25 @@
 	return uuc_uah_iavg;
 }
 
-static void find_ocv_for_soc(struct qpnp_bms_chip *chip,
-				struct soc_params *params,
-				int batt_temp,
-				int shutdown_soc,
-				int *ret_ocv_uv)
+static s64 find_ocv_charge_for_soc(struct qpnp_bms_chip *chip,
+				struct soc_params *params, int soc)
 {
-	s64 ocv_charge_uah;
-	int pc, new_pc;
-	int batt_temp_degc = batt_temp / 10;
-	int ocv_uv;
+	return div_s64((s64)soc * (params->fcc_uah - params->uuc_uah),
+			100) + params->cc_uah + params->uuc_uah;
+}
 
-	ocv_charge_uah = (s64)shutdown_soc
-				* (params->fcc_uah - params->uuc_uah);
-	ocv_charge_uah = div_s64(ocv_charge_uah, 100)
-				+ params->cc_uah + params->uuc_uah;
+static int find_pc_for_soc(struct qpnp_bms_chip *chip,
+			struct soc_params *params, int soc)
+{
+	int ocv_charge_uah = find_ocv_charge_for_soc(chip, params, soc);
+	int pc;
+
 	pc = DIV_ROUND_CLOSEST((int)ocv_charge_uah * 100, params->fcc_uah);
 	pc = clamp(pc, 0, 100);
-
-	ocv_uv = interpolate_ocv(chip->pc_temp_ocv_lut, batt_temp_degc, pc);
-
-	pr_debug("s_soc = %d, fcc = %d uuc = %d rc = %d, pc = %d, ocv mv = %d\n",
-					shutdown_soc, params->fcc_uah,
-					params->uuc_uah, (int)ocv_charge_uah,
-					pc, ocv_uv);
-	new_pc = interpolate_pc(chip->pc_temp_ocv_lut, batt_temp_degc, ocv_uv);
-	pr_debug("test revlookup pc = %d for ocv = %d\n", new_pc, ocv_uv);
-
-	while (abs(new_pc - pc) > 1) {
-		int delta_mv = 5;
-
-		if (new_pc > pc)
-			delta_mv = -1 * delta_mv;
-
-		ocv_uv = ocv_uv + delta_mv;
-		new_pc = interpolate_pc(chip->pc_temp_ocv_lut,
-				batt_temp_degc, ocv_uv);
-		pr_debug("test revlookup pc = %d for ocv = %d\n",
-				new_pc, ocv_uv);
-	}
-
-	*ret_ocv_uv = ocv_uv * 1000;
-	params->ocv_charge_uah = (int)ocv_charge_uah;
+	pr_debug("soc = %d, fcc = %d uuc = %d rc = %d pc = %d\n",
+			soc, params->fcc_uah, params->uuc_uah,
+			ocv_charge_uah, pc);
+	return pc;
 }
 
 static int get_current_time(unsigned long *now_tm_sec)
@@ -1614,10 +1688,13 @@
 
 	rc = qpnp_write_wrapper(chip, &temp, chip->base + IAVG_STORAGE_REG, 1);
 
-	/* don't store soc if temperature is below 5degC */
+	/* store an invalid soc if temperature is below 5degC */
 	if (batt_temp > IGNORE_SOC_TEMP_DECIDEG)
 		qpnp_masked_write_base(chip, chip->soc_storage_addr,
 				SOC_STORAGE_MASK, (soc + 1) << 1);
+	else
+		qpnp_masked_write_base(chip, chip->soc_storage_addr,
+				SOC_STORAGE_MASK, SOC_STORAGE_MASK);
 }
 
 static int scale_soc_while_chg(struct qpnp_bms_chip *chip, int chg_time_sec,
@@ -1754,8 +1831,15 @@
 					chip->catch_up_time_sec,
 					soc, chip->last_soc);
 
-		soc_change = min((int)abs(chip->last_soc - soc),
-			time_since_last_change_sec / SOC_CHANGE_PER_SEC);
+		/* if the battery is close to cutoff allow more change */
+		if (wake_lock_active(&chip->low_voltage_wake_lock))
+			soc_change = min((int)abs(chip->last_soc - soc),
+				time_since_last_change_sec);
+		else
+			soc_change = min((int)abs(chip->last_soc - soc),
+				time_since_last_change_sec
+					/ SOC_CHANGE_PER_SEC);
+
 		if (chip->last_soc_unbound) {
 			chip->last_soc_unbound = false;
 		} else {
@@ -1798,14 +1882,14 @@
 		return report_cc_based_soc(chip);
 }
 
-#define VDD_MAX_ERR		5000
-#define VDD_STEP_SIZE		10000
+#define VDD_MAX_ERR			5000
+#define VDD_STEP_SIZE			10000
+#define MAX_COUNT_BEFORE_RESET_TO_CC	3
 static int charging_adjustments(struct qpnp_bms_chip *chip,
 				struct soc_params *params, int soc,
 				int vbat_uv, int ibat_ua, int batt_temp)
 {
 	int chg_soc, soc_ibat, batt_terminal_uv, weight_ibat, weight_cc;
-	int new_ocv_uv;
 
 	batt_terminal_uv = vbat_uv + (ibat_ua * chip->r_conn_mohm) / 1000;
 
@@ -1822,9 +1906,28 @@
 		}
 
 		chip->prev_batt_terminal_uv = batt_terminal_uv;
+		chip->system_load_count = 0;
+		return soc;
+	} else if (ibat_ua > 0 && batt_terminal_uv
+			< chip->max_voltage_uv - (VDD_MAX_ERR * 2)) {
+		if (chip->system_load_count > MAX_COUNT_BEFORE_RESET_TO_CC) {
+			chip->soc_at_cv = -EINVAL;
+			pr_debug("Vbat below CV threshold, resetting CC_TO_CV\n");
+			chip->system_load_count = 0;
+		} else {
+			chip->system_load_count += 1;
+			pr_debug("Vbat below CV threshold, count: %d\n",
+					chip->system_load_count);
+		}
+		return soc;
+	} else if (ibat_ua > 0) {
+		pr_debug("NOT CHARGING SOC %d\n", soc);
+		chip->system_load_count = 0;
+		chip->prev_chg_soc = soc;
 		return soc;
 	}
 
+	chip->system_load_count = 0;
 	/*
 	 * battery is in CV phase - begin linear interpolation of soc based on
 	 * battery charge current
@@ -1859,9 +1962,10 @@
 	if (chg_soc > chip->prev_chg_soc) {
 		chip->prev_chg_soc = chg_soc;
 
-		find_ocv_for_soc(chip, params, batt_temp, chg_soc, &new_ocv_uv);
-		chip->charging_adjusted_ocv = new_ocv_uv;
-		pr_debug("CC CHG ADJ OCV = %d CHG SOC %d\n", new_ocv_uv,
+		chip->charging_adjusted_ocv = find_ocv_for_pc(chip, batt_temp,
+				find_pc_for_soc(chip, params, chg_soc));
+		pr_debug("CC CHG ADJ OCV = %d CHG SOC %d\n",
+				chip->charging_adjusted_ocv,
 				chip->prev_chg_soc);
 	}
 
@@ -1911,7 +2015,7 @@
 	}
 }
 
-#define NO_ADJUST_HIGH_SOC_THRESHOLD	90
+#define NO_ADJUST_HIGH_SOC_THRESHOLD	98
 static int adjust_soc(struct qpnp_bms_chip *chip, struct soc_params *params,
 							int soc, int batt_temp)
 {
@@ -1951,10 +2055,12 @@
 		goto out;
 	}
 
-	if (ibat_ua < 0 && !is_battery_full(chip)) {
+	if (is_battery_charging(chip)) {
 		soc = charging_adjustments(chip, params, soc, vbat_uv, ibat_ua,
 				batt_temp);
-		goto out;
+		/* Skip adjustments if we are in CV or ibat is negative */
+		if (chip->soc_at_cv != -EINVAL || ibat_ua < 0)
+			goto out;
 	}
 
 	/*
@@ -1965,9 +2071,10 @@
 	 * because we might pull it low
 	 * and cause a bad user experience
 	 */
-	if (soc_est == soc
-		|| soc_est > chip->adjust_soc_low_threshold
-		|| soc >= NO_ADJUST_HIGH_SOC_THRESHOLD)
+	if (!wake_lock_active(&chip->low_voltage_wake_lock) &&
+			(soc_est == soc
+			|| soc_est > chip->adjust_soc_low_threshold
+			|| soc >= NO_ADJUST_HIGH_SOC_THRESHOLD))
 		goto out;
 
 	if (chip->last_soc_est == -EINVAL)
@@ -2012,8 +2119,11 @@
 		pr_debug("new delta ocv = %d\n", delta_ocv_uv);
 	}
 
-	if (wake_lock_active(&chip->low_voltage_wake_lock))
+	if (wake_lock_active(&chip->low_voltage_wake_lock)) {
+		/* when in the cutoff region, do not correct upwards */
+		delta_ocv_uv = max(0, delta_ocv_uv);
 		goto skip_limits;
+	}
 
 	if (chip->last_ocv_uv > chip->flat_ocv_threshold_uv)
 		correction_limit_uv = chip->high_ocv_correction_limit_uv;
@@ -2143,7 +2253,8 @@
 	cc_raw_64 = convert_cc_uah_to_raw(chip, target_cc_uah);
 	cc_raw = convert_s64_to_s36(cc_raw_64);
 
-	find_ocv_for_soc(chip, params, batt_temp, target_soc, &target_ocv_uv);
+	target_ocv_uv = find_ocv_for_pc(chip, batt_temp,
+				find_pc_for_soc(chip, params, target_soc));
 	ocv_raw = convert_vbatt_uv_to_raw(chip, target_ocv_uv);
 
 	/*
@@ -2168,13 +2279,13 @@
 			(uint16_t)ocv_raw);
 }
 
+#define BAD_SOC_THRESH	-10
 static int calculate_raw_soc(struct qpnp_bms_chip *chip,
 					struct raw_soc_params *raw,
 					struct soc_params *params,
 					int batt_temp)
 {
-	int soc, new_ocv_uv;
-	int remaining_usable_charge_uah;
+	int soc, remaining_usable_charge_uah;
 
 	/* calculate remaining usable charge */
 	remaining_usable_charge_uah = params->ocv_charge_uah
@@ -2185,14 +2296,16 @@
 	soc = DIV_ROUND_CLOSEST((remaining_usable_charge_uah * 100),
 				(params->fcc_uah - params->uuc_uah));
 
-	if (chip->first_time_calc_soc && soc < 0) {
+	if (chip->first_time_calc_soc && soc > BAD_SOC_THRESH && soc < 0) {
 		/*
 		 * first time calcualtion and the pon ocv  is too low resulting
 		 * in a bad soc. Adjust ocv to get 0 soc
 		 */
 		pr_debug("soc is %d, adjusting pon ocv to make it 0\n", soc);
-		find_ocv_for_soc(chip, params, batt_temp, 0, &new_ocv_uv);
-		chip->last_ocv_uv = new_ocv_uv;
+		chip->last_ocv_uv = find_ocv_for_pc(chip, batt_temp,
+				find_pc_for_soc(chip, params, 0));
+		params->ocv_charge_uah = find_ocv_charge_for_soc(chip,
+				params, 0);
 
 		remaining_usable_charge_uah = params->ocv_charge_uah
 					- params->cc_uah
@@ -2208,7 +2321,7 @@
 	if (soc > 100)
 		soc = 100;
 
-	if (soc < 0) {
+	if (soc > BAD_SOC_THRESH && soc < 0) {
 		pr_debug("bad rem_usb_chg = %d rem_chg %d, cc_uah %d, unusb_chg %d\n",
 				remaining_usable_charge_uah,
 				params->ocv_charge_uah,
@@ -2230,7 +2343,7 @@
 {
 	struct soc_params params;
 	int soc, previous_soc, shutdown_soc, new_calculated_soc;
-	int remaining_usable_charge_uah, new_ocv_uv;
+	int remaining_usable_charge_uah;
 
 	calculate_soc_params(chip, raw, &params, batt_temp);
 	if (!is_battery_present(chip)) {
@@ -2261,9 +2374,10 @@
 		 */
 		pr_debug("soc = %d before forcing shutdown_soc = %d\n",
 							soc, shutdown_soc);
-		find_ocv_for_soc(chip, &params, batt_temp,
-					shutdown_soc, &new_ocv_uv);
-		chip->last_ocv_uv = new_ocv_uv;
+		chip->last_ocv_uv = find_ocv_for_pc(chip, batt_temp,
+				find_pc_for_soc(chip, &params, shutdown_soc));
+		params.ocv_charge_uah = find_ocv_charge_for_soc(chip,
+				&params, shutdown_soc);
 
 		remaining_usable_charge_uah = params.ocv_charge_uah
 					- params.cc_uah
@@ -2460,22 +2574,26 @@
 	recalculate_soc(chip);
 }
 
+static int get_calculation_delay_ms(struct qpnp_bms_chip *chip)
+{
+	if (wake_lock_active(&chip->low_voltage_wake_lock))
+		return chip->low_voltage_calculate_soc_ms;
+	else if (chip->calculated_soc < chip->low_soc_calc_threshold)
+		return chip->low_soc_calculate_soc_ms;
+	else
+		return chip->calculate_soc_ms;
+}
+
 static void calculate_soc_work(struct work_struct *work)
 {
 	struct qpnp_bms_chip *chip = container_of(work,
 				struct qpnp_bms_chip,
 				calculate_soc_delayed_work.work);
-	int soc = recalculate_soc(chip);
 
-	if (soc < chip->low_soc_calc_threshold
-			|| wake_lock_active(&chip->low_voltage_wake_lock))
-		schedule_delayed_work(&chip->calculate_soc_delayed_work,
-			round_jiffies_relative(msecs_to_jiffies
-			(chip->low_soc_calculate_soc_ms)));
-	else
-		schedule_delayed_work(&chip->calculate_soc_delayed_work,
-			round_jiffies_relative(msecs_to_jiffies
-			(chip->calculate_soc_ms)));
+	recalculate_soc(chip);
+	schedule_delayed_work(&chip->calculate_soc_delayed_work,
+		round_jiffies_relative(msecs_to_jiffies
+		(get_calculation_delay_ms(chip))));
 }
 
 static void configure_vbat_monitor_low(struct qpnp_bms_chip *chip)
@@ -3171,12 +3289,20 @@
 
 static void battery_insertion_check(struct qpnp_bms_chip *chip)
 {
-	bool present = is_battery_present(chip);
+	int present = (int)is_battery_present(chip);
+	int insertion_ocv_uv = get_battery_insertion_ocv_uv(chip);
+	int insertion_ocv_taken = (insertion_ocv_uv > 0);
 
 	mutex_lock(&chip->vbat_monitor_mutex);
-	if (chip->battery_present != present) {
+	if (chip->battery_present != present
+			&& (present == insertion_ocv_taken
+				|| chip->battery_present == -EINVAL)) {
+		pr_debug("status = %d, shadow status = %d, insertion_ocv_uv = %d\n",
+				present, chip->battery_present,
+				insertion_ocv_uv);
 		if (chip->battery_present != -EINVAL) {
 			if (present) {
+				chip->insertion_ocv_uv = insertion_ocv_uv;
 				setup_vbat_monitoring(chip);
 				chip->new_battery = true;
 			} else {
@@ -3388,7 +3514,7 @@
 			|| shutdown_soc_out_of_limit) {
 		chip->battery_removed = true;
 		chip->shutdown_soc_invalid = true;
-		chip->shutdown_iavg_ma = 0;
+		chip->shutdown_iavg_ma = MIN_IAVG_MA;
 		pr_debug("Ignoring shutdown SoC: invalid = %d, offmode = %d, out_of_limit = %d\n",
 				invalid_stored_soc, offmode_battery_replaced,
 				shutdown_soc_out_of_limit);
@@ -3617,6 +3743,8 @@
 			"low-soc-calculate-soc-threshold", rc);
 	SPMI_PROP_READ(low_soc_calculate_soc_ms,
 			"low-soc-calculate-soc-ms", rc);
+	SPMI_PROP_READ(low_voltage_calculate_soc_ms,
+			"low-voltage-calculate-soc-ms", rc);
 	SPMI_PROP_READ(calculate_soc_ms, "calculate-soc-ms", rc);
 	SPMI_PROP_READ(high_ocv_correction_limit_uv,
 			"high-ocv-correction-limit-uv", rc);
@@ -4225,10 +4353,7 @@
 	if (rc) {
 		pr_err("Could not read current time: %d\n", rc);
 	} else {
-		if (chip->calculated_soc < chip->low_soc_calc_threshold)
-			soc_calc_period = chip->low_soc_calculate_soc_ms;
-		else
-			soc_calc_period = chip->calculate_soc_ms;
+		soc_calc_period = get_calculation_delay_ms(chip);
 		time_since_last_recalc = tm_now_sec - chip->last_recalc_time;
 		pr_debug("Time since last recalc: %lu\n",
 				time_since_last_recalc);
diff --git a/drivers/power/qpnp-charger.c b/drivers/power/qpnp-charger.c
index 64ad940..095fddf 100644
--- a/drivers/power/qpnp-charger.c
+++ b/drivers/power/qpnp-charger.c
@@ -101,6 +101,7 @@
 #define BUCK_VCHG_OV				0x77
 #define BUCK_TEST_SMBC_MODES			0xE6
 #define BUCK_CTRL_TRIM1				0xF1
+#define BUCK_CTRL_TRIM3				0xF3
 #define SEC_ACCESS				0xD0
 #define BAT_IF_VREF_BAT_THM_CTRL		0x4A
 #define BAT_IF_BPD_CTRL				0x48
@@ -310,6 +311,9 @@
 	bool				btc_disabled;
 	bool				use_default_batt_values;
 	bool				duty_cycle_100p;
+	bool				ibat_calibration_enabled;
+	bool				aicl_settled;
+	bool				use_external_rsense;
 	unsigned int			bpd_detection;
 	unsigned int			max_bat_chg_current;
 	unsigned int			warm_bat_chg_ma;
@@ -325,6 +329,7 @@
 	unsigned int			warm_bat_mv;
 	unsigned int			cool_bat_mv;
 	unsigned int			resume_delta_mv;
+	int				insertion_ocv_uv;
 	int				term_current;
 	int				soc_resume_limit;
 	bool				resuming_charging;
@@ -354,12 +359,14 @@
 	struct delayed_work		usbin_health_check;
 	struct work_struct		soc_check_work;
 	struct delayed_work		aicl_check_work;
+	struct work_struct		insertion_ocv_work;
 	struct qpnp_chg_regulator	otg_vreg;
 	struct qpnp_chg_regulator	boost_vreg;
 	struct qpnp_chg_regulator	batfet_vreg;
 	bool				batfet_ext_en;
 	struct work_struct		batfet_lcl_work;
 	struct qpnp_vadc_chip		*vadc_dev;
+	struct qpnp_iadc_chip		*iadc_dev;
 	struct qpnp_adc_tm_chip		*adc_tm_dev;
 	struct mutex			jeita_configure_lock;
 	spinlock_t			usbin_health_monitor_lock;
@@ -367,6 +374,7 @@
 	struct alarm			reduce_power_stage_alarm;
 	struct work_struct		reduce_power_stage_work;
 	bool				power_stage_workaround_running;
+	bool				power_stage_workaround_enable;
 };
 
 
@@ -418,6 +426,16 @@
 	return -EINVAL;
 }
 
+static bool
+is_within_range(int value, int left, int right)
+{
+	if (left >= right && left >= value && value >= right)
+		return 1;
+	if (left <= right && left <= value && value <= right)
+		return 1;
+	return 0;
+}
+
 static int
 qpnp_chg_read(struct qpnp_chg_chip *chip, u8 *val,
 			u16 base, int count)
@@ -620,6 +638,22 @@
 	return (usbin_valid_rt_sts & USB_VALID_BIT) ? 1 : 0;
 }
 
+static bool
+qpnp_chg_is_ibat_loop_active(struct qpnp_chg_chip *chip)
+{
+	int rc;
+	u8 buck_sts;
+
+	rc = qpnp_chg_read(chip, &buck_sts,
+			INT_RT_STS(chip->buck_base), 1);
+	if (rc) {
+		pr_err("failed to read buck RT status rc=%d\n", rc);
+		return 0;
+	}
+
+	return !!(buck_sts & IBAT_LOOP_IRQ);
+}
+
 #define USB_VALID_MASK 0xC0
 #define USB_COARSE_DET 0x10
 #define USB_VALID_UVP_VALUE    0x00
@@ -866,7 +900,7 @@
 	}
 	if (voltage >= QPNP_CHG_VINMIN_HIGH_MIN_MV) {
 		temp = QPNP_CHG_VINMIN_HIGH_MIN_VAL;
-		temp += (voltage - QPNP_CHG_VINMIN_MIN_MV)
+		temp += (voltage - QPNP_CHG_VINMIN_HIGH_MIN_MV)
 			/ QPNP_CHG_VINMIN_STEP_HIGH_MV;
 	} else {
 		temp = QPNP_CHG_VINMIN_MIN_VAL;
@@ -894,7 +928,7 @@
 
 	if (vin_min == 0)
 		vin_min_mv = QPNP_CHG_I_MAX_MIN_100;
-	else if (vin_min > QPNP_CHG_VINMIN_HIGH_MIN_VAL)
+	else if (vin_min >= QPNP_CHG_VINMIN_HIGH_MIN_VAL)
 		vin_min_mv = QPNP_CHG_VINMIN_HIGH_MIN_MV +
 			(vin_min - QPNP_CHG_VINMIN_HIGH_MIN_VAL)
 				* QPNP_CHG_VINMIN_STEP_HIGH_MV;
@@ -965,6 +999,11 @@
 static int
 qpnp_chg_charge_en(struct qpnp_chg_chip *chip, int enable)
 {
+	if (chip->insertion_ocv_uv == 0 && enable) {
+		pr_debug("Battery not present, skipping\n");
+		return 0;
+	}
+	pr_debug("charging %s\n", enable ? "enabled" : "disabled");
 	return qpnp_chg_masked_write(chip, chip->chgr_base + CHGR_CHG_CTRL,
 			CHGR_CHG_EN,
 			enable ? CHGR_CHG_EN : 0, 1);
@@ -1396,10 +1435,10 @@
 				       (chip->usb_valid_check_ovp)) {
 				usbin_health =
 					qpnp_chg_check_usbin_health(chip);
-				if (chip->usbin_health != usbin_health) {
+				if ((chip->usbin_health != usbin_health)
+					&& (usbin_health == USBIN_OVP)) {
 					chip->usbin_health = usbin_health;
-					if (usbin_health == USBIN_OVP)
-						psy_health_sts =
+					psy_health_sts =
 					POWER_SUPPLY_HEALTH_OVERVOLTAGE;
 					power_supply_set_health_state(
 						chip->usb_psy,
@@ -1412,8 +1451,9 @@
 				qpnp_chg_set_appropriate_vddmax(chip);
 				chip->chg_done = false;
 			}
-			qpnp_chg_usb_suspend_enable(chip, 1);
+			qpnp_chg_usb_suspend_enable(chip, 0);
 			chip->prev_usb_max_ma = -EINVAL;
+			chip->aicl_settled = false;
 		} else {
 			/* when OVP clamped usbin, and then decrease
 			 * the charger voltage to lower than the OVP
@@ -1424,10 +1464,10 @@
 				       (chip->usb_valid_check_ovp)) {
 				usbin_health =
 					qpnp_chg_check_usbin_health(chip);
-				if (chip->usbin_health != usbin_health) {
+				if ((chip->usbin_health != usbin_health)
+					&& (usbin_health == USBIN_OK)) {
 					chip->usbin_health = usbin_health;
-					 if (usbin_health == USBIN_OK)
-						psy_health_sts =
+					psy_health_sts =
 						POWER_SUPPLY_HEALTH_GOOD;
 					power_supply_set_health_state(
 						chip->usb_psy,
@@ -1476,6 +1516,12 @@
 	pr_debug("batt-pres triggered: %d\n", batt_present);
 
 	if (chip->batt_present ^ batt_present) {
+		if (batt_present) {
+			schedule_work(&chip->insertion_ocv_work);
+		} else {
+			chip->insertion_ocv_uv = 0;
+			qpnp_chg_charge_en(chip, 0);
+		}
 		chip->batt_present = batt_present;
 		pr_debug("psy changed batt_psy\n");
 		power_supply_changed(&chip->batt_psy);
@@ -1507,6 +1553,8 @@
 
 	if (chip->dc_present ^ dc_present) {
 		chip->dc_present = dc_present;
+		if (qpnp_chg_is_otg_en_set(chip))
+			qpnp_chg_force_run_on_batt(chip, !dc_present ? 1 : 0);
 		if (!dc_present && !qpnp_chg_is_usb_chg_plugged_in(chip)) {
 			chip->delta_vddmax_mv = 0;
 			qpnp_chg_set_appropriate_vddmax(chip);
@@ -1640,6 +1688,7 @@
 	case POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL:
 	case POWER_SUPPLY_PROP_INPUT_CURRENT_MAX:
 	case POWER_SUPPLY_PROP_INPUT_CURRENT_TRIM:
+	case POWER_SUPPLY_PROP_INPUT_CURRENT_SETTLED:
 	case POWER_SUPPLY_PROP_VOLTAGE_MIN:
 	case POWER_SUPPLY_PROP_COOL_TEMP:
 	case POWER_SUPPLY_PROP_WARM_TEMP:
@@ -1711,10 +1760,12 @@
 	if (qpnp_chg_is_otg_en_set(chip))
 		return 0;
 
-	rc = qpnp_chg_force_run_on_batt(chip, 1);
-	if (rc) {
-		pr_err("Failed to disable charging rc = %d\n", rc);
-		return rc;
+	if (!qpnp_chg_is_dc_chg_plugged_in(chip)) {
+		rc = qpnp_chg_force_run_on_batt(chip, 1);
+		if (rc) {
+			pr_err("Failed to disable charging rc = %d\n", rc);
+			return rc;
+		}
 	}
 
 	/* force usb ovp fet off */
@@ -1751,6 +1802,7 @@
 	POWER_SUPPLY_PROP_CURRENT_NOW,
 	POWER_SUPPLY_PROP_INPUT_CURRENT_MAX,
 	POWER_SUPPLY_PROP_INPUT_CURRENT_TRIM,
+	POWER_SUPPLY_PROP_INPUT_CURRENT_SETTLED,
 	POWER_SUPPLY_PROP_VOLTAGE_MIN,
 	POWER_SUPPLY_PROP_INPUT_VOLTAGE_REGULATION,
 	POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
@@ -1760,6 +1812,7 @@
 	POWER_SUPPLY_PROP_WARM_TEMP,
 	POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL,
 	POWER_SUPPLY_PROP_CYCLE_COUNT,
+	POWER_SUPPLY_PROP_VOLTAGE_OCV,
 };
 
 static char *pm_power_supplied_to[] = {
@@ -2110,9 +2163,12 @@
 		if (chip->prev_usb_max_ma == ret.intval)
 			goto skip_set_iusb_max;
 
+		chip->prev_usb_max_ma = ret.intval;
+
 		if (ret.intval <= 2 && !chip->use_default_batt_values &&
 						get_prop_batt_present(chip)) {
-			qpnp_chg_usb_suspend_enable(chip, 1);
+			if (ret.intval ==  2)
+				qpnp_chg_usb_suspend_enable(chip, 1);
 			qpnp_chg_iusbmax_set(chip, QPNP_CHG_I_MAX_MIN_100);
 		} else {
 			qpnp_chg_usb_suspend_enable(chip, 0);
@@ -2131,14 +2187,14 @@
 
 			if ((chip->flags & POWER_STAGE_WA)
 			&& ((ret.intval / 1000) > USB_WALL_THRESHOLD_MA)
-			&& !chip->power_stage_workaround_running) {
+			&& !chip->power_stage_workaround_running
+			&& chip->power_stage_workaround_enable) {
 				chip->power_stage_workaround_running = true;
 				pr_debug("usb wall chg inserted starting power stage workaround charger_monitor = %d\n",
 						charger_monitor);
 				schedule_work(&chip->reduce_power_stage_work);
 			}
 		}
-		chip->prev_usb_max_ma = ret.intval;
 	}
 
 skip_set_iusb_max:
@@ -2180,6 +2236,9 @@
 	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
 		val->intval = get_prop_battery_voltage_now(chip);
 		break;
+	case POWER_SUPPLY_PROP_VOLTAGE_OCV:
+		val->intval = chip->insertion_ocv_uv;
+		break;
 	case POWER_SUPPLY_PROP_TEMP:
 		val->intval = get_prop_batt_temp(chip);
 		break;
@@ -2219,6 +2278,9 @@
 	case POWER_SUPPLY_PROP_INPUT_CURRENT_TRIM:
 		val->intval = qpnp_chg_iusb_trim_get(chip);
 		break;
+	case POWER_SUPPLY_PROP_INPUT_CURRENT_SETTLED:
+		val->intval = chip->aicl_settled;
+		break;
 	case POWER_SUPPLY_PROP_VOLTAGE_MIN:
 		val->intval = qpnp_chg_vinmin_get(chip) * 1000;
 		break;
@@ -2325,6 +2387,24 @@
 			QPNP_CHG_I_MASK, temp, 1);
 }
 
+static int
+qpnp_chg_ibatmax_get(struct qpnp_chg_chip *chip, int *chg_current)
+{
+	int rc;
+	u8 temp;
+
+	*chg_current = 0;
+	rc = qpnp_chg_read(chip, &temp, chip->chgr_base + CHGR_IBAT_MAX, 1);
+	if (rc) {
+		pr_err("failed read ibat_max rc=%d\n", rc);
+		return rc;
+	}
+
+	*chg_current = ((temp & QPNP_CHG_I_MASK) * QPNP_CHG_I_STEP_MA);
+
+	return 0;
+}
+
 #define QPNP_CHG_TCHG_MASK	0x7F
 #define QPNP_CHG_TCHG_MIN	4
 #define QPNP_CHG_TCHG_MAX	512
@@ -2359,6 +2439,155 @@
 		chip->chgr_base + CHGR_VDD_SAFE, 1);
 }
 
+#define IBAT_TRIM_TGT_MA		500
+#define IBAT_TRIM_OFFSET_MASK		0x7F
+#define IBAT_TRIM_GOOD_BIT		BIT(7)
+#define IBAT_TRIM_LOW_LIM		20
+#define IBAT_TRIM_HIGH_LIM		114
+#define IBAT_TRIM_MEAN			64
+
+static void
+qpnp_chg_trim_ibat(struct qpnp_chg_chip *chip, u8 ibat_trim)
+{
+	int ibat_now_ma, ibat_diff_ma, rc;
+	struct qpnp_iadc_result i_result;
+	enum qpnp_iadc_channels iadc_channel;
+
+	iadc_channel = chip->use_external_rsense ?
+				EXTERNAL_RSENSE : INTERNAL_RSENSE;
+	rc = qpnp_iadc_read(chip->iadc_dev, iadc_channel, &i_result);
+	if (rc) {
+		pr_err("Unable to read bat rc=%d\n", rc);
+		return;
+	}
+
+	ibat_now_ma = i_result.result_ua / 1000;
+
+	if (qpnp_chg_is_ibat_loop_active(chip)) {
+		ibat_diff_ma = ibat_now_ma - IBAT_TRIM_TGT_MA;
+
+		if (abs(ibat_diff_ma) > 50) {
+			ibat_trim += (ibat_diff_ma / 20);
+			ibat_trim &= IBAT_TRIM_OFFSET_MASK;
+			/* reject new ibat_trim if it is outside limits */
+			if (!is_within_range(ibat_trim, IBAT_TRIM_LOW_LIM,
+						IBAT_TRIM_HIGH_LIM))
+				return;
+		}
+		ibat_trim |= IBAT_TRIM_GOOD_BIT;
+		rc = qpnp_chg_write(chip, &ibat_trim,
+				chip->buck_base + BUCK_CTRL_TRIM3, 1);
+		if (rc)
+			pr_err("failed to set IBAT_TRIM rc=%d\n", rc);
+
+		pr_debug("ibat_now=%dmA, itgt=%dmA, ibat_diff=%dmA, ibat_trim=%x\n",
+					ibat_now_ma, IBAT_TRIM_TGT_MA,
+					ibat_diff_ma, ibat_trim);
+	} else {
+		pr_debug("ibat loop not active - cannot calibrate ibat\n");
+	}
+}
+
+static int
+qpnp_chg_input_current_settled(struct qpnp_chg_chip *chip)
+{
+	int rc, ibat_max_ma;
+	u8 reg, chgr_sts, ibat_trim, i;
+
+	chip->aicl_settled = true;
+
+	/*
+	 * Perform the ibat calibration.
+	 * This is for devices which have a IBAT_TRIM error
+	 * which can show IBAT_MAX out of spec.
+	 */
+	if (!chip->ibat_calibration_enabled)
+		return 0;
+
+	if (chip->type != SMBB)
+		return 0;
+
+	rc = qpnp_chg_read(chip, &reg,
+			chip->buck_base + BUCK_CTRL_TRIM3, 1);
+	if (rc) {
+		pr_err("failed to read BUCK_CTRL_TRIM3 rc=%d\n", rc);
+		return rc;
+	}
+	if (reg & IBAT_TRIM_GOOD_BIT) {
+		pr_debug("IBAT_TRIM_GOOD bit already set. Quitting!\n");
+		return 0;
+	}
+	ibat_trim = reg & IBAT_TRIM_OFFSET_MASK;
+
+	if (!is_within_range(ibat_trim, IBAT_TRIM_LOW_LIM,
+					IBAT_TRIM_HIGH_LIM)) {
+		pr_debug("Improper ibat_trim value=%x setting to value=%x\n",
+						ibat_trim, IBAT_TRIM_MEAN);
+		ibat_trim = IBAT_TRIM_MEAN;
+		rc = qpnp_chg_masked_write(chip,
+				chip->buck_base + BUCK_CTRL_TRIM3,
+				IBAT_TRIM_OFFSET_MASK, ibat_trim, 1);
+		if (rc) {
+			pr_err("failed to set ibat_trim to %x rc=%d\n",
+						IBAT_TRIM_MEAN, rc);
+			return rc;
+		}
+	}
+
+	rc = qpnp_chg_read(chip, &chgr_sts,
+				INT_RT_STS(chip->chgr_base), 1);
+	if (rc) {
+		pr_err("failed to read interrupt sts rc=%d\n", rc);
+		return rc;
+	}
+	if (!(chgr_sts & FAST_CHG_ON_IRQ)) {
+		pr_debug("Not in fastchg\n");
+		return rc;
+	}
+
+	/* save the ibat_max to restore it later */
+	rc = qpnp_chg_ibatmax_get(chip, &ibat_max_ma);
+	if (rc) {
+		pr_debug("failed to save ibatmax rc=%d\n", rc);
+		return rc;
+	}
+
+	rc = qpnp_chg_ibatmax_set(chip, IBAT_TRIM_TGT_MA);
+	if (rc) {
+		pr_err("failed to set ibatmax rc=%d\n", rc);
+		return rc;
+	}
+
+	for (i = 0; i < 3; i++) {
+		/*
+		 * ibat settling delay - to make sure the BMS controller
+		 * has sufficient time to sample ibat for the configured
+		 * ibat_max
+		 */
+		msleep(20);
+		if (qpnp_chg_is_ibat_loop_active(chip))
+			qpnp_chg_trim_ibat(chip, ibat_trim);
+		else
+			pr_debug("ibat loop not active\n");
+
+		/* read the adjusted ibat_trim for further adjustments */
+		rc = qpnp_chg_read(chip, &ibat_trim,
+			chip->buck_base + BUCK_CTRL_TRIM3, 1);
+		if (rc) {
+			pr_err("failed to read BUCK_CTRL_TRIM3 rc=%d\n", rc);
+			break;
+		}
+	}
+
+	/* restore IBATMAX */
+	rc = qpnp_chg_ibatmax_set(chip, ibat_max_ma);
+	if (rc)
+		pr_err("failed to restore ibatmax rc=%d\n", rc);
+
+	return rc;
+}
+
+
 #define BOOST_MIN_UV	4200000
 #define BOOST_MAX_UV	5500000
 #define BOOST_STEP_UV	50000
@@ -2888,6 +3117,32 @@
 }
 
 static void
+qpnp_chg_insertion_ocv_work(struct work_struct *work)
+{
+	struct qpnp_chg_chip *chip = container_of(work,
+				struct qpnp_chg_chip, insertion_ocv_work);
+	u8 bat_if_sts = 0, charge_en = 0;
+	int rc;
+
+	chip->insertion_ocv_uv = get_prop_battery_voltage_now(chip);
+
+	rc = qpnp_chg_read(chip, &bat_if_sts, INT_RT_STS(chip->bat_if_base), 1);
+	if (rc)
+		pr_err("failed to read bat_if sts %d\n", rc);
+
+	rc = qpnp_chg_read(chip, &charge_en,
+			chip->chgr_base + CHGR_CHG_CTRL, 1);
+	if (rc)
+		pr_err("failed to read bat_if sts %d\n", rc);
+
+	pr_debug("batfet sts = %02x, charge_en = %02x ocv = %d\n",
+			bat_if_sts, charge_en, chip->insertion_ocv_uv);
+	qpnp_chg_charge_en(chip, !chip->charging_disabled);
+	pr_debug("psy changed batt_psy\n");
+	power_supply_changed(&chip->batt_psy);
+}
+
+static void
 qpnp_chg_soc_check_work(struct work_struct *work)
 {
 	struct qpnp_chg_chip *chip = container_of(work,
@@ -3327,6 +3582,9 @@
 	case POWER_SUPPLY_PROP_INPUT_CURRENT_TRIM:
 		qpnp_chg_iusb_trim_set(chip, val->intval);
 		break;
+	case POWER_SUPPLY_PROP_INPUT_CURRENT_SETTLED:
+		qpnp_chg_input_current_settled(chip);
+		break;
 	case POWER_SUPPLY_PROP_VOLTAGE_MIN:
 		qpnp_chg_vinmin_set(chip, val->intval / 1000);
 		break;
@@ -4048,6 +4306,11 @@
 			return rc;
 	}
 
+	/* Get the use-external-rsense property */
+	chip->use_external_rsense = of_property_read_bool(
+			chip->spmi->dev.of_node,
+			"qcom,use-external-rsense");
+
 	/* Get the btc-disabled property */
 	chip->btc_disabled = of_property_read_bool(chip->spmi->dev.of_node,
 					"qcom,btc-disabled");
@@ -4076,17 +4339,25 @@
 	if (chip->use_default_batt_values)
 		chip->charging_disabled = true;
 
+	chip->power_stage_workaround_enable =
+			of_property_read_bool(chip->spmi->dev.of_node,
+					"qcom,power-stage-reduced");
+
+	chip->ibat_calibration_enabled =
+			of_property_read_bool(chip->spmi->dev.of_node,
+					"qcom,ibat-calibration-enabled");
+
 	of_get_property(chip->spmi->dev.of_node, "qcom,thermal-mitigation",
 		&(chip->thermal_levels));
 
 	if (chip->thermal_levels > sizeof(int)) {
-		chip->thermal_mitigation = kzalloc(
+		chip->thermal_mitigation = devm_kzalloc(chip->dev,
 			chip->thermal_levels,
 			GFP_KERNEL);
 
 		if (chip->thermal_mitigation == NULL) {
 			pr_err("thermal mitigation kzalloc() failed.\n");
-			return rc;
+			return -ENOMEM;
 		}
 
 		chip->thermal_levels /= sizeof(int);
@@ -4111,7 +4382,8 @@
 	struct spmi_resource *spmi_resource;
 	int rc = 0;
 
-	chip = kzalloc(sizeof *chip, GFP_KERNEL);
+	chip = devm_kzalloc(&spmi->dev,
+			sizeof(struct qpnp_chg_chip), GFP_KERNEL);
 	if (chip == NULL) {
 		pr_err("kzalloc() failed.\n");
 		return -ENOMEM;
@@ -4137,11 +4409,13 @@
 	mutex_init(&chip->batfet_vreg_lock);
 	INIT_WORK(&chip->batfet_lcl_work,
 			qpnp_chg_batfet_lcl_work);
+	INIT_WORK(&chip->insertion_ocv_work,
+			qpnp_chg_insertion_ocv_work);
 
 	/* Get all device tree properties */
 	rc = qpnp_charger_read_dt_props(chip);
 	if (rc)
-		goto fail_chg_enable;
+		return rc;
 
 	/*
 	 * Check if bat_if is set in DT and make sure VADC is present
@@ -4181,6 +4455,17 @@
 				goto fail_chg_enable;
 			}
 
+			if (subtype == SMBB_BAT_IF_SUBTYPE) {
+				chip->iadc_dev = qpnp_get_iadc(chip->dev,
+						"chg");
+				if (IS_ERR(chip->iadc_dev)) {
+					rc = PTR_ERR(chip->iadc_dev);
+					if (rc != -EPROBE_DEFER)
+						pr_err("iadc property missing\n");
+					goto fail_chg_enable;
+				}
+			}
+
 			rc = qpnp_chg_load_battery_data(chip);
 			if (rc)
 				goto fail_chg_enable;
@@ -4317,6 +4602,8 @@
 	dev_set_drvdata(&spmi->dev, chip);
 	device_init_wakeup(&spmi->dev, 1);
 
+	chip->insertion_ocv_uv = -EINVAL;
+	chip->batt_present = qpnp_chg_is_batt_present(chip);
 	if (chip->bat_if_base) {
 		chip->batt_psy.name = "battery";
 		chip->batt_psy.type = POWER_SUPPLY_TYPE_BATTERY;
@@ -4451,9 +4738,6 @@
 fail_chg_enable:
 	regulator_unregister(chip->otg_vreg.rdev);
 	regulator_unregister(chip->boost_vreg.rdev);
-	kfree(chip->thermal_mitigation);
-	kfree(chip);
-	dev_set_drvdata(&spmi->dev, NULL);
 	return rc;
 }
 
@@ -4466,15 +4750,27 @@
 		qpnp_adc_tm_disable_chan_meas(chip->adc_tm_dev,
 							&chip->adc_param);
 	}
-	cancel_work_sync(&chip->adc_measure_work);
+
+	cancel_delayed_work_sync(&chip->aicl_check_work);
+	power_supply_unregister(&chip->dc_psy);
+	cancel_work_sync(&chip->soc_check_work);
+	cancel_delayed_work_sync(&chip->usbin_health_check);
+	cancel_delayed_work_sync(&chip->arb_stop_work);
 	cancel_delayed_work_sync(&chip->eoc_work);
+	cancel_work_sync(&chip->adc_disable_work);
+	cancel_work_sync(&chip->adc_measure_work);
+	power_supply_unregister(&chip->batt_psy);
+	cancel_work_sync(&chip->batfet_lcl_work);
+	cancel_work_sync(&chip->insertion_ocv_work);
+	cancel_work_sync(&chip->reduce_power_stage_work);
+	alarm_cancel(&chip->reduce_power_stage_alarm);
+
+	mutex_destroy(&chip->batfet_vreg_lock);
+	mutex_destroy(&chip->jeita_configure_lock);
 
 	regulator_unregister(chip->otg_vreg.rdev);
 	regulator_unregister(chip->boost_vreg.rdev);
 
-	dev_set_drvdata(&spmi->dev, NULL);
-	kfree(chip);
-
 	return 0;
 }
 
diff --git a/drivers/slimbus/slim-msm-ngd.c b/drivers/slimbus/slim-msm-ngd.c
index 0c9959c..67cf049 100644
--- a/drivers/slimbus/slim-msm-ngd.c
+++ b/drivers/slimbus/slim-msm-ngd.c
@@ -1065,7 +1065,7 @@
 	}
 
 	dev = kzalloc(sizeof(struct msm_slim_ctrl), GFP_KERNEL);
-	if (IS_ERR(dev)) {
+	if (IS_ERR_OR_NULL(dev)) {
 		dev_err(&pdev->dev, "no memory for MSM slimbus controller\n");
 		return PTR_ERR(dev);
 	}
diff --git a/drivers/spi/spi_qsd.c b/drivers/spi/spi_qsd.c
index 4512d02..45400cb 100644
--- a/drivers/spi/spi_qsd.c
+++ b/drivers/spi/spi_qsd.c
@@ -652,8 +652,6 @@
 	if (dd->qup_ver == SPI_QUP_VERSION_NONE)
 		/* flags removed from SPI_CONFIG in QUP version-2 */
 		msm_spi_set_bpw_and_no_io_flags(dd, &spi_config, bpw-1);
-	else if (dd->mode == SPI_BAM_MODE)
-		spi_config |= SPI_CFG_INPUT_FIRST;
 
 	/*
 	 * HS_MODE improves signal stability for spi-clk high rates
diff --git a/drivers/spmi/spmi-dbgfs.h b/drivers/spmi/spmi-dbgfs.h
index 10e98b9..a419002 100644
--- a/drivers/spmi/spmi-dbgfs.h
+++ b/drivers/spmi/spmi-dbgfs.h
@@ -18,8 +18,14 @@
 int spmi_dfs_add_controller(struct spmi_controller *ctrl);
 int spmi_dfs_del_controller(struct spmi_controller *ctrl);
 #else
-static int spmi_dfs_add_controller(struct spmi_controller *ctrl) { return 0; }
-static int spmi_dfs_del_controller(struct spmi_controller *ctrl) { return 0; }
+static inline int spmi_dfs_add_controller(struct spmi_controller *ctrl)
+{
+	return 0;
+}
+static inline int spmi_dfs_del_controller(struct spmi_controller *ctrl)
+{
+	return 0;
+}
 #endif
 
 struct dentry *spmi_dfs_create_file(struct spmi_controller *ctrl,
diff --git a/drivers/staging/zram/Kconfig b/drivers/staging/zram/Kconfig
index 9d11a4c..983314c 100644
--- a/drivers/staging/zram/Kconfig
+++ b/drivers/staging/zram/Kconfig
@@ -1,9 +1,6 @@
 config ZRAM
 	tristate "Compressed RAM block device support"
-	# X86 dependency is because zsmalloc uses non-portable pte/tlb
-	# functions
-	depends on BLOCK && SYSFS && X86
-	select ZSMALLOC
+	depends on BLOCK && SYSFS && ZSMALLOC
 	select LZO_COMPRESS
 	select LZO_DECOMPRESS
 	default n
@@ -17,7 +14,7 @@
 	  disks and maybe many more.
 
 	  See zram.txt for more information.
-	  Project home: http://compcache.googlecode.com/
+	  Project home: <https://compcache.googlecode.com/>
 
 config ZRAM_DEBUG
 	bool "Compressed RAM block device debug support"
diff --git a/drivers/staging/zram/Makefile b/drivers/staging/zram/Makefile
index 7f4a301..cb0f9ce 100644
--- a/drivers/staging/zram/Makefile
+++ b/drivers/staging/zram/Makefile
@@ -1,3 +1,3 @@
-zram-y	:=	zram_drv.o zram_sysfs.o
+zram-y	:=	zram_drv.o
 
 obj-$(CONFIG_ZRAM)	+=	zram.o
diff --git a/drivers/staging/zram/zram.txt b/drivers/staging/zram/zram.txt
index 5f75d29..765d790 100644
--- a/drivers/staging/zram/zram.txt
+++ b/drivers/staging/zram/zram.txt
@@ -23,17 +23,17 @@
 	This creates 4 devices: /dev/zram{0,1,2,3}
 	(num_devices parameter is optional. Default: 1)
 
-2) Set Disksize (Optional):
-	Set disk size by writing the value to sysfs node 'disksize'
-	(in bytes). If disksize is not given, default value of 25%
-	of RAM is used.
+2) Set Disksize
+        Set disk size by writing the value to sysfs node 'disksize'.
+        The value can be either in bytes or you can use mem suffixes.
+        Examples:
+            # Initialize /dev/zram0 with 50MB disksize
+            echo $((50*1024*1024)) > /sys/block/zram0/disksize
 
-	# Initialize /dev/zram0 with 50MB disksize
-	echo $((50*1024*1024)) > /sys/block/zram0/disksize
-
-	NOTE: disksize cannot be changed if the disk contains any
-	data. So, for such a disk, you need to issue 'reset' (see below)
-	before you can change its disksize.
+            # Using mem suffixes
+            echo 256K > /sys/block/zram0/disksize
+            echo 512M > /sys/block/zram0/disksize
+            echo 1G > /sys/block/zram0/disksize
 
 3) Activate:
 	mkswap /dev/zram0
@@ -65,8 +65,9 @@
 	echo 1 > /sys/block/zram0/reset
 	echo 1 > /sys/block/zram1/reset
 
-	(This frees all the memory allocated for the given device).
-
+	This frees all the memory allocated for the given device and
+	resets the disksize to zero. You must set the disksize again
+	before reusing the device.
 
 Please report any problems at:
  - Mailing list: linux-mm-cc at laptop dot org
diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c
index 685d612..83fa657 100644
--- a/drivers/staging/zram/zram_drv.c
+++ b/drivers/staging/zram/zram_drv.c
@@ -32,61 +32,229 @@
 #include <linux/lzo.h>
 #include <linux/string.h>
 #include <linux/vmalloc.h>
+#include <linux/ratelimit.h>
 
 #include "zram_drv.h"
 
 /* Globals */
 static int zram_major;
-struct zram *zram_devices;
+static struct zram *zram_devices;
+
+/*
+ * We don't need to see memory allocation errors more than once every 1
+ * second to know that a problem is occurring.
+ */
+#define ALLOC_ERROR_LOG_RATE_MS 1000
 
 /* Module params (documentation at end) */
-static unsigned int num_devices;
+static unsigned int num_devices = 1;
 
-static void zram_stat_inc(u32 *v)
+static inline struct zram *dev_to_zram(struct device *dev)
 {
-	*v = *v + 1;
+	return (struct zram *)dev_to_disk(dev)->private_data;
 }
 
-static void zram_stat_dec(u32 *v)
+static ssize_t disksize_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
 {
-	*v = *v - 1;
+	struct zram *zram = dev_to_zram(dev);
+
+	return sprintf(buf, "%llu\n", zram->disksize);
 }
 
-static void zram_stat64_add(struct zram *zram, u64 *v, u64 inc)
+static ssize_t initstate_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
 {
-	spin_lock(&zram->stat64_lock);
-	*v = *v + inc;
-	spin_unlock(&zram->stat64_lock);
+	struct zram *zram = dev_to_zram(dev);
+
+	return sprintf(buf, "%u\n", zram->init_done);
 }
 
-static void zram_stat64_sub(struct zram *zram, u64 *v, u64 dec)
+static ssize_t num_reads_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
 {
-	spin_lock(&zram->stat64_lock);
-	*v = *v - dec;
-	spin_unlock(&zram->stat64_lock);
+	struct zram *zram = dev_to_zram(dev);
+
+	return sprintf(buf, "%llu\n",
+			(u64)atomic64_read(&zram->stats.num_reads));
 }
 
-static void zram_stat64_inc(struct zram *zram, u64 *v)
+static ssize_t num_writes_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
 {
-	zram_stat64_add(zram, v, 1);
+	struct zram *zram = dev_to_zram(dev);
+
+	return sprintf(buf, "%llu\n",
+			(u64)atomic64_read(&zram->stats.num_writes));
 }
 
-static int zram_test_flag(struct zram *zram, u32 index,
+static ssize_t invalid_io_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct zram *zram = dev_to_zram(dev);
+
+	return sprintf(buf, "%llu\n",
+			(u64)atomic64_read(&zram->stats.invalid_io));
+}
+
+static ssize_t notify_free_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct zram *zram = dev_to_zram(dev);
+
+	return sprintf(buf, "%llu\n",
+			(u64)atomic64_read(&zram->stats.notify_free));
+}
+
+static ssize_t zero_pages_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct zram *zram = dev_to_zram(dev);
+
+	return sprintf(buf, "%u\n", zram->stats.pages_zero);
+}
+
+static ssize_t orig_data_size_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct zram *zram = dev_to_zram(dev);
+
+	return sprintf(buf, "%llu\n",
+		(u64)(zram->stats.pages_stored) << PAGE_SHIFT);
+}
+
+static ssize_t compr_data_size_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	struct zram *zram = dev_to_zram(dev);
+
+	return sprintf(buf, "%llu\n",
+			(u64)atomic64_read(&zram->stats.compr_size));
+}
+
+static ssize_t mem_used_total_show(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	u64 val = 0;
+	struct zram *zram = dev_to_zram(dev);
+	struct zram_meta *meta = zram->meta;
+
+	down_read(&zram->init_lock);
+	if (zram->init_done)
+		val = zs_get_total_size_bytes(meta->mem_pool);
+	up_read(&zram->init_lock);
+
+	return sprintf(buf, "%llu\n", val);
+}
+
+static int zram_test_flag(struct zram_meta *meta, u32 index,
 			enum zram_pageflags flag)
 {
-	return zram->table[index].flags & BIT(flag);
+	return meta->table[index].flags & BIT(flag);
 }
 
-static void zram_set_flag(struct zram *zram, u32 index,
+static void zram_set_flag(struct zram_meta *meta, u32 index,
 			enum zram_pageflags flag)
 {
-	zram->table[index].flags |= BIT(flag);
+	meta->table[index].flags |= BIT(flag);
 }
 
-static void zram_clear_flag(struct zram *zram, u32 index,
+static void zram_clear_flag(struct zram_meta *meta, u32 index,
 			enum zram_pageflags flag)
 {
-	zram->table[index].flags &= ~BIT(flag);
+	meta->table[index].flags &= ~BIT(flag);
+}
+
+static inline int is_partial_io(struct bio_vec *bvec)
+{
+	return bvec->bv_len != PAGE_SIZE;
+}
+
+/*
+ * Check if request is within bounds and aligned on zram logical blocks.
+ */
+static inline int valid_io_request(struct zram *zram, struct bio *bio)
+{
+	u64 start, end, bound;
+
+	/* unaligned request */
+	if (unlikely(bio->bi_sector & (ZRAM_SECTOR_PER_LOGICAL_BLOCK - 1)))
+		return 0;
+	if (unlikely(bio->bi_size & (ZRAM_LOGICAL_BLOCK_SIZE - 1)))
+		return 0;
+
+	start = bio->bi_sector;
+	end = start + (bio->bi_size >> SECTOR_SHIFT);
+	bound = zram->disksize >> SECTOR_SHIFT;
+	/* out of range range */
+	if (unlikely(start >= bound || end > bound || start > end))
+		return 0;
+
+	/* I/O request is valid */
+	return 1;
+}
+
+static void zram_meta_free(struct zram_meta *meta)
+{
+	zs_destroy_pool(meta->mem_pool);
+	kfree(meta->compress_workmem);
+	free_pages((unsigned long)meta->compress_buffer, 1);
+	vfree(meta->table);
+	kfree(meta);
+}
+
+static struct zram_meta *zram_meta_alloc(u64 disksize)
+{
+	size_t num_pages;
+	struct zram_meta *meta = kmalloc(sizeof(*meta), GFP_KERNEL);
+	if (!meta)
+		goto out;
+
+	meta->compress_workmem = kzalloc(LZO1X_MEM_COMPRESS, GFP_KERNEL);
+	if (!meta->compress_workmem)
+		goto free_meta;
+
+	meta->compress_buffer =
+		(void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, 1);
+	if (!meta->compress_buffer) {
+		pr_err("Error allocating compressor buffer space\n");
+		goto free_workmem;
+	}
+
+	num_pages = disksize >> PAGE_SHIFT;
+	meta->table = vzalloc(num_pages * sizeof(*meta->table));
+	if (!meta->table) {
+		pr_err("Error allocating zram address table\n");
+		goto free_buffer;
+	}
+
+	meta->mem_pool = zs_create_pool(GFP_NOIO | __GFP_HIGHMEM |
+					__GFP_NOWARN);
+	if (!meta->mem_pool) {
+		pr_err("Error creating memory pool\n");
+		goto free_table;
+	}
+
+	return meta;
+
+free_table:
+	vfree(meta->table);
+free_buffer:
+	free_pages((unsigned long)meta->compress_buffer, 1);
+free_workmem:
+	kfree(meta->compress_workmem);
+free_meta:
+	kfree(meta);
+	meta = NULL;
+out:
+	return meta;
+}
+
+static void update_position(u32 *index, int *offset, struct bio_vec *bvec)
+{
+	if (*offset + bvec->bv_len >= PAGE_SIZE)
+		(*index)++;
+	*offset = (*offset + bvec->bv_len) % PAGE_SIZE;
 }
 
 static int page_zero_filled(void *ptr)
@@ -104,352 +272,272 @@
 	return 1;
 }
 
-static void zram_set_disksize(struct zram *zram, size_t totalram_bytes)
-{
-	if (!zram->disksize) {
-		pr_info(
-		"disk size not provided. You can use disksize_kb module "
-		"param to specify size.\nUsing default: (%u%% of RAM).\n",
-		default_disksize_perc_ram
-		);
-		zram->disksize = default_disksize_perc_ram *
-					(totalram_bytes / 100);
-	}
-
-	if (zram->disksize > 2 * (totalram_bytes)) {
-		pr_info(
-		"There is little point creating a zram of greater than "
-		"twice the size of memory since we expect a 2:1 compression "
-		"ratio. Note that zram uses about 0.1%% of the size of "
-		"the disk when not in use so a huge zram is "
-		"wasteful.\n"
-		"\tMemory Size: %zu kB\n"
-		"\tSize you selected: %llu kB\n"
-		"Continuing anyway ...\n",
-		totalram_bytes >> 10, zram->disksize
-		);
-	}
-
-	zram->disksize &= PAGE_MASK;
-}
-
-static void zram_free_page(struct zram *zram, size_t index)
-{
-	void *handle = zram->table[index].handle;
-
-	if (unlikely(!handle)) {
-		/*
-		 * No memory is allocated for zero filled pages.
-		 * Simply clear zero page flag.
-		 */
-		if (zram_test_flag(zram, index, ZRAM_ZERO)) {
-			zram_clear_flag(zram, index, ZRAM_ZERO);
-			zram_stat_dec(&zram->stats.pages_zero);
-		}
-		return;
-	}
-
-	if (unlikely(zram_test_flag(zram, index, ZRAM_UNCOMPRESSED))) {
-		__free_page(handle);
-		zram_clear_flag(zram, index, ZRAM_UNCOMPRESSED);
-		zram_stat_dec(&zram->stats.pages_expand);
-		goto out;
-	}
-
-	zs_free(zram->mem_pool, handle);
-
-	if (zram->table[index].size <= PAGE_SIZE / 2)
-		zram_stat_dec(&zram->stats.good_compress);
-
-out:
-	zram_stat64_sub(zram, &zram->stats.compr_size,
-			zram->table[index].size);
-	zram_stat_dec(&zram->stats.pages_stored);
-
-	zram->table[index].handle = NULL;
-	zram->table[index].size = 0;
-}
-
 static void handle_zero_page(struct bio_vec *bvec)
 {
 	struct page *page = bvec->bv_page;
 	void *user_mem;
 
 	user_mem = kmap_atomic(page);
-	memset(user_mem + bvec->bv_offset, 0, bvec->bv_len);
+	if (is_partial_io(bvec))
+		memset(user_mem + bvec->bv_offset, 0, bvec->bv_len);
+	else
+		clear_page(user_mem);
 	kunmap_atomic(user_mem);
 
 	flush_dcache_page(page);
 }
 
-static void handle_uncompressed_page(struct zram *zram, struct bio_vec *bvec,
-				     u32 index, int offset)
+static void zram_free_page(struct zram *zram, size_t index)
 {
-	struct page *page = bvec->bv_page;
-	unsigned char *user_mem, *cmem;
+	struct zram_meta *meta = zram->meta;
+	unsigned long handle = meta->table[index].handle;
+	u16 size = meta->table[index].size;
 
-	user_mem = kmap_atomic(page);
-	cmem = kmap_atomic(zram->table[index].handle);
+	if (unlikely(!handle)) {
+		/*
+		 * No memory is allocated for zero filled pages.
+		 * Simply clear zero page flag.
+		 */
+		if (zram_test_flag(meta, index, ZRAM_ZERO)) {
+			zram_clear_flag(meta, index, ZRAM_ZERO);
+			zram->stats.pages_zero--;
+		}
+		return;
+	}
 
-	memcpy(user_mem + bvec->bv_offset, cmem + offset, bvec->bv_len);
-	kunmap_atomic(cmem);
-	kunmap_atomic(user_mem);
+	if (unlikely(size > max_zpage_size))
+		zram->stats.bad_compress--;
 
-	flush_dcache_page(page);
+	zs_free(meta->mem_pool, handle);
+
+	if (size <= PAGE_SIZE / 2)
+		zram->stats.good_compress--;
+
+	atomic64_sub(meta->table[index].size, &zram->stats.compr_size);
+	zram->stats.pages_stored--;
+
+	meta->table[index].handle = 0;
+	meta->table[index].size = 0;
 }
 
-static inline int is_partial_io(struct bio_vec *bvec)
+static int zram_decompress_page(struct zram *zram, char *mem, u32 index)
 {
-	return bvec->bv_len != PAGE_SIZE;
+	int ret = LZO_E_OK;
+	size_t clen = PAGE_SIZE;
+	unsigned char *cmem;
+	struct zram_meta *meta = zram->meta;
+	unsigned long handle = meta->table[index].handle;
+
+	if (!handle || zram_test_flag(meta, index, ZRAM_ZERO)) {
+		clear_page(mem);
+		return 0;
+	}
+
+	cmem = zs_map_object(meta->mem_pool, handle, ZS_MM_RO);
+	if (meta->table[index].size == PAGE_SIZE)
+		copy_page(mem, cmem);
+	else
+		ret = lzo1x_decompress_safe(cmem, meta->table[index].size,
+						mem, &clen);
+	zs_unmap_object(meta->mem_pool, handle);
+
+	/* Should NEVER happen. Return bio error if it does. */
+	if (unlikely(ret != LZO_E_OK)) {
+		pr_err("Decompression failed! err=%d, page=%u\n", ret, index);
+		atomic64_inc(&zram->stats.failed_reads);
+		return ret;
+	}
+
+	return 0;
 }
 
 static int zram_bvec_read(struct zram *zram, struct bio_vec *bvec,
 			  u32 index, int offset, struct bio *bio)
 {
 	int ret;
-	size_t clen;
 	struct page *page;
-	struct zobj_header *zheader;
-	unsigned char *user_mem, *cmem, *uncmem = NULL;
-
+	unsigned char *user_mem, *uncmem = NULL;
+	struct zram_meta *meta = zram->meta;
 	page = bvec->bv_page;
 
-	if (zram_test_flag(zram, index, ZRAM_ZERO)) {
+	if (unlikely(!meta->table[index].handle) ||
+			zram_test_flag(meta, index, ZRAM_ZERO)) {
 		handle_zero_page(bvec);
 		return 0;
 	}
 
-	/* Requested page is not present in compressed area */
-	if (unlikely(!zram->table[index].handle)) {
-		pr_debug("Read before write: sector=%lu, size=%u",
-			 (ulong)(bio->bi_sector), bio->bi_size);
-		handle_zero_page(bvec);
-		return 0;
-	}
-
-	/* Page is stored uncompressed since it's incompressible */
-	if (unlikely(zram_test_flag(zram, index, ZRAM_UNCOMPRESSED))) {
-		handle_uncompressed_page(zram, bvec, index, offset);
-		return 0;
-	}
-
-	if (is_partial_io(bvec)) {
+	if (is_partial_io(bvec))
 		/* Use  a temporary buffer to decompress the page */
-		uncmem = kmalloc(PAGE_SIZE, GFP_KERNEL);
-		if (!uncmem) {
-			pr_info("Error allocating temp memory!\n");
-			return -ENOMEM;
-		}
-	}
+		uncmem = kmalloc(PAGE_SIZE, GFP_NOIO);
 
 	user_mem = kmap_atomic(page);
 	if (!is_partial_io(bvec))
 		uncmem = user_mem;
-	clen = PAGE_SIZE;
 
-	cmem = zs_map_object(zram->mem_pool, zram->table[index].handle);
-
-	ret = lzo1x_decompress_safe(cmem + sizeof(*zheader),
-				    zram->table[index].size,
-				    uncmem, &clen);
-
-	if (is_partial_io(bvec)) {
-		memcpy(user_mem + bvec->bv_offset, uncmem + offset,
-		       bvec->bv_len);
-		kfree(uncmem);
+	if (!uncmem) {
+		pr_info("Unable to allocate temp memory\n");
+		ret = -ENOMEM;
+		goto out_cleanup;
 	}
 
-	zs_unmap_object(zram->mem_pool, zram->table[index].handle);
-	kunmap_atomic(user_mem);
-
+	ret = zram_decompress_page(zram, uncmem, index);
 	/* Should NEVER happen. Return bio error if it does. */
-	if (unlikely(ret != LZO_E_OK)) {
-		pr_err("Decompression failed! err=%d, page=%u\n", ret, index);
-		zram_stat64_inc(zram, &zram->stats.failed_reads);
-		return ret;
-	}
+	if (unlikely(ret != LZO_E_OK))
+		goto out_cleanup;
+
+	if (is_partial_io(bvec))
+		memcpy(user_mem + bvec->bv_offset, uncmem + offset,
+				bvec->bv_len);
 
 	flush_dcache_page(page);
-
-	return 0;
-}
-
-static int zram_read_before_write(struct zram *zram, char *mem, u32 index)
-{
-	int ret;
-	size_t clen = PAGE_SIZE;
-	struct zobj_header *zheader;
-	unsigned char *cmem;
-
-	if (zram_test_flag(zram, index, ZRAM_ZERO) ||
-	    !zram->table[index].handle) {
-		memset(mem, 0, PAGE_SIZE);
-		return 0;
-	}
-
-	cmem = zs_map_object(zram->mem_pool, zram->table[index].handle);
-
-	/* Page is stored uncompressed since it's incompressible */
-	if (unlikely(zram_test_flag(zram, index, ZRAM_UNCOMPRESSED))) {
-		memcpy(mem, cmem, PAGE_SIZE);
-		kunmap_atomic(cmem);
-		return 0;
-	}
-
-	ret = lzo1x_decompress_safe(cmem + sizeof(*zheader),
-				    zram->table[index].size,
-				    mem, &clen);
-	zs_unmap_object(zram->mem_pool, zram->table[index].handle);
-
-	/* Should NEVER happen. Return bio error if it does. */
-	if (unlikely(ret != LZO_E_OK)) {
-		pr_err("Decompression failed! err=%d, page=%u\n", ret, index);
-		zram_stat64_inc(zram, &zram->stats.failed_reads);
-		return ret;
-	}
-
-	return 0;
+	ret = 0;
+out_cleanup:
+	kunmap_atomic(user_mem);
+	if (is_partial_io(bvec))
+		kfree(uncmem);
+	return ret;
 }
 
 static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
 			   int offset)
 {
-	int ret;
-	u32 store_offset;
+	int ret = 0;
 	size_t clen;
-	void *handle;
-	struct zobj_header *zheader;
-	struct page *page, *page_store;
+	unsigned long handle;
+	struct page *page;
 	unsigned char *user_mem, *cmem, *src, *uncmem = NULL;
+	struct zram_meta *meta = zram->meta;
+	static unsigned long zram_rs_time;
 
 	page = bvec->bv_page;
-	src = zram->compress_buffer;
+	src = meta->compress_buffer;
 
 	if (is_partial_io(bvec)) {
 		/*
 		 * This is a partial IO. We need to read the full page
 		 * before to write the changes.
 		 */
-		uncmem = kmalloc(PAGE_SIZE, GFP_KERNEL);
+		uncmem = kmalloc(PAGE_SIZE, GFP_NOIO);
 		if (!uncmem) {
-			pr_info("Error allocating temp memory!\n");
 			ret = -ENOMEM;
 			goto out;
 		}
-		ret = zram_read_before_write(zram, uncmem, index);
-		if (ret) {
-			kfree(uncmem);
+		ret = zram_decompress_page(zram, uncmem, index);
+		if (ret)
 			goto out;
-		}
 	}
 
-	/*
-	 * System overwrites unused sectors. Free memory associated
-	 * with this sector now.
-	 */
-	if (zram->table[index].handle ||
-	    zram_test_flag(zram, index, ZRAM_ZERO))
-		zram_free_page(zram, index);
-
 	user_mem = kmap_atomic(page);
 
-	if (is_partial_io(bvec))
+	if (is_partial_io(bvec)) {
 		memcpy(uncmem + offset, user_mem + bvec->bv_offset,
 		       bvec->bv_len);
-	else
+		kunmap_atomic(user_mem);
+		user_mem = NULL;
+	} else {
 		uncmem = user_mem;
+	}
 
 	if (page_zero_filled(uncmem)) {
 		kunmap_atomic(user_mem);
-		if (is_partial_io(bvec))
-			kfree(uncmem);
-		zram_stat_inc(&zram->stats.pages_zero);
-		zram_set_flag(zram, index, ZRAM_ZERO);
+		/* Free memory associated with this sector now. */
+		zram_free_page(zram, index);
+
+		zram->stats.pages_zero++;
+		zram_set_flag(meta, index, ZRAM_ZERO);
 		ret = 0;
 		goto out;
 	}
 
-	ret = lzo1x_1_compress(uncmem, PAGE_SIZE, src, &clen,
-			       zram->compress_workmem);
+	/*
+	 * zram_slot_free_notify could miss free so that let's
+	 * double check.
+	 */
+	if (unlikely(meta->table[index].handle ||
+			zram_test_flag(meta, index, ZRAM_ZERO)))
+		zram_free_page(zram, index);
 
-	kunmap_atomic(user_mem);
-	if (is_partial_io(bvec))
-			kfree(uncmem);
+	ret = lzo1x_1_compress(uncmem, PAGE_SIZE, src, &clen,
+			       meta->compress_workmem);
+
+	if (!is_partial_io(bvec)) {
+		kunmap_atomic(user_mem);
+		user_mem = NULL;
+		uncmem = NULL;
+	}
 
 	if (unlikely(ret != LZO_E_OK)) {
 		pr_err("Compression failed! err=%d\n", ret);
 		goto out;
 	}
 
-	/*
-	 * Page is incompressible. Store it as-is (uncompressed)
-	 * since we do not want to return too many disk write
-	 * errors which has side effect of hanging the system.
-	 */
 	if (unlikely(clen > max_zpage_size)) {
+		zram->stats.bad_compress++;
 		clen = PAGE_SIZE;
-		page_store = alloc_page(GFP_NOIO | __GFP_HIGHMEM);
-		if (unlikely(!page_store)) {
-			pr_info("Error allocating memory for "
-				"incompressible page: %u\n", index);
-			ret = -ENOMEM;
-			goto out;
-		}
-
-		store_offset = 0;
-		zram_set_flag(zram, index, ZRAM_UNCOMPRESSED);
-		zram_stat_inc(&zram->stats.pages_expand);
-		handle = page_store;
-		src = kmap_atomic(page);
-		cmem = kmap_atomic(page_store);
-		goto memstore;
+		src = NULL;
+		if (is_partial_io(bvec))
+			src = uncmem;
 	}
 
-	handle = zs_malloc(zram->mem_pool, clen + sizeof(*zheader));
+	handle = zs_malloc(meta->mem_pool, clen);
 	if (!handle) {
-		pr_info("Error allocating memory for compressed "
-			"page: %u, size=%zu\n", index, clen);
+		if (printk_timed_ratelimit(&zram_rs_time,
+					   ALLOC_ERROR_LOG_RATE_MS))
+			pr_info("Error allocating memory for compressed page: %u, size=%zu\n",
+				index, clen);
 		ret = -ENOMEM;
 		goto out;
 	}
-	cmem = zs_map_object(zram->mem_pool, handle);
+	cmem = zs_map_object(meta->mem_pool, handle, ZS_MM_WO);
 
-memstore:
-#if 0
-	/* Back-reference needed for memory defragmentation */
-	if (!zram_test_flag(zram, index, ZRAM_UNCOMPRESSED)) {
-		zheader = (struct zobj_header *)cmem;
-		zheader->table_idx = index;
-		cmem += sizeof(*zheader);
-	}
-#endif
-
-	memcpy(cmem, src, clen);
-
-	if (unlikely(zram_test_flag(zram, index, ZRAM_UNCOMPRESSED))) {
-		kunmap_atomic(cmem);
+	if ((clen == PAGE_SIZE) && !is_partial_io(bvec)) {
+		src = kmap_atomic(page);
+		copy_page(cmem, src);
 		kunmap_atomic(src);
 	} else {
-		zs_unmap_object(zram->mem_pool, handle);
+		memcpy(cmem, src, clen);
 	}
 
-	zram->table[index].handle = handle;
-	zram->table[index].size = clen;
+	zs_unmap_object(meta->mem_pool, handle);
+
+	/*
+	 * Free memory associated with this sector
+	 * before overwriting unused sectors.
+	 */
+	zram_free_page(zram, index);
+
+	meta->table[index].handle = handle;
+	meta->table[index].size = clen;
 
 	/* Update stats */
-	zram_stat64_add(zram, &zram->stats.compr_size, clen);
-	zram_stat_inc(&zram->stats.pages_stored);
+	atomic64_add(clen, &zram->stats.compr_size);
+	zram->stats.pages_stored++;
 	if (clen <= PAGE_SIZE / 2)
-		zram_stat_inc(&zram->stats.good_compress);
-
-	return 0;
+		zram->stats.good_compress++;
 
 out:
+	if (is_partial_io(bvec))
+		kfree(uncmem);
+
 	if (ret)
-		zram_stat64_inc(zram, &zram->stats.failed_writes);
+		atomic64_inc(&zram->stats.failed_writes);
 	return ret;
 }
 
+static void handle_pending_slot_free(struct zram *zram)
+{
+	struct zram_slot_free *free_rq;
+
+	spin_lock(&zram->slot_free_lock);
+	while (zram->slot_free_rq) {
+		free_rq = zram->slot_free_rq;
+		zram->slot_free_rq = free_rq->next;
+		zram_free_page(zram, free_rq->index);
+		kfree(free_rq);
+	}
+	spin_unlock(&zram->slot_free_lock);
+}
+
 static int zram_bvec_rw(struct zram *zram, struct bio_vec *bvec, u32 index,
 			int offset, struct bio *bio, int rw)
 {
@@ -457,10 +545,12 @@
 
 	if (rw == READ) {
 		down_read(&zram->lock);
+		handle_pending_slot_free(zram);
 		ret = zram_bvec_read(zram, bvec, index, offset, bio);
 		up_read(&zram->lock);
 	} else {
 		down_write(&zram->lock);
+		handle_pending_slot_free(zram);
 		ret = zram_bvec_write(zram, bvec, index, offset);
 		up_write(&zram->lock);
 	}
@@ -468,11 +558,124 @@
 	return ret;
 }
 
-static void update_position(u32 *index, int *offset, struct bio_vec *bvec)
+static void zram_reset_device(struct zram *zram, bool reset_capacity)
 {
-	if (*offset + bvec->bv_len >= PAGE_SIZE)
-		(*index)++;
-	*offset = (*offset + bvec->bv_len) % PAGE_SIZE;
+	size_t index;
+	struct zram_meta *meta;
+
+	flush_work(&zram->free_work);
+
+	down_write(&zram->init_lock);
+	if (!zram->init_done) {
+		up_write(&zram->init_lock);
+		return;
+	}
+
+	meta = zram->meta;
+	zram->init_done = 0;
+
+	/* Free all pages that are still in this zram device */
+	for (index = 0; index < zram->disksize >> PAGE_SHIFT; index++) {
+		unsigned long handle = meta->table[index].handle;
+		if (!handle)
+			continue;
+
+		zs_free(meta->mem_pool, handle);
+	}
+
+	zram_meta_free(zram->meta);
+	zram->meta = NULL;
+	/* Reset stats */
+	memset(&zram->stats, 0, sizeof(zram->stats));
+
+	zram->disksize = 0;
+	if (reset_capacity)
+		set_capacity(zram->disk, 0);
+	up_write(&zram->init_lock);
+}
+
+static void zram_init_device(struct zram *zram, struct zram_meta *meta)
+{
+	if (zram->disksize > 2 * (totalram_pages << PAGE_SHIFT)) {
+		pr_info(
+		"There is little point creating a zram of greater than "
+		"twice the size of memory since we expect a 2:1 compression "
+		"ratio. Note that zram uses about 0.1%% of the size of "
+		"the disk when not in use so a huge zram is "
+		"wasteful.\n"
+		"\tMemory Size: %lu kB\n"
+		"\tSize you selected: %llu kB\n"
+		"Continuing anyway ...\n",
+		(totalram_pages << PAGE_SHIFT) >> 10, zram->disksize >> 10
+		);
+	}
+
+	/* zram devices sort of resembles non-rotational disks */
+	queue_flag_set_unlocked(QUEUE_FLAG_NONROT, zram->disk->queue);
+
+	zram->meta = meta;
+	zram->init_done = 1;
+
+	pr_debug("Initialization done!\n");
+}
+
+static ssize_t disksize_store(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t len)
+{
+	u64 disksize;
+	struct zram_meta *meta;
+	struct zram *zram = dev_to_zram(dev);
+
+	disksize = memparse(buf, NULL);
+	if (!disksize)
+		return -EINVAL;
+
+	disksize = PAGE_ALIGN(disksize);
+	meta = zram_meta_alloc(disksize);
+	down_write(&zram->init_lock);
+	if (zram->init_done) {
+		up_write(&zram->init_lock);
+		zram_meta_free(meta);
+		pr_info("Cannot change disksize for initialized device\n");
+		return -EBUSY;
+	}
+
+	zram->disksize = disksize;
+	set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT);
+	zram_init_device(zram, meta);
+	up_write(&zram->init_lock);
+
+	return len;
+}
+
+static ssize_t reset_store(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t len)
+{
+	int ret;
+	unsigned short do_reset;
+	struct zram *zram;
+	struct block_device *bdev;
+
+	zram = dev_to_zram(dev);
+	bdev = bdget_disk(zram->disk, 0);
+
+	/* Do not reset an active device! */
+	if (bdev->bd_holders)
+		return -EBUSY;
+
+	ret = kstrtou16(buf, 10, &do_reset);
+	if (ret)
+		return ret;
+
+	if (!do_reset)
+		return -EINVAL;
+
+	/* Make sure all pending I/O is finished */
+	if (bdev)
+		fsync_bdev(bdev);
+
+	zram_reset_device(zram, true);
+	return len;
 }
 
 static void __zram_make_request(struct zram *zram, struct bio *bio, int rw)
@@ -483,10 +686,10 @@
 
 	switch (rw) {
 	case READ:
-		zram_stat64_inc(zram, &zram->stats.num_reads);
+		atomic64_inc(&zram->stats.num_reads);
 		break;
 	case WRITE:
-		zram_stat64_inc(zram, &zram->stats.num_writes);
+		atomic64_inc(&zram->stats.num_writes);
 		break;
 	}
 
@@ -531,39 +734,19 @@
 }
 
 /*
- * Check if request is within bounds and aligned on zram logical blocks.
- */
-static inline int valid_io_request(struct zram *zram, struct bio *bio)
-{
-	if (unlikely(
-		(bio->bi_sector >= (zram->disksize >> SECTOR_SHIFT)) ||
-		(bio->bi_sector & (ZRAM_SECTOR_PER_LOGICAL_BLOCK - 1)) ||
-		(bio->bi_size & (ZRAM_LOGICAL_BLOCK_SIZE - 1)))) {
-
-		return 0;
-	}
-
-	/* I/O request is valid */
-	return 1;
-}
-
-/*
  * Handler function for all zram I/O requests.
  */
 static void zram_make_request(struct request_queue *queue, struct bio *bio)
 {
 	struct zram *zram = queue->queuedata;
 
-	if (unlikely(!zram->init_done) && zram_init_device(zram))
-		goto error;
-
 	down_read(&zram->init_lock);
 	if (unlikely(!zram->init_done))
-		goto error_unlock;
+		goto error;
 
 	if (!valid_io_request(zram, bio)) {
-		zram_stat64_inc(zram, &zram->stats.invalid_io);
-		goto error_unlock;
+		atomic64_inc(&zram->stats.invalid_io);
+		goto error;
 	}
 
 	__zram_make_request(zram, bio, bio_data_dir(bio));
@@ -571,129 +754,45 @@
 
 	return;
 
-error_unlock:
-	up_read(&zram->init_lock);
 error:
+	up_read(&zram->init_lock);
 	bio_io_error(bio);
 }
 
-void __zram_reset_device(struct zram *zram)
+static void zram_slot_free(struct work_struct *work)
 {
-	size_t index;
+	struct zram *zram;
 
-	zram->init_done = 0;
-
-	/* Free various per-device buffers */
-	kfree(zram->compress_workmem);
-	free_pages((unsigned long)zram->compress_buffer, 1);
-
-	zram->compress_workmem = NULL;
-	zram->compress_buffer = NULL;
-
-	/* Free all pages that are still in this zram device */
-	for (index = 0; index < zram->disksize >> PAGE_SHIFT; index++) {
-		void *handle = zram->table[index].handle;
-		if (!handle)
-			continue;
-
-		if (unlikely(zram_test_flag(zram, index, ZRAM_UNCOMPRESSED)))
-			__free_page(handle);
-		else
-			zs_free(zram->mem_pool, handle);
-	}
-
-	vfree(zram->table);
-	zram->table = NULL;
-
-	zs_destroy_pool(zram->mem_pool);
-	zram->mem_pool = NULL;
-
-	/* Reset stats */
-	memset(&zram->stats, 0, sizeof(zram->stats));
-
-	zram->disksize = 0;
+	zram = container_of(work, struct zram, free_work);
+	down_write(&zram->lock);
+	handle_pending_slot_free(zram);
+	up_write(&zram->lock);
 }
 
-void zram_reset_device(struct zram *zram)
+static void add_slot_free(struct zram *zram, struct zram_slot_free *free_rq)
 {
-	down_write(&zram->init_lock);
-	__zram_reset_device(zram);
-	up_write(&zram->init_lock);
-}
-
-int zram_init_device(struct zram *zram)
-{
-	int ret;
-	size_t num_pages;
-
-	down_write(&zram->init_lock);
-
-	if (zram->init_done) {
-		up_write(&zram->init_lock);
-		return 0;
-	}
-
-	zram_set_disksize(zram, totalram_pages << PAGE_SHIFT);
-
-	zram->compress_workmem = kzalloc(LZO1X_MEM_COMPRESS, GFP_KERNEL);
-	if (!zram->compress_workmem) {
-		pr_err("Error allocating compressor working memory!\n");
-		ret = -ENOMEM;
-		goto fail_no_table;
-	}
-
-	zram->compress_buffer =
-		(void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, 1);
-	if (!zram->compress_buffer) {
-		pr_err("Error allocating compressor buffer space\n");
-		ret = -ENOMEM;
-		goto fail_no_table;
-	}
-
-	num_pages = zram->disksize >> PAGE_SHIFT;
-	zram->table = vzalloc(num_pages * sizeof(*zram->table));
-	if (!zram->table) {
-		pr_err("Error allocating zram address table\n");
-		ret = -ENOMEM;
-		goto fail_no_table;
-	}
-
-	set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT);
-
-	/* zram devices sort of resembles non-rotational disks */
-	queue_flag_set_unlocked(QUEUE_FLAG_NONROT, zram->disk->queue);
-
-	zram->mem_pool = zs_create_pool("zram", GFP_NOIO | __GFP_HIGHMEM);
-	if (!zram->mem_pool) {
-		pr_err("Error creating memory pool\n");
-		ret = -ENOMEM;
-		goto fail;
-	}
-
-	zram->init_done = 1;
-	up_write(&zram->init_lock);
-
-	pr_debug("Initialization done!\n");
-	return 0;
-
-fail_no_table:
-	/* To prevent accessing table entries during cleanup */
-	zram->disksize = 0;
-fail:
-	__zram_reset_device(zram);
-	up_write(&zram->init_lock);
-	pr_err("Initialization failed: err=%d\n", ret);
-	return ret;
+	spin_lock(&zram->slot_free_lock);
+	free_rq->next = zram->slot_free_rq;
+	zram->slot_free_rq = free_rq;
+	spin_unlock(&zram->slot_free_lock);
 }
 
 static void zram_slot_free_notify(struct block_device *bdev,
 				unsigned long index)
 {
 	struct zram *zram;
+	struct zram_slot_free *free_rq;
 
 	zram = bdev->bd_disk->private_data;
-	zram_free_page(zram, index);
-	zram_stat64_inc(zram, &zram->stats.notify_free);
+	atomic64_inc(&zram->stats.notify_free);
+
+	free_rq = kmalloc(sizeof(struct zram_slot_free), GFP_ATOMIC);
+	if (!free_rq)
+		return;
+
+	free_rq->index = index;
+	add_slot_free(zram, free_rq);
+	schedule_work(&zram->free_work);
 }
 
 static const struct block_device_operations zram_devops = {
@@ -701,19 +800,53 @@
 	.owner = THIS_MODULE
 };
 
+static DEVICE_ATTR(disksize, S_IRUGO | S_IWUSR,
+		disksize_show, disksize_store);
+static DEVICE_ATTR(initstate, S_IRUGO, initstate_show, NULL);
+static DEVICE_ATTR(reset, S_IWUSR, NULL, reset_store);
+static DEVICE_ATTR(num_reads, S_IRUGO, num_reads_show, NULL);
+static DEVICE_ATTR(num_writes, S_IRUGO, num_writes_show, NULL);
+static DEVICE_ATTR(invalid_io, S_IRUGO, invalid_io_show, NULL);
+static DEVICE_ATTR(notify_free, S_IRUGO, notify_free_show, NULL);
+static DEVICE_ATTR(zero_pages, S_IRUGO, zero_pages_show, NULL);
+static DEVICE_ATTR(orig_data_size, S_IRUGO, orig_data_size_show, NULL);
+static DEVICE_ATTR(compr_data_size, S_IRUGO, compr_data_size_show, NULL);
+static DEVICE_ATTR(mem_used_total, S_IRUGO, mem_used_total_show, NULL);
+
+static struct attribute *zram_disk_attrs[] = {
+	&dev_attr_disksize.attr,
+	&dev_attr_initstate.attr,
+	&dev_attr_reset.attr,
+	&dev_attr_num_reads.attr,
+	&dev_attr_num_writes.attr,
+	&dev_attr_invalid_io.attr,
+	&dev_attr_notify_free.attr,
+	&dev_attr_zero_pages.attr,
+	&dev_attr_orig_data_size.attr,
+	&dev_attr_compr_data_size.attr,
+	&dev_attr_mem_used_total.attr,
+	NULL,
+};
+
+static struct attribute_group zram_disk_attr_group = {
+	.attrs = zram_disk_attrs,
+};
+
 static int create_device(struct zram *zram, int device_id)
 {
-	int ret = 0;
+	int ret = -ENOMEM;
 
 	init_rwsem(&zram->lock);
 	init_rwsem(&zram->init_lock);
-	spin_lock_init(&zram->stat64_lock);
+
+	INIT_WORK(&zram->free_work, zram_slot_free);
+	spin_lock_init(&zram->slot_free_lock);
+	zram->slot_free_rq = NULL;
 
 	zram->queue = blk_alloc_queue(GFP_KERNEL);
 	if (!zram->queue) {
 		pr_err("Error allocating disk queue for device %d\n",
 			device_id);
-		ret = -ENOMEM;
 		goto out;
 	}
 
@@ -723,11 +856,9 @@
 	 /* gendisk structure */
 	zram->disk = alloc_disk(1);
 	if (!zram->disk) {
-		blk_cleanup_queue(zram->queue);
-		pr_warning("Error allocating disk structure for device %d\n",
+		pr_warn("Error allocating disk structure for device %d\n",
 			device_id);
-		ret = -ENOMEM;
-		goto out;
+		goto out_free_queue;
 	}
 
 	zram->disk->major = zram_major;
@@ -755,12 +886,18 @@
 	ret = sysfs_create_group(&disk_to_dev(zram->disk)->kobj,
 				&zram_disk_attr_group);
 	if (ret < 0) {
-		pr_warning("Error creating sysfs group");
-		goto out;
+		pr_warn("Error creating sysfs group");
+		goto out_free_disk;
 	}
 
 	zram->init_done = 0;
+	return 0;
 
+out_free_disk:
+	del_gendisk(zram->disk);
+	put_disk(zram->disk);
+out_free_queue:
+	blk_cleanup_queue(zram->queue);
 out:
 	return ret;
 }
@@ -779,17 +916,12 @@
 		blk_cleanup_queue(zram->queue);
 }
 
-unsigned int zram_get_num_devices(void)
-{
-	return num_devices;
-}
-
 static int __init zram_init(void)
 {
 	int ret, dev_id;
 
 	if (num_devices > max_num_devices) {
-		pr_warning("Invalid value for num_devices: %u\n",
+		pr_warn("Invalid value for num_devices: %u\n",
 				num_devices);
 		ret = -EINVAL;
 		goto out;
@@ -797,18 +929,12 @@
 
 	zram_major = register_blkdev(0, "zram");
 	if (zram_major <= 0) {
-		pr_warning("Unable to get major number\n");
+		pr_warn("Unable to get major number\n");
 		ret = -EBUSY;
 		goto out;
 	}
 
-	if (!num_devices) {
-		pr_info("num_devices not specified. Using default: 1\n");
-		num_devices = 1;
-	}
-
 	/* Allocate the device array and initialize each one */
-	pr_info("Creating %u devices ...\n", num_devices);
 	zram_devices = kzalloc(num_devices * sizeof(struct zram), GFP_KERNEL);
 	if (!zram_devices) {
 		ret = -ENOMEM;
@@ -821,6 +947,8 @@
 			goto free_devices;
 	}
 
+	pr_info("Created %u device(s) ...\n", num_devices);
+
 	return 0;
 
 free_devices:
@@ -842,8 +970,11 @@
 		zram = &zram_devices[i];
 
 		destroy_device(zram);
-		if (zram->init_done)
-			zram_reset_device(zram);
+		/*
+		 * Shouldn't access zram->disk after destroy_device
+		 * because destroy_device already released zram->disk.
+		 */
+		zram_reset_device(zram, false);
 	}
 
 	unregister_blkdev(zram_major, "zram");
@@ -852,12 +983,13 @@
 	pr_debug("Cleanup done!\n");
 }
 
-module_param(num_devices, uint, 0);
-MODULE_PARM_DESC(num_devices, "Number of zram devices");
-
 module_init(zram_init);
 module_exit(zram_exit);
 
+module_param(num_devices, uint, 0);
+MODULE_PARM_DESC(num_devices, "Number of zram devices");
+
 MODULE_LICENSE("Dual BSD/GPL");
 MODULE_AUTHOR("Nitin Gupta <ngupta@vflare.org>");
 MODULE_DESCRIPTION("Compressed RAM Block Device");
+MODULE_ALIAS("devname:zram");
diff --git a/drivers/staging/zram/zram_drv.h b/drivers/staging/zram/zram_drv.h
index fbe8ac9..508a19f 100644
--- a/drivers/staging/zram/zram_drv.h
+++ b/drivers/staging/zram/zram_drv.h
@@ -26,33 +26,18 @@
  */
 static const unsigned max_num_devices = 32;
 
-/*
- * Stored at beginning of each compressed object.
- *
- * It stores back-reference to table entry which points to this
- * object. This is required to support memory defragmentation.
- */
-struct zobj_header {
-#if 0
-	u32 table_idx;
-#endif
-};
-
 /*-- Configurable parameters */
 
-/* Default zram disk size: 25% of total RAM */
-static const unsigned default_disksize_perc_ram = 25;
-
 /*
  * Pages that compress to size greater than this are stored
  * uncompressed in memory.
  */
-static const size_t max_zpage_size = PAGE_SIZE / 4 * 3;
+static const size_t max_zpage_size = PAGE_SIZE / 10 * 9;
 
 /*
  * NOTE: max_zpage_size must be less than or equal to:
- *   ZS_MAX_ALLOC_SIZE - sizeof(struct zobj_header)
- * otherwise, xv_malloc() would always return failure.
+ *   ZS_MAX_ALLOC_SIZE. Otherwise, zs_malloc() would
+ * always return failure.
  */
 
 /*-- End of configurable params */
@@ -68,9 +53,6 @@
 
 /* Flags for zram pages (table[page_no].flags) */
 enum zram_pageflags {
-	/* Page is stored uncompressed */
-	ZRAM_UNCOMPRESSED,
-
 	/* Page consists entirely of zeros */
 	ZRAM_ZERO,
 
@@ -81,34 +63,51 @@
 
 /* Allocated for each disk page */
 struct table {
-	void *handle;
+	unsigned long handle;
 	u16 size;	/* object size (excluding header) */
 	u8 count;	/* object ref count (not yet used) */
 	u8 flags;
-} __attribute__((aligned(4)));
+} __aligned(4);
 
+/*
+ * All 64bit fields should only be manipulated by 64bit atomic accessors.
+ * All modifications to 32bit counter should be protected by zram->lock.
+ */
 struct zram_stats {
-	u64 compr_size;		/* compressed size of pages stored */
-	u64 num_reads;		/* failed + successful */
-	u64 num_writes;		/* --do-- */
-	u64 failed_reads;	/* should NEVER! happen */
-	u64 failed_writes;	/* can happen when memory is too low */
-	u64 invalid_io;		/* non-page-aligned I/O requests */
-	u64 notify_free;	/* no. of swap slot free notifications */
+	atomic64_t compr_size;	/* compressed size of pages stored */
+	atomic64_t num_reads;	/* failed + successful */
+	atomic64_t num_writes;	/* --do-- */
+	atomic64_t failed_reads;	/* should NEVER! happen */
+	atomic64_t failed_writes;	/* can happen when memory is too low */
+	atomic64_t invalid_io;	/* non-page-aligned I/O requests */
+	atomic64_t notify_free;	/* no. of swap slot free notifications */
 	u32 pages_zero;		/* no. of zero filled pages */
 	u32 pages_stored;	/* no. of pages currently stored */
 	u32 good_compress;	/* % of pages with compression ratio<=50% */
-	u32 pages_expand;	/* % of incompressible pages */
+	u32 bad_compress;	/* % of pages with compression ratio>=75% */
 };
 
-struct zram {
-	struct zs_pool *mem_pool;
+struct zram_meta {
 	void *compress_workmem;
 	void *compress_buffer;
 	struct table *table;
-	spinlock_t stat64_lock;	/* protect 64-bit stats */
-	struct rw_semaphore lock; /* protect compression buffers and table
-				   * against concurrent read and writes */
+	struct zs_pool *mem_pool;
+};
+
+struct zram_slot_free {
+	unsigned long index;
+	struct zram_slot_free *next;
+};
+
+struct zram {
+	struct zram_meta *meta;
+	struct rw_semaphore lock; /* protect compression buffers, table,
+				   * 32bit stat counters against concurrent
+				   * notifications, reads and writes */
+
+	struct work_struct free_work;  /* handle pending free request */
+	struct zram_slot_free *slot_free_rq; /* list head of free request */
+
 	struct request_queue *queue;
 	struct gendisk *disk;
 	int init_done;
@@ -119,17 +118,8 @@
 	 * we can store in a disk.
 	 */
 	u64 disksize;	/* bytes */
+	spinlock_t slot_free_lock;
 
 	struct zram_stats stats;
 };
-
-extern struct zram *zram_devices;
-unsigned int zram_get_num_devices(void);
-#ifdef CONFIG_SYSFS
-extern struct attribute_group zram_disk_attr_group;
-#endif
-
-extern int zram_init_device(struct zram *zram);
-extern void __zram_reset_device(struct zram *zram);
-
 #endif
diff --git a/drivers/staging/zram/zram_sysfs.c b/drivers/staging/zram/zram_sysfs.c
deleted file mode 100644
index a7f3771..0000000
--- a/drivers/staging/zram/zram_sysfs.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Compressed RAM block device
- *
- * Copyright (C) 2008, 2009, 2010  Nitin Gupta
- *
- * This code is released using a dual license strategy: BSD/GPL
- * You can choose the licence that better fits your requirements.
- *
- * Released under the terms of 3-clause BSD License
- * Released under the terms of GNU General Public License Version 2.0
- *
- * Project home: http://compcache.googlecode.com/
- */
-
-#include <linux/device.h>
-#include <linux/genhd.h>
-#include <linux/mm.h>
-
-#include "zram_drv.h"
-
-static u64 zram_stat64_read(struct zram *zram, u64 *v)
-{
-	u64 val;
-
-	spin_lock(&zram->stat64_lock);
-	val = *v;
-	spin_unlock(&zram->stat64_lock);
-
-	return val;
-}
-
-static struct zram *dev_to_zram(struct device *dev)
-{
-	int i;
-	struct zram *zram = NULL;
-
-	for (i = 0; i < zram_get_num_devices(); i++) {
-		zram = &zram_devices[i];
-		if (disk_to_dev(zram->disk) == dev)
-			break;
-	}
-
-	return zram;
-}
-
-static ssize_t disksize_show(struct device *dev,
-		struct device_attribute *attr, char *buf)
-{
-	struct zram *zram = dev_to_zram(dev);
-
-	return sprintf(buf, "%llu\n", zram->disksize);
-}
-
-static ssize_t disksize_store(struct device *dev,
-		struct device_attribute *attr, const char *buf, size_t len)
-{
-	int ret;
-	u64 disksize;
-	struct zram *zram = dev_to_zram(dev);
-
-	ret = kstrtoull(buf, 10, &disksize);
-	if (ret)
-		return ret;
-
-	down_write(&zram->init_lock);
-	if (zram->init_done) {
-		up_write(&zram->init_lock);
-		pr_info("Cannot change disksize for initialized device\n");
-		return -EBUSY;
-	}
-
-	zram->disksize = PAGE_ALIGN(disksize);
-	set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT);
-	up_write(&zram->init_lock);
-
-	return len;
-}
-
-static ssize_t initstate_show(struct device *dev,
-		struct device_attribute *attr, char *buf)
-{
-	struct zram *zram = dev_to_zram(dev);
-
-	return sprintf(buf, "%u\n", zram->init_done);
-}
-
-static ssize_t reset_store(struct device *dev,
-		struct device_attribute *attr, const char *buf, size_t len)
-{
-	int ret;
-	unsigned short do_reset;
-	struct zram *zram;
-	struct block_device *bdev;
-
-	zram = dev_to_zram(dev);
-	bdev = bdget_disk(zram->disk, 0);
-
-	/* Do not reset an active device! */
-	if (bdev->bd_holders)
-		return -EBUSY;
-
-	ret = kstrtou16(buf, 10, &do_reset);
-	if (ret)
-		return ret;
-
-	if (!do_reset)
-		return -EINVAL;
-
-	/* Make sure all pending I/O is finished */
-	if (bdev)
-		fsync_bdev(bdev);
-
-	down_write(&zram->init_lock);
-	if (zram->init_done)
-		__zram_reset_device(zram);
-	up_write(&zram->init_lock);
-
-	return len;
-}
-
-static ssize_t num_reads_show(struct device *dev,
-		struct device_attribute *attr, char *buf)
-{
-	struct zram *zram = dev_to_zram(dev);
-
-	return sprintf(buf, "%llu\n",
-		zram_stat64_read(zram, &zram->stats.num_reads));
-}
-
-static ssize_t num_writes_show(struct device *dev,
-		struct device_attribute *attr, char *buf)
-{
-	struct zram *zram = dev_to_zram(dev);
-
-	return sprintf(buf, "%llu\n",
-		zram_stat64_read(zram, &zram->stats.num_writes));
-}
-
-static ssize_t invalid_io_show(struct device *dev,
-		struct device_attribute *attr, char *buf)
-{
-	struct zram *zram = dev_to_zram(dev);
-
-	return sprintf(buf, "%llu\n",
-		zram_stat64_read(zram, &zram->stats.invalid_io));
-}
-
-static ssize_t notify_free_show(struct device *dev,
-		struct device_attribute *attr, char *buf)
-{
-	struct zram *zram = dev_to_zram(dev);
-
-	return sprintf(buf, "%llu\n",
-		zram_stat64_read(zram, &zram->stats.notify_free));
-}
-
-static ssize_t zero_pages_show(struct device *dev,
-		struct device_attribute *attr, char *buf)
-{
-	struct zram *zram = dev_to_zram(dev);
-
-	return sprintf(buf, "%u\n", zram->stats.pages_zero);
-}
-
-static ssize_t orig_data_size_show(struct device *dev,
-		struct device_attribute *attr, char *buf)
-{
-	struct zram *zram = dev_to_zram(dev);
-
-	return sprintf(buf, "%llu\n",
-		(u64)(zram->stats.pages_stored) << PAGE_SHIFT);
-}
-
-static ssize_t compr_data_size_show(struct device *dev,
-		struct device_attribute *attr, char *buf)
-{
-	struct zram *zram = dev_to_zram(dev);
-
-	return sprintf(buf, "%llu\n",
-		zram_stat64_read(zram, &zram->stats.compr_size));
-}
-
-static ssize_t mem_used_total_show(struct device *dev,
-		struct device_attribute *attr, char *buf)
-{
-	u64 val = 0;
-	struct zram *zram = dev_to_zram(dev);
-
-	if (zram->init_done) {
-		val = zs_get_total_size_bytes(zram->mem_pool) +
-			((u64)(zram->stats.pages_expand) << PAGE_SHIFT);
-	}
-
-	return sprintf(buf, "%llu\n", val);
-}
-
-static DEVICE_ATTR(disksize, S_IRUGO | S_IWUSR,
-		disksize_show, disksize_store);
-static DEVICE_ATTR(initstate, S_IRUGO, initstate_show, NULL);
-static DEVICE_ATTR(reset, S_IWUSR, NULL, reset_store);
-static DEVICE_ATTR(num_reads, S_IRUGO, num_reads_show, NULL);
-static DEVICE_ATTR(num_writes, S_IRUGO, num_writes_show, NULL);
-static DEVICE_ATTR(invalid_io, S_IRUGO, invalid_io_show, NULL);
-static DEVICE_ATTR(notify_free, S_IRUGO, notify_free_show, NULL);
-static DEVICE_ATTR(zero_pages, S_IRUGO, zero_pages_show, NULL);
-static DEVICE_ATTR(orig_data_size, S_IRUGO, orig_data_size_show, NULL);
-static DEVICE_ATTR(compr_data_size, S_IRUGO, compr_data_size_show, NULL);
-static DEVICE_ATTR(mem_used_total, S_IRUGO, mem_used_total_show, NULL);
-
-static struct attribute *zram_disk_attrs[] = {
-	&dev_attr_disksize.attr,
-	&dev_attr_initstate.attr,
-	&dev_attr_reset.attr,
-	&dev_attr_num_reads.attr,
-	&dev_attr_num_writes.attr,
-	&dev_attr_invalid_io.attr,
-	&dev_attr_notify_free.attr,
-	&dev_attr_zero_pages.attr,
-	&dev_attr_orig_data_size.attr,
-	&dev_attr_compr_data_size.attr,
-	&dev_attr_mem_used_total.attr,
-	NULL,
-};
-
-struct attribute_group zram_disk_attr_group = {
-	.attrs = zram_disk_attrs,
-};
diff --git a/drivers/staging/zsmalloc/Kconfig b/drivers/staging/zsmalloc/Kconfig
index a5ab720..7fab032 100644
--- a/drivers/staging/zsmalloc/Kconfig
+++ b/drivers/staging/zsmalloc/Kconfig
@@ -1,9 +1,5 @@
 config ZSMALLOC
-	tristate "Memory allocator for compressed pages"
-	# X86 dependency is because of the use of __flush_tlb_one and set_pte
-	# in zsmalloc-main.c.
-	# TODO: convert these to portable functions
-	depends on X86
+	bool "Memory allocator for compressed pages"
 	default n
 	help
 	  zsmalloc is a slab-based memory allocator designed to store
diff --git a/drivers/staging/zsmalloc/zsmalloc-main.c b/drivers/staging/zsmalloc/zsmalloc-main.c
index 917461c..523b937 100644
--- a/drivers/staging/zsmalloc/zsmalloc-main.c
+++ b/drivers/staging/zsmalloc/zsmalloc-main.c
@@ -10,6 +10,54 @@
  * Released under the terms of GNU General Public License Version 2.0
  */
 
+
+/*
+ * This allocator is designed for use with zcache and zram. Thus, the
+ * allocator is supposed to work well under low memory conditions. In
+ * particular, it never attempts higher order page allocation which is
+ * very likely to fail under memory pressure. On the other hand, if we
+ * just use single (0-order) pages, it would suffer from very high
+ * fragmentation -- any object of size PAGE_SIZE/2 or larger would occupy
+ * an entire page. This was one of the major issues with its predecessor
+ * (xvmalloc).
+ *
+ * To overcome these issues, zsmalloc allocates a bunch of 0-order pages
+ * and links them together using various 'struct page' fields. These linked
+ * pages act as a single higher-order page i.e. an object can span 0-order
+ * page boundaries. The code refers to these linked pages as a single entity
+ * called zspage.
+ *
+ * Following is how we use various fields and flags of underlying
+ * struct page(s) to form a zspage.
+ *
+ * Usage of struct page fields:
+ *	page->first_page: points to the first component (0-order) page
+ *	page->index (union with page->freelist): offset of the first object
+ *		starting in this page. For the first page, this is
+ *		always 0, so we use this field (aka freelist) to point
+ *		to the first free object in zspage.
+ *	page->lru: links together all component pages (except the first page)
+ *		of a zspage
+ *
+ *	For _first_ page only:
+ *
+ *	page->private (union with page->first_page): refers to the
+ *		component page after the first page
+ *	page->freelist: points to the first free object in zspage.
+ *		Free objects are linked together using in-place
+ *		metadata.
+ *	page->objects: maximum number of objects we can store in this
+ *		zspage (class->zspage_order * PAGE_SIZE / class->size)
+ *	page->lru: links together first pages of various zspages.
+ *		Basically forming list of zspages in a fullness group.
+ *	page->mapping: class index and fullness group of the zspage
+ *
+ * Usage of struct page flags:
+ *	PG_private: identifies the first component page
+ *	PG_private2: identifies the last component page
+ *
+ */
+
 #ifdef CONFIG_ZSMALLOC_DEBUG
 #define DEBUG
 #endif
@@ -27,9 +75,139 @@
 #include <linux/cpumask.h>
 #include <linux/cpu.h>
 #include <linux/vmalloc.h>
+#include <linux/hardirq.h>
+#include <linux/spinlock.h>
+#include <linux/types.h>
 
 #include "zsmalloc.h"
-#include "zsmalloc_int.h"
+
+/*
+ * This must be power of 2 and greater than of equal to sizeof(link_free).
+ * These two conditions ensure that any 'struct link_free' itself doesn't
+ * span more than 1 page which avoids complex case of mapping 2 pages simply
+ * to restore link_free pointer values.
+ */
+#define ZS_ALIGN		8
+
+/*
+ * A single 'zspage' is composed of up to 2^N discontiguous 0-order (single)
+ * pages. ZS_MAX_ZSPAGE_ORDER defines upper limit on N.
+ */
+#define ZS_MAX_ZSPAGE_ORDER 2
+#define ZS_MAX_PAGES_PER_ZSPAGE (_AC(1, UL) << ZS_MAX_ZSPAGE_ORDER)
+
+/*
+ * Object location (<PFN>, <obj_idx>) is encoded as
+ * as single (void *) handle value.
+ *
+ * Note that object index <obj_idx> is relative to system
+ * page <PFN> it is stored in, so for each sub-page belonging
+ * to a zspage, obj_idx starts with 0.
+ *
+ * This is made more complicated by various memory models and PAE.
+ */
+
+#ifndef MAX_PHYSMEM_BITS
+#ifdef CONFIG_HIGHMEM64G
+#define MAX_PHYSMEM_BITS 36
+#else /* !CONFIG_HIGHMEM64G */
+/*
+ * If this definition of MAX_PHYSMEM_BITS is used, OBJ_INDEX_BITS will just
+ * be PAGE_SHIFT
+ */
+#define MAX_PHYSMEM_BITS BITS_PER_LONG
+#endif
+#endif
+#define _PFN_BITS		(MAX_PHYSMEM_BITS - PAGE_SHIFT)
+#define OBJ_INDEX_BITS	(BITS_PER_LONG - _PFN_BITS)
+#define OBJ_INDEX_MASK	((_AC(1, UL) << OBJ_INDEX_BITS) - 1)
+
+#define MAX(a, b) ((a) >= (b) ? (a) : (b))
+/* ZS_MIN_ALLOC_SIZE must be multiple of ZS_ALIGN */
+#define ZS_MIN_ALLOC_SIZE \
+	MAX(32, (ZS_MAX_PAGES_PER_ZSPAGE << PAGE_SHIFT >> OBJ_INDEX_BITS))
+#define ZS_MAX_ALLOC_SIZE	PAGE_SIZE
+
+/*
+ * On systems with 4K page size, this gives 254 size classes! There is a
+ * trader-off here:
+ *  - Large number of size classes is potentially wasteful as free page are
+ *    spread across these classes
+ *  - Small number of size classes causes large internal fragmentation
+ *  - Probably its better to use specific size classes (empirically
+ *    determined). NOTE: all those class sizes must be set as multiple of
+ *    ZS_ALIGN to make sure link_free itself never has to span 2 pages.
+ *
+ *  ZS_MIN_ALLOC_SIZE and ZS_SIZE_CLASS_DELTA must be multiple of ZS_ALIGN
+ *  (reason above)
+ */
+#define ZS_SIZE_CLASS_DELTA	(PAGE_SIZE >> 8)
+#define ZS_SIZE_CLASSES		((ZS_MAX_ALLOC_SIZE - ZS_MIN_ALLOC_SIZE) / \
+					ZS_SIZE_CLASS_DELTA + 1)
+
+/*
+ * We do not maintain any list for completely empty or full pages
+ */
+enum fullness_group {
+	ZS_ALMOST_FULL,
+	ZS_ALMOST_EMPTY,
+	_ZS_NR_FULLNESS_GROUPS,
+
+	ZS_EMPTY,
+	ZS_FULL
+};
+
+/*
+ * We assign a page to ZS_ALMOST_EMPTY fullness group when:
+ *	n <= N / f, where
+ * n = number of allocated objects
+ * N = total number of objects zspage can store
+ * f = 1/fullness_threshold_frac
+ *
+ * Similarly, we assign zspage to:
+ *	ZS_ALMOST_FULL	when n > N / f
+ *	ZS_EMPTY	when n == 0
+ *	ZS_FULL		when n == N
+ *
+ * (see: fix_fullness_group())
+ */
+static const int fullness_threshold_frac = 4;
+
+struct size_class {
+	/*
+	 * Size of objects stored in this class. Must be multiple
+	 * of ZS_ALIGN.
+	 */
+	int size;
+	unsigned int index;
+
+	/* Number of PAGE_SIZE sized pages to combine to form a 'zspage' */
+	int pages_per_zspage;
+
+	spinlock_t lock;
+
+	/* stats */
+	u64 pages_allocated;
+
+	struct page *fullness_list[_ZS_NR_FULLNESS_GROUPS];
+};
+
+/*
+ * Placed within free objects to form a singly linked list.
+ * For every zspage, first_page->freelist gives head of this list.
+ *
+ * This must be power of 2 and less than or equal to ZS_ALIGN
+ */
+struct link_free {
+	/* Handle of next free chunk (encodes <PFN, obj_idx>) */
+	void *next;
+};
+
+struct zs_pool {
+	struct size_class size_class[ZS_SIZE_CLASSES];
+
+	gfp_t flags;	/* allocation flags used when growing pool */
+};
 
 /*
  * A zspage's class index and fullness group
@@ -40,17 +218,39 @@
 #define CLASS_IDX_MASK	((1 << CLASS_IDX_BITS) - 1)
 #define FULLNESS_MASK	((1 << FULLNESS_BITS) - 1)
 
+/*
+ * By default, zsmalloc uses a copy-based object mapping method to access
+ * allocations that span two pages. However, if a particular architecture
+ * performs VM mapping faster than copying, then it should be added here
+ * so that USE_PGTABLE_MAPPING is defined. This causes zsmalloc to use
+ * page table mapping rather than copying for object mapping.
+ */
+#if defined(CONFIG_ARM) && !defined(MODULE)
+#define USE_PGTABLE_MAPPING
+#endif
+
+struct mapping_area {
+#ifdef USE_PGTABLE_MAPPING
+	struct vm_struct *vm; /* vm area for mapping object that span pages */
+#else
+	char *vm_buf; /* copy buffer for objects that span pages */
+#endif
+	char *vm_addr; /* address of kmap_atomic()'ed pages */
+	enum zs_mapmode vm_mm; /* mapping mode */
+};
+
+
 /* per-cpu VM mapping areas for zspage accesses that cross page boundaries */
 static DEFINE_PER_CPU(struct mapping_area, zs_map_area);
 
 static int is_first_page(struct page *page)
 {
-	return test_bit(PG_private, &page->flags);
+	return PagePrivate(page);
 }
 
 static int is_last_page(struct page *page)
 {
-	return test_bit(PG_private_2, &page->flags);
+	return PagePrivate2(page);
 }
 
 static void get_zspage_mapping(struct page *page, unsigned int *class_idx,
@@ -180,7 +380,7 @@
  * link together 3 PAGE_SIZE sized pages to form a zspage
  * since then we can perfectly fit in 8 such objects.
  */
-static int get_zspage_order(int class_size)
+static int get_pages_per_zspage(int class_size)
 {
 	int i, max_usedpc = 0;
 	/* zspage order which gives maximum used size per KB */
@@ -223,7 +423,7 @@
 	if (is_last_page(page))
 		next = NULL;
 	else if (is_first_page(page))
-		next = (struct page *)page->private;
+		next = (struct page *)page_private(page);
 	else
 		next = list_entry(page->lru.next, struct page, lru);
 
@@ -247,13 +447,11 @@
 }
 
 /* Decode <page, obj_idx> pair from the given object handle */
-static void obj_handle_to_location(void *handle, struct page **page,
+static void obj_handle_to_location(unsigned long handle, struct page **page,
 				unsigned long *obj_idx)
 {
-	unsigned long hval = (unsigned long)handle;
-
-	*page = pfn_to_page(hval >> OBJ_INDEX_BITS);
-	*obj_idx = hval & OBJ_INDEX_MASK;
+	*page = pfn_to_page(handle >> OBJ_INDEX_BITS);
+	*obj_idx = handle & OBJ_INDEX_MASK;
 }
 
 static unsigned long obj_idx_to_offset(struct page *page,
@@ -354,7 +552,7 @@
 static struct page *alloc_zspage(struct size_class *class, gfp_t flags)
 {
 	int i, error;
-	struct page *first_page = NULL;
+	struct page *first_page = NULL, *uninitialized_var(prev_page);
 
 	/*
 	 * Allocate individual pages and link them together as:
@@ -368,8 +566,8 @@
 	 * identify the last page.
 	 */
 	error = -ENOMEM;
-	for (i = 0; i < class->zspage_order; i++) {
-		struct page *page, *prev_page;
+	for (i = 0; i < class->pages_per_zspage; i++) {
+		struct page *page;
 
 		page = alloc_page(flags);
 		if (!page)
@@ -377,20 +575,19 @@
 
 		INIT_LIST_HEAD(&page->lru);
 		if (i == 0) {	/* first page */
-			set_bit(PG_private, &page->flags);
+			SetPagePrivate(page);
 			set_page_private(page, 0);
 			first_page = page;
 			first_page->inuse = 0;
 		}
 		if (i == 1)
-			first_page->private = (unsigned long)page;
+			set_page_private(first_page, (unsigned long)page);
 		if (i >= 1)
 			page->first_page = first_page;
 		if (i >= 2)
 			list_add(&page->lru, &prev_page->lru);
-		if (i == class->zspage_order - 1)	/* last page */
-			set_bit(PG_private_2, &page->flags);
-
+		if (i == class->pages_per_zspage - 1)	/* last page */
+			SetPagePrivate2(page);
 		prev_page = page;
 	}
 
@@ -398,7 +595,7 @@
 
 	first_page->freelist = obj_location_to_handle(first_page, 0);
 	/* Maximum number of objects we can store in this zspage */
-	first_page->objects = class->zspage_order * PAGE_SIZE / class->size;
+	first_page->objects = class->pages_per_zspage * PAGE_SIZE / class->size;
 
 	error = 0; /* Success */
 
@@ -425,34 +622,141 @@
 	return page;
 }
 
+#ifdef USE_PGTABLE_MAPPING
+static inline int __zs_cpu_up(struct mapping_area *area)
+{
+	/*
+	 * Make sure we don't leak memory if a cpu UP notification
+	 * and zs_init() race and both call zs_cpu_up() on the same cpu
+	 */
+	if (area->vm)
+		return 0;
+	area->vm = alloc_vm_area(PAGE_SIZE * 2, NULL);
+	if (!area->vm)
+		return -ENOMEM;
+	return 0;
+}
 
-/*
- * If this becomes a separate module, register zs_init() with
- * module_init(), zs_exit with module_exit(), and remove zs_initialized
-*/
-static int zs_initialized;
+static inline void __zs_cpu_down(struct mapping_area *area)
+{
+	if (area->vm)
+		free_vm_area(area->vm);
+	area->vm = NULL;
+}
+
+static inline void *__zs_map_object(struct mapping_area *area,
+				struct page *pages[2], int off, int size)
+{
+	BUG_ON(map_vm_area(area->vm, PAGE_KERNEL, &pages));
+	area->vm_addr = area->vm->addr;
+	return area->vm_addr + off;
+}
+
+static inline void __zs_unmap_object(struct mapping_area *area,
+				struct page *pages[2], int off, int size)
+{
+	unsigned long addr = (unsigned long)area->vm_addr;
+
+	unmap_kernel_range(addr, PAGE_SIZE * 2);
+}
+
+#else /* USE_PGTABLE_MAPPING */
+
+static inline int __zs_cpu_up(struct mapping_area *area)
+{
+	/*
+	 * Make sure we don't leak memory if a cpu UP notification
+	 * and zs_init() race and both call zs_cpu_up() on the same cpu
+	 */
+	if (area->vm_buf)
+		return 0;
+	area->vm_buf = (char *)__get_free_page(GFP_KERNEL);
+	if (!area->vm_buf)
+		return -ENOMEM;
+	return 0;
+}
+
+static inline void __zs_cpu_down(struct mapping_area *area)
+{
+	if (area->vm_buf)
+		free_page((unsigned long)area->vm_buf);
+	area->vm_buf = NULL;
+}
+
+static void *__zs_map_object(struct mapping_area *area,
+			struct page *pages[2], int off, int size)
+{
+	int sizes[2];
+	void *addr;
+	char *buf = area->vm_buf;
+
+	/* disable page faults to match kmap_atomic() return conditions */
+	pagefault_disable();
+
+	/* no read fastpath */
+	if (area->vm_mm == ZS_MM_WO)
+		goto out;
+
+	sizes[0] = PAGE_SIZE - off;
+	sizes[1] = size - sizes[0];
+
+	/* copy object to per-cpu buffer */
+	addr = kmap_atomic(pages[0]);
+	memcpy(buf, addr + off, sizes[0]);
+	kunmap_atomic(addr);
+	addr = kmap_atomic(pages[1]);
+	memcpy(buf + sizes[0], addr, sizes[1]);
+	kunmap_atomic(addr);
+out:
+	return area->vm_buf;
+}
+
+static void __zs_unmap_object(struct mapping_area *area,
+			struct page *pages[2], int off, int size)
+{
+	int sizes[2];
+	void *addr;
+	char *buf = area->vm_buf;
+
+	/* no write fastpath */
+	if (area->vm_mm == ZS_MM_RO)
+		goto out;
+
+	sizes[0] = PAGE_SIZE - off;
+	sizes[1] = size - sizes[0];
+
+	/* copy per-cpu buffer to object */
+	addr = kmap_atomic(pages[0]);
+	memcpy(addr + off, buf, sizes[0]);
+	kunmap_atomic(addr);
+	addr = kmap_atomic(pages[1]);
+	memcpy(addr, buf + sizes[0], sizes[1]);
+	kunmap_atomic(addr);
+
+out:
+	/* enable page faults to match kunmap_atomic() return conditions */
+	pagefault_enable();
+}
+
+#endif /* USE_PGTABLE_MAPPING */
 
 static int zs_cpu_notifier(struct notifier_block *nb, unsigned long action,
 				void *pcpu)
 {
-	int cpu = (long)pcpu;
+	int ret, cpu = (long)pcpu;
 	struct mapping_area *area;
 
 	switch (action) {
 	case CPU_UP_PREPARE:
 		area = &per_cpu(zs_map_area, cpu);
-		if (area->vm)
-			break;
-		area->vm = alloc_vm_area(2 * PAGE_SIZE, area->vm_ptes);
-		if (!area->vm)
-			return notifier_from_errno(-ENOMEM);
+		ret = __zs_cpu_up(area);
+		if (ret)
+			return notifier_from_errno(ret);
 		break;
 	case CPU_DEAD:
 	case CPU_UP_CANCELED:
 		area = &per_cpu(zs_map_area, cpu);
-		if (area->vm)
-			free_vm_area(area->vm);
-		area->vm = NULL;
+		__zs_cpu_down(area);
 		break;
 	}
 
@@ -488,14 +792,21 @@
 	return notifier_to_errno(ret);
 }
 
-struct zs_pool *zs_create_pool(const char *name, gfp_t flags)
+/**
+ * zs_create_pool - Creates an allocation pool to work from.
+ * @flags: allocation flags used to allocate pool metadata
+ *
+ * This function must be called before anything when using
+ * the zsmalloc allocator.
+ *
+ * On success, a pointer to the newly created pool is returned,
+ * otherwise NULL.
+ */
+struct zs_pool *zs_create_pool(gfp_t flags)
 {
-	int i, error, ovhd_size;
+	int i, ovhd_size;
 	struct zs_pool *pool;
 
-	if (!name)
-		return NULL;
-
 	ovhd_size = roundup(sizeof(*pool), PAGE_SIZE);
 	pool = kzalloc(ovhd_size, GFP_KERNEL);
 	if (!pool)
@@ -513,31 +824,11 @@
 		class->size = size;
 		class->index = i;
 		spin_lock_init(&class->lock);
-		class->zspage_order = get_zspage_order(size);
+		class->pages_per_zspage = get_pages_per_zspage(size);
 
 	}
 
-	/*
-	 * If this becomes a separate module, register zs_init with
-	 * module_init, and remove this block
-	*/
-	if (!zs_initialized) {
-		error = zs_init();
-		if (error)
-			goto cleanup;
-		zs_initialized = 1;
-	}
-
 	pool->flags = flags;
-	pool->name = name;
-
-	error = 0; /* Success */
-
-cleanup:
-	if (error) {
-		zs_destroy_pool(pool);
-		pool = NULL;
-	}
 
 	return pool;
 }
@@ -553,8 +844,7 @@
 
 		for (fg = 0; fg < _ZS_NR_FULLNESS_GROUPS; fg++) {
 			if (class->fullness_list[fg]) {
-				pr_info("Freeing non-empty class with size "
-					"%db, fullness group %d\n",
+				pr_info("Freeing non-empty class with size %db, fullness group %d\n",
 					class->size, fg);
 			}
 		}
@@ -567,18 +857,14 @@
  * zs_malloc - Allocate block of given size from pool.
  * @pool: pool to allocate from
  * @size: size of block to allocate
- * @page: page no. that holds the object
- * @offset: location of object within page
  *
- * On success, <page, offset> identifies block allocated
- * and 0 is returned. On failure, <page, offset> is set to
- * 0 and -ENOMEM is returned.
- *
+ * On success, handle to the allocated object is returned,
+ * otherwise 0.
  * Allocation requests with size > ZS_MAX_ALLOC_SIZE will fail.
  */
-void *zs_malloc(struct zs_pool *pool, size_t size)
+unsigned long zs_malloc(struct zs_pool *pool, size_t size)
 {
-	void *obj;
+	unsigned long obj;
 	struct link_free *link;
 	int class_idx;
 	struct size_class *class;
@@ -587,7 +873,7 @@
 	unsigned long m_objidx, m_offset;
 
 	if (unlikely(!size || size > ZS_MAX_ALLOC_SIZE))
-		return NULL;
+		return 0;
 
 	class_idx = get_size_class_index(size);
 	class = &pool->size_class[class_idx];
@@ -600,14 +886,14 @@
 		spin_unlock(&class->lock);
 		first_page = alloc_zspage(class, pool->flags);
 		if (unlikely(!first_page))
-			return NULL;
+			return 0;
 
 		set_zspage_mapping(first_page, class->index, ZS_EMPTY);
 		spin_lock(&class->lock);
-		class->pages_allocated += class->zspage_order;
+		class->pages_allocated += class->pages_per_zspage;
 	}
 
-	obj = first_page->freelist;
+	obj = (unsigned long)first_page->freelist;
 	obj_handle_to_location(obj, &m_page, &m_objidx);
 	m_offset = obj_idx_to_offset(m_page, m_objidx, class->size);
 
@@ -626,7 +912,7 @@
 }
 EXPORT_SYMBOL_GPL(zs_malloc);
 
-void zs_free(struct zs_pool *pool, void *obj)
+void zs_free(struct zs_pool *pool, unsigned long obj)
 {
 	struct link_free *link;
 	struct page *first_page, *f_page;
@@ -653,13 +939,13 @@
 							+ f_offset);
 	link->next = first_page->freelist;
 	kunmap_atomic(link);
-	first_page->freelist = obj;
+	first_page->freelist = (void *)obj;
 
 	first_page->inuse--;
 	fullness = fix_fullness_group(pool, first_page);
 
 	if (fullness == ZS_EMPTY)
-		class->pages_allocated -= class->zspage_order;
+		class->pages_allocated -= class->pages_per_zspage;
 
 	spin_unlock(&class->lock);
 
@@ -668,7 +954,22 @@
 }
 EXPORT_SYMBOL_GPL(zs_free);
 
-void *zs_map_object(struct zs_pool *pool, void *handle)
+/**
+ * zs_map_object - get address of allocated object from handle.
+ * @pool: pool from which the object was allocated
+ * @handle: handle returned from zs_malloc
+ *
+ * Before using an object allocated from zs_malloc, it must be mapped using
+ * this function. When done with the object, it must be unmapped using
+ * zs_unmap_object.
+ *
+ * Only one object can be mapped per cpu at a time. There is no protection
+ * against nested mappings.
+ *
+ * This function returns with preemption and page faults disabled.
+ */
+void *zs_map_object(struct zs_pool *pool, unsigned long handle,
+			enum zs_mapmode mm)
 {
 	struct page *page;
 	unsigned long obj_idx, off;
@@ -677,38 +978,40 @@
 	enum fullness_group fg;
 	struct size_class *class;
 	struct mapping_area *area;
+	struct page *pages[2];
 
 	BUG_ON(!handle);
 
+	/*
+	 * Because we use per-cpu mapping areas shared among the
+	 * pools/users, we can't allow mapping in interrupt context
+	 * because it can corrupt another users mappings.
+	 */
+	BUG_ON(in_interrupt());
+
 	obj_handle_to_location(handle, &page, &obj_idx);
 	get_zspage_mapping(get_first_page(page), &class_idx, &fg);
 	class = &pool->size_class[class_idx];
 	off = obj_idx_to_offset(page, obj_idx, class->size);
 
 	area = &get_cpu_var(zs_map_area);
+	area->vm_mm = mm;
 	if (off + class->size <= PAGE_SIZE) {
 		/* this object is contained entirely within a page */
 		area->vm_addr = kmap_atomic(page);
-	} else {
-		/* this object spans two pages */
-		struct page *nextp;
-
-		nextp = get_next_page(page);
-		BUG_ON(!nextp);
-
-
-		set_pte(area->vm_ptes[0], mk_pte(page, PAGE_KERNEL));
-		set_pte(area->vm_ptes[1], mk_pte(nextp, PAGE_KERNEL));
-
-		/* We pre-allocated VM area so mapping can never fail */
-		area->vm_addr = area->vm->addr;
+		return area->vm_addr + off;
 	}
 
-	return area->vm_addr + off;
+	/* this object spans two pages */
+	pages[0] = page;
+	pages[1] = get_next_page(page);
+	BUG_ON(!pages[1]);
+
+	return __zs_map_object(area, pages, off, class->size);
 }
 EXPORT_SYMBOL_GPL(zs_map_object);
 
-void zs_unmap_object(struct zs_pool *pool, void *handle)
+void zs_unmap_object(struct zs_pool *pool, unsigned long handle)
 {
 	struct page *page;
 	unsigned long obj_idx, off;
@@ -726,13 +1029,16 @@
 	off = obj_idx_to_offset(page, obj_idx, class->size);
 
 	area = &__get_cpu_var(zs_map_area);
-	if (off + class->size <= PAGE_SIZE) {
+	if (off + class->size <= PAGE_SIZE)
 		kunmap_atomic(area->vm_addr);
-	} else {
-		set_pte(area->vm_ptes[0], __pte(0));
-		set_pte(area->vm_ptes[1], __pte(0));
-		__flush_tlb_one((unsigned long)area->vm_addr);
-		__flush_tlb_one((unsigned long)area->vm_addr + PAGE_SIZE);
+	else {
+		struct page *pages[2];
+
+		pages[0] = page;
+		pages[1] = get_next_page(page);
+		BUG_ON(!pages[1]);
+
+		__zs_unmap_object(area, pages, off, class->size);
 	}
 	put_cpu_var(zs_map_area);
 }
@@ -749,3 +1055,9 @@
 	return npages << PAGE_SHIFT;
 }
 EXPORT_SYMBOL_GPL(zs_get_total_size_bytes);
+
+module_init(zs_init);
+module_exit(zs_exit);
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_AUTHOR("Nitin Gupta <ngupta@vflare.org>");
diff --git a/drivers/staging/zsmalloc/zsmalloc.h b/drivers/staging/zsmalloc/zsmalloc.h
index 949384e..fbe6bec 100644
--- a/drivers/staging/zsmalloc/zsmalloc.h
+++ b/drivers/staging/zsmalloc/zsmalloc.h
@@ -15,16 +15,28 @@
 
 #include <linux/types.h>
 
+/*
+ * zsmalloc mapping modes
+ *
+ * NOTE: These only make a difference when a mapped object spans pages
+ */
+enum zs_mapmode {
+	ZS_MM_RW, /* normal read-write mapping */
+	ZS_MM_RO, /* read-only (no copy-out at unmap time) */
+	ZS_MM_WO /* write-only (no copy-in at map time) */
+};
+
 struct zs_pool;
 
-struct zs_pool *zs_create_pool(const char *name, gfp_t flags);
+struct zs_pool *zs_create_pool(gfp_t flags);
 void zs_destroy_pool(struct zs_pool *pool);
 
-void *zs_malloc(struct zs_pool *pool, size_t size);
-void zs_free(struct zs_pool *pool, void *obj);
+unsigned long zs_malloc(struct zs_pool *pool, size_t size);
+void zs_free(struct zs_pool *pool, unsigned long obj);
 
-void *zs_map_object(struct zs_pool *pool, void *handle);
-void zs_unmap_object(struct zs_pool *pool, void *handle);
+void *zs_map_object(struct zs_pool *pool, unsigned long handle,
+			enum zs_mapmode mm);
+void zs_unmap_object(struct zs_pool *pool, unsigned long handle);
 
 u64 zs_get_total_size_bytes(struct zs_pool *pool);
 
diff --git a/drivers/staging/zsmalloc/zsmalloc_int.h b/drivers/staging/zsmalloc/zsmalloc_int.h
deleted file mode 100644
index 92eefc6..0000000
--- a/drivers/staging/zsmalloc/zsmalloc_int.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * zsmalloc memory allocator
- *
- * Copyright (C) 2011  Nitin Gupta
- *
- * This code is released using a dual license strategy: BSD/GPL
- * You can choose the license that better fits your requirements.
- *
- * Released under the terms of 3-clause BSD License
- * Released under the terms of GNU General Public License Version 2.0
- */
-
-#ifndef _ZS_MALLOC_INT_H_
-#define _ZS_MALLOC_INT_H_
-
-#include <linux/kernel.h>
-#include <linux/spinlock.h>
-#include <linux/types.h>
-
-/*
- * This must be power of 2 and greater than of equal to sizeof(link_free).
- * These two conditions ensure that any 'struct link_free' itself doesn't
- * span more than 1 page which avoids complex case of mapping 2 pages simply
- * to restore link_free pointer values.
- */
-#define ZS_ALIGN		8
-
-/*
- * A single 'zspage' is composed of up to 2^N discontiguous 0-order (single)
- * pages. ZS_MAX_ZSPAGE_ORDER defines upper limit on N.
- */
-#define ZS_MAX_ZSPAGE_ORDER 2
-#define ZS_MAX_PAGES_PER_ZSPAGE (_AC(1, UL) << ZS_MAX_ZSPAGE_ORDER)
-
-/*
- * Object location (<PFN>, <obj_idx>) is encoded as
- * as single (void *) handle value.
- *
- * Note that object index <obj_idx> is relative to system
- * page <PFN> it is stored in, so for each sub-page belonging
- * to a zspage, obj_idx starts with 0.
- *
- * This is made more complicated by various memory models and PAE.
- */
-
-#ifndef MAX_PHYSMEM_BITS
-#ifdef CONFIG_HIGHMEM64G
-#define MAX_PHYSMEM_BITS 36
-#else /* !CONFIG_HIGHMEM64G */
-/*
- * If this definition of MAX_PHYSMEM_BITS is used, OBJ_INDEX_BITS will just
- * be PAGE_SHIFT
- */
-#define MAX_PHYSMEM_BITS BITS_PER_LONG
-#endif
-#endif
-#define _PFN_BITS		(MAX_PHYSMEM_BITS - PAGE_SHIFT)
-#define OBJ_INDEX_BITS	(BITS_PER_LONG - _PFN_BITS)
-#define OBJ_INDEX_MASK	((_AC(1, UL) << OBJ_INDEX_BITS) - 1)
-
-#define MAX(a, b) ((a) >= (b) ? (a) : (b))
-/* ZS_MIN_ALLOC_SIZE must be multiple of ZS_ALIGN */
-#define ZS_MIN_ALLOC_SIZE \
-	MAX(32, (ZS_MAX_PAGES_PER_ZSPAGE << PAGE_SHIFT >> OBJ_INDEX_BITS))
-#define ZS_MAX_ALLOC_SIZE	PAGE_SIZE
-
-/*
- * On systems with 4K page size, this gives 254 size classes! There is a
- * trader-off here:
- *  - Large number of size classes is potentially wasteful as free page are
- *    spread across these classes
- *  - Small number of size classes causes large internal fragmentation
- *  - Probably its better to use specific size classes (empirically
- *    determined). NOTE: all those class sizes must be set as multiple of
- *    ZS_ALIGN to make sure link_free itself never has to span 2 pages.
- *
- *  ZS_MIN_ALLOC_SIZE and ZS_SIZE_CLASS_DELTA must be multiple of ZS_ALIGN
- *  (reason above)
- */
-#define ZS_SIZE_CLASS_DELTA	16
-#define ZS_SIZE_CLASSES		((ZS_MAX_ALLOC_SIZE - ZS_MIN_ALLOC_SIZE) / \
-					ZS_SIZE_CLASS_DELTA + 1)
-
-/*
- * We do not maintain any list for completely empty or full pages
- */
-enum fullness_group {
-	ZS_ALMOST_FULL,
-	ZS_ALMOST_EMPTY,
-	_ZS_NR_FULLNESS_GROUPS,
-
-	ZS_EMPTY,
-	ZS_FULL
-};
-
-/*
- * We assign a page to ZS_ALMOST_EMPTY fullness group when:
- *	n <= N / f, where
- * n = number of allocated objects
- * N = total number of objects zspage can store
- * f = 1/fullness_threshold_frac
- *
- * Similarly, we assign zspage to:
- *	ZS_ALMOST_FULL	when n > N / f
- *	ZS_EMPTY	when n == 0
- *	ZS_FULL		when n == N
- *
- * (see: fix_fullness_group())
- */
-static const int fullness_threshold_frac = 4;
-
-struct mapping_area {
-	struct vm_struct *vm;
-	pte_t *vm_ptes[2];
-	char *vm_addr;
-};
-
-struct size_class {
-	/*
-	 * Size of objects stored in this class. Must be multiple
-	 * of ZS_ALIGN.
-	 */
-	int size;
-	unsigned int index;
-
-	/* Number of PAGE_SIZE sized pages to combine to form a 'zspage' */
-	int zspage_order;
-
-	spinlock_t lock;
-
-	/* stats */
-	u64 pages_allocated;
-
-	struct page *fullness_list[_ZS_NR_FULLNESS_GROUPS];
-};
-
-/*
- * Placed within free objects to form a singly linked list.
- * For every zspage, first_page->freelist gives head of this list.
- *
- * This must be power of 2 and less than or equal to ZS_ALIGN
- */
-struct link_free {
-	/* Handle of next free chunk (encodes <PFN, obj_idx>) */
-	void *next;
-};
-
-struct zs_pool {
-	struct size_class size_class[ZS_SIZE_CLASSES];
-
-	gfp_t flags;	/* allocation flags used when growing pool */
-	const char *name;
-};
-
-#endif
diff --git a/drivers/thermal/msm_thermal.c b/drivers/thermal/msm_thermal.c
index 00df613..39cfa33 100644
--- a/drivers/thermal/msm_thermal.c
+++ b/drivers/thermal/msm_thermal.c
@@ -38,9 +38,11 @@
 #include <linux/regulator/consumer.h>
 
 #define MAX_RAILS 5
+#define MAX_THRESHOLD 2
 
 static struct msm_thermal_data msm_thermal_info;
-static uint32_t limited_max_freq = MSM_CPUFREQ_NO_LIMIT;
+static uint32_t limited_max_freq = UINT_MAX;
+static uint32_t limited_min_freq;
 static struct delayed_work check_temp_work;
 static bool core_control_enabled;
 static uint32_t cpus_offlined;
@@ -69,6 +71,7 @@
 static bool psm_enabled;
 static bool psm_nodes_called;
 static bool psm_probed;
+static bool hotplug_enabled;
 static int *tsens_id_map;
 static DEFINE_MUTEX(vdd_rstr_mutex);
 static DEFINE_MUTEX(psm_mutex);
@@ -77,8 +80,10 @@
 	uint32_t cpu;
 	bool offline;
 	bool user_offline;
+	bool thresh_cleared;
 	const char *sensor_type;
-	struct sensor_threshold thresh[2];
+	uint32_t sensor_id;
+	struct sensor_threshold thresh[MAX_THRESHOLD];
 };
 
 struct rail {
@@ -154,6 +159,25 @@
 
 #define PSM_REG_MODE_FROM_ATTRIBS(attr) \
 	(container_of(attr, struct psm_rail, mode_attr));
+
+static int  msm_thermal_cpufreq_callback(struct notifier_block *nfb,
+		unsigned long event, void *data)
+{
+	struct cpufreq_policy *policy = data;
+
+	switch (event) {
+	case CPUFREQ_INCOMPATIBLE:
+		cpufreq_verify_within_limits(policy, limited_min_freq,
+				limited_max_freq);
+		break;
+	}
+	return NOTIFY_OK;
+}
+
+static struct notifier_block msm_thermal_cpufreq_notifier = {
+	.notifier_call = msm_thermal_cpufreq_callback,
+};
+
 /* If freq table exists, then we can send freq request */
 static int check_freq_table(void)
 {
@@ -174,37 +198,26 @@
 {
 	int cpu = 0;
 	int ret = 0;
-	struct cpufreq_policy *policy = NULL;
 
 	if (!freq_table_get) {
 		ret = check_freq_table();
 		if (ret) {
-			pr_err("%s:Fail to get freq table\n", __func__);
+			pr_err("%s:Fail to get freq table\n", KBUILD_MODNAME);
 			return ret;
 		}
 	}
 	/* If min is larger than allowed max */
-	if (min != MSM_CPUFREQ_NO_LIMIT &&
-			min > table[limit_idx_high].frequency)
-		min = table[limit_idx_high].frequency;
+	min = min(min, table[limit_idx_high].frequency);
 
-	for_each_possible_cpu(cpu) {
-		ret = msm_cpufreq_set_freq_limits(cpu, min, limited_max_freq);
-		if (ret) {
-			pr_err("%s:Fail to set limits for cpu%d\n",
-					__func__, cpu);
-			return ret;
-		}
+	limited_min_freq = min;
 
-		if (cpu_online(cpu)) {
-			policy = cpufreq_cpu_get(cpu);
-			if (!policy)
-				continue;
-			cpufreq_driver_target(policy, policy->cur,
-					CPUFREQ_RELATION_L);
-			cpufreq_cpu_put(policy);
-		}
+	get_online_cpus();
+	for_each_online_cpu(cpu) {
+		if (cpufreq_update_policy(cpu))
+			pr_info("%s: Unable to update policy for cpu:%d\n",
+				KBUILD_MODNAME, cpu);
 	}
+	put_online_cpus();
 
 	return ret;
 }
@@ -599,27 +612,90 @@
 {
 	int ret = 0;
 
-	ret = msm_cpufreq_set_freq_limits(cpu, MSM_CPUFREQ_NO_LIMIT, max_freq);
-	if (ret)
-		return ret;
-
-	limited_max_freq = max_freq;
-	if (max_freq != MSM_CPUFREQ_NO_LIMIT)
+	if (max_freq != UINT_MAX)
 		pr_info("%s: Limiting cpu%d max frequency to %d\n",
 				KBUILD_MODNAME, cpu, max_freq);
 	else
 		pr_info("%s: Max frequency reset for cpu%d\n",
 				KBUILD_MODNAME, cpu);
+	get_online_cpus();
+	for_each_online_cpu(cpu) {
+		if (cpufreq_update_policy(cpu))
+			pr_info("%s: Unable to update policy for cpu:%d\n",
+				KBUILD_MODNAME, cpu);
+	}
+	put_online_cpus();
 
-	if (cpu_online(cpu)) {
-		struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
-		if (!policy)
-			return ret;
-		ret = cpufreq_driver_target(policy, policy->cur,
-				CPUFREQ_RELATION_H);
-		cpufreq_cpu_put(policy);
+	return ret;
+}
+
+static int set_and_activate_threshold(uint32_t sensor_id,
+	struct sensor_threshold *threshold)
+{
+	int ret = 0;
+
+	ret = sensor_set_trip(sensor_id, threshold);
+	if (ret != 0) {
+		pr_err("%s: Error in setting trip %d\n",
+			KBUILD_MODNAME, threshold->trip);
+		goto set_done;
 	}
 
+	ret = sensor_activate_trip(sensor_id, threshold, true);
+	if (ret != 0) {
+		pr_err("%s: Error in enabling trip %d\n",
+			KBUILD_MODNAME, threshold->trip);
+		goto set_done;
+	}
+
+set_done:
+	return ret;
+}
+
+static int set_threshold(uint32_t sensor_id,
+	struct sensor_threshold *threshold)
+{
+	struct tsens_device tsens_dev;
+	int i = 0, ret = 0;
+	long temp;
+
+	if ((!threshold) || check_sensor_id(sensor_id)) {
+		pr_err("%s: Invalid input\n", KBUILD_MODNAME);
+		ret = -EINVAL;
+		goto set_threshold_exit;
+	}
+
+	tsens_dev.sensor_num = sensor_id;
+	ret = tsens_get_temp(&tsens_dev, &temp);
+	if (ret) {
+		pr_err("%s: Unable to read TSENS sensor %d\n",
+			KBUILD_MODNAME, tsens_dev.sensor_num);
+		goto set_threshold_exit;
+	}
+	while (i < MAX_THRESHOLD) {
+		switch (threshold[i].trip) {
+		case THERMAL_TRIP_CONFIGURABLE_HI:
+			if (threshold[i].temp >= temp) {
+				ret = set_and_activate_threshold(sensor_id,
+					&threshold[i]);
+				if (ret)
+					goto set_threshold_exit;
+			}
+			break;
+		case THERMAL_TRIP_CONFIGURABLE_LOW:
+			if (threshold[i].temp <= temp) {
+				ret = set_and_activate_threshold(sensor_id,
+					&threshold[i]);
+				if (ret)
+					goto set_threshold_exit;
+			}
+			break;
+		default:
+			break;
+		}
+		i++;
+	}
+set_threshold_exit:
 	return ret;
 }
 
@@ -676,7 +752,7 @@
 /* Call with core_control_mutex locked */
 static int __ref update_offline_cores(int val)
 {
-	int cpu = 0;
+	uint32_t cpu = 0;
 	int ret = 0;
 
 	if (!core_control_enabled)
@@ -700,8 +776,7 @@
 static __ref int do_hotplug(void *data)
 {
 	int ret = 0;
-	int cpu = 0;
-	uint32_t mask = 0;
+	uint32_t cpu = 0, mask = 0;
 
 	if (!core_control_enabled)
 		return -EINVAL;
@@ -713,6 +788,12 @@
 
 		mutex_lock(&core_control_mutex);
 		for_each_possible_cpu(cpu) {
+			if (hotplug_enabled &&
+				cpus[cpu].thresh_cleared) {
+				set_threshold(cpus[cpu].sensor_id,
+					cpus[cpu].thresh);
+				cpus[cpu].thresh_cleared = false;
+			}
 			if (cpus[cpu].offline || cpus[cpu].user_offline)
 				mask |= BIT(cpu);
 		}
@@ -835,7 +916,6 @@
 
 static void __ref do_freq_control(long temp)
 {
-	int ret = 0;
 	int cpu = 0;
 	uint32_t max_freq = limited_max_freq;
 
@@ -855,7 +935,7 @@
 		limit_idx += msm_thermal_info.freq_step;
 		if (limit_idx >= limit_idx_high) {
 			limit_idx = limit_idx_high;
-			max_freq = MSM_CPUFREQ_NO_LIMIT;
+			max_freq = UINT_MAX;
 		} else
 			max_freq = table[limit_idx].frequency;
 	}
@@ -863,17 +943,13 @@
 	if (max_freq == limited_max_freq)
 		return;
 
+	limited_max_freq = max_freq;
 	/* Update new limits */
 	for_each_possible_cpu(cpu) {
 		if (!(msm_thermal_info.freq_control_mask & BIT(cpu)))
 			continue;
-		ret = update_cpu_max_freq(cpu, max_freq);
-		if (ret)
-			pr_debug(
-			"%s: Unable to limit cpu%d max freq to %d\n",
-					KBUILD_MODNAME, cpu, max_freq);
+		update_cpu_max_freq(cpu, max_freq);
 	}
-
 }
 
 static void __ref check_temp(struct work_struct *work)
@@ -988,10 +1064,12 @@
 	default:
 		break;
 	}
-	if (hotplug_task)
+	if (hotplug_task) {
+		cpu_node->thresh_cleared = true;
 		complete(&hotplug_notify_complete);
-	else
+	} else {
 		pr_err("%s: Hotplug task is not initialized\n", KBUILD_MODNAME);
+	}
 	return 0;
 }
 /* Adjust cpus offlined bit based on temperature reading. */
@@ -1001,15 +1079,18 @@
 	long temp = 0;
 	int cpu = 0;
 
+	if (!hotplug_enabled)
+		return 0;
+
 	mutex_lock(&core_control_mutex);
 	for_each_possible_cpu(cpu) {
 		if (!(msm_thermal_info.core_control_mask & BIT(cpus[cpu].cpu)))
 			continue;
-		tsens_dev.sensor_num = sensor_get_id(\
-				(char *)cpus[cpu].sensor_type);
+		tsens_dev.sensor_num = cpus[cpu].sensor_id;
 		if (tsens_get_temp(&tsens_dev, &temp)) {
 			pr_err("%s: Unable to read TSENS sensor %d\n",
 				KBUILD_MODNAME, tsens_dev.sensor_num);
+			mutex_unlock(&core_control_mutex);
 			return -EINVAL;
 		}
 
@@ -1038,26 +1119,29 @@
 	if (hotplug_task)
 		return;
 
+	if (!hotplug_enabled)
+		goto init_kthread;
+
 	for_each_possible_cpu(cpu) {
+		cpus[cpu].cpu = (uint32_t)cpu;
+		cpus[cpu].thresh_cleared = false;
+		cpus[cpu].sensor_id =
+			sensor_get_id((char *)cpus[cpu].sensor_type);
 		if (!(msm_thermal_info.core_control_mask & BIT(cpus[cpu].cpu)))
 			continue;
-		cpus[cpu].cpu = (uint32_t)cpu;
 		cpus[cpu].thresh[0].temp = msm_thermal_info.hotplug_temp_degC;
 		cpus[cpu].thresh[0].trip = THERMAL_TRIP_CONFIGURABLE_HI;
 		cpus[cpu].thresh[0].notify = hotplug_notify;
 		cpus[cpu].thresh[0].data = (void *)&cpus[cpu];
-		sensor_set_trip(sensor_get_id((char *)cpus[cpu].sensor_type),
-				&cpus[cpu].thresh[0]);
 
 		cpus[cpu].thresh[1].temp = msm_thermal_info.hotplug_temp_degC -
 				msm_thermal_info.hotplug_temp_hysteresis_degC;
 		cpus[cpu].thresh[1].trip = THERMAL_TRIP_CONFIGURABLE_LOW;
 		cpus[cpu].thresh[1].notify = hotplug_notify;
 		cpus[cpu].thresh[1].data = (void *)&cpus[cpu];
-		sensor_set_trip(sensor_get_id((char *)cpus[cpu].sensor_type),
-				&cpus[cpu].thresh[1]);
-
+		set_threshold(cpus[cpu].sensor_id, cpus[cpu].thresh);
 	}
+init_kthread:
 	init_completion(&hotplug_notify_complete);
 	hotplug_task = kthread_run(do_hotplug, NULL, "msm_thermal:hotplug");
 	if (IS_ERR(hotplug_task)) {
@@ -1086,12 +1170,17 @@
 	cancel_delayed_work(&check_temp_work);
 	flush_scheduled_work();
 
-	if (limited_max_freq == MSM_CPUFREQ_NO_LIMIT)
+	if (limited_max_freq == UINT_MAX)
 		return;
 
-	for_each_possible_cpu(cpu) {
-		update_cpu_max_freq(cpu, MSM_CPUFREQ_NO_LIMIT);
+	limited_max_freq = UINT_MAX;
+	get_online_cpus();
+	for_each_online_cpu(cpu) {
+		if (cpufreq_update_policy(cpu))
+			pr_info("%s: Unable to update policy for cpu:%d\n",
+				KBUILD_MODNAME, cpu);
 	}
+	put_online_cpus();
 }
 
 static int __ref set_enabled(const char *val, const struct kernel_param *kp)
@@ -1104,7 +1193,7 @@
 		hotplug_init();
 	} else
 		pr_info("%s: no action for enabled = %d\n",
-				KBUILD_MODNAME, enabled);
+			KBUILD_MODNAME, enabled);
 
 	pr_info("%s: enabled = %d\n", KBUILD_MODNAME, enabled);
 
@@ -1345,7 +1434,11 @@
 		return -EINVAL;
 
 	enabled = 1;
-
+	ret = cpufreq_register_notifier(&msm_thermal_cpufreq_notifier,
+			CPUFREQ_POLICY_NOTIFIER);
+	if (ret)
+		pr_err("%s: cannot register cpufreq notifier\n",
+			KBUILD_MODNAME);
 	INIT_DELAYED_WORK(&check_temp_work, check_temp);
 	schedule_delayed_work(&check_temp_work, 0);
 
@@ -1659,7 +1752,7 @@
 		key = "qcom,freq-req";
 		rails[i].freq_req = of_property_read_bool(child_node, key);
 		if (rails[i].freq_req)
-			rails[i].min_level = MSM_CPUFREQ_NO_LIMIT;
+			rails[i].min_level = 0;
 		else {
 			key = "qcom,min-level";
 			ret = of_property_read_u32(child_node, key,
@@ -1764,6 +1857,11 @@
 	int ret = 0;
 	int cpu = 0;
 
+	if (num_possible_cpus() > 1) {
+		core_control_enabled = 1;
+		hotplug_enabled = 1;
+	}
+
 	key = "qcom,core-limit-temp";
 	ret = of_property_read_u32(node, key, &data->core_limit_temp_degC);
 	if (ret)
@@ -1782,19 +1880,20 @@
 	key = "qcom,hotplug-temp";
 	ret = of_property_read_u32(node, key, &data->hotplug_temp_degC);
 	if (ret)
-		goto read_node_fail;
+		goto hotplug_node_fail;
 
 	key = "qcom,hotplug-temp-hysteresis";
 	ret = of_property_read_u32(node, key,
 			&data->hotplug_temp_hysteresis_degC);
 	if (ret)
-		goto read_node_fail;
+		goto hotplug_node_fail;
 
 	key = "qcom,cpu-sensors";
 	cpu_cnt = of_property_count_strings(node, key);
 	if (cpu_cnt != num_possible_cpus()) {
 		pr_err("%s: Wrong number of cpu\n", KBUILD_MODNAME);
-		goto read_node_fail;
+		ret = -EINVAL;
+		goto hotplug_node_fail;
 	}
 
 	for_each_possible_cpu(cpu) {
@@ -1804,12 +1903,9 @@
 		ret = of_property_read_string_index(node, key, cpu,
 				&cpus[cpu].sensor_type);
 		if (ret)
-			goto read_node_fail;
+			goto hotplug_node_fail;
 	}
 
-	if (num_possible_cpus() > 1)
-		core_control_enabled = 1;
-
 read_node_fail:
 	if (ret) {
 		dev_info(&pdev->dev,
@@ -1819,6 +1915,16 @@
 	}
 
 	return ret;
+
+hotplug_node_fail:
+	if (ret) {
+		dev_info(&pdev->dev,
+			"%s:Failed reading node=%s, key=%s. KTM continues\n",
+			KBUILD_MODNAME, node->full_name, key);
+		hotplug_enabled = 0;
+	}
+
+	return ret;
 }
 
 static int __devinit msm_thermal_dev_probe(struct platform_device *pdev)
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index 8d9da6b..739696d 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -89,30 +89,21 @@
 }
 EXPORT_SYMBOL(sensor_get_id);
 
-static long get_min(struct sensor_info *sensor, long temp)
+static int __update_sensor_thresholds(struct sensor_info *sensor)
 {
-	long min = LONG_MIN;
-	struct sensor_threshold *pos, *var;
-
-	list_for_each_entry_safe(pos, var, &sensor->threshold_list, list) {
-		if (pos->trip == THERMAL_TRIP_CONFIGURABLE_LOW)
-			if (pos->temp < temp && pos->temp > min)
-				min = pos->temp;
-	}
-
-	return min;
-}
-
-static void __update_sensor_thresholds(struct sensor_info *sensor)
-{
-	long min = LONG_MIN;
-	long max = LONG_MAX;
-	long max_of_min = LONG_MIN;
-	long min_of_max = LONG_MAX;
+	long max_of_low_thresh = LONG_MIN;
+	long min_of_high_thresh = LONG_MAX;
 	struct sensor_threshold *pos, *var;
 	enum thermal_trip_type type;
-	int i;
-	long curr_temp;
+	int i, ret = 0;
+
+	if (!sensor->tz->ops->set_trip_temp ||
+		!sensor->tz->ops->activate_trip_type ||
+		!sensor->tz->ops->get_trip_type ||
+		!sensor->tz->ops->get_trip_temp) {
+		ret = -ENODEV;
+		goto update_done;
+	}
 
 	for (i = 0; ((sensor->max_idx == -1) || (sensor->min_idx == -1)) &&
 		(sensor->tz->ops->get_trip_type) && (i < sensor->tz->trips);
@@ -128,60 +119,85 @@
 			THERMAL_TRIP_CONFIGURABLE_HI, &sensor->threshold_max);
 	}
 
-	sensor->tz->ops->get_temp(sensor->tz, &curr_temp);
 	list_for_each_entry_safe(pos, var, &sensor->threshold_list, list) {
+		if (!pos->active)
+			continue;
 		if (pos->trip == THERMAL_TRIP_CONFIGURABLE_LOW) {
-			if (pos->temp > max_of_min)
-				max_of_min = pos->temp;
-			if (pos->temp < curr_temp && pos->temp > min)
-				min = pos->temp;
+			if (pos->temp > max_of_low_thresh)
+				max_of_low_thresh = pos->temp;
 		}
 		if (pos->trip == THERMAL_TRIP_CONFIGURABLE_HI) {
-			if (pos->temp < min_of_max)
-				min_of_max = pos->temp;
-			if (pos->temp > curr_temp && pos->temp < max)
-				max = pos->temp;
+			if (pos->temp < min_of_high_thresh)
+				min_of_high_thresh = pos->temp;
 		}
 	}
 
-	pr_debug("sensor %d: min of max: %ld max of min: %ld\n",
-			sensor->sensor_id, max_of_min, min_of_max);
+	pr_debug("sensor %d: Thresholds: max of low: %ld min of high: %ld\n",
+		sensor->sensor_id, max_of_low_thresh,
+		min_of_high_thresh);
 
-	/* If we haven't found a max and min bounding the curr_temp,
-	 * use the min of max and max of min instead.
-	 */
-	if (max == LONG_MAX)
-		max = min_of_max;
-	if (min == LONG_MIN) {
-		min = get_min(sensor, max);
-		if (min == LONG_MIN)
-			min = max_of_min;
+	if ((min_of_high_thresh != sensor->threshold_max) &&
+		(min_of_high_thresh != LONG_MAX)) {
+		ret = sensor->tz->ops->set_trip_temp(sensor->tz,
+			sensor->max_idx, min_of_high_thresh);
+		if (ret) {
+			pr_err("sensor %d: Unable to set high threshold %d",
+				sensor->sensor_id, ret);
+			goto update_done;
+		}
+		sensor->threshold_max = min_of_high_thresh;
+	}
+	ret = sensor->tz->ops->activate_trip_type(sensor->tz,
+		sensor->max_idx,
+		(min_of_high_thresh == LONG_MAX) ?
+		THERMAL_TRIP_ACTIVATION_DISABLED :
+		THERMAL_TRIP_ACTIVATION_ENABLED);
+	if (ret) {
+		pr_err("sensor %d: Unable to activate high threshold %d",
+			sensor->sensor_id, ret);
+		goto update_done;
 	}
 
-	if (sensor->tz->ops->set_trip_temp) {
-		if (max != sensor->threshold_max) {
-			sensor->tz->ops->set_trip_temp(sensor->tz,
-				sensor->max_idx, max);
-			sensor->threshold_max = max;
+	if ((max_of_low_thresh != sensor->threshold_min) &&
+		(max_of_low_thresh != LONG_MIN)) {
+		ret = sensor->tz->ops->set_trip_temp(sensor->tz,
+			sensor->min_idx, max_of_low_thresh);
+		if (ret) {
+			pr_err("sensor %d: Unable to set low threshold %d",
+				sensor->sensor_id, ret);
+			goto update_done;
 		}
-		if (min != sensor->threshold_min) {
-			sensor->tz->ops->set_trip_temp(sensor->tz,
-				sensor->min_idx, min);
-			sensor->threshold_min = min;
-		}
+		sensor->threshold_min = max_of_low_thresh;
+	}
+	ret = sensor->tz->ops->activate_trip_type(sensor->tz,
+		sensor->min_idx,
+		(max_of_low_thresh == LONG_MIN) ?
+		THERMAL_TRIP_ACTIVATION_DISABLED :
+		THERMAL_TRIP_ACTIVATION_ENABLED);
+	if (ret) {
+		pr_err("sensor %d: Unable to activate low threshold %d",
+			sensor->sensor_id, ret);
+		goto update_done;
 	}
 
-	pr_debug("sensor %d: curr_temp: %ld min: %ld max: %ld\n",
-		sensor->sensor_id, curr_temp,
+	pr_debug("sensor %d: low: %ld high: %ld\n",
+		sensor->sensor_id,
 		sensor->threshold_min, sensor->threshold_max);
+
+update_done:
+	return ret;
 }
 
 static void sensor_update_work(struct work_struct *work)
 {
 	struct sensor_info *sensor = container_of(work, struct sensor_info,
 						work);
+	int ret = 0;
 	mutex_lock(&sensor->lock);
-	__update_sensor_thresholds(sensor);
+	ret = __update_sensor_thresholds(sensor);
+	if (ret)
+		pr_err("sensor %d: Error %d setting threshold\n",
+			sensor->sensor_id, ret);
 	mutex_unlock(&sensor->lock);
 }
 
@@ -202,7 +218,7 @@
 		return 0;
 
 	list_for_each_entry_safe(pos, var, &tz->sensor.threshold_list, list) {
-		if (pos->trip != trip)
+		if ((pos->trip != trip) || (!pos->active))
 			continue;
 		if (((trip == THERMAL_TRIP_CONFIGURABLE_LOW) &&
 			(pos->temp <= tz->sensor.threshold_min) &&
@@ -210,6 +226,7 @@
 			((trip == THERMAL_TRIP_CONFIGURABLE_HI) &&
 				(pos->temp >= tz->sensor.threshold_max) &&
 				(pos->temp <= temp))) {
+			pos->active = 0;
 			pos->notify(trip, temp, pos->data);
 		}
 	}
@@ -220,6 +237,29 @@
 }
 EXPORT_SYMBOL(thermal_sensor_trip);
 
+int sensor_activate_trip(uint32_t sensor_id,
+	struct sensor_threshold *threshold, bool enable)
+{
+	struct sensor_info *sensor = get_sensor(sensor_id);
+	int ret = 0;
+
+	if (!sensor || !threshold) {
+		pr_err("Sensor %d: uninitialized data\n",
+			sensor_id);
+		ret = -ENODEV;
+		goto activate_trip_exit;
+	}
+
+	mutex_lock(&sensor->lock);
+	threshold->active = (enable) ? 1 : 0;
+	ret = __update_sensor_thresholds(sensor);
+	mutex_unlock(&sensor->lock);
+
+activate_trip_exit:
+	return ret;
+}
+EXPORT_SYMBOL(sensor_activate_trip);
+
 int sensor_set_trip(uint32_t sensor_id, struct sensor_threshold *threshold)
 {
 	struct sensor_threshold *pos, *var;
@@ -241,8 +281,7 @@
 		INIT_LIST_HEAD(&threshold->list);
 		list_add(&threshold->list, &sensor->threshold_list);
 	}
-
-	__update_sensor_thresholds(sensor);
+	threshold->active = 0; /* Do not allow active threshold right away */
 	mutex_unlock(&sensor->lock);
 
 	return 0;
@@ -254,6 +293,7 @@
 {
 	struct sensor_threshold *pos, *var;
 	struct sensor_info *sensor = get_sensor(sensor_id);
+	int ret = 0;
 
 	if (!sensor)
 		return -ENODEV;
@@ -261,15 +301,16 @@
 	mutex_lock(&sensor->lock);
 	list_for_each_entry_safe(pos, var, &sensor->threshold_list, list) {
 		if (pos == threshold) {
+			pos->active = 0;
 			list_del(&pos->list);
 			break;
 		}
 	}
 
-	__update_sensor_thresholds(sensor);
+	ret = __update_sensor_thresholds(sensor);
 	mutex_unlock(&sensor->lock);
 
-	return 0;
+	return ret;
 }
 EXPORT_SYMBOL(sensor_cancel_trip);
 
@@ -283,36 +324,36 @@
 	return 0;
 }
 
+static void get_trip_threshold(struct thermal_zone_device *tz, int trip,
+	struct sensor_threshold **threshold)
+{
+	enum thermal_trip_type type;
+
+	tz->ops->get_trip_type(tz, trip, &type);
+
+	if (type == THERMAL_TRIP_CONFIGURABLE_HI)
+		*threshold = &tz->tz_threshold[0];
+	else if (type == THERMAL_TRIP_CONFIGURABLE_LOW)
+		*threshold = &tz->tz_threshold[1];
+	else
+		*threshold = NULL;
+}
+
 int sensor_set_trip_temp(struct thermal_zone_device *tz,
 		int trip, long temp)
 {
 	int ret = 0;
-	enum thermal_trip_type type;
+	struct sensor_threshold *threshold = NULL;
 
 	if (!tz->ops->get_trip_type)
 		return -EPERM;
 
-	tz->ops->get_trip_type(tz, trip, &type);
-	switch (type) {
-	case THERMAL_TRIP_CONFIGURABLE_HI:
-		tz->tz_threshold[0].temp = temp;
-		tz->tz_threshold[0].trip = THERMAL_TRIP_CONFIGURABLE_HI;
-		tz->tz_threshold[0].notify = tz_notify_trip;
-		tz->tz_threshold[0].data = tz;
-		ret = sensor_set_trip(tz->sensor.sensor_id,
-					&tz->tz_threshold[0]);
-		break;
-	case THERMAL_TRIP_CONFIGURABLE_LOW:
-		tz->tz_threshold[1].temp = temp;
-		tz->tz_threshold[1].trip = THERMAL_TRIP_CONFIGURABLE_LOW;
-		tz->tz_threshold[1].notify = tz_notify_trip;
-		tz->tz_threshold[1].data = tz;
-		ret = sensor_set_trip(tz->sensor.sensor_id,
-					&tz->tz_threshold[1]);
-		break;
-	default:
+	get_trip_threshold(tz, trip, &threshold);
+	if (threshold) {
+		threshold->temp = temp;
+		ret = sensor_set_trip(tz->sensor.sensor_id, threshold);
+	} else {
 		ret = tz->ops->set_trip_temp(tz, trip, temp);
-		break;
 	}
 
 	return ret;
@@ -333,10 +374,12 @@
 	INIT_LIST_HEAD(&sensor->threshold_list);
 	INIT_LIST_HEAD(&tz->tz_threshold[0].list);
 	INIT_LIST_HEAD(&tz->tz_threshold[1].list);
-	tz->tz_threshold[0].notify = NULL;
-	tz->tz_threshold[0].data = NULL;
-	tz->tz_threshold[1].notify = NULL;
-	tz->tz_threshold[1].data = NULL;
+	tz->tz_threshold[0].notify = tz_notify_trip;
+	tz->tz_threshold[0].data = tz;
+	tz->tz_threshold[0].trip = THERMAL_TRIP_CONFIGURABLE_HI;
+	tz->tz_threshold[1].notify = tz_notify_trip;
+	tz->tz_threshold[1].data = tz;
+	tz->tz_threshold[1].trip = THERMAL_TRIP_CONFIGURABLE_LOW;
 	list_add(&sensor->sensor_list, &sensor_info_list);
 	INIT_WORK(&sensor->work, sensor_update_work);
 
@@ -489,23 +532,40 @@
 		const char *buf, size_t count)
 {
 	struct thermal_zone_device *tz = to_thermal_zone(dev);
-	int trip, result;
+	int trip, result = 0;
+	bool activate;
+	struct sensor_threshold *threshold = NULL;
 
-	if (!tz->ops->activate_trip_type)
-		return -EPERM;
+	if (!tz->ops->get_trip_type ||
+		!tz->ops->activate_trip_type) {
+		result = -EPERM;
+		goto trip_activate_exit;
+	}
 
-	if (!sscanf(attr->attr.name, "trip_point_%d_type", &trip))
-		return -EINVAL;
-
-	if (!strncmp(buf, "enabled", sizeof("enabled")))
-		result = tz->ops->activate_trip_type(tz, trip,
-					THERMAL_TRIP_ACTIVATION_ENABLED);
-	else if (!strncmp(buf, "disabled", sizeof("disabled")))
-		result = tz->ops->activate_trip_type(tz, trip,
-					THERMAL_TRIP_ACTIVATION_DISABLED);
-	else
+	if (!sscanf(attr->attr.name, "trip_point_%d_type", &trip)) {
 		result = -EINVAL;
+		goto trip_activate_exit;
+	}
 
+	if (!strcmp(buf, "enabled")) {
+		activate = true;
+	} else if (!strcmp(buf, "disabled")) {
+		activate = false;
+	} else {
+		result = -EINVAL;
+		goto trip_activate_exit;
+	}
+
+	get_trip_threshold(tz, trip, &threshold);
+	if (threshold)
+		result = sensor_activate_trip(tz->sensor.sensor_id,
+			threshold, activate);
+	else
+		result = tz->ops->activate_trip_type(tz, trip,
+			activate ? THERMAL_TRIP_ACTIVATION_ENABLED :
+			THERMAL_TRIP_ACTIVATION_DISABLED);
+
+trip_activate_exit:
 	if (result)
 		return result;
 
diff --git a/drivers/tty/serial/msm_serial_hs.c b/drivers/tty/serial/msm_serial_hs.c
index a243a05..078929b 100644
--- a/drivers/tty/serial/msm_serial_hs.c
+++ b/drivers/tty/serial/msm_serial_hs.c
@@ -155,7 +155,6 @@
 	struct tasklet_struct tlet;
 	struct msm_hs_sps_ep_conn_data prod;
 };
-
 enum buffer_states {
 	NONE_PENDING = 0x0,
 	FIFO_OVERRUN = 0x1,
@@ -219,6 +218,7 @@
 	struct msm_bus_scale_pdata *bus_scale_table;
 	bool rx_discard_flush_issued;
 	int rx_count_callback;
+	bool rx_bam_inprogress;
 	unsigned int *reg_ptr;
 };
 
@@ -998,6 +998,14 @@
 	mutex_lock(&msm_uport->clk_mutex);
 	msm_hs_write(uport, UART_DM_IMR, 0);
 
+	/* Clear the Rx Ready Ctl bit - This ensures that
+	* flow control lines stop the other side from sending
+	* data while we change the parameters
+	*/
+	data = msm_hs_read(uport, UART_DM_MR1);
+	data &= ~UARTDM_MR1_RX_RDY_CTL_BMSK;
+	msm_hs_write(uport, UART_DM_MR1, data);
+
 	/*
 	 * Disable Rx channel of UARTDM
 	 * DMA Rx Stall happens if enqueue and flush of Rx command happens
@@ -1071,18 +1079,6 @@
 	/* write parity/bits per char/stop bit configuration */
 	msm_hs_write(uport, UART_DM_MR2, data);
 
-	/* Configure HW flow control */
-	data = msm_hs_read(uport, UART_DM_MR1);
-
-	data &= ~(UARTDM_MR1_CTS_CTL_BMSK | UARTDM_MR1_RX_RDY_CTL_BMSK);
-
-	if (c_cflag & CRTSCTS) {
-		data |= UARTDM_MR1_CTS_CTL_BMSK;
-		data |= UARTDM_MR1_RX_RDY_CTL_BMSK;
-	}
-
-	msm_hs_write(uport, UART_DM_MR1, data);
-
 	uport->ignore_status_mask = termios->c_iflag & INPCK;
 	uport->ignore_status_mask |= termios->c_iflag & IGNPAR;
 	uport->ignore_status_mask |= termios->c_iflag & IGNBRK;
@@ -1106,6 +1102,10 @@
 		 */
 		mb();
 		if (is_blsp_uart(msm_uport)) {
+			if (msm_uport->rx_bam_inprogress)
+				ret = wait_event_timeout(msm_uport->rx.wait,
+					msm_uport->rx_bam_inprogress == false,
+					RX_FLUSH_COMPLETE_TIMEOUT);
 			ret = sps_disconnect(sps_pipe_handle);
 			if (ret)
 				pr_err("%s(): sps_disconnect failed\n",
@@ -1127,6 +1127,20 @@
 		}
 	}
 
+	/* Configure HW flow control
+	 * UART Core would see status of CTS line when it is sending data
+	 * to remote uart to confirm that it can receive or not.
+	 * UART Core would trigger RFR if it is not having any space with
+	 * RX FIFO.
+	 */
+	data = msm_hs_read(uport, UART_DM_MR1);
+	data &= ~(UARTDM_MR1_CTS_CTL_BMSK | UARTDM_MR1_RX_RDY_CTL_BMSK);
+	if (c_cflag & CRTSCTS) {
+		data |= UARTDM_MR1_CTS_CTL_BMSK;
+		data |= UARTDM_MR1_RX_RDY_CTL_BMSK;
+	}
+	msm_hs_write(uport, UART_DM_MR1, data);
+
 	msm_hs_write(uport, UART_DM_IMR, msm_uport->imr_reg);
 	mb();
 	mutex_unlock(&msm_uport->clk_mutex);
@@ -1358,10 +1372,13 @@
 	msm_uport->rx.flush = FLUSH_NONE;
 
 	if (is_blsp_uart(msm_uport)) {
+		msm_uport->rx_bam_inprogress = true;
 		sps_pipe_handle = rx->prod.pipe_handle;
 		/* Queue transfer request to SPS */
 		sps_transfer_one(sps_pipe_handle, rx->rbuffer,
 			UARTDM_RX_BUF_SIZE, msm_uport, flags);
+		msm_uport->rx_bam_inprogress = false;
+		wake_up(&msm_uport->rx.wait);
 	} else {
 		msm_dmov_enqueue_cmd(msm_uport->dma_rx_channel,
 				&msm_uport->rx.xfer);
@@ -1531,10 +1548,13 @@
 	if (!msm_uport->rx.buffer_pending) {
 		if (is_blsp_uart(msm_uport)) {
 			msm_uport->rx.flush = FLUSH_NONE;
+			msm_uport->rx_bam_inprogress = true;
 			sps_pipe_handle = rx->prod.pipe_handle;
 			/* Queue transfer request to SPS */
 			sps_transfer_one(sps_pipe_handle, rx->rbuffer,
 				UARTDM_RX_BUF_SIZE, msm_uport, sps_flags);
+			msm_uport->rx_bam_inprogress = false;
+			wake_up(&msm_uport->rx.wait);
 		} else {
 			msm_hs_start_rx_locked(uport);
 		}
@@ -2832,9 +2852,9 @@
 	/* Now save the sps pipe handle */
 	ep->pipe_handle = sps_pipe_handle;
 	pr_debug("msm_serial_hs: success !! %s: pipe_handle=0x%x\n"
-		"desc_fifo.phys_base=0x%x\n",
+		"desc_fifo.phys_base=0x%llx\n",
 		is_producer ? "READ" : "WRITE",
-		(u32)sps_pipe_handle, sps_config->desc.phys_base);
+		(u32) sps_pipe_handle, (u64) sps_config->desc.phys_base);
 	return 0;
 
 get_config_err:
diff --git a/drivers/tty/serial/msm_serial_hs_lite.c b/drivers/tty/serial/msm_serial_hs_lite.c
index a4a4f28..0ff8ad7 100644
--- a/drivers/tty/serial/msm_serial_hs_lite.c
+++ b/drivers/tty/serial/msm_serial_hs_lite.c
@@ -523,6 +523,10 @@
 {
 	struct msm_hsl_port *msm_hsl_port = UART_TO_MSM(port);
 
+	if (port->suspended) {
+		pr_err("%s: System is in Suspend state\n", __func__);
+		return;
+	}
 	msm_hsl_port->imr |= UARTDM_ISR_TXLEV_BMSK;
 	msm_hsl_write(port, msm_hsl_port->imr,
 		regmap[msm_hsl_port->ver_id][UARTDM_IMR]);
diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig
index 6f3ea9b..ad66113 100644
--- a/drivers/uio/Kconfig
+++ b/drivers/uio/Kconfig
@@ -111,4 +111,11 @@
 	  To compile this driver as a module, choose M here: the module
 	  will be called uio_pruss.
 
+config UIO_MSM_SHAREDMEM
+	bool "MSM shared memory driver"
+	default n
+	help
+	  Provides the clients with their respective alloted shared memory
+	  addresses which are used as transport buffer.
+
 endif
diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile
index d4dd9a5..c4d177a 100644
--- a/drivers/uio/Makefile
+++ b/drivers/uio/Makefile
@@ -7,3 +7,4 @@
 obj-$(CONFIG_UIO_PCI_GENERIC)	+= uio_pci_generic.o
 obj-$(CONFIG_UIO_NETX)	+= uio_netx.o
 obj-$(CONFIG_UIO_PRUSS)         += uio_pruss.o
+obj-$(CONFIG_UIO_MSM_SHAREDMEM) += msm_sharedmem.o
diff --git a/drivers/uio/msm_sharedmem.c b/drivers/uio/msm_sharedmem.c
new file mode 100644
index 0000000..438f002
--- /dev/null
+++ b/drivers/uio/msm_sharedmem.c
@@ -0,0 +1,87 @@
+/* Copyright (c) 2013, The Linux Foundation. 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 pr_fmt(fmt) "%s: " fmt, __func__
+
+#include <linux/uio_driver.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/err.h>
+
+#define DRIVER_NAME "msm_sharedmem"
+
+static int msm_sharedmem_probe(struct platform_device *pdev)
+{
+	int ret = 0;
+	struct uio_info *info = NULL;
+	struct resource *clnt_res = NULL;
+
+	/* Get the addresses from platform-data */
+	if (!pdev->dev.of_node) {
+		pr_err("Node not found\n");
+		ret = -ENODEV;
+		goto out;
+	}
+	clnt_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!clnt_res) {
+		pr_err("resource not found\n");
+		return -ENODEV;
+	}
+
+	info = devm_kzalloc(&pdev->dev, sizeof(struct uio_info), GFP_KERNEL);
+	if (!info)
+		return -ENOMEM;
+
+	info->name = clnt_res->name;
+	info->version = "1.0";
+	info->mem[0].addr = clnt_res->start;
+	info->mem[0].size = resource_size(clnt_res);
+	info->mem[0].memtype = UIO_MEM_PHYS;
+
+	/* Setup device */
+	ret = uio_register_device(&pdev->dev, info);
+	if (ret)
+		goto out;
+
+	dev_set_drvdata(&pdev->dev, info);
+	pr_debug("Device created for client '%s'\n", clnt_res->name);
+out:
+	return ret;
+}
+
+static int msm_sharedmem_remove(struct platform_device *pdev)
+{
+	struct uio_info *info = dev_get_drvdata(&pdev->dev);
+
+	uio_unregister_device(info);
+
+	return 0;
+}
+
+static struct of_device_id msm_sharedmem_of_match[] = {
+	{.compatible = "qcom,sharedmem-uio",},
+	{},
+};
+MODULE_DEVICE_TABLE(of, msm_sharedmem_of_match);
+
+static struct platform_driver msm_sharedmem_driver = {
+	.probe          = msm_sharedmem_probe,
+	.remove         = msm_sharedmem_remove,
+	.driver         = {
+		.name   = DRIVER_NAME,
+		.owner	= THIS_MODULE,
+		.of_match_table = msm_sharedmem_of_match,
+	},
+};
+
+module_platform_driver(msm_sharedmem_driver);
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 98c6884..90dd115 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -153,8 +153,7 @@
 	reg |= DWC3_GCTL_CORESOFTRESET;
 	dwc3_writel(dwc->regs, DWC3_GCTL, reg);
 
-	if (dwc->revision >= DWC3_REVISION_230A)
-		dwc3_notify_event(dwc, DWC3_CONTROLLER_RESET_EVENT);
+	dwc3_notify_event(dwc, DWC3_CONTROLLER_RESET_EVENT);
 
 	/* Assert USB3 PHY reset */
 	reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
@@ -185,8 +184,7 @@
 	reg &= ~DWC3_GCTL_CORESOFTRESET;
 	dwc3_writel(dwc->regs, DWC3_GCTL, reg);
 
-	if (dwc->revision >= DWC3_REVISION_230A)
-		dwc3_notify_event(dwc, DWC3_CONTROLLER_POST_RESET_EVENT);
+	dwc3_notify_event(dwc, DWC3_CONTROLLER_POST_RESET_EVENT);
 }
 
 /**
@@ -503,6 +501,7 @@
 {
 	dwc3_core_init(dwc);
 	dwc3_gadget_restart(dwc);
+	dwc3_notify_event(dwc, DWC3_CONTROLLER_POST_INITIALIZATION_EVENT);
 }
 
 static void (*notify_event) (struct dwc3 *, unsigned);
@@ -682,6 +681,8 @@
 		goto err2;
 	}
 
+	dwc3_notify_event(dwc, DWC3_CONTROLLER_POST_INITIALIZATION_EVENT);
+
 	return 0;
 
 err2:
diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
index 068dd5f..1be2550 100644
--- a/drivers/usb/dwc3/core.h
+++ b/drivers/usb/dwc3/core.h
@@ -649,6 +649,7 @@
 #define DWC3_CONTROLLER_ERROR_EVENT			0
 #define DWC3_CONTROLLER_RESET_EVENT			1
 #define DWC3_CONTROLLER_POST_RESET_EVENT		2
+#define DWC3_CONTROLLER_POST_INITIALIZATION_EVENT	3
 /**
  * struct dwc3 - representation of our controller
  * @ctrl_req: usb control request which is used for ep0
diff --git a/drivers/usb/dwc3/dwc3-msm.c b/drivers/usb/dwc3/dwc3-msm.c
index 784ff3f..97592c4 100644
--- a/drivers/usb/dwc3/dwc3-msm.c
+++ b/drivers/usb/dwc3/dwc3-msm.c
@@ -1505,6 +1505,9 @@
 {
 	struct dwc3_msm *mdwc = dev_get_drvdata(dwc->dev->parent);
 
+	if (dwc->revision < DWC3_REVISION_230A)
+		return;
+
 	switch (event) {
 	case DWC3_CONTROLLER_ERROR_EVENT:
 		dev_info(mdwc->dev, "DWC3_CONTROLLER_ERROR_EVENT received\n");
@@ -1526,6 +1529,10 @@
 					DWC3_CONTROLLER_POST_RESET_EVENT);
 		dwc->tx_fifo_size = mdwc->tx_fifo_size;
 		break;
+	case DWC3_CONTROLLER_POST_INITIALIZATION_EVENT:
+		/* clear LANE0_PWR_PRESENT bit after initialization is done */
+		dwc3_msm_write_readback(mdwc->base, SS_PHY_CTRL_REG, (1 << 24),
+									0x0);
 	default:
 		dev_dbg(mdwc->dev, "unknown dwc3 event\n");
 		break;
@@ -2281,8 +2288,12 @@
 		if (mdwc->otg_xceiv && !mdwc->ext_inuse &&
 		    (mdwc->ext_xceiv.otg_capability || !init)) {
 			mdwc->ext_xceiv.bsv = val->intval;
+			/*
+			 * set debouncing delay to 120msec. Otherwise battery
+			 * charging CDP complaince test fails if delay > 120ms.
+			 */
 			queue_delayed_work(system_nrt_wq,
-							&mdwc->resume_work, 20);
+							&mdwc->resume_work, 12);
 
 			if (!init)
 				init = true;
diff --git a/drivers/usb/dwc3/dwc3_otg.c b/drivers/usb/dwc3/dwc3_otg.c
index 9599936..cacd635 100644
--- a/drivers/usb/dwc3/dwc3_otg.c
+++ b/drivers/usb/dwc3/dwc3_otg.c
@@ -93,6 +93,19 @@
 	return 0;
 }
 
+static void dwc3_otg_set_hsphy_auto_suspend(struct dwc3_otg *dotg, bool susp)
+{
+	struct dwc3 *dwc = dotg->dwc;
+	u32 reg;
+
+	reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
+	if (susp)
+		reg |= DWC3_GUSB2PHYCFG_SUSPHY;
+	else
+		reg &= ~(DWC3_GUSB2PHYCFG_SUSPHY);
+	dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
+}
+
 /**
  * dwc3_otg_set_host_power - Enable port power control for host operation
  *
@@ -194,6 +207,7 @@
 		 * remove_hcd, But we may not use standard set_host method
 		 * anymore.
 		 */
+		dwc3_otg_set_hsphy_auto_suspend(dotg, true);
 		dwc3_otg_set_host_regs(dotg);
 		/*
 		 * FIXME If micro A cable is disconnected during system suspend,
@@ -242,6 +256,7 @@
 						ext_xceiv->ext_block_reset)
 			ext_xceiv->ext_block_reset(ext_xceiv, true);
 
+		dwc3_otg_set_hsphy_auto_suspend(dotg, false);
 		dwc3_otg_set_peripheral_regs(dotg);
 
 		/* re-init core and OTG registers as block reset clears these */
@@ -309,12 +324,14 @@
 						ext_xceiv->ext_block_reset)
 			ext_xceiv->ext_block_reset(ext_xceiv, false);
 
+		dwc3_otg_set_hsphy_auto_suspend(dotg, true);
 		dwc3_otg_set_peripheral_regs(dotg);
 		usb_gadget_vbus_connect(otg->gadget);
 	} else {
 		dev_dbg(otg->phy->dev, "%s: turn off gadget %s\n",
 					__func__, otg->gadget->name);
 		usb_gadget_vbus_disconnect(otg->gadget);
+		dwc3_otg_set_hsphy_auto_suspend(dotg, false);
 	}
 
 	return 0;
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 38c4b86..ad3a3a9 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2623,13 +2623,10 @@
 		}
 	}
 
-	/*
-	 * Notify suspend only to gadget driver, but not resume. Resume is
-	 * notified as part of wakeup event in dwc3_gadget_wakeup_interrupt().
-	 */
 	if (next == DWC3_LINK_STATE_U0) {
 		if (dwc->link_state == DWC3_LINK_STATE_U3) {
 			dbg_event(0xFF, "RESUME", 0);
+			dwc->gadget_driver->resume(&dwc->gadget);
 		}
 	} else if (next == DWC3_LINK_STATE_U3) {
 		dbg_event(0xFF, "SUSPEND", 0);
@@ -2920,7 +2917,11 @@
 
 		dwc3_writel(dwc->regs, DWC3_DCTL, reg);
 
-		dwc3_gadget_usb2_phy_suspend(dwc, true);
+		/*
+		 * Clear autosuspend bit in dwc3 register for USB2. It will be
+		 * enabled before setting run/stop bit.
+		 */
+		dwc3_gadget_usb2_phy_suspend(dwc, false);
 		dwc3_gadget_usb3_phy_suspend(dwc, true);
 	}
 
diff --git a/drivers/usb/gadget/android.c b/drivers/usb/gadget/android.c
index 6765078..877b944 100644
--- a/drivers/usb/gadget/android.c
+++ b/drivers/usb/gadget/android.c
@@ -1770,7 +1770,7 @@
 	struct fsg_common *common;
 	int err;
 	int i;
-	const char *name[2];
+	const char *name[3];
 
 	config = kzalloc(sizeof(struct mass_storage_function_config),
 								GFP_KERNEL);
@@ -2181,6 +2181,22 @@
 	}
 }
 
+static inline void check_streaming_func(struct usb_gadget *gadget,
+		struct android_usb_platform_data *pdata,
+		char *name)
+{
+	int i;
+
+	for (i = 0; i < pdata->streaming_func_count; i++) {
+		if (!strcmp(name,
+			pdata->streaming_func[i])) {
+			pr_debug("set streaming_enabled to true\n");
+			gadget->streaming_enabled = true;
+			break;
+		}
+	}
+}
+
 static int android_enable_function(struct android_dev *dev,
 				   struct android_configuration *conf,
 				   char *name)
@@ -2188,6 +2204,9 @@
 	struct android_usb_function **functions = dev->functions;
 	struct android_usb_function *f;
 	struct android_usb_function_holder *f_holder;
+	struct android_usb_platform_data *pdata = dev->pdata;
+	struct usb_gadget *gadget = dev->cdev->gadget;
+
 	while ((f = *functions++)) {
 		if (!strcmp(name, f->name)) {
 			if (f->android_dev && f->android_dev != dev)
@@ -2205,6 +2224,13 @@
 				f_holder->f = f;
 				list_add_tail(&f_holder->enabled_list,
 					      &conf->enabled_functions);
+				pr_debug("func:%s is enabled.\n", f->name);
+				/*
+				 * compare enable function with streaming func
+				 * list and based on the same request streaming.
+				 */
+				check_streaming_func(gadget, pdata, f->name);
+
 				return 0;
 			}
 		}
@@ -2577,6 +2603,10 @@
 {
 	struct android_dev *dev = cdev_to_android_dev(c->cdev);
 
+	if (c->cdev->gadget->streaming_enabled) {
+		c->cdev->gadget->streaming_enabled = false;
+		pr_debug("setting streaming_enabled to false.\n");
+	}
 	android_unbind_enabled_functions(dev, c);
 }
 
@@ -2745,8 +2775,10 @@
 	unsigned long flags;
 
 	spin_lock_irqsave(&cdev->lock, flags);
-	dev->suspended = 1;
-	schedule_work(&dev->work);
+	if (!dev->suspended) {
+		dev->suspended = 1;
+		schedule_work(&dev->work);
+	}
 	spin_unlock_irqrestore(&cdev->lock, flags);
 
 	composite_suspend(gadget);
@@ -2759,8 +2791,10 @@
 	unsigned long flags;
 
 	spin_lock_irqsave(&cdev->lock, flags);
-	dev->suspended = 0;
-	schedule_work(&dev->work);
+	if (dev->suspended) {
+		dev->suspended = 0;
+		schedule_work(&dev->work);
+	}
 	spin_unlock_irqrestore(&cdev->lock, flags);
 
 	composite_resume(gadget);
@@ -2895,7 +2929,7 @@
 	struct android_usb_platform_data *pdata;
 	struct android_dev *android_dev;
 	struct resource *res;
-	int ret = 0;
+	int ret = 0, i, len = 0;
 
 	if (pdev->dev.of_node) {
 		dev_dbg(&pdev->dev, "device tree enabled\n");
@@ -2912,6 +2946,33 @@
 				"qcom,android-usb-cdrom");
 		pdata->internal_ums = of_property_read_bool(pdev->dev.of_node,
 				"qcom,android-usb-internal-ums");
+		len = of_property_count_strings(pdev->dev.of_node,
+				"qcom,streaming-func");
+		if (len > MAX_STREAMING_FUNCS) {
+			pr_err("Invalid number of functions used.\n");
+			return -EINVAL;
+		}
+
+		for (i = 0; i < len; i++) {
+			const char *name = NULL;
+
+			of_property_read_string_index(pdev->dev.of_node,
+				"qcom,streaming-func", i, &name);
+			if (!name)
+				continue;
+
+			if (sizeof(name) > FUNC_NAME_LEN) {
+				pr_err("Function name is bigger than allowed.\n");
+				continue;
+			}
+
+			strlcpy(pdata->streaming_func[i], name,
+				sizeof(pdata->streaming_func[i]));
+			pr_debug("name of streaming function:%s\n",
+				pdata->streaming_func[i]);
+		}
+
+		pdata->streaming_func_count = len;
 	} else {
 		pdata = pdev->dev.platform_data;
 	}
diff --git a/drivers/usb/gadget/ci13xxx_msm.c b/drivers/usb/gadget/ci13xxx_msm.c
index a9c073b..f1e4220 100644
--- a/drivers/usb/gadget/ci13xxx_msm.c
+++ b/drivers/usb/gadget/ci13xxx_msm.c
@@ -271,6 +271,10 @@
 				1 << (pdata->log2_itc-1);
 
 		is_l1_supported = pdata->l1_supported;
+		/* Set ahb2ahb bypass flag if it is requested. */
+		if (pdata->enable_ahb2ahb_bypass)
+			ci13xxx_msm_udc_driver.flags |=
+				CI13XXX_ENABLE_AHB2AHB_BYPASS;
 	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c
index 3f8d924..6a92684 100644
--- a/drivers/usb/gadget/ci13xxx_udc.c
+++ b/drivers/usb/gadget/ci13xxx_udc.c
@@ -70,10 +70,6 @@
 #include <mach/usb_trace.h>
 #include "ci13xxx_udc.h"
 
-/* Turns on streaming. overrides CI13XXX_DISABLE_STREAMING */
-static unsigned int streaming;
-module_param(streaming, uint, S_IRUGO | S_IWUSR);
-
 /******************************************************************************
  * DEFINE
  *****************************************************************************/
@@ -392,20 +388,32 @@
 static int hw_device_state(u32 dma)
 {
 	struct ci13xxx *udc = _udc;
+	struct usb_gadget *gadget = &udc->gadget;
 
 	if (dma) {
-		if (streaming || !(udc->udc_driver->flags &
-				CI13XXX_DISABLE_STREAMING))
+		if (gadget->streaming_enabled || !(udc->udc_driver->flags &
+				CI13XXX_DISABLE_STREAMING)) {
 			hw_cwrite(CAP_USBMODE, USBMODE_SDIS, 0);
-		else
+			pr_debug("%s(): streaming mode is enabled. USBMODE:%x\n",
+				__func__, hw_cread(CAP_USBMODE, ~0));
+		} else {
 			hw_cwrite(CAP_USBMODE, USBMODE_SDIS, USBMODE_SDIS);
-
+			pr_debug("%s(): streaming mode is disabled. USBMODE:%x\n",
+				__func__, hw_cread(CAP_USBMODE, ~0));
+		}
 		hw_cwrite(CAP_ENDPTLISTADDR, ~0, dma);
 
 		if (udc->udc_driver->notify_event)
 			udc->udc_driver->notify_event(udc,
 				CI13XXX_CONTROLLER_CONNECT_EVENT);
 
+		/* Set BIT(31) to enable AHB2AHB Bypass functionality */
+		if (udc->udc_driver->flags & CI13XXX_ENABLE_AHB2AHB_BYPASS) {
+			hw_awrite(ABS_AHBMODE, AHB2AHB_BYPASS, AHB2AHB_BYPASS);
+			pr_debug("%s(): ByPass Mode is enabled. AHBMODE:%x\n",
+					__func__, hw_aread(ABS_AHBMODE, ~0));
+		}
+
 		/* interrupt, error, port change, reset, sleep/suspend */
 		hw_cwrite(CAP_USBINTR, ~0,
 			     USBi_UI|USBi_UEI|USBi_PCI|USBi_URI|USBi_SLI);
@@ -413,6 +421,12 @@
 	} else {
 		hw_cwrite(CAP_USBCMD, USBCMD_RS, 0);
 		hw_cwrite(CAP_USBINTR, ~0, 0);
+		/* Clear BIT(31) to disable AHB2AHB Bypass functionality */
+		if (udc->udc_driver->flags & CI13XXX_ENABLE_AHB2AHB_BYPASS) {
+			hw_awrite(ABS_AHBMODE, AHB2AHB_BYPASS, 0);
+			pr_debug("%s(): ByPass Mode is disabled. AHBMODE:%x\n",
+					__func__, hw_aread(ABS_AHBMODE, ~0));
+		}
 	}
 	return 0;
 }
diff --git a/drivers/usb/gadget/ci13xxx_udc.h b/drivers/usb/gadget/ci13xxx_udc.h
index f90ea86..47fe138 100644
--- a/drivers/usb/gadget/ci13xxx_udc.h
+++ b/drivers/usb/gadget/ci13xxx_udc.h
@@ -136,6 +136,7 @@
 #define CI13XXX_DISABLE_STREAMING	BIT(3)
 #define CI13XXX_ZERO_ITC		BIT(4)
 #define CI13XXX_IS_OTG			BIT(5)
+#define CI13XXX_ENABLE_AHB2AHB_BYPASS	BIT(6)
 
 #define CI13XXX_CONTROLLER_RESET_EVENT			0
 #define CI13XXX_CONTROLLER_CONNECT_EVENT		1
@@ -197,6 +198,9 @@
 /* TESTMODE */
 #define TESTMODE_FORCE        BIT(0)
 
+/* AHB_MODE */
+#define AHB2AHB_BYPASS	      BIT(31)
+
 /* USBCMD */
 #define USBCMD_RS             BIT(0)
 #define USBCMD_RST            BIT(1)
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index e4fb26a..7d63bf9 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1356,6 +1356,14 @@
 			if (c && c->setup)
 				value = c->setup(c, ctrl);
 		}
+		if (value == USB_GADGET_DELAYED_STATUS) {
+			DBG(cdev,
+			 "%s: interface %d (%s) requested delayed status\n",
+					__func__, intf, f->name);
+			cdev->delayed_status++;
+			DBG(cdev, "delayed_status count %d\n",
+					cdev->delayed_status);
+		}
 
 		goto done;
 	}
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index 2f35315..4410e99 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -637,7 +637,10 @@
 		 */
 		DBG(fsg, "bulk reset request\n");
 		raise_exception(fsg->common, FSG_STATE_RESET);
-		return DELAYED_STATUS;
+		if (fsg->common->cdev)
+			return USB_GADGET_DELAYED_STATUS;
+		else
+			return DELAYED_STATUS;
 
 	case US_BULK_GET_MAX_LUN:
 		if (ctrl->bRequestType !=
@@ -2698,8 +2701,13 @@
 				       &common->fsg->atomic_bitflags))
 			usb_ep_clear_halt(common->fsg->bulk_in);
 
-		if (common->ep0_req_tag == exception_req_tag)
-			ep0_queue(common);	/* Complete the status stage */
+		if (common->ep0_req_tag == exception_req_tag) {
+			/* Complete the status stage */
+			if (common->cdev)
+				usb_composite_setup_continue(common->cdev);
+			else
+				ep0_queue(common);
+		}
 
 		/*
 		 * Technically this should go here, but it would only be
diff --git a/drivers/usb/gadget/f_qdss.c b/drivers/usb/gadget/f_qdss.c
index f649248..7e474f3 100644
--- a/drivers/usb/gadget/f_qdss.c
+++ b/drivers/usb/gadget/f_qdss.c
@@ -18,6 +18,7 @@
 #include <linux/usb/usb_qdss.h>
 #include <linux/usb/msm_hsusb.h>
 
+#include "gadget_chips.h"
 #include "f_qdss.h"
 #include "u_qdss.c"
 
@@ -395,7 +396,9 @@
 			goto fail;
 		}
 	}
-	dwc3_tx_fifo_resize_request(qdss->data, true);
+
+	if (gadget_is_dwc3(gadget))
+		dwc3_tx_fifo_resize_request(qdss->data, true);
 
 	return 0;
 fail:
@@ -408,12 +411,15 @@
 static void qdss_unbind(struct usb_configuration *c, struct usb_function *f)
 {
 	struct f_qdss  *qdss = func_to_qdss(f);
+	struct usb_gadget *gadget = c->cdev->gadget;
 
 	pr_debug("qdss_unbind\n");
 
-	dwc3_tx_fifo_resize_request(qdss->data, false);
+	if (gadget_is_dwc3(gadget))
+		dwc3_tx_fifo_resize_request(qdss->data, false);
+
 	clear_eps(f);
-	clear_desc(c->cdev->gadget, f);
+	clear_desc(gadget, f);
 }
 
 static void qdss_eps_disable(struct usb_function *f)
@@ -605,7 +611,7 @@
 
 	spin_lock_irqsave(&d_lock, flags);
 	list_for_each_entry(ch, &usb_qdss_ch_list, list) {
-		if (!strncmp(name, ch->name, sizeof(ch->name))) {
+		if (!strcmp(name, ch->name)) {
 			found = 1;
 			break;
 		}
@@ -767,7 +773,7 @@
 	spin_lock_irqsave(&d_lock, flags);
 	/* Check if we already have a channel with this name */
 	list_for_each_entry(ch, &usb_qdss_ch_list, list) {
-		if (!strncmp(name, ch->name, sizeof(ch->name))) {
+		if (!strcmp(name, ch->name)) {
 			found = 1;
 			break;
 		}
@@ -824,7 +830,8 @@
 	ch->app_conn = 0;
 	spin_unlock_irqrestore(&d_lock, flags);
 
-	msm_dwc3_restart_usb_session(gadget);
+	if (gadget_is_dwc3(gadget))
+		msm_dwc3_restart_usb_session(gadget);
 }
 EXPORT_SYMBOL(usb_qdss_close);
 
diff --git a/drivers/usb/gadget/f_rndis.c b/drivers/usb/gadget/f_rndis.c
index 7903764..aee7b58 100644
--- a/drivers/usb/gadget/f_rndis.c
+++ b/drivers/usb/gadget/f_rndis.c
@@ -379,13 +379,35 @@
 					struct sk_buff *skb)
 {
 	struct sk_buff *skb2;
+	struct rndis_packet_msg_type *header = NULL;
+	struct f_rndis *rndis = func_to_rndis(&port->func);
 
-	skb2 = skb_realloc_headroom(skb, sizeof(struct rndis_packet_msg_type));
-	if (skb2)
-		rndis_add_hdr(skb2);
+	if (rndis->port.multi_pkt_xfer) {
+		if (port->header) {
+			header = port->header;
+			memset(header, 0, sizeof(*header));
+			header->MessageType = cpu_to_le32(REMOTE_NDIS_PACKET_MSG);
+			header->MessageLength = cpu_to_le32(skb->len +
+							sizeof(*header));
+			header->DataOffset = cpu_to_le32(36);
+			header->DataLength = cpu_to_le32(skb->len);
+			pr_debug("MessageLength:%d DataLength:%d\n",
+						header->MessageLength,
+						header->DataLength);
+			return skb;
+		} else {
+			pr_err("RNDIS header is NULL.\n");
+			return NULL;
+		}
+	} else {
+		skb2 = skb_realloc_headroom(skb,
+				sizeof(struct rndis_packet_msg_type));
+		if (skb2)
+			rndis_add_hdr(skb2);
 
-	dev_kfree_skb_any(skb);
-	return skb2;
+		dev_kfree_skb_any(skb);
+		return skb2;
+	}
 }
 
 static void rndis_response_available(void *_rndis)
diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c
index 9e789c5..734619f 100644
--- a/drivers/usb/gadget/u_ether.c
+++ b/drivers/usb/gadget/u_ether.c
@@ -197,6 +197,7 @@
 }
 
 static void rx_complete(struct usb_ep *ep, struct usb_request *req);
+static void tx_complete(struct usb_ep *ep, struct usb_request *req);
 
 static int
 rx_submit(struct eth_dev *dev, struct usb_request *req, gfp_t gfp_flags)
@@ -256,7 +257,6 @@
 
 	req->buf = skb->data;
 	req->length = size;
-	req->complete = rx_complete;
 	req->context = skb;
 
 	retval = usb_ep_queue(out, req, gfp_flags);
@@ -349,6 +349,7 @@
 {
 	unsigned		i;
 	struct usb_request	*req;
+	bool			usb_in;
 
 	if (!n)
 		return -ENOMEM;
@@ -359,10 +360,22 @@
 		if (i-- == 0)
 			goto extra;
 	}
+
+	if (ep->desc->bEndpointAddress & USB_DIR_IN)
+		usb_in = true;
+	else
+		usb_in = false;
+
 	while (i--) {
 		req = usb_ep_alloc_request(ep, GFP_ATOMIC);
 		if (!req)
 			return list_empty(list) ? -ENOMEM : 0;
+		/* update completion handler */
+		if (usb_in)
+			req->complete = tx_complete;
+		else
+			req->complete = rx_complete;
+
 		list_add(&req->list, list);
 	}
 	return 0;
@@ -479,7 +492,7 @@
 
 static void tx_complete(struct usb_ep *ep, struct usb_request *req)
 {
-	struct sk_buff	*skb = req->context;
+	struct sk_buff	*skb;
 	struct eth_dev	*dev;
 	struct net_device *net;
 	struct usb_request *new_req;
@@ -553,7 +566,6 @@
 				}
 
 				new_req->length = length;
-				new_req->complete = tx_complete;
 				retval = usb_ep_queue(in, new_req, GFP_ATOMIC);
 				switch (retval) {
 				default:
@@ -585,6 +597,7 @@
 			spin_unlock(&dev->req_lock);
 		}
 	} else {
+		skb = req->context;
 		spin_unlock(&dev->req_lock);
 		dev_kfree_skb_any(skb);
 	}
@@ -613,7 +626,7 @@
 	list_for_each(act, &dev->tx_reqs) {
 		req = container_of(act, struct usb_request, list);
 		if (!req->buf)
-			req->buf = kmalloc(dev->tx_req_bufsize,
+			req->buf = kzalloc(dev->tx_req_bufsize,
 						GFP_ATOMIC);
 			if (!req->buf)
 				goto free_buf;
@@ -626,6 +639,7 @@
 	list_for_each(act, &dev->tx_reqs) {
 		req = container_of(act, struct usb_request, list);
 		kfree(req->buf);
+		req->buf = NULL;
 	}
 	return -ENOMEM;
 }
@@ -710,28 +724,37 @@
 	 * or the hardware can't use skb buffers.
 	 * or there's not enough space for extra headers we need
 	 */
+	spin_lock_irqsave(&dev->lock, flags);
 	if (dev->wrap) {
-		unsigned long	flags;
-
-		spin_lock_irqsave(&dev->lock, flags);
 		if (dev->port_usb)
 			skb = dev->wrap(dev->port_usb, skb);
-		spin_unlock_irqrestore(&dev->lock, flags);
-		if (!skb)
+		if (!skb) {
+			spin_unlock_irqrestore(&dev->lock, flags);
 			goto drop;
+		}
 	}
 
-	spin_lock_irqsave(&dev->req_lock, flags);
-	dev->tx_skb_hold_count++;
-	spin_unlock_irqrestore(&dev->req_lock, flags);
-
 	if (multi_pkt_xfer) {
+
+		pr_debug("req->length:%d header_len:%u\n"
+				"skb->len:%d skb->data_len:%d\n",
+				req->length, dev->header_len,
+				skb->len, skb->data_len);
+		/* Add RNDIS Header */
+		memcpy(req->buf + req->length, dev->port_usb->header,
+						dev->header_len);
+		/* Increment req length by header size */
+		req->length += dev->header_len;
+		spin_unlock_irqrestore(&dev->lock, flags);
+		/* Copy received IP data from SKB */
 		memcpy(req->buf + req->length, skb->data, skb->len);
-		req->length = req->length + skb->len;
+		/* Increment req length by skb data length */
+		req->length += skb->len;
 		length = req->length;
 		dev_kfree_skb_any(skb);
 
 		spin_lock_irqsave(&dev->req_lock, flags);
+		dev->tx_skb_hold_count++;
 		if (dev->tx_skb_hold_count < dev->dl_max_pkts_per_xfer) {
 			if (dev->no_tx_req_used > TX_REQ_THRESHOLD) {
 				list_add(&req->list, &dev->tx_reqs);
@@ -741,19 +764,15 @@
 		}
 
 		dev->no_tx_req_used++;
-		spin_unlock_irqrestore(&dev->req_lock, flags);
-
-		spin_lock_irqsave(&dev->lock, flags);
 		dev->tx_skb_hold_count = 0;
-		spin_unlock_irqrestore(&dev->lock, flags);
+		spin_unlock_irqrestore(&dev->req_lock, flags);
 	} else {
+		spin_unlock_irqrestore(&dev->lock, flags);
 		length = skb->len;
 		req->buf = skb->data;
 		req->context = skb;
 	}
 
-	req->complete = tx_complete;
-
 	/* NCM requires no zlp if transfer is dwNtbInMaxSize */
 	if (dev->port_usb->is_fixed &&
 	    length == dev->port_usb->fixed_in_len &&
@@ -806,7 +825,7 @@
 		spin_lock_irqsave(&dev->req_lock, flags);
 		if (list_empty(&dev->tx_reqs))
 			netif_start_queue(net);
-		list_add(&req->list, &dev->tx_reqs);
+		list_add_tail(&req->list, &dev->tx_reqs);
 		spin_unlock_irqrestore(&dev->req_lock, flags);
 	}
 success:
@@ -1085,6 +1104,14 @@
 	if (!dev)
 		return ERR_PTR(-EINVAL);
 
+	link->header = kzalloc(sizeof(struct rndis_packet_msg_type),
+							GFP_ATOMIC);
+	if (!link->header) {
+		pr_err("RNDIS header memory allocation failed.\n");
+		result = -ENOMEM;
+		goto fail;
+	}
+
 	link->in_ep->driver_data = dev;
 	result = usb_ep_enable(link->in_ep);
 	if (result != 0) {
@@ -1105,6 +1132,7 @@
 		result = alloc_requests(dev, link, qlen(dev->gadget));
 
 	if (result == 0) {
+
 		dev->zlp = link->is_zlp_ok;
 		DBG(dev, "qlen %d\n", qlen(dev->gadget));
 
@@ -1139,10 +1167,15 @@
 fail1:
 		(void) usb_ep_disable(link->in_ep);
 	}
-fail0:
+
 	/* caller is responsible for cleanup on error */
-	if (result < 0)
+	if (result < 0) {
+fail0:
+		kfree(link->header);
+fail:
 		return ERR_PTR(result);
+	}
+
 	return dev->net;
 }
 
@@ -1184,11 +1217,16 @@
 		list_del(&req->list);
 
 		spin_unlock(&dev->req_lock);
-		if (link->multi_pkt_xfer)
+		if (link->multi_pkt_xfer) {
 			kfree(req->buf);
+			req->buf = NULL;
+		}
 		usb_ep_free_request(link->in_ep, req);
 		spin_lock(&dev->req_lock);
 	}
+	/* Free rndis header buffer memory */
+	kfree(link->header);
+	link->header = NULL;
 	spin_unlock(&dev->req_lock);
 	link->in_ep->driver_data = NULL;
 	link->in_ep->desc = NULL;
diff --git a/drivers/usb/gadget/u_ether.h b/drivers/usb/gadget/u_ether.h
index 05984d8..2c5da77 100644
--- a/drivers/usb/gadget/u_ether.h
+++ b/drivers/usb/gadget/u_ether.h
@@ -66,6 +66,8 @@
 	/* called on network open/close */
 	void				(*open)(struct gether *);
 	void				(*close)(struct gether *);
+	struct rndis_packet_msg_type	*header;
+
 };
 
 #define	DEFAULT_FILTER	(USB_CDC_PACKET_TYPE_BROADCAST \
diff --git a/drivers/usb/gadget/u_qdss.c b/drivers/usb/gadget/u_qdss.c
index e241e29..23d4d06 100644
--- a/drivers/usb/gadget/u_qdss.c
+++ b/drivers/usb/gadget/u_qdss.c
@@ -14,6 +14,7 @@
 #include <linux/device.h>
 #include <linux/usb/msm_hsusb.h>
 #include <mach/usb_bam.h>
+#include "gadget_chips.h"
 
 struct  usb_qdss_bam_connect_info {
 	u32 usb_bam_pipe_idx;
@@ -88,8 +89,11 @@
 			&bam_info.usb_bam_pipe_idx, &bam_info.peer_pipe_idx,
 			NULL, bam_info.data_fifo);
 
-		msm_data_fifo_config(data_ep, bam_info.data_fifo->phys_base,
-			bam_info.data_fifo->size, bam_info.usb_bam_pipe_idx);
+		if (gadget_is_dwc3(gadget))
+			msm_data_fifo_config(data_ep,
+					     bam_info.data_fifo->phys_base,
+					     bam_info.data_fifo->size,
+					     bam_info.usb_bam_pipe_idx);
 	} else {
 		kfree(bam_info.data_fifo);
 		res = usb_bam_disconnect_pipe(idx);
diff --git a/drivers/usb/host/ehci-msm-hsic.c b/drivers/usb/host/ehci-msm-hsic.c
index 5d58f16..5f20ad1 100644
--- a/drivers/usb/host/ehci-msm-hsic.c
+++ b/drivers/usb/host/ehci-msm-hsic.c
@@ -1947,7 +1947,6 @@
 	if (pdev->dev.of_node) {
 		dev_dbg(&pdev->dev, "device tree enabled\n");
 		pdev->dev.platform_data = msm_hsic_dt_to_pdata(pdev);
-		dev_set_name(&pdev->dev, ehci_msm_hsic_driver.driver.name);
 	} else {
 		/* explicitly pass wakeup_irq flag for !DT */
 		wakeup_irq_flags = IRQF_TRIGGER_HIGH;
diff --git a/drivers/usb/misc/diag_bridge.c b/drivers/usb/misc/diag_bridge.c
index 22e2a25..ccd48ca 100644
--- a/drivers/usb/misc/diag_bridge.c
+++ b/drivers/usb/misc/diag_bridge.c
@@ -464,12 +464,7 @@
 		pr_err("unable to allocate dev");
 		return -ENOMEM;
 	}
-	dev->pdev = platform_device_alloc("diag_bridge", devid);
-	if (!dev->pdev) {
-		pr_err("unable to allocate platform device");
-		kfree(dev);
-		return -ENOMEM;
-	}
+
 	__dev[devid] = dev;
 	dev->id = devid;
 
@@ -498,7 +493,13 @@
 
 	usb_set_intfdata(ifc, dev);
 	diag_bridge_debugfs_init();
-	platform_device_add(dev->pdev);
+	dev->pdev = platform_device_register_simple("diag_bridge", devid,
+						    NULL, 0);
+	if (IS_ERR(dev->pdev)) {
+		pr_err("unable to allocate platform device");
+		ret = PTR_ERR(dev->pdev);
+		goto error;
+	}
 
 	dev_dbg(&dev->ifc->dev, "%s: complete\n", __func__);
 
diff --git a/drivers/usb/otg/msm_otg.c b/drivers/usb/otg/msm_otg.c
index 4cf4703..45fbfa8 100644
--- a/drivers/usb/otg/msm_otg.c
+++ b/drivers/usb/otg/msm_otg.c
@@ -470,6 +470,20 @@
 	int ret;
 	struct msm_otg_platform_data *pdata = motg->pdata;
 
+	/*
+	 * AHB2AHB Bypass mode shouldn't be enable before doing
+	 * async clock reset. If it is enable, disable the same.
+	 */
+	val = readl_relaxed(USB_AHBMODE);
+	if (val & AHB2AHB_BYPASS) {
+		pr_err("%s(): AHB2AHB_BYPASS SET: AHBMODE:%x\n",
+				__func__, val);
+		val &= ~AHB2AHB_BYPASS_BIT_MASK;
+		writel_relaxed(val | AHB2AHB_BYPASS_CLEAR, USB_AHBMODE);
+		pr_err("%s(): AHBMODE: %x\n", __func__,
+				readl_relaxed(USB_AHBMODE));
+	}
+
 	ret = msm_otg_link_clk_reset(motg, 1);
 	if (ret)
 		return ret;
@@ -882,6 +896,7 @@
 	if (motg->pdata->delay_lpm_hndshk_on_disconnect && !msm_bam_lpm_ok())
 		return -EBUSY;
 
+	motg->ui_enabled = 0;
 	disable_irq(motg->irq);
 	host_bus_suspend = !test_bit(MHL, &motg->inputs) && phy->otg->host &&
 		!test_bit(ID, &motg->inputs);
@@ -912,6 +927,7 @@
 	if ((test_bit(B_SESS_VLD, &motg->inputs) && !device_bus_suspend &&
 		!dcp && !prop_charger && !floated_charger) ||
 		test_bit(A_BUS_REQ, &motg->inputs)) {
+		motg->ui_enabled = 1;
 		enable_irq(motg->irq);
 		return -EBUSY;
 	}
@@ -961,6 +977,7 @@
 	if (cnt >= PHY_SUSPEND_TIMEOUT_USEC) {
 		dev_err(phy->dev, "Unable to suspend PHY\n");
 		msm_otg_reset(phy);
+		motg->ui_enabled = 1;
 		enable_irq(motg->irq);
 		return -ETIMEDOUT;
 	}
@@ -1077,7 +1094,12 @@
 	/* Enable ASYNC IRQ (if present) during LPM */
 	if (motg->async_irq)
 		enable_irq(motg->async_irq);
-	enable_irq(motg->irq);
+
+	/* XO shutdown during idle , non wakeable irqs must be disabled */
+	if (device_bus_suspend || host_bus_suspend || !motg->async_irq) {
+		motg->ui_enabled = 1;
+		enable_irq(motg->irq);
+	}
 	wake_unlock(&motg->wlock);
 
 	dev_info(phy->dev, "USB in low power mode\n");
@@ -1101,7 +1123,10 @@
 	if (motg->pdata->delay_lpm_hndshk_on_disconnect)
 		msm_bam_notify_lpm_resume();
 
-	disable_irq(motg->irq);
+	if (motg->ui_enabled) {
+		motg->ui_enabled = 0;
+		disable_irq(motg->irq);
+	}
 	wake_lock(&motg->wlock);
 
 	/* Some platforms require BUS vote to enable/disable clocks */
@@ -1206,6 +1231,7 @@
 		enable_irq(motg->async_int);
 		motg->async_int = 0;
 	}
+	motg->ui_enabled = 1;
 	enable_irq(motg->irq);
 
 	/* If ASYNC IRQ is present then keep it enabled only during LPM */
@@ -1263,7 +1289,8 @@
 	else if (motg->chg_type == USB_CDP_CHARGER)
 		charger_type = POWER_SUPPLY_TYPE_USB_CDP;
 	else if (motg->chg_type == USB_DCP_CHARGER ||
-			motg->chg_type == USB_PROPRIETARY_CHARGER)
+			motg->chg_type == USB_PROPRIETARY_CHARGER ||
+			motg->chg_type == USB_FLOATED_CHARGER)
 		charger_type = POWER_SUPPLY_TYPE_USB_DCP;
 	else if ((motg->chg_type == USB_ACA_DOCK_CHARGER ||
 		motg->chg_type == USB_ACA_A_CHARGER ||
@@ -3822,6 +3849,8 @@
 		ci_pdata.log2_itc = otg_pdata->log2_itc;
 		ci_pdata.usb_core_id = 0;
 		ci_pdata.l1_supported = otg_pdata->l1_supported;
+		ci_pdata.enable_ahb2ahb_bypass =
+				otg_pdata->enable_ahb2ahb_bypass;
 		retval = platform_device_add_data(pdev, &ci_pdata,
 			sizeof(ci_pdata));
 		if (retval)
@@ -4152,6 +4181,8 @@
 
 	pdata->l1_supported = of_property_read_bool(node,
 				"qcom,hsusb-l1-supported");
+	pdata->enable_ahb2ahb_bypass = of_property_read_bool(node,
+				"qcom,ahb-async-bridge-bypass");
 
 	return pdata;
 }
diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
index 5c3960d..f26570d 100644
--- a/drivers/video/fbcmap.c
+++ b/drivers/video/fbcmap.c
@@ -166,6 +166,9 @@
 	int tooff = 0, fromoff = 0;
 	int size;
 
+	if (!to || !from)
+		return -EINVAL;
+
 	if (to->start > from->start)
 		fromoff = to->start - from->start;
 	else
@@ -177,9 +180,12 @@
 		return -EINVAL;
 	size *= sizeof(u16);
 
-	memcpy(to->red+tooff, from->red+fromoff, size);
-	memcpy(to->green+tooff, from->green+fromoff, size);
-	memcpy(to->blue+tooff, from->blue+fromoff, size);
+	if (from->red && to->red)
+		memcpy(to->red+tooff, from->red+fromoff, size);
+	if (from->green && to->green)
+		memcpy(to->green+tooff, from->green+fromoff, size);
+	if (from->blue && to->blue)
+		memcpy(to->blue+tooff, from->blue+fromoff, size);
 	if (from->transp && to->transp)
 		memcpy(to->transp+tooff, from->transp+fromoff, size);
 	return 0;
@@ -190,23 +196,31 @@
 	int tooff = 0, fromoff = 0;
 	int size;
 
+	if (!to || !from)
+		return -EINVAL;
+
 	if (to->start > from->start)
 		fromoff = to->start - from->start;
 	else
 		tooff = from->start - to->start;
+	if ((to->len <= tooff) || (from->len <= fromoff))
+		return -EINVAL;
+
 	size = to->len - tooff;
+
 	if (size > (int) (from->len - fromoff))
 		size = from->len - fromoff;
-	if (size <= 0)
-		return -EINVAL;
 	size *= sizeof(u16);
 
-	if (copy_to_user(to->red+tooff, from->red+fromoff, size))
-		return -EFAULT;
-	if (copy_to_user(to->green+tooff, from->green+fromoff, size))
-		return -EFAULT;
-	if (copy_to_user(to->blue+tooff, from->blue+fromoff, size))
-		return -EFAULT;
+	if (from->red && to->red)
+		if (copy_to_user(to->red+tooff, from->red+fromoff, size))
+			return -EFAULT;
+	if (from->green && to->green)
+		if (copy_to_user(to->green+tooff, from->green+fromoff, size))
+			return -EFAULT;
+	if (from->blue && to->blue)
+		if (copy_to_user(to->blue+tooff, from->blue+fromoff, size))
+			return -EFAULT;
 	if (from->transp && to->transp)
 		if (copy_to_user(to->transp+tooff, from->transp+fromoff, size))
 			return -EFAULT;
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index d6a664a..6b84107 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1113,6 +1113,10 @@
 		if (copy_from_user(&cmap, argp, sizeof(cmap)))
 			return -EFAULT;
 		ret = fb_set_user_cmap(&cmap, info);
+		if (ret) {
+			if (info)
+				fb_dealloc_cmap(&info->cmap);
+		}
 		break;
 	case FBIOGETCMAP:
 		if (copy_from_user(&cmap, argp, sizeof(cmap)))
diff --git a/drivers/video/msm/mdss/Kconfig b/drivers/video/msm/mdss/Kconfig
index 7682a49..b49e08e 100644
--- a/drivers/video/msm/mdss/Kconfig
+++ b/drivers/video/msm/mdss/Kconfig
@@ -20,3 +20,11 @@
 	  Support the HDMI to MHL conversion.
 	  MHL (Mobile High-Definition Link) technology
 	  uses USB connector to output HDMI content
+
+config FB_MSM_MDSS_DSI_CTRL_STATUS
+	tristate "DSI controller status check feature"
+	---help---
+	  Check DSI controller status periodically (default period is 5
+	  seconds) by sending Bus-Turn-Around (BTA) command. If DSI controller
+	  fails to acknowledge the BTA command, it sends PANEL_ALIVE=0 status
+	  to HAL layer to reset the controller.
diff --git a/drivers/video/msm/mdss/Makefile b/drivers/video/msm/mdss/Makefile
index ba14d67..8f5fa26 100644
--- a/drivers/video/msm/mdss/Makefile
+++ b/drivers/video/msm/mdss/Makefile
@@ -41,3 +41,5 @@
 obj-$(CONFIG_FB_MSM_QPIC_ILI_QVGA_PANEL) += qpic_panel_ili_qvga.o
 
 obj-$(CONFIG_FB_MSM_MDSS) += mdss_fb.o
+
+obj-$(CONFIG_FB_MSM_MDSS_DSI_CTRL_STATUS) += mdss_dsi_status.o
diff --git a/drivers/video/msm/mdss/dsi_host_v2.c b/drivers/video/msm/mdss/dsi_host_v2.c
index 5264005..e8fe7e3 100644
--- a/drivers/video/msm/mdss/dsi_host_v2.c
+++ b/drivers/video/msm/mdss/dsi_host_v2.c
@@ -77,7 +77,7 @@
 
 	if (status) {
 		MIPI_OUTP(ctrl_base + DSI_ACK_ERR_STATUS, status);
-		pr_debug("%s: status=%x\n", __func__, status);
+		pr_err("%s: status=%x\n", __func__, status);
 	}
 }
 
@@ -88,7 +88,7 @@
 	status = MIPI_INP(ctrl_base + DSI_TIMEOUT_STATUS);
 	if (status & 0x0111) {
 		MIPI_OUTP(ctrl_base + DSI_TIMEOUT_STATUS, status);
-		pr_debug("%s: status=%x\n", __func__, status);
+		pr_err("%s: status=%x\n", __func__, status);
 	}
 }
 
@@ -100,7 +100,7 @@
 
 	if (status & 0x011111) {
 		MIPI_OUTP(ctrl_base + DSI_DLN0_PHY_ERR, status);
-		pr_debug("%s: status=%x\n", __func__, status);
+		pr_err("%s: status=%x\n", __func__, status);
 	}
 }
 
@@ -112,7 +112,7 @@
 
 	if (status & 0x44444489) {
 		MIPI_OUTP(ctrl_base + DSI_FIFO_STATUS, status);
-		pr_debug("%s: status=%x\n", __func__, status);
+		pr_err("%s: status=%x\n", __func__, status);
 	}
 }
 
@@ -124,7 +124,7 @@
 
 	if (status & 0x80000000) {
 		MIPI_OUTP(ctrl_base + DSI_STATUS, status);
-		pr_debug("%s: status=%x\n", __func__, status);
+		pr_err("%s: status=%x\n", __func__, status);
 	}
 }
 
@@ -546,8 +546,12 @@
 	cm = cmds;
 	for (i = 0; i < cnt; i++) {
 		dsi_buf_init(tp);
-		dsi_cmd_dma_add(tp, cm);
-		msm_dsi_cmd_dma_tx(tp);
+		rc = dsi_cmd_dma_add(tp, cm);
+		if (!rc) {
+			pr_err("%s: dsi_cmd_dma_add fail\n", __func__);
+			rc = -EINVAL;
+			break;
+		}
 		rc = msm_dsi_cmd_dma_tx(tp);
 		if (IS_ERR_VALUE(rc)) {
 			pr_err("%s: failed to call cmd_dma_tx\n", __func__);
@@ -591,6 +595,17 @@
 {
 	int cnt, len, diff, pkt_size, rc = 0;
 	char cmd;
+	unsigned char *ctrl_base = dsi_host_private->dsi_base;
+	u32 dsi_ctrl, data;
+	int video_mode;
+
+	/* turn on cmd mode for video mode */
+	dsi_ctrl = MIPI_INP(ctrl_base + DSI_CTRL);
+	video_mode = dsi_ctrl & 0x02; /* VIDEO_MODE_EN */
+	if (video_mode) {
+		data = dsi_ctrl | 0x04; /* CMD_MODE_EN */
+		MIPI_OUTP(ctrl_base + DSI_CTRL, data);
+	}
 
 	if (pdata->panel_info.mipi.no_max_pkt_size)
 		rlen = ALIGN(rlen, 4); /* Only support rlen = 4*n */
@@ -624,27 +639,35 @@
 		pkt_size = len;
 		max_pktsize[0] = pkt_size;
 		dsi_buf_init(tp);
-		dsi_cmd_dma_add(tp, pkt_size_cmd);
+		rc = dsi_cmd_dma_add(tp, pkt_size_cmd);
+		if (!rc) {
+			pr_err("%s: dsi_cmd_dma_add failed\n", __func__);
+			rp->len = 0;
+			goto msm_dsi_cmds_rx_err;
+		}
 		rc = msm_dsi_cmd_dma_tx(tp);
 		if (IS_ERR_VALUE(rc)) {
-			msm_dsi_disable_irq();
-			pr_err("%s: dma_tx failed\n", __func__);
+			pr_err("%s: msm_dsi_cmd_dma_tx failed\n", __func__);
 			rp->len = 0;
-			goto end;
+			goto msm_dsi_cmds_rx_err;
 		}
 		pr_debug("%s: Max packet size sent\n", __func__);
 	}
 
 	dsi_buf_init(tp);
-	dsi_cmd_dma_add(tp, cmds);
+	rc = dsi_cmd_dma_add(tp, cmds);
+	if (!rc) {
+		pr_err("%s: dsi_cmd_dma_add failed\n", __func__);
+		rp->len = 0;
+		goto msm_dsi_cmds_rx_err;
+	}
 
 	/* transmit read comamnd to client */
-	msm_dsi_cmd_dma_tx(tp);
+	rc = msm_dsi_cmd_dma_tx(tp);
 	if (IS_ERR_VALUE(rc)) {
-		msm_dsi_disable_irq();
-		pr_err("%s: dma_tx failed\n", __func__);
+		pr_err("%s: msm_dsi_cmd_dma_tx failed\n", __func__);
 		rp->len = 0;
-		goto end;
+		goto msm_dsi_cmds_rx_err;
 	}
 	/*
 	 * once cmd_dma_done interrupt received,
@@ -662,8 +685,6 @@
 
 	msm_dsi_cmd_dma_rx(rp, cnt);
 
-	msm_dsi_disable_irq();
-
 	if (pdata->panel_info.mipi.no_max_pkt_size) {
 		/*
 		 * remove extra 2 bytes from previous
@@ -679,6 +700,7 @@
 	switch (cmd) {
 	case DTYPE_ACK_ERR_RESP:
 		pr_debug("%s: rx ACK_ERR_PACLAGE\n", __func__);
+		rp->len = 0;
 		break;
 	case DTYPE_GEN_READ1_RESP:
 	case DTYPE_DCS_READ1_RESP:
@@ -695,11 +717,17 @@
 		rp->len -= diff; /* align bytes */
 		break;
 	default:
-		pr_debug("%s: Unknown cmd received\n", __func__);
+		pr_warn("%s: Unknown cmd received\n", __func__);
+		rp->len = 0;
 		break;
 	}
 
-end:
+	if (video_mode)
+		MIPI_OUTP(ctrl_base + DSI_CTRL,
+					dsi_ctrl); /* restore */
+
+msm_dsi_cmds_rx_err:
+	msm_dsi_disable_irq();
 	return rp->len;
 }
 
@@ -1057,6 +1085,27 @@
 	return dsi_pan_node;
 }
 
+static int msm_dsi_clk_ctrl(struct mdss_panel_data *pdata, int enable)
+{
+	u32 bitclk_rate = 0, byteclk_rate = 0, pclk_rate = 0, dsiclk_rate = 0;
+
+	pr_debug("%s:\n", __func__);
+
+	if (enable) {
+		msm_dsi_ahb_ctrl(1);
+		msm_dsi_cal_clk_rate(pdata, &bitclk_rate, &dsiclk_rate,
+					&byteclk_rate, &pclk_rate);
+		msm_dsi_clk_set_rate(DSI_ESC_CLK_RATE, dsiclk_rate,
+					byteclk_rate, pclk_rate);
+		msm_dsi_clk_enable();
+	} else {
+		msm_dsi_clk_set_rate(DSI_ESC_CLK_RATE, 0, 0, 0);
+		msm_dsi_clk_disable();
+		msm_dsi_ahb_ctrl(0);
+	}
+	return 0;
+}
+
 static int __devinit msm_dsi_probe(struct platform_device *pdev)
 {
 	struct dsi_interface intf;
@@ -1175,6 +1224,7 @@
 	intf.on = msm_dsi_on;
 	intf.off = msm_dsi_off;
 	intf.cont_on = msm_dsi_cont_on;
+	intf.clk_ctrl = msm_dsi_clk_ctrl;
 	intf.op_mode_config = msm_dsi_op_mode_config;
 	intf.tx = msm_dsi_cmds_tx;
 	intf.rx = msm_dsi_cmds_rx;
diff --git a/drivers/video/msm/mdss/dsi_v2.c b/drivers/video/msm/mdss/dsi_v2.c
index 65cca0e..f3d0ad4 100644
--- a/drivers/video/msm/mdss/dsi_v2.c
+++ b/drivers/video/msm/mdss/dsi_v2.c
@@ -104,6 +104,18 @@
 	return rc;
 }
 
+static int dsi_clk_ctrl(struct mdss_panel_data *pdata, int enable)
+{
+	int rc = 0;
+
+	pr_debug("%s:\n", __func__);
+
+	if (dsi_intf.clk_ctrl)
+		rc = dsi_intf.clk_ctrl(pdata, enable);
+
+	return rc;
+}
+
 static int dsi_event_handler(struct mdss_panel_data *pdata,
 				int event, void *arg)
 {
@@ -130,6 +142,9 @@
 	case MDSS_EVENT_CONT_SPLASH_BEGIN:
 		rc = dsi_splash_on(pdata);
 		break;
+	case MDSS_EVENT_PANEL_CLK_CTRL:
+		rc = dsi_clk_ctrl(pdata, (int)arg);
+		break;
 	default:
 		pr_debug("%s: unhandled event=%d\n", __func__, event);
 		break;
diff --git a/drivers/video/msm/mdss/dsi_v2.h b/drivers/video/msm/mdss/dsi_v2.h
index e15f640..cb007e3 100644
--- a/drivers/video/msm/mdss/dsi_v2.h
+++ b/drivers/video/msm/mdss/dsi_v2.h
@@ -27,6 +27,7 @@
 	int (*on)(struct mdss_panel_data *pdata);
 	int (*off)(struct mdss_panel_data *pdata);
 	int (*cont_on)(struct mdss_panel_data *pdata);
+	int (*clk_ctrl)(struct mdss_panel_data *pdata, int enable);
 	void (*op_mode_config)(int mode, struct mdss_panel_data *pdata);
 	int (*tx)(struct mdss_panel_data *pdata,
 		struct dsi_buf *tp, struct dsi_cmd_desc *cmds, int cnt);
diff --git a/drivers/video/msm/mdss/mdp3.c b/drivers/video/msm/mdss/mdp3.c
index 55037e3..e4ae7ea 100644
--- a/drivers/video/msm/mdss/mdp3.c
+++ b/drivers/video/msm/mdss/mdp3.c
@@ -184,11 +184,11 @@
 	u32 mdp_interrupt = 0;
 
 	spin_lock(&mdata->irq_lock);
-	if (!mdata->irq_mask) {
+	if (!mdata->irq_mask)
 		pr_err("spurious interrupt\n");
-		spin_unlock(&mdata->irq_lock);
-		return IRQ_HANDLED;
-	}
+
+	clk_enable(mdp3_res->clocks[MDP3_CLK_AHB]);
+	clk_enable(mdp3_res->clocks[MDP3_CLK_CORE]);
 
 	mdp_interrupt = MDP3_REG_READ(MDP3_REG_INTR_STATUS);
 	MDP3_REG_WRITE(MDP3_REG_INTR_CLEAR, mdp_interrupt);
@@ -202,6 +202,10 @@
 		mdp_interrupt = mdp_interrupt >> 1;
 		i++;
 	}
+
+	clk_disable(mdp3_res->clocks[MDP3_CLK_AHB]);
+	clk_disable(mdp3_res->clocks[MDP3_CLK_CORE]);
+
 	spin_unlock(&mdata->irq_lock);
 
 	return IRQ_HANDLED;
@@ -281,8 +285,6 @@
 	spin_lock_irqsave(&mdp3_res->irq_lock, flag);
 	memset(mdp3_res->irq_ref_count, 0, sizeof(u32) * MDP3_MAX_INTR);
 	mdp3_res->irq_mask = 0;
-	MDP3_REG_WRITE(MDP3_REG_INTR_ENABLE, 0);
-	MDP3_REG_WRITE(MDP3_REG_INTR_CLEAR, 0xfffffff);
 	disable_irq_nosync(mdp3_res->irq);
 	spin_unlock_irqrestore(&mdp3_res->irq_lock, flag);
 }
@@ -415,10 +417,10 @@
 	count = mdp3_res->clock_ref_count[clk_idx];
 	if (count == 1 && enable) {
 		pr_debug("clk=%d en=%d\n", clk_idx, enable);
-		ret = clk_prepare_enable(clk);
+		ret = clk_enable(clk);
 	} else if (count == 0) {
 		pr_debug("clk=%d disable\n", clk_idx);
-		clk_disable_unprepare(clk);
+		clk_disable(clk);
 		ret = 0;
 	} else if (count < 0) {
 		pr_err("clk=%d count=%d\n", clk_idx, count);
@@ -554,7 +556,7 @@
 		clk_put(mdp3_res->clocks[MDP3_CLK_DSI]);
 }
 
-int mdp3_clk_enable(int enable)
+int mdp3_clk_enable(int enable, int dsi_clk)
 {
 	int rc;
 
@@ -564,11 +566,62 @@
 	rc = mdp3_clk_update(MDP3_CLK_AHB, enable);
 	rc |= mdp3_clk_update(MDP3_CLK_CORE, enable);
 	rc |= mdp3_clk_update(MDP3_CLK_VSYNC, enable);
-	rc |= mdp3_clk_update(MDP3_CLK_DSI, enable);
+	if (dsi_clk)
+		rc |= mdp3_clk_update(MDP3_CLK_DSI, enable);
 	mutex_unlock(&mdp3_res->res_mutex);
 	return rc;
 }
 
+int mdp3_clk_prepare(void)
+{
+	int rc = 0;
+
+	mutex_lock(&mdp3_res->res_mutex);
+	mdp3_res->clk_prepare_count++;
+	if (mdp3_res->clk_prepare_count == 1) {
+		rc = clk_prepare(mdp3_res->clocks[MDP3_CLK_AHB]);
+		if (rc < 0)
+			goto error0;
+		rc = clk_prepare(mdp3_res->clocks[MDP3_CLK_CORE]);
+		if (rc < 0)
+			goto error1;
+		rc = clk_prepare(mdp3_res->clocks[MDP3_CLK_VSYNC]);
+		if (rc < 0)
+			goto error2;
+		rc = clk_prepare(mdp3_res->clocks[MDP3_CLK_DSI]);
+		if (rc < 0)
+			goto error3;
+	}
+	mutex_unlock(&mdp3_res->res_mutex);
+	return rc;
+
+error3:
+	clk_unprepare(mdp3_res->clocks[MDP3_CLK_VSYNC]);
+error2:
+	clk_unprepare(mdp3_res->clocks[MDP3_CLK_CORE]);
+error1:
+	clk_unprepare(mdp3_res->clocks[MDP3_CLK_AHB]);
+error0:
+	mdp3_res->clk_prepare_count--;
+	mutex_unlock(&mdp3_res->res_mutex);
+	return rc;
+}
+
+void mdp3_clk_unprepare(void)
+{
+	mutex_lock(&mdp3_res->res_mutex);
+	mdp3_res->clk_prepare_count--;
+	if (mdp3_res->clk_prepare_count == 0) {
+		clk_unprepare(mdp3_res->clocks[MDP3_CLK_AHB]);
+		clk_unprepare(mdp3_res->clocks[MDP3_CLK_CORE]);
+		clk_unprepare(mdp3_res->clocks[MDP3_CLK_VSYNC]);
+		clk_unprepare(mdp3_res->clocks[MDP3_CLK_DSI]);
+	} else if (mdp3_res->clk_prepare_count < 0) {
+		pr_err("mdp3 clk unprepare mismatch\n");
+	}
+	mutex_unlock(&mdp3_res->res_mutex);
+}
+
 static int mdp3_irq_setup(void)
 {
 	int ret;
@@ -586,41 +639,6 @@
 	return 0;
 }
 
-struct reg_dump {
-	int start_addr;
-	int num_reads;
-};
-
-struct reg_dump ppp_reg[] = {
-	{0x10108, 3},
-	{0x10118, 6},
-	{0x10138, 9},
-	{0x10158, 1},
-	{0x10164, 7},
-	{0x1019C, 1},
-	{0x101b8, 2},
-	{0x101c0, 8},
-};
-
-static int mdp3_iommu_fault_handler(struct iommu_domain *domain,
-		struct device *dev, unsigned long iova, int flags, void *token)
-{
-	unsigned int addr, val;
-	int i, j;
-	pr_err("MDP IOMMU page fault: iova 0x%lx\n", iova);
-	for (i = 0; i < ARRAY_SIZE(ppp_reg); i++) {
-		for (j = 0; j < ppp_reg[i].num_reads; j++) {
-			addr = ppp_reg[i].start_addr + (j*4);
-			val = MDP3_REG_READ(addr);
-			pr_err("TMsg: Addr= 0x%08x, val= 0x%08x\n",
-				(unsigned int)addr, (unsigned int)val);
-		}
-	}
-	panic("PPP pagefault, shutting down for easier debugging\n");
-	return 0;
-}
-
-
 int mdp3_iommu_attach(int context)
 {
 	struct mdp3_iommu_ctx_map *context_map;
@@ -696,9 +714,6 @@
 			else
 				return PTR_ERR(mdp3_iommu_domains[i].domain);
 		}
-		iommu_set_fault_handler(mdp3_iommu_domains[i].domain,
-			mdp3_iommu_fault_handler,
-			NULL);
 	}
 
 	mdp3_res->domains = mdp3_iommu_domains;
@@ -1550,8 +1565,17 @@
 static int mdp3_init(struct msm_fb_data_type *mfd)
 {
 	int rc;
+
 	rc = mdp3_ctrl_init(mfd);
-	rc |= mdp3_ppp_res_init(mfd);
+	if (rc) {
+		pr_err("mdp3 ctl init fail\n");
+		return rc;
+	}
+
+	rc = mdp3_ppp_res_init(mfd);
+	if (rc)
+		pr_err("mdp3 ppp res init fail\n");
+
 	return rc;
 }
 
@@ -1709,6 +1733,11 @@
 	return mdp3_res->domains[MDP3_DMA_IOMMU_DOMAIN].domain_idx;
 }
 
+int mdp3_get_cont_spash_en(void)
+{
+	return mdp3_res->cont_splash_en;
+}
+
 int mdp3_continuous_splash_copy(struct mdss_panel_data *pdata)
 {
 	unsigned long splash_phys, phys;
@@ -1764,7 +1793,7 @@
 		rc = (status == 0x080000);
 	}
 
-	mdp3_res->splash_mem_addr = MDP3_REG_READ(MDP3_REG_DMA_S_IBUF_ADDR);
+	mdp3_res->splash_mem_addr = MDP3_REG_READ(MDP3_REG_DMA_P_IBUF_ADDR);
 
 	mdp3_clk_update(MDP3_CLK_AHB, 0);
 	mdp3_clk_update(MDP3_CLK_CORE, 0);
@@ -1778,9 +1807,19 @@
 
 	pr_debug("mdp3__continuous_splash_on\n");
 
-	rc = mdp3_clk_enable(1);
+	mdp3_clk_set_rate(MDP3_CLK_VSYNC, MDP_VSYNC_CLK_RATE,
+			MDP3_CLIENT_DMA_P);
+
+	rc = mdp3_clk_prepare();
+	if (rc) {
+		pr_err("fail to prepare clk\n");
+		return rc;
+	}
+
+	rc = mdp3_clk_enable(1, 1);
 	if (rc) {
 		pr_err("fail to enable clk\n");
+		mdp3_clk_unprepare();
 		return rc;
 	}
 
@@ -1814,11 +1853,15 @@
 		mdp3_res->intf[MDP3_DMA_OUTPUT_SEL_DSI_VIDEO].active = 1;
 	else
 		mdp3_res->intf[MDP3_DMA_OUTPUT_SEL_DSI_CMD].active = 1;
+
+	mdp3_res->cont_splash_en = 1;
 	return 0;
 
 splash_on_err:
-	if (mdp3_clk_enable(0))
+	if (mdp3_clk_enable(0, 1))
 		pr_err("%s: Unable to disable mdp3 clocks\n", __func__);
+
+	mdp3_clk_unprepare();
 	return rc;
 }
 
@@ -1851,10 +1894,13 @@
 
 static void mdp3_debug_enable_clock(int on)
 {
-	if (on)
-		mdp3_clk_enable(1);
-	else
-		mdp3_clk_enable(0);
+	if (on) {
+		mdp3_clk_prepare();
+		mdp3_clk_enable(1, 0);
+	} else {
+		mdp3_clk_enable(0, 0);
+		mdp3_clk_unprepare();
+	}
 }
 
 static int mdp3_debug_init(struct platform_device *pdev)
@@ -1897,6 +1943,52 @@
 			mdp3_res->underrun_cnt);
 }
 
+static ssize_t mdp3_show_capabilities(struct device *dev,
+		struct device_attribute *attr, char *buf)
+{
+	size_t len = PAGE_SIZE;
+	int cnt = 0;
+
+#define SPRINT(fmt, ...) \
+		(cnt += scnprintf(buf + cnt, len - cnt, fmt, ##__VA_ARGS__))
+
+	SPRINT("mdp_version=3\n");
+	SPRINT("hw_rev=%d\n", 304);
+	SPRINT("dma_pipes=%d\n", 1);
+	SPRINT("\n");
+
+	return cnt;
+}
+
+static DEVICE_ATTR(caps, S_IRUGO, mdp3_show_capabilities, NULL);
+
+static struct attribute *mdp3_fs_attrs[] = {
+	&dev_attr_caps.attr,
+	NULL
+};
+
+static struct attribute_group mdp3_fs_attr_group = {
+	.attrs = mdp3_fs_attrs
+};
+
+static int mdp3_register_sysfs(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	int rc;
+
+	rc = sysfs_create_group(&dev->kobj, &mdp3_fs_attr_group);
+
+	return rc;
+}
+
+int mdp3_create_sysfs_link(struct device *dev)
+{
+	int rc;
+	rc = sysfs_create_link_nowarn(&dev->kobj,
+			&mdp3_res->pdev->dev.kobj, "mdp");
+
+	return rc;
+}
 
 static int mdp3_probe(struct platform_device *pdev)
 {
@@ -1956,6 +2048,10 @@
 		goto probe_done;
 	}
 
+	rc = mdp3_register_sysfs(pdev);
+	if (rc)
+		pr_err("unable to register mdp sysfs nodes\n");
+
 	rc = mdss_fb_register_mdp_instance(&mdp3_interface);
 	if (rc)
 		pr_err("unable to register mdp instance\n");
diff --git a/drivers/video/msm/mdss/mdp3.h b/drivers/video/msm/mdss/mdp3.h
index 4480c20..c0d630e 100644
--- a/drivers/video/msm/mdss/mdp3.h
+++ b/drivers/video/msm/mdss/mdp3.h
@@ -25,6 +25,8 @@
 #include "mdp3_dma.h"
 #include "mdss_fb.h"
 
+#define MDP_VSYNC_CLK_RATE	19200000
+
 enum  {
 	MDP3_CLK_AHB,
 	MDP3_CLK_CORE,
@@ -152,6 +154,9 @@
 	struct mdss_panel_cfg pan_cfg;
 	u32 splash_mem_addr;
 	u32 splash_mem_size;
+
+	int clk_prepare_count;
+	int cont_splash_en;
 };
 
 struct mdp3_img_data {
@@ -175,7 +180,9 @@
 void mdp3_irq_register(void);
 void mdp3_irq_deregister(void);
 int mdp3_clk_set_rate(int clk_type, unsigned long clk_rate, int client);
-int mdp3_clk_enable(int enable);
+int mdp3_clk_enable(int enable, int dsi_clk);
+int mdp3_clk_prepare(void);
+void mdp3_clk_unprepare(void);
 int mdp3_bus_scale_set_quota(int client, u64 ab_quota, u64 ib_quota);
 int mdp3_put_img(struct mdp3_img_data *data, int client);
 int mdp3_get_img(struct msmfb_data *img, struct mdp3_img_data *data,
@@ -186,6 +193,8 @@
 void mdp3_free(void);
 int mdp3_parse_dt_splash(struct msm_fb_data_type *mfd);
 void mdp3_release_splash_memory(void);
+int mdp3_create_sysfs_link(struct device *dev);
+int mdp3_get_cont_spash_en(void);
 
 #define MDP3_REG_WRITE(addr, val) writel_relaxed(val, mdp3_res->mdp_base + addr)
 #define MDP3_REG_READ(addr) readl_relaxed(mdp3_res->mdp_base + addr)
diff --git a/drivers/video/msm/mdss/mdp3_ctrl.c b/drivers/video/msm/mdss/mdp3_ctrl.c
index 9c909bf..14107c5 100644
--- a/drivers/video/msm/mdss/mdp3_ctrl.c
+++ b/drivers/video/msm/mdss/mdp3_ctrl.c
@@ -26,12 +26,15 @@
 #include "mdp3_ppp.h"
 
 #define MDP_CORE_CLK_RATE	100000000
-#define MDP_VSYNC_CLK_RATE	19200000
+#define VSYNC_EXPIRE_TICK	4
 
 static void mdp3_ctrl_pan_display(struct msm_fb_data_type *mfd);
 static int mdp3_overlay_unset(struct msm_fb_data_type *mfd, int ndx);
 static int mdp3_histogram_stop(struct mdp3_session_data *session,
 					u32 block);
+static int mdp3_ctrl_clk_enable(struct msm_fb_data_type *mfd, int enable);
+static int mdp3_ctrl_vsync_enable(struct msm_fb_data_type *mfd, int enable);
+static int mdp3_ctrl_get_intf_type(struct msm_fb_data_type *mfd);
 
 static void mdp3_bufq_init(struct mdp3_buffer_queue *bufq)
 {
@@ -88,6 +91,29 @@
 	return bufq->count;
 }
 
+static void mdp3_dispatch_clk_off(struct work_struct *work)
+{
+	struct mdp3_session_data *session;
+
+	pr_debug("%s\n", __func__);
+	session = container_of(work, struct mdp3_session_data,
+				clk_off_work);
+	if (!session)
+		return;
+
+	mutex_lock(&session->lock);
+	if (session->vsync_enabled ||
+			atomic_read(&session->vsync_countdown) != 0) {
+		mutex_unlock(&session->lock);
+		pr_debug("Ignoring clk shut down\n");
+		return;
+	}
+
+	mdp3_ctrl_vsync_enable(session->mfd, 0);
+	mdp3_ctrl_clk_enable(session->mfd, 0);
+	mutex_unlock(&session->lock);
+}
+
 void vsync_notify_handler(void *arg)
 {
 	struct mdp3_session_data *session = (struct mdp3_session_data *)arg;
@@ -95,6 +121,22 @@
 	sysfs_notify_dirent(session->vsync_event_sd);
 }
 
+void vsync_count_down(void *arg)
+{
+	struct mdp3_session_data *session = (struct mdp3_session_data *)arg;
+	/* We are counting down to turn off clocks */
+	atomic_dec(&session->vsync_countdown);
+	if (atomic_read(&session->vsync_countdown) == 0)
+		schedule_work(&session->clk_off_work);
+}
+
+void mdp3_ctrl_reset_countdown(struct mdp3_session_data *session,
+		struct msm_fb_data_type *mfd)
+{
+	if (mdp3_ctrl_get_intf_type(mfd) == MDP3_DMA_OUTPUT_SEL_DSI_CMD)
+		atomic_set(&session->vsync_countdown, VSYNC_EXPIRE_TICK);
+}
+
 static int mdp3_ctrl_vsync_enable(struct msm_fb_data_type *mfd, int enable)
 {
 	struct mdp3_session_data *mdp3_session;
@@ -115,17 +157,37 @@
 		vsync_client.handler = vsync_notify_handler;
 		vsync_client.arg = mdp3_session;
 		arg = &vsync_client;
+	} else if (atomic_read(&mdp3_session->vsync_countdown)) {
+		/*
+		 * Now that vsync is no longer needed we will
+		 * shutdown dsi clocks as soon as cnt down == 0
+		 * for cmd mode panels
+		 */
+		vsync_client.handler = vsync_count_down;
+		vsync_client.arg = mdp3_session;
+		arg = &vsync_client;
+		enable = 1;
 	}
 
-	mutex_lock(&mdp3_session->lock);
+	mdp3_clk_enable(1, 0);
 	mdp3_session->dma->vsync_enable(mdp3_session->dma, arg);
-	if (enable && mdp3_session->status == 1 && !mdp3_session->intf->active)
+	mdp3_clk_enable(0, 0);
+
+	/*
+	 * Need to fake vsync whenever dsi interface is not
+	 * active or when dsi clocks are currently off
+	 */
+	if (enable && mdp3_session->status == 1
+			&& !mdp3_session->intf->active) {
 		mod_timer(&mdp3_session->vsync_timer,
 			jiffies + msecs_to_jiffies(mdp3_session->vsync_period));
-	 else if (!enable)
+	} else if (enable && !mdp3_session->clk_on) {
+		mdp3_ctrl_reset_countdown(mdp3_session, mfd);
+		mdp3_ctrl_clk_enable(mfd, 1);
+	} else if (!enable) {
 		del_timer(&mdp3_session->vsync_timer);
+	}
 
-	mutex_unlock(&mdp3_session->lock);
 	return 0;
 }
 
@@ -209,6 +271,33 @@
 	.attrs = vsync_fs_attrs,
 };
 
+static int mdp3_ctrl_clk_enable(struct msm_fb_data_type *mfd, int enable)
+{
+	struct mdp3_session_data *session;
+	struct mdss_panel_data *panel;
+	int rc = 0;
+
+	pr_debug("mdp3_ctrl_clk_enable %d\n", enable);
+
+	session = mfd->mdp.private1;
+	panel = session->panel;
+
+	if (!panel->event_handler)
+		return 0;
+
+	if ((enable && session->clk_on == 0) ||
+				(!enable && session->clk_on == 1)) {
+		rc = panel->event_handler(panel,
+			MDSS_EVENT_PANEL_CLK_CTRL, (void *)enable);
+		rc |= mdp3_clk_enable(enable, 1);
+	} else {
+		pr_debug("enable = %d, clk_on=%d\n", enable, session->clk_on);
+	}
+
+	session->clk_on = enable;
+	return rc;
+}
+
 static int mdp3_ctrl_res_req_bus(struct msm_fb_data_type *mfd, int status)
 {
 	int rc = 0;
@@ -236,12 +325,24 @@
 		mdp3_clk_set_rate(MDP3_CLK_VSYNC, MDP_VSYNC_CLK_RATE,
 				MDP3_CLIENT_DMA_P);
 
-		rc = mdp3_clk_enable(true);
-		if (rc)
+		rc = mdp3_clk_prepare();
+		if (rc) {
+			pr_err("mdp3 clk prepare fail\n");
 			return rc;
+		}
 
+		rc = mdp3_clk_enable(1, 1);
+		if (rc) {
+			pr_err("mdp3 clk enable fail\n");
+			mdp3_clk_unprepare();
+			return rc;
+		}
 	} else {
-		rc = mdp3_clk_enable(false);
+		rc = mdp3_clk_enable(0, 1);
+		if (rc)
+			pr_err("mdp3 clk disable fail\n");
+		else
+			mdp3_clk_unprepare();
 	}
 	return rc;
 }
@@ -473,6 +574,7 @@
 		goto on_error;
 	}
 
+	mdp3_session->clk_on = 1;
 	pr_debug("mdp3_ctrl_on dma start\n");
 	if (mfd->fbi->screen_base) {
 		rc = mdp3_session->dma->start(mdp3_session->dma,
@@ -509,36 +611,44 @@
 	panel = mdp3_session->panel;
 	mutex_lock(&mdp3_session->lock);
 
+	if (panel && panel->set_backlight)
+		panel->set_backlight(panel, 0);
+
 	if (!mdp3_session->status) {
 		pr_debug("fb%d is off already", mfd->index);
 		goto off_error;
 	}
 
+	mdp3_ctrl_clk_enable(mfd, 1);
+
 	mdp3_histogram_stop(mdp3_session, MDP_BLOCK_DMA_P);
 
 	rc = mdp3_session->dma->stop(mdp3_session->dma, mdp3_session->intf);
 	if (rc)
 		pr_debug("fail to stop the MDP3 dma\n");
 
+
 	if (panel->event_handler)
 		rc = panel->event_handler(panel, MDSS_EVENT_PANEL_OFF, NULL);
 	if (rc)
 		pr_err("fail to turn off the panel\n");
 
-
-
 	mdp3_irq_deregister();
 
 	pr_debug("mdp3_ctrl_off stop clock\n");
-	rc = mdp3_ctrl_res_req_clk(mfd, 0);
-	if (rc)
-		pr_err("mdp clock resource release failed\n");
+	if (mdp3_session->clk_on) {
+		rc = mdp3_clk_enable(0, 1);
+		if (rc)
+			pr_err("mdp clock resource release failed\n");
 
-	pr_debug("mdp3_ctrl_off stop dsi controller\n");
-	if (panel->event_handler)
-		rc = panel->event_handler(panel, MDSS_EVENT_BLANK, NULL);
-	if (rc)
-		pr_err("fail to turn off the panel\n");
+		pr_debug("mdp3_ctrl_off stop dsi controller\n");
+		if (panel->event_handler)
+			rc = panel->event_handler(panel,
+				MDSS_EVENT_BLANK, NULL);
+		if (rc)
+			pr_err("fail to turn off the panel\n");
+	}
+	mdp3_clk_unprepare();
 
 	pr_debug("mdp3_ctrl_off release bus\n");
 	rc = mdp3_ctrl_res_req_bus(mfd, 0);
@@ -549,6 +659,9 @@
 	if (rc)
 		pr_err("fail to dettach MDP DMA SMMU\n");
 
+	mdp3_session->vsync_enabled = 0;
+	atomic_set(&mdp3_session->vsync_countdown, 0);
+	mdp3_session->clk_on = 0;
 off_error:
 	mdp3_session->status = 0;
 	mdp3_bufq_deinit(&mdp3_session->bufq_out);
@@ -842,6 +955,8 @@
 
 	data = mdp3_bufq_pop(&mdp3_session->bufq_in);
 	if (data) {
+		mdp3_ctrl_reset_countdown(mdp3_session, mfd);
+		mdp3_ctrl_clk_enable(mfd, 1);
 		mdp3_session->dma->update(mdp3_session->dma,
 			(void *)data->addr,
 			mdp3_session->intf);
@@ -910,12 +1025,16 @@
 	}
 
 	if (mfd->fbi->screen_base) {
+		mdp3_ctrl_reset_countdown(mdp3_session, mfd);
+		mdp3_ctrl_clk_enable(mfd, 1);
 		mdp3_session->dma->update(mdp3_session->dma,
 				(void *)mfd->iova + offset,
 				mdp3_session->intf);
 	} else {
 		pr_debug("mdp3_ctrl_pan_display no memory, stop interface");
+		mdp3_clk_enable(1, 0);
 		mdp3_session->dma->stop(mdp3_session->dma, mdp3_session->intf);
+		mdp3_clk_enable(0, 0);
 	}
 
 	if (mdp3_session->first_commit) {
@@ -1031,10 +1150,11 @@
 
 	if (session->histo_status) {
 		pr_err("mdp3_histogram_start already started\n");
-		ret = -EBUSY;
-		goto histogram_start_err;
+		mutex_unlock(&session->histo_lock);
+		return -EBUSY;
 	}
 
+	mdp3_clk_enable(1, 0);
 	ret = session->dma->histo_op(session->dma, MDP3_DMA_HISTO_OP_RESET);
 	if (ret) {
 		pr_err("mdp3_histogram_start reset error\n");
@@ -1060,6 +1180,7 @@
 	session->histo_status = 1;
 
 histogram_start_err:
+	mdp3_clk_enable(0, 0);
 	mutex_unlock(&session->histo_lock);
 	return ret;
 }
@@ -1082,7 +1203,9 @@
 		goto histogram_stop_err;
 	}
 
+	mdp3_clk_enable(1, 0);
 	ret = session->dma->histo_op(session->dma, MDP3_DMA_HISTO_OP_CANCEL);
+	mdp3_clk_enable(0, 0);
 	if (ret)
 		pr_err("mdp3_histogram_stop error\n");
 
@@ -1099,11 +1222,17 @@
 	int ret;
 	struct mdp3_dma_histogram_data *mdp3_histo;
 
+	pr_debug("%s\n", __func__);
 	if (!session->dma->get_histo) {
 		pr_err("mdp3_histogram_collect not supported\n");
 		return -EINVAL;
 	}
 
+	if (!session->clk_on) {
+		pr_debug("mdp/dsi clock off currently\n");
+		return -EPERM;
+	}
+
 	mutex_lock(&session->histo_lock);
 
 	if (!session->histo_status) {
@@ -1114,7 +1243,9 @@
 
 	mutex_unlock(&session->histo_lock);
 
+	mdp3_clk_enable(1, 0);
 	ret = session->dma->get_histo(session->dma);
+	mdp3_clk_enable(0, 0);
 	if (ret) {
 		pr_debug("mdp3_histogram_collect error = %d\n", ret);
 		return ret;
@@ -1196,7 +1327,9 @@
 	ccs.post_lv = data->csc_data.csc_post_lv;
 
 	mutex_lock(&session->lock);
+	mdp3_clk_enable(1, 0);
 	ret = session->dma->config_ccs(session->dma, &config, &ccs);
+	mdp3_clk_enable(0, 0);
 	mutex_unlock(&session->lock);
 	return ret;
 }
@@ -1338,8 +1471,10 @@
 		return -EPERM;
 	}
 
+	mdp3_clk_enable(1, 0);
 	rc = mdp3_session->dma->config_lut(mdp3_session->dma, &lut_config,
 					&lut);
+	mdp3_clk_enable(0, 0);
 	if (rc)
 		pr_err("mdp3_ctrl_lut_update failed\n");
 
@@ -1355,7 +1490,7 @@
 	int rc = -EINVAL;
 	struct mdp3_session_data *mdp3_session;
 	struct msmfb_metadata metadata;
-	struct mdp_overlay req;
+	struct mdp_overlay *req = NULL;
 	struct msmfb_overlay_data ov_data;
 	int val;
 
@@ -1363,7 +1498,9 @@
 	if (!mdp3_session)
 		return -ENODEV;
 
-	if (!mdp3_session->status) {
+	req = &mdp3_session->req_overlay;
+
+	if (!mdp3_session->status && cmd != MSMFB_METADATA_GET) {
 		pr_err("mdp3_ctrl_ioctl_handler, display off!\n");
 		return -EPERM;
 	}
@@ -1381,7 +1518,10 @@
 	case MSMFB_VSYNC_CTRL:
 	case MSMFB_OVERLAY_VSYNC_CTRL:
 		if (!copy_from_user(&val, argp, sizeof(val))) {
+			mutex_lock(&mdp3_session->lock);
+			mdp3_session->vsync_enabled = val;
 			rc = mdp3_ctrl_vsync_enable(mfd, val);
+			mutex_unlock(&mdp3_session->lock);
 		} else {
 			pr_err("MSMFB_OVERLAY_VSYNC_CTRL failed\n");
 			rc = -EFAULT;
@@ -1402,23 +1542,23 @@
 			rc = copy_to_user(argp, &metadata, sizeof(metadata));
 		break;
 	case MSMFB_OVERLAY_GET:
-		rc = copy_from_user(&req, argp, sizeof(req));
+		rc = copy_from_user(req, argp, sizeof(*req));
 		if (!rc) {
-			rc = mdp3_overlay_get(mfd, &req);
+			rc = mdp3_overlay_get(mfd, req);
 
 		if (!IS_ERR_VALUE(rc))
-			rc = copy_to_user(argp, &req, sizeof(req));
+			rc = copy_to_user(argp, req, sizeof(*req));
 		}
 		if (rc)
 			pr_err("OVERLAY_GET failed (%d)\n", rc);
 		break;
 	case MSMFB_OVERLAY_SET:
-		rc = copy_from_user(&req, argp, sizeof(req));
+		rc = copy_from_user(req, argp, sizeof(*req));
 		if (!rc) {
-			rc = mdp3_overlay_set(mfd, &req);
+			rc = mdp3_overlay_set(mfd, req);
 
 		if (!IS_ERR_VALUE(rc))
-			rc = copy_to_user(argp, &req, sizeof(req));
+			rc = copy_to_user(argp, req, sizeof(*req));
 		}
 		if (rc)
 			pr_err("OVERLAY_SET failed (%d)\n", rc);
@@ -1470,6 +1610,8 @@
 	}
 	memset(mdp3_session, 0, sizeof(struct mdp3_session_data));
 	mutex_init(&mdp3_session->lock);
+	INIT_WORK(&mdp3_session->clk_off_work, mdp3_dispatch_clk_off);
+	atomic_set(&mdp3_session->vsync_countdown, 0);
 	mutex_init(&mdp3_session->histo_lock);
 	mdp3_session->dma = mdp3_get_dma_pipe(MDP3_DMA_CAP_ALL);
 	if (!mdp3_session->dma) {
@@ -1525,6 +1667,10 @@
 		goto init_done;
 	}
 
+	rc = mdp3_create_sysfs_link(dev);
+	if (rc)
+		pr_warn("problem creating link to mdp sysfs\n");
+
 	kobject_uevent(&dev->kobj, KOBJ_ADD);
 	pr_debug("vsync kobject_uevent(KOBJ_ADD)\n");
 
@@ -1533,6 +1679,9 @@
 		mdp3_ctrl_off(mfd);
 	}
 
+	if (mdp3_get_cont_spash_en())
+		mdp3_session->clk_on = 1;
+
 init_done:
 	if (IS_ERR_VALUE(rc))
 		kfree(mdp3_session);
diff --git a/drivers/video/msm/mdss/mdp3_ctrl.h b/drivers/video/msm/mdss/mdp3_ctrl.h
index 7c4f6ac..8d7627e 100644
--- a/drivers/video/msm/mdss/mdp3_ctrl.h
+++ b/drivers/video/msm/mdss/mdp3_ctrl.h
@@ -45,13 +45,19 @@
 	int vsync_period;
 	struct sysfs_dirent *vsync_event_sd;
 	struct mdp_overlay overlay;
+	struct mdp_overlay req_overlay;
 	struct mdp3_buffer_queue bufq_in;
 	struct mdp3_buffer_queue bufq_out;
+	struct work_struct clk_off_work;
 	int histo_status;
 	struct mutex histo_lock;
 	int lut_sel;
 	int cc_vect_sel;
 	bool first_commit;
+	int clk_on;
+
+	int vsync_enabled;
+	atomic_t vsync_countdown; /* Used to count down  */
 };
 
 int mdp3_ctrl_init(struct msm_fb_data_type *mfd);
diff --git a/drivers/video/msm/mdss/mdp3_dma.c b/drivers/video/msm/mdss/mdp3_dma.c
index 89f3e27..3a2c94b 100644
--- a/drivers/video/msm/mdss/mdp3_dma.c
+++ b/drivers/video/msm/mdss/mdp3_dma.c
@@ -828,6 +828,9 @@
 					MDP3_DMA_CALLBACK_TYPE_DMA_DONE);
 	mdp3_irq_disable(MDP3_INTR_LCDC_UNDERFLOW);
 
+	MDP3_REG_WRITE(MDP3_REG_INTR_ENABLE, 0);
+	MDP3_REG_WRITE(MDP3_REG_INTR_CLEAR, 0xfffffff);
+
 	init_completion(&dma->dma_comp);
 	dma->vsync_client.handler = NULL;
 	return ret;
diff --git a/drivers/video/msm/mdss/mdp3_hwio.h b/drivers/video/msm/mdss/mdp3_hwio.h
index 4afa37c..8846ec5 100644
--- a/drivers/video/msm/mdss/mdp3_hwio.h
+++ b/drivers/video/msm/mdss/mdp3_hwio.h
@@ -111,11 +111,11 @@
 #define MDP3_REG_DMA_P_DCVS_STATUS			0x90084
 
 /*DMA_S*/
-#define MDP3_REG_DMA_S_CONFIG				0x90000
-#define MDP3_REG_DMA_S_SIZE				0x90004
-#define MDP3_REG_DMA_S_IBUF_ADDR			0x90008
-#define MDP3_REG_DMA_S_IBUF_Y_STRIDE			0x9000C
-#define MDP3_REG_DMA_S_OUT_XY				0x90010
+#define MDP3_REG_DMA_S_CONFIG				0xA0000
+#define MDP3_REG_DMA_S_SIZE				0xA0004
+#define MDP3_REG_DMA_S_IBUF_ADDR			0xA0008
+#define MDP3_REG_DMA_S_IBUF_Y_STRIDE			0xA000C
+#define MDP3_REG_DMA_S_OUT_XY				0xA0010
 
 /*interface*/
 #define MDP3_REG_LCDC_EN				0xE0000
@@ -221,6 +221,9 @@
 #define MDP3_PPP_BG_UNPACK_PATTERN1	0x101D8
 #define MDP3_PPP_BG_UNPACK_PATTERN2	0x101DC
 
+#define MDP3_TFETCH_SOLID_FILL		0x20004
+#define MDP3_TFETCH_FILL_COLOR		0x20040
+
 #define MDP3_PPP_BLEND_PARAM		0x1014C
 
 #define MDP3_PPP_BLEND_BG_ALPHA_SEL	0x70010
diff --git a/drivers/video/msm/mdss/mdp3_ppp.c b/drivers/video/msm/mdss/mdp3_ppp.c
index 8f6168a..a64a6b4 100644
--- a/drivers/video/msm/mdss/mdp3_ppp.c
+++ b/drivers/video/msm/mdss/mdp3_ppp.c
@@ -36,6 +36,8 @@
 #define MDP_PPP_MAX_BPP 4
 #define MDP_PPP_DYNAMIC_FACTOR 3
 #define MDP_PPP_MAX_READ_WRITE 3
+#define ENABLE_SOLID_FILL	0x2
+#define DISABLE_SOLID_FILL	0x0
 
 static const bool valid_fmt[MDP_IMGTYPE_LIMIT] = {
 	[MDP_RGB_565] = true,
@@ -370,14 +372,14 @@
 		ib = (ab * 3) / 2;
 	}
 	mdp3_clk_set_rate(MDP3_CLK_CORE, rate, MDP3_CLIENT_PPP);
-	rc = mdp3_clk_enable(on_off);
+	rc = mdp3_clk_enable(on_off, 0);
 	if (rc < 0) {
 		pr_err("%s: mdp3_clk_enable failed\n", __func__);
 		return rc;
 	}
 	rc = mdp3_bus_scale_set_quota(MDP3_CLIENT_PPP, ab, ib);
 	if (rc < 0) {
-		mdp3_clk_enable(!on_off);
+		mdp3_clk_enable(!on_off, 0);
 		pr_err("%s: scale_set_quota failed\n", __func__);
 		return rc;
 	}
@@ -390,6 +392,23 @@
 	/* Wait for the pipe to clear */
 	do { } while (mdp3_ppp_pipe_wait() <= 0);
 	config_ppp_op_mode(blit_op);
+	if (blit_op->solid_fill) {
+		MDP3_REG_WRITE(0x10138, 0x10000000);
+		MDP3_REG_WRITE(0x1014c, 0xffffffff);
+		MDP3_REG_WRITE(0x101b8, 0);
+		MDP3_REG_WRITE(0x101bc, 0);
+		MDP3_REG_WRITE(0x1013c, 0);
+		MDP3_REG_WRITE(0x10140, 0);
+		MDP3_REG_WRITE(0x10144, 0);
+		MDP3_REG_WRITE(0x10148, 0);
+		MDP3_REG_WRITE(MDP3_TFETCH_FILL_COLOR,
+					blit_op->solid_fill_color);
+		MDP3_REG_WRITE(MDP3_TFETCH_SOLID_FILL,
+					ENABLE_SOLID_FILL);
+	} else {
+		MDP3_REG_WRITE(MDP3_TFETCH_SOLID_FILL,
+					DISABLE_SOLID_FILL);
+	}
 	mdp3_ppp_kickoff();
 }
 
@@ -489,6 +508,26 @@
 
 	if (req->flags & MDP_BLUR)
 		blit_op->mdp_op |= MDPOP_ASCALE | MDPOP_BLUR;
+
+	if (req->flags & MDP_SOLID_FILL) {
+		blit_op->solid_fill = true;
+
+		/* Avoid odd width, as it could hang ppp during solid fill */
+		blit_op->dst.roi.width = (blit_op->dst.roi.width / 2) * 2;
+		blit_op->src.roi.width = (blit_op->src.roi.width / 2) * 2;
+
+		/* Avoid RGBA format, as it could hang ppp during solid fill */
+		if (blit_op->src.color_fmt == MDP_RGBA_8888)
+			blit_op->src.color_fmt = MDP_RGBX_8888;
+		if (blit_op->dst.color_fmt == MDP_RGBA_8888)
+			blit_op->dst.color_fmt = MDP_RGBX_8888;
+		blit_op->solid_fill_color = (req->const_color.g & 0xFF)|
+				(req->const_color.r & 0xFF) << 8 |
+				(req->const_color.b & 0xFF)  << 16 |
+				(req->const_color.alpha & 0xFF) << 24;
+	} else {
+		blit_op->solid_fill = false;
+	}
 }
 
 static void mdp3_ppp_tile_workaround(struct ppp_blit_op *blit_op,
@@ -502,7 +541,6 @@
 
 	src_w = req->src_rect.w;
 	dst_h = blit_op->dst.roi.height;
-	pr_err("TMsg: In workaround. srcw= %d, dstH=%d\n", src_w, dst_h);
 	/* bg tile fetching HW workaround */
 	for (i = 0; i < (req->dst_rect.h / 16); i++) {
 		/* this tile size */
@@ -792,9 +830,10 @@
 	}
 	is_bpp_4 = (ret == 4) ? 1 : 0;
 
-	if ((is_bpp_4 && (remainder == 6 || remainder == 14)))
+	if ((is_bpp_4 && (remainder == 6 || remainder == 14)) &&
+						!(req->flags & MDP_SOLID_FILL))
 		ret = mdp3_ppp_blit_workaround(mfd, req, remainder,
-				src_data, dst_data);
+							src_data, dst_data);
 	else
 		ret = mdp3_ppp_blit(mfd, req, src_data, dst_data);
 	return ret;
diff --git a/drivers/video/msm/mdss/mdp3_ppp.h b/drivers/video/msm/mdss/mdp3_ppp.h
index b4252ca..9753e94 100644
--- a/drivers/video/msm/mdss/mdp3_ppp.h
+++ b/drivers/video/msm/mdss/mdp3_ppp.h
@@ -332,6 +332,8 @@
 	struct ppp_img_desc bg;
 	struct ppp_blend blend;
 	uint32_t mdp_op; /* Operations */
+	uint32_t solid_fill_color;
+	bool solid_fill;
 };
 
 struct ppp_edge_rep {
diff --git a/drivers/video/msm/mdss/mdss.h b/drivers/video/msm/mdss/mdss.h
index 5857606..61c4acd 100644
--- a/drivers/video/msm/mdss/mdss.h
+++ b/drivers/video/msm/mdss/mdss.h
@@ -28,6 +28,8 @@
 #define MDSS_REG_WRITE(addr, val) writel_relaxed(val, mdss_res->mdp_base + addr)
 #define MDSS_REG_READ(addr) readl_relaxed(mdss_res->mdp_base + addr)
 
+#define MAX_DRV_SUP_MMB_BLKS	44
+
 enum mdss_mdp_clk_type {
 	MDSS_CLK_AHB,
 	MDSS_CLK_AXI,
@@ -113,6 +115,9 @@
 	u32 nvig_pipes;
 	u32 nrgb_pipes;
 	u32 ndma_pipes;
+
+	DECLARE_BITMAP(mmb_alloc_map, MAX_DRV_SUP_MMB_BLKS);
+
 	struct mdss_mdp_mixer *mixer_intf;
 	struct mdss_mdp_mixer *mixer_wb;
 	u32 nmixers_intf;
@@ -160,6 +165,7 @@
 void mdss_enable_irq(struct mdss_hw *hw);
 void mdss_disable_irq(struct mdss_hw *hw);
 void mdss_disable_irq_nosync(struct mdss_hw *hw);
+void mdss_bus_bandwidth_ctrl(int enable);
 
 static inline struct ion_client *mdss_get_ionclient(void)
 {
diff --git a/drivers/video/msm/mdss/mdss_dsi.c b/drivers/video/msm/mdss/mdss_dsi.c
index 865775a..bb1f8ae 100644
--- a/drivers/video/msm/mdss/mdss_dsi.c
+++ b/drivers/video/msm/mdss/mdss_dsi.c
@@ -1216,7 +1216,8 @@
 		}
 	}
 
-	if (gpio_is_valid(ctrl_pdata->disp_te_gpio)) {
+	if (gpio_is_valid(ctrl_pdata->disp_te_gpio) &&
+					pinfo->type == MIPI_CMD_PANEL) {
 		rc = gpio_request(ctrl_pdata->disp_te_gpio, "disp_te");
 		if (rc) {
 			pr_err("request TE gpio failed, rc=%d\n",
@@ -1304,6 +1305,7 @@
 	}
 
 	ctrl_pdata->panel_data.event_handler = mdss_dsi_event_handler;
+	ctrl_pdata->check_status = mdss_dsi_bta_status_check;
 
 	if (ctrl_pdata->bklt_ctrl == BL_PWM)
 		mdss_dsi_panel_pwm_cfg(ctrl_pdata);
diff --git a/drivers/video/msm/mdss/mdss_dsi.h b/drivers/video/msm/mdss/mdss_dsi.h
index 6953d8b..7202c62 100644
--- a/drivers/video/msm/mdss/mdss_dsi.h
+++ b/drivers/video/msm/mdss/mdss_dsi.h
@@ -118,6 +118,8 @@
 
 #define DSI_INTR_ERROR_MASK		BIT(25)
 #define DSI_INTR_ERROR			BIT(24)
+#define DSI_INTR_BTA_DONE_MASK          BIT(21)
+#define DSI_INTR_BTA_DONE               BIT(20)
 #define DSI_INTR_VIDEO_DONE_MASK	BIT(17)
 #define DSI_INTR_VIDEO_DONE		BIT(16)
 #define DSI_INTR_CMD_MDP_DONE_MASK	BIT(9)
@@ -133,6 +135,7 @@
 
 #define DSI_VIDEO_TERM  BIT(16)
 #define DSI_MDP_TERM    BIT(8)
+#define DSI_BTA_TERM    BIT(1)
 #define DSI_CMD_TERM    BIT(0)
 
 extern struct device dsi_dev;
@@ -266,8 +269,6 @@
 
 #define CMD_REQ_MAX     4
 
-typedef void (*fxn)(u32 data);
-
 #define CMD_REQ_RX      0x0001
 #define CMD_REQ_COMMIT  0x0002
 #define CMD_CLK_CTRL    0x0004
@@ -278,7 +279,8 @@
 	int cmds_cnt;
 	u32 flags;
 	int rlen;       /* rx length */
-	fxn cb;
+	char *rbuf;	/* rx buf */
+	void (*cb)(int data);
 };
 
 struct dcs_cmd_list {
@@ -316,10 +318,12 @@
 	int (*on) (struct mdss_panel_data *pdata);
 	int (*off) (struct mdss_panel_data *pdata);
 	int (*partial_update_fnc) (struct mdss_panel_data *pdata);
+	int (*check_status) (struct mdss_dsi_ctrl_pdata *pdata);
 	struct mdss_panel_data panel_data;
 	unsigned char *ctrl_base;
 	int reg_size;
 	u32 clk_cnt;
+	struct clk *mdp_core_clk;
 	struct clk *ahb_clk;
 	struct clk *axi_clk;
 	struct clk *byte_clk;
@@ -360,6 +364,7 @@
 	struct completion dma_comp;
 	struct completion mdp_comp;
 	struct completion video_comp;
+	struct completion bta_comp;
 	spinlock_t irq_lock;
 	spinlock_t mdp_lock;
 	int mdp_busy;
@@ -382,7 +387,7 @@
 		struct dsi_cmd_desc *cmds, int cnt);
 
 int mdss_dsi_cmds_rx(struct mdss_dsi_ctrl_pdata *ctrl,
-			struct dsi_cmd_desc *cmds, int rlen, u32 rx_flags);
+			struct dsi_cmd_desc *cmds, int rlen);
 
 void mdss_dsi_host_init(struct mipi_panel_info *pinfo,
 				struct mdss_panel_data *pdata);
@@ -428,6 +433,7 @@
 				struct dcs_cmd_req *cmdreq);
 struct dcs_cmd_req *mdss_dsi_cmdlist_get(struct mdss_dsi_ctrl_pdata *ctrl);
 void mdss_dsi_cmdlist_kickoff(int intf);
+int mdss_dsi_bta_status_check(struct mdss_dsi_ctrl_pdata *ctrl);
 
 int mdss_dsi_panel_init(struct device_node *node,
 		struct mdss_dsi_ctrl_pdata *ctrl_pdata,
diff --git a/drivers/video/msm/mdss/mdss_dsi_host.c b/drivers/video/msm/mdss/mdss_dsi_host.c
index 845ef10..750fbf3 100644
--- a/drivers/video/msm/mdss/mdss_dsi_host.c
+++ b/drivers/video/msm/mdss/mdss_dsi_host.c
@@ -49,6 +49,8 @@
 
 #define DSI_EVENT_Q_MAX	4
 
+#define DSI_BTA_EVENT_TIMEOUT (HZ / 10)
+
 /* event */
 struct dsi_event_q {
 	struct mdss_dsi_ctrl_pdata *ctrl;
@@ -98,6 +100,7 @@
 	init_completion(&ctrl->dma_comp);
 	init_completion(&ctrl->mdp_comp);
 	init_completion(&ctrl->video_comp);
+	init_completion(&ctrl->bta_comp);
 	spin_lock_init(&ctrl->irq_lock);
 	spin_lock_init(&ctrl->mdp_lock);
 	mutex_init(&ctrl->mutex);
@@ -760,17 +763,10 @@
 
 static int mdss_dsi_long_read_resp(struct dsi_buf *rp)
 {
-	short len;
-
-	len = rp->data[2];
-	len <<= 8;
-	len |= rp->data[1];
 	/* strip out dcs header */
 	rp->data += 4;
 	rp->len -= 4;
-	/* strip out 2 bytes of checksum */
-	rp->len -= 2;
-	return len;
+	return rp->len;
 }
 
 void mdss_dsi_cmd_test_pattern(struct mdss_panel_data *pdata)
@@ -1114,14 +1110,14 @@
 
 	if (mode == DSI_VIDEO_MODE) {
 		dsi_ctrl |= 0x03;
-		intr_ctrl = DSI_INTR_CMD_DMA_DONE_MASK;
+		intr_ctrl = DSI_INTR_CMD_DMA_DONE_MASK | DSI_INTR_BTA_DONE_MASK;
 	} else {		/* command mode */
 		dsi_ctrl |= 0x05;
 		if (pdata->panel_info.type == MIPI_VIDEO_PANEL)
 			dsi_ctrl |= 0x02;
 
 		intr_ctrl = DSI_INTR_CMD_DMA_DONE_MASK | DSI_INTR_ERROR_MASK |
-				DSI_INTR_CMD_MDP_DONE_MASK;
+			DSI_INTR_CMD_MDP_DONE_MASK | DSI_INTR_BTA_DONE_MASK;
 	}
 
 	if (ctrl_pdata->shared_pdata.broadcast_enable)
@@ -1167,6 +1163,45 @@
 	pr_debug("%s: BTA done, status = %d\n", __func__, status);
 }
 
+int mdss_dsi_bta_status_check(struct mdss_dsi_ctrl_pdata *ctrl_pdata)
+{
+	int ret = 0;
+	unsigned long flag;
+
+	if (ctrl_pdata == NULL) {
+		pr_err("%s: Invalid input data\n", __func__);
+
+		/*
+		 * This should not return error otherwise
+		 * BTA status thread will treat it as dead panel scenario
+		 * and request for blank/unblank
+		 */
+		return 0;
+	}
+
+	pr_debug("%s: Checking BTA status\n", __func__);
+
+	mdss_dsi_clk_ctrl(ctrl_pdata, 1);
+	spin_lock_irqsave(&ctrl_pdata->mdp_lock, flag);
+	INIT_COMPLETION(ctrl_pdata->bta_comp);
+	mdss_dsi_enable_irq(ctrl_pdata, DSI_BTA_TERM);
+	spin_unlock_irqrestore(&ctrl_pdata->mdp_lock, flag);
+	MIPI_OUTP(ctrl_pdata->ctrl_base + 0x098, 0x01); /* trigger  */
+	wmb();
+
+	ret = wait_for_completion_killable_timeout(&ctrl_pdata->bta_comp,
+						DSI_BTA_EVENT_TIMEOUT);
+	if (ret <= 0) {
+		mdss_dsi_disable_irq(ctrl_pdata, DSI_BTA_TERM);
+		pr_err("%s: DSI BTA error: %i\n", __func__, ret);
+	}
+
+	mdss_dsi_clk_ctrl(ctrl_pdata, 0);
+	pr_debug("%s: BTA done with ret: %d\n", __func__, ret);
+
+	return ret;
+}
+
 static char set_tear_on[2] = {0x35, 0x00};
 static struct dsi_cmd_desc dsi_tear_on_cmd = {
 	{DTYPE_DCS_WRITE1, 1, 0, 0, 0, sizeof(set_tear_on)}, set_tear_on};
@@ -1254,7 +1289,8 @@
 		mdss_dsi_buf_reserve(tp, len);
 		len = mdss_dsi_cmd_dma_add(tp, cm);
 		if (!len) {
-			pr_err("%s: failed to call cmd_dma_add\n", __func__);
+			pr_err("%s: failed to add cmd = 0x%x\n",
+				__func__,  cm->payload[0]);
 			return -EINVAL;
 		}
 		tot += len;
@@ -1357,24 +1393,25 @@
 };
 
 /*
- * DSI panel reply with  MAX_RETURN_PACKET_SIZE bytes of data
- * plus DCS header, ECC and CRC for DCS long read response
- * mdss_dsi_controller only have 4x32 bits register ( 16 bytes) to
- * hold data per transaction.
- * MIPI_DSI_LEN equal to 8
- * len should be either 4 or 8
- * any return data more than MIPI_DSI_LEN need to be break down
- * to multiple transactions.
+ * mdss_dsi_cmds_rx() - dcs read from panel
+ * @ctrl: dsi controller
+ * @cmds: read command descriptor
+ * @len: number of bytes to read back
  *
- * ov_mutex need to be acquired before call this function.
+ * controller have 4 registers can hold 16 bytes of rxed data
+ * dcs packet: 4 bytes header + payload + 2 bytes crc
+ * 2 padding bytes add to payload to have payload length is mutipled by 4
+ * 1st read: 4 bytes header + 8 bytes payload + 2 padding + 2 crc
+ * 2nd read: 12 bytes payload + 2 padding + 2 crc
+ * 3rd read: 12 bytes payload + 2 padding + 2 crc
+ *
  */
-
 int mdss_dsi_cmds_rx(struct mdss_dsi_ctrl_pdata *ctrl,
-			struct dsi_cmd_desc *cmds, int rlen, u32 rx_flags)
+			struct dsi_cmd_desc *cmds, int rlen)
 {
-	int cnt, len, diff, pkt_size, ret = 0;
+	int data_byte, rx_byte, dlen, end;
+	int short_response, diff, pkt_size, ret = 0;
 	struct dsi_buf *tp, *rp;
-	int no_max_pkt_size;
 	char cmd;
 	u32 dsi_ctrl, data;
 	int video_mode;
@@ -1416,109 +1453,109 @@
 		MIPI_OUTP((ctrl->ctrl_base) + 0x0004, data);
 	}
 
-	no_max_pkt_size = rx_flags & CMD_REQ_NO_MAX_PKT_SIZE;
-	if (no_max_pkt_size)
-		rlen = ALIGN(rlen, 4); /* Only support rlen = 4*n */
-
-	len = rlen;
-	diff = 0;
-
-	if (len <= 2)
-		cnt = 4;	/* short read */
-	else {
-		if (len > MDSS_DSI_LEN)
-			len = MDSS_DSI_LEN;	/* 8 bytes at most */
-
-		len = ALIGN(len, 4); /* len 4 bytes align */
-		diff = len - rlen;
+	if (rlen == 0) {
+		short_response = 1;
+		rx_byte = 4;
+	} else {
+		short_response = 0;
+		data_byte = 8;	/* first read */
 		/*
-		 * add extra 2 bytes to len to have overall
+		 * add extra 2 padding bytes to have overall
 		 * packet size is multipe by 4. This also make
 		 * sure 4 bytes dcs headerlocates within a
 		 * 32 bits register after shift in.
-		 * after all, len should be either 6 or 10.
 		 */
-		len += 2;
-		cnt = len + 6; /* 4 bytes header + 2 bytes crc */
+		pkt_size = data_byte + 2;
+		rx_byte = data_byte + 8; /* 4 header + 2 crc  + 2 padding*/
 	}
 
+
 	tp = &ctrl->tx_buf;
 	rp = &ctrl->rx_buf;
 
-	if (!no_max_pkt_size) {
-		/* packet size need to be set at every read */
-		pkt_size = len;
-		max_pktsize[0] = pkt_size;
+	end = 0;
+	mdss_dsi_buf_init(rp);
+	while (!end) {
+		pr_debug("%s:  rlen=%d pkt_size=%d rx_byte=%d\n",
+				__func__, rlen, pkt_size, rx_byte);
+		 if (!short_response) {
+			max_pktsize[0] = pkt_size;
+			mdss_dsi_buf_init(tp);
+			ret = mdss_dsi_cmd_dma_add(tp, &pkt_size_cmd);
+			if (!ret) {
+				pr_err("%s: failed to add max_pkt_size\n",
+					__func__);
+				rp->len = 0;
+				goto end;
+			}
+
+			mdss_dsi_wait4video_eng_busy(ctrl);
+
+			mdss_dsi_enable_irq(ctrl, DSI_CMD_TERM);
+			ret = mdss_dsi_cmd_dma_tx(ctrl, tp);
+			if (IS_ERR_VALUE(ret)) {
+				mdss_dsi_disable_irq(ctrl, DSI_CMD_TERM);
+				pr_err("%s: failed to tx max_pkt_size\n",
+					__func__);
+				rp->len = 0;
+				goto end;
+			}
+			pr_debug("%s: max_pkt_size=%d sent\n",
+						__func__, pkt_size);
+		}
+
 		mdss_dsi_buf_init(tp);
-		ret = mdss_dsi_cmd_dma_add(tp, &pkt_size_cmd);
+		ret = mdss_dsi_cmd_dma_add(tp, cmds);
 		if (!ret) {
-			pr_err("%s: failed to call\n",
-				__func__);
+			pr_err("%s: failed to add cmd = 0x%x\n",
+				__func__,  cmds->payload[0]);
 			rp->len = 0;
 			goto end;
 		}
 
-		mdss_dsi_wait4video_eng_busy(ctrl);
-
+		mdss_dsi_wait4video_eng_busy(ctrl);	/* video mode only */
 		mdss_dsi_enable_irq(ctrl, DSI_CMD_TERM);
+		/* transmit read comamnd to client */
 		ret = mdss_dsi_cmd_dma_tx(ctrl, tp);
 		if (IS_ERR_VALUE(ret)) {
 			mdss_dsi_disable_irq(ctrl, DSI_CMD_TERM);
-			pr_err("%s: failed to call\n",
-				__func__);
+			pr_err("%s: failed to tx cmd = 0x%x\n",
+				__func__,  cmds->payload[0]);
 			rp->len = 0;
 			goto end;
 		}
-		pr_debug("%s: Max packet size sent\n", __func__);
-	}
-	mdss_dsi_buf_init(tp);
-	ret = mdss_dsi_cmd_dma_add(tp, cmds);
-	if (!ret) {
-		pr_err("%s: failed to call cmd_dma_add for cmd = 0x%x\n",
-			__func__,  cmds->payload[0]);
-		rp->len = 0;
-		goto end;
-	}
-
-	mdss_dsi_wait4video_eng_busy(ctrl);
-
-	mdss_dsi_enable_irq(ctrl, DSI_CMD_TERM);
-	/* transmit read comamnd to client */
-	ret = mdss_dsi_cmd_dma_tx(ctrl, tp);
-	if (IS_ERR_VALUE(ret)) {
-		mdss_dsi_disable_irq(ctrl, DSI_CMD_TERM);
-		pr_err("%s: failed to call\n",
-			__func__);
-		rp->len = 0;
-		goto end;
-	}
-	/*
-	 * once cmd_dma_done interrupt received,
-	 * return data from client is ready and stored
-	 * at RDBK_DATA register already
-	 */
-	mdss_dsi_buf_init(rp);
-	if (no_max_pkt_size) {
 		/*
-		 * expect rlen = n * 4
-		 * short alignement for start addr
+		 * once cmd_dma_done interrupt received,
+		 * return data from client is ready and stored
+		 * at RDBK_DATA register already
+		 * since rx fifo is 16 bytes, dcs header is kept at first loop,
+		 * after that dcs header lost during shift into registers
 		 */
-		rp->data += 2;
+		dlen = mdss_dsi_cmd_dma_rx(ctrl, rp, rx_byte);
+
+		if (short_response)
+			break;
+
+		if (rlen <= data_byte) {
+			diff = data_byte - rlen;
+			end = 1;
+		} else {
+			diff = 0;
+			rlen -= data_byte;
+		}
+
+		dlen -= 2; /* 2 padding bytes */
+		dlen -= 2; /* 2 crc */
+		dlen -= diff;
+		rp->data += dlen;	/* next start position */
+		rp->len += dlen;
+		data_byte = 12;	/* NOT first read */
+		pkt_size += data_byte;
+		pr_debug("%s: rp data=%x len=%d dlen=%d diff=%d\n",
+			__func__, (int)rp->data, rp->len, dlen, diff);
 	}
 
-	mdss_dsi_cmd_dma_rx(ctrl, rp, cnt);
-
-	if (no_max_pkt_size) {
-		/*
-		 * remove extra 2 bytes from previous
-		 * rx transaction at shift register
-		 * which was inserted during copy
-		 * shift registers to rx buffer
-		 * rx payload start from long alignment addr
-		 */
-		rp->data += 2;
-	}
-
+	rp->data = rp->start;	/* move back to start position */
 	cmd = rp->data[0];
 	switch (cmd) {
 	case DTYPE_ACK_ERR_RESP:
@@ -1535,8 +1572,6 @@
 	case DTYPE_GEN_LREAD_RESP:
 	case DTYPE_DCS_LREAD_RESP:
 		mdss_dsi_long_read_resp(rp);
-		rp->len -= 2; /* extra 2 bytes added */
-		rp->len -= diff; /* align bytes */
 		break;
 	default:
 		pr_warning("%s:Invalid response cmd\n", __func__);
@@ -1618,14 +1653,14 @@
 }
 
 static int mdss_dsi_cmd_dma_rx(struct mdss_dsi_ctrl_pdata *ctrl,
-			struct dsi_buf *rp, int rlen)
+			struct dsi_buf *rp, int rx_byte)
 
 {
 	u32 *lp, data;
 	int i, off, cnt;
 
 	lp = (u32 *)rp->data;
-	cnt = rlen;
+	cnt = rx_byte;
 	cnt += 3;
 	cnt >>= 2;
 
@@ -1641,9 +1676,9 @@
 		pr_debug("%s: data = 0x%x and ntohl(data) = 0x%x\n",
 					 __func__, data, ntohl(data));
 		off -= 4;
-		rp->len += sizeof(*lp);
 	}
-	return rlen;
+
+	return rx_byte;
 }
 
 
@@ -1736,17 +1771,19 @@
 void mdss_dsi_cmdlist_rx(struct mdss_dsi_ctrl_pdata *ctrl,
 				struct dcs_cmd_req *req)
 {
-	int len;
-	u32 data, *dp;
 	struct dsi_buf *rp;
+	int len = 0;
 
-	len = mdss_dsi_cmds_rx(ctrl, req->cmds, req->rlen, req->flags);
-	rp = &ctrl->rx_buf;
-	dp = (u32 *)rp->data;
-	data = *dp;
+	if (req->rbuf) {
+		rp = &ctrl->rx_buf;
+		len = mdss_dsi_cmds_rx(ctrl, req->cmds, req->rlen);
+		memcpy(req->rbuf, rp->data, rp->len);
+	} else {
+		pr_err("%s: No rx buffer provided\n", __func__);
+	}
 
 	if (req->cb)
-		req->cb(data);
+		req->cb(len);
 }
 
 void mdss_dsi_cmdlist_commit(struct mdss_dsi_ctrl_pdata *ctrl, int from_mdp)
@@ -1764,6 +1801,14 @@
 	if (req == NULL)
 		goto need_lock;
 
+	/*
+	 * mdss interrupt is generated in mdp core clock domain
+	 * mdp clock need to be enabled to receive dsi interrupt
+	 * also, axi bus bandwidth need since dsi controller will
+	 * fetch dcs commands from axi bus
+	 */
+	mdss_bus_bandwidth_ctrl(1);
+
 	pr_debug("%s:  from_mdp=%d pid=%d\n", __func__, from_mdp, current->pid);
 	mdss_dsi_clk_ctrl(ctrl, 1);
 
@@ -1773,6 +1818,7 @@
 		mdss_dsi_cmdlist_tx(ctrl, req);
 
 	mdss_dsi_clk_ctrl(ctrl, 0);
+	mdss_bus_bandwidth_ctrl(0);
 
 need_lock:
 
@@ -2074,5 +2120,12 @@
 		spin_unlock(&ctrl->mdp_lock);
 	}
 
+	if (isr & DSI_INTR_BTA_DONE) {
+		spin_lock(&ctrl->mdp_lock);
+		mdss_dsi_disable_irq_nosync(ctrl, DSI_BTA_TERM);
+		complete(&ctrl->bta_comp);
+		spin_unlock(&ctrl->mdp_lock);
+	}
+
 	return IRQ_HANDLED;
 }
diff --git a/drivers/video/msm/mdss/mdss_dsi_panel.c b/drivers/video/msm/mdss/mdss_dsi_panel.c
index 33109e1..03dbd4d 100644
--- a/drivers/video/msm/mdss/mdss_dsi_panel.c
+++ b/drivers/video/msm/mdss/mdss_dsi_panel.c
@@ -106,8 +106,8 @@
 	dcs_cmd
 };
 
-u32 mdss_dsi_dcs_read(struct mdss_dsi_ctrl_pdata *ctrl,
-			char cmd0, char cmd1)
+u32 mdss_dsi_panel_cmd_read(struct mdss_dsi_ctrl_pdata *ctrl, char cmd0,
+		char cmd1, void (*fxn)(int), char *rbuf, int len)
 {
 	struct dcs_cmd_req cmdreq;
 
@@ -117,8 +117,9 @@
 	cmdreq.cmds = &dcs_read_cmd;
 	cmdreq.cmds_cnt = 1;
 	cmdreq.flags = CMD_REQ_RX | CMD_REQ_COMMIT;
-	cmdreq.rlen = 1;
-	cmdreq.cb = NULL; /* call back */
+	cmdreq.rlen = len;
+	cmdreq.rbuf = rbuf;
+	cmdreq.cb = fxn; /* call back */
 	mdss_dsi_cmdlist_put(ctrl, &cmdreq);
 	/*
 	 * blocked here, until call back called
@@ -292,6 +293,15 @@
 	ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
 				panel_data);
 
+	/*
+	 * Some backlight controllers specify a minimum duty cycle
+	 * for the backlight brightness. If the brightness is less
+	 * than it, the controller can malfunction.
+	 */
+
+	if ((bl_level < pdata->panel_info.bl_min) && (bl_level != 0))
+		bl_level = pdata->panel_info.bl_min;
+
 	switch (ctrl_pdata->bklt_ctrl) {
 	case BL_WLED:
 		led_trigger_event(bl_led_trigger, bl_level);
@@ -388,7 +398,7 @@
 		if (dchdr->dlen > len) {
 			pr_err("%s: dtsi cmd=%x error, len=%d",
 				__func__, dchdr->dtype, dchdr->dlen);
-			return -ENOMEM;
+			goto exit_free;
 		}
 		bp += sizeof(*dchdr);
 		len -= sizeof(*dchdr);
@@ -400,14 +410,13 @@
 	if (len != 0) {
 		pr_err("%s: dcs_cmd=%x len=%d error!",
 				__func__, buf[0], blen);
-		kfree(buf);
-		return -ENOMEM;
+		goto exit_free;
 	}
 
 	pcmds->cmds = kzalloc(cnt * sizeof(struct dsi_cmd_desc),
 						GFP_KERNEL);
 	if (!pcmds->cmds)
-		return -ENOMEM;
+		goto exit_free;
 
 	pcmds->cmd_cnt = cnt;
 	pcmds->buf = buf;
@@ -435,6 +444,10 @@
 		pcmds->buf[0], pcmds->blen, pcmds->cmd_cnt, pcmds->link_state);
 
 	return 0;
+
+exit_free:
+	kfree(buf);
+	return -ENOMEM;
 }
 
 
diff --git a/drivers/video/msm/mdss/mdss_dsi_status.c b/drivers/video/msm/mdss/mdss_dsi_status.c
new file mode 100644
index 0000000..f0c4f4c
--- /dev/null
+++ b/drivers/video/msm/mdss/mdss_dsi_status.c
@@ -0,0 +1,208 @@
+/* Copyright (c) 2013, The Linux Foundation. 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.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/fb.h>
+#include <linux/notifier.h>
+#include <linux/workqueue.h>
+#include <linux/delay.h>
+#include <linux/debugfs.h>
+#include <linux/slab.h>
+#include <linux/uaccess.h>
+#include <linux/iopoll.h>
+#include <linux/kobject.h>
+#include <linux/string.h>
+#include <linux/sysfs.h>
+
+#include "mdss_fb.h"
+#include "mdss_dsi.h"
+#include "mdss_panel.h"
+#include "mdss_mdp.h"
+
+#define STATUS_CHECK_INTERVAL 5000
+
+struct dsi_status_data {
+	struct notifier_block fb_notifier;
+	struct delayed_work check_status;
+	struct msm_fb_data_type *mfd;
+	uint32_t check_interval;
+};
+struct dsi_status_data *pstatus_data;
+static uint32_t interval = STATUS_CHECK_INTERVAL;
+
+/*
+ * check_dsi_ctrl_status() - Check DSI controller status periodically.
+ * @work  : dsi controller status data
+ *
+ * This function calls check_status API on DSI controller to send the BTA
+ * command. If DSI controller fails to acknowledge the BTA command, it sends
+ * the PANEL_ALIVE=0 status to HAL layer.
+ */
+static void check_dsi_ctrl_status(struct work_struct *work)
+{
+	struct dsi_status_data *pdsi_status = NULL;
+	struct mdss_panel_data *pdata = NULL;
+	struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL;
+	struct mdss_overlay_private *mdp5_data = NULL;
+	struct mdss_mdp_ctl *ctl = NULL;
+	int ret = 0;
+
+	pdsi_status = container_of(to_delayed_work(work),
+		struct dsi_status_data, check_status);
+	if (!pdsi_status) {
+		pr_err("%s: DSI status data not available\n", __func__);
+		return;
+	}
+
+	pdata = dev_get_platdata(&pdsi_status->mfd->pdev->dev);
+	if (!pdata) {
+		pr_err("%s: Panel data not available\n", __func__);
+		return;
+	}
+
+	ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata,
+							panel_data);
+	if (!ctrl_pdata || !ctrl_pdata->check_status) {
+		pr_err("%s: DSI ctrl or status_check callback not available\n",
+								__func__);
+		return;
+	}
+
+	mdp5_data = mfd_to_mdp5_data(pdsi_status->mfd);
+	ctl = mfd_to_ctl(pdsi_status->mfd);
+
+	if (ctl->shared_lock)
+		mutex_lock(ctl->shared_lock);
+	mutex_lock(&mdp5_data->ov_lock);
+
+	/*
+	 * For the command mode panels, we return pan display
+	 * IOCTL on vsync interrupt. So, after vsync interrupt comes
+	 * and when DMA_P is in progress, if the panel stops responding
+	 * and if we trigger BTA before DMA_P finishes, then the DSI
+	 * FIFO will not be cleared since the DSI data bus control
+	 * doesn't come back to the host after BTA. This may cause the
+	 * display reset not to be proper. Hence, wait for DMA_P done
+	 * for command mode panels before triggering BTA.
+	 */
+	if (ctl->wait_pingpong)
+		ctl->wait_pingpong(ctl, NULL);
+
+	pr_debug("%s: DSI ctrl wait for ping pong done\n", __func__);
+
+	mdss_mdp_clk_ctrl(MDP_BLOCK_POWER_ON, false);
+	ret = ctrl_pdata->check_status(ctrl_pdata);
+	mdss_mdp_clk_ctrl(MDP_BLOCK_POWER_OFF, false);
+
+	mutex_unlock(&mdp5_data->ov_lock);
+	if (ctl->shared_lock)
+		mutex_unlock(ctl->shared_lock);
+
+	if ((pdsi_status->mfd->panel_power_on)) {
+		if (ret > 0) {
+			schedule_delayed_work(&pdsi_status->check_status,
+				msecs_to_jiffies(pdsi_status->check_interval));
+		} else {
+			char *envp[2] = {"PANEL_ALIVE=0", NULL};
+			pdata->panel_info.panel_dead = true;
+			ret = kobject_uevent_env(
+				&pdsi_status->mfd->fbi->dev->kobj,
+							KOBJ_CHANGE, envp);
+			pr_err("%s: Panel has gone bad, sending uevent - %s\n",
+							__func__, envp[0]);
+		}
+	}
+}
+
+/*
+ * fb_event_callback() - Call back function for the fb_register_client()
+ *			 notifying events
+ * @self  : notifier block
+ * @event : The event that was triggered
+ * @data  : Of type struct fb_event
+ *
+ * This function listens for FB_BLANK_UNBLANK and FB_BLANK_POWERDOWN events
+ * from frame buffer. DSI status check work is either scheduled again after
+ * PANEL_STATUS_CHECK_INTERVAL or cancelled based on the event.
+ */
+static int fb_event_callback(struct notifier_block *self,
+				unsigned long event, void *data)
+{
+	struct fb_event *evdata = data;
+	struct dsi_status_data *pdata = container_of(self,
+				struct dsi_status_data, fb_notifier);
+	pdata->mfd = evdata->info->par;
+
+	if (event == FB_EVENT_BLANK && evdata) {
+		int *blank = evdata->data;
+		switch (*blank) {
+		case FB_BLANK_UNBLANK:
+			schedule_delayed_work(&pdata->check_status,
+				msecs_to_jiffies(pdata->check_interval));
+			break;
+		case FB_BLANK_POWERDOWN:
+			cancel_delayed_work(&pdata->check_status);
+			break;
+		}
+	}
+	return 0;
+}
+
+int __init mdss_dsi_status_init(void)
+{
+	int rc = 0;
+
+	pstatus_data = kzalloc(sizeof(struct dsi_status_data), GFP_KERNEL);
+	if (!pstatus_data) {
+		pr_err("%s: can't allocate memory\n", __func__);
+		return -ENOMEM;
+	}
+
+	pstatus_data->fb_notifier.notifier_call = fb_event_callback;
+
+	rc = fb_register_client(&pstatus_data->fb_notifier);
+	if (rc < 0) {
+		pr_err("%s: fb_register_client failed, returned with rc=%d\n",
+								__func__, rc);
+		kfree(pstatus_data);
+		return -EPERM;
+	}
+
+	pstatus_data->check_interval = interval;
+	pr_info("%s: DSI status check interval:%d\n", __func__,	interval);
+
+	INIT_DELAYED_WORK(&pstatus_data->check_status, check_dsi_ctrl_status);
+
+	pr_debug("%s: DSI ctrl status work queue initialized\n", __func__);
+
+	return rc;
+}
+
+void __exit mdss_dsi_status_exit(void)
+{
+	fb_unregister_client(&pstatus_data->fb_notifier);
+	cancel_delayed_work_sync(&pstatus_data->check_status);
+	kfree(pstatus_data);
+	pr_debug("%s: DSI ctrl status work queue removed\n", __func__);
+}
+
+module_param(interval, uint, 0);
+MODULE_PARM_DESC(interval,
+		"Duration in milliseconds to send BTA command for checking"
+		"DSI status periodically");
+
+module_init(mdss_dsi_status_init);
+module_exit(mdss_dsi_status_exit);
+
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/video/msm/mdss/mdss_edp.c b/drivers/video/msm/mdss/mdss_edp.c
index 64caaf5..042491d 100644
--- a/drivers/video/msm/mdss/mdss_edp.c
+++ b/drivers/video/msm/mdss/mdss_edp.c
@@ -164,46 +164,33 @@
 	ret = of_property_read_u32(edp_drv->pdev->dev.of_node,
 			"qcom,panel-pwm-period", &edp_drv->pwm_period);
 	if (ret) {
-		pr_err("%s: panel pwm period is not specified, %d", __func__,
+		pr_warn("%s: panel pwm period is not specified, %d", __func__,
 				edp_drv->pwm_period);
-		return -EINVAL;
+		edp_drv->pwm_period = -EINVAL;
 	}
 
 	ret = of_property_read_u32(edp_drv->pdev->dev.of_node,
 			"qcom,panel-lpg-channel", &edp_drv->lpg_channel);
 	if (ret) {
-		pr_err("%s: panel lpg channel is not specified, %d", __func__,
+		pr_warn("%s: panel lpg channel is not specified, %d", __func__,
 				edp_drv->lpg_channel);
-		return -EINVAL;
+		edp_drv->lpg_channel = -EINVAL;
 	}
 
-	edp_drv->bl_pwm = pwm_request(edp_drv->lpg_channel, "lcd-backlight");
-	if (edp_drv->bl_pwm == NULL || IS_ERR(edp_drv->bl_pwm)) {
-		pr_err("%s: pwm request failed", __func__);
+	if (edp_drv->pwm_period != -EINVAL &&
+		edp_drv->lpg_channel != -EINVAL) {
+		edp_drv->bl_pwm = pwm_request(edp_drv->lpg_channel,
+				"lcd-backlight");
+		if (edp_drv->bl_pwm == NULL || IS_ERR(edp_drv->bl_pwm)) {
+			pr_err("%s: pwm request failed", __func__);
+			edp_drv->bl_pwm = NULL;
+			return -EIO;
+		}
+	} else {
 		edp_drv->bl_pwm = NULL;
-		return -EIO;
-	}
-
-	edp_drv->gpio_panel_pwm = of_get_named_gpio(edp_drv->pdev->dev.of_node,
-			"gpio-panel-pwm", 0);
-	if (!gpio_is_valid(edp_drv->gpio_panel_pwm)) {
-		pr_err("%s: gpio_panel_pwm=%d not specified\n", __func__,
-				edp_drv->gpio_panel_pwm);
-		goto edp_free_pwm;
-	}
-
-	ret = gpio_request(edp_drv->gpio_panel_pwm, "disp_pwm");
-	if (ret) {
-		pr_err("%s: Request reset gpio_panel_pwm failed, ret=%d\n",
-				__func__, ret);
-		goto edp_free_pwm;
 	}
 
 	return 0;
-
-edp_free_pwm:
-	pwm_free(edp_drv->bl_pwm);
-	return -ENODEV;
 }
 
 void mdss_edp_set_backlight(struct mdss_panel_data *pdata, u32 bl_level)
@@ -218,27 +205,26 @@
 		return;
 	}
 
-	bl_max = edp_drv->panel_data.panel_info.bl_max;
-	if (bl_level > bl_max)
-		bl_level = bl_max;
+	if (edp_drv->bl_pwm != NULL) {
+		bl_max = edp_drv->panel_data.panel_info.bl_max;
+		if (bl_level > bl_max)
+			bl_level = bl_max;
 
-	if (edp_drv->bl_pwm == NULL) {
-		pr_err("%s: edp_drv->bl_pwm=NULL.\n", __func__);
-		return;
-	}
+		ret = pwm_config(edp_drv->bl_pwm,
+				bl_level * edp_drv->pwm_period / bl_max,
+				edp_drv->pwm_period);
+		if (ret) {
+			pr_err("%s: pwm_config() failed err=%d.\n", __func__,
+					ret);
+			return;
+		}
 
-	ret = pwm_config(edp_drv->bl_pwm,
-			bl_level * edp_drv->pwm_period / bl_max,
-			edp_drv->pwm_period);
-	if (ret) {
-		pr_err("%s: pwm_config() failed err=%d.\n", __func__, ret);
-		return;
-	}
-
-	ret = pwm_enable(edp_drv->bl_pwm);
-	if (ret) {
-		pr_err("%s: pwm_enable() failed err=%d\n", __func__, ret);
-		return;
+		ret = pwm_enable(edp_drv->bl_pwm);
+		if (ret) {
+			pr_err("%s: pwm_enable() failed err=%d\n", __func__,
+					ret);
+			return;
+		}
 	}
 }
 
@@ -378,7 +364,8 @@
 	mdss_edp_irq_disable(edp_drv);
 
 	gpio_set_value(edp_drv->gpio_panel_en, 0);
-	pwm_disable(edp_drv->bl_pwm);
+	if (edp_drv->bl_pwm != NULL)
+		pwm_disable(edp_drv->bl_pwm);
 	mdss_edp_enable(edp_drv->base, 0);
 	mdss_edp_unconfig_clk(edp_drv->base, edp_drv->mmss_cc_base);
 	mdss_edp_enable_mainlink(edp_drv->base, 0);
diff --git a/drivers/video/msm/mdss/mdss_edp.h b/drivers/video/msm/mdss/mdss_edp.h
index c3f7d0d..33b899f 100644
--- a/drivers/video/msm/mdss/mdss_edp.h
+++ b/drivers/video/msm/mdss/mdss_edp.h
@@ -261,7 +261,6 @@
 
 	/* gpios */
 	int gpio_panel_en;
-	int gpio_panel_pwm;
 
 	/* backlight */
 	struct pwm_device *bl_pwm;
diff --git a/drivers/video/msm/mdss/mdss_fb.c b/drivers/video/msm/mdss/mdss_fb.c
index 4ca0a3f..96d8be0 100644
--- a/drivers/video/msm/mdss/mdss_fb.c
+++ b/drivers/video/msm/mdss/mdss_fb.c
@@ -43,6 +43,7 @@
 #include <linux/sw_sync.h>
 #include <linux/file.h>
 #include <linux/memory_alloc.h>
+#include <linux/kthread.h>
 
 #include <mach/board.h>
 #include <mach/memory.h>
@@ -74,6 +75,7 @@
 static int mdss_fb_register(struct msm_fb_data_type *mfd);
 static int mdss_fb_open(struct fb_info *info, int user);
 static int mdss_fb_release(struct fb_info *info, int user);
+static int mdss_fb_release_all(struct fb_info *info, bool release_all);
 static int mdss_fb_pan_display(struct fb_var_screeninfo *var,
 			       struct fb_info *info);
 static int mdss_fb_check_var(struct fb_var_screeninfo *var,
@@ -86,16 +88,20 @@
 			 unsigned long arg);
 static int mdss_fb_mmap(struct fb_info *info, struct vm_area_struct *vma);
 static void mdss_fb_release_fences(struct msm_fb_data_type *mfd);
+static int __mdss_fb_sync_buf_done_callback(struct notifier_block *p,
+		unsigned long val, void *data);
 
-static void mdss_fb_commit_wq_handler(struct work_struct *work);
+static int __mdss_fb_display_thread(void *data);
 static void mdss_fb_pan_idle(struct msm_fb_data_type *mfd);
 static int mdss_fb_send_panel_event(struct msm_fb_data_type *mfd,
 					int event, void *arg);
 void mdss_fb_no_update_notify_timer_cb(unsigned long data)
 {
 	struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)data;
-	if (!mfd)
+	if (!mfd) {
 		pr_err("%s mfd NULL\n", __func__);
+		return;
+	}
 	mfd->no_update.value = NOTIFY_TYPE_NO_UPDATE;
 	complete(&mfd->no_update.comp);
 }
@@ -103,9 +109,10 @@
 static int mdss_fb_notify_update(struct msm_fb_data_type *mfd,
 							unsigned long *argp)
 {
-	int ret, notify, to_user;
+	int ret;
+	unsigned long notify = 0x0, to_user = 0x0;
 
-	ret = copy_from_user(&notify, argp, sizeof(int));
+	ret = copy_from_user(&notify, argp, sizeof(unsigned long));
 	if (ret) {
 		pr_err("%s:ioctl failed\n", __func__);
 		return ret;
@@ -118,12 +125,12 @@
 		INIT_COMPLETION(mfd->update.comp);
 		ret = wait_for_completion_interruptible_timeout(
 						&mfd->update.comp, 4 * HZ);
-		to_user = mfd->update.value;
+		to_user = (unsigned int)mfd->update.value;
 	} else if (notify == NOTIFY_UPDATE_STOP) {
 		INIT_COMPLETION(mfd->no_update.comp);
 		ret = wait_for_completion_interruptible_timeout(
 						&mfd->no_update.comp, 4 * HZ);
-		to_user = mfd->no_update.value;
+		to_user = (unsigned int)mfd->no_update.value;
 	} else {
 		if (mfd->panel_power_on) {
 			INIT_COMPLETION(mfd->power_off_comp);
@@ -135,7 +142,7 @@
 	if (ret == 0)
 		ret = -ETIMEDOUT;
 	else if (ret > 0)
-		ret = copy_to_user(argp, &to_user, sizeof(int));
+		ret = copy_to_user(argp, &to_user, sizeof(unsigned long));
 	return ret;
 }
 
@@ -290,10 +297,9 @@
 {
 	struct msm_fb_data_type *mfd = platform_get_drvdata(pdev);
 
-	for (; mfd->ref_cnt > 1; mfd->ref_cnt--)
-		pm_runtime_put(mfd->fbi->dev);
-
-	mdss_fb_release(mfd->fbi, 0);
+	lock_fb_info(mfd->fbi);
+	mdss_fb_release_all(mfd->fbi, true);
+	unlock_fb_info(mfd->fbi);
 }
 
 static int mdss_fb_probe(struct platform_device *pdev)
@@ -386,11 +392,12 @@
 		if (mfd->mdp_sync_pt_data.timeline == NULL) {
 			pr_err("%s: cannot create time line", __func__);
 			return -ENOMEM;
-		} else {
-			mfd->mdp_sync_pt_data.timeline_value = 0;
 		}
+		mfd->mdp_sync_pt_data.notifier.notifier_call =
+			__mdss_fb_sync_buf_done_callback;
 	}
-	if (mfd->panel.type == WRITEBACK_PANEL)
+	if ((mfd->panel.type == WRITEBACK_PANEL) ||
+			(mfd->panel.type == MIPI_CMD_PANEL))
 		mfd->mdp_sync_pt_data.threshold = 1;
 	else
 		mfd->mdp_sync_pt_data.threshold = 2;
@@ -612,11 +619,11 @@
 		 * scaling fraction (x/1024)
 		 */
 		temp = (temp * mfd->bl_scale) / 1024;
-	}
-	/*if less than minimum level, use min level*/
-	else if ((temp < mfd->bl_min_lvl) && (0 != temp))
-		temp = mfd->bl_min_lvl;
 
+		/*if less than minimum level, use min level*/
+		if (temp < mfd->bl_min_lvl)
+			temp = mfd->bl_min_lvl;
+	}
 	pr_debug("output = %d", temp);
 
 	(*bl_lvl) = temp;
@@ -631,11 +638,8 @@
 
 	if (((!mfd->panel_power_on && mfd->dcm_state != DCM_ENTER)
 		|| !mfd->bl_updated) && !IS_CALIB_MODE_BL(mfd)) {
-			if (bkl_lvl < mfd->bl_min_lvl)
-				mfd->unset_bl_level = mfd->bl_min_lvl;
-			else
-				mfd->unset_bl_level = bkl_lvl;
-			return;
+		mfd->unset_bl_level = bkl_lvl;
+		return;
 	} else {
 		mfd->unset_bl_level = 0;
 	}
@@ -704,8 +708,10 @@
 	case FB_BLANK_UNBLANK:
 		if (!mfd->panel_power_on && mfd->mdp.on_fnc) {
 			ret = mfd->mdp.on_fnc(mfd);
-			if (ret == 0)
+			if (ret == 0) {
 				mfd->panel_power_on = true;
+				mfd->panel_info->panel_dead = false;
+			}
 			mutex_lock(&mfd->update.lock);
 			mfd->update.type = NOTIFY_TYPE_UPDATE;
 			mutex_unlock(&mfd->update.lock);
@@ -1086,6 +1092,8 @@
 	mutex_init(&mfd->update.lock);
 	mutex_init(&mfd->no_update.lock);
 	mutex_init(&mfd->mdp_sync_pt_data.sync_mutex);
+	atomic_set(&mfd->mdp_sync_pt_data.commit_cnt, 0);
+	atomic_set(&mfd->commits_pending, 0);
 
 	init_timer(&mfd->no_update.timer);
 	mfd->no_update.timer.function = mdss_fb_no_update_notify_timer_cb;
@@ -1093,15 +1101,9 @@
 	init_completion(&mfd->update.comp);
 	init_completion(&mfd->no_update.comp);
 	init_completion(&mfd->power_off_comp);
-	init_completion(&mfd->commit_comp);
 	init_completion(&mfd->power_set_comp);
-	INIT_WORK(&mfd->commit_work, mdss_fb_commit_wq_handler);
-	mfd->msm_fb_backup = kzalloc(sizeof(struct msm_fb_backup_type),
-		GFP_KERNEL);
-	if (mfd->msm_fb_backup == 0) {
-		pr_err("error: not enough memory!\n");
-		return -ENOMEM;
-	}
+	init_waitqueue_head(&mfd->commit_wait_q);
+	init_waitqueue_head(&mfd->idle_wait_q);
 
 	ret = fb_alloc_cmap(&fbi->cmap, 256, 0);
 	if (ret)
@@ -1118,9 +1120,9 @@
 		     mfd->index, fbi->var.xres, fbi->var.yres,
 		     fbi->fix.smem_len);
 
-	ret = 0;
+	kthread_run(__mdss_fb_display_thread, mfd, "mdss_fb%d", mfd->index);
 
-	return ret;
+	return 0;
 }
 
 static int mdss_fb_open(struct fb_info *info, int user)
@@ -1168,65 +1170,98 @@
 	return 0;
 }
 
-static int mdss_fb_release(struct fb_info *info, int user)
+static int mdss_fb_release_all(struct fb_info *info, bool release_all)
 {
 	struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par;
-	struct mdss_fb_proc_info *pinfo = NULL;
+	struct mdss_fb_proc_info *pinfo = NULL, *temp_pinfo = NULL;
 	int ret = 0;
 	int pid = current->tgid;
+	bool unknown_pid = true, release_needed = false;
+	struct task_struct *task = current->group_leader;
 
 	if (!mfd->ref_cnt) {
-		pr_info("try to close unopened fb %d!\n", mfd->index);
+		pr_info("try to close unopened fb %d! from %s\n", mfd->index,
+			task->comm);
 		return -EINVAL;
 	}
 
 	mdss_fb_pan_idle(mfd);
-	mfd->ref_cnt--;
 
-	list_for_each_entry(pinfo, &mfd->proc_list, list) {
-		if (pinfo->pid == pid)
+	pr_debug("release_all = %s\n", release_all ? "true" : "false");
+
+	list_for_each_entry_safe(pinfo, temp_pinfo, &mfd->proc_list, list) {
+		if (!release_all && (pinfo->pid != pid))
+			continue;
+
+		unknown_pid = false;
+
+		pr_debug("found process %s pid=%d mfd->ref=%d pinfo->ref=%d\n",
+			task->comm, mfd->ref_cnt, pinfo->pid, pinfo->ref_cnt);
+
+		do {
+			if (mfd->ref_cnt < pinfo->ref_cnt)
+				pr_warn("WARN:mfd->ref=%d < pinfo->ref=%d\n",
+					mfd->ref_cnt, pinfo->ref_cnt);
+			else
+				mfd->ref_cnt--;
+
+			pinfo->ref_cnt--;
+			pm_runtime_put(info->dev);
+		} while (release_all && pinfo->ref_cnt);
+
+		if (pinfo->ref_cnt == 0) {
+			list_del(&pinfo->list);
+			kfree(pinfo);
+			release_needed = !release_all;
+		}
+
+		if (!release_all)
 			break;
 	}
 
-	if (!pinfo || (pinfo->pid != pid)) {
-		pr_warn("unable to find process info for fb%d pid=%d\n",
-				mfd->index, pid);
-		if (mfd->mdp.release_fnc) {
-			ret = mfd->mdp.release_fnc(mfd);
-			if (ret)
-				pr_err("error releasing fb%d resources\n",
-						mfd->index);
-		}
-	} else {
-		pr_debug("found process entry pid=%d ref=%d\n",
-				pinfo->pid, pinfo->ref_cnt);
+	if (release_needed) {
+		pr_debug("known process %s pid=%d mfd->ref=%d\n",
+			task->comm, pid, mfd->ref_cnt);
 
-		pinfo->ref_cnt--;
-		if (pinfo->ref_cnt == 0) {
-			if (mfd->mdp.release_fnc) {
-				ret = mfd->mdp.release_fnc(mfd);
-				if (ret)
-					pr_err("error releasing fb%d pid=%d\n",
-						mfd->index, pinfo->pid);
-			}
-			list_del(&pinfo->list);
-			kfree(pinfo);
+		if (mfd->mdp.release_fnc) {
+			ret = mfd->mdp.release_fnc(mfd, false);
+			if (ret)
+				pr_err("error releasing fb%d pid=%d\n",
+					mfd->index, pid);
+		}
+	} else if (unknown_pid || release_all) {
+		pr_warn("unknown process %s pid=%d mfd->ref=%d\n",
+			task->comm, pid, mfd->ref_cnt);
+
+		if (mfd->ref_cnt)
+			mfd->ref_cnt--;
+
+		if (mfd->mdp.release_fnc) {
+			ret = mfd->mdp.release_fnc(mfd, true);
+			if (ret)
+				pr_err("error fb%d release process %s pid=%d\n",
+					mfd->index, task->comm, pid);
 		}
 	}
 
 	if (!mfd->ref_cnt) {
 		ret = mdss_fb_blank_sub(FB_BLANK_POWERDOWN, info,
-				       mfd->op_enable);
+			mfd->op_enable);
 		if (ret) {
-			pr_err("can't turn off fb%d! rc=%d\n", mfd->index, ret);
+			pr_err("can't turn off fb%d! rc=%d process %s pid=%d\n",
+				mfd->index, ret, task->comm, pid);
 			return ret;
 		}
 	}
 
-	pm_runtime_put(info->dev);
 	return ret;
 }
 
+static int mdss_fb_release(struct fb_info *info, int user)
+{
+	return mdss_fb_release_all(info, false);
+}
+
 static void mdss_fb_power_setting_idle(struct msm_fb_data_type *mfd)
 {
 	int ret;
@@ -1249,85 +1284,155 @@
 
 void mdss_fb_wait_for_fence(struct msm_sync_pt_data *sync_pt_data)
 {
+	struct sync_fence *fences[MDP_MAX_FENCE_FD];
+	int fence_cnt;
 	int i, ret = 0;
+
+	pr_debug("%s: wait for fences\n", sync_pt_data->fence_name);
+
+	mutex_lock(&sync_pt_data->sync_mutex);
+	/*
+	 * Assuming that acq_fen_cnt is sanitized in bufsync ioctl
+	 * to check for sync_pt_data->acq_fen_cnt) <= MDP_MAX_FENCE_FD
+	 */
+	fence_cnt = sync_pt_data->acq_fen_cnt;
+	sync_pt_data->acq_fen_cnt = 0;
+	if (fence_cnt)
+		memcpy(fences, sync_pt_data->acq_fen,
+				fence_cnt * sizeof(struct sync_fence *));
+	mutex_unlock(&sync_pt_data->sync_mutex);
+
 	/* buf sync */
-	for (i = 0; i < sync_pt_data->acq_fen_cnt; i++) {
-		ret = sync_fence_wait(sync_pt_data->acq_fen[i],
+	for (i = 0; i < fence_cnt && !ret; i++) {
+		ret = sync_fence_wait(fences[i],
 				WAIT_FENCE_FIRST_TIMEOUT);
 		if (ret == -ETIME) {
-			pr_warn("sync_fence_wait timed out! ");
+			pr_warn("%s: sync_fence_wait timed out! ",
+					sync_pt_data->fence_name);
 			pr_cont("Waiting %ld more seconds\n",
 					WAIT_FENCE_FINAL_TIMEOUT/MSEC_PER_SEC);
-			ret = sync_fence_wait(sync_pt_data->acq_fen[i],
+			ret = sync_fence_wait(fences[i],
 					WAIT_FENCE_FINAL_TIMEOUT);
 		}
-		if (ret < 0) {
-			pr_err("%s: sync_fence_wait failed! ret = %x\n",
-				__func__, ret);
-			break;
-		}
-		sync_fence_put(sync_pt_data->acq_fen[i]);
+		sync_fence_put(fences[i]);
 	}
 
 	if (ret < 0) {
-		while (i < sync_pt_data->acq_fen_cnt) {
-			sync_fence_put(sync_pt_data->acq_fen[i]);
-			i++;
-		}
+		pr_err("%s: sync_fence_wait failed! ret = %x\n",
+				sync_pt_data->fence_name, ret);
+		for (; i < fence_cnt; i++)
+			sync_fence_put(fences[i]);
 	}
-	sync_pt_data->acq_fen_cnt = 0;
 }
 
-static void mdss_fb_signal_timeline_locked(
-				struct msm_sync_pt_data *sync_pt_data)
-{
-	if (sync_pt_data->timeline && !list_empty((const struct list_head *)
-			(&(sync_pt_data->timeline->obj.active_list_head)))) {
-		sw_sync_timeline_inc(sync_pt_data->timeline, 1);
-		sync_pt_data->timeline_value++;
-	}
-	sync_pt_data->cur_rel_fence = 0;
-}
-
+/**
+ * mdss_fb_signal_timeline() - signal a single release fence
+ * @sync_pt_data:	Sync point data structure for the timeline which
+ *			should be signaled.
+ *
+ * This is called after a frame has been pushed to display. This signals the
+ * timeline to release the fences associated with this frame.
+ */
 void mdss_fb_signal_timeline(struct msm_sync_pt_data *sync_pt_data)
 {
 	mutex_lock(&sync_pt_data->sync_mutex);
-	mdss_fb_signal_timeline_locked(sync_pt_data);
+	if (atomic_add_unless(&sync_pt_data->commit_cnt, -1, 0) &&
+			sync_pt_data->timeline) {
+		sw_sync_timeline_inc(sync_pt_data->timeline, 1);
+		sync_pt_data->timeline_value++;
+
+		pr_debug("%s: buffer signaled! timeline val=%d remaining=%d\n",
+			sync_pt_data->fence_name, sync_pt_data->timeline_value,
+			atomic_read(&sync_pt_data->commit_cnt));
+	} else {
+		pr_debug("%s timeline signaled without commits val=%d\n",
+			sync_pt_data->fence_name, sync_pt_data->timeline_value);
+	}
 	mutex_unlock(&sync_pt_data->sync_mutex);
 }
 
+/**
+ * mdss_fb_release_fences() - signal all pending release fences
+ * @mfd:	Framebuffer data structure for display
+ *
+ * Release all currently pending release fences, including those that are in
+ * the process to be commited.
+ *
+ * Note: this should only be called during close or suspend sequence.
+ */
 static void mdss_fb_release_fences(struct msm_fb_data_type *mfd)
 {
+	struct msm_sync_pt_data *sync_pt_data = &mfd->mdp_sync_pt_data;
+	int val;
 
-	mutex_lock(&mfd->mdp_sync_pt_data.sync_mutex);
-	if (mfd->mdp_sync_pt_data.timeline) {
-		sw_sync_timeline_inc(mfd->mdp_sync_pt_data.timeline, 2);
-		mfd->mdp_sync_pt_data.timeline_value += 2;
+	mutex_lock(&sync_pt_data->sync_mutex);
+	if (sync_pt_data->timeline) {
+		val = sync_pt_data->threshold +
+			atomic_read(&sync_pt_data->commit_cnt);
+		sw_sync_timeline_inc(sync_pt_data->timeline, val);
+		sync_pt_data->timeline_value += val;
+		atomic_set(&sync_pt_data->commit_cnt, 0);
 	}
-	mfd->mdp_sync_pt_data.cur_rel_fence = 0;
-	mutex_unlock(&mfd->mdp_sync_pt_data.sync_mutex);
+	mutex_unlock(&sync_pt_data->sync_mutex);
 }
 
+/**
+ * __mdss_fb_sync_buf_done_callback() - process async display events
+ * @p:		Notifier block registered for async events.
+ * @event:	Event enum to identify the event.
+ * @data:	Optional argument provided with the event.
+ *
+ * See enum mdp_notify_event for events handled.
+ */
+static int __mdss_fb_sync_buf_done_callback(struct notifier_block *p,
+		unsigned long event, void *data)
+{
+	struct msm_sync_pt_data *sync_pt_data;
+
+	sync_pt_data = container_of(p, struct msm_sync_pt_data, notifier);
+
+	switch (event) {
+	case MDP_NOTIFY_FRAME_READY:
+		if (sync_pt_data->async_wait_fences)
+			mdss_fb_wait_for_fence(sync_pt_data);
+		break;
+	case MDP_NOTIFY_FRAME_FLUSHED:
+		pr_debug("%s: frame flushed\n", sync_pt_data->fence_name);
+		sync_pt_data->flushed = true;
+		break;
+	case MDP_NOTIFY_FRAME_TIMEOUT:
+		pr_err("%s: frame timeout\n", sync_pt_data->fence_name);
+		mdss_fb_signal_timeline(sync_pt_data);
+		break;
+	case MDP_NOTIFY_FRAME_DONE:
+		pr_debug("%s: frame done\n", sync_pt_data->fence_name);
+		mdss_fb_signal_timeline(sync_pt_data);
+		break;
+	}
+
+	return NOTIFY_OK;
+}
+
+/**
+ * mdss_fb_pan_idle() - wait for panel programming to be idle
+ * @mfd:	Framebuffer data structure for display
+ *
+ * Wait for any pending programming to be done if in the process of programming
+ * hardware configuration. After this function returns it is safe to perform
+ * software updates for next frame.
+ */
 static void mdss_fb_pan_idle(struct msm_fb_data_type *mfd)
 {
 	int ret;
 
-	if (mfd->is_committing) {
-		ret = wait_for_completion_timeout(
-				&mfd->commit_comp,
+	ret = wait_event_timeout(mfd->idle_wait_q,
+			!atomic_read(&mfd->commits_pending),
 			msecs_to_jiffies(WAIT_DISP_OP_TIMEOUT));
-		if (ret < 0)
-			ret = -ERESTARTSYS;
-		else if (!ret)
-			pr_err("%s wait for commit_comp timeout %d %d",
-				__func__, ret, mfd->is_committing);
-		if (ret <= 0) {
-			mutex_lock(&mfd->mdp_sync_pt_data.sync_mutex);
-			mdss_fb_signal_timeline_locked(&mfd->mdp_sync_pt_data);
-			mfd->is_committing = 0;
-			complete_all(&mfd->commit_comp);
-			mutex_unlock(&mfd->mdp_sync_pt_data.sync_mutex);
-		}
+	if (!ret) {
+		pr_err("wait for idle timeout %d pending=%d\n",
+				ret, atomic_read(&mfd->commits_pending));
+
+		mdss_fb_signal_timeline(&mfd->mdp_sync_pt_data);
 	}
 }
 
@@ -1335,12 +1440,11 @@
 		struct mdp_display_commit *disp_commit)
 {
 	struct msm_fb_data_type *mfd = (struct msm_fb_data_type *)info->par;
-	struct msm_fb_backup_type *fb_backup;
 	struct fb_var_screeninfo *var = &disp_commit->var;
 	u32 wait_for_finish = disp_commit->wait_for_finish;
 	int ret = 0;
 
-	if ((!mfd->op_enable) || (!mfd->panel_power_on))
+	if (!mfd || (!mfd->op_enable) || (!mfd->panel_power_on))
 		return -EPERM;
 
 	if (var->xoffset > (info->var.xres_virtual - info->var.xres))
@@ -1360,13 +1464,12 @@
 		info->var.yoffset =
 		(var->yoffset / info->fix.ypanstep) * info->fix.ypanstep;
 
-	fb_backup = (struct msm_fb_backup_type *)mfd->msm_fb_backup;
-	memcpy(&fb_backup->info, info, sizeof(struct fb_info));
-	memcpy(&fb_backup->disp_commit, disp_commit,
-		sizeof(struct mdp_display_commit));
-	INIT_COMPLETION(mfd->commit_comp);
-	mfd->is_committing = 1;
-	schedule_work(&mfd->commit_work);
+	mfd->msm_fb_backup.info = *info;
+	mfd->msm_fb_backup.disp_commit = *disp_commit;
+
+	atomic_inc(&mfd->mdp_sync_pt_data.commit_cnt);
+	atomic_inc(&mfd->commits_pending);
+	wake_up_all(&mfd->commit_wait_q);
 	mutex_unlock(&mfd->mdp_sync_pt_data.sync_mutex);
 	if (wait_for_finish)
 		mdss_fb_pan_idle(mfd);
@@ -1405,14 +1508,12 @@
 		info->var.yoffset =
 		(var->yoffset / info->fix.ypanstep) * info->fix.ypanstep;
 
-	mdss_fb_wait_for_fence(&mfd->mdp_sync_pt_data);
 	if (mfd->mdp.dma_fnc)
 		mfd->mdp.dma_fnc(mfd);
 	else
 		pr_warn("dma function not set for panel type=%d\n",
 				mfd->panel.type);
-	mdss_fb_signal_timeline(&mfd->mdp_sync_pt_data);
-	mdss_fb_update_backlight(mfd);
+
 	return 0;
 }
 
@@ -1430,35 +1531,69 @@
 	pinfo->clk_rate = var->pixclock;
 }
 
-static void mdss_fb_commit_wq_handler(struct work_struct *work)
+/**
+ * __mdss_fb_perform_commit() - process a frame to display
+ * @mfd:	Framebuffer data structure for display
+ *
+ * Processes all layers and buffers programmed and ensures all pending release
+ * fences are signaled once the buffer is transfered to display.
+ */
+static int __mdss_fb_perform_commit(struct msm_fb_data_type *mfd)
 {
-	struct msm_fb_data_type *mfd;
-	struct fb_var_screeninfo *var;
-	struct fb_info *info;
-	struct msm_fb_backup_type *fb_backup;
-	int ret = 0;
+	struct msm_sync_pt_data *sync_pt_data = &mfd->mdp_sync_pt_data;
+	struct msm_fb_backup_type *fb_backup = &mfd->msm_fb_backup;
+	int ret = -ENOSYS;
 
-	mfd = container_of(work, struct msm_fb_data_type, commit_work);
-	fb_backup = (struct msm_fb_backup_type *)mfd->msm_fb_backup;
-	info = &fb_backup->info;
-	if (fb_backup->disp_commit.flags &
-		MDP_DISPLAY_COMMIT_OVERLAY) {
-		mdss_fb_wait_for_fence(&mfd->mdp_sync_pt_data);
+	if (!sync_pt_data->async_wait_fences)
+		mdss_fb_wait_for_fence(sync_pt_data);
+	sync_pt_data->flushed = false;
+
+	if (fb_backup->disp_commit.flags & MDP_DISPLAY_COMMIT_OVERLAY) {
 		if (mfd->mdp.kickoff_fnc)
-			ret = mfd->mdp.kickoff_fnc(mfd, &fb_backup->disp_commit);
-		if (!ret)
-			mdss_fb_update_backlight(mfd);
-		mdss_fb_signal_timeline(&mfd->mdp_sync_pt_data);
+			ret = mfd->mdp.kickoff_fnc(mfd,
+					&fb_backup->disp_commit);
+		else
+			pr_warn("no kickoff function setup for fb%d\n",
+					mfd->index);
 	} else {
-		var = &fb_backup->disp_commit.var;
-		ret = mdss_fb_pan_display_sub(var, info);
+		ret = mdss_fb_pan_display_sub(&fb_backup->disp_commit.var,
+				&fb_backup->info);
 		if (ret)
-			pr_err("%s fails: ret = %x", __func__, ret);
+			pr_err("pan display failed %x on fb%d\n", ret,
+					mfd->index);
 	}
-	mutex_lock(&mfd->mdp_sync_pt_data.sync_mutex);
-	mfd->is_committing = 0;
-	complete_all(&mfd->commit_comp);
-	mutex_unlock(&mfd->mdp_sync_pt_data.sync_mutex);
+	if (!ret)
+		mdss_fb_update_backlight(mfd);
+
+	if (IS_ERR_VALUE(ret) || !sync_pt_data->flushed)
+		mdss_fb_signal_timeline(sync_pt_data);
+
+	return ret;
+}
+
+static int __mdss_fb_display_thread(void *data)
+{
+	struct msm_fb_data_type *mfd = data;
+	int ret;
+	struct sched_param param;
+
+	param.sched_priority = 16;
+	ret = sched_setscheduler(current, SCHED_FIFO, &param);
+	if (ret)
+		pr_warn("set priority failed for fb%d display thread\n",
+				mfd->index);
+
+	while (1) {
+		wait_event(mfd->commit_wait_q,
+				atomic_read(&mfd->commits_pending));
+
+		ret = __mdss_fb_perform_commit(mfd);
+
+		atomic_dec(&mfd->commits_pending);
+		wake_up_all(&mfd->idle_wait_q);
+	}
+
+	return ret;
 }
 
 static int mdss_fb_check_var(struct fb_var_screeninfo *var,
@@ -1716,12 +1851,52 @@
 	return 0;
 }
 
+/**
+ * mdss_fb_sync_get_rel_fence() - get release fence from sync pt timeline
+ * @sync_pt_data:	Sync pt structure holding timeline and fence info.
+ *
+ * Function returns a release fence on the timeline associated with the
+ * sync pt struct given and it's associated information. The release fence
+ * created can be used to signal when buffers provided will be released.
+ */
+static struct sync_fence *__mdss_fb_sync_get_rel_fence(
+		struct msm_sync_pt_data *sync_pt_data)
+{
+	struct sync_pt *rel_sync_pt;
+	struct sync_fence *rel_fence;
+	int val;
+
+	val = sync_pt_data->timeline_value + sync_pt_data->threshold +
+		atomic_read(&sync_pt_data->commit_cnt);
+
+	pr_debug("%s: buf sync rel fence timeline=%d\n",
+		sync_pt_data->fence_name, val);
+
+	rel_sync_pt = sw_sync_pt_create(sync_pt_data->timeline, val);
+	if (rel_sync_pt == NULL) {
+		pr_err("%s: cannot create sync point\n",
+				sync_pt_data->fence_name);
+		return NULL;
+	}
+
+	/* create fence */
+	rel_fence = sync_fence_create(sync_pt_data->fence_name, rel_sync_pt);
+	if (rel_fence == NULL) {
+		sync_pt_free(rel_sync_pt);
+		pr_err("%s: cannot create fence\n", sync_pt_data->fence_name);
+		return NULL;
+	}
+
+	return rel_fence;
+}
+
 static int mdss_fb_handle_buf_sync_ioctl(struct msm_sync_pt_data *sync_pt_data,
 				 struct mdp_buf_sync *buf_sync)
 {
 	int i, ret = 0;
 	int acq_fen_fd[MDP_MAX_FENCE_FD];
-	struct sync_fence *fence;
+	struct sync_fence *fence, *rel_fence;
+	int rel_fen_fd;
 
 	if ((buf_sync->acq_fen_fd_cnt > MDP_MAX_FENCE_FD) ||
 				(sync_pt_data->timeline == NULL))
@@ -1731,16 +1906,24 @@
 		ret = copy_from_user(acq_fen_fd, buf_sync->acq_fen_fd,
 				buf_sync->acq_fen_fd_cnt * sizeof(int));
 	if (ret) {
-		pr_err("%s:copy_from_user failed", __func__);
+		pr_err("%s: copy_from_user failed", sync_pt_data->fence_name);
 		return ret;
 	}
 
+	if (sync_pt_data->acq_fen_cnt) {
+		pr_warn("%s: currently %d fences active. waiting...\n",
+				sync_pt_data->fence_name,
+				sync_pt_data->acq_fen_cnt);
+		mdss_fb_wait_for_fence(sync_pt_data);
+	}
+
 	mutex_lock(&sync_pt_data->sync_mutex);
 	for (i = 0; i < buf_sync->acq_fen_fd_cnt; i++) {
 		fence = sync_fence_fdget(acq_fen_fd[i]);
 		if (fence == NULL) {
-			pr_info("%s: null fence! i=%d fd=%d\n", __func__, i,
-				acq_fen_fd[i]);
+			pr_err("%s: null fence! i=%d fd=%d\n",
+					sync_pt_data->fence_name, i,
+					acq_fen_fd[i]);
 			ret = -EINVAL;
 			break;
 		}
@@ -1750,54 +1933,40 @@
 	if (ret)
 		goto buf_sync_err_1;
 
-	if (buf_sync->flags & MDP_BUF_SYNC_FLAG_WAIT)
-		mdss_fb_wait_for_fence(sync_pt_data);
-
-	sync_pt_data->cur_rel_sync_pt = sw_sync_pt_create(
-			sync_pt_data->timeline, sync_pt_data->timeline_value +
-					sync_pt_data->threshold);
-
-	if (sync_pt_data->cur_rel_sync_pt == NULL) {
-		pr_err("%s: cannot create sync point", __func__);
-		ret = -ENOMEM;
+	rel_fence = __mdss_fb_sync_get_rel_fence(sync_pt_data);
+	if (IS_ERR_OR_NULL(rel_fence)) {
+		pr_err("%s: unable to retrieve release fence\n",
+				sync_pt_data->fence_name);
+		ret = rel_fence ? PTR_ERR(rel_fence) : -ENOMEM;
 		goto buf_sync_err_1;
 	}
-	/* create fence */
-	sync_pt_data->cur_rel_fence = sync_fence_create(
-		sync_pt_data->fence_name, sync_pt_data->cur_rel_sync_pt);
 
-	if (sync_pt_data->cur_rel_fence == NULL) {
-		sync_pt_free(sync_pt_data->cur_rel_sync_pt);
-		sync_pt_data->cur_rel_sync_pt = NULL;
-		pr_err("%s: cannot create fence", __func__);
-		ret = -ENOMEM;
-		goto buf_sync_err_1;
-	}
 	/* create fd */
-	sync_pt_data->cur_rel_fen_fd = get_unused_fd_flags(0);
-	if (sync_pt_data->cur_rel_fen_fd < 0) {
-		pr_err("%s: get_unused_fd_flags failed", __func__);
-		ret  = -EIO;
+	rel_fen_fd = get_unused_fd_flags(0);
+	if (rel_fen_fd < 0) {
+		pr_err("%s: get_unused_fd_flags failed\n",
+				sync_pt_data->fence_name);
+		ret = -EIO;
 		goto buf_sync_err_2;
 	}
 
-	sync_fence_install(sync_pt_data->cur_rel_fence,
-					sync_pt_data->cur_rel_fen_fd);
-	ret = copy_to_user(buf_sync->rel_fen_fd,
-				&sync_pt_data->cur_rel_fen_fd, sizeof(int));
+	sync_fence_install(rel_fence, rel_fen_fd);
 
+	ret = copy_to_user(buf_sync->rel_fen_fd, &rel_fen_fd, sizeof(int));
 	if (ret) {
-		pr_err("%s:copy_to_user failed", __func__);
+		pr_err("%s: copy_to_user failed\n", sync_pt_data->fence_name);
 		goto buf_sync_err_3;
 	}
 	mutex_unlock(&sync_pt_data->sync_mutex);
+
+	if (buf_sync->flags & MDP_BUF_SYNC_FLAG_WAIT)
+		mdss_fb_wait_for_fence(sync_pt_data);
+
 	return ret;
 buf_sync_err_3:
-	put_unused_fd(sync_pt_data->cur_rel_fen_fd);
+	put_unused_fd(rel_fen_fd);
 buf_sync_err_2:
-	sync_fence_put(sync_pt_data->cur_rel_fence);
-	sync_pt_data->cur_rel_fence = NULL;
-	sync_pt_data->cur_rel_fen_fd = 0;
+	sync_fence_put(rel_fence);
 buf_sync_err_1:
 	for (i = 0; i < sync_pt_data->acq_fen_cnt; i++)
 		sync_fence_put(sync_pt_data->acq_fen[i]);
@@ -1834,8 +2003,9 @@
 		return -EINVAL;
 	mfd = (struct msm_fb_data_type *)info->par;
 	mdss_fb_power_setting_idle(mfd);
-
-	mdss_fb_pan_idle(mfd);
+	if ((cmd != MSMFB_VSYNC_CTRL) && (cmd != MSMFB_OVERLAY_VSYNC_CTRL) &&
+			(cmd != MSMFB_ASYNC_BLIT) && (cmd != MSMFB_BLIT))
+		mdss_fb_pan_idle(mfd);
 
 	switch (cmd) {
 	case MSMFB_CURSOR:
diff --git a/drivers/video/msm/mdss/mdss_fb.h b/drivers/video/msm/mdss/mdss_fb.h
index 256789d..80e6581 100644
--- a/drivers/video/msm/mdss/mdss_fb.h
+++ b/drivers/video/msm/mdss/mdss_fb.h
@@ -18,6 +18,7 @@
 #include <linux/list.h>
 #include <linux/msm_mdp.h>
 #include <linux/types.h>
+#include <linux/notifier.h>
 
 #include "mdss_panel.h"
 
@@ -40,6 +41,32 @@
 #define  MIN(x, y) (((x) < (y)) ? (x) : (y))
 #endif
 
+/**
+ * enum mdp_notify_event - Different frame events to indicate frame update state
+ *
+ * @MDP_NOTIFY_FRAME_BEGIN:	Frame update has started, the frame is about to
+ *				be programmed into hardware.
+ * @MDP_NOTIFY_FRAME_READY:	Frame ready to be kicked off, this can be used
+ *				as the last point in time to synchronized with
+ *				source buffers before kickoff.
+ * @MDP_NOTIFY_FRAME_FLUSHED:	Configuration of frame has been flushed and
+ *				DMA transfer has started.
+ * @MDP_NOTIFY_FRAME_DONE:	Frame DMA transfer has completed.
+ *				- For video mode panels this will indicate that
+ *				  previous frame has been replaced by new one.
+ *				- For command mode/writeback frame done happens
+ *				  as soon as the DMA of the frame is done.
+ * @MDP_NOTIFY_FRAME_TIMEOUT:	Frame DMA transfer has failed to complete within
+ *				a fair amount of time.
+ */
+enum mdp_notify_event {
+	MDP_NOTIFY_FRAME_BEGIN = 1,
+	MDP_NOTIFY_FRAME_READY,
+	MDP_NOTIFY_FRAME_FLUSHED,
+	MDP_NOTIFY_FRAME_DONE,
+	MDP_NOTIFY_FRAME_TIMEOUT,
+};
+
 struct disp_info_type_suspend {
 	int op_enable;
 	int panel_power_on;
@@ -57,13 +84,17 @@
 	char *fence_name;
 	u32 acq_fen_cnt;
 	struct sync_fence *acq_fen[MDP_MAX_FENCE_FD];
-	int cur_rel_fen_fd;
-	struct sync_pt *cur_rel_sync_pt;
-	struct sync_fence *cur_rel_fence;
+
 	struct sw_sync_timeline *timeline;
 	int timeline_value;
 	u32 threshold;
+
+	atomic_t commit_cnt;
+	bool flushed;
+	bool async_wait_fences;
+
 	struct mutex sync_mutex;
+	struct notifier_block notifier;
 };
 
 struct msm_fb_data_type;
@@ -75,7 +106,7 @@
 	int (*on_fnc)(struct msm_fb_data_type *mfd);
 	int (*off_fnc)(struct msm_fb_data_type *mfd);
 	/* called to release resources associated to the process */
-	int (*release_fnc)(struct msm_fb_data_type *mfd);
+	int (*release_fnc)(struct msm_fb_data_type *mfd, bool release_all);
 	int (*kickoff_fnc)(struct msm_fb_data_type *mfd,
 					struct mdp_display_commit *data);
 	int (*ioctl_handler)(struct msm_fb_data_type *mfd, u32 cmd, void *arg);
@@ -105,6 +136,11 @@
 	struct list_head list;
 };
 
+struct msm_fb_backup_type {
+	struct fb_info info;
+	struct mdp_display_commit disp_commit;
+};
+
 struct msm_fb_data_type {
 	u32 key;
 	u32 index;
@@ -159,10 +195,11 @@
 	struct msm_sync_pt_data mdp_sync_pt_data;
 
 	/* for non-blocking */
-	struct completion commit_comp;
-	u32 is_committing;
-	struct work_struct commit_work;
-	void *msm_fb_backup;
+	atomic_t commits_pending;
+	wait_queue_head_t commit_wait_q;
+	wait_queue_head_t idle_wait_q;
+
+	struct msm_fb_backup_type msm_fb_backup;
 	struct completion power_set_comp;
 	u32 is_power_setting;
 
@@ -170,11 +207,6 @@
 	struct list_head proc_list;
 };
 
-struct msm_fb_backup_type {
-	struct fb_info info;
-	struct mdp_display_commit disp_commit;
-};
-
 static inline void mdss_fb_update_notify_update(struct msm_fb_data_type *mfd)
 {
 	int needs_complete = 0;
diff --git a/drivers/video/msm/mdss/mdss_hdmi_edid.c b/drivers/video/msm/mdss/mdss_hdmi_edid.c
index 0074873..5174cab 100644
--- a/drivers/video/msm/mdss/mdss_hdmi_edid.c
+++ b/drivers/video/msm/mdss/mdss_hdmi_edid.c
@@ -16,6 +16,13 @@
 #include "mdss_hdmi_edid.h"
 
 #define DBC_START_OFFSET 4
+
+/*
+ * As per CEA-861-E specification 7.5.2, there can be
+ * upto 31 bytes following any tag (data block type).
+ */
+#define MAX_DATA_BLOCK_SIZE 31
+
 #define HDMI_VSDB_3D_EVF_DATA_OFFSET(vsd) \
 	(!((vsd)[8] & BIT(7)) ? 9 : (!((vsd)[8] & BIT(6)) ? 11 : 13))
 
@@ -32,6 +39,19 @@
 /* Support for first 5 EDID blocks */
 #define MAX_EDID_BLOCK_SIZE (0x80 * 5)
 
+#define BUFF_SIZE_3D 128
+
+enum data_block_types {
+	RESERVED,
+	AUDIO_DATA_BLOCK,
+	VIDEO_DATA_BLOCK,
+	VENDOR_SPECIFIC_DATA_BLOCK,
+	SPEAKER_ALLOCATION_DATA_BLOCK,
+	VESA_DTC_DATA_BLOCK,
+	RESERVED2,
+	USE_EXTENDED_TAG
+};
+
 struct hdmi_edid_sink_data {
 	u32 disp_mode_list[HDMI_VFRMT_MAX];
 	u32 disp_3d_mode_list[HDMI_VFRMT_MAX];
@@ -469,13 +489,17 @@
 	return status;
 } /* hdmi_edid_read_block */
 
+#define EDID_BLK_LEN 128
+#define EDID_DTD_LEN 18
 static const u8 *hdmi_edid_find_block(const u8 *in_buf, u32 start_offset,
 	u8 type, u8 *len)
 {
 	/* the start of data block collection, start of Video Data Block */
 	u32 offset = start_offset;
-	u32 end_dbc_offset = in_buf[2];
+	u32 dbc_offset = in_buf[2];
 
+	if (dbc_offset >= EDID_BLK_LEN - EDID_DTD_LEN)
+		return NULL;
 	*len = 0;
 
 	/*
@@ -484,14 +508,15 @@
 	 * * edid buffer 1, byte 2 being 0 menas no non-DTD/DATA block
 	 *   collection present and no DTD data present.
 	 */
-	if ((end_dbc_offset == 0) || (end_dbc_offset == 4)) {
+	if ((dbc_offset == 0) || (dbc_offset == 4)) {
 		DEV_WARN("EDID: no DTD or non-DTD data present\n");
 		return NULL;
 	}
 
-	while (offset < end_dbc_offset) {
+	while (offset < dbc_offset) {
 		u8 block_len = in_buf[offset] & 0x1F;
-		if ((in_buf[offset] >> 5) == type) {
+		if ((offset + block_len <= dbc_offset) &&
+		    (in_buf[offset] >> 5) == type) {
 			*len = block_len;
 			DEV_DBG("%s: EDID: block=%d found @ 0x%x w/ len=%d\n",
 				__func__, type, offset, block_len);
@@ -519,7 +544,8 @@
 	}
 
 	/* A Tage code of 7 identifies extended data blocks */
-	etag = hdmi_edid_find_block(in_buf, start_offset, 7, &len);
+	etag = hdmi_edid_find_block(in_buf, start_offset, USE_EXTENDED_TAG,
+		&len);
 
 	while (etag != NULL) {
 		/* The extended data block should at least be 2 bytes long */
@@ -565,7 +591,8 @@
 
 		/* There could be more that one extended data block */
 		start_offset = etag - in_buf + len + 1;
-		etag = hdmi_edid_find_block(in_buf, start_offset, 7, &len);
+		etag = hdmi_edid_find_block(in_buf, start_offset,
+			USE_EXTENDED_TAG, &len);
 	}
 } /* hdmi_edid_extract_extended_data_blocks */
 
@@ -580,11 +607,12 @@
 		return;
 	}
 
-	vsd = hdmi_edid_find_block(in_buf, DBC_START_OFFSET, 3, &len);
+	vsd = hdmi_edid_find_block(in_buf, DBC_START_OFFSET,
+		VENDOR_SPECIFIC_DATA_BLOCK, &len);
 
 	edid_ctrl->present_3d = 0;
-	if (vsd == NULL || len < 9) {
-		DEV_DBG("%s: blk-id 3 not found or not long enough\n",
+	if (vsd == NULL || len == 0 || len > MAX_DATA_BLOCK_SIZE) {
+		DEV_DBG("%s: No/Invalid vendor Specific Data Block\n",
 			__func__);
 		return;
 	}
@@ -611,9 +639,13 @@
 		return;
 	}
 
-	adb = hdmi_edid_find_block(in_buf, DBC_START_OFFSET, 1, &len);
-	if ((adb == NULL) || (len > MAX_AUDIO_DATA_BLOCK_SIZE))
+	adb = hdmi_edid_find_block(in_buf, DBC_START_OFFSET, AUDIO_DATA_BLOCK,
+		&len);
+	if ((adb == NULL) || (len > MAX_AUDIO_DATA_BLOCK_SIZE)) {
+		DEV_DBG("%s: No/Invalid Audio Data Block\n",
+			__func__);
 		return;
+	}
 
 	memcpy(edid_ctrl->audio_data_block, adb + 1, len);
 	edid_ctrl->adb_size = len;
@@ -639,9 +671,13 @@
 		return;
 	}
 
-	sadb = hdmi_edid_find_block(in_buf, DBC_START_OFFSET, 4, &len);
-	if ((sadb == NULL) || (len != MAX_SPKR_ALLOC_DATA_BLOCK_SIZE))
+	sadb = hdmi_edid_find_block(in_buf, DBC_START_OFFSET,
+		SPEAKER_ALLOCATION_DATA_BLOCK, &len);
+	if ((sadb == NULL) || (len != MAX_SPKR_ALLOC_DATA_BLOCK_SIZE)) {
+		DEV_DBG("%s: No/Invalid Speaker Allocation Data Block\n",
+			__func__);
 		return;
+	}
 
 	memcpy(edid_ctrl->spkr_alloc_data_block, sadb + 1, len);
 	edid_ctrl->sadb_size = len;
@@ -668,9 +704,11 @@
 		return;
 	}
 
-	vsd = hdmi_edid_find_block(in_buf, DBC_START_OFFSET, 3, &len);
+	vsd = hdmi_edid_find_block(in_buf, DBC_START_OFFSET,
+		VENDOR_SPECIFIC_DATA_BLOCK, &len);
 
-	if (vsd == NULL || len < 12 || !(vsd[8] & BIT(7))) {
+	if (vsd == NULL || len == 0 || len > MAX_DATA_BLOCK_SIZE ||
+		!(vsd[8] & BIT(7))) {
 		edid_ctrl->video_latency = (u16)-1;
 		edid_ctrl->audio_latency = (u16)-1;
 		DEV_DBG("%s: EDID: No audio/video latency present\n", __func__);
@@ -694,9 +732,14 @@
 		return 0;
 	}
 
-	vsd = hdmi_edid_find_block(in_buf, DBC_START_OFFSET, 3, &len);
-	if (vsd == NULL)
+	vsd = hdmi_edid_find_block(in_buf, DBC_START_OFFSET,
+		VENDOR_SPECIFIC_DATA_BLOCK, &len);
+
+	if (vsd == NULL || len == 0 || len > MAX_DATA_BLOCK_SIZE) {
+		DEV_DBG("%s: No/Invalid Vendor Specific Data Block\n",
+			__func__);
 		return 0;
+	}
 
 	DEV_DBG("%s: EDID: VSD PhyAddr=%04x, MaxTMDS=%dMHz\n", __func__,
 		((u32)vsd[4] << 8) + (u32)vsd[5], (u32)vsd[7] * 5);
@@ -885,7 +928,7 @@
 	}
 } /* hdmi_edid_add_sink_video_format */
 
-static void hdmi_edid_get_display_vsd_3d_mode(const u8 *data_buf,
+static int hdmi_edid_get_display_vsd_3d_mode(const u8 *data_buf,
 	struct hdmi_edid_sink_data *sink_data, u32 num_of_cea_blocks)
 {
 	u8 len, offset, present_multi_3d, hdmi_vic_len;
@@ -893,25 +936,40 @@
 	u16 structure_all, structure_mask;
 	const u8 *vsd = num_of_cea_blocks ?
 		hdmi_edid_find_block(data_buf+0x80, DBC_START_OFFSET,
-				3, &len) : NULL;
+			VENDOR_SPECIFIC_DATA_BLOCK, &len) : NULL;
 	int i;
 
+	if (vsd == NULL || len == 0 || len > MAX_DATA_BLOCK_SIZE) {
+		DEV_DBG("%s: No/Invalid Vendor Specific Data Block\n",
+			__func__);
+		return -ENXIO;
+	}
+
 	offset = HDMI_VSDB_3D_EVF_DATA_OFFSET(vsd);
+	if (offset >= len - 1)
+		return -ETOOSMALL;
+
 	present_multi_3d = (vsd[offset] & 0x60) >> 5;
 
 	offset += 1;
+
 	hdmi_vic_len = (vsd[offset] >> 5) & 0x7;
 	hdmi_3d_len = vsd[offset] & 0x1F;
 	DEV_DBG("%s: EDID[3D]: HDMI_VIC_LEN = %d, HDMI_3D_LEN = %d\n", __func__,
 		hdmi_vic_len, hdmi_3d_len);
 
 	offset += (hdmi_vic_len + 1);
+	if (offset >= len - 1)
+		return -ETOOSMALL;
+
 	if (present_multi_3d == 1 || present_multi_3d == 2) {
 		DEV_DBG("%s: EDID[3D]: multi 3D present (%d)\n", __func__,
 			present_multi_3d);
 		/* 3d_structure_all */
 		structure_all = (vsd[offset] << 8) | vsd[offset + 1];
 		offset += 2;
+		if (offset >= len - 1)
+			return -ETOOSMALL;
 		hdmi_3d_len -= 2;
 		if (present_multi_3d == 2) {
 			/* 3d_structure_mask */
@@ -958,16 +1016,18 @@
 
 	i = 0;
 	while (hdmi_3d_len > 0) {
+		if (offset >= len - 1)
+			return -ETOOSMALL;
 		DEV_DBG("%s: EDID: 3D_Structure_%d @ 0x%x: %02x\n",
 			__func__, i + 1, offset, vsd[offset]);
-
 		if ((vsd[offset] >> 4) >=
 			sink_data->disp_multi_3d_mode_list_cnt) {
 			if ((vsd[offset] & 0x0F) >= 8) {
 				offset += 1;
 				hdmi_3d_len -= 1;
 				DEV_DBG("%s:EDID:3D_Detail_%d @ 0x%x: %02x\n",
-					__func__, i + 1, offset, vsd[offset]);
+					__func__, i + 1, offset,
+					vsd[min_t(u32, offset, (len - 1))]);
 			}
 			i += 1;
 			offset += 1;
@@ -1003,12 +1063,13 @@
 			hdmi_3d_len -= 1;
 			DEV_DBG("%s: EDID[3D]: 3D_Detail_%d @ 0x%x: %02x\n",
 				__func__, i + 1, offset,
-				vsd[offset]);
+				vsd[min_t(u32, offset, (len - 1))]);
 		}
 		i += 1;
 		offset += 1;
 		hdmi_3d_len -= 1;
 	}
+	return 0;
 } /* hdmi_edid_get_display_vsd_3d_mode */
 
 static void hdmi_edid_get_extended_video_formats(
@@ -1024,10 +1085,11 @@
 		return;
 	}
 
-	vsd = hdmi_edid_find_block(in_buf, DBC_START_OFFSET, 3, &db_len);
+	vsd = hdmi_edid_find_block(in_buf, DBC_START_OFFSET,
+		VENDOR_SPECIFIC_DATA_BLOCK, &db_len);
 
-	if (vsd == NULL || db_len < 9) {
-		DEV_DBG("%s: blk-id 3 not found or not long enough\n",
+	if (vsd == NULL || db_len == 0 || db_len > MAX_DATA_BLOCK_SIZE) {
+		DEV_DBG("%s: No/Invalid Vendor Specific Data Block\n",
 			__func__);
 		return;
 	}
@@ -1061,6 +1123,7 @@
 	u32 video_format = HDMI_VFRMT_640x480p60_4_3;
 	u32 has480p = false;
 	u8 len;
+	int rc;
 	const u8 *edid_blk0 = NULL;
 	const u8 *edid_blk1 = NULL;
 	const u8 *svd = NULL;
@@ -1076,8 +1139,14 @@
 	edid_blk0 = &data_buf[0x0];
 	edid_blk1 = &data_buf[0x80];
 	svd = num_of_cea_blocks ?
-		hdmi_edid_find_block(data_buf+0x80, DBC_START_OFFSET, 2,
-			&len) : NULL;
+		hdmi_edid_find_block(data_buf+0x80, DBC_START_OFFSET,
+			VIDEO_DATA_BLOCK, &len) : NULL;
+
+	if (svd == NULL || len == 0 || len > MAX_DATA_BLOCK_SIZE) {
+		DEV_DBG("%s: No/Invalid Video Data Block\n",
+			__func__);
+		return;
+	}
 
 	sink_data = &edid_ctrl->sink_data;
 
@@ -1311,8 +1380,10 @@
 		}
 
 		/* 3d format described in Vendor Specific Data */
-		hdmi_edid_get_display_vsd_3d_mode(data_buf, sink_data,
+		rc = hdmi_edid_get_display_vsd_3d_mode(data_buf, sink_data,
 			num_of_cea_blocks);
+		if (!rc)
+			pr_debug("%s: 3D formats in VSD\n", __func__);
 	}
 
 	/*
diff --git a/drivers/video/msm/mdss/mdss_hdmi_hdcp.c b/drivers/video/msm/mdss/mdss_hdmi_hdcp.c
index bf28e8c..8ff9059 100644
--- a/drivers/video/msm/mdss/mdss_hdmi_hdcp.c
+++ b/drivers/video/msm/mdss/mdss_hdmi_hdcp.c
@@ -31,6 +31,8 @@
 #define HDCP_KEYS_STATE_PROD_AKSV	6
 #define HDCP_KEYS_STATE_RESERVED	7
 
+#define HDCP_INT_CLR (BIT(1) | BIT(5) | BIT(7) | BIT(9) | BIT(13))
+
 struct hdmi_hdcp_ctrl {
 	u32 auth_retries;
 	u32 tp_msgid;
@@ -289,6 +291,10 @@
 	}
 	DEV_DBG("%s: %s: BCAPS=%02x\n", __func__, HDCP_STATE_NAME, bcaps);
 
+	/* receiver (0), repeater (1) */
+	hdcp_ctrl->current_tp.ds_type =
+		(bcaps & BIT(6)) >> 6 ? DS_REPEATER : DS_RECEIVER;
+
 	/*
 	 * HDCP setup prior to enabling HDCP_CTRL.
 	 * Setup seed values for random number An.
@@ -644,40 +650,12 @@
 	memset(ksv_fifo, 0,
 		sizeof(hdcp_ctrl->current_tp.ksv_list));
 
-	/* Read BCAPS at offset 0x40 */
-	memset(&ddc_data, 0, sizeof(ddc_data));
-	ddc_data.dev_addr = 0x74;
-	ddc_data.offset = 0x40;
-	ddc_data.data_buf = &bcaps;
-	ddc_data.data_len = 1;
-	ddc_data.request_len = 1;
-	ddc_data.retry = 5;
-	ddc_data.what = "Bcaps";
-	ddc_data.no_align = false;
-	rc = hdmi_ddc_read(hdcp_ctrl->init_data.ddc_ctrl, &ddc_data);
-	if (rc) {
-		DEV_ERR("%s: %s: BCAPS read failed\n", __func__,
-			HDCP_STATE_NAME);
-		goto error;
-	}
-	DEV_DBG("%s: %s: BCAPS=%02x (%s)\n", __func__, HDCP_STATE_NAME, bcaps,
-		(bcaps & BIT(6)) ? "repeater" : "no repeater");
-
-	/* receiver (0), repeater (1) */
-	hdcp_ctrl->current_tp.ds_type =
-		(bcaps & BIT(6)) >> 6 ? DS_REPEATER : DS_RECEIVER;
-
-	/* if REPEATER (Bit 6), perform Part2 Authentication */
-	if (!(bcaps & BIT(6))) {
-		DEV_INFO("%s: %s: auth part II skipped, no repeater\n",
-			__func__, HDCP_STATE_NAME);
-		return 0;
-	}
-
-	/* Wait until READY bit is set in BCAPS */
+	/*
+	 * Wait until READY bit is set in BCAPS, as per HDCP specifications
+	 * maximum permitted time to check for READY bit is five seconds.
+	 */
 	timeout_count = 50;
-	while (!(bcaps & BIT(5)) && timeout_count) {
-		msleep(100);
+	do {
 		timeout_count--;
 		/* Read BCAPS at offset 0x40 */
 		memset(&ddc_data, 0, sizeof(ddc_data));
@@ -695,7 +673,8 @@
 				HDCP_STATE_NAME);
 			goto error;
 		}
-	}
+		msleep(100);
+	} while (!(bcaps & BIT(5)) && timeout_count);
 
 	/* Read BSTATUS at offset 0x41 */
 	memset(&ddc_data, 0, sizeof(ddc_data));
@@ -976,11 +955,15 @@
 		goto error;
 	}
 
-	rc = hdmi_hdcp_authentication_part2(hdcp_ctrl);
-	if (rc) {
-		DEV_DBG("%s: %s: HDCP Auth Part II failed\n", __func__,
-			HDCP_STATE_NAME);
-		goto error;
+	if (hdcp_ctrl->current_tp.ds_type == DS_REPEATER) {
+		rc = hdmi_hdcp_authentication_part2(hdcp_ctrl);
+		if (rc) {
+			DEV_DBG("%s: %s: HDCP Auth Part II failed\n", __func__,
+				HDCP_STATE_NAME);
+			goto error;
+		}
+	} else {
+		DEV_INFO("%s: Downstream device is not a repeater\n", __func__);
 	}
 	/* Disabling software DDC before going into part3 to make sure
 	 * there is no Arbitration between software and hardware for DDC */
@@ -1158,16 +1141,15 @@
 	}
 
 	/*
-	 * Need to set the state to inactive here so that any ongoing
-	 * reauth works will know that the HDCP session has been turned off
+	 * Disable HDCP interrupts.
+	 * Also, need to set the state to inactive here so that any ongoing
+	 * reauth works will know that the HDCP session has been turned off.
 	 */
 	mutex_lock(hdcp_ctrl->init_data.mutex);
+	DSS_REG_W(io, HDMI_HDCP_INT_CTRL, 0);
 	hdcp_ctrl->hdcp_state = HDCP_STATE_INACTIVE;
 	mutex_unlock(hdcp_ctrl->init_data.mutex);
 
-	/* Disable HDCP interrupts */
-	DSS_REG_W(io, HDMI_HDCP_INT_CTRL, 0);
-
 	/*
 	 * Cancel any pending auth/reauth attempts.
 	 * If one is ongoing, this will wait for it to finish.
@@ -1185,9 +1167,6 @@
 
 	DSS_REG_W(io, HDMI_HDCP_RESET, BIT(0));
 
-	/* Wait to be clean on DDC HW engine */
-	hdmi_hdcp_hw_ddc_clean(hdcp_ctrl);
-
 	/* Disable encryption and disable the HDCP block */
 	DSS_REG_W(io, HDMI_HDCP_CTRL, 0);
 
@@ -1215,7 +1194,7 @@
 	if (HDCP_STATE_INACTIVE == hdcp_ctrl->hdcp_state) {
 		DEV_ERR("%s: HDCP inactive. Just clear int and return.\n",
 			__func__);
-		DSS_REG_W(io, HDMI_HDCP_INT_CTRL, hdcp_int_val);
+		DSS_REG_W(io, HDMI_HDCP_INT_CTRL, HDCP_INT_CLR);
 		return 0;
 	}
 
diff --git a/drivers/video/msm/mdss/mdss_hdmi_tx.c b/drivers/video/msm/mdss/mdss_hdmi_tx.c
index 0b64bbb..466b8d2 100644
--- a/drivers/video/msm/mdss/mdss_hdmi_tx.c
+++ b/drivers/video/msm/mdss/mdss_hdmi_tx.c
@@ -46,6 +46,14 @@
 #define HPD_DISCONNECT_POLARITY 0
 #define HPD_CONNECT_POLARITY    1
 
+/*
+ * Audio engine may take 1 to 3 sec to shutdown
+ * in normal cases. To handle worst cases, making
+ * timeout for audio engine shutdown as 5 sec.
+ */
+#define AUDIO_POLL_SLEEP_US   (5 * 1000)
+#define AUDIO_POLL_TIMEOUT_US (AUDIO_POLL_SLEEP_US * 1000)
+
 #define IFRAME_CHECKSUM_32(d)			\
 	((d & 0xff) + ((d >> 8) & 0xff) +	\
 	((d >> 16) & 0xff) + ((d >> 24) & 0xff))
@@ -87,8 +95,8 @@
 static void hdmi_tx_hpd_off(struct hdmi_tx_ctrl *hdmi_ctrl);
 static int hdmi_tx_enable_power(struct hdmi_tx_ctrl *hdmi_ctrl,
 	enum hdmi_tx_power_module_type module, int enable);
-static void hdmi_tx_audio_off(struct hdmi_tx_ctrl *hdmi_ctrl,
-				bool wait_audio_tx);
+static inline void hdmi_tx_set_audio_switch_node(struct hdmi_tx_ctrl *hdmi_ctrl,
+	int val, bool force);
 static int hdmi_tx_audio_setup(struct hdmi_tx_ctrl *hdmi_ctrl);
 
 struct mdss_hw hdmi_tx_hw = {
@@ -343,6 +351,65 @@
 	return new_vic;
 } /* hdmi_tx_get_vic_from_panel_info */
 
+static inline void hdmi_tx_send_cable_notification(
+	struct hdmi_tx_ctrl *hdmi_ctrl, int val)
+{
+	if (!hdmi_ctrl) {
+		DEV_ERR("%s: invalid input\n", __func__);
+		return;
+	}
+
+	if (!hdmi_ctrl->pdata.primary && (hdmi_ctrl->sdev.state != val))
+		switch_set_state(&hdmi_ctrl->sdev, val);
+} /* hdmi_tx_send_cable_notification */
+
+static inline u32 hdmi_tx_is_dvi_mode(struct hdmi_tx_ctrl *hdmi_ctrl)
+{
+	return hdmi_edid_get_sink_mode(
+		hdmi_ctrl->feature_data[HDMI_TX_FEAT_EDID]) ? 0 : 1;
+} /* hdmi_tx_is_dvi_mode */
+
+static void hdmi_tx_wait_for_audio_engine(struct hdmi_tx_ctrl *hdmi_ctrl)
+{
+	u32 status = 0;
+	u32 wait_for_vote = 50;
+	struct dss_io_data *io = NULL;
+
+	if (!hdmi_ctrl) {
+		DEV_ERR("%s: invalid input\n", __func__);
+		return;
+	}
+
+	io = &hdmi_ctrl->pdata.io[HDMI_TX_CORE_IO];
+	if (!io->base) {
+		DEV_ERR("%s: core io not inititalized\n", __func__);
+		return;
+	}
+
+	/*
+	 * wait for 5 sec max for audio engine to acknowledge if hdmi tx core
+	 * can be safely turned off. Sleep for a reasonable time to make sure
+	 * vote_hdmi_core_on variable is updated properly by audio.
+	 */
+	while (hdmi_ctrl->vote_hdmi_core_on && --wait_for_vote)
+		msleep(100);
+
+
+	if (!wait_for_vote)
+		DEV_ERR("%s: HDMI core still voted for power on\n", __func__);
+
+	if (readl_poll_timeout(io->base + HDMI_AUDIO_PKT_CTRL, status,
+				(status & BIT(0)) == 0, AUDIO_POLL_SLEEP_US,
+				AUDIO_POLL_TIMEOUT_US))
+		DEV_ERR("%s: Error turning off audio packet transmission.\n",
+			__func__);
+
+	if (readl_poll_timeout(io->base + HDMI_AUDIO_CFG, status,
+				(status & BIT(0)) == 0, AUDIO_POLL_SLEEP_US,
+				AUDIO_POLL_TIMEOUT_US))
+		DEV_ERR("%s: Error turning off audio engine.\n", __func__);
+}
+
 static struct hdmi_tx_ctrl *hdmi_tx_get_drvdata_from_panel_data(
 	struct mdss_panel_data *mpd)
 {
@@ -461,6 +528,15 @@
 
 	if (0 == hpd && hdmi_ctrl->hpd_feature_on) {
 		rc = hdmi_tx_sysfs_enable_hpd(hdmi_ctrl, false);
+
+		if (hdmi_ctrl->panel_power_on && hdmi_ctrl->hpd_state) {
+			hdmi_tx_set_audio_switch_node(hdmi_ctrl, 0, false);
+			hdmi_tx_wait_for_audio_engine(hdmi_ctrl);
+		}
+
+		hdmi_tx_send_cable_notification(hdmi_ctrl, 0);
+		DEV_DBG("%s: Hdmi state switch to %d\n", __func__,
+			hdmi_ctrl->sdev.state);
 	} else if (1 == hpd && !hdmi_ctrl->hpd_feature_on) {
 		rc = hdmi_tx_sysfs_enable_hpd(hdmi_ctrl, true);
 	} else {
@@ -708,24 +784,6 @@
 	hdmi_ctrl->kobj = NULL;
 } /* hdmi_tx_sysfs_remove */
 
-static inline u32 hdmi_tx_is_dvi_mode(struct hdmi_tx_ctrl *hdmi_ctrl)
-{
-	return hdmi_edid_get_sink_mode(
-		hdmi_ctrl->feature_data[HDMI_TX_FEAT_EDID]) ? 0 : 1;
-} /* hdmi_tx_is_dvi_mode */
-
-static inline void hdmi_tx_send_cable_notification(
-	struct hdmi_tx_ctrl *hdmi_ctrl, int val)
-{
-	if (!hdmi_ctrl) {
-		DEV_ERR("%s: invalid input\n", __func__);
-		return;
-	}
-
-	if (!hdmi_ctrl->pdata.primary && (hdmi_ctrl->sdev.state != val))
-		switch_set_state(&hdmi_ctrl->sdev, val);
-} /* hdmi_tx_send_cable_notification */
-
 static inline void hdmi_tx_set_audio_switch_node(struct hdmi_tx_ctrl *hdmi_ctrl,
 	int val, bool force)
 {
@@ -1012,8 +1070,8 @@
 		DEV_INFO("%s: sense cable CONNECTED: state switch to %d\n",
 			__func__, hdmi_ctrl->sdev.state);
 	} else {
-		if (hdmi_tx_enable_power(hdmi_ctrl, HDMI_TX_DDC_PM, false))
-			DEV_WARN("%s: Failed to disable ddc power\n", __func__);
+		hdmi_tx_set_audio_switch_node(hdmi_ctrl, 0, false);
+		hdmi_tx_wait_for_audio_engine(hdmi_ctrl);
 
 		hdmi_tx_send_cable_notification(hdmi_ctrl, 0);
 		DEV_INFO("%s: sense cable DISCONNECTED: state switch to %d\n",
@@ -1660,8 +1718,6 @@
 	} else {
 		msm_dss_enable_clk(power_data->clk_config,
 			power_data->num_clk, 0);
-		msm_dss_clk_set_rate(power_data->clk_config,
-			power_data->num_clk);
 		msm_dss_enable_gpio(power_data->gpio_config,
 			power_data->num_gpio, 0);
 		msm_dss_enable_vreg(power_data->vreg_config,
@@ -2193,6 +2249,29 @@
 	return 0;
 }
 
+static int hdmi_tx_get_cable_status(struct platform_device *pdev, u32 vote)
+{
+	struct hdmi_tx_ctrl *hdmi_ctrl = platform_get_drvdata(pdev);
+	unsigned long flags;
+	u32 hpd;
+
+	if (!hdmi_ctrl) {
+		DEV_ERR("%s: invalid input\n", __func__);
+		return -ENODEV;
+	}
+
+	spin_lock_irqsave(&hdmi_ctrl->hpd_state_lock, flags);
+	hpd = hdmi_ctrl->hpd_state;
+	spin_unlock_irqrestore(&hdmi_ctrl->hpd_state_lock, flags);
+
+	hdmi_ctrl->vote_hdmi_core_on = false;
+
+	if (vote && hpd)
+		hdmi_ctrl->vote_hdmi_core_on = true;
+
+	return hpd;
+}
+
 int msm_hdmi_register_audio_codec(struct platform_device *pdev,
 	struct msm_hdmi_audio_codec_ops *ops)
 {
@@ -2205,6 +2284,7 @@
 
 	ops->audio_info_setup = hdmi_tx_audio_info_setup;
 	ops->get_audio_edid_blk = hdmi_tx_get_audio_edid_blk;
+	ops->hdmi_cable_status = hdmi_tx_get_cable_status;
 
 	return 0;
 } /* hdmi_tx_audio_register */
@@ -2245,10 +2325,8 @@
 	return 0;
 } /* hdmi_tx_audio_setup */
 
-static void hdmi_tx_audio_off(struct hdmi_tx_ctrl *hdmi_ctrl,
-				bool wait_audio_tx)
+static void hdmi_tx_audio_off(struct hdmi_tx_ctrl *hdmi_ctrl)
 {
-	u32 i = 0, status, sleep_us, timeout_us, timeout_sec = 15;
 	struct dss_io_data *io = NULL;
 
 	if (!hdmi_ctrl) {
@@ -2262,34 +2340,6 @@
 		return;
 	}
 
-	if (wait_audio_tx) {
-		/* Check if audio engine is turned off by QDSP or not */
-		/* send off notification after every 1 sec for 15 seconds */
-		for (i = 0; i < timeout_sec; i++) {
-			/* Maximum time to sleep between two reads */
-			sleep_us = 5000;
-			/* Total time for condition to meet */
-			timeout_us = 1000 * 1000;
-
-			if (readl_poll_timeout((io->base + HDMI_AUDIO_CFG),
-				status, ((status & BIT(0)) == 0),
-				sleep_us, timeout_us)) {
-
-				DEV_ERR(
-				"%s: audio still on after %d sec. try again\n",
-				__func__, i+1);
-
-				hdmi_tx_set_audio_switch_node(hdmi_ctrl, 0,
-					true);
-				continue;
-			}
-			break;
-		}
-	}
-
-	if (i == timeout_sec)
-		DEV_ERR("%s: Error: cannot turn off audio engine\n", __func__);
-
 	if (hdmi_tx_audio_iframe_setup(hdmi_ctrl, false))
 		DEV_ERR("%s: hdmi_tx_audio_iframe_setup failed.\n", __func__);
 
@@ -2413,19 +2463,14 @@
 		hdmi_hdcp_off(hdmi_ctrl->feature_data[HDMI_TX_FEAT_HDCP]);
 	}
 
-	if (!hdmi_tx_is_dvi_mode(hdmi_ctrl)) {
-		hdmi_tx_set_audio_switch_node(hdmi_ctrl, 0, false);
-		hdmi_tx_audio_off(hdmi_ctrl, true);
-	}
+	if (hdmi_tx_enable_power(hdmi_ctrl, HDMI_TX_DDC_PM, false))
+		DEV_WARN("%s: Failed to disable ddc power\n", __func__);
+
+	if (!hdmi_tx_is_dvi_mode(hdmi_ctrl))
+		hdmi_tx_audio_off(hdmi_ctrl);
 
 	hdmi_tx_powerdown_phy(hdmi_ctrl);
 
-	/*
-	 * this is needed to avoid pll lock failure due to
-	 * clk framework's rate caching.
-	 */
-	hdmi_ctrl->pdata.power_data[HDMI_TX_CORE_PM].clk_config[0].rate = 0;
-
 	hdmi_cec_deconfig(hdmi_ctrl->feature_data[HDMI_TX_FEAT_CEC]);
 
 	hdmi_tx_core_off(hdmi_ctrl);
@@ -2440,6 +2485,10 @@
 	mutex_unlock(&hdmi_ctrl->mutex);
 
 	DEV_INFO("%s: HDMI Core: OFF\n", __func__);
+
+	if (hdmi_ctrl->hdmi_tx_hpd_done)
+		hdmi_ctrl->hdmi_tx_hpd_done(
+			hdmi_ctrl->downstream_data);
 } /* hdmi_tx_power_off_work */
 
 static int hdmi_tx_power_off(struct mdss_panel_data *panel_data)
@@ -2542,6 +2591,9 @@
 
 	hdmi_tx_hpd_polarity_setup(hdmi_ctrl, HPD_DISCONNECT_POLARITY);
 
+	if (hdmi_ctrl->hdmi_tx_hpd_done)
+		hdmi_ctrl->hdmi_tx_hpd_done(hdmi_ctrl->downstream_data);
+
 	return 0;
 } /* hdmi_tx_power_on */
 
@@ -2549,6 +2601,7 @@
 {
 	int rc = 0;
 	struct dss_io_data *io = NULL;
+	unsigned long flags;
 
 	if (!hdmi_ctrl) {
 		DEV_ERR("%s: invalid input\n", __func__);
@@ -2588,7 +2641,10 @@
 		DEV_INFO("%s: Failed to disable hpd power. Error=%d\n",
 			__func__, rc);
 
+	spin_lock_irqsave(&hdmi_ctrl->hpd_state_lock, flags);
 	hdmi_ctrl->hpd_state = false;
+	spin_unlock_irqrestore(&hdmi_ctrl->hpd_state_lock, flags);
+
 	hdmi_ctrl->hpd_initialized = false;
 } /* hdmi_tx_hpd_off */
 
@@ -2667,10 +2723,6 @@
 			hdmi_tx_hpd_off(hdmi_ctrl);
 		else
 			hdmi_ctrl->hpd_off_pending = true;
-
-		hdmi_tx_send_cable_notification(hdmi_ctrl, 0);
-		DEV_DBG("%s: Hdmi state switch to %d\n", __func__,
-			hdmi_ctrl->sdev.state);
 	}
 
 	return rc;
@@ -2718,6 +2770,7 @@
 {
 	struct dss_io_data *io = NULL;
 	struct hdmi_tx_ctrl *hdmi_ctrl = (struct hdmi_tx_ctrl *)data;
+	unsigned long flags;
 
 	if (!hdmi_ctrl) {
 		DEV_WARN("%s: invalid input data, ISR ignored\n", __func__);
@@ -2732,8 +2785,10 @@
 	}
 
 	if (DSS_REG_R(io, HDMI_HPD_INT_STATUS) & BIT(0)) {
+		spin_lock_irqsave(&hdmi_ctrl->hpd_state_lock, flags);
 		hdmi_ctrl->hpd_state =
 			(DSS_REG_R(io, HDMI_HPD_INT_STATUS) & BIT(1)) >> 1;
+		spin_unlock_irqrestore(&hdmi_ctrl->hpd_state_lock, flags);
 
 		/*
 		 * Ack the current hpd interrupt and stop listening to
@@ -2832,6 +2887,8 @@
 
 	INIT_WORK(&hdmi_ctrl->power_off_work, hdmi_tx_power_off_work);
 
+	spin_lock_init(&hdmi_ctrl->hpd_state_lock);
+
 	hdmi_ctrl->audio_data.sample_rate = AUDIO_SAMPLE_RATE_48KHZ;
 	hdmi_ctrl->audio_data.channel_num = MSM_HDMI_AUDIO_CHANNEL_2;
 
diff --git a/drivers/video/msm/mdss/mdss_hdmi_tx.h b/drivers/video/msm/mdss/mdss_hdmi_tx.h
index fd95582..66071e9 100644
--- a/drivers/video/msm/mdss/mdss_hdmi_tx.h
+++ b/drivers/video/msm/mdss/mdss_hdmi_tx.h
@@ -58,6 +58,7 @@
 	struct switch_dev sdev;
 	struct switch_dev audio_sdev;
 	struct workqueue_struct *workq;
+	spinlock_t hpd_state_lock;
 
 	uint32_t video_resolution;
 
@@ -68,6 +69,7 @@
 	u32 hpd_off_pending;
 	u32 hpd_feature_on;
 	u32 hpd_initialized;
+	u32 vote_hdmi_core_on;
 	u8  timing_gen_on;
 	u32 mhl_max_pclk;
 	u8  mhl_hpd_on;
@@ -84,6 +86,9 @@
 
 	struct hdmi_tx_ddc_ctrl ddc_ctrl;
 
+	void (*hdmi_tx_hpd_done) (void *data);
+	void *downstream_data;
+
 	void *feature_data[HDMI_TX_FEAT_MAX];
 };
 
diff --git a/drivers/video/msm/mdss/mdss_mdp.c b/drivers/video/msm/mdss/mdss_mdp.c
index db8a098..3afe2c7 100644
--- a/drivers/video/msm/mdss/mdss_mdp.c
+++ b/drivers/video/msm/mdss/mdss_mdp.c
@@ -79,6 +79,7 @@
 
 static DEFINE_SPINLOCK(mdp_lock);
 static DEFINE_MUTEX(mdp_clk_lock);
+static DEFINE_MUTEX(bus_bw_lock);
 
 #define MDP_BUS_VECTOR_ENTRY(ab_val, ib_val)		\
 	{						\
@@ -608,9 +609,58 @@
 	return clk_rate;
 }
 
+/**
+ * mdss_bus_bandwidth_ctrl() -- place bus bandwidth request
+ * @enable:	value of enable or disable
+ *
+ * Function place bus bandwidth request to allocate saved bandwidth
+ * if enabled or free bus bandwidth allocation if disabled.
+ * Bus bandwidth is required by mdp.For dsi, it only requires to send
+ * dcs coammnd.
+ */
+void mdss_bus_bandwidth_ctrl(int enable)
+{
+	struct mdss_data_type *mdata = mdss_mdp_get_mdata();
+	static int bus_bw_cnt;
+	int changed = 0;
+
+	mutex_lock(&bus_bw_lock);
+	if (enable) {
+		if (bus_bw_cnt == 0)
+			changed++;
+		bus_bw_cnt++;
+	} else {
+		if (bus_bw_cnt) {
+			bus_bw_cnt--;
+			if (bus_bw_cnt == 0)
+				changed++;
+		} else {
+			pr_err("Can not be turned off\n");
+		}
+	}
+
+	pr_debug("bw_cnt=%d changed=%d enable=%d\n",
+			bus_bw_cnt, changed, enable);
+
+	if (changed) {
+		if (!enable) {
+			msm_bus_scale_client_update_request(
+				mdata->bus_hdl, 0);
+			pm_runtime_put(&mdata->pdev->dev);
+		} else {
+			pm_runtime_get_sync(&mdata->pdev->dev);
+			msm_bus_scale_client_update_request(
+				mdata->bus_hdl, mdata->current_bus_idx);
+		}
+	}
+
+	mutex_unlock(&bus_bw_lock);
+}
+EXPORT_SYMBOL(mdss_bus_bandwidth_ctrl);
+
 void mdss_mdp_clk_ctrl(int enable, int isr)
 {
-	struct mdss_data_type *mdata = mdss_res;
+	struct mdss_data_type *mdata = mdss_mdp_get_mdata();
 	static int mdp_clk_cnt;
 	int changed = 0;
 
@@ -620,9 +670,13 @@
 			changed++;
 		mdp_clk_cnt++;
 	} else {
-		mdp_clk_cnt--;
-		if (mdp_clk_cnt == 0)
-			changed++;
+		if (mdp_clk_cnt) {
+			mdp_clk_cnt--;
+			if (mdp_clk_cnt == 0)
+				changed++;
+		} else {
+			pr_err("Can not be turned off\n");
+		}
 	}
 
 	pr_debug("%s: clk_cnt=%d changed=%d enable=%d\n",
@@ -640,14 +694,10 @@
 		if (mdata->vsync_ena)
 			mdss_mdp_clk_update(MDSS_CLK_MDP_VSYNC, enable);
 
-		if (!enable) {
-			msm_bus_scale_client_update_request(
-				mdss_res->bus_hdl, 0);
+		mdss_bus_bandwidth_ctrl(enable);
+
+		if (!enable)
 			pm_runtime_put(&mdata->pdev->dev);
-		} else {
-			msm_bus_scale_client_update_request(
-				mdss_res->bus_hdl, mdss_res->current_bus_idx);
-		}
 	}
 
 	mutex_unlock(&mdp_clk_lock);
@@ -1771,7 +1821,8 @@
 	struct mdss_data_type *mdata = platform_get_drvdata(pdev);
 	u32 num;
 	u32 data[2];
-	int rc;
+	int rc, len;
+	const u32 *arr;
 
 	num = mdss_mdp_parse_dt_prop_len(pdev, "qcom,mdss-smp-data");
 
@@ -1793,7 +1844,49 @@
 		"qcom,mdss-smp-mb-per-pipe", data);
 	mdata->smp_mb_per_pipe = (!rc ? data[0] : 0);
 
-	return 0;
+	rc = 0;
+	arr = of_get_property(pdev->dev.of_node,
+		"qcom,mdss-pipe-rgb-fixed-mmb", &len);
+	if (arr) {
+		int i, j, k;
+		u32 cnt, mmb;
+
+		len /= sizeof(u32);
+		for (i = 0, k = 0; i < len; k++) {
+			struct mdss_mdp_pipe *pipe = NULL;
+
+			if (k >= mdata->nrgb_pipes) {
+				pr_err("invalid fixed mmbs for rgb pipes\n");
+				return -EINVAL;
+			}
+
+			pipe = &mdata->rgb_pipes[k];
+
+			cnt = be32_to_cpu(arr[i++]);
+			if (cnt == 0)
+				continue;
+
+			for (j = 0; j < cnt; j++) {
+				mmb = be32_to_cpu(arr[i++]);
+				if (mmb > mdata->smp_mb_cnt) {
+					pr_err("overflow mmb%d: rgb%d: max%d\n",
+						mmb, k, mdata->smp_mb_cnt);
+					return -EINVAL;
+				}
+				/* rgb pipes fetches only single plane */
+				set_bit(mmb, pipe->smp_map[0].fixed);
+			}
+			if (bitmap_intersects(pipe->smp_map[0].fixed,
+				mdata->mmb_alloc_map, mdata->smp_mb_cnt)) {
+				pr_err("overlapping fixed mmb map\n");
+				return -EINVAL;
+			}
+			bitmap_or(mdata->mmb_alloc_map, pipe->smp_map[0].fixed,
+				mdata->mmb_alloc_map, mdata->smp_mb_cnt);
+		}
+	}
+
+	return rc;
 }
 
 static int mdss_mdp_parse_dt_misc(struct platform_device *pdev)
diff --git a/drivers/video/msm/mdss/mdss_mdp.h b/drivers/video/msm/mdss/mdss_mdp.h
index 3ce61a0..f36e3c5 100644
--- a/drivers/video/msm/mdss/mdss_mdp.h
+++ b/drivers/video/msm/mdss/mdss_mdp.h
@@ -18,9 +18,11 @@
 #include <linux/io.h>
 #include <linux/msm_mdp.h>
 #include <linux/platform_device.h>
+#include <linux/notifier.h>
 
 #include "mdss.h"
 #include "mdss_mdp_hwio.h"
+#include "mdss_fb.h"
 
 #define MDSS_MDP_DEFAULT_INTR_MASK 0
 #define MDSS_MDP_CURSOR_WIDTH 64
@@ -35,7 +37,6 @@
 #define MAX_IMG_HEIGHT		0x3FFF
 #define MAX_DST_W		MAX_MIXER_WIDTH
 #define MAX_DST_H		MAX_MIXER_HEIGHT
-#define MAX_PLANES		4
 #define MAX_DOWNSCALE_RATIO	4
 #define MAX_UPSCALE_RATIO	20
 #define MAX_DECIMATION		4
@@ -50,6 +51,11 @@
 /* wait for at most 2 vsync for lowest refresh rate (24hz) */
 #define KOFF_TIMEOUT msecs_to_jiffies(84)
 
+#define OVERFETCH_DISABLE_TOP		BIT(0)
+#define OVERFETCH_DISABLE_BOTTOM	BIT(1)
+#define OVERFETCH_DISABLE_LEFT		BIT(2)
+#define OVERFETCH_DISABLE_RIGHT		BIT(3)
+
 #ifdef MDSS_MDP_DEBUG_REG
 static inline void mdss_mdp_reg_write(u32 addr, u32 val)
 {
@@ -187,6 +193,9 @@
 	int (*remove_vsync_handler) (struct mdss_mdp_ctl *,
 					struct mdss_mdp_vsync_handler *);
 	int (*config_fps_fnc) (struct mdss_mdp_ctl *ctl, int new_fps);
+
+	struct blocking_notifier_head notifier_head;
+
 	void *priv_data;
 	u32 wb_type;
 };
@@ -311,8 +320,9 @@
 };
 
 struct mdss_mdp_pipe_smp_map {
-	DECLARE_BITMAP(reserved, MDSS_MDP_SMP_MMB_BLOCKS);
-	DECLARE_BITMAP(allocated, MDSS_MDP_SMP_MMB_BLOCKS);
+	DECLARE_BITMAP(reserved, MAX_DRV_SUP_MMB_BLKS);
+	DECLARE_BITMAP(allocated, MAX_DRV_SUP_MMB_BLKS);
+	DECLARE_BITMAP(fixed, MAX_DRV_SUP_MMB_BLKS);
 };
 
 struct mdss_mdp_pipe {
@@ -324,6 +334,7 @@
 	atomic_t ref_cnt;
 	u32 play_cnt;
 	int pid;
+	bool is_handed_off;
 
 	u32 flags;
 	u32 bwc_mode;
@@ -334,9 +345,6 @@
 	u8 vert_deci;
 	struct mdss_mdp_img_rect src;
 	struct mdss_mdp_img_rect dst;
-	u32 phase_step_x;
-	u32 phase_step_y;
-
 	struct mdss_mdp_format_params *src_fmt;
 	struct mdss_mdp_plane_sizes src_planes;
 
@@ -363,11 +371,13 @@
 
 	struct mdp_overlay_pp_params pp_cfg;
 	struct mdss_pipe_pp_res pp_res;
+	struct mdp_scale_data scale;
+	u8 chroma_sample_h;
+	u8 chroma_sample_v;
 };
 
 struct mdss_mdp_writeback_arg {
 	struct mdss_mdp_data *data;
-	void (*callback_fnc) (void *arg);
 	void *priv_data;
 };
 
@@ -393,6 +403,7 @@
 	int free_list_size;
 	int ad_state;
 
+	bool handoff;
 	u32 splash_mem_addr;
 	u32 splash_mem_size;
 	u32 sd_enabled;
@@ -479,9 +490,11 @@
 
 struct mdss_mdp_ctl *mdss_mdp_ctl_init(struct mdss_panel_data *pdata,
 					struct msm_fb_data_type *mfd);
-int mdss_mdp_video_reconfigure_splash_done(struct mdss_mdp_ctl *ctl);
-int mdss_mdp_cmd_reconfigure_splash_done(struct mdss_mdp_ctl *ctl);
-int mdss_mdp_ctl_splash_finish(struct mdss_mdp_ctl *ctl);
+int mdss_mdp_video_reconfigure_splash_done(struct mdss_mdp_ctl *ctl,
+		bool handoff);
+int mdss_mdp_cmd_reconfigure_splash_done(struct mdss_mdp_ctl *ctl,
+		bool handoff);
+int mdss_mdp_ctl_splash_finish(struct mdss_mdp_ctl *ctl, bool handoff);
 int mdss_mdp_ctl_setup(struct mdss_mdp_ctl *ctl);
 int mdss_mdp_ctl_split_display_setup(struct mdss_mdp_ctl *ctl,
 		struct mdss_panel_data *pdata);
@@ -491,7 +504,14 @@
 int mdss_mdp_ctl_intf_event(struct mdss_mdp_ctl *ctl, int event, void *arg);
 int mdss_mdp_perf_calc_pipe(struct mdss_mdp_pipe *pipe,
 		struct mdss_mdp_perf_params *perf);
+int mdss_mdp_ctl_notify(struct mdss_mdp_ctl *ctl, int event);
+void mdss_mdp_ctl_notifier_register(struct mdss_mdp_ctl *ctl,
+	struct notifier_block *notifier);
+void mdss_mdp_ctl_notifier_unregister(struct mdss_mdp_ctl *ctl,
+	struct notifier_block *notifier);
 
+int mdss_mdp_mixer_handoff(struct mdss_mdp_ctl *ctl, u32 num,
+	struct mdss_mdp_pipe *pipe);
 struct mdss_mdp_mixer *mdss_mdp_wb_mixer_alloc(int rotator);
 int mdss_mdp_wb_mixer_destroy(struct mdss_mdp_mixer *mixer);
 struct mdss_mdp_mixer *mdss_mdp_mixer_get(struct mdss_mdp_ctl *ctl, int mux);
@@ -545,6 +565,8 @@
 int mdss_mdp_calib_mode(struct msm_fb_data_type *mfd,
 				struct mdss_calib_cfg *cfg);
 
+int mdss_mdp_pipe_handoff(struct mdss_mdp_pipe *pipe);
+int mdss_mdp_smp_handoff(struct mdss_data_type *mdata);
 struct mdss_mdp_pipe *mdss_mdp_pipe_alloc(struct mdss_mdp_mixer *mixer,
 					  u32 type);
 struct mdss_mdp_pipe *mdss_mdp_pipe_get(struct mdss_data_type *mdata, u32 ndx);
@@ -611,6 +633,7 @@
 int mdss_mdp_wb_get_format(struct msm_fb_data_type *mfd,
 					struct mdp_mixer_cfg *mixer_cfg);
 
+int mdss_mdp_pipe_program_pixel_extn(struct mdss_mdp_pipe *pipe);
 #define mfd_to_mdp5_data(mfd) (mfd->mdp.private1)
 #define mfd_to_mdata(mfd) (((struct mdss_overlay_private *)\
 				(mfd->mdp.private1))->mdata)
diff --git a/drivers/video/msm/mdss/mdss_mdp_ctl.c b/drivers/video/msm/mdss/mdss_mdp_ctl.c
index e50598f..1198897 100644
--- a/drivers/video/msm/mdss/mdss_mdp_ctl.c
+++ b/drivers/video/msm/mdss/mdss_mdp_ctl.c
@@ -28,7 +28,7 @@
 #define MDSS_MDP_BUS_FUDGE_FACTOR_IB(val) (((val) / 2) * 3)
 #define MDSS_MDP_BUS_FUDGE_FACTOR_HIGH_IB(val) (val << 1)
 #define MDSS_MDP_BUS_FUDGE_FACTOR_AB(val) (val << 1)
-#define MDSS_MDP_BUS_FLOOR_BW (3200000000ULL >> MDSS_MDP_BUS_FACTOR_SHIFT)
+#define MDSS_MDP_BUS_FLOOR_BW (1600000000ULL >> MDSS_MDP_BUS_FACTOR_SHIFT)
 
 /* 1.25 clock fudge factor */
 #define MDSS_MDP_CLK_FUDGE_FACTOR(val) (((val) * 5) / 4)
@@ -385,6 +385,7 @@
 			ctl->ref_cnt++;
 			ctl->mdata = mdata;
 			mutex_init(&ctl->lock);
+			BLOCKING_INIT_NOTIFIER_HEAD(&ctl->notifier_head);
 			pr_debug("alloc ctl_num=%d\n", ctl->num);
 			break;
 		}
@@ -610,13 +611,13 @@
 	return 0;
 }
 
-int mdss_mdp_ctl_splash_finish(struct mdss_mdp_ctl *ctl)
+int mdss_mdp_ctl_splash_finish(struct mdss_mdp_ctl *ctl, bool handoff)
 {
 	switch (ctl->panel_data->panel_info.type) {
 	case MIPI_VIDEO_PANEL:
-		return mdss_mdp_video_reconfigure_splash_done(ctl);
+		return mdss_mdp_video_reconfigure_splash_done(ctl, handoff);
 	case MIPI_CMD_PANEL:
-		return mdss_mdp_cmd_reconfigure_splash_done(ctl);
+		return mdss_mdp_cmd_reconfigure_splash_done(ctl, handoff);
 	default:
 		return 0;
 	}
@@ -973,6 +974,8 @@
 
 	mixer->width = sctl->width;
 	mixer->height = sctl->height;
+	mixer->roi = (struct mdss_mdp_img_rect)
+				{0, 0, mixer->width, mixer->height};
 	sctl->mixer_left = mixer;
 
 	return mdss_mdp_set_split_ctl(ctl, sctl);
@@ -1078,9 +1081,12 @@
 
 	pr_debug("ctl_num=%d\n", ctl->num);
 
-	nmixers = MDSS_MDP_INTF_MAX_LAYERMIXER + MDSS_MDP_WB_MAX_LAYERMIXER;
-	for (i = 0; i < nmixers; i++)
-		mdss_mdp_ctl_write(ctl, MDSS_MDP_REG_CTL_LAYER(i), 0);
+	if (!ctl->panel_data->panel_info.cont_splash_enabled) {
+		nmixers = MDSS_MDP_INTF_MAX_LAYERMIXER +
+			MDSS_MDP_WB_MAX_LAYERMIXER;
+		for (i = 0; i < nmixers; i++)
+			mdss_mdp_ctl_write(ctl, MDSS_MDP_REG_CTL_LAYER(i), 0);
+	}
 
 	mixer = ctl->mixer_left;
 	mdss_mdp_pp_resume(ctl, mixer->num);
@@ -1556,9 +1562,17 @@
 struct mdss_mdp_mixer *mdss_mdp_mixer_get(struct mdss_mdp_ctl *ctl, int mux)
 {
 	struct mdss_mdp_mixer *mixer = NULL;
-	struct mdss_overlay_private *mdp5_data = mfd_to_mdp5_data(ctl->mfd);
-	if (!ctl)
+	struct mdss_overlay_private *mdp5_data = NULL;
+	if (!ctl || !ctl->mfd) {
+		pr_err("ctl not initialized\n");
 		return NULL;
+	}
+
+	mdp5_data = mfd_to_mdp5_data(ctl->mfd);
+	if (!mdp5_data) {
+		pr_err("ctl not initialized\n");
+		return NULL;
+	}
 
 	switch (mux) {
 	case MDSS_MDP_MIXER_MUX_DEFAULT:
@@ -1770,6 +1784,11 @@
 {
 	int ret;
 
+	if (!ctl) {
+		pr_err("invalid ctl\n");
+		return -ENODEV;
+	}
+
 	ret = mutex_lock_interruptible(&ctl->lock);
 	if (ret)
 		return ret;
@@ -1870,6 +1889,11 @@
 		}
 	}
 
+	mdss_mdp_ctl_notify(ctl, MDP_NOTIFY_FRAME_READY);
+
+	if (ctl->wait_pingpong)
+		ctl->wait_pingpong(ctl, NULL);
+
 	/* postprocessing setup, including dspp */
 	mdss_mdp_pp_setup_locked(ctl);
 	mdss_mdp_ctl_write(ctl, MDSS_MDP_REG_CTL_FLUSH, ctl->flush_bits);
@@ -1895,6 +1919,23 @@
 	return ret;
 }
 
+void mdss_mdp_ctl_notifier_register(struct mdss_mdp_ctl *ctl,
+	struct notifier_block *notifier)
+{
+	blocking_notifier_chain_register(&ctl->notifier_head, notifier);
+}
+
+void mdss_mdp_ctl_notifier_unregister(struct mdss_mdp_ctl *ctl,
+	struct notifier_block *notifier)
+{
+	blocking_notifier_chain_unregister(&ctl->notifier_head, notifier);
+}
+
+int mdss_mdp_ctl_notify(struct mdss_mdp_ctl *ctl, int event)
+{
+	return blocking_notifier_call_chain(&ctl->notifier_head, event, ctl);
+}
+
 int mdss_mdp_get_ctl_mixers(u32 fb_num, u32 *mixer_id)
 {
 	int i;
@@ -1965,3 +2006,66 @@
 				MDSS_MDP_INTF_LAYERMIXER3);
 	}
 }
+
+static int __mdss_mdp_mixer_handoff_helper(struct mdss_mdp_mixer *mixer,
+	struct mdss_mdp_pipe *pipe)
+{
+	int rc = 0;
+
+	if (!mixer) {
+		rc = -EINVAL;
+		goto error;
+	}
+
+	if (mixer->stage_pipe[MDSS_MDP_STAGE_UNUSED] != NULL) {
+		pr_err("More than one pipe staged on mixer num %d\n",
+			mixer->num);
+		rc = -EINVAL;
+		goto error;
+	}
+
+	pr_debug("Staging pipe num %d on mixer num %d\n",
+		pipe->num, mixer->num);
+	mixer->stage_pipe[MDSS_MDP_STAGE_UNUSED] = pipe;
+	pipe->mixer = mixer;
+	pipe->mixer_stage = MDSS_MDP_STAGE_UNUSED;
+
+error:
+	return rc;
+}
+
+/**
+ * mdss_mdp_mixer_handoff() - Stages a given pipe on the appropriate mixer
+ * @ctl:  pointer to the control structure associated with the overlay device.
+ * @num:  the mixer number on which the pipe needs to be staged.
+ * @pipe: pointer to the pipe to be staged.
+ *
+ * Function stages a given pipe on either the left mixer or the right mixer
+ * for the control structre based on the mixer number. If the input mixer
+ * number does not match either of the mixers then an error is returned.
+ * This function is called during overlay handoff when certain pipes are
+ * already staged by the bootloader.
+ */
+int mdss_mdp_mixer_handoff(struct mdss_mdp_ctl *ctl, u32 num,
+	struct mdss_mdp_pipe *pipe)
+{
+	int rc = 0;
+	struct mdss_mdp_mixer *mx_left = ctl->mixer_left;
+	struct mdss_mdp_mixer *mx_right = ctl->mixer_right;
+
+	/*
+	 * For performance calculations, stage the handed off pipe
+	 * as MDSS_MDP_STAGE_UNUSED
+	 */
+	if (mx_left && (mx_left->num == num)) {
+		rc = __mdss_mdp_mixer_handoff_helper(mx_left, pipe);
+	} else if (mx_right && (mx_right->num == num)) {
+		rc = __mdss_mdp_mixer_handoff_helper(mx_right, pipe);
+	} else {
+		pr_err("pipe num %d staged on unallocated mixer num %d\n",
+			pipe->num, num);
+		rc = -EINVAL;
+	}
+
+	return rc;
+}
diff --git a/drivers/video/msm/mdss/mdss_mdp_hwio.h b/drivers/video/msm/mdss/mdss_mdp_hwio.h
index 940d6c9..8d59107 100644
--- a/drivers/video/msm/mdss/mdss_mdp_hwio.h
+++ b/drivers/video/msm/mdss/mdss_mdp_hwio.h
@@ -201,6 +201,9 @@
 #define MDSS_MDP_REG_SSPP_CURRENT_SRC2_ADDR		0x0AC
 #define MDSS_MDP_REG_SSPP_CURRENT_SRC3_ADDR		0x0B0
 #define MDSS_MDP_REG_SSPP_DECIMATION_CONFIG		0x0B4
+#define MDSS_MDP_REG_SSPP_SW_PIX_EXT_C0_LR		0x100
+#define MDSS_MDP_REG_SSPP_SW_PIX_EXT_C0_TB		0x104
+#define MDSS_MDP_REG_SSPP_SW_PIX_EXT_C0_REQ_PIXELS	0x108
 
 #define MDSS_MDP_REG_VIG_OP_MODE			0x200
 #define MDSS_MDP_REG_VIG_QSEED2_CONFIG			0x204
@@ -356,6 +359,8 @@
 #define MDSS_MDP_REG_WB_CSC_BASE			0x260
 #define MDSS_MDP_REG_WB_DST_ADDR_SW_STATUS		0x2B0
 
+#define MDSS_MDP_MAX_AD_AL	65535
+#define MDSS_MDP_MAX_AD_STR	255
 
 #define MDSS_MDP_REG_AD_BYPASS				0x000
 #define MDSS_MDP_REG_AD_CTRL_0				0x004
@@ -419,8 +424,6 @@
 	MDSS_MDP_MAX_INTF
 };
 
-#define MDSS_MDP_REG_INTF_OFFSET(intf)		(0x20F00 + ((intf) * 0x200))
-
 #define MDSS_MDP_REG_INTF_TIMING_ENGINE_EN		0x000
 #define MDSS_MDP_REG_INTF_CONFIG			0x004
 #define MDSS_MDP_REG_INTF_HSYNC_CTL			0x008
@@ -499,8 +502,6 @@
 #define MDSS_MDP_REG_SMP_ALLOC_W0			0x00180
 #define MDSS_MDP_REG_SMP_ALLOC_R0			0x00230
 
-#define MDSS_MDP_SMP_MMB_BLOCKS			44
-
 #define MDSS_MDP_LP_MISR_SEL			0x450
 #define MDSS_MDP_LP_MISR_CTRL_MDP		0x454
 #define MDSS_MDP_LP_MISR_CTRL_HDMI		0x458
diff --git a/drivers/video/msm/mdss/mdss_mdp_intf_cmd.c b/drivers/video/msm/mdss/mdss_mdp_intf_cmd.c
index e0717ad..d3e18ac 100644
--- a/drivers/video/msm/mdss/mdss_mdp_intf_cmd.c
+++ b/drivers/video/msm/mdss/mdss_mdp_intf_cmd.c
@@ -12,9 +12,9 @@
  */
 
 #include <linux/kernel.h>
-#include "mdss_panel.h"
+
 #include "mdss_mdp.h"
-#include "mdss_dsi.h"
+#include "mdss_panel.h"
 
 #define VSYNC_EXPIRE_TICK 4
 
@@ -43,6 +43,9 @@
 	struct mutex clk_mtx;
 	spinlock_t clk_lock;
 	struct work_struct clk_work;
+	struct work_struct pp_done_work;
+	atomic_t pp_done_cnt;
+
 	/* te config */
 	u8 tear_check;
 	u16 height;	/* panel height */
@@ -311,6 +314,8 @@
 	complete_all(&ctx->pp_comp);
 
 	if (ctx->koff_cnt) {
+		atomic_inc(&ctx->pp_done_cnt);
+		schedule_work(&ctx->pp_done_work);
 		ctx->koff_cnt--;
 		if (ctx->koff_cnt) {
 			pr_err("%s: too many kickoffs=%d!\n", __func__,
@@ -326,6 +331,16 @@
 	spin_unlock(&ctx->clk_lock);
 }
 
+static void pingpong_done_work(struct work_struct *work)
+{
+	struct mdss_mdp_cmd_ctx *ctx =
+		container_of(work, typeof(*ctx), pp_done_work);
+
+	if (ctx->ctl)
+		while (atomic_add_unless(&ctx->pp_done_cnt, -1, 0))
+			mdss_mdp_ctl_notify(ctx->ctl, MDP_NOTIFY_FRAME_DONE);
+}
+
 static void clk_ctrl_work(struct work_struct *work)
 {
 	struct mdss_mdp_cmd_ctx *ctx =
@@ -399,7 +414,7 @@
 	return 0;
 }
 
-int mdss_mdp_cmd_reconfigure_splash_done(struct mdss_mdp_ctl *ctl)
+int mdss_mdp_cmd_reconfigure_splash_done(struct mdss_mdp_ctl *ctl, bool handoff)
 {
 	struct mdss_panel_data *pdata;
 	int ret = 0;
@@ -446,8 +461,10 @@
 			WARN(1, "cmd kickoff timed out (%d) ctl=%d\n",
 						rc, ctl->num);
 			rc = -EPERM;
-		} else
+			mdss_mdp_ctl_notify(ctl, MDP_NOTIFY_FRAME_TIMEOUT);
+		} else {
 			rc = 0;
+		}
 	}
 
 	return rc;
@@ -515,6 +532,7 @@
 int mdss_mdp_cmd_stop(struct mdss_mdp_ctl *ctl)
 {
 	struct mdss_mdp_cmd_ctx *ctx;
+	struct mdss_panel_info *pinfo;
 	unsigned long flags;
 	struct mdss_mdp_vsync_handler *tmp, *handle;
 	int need_wait = 0;
@@ -525,6 +543,10 @@
 		pr_err("invalid ctx\n");
 		return -ENODEV;
 	}
+
+	list_for_each_entry_safe(handle, tmp, &ctx->vsync_handlers, list)
+		mdss_mdp_cmd_remove_vsync_handler(ctl, handle);
+
 	spin_lock_irqsave(&ctx->clk_lock, flags);
 	if (ctx->rdptr_enabled) {
 		INIT_COMPLETION(ctx->stop_comp);
@@ -534,18 +556,31 @@
 
 	if (need_wait)
 		if (wait_for_completion_timeout(&ctx->stop_comp, STOP_TIMEOUT)
-		    <= 0)
+		    <= 0) {
 			WARN(1, "stop cmd time out\n");
 
+			if (IS_ERR_OR_NULL(ctl->panel_data)) {
+				pr_err("no panel data\n");
+			} else {
+				pinfo = &ctl->panel_data->panel_info;
+
+				if (pinfo->panel_dead) {
+					mdss_mdp_irq_disable
+						(MDSS_MDP_IRQ_PING_PONG_RD_PTR,
+								ctx->pp_num);
+					ctx->rdptr_enabled = 0;
+				}
+			}
+		}
+
 	if (cancel_work_sync(&ctx->clk_work))
 		pr_debug("no pending clk work\n");
 
 	mdss_mdp_cmd_clk_off(ctx);
 
-	ctx->panel_on = 0;
+	flush_work(&ctx->pp_done_work);
 
-	list_for_each_entry_safe(handle, tmp, &ctx->vsync_handlers, list)
-		mdss_mdp_cmd_remove_vsync_handler(ctl, handle);
+	ctx->panel_on = 0;
 
 	mdss_mdp_set_intr_callback(MDSS_MDP_IRQ_PING_PONG_RD_PTR, ctx->pp_num,
 				   NULL, NULL);
@@ -611,6 +646,8 @@
 	spin_lock_init(&ctx->clk_lock);
 	mutex_init(&ctx->clk_mtx);
 	INIT_WORK(&ctx->clk_work, clk_ctrl_work);
+	INIT_WORK(&ctx->pp_done_work, pingpong_done_work);
+	atomic_set(&ctx->pp_done_cnt, 0);
 	INIT_LIST_HEAD(&ctx->vsync_handlers);
 
 	ctx->recovery.fxn = mdss_mdp_cmd_underflow_recovery;
diff --git a/drivers/video/msm/mdss/mdss_mdp_intf_video.c b/drivers/video/msm/mdss/mdss_mdp_intf_video.c
index a040785..bd1c3eb 100644
--- a/drivers/video/msm/mdss/mdss_mdp_intf_video.c
+++ b/drivers/video/msm/mdss/mdss_mdp_intf_video.c
@@ -21,6 +21,7 @@
 
 #include "mdss_fb.h"
 #include "mdss_mdp.h"
+#include "mdss_panel.h"
 
 /* wait for at least 2 vsyncs for lowest refresh rate (24hz) */
 #define VSYNC_TIMEOUT_US 100000
@@ -293,6 +294,7 @@
 	struct mdss_mdp_video_ctx *ctx;
 	struct mdss_mdp_vsync_handler *tmp, *handle;
 	int rc;
+	u32 frame_rate = 0;
 
 	pr_debug("stop ctl=%d\n", ctl->num);
 
@@ -312,6 +314,14 @@
 		WARN(rc, "intf %d blank error (%d)\n", ctl->intf_num, rc);
 
 		mdp_video_write(ctx, MDSS_MDP_REG_INTF_TIMING_ENGINE_EN, 0);
+		/* wait for at least one VSYNC on HDMI intf for proper TG OFF */
+		if (MDSS_INTF_HDMI == ctx->intf_type) {
+			frame_rate = mdss_panel_get_framerate
+					(&(ctl->panel_data->panel_info));
+			if (!(frame_rate >= 24 && frame_rate <= 240))
+				frame_rate = 24;
+			msleep((1000/frame_rate) + 1);
+		}
 		mdss_mdp_clk_ctrl(MDP_BLOCK_POWER_OFF, false);
 		ctx->timegen_en = false;
 
@@ -429,6 +439,8 @@
 			rc = 0;
 		}
 	}
+	mdss_mdp_ctl_notify(ctl,
+			rc ? MDP_NOTIFY_FRAME_TIMEOUT : MDP_NOTIFY_FRAME_DONE);
 
 	if (ctx->wait_pending) {
 		ctx->wait_pending = 0;
@@ -583,46 +595,52 @@
 	return 0;
 }
 
-int mdss_mdp_video_reconfigure_splash_done(struct mdss_mdp_ctl *ctl)
+int mdss_mdp_video_reconfigure_splash_done(struct mdss_mdp_ctl *ctl,
+	bool handoff)
 {
-	struct mdss_panel_data *pdata;
-	int ret = 0, off;
-	int mdss_mdp_rev = MDSS_MDP_REG_READ(MDSS_MDP_REG_HW_VERSION);
-	int mdss_v2_intf_off = 0;
+	struct mdss_panel_data *pdata = ctl->panel_data;
+	int i, ret = 0;
 	struct mdss_overlay_private *mdp5_data = mfd_to_mdp5_data(ctl->mfd);
+	struct mdss_mdp_video_ctx *ctx;
+	struct mdss_data_type *mdata = ctl->mdata;
 
-	off = 0;
-
-	pdata = ctl->panel_data;
-
-	pdata->panel_info.cont_splash_enabled = 0;
-
-	ret = mdss_mdp_ctl_intf_event(ctl, MDSS_EVENT_CONT_SPLASH_BEGIN,
-				      NULL);
-	if (ret) {
-		pr_err("%s: Failed to handle 'CONT_SPLASH_BEGIN' event\n",
-					__func__);
-		return ret;
+	i = ctl->intf_num - MDSS_MDP_INTF0;
+	if (i < mdata->nintf) {
+		ctx = ((struct mdss_mdp_video_ctx *) mdata->video_intf) + i;
+		pr_debug("video Intf #%d base=%p", ctx->intf_num, ctx->base);
+	} else {
+		pr_err("Invalid intf number: %d\n", ctl->intf_num);
+		ret = -EINVAL;
+		goto error;
 	}
 
-	mdss_mdp_ctl_write(ctl, 0, MDSS_MDP_LM_BORDER_COLOR);
-	off = MDSS_MDP_REG_INTF_OFFSET(ctl->intf_num);
+	if (!handoff) {
+		ret = mdss_mdp_ctl_intf_event(ctl, MDSS_EVENT_CONT_SPLASH_BEGIN,
+					      NULL);
+		if (ret) {
+			pr_err("%s: Failed to handle 'CONT_SPLASH_BEGIN' event\n"
+				, __func__);
+			return ret;
+		}
 
-	if (mdss_mdp_rev >= MDSS_MDP_HW_REV_102)
-		mdss_v2_intf_off =  0xEC00;
+		mdss_mdp_ctl_write(ctl, 0, MDSS_MDP_LM_BORDER_COLOR);
+		mdp_video_write(ctx, MDSS_MDP_REG_INTF_TIMING_ENGINE_EN, 0);
 
-	MDSS_MDP_REG_WRITE(off + MDSS_MDP_REG_INTF_TIMING_ENGINE_EN -
-			mdss_v2_intf_off, 0);
-	/* wait for 1 VSYNC for the pipe to be unstaged */
-	msleep(20);
+		/* wait for 1 VSYNC for the pipe to be unstaged */
+		msleep(20);
+
+		ret = mdss_mdp_ctl_intf_event(ctl,
+			MDSS_EVENT_CONT_SPLASH_FINISH, NULL);
+	}
+
+error:
+	pdata->panel_info.cont_splash_enabled = 0;
 
 	/* Give back the reserved memory to the system */
 	memblock_free(mdp5_data->splash_mem_addr, mdp5_data->splash_mem_size);
 	free_bootmem_late(mdp5_data->splash_mem_addr,
 				 mdp5_data->splash_mem_size);
 
-	ret = mdss_mdp_ctl_intf_event(ctl, MDSS_EVENT_CONT_SPLASH_FINISH,
-			NULL);
 	mdss_mdp_clk_ctrl(MDP_BLOCK_POWER_OFF, false);
 	return ret;
 }
diff --git a/drivers/video/msm/mdss/mdss_mdp_intf_writeback.c b/drivers/video/msm/mdss/mdss_mdp_intf_writeback.c
index 7f872b4..ff55c57 100644
--- a/drivers/video/msm/mdss/mdss_mdp_intf_writeback.c
+++ b/drivers/video/msm/mdss/mdss_mdp_intf_writeback.c
@@ -13,9 +13,9 @@
 
 #define pr_fmt(fmt)	"%s: " fmt, __func__
 
-#include "mdss_fb.h"
 #include "mdss_mdp.h"
 #include "mdss_mdp_rotator.h"
+#include "mdss_panel.h"
 
 enum mdss_mdp_writeback_type {
 	MDSS_MDP_WRITEBACK_TYPE_ROTATOR,
@@ -46,8 +46,6 @@
 
 	struct mdss_mdp_plane_sizes dst_planes;
 
-	void (*callback_fnc) (void *arg);
-	void *callback_arg;
 	spinlock_t wb_lock;
 	struct list_head vsync_handlers;
 };
@@ -365,6 +363,8 @@
 		mdss_mdp_set_intr_callback(ctx->intr_type, ctx->intf_num,
 				NULL, NULL);
 
+		complete_all(&ctx->wb_comp);
+
 		ctl->priv_data = NULL;
 		ctx->ref_cnt--;
 	}
@@ -389,9 +389,6 @@
 
 	mdss_mdp_irq_disable_nosync(ctx->intr_type, ctx->intf_num);
 
-	if (ctx->callback_fnc)
-		ctx->callback_fnc(ctx->callback_arg);
-
 	spin_lock(&ctx->wb_lock);
 	list_for_each_entry(tmp, &ctx->vsync_handlers, list) {
 		tmp->vsync_handler(ctl, vsync_time);
@@ -421,10 +418,12 @@
 		NULL, NULL);
 
 	if (rc == 0) {
+		mdss_mdp_ctl_notify(ctl, MDP_NOTIFY_FRAME_TIMEOUT);
 		rc = -ENODEV;
 		WARN(1, "writeback kickoff timed out (%d) ctl=%d\n",
 						rc, ctl->num);
 	} else {
+		mdss_mdp_ctl_notify(ctl, MDP_NOTIFY_FRAME_DONE);
 		rc = 0;
 	}
 
@@ -465,9 +464,6 @@
 	mdss_mdp_set_intr_callback(ctx->intr_type, ctx->intf_num,
 		   mdss_mdp_writeback_intr_done, ctl);
 
-	ctx->callback_fnc = wb_args->callback_fnc;
-	ctx->callback_arg = wb_args->priv_data;
-
 	flush_bits = BIT(16); /* WB */
 	mdp_wb_write(ctx, MDSS_MDP_REG_WB_DST_ADDR_SW_STATUS, ctl->is_secure);
 	mdss_mdp_ctl_write(ctl, MDSS_MDP_REG_CTL_FLUSH, flush_bits);
@@ -527,6 +523,8 @@
 
 int mdss_mdp_writeback_display_commit(struct mdss_mdp_ctl *ctl, void *arg)
 {
+	int ret = 0;
+
 	if (ctl->shared_lock && !mutex_is_locked(ctl->shared_lock)) {
 		pr_err("shared mutex is not locked before commit on ctl=%d\n",
 			ctl->num);
@@ -540,5 +538,10 @@
 			ctl->mixer_right->params_changed++;
 	}
 
-	return mdss_mdp_display_commit(ctl, arg);
+	ret = mdss_mdp_display_commit(ctl, arg);
+
+	if (!IS_ERR_VALUE(ret))
+		mdss_mdp_display_wait4comp(ctl);
+
+	return ret;
 }
diff --git a/drivers/video/msm/mdss/mdss_mdp_overlay.c b/drivers/video/msm/mdss/mdss_mdp_overlay.c
index cccec93..29cf99d 100644
--- a/drivers/video/msm/mdss/mdss_mdp_overlay.c
+++ b/drivers/video/msm/mdss/mdss_mdp_overlay.c
@@ -282,7 +282,12 @@
 	int rc;
 
 	src = pipe->src.w >> pipe->horz_deci;
-	rc = mdss_mdp_calc_phase_step(src, pipe->dst.w, &pipe->phase_step_x);
+
+	if (pipe->scale.enable_pxl_ext)
+		return 0;
+	memset(&pipe->scale, 0, sizeof(struct mdp_scale_data));
+	rc = mdss_mdp_calc_phase_step(src, pipe->dst.w,
+			&pipe->scale.phase_step_x[0]);
 	if (rc) {
 		pr_err("Horizontal scaling calculation failed=%d! %d->%d\n",
 				rc, src, pipe->dst.w);
@@ -290,16 +295,43 @@
 	}
 
 	src = pipe->src.h >> pipe->vert_deci;
-	rc = mdss_mdp_calc_phase_step(src, pipe->dst.h, &pipe->phase_step_y);
+	rc = mdss_mdp_calc_phase_step(src, pipe->dst.h,
+			&pipe->scale.phase_step_y[0]);
 	if (rc) {
 		pr_err("Vertical scaling calculation failed=%d! %d->%d\n",
 				rc, src, pipe->dst.h);
 		return rc;
 	}
-
+	pipe->scale.init_phase_x[0] = (pipe->scale.phase_step_x[0] -
+					(1 << PHASE_STEP_SHIFT)) / 2;
+	pipe->scale.init_phase_y[0] = (pipe->scale.phase_step_y[0] -
+					(1 << PHASE_STEP_SHIFT)) / 2;
 	return 0;
 }
 
+static inline void __mdss_mdp_overlay_set_chroma_sample(
+	struct mdss_mdp_pipe *pipe)
+{
+	pipe->chroma_sample_v = pipe->chroma_sample_h = 0;
+
+	switch (pipe->src_fmt->chroma_sample) {
+	case MDSS_MDP_CHROMA_H1V2:
+		pipe->chroma_sample_v = 1;
+		break;
+	case MDSS_MDP_CHROMA_H2V1:
+		pipe->chroma_sample_h = 1;
+		break;
+	case MDSS_MDP_CHROMA_420:
+		pipe->chroma_sample_v = 1;
+		pipe->chroma_sample_h = 1;
+		break;
+	}
+	if (pipe->horz_deci)
+		pipe->chroma_sample_h = 0;
+	if (pipe->vert_deci)
+		pipe->chroma_sample_v = 0;
+}
+
 static int mdss_mdp_overlay_pipe_setup(struct msm_fb_data_type *mfd,
 				       struct mdp_overlay *req,
 				       struct mdss_mdp_pipe **ppipe)
@@ -442,7 +474,10 @@
 	pipe->dst.h = req->dst_rect.h;
 	pipe->horz_deci = req->horz_deci;
 	pipe->vert_deci = req->vert_deci;
+
+	memcpy(&pipe->scale, &req->scale, sizeof(struct mdp_scale_data));
 	pipe->src_fmt = fmt;
+	__mdss_mdp_overlay_set_chroma_sample(pipe);
 
 	pipe->mixer_stage = req->z_order;
 	pipe->is_fg = req->is_fg;
@@ -458,8 +493,17 @@
 		pr_debug("Unintended blend_op %d on layer with no alpha plane\n",
 			pipe->blend_op);
 
-	pipe->overfetch_disable = fmt->is_yuv &&
-			!(pipe->flags & MDP_SOURCE_ROTATED_90);
+	if (fmt->is_yuv && !(pipe->flags & MDP_SOURCE_ROTATED_90) &&
+			!pipe->scale.enable_pxl_ext) {
+		pipe->overfetch_disable = OVERFETCH_DISABLE_BOTTOM;
+
+		if (!(pipe->flags & MDSS_MDP_DUAL_PIPE) ||
+				(pipe->flags & MDSS_MDP_RIGHT_MIXER))
+			pipe->overfetch_disable |= OVERFETCH_DISABLE_RIGHT;
+		pr_debug("overfetch flags=%x\n", pipe->overfetch_disable);
+	} else {
+		pipe->overfetch_disable = 0;
+	}
 
 	req->id = pipe->ndx;
 	pipe->req_data = *req;
@@ -516,12 +560,16 @@
 		}
 	}
 
-	if (pipe->flags & MDP_DEINTERLACE) {
+	if ((pipe->flags & MDP_DEINTERLACE) && !pipe->scale.enable_pxl_ext) {
 		if (pipe->flags & MDP_SOURCE_ROTATED_90) {
+			pipe->src.x = DIV_ROUND_UP(pipe->src.x, 2);
+			pipe->src.x &= ~1;
 			pipe->src.w /= 2;
 			pipe->img_width /= 2;
 		} else {
 			pipe->src.h /= 2;
+			pipe->src.y = DIV_ROUND_UP(pipe->src.y, 2);
+			pipe->src.y &= ~1;
 		}
 	}
 
@@ -539,6 +587,12 @@
 		!mdp5_data->mdata->has_wfd_blk)
 		mdss_mdp_smp_release(pipe);
 
+	/*
+	 * Clear previous SMP reservations and reserve according to the
+	 * latest configuration
+	 */
+	mdss_mdp_smp_unreserve(pipe);
+
 	ret = mdss_mdp_smp_reserve(pipe);
 	if (ret) {
 		pr_debug("mdss_mdp_smp_reserve failed. ret=%d\n", ret);
@@ -720,12 +774,60 @@
 		mdss_mdp_pipe_destroy(pipe);
 }
 
+static void __mdss_mdp_handoff_cleanup_pipes(struct msm_fb_data_type *mfd,
+	u32 type)
+{
+	u32 i, npipes;
+	struct mdss_mdp_pipe *pipes;
+	struct mdss_mdp_pipe *pipe;
+	struct mdss_overlay_private *mdp5_data = mfd_to_mdp5_data(mfd);
+	struct mdss_data_type *mdata = mfd_to_mdata(mfd);
+
+	switch (type) {
+	case MDSS_MDP_PIPE_TYPE_VIG:
+		pipes = mdata->vig_pipes;
+		npipes = mdata->nvig_pipes;
+		break;
+	case MDSS_MDP_PIPE_TYPE_RGB:
+		pipes = mdata->rgb_pipes;
+		npipes = mdata->nrgb_pipes;
+		break;
+	case MDSS_MDP_PIPE_TYPE_DMA:
+		pipes = mdata->dma_pipes;
+		npipes = mdata->ndma_pipes;
+		break;
+	default:
+		return;
+	}
+
+	for (i = 0; i < npipes; i++) {
+		pipe = &pipes[i];
+		if (pipe->is_handed_off) {
+			pr_debug("Unmapping handed off pipe %d\n", pipe->num);
+			list_add(&pipe->cleanup_list,
+				&mdp5_data->pipes_cleanup);
+			mdss_mdp_mixer_pipe_unstage(pipe);
+			pipe->is_handed_off = false;
+		}
+	}
+}
+
+/**
+ * mdss_mdp_overlay_start() - Programs the MDP control data path to hardware
+ * @mfd: Msm frame buffer structure associated with fb device.
+ *
+ * Program the MDP hardware with the control settings for the framebuffer
+ * device. In addition to this, this function also handles the transition
+ * from the the splash screen to the android boot animation when the
+ * continuous splash screen feature is enabled.
+ */
 static int mdss_mdp_overlay_start(struct msm_fb_data_type *mfd)
 {
 	int rc;
 	struct mdss_overlay_private *mdp5_data = mfd_to_mdp5_data(mfd);
+	struct mdss_mdp_ctl *ctl = mdp5_data->ctl;
 
-	if (mdp5_data->ctl->power_on) {
+	if (ctl->power_on) {
 		if (!mdp5_data->mdata->batfet)
 			mdss_mdp_batfet_ctrl(mdp5_data->mdata, true);
 		return 0;
@@ -739,24 +841,84 @@
 		return rc;
 	}
 
-	if (mfd->panel_info->cont_splash_enabled) {
-		mdss_mdp_ctl_splash_finish(mdp5_data->ctl);
-		mdss_mdp_footswitch_ctrl_splash(0);
-	}
-
+	/*
+	 * We need to do hw init before any hw programming.
+	 * Also, hw init involves programming the VBIF registers which
+	 * should be done only after attaching IOMMU which in turn would call
+	 * in to TZ to restore security configs on the VBIF registers.
+	 * This is not needed when continuous splash screen is enabled since
+	 * we would have called in to TZ to restore security configs from LK.
+	 */
 	if (!is_mdss_iommu_attached()) {
-		mdss_iommu_attach(mdss_res);
+		if (!mfd->panel_info->cont_splash_enabled)
+			mdss_iommu_attach(mdss_res);
 		mdss_hw_init(mdss_res);
 	}
 
-	rc = mdss_mdp_ctl_start(mdp5_data->ctl);
+	rc = mdss_mdp_ctl_start(ctl);
 	if (rc == 0) {
 		atomic_inc(&ov_active_panels);
-	} else {
-		pr_err("overlay start failed.\n");
-		mdss_mdp_ctl_destroy(mdp5_data->ctl);
-		mdp5_data->ctl = NULL;
 
+		mdss_mdp_ctl_notifier_register(mdp5_data->ctl,
+				&mfd->mdp_sync_pt_data.notifier);
+	} else {
+		pr_err("mdp ctl start failed.\n");
+		goto error;
+	}
+
+	if (mfd->panel_info->cont_splash_enabled) {
+		if (mdp5_data->handoff) {
+			/*
+			 * Set up border-fill on the handed off pipes.
+			 * This is needed to ensure that there are no memory
+			 * accesses prior to attaching iommu during continuous
+			 * splash screen case. However, for command mode
+			 * displays, this is not necessary since the panels can
+			 * refresh from their internal memory if no data is sent
+			 * out on the dsi lanes.
+			 */
+			if (ctl && ctl->is_video_mode) {
+				rc = mdss_mdp_display_commit(ctl, NULL);
+				if (!IS_ERR_VALUE(rc)) {
+					mdss_mdp_display_wait4comp(ctl);
+				} else {
+					/*
+					 * Since border-fill setup failed, we
+					 * need to ensure that we turn off the
+					 * MDP timing generator before attaching
+					 * iommu
+					 */
+					pr_err("failed to set BF at handoff\n");
+					mdp5_data->handoff = false;
+					rc = 0;
+				}
+			}
+
+			/* Add all the handed off pipes to the cleanup list */
+			__mdss_mdp_handoff_cleanup_pipes(mfd,
+				MDSS_MDP_PIPE_TYPE_RGB);
+			__mdss_mdp_handoff_cleanup_pipes(mfd,
+				MDSS_MDP_PIPE_TYPE_VIG);
+			__mdss_mdp_handoff_cleanup_pipes(mfd,
+				MDSS_MDP_PIPE_TYPE_DMA);
+		}
+		rc = mdss_mdp_ctl_splash_finish(ctl, mdp5_data->handoff);
+		/*
+		 * Remove the vote for footswitch even if above function
+		 * returned error
+		 */
+		mdss_mdp_footswitch_ctrl_splash(0);
+		if (rc)
+			goto error;
+
+		if (!is_mdss_iommu_attached())
+			mdss_iommu_attach(mdss_res);
+	}
+
+error:
+	if (rc) {
+		mdss_mdp_ctl_destroy(ctl);
+		mdp5_data->ctl = NULL;
 		pm_runtime_put(&mfd->pdev->dev);
 	}
 
@@ -783,7 +945,7 @@
 	struct mdss_mdp_pipe *pipe;
 	struct mdss_mdp_ctl *ctl = mfd_to_ctl(mfd);
 	struct mdss_mdp_ctl *tmp;
-	int ret;
+	int ret = 0;
 	int sd_in_pipe = 0;
 
 	if (ctl->shared_lock)
@@ -792,14 +954,6 @@
 	mutex_lock(&mdp5_data->ov_lock);
 	mutex_lock(&mfd->lock);
 
-	ret = mdss_mdp_display_wait4pingpong(mdp5_data->ctl);
-	if (ret) {
-		mutex_unlock(&mfd->lock);
-		mutex_unlock(&mdp5_data->ov_lock);
-		if (ctl->shared_lock)
-			mutex_unlock(ctl->shared_lock);
-		return ret;
-	}
 	/*
 	 * check if there is a secure display session
 	 */
@@ -819,6 +973,9 @@
 			mdp5_data->sd_enabled = 0;
 	}
 
+	mdss_mdp_ctl_notify(ctl, MDP_NOTIFY_FRAME_BEGIN);
+	mdss_mdp_clk_ctrl(MDP_BLOCK_POWER_ON, false);
+
 	if (data)
 		mdss_mdp_set_roi(ctl, data);
 
@@ -913,6 +1070,8 @@
 	mdss_fb_update_notify_update(mfd);
 commit_fail:
 	mdss_mdp_overlay_cleanup(mfd);
+	mdss_mdp_clk_ctrl(MDP_BLOCK_POWER_OFF, false);
+	mdss_mdp_ctl_notify(ctl, MDP_NOTIFY_FRAME_FLUSHED);
 
 	mutex_unlock(&mdp5_data->ov_lock);
 	if (ctl->shared_lock)
@@ -998,11 +1157,13 @@
 /**
  * mdss_mdp_overlay_release_all() - release any overlays associated with fb dev
  * @mfd:	Msm frame buffer structure associated with fb device
+ * @release_all: ignore pid and release all the pipes
  *
  * Release any resources allocated by calling process, this can be called
  * on fb_release to release any overlays/rotator sessions left open.
  */
-static int __mdss_mdp_overlay_release_all(struct msm_fb_data_type *mfd)
+static int __mdss_mdp_overlay_release_all(struct msm_fb_data_type *mfd,
+	bool release_all)
 {
 	struct mdss_mdp_pipe *pipe;
 	struct mdss_mdp_rotator_session *rot, *tmp;
@@ -1016,7 +1177,7 @@
 	mutex_lock(&mdp5_data->ov_lock);
 	mutex_lock(&mfd->lock);
 	list_for_each_entry(pipe, &mdp5_data->pipes_used, used_list) {
-		if (!mfd->ref_cnt || (pipe->pid == pid)) {
+		if (release_all || (pipe->pid == pid)) {
 			unset_ndx |= pipe->ndx;
 			cnt++;
 		}
@@ -1028,6 +1189,9 @@
 		cnt++;
 	}
 
+	pr_debug("release_all=%d mfd->ref_cnt=%d unset_ndx=0x%x cnt=%d\n",
+		release_all, mfd->ref_cnt, unset_ndx, cnt);
+
 	mutex_unlock(&mfd->lock);
 
 	if (unset_ndx) {
@@ -1370,15 +1534,26 @@
 static void mdss_mdp_overlay_handle_vsync(struct mdss_mdp_ctl *ctl,
 						ktime_t t)
 {
-	struct msm_fb_data_type *mfd = ctl->mfd;
-	struct mdss_overlay_private *mdp5_data;
+	struct msm_fb_data_type *mfd = NULL;
+	struct mdss_overlay_private *mdp5_data = NULL;
 
+	if (!ctl) {
+		pr_err("ctl is NULL\n");
+		return;
+	}
+
+	mfd = ctl->mfd;
 	if (!mfd || !mfd->mdp.private1) {
 		pr_warn("Invalid handle for vsync\n");
 		return;
 	}
 
 	mdp5_data = mfd_to_mdp5_data(mfd);
+	if (!mdp5_data) {
+		pr_err("mdp5_data is NULL\n");
+		return;
+	}
+
 	pr_debug("vsync on fb%d play_cnt=%d\n", mfd->index, ctl->play_cnt);
 
 	mdp5_data->vsync_time = t;
@@ -2000,7 +2175,7 @@
 					  u32 cmd, void __user *argp)
 {
 	struct mdss_overlay_private *mdp5_data = mfd_to_mdp5_data(mfd);
-	struct mdp_overlay req;
+	struct mdp_overlay *req = NULL;
 	int val, ret = -ENOSYS;
 	struct msmfb_metadata metadata;
 
@@ -2016,12 +2191,15 @@
 		break;
 
 	case MSMFB_OVERLAY_GET:
-		ret = copy_from_user(&req, argp, sizeof(req));
+		req = kmalloc(sizeof(struct mdp_overlay), GFP_KERNEL);
+		if (!req)
+			return -ENOMEM;
+		ret = copy_from_user(req, argp, sizeof(*req));
 		if (!ret) {
-			ret = mdss_mdp_overlay_get(mfd, &req);
+			ret = mdss_mdp_overlay_get(mfd, req);
 
 			if (!IS_ERR_VALUE(ret))
-				ret = copy_to_user(argp, &req, sizeof(req));
+				ret = copy_to_user(argp, req, sizeof(*req));
 		}
 
 		if (ret)
@@ -2029,12 +2207,15 @@
 		break;
 
 	case MSMFB_OVERLAY_SET:
-		ret = copy_from_user(&req, argp, sizeof(req));
+		req = kmalloc(sizeof(struct mdp_overlay), GFP_KERNEL);
+		if (!req)
+			return -ENOMEM;
+		ret = copy_from_user(req, argp, sizeof(*req));
 		if (!ret) {
-			ret = mdss_mdp_overlay_set(mfd, &req);
+			ret = mdss_mdp_overlay_set(mfd, req);
 
 			if (!IS_ERR_VALUE(ret))
-				ret = copy_to_user(argp, &req, sizeof(req));
+				ret = copy_to_user(argp, req, sizeof(*req));
 		}
 		if (ret)
 			pr_debug("OVERLAY_SET failed (%d)\n", ret);
@@ -2098,7 +2279,6 @@
 	case MSMFB_OVERLAY_COMMIT:
 		mdss_fb_wait_for_fence(&(mfd->mdp_sync_pt_data));
 		ret = mfd->mdp.kickoff_fnc(mfd, NULL);
-		mdss_fb_signal_timeline(&(mfd->mdp_sync_pt_data));
 		break;
 	case MSMFB_METADATA_SET:
 		ret = copy_from_user(&metadata, argp, sizeof(metadata));
@@ -2120,13 +2300,70 @@
 		break;
 	}
 
+	kfree(req);
 	return ret;
 }
 
+/**
+ * __mdss_mdp_overlay_ctl_init - Helper function to intialize control structure
+ * @mfd: msm frame buffer data structure associated with the fb device.
+ *
+ * Helper function that allocates and initializes the mdp control structure
+ * for a frame buffer device. Whenver applicable, this function will also setup
+ * the control for the split display path as well.
+ *
+ * Return: pointer to the newly allocated control structure.
+ */
+static struct mdss_mdp_ctl *__mdss_mdp_overlay_ctl_init(
+	struct msm_fb_data_type *mfd)
+{
+	int rc = 0;
+	struct mdss_mdp_ctl *ctl;
+	struct mdss_panel_data *pdata;
+
+	if (!mfd)
+		return ERR_PTR(-EINVAL);
+
+	pdata = dev_get_platdata(&mfd->pdev->dev);
+	if (!pdata) {
+		pr_err("no panel connected for fb%d\n", mfd->index);
+		rc = -ENODEV;
+		goto error;
+	}
+
+	ctl = mdss_mdp_ctl_init(pdata, mfd);
+	if (IS_ERR_OR_NULL(ctl)) {
+		pr_err("Unable to initialize ctl for fb%d\n",
+			mfd->index);
+		rc = PTR_ERR(ctl);
+		goto error;
+	}
+	ctl->vsync_handler.vsync_handler =
+					mdss_mdp_overlay_handle_vsync;
+	ctl->vsync_handler.cmd_post_flush = false;
+
+	if (mfd->split_display && pdata->next) {
+		/* enable split display */
+		rc = mdss_mdp_ctl_split_display_setup(ctl, pdata->next);
+		if (rc) {
+			mdss_mdp_ctl_destroy(ctl);
+			goto error;
+		}
+	}
+
+error:
+	if (rc)
+		return ERR_PTR(rc);
+	else
+		return ctl;
+}
+
 static int mdss_mdp_overlay_on(struct msm_fb_data_type *mfd)
 {
 	int rc;
 	struct mdss_overlay_private *mdp5_data;
+	struct mdss_mdp_ctl *ctl = NULL;
+
 	if (!mfd)
 		return -ENODEV;
 
@@ -2138,33 +2375,9 @@
 		return -EINVAL;
 
 	if (!mdp5_data->ctl) {
-		struct mdss_mdp_ctl *ctl;
-		struct mdss_panel_data *pdata;
-
-		pdata = dev_get_platdata(&mfd->pdev->dev);
-		if (!pdata) {
-			pr_err("no panel connected for fb%d\n", mfd->index);
-			return -ENODEV;
-		}
-
-		ctl = mdss_mdp_ctl_init(pdata, mfd);
-		if (IS_ERR_OR_NULL(ctl)) {
-			pr_err("Unable to initialize ctl for fb%d\n",
-				mfd->index);
+		ctl = __mdss_mdp_overlay_ctl_init(mfd);
+		if (IS_ERR_OR_NULL(ctl))
 			return PTR_ERR(ctl);
-		}
-		ctl->vsync_handler.vsync_handler =
-						mdss_mdp_overlay_handle_vsync;
-		ctl->vsync_handler.cmd_post_flush = false;
-
-		if (mfd->split_display && pdata->next) {
-			/* enable split display */
-			rc = mdss_mdp_ctl_split_display_setup(ctl, pdata->next);
-			if (rc) {
-				mdss_mdp_ctl_destroy(ctl);
-				return rc;
-			}
-		}
 		mdp5_data->ctl = ctl;
 	}
 
@@ -2232,6 +2445,8 @@
 	rc = mdss_mdp_ctl_stop(mdp5_data->ctl);
 	if (rc == 0) {
 		__mdss_mdp_overlay_free_list_purge(mfd);
+		mdss_mdp_ctl_notifier_unregister(mdp5_data->ctl,
+				&mfd->mdp_sync_pt_data.notifier);
 
 		if (!mfd->ref_cnt) {
 			mdp5_data->borderfill_enable = false;
@@ -2263,6 +2478,96 @@
 	return 0;
 }
 
+/**
+ * mdss_mdp_overlay_handoff() - Read MDP registers to handoff an active ctl path
+ * @mfd: Msm frame buffer structure associated with the fb device.
+ *
+ * This function populates the MDP software structures with the current state of
+ * the MDP hardware to handoff any active control path for the framebuffer
+ * device. This is needed to identify any ctl, mixers and pipes being set up by
+ * the bootloader to display the splash screen when the continuous splash screen
+ * feature is enabled in kernel.
+ */
+static int mdss_mdp_overlay_handoff(struct msm_fb_data_type *mfd)
+{
+	int rc = 0;
+	struct mdss_data_type *mdata = mfd_to_mdata(mfd);
+	struct mdss_overlay_private *mdp5_data = mfd_to_mdp5_data(mfd);
+	int i, j;
+	u32 reg;
+	struct mdss_mdp_pipe *pipe = NULL;
+	struct mdss_mdp_ctl *ctl = NULL;
+
+	if (!mdp5_data->ctl) {
+		ctl = __mdss_mdp_overlay_ctl_init(mfd);
+		if (IS_ERR_OR_NULL(ctl)) {
+			rc = PTR_ERR(ctl);
+			goto error;
+		}
+		mdp5_data->ctl = ctl;
+	}
+
+	rc = mdss_mdp_ctl_setup(ctl);
+	if (rc)
+		goto error;
+
+	ctl->clk_rate = mdss_mdp_get_clk_rate(MDSS_CLK_MDP_SRC);
+	pr_debug("Set the ctl clock rate to %d Hz\n", ctl->clk_rate);
+
+	for (i = 0; i < mdata->nmixers_intf; i++) {
+		reg = mdss_mdp_ctl_read(ctl, MDSS_MDP_REG_CTL_LAYER(i));
+		pr_debug("for lm%d reg = 0x%09x\n", i, reg);
+		for (j = MDSS_MDP_SSPP_VIG0; j < MDSS_MDP_MAX_SSPP; j++) {
+			u32 cfg = j * 3;
+			if ((j == MDSS_MDP_SSPP_VIG3) ||
+				(j == MDSS_MDP_SSPP_RGB3)) {
+				/* Add 2 to account for Cursor & Border bits */
+				cfg += 2;
+			}
+			if (reg & (0x7 << cfg)) {
+				pr_debug("Pipe %d staged\n", j);
+				pipe = mdss_mdp_pipe_search(mdata, BIT(j));
+				if (!pipe) {
+					pr_warn("Invalid pipe %d staged\n", j);
+					continue;
+				}
+
+				rc = mdss_mdp_pipe_handoff(pipe);
+				if (rc) {
+					pr_err("Failed to handoff pipe num %d\n"
+						, pipe->num);
+					goto error;
+				}
+
+				rc = mdss_mdp_mixer_handoff(ctl, i, pipe);
+				if (rc) {
+					pr_err("failed to handoff mixer num %d\n"
+						, i);
+					goto error;
+				}
+			}
+		}
+	}
+
+	rc = mdss_mdp_smp_handoff(mdata);
+	if (rc)
+		pr_err("Failed to handoff smps\n");
+
+	mdp5_data->handoff = true;
+
+error:
+	if (rc && ctl) {
+		__mdss_mdp_handoff_cleanup_pipes(mfd, MDSS_MDP_PIPE_TYPE_RGB);
+		__mdss_mdp_handoff_cleanup_pipes(mfd, MDSS_MDP_PIPE_TYPE_VIG);
+		__mdss_mdp_handoff_cleanup_pipes(mfd, MDSS_MDP_PIPE_TYPE_DMA);
+		mdss_mdp_ctl_destroy(ctl);
+		mdp5_data->ctl = NULL;
+		mdp5_data->handoff = false;
+	}
+
+	return rc;
+}
+
 int mdss_mdp_overlay_init(struct msm_fb_data_type *mfd)
 {
 	struct device *dev = mfd->fbi->dev;
@@ -2329,6 +2634,7 @@
 			goto init_fail;
 		}
 	}
+	mfd->mdp_sync_pt_data.async_wait_fences = true;
 
 	pm_runtime_set_suspended(&mfd->pdev->dev);
 	pm_runtime_enable(&mfd->pdev->dev);
@@ -2340,6 +2646,21 @@
 	if (!mdp5_data->cpu_pm_hdl)
 		pr_warn("%s: unable to add event timer\n", __func__);
 
+	if (mfd->panel_info->cont_splash_enabled) {
+		rc = mdss_mdp_overlay_handoff(mfd);
+		if (rc) {
+			/*
+			 * Even though handoff failed, it is not fatal.
+			 * MDP can continue, just that we would have a longer
+			 * delay in transitioning from splash screen to boot
+			 * animation
+			 */
+			pr_warn("Overlay handoff failed for fb%d. rc=%d\n",
+				mfd->index, rc);
+			rc = 0;
+		}
+	}
+
 	return rc;
 init_fail:
 	kfree(mdp5_data);
diff --git a/drivers/video/msm/mdss/mdss_mdp_pipe.c b/drivers/video/msm/mdss/mdss_mdp_pipe.c
index c18fd9b..25cb9dd 100644
--- a/drivers/video/msm/mdss/mdss_mdp_pipe.c
+++ b/drivers/video/msm/mdss/mdss_mdp_pipe.c
@@ -27,10 +27,10 @@
 
 static DEFINE_MUTEX(mdss_mdp_sspp_lock);
 static DEFINE_MUTEX(mdss_mdp_smp_lock);
-static DECLARE_BITMAP(mdss_mdp_smp_mmb_pool, MDSS_MDP_SMP_MMB_BLOCKS);
 
 static int mdss_mdp_pipe_free(struct mdss_mdp_pipe *pipe);
-static int __mdss_mdp_pipe_smp_mmb_is_empty(unsigned long *smp);
+static struct mdss_mdp_pipe *mdss_mdp_pipe_search_by_client_id(
+	struct mdss_data_type *mdata, int client_id);
 
 static inline void mdss_mdp_pipe_write(struct mdss_mdp_pipe *pipe,
 				       u32 reg, u32 val)
@@ -43,21 +43,29 @@
 	return readl_relaxed(pipe->base + reg);
 }
 
-static u32 mdss_mdp_smp_mmb_reserve(unsigned long *existing,
-	unsigned long *reserve, size_t n)
+static u32 mdss_mdp_smp_mmb_reserve(struct mdss_mdp_pipe_smp_map *smp_map,
+	size_t n)
 {
 	u32 i, mmb;
+	u32 fixed_cnt = bitmap_weight(smp_map->fixed, SMP_MB_CNT);
+	struct mdss_data_type *mdata = mdss_mdp_get_mdata();
+
+	if (n <= fixed_cnt)
+		return fixed_cnt;
+	else
+		n -= fixed_cnt;
 
 	/* reserve more blocks if needed, but can't free mmb at this point */
-	for (i = bitmap_weight(existing, SMP_MB_CNT); i < n; i++) {
-		if (bitmap_full(mdss_mdp_smp_mmb_pool, SMP_MB_CNT))
+	for (i = bitmap_weight(smp_map->allocated, SMP_MB_CNT); i < n; i++) {
+		if (bitmap_full(mdata->mmb_alloc_map, SMP_MB_CNT))
 			break;
 
-		mmb = find_first_zero_bit(mdss_mdp_smp_mmb_pool, SMP_MB_CNT);
-		set_bit(mmb, reserve);
-		set_bit(mmb, mdss_mdp_smp_mmb_pool);
+		mmb = find_first_zero_bit(mdata->mmb_alloc_map, SMP_MB_CNT);
+		set_bit(mmb, smp_map->reserved);
+		set_bit(mmb, mdata->mmb_alloc_map);
 	}
-	return i;
+
+	return i + fixed_cnt;
 }
 
 static int mdss_mdp_smp_mmb_set(int client_id, unsigned long *smp)
@@ -86,20 +94,17 @@
 
 static void mdss_mdp_smp_mmb_free(unsigned long *smp, bool write)
 {
+	struct mdss_data_type *mdata = mdss_mdp_get_mdata();
+
 	if (!bitmap_empty(smp, SMP_MB_CNT)) {
 		if (write)
 			mdss_mdp_smp_mmb_set(0, smp);
-		bitmap_andnot(mdss_mdp_smp_mmb_pool, mdss_mdp_smp_mmb_pool,
+		bitmap_andnot(mdata->mmb_alloc_map, mdata->mmb_alloc_map,
 			      smp, SMP_MB_CNT);
 		bitmap_zero(smp, SMP_MB_CNT);
 	}
 }
 
-static int __mdss_mdp_pipe_smp_mmb_is_empty(unsigned long *smp)
-{
-	return bitmap_weight(smp, SMP_MB_CNT) == 0;
-}
-
 static void mdss_mdp_smp_set_wm_levels(struct mdss_mdp_pipe *pipe, int mb_cnt)
 {
 	u32 fetch_size, val, wm[3];
@@ -229,8 +234,8 @@
 
 		pr_debug("reserving %d mmb for pnum=%d plane=%d\n",
 				num_blks, pipe->num, i);
-		reserved = mdss_mdp_smp_mmb_reserve(pipe->smp_map[i].allocated,
-			pipe->smp_map[i].reserved, num_blks);
+		reserved = mdss_mdp_smp_mmb_reserve(&pipe->smp_map[i],
+			num_blks);
 		if (reserved < num_blks)
 			break;
 	}
@@ -246,7 +251,21 @@
 
 	return rc;
 }
-
+/*
+ * mdss_mdp_smp_alloc() -- set smp mmb and and wm levels for a staged pipe
+ * @pipe: pointer to a pipe
+ *
+ * Function amends reserved smp mmbs to allocated bitmap and ties respective
+ * mmbs to their pipe fetch_ids. Based on the number of total allocated mmbs
+ * for a staged pipe, it also sets the watermark levels (wm).
+ *
+ * This function will be called on every commit where pipe params might not
+ * have changed. In such cases, we need to ensure that wm levels are not
+ * wiped out. Also in some rare situations hw might have reset and wiped out
+ * smp mmb programming but new smp reservation is not done. In such cases we
+ * need to ensure that for a staged pipes, mmbs are set properly based on
+ * allocated bitmap.
+ */
 static int mdss_mdp_smp_alloc(struct mdss_mdp_pipe *pipe)
 {
 	int i;
@@ -254,8 +273,14 @@
 
 	mutex_lock(&mdss_mdp_smp_lock);
 	for (i = 0; i < MAX_PLANES; i++) {
-		if (__mdss_mdp_pipe_smp_mmb_is_empty(pipe->smp_map[i].reserved))
+		cnt += bitmap_weight(pipe->smp_map[i].fixed, SMP_MB_CNT);
+
+		if (bitmap_empty(pipe->smp_map[i].reserved, SMP_MB_CNT)) {
+			cnt += mdss_mdp_smp_mmb_set(pipe->ftch_id + i,
+				pipe->smp_map[i].allocated);
 			continue;
+		}
+
 		mdss_mdp_smp_mmb_amend(pipe->smp_map[i].allocated,
 			pipe->smp_map[i].reserved);
 		cnt += mdss_mdp_smp_mmb_set(pipe->ftch_id + i,
@@ -284,6 +309,80 @@
 	return 0;
 }
 
+/**
+ * mdss_mdp_smp_handoff() - Handoff SMP MMBs in use by staged pipes
+ * @mdata: pointer to the global mdss data structure.
+ *
+ * Iterate through the list of all SMP MMBs and check to see if any
+ * of them are assigned to a pipe being marked as being handed-off.
+ * If so, update the corresponding software allocation map to reflect
+ * this.
+ *
+ * This function would typically be called during MDP probe for the case
+ * when certain pipes might be programmed in the bootloader to display
+ * the splash screen.
+ */
+int mdss_mdp_smp_handoff(struct mdss_data_type *mdata)
+{
+	int rc = 0;
+	int i, client_id, prev_id = 0;
+	u32 off, s, data;
+	struct mdss_mdp_pipe *pipe = NULL;
+
+	/*
+	 * figure out what SMP MMBs are allocated for each of the pipes
+	 * that need to be handed off.
+	 */
+	for (i = 0; i < SMP_MB_CNT; i++) {
+		off = (i / 3) * 4;
+		s = (i % 3) * 8;
+		data = MDSS_MDP_REG_READ(MDSS_MDP_REG_SMP_ALLOC_W0 + off);
+		client_id = (data >> s) & 0xFF;
+		if (test_bit(i, mdata->mmb_alloc_map)) {
+			/*
+			 * Certain pipes may have a dedicated set of
+			 * SMP MMBs statically allocated to them. In
+			 * such cases, we do not need to do anything
+			 * here.
+			 */
+			pr_debug("smp mmb %d already assigned to pipe %d (client_id %d)"
+				, i, pipe->num, client_id);
+			continue;
+		}
+
+		if (client_id) {
+			if (client_id != prev_id) {
+				pipe = mdss_mdp_pipe_search_by_client_id(mdata,
+					client_id);
+				prev_id = client_id;
+			}
+
+			if (!pipe) {
+				pr_warn("Invalid client id %d for SMP MMB %d\n",
+					client_id, i);
+				continue;
+			}
+
+			if (!pipe->is_handed_off) {
+				pr_warn("SMP MMB %d assigned to a pipe not marked for handoff (client id %d)"
+					, i, client_id);
+				continue;
+			}
+
+			/*
+			 * Assume that the source format only has
+			 * one plane
+			 */
+			pr_debug("Assigning smp mmb %d to pipe %d (client_id %d)\n"
+				, i, pipe->num, client_id);
+			set_bit(i, pipe->smp_map[0].allocated);
+			set_bit(i, mdata->mmb_alloc_map);
+		}
+	}
+
+	return rc;
+}
+
 void mdss_mdp_pipe_unmap(struct mdss_mdp_pipe *pipe)
 {
 	int tmp;
@@ -427,6 +526,29 @@
 	return pipe;
 }
 
+static struct mdss_mdp_pipe *mdss_mdp_pipe_search_by_client_id(
+	struct mdss_data_type *mdata, int client_id)
+{
+	u32 i;
+
+	for (i = 0; i < mdata->nrgb_pipes; i++) {
+		if (mdata->rgb_pipes[i].ftch_id == client_id)
+			return &mdata->rgb_pipes[i];
+	}
+
+	for (i = 0; i < mdata->nvig_pipes; i++) {
+		if (mdata->vig_pipes[i].ftch_id == client_id)
+			return &mdata->vig_pipes[i];
+	}
+
+	for (i = 0; i < mdata->ndma_pipes; i++) {
+		if (mdata->dma_pipes[i].ftch_id == client_id)
+			return &mdata->dma_pipes[i];
+	}
+
+	return NULL;
+}
+
 struct mdss_mdp_pipe *mdss_mdp_pipe_search(struct mdss_data_type *mdata,
 						  u32 ndx)
 {
@@ -459,6 +581,8 @@
 	mdss_mdp_smp_free(pipe);
 	pipe->flags = 0;
 	pipe->bwc_mode = 0;
+	memset(&pipe->scale, 0, sizeof(struct mdp_scale_data));
+
 	mdss_mdp_clk_ctrl(MDP_BLOCK_POWER_OFF, false);
 
 	return 0;
@@ -481,6 +605,67 @@
 
 }
 
+/**
+ * mdss_mdp_pipe_handoff() - Handoff staged pipes during bootup
+ * @pipe: pointer to the pipe to be handed-off
+ *
+ * Populate the software structures for the pipe based on the current
+ * configuration of the hardware pipe by the reading the appropriate MDP
+ * registers.
+ *
+ * This function would typically be called during MDP probe for the case
+ * when certain pipes might be programmed in the bootloader to display
+ * the splash screen.
+ */
+int mdss_mdp_pipe_handoff(struct mdss_mdp_pipe *pipe)
+{
+	int rc = 0;
+	u32 src_fmt, reg = 0, bpp = 0;
+
+	/*
+	 * todo: for now, only reading pipe src and dest size details
+	 * from the registers. This is needed for appropriately
+	 * calculating perf metrics for the handed off pipes.
+	 * We may need to parse some more details at a later date.
+	 */
+	reg = mdss_mdp_pipe_read(pipe, MDSS_MDP_REG_SSPP_SRC_SIZE);
+	pipe->src.h = reg >> 16;
+	pipe->src.w = reg & 0xFFFF;
+	reg = mdss_mdp_pipe_read(pipe, MDSS_MDP_REG_SSPP_OUT_SIZE);
+	pipe->dst.h = reg >> 16;
+	pipe->dst.w = reg & 0xFFFF;
+
+	/* Assume that the source format is RGB */
+	reg = mdss_mdp_pipe_read(pipe, MDSS_MDP_REG_SSPP_SRC_FORMAT);
+	bpp = ((reg >> 9) & 0x3) + 1;
+	switch (bpp) {
+	case 4:
+		src_fmt = MDP_RGBA_8888;
+		break;
+	case 3:
+		src_fmt = MDP_RGB_888;
+		break;
+	case 2:
+		src_fmt = MDP_RGB_565;
+		break;
+	default:
+		pr_err("Invalid bpp=%d found\n", bpp);
+		rc = -EINVAL;
+		goto error;
+	}
+	pipe->src_fmt = mdss_mdp_get_format_params(src_fmt);
+
+	pr_debug("Pipe settings: src.h=%d src.w=%d dst.h=%d dst.w=%d bpp=%d\n"
+		, pipe->src.h, pipe->src.w, pipe->dst.h, pipe->dst.w,
+		pipe->src_fmt->bpp);
+
+	pipe->is_handed_off = true;
+	atomic_inc(&pipe->ref_cnt);
+
+error:
+	return rc;
+}
+
 void mdss_mdp_crop_rect(struct mdss_mdp_img_rect *src_rect,
 	struct mdss_mdp_img_rect *dst_rect,
 	const struct mdss_mdp_img_rect *sci_rect)
@@ -545,24 +730,43 @@
 	dst = pipe->dst;
 	src = pipe->src;
 
-	mdss_mdp_crop_rect(&src, &dst, &sci);
+	if (pipe->mixer->type == MDSS_MDP_MIXER_TYPE_INTF)
+		mdss_mdp_crop_rect(&src, &dst, &sci);
 
 	src_size = (src.h << 16) | src.w;
 	src_xy = (src.y << 16) | src.x;
 	dst_size = (dst.h << 16) | dst.w;
 	dst_xy = (dst.y << 16) | dst.x;
 
-	img_size = (height << 16) | width;
-
 	ystride0 =  (pipe->src_planes.ystride[0]) |
 			(pipe->src_planes.ystride[1] << 16);
 	ystride1 =  (pipe->src_planes.ystride[2]) |
 			(pipe->src_planes.ystride[3] << 16);
 
-	if (pipe->overfetch_disable) {
-		img_size = src_size;
-		src_xy = 0;
+	/*
+	 * Software overfetch is used when scalar pixel extension is
+	 * not enabled
+	 */
+	if (pipe->overfetch_disable && !pipe->scale.enable_pxl_ext) {
+		if (pipe->overfetch_disable & OVERFETCH_DISABLE_BOTTOM) {
+			height = pipe->src.h;
+			if (!(pipe->overfetch_disable & OVERFETCH_DISABLE_TOP))
+				height += pipe->src.y;
+		}
+		if (pipe->overfetch_disable & OVERFETCH_DISABLE_RIGHT) {
+			width = pipe->src.w;
+			if (!(pipe->overfetch_disable & OVERFETCH_DISABLE_LEFT))
+				width += pipe->src.x;
+		}
+		if (pipe->overfetch_disable & OVERFETCH_DISABLE_LEFT)
+			src_xy &= ~0xFFFF;
+		if (pipe->overfetch_disable & OVERFETCH_DISABLE_TOP)
+			src_xy &= ~(0xFFFF << 16);
+
+		pr_debug("overfetch w=%d/%d h=%d/%d src_xy=0x%08x\n", width,
+			pipe->img_width, height, pipe->img_height, src_xy);
 	}
+	img_size = (height << 16) | width;
 
 	mdss_mdp_pipe_write(pipe, MDSS_MDP_REG_SSPP_SRC_IMG_SIZE, img_size);
 	mdss_mdp_pipe_write(pipe, MDSS_MDP_REG_SSPP_SRC_SIZE, src_size);
@@ -629,6 +833,9 @@
 
 	mdss_mdp_pipe_sspp_setup(pipe, &opmode);
 
+	if (pipe->scale.enable_pxl_ext)
+		opmode |= (1 << 31);
+
 	mdss_mdp_pipe_write(pipe, MDSS_MDP_REG_SSPP_SRC_FORMAT, src_format);
 	mdss_mdp_pipe_write(pipe, MDSS_MDP_REG_SSPP_SRC_UNPACK_PATTERN, unpack);
 	mdss_mdp_pipe_write(pipe, MDSS_MDP_REG_SSPP_SRC_OP_MODE, opmode);
@@ -660,33 +867,42 @@
 }
 
 static int mdss_mdp_src_addr_setup(struct mdss_mdp_pipe *pipe,
-				   struct mdss_mdp_data *data)
+				   struct mdss_mdp_data *src_data)
 {
 	struct mdss_data_type *mdata = mdss_mdp_get_mdata();
+	struct mdss_mdp_data data = *src_data;
 	int ret = 0;
 
 	pr_debug("pnum=%d\n", pipe->num);
 
-	data->bwc_enabled = pipe->bwc_mode;
+	data.bwc_enabled = pipe->bwc_mode;
 
-	ret = mdss_mdp_data_check(data, &pipe->src_planes);
+	ret = mdss_mdp_data_check(&data, &pipe->src_planes);
 	if (ret)
 		return ret;
 
-	if (pipe->overfetch_disable)
-		mdss_mdp_data_calc_offset(data, pipe->src.x, pipe->src.y,
+	if (pipe->overfetch_disable && !pipe->scale.enable_pxl_ext) {
+		u32 x = 0, y = 0;
+
+		if (pipe->overfetch_disable & OVERFETCH_DISABLE_LEFT)
+			x = pipe->src.x;
+		if (pipe->overfetch_disable & OVERFETCH_DISABLE_TOP)
+			y = pipe->src.y;
+
+		mdss_mdp_data_calc_offset(&data, x, y,
 			&pipe->src_planes, pipe->src_fmt);
+	}
 
 	/* planar format expects YCbCr, swap chroma planes if YCrCb */
 	if (mdata->mdp_rev < MDSS_MDP_HW_REV_102 &&
 			(pipe->src_fmt->fetch_planes == MDSS_MDP_PLANE_PLANAR)
 				&& (pipe->src_fmt->element[0] == C1_B_Cb))
-		swap(data->p[1].addr, data->p[2].addr);
+		swap(data.p[1].addr, data.p[2].addr);
 
-	mdss_mdp_pipe_write(pipe, MDSS_MDP_REG_SSPP_SRC0_ADDR, data->p[0].addr);
-	mdss_mdp_pipe_write(pipe, MDSS_MDP_REG_SSPP_SRC1_ADDR, data->p[1].addr);
-	mdss_mdp_pipe_write(pipe, MDSS_MDP_REG_SSPP_SRC2_ADDR, data->p[2].addr);
-	mdss_mdp_pipe_write(pipe, MDSS_MDP_REG_SSPP_SRC3_ADDR, data->p[3].addr);
+	mdss_mdp_pipe_write(pipe, MDSS_MDP_REG_SSPP_SRC0_ADDR, data.p[0].addr);
+	mdss_mdp_pipe_write(pipe, MDSS_MDP_REG_SSPP_SRC1_ADDR, data.p[1].addr);
+	mdss_mdp_pipe_write(pipe, MDSS_MDP_REG_SSPP_SRC2_ADDR, data.p[2].addr);
+	mdss_mdp_pipe_write(pipe, MDSS_MDP_REG_SSPP_SRC3_ADDR, data.p[3].addr);
 
 	return 0;
 }
@@ -717,8 +933,9 @@
 			     struct mdss_mdp_data *src_data)
 {
 	int ret = 0;
-	u32 params_changed, opmode;
 	struct mdss_mdp_ctl *ctl;
+	u32 params_changed;
+	u32 opmode = 0;
 
 	if (!pipe) {
 		pr_err("pipe not setup properly for queue\n");
@@ -799,3 +1016,53 @@
 {
 	return (pipe == pipe->mixer->stage_pipe[pipe->mixer_stage]);
 }
+
+static inline void __mdss_mdp_pipe_program_pixel_extn_helper(
+	struct mdss_mdp_pipe *pipe, u32 plane, u32 off)
+{
+	u32 src_h = pipe->src.h >> pipe->vert_deci;
+	u32 mask = 0xFF;
+
+	/*
+	 * CB CR plane required pxls need to be accounted
+	 * for chroma decimation.
+	 */
+	if (plane == 1)
+		src_h >>= pipe->chroma_sample_v;
+	writel_relaxed(((pipe->scale.right_ftch[plane] & mask) << 24)|
+		((pipe->scale.right_rpt[plane] & mask) << 16)|
+		((pipe->scale.left_ftch[plane] & mask) << 8)|
+		(pipe->scale.left_rpt[plane] & mask), pipe->base +
+			MDSS_MDP_REG_SSPP_SW_PIX_EXT_C0_LR + off);
+	writel_relaxed(((pipe->scale.btm_ftch[plane] & mask) << 24)|
+		((pipe->scale.btm_rpt[plane] & mask) << 16)|
+		((pipe->scale.top_ftch[plane] & mask) << 8)|
+		(pipe->scale.top_rpt[plane] & mask), pipe->base +
+			MDSS_MDP_REG_SSPP_SW_PIX_EXT_C0_TB + off);
+	mask = 0xFFFF;
+	writel_relaxed((((src_h + pipe->scale.num_ext_pxls_top[plane] +
+		pipe->scale.num_ext_pxls_btm[plane]) & mask) << 16) |
+		((pipe->scale.roi_w[plane] +
+		pipe->scale.num_ext_pxls_left[plane] +
+		pipe->scale.num_ext_pxls_right[plane]) & mask), pipe->base +
+			MDSS_MDP_REG_SSPP_SW_PIX_EXT_C0_REQ_PIXELS + off);
+}
+
+/**
+ * mdss_mdp_pipe_program_pixel_extn - Program the source pipe's
+ *				      sw pixel extension
+ * @pipe:	Source pipe struct containing pixel extn values
+ *
+ * Function programs the pixel extn values calculated during
+ * scale setup.
+ */
+int mdss_mdp_pipe_program_pixel_extn(struct mdss_mdp_pipe *pipe)
+{
+	/* Y plane pixel extn */
+	__mdss_mdp_pipe_program_pixel_extn_helper(pipe, 0, 0);
+	/* CB CR plane pixel extn */
+	__mdss_mdp_pipe_program_pixel_extn_helper(pipe, 1, 16);
+	/* Alpha plane pixel extn */
+	__mdss_mdp_pipe_program_pixel_extn_helper(pipe, 3, 32);
+	return 0;
+}
diff --git a/drivers/video/msm/mdss/mdss_mdp_pp.c b/drivers/video/msm/mdss/mdss_mdp_pp.c
index e48e749..dfeec22 100644
--- a/drivers/video/msm/mdss/mdss_mdp_pp.c
+++ b/drivers/video/msm/mdss/mdss_mdp_pp.c
@@ -629,7 +629,7 @@
 		}
 	}
 
-	*op = opmode;
+	*op |= opmode;
 
 	return 0;
 }
@@ -637,12 +637,15 @@
 static int mdss_mdp_scale_setup(struct mdss_mdp_pipe *pipe)
 {
 	u32 scale_config = 0;
-	u32 phasex_step = 0, phasey_step = 0;
+	int init_phasex = 0, init_phasey = 0;
+	int phasex_step = 0, phasey_step = 0;
 	u32 chroma_sample;
 	u32 filter_mode;
 	struct mdss_data_type *mdata;
 	u32 src_w, src_h;
 
+	pr_debug("pipe=%d, change pxl ext=%d\n", pipe->num,
+			pipe->scale.enable_pxl_ext);
 	mdata = mdss_mdp_get_mdata();
 	if (mdata->mdp_rev >= MDSS_MDP_HW_REV_102 && pipe->src_fmt->is_yuv)
 		filter_mode = MDSS_MDP_SCALE_FILTER_CA;
@@ -689,7 +692,8 @@
 	if ((src_h != pipe->dst.h) ||
 	    (pipe->pp_res.pp_sts.sharp_sts & PP_STS_ENABLE) ||
 	    (chroma_sample == MDSS_MDP_CHROMA_420) ||
-	    (chroma_sample == MDSS_MDP_CHROMA_H1V2)) {
+	    (chroma_sample == MDSS_MDP_CHROMA_H1V2) ||
+	    pipe->scale.enable_pxl_ext) {
 		pr_debug("scale y - src_h=%d dst_h=%d\n", src_h, pipe->dst.h);
 
 		if ((src_h / MAX_DOWNSCALE_RATIO) > pipe->dst.h) {
@@ -699,7 +703,8 @@
 		}
 
 		scale_config |= MDSS_MDP_SCALEY_EN;
-		phasey_step = pipe->phase_step_y;
+		phasey_step = pipe->scale.phase_step_y[0];
+		init_phasey = pipe->scale.init_phase_y[0];
 
 		if (pipe->type == MDSS_MDP_PIPE_TYPE_VIG) {
 			u32 chroma_shift = 0;
@@ -708,11 +713,11 @@
 			    (chroma_sample == MDSS_MDP_CHROMA_H1V2)))
 				chroma_shift = 1; /* 2x upsample chroma */
 
-			if (src_h <= pipe->dst.h) {
+			if (src_h <= pipe->dst.h)
 				scale_config |= /* G/Y, A */
 					(filter_mode << 10) |
-					(MDSS_MDP_SCALE_FILTER_NEAREST << 18);
-			} else
+					(MDSS_MDP_SCALE_FILTER_BIL << 18);
+			else
 				scale_config |= /* G/Y, A */
 					(MDSS_MDP_SCALE_FILTER_PCMN << 10) |
 					(MDSS_MDP_SCALE_FILTER_PCMN << 18);
@@ -724,13 +729,15 @@
 				scale_config |= /* CrCb */
 					(MDSS_MDP_SCALE_FILTER_PCMN << 14);
 
+			writel_relaxed(init_phasey, pipe->base +
+				MDSS_MDP_REG_VIG_QSEED2_C12_INIT_PHASEY);
 			writel_relaxed(phasey_step >> chroma_shift, pipe->base +
 				MDSS_MDP_REG_VIG_QSEED2_C12_PHASESTEPY);
 		} else {
 			if (src_h <= pipe->dst.h)
 				scale_config |= /* RGB, A */
 					(MDSS_MDP_SCALE_FILTER_BIL << 10) |
-					(MDSS_MDP_SCALE_FILTER_NEAREST << 18);
+					(MDSS_MDP_SCALE_FILTER_BIL << 18);
 			else
 				scale_config |= /* RGB, A */
 					(MDSS_MDP_SCALE_FILTER_PCMN << 10) |
@@ -741,7 +748,8 @@
 	if ((src_w != pipe->dst.w) ||
 	    (pipe->pp_res.pp_sts.sharp_sts & PP_STS_ENABLE) ||
 	    (chroma_sample == MDSS_MDP_CHROMA_420) ||
-	    (chroma_sample == MDSS_MDP_CHROMA_H2V1)) {
+	    (chroma_sample == MDSS_MDP_CHROMA_H2V1) ||
+	    pipe->scale.enable_pxl_ext) {
 		pr_debug("scale x - src_w=%d dst_w=%d\n", src_w, pipe->dst.w);
 
 		if ((src_w / MAX_DOWNSCALE_RATIO) > pipe->dst.w) {
@@ -751,7 +759,8 @@
 		}
 
 		scale_config |= MDSS_MDP_SCALEX_EN;
-		phasex_step = pipe->phase_step_x;
+		init_phasex = pipe->scale.init_phase_x[0];
+		phasex_step = pipe->scale.phase_step_x[0];
 
 		if (pipe->type == MDSS_MDP_PIPE_TYPE_VIG) {
 			u32 chroma_shift = 0;
@@ -761,11 +770,11 @@
 			    (chroma_sample == MDSS_MDP_CHROMA_H2V1)))
 				chroma_shift = 1; /* 2x upsample chroma */
 
-			if (src_w <= pipe->dst.w) {
+			if (src_w <= pipe->dst.w)
 				scale_config |= /* G/Y, A */
 					(filter_mode << 8) |
-					(MDSS_MDP_SCALE_FILTER_NEAREST << 16);
-			} else
+					(MDSS_MDP_SCALE_FILTER_BIL << 16);
+			else
 				scale_config |= /* G/Y, A */
 					(MDSS_MDP_SCALE_FILTER_PCMN << 8) |
 					(MDSS_MDP_SCALE_FILTER_PCMN << 16);
@@ -777,13 +786,15 @@
 				scale_config |= /* CrCb */
 					(MDSS_MDP_SCALE_FILTER_PCMN << 12);
 
+			writel_relaxed(init_phasex, pipe->base +
+				MDSS_MDP_REG_VIG_QSEED2_C12_INIT_PHASEX);
 			writel_relaxed(phasex_step >> chroma_shift, pipe->base +
 				MDSS_MDP_REG_VIG_QSEED2_C12_PHASESTEPX);
 		} else {
 			if (src_w <= pipe->dst.w)
 				scale_config |= /* RGB, A */
 					(MDSS_MDP_SCALE_FILTER_BIL << 8) |
-					(MDSS_MDP_SCALE_FILTER_NEAREST << 16);
+					(MDSS_MDP_SCALE_FILTER_BIL << 16);
 			else
 				scale_config |= /* RGB, A */
 					(MDSS_MDP_SCALE_FILTER_PCMN << 8) |
@@ -791,12 +802,44 @@
 		}
 	}
 
+	if (pipe->scale.enable_pxl_ext &&
+		pipe->type == MDSS_MDP_PIPE_TYPE_VIG) {
+
+		/*program x,y initial phase and phase step*/
+		writel_relaxed(pipe->scale.init_phase_x[0],
+			pipe->base + MDSS_MDP_REG_VIG_QSEED2_C03_INIT_PHASEX);
+		writel_relaxed(pipe->scale.phase_step_x[0],
+			pipe->base + MDSS_MDP_REG_VIG_QSEED2_C03_PHASESTEPX);
+		writel_relaxed(pipe->scale.init_phase_x[1],
+			pipe->base + MDSS_MDP_REG_VIG_QSEED2_C12_INIT_PHASEX);
+		writel_relaxed(pipe->scale.phase_step_x[1],
+			pipe->base + MDSS_MDP_REG_VIG_QSEED2_C12_PHASESTEPX);
+
+		writel_relaxed(pipe->scale.init_phase_y[0],
+			pipe->base + MDSS_MDP_REG_VIG_QSEED2_C03_INIT_PHASEY);
+		writel_relaxed(pipe->scale.phase_step_y[0],
+			pipe->base + MDSS_MDP_REG_VIG_QSEED2_C03_PHASESTEPY);
+		writel_relaxed(pipe->scale.init_phase_y[1],
+			pipe->base + MDSS_MDP_REG_VIG_QSEED2_C12_INIT_PHASEY);
+		writel_relaxed(pipe->scale.phase_step_y[1],
+			pipe->base + MDSS_MDP_REG_VIG_QSEED2_C12_PHASESTEPY);
+
+		/*program pixel extn values for the SSPP*/
+		mdss_mdp_pipe_program_pixel_extn(pipe);
+	} else {
+		writel_relaxed(phasex_step, pipe->base +
+		   MDSS_MDP_REG_SCALE_PHASE_STEP_X);
+		writel_relaxed(phasey_step, pipe->base +
+		   MDSS_MDP_REG_SCALE_PHASE_STEP_Y);
+		writel_relaxed(init_phasex, pipe->base +
+			MDSS_MDP_REG_SCALE_INIT_PHASE_X);
+		writel_relaxed(init_phasey, pipe->base +
+			MDSS_MDP_REG_SCALE_INIT_PHASE_Y);
+	}
+
 	writel_relaxed(scale_config, pipe->base +
 	   MDSS_MDP_REG_SCALE_CONFIG);
-	writel_relaxed(phasex_step, pipe->base +
-	   MDSS_MDP_REG_SCALE_PHASE_STEP_X);
-	writel_relaxed(phasey_step, pipe->base +
-	   MDSS_MDP_REG_SCALE_PHASE_STEP_Y);
+
 	return 0;
 }
 
@@ -2248,6 +2291,7 @@
 	return ret;
 }
 
+#define MDSS_MAX_HIST_BIN_SIZE 16777215
 int mdss_mdp_histogram_start(struct mdp_histogram_start_req *req)
 {
 	u32 done_shift_bit;
@@ -2256,9 +2300,13 @@
 	int i, ret = 0;
 	u32 disp_num, dspp_num = 0;
 	u32 mixer_cnt, mixer_id[MDSS_MDP_INTF_MAX_LAYERMIXER];
+	u32 frame_size;
 	struct mdss_mdp_pipe *pipe;
 	struct mdss_data_type *mdata = mdss_mdp_get_mdata();
 
+	if (!mdss_is_ready())
+		return -EPROBE_DEFER;
+
 	if ((PP_BLOCK(req->block) < MDP_LOGICAL_BLOCK_DISP_0) ||
 		(PP_BLOCK(req->block) >= MDP_BLOCK_MAX))
 		return -EINVAL;
@@ -2278,6 +2326,16 @@
 		ret = -EPERM;
 		goto hist_exit;
 	}
+
+	frame_size = (mdata->ctl_off[mixer_id[0]].width *
+					mdata->ctl_off[mixer_id[0]].height);
+	if (!frame_size ||
+		((MDSS_MAX_HIST_BIN_SIZE / frame_size) < req->frame_cnt)) {
+		pr_err("%s, too many frames for given display size, %d",
+						__func__, req->frame_cnt);
+		ret = -EINVAL;
+		goto hist_exit;
+	}
 	mdss_mdp_clk_ctrl(MDP_BLOCK_POWER_ON, false);
 
 	if (PP_LOCAT(req->block) == MDSS_PP_SSPP_CFG) {
@@ -2944,6 +3002,11 @@
 			ret = -EINVAL;
 			goto error;
 		}
+		if (input->in.amb_light > MDSS_MDP_MAX_AD_AL) {
+			pr_warn("invalid input ambient light");
+			ret = -EINVAL;
+			goto error;
+		}
 		ad->ad_data_mode = MDSS_AD_INPUT_AMBIENT;
 		pr_debug("ambient = %d", input->in.amb_light);
 		ad->ad_data = input->in.amb_light;
@@ -2958,6 +3021,11 @@
 			ret = -EINVAL;
 			goto error;
 		}
+		if (input->in.strength > MDSS_MDP_MAX_AD_STR) {
+			pr_warn("invalid input strength");
+			ret = -EINVAL;
+			goto error;
+		}
 		ad->ad_data_mode = MDSS_AD_INPUT_STRENGTH;
 		pr_debug("strength = %d", input->in.strength);
 		ad->ad_data = input->in.strength;
@@ -3520,8 +3588,8 @@
 		return ret;
 	}
 
-	if (cfg->size == 0) {
-		pr_err("Invalid buffer size");
+	if (cfg->size == 0 || cfg->size > PAGE_SIZE) {
+		pr_err("Invalid buffer size %d", cfg->size);
 		return ret;
 	}
 
diff --git a/drivers/video/msm/mdss/mdss_mdp_rotator.c b/drivers/video/msm/mdss/mdss_mdp_rotator.c
index 261679f..e2e41bb 100644
--- a/drivers/video/msm/mdss/mdss_mdp_rotator.c
+++ b/drivers/video/msm/mdss/mdss_mdp_rotator.c
@@ -137,7 +137,6 @@
 {
 	int ret;
 	struct mdss_mdp_writeback_arg wb_args = {
-		.callback_fnc = NULL,
 		.data = dst_data,
 		.priv_data = rot,
 	};
@@ -276,17 +275,15 @@
 
 	mutex_lock(&rotator_lock);
 	ret = mdss_mdp_rotator_queue_helper(rot);
-
-	if (ret) {
+	if (ret)
 		pr_err("rotator queue failed\n");
-		mutex_unlock(&rotator_lock);
-		return;
-	}
 
-	if (rot->rot_sync_pt_data)
+	if (rot->rot_sync_pt_data) {
+		atomic_inc(&rot->rot_sync_pt_data->commit_cnt);
 		mdss_fb_signal_timeline(rot->rot_sync_pt_data);
-	else
+	} else {
 		pr_err("rot_sync_pt_data is NULL\n");
+	}
 
 	mutex_unlock(&rotator_lock);
 }
@@ -440,6 +437,7 @@
 		rot->flags |= MDP_DEINTERLACE;
 		rot->src_rect.h /= 2;
 		rot->src_rect.y = DIV_ROUND_UP(rot->src_rect.y, 2);
+		rot->src_rect.y &= ~1;
 	}
 
 	rot->dst = rot->src_rect;
diff --git a/drivers/video/msm/mdss/mdss_mdp_util.c b/drivers/video/msm/mdss/mdss_mdp_util.c
index 1170d1e..b680823 100644
--- a/drivers/video/msm/mdss/mdss_mdp_util.c
+++ b/drivers/video/msm/mdss/mdss_mdp_util.c
@@ -592,7 +592,7 @@
 		return -EINVAL;
 
 	unit = 1 << PHASE_STEP_SHIFT;
-	*out_phase = mult_frac(src, unit, dst);
+	*out_phase = mult_frac(unit, src, dst);
 
 	/* check if overflow is possible */
 	if (src > dst) {
diff --git a/drivers/video/msm/mdss/mdss_mdp_wb.c b/drivers/video/msm/mdss/mdss_mdp_wb.c
index a9f3e35..d29323d3 100644
--- a/drivers/video/msm/mdss/mdss_mdp_wb.c
+++ b/drivers/video/msm/mdss/mdss_mdp_wb.c
@@ -132,6 +132,16 @@
 
 	pr_debug("setting secure=%d\n", enable);
 
+	if (!ctl || !ctl->mdata) {
+		pr_err("%s : ctl is NULL", __func__);
+		return -EINVAL;
+	}
+
+	if (!wb) {
+		pr_err("unable to start, writeback is not initialized\n");
+		return -ENODEV;
+	}
+
 	ctl->is_secure = enable;
 	wb->is_secure = enable;
 
@@ -476,23 +486,13 @@
 	return ret;
 }
 
-static void mdss_mdp_wb_callback(void *arg)
-{
-	if (arg)
-		complete((struct completion *) arg);
-}
-
 int mdss_mdp_wb_kickoff(struct msm_fb_data_type *mfd)
 {
 	struct mdss_mdp_wb *wb = mfd_to_wb(mfd);
 	struct mdss_mdp_ctl *ctl = mfd_to_ctl(mfd);
 	struct mdss_mdp_wb_data *node = NULL;
 	int ret = 0;
-	DECLARE_COMPLETION_ONSTACK(comp);
-	struct mdss_mdp_writeback_arg wb_args = {
-		.callback_fnc = mdss_mdp_wb_callback,
-		.priv_data = &comp,
-	};
+	struct mdss_mdp_writeback_arg wb_args;
 
 	if (!ctl->power_on)
 		return 0;
@@ -524,6 +524,7 @@
 		pr_err("unable to get writeback buf ctl=%d\n", ctl->num);
 		/* drop buffer but don't return error */
 		ret = 0;
+		mdss_mdp_ctl_notify(ctl, MDP_NOTIFY_FRAME_DONE);
 		goto kickoff_fail;
 	}
 
@@ -533,12 +534,6 @@
 		goto kickoff_fail;
 	}
 
-	ret = wait_for_completion_timeout(&comp, KOFF_TIMEOUT);
-	if (ret == 0)
-		WARN(1, "wfd kick off time out=%d ctl=%d", ret, ctl->num);
-	else
-		ret = 0;
-
 	if (wb && node) {
 		mutex_lock(&wb->lock);
 		list_add_tail(&node->active_entry, &wb->busy_queue);
diff --git a/drivers/video/msm/mdss/mdss_panel.h b/drivers/video/msm/mdss/mdss_panel.h
index 75fc095..b859598 100644
--- a/drivers/video/msm/mdss/mdss_panel.h
+++ b/drivers/video/msm/mdss/mdss_panel.h
@@ -299,6 +299,8 @@
 	struct ion_handle *splash_ihdl;
 	u32 panel_power_on;
 
+	uint32_t panel_dead;
+
 	struct lcd_panel_info lcdc;
 	struct fbc_panel_info fbc;
 	struct mipi_panel_info mipi;
diff --git a/drivers/video/msm/mdss/mhl_sii8334.c b/drivers/video/msm/mdss/mhl_sii8334.c
index a759e86..ab01566 100644
--- a/drivers/video/msm/mdss/mhl_sii8334.c
+++ b/drivers/video/msm/mdss/mhl_sii8334.c
@@ -1463,7 +1463,7 @@
 	static struct regulator *reg_8941_l02;
 	static struct regulator *reg_8941_smps3a;
 	static struct regulator *reg_8941_vdda;
-	int rc;
+	int rc = -EINVAL;
 
 	pr_debug("%s\n", __func__);
 	if (!reg_8941_l24) {
diff --git a/drivers/video/msm/mdss/msm_mdss_io_8974.c b/drivers/video/msm/mdss/msm_mdss_io_8974.c
index f7ea557..62704a9 100644
--- a/drivers/video/msm/mdss/msm_mdss_io_8974.c
+++ b/drivers/video/msm/mdss/msm_mdss_io_8974.c
@@ -40,6 +40,14 @@
 	}
 
 	dev = &pdev->dev;
+	ctrl_pdata->mdp_core_clk = clk_get(dev, "mdp_core_clk");
+	if (IS_ERR(ctrl_pdata->mdp_core_clk)) {
+		rc = PTR_ERR(ctrl_pdata->mdp_core_clk);
+		pr_err("%s: Unable to get mdp core clk. rc=%d\n",
+			__func__, rc);
+		goto mdss_dsi_clk_err;
+	}
+
 	ctrl_pdata->ahb_clk = clk_get(dev, "iface_clk");
 	if (IS_ERR(ctrl_pdata->ahb_clk)) {
 		rc = PTR_ERR(ctrl_pdata->ahb_clk);
@@ -101,6 +109,8 @@
 		clk_put(ctrl_pdata->axi_clk);
 	if (ctrl_pdata->ahb_clk)
 		clk_put(ctrl_pdata->ahb_clk);
+	if (ctrl_pdata->mdp_core_clk)
+		clk_put(ctrl_pdata->mdp_core_clk);
 }
 
 #define PREF_DIV_RATIO 27
@@ -241,9 +251,17 @@
 {
 	int rc = 0;
 
+	rc = clk_prepare_enable(ctrl_pdata->mdp_core_clk);
+	if (rc) {
+		pr_err("%s: failed to enable mdp_core_clock. rc=%d\n",
+							 __func__, rc);
+		goto error;
+	}
+
 	rc = clk_prepare_enable(ctrl_pdata->ahb_clk);
 	if (rc) {
 		pr_err("%s: failed to enable ahb clock. rc=%d\n", __func__, rc);
+		clk_disable_unprepare(ctrl_pdata->mdp_core_clk);
 		goto error;
 	}
 
@@ -251,6 +269,7 @@
 	if (rc) {
 		pr_err("%s: failed to enable ahb clock. rc=%d\n", __func__, rc);
 		clk_disable_unprepare(ctrl_pdata->ahb_clk);
+		clk_disable_unprepare(ctrl_pdata->mdp_core_clk);
 		goto error;
 	}
 
@@ -262,6 +281,7 @@
 {
 	clk_disable_unprepare(ctrl_pdata->axi_clk);
 	clk_disable_unprepare(ctrl_pdata->ahb_clk);
+	clk_disable_unprepare(ctrl_pdata->mdp_core_clk);
 }
 
 static int mdss_dsi_clk_prepare(struct mdss_dsi_ctrl_pdata *ctrl_pdata)
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index 4bbd07a..8da837b 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -90,8 +90,8 @@
 	 * unusual file system layouts.
 	 */
 	if (ext4_block_in_group(sb, ext4_block_bitmap(sb, gdp), block_group)) {
-		block_cluster = EXT4_B2C(sbi, (start -
-					       ext4_block_bitmap(sb, gdp)));
+		block_cluster = EXT4_B2C(sbi,
+					 ext4_block_bitmap(sb, gdp) - start);
 		if (block_cluster < num_clusters)
 			block_cluster = -1;
 		else if (block_cluster == num_clusters) {
@@ -102,7 +102,7 @@
 
 	if (ext4_block_in_group(sb, ext4_inode_bitmap(sb, gdp), block_group)) {
 		inode_cluster = EXT4_B2C(sbi,
-					 start - ext4_inode_bitmap(sb, gdp));
+					 ext4_inode_bitmap(sb, gdp) - start);
 		if (inode_cluster < num_clusters)
 			inode_cluster = -1;
 		else if (inode_cluster == num_clusters) {
@@ -114,7 +114,7 @@
 	itbl_blk = ext4_inode_table(sb, gdp);
 	for (i = 0; i < sbi->s_itb_per_group; i++) {
 		if (ext4_block_in_group(sb, itbl_blk + i, block_group)) {
-			c = EXT4_B2C(sbi, start - itbl_blk + i);
+			c = EXT4_B2C(sbi, itbl_blk + i - start);
 			if ((c < num_clusters) || (c == inode_cluster) ||
 			    (c == block_cluster) || (c == itbl_cluster))
 				continue;
diff --git a/include/linux/diagchar.h b/include/linux/diagchar.h
index 0739ece..d525e84 100644
--- a/include/linux/diagchar.h
+++ b/include/linux/diagchar.h
@@ -726,25 +726,27 @@
 };
 
 /* LOG CODES */
+static const uint32_t log_code_last_tbl[] = {
+	0x0,	/* EQUIP ID 0 */
+	0x182F,	/* EQUIP ID 1 */
+	0x0,	/* EQUIP ID 2 */
+	0x0,	/* EQUIP ID 3 */
+	0x4910,	/* EQUIP ID 4 */
+	0x5420,	/* EQUIP ID 5 */
+	0x0,	/* EQUIP ID 6 */
+	0x74FF,	/* EQUIP ID 7 */
+	0x0,	/* EQUIP ID 8 */
+	0x0,	/* EQUIP ID 9 */
+	0xA38A,	/* EQUIP ID 10 */
+	0xB201,	/* EQUIP ID 11 */
+	0x0,	/* EQUIP ID 12 */
+	0x0,	/* EQUIP ID 13 */
+	0x0,	/* EQUIP ID 14 */
+	0x0,	/* EQUIP ID 15 */
+};
 
-#define LOG_0	0x0
-#define LOG_1	0x1808
-#define LOG_2	0x0
-#define LOG_3	0x0
-#define LOG_4	0x4910
-#define LOG_5	0x5420
-#define LOG_6	0x0
-#define LOG_7	0x74FF
-#define LOG_8	0x0
-#define LOG_9	0x0
-#define LOG_10	0xA38A
-#define LOG_11	0xB201
-#define LOG_12	0x0
-#define LOG_13	0x0
-#define LOG_14	0x0
-#define LOG_15	0x0
-
-#define LOG_GET_ITEM_NUM(xx_code) (xx_code & 0x0FFF)
-#define LOG_GET_EQUIP_ID(xx_code) ((xx_code & 0xF000) >> 12)
+#define LOG_GET_ITEM_NUM(xx_code)	(xx_code & 0x0FFF)
+#define LOG_GET_EQUIP_ID(xx_code)	((xx_code & 0xF000) >> 12)
+#define LOG_ITEMS_TO_SIZE(num_items)	((num_items+7)/8)
 
 #endif
diff --git a/include/linux/kref.h b/include/linux/kref.h
index 9c07dce..6f515f2 100644
--- a/include/linux/kref.h
+++ b/include/linux/kref.h
@@ -18,6 +18,7 @@
 #include <linux/bug.h>
 #include <linux/atomic.h>
 #include <linux/kernel.h>
+#include <linux/mutex.h>
 
 struct kref {
 	atomic_t refcount;
@@ -93,4 +94,43 @@
 {
 	return kref_sub(kref, 1, release);
 }
+
+static inline int kref_put_mutex(struct kref *kref,
+				 void (*release)(struct kref *kref),
+				 struct mutex *lock)
+{
+	WARN_ON(release == NULL);
+        if (unlikely(!atomic_add_unless(&kref->refcount, -1, 1))) {
+		mutex_lock(lock);
+		if (unlikely(!atomic_dec_and_test(&kref->refcount))) {
+			mutex_unlock(lock);
+			return 0;
+		}
+		release(kref);
+		return 1;
+	}
+	return 0;
+}
+
+
+/**
+ * kref_get_unless_zero - Increment refcount for object unless it is zero.
+ * @kref: object.
+ *
+ * Return non-zero if the increment succeeded. Otherwise return 0.
+ *
+ * This function is intended to simplify locking around refcounting for
+ * objects that can be looked up from a lookup structure, and which are
+ * removed from that lookup structure in the object destructor.
+ * Operations on such objects require at least a read lock around
+ * lookup + kref_get, and a write lock around kref_put + remove from lookup
+ * structure. Furthermore, RCU implementations become extremely tricky.
+ * With a lookup followed by a kref_get_unless_zero *with return value check*
+ * locking in the kref_put path can be deferred to the actual removal from
+ * the lookup structure and RCU lookups become trivial.
+ */
+static inline int __must_check kref_get_unless_zero(struct kref *kref)
+{
+	return atomic_add_unless(&kref->refcount, 1, 0);
+}
 #endif /* _KREF_H_ */
diff --git a/include/linux/mm.h b/include/linux/mm.h
index a5fa304..2218ac4 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -806,6 +806,17 @@
 	return (void *)((unsigned long)page->mapping & ~PAGE_MAPPING_FLAGS);
 }
 
+extern struct address_space *__page_file_mapping(struct page *);
+
+static inline
+struct address_space *page_file_mapping(struct page *page)
+{
+	if (unlikely(PageSwapCache(page)))
+		return __page_file_mapping(page);
+
+	return page->mapping;
+}
+
 static inline int PageAnon(struct page *page)
 {
 	return ((unsigned long)page->mapping & PAGE_MAPPING_ANON) != 0;
@@ -822,6 +833,20 @@
 	return page->index;
 }
 
+extern pgoff_t __page_file_index(struct page *page);
+
+/*
+ * Return the file index of the page. Regular pagecache pages use ->index
+ * whereas swapcache pages use swp_offset(->private)
+ */
+static inline pgoff_t page_file_index(struct page *page)
+{
+	if (unlikely(PageSwapCache(page)))
+		return __page_file_index(page);
+
+	return page->index;
+}
+
 /*
  * Return true if this page is mapped into pagetables.
  */
diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h
index 227fd3e..9a584c0 100644
--- a/include/linux/mm_inline.h
+++ b/include/linux/mm_inline.h
@@ -2,6 +2,7 @@
 #define LINUX_MM_INLINE_H
 
 #include <linux/huge_mm.h>
+#include <linux/swap.h>
 
 /**
  * page_is_file_cache - should the page be on a file LRU or anon LRU?
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index d0ad3e4..1bcfd28 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -219,6 +219,7 @@
 	MMC_BLK_NEW_REQUEST,
 	MMC_BLK_URGENT,
 	MMC_BLK_URGENT_DONE,
+	MMC_BLK_NO_REQ_TO_STOP,
 };
 
 struct mmc_wr_pack_stats {
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index e1dbd21..bff056d 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -300,6 +300,7 @@
 
 #define MMC_CAP2_HS400_1_8V	(1 << 21)        /* can support */
 #define MMC_CAP2_HS400_1_2V	(1 << 22)        /* can support */
+#define MMC_CAP2_CORE_PM	(1 << 23)       /* use PM framework */
 #define MMC_CAP2_HS400		(MMC_CAP2_HS400_1_8V | \
 				 MMC_CAP2_HS400_1_2V)
 	mmc_pm_flag_t		pm_caps;	/* supported pm features */
@@ -572,4 +573,9 @@
 	return host->caps2 & MMC_CAP2_CORE_RUNTIME_PM;
 }
 
+static inline int mmc_use_core_pm(struct mmc_host *host)
+{
+	return host->caps2 & MMC_CAP2_CORE_PM;
+}
+
 #endif /* LINUX_MMC_HOST_H */
diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
index 186fff1..08ca341 100644
--- a/include/linux/mmc/sdhci.h
+++ b/include/linux/mmc/sdhci.h
@@ -252,6 +252,7 @@
 	struct mutex ios_mutex;
 	enum sdhci_power_policy power_policy;
 
+	u32 auto_cmd_err_sts;
 	unsigned long private[0] ____cacheline_aligned;
 };
 #endif /* LINUX_MMC_SDHCI_H */
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 7539e03..381fff5 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -375,7 +375,6 @@
 	 * free areas of different sizes
 	 */
 	spinlock_t		lock;
-	int                     all_unreclaimable; /* All pages pinned */
 #if defined CONFIG_COMPACTION || defined CONFIG_CMA
 	/* Set to true when the PG_migrate_skip bits should be cleared */
 	bool			compact_blockskip_flush;
diff --git a/include/linux/msm_mdp.h b/include/linux/msm_mdp.h
index 0c08421..803ebeb 100644
--- a/include/linux/msm_mdp.h
+++ b/include/linux/msm_mdp.h
@@ -156,6 +156,7 @@
 
 #define MDSS_MDP_ROT_ONLY		0x80
 #define MDSS_MDP_RIGHT_MIXER		0x100
+#define MDSS_MDP_DUAL_PIPE		0x200
 
 /* mdp_blit_req flag values */
 #define MDP_ROT_NOP 0
@@ -168,6 +169,7 @@
 #define MDP_BLUR 0x10
 #define MDP_BLEND_FG_PREMULT 0x20000
 #define MDP_IS_FG 0x40000
+#define MDP_SOLID_FILL 0x0000100
 #define MDP_DEINTERLACE 0x80000000
 #define MDP_SHARPENING  0x40000000
 #define MDP_NO_DMA_BARRIER_START	0x20000000
@@ -253,11 +255,19 @@
 
 #define MDP_BLIT_REQ_VERSION 2
 
+struct color {
+	uint32_t r;
+	uint32_t g;
+	uint32_t b;
+	uint32_t alpha;
+};
+
 struct mdp_blit_req {
 	struct mdp_img src;
 	struct mdp_img dst;
 	struct mdp_rect src_rect;
 	struct mdp_rect dst_rect;
+	struct color const_color;
 	uint32_t alpha;
 	uint32_t transp_mask;
 	uint32_t flags;
@@ -442,6 +452,33 @@
 	BLEND_OP_MAX,
 };
 
+#define MAX_PLANES	4
+struct mdp_scale_data {
+	uint8_t enable_pxl_ext;
+
+	int init_phase_x[MAX_PLANES];
+	int phase_step_x[MAX_PLANES];
+	int init_phase_y[MAX_PLANES];
+	int phase_step_y[MAX_PLANES];
+
+	int num_ext_pxls_left[MAX_PLANES];
+	int num_ext_pxls_right[MAX_PLANES];
+	int num_ext_pxls_top[MAX_PLANES];
+	int num_ext_pxls_btm[MAX_PLANES];
+
+	int left_ftch[MAX_PLANES];
+	int left_rpt[MAX_PLANES];
+	int right_ftch[MAX_PLANES];
+	int right_rpt[MAX_PLANES];
+
+	int top_rpt[MAX_PLANES];
+	int btm_rpt[MAX_PLANES];
+	int top_ftch[MAX_PLANES];
+	int btm_ftch[MAX_PLANES];
+
+	uint32_t roi_w[MAX_PLANES];
+};
+
 struct mdp_overlay {
 	struct msmfb_img src;
 	struct mdp_rect src_rect;
@@ -457,6 +494,7 @@
 	uint8_t horz_deci;
 	uint8_t vert_deci;
 	struct mdp_overlay_pp_params overlay_pp_cfg;
+	struct mdp_scale_data scale;
 };
 
 struct msmfb_overlay_3d {
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index cfaaa69..696ca39 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -205,7 +205,16 @@
 #else
 static inline struct page *__page_cache_alloc(gfp_t gfp)
 {
-	return alloc_pages(gfp, 0);
+	struct page *page;
+
+	page = alloc_pages(gfp, 0);
+
+	if (page && is_cma_pageblock(page)) {
+		__free_page(page);
+		page = alloc_pages(gfp & ~__GFP_MOVABLE, 0);
+	}
+
+	return page;
 }
 #endif
 
@@ -286,6 +295,11 @@
 	return ((loff_t)page->index) << PAGE_CACHE_SHIFT;
 }
 
+static inline loff_t page_file_offset(struct page *page)
+{
+	return ((loff_t)page_file_index(page)) << PAGE_CACHE_SHIFT;
+}
+
 extern pgoff_t linear_hugepage_index(struct vm_area_struct *vma,
 				     unsigned long address);
 
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 93af04d..0065203 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -101,9 +101,11 @@
 	POWER_SUPPLY_PROP_VOLTAGE_NOW,
 	POWER_SUPPLY_PROP_VOLTAGE_AVG,
 	POWER_SUPPLY_PROP_INPUT_VOLTAGE_REGULATION,
+	POWER_SUPPLY_PROP_VOLTAGE_OCV,
 	POWER_SUPPLY_PROP_CURRENT_MAX,
 	POWER_SUPPLY_PROP_INPUT_CURRENT_MAX,
 	POWER_SUPPLY_PROP_INPUT_CURRENT_TRIM,
+	POWER_SUPPLY_PROP_INPUT_CURRENT_SETTLED,
 	POWER_SUPPLY_PROP_CURRENT_NOW,
 	POWER_SUPPLY_PROP_CURRENT_AVG,
 	POWER_SUPPLY_PROP_POWER_NOW,
@@ -320,6 +322,7 @@
 	case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
 	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
 	case POWER_SUPPLY_PROP_VOLTAGE_AVG:
+	case POWER_SUPPLY_PROP_VOLTAGE_OCV:
 	case POWER_SUPPLY_PROP_POWER_NOW:
 		return 1;
 	default:
diff --git a/include/linux/slimbus/slimbus.h b/include/linux/slimbus/slimbus.h
index cba4394..c940091 100644
--- a/include/linux/slimbus/slimbus.h
+++ b/include/linux/slimbus/slimbus.h
@@ -1077,7 +1077,7 @@
 extern int slim_register_board_info(struct slim_boardinfo const *info,
 					unsigned n);
 #else
-int slim_register_board_info(struct slim_boardinfo const *info,
+static inline int slim_register_board_info(struct slim_boardinfo const *info,
 					unsigned n)
 {
 	return 0;
diff --git a/include/linux/swap.h b/include/linux/swap.h
index d5bd6ee..c1fcf34 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -197,6 +197,18 @@
 	struct block_device *bdev;	/* swap device or bdev of swap file */
 	struct file *swap_file;		/* seldom referenced */
 	unsigned int old_block_size;	/* seldom referenced */
+	spinlock_t lock;		/*
+					 * protect map scan related fields like
+					 * swap_map, lowest_bit, highest_bit,
+					 * inuse_pages, cluster_next,
+					 * cluster_nr, lowest_alloc and
+					 * highest_alloc. other fields are only
+					 * changed at swapon/swapoff, so are
+					 * protected by swap_lock. changing
+					 * flags need hold this lock and
+					 * swap_lock. If both locks need hold,
+					 * hold swap_lock first.
+					 */
 };
 
 struct swap_list_t {
@@ -204,9 +216,6 @@
 	int next;	/* swapfile to be used next */
 };
 
-/* Swap 50% full? Release swapcache more aggressively.. */
-#define vm_swap_full() (nr_swap_pages*2 < total_swap_pages)
-
 /* linux/mm/page_alloc.c */
 extern unsigned long totalram_pages;
 extern unsigned long totalreserve_pages;
@@ -335,8 +344,20 @@
 			struct vm_area_struct *vma, unsigned long addr);
 
 /* linux/mm/swapfile.c */
-extern long nr_swap_pages;
+extern atomic_long_t nr_swap_pages;
 extern long total_swap_pages;
+
+/* Swap 50% full? Release swapcache more aggressively.. */
+static inline bool vm_swap_full(void)
+{
+	return atomic_long_read(&nr_swap_pages) * 2 < total_swap_pages;
+}
+
+static inline long get_nr_swap_pages(void)
+{
+	return atomic_long_read(&nr_swap_pages);
+}
+
 extern void si_swapinfo(struct sysinfo *);
 extern swp_entry_t get_swap_page(void);
 extern swp_entry_t get_swap_page_of_type(int);
@@ -351,6 +372,8 @@
 extern unsigned int count_swap_pages(int, int);
 extern sector_t map_swap_page(struct page *, struct block_device **);
 extern sector_t swapdev_block(int, pgoff_t);
+extern int page_swapcount(struct page *);
+extern struct swap_info_struct *page_swap_info(struct page *);
 extern int reuse_swap_page(struct page *);
 extern int try_to_free_swap(struct page *);
 struct backing_dev_info;
@@ -368,9 +391,10 @@
 
 #else /* CONFIG_SWAP */
 
-#define nr_swap_pages				0L
+#define get_nr_swap_pages()			0L
 #define total_swap_pages			0L
 #define total_swapcache_pages			0UL
+#define vm_swap_full()				0
 
 #define si_swapinfo(val) \
 	do { (val)->freeswap = (val)->totalswap = 0; } while (0)
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index ed6d41b..faf98fe 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -102,6 +102,7 @@
 	enum thermal_trip_type trip;
 	int (*notify)(enum thermal_trip_type type, int temp, void *data);
 	void *data;
+	uint8_t active;
 	struct list_head list;
 };
 
@@ -189,6 +190,8 @@
 int sensor_get_id(char *name);
 int sensor_set_trip(uint32_t sensor_id, struct sensor_threshold *threshold);
 int sensor_cancel_trip(uint32_t sensor_id, struct sensor_threshold *threshold);
+int sensor_activate_trip(uint32_t sensor_id, struct sensor_threshold *threshold,
+			bool enable);
 int thermal_sensor_trip(struct thermal_zone_device *tz,
 		enum thermal_trip_type trip, long temp);
 
diff --git a/include/linux/usb/android.h b/include/linux/usb/android.h
index e17e978..8d5e51b 100644
--- a/include/linux/usb/android.h
+++ b/include/linux/usb/android.h
@@ -19,12 +19,16 @@
 
 #include <linux/usb/composite.h>
 
+#define MAX_STREAMING_FUNCS 3
+#define FUNC_NAME_LEN 10
 struct android_usb_platform_data {
 	int (*update_pid_and_serial_num)(uint32_t, const char *);
 	u32 swfi_latency;
 	u8 usb_core_id;
 	bool cdrom;
 	bool internal_ums;
+	char streaming_func[MAX_STREAMING_FUNCS][FUNC_NAME_LEN];
+	int  streaming_func_count;
 };
 
 #ifndef CONFIG_TARGET_CORE
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index fea832e..3844f41 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -508,6 +508,7 @@
  * @dev: Driver model state for this abstract device.
  * @usb_core_id: Identifies the usb core controlled by this usb_gadget.
  *		 Used in case of more then one core operates concurrently.
+ * @streaming_enabled: Enable streaming mode with usb core.
  *
  * Gadgets have a mostly-portable "gadget driver" implementing device
  * functions, handling all usb configurations and interfaces.  Gadget
@@ -546,6 +547,7 @@
 	struct device			dev;
 	u8				usb_core_id;
 	bool				l1_supported;
+	bool				streaming_enabled;
 };
 
 static inline void set_gadget_data(struct usb_gadget *gadget, void *data)
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h
index be92ca7..9eb9cd8 100644
--- a/include/linux/usb/msm_hsusb.h
+++ b/include/linux/usb/msm_hsusb.h
@@ -229,7 +229,9 @@
  *              between 1 to 7.
  * @l1_supported: enable link power management support.
  * @dpdm_pulldown_added: Indicates whether pull down resistors are
-		connected on data lines or not.
+ *		connected on data lines or not.
+ * @enable_ahb2ahb_bypass: Indicates whether enable AHB2AHB BYPASS
+ *		mode with controller in device mode.
  */
 struct msm_otg_platform_data {
 	int *phy_init_seq;
@@ -258,6 +260,7 @@
 	int log2_itc;
 	bool l1_supported;
 	bool dpdm_pulldown_added;
+	bool enable_ahb2ahb_bypass;
 };
 
 /* phy related flags */
@@ -339,6 +342,7 @@
  * @host_bus_suspend: indicates host bus suspend or not.
  * @chg_check_timer: The timer used to implement the workaround to detect
  *               very slow plug in of wall charger.
+ * @ui_enabled: USB Intterupt is enabled or disabled.
  */
 struct msm_otg {
 	struct usb_phy phy;
@@ -449,6 +453,7 @@
 	bool ext_chg_opened;
 	bool ext_chg_active;
 	struct completion ext_chg_wait;
+	int ui_enabled;
 };
 
 struct ci13xxx_platform_data {
@@ -460,6 +465,7 @@
 	int log2_itc;
 	void *prv_data;
 	bool l1_supported;
+	bool enable_ahb2ahb_bypass;
 };
 
 /**
diff --git a/include/linux/usb/msm_hsusb_hw.h b/include/linux/usb/msm_hsusb_hw.h
index 58ab4eb..2a5ebd4 100644
--- a/include/linux/usb/msm_hsusb_hw.h
+++ b/include/linux/usb/msm_hsusb_hw.h
@@ -49,6 +49,10 @@
 #define L1_CONFIG_PHY_LPM	BIT(10)
 #define L1_CONFIG_PLL		BIT(11)
 
+#define AHB2AHB_BYPASS		BIT(31)
+#define AHB2AHB_BYPASS_BIT_MASK	BIT(31)
+#define AHB2AHB_BYPASS_CLEAR	(0 << 31)
+
 #define PORTSC_PHCD            (1 << 23) /* phy suspend mode */
 #define PORTSC_PTS_MASK         (3 << 30)
 #define PORTSC_PTS_ULPI         (3 << 30)
diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
index 1d10474..2d59889 100644
--- a/include/linux/vmstat.h
+++ b/include/linux/vmstat.h
@@ -140,7 +140,6 @@
 }
 
 extern unsigned long global_reclaimable_pages(void);
-extern unsigned long zone_reclaimable_pages(struct zone *zone);
 
 #ifdef CONFIG_NUMA
 /*
diff --git a/include/media/msm_cam_sensor.h b/include/media/msm_cam_sensor.h
index 326e8bf..c48586e 100644
--- a/include/media/msm_cam_sensor.h
+++ b/include/media/msm_cam_sensor.h
@@ -48,6 +48,12 @@
 
 #define MAX_AF_ITERATIONS 3
 
+enum flash_type {
+	LED_FLASH = 1,
+	STROBE_FLASH,
+	GPIO_FLASH
+};
+
 enum msm_camera_i2c_reg_addr_type {
 	MSM_CAMERA_I2C_BYTE_ADDR = 1,
 	MSM_CAMERA_I2C_WORD_ADDR,
@@ -565,6 +571,7 @@
 
 struct msm_camera_led_cfg_t {
 	enum msm_camera_led_config_t cfgtype;
+	uint32_t led_current;
 };
 
 #define VIDIOC_MSM_SENSOR_CFG \
diff --git a/include/media/msm_media_info.h b/include/media/msm_media_info.h
index 65831db..ddf9c8e 100644
--- a/include/media/msm_media_info.h
+++ b/include/media/msm_media_info.h
@@ -6,7 +6,76 @@
 #endif
 
 enum color_fmts {
+	/* Venus NV12:
+	 * YUV 4:2:0 image with a plane of 8 bit Y samples followed
+	 * by an interleaved U/V plane containing 8 bit 2x2 subsampled
+	 * colour difference samples.
+	 *
+	 * <-------- Y/UV_Stride -------->
+	 * <------- Width ------->
+	 * Y Y Y Y Y Y Y Y Y Y Y Y X X X X  ^           ^
+	 * Y Y Y Y Y Y Y Y Y Y Y Y X X X X  |           |
+	 * Y Y Y Y Y Y Y Y Y Y Y Y X X X X  Height      |
+	 * Y Y Y Y Y Y Y Y Y Y Y Y X X X X  |          Y_Scanlines
+	 * Y Y Y Y Y Y Y Y Y Y Y Y X X X X  |           |
+	 * Y Y Y Y Y Y Y Y Y Y Y Y X X X X  |           |
+	 * Y Y Y Y Y Y Y Y Y Y Y Y X X X X  |           |
+	 * Y Y Y Y Y Y Y Y Y Y Y Y X X X X  V           |
+	 * X X X X X X X X X X X X X X X X              |
+	 * X X X X X X X X X X X X X X X X              |
+	 * X X X X X X X X X X X X X X X X              |
+	 * X X X X X X X X X X X X X X X X              V
+	 * U V U V U V U V U V U V X X X X  ^
+	 * U V U V U V U V U V U V X X X X  |
+	 * U V U V U V U V U V U V X X X X  |
+	 * U V U V U V U V U V U V X X X X  UV_Scanlines
+	 * X X X X X X X X X X X X X X X X  |
+	 * X X X X X X X X X X X X X X X X  V
+	 * X X X X X X X X X X X X X X X X  --> Buffer size alignment
+	 *
+	 * Y_Stride : Width aligned to 128
+	 * UV_Stride : Width aligned to 128
+	 * Y_Scanlines: Height aligned to 32
+	 * UV_Scanlines: Height/2 aligned to 16
+	 * Total size = align((Y_Stride * Y_Scanlines
+	 *          + UV_Stride * UV_Scanlines + 4096), 4096)
+	 */
 	COLOR_FMT_NV12,
+
+	/* Venus NV21:
+	 * YUV 4:2:0 image with a plane of 8 bit Y samples followed
+	 * by an interleaved V/U plane containing 8 bit 2x2 subsampled
+	 * colour difference samples.
+	 *
+	 * <-------- Y/UV_Stride -------->
+	 * <------- Width ------->
+	 * Y Y Y Y Y Y Y Y Y Y Y Y X X X X  ^           ^
+	 * Y Y Y Y Y Y Y Y Y Y Y Y X X X X  |           |
+	 * Y Y Y Y Y Y Y Y Y Y Y Y X X X X  Height      |
+	 * Y Y Y Y Y Y Y Y Y Y Y Y X X X X  |          Y_Scanlines
+	 * Y Y Y Y Y Y Y Y Y Y Y Y X X X X  |           |
+	 * Y Y Y Y Y Y Y Y Y Y Y Y X X X X  |           |
+	 * Y Y Y Y Y Y Y Y Y Y Y Y X X X X  |           |
+	 * Y Y Y Y Y Y Y Y Y Y Y Y X X X X  V           |
+	 * X X X X X X X X X X X X X X X X              |
+	 * X X X X X X X X X X X X X X X X              |
+	 * X X X X X X X X X X X X X X X X              |
+	 * X X X X X X X X X X X X X X X X              V
+	 * V U V U V U V U V U V U X X X X  ^
+	 * V U V U V U V U V U V U X X X X  |
+	 * V U V U V U V U V U V U X X X X  |
+	 * V U V U V U V U V U V U X X X X  UV_Scanlines
+	 * X X X X X X X X X X X X X X X X  |
+	 * X X X X X X X X X X X X X X X X  V
+	 * X X X X X X X X X X X X X X X X  --> Padding & Buffer size alignment
+	 *
+	 * Y_Stride : Width aligned to 128
+	 * UV_Stride : Width aligned to 128
+	 * Y_Scanlines: Height aligned to 32
+	 * UV_Scanlines: Height/2 aligned to 16
+	 * Total size = align((Y_Stride * Y_Scanlines
+	 *          + UV_Stride * UV_Scanlines + 4096), 4096)
+	 */
 	COLOR_FMT_NV21,
 };
 
diff --git a/include/media/msm_vidc.h b/include/media/msm_vidc.h
index 868be9f..bc85ebb 100644
--- a/include/media/msm_vidc.h
+++ b/include/media/msm_vidc.h
@@ -18,6 +18,41 @@
 	MSM_VIDC_MAX_DEVICES,
 };
 
+/* NOTE: if you change this enum you MUST update the
+ * "buffer-type-tz-usage-table" for any affected target
+ * in arch/arm/boot/dts/<arch>.dtsi
+ */
+enum hal_buffer {
+	HAL_BUFFER_INPUT = 0x1,
+	HAL_BUFFER_OUTPUT = 0x2,
+	HAL_BUFFER_OUTPUT2 = 0x4,
+	HAL_BUFFER_EXTRADATA_INPUT = 0x8,
+	HAL_BUFFER_EXTRADATA_OUTPUT = 0x10,
+	HAL_BUFFER_EXTRADATA_OUTPUT2 = 0x20,
+	HAL_BUFFER_INTERNAL_SCRATCH = 0x40,
+	HAL_BUFFER_INTERNAL_SCRATCH_1 = 0x80,
+	HAL_BUFFER_INTERNAL_SCRATCH_2 = 0x100,
+	HAL_BUFFER_INTERNAL_PERSIST = 0x200,
+	HAL_BUFFER_INTERNAL_PERSIST_1 = 0x400,
+	HAL_BUFFER_INTERNAL_CMD_QUEUE = 0x800,
+};
+
+struct msm_smem {
+	int mem_type;
+	size_t size;
+	void *kvaddr;
+	unsigned long device_addr;
+	u32 flags;
+	void *smem_priv;
+	enum hal_buffer buffer_type;
+};
+
+enum smem_cache_ops {
+	SMEM_CACHE_CLEAN,
+	SMEM_CACHE_INVALIDATE,
+	SMEM_CACHE_CLEAN_INVALIDATE,
+};
+
 void *msm_vidc_open(int core_id, int session_type);
 int msm_vidc_close(void *instance);
 int msm_vidc_querycap(void *instance, struct v4l2_capability *cap);
@@ -47,6 +82,18 @@
 int msm_vidc_wait(void *instance);
 int msm_vidc_s_parm(void *instance, struct v4l2_streamparm *a);
 int msm_vidc_enum_framesizes(void *instance, struct v4l2_frmsizeenum *fsize);
+struct msm_smem *msm_vidc_smem_alloc(void *instance,
+			size_t size, u32 align, u32 flags,
+			enum hal_buffer buffer_type, int map_kernel);
+void msm_vidc_smem_free(void *instance, struct msm_smem *mem);
+int msm_vidc_smem_cache_operations(void *instance,
+		struct msm_smem *mem, enum smem_cache_ops);
+struct msm_smem *msm_vidc_smem_user_to_kernel(void *instance,
+			int fd, u32 offset, enum hal_buffer buffer_type);
+int msm_vidc_smem_get_domain_partition(void *instance,
+		u32 flags, enum hal_buffer buffer_type,
+		int *domain_num, int *partition_num);
+void *msm_vidc_smem_get_client(void *instance);
 #endif
 struct msm_vidc_interlace_payload {
 	unsigned int format;
@@ -93,6 +140,27 @@
 	unsigned int num_panscan_windows;
 	struct msm_vidc_panscan_window wnd[1];
 };
+struct msm_vidc_s3d_frame_packing_payload {
+	unsigned int fpa_id;
+	unsigned int cancel_flag;
+	unsigned int fpa_type;
+	unsigned int quin_cunx_flag;
+	unsigned int content_interprtation_type;
+	unsigned int spatial_flipping_flag;
+	unsigned int frame0_flipped_flag;
+	unsigned int field_views_flag;
+	unsigned int current_frame_is_frame0_flag;
+	unsigned int frame0_self_contained_flag;
+	unsigned int frame1_self_contained_flag;
+	unsigned int frame0_graid_pos_x;
+	unsigned int frame0_graid_pos_y;
+	unsigned int frame1_graid_pos_x;
+	unsigned int frame1_graid_pos_y;
+	unsigned int fpa_reserved_byte;
+	unsigned int fpa_repetition_period;
+	unsigned int fpa_extension_flag;
+};
+
 enum msm_vidc_extradata_type {
 	EXTRADATA_NONE = 0x00000000,
 	EXTRADATA_MB_QUANTIZATION = 0x00000001,
diff --git a/include/media/msmb_pproc.h b/include/media/msmb_pproc.h
index de42c38..ed4ffa2 100644
--- a/include/media/msmb_pproc.h
+++ b/include/media/msmb_pproc.h
@@ -90,6 +90,7 @@
 	uint32_t offset;
 	uint8_t native_buff;
 	uint8_t processed_divert;
+	uint32_t identity;
 };
 
 struct msm_cpp_stream_buff_info_t {
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 4ecadd8..7932ba1 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1801,22 +1801,28 @@
  * enum wiphy_flags - wiphy capability flags
  *
  * @WIPHY_FLAG_CUSTOM_REGULATORY:  tells us the driver for this device
- * 	has its own custom regulatory domain and cannot identify the
- * 	ISO / IEC 3166 alpha2 it belongs to. When this is enabled
- * 	we will disregard the first regulatory hint (when the
- * 	initiator is %REGDOM_SET_BY_CORE).
- * @WIPHY_FLAG_STRICT_REGULATORY: tells us the driver for this device will
- *	ignore regulatory domain settings until it gets its own regulatory
- *	domain via its regulatory_hint() unless the regulatory hint is
- *	from a country IE. After its gets its own regulatory domain it will
- *	only allow further regulatory domain settings to further enhance
- *	compliance. For example if channel 13 and 14 are disabled by this
- *	regulatory domain no user regulatory domain can enable these channels
- *	at a later time. This can be used for devices which do not have
- *	calibration information guaranteed for frequencies or settings
- *	outside of its regulatory domain. If used in combination with
- *	WIPHY_FLAG_CUSTOM_REGULATORY the inspected country IE power settings
- *	will be followed.
+ *	has its own custom regulatory domain and cannot identify the
+ *	ISO / IEC 3166 alpha2 it belongs to. When this is enabled
+ *	we will disregard the first regulatory hint (when the
+ *	initiator is %REGDOM_SET_BY_CORE). wiphys can set the custom
+ *	regulatory domain using wiphy_apply_custom_regulatory()
+ *	prior to wiphy registration.
+ * @WIPHY_FLAG_STRICT_REGULATORY: tells us that the wiphy for this device
+ *	has regulatory domain that it wishes to be considered as the
+ *	superset for regulatory rules. After this device gets its regulatory
+ *	domain programmed further regulatory hints shall only be considered
+ *	for this device to enhance regulatory compliance, forcing the
+ *	device to only possibly use subsets of the original regulatory
+ *	rules. For example if channel 13 and 14 are disabled by this
+ *	device's regulatory domain no user specified regulatory hint which
+ *	has these channels enabled would enable them for this wiphy,
+ *	the device's original regulatory domain will be trusted as the
+ *	base. You can program the superset of regulatory rules for this
+ *	wiphy with regulatory_hint() for cards programmed with an
+ *	ISO3166-alpha2 country code. wiphys that use regulatory_hint()
+ *	will have their wiphy->regd programmed once the regulatory
+ *	domain is set, and all other regulatory hints will be ignored
+ *	until their own regulatory domain gets programmed.
  * @WIPHY_FLAG_DISABLE_BEACON_HINTS: enable this if your driver needs to ensure
  *	that passive scan flags and beaconing flags may not be lifted by
  *	cfg80211 due to regulatory beacon hints. For more information on beacon
@@ -1884,6 +1890,34 @@
 };
 
 /**
+ * enum nl80211_country_ie_pref - country IE processing preferences
+ *
+ * enumerates the different preferences a 802.11 card can advertize
+ * for parsing the country IEs. As per the current implementation
+ * country IEs are only used derive the apha2, the information
+ * for power settings that comes with the country IE is ignored
+ * and we use the power settings from regdb.
+ *
+ * @NL80211_COUNTRY_IE_FOLLOW_CORE - This is the default behaviour.
+ *	It allows the core to update channel flags according to the
+ *	ISO3166-alpha2 in the country IE. The applied power is -
+ *	MIN(power specified by custom domain, power obtained from regdb)
+ * @NL80211_COUNTRY_IE_FOLLOW_POWER - for devices that have a
+ *	preference that even though they may have programmed their own
+ *	custom power setting prior to wiphy registration, they want
+ *	to ensure their channel power settings are updated for this
+ *	connection with the power settings derived from alpha2 of the
+ *	country IE.
+ * @NL80211_COUNTRY_IE_IGNORE_CORE - for devices that have a preference to
+ *	to ignore all country IE information processed by the core.
+ */
+enum nl80211_country_ie_pref {
+	NL80211_COUNTRY_IE_FOLLOW_CORE,
+	NL80211_COUNTRY_IE_FOLLOW_POWER,
+	NL80211_COUNTRY_IE_IGNORE_CORE,
+};
+
+/**
  * struct ieee80211_iface_limit - limit on certain interface types
  * @max: maximum number of interfaces of these types
  * @types: interface types (bits)
@@ -2100,6 +2134,8 @@
  *
  * @max_acl_mac_addrs: Maximum number of MAC addresses that the device
  *	supports for ACL.
+ * @country_ie_pref: country IE processing preferences specified
+ *	by enum nl80211_country_ie_pref
  */
 struct wiphy {
 	/* assign these fields before you register the wiphy */
@@ -2164,6 +2200,8 @@
 	 */
 	u32 probe_resp_offload;
 
+	u8 country_ie_pref;
+
 	/* If multiple wiphys are registered and you're handed e.g.
 	 * a regular netdev with assigned ieee80211_ptr, you won't
 	 * know whether it points to a wiphy your driver has registered
@@ -2691,6 +2729,30 @@
 extern int regulatory_hint(struct wiphy *wiphy, const char *alpha2);
 
 /**
+ * regulatory_hint_user - hint to the wireless core a regulatory domain
+ * which the driver has received from an application
+ * @alpha2: the ISO/IEC 3166 alpha2 the driver claims its regulatory domain
+ * 	should be in. If @rd is set this should be NULL. Note that if you
+ * 	set this to NULL you should still set rd->alpha2 to some accepted
+ * 	alpha2.
+ *
+ * Wireless drivers can use this function to hint to the wireless core
+ * the current regulatory domain as specified by trusted applications,
+ * it is the driver's responsibilty to estbalish which applications it
+ * trusts.
+ *
+ * The wiphy should be registered to cfg80211 prior to this call.
+ * For cfg80211 drivers this means you must first use wiphy_register(),
+ * for mac80211 drivers you must first use ieee80211_register_hw().
+ *
+ * Drivers should check the return value, its possible you can get
+ * an -ENOMEM or an -EINVAL.
+ *
+ * Return: 0 on success. -ENOMEM, -EINVAL.
+ */
+extern int regulatory_hint_user(const char *alpha2);
+
+/**
  * wiphy_apply_custom_regulatory - apply a custom driver regulatory domain
  * @wiphy: the wireless device we want to process the regulatory domain on
  * @regd: the custom regulatory domain to use for this wiphy
diff --git a/include/sound/apr_audio-v2.h b/include/sound/apr_audio-v2.h
index bbda72e..104f86e 100644
--- a/include/sound/apr_audio-v2.h
+++ b/include/sound/apr_audio-v2.h
@@ -3676,6 +3676,7 @@
 } __packed;
 
 #define ASM_SESSION_CMD_PAUSE 0x00010BD3
+#define ASM_SESSION_CMD_SUSPEND 0x00010DEC
 #define ASM_SESSION_CMD_GET_SESSIONTIME_V3 0x00010D9D
 #define ASM_SESSION_CMD_REGISTER_FOR_RX_UNDERFLOW_EVENTS 0x00010BD5
 
diff --git a/include/sound/q6asm-v2.h b/include/sound/q6asm-v2.h
index 0dd1f1c..65ca46f 100644
--- a/include/sound/q6asm-v2.h
+++ b/include/sound/q6asm-v2.h
@@ -54,6 +54,7 @@
 #define CMD_EOS            0x0003
 #define CMD_CLOSE          0x0004
 #define CMD_OUT_FLUSH      0x0005
+#define CMD_SUSPEND        0x0006
 
 /* bit 0:1 represents priority of stream */
 #define STREAM_PRIORITY_NORMAL	0x0000
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index fed2e0a..4a606af 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -442,6 +442,11 @@
 	snd_soc_dapm_siggen,		/* signal generator */
 };
 
+enum snd_soc_dapm_subclass {
+	SND_SOC_DAPM_CLASS_INIT	= 0,
+	SND_SOC_DAPM_CLASS_PCM	= 1,
+};
+
 /*
  * DAPM audio route definition.
  *
diff --git a/include/sound/soc.h b/include/sound/soc.h
index b1e536d..50d0471 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -561,6 +561,7 @@
 #endif
 
 struct snd_soc_jack {
+	struct mutex mutex;
 	struct snd_jack *jack;
 	struct snd_soc_codec *codec;
 	struct list_head pins;
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index d66b213..8432330 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -681,23 +681,69 @@
  */
 static void timekeeping_resume(void)
 {
+	struct timekeeper *tk = &timekeeper;
+	struct clocksource *clock = tk->clock;
 	unsigned long flags;
-	struct timespec ts;
+	struct timespec ts_new, ts_delta;
+	cycle_t cycle_now, cycle_delta;
+	bool suspendtime_found = false;
 
-	read_persistent_clock(&ts);
+	read_persistent_clock(&ts_new);
 
 	clocksource_resume();
 
 	write_seqlock_irqsave(&timekeeper.lock, flags);
 
-	if (timespec_compare(&ts, &timekeeping_suspend_time) > 0) {
-		ts = timespec_sub(ts, timekeeping_suspend_time);
-		__timekeeping_inject_sleeptime(&ts);
+	/*
+	 * After system resumes, we need to calculate the suspended time and
+	 * compensate it for the OS time. There are 3 sources that could be
+	 * used: Nonstop clocksource during suspend, persistent clock and rtc
+	 * device.
+	 *
+	 * One specific platform may have 1 or 2 or all of them, and the
+	 * preference will be:
+	 *	suspend-nonstop clocksource -> persistent clock -> rtc
+	 * The less preferred source will only be tried if there is no better
+	 * usable source. The rtc part is handled separately in rtc core code.
+	 */
+	cycle_now = clock->read(clock);
+	if ((clock->flags & CLOCK_SOURCE_SUSPEND_NONSTOP) &&
+		cycle_now > clock->cycle_last) {
+		u64 num, max = ULLONG_MAX;
+		u32 mult = clock->mult;
+		u32 shift = clock->shift;
+		s64 nsec = 0;
+
+		cycle_delta = (cycle_now - clock->cycle_last) & clock->mask;
+
+		/*
+		 * "cycle_delta * mutl" may cause 64 bits overflow, if the
+		 * suspended time is too long. In that case we need do the
+		 * 64 bits math carefully
+		 */
+		do_div(max, mult);
+		if (cycle_delta > max) {
+			num = div64_u64(cycle_delta, max);
+			nsec = (((u64) max * mult) >> shift) * num;
+			cycle_delta -= num * max;
+		}
+		nsec += ((u64) cycle_delta * mult) >> shift;
+
+		ts_delta = ns_to_timespec(nsec);
+		suspendtime_found = true;
+	} else if (timespec_compare(&ts_new, &timekeeping_suspend_time) > 0) {
+		ts_delta = timespec_sub(ts_new, timekeeping_suspend_time);
+		suspendtime_found = true;
 	}
-	/* re-base the last cycle value */
-	timekeeper.clock->cycle_last = timekeeper.clock->read(timekeeper.clock);
-	timekeeper.ntp_error = 0;
+
+	if (suspendtime_found)
+		__timekeeping_inject_sleeptime(&ts_delta);
+
+	/* Re-base the last cycle value */
+	clock->cycle_last = cycle_now;
+	tk->ntp_error = 0;
 	timekeeping_suspended = 0;
+	timekeeping_update(false);
 	write_sequnlock_irqrestore(&timekeeper.lock, flags);
 
 	touch_softlockup_watchdog();
diff --git a/mm/internal.h b/mm/internal.h
index 3439ef4..f5369cc 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -90,6 +90,8 @@
  */
 extern int isolate_lru_page(struct page *page);
 extern void putback_lru_page(struct page *page);
+extern unsigned long zone_reclaimable_pages(struct zone *zone);
+extern bool zone_reclaimable(struct zone *zone);
 
 /*
  * in mm/page_alloc.c
diff --git a/mm/mmap.c b/mm/mmap.c
index 848ef52..9932edb 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -133,7 +133,7 @@
 		 */
 		free -= global_page_state(NR_SHMEM);
 
-		free += nr_swap_pages;
+		free += get_nr_swap_pages();
 
 		/*
 		 * Any slabs which are created with the
diff --git a/mm/nommu.c b/mm/nommu.c
index bb8f4f0..6bb7042 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -1928,7 +1928,7 @@
 		 */
 		free -= global_page_state(NR_SHMEM);
 
-		free += nr_swap_pages;
+		free += get_nr_swap_pages();
 
 		/*
 		 * Any slabs which are created with the
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 26adea8..a5e8dc2 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -34,8 +34,11 @@
 #include <linux/syscalls.h>
 #include <linux/buffer_head.h> /* __set_page_dirty_buffers */
 #include <linux/pagevec.h>
+#include <linux/mm_inline.h>
 #include <trace/events/writeback.h>
 
+#include "internal.h"
+
 /*
  * Sleep at most 200ms at a time in balance_dirty_pages().
  */
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 46ccd2f..a1e4f77 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -57,6 +57,7 @@
 #include <linux/ftrace_event.h>
 #include <linux/memcontrol.h>
 #include <linux/prefetch.h>
+#include <linux/mm_inline.h>
 #include <linux/migrate.h>
 #include <linux/page-debug-flags.h>
 
@@ -647,7 +648,6 @@
 	int mt = 0;
 
 	spin_lock(&zone->lock);
-	zone->all_unreclaimable = 0;
 	zone->pages_scanned = 0;
 
 	while (to_free) {
@@ -693,7 +693,6 @@
 				int migratetype)
 {
 	spin_lock(&zone->lock);
-	zone->all_unreclaimable = 0;
 	zone->pages_scanned = 0;
 
 	__free_one_page(page, zone, order, migratetype);
@@ -2997,7 +2996,7 @@
 			K(zone_page_state(zone, NR_FREE_CMA_PAGES)),
 			K(zone_page_state(zone, NR_WRITEBACK_TEMP)),
 			zone->pages_scanned,
-			(zone->all_unreclaimable ? "yes" : "no")
+			(!zone_reclaimable(zone) ? "yes" : "no")
 			);
 		printk("lowmem_reserve[]:");
 		for (i = 0; i < MAX_NR_ZONES; i++)
diff --git a/mm/page_io.c b/mm/page_io.c
index dc76b4d..1499e1c 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -1,3 +1,4 @@
+
 /*
  *  linux/mm/page_io.c
  *
@@ -18,8 +19,16 @@
 #include <linux/bio.h>
 #include <linux/swapops.h>
 #include <linux/writeback.h>
+#include <linux/blkdev.h>
+#include <linux/ratelimit.h>
 #include <asm/pgtable.h>
 
+/*
+ * We don't need to see swap errors more than once every 1 second to know
+ * that a problem is occurring.
+ */
+#define SWAP_ERROR_LOG_RATE_MS 1000
+
 static struct bio *get_swap_bio(gfp_t gfp_flags,
 				struct page *page, bio_end_io_t end_io)
 {
@@ -44,6 +53,7 @@
 {
 	const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
 	struct page *page = bio->bi_io_vec[0].bv_page;
+	static unsigned long swap_error_rs_time;
 
 	if (!uptodate) {
 		SetPageError(page);
@@ -56,7 +66,9 @@
 		 * Also clear PG_reclaim to avoid rotate_reclaimable_page()
 		 */
 		set_page_dirty(page);
-		printk(KERN_ALERT "Write-error on swap-device (%u:%u:%Lu)\n",
+		if (printk_timed_ratelimit(&swap_error_rs_time,
+					   SWAP_ERROR_LOG_RATE_MS))
+			printk(KERN_ALERT "Write-error on swap-device (%u:%u:%Lu)\n",
 				imajor(bio->bi_bdev->bd_inode),
 				iminor(bio->bi_bdev->bd_inode),
 				(unsigned long long)bio->bi_sector);
@@ -78,9 +90,54 @@
 				imajor(bio->bi_bdev->bd_inode),
 				iminor(bio->bi_bdev->bd_inode),
 				(unsigned long long)bio->bi_sector);
-	} else {
-		SetPageUptodate(page);
+		goto out;
 	}
+
+	SetPageUptodate(page);
+
+	/*
+	 * There is no guarantee that the page is in swap cache - the software
+	 * suspend code (at least) uses end_swap_bio_read() against a non-
+	 * swapcache page.  So we must check PG_swapcache before proceeding with
+	 * this optimization.
+	 */
+	if (likely(PageSwapCache(page))) {
+		struct swap_info_struct *sis;
+
+		sis = page_swap_info(page);
+		if (sis->flags & SWP_BLKDEV) {
+			/*
+			 * The swap subsystem performs lazy swap slot freeing,
+			 * expecting that the page will be swapped out again.
+			 * So we can avoid an unnecessary write if the page
+			 * isn't redirtied.
+			 * This is good for real swap storage because we can
+			 * reduce unnecessary I/O and enhance wear-leveling
+			 * if an SSD is used as the as swap device.
+			 * But if in-memory swap device (eg zram) is used,
+			 * this causes a duplicated copy between uncompressed
+			 * data in VM-owned memory and compressed data in
+			 * zram-owned memory.  So let's free zram-owned memory
+			 * and make the VM-owned decompressed page *dirty*,
+			 * so the page should be swapped out somewhere again if
+			 * we again wish to reclaim it.
+			 */
+			struct gendisk *disk = sis->bdev->bd_disk;
+			if (disk->fops->swap_slot_free_notify) {
+				swp_entry_t entry;
+				unsigned long offset;
+
+				entry.val = page_private(page);
+				offset = swp_offset(entry);
+
+				SetPageDirty(page);
+				disk->fops->swap_slot_free_notify(sis->bdev,
+						offset);
+			}
+		}
+	}
+
+out:
 	unlock_page(page);
 	bio_put(bio);
 }
diff --git a/mm/swap_state.c b/mm/swap_state.c
index 4c5ff7f..eb6a79c 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -58,7 +58,8 @@
 	printk("Swap cache stats: add %lu, delete %lu, find %lu/%lu\n",
 		swap_cache_info.add_total, swap_cache_info.del_total,
 		swap_cache_info.find_success, swap_cache_info.find_total);
-	printk("Free swap  = %ldkB\n", nr_swap_pages << (PAGE_SHIFT - 10));
+	printk("Free swap  = %ldkB\n",
+		get_nr_swap_pages() << (PAGE_SHIFT - 10));
 	printk("Total swap = %lukB\n", total_swap_pages << (PAGE_SHIFT - 10));
 }
 
diff --git a/mm/swapfile.c b/mm/swapfile.c
index fafc26d..9ae4c8d 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -31,6 +31,7 @@
 #include <linux/memcontrol.h>
 #include <linux/poll.h>
 #include <linux/oom.h>
+#include <linux/export.h>
 
 #include <asm/pgtable.h>
 #include <asm/tlbflush.h>
@@ -44,9 +45,11 @@
 
 static DEFINE_SPINLOCK(swap_lock);
 static unsigned int nr_swapfiles;
-long nr_swap_pages;
+atomic_long_t nr_swap_pages;
+/* protected with swap_lock. reading in vm_swap_full() doesn't need lock */
 long total_swap_pages;
 static int least_priority;
+static atomic_t highest_priority_index = ATOMIC_INIT(-1);
 
 static const char Bad_file[] = "Bad swap file entry ";
 static const char Unused_file[] = "Unused swap file entry ";
@@ -220,7 +223,7 @@
 			si->lowest_alloc = si->max;
 			si->highest_alloc = 0;
 		}
-		spin_unlock(&swap_lock);
+		spin_unlock(&si->lock);
 
 		/*
 		 * If seek is expensive, start searching for new cluster from
@@ -239,7 +242,7 @@
 			if (si->swap_map[offset])
 				last_in_cluster = offset + SWAPFILE_CLUSTER;
 			else if (offset == last_in_cluster) {
-				spin_lock(&swap_lock);
+				spin_lock(&si->lock);
 				offset -= SWAPFILE_CLUSTER - 1;
 				si->cluster_next = offset;
 				si->cluster_nr = SWAPFILE_CLUSTER - 1;
@@ -260,7 +263,7 @@
 			if (si->swap_map[offset])
 				last_in_cluster = offset + SWAPFILE_CLUSTER;
 			else if (offset == last_in_cluster) {
-				spin_lock(&swap_lock);
+				spin_lock(&si->lock);
 				offset -= SWAPFILE_CLUSTER - 1;
 				si->cluster_next = offset;
 				si->cluster_nr = SWAPFILE_CLUSTER - 1;
@@ -274,7 +277,7 @@
 		}
 
 		offset = scan_base;
-		spin_lock(&swap_lock);
+		spin_lock(&si->lock);
 		si->cluster_nr = SWAPFILE_CLUSTER - 1;
 		si->lowest_alloc = 0;
 	}
@@ -290,9 +293,9 @@
 	/* reuse swap entry of cache-only swap if not busy. */
 	if (vm_swap_full() && si->swap_map[offset] == SWAP_HAS_CACHE) {
 		int swap_was_freed;
-		spin_unlock(&swap_lock);
+		spin_unlock(&si->lock);
 		swap_was_freed = __try_to_reclaim_swap(si, offset);
-		spin_lock(&swap_lock);
+		spin_lock(&si->lock);
 		/* entry was freed successfully, try to use this again */
 		if (swap_was_freed)
 			goto checks;
@@ -332,13 +335,13 @@
 			    si->lowest_alloc <= last_in_cluster)
 				last_in_cluster = si->lowest_alloc - 1;
 			si->flags |= SWP_DISCARDING;
-			spin_unlock(&swap_lock);
+			spin_unlock(&si->lock);
 
 			if (offset < last_in_cluster)
 				discard_swap_cluster(si, offset,
 					last_in_cluster - offset + 1);
 
-			spin_lock(&swap_lock);
+			spin_lock(&si->lock);
 			si->lowest_alloc = 0;
 			si->flags &= ~SWP_DISCARDING;
 
@@ -352,10 +355,10 @@
 			 * could defer that delay until swap_writepage,
 			 * but it's easier to keep this self-contained.
 			 */
-			spin_unlock(&swap_lock);
+			spin_unlock(&si->lock);
 			wait_on_bit(&si->flags, ilog2(SWP_DISCARDING),
 				wait_for_discard, TASK_UNINTERRUPTIBLE);
-			spin_lock(&swap_lock);
+			spin_lock(&si->lock);
 		} else {
 			/*
 			 * Note pages allocated by racing tasks while
@@ -371,14 +374,14 @@
 	return offset;
 
 scan:
-	spin_unlock(&swap_lock);
+	spin_unlock(&si->lock);
 	while (++offset <= si->highest_bit) {
 		if (!si->swap_map[offset]) {
-			spin_lock(&swap_lock);
+			spin_lock(&si->lock);
 			goto checks;
 		}
 		if (vm_swap_full() && si->swap_map[offset] == SWAP_HAS_CACHE) {
-			spin_lock(&swap_lock);
+			spin_lock(&si->lock);
 			goto checks;
 		}
 		if (unlikely(--latency_ration < 0)) {
@@ -389,11 +392,11 @@
 	offset = si->lowest_bit;
 	while (++offset < scan_base) {
 		if (!si->swap_map[offset]) {
-			spin_lock(&swap_lock);
+			spin_lock(&si->lock);
 			goto checks;
 		}
 		if (vm_swap_full() && si->swap_map[offset] == SWAP_HAS_CACHE) {
-			spin_lock(&swap_lock);
+			spin_lock(&si->lock);
 			goto checks;
 		}
 		if (unlikely(--latency_ration < 0)) {
@@ -401,7 +404,7 @@
 			latency_ration = LATENCY_LIMIT;
 		}
 	}
-	spin_lock(&swap_lock);
+	spin_lock(&si->lock);
 
 no_page:
 	si->flags -= SWP_SCANNING;
@@ -414,13 +417,34 @@
 	pgoff_t offset;
 	int type, next;
 	int wrapped = 0;
+	int hp_index;
 
 	spin_lock(&swap_lock);
-	if (nr_swap_pages <= 0)
+	if (atomic_long_read(&nr_swap_pages) <= 0)
 		goto noswap;
-	nr_swap_pages--;
+	atomic_long_dec(&nr_swap_pages);
 
 	for (type = swap_list.next; type >= 0 && wrapped < 2; type = next) {
+		hp_index = atomic_xchg(&highest_priority_index, -1);
+		/*
+		 * highest_priority_index records current highest priority swap
+		 * type which just frees swap entries. If its priority is
+		 * higher than that of swap_list.next swap type, we use it.  It
+		 * isn't protected by swap_lock, so it can be an invalid value
+		 * if the corresponding swap type is swapoff. We double check
+		 * the flags here. It's even possible the swap type is swapoff
+		 * and swapon again and its priority is changed. In such rare
+		 * case, low prority swap type might be used, but eventually
+		 * high priority swap will be used after several rounds of
+		 * swap.
+		 */
+		if (hp_index != -1 && hp_index != type &&
+		    swap_info[type]->prio < swap_info[hp_index]->prio &&
+		    (swap_info[hp_index]->flags & SWP_WRITEOK)) {
+			type = hp_index;
+			swap_list.next = type;
+		}
+
 		si = swap_info[type];
 		next = si->next;
 		if (next < 0 ||
@@ -429,22 +453,29 @@
 			wrapped++;
 		}
 
-		if (!si->highest_bit)
+		spin_lock(&si->lock);
+		if (!si->highest_bit) {
+			spin_unlock(&si->lock);
 			continue;
-		if (!(si->flags & SWP_WRITEOK))
+		}
+		if (!(si->flags & SWP_WRITEOK)) {
+			spin_unlock(&si->lock);
 			continue;
+		}
 
 		swap_list.next = next;
+
+		spin_unlock(&swap_lock);
 		/* This is called for allocating swap entry for cache */
 		offset = scan_swap_map(si, SWAP_HAS_CACHE);
-		if (offset) {
-			spin_unlock(&swap_lock);
+		spin_unlock(&si->lock);
+		if (offset)
 			return swp_entry(type, offset);
-		}
+		spin_lock(&swap_lock);
 		next = swap_list.next;
 	}
 
-	nr_swap_pages++;
+	atomic_long_inc(&nr_swap_pages);
 noswap:
 	spin_unlock(&swap_lock);
 	return (swp_entry_t) {0};
@@ -456,19 +487,19 @@
 	struct swap_info_struct *si;
 	pgoff_t offset;
 
-	spin_lock(&swap_lock);
 	si = swap_info[type];
+	spin_lock(&si->lock);
 	if (si && (si->flags & SWP_WRITEOK)) {
-		nr_swap_pages--;
+		atomic_long_dec(&nr_swap_pages);
 		/* This is called for allocating swap entry, not cache */
 		offset = scan_swap_map(si, 1);
 		if (offset) {
-			spin_unlock(&swap_lock);
+			spin_unlock(&si->lock);
 			return swp_entry(type, offset);
 		}
-		nr_swap_pages++;
+		atomic_long_inc(&nr_swap_pages);
 	}
-	spin_unlock(&swap_lock);
+	spin_unlock(&si->lock);
 	return (swp_entry_t) {0};
 }
 
@@ -490,7 +521,7 @@
 		goto bad_offset;
 	if (!p->swap_map[offset])
 		goto bad_free;
-	spin_lock(&swap_lock);
+	spin_lock(&p->lock);
 	return p;
 
 bad_free:
@@ -508,6 +539,27 @@
 	return NULL;
 }
 
+/*
+ * This swap type frees swap entry, check if it is the highest priority swap
+ * type which just frees swap entry. get_swap_page() uses
+ * highest_priority_index to search highest priority swap type. The
+ * swap_info_struct.lock can't protect us if there are multiple swap types
+ * active, so we use atomic_cmpxchg.
+ */
+static void set_highest_priority_index(int type)
+{
+	int old_hp_index, new_hp_index;
+
+	do {
+		old_hp_index = atomic_read(&highest_priority_index);
+		if (old_hp_index != -1 &&
+			swap_info[old_hp_index]->prio >= swap_info[type]->prio)
+			break;
+		new_hp_index = type;
+	} while (atomic_cmpxchg(&highest_priority_index,
+		old_hp_index, new_hp_index) != old_hp_index);
+}
+
 static unsigned char swap_entry_free(struct swap_info_struct *p,
 				     swp_entry_t entry, unsigned char usage)
 {
@@ -551,10 +603,8 @@
 			p->lowest_bit = offset;
 		if (offset > p->highest_bit)
 			p->highest_bit = offset;
-		if (swap_list.next >= 0 &&
-		    p->prio > swap_info[swap_list.next]->prio)
-			swap_list.next = p->type;
-		nr_swap_pages++;
+		set_highest_priority_index(p->type);
+		atomic_long_inc(&nr_swap_pages);
 		p->inuse_pages--;
 		if ((p->flags & SWP_BLKDEV) &&
 				disk->fops->swap_slot_free_notify)
@@ -575,7 +625,7 @@
 	p = swap_info_get(entry);
 	if (p) {
 		swap_entry_free(p, entry, 1);
-		spin_unlock(&swap_lock);
+		spin_unlock(&p->lock);
 	}
 }
 
@@ -592,7 +642,7 @@
 		count = swap_entry_free(p, entry, SWAP_HAS_CACHE);
 		if (page)
 			mem_cgroup_uncharge_swapcache(page, entry, count != 0);
-		spin_unlock(&swap_lock);
+		spin_unlock(&p->lock);
 	}
 }
 
@@ -601,7 +651,7 @@
  * This does not give an exact answer when swap count is continued,
  * but does include the high COUNT_CONTINUED flag to allow for that.
  */
-static inline int page_swapcount(struct page *page)
+int page_swapcount(struct page *page)
 {
 	int count = 0;
 	struct swap_info_struct *p;
@@ -611,7 +661,7 @@
 	p = swap_info_get(entry);
 	if (p) {
 		count = swap_count(p->swap_map[swp_offset(entry)]);
-		spin_unlock(&swap_lock);
+		spin_unlock(&p->lock);
 	}
 	return count;
 }
@@ -699,7 +749,7 @@
 				page = NULL;
 			}
 		}
-		spin_unlock(&swap_lock);
+		spin_unlock(&p->lock);
 	}
 	if (page) {
 		/*
@@ -828,11 +878,13 @@
 	if ((unsigned int)type < nr_swapfiles) {
 		struct swap_info_struct *sis = swap_info[type];
 
+		spin_lock(&sis->lock);
 		if (sis->flags & SWP_WRITEOK) {
 			n = sis->pages;
 			if (free)
 				n -= sis->inuse_pages;
 		}
+		spin_unlock(&sis->lock);
 	}
 	spin_unlock(&swap_lock);
 	return n;
@@ -1528,7 +1580,7 @@
 		p->prio = --least_priority;
 	p->swap_map = swap_map;
 	p->flags |= SWP_WRITEOK;
-	nr_swap_pages += p->pages;
+	atomic_long_add(p->pages, &nr_swap_pages);
 	total_swap_pages += p->pages;
 
 	/* insert swap space into swap_list: */
@@ -1605,14 +1657,16 @@
 		/* just pick something that's safe... */
 		swap_list.next = swap_list.head;
 	}
+	spin_lock(&p->lock);
 	if (p->prio < 0) {
 		for (i = p->next; i >= 0; i = swap_info[i]->next)
 			swap_info[i]->prio = p->prio--;
 		least_priority++;
 	}
-	nr_swap_pages -= p->pages;
+	atomic_long_sub(p->pages, &nr_swap_pages);
 	total_swap_pages -= p->pages;
 	p->flags &= ~SWP_WRITEOK;
+	spin_unlock(&p->lock);
 	spin_unlock(&swap_lock);
 
 	oom_score_adj = test_set_oom_score_adj(OOM_SCORE_ADJ_MAX);
@@ -1637,14 +1691,17 @@
 
 	mutex_lock(&swapon_mutex);
 	spin_lock(&swap_lock);
+	spin_lock(&p->lock);
 	drain_mmlist();
 
 	/* wait for anyone still in scan_swap_map */
 	p->highest_bit = 0;		/* cuts scans short */
 	while (p->flags >= SWP_SCANNING) {
+		spin_unlock(&p->lock);
 		spin_unlock(&swap_lock);
 		schedule_timeout_uninterruptible(1);
 		spin_lock(&swap_lock);
+		spin_lock(&p->lock);
 	}
 
 	swap_file = p->swap_file;
@@ -1653,6 +1710,7 @@
 	swap_map = p->swap_map;
 	p->swap_map = NULL;
 	p->flags = 0;
+	spin_unlock(&p->lock);
 	spin_unlock(&swap_lock);
 	mutex_unlock(&swapon_mutex);
 	vfree(swap_map);
@@ -1856,6 +1914,7 @@
 	p->flags = SWP_USED;
 	p->next = -1;
 	spin_unlock(&swap_lock);
+	spin_lock_init(&p->lock);
 
 	return p;
 }
@@ -2177,7 +2236,7 @@
 		if ((si->flags & SWP_USED) && !(si->flags & SWP_WRITEOK))
 			nr_to_be_unused += si->inuse_pages;
 	}
-	val->freeswap = nr_swap_pages + nr_to_be_unused;
+	val->freeswap = atomic_long_read(&nr_swap_pages) + nr_to_be_unused;
 	val->totalswap = total_swap_pages + nr_to_be_unused;
 	spin_unlock(&swap_lock);
 }
@@ -2210,7 +2269,7 @@
 	p = swap_info[type];
 	offset = swp_offset(entry);
 
-	spin_lock(&swap_lock);
+	spin_lock(&p->lock);
 	if (unlikely(offset >= p->max))
 		goto unlock_out;
 
@@ -2245,7 +2304,7 @@
 	p->swap_map[offset] = count | has_cache;
 
 unlock_out:
-	spin_unlock(&swap_lock);
+	spin_unlock(&p->lock);
 out:
 	return err;
 
@@ -2292,6 +2351,31 @@
 	return __swap_duplicate(entry, SWAP_HAS_CACHE);
 }
 
+struct swap_info_struct *page_swap_info(struct page *page)
+{
+	swp_entry_t swap = { .val = page_private(page) };
+	BUG_ON(!PageSwapCache(page));
+	return swap_info[swp_type(swap)];
+}
+
+/*
+ * out-of-line __page_file_ methods to avoid include hell.
+ */
+struct address_space *__page_file_mapping(struct page *page)
+{
+	VM_BUG_ON(!PageSwapCache(page));
+	return page_swap_info(page)->swap_file->f_mapping;
+}
+EXPORT_SYMBOL_GPL(__page_file_mapping);
+
+pgoff_t __page_file_index(struct page *page)
+{
+	swp_entry_t swap = { .val = page_private(page) };
+	VM_BUG_ON(!PageSwapCache(page));
+	return swp_offset(swap);
+}
+EXPORT_SYMBOL_GPL(__page_file_index);
+
 /*
  * add_swap_count_continuation - called when a swap count is duplicated
  * beyond SWAP_MAP_MAX, it allocates a new page and links that to the entry's
@@ -2345,7 +2429,7 @@
 	}
 
 	if (!page) {
-		spin_unlock(&swap_lock);
+		spin_unlock(&si->lock);
 		return -ENOMEM;
 	}
 
@@ -2393,7 +2477,7 @@
 	list_add_tail(&page->lru, &head->lru);
 	page = NULL;			/* now it's attached, don't free it */
 out:
-	spin_unlock(&swap_lock);
+	spin_unlock(&si->lock);
 outer:
 	if (page)
 		__free_page(page);
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 1438de9..d0e40e5 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -158,8 +158,28 @@
 	return &mz->zone->reclaim_stat;
 }
 
+unsigned long zone_reclaimable_pages(struct zone *zone)
+{
+	int nr;
+
+	nr = zone_page_state(zone, NR_ACTIVE_FILE) +
+	     zone_page_state(zone, NR_INACTIVE_FILE);
+
+	if (get_nr_swap_pages() > 0)
+		nr += zone_page_state(zone, NR_ACTIVE_ANON) +
+		      zone_page_state(zone, NR_INACTIVE_ANON);
+
+	return nr;
+}
+
+bool zone_reclaimable(struct zone *zone)
+{
+	return zone->pages_scanned < zone_reclaimable_pages(zone) * 6;
+}
+
 static unsigned long zone_nr_lru_pages(struct mem_cgroup_zone *mz,
 				       enum lru_list lru)
+
 {
 	if (!mem_cgroup_disabled())
 		return mem_cgroup_zone_nr_lru_pages(mz->mem_cgroup,
@@ -454,6 +474,8 @@
 		if (!PageWriteback(page)) {
 			/* synchronous write or broken a_ops? */
 			ClearPageReclaim(page);
+			if (PageError(page))
+				return PAGE_ACTIVATE;
 		}
 		trace_mm_vmscan_writepage(page, trace_reclaim_flags(page));
 		inc_zone_page_state(page, NR_VMSCAN_WRITE);
@@ -1648,13 +1670,13 @@
 	 * latencies, so it's better to scan a minimum amount there as
 	 * well.
 	 */
-	if (current_is_kswapd() && mz->zone->all_unreclaimable)
+	if (current_is_kswapd() && !zone_reclaimable(mz->zone))
 		force_scan = true;
 	if (!global_reclaim(sc))
 		force_scan = true;
 
 	/* If we have no swap space, do not bother scanning anon pages. */
-	if (!sc->may_swap || (nr_swap_pages <= 0)) {
+	if (!sc->may_swap || (get_nr_swap_pages() <= 0)) {
 		noswap = 1;
 		fraction[0] = 0;
 		fraction[1] = 1;
@@ -1798,7 +1820,7 @@
 	 */
 	pages_for_compaction = (2UL << sc->order);
 	inactive_lru_pages = zone_nr_lru_pages(mz, LRU_INACTIVE_FILE);
-	if (nr_swap_pages > 0)
+	if (get_nr_swap_pages() > 0)
 		inactive_lru_pages += zone_nr_lru_pages(mz, LRU_INACTIVE_ANON);
 	if (sc->nr_reclaimed < pages_for_compaction &&
 			inactive_lru_pages > pages_for_compaction)
@@ -1995,8 +2017,8 @@
 		if (global_reclaim(sc)) {
 			if (!cpuset_zone_allowed_hardwall(zone, GFP_KERNEL))
 				continue;
-			if (zone->all_unreclaimable &&
-					sc->priority != DEF_PRIORITY)
+			if (sc->priority != DEF_PRIORITY &&
+			    !zone_reclaimable(zone))
 				continue;	/* Let kswapd poll it */
 			if (COMPACTION_BUILD) {
 				/*
@@ -2034,11 +2056,6 @@
 	return aborted_reclaim;
 }
 
-static bool zone_reclaimable(struct zone *zone)
-{
-	return zone->pages_scanned < zone_reclaimable_pages(zone) * 6;
-}
-
 /* All zones in zonelist are unreclaimable? */
 static bool all_unreclaimable(struct zonelist *zonelist,
 		struct scan_control *sc)
@@ -2052,7 +2069,7 @@
 			continue;
 		if (!cpuset_zone_allowed_hardwall(zone, GFP_KERNEL))
 			continue;
-		if (!zone->all_unreclaimable)
+		if (zone_reclaimable(zone))
 			return false;
 	}
 
@@ -2377,7 +2394,7 @@
 		 * they must be considered balanced here as well if kswapd
 		 * is to sleep
 		 */
-		if (zone->all_unreclaimable) {
+		if (!zone_reclaimable(zone)) {
 			balanced += zone->present_pages;
 			continue;
 		}
@@ -2470,8 +2487,8 @@
 			if (!populated_zone(zone))
 				continue;
 
-			if (zone->all_unreclaimable &&
-			    sc.priority != DEF_PRIORITY)
+			if (sc.priority != DEF_PRIORITY &&
+			    !zone_reclaimable(zone))
 				continue;
 
 			/*
@@ -2525,8 +2542,8 @@
 			if (!populated_zone(zone))
 				continue;
 
-			if (zone->all_unreclaimable &&
-			    sc.priority != DEF_PRIORITY)
+			if (sc.priority != DEF_PRIORITY &&
+			    !zone_reclaimable(zone))
 				continue;
 
 			sc.nr_scanned = 0;
@@ -2576,8 +2593,6 @@
 				sc.nr_reclaimed += reclaim_state->reclaimed_slab;
 				total_scanned += sc.nr_scanned;
 
-				if (nr_slab == 0 && !zone_reclaimable(zone))
-					zone->all_unreclaimable = 1;
 			}
 
 			/*
@@ -2589,7 +2604,7 @@
 			    total_scanned > sc.nr_reclaimed + sc.nr_reclaimed / 2)
 				sc.may_writepage = 1;
 
-			if (zone->all_unreclaimable) {
+			if (!zone_reclaimable(zone)) {
 				if (end_zone && end_zone == i)
 					end_zone--;
 				continue;
@@ -2912,27 +2927,13 @@
 	nr = global_page_state(NR_ACTIVE_FILE) +
 	     global_page_state(NR_INACTIVE_FILE);
 
-	if (nr_swap_pages > 0)
+	if (get_nr_swap_pages() > 0)
 		nr += global_page_state(NR_ACTIVE_ANON) +
 		      global_page_state(NR_INACTIVE_ANON);
 
 	return nr;
 }
 
-unsigned long zone_reclaimable_pages(struct zone *zone)
-{
-	int nr;
-
-	nr = zone_page_state(zone, NR_ACTIVE_FILE) +
-	     zone_page_state(zone, NR_INACTIVE_FILE);
-
-	if (nr_swap_pages > 0)
-		nr += zone_page_state(zone, NR_ACTIVE_ANON) +
-		      zone_page_state(zone, NR_INACTIVE_ANON);
-
-	return nr;
-}
-
 #ifdef CONFIG_HIBERNATION
 /*
  * Try to free `nr_to_reclaim' of memory, system-wide, and return the number of
@@ -3227,7 +3228,7 @@
 	    zone_page_state(zone, NR_SLAB_RECLAIMABLE) <= zone->min_slab_pages)
 		return ZONE_RECLAIM_FULL;
 
-	if (zone->all_unreclaimable)
+	if (!zone_reclaimable(zone))
 		return ZONE_RECLAIM_FULL;
 
 	/*
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 959a558..9559032 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -19,6 +19,9 @@
 #include <linux/math64.h>
 #include <linux/writeback.h>
 #include <linux/compaction.h>
+#include <linux/mm_inline.h>
+
+#include "internal.h"
 
 #ifdef CONFIG_VM_EVENT_COUNTERS
 DEFINE_PER_CPU(struct vm_event_state, vm_event_states) = {{0}};
@@ -1027,7 +1030,7 @@
 		   "\n  all_unreclaimable: %u"
 		   "\n  start_pfn:         %lu"
 		   "\n  inactive_ratio:    %u",
-		   zone->all_unreclaimable,
+		   !zone_reclaimable(zone),
 		   zone->zone_start_pfn,
 		   zone->inactive_ratio);
 	seq_putc(m, '\n');
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index e598400..04cfc69 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -191,7 +191,7 @@
 	size = SKB_DATA_ALIGN(size);
 	size += SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
 	data = kmalloc_node_track_caller(size, gfp_mask, node);
-	if (!data)
+	if (unlikely(ZERO_OR_NULL_PTR(data)))
 		goto nodata;
 	/* kmalloc(size) might give us more room than requested.
 	 * Put skb_shared_info exactly at the end of allocated zone,
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index b96094c..036f8ae 100755
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -883,7 +883,19 @@
 	chan->max_antenna_gain = min(chan->orig_mag,
 		(int) MBI_TO_DBI(power_rule->max_antenna_gain));
 	chan->max_reg_power = (int) MBM_TO_DBM(power_rule->max_eirp);
-	chan->max_power = min(chan->max_power, chan->max_reg_power);
+	if (chan->orig_mpwr) {
+		/*
+		 * Devices that use NL80211_COUNTRY_IE_FOLLOW_POWER will always
+		 * follow the passed country IE power settings.
+		 */
+		if (initiator == NL80211_REGDOM_SET_BY_COUNTRY_IE &&
+		    wiphy->country_ie_pref & NL80211_COUNTRY_IE_FOLLOW_POWER)
+			chan->max_power = chan->max_reg_power;
+		else
+			chan->max_power = min(chan->orig_mpwr,
+					      chan->max_reg_power);
+	} else
+		chan->max_power = chan->max_reg_power;
 }
 
 static void handle_band(struct wiphy *wiphy,
@@ -1295,6 +1307,8 @@
 	case NL80211_REGDOM_SET_BY_CORE:
 		return 0;
 	case NL80211_REGDOM_SET_BY_COUNTRY_IE:
+		if (wiphy->country_ie_pref & NL80211_COUNTRY_IE_IGNORE_CORE)
+			return -EALREADY;
 
 		last_wiphy = wiphy_idx_to_wiphy(last_request->wiphy_idx);
 
@@ -1648,6 +1662,7 @@
 
 	return 0;
 }
+EXPORT_SYMBOL(regulatory_hint_user);
 
 /* Driver hints */
 int regulatory_hint(struct wiphy *wiphy, const char *alpha2)
diff --git a/net/wireless/reg.h b/net/wireless/reg.h
index e2aaaf5..017880c 100644
--- a/net/wireless/reg.h
+++ b/net/wireless/reg.h
@@ -22,8 +22,6 @@
 bool reg_is_valid_request(const char *alpha2);
 bool reg_supported_dfs_region(u8 dfs_region);
 
-int regulatory_hint_user(const char *alpha2);
-
 int reg_device_uevent(struct device *dev, struct kobj_uevent_env *env);
 void reg_device_remove(struct wiphy *wiphy);
 
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 56cd5e6..a3ed23d 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -53,7 +53,7 @@
 snd-soc-cs8427-objs := cs8427.o
 snd-soc-wcd9320-objs := wcd9xxx-resmgr.o wcd9320.o wcd9320-tables.o wcd9xxx-mbhc.o wcd9xxx-common.o
 snd-soc-wcd9306-objs := wcd9306.o wcd9306-tables.o wcd9xxx-common.o
-snd-soc-msm8x10-wcd-objs := msm8x10-wcd.o msm8x10-wcd-tables.o
+snd-soc-msm8x10-wcd-objs := msm8x10-wcd.o msm8x10-wcd-tables.o wcd9xxx-common.o
 snd-soc-wl1273-objs := wl1273.o
 snd-soc-wm1250-ev1-objs := wm1250-ev1.o
 snd-soc-wm2000-objs := wm2000.o
diff --git a/sound/soc/codecs/msm8x10-wcd.c b/sound/soc/codecs/msm8x10-wcd.c
index 942d095..55fec32 100644
--- a/sound/soc/codecs/msm8x10-wcd.c
+++ b/sound/soc/codecs/msm8x10-wcd.c
@@ -39,6 +39,7 @@
 #include "wcd9xxx-resmgr.h"
 #include "msm8x10_wcd_registers.h"
 #include "../msm/qdsp6v2/q6core.h"
+#include "wcd9xxx-common.h"
 
 #define MSM8X10_WCD_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
 			SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000)
@@ -63,6 +64,15 @@
 #define MAX_ON_DEMAND_SUPPLY_NAME_LENGTH 64
 #define HELICON_MCLK_CLK_9P6MHZ				9600000
 
+/*
+ * Multiplication factor to compute impedance on codec
+ * This is computed from (Vx / (m*Ical)) = (10mV/(180*30uA))
+ */
+#define MSM8X10_WCD_ZDET_MUL_FACTOR 1852
+
+/* RX_HPH_CNP_WG_TIME increases by 0.24ms */
+#define MSM8X10_WCD_WG_TIME_FACTOR_US  240
+
 enum {
 	MSM8X10_WCD_I2C_TOP_LEVEL = 0,
 	MSM8X10_WCD_I2C_ANALOG,
@@ -168,6 +178,12 @@
 
 	struct delayed_work hs_detect_work;
 	struct wcd9xxx_mbhc_config *mbhc_cfg;
+
+	/*
+	 * list used to save/restore registers at start and
+	 * end of impedance measurement
+	 */
+	struct list_head reg_save_restore;
 };
 
 static unsigned short rx_digital_gain_reg[] = {
@@ -192,7 +208,7 @@
 	struct msm8x10_wcd_regulator *vreg,
 	const char *vreg_name, bool ondemand);
 static int msm8x10_wcd_dt_parse_micbias_info(struct device *dev,
-	struct msm8x10_wcd_micbias_setting *micbias);
+	struct wcd9xxx_micbias_setting *micbias);
 static struct msm8x10_wcd_pdata *msm8x10_wcd_populate_dt_pdata(
 	struct device *dev);
 
@@ -435,8 +451,8 @@
 				__func__, reg);
 	else
 		dev_dbg(msm8x10_wcd->dev,
-				"%s: Codec reg 0x%x written with value 0x%x\n",
-				__func__, reg, val);
+			"%s: Write %x to R%d(0x%x)\n",
+			__func__, val, reg, reg);
 
 	return ret;
 }
@@ -609,13 +625,24 @@
 }
 
 static int msm8x10_wcd_dt_parse_micbias_info(struct device *dev,
-	struct msm8x10_wcd_micbias_setting *micbias)
+	struct wcd9xxx_micbias_setting *micbias)
 {
 	int ret = 0;
 	char prop_name[CODEC_DT_MAX_PROP_SIZE];
 	u32 prop_val;
 
 	snprintf(prop_name, CODEC_DT_MAX_PROP_SIZE,
+		 "qcom,cdc-micbias-ldoh-v");
+	ret = of_property_read_u32(dev->of_node, prop_name,
+				   &prop_val);
+	if (ret) {
+		dev_err(dev, "Looking up %s property in node %s failed",
+			prop_name, dev->of_node->full_name);
+		return -ENODEV;
+	}
+	micbias->ldoh_v = (u8) prop_val;
+
+	snprintf(prop_name, CODEC_DT_MAX_PROP_SIZE,
 		 "qcom,cdc-micbias-cfilt-mv");
 	ret = of_property_read_u32(dev->of_node, prop_name,
 				   &micbias->cfilt1_mv);
@@ -2515,7 +2542,7 @@
 
 	/* Disable internal biasing path which can cause leakage */
 	MSM8X10_WCD_REG_VAL(MSM8X10_WCD_A_BIAS_CURR_CTL_2, 0x04),
-	MSM8X10_WCD_REG_VAL(MSM8X10_WCD_A_MICB_CFILT_1_VAL, 0x60),
+
 	/* Enable pulldown to reduce leakage */
 	MSM8X10_WCD_REG_VAL(MSM8X10_WCD_A_MICB_1_CTL, 0x82),
 	MSM8X10_WCD_REG_VAL(MSM8X10_WCD_A_TX_COM_BIAS, 0xE0),
@@ -2555,6 +2582,8 @@
 	 */
 	{MSM8X10_WCD_A_RX_HPH_OCP_CTL, 0xE1, 0x61},
 	{MSM8X10_WCD_A_RX_COM_OCP_COUNT, 0xFF, 0xFF},
+	{MSM8X10_WCD_A_RX_HPH_L_TEST, 0x01, 0x01},
+	{MSM8X10_WCD_A_RX_HPH_R_TEST, 0x01, 0x01},
 
 	/* Initialize gain registers to use register gain */
 	{MSM8X10_WCD_A_RX_HPH_L_GAIN, 0x20, 0x20},
@@ -2689,6 +2718,228 @@
 			    0x40, on ? 0x40 : 0x00);
 }
 
+static void msm8x10_wcd_prepare_hph_pa(struct snd_soc_codec *codec,
+				       struct list_head *lh)
+{
+	int i;
+	u32 delay;
+
+	const struct wcd9xxx_reg_mask_val reg_set_paon[] = {
+		{MSM8X10_WCD_A_CDC_RX1_B6_CTL, 0xFF, 0x01},
+		{MSM8X10_WCD_A_CDC_RX2_B6_CTL, 0xFF, 0x01},
+		{MSM8X10_WCD_A_RX_HPH_L_GAIN, 0xFF, 0x2C},
+		{MSM8X10_WCD_A_RX_HPH_R_GAIN, 0xFF, 0x2C},
+		{MSM8X10_WCD_A_CDC_CLK_RX_B1_CTL, 0xFF, 0x01},
+		{MSM8X10_WCD_A_RX_COM_BIAS, 0xFF, 0x80},
+		{MSM8X10_WCD_A_CP_EN, 0xFF, 0xE7},
+		{MSM8X10_WCD_A_CP_STATIC, 0xFF, 0x13},
+		{MSM8X10_WCD_A_CP_STATIC, 0xFF, 0x1B},
+		{MSM8X10_WCD_A_CDC_RX2_B6_CTL, 0xFF, 0x01},
+		{MSM8X10_WCD_A_CDC_CLK_RX_B1_CTL, 0xFF, 0x03},
+		{MSM8X10_WCD_A_CDC_ANA_CLK_CTL, 0xFF, 0x22},
+		{MSM8X10_WCD_A_CDC_ANA_CLK_CTL, 0xFF, 0x23},
+		{MSM8X10_WCD_A_RX_HPH_CNP_WG_CTL, 0xFF, 0xDA},
+		{MSM8X10_WCD_A_CDC_DIG_CLK_CTL, 0xFF, 0x01},
+		{MSM8X10_WCD_A_CDC_DIG_CLK_CTL, 0xFF, 0x03},
+		{MSM8X10_WCD_A_RX_HPH_CHOP_CTL, 0xFF, 0xA4},
+		{MSM8X10_WCD_A_RX_HPH_OCP_CTL, 0xFF, 0x67},
+		{MSM8X10_WCD_A_RX_HPH_L_TEST, 0x01, 0x00},
+		{MSM8X10_WCD_A_RX_HPH_R_TEST, 0x01, 0x00},
+		{MSM8X10_WCD_A_RX_HPH_BIAS_WG_OCP, 0xFF, 0x1A},
+		{MSM8X10_WCD_A_RX_HPH_CNP_WG_CTL, 0xFF, 0xDB},
+		{MSM8X10_WCD_A_RX_HPH_CNP_WG_TIME, 0xFF, 0xDB},
+		{MSM8X10_WCD_A_RX_HPH_L_DAC_CTL, 0xFF, 0x40},
+		{MSM8X10_WCD_A_RX_HPH_L_DAC_CTL, 0xFF, 0xC0},
+		{MSM8X10_WCD_A_RX_HPH_R_DAC_CTL, 0xFF, 0x40},
+		{MSM8X10_WCD_A_RX_HPH_R_DAC_CTL, 0xFF, 0xC0},
+		{MSM8X10_WCD_A_RX_HPH_L_DAC_CTL, 0x03, 0x01},
+		{MSM8X10_WCD_A_RX_HPH_R_DAC_CTL, 0x03, 0x01},
+	};
+
+	for (i = 0; i < ARRAY_SIZE(reg_set_paon); i++) {
+		delay = 0;
+		wcd9xxx_soc_update_bits_push(codec, lh,
+					     reg_set_paon[i].reg,
+					     reg_set_paon[i].mask,
+					     reg_set_paon[i].val, delay);
+	}
+	dev_dbg(codec->dev, "%s: PAs are prepared\n", __func__);
+	return;
+}
+
+static int msm8x10_wcd_enable_static_pa(struct snd_soc_codec *codec,
+					bool enable)
+{
+	int wg_time = snd_soc_read(codec, WCD9XXX_A_RX_HPH_CNP_WG_TIME) *
+				MSM8X10_WCD_WG_TIME_FACTOR_US;
+
+	wg_time += (int) (wg_time * 35) / 100;
+
+	snd_soc_update_bits(codec, MSM8X10_WCD_A_RX_HPH_CNP_EN, 0x30,
+			    enable ? 0x30 : 0x0);
+	/* Wait for wave gen time to avoid pop noise */
+	usleep_range(wg_time, wg_time + WCD9XXX_USLEEP_RANGE_MARGIN_US);
+	snd_soc_update_bits(codec, MSM8X10_WCD_A_CDC_RX1_B6_CTL, 0xFF, 0x00);
+	snd_soc_update_bits(codec, MSM8X10_WCD_A_CDC_RX2_B6_CTL, 0xFF, 0x00);
+
+	dev_dbg(codec->dev, "%s: PAs are %s as static mode (wg_time %d)\n",
+		__func__, enable ? "enabled" : "disabled", wg_time);
+	return 0;
+}
+
+static int msm8x10_wcd_setup_zdet(struct wcd9xxx_mbhc *mbhc,
+				  enum mbhc_impedance_detect_stages stage)
+{
+	int ret = 0;
+	struct snd_soc_codec *codec = mbhc->codec;
+	struct msm8x10_wcd_priv *wcd_priv = snd_soc_codec_get_drvdata(codec);
+	const int mux_wait_us = 25;
+
+#define __wr(reg, mask, value)					\
+	do {							\
+		ret = wcd9xxx_soc_update_bits_push(codec,	\
+				&wcd_priv->reg_save_restore,	\
+				reg, mask, value, 0);		\
+		if (ret < 0)					\
+			return ret;				\
+	 } while (0)
+
+	switch (stage) {
+	case PRE_MEAS:
+		dev_dbg(codec->dev, "%s: PRE_MEAS\n", __func__);
+		INIT_LIST_HEAD(&wcd_priv->reg_save_restore);
+		/* Configure PA */
+		msm8x10_wcd_prepare_hph_pa(mbhc->codec,
+					   &wcd_priv->reg_save_restore);
+
+		/* Setup MBHC */
+		__wr(WCD9XXX_A_MBHC_SCALING_MUX_1, 0x7F, 0x40);
+		__wr(WCD9XXX_A_MBHC_SCALING_MUX_2, 0xFF, 0xF0);
+		__wr(0x171, 0xFF, 0x90);
+		__wr(WCD9XXX_A_TX_7_MBHC_EN, 0xFF, 0xF0);
+		__wr(WCD9XXX_A_CDC_MBHC_TIMER_B4_CTL, 0xFF, 0x45);
+		__wr(WCD9XXX_A_CDC_MBHC_TIMER_B5_CTL, 0xFF, 0x80);
+
+		__wr(WCD9XXX_A_CDC_MBHC_CLK_CTL, 0xFF, 0x0A);
+		snd_soc_write(codec, WCD9XXX_A_CDC_MBHC_EN_CTL, 0x2);
+		__wr(WCD9XXX_A_CDC_MBHC_CLK_CTL, 0xFF, 0x02);
+
+		/* Enable Impedance Detection */
+		__wr(WCD9XXX_A_MBHC_HPH, 0xFF, 0xC8);
+
+		/*
+		 * CnP setup for 0mV
+		 * Route static data as input to noise shaper
+		 */
+		__wr(MSM8X10_WCD_A_CDC_RX1_B3_CTL, 0xFF, 0x02);
+		__wr(MSM8X10_WCD_A_CDC_RX2_B3_CTL, 0xFF, 0x02);
+
+		snd_soc_update_bits(codec, WCD9XXX_A_RX_HPH_L_TEST,
+				    0x02, 0x00);
+		snd_soc_update_bits(codec, WCD9XXX_A_RX_HPH_R_TEST,
+				    0x02, 0x00);
+
+		/* Reset the HPHL static data pointer */
+		__wr(MSM8X10_WCD_A_CDC_RX1_B2_CTL, 0xFF, 0x00);
+		/* Four consecutive writes to set 0V as static data input */
+		snd_soc_write(codec, MSM8X10_WCD_A_CDC_RX1_B1_CTL, 0x00);
+		snd_soc_write(codec, MSM8X10_WCD_A_CDC_RX1_B1_CTL, 0x00);
+		snd_soc_write(codec, MSM8X10_WCD_A_CDC_RX1_B1_CTL, 0x00);
+		snd_soc_write(codec, MSM8X10_WCD_A_CDC_RX1_B1_CTL, 0x00);
+
+		/* Reset the HPHR static data pointer */
+		__wr(MSM8X10_WCD_A_CDC_RX2_B2_CTL, 0xFF, 0x00);
+		/* Four consecutive writes to set 0V as static data input */
+		snd_soc_write(codec, MSM8X10_WCD_A_CDC_RX2_B1_CTL, 0x00);
+		snd_soc_write(codec, MSM8X10_WCD_A_CDC_RX2_B1_CTL, 0x00);
+		snd_soc_write(codec, MSM8X10_WCD_A_CDC_RX2_B1_CTL, 0x00);
+		snd_soc_write(codec, MSM8X10_WCD_A_CDC_RX2_B1_CTL, 0x00);
+
+		/* Enable the HPHL and HPHR PA */
+		msm8x10_wcd_enable_static_pa(mbhc->codec, true);
+		break;
+
+	case POST_MEAS:
+		dev_dbg(codec->dev, "%s: POST_MEAS\n", __func__);
+		/* Turn off ICAL */
+		snd_soc_write(codec, WCD9XXX_A_MBHC_SCALING_MUX_2, 0xF0);
+
+		msm8x10_wcd_enable_static_pa(mbhc->codec, false);
+
+		/*
+		 * Setup CnP wavegen to ramp to the desired
+		 * output using a 40ms ramp
+		 */
+
+		/* CnP wavegen current to 0.5uA */
+		snd_soc_write(codec, WCD9XXX_A_RX_HPH_BIAS_WG_OCP, 0x1A);
+		/* Set the current division ratio to 2000 */
+		snd_soc_write(codec, WCD9XXX_A_RX_HPH_CNP_WG_CTL, 0xDF);
+		/* Set the wavegen timer to max (60msec) */
+		snd_soc_write(codec, WCD9XXX_A_RX_HPH_CNP_WG_TIME, 0xA0);
+		/* Set the CnP reference current to sc_bias */
+		snd_soc_write(codec, WCD9XXX_A_RX_HPH_OCP_CTL, 0x6D);
+
+		snd_soc_write(codec, MSM8X10_WCD_A_CDC_RX1_B2_CTL, 0x00);
+		/* Four consecutive writes to set -10mV as static data input */
+		snd_soc_write(codec, MSM8X10_WCD_A_CDC_RX1_B1_CTL, 0x00);
+		snd_soc_write(codec, MSM8X10_WCD_A_CDC_RX1_B1_CTL, 0x1F);
+		snd_soc_write(codec, MSM8X10_WCD_A_CDC_RX1_B1_CTL, 0xE3);
+		snd_soc_write(codec, MSM8X10_WCD_A_CDC_RX1_B1_CTL, 0x08);
+
+		snd_soc_write(codec, MSM8X10_WCD_A_CDC_RX2_B2_CTL, 0x00);
+		/* Four consecutive writes to set -10mV as static data input */
+		snd_soc_write(codec, MSM8X10_WCD_A_CDC_RX2_B1_CTL, 0x00);
+		snd_soc_write(codec, MSM8X10_WCD_A_CDC_RX2_B1_CTL, 0x1F);
+		snd_soc_write(codec, MSM8X10_WCD_A_CDC_RX2_B1_CTL, 0xE3);
+		snd_soc_write(codec, MSM8X10_WCD_A_CDC_RX2_B1_CTL, 0x08);
+
+		snd_soc_update_bits(codec, WCD9XXX_A_RX_HPH_L_TEST,
+				    0x02, 0x02);
+		snd_soc_update_bits(codec, WCD9XXX_A_RX_HPH_R_TEST,
+				    0x02, 0x02);
+		/* Enable the HPHL and HPHR PA and wait for 60mS */
+		msm8x10_wcd_enable_static_pa(mbhc->codec, true);
+
+		snd_soc_update_bits(codec, WCD9XXX_A_MBHC_SCALING_MUX_1,
+				    0x7F, 0x40);
+		usleep_range(mux_wait_us,
+				mux_wait_us + WCD9XXX_USLEEP_RANGE_MARGIN_US);
+		break;
+	case PA_DISABLE:
+		dev_dbg(codec->dev, "%s: PA_DISABLE\n", __func__);
+		msm8x10_wcd_enable_static_pa(mbhc->codec, false);
+		wcd9xxx_restore_registers(codec, &wcd_priv->reg_save_restore);
+		break;
+	}
+#undef __wr
+
+	return ret;
+}
+
+static void msm8x10_wcd_compute_impedance(s16 *l, s16 *r, uint32_t *zl,
+					  uint32_t *zr)
+{
+	int zln, zld;
+	int zrn, zrd;
+	int rl = 0, rr = 0;
+
+	zln = (l[1] - l[0]) * MSM8X10_WCD_ZDET_MUL_FACTOR;
+	zld = (l[2] - l[0]);
+	if (zld)
+		rl = zln / zld;
+
+	zrn = (r[1] - r[0]) * MSM8X10_WCD_ZDET_MUL_FACTOR;
+	zrd = (r[2] - r[0]);
+	if (zrd)
+		rr = zrn / zrd;
+
+	*zl = rl;
+	*zr = rr;
+}
+
+
+
 static const struct wcd9xxx_mbhc_cb mbhc_cb = {
 	.enable_mux_bias_block = msm8x10_wcd_enable_mux_bias_block,
 	.cfilt_fast_mode = msm8x10_wcd_put_cfilt_fast_mode,
@@ -2701,6 +2952,8 @@
 	.enable_mb_source = msm8x10_wcd_enable_ext_mb_source,
 	.setup_int_rbias = msm8x10_wcd_micb_internal,
 	.pull_mb_to_vddio = msm8x10_wcd_enable_mb_vddio,
+	.setup_zdet = msm8x10_wcd_setup_zdet,
+	.compute_impedance = msm8x10_wcd_compute_impedance,
 };
 
 static void delayed_hs_detect_fn(struct work_struct *work)
@@ -2756,10 +3009,21 @@
 
 	return NULL;
 }
+static int msm8x10_wcd_device_down(struct snd_soc_codec *codec)
+{
+	dev_dbg(codec->dev, "%s: device down!\n", __func__);
+
+	snd_soc_card_change_online_state(codec->card, 0);
+	return 0;
+}
 
 static int msm8x10_wcd_device_up(struct snd_soc_codec *codec)
 {
-	pr_debug("%s: device up!\n", __func__);
+	dev_dbg(codec->dev, "%s: device up!\n", __func__);
+
+	snd_soc_card_change_online_state(codec->card, 1);
+	/* delay is required to make sure sound card state updated */
+	usleep_range(5000, 5100);
 
 	mutex_lock(&codec->mutex);
 
@@ -2778,7 +3042,9 @@
 	bool timedout;
 	unsigned long timeout;
 
-	if (value == SUBSYS_AFTER_POWERUP) {
+	if (value == SUBSYS_BEFORE_SHUTDOWN)
+		msm8x10_wcd_device_down(registered_codec);
+	else if (value == SUBSYS_AFTER_POWERUP) {
 		pr_debug("%s: ADSP is about to power up. bring up codec\n",
 			 __func__);
 
@@ -2815,6 +3081,41 @@
 	.hs_jack_switch = MSM8X10_WCD_IRQ_MBHC_HS_DET,
 };
 
+static int msm8x10_wcd_handle_pdata(struct snd_soc_codec *codec,
+	struct msm8x10_wcd_pdata *pdata)
+{
+	int k1, rc = 0;
+	struct msm8x10_wcd_priv *msm8x10_wcd_priv;
+
+	msm8x10_wcd_priv = snd_soc_codec_get_drvdata(codec);
+
+	/* Make sure settings are correct */
+	if (pdata->micbias.ldoh_v > WCD9XXX_LDOH_3P0_V ||
+	    pdata->micbias.bias1_cfilt_sel > WCD9XXX_CFILT1_SEL) {
+		rc = -EINVAL;
+		goto done;
+	}
+
+	/* figure out k value */
+	k1 = wcd9xxx_resmgr_get_k_val(&msm8x10_wcd_priv->resmgr,
+				 pdata->micbias.cfilt1_mv);
+	if (IS_ERR_VALUE(k1)) {
+		rc = -EINVAL;
+		goto done;
+	}
+
+	/* Set voltage level */
+	snd_soc_update_bits(codec, MSM8X10_WCD_A_MICB_CFILT_1_VAL,
+			    0xFC, (k1 << 2));
+
+	/* update micbias capless mode */
+	snd_soc_update_bits(codec, MSM8X10_WCD_A_MICB_1_CTL, 0x10,
+			    pdata->micbias.bias1_cap_mode << 4);
+
+done:
+	return rc;
+}
+
 static int msm8x10_wcd_codec_probe(struct snd_soc_codec *codec)
 {
 	struct msm8x10_wcd_priv *msm8x10_wcd_priv;
@@ -2851,12 +3152,18 @@
 	INIT_DELAYED_WORK(&msm8x10_wcd_priv->hs_detect_work,
 			delayed_hs_detect_fn);
 
+	pdata = dev_get_platdata(msm8x10_wcd->dev);
+	if (!pdata) {
+		dev_err(msm8x10_wcd->dev, "%s: platform data not found\n",
+			__func__);
+	}
+
 	/* codec resmgr module init */
 	msm8x10_wcd = codec->control_data;
 	core_res = &msm8x10_wcd->wcd9xxx_res;
 	ret = wcd9xxx_resmgr_init(&msm8x10_wcd_priv->resmgr,
-				codec, core_res, NULL, NULL,
-				WCD9XXX_CDC_TYPE_HELICON);
+				codec, core_res, NULL, &pdata->micbias,
+				NULL, WCD9XXX_CDC_TYPE_HELICON);
 	if (ret) {
 		dev_err(codec->dev,
 				"%s: wcd9xxx init failed %d\n",
@@ -2868,16 +3175,6 @@
 	msm8x10_wcd_codec_init_reg(codec);
 	msm8x10_wcd_update_reg_defaults(codec);
 
-	pdata = dev_get_platdata(msm8x10_wcd->dev);
-	if (!pdata) {
-		dev_err(msm8x10_wcd->dev, "%s: platform data not found\n",
-			__func__);
-	}
-
-	/* update micbias capless mode */
-	snd_soc_update_bits(codec, MSM8X10_WCD_A_MICB_1_CTL, 0x10,
-			    pdata->micbias.bias1_cap_mode << 4);
-
 	msm8x10_wcd_priv->on_demand_list[ON_DEMAND_CP].supply =
 				wcd8x10_wcd_codec_find_regulator(
 				codec->control_data,
@@ -2892,12 +3189,18 @@
 	ret = wcd9xxx_mbhc_init(&msm8x10_wcd_priv->mbhc,
 				&msm8x10_wcd_priv->resmgr,
 				codec, NULL, &mbhc_cb, &cdc_intr_ids,
-				HELICON_MCLK_CLK_9P6MHZ, false);
+				HELICON_MCLK_CLK_9P6MHZ, true);
 	if (ret) {
-		pr_err("%s: Failed to initialize mbhc\n", __func__);
+		dev_err(msm8x10_wcd->dev, "%s: Failed to initialize mbhc\n",
+			__func__);
 		goto exit_probe;
 	}
 
+	/* Handle the Pdata */
+	ret = msm8x10_wcd_handle_pdata(codec, pdata);
+	if (IS_ERR_VALUE(ret))
+		dev_err(msm8x10_wcd->dev, "%s: Bad Pdata\n", __func__);
+
 	registered_codec = codec;
 	adsp_state_notifier =
 	    subsys_notif_register_notifier("adsp",
@@ -3202,6 +3505,11 @@
 		dev_dbg(&client->dev, "%s:Platform data from device tree\n",
 			__func__);
 		pdata = msm8x10_wcd_populate_dt_pdata(&client->dev);
+		if (!pdata) {
+			dev_err(&client->dev, "%s: Failed to parse pdata from device tree\n",
+				__func__);
+			goto rtn;
+		}
 		client->dev.platform_data = pdata;
 	} else {
 		dev_dbg(&client->dev, "%s:Platform data from board file\n",
@@ -3311,12 +3619,61 @@
 	{ },
 };
 
+#ifdef CONFIG_PM
+static int msm8x10_wcd_i2c_resume(struct device *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct msm8x10_wcd_priv *priv = i2c_get_clientdata(client);
+	struct msm8x10_wcd *msm8x10;
+	int ret =  0;
+
+	if (client->addr == HELICON_CORE_0_I2C_ADDR) {
+		if (!priv || !priv->codec || !priv->codec->control_data) {
+			ret = -EINVAL;
+			dev_err(dev, "%s: Invalid client data\n", __func__);
+			goto rtn;
+		}
+		msm8x10 = priv->codec->control_data;
+		return wcd9xxx_core_res_resume(&msm8x10->wcd9xxx_res);
+	}
+rtn:
+	return 0;
+}
+
+static int msm8x10_wcd_i2c_suspend(struct device *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct msm8x10_wcd_priv *priv = i2c_get_clientdata(client);
+	struct msm8x10_wcd *msm8x10;
+	int ret = 0;
+
+	if (client->addr == HELICON_CORE_0_I2C_ADDR) {
+		if (!priv || !priv->codec || !priv->codec->control_data) {
+			ret = -EINVAL;
+			dev_err(dev, "%s: Invalid client data\n", __func__);
+			goto rtn;
+		}
+		msm8x10 = priv->codec->control_data;
+		return wcd9xxx_core_res_suspend(&msm8x10->wcd9xxx_res,
+						PMSG_SUSPEND);
+	}
+
+rtn:
+	return ret;
+}
+
+static SIMPLE_DEV_PM_OPS(msm8x1_wcd_pm_ops, msm8x10_wcd_i2c_suspend,
+			 msm8x10_wcd_i2c_resume);
+#endif
 
 static struct i2c_driver msm8x10_wcd_i2c_driver = {
 	.driver                 = {
 		.owner          = THIS_MODULE,
 		.name           = "msm8x10-wcd-i2c-core",
-		.of_match_table = msm8x10_wcd_of_match
+		.of_match_table = msm8x10_wcd_of_match,
+#ifdef CONFIG_PM
+		.pm = &msm8x1_wcd_pm_ops,
+#endif
 	},
 	.id_table               = msm8x10_wcd_id_table,
 	.probe                  = msm8x10_wcd_i2c_probe,
diff --git a/sound/soc/codecs/msm8x10-wcd.h b/sound/soc/codecs/msm8x10-wcd.h
index 5f67cba..eeeb557 100644
--- a/sound/soc/codecs/msm8x10-wcd.h
+++ b/sound/soc/codecs/msm8x10-wcd.h
@@ -16,6 +16,7 @@
 #include <sound/jack.h>
 #include "wcd9xxx-mbhc.h"
 #include "wcd9xxx-resmgr.h"
+#include <linux/mfd/wcd9xxx/pdata.h>
 
 #define MSM8X10_WCD_NUM_REGISTERS	0x600
 #define MSM8X10_WCD_MAX_REGISTER	(MSM8X10_WCD_NUM_REGISTERS-1)
@@ -113,28 +114,6 @@
 	MSM8X10_WCD_NUM_IRQS,
 };
 
-/*
- * Each micbias can be assigned to one of three cfilters
- * Vbatt_min >= .15V + ldoh_v
- * ldoh_v >= .15v + cfiltx_mv
- * If ldoh_v = 1.95 160 mv < cfiltx_mv < 1800 mv
- * If ldoh_v = 2.35 200 mv < cfiltx_mv < 2200 mv
- * If ldoh_v = 2.75 240 mv < cfiltx_mv < 2600 mv
- * If ldoh_v = 2.85 250 mv < cfiltx_mv < 2700 mv
- */
-struct msm8x10_wcd_micbias_setting {
-	u8 ldoh_v;
-	u32 cfilt1_mv; /* in mv */
-	/*
-	 * Different WCD9xxx series codecs may not
-	 * have 4 mic biases. If a codec has fewer
-	 * mic biases, some of these properties will
-	 * not be used.
-	 */
-	u8 bias1_cfilt_sel;
-	u8 bias1_cap_mode;
-};
-
 struct msm8x10_wcd_ocp_setting {
 	unsigned int	use_pdata:1; /* 0 - use sys default as recommended */
 	unsigned int	num_attempts:4; /* up to 15 attempts */
@@ -158,7 +137,7 @@
 	int num_irqs;
 	int reset_gpio;
 	void *msm8x10_wcd_ahb_base_vaddr;
-	struct msm8x10_wcd_micbias_setting micbias;
+	struct wcd9xxx_micbias_setting micbias;
 	struct msm8x10_wcd_ocp_setting ocp;
 	struct msm8x10_wcd_regulator regulator[MAX_REGULATOR];
 	u32 mclk_rate;
diff --git a/sound/soc/codecs/msm_hdmi_codec_rx.c b/sound/soc/codecs/msm_hdmi_codec_rx.c
index e5d5c32..b406feb 100644
--- a/sound/soc/codecs/msm_hdmi_codec_rx.c
+++ b/sound/soc/codecs/msm_hdmi_codec_rx.c
@@ -21,6 +21,8 @@
 
 #define MSM_HDMI_PCM_RATES	SNDRV_PCM_RATE_48000
 
+static int msm_hdmi_audio_codec_return_value;
+
 struct msm_hdmi_audio_codec_rx_data {
 	struct platform_device *hdmi_core_pdev;
 	struct msm_hdmi_audio_codec_ops hdmi_ops;
@@ -54,8 +56,8 @@
 	int rc;
 
 	codec_data = snd_soc_codec_get_drvdata(codec);
-	rc = codec_data->hdmi_ops.get_audio_edid_blk(codec_data->hdmi_core_pdev,
-						     &edid_blk);
+	rc = codec_data->hdmi_ops.get_audio_edid_blk(
+			codec_data->hdmi_core_pdev, &edid_blk);
 
 	if (!IS_ERR_VALUE(rc)) {
 		memcpy(ucontrol->value.bytes.data, edid_blk.audio_data_blk,
@@ -80,6 +82,24 @@
 	},
 };
 
+static int msm_hdmi_audio_codec_rx_dai_startup(
+		struct snd_pcm_substream *substream,
+		struct snd_soc_dai *dai)
+{
+	struct msm_hdmi_audio_codec_rx_data *codec_data =
+			dev_get_drvdata(dai->codec->dev);
+
+	msm_hdmi_audio_codec_return_value =
+		codec_data->hdmi_ops.hdmi_cable_status(
+		codec_data->hdmi_core_pdev, 1);
+	if (IS_ERR_VALUE(msm_hdmi_audio_codec_return_value)) {
+		dev_err(dai->dev,
+			"%s() HDMI core is not ready\n", __func__);
+	}
+
+	return msm_hdmi_audio_codec_return_value;
+}
+
 static int msm_hdmi_audio_codec_rx_dai_hw_params(
 		struct snd_pcm_substream *substream,
 		struct snd_pcm_hw_params *params,
@@ -89,10 +109,17 @@
 	u32 level_shift  = 0; /* 0dB */
 	bool down_mix = 0;
 	u32 num_channels = params_channels(params);
+	int rc = 0;
 
 	struct msm_hdmi_audio_codec_rx_data *codec_data =
 			dev_get_drvdata(dai->codec->dev);
 
+	if (IS_ERR_VALUE(msm_hdmi_audio_codec_return_value)) {
+		dev_err(dai->dev,
+			"%s() HDMI core is not ready\n", __func__);
+		return msm_hdmi_audio_codec_return_value;
+	}
+
 	switch (num_channels) {
 	case 2:
 		channel_allocation  = 0;
@@ -108,19 +135,47 @@
 		return -EINVAL;
 	}
 
-	dev_dbg(dai->dev, "%s() num_ch %u  samplerate %u channel_allocation = %u\n",
+	dev_dbg(dai->dev,
+		"%s() num_ch %u  samplerate %u channel_allocation = %u\n",
 		__func__, num_channels, params_rate(params),
 		channel_allocation);
 
-	codec_data->hdmi_ops.audio_info_setup(codec_data->hdmi_core_pdev,
-			params_rate(params), num_channels, channel_allocation,
-			level_shift, down_mix);
+	rc = codec_data->hdmi_ops.audio_info_setup(
+			codec_data->hdmi_core_pdev,
+			params_rate(params), num_channels,
+			channel_allocation, level_shift, down_mix);
+	if (IS_ERR_VALUE(rc)) {
+		dev_err(dai->dev,
+			"%s() HDMI core is not ready\n", __func__);
+	}
 
-	return 0;
+	return rc;
+}
+
+static void msm_hdmi_audio_codec_rx_dai_shutdown(
+		struct snd_pcm_substream *substream,
+		struct snd_soc_dai *dai)
+{
+	int rc;
+
+	struct msm_hdmi_audio_codec_rx_data *codec_data =
+			dev_get_drvdata(dai->codec->dev);
+
+	rc = codec_data->hdmi_ops.hdmi_cable_status(
+			codec_data->hdmi_core_pdev, 0);
+	if (IS_ERR_VALUE(rc)) {
+		dev_err(dai->dev,
+			"%s() HDMI core had problems releasing HDMI audio flag\n",
+			__func__);
+	}
+
+	return;
 }
 
 static struct snd_soc_dai_ops msm_hdmi_audio_codec_rx_dai_ops = {
+	.startup	= msm_hdmi_audio_codec_rx_dai_startup,
 	.hw_params	= msm_hdmi_audio_codec_rx_dai_hw_params,
+	.shutdown	= msm_hdmi_audio_codec_rx_dai_shutdown
 };
 
 static int msm_hdmi_audio_codec_rx_probe(struct snd_soc_codec *codec)
diff --git a/sound/soc/codecs/wcd9306.c b/sound/soc/codecs/wcd9306.c
index 4857593..abc628b 100644
--- a/sound/soc/codecs/wcd9306.c
+++ b/sound/soc/codecs/wcd9306.c
@@ -1323,6 +1323,9 @@
 static const struct soc_enum rx4_mix1_inp2_chain_enum =
 	SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_RX4_B1_CTL, 4, 13, rx_3_4_mix1_text);
 
+static const struct soc_enum rx4_mix1_inp3_chain_enum =
+	SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_RX4_B2_CTL, 0, 13, rx_3_4_mix1_text);
+
 static const struct soc_enum rx1_mix2_inp1_chain_enum =
 	SOC_ENUM_SINGLE(TAPAN_A_CDC_CONN_RX1_B3_CTL, 0, 5, rx_mix2_text);
 
@@ -1418,6 +1421,9 @@
 static const struct snd_kcontrol_new rx4_mix1_inp2_mux =
 	SOC_DAPM_ENUM("RX4 MIX1 INP2 Mux", rx4_mix1_inp2_chain_enum);
 
+static const struct snd_kcontrol_new rx4_mix1_inp3_mux =
+	SOC_DAPM_ENUM("RX4 MIX1 INP3 Mux", rx4_mix1_inp3_chain_enum);
+
 static const struct snd_kcontrol_new rx1_mix2_inp1_mux =
 	SOC_DAPM_ENUM("RX1 MIX2 INP1 Mux", rx1_mix2_inp1_chain_enum);
 
@@ -3154,13 +3160,27 @@
 		struct snd_soc_dai *dai)
 {
 	struct wcd9xxx *tapan_core = dev_get_drvdata(dai->codec->dev->parent);
+	struct tapan_priv *tapan = snd_soc_codec_get_drvdata(dai->codec);
+	u32 active = 0;
+
 	dev_dbg(dai->codec->dev, "%s(): substream = %s  stream = %d\n",
 		 __func__, substream->name, substream->stream);
+
+	if (dai->id <= NUM_CODEC_DAIS) {
+		if (tapan->dai[dai->id].ch_mask) {
+			active = 1;
+			dev_dbg(dai->codec->dev, "%s(): Codec DAI: chmask[%d] = 0x%lx\n",
+				 __func__, dai->id,
+				 tapan->dai[dai->id].ch_mask);
+		}
+	}
 	if ((tapan_core != NULL) &&
 	    (tapan_core->dev != NULL) &&
-	    (tapan_core->dev->parent != NULL)) {
+	    (tapan_core->dev->parent != NULL) &&
+	    (active == 0)) {
 		pm_runtime_mark_last_busy(tapan_core->dev->parent);
 		pm_runtime_put(tapan_core->dev->parent);
+		dev_dbg(dai->codec->dev, "%s: unvote requested", __func__);
 	}
 }
 
@@ -3920,6 +3940,13 @@
 			dev_dbg(codec->dev, "%s: Disconnect RX port, ret = %d\n",
 				 __func__, ret);
 		}
+		if ((core != NULL) &&
+		    (core->dev != NULL) &&
+		    (core->dev->parent != NULL)) {
+			pm_runtime_mark_last_busy(core->dev->parent);
+			pm_runtime_put(core->dev->parent);
+			dev_dbg(codec->dev, "%s: unvote requested", __func__);
+		}
 		break;
 	}
 	return ret;
@@ -3967,6 +3994,13 @@
 			dev_dbg(codec->dev, "%s: Disconnect RX port, ret = %d\n",
 				 __func__, ret);
 		}
+		if ((core != NULL) &&
+		    (core->dev != NULL) &&
+		    (core->dev->parent != NULL)) {
+			pm_runtime_mark_last_busy(core->dev->parent);
+			pm_runtime_put(core->dev->parent);
+			dev_dbg(codec->dev, "%s: unvote requested", __func__);
+		}
 		break;
 	}
 	return ret;
@@ -4139,7 +4173,7 @@
 	SND_SOC_DAPM_MUX("RX4 MIX1 INP2", SND_SOC_NOPM, 0, 0,
 		&rx4_mix1_inp2_mux),
 	SND_SOC_DAPM_MUX("RX4 MIX1 INP3", SND_SOC_NOPM, 0, 0,
-		&rx4_mix1_inp2_mux),
+		&rx4_mix1_inp3_mux),
 
 	/* RX4 MIX2 mux inputs */
 	SND_SOC_DAPM_MUX("RX4 MIX2 INP1", SND_SOC_NOPM, 0, 0,
@@ -5647,7 +5681,8 @@
 	core_res = &wcd9xxx->core_res;
 	pdata = dev_get_platdata(codec->dev->parent);
 	ret = wcd9xxx_resmgr_init(&tapan->resmgr, codec, core_res, pdata,
-				  &tapan_reg_address, WCD9XXX_CDC_TYPE_TAPAN);
+				  &pdata->micbias, &tapan_reg_address,
+				  WCD9XXX_CDC_TYPE_TAPAN);
 	if (ret) {
 		pr_err("%s: wcd9xxx init failed %d\n", __func__, ret);
 		return ret;
diff --git a/sound/soc/codecs/wcd9310.c b/sound/soc/codecs/wcd9310.c
index 673b634..725c51f 100644
--- a/sound/soc/codecs/wcd9310.c
+++ b/sound/soc/codecs/wcd9310.c
@@ -1235,49 +1235,49 @@
 	SOC_SINGLE_TLV("HPHR Volume", TABLA_A_RX_HPH_R_GAIN, 0, 12, 1,
 		line_gain),
 
-	SOC_SINGLE_S8_TLV("RX1 Digital Volume", TABLA_A_CDC_RX1_VOL_CTL_B2_CTL,
-		-84, 40, digital_gain),
-	SOC_SINGLE_S8_TLV("RX2 Digital Volume", TABLA_A_CDC_RX2_VOL_CTL_B2_CTL,
-		-84, 40, digital_gain),
-	SOC_SINGLE_S8_TLV("RX3 Digital Volume", TABLA_A_CDC_RX3_VOL_CTL_B2_CTL,
-		-84, 40, digital_gain),
-	SOC_SINGLE_S8_TLV("RX4 Digital Volume", TABLA_A_CDC_RX4_VOL_CTL_B2_CTL,
-		-84, 40, digital_gain),
-	SOC_SINGLE_S8_TLV("RX5 Digital Volume", TABLA_A_CDC_RX5_VOL_CTL_B2_CTL,
-		-84, 40, digital_gain),
-	SOC_SINGLE_S8_TLV("RX6 Digital Volume", TABLA_A_CDC_RX6_VOL_CTL_B2_CTL,
-		-84, 40, digital_gain),
-	SOC_SINGLE_S8_TLV("RX7 Digital Volume", TABLA_A_CDC_RX7_VOL_CTL_B2_CTL,
-		-84, 40, digital_gain),
+	SOC_SINGLE_SX_TLV("RX1 Digital Volume", TABLA_A_CDC_RX1_VOL_CTL_B2_CTL,
+		0, -84, 40, digital_gain),
+	SOC_SINGLE_SX_TLV("RX2 Digital Volume", TABLA_A_CDC_RX2_VOL_CTL_B2_CTL,
+		0, -84, 40, digital_gain),
+	SOC_SINGLE_SX_TLV("RX3 Digital Volume", TABLA_A_CDC_RX3_VOL_CTL_B2_CTL,
+		0, -84, 40, digital_gain),
+	SOC_SINGLE_SX_TLV("RX4 Digital Volume", TABLA_A_CDC_RX4_VOL_CTL_B2_CTL,
+		0, -84, 40, digital_gain),
+	SOC_SINGLE_SX_TLV("RX5 Digital Volume", TABLA_A_CDC_RX5_VOL_CTL_B2_CTL,
+		0, -84, 40, digital_gain),
+	SOC_SINGLE_SX_TLV("RX6 Digital Volume", TABLA_A_CDC_RX6_VOL_CTL_B2_CTL,
+		0, -84, 40, digital_gain),
+	SOC_SINGLE_SX_TLV("RX7 Digital Volume", TABLA_A_CDC_RX7_VOL_CTL_B2_CTL,
+		0, -84, 40, digital_gain),
 
-	SOC_SINGLE_S8_TLV("DEC1 Volume", TABLA_A_CDC_TX1_VOL_CTL_GAIN, -84, 40,
-		digital_gain),
-	SOC_SINGLE_S8_TLV("DEC2 Volume", TABLA_A_CDC_TX2_VOL_CTL_GAIN, -84, 40,
-		digital_gain),
-	SOC_SINGLE_S8_TLV("DEC3 Volume", TABLA_A_CDC_TX3_VOL_CTL_GAIN, -84, 40,
-		digital_gain),
-	SOC_SINGLE_S8_TLV("DEC4 Volume", TABLA_A_CDC_TX4_VOL_CTL_GAIN, -84, 40,
-		digital_gain),
-	SOC_SINGLE_S8_TLV("DEC5 Volume", TABLA_A_CDC_TX5_VOL_CTL_GAIN, -84, 40,
-		digital_gain),
-	SOC_SINGLE_S8_TLV("DEC6 Volume", TABLA_A_CDC_TX6_VOL_CTL_GAIN, -84, 40,
-		digital_gain),
-	SOC_SINGLE_S8_TLV("DEC7 Volume", TABLA_A_CDC_TX7_VOL_CTL_GAIN, -84, 40,
-		digital_gain),
-	SOC_SINGLE_S8_TLV("DEC8 Volume", TABLA_A_CDC_TX8_VOL_CTL_GAIN, -84, 40,
-		digital_gain),
-	SOC_SINGLE_S8_TLV("DEC9 Volume", TABLA_A_CDC_TX9_VOL_CTL_GAIN, -84, 40,
-		digital_gain),
-	SOC_SINGLE_S8_TLV("DEC10 Volume", TABLA_A_CDC_TX10_VOL_CTL_GAIN, -84,
+	SOC_SINGLE_SX_TLV("DEC1 Volume", TABLA_A_CDC_TX1_VOL_CTL_GAIN, 0, -84,
 		40, digital_gain),
-	SOC_SINGLE_S8_TLV("IIR1 INP1 Volume", TABLA_A_CDC_IIR1_GAIN_B1_CTL, -84,
+	SOC_SINGLE_SX_TLV("DEC2 Volume", TABLA_A_CDC_TX2_VOL_CTL_GAIN, 0, -84,
 		40, digital_gain),
-	SOC_SINGLE_S8_TLV("IIR1 INP2 Volume", TABLA_A_CDC_IIR1_GAIN_B2_CTL, -84,
+	SOC_SINGLE_SX_TLV("DEC3 Volume", TABLA_A_CDC_TX3_VOL_CTL_GAIN, 0, -84,
 		40, digital_gain),
-	SOC_SINGLE_S8_TLV("IIR1 INP3 Volume", TABLA_A_CDC_IIR1_GAIN_B3_CTL, -84,
+	SOC_SINGLE_SX_TLV("DEC4 Volume", TABLA_A_CDC_TX4_VOL_CTL_GAIN, 0, -84,
 		40, digital_gain),
-	SOC_SINGLE_S8_TLV("IIR1 INP4 Volume", TABLA_A_CDC_IIR1_GAIN_B4_CTL, -84,
+	SOC_SINGLE_SX_TLV("DEC5 Volume", TABLA_A_CDC_TX5_VOL_CTL_GAIN, 0, -84,
 		40, digital_gain),
+	SOC_SINGLE_SX_TLV("DEC6 Volume", TABLA_A_CDC_TX6_VOL_CTL_GAIN, 0, -84,
+		40, digital_gain),
+	SOC_SINGLE_SX_TLV("DEC7 Volume", TABLA_A_CDC_TX7_VOL_CTL_GAIN, 0, -84,
+		40, digital_gain),
+	SOC_SINGLE_SX_TLV("DEC8 Volume", TABLA_A_CDC_TX8_VOL_CTL_GAIN, 0, -84,
+		40, digital_gain),
+	SOC_SINGLE_SX_TLV("DEC9 Volume", TABLA_A_CDC_TX9_VOL_CTL_GAIN, 0, -84,
+		40, digital_gain),
+	SOC_SINGLE_SX_TLV("DEC10 Volume", TABLA_A_CDC_TX10_VOL_CTL_GAIN, 0,
+		-84, 40, digital_gain),
+	SOC_SINGLE_SX_TLV("IIR1 INP1 Volume", TABLA_A_CDC_IIR1_GAIN_B1_CTL, 0,
+		-84, 40, digital_gain),
+	SOC_SINGLE_SX_TLV("IIR1 INP2 Volume", TABLA_A_CDC_IIR1_GAIN_B2_CTL, 0,
+		-84, 40, digital_gain),
+	SOC_SINGLE_SX_TLV("IIR1 INP3 Volume", TABLA_A_CDC_IIR1_GAIN_B3_CTL, 0,
+		-84, 40, digital_gain),
+	SOC_SINGLE_SX_TLV("IIR1 INP4 Volume", TABLA_A_CDC_IIR1_GAIN_B4_CTL, 0,
+		-84, 40, digital_gain),
 	SOC_SINGLE_TLV("ADC1 Volume", TABLA_A_TX_1_2_EN, 5, 3, 0, analog_gain),
 	SOC_SINGLE_TLV("ADC2 Volume", TABLA_A_TX_1_2_EN, 1, 3, 0, analog_gain),
 	SOC_SINGLE_TLV("ADC3 Volume", TABLA_A_TX_3_4_EN, 5, 3, 0, analog_gain),
@@ -2155,7 +2155,7 @@
 		goto err;
 	}
 rtn:
-	snd_soc_dapm_mux_update_power(widget, kcontrol, 1, widget->value, e);
+	snd_soc_dapm_mux_update_power(widget, kcontrol, widget->value, e);
 	mutex_unlock(&codec->mutex);
 	return 0;
 err:
diff --git a/sound/soc/codecs/wcd9320.c b/sound/soc/codecs/wcd9320.c
index 5656887..c62f875 100644
--- a/sound/soc/codecs/wcd9320.c
+++ b/sound/soc/codecs/wcd9320.c
@@ -260,6 +260,8 @@
 
 #define TAIKO_FORMATS (SNDRV_PCM_FMTBIT_S16_LE)
 
+#define TAIKO_SLIM_PGD_PORT_INT_TX_EN0 (TAIKO_SLIM_PGD_PORT_INT_EN0 + 2)
+
 enum {
 	AIF1_PB = 0,
 	AIF1_CAP,
@@ -4884,6 +4886,46 @@
 	return ret;
 }
 
+static void taiko_codec_enable_int_port(struct wcd9xxx_codec_dai_data *dai,
+					  struct snd_soc_codec *codec)
+{
+	struct wcd9xxx_ch *ch;
+	int port_num = 0;
+	unsigned short reg = 0;
+	u8 val = 0;
+	if (!dai || !codec) {
+		pr_err("%s: Invalid params\n", __func__);
+		return;
+	}
+	list_for_each_entry(ch, &dai->wcd9xxx_ch_list, list) {
+		if (ch->port >= TAIKO_RX_PORT_START_NUMBER) {
+			port_num = ch->port - TAIKO_RX_PORT_START_NUMBER;
+			reg = TAIKO_SLIM_PGD_PORT_INT_EN0 + (port_num / 8);
+			val = wcd9xxx_interface_reg_read(codec->control_data,
+				reg);
+			if (!(val & (1 << (port_num % 8)))) {
+				val |= (1 << (port_num % 8));
+				wcd9xxx_interface_reg_write(
+					codec->control_data, reg, val);
+				val = wcd9xxx_interface_reg_read(
+					codec->control_data, reg);
+			}
+		} else {
+			port_num = ch->port;
+			reg = TAIKO_SLIM_PGD_PORT_INT_TX_EN0 + (port_num / 8);
+			val = wcd9xxx_interface_reg_read(codec->control_data,
+				reg);
+			if (!(val & (1 << (port_num % 8)))) {
+				val |= (1 << (port_num % 8));
+				wcd9xxx_interface_reg_write(codec->control_data,
+					reg, val);
+				val = wcd9xxx_interface_reg_read(
+					codec->control_data, reg);
+			}
+		}
+	}
+}
+
 static int taiko_codec_enable_slimrx(struct snd_soc_dapm_widget *w,
 				     struct snd_kcontrol *kcontrol,
 				     int event)
@@ -4910,6 +4952,7 @@
 
 	switch (event) {
 	case SND_SOC_DAPM_POST_PMU:
+		taiko_codec_enable_int_port(dai, codec);
 		(void) taiko_codec_enable_slim_chmask(dai, true);
 		ret = wcd9xxx_cfg_slim_sch_rx(core, &dai->wcd9xxx_ch_list,
 					      dai->rate, dai->bit_width,
@@ -4974,12 +5017,7 @@
 		/*Enable spkr VI clocks*/
 		snd_soc_update_bits(codec,
 		TAIKO_A_CDC_CLK_TX_CLK_EN_B2_CTL, 0xC, 0xC);
-		/*Enable Voltage Decimator*/
-		snd_soc_update_bits(codec,
-		TAIKO_A_CDC_CONN_TX_SB_B9_CTL, 0x1F, 0x12);
-		/*Enable Current Decimator*/
-		snd_soc_update_bits(codec,
-		TAIKO_A_CDC_CONN_TX_SB_B10_CTL, 0x1F, 0x13);
+		taiko_codec_enable_int_port(dai, codec);
 		(void) taiko_codec_enable_slim_chmask(dai, true);
 		ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
 					dai->rate, dai->bit_width,
@@ -4991,13 +5029,6 @@
 		if (ret)
 			pr_err("%s error in close_slim_sch_tx %d\n",
 				__func__, ret);
-		/*Disable Voltage decimator*/
-		snd_soc_update_bits(codec,
-		TAIKO_A_CDC_CONN_TX_SB_B9_CTL, 0x1F, 0x0);
-		/*Disable Current decimator*/
-		snd_soc_update_bits(codec,
-		TAIKO_A_CDC_CONN_TX_SB_B10_CTL, 0x1F, 0x0);
-		/*Disable spkr VI clocks*/
 		snd_soc_update_bits(codec, TAIKO_A_CDC_CLK_TX_CLK_EN_B2_CTL,
 				0xC, 0x0);
 		/*Disable V&I sensing*/
@@ -5034,6 +5065,7 @@
 	dai = &taiko_p->dai[w->shift];
 	switch (event) {
 	case SND_SOC_DAPM_POST_PMU:
+		taiko_codec_enable_int_port(dai, codec);
 		(void) taiko_codec_enable_slim_chmask(dai, true);
 		ret = wcd9xxx_cfg_slim_sch_tx(core, &dai->wcd9xxx_ch_list,
 					      dai->rate, dai->bit_width,
@@ -5642,8 +5674,9 @@
 	unsigned long status = 0;
 	int i, j, port_id, k;
 	u32 bit;
-	u8 val;
+	u8 val, int_val = 0;
 	bool tx, cleared;
+	unsigned short reg = 0;
 
 	for (i = TAIKO_SLIM_PGD_PORT_INT_STATUS_RX_0, j = 0;
 	     i <= TAIKO_SLIM_PGD_PORT_INT_STATUS_TX_1; i++, j++) {
@@ -5658,12 +5691,28 @@
 					TAIKO_SLIM_PGD_PORT_INT_RX_SOURCE0 + j);
 		if (val & TAIKO_SLIM_IRQ_OVERFLOW)
 			pr_err_ratelimited(
-			    "%s: overflow error on %s port %d, value %x\n",
-			    __func__, (tx ? "TX" : "RX"), port_id, val);
+			   "%s: overflow error on %s port %d, value %x\n",
+			   __func__, (tx ? "TX" : "RX"), port_id, val);
 		if (val & TAIKO_SLIM_IRQ_UNDERFLOW)
 			pr_err_ratelimited(
-			    "%s: underflow error on %s port %d, value %x\n",
-			    __func__, (tx ? "TX" : "RX"), port_id, val);
+			   "%s: underflow error on %s port %d, value %x\n",
+			   __func__, (tx ? "TX" : "RX"), port_id, val);
+		if ((val & TAIKO_SLIM_IRQ_OVERFLOW) ||
+			(val & TAIKO_SLIM_IRQ_UNDERFLOW)) {
+			if (!tx)
+				reg = TAIKO_SLIM_PGD_PORT_INT_EN0 +
+					(port_id / 8);
+			else
+				reg = TAIKO_SLIM_PGD_PORT_INT_TX_EN0 +
+					(port_id / 8);
+			int_val = wcd9xxx_interface_reg_read(
+				codec->control_data, reg);
+			if (int_val & (1 << (port_id % 8))) {
+				int_val = int_val ^ (1 << (port_id % 8));
+				wcd9xxx_interface_reg_write(codec->control_data,
+					reg, int_val);
+			}
+		}
 		if (val & TAIKO_SLIM_IRQ_PORT_CLOSED) {
 			/*
 			 * INT SOURCE register starts from RX to TX
@@ -5988,6 +6037,10 @@
 
 	/* Set HPH Path to low power mode */
 	TAIKO_REG_VAL(TAIKO_A_RX_HPH_BIAS_PA, 0x55),
+
+	/* BUCK default */
+	TAIKO_REG_VAL(WCD9XXX_A_BUCK_CTRL_CCL_4, 0x51),
+	TAIKO_REG_VAL(WCD9XXX_A_BUCK_CTRL_CCL_1, 0x5B),
 };
 
 static const struct wcd9xxx_reg_mask_val taiko_1_0_reg_defaults[] = {
@@ -5996,13 +6049,9 @@
 	 * Taiko 2.0 will have appropriate defaults for these registers.
 	 */
 
-	/* BUCK default */
-	TAIKO_REG_VAL(WCD9XXX_A_BUCK_CTRL_CCL_4, 0x50),
-
 	/* Required defaults for class H operation */
 	TAIKO_REG_VAL(TAIKO_A_RX_HPH_CHOP_CTL, 0xF4),
 	TAIKO_REG_VAL(TAIKO_A_BIAS_CURR_CTL_2, 0x08),
-	TAIKO_REG_VAL(WCD9XXX_A_BUCK_CTRL_CCL_1, 0x5B),
 	TAIKO_REG_VAL(WCD9XXX_A_BUCK_CTRL_CCL_3, 0x60),
 
 	/* Choose max non-overlap time for NCP */
@@ -6053,7 +6102,7 @@
 	TAIKO_REG_VAL(TAIKO_A_CDC_TX_5_6_ADC_IB, 0x44),
 	TAIKO_REG_VAL(WCD9XXX_A_BUCK_MODE_3, 0xCE),
 	TAIKO_REG_VAL(WCD9XXX_A_BUCK_CTRL_VCL_1, 0x8),
-	TAIKO_REG_VAL(WCD9XXX_A_BUCK_CTRL_CCL_4, 0x51),
+	TAIKO_REG_VAL(TAIKO_A_BUCK_CTRL_CCL_4, 0x51),
 	TAIKO_REG_VAL(TAIKO_A_NCP_DTEST, 0x10),
 	TAIKO_REG_VAL(TAIKO_A_RX_HPH_CHOP_CTL, 0xA4),
 	TAIKO_REG_VAL(TAIKO_A_RX_HPH_OCP_CTL, 0x69),
@@ -6094,6 +6143,7 @@
 	TAIKO_REG_VAL(TAIKO_A_CDC_SPKR_CLIPDET_B1_CTL, 0x0),
 	TAIKO_REG_VAL(TAIKO_A_CDC_COMP0_B4_CTL, 0x37),
 	TAIKO_REG_VAL(TAIKO_A_CDC_COMP0_B5_CTL, 0x7f),
+	TAIKO_REG_VAL(TAIKO_A_CDC_COMP0_B5_CTL, 0x7f),
 };
 
 static void taiko_update_reg_defaults(struct snd_soc_codec *codec)
@@ -6719,7 +6769,8 @@
 	core_res = &wcd9xxx->core_res;
 	pdata = dev_get_platdata(codec->dev->parent);
 	ret = wcd9xxx_resmgr_init(&taiko->resmgr, codec, core_res, pdata,
-				  &taiko_reg_address, WCD9XXX_CDC_TYPE_TAIKO);
+				  &pdata->micbias, &taiko_reg_address,
+				  WCD9XXX_CDC_TYPE_TAIKO);
 	if (ret) {
 		pr_err("%s: wcd9xxx init failed %d\n", __func__, ret);
 		goto err_init;
diff --git a/sound/soc/codecs/wcd9xxx-common.c b/sound/soc/codecs/wcd9xxx-common.c
index 05f2191..b104a6b 100644
--- a/sound/soc/codecs/wcd9xxx-common.c
+++ b/sound/soc/codecs/wcd9xxx-common.c
@@ -22,12 +22,11 @@
 #define CLSH_COMPUTE_HPH_L 0x02
 #define CLSH_COMPUTE_HPH_R 0x03
 
+#define BUCK_VREF_0P494V 0x3F
 #define BUCK_VREF_2V 0xFF
+#define BUCK_VREF_0P494V 0x3F
 #define BUCK_VREF_1P8V 0xE6
 
-#define NCP_FCLK_LEVEL_8 0x08
-#define NCP_FCLK_LEVEL_5 0x05
-
 #define BUCK_SETTLE_TIME_US 50
 #define NCP_SETTLE_TIME_US 50
 
@@ -414,12 +413,16 @@
 	{32164, 22},
 };
 
-static inline void wcd9xxx_enable_clsh_block(
-	struct snd_soc_codec *codec,
-	bool on)
+static inline void
+wcd9xxx_enable_clsh_block(struct snd_soc_codec *codec,
+			  struct wcd9xxx_clsh_cdc_data *clsh_d, bool enable)
 {
-	snd_soc_update_bits(codec, WCD9XXX_A_CDC_CLSH_B1_CTL,
-		0x01, on ? 0x01 : 0x00);
+	if ((enable && ++clsh_d->clsh_users == 1) ||
+	    (!enable && --clsh_d->clsh_users == 0))
+		snd_soc_update_bits(codec, WCD9XXX_A_CDC_CLSH_B1_CTL,
+				    0x01, enable ? 0x01 : 0x00);
+	dev_dbg(codec->dev, "%s: clsh_users %d, enable %d", __func__,
+		clsh_d->clsh_users, enable);
 }
 
 static inline void wcd9xxx_enable_anc_delay(
@@ -430,64 +433,56 @@
 		0x02, on ? 0x02 : 0x00);
 }
 
-static inline void wcd9xxx_enable_ncp(
-	struct snd_soc_codec *codec,
-	bool on)
+static inline void
+wcd9xxx_enable_buck(struct snd_soc_codec *codec,
+		    struct wcd9xxx_clsh_cdc_data *clsh_d, bool enable)
 {
-	snd_soc_update_bits(codec, WCD9XXX_A_NCP_EN,
-		0x01, on ? 0x01 : 0x00);
+	if ((enable && ++clsh_d->buck_users == 1) ||
+	    (!enable && --clsh_d->buck_users == 0))
+		snd_soc_update_bits(codec, WCD9XXX_A_BUCK_MODE_1,
+				    0x80, enable ? 0x80 : 0x00);
+	dev_dbg(codec->dev, "%s: buck_users %d, enable %d", __func__,
+		clsh_d->buck_users, enable);
 }
 
-static inline void wcd9xxx_enable_buck(
-	struct snd_soc_codec *codec,
-	bool on)
-{
-	snd_soc_update_bits(codec, WCD9XXX_A_BUCK_MODE_1,
-		0x80, on ? 0x80 : 0x00);
-}
+static void (*clsh_state_fp[NUM_CLSH_STATES])(struct snd_soc_codec *,
+					      struct wcd9xxx_clsh_cdc_data *,
+					      u8 req_state, bool req_type);
 
-static int cdc_lo_count;
-
-static void (*clsh_state_fp[NUM_CLSH_STATES])
-			(struct snd_soc_codec *,
-			 struct wcd9xxx_clsh_cdc_data *,
-			 u8 req_state, bool req_type);
-
-static const char *state_to_str(u8 state)
-{
-	if (state == WCD9XXX_CLSH_STATE_IDLE)
-		return "STATE_IDLE";
-	else if (state == WCD9XXX_CLSH_STATE_EAR)
-		return "STATE_EAR";
-	else if (state == WCD9XXX_CLSH_STATE_HPHL)
-		return "STATE_HPH_L";
-	else if (state == WCD9XXX_CLSH_STATE_HPHR)
-		return "STATE_HPH_R";
-	else if (state == (WCD9XXX_CLSH_STATE_HPHL
-				| WCD9XXX_CLSH_STATE_HPHR))
-		return "STATE_HPH_L_R";
-	else if (state == WCD9XXX_CLSH_STATE_LO)
-		return "STATE_LO";
-
-	return "UNKNOWN_STATE";
-}
-
-static void wcd9xxx_cfg_clsh_buck(
-		struct snd_soc_codec *codec)
+static const char *state_to_str(u8 state, char *buf, size_t buflen)
 {
 	int i;
-	const struct wcd9xxx_reg_mask_val reg_set[] = {
-		{WCD9XXX_A_BUCK_CTRL_CCL_4, 0x0B, 0x00},
-		{WCD9XXX_A_BUCK_CTRL_CCL_1, 0xF0, 0x50},
-		{WCD9XXX_A_BUCK_CTRL_CCL_3, 0x03, 0x00},
-		{WCD9XXX_A_BUCK_CTRL_CCL_3, 0x0B, 0x00},
+	int cnt = 0;
+	/*
+	 * This array of strings should match with enum wcd9xxx_clsh_state_bit.
+	 */
+	const char *states[] = {
+		"STATE_EAR",
+		"STATE_HPH_L",
+		"STATE_HPH_R",
+		"STATE_LO",
 	};
 
-	for (i = 0; i < ARRAY_SIZE(reg_set); i++)
-		snd_soc_update_bits(codec, reg_set[i].reg, reg_set[i].mask,
-						    reg_set[i].val);
+	if (state == WCD9XXX_CLSH_STATE_IDLE) {
+		snprintf(buf, buflen, "[STATE_IDLE]");
+		goto done;
+	}
 
-	dev_dbg(codec->dev, "%s: Programmed buck parameters", __func__);
+	buf[0] = '\0';
+	for (i = 0; i < ARRAY_SIZE(states); i++) {
+		if (!(state & (1 << i)))
+			continue;
+		cnt = snprintf(buf, buflen - cnt - 1, "%s%s%s", buf,
+			       buf[0] == '\0' ? "[" : "|",
+			       states[i]);
+	}
+	if (cnt > 0)
+		strlcat(buf + cnt, "]", buflen);
+
+done:
+	if (buf[0] == '\0')
+		snprintf(buf, buflen, "[STATE_UNKNOWN]");
+	return buf;
 }
 
 static void wcd9xxx_cfg_clsh_param_common(
@@ -515,26 +510,25 @@
 			 __func__);
 }
 
-static void wcd9xxx_chargepump_request(
-	struct snd_soc_codec *codec, bool on)
+static void wcd9xxx_chargepump_request(struct snd_soc_codec *codec, bool on)
 {
 	static int cp_count;
 
 	if (on && (++cp_count == 1)) {
 		snd_soc_update_bits(codec, WCD9XXX_A_CDC_CLK_OTHR_CTL,
-							0x01, 0x01);
+				    0x01, 0x01);
 		dev_dbg(codec->dev, "%s: Charge Pump enabled, count = %d\n",
-				__func__, cp_count);
-	}
-
-	else if (!on) {
+			__func__, cp_count);
+	} else if (!on) {
 		if (--cp_count < 0) {
-			dev_dbg(codec->dev, "%s: Unbalanced disable for charge pump\n",
+			dev_dbg(codec->dev,
+				"%s: Unbalanced disable for charge pump\n",
+				__func__);
+			if (snd_soc_read(codec, WCD9XXX_A_CDC_CLK_OTHR_CTL) &
+			    0x01) {
+				dev_dbg(codec->dev,
+					"%s: Actual chargepump is ON\n",
 					__func__);
-			if (snd_soc_read(codec, WCD9XXX_A_CDC_CLK_OTHR_CTL)
-					& 0x01) {
-				dev_dbg(codec->dev, "%s: Actual chargepump is ON\n",
-						__func__);
 			}
 			cp_count = 0;
 			WARN_ON(1);
@@ -542,9 +536,10 @@
 
 		if (cp_count == 0) {
 			snd_soc_update_bits(codec, WCD9XXX_A_CDC_CLK_OTHR_CTL,
-							0x01, 0x00);
-			dev_dbg(codec->dev, "%s: Charge pump disabled, count = %d\n",
-					__func__, cp_count);
+					    0x01, 0x00);
+			dev_dbg(codec->dev,
+				"%s: Charge pump disabled, count = %d\n",
+				__func__, cp_count);
 		}
 	}
 }
@@ -617,7 +612,6 @@
 	}
 }
 
-
 int wcd9xxx_soc_update_bits_push(struct snd_soc_codec *codec,
 					struct list_head *list,
 					uint16_t reg, uint8_t mask,
@@ -657,18 +651,15 @@
 }
 EXPORT_SYMBOL(wcd9xxx_restore_registers);
 
-static void wcd9xxx_enable_buck_mode(struct snd_soc_codec *codec,
-		u8 buck_vref)
+static void wcd9xxx_set_buck_mode(struct snd_soc_codec *codec, u8 buck_vref)
 {
 	int i;
 	const struct wcd9xxx_reg_mask_val reg_set[] = {
-		{WCD9XXX_A_BUCK_MODE_5, 0x02, 0x03},
+		{WCD9XXX_A_BUCK_MODE_5, 0x02, 0x02},
 		{WCD9XXX_A_BUCK_MODE_4, 0xFF, buck_vref},
 		{WCD9XXX_A_BUCK_MODE_1, 0x04, 0x04},
-		{WCD9XXX_A_BUCK_MODE_1, 0x08, 0x00},
 		{WCD9XXX_A_BUCK_MODE_3, 0x04, 0x00},
 		{WCD9XXX_A_BUCK_MODE_3, 0x08, 0x00},
-		{WCD9XXX_A_BUCK_MODE_1, 0x80, 0x80},
 	};
 
 	for (i = 0; i < ARRAY_SIZE(reg_set); i++)
@@ -704,25 +695,51 @@
 
 }
 
-static void wcd9xxx_set_fclk_enable_ncp(struct snd_soc_codec *codec,
-		u8 fclk_level)
+static void wcd9xxx_set_fclk_get_ncp(struct snd_soc_codec *codec,
+				     struct wcd9xxx_clsh_cdc_data *clsh_d,
+				     enum ncp_fclk_level fclk_level)
 {
-	int i;
-	const struct wcd9xxx_reg_mask_val reg_set[] = {
-		{WCD9XXX_A_NCP_STATIC, 0x20, 0x20},
-		{WCD9XXX_A_NCP_EN, 0x01, 0x01},
-	};
-	snd_soc_update_bits(codec, WCD9XXX_A_NCP_STATIC,
-						0x010, 0x00);
-	snd_soc_update_bits(codec, WCD9XXX_A_NCP_STATIC,
-						0x0F, fclk_level);
-	for (i = 0; i < ARRAY_SIZE(reg_set); i++)
-		snd_soc_update_bits(codec, reg_set[i].reg,
-					reg_set[i].mask, reg_set[i].val);
+	clsh_d->ncp_users[fclk_level]++;
 
-	usleep_range(NCP_SETTLE_TIME_US, NCP_SETTLE_TIME_US);
+	pr_debug("%s: enter ncp type %d users fclk8 %d, fclk5 %d\n", __func__,
+		 fclk_level, clsh_d->ncp_users[NCP_FCLK_LEVEL_8],
+		 clsh_d->ncp_users[NCP_FCLK_LEVEL_5]);
 
-	dev_dbg(codec->dev, "%s: set ncp done\n", __func__);
+	snd_soc_update_bits(codec, WCD9XXX_A_NCP_STATIC, 0x10, 0x00);
+	/* fclk level 8 dominates level 5 */
+	if (clsh_d->ncp_users[NCP_FCLK_LEVEL_8] > 0)
+		snd_soc_update_bits(codec, WCD9XXX_A_NCP_STATIC, 0x0F, 0x08);
+	else if (clsh_d->ncp_users[NCP_FCLK_LEVEL_5] > 0)
+		snd_soc_update_bits(codec, WCD9XXX_A_NCP_STATIC, 0x0F, 0x05);
+	else
+		WARN_ONCE(1, "Unexpected users %d,%d\n",
+			  clsh_d->ncp_users[NCP_FCLK_LEVEL_8],
+			  clsh_d->ncp_users[NCP_FCLK_LEVEL_5]);
+	snd_soc_update_bits(codec, WCD9XXX_A_NCP_STATIC, 0x20, 0x20);
+
+	/* enable NCP and wait until settles down */
+	if (snd_soc_update_bits(codec, WCD9XXX_A_NCP_EN, 0x01, 0x01))
+		usleep_range(NCP_SETTLE_TIME_US, NCP_SETTLE_TIME_US);
+	pr_debug("%s: leave\n", __func__);
+}
+
+static void wcd9xxx_set_fclk_put_ncp(struct snd_soc_codec *codec,
+				     struct wcd9xxx_clsh_cdc_data *clsh_d,
+				     enum ncp_fclk_level fclk_level)
+{
+	clsh_d->ncp_users[fclk_level]--;
+
+	pr_debug("%s: enter ncp type %d users fclk8 %d, fclk5 %d\n", __func__,
+		 fclk_level, clsh_d->ncp_users[NCP_FCLK_LEVEL_8],
+		 clsh_d->ncp_users[NCP_FCLK_LEVEL_5]);
+
+	if (clsh_d->ncp_users[NCP_FCLK_LEVEL_8] == 0 &&
+	    clsh_d->ncp_users[NCP_FCLK_LEVEL_5] == 0)
+		snd_soc_update_bits(codec, WCD9XXX_A_NCP_EN, 0x01, 0x00);
+	else if (clsh_d->ncp_users[NCP_FCLK_LEVEL_8] == 0)
+		/* if dominating level 8 has gone, switch to 5 */
+		snd_soc_update_bits(codec, WCD9XXX_A_NCP_STATIC, 0x0F, 0x05);
+	pr_debug("%s: leave\n", __func__);
 }
 
 static void wcd9xxx_cfg_clsh_param_ear(struct snd_soc_codec *codec)
@@ -790,72 +807,30 @@
 			 __func__);
 }
 
-static void wcd9xxx_clsh_turnoff_postpa
-	(struct snd_soc_codec *codec)
-{
-
-	int i;
-
-	const struct wcd9xxx_reg_mask_val reg_set[] = {
-		{WCD9XXX_A_NCP_EN, 0x01, 0x00},
-		{WCD9XXX_A_BUCK_MODE_1, 0x80, 0x00},
-		{WCD9XXX_A_CDC_CLSH_B1_CTL, 0x10, 0x00},
-	};
-
-	wcd9xxx_chargepump_request(codec, false);
-
-	for (i = 0; i < ARRAY_SIZE(reg_set); i++)
-		snd_soc_update_bits(codec, reg_set[i].reg,
-				reg_set[i].mask, reg_set[i].val);
-
-	wcd9xxx_enable_clsh_block(codec, false);
-
-	dev_dbg(codec->dev, "%s: Done\n", __func__);
-}
-
-static void wcd9xxx_clsh_state_idle(struct snd_soc_codec *codec,
-			struct wcd9xxx_clsh_cdc_data *clsh_d,
-			u8 req_state, bool is_enable)
-{
-	if (is_enable) {
-		dev_dbg(codec->dev, "%s: wrong transition, cannot enable IDLE state\n",
-			   __func__);
-	} else {
-		if (req_state == WCD9XXX_CLSH_STATE_EAR) {
-			wcd9xxx_clsh_turnoff_postpa(codec);
-		} else if (req_state == WCD9XXX_CLSH_STATE_HPHL) {
-			wcd9xxx_clsh_comp_req(codec, clsh_d, CLSH_COMPUTE_HPH_L,
-					      false);
-			wcd9xxx_clsh_turnoff_postpa(codec);
-		} else if (req_state == WCD9XXX_CLSH_STATE_HPHR) {
-			wcd9xxx_clsh_comp_req(codec, clsh_d, CLSH_COMPUTE_HPH_R,
-					      false);
-			wcd9xxx_clsh_turnoff_postpa(codec);
-		} else if (req_state == WCD9XXX_CLSH_STATE_LO) {
-			wcd9xxx_enable_ncp(codec, false);
-			wcd9xxx_enable_buck(codec, false);
-		}
-	}
-}
-
 static void wcd9xxx_clsh_state_ear(struct snd_soc_codec *codec,
 			struct wcd9xxx_clsh_cdc_data *clsh_d,
 			u8 req_state, bool is_enable)
 {
+	pr_debug("%s: enter %s\n", __func__, is_enable ? "enable" : "disable");
 	if (is_enable) {
-		wcd9xxx_cfg_clsh_buck(codec);
 		wcd9xxx_cfg_clsh_param_common(codec);
 		wcd9xxx_cfg_clsh_param_ear(codec);
-		wcd9xxx_enable_clsh_block(codec, true);
+		wcd9xxx_enable_clsh_block(codec, clsh_d, true);
 		wcd9xxx_chargepump_request(codec, true);
 		wcd9xxx_enable_anc_delay(codec, true);
 		wcd9xxx_clsh_comp_req(codec, clsh_d, CLSH_COMPUTE_EAR, true);
-		wcd9xxx_enable_buck_mode(codec, BUCK_VREF_2V);
-		wcd9xxx_set_fclk_enable_ncp(codec, NCP_FCLK_LEVEL_8);
+		wcd9xxx_set_buck_mode(codec, BUCK_VREF_2V);
+		wcd9xxx_enable_buck(codec, clsh_d, true);
+		wcd9xxx_set_fclk_get_ncp(codec, clsh_d, NCP_FCLK_LEVEL_8);
 
 		dev_dbg(codec->dev, "%s: Enabled ear mode class h\n", __func__);
 	} else {
 		dev_dbg(codec->dev, "%s: stub fallback to ear\n", __func__);
+		wcd9xxx_set_fclk_put_ncp(codec, clsh_d, NCP_FCLK_LEVEL_8);
+		wcd9xxx_enable_buck(codec, clsh_d, false);
+		wcd9xxx_clsh_comp_req(codec, clsh_d, CLSH_COMPUTE_EAR, true);
+		wcd9xxx_chargepump_request(codec, false);
+		wcd9xxx_enable_clsh_block(codec, clsh_d, false);
 	}
 }
 
@@ -863,26 +838,26 @@
 		struct wcd9xxx_clsh_cdc_data *clsh_d,
 		u8 req_state, bool is_enable)
 {
+	pr_debug("%s: enter %s\n", __func__, is_enable ? "enable" : "disable");
+
 	if (is_enable) {
-		wcd9xxx_cfg_clsh_buck(codec);
 		wcd9xxx_cfg_clsh_param_common(codec);
 		wcd9xxx_cfg_clsh_param_hph(codec);
-		wcd9xxx_enable_clsh_block(codec, true);
+		wcd9xxx_enable_clsh_block(codec, clsh_d, true);
 		wcd9xxx_chargepump_request(codec, true);
 		wcd9xxx_enable_anc_delay(codec, true);
 		wcd9xxx_clsh_comp_req(codec, clsh_d, CLSH_COMPUTE_HPH_L, true);
-		wcd9xxx_enable_buck_mode(codec, BUCK_VREF_2V);
-		wcd9xxx_set_fclk_enable_ncp(codec, NCP_FCLK_LEVEL_8);
+		wcd9xxx_set_buck_mode(codec, BUCK_VREF_0P494V);
+		wcd9xxx_enable_buck(codec, clsh_d, true);
+		wcd9xxx_set_fclk_get_ncp(codec, clsh_d, NCP_FCLK_LEVEL_8);
 
 		dev_dbg(codec->dev, "%s: Done\n", __func__);
 	} else {
-		if (req_state == WCD9XXX_CLSH_STATE_HPHR) {
-			wcd9xxx_clsh_comp_req(codec, clsh_d, CLSH_COMPUTE_HPH_R,
-					      false);
-		} else {
-			dev_dbg(codec->dev, "%s: stub fallback to hph_l\n",
-					__func__);
-		}
+		wcd9xxx_set_fclk_put_ncp(codec, clsh_d, NCP_FCLK_LEVEL_8);
+		wcd9xxx_enable_buck(codec, clsh_d, false);
+		wcd9xxx_clsh_comp_req(codec, clsh_d, CLSH_COMPUTE_HPH_L, false);
+		wcd9xxx_chargepump_request(codec, false);
+		wcd9xxx_enable_clsh_block(codec, clsh_d, false);
 	}
 }
 
@@ -890,27 +865,26 @@
 		struct wcd9xxx_clsh_cdc_data *clsh_d,
 		u8 req_state, bool is_enable)
 {
-	if (is_enable) {
+	pr_debug("%s: enter %s\n", __func__, is_enable ? "enable" : "disable");
 
-		wcd9xxx_cfg_clsh_buck(codec);
+	if (is_enable) {
 		wcd9xxx_cfg_clsh_param_common(codec);
 		wcd9xxx_cfg_clsh_param_hph(codec);
-		wcd9xxx_enable_clsh_block(codec, true);
+		wcd9xxx_enable_clsh_block(codec, clsh_d, true);
 		wcd9xxx_chargepump_request(codec, true);
 		wcd9xxx_enable_anc_delay(codec, true);
 		wcd9xxx_clsh_comp_req(codec, clsh_d, CLSH_COMPUTE_HPH_R, true);
-		wcd9xxx_enable_buck_mode(codec, BUCK_VREF_2V);
-		wcd9xxx_set_fclk_enable_ncp(codec, NCP_FCLK_LEVEL_8);
+		wcd9xxx_set_buck_mode(codec, BUCK_VREF_0P494V);
+		wcd9xxx_enable_buck(codec, clsh_d, true);
+		wcd9xxx_set_fclk_get_ncp(codec, clsh_d, NCP_FCLK_LEVEL_8);
 
 		dev_dbg(codec->dev, "%s: Done\n", __func__);
 	} else {
-		if (req_state == WCD9XXX_CLSH_STATE_HPHL) {
-			wcd9xxx_clsh_comp_req(codec, clsh_d, CLSH_COMPUTE_HPH_L,
-					      false);
-		} else {
-			dev_dbg(codec->dev, "%s: stub fallback to hph_r\n",
-					__func__);
-		}
+		wcd9xxx_set_fclk_put_ncp(codec, clsh_d, NCP_FCLK_LEVEL_8);
+		wcd9xxx_enable_buck(codec, clsh_d, false);
+		wcd9xxx_clsh_comp_req(codec, clsh_d, CLSH_COMPUTE_HPH_R, false);
+		wcd9xxx_chargepump_request(codec, false);
+		wcd9xxx_enable_clsh_block(codec, clsh_d, false);
 	}
 }
 
@@ -918,9 +892,11 @@
 		struct wcd9xxx_clsh_cdc_data *clsh_d,
 		u8 req_state, bool is_enable)
 {
+	pr_debug("%s: enter %s\n", __func__, is_enable ? "enable" : "disable");
+
 	if (is_enable) {
 		wcd9xxx_clsh_comp_req(codec, clsh_d, CLSH_COMPUTE_HPH_L, true);
-		wcd9xxx_clsh_comp_req(codec, clsh_d,  CLSH_COMPUTE_HPH_R, true);
+		wcd9xxx_clsh_comp_req(codec, clsh_d, CLSH_COMPUTE_HPH_R, true);
 	} else {
 		dev_dbg(codec->dev, "%s: stub fallback to hph_st\n", __func__);
 	}
@@ -930,38 +906,36 @@
 		struct wcd9xxx_clsh_cdc_data *clsh_d,
 		u8 req_state, bool is_enable)
 {
-	if (is_enable) {
-		if (++cdc_lo_count > 1)
-			return;
+	pr_debug("%s: enter %s, buck_mv %d\n", __func__,
+		 is_enable ? "enable" : "disable", clsh_d->buck_mv);
 
-		wcd9xxx_enable_buck_mode(codec, BUCK_VREF_1P8V);
-		wcd9xxx_set_fclk_enable_ncp(codec, NCP_FCLK_LEVEL_5);
+	if (is_enable) {
+		wcd9xxx_set_buck_mode(codec, BUCK_VREF_1P8V);
+		wcd9xxx_enable_buck(codec, clsh_d, true);
+		wcd9xxx_set_fclk_get_ncp(codec, clsh_d, NCP_FCLK_LEVEL_5);
 
 		if (clsh_d->buck_mv == WCD9XXX_CDC_BUCK_MV_1P8) {
-			wcd9xxx_enable_buck(codec, false);
+			wcd9xxx_enable_buck(codec, clsh_d, false);
 			snd_soc_update_bits(codec, WCD9XXX_A_NCP_STATIC,
-							0x20, 0x01);
-			wcd9xxx_enable_ncp(codec, true);
+					    1 << 4, 1 << 4);
 			/* NCP settle time recommended by codec specification */
 			usleep_range(NCP_SETTLE_TIME_US,
-				NCP_SETTLE_TIME_US + 10);
-
+				     NCP_SETTLE_TIME_US + 10);
 		} else {
-			snd_soc_update_bits(codec, WCD9XXX_A_NCP_EN,
-							0x40, 0x00);
-			wcd9xxx_enable_ncp(codec, true);
 			/* NCP settle time recommended by codec specification */
 			usleep_range(NCP_SETTLE_TIME_US,
-				NCP_SETTLE_TIME_US + 10);
+				     NCP_SETTLE_TIME_US + 10);
 			snd_soc_update_bits(codec, WCD9XXX_A_BUCK_MODE_5,
-							0x01, 0x01);
+					    0x01, (0x01 & 0x03));
 			snd_soc_update_bits(codec, WCD9XXX_A_BUCK_MODE_5,
-							0xFB, (0x02 << 2));
+					    0xFC, (0xFC & 0xB));
 		}
-		snd_soc_update_bits(codec, WCD9XXX_A_BUCK_MODE_1,
-							0x04, 0x00);
+		snd_soc_update_bits(codec, WCD9XXX_A_BUCK_MODE_1, 0x04, 0x00);
 	} else {
 		dev_dbg(codec->dev, "%s: stub fallback to lineout\n", __func__);
+		wcd9xxx_set_fclk_put_ncp(codec, clsh_d, NCP_FCLK_LEVEL_5);
+		if (clsh_d->buck_mv != WCD9XXX_CDC_BUCK_MV_1P8)
+			wcd9xxx_enable_buck(codec, clsh_d, false);
 	}
 }
 
@@ -969,9 +943,12 @@
 		struct wcd9xxx_clsh_cdc_data *clsh_d,
 		u8 req_state, bool is_enable)
 {
-	dev_dbg(codec->dev, "%s Wrong request for class H state machine requested to %s %s"
-			, __func__, is_enable ? "enable" : "disable",
-			state_to_str(req_state));
+	char msg[128];
+
+	dev_dbg(codec->dev,
+		"%s Wrong request for class H state machine requested to %s %s",
+		__func__, is_enable ? "enable" : "disable",
+		state_to_str(req_state, msg, sizeof(msg)));
 	WARN_ON(1);
 }
 
@@ -980,51 +957,45 @@
 		u8 req_state, bool req_type, u8 clsh_event)
 {
 	u8 old_state, new_state;
+	char msg0[128], msg1[128];
 
 	switch (clsh_event) {
-
 	case WCD9XXX_CLSH_EVENT_PRE_DAC:
-
 		/* PRE_DAC event should be used only for Enable */
 		BUG_ON(req_type != WCD9XXX_CLSH_REQ_ENABLE);
 
 		old_state = cdc_clsh_d->state;
 		new_state = old_state | req_state;
 
-		(*clsh_state_fp[new_state]) (codec, cdc_clsh_d,
-							req_state, req_type);
+		(*clsh_state_fp[req_state]) (codec, cdc_clsh_d, req_state,
+					     req_type);
 		cdc_clsh_d->state = new_state;
 		dev_dbg(codec->dev, "%s: ClassH state transition from %s to %s\n",
-			__func__, state_to_str(old_state),
-			state_to_str(cdc_clsh_d->state));
+			__func__, state_to_str(old_state, msg0, sizeof(msg0)),
+			state_to_str(cdc_clsh_d->state, msg1, sizeof(msg1)));
 
 		break;
-
 	case WCD9XXX_CLSH_EVENT_POST_PA:
-
 		if (req_type == WCD9XXX_CLSH_REQ_DISABLE) {
-			if (req_state == WCD9XXX_CLSH_STATE_LO
-					&& --cdc_lo_count > 0)
-				break;
-
 			old_state = cdc_clsh_d->state;
 			new_state = old_state & (~req_state);
 
 			if (new_state < NUM_CLSH_STATES) {
-				(*clsh_state_fp[new_state]) (codec, cdc_clsh_d,
-							req_state, req_type);
+				(*clsh_state_fp[req_state]) (codec, cdc_clsh_d,
+							     req_state,
+							     req_type);
 				cdc_clsh_d->state = new_state;
 				dev_dbg(codec->dev, "%s: ClassH state transition from %s to %s\n",
-					__func__, state_to_str(old_state),
-					state_to_str(cdc_clsh_d->state));
+					__func__, state_to_str(old_state, msg0,
+							       sizeof(msg0)),
+					state_to_str(cdc_clsh_d->state, msg1,
+						     sizeof(msg1)));
 
 			} else {
 				dev_dbg(codec->dev, "%s: wrong new state = %x\n",
 						__func__, new_state);
 			}
-
-
-		} else if (req_state != WCD9XXX_CLSH_STATE_LO) {
+		} else if (!(cdc_clsh_d->state & WCD9XXX_CLSH_STATE_LO)) {
 			wcd9xxx_clsh_enable_post_pa(codec, cdc_clsh_d);
 		}
 
@@ -1044,7 +1015,6 @@
 	for (i = 0; i < NUM_CLSH_STATES; i++)
 		clsh_state_fp[i] = wcd9xxx_clsh_state_err;
 
-	clsh_state_fp[WCD9XXX_CLSH_STATE_IDLE] = wcd9xxx_clsh_state_idle;
 	clsh_state_fp[WCD9XXX_CLSH_STATE_EAR] = wcd9xxx_clsh_state_ear;
 	clsh_state_fp[WCD9XXX_CLSH_STATE_HPHL] =
 						wcd9xxx_clsh_state_hph_l;
diff --git a/sound/soc/codecs/wcd9xxx-common.h b/sound/soc/codecs/wcd9xxx-common.h
index 0239c86..324f6e9 100644
--- a/sound/soc/codecs/wcd9xxx-common.h
+++ b/sound/soc/codecs/wcd9xxx-common.h
@@ -63,11 +63,20 @@
 	u8	val;
 };
 
+enum ncp_fclk_level {
+	NCP_FCLK_LEVEL_8,
+	NCP_FCLK_LEVEL_5,
+	NCP_FCLK_LEVEL_MAX,
+};
+
 /* Class H data that the codec driver will maintain */
 struct wcd9xxx_clsh_cdc_data {
 	u8 state;
 	int buck_mv;
 	bool is_dynamic_vdd_cp;
+	int clsh_users;
+	int buck_users;
+	int ncp_users[NCP_FCLK_LEVEL_MAX];
 	struct wcd9xxx_resmgr *resmgr;
 };
 
diff --git a/sound/soc/codecs/wcd9xxx-mbhc.c b/sound/soc/codecs/wcd9xxx-mbhc.c
index 2ecebcd..db7a34c 100644
--- a/sound/soc/codecs/wcd9xxx-mbhc.c
+++ b/sound/soc/codecs/wcd9xxx-mbhc.c
@@ -90,7 +90,7 @@
 
 #define WCD9XXX_HPHL_STATUS_READY_WAIT_US 1000
 #define WCD9XXX_MUX_SWITCH_READY_WAIT_MS 50
-#define WCD9XXX_MEAS_DELTA_MAX_MV 50
+#define WCD9XXX_MEAS_DELTA_MAX_MV 120
 #define WCD9XXX_MEAS_INVALD_RANGE_LOW_MV 20
 #define WCD9XXX_MEAS_INVALD_RANGE_HIGH_MV 80
 
@@ -128,7 +128,7 @@
 			S_IRUGO | S_IWUSR | S_IWGRP);
 MODULE_PARM_DESC(impedance_detect_en, "enable/disable impedance detect");
 
-static bool detect_use_vddio_switch = true;
+static bool detect_use_vddio_switch;
 
 struct wcd9xxx_mbhc_detect {
 	u16 dce;
@@ -222,6 +222,19 @@
 		pr_debug("Polling is not active, do not start polling\n");
 		return;
 	}
+
+	/*
+	 * setup internal micbias if codec uses internal micbias for
+	 * headset detection
+	 */
+	if (mbhc->mbhc_cfg->use_int_rbias) {
+		if (mbhc->mbhc_cb && mbhc->mbhc_cb->setup_int_rbias)
+			mbhc->mbhc_cb->setup_int_rbias(codec, true);
+		else
+			pr_err("%s: internal bias requested but codec did not provide callback\n",
+				__func__);
+	}
+
 	snd_soc_write(codec, WCD9XXX_A_MBHC_SCALING_MUX_1, 0x04);
 	if (mbhc->mbhc_cb && mbhc->mbhc_cb->enable_mux_bias_block)
 		mbhc->mbhc_cb->enable_mux_bias_block(codec);
@@ -263,11 +276,6 @@
 static int __wcd9xxx_resmgr_get_k_val(struct wcd9xxx_mbhc *mbhc,
 		unsigned int cfilt_mv)
 {
-	if (mbhc->mbhc_cb &&
-			mbhc->mbhc_cb->get_cdc_type() ==
-					WCD9XXX_CDC_TYPE_HELICON)
-		return 0x18;
-
 	return wcd9xxx_resmgr_get_k_val(mbhc->resmgr, cfilt_mv);
 }
 
@@ -592,41 +600,30 @@
 					struct mbhc_micbias_regs *micbias_regs)
 {
 	unsigned int cfilt;
-	struct wcd9xxx_pdata *pdata = mbhc->resmgr->pdata;
-
-	if (mbhc->mbhc_cb &&
-			mbhc->mbhc_cb->get_cdc_type() ==
-					WCD9XXX_CDC_TYPE_HELICON) {
-		micbias_regs->mbhc_reg = WCD9XXX_A_MICB_1_MBHC;
-		micbias_regs->int_rbias = WCD9XXX_A_MICB_1_INT_RBIAS;
-		micbias_regs->ctl_reg = WCD9XXX_A_MICB_1_CTL;
-		micbias_regs->cfilt_val = WCD9XXX_A_MICB_CFILT_1_VAL;
-		micbias_regs->cfilt_ctl = WCD9XXX_A_MICB_CFILT_1_CTL;
-		mbhc->mbhc_data.micb_mv = 1800;
-		return;
-	}
+	struct wcd9xxx_micbias_setting *micbias_pdata =
+		mbhc->resmgr->micbias_pdata;
 
 	switch (mbhc->mbhc_cfg->micbias) {
 	case MBHC_MICBIAS1:
-		cfilt = pdata->micbias.bias1_cfilt_sel;
+		cfilt = micbias_pdata->bias1_cfilt_sel;
 		micbias_regs->mbhc_reg = WCD9XXX_A_MICB_1_MBHC;
 		micbias_regs->int_rbias = WCD9XXX_A_MICB_1_INT_RBIAS;
 		micbias_regs->ctl_reg = WCD9XXX_A_MICB_1_CTL;
 		break;
 	case MBHC_MICBIAS2:
-		cfilt = pdata->micbias.bias2_cfilt_sel;
+		cfilt = micbias_pdata->bias2_cfilt_sel;
 		micbias_regs->mbhc_reg = WCD9XXX_A_MICB_2_MBHC;
 		micbias_regs->int_rbias = WCD9XXX_A_MICB_2_INT_RBIAS;
 		micbias_regs->ctl_reg = WCD9XXX_A_MICB_2_CTL;
 		break;
 	case MBHC_MICBIAS3:
-		cfilt = pdata->micbias.bias3_cfilt_sel;
+		cfilt = micbias_pdata->bias3_cfilt_sel;
 		micbias_regs->mbhc_reg = WCD9XXX_A_MICB_3_MBHC;
 		micbias_regs->int_rbias = WCD9XXX_A_MICB_3_INT_RBIAS;
 		micbias_regs->ctl_reg = WCD9XXX_A_MICB_3_CTL;
 		break;
 	case MBHC_MICBIAS4:
-		cfilt = pdata->micbias.bias4_cfilt_sel;
+		cfilt = micbias_pdata->bias4_cfilt_sel;
 		micbias_regs->mbhc_reg = mbhc->resmgr->reg_addr->micb_4_mbhc;
 		micbias_regs->int_rbias =
 		    mbhc->resmgr->reg_addr->micb_4_int_rbias;
@@ -644,20 +641,17 @@
 	case WCD9XXX_CFILT1_SEL:
 		micbias_regs->cfilt_val = WCD9XXX_A_MICB_CFILT_1_VAL;
 		micbias_regs->cfilt_ctl = WCD9XXX_A_MICB_CFILT_1_CTL;
-		mbhc->mbhc_data.micb_mv =
-		    mbhc->resmgr->pdata->micbias.cfilt1_mv;
+		mbhc->mbhc_data.micb_mv = micbias_pdata->cfilt1_mv;
 		break;
 	case WCD9XXX_CFILT2_SEL:
 		micbias_regs->cfilt_val = WCD9XXX_A_MICB_CFILT_2_VAL;
 		micbias_regs->cfilt_ctl = WCD9XXX_A_MICB_CFILT_2_CTL;
-		mbhc->mbhc_data.micb_mv =
-		    mbhc->resmgr->pdata->micbias.cfilt2_mv;
+		mbhc->mbhc_data.micb_mv = micbias_pdata->cfilt2_mv;
 		break;
 	case WCD9XXX_CFILT3_SEL:
 		micbias_regs->cfilt_val = WCD9XXX_A_MICB_CFILT_3_VAL;
 		micbias_regs->cfilt_ctl = WCD9XXX_A_MICB_CFILT_3_CTL;
-		mbhc->mbhc_data.micb_mv =
-		    mbhc->resmgr->pdata->micbias.cfilt3_mv;
+		mbhc->mbhc_data.micb_mv = micbias_pdata->cfilt3_mv;
 		break;
 	}
 }
@@ -826,25 +820,29 @@
 		mbhc->current_plug = PLUG_TYPE_NONE;
 		mbhc->polling_active = false;
 	} else {
-		if (mbhc->mbhc_cfg->detect_extn_cable) {
-			/* Report removal of current jack type */
-			if (mbhc->hph_status && mbhc->hph_status != jack_type) {
-				if (mbhc->micbias_enable &&
-				    mbhc->micbias_enable_cb &&
-				    mbhc->hph_status == SND_JACK_HEADSET) {
-					pr_debug("%s: Disabling micbias\n",
-						 __func__);
-					mbhc->micbias_enable_cb(mbhc->codec,
-								false);
-					mbhc->micbias_enable = false;
-				}
-				pr_debug("%s: Reporting removal (%x)\n",
-						__func__, mbhc->hph_status);
-				mbhc->zl = mbhc->zr = 0;
-				wcd9xxx_jack_report(mbhc, &mbhc->headset_jack,
-						    0, WCD9XXX_JACK_MASK);
-				mbhc->hph_status = 0;
+		/*
+		 * Report removal of current jack type.
+		 * Headphone to headset shouldn't report headphone
+		 * removal.
+		 */
+		if (mbhc->mbhc_cfg->detect_extn_cable &&
+		    !(mbhc->current_plug == PLUG_TYPE_HEADPHONE &&
+		      jack_type == SND_JACK_HEADSET) &&
+		    (mbhc->hph_status && mbhc->hph_status != jack_type)) {
+			if (mbhc->micbias_enable && mbhc->micbias_enable_cb &&
+			    mbhc->hph_status == SND_JACK_HEADSET) {
+				pr_debug("%s: Disabling micbias\n", __func__);
+				mbhc->micbias_enable_cb(mbhc->codec, false);
+				mbhc->micbias_enable = false;
 			}
+
+			pr_debug("%s: Reporting removal (%x)\n",
+				 __func__, mbhc->hph_status);
+			mbhc->zl = mbhc->zr = 0;
+			wcd9xxx_jack_report(mbhc, &mbhc->headset_jack,
+					    0, WCD9XXX_JACK_MASK);
+			mbhc->hph_status &= ~(SND_JACK_HEADSET |
+						SND_JACK_LINEOUT);
 		}
 		/* Report insertion */
 		mbhc->hph_status |= jack_type;
@@ -975,7 +973,9 @@
 	if (noreldetection)
 		wcd9xxx_turn_onoff_rel_detection(codec, false);
 
-	snd_soc_update_bits(codec, WCD9XXX_A_CDC_MBHC_CLK_CTL, 0x2, 0x0);
+	if (mbhc->mbhc_cfg->do_recalibration)
+		snd_soc_update_bits(codec, WCD9XXX_A_CDC_MBHC_CLK_CTL, 0x2,
+				    0x0);
 	/* Turn on the override */
 	if (!override_bypass)
 		snd_soc_update_bits(codec, WCD9XXX_A_CDC_MBHC_B1_CTL, 0x4, 0x4);
@@ -985,8 +985,9 @@
 		snd_soc_write(codec, WCD9XXX_A_CDC_MBHC_EN_CTL, 0x4);
 		snd_soc_update_bits(codec, WCD9XXX_A_CDC_MBHC_CLK_CTL, 0x8,
 				    0x0);
-		snd_soc_update_bits(codec, WCD9XXX_A_CDC_MBHC_CLK_CTL, 0x2,
-				    0x2);
+		if (mbhc->mbhc_cfg->do_recalibration)
+			snd_soc_update_bits(codec, WCD9XXX_A_CDC_MBHC_CLK_CTL,
+					    0x2, 0x2);
 		usleep_range(mbhc->mbhc_data.t_sta_dce,
 			     mbhc->mbhc_data.t_sta_dce);
 		snd_soc_write(codec, WCD9XXX_A_CDC_MBHC_EN_CTL, 0x4);
@@ -998,8 +999,9 @@
 		snd_soc_write(codec, WCD9XXX_A_CDC_MBHC_EN_CTL, 0x2);
 		snd_soc_update_bits(codec, WCD9XXX_A_CDC_MBHC_CLK_CTL, 0x8,
 				    0x0);
-		snd_soc_update_bits(codec, WCD9XXX_A_CDC_MBHC_CLK_CTL, 0x2,
-				    0x2);
+		if (mbhc->mbhc_cfg->do_recalibration)
+			snd_soc_update_bits(codec, WCD9XXX_A_CDC_MBHC_CLK_CTL,
+					    0x2, 0x2);
 		usleep_range(mbhc->mbhc_data.t_sta_dce,
 			     mbhc->mbhc_data.t_sta_dce);
 		snd_soc_write(codec, WCD9XXX_A_CDC_MBHC_EN_CTL, 0x2);
@@ -1110,8 +1112,8 @@
 		if (mbhc->mbhc_cb && mbhc->mbhc_cb->setup_int_rbias)
 			mbhc->mbhc_cb->setup_int_rbias(codec, true);
 	else
-		pr_err("%s: internal bias is requested but codec did not provide callback\n",
-			 __func__);
+		pr_err("%s: internal bias requested but codec did not provide callback\n",
+			__func__);
 	}
 
 	snd_soc_update_bits(codec, WCD9XXX_A_CLK_BUFF_EN1, 0x05, 0x01);
@@ -1143,48 +1145,59 @@
 	snd_soc_update_bits(codec, WCD9XXX_A_CDC_MBHC_B1_CTL, 0x2, 0x2);
 	snd_soc_update_bits(codec, WCD9XXX_A_CDC_MBHC_CLK_CTL, 0x8, 0x8);
 
+	if (!mbhc->mbhc_cfg->do_recalibration) {
+		if (!is_cs_enable)
+			wcd9xxx_calibrate_hs_polling(mbhc);
+	}
+
 	/* don't flip override */
 	bias_value = __wcd9xxx_codec_sta_dce(mbhc, 1, true, true);
 	snd_soc_write(codec, mbhc->mbhc_bias_regs.cfilt_ctl, cfilt_mode);
 	snd_soc_update_bits(codec, WCD9XXX_A_MBHC_HPH, 0x13, 0x00);
 
-	/* recalibrate dce_z and sta_z */
-	reg = snd_soc_read(codec, WCD9XXX_A_CDC_MBHC_B1_CTL);
-	change = snd_soc_update_bits(codec, WCD9XXX_A_CDC_MBHC_B1_CTL, 0x78,
-				     btn_det->mbhc_nsc << 3);
-	wcd9xxx_get_z(mbhc, &dce_z, &sta_z);
-	if (change)
-		snd_soc_write(codec, WCD9XXX_A_CDC_MBHC_B1_CTL, reg);
-	if (dce_z && sta_z) {
-		pr_debug("%s: sta_z 0x%x -> 0x%x, dce_z 0x%x -> 0x%x\n",
-			 __func__,
-			 mbhc->mbhc_data.sta_z, sta_z & 0xffff,
-			 mbhc->mbhc_data.dce_z, dce_z & 0xffff);
-		mbhc->mbhc_data.dce_z = dce_z;
-		mbhc->mbhc_data.sta_z = sta_z;
-		wcd9xxx_mbhc_calc_thres(mbhc);
-		wcd9xxx_calibrate_hs_polling(mbhc);
-	} else {
-		pr_warn("%s: failed get new dce_z/sta_z 0x%x/0x%x\n", __func__,
-			dce_z, sta_z);
-	}
-
-	if (is_cs_enable) {
-		/* recalibrate dce_nsc_cs_z */
-		reg = snd_soc_read(mbhc->codec, WCD9XXX_A_CDC_MBHC_B1_CTL);
-		snd_soc_update_bits(mbhc->codec, WCD9XXX_A_CDC_MBHC_B1_CTL,
-				    0x78, WCD9XXX_MBHC_NSC_CS << 3);
-		wcd9xxx_get_z(mbhc, &dce_z, NULL);
-		snd_soc_write(mbhc->codec, WCD9XXX_A_CDC_MBHC_B1_CTL, reg);
-		if (dce_z) {
-			pr_debug("%s: dce_nsc_cs_z 0x%x -> 0x%x\n", __func__,
-				 mbhc->mbhc_data.dce_nsc_cs_z, dce_z & 0xffff);
-			mbhc->mbhc_data.dce_nsc_cs_z = dce_z;
+	if (mbhc->mbhc_cfg->do_recalibration) {
+		/* recalibrate dce_z and sta_z */
+		reg = snd_soc_read(codec, WCD9XXX_A_CDC_MBHC_B1_CTL);
+		change = snd_soc_update_bits(codec, WCD9XXX_A_CDC_MBHC_B1_CTL,
+					     0x78, btn_det->mbhc_nsc << 3);
+		wcd9xxx_get_z(mbhc, &dce_z, &sta_z);
+		if (change)
+			snd_soc_write(codec, WCD9XXX_A_CDC_MBHC_B1_CTL, reg);
+		if (dce_z && sta_z) {
+			pr_debug("%s: sta_z 0x%x -> 0x%x, dce_z 0x%x -> 0x%x\n",
+				 __func__,
+				 mbhc->mbhc_data.sta_z, sta_z & 0xffff,
+				 mbhc->mbhc_data.dce_z, dce_z & 0xffff);
+			mbhc->mbhc_data.dce_z = dce_z;
+			mbhc->mbhc_data.sta_z = sta_z;
+			wcd9xxx_mbhc_calc_thres(mbhc);
+			wcd9xxx_calibrate_hs_polling(mbhc);
 		} else {
-			pr_debug("%s: failed get new dce_nsc_cs_z\n", __func__);
+			pr_warn("%s: failed get new dce_z/sta_z 0x%x/0x%x\n",
+				__func__, dce_z, sta_z);
+		}
+
+		if (is_cs_enable) {
+			/* recalibrate dce_nsc_cs_z */
+			reg = snd_soc_read(mbhc->codec,
+					   WCD9XXX_A_CDC_MBHC_B1_CTL);
+			snd_soc_update_bits(mbhc->codec,
+					    WCD9XXX_A_CDC_MBHC_B1_CTL,
+					    0x78, WCD9XXX_MBHC_NSC_CS << 3);
+			wcd9xxx_get_z(mbhc, &dce_z, NULL);
+			snd_soc_write(mbhc->codec, WCD9XXX_A_CDC_MBHC_B1_CTL,
+				      reg);
+			if (dce_z) {
+				pr_debug("%s: dce_nsc_cs_z 0x%x -> 0x%x\n",
+					 __func__, mbhc->mbhc_data.dce_nsc_cs_z,
+					 dce_z & 0xffff);
+				mbhc->mbhc_data.dce_nsc_cs_z = dce_z;
+			} else {
+				pr_debug("%s: failed get new dce_nsc_cs_z\n",
+					 __func__);
+			}
 		}
 	}
-
 	return bias_value;
 }
 
@@ -1305,6 +1318,7 @@
 	const struct wcd9xxx_mbhc_plug_type_cfg *plug_type =
 	    WCD9XXX_MBHC_CAL_PLUG_TYPE_PTR(mbhc->mbhc_cfg->calibration);
 	s16 hs_max, no_mic, dce_z;
+	int highhph_cnt = 0;
 
 	pr_debug("%s: enter\n", __func__);
 	pr_debug("%s: event_state 0x%lx\n", __func__, event_state);
@@ -1329,9 +1343,10 @@
 		d->_vdces = vdce;
 		if (d->_vdces < no_mic)
 			d->_type = PLUG_TYPE_HEADPHONE;
-		else if (d->_vdces >= hs_max)
+		else if (d->_vdces >= hs_max) {
 			d->_type = PLUG_TYPE_HIGH_HPH;
-		else
+			highhph_cnt++;
+		} else
 			d->_type = PLUG_TYPE_HEADSET;
 
 		pr_debug("%s: DCE #%d, %04x, V %04d(%04d), HPHL %d TYPE %d\n",
@@ -1366,7 +1381,8 @@
 		goto exit;
 	}
 
-	delta_thr = highhph ? WCD9XXX_MB_MEAS_DELTA_MAX_MV :
+	delta_thr = ((highhph_cnt == sz) || highhph) ?
+			      WCD9XXX_MB_MEAS_DELTA_MAX_MV :
 			      WCD9XXX_CS_MEAS_DELTA_MAX_MV;
 
 	for (i = 0, d = dt; i < sz; i++, d++) {
@@ -1751,6 +1767,7 @@
 
 	/* GND and MIC swap detection requires at least 2 rounds of DCE */
 	BUG_ON(NUM_DCE_PLUG_INS_DETECT < 2);
+	detect_use_vddio_switch = mbhc->mbhc_cfg->use_vddio_meas;
 
 	/*
 	 * There are chances vddio switch is on and cfilt voltage is adjusted
@@ -2858,6 +2875,10 @@
 	if (wcd9xxx_cancel_btn_work(mbhc))
 		pr_debug("%s: button press is canceled\n", __func__);
 
+	/* cancel detect plug */
+	wcd9xxx_cancel_hs_detect_plug(mbhc,
+				      &mbhc->correct_plug_swch);
+
 	insert = !wcd9xxx_swch_level_remove(mbhc);
 	pr_debug("%s: Current plug type %d, insert %d\n", __func__,
 		 mbhc->current_plug, insert);
@@ -2865,9 +2886,6 @@
 		mbhc->lpi_enabled = false;
 		wmb();
 
-		/* cancel detect plug */
-		wcd9xxx_cancel_hs_detect_plug(mbhc,
-					      &mbhc->correct_plug_swch);
 		if ((mbhc->current_plug != PLUG_TYPE_NONE) &&
 		    !(snd_soc_read(codec, WCD9XXX_A_MBHC_INSERT_DETECT) &
 				   (1 << 1)))
@@ -2882,10 +2900,6 @@
 		mbhc->lpi_enabled = false;
 		wmb();
 
-		/* cancel detect plug */
-		wcd9xxx_cancel_hs_detect_plug(mbhc,
-					      &mbhc->correct_plug_swch);
-
 		if (mbhc->current_plug == PLUG_TYPE_HEADPHONE) {
 			wcd9xxx_report_plug(mbhc, 0, SND_JACK_HEADPHONE);
 			is_removed = true;
@@ -2904,6 +2918,11 @@
 		}
 
 		if (is_removed) {
+			snd_soc_write(codec, WCD9XXX_A_MBHC_SCALING_MUX_1,
+				      0x00);
+			snd_soc_update_bits(codec, WCD9XXX_A_CDC_MBHC_B1_CTL,
+					    0x02, 0x00);
+
 			/* Enable Mic Bias pull down and HPH Switch to GND */
 			snd_soc_update_bits(codec,
 					mbhc->mbhc_bias_regs.ctl_reg, 0x01,
@@ -3182,6 +3201,19 @@
 		goto done;
 	}
 
+	/*
+	 * setup internal micbias if codec uses internal micbias for
+	 * headset detection
+	 */
+	if (mbhc->mbhc_cfg->use_int_rbias) {
+		if (mbhc->mbhc_cb && mbhc->mbhc_cb->setup_int_rbias)
+			mbhc->mbhc_cb->setup_int_rbias(codec, true);
+		else
+			pr_err("%s: internal bias requested but codec did not provide callback\n",
+				__func__);
+	}
+
+
 	/* Measure scaled HW DCE */
 	vddio = (mbhc->mbhc_data.micb_mv != VDDIO_MICBIAS_MV &&
 		 mbhc->mbhc_micbias_switched);
@@ -4002,11 +4034,12 @@
 	 * headset detection
 	 */
 	if (mbhc->mbhc_cfg->use_int_rbias) {
-		if (mbhc->mbhc_cb && mbhc->mbhc_cb->setup_int_rbias)
+		if (mbhc->mbhc_cb && mbhc->mbhc_cb->setup_int_rbias) {
 			mbhc->mbhc_cb->setup_int_rbias(codec, true);
-		else
-			pr_info("%s: internal bias is requested but codec did not provide callback\n",
+		} else {
+			pr_info("%s: internal bias requested but codec did not provide callback\n",
 				__func__);
+		}
 	}
 
 	/*
@@ -4112,20 +4145,21 @@
 static int wcd9xxx_get_mbhc_cfilt_sel(struct wcd9xxx_mbhc *mbhc)
 {
 	int cfilt;
-	const struct wcd9xxx_pdata *pdata = mbhc->resmgr->pdata;
+	const struct wcd9xxx_micbias_setting *mb_pdata =
+		mbhc->resmgr->micbias_pdata;
 
 	switch (mbhc->mbhc_cfg->micbias) {
 	case MBHC_MICBIAS1:
-		cfilt = pdata->micbias.bias1_cfilt_sel;
+		cfilt = mb_pdata->bias1_cfilt_sel;
 		break;
 	case MBHC_MICBIAS2:
-		cfilt = pdata->micbias.bias2_cfilt_sel;
+		cfilt = mb_pdata->bias2_cfilt_sel;
 		break;
 	case MBHC_MICBIAS3:
-		cfilt = pdata->micbias.bias3_cfilt_sel;
+		cfilt = mb_pdata->bias3_cfilt_sel;
 		break;
 	case MBHC_MICBIAS4:
-		cfilt = pdata->micbias.bias4_cfilt_sel;
+		cfilt = mb_pdata->bias4_cfilt_sel;
 		break;
 	default:
 		cfilt = MBHC_MICBIAS_INVALID;
@@ -4193,10 +4227,11 @@
 			   (1 << MBHC_EVENT_PA_HPHL | 1 << MBHC_EVENT_PA_HPHR))
 				wcd9xxx_switch_micbias(mbhc, 1);
 			/*
-			 * Disable MBHC TxFE, in case it was enabled
-			 * earlier when micbias was enabled.
+			 * Disable MBHC TxFE, in case it was enabled earlier
+			 * when micbias was enabled and polling is not active.
 			 */
-			wcd9xxx_enable_mbhc_txfe(mbhc, false);
+			if (!mbhc->polling_active)
+				wcd9xxx_enable_mbhc_txfe(mbhc, false);
 		}
 		break;
 	/* PA usage change */
@@ -4363,13 +4398,7 @@
 	 */
 	mutex_lock(&codec->mutex);
 
-	/*
-	 * Fast(mbhc) mode bandagap doesn't need to be enabled explicitly
-	 * since fast mode is set by MBHC hardware when override is on.
-	 * Enable bandgap mode to avoid unnecessary RCO disable and enable
-	 * during clock source change.
-	 */
-	wcd9xxx_mbhc_ctrl_clk_bandgap(mbhc, true);
+	wcd9xxx_onoff_ext_mclk(mbhc, true);
 
 	wcd9xxx_turn_onoff_override(mbhc, true);
 	pr_debug("%s: Setting impedance detection\n", __func__);
@@ -4417,7 +4446,7 @@
 
 	mutex_unlock(&codec->mutex);
 
-	wcd9xxx_mbhc_ctrl_clk_bandgap(mbhc, false);
+	wcd9xxx_onoff_ext_mclk(mbhc, false);
 
 	wcd9xxx_turn_onoff_override(mbhc, false);
 	mbhc->mbhc_cb->compute_impedance(l, r, zl, zr);
@@ -4487,7 +4516,6 @@
 	mbhc->mbhc_cb = mbhc_cb;
 	mbhc->intr_ids = mbhc_cdc_intr_ids;
 	mbhc->impedance_detect = impedance_det_en;
-	impedance_detect_en = impedance_det_en ? 1 : 0;
 
 	if (mbhc->intr_ids == NULL) {
 		pr_err("%s: Interrupt mapping not provided\n", __func__);
@@ -4536,6 +4564,14 @@
 
 	wcd9xxx_init_debugfs(mbhc);
 
+
+	/* Disable Impedance detection by default for certain codec types */
+	if (mbhc->mbhc_cb &&
+	    mbhc->mbhc_cb->get_cdc_type() == WCD9XXX_CDC_TYPE_HELICON)
+		impedance_detect_en = 0;
+	else
+		impedance_detect_en = impedance_det_en ? 1 : 0;
+
 	core_res = mbhc->resmgr->core_res;
 	ret = wcd9xxx_request_irq(core_res, mbhc->intr_ids->insertion,
 				  wcd9xxx_hs_insert_irq,
diff --git a/sound/soc/codecs/wcd9xxx-mbhc.h b/sound/soc/codecs/wcd9xxx-mbhc.h
index 9d0afe9..29dd84a 100644
--- a/sound/soc/codecs/wcd9xxx-mbhc.h
+++ b/sound/soc/codecs/wcd9xxx-mbhc.h
@@ -228,6 +228,8 @@
 	bool (*swap_gnd_mic) (struct snd_soc_codec *);
 	unsigned long cs_enable_flags;
 	bool use_int_rbias;
+	bool do_recalibration;
+	bool use_vddio_meas;
 };
 
 struct wcd9xxx_cfilt_mode {
@@ -336,7 +338,6 @@
 	u32 rco_clk_rate;
 
 	bool update_z;
-
 	/* Holds codec specific interrupt mapping */
 	const struct wcd9xxx_mbhc_intr *intr_ids;
 
diff --git a/sound/soc/codecs/wcd9xxx-resmgr.c b/sound/soc/codecs/wcd9xxx-resmgr.c
index cb76342..e18593a 100644
--- a/sound/soc/codecs/wcd9xxx-resmgr.c
+++ b/sound/soc/codecs/wcd9xxx-resmgr.c
@@ -561,6 +561,13 @@
 		if (--resmgr->clk_rco_users == 0 &&
 		    resmgr->clk_type == WCD9XXX_CLK_RCO) {
 			wcd9xxx_disable_clock_block(resmgr);
+			/* if RCO is enabled, switch from it */
+			if (snd_soc_read(resmgr->codec, WCD9XXX_A_RC_OSC_FREQ) & 0x80) {
+				if (resmgr->codec_type != WCD9XXX_CDC_TYPE_HELICON)
+					snd_soc_write(resmgr->codec, WCD9XXX_A_CLK_BUFF_EN2,
+							0x02);
+				wcd9xxx_resmgr_enable_config_mode(resmgr, 0);
+			}
 			resmgr->clk_type = WCD9XXX_CLK_OFF;
 		}
 		break;
@@ -658,7 +665,7 @@
 			     unsigned int cfilt_mv)
 {
 	int rc = -EINVAL;
-	unsigned int ldoh_v = resmgr->pdata->micbias.ldoh_v;
+	unsigned int ldoh_v = resmgr->micbias_pdata->ldoh_v;
 	unsigned min_mv, max_mv;
 
 	switch (ldoh_v) {
@@ -843,6 +850,7 @@
 			struct snd_soc_codec *codec,
 			struct wcd9xxx_core_resource *core_res,
 			struct wcd9xxx_pdata *pdata,
+			struct wcd9xxx_micbias_setting *micbias_pdata,
 			struct wcd9xxx_reg_address *reg_addr,
 			enum wcd9xxx_cdc_type cdc_type)
 {
@@ -856,6 +864,7 @@
 	/* This gives access of core handle to lock/unlock suspend */
 	resmgr->core_res = core_res;
 	resmgr->pdata = pdata;
+	resmgr->micbias_pdata = micbias_pdata;
 	resmgr->reg_addr = reg_addr;
 
 	INIT_LIST_HEAD(&resmgr->update_bit_cond_h);
diff --git a/sound/soc/codecs/wcd9xxx-resmgr.h b/sound/soc/codecs/wcd9xxx-resmgr.h
index 7fb5820..603bd1e 100644
--- a/sound/soc/codecs/wcd9xxx-resmgr.h
+++ b/sound/soc/codecs/wcd9xxx-resmgr.h
@@ -137,6 +137,8 @@
 
 	struct wcd9xxx_pdata *pdata;
 
+	struct wcd9xxx_micbias_setting *micbias_pdata;
+
 	struct blocking_notifier_head notifier;
 	/* Notifier needs mbhc pointer with resmgr */
 	struct wcd9xxx_mbhc *mbhc;
@@ -162,6 +164,7 @@
 			struct snd_soc_codec *codec,
 			struct wcd9xxx_core_resource *core_res,
 			struct wcd9xxx_pdata *pdata,
+			struct wcd9xxx_micbias_setting *micbias_pdata,
 			struct wcd9xxx_reg_address *reg_addr,
 			enum wcd9xxx_cdc_type cdc_type);
 void wcd9xxx_resmgr_deinit(struct wcd9xxx_resmgr *resmgr);
diff --git a/sound/soc/msm/apq8074.c b/sound/soc/msm/apq8074.c
index 3a055e2..5b12b9c 100644
--- a/sound/soc/msm/apq8074.c
+++ b/sound/soc/msm/apq8074.c
@@ -19,18 +19,22 @@
 #include <linux/mfd/pm8xxx/pm8921.h>
 #include <linux/qpnp/clkdiv.h>
 #include <linux/regulator/consumer.h>
+#include <linux/io.h>
 #include <sound/core.h>
 #include <sound/soc.h>
 #include <sound/soc-dapm.h>
 #include <sound/pcm.h>
 #include <sound/jack.h>
 #include <sound/q6afe-v2.h>
-#include <asm/mach-types.h>
-#include <mach/socinfo.h>
 #include <sound/pcm_params.h>
+#include <asm/mach-types.h>
+#include <mach/subsystem_notif.h>
+#include <mach/socinfo.h>
+
 #include "qdsp6v2/msm-pcm-routing-v2.h"
+#include "qdsp6v2/q6core.h"
+#include "../codecs/wcd9xxx-common.h"
 #include "../codecs/wcd9320.h"
-#include <linux/io.h>
 
 #define DRV_NAME "apq8074-asoc-taiko"
 
@@ -82,6 +86,10 @@
 
 #define NUM_OF_AUXPCM_GPIOS 4
 
+static void *adsp_state_notifier;
+
+#define ADSP_STATE_READY_TIMEOUT_MS 3000
+
 static inline int param_is_mask(int p)
 {
 	return ((p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
@@ -1230,6 +1238,101 @@
 	return true;
 }
 
+static int msm_afe_set_config(struct snd_soc_codec *codec)
+{
+	int rc;
+	void *config_data;
+
+	pr_debug("%s: enter\n", __func__);
+	config_data = taiko_get_afe_config(codec, AFE_CDC_REGISTERS_CONFIG);
+	rc = afe_set_config(AFE_CDC_REGISTERS_CONFIG, config_data, 0);
+	if (rc) {
+		pr_err("%s: Failed to set codec registers config %d\n",
+		       __func__, rc);
+		return rc;
+	}
+
+	config_data = taiko_get_afe_config(codec, AFE_SLIMBUS_SLAVE_CONFIG);
+	rc = afe_set_config(AFE_SLIMBUS_SLAVE_CONFIG, config_data, 0);
+	if (rc) {
+		pr_err("%s: Failed to set slimbus slave config %d\n", __func__,
+		       rc);
+		return rc;
+	}
+
+	return 0;
+}
+
+static void msm_afe_clear_config(void)
+{
+	afe_clear_config(AFE_CDC_REGISTERS_CONFIG);
+	afe_clear_config(AFE_SLIMBUS_SLAVE_CONFIG);
+}
+
+static int  msm8974_adsp_state_callback(struct notifier_block *nb,
+		unsigned long value, void *priv)
+{
+	if (value == SUBSYS_BEFORE_SHUTDOWN) {
+		pr_debug("%s: ADSP is about to shutdown. Clearing AFE config\n",
+			 __func__);
+		msm_afe_clear_config();
+	} else if (value == SUBSYS_AFTER_POWERUP) {
+		pr_debug("%s: ADSP is up\n", __func__);
+	}
+
+	return NOTIFY_OK;
+}
+
+static struct notifier_block adsp_state_notifier_block = {
+	.notifier_call = msm8974_adsp_state_callback,
+	.priority = -INT_MAX,
+};
+
+static int msm8974_taiko_codec_up(struct snd_soc_codec *codec)
+{
+	int err;
+	unsigned long timeout;
+	int adsp_ready = 0;
+
+	timeout = jiffies +
+		msecs_to_jiffies(ADSP_STATE_READY_TIMEOUT_MS);
+
+	do {
+		if (!q6core_is_adsp_ready()) {
+			pr_err("%s: ADSP Audio isn't ready\n", __func__);
+		} else {
+			pr_debug("%s: ADSP Audio is ready\n", __func__);
+			adsp_ready = 1;
+			break;
+		}
+	} while (time_after(timeout, jiffies));
+
+	if (!adsp_ready) {
+		pr_err("%s: timed out waiting for ADSP Audio\n", __func__);
+		return -ETIMEDOUT;
+	}
+
+	err = msm_afe_set_config(codec);
+	if (err)
+		pr_err("%s: Failed to set AFE config. err %d\n",
+				__func__, err);
+	return err;
+}
+
+static int apq8074_taiko_event_cb(struct snd_soc_codec *codec,
+		enum wcd9xxx_codec_event codec_event)
+{
+	switch (codec_event) {
+	case WCD9XXX_CODEC_EVENT_CODEC_UP:
+		return msm8974_taiko_codec_up(codec);
+		break;
+	default:
+		pr_err("%s: UnSupported codec event %d\n",
+				__func__, codec_event);
+		return -EINVAL;
+	}
+}
+
 static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd)
 {
 	int err;
@@ -1291,19 +1394,9 @@
 				    tx_ch, ARRAY_SIZE(rx_ch), rx_ch);
 
 
-	config_data = taiko_get_afe_config(codec, AFE_CDC_REGISTERS_CONFIG);
-	err = afe_set_config(AFE_CDC_REGISTERS_CONFIG, config_data, 0);
+	err = msm_afe_set_config(codec);
 	if (err) {
-		pr_err("%s: Failed to set codec registers config %d\n",
-		       __func__, err);
-		goto out;
-	}
-
-	config_data = taiko_get_afe_config(codec, AFE_SLIMBUS_SLAVE_CONFIG);
-	err = afe_set_config(AFE_SLIMBUS_SLAVE_CONFIG, config_data, 0);
-	if (err) {
-		pr_err("%s: Failed to set slimbus slave config %d\n", __func__,
-		       err);
+		pr_err("%s: Failed to set AFE config %d\n", __func__, err);
 		goto out;
 	}
 
@@ -1340,12 +1433,23 @@
 		err = taiko_hs_detect(codec, &mbhc_cfg);
 		if (err)
 			goto out;
-		else
-			return err;
 	} else {
 		err = -ENOMEM;
 		goto out;
 	}
+	adsp_state_notifier =
+	    subsys_notif_register_notifier("adsp",
+					   &adsp_state_notifier_block);
+	if (!adsp_state_notifier) {
+		pr_err("%s: Failed to register adsp state notifier\n",
+		       __func__);
+		err = -EFAULT;
+		taiko_hs_detect_exit(codec);
+		goto out;
+	}
+
+	taiko_event_register(apq8074_taiko_event_cb, rtd->codec);
+	return 0;
 out:
 	clk_put(codec_clk);
 	return err;
diff --git a/sound/soc/msm/msm-pcm-host-voice.c b/sound/soc/msm/msm-pcm-host-voice.c
index 2eafc1d..1b68bcf 100644
--- a/sound/soc/msm/msm-pcm-host-voice.c
+++ b/sound/soc/msm/msm-pcm-host-voice.c
@@ -989,7 +989,7 @@
 			spin_unlock_irqrestore(&dai_data->dsp_lock, dsp_flags);
 			ret = copy_to_user(buf,
 					   &buf_node->frame.voc_pkt,
-					   count);
+					   buf_node->frame.len);
 			if (ret) {
 				pr_err("%s: Copy to user retuned %d\n",
 					__func__, ret);
diff --git a/sound/soc/msm/msm8226.c b/sound/soc/msm/msm8226.c
index 40de65b..05d6c62 100644
--- a/sound/soc/msm/msm8226.c
+++ b/sound/soc/msm/msm8226.c
@@ -94,6 +94,8 @@
 	.cs_enable_flags = (1 << MBHC_CS_ENABLE_POLLING |
 			    1 << MBHC_CS_ENABLE_INSERTION |
 			    1 << MBHC_CS_ENABLE_REMOVAL),
+	.do_recalibration = true,
+	.use_vddio_meas = true,
 };
 
 struct msm_auxpcm_gpio {
@@ -688,6 +690,22 @@
 	return 0;
 }
 
+static int msm_be_fm_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
+				struct snd_pcm_hw_params *params)
+{
+	struct snd_interval *rate = hw_param_interval(params,
+					SNDRV_PCM_HW_PARAM_RATE);
+
+	struct snd_interval *channels = hw_param_interval(params,
+			SNDRV_PCM_HW_PARAM_CHANNELS);
+
+	pr_debug("%s()\n", __func__);
+	rate->min = rate->max = 48000;
+	channels->min = channels->max = 2;
+
+	return 0;
+}
+
 static const struct soc_enum msm_snd_enum[] = {
 	SOC_ENUM_SINGLE_EXT(2, slim0_rx_ch_text),
 	SOC_ENUM_SINGLE_EXT(4, slim0_tx_ch_text),
@@ -1369,7 +1387,7 @@
 		.codec_dai_name = "msm-stub-rx",
 		.no_pcm = 1,
 		.be_id = MSM_BACKEND_DAI_INT_FM_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
+		.be_hw_params_fixup = msm_be_fm_hw_params_fixup,
 		/* this dainlink has playback support */
 		.ignore_pmdown_time = 1,
 		.ignore_suspend = 1,
diff --git a/sound/soc/msm/msm8974.c b/sound/soc/msm/msm8974.c
index e612eec..381992d 100644
--- a/sound/soc/msm/msm8974.c
+++ b/sound/soc/msm/msm8974.c
@@ -58,16 +58,9 @@
 #define LO_2_SPK_AMP	0x4
 #define LO_4_SPK_AMP	0x8
 
-#define LPAIF_OFFSET 0xFE000000
-#define LPAIF_PRI_MODE_MUXSEL (LPAIF_OFFSET + 0x2B000)
-#define LPAIF_SEC_MODE_MUXSEL (LPAIF_OFFSET + 0x2C000)
-#define LPAIF_TER_MODE_MUXSEL (LPAIF_OFFSET + 0x2D000)
-#define LPAIF_QUAD_MODE_MUXSEL (LPAIF_OFFSET + 0x2E000)
-
 #define I2S_PCM_SEL 1
 #define I2S_PCM_SEL_OFFSET 1
 
-
 #define WCD9XXX_MBHC_DEF_BUTTONS 8
 #define WCD9XXX_MBHC_DEF_RLOADS 5
 #define TAIKO_EXT_CLK_RATE 9600000
@@ -136,6 +129,8 @@
 	.cs_enable_flags = (1 << MBHC_CS_ENABLE_POLLING |
 			    1 << MBHC_CS_ENABLE_INSERTION |
 			    1 << MBHC_CS_ENABLE_REMOVAL),
+	.do_recalibration = true,
+	.use_vddio_meas = true,
 };
 
 struct msm_auxpcm_gpio {
@@ -146,6 +141,7 @@
 struct msm_auxpcm_ctrl {
 	struct msm_auxpcm_gpio *pin_data;
 	u32 cnt;
+	void __iomem *mux;
 };
 
 struct msm8974_asoc_mach_data {
@@ -173,9 +169,6 @@
 	{"SEC_AUXPCM_DOUT",      "qcom,sec-auxpcm-gpio-dout"},
 };
 
-void *lpaif_pri_muxsel_virt_addr;
-void *lpaif_sec_muxsel_virt_addr;
-
 struct msm8974_liquid_dock_dev {
 	int dock_plug_gpio;
 	int dock_plug_irq;
@@ -1192,12 +1185,14 @@
 		goto err;
 	}
 	if (atomic_inc_return(&prim_auxpcm_rsc_ref) == 1) {
-		if (lpaif_pri_muxsel_virt_addr != NULL)
+		if (auxpcm_ctrl->mux != NULL) {
 			iowrite32(I2S_PCM_SEL << I2S_PCM_SEL_OFFSET,
-				lpaif_pri_muxsel_virt_addr);
-		else
-			pr_err("%s lpaif_pri_muxsel_virt_addr is NULL\n",
-				 __func__);
+				  auxpcm_ctrl->mux);
+		} else {
+			pr_err("%s: Pri AUXPCM MUX addr is NULL\n", __func__);
+			ret = -EINVAL;
+			goto err;
+		}
 		ret = msm_aux_pcm_get_gpios(auxpcm_ctrl);
 	}
 	if (ret < 0) {
@@ -1247,12 +1242,14 @@
 		goto err;
 	}
 	if (atomic_inc_return(&sec_auxpcm_rsc_ref) == 1) {
-		if (lpaif_sec_muxsel_virt_addr != NULL)
+		if (auxpcm_ctrl->mux != NULL) {
 			iowrite32(I2S_PCM_SEL << I2S_PCM_SEL_OFFSET,
-				lpaif_sec_muxsel_virt_addr);
-		else
-			pr_err("%s lpaif_sec_muxsel_virt_addr is NULL\n",
-				 __func__);
+				  auxpcm_ctrl->mux);
+		} else {
+			pr_err("%s Sec AUXPCM MUX addr is NULL\n", __func__);
+			ret = -EINVAL;
+			goto err;
+		}
 		ret = msm_aux_pcm_get_gpios(auxpcm_ctrl);
 	}
 	if (ret < 0) {
@@ -1377,6 +1374,22 @@
 	return 0;
 }
 
+static int msm_be_fm_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
+				struct snd_pcm_hw_params *params)
+{
+	struct snd_interval *rate = hw_param_interval(params,
+					SNDRV_PCM_HW_PARAM_RATE);
+
+	struct snd_interval *channels =
+	    hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS);
+
+	pr_debug("%s()\n", __func__);
+	rate->min = rate->max = 48000;
+	channels->min = channels->max = 2;
+
+	return 0;
+}
+
 static const struct soc_enum msm_snd_enum[] = {
 	SOC_ENUM_SINGLE_EXT(2, spk_function),
 	SOC_ENUM_SINGLE_EXT(2, slim0_rx_ch_text),
@@ -2262,7 +2275,7 @@
 		.codec_dai_name = "msm-stub-rx",
 		.no_pcm = 1,
 		.be_id = MSM_BACKEND_DAI_INT_FM_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
+		.be_hw_params_fixup = msm_be_fm_hw_params_fixup,
 		/* this dainlink has playback support */
 		.ignore_pmdown_time = 1,
 		.ignore_suspend = 1,
@@ -2651,6 +2664,8 @@
 	int ret;
 	const char *auxpcm_pri_gpio_set = NULL;
 	const char *prop_name_ult_lo_gpio = "qcom,ext-ult-lo-amp-gpio";
+	struct resource	*pri_muxsel;
+	struct resource	*sec_muxsel;
 
 	if (!pdev->dev.of_node) {
 		dev_err(&pdev->dev, "No platform supplied from device tree\n");
@@ -2778,7 +2793,6 @@
 		}
 	}
 
-
 	pdata->us_euro_gpio = of_get_named_gpio(pdev->dev.of_node,
 				"qcom,us-euro-gpios", 0);
 	if (pdata->us_euro_gpio < 0) {
@@ -2805,28 +2819,49 @@
 		goto err1;
 	}
 	if (!strcmp(auxpcm_pri_gpio_set, "prim-gpio-prim")) {
-		lpaif_pri_muxsel_virt_addr = ioremap(LPAIF_PRI_MODE_MUXSEL, 4);
+		pri_muxsel = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+						"lpaif_pri_mode_muxsel");
 	} else if (!strcmp(auxpcm_pri_gpio_set, "prim-gpio-tert")) {
-		lpaif_pri_muxsel_virt_addr = ioremap(LPAIF_TER_MODE_MUXSEL, 4);
+		pri_muxsel = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+						"lpaif_tert_mode_muxsel");
 	} else {
 		dev_err(&pdev->dev, "Invalid value %s for AUXPCM GPIO set\n",
 			auxpcm_pri_gpio_set);
 		ret = -EINVAL;
 		goto err1;
 	}
-	if (lpaif_pri_muxsel_virt_addr == NULL) {
-		pr_err("%s Pri muxsel virt addr is null\n", __func__);
-		ret = -EINVAL;
-		goto err1;
+	if (!pri_muxsel) {
+		dev_err(&pdev->dev, "MUX addr invalid for primary AUXPCM\n");
+			ret = -ENODEV;
+			goto err1;
+	} else {
+		pdata->pri_auxpcm_ctrl->mux = ioremap(pri_muxsel->start,
+						    resource_size(pri_muxsel));
+		if (pdata->pri_auxpcm_ctrl->mux == NULL) {
+			pr_err("%s Pri muxsel virt addr is null\n", __func__);
+			ret = -EINVAL;
+			goto err1;
+		}
 	}
-	lpaif_sec_muxsel_virt_addr = ioremap(LPAIF_SEC_MODE_MUXSEL, 4);
-	if (lpaif_sec_muxsel_virt_addr == NULL) {
+
+	sec_muxsel = platform_get_resource_byname(pdev, IORESOURCE_MEM,
+						"lpaif_sec_mode_muxsel");
+	if (!sec_muxsel) {
+		dev_err(&pdev->dev, "MUX addr invalid for secondary AUXPCM\n");
+		ret = -ENODEV;
+		goto err2;
+	}
+	pdata->sec_auxpcm_ctrl->mux = ioremap(sec_muxsel->start,
+					     resource_size(sec_muxsel));
+	if (pdata->sec_auxpcm_ctrl->mux == NULL) {
 		pr_err("%s Sec muxsel virt addr is null\n", __func__);
 		ret = -EINVAL;
-		goto err1;
+		goto err2;
 	}
 	return 0;
 
+err2:
+	iounmap(pdata->pri_auxpcm_ctrl->mux);
 err1:
 	if (ext_ult_lo_amp_gpio >= 0)
 		gpio_free(ext_ult_lo_amp_gpio);
@@ -2880,8 +2915,8 @@
 		msm8974_liquid_dock_dev = NULL;
 	}
 
-	iounmap(lpaif_pri_muxsel_virt_addr);
-	iounmap(lpaif_sec_muxsel_virt_addr);
+	iounmap(pdata->pri_auxpcm_ctrl->mux);
+	iounmap(pdata->sec_auxpcm_ctrl->mux);
 	snd_soc_unregister_card(card);
 
 	return 0;
diff --git a/sound/soc/msm/msm8x10.c b/sound/soc/msm/msm8x10.c
index c318849..6ac86cc 100644
--- a/sound/soc/msm/msm8x10.c
+++ b/sound/soc/msm/msm8x10.c
@@ -74,6 +74,11 @@
 	.insert_detect = true,
 	.swap_gnd_mic = NULL,
 	.use_int_rbias = false,
+	.cs_enable_flags = (1 << MBHC_CS_ENABLE_POLLING |
+			    1 << MBHC_CS_ENABLE_INSERTION |
+			    1 << MBHC_CS_ENABLE_REMOVAL),
+	.do_recalibration = false,
+	.use_vddio_meas = false,
 };
 
 /*
@@ -210,6 +215,22 @@
 	return 0;
 }
 
+static int msm_be_fm_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
+				struct snd_pcm_hw_params *params)
+{
+	struct snd_interval *rate = hw_param_interval(params,
+					SNDRV_PCM_HW_PARAM_RATE);
+
+	struct snd_interval *channels = hw_param_interval(params,
+					SNDRV_PCM_HW_PARAM_CHANNELS);
+
+	pr_debug("%s()\n", __func__);
+	rate->min = rate->max = 48000;
+	channels->min = channels->max = 2;
+
+	return 0;
+}
+
 static int msm_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
 				struct snd_pcm_hw_params *params)
 {
@@ -538,7 +559,7 @@
 #undef S
 #define S(X, Y) ((WCD9XXX_MBHC_CAL_PLUG_TYPE_PTR(msm8x10_wcd_cal)->X) = (Y))
 	S(v_no_mic, 30);
-	S(v_hs_max, 1650);
+	S(v_hs_max, 2550);
 #undef S
 #define S(X, Y) ((WCD9XXX_MBHC_CAL_BTN_DET_PTR(msm8x10_wcd_cal)->X) = (Y))
 	S(c[0], 62);
@@ -902,7 +923,7 @@
 		.codec_dai_name = "msm-stub-rx",
 		.no_pcm = 1,
 		.be_id = MSM_BACKEND_DAI_INT_FM_RX,
-		.be_hw_params_fixup = msm_be_hw_params_fixup,
+		.be_hw_params_fixup = msm_be_fm_hw_params_fixup,
 		/* this dainlink has playback support */
 		.ignore_pmdown_time = 1,
 		.ignore_suspend = 1,
diff --git a/sound/soc/msm/qdsp6v2/audio_acdb.c b/sound/soc/msm/qdsp6v2/audio_acdb.c
index 01422cf..cc2fd50 100644
--- a/sound/soc/msm/qdsp6v2/audio_acdb.c
+++ b/sound/soc/msm/qdsp6v2/audio_acdb.c
@@ -38,64 +38,60 @@
 
 #define MAX_HW_DELAY_ENTRIES	25
 
-struct sidetone_atomic_cal {
-	atomic_t	enable;
-	atomic_t	gain;
-};
-
-
 struct acdb_data {
+	uint32_t		usage_count;
+
 	struct mutex		acdb_mutex;
 
 	/* ANC Cal */
-	struct acdb_atomic_cal_block	anc_cal;
+	struct acdb_cal_block		anc_cal;
 
 	/* AANC Cal */
-	struct acdb_atomic_cal_block    aanc_cal;
+	struct acdb_cal_block		aanc_cal;
 
 	/* LSM Cal */
-	struct acdb_atomic_cal_block	lsm_cal;
+	struct acdb_cal_block		lsm_cal;
 
 	/* AudProc Cal */
-	atomic_t			asm_topology;
-	atomic_t			adm_topology[MAX_AUDPROC_TYPES];
-	struct acdb_atomic_cal_block	audproc_cal[MAX_AUDPROC_TYPES];
-	struct acdb_atomic_cal_block	audstrm_cal[MAX_AUDPROC_TYPES];
-	struct acdb_atomic_cal_block	audvol_cal[MAX_AUDPROC_TYPES];
+	uint32_t			asm_topology;
+	uint32_t			adm_topology[MAX_AUDPROC_TYPES];
+	struct acdb_cal_block		audproc_cal[MAX_AUDPROC_TYPES];
+	struct acdb_cal_block		audstrm_cal[MAX_AUDPROC_TYPES];
+	struct acdb_cal_block		audvol_cal[MAX_AUDPROC_TYPES];
 
 	/* VocProc Cal */
-	atomic_t			voice_rx_topology;
-	atomic_t			voice_tx_topology;
-	struct acdb_atomic_cal_block	vocproc_cal;
-	struct acdb_atomic_cal_block	vocstrm_cal;
-	struct acdb_atomic_cal_block	vocvol_cal;
+	uint32_t			voice_rx_topology;
+	uint32_t			voice_tx_topology;
+	struct acdb_cal_block		vocproc_cal;
+	struct acdb_cal_block		vocstrm_cal;
+	struct acdb_cal_block		vocvol_cal;
 
 	/* Voice Column data */
-	struct acdb_atomic_cal_block	vocproc_col_cal[MAX_VOCPROC_TYPES];
+	struct acdb_cal_block		vocproc_col_cal[MAX_VOCPROC_TYPES];
 	uint32_t			*col_data[MAX_VOCPROC_TYPES];
 
 	/* VocProc dev cfg cal*/
-	struct acdb_atomic_cal_block	vocproc_dev_cal;
+	struct acdb_cal_block		vocproc_dev_cal;
 
 	/* Custom topology */
-	struct acdb_atomic_cal_block	adm_custom_topology;
-	struct acdb_atomic_cal_block	asm_custom_topology;
-	atomic_t			valid_adm_custom_top;
-	atomic_t			valid_asm_custom_top;
+	struct acdb_cal_block		adm_custom_topology;
+	struct acdb_cal_block		asm_custom_topology;
+	uint32_t			valid_adm_custom_top;
+	uint32_t			valid_asm_custom_top;
 
 	/* AFE cal */
-	struct acdb_atomic_cal_block	afe_cal[MAX_AUDPROC_TYPES];
+	struct acdb_cal_block		afe_cal[MAX_AUDPROC_TYPES];
 
 	/* Sidetone Cal */
-	struct sidetone_atomic_cal	sidetone_cal;
+	struct sidetone_cal		sidetone_cal;
 
 	/* Allocation information */
 	struct ion_client		*ion_client;
 	struct ion_handle		*ion_handle;
-	atomic_t			map_handle;
-	atomic64_t			paddr;
-	atomic64_t			kvaddr;
-	atomic64_t			mem_len;
+	uint32_t			map_handle;
+	uint64_t			paddr;
+	uint64_t			kvaddr;
+	uint64_t			mem_len;
 
 	/* Speaker protection */
 	struct msm_spk_prot_cfg spk_prot_cfg;
@@ -106,62 +102,63 @@
 };
 
 static struct acdb_data		acdb_data;
-static atomic_t usage_count;
 
 uint32_t get_voice_rx_topology(void)
 {
-	return atomic_read(&acdb_data.voice_rx_topology);
+	return acdb_data.voice_rx_topology;
 }
 
 void store_voice_rx_topology(uint32_t topology)
 {
-	atomic_set(&acdb_data.voice_rx_topology, topology);
+	acdb_data.voice_rx_topology = topology;
 }
 
 uint32_t get_voice_tx_topology(void)
 {
-	return atomic_read(&acdb_data.voice_tx_topology);
+	return acdb_data.voice_tx_topology;
 }
 
 void store_voice_tx_topology(uint32_t topology)
 {
-	atomic_set(&acdb_data.voice_tx_topology, topology);
+	acdb_data.voice_tx_topology = topology;
 }
 
 uint32_t get_adm_rx_topology(void)
 {
-	return atomic_read(&acdb_data.adm_topology[RX_CAL]);
+	return acdb_data.adm_topology[RX_CAL];
 }
 
 void store_adm_rx_topology(uint32_t topology)
 {
-	atomic_set(&acdb_data.adm_topology[RX_CAL], topology);
+	acdb_data.adm_topology[RX_CAL] = topology;
 }
 
 uint32_t get_adm_tx_topology(void)
 {
-	return atomic_read(&acdb_data.adm_topology[TX_CAL]);
+	return acdb_data.adm_topology[TX_CAL];
 }
 
 void store_adm_tx_topology(uint32_t topology)
 {
-	atomic_set(&acdb_data.adm_topology[TX_CAL], topology);
+	acdb_data.adm_topology[TX_CAL] = topology;
 }
 
 uint32_t get_asm_topology(void)
 {
-	return atomic_read(&acdb_data.asm_topology);
+	return acdb_data.asm_topology;
 }
 
 void store_asm_topology(uint32_t topology)
 {
-	atomic_set(&acdb_data.asm_topology, topology);
+	acdb_data.asm_topology = topology;
 }
 
 void reset_custom_topology_flags(void)
 {
-	atomic_set(&acdb_data.valid_adm_custom_top, 1);
-	atomic_set(&acdb_data.valid_asm_custom_top, 1);
+	mutex_lock(&acdb_data.acdb_mutex);
+	acdb_data.valid_adm_custom_top = 1;
+	acdb_data.valid_asm_custom_top = 1;
+	mutex_unlock(&acdb_data.acdb_mutex);
 }
 
 int get_adm_custom_topology(struct acdb_cal_block *cal_block)
@@ -175,19 +172,19 @@
 		goto done;
 	}
 
+	mutex_lock(&acdb_data.acdb_mutex);
 	/* Only return allow one access after memory registered */
-	if (atomic_read(&acdb_data.valid_adm_custom_top) == 0) {
+	if (acdb_data.valid_adm_custom_top == 0) {
 		cal_block->cal_size = 0;
-		goto done;
+		goto unlock;
 	}
-	atomic_set(&acdb_data.valid_adm_custom_top, 0);
+	acdb_data.valid_adm_custom_top = 0;
 
-	cal_block->cal_size =
-		atomic_read(&acdb_data.adm_custom_topology.cal_size);
-	cal_block->cal_paddr =
-		atomic_read(&acdb_data.adm_custom_topology.cal_paddr);
-	cal_block->cal_kvaddr =
-		atomic_read(&acdb_data.adm_custom_topology.cal_kvaddr);
+	cal_block->cal_size = acdb_data.adm_custom_topology.cal_size;
+	cal_block->cal_paddr = acdb_data.adm_custom_topology.cal_paddr;
+	cal_block->cal_kvaddr = acdb_data.adm_custom_topology.cal_kvaddr;
+unlock:
+	mutex_unlock(&acdb_data.acdb_mutex);
 done:
 	return result;
 }
@@ -197,21 +194,18 @@
 	int result = 0;
 	pr_debug("%s,\n", __func__);
 
-	if (cal_block->cal_offset > atomic64_read(&acdb_data.mem_len)) {
-		pr_err("%s: offset %d is > mem_len %ld\n",
-			__func__, cal_block->cal_offset,
-			(long)atomic64_read(&acdb_data.mem_len));
+	if (cal_block->cal_offset > acdb_data.mem_len) {
+		pr_err("%s: offset %d is > mem_len %llu\n",
+			__func__, cal_block->cal_offset, acdb_data.mem_len);
 		result = -EINVAL;
 		goto done;
 	}
 
-	atomic_set(&acdb_data.adm_custom_topology.cal_size,
-		cal_block->cal_size);
-	atomic_set(&acdb_data.adm_custom_topology.cal_paddr,
-		cal_block->cal_offset + atomic64_read(&acdb_data.paddr));
-	atomic_set(&acdb_data.adm_custom_topology.cal_kvaddr,
-		cal_block->cal_offset +
-		atomic64_read(&acdb_data.kvaddr));
+	acdb_data.adm_custom_topology.cal_size = cal_block->cal_size;
+	acdb_data.adm_custom_topology.cal_paddr =
+		cal_block->cal_offset + acdb_data.paddr;
+	acdb_data.adm_custom_topology.cal_kvaddr =
+		cal_block->cal_offset + acdb_data.kvaddr;
 done:
 	return result;
 }
@@ -227,19 +221,19 @@
 		goto done;
 	}
 
+	mutex_lock(&acdb_data.acdb_mutex);
 	/* Only return allow one access after memory registered */
-	if (atomic_read(&acdb_data.valid_asm_custom_top) == 0) {
+	if (acdb_data.valid_asm_custom_top == 0) {
 		cal_block->cal_size = 0;
-		goto done;
+		goto unlock;
 	}
-	atomic_set(&acdb_data.valid_asm_custom_top, 0);
+	acdb_data.valid_asm_custom_top = 0;
 
-	cal_block->cal_size =
-		atomic_read(&acdb_data.asm_custom_topology.cal_size);
-	cal_block->cal_paddr =
-		atomic_read(&acdb_data.asm_custom_topology.cal_paddr);
-	cal_block->cal_kvaddr =
-		atomic_read(&acdb_data.asm_custom_topology.cal_kvaddr);
+	cal_block->cal_size = acdb_data.asm_custom_topology.cal_size;
+	cal_block->cal_paddr = acdb_data.asm_custom_topology.cal_paddr;
+	cal_block->cal_kvaddr = acdb_data.asm_custom_topology.cal_kvaddr;
+unlock:
+	mutex_unlock(&acdb_data.acdb_mutex);
 done:
 	return result;
 }
@@ -249,21 +243,18 @@
 	int result = 0;
 	pr_debug("%s,\n", __func__);
 
-	if (cal_block->cal_offset > atomic64_read(&acdb_data.mem_len)) {
-		pr_err("%s: offset %d is > mem_len %ld\n",
-			__func__, cal_block->cal_offset,
-			(long)atomic64_read(&acdb_data.mem_len));
+	if (cal_block->cal_offset > acdb_data.mem_len) {
+		pr_err("%s: offset %d is > mem_len %llu\n",
+			__func__, cal_block->cal_offset, acdb_data.mem_len);
 		result = -EINVAL;
 		goto done;
 	}
 
-	atomic_set(&acdb_data.asm_custom_topology.cal_size,
-		cal_block->cal_size);
-	atomic_set(&acdb_data.asm_custom_topology.cal_paddr,
-		cal_block->cal_offset + atomic64_read(&acdb_data.paddr));
-	atomic_set(&acdb_data.asm_custom_topology.cal_kvaddr,
-		cal_block->cal_offset +
-		atomic64_read(&acdb_data.kvaddr));
+	acdb_data.asm_custom_topology.cal_size = cal_block->cal_size;
+	acdb_data.asm_custom_topology.cal_paddr =
+		cal_block->cal_offset + acdb_data.paddr;
+	acdb_data.asm_custom_topology.cal_kvaddr =
+		cal_block->cal_offset + acdb_data.kvaddr;
 done:
 	return result;
 }
@@ -280,10 +271,8 @@
 	}
 
 	cal_block->cal_size = ACDB_TOTAL_VOICE_ALLOCATION;
-	cal_block->cal_paddr =
-		atomic_read(&acdb_data.vocproc_cal.cal_paddr);
-	cal_block->cal_kvaddr =
-		atomic_read(&acdb_data.vocproc_cal.cal_kvaddr);
+	cal_block->cal_paddr = acdb_data.vocproc_cal.cal_paddr;
+	cal_block->cal_kvaddr = acdb_data.vocproc_cal.cal_kvaddr;
 done:
 	return result;
 }
@@ -299,12 +288,9 @@
 		goto done;
 	}
 
-	cal_block->cal_size =
-		atomic_read(&acdb_data.aanc_cal.cal_size);
-	cal_block->cal_paddr =
-		atomic_read(&acdb_data.aanc_cal.cal_paddr);
-	cal_block->cal_kvaddr =
-		atomic_read(&acdb_data.aanc_cal.cal_kvaddr);
+	cal_block->cal_size = acdb_data.aanc_cal.cal_size;
+	cal_block->cal_paddr = acdb_data.aanc_cal.cal_paddr;
+	cal_block->cal_kvaddr = acdb_data.aanc_cal.cal_kvaddr;
 done:
 	return result;
 }
@@ -314,20 +300,18 @@
 	int result = 0;
 	pr_debug("%s,\n", __func__);
 
-	if (cal_block->cal_offset > atomic64_read(&acdb_data.mem_len)) {
-		pr_err("%s: offset %d is > mem_len %ld\n",
-		 __func__, cal_block->cal_offset,
-		(long)atomic64_read(&acdb_data.mem_len));
+	if (cal_block->cal_offset > acdb_data.mem_len) {
+		pr_err("%s: offset %d is > mem_len %llu\n",
+		 __func__, cal_block->cal_offset, acdb_data.mem_len);
 		result = -EINVAL;
 		goto done;
 	}
 
-	atomic_set(&acdb_data.aanc_cal.cal_size,
-		cal_block->cal_size);
-	atomic_set(&acdb_data.aanc_cal.cal_paddr,
-		cal_block->cal_offset + atomic64_read(&acdb_data.paddr));
-	atomic_set(&acdb_data.aanc_cal.cal_kvaddr,
-		cal_block->cal_offset + atomic64_read(&acdb_data.kvaddr));
+	acdb_data.aanc_cal.cal_size = cal_block->cal_size;
+	acdb_data.aanc_cal.cal_paddr =
+		cal_block->cal_offset + acdb_data.paddr;
+	acdb_data.aanc_cal.cal_kvaddr =
+		cal_block->cal_offset + acdb_data.kvaddr;
 done:
 	return result;
 }
@@ -343,12 +327,9 @@
 		goto done;
 	}
 
-	cal_block->cal_size =
-		atomic_read(&acdb_data.lsm_cal.cal_size);
-	cal_block->cal_paddr =
-		atomic_read(&acdb_data.lsm_cal.cal_paddr);
-	cal_block->cal_kvaddr =
-		atomic_read(&acdb_data.lsm_cal.cal_kvaddr);
+	cal_block->cal_size = acdb_data.lsm_cal.cal_size;
+	cal_block->cal_paddr = acdb_data.lsm_cal.cal_paddr;
+	cal_block->cal_kvaddr = acdb_data.lsm_cal.cal_kvaddr;
 done:
 	return result;
 }
@@ -358,20 +339,18 @@
 	int result = 0;
 	pr_debug("%s,\n", __func__);
 
-	if (cal_block->cal_offset > atomic64_read(&acdb_data.mem_len)) {
-		pr_err("%s: offset %d is > mem_len %ld\n",
-			__func__, cal_block->cal_offset,
-			(long)atomic64_read(&acdb_data.mem_len));
+	if (cal_block->cal_offset > acdb_data.mem_len) {
+		pr_err("%s: offset %d is > mem_len %llu\n",
+			__func__, cal_block->cal_offset, acdb_data.mem_len);
 		result = -EINVAL;
 		goto done;
 	}
 
-	atomic_set(&acdb_data.lsm_cal.cal_size,
-		cal_block->cal_size);
-	atomic_set(&acdb_data.lsm_cal.cal_paddr,
-		cal_block->cal_offset + atomic64_read(&acdb_data.paddr));
-	atomic_set(&acdb_data.lsm_cal.cal_kvaddr,
-		cal_block->cal_offset + atomic64_read(&acdb_data.kvaddr));
+	acdb_data.lsm_cal.cal_size = cal_block->cal_size;
+	acdb_data.lsm_cal.cal_paddr =
+		cal_block->cal_offset + acdb_data.paddr;
+	acdb_data.lsm_cal.cal_kvaddr =
+		cal_block->cal_offset + acdb_data.kvaddr;
 done:
 	return result;
 }
@@ -470,7 +449,6 @@
 	pr_debug("ACDB=> %s : Path = %d num_entries = %d\n",
 		 __func__, path, delay.num_entries);
 
-	mutex_lock(&acdb_data.acdb_mutex);
 	if (path == RX_CAL)
 		delay_dest = &acdb_data.hw_delay_rx;
 	else if (path == TX_CAL)
@@ -487,7 +465,6 @@
 		       __func__, result, path);
 		result = -EFAULT;
 	}
-	mutex_unlock(&acdb_data.acdb_mutex);
 done:
 	return result;
 }
@@ -503,12 +480,9 @@
 		goto done;
 	}
 
-	cal_block->cal_size =
-		atomic_read(&acdb_data.anc_cal.cal_size);
-	cal_block->cal_paddr =
-		atomic_read(&acdb_data.anc_cal.cal_paddr);
-	cal_block->cal_kvaddr =
-		atomic_read(&acdb_data.anc_cal.cal_kvaddr);
+	cal_block->cal_size = acdb_data.anc_cal.cal_size;
+	cal_block->cal_paddr = acdb_data.anc_cal.cal_paddr;
+	cal_block->cal_kvaddr = acdb_data.anc_cal.cal_kvaddr;
 done:
 	return result;
 }
@@ -518,20 +492,18 @@
 	int result = 0;
 	pr_debug("%s,\n", __func__);
 
-	if (cal_block->cal_offset > atomic64_read(&acdb_data.mem_len)) {
-		pr_err("%s: offset %d is > mem_len %ld\n",
-			__func__, cal_block->cal_offset,
-			(long)atomic64_read(&acdb_data.mem_len));
+	if (cal_block->cal_offset > acdb_data.mem_len) {
+		pr_err("%s: offset %d is > mem_len %llu\n",
+			__func__, cal_block->cal_offset, acdb_data.mem_len);
 		result = -EINVAL;
 		goto done;
 	}
 
-	atomic_set(&acdb_data.anc_cal.cal_size,
-		cal_block->cal_size);
-	atomic_set(&acdb_data.anc_cal.cal_paddr,
-		cal_block->cal_offset + atomic64_read(&acdb_data.paddr));
-	atomic_set(&acdb_data.anc_cal.cal_kvaddr,
-		cal_block->cal_offset + atomic64_read(&acdb_data.kvaddr));
+	acdb_data.anc_cal.cal_size = cal_block->cal_size;
+	acdb_data.anc_cal.cal_paddr =
+		cal_block->cal_offset + acdb_data.paddr;
+	acdb_data.anc_cal.cal_kvaddr =
+		cal_block->cal_offset + acdb_data.kvaddr;
 done:
 	return result;
 }
@@ -541,10 +513,9 @@
 	int result = 0;
 	pr_debug("%s, path = %d\n", __func__, path);
 
-	if (cal_block->cal_offset > atomic64_read(&acdb_data.mem_len)) {
-		pr_err("%s: offset %d is > mem_len %ld\n",
-			__func__, cal_block->cal_offset,
-			(long)atomic64_read(&acdb_data.mem_len));
+	if (cal_block->cal_offset > acdb_data.mem_len) {
+		pr_err("%s: offset %d is > mem_len %llu\n",
+			__func__, cal_block->cal_offset, acdb_data.mem_len);
 		result = -EINVAL;
 		goto done;
 	}
@@ -555,12 +526,11 @@
 		goto done;
 	}
 
-	atomic_set(&acdb_data.afe_cal[path].cal_size,
-		cal_block->cal_size);
-	atomic_set(&acdb_data.afe_cal[path].cal_paddr,
-		cal_block->cal_offset + atomic64_read(&acdb_data.paddr));
-	atomic_set(&acdb_data.afe_cal[path].cal_kvaddr,
-		cal_block->cal_offset + atomic64_read(&acdb_data.kvaddr));
+	acdb_data.afe_cal[path].cal_size = cal_block->cal_size;
+	acdb_data.afe_cal[path].cal_paddr =
+		cal_block->cal_offset + acdb_data.paddr;
+	acdb_data.afe_cal[path].cal_kvaddr =
+		cal_block->cal_offset + acdb_data.kvaddr;
 done:
 	return result;
 }
@@ -582,12 +552,9 @@
 		goto done;
 	}
 
-	cal_block->cal_size =
-		atomic_read(&acdb_data.afe_cal[path].cal_size);
-	cal_block->cal_paddr =
-		atomic_read(&acdb_data.afe_cal[path].cal_paddr);
-	cal_block->cal_kvaddr =
-		atomic_read(&acdb_data.afe_cal[path].cal_kvaddr);
+	cal_block->cal_size = acdb_data.afe_cal[path].cal_size;
+	cal_block->cal_paddr = acdb_data.afe_cal[path].cal_paddr;
+	cal_block->cal_kvaddr = acdb_data.afe_cal[path].cal_kvaddr;
 done:
 	return result;
 }
@@ -597,10 +564,9 @@
 	int result = 0;
 	pr_debug("%s, path = %d\n", __func__, path);
 
-	if (cal_block->cal_offset > atomic64_read(&acdb_data.mem_len)) {
-		pr_err("%s: offset %d is > mem_len %ld\n",
-			__func__, cal_block->cal_offset,
-			(long)atomic64_read(&acdb_data.mem_len));
+	if (cal_block->cal_offset > acdb_data.mem_len) {
+		pr_err("%s: offset %d is > mem_len %llu\n",
+			__func__, cal_block->cal_offset, acdb_data.mem_len);
 		result = -EINVAL;
 		goto done;
 	}
@@ -611,12 +577,11 @@
 		goto done;
 	}
 
-	atomic_set(&acdb_data.audproc_cal[path].cal_size,
-		cal_block->cal_size);
-	atomic_set(&acdb_data.audproc_cal[path].cal_paddr,
-		cal_block->cal_offset + atomic64_read(&acdb_data.paddr));
-	atomic_set(&acdb_data.audproc_cal[path].cal_kvaddr,
-		cal_block->cal_offset + atomic64_read(&acdb_data.kvaddr));
+	acdb_data.audproc_cal[path].cal_size = cal_block->cal_size;
+	acdb_data.audproc_cal[path].cal_paddr =
+		cal_block->cal_offset + acdb_data.paddr;
+	acdb_data.audproc_cal[path].cal_kvaddr =
+		cal_block->cal_offset + acdb_data.kvaddr;
 done:
 	return result;
 }
@@ -638,12 +603,9 @@
 		goto done;
 	}
 
-	cal_block->cal_size =
-		atomic_read(&acdb_data.audproc_cal[path].cal_size);
-	cal_block->cal_paddr =
-		atomic_read(&acdb_data.audproc_cal[path].cal_paddr);
-	cal_block->cal_kvaddr =
-		atomic_read(&acdb_data.audproc_cal[path].cal_kvaddr);
+	cal_block->cal_size = acdb_data.audproc_cal[path].cal_size;
+	cal_block->cal_paddr = acdb_data.audproc_cal[path].cal_paddr;
+	cal_block->cal_kvaddr = acdb_data.audproc_cal[path].cal_kvaddr;
 done:
 	return result;
 }
@@ -653,10 +615,9 @@
 	int result = 0;
 	pr_debug("%s, path = %d\n", __func__, path);
 
-	if (cal_block->cal_offset > atomic64_read(&acdb_data.mem_len)) {
-		pr_err("%s: offset %d is > mem_len %ld\n",
-			__func__, cal_block->cal_offset,
-			(long)atomic64_read(&acdb_data.mem_len));
+	if (cal_block->cal_offset > acdb_data.mem_len) {
+		pr_err("%s: offset %d is > mem_len %llu\n",
+			__func__, cal_block->cal_offset, acdb_data.mem_len);
 		result = -EINVAL;
 		goto done;
 	}
@@ -667,12 +628,11 @@
 		goto done;
 	}
 
-	atomic_set(&acdb_data.audstrm_cal[path].cal_size,
-		cal_block->cal_size);
-	atomic_set(&acdb_data.audstrm_cal[path].cal_paddr,
-		cal_block->cal_offset + atomic64_read(&acdb_data.paddr));
-	atomic_set(&acdb_data.audstrm_cal[path].cal_kvaddr,
-		cal_block->cal_offset + atomic64_read(&acdb_data.kvaddr));
+	acdb_data.audstrm_cal[path].cal_size = cal_block->cal_size;
+	acdb_data.audstrm_cal[path].cal_paddr =
+		cal_block->cal_offset + acdb_data.paddr;
+	acdb_data.audstrm_cal[path].cal_kvaddr =
+		cal_block->cal_offset + acdb_data.kvaddr;
 done:
 	return result;
 }
@@ -694,12 +654,9 @@
 		goto done;
 	}
 
-	cal_block->cal_size =
-		atomic_read(&acdb_data.audstrm_cal[path].cal_size);
-	cal_block->cal_paddr =
-		atomic_read(&acdb_data.audstrm_cal[path].cal_paddr);
-	cal_block->cal_kvaddr =
-		atomic_read(&acdb_data.audstrm_cal[path].cal_kvaddr);
+	cal_block->cal_size = acdb_data.audstrm_cal[path].cal_size;
+	cal_block->cal_paddr = acdb_data.audstrm_cal[path].cal_paddr;
+	cal_block->cal_kvaddr = acdb_data.audstrm_cal[path].cal_kvaddr;
 done:
 	return result;
 }
@@ -709,10 +666,9 @@
 	int result = 0;
 	pr_debug("%s, path = %d\n", __func__, path);
 
-	if (cal_block->cal_offset > atomic64_read(&acdb_data.mem_len)) {
-		pr_err("%s: offset %d is > mem_len %ld\n",
-			__func__, cal_block->cal_offset,
-			(long)atomic64_read(&acdb_data.mem_len));
+	if (cal_block->cal_offset > acdb_data.mem_len) {
+		pr_err("%s: offset %d is > mem_len %llu\n",
+			__func__, cal_block->cal_offset, acdb_data.mem_len);
 		result = -EINVAL;
 		goto done;
 	}
@@ -723,12 +679,11 @@
 		goto done;
 	}
 
-	atomic_set(&acdb_data.audvol_cal[path].cal_size,
-		cal_block->cal_size);
-	atomic_set(&acdb_data.audvol_cal[path].cal_paddr,
-		cal_block->cal_offset + atomic64_read(&acdb_data.paddr));
-	atomic_set(&acdb_data.audvol_cal[path].cal_kvaddr,
-		cal_block->cal_offset + atomic64_read(&acdb_data.kvaddr));
+	acdb_data.audvol_cal[path].cal_size = cal_block->cal_size;
+	acdb_data.audvol_cal[path].cal_paddr =
+		cal_block->cal_offset + acdb_data.paddr;
+	acdb_data.audvol_cal[path].cal_kvaddr =
+		cal_block->cal_offset + acdb_data.kvaddr;
 done:
 	return result;
 }
@@ -750,12 +705,9 @@
 		goto done;
 	}
 
-	cal_block->cal_size =
-		atomic_read(&acdb_data.audvol_cal[path].cal_size);
-	cal_block->cal_paddr =
-		atomic_read(&acdb_data.audvol_cal[path].cal_paddr);
-	cal_block->cal_kvaddr =
-		atomic_read(&acdb_data.audvol_cal[path].cal_kvaddr);
+	cal_block->cal_size = acdb_data.audvol_cal[path].cal_size;
+	cal_block->cal_paddr = acdb_data.audvol_cal[path].cal_paddr;
+	cal_block->cal_kvaddr = acdb_data.audvol_cal[path].cal_kvaddr;
 done:
 	return result;
 }
@@ -766,22 +718,30 @@
 	int result = 0;
 	pr_debug("%s,\n", __func__);
 
+	if (cal_block == NULL) {
+		pr_err("ACDB=> NULL pointer sent to %s\n", __func__);
+		result = -EINVAL;
+		goto done;
+	}
 	if (cal_size > MAX_COL_SIZE) {
-		pr_err("%s: col size is to big %d\n", __func__,
-				cal_size);
+		pr_err("%s: col size is to big %d\n", __func__, cal_size);
+		result = -EINVAL;
+		goto done;
+	}
+	if (acdb_data.col_data[vocproc_type] == NULL) {
+		pr_err("%s: vocproc_type %d data not allocated!\n",
+			__func__, vocproc_type);
 		result = -EINVAL;
 		goto done;
 	}
 	if (copy_from_user(acdb_data.col_data[vocproc_type],
 			(void *)((uint8_t *)cal_block + sizeof(cal_size)),
 			cal_size)) {
-		pr_err("%s: fail to copy col size %d\n",
-			__func__, cal_size);
+		pr_err("%s: fail to copy col size %d\n", __func__, cal_size);
 		result = -EINVAL;
 		goto done;
 	}
-	atomic_set(&acdb_data.vocproc_col_cal[vocproc_type].cal_size,
-		cal_size);
+	acdb_data.vocproc_col_cal[vocproc_type].cal_size = cal_size;
 done:
 	return result;
 }
@@ -797,13 +757,19 @@
 		result = -EINVAL;
 		goto done;
 	}
+	if (acdb_data.col_data[vocproc_type] == NULL) {
+		pr_err("%s: vocproc_type %d data not allocated!\n",
+			__func__, vocproc_type);
+		result = -EINVAL;
+		goto done;
+	}
 
-	cal_block->cal_size = atomic_read(&acdb_data.
-				vocproc_col_cal[vocproc_type].cal_size);
-	cal_block->cal_paddr = atomic_read(&acdb_data.
-				vocproc_col_cal[vocproc_type].cal_paddr);
-	cal_block->cal_kvaddr = atomic_read(&acdb_data.
-				vocproc_col_cal[vocproc_type].cal_kvaddr);
+	cal_block->cal_size = acdb_data.
+		vocproc_col_cal[vocproc_type].cal_size;
+	cal_block->cal_paddr = acdb_data.
+		vocproc_col_cal[vocproc_type].cal_paddr;
+	cal_block->cal_kvaddr = acdb_data.
+		vocproc_col_cal[vocproc_type].cal_kvaddr;
 done:
 	return result;
 }
@@ -815,24 +781,19 @@
 
 
 	if (cal_block->cal_offset >
-				atomic64_read(&acdb_data.mem_len)) {
-		pr_err("%s: offset %d is > mem_len %ld\n",
-			__func__, cal_block->cal_offset,
-			(long)atomic64_read(&acdb_data.mem_len));
-		atomic_set(&acdb_data.vocproc_dev_cal.cal_size, 0);
+				acdb_data.mem_len) {
+		pr_err("%s: offset %d is > mem_len %llu\n",
+			__func__, cal_block->cal_offset, acdb_data.mem_len);
+		acdb_data.vocproc_dev_cal.cal_size = 0;
 		result = -EINVAL;
 		goto done;
 	}
 
-	atomic_set(&acdb_data.vocproc_dev_cal.cal_size,
-		cal_block->cal_size);
-	atomic_set(&acdb_data.vocproc_dev_cal.cal_paddr,
-		cal_block->cal_offset +
-	atomic64_read(&acdb_data.paddr));
-			atomic_set(&acdb_data.vocproc_dev_cal.cal_kvaddr,
-			cal_block->cal_offset +
-			atomic64_read(&acdb_data.kvaddr));
-
+	acdb_data.vocproc_dev_cal.cal_size = cal_block->cal_size;
+	acdb_data.vocproc_dev_cal.cal_paddr =
+		cal_block->cal_offset + acdb_data.paddr;
+	acdb_data.vocproc_dev_cal.cal_kvaddr =
+		cal_block->cal_offset + acdb_data.kvaddr;
 done:
 	return result;
 }
@@ -848,12 +809,9 @@
 		goto done;
 	}
 
-	cal_block->cal_size =
-		atomic_read(&acdb_data.vocproc_dev_cal.cal_size);
-	cal_block->cal_paddr =
-		atomic_read(&acdb_data.vocproc_dev_cal.cal_paddr);
-	cal_block->cal_kvaddr =
-		atomic_read(&acdb_data.vocproc_dev_cal.cal_kvaddr);
+	cal_block->cal_size = acdb_data.vocproc_dev_cal.cal_size;
+	cal_block->cal_paddr = acdb_data.vocproc_dev_cal.cal_paddr;
+	cal_block->cal_kvaddr = acdb_data.vocproc_dev_cal.cal_kvaddr;
 done:
 	return result;
 }
@@ -866,24 +824,19 @@
 	pr_debug("%s,\n", __func__);
 
 	if (cal_block->cal_offset >
-				atomic64_read(&acdb_data.mem_len)) {
-		pr_err("%s: offset %d is > mem_len %ld\n",
-			__func__, cal_block->cal_offset,
-			(long)atomic64_read(&acdb_data.mem_len));
-		atomic_set(&acdb_data.vocproc_cal.cal_size, 0);
+				acdb_data.mem_len) {
+		pr_err("%s: offset %d is > mem_len %llu\n",
+			__func__, cal_block->cal_offset, acdb_data.mem_len);
+		acdb_data.vocproc_cal.cal_size = 0;
 		result = -EINVAL;
 		goto done;
 	}
 
-	atomic_set(&acdb_data.vocproc_cal.cal_size,
-		cal_block->cal_size);
-	atomic_set(&acdb_data.vocproc_cal.cal_paddr,
-		cal_block->cal_offset +
-		atomic64_read(&acdb_data.paddr));
-	atomic_set(&acdb_data.vocproc_cal.cal_kvaddr,
-		cal_block->cal_offset +
-		atomic64_read(&acdb_data.kvaddr));
-
+	acdb_data.vocproc_cal.cal_size = cal_block->cal_size;
+	acdb_data.vocproc_cal.cal_paddr =
+		cal_block->cal_offset + acdb_data.paddr;
+	acdb_data.vocproc_cal.cal_kvaddr =
+		cal_block->cal_offset + acdb_data.kvaddr;
 done:
 	return result;
 }
@@ -899,12 +852,9 @@
 		goto done;
 	}
 
-	cal_block->cal_size =
-		atomic_read(&acdb_data.vocproc_cal.cal_size);
-	cal_block->cal_paddr =
-		atomic_read(&acdb_data.vocproc_cal.cal_paddr);
-	cal_block->cal_kvaddr =
-		atomic_read(&acdb_data.vocproc_cal.cal_kvaddr);
+	cal_block->cal_size = acdb_data.vocproc_cal.cal_size;
+	cal_block->cal_paddr = acdb_data.vocproc_cal.cal_paddr;
+	cal_block->cal_kvaddr = acdb_data.vocproc_cal.cal_kvaddr;
 done:
 	return result;
 }
@@ -915,24 +865,19 @@
 	pr_debug("%s,\n", __func__);
 
 	if (cal_block->cal_offset >
-			atomic64_read(&acdb_data.mem_len)) {
-		pr_err("%s: offset %d is > mem_len %ld\n",
-			__func__, cal_block->cal_offset,
-			(long)atomic64_read(&acdb_data.mem_len));
-		atomic_set(&acdb_data.vocstrm_cal.cal_size, 0);
+			acdb_data.mem_len) {
+		pr_err("%s: offset %d is > mem_len %llu\n",
+			__func__, cal_block->cal_offset, acdb_data.mem_len);
+		acdb_data.vocstrm_cal.cal_size = 0;
 		result = -EINVAL;
 		goto done;
 	}
 
-	atomic_set(&acdb_data.vocstrm_cal.cal_size,
-		cal_block->cal_size);
-	atomic_set(&acdb_data.vocstrm_cal.cal_paddr,
-		cal_block->cal_offset +
-		atomic64_read(&acdb_data.paddr));
-	atomic_set(&acdb_data.vocstrm_cal.cal_kvaddr,
-		cal_block->cal_offset +
-		atomic64_read(&acdb_data.kvaddr));
-
+	acdb_data.vocstrm_cal.cal_size = cal_block->cal_size;
+	acdb_data.vocstrm_cal.cal_paddr =
+		cal_block->cal_offset + acdb_data.paddr;
+	acdb_data.vocstrm_cal.cal_kvaddr =
+		cal_block->cal_offset + acdb_data.kvaddr;
 done:
 	return result;
 }
@@ -948,12 +893,9 @@
 		goto done;
 	}
 
-	cal_block->cal_size =
-		atomic_read(&acdb_data.vocstrm_cal.cal_size);
-	cal_block->cal_paddr =
-		atomic_read(&acdb_data.vocstrm_cal.cal_paddr);
-	cal_block->cal_kvaddr =
-		atomic_read(&acdb_data.vocstrm_cal.cal_kvaddr);
+	cal_block->cal_size = acdb_data.vocstrm_cal.cal_size;
+	cal_block->cal_paddr = acdb_data.vocstrm_cal.cal_paddr;
+	cal_block->cal_kvaddr = acdb_data.vocstrm_cal.cal_kvaddr;
 done:
 	return result;
 }
@@ -963,25 +905,19 @@
 	int result = 0;
 	pr_debug("%s,\n", __func__);
 
-	if (cal_block->cal_offset >
-			atomic64_read(&acdb_data.mem_len)) {
-		pr_err("%s: offset %d is > mem_len %ld\n",
-			__func__, cal_block->cal_offset,
-			(long)atomic64_read(&acdb_data.mem_len));
-		atomic_set(&acdb_data.vocvol_cal.cal_size, 0);
+	if (cal_block->cal_offset > acdb_data.mem_len) {
+		pr_err("%s: offset %d is > mem_len %llu\n",
+			__func__, cal_block->cal_offset, acdb_data.mem_len);
+		acdb_data.vocvol_cal.cal_size = 0;
 		result = -EINVAL;
 		goto done;
 	}
 
-	atomic_set(&acdb_data.vocvol_cal.cal_size,
-		cal_block->cal_size);
-	atomic_set(&acdb_data.vocvol_cal.cal_paddr,
-		cal_block->cal_offset +
-		atomic64_read(&acdb_data.paddr));
-	atomic_set(&acdb_data.vocvol_cal.cal_kvaddr,
-		cal_block->cal_offset +
-		atomic64_read(&acdb_data.kvaddr));
-
+	acdb_data.vocvol_cal.cal_size = cal_block->cal_size;
+	acdb_data.vocvol_cal.cal_paddr =
+		cal_block->cal_offset + acdb_data.paddr;
+	acdb_data.vocvol_cal.cal_kvaddr =
+		cal_block->cal_offset + acdb_data.kvaddr;
 done:
 	return result;
 }
@@ -997,12 +933,9 @@
 		goto done;
 	}
 
-	cal_block->cal_size =
-		atomic_read(&acdb_data.vocvol_cal.cal_size);
-	cal_block->cal_paddr =
-		atomic_read(&acdb_data.vocvol_cal.cal_paddr);
-	cal_block->cal_kvaddr =
-		atomic_read(&acdb_data.vocvol_cal.cal_kvaddr);
+	cal_block->cal_size = acdb_data.vocvol_cal.cal_size;
+	cal_block->cal_paddr = acdb_data.vocvol_cal.cal_paddr;
+	cal_block->cal_kvaddr = acdb_data.vocvol_cal.cal_kvaddr;
 done:
 	return result;
 }
@@ -1011,8 +944,8 @@
 {
 	pr_debug("%s,\n", __func__);
 
-	atomic_set(&acdb_data.sidetone_cal.enable, cal_data->enable);
-	atomic_set(&acdb_data.sidetone_cal.gain, cal_data->gain);
+	acdb_data.sidetone_cal.enable = cal_data->enable;
+	acdb_data.sidetone_cal.gain = cal_data->gain;
 }
 
 int get_sidetone_cal(struct sidetone_cal *cal_data)
@@ -1026,8 +959,10 @@
 		goto done;
 	}
 
-	cal_data->enable = atomic_read(&acdb_data.sidetone_cal.enable);
-	cal_data->gain = atomic_read(&acdb_data.sidetone_cal.gain);
+	mutex_lock(&acdb_data.acdb_mutex);
+	cal_data->enable = acdb_data.sidetone_cal.enable;
+	cal_data->gain = acdb_data.sidetone_cal.gain;
+	mutex_unlock(&acdb_data.acdb_mutex);
 done:
 	return result;
 }
@@ -1111,20 +1046,32 @@
 	s32 result = 0;
 	pr_debug("%s\n", __func__);
 
-	if (atomic64_read(&acdb_data.mem_len)) {
+	mutex_lock(&acdb_data.acdb_mutex);
+	if (acdb_data.mem_len)
 		pr_debug("%s: ACDB opened but memory allocated, using existing allocation!\n",
 			__func__);
-	}
 
-	atomic_set(&acdb_data.valid_adm_custom_top, 1);
-	atomic_set(&acdb_data.valid_asm_custom_top, 1);
-	atomic_inc(&usage_count);
+	acdb_data.valid_adm_custom_top = 1;
+	acdb_data.valid_asm_custom_top = 1;
+	acdb_data.usage_count++;
+	mutex_unlock(&acdb_data.acdb_mutex);
 
 	return result;
 }
 
-static void allocate_hw_delay_entries(void)
+static void deallocate_hw_delay_entries(void)
 {
+	kfree(acdb_data.hw_delay_rx.delay_info);
+	kfree(acdb_data.hw_delay_tx.delay_info);
+
+	acdb_data.hw_delay_rx.delay_info = NULL;
+	acdb_data.hw_delay_tx.delay_info = NULL;
+}
+
+static int allocate_hw_delay_entries(void)
+{
+	int	result = 0;
+
 	/* Allocate memory for hw delay entries */
 	acdb_data.hw_delay_rx.num_entries = 0;
 	acdb_data.hw_delay_tx.num_entries = 0;
@@ -1135,6 +1082,8 @@
 	if (acdb_data.hw_delay_rx.delay_info == NULL) {
 		pr_err("%s : Failed to allocate av sync delay entries rx\n",
 			__func__);
+		result = -ENOMEM;
+		goto done;
 	}
 	acdb_data.hw_delay_tx.delay_info =
 				kmalloc(sizeof(struct hw_delay_entry)*
@@ -1143,7 +1092,44 @@
 	if (acdb_data.hw_delay_tx.delay_info == NULL) {
 		pr_err("%s : Failed to allocate av sync delay entries tx\n",
 			__func__);
+		deallocate_hw_delay_entries();
+		result = -ENOMEM;
+		goto done;
 	}
+done:
+	return result;
+}
+
+static void deallocate_col_data(void)
+{
+	int	i;
+
+	for (i = 0; i < MAX_VOCPROC_TYPES; i++) {
+		kfree(acdb_data.col_data[i]);
+		acdb_data.col_data[i] = NULL;
+	}
+}
+
+static int allocate_col_data(void)
+{
+	int	result = 0;
+	int	i;
+
+	for (i = 0; i < MAX_VOCPROC_TYPES; i++) {
+		acdb_data.col_data[i] = kmalloc(MAX_COL_SIZE, GFP_KERNEL);
+		if (acdb_data.col_data[i] == NULL) {
+			pr_err("%s: kmalloc column data failed, type = %d\n",
+				__func__, i);
+			deallocate_col_data();
+			result = -ENOMEM;
+			goto done;
+		}
+		acdb_data.vocproc_col_cal[i].cal_kvaddr =
+			(uint32_t)acdb_data.col_data[i];
+	}
+
+done:
+	return result;
 }
 
 static int unmap_cal_tables(void)
@@ -1192,81 +1178,81 @@
 static int deregister_memory(void)
 {
 	int	result = 0;
-	int	i;
 	pr_debug("%s\n", __func__);
 
-	mutex_lock(&acdb_data.acdb_mutex);
-	kfree(acdb_data.hw_delay_tx.delay_info);
-	kfree(acdb_data.hw_delay_rx.delay_info);
+	if (acdb_data.mem_len == 0)
+		goto done;
 
-	if (atomic64_read(&acdb_data.mem_len)) {
-		/* unmap all cal data */
-		result = unmap_cal_tables();
-		if (result < 0)
-			pr_err("%s: unmap_cal_tables failed, err = %d\n",
-				__func__, result);
+	pr_debug("Remove existing memory\n");
+	acdb_data.mem_len = 0;
 
-		atomic64_set(&acdb_data.mem_len, 0);
+	/* unmap all cal data */
+	result = unmap_cal_tables();
+	if (result < 0)
+		pr_err("%s: unmap_cal_tables failed, err = %d\n",
+			__func__, result);
 
-		for (i = 0; i < MAX_VOCPROC_TYPES; i++) {
-			kfree(acdb_data.col_data[i]);
-			acdb_data.col_data[i] = NULL;
-		}
-		msm_audio_ion_free(acdb_data.ion_client, acdb_data.ion_handle);
-		acdb_data.ion_client = NULL;
-		acdb_data.ion_handle = NULL;
-		mutex_unlock(&acdb_data.acdb_mutex);
-	}
-	mutex_unlock(&acdb_data.acdb_mutex);
-	return 0;
+	msm_audio_ion_free(acdb_data.ion_client, acdb_data.ion_handle);
+	acdb_data.ion_client = NULL;
+	acdb_data.ion_handle = NULL;
+
+	deallocate_col_data();
+	deallocate_hw_delay_entries();
+done:
+	return result;
 }
 
 static int register_memory(void)
 {
 	int			result;
-	int			i;
 	ion_phys_addr_t		paddr;
 	void                    *kvptr;
 	unsigned long		kvaddr;
 	unsigned long		mem_len;
 	pr_debug("%s\n", __func__);
 
-	mutex_lock(&acdb_data.acdb_mutex);
-	allocate_hw_delay_entries();
-	for (i = 0; i < MAX_VOCPROC_TYPES; i++) {
-		acdb_data.col_data[i] = kmalloc(MAX_COL_SIZE, GFP_KERNEL);
-		atomic_set(&acdb_data.vocproc_col_cal[i].cal_kvaddr,
-			(uint32_t)acdb_data.col_data[i]);
+	result = allocate_col_data();
+	if (result) {
+		pr_err("%s: allocate_hw_delay_entries failed, rc = %d\n",
+			__func__, result);
+		goto err_done;
+	}
+
+	result = allocate_hw_delay_entries();
+	if (result) {
+		pr_err("%s: allocate_hw_delay_entries failed, rc = %d\n",
+			__func__, result);
+		goto err_col;
 	}
 
 	result = msm_audio_ion_import("audio_acdb_client",
 				&acdb_data.ion_client,
 				&acdb_data.ion_handle,
-				atomic_read(&acdb_data.map_handle),
+				acdb_data.map_handle,
 				NULL, 0,
 				&paddr, (size_t *)&mem_len, &kvptr);
 	if (result) {
 		pr_err("%s: audio ION alloc failed, rc = %d\n",
 			__func__, result);
-		result = PTR_ERR(acdb_data.ion_client);
-		goto err_ion_handle;
+		goto err_hw_delay;
 	}
-	kvaddr = (unsigned long)kvptr;
-	atomic64_set(&acdb_data.paddr, paddr);
-	atomic64_set(&acdb_data.kvaddr, kvaddr);
-	atomic64_set(&acdb_data.mem_len, mem_len);
-	mutex_unlock(&acdb_data.acdb_mutex);
 
-	pr_debug("%s done! paddr = 0x%lx, kvaddr = 0x%lx, len = x%lx\n",
-		 __func__,
-		(long)atomic64_read(&acdb_data.paddr),
-		(long)atomic64_read(&acdb_data.kvaddr),
-		(long)atomic64_read(&acdb_data.mem_len));
+	kvaddr = (unsigned long)kvptr;
+	acdb_data.paddr = paddr;
+	acdb_data.kvaddr = kvaddr;
+	acdb_data.mem_len = mem_len;
+
+	pr_debug("%s done! paddr = 0x%llx, kvaddr = 0x%llx, len = 0x%llx\n",
+		 __func__, acdb_data.paddr, acdb_data.kvaddr,
+		 acdb_data.mem_len);
 
 	return result;
-err_ion_handle:
-	atomic64_set(&acdb_data.mem_len, 0);
-	mutex_unlock(&acdb_data.acdb_mutex);
+err_hw_delay:
+	deallocate_hw_delay_entries();
+err_col:
+	deallocate_col_data();
+err_done:
+	acdb_data.mem_len = 0;
 	return result;
 }
 static long acdb_ioctl(struct file *f,
@@ -1281,26 +1267,26 @@
 	struct msm_spk_prot_status acdb_spk_status;
 	pr_debug("%s\n", __func__);
 
+	mutex_lock(&acdb_data.acdb_mutex);
 	switch (cmd) {
 	case AUDIO_REGISTER_PMEM:
 		pr_debug("AUDIO_REGISTER_PMEM\n");
-		if (atomic_read(&acdb_data.mem_len)) {
-			deregister_memory();
-			pr_debug("Remove the existing memory\n");
-		}
+		result = deregister_memory();
+		if (result < 0)
+			pr_err("%s: deregister_memory failed returned %d!\n",
+				__func__, result);
 
 		if (copy_from_user(&map_fd, (void *)arg, sizeof(map_fd))) {
 			pr_err("%s: fail to copy memory handle!\n", __func__);
 			result = -EFAULT;
 		} else {
-			atomic_set(&acdb_data.map_handle, map_fd);
+			acdb_data.map_handle = map_fd;
 			result = register_memory();
 		}
 		goto done;
-
 	case AUDIO_DEREGISTER_PMEM:
 		pr_debug("AUDIO_DEREGISTER_PMEM\n");
-		deregister_memory();
+		result = deregister_memory();
 		goto done;
 	case AUDIO_SET_VOICE_RX_TOPOLOGY:
 		if (copy_from_user(&topology, (void *)arg,
@@ -1343,16 +1329,13 @@
 		store_asm_topology(topology);
 		goto done;
 	case AUDIO_SET_SPEAKER_PROT:
-		mutex_lock(&acdb_data.acdb_mutex);
 		if (copy_from_user(&acdb_data.spk_prot_cfg, (void *)arg,
 				sizeof(acdb_data.spk_prot_cfg))) {
 			pr_err("%s fail to copy spk_prot_cfg\n", __func__);
 			result = -EFAULT;
 		}
-		mutex_unlock(&acdb_data.acdb_mutex);
 		goto done;
 	case AUDIO_GET_SPEAKER_PROT:
-		mutex_lock(&acdb_data.acdb_mutex);
 		/*Indicates calibration was succesfull*/
 		if (acdb_data.spk_prot_cfg.mode == MSM_SPKR_PROT_CALIBRATED) {
 			prot_status.r0 = acdb_data.spk_prot_cfg.r0;
@@ -1379,7 +1362,6 @@
 			sizeof(prot_status))) {
 			pr_err("%s: Failed to update prot_status\n", __func__);
 		}
-		mutex_unlock(&acdb_data.acdb_mutex);
 		goto done;
 	case AUDIO_REGISTER_VOCPROC_VOL_TABLE:
 		result = register_vocvol_table();
@@ -1502,23 +1484,25 @@
 	}
 
 done:
+	mutex_unlock(&acdb_data.acdb_mutex);
 	return result;
 }
 
 static int acdb_mmap(struct file *file, struct vm_area_struct *vma)
 {
 	int result = 0;
-	uint32_t size = vma->vm_end - vma->vm_start;
+	size_t size = vma->vm_end - vma->vm_start;
 
 	pr_debug("%s\n", __func__);
 
-	if (atomic64_read(&acdb_data.mem_len)) {
-		if (size <= atomic64_read(&acdb_data.mem_len)) {
+	mutex_lock(&acdb_data.acdb_mutex);
+	if (acdb_data.mem_len) {
+		if (size <= acdb_data.mem_len) {
 			vma->vm_page_prot = pgprot_noncached(
 						vma->vm_page_prot);
 			result = remap_pfn_range(vma,
 				vma->vm_start,
-				atomic64_read(&acdb_data.paddr) >> PAGE_SHIFT,
+				acdb_data.paddr >> PAGE_SHIFT,
 				size,
 				vma->vm_page_prot);
 		} else {
@@ -1529,25 +1513,29 @@
 		pr_err("%s: memory is not allocated, yet!\n", __func__);
 		result = -ENODEV;
 	}
+	mutex_unlock(&acdb_data.acdb_mutex);
 
 	return result;
 }
 
 static int acdb_release(struct inode *inode, struct file *f)
 {
-	s32 result = 0;
+	int result = 0;
+	pr_debug("%s\n", __func__);
 
-	atomic_dec(&usage_count);
-	atomic_read(&usage_count);
+	mutex_lock(&acdb_data.acdb_mutex);
+	acdb_data.usage_count--;
 
-	pr_debug("%s: ref count %d!\n", __func__,
-		atomic_read(&usage_count));
+	pr_debug("%s: ref count %d!\n", __func__, acdb_data.usage_count);
 
-	if (atomic_read(&usage_count) >= 1)
+	if (acdb_data.usage_count > 0) {
 		result = -EBUSY;
-	else
-		result = deregister_memory();
+		goto done;
+	}
 
+	result = deregister_memory();
+done:
+	mutex_unlock(&acdb_data.acdb_mutex);
 	return result;
 }
 
@@ -1571,9 +1559,9 @@
 	/*Speaker protection disabled*/
 	acdb_data.spk_prot_cfg.mode = MSM_SPKR_PROT_DISABLED;
 	mutex_init(&acdb_data.acdb_mutex);
-	atomic_set(&usage_count, 0);
-	atomic_set(&acdb_data.valid_adm_custom_top, 1);
-	atomic_set(&acdb_data.valid_asm_custom_top, 1);
+	acdb_data.usage_count = 0;
+	acdb_data.valid_adm_custom_top = 1;
+	acdb_data.valid_asm_custom_top = 1;
 
 	return misc_register(&acdb_misc);
 }
diff --git a/sound/soc/msm/qdsp6v2/audio_acdb.h b/sound/soc/msm/qdsp6v2/audio_acdb.h
index e2ca395..45a83f6 100644
--- a/sound/soc/msm/qdsp6v2/audio_acdb.h
+++ b/sound/soc/msm/qdsp6v2/audio_acdb.h
@@ -35,12 +35,6 @@
 	uint32_t		cal_paddr;
 };
 
-struct acdb_atomic_cal_block {
-	atomic_t		cal_size;
-	atomic_t		cal_kvaddr;
-	atomic_t		cal_paddr;
-};
-
 struct hw_delay_entry {
 	uint32_t sample_rate;
 	uint32_t delay_usec;
diff --git a/sound/soc/msm/qdsp6v2/audio_ocmem.c b/sound/soc/msm/qdsp6v2/audio_ocmem.c
index bedaba0..4a25606 100644
--- a/sound/soc/msm/qdsp6v2/audio_ocmem.c
+++ b/sound/soc/msm/qdsp6v2/audio_ocmem.c
@@ -454,6 +454,15 @@
 
 			}
 
+			if (test_bit_pos(audio_ocmem_lcl.audio_state,
+						OCMEM_STATE_DISABLE) ||
+			    test_bit_pos(audio_ocmem_lcl.audio_state,
+			     OCMEM_STATE_FREE)) {
+				pr_info("%s: audio already freed from ocmem, state[0x%x]\n",
+					__func__,
+				atomic_read(&audio_ocmem_lcl.audio_state));
+				goto fail_cmd2;
+			}
 			pr_debug("%s: calling ocmem free, state:0x%x\n",
 				__func__,
 				atomic_read(&audio_ocmem_lcl.audio_state));
@@ -491,7 +500,11 @@
 				ret);
 				goto fail_cmd2;
 			}
-			pr_debug("%s: ocmem_free success\n", __func__);
+			set_bit_pos(audio_ocmem_lcl.audio_state,
+					OCMEM_STATE_FREE);
+			pr_debug("%s: ocmem_free success, state[0x%x]\n",
+				 __func__,
+				 atomic_read(&audio_ocmem_lcl.audio_state));
 		/* Fall through */
 		case OCMEM_STATE_SSR:
 			msm_bus_scale_client_update_request(
@@ -517,6 +530,8 @@
 	ret = ocmem_free(OCMEM_LP_AUDIO, audio_ocmem_lcl.buf);
 	if (ret)
 		pr_err("%s: ocmem_free failed\n", __func__);
+	set_bit_pos(audio_ocmem_lcl.audio_state,
+		    OCMEM_STATE_FREE);
 fail_cmd2:
 	mutex_unlock(&audio_ocmem_lcl.state_process_lock);
 fail_cmd:
@@ -710,7 +725,8 @@
 			audio_ocmem_lcl.ocmem_en = true;
 	}
 
-	if (audio_ocmem_lcl.ocmem_en) {
+	if (audio_ocmem_lcl.ocmem_en &&
+	    (!enable || !audio_ocmem_lcl.audio_ocmem_running)) {
 		if (audio_ocmem_lcl.audio_ocmem_workqueue == NULL) {
 			pr_err("%s: audio ocmem workqueue is NULL\n",
 								__func__);
@@ -863,6 +879,15 @@
 
 	pr_debug("%s\n", __func__);
 
+	audio_ocmem_lcl.audio_hdl = ocmem_notifier_register(OCMEM_LP_AUDIO,
+						&audio_ocmem_client_nb);
+	if (PTR_RET(audio_ocmem_lcl.audio_hdl) == -EPROBE_DEFER)
+		return -EPROBE_DEFER;
+	else if (!audio_ocmem_lcl.audio_hdl) {
+		pr_err("%s: Failed to get ocmem handle %d\n", __func__,
+						OCMEM_LP_AUDIO);
+		return -ENODEV;
+	}
 	subsys_notif_register_notifier("adsp", &anb);
 
 	audio_ocmem_lcl.ocmem_dump_addr =
@@ -875,7 +900,7 @@
 			create_ramdump_device("audio-ocmem", &pdev->dev);
 
 		if (!audio_ocmem_lcl.ocmem_ramdump_dev)
-			pr_err("%s: audio-ocmem ramdump device failed\n",
+			pr_info("%s: audio-ocmem ramdump device failed\n",
 				__func__);
 	} else {
 		pr_err("%s: ocmem dump memory alloc failed\n", __func__);
@@ -887,16 +912,18 @@
 	if (!audio_ocmem_lcl.audio_ocmem_workqueue) {
 		pr_err("%s: Failed to create ocmem audio work queue\n",
 			__func__);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto destroy_ramdump;
 	}
 
 	audio_ocmem_lcl.voice_ocmem_workqueue =
 		alloc_workqueue("ocmem_audio_client_driver_voice",
 					WQ_NON_REENTRANT, 0);
 	if (!audio_ocmem_lcl.voice_ocmem_workqueue) {
-		pr_err("%s: Failed to create ocmem voice work queue\n",
+		pr_info("%s: Failed to create ocmem voice work queue\n",
 			__func__);
-		return -ENOMEM;
+		ret = -ENOMEM;
+		goto destroy_audio_wq;
 	}
 
 	init_waitqueue_head(&audio_ocmem_lcl.audio_wait);
@@ -913,7 +940,7 @@
 	if (ret) {
 		dev_err(&pdev->dev, "%s: failed to populate platform data, rc = %d\n",
 						__func__, ret);
-		return -ENODEV;
+		goto destroy_voice_wq;
 	}
 	audio_ocmem_bus_scale_pdata = dev_get_drvdata(&pdev->dev);
 
@@ -923,16 +950,28 @@
 	if (!audio_ocmem_lcl.audio_ocmem_bus_client) {
 		pr_err("%s: msm_bus_scale_register_client() failed\n",
 		__func__);
-		return -EFAULT;
-	}
-	audio_ocmem_lcl.audio_hdl = ocmem_notifier_register(OCMEM_LP_AUDIO,
-						&audio_ocmem_client_nb);
-	if (audio_ocmem_lcl.audio_hdl == NULL) {
-		pr_err("%s: Failed to get ocmem handle %d\n", __func__,
-						OCMEM_LP_AUDIO);
+		ret = -EFAULT;
+		goto destroy_voice_wq;
 	}
 	audio_ocmem_lcl.lp_memseg_ptr = NULL;
 	return 0;
+destroy_voice_wq:
+	if (audio_ocmem_lcl.voice_ocmem_workqueue) {
+		destroy_workqueue(audio_ocmem_lcl.voice_ocmem_workqueue);
+		audio_ocmem_lcl.voice_ocmem_workqueue = NULL;
+	}
+destroy_audio_wq:
+	if (audio_ocmem_lcl.audio_ocmem_workqueue) {
+		destroy_workqueue(audio_ocmem_lcl.audio_ocmem_workqueue);
+		audio_ocmem_lcl.audio_ocmem_workqueue = NULL;
+	}
+destroy_ramdump:
+	if (audio_ocmem_lcl.ocmem_ramdump_dev)
+		destroy_ramdump_device(audio_ocmem_lcl.ocmem_ramdump_dev);
+	if (audio_ocmem_lcl.ocmem_dump_addr)
+		free_contiguous_memory_by_paddr(
+		    audio_ocmem_lcl.ocmem_dump_addr);
+	return ret;
 }
 
 static int ocmem_audio_client_remove(struct platform_device *pdev)
@@ -945,7 +984,12 @@
 	msm_bus_cl_clear_pdata(audio_ocmem_bus_scale_pdata);
 	ocmem_notifier_unregister(audio_ocmem_lcl.audio_hdl,
 					&audio_ocmem_client_nb);
-	free_contiguous_memory_by_paddr(audio_ocmem_lcl.ocmem_dump_addr);
+	if (audio_ocmem_lcl.ocmem_ramdump_dev)
+		destroy_ramdump_device(audio_ocmem_lcl.ocmem_ramdump_dev);
+	if (audio_ocmem_lcl.ocmem_dump_addr)
+		free_contiguous_memory_by_paddr(
+		    audio_ocmem_lcl.ocmem_dump_addr);
+
 	return 0;
 }
 static const struct of_device_id msm_ocmem_audio_dt_match[] = {
diff --git a/sound/soc/msm/qdsp6v2/msm-compr-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-compr-q6-v2.c
old mode 100644
new mode 100755
index aa6ef6b..bb926ec
--- a/sound/soc/msm/qdsp6v2/msm-compr-q6-v2.c
+++ b/sound/soc/msm/qdsp6v2/msm-compr-q6-v2.c
@@ -51,6 +51,8 @@
 #define COMPRE_OUTPUT_METADATA_SIZE	(sizeof(struct output_meta_data_st))
 #define COMPRESSED_LR_VOL_MAX_STEPS	0x20002000
 
+#define MAX_AC3_PARAM_SIZE		(18*2*sizeof(int))
+
 const DECLARE_TLV_DB_LINEAR(compr_rx_vol_gain, 0,
 			    COMPRESSED_LR_VOL_MAX_STEPS);
 struct snd_msm {
@@ -977,19 +979,25 @@
 			compr->codec = FORMAT_MPEG4_AAC;
 			break;
 		case SND_AUDIOCODEC_AC3: {
-			char params_value[18*2*sizeof(int)];
+			char params_value[MAX_AC3_PARAM_SIZE];
 			int *params_value_data = (int *)params_value;
 			/* 36 is the max param length for ddp */
 			int i;
 			struct snd_dec_ddp *ddp =
 				&compr->info.codec_param.codec.options.ddp;
-			int params_length = ddp->params_length*sizeof(int);
+			uint32_t params_length = ddp->params_length*sizeof(int);
+			if (params_length > MAX_AC3_PARAM_SIZE) {
+				/*MAX is 36*sizeof(int) this should not happen*/
+				pr_err("params_length(%d) is greater than %d",
+				params_length, MAX_AC3_PARAM_SIZE);
+				params_length = MAX_AC3_PARAM_SIZE;
+			}
 			pr_debug("SND_AUDIOCODEC_AC3\n");
 			compr->codec = FORMAT_AC3;
 			if (copy_from_user(params_value, (void *)ddp->params,
 					params_length))
-				pr_err("%s: ERROR: copy ddp params value\n",
-					__func__);
+				pr_err("%s: copy ddp params value, size=%d\n",
+					__func__, params_length);
 			pr_debug("params_length: %d\n", ddp->params_length);
 			for (i = 0; i < params_length; i++)
 				pr_debug("params_value[%d]: %x\n", i,
@@ -1008,19 +1016,25 @@
 			break;
 		}
 		case SND_AUDIOCODEC_EAC3: {
-			char params_value[18*2*sizeof(int)];
+			char params_value[MAX_AC3_PARAM_SIZE];
 			int *params_value_data = (int *)params_value;
 			/* 36 is the max param length for ddp */
 			int i;
 			struct snd_dec_ddp *ddp =
 				&compr->info.codec_param.codec.options.ddp;
-			int params_length = ddp->params_length*sizeof(int);
+			uint32_t params_length = ddp->params_length*sizeof(int);
+			if (params_length > MAX_AC3_PARAM_SIZE) {
+				/*MAX is 36*sizeof(int) this should not happen*/
+				pr_err("params_length(%d) is greater than %d",
+				params_length, MAX_AC3_PARAM_SIZE);
+				params_length = MAX_AC3_PARAM_SIZE;
+			}
 			pr_debug("SND_AUDIOCODEC_EAC3\n");
 			compr->codec = FORMAT_EAC3;
 			if (copy_from_user(params_value, (void *)ddp->params,
 					params_length))
-				pr_err("%s: ERROR: copy ddp params value\n",
-					__func__);
+				pr_err("%s: copy ddp params value, size=%d\n",
+					__func__, params_length);
 			pr_debug("params_length: %d\n", ddp->params_length);
 			for (i = 0; i < ddp->params_length; i++)
 				pr_debug("params_value[%d]: %x\n", i,
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-afe-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-afe-v2.c
index d80ca19..0612805 100644
--- a/sound/soc/msm/qdsp6v2/msm-pcm-afe-v2.c
+++ b/sound/soc/msm/qdsp6v2/msm-pcm-afe-v2.c
@@ -40,8 +40,8 @@
 
 #define MIN_CAPTURE_PERIOD_SIZE (128 * 2 * 4)
 #define MAX_CAPTURE_PERIOD_SIZE (128 * 2 * 2 * 6 * 4)
-#define MIN_CAPTURE_NUM_PERIODS (32)
-#define MAX_CAPTURE_NUM_PERIODS (384)
+#define MIN_CAPTURE_NUM_PERIODS (32 * 4)
+#define MAX_CAPTURE_NUM_PERIODS (384 * 4)
 
 static struct snd_pcm_hardware msm_afe_hardware_playback = {
 	.info =                 (SNDRV_PCM_INFO_MMAP |
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c
index 11326f6..6f3f8ec 100644
--- a/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c
+++ b/sound/soc/msm/qdsp6v2/msm-pcm-q6-v2.c
@@ -396,6 +396,18 @@
 									ret);
 		}
 	}
+	ret = snd_pcm_hw_constraint_step(runtime, 0,
+		SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32);
+	if (ret < 0) {
+		pr_err("constraint for period bytes step ret = %d\n",
+								ret);
+	}
+	ret = snd_pcm_hw_constraint_step(runtime, 0,
+		SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 32);
+	if (ret < 0) {
+		pr_err("constraint for buffer bytes step ret = %d\n",
+								ret);
+	}
 
 	prtd->dsp_cnt = 0;
 	prtd->set_channel_map = false;
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c
index 1b4fae9..d56ad2b 100644
--- a/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c
+++ b/sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c
@@ -54,6 +54,11 @@
 #define SESSION_TYPE_RX 0
 #define SESSION_TYPE_TX 1
 
+#define EC_PORT_ID_PRIMARY_MI2S_TX    1
+#define EC_PORT_ID_SECONDARY_MI2S_TX  2
+#define EC_PORT_ID_TERTIARY_MI2S_TX   3
+#define EC_PORT_ID_QUATERNARY_MI2S_TX 4
+
 static struct mutex routing_lock;
 
 static int fm_switch_enable;
@@ -63,6 +68,7 @@
 static int slim0_rx_aanc_fb_port;
 static int msm_route_ec_ref_rx = 3; /* NONE */
 static uint32_t voc_session_id = ALL_SESSION_VSID;
+static int msm_route_ext_ec_ref = AFE_PORT_INVALID;
 
 enum {
 	MADNONE,
@@ -1369,6 +1375,76 @@
 		     msm_routing_ec_ref_rx_get, msm_routing_ec_ref_rx_put),
 };
 
+static int msm_routing_ext_ec_get(struct snd_kcontrol *kcontrol,
+				  struct snd_ctl_elem_value *ucontrol)
+{
+	pr_debug("%s: ext_ec_ref_rx  = %x\n", __func__, msm_route_ext_ec_ref);
+
+	mutex_lock(&routing_lock);
+	ucontrol->value.integer.value[0] = msm_route_ext_ec_ref;
+	mutex_unlock(&routing_lock);
+	return 0;
+}
+
+static int msm_routing_ext_ec_put(struct snd_kcontrol *kcontrol,
+				  struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
+	struct snd_soc_dapm_widget *widget = wlist->widgets[0];
+	int mux = ucontrol->value.enumerated.item[0];
+	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
+	int ret = 0;
+	bool state = false;
+
+	pr_debug("%s: msm_route_ec_ref_rx = %d value = %ld\n",
+		 __func__, msm_route_ext_ec_ref,
+		 ucontrol->value.integer.value[0]);
+
+	mutex_lock(&routing_lock);
+	switch (ucontrol->value.integer.value[0]) {
+	case EC_PORT_ID_PRIMARY_MI2S_TX:
+		msm_route_ext_ec_ref = AFE_PORT_ID_PRIMARY_MI2S_TX;
+		state = true;
+		break;
+	case EC_PORT_ID_SECONDARY_MI2S_TX:
+		msm_route_ext_ec_ref = AFE_PORT_ID_SECONDARY_MI2S_TX;
+		state = true;
+		break;
+	case EC_PORT_ID_TERTIARY_MI2S_TX:
+		msm_route_ext_ec_ref = AFE_PORT_ID_TERTIARY_MI2S_TX;
+		state = true;
+		break;
+	case EC_PORT_ID_QUATERNARY_MI2S_TX:
+		msm_route_ext_ec_ref = AFE_PORT_ID_QUATERNARY_MI2S_TX;
+		state = true;
+		break;
+	default:
+		msm_route_ext_ec_ref = AFE_PORT_INVALID;
+		break;
+	}
+	if (voc_set_ext_ec_ref(msm_route_ext_ec_ref, state)) {
+		mutex_unlock(&routing_lock);
+		snd_soc_dapm_mux_update_power(widget, kcontrol, 1, mux, e);
+	} else {
+		ret = -EINVAL;
+		mutex_unlock(&routing_lock);
+	}
+	return ret;
+}
+
+static const char * const ext_ec_ref_rx[] = {"NONE", "PRI_MI2S_TX",
+					     "SEC_MI2S_TX", "TERT_MI2S_TX",
+					     "QUAT_MI2S_TX"};
+
+static const struct soc_enum msm_route_ext_ec_ref_rx_enum[] = {
+	SOC_ENUM_SINGLE_EXT(5, ext_ec_ref_rx),
+};
+
+static const struct snd_kcontrol_new voc_ext_ec_mux =
+	SOC_DAPM_ENUM_EXT("VOC_EXT_EC MUX Mux", msm_route_ext_ec_ref_rx_enum[0],
+			  msm_routing_ext_ec_get, msm_routing_ext_ec_put);
+
+
 static const struct snd_kcontrol_new pri_i2s_rx_mixer_controls[] = {
 	SOC_SINGLE_EXT("MultiMedia1", MSM_BACKEND_DAI_PRI_I2S_RX ,
 	MSM_FRONTEND_DAI_MULTIMEDIA1, 1, 0, msm_routing_get_audio_mixer,
@@ -3235,6 +3311,8 @@
 
 	SND_SOC_DAPM_MUX("SLIM0_RX_VI_FB_LCH_MUX", SND_SOC_NOPM, 0, 0,
 				&slim0_rx_vi_fb_lch_mux),
+	SND_SOC_DAPM_MUX("VOC_EXT_EC MUX", SND_SOC_NOPM, 0, 0,
+			 &voc_ext_ec_mux),
 
 };
 
@@ -3524,6 +3602,12 @@
 	{"MI2S_RX_Voice Mixer", "QCHAT", "QCHAT_DL"},
 	{"MI2S_RX", NULL, "MI2S_RX_Voice Mixer"},
 
+	{"VOC_EXT_EC MUX", "PRI_MI2S_TX" , "PRI_MI2S_TX"},
+	{"VOC_EXT_EC MUX", "SEC_MI2S_TX" , "SEC_MI2S_TX"},
+	{"VOC_EXT_EC MUX", "TERT_MI2S_TX" , "TERT_MI2S_TX"},
+	{"VOC_EXT_EC MUX", "QUAT_MI2S_TX" , "QUAT_MI2S_TX"},
+	{"CS-VOICE_UL1", NULL, "VOC_EXT_EC MUX"},
+
 	{"Voice_Tx Mixer", "PRI_TX_Voice", "PRI_I2S_TX"},
 	{"Voice_Tx Mixer", "PRI_MI2S_TX_Voice", "PRI_MI2S_TX"},
 	{"Voice_Tx Mixer", "MI2S_TX_Voice", "MI2S_TX"},
diff --git a/sound/soc/msm/qdsp6v2/q6adm.c b/sound/soc/msm/qdsp6v2/q6adm.c
index 27c74ce..3ee6f6e 100644
--- a/sound/soc/msm/qdsp6v2/q6adm.c
+++ b/sound/soc/msm/qdsp6v2/q6adm.c
@@ -1144,8 +1144,8 @@
 			open.dev_channel_mapping[1] = PCM_CHANNEL_FR;
 		} else if (channel_mode == 3)	{
 			open.dev_channel_mapping[0] = PCM_CHANNEL_FL;
-			open.dev_channel_mapping[0] = PCM_CHANNEL_FR;
-			open.dev_channel_mapping[1] = PCM_CHANNEL_FC;
+			open.dev_channel_mapping[1] = PCM_CHANNEL_FR;
+			open.dev_channel_mapping[2] = PCM_CHANNEL_FC;
 		} else if (channel_mode == 4) {
 			open.dev_channel_mapping[0] = PCM_CHANNEL_FL;
 			open.dev_channel_mapping[1] = PCM_CHANNEL_FR;
diff --git a/sound/soc/msm/qdsp6v2/q6asm.c b/sound/soc/msm/qdsp6v2/q6asm.c
index 9c0c362..7a5efb0 100644
--- a/sound/soc/msm/qdsp6v2/q6asm.c
+++ b/sound/soc/msm/qdsp6v2/q6asm.c
@@ -78,6 +78,12 @@
 void *q6asm_mmap_apr_reg(void);
 
 
+/* for ASM custom topology */
+static struct audio_buffer common_buf[2];
+static struct audio_client common_client;
+static int set_custom_topology;
+static int topology_map_handle;
+
 #ifdef CONFIG_DEBUG_FS
 #define OUT_BUFFER_SIZE 56
 #define IN_BUFFER_SIZE 24
@@ -95,10 +101,6 @@
 static int out_cold_index;
 static char *out_buffer;
 static char *in_buffer;
-static struct audio_buffer common_buf[2];
-static struct audio_client common_client;
-static int set_custom_topology;
-static int topology_map_handle;
 
 
 int q6asm_mmap_apr_dereg(void)
@@ -1223,6 +1225,7 @@
 					data->payload_size))
 				break;
 		case ASM_SESSION_CMD_PAUSE:
+		case ASM_SESSION_CMD_SUSPEND:
 		case ASM_DATA_CMD_EOS:
 		case ASM_STREAM_CMD_CLOSE:
 		case ASM_STREAM_CMD_FLUSH:
@@ -3868,6 +3871,11 @@
 		hdr.opcode = ASM_SESSION_CMD_PAUSE;
 		state = &ac->cmd_state;
 		break;
+	case CMD_SUSPEND:
+		pr_debug("%s:CMD_SUSPEND\n", __func__);
+		hdr.opcode = ASM_SESSION_CMD_SUSPEND;
+		state = &ac->cmd_state;
+		break;
 	case CMD_FLUSH:
 		pr_debug("%s:CMD_FLUSH\n", __func__);
 		hdr.opcode = ASM_STREAM_CMD_FLUSH;
diff --git a/sound/soc/msm/qdsp6v2/q6voice.c b/sound/soc/msm/qdsp6v2/q6voice.c
index 673ecff..5aadfa5 100644
--- a/sound/soc/msm/qdsp6v2/q6voice.c
+++ b/sound/soc/msm/qdsp6v2/q6voice.c
@@ -1861,10 +1861,18 @@
 
 	cvp_setdev_cmd.cvp_set_device_v2.tx_port_id = v->dev_tx.port_id;
 	cvp_setdev_cmd.cvp_set_device_v2.rx_port_id = v->dev_rx.port_id;
-	cvp_setdev_cmd.cvp_set_device_v2.vocproc_mode =
+
+	if (common.ec_ref_ext) {
+		cvp_setdev_cmd.cvp_set_device_v2.vocproc_mode =
+				VSS_IVOCPROC_VOCPROC_MODE_EC_EXT_MIXING;
+		cvp_setdev_cmd.cvp_set_device_v2.ec_ref_port_id =
+				common.ec_port_id;
+	} else {
+		cvp_setdev_cmd.cvp_set_device_v2.vocproc_mode =
 				    VSS_IVOCPROC_VOCPROC_MODE_EC_INT_MIXING;
-	cvp_setdev_cmd.cvp_set_device_v2.ec_ref_port_id =
+		cvp_setdev_cmd.cvp_set_device_v2.ec_ref_port_id =
 				    VSS_IVOCPROC_PORT_ID_NONE;
+	}
 	pr_debug("topology=%d , tx_port_id=%d, rx_port_id=%d\n",
 		cvp_setdev_cmd.cvp_set_device_v2.tx_topology_id,
 		cvp_setdev_cmd.cvp_set_device_v2.tx_port_id,
@@ -3026,10 +3034,17 @@
 	cvp_session_cmd.cvp_session.rx_port_id = v->dev_rx.port_id;
 	cvp_session_cmd.cvp_session.profile_id =
 					 VSS_ICOMMON_CAL_NETWORK_ID_NONE;
-	cvp_session_cmd.cvp_session.vocproc_mode =
+	if (common.ec_ref_ext) {
+		cvp_session_cmd.cvp_session.vocproc_mode =
+				VSS_IVOCPROC_VOCPROC_MODE_EC_EXT_MIXING;
+		cvp_session_cmd.cvp_session.ec_ref_port_id =
+					common.ec_port_id;
+	} else {
+		cvp_session_cmd.cvp_session.vocproc_mode =
 				 VSS_IVOCPROC_VOCPROC_MODE_EC_INT_MIXING;
-	cvp_session_cmd.cvp_session.ec_ref_port_id =
+		cvp_session_cmd.cvp_session.ec_ref_port_id =
 						 VSS_IVOCPROC_PORT_ID_NONE;
+	}
 
 	pr_debug("tx_topology: %d tx_port_id=%d, rx_port_id=%d, mode: 0x%x\n",
 		cvp_session_cmd.cvp_session.tx_topology_id,
@@ -4313,7 +4328,8 @@
 
 		v->voc_state = VOC_CHANGE;
 	}
-
+	if (common.ec_ref_ext)
+		voc_set_ext_ec_ref(AFE_PORT_INVALID, false);
 fail:	mutex_unlock(&v->lock);
 
 	return ret;
@@ -4756,6 +4772,8 @@
 
 		ret = -EINVAL;
 	}
+	if (common.ec_ref_ext)
+		voc_set_ext_ec_ref(AFE_PORT_INVALID, false);
 
 	mutex_unlock(&v->lock);
 	return ret;
@@ -4973,6 +4991,28 @@
 	return ret;
 }
 
+int voc_set_ext_ec_ref(uint16_t port_id, bool state)
+{
+	int ret = 0;
+
+	mutex_lock(&common.common_lock);
+	if (state == true) {
+		if (port_id == AFE_PORT_INVALID) {
+			pr_err("%s: Invalid port id", __func__);
+			ret = -EINVAL;
+			goto exit;
+		}
+		common.ec_port_id = port_id;
+		common.ec_ref_ext = true;
+	} else {
+		common.ec_ref_ext = false;
+		common.ec_port_id = port_id;
+	}
+exit:
+	mutex_unlock(&common.common_lock);
+	return ret;
+}
+
 void voc_register_mvs_cb(ul_cb_fn ul_cb,
 			   dl_cb_fn dl_cb,
 			   void *private_data)
@@ -5807,7 +5847,7 @@
 	common.default_vol_step_val = 0;
 	common.default_vol_ramp_duration_ms = DEFAULT_VOLUME_RAMP_DURATION;
 	common.default_mute_ramp_duration_ms = DEFAULT_MUTE_RAMP_DURATION;
-
+	common.ec_ref_ext = false;
 	/* Initialize MVS info. */
 	common.mvs_info.network_type = VSS_NETWORK_ID_DEFAULT;
 
diff --git a/sound/soc/msm/qdsp6v2/q6voice.h b/sound/soc/msm/qdsp6v2/q6voice.h
index 39f0986..5c0cf21 100644
--- a/sound/soc/msm/qdsp6v2/q6voice.h
+++ b/sound/soc/msm/qdsp6v2/q6voice.h
@@ -1328,6 +1328,8 @@
 	uint32_t default_vol_step_val;
 	uint32_t default_vol_ramp_duration_ms;
 	uint32_t default_mute_ramp_duration_ms;
+	bool ec_ref_ext;
+	uint16_t ec_port_id;
 
 	/* APR to MVM in the Q6 */
 	void *apr_q6_mvm;
@@ -1462,5 +1464,6 @@
 int voc_start_playback(uint32_t set, uint16_t port_id);
 int voc_start_record(uint32_t port_id, uint32_t set, uint32_t session_id);
 int voice_get_idx_for_session(u32 session_id);
+int voc_set_ext_ec_ref(uint16_t port_id, bool state);
 
 #endif
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 55f8dc8..f3f9725 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3229,7 +3229,7 @@
 	mutex_init(&card->mutex);
 	mutex_init(&card->dpcm_mutex);
 	mutex_init(&card->dapm_power_mutex);
-
+	mutex_init(&card->dapm_mutex);
 	ret = snd_soc_instantiate_card(card);
 	if (ret != 0) {
 		soc_cleanup_card_debugfs(card);
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 99047178..63bbbdd 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1866,7 +1866,7 @@
 #endif
 
 /* test and update the power status of a mux widget */
-int snd_soc_dapm_mux_update_power(struct snd_soc_dapm_widget *widget,
+static int soc_dapm_mux_update_power(struct snd_soc_dapm_widget *widget,
 				 struct snd_kcontrol *kcontrol, int change,
 				 int mux, struct soc_enum *e)
 {
@@ -1915,10 +1915,22 @@
 
 	return 0;
 }
+
+int snd_soc_dapm_mux_update_power(struct snd_soc_dapm_widget *widget,
+				 struct snd_kcontrol *kcontrol, int change,
+				 int mux, struct soc_enum *e)
+{
+	struct snd_soc_card *card = widget->dapm->card;
+	int ret;
+	mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_PCM);
+	ret = soc_dapm_mux_update_power(widget, kcontrol, change, mux, e);
+	mutex_unlock(&card->dapm_mutex);
+	return ret;
+}
 EXPORT_SYMBOL_GPL(snd_soc_dapm_mux_update_power);
 
 /* test and update the power status of a mixer or switch widget */
-int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_widget *widget,
+static int soc_dapm_mixer_update_power(struct snd_soc_dapm_widget *widget,
 				   struct snd_kcontrol *kcontrol, int connect)
 {
 	struct snd_soc_dapm_path *path;
@@ -1952,6 +1964,17 @@
 
 	return 0;
 }
+
+int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_widget *widget,
+				   struct snd_kcontrol *kcontrol, int connect)
+{
+	struct snd_soc_card *card = widget->dapm->card;
+	int ret;
+	mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_PCM);
+	ret = soc_dapm_mixer_update_power(widget, kcontrol, connect);
+	mutex_unlock(&card->dapm_mutex);
+	return ret;
+}
 EXPORT_SYMBOL_GPL(snd_soc_dapm_mixer_update_power);
 
 /* show dapm widget status in sys fs */
@@ -2108,6 +2131,8 @@
  */
 int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm)
 {
+	int ret;
+
 	/*
 	 * Suppress early reports (eg, jacks syncing their state) to avoid
 	 * silly DAPM runs during card startup.
@@ -2115,7 +2140,10 @@
 	if (!dapm->card || !dapm->card->instantiated)
 		return 0;
 
-	return dapm_power_widgets(dapm, SND_SOC_DAPM_STREAM_NOP);
+	mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_PCM);
+	ret = dapm_power_widgets(dapm, SND_SOC_DAPM_STREAM_NOP);
+	mutex_unlock(&dapm->card->dapm_mutex);
+	return ret;
 }
 EXPORT_SYMBOL_GPL(snd_soc_dapm_sync);
 
@@ -2279,6 +2307,7 @@
 {
 	int i, ret;
 
+	mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT);
 	for (i = 0; i < num; i++) {
 		ret = snd_soc_dapm_add_route(dapm, route);
 		if (ret < 0) {
@@ -2288,6 +2317,7 @@
 		}
 		route++;
 	}
+	mutex_unlock(&dapm->card->dapm_mutex);
 
 	return 0;
 }
@@ -2360,12 +2390,14 @@
 	int i, err;
 	int ret = 0;
 
+	mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT);
 	for (i = 0; i < num; i++) {
 		err = snd_soc_dapm_weak_route(dapm, route);
 		if (err)
 			ret = err;
 		route++;
 	}
+	mutex_unlock(&dapm->card->dapm_mutex);
 
 	return ret;
 }
@@ -2384,6 +2416,8 @@
 	struct snd_soc_dapm_widget *w;
 	unsigned int val;
 
+	mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT);
+
 	list_for_each_entry(w, &dapm->card->widgets, list)
 	{
 		if (w->new)
@@ -2393,8 +2427,10 @@
 			w->kcontrols = kzalloc(w->num_kcontrols *
 						sizeof(struct snd_kcontrol *),
 						GFP_KERNEL);
-			if (!w->kcontrols)
+			if (!w->kcontrols) {
+				mutex_unlock(&dapm->card->dapm_mutex);
 				return -ENOMEM;
+			}
 		}
 
 		switch(w->id) {
@@ -2434,6 +2470,7 @@
 	}
 
 	dapm_power_widgets(dapm, SND_SOC_DAPM_STREAM_NOP);
+	mutex_unlock(&dapm->card->dapm_mutex);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(snd_soc_dapm_new_widgets);
@@ -2493,6 +2530,7 @@
 	struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
 	struct snd_soc_dapm_widget *widget = wlist->widgets[0];
 	struct snd_soc_codec *codec = widget->codec;
+	struct snd_soc_card *card = codec->card;
 	struct soc_mixer_control *mc =
 		(struct soc_mixer_control *)kcontrol->private_value;
 	unsigned int reg = mc->reg;
@@ -2519,7 +2557,7 @@
 		/* old connection must be powered down */
 		connect = invert ? 1 : 0;
 
-	mutex_lock(&codec->mutex);
+	mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_PCM);
 
 	change = snd_soc_test_bits(widget->codec, reg, mask, val);
 	if (change) {
@@ -2535,13 +2573,13 @@
 			update.val = val;
 			widget->dapm->update = &update;
 
-			snd_soc_dapm_mixer_update_power(widget, kcontrol, connect);
+			soc_dapm_mixer_update_power(widget, kcontrol, connect);
 
 			widget->dapm->update = NULL;
 		}
 	}
 
-	mutex_unlock(&codec->mutex);
+	mutex_unlock(&card->dapm_mutex);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_volsw);
@@ -2590,6 +2628,7 @@
 	struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
 	struct snd_soc_dapm_widget *widget = wlist->widgets[0];
 	struct snd_soc_codec *codec = widget->codec;
+	struct snd_soc_card *card = codec->card;
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
 	unsigned int val, mux, change;
 	unsigned int mask, bitmask;
@@ -2610,7 +2649,7 @@
 		mask |= (bitmask - 1) << e->shift_r;
 	}
 
-	mutex_lock(&codec->mutex);
+	mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_PCM);
 
 	change = snd_soc_test_bits(widget->codec, e->reg, mask, val);
 	if (change) {
@@ -2626,13 +2665,13 @@
 			update.val = val;
 			widget->dapm->update = &update;
 
-			snd_soc_dapm_mux_update_power(widget, kcontrol, change, mux, e);
+			soc_dapm_mux_update_power(widget, kcontrol, change, mux, e);
 
 			widget->dapm->update = NULL;
 		}
 	}
 
-	mutex_unlock(&codec->mutex);
+	mutex_unlock(&card->dapm_mutex);
 	return change;
 }
 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_double);
@@ -2669,6 +2708,7 @@
 	struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
 	struct snd_soc_dapm_widget *widget = wlist->widgets[0];
 	struct snd_soc_codec *codec = widget->codec;
+	struct snd_soc_card *card = codec->card;
 	struct soc_enum *e =
 		(struct soc_enum *)kcontrol->private_value;
 	int change;
@@ -2678,7 +2718,7 @@
 	if (ucontrol->value.enumerated.item[0] >= e->max)
 		return -EINVAL;
 
-	mutex_lock(&codec->mutex);
+	mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_PCM);
 
 	change = widget->value != ucontrol->value.enumerated.item[0];
 	if (change) {
@@ -2687,12 +2727,12 @@
 
 			widget->value = ucontrol->value.enumerated.item[0];
 
-			snd_soc_dapm_mux_update_power(widget, kcontrol, change,
+			soc_dapm_mux_update_power(widget, kcontrol, change,
 					widget->value, e);
 		}
 	}
 
-	mutex_unlock(&codec->mutex);
+	mutex_unlock(&card->dapm_mutex);
 	return ret;
 }
 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_virt);
@@ -2757,6 +2797,7 @@
 	struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
 	struct snd_soc_dapm_widget *widget = wlist->widgets[0];
 	struct snd_soc_codec *codec = widget->codec;
+	struct snd_soc_card *card = codec->card;
 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
 	unsigned int val, mux, change;
 	unsigned int mask;
@@ -2775,7 +2816,7 @@
 		mask |= e->mask << e->shift_r;
 	}
 
-	mutex_lock(&codec->mutex);
+	mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_PCM);
 
 	change = snd_soc_test_bits(widget->codec, e->reg, mask, val);
 	if (change) {
@@ -2791,13 +2832,13 @@
 			update.val = val;
 			widget->dapm->update = &update;
 
-			snd_soc_dapm_mux_update_power(widget, kcontrol, change, mux, e);
+			soc_dapm_mux_update_power(widget, kcontrol, change, mux, e);
 
 			widget->dapm->update = NULL;
 		}
 	}
 
-	mutex_unlock(&codec->mutex);
+	mutex_unlock(&card->dapm_mutex);
 	return change;
 }
 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_value_enum_double);
@@ -2831,15 +2872,15 @@
 int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol,
 				struct snd_ctl_elem_value *ucontrol)
 {
-	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+	struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
 	const char *pin = (const char *)kcontrol->private_value;
 
-	mutex_lock(&codec->mutex);
+	mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_PCM);
 
 	ucontrol->value.integer.value[0] =
-		snd_soc_dapm_get_pin_status(&codec->dapm, pin);
+		snd_soc_dapm_get_pin_status(&card->dapm, pin);
 
-	mutex_unlock(&codec->mutex);
+	mutex_unlock(&card->dapm_mutex);
 
 	return 0;
 }
@@ -2854,20 +2895,19 @@
 int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol,
 				struct snd_ctl_elem_value *ucontrol)
 {
-	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+	struct snd_soc_card *card = snd_kcontrol_chip(kcontrol);
 	const char *pin = (const char *)kcontrol->private_value;
 
-	mutex_lock(&codec->mutex);
+	mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_PCM);
 
 	if (ucontrol->value.integer.value[0])
-		snd_soc_dapm_enable_pin(&codec->dapm, pin);
+		snd_soc_dapm_enable_pin(&card->dapm, pin);
 	else
-		snd_soc_dapm_disable_pin(&codec->dapm, pin);
+		snd_soc_dapm_disable_pin(&card->dapm, pin);
 
-	snd_soc_dapm_sync(&codec->dapm);
+	mutex_unlock(&card->dapm_mutex);
 
-	mutex_unlock(&codec->mutex);
-
+	snd_soc_dapm_sync(&card->dapm);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(snd_soc_dapm_put_pin_switch);
@@ -2975,6 +3015,7 @@
 {
 	int i, ret;
 
+	mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_INIT);
 	for (i = 0; i < num; i++) {
 		ret = snd_soc_dapm_new_control(dapm, widget);
 		if (ret < 0) {
@@ -2985,6 +3026,7 @@
 		}
 		widget++;
 	}
+	mutex_unlock(&dapm->card->dapm_mutex);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(snd_soc_dapm_new_controls);
@@ -3099,7 +3141,6 @@
 	mutex_lock(&codec->mutex);
 	soc_dapm_stream_event(&codec->dapm, stream, event);
 	mutex_unlock(&codec->mutex);
-
 	return 0;
 }
 
diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c
index 9eb96e5..60a401a 100644
--- a/sound/soc/soc-jack.c
+++ b/sound/soc/soc-jack.c
@@ -36,6 +36,7 @@
 int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type,
 		     struct snd_soc_jack *jack)
 {
+	mutex_init(&jack->mutex);
 	jack->codec = codec;
 	INIT_LIST_HEAD(&jack->pins);
 	INIT_LIST_HEAD(&jack->jack_zones);
@@ -75,7 +76,7 @@
 	codec = jack->codec;
 	dapm =  &codec->dapm;
 
-	mutex_lock(&codec->mutex);
+	mutex_lock(&jack->mutex);
 
 	oldstatus = jack->status;
 
@@ -109,7 +110,7 @@
 	snd_jack_report(jack->jack, jack->status);
 
 out:
-	mutex_unlock(&codec->mutex);
+	mutex_unlock(&jack->mutex);
 }
 EXPORT_SYMBOL_GPL(snd_soc_jack_report);